vendors.js 1.2 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625
  1. /*!
  2. Anime.js - IIFE
  3. Version: v4.1.3
  4. Plugin URL: https://animejs.com
  5. License: (c) 2025 Julian Garnier | Released under the MIT license
  6. !*/
  7. var anime=function(t){"use strict";const e="undefined"!=typeof window,s=e?window:null,i=e?document:null,r={replace:0,none:1,blend:2},n=Symbol(),o=Symbol(),a=Symbol(),h=Symbol(),l=Symbol(),c=Symbol(),d=1e-11,u=1e12,p=1e3,m="",f=(()=>{const t=new Map;return t.set("x","translateX"),t.set("y","translateY"),t.set("z","translateZ"),t})(),g=["translateX","translateY","translateZ","rotate","rotateX","rotateY","rotateZ","scale","scaleX","scaleY","scaleZ","skew","skewX","skewY","perspective","matrix","matrix3d"],y=g.reduce(((t,e)=>({...t,[e]:e+"("})),{}),_=()=>{},v=/(^#([\da-f]{3}){1,2}$)|(^#([\da-f]{4}){1,2}$)/i,b=/rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/i,T=/rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(-?\d+|-?\d*.\d+)\s*\)/i,w=/hsl\(\s*(-?\d+|-?\d*.\d+)\s*,\s*(-?\d+|-?\d*.\d+)%\s*,\s*(-?\d+|-?\d*.\d+)%\s*\)/i,S=/hsla\(\s*(-?\d+|-?\d*.\d+)\s*,\s*(-?\d+|-?\d*.\d+)%\s*,\s*(-?\d+|-?\d*.\d+)%\s*,\s*(-?\d+|-?\d*.\d+)\s*\)/i,x=/[-+]?\d*\.?\d+(?:e[-+]?\d)?/gi,k=/^([-+]?\d*\.?\d+(?:e[-+]?\d+)?)([a-z]+|%)$/i,$=/([a-z])([A-Z])/g,C=/(\w+)(\([^)]+\)+)/g,E=/(\*=|\+=|-=)/,B={id:null,keyframes:null,playbackEase:null,playbackRate:1,frameRate:120,loop:0,reversed:!1,alternate:!1,autoplay:!0,duration:p,delay:0,loopDelay:0,ease:"out(2)",composition:r.replace,modifier:t=>t,onBegin:_,onBeforeUpdate:_,onUpdate:_,onLoop:_,onPause:_,onComplete:_,onRender:_},L={current:null,root:i},D={defaults:B,precision:4,timeScale:1,tickThreshold:200},A={version:"4.1.3",engine:null};e&&(s.AnimeJS||(s.AnimeJS=[]),s.AnimeJS.push(A));const N=t=>t.replace($,"$1-$2").toLowerCase(),F=(t,e)=>0===t.indexOf(e),O=Date.now,P=Array.isArray,R=t=>t&&t.constructor===Object,M=t=>"number"==typeof t&&!isNaN(t),I=t=>"string"==typeof t,z=t=>"function"==typeof t,Y=t=>void 0===t,X=t=>Y(t)||null===t,W=t=>e&&t instanceof SVGElement,V=t=>v.test(t),H=t=>F(t,"rgb"),U=t=>F(t,"hsl"),q=t=>!D.defaults.hasOwnProperty(t),Q=t=>I(t)?parseFloat(t):t,j=Math.pow,G=Math.sqrt,Z=Math.sin,J=Math.cos,K=Math.abs,tt=Math.exp,et=Math.ceil,st=Math.floor,it=Math.asin,rt=Math.max,nt=Math.atan2,ot=Math.PI,at=Math.round,ht=(t,e,s)=>t<e?e:t>s?s:t,lt={},ct=(t,e)=>{if(e<0)return t;if(!e)return at(t);let s=lt[e];return s||(s=lt[e]=10**e),at(t*s)/s},dt=(t,e)=>P(e)?e.reduce(((e,s)=>K(s-t)<K(e-t)?s:e)):e?at(t/e)*e:t,ut=(t,e,s)=>t+(e-t)*s,pt=(t,e,s)=>{const i=10**(s||0);return st((Math.random()*(e-t+1/i)+t)*i)/i},mt=t=>{let e,s,i=t.length;for(;i;)s=pt(0,--i),e=t[i],t[i]=t[s],t[s]=e;return t},ft=t=>t===1/0?u:t===-1/0?-1e12:t,gt=t=>t<=d?d:ft(ct(t,11)),yt=t=>P(t)?[...t]:t,_t=(t,e)=>{const s={...t};for(let i in e){const r=t[i];s[i]=Y(r)?e[i]:r}return s},vt=(t,e,s,i="_prev",r="_next")=>{let n=t._head,o=r;for(s&&(n=t._tail,o=i);n;){const t=n[o];e(n),n=t}},bt=(t,e,s="_prev",i="_next")=>{const r=e[s],n=e[i];r?r[i]=n:t._head=n,n?n[s]=r:t._tail=r,e[s]=null,e[i]=null},Tt=(t,e,s,i="_prev",r="_next")=>{let n=t._tail;for(;n&&s&&s(n,e);)n=n[i];const o=n?n[r]:t._head;n?n[r]=e:t._head=e,o?o[i]=e:t._tail=e,e[i]=n,e[r]=o},wt=t=>{let e;return(...s)=>{let i,r,n,o;e&&(i=e.currentIteration,r=e.iterationProgress,n=e.reversed,o=e._alternate,e.revert());const a=t(...s);return a&&!z(a)&&a.revert&&(e=a),Y(r)||(e.currentIteration=i,e.iterationProgress=(o&&i%2?!n:n)?1-r:r),a||_}};class St{constructor(t=0){this.deltaTime=0,this._currentTime=t,this._elapsedTime=t,this._startTime=t,this._lastTime=t,this._scheduledTime=0,this._frameDuration=ct(p/120,0),this._fps=120,this._speed=1,this._hasChildren=!1,this._head=null,this._tail=null}get fps(){return this._fps}set fps(t){const e=this._frameDuration,s=+t,i=s<d?d:s,r=ct(p/i,0);this._fps=i,this._frameDuration=r,this._scheduledTime+=r-e}get speed(){return this._speed}set speed(t){const e=+t;this._speed=e<d?d:e}requestTick(t){const e=this._scheduledTime,s=this._elapsedTime;if(this._elapsedTime+=t-s,s<e)return 0;const i=this._frameDuration,r=s-e;return this._scheduledTime+=r<i?i:r,1}computeDeltaTime(t){const e=t-this._lastTime;return this.deltaTime=e,this._lastTime=t,e}}const xt=(t,e,s,i,n)=>{const o=t.parent,a=t.duration,l=t.completed,c=t.iterationDuration,u=t.iterationCount,p=t._currentIteration,f=t._loopDelay,g=t._reversed,_=t._alternate,v=t._hasChildren,b=t._delay,T=t._currentTime,w=b+c,S=e-b,x=ht(T,-b,a),k=ht(S,-b,a),$=S-T,C=k>0,E=k>=a,B=a<=d,L=2===n;let A=0,N=S,F=0;if(u>1){const e=~~(k/(c+(E?0:f)));t._currentIteration=ht(e,0,u),E&&t._currentIteration--,A=t._currentIteration%2,N=k%(c+f)||0}const O=g^(_&&A),P=t._ease;let R=E?O?0:a:O?c-N:N;P&&(R=c*P(R/c)||0);const M=(o?o.backwards:S<T)?!O:!!O;if(t._currentTime=S,t._iterationTime=R,t.backwards=M,C&&!t.began?(t.began=!0,s||o&&(M||!o.began)||t.onBegin(t)):S<=0&&(t.began=!1),s||v||!C||t._currentIteration===p||t.onLoop(t),L||1===n&&(e>=b&&e<=w||e<=b&&x>b||e>=w&&x!==a)||R>=w&&x!==a||R<=b&&x>0||e<=x&&x===a&&l||E&&!l&&B){if(C&&(t.computeDeltaTime(x),s||t.onBeforeUpdate(t)),!v){const e=L||(M?-1*$:$)>=D.tickThreshold,n=t._offset+(o?o._offset:0)+b+R;let a,l,c,d,u=t._head,p=0;for(;u;){const t=u._composition,s=u._currentTime,o=u._changeDuration,f=u._absoluteStartTime+u._changeDuration,g=u._nextRep,_=u._prevRep,v=t!==r.none;if((e||(s!==o||n<=f+(g?g._delay:0))&&(0!==s||n>=u._absoluteStartTime))&&(!v||!u._isOverridden&&(!u._isOverlapped||n<=f)&&(!g||g._isOverridden||n<=g._absoluteStartTime)&&(!_||_._isOverridden||n>=_._absoluteStartTime+_._changeDuration+u._delay))){const e=u._currentTime=ht(R-u._startTime,0,o),s=u._ease(e/u._updateDuration),n=u._modifier,m=u._valueType,f=u._tweenType,g=0===f,y=0===m,_=y&&g||0===s||1===s?-1:D.precision;let b,T;if(y)b=T=n(ct(ut(u._fromNumber,u._toNumber,s),_));else if(1===m)T=n(ct(ut(u._fromNumber,u._toNumber,s),_)),b=`${T}${u._unit}`;else if(2===m){const t=u._fromNumbers,e=u._toNumbers,i=ct(ht(n(ut(t[0],e[0],s)),0,255),0),r=ct(ht(n(ut(t[1],e[1],s)),0,255),0),o=ct(ht(n(ut(t[2],e[2],s)),0,255),0),a=ht(n(ct(ut(t[3],e[3],s),_)),0,1);if(b=`rgba(${i},${r},${o},${a})`,v){const t=u._numbers;t[0]=i,t[1]=r,t[2]=o,t[3]=a}}else if(3===m){b=u._strings[0];for(let t=0,e=u._toNumbers.length;t<e;t++){const e=n(ct(ut(u._fromNumbers[t],u._toNumbers[t],s),_)),i=u._strings[t+1];b+=`${i?e+i:e}`,v&&(u._numbers[t]=e)}}if(v&&(u._number=T),i||t===r.blend)u._value=b;else{const t=u.property;a=u.target,g?a[t]=b:1===f?a.setAttribute(t,b):(l=a.style,3===f?(a!==c&&(c=a,d=a[h]),d[t]=b,p=1):2===f?l[t]=b:4===f&&l.setProperty(t,b)),C&&(F=1)}}if(p&&u._renderTransforms){let t=m;for(let e in d)t+=`${y[e]}${d[e]}) `;l.transform=t,p=0}u=u._next}!s&&F&&t.onRender(t)}!s&&C&&t.onUpdate(t)}return o&&B?!s&&(o.began&&!M&&S>=a&&!l||M&&S<=d&&l)&&(t.onComplete(t),t.completed=!M):C&&E?u===1/0?t._startTime+=t.duration:t._currentIteration>=u-1&&(t.paused=!0,l||v||(t.completed=!0,s||o&&(M||!o.began)||(t.onComplete(t),t._resolve(t)))):t.completed=!1,F},kt=(t,e,s,i,r)=>{const n=t._currentIteration;if(xt(t,e,s,i,r),t._hasChildren){const o=t,a=o.backwards,h=i?e:o._iterationTime,l=O();let c=0,u=!0;if(!i&&o._currentIteration!==n){const t=o.iterationDuration;vt(o,(e=>{if(a){const i=e.duration,r=e._offset+e._delay;s||!(i<=d)||r&&r+i!==t||e.onComplete(e)}else!e.completed&&!e.backwards&&e._currentTime<e.iterationDuration&&xt(e,t,s,1,2),e.began=!1,e.completed=!1})),s||o.onLoop(o)}vt(o,(t=>{const e=ct((h-t._offset)*t._speed,12),n=t._fps<o._fps?t.requestTick(l):r;c+=xt(t,e,s,i,n),!t.completed&&u&&(u=!1)}),a),!s&&c&&o.onRender(o),(u||a)&&o._currentTime>=o.duration&&(o.paused=!0,o.completed||(o.completed=!0,s||(o.onComplete(o),o._resolve(o))))}},$t={animation:null,update:_},Ct=(()=>e?requestAnimationFrame:setImmediate)(),Et=(()=>e?cancelAnimationFrame:clearImmediate)();class Bt extends St{constructor(t){super(t),this.useDefaultMainLoop=!0,this.pauseOnDocumentHidden=!0,this.defaults=B,this.paused=!0,this.reqId=0}update(){const t=this._currentTime=O();if(this.requestTick(t)){this.computeDeltaTime(t);const e=this._speed,s=this._fps;let i=this._head;for(;i;){const r=i._next;i.paused?(bt(this,i),this._hasChildren=!!this._tail,i._running=!1,i.completed&&!i._cancelled&&i.cancel()):kt(i,(t-i._startTime)*i._speed*e,0,0,i._fps<s?i.requestTick(t):1),i=r}$t.update()}}wake(){return this.useDefaultMainLoop&&!this.reqId&&(this.requestTick(O()),this.reqId=Ct(Dt)),this}pause(){if(this.reqId)return this.paused=!0,At()}resume(){if(this.paused)return this.paused=!1,vt(this,(t=>t.resetTime())),this.wake()}get speed(){return this._speed*(1===D.timeScale?1:p)}set speed(t){this._speed=t*D.timeScale,vt(this,(t=>t.speed=t._speed))}get timeUnit(){return 1===D.timeScale?"ms":"s"}set timeUnit(t){const e="s"===t,s=e?.001:1;if(D.timeScale!==s){D.timeScale=s,D.tickThreshold=200*s;const t=e?.001:p;this.defaults.duration*=t,this._speed*=t}}get precision(){return D.precision}set precision(t){D.precision=t}}const Lt=(()=>{const t=new Bt(O());return e&&(A.engine=t,i.addEventListener("visibilitychange",(()=>{t.pauseOnDocumentHidden&&(i.hidden?t.pause():t.resume())}))),t})(),Dt=()=>{Lt._head?(Lt.reqId=Ct(Dt),Lt.update()):Lt.reqId=0},At=()=>(Et(Lt.reqId),Lt.reqId=0,Lt);function Nt(t){const e=I(t)?L.root.querySelectorAll(t):t;if(e instanceof NodeList||e instanceof HTMLCollection)return e}function Ft(t){if(X(t))return[];if(!e)return P(t)&&t.flat(1/0)||[t];if(P(t)){const e=t.flat(1/0),s=[];for(let t=0,i=e.length;t<i;t++){const i=e[t];if(!X(i)){const t=Nt(i);if(t)for(let e=0,i=t.length;e<i;e++){const i=t[e];if(!X(i)){let t=!1;for(let e=0,r=s.length;e<r;e++)if(s[e]===i){t=!0;break}t||s.push(i)}}else{let t=!1;for(let e=0,r=s.length;e<r;e++)if(s[e]===i){t=!0;break}t||s.push(i)}}}return s}const s=Nt(t);return s?Array.from(s):[t]}function Ot(t){const e=Ft(t),s=e.length;if(s)for(let t=0;t<s;t++){const s=e[t];if(!s[n]){s[n]=!0;const t=W(s);(s.nodeType||t)&&(s[o]=!0,s[a]=t,s[h]={})}}return e}const Pt=t=>{const e=Ft(t)[0];if(e&&W(e))return e},Rt=(t,e,s=0)=>t.getPointAtLength(e+s>=1?e+s:0),Mt=(t,e)=>s=>{const i=+t.getTotalLength(),r=s[a],n=t.getCTM();return{from:0,to:i,modifier:s=>{if("a"===e){const e=Rt(t,s,-1),i=Rt(t,s,1);return 180*nt(i.y-e.y,i.x-e.x)/ot}{const i=Rt(t,s,0);return"x"===e?r||!n?i.x:i.x*n.a+i.y*n.c+n.e:r||!n?i.y:i.x*n.b+i.y*n.d+n.f}}}},It=["opacity","rotate","overflow","color"],zt={morphTo:(t,e=.33)=>s=>{const i=Pt(t);if(!i)return;const r="path"===s.tagName,n=r?" ":",",o=s[l];o&&s.setAttribute(r?"d":"points",o);let a="",h="";if(e){const t=s.getTotalLength(),o=i.getTotalLength(),l=Math.max(Math.ceil(t*e),Math.ceil(o*e));for(let e=0;e<l;e++){const c=e/(l-1),d=s.getPointAtLength(t*c),u=i.getPointAtLength(o*c),p=r?0===e?"M":"L":"";a+=p+ct(d.x,3)+n+d.y+" ",h+=p+ct(u.x,3)+n+u.y+" "}}else a=s.getAttribute(r?"d":"points"),h=i.getAttribute(r?"d":"points");return s[l]=h,[a,h]},createMotionPath:t=>{const e=Pt(t);if(e)return{translateX:Mt(e,"x"),translateY:Mt(e,"y"),rotate:Mt(e,"a")}},createDrawable:(t,e=0,s=0)=>Ft(t).map((t=>((t,e,s)=>{const i=p,r=getComputedStyle(t),n=r.strokeLinecap,o="non-scaling-stroke"===r.vectorEffect?t:null;let a=n;const h=new Proxy(t,{get(t,e){const s=t[e];return e===c?t:"setAttribute"===e?(...e)=>{if("draw"===e[0]){const s=e[1].split(" "),r=+s[0],h=+s[1],l=(t=>{let e=1;if(t&&t.getCTM){const s=t.getCTM();s&&(e=(G(s.a*s.a+s.b*s.b)+G(s.c*s.c+s.d*s.d))/2)}return e})(o),c=-1e3*r*l,d=h*i*l+c,u=i*l+(0===r&&1===h||1===r&&0===h?0:10*l)-d;if("butt"!==n){const e=r===h?"butt":n;a!==e&&(t.style.strokeLinecap=`${e}`,a=e)}t.setAttribute("stroke-dashoffset",`${c}`),t.setAttribute("stroke-dasharray",`${d} ${u}`)}return Reflect.apply(s,t,e)}:z(s)?(...e)=>Reflect.apply(s,t,e):s}});return"1000"!==t.getAttribute("pathLength")&&(t.setAttribute("pathLength","1000"),h.setAttribute("draw",`${e} ${s}`)),h})(t,e,s)))},Yt=(t,e,s)=>(s<0&&(s+=1),s>1&&(s-=1),s<1/6?t+6*(e-t)*s:s<.5?e:s<2/3?t+(e-t)*(2/3-s)*6:t),Xt=(t,e)=>Y(t)?e:t,Wt=(t,e,s,i,r)=>{if(z(t)){const n=()=>{const r=t(e,s,i);return isNaN(+r)?r||0:+r};return r&&(r.func=n),n()}return t},Vt=(t,e)=>t[o]?t[a]&&((t,e)=>{if(It.includes(e))return!1;if(t.getAttribute(e)||e in t){if("scale"===e){const e=t.parentNode;return e&&"filter"===e.tagName}return!0}})(t,e)?1:g.includes(e)||f.get(e)?3:F(e,"--")?4:e in t.style?2:e in t?0:1:0,Ht=(t,e,s)=>{const i=t.style[e];i&&s&&(s[e]=i);const r=i||getComputedStyle(t[c]||t).getPropertyValue(e);return"auto"===r?"0":r},Ut=(t,e,s,i)=>{const r=Y(s)?Vt(t,e):s;return 0===r?t[e]||0:1===r?t.getAttribute(e):3===r?((t,e,s)=>{const i=t.style.transform;let r;if(i){const n=t[h];let o;for(;o=C.exec(i);){const t=o[1],i=o[2].slice(1,-1);n[t]=i,t===e&&(r=i,s&&(s[e]=i))}}return i&&!Y(r)?r:F(e,"scale")?"1":F(e,"rotate")||F(e,"skew")?"0deg":"0px"})(t,e,i):4===r?Ht(t,e,i).trimStart():Ht(t,e,i)},qt=(t,e,s)=>"-"===s?t-e:"+"===s?t+e:t*e,Qt=(t,e)=>{if(e.t=0,e.n=0,e.u=null,e.o=null,e.d=null,e.s=null,!t)return e;const s=+t;if(isNaN(s)){let s=t;"="===s[1]&&(e.o=s[0],s=s.slice(2));const n=!s.includes(" ")&&k.exec(s);if(n)return e.t=1,e.n=+n[1],e.u=n[2],e;if(e.o)return e.n=+s,e;if(V(r=s)||H(r)||U(r))return e.t=2,e.d=H(i=s)?(t=>{const e=b.exec(t)||T.exec(t),s=Y(e[4])?1:+e[4];return[+e[1],+e[2],+e[3],s]})(i):V(i)?(t=>{const e=t.length,s=4===e||5===e;return[+("0x"+t[1]+t[s?1:2]),+("0x"+t[s?2:3]+t[s?2:4]),+("0x"+t[s?3:5]+t[s?3:6]),5===e||9===e?+(+("0x"+t[s?4:7]+t[s?4:8])/255).toFixed(3):1]})(i):U(i)?(t=>{const e=w.exec(t)||S.exec(t),s=+e[1]/360,i=+e[2]/100,r=+e[3]/100,n=Y(e[4])?1:+e[4];let o,a,h;if(0===i)o=a=h=r;else{const t=r<.5?r*(1+i):r+i-r*i,e=2*r-t;o=ct(255*Yt(e,t,s+1/3),0),a=ct(255*Yt(e,t,s),0),h=ct(255*Yt(e,t,s-1/3),0)}return[o,a,h,n]})(i):[0,0,0,1],e;{const t=s.match(x);return e.t=3,e.d=t?t.map(Number):[],e.s=s.split(x)||[],e}}var i,r;return e.n=s,e},jt=(t,e)=>(e.t=t._valueType,e.n=t._toNumber,e.u=t._unit,e.o=null,e.d=yt(t._toNumbers),e.s=yt(t._strings),e),Gt={t:0,n:0,u:null,o:null,d:null,s:null},Zt={_rep:new WeakMap,_add:new Map},Jt=(t,e,s="_rep")=>{const i=Zt[s];let r=i.get(t);return r||(r={},i.set(t,r)),r[e]?r[e]:r[e]={_head:null,_tail:null}},Kt=(t,e)=>t._isOverridden||t._absoluteStartTime>e._absoluteStartTime,te=t=>{t._isOverlapped=1,t._isOverridden=1,t._changeDuration=d,t._currentTime=d},ee=(t,e)=>{const s=t._composition;if(s===r.replace){const s=t._absoluteStartTime;Tt(e,t,Kt,"_prevRep","_nextRep");const i=t._prevRep;if(i){const e=i.parent,r=i._absoluteStartTime+i._changeDuration;if(t.parent.id!==e.id&&e.iterationCount>1&&r+(e.duration-e.iterationDuration)>s){te(i);let t=i._prevRep;for(;t&&t.parent.id===e.id;)te(t),t=t._prevRep}const n=s-t._delay;if(r>n){const t=i._startTime,e=r-(t+i._updateDuration),s=ct(n-e-t,12);i._changeDuration=s,i._currentTime=s,i._isOverlapped=1,s<d&&te(i)}let o=!0;if(vt(e,(t=>{t._isOverlapped||(o=!1)})),o){const t=e.parent;if(t){let s=!0;vt(t,(t=>{t!==e&&vt(t,(t=>{t._isOverlapped||(s=!1)}))})),s&&t.cancel()}else e.cancel()}}}else if(s===r.blend){const e=Jt(t.target,t.property,"_add"),s=(t=>{let e=$t.animation;return e||(e={duration:d,computeDeltaTime:_,_offset:0,_delay:0,_head:null,_tail:null},$t.animation=e,$t.update=()=>{t.forEach((t=>{for(let e in t){const s=t[e],i=s._head;if(i){const t=i._valueType,e=3===t||2===t?yt(i._fromNumbers):null;let r=i._fromNumber,n=s._tail;for(;n&&n!==i;){if(e)for(let t=0,s=n._numbers.length;t<s;t++)e[t]+=n._numbers[t];else r+=n._number;n=n._prevAdd}i._toNumber=r,i._toNumbers=e}}})),xt(e,1,1,0,2)}),e})(Zt._add);let i=e._head;i||(i={...t},i._composition=r.replace,i._updateDuration=d,i._startTime=0,i._numbers=yt(t._fromNumbers),i._number=0,i._next=null,i._prev=null,Tt(e,i),Tt(s,i));const n=t._toNumber;if(t._fromNumber=i._fromNumber-n,t._toNumber=0,t._numbers=yt(t._fromNumbers),t._number=0,i._fromNumber=n,t._toNumbers){const e=yt(t._toNumbers);e&&e.forEach(((e,s)=>{t._fromNumbers[s]=i._fromNumbers[s]-e,t._toNumbers[s]=0})),i._fromNumbers=e}Tt(e,t,null,"_prevAdd","_nextAdd")}return t},se=t=>{const e=t._composition;if(e!==r.none){const s=t.target,i=t.property,n=Zt._rep.get(s)[i];if(bt(n,t,"_prevRep","_nextRep"),e===r.blend){const e=Zt._add,r=e.get(s);if(!r)return;const n=r[i],o=$t.animation;bt(n,t,"_prevAdd","_nextAdd");const a=n._head;if(a&&a===n._tail){bt(n,a,"_prevAdd","_nextAdd"),bt(o,a);let t=!0;for(let e in r)if(r[e]._head){t=!1;break}t&&e.delete(s)}}}return t},ie=t=>(t.paused=!0,t.began=!1,t.completed=!1,t),re=t=>t._cancelled?(t._hasChildren?vt(t,re):vt(t,(t=>{t._composition!==r.none&&ee(t,Jt(t.target,t.property))})),t._cancelled=0,t):t;let ne=0;class oe extends St{constructor(t={},e=null,s=0){super(0);const{id:i,delay:r,duration:n,reversed:o,alternate:a,loop:h,loopDelay:l,autoplay:c,frameRate:u,playbackRate:p,onComplete:m,onLoop:f,onPause:g,onBegin:y,onBeforeUpdate:v,onUpdate:b}=t;L.current&&L.current.register(this);const T=e?0:Lt._elapsedTime,w=e?e.defaults:D.defaults,S=z(r)||Y(r)?w.delay:+r,x=z(n)||Y(n)?1/0:+n,k=Xt(h,w.loop),$=Xt(l,w.loopDelay),C=!0===k||k===1/0||k<0?1/0:k+1;let E=0;e?E=s:(Lt.reqId||Lt.requestTick(O()),E=(Lt._elapsedTime-Lt._startTime)*D.timeScale),this.id=Y(i)?++ne:i,this.parent=e,this.duration=ft((x+$)*C-$)||d,this.backwards=!1,this.paused=!0,this.began=!1,this.completed=!1,this.onBegin=y||w.onBegin,this.onBeforeUpdate=v||w.onBeforeUpdate,this.onUpdate=b||w.onUpdate,this.onLoop=f||w.onLoop,this.onPause=g||w.onPause,this.onComplete=m||w.onComplete,this.iterationDuration=x,this.iterationCount=C,this._autoplay=!e&&Xt(c,w.autoplay),this._offset=E,this._delay=S,this._loopDelay=$,this._iterationTime=0,this._currentIteration=0,this._resolve=_,this._running=!1,this._reversed=+Xt(o,w.reversed),this._reverse=this._reversed,this._cancelled=0,this._alternate=Xt(a,w.alternate),this._prev=null,this._next=null,this._elapsedTime=T,this._startTime=T,this._lastTime=T,this._fps=Xt(u,w.frameRate),this._speed=Xt(p,w.playbackRate)}get cancelled(){return!!this._cancelled}set cancelled(t){t?this.cancel():this.reset(1).play()}get currentTime(){return ht(ct(this._currentTime,D.precision),-this._delay,this.duration)}set currentTime(t){const e=this.paused;this.pause().seek(+t),e||this.resume()}get iterationCurrentTime(){return ct(this._iterationTime,D.precision)}set iterationCurrentTime(t){this.currentTime=this.iterationDuration*this._currentIteration+t}get progress(){return ht(ct(this._currentTime/this.duration,10),0,1)}set progress(t){this.currentTime=this.duration*t}get iterationProgress(){return ht(ct(this._iterationTime/this.iterationDuration,10),0,1)}set iterationProgress(t){const e=this.iterationDuration;this.currentTime=e*this._currentIteration+e*t}get currentIteration(){return this._currentIteration}set currentIteration(t){this.currentTime=this.iterationDuration*ht(+t,0,this.iterationCount-1)}get reversed(){return!!this._reversed}set reversed(t){t?this.reverse():this.play()}get speed(){return super.speed}set speed(t){super.speed=t,this.resetTime()}reset(t=0){return re(this),this._reversed&&!this._reverse&&(this.reversed=!1),this._iterationTime=this.iterationDuration,kt(this,0,1,t,2),ie(this),this._hasChildren&&vt(this,ie),this}init(t=0){this.fps=this._fps,this.speed=this._speed,!t&&this._hasChildren&&kt(this,this.duration,1,t,2),this.reset(t);const e=this._autoplay;return!0===e?this.resume():e&&!Y(e.linked)&&e.link(this),this}resetTime(){const t=1/(this._speed*Lt._speed);return this._startTime=O()-(this._currentTime+this._delay)*t,this}pause(){return this.paused||(this.paused=!0,this.onPause(this)),this}resume(){return this.paused?(this.paused=!1,this.duration<=d&&!this._hasChildren?kt(this,d,0,0,2):(this._running||(Tt(Lt,this),Lt._hasChildren=!0,this._running=!0),this.resetTime(),this._startTime-=12,Lt.wake()),this):this}restart(){return this.reset(0).resume()}seek(t,e=0,s=0){re(this),this.completed=!1;const i=this.paused;return this.paused=!0,kt(this,t+this._delay,~~e,~~s,1),i?this:this.resume()}alternate(){const t=this._reversed,e=this.iterationCount,s=this.iterationDuration,i=e===1/0?st(u/s):e;return this._reversed=+(!this._alternate||i%2?!t:t),e===1/0?this.iterationProgress=this._reversed?1-this.iterationProgress:this.iterationProgress:this.seek(s*i-this._currentTime),this.resetTime(),this}play(){return this._reversed&&this.alternate(),this.resume()}reverse(){return this._reversed||this.alternate(),this.resume()}cancel(){return this._hasChildren?vt(this,(t=>t.cancel()),!0):vt(this,se),this._cancelled=1,this.pause()}stretch(t){const e=this.duration,s=gt(t);if(e===s)return this;const i=t/e,r=t<=d;return this.duration=r?d:s,this.iterationDuration=r?d:gt(this.iterationDuration*i),this._offset*=i,this._delay*=i,this._loopDelay*=i,this}revert(){kt(this,0,1,0,1);const t=this._autoplay;return t&&t.linked&&t.linked===this&&t.revert(),this.cancel()}complete(){return this.seek(this.duration).cancel()}then(t=_){const e=this.then,s=()=>{this.then=null,t(this),this.then=e,this._resolve=_};return new Promise((t=>(this._resolve=()=>t(s()),this.completed&&this._resolve(),this)))}}const ae=t=>t,he=(t,e,s)=>(((1-3*s+3*e)*t+(3*s-6*e))*t+3*e)*t,le=(t=.5,e=0,s=.5,i=1)=>t===e&&s===i?ae:r=>0===r||1===r?r:he(((t,e,s)=>{let i,r,n=0,o=1,a=0;do{r=n+(o-n)/2,i=he(r,e,s)-t,i>0?o=r:n=r}while(K(i)>1e-7&&++a<100);return r})(r,t,s),e,i),ce=(t=10,e)=>{const s=e?et:st;return e=>s(ht(e,0,1)*t)*(1/t)},de=(...t)=>{const e=t.length;if(!e)return ae;const s=e-1,i=t[0],r=t[s],n=[0],o=[Q(i)];for(let e=1;e<s;e++){const i=t[e],r=I(i)?i.trim().split(" "):[i],a=r[0],h=r[1];n.push(Y(h)?e/s:Q(h)/100),o.push(Q(a))}return o.push(Q(r)),n.push(1),function(t){for(let e=1,s=n.length;e<s;e++){const s=n[e];if(t<=s){const i=n[e-1],r=o[e-1];return r+(o[e]-r)*(t-i)/(s-i)}}return o[o.length-1]}},ue=(t=10,e=1)=>{const s=[0],i=t-1;for(let t=1;t<i;t++){const r=s[t-1],n=t/i,o=n*(1-e)+(n+((t+1)/i-n)*Math.random())*e;s.push(ht(o,r,1))}return s.push(1),de(...s)},pe=ot/2,me=2*ot,fe=(t=1.68)=>e=>j(e,+t),ge={[m]:fe,Quad:fe(2),Cubic:fe(3),Quart:fe(4),Quint:fe(5),Sine:t=>1-J(t*pe),Circ:t=>1-G(1-t*t),Expo:t=>t?j(2,10*t-10):0,Bounce:t=>{let e,s=4;for(;t<((e=j(2,--s))-1)/11;);return 1/j(4,3-s)-7.5625*j((3*e-2)/22-t,2)},Back:(t=1.70158)=>e=>(+t+1)*e*e*e-+t*e*e,Elastic:(t=1,e=.3)=>{const s=ht(+t,1,10),i=ht(+e,d,2),r=i/me*it(1/s),n=me/i;return t=>0===t||1===t?t:-s*j(2,-10*(1-t))*Z((1-t-r)*n)}},ye={in:t=>e=>t(e),out:t=>e=>1-t(1-e),inOut:t=>e=>e<.5?t(2*e)/2:1-t(-2*e+2)/2,outIn:t=>e=>e<.5?(1-t(1-2*e))/2:(t(2*e-1)+1)/2},_e=(t,e,s)=>{if(s[t])return s[t];if(t.indexOf("(")<=-1){const i=ye[t]||t.includes("Back")||t.includes("Elastic")?e[t]():e[t];return i?s[t]=i:ae}{const i=t.slice(0,-1).split("("),r=e[i[0]];return r?s[t]=r(...i[1].split(",")):ae}},ve=(()=>{const t={linear:de,irregular:ue,steps:ce,cubicBezier:le};for(let e in ye)for(let s in ge){const i=ge[s],r=ye[e];t[e+s]=s===m||"Back"===s||"Elastic"===s?(t,e)=>r(i(t,e)):r(i)}return t})(),be={linear:ae},Te=t=>z(t)?t:I(t)?_e(t,ve,be):ae,we={},Se=(t,e,s)=>{if(3===s)return f.get(t)||t;if(2===s||1===s&&W(e)&&t in e.style){const e=we[t];if(e)return e;{const e=t?N(t):t;return we[t]=e,e}}return t},xe={deg:1,rad:180/ot,turn:360},ke={},$e=(t,e,s,r=!1)=>{const n=e.u,o=e.n;if(1===e.t&&n===s)return e;const a=o+n+s,h=ke[a];if(Y(h)||r){let r;if(n in xe)r=o*xe[n]/xe[s];else{const e=100,a=t.cloneNode(),h=t.parentNode,l=h&&h!==i?h:i.body;l.appendChild(a);const c=a.style;c.width=e+n;const d=a.offsetWidth||e;c.width=e+s;const u=d/(a.offsetWidth||e);l.removeChild(a),r=u*o}e.n=r,ke[a]=r}else e.n=h;return e.t,e.u=s,e},Ce=t=>{if(t._hasChildren)vt(t,Ce,!0);else{const e=t;e.pause(),vt(e,(t=>{const s=t.property,i=t.target;if(i[o]){const r=i.style,n=e._inlineStyles[s];if(3===t._tweenType){const e=i[h];if(Y(n)||n===m?delete e[s]:e[s]=n,t._renderTransforms)if(Object.keys(e).length){let t=m;for(let s in e)t+=y[s]+e[s]+") ";r.transform=t}else r.removeProperty("transform")}else Y(n)||n===m?r.removeProperty(s):r[s]=n;e._tail===t&&e.targets.forEach((t=>{t.getAttribute&&t.getAttribute("style")===m&&t.removeAttribute("style")}))}}))}return t},Ee={t:0,n:0,u:null,o:null,d:null,s:null},Be={t:0,n:0,u:null,o:null,d:null,s:null},Le={func:null},De=[null],Ae=[null,null],Ne={to:null};let Fe,Oe,Pe=0;class Re extends oe{constructor(t,e,s,i,n=!1,o=0,a=0){super(e,s,i);const h=Ot(t),l=h.length,c=e.keyframes,u=c?_t(((t,e)=>{const s={};if(P(t)){const e=[].concat(...t.map((t=>Object.keys(t)))).filter(q);for(let i=0,r=e.length;i<r;i++){const r=e[i],n=t.map((t=>{const e={};for(let s in t){const i=t[s];q(s)?s===r&&(e.to=i):e[s]=i}return e}));s[r]=n}}else{const i=Xt(e.duration,D.defaults.duration),r=Object.keys(t).map((e=>({o:parseFloat(e)/100,p:t[e]}))).sort(((t,e)=>t.o-e.o));r.forEach((t=>{const e=t.o,r=t.p;for(let t in r)if(q(t)){let n=s[t];n||(n=s[t]=[]);const o=e*i;let a=n.length,h=n[a-1];const l={to:r[t]};let c=0;for(let t=0;t<a;t++)c+=n[t].duration;1===a&&(l.from=h.to),r.ease&&(l.ease=r.ease),l.duration=o-(a?c:0),n.push(l)}return t}));for(let t in s){const e=s[t];let i;for(let t=0,s=e.length;t<s;t++){const s=e[t],r=s.ease;s.ease=i||void 0,i=r}e[0].duration||e.shift()}}return s})(c,e),e):e,{delay:m,duration:f,ease:g,playbackEase:y,modifier:_,composition:v,onRender:b}=u,T=s?s.defaults:D.defaults,w=Xt(y,T.playbackEase),S=w?Te(w):null,x=!Y(g)&&!Y(g.ease),k=x?g.ease:Xt(g,S?"linear":T.ease),$=x?g.duration:Xt(f,T.duration),C=Xt(m,T.delay),E=_||T.modifier,B=Y(v)&&l>=p?r.none:Y(v)?T.composition:v,L={},A=this._offset+(s?s._offset:0);let N=NaN,F=NaN,O=0,I=0;for(let t=0;t<l;t++){const e=h[t],i=o||t,c=a||l;let p=NaN,m=NaN;for(let t in u)if(q(t)){const o=Vt(e,t),a=Se(t,e,o);let h=u[t];const l=P(h);if(n&&!l&&(Ae[0]=h,Ae[1]=h,h=Ae),l){const t=h.length,e=!R(h[0]);2===t&&e?(Ne.to=h,De[0]=Ne,Fe=De):t>2&&e?(Fe=[],h.forEach(((t,e)=>{e?1===e?(Ae[1]=t,Fe.push(Ae)):Fe.push(t):Ae[0]=t}))):Fe=h}else De[0]=h,Fe=De;let f=null,g=null,y=NaN,_=0,v=0;for(let t=Fe.length;v<t;v++){const n=Fe[v];R(n)?Oe=n:(Ne.to=n,Oe=Ne),Le.func=null;const h=Wt(Oe.to,e,i,c,Le);let l;R(h)&&!Y(h.to)?(Oe=h,l=h.to):l=h;const u=Wt(Oe.from,e,i,c),p=Oe.ease,m=!Y(p)&&!Y(p.ease),b=m?p.ease:p||k,T=m?p.duration:Wt(Xt(Oe.duration,t>1?Wt($,e,i,c)/t:$),e,i,c),w=Wt(Xt(Oe.delay,v?0:C),e,i,c),S=Wt(Xt(Oe.composition,B),e,i,c),x=M(S)?S:r[S],D=Oe.modifier||E,N=!Y(u),F=!Y(l),z=P(l),X=z||N&&F,W=g?_+w:w,V=ct(A+W,12);I||!N&&!z||(I=1);let H=g;if(x!==r.none){f||(f=Jt(e,a));let t=f._head;for(;t&&!t._isOverridden&&t._absoluteStartTime<=V;)if(H=t,t=t._nextRep,t&&t._absoluteStartTime>=V)for(;t;)te(t),t=t._nextRep}if(X?(Qt(z?Wt(l[0],e,i,c):u,Ee),Qt(z?Wt(l[1],e,i,c,Le):l,Be),0===Ee.t&&(H?1===H._valueType&&(Ee.t=1,Ee.u=H._unit):(Qt(Ut(e,a,o,L),Gt),1===Gt.t&&(Ee.t=1,Ee.u=Gt.u)))):(F?Qt(l,Be):g?jt(g,Be):Qt(s&&H&&H.parent.parent===s?H._value:Ut(e,a,o,L),Be),N?Qt(u,Ee):g?jt(g,Ee):Qt(s&&H&&H.parent.parent===s?H._value:Ut(e,a,o,L),Ee)),Ee.o&&(Ee.n=qt(H?H._toNumber:Qt(Ut(e,a,o,L),Gt).n,Ee.n,Ee.o)),Be.o&&(Be.n=qt(Ee.n,Be.n,Be.o)),Ee.t!==Be.t)if(3===Ee.t||3===Be.t){const t=3===Ee.t?Ee:Be,e=3===Ee.t?Be:Ee;e.t=3,e.s=yt(t.s),e.d=t.d.map((()=>e.n))}else if(1===Ee.t||1===Be.t){const t=1===Ee.t?Ee:Be,e=1===Ee.t?Be:Ee;e.t=1,e.u=t.u}else if(2===Ee.t||2===Be.t){const t=2===Ee.t?Ee:Be,e=2===Ee.t?Be:Ee;e.t=2,e.s=t.s,e.d=[0,0,0,1]}if(Ee.u!==Be.u){let t=Be.u?Ee:Be;t=$e(e,t,Be.u?Be.u:Ee.u,!1)}if(Be.d&&Ee.d&&Be.d.length!==Ee.d.length){const t=Ee.d.length>Be.d.length?Ee:Be,e=t===Ee?Be:Ee;e.d=t.d.map(((t,s)=>Y(e.d[s])?0:e.d[s])),e.s=yt(t.s)}const U=ct(+T||d,12),q={parent:this,id:Pe++,property:a,target:e,_value:null,_func:Le.func,_ease:Te(b),_fromNumbers:yt(Ee.d),_toNumbers:yt(Be.d),_strings:yt(Be.s),_fromNumber:Ee.n,_toNumber:Be.n,_numbers:yt(Ee.d),_number:Ee.n,_unit:Be.u,_modifier:D,_currentTime:0,_startTime:W,_delay:+w,_updateDuration:U,_changeDuration:U,_absoluteStartTime:V,_tweenType:o,_valueType:Be.t,_composition:x,_isOverlapped:0,_isOverridden:0,_renderTransforms:0,_prevRep:null,_nextRep:null,_prevAdd:null,_nextAdd:null,_prev:null,_next:null};x!==r.none&&ee(q,f),isNaN(y)&&(y=q._startTime),_=ct(W+U,12),g=q,O++,Tt(this,q)}(isNaN(F)||y<F)&&(F=y),(isNaN(N)||_>N)&&(N=_),3===o&&(p=O-v,m=O)}if(!isNaN(p)){let t=0;vt(this,(e=>{t>=p&&t<m&&(e._renderTransforms=1,e._composition===r.blend&&vt($t.animation,(t=>{t.id===e.id&&(t._renderTransforms=1)}))),t++}))}}l||console.warn("No target found. Make sure the element you're trying to animate is accessible before creating your animation."),F?(vt(this,(t=>{t._startTime-t._delay||(t._delay-=F),t._startTime-=F})),N-=F):F=0,N||(N=d,this.iterationCount=0),this.targets=h,this.duration=N===d?d:ft((N+this._loopDelay)*this.iterationCount-this._loopDelay)||d,this.onRender=b||T.onRender,this._ease=S,this._delay=F,this.iterationDuration=N,this._inlineStyles=L,!this._autoplay&&I&&this.onRender(this)}stretch(t){const e=this.duration;if(e===gt(t))return this;const s=t/e;return vt(this,(t=>{t._updateDuration=gt(t._updateDuration*s),t._changeDuration=gt(t._changeDuration*s),t._currentTime*=s,t._startTime*=s,t._absoluteStartTime*=s})),super.stretch(t)}refresh(){return vt(this,(t=>{const e=t._func;if(e){const s=Ut(t.target,t.property,t._tweenType);Qt(s,Gt),Qt(e(),Be),t._fromNumbers=yt(Gt.d),t._fromNumber=Gt.n,t._toNumbers=yt(Be.d),t._strings=yt(Be.s),t._toNumber=Be.o?qt(Gt.n,Be.n,Be.o):Be.n}})),this}revert(){return super.revert(),Ce(this)}then(t){return super.then(t)}}const Me=(t,e=100)=>{const s=[];for(let i=0;i<=e;i++)s.push(t(i/e));return`linear(${s.join(", ")})`},Ie={in:"ease-in",out:"ease-out",inOut:"ease-in-out"},ze=(()=>{const t={};for(let e in ye)t[e]=t=>ye[e](fe(t));return t})(),Ye=t=>{let e=Ie[t];if(e)return e;if(e="linear",I(t)){if(F(t,"linear")||F(t,"cubic-")||F(t,"steps")||F(t,"ease"))e=t;else if(F(t,"cubicB"))e=N(t);else{const s=_e(t,ze,Ie);z(s)&&(e=s===ae?"linear":Me(s))}Ie[t]=e}else if(z(t)){const s=Me(t);s&&(e=s)}else t.ease&&(e=Me(t.ease));return e},Xe=["x","y","z"],We=["perspective","width","height","margin","padding","top","right","bottom","left","borderWidth","fontSize","borderRadius",...Xe],Ve=(()=>[...Xe,...g.filter((t=>["X","Y","Z"].some((e=>t.endsWith(e)))))])();let He=null;const Ue={_head:null,_tail:null},qe=(t,e,s)=>{let i=Ue._head;for(;i;){const r=i._next,n=i.$el===t,o=!e||i.property===e,a=!s||i.parent===s;if(n&&o&&a){const t=i.animation;try{t.commitStyles()}catch{}t.cancel(),bt(Ue,i);const e=i.parent;e&&(e._completed++,e.animations.length===e._completed&&(e.completed=!0,e.muteCallbacks||(e.paused=!0,e.onComplete(e),e._resolve(e))))}i=r}},Qe=(t,e,s,i,r)=>{const n=e.animate(i,r),o=r.delay+ +r.duration*r.iterations;n.playbackRate=t._speed,t.paused&&n.pause(),t.duration<o&&(t.duration=o,t.controlAnimation=n),t.animations.push(n),qe(e,s),Tt(Ue,{parent:t,animation:n,$el:e,property:s,_next:null,_prev:null});const a=()=>{qe(e,s,t)};return n.onremove=a,n.onfinish=a,n},je=(t,e,s,i,r)=>{let n=Wt(e,s,i,r);return M(n)?We.includes(t)||F(t,"translate")?`${n}px`:F(t,"rotate")||F(t,"skew")?`${n}deg`:`${n}`:n},Ge=(t,e,s,i,r,n)=>{let o="0";const a=Y(i)?getComputedStyle(t)[e]:je(e,i,t,r,n);return o=Y(s)?P(i)?i.map((s=>je(e,s,t,r,n))):a:[je(e,s,t,r,n),a],o};class Ze{constructor(t,s){L.current&&L.current.register(this),X(He)&&(!e||!Y(CSS)&&Object.hasOwnProperty.call(CSS,"registerProperty")?(g.forEach((t=>{const e=F(t,"skew"),s=F(t,"scale"),i=F(t,"rotate"),r=F(t,"translate"),n=i||e,o=n?"<angle>":s?"<number>":r?"<length-percentage>":"*";try{CSS.registerProperty({name:"--"+t,syntax:o,inherits:!1,initialValue:r?"0px":n?"0deg":s?"1":"0"})}catch{}})),He=!0):He=!1);const i=Ot(t),r=i.length;r||console.warn("No target found. Make sure the element you're trying to animate is accessible before creating your animation.");const n=Xt(s.ease,Ye(D.defaults.ease)),o=n.ease&&n,a=Xt(s.autoplay,D.defaults.autoplay),l=!(!a||!a.link)&&a,c=s.alternate&&!0===s.alternate,d=s.reversed&&!0===s.reversed,u=Xt(s.loop,D.defaults.loop),v=!0===u||u===1/0?1/0:M(u)?u+1:1,b=c?d?"alternate-reverse":"alternate":d?"reverse":"normal",T=Ye(n),w=1===D.timeScale?1:p;this.targets=i,this.animations=[],this.controlAnimation=null,this.onComplete=s.onComplete||_,this.duration=0,this.muteCallbacks=!1,this.completed=!1,this.paused=!a||!1!==l,this.reversed=d,this.autoplay=a,this._speed=Xt(s.playbackRate,D.defaults.playbackRate),this._resolve=_,this._completed=0,this._inlineStyles=i.map((t=>t.getAttribute("style"))),i.forEach(((t,e)=>{const i=t[h],a=Ve.some((t=>s.hasOwnProperty(t))),l=(o?o.duration:Wt(Xt(s.duration,D.defaults.duration),t,e,r))*w,c=Wt(Xt(s.delay,D.defaults.delay),t,e,r)*w,d=Xt(s.composition,"replace");for(let o in s){if(!q(o))continue;const h={},u={iterations:v,direction:b,fill:"forwards",easing:T,duration:l,delay:c,composite:d},p=s[o],m=!!a&&(g.includes(o)?o:f.get(o));let y;if(R(p)){const s=p,a=Xt(s.ease,n),f=a.ease&&a,g=s.to,_=s.from;if(u.duration=(f?f.duration:Wt(Xt(s.duration,l),t,e,r))*w,u.delay=Wt(Xt(s.delay,c),t,e,r)*w,u.composite=Xt(s.composition,d),u.easing=Ye(a),y=Ge(t,o,_,g,e,r),m?(h[`--${m}`]=y,i[m]=y):h[o]=Ge(t,o,_,g,e,r),Qe(this,t,o,h,u),!Y(_))if(m){const e=`--${m}`;t.style.setProperty(e,h[e][0])}else t.style[o]=h[o][0]}else y=P(p)?p.map((s=>je(o,s,t,e,r))):je(o,p,t,e,r),m?(h[`--${m}`]=y,i[m]=y):h[o]=y,Qe(this,t,o,h,u)}if(a){let e=m;for(let t in i)e+=`${y[t]}var(--${t})) `;t.style.transform=e}})),l&&this.autoplay.link(this)}forEach(t){const e=I(t)?e=>e[t]():t;return this.animations.forEach(e),this}get speed(){return this._speed}set speed(t){this._speed=+t,this.forEach((e=>e.playbackRate=t))}get currentTime(){const t=this.controlAnimation,e=D.timeScale;return this.completed?this.duration:t?+t.currentTime*(1===e?1:e):0}set currentTime(t){const e=t*(1===D.timeScale?1:p);this.forEach((t=>{e>=this.duration&&t.play(),t.currentTime=e}))}get progress(){return this.currentTime/this.duration}set progress(t){this.forEach((e=>e.currentTime=t*this.duration||0))}resume(){return this.paused?(this.paused=!1,this.forEach("play")):this}pause(){return this.paused?this:(this.paused=!0,this.forEach("pause"))}alternate(){return this.reversed=!this.reversed,this.forEach("reverse"),this.paused&&this.forEach("pause"),this}play(){return this.reversed&&this.alternate(),this.resume()}reverse(){return this.reversed||this.alternate(),this.resume()}seek(t,e=!1){return e&&(this.muteCallbacks=!0),t<this.duration&&(this.completed=!1),this.currentTime=t,this.muteCallbacks=!1,this.paused&&this.pause(),this}restart(){return this.completed=!1,this.seek(0,!0).resume()}commitStyles(){return this.forEach("commitStyles")}complete(){return this.seek(this.duration)}cancel(){return this.forEach("cancel"),this.pause()}revert(){return this.cancel(),this.targets.forEach(((t,e)=>t.setAttribute("style",this._inlineStyles[e]))),this}then(t=_){const e=this.then,s=()=>{this.then=null,t(this),this.then=e,this._resolve=_};return new Promise((t=>(this._resolve=()=>t(s()),this.completed&&this._resolve(),this)))}}const Je={animate:(t,e)=>new Ze(t,e),convertEase:Me},Ke=(t=_)=>new oe({duration:1*D.timeScale,onComplete:t},null,0).resume();function ts(t,e,s){const i=Ot(t);if(!i.length)return;const[r]=i,n=Vt(r,e),o=Se(e,r,n);let a=Ut(r,o);if(Y(s))return a;if(Qt(a,Gt),0===Gt.t||1===Gt.t){if(!1===s)return Gt.n;{const t=$e(r,Gt,s,!1);return`${ct(t.n,D.precision)}${t.u}`}}}const es=(t,e)=>{if(!Y(e))return e.duration=d,e.composition=Xt(e.composition,r.none),new Re(t,e,null,0,!0).resume()},ss=(t,e,s)=>{let i=!1;return vt(e,(r=>{const n=r.target;if(t.includes(n)){const t=r.property,o=r._tweenType,a=Se(s,n,o);(!a||a&&a===t)&&(r.parent._tail===r&&3===r._tweenType&&r._prev&&3===r._prev._tweenType&&(r._prev._renderTransforms=1),bt(e,r),se(r),i=!0)}}),!0),i},is=(t,e,s)=>{const i=Ft(t),r=e||Lt,n=e&&e.controlAnimation&&e;for(let t=0,e=i.length;t<e;t++){const e=i[t];qe(e,s,n)}let o;if(r._hasChildren){let e=0;vt(r,(n=>{if(!n._hasChildren)if(o=ss(i,n,s),o&&!n._head)n.cancel(),bt(r,n);else{const t=n._offset+n._delay+n.duration;t>e&&(e=t)}n._head?is(t,n,s):n._hasChildren=!1}),!0),Y(r.iterationDuration)||(r.iterationDuration=e)}else o=ss(i,r,s);return o&&!r._head&&(r._hasChildren=!1,r.cancel&&r.cancel()),i},rs=(t,e,s,i,r)=>i+(t-e)/(s-e)*(r-i),ns=(t,e,s,i)=>{let r=p/D.defaults.frameRate;if(!1!==i){const t=i||Lt._hasChildren&&Lt;t&&t.deltaTime&&(r=t.deltaTime)}const n=1-Math.exp(-s*r*.1);return s?1===s?e:(1-n)*t+n*e:t},os=t=>(...e)=>{const s=t(...e);return new Proxy(_,{apply:(t,e,[i])=>s(i),get:(t,e)=>os(((...t)=>{const i=hs[e](...t);return t=>i(s(t))}))})},as=(t,e=0)=>(...s)=>(s.length<t.length?os(((t,e=0)=>(...s)=>e?e=>t(...s,e):e=>t(e,...s))(t,e)):t)(...s),hs={$:Ot,get:ts,set:es,remove:is,cleanInlineStyles:Ce,random:pt,randomPick:t=>t[pt(0,t.length-1)],shuffle:mt,lerp:ns,sync:Ke,keepTime:wt,clamp:as(ht),round:as(ct),snap:as(dt),wrap:as(((t,e,s)=>((t-e)%(s-e)+(s-e))%(s-e)+e)),interpolate:as(ut,1),mapRange:as(rs),roundPad:as(((t,e)=>(+t).toFixed(e))),padStart:as(((t,e,s)=>`${t}`.padStart(e,s))),padEnd:as(((t,e,s)=>`${t}`.padEnd(e,s))),degToRad:as((t=>t*ot/180)),radToDeg:as((t=>180*t/ot))},ls=(t,e)=>{let s=t.iterationDuration;if(s===d&&(s=0),Y(e))return s;if(M(+e))return+e;const i=e,r=t?t.labels:null,n=!X(r),o=((t,e)=>{if(F(e,"<")){const s="<"===e[1],i=t._tail,r=i?i._offset+i._delay:0;return s?r:r+i.duration}})(t,i),a=!Y(o),h=E.exec(i);if(h){const t=h[0],e=i.split(t),l=n&&e[0]?r[e[0]]:s,c=a?o:n?l:s,d=+e[1];return qt(c,d,t[0])}return a?o:n?Y(r[i])?s:r[i]:s};function cs(t,e,s,i,r,n){const o=M(t.duration)&&t.duration<=d?s-d:s;kt(e,o,1,1,1);const a=i?new Re(i,t,e,o,!1,r,n):new oe(t,e,o);return a.init(1),Tt(e,a),vt(e,(t=>{const s=t._offset+t._delay+t.duration;s>e.iterationDuration&&(e.iterationDuration=s)})),e.duration=function(t){return ft((t.iterationDuration+t._loopDelay)*t.iterationCount-t._loopDelay)||d}(e),e}class ds extends oe{constructor(t={}){super(t,null,0),this.duration=0,this.labels={};const e=t.defaults,s=D.defaults;this.defaults=e?_t(e,s):s,this.onRender=t.onRender||s.onRender;const i=Xt(t.playbackEase,s.playbackEase);this._ease=i?Te(i):null,this.iterationDuration=0}add(t,e,s){const i=R(e),r=R(t);if(i||r){if(this._hasChildren=!0,i){const i=e;if(z(s)){const e=s,r=Ft(t),n=this.duration,o=this.iterationDuration,a=i.id;let h=0;const l=r.length;r.forEach((t=>{const s={...i};this.duration=n,this.iterationDuration=o,Y(a)||(s.id=a+"-"+h),cs(s,this,ls(this,e(t,h,l,this)),t,h,l),h++}))}else cs(i,this,ls(this,s),t)}else cs(t,this,ls(this,e));return this.init(1)}}sync(t,e){if(Y(t)||t&&Y(t.pause))return this;t.pause();const s=+(t.effect?t.effect.getTiming().duration:t.duration);return this.add(t,{currentTime:[0,s],duration:s,ease:"linear"},e)}set(t,e,s){return Y(e)?this:(e.duration=d,e.composition=r.replace,this.add(t,e,s))}call(t,e){return Y(t)||t&&!z(t)?this:this.add({duration:0,onComplete:()=>t(this)},e)}label(t,e){return Y(t)||t&&!I(t)||(this.labels[t]=ls(this,e)),this}remove(t,e){return is(t,this,e),this}stretch(t){const e=this.duration;if(e===gt(t))return this;const s=t/e,i=this.labels;vt(this,(t=>t.stretch(t.duration*s)));for(let t in i)i[t]*=s;return super.stretch(t)}refresh(){return vt(this,(t=>{t.refresh&&t.refresh()})),this}revert(){return super.revert(),vt(this,(t=>t.revert),!0),Ce(this)}then(t){return super.then(t)}}class us{constructor(t,e){L.current&&L.current.register(this);const s=()=>{if(this.callbacks.completed)return;let t=!0;for(let e in this.animations)if(!this.animations[e].paused&&t){t=!1;break}t&&this.callbacks.complete()},i={onBegin:()=>{this.callbacks.completed&&this.callbacks.reset(),this.callbacks.play()},onComplete:s,onPause:s},n={v:1,autoplay:!1},o={};if(this.targets=[],this.animations={},this.callbacks=null,!Y(t)&&!Y(e)){for(let t in e){const s=e[t];q(t)?o[t]=s:F(t,"on")?n[t]=s:i[t]=s}this.callbacks=new Re({v:0},n);for(let e in o){const s=o[e],n=R(s);let a={},h="+=0";if(n){const t=s.unit;I(t)&&(h+=t)}else a.duration=s;a[e]=n?_t({to:h},s):h;const l=_t(i,a);l.composition=r.replace,l.autoplay=!1;const c=this.animations[e]=new Re(t,l,null,0,!1).init();this.targets.length||this.targets.push(...c.targets),this[e]=(t,e,s)=>{const i=c._head;if(Y(t)&&i){const t=i._numbers;return t&&t.length?t:i._modifier(i._number)}return vt(c,(e=>{if(P(t))for(let s=0,i=t.length;s<i;s++)Y(e._numbers[s])||(e._fromNumbers[s]=e._modifier(e._numbers[s]),e._toNumbers[s]=t[s]);else e._fromNumber=e._modifier(e._number),e._toNumber=t;Y(s)||(e._ease=Te(s)),e._currentTime=0})),Y(e)||c.stretch(e),c.reset(1).resume(),this}}}}revert(){for(let t in this.animations)this[t]=_,this.animations[t].revert();return this.animations={},this.targets.length=0,this.callbacks&&this.callbacks.revert(),this}}const ps=10*p;class ms{constructor(t={}){this.timeStep=.02,this.restThreshold=5e-4,this.restDuration=200,this.maxDuration=6e4,this.maxRestSteps=this.restDuration/this.timeStep/p,this.maxIterations=this.maxDuration/this.timeStep/p,this.m=ht(Xt(t.mass,1),0,ps),this.s=ht(Xt(t.stiffness,100),1,ps),this.d=ht(Xt(t.damping,10),.1,ps),this.v=ht(Xt(t.velocity,0),-1e4,ps),this.w0=0,this.zeta=0,this.wd=0,this.b=0,this.solverDuration=0,this.duration=0,this.compute(),this.ease=t=>0===t||1===t?t:this.solve(t*this.solverDuration)}solve(t){const{zeta:e,w0:s,wd:i,b:r}=this;let n=t;return n=e<1?tt(-n*e*s)*(1*J(i*n)+r*Z(i*n)):(1+r*n)*tt(-n*s),1-n}compute(){const{maxRestSteps:t,maxIterations:e,restThreshold:s,timeStep:i,m:r,d:n,s:o,v:a}=this,h=this.w0=ht(G(o/r),d,p),l=this.zeta=n/(2*G(o*r)),c=this.wd=l<1?h*G(1-l*l):0;this.b=l<1?(l*h-a)/c:-a+h;let u=0,m=0,f=0;for(;m<t&&f<e;)K(1-this.solve(u))<s?m++:m=0,this.solverDuration=u,u+=i,f++;this.duration=ct(this.solverDuration*p,0)*D.timeScale}get mass(){return this.m}set mass(t){this.m=ht(Xt(t,1),0,ps),this.compute()}get stiffness(){return this.s}set stiffness(t){this.s=ht(Xt(t,100),1,ps),this.compute()}get damping(){return this.d}set damping(t){this.d=ht(Xt(t,10),.1,ps),this.compute()}get velocity(){return this.v}set velocity(t){this.v=ht(Xt(t,0),-1e4,ps),this.compute()}}const fs=t=>new ms(t),gs=t=>{t.cancelable&&t.preventDefault()};class ys{constructor(t){this.el=t,this.zIndex=0,this.parentElement=null,this.classList={add:_,remove:_}}get x(){return this.el.x||0}set x(t){this.el.x=t}get y(){return this.el.y||0}set y(t){this.el.y=t}get width(){return this.el.width||0}set width(t){this.el.width=t}get height(){return this.el.height||0}set height(t){this.el.height=t}getBoundingClientRect(){return{top:this.y,right:this.x,bottom:this.y+this.height,left:this.x+this.width}}}class _s{constructor(t){this.$el=t,this.inlineTransforms=[],this.point=new DOMPoint,this.inversedMatrix=this.getMatrix().inverse()}normalizePoint(t,e){return this.point.x=t,this.point.y=e,this.point.matrixTransform(this.inversedMatrix)}traverseUp(t){let e=this.$el.parentElement,s=0;for(;e&&e!==i;)t(e,s),e=e.parentElement,s++}getMatrix(){const t=new DOMMatrix;return this.traverseUp((e=>{const s=getComputedStyle(e).transform;if(s){const e=new DOMMatrix(s);t.preMultiplySelf(e)}})),t}remove(){this.traverseUp(((t,e)=>{this.inlineTransforms[e]=t.style.transform,t.style.transform="none"}))}revert(){this.traverseUp(((t,e)=>{const s=this.inlineTransforms[e];""===s?t.style.removeProperty("transform"):t.style.transform=s}))}}const vs=(t,e)=>t&&z(t)?t(e):t;let bs=0;class Ts{constructor(t,e={}){if(!t)return;L.current&&L.current.register(this);const r=e.x,n=e.y,o=e.trigger,a=e.modifier,h=e.releaseEase,l=h&&Te(h),c=!Y(h)&&!Y(h.ease),d=R(r)&&!Y(r.mapTo)?r.mapTo:"translateX",p=R(n)&&!Y(n.mapTo)?n.mapTo:"translateY",m=vs(e.container,this);this.containerArray=P(m)?m:null,this.$container=m&&!this.containerArray?Ft(m)[0]:i.body,this.useWin=this.$container===i.body,this.$scrollContainer=this.useWin?s:this.$container,this.$target=R(t)?new ys(t):Ft(t)[0],this.$trigger=Ft(o||t)[0],this.fixed="fixed"===ts(this.$target,"position"),this.isFinePointer=!0,this.containerPadding=[0,0,0,0],this.containerFriction=0,this.releaseContainerFriction=0,this.snapX=0,this.snapY=0,this.scrollSpeed=0,this.scrollThreshold=0,this.dragSpeed=0,this.maxVelocity=0,this.minVelocity=0,this.velocityMultiplier=0,this.cursor=!1,this.releaseXSpring=c?h:fs({mass:Xt(e.releaseMass,1),stiffness:Xt(e.releaseStiffness,80),damping:Xt(e.releaseDamping,20)}),this.releaseYSpring=c?h:fs({mass:Xt(e.releaseMass,1),stiffness:Xt(e.releaseStiffness,80),damping:Xt(e.releaseDamping,20)}),this.releaseEase=l||ve.outQuint,this.hasReleaseSpring=c,this.onGrab=e.onGrab||_,this.onDrag=e.onDrag||_,this.onRelease=e.onRelease||_,this.onUpdate=e.onUpdate||_,this.onSettle=e.onSettle||_,this.onSnap=e.onSnap||_,this.onResize=e.onResize||_,this.onAfterResize=e.onAfterResize||_,this.disabled=[0,0];const f={};if(a&&(f.modifier=a),Y(r)||!0===r)f[d]=0;else if(R(r)){const t=r,e={};t.modifier&&(e.modifier=t.modifier),t.composition&&(e.composition=t.composition),f[d]=e}else!1===r&&(f[d]=0,this.disabled[0]=1);if(Y(n)||!0===n)f[p]=0;else if(R(n)){const t=n,e={};t.modifier&&(e.modifier=t.modifier),t.composition&&(e.composition=t.composition),f[p]=e}else!1===n&&(f[p]=0,this.disabled[1]=1);this.animate=new us(this.$target,f),this.xProp=d,this.yProp=p,this.destX=0,this.destY=0,this.deltaX=0,this.deltaY=0,this.scroll={x:0,y:0},this.coords=[this.x,this.y,0,0],this.snapped=[0,0],this.pointer=[0,0,0,0,0,0,0,0],this.scrollView=[0,0],this.dragArea=[0,0,0,0],this.containerBounds=[-1e12,u,u,-1e12],this.scrollBounds=[0,0,0,0],this.targetBounds=[0,0,0,0],this.window=[0,0],this.velocityStack=[0,0,0],this.velocityStackIndex=0,this.velocityTime=O(),this.velocity=0,this.angle=0,this.cursorStyles=null,this.triggerStyles=null,this.bodyStyles=null,this.targetStyles=null,this.touchActionStyles=null,this.transforms=new _s(this.$target),this.overshootCoords={x:0,y:0},this.overshootTicker=new oe({autoplay:!1,onUpdate:()=>{this.updated=!0,this.manual=!0,this.disabled[0]||this.animate[this.xProp](this.overshootCoords.x,1),this.disabled[1]||this.animate[this.yProp](this.overshootCoords.y,1)},onComplete:()=>{this.manual=!1,this.disabled[0]||this.animate[this.xProp](this.overshootCoords.x,0),this.disabled[1]||this.animate[this.yProp](this.overshootCoords.y,0)}},null,0).init(),this.updateTicker=new oe({autoplay:!1,onUpdate:()=>this.update()},null,0).init(),this.contained=!Y(m),this.manual=!1,this.grabbed=!1,this.dragged=!1,this.updated=!1,this.released=!1,this.canScroll=!1,this.enabled=!1,this.initialized=!1,this.activeProp=this.disabled[1]?d:p,this.animate.callbacks.onRender=()=>{const t=this.updated,e=!(this.grabbed&&t)&&this.released,s=this.x,i=this.y,r=s-this.coords[2],n=i-this.coords[3];this.deltaX=r,this.deltaY=n,this.coords[2]=s,this.coords[3]=i,t&&(r||n)&&this.onUpdate(this),e?(this.computeVelocity(r,n),this.angle=nt(n,r)):this.updated=!1},this.animate.callbacks.onComplete=()=>{!this.grabbed&&this.released&&(this.released=!1),this.manual||(this.deltaX=0,this.deltaY=0,this.velocity=0,this.velocityStack[0]=0,this.velocityStack[1]=0,this.velocityStack[2]=0,this.velocityStackIndex=0,this.onSettle(this))},this.resizeTicker=new oe({autoplay:!1,duration:150*D.timeScale,onComplete:()=>{this.onResize(this),this.refresh(),this.onAfterResize(this)}}).init(),this.parameters=e,this.resizeObserver=new ResizeObserver((()=>{this.initialized?this.resizeTicker.restart():this.initialized=!0})),this.enable(),this.refresh(),this.resizeObserver.observe(this.$container),R(t)||this.resizeObserver.observe(this.$target)}computeVelocity(t,e){const s=this.velocityTime,i=O(),r=i-s;if(r<17)return this.velocity;this.velocityTime=i;const n=this.velocityStack,o=this.velocityMultiplier,a=this.minVelocity,h=this.maxVelocity,l=this.velocityStackIndex;n[l]=ct(ht(G(t*t+e*e)/r*o,a,h),5);const c=rt(n[0],n[1],n[2]);return this.velocity=c,this.velocityStackIndex=(l+1)%3,c}setX(t,e=!1){if(this.disabled[0])return;const s=ct(t,5);return this.overshootTicker.pause(),this.manual=!0,this.updated=!e,this.destX=s,this.snapped[0]=dt(s,this.snapX),this.animate[this.xProp](s,0),this.manual=!1,this}setY(t,e=!1){if(this.disabled[1])return;const s=ct(t,5);return this.overshootTicker.pause(),this.manual=!0,this.updated=!e,this.destY=s,this.snapped[1]=dt(s,this.snapY),this.animate[this.yProp](s,0),this.manual=!1,this}get x(){return ct(this.animate[this.xProp](),D.precision)}set x(t){this.setX(t,!1)}get y(){return ct(this.animate[this.yProp](),D.precision)}set y(t){this.setY(t,!1)}get progressX(){return rs(this.x,this.containerBounds[3],this.containerBounds[1],0,1)}set progressX(t){this.setX(rs(t,0,1,this.containerBounds[3],this.containerBounds[1]),!1)}get progressY(){return rs(this.y,this.containerBounds[0],this.containerBounds[2],0,1)}set progressY(t){this.setY(rs(t,0,1,this.containerBounds[0],this.containerBounds[2]),!1)}updateScrollCoords(){const t=ct(this.useWin?s.scrollX:this.$container.scrollLeft,0),e=ct(this.useWin?s.scrollY:this.$container.scrollTop,0),[i,r,n,o]=this.containerPadding,a=this.scrollThreshold;this.scroll.x=t,this.scroll.y=e,this.scrollBounds[0]=e-this.targetBounds[0]+i-a,this.scrollBounds[1]=t-this.targetBounds[1]-r+a,this.scrollBounds[2]=e-this.targetBounds[2]-n+a,this.scrollBounds[3]=t-this.targetBounds[3]+o-a}updateBoundingValues(){const t=this.$container;if(!t)return;const e=this.x,r=this.y,n=this.coords[2],o=this.coords[3];this.coords[2]=0,this.coords[3]=0,this.setX(0,!0),this.setY(0,!0),this.transforms.remove();const a=this.window[0]=s.innerWidth,h=this.window[1]=s.innerHeight,l=this.useWin,c=t.scrollWidth,d=t.scrollHeight,u=this.fixed,p=t.getBoundingClientRect(),[m,f,g,y]=this.containerPadding;this.dragArea[0]=l?0:p.left,this.dragArea[1]=l?0:p.top,this.scrollView[0]=l?ht(c,a,c):c,this.scrollView[1]=l?ht(d,h,d):d,this.updateScrollCoords();const{width:_,height:v,left:b,top:T,right:w,bottom:S}=t.getBoundingClientRect();this.dragArea[2]=ct(l?ht(_,a,a):_,0),this.dragArea[3]=ct(l?ht(v,h,h):v,0);const x=ts(t,"overflow"),k="visible"===x,$="hidden"===x;if(this.canScroll=!u&&this.contained&&(t===i.body&&k||!$&&!k)&&(c>this.dragArea[2]+y-f||d>this.dragArea[3]+m-g)&&(!this.containerArray||this.containerArray&&!P(this.containerArray)),this.contained){const e=this.scroll.x,s=this.scroll.y,i=this.canScroll,r=this.$target.getBoundingClientRect(),n=i?l?0:t.scrollLeft:0,o=i?l?0:t.scrollTop:0,c=i?this.scrollView[0]-n-_:0,d=i?this.scrollView[1]-o-v:0;this.targetBounds[0]=ct(r.top+s-(l?0:T),0),this.targetBounds[1]=ct(r.right+e-(l?a:w),0),this.targetBounds[2]=ct(r.bottom+s-(l?h:S),0),this.targetBounds[3]=ct(r.left+e-(l?0:b),0),this.containerArray?(this.containerBounds[0]=this.containerArray[0]+m,this.containerBounds[1]=this.containerArray[1]-f,this.containerBounds[2]=this.containerArray[2]-g,this.containerBounds[3]=this.containerArray[3]+y):(this.containerBounds[0]=-ct(r.top-(u?ht(T,0,h):T)+o-m,0),this.containerBounds[1]=-ct(r.right-(u?ht(w,0,a):w)-c+f,0),this.containerBounds[2]=-ct(r.bottom-(u?ht(S,0,h):S)-d+g,0),this.containerBounds[3]=-ct(r.left-(u?ht(b,0,a):b)+n-y,0))}this.transforms.revert(),this.coords[2]=n,this.coords[3]=o,this.setX(e,!0),this.setY(r,!0)}isOutOfBounds(t,e,s){if(!this.contained)return 0;const[i,r,n,o]=t,[a,h]=this.disabled,l=!a&&e<o||!a&&e>r,c=!h&&s<i||!h&&s>n;return l&&!c?1:!l&&c?2:l&&c?3:0}refresh(){const t=this.parameters,e=t.x,r=t.y,n=vs(t.container,this),o=vs(t.containerPadding,this)||0,a=P(o)?o:[o,o,o,o],h=this.x,l=this.y,c=vs(t.cursor,this),d={onHover:"grab",onGrab:"grabbing"};if(c){const{onHover:t,onGrab:e}=c;t&&(d.onHover=t),e&&(d.onGrab=e)}this.containerArray=P(n)?n:null,this.$container=n&&!this.containerArray?Ft(n)[0]:i.body,this.useWin=this.$container===i.body,this.$scrollContainer=this.useWin?s:this.$container,this.isFinePointer=matchMedia("(pointer:fine)").matches,this.containerPadding=Xt(a,[0,0,0,0]),this.containerFriction=ht(Xt(vs(t.containerFriction,this),.8),0,1),this.releaseContainerFriction=ht(Xt(vs(t.releaseContainerFriction,this),this.containerFriction),0,1),this.snapX=vs(R(e)&&!Y(e.snap)?e.snap:t.snap,this),this.snapY=vs(R(r)&&!Y(r.snap)?r.snap:t.snap,this),this.scrollSpeed=Xt(vs(t.scrollSpeed,this),1.5),this.scrollThreshold=Xt(vs(t.scrollThreshold,this),20),this.dragSpeed=Xt(vs(t.dragSpeed,this),1),this.minVelocity=Xt(vs(t.minVelocity,this),0),this.maxVelocity=Xt(vs(t.maxVelocity,this),50),this.velocityMultiplier=Xt(vs(t.velocityMultiplier,this),1),this.cursor=!1!==c&&d,this.updateBoundingValues();const[u,p,m,f]=this.containerBounds;this.setX(ht(h,f,p),!0),this.setY(ht(l,u,m),!0)}update(){if(this.updateScrollCoords(),this.canScroll){const[t,e,s,i]=this.containerPadding,[r,n]=this.scrollView,o=this.dragArea[2],a=this.dragArea[3],h=this.scroll.x,l=this.scroll.y,c=this.$container.scrollWidth,d=this.$container.scrollHeight,u=this.useWin?ht(c,this.window[0],c):c,p=this.useWin?ht(d,this.window[1],d):d,m=r-u,f=n-p;this.dragged&&m>0&&(this.coords[0]-=m,this.scrollView[0]=u),this.dragged&&f>0&&(this.coords[1]-=f,this.scrollView[1]=p);const g=10*this.scrollSpeed,y=this.scrollThreshold,[_,v]=this.coords,[b,T,w,S]=this.scrollBounds,x=ct(ht((v-b+t)/y,-1,0)*g,0),k=ct(ht((_-T-e)/y,0,1)*g,0),$=ct(ht((v-w-s)/y,0,1)*g,0),C=ct(ht((_-S+i)/y,-1,0)*g,0);if(x||$||C||k){const[t,e]=this.disabled;let s=h,i=l;t||(s=ct(ht(h+(C||k),0,r-o),0),this.coords[0]-=h-s),e||(i=ct(ht(l+(x||$),0,n-a),0),this.coords[1]-=l-i),this.useWin?this.$scrollContainer.scrollBy(-(h-s),-(l-i)):this.$scrollContainer.scrollTo(s,i)}}const[t,e,s,i]=this.containerBounds,[r,n,o,a,h,l]=this.pointer;this.coords[0]+=(r-h)*this.dragSpeed,this.coords[1]+=(n-l)*this.dragSpeed,this.pointer[4]=r,this.pointer[5]=n;const[c,d]=this.coords,[u,p]=this.snapped,m=(1-this.containerFriction)*this.dragSpeed;this.setX(c>e?e+(c-e)*m:c<i?i+(c-i)*m:c,!1),this.setY(d>s?s+(d-s)*m:d<t?t+(d-t)*m:d,!1),this.computeVelocity(r-h,n-l),this.angle=nt(n-a,r-o);const[f,g]=this.snapped;(f!==u&&this.snapX||g!==p&&this.snapY)&&this.onSnap(this)}stop(){this.updateTicker.pause(),this.overshootTicker.pause();for(let t in this.animate.animations)this.animate.animations[t].pause();return is(this,null,"x"),is(this,null,"y"),is(this,null,"progressX"),is(this,null,"progressY"),is(this.scroll),is(this.overshootCoords),this}scrollInView(t,e=0,s=ve.inOutQuad){this.updateScrollCoords();const i=this.destX,r=this.destY,n=this.scroll,o=this.scrollBounds,a=this.canScroll;if(!this.containerArray&&this.isOutOfBounds(o,i,r)){const[h,l,c,d]=o,p=ct(ht(r-h,-1e12,0),0),m=ct(ht(i-l,0,u),0),f=ct(ht(r-c,0,u),0),g=ct(ht(i-d,-1e12,0),0);new Re(n,{x:ct(n.x+(g?g-e:m?m+e:0),0),y:ct(n.y+(p?p-e:f?f+e:0),0),duration:Y(t)?350*D.timeScale:t,ease:s,onUpdate:()=>{this.canScroll=!1,this.$scrollContainer.scrollTo(n.x,n.y)}}).init().then((()=>{this.canScroll=a}))}return this}handleHover(){this.isFinePointer&&this.cursor&&!this.cursorStyles&&(this.cursorStyles=es(this.$trigger,{cursor:this.cursor.onHover}))}animateInView(t,e=0,s=ve.inOutQuad){this.stop(),this.updateBoundingValues();const i=this.x,r=this.y,[n,o,a,h]=this.containerPadding,l=this.scroll.y-this.targetBounds[0]+n+e,c=this.scroll.x-this.targetBounds[1]-o-e,d=this.scroll.y-this.targetBounds[2]-a-e,u=this.scroll.x-this.targetBounds[3]+h+e,p=this.isOutOfBounds([l,c,d,u],i,r);if(p){const[e,n]=this.disabled,o=ht(dt(i,this.snapX),u,c),a=ht(dt(r,this.snapY),l,d),h=Y(t)?350*D.timeScale:t;e||1!==p&&3!==p||this.animate[this.xProp](o,h,s),n||2!==p&&3!==p||this.animate[this.yProp](a,h,s)}return this}handleDown(t){const e=t.target;if(this.grabbed||"range"===e.type)return;t.stopPropagation(),this.grabbed=!0,this.released=!1,this.stop(),this.updateBoundingValues();const s=t.changedTouches,r=s?s[0].clientX:t.clientX,n=s?s[0].clientY:t.clientY,{x:o,y:a}=this.transforms.normalizePoint(r,n),[h,l,c,d]=this.containerBounds,u=(1-this.containerFriction)*this.dragSpeed,p=this.x,m=this.y;this.coords[0]=this.coords[2]=u?p>l?l+(p-l)/u:p<d?d+(p-d)/u:p:p,this.coords[1]=this.coords[3]=u?m>c?c+(m-c)/u:m<h?h+(m-h)/u:m:m,this.pointer[0]=o,this.pointer[1]=a,this.pointer[2]=o,this.pointer[3]=a,this.pointer[4]=o,this.pointer[5]=a,this.pointer[6]=o,this.pointer[7]=a,this.deltaX=0,this.deltaY=0,this.velocity=0,this.velocityStack[0]=0,this.velocityStack[1]=0,this.velocityStack[2]=0,this.velocityStackIndex=0,this.angle=0,this.targetStyles&&(this.targetStyles.revert(),this.targetStyles=null);const f=ts(this.$target,"zIndex",!1);bs=(f>bs?f:bs)+1,this.targetStyles=es(this.$target,{zIndex:bs}),this.triggerStyles&&(this.triggerStyles.revert(),this.triggerStyles=null),this.cursorStyles&&(this.cursorStyles.revert(),this.cursorStyles=null),this.isFinePointer&&this.cursor&&(this.bodyStyles=es(i.body,{cursor:this.cursor.onGrab})),this.scrollInView(100,0,ve.out(3)),this.onGrab(this),i.addEventListener("touchmove",this),i.addEventListener("touchend",this),i.addEventListener("touchcancel",this),i.addEventListener("mousemove",this),i.addEventListener("mouseup",this),i.addEventListener("selectstart",this)}handleMove(t){if(!this.grabbed)return;const e=t.changedTouches,s=e?e[0].clientX:t.clientX,i=e?e[0].clientY:t.clientY,{x:r,y:n}=this.transforms.normalizePoint(s,i),o=r-this.pointer[6],a=n-this.pointer[7];let h=t.target,l=!1,c=!1,d=!1;for(;e&&h&&h!==this.$trigger;){const t=ts(h,"overflow-y");if("hidden"!==t&&"visible"!==t){const{scrollTop:t,scrollHeight:e,clientHeight:s}=h;if(e>s){d=!0,l=t<=3,c=t>=e-s-3;break}}h=h.parentNode}d&&(!l&&!c||l&&a<0||c&&a>0)?(this.pointer[0]=r,this.pointer[1]=n,this.pointer[2]=r,this.pointer[3]=n,this.pointer[4]=r,this.pointer[5]=n,this.pointer[6]=r,this.pointer[7]=n):(gs(t),this.triggerStyles||(this.triggerStyles=es(this.$trigger,{pointerEvents:"none"})),this.$trigger.addEventListener("touchstart",gs,{passive:!1}),this.$trigger.addEventListener("touchmove",gs,{passive:!1}),this.$trigger.addEventListener("touchend",gs),(!this.disabled[0]&&K(o)>3||!this.disabled[1]&&K(a)>3)&&(this.updateTicker.resume(),this.pointer[2]=this.pointer[0],this.pointer[3]=this.pointer[1],this.pointer[0]=r,this.pointer[1]=n,this.dragged=!0,this.released=!1,this.onDrag(this)))}handleUp(){if(!this.grabbed)return;this.updateTicker.pause(),this.triggerStyles&&(this.triggerStyles.revert(),this.triggerStyles=null),this.bodyStyles&&(this.bodyStyles.revert(),this.bodyStyles=null);const[t,e]=this.disabled,[s,n,o,a,h,l]=this.pointer,[c,d,u,p]=this.containerBounds,[m,f]=this.snapped,g=this.releaseXSpring,y=this.releaseYSpring,_=this.releaseEase,v=this.hasReleaseSpring,b=this.overshootCoords,T=this.x,w=this.y,S=this.computeVelocity(s-h,n-l),x=this.angle=nt(n-a,s-o),k=150*S,$=(1-this.releaseContainerFriction)*this.dragSpeed,C=T+J(x)*k,E=w+Z(x)*k,B=C>d?d+(C-d)*$:C<p?p+(C-p)*$:C,L=E>u?u+(E-u)*$:E<c?c+(E-c)*$:E,A=this.destX=ht(ct(dt(B,this.snapX),5),p,d),N=this.destY=ht(ct(dt(L,this.snapY),5),c,u),F=this.isOutOfBounds(this.containerBounds,C,E);let O=0,P=0,R=_,M=_,I=0;if(b.x=T,b.y=w,!t){const t=A===d?T>d?-1:1:T<p?-1:1,s=ct(T-A,0);g.velocity=e&&v?s?k*t/K(s):0:S;const{ease:i,duration:r,restDuration:n}=g;O=T===A?0:v?r:r-n*D.timeScale,v&&(R=i),O>I&&(I=O)}if(!e){const e=N===u?w>u?-1:1:w<c?-1:1,s=ct(w-N,0);y.velocity=t&&v?s?k*e/K(s):0:S;const{ease:i,duration:r,restDuration:n}=y;P=w===N?0:v?r:r-n*D.timeScale,v&&(M=i),P>I&&(I=P)}if(!v&&F&&$&&(O||P)){const t=r.blend;new Re(b,{x:{to:B,duration:.65*O},y:{to:L,duration:.65*P},ease:_,composition:t}).init(),new Re(b,{x:{to:A,duration:O},y:{to:N,duration:P},ease:_,composition:t}).init(),this.overshootTicker.stretch(rt(O,P)).restart()}else t||this.animate[this.xProp](A,O,R),e||this.animate[this.yProp](N,P,M);this.scrollInView(I,this.scrollThreshold,_);let z=!1;A!==m&&(this.snapped[0]=A,this.snapX&&(z=!0)),N!==f&&this.snapY&&(this.snapped[1]=N,this.snapY&&(z=!0)),z&&this.onSnap(this),this.grabbed=!1,this.dragged=!1,this.updated=!0,this.released=!0,this.onRelease(this),this.$trigger.removeEventListener("touchstart",gs),this.$trigger.removeEventListener("touchmove",gs),this.$trigger.removeEventListener("touchend",gs),i.removeEventListener("touchmove",this),i.removeEventListener("touchend",this),i.removeEventListener("touchcancel",this),i.removeEventListener("mousemove",this),i.removeEventListener("mouseup",this),i.removeEventListener("selectstart",this)}reset(){return this.stop(),this.resizeTicker.pause(),this.grabbed=!1,this.dragged=!1,this.updated=!1,this.released=!1,this.canScroll=!1,this.setX(0,!0),this.setY(0,!0),this.coords[0]=0,this.coords[1]=0,this.pointer[0]=0,this.pointer[1]=0,this.pointer[2]=0,this.pointer[3]=0,this.pointer[4]=0,this.pointer[5]=0,this.pointer[6]=0,this.pointer[7]=0,this.velocity=0,this.velocityStack[0]=0,this.velocityStack[1]=0,this.velocityStack[2]=0,this.velocityStackIndex=0,this.angle=0,this}enable(){return this.enabled||(this.enabled=!0,this.$target.classList.remove("is-disabled"),this.touchActionStyles=es(this.$trigger,{touchAction:this.disabled[0]?"pan-x":this.disabled[1]?"pan-y":"none"}),this.$trigger.addEventListener("touchstart",this,{passive:!0}),this.$trigger.addEventListener("mousedown",this,{passive:!0}),this.$trigger.addEventListener("mouseenter",this)),this}disable(){return this.enabled=!1,this.grabbed=!1,this.dragged=!1,this.updated=!1,this.released=!1,this.canScroll=!1,this.touchActionStyles.revert(),this.cursorStyles&&(this.cursorStyles.revert(),this.cursorStyles=null),this.triggerStyles&&(this.triggerStyles.revert(),this.triggerStyles=null),this.bodyStyles&&(this.bodyStyles.revert(),this.bodyStyles=null),this.targetStyles&&(this.targetStyles.revert(),this.targetStyles=null),this.$target.classList.add("is-disabled"),this.$trigger.removeEventListener("touchstart",this),this.$trigger.removeEventListener("mousedown",this),this.$trigger.removeEventListener("mouseenter",this),i.removeEventListener("touchmove",this),i.removeEventListener("touchend",this),i.removeEventListener("touchcancel",this),i.removeEventListener("mousemove",this),i.removeEventListener("mouseup",this),i.removeEventListener("selectstart",this),this}revert(){return this.reset(),this.disable(),this.$target.classList.remove("is-disabled"),this.updateTicker.revert(),this.overshootTicker.revert(),this.resizeTicker.revert(),this.animate.revert(),this.resizeObserver.disconnect(),this}handleEvent(t){switch(t.type){case"mousedown":case"touchstart":this.handleDown(t);break;case"mousemove":case"touchmove":this.handleMove(t);break;case"mouseup":case"touchend":case"touchcancel":this.handleUp();break;case"mouseenter":this.handleHover();break;case"selectstart":gs(t)}}}class ws{constructor(t={}){L.current&&L.current.register(this);const e=t.root;let r=i;e&&(r=e.current||e.nativeElement||Ft(e)[0]||i);const n=t.defaults,o=D.defaults,a=t.mediaQueries;if(this.defaults=n?_t(n,o):o,this.root=r,this.constructors=[],this.revertConstructors=[],this.revertibles=[],this.constructorsOnce=[],this.revertConstructorsOnce=[],this.revertiblesOnce=[],this.once=!1,this.onceIndex=0,this.methods={},this.matches={},this.mediaQueryLists={},this.data={},a)for(let t in a){const e=s.matchMedia(a[t]);this.mediaQueryLists[t]=e,e.addEventListener("change",this)}}register(t){(this.once?this.revertiblesOnce:this.revertibles).push(t)}execute(t){let e=L.current,s=L.root,i=D.defaults;L.current=this,L.root=this.root,D.defaults=this.defaults;const r=this.mediaQueryLists;for(let t in r)this.matches[t]=r[t].matches;const n=t(this);return L.current=e,L.root=s,D.defaults=i,n}refresh(){return this.onceIndex=0,this.execute((()=>{let t=this.revertibles.length,e=this.revertConstructors.length;for(;t--;)this.revertibles[t].revert();for(;e--;)this.revertConstructors[e](this);this.revertibles.length=0,this.revertConstructors.length=0,this.constructors.forEach((t=>{const e=t(this);z(e)&&this.revertConstructors.push(e)}))})),this}add(t,e){if(this.once=!1,z(t)){const e=t;this.constructors.push(e),this.execute((()=>{const t=e(this);z(t)&&this.revertConstructors.push(t)}))}else this.methods[t]=(...t)=>this.execute((()=>e(...t)));return this}addOnce(t){if(this.once=!0,z(t)){const e=this.onceIndex++;if(this.constructorsOnce[e])return this;const s=t;this.constructorsOnce[e]=s,this.execute((()=>{const t=s(this);z(t)&&this.revertConstructorsOnce.push(t)}))}return this}keepTime(t){this.once=!0;const e=this.onceIndex++,s=this.constructorsOnce[e];if(z(s))return s(this);const i=wt(t);let r;return this.constructorsOnce[e]=i,this.execute((()=>{r=i(this)})),r}handleEvent(t){"change"===t.type&&this.refresh()}revert(){const t=this.revertibles,e=this.revertConstructors,s=this.revertiblesOnce,i=this.revertConstructorsOnce,r=this.mediaQueryLists;let n=t.length,o=e.length,a=s.length,h=i.length;for(;n--;)t[n].revert();for(;o--;)e[o](this);for(;a--;)s[a].revert();for(;h--;)i[h](this);for(let t in r)r[t].removeEventListener("change",this);t.length=0,e.length=0,this.constructors.length=0,s.length=0,i.length=0,this.constructorsOnce.length=0,this.onceIndex=0,this.matches={},this.methods={},this.mediaQueryLists={},this.data={}}}const Ss=(t,e)=>t&&z(t)?t(e):t,xs=new Map;class ks{constructor(t){this.element=t,this.useWin=this.element===i.body,this.winWidth=0,this.winHeight=0,this.width=0,this.height=0,this.left=0,this.top=0,this.zIndex=0,this.scrollX=0,this.scrollY=0,this.prevScrollX=0,this.prevScrollY=0,this.scrollWidth=0,this.scrollHeight=0,this.velocity=0,this.backwardX=!1,this.backwardY=!1,this.scrollTicker=new oe({autoplay:!1,onBegin:()=>this.dataTimer.resume(),onUpdate:()=>{const t=this.backwardX||this.backwardY;vt(this,(t=>t.handleScroll()),t)},onComplete:()=>this.dataTimer.pause()}).init(),this.dataTimer=new oe({autoplay:!1,frameRate:30,onUpdate:t=>{const e=t.deltaTime,s=this.prevScrollX,i=this.prevScrollY,r=this.scrollX,n=this.scrollY,o=s-r,a=i-n;this.prevScrollX=r,this.prevScrollY=n,o&&(this.backwardX=s>r),a&&(this.backwardY=i>n),this.velocity=ct(e>0?Math.sqrt(o*o+a*a)/e:0,5)}}).init(),this.resizeTicker=new oe({autoplay:!1,duration:250*D.timeScale,onComplete:()=>{this.updateWindowBounds(),this.refreshScrollObservers(),this.handleScroll()}}).init(),this.wakeTicker=new oe({autoplay:!1,duration:500*D.timeScale,onBegin:()=>{this.scrollTicker.resume()},onComplete:()=>{this.scrollTicker.pause()}}).init(),this._head=null,this._tail=null,this.updateScrollCoords(),this.updateWindowBounds(),this.updateBounds(),this.refreshScrollObservers(),this.handleScroll(),this.resizeObserver=new ResizeObserver((()=>this.resizeTicker.restart())),this.resizeObserver.observe(this.element),(this.useWin?s:this.element).addEventListener("scroll",this,!1)}updateScrollCoords(){const t=this.useWin,e=this.element;this.scrollX=ct(t?s.scrollX:e.scrollLeft,0),this.scrollY=ct(t?s.scrollY:e.scrollTop,0)}updateWindowBounds(){this.winWidth=s.innerWidth,this.winHeight=(()=>{const t=i.createElement("div");i.body.appendChild(t),t.style.height="100lvh";const e=t.offsetHeight;return i.body.removeChild(t),e})()}updateBounds(){const t=getComputedStyle(this.element),e=this.element;let s,i;if(this.scrollWidth=e.scrollWidth+parseFloat(t.marginLeft)+parseFloat(t.marginRight),this.scrollHeight=e.scrollHeight+parseFloat(t.marginTop)+parseFloat(t.marginBottom),this.updateWindowBounds(),this.useWin)s=this.winWidth,i=this.winHeight;else{const t=e.getBoundingClientRect();s=e.clientWidth,i=e.clientHeight,this.top=t.top,this.left=t.left}this.width=s,this.height=i}refreshScrollObservers(){vt(this,(t=>{t._debug&&t.removeDebug()})),this.updateBounds(),vt(this,(t=>{t.refresh(),t._debug&&t.debug()}))}refresh(){this.updateWindowBounds(),this.updateBounds(),this.refreshScrollObservers(),this.handleScroll()}handleScroll(){this.updateScrollCoords(),this.wakeTicker.restart()}handleEvent(t){"scroll"===t.type&&this.handleScroll()}revert(){this.scrollTicker.cancel(),this.dataTimer.cancel(),this.resizeTicker.cancel(),this.wakeTicker.cancel(),this.resizeObserver.disconnect(),(this.useWin?s:this.element).removeEventListener("scroll",this),xs.delete(this.element)}}const $s=(t,e,s,i,r)=>{const n="min"===e,o="max"===e,a="top"===e||"left"===e||"start"===e||n?0:"bottom"===e||"right"===e||"end"===e||o?"100%":"center"===e?"50%":e,{n:h,u:l}=Qt(a,Gt);let c=h;return"%"===l?c=h/100*s:l&&(c=$e(t,Gt,"px",!0).n),o&&i<0&&(c+=i),n&&r>0&&(c+=r),c},Cs=(t,e,s,i,r)=>{let n;if(I(e)){const o=E.exec(e);if(o){const a=o[0],h=a[0],l=e.split(a),c="min"===l[0],d="max"===l[0],u=$s(t,l[0],s,i,r),p=$s(t,l[1],s,i,r);if(c){const e=qt($s(t,"min",s),p,h);n=e<u?u:e}else if(d){const e=qt($s(t,"max",s),p,h);n=e>u?u:e}else n=qt(u,p,h)}else n=$s(t,e,s,i,r)}else n=e;return ct(n,0)},Es=t=>{let e;const s=t.targets;for(let t=0,i=s.length;t<i;t++){const i=s[t];if(i[o]){e=i;break}}return e};let Bs=0;const Ls=["#FF4B4B","#FF971B","#FFC730","#F9F640","#7AFF5A","#18FF74","#17E09B","#3CFFEC","#05DBE9","#33B3F1","#638CF9","#C563FE","#FF4FCF","#F93F8A"];class Ds{constructor(t={}){L.current&&L.current.register(this);const e=Xt(t.sync,"play pause"),s=e?Te(e):null,r=e&&("linear"===e||e===ae),n=e&&!(s===ae&&!r),o=e&&(M(e)||!0===e||r),a=e&&I(e)&&!n&&!o,h=a?e.split(" ").map((t=>()=>{const e=this.linked;return e&&e[t]?e[t]():null})):null,l=a&&h.length>2;this.index=Bs++,this.id=Y(t.id)?this.index:t.id,this.container=(t=>{const e=t&&Ft(t)[0]||i.body;let s=xs.get(e);return s||(s=new ks(e),xs.set(e,s)),s})(t.container),this.target=null,this.linked=null,this.repeat=null,this.horizontal=null,this.enter=null,this.leave=null,this.sync=n||o||!!h,this.syncEase=n?s:null,this.syncSmooth=o?!0===e||r?1:e:null,this.onSyncEnter=h&&!l&&h[0]?h[0]:_,this.onSyncLeave=h&&!l&&h[1]?h[1]:_,this.onSyncEnterForward=h&&l&&h[0]?h[0]:_,this.onSyncLeaveForward=h&&l&&h[1]?h[1]:_,this.onSyncEnterBackward=h&&l&&h[2]?h[2]:_,this.onSyncLeaveBackward=h&&l&&h[3]?h[3]:_,this.onEnter=t.onEnter||_,this.onLeave=t.onLeave||_,this.onEnterForward=t.onEnterForward||_,this.onLeaveForward=t.onLeaveForward||_,this.onEnterBackward=t.onEnterBackward||_,this.onLeaveBackward=t.onLeaveBackward||_,this.onUpdate=t.onUpdate||_,this.onSyncComplete=t.onSyncComplete||_,this.reverted=!1,this.completed=!1,this.began=!1,this.isInView=!1,this.forceEnter=!1,this.hasEntered=!1,this.offset=0,this.offsetStart=0,this.offsetEnd=0,this.distance=0,this.prevProgress=0,this.thresholds=["start","end","end","start"],this.coords=[0,0,0,0],this.debugStyles=null,this.$debug=null,this._params=t,this._debug=Xt(t.debug,!1),this._next=null,this._prev=null,Tt(this.container,this),Ke((()=>{if(!this.reverted){if(!this.target){const e=Ft(t.target)[0];this.target=e||i.body,this.refresh()}this._debug&&this.debug()}}))}link(t){if(t&&(t.pause(),this.linked=t,!this._params.target)){let e;Y(t.targets)?vt(t,(t=>{t.targets&&!e&&(e=Es(t))})):e=Es(t),this.target=e||i.body,this.refresh()}return this}get velocity(){return this.container.velocity}get backward(){return this.horizontal?this.container.backwardX:this.container.backwardY}get scroll(){return this.horizontal?this.container.scrollX:this.container.scrollY}get progress(){const t=(this.scroll-this.offsetStart)/this.distance;return t===1/0||isNaN(t)?0:ct(ht(t,0,1),6)}refresh(){this.reverted=!1;const t=this._params;return this.repeat=Xt(Ss(t.repeat,this),!0),this.horizontal="x"===Xt(Ss(t.axis,this),"y"),this.enter=Xt(Ss(t.enter,this),"end start"),this.leave=Xt(Ss(t.leave,this),"start end"),this.updateBounds(),this.handleScroll(),this}removeDebug(){return this.$debug&&(this.$debug.parentNode.removeChild(this.$debug),this.$debug=null),this.debugStyles&&(this.debugStyles.revert(),this.$debug=null),this}debug(){this.removeDebug();const t=this.container,e=this.horizontal,s=t.element.querySelector(":scope > .animejs-onscroll-debug"),r=i.createElement("div"),n=i.createElement("div"),o=i.createElement("div"),a=Ls[this.index%Ls.length],h=t.useWin,l=h?t.winWidth:t.width,c=h?t.winHeight:t.height,d=t.scrollWidth,u=t.scrollHeight,p=this.container.width>360?320:260,m=e?0:10,f=e?10:0,g=e?24:p/2,y=e?g:15,_=e?60:g,v=e?_:y,b=e?"repeat-x":"repeat-y",T=t=>e?"0px "+t+"px":t+"px 2px",w=t=>`linear-gradient(${e?90:0}deg, ${t} 2px, transparent 1px)`,S=(t,e,s,i,r)=>`position:${t};left:${e}px;top:${s}px;width:${i}px;height:${r}px;`;r.style.cssText=`${S("absolute",m,f,e?d:p,e?p:u)}\n pointer-events: none;\n z-index: ${this.container.zIndex++};\n display: flex;\n flex-direction: ${e?"column":"row"};\n filter: drop-shadow(0px 1px 0px rgba(0,0,0,.75));\n `,n.style.cssText=`${S("sticky",0,0,e?l:g,e?g:c)}`,s||(n.style.cssText+=`background:\n ${w("#FFFF")}${T(g-10)} / 100px 100px ${b},\n ${w("#FFF8")}${T(g-10)} / 10px 10px ${b};\n `),o.style.cssText=`${S("relative",0,0,e?d:g,e?g:u)}`,s||(o.style.cssText+=`background:\n ${w("#FFFF")}${T(0)} / ${e?"100px 10px":"10px 100px"} ${b},\n ${w("#FFF8")}${T(0)} / ${e?"10px 0px":"0px 10px"} ${b};\n `);const x=[" enter: "," leave: "];this.coords.forEach(((t,s)=>{const r=s>1,h=(r?0:this.offset)+t,m=s%2,f=h<v,g=h>(r?e?l:c:e?d:u)-v,b=(r?m&&!f:!m&&!f)||g,T=i.createElement("div"),w=i.createElement("div"),k=e?b?"right":"left":b?"bottom":"top",$=b?(e?_:y)+(r?e?-1:g?0:-2:e?-1:-2):e?1:0;w.innerHTML=`${this.id}${x[m]}${this.thresholds[s]}`,T.style.cssText=`${S("absolute",0,0,_,y)}\n display: flex;\n flex-direction: ${e?"column":"row"};\n justify-content: flex-${r?"start":"end"};\n align-items: flex-${b?"end":"start"};\n border-${k}: 2px solid ${a};\n `,w.style.cssText=`\n overflow: hidden;\n max-width: ${p/2-10}px;\n height: ${y};\n margin-${e?b?"right":"left":b?"bottom":"top"}: -2px;\n padding: 1px;\n font-family: ui-monospace, monospace;\n font-size: 10px;\n letter-spacing: -.025em;\n line-height: 9px;\n font-weight: 600;\n text-align: ${e&&b||!e&&!r?"right":"left"};\n white-space: pre;\n text-overflow: ellipsis;\n color: ${m?a:"rgba(0,0,0,.75)"};\n background-color: ${m?"rgba(0,0,0,.65)":a};\n border: 2px solid ${m?a:"transparent"};\n border-${e?b?"top-left":"top-right":b?"top-left":"bottom-left"}-radius: 5px;\n border-${e?b?"bottom-left":"bottom-right":b?"top-right":"bottom-right"}-radius: 5px;\n `,T.appendChild(w);let C=h-$+(e?1:0);T.style[e?"left":"top"]=`${C}px`,(r?n:o).appendChild(T)})),r.appendChild(n),r.appendChild(o),t.element.appendChild(r),s||r.classList.add("animejs-onscroll-debug"),this.$debug=r,"static"===ts(t.element,"position")&&(this.debugStyles=es(t.element,{position:"relative "}))}updateBounds(){let t;this._debug&&this.removeDebug();const e=this.target,s=this.container,r=this.horizontal,n=this.linked;let o,a=e;for(n&&(o=n.currentTime,n.seek(0,!0)),a.parentElement;a&&a!==s.element&&a!==i.body;){const e="sticky"===ts(a,"position")&&es(a,{position:"static"});a=a.parentElement,e&&(t||(t=[]),t.push(e))}const h=e.getBoundingClientRect(),l=r?h.left+s.scrollX-s.left:h.top+s.scrollY-s.top,c=r?h.width:h.height,d=r?s.width:s.height,u=(r?s.scrollWidth:s.scrollHeight)-d,p=this.enter,m=this.leave;let f="start",g="end",y="end",_="start";if(I(p)){const t=p.split(" ");y=t[0],f=t.length>1?t[1]:f}else if(R(p)){const t=p;Y(t.container)||(y=t.container),Y(t.target)||(f=t.target)}else M(p)&&(y=p);if(I(m)){const t=m.split(" ");_=t[0],g=t.length>1?t[1]:g}else if(R(m)){const t=m;Y(t.container)||(_=t.container),Y(t.target)||(g=t.target)}else M(m)&&(_=m);const v=Cs(e,f,c),b=Cs(e,g,c),T=v+l-d,w=b+l-u,S=Cs(e,y,d,T,w),x=Cs(e,_,d,T,w),k=v+l-S,$=b+l-x,C=$-k;this.offset=l,this.offsetStart=k,this.offsetEnd=$,this.distance=C<=0?0:C,this.thresholds=[f,g,y,_],this.coords=[v,b,S,x],t&&t.forEach((t=>t.revert())),n&&n.seek(o,!0),this._debug&&this.debug()}handleScroll(){const t=this.linked,e=this.sync,s=this.syncEase,i=this.syncSmooth,r=t&&(s||i),n=this.horizontal,o=this.container,a=this.scroll,h=a<=this.offsetStart,l=a>=this.offsetEnd,c=!h&&!l,d=a===this.offsetStart||a===this.offsetEnd,u=!this.hasEntered&&d,p=this._debug&&this.$debug;let m=!1,f=!1,g=this.progress;if(h&&this.began&&(this.began=!1),g>0&&!this.began&&(this.began=!0),r){const e=t.progress;if(i&&M(i)){if(i<1){const t=e<g&&1===g?1e-4:e>g&&!g?-1e-4:0;g=ct(ns(e,g,ut(.01,.2,i),!1)+t,6)}}else s&&(g=s(g));m=g!==this.prevProgress,f=1===e,m&&!f&&i&&e&&o.wakeTicker.restart()}if(p){const t=n?o.scrollY:o.scrollX;p.style[n?"top":"left"]=t+10+"px"}(c&&!this.isInView||u&&!this.forceEnter&&!this.hasEntered)&&(c&&(this.isInView=!0),this.forceEnter&&this.hasEntered?c&&(this.forceEnter=!1):(p&&c&&(p.style.zIndex=""+this.container.zIndex++),this.onSyncEnter(this),this.onEnter(this),this.backward?(this.onSyncEnterBackward(this),this.onEnterBackward(this)):(this.onSyncEnterForward(this),this.onEnterForward(this)),this.hasEntered=!0,u&&(this.forceEnter=!0))),(c||!c&&this.isInView)&&(m=!0),m&&(r&&t.seek(t.duration*g),this.onUpdate(this)),!c&&this.isInView&&(this.isInView=!1,this.onSyncLeave(this),this.onLeave(this),this.backward?(this.onSyncLeaveBackward(this),this.onLeaveBackward(this)):(this.onSyncLeaveForward(this),this.onLeaveForward(this)),e&&!i&&(f=!0)),g>=1&&this.began&&!this.completed&&(e&&f||!e)&&(e&&this.onSyncComplete(this),this.completed=!0,(!this.repeat&&!t||!this.repeat&&t&&t.completed)&&this.revert()),g<1&&this.completed&&(this.completed=!1),this.prevProgress=g}revert(){if(this.reverted)return;const t=this.container;return bt(t,this),t._head||t.revert(),this._debug&&this.removeDebug(),this.reverted=!0,this}}const As="undefined"!=typeof Intl&&Intl.Segmenter,Ns=/\{value\}/g,Fs=/\{i\}/g,Os=/(\s+)/,Ps=/^\s+$/,Rs="line",Ms="word",Is="char",zs="data-line";let Ys=null,Xs=null,Ws=null;const Vs=t=>t.isWordLike||" "===t.segment||M(+t.segment),Hs=t=>t.setAttribute("aria-hidden","true"),Us=(t,e)=>[...t.querySelectorAll(`[data-${e}]:not([data-${e}] [data-${e}])`)],qs={line:"#00D672",word:"#FF4B4B",char:"#5A87FF"},Qs=t=>{if(!t.childElementCount&&!t.textContent.trim()){const e=t.parentElement;t.remove(),e&&Qs(e)}},js=(t,e,s)=>{const i=t.getAttribute(zs);(null!==i&&+i!==e||"BR"===t.tagName)&&s.add(t);let r=t.childElementCount;for(;r--;)js(t.children[r],e,s);return s},Gs=(t,e={})=>{let s="";const i=I(e.class)?` class="${e.class}"`:"",r=Xt(e.clone,!1),n=Xt(e.wrap,!1),o=n?!0===n?"clip":n:!!r&&"clip";return n&&(s+=`<span${o?` style="overflow:${o};"`:""}>`),s+=`<span${i}${r?' style="position:relative;"':""} data-${t}="{i}">`,r?(s+="<span>{value}</span>",s+=`<span inert style="position:absolute;top:${"top"===r?"-100%":"bottom"===r?"100%":"0"};left:${"left"===r?"-100%":"right"===r?"100%":"0"};white-space:nowrap;">{value}</span>`):s+="{value}",s+="</span>",n&&(s+="</span>"),s},Zs=(t,e,s,i,r,n,o,a,h)=>{const l=r===Rs,c=r===Is,d=`_${r}_`,u=z(t)?t(s):t,p=l?"block":"inline-block";Ws.innerHTML=u.replace(Ns,`<i class="${d}"></i>`).replace(Fs,`${c?h:l?o:a}`);const m=Ws.content,f=m.firstElementChild,g=m.querySelector(`[data-${r}]`)||f,y=m.querySelectorAll(`i.${d}`),_=y.length;if(_){f.style.display=p,g.style.display=p,g.setAttribute(zs,`${o}`),l||(g.setAttribute("data-word",`${a}`),c&&g.setAttribute("data-char",`${h}`));let t=_;for(;t--;){const e=y[t],i=e.parentElement;i.style.display=p,l?i.innerHTML=s.innerHTML:i.replaceChild(s.cloneNode(!0),e)}e.push(g),i.appendChild(m)}else console.warn('The expression "{value}" is missing from the provided template.');return n&&(f.style.outline=`1px dotted ${qs[r]}`),f};class Js{constructor(t,s={}){Ys||(Ys=As?new As([],{granularity:Ms}):{segment:t=>{const e=[],s=t.split(Os);for(let t=0,i=s.length;t<i;t++){const i=s[t];e.push({segment:i,isWordLike:!Ps.test(i)})}return e}}),Xs||(Xs=As?new As([],{granularity:"grapheme"}):{segment:t=>[...t].map((t=>({segment:t})))}),!Ws&&e&&(Ws=i.createElement("template")),L.current&&L.current.register(this);const{words:r,chars:n,lines:o,accessible:a,includeSpaces:h,debug:l}=s,c=(t=P(t)?t[0]:t)&&t.nodeType?t:(Nt(t)||[])[0],d=!0===o?{}:o,u=!0===r||Y(r)?{}:r,p=!0===n?{}:n;this.debug=Xt(l,!1),this.includeSpaces=Xt(h,!1),this.accessible=Xt(a,!0),this.linesOnly=d&&!u&&!p,this.lineTemplate=R(d)?Gs(Rs,d):d,this.wordTemplate=R(u)||this.linesOnly?Gs(Ms,u):u,this.charTemplate=R(p)?Gs(Is,p):p,this.$target=c,this.html=c&&c.innerHTML,this.lines=[],this.words=[],this.chars=[],this.effects=[],this.effectsCleanups=[],this.cache=null,this.ready=!1,this.width=0,this.resizeTimeout=null;const m=()=>this.html&&(d||u||p)&&this.split();this.resizeObserver=new ResizeObserver((()=>{clearTimeout(this.resizeTimeout),this.resizeTimeout=setTimeout((()=>{const t=c.offsetWidth;t!==this.width&&(this.width=t,m())}),150)})),this.lineTemplate&&!this.ready?i.fonts.ready.then(m):m(),c?this.resizeObserver.observe(c):console.warn("No Text Splitter target found.")}addEffect(t){if(!z(t))return console.warn("Effect must return a function.");const e=wt(t);return this.effects.push(e),this.ready&&(this.effectsCleanups[this.effects.length-1]=e(this)),this}revert(){return clearTimeout(this.resizeTimeout),this.lines.length=this.words.length=this.chars.length=0,this.resizeObserver.disconnect(),this.effectsCleanups.forEach((t=>z(t)?t(this):t.revert&&t.revert())),this.$target.innerHTML=this.html,this}splitNode(t){const e=this.wordTemplate,s=this.charTemplate,r=this.includeSpaces,n=this.debug,o=t.nodeType;if(3===o){const o=t.nodeValue;if(o.trim()){const a=[],h=this.words,l=this.chars,c=Ys.segment(o),d=i.createDocumentFragment();let u=null;for(const t of c){const e=t.segment,s=Vs(t);if(!u||s&&u&&Vs(u))a.push(e);else{const t=a.length-1;a[t].includes(" ")||e.includes(" ")?a.push(e):a[t]+=e}u=t}for(let t=0,o=a.length;t<o;t++){const o=a[t];if(o.trim()){const c=a[t+1],u=r&&c&&!c.trim(),p=o,m=s?Xs.segment(p):null,f=s?i.createDocumentFragment():i.createTextNode(u?o+" ":o);if(s){const t=[...m];for(let e=0,r=t.length;e<r;e++){const o=t[e],a=e===r-1&&u?o.segment+" ":o.segment,c=i.createTextNode(a);Zs(s,l,c,f,Is,n,-1,h.length,l.length)}}e?Zs(e,h,f,d,Ms,n,-1,h.length,l.length):s?d.appendChild(f):d.appendChild(i.createTextNode(o)),u&&t++}else{if(t&&r)continue;d.appendChild(i.createTextNode(o))}}t.parentNode.replaceChild(d,t)}}else if(1===o){const e=[...t.childNodes];for(let t=0,s=e.length;t<s;t++)this.splitNode(e[t])}}split(t=!1){const e=this.$target,s=!!this.cache&&!t,r=this.lineTemplate,n=this.wordTemplate,o=this.charTemplate,a="loading"!==i.fonts.status,h=r&&a;this.ready=!r||a,(h||t)&&this.effectsCleanups.forEach((t=>z(t)&&t(this))),s||(t&&(e.innerHTML=this.html,this.words.length=this.chars.length=0),this.splitNode(e),this.cache=e.innerHTML),h&&(s&&(e.innerHTML=this.cache),this.lines.length=0,n&&(this.words=Us(e,Ms))),o&&(h||n)&&(this.chars=Us(e,Is));const l=this.words.length?this.words:this.chars;let c,d=0;for(let t=0,e=l.length;t<e;t++){const e=l[t],{top:s,height:i}=e.getBoundingClientRect();c&&s-c>.5*i&&d++,e.setAttribute(zs,`${d}`);const r=e.querySelectorAll(`[${zs}]`);let n=r.length;for(;n--;)r[n].setAttribute(zs,`${d}`);c=s}if(h){const t=i.createDocumentFragment(),s=new Set,a=[];for(let t=0;t<d+1;t++){const i=e.cloneNode(!0);js(i,t,new Set).forEach((t=>{const e=t.parentElement;e&&s.add(e),t.remove()})),a.push(i)}s.forEach(Qs);for(let e=0,s=a.length;e<s;e++)Zs(r,this.lines,a[e],t,Rs,this.debug,e);e.innerHTML="",e.appendChild(t),n&&(this.words=Us(e,Ms)),o&&(this.chars=Us(e,Is))}if(this.linesOnly){const t=this.words;let e=t.length;for(;e--;){const s=t[e];s.replaceWith(s.textContent)}t.length=0}if(this.accessible&&(h||!s)){const t=i.createElement("span");t.style.cssText="position:absolute;overflow:hidden;clip:rect(0 0 0 0);clip-path:inset(50%);width:1px;height:1px;white-space:nowrap;",t.innerHTML=this.html,e.insertBefore(t,e.firstChild),this.lines.forEach(Hs),this.words.forEach(Hs),this.chars.forEach(Hs)}return this.width=e.offsetWidth,(h||t)&&this.effects.forEach(((t,e)=>this.effectsCleanups[e]=t(this))),this}refresh(){this.split(!0)}}const Ks={split:(t,e)=>new Js(t,e)};return t.Animatable=us,t.Draggable=Ts,t.JSAnimation=Re,t.Scope=ws,t.ScrollObserver=Ds,t.Spring=ms,t.TextSplitter=Js,t.Timeline=ds,t.Timer=oe,t.WAAPIAnimation=Ze,t.animate=(t,e)=>new Re(t,e,null,0,!1).init(),t.createAnimatable=(t,e)=>new us(t,e),t.createDraggable=(t,e)=>new Ts(t,e),t.createScope=t=>new ws(t),t.createSpring=fs,t.createTimeline=t=>new ds(t).init(),t.createTimer=t=>new oe(t,null,0).init(),t.eases=ve,t.engine=Lt,t.onScroll=(t={})=>new Ds(t),t.scrollContainers=xs,t.stagger=(t,e={})=>{let s=[],i=0;const r=e.from,n=e.reversed,o=e.ease,a=!Y(o),h=a&&!Y(o.ease)?o.ease:a?Te(o):null,l=e.grid,c=e.axis,d=e.total,u=Y(r)||0===r||"first"===r,p="center"===r,f="last"===r,g="random"===r,y=P(t),_=e.use,v=Q(y?t[0]:t),b=y?Q(t[1]):0,T=k.exec((y?t[1]:t)+m),w=e.start||0+(y?v:0);let S=u?0:M(r)?r:0;return(t,r,o,a)=>{const[u]=Ot(t),m=Y(d)?o:d,x=!Y(_)&&(z(_)?_(u,r,m):Ut(u,_)),k=M(x)||I(x)&&M(+x)?+x:r;if(p&&(S=(m-1)/2),f&&(S=m-1),!s.length){for(let t=0;t<m;t++){if(l){const e=p?(l[0]-1)/2:S%l[0],i=p?(l[1]-1)/2:st(S/l[0]),r=e-t%l[0],n=i-st(t/l[0]);let o=G(r*r+n*n);"x"===c&&(o=-r),"y"===c&&(o=-n),s.push(o)}else s.push(K(S-t));i=rt(...s)}h&&(s=s.map((t=>h(t/i)*i))),n&&(s=s.map((t=>c?t<0?-1*t:-t:K(i-t)))),g&&(s=mt(s))}const $=y?(b-v)/i:v;let C=(a?ls(a,Y(e.start)?a.iterationDuration:w):w)+($*ct(s[k],2)||0);return e.modifier&&(C=e.modifier(C)),T&&(C=`${C}${T[2]}`),C}},t.svg=zt,t.text=Ks,t.utils=hs,t.waapi=Je,t}({});
  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: v5.3.7
  484. Plugin URL: https://getbootstrap.com/
  485. License: Copyright 2011-2025 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.harrytheo.com/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.call(...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);
  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.7';
  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. // Private
  1118. _queueCallback(callback, element, isAnimated = true) {
  1119. executeAfterTransition(callback, element, isAnimated);
  1120. }
  1121. _getConfig(config) {
  1122. config = this._mergeConfigObj(config, this._element);
  1123. config = this._configAfterMerge(config);
  1124. this._typeCheckConfig(config);
  1125. return config;
  1126. }
  1127. // Static
  1128. static getInstance(element) {
  1129. return Data.get(getElement(element), this.DATA_KEY);
  1130. }
  1131. static getOrCreateInstance(element, config = {}) {
  1132. return this.getInstance(element) || new this(element, typeof config === 'object' ? config : null);
  1133. }
  1134. static get VERSION() {
  1135. return VERSION;
  1136. }
  1137. static get DATA_KEY() {
  1138. return `bs.${this.NAME}`;
  1139. }
  1140. static get EVENT_KEY() {
  1141. return `.${this.DATA_KEY}`;
  1142. }
  1143. static eventName(name) {
  1144. return `${name}${this.EVENT_KEY}`;
  1145. }
  1146. }
  1147. /**
  1148. * --------------------------------------------------------------------------
  1149. * Bootstrap dom/selector-engine.js
  1150. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  1151. * --------------------------------------------------------------------------
  1152. */
  1153. const getSelector = element => {
  1154. let selector = element.getAttribute('data-bs-target');
  1155. if (!selector || selector === '#') {
  1156. let hrefAttribute = element.getAttribute('href');
  1157. // The only valid content that could double as a selector are IDs or classes,
  1158. // so everything starting with `#` or `.`. If a "real" URL is used as the selector,
  1159. // `document.querySelector` will rightfully complain it is invalid.
  1160. // See https://github.com/twbs/bootstrap/issues/32273
  1161. if (!hrefAttribute || !hrefAttribute.includes('#') && !hrefAttribute.startsWith('.')) {
  1162. return null;
  1163. }
  1164. // Just in case some CMS puts out a full URL with the anchor appended
  1165. if (hrefAttribute.includes('#') && !hrefAttribute.startsWith('#')) {
  1166. hrefAttribute = `#${hrefAttribute.split('#')[1]}`;
  1167. }
  1168. selector = hrefAttribute && hrefAttribute !== '#' ? hrefAttribute.trim() : null;
  1169. }
  1170. return selector ? selector.split(',').map(sel => parseSelector(sel)).join(',') : null;
  1171. };
  1172. const SelectorEngine = {
  1173. find(selector, element = document.documentElement) {
  1174. return [].concat(...Element.prototype.querySelectorAll.call(element, selector));
  1175. },
  1176. findOne(selector, element = document.documentElement) {
  1177. return Element.prototype.querySelector.call(element, selector);
  1178. },
  1179. children(element, selector) {
  1180. return [].concat(...element.children).filter(child => child.matches(selector));
  1181. },
  1182. parents(element, selector) {
  1183. const parents = [];
  1184. let ancestor = element.parentNode.closest(selector);
  1185. while (ancestor) {
  1186. parents.push(ancestor);
  1187. ancestor = ancestor.parentNode.closest(selector);
  1188. }
  1189. return parents;
  1190. },
  1191. prev(element, selector) {
  1192. let previous = element.previousElementSibling;
  1193. while (previous) {
  1194. if (previous.matches(selector)) {
  1195. return [previous];
  1196. }
  1197. previous = previous.previousElementSibling;
  1198. }
  1199. return [];
  1200. },
  1201. // TODO: this is now unused; remove later along with prev()
  1202. next(element, selector) {
  1203. let next = element.nextElementSibling;
  1204. while (next) {
  1205. if (next.matches(selector)) {
  1206. return [next];
  1207. }
  1208. next = next.nextElementSibling;
  1209. }
  1210. return [];
  1211. },
  1212. focusableChildren(element) {
  1213. const focusables = ['a', 'button', 'input', 'textarea', 'select', 'details', '[tabindex]', '[contenteditable="true"]'].map(selector => `${selector}:not([tabindex^="-"])`).join(',');
  1214. return this.find(focusables, element).filter(el => !isDisabled(el) && isVisible(el));
  1215. },
  1216. getSelectorFromElement(element) {
  1217. const selector = getSelector(element);
  1218. if (selector) {
  1219. return SelectorEngine.findOne(selector) ? selector : null;
  1220. }
  1221. return null;
  1222. },
  1223. getElementFromSelector(element) {
  1224. const selector = getSelector(element);
  1225. return selector ? SelectorEngine.findOne(selector) : null;
  1226. },
  1227. getMultipleElementsFromSelector(element) {
  1228. const selector = getSelector(element);
  1229. return selector ? SelectorEngine.find(selector) : [];
  1230. }
  1231. };
  1232. /**
  1233. * --------------------------------------------------------------------------
  1234. * Bootstrap util/component-functions.js
  1235. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  1236. * --------------------------------------------------------------------------
  1237. */
  1238. const enableDismissTrigger = (component, method = 'hide') => {
  1239. const clickEvent = `click.dismiss${component.EVENT_KEY}`;
  1240. const name = component.NAME;
  1241. EventHandler.on(document, clickEvent, `[data-bs-dismiss="${name}"]`, function (event) {
  1242. if (['A', 'AREA'].includes(this.tagName)) {
  1243. event.preventDefault();
  1244. }
  1245. if (isDisabled(this)) {
  1246. return;
  1247. }
  1248. const target = SelectorEngine.getElementFromSelector(this) || this.closest(`.${name}`);
  1249. const instance = component.getOrCreateInstance(target);
  1250. // Method argument is left, for Alert and only, as it doesn't implement the 'hide' method
  1251. instance[method]();
  1252. });
  1253. };
  1254. /**
  1255. * --------------------------------------------------------------------------
  1256. * Bootstrap alert.js
  1257. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  1258. * --------------------------------------------------------------------------
  1259. */
  1260. /**
  1261. * Constants
  1262. */
  1263. const NAME$f = 'alert';
  1264. const DATA_KEY$a = 'bs.alert';
  1265. const EVENT_KEY$b = `.${DATA_KEY$a}`;
  1266. const EVENT_CLOSE = `close${EVENT_KEY$b}`;
  1267. const EVENT_CLOSED = `closed${EVENT_KEY$b}`;
  1268. const CLASS_NAME_FADE$5 = 'fade';
  1269. const CLASS_NAME_SHOW$8 = 'show';
  1270. /**
  1271. * Class definition
  1272. */
  1273. class Alert extends BaseComponent {
  1274. // Getters
  1275. static get NAME() {
  1276. return NAME$f;
  1277. }
  1278. // Public
  1279. close() {
  1280. const closeEvent = EventHandler.trigger(this._element, EVENT_CLOSE);
  1281. if (closeEvent.defaultPrevented) {
  1282. return;
  1283. }
  1284. this._element.classList.remove(CLASS_NAME_SHOW$8);
  1285. const isAnimated = this._element.classList.contains(CLASS_NAME_FADE$5);
  1286. this._queueCallback(() => this._destroyElement(), this._element, isAnimated);
  1287. }
  1288. // Private
  1289. _destroyElement() {
  1290. this._element.remove();
  1291. EventHandler.trigger(this._element, EVENT_CLOSED);
  1292. this.dispose();
  1293. }
  1294. // Static
  1295. static jQueryInterface(config) {
  1296. return this.each(function () {
  1297. const data = Alert.getOrCreateInstance(this);
  1298. if (typeof config !== 'string') {
  1299. return;
  1300. }
  1301. if (data[config] === undefined || config.startsWith('_') || config === 'constructor') {
  1302. throw new TypeError(`No method named "${config}"`);
  1303. }
  1304. data[config](this);
  1305. });
  1306. }
  1307. }
  1308. /**
  1309. * Data API implementation
  1310. */
  1311. enableDismissTrigger(Alert, 'close');
  1312. /**
  1313. * jQuery
  1314. */
  1315. defineJQueryPlugin(Alert);
  1316. /**
  1317. * --------------------------------------------------------------------------
  1318. * Bootstrap button.js
  1319. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  1320. * --------------------------------------------------------------------------
  1321. */
  1322. /**
  1323. * Constants
  1324. */
  1325. const NAME$e = 'button';
  1326. const DATA_KEY$9 = 'bs.button';
  1327. const EVENT_KEY$a = `.${DATA_KEY$9}`;
  1328. const DATA_API_KEY$6 = '.data-api';
  1329. const CLASS_NAME_ACTIVE$3 = 'active';
  1330. const SELECTOR_DATA_TOGGLE$5 = '[data-bs-toggle="button"]';
  1331. const EVENT_CLICK_DATA_API$6 = `click${EVENT_KEY$a}${DATA_API_KEY$6}`;
  1332. /**
  1333. * Class definition
  1334. */
  1335. class Button extends BaseComponent {
  1336. // Getters
  1337. static get NAME() {
  1338. return NAME$e;
  1339. }
  1340. // Public
  1341. toggle() {
  1342. // Toggle class and sync the `aria-pressed` attribute with the return value of the `.toggle()` method
  1343. this._element.setAttribute('aria-pressed', this._element.classList.toggle(CLASS_NAME_ACTIVE$3));
  1344. }
  1345. // Static
  1346. static jQueryInterface(config) {
  1347. return this.each(function () {
  1348. const data = Button.getOrCreateInstance(this);
  1349. if (config === 'toggle') {
  1350. data[config]();
  1351. }
  1352. });
  1353. }
  1354. }
  1355. /**
  1356. * Data API implementation
  1357. */
  1358. EventHandler.on(document, EVENT_CLICK_DATA_API$6, SELECTOR_DATA_TOGGLE$5, event => {
  1359. event.preventDefault();
  1360. const button = event.target.closest(SELECTOR_DATA_TOGGLE$5);
  1361. const data = Button.getOrCreateInstance(button);
  1362. data.toggle();
  1363. });
  1364. /**
  1365. * jQuery
  1366. */
  1367. defineJQueryPlugin(Button);
  1368. /**
  1369. * --------------------------------------------------------------------------
  1370. * Bootstrap util/swipe.js
  1371. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  1372. * --------------------------------------------------------------------------
  1373. */
  1374. /**
  1375. * Constants
  1376. */
  1377. const NAME$d = 'swipe';
  1378. const EVENT_KEY$9 = '.bs.swipe';
  1379. const EVENT_TOUCHSTART = `touchstart${EVENT_KEY$9}`;
  1380. const EVENT_TOUCHMOVE = `touchmove${EVENT_KEY$9}`;
  1381. const EVENT_TOUCHEND = `touchend${EVENT_KEY$9}`;
  1382. const EVENT_POINTERDOWN = `pointerdown${EVENT_KEY$9}`;
  1383. const EVENT_POINTERUP = `pointerup${EVENT_KEY$9}`;
  1384. const POINTER_TYPE_TOUCH = 'touch';
  1385. const POINTER_TYPE_PEN = 'pen';
  1386. const CLASS_NAME_POINTER_EVENT = 'pointer-event';
  1387. const SWIPE_THRESHOLD = 40;
  1388. const Default$c = {
  1389. endCallback: null,
  1390. leftCallback: null,
  1391. rightCallback: null
  1392. };
  1393. const DefaultType$c = {
  1394. endCallback: '(function|null)',
  1395. leftCallback: '(function|null)',
  1396. rightCallback: '(function|null)'
  1397. };
  1398. /**
  1399. * Class definition
  1400. */
  1401. class Swipe extends Config {
  1402. constructor(element, config) {
  1403. super();
  1404. this._element = element;
  1405. if (!element || !Swipe.isSupported()) {
  1406. return;
  1407. }
  1408. this._config = this._getConfig(config);
  1409. this._deltaX = 0;
  1410. this._supportPointerEvents = Boolean(window.PointerEvent);
  1411. this._initEvents();
  1412. }
  1413. // Getters
  1414. static get Default() {
  1415. return Default$c;
  1416. }
  1417. static get DefaultType() {
  1418. return DefaultType$c;
  1419. }
  1420. static get NAME() {
  1421. return NAME$d;
  1422. }
  1423. // Public
  1424. dispose() {
  1425. EventHandler.off(this._element, EVENT_KEY$9);
  1426. }
  1427. // Private
  1428. _start(event) {
  1429. if (!this._supportPointerEvents) {
  1430. this._deltaX = event.touches[0].clientX;
  1431. return;
  1432. }
  1433. if (this._eventIsPointerPenTouch(event)) {
  1434. this._deltaX = event.clientX;
  1435. }
  1436. }
  1437. _end(event) {
  1438. if (this._eventIsPointerPenTouch(event)) {
  1439. this._deltaX = event.clientX - this._deltaX;
  1440. }
  1441. this._handleSwipe();
  1442. execute(this._config.endCallback);
  1443. }
  1444. _move(event) {
  1445. this._deltaX = event.touches && event.touches.length > 1 ? 0 : event.touches[0].clientX - this._deltaX;
  1446. }
  1447. _handleSwipe() {
  1448. const absDeltaX = Math.abs(this._deltaX);
  1449. if (absDeltaX <= SWIPE_THRESHOLD) {
  1450. return;
  1451. }
  1452. const direction = absDeltaX / this._deltaX;
  1453. this._deltaX = 0;
  1454. if (!direction) {
  1455. return;
  1456. }
  1457. execute(direction > 0 ? this._config.rightCallback : this._config.leftCallback);
  1458. }
  1459. _initEvents() {
  1460. if (this._supportPointerEvents) {
  1461. EventHandler.on(this._element, EVENT_POINTERDOWN, event => this._start(event));
  1462. EventHandler.on(this._element, EVENT_POINTERUP, event => this._end(event));
  1463. this._element.classList.add(CLASS_NAME_POINTER_EVENT);
  1464. } else {
  1465. EventHandler.on(this._element, EVENT_TOUCHSTART, event => this._start(event));
  1466. EventHandler.on(this._element, EVENT_TOUCHMOVE, event => this._move(event));
  1467. EventHandler.on(this._element, EVENT_TOUCHEND, event => this._end(event));
  1468. }
  1469. }
  1470. _eventIsPointerPenTouch(event) {
  1471. return this._supportPointerEvents && (event.pointerType === POINTER_TYPE_PEN || event.pointerType === POINTER_TYPE_TOUCH);
  1472. }
  1473. // Static
  1474. static isSupported() {
  1475. return 'ontouchstart' in document.documentElement || navigator.maxTouchPoints > 0;
  1476. }
  1477. }
  1478. /**
  1479. * --------------------------------------------------------------------------
  1480. * Bootstrap carousel.js
  1481. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  1482. * --------------------------------------------------------------------------
  1483. */
  1484. /**
  1485. * Constants
  1486. */
  1487. const NAME$c = 'carousel';
  1488. const DATA_KEY$8 = 'bs.carousel';
  1489. const EVENT_KEY$8 = `.${DATA_KEY$8}`;
  1490. const DATA_API_KEY$5 = '.data-api';
  1491. const ARROW_LEFT_KEY$1 = 'ArrowLeft';
  1492. const ARROW_RIGHT_KEY$1 = 'ArrowRight';
  1493. const TOUCHEVENT_COMPAT_WAIT = 500; // Time for mouse compat events to fire after touch
  1494. const ORDER_NEXT = 'next';
  1495. const ORDER_PREV = 'prev';
  1496. const DIRECTION_LEFT = 'left';
  1497. const DIRECTION_RIGHT = 'right';
  1498. const EVENT_SLIDE = `slide${EVENT_KEY$8}`;
  1499. const EVENT_SLID = `slid${EVENT_KEY$8}`;
  1500. const EVENT_KEYDOWN$1 = `keydown${EVENT_KEY$8}`;
  1501. const EVENT_MOUSEENTER$1 = `mouseenter${EVENT_KEY$8}`;
  1502. const EVENT_MOUSELEAVE$1 = `mouseleave${EVENT_KEY$8}`;
  1503. const EVENT_DRAG_START = `dragstart${EVENT_KEY$8}`;
  1504. const EVENT_LOAD_DATA_API$3 = `load${EVENT_KEY$8}${DATA_API_KEY$5}`;
  1505. const EVENT_CLICK_DATA_API$5 = `click${EVENT_KEY$8}${DATA_API_KEY$5}`;
  1506. const CLASS_NAME_CAROUSEL = 'carousel';
  1507. const CLASS_NAME_ACTIVE$2 = 'active';
  1508. const CLASS_NAME_SLIDE = 'slide';
  1509. const CLASS_NAME_END = 'carousel-item-end';
  1510. const CLASS_NAME_START = 'carousel-item-start';
  1511. const CLASS_NAME_NEXT = 'carousel-item-next';
  1512. const CLASS_NAME_PREV = 'carousel-item-prev';
  1513. const SELECTOR_ACTIVE = '.active';
  1514. const SELECTOR_ITEM = '.carousel-item';
  1515. const SELECTOR_ACTIVE_ITEM = SELECTOR_ACTIVE + SELECTOR_ITEM;
  1516. const SELECTOR_ITEM_IMG = '.carousel-item img';
  1517. const SELECTOR_INDICATORS = '.carousel-indicators';
  1518. const SELECTOR_DATA_SLIDE = '[data-bs-slide], [data-bs-slide-to]';
  1519. const SELECTOR_DATA_RIDE = '[data-bs-ride="carousel"]';
  1520. const KEY_TO_DIRECTION = {
  1521. [ARROW_LEFT_KEY$1]: DIRECTION_RIGHT,
  1522. [ARROW_RIGHT_KEY$1]: DIRECTION_LEFT
  1523. };
  1524. const Default$b = {
  1525. interval: 5000,
  1526. keyboard: true,
  1527. pause: 'hover',
  1528. ride: false,
  1529. touch: true,
  1530. wrap: true
  1531. };
  1532. const DefaultType$b = {
  1533. interval: '(number|boolean)',
  1534. // TODO:v6 remove boolean support
  1535. keyboard: 'boolean',
  1536. pause: '(string|boolean)',
  1537. ride: '(boolean|string)',
  1538. touch: 'boolean',
  1539. wrap: 'boolean'
  1540. };
  1541. /**
  1542. * Class definition
  1543. */
  1544. class Carousel extends BaseComponent {
  1545. constructor(element, config) {
  1546. super(element, config);
  1547. this._interval = null;
  1548. this._activeElement = null;
  1549. this._isSliding = false;
  1550. this.touchTimeout = null;
  1551. this._swipeHelper = null;
  1552. this._indicatorsElement = SelectorEngine.findOne(SELECTOR_INDICATORS, this._element);
  1553. this._addEventListeners();
  1554. if (this._config.ride === CLASS_NAME_CAROUSEL) {
  1555. this.cycle();
  1556. }
  1557. }
  1558. // Getters
  1559. static get Default() {
  1560. return Default$b;
  1561. }
  1562. static get DefaultType() {
  1563. return DefaultType$b;
  1564. }
  1565. static get NAME() {
  1566. return NAME$c;
  1567. }
  1568. // Public
  1569. next() {
  1570. this._slide(ORDER_NEXT);
  1571. }
  1572. nextWhenVisible() {
  1573. // FIXME TODO use `document.visibilityState`
  1574. // Don't call next when the page isn't visible
  1575. // or the carousel or its parent isn't visible
  1576. if (!document.hidden && isVisible(this._element)) {
  1577. this.next();
  1578. }
  1579. }
  1580. prev() {
  1581. this._slide(ORDER_PREV);
  1582. }
  1583. pause() {
  1584. if (this._isSliding) {
  1585. triggerTransitionEnd(this._element);
  1586. }
  1587. this._clearInterval();
  1588. }
  1589. cycle() {
  1590. this._clearInterval();
  1591. this._updateInterval();
  1592. this._interval = setInterval(() => this.nextWhenVisible(), this._config.interval);
  1593. }
  1594. _maybeEnableCycle() {
  1595. if (!this._config.ride) {
  1596. return;
  1597. }
  1598. if (this._isSliding) {
  1599. EventHandler.one(this._element, EVENT_SLID, () => this.cycle());
  1600. return;
  1601. }
  1602. this.cycle();
  1603. }
  1604. to(index) {
  1605. const items = this._getItems();
  1606. if (index > items.length - 1 || index < 0) {
  1607. return;
  1608. }
  1609. if (this._isSliding) {
  1610. EventHandler.one(this._element, EVENT_SLID, () => this.to(index));
  1611. return;
  1612. }
  1613. const activeIndex = this._getItemIndex(this._getActive());
  1614. if (activeIndex === index) {
  1615. return;
  1616. }
  1617. const order = index > activeIndex ? ORDER_NEXT : ORDER_PREV;
  1618. this._slide(order, items[index]);
  1619. }
  1620. dispose() {
  1621. if (this._swipeHelper) {
  1622. this._swipeHelper.dispose();
  1623. }
  1624. super.dispose();
  1625. }
  1626. // Private
  1627. _configAfterMerge(config) {
  1628. config.defaultInterval = config.interval;
  1629. return config;
  1630. }
  1631. _addEventListeners() {
  1632. if (this._config.keyboard) {
  1633. EventHandler.on(this._element, EVENT_KEYDOWN$1, event => this._keydown(event));
  1634. }
  1635. if (this._config.pause === 'hover') {
  1636. EventHandler.on(this._element, EVENT_MOUSEENTER$1, () => this.pause());
  1637. EventHandler.on(this._element, EVENT_MOUSELEAVE$1, () => this._maybeEnableCycle());
  1638. }
  1639. if (this._config.touch && Swipe.isSupported()) {
  1640. this._addTouchEventListeners();
  1641. }
  1642. }
  1643. _addTouchEventListeners() {
  1644. for (const img of SelectorEngine.find(SELECTOR_ITEM_IMG, this._element)) {
  1645. EventHandler.on(img, EVENT_DRAG_START, event => event.preventDefault());
  1646. }
  1647. const endCallBack = () => {
  1648. if (this._config.pause !== 'hover') {
  1649. return;
  1650. }
  1651. // If it's a touch-enabled device, mouseenter/leave are fired as
  1652. // part of the mouse compatibility events on first tap - the carousel
  1653. // would stop cycling until user tapped out of it;
  1654. // here, we listen for touchend, explicitly pause the carousel
  1655. // (as if it's the second time we tap on it, mouseenter compat event
  1656. // is NOT fired) and after a timeout (to allow for mouse compatibility
  1657. // events to fire) we explicitly restart cycling
  1658. this.pause();
  1659. if (this.touchTimeout) {
  1660. clearTimeout(this.touchTimeout);
  1661. }
  1662. this.touchTimeout = setTimeout(() => this._maybeEnableCycle(), TOUCHEVENT_COMPAT_WAIT + this._config.interval);
  1663. };
  1664. const swipeConfig = {
  1665. leftCallback: () => this._slide(this._directionToOrder(DIRECTION_LEFT)),
  1666. rightCallback: () => this._slide(this._directionToOrder(DIRECTION_RIGHT)),
  1667. endCallback: endCallBack
  1668. };
  1669. this._swipeHelper = new Swipe(this._element, swipeConfig);
  1670. }
  1671. _keydown(event) {
  1672. if (/input|textarea/i.test(event.target.tagName)) {
  1673. return;
  1674. }
  1675. const direction = KEY_TO_DIRECTION[event.key];
  1676. if (direction) {
  1677. event.preventDefault();
  1678. this._slide(this._directionToOrder(direction));
  1679. }
  1680. }
  1681. _getItemIndex(element) {
  1682. return this._getItems().indexOf(element);
  1683. }
  1684. _setActiveIndicatorElement(index) {
  1685. if (!this._indicatorsElement) {
  1686. return;
  1687. }
  1688. const activeIndicator = SelectorEngine.findOne(SELECTOR_ACTIVE, this._indicatorsElement);
  1689. activeIndicator.classList.remove(CLASS_NAME_ACTIVE$2);
  1690. activeIndicator.removeAttribute('aria-current');
  1691. const newActiveIndicator = SelectorEngine.findOne(`[data-bs-slide-to="${index}"]`, this._indicatorsElement);
  1692. if (newActiveIndicator) {
  1693. newActiveIndicator.classList.add(CLASS_NAME_ACTIVE$2);
  1694. newActiveIndicator.setAttribute('aria-current', 'true');
  1695. }
  1696. }
  1697. _updateInterval() {
  1698. const element = this._activeElement || this._getActive();
  1699. if (!element) {
  1700. return;
  1701. }
  1702. const elementInterval = Number.parseInt(element.getAttribute('data-bs-interval'), 10);
  1703. this._config.interval = elementInterval || this._config.defaultInterval;
  1704. }
  1705. _slide(order, element = null) {
  1706. if (this._isSliding) {
  1707. return;
  1708. }
  1709. const activeElement = this._getActive();
  1710. const isNext = order === ORDER_NEXT;
  1711. const nextElement = element || getNextActiveElement(this._getItems(), activeElement, isNext, this._config.wrap);
  1712. if (nextElement === activeElement) {
  1713. return;
  1714. }
  1715. const nextElementIndex = this._getItemIndex(nextElement);
  1716. const triggerEvent = eventName => {
  1717. return EventHandler.trigger(this._element, eventName, {
  1718. relatedTarget: nextElement,
  1719. direction: this._orderToDirection(order),
  1720. from: this._getItemIndex(activeElement),
  1721. to: nextElementIndex
  1722. });
  1723. };
  1724. const slideEvent = triggerEvent(EVENT_SLIDE);
  1725. if (slideEvent.defaultPrevented) {
  1726. return;
  1727. }
  1728. if (!activeElement || !nextElement) {
  1729. // Some weirdness is happening, so we bail
  1730. // TODO: change tests that use empty divs to avoid this check
  1731. return;
  1732. }
  1733. const isCycling = Boolean(this._interval);
  1734. this.pause();
  1735. this._isSliding = true;
  1736. this._setActiveIndicatorElement(nextElementIndex);
  1737. this._activeElement = nextElement;
  1738. const directionalClassName = isNext ? CLASS_NAME_START : CLASS_NAME_END;
  1739. const orderClassName = isNext ? CLASS_NAME_NEXT : CLASS_NAME_PREV;
  1740. nextElement.classList.add(orderClassName);
  1741. reflow(nextElement);
  1742. activeElement.classList.add(directionalClassName);
  1743. nextElement.classList.add(directionalClassName);
  1744. const completeCallBack = () => {
  1745. nextElement.classList.remove(directionalClassName, orderClassName);
  1746. nextElement.classList.add(CLASS_NAME_ACTIVE$2);
  1747. activeElement.classList.remove(CLASS_NAME_ACTIVE$2, orderClassName, directionalClassName);
  1748. this._isSliding = false;
  1749. triggerEvent(EVENT_SLID);
  1750. };
  1751. this._queueCallback(completeCallBack, activeElement, this._isAnimated());
  1752. if (isCycling) {
  1753. this.cycle();
  1754. }
  1755. }
  1756. _isAnimated() {
  1757. return this._element.classList.contains(CLASS_NAME_SLIDE);
  1758. }
  1759. _getActive() {
  1760. return SelectorEngine.findOne(SELECTOR_ACTIVE_ITEM, this._element);
  1761. }
  1762. _getItems() {
  1763. return SelectorEngine.find(SELECTOR_ITEM, this._element);
  1764. }
  1765. _clearInterval() {
  1766. if (this._interval) {
  1767. clearInterval(this._interval);
  1768. this._interval = null;
  1769. }
  1770. }
  1771. _directionToOrder(direction) {
  1772. if (isRTL()) {
  1773. return direction === DIRECTION_LEFT ? ORDER_PREV : ORDER_NEXT;
  1774. }
  1775. return direction === DIRECTION_LEFT ? ORDER_NEXT : ORDER_PREV;
  1776. }
  1777. _orderToDirection(order) {
  1778. if (isRTL()) {
  1779. return order === ORDER_PREV ? DIRECTION_LEFT : DIRECTION_RIGHT;
  1780. }
  1781. return order === ORDER_PREV ? DIRECTION_RIGHT : DIRECTION_LEFT;
  1782. }
  1783. // Static
  1784. static jQueryInterface(config) {
  1785. return this.each(function () {
  1786. const data = Carousel.getOrCreateInstance(this, config);
  1787. if (typeof config === 'number') {
  1788. data.to(config);
  1789. return;
  1790. }
  1791. if (typeof config === 'string') {
  1792. if (data[config] === undefined || config.startsWith('_') || config === 'constructor') {
  1793. throw new TypeError(`No method named "${config}"`);
  1794. }
  1795. data[config]();
  1796. }
  1797. });
  1798. }
  1799. }
  1800. /**
  1801. * Data API implementation
  1802. */
  1803. EventHandler.on(document, EVENT_CLICK_DATA_API$5, SELECTOR_DATA_SLIDE, function (event) {
  1804. const target = SelectorEngine.getElementFromSelector(this);
  1805. if (!target || !target.classList.contains(CLASS_NAME_CAROUSEL)) {
  1806. return;
  1807. }
  1808. event.preventDefault();
  1809. const carousel = Carousel.getOrCreateInstance(target);
  1810. const slideIndex = this.getAttribute('data-bs-slide-to');
  1811. if (slideIndex) {
  1812. carousel.to(slideIndex);
  1813. carousel._maybeEnableCycle();
  1814. return;
  1815. }
  1816. if (Manipulator.getDataAttribute(this, 'slide') === 'next') {
  1817. carousel.next();
  1818. carousel._maybeEnableCycle();
  1819. return;
  1820. }
  1821. carousel.prev();
  1822. carousel._maybeEnableCycle();
  1823. });
  1824. EventHandler.on(window, EVENT_LOAD_DATA_API$3, () => {
  1825. const carousels = SelectorEngine.find(SELECTOR_DATA_RIDE);
  1826. for (const carousel of carousels) {
  1827. Carousel.getOrCreateInstance(carousel);
  1828. }
  1829. });
  1830. /**
  1831. * jQuery
  1832. */
  1833. defineJQueryPlugin(Carousel);
  1834. /**
  1835. * --------------------------------------------------------------------------
  1836. * Bootstrap collapse.js
  1837. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  1838. * --------------------------------------------------------------------------
  1839. */
  1840. /**
  1841. * Constants
  1842. */
  1843. const NAME$b = 'collapse';
  1844. const DATA_KEY$7 = 'bs.collapse';
  1845. const EVENT_KEY$7 = `.${DATA_KEY$7}`;
  1846. const DATA_API_KEY$4 = '.data-api';
  1847. const EVENT_SHOW$6 = `show${EVENT_KEY$7}`;
  1848. const EVENT_SHOWN$6 = `shown${EVENT_KEY$7}`;
  1849. const EVENT_HIDE$6 = `hide${EVENT_KEY$7}`;
  1850. const EVENT_HIDDEN$6 = `hidden${EVENT_KEY$7}`;
  1851. const EVENT_CLICK_DATA_API$4 = `click${EVENT_KEY$7}${DATA_API_KEY$4}`;
  1852. const CLASS_NAME_SHOW$7 = 'show';
  1853. const CLASS_NAME_COLLAPSE = 'collapse';
  1854. const CLASS_NAME_COLLAPSING = 'collapsing';
  1855. const CLASS_NAME_COLLAPSED = 'collapsed';
  1856. const CLASS_NAME_DEEPER_CHILDREN = `:scope .${CLASS_NAME_COLLAPSE} .${CLASS_NAME_COLLAPSE}`;
  1857. const CLASS_NAME_HORIZONTAL = 'collapse-horizontal';
  1858. const WIDTH = 'width';
  1859. const HEIGHT = 'height';
  1860. const SELECTOR_ACTIVES = '.collapse.show, .collapse.collapsing';
  1861. const SELECTOR_DATA_TOGGLE$4 = '[data-bs-toggle="collapse"]';
  1862. const Default$a = {
  1863. parent: null,
  1864. toggle: true
  1865. };
  1866. const DefaultType$a = {
  1867. parent: '(null|element)',
  1868. toggle: 'boolean'
  1869. };
  1870. /**
  1871. * Class definition
  1872. */
  1873. class Collapse extends BaseComponent {
  1874. constructor(element, config) {
  1875. super(element, config);
  1876. this._isTransitioning = false;
  1877. this._triggerArray = [];
  1878. const toggleList = SelectorEngine.find(SELECTOR_DATA_TOGGLE$4);
  1879. for (const elem of toggleList) {
  1880. const selector = SelectorEngine.getSelectorFromElement(elem);
  1881. const filterElement = SelectorEngine.find(selector).filter(foundElement => foundElement === this._element);
  1882. if (selector !== null && filterElement.length) {
  1883. this._triggerArray.push(elem);
  1884. }
  1885. }
  1886. this._initializeChildren();
  1887. if (!this._config.parent) {
  1888. this._addAriaAndCollapsedClass(this._triggerArray, this._isShown());
  1889. }
  1890. if (this._config.toggle) {
  1891. this.toggle();
  1892. }
  1893. }
  1894. // Getters
  1895. static get Default() {
  1896. return Default$a;
  1897. }
  1898. static get DefaultType() {
  1899. return DefaultType$a;
  1900. }
  1901. static get NAME() {
  1902. return NAME$b;
  1903. }
  1904. // Public
  1905. toggle() {
  1906. if (this._isShown()) {
  1907. this.hide();
  1908. } else {
  1909. this.show();
  1910. }
  1911. }
  1912. show() {
  1913. if (this._isTransitioning || this._isShown()) {
  1914. return;
  1915. }
  1916. let activeChildren = [];
  1917. // find active children
  1918. if (this._config.parent) {
  1919. activeChildren = this._getFirstLevelChildren(SELECTOR_ACTIVES).filter(element => element !== this._element).map(element => Collapse.getOrCreateInstance(element, {
  1920. toggle: false
  1921. }));
  1922. }
  1923. if (activeChildren.length && activeChildren[0]._isTransitioning) {
  1924. return;
  1925. }
  1926. const startEvent = EventHandler.trigger(this._element, EVENT_SHOW$6);
  1927. if (startEvent.defaultPrevented) {
  1928. return;
  1929. }
  1930. for (const activeInstance of activeChildren) {
  1931. activeInstance.hide();
  1932. }
  1933. const dimension = this._getDimension();
  1934. this._element.classList.remove(CLASS_NAME_COLLAPSE);
  1935. this._element.classList.add(CLASS_NAME_COLLAPSING);
  1936. this._element.style[dimension] = 0;
  1937. this._addAriaAndCollapsedClass(this._triggerArray, true);
  1938. this._isTransitioning = true;
  1939. const complete = () => {
  1940. this._isTransitioning = false;
  1941. this._element.classList.remove(CLASS_NAME_COLLAPSING);
  1942. this._element.classList.add(CLASS_NAME_COLLAPSE, CLASS_NAME_SHOW$7);
  1943. this._element.style[dimension] = '';
  1944. EventHandler.trigger(this._element, EVENT_SHOWN$6);
  1945. };
  1946. const capitalizedDimension = dimension[0].toUpperCase() + dimension.slice(1);
  1947. const scrollSize = `scroll${capitalizedDimension}`;
  1948. this._queueCallback(complete, this._element, true);
  1949. this._element.style[dimension] = `${this._element[scrollSize]}px`;
  1950. }
  1951. hide() {
  1952. if (this._isTransitioning || !this._isShown()) {
  1953. return;
  1954. }
  1955. const startEvent = EventHandler.trigger(this._element, EVENT_HIDE$6);
  1956. if (startEvent.defaultPrevented) {
  1957. return;
  1958. }
  1959. const dimension = this._getDimension();
  1960. this._element.style[dimension] = `${this._element.getBoundingClientRect()[dimension]}px`;
  1961. reflow(this._element);
  1962. this._element.classList.add(CLASS_NAME_COLLAPSING);
  1963. this._element.classList.remove(CLASS_NAME_COLLAPSE, CLASS_NAME_SHOW$7);
  1964. for (const trigger of this._triggerArray) {
  1965. const element = SelectorEngine.getElementFromSelector(trigger);
  1966. if (element && !this._isShown(element)) {
  1967. this._addAriaAndCollapsedClass([trigger], false);
  1968. }
  1969. }
  1970. this._isTransitioning = true;
  1971. const complete = () => {
  1972. this._isTransitioning = false;
  1973. this._element.classList.remove(CLASS_NAME_COLLAPSING);
  1974. this._element.classList.add(CLASS_NAME_COLLAPSE);
  1975. EventHandler.trigger(this._element, EVENT_HIDDEN$6);
  1976. };
  1977. this._element.style[dimension] = '';
  1978. this._queueCallback(complete, this._element, true);
  1979. }
  1980. // Private
  1981. _isShown(element = this._element) {
  1982. return element.classList.contains(CLASS_NAME_SHOW$7);
  1983. }
  1984. _configAfterMerge(config) {
  1985. config.toggle = Boolean(config.toggle); // Coerce string values
  1986. config.parent = getElement(config.parent);
  1987. return config;
  1988. }
  1989. _getDimension() {
  1990. return this._element.classList.contains(CLASS_NAME_HORIZONTAL) ? WIDTH : HEIGHT;
  1991. }
  1992. _initializeChildren() {
  1993. if (!this._config.parent) {
  1994. return;
  1995. }
  1996. const children = this._getFirstLevelChildren(SELECTOR_DATA_TOGGLE$4);
  1997. for (const element of children) {
  1998. const selected = SelectorEngine.getElementFromSelector(element);
  1999. if (selected) {
  2000. this._addAriaAndCollapsedClass([element], this._isShown(selected));
  2001. }
  2002. }
  2003. }
  2004. _getFirstLevelChildren(selector) {
  2005. const children = SelectorEngine.find(CLASS_NAME_DEEPER_CHILDREN, this._config.parent);
  2006. // remove children if greater depth
  2007. return SelectorEngine.find(selector, this._config.parent).filter(element => !children.includes(element));
  2008. }
  2009. _addAriaAndCollapsedClass(triggerArray, isOpen) {
  2010. if (!triggerArray.length) {
  2011. return;
  2012. }
  2013. for (const element of triggerArray) {
  2014. element.classList.toggle(CLASS_NAME_COLLAPSED, !isOpen);
  2015. element.setAttribute('aria-expanded', isOpen);
  2016. }
  2017. }
  2018. // Static
  2019. static jQueryInterface(config) {
  2020. const _config = {};
  2021. if (typeof config === 'string' && /show|hide/.test(config)) {
  2022. _config.toggle = false;
  2023. }
  2024. return this.each(function () {
  2025. const data = Collapse.getOrCreateInstance(this, _config);
  2026. if (typeof config === 'string') {
  2027. if (typeof data[config] === 'undefined') {
  2028. throw new TypeError(`No method named "${config}"`);
  2029. }
  2030. data[config]();
  2031. }
  2032. });
  2033. }
  2034. }
  2035. /**
  2036. * Data API implementation
  2037. */
  2038. EventHandler.on(document, EVENT_CLICK_DATA_API$4, SELECTOR_DATA_TOGGLE$4, function (event) {
  2039. // preventDefault only for <a> elements (which change the URL) not inside the collapsible element
  2040. if (event.target.tagName === 'A' || event.delegateTarget && event.delegateTarget.tagName === 'A') {
  2041. event.preventDefault();
  2042. }
  2043. for (const element of SelectorEngine.getMultipleElementsFromSelector(this)) {
  2044. Collapse.getOrCreateInstance(element, {
  2045. toggle: false
  2046. }).toggle();
  2047. }
  2048. });
  2049. /**
  2050. * jQuery
  2051. */
  2052. defineJQueryPlugin(Collapse);
  2053. var top = 'top';
  2054. var bottom = 'bottom';
  2055. var right = 'right';
  2056. var left = 'left';
  2057. var auto = 'auto';
  2058. var basePlacements = [top, bottom, right, left];
  2059. var start = 'start';
  2060. var end = 'end';
  2061. var clippingParents = 'clippingParents';
  2062. var viewport = 'viewport';
  2063. var popper = 'popper';
  2064. var reference = 'reference';
  2065. var variationPlacements = /*#__PURE__*/basePlacements.reduce(function (acc, placement) {
  2066. return acc.concat([placement + "-" + start, placement + "-" + end]);
  2067. }, []);
  2068. var placements = /*#__PURE__*/[].concat(basePlacements, [auto]).reduce(function (acc, placement) {
  2069. return acc.concat([placement, placement + "-" + start, placement + "-" + end]);
  2070. }, []); // modifiers that need to read the DOM
  2071. var beforeRead = 'beforeRead';
  2072. var read = 'read';
  2073. var afterRead = 'afterRead'; // pure-logic modifiers
  2074. var beforeMain = 'beforeMain';
  2075. var main = 'main';
  2076. var afterMain = 'afterMain'; // modifier with the purpose to write to the DOM (or write into a framework state)
  2077. var beforeWrite = 'beforeWrite';
  2078. var write = 'write';
  2079. var afterWrite = 'afterWrite';
  2080. var modifierPhases = [beforeRead, read, afterRead, beforeMain, main, afterMain, beforeWrite, write, afterWrite];
  2081. function getNodeName(element) {
  2082. return element ? (element.nodeName || '').toLowerCase() : null;
  2083. }
  2084. function getWindow(node) {
  2085. if (node == null) {
  2086. return window;
  2087. }
  2088. if (node.toString() !== '[object Window]') {
  2089. var ownerDocument = node.ownerDocument;
  2090. return ownerDocument ? ownerDocument.defaultView || window : window;
  2091. }
  2092. return node;
  2093. }
  2094. function isElement(node) {
  2095. var OwnElement = getWindow(node).Element;
  2096. return node instanceof OwnElement || node instanceof Element;
  2097. }
  2098. function isHTMLElement(node) {
  2099. var OwnElement = getWindow(node).HTMLElement;
  2100. return node instanceof OwnElement || node instanceof HTMLElement;
  2101. }
  2102. function isShadowRoot(node) {
  2103. // IE 11 has no ShadowRoot
  2104. if (typeof ShadowRoot === 'undefined') {
  2105. return false;
  2106. }
  2107. var OwnElement = getWindow(node).ShadowRoot;
  2108. return node instanceof OwnElement || node instanceof ShadowRoot;
  2109. }
  2110. // and applies them to the HTMLElements such as popper and arrow
  2111. function applyStyles(_ref) {
  2112. var state = _ref.state;
  2113. Object.keys(state.elements).forEach(function (name) {
  2114. var style = state.styles[name] || {};
  2115. var attributes = state.attributes[name] || {};
  2116. var element = state.elements[name]; // arrow is optional + virtual elements
  2117. if (!isHTMLElement(element) || !getNodeName(element)) {
  2118. return;
  2119. } // Flow doesn't support to extend this property, but it's the most
  2120. // effective way to apply styles to an HTMLElement
  2121. // $FlowFixMe[cannot-write]
  2122. Object.assign(element.style, style);
  2123. Object.keys(attributes).forEach(function (name) {
  2124. var value = attributes[name];
  2125. if (value === false) {
  2126. element.removeAttribute(name);
  2127. } else {
  2128. element.setAttribute(name, value === true ? '' : value);
  2129. }
  2130. });
  2131. });
  2132. }
  2133. function effect$2(_ref2) {
  2134. var state = _ref2.state;
  2135. var initialStyles = {
  2136. popper: {
  2137. position: state.options.strategy,
  2138. left: '0',
  2139. top: '0',
  2140. margin: '0'
  2141. },
  2142. arrow: {
  2143. position: 'absolute'
  2144. },
  2145. reference: {}
  2146. };
  2147. Object.assign(state.elements.popper.style, initialStyles.popper);
  2148. state.styles = initialStyles;
  2149. if (state.elements.arrow) {
  2150. Object.assign(state.elements.arrow.style, initialStyles.arrow);
  2151. }
  2152. return function () {
  2153. Object.keys(state.elements).forEach(function (name) {
  2154. var element = state.elements[name];
  2155. var attributes = state.attributes[name] || {};
  2156. var styleProperties = Object.keys(state.styles.hasOwnProperty(name) ? state.styles[name] : initialStyles[name]); // Set all values to an empty string to unset them
  2157. var style = styleProperties.reduce(function (style, property) {
  2158. style[property] = '';
  2159. return style;
  2160. }, {}); // arrow is optional + virtual elements
  2161. if (!isHTMLElement(element) || !getNodeName(element)) {
  2162. return;
  2163. }
  2164. Object.assign(element.style, style);
  2165. Object.keys(attributes).forEach(function (attribute) {
  2166. element.removeAttribute(attribute);
  2167. });
  2168. });
  2169. };
  2170. } // eslint-disable-next-line import/no-unused-modules
  2171. const applyStyles$1 = {
  2172. name: 'applyStyles',
  2173. enabled: true,
  2174. phase: 'write',
  2175. fn: applyStyles,
  2176. effect: effect$2,
  2177. requires: ['computeStyles']
  2178. };
  2179. function getBasePlacement(placement) {
  2180. return placement.split('-')[0];
  2181. }
  2182. var max = Math.max;
  2183. var min = Math.min;
  2184. var round = Math.round;
  2185. function getUAString() {
  2186. var uaData = navigator.userAgentData;
  2187. if (uaData != null && uaData.brands && Array.isArray(uaData.brands)) {
  2188. return uaData.brands.map(function (item) {
  2189. return item.brand + "/" + item.version;
  2190. }).join(' ');
  2191. }
  2192. return navigator.userAgent;
  2193. }
  2194. function isLayoutViewport() {
  2195. return !/^((?!chrome|android).)*safari/i.test(getUAString());
  2196. }
  2197. function getBoundingClientRect(element, includeScale, isFixedStrategy) {
  2198. if (includeScale === void 0) {
  2199. includeScale = false;
  2200. }
  2201. if (isFixedStrategy === void 0) {
  2202. isFixedStrategy = false;
  2203. }
  2204. var clientRect = element.getBoundingClientRect();
  2205. var scaleX = 1;
  2206. var scaleY = 1;
  2207. if (includeScale && isHTMLElement(element)) {
  2208. scaleX = element.offsetWidth > 0 ? round(clientRect.width) / element.offsetWidth || 1 : 1;
  2209. scaleY = element.offsetHeight > 0 ? round(clientRect.height) / element.offsetHeight || 1 : 1;
  2210. }
  2211. var _ref = isElement(element) ? getWindow(element) : window,
  2212. visualViewport = _ref.visualViewport;
  2213. var addVisualOffsets = !isLayoutViewport() && isFixedStrategy;
  2214. var x = (clientRect.left + (addVisualOffsets && visualViewport ? visualViewport.offsetLeft : 0)) / scaleX;
  2215. var y = (clientRect.top + (addVisualOffsets && visualViewport ? visualViewport.offsetTop : 0)) / scaleY;
  2216. var width = clientRect.width / scaleX;
  2217. var height = clientRect.height / scaleY;
  2218. return {
  2219. width: width,
  2220. height: height,
  2221. top: y,
  2222. right: x + width,
  2223. bottom: y + height,
  2224. left: x,
  2225. x: x,
  2226. y: y
  2227. };
  2228. }
  2229. // means it doesn't take into account transforms.
  2230. function getLayoutRect(element) {
  2231. var clientRect = getBoundingClientRect(element); // Use the clientRect sizes if it's not been transformed.
  2232. // Fixes https://github.com/popperjs/popper-core/issues/1223
  2233. var width = element.offsetWidth;
  2234. var height = element.offsetHeight;
  2235. if (Math.abs(clientRect.width - width) <= 1) {
  2236. width = clientRect.width;
  2237. }
  2238. if (Math.abs(clientRect.height - height) <= 1) {
  2239. height = clientRect.height;
  2240. }
  2241. return {
  2242. x: element.offsetLeft,
  2243. y: element.offsetTop,
  2244. width: width,
  2245. height: height
  2246. };
  2247. }
  2248. function contains(parent, child) {
  2249. var rootNode = child.getRootNode && child.getRootNode(); // First, attempt with faster native method
  2250. if (parent.contains(child)) {
  2251. return true;
  2252. } // then fallback to custom implementation with Shadow DOM support
  2253. else if (rootNode && isShadowRoot(rootNode)) {
  2254. var next = child;
  2255. do {
  2256. if (next && parent.isSameNode(next)) {
  2257. return true;
  2258. } // $FlowFixMe[prop-missing]: need a better way to handle this...
  2259. next = next.parentNode || next.host;
  2260. } while (next);
  2261. } // Give up, the result is false
  2262. return false;
  2263. }
  2264. function getComputedStyle$1(element) {
  2265. return getWindow(element).getComputedStyle(element);
  2266. }
  2267. function isTableElement(element) {
  2268. return ['table', 'td', 'th'].indexOf(getNodeName(element)) >= 0;
  2269. }
  2270. function getDocumentElement(element) {
  2271. // $FlowFixMe[incompatible-return]: assume body is always available
  2272. return ((isElement(element) ? element.ownerDocument : // $FlowFixMe[prop-missing]
  2273. element.document) || window.document).documentElement;
  2274. }
  2275. function getParentNode(element) {
  2276. if (getNodeName(element) === 'html') {
  2277. return element;
  2278. }
  2279. return (// this is a quicker (but less type safe) way to save quite some bytes from the bundle
  2280. // $FlowFixMe[incompatible-return]
  2281. // $FlowFixMe[prop-missing]
  2282. element.assignedSlot || // step into the shadow DOM of the parent of a slotted node
  2283. element.parentNode || ( // DOM Element detected
  2284. isShadowRoot(element) ? element.host : null) || // ShadowRoot detected
  2285. // $FlowFixMe[incompatible-call]: HTMLElement is a Node
  2286. getDocumentElement(element) // fallback
  2287. );
  2288. }
  2289. function getTrueOffsetParent(element) {
  2290. if (!isHTMLElement(element) || // https://github.com/popperjs/popper-core/issues/837
  2291. getComputedStyle$1(element).position === 'fixed') {
  2292. return null;
  2293. }
  2294. return element.offsetParent;
  2295. } // `.offsetParent` reports `null` for fixed elements, while absolute elements
  2296. // return the containing block
  2297. function getContainingBlock(element) {
  2298. var isFirefox = /firefox/i.test(getUAString());
  2299. var isIE = /Trident/i.test(getUAString());
  2300. if (isIE && isHTMLElement(element)) {
  2301. // In IE 9, 10 and 11 fixed elements containing block is always established by the viewport
  2302. var elementCss = getComputedStyle$1(element);
  2303. if (elementCss.position === 'fixed') {
  2304. return null;
  2305. }
  2306. }
  2307. var currentNode = getParentNode(element);
  2308. if (isShadowRoot(currentNode)) {
  2309. currentNode = currentNode.host;
  2310. }
  2311. while (isHTMLElement(currentNode) && ['html', 'body'].indexOf(getNodeName(currentNode)) < 0) {
  2312. var css = getComputedStyle$1(currentNode); // This is non-exhaustive but covers the most common CSS properties that
  2313. // create a containing block.
  2314. // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
  2315. 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') {
  2316. return currentNode;
  2317. } else {
  2318. currentNode = currentNode.parentNode;
  2319. }
  2320. }
  2321. return null;
  2322. } // Gets the closest ancestor positioned element. Handles some edge cases,
  2323. // such as table ancestors and cross browser bugs.
  2324. function getOffsetParent(element) {
  2325. var window = getWindow(element);
  2326. var offsetParent = getTrueOffsetParent(element);
  2327. while (offsetParent && isTableElement(offsetParent) && getComputedStyle$1(offsetParent).position === 'static') {
  2328. offsetParent = getTrueOffsetParent(offsetParent);
  2329. }
  2330. if (offsetParent && (getNodeName(offsetParent) === 'html' || getNodeName(offsetParent) === 'body' && getComputedStyle$1(offsetParent).position === 'static')) {
  2331. return window;
  2332. }
  2333. return offsetParent || getContainingBlock(element) || window;
  2334. }
  2335. function getMainAxisFromPlacement(placement) {
  2336. return ['top', 'bottom'].indexOf(placement) >= 0 ? 'x' : 'y';
  2337. }
  2338. function within(min$1, value, max$1) {
  2339. return max(min$1, min(value, max$1));
  2340. }
  2341. function withinMaxClamp(min, value, max) {
  2342. var v = within(min, value, max);
  2343. return v > max ? max : v;
  2344. }
  2345. function getFreshSideObject() {
  2346. return {
  2347. top: 0,
  2348. right: 0,
  2349. bottom: 0,
  2350. left: 0
  2351. };
  2352. }
  2353. function mergePaddingObject(paddingObject) {
  2354. return Object.assign({}, getFreshSideObject(), paddingObject);
  2355. }
  2356. function expandToHashMap(value, keys) {
  2357. return keys.reduce(function (hashMap, key) {
  2358. hashMap[key] = value;
  2359. return hashMap;
  2360. }, {});
  2361. }
  2362. var toPaddingObject = function toPaddingObject(padding, state) {
  2363. padding = typeof padding === 'function' ? padding(Object.assign({}, state.rects, {
  2364. placement: state.placement
  2365. })) : padding;
  2366. return mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements));
  2367. };
  2368. function arrow(_ref) {
  2369. var _state$modifiersData$;
  2370. var state = _ref.state,
  2371. name = _ref.name,
  2372. options = _ref.options;
  2373. var arrowElement = state.elements.arrow;
  2374. var popperOffsets = state.modifiersData.popperOffsets;
  2375. var basePlacement = getBasePlacement(state.placement);
  2376. var axis = getMainAxisFromPlacement(basePlacement);
  2377. var isVertical = [left, right].indexOf(basePlacement) >= 0;
  2378. var len = isVertical ? 'height' : 'width';
  2379. if (!arrowElement || !popperOffsets) {
  2380. return;
  2381. }
  2382. var paddingObject = toPaddingObject(options.padding, state);
  2383. var arrowRect = getLayoutRect(arrowElement);
  2384. var minProp = axis === 'y' ? top : left;
  2385. var maxProp = axis === 'y' ? bottom : right;
  2386. var endDiff = state.rects.reference[len] + state.rects.reference[axis] - popperOffsets[axis] - state.rects.popper[len];
  2387. var startDiff = popperOffsets[axis] - state.rects.reference[axis];
  2388. var arrowOffsetParent = getOffsetParent(arrowElement);
  2389. var clientSize = arrowOffsetParent ? axis === 'y' ? arrowOffsetParent.clientHeight || 0 : arrowOffsetParent.clientWidth || 0 : 0;
  2390. var centerToReference = endDiff / 2 - startDiff / 2; // Make sure the arrow doesn't overflow the popper if the center point is
  2391. // outside of the popper bounds
  2392. var min = paddingObject[minProp];
  2393. var max = clientSize - arrowRect[len] - paddingObject[maxProp];
  2394. var center = clientSize / 2 - arrowRect[len] / 2 + centerToReference;
  2395. var offset = within(min, center, max); // Prevents breaking syntax highlighting...
  2396. var axisProp = axis;
  2397. state.modifiersData[name] = (_state$modifiersData$ = {}, _state$modifiersData$[axisProp] = offset, _state$modifiersData$.centerOffset = offset - center, _state$modifiersData$);
  2398. }
  2399. function effect$1(_ref2) {
  2400. var state = _ref2.state,
  2401. options = _ref2.options;
  2402. var _options$element = options.element,
  2403. arrowElement = _options$element === void 0 ? '[data-popper-arrow]' : _options$element;
  2404. if (arrowElement == null) {
  2405. return;
  2406. } // CSS selector
  2407. if (typeof arrowElement === 'string') {
  2408. arrowElement = state.elements.popper.querySelector(arrowElement);
  2409. if (!arrowElement) {
  2410. return;
  2411. }
  2412. }
  2413. if (!contains(state.elements.popper, arrowElement)) {
  2414. return;
  2415. }
  2416. state.elements.arrow = arrowElement;
  2417. } // eslint-disable-next-line import/no-unused-modules
  2418. const arrow$1 = {
  2419. name: 'arrow',
  2420. enabled: true,
  2421. phase: 'main',
  2422. fn: arrow,
  2423. effect: effect$1,
  2424. requires: ['popperOffsets'],
  2425. requiresIfExists: ['preventOverflow']
  2426. };
  2427. function getVariation(placement) {
  2428. return placement.split('-')[1];
  2429. }
  2430. var unsetSides = {
  2431. top: 'auto',
  2432. right: 'auto',
  2433. bottom: 'auto',
  2434. left: 'auto'
  2435. }; // Round the offsets to the nearest suitable subpixel based on the DPR.
  2436. // Zooming can change the DPR, but it seems to report a value that will
  2437. // cleanly divide the values into the appropriate subpixels.
  2438. function roundOffsetsByDPR(_ref, win) {
  2439. var x = _ref.x,
  2440. y = _ref.y;
  2441. var dpr = win.devicePixelRatio || 1;
  2442. return {
  2443. x: round(x * dpr) / dpr || 0,
  2444. y: round(y * dpr) / dpr || 0
  2445. };
  2446. }
  2447. function mapToStyles(_ref2) {
  2448. var _Object$assign2;
  2449. var popper = _ref2.popper,
  2450. popperRect = _ref2.popperRect,
  2451. placement = _ref2.placement,
  2452. variation = _ref2.variation,
  2453. offsets = _ref2.offsets,
  2454. position = _ref2.position,
  2455. gpuAcceleration = _ref2.gpuAcceleration,
  2456. adaptive = _ref2.adaptive,
  2457. roundOffsets = _ref2.roundOffsets,
  2458. isFixed = _ref2.isFixed;
  2459. var _offsets$x = offsets.x,
  2460. x = _offsets$x === void 0 ? 0 : _offsets$x,
  2461. _offsets$y = offsets.y,
  2462. y = _offsets$y === void 0 ? 0 : _offsets$y;
  2463. var _ref3 = typeof roundOffsets === 'function' ? roundOffsets({
  2464. x: x,
  2465. y: y
  2466. }) : {
  2467. x: x,
  2468. y: y
  2469. };
  2470. x = _ref3.x;
  2471. y = _ref3.y;
  2472. var hasX = offsets.hasOwnProperty('x');
  2473. var hasY = offsets.hasOwnProperty('y');
  2474. var sideX = left;
  2475. var sideY = top;
  2476. var win = window;
  2477. if (adaptive) {
  2478. var offsetParent = getOffsetParent(popper);
  2479. var heightProp = 'clientHeight';
  2480. var widthProp = 'clientWidth';
  2481. if (offsetParent === getWindow(popper)) {
  2482. offsetParent = getDocumentElement(popper);
  2483. if (getComputedStyle$1(offsetParent).position !== 'static' && position === 'absolute') {
  2484. heightProp = 'scrollHeight';
  2485. widthProp = 'scrollWidth';
  2486. }
  2487. } // $FlowFixMe[incompatible-cast]: force type refinement, we compare offsetParent with window above, but Flow doesn't detect it
  2488. offsetParent = offsetParent;
  2489. if (placement === top || (placement === left || placement === right) && variation === end) {
  2490. sideY = bottom;
  2491. var offsetY = isFixed && offsetParent === win && win.visualViewport ? win.visualViewport.height : // $FlowFixMe[prop-missing]
  2492. offsetParent[heightProp];
  2493. y -= offsetY - popperRect.height;
  2494. y *= gpuAcceleration ? 1 : -1;
  2495. }
  2496. if (placement === left || (placement === top || placement === bottom) && variation === end) {
  2497. sideX = right;
  2498. var offsetX = isFixed && offsetParent === win && win.visualViewport ? win.visualViewport.width : // $FlowFixMe[prop-missing]
  2499. offsetParent[widthProp];
  2500. x -= offsetX - popperRect.width;
  2501. x *= gpuAcceleration ? 1 : -1;
  2502. }
  2503. }
  2504. var commonStyles = Object.assign({
  2505. position: position
  2506. }, adaptive && unsetSides);
  2507. var _ref4 = roundOffsets === true ? roundOffsetsByDPR({
  2508. x: x,
  2509. y: y
  2510. }, getWindow(popper)) : {
  2511. x: x,
  2512. y: y
  2513. };
  2514. x = _ref4.x;
  2515. y = _ref4.y;
  2516. if (gpuAcceleration) {
  2517. var _Object$assign;
  2518. 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));
  2519. }
  2520. return Object.assign({}, commonStyles, (_Object$assign2 = {}, _Object$assign2[sideY] = hasY ? y + "px" : '', _Object$assign2[sideX] = hasX ? x + "px" : '', _Object$assign2.transform = '', _Object$assign2));
  2521. }
  2522. function computeStyles(_ref5) {
  2523. var state = _ref5.state,
  2524. options = _ref5.options;
  2525. var _options$gpuAccelerat = options.gpuAcceleration,
  2526. gpuAcceleration = _options$gpuAccelerat === void 0 ? true : _options$gpuAccelerat,
  2527. _options$adaptive = options.adaptive,
  2528. adaptive = _options$adaptive === void 0 ? true : _options$adaptive,
  2529. _options$roundOffsets = options.roundOffsets,
  2530. roundOffsets = _options$roundOffsets === void 0 ? true : _options$roundOffsets;
  2531. var commonStyles = {
  2532. placement: getBasePlacement(state.placement),
  2533. variation: getVariation(state.placement),
  2534. popper: state.elements.popper,
  2535. popperRect: state.rects.popper,
  2536. gpuAcceleration: gpuAcceleration,
  2537. isFixed: state.options.strategy === 'fixed'
  2538. };
  2539. if (state.modifiersData.popperOffsets != null) {
  2540. state.styles.popper = Object.assign({}, state.styles.popper, mapToStyles(Object.assign({}, commonStyles, {
  2541. offsets: state.modifiersData.popperOffsets,
  2542. position: state.options.strategy,
  2543. adaptive: adaptive,
  2544. roundOffsets: roundOffsets
  2545. })));
  2546. }
  2547. if (state.modifiersData.arrow != null) {
  2548. state.styles.arrow = Object.assign({}, state.styles.arrow, mapToStyles(Object.assign({}, commonStyles, {
  2549. offsets: state.modifiersData.arrow,
  2550. position: 'absolute',
  2551. adaptive: false,
  2552. roundOffsets: roundOffsets
  2553. })));
  2554. }
  2555. state.attributes.popper = Object.assign({}, state.attributes.popper, {
  2556. 'data-popper-placement': state.placement
  2557. });
  2558. } // eslint-disable-next-line import/no-unused-modules
  2559. const computeStyles$1 = {
  2560. name: 'computeStyles',
  2561. enabled: true,
  2562. phase: 'beforeWrite',
  2563. fn: computeStyles,
  2564. data: {}
  2565. };
  2566. var passive = {
  2567. passive: true
  2568. };
  2569. function effect(_ref) {
  2570. var state = _ref.state,
  2571. instance = _ref.instance,
  2572. options = _ref.options;
  2573. var _options$scroll = options.scroll,
  2574. scroll = _options$scroll === void 0 ? true : _options$scroll,
  2575. _options$resize = options.resize,
  2576. resize = _options$resize === void 0 ? true : _options$resize;
  2577. var window = getWindow(state.elements.popper);
  2578. var scrollParents = [].concat(state.scrollParents.reference, state.scrollParents.popper);
  2579. if (scroll) {
  2580. scrollParents.forEach(function (scrollParent) {
  2581. scrollParent.addEventListener('scroll', instance.update, passive);
  2582. });
  2583. }
  2584. if (resize) {
  2585. window.addEventListener('resize', instance.update, passive);
  2586. }
  2587. return function () {
  2588. if (scroll) {
  2589. scrollParents.forEach(function (scrollParent) {
  2590. scrollParent.removeEventListener('scroll', instance.update, passive);
  2591. });
  2592. }
  2593. if (resize) {
  2594. window.removeEventListener('resize', instance.update, passive);
  2595. }
  2596. };
  2597. } // eslint-disable-next-line import/no-unused-modules
  2598. const eventListeners = {
  2599. name: 'eventListeners',
  2600. enabled: true,
  2601. phase: 'write',
  2602. fn: function fn() {},
  2603. effect: effect,
  2604. data: {}
  2605. };
  2606. var hash$1 = {
  2607. left: 'right',
  2608. right: 'left',
  2609. bottom: 'top',
  2610. top: 'bottom'
  2611. };
  2612. function getOppositePlacement(placement) {
  2613. return placement.replace(/left|right|bottom|top/g, function (matched) {
  2614. return hash$1[matched];
  2615. });
  2616. }
  2617. var hash = {
  2618. start: 'end',
  2619. end: 'start'
  2620. };
  2621. function getOppositeVariationPlacement(placement) {
  2622. return placement.replace(/start|end/g, function (matched) {
  2623. return hash[matched];
  2624. });
  2625. }
  2626. function getWindowScroll(node) {
  2627. var win = getWindow(node);
  2628. var scrollLeft = win.pageXOffset;
  2629. var scrollTop = win.pageYOffset;
  2630. return {
  2631. scrollLeft: scrollLeft,
  2632. scrollTop: scrollTop
  2633. };
  2634. }
  2635. function getWindowScrollBarX(element) {
  2636. // If <html> has a CSS width greater than the viewport, then this will be
  2637. // incorrect for RTL.
  2638. // Popper 1 is broken in this case and never had a bug report so let's assume
  2639. // it's not an issue. I don't think anyone ever specifies width on <html>
  2640. // anyway.
  2641. // Browsers where the left scrollbar doesn't cause an issue report `0` for
  2642. // this (e.g. Edge 2019, IE11, Safari)
  2643. return getBoundingClientRect(getDocumentElement(element)).left + getWindowScroll(element).scrollLeft;
  2644. }
  2645. function getViewportRect(element, strategy) {
  2646. var win = getWindow(element);
  2647. var html = getDocumentElement(element);
  2648. var visualViewport = win.visualViewport;
  2649. var width = html.clientWidth;
  2650. var height = html.clientHeight;
  2651. var x = 0;
  2652. var y = 0;
  2653. if (visualViewport) {
  2654. width = visualViewport.width;
  2655. height = visualViewport.height;
  2656. var layoutViewport = isLayoutViewport();
  2657. if (layoutViewport || !layoutViewport && strategy === 'fixed') {
  2658. x = visualViewport.offsetLeft;
  2659. y = visualViewport.offsetTop;
  2660. }
  2661. }
  2662. return {
  2663. width: width,
  2664. height: height,
  2665. x: x + getWindowScrollBarX(element),
  2666. y: y
  2667. };
  2668. }
  2669. // of the `<html>` and `<body>` rect bounds if horizontally scrollable
  2670. function getDocumentRect(element) {
  2671. var _element$ownerDocumen;
  2672. var html = getDocumentElement(element);
  2673. var winScroll = getWindowScroll(element);
  2674. var body = (_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body;
  2675. var width = max(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0);
  2676. var height = max(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0);
  2677. var x = -winScroll.scrollLeft + getWindowScrollBarX(element);
  2678. var y = -winScroll.scrollTop;
  2679. if (getComputedStyle$1(body || html).direction === 'rtl') {
  2680. x += max(html.clientWidth, body ? body.clientWidth : 0) - width;
  2681. }
  2682. return {
  2683. width: width,
  2684. height: height,
  2685. x: x,
  2686. y: y
  2687. };
  2688. }
  2689. function isScrollParent(element) {
  2690. // Firefox wants us to check `-x` and `-y` variations as well
  2691. var _getComputedStyle = getComputedStyle$1(element),
  2692. overflow = _getComputedStyle.overflow,
  2693. overflowX = _getComputedStyle.overflowX,
  2694. overflowY = _getComputedStyle.overflowY;
  2695. return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);
  2696. }
  2697. function getScrollParent(node) {
  2698. if (['html', 'body', '#document'].indexOf(getNodeName(node)) >= 0) {
  2699. // $FlowFixMe[incompatible-return]: assume body is always available
  2700. return node.ownerDocument.body;
  2701. }
  2702. if (isHTMLElement(node) && isScrollParent(node)) {
  2703. return node;
  2704. }
  2705. return getScrollParent(getParentNode(node));
  2706. }
  2707. /*
  2708. given a DOM element, return the list of all scroll parents, up the list of ancesors
  2709. until we get to the top window object. This list is what we attach scroll listeners
  2710. to, because if any of these parent elements scroll, we'll need to re-calculate the
  2711. reference element's position.
  2712. */
  2713. function listScrollParents(element, list) {
  2714. var _element$ownerDocumen;
  2715. if (list === void 0) {
  2716. list = [];
  2717. }
  2718. var scrollParent = getScrollParent(element);
  2719. var isBody = scrollParent === ((_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body);
  2720. var win = getWindow(scrollParent);
  2721. var target = isBody ? [win].concat(win.visualViewport || [], isScrollParent(scrollParent) ? scrollParent : []) : scrollParent;
  2722. var updatedList = list.concat(target);
  2723. return isBody ? updatedList : // $FlowFixMe[incompatible-call]: isBody tells us target will be an HTMLElement here
  2724. updatedList.concat(listScrollParents(getParentNode(target)));
  2725. }
  2726. function rectToClientRect(rect) {
  2727. return Object.assign({}, rect, {
  2728. left: rect.x,
  2729. top: rect.y,
  2730. right: rect.x + rect.width,
  2731. bottom: rect.y + rect.height
  2732. });
  2733. }
  2734. function getInnerBoundingClientRect(element, strategy) {
  2735. var rect = getBoundingClientRect(element, false, strategy === 'fixed');
  2736. rect.top = rect.top + element.clientTop;
  2737. rect.left = rect.left + element.clientLeft;
  2738. rect.bottom = rect.top + element.clientHeight;
  2739. rect.right = rect.left + element.clientWidth;
  2740. rect.width = element.clientWidth;
  2741. rect.height = element.clientHeight;
  2742. rect.x = rect.left;
  2743. rect.y = rect.top;
  2744. return rect;
  2745. }
  2746. function getClientRectFromMixedType(element, clippingParent, strategy) {
  2747. return clippingParent === viewport ? rectToClientRect(getViewportRect(element, strategy)) : isElement(clippingParent) ? getInnerBoundingClientRect(clippingParent, strategy) : rectToClientRect(getDocumentRect(getDocumentElement(element)));
  2748. } // A "clipping parent" is an overflowable container with the characteristic of
  2749. // clipping (or hiding) overflowing elements with a position different from
  2750. // `initial`
  2751. function getClippingParents(element) {
  2752. var clippingParents = listScrollParents(getParentNode(element));
  2753. var canEscapeClipping = ['absolute', 'fixed'].indexOf(getComputedStyle$1(element).position) >= 0;
  2754. var clipperElement = canEscapeClipping && isHTMLElement(element) ? getOffsetParent(element) : element;
  2755. if (!isElement(clipperElement)) {
  2756. return [];
  2757. } // $FlowFixMe[incompatible-return]: https://github.com/facebook/flow/issues/1414
  2758. return clippingParents.filter(function (clippingParent) {
  2759. return isElement(clippingParent) && contains(clippingParent, clipperElement) && getNodeName(clippingParent) !== 'body';
  2760. });
  2761. } // Gets the maximum area that the element is visible in due to any number of
  2762. // clipping parents
  2763. function getClippingRect(element, boundary, rootBoundary, strategy) {
  2764. var mainClippingParents = boundary === 'clippingParents' ? getClippingParents(element) : [].concat(boundary);
  2765. var clippingParents = [].concat(mainClippingParents, [rootBoundary]);
  2766. var firstClippingParent = clippingParents[0];
  2767. var clippingRect = clippingParents.reduce(function (accRect, clippingParent) {
  2768. var rect = getClientRectFromMixedType(element, clippingParent, strategy);
  2769. accRect.top = max(rect.top, accRect.top);
  2770. accRect.right = min(rect.right, accRect.right);
  2771. accRect.bottom = min(rect.bottom, accRect.bottom);
  2772. accRect.left = max(rect.left, accRect.left);
  2773. return accRect;
  2774. }, getClientRectFromMixedType(element, firstClippingParent, strategy));
  2775. clippingRect.width = clippingRect.right - clippingRect.left;
  2776. clippingRect.height = clippingRect.bottom - clippingRect.top;
  2777. clippingRect.x = clippingRect.left;
  2778. clippingRect.y = clippingRect.top;
  2779. return clippingRect;
  2780. }
  2781. function computeOffsets(_ref) {
  2782. var reference = _ref.reference,
  2783. element = _ref.element,
  2784. placement = _ref.placement;
  2785. var basePlacement = placement ? getBasePlacement(placement) : null;
  2786. var variation = placement ? getVariation(placement) : null;
  2787. var commonX = reference.x + reference.width / 2 - element.width / 2;
  2788. var commonY = reference.y + reference.height / 2 - element.height / 2;
  2789. var offsets;
  2790. switch (basePlacement) {
  2791. case top:
  2792. offsets = {
  2793. x: commonX,
  2794. y: reference.y - element.height
  2795. };
  2796. break;
  2797. case bottom:
  2798. offsets = {
  2799. x: commonX,
  2800. y: reference.y + reference.height
  2801. };
  2802. break;
  2803. case right:
  2804. offsets = {
  2805. x: reference.x + reference.width,
  2806. y: commonY
  2807. };
  2808. break;
  2809. case left:
  2810. offsets = {
  2811. x: reference.x - element.width,
  2812. y: commonY
  2813. };
  2814. break;
  2815. default:
  2816. offsets = {
  2817. x: reference.x,
  2818. y: reference.y
  2819. };
  2820. }
  2821. var mainAxis = basePlacement ? getMainAxisFromPlacement(basePlacement) : null;
  2822. if (mainAxis != null) {
  2823. var len = mainAxis === 'y' ? 'height' : 'width';
  2824. switch (variation) {
  2825. case start:
  2826. offsets[mainAxis] = offsets[mainAxis] - (reference[len] / 2 - element[len] / 2);
  2827. break;
  2828. case end:
  2829. offsets[mainAxis] = offsets[mainAxis] + (reference[len] / 2 - element[len] / 2);
  2830. break;
  2831. }
  2832. }
  2833. return offsets;
  2834. }
  2835. function detectOverflow(state, options) {
  2836. if (options === void 0) {
  2837. options = {};
  2838. }
  2839. var _options = options,
  2840. _options$placement = _options.placement,
  2841. placement = _options$placement === void 0 ? state.placement : _options$placement,
  2842. _options$strategy = _options.strategy,
  2843. strategy = _options$strategy === void 0 ? state.strategy : _options$strategy,
  2844. _options$boundary = _options.boundary,
  2845. boundary = _options$boundary === void 0 ? clippingParents : _options$boundary,
  2846. _options$rootBoundary = _options.rootBoundary,
  2847. rootBoundary = _options$rootBoundary === void 0 ? viewport : _options$rootBoundary,
  2848. _options$elementConte = _options.elementContext,
  2849. elementContext = _options$elementConte === void 0 ? popper : _options$elementConte,
  2850. _options$altBoundary = _options.altBoundary,
  2851. altBoundary = _options$altBoundary === void 0 ? false : _options$altBoundary,
  2852. _options$padding = _options.padding,
  2853. padding = _options$padding === void 0 ? 0 : _options$padding;
  2854. var paddingObject = mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements));
  2855. var altContext = elementContext === popper ? reference : popper;
  2856. var popperRect = state.rects.popper;
  2857. var element = state.elements[altBoundary ? altContext : elementContext];
  2858. var clippingClientRect = getClippingRect(isElement(element) ? element : element.contextElement || getDocumentElement(state.elements.popper), boundary, rootBoundary, strategy);
  2859. var referenceClientRect = getBoundingClientRect(state.elements.reference);
  2860. var popperOffsets = computeOffsets({
  2861. reference: referenceClientRect,
  2862. element: popperRect,
  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. placement: state.placement
  3145. });
  3146. } // eslint-disable-next-line import/no-unused-modules
  3147. const popperOffsets$1 = {
  3148. name: 'popperOffsets',
  3149. enabled: true,
  3150. phase: 'read',
  3151. fn: popperOffsets,
  3152. data: {}
  3153. };
  3154. function getAltAxis(axis) {
  3155. return axis === 'x' ? 'y' : 'x';
  3156. }
  3157. function preventOverflow(_ref) {
  3158. var state = _ref.state,
  3159. options = _ref.options,
  3160. name = _ref.name;
  3161. var _options$mainAxis = options.mainAxis,
  3162. checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis,
  3163. _options$altAxis = options.altAxis,
  3164. checkAltAxis = _options$altAxis === void 0 ? false : _options$altAxis,
  3165. boundary = options.boundary,
  3166. rootBoundary = options.rootBoundary,
  3167. altBoundary = options.altBoundary,
  3168. padding = options.padding,
  3169. _options$tether = options.tether,
  3170. tether = _options$tether === void 0 ? true : _options$tether,
  3171. _options$tetherOffset = options.tetherOffset,
  3172. tetherOffset = _options$tetherOffset === void 0 ? 0 : _options$tetherOffset;
  3173. var overflow = detectOverflow(state, {
  3174. boundary: boundary,
  3175. rootBoundary: rootBoundary,
  3176. padding: padding,
  3177. altBoundary: altBoundary
  3178. });
  3179. var basePlacement = getBasePlacement(state.placement);
  3180. var variation = getVariation(state.placement);
  3181. var isBasePlacement = !variation;
  3182. var mainAxis = getMainAxisFromPlacement(basePlacement);
  3183. var altAxis = getAltAxis(mainAxis);
  3184. var popperOffsets = state.modifiersData.popperOffsets;
  3185. var referenceRect = state.rects.reference;
  3186. var popperRect = state.rects.popper;
  3187. var tetherOffsetValue = typeof tetherOffset === 'function' ? tetherOffset(Object.assign({}, state.rects, {
  3188. placement: state.placement
  3189. })) : tetherOffset;
  3190. var normalizedTetherOffsetValue = typeof tetherOffsetValue === 'number' ? {
  3191. mainAxis: tetherOffsetValue,
  3192. altAxis: tetherOffsetValue
  3193. } : Object.assign({
  3194. mainAxis: 0,
  3195. altAxis: 0
  3196. }, tetherOffsetValue);
  3197. var offsetModifierState = state.modifiersData.offset ? state.modifiersData.offset[state.placement] : null;
  3198. var data = {
  3199. x: 0,
  3200. y: 0
  3201. };
  3202. if (!popperOffsets) {
  3203. return;
  3204. }
  3205. if (checkMainAxis) {
  3206. var _offsetModifierState$;
  3207. var mainSide = mainAxis === 'y' ? top : left;
  3208. var altSide = mainAxis === 'y' ? bottom : right;
  3209. var len = mainAxis === 'y' ? 'height' : 'width';
  3210. var offset = popperOffsets[mainAxis];
  3211. var min$1 = offset + overflow[mainSide];
  3212. var max$1 = offset - overflow[altSide];
  3213. var additive = tether ? -popperRect[len] / 2 : 0;
  3214. var minLen = variation === start ? referenceRect[len] : popperRect[len];
  3215. var maxLen = variation === start ? -popperRect[len] : -referenceRect[len]; // We need to include the arrow in the calculation so the arrow doesn't go
  3216. // outside the reference bounds
  3217. var arrowElement = state.elements.arrow;
  3218. var arrowRect = tether && arrowElement ? getLayoutRect(arrowElement) : {
  3219. width: 0,
  3220. height: 0
  3221. };
  3222. var arrowPaddingObject = state.modifiersData['arrow#persistent'] ? state.modifiersData['arrow#persistent'].padding : getFreshSideObject();
  3223. var arrowPaddingMin = arrowPaddingObject[mainSide];
  3224. var arrowPaddingMax = arrowPaddingObject[altSide]; // If the reference length is smaller than the arrow length, we don't want
  3225. // to include its full size in the calculation. If the reference is small
  3226. // and near the edge of a boundary, the popper can overflow even if the
  3227. // reference is not overflowing as well (e.g. virtual elements with no
  3228. // width or height)
  3229. var arrowLen = within(0, referenceRect[len], arrowRect[len]);
  3230. var minOffset = isBasePlacement ? referenceRect[len] / 2 - additive - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis : minLen - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis;
  3231. var maxOffset = isBasePlacement ? -referenceRect[len] / 2 + additive + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis : maxLen + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis;
  3232. var arrowOffsetParent = state.elements.arrow && getOffsetParent(state.elements.arrow);
  3233. var clientOffset = arrowOffsetParent ? mainAxis === 'y' ? arrowOffsetParent.clientTop || 0 : arrowOffsetParent.clientLeft || 0 : 0;
  3234. var offsetModifierValue = (_offsetModifierState$ = offsetModifierState == null ? void 0 : offsetModifierState[mainAxis]) != null ? _offsetModifierState$ : 0;
  3235. var tetherMin = offset + minOffset - offsetModifierValue - clientOffset;
  3236. var tetherMax = offset + maxOffset - offsetModifierValue;
  3237. var preventedOffset = within(tether ? min(min$1, tetherMin) : min$1, offset, tether ? max(max$1, tetherMax) : max$1);
  3238. popperOffsets[mainAxis] = preventedOffset;
  3239. data[mainAxis] = preventedOffset - offset;
  3240. }
  3241. if (checkAltAxis) {
  3242. var _offsetModifierState$2;
  3243. var _mainSide = mainAxis === 'x' ? top : left;
  3244. var _altSide = mainAxis === 'x' ? bottom : right;
  3245. var _offset = popperOffsets[altAxis];
  3246. var _len = altAxis === 'y' ? 'height' : 'width';
  3247. var _min = _offset + overflow[_mainSide];
  3248. var _max = _offset - overflow[_altSide];
  3249. var isOriginSide = [top, left].indexOf(basePlacement) !== -1;
  3250. var _offsetModifierValue = (_offsetModifierState$2 = offsetModifierState == null ? void 0 : offsetModifierState[altAxis]) != null ? _offsetModifierState$2 : 0;
  3251. var _tetherMin = isOriginSide ? _min : _offset - referenceRect[_len] - popperRect[_len] - _offsetModifierValue + normalizedTetherOffsetValue.altAxis;
  3252. var _tetherMax = isOriginSide ? _offset + referenceRect[_len] + popperRect[_len] - _offsetModifierValue - normalizedTetherOffsetValue.altAxis : _max;
  3253. var _preventedOffset = tether && isOriginSide ? withinMaxClamp(_tetherMin, _offset, _tetherMax) : within(tether ? _tetherMin : _min, _offset, tether ? _tetherMax : _max);
  3254. popperOffsets[altAxis] = _preventedOffset;
  3255. data[altAxis] = _preventedOffset - _offset;
  3256. }
  3257. state.modifiersData[name] = data;
  3258. } // eslint-disable-next-line import/no-unused-modules
  3259. const preventOverflow$1 = {
  3260. name: 'preventOverflow',
  3261. enabled: true,
  3262. phase: 'main',
  3263. fn: preventOverflow,
  3264. requiresIfExists: ['offset']
  3265. };
  3266. function getHTMLElementScroll(element) {
  3267. return {
  3268. scrollLeft: element.scrollLeft,
  3269. scrollTop: element.scrollTop
  3270. };
  3271. }
  3272. function getNodeScroll(node) {
  3273. if (node === getWindow(node) || !isHTMLElement(node)) {
  3274. return getWindowScroll(node);
  3275. } else {
  3276. return getHTMLElementScroll(node);
  3277. }
  3278. }
  3279. function isElementScaled(element) {
  3280. var rect = element.getBoundingClientRect();
  3281. var scaleX = round(rect.width) / element.offsetWidth || 1;
  3282. var scaleY = round(rect.height) / element.offsetHeight || 1;
  3283. return scaleX !== 1 || scaleY !== 1;
  3284. } // Returns the composite rect of an element relative to its offsetParent.
  3285. // Composite means it takes into account transforms as well as layout.
  3286. function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) {
  3287. if (isFixed === void 0) {
  3288. isFixed = false;
  3289. }
  3290. var isOffsetParentAnElement = isHTMLElement(offsetParent);
  3291. var offsetParentIsScaled = isHTMLElement(offsetParent) && isElementScaled(offsetParent);
  3292. var documentElement = getDocumentElement(offsetParent);
  3293. var rect = getBoundingClientRect(elementOrVirtualElement, offsetParentIsScaled, isFixed);
  3294. var scroll = {
  3295. scrollLeft: 0,
  3296. scrollTop: 0
  3297. };
  3298. var offsets = {
  3299. x: 0,
  3300. y: 0
  3301. };
  3302. if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
  3303. if (getNodeName(offsetParent) !== 'body' || // https://github.com/popperjs/popper-core/issues/1078
  3304. isScrollParent(documentElement)) {
  3305. scroll = getNodeScroll(offsetParent);
  3306. }
  3307. if (isHTMLElement(offsetParent)) {
  3308. offsets = getBoundingClientRect(offsetParent, true);
  3309. offsets.x += offsetParent.clientLeft;
  3310. offsets.y += offsetParent.clientTop;
  3311. } else if (documentElement) {
  3312. offsets.x = getWindowScrollBarX(documentElement);
  3313. }
  3314. }
  3315. return {
  3316. x: rect.left + scroll.scrollLeft - offsets.x,
  3317. y: rect.top + scroll.scrollTop - offsets.y,
  3318. width: rect.width,
  3319. height: rect.height
  3320. };
  3321. }
  3322. function order(modifiers) {
  3323. var map = new Map();
  3324. var visited = new Set();
  3325. var result = [];
  3326. modifiers.forEach(function (modifier) {
  3327. map.set(modifier.name, modifier);
  3328. }); // On visiting object, check for its dependencies and visit them recursively
  3329. function sort(modifier) {
  3330. visited.add(modifier.name);
  3331. var requires = [].concat(modifier.requires || [], modifier.requiresIfExists || []);
  3332. requires.forEach(function (dep) {
  3333. if (!visited.has(dep)) {
  3334. var depModifier = map.get(dep);
  3335. if (depModifier) {
  3336. sort(depModifier);
  3337. }
  3338. }
  3339. });
  3340. result.push(modifier);
  3341. }
  3342. modifiers.forEach(function (modifier) {
  3343. if (!visited.has(modifier.name)) {
  3344. // check for visited object
  3345. sort(modifier);
  3346. }
  3347. });
  3348. return result;
  3349. }
  3350. function orderModifiers(modifiers) {
  3351. // order based on dependencies
  3352. var orderedModifiers = order(modifiers); // order based on phase
  3353. return modifierPhases.reduce(function (acc, phase) {
  3354. return acc.concat(orderedModifiers.filter(function (modifier) {
  3355. return modifier.phase === phase;
  3356. }));
  3357. }, []);
  3358. }
  3359. function debounce(fn) {
  3360. var pending;
  3361. return function () {
  3362. if (!pending) {
  3363. pending = new Promise(function (resolve) {
  3364. Promise.resolve().then(function () {
  3365. pending = undefined;
  3366. resolve(fn());
  3367. });
  3368. });
  3369. }
  3370. return pending;
  3371. };
  3372. }
  3373. function mergeByName(modifiers) {
  3374. var merged = modifiers.reduce(function (merged, current) {
  3375. var existing = merged[current.name];
  3376. merged[current.name] = existing ? Object.assign({}, existing, current, {
  3377. options: Object.assign({}, existing.options, current.options),
  3378. data: Object.assign({}, existing.data, current.data)
  3379. }) : current;
  3380. return merged;
  3381. }, {}); // IE11 does not support Object.values
  3382. return Object.keys(merged).map(function (key) {
  3383. return merged[key];
  3384. });
  3385. }
  3386. var DEFAULT_OPTIONS = {
  3387. placement: 'bottom',
  3388. modifiers: [],
  3389. strategy: 'absolute'
  3390. };
  3391. function areValidElements() {
  3392. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  3393. args[_key] = arguments[_key];
  3394. }
  3395. return !args.some(function (element) {
  3396. return !(element && typeof element.getBoundingClientRect === 'function');
  3397. });
  3398. }
  3399. function popperGenerator(generatorOptions) {
  3400. if (generatorOptions === void 0) {
  3401. generatorOptions = {};
  3402. }
  3403. var _generatorOptions = generatorOptions,
  3404. _generatorOptions$def = _generatorOptions.defaultModifiers,
  3405. defaultModifiers = _generatorOptions$def === void 0 ? [] : _generatorOptions$def,
  3406. _generatorOptions$def2 = _generatorOptions.defaultOptions,
  3407. defaultOptions = _generatorOptions$def2 === void 0 ? DEFAULT_OPTIONS : _generatorOptions$def2;
  3408. return function createPopper(reference, popper, options) {
  3409. if (options === void 0) {
  3410. options = defaultOptions;
  3411. }
  3412. var state = {
  3413. placement: 'bottom',
  3414. orderedModifiers: [],
  3415. options: Object.assign({}, DEFAULT_OPTIONS, defaultOptions),
  3416. modifiersData: {},
  3417. elements: {
  3418. reference: reference,
  3419. popper: popper
  3420. },
  3421. attributes: {},
  3422. styles: {}
  3423. };
  3424. var effectCleanupFns = [];
  3425. var isDestroyed = false;
  3426. var instance = {
  3427. state: state,
  3428. setOptions: function setOptions(setOptionsAction) {
  3429. var options = typeof setOptionsAction === 'function' ? setOptionsAction(state.options) : setOptionsAction;
  3430. cleanupModifierEffects();
  3431. state.options = Object.assign({}, defaultOptions, state.options, options);
  3432. state.scrollParents = {
  3433. reference: isElement(reference) ? listScrollParents(reference) : reference.contextElement ? listScrollParents(reference.contextElement) : [],
  3434. popper: listScrollParents(popper)
  3435. }; // Orders the modifiers based on their dependencies and `phase`
  3436. // properties
  3437. var orderedModifiers = orderModifiers(mergeByName([].concat(defaultModifiers, state.options.modifiers))); // Strip out disabled modifiers
  3438. state.orderedModifiers = orderedModifiers.filter(function (m) {
  3439. return m.enabled;
  3440. });
  3441. runModifierEffects();
  3442. return instance.update();
  3443. },
  3444. // Sync update – it will always be executed, even if not necessary. This
  3445. // is useful for low frequency updates where sync behavior simplifies the
  3446. // logic.
  3447. // For high frequency updates (e.g. `resize` and `scroll` events), always
  3448. // prefer the async Popper#update method
  3449. forceUpdate: function forceUpdate() {
  3450. if (isDestroyed) {
  3451. return;
  3452. }
  3453. var _state$elements = state.elements,
  3454. reference = _state$elements.reference,
  3455. popper = _state$elements.popper; // Don't proceed if `reference` or `popper` are not valid elements
  3456. // anymore
  3457. if (!areValidElements(reference, popper)) {
  3458. return;
  3459. } // Store the reference and popper rects to be read by modifiers
  3460. state.rects = {
  3461. reference: getCompositeRect(reference, getOffsetParent(popper), state.options.strategy === 'fixed'),
  3462. popper: getLayoutRect(popper)
  3463. }; // Modifiers have the ability to reset the current update cycle. The
  3464. // most common use case for this is the `flip` modifier changing the
  3465. // placement, which then needs to re-run all the modifiers, because the
  3466. // logic was previously ran for the previous placement and is therefore
  3467. // stale/incorrect
  3468. state.reset = false;
  3469. state.placement = state.options.placement; // On each update cycle, the `modifiersData` property for each modifier
  3470. // is filled with the initial data specified by the modifier. This means
  3471. // it doesn't persist and is fresh on each update.
  3472. // To ensure persistent data, use `${name}#persistent`
  3473. state.orderedModifiers.forEach(function (modifier) {
  3474. return state.modifiersData[modifier.name] = Object.assign({}, modifier.data);
  3475. });
  3476. for (var index = 0; index < state.orderedModifiers.length; index++) {
  3477. if (state.reset === true) {
  3478. state.reset = false;
  3479. index = -1;
  3480. continue;
  3481. }
  3482. var _state$orderedModifie = state.orderedModifiers[index],
  3483. fn = _state$orderedModifie.fn,
  3484. _state$orderedModifie2 = _state$orderedModifie.options,
  3485. _options = _state$orderedModifie2 === void 0 ? {} : _state$orderedModifie2,
  3486. name = _state$orderedModifie.name;
  3487. if (typeof fn === 'function') {
  3488. state = fn({
  3489. state: state,
  3490. options: _options,
  3491. name: name,
  3492. instance: instance
  3493. }) || state;
  3494. }
  3495. }
  3496. },
  3497. // Async and optimistically optimized update – it will not be executed if
  3498. // not necessary (debounced to run at most once-per-tick)
  3499. update: debounce(function () {
  3500. return new Promise(function (resolve) {
  3501. instance.forceUpdate();
  3502. resolve(state);
  3503. });
  3504. }),
  3505. destroy: function destroy() {
  3506. cleanupModifierEffects();
  3507. isDestroyed = true;
  3508. }
  3509. };
  3510. if (!areValidElements(reference, popper)) {
  3511. return instance;
  3512. }
  3513. instance.setOptions(options).then(function (state) {
  3514. if (!isDestroyed && options.onFirstUpdate) {
  3515. options.onFirstUpdate(state);
  3516. }
  3517. }); // Modifiers have the ability to execute arbitrary code before the first
  3518. // update cycle runs. They will be executed in the same order as the update
  3519. // cycle. This is useful when a modifier adds some persistent data that
  3520. // other modifiers need to use, but the modifier is run after the dependent
  3521. // one.
  3522. function runModifierEffects() {
  3523. state.orderedModifiers.forEach(function (_ref) {
  3524. var name = _ref.name,
  3525. _ref$options = _ref.options,
  3526. options = _ref$options === void 0 ? {} : _ref$options,
  3527. effect = _ref.effect;
  3528. if (typeof effect === 'function') {
  3529. var cleanupFn = effect({
  3530. state: state,
  3531. name: name,
  3532. instance: instance,
  3533. options: options
  3534. });
  3535. var noopFn = function noopFn() {};
  3536. effectCleanupFns.push(cleanupFn || noopFn);
  3537. }
  3538. });
  3539. }
  3540. function cleanupModifierEffects() {
  3541. effectCleanupFns.forEach(function (fn) {
  3542. return fn();
  3543. });
  3544. effectCleanupFns = [];
  3545. }
  3546. return instance;
  3547. };
  3548. }
  3549. var createPopper$2 = /*#__PURE__*/popperGenerator(); // eslint-disable-next-line import/no-unused-modules
  3550. var defaultModifiers$1 = [eventListeners, popperOffsets$1, computeStyles$1, applyStyles$1];
  3551. var createPopper$1 = /*#__PURE__*/popperGenerator({
  3552. defaultModifiers: defaultModifiers$1
  3553. }); // eslint-disable-next-line import/no-unused-modules
  3554. var defaultModifiers = [eventListeners, popperOffsets$1, computeStyles$1, applyStyles$1, offset$1, flip$1, preventOverflow$1, arrow$1, hide$1];
  3555. var createPopper = /*#__PURE__*/popperGenerator({
  3556. defaultModifiers: defaultModifiers
  3557. }); // eslint-disable-next-line import/no-unused-modules
  3558. const Popper = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
  3559. __proto__: null,
  3560. afterMain,
  3561. afterRead,
  3562. afterWrite,
  3563. applyStyles: applyStyles$1,
  3564. arrow: arrow$1,
  3565. auto,
  3566. basePlacements,
  3567. beforeMain,
  3568. beforeRead,
  3569. beforeWrite,
  3570. bottom,
  3571. clippingParents,
  3572. computeStyles: computeStyles$1,
  3573. createPopper,
  3574. createPopperBase: createPopper$2,
  3575. createPopperLite: createPopper$1,
  3576. detectOverflow,
  3577. end,
  3578. eventListeners,
  3579. flip: flip$1,
  3580. hide: hide$1,
  3581. left,
  3582. main,
  3583. modifierPhases,
  3584. offset: offset$1,
  3585. placements,
  3586. popper,
  3587. popperGenerator,
  3588. popperOffsets: popperOffsets$1,
  3589. preventOverflow: preventOverflow$1,
  3590. read,
  3591. reference,
  3592. right,
  3593. start,
  3594. top,
  3595. variationPlacements,
  3596. viewport,
  3597. write
  3598. }, Symbol.toStringTag, { value: 'Module' }));
  3599. /**
  3600. * --------------------------------------------------------------------------
  3601. * Bootstrap dropdown.js
  3602. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  3603. * --------------------------------------------------------------------------
  3604. */
  3605. /**
  3606. * Constants
  3607. */
  3608. const NAME$a = 'dropdown';
  3609. const DATA_KEY$6 = 'bs.dropdown';
  3610. const EVENT_KEY$6 = `.${DATA_KEY$6}`;
  3611. const DATA_API_KEY$3 = '.data-api';
  3612. const ESCAPE_KEY$2 = 'Escape';
  3613. const TAB_KEY$1 = 'Tab';
  3614. const ARROW_UP_KEY$1 = 'ArrowUp';
  3615. const ARROW_DOWN_KEY$1 = 'ArrowDown';
  3616. const RIGHT_MOUSE_BUTTON = 2; // MouseEvent.button value for the secondary button, usually the right button
  3617. const EVENT_HIDE$5 = `hide${EVENT_KEY$6}`;
  3618. const EVENT_HIDDEN$5 = `hidden${EVENT_KEY$6}`;
  3619. const EVENT_SHOW$5 = `show${EVENT_KEY$6}`;
  3620. const EVENT_SHOWN$5 = `shown${EVENT_KEY$6}`;
  3621. const EVENT_CLICK_DATA_API$3 = `click${EVENT_KEY$6}${DATA_API_KEY$3}`;
  3622. const EVENT_KEYDOWN_DATA_API = `keydown${EVENT_KEY$6}${DATA_API_KEY$3}`;
  3623. const EVENT_KEYUP_DATA_API = `keyup${EVENT_KEY$6}${DATA_API_KEY$3}`;
  3624. const CLASS_NAME_SHOW$6 = 'show';
  3625. const CLASS_NAME_DROPUP = 'dropup';
  3626. const CLASS_NAME_DROPEND = 'dropend';
  3627. const CLASS_NAME_DROPSTART = 'dropstart';
  3628. const CLASS_NAME_DROPUP_CENTER = 'dropup-center';
  3629. const CLASS_NAME_DROPDOWN_CENTER = 'dropdown-center';
  3630. const SELECTOR_DATA_TOGGLE$3 = '[data-bs-toggle="dropdown"]:not(.disabled):not(:disabled)';
  3631. const SELECTOR_DATA_TOGGLE_SHOWN = `${SELECTOR_DATA_TOGGLE$3}.${CLASS_NAME_SHOW$6}`;
  3632. const SELECTOR_MENU = '.dropdown-menu';
  3633. const SELECTOR_NAVBAR = '.navbar';
  3634. const SELECTOR_NAVBAR_NAV = '.navbar-nav';
  3635. const SELECTOR_VISIBLE_ITEMS = '.dropdown-menu .dropdown-item:not(.disabled):not(:disabled)';
  3636. const PLACEMENT_TOP = isRTL() ? 'top-end' : 'top-start';
  3637. const PLACEMENT_TOPEND = isRTL() ? 'top-start' : 'top-end';
  3638. const PLACEMENT_BOTTOM = isRTL() ? 'bottom-end' : 'bottom-start';
  3639. const PLACEMENT_BOTTOMEND = isRTL() ? 'bottom-start' : 'bottom-end';
  3640. const PLACEMENT_RIGHT = isRTL() ? 'left-start' : 'right-start';
  3641. const PLACEMENT_LEFT = isRTL() ? 'right-start' : 'left-start';
  3642. const PLACEMENT_TOPCENTER = 'top';
  3643. const PLACEMENT_BOTTOMCENTER = 'bottom';
  3644. const Default$9 = {
  3645. autoClose: true,
  3646. boundary: 'clippingParents',
  3647. display: 'dynamic',
  3648. offset: [0, 2],
  3649. popperConfig: null,
  3650. reference: 'toggle'
  3651. };
  3652. const DefaultType$9 = {
  3653. autoClose: '(boolean|string)',
  3654. boundary: '(string|element)',
  3655. display: 'string',
  3656. offset: '(array|string|function)',
  3657. popperConfig: '(null|object|function)',
  3658. reference: '(string|element|object)'
  3659. };
  3660. /**
  3661. * Class definition
  3662. */
  3663. class Dropdown extends BaseComponent {
  3664. constructor(element, config) {
  3665. super(element, config);
  3666. this._popper = null;
  3667. this._parent = this._element.parentNode; // dropdown wrapper
  3668. // TODO: v6 revert #37011 & change markup https://getbootstrap.com/docs/5.3/forms/input-group/
  3669. this._menu = SelectorEngine.next(this._element, SELECTOR_MENU)[0] || SelectorEngine.prev(this._element, SELECTOR_MENU)[0] || SelectorEngine.findOne(SELECTOR_MENU, this._parent);
  3670. this._inNavbar = this._detectNavbar();
  3671. }
  3672. // Getters
  3673. static get Default() {
  3674. return Default$9;
  3675. }
  3676. static get DefaultType() {
  3677. return DefaultType$9;
  3678. }
  3679. static get NAME() {
  3680. return NAME$a;
  3681. }
  3682. // Public
  3683. toggle() {
  3684. return this._isShown() ? this.hide() : this.show();
  3685. }
  3686. show() {
  3687. if (isDisabled(this._element) || this._isShown()) {
  3688. return;
  3689. }
  3690. const relatedTarget = {
  3691. relatedTarget: this._element
  3692. };
  3693. const showEvent = EventHandler.trigger(this._element, EVENT_SHOW$5, relatedTarget);
  3694. if (showEvent.defaultPrevented) {
  3695. return;
  3696. }
  3697. this._createPopper();
  3698. // If this is a touch-enabled device we add extra
  3699. // empty mouseover listeners to the body's immediate children;
  3700. // only needed because of broken event delegation on iOS
  3701. // https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html
  3702. if ('ontouchstart' in document.documentElement && !this._parent.closest(SELECTOR_NAVBAR_NAV)) {
  3703. for (const element of [].concat(...document.body.children)) {
  3704. EventHandler.on(element, 'mouseover', noop);
  3705. }
  3706. }
  3707. this._element.focus();
  3708. this._element.setAttribute('aria-expanded', true);
  3709. this._menu.classList.add(CLASS_NAME_SHOW$6);
  3710. this._element.classList.add(CLASS_NAME_SHOW$6);
  3711. EventHandler.trigger(this._element, EVENT_SHOWN$5, relatedTarget);
  3712. }
  3713. hide() {
  3714. if (isDisabled(this._element) || !this._isShown()) {
  3715. return;
  3716. }
  3717. const relatedTarget = {
  3718. relatedTarget: this._element
  3719. };
  3720. this._completeHide(relatedTarget);
  3721. }
  3722. dispose() {
  3723. if (this._popper) {
  3724. this._popper.destroy();
  3725. }
  3726. super.dispose();
  3727. }
  3728. update() {
  3729. this._inNavbar = this._detectNavbar();
  3730. if (this._popper) {
  3731. this._popper.update();
  3732. }
  3733. }
  3734. // Private
  3735. _completeHide(relatedTarget) {
  3736. const hideEvent = EventHandler.trigger(this._element, EVENT_HIDE$5, relatedTarget);
  3737. if (hideEvent.defaultPrevented) {
  3738. return;
  3739. }
  3740. // If this is a touch-enabled device we remove the extra
  3741. // empty mouseover listeners we added for iOS support
  3742. if ('ontouchstart' in document.documentElement) {
  3743. for (const element of [].concat(...document.body.children)) {
  3744. EventHandler.off(element, 'mouseover', noop);
  3745. }
  3746. }
  3747. if (this._popper) {
  3748. this._popper.destroy();
  3749. }
  3750. this._menu.classList.remove(CLASS_NAME_SHOW$6);
  3751. this._element.classList.remove(CLASS_NAME_SHOW$6);
  3752. this._element.setAttribute('aria-expanded', 'false');
  3753. Manipulator.removeDataAttribute(this._menu, 'popper');
  3754. EventHandler.trigger(this._element, EVENT_HIDDEN$5, relatedTarget);
  3755. // Explicitly return focus to the trigger element
  3756. this._element.focus();
  3757. }
  3758. _getConfig(config) {
  3759. config = super._getConfig(config);
  3760. if (typeof config.reference === 'object' && !isElement$1(config.reference) && typeof config.reference.getBoundingClientRect !== 'function') {
  3761. // Popper virtual elements require a getBoundingClientRect method
  3762. throw new TypeError(`${NAME$a.toUpperCase()}: Option "reference" provided type "object" without a required "getBoundingClientRect" method.`);
  3763. }
  3764. return config;
  3765. }
  3766. _createPopper() {
  3767. if (typeof Popper === 'undefined') {
  3768. throw new TypeError('Bootstrap\'s dropdowns require Popper (https://popper.js.org/docs/v2/)');
  3769. }
  3770. let referenceElement = this._element;
  3771. if (this._config.reference === 'parent') {
  3772. referenceElement = this._parent;
  3773. } else if (isElement$1(this._config.reference)) {
  3774. referenceElement = getElement(this._config.reference);
  3775. } else if (typeof this._config.reference === 'object') {
  3776. referenceElement = this._config.reference;
  3777. }
  3778. const popperConfig = this._getPopperConfig();
  3779. this._popper = createPopper(referenceElement, this._menu, popperConfig);
  3780. }
  3781. _isShown() {
  3782. return this._menu.classList.contains(CLASS_NAME_SHOW$6);
  3783. }
  3784. _getPlacement() {
  3785. const parentDropdown = this._parent;
  3786. if (parentDropdown.classList.contains(CLASS_NAME_DROPEND)) {
  3787. return PLACEMENT_RIGHT;
  3788. }
  3789. if (parentDropdown.classList.contains(CLASS_NAME_DROPSTART)) {
  3790. return PLACEMENT_LEFT;
  3791. }
  3792. if (parentDropdown.classList.contains(CLASS_NAME_DROPUP_CENTER)) {
  3793. return PLACEMENT_TOPCENTER;
  3794. }
  3795. if (parentDropdown.classList.contains(CLASS_NAME_DROPDOWN_CENTER)) {
  3796. return PLACEMENT_BOTTOMCENTER;
  3797. }
  3798. // We need to trim the value because custom properties can also include spaces
  3799. const isEnd = getComputedStyle(this._menu).getPropertyValue('--bs-position').trim() === 'end';
  3800. if (parentDropdown.classList.contains(CLASS_NAME_DROPUP)) {
  3801. return isEnd ? PLACEMENT_TOPEND : PLACEMENT_TOP;
  3802. }
  3803. return isEnd ? PLACEMENT_BOTTOMEND : PLACEMENT_BOTTOM;
  3804. }
  3805. _detectNavbar() {
  3806. return this._element.closest(SELECTOR_NAVBAR) !== null;
  3807. }
  3808. _getOffset() {
  3809. const {
  3810. offset
  3811. } = this._config;
  3812. if (typeof offset === 'string') {
  3813. return offset.split(',').map(value => Number.parseInt(value, 10));
  3814. }
  3815. if (typeof offset === 'function') {
  3816. return popperData => offset(popperData, this._element);
  3817. }
  3818. return offset;
  3819. }
  3820. _getPopperConfig() {
  3821. const defaultBsPopperConfig = {
  3822. placement: this._getPlacement(),
  3823. modifiers: [{
  3824. name: 'preventOverflow',
  3825. options: {
  3826. boundary: this._config.boundary
  3827. }
  3828. }, {
  3829. name: 'offset',
  3830. options: {
  3831. offset: this._getOffset()
  3832. }
  3833. }]
  3834. };
  3835. // Disable Popper if we have a static display or Dropdown is in Navbar
  3836. if (this._inNavbar || this._config.display === 'static') {
  3837. Manipulator.setDataAttribute(this._menu, 'popper', 'static'); // TODO: v6 remove
  3838. defaultBsPopperConfig.modifiers = [{
  3839. name: 'applyStyles',
  3840. enabled: false
  3841. }];
  3842. }
  3843. return {
  3844. ...defaultBsPopperConfig,
  3845. ...execute(this._config.popperConfig, [undefined, defaultBsPopperConfig])
  3846. };
  3847. }
  3848. _selectMenuItem({
  3849. key,
  3850. target
  3851. }) {
  3852. const items = SelectorEngine.find(SELECTOR_VISIBLE_ITEMS, this._menu).filter(element => isVisible(element));
  3853. if (!items.length) {
  3854. return;
  3855. }
  3856. // if target isn't included in items (e.g. when expanding the dropdown)
  3857. // allow cycling to get the last item in case key equals ARROW_UP_KEY
  3858. getNextActiveElement(items, target, key === ARROW_DOWN_KEY$1, !items.includes(target)).focus();
  3859. }
  3860. // Static
  3861. static jQueryInterface(config) {
  3862. return this.each(function () {
  3863. const data = Dropdown.getOrCreateInstance(this, config);
  3864. if (typeof config !== 'string') {
  3865. return;
  3866. }
  3867. if (typeof data[config] === 'undefined') {
  3868. throw new TypeError(`No method named "${config}"`);
  3869. }
  3870. data[config]();
  3871. });
  3872. }
  3873. static clearMenus(event) {
  3874. if (event.button === RIGHT_MOUSE_BUTTON || event.type === 'keyup' && event.key !== TAB_KEY$1) {
  3875. return;
  3876. }
  3877. const openToggles = SelectorEngine.find(SELECTOR_DATA_TOGGLE_SHOWN);
  3878. for (const toggle of openToggles) {
  3879. const context = Dropdown.getInstance(toggle);
  3880. if (!context || context._config.autoClose === false) {
  3881. continue;
  3882. }
  3883. const composedPath = event.composedPath();
  3884. const isMenuTarget = composedPath.includes(context._menu);
  3885. if (composedPath.includes(context._element) || context._config.autoClose === 'inside' && !isMenuTarget || context._config.autoClose === 'outside' && isMenuTarget) {
  3886. continue;
  3887. }
  3888. // Tab navigation through the dropdown menu or events from contained inputs shouldn't close the menu
  3889. if (context._menu.contains(event.target) && (event.type === 'keyup' && event.key === TAB_KEY$1 || /input|select|option|textarea|form/i.test(event.target.tagName))) {
  3890. continue;
  3891. }
  3892. const relatedTarget = {
  3893. relatedTarget: context._element
  3894. };
  3895. if (event.type === 'click') {
  3896. relatedTarget.clickEvent = event;
  3897. }
  3898. context._completeHide(relatedTarget);
  3899. }
  3900. }
  3901. static dataApiKeydownHandler(event) {
  3902. // If not an UP | DOWN | ESCAPE key => not a dropdown command
  3903. // If input/textarea && if key is other than ESCAPE => not a dropdown command
  3904. const isInput = /input|textarea/i.test(event.target.tagName);
  3905. const isEscapeEvent = event.key === ESCAPE_KEY$2;
  3906. const isUpOrDownEvent = [ARROW_UP_KEY$1, ARROW_DOWN_KEY$1].includes(event.key);
  3907. if (!isUpOrDownEvent && !isEscapeEvent) {
  3908. return;
  3909. }
  3910. if (isInput && !isEscapeEvent) {
  3911. return;
  3912. }
  3913. event.preventDefault();
  3914. // TODO: v6 revert #37011 & change markup https://getbootstrap.com/docs/5.3/forms/input-group/
  3915. 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);
  3916. const instance = Dropdown.getOrCreateInstance(getToggleButton);
  3917. if (isUpOrDownEvent) {
  3918. event.stopPropagation();
  3919. instance.show();
  3920. instance._selectMenuItem(event);
  3921. return;
  3922. }
  3923. if (instance._isShown()) {
  3924. // else is escape and we check if it is shown
  3925. event.stopPropagation();
  3926. instance.hide();
  3927. getToggleButton.focus();
  3928. }
  3929. }
  3930. }
  3931. /**
  3932. * Data API implementation
  3933. */
  3934. EventHandler.on(document, EVENT_KEYDOWN_DATA_API, SELECTOR_DATA_TOGGLE$3, Dropdown.dataApiKeydownHandler);
  3935. EventHandler.on(document, EVENT_KEYDOWN_DATA_API, SELECTOR_MENU, Dropdown.dataApiKeydownHandler);
  3936. EventHandler.on(document, EVENT_CLICK_DATA_API$3, Dropdown.clearMenus);
  3937. EventHandler.on(document, EVENT_KEYUP_DATA_API, Dropdown.clearMenus);
  3938. EventHandler.on(document, EVENT_CLICK_DATA_API$3, SELECTOR_DATA_TOGGLE$3, function (event) {
  3939. event.preventDefault();
  3940. Dropdown.getOrCreateInstance(this).toggle();
  3941. });
  3942. /**
  3943. * jQuery
  3944. */
  3945. defineJQueryPlugin(Dropdown);
  3946. /**
  3947. * --------------------------------------------------------------------------
  3948. * Bootstrap util/backdrop.js
  3949. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  3950. * --------------------------------------------------------------------------
  3951. */
  3952. /**
  3953. * Constants
  3954. */
  3955. const NAME$9 = 'backdrop';
  3956. const CLASS_NAME_FADE$4 = 'fade';
  3957. const CLASS_NAME_SHOW$5 = 'show';
  3958. const EVENT_MOUSEDOWN = `mousedown.bs.${NAME$9}`;
  3959. const Default$8 = {
  3960. className: 'modal-backdrop',
  3961. clickCallback: null,
  3962. isAnimated: false,
  3963. isVisible: true,
  3964. // if false, we use the backdrop helper without adding any element to the dom
  3965. rootElement: 'body' // give the choice to place backdrop under different elements
  3966. };
  3967. const DefaultType$8 = {
  3968. className: 'string',
  3969. clickCallback: '(function|null)',
  3970. isAnimated: 'boolean',
  3971. isVisible: 'boolean',
  3972. rootElement: '(element|string)'
  3973. };
  3974. /**
  3975. * Class definition
  3976. */
  3977. class Backdrop extends Config {
  3978. constructor(config) {
  3979. super();
  3980. this._config = this._getConfig(config);
  3981. this._isAppended = false;
  3982. this._element = null;
  3983. }
  3984. // Getters
  3985. static get Default() {
  3986. return Default$8;
  3987. }
  3988. static get DefaultType() {
  3989. return DefaultType$8;
  3990. }
  3991. static get NAME() {
  3992. return NAME$9;
  3993. }
  3994. // Public
  3995. show(callback) {
  3996. if (!this._config.isVisible) {
  3997. execute(callback);
  3998. return;
  3999. }
  4000. this._append();
  4001. const element = this._getElement();
  4002. if (this._config.isAnimated) {
  4003. reflow(element);
  4004. }
  4005. element.classList.add(CLASS_NAME_SHOW$5);
  4006. this._emulateAnimation(() => {
  4007. execute(callback);
  4008. });
  4009. }
  4010. hide(callback) {
  4011. if (!this._config.isVisible) {
  4012. execute(callback);
  4013. return;
  4014. }
  4015. this._getElement().classList.remove(CLASS_NAME_SHOW$5);
  4016. this._emulateAnimation(() => {
  4017. this.dispose();
  4018. execute(callback);
  4019. });
  4020. }
  4021. dispose() {
  4022. if (!this._isAppended) {
  4023. return;
  4024. }
  4025. EventHandler.off(this._element, EVENT_MOUSEDOWN);
  4026. this._element.remove();
  4027. this._isAppended = false;
  4028. }
  4029. // Private
  4030. _getElement() {
  4031. if (!this._element) {
  4032. const backdrop = document.createElement('div');
  4033. backdrop.className = this._config.className;
  4034. if (this._config.isAnimated) {
  4035. backdrop.classList.add(CLASS_NAME_FADE$4);
  4036. }
  4037. this._element = backdrop;
  4038. }
  4039. return this._element;
  4040. }
  4041. _configAfterMerge(config) {
  4042. // use getElement() with the default "body" to get a fresh Element on each instantiation
  4043. config.rootElement = getElement(config.rootElement);
  4044. return config;
  4045. }
  4046. _append() {
  4047. if (this._isAppended) {
  4048. return;
  4049. }
  4050. const element = this._getElement();
  4051. this._config.rootElement.append(element);
  4052. EventHandler.on(element, EVENT_MOUSEDOWN, () => {
  4053. execute(this._config.clickCallback);
  4054. });
  4055. this._isAppended = true;
  4056. }
  4057. _emulateAnimation(callback) {
  4058. executeAfterTransition(callback, this._getElement(), this._config.isAnimated);
  4059. }
  4060. }
  4061. /**
  4062. * --------------------------------------------------------------------------
  4063. * Bootstrap util/focustrap.js
  4064. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  4065. * --------------------------------------------------------------------------
  4066. */
  4067. /**
  4068. * Constants
  4069. */
  4070. const NAME$8 = 'focustrap';
  4071. const DATA_KEY$5 = 'bs.focustrap';
  4072. const EVENT_KEY$5 = `.${DATA_KEY$5}`;
  4073. const EVENT_FOCUSIN$2 = `focusin${EVENT_KEY$5}`;
  4074. const EVENT_KEYDOWN_TAB = `keydown.tab${EVENT_KEY$5}`;
  4075. const TAB_KEY = 'Tab';
  4076. const TAB_NAV_FORWARD = 'forward';
  4077. const TAB_NAV_BACKWARD = 'backward';
  4078. const Default$7 = {
  4079. autofocus: true,
  4080. trapElement: null // The element to trap focus inside of
  4081. };
  4082. const DefaultType$7 = {
  4083. autofocus: 'boolean',
  4084. trapElement: 'element'
  4085. };
  4086. /**
  4087. * Class definition
  4088. */
  4089. class FocusTrap extends Config {
  4090. constructor(config) {
  4091. super();
  4092. this._config = this._getConfig(config);
  4093. this._isActive = false;
  4094. this._lastTabNavDirection = null;
  4095. }
  4096. // Getters
  4097. static get Default() {
  4098. return Default$7;
  4099. }
  4100. static get DefaultType() {
  4101. return DefaultType$7;
  4102. }
  4103. static get NAME() {
  4104. return NAME$8;
  4105. }
  4106. // Public
  4107. activate() {
  4108. if (this._isActive) {
  4109. return;
  4110. }
  4111. if (this._config.autofocus) {
  4112. this._config.trapElement.focus();
  4113. }
  4114. EventHandler.off(document, EVENT_KEY$5); // guard against infinite focus loop
  4115. EventHandler.on(document, EVENT_FOCUSIN$2, event => this._handleFocusin(event));
  4116. EventHandler.on(document, EVENT_KEYDOWN_TAB, event => this._handleKeydown(event));
  4117. this._isActive = true;
  4118. }
  4119. deactivate() {
  4120. if (!this._isActive) {
  4121. return;
  4122. }
  4123. this._isActive = false;
  4124. EventHandler.off(document, EVENT_KEY$5);
  4125. }
  4126. // Private
  4127. _handleFocusin(event) {
  4128. const {
  4129. trapElement
  4130. } = this._config;
  4131. if (event.target === document || event.target === trapElement || trapElement.contains(event.target)) {
  4132. return;
  4133. }
  4134. const elements = SelectorEngine.focusableChildren(trapElement);
  4135. if (elements.length === 0) {
  4136. trapElement.focus();
  4137. } else if (this._lastTabNavDirection === TAB_NAV_BACKWARD) {
  4138. elements[elements.length - 1].focus();
  4139. } else {
  4140. elements[0].focus();
  4141. }
  4142. }
  4143. _handleKeydown(event) {
  4144. if (event.key !== TAB_KEY) {
  4145. return;
  4146. }
  4147. this._lastTabNavDirection = event.shiftKey ? TAB_NAV_BACKWARD : TAB_NAV_FORWARD;
  4148. }
  4149. }
  4150. /**
  4151. * --------------------------------------------------------------------------
  4152. * Bootstrap util/scrollBar.js
  4153. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  4154. * --------------------------------------------------------------------------
  4155. */
  4156. /**
  4157. * Constants
  4158. */
  4159. const SELECTOR_FIXED_CONTENT = '.fixed-top, .fixed-bottom, .is-fixed, .sticky-top';
  4160. const SELECTOR_STICKY_CONTENT = '.sticky-top';
  4161. const PROPERTY_PADDING = 'padding-right';
  4162. const PROPERTY_MARGIN = 'margin-right';
  4163. /**
  4164. * Class definition
  4165. */
  4166. class ScrollBarHelper {
  4167. constructor() {
  4168. this._element = document.body;
  4169. }
  4170. // Public
  4171. getWidth() {
  4172. // https://developer.mozilla.org/en-US/docs/Web/API/Window/innerWidth#usage_notes
  4173. const documentWidth = document.documentElement.clientWidth;
  4174. return Math.abs(window.innerWidth - documentWidth);
  4175. }
  4176. hide() {
  4177. const width = this.getWidth();
  4178. this._disableOverFlow();
  4179. // give padding to element to balance the hidden scrollbar width
  4180. this._setElementAttributes(this._element, PROPERTY_PADDING, calculatedValue => calculatedValue + width);
  4181. // trick: We adjust positive paddingRight and negative marginRight to sticky-top elements to keep showing fullwidth
  4182. this._setElementAttributes(SELECTOR_FIXED_CONTENT, PROPERTY_PADDING, calculatedValue => calculatedValue + width);
  4183. this._setElementAttributes(SELECTOR_STICKY_CONTENT, PROPERTY_MARGIN, calculatedValue => calculatedValue - width);
  4184. }
  4185. reset() {
  4186. this._resetElementAttributes(this._element, 'overflow');
  4187. this._resetElementAttributes(this._element, PROPERTY_PADDING);
  4188. this._resetElementAttributes(SELECTOR_FIXED_CONTENT, PROPERTY_PADDING);
  4189. this._resetElementAttributes(SELECTOR_STICKY_CONTENT, PROPERTY_MARGIN);
  4190. }
  4191. isOverflowing() {
  4192. return this.getWidth() > 0;
  4193. }
  4194. // Private
  4195. _disableOverFlow() {
  4196. this._saveInitialAttribute(this._element, 'overflow');
  4197. this._element.style.overflow = 'hidden';
  4198. }
  4199. _setElementAttributes(selector, styleProperty, callback) {
  4200. const scrollbarWidth = this.getWidth();
  4201. const manipulationCallBack = element => {
  4202. if (element !== this._element && window.innerWidth > element.clientWidth + scrollbarWidth) {
  4203. return;
  4204. }
  4205. this._saveInitialAttribute(element, styleProperty);
  4206. const calculatedValue = window.getComputedStyle(element).getPropertyValue(styleProperty);
  4207. element.style.setProperty(styleProperty, `${callback(Number.parseFloat(calculatedValue))}px`);
  4208. };
  4209. this._applyManipulationCallback(selector, manipulationCallBack);
  4210. }
  4211. _saveInitialAttribute(element, styleProperty) {
  4212. const actualValue = element.style.getPropertyValue(styleProperty);
  4213. if (actualValue) {
  4214. Manipulator.setDataAttribute(element, styleProperty, actualValue);
  4215. }
  4216. }
  4217. _resetElementAttributes(selector, styleProperty) {
  4218. const manipulationCallBack = element => {
  4219. const value = Manipulator.getDataAttribute(element, styleProperty);
  4220. // We only want to remove the property if the value is `null`; the value can also be zero
  4221. if (value === null) {
  4222. element.style.removeProperty(styleProperty);
  4223. return;
  4224. }
  4225. Manipulator.removeDataAttribute(element, styleProperty);
  4226. element.style.setProperty(styleProperty, value);
  4227. };
  4228. this._applyManipulationCallback(selector, manipulationCallBack);
  4229. }
  4230. _applyManipulationCallback(selector, callBack) {
  4231. if (isElement$1(selector)) {
  4232. callBack(selector);
  4233. return;
  4234. }
  4235. for (const sel of SelectorEngine.find(selector, this._element)) {
  4236. callBack(sel);
  4237. }
  4238. }
  4239. }
  4240. /**
  4241. * --------------------------------------------------------------------------
  4242. * Bootstrap modal.js
  4243. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  4244. * --------------------------------------------------------------------------
  4245. */
  4246. /**
  4247. * Constants
  4248. */
  4249. const NAME$7 = 'modal';
  4250. const DATA_KEY$4 = 'bs.modal';
  4251. const EVENT_KEY$4 = `.${DATA_KEY$4}`;
  4252. const DATA_API_KEY$2 = '.data-api';
  4253. const ESCAPE_KEY$1 = 'Escape';
  4254. const EVENT_HIDE$4 = `hide${EVENT_KEY$4}`;
  4255. const EVENT_HIDE_PREVENTED$1 = `hidePrevented${EVENT_KEY$4}`;
  4256. const EVENT_HIDDEN$4 = `hidden${EVENT_KEY$4}`;
  4257. const EVENT_SHOW$4 = `show${EVENT_KEY$4}`;
  4258. const EVENT_SHOWN$4 = `shown${EVENT_KEY$4}`;
  4259. const EVENT_RESIZE$1 = `resize${EVENT_KEY$4}`;
  4260. const EVENT_CLICK_DISMISS = `click.dismiss${EVENT_KEY$4}`;
  4261. const EVENT_MOUSEDOWN_DISMISS = `mousedown.dismiss${EVENT_KEY$4}`;
  4262. const EVENT_KEYDOWN_DISMISS$1 = `keydown.dismiss${EVENT_KEY$4}`;
  4263. const EVENT_CLICK_DATA_API$2 = `click${EVENT_KEY$4}${DATA_API_KEY$2}`;
  4264. const CLASS_NAME_OPEN = 'modal-open';
  4265. const CLASS_NAME_FADE$3 = 'fade';
  4266. const CLASS_NAME_SHOW$4 = 'show';
  4267. const CLASS_NAME_STATIC = 'modal-static';
  4268. const OPEN_SELECTOR$1 = '.modal.show';
  4269. const SELECTOR_DIALOG = '.modal-dialog';
  4270. const SELECTOR_MODAL_BODY = '.modal-body';
  4271. const SELECTOR_DATA_TOGGLE$2 = '[data-bs-toggle="modal"]';
  4272. const Default$6 = {
  4273. backdrop: true,
  4274. focus: true,
  4275. keyboard: true
  4276. };
  4277. const DefaultType$6 = {
  4278. backdrop: '(boolean|string)',
  4279. focus: 'boolean',
  4280. keyboard: 'boolean'
  4281. };
  4282. /**
  4283. * Class definition
  4284. */
  4285. class Modal extends BaseComponent {
  4286. constructor(element, config) {
  4287. super(element, config);
  4288. this._dialog = SelectorEngine.findOne(SELECTOR_DIALOG, this._element);
  4289. this._backdrop = this._initializeBackDrop();
  4290. this._focustrap = this._initializeFocusTrap();
  4291. this._isShown = false;
  4292. this._isTransitioning = false;
  4293. this._scrollBar = new ScrollBarHelper();
  4294. this._addEventListeners();
  4295. }
  4296. // Getters
  4297. static get Default() {
  4298. return Default$6;
  4299. }
  4300. static get DefaultType() {
  4301. return DefaultType$6;
  4302. }
  4303. static get NAME() {
  4304. return NAME$7;
  4305. }
  4306. // Public
  4307. toggle(relatedTarget) {
  4308. return this._isShown ? this.hide() : this.show(relatedTarget);
  4309. }
  4310. show(relatedTarget) {
  4311. if (this._isShown || this._isTransitioning) {
  4312. return;
  4313. }
  4314. const showEvent = EventHandler.trigger(this._element, EVENT_SHOW$4, {
  4315. relatedTarget
  4316. });
  4317. if (showEvent.defaultPrevented) {
  4318. return;
  4319. }
  4320. this._isShown = true;
  4321. this._isTransitioning = true;
  4322. this._scrollBar.hide();
  4323. document.body.classList.add(CLASS_NAME_OPEN);
  4324. this._adjustDialog();
  4325. this._backdrop.show(() => this._showElement(relatedTarget));
  4326. }
  4327. hide() {
  4328. if (!this._isShown || this._isTransitioning) {
  4329. return;
  4330. }
  4331. const hideEvent = EventHandler.trigger(this._element, EVENT_HIDE$4);
  4332. if (hideEvent.defaultPrevented) {
  4333. return;
  4334. }
  4335. this._isShown = false;
  4336. this._isTransitioning = true;
  4337. this._focustrap.deactivate();
  4338. this._element.classList.remove(CLASS_NAME_SHOW$4);
  4339. this._queueCallback(() => this._hideModal(), this._element, this._isAnimated());
  4340. }
  4341. dispose() {
  4342. EventHandler.off(window, EVENT_KEY$4);
  4343. EventHandler.off(this._dialog, EVENT_KEY$4);
  4344. this._backdrop.dispose();
  4345. this._focustrap.deactivate();
  4346. super.dispose();
  4347. }
  4348. handleUpdate() {
  4349. this._adjustDialog();
  4350. }
  4351. // Private
  4352. _initializeBackDrop() {
  4353. return new Backdrop({
  4354. isVisible: Boolean(this._config.backdrop),
  4355. // 'static' option will be translated to true, and booleans will keep their value,
  4356. isAnimated: this._isAnimated()
  4357. });
  4358. }
  4359. _initializeFocusTrap() {
  4360. return new FocusTrap({
  4361. trapElement: this._element
  4362. });
  4363. }
  4364. _showElement(relatedTarget) {
  4365. // try to append dynamic modal
  4366. if (!document.body.contains(this._element)) {
  4367. document.body.append(this._element);
  4368. }
  4369. this._element.style.display = 'block';
  4370. this._element.removeAttribute('aria-hidden');
  4371. this._element.setAttribute('aria-modal', true);
  4372. this._element.setAttribute('role', 'dialog');
  4373. this._element.scrollTop = 0;
  4374. const modalBody = SelectorEngine.findOne(SELECTOR_MODAL_BODY, this._dialog);
  4375. if (modalBody) {
  4376. modalBody.scrollTop = 0;
  4377. }
  4378. reflow(this._element);
  4379. this._element.classList.add(CLASS_NAME_SHOW$4);
  4380. const transitionComplete = () => {
  4381. if (this._config.focus) {
  4382. this._focustrap.activate();
  4383. }
  4384. this._isTransitioning = false;
  4385. EventHandler.trigger(this._element, EVENT_SHOWN$4, {
  4386. relatedTarget
  4387. });
  4388. };
  4389. this._queueCallback(transitionComplete, this._dialog, this._isAnimated());
  4390. }
  4391. _addEventListeners() {
  4392. EventHandler.on(this._element, EVENT_KEYDOWN_DISMISS$1, event => {
  4393. if (event.key !== ESCAPE_KEY$1) {
  4394. return;
  4395. }
  4396. if (this._config.keyboard) {
  4397. this.hide();
  4398. return;
  4399. }
  4400. this._triggerBackdropTransition();
  4401. });
  4402. EventHandler.on(window, EVENT_RESIZE$1, () => {
  4403. if (this._isShown && !this._isTransitioning) {
  4404. this._adjustDialog();
  4405. }
  4406. });
  4407. EventHandler.on(this._element, EVENT_MOUSEDOWN_DISMISS, event => {
  4408. // a bad trick to segregate clicks that may start inside dialog but end outside, and avoid listen to scrollbar clicks
  4409. EventHandler.one(this._element, EVENT_CLICK_DISMISS, event2 => {
  4410. if (this._element !== event.target || this._element !== event2.target) {
  4411. return;
  4412. }
  4413. if (this._config.backdrop === 'static') {
  4414. this._triggerBackdropTransition();
  4415. return;
  4416. }
  4417. if (this._config.backdrop) {
  4418. this.hide();
  4419. }
  4420. });
  4421. });
  4422. }
  4423. _hideModal() {
  4424. this._element.style.display = 'none';
  4425. this._element.setAttribute('aria-hidden', true);
  4426. this._element.removeAttribute('aria-modal');
  4427. this._element.removeAttribute('role');
  4428. this._isTransitioning = false;
  4429. this._backdrop.hide(() => {
  4430. document.body.classList.remove(CLASS_NAME_OPEN);
  4431. this._resetAdjustments();
  4432. this._scrollBar.reset();
  4433. EventHandler.trigger(this._element, EVENT_HIDDEN$4);
  4434. });
  4435. }
  4436. _isAnimated() {
  4437. return this._element.classList.contains(CLASS_NAME_FADE$3);
  4438. }
  4439. _triggerBackdropTransition() {
  4440. const hideEvent = EventHandler.trigger(this._element, EVENT_HIDE_PREVENTED$1);
  4441. if (hideEvent.defaultPrevented) {
  4442. return;
  4443. }
  4444. const isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight;
  4445. const initialOverflowY = this._element.style.overflowY;
  4446. // return if the following background transition hasn't yet completed
  4447. if (initialOverflowY === 'hidden' || this._element.classList.contains(CLASS_NAME_STATIC)) {
  4448. return;
  4449. }
  4450. if (!isModalOverflowing) {
  4451. this._element.style.overflowY = 'hidden';
  4452. }
  4453. this._element.classList.add(CLASS_NAME_STATIC);
  4454. this._queueCallback(() => {
  4455. this._element.classList.remove(CLASS_NAME_STATIC);
  4456. this._queueCallback(() => {
  4457. this._element.style.overflowY = initialOverflowY;
  4458. }, this._dialog);
  4459. }, this._dialog);
  4460. this._element.focus();
  4461. }
  4462. /**
  4463. * The following methods are used to handle overflowing modals
  4464. */
  4465. _adjustDialog() {
  4466. const isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight;
  4467. const scrollbarWidth = this._scrollBar.getWidth();
  4468. const isBodyOverflowing = scrollbarWidth > 0;
  4469. if (isBodyOverflowing && !isModalOverflowing) {
  4470. const property = isRTL() ? 'paddingLeft' : 'paddingRight';
  4471. this._element.style[property] = `${scrollbarWidth}px`;
  4472. }
  4473. if (!isBodyOverflowing && isModalOverflowing) {
  4474. const property = isRTL() ? 'paddingRight' : 'paddingLeft';
  4475. this._element.style[property] = `${scrollbarWidth}px`;
  4476. }
  4477. }
  4478. _resetAdjustments() {
  4479. this._element.style.paddingLeft = '';
  4480. this._element.style.paddingRight = '';
  4481. }
  4482. // Static
  4483. static jQueryInterface(config, relatedTarget) {
  4484. return this.each(function () {
  4485. const data = Modal.getOrCreateInstance(this, config);
  4486. if (typeof config !== 'string') {
  4487. return;
  4488. }
  4489. if (typeof data[config] === 'undefined') {
  4490. throw new TypeError(`No method named "${config}"`);
  4491. }
  4492. data[config](relatedTarget);
  4493. });
  4494. }
  4495. }
  4496. /**
  4497. * Data API implementation
  4498. */
  4499. EventHandler.on(document, EVENT_CLICK_DATA_API$2, SELECTOR_DATA_TOGGLE$2, function (event) {
  4500. const target = SelectorEngine.getElementFromSelector(this);
  4501. if (['A', 'AREA'].includes(this.tagName)) {
  4502. event.preventDefault();
  4503. }
  4504. EventHandler.one(target, EVENT_SHOW$4, showEvent => {
  4505. if (showEvent.defaultPrevented) {
  4506. // only register focus restorer if modal will actually get shown
  4507. return;
  4508. }
  4509. EventHandler.one(target, EVENT_HIDDEN$4, () => {
  4510. if (isVisible(this)) {
  4511. this.focus();
  4512. }
  4513. });
  4514. });
  4515. // avoid conflict when clicking modal toggler while another one is open
  4516. const alreadyOpen = SelectorEngine.findOne(OPEN_SELECTOR$1);
  4517. if (alreadyOpen) {
  4518. Modal.getInstance(alreadyOpen).hide();
  4519. }
  4520. const data = Modal.getOrCreateInstance(target);
  4521. data.toggle(this);
  4522. });
  4523. enableDismissTrigger(Modal);
  4524. /**
  4525. * jQuery
  4526. */
  4527. defineJQueryPlugin(Modal);
  4528. /**
  4529. * --------------------------------------------------------------------------
  4530. * Bootstrap offcanvas.js
  4531. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  4532. * --------------------------------------------------------------------------
  4533. */
  4534. /**
  4535. * Constants
  4536. */
  4537. const NAME$6 = 'offcanvas';
  4538. const DATA_KEY$3 = 'bs.offcanvas';
  4539. const EVENT_KEY$3 = `.${DATA_KEY$3}`;
  4540. const DATA_API_KEY$1 = '.data-api';
  4541. const EVENT_LOAD_DATA_API$2 = `load${EVENT_KEY$3}${DATA_API_KEY$1}`;
  4542. const ESCAPE_KEY = 'Escape';
  4543. const CLASS_NAME_SHOW$3 = 'show';
  4544. const CLASS_NAME_SHOWING$1 = 'showing';
  4545. const CLASS_NAME_HIDING = 'hiding';
  4546. const CLASS_NAME_BACKDROP = 'offcanvas-backdrop';
  4547. const OPEN_SELECTOR = '.offcanvas.show';
  4548. const EVENT_SHOW$3 = `show${EVENT_KEY$3}`;
  4549. const EVENT_SHOWN$3 = `shown${EVENT_KEY$3}`;
  4550. const EVENT_HIDE$3 = `hide${EVENT_KEY$3}`;
  4551. const EVENT_HIDE_PREVENTED = `hidePrevented${EVENT_KEY$3}`;
  4552. const EVENT_HIDDEN$3 = `hidden${EVENT_KEY$3}`;
  4553. const EVENT_RESIZE = `resize${EVENT_KEY$3}`;
  4554. const EVENT_CLICK_DATA_API$1 = `click${EVENT_KEY$3}${DATA_API_KEY$1}`;
  4555. const EVENT_KEYDOWN_DISMISS = `keydown.dismiss${EVENT_KEY$3}`;
  4556. const SELECTOR_DATA_TOGGLE$1 = '[data-bs-toggle="offcanvas"]';
  4557. const Default$5 = {
  4558. backdrop: true,
  4559. keyboard: true,
  4560. scroll: false
  4561. };
  4562. const DefaultType$5 = {
  4563. backdrop: '(boolean|string)',
  4564. keyboard: 'boolean',
  4565. scroll: 'boolean'
  4566. };
  4567. /**
  4568. * Class definition
  4569. */
  4570. class Offcanvas extends BaseComponent {
  4571. constructor(element, config) {
  4572. super(element, config);
  4573. this._isShown = false;
  4574. this._backdrop = this._initializeBackDrop();
  4575. this._focustrap = this._initializeFocusTrap();
  4576. this._addEventListeners();
  4577. }
  4578. // Getters
  4579. static get Default() {
  4580. return Default$5;
  4581. }
  4582. static get DefaultType() {
  4583. return DefaultType$5;
  4584. }
  4585. static get NAME() {
  4586. return NAME$6;
  4587. }
  4588. // Public
  4589. toggle(relatedTarget) {
  4590. return this._isShown ? this.hide() : this.show(relatedTarget);
  4591. }
  4592. show(relatedTarget) {
  4593. if (this._isShown) {
  4594. return;
  4595. }
  4596. const showEvent = EventHandler.trigger(this._element, EVENT_SHOW$3, {
  4597. relatedTarget
  4598. });
  4599. if (showEvent.defaultPrevented) {
  4600. return;
  4601. }
  4602. this._isShown = true;
  4603. this._backdrop.show();
  4604. if (!this._config.scroll) {
  4605. new ScrollBarHelper().hide();
  4606. }
  4607. this._element.setAttribute('aria-modal', true);
  4608. this._element.setAttribute('role', 'dialog');
  4609. this._element.classList.add(CLASS_NAME_SHOWING$1);
  4610. const completeCallBack = () => {
  4611. if (!this._config.scroll || this._config.backdrop) {
  4612. this._focustrap.activate();
  4613. }
  4614. this._element.classList.add(CLASS_NAME_SHOW$3);
  4615. this._element.classList.remove(CLASS_NAME_SHOWING$1);
  4616. EventHandler.trigger(this._element, EVENT_SHOWN$3, {
  4617. relatedTarget
  4618. });
  4619. };
  4620. this._queueCallback(completeCallBack, this._element, true);
  4621. }
  4622. hide() {
  4623. if (!this._isShown) {
  4624. return;
  4625. }
  4626. const hideEvent = EventHandler.trigger(this._element, EVENT_HIDE$3);
  4627. if (hideEvent.defaultPrevented) {
  4628. return;
  4629. }
  4630. this._focustrap.deactivate();
  4631. this._element.blur();
  4632. this._isShown = false;
  4633. this._element.classList.add(CLASS_NAME_HIDING);
  4634. this._backdrop.hide();
  4635. const completeCallback = () => {
  4636. this._element.classList.remove(CLASS_NAME_SHOW$3, CLASS_NAME_HIDING);
  4637. this._element.removeAttribute('aria-modal');
  4638. this._element.removeAttribute('role');
  4639. if (!this._config.scroll) {
  4640. new ScrollBarHelper().reset();
  4641. }
  4642. EventHandler.trigger(this._element, EVENT_HIDDEN$3);
  4643. };
  4644. this._queueCallback(completeCallback, this._element, true);
  4645. }
  4646. dispose() {
  4647. this._backdrop.dispose();
  4648. this._focustrap.deactivate();
  4649. super.dispose();
  4650. }
  4651. // Private
  4652. _initializeBackDrop() {
  4653. const clickCallback = () => {
  4654. if (this._config.backdrop === 'static') {
  4655. EventHandler.trigger(this._element, EVENT_HIDE_PREVENTED);
  4656. return;
  4657. }
  4658. this.hide();
  4659. };
  4660. // 'static' option will be translated to true, and booleans will keep their value
  4661. const isVisible = Boolean(this._config.backdrop);
  4662. return new Backdrop({
  4663. className: CLASS_NAME_BACKDROP,
  4664. isVisible,
  4665. isAnimated: true,
  4666. rootElement: this._element.parentNode,
  4667. clickCallback: isVisible ? clickCallback : null
  4668. });
  4669. }
  4670. _initializeFocusTrap() {
  4671. return new FocusTrap({
  4672. trapElement: this._element
  4673. });
  4674. }
  4675. _addEventListeners() {
  4676. EventHandler.on(this._element, EVENT_KEYDOWN_DISMISS, event => {
  4677. if (event.key !== ESCAPE_KEY) {
  4678. return;
  4679. }
  4680. if (this._config.keyboard) {
  4681. this.hide();
  4682. return;
  4683. }
  4684. EventHandler.trigger(this._element, EVENT_HIDE_PREVENTED);
  4685. });
  4686. }
  4687. // Static
  4688. static jQueryInterface(config) {
  4689. return this.each(function () {
  4690. const data = Offcanvas.getOrCreateInstance(this, config);
  4691. if (typeof config !== 'string') {
  4692. return;
  4693. }
  4694. if (data[config] === undefined || config.startsWith('_') || config === 'constructor') {
  4695. throw new TypeError(`No method named "${config}"`);
  4696. }
  4697. data[config](this);
  4698. });
  4699. }
  4700. }
  4701. /**
  4702. * Data API implementation
  4703. */
  4704. EventHandler.on(document, EVENT_CLICK_DATA_API$1, SELECTOR_DATA_TOGGLE$1, function (event) {
  4705. const target = SelectorEngine.getElementFromSelector(this);
  4706. if (['A', 'AREA'].includes(this.tagName)) {
  4707. event.preventDefault();
  4708. }
  4709. if (isDisabled(this)) {
  4710. return;
  4711. }
  4712. EventHandler.one(target, EVENT_HIDDEN$3, () => {
  4713. // focus on trigger when it is closed
  4714. if (isVisible(this)) {
  4715. this.focus();
  4716. }
  4717. });
  4718. // avoid conflict when clicking a toggler of an offcanvas, while another is open
  4719. const alreadyOpen = SelectorEngine.findOne(OPEN_SELECTOR);
  4720. if (alreadyOpen && alreadyOpen !== target) {
  4721. Offcanvas.getInstance(alreadyOpen).hide();
  4722. }
  4723. const data = Offcanvas.getOrCreateInstance(target);
  4724. data.toggle(this);
  4725. });
  4726. EventHandler.on(window, EVENT_LOAD_DATA_API$2, () => {
  4727. for (const selector of SelectorEngine.find(OPEN_SELECTOR)) {
  4728. Offcanvas.getOrCreateInstance(selector).show();
  4729. }
  4730. });
  4731. EventHandler.on(window, EVENT_RESIZE, () => {
  4732. for (const element of SelectorEngine.find('[aria-modal][class*=show][class*=offcanvas-]')) {
  4733. if (getComputedStyle(element).position !== 'fixed') {
  4734. Offcanvas.getOrCreateInstance(element).hide();
  4735. }
  4736. }
  4737. });
  4738. enableDismissTrigger(Offcanvas);
  4739. /**
  4740. * jQuery
  4741. */
  4742. defineJQueryPlugin(Offcanvas);
  4743. /**
  4744. * --------------------------------------------------------------------------
  4745. * Bootstrap util/sanitizer.js
  4746. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  4747. * --------------------------------------------------------------------------
  4748. */
  4749. // js-docs-start allow-list
  4750. const ARIA_ATTRIBUTE_PATTERN = /^aria-[\w-]*$/i;
  4751. const DefaultAllowlist = {
  4752. // Global attributes allowed on any supplied element below.
  4753. '*': ['class', 'dir', 'id', 'lang', 'role', ARIA_ATTRIBUTE_PATTERN],
  4754. a: ['target', 'href', 'title', 'rel'],
  4755. area: [],
  4756. b: [],
  4757. br: [],
  4758. col: [],
  4759. code: [],
  4760. dd: [],
  4761. div: [],
  4762. dl: [],
  4763. dt: [],
  4764. em: [],
  4765. hr: [],
  4766. h1: [],
  4767. h2: [],
  4768. h3: [],
  4769. h4: [],
  4770. h5: [],
  4771. h6: [],
  4772. i: [],
  4773. img: ['src', 'srcset', 'alt', 'title', 'width', 'height'],
  4774. li: [],
  4775. ol: [],
  4776. p: [],
  4777. pre: [],
  4778. s: [],
  4779. small: [],
  4780. span: [],
  4781. sub: [],
  4782. sup: [],
  4783. strong: [],
  4784. u: [],
  4785. ul: []
  4786. };
  4787. // js-docs-end allow-list
  4788. const uriAttributes = new Set(['background', 'cite', 'href', 'itemtype', 'longdesc', 'poster', 'src', 'xlink:href']);
  4789. /**
  4790. * A pattern that recognizes URLs that are safe wrt. XSS in URL navigation
  4791. * contexts.
  4792. *
  4793. * Shout-out to Angular https://github.com/angular/angular/blob/15.2.8/packages/core/src/sanitization/url_sanitizer.ts#L38
  4794. */
  4795. const SAFE_URL_PATTERN = /^(?!javascript:)(?:[a-z0-9+.-]+:|[^&:/?#]*(?:[/?#]|$))/i;
  4796. const allowedAttribute = (attribute, allowedAttributeList) => {
  4797. const attributeName = attribute.nodeName.toLowerCase();
  4798. if (allowedAttributeList.includes(attributeName)) {
  4799. if (uriAttributes.has(attributeName)) {
  4800. return Boolean(SAFE_URL_PATTERN.test(attribute.nodeValue));
  4801. }
  4802. return true;
  4803. }
  4804. // Check if a regular expression validates the attribute.
  4805. return allowedAttributeList.filter(attributeRegex => attributeRegex instanceof RegExp).some(regex => regex.test(attributeName));
  4806. };
  4807. function sanitizeHtml(unsafeHtml, allowList, sanitizeFunction) {
  4808. if (!unsafeHtml.length) {
  4809. return unsafeHtml;
  4810. }
  4811. if (sanitizeFunction && typeof sanitizeFunction === 'function') {
  4812. return sanitizeFunction(unsafeHtml);
  4813. }
  4814. const domParser = new window.DOMParser();
  4815. const createdDocument = domParser.parseFromString(unsafeHtml, 'text/html');
  4816. const elements = [].concat(...createdDocument.body.querySelectorAll('*'));
  4817. for (const element of elements) {
  4818. const elementName = element.nodeName.toLowerCase();
  4819. if (!Object.keys(allowList).includes(elementName)) {
  4820. element.remove();
  4821. continue;
  4822. }
  4823. const attributeList = [].concat(...element.attributes);
  4824. const allowedAttributes = [].concat(allowList['*'] || [], allowList[elementName] || []);
  4825. for (const attribute of attributeList) {
  4826. if (!allowedAttribute(attribute, allowedAttributes)) {
  4827. element.removeAttribute(attribute.nodeName);
  4828. }
  4829. }
  4830. }
  4831. return createdDocument.body.innerHTML;
  4832. }
  4833. /**
  4834. * --------------------------------------------------------------------------
  4835. * Bootstrap util/template-factory.js
  4836. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  4837. * --------------------------------------------------------------------------
  4838. */
  4839. /**
  4840. * Constants
  4841. */
  4842. const NAME$5 = 'TemplateFactory';
  4843. const Default$4 = {
  4844. allowList: DefaultAllowlist,
  4845. content: {},
  4846. // { selector : text , selector2 : text2 , }
  4847. extraClass: '',
  4848. html: false,
  4849. sanitize: true,
  4850. sanitizeFn: null,
  4851. template: '<div></div>'
  4852. };
  4853. const DefaultType$4 = {
  4854. allowList: 'object',
  4855. content: 'object',
  4856. extraClass: '(string|function)',
  4857. html: 'boolean',
  4858. sanitize: 'boolean',
  4859. sanitizeFn: '(null|function)',
  4860. template: 'string'
  4861. };
  4862. const DefaultContentType = {
  4863. entry: '(string|element|function|null)',
  4864. selector: '(string|element)'
  4865. };
  4866. /**
  4867. * Class definition
  4868. */
  4869. class TemplateFactory extends Config {
  4870. constructor(config) {
  4871. super();
  4872. this._config = this._getConfig(config);
  4873. }
  4874. // Getters
  4875. static get Default() {
  4876. return Default$4;
  4877. }
  4878. static get DefaultType() {
  4879. return DefaultType$4;
  4880. }
  4881. static get NAME() {
  4882. return NAME$5;
  4883. }
  4884. // Public
  4885. getContent() {
  4886. return Object.values(this._config.content).map(config => this._resolvePossibleFunction(config)).filter(Boolean);
  4887. }
  4888. hasContent() {
  4889. return this.getContent().length > 0;
  4890. }
  4891. changeContent(content) {
  4892. this._checkContent(content);
  4893. this._config.content = {
  4894. ...this._config.content,
  4895. ...content
  4896. };
  4897. return this;
  4898. }
  4899. toHtml() {
  4900. const templateWrapper = document.createElement('div');
  4901. templateWrapper.innerHTML = this._maybeSanitize(this._config.template);
  4902. for (const [selector, text] of Object.entries(this._config.content)) {
  4903. this._setContent(templateWrapper, text, selector);
  4904. }
  4905. const template = templateWrapper.children[0];
  4906. const extraClass = this._resolvePossibleFunction(this._config.extraClass);
  4907. if (extraClass) {
  4908. template.classList.add(...extraClass.split(' '));
  4909. }
  4910. return template;
  4911. }
  4912. // Private
  4913. _typeCheckConfig(config) {
  4914. super._typeCheckConfig(config);
  4915. this._checkContent(config.content);
  4916. }
  4917. _checkContent(arg) {
  4918. for (const [selector, content] of Object.entries(arg)) {
  4919. super._typeCheckConfig({
  4920. selector,
  4921. entry: content
  4922. }, DefaultContentType);
  4923. }
  4924. }
  4925. _setContent(template, content, selector) {
  4926. const templateElement = SelectorEngine.findOne(selector, template);
  4927. if (!templateElement) {
  4928. return;
  4929. }
  4930. content = this._resolvePossibleFunction(content);
  4931. if (!content) {
  4932. templateElement.remove();
  4933. return;
  4934. }
  4935. if (isElement$1(content)) {
  4936. this._putElementInTemplate(getElement(content), templateElement);
  4937. return;
  4938. }
  4939. if (this._config.html) {
  4940. templateElement.innerHTML = this._maybeSanitize(content);
  4941. return;
  4942. }
  4943. templateElement.textContent = content;
  4944. }
  4945. _maybeSanitize(arg) {
  4946. return this._config.sanitize ? sanitizeHtml(arg, this._config.allowList, this._config.sanitizeFn) : arg;
  4947. }
  4948. _resolvePossibleFunction(arg) {
  4949. return execute(arg, [undefined, this]);
  4950. }
  4951. _putElementInTemplate(element, templateElement) {
  4952. if (this._config.html) {
  4953. templateElement.innerHTML = '';
  4954. templateElement.append(element);
  4955. return;
  4956. }
  4957. templateElement.textContent = element.textContent;
  4958. }
  4959. }
  4960. /**
  4961. * --------------------------------------------------------------------------
  4962. * Bootstrap tooltip.js
  4963. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  4964. * --------------------------------------------------------------------------
  4965. */
  4966. /**
  4967. * Constants
  4968. */
  4969. const NAME$4 = 'tooltip';
  4970. const DISALLOWED_ATTRIBUTES = new Set(['sanitize', 'allowList', 'sanitizeFn']);
  4971. const CLASS_NAME_FADE$2 = 'fade';
  4972. const CLASS_NAME_MODAL = 'modal';
  4973. const CLASS_NAME_SHOW$2 = 'show';
  4974. const SELECTOR_TOOLTIP_INNER = '.tooltip-inner';
  4975. const SELECTOR_MODAL = `.${CLASS_NAME_MODAL}`;
  4976. const EVENT_MODAL_HIDE = 'hide.bs.modal';
  4977. const TRIGGER_HOVER = 'hover';
  4978. const TRIGGER_FOCUS = 'focus';
  4979. const TRIGGER_CLICK = 'click';
  4980. const TRIGGER_MANUAL = 'manual';
  4981. const EVENT_HIDE$2 = 'hide';
  4982. const EVENT_HIDDEN$2 = 'hidden';
  4983. const EVENT_SHOW$2 = 'show';
  4984. const EVENT_SHOWN$2 = 'shown';
  4985. const EVENT_INSERTED = 'inserted';
  4986. const EVENT_CLICK$1 = 'click';
  4987. const EVENT_FOCUSIN$1 = 'focusin';
  4988. const EVENT_FOCUSOUT$1 = 'focusout';
  4989. const EVENT_MOUSEENTER = 'mouseenter';
  4990. const EVENT_MOUSELEAVE = 'mouseleave';
  4991. const AttachmentMap = {
  4992. AUTO: 'auto',
  4993. TOP: 'top',
  4994. RIGHT: isRTL() ? 'left' : 'right',
  4995. BOTTOM: 'bottom',
  4996. LEFT: isRTL() ? 'right' : 'left'
  4997. };
  4998. const Default$3 = {
  4999. allowList: DefaultAllowlist,
  5000. animation: true,
  5001. boundary: 'clippingParents',
  5002. container: false,
  5003. customClass: '',
  5004. delay: 0,
  5005. fallbackPlacements: ['top', 'right', 'bottom', 'left'],
  5006. html: false,
  5007. offset: [0, 6],
  5008. placement: 'top',
  5009. popperConfig: null,
  5010. sanitize: true,
  5011. sanitizeFn: null,
  5012. selector: false,
  5013. template: '<div class="tooltip" role="tooltip">' + '<div class="tooltip-arrow"></div>' + '<div class="tooltip-inner"></div>' + '</div>',
  5014. title: '',
  5015. trigger: 'hover focus'
  5016. };
  5017. const DefaultType$3 = {
  5018. allowList: 'object',
  5019. animation: 'boolean',
  5020. boundary: '(string|element)',
  5021. container: '(string|element|boolean)',
  5022. customClass: '(string|function)',
  5023. delay: '(number|object)',
  5024. fallbackPlacements: 'array',
  5025. html: 'boolean',
  5026. offset: '(array|string|function)',
  5027. placement: '(string|function)',
  5028. popperConfig: '(null|object|function)',
  5029. sanitize: 'boolean',
  5030. sanitizeFn: '(null|function)',
  5031. selector: '(string|boolean)',
  5032. template: 'string',
  5033. title: '(string|element|function)',
  5034. trigger: 'string'
  5035. };
  5036. /**
  5037. * Class definition
  5038. */
  5039. class Tooltip extends BaseComponent {
  5040. constructor(element, config) {
  5041. if (typeof Popper === 'undefined') {
  5042. throw new TypeError('Bootstrap\'s tooltips require Popper (https://popper.js.org/docs/v2/)');
  5043. }
  5044. super(element, config);
  5045. // Private
  5046. this._isEnabled = true;
  5047. this._timeout = 0;
  5048. this._isHovered = null;
  5049. this._activeTrigger = {};
  5050. this._popper = null;
  5051. this._templateFactory = null;
  5052. this._newContent = null;
  5053. // Protected
  5054. this.tip = null;
  5055. this._setListeners();
  5056. if (!this._config.selector) {
  5057. this._fixTitle();
  5058. }
  5059. }
  5060. // Getters
  5061. static get Default() {
  5062. return Default$3;
  5063. }
  5064. static get DefaultType() {
  5065. return DefaultType$3;
  5066. }
  5067. static get NAME() {
  5068. return NAME$4;
  5069. }
  5070. // Public
  5071. enable() {
  5072. this._isEnabled = true;
  5073. }
  5074. disable() {
  5075. this._isEnabled = false;
  5076. }
  5077. toggleEnabled() {
  5078. this._isEnabled = !this._isEnabled;
  5079. }
  5080. toggle() {
  5081. if (!this._isEnabled) {
  5082. return;
  5083. }
  5084. if (this._isShown()) {
  5085. this._leave();
  5086. return;
  5087. }
  5088. this._enter();
  5089. }
  5090. dispose() {
  5091. clearTimeout(this._timeout);
  5092. EventHandler.off(this._element.closest(SELECTOR_MODAL), EVENT_MODAL_HIDE, this._hideModalHandler);
  5093. if (this._element.getAttribute('data-bs-original-title')) {
  5094. this._element.setAttribute('title', this._element.getAttribute('data-bs-original-title'));
  5095. }
  5096. this._disposePopper();
  5097. super.dispose();
  5098. }
  5099. show() {
  5100. if (this._element.style.display === 'none') {
  5101. throw new Error('Please use show on visible elements');
  5102. }
  5103. if (!(this._isWithContent() && this._isEnabled)) {
  5104. return;
  5105. }
  5106. const showEvent = EventHandler.trigger(this._element, this.constructor.eventName(EVENT_SHOW$2));
  5107. const shadowRoot = findShadowRoot(this._element);
  5108. const isInTheDom = (shadowRoot || this._element.ownerDocument.documentElement).contains(this._element);
  5109. if (showEvent.defaultPrevented || !isInTheDom) {
  5110. return;
  5111. }
  5112. // TODO: v6 remove this or make it optional
  5113. this._disposePopper();
  5114. const tip = this._getTipElement();
  5115. this._element.setAttribute('aria-describedby', tip.getAttribute('id'));
  5116. const {
  5117. container
  5118. } = this._config;
  5119. if (!this._element.ownerDocument.documentElement.contains(this.tip)) {
  5120. container.append(tip);
  5121. EventHandler.trigger(this._element, this.constructor.eventName(EVENT_INSERTED));
  5122. }
  5123. this._popper = this._createPopper(tip);
  5124. tip.classList.add(CLASS_NAME_SHOW$2);
  5125. // If this is a touch-enabled device we add extra
  5126. // empty mouseover listeners to the body's immediate children;
  5127. // only needed because of broken event delegation on iOS
  5128. // https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html
  5129. if ('ontouchstart' in document.documentElement) {
  5130. for (const element of [].concat(...document.body.children)) {
  5131. EventHandler.on(element, 'mouseover', noop);
  5132. }
  5133. }
  5134. const complete = () => {
  5135. EventHandler.trigger(this._element, this.constructor.eventName(EVENT_SHOWN$2));
  5136. if (this._isHovered === false) {
  5137. this._leave();
  5138. }
  5139. this._isHovered = false;
  5140. };
  5141. this._queueCallback(complete, this.tip, this._isAnimated());
  5142. }
  5143. hide() {
  5144. if (!this._isShown()) {
  5145. return;
  5146. }
  5147. const hideEvent = EventHandler.trigger(this._element, this.constructor.eventName(EVENT_HIDE$2));
  5148. if (hideEvent.defaultPrevented) {
  5149. return;
  5150. }
  5151. const tip = this._getTipElement();
  5152. tip.classList.remove(CLASS_NAME_SHOW$2);
  5153. // If this is a touch-enabled device we remove the extra
  5154. // empty mouseover listeners we added for iOS support
  5155. if ('ontouchstart' in document.documentElement) {
  5156. for (const element of [].concat(...document.body.children)) {
  5157. EventHandler.off(element, 'mouseover', noop);
  5158. }
  5159. }
  5160. this._activeTrigger[TRIGGER_CLICK] = false;
  5161. this._activeTrigger[TRIGGER_FOCUS] = false;
  5162. this._activeTrigger[TRIGGER_HOVER] = false;
  5163. this._isHovered = null; // it is a trick to support manual triggering
  5164. const complete = () => {
  5165. if (this._isWithActiveTrigger()) {
  5166. return;
  5167. }
  5168. if (!this._isHovered) {
  5169. this._disposePopper();
  5170. }
  5171. this._element.removeAttribute('aria-describedby');
  5172. EventHandler.trigger(this._element, this.constructor.eventName(EVENT_HIDDEN$2));
  5173. };
  5174. this._queueCallback(complete, this.tip, this._isAnimated());
  5175. }
  5176. update() {
  5177. if (this._popper) {
  5178. this._popper.update();
  5179. }
  5180. }
  5181. // Protected
  5182. _isWithContent() {
  5183. return Boolean(this._getTitle());
  5184. }
  5185. _getTipElement() {
  5186. if (!this.tip) {
  5187. this.tip = this._createTipElement(this._newContent || this._getContentForTemplate());
  5188. }
  5189. return this.tip;
  5190. }
  5191. _createTipElement(content) {
  5192. const tip = this._getTemplateFactory(content).toHtml();
  5193. // TODO: remove this check in v6
  5194. if (!tip) {
  5195. return null;
  5196. }
  5197. tip.classList.remove(CLASS_NAME_FADE$2, CLASS_NAME_SHOW$2);
  5198. // TODO: v6 the following can be achieved with CSS only
  5199. tip.classList.add(`bs-${this.constructor.NAME}-auto`);
  5200. const tipId = getUID(this.constructor.NAME).toString();
  5201. tip.setAttribute('id', tipId);
  5202. if (this._isAnimated()) {
  5203. tip.classList.add(CLASS_NAME_FADE$2);
  5204. }
  5205. return tip;
  5206. }
  5207. setContent(content) {
  5208. this._newContent = content;
  5209. if (this._isShown()) {
  5210. this._disposePopper();
  5211. this.show();
  5212. }
  5213. }
  5214. _getTemplateFactory(content) {
  5215. if (this._templateFactory) {
  5216. this._templateFactory.changeContent(content);
  5217. } else {
  5218. this._templateFactory = new TemplateFactory({
  5219. ...this._config,
  5220. // the `content` var has to be after `this._config`
  5221. // to override config.content in case of popover
  5222. content,
  5223. extraClass: this._resolvePossibleFunction(this._config.customClass)
  5224. });
  5225. }
  5226. return this._templateFactory;
  5227. }
  5228. _getContentForTemplate() {
  5229. return {
  5230. [SELECTOR_TOOLTIP_INNER]: this._getTitle()
  5231. };
  5232. }
  5233. _getTitle() {
  5234. return this._resolvePossibleFunction(this._config.title) || this._element.getAttribute('data-bs-original-title');
  5235. }
  5236. // Private
  5237. _initializeOnDelegatedTarget(event) {
  5238. return this.constructor.getOrCreateInstance(event.delegateTarget, this._getDelegateConfig());
  5239. }
  5240. _isAnimated() {
  5241. return this._config.animation || this.tip && this.tip.classList.contains(CLASS_NAME_FADE$2);
  5242. }
  5243. _isShown() {
  5244. return this.tip && this.tip.classList.contains(CLASS_NAME_SHOW$2);
  5245. }
  5246. _createPopper(tip) {
  5247. const placement = execute(this._config.placement, [this, tip, this._element]);
  5248. const attachment = AttachmentMap[placement.toUpperCase()];
  5249. return createPopper(this._element, tip, this._getPopperConfig(attachment));
  5250. }
  5251. _getOffset() {
  5252. const {
  5253. offset
  5254. } = this._config;
  5255. if (typeof offset === 'string') {
  5256. return offset.split(',').map(value => Number.parseInt(value, 10));
  5257. }
  5258. if (typeof offset === 'function') {
  5259. return popperData => offset(popperData, this._element);
  5260. }
  5261. return offset;
  5262. }
  5263. _resolvePossibleFunction(arg) {
  5264. return execute(arg, [this._element, this._element]);
  5265. }
  5266. _getPopperConfig(attachment) {
  5267. const defaultBsPopperConfig = {
  5268. placement: attachment,
  5269. modifiers: [{
  5270. name: 'flip',
  5271. options: {
  5272. fallbackPlacements: this._config.fallbackPlacements
  5273. }
  5274. }, {
  5275. name: 'offset',
  5276. options: {
  5277. offset: this._getOffset()
  5278. }
  5279. }, {
  5280. name: 'preventOverflow',
  5281. options: {
  5282. boundary: this._config.boundary
  5283. }
  5284. }, {
  5285. name: 'arrow',
  5286. options: {
  5287. element: `.${this.constructor.NAME}-arrow`
  5288. }
  5289. }, {
  5290. name: 'preSetPlacement',
  5291. enabled: true,
  5292. phase: 'beforeMain',
  5293. fn: data => {
  5294. // Pre-set Popper's placement attribute in order to read the arrow sizes properly.
  5295. // Otherwise, Popper mixes up the width and height dimensions since the initial arrow style is for top placement
  5296. this._getTipElement().setAttribute('data-popper-placement', data.state.placement);
  5297. }
  5298. }]
  5299. };
  5300. return {
  5301. ...defaultBsPopperConfig,
  5302. ...execute(this._config.popperConfig, [undefined, defaultBsPopperConfig])
  5303. };
  5304. }
  5305. _setListeners() {
  5306. const triggers = this._config.trigger.split(' ');
  5307. for (const trigger of triggers) {
  5308. if (trigger === 'click') {
  5309. EventHandler.on(this._element, this.constructor.eventName(EVENT_CLICK$1), this._config.selector, event => {
  5310. const context = this._initializeOnDelegatedTarget(event);
  5311. context._activeTrigger[TRIGGER_CLICK] = !(context._isShown() && context._activeTrigger[TRIGGER_CLICK]);
  5312. context.toggle();
  5313. });
  5314. } else if (trigger !== TRIGGER_MANUAL) {
  5315. const eventIn = trigger === TRIGGER_HOVER ? this.constructor.eventName(EVENT_MOUSEENTER) : this.constructor.eventName(EVENT_FOCUSIN$1);
  5316. const eventOut = trigger === TRIGGER_HOVER ? this.constructor.eventName(EVENT_MOUSELEAVE) : this.constructor.eventName(EVENT_FOCUSOUT$1);
  5317. EventHandler.on(this._element, eventIn, this._config.selector, event => {
  5318. const context = this._initializeOnDelegatedTarget(event);
  5319. context._activeTrigger[event.type === 'focusin' ? TRIGGER_FOCUS : TRIGGER_HOVER] = true;
  5320. context._enter();
  5321. });
  5322. EventHandler.on(this._element, eventOut, this._config.selector, event => {
  5323. const context = this._initializeOnDelegatedTarget(event);
  5324. context._activeTrigger[event.type === 'focusout' ? TRIGGER_FOCUS : TRIGGER_HOVER] = context._element.contains(event.relatedTarget);
  5325. context._leave();
  5326. });
  5327. }
  5328. }
  5329. this._hideModalHandler = () => {
  5330. if (this._element) {
  5331. this.hide();
  5332. }
  5333. };
  5334. EventHandler.on(this._element.closest(SELECTOR_MODAL), EVENT_MODAL_HIDE, this._hideModalHandler);
  5335. }
  5336. _fixTitle() {
  5337. const title = this._element.getAttribute('title');
  5338. if (!title) {
  5339. return;
  5340. }
  5341. if (!this._element.getAttribute('aria-label') && !this._element.textContent.trim()) {
  5342. this._element.setAttribute('aria-label', title);
  5343. }
  5344. this._element.setAttribute('data-bs-original-title', title); // DO NOT USE IT. Is only for backwards compatibility
  5345. this._element.removeAttribute('title');
  5346. }
  5347. _enter() {
  5348. if (this._isShown() || this._isHovered) {
  5349. this._isHovered = true;
  5350. return;
  5351. }
  5352. this._isHovered = true;
  5353. this._setTimeout(() => {
  5354. if (this._isHovered) {
  5355. this.show();
  5356. }
  5357. }, this._config.delay.show);
  5358. }
  5359. _leave() {
  5360. if (this._isWithActiveTrigger()) {
  5361. return;
  5362. }
  5363. this._isHovered = false;
  5364. this._setTimeout(() => {
  5365. if (!this._isHovered) {
  5366. this.hide();
  5367. }
  5368. }, this._config.delay.hide);
  5369. }
  5370. _setTimeout(handler, timeout) {
  5371. clearTimeout(this._timeout);
  5372. this._timeout = setTimeout(handler, timeout);
  5373. }
  5374. _isWithActiveTrigger() {
  5375. return Object.values(this._activeTrigger).includes(true);
  5376. }
  5377. _getConfig(config) {
  5378. const dataAttributes = Manipulator.getDataAttributes(this._element);
  5379. for (const dataAttribute of Object.keys(dataAttributes)) {
  5380. if (DISALLOWED_ATTRIBUTES.has(dataAttribute)) {
  5381. delete dataAttributes[dataAttribute];
  5382. }
  5383. }
  5384. config = {
  5385. ...dataAttributes,
  5386. ...(typeof config === 'object' && config ? config : {})
  5387. };
  5388. config = this._mergeConfigObj(config);
  5389. config = this._configAfterMerge(config);
  5390. this._typeCheckConfig(config);
  5391. return config;
  5392. }
  5393. _configAfterMerge(config) {
  5394. config.container = config.container === false ? document.body : getElement(config.container);
  5395. if (typeof config.delay === 'number') {
  5396. config.delay = {
  5397. show: config.delay,
  5398. hide: config.delay
  5399. };
  5400. }
  5401. if (typeof config.title === 'number') {
  5402. config.title = config.title.toString();
  5403. }
  5404. if (typeof config.content === 'number') {
  5405. config.content = config.content.toString();
  5406. }
  5407. return config;
  5408. }
  5409. _getDelegateConfig() {
  5410. const config = {};
  5411. for (const [key, value] of Object.entries(this._config)) {
  5412. if (this.constructor.Default[key] !== value) {
  5413. config[key] = value;
  5414. }
  5415. }
  5416. config.selector = false;
  5417. config.trigger = 'manual';
  5418. // In the future can be replaced with:
  5419. // const keysWithDifferentValues = Object.entries(this._config).filter(entry => this.constructor.Default[entry[0]] !== this._config[entry[0]])
  5420. // `Object.fromEntries(keysWithDifferentValues)`
  5421. return config;
  5422. }
  5423. _disposePopper() {
  5424. if (this._popper) {
  5425. this._popper.destroy();
  5426. this._popper = null;
  5427. }
  5428. if (this.tip) {
  5429. this.tip.remove();
  5430. this.tip = null;
  5431. }
  5432. }
  5433. // Static
  5434. static jQueryInterface(config) {
  5435. return this.each(function () {
  5436. const data = Tooltip.getOrCreateInstance(this, config);
  5437. if (typeof config !== 'string') {
  5438. return;
  5439. }
  5440. if (typeof data[config] === 'undefined') {
  5441. throw new TypeError(`No method named "${config}"`);
  5442. }
  5443. data[config]();
  5444. });
  5445. }
  5446. }
  5447. /**
  5448. * jQuery
  5449. */
  5450. defineJQueryPlugin(Tooltip);
  5451. /**
  5452. * --------------------------------------------------------------------------
  5453. * Bootstrap popover.js
  5454. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  5455. * --------------------------------------------------------------------------
  5456. */
  5457. /**
  5458. * Constants
  5459. */
  5460. const NAME$3 = 'popover';
  5461. const SELECTOR_TITLE = '.popover-header';
  5462. const SELECTOR_CONTENT = '.popover-body';
  5463. const Default$2 = {
  5464. ...Tooltip.Default,
  5465. content: '',
  5466. offset: [0, 8],
  5467. placement: 'right',
  5468. template: '<div class="popover" role="tooltip">' + '<div class="popover-arrow"></div>' + '<h3 class="popover-header"></h3>' + '<div class="popover-body"></div>' + '</div>',
  5469. trigger: 'click'
  5470. };
  5471. const DefaultType$2 = {
  5472. ...Tooltip.DefaultType,
  5473. content: '(null|string|element|function)'
  5474. };
  5475. /**
  5476. * Class definition
  5477. */
  5478. class Popover extends Tooltip {
  5479. // Getters
  5480. static get Default() {
  5481. return Default$2;
  5482. }
  5483. static get DefaultType() {
  5484. return DefaultType$2;
  5485. }
  5486. static get NAME() {
  5487. return NAME$3;
  5488. }
  5489. // Overrides
  5490. _isWithContent() {
  5491. return this._getTitle() || this._getContent();
  5492. }
  5493. // Private
  5494. _getContentForTemplate() {
  5495. return {
  5496. [SELECTOR_TITLE]: this._getTitle(),
  5497. [SELECTOR_CONTENT]: this._getContent()
  5498. };
  5499. }
  5500. _getContent() {
  5501. return this._resolvePossibleFunction(this._config.content);
  5502. }
  5503. // Static
  5504. static jQueryInterface(config) {
  5505. return this.each(function () {
  5506. const data = Popover.getOrCreateInstance(this, config);
  5507. if (typeof config !== 'string') {
  5508. return;
  5509. }
  5510. if (typeof data[config] === 'undefined') {
  5511. throw new TypeError(`No method named "${config}"`);
  5512. }
  5513. data[config]();
  5514. });
  5515. }
  5516. }
  5517. /**
  5518. * jQuery
  5519. */
  5520. defineJQueryPlugin(Popover);
  5521. /**
  5522. * --------------------------------------------------------------------------
  5523. * Bootstrap scrollspy.js
  5524. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  5525. * --------------------------------------------------------------------------
  5526. */
  5527. /**
  5528. * Constants
  5529. */
  5530. const NAME$2 = 'scrollspy';
  5531. const DATA_KEY$2 = 'bs.scrollspy';
  5532. const EVENT_KEY$2 = `.${DATA_KEY$2}`;
  5533. const DATA_API_KEY = '.data-api';
  5534. const EVENT_ACTIVATE = `activate${EVENT_KEY$2}`;
  5535. const EVENT_CLICK = `click${EVENT_KEY$2}`;
  5536. const EVENT_LOAD_DATA_API$1 = `load${EVENT_KEY$2}${DATA_API_KEY}`;
  5537. const CLASS_NAME_DROPDOWN_ITEM = 'dropdown-item';
  5538. const CLASS_NAME_ACTIVE$1 = 'active';
  5539. const SELECTOR_DATA_SPY = '[data-bs-spy="scroll"]';
  5540. const SELECTOR_TARGET_LINKS = '[href]';
  5541. const SELECTOR_NAV_LIST_GROUP = '.nav, .list-group';
  5542. const SELECTOR_NAV_LINKS = '.nav-link';
  5543. const SELECTOR_NAV_ITEMS = '.nav-item';
  5544. const SELECTOR_LIST_ITEMS = '.list-group-item';
  5545. const SELECTOR_LINK_ITEMS = `${SELECTOR_NAV_LINKS}, ${SELECTOR_NAV_ITEMS} > ${SELECTOR_NAV_LINKS}, ${SELECTOR_LIST_ITEMS}`;
  5546. const SELECTOR_DROPDOWN = '.dropdown';
  5547. const SELECTOR_DROPDOWN_TOGGLE$1 = '.dropdown-toggle';
  5548. const Default$1 = {
  5549. offset: null,
  5550. // TODO: v6 @deprecated, keep it for backwards compatibility reasons
  5551. rootMargin: '0px 0px -25%',
  5552. smoothScroll: false,
  5553. target: null,
  5554. threshold: [0.1, 0.5, 1]
  5555. };
  5556. const DefaultType$1 = {
  5557. offset: '(number|null)',
  5558. // TODO v6 @deprecated, keep it for backwards compatibility reasons
  5559. rootMargin: 'string',
  5560. smoothScroll: 'boolean',
  5561. target: 'element',
  5562. threshold: 'array'
  5563. };
  5564. /**
  5565. * Class definition
  5566. */
  5567. class ScrollSpy extends BaseComponent {
  5568. constructor(element, config) {
  5569. super(element, config);
  5570. // this._element is the observablesContainer and config.target the menu links wrapper
  5571. this._targetLinks = new Map();
  5572. this._observableSections = new Map();
  5573. this._rootElement = getComputedStyle(this._element).overflowY === 'visible' ? null : this._element;
  5574. this._activeTarget = null;
  5575. this._observer = null;
  5576. this._previousScrollData = {
  5577. visibleEntryTop: 0,
  5578. parentScrollTop: 0
  5579. };
  5580. this.refresh(); // initialize
  5581. }
  5582. // Getters
  5583. static get Default() {
  5584. return Default$1;
  5585. }
  5586. static get DefaultType() {
  5587. return DefaultType$1;
  5588. }
  5589. static get NAME() {
  5590. return NAME$2;
  5591. }
  5592. // Public
  5593. refresh() {
  5594. this._initializeTargetsAndObservables();
  5595. this._maybeEnableSmoothScroll();
  5596. if (this._observer) {
  5597. this._observer.disconnect();
  5598. } else {
  5599. this._observer = this._getNewObserver();
  5600. }
  5601. for (const section of this._observableSections.values()) {
  5602. this._observer.observe(section);
  5603. }
  5604. }
  5605. dispose() {
  5606. this._observer.disconnect();
  5607. super.dispose();
  5608. }
  5609. // Private
  5610. _configAfterMerge(config) {
  5611. // TODO: on v6 target should be given explicitly & remove the {target: 'ss-target'} case
  5612. config.target = getElement(config.target) || document.body;
  5613. // TODO: v6 Only for backwards compatibility reasons. Use rootMargin only
  5614. config.rootMargin = config.offset ? `${config.offset}px 0px -30%` : config.rootMargin;
  5615. if (typeof config.threshold === 'string') {
  5616. config.threshold = config.threshold.split(',').map(value => Number.parseFloat(value));
  5617. }
  5618. return config;
  5619. }
  5620. _maybeEnableSmoothScroll() {
  5621. if (!this._config.smoothScroll) {
  5622. return;
  5623. }
  5624. // unregister any previous listeners
  5625. EventHandler.off(this._config.target, EVENT_CLICK);
  5626. EventHandler.on(this._config.target, EVENT_CLICK, SELECTOR_TARGET_LINKS, event => {
  5627. const observableSection = this._observableSections.get(event.target.hash);
  5628. if (observableSection) {
  5629. event.preventDefault();
  5630. const root = this._rootElement || window;
  5631. const height = observableSection.offsetTop - this._element.offsetTop;
  5632. if (root.scrollTo) {
  5633. root.scrollTo({
  5634. top: height,
  5635. behavior: 'smooth'
  5636. });
  5637. return;
  5638. }
  5639. // Chrome 60 doesn't support `scrollTo`
  5640. root.scrollTop = height;
  5641. }
  5642. });
  5643. }
  5644. _getNewObserver() {
  5645. const options = {
  5646. root: this._rootElement,
  5647. threshold: this._config.threshold,
  5648. rootMargin: this._config.rootMargin
  5649. };
  5650. return new IntersectionObserver(entries => this._observerCallback(entries), options);
  5651. }
  5652. // The logic of selection
  5653. _observerCallback(entries) {
  5654. const targetElement = entry => this._targetLinks.get(`#${entry.target.id}`);
  5655. const activate = entry => {
  5656. this._previousScrollData.visibleEntryTop = entry.target.offsetTop;
  5657. this._process(targetElement(entry));
  5658. };
  5659. const parentScrollTop = (this._rootElement || document.documentElement).scrollTop;
  5660. const userScrollsDown = parentScrollTop >= this._previousScrollData.parentScrollTop;
  5661. this._previousScrollData.parentScrollTop = parentScrollTop;
  5662. for (const entry of entries) {
  5663. if (!entry.isIntersecting) {
  5664. this._activeTarget = null;
  5665. this._clearActiveClass(targetElement(entry));
  5666. continue;
  5667. }
  5668. const entryIsLowerThanPrevious = entry.target.offsetTop >= this._previousScrollData.visibleEntryTop;
  5669. // if we are scrolling down, pick the bigger offsetTop
  5670. if (userScrollsDown && entryIsLowerThanPrevious) {
  5671. activate(entry);
  5672. // if parent isn't scrolled, let's keep the first visible item, breaking the iteration
  5673. if (!parentScrollTop) {
  5674. return;
  5675. }
  5676. continue;
  5677. }
  5678. // if we are scrolling up, pick the smallest offsetTop
  5679. if (!userScrollsDown && !entryIsLowerThanPrevious) {
  5680. activate(entry);
  5681. }
  5682. }
  5683. }
  5684. _initializeTargetsAndObservables() {
  5685. this._targetLinks = new Map();
  5686. this._observableSections = new Map();
  5687. const targetLinks = SelectorEngine.find(SELECTOR_TARGET_LINKS, this._config.target);
  5688. for (const anchor of targetLinks) {
  5689. // ensure that the anchor has an id and is not disabled
  5690. if (!anchor.hash || isDisabled(anchor)) {
  5691. continue;
  5692. }
  5693. const observableSection = SelectorEngine.findOne(decodeURI(anchor.hash), this._element);
  5694. // ensure that the observableSection exists & is visible
  5695. if (isVisible(observableSection)) {
  5696. this._targetLinks.set(decodeURI(anchor.hash), anchor);
  5697. this._observableSections.set(anchor.hash, observableSection);
  5698. }
  5699. }
  5700. }
  5701. _process(target) {
  5702. if (this._activeTarget === target) {
  5703. return;
  5704. }
  5705. this._clearActiveClass(this._config.target);
  5706. this._activeTarget = target;
  5707. target.classList.add(CLASS_NAME_ACTIVE$1);
  5708. this._activateParents(target);
  5709. EventHandler.trigger(this._element, EVENT_ACTIVATE, {
  5710. relatedTarget: target
  5711. });
  5712. }
  5713. _activateParents(target) {
  5714. // Activate dropdown parents
  5715. if (target.classList.contains(CLASS_NAME_DROPDOWN_ITEM)) {
  5716. SelectorEngine.findOne(SELECTOR_DROPDOWN_TOGGLE$1, target.closest(SELECTOR_DROPDOWN)).classList.add(CLASS_NAME_ACTIVE$1);
  5717. return;
  5718. }
  5719. for (const listGroup of SelectorEngine.parents(target, SELECTOR_NAV_LIST_GROUP)) {
  5720. // Set triggered links parents as active
  5721. // With both <ul> and <nav> markup a parent is the previous sibling of any nav ancestor
  5722. for (const item of SelectorEngine.prev(listGroup, SELECTOR_LINK_ITEMS)) {
  5723. item.classList.add(CLASS_NAME_ACTIVE$1);
  5724. }
  5725. }
  5726. }
  5727. _clearActiveClass(parent) {
  5728. parent.classList.remove(CLASS_NAME_ACTIVE$1);
  5729. const activeNodes = SelectorEngine.find(`${SELECTOR_TARGET_LINKS}.${CLASS_NAME_ACTIVE$1}`, parent);
  5730. for (const node of activeNodes) {
  5731. node.classList.remove(CLASS_NAME_ACTIVE$1);
  5732. }
  5733. }
  5734. // Static
  5735. static jQueryInterface(config) {
  5736. return this.each(function () {
  5737. const data = ScrollSpy.getOrCreateInstance(this, config);
  5738. if (typeof config !== 'string') {
  5739. return;
  5740. }
  5741. if (data[config] === undefined || config.startsWith('_') || config === 'constructor') {
  5742. throw new TypeError(`No method named "${config}"`);
  5743. }
  5744. data[config]();
  5745. });
  5746. }
  5747. }
  5748. /**
  5749. * Data API implementation
  5750. */
  5751. EventHandler.on(window, EVENT_LOAD_DATA_API$1, () => {
  5752. for (const spy of SelectorEngine.find(SELECTOR_DATA_SPY)) {
  5753. ScrollSpy.getOrCreateInstance(spy);
  5754. }
  5755. });
  5756. /**
  5757. * jQuery
  5758. */
  5759. defineJQueryPlugin(ScrollSpy);
  5760. /**
  5761. * --------------------------------------------------------------------------
  5762. * Bootstrap tab.js
  5763. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  5764. * --------------------------------------------------------------------------
  5765. */
  5766. /**
  5767. * Constants
  5768. */
  5769. const NAME$1 = 'tab';
  5770. const DATA_KEY$1 = 'bs.tab';
  5771. const EVENT_KEY$1 = `.${DATA_KEY$1}`;
  5772. const EVENT_HIDE$1 = `hide${EVENT_KEY$1}`;
  5773. const EVENT_HIDDEN$1 = `hidden${EVENT_KEY$1}`;
  5774. const EVENT_SHOW$1 = `show${EVENT_KEY$1}`;
  5775. const EVENT_SHOWN$1 = `shown${EVENT_KEY$1}`;
  5776. const EVENT_CLICK_DATA_API = `click${EVENT_KEY$1}`;
  5777. const EVENT_KEYDOWN = `keydown${EVENT_KEY$1}`;
  5778. const EVENT_LOAD_DATA_API = `load${EVENT_KEY$1}`;
  5779. const ARROW_LEFT_KEY = 'ArrowLeft';
  5780. const ARROW_RIGHT_KEY = 'ArrowRight';
  5781. const ARROW_UP_KEY = 'ArrowUp';
  5782. const ARROW_DOWN_KEY = 'ArrowDown';
  5783. const HOME_KEY = 'Home';
  5784. const END_KEY = 'End';
  5785. const CLASS_NAME_ACTIVE = 'active';
  5786. const CLASS_NAME_FADE$1 = 'fade';
  5787. const CLASS_NAME_SHOW$1 = 'show';
  5788. const CLASS_DROPDOWN = 'dropdown';
  5789. const SELECTOR_DROPDOWN_TOGGLE = '.dropdown-toggle';
  5790. const SELECTOR_DROPDOWN_MENU = '.dropdown-menu';
  5791. const NOT_SELECTOR_DROPDOWN_TOGGLE = `:not(${SELECTOR_DROPDOWN_TOGGLE})`;
  5792. const SELECTOR_TAB_PANEL = '.list-group, .nav, [role="tablist"]';
  5793. const SELECTOR_OUTER = '.nav-item, .list-group-item';
  5794. const SELECTOR_INNER = `.nav-link${NOT_SELECTOR_DROPDOWN_TOGGLE}, .list-group-item${NOT_SELECTOR_DROPDOWN_TOGGLE}, [role="tab"]${NOT_SELECTOR_DROPDOWN_TOGGLE}`;
  5795. const SELECTOR_DATA_TOGGLE = '[data-bs-toggle="tab"], [data-bs-toggle="pill"], [data-bs-toggle="list"]'; // TODO: could only be `tab` in v6
  5796. const SELECTOR_INNER_ELEM = `${SELECTOR_INNER}, ${SELECTOR_DATA_TOGGLE}`;
  5797. 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"]`;
  5798. /**
  5799. * Class definition
  5800. */
  5801. class Tab extends BaseComponent {
  5802. constructor(element) {
  5803. super(element);
  5804. this._parent = this._element.closest(SELECTOR_TAB_PANEL);
  5805. if (!this._parent) {
  5806. return;
  5807. // TODO: should throw exception in v6
  5808. // throw new TypeError(`${element.outerHTML} has not a valid parent ${SELECTOR_INNER_ELEM}`)
  5809. }
  5810. // Set up initial aria attributes
  5811. this._setInitialAttributes(this._parent, this._getChildren());
  5812. EventHandler.on(this._element, EVENT_KEYDOWN, event => this._keydown(event));
  5813. }
  5814. // Getters
  5815. static get NAME() {
  5816. return NAME$1;
  5817. }
  5818. // Public
  5819. show() {
  5820. // Shows this elem and deactivate the active sibling if exists
  5821. const innerElem = this._element;
  5822. if (this._elemIsActive(innerElem)) {
  5823. return;
  5824. }
  5825. // Search for active tab on same parent to deactivate it
  5826. const active = this._getActiveElem();
  5827. const hideEvent = active ? EventHandler.trigger(active, EVENT_HIDE$1, {
  5828. relatedTarget: innerElem
  5829. }) : null;
  5830. const showEvent = EventHandler.trigger(innerElem, EVENT_SHOW$1, {
  5831. relatedTarget: active
  5832. });
  5833. if (showEvent.defaultPrevented || hideEvent && hideEvent.defaultPrevented) {
  5834. return;
  5835. }
  5836. this._deactivate(active, innerElem);
  5837. this._activate(innerElem, active);
  5838. }
  5839. // Private
  5840. _activate(element, relatedElem) {
  5841. if (!element) {
  5842. return;
  5843. }
  5844. element.classList.add(CLASS_NAME_ACTIVE);
  5845. this._activate(SelectorEngine.getElementFromSelector(element)); // Search and activate/show the proper section
  5846. const complete = () => {
  5847. if (element.getAttribute('role') !== 'tab') {
  5848. element.classList.add(CLASS_NAME_SHOW$1);
  5849. return;
  5850. }
  5851. element.removeAttribute('tabindex');
  5852. element.setAttribute('aria-selected', true);
  5853. this._toggleDropDown(element, true);
  5854. EventHandler.trigger(element, EVENT_SHOWN$1, {
  5855. relatedTarget: relatedElem
  5856. });
  5857. };
  5858. this._queueCallback(complete, element, element.classList.contains(CLASS_NAME_FADE$1));
  5859. }
  5860. _deactivate(element, relatedElem) {
  5861. if (!element) {
  5862. return;
  5863. }
  5864. element.classList.remove(CLASS_NAME_ACTIVE);
  5865. element.blur();
  5866. this._deactivate(SelectorEngine.getElementFromSelector(element)); // Search and deactivate the shown section too
  5867. const complete = () => {
  5868. if (element.getAttribute('role') !== 'tab') {
  5869. element.classList.remove(CLASS_NAME_SHOW$1);
  5870. return;
  5871. }
  5872. element.setAttribute('aria-selected', false);
  5873. element.setAttribute('tabindex', '-1');
  5874. this._toggleDropDown(element, false);
  5875. EventHandler.trigger(element, EVENT_HIDDEN$1, {
  5876. relatedTarget: relatedElem
  5877. });
  5878. };
  5879. this._queueCallback(complete, element, element.classList.contains(CLASS_NAME_FADE$1));
  5880. }
  5881. _keydown(event) {
  5882. if (![ARROW_LEFT_KEY, ARROW_RIGHT_KEY, ARROW_UP_KEY, ARROW_DOWN_KEY, HOME_KEY, END_KEY].includes(event.key)) {
  5883. return;
  5884. }
  5885. event.stopPropagation(); // stopPropagation/preventDefault both added to support up/down keys without scrolling the page
  5886. event.preventDefault();
  5887. const children = this._getChildren().filter(element => !isDisabled(element));
  5888. let nextActiveElement;
  5889. if ([HOME_KEY, END_KEY].includes(event.key)) {
  5890. nextActiveElement = children[event.key === HOME_KEY ? 0 : children.length - 1];
  5891. } else {
  5892. const isNext = [ARROW_RIGHT_KEY, ARROW_DOWN_KEY].includes(event.key);
  5893. nextActiveElement = getNextActiveElement(children, event.target, isNext, true);
  5894. }
  5895. if (nextActiveElement) {
  5896. nextActiveElement.focus({
  5897. preventScroll: true
  5898. });
  5899. Tab.getOrCreateInstance(nextActiveElement).show();
  5900. }
  5901. }
  5902. _getChildren() {
  5903. // collection of inner elements
  5904. return SelectorEngine.find(SELECTOR_INNER_ELEM, this._parent);
  5905. }
  5906. _getActiveElem() {
  5907. return this._getChildren().find(child => this._elemIsActive(child)) || null;
  5908. }
  5909. _setInitialAttributes(parent, children) {
  5910. this._setAttributeIfNotExists(parent, 'role', 'tablist');
  5911. for (const child of children) {
  5912. this._setInitialAttributesOnChild(child);
  5913. }
  5914. }
  5915. _setInitialAttributesOnChild(child) {
  5916. child = this._getInnerElement(child);
  5917. const isActive = this._elemIsActive(child);
  5918. const outerElem = this._getOuterElement(child);
  5919. child.setAttribute('aria-selected', isActive);
  5920. if (outerElem !== child) {
  5921. this._setAttributeIfNotExists(outerElem, 'role', 'presentation');
  5922. }
  5923. if (!isActive) {
  5924. child.setAttribute('tabindex', '-1');
  5925. }
  5926. this._setAttributeIfNotExists(child, 'role', 'tab');
  5927. // set attributes to the related panel too
  5928. this._setInitialAttributesOnTargetPanel(child);
  5929. }
  5930. _setInitialAttributesOnTargetPanel(child) {
  5931. const target = SelectorEngine.getElementFromSelector(child);
  5932. if (!target) {
  5933. return;
  5934. }
  5935. this._setAttributeIfNotExists(target, 'role', 'tabpanel');
  5936. if (child.id) {
  5937. this._setAttributeIfNotExists(target, 'aria-labelledby', `${child.id}`);
  5938. }
  5939. }
  5940. _toggleDropDown(element, open) {
  5941. const outerElem = this._getOuterElement(element);
  5942. if (!outerElem.classList.contains(CLASS_DROPDOWN)) {
  5943. return;
  5944. }
  5945. const toggle = (selector, className) => {
  5946. const element = SelectorEngine.findOne(selector, outerElem);
  5947. if (element) {
  5948. element.classList.toggle(className, open);
  5949. }
  5950. };
  5951. toggle(SELECTOR_DROPDOWN_TOGGLE, CLASS_NAME_ACTIVE);
  5952. toggle(SELECTOR_DROPDOWN_MENU, CLASS_NAME_SHOW$1);
  5953. outerElem.setAttribute('aria-expanded', open);
  5954. }
  5955. _setAttributeIfNotExists(element, attribute, value) {
  5956. if (!element.hasAttribute(attribute)) {
  5957. element.setAttribute(attribute, value);
  5958. }
  5959. }
  5960. _elemIsActive(elem) {
  5961. return elem.classList.contains(CLASS_NAME_ACTIVE);
  5962. }
  5963. // Try to get the inner element (usually the .nav-link)
  5964. _getInnerElement(elem) {
  5965. return elem.matches(SELECTOR_INNER_ELEM) ? elem : SelectorEngine.findOne(SELECTOR_INNER_ELEM, elem);
  5966. }
  5967. // Try to get the outer element (usually the .nav-item)
  5968. _getOuterElement(elem) {
  5969. return elem.closest(SELECTOR_OUTER) || elem;
  5970. }
  5971. // Static
  5972. static jQueryInterface(config) {
  5973. return this.each(function () {
  5974. const data = Tab.getOrCreateInstance(this);
  5975. if (typeof config !== 'string') {
  5976. return;
  5977. }
  5978. if (data[config] === undefined || config.startsWith('_') || config === 'constructor') {
  5979. throw new TypeError(`No method named "${config}"`);
  5980. }
  5981. data[config]();
  5982. });
  5983. }
  5984. }
  5985. /**
  5986. * Data API implementation
  5987. */
  5988. EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, function (event) {
  5989. if (['A', 'AREA'].includes(this.tagName)) {
  5990. event.preventDefault();
  5991. }
  5992. if (isDisabled(this)) {
  5993. return;
  5994. }
  5995. Tab.getOrCreateInstance(this).show();
  5996. });
  5997. /**
  5998. * Initialize on focus
  5999. */
  6000. EventHandler.on(window, EVENT_LOAD_DATA_API, () => {
  6001. for (const element of SelectorEngine.find(SELECTOR_DATA_TOGGLE_ACTIVE)) {
  6002. Tab.getOrCreateInstance(element);
  6003. }
  6004. });
  6005. /**
  6006. * jQuery
  6007. */
  6008. defineJQueryPlugin(Tab);
  6009. /**
  6010. * --------------------------------------------------------------------------
  6011. * Bootstrap toast.js
  6012. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  6013. * --------------------------------------------------------------------------
  6014. */
  6015. /**
  6016. * Constants
  6017. */
  6018. const NAME = 'toast';
  6019. const DATA_KEY = 'bs.toast';
  6020. const EVENT_KEY = `.${DATA_KEY}`;
  6021. const EVENT_MOUSEOVER = `mouseover${EVENT_KEY}`;
  6022. const EVENT_MOUSEOUT = `mouseout${EVENT_KEY}`;
  6023. const EVENT_FOCUSIN = `focusin${EVENT_KEY}`;
  6024. const EVENT_FOCUSOUT = `focusout${EVENT_KEY}`;
  6025. const EVENT_HIDE = `hide${EVENT_KEY}`;
  6026. const EVENT_HIDDEN = `hidden${EVENT_KEY}`;
  6027. const EVENT_SHOW = `show${EVENT_KEY}`;
  6028. const EVENT_SHOWN = `shown${EVENT_KEY}`;
  6029. const CLASS_NAME_FADE = 'fade';
  6030. const CLASS_NAME_HIDE = 'hide'; // @deprecated - kept here only for backwards compatibility
  6031. const CLASS_NAME_SHOW = 'show';
  6032. const CLASS_NAME_SHOWING = 'showing';
  6033. const DefaultType = {
  6034. animation: 'boolean',
  6035. autohide: 'boolean',
  6036. delay: 'number'
  6037. };
  6038. const Default = {
  6039. animation: true,
  6040. autohide: true,
  6041. delay: 5000
  6042. };
  6043. /**
  6044. * Class definition
  6045. */
  6046. class Toast extends BaseComponent {
  6047. constructor(element, config) {
  6048. super(element, config);
  6049. this._timeout = null;
  6050. this._hasMouseInteraction = false;
  6051. this._hasKeyboardInteraction = false;
  6052. this._setListeners();
  6053. }
  6054. // Getters
  6055. static get Default() {
  6056. return Default;
  6057. }
  6058. static get DefaultType() {
  6059. return DefaultType;
  6060. }
  6061. static get NAME() {
  6062. return NAME;
  6063. }
  6064. // Public
  6065. show() {
  6066. const showEvent = EventHandler.trigger(this._element, EVENT_SHOW);
  6067. if (showEvent.defaultPrevented) {
  6068. return;
  6069. }
  6070. this._clearTimeout();
  6071. if (this._config.animation) {
  6072. this._element.classList.add(CLASS_NAME_FADE);
  6073. }
  6074. const complete = () => {
  6075. this._element.classList.remove(CLASS_NAME_SHOWING);
  6076. EventHandler.trigger(this._element, EVENT_SHOWN);
  6077. this._maybeScheduleHide();
  6078. };
  6079. this._element.classList.remove(CLASS_NAME_HIDE); // @deprecated
  6080. reflow(this._element);
  6081. this._element.classList.add(CLASS_NAME_SHOW, CLASS_NAME_SHOWING);
  6082. this._queueCallback(complete, this._element, this._config.animation);
  6083. }
  6084. hide() {
  6085. if (!this.isShown()) {
  6086. return;
  6087. }
  6088. const hideEvent = EventHandler.trigger(this._element, EVENT_HIDE);
  6089. if (hideEvent.defaultPrevented) {
  6090. return;
  6091. }
  6092. const complete = () => {
  6093. this._element.classList.add(CLASS_NAME_HIDE); // @deprecated
  6094. this._element.classList.remove(CLASS_NAME_SHOWING, CLASS_NAME_SHOW);
  6095. EventHandler.trigger(this._element, EVENT_HIDDEN);
  6096. };
  6097. this._element.classList.add(CLASS_NAME_SHOWING);
  6098. this._queueCallback(complete, this._element, this._config.animation);
  6099. }
  6100. dispose() {
  6101. this._clearTimeout();
  6102. if (this.isShown()) {
  6103. this._element.classList.remove(CLASS_NAME_SHOW);
  6104. }
  6105. super.dispose();
  6106. }
  6107. isShown() {
  6108. return this._element.classList.contains(CLASS_NAME_SHOW);
  6109. }
  6110. // Private
  6111. _maybeScheduleHide() {
  6112. if (!this._config.autohide) {
  6113. return;
  6114. }
  6115. if (this._hasMouseInteraction || this._hasKeyboardInteraction) {
  6116. return;
  6117. }
  6118. this._timeout = setTimeout(() => {
  6119. this.hide();
  6120. }, this._config.delay);
  6121. }
  6122. _onInteraction(event, isInteracting) {
  6123. switch (event.type) {
  6124. case 'mouseover':
  6125. case 'mouseout':
  6126. {
  6127. this._hasMouseInteraction = isInteracting;
  6128. break;
  6129. }
  6130. case 'focusin':
  6131. case 'focusout':
  6132. {
  6133. this._hasKeyboardInteraction = isInteracting;
  6134. break;
  6135. }
  6136. }
  6137. if (isInteracting) {
  6138. this._clearTimeout();
  6139. return;
  6140. }
  6141. const nextElement = event.relatedTarget;
  6142. if (this._element === nextElement || this._element.contains(nextElement)) {
  6143. return;
  6144. }
  6145. this._maybeScheduleHide();
  6146. }
  6147. _setListeners() {
  6148. EventHandler.on(this._element, EVENT_MOUSEOVER, event => this._onInteraction(event, true));
  6149. EventHandler.on(this._element, EVENT_MOUSEOUT, event => this._onInteraction(event, false));
  6150. EventHandler.on(this._element, EVENT_FOCUSIN, event => this._onInteraction(event, true));
  6151. EventHandler.on(this._element, EVENT_FOCUSOUT, event => this._onInteraction(event, false));
  6152. }
  6153. _clearTimeout() {
  6154. clearTimeout(this._timeout);
  6155. this._timeout = null;
  6156. }
  6157. // Static
  6158. static jQueryInterface(config) {
  6159. return this.each(function () {
  6160. const data = Toast.getOrCreateInstance(this, config);
  6161. if (typeof config === 'string') {
  6162. if (typeof data[config] === 'undefined') {
  6163. throw new TypeError(`No method named "${config}"`);
  6164. }
  6165. data[config](this);
  6166. }
  6167. });
  6168. }
  6169. }
  6170. /**
  6171. * Data API implementation
  6172. */
  6173. enableDismissTrigger(Toast);
  6174. /**
  6175. * jQuery
  6176. */
  6177. defineJQueryPlugin(Toast);
  6178. /**
  6179. * --------------------------------------------------------------------------
  6180. * Bootstrap index.umd.js
  6181. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  6182. * --------------------------------------------------------------------------
  6183. */
  6184. const index_umd = {
  6185. Alert,
  6186. Button,
  6187. Carousel,
  6188. Collapse,
  6189. Dropdown,
  6190. Modal,
  6191. Offcanvas,
  6192. Popover,
  6193. ScrollSpy,
  6194. Tab,
  6195. Toast,
  6196. Tooltip
  6197. };
  6198. return index_umd;
  6199. }));
  6200. //# sourceMappingURL=bootstrap.bundle.js.map
  6201. /*!
  6202. GSAP
  6203. Version: 3.13.0
  6204. Plugin URL: https://gsap.com
  6205. License: Copyright 2025, 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
  6206. !*/
  6207. (function (global, factory) {
  6208. typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
  6209. typeof define === 'function' && define.amd ? define(['exports'], factory) :
  6210. (global = global || self, factory(global.window = global.window || {}));
  6211. }(this, (function (exports) { 'use strict';
  6212. function _inheritsLoose(subClass, superClass) {
  6213. subClass.prototype = Object.create(superClass.prototype);
  6214. subClass.prototype.constructor = subClass;
  6215. subClass.__proto__ = superClass;
  6216. }
  6217. function _assertThisInitialized(self) {
  6218. if (self === void 0) {
  6219. throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
  6220. }
  6221. return self;
  6222. }
  6223. /*!
  6224. * GSAP 3.13.0
  6225. * https://gsap.com
  6226. *
  6227. * @license Copyright 2008-2025, GreenSock. All rights reserved.
  6228. * Subject to the terms at https://gsap.com/standard-license
  6229. * @author: Jack Doyle, jack@greensock.com
  6230. */
  6231. var _config = {
  6232. autoSleep: 120,
  6233. force3D: "auto",
  6234. nullTargetWarn: 1,
  6235. units: {
  6236. lineHeight: ""
  6237. }
  6238. },
  6239. _defaults = {
  6240. duration: .5,
  6241. overwrite: false,
  6242. delay: 0
  6243. },
  6244. _suppressOverwrites,
  6245. _reverting,
  6246. _context,
  6247. _bigNum = 1e8,
  6248. _tinyNum = 1 / _bigNum,
  6249. _2PI = Math.PI * 2,
  6250. _HALF_PI = _2PI / 4,
  6251. _gsID = 0,
  6252. _sqrt = Math.sqrt,
  6253. _cos = Math.cos,
  6254. _sin = Math.sin,
  6255. _isString = function _isString(value) {
  6256. return typeof value === "string";
  6257. },
  6258. _isFunction = function _isFunction(value) {
  6259. return typeof value === "function";
  6260. },
  6261. _isNumber = function _isNumber(value) {
  6262. return typeof value === "number";
  6263. },
  6264. _isUndefined = function _isUndefined(value) {
  6265. return typeof value === "undefined";
  6266. },
  6267. _isObject = function _isObject(value) {
  6268. return typeof value === "object";
  6269. },
  6270. _isNotFalse = function _isNotFalse(value) {
  6271. return value !== false;
  6272. },
  6273. _windowExists = function _windowExists() {
  6274. return typeof window !== "undefined";
  6275. },
  6276. _isFuncOrString = function _isFuncOrString(value) {
  6277. return _isFunction(value) || _isString(value);
  6278. },
  6279. _isTypedArray = typeof ArrayBuffer === "function" && ArrayBuffer.isView || function () {},
  6280. _isArray = Array.isArray,
  6281. _strictNumExp = /(?:-?\.?\d|\.)+/gi,
  6282. _numExp = /[-+=.]*\d+[.e\-+]*\d*[e\-+]*\d*/g,
  6283. _numWithUnitExp = /[-+=.]*\d+[.e-]*\d*[a-z%]*/g,
  6284. _complexStringNumExp = /[-+=.]*\d+\.?\d*(?:e-|e\+)?\d*/gi,
  6285. _relExp = /[+-]=-?[.\d]+/,
  6286. _delimitedValueExp = /[^,'"\[\]\s]+/gi,
  6287. _unitExp = /^[+\-=e\s\d]*\d+[.\d]*([a-z]*|%)\s*$/i,
  6288. _globalTimeline,
  6289. _win,
  6290. _coreInitted,
  6291. _doc,
  6292. _globals = {},
  6293. _installScope = {},
  6294. _coreReady,
  6295. _install = function _install(scope) {
  6296. return (_installScope = _merge(scope, _globals)) && gsap;
  6297. },
  6298. _missingPlugin = function _missingPlugin(property, value) {
  6299. return console.warn("Invalid property", property, "set to", value, "Missing plugin? gsap.registerPlugin()");
  6300. },
  6301. _warn = function _warn(message, suppress) {
  6302. return !suppress && console.warn(message);
  6303. },
  6304. _addGlobal = function _addGlobal(name, obj) {
  6305. return name && (_globals[name] = obj) && _installScope && (_installScope[name] = obj) || _globals;
  6306. },
  6307. _emptyFunc = function _emptyFunc() {
  6308. return 0;
  6309. },
  6310. _startAtRevertConfig = {
  6311. suppressEvents: true,
  6312. isStart: true,
  6313. kill: false
  6314. },
  6315. _revertConfigNoKill = {
  6316. suppressEvents: true,
  6317. kill: false
  6318. },
  6319. _revertConfig = {
  6320. suppressEvents: true
  6321. },
  6322. _reservedProps = {},
  6323. _lazyTweens = [],
  6324. _lazyLookup = {},
  6325. _lastRenderedFrame,
  6326. _plugins = {},
  6327. _effects = {},
  6328. _nextGCFrame = 30,
  6329. _harnessPlugins = [],
  6330. _callbackNames = "",
  6331. _harness = function _harness(targets) {
  6332. var target = targets[0],
  6333. harnessPlugin,
  6334. i;
  6335. _isObject(target) || _isFunction(target) || (targets = [targets]);
  6336. if (!(harnessPlugin = (target._gsap || {}).harness)) {
  6337. i = _harnessPlugins.length;
  6338. while (i-- && !_harnessPlugins[i].targetTest(target)) {}
  6339. harnessPlugin = _harnessPlugins[i];
  6340. }
  6341. i = targets.length;
  6342. while (i--) {
  6343. targets[i] && (targets[i]._gsap || (targets[i]._gsap = new GSCache(targets[i], harnessPlugin))) || targets.splice(i, 1);
  6344. }
  6345. return targets;
  6346. },
  6347. _getCache = function _getCache(target) {
  6348. return target._gsap || _harness(toArray(target))[0]._gsap;
  6349. },
  6350. _getProperty = function _getProperty(target, property, v) {
  6351. return (v = target[property]) && _isFunction(v) ? target[property]() : _isUndefined(v) && target.getAttribute && target.getAttribute(property) || v;
  6352. },
  6353. _forEachName = function _forEachName(names, func) {
  6354. return (names = names.split(",")).forEach(func) || names;
  6355. },
  6356. _round = function _round(value) {
  6357. return Math.round(value * 100000) / 100000 || 0;
  6358. },
  6359. _roundPrecise = function _roundPrecise(value) {
  6360. return Math.round(value * 10000000) / 10000000 || 0;
  6361. },
  6362. _parseRelative = function _parseRelative(start, value) {
  6363. var operator = value.charAt(0),
  6364. end = parseFloat(value.substr(2));
  6365. start = parseFloat(start);
  6366. return operator === "+" ? start + end : operator === "-" ? start - end : operator === "*" ? start * end : start / end;
  6367. },
  6368. _arrayContainsAny = function _arrayContainsAny(toSearch, toFind) {
  6369. var l = toFind.length,
  6370. i = 0;
  6371. for (; toSearch.indexOf(toFind[i]) < 0 && ++i < l;) {}
  6372. return i < l;
  6373. },
  6374. _lazyRender = function _lazyRender() {
  6375. var l = _lazyTweens.length,
  6376. a = _lazyTweens.slice(0),
  6377. i,
  6378. tween;
  6379. _lazyLookup = {};
  6380. _lazyTweens.length = 0;
  6381. for (i = 0; i < l; i++) {
  6382. tween = a[i];
  6383. tween && tween._lazy && (tween.render(tween._lazy[0], tween._lazy[1], true)._lazy = 0);
  6384. }
  6385. },
  6386. _isRevertWorthy = function _isRevertWorthy(animation) {
  6387. return !!(animation._initted || animation._startAt || animation.add);
  6388. },
  6389. _lazySafeRender = function _lazySafeRender(animation, time, suppressEvents, force) {
  6390. _lazyTweens.length && !_reverting && _lazyRender();
  6391. animation.render(time, suppressEvents, force || !!(_reverting && time < 0 && _isRevertWorthy(animation)));
  6392. _lazyTweens.length && !_reverting && _lazyRender();
  6393. },
  6394. _numericIfPossible = function _numericIfPossible(value) {
  6395. var n = parseFloat(value);
  6396. return (n || n === 0) && (value + "").match(_delimitedValueExp).length < 2 ? n : _isString(value) ? value.trim() : value;
  6397. },
  6398. _passThrough = function _passThrough(p) {
  6399. return p;
  6400. },
  6401. _setDefaults = function _setDefaults(obj, defaults) {
  6402. for (var p in defaults) {
  6403. p in obj || (obj[p] = defaults[p]);
  6404. }
  6405. return obj;
  6406. },
  6407. _setKeyframeDefaults = function _setKeyframeDefaults(excludeDuration) {
  6408. return function (obj, defaults) {
  6409. for (var p in defaults) {
  6410. p in obj || p === "duration" && excludeDuration || p === "ease" || (obj[p] = defaults[p]);
  6411. }
  6412. };
  6413. },
  6414. _merge = function _merge(base, toMerge) {
  6415. for (var p in toMerge) {
  6416. base[p] = toMerge[p];
  6417. }
  6418. return base;
  6419. },
  6420. _mergeDeep = function _mergeDeep(base, toMerge) {
  6421. for (var p in toMerge) {
  6422. p !== "__proto__" && p !== "constructor" && p !== "prototype" && (base[p] = _isObject(toMerge[p]) ? _mergeDeep(base[p] || (base[p] = {}), toMerge[p]) : toMerge[p]);
  6423. }
  6424. return base;
  6425. },
  6426. _copyExcluding = function _copyExcluding(obj, excluding) {
  6427. var copy = {},
  6428. p;
  6429. for (p in obj) {
  6430. p in excluding || (copy[p] = obj[p]);
  6431. }
  6432. return copy;
  6433. },
  6434. _inheritDefaults = function _inheritDefaults(vars) {
  6435. var parent = vars.parent || _globalTimeline,
  6436. func = vars.keyframes ? _setKeyframeDefaults(_isArray(vars.keyframes)) : _setDefaults;
  6437. if (_isNotFalse(vars.inherit)) {
  6438. while (parent) {
  6439. func(vars, parent.vars.defaults);
  6440. parent = parent.parent || parent._dp;
  6441. }
  6442. }
  6443. return vars;
  6444. },
  6445. _arraysMatch = function _arraysMatch(a1, a2) {
  6446. var i = a1.length,
  6447. match = i === a2.length;
  6448. while (match && i-- && a1[i] === a2[i]) {}
  6449. return i < 0;
  6450. },
  6451. _addLinkedListItem = function _addLinkedListItem(parent, child, firstProp, lastProp, sortBy) {
  6452. if (firstProp === void 0) {
  6453. firstProp = "_first";
  6454. }
  6455. if (lastProp === void 0) {
  6456. lastProp = "_last";
  6457. }
  6458. var prev = parent[lastProp],
  6459. t;
  6460. if (sortBy) {
  6461. t = child[sortBy];
  6462. while (prev && prev[sortBy] > t) {
  6463. prev = prev._prev;
  6464. }
  6465. }
  6466. if (prev) {
  6467. child._next = prev._next;
  6468. prev._next = child;
  6469. } else {
  6470. child._next = parent[firstProp];
  6471. parent[firstProp] = child;
  6472. }
  6473. if (child._next) {
  6474. child._next._prev = child;
  6475. } else {
  6476. parent[lastProp] = child;
  6477. }
  6478. child._prev = prev;
  6479. child.parent = child._dp = parent;
  6480. return child;
  6481. },
  6482. _removeLinkedListItem = function _removeLinkedListItem(parent, child, firstProp, lastProp) {
  6483. if (firstProp === void 0) {
  6484. firstProp = "_first";
  6485. }
  6486. if (lastProp === void 0) {
  6487. lastProp = "_last";
  6488. }
  6489. var prev = child._prev,
  6490. next = child._next;
  6491. if (prev) {
  6492. prev._next = next;
  6493. } else if (parent[firstProp] === child) {
  6494. parent[firstProp] = next;
  6495. }
  6496. if (next) {
  6497. next._prev = prev;
  6498. } else if (parent[lastProp] === child) {
  6499. parent[lastProp] = prev;
  6500. }
  6501. child._next = child._prev = child.parent = null;
  6502. },
  6503. _removeFromParent = function _removeFromParent(child, onlyIfParentHasAutoRemove) {
  6504. child.parent && (!onlyIfParentHasAutoRemove || child.parent.autoRemoveChildren) && child.parent.remove && child.parent.remove(child);
  6505. child._act = 0;
  6506. },
  6507. _uncache = function _uncache(animation, child) {
  6508. if (animation && (!child || child._end > animation._dur || child._start < 0)) {
  6509. var a = animation;
  6510. while (a) {
  6511. a._dirty = 1;
  6512. a = a.parent;
  6513. }
  6514. }
  6515. return animation;
  6516. },
  6517. _recacheAncestors = function _recacheAncestors(animation) {
  6518. var parent = animation.parent;
  6519. while (parent && parent.parent) {
  6520. parent._dirty = 1;
  6521. parent.totalDuration();
  6522. parent = parent.parent;
  6523. }
  6524. return animation;
  6525. },
  6526. _rewindStartAt = function _rewindStartAt(tween, totalTime, suppressEvents, force) {
  6527. return tween._startAt && (_reverting ? tween._startAt.revert(_revertConfigNoKill) : tween.vars.immediateRender && !tween.vars.autoRevert || tween._startAt.render(totalTime, true, force));
  6528. },
  6529. _hasNoPausedAncestors = function _hasNoPausedAncestors(animation) {
  6530. return !animation || animation._ts && _hasNoPausedAncestors(animation.parent);
  6531. },
  6532. _elapsedCycleDuration = function _elapsedCycleDuration(animation) {
  6533. return animation._repeat ? _animationCycle(animation._tTime, animation = animation.duration() + animation._rDelay) * animation : 0;
  6534. },
  6535. _animationCycle = function _animationCycle(tTime, cycleDuration) {
  6536. var whole = Math.floor(tTime = _roundPrecise(tTime / cycleDuration));
  6537. return tTime && whole === tTime ? whole - 1 : whole;
  6538. },
  6539. _parentToChildTotalTime = function _parentToChildTotalTime(parentTime, child) {
  6540. return (parentTime - child._start) * child._ts + (child._ts >= 0 ? 0 : child._dirty ? child.totalDuration() : child._tDur);
  6541. },
  6542. _setEnd = function _setEnd(animation) {
  6543. return animation._end = _roundPrecise(animation._start + (animation._tDur / Math.abs(animation._ts || animation._rts || _tinyNum) || 0));
  6544. },
  6545. _alignPlayhead = function _alignPlayhead(animation, totalTime) {
  6546. var parent = animation._dp;
  6547. if (parent && parent.smoothChildTiming && animation._ts) {
  6548. animation._start = _roundPrecise(parent._time - (animation._ts > 0 ? totalTime / animation._ts : ((animation._dirty ? animation.totalDuration() : animation._tDur) - totalTime) / -animation._ts));
  6549. _setEnd(animation);
  6550. parent._dirty || _uncache(parent, animation);
  6551. }
  6552. return animation;
  6553. },
  6554. _postAddChecks = function _postAddChecks(timeline, child) {
  6555. var t;
  6556. if (child._time || !child._dur && child._initted || child._start < timeline._time && (child._dur || !child.add)) {
  6557. t = _parentToChildTotalTime(timeline.rawTime(), child);
  6558. if (!child._dur || _clamp(0, child.totalDuration(), t) - child._tTime > _tinyNum) {
  6559. child.render(t, true);
  6560. }
  6561. }
  6562. if (_uncache(timeline, child)._dp && timeline._initted && timeline._time >= timeline._dur && timeline._ts) {
  6563. if (timeline._dur < timeline.duration()) {
  6564. t = timeline;
  6565. while (t._dp) {
  6566. t.rawTime() >= 0 && t.totalTime(t._tTime);
  6567. t = t._dp;
  6568. }
  6569. }
  6570. timeline._zTime = -_tinyNum;
  6571. }
  6572. },
  6573. _addToTimeline = function _addToTimeline(timeline, child, position, skipChecks) {
  6574. child.parent && _removeFromParent(child);
  6575. child._start = _roundPrecise((_isNumber(position) ? position : position || timeline !== _globalTimeline ? _parsePosition(timeline, position, child) : timeline._time) + child._delay);
  6576. child._end = _roundPrecise(child._start + (child.totalDuration() / Math.abs(child.timeScale()) || 0));
  6577. _addLinkedListItem(timeline, child, "_first", "_last", timeline._sort ? "_start" : 0);
  6578. _isFromOrFromStart(child) || (timeline._recent = child);
  6579. skipChecks || _postAddChecks(timeline, child);
  6580. timeline._ts < 0 && _alignPlayhead(timeline, timeline._tTime);
  6581. return timeline;
  6582. },
  6583. _scrollTrigger = function _scrollTrigger(animation, trigger) {
  6584. return (_globals.ScrollTrigger || _missingPlugin("scrollTrigger", trigger)) && _globals.ScrollTrigger.create(trigger, animation);
  6585. },
  6586. _attemptInitTween = function _attemptInitTween(tween, time, force, suppressEvents, tTime) {
  6587. _initTween(tween, time, tTime);
  6588. if (!tween._initted) {
  6589. return 1;
  6590. }
  6591. if (!force && tween._pt && !_reverting && (tween._dur && tween.vars.lazy !== false || !tween._dur && tween.vars.lazy) && _lastRenderedFrame !== _ticker.frame) {
  6592. _lazyTweens.push(tween);
  6593. tween._lazy = [tTime, suppressEvents];
  6594. return 1;
  6595. }
  6596. },
  6597. _parentPlayheadIsBeforeStart = function _parentPlayheadIsBeforeStart(_ref) {
  6598. var parent = _ref.parent;
  6599. return parent && parent._ts && parent._initted && !parent._lock && (parent.rawTime() < 0 || _parentPlayheadIsBeforeStart(parent));
  6600. },
  6601. _isFromOrFromStart = function _isFromOrFromStart(_ref2) {
  6602. var data = _ref2.data;
  6603. return data === "isFromStart" || data === "isStart";
  6604. },
  6605. _renderZeroDurationTween = function _renderZeroDurationTween(tween, totalTime, suppressEvents, force) {
  6606. var prevRatio = tween.ratio,
  6607. ratio = totalTime < 0 || !totalTime && (!tween._start && _parentPlayheadIsBeforeStart(tween) && !(!tween._initted && _isFromOrFromStart(tween)) || (tween._ts < 0 || tween._dp._ts < 0) && !_isFromOrFromStart(tween)) ? 0 : 1,
  6608. repeatDelay = tween._rDelay,
  6609. tTime = 0,
  6610. pt,
  6611. iteration,
  6612. prevIteration;
  6613. if (repeatDelay && tween._repeat) {
  6614. tTime = _clamp(0, tween._tDur, totalTime);
  6615. iteration = _animationCycle(tTime, repeatDelay);
  6616. tween._yoyo && iteration & 1 && (ratio = 1 - ratio);
  6617. if (iteration !== _animationCycle(tween._tTime, repeatDelay)) {
  6618. prevRatio = 1 - ratio;
  6619. tween.vars.repeatRefresh && tween._initted && tween.invalidate();
  6620. }
  6621. }
  6622. if (ratio !== prevRatio || _reverting || force || tween._zTime === _tinyNum || !totalTime && tween._zTime) {
  6623. if (!tween._initted && _attemptInitTween(tween, totalTime, force, suppressEvents, tTime)) {
  6624. return;
  6625. }
  6626. prevIteration = tween._zTime;
  6627. tween._zTime = totalTime || (suppressEvents ? _tinyNum : 0);
  6628. suppressEvents || (suppressEvents = totalTime && !prevIteration);
  6629. tween.ratio = ratio;
  6630. tween._from && (ratio = 1 - ratio);
  6631. tween._time = 0;
  6632. tween._tTime = tTime;
  6633. pt = tween._pt;
  6634. while (pt) {
  6635. pt.r(ratio, pt.d);
  6636. pt = pt._next;
  6637. }
  6638. totalTime < 0 && _rewindStartAt(tween, totalTime, suppressEvents, true);
  6639. tween._onUpdate && !suppressEvents && _callback(tween, "onUpdate");
  6640. tTime && tween._repeat && !suppressEvents && tween.parent && _callback(tween, "onRepeat");
  6641. if ((totalTime >= tween._tDur || totalTime < 0) && tween.ratio === ratio) {
  6642. ratio && _removeFromParent(tween, 1);
  6643. if (!suppressEvents && !_reverting) {
  6644. _callback(tween, ratio ? "onComplete" : "onReverseComplete", true);
  6645. tween._prom && tween._prom();
  6646. }
  6647. }
  6648. } else if (!tween._zTime) {
  6649. tween._zTime = totalTime;
  6650. }
  6651. },
  6652. _findNextPauseTween = function _findNextPauseTween(animation, prevTime, time) {
  6653. var child;
  6654. if (time > prevTime) {
  6655. child = animation._first;
  6656. while (child && child._start <= time) {
  6657. if (child.data === "isPause" && child._start > prevTime) {
  6658. return child;
  6659. }
  6660. child = child._next;
  6661. }
  6662. } else {
  6663. child = animation._last;
  6664. while (child && child._start >= time) {
  6665. if (child.data === "isPause" && child._start < prevTime) {
  6666. return child;
  6667. }
  6668. child = child._prev;
  6669. }
  6670. }
  6671. },
  6672. _setDuration = function _setDuration(animation, duration, skipUncache, leavePlayhead) {
  6673. var repeat = animation._repeat,
  6674. dur = _roundPrecise(duration) || 0,
  6675. totalProgress = animation._tTime / animation._tDur;
  6676. totalProgress && !leavePlayhead && (animation._time *= dur / animation._dur);
  6677. animation._dur = dur;
  6678. animation._tDur = !repeat ? dur : repeat < 0 ? 1e10 : _roundPrecise(dur * (repeat + 1) + animation._rDelay * repeat);
  6679. totalProgress > 0 && !leavePlayhead && _alignPlayhead(animation, animation._tTime = animation._tDur * totalProgress);
  6680. animation.parent && _setEnd(animation);
  6681. skipUncache || _uncache(animation.parent, animation);
  6682. return animation;
  6683. },
  6684. _onUpdateTotalDuration = function _onUpdateTotalDuration(animation) {
  6685. return animation instanceof Timeline ? _uncache(animation) : _setDuration(animation, animation._dur);
  6686. },
  6687. _zeroPosition = {
  6688. _start: 0,
  6689. endTime: _emptyFunc,
  6690. totalDuration: _emptyFunc
  6691. },
  6692. _parsePosition = function _parsePosition(animation, position, percentAnimation) {
  6693. var labels = animation.labels,
  6694. recent = animation._recent || _zeroPosition,
  6695. clippedDuration = animation.duration() >= _bigNum ? recent.endTime(false) : animation._dur,
  6696. i,
  6697. offset,
  6698. isPercent;
  6699. if (_isString(position) && (isNaN(position) || position in labels)) {
  6700. offset = position.charAt(0);
  6701. isPercent = position.substr(-1) === "%";
  6702. i = position.indexOf("=");
  6703. if (offset === "<" || offset === ">") {
  6704. i >= 0 && (position = position.replace(/=/, ""));
  6705. return (offset === "<" ? recent._start : recent.endTime(recent._repeat >= 0)) + (parseFloat(position.substr(1)) || 0) * (isPercent ? (i < 0 ? recent : percentAnimation).totalDuration() / 100 : 1);
  6706. }
  6707. if (i < 0) {
  6708. position in labels || (labels[position] = clippedDuration);
  6709. return labels[position];
  6710. }
  6711. offset = parseFloat(position.charAt(i - 1) + position.substr(i + 1));
  6712. if (isPercent && percentAnimation) {
  6713. offset = offset / 100 * (_isArray(percentAnimation) ? percentAnimation[0] : percentAnimation).totalDuration();
  6714. }
  6715. return i > 1 ? _parsePosition(animation, position.substr(0, i - 1), percentAnimation) + offset : clippedDuration + offset;
  6716. }
  6717. return position == null ? clippedDuration : +position;
  6718. },
  6719. _createTweenType = function _createTweenType(type, params, timeline) {
  6720. var isLegacy = _isNumber(params[1]),
  6721. varsIndex = (isLegacy ? 2 : 1) + (type < 2 ? 0 : 1),
  6722. vars = params[varsIndex],
  6723. irVars,
  6724. parent;
  6725. isLegacy && (vars.duration = params[1]);
  6726. vars.parent = timeline;
  6727. if (type) {
  6728. irVars = vars;
  6729. parent = timeline;
  6730. while (parent && !("immediateRender" in irVars)) {
  6731. irVars = parent.vars.defaults || {};
  6732. parent = _isNotFalse(parent.vars.inherit) && parent.parent;
  6733. }
  6734. vars.immediateRender = _isNotFalse(irVars.immediateRender);
  6735. type < 2 ? vars.runBackwards = 1 : vars.startAt = params[varsIndex - 1];
  6736. }
  6737. return new Tween(params[0], vars, params[varsIndex + 1]);
  6738. },
  6739. _conditionalReturn = function _conditionalReturn(value, func) {
  6740. return value || value === 0 ? func(value) : func;
  6741. },
  6742. _clamp = function _clamp(min, max, value) {
  6743. return value < min ? min : value > max ? max : value;
  6744. },
  6745. getUnit = function getUnit(value, v) {
  6746. return !_isString(value) || !(v = _unitExp.exec(value)) ? "" : v[1];
  6747. },
  6748. clamp = function clamp(min, max, value) {
  6749. return _conditionalReturn(value, function (v) {
  6750. return _clamp(min, max, v);
  6751. });
  6752. },
  6753. _slice = [].slice,
  6754. _isArrayLike = function _isArrayLike(value, nonEmpty) {
  6755. return value && _isObject(value) && "length" in value && (!nonEmpty && !value.length || value.length - 1 in value && _isObject(value[0])) && !value.nodeType && value !== _win;
  6756. },
  6757. _flatten = function _flatten(ar, leaveStrings, accumulator) {
  6758. if (accumulator === void 0) {
  6759. accumulator = [];
  6760. }
  6761. return ar.forEach(function (value) {
  6762. var _accumulator;
  6763. return _isString(value) && !leaveStrings || _isArrayLike(value, 1) ? (_accumulator = accumulator).push.apply(_accumulator, toArray(value)) : accumulator.push(value);
  6764. }) || accumulator;
  6765. },
  6766. toArray = function toArray(value, scope, leaveStrings) {
  6767. 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] : [];
  6768. },
  6769. selector = function selector(value) {
  6770. value = toArray(value)[0] || _warn("Invalid scope") || {};
  6771. return function (v) {
  6772. var el = value.current || value.nativeElement || value;
  6773. return toArray(v, el.querySelectorAll ? el : el === value ? _warn("Invalid scope") || _doc.createElement("div") : value);
  6774. };
  6775. },
  6776. shuffle = function shuffle(a) {
  6777. return a.sort(function () {
  6778. return .5 - Math.random();
  6779. });
  6780. },
  6781. distribute = function distribute(v) {
  6782. if (_isFunction(v)) {
  6783. return v;
  6784. }
  6785. var vars = _isObject(v) ? v : {
  6786. each: v
  6787. },
  6788. ease = _parseEase(vars.ease),
  6789. from = vars.from || 0,
  6790. base = parseFloat(vars.base) || 0,
  6791. cache = {},
  6792. isDecimal = from > 0 && from < 1,
  6793. ratios = isNaN(from) || isDecimal,
  6794. axis = vars.axis,
  6795. ratioX = from,
  6796. ratioY = from;
  6797. if (_isString(from)) {
  6798. ratioX = ratioY = {
  6799. center: .5,
  6800. edges: .5,
  6801. end: 1
  6802. }[from] || 0;
  6803. } else if (!isDecimal && ratios) {
  6804. ratioX = from[0];
  6805. ratioY = from[1];
  6806. }
  6807. return function (i, target, a) {
  6808. var l = (a || vars).length,
  6809. distances = cache[l],
  6810. originX,
  6811. originY,
  6812. x,
  6813. y,
  6814. d,
  6815. j,
  6816. max,
  6817. min,
  6818. wrapAt;
  6819. if (!distances) {
  6820. wrapAt = vars.grid === "auto" ? 0 : (vars.grid || [1, _bigNum])[1];
  6821. if (!wrapAt) {
  6822. max = -_bigNum;
  6823. while (max < (max = a[wrapAt++].getBoundingClientRect().left) && wrapAt < l) {}
  6824. wrapAt < l && wrapAt--;
  6825. }
  6826. distances = cache[l] = [];
  6827. originX = ratios ? Math.min(wrapAt, l) * ratioX - .5 : from % wrapAt;
  6828. originY = wrapAt === _bigNum ? 0 : ratios ? l * ratioY / wrapAt - .5 : from / wrapAt | 0;
  6829. max = 0;
  6830. min = _bigNum;
  6831. for (j = 0; j < l; j++) {
  6832. x = j % wrapAt - originX;
  6833. y = originY - (j / wrapAt | 0);
  6834. distances[j] = d = !axis ? _sqrt(x * x + y * y) : Math.abs(axis === "y" ? y : x);
  6835. d > max && (max = d);
  6836. d < min && (min = d);
  6837. }
  6838. from === "random" && shuffle(distances);
  6839. distances.max = max - min;
  6840. distances.min = min;
  6841. 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);
  6842. distances.b = l < 0 ? base - l : base;
  6843. distances.u = getUnit(vars.amount || vars.each) || 0;
  6844. ease = ease && l < 0 ? _invertEase(ease) : ease;
  6845. }
  6846. l = (distances[i] - distances.min) / distances.max || 0;
  6847. return _roundPrecise(distances.b + (ease ? ease(l) : l) * distances.v) + distances.u;
  6848. };
  6849. },
  6850. _roundModifier = function _roundModifier(v) {
  6851. var p = Math.pow(10, ((v + "").split(".")[1] || "").length);
  6852. return function (raw) {
  6853. var n = _roundPrecise(Math.round(parseFloat(raw) / v) * v * p);
  6854. return (n - n % 1) / p + (_isNumber(raw) ? 0 : getUnit(raw));
  6855. };
  6856. },
  6857. snap = function snap(snapTo, value) {
  6858. var isArray = _isArray(snapTo),
  6859. radius,
  6860. is2D;
  6861. if (!isArray && _isObject(snapTo)) {
  6862. radius = isArray = snapTo.radius || _bigNum;
  6863. if (snapTo.values) {
  6864. snapTo = toArray(snapTo.values);
  6865. if (is2D = !_isNumber(snapTo[0])) {
  6866. radius *= radius;
  6867. }
  6868. } else {
  6869. snapTo = _roundModifier(snapTo.increment);
  6870. }
  6871. }
  6872. return _conditionalReturn(value, !isArray ? _roundModifier(snapTo) : _isFunction(snapTo) ? function (raw) {
  6873. is2D = snapTo(raw);
  6874. return Math.abs(is2D - raw) <= radius ? is2D : raw;
  6875. } : function (raw) {
  6876. var x = parseFloat(is2D ? raw.x : raw),
  6877. y = parseFloat(is2D ? raw.y : 0),
  6878. min = _bigNum,
  6879. closest = 0,
  6880. i = snapTo.length,
  6881. dx,
  6882. dy;
  6883. while (i--) {
  6884. if (is2D) {
  6885. dx = snapTo[i].x - x;
  6886. dy = snapTo[i].y - y;
  6887. dx = dx * dx + dy * dy;
  6888. } else {
  6889. dx = Math.abs(snapTo[i] - x);
  6890. }
  6891. if (dx < min) {
  6892. min = dx;
  6893. closest = i;
  6894. }
  6895. }
  6896. closest = !radius || min <= radius ? snapTo[closest] : raw;
  6897. return is2D || closest === raw || _isNumber(raw) ? closest : closest + getUnit(raw);
  6898. });
  6899. },
  6900. random = function random(min, max, roundingIncrement, returnFunction) {
  6901. return _conditionalReturn(_isArray(min) ? !max : roundingIncrement === true ? !!(roundingIncrement = 0) : !returnFunction, function () {
  6902. 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;
  6903. });
  6904. },
  6905. pipe = function pipe() {
  6906. for (var _len = arguments.length, functions = new Array(_len), _key = 0; _key < _len; _key++) {
  6907. functions[_key] = arguments[_key];
  6908. }
  6909. return function (value) {
  6910. return functions.reduce(function (v, f) {
  6911. return f(v);
  6912. }, value);
  6913. };
  6914. },
  6915. unitize = function unitize(func, unit) {
  6916. return function (value) {
  6917. return func(parseFloat(value)) + (unit || getUnit(value));
  6918. };
  6919. },
  6920. normalize = function normalize(min, max, value) {
  6921. return mapRange(min, max, 0, 1, value);
  6922. },
  6923. _wrapArray = function _wrapArray(a, wrapper, value) {
  6924. return _conditionalReturn(value, function (index) {
  6925. return a[~~wrapper(index)];
  6926. });
  6927. },
  6928. wrap = function wrap(min, max, value) {
  6929. var range = max - min;
  6930. return _isArray(min) ? _wrapArray(min, wrap(0, min.length), max) : _conditionalReturn(value, function (value) {
  6931. return (range + (value - min) % range) % range + min;
  6932. });
  6933. },
  6934. wrapYoyo = function wrapYoyo(min, max, value) {
  6935. var range = max - min,
  6936. total = range * 2;
  6937. return _isArray(min) ? _wrapArray(min, wrapYoyo(0, min.length - 1), max) : _conditionalReturn(value, function (value) {
  6938. value = (total + (value - min) % total) % total || 0;
  6939. return min + (value > range ? total - value : value);
  6940. });
  6941. },
  6942. _replaceRandom = function _replaceRandom(value) {
  6943. var prev = 0,
  6944. s = "",
  6945. i,
  6946. nums,
  6947. end,
  6948. isArray;
  6949. while (~(i = value.indexOf("random(", prev))) {
  6950. end = value.indexOf(")", i);
  6951. isArray = value.charAt(i + 7) === "[";
  6952. nums = value.substr(i + 7, end - i - 7).match(isArray ? _delimitedValueExp : _strictNumExp);
  6953. s += value.substr(prev, i - prev) + random(isArray ? nums : +nums[0], isArray ? 0 : +nums[1], +nums[2] || 1e-5);
  6954. prev = end + 1;
  6955. }
  6956. return s + value.substr(prev, value.length - prev);
  6957. },
  6958. mapRange = function mapRange(inMin, inMax, outMin, outMax, value) {
  6959. var inRange = inMax - inMin,
  6960. outRange = outMax - outMin;
  6961. return _conditionalReturn(value, function (value) {
  6962. return outMin + ((value - inMin) / inRange * outRange || 0);
  6963. });
  6964. },
  6965. interpolate = function interpolate(start, end, progress, mutate) {
  6966. var func = isNaN(start + end) ? 0 : function (p) {
  6967. return (1 - p) * start + p * end;
  6968. };
  6969. if (!func) {
  6970. var isString = _isString(start),
  6971. master = {},
  6972. p,
  6973. i,
  6974. interpolators,
  6975. l,
  6976. il;
  6977. progress === true && (mutate = 1) && (progress = null);
  6978. if (isString) {
  6979. start = {
  6980. p: start
  6981. };
  6982. end = {
  6983. p: end
  6984. };
  6985. } else if (_isArray(start) && !_isArray(end)) {
  6986. interpolators = [];
  6987. l = start.length;
  6988. il = l - 2;
  6989. for (i = 1; i < l; i++) {
  6990. interpolators.push(interpolate(start[i - 1], start[i]));
  6991. }
  6992. l--;
  6993. func = function func(p) {
  6994. p *= l;
  6995. var i = Math.min(il, ~~p);
  6996. return interpolators[i](p - i);
  6997. };
  6998. progress = end;
  6999. } else if (!mutate) {
  7000. start = _merge(_isArray(start) ? [] : {}, start);
  7001. }
  7002. if (!interpolators) {
  7003. for (p in end) {
  7004. _addPropTween.call(master, start, p, "get", end[p]);
  7005. }
  7006. func = function func(p) {
  7007. return _renderPropTweens(p, master) || (isString ? start.p : start);
  7008. };
  7009. }
  7010. }
  7011. return _conditionalReturn(progress, func);
  7012. },
  7013. _getLabelInDirection = function _getLabelInDirection(timeline, fromTime, backward) {
  7014. var labels = timeline.labels,
  7015. min = _bigNum,
  7016. p,
  7017. distance,
  7018. label;
  7019. for (p in labels) {
  7020. distance = labels[p] - fromTime;
  7021. if (distance < 0 === !!backward && distance && min > (distance = Math.abs(distance))) {
  7022. label = p;
  7023. min = distance;
  7024. }
  7025. }
  7026. return label;
  7027. },
  7028. _callback = function _callback(animation, type, executeLazyFirst) {
  7029. var v = animation.vars,
  7030. callback = v[type],
  7031. prevContext = _context,
  7032. context = animation._ctx,
  7033. params,
  7034. scope,
  7035. result;
  7036. if (!callback) {
  7037. return;
  7038. }
  7039. params = v[type + "Params"];
  7040. scope = v.callbackScope || animation;
  7041. executeLazyFirst && _lazyTweens.length && _lazyRender();
  7042. context && (_context = context);
  7043. result = params ? callback.apply(scope, params) : callback.call(scope);
  7044. _context = prevContext;
  7045. return result;
  7046. },
  7047. _interrupt = function _interrupt(animation) {
  7048. _removeFromParent(animation);
  7049. animation.scrollTrigger && animation.scrollTrigger.kill(!!_reverting);
  7050. animation.progress() < 1 && _callback(animation, "onInterrupt");
  7051. return animation;
  7052. },
  7053. _quickTween,
  7054. _registerPluginQueue = [],
  7055. _createPlugin = function _createPlugin(config) {
  7056. if (!config) return;
  7057. config = !config.name && config["default"] || config;
  7058. if (_windowExists() || config.headless) {
  7059. var name = config.name,
  7060. isFunc = _isFunction(config),
  7061. Plugin = name && !isFunc && config.init ? function () {
  7062. this._props = [];
  7063. } : config,
  7064. instanceDefaults = {
  7065. init: _emptyFunc,
  7066. render: _renderPropTweens,
  7067. add: _addPropTween,
  7068. kill: _killPropTweensOf,
  7069. modifier: _addPluginModifier,
  7070. rawVars: 0
  7071. },
  7072. statics = {
  7073. targetTest: 0,
  7074. get: 0,
  7075. getSetter: _getSetter,
  7076. aliases: {},
  7077. register: 0
  7078. };
  7079. _wake();
  7080. if (config !== Plugin) {
  7081. if (_plugins[name]) {
  7082. return;
  7083. }
  7084. _setDefaults(Plugin, _setDefaults(_copyExcluding(config, instanceDefaults), statics));
  7085. _merge(Plugin.prototype, _merge(instanceDefaults, _copyExcluding(config, statics)));
  7086. _plugins[Plugin.prop = name] = Plugin;
  7087. if (config.targetTest) {
  7088. _harnessPlugins.push(Plugin);
  7089. _reservedProps[name] = 1;
  7090. }
  7091. name = (name === "css" ? "CSS" : name.charAt(0).toUpperCase() + name.substr(1)) + "Plugin";
  7092. }
  7093. _addGlobal(name, Plugin);
  7094. config.register && config.register(gsap, Plugin, PropTween);
  7095. } else {
  7096. _registerPluginQueue.push(config);
  7097. }
  7098. },
  7099. _255 = 255,
  7100. _colorLookup = {
  7101. aqua: [0, _255, _255],
  7102. lime: [0, _255, 0],
  7103. silver: [192, 192, 192],
  7104. black: [0, 0, 0],
  7105. maroon: [128, 0, 0],
  7106. teal: [0, 128, 128],
  7107. blue: [0, 0, _255],
  7108. navy: [0, 0, 128],
  7109. white: [_255, _255, _255],
  7110. olive: [128, 128, 0],
  7111. yellow: [_255, _255, 0],
  7112. orange: [_255, 165, 0],
  7113. gray: [128, 128, 128],
  7114. purple: [128, 0, 128],
  7115. green: [0, 128, 0],
  7116. red: [_255, 0, 0],
  7117. pink: [_255, 192, 203],
  7118. cyan: [0, _255, _255],
  7119. transparent: [_255, _255, _255, 0]
  7120. },
  7121. _hue = function _hue(h, m1, m2) {
  7122. h += h < 0 ? 1 : h > 1 ? -1 : 0;
  7123. 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;
  7124. },
  7125. splitColor = function splitColor(v, toHSL, forceAlpha) {
  7126. var a = !v ? _colorLookup.black : _isNumber(v) ? [v >> 16, v >> 8 & _255, v & _255] : 0,
  7127. r,
  7128. g,
  7129. b,
  7130. h,
  7131. s,
  7132. l,
  7133. max,
  7134. min,
  7135. d,
  7136. wasHSL;
  7137. if (!a) {
  7138. if (v.substr(-1) === ",") {
  7139. v = v.substr(0, v.length - 1);
  7140. }
  7141. if (_colorLookup[v]) {
  7142. a = _colorLookup[v];
  7143. } else if (v.charAt(0) === "#") {
  7144. if (v.length < 6) {
  7145. r = v.charAt(1);
  7146. g = v.charAt(2);
  7147. b = v.charAt(3);
  7148. v = "#" + r + r + g + g + b + b + (v.length === 5 ? v.charAt(4) + v.charAt(4) : "");
  7149. }
  7150. if (v.length === 9) {
  7151. a = parseInt(v.substr(1, 6), 16);
  7152. return [a >> 16, a >> 8 & _255, a & _255, parseInt(v.substr(7), 16) / 255];
  7153. }
  7154. v = parseInt(v.substr(1), 16);
  7155. a = [v >> 16, v >> 8 & _255, v & _255];
  7156. } else if (v.substr(0, 3) === "hsl") {
  7157. a = wasHSL = v.match(_strictNumExp);
  7158. if (!toHSL) {
  7159. h = +a[0] % 360 / 360;
  7160. s = +a[1] / 100;
  7161. l = +a[2] / 100;
  7162. g = l <= .5 ? l * (s + 1) : l + s - l * s;
  7163. r = l * 2 - g;
  7164. a.length > 3 && (a[3] *= 1);
  7165. a[0] = _hue(h + 1 / 3, r, g);
  7166. a[1] = _hue(h, r, g);
  7167. a[2] = _hue(h - 1 / 3, r, g);
  7168. } else if (~v.indexOf("=")) {
  7169. a = v.match(_numExp);
  7170. forceAlpha && a.length < 4 && (a[3] = 1);
  7171. return a;
  7172. }
  7173. } else {
  7174. a = v.match(_strictNumExp) || _colorLookup.transparent;
  7175. }
  7176. a = a.map(Number);
  7177. }
  7178. if (toHSL && !wasHSL) {
  7179. r = a[0] / _255;
  7180. g = a[1] / _255;
  7181. b = a[2] / _255;
  7182. max = Math.max(r, g, b);
  7183. min = Math.min(r, g, b);
  7184. l = (max + min) / 2;
  7185. if (max === min) {
  7186. h = s = 0;
  7187. } else {
  7188. d = max - min;
  7189. s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
  7190. h = max === r ? (g - b) / d + (g < b ? 6 : 0) : max === g ? (b - r) / d + 2 : (r - g) / d + 4;
  7191. h *= 60;
  7192. }
  7193. a[0] = ~~(h + .5);
  7194. a[1] = ~~(s * 100 + .5);
  7195. a[2] = ~~(l * 100 + .5);
  7196. }
  7197. forceAlpha && a.length < 4 && (a[3] = 1);
  7198. return a;
  7199. },
  7200. _colorOrderData = function _colorOrderData(v) {
  7201. var values = [],
  7202. c = [],
  7203. i = -1;
  7204. v.split(_colorExp).forEach(function (v) {
  7205. var a = v.match(_numWithUnitExp) || [];
  7206. values.push.apply(values, a);
  7207. c.push(i += a.length + 1);
  7208. });
  7209. values.c = c;
  7210. return values;
  7211. },
  7212. _formatColors = function _formatColors(s, toHSL, orderMatchData) {
  7213. var result = "",
  7214. colors = (s + result).match(_colorExp),
  7215. type = toHSL ? "hsla(" : "rgba(",
  7216. i = 0,
  7217. c,
  7218. shell,
  7219. d,
  7220. l;
  7221. if (!colors) {
  7222. return s;
  7223. }
  7224. colors = colors.map(function (color) {
  7225. return (color = splitColor(color, toHSL, 1)) && type + (toHSL ? color[0] + "," + color[1] + "%," + color[2] + "%," + color[3] : color.join(",")) + ")";
  7226. });
  7227. if (orderMatchData) {
  7228. d = _colorOrderData(s);
  7229. c = orderMatchData.c;
  7230. if (c.join(result) !== d.c.join(result)) {
  7231. shell = s.replace(_colorExp, "1").split(_numWithUnitExp);
  7232. l = shell.length - 1;
  7233. for (; i < l; i++) {
  7234. result += shell[i] + (~c.indexOf(i) ? colors.shift() || type + "0,0,0,0)" : (d.length ? d : colors.length ? colors : orderMatchData).shift());
  7235. }
  7236. }
  7237. }
  7238. if (!shell) {
  7239. shell = s.split(_colorExp);
  7240. l = shell.length - 1;
  7241. for (; i < l; i++) {
  7242. result += shell[i] + colors[i];
  7243. }
  7244. }
  7245. return result + shell[l];
  7246. },
  7247. _colorExp = function () {
  7248. var s = "(?:\\b(?:(?:rgb|rgba|hsl|hsla)\\(.+?\\))|\\B#(?:[0-9a-f]{3,4}){1,2}\\b",
  7249. p;
  7250. for (p in _colorLookup) {
  7251. s += "|" + p + "\\b";
  7252. }
  7253. return new RegExp(s + ")", "gi");
  7254. }(),
  7255. _hslExp = /hsl[a]?\(/,
  7256. _colorStringFilter = function _colorStringFilter(a) {
  7257. var combined = a.join(" "),
  7258. toHSL;
  7259. _colorExp.lastIndex = 0;
  7260. if (_colorExp.test(combined)) {
  7261. toHSL = _hslExp.test(combined);
  7262. a[1] = _formatColors(a[1], toHSL);
  7263. a[0] = _formatColors(a[0], toHSL, _colorOrderData(a[1]));
  7264. return true;
  7265. }
  7266. },
  7267. _tickerActive,
  7268. _ticker = function () {
  7269. var _getTime = Date.now,
  7270. _lagThreshold = 500,
  7271. _adjustedLag = 33,
  7272. _startTime = _getTime(),
  7273. _lastUpdate = _startTime,
  7274. _gap = 1000 / 240,
  7275. _nextTime = _gap,
  7276. _listeners = [],
  7277. _id,
  7278. _req,
  7279. _raf,
  7280. _self,
  7281. _delta,
  7282. _i,
  7283. _tick = function _tick(v) {
  7284. var elapsed = _getTime() - _lastUpdate,
  7285. manual = v === true,
  7286. overlap,
  7287. dispatch,
  7288. time,
  7289. frame;
  7290. (elapsed > _lagThreshold || elapsed < 0) && (_startTime += elapsed - _adjustedLag);
  7291. _lastUpdate += elapsed;
  7292. time = _lastUpdate - _startTime;
  7293. overlap = time - _nextTime;
  7294. if (overlap > 0 || manual) {
  7295. frame = ++_self.frame;
  7296. _delta = time - _self.time * 1000;
  7297. _self.time = time = time / 1000;
  7298. _nextTime += overlap + (overlap >= _gap ? 4 : _gap - overlap);
  7299. dispatch = 1;
  7300. }
  7301. manual || (_id = _req(_tick));
  7302. if (dispatch) {
  7303. for (_i = 0; _i < _listeners.length; _i++) {
  7304. _listeners[_i](time, _delta, frame, v);
  7305. }
  7306. }
  7307. };
  7308. _self = {
  7309. time: 0,
  7310. frame: 0,
  7311. tick: function tick() {
  7312. _tick(true);
  7313. },
  7314. deltaRatio: function deltaRatio(fps) {
  7315. return _delta / (1000 / (fps || 60));
  7316. },
  7317. wake: function wake() {
  7318. if (_coreReady) {
  7319. if (!_coreInitted && _windowExists()) {
  7320. _win = _coreInitted = window;
  7321. _doc = _win.document || {};
  7322. _globals.gsap = gsap;
  7323. (_win.gsapVersions || (_win.gsapVersions = [])).push(gsap.version);
  7324. _install(_installScope || _win.GreenSockGlobals || !_win.gsap && _win || {});
  7325. _registerPluginQueue.forEach(_createPlugin);
  7326. }
  7327. _raf = typeof requestAnimationFrame !== "undefined" && requestAnimationFrame;
  7328. _id && _self.sleep();
  7329. _req = _raf || function (f) {
  7330. return setTimeout(f, _nextTime - _self.time * 1000 + 1 | 0);
  7331. };
  7332. _tickerActive = 1;
  7333. _tick(2);
  7334. }
  7335. },
  7336. sleep: function sleep() {
  7337. (_raf ? cancelAnimationFrame : clearTimeout)(_id);
  7338. _tickerActive = 0;
  7339. _req = _emptyFunc;
  7340. },
  7341. lagSmoothing: function lagSmoothing(threshold, adjustedLag) {
  7342. _lagThreshold = threshold || Infinity;
  7343. _adjustedLag = Math.min(adjustedLag || 33, _lagThreshold);
  7344. },
  7345. fps: function fps(_fps) {
  7346. _gap = 1000 / (_fps || 240);
  7347. _nextTime = _self.time * 1000 + _gap;
  7348. },
  7349. add: function add(callback, once, prioritize) {
  7350. var func = once ? function (t, d, f, v) {
  7351. callback(t, d, f, v);
  7352. _self.remove(func);
  7353. } : callback;
  7354. _self.remove(callback);
  7355. _listeners[prioritize ? "unshift" : "push"](func);
  7356. _wake();
  7357. return func;
  7358. },
  7359. remove: function remove(callback, i) {
  7360. ~(i = _listeners.indexOf(callback)) && _listeners.splice(i, 1) && _i >= i && _i--;
  7361. },
  7362. _listeners: _listeners
  7363. };
  7364. return _self;
  7365. }(),
  7366. _wake = function _wake() {
  7367. return !_tickerActive && _ticker.wake();
  7368. },
  7369. _easeMap = {},
  7370. _customEaseExp = /^[\d.\-M][\d.\-,\s]/,
  7371. _quotesExp = /["']/g,
  7372. _parseObjectInString = function _parseObjectInString(value) {
  7373. var obj = {},
  7374. split = value.substr(1, value.length - 3).split(":"),
  7375. key = split[0],
  7376. i = 1,
  7377. l = split.length,
  7378. index,
  7379. val,
  7380. parsedVal;
  7381. for (; i < l; i++) {
  7382. val = split[i];
  7383. index = i !== l - 1 ? val.lastIndexOf(",") : val.length;
  7384. parsedVal = val.substr(0, index);
  7385. obj[key] = isNaN(parsedVal) ? parsedVal.replace(_quotesExp, "").trim() : +parsedVal;
  7386. key = val.substr(index + 1).trim();
  7387. }
  7388. return obj;
  7389. },
  7390. _valueInParentheses = function _valueInParentheses(value) {
  7391. var open = value.indexOf("(") + 1,
  7392. close = value.indexOf(")"),
  7393. nested = value.indexOf("(", open);
  7394. return value.substring(open, ~nested && nested < close ? value.indexOf(")", close + 1) : close);
  7395. },
  7396. _configEaseFromString = function _configEaseFromString(name) {
  7397. var split = (name + "").split("("),
  7398. ease = _easeMap[split[0]];
  7399. 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;
  7400. },
  7401. _invertEase = function _invertEase(ease) {
  7402. return function (p) {
  7403. return 1 - ease(1 - p);
  7404. };
  7405. },
  7406. _propagateYoyoEase = function _propagateYoyoEase(timeline, isYoyo) {
  7407. var child = timeline._first,
  7408. ease;
  7409. while (child) {
  7410. if (child instanceof Timeline) {
  7411. _propagateYoyoEase(child, isYoyo);
  7412. } else if (child.vars.yoyoEase && (!child._yoyo || !child._repeat) && child._yoyo !== isYoyo) {
  7413. if (child.timeline) {
  7414. _propagateYoyoEase(child.timeline, isYoyo);
  7415. } else {
  7416. ease = child._ease;
  7417. child._ease = child._yEase;
  7418. child._yEase = ease;
  7419. child._yoyo = isYoyo;
  7420. }
  7421. }
  7422. child = child._next;
  7423. }
  7424. },
  7425. _parseEase = function _parseEase(ease, defaultEase) {
  7426. return !ease ? defaultEase : (_isFunction(ease) ? ease : _easeMap[ease] || _configEaseFromString(ease)) || defaultEase;
  7427. },
  7428. _insertEase = function _insertEase(names, easeIn, easeOut, easeInOut) {
  7429. if (easeOut === void 0) {
  7430. easeOut = function easeOut(p) {
  7431. return 1 - easeIn(1 - p);
  7432. };
  7433. }
  7434. if (easeInOut === void 0) {
  7435. easeInOut = function easeInOut(p) {
  7436. return p < .5 ? easeIn(p * 2) / 2 : 1 - easeIn((1 - p) * 2) / 2;
  7437. };
  7438. }
  7439. var ease = {
  7440. easeIn: easeIn,
  7441. easeOut: easeOut,
  7442. easeInOut: easeInOut
  7443. },
  7444. lowercaseName;
  7445. _forEachName(names, function (name) {
  7446. _easeMap[name] = _globals[name] = ease;
  7447. _easeMap[lowercaseName = name.toLowerCase()] = easeOut;
  7448. for (var p in ease) {
  7449. _easeMap[lowercaseName + (p === "easeIn" ? ".in" : p === "easeOut" ? ".out" : ".inOut")] = _easeMap[name + "." + p] = ease[p];
  7450. }
  7451. });
  7452. return ease;
  7453. },
  7454. _easeInOutFromOut = function _easeInOutFromOut(easeOut) {
  7455. return function (p) {
  7456. return p < .5 ? (1 - easeOut(1 - p * 2)) / 2 : .5 + easeOut((p - .5) * 2) / 2;
  7457. };
  7458. },
  7459. _configElastic = function _configElastic(type, amplitude, period) {
  7460. var p1 = amplitude >= 1 ? amplitude : 1,
  7461. p2 = (period || (type ? .3 : .45)) / (amplitude < 1 ? amplitude : 1),
  7462. p3 = p2 / _2PI * (Math.asin(1 / p1) || 0),
  7463. easeOut = function easeOut(p) {
  7464. return p === 1 ? 1 : p1 * Math.pow(2, -10 * p) * _sin((p - p3) * p2) + 1;
  7465. },
  7466. ease = type === "out" ? easeOut : type === "in" ? function (p) {
  7467. return 1 - easeOut(1 - p);
  7468. } : _easeInOutFromOut(easeOut);
  7469. p2 = _2PI / p2;
  7470. ease.config = function (amplitude, period) {
  7471. return _configElastic(type, amplitude, period);
  7472. };
  7473. return ease;
  7474. },
  7475. _configBack = function _configBack(type, overshoot) {
  7476. if (overshoot === void 0) {
  7477. overshoot = 1.70158;
  7478. }
  7479. var easeOut = function easeOut(p) {
  7480. return p ? --p * p * ((overshoot + 1) * p + overshoot) + 1 : 0;
  7481. },
  7482. ease = type === "out" ? easeOut : type === "in" ? function (p) {
  7483. return 1 - easeOut(1 - p);
  7484. } : _easeInOutFromOut(easeOut);
  7485. ease.config = function (overshoot) {
  7486. return _configBack(type, overshoot);
  7487. };
  7488. return ease;
  7489. };
  7490. _forEachName("Linear,Quad,Cubic,Quart,Quint,Strong", function (name, i) {
  7491. var power = i < 5 ? i + 1 : i;
  7492. _insertEase(name + ",Power" + (power - 1), i ? function (p) {
  7493. return Math.pow(p, power);
  7494. } : function (p) {
  7495. return p;
  7496. }, function (p) {
  7497. return 1 - Math.pow(1 - p, power);
  7498. }, function (p) {
  7499. return p < .5 ? Math.pow(p * 2, power) / 2 : 1 - Math.pow((1 - p) * 2, power) / 2;
  7500. });
  7501. });
  7502. _easeMap.Linear.easeNone = _easeMap.none = _easeMap.Linear.easeIn;
  7503. _insertEase("Elastic", _configElastic("in"), _configElastic("out"), _configElastic());
  7504. (function (n, c) {
  7505. var n1 = 1 / c,
  7506. n2 = 2 * n1,
  7507. n3 = 2.5 * n1,
  7508. easeOut = function easeOut(p) {
  7509. 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;
  7510. };
  7511. _insertEase("Bounce", function (p) {
  7512. return 1 - easeOut(1 - p);
  7513. }, easeOut);
  7514. })(7.5625, 2.75);
  7515. _insertEase("Expo", function (p) {
  7516. return Math.pow(2, 10 * (p - 1)) * p + p * p * p * p * p * p * (1 - p);
  7517. });
  7518. _insertEase("Circ", function (p) {
  7519. return -(_sqrt(1 - p * p) - 1);
  7520. });
  7521. _insertEase("Sine", function (p) {
  7522. return p === 1 ? 1 : -_cos(p * _HALF_PI) + 1;
  7523. });
  7524. _insertEase("Back", _configBack("in"), _configBack("out"), _configBack());
  7525. _easeMap.SteppedEase = _easeMap.steps = _globals.SteppedEase = {
  7526. config: function config(steps, immediateStart) {
  7527. if (steps === void 0) {
  7528. steps = 1;
  7529. }
  7530. var p1 = 1 / steps,
  7531. p2 = steps + (immediateStart ? 0 : 1),
  7532. p3 = immediateStart ? 1 : 0,
  7533. max = 1 - _tinyNum;
  7534. return function (p) {
  7535. return ((p2 * _clamp(0, max, p) | 0) + p3) * p1;
  7536. };
  7537. }
  7538. };
  7539. _defaults.ease = _easeMap["quad.out"];
  7540. _forEachName("onComplete,onUpdate,onStart,onRepeat,onReverseComplete,onInterrupt", function (name) {
  7541. return _callbackNames += name + "," + name + "Params,";
  7542. });
  7543. var GSCache = function GSCache(target, harness) {
  7544. this.id = _gsID++;
  7545. target._gsap = this;
  7546. this.target = target;
  7547. this.harness = harness;
  7548. this.get = harness ? harness.get : _getProperty;
  7549. this.set = harness ? harness.getSetter : _getSetter;
  7550. };
  7551. var Animation = function () {
  7552. function Animation(vars) {
  7553. this.vars = vars;
  7554. this._delay = +vars.delay || 0;
  7555. if (this._repeat = vars.repeat === Infinity ? -2 : vars.repeat || 0) {
  7556. this._rDelay = vars.repeatDelay || 0;
  7557. this._yoyo = !!vars.yoyo || !!vars.yoyoEase;
  7558. }
  7559. this._ts = 1;
  7560. _setDuration(this, +vars.duration, 1, 1);
  7561. this.data = vars.data;
  7562. if (_context) {
  7563. this._ctx = _context;
  7564. _context.data.push(this);
  7565. }
  7566. _tickerActive || _ticker.wake();
  7567. }
  7568. var _proto = Animation.prototype;
  7569. _proto.delay = function delay(value) {
  7570. if (value || value === 0) {
  7571. this.parent && this.parent.smoothChildTiming && this.startTime(this._start + value - this._delay);
  7572. this._delay = value;
  7573. return this;
  7574. }
  7575. return this._delay;
  7576. };
  7577. _proto.duration = function duration(value) {
  7578. return arguments.length ? this.totalDuration(this._repeat > 0 ? value + (value + this._rDelay) * this._repeat : value) : this.totalDuration() && this._dur;
  7579. };
  7580. _proto.totalDuration = function totalDuration(value) {
  7581. if (!arguments.length) {
  7582. return this._tDur;
  7583. }
  7584. this._dirty = 0;
  7585. return _setDuration(this, this._repeat < 0 ? value : (value - this._repeat * this._rDelay) / (this._repeat + 1));
  7586. };
  7587. _proto.totalTime = function totalTime(_totalTime, suppressEvents) {
  7588. _wake();
  7589. if (!arguments.length) {
  7590. return this._tTime;
  7591. }
  7592. var parent = this._dp;
  7593. if (parent && parent.smoothChildTiming && this._ts) {
  7594. _alignPlayhead(this, _totalTime);
  7595. !parent._dp || parent.parent || _postAddChecks(parent, this);
  7596. while (parent && parent.parent) {
  7597. if (parent.parent._time !== parent._start + (parent._ts >= 0 ? parent._tTime / parent._ts : (parent.totalDuration() - parent._tTime) / -parent._ts)) {
  7598. parent.totalTime(parent._tTime, true);
  7599. }
  7600. parent = parent.parent;
  7601. }
  7602. if (!this.parent && this._dp.autoRemoveChildren && (this._ts > 0 && _totalTime < this._tDur || this._ts < 0 && _totalTime > 0 || !this._tDur && !_totalTime)) {
  7603. _addToTimeline(this._dp, this, this._start - this._delay);
  7604. }
  7605. }
  7606. if (this._tTime !== _totalTime || !this._dur && !suppressEvents || this._initted && Math.abs(this._zTime) === _tinyNum || !_totalTime && !this._initted && (this.add || this._ptLookup)) {
  7607. this._ts || (this._pTime = _totalTime);
  7608. _lazySafeRender(this, _totalTime, suppressEvents);
  7609. }
  7610. return this;
  7611. };
  7612. _proto.time = function time(value, suppressEvents) {
  7613. return arguments.length ? this.totalTime(Math.min(this.totalDuration(), value + _elapsedCycleDuration(this)) % (this._dur + this._rDelay) || (value ? this._dur : 0), suppressEvents) : this._time;
  7614. };
  7615. _proto.totalProgress = function totalProgress(value, suppressEvents) {
  7616. return arguments.length ? this.totalTime(this.totalDuration() * value, suppressEvents) : this.totalDuration() ? Math.min(1, this._tTime / this._tDur) : this.rawTime() >= 0 && this._initted ? 1 : 0;
  7617. };
  7618. _proto.progress = function progress(value, suppressEvents) {
  7619. 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;
  7620. };
  7621. _proto.iteration = function iteration(value, suppressEvents) {
  7622. var cycleDuration = this.duration() + this._rDelay;
  7623. return arguments.length ? this.totalTime(this._time + (value - 1) * cycleDuration, suppressEvents) : this._repeat ? _animationCycle(this._tTime, cycleDuration) + 1 : 1;
  7624. };
  7625. _proto.timeScale = function timeScale(value, suppressEvents) {
  7626. if (!arguments.length) {
  7627. return this._rts === -_tinyNum ? 0 : this._rts;
  7628. }
  7629. if (this._rts === value) {
  7630. return this;
  7631. }
  7632. var tTime = this.parent && this._ts ? _parentToChildTotalTime(this.parent._time, this) : this._tTime;
  7633. this._rts = +value || 0;
  7634. this._ts = this._ps || value === -_tinyNum ? 0 : this._rts;
  7635. this.totalTime(_clamp(-Math.abs(this._delay), this.totalDuration(), tTime), suppressEvents !== false);
  7636. _setEnd(this);
  7637. return _recacheAncestors(this);
  7638. };
  7639. _proto.paused = function paused(value) {
  7640. if (!arguments.length) {
  7641. return this._ps;
  7642. }
  7643. if (this._ps !== value) {
  7644. this._ps = value;
  7645. if (value) {
  7646. this._pTime = this._tTime || Math.max(-this._delay, this.rawTime());
  7647. this._ts = this._act = 0;
  7648. } else {
  7649. _wake();
  7650. this._ts = this._rts;
  7651. this.totalTime(this.parent && !this.parent.smoothChildTiming ? this.rawTime() : this._tTime || this._pTime, this.progress() === 1 && Math.abs(this._zTime) !== _tinyNum && (this._tTime -= _tinyNum));
  7652. }
  7653. }
  7654. return this;
  7655. };
  7656. _proto.startTime = function startTime(value) {
  7657. if (arguments.length) {
  7658. this._start = value;
  7659. var parent = this.parent || this._dp;
  7660. parent && (parent._sort || !this.parent) && _addToTimeline(parent, this, value - this._delay);
  7661. return this;
  7662. }
  7663. return this._start;
  7664. };
  7665. _proto.endTime = function endTime(includeRepeats) {
  7666. return this._start + (_isNotFalse(includeRepeats) ? this.totalDuration() : this.duration()) / Math.abs(this._ts || 1);
  7667. };
  7668. _proto.rawTime = function rawTime(wrapRepeats) {
  7669. var parent = this.parent || this._dp;
  7670. 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);
  7671. };
  7672. _proto.revert = function revert(config) {
  7673. if (config === void 0) {
  7674. config = _revertConfig;
  7675. }
  7676. var prevIsReverting = _reverting;
  7677. _reverting = config;
  7678. if (_isRevertWorthy(this)) {
  7679. this.timeline && this.timeline.revert(config);
  7680. this.totalTime(-0.01, config.suppressEvents);
  7681. }
  7682. this.data !== "nested" && config.kill !== false && this.kill();
  7683. _reverting = prevIsReverting;
  7684. return this;
  7685. };
  7686. _proto.globalTime = function globalTime(rawTime) {
  7687. var animation = this,
  7688. time = arguments.length ? rawTime : animation.rawTime();
  7689. while (animation) {
  7690. time = animation._start + time / (Math.abs(animation._ts) || 1);
  7691. animation = animation._dp;
  7692. }
  7693. return !this.parent && this._sat ? this._sat.globalTime(rawTime) : time;
  7694. };
  7695. _proto.repeat = function repeat(value) {
  7696. if (arguments.length) {
  7697. this._repeat = value === Infinity ? -2 : value;
  7698. return _onUpdateTotalDuration(this);
  7699. }
  7700. return this._repeat === -2 ? Infinity : this._repeat;
  7701. };
  7702. _proto.repeatDelay = function repeatDelay(value) {
  7703. if (arguments.length) {
  7704. var time = this._time;
  7705. this._rDelay = value;
  7706. _onUpdateTotalDuration(this);
  7707. return time ? this.time(time) : this;
  7708. }
  7709. return this._rDelay;
  7710. };
  7711. _proto.yoyo = function yoyo(value) {
  7712. if (arguments.length) {
  7713. this._yoyo = value;
  7714. return this;
  7715. }
  7716. return this._yoyo;
  7717. };
  7718. _proto.seek = function seek(position, suppressEvents) {
  7719. return this.totalTime(_parsePosition(this, position), _isNotFalse(suppressEvents));
  7720. };
  7721. _proto.restart = function restart(includeDelay, suppressEvents) {
  7722. this.play().totalTime(includeDelay ? -this._delay : 0, _isNotFalse(suppressEvents));
  7723. this._dur || (this._zTime = -_tinyNum);
  7724. return this;
  7725. };
  7726. _proto.play = function play(from, suppressEvents) {
  7727. from != null && this.seek(from, suppressEvents);
  7728. return this.reversed(false).paused(false);
  7729. };
  7730. _proto.reverse = function reverse(from, suppressEvents) {
  7731. from != null && this.seek(from || this.totalDuration(), suppressEvents);
  7732. return this.reversed(true).paused(false);
  7733. };
  7734. _proto.pause = function pause(atTime, suppressEvents) {
  7735. atTime != null && this.seek(atTime, suppressEvents);
  7736. return this.paused(true);
  7737. };
  7738. _proto.resume = function resume() {
  7739. return this.paused(false);
  7740. };
  7741. _proto.reversed = function reversed(value) {
  7742. if (arguments.length) {
  7743. !!value !== this.reversed() && this.timeScale(-this._rts || (value ? -_tinyNum : 0));
  7744. return this;
  7745. }
  7746. return this._rts < 0;
  7747. };
  7748. _proto.invalidate = function invalidate() {
  7749. this._initted = this._act = 0;
  7750. this._zTime = -_tinyNum;
  7751. return this;
  7752. };
  7753. _proto.isActive = function isActive() {
  7754. var parent = this.parent || this._dp,
  7755. start = this._start,
  7756. rawTime;
  7757. return !!(!parent || this._ts && this._initted && parent.isActive() && (rawTime = parent.rawTime(true)) >= start && rawTime < this.endTime(true) - _tinyNum);
  7758. };
  7759. _proto.eventCallback = function eventCallback(type, callback, params) {
  7760. var vars = this.vars;
  7761. if (arguments.length > 1) {
  7762. if (!callback) {
  7763. delete vars[type];
  7764. } else {
  7765. vars[type] = callback;
  7766. params && (vars[type + "Params"] = params);
  7767. type === "onUpdate" && (this._onUpdate = callback);
  7768. }
  7769. return this;
  7770. }
  7771. return vars[type];
  7772. };
  7773. _proto.then = function then(onFulfilled) {
  7774. var self = this;
  7775. return new Promise(function (resolve) {
  7776. var f = _isFunction(onFulfilled) ? onFulfilled : _passThrough,
  7777. _resolve = function _resolve() {
  7778. var _then = self.then;
  7779. self.then = null;
  7780. _isFunction(f) && (f = f(self)) && (f.then || f === self) && (self.then = _then);
  7781. resolve(f);
  7782. self.then = _then;
  7783. };
  7784. if (self._initted && self.totalProgress() === 1 && self._ts >= 0 || !self._tTime && self._ts < 0) {
  7785. _resolve();
  7786. } else {
  7787. self._prom = _resolve;
  7788. }
  7789. });
  7790. };
  7791. _proto.kill = function kill() {
  7792. _interrupt(this);
  7793. };
  7794. return Animation;
  7795. }();
  7796. _setDefaults(Animation.prototype, {
  7797. _time: 0,
  7798. _start: 0,
  7799. _end: 0,
  7800. _tTime: 0,
  7801. _tDur: 0,
  7802. _dirty: 0,
  7803. _repeat: 0,
  7804. _yoyo: false,
  7805. parent: null,
  7806. _initted: false,
  7807. _rDelay: 0,
  7808. _ts: 1,
  7809. _dp: 0,
  7810. ratio: 0,
  7811. _zTime: -_tinyNum,
  7812. _prom: 0,
  7813. _ps: false,
  7814. _rts: 1
  7815. });
  7816. var Timeline = function (_Animation) {
  7817. _inheritsLoose(Timeline, _Animation);
  7818. function Timeline(vars, position) {
  7819. var _this;
  7820. if (vars === void 0) {
  7821. vars = {};
  7822. }
  7823. _this = _Animation.call(this, vars) || this;
  7824. _this.labels = {};
  7825. _this.smoothChildTiming = !!vars.smoothChildTiming;
  7826. _this.autoRemoveChildren = !!vars.autoRemoveChildren;
  7827. _this._sort = _isNotFalse(vars.sortChildren);
  7828. _globalTimeline && _addToTimeline(vars.parent || _globalTimeline, _assertThisInitialized(_this), position);
  7829. vars.reversed && _this.reverse();
  7830. vars.paused && _this.paused(true);
  7831. vars.scrollTrigger && _scrollTrigger(_assertThisInitialized(_this), vars.scrollTrigger);
  7832. return _this;
  7833. }
  7834. var _proto2 = Timeline.prototype;
  7835. _proto2.to = function to(targets, vars, position) {
  7836. _createTweenType(0, arguments, this);
  7837. return this;
  7838. };
  7839. _proto2.from = function from(targets, vars, position) {
  7840. _createTweenType(1, arguments, this);
  7841. return this;
  7842. };
  7843. _proto2.fromTo = function fromTo(targets, fromVars, toVars, position) {
  7844. _createTweenType(2, arguments, this);
  7845. return this;
  7846. };
  7847. _proto2.set = function set(targets, vars, position) {
  7848. vars.duration = 0;
  7849. vars.parent = this;
  7850. _inheritDefaults(vars).repeatDelay || (vars.repeat = 0);
  7851. vars.immediateRender = !!vars.immediateRender;
  7852. new Tween(targets, vars, _parsePosition(this, position), 1);
  7853. return this;
  7854. };
  7855. _proto2.call = function call(callback, params, position) {
  7856. return _addToTimeline(this, Tween.delayedCall(0, callback, params), position);
  7857. };
  7858. _proto2.staggerTo = function staggerTo(targets, duration, vars, stagger, position, onCompleteAll, onCompleteAllParams) {
  7859. vars.duration = duration;
  7860. vars.stagger = vars.stagger || stagger;
  7861. vars.onComplete = onCompleteAll;
  7862. vars.onCompleteParams = onCompleteAllParams;
  7863. vars.parent = this;
  7864. new Tween(targets, vars, _parsePosition(this, position));
  7865. return this;
  7866. };
  7867. _proto2.staggerFrom = function staggerFrom(targets, duration, vars, stagger, position, onCompleteAll, onCompleteAllParams) {
  7868. vars.runBackwards = 1;
  7869. _inheritDefaults(vars).immediateRender = _isNotFalse(vars.immediateRender);
  7870. return this.staggerTo(targets, duration, vars, stagger, position, onCompleteAll, onCompleteAllParams);
  7871. };
  7872. _proto2.staggerFromTo = function staggerFromTo(targets, duration, fromVars, toVars, stagger, position, onCompleteAll, onCompleteAllParams) {
  7873. toVars.startAt = fromVars;
  7874. _inheritDefaults(toVars).immediateRender = _isNotFalse(toVars.immediateRender);
  7875. return this.staggerTo(targets, duration, toVars, stagger, position, onCompleteAll, onCompleteAllParams);
  7876. };
  7877. _proto2.render = function render(totalTime, suppressEvents, force) {
  7878. var prevTime = this._time,
  7879. tDur = this._dirty ? this.totalDuration() : this._tDur,
  7880. dur = this._dur,
  7881. tTime = totalTime <= 0 ? 0 : _roundPrecise(totalTime),
  7882. crossingStart = this._zTime < 0 !== totalTime < 0 && (this._initted || !dur),
  7883. time,
  7884. child,
  7885. next,
  7886. iteration,
  7887. cycleDuration,
  7888. prevPaused,
  7889. pauseTween,
  7890. timeScale,
  7891. prevStart,
  7892. prevIteration,
  7893. yoyo,
  7894. isYoyo;
  7895. this !== _globalTimeline && tTime > tDur && totalTime >= 0 && (tTime = tDur);
  7896. if (tTime !== this._tTime || force || crossingStart) {
  7897. if (prevTime !== this._time && dur) {
  7898. tTime += this._time - prevTime;
  7899. totalTime += this._time - prevTime;
  7900. }
  7901. time = tTime;
  7902. prevStart = this._start;
  7903. timeScale = this._ts;
  7904. prevPaused = !timeScale;
  7905. if (crossingStart) {
  7906. dur || (prevTime = this._zTime);
  7907. (totalTime || !suppressEvents) && (this._zTime = totalTime);
  7908. }
  7909. if (this._repeat) {
  7910. yoyo = this._yoyo;
  7911. cycleDuration = dur + this._rDelay;
  7912. if (this._repeat < -1 && totalTime < 0) {
  7913. return this.totalTime(cycleDuration * 100 + totalTime, suppressEvents, force);
  7914. }
  7915. time = _roundPrecise(tTime % cycleDuration);
  7916. if (tTime === tDur) {
  7917. iteration = this._repeat;
  7918. time = dur;
  7919. } else {
  7920. prevIteration = _roundPrecise(tTime / cycleDuration);
  7921. iteration = ~~prevIteration;
  7922. if (iteration && iteration === prevIteration) {
  7923. time = dur;
  7924. iteration--;
  7925. }
  7926. time > dur && (time = dur);
  7927. }
  7928. prevIteration = _animationCycle(this._tTime, cycleDuration);
  7929. !prevTime && this._tTime && prevIteration !== iteration && this._tTime - prevIteration * cycleDuration - this._dur <= 0 && (prevIteration = iteration);
  7930. if (yoyo && iteration & 1) {
  7931. time = dur - time;
  7932. isYoyo = 1;
  7933. }
  7934. if (iteration !== prevIteration && !this._lock) {
  7935. var rewinding = yoyo && prevIteration & 1,
  7936. doesWrap = rewinding === (yoyo && iteration & 1);
  7937. iteration < prevIteration && (rewinding = !rewinding);
  7938. prevTime = rewinding ? 0 : tTime % dur ? dur : tTime;
  7939. this._lock = 1;
  7940. this.render(prevTime || (isYoyo ? 0 : _roundPrecise(iteration * cycleDuration)), suppressEvents, !dur)._lock = 0;
  7941. this._tTime = tTime;
  7942. !suppressEvents && this.parent && _callback(this, "onRepeat");
  7943. this.vars.repeatRefresh && !isYoyo && (this.invalidate()._lock = 1);
  7944. if (prevTime && prevTime !== this._time || prevPaused !== !this._ts || this.vars.onRepeat && !this.parent && !this._act) {
  7945. return this;
  7946. }
  7947. dur = this._dur;
  7948. tDur = this._tDur;
  7949. if (doesWrap) {
  7950. this._lock = 2;
  7951. prevTime = rewinding ? dur : -0.0001;
  7952. this.render(prevTime, true);
  7953. this.vars.repeatRefresh && !isYoyo && this.invalidate();
  7954. }
  7955. this._lock = 0;
  7956. if (!this._ts && !prevPaused) {
  7957. return this;
  7958. }
  7959. _propagateYoyoEase(this, isYoyo);
  7960. }
  7961. }
  7962. if (this._hasPause && !this._forcing && this._lock < 2) {
  7963. pauseTween = _findNextPauseTween(this, _roundPrecise(prevTime), _roundPrecise(time));
  7964. if (pauseTween) {
  7965. tTime -= time - (time = pauseTween._start);
  7966. }
  7967. }
  7968. this._tTime = tTime;
  7969. this._time = time;
  7970. this._act = !timeScale;
  7971. if (!this._initted) {
  7972. this._onUpdate = this.vars.onUpdate;
  7973. this._initted = 1;
  7974. this._zTime = totalTime;
  7975. prevTime = 0;
  7976. }
  7977. if (!prevTime && tTime && !suppressEvents && !prevIteration) {
  7978. _callback(this, "onStart");
  7979. if (this._tTime !== tTime) {
  7980. return this;
  7981. }
  7982. }
  7983. if (time >= prevTime && totalTime >= 0) {
  7984. child = this._first;
  7985. while (child) {
  7986. next = child._next;
  7987. if ((child._act || time >= child._start) && child._ts && pauseTween !== child) {
  7988. if (child.parent !== this) {
  7989. return this.render(totalTime, suppressEvents, force);
  7990. }
  7991. child.render(child._ts > 0 ? (time - child._start) * child._ts : (child._dirty ? child.totalDuration() : child._tDur) + (time - child._start) * child._ts, suppressEvents, force);
  7992. if (time !== this._time || !this._ts && !prevPaused) {
  7993. pauseTween = 0;
  7994. next && (tTime += this._zTime = -_tinyNum);
  7995. break;
  7996. }
  7997. }
  7998. child = next;
  7999. }
  8000. } else {
  8001. child = this._last;
  8002. var adjustedTime = totalTime < 0 ? totalTime : time;
  8003. while (child) {
  8004. next = child._prev;
  8005. if ((child._act || adjustedTime <= child._end) && child._ts && pauseTween !== child) {
  8006. if (child.parent !== this) {
  8007. return this.render(totalTime, suppressEvents, force);
  8008. }
  8009. child.render(child._ts > 0 ? (adjustedTime - child._start) * child._ts : (child._dirty ? child.totalDuration() : child._tDur) + (adjustedTime - child._start) * child._ts, suppressEvents, force || _reverting && _isRevertWorthy(child));
  8010. if (time !== this._time || !this._ts && !prevPaused) {
  8011. pauseTween = 0;
  8012. next && (tTime += this._zTime = adjustedTime ? -_tinyNum : _tinyNum);
  8013. break;
  8014. }
  8015. }
  8016. child = next;
  8017. }
  8018. }
  8019. if (pauseTween && !suppressEvents) {
  8020. this.pause();
  8021. pauseTween.render(time >= prevTime ? 0 : -_tinyNum)._zTime = time >= prevTime ? 1 : -1;
  8022. if (this._ts) {
  8023. this._start = prevStart;
  8024. _setEnd(this);
  8025. return this.render(totalTime, suppressEvents, force);
  8026. }
  8027. }
  8028. this._onUpdate && !suppressEvents && _callback(this, "onUpdate", true);
  8029. if (tTime === tDur && this._tTime >= this.totalDuration() || !tTime && prevTime) if (prevStart === this._start || Math.abs(timeScale) !== Math.abs(this._ts)) if (!this._lock) {
  8030. (totalTime || !dur) && (tTime === tDur && this._ts > 0 || !tTime && this._ts < 0) && _removeFromParent(this, 1);
  8031. if (!suppressEvents && !(totalTime < 0 && !prevTime) && (tTime || prevTime || !tDur)) {
  8032. _callback(this, tTime === tDur && totalTime >= 0 ? "onComplete" : "onReverseComplete", true);
  8033. this._prom && !(tTime < tDur && this.timeScale() > 0) && this._prom();
  8034. }
  8035. }
  8036. }
  8037. return this;
  8038. };
  8039. _proto2.add = function add(child, position) {
  8040. var _this2 = this;
  8041. _isNumber(position) || (position = _parsePosition(this, position, child));
  8042. if (!(child instanceof Animation)) {
  8043. if (_isArray(child)) {
  8044. child.forEach(function (obj) {
  8045. return _this2.add(obj, position);
  8046. });
  8047. return this;
  8048. }
  8049. if (_isString(child)) {
  8050. return this.addLabel(child, position);
  8051. }
  8052. if (_isFunction(child)) {
  8053. child = Tween.delayedCall(0, child);
  8054. } else {
  8055. return this;
  8056. }
  8057. }
  8058. return this !== child ? _addToTimeline(this, child, position) : this;
  8059. };
  8060. _proto2.getChildren = function getChildren(nested, tweens, timelines, ignoreBeforeTime) {
  8061. if (nested === void 0) {
  8062. nested = true;
  8063. }
  8064. if (tweens === void 0) {
  8065. tweens = true;
  8066. }
  8067. if (timelines === void 0) {
  8068. timelines = true;
  8069. }
  8070. if (ignoreBeforeTime === void 0) {
  8071. ignoreBeforeTime = -_bigNum;
  8072. }
  8073. var a = [],
  8074. child = this._first;
  8075. while (child) {
  8076. if (child._start >= ignoreBeforeTime) {
  8077. if (child instanceof Tween) {
  8078. tweens && a.push(child);
  8079. } else {
  8080. timelines && a.push(child);
  8081. nested && a.push.apply(a, child.getChildren(true, tweens, timelines));
  8082. }
  8083. }
  8084. child = child._next;
  8085. }
  8086. return a;
  8087. };
  8088. _proto2.getById = function getById(id) {
  8089. var animations = this.getChildren(1, 1, 1),
  8090. i = animations.length;
  8091. while (i--) {
  8092. if (animations[i].vars.id === id) {
  8093. return animations[i];
  8094. }
  8095. }
  8096. };
  8097. _proto2.remove = function remove(child) {
  8098. if (_isString(child)) {
  8099. return this.removeLabel(child);
  8100. }
  8101. if (_isFunction(child)) {
  8102. return this.killTweensOf(child);
  8103. }
  8104. child.parent === this && _removeLinkedListItem(this, child);
  8105. if (child === this._recent) {
  8106. this._recent = this._last;
  8107. }
  8108. return _uncache(this);
  8109. };
  8110. _proto2.totalTime = function totalTime(_totalTime2, suppressEvents) {
  8111. if (!arguments.length) {
  8112. return this._tTime;
  8113. }
  8114. this._forcing = 1;
  8115. if (!this._dp && this._ts) {
  8116. this._start = _roundPrecise(_ticker.time - (this._ts > 0 ? _totalTime2 / this._ts : (this.totalDuration() - _totalTime2) / -this._ts));
  8117. }
  8118. _Animation.prototype.totalTime.call(this, _totalTime2, suppressEvents);
  8119. this._forcing = 0;
  8120. return this;
  8121. };
  8122. _proto2.addLabel = function addLabel(label, position) {
  8123. this.labels[label] = _parsePosition(this, position);
  8124. return this;
  8125. };
  8126. _proto2.removeLabel = function removeLabel(label) {
  8127. delete this.labels[label];
  8128. return this;
  8129. };
  8130. _proto2.addPause = function addPause(position, callback, params) {
  8131. var t = Tween.delayedCall(0, callback || _emptyFunc, params);
  8132. t.data = "isPause";
  8133. this._hasPause = 1;
  8134. return _addToTimeline(this, t, _parsePosition(this, position));
  8135. };
  8136. _proto2.removePause = function removePause(position) {
  8137. var child = this._first;
  8138. position = _parsePosition(this, position);
  8139. while (child) {
  8140. if (child._start === position && child.data === "isPause") {
  8141. _removeFromParent(child);
  8142. }
  8143. child = child._next;
  8144. }
  8145. };
  8146. _proto2.killTweensOf = function killTweensOf(targets, props, onlyActive) {
  8147. var tweens = this.getTweensOf(targets, onlyActive),
  8148. i = tweens.length;
  8149. while (i--) {
  8150. _overwritingTween !== tweens[i] && tweens[i].kill(targets, props);
  8151. }
  8152. return this;
  8153. };
  8154. _proto2.getTweensOf = function getTweensOf(targets, onlyActive) {
  8155. var a = [],
  8156. parsedTargets = toArray(targets),
  8157. child = this._first,
  8158. isGlobalTime = _isNumber(onlyActive),
  8159. children;
  8160. while (child) {
  8161. if (child instanceof Tween) {
  8162. if (_arrayContainsAny(child._targets, parsedTargets) && (isGlobalTime ? (!_overwritingTween || child._initted && child._ts) && child.globalTime(0) <= onlyActive && child.globalTime(child.totalDuration()) > onlyActive : !onlyActive || child.isActive())) {
  8163. a.push(child);
  8164. }
  8165. } else if ((children = child.getTweensOf(parsedTargets, onlyActive)).length) {
  8166. a.push.apply(a, children);
  8167. }
  8168. child = child._next;
  8169. }
  8170. return a;
  8171. };
  8172. _proto2.tweenTo = function tweenTo(position, vars) {
  8173. vars = vars || {};
  8174. var tl = this,
  8175. endTime = _parsePosition(tl, position),
  8176. _vars = vars,
  8177. startAt = _vars.startAt,
  8178. _onStart = _vars.onStart,
  8179. onStartParams = _vars.onStartParams,
  8180. immediateRender = _vars.immediateRender,
  8181. initted,
  8182. tween = Tween.to(tl, _setDefaults({
  8183. ease: vars.ease || "none",
  8184. lazy: false,
  8185. immediateRender: false,
  8186. time: endTime,
  8187. overwrite: "auto",
  8188. duration: vars.duration || Math.abs((endTime - (startAt && "time" in startAt ? startAt.time : tl._time)) / tl.timeScale()) || _tinyNum,
  8189. onStart: function onStart() {
  8190. tl.pause();
  8191. if (!initted) {
  8192. var duration = vars.duration || Math.abs((endTime - (startAt && "time" in startAt ? startAt.time : tl._time)) / tl.timeScale());
  8193. tween._dur !== duration && _setDuration(tween, duration, 0, 1).render(tween._time, true, true);
  8194. initted = 1;
  8195. }
  8196. _onStart && _onStart.apply(tween, onStartParams || []);
  8197. }
  8198. }, vars));
  8199. return immediateRender ? tween.render(0) : tween;
  8200. };
  8201. _proto2.tweenFromTo = function tweenFromTo(fromPosition, toPosition, vars) {
  8202. return this.tweenTo(toPosition, _setDefaults({
  8203. startAt: {
  8204. time: _parsePosition(this, fromPosition)
  8205. }
  8206. }, vars));
  8207. };
  8208. _proto2.recent = function recent() {
  8209. return this._recent;
  8210. };
  8211. _proto2.nextLabel = function nextLabel(afterTime) {
  8212. if (afterTime === void 0) {
  8213. afterTime = this._time;
  8214. }
  8215. return _getLabelInDirection(this, _parsePosition(this, afterTime));
  8216. };
  8217. _proto2.previousLabel = function previousLabel(beforeTime) {
  8218. if (beforeTime === void 0) {
  8219. beforeTime = this._time;
  8220. }
  8221. return _getLabelInDirection(this, _parsePosition(this, beforeTime), 1);
  8222. };
  8223. _proto2.currentLabel = function currentLabel(value) {
  8224. return arguments.length ? this.seek(value, true) : this.previousLabel(this._time + _tinyNum);
  8225. };
  8226. _proto2.shiftChildren = function shiftChildren(amount, adjustLabels, ignoreBeforeTime) {
  8227. if (ignoreBeforeTime === void 0) {
  8228. ignoreBeforeTime = 0;
  8229. }
  8230. var child = this._first,
  8231. labels = this.labels,
  8232. p;
  8233. while (child) {
  8234. if (child._start >= ignoreBeforeTime) {
  8235. child._start += amount;
  8236. child._end += amount;
  8237. }
  8238. child = child._next;
  8239. }
  8240. if (adjustLabels) {
  8241. for (p in labels) {
  8242. if (labels[p] >= ignoreBeforeTime) {
  8243. labels[p] += amount;
  8244. }
  8245. }
  8246. }
  8247. return _uncache(this);
  8248. };
  8249. _proto2.invalidate = function invalidate(soft) {
  8250. var child = this._first;
  8251. this._lock = 0;
  8252. while (child) {
  8253. child.invalidate(soft);
  8254. child = child._next;
  8255. }
  8256. return _Animation.prototype.invalidate.call(this, soft);
  8257. };
  8258. _proto2.clear = function clear(includeLabels) {
  8259. if (includeLabels === void 0) {
  8260. includeLabels = true;
  8261. }
  8262. var child = this._first,
  8263. next;
  8264. while (child) {
  8265. next = child._next;
  8266. this.remove(child);
  8267. child = next;
  8268. }
  8269. this._dp && (this._time = this._tTime = this._pTime = 0);
  8270. includeLabels && (this.labels = {});
  8271. return _uncache(this);
  8272. };
  8273. _proto2.totalDuration = function totalDuration(value) {
  8274. var max = 0,
  8275. self = this,
  8276. child = self._last,
  8277. prevStart = _bigNum,
  8278. prev,
  8279. start,
  8280. parent;
  8281. if (arguments.length) {
  8282. return self.timeScale((self._repeat < 0 ? self.duration() : self.totalDuration()) / (self.reversed() ? -value : value));
  8283. }
  8284. if (self._dirty) {
  8285. parent = self.parent;
  8286. while (child) {
  8287. prev = child._prev;
  8288. child._dirty && child.totalDuration();
  8289. start = child._start;
  8290. if (start > prevStart && self._sort && child._ts && !self._lock) {
  8291. self._lock = 1;
  8292. _addToTimeline(self, child, start - child._delay, 1)._lock = 0;
  8293. } else {
  8294. prevStart = start;
  8295. }
  8296. if (start < 0 && child._ts) {
  8297. max -= start;
  8298. if (!parent && !self._dp || parent && parent.smoothChildTiming) {
  8299. self._start += start / self._ts;
  8300. self._time -= start;
  8301. self._tTime -= start;
  8302. }
  8303. self.shiftChildren(-start, false, -1e999);
  8304. prevStart = 0;
  8305. }
  8306. child._end > max && child._ts && (max = child._end);
  8307. child = prev;
  8308. }
  8309. _setDuration(self, self === _globalTimeline && self._time > max ? self._time : max, 1, 1);
  8310. self._dirty = 0;
  8311. }
  8312. return self._tDur;
  8313. };
  8314. Timeline.updateRoot = function updateRoot(time) {
  8315. if (_globalTimeline._ts) {
  8316. _lazySafeRender(_globalTimeline, _parentToChildTotalTime(time, _globalTimeline));
  8317. _lastRenderedFrame = _ticker.frame;
  8318. }
  8319. if (_ticker.frame >= _nextGCFrame) {
  8320. _nextGCFrame += _config.autoSleep || 120;
  8321. var child = _globalTimeline._first;
  8322. if (!child || !child._ts) if (_config.autoSleep && _ticker._listeners.length < 2) {
  8323. while (child && !child._ts) {
  8324. child = child._next;
  8325. }
  8326. child || _ticker.sleep();
  8327. }
  8328. }
  8329. };
  8330. return Timeline;
  8331. }(Animation);
  8332. _setDefaults(Timeline.prototype, {
  8333. _lock: 0,
  8334. _hasPause: 0,
  8335. _forcing: 0
  8336. });
  8337. var _addComplexStringPropTween = function _addComplexStringPropTween(target, prop, start, end, setter, stringFilter, funcParam) {
  8338. var pt = new PropTween(this._pt, target, prop, 0, 1, _renderComplexString, null, setter),
  8339. index = 0,
  8340. matchIndex = 0,
  8341. result,
  8342. startNums,
  8343. color,
  8344. endNum,
  8345. chunk,
  8346. startNum,
  8347. hasRandom,
  8348. a;
  8349. pt.b = start;
  8350. pt.e = end;
  8351. start += "";
  8352. end += "";
  8353. if (hasRandom = ~end.indexOf("random(")) {
  8354. end = _replaceRandom(end);
  8355. }
  8356. if (stringFilter) {
  8357. a = [start, end];
  8358. stringFilter(a, target, prop);
  8359. start = a[0];
  8360. end = a[1];
  8361. }
  8362. startNums = start.match(_complexStringNumExp) || [];
  8363. while (result = _complexStringNumExp.exec(end)) {
  8364. endNum = result[0];
  8365. chunk = end.substring(index, result.index);
  8366. if (color) {
  8367. color = (color + 1) % 5;
  8368. } else if (chunk.substr(-5) === "rgba(") {
  8369. color = 1;
  8370. }
  8371. if (endNum !== startNums[matchIndex++]) {
  8372. startNum = parseFloat(startNums[matchIndex - 1]) || 0;
  8373. pt._pt = {
  8374. _next: pt._pt,
  8375. p: chunk || matchIndex === 1 ? chunk : ",",
  8376. s: startNum,
  8377. c: endNum.charAt(1) === "=" ? _parseRelative(startNum, endNum) - startNum : parseFloat(endNum) - startNum,
  8378. m: color && color < 4 ? Math.round : 0
  8379. };
  8380. index = _complexStringNumExp.lastIndex;
  8381. }
  8382. }
  8383. pt.c = index < end.length ? end.substring(index, end.length) : "";
  8384. pt.fp = funcParam;
  8385. if (_relExp.test(end) || hasRandom) {
  8386. pt.e = 0;
  8387. }
  8388. this._pt = pt;
  8389. return pt;
  8390. },
  8391. _addPropTween = function _addPropTween(target, prop, start, end, index, targets, modifier, stringFilter, funcParam, optional) {
  8392. _isFunction(end) && (end = end(index || 0, target, targets));
  8393. var currentValue = target[prop],
  8394. 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](),
  8395. setter = !_isFunction(currentValue) ? _setterPlain : funcParam ? _setterFuncWithParam : _setterFunc,
  8396. pt;
  8397. if (_isString(end)) {
  8398. if (~end.indexOf("random(")) {
  8399. end = _replaceRandom(end);
  8400. }
  8401. if (end.charAt(1) === "=") {
  8402. pt = _parseRelative(parsedStart, end) + (getUnit(parsedStart) || 0);
  8403. if (pt || pt === 0) {
  8404. end = pt;
  8405. }
  8406. }
  8407. }
  8408. if (!optional || parsedStart !== end || _forceAllPropTweens) {
  8409. if (!isNaN(parsedStart * end) && end !== "") {
  8410. pt = new PropTween(this._pt, target, prop, +parsedStart || 0, end - (parsedStart || 0), typeof currentValue === "boolean" ? _renderBoolean : _renderPlain, 0, setter);
  8411. funcParam && (pt.fp = funcParam);
  8412. modifier && pt.modifier(modifier, this, target);
  8413. return this._pt = pt;
  8414. }
  8415. !currentValue && !(prop in target) && _missingPlugin(prop, end);
  8416. return _addComplexStringPropTween.call(this, target, prop, parsedStart, end, setter, stringFilter || _config.stringFilter, funcParam);
  8417. }
  8418. },
  8419. _processVars = function _processVars(vars, index, target, targets, tween) {
  8420. _isFunction(vars) && (vars = _parseFuncOrString(vars, tween, index, target, targets));
  8421. if (!_isObject(vars) || vars.style && vars.nodeType || _isArray(vars) || _isTypedArray(vars)) {
  8422. return _isString(vars) ? _parseFuncOrString(vars, tween, index, target, targets) : vars;
  8423. }
  8424. var copy = {},
  8425. p;
  8426. for (p in vars) {
  8427. copy[p] = _parseFuncOrString(vars[p], tween, index, target, targets);
  8428. }
  8429. return copy;
  8430. },
  8431. _checkPlugin = function _checkPlugin(property, vars, tween, index, target, targets) {
  8432. var plugin, pt, ptLookup, i;
  8433. if (_plugins[property] && (plugin = new _plugins[property]()).init(target, plugin.rawVars ? vars[property] : _processVars(vars[property], index, target, targets, tween), tween, index, targets) !== false) {
  8434. tween._pt = pt = new PropTween(tween._pt, target, property, 0, 1, plugin.render, plugin, 0, plugin.priority);
  8435. if (tween !== _quickTween) {
  8436. ptLookup = tween._ptLookup[tween._targets.indexOf(target)];
  8437. i = plugin._props.length;
  8438. while (i--) {
  8439. ptLookup[plugin._props[i]] = pt;
  8440. }
  8441. }
  8442. }
  8443. return plugin;
  8444. },
  8445. _overwritingTween,
  8446. _forceAllPropTweens,
  8447. _initTween = function _initTween(tween, time, tTime) {
  8448. var vars = tween.vars,
  8449. ease = vars.ease,
  8450. startAt = vars.startAt,
  8451. immediateRender = vars.immediateRender,
  8452. lazy = vars.lazy,
  8453. onUpdate = vars.onUpdate,
  8454. runBackwards = vars.runBackwards,
  8455. yoyoEase = vars.yoyoEase,
  8456. keyframes = vars.keyframes,
  8457. autoRevert = vars.autoRevert,
  8458. dur = tween._dur,
  8459. prevStartAt = tween._startAt,
  8460. targets = tween._targets,
  8461. parent = tween.parent,
  8462. fullTargets = parent && parent.data === "nested" ? parent.vars.targets : targets,
  8463. autoOverwrite = tween._overwrite === "auto" && !_suppressOverwrites,
  8464. tl = tween.timeline,
  8465. cleanVars,
  8466. i,
  8467. p,
  8468. pt,
  8469. target,
  8470. hasPriority,
  8471. gsData,
  8472. harness,
  8473. plugin,
  8474. ptLookup,
  8475. index,
  8476. harnessVars,
  8477. overwritten;
  8478. tl && (!keyframes || !ease) && (ease = "none");
  8479. tween._ease = _parseEase(ease, _defaults.ease);
  8480. tween._yEase = yoyoEase ? _invertEase(_parseEase(yoyoEase === true ? ease : yoyoEase, _defaults.ease)) : 0;
  8481. if (yoyoEase && tween._yoyo && !tween._repeat) {
  8482. yoyoEase = tween._yEase;
  8483. tween._yEase = tween._ease;
  8484. tween._ease = yoyoEase;
  8485. }
  8486. tween._from = !tl && !!vars.runBackwards;
  8487. if (!tl || keyframes && !vars.stagger) {
  8488. harness = targets[0] ? _getCache(targets[0]).harness : 0;
  8489. harnessVars = harness && vars[harness.prop];
  8490. cleanVars = _copyExcluding(vars, _reservedProps);
  8491. if (prevStartAt) {
  8492. prevStartAt._zTime < 0 && prevStartAt.progress(1);
  8493. time < 0 && runBackwards && immediateRender && !autoRevert ? prevStartAt.render(-1, true) : prevStartAt.revert(runBackwards && dur ? _revertConfigNoKill : _startAtRevertConfig);
  8494. prevStartAt._lazy = 0;
  8495. }
  8496. if (startAt) {
  8497. _removeFromParent(tween._startAt = Tween.set(targets, _setDefaults({
  8498. data: "isStart",
  8499. overwrite: false,
  8500. parent: parent,
  8501. immediateRender: true,
  8502. lazy: !prevStartAt && _isNotFalse(lazy),
  8503. startAt: null,
  8504. delay: 0,
  8505. onUpdate: onUpdate && function () {
  8506. return _callback(tween, "onUpdate");
  8507. },
  8508. stagger: 0
  8509. }, startAt)));
  8510. tween._startAt._dp = 0;
  8511. tween._startAt._sat = tween;
  8512. time < 0 && (_reverting || !immediateRender && !autoRevert) && tween._startAt.revert(_revertConfigNoKill);
  8513. if (immediateRender) {
  8514. if (dur && time <= 0 && tTime <= 0) {
  8515. time && (tween._zTime = time);
  8516. return;
  8517. }
  8518. }
  8519. } else if (runBackwards && dur) {
  8520. if (!prevStartAt) {
  8521. time && (immediateRender = false);
  8522. p = _setDefaults({
  8523. overwrite: false,
  8524. data: "isFromStart",
  8525. lazy: immediateRender && !prevStartAt && _isNotFalse(lazy),
  8526. immediateRender: immediateRender,
  8527. stagger: 0,
  8528. parent: parent
  8529. }, cleanVars);
  8530. harnessVars && (p[harness.prop] = harnessVars);
  8531. _removeFromParent(tween._startAt = Tween.set(targets, p));
  8532. tween._startAt._dp = 0;
  8533. tween._startAt._sat = tween;
  8534. time < 0 && (_reverting ? tween._startAt.revert(_revertConfigNoKill) : tween._startAt.render(-1, true));
  8535. tween._zTime = time;
  8536. if (!immediateRender) {
  8537. _initTween(tween._startAt, _tinyNum, _tinyNum);
  8538. } else if (!time) {
  8539. return;
  8540. }
  8541. }
  8542. }
  8543. tween._pt = tween._ptCache = 0;
  8544. lazy = dur && _isNotFalse(lazy) || lazy && !dur;
  8545. for (i = 0; i < targets.length; i++) {
  8546. target = targets[i];
  8547. gsData = target._gsap || _harness(targets)[i]._gsap;
  8548. tween._ptLookup[i] = ptLookup = {};
  8549. _lazyLookup[gsData.id] && _lazyTweens.length && _lazyRender();
  8550. index = fullTargets === targets ? i : fullTargets.indexOf(target);
  8551. if (harness && (plugin = new harness()).init(target, harnessVars || cleanVars, tween, index, fullTargets) !== false) {
  8552. tween._pt = pt = new PropTween(tween._pt, target, plugin.name, 0, 1, plugin.render, plugin, 0, plugin.priority);
  8553. plugin._props.forEach(function (name) {
  8554. ptLookup[name] = pt;
  8555. });
  8556. plugin.priority && (hasPriority = 1);
  8557. }
  8558. if (!harness || harnessVars) {
  8559. for (p in cleanVars) {
  8560. if (_plugins[p] && (plugin = _checkPlugin(p, cleanVars, tween, index, target, fullTargets))) {
  8561. plugin.priority && (hasPriority = 1);
  8562. } else {
  8563. ptLookup[p] = pt = _addPropTween.call(tween, target, p, "get", cleanVars[p], index, fullTargets, 0, vars.stringFilter);
  8564. }
  8565. }
  8566. }
  8567. tween._op && tween._op[i] && tween.kill(target, tween._op[i]);
  8568. if (autoOverwrite && tween._pt) {
  8569. _overwritingTween = tween;
  8570. _globalTimeline.killTweensOf(target, ptLookup, tween.globalTime(time));
  8571. overwritten = !tween.parent;
  8572. _overwritingTween = 0;
  8573. }
  8574. tween._pt && lazy && (_lazyLookup[gsData.id] = 1);
  8575. }
  8576. hasPriority && _sortPropTweensByPriority(tween);
  8577. tween._onInit && tween._onInit(tween);
  8578. }
  8579. tween._onUpdate = onUpdate;
  8580. tween._initted = (!tween._op || tween._pt) && !overwritten;
  8581. keyframes && time <= 0 && tl.render(_bigNum, true, true);
  8582. },
  8583. _updatePropTweens = function _updatePropTweens(tween, property, value, start, startIsRelative, ratio, time, skipRecursion) {
  8584. var ptCache = (tween._pt && tween._ptCache || (tween._ptCache = {}))[property],
  8585. pt,
  8586. rootPT,
  8587. lookup,
  8588. i;
  8589. if (!ptCache) {
  8590. ptCache = tween._ptCache[property] = [];
  8591. lookup = tween._ptLookup;
  8592. i = tween._targets.length;
  8593. while (i--) {
  8594. pt = lookup[i][property];
  8595. if (pt && pt.d && pt.d._pt) {
  8596. pt = pt.d._pt;
  8597. while (pt && pt.p !== property && pt.fp !== property) {
  8598. pt = pt._next;
  8599. }
  8600. }
  8601. if (!pt) {
  8602. _forceAllPropTweens = 1;
  8603. tween.vars[property] = "+=0";
  8604. _initTween(tween, time);
  8605. _forceAllPropTweens = 0;
  8606. return skipRecursion ? _warn(property + " not eligible for reset") : 1;
  8607. }
  8608. ptCache.push(pt);
  8609. }
  8610. }
  8611. i = ptCache.length;
  8612. while (i--) {
  8613. rootPT = ptCache[i];
  8614. pt = rootPT._pt || rootPT;
  8615. pt.s = (start || start === 0) && !startIsRelative ? start : pt.s + (start || 0) + ratio * pt.c;
  8616. pt.c = value - pt.s;
  8617. rootPT.e && (rootPT.e = _round(value) + getUnit(rootPT.e));
  8618. rootPT.b && (rootPT.b = pt.s + getUnit(rootPT.b));
  8619. }
  8620. },
  8621. _addAliasesToVars = function _addAliasesToVars(targets, vars) {
  8622. var harness = targets[0] ? _getCache(targets[0]).harness : 0,
  8623. propertyAliases = harness && harness.aliases,
  8624. copy,
  8625. p,
  8626. i,
  8627. aliases;
  8628. if (!propertyAliases) {
  8629. return vars;
  8630. }
  8631. copy = _merge({}, vars);
  8632. for (p in propertyAliases) {
  8633. if (p in copy) {
  8634. aliases = propertyAliases[p].split(",");
  8635. i = aliases.length;
  8636. while (i--) {
  8637. copy[aliases[i]] = copy[p];
  8638. }
  8639. }
  8640. }
  8641. return copy;
  8642. },
  8643. _parseKeyframe = function _parseKeyframe(prop, obj, allProps, easeEach) {
  8644. var ease = obj.ease || easeEach || "power1.inOut",
  8645. p,
  8646. a;
  8647. if (_isArray(obj)) {
  8648. a = allProps[prop] || (allProps[prop] = []);
  8649. obj.forEach(function (value, i) {
  8650. return a.push({
  8651. t: i / (obj.length - 1) * 100,
  8652. v: value,
  8653. e: ease
  8654. });
  8655. });
  8656. } else {
  8657. for (p in obj) {
  8658. a = allProps[p] || (allProps[p] = []);
  8659. p === "ease" || a.push({
  8660. t: parseFloat(prop),
  8661. v: obj[p],
  8662. e: ease
  8663. });
  8664. }
  8665. }
  8666. },
  8667. _parseFuncOrString = function _parseFuncOrString(value, tween, i, target, targets) {
  8668. return _isFunction(value) ? value.call(tween, i, target, targets) : _isString(value) && ~value.indexOf("random(") ? _replaceRandom(value) : value;
  8669. },
  8670. _staggerTweenProps = _callbackNames + "repeat,repeatDelay,yoyo,repeatRefresh,yoyoEase,autoRevert",
  8671. _staggerPropsToSkip = {};
  8672. _forEachName(_staggerTweenProps + ",id,stagger,delay,duration,paused,scrollTrigger", function (name) {
  8673. return _staggerPropsToSkip[name] = 1;
  8674. });
  8675. var Tween = function (_Animation2) {
  8676. _inheritsLoose(Tween, _Animation2);
  8677. function Tween(targets, vars, position, skipInherit) {
  8678. var _this3;
  8679. if (typeof vars === "number") {
  8680. position.duration = vars;
  8681. vars = position;
  8682. position = null;
  8683. }
  8684. _this3 = _Animation2.call(this, skipInherit ? vars : _inheritDefaults(vars)) || this;
  8685. var _this3$vars = _this3.vars,
  8686. duration = _this3$vars.duration,
  8687. delay = _this3$vars.delay,
  8688. immediateRender = _this3$vars.immediateRender,
  8689. stagger = _this3$vars.stagger,
  8690. overwrite = _this3$vars.overwrite,
  8691. keyframes = _this3$vars.keyframes,
  8692. defaults = _this3$vars.defaults,
  8693. scrollTrigger = _this3$vars.scrollTrigger,
  8694. yoyoEase = _this3$vars.yoyoEase,
  8695. parent = vars.parent || _globalTimeline,
  8696. parsedTargets = (_isArray(targets) || _isTypedArray(targets) ? _isNumber(targets[0]) : "length" in vars) ? [targets] : toArray(targets),
  8697. tl,
  8698. i,
  8699. copy,
  8700. l,
  8701. p,
  8702. curTarget,
  8703. staggerFunc,
  8704. staggerVarsToMerge;
  8705. _this3._targets = parsedTargets.length ? _harness(parsedTargets) : _warn("GSAP target " + targets + " not found. https://gsap.com", !_config.nullTargetWarn) || [];
  8706. _this3._ptLookup = [];
  8707. _this3._overwrite = overwrite;
  8708. if (keyframes || stagger || _isFuncOrString(duration) || _isFuncOrString(delay)) {
  8709. vars = _this3.vars;
  8710. tl = _this3.timeline = new Timeline({
  8711. data: "nested",
  8712. defaults: defaults || {},
  8713. targets: parent && parent.data === "nested" ? parent.vars.targets : parsedTargets
  8714. });
  8715. tl.kill();
  8716. tl.parent = tl._dp = _assertThisInitialized(_this3);
  8717. tl._start = 0;
  8718. if (stagger || _isFuncOrString(duration) || _isFuncOrString(delay)) {
  8719. l = parsedTargets.length;
  8720. staggerFunc = stagger && distribute(stagger);
  8721. if (_isObject(stagger)) {
  8722. for (p in stagger) {
  8723. if (~_staggerTweenProps.indexOf(p)) {
  8724. staggerVarsToMerge || (staggerVarsToMerge = {});
  8725. staggerVarsToMerge[p] = stagger[p];
  8726. }
  8727. }
  8728. }
  8729. for (i = 0; i < l; i++) {
  8730. copy = _copyExcluding(vars, _staggerPropsToSkip);
  8731. copy.stagger = 0;
  8732. yoyoEase && (copy.yoyoEase = yoyoEase);
  8733. staggerVarsToMerge && _merge(copy, staggerVarsToMerge);
  8734. curTarget = parsedTargets[i];
  8735. copy.duration = +_parseFuncOrString(duration, _assertThisInitialized(_this3), i, curTarget, parsedTargets);
  8736. copy.delay = (+_parseFuncOrString(delay, _assertThisInitialized(_this3), i, curTarget, parsedTargets) || 0) - _this3._delay;
  8737. if (!stagger && l === 1 && copy.delay) {
  8738. _this3._delay = delay = copy.delay;
  8739. _this3._start += delay;
  8740. copy.delay = 0;
  8741. }
  8742. tl.to(curTarget, copy, staggerFunc ? staggerFunc(i, curTarget, parsedTargets) : 0);
  8743. tl._ease = _easeMap.none;
  8744. }
  8745. tl.duration() ? duration = delay = 0 : _this3.timeline = 0;
  8746. } else if (keyframes) {
  8747. _inheritDefaults(_setDefaults(tl.vars.defaults, {
  8748. ease: "none"
  8749. }));
  8750. tl._ease = _parseEase(keyframes.ease || vars.ease || "none");
  8751. var time = 0,
  8752. a,
  8753. kf,
  8754. v;
  8755. if (_isArray(keyframes)) {
  8756. keyframes.forEach(function (frame) {
  8757. return tl.to(parsedTargets, frame, ">");
  8758. });
  8759. tl.duration();
  8760. } else {
  8761. copy = {};
  8762. for (p in keyframes) {
  8763. p === "ease" || p === "easeEach" || _parseKeyframe(p, keyframes[p], copy, keyframes.easeEach);
  8764. }
  8765. for (p in copy) {
  8766. a = copy[p].sort(function (a, b) {
  8767. return a.t - b.t;
  8768. });
  8769. time = 0;
  8770. for (i = 0; i < a.length; i++) {
  8771. kf = a[i];
  8772. v = {
  8773. ease: kf.e,
  8774. duration: (kf.t - (i ? a[i - 1].t : 0)) / 100 * duration
  8775. };
  8776. v[p] = kf.v;
  8777. tl.to(parsedTargets, v, time);
  8778. time += v.duration;
  8779. }
  8780. }
  8781. tl.duration() < duration && tl.to({}, {
  8782. duration: duration - tl.duration()
  8783. });
  8784. }
  8785. }
  8786. duration || _this3.duration(duration = tl.duration());
  8787. } else {
  8788. _this3.timeline = 0;
  8789. }
  8790. if (overwrite === true && !_suppressOverwrites) {
  8791. _overwritingTween = _assertThisInitialized(_this3);
  8792. _globalTimeline.killTweensOf(parsedTargets);
  8793. _overwritingTween = 0;
  8794. }
  8795. _addToTimeline(parent, _assertThisInitialized(_this3), position);
  8796. vars.reversed && _this3.reverse();
  8797. vars.paused && _this3.paused(true);
  8798. if (immediateRender || !duration && !keyframes && _this3._start === _roundPrecise(parent._time) && _isNotFalse(immediateRender) && _hasNoPausedAncestors(_assertThisInitialized(_this3)) && parent.data !== "nested") {
  8799. _this3._tTime = -_tinyNum;
  8800. _this3.render(Math.max(0, -delay) || 0);
  8801. }
  8802. scrollTrigger && _scrollTrigger(_assertThisInitialized(_this3), scrollTrigger);
  8803. return _this3;
  8804. }
  8805. var _proto3 = Tween.prototype;
  8806. _proto3.render = function render(totalTime, suppressEvents, force) {
  8807. var prevTime = this._time,
  8808. tDur = this._tDur,
  8809. dur = this._dur,
  8810. isNegative = totalTime < 0,
  8811. tTime = totalTime > tDur - _tinyNum && !isNegative ? tDur : totalTime < _tinyNum ? 0 : totalTime,
  8812. time,
  8813. pt,
  8814. iteration,
  8815. cycleDuration,
  8816. prevIteration,
  8817. isYoyo,
  8818. ratio,
  8819. timeline,
  8820. yoyoEase;
  8821. if (!dur) {
  8822. _renderZeroDurationTween(this, totalTime, suppressEvents, force);
  8823. } else if (tTime !== this._tTime || !totalTime || force || !this._initted && this._tTime || this._startAt && this._zTime < 0 !== isNegative || this._lazy) {
  8824. time = tTime;
  8825. timeline = this.timeline;
  8826. if (this._repeat) {
  8827. cycleDuration = dur + this._rDelay;
  8828. if (this._repeat < -1 && isNegative) {
  8829. return this.totalTime(cycleDuration * 100 + totalTime, suppressEvents, force);
  8830. }
  8831. time = _roundPrecise(tTime % cycleDuration);
  8832. if (tTime === tDur) {
  8833. iteration = this._repeat;
  8834. time = dur;
  8835. } else {
  8836. prevIteration = _roundPrecise(tTime / cycleDuration);
  8837. iteration = ~~prevIteration;
  8838. if (iteration && iteration === prevIteration) {
  8839. time = dur;
  8840. iteration--;
  8841. } else if (time > dur) {
  8842. time = dur;
  8843. }
  8844. }
  8845. isYoyo = this._yoyo && iteration & 1;
  8846. if (isYoyo) {
  8847. yoyoEase = this._yEase;
  8848. time = dur - time;
  8849. }
  8850. prevIteration = _animationCycle(this._tTime, cycleDuration);
  8851. if (time === prevTime && !force && this._initted && iteration === prevIteration) {
  8852. this._tTime = tTime;
  8853. return this;
  8854. }
  8855. if (iteration !== prevIteration) {
  8856. timeline && this._yEase && _propagateYoyoEase(timeline, isYoyo);
  8857. if (this.vars.repeatRefresh && !isYoyo && !this._lock && time !== cycleDuration && this._initted) {
  8858. this._lock = force = 1;
  8859. this.render(_roundPrecise(cycleDuration * iteration), true).invalidate()._lock = 0;
  8860. }
  8861. }
  8862. }
  8863. if (!this._initted) {
  8864. if (_attemptInitTween(this, isNegative ? totalTime : time, force, suppressEvents, tTime)) {
  8865. this._tTime = 0;
  8866. return this;
  8867. }
  8868. if (prevTime !== this._time && !(force && this.vars.repeatRefresh && iteration !== prevIteration)) {
  8869. return this;
  8870. }
  8871. if (dur !== this._dur) {
  8872. return this.render(totalTime, suppressEvents, force);
  8873. }
  8874. }
  8875. this._tTime = tTime;
  8876. this._time = time;
  8877. if (!this._act && this._ts) {
  8878. this._act = 1;
  8879. this._lazy = 0;
  8880. }
  8881. this.ratio = ratio = (yoyoEase || this._ease)(time / dur);
  8882. if (this._from) {
  8883. this.ratio = ratio = 1 - ratio;
  8884. }
  8885. if (!prevTime && tTime && !suppressEvents && !prevIteration) {
  8886. _callback(this, "onStart");
  8887. if (this._tTime !== tTime) {
  8888. return this;
  8889. }
  8890. }
  8891. pt = this._pt;
  8892. while (pt) {
  8893. pt.r(ratio, pt.d);
  8894. pt = pt._next;
  8895. }
  8896. timeline && timeline.render(totalTime < 0 ? totalTime : timeline._dur * timeline._ease(time / this._dur), suppressEvents, force) || this._startAt && (this._zTime = totalTime);
  8897. if (this._onUpdate && !suppressEvents) {
  8898. isNegative && _rewindStartAt(this, totalTime, suppressEvents, force);
  8899. _callback(this, "onUpdate");
  8900. }
  8901. this._repeat && iteration !== prevIteration && this.vars.onRepeat && !suppressEvents && this.parent && _callback(this, "onRepeat");
  8902. if ((tTime === this._tDur || !tTime) && this._tTime === tTime) {
  8903. isNegative && !this._onUpdate && _rewindStartAt(this, totalTime, true, true);
  8904. (totalTime || !dur) && (tTime === this._tDur && this._ts > 0 || !tTime && this._ts < 0) && _removeFromParent(this, 1);
  8905. if (!suppressEvents && !(isNegative && !prevTime) && (tTime || prevTime || isYoyo)) {
  8906. _callback(this, tTime === tDur ? "onComplete" : "onReverseComplete", true);
  8907. this._prom && !(tTime < tDur && this.timeScale() > 0) && this._prom();
  8908. }
  8909. }
  8910. }
  8911. return this;
  8912. };
  8913. _proto3.targets = function targets() {
  8914. return this._targets;
  8915. };
  8916. _proto3.invalidate = function invalidate(soft) {
  8917. (!soft || !this.vars.runBackwards) && (this._startAt = 0);
  8918. this._pt = this._op = this._onUpdate = this._lazy = this.ratio = 0;
  8919. this._ptLookup = [];
  8920. this.timeline && this.timeline.invalidate(soft);
  8921. return _Animation2.prototype.invalidate.call(this, soft);
  8922. };
  8923. _proto3.resetTo = function resetTo(property, value, start, startIsRelative, skipRecursion) {
  8924. _tickerActive || _ticker.wake();
  8925. this._ts || this.play();
  8926. var time = Math.min(this._dur, (this._dp._time - this._start) * this._ts),
  8927. ratio;
  8928. this._initted || _initTween(this, time);
  8929. ratio = this._ease(time / this._dur);
  8930. if (_updatePropTweens(this, property, value, start, startIsRelative, ratio, time, skipRecursion)) {
  8931. return this.resetTo(property, value, start, startIsRelative, 1);
  8932. }
  8933. _alignPlayhead(this, 0);
  8934. this.parent || _addLinkedListItem(this._dp, this, "_first", "_last", this._dp._sort ? "_start" : 0);
  8935. return this.render(0);
  8936. };
  8937. _proto3.kill = function kill(targets, vars) {
  8938. if (vars === void 0) {
  8939. vars = "all";
  8940. }
  8941. if (!targets && (!vars || vars === "all")) {
  8942. this._lazy = this._pt = 0;
  8943. this.parent ? _interrupt(this) : this.scrollTrigger && this.scrollTrigger.kill(!!_reverting);
  8944. return this;
  8945. }
  8946. if (this.timeline) {
  8947. var tDur = this.timeline.totalDuration();
  8948. this.timeline.killTweensOf(targets, vars, _overwritingTween && _overwritingTween.vars.overwrite !== true)._first || _interrupt(this);
  8949. this.parent && tDur !== this.timeline.totalDuration() && _setDuration(this, this._dur * this.timeline._tDur / tDur, 0, 1);
  8950. return this;
  8951. }
  8952. var parsedTargets = this._targets,
  8953. killingTargets = targets ? toArray(targets) : parsedTargets,
  8954. propTweenLookup = this._ptLookup,
  8955. firstPT = this._pt,
  8956. overwrittenProps,
  8957. curLookup,
  8958. curOverwriteProps,
  8959. props,
  8960. p,
  8961. pt,
  8962. i;
  8963. if ((!vars || vars === "all") && _arraysMatch(parsedTargets, killingTargets)) {
  8964. vars === "all" && (this._pt = 0);
  8965. return _interrupt(this);
  8966. }
  8967. overwrittenProps = this._op = this._op || [];
  8968. if (vars !== "all") {
  8969. if (_isString(vars)) {
  8970. p = {};
  8971. _forEachName(vars, function (name) {
  8972. return p[name] = 1;
  8973. });
  8974. vars = p;
  8975. }
  8976. vars = _addAliasesToVars(parsedTargets, vars);
  8977. }
  8978. i = parsedTargets.length;
  8979. while (i--) {
  8980. if (~killingTargets.indexOf(parsedTargets[i])) {
  8981. curLookup = propTweenLookup[i];
  8982. if (vars === "all") {
  8983. overwrittenProps[i] = vars;
  8984. props = curLookup;
  8985. curOverwriteProps = {};
  8986. } else {
  8987. curOverwriteProps = overwrittenProps[i] = overwrittenProps[i] || {};
  8988. props = vars;
  8989. }
  8990. for (p in props) {
  8991. pt = curLookup && curLookup[p];
  8992. if (pt) {
  8993. if (!("kill" in pt.d) || pt.d.kill(p) === true) {
  8994. _removeLinkedListItem(this, pt, "_pt");
  8995. }
  8996. delete curLookup[p];
  8997. }
  8998. if (curOverwriteProps !== "all") {
  8999. curOverwriteProps[p] = 1;
  9000. }
  9001. }
  9002. }
  9003. }
  9004. this._initted && !this._pt && firstPT && _interrupt(this);
  9005. return this;
  9006. };
  9007. Tween.to = function to(targets, vars) {
  9008. return new Tween(targets, vars, arguments[2]);
  9009. };
  9010. Tween.from = function from(targets, vars) {
  9011. return _createTweenType(1, arguments);
  9012. };
  9013. Tween.delayedCall = function delayedCall(delay, callback, params, scope) {
  9014. return new Tween(callback, 0, {
  9015. immediateRender: false,
  9016. lazy: false,
  9017. overwrite: false,
  9018. delay: delay,
  9019. onComplete: callback,
  9020. onReverseComplete: callback,
  9021. onCompleteParams: params,
  9022. onReverseCompleteParams: params,
  9023. callbackScope: scope
  9024. });
  9025. };
  9026. Tween.fromTo = function fromTo(targets, fromVars, toVars) {
  9027. return _createTweenType(2, arguments);
  9028. };
  9029. Tween.set = function set(targets, vars) {
  9030. vars.duration = 0;
  9031. vars.repeatDelay || (vars.repeat = 0);
  9032. return new Tween(targets, vars);
  9033. };
  9034. Tween.killTweensOf = function killTweensOf(targets, props, onlyActive) {
  9035. return _globalTimeline.killTweensOf(targets, props, onlyActive);
  9036. };
  9037. return Tween;
  9038. }(Animation);
  9039. _setDefaults(Tween.prototype, {
  9040. _targets: [],
  9041. _lazy: 0,
  9042. _startAt: 0,
  9043. _op: 0,
  9044. _onInit: 0
  9045. });
  9046. _forEachName("staggerTo,staggerFrom,staggerFromTo", function (name) {
  9047. Tween[name] = function () {
  9048. var tl = new Timeline(),
  9049. params = _slice.call(arguments, 0);
  9050. params.splice(name === "staggerFromTo" ? 5 : 4, 0, 0);
  9051. return tl[name].apply(tl, params);
  9052. };
  9053. });
  9054. var _setterPlain = function _setterPlain(target, property, value) {
  9055. return target[property] = value;
  9056. },
  9057. _setterFunc = function _setterFunc(target, property, value) {
  9058. return target[property](value);
  9059. },
  9060. _setterFuncWithParam = function _setterFuncWithParam(target, property, value, data) {
  9061. return target[property](data.fp, value);
  9062. },
  9063. _setterAttribute = function _setterAttribute(target, property, value) {
  9064. return target.setAttribute(property, value);
  9065. },
  9066. _getSetter = function _getSetter(target, property) {
  9067. return _isFunction(target[property]) ? _setterFunc : _isUndefined(target[property]) && target.setAttribute ? _setterAttribute : _setterPlain;
  9068. },
  9069. _renderPlain = function _renderPlain(ratio, data) {
  9070. return data.set(data.t, data.p, Math.round((data.s + data.c * ratio) * 1000000) / 1000000, data);
  9071. },
  9072. _renderBoolean = function _renderBoolean(ratio, data) {
  9073. return data.set(data.t, data.p, !!(data.s + data.c * ratio), data);
  9074. },
  9075. _renderComplexString = function _renderComplexString(ratio, data) {
  9076. var pt = data._pt,
  9077. s = "";
  9078. if (!ratio && data.b) {
  9079. s = data.b;
  9080. } else if (ratio === 1 && data.e) {
  9081. s = data.e;
  9082. } else {
  9083. while (pt) {
  9084. s = pt.p + (pt.m ? pt.m(pt.s + pt.c * ratio) : Math.round((pt.s + pt.c * ratio) * 10000) / 10000) + s;
  9085. pt = pt._next;
  9086. }
  9087. s += data.c;
  9088. }
  9089. data.set(data.t, data.p, s, data);
  9090. },
  9091. _renderPropTweens = function _renderPropTweens(ratio, data) {
  9092. var pt = data._pt;
  9093. while (pt) {
  9094. pt.r(ratio, pt.d);
  9095. pt = pt._next;
  9096. }
  9097. },
  9098. _addPluginModifier = function _addPluginModifier(modifier, tween, target, property) {
  9099. var pt = this._pt,
  9100. next;
  9101. while (pt) {
  9102. next = pt._next;
  9103. pt.p === property && pt.modifier(modifier, tween, target);
  9104. pt = next;
  9105. }
  9106. },
  9107. _killPropTweensOf = function _killPropTweensOf(property) {
  9108. var pt = this._pt,
  9109. hasNonDependentRemaining,
  9110. next;
  9111. while (pt) {
  9112. next = pt._next;
  9113. if (pt.p === property && !pt.op || pt.op === property) {
  9114. _removeLinkedListItem(this, pt, "_pt");
  9115. } else if (!pt.dep) {
  9116. hasNonDependentRemaining = 1;
  9117. }
  9118. pt = next;
  9119. }
  9120. return !hasNonDependentRemaining;
  9121. },
  9122. _setterWithModifier = function _setterWithModifier(target, property, value, data) {
  9123. data.mSet(target, property, data.m.call(data.tween, value, data.mt), data);
  9124. },
  9125. _sortPropTweensByPriority = function _sortPropTweensByPriority(parent) {
  9126. var pt = parent._pt,
  9127. next,
  9128. pt2,
  9129. first,
  9130. last;
  9131. while (pt) {
  9132. next = pt._next;
  9133. pt2 = first;
  9134. while (pt2 && pt2.pr > pt.pr) {
  9135. pt2 = pt2._next;
  9136. }
  9137. if (pt._prev = pt2 ? pt2._prev : last) {
  9138. pt._prev._next = pt;
  9139. } else {
  9140. first = pt;
  9141. }
  9142. if (pt._next = pt2) {
  9143. pt2._prev = pt;
  9144. } else {
  9145. last = pt;
  9146. }
  9147. pt = next;
  9148. }
  9149. parent._pt = first;
  9150. };
  9151. var PropTween = function () {
  9152. function PropTween(next, target, prop, start, change, renderer, data, setter, priority) {
  9153. this.t = target;
  9154. this.s = start;
  9155. this.c = change;
  9156. this.p = prop;
  9157. this.r = renderer || _renderPlain;
  9158. this.d = data || this;
  9159. this.set = setter || _setterPlain;
  9160. this.pr = priority || 0;
  9161. this._next = next;
  9162. if (next) {
  9163. next._prev = this;
  9164. }
  9165. }
  9166. var _proto4 = PropTween.prototype;
  9167. _proto4.modifier = function modifier(func, tween, target) {
  9168. this.mSet = this.mSet || this.set;
  9169. this.set = _setterWithModifier;
  9170. this.m = func;
  9171. this.mt = target;
  9172. this.tween = tween;
  9173. };
  9174. return PropTween;
  9175. }();
  9176. _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) {
  9177. return _reservedProps[name] = 1;
  9178. });
  9179. _globals.TweenMax = _globals.TweenLite = Tween;
  9180. _globals.TimelineLite = _globals.TimelineMax = Timeline;
  9181. _globalTimeline = new Timeline({
  9182. sortChildren: false,
  9183. defaults: _defaults,
  9184. autoRemoveChildren: true,
  9185. id: "root",
  9186. smoothChildTiming: true
  9187. });
  9188. _config.stringFilter = _colorStringFilter;
  9189. var _media = [],
  9190. _listeners = {},
  9191. _emptyArray = [],
  9192. _lastMediaTime = 0,
  9193. _contextID = 0,
  9194. _dispatch = function _dispatch(type) {
  9195. return (_listeners[type] || _emptyArray).map(function (f) {
  9196. return f();
  9197. });
  9198. },
  9199. _onMediaChange = function _onMediaChange() {
  9200. var time = Date.now(),
  9201. matches = [];
  9202. if (time - _lastMediaTime > 2) {
  9203. _dispatch("matchMediaInit");
  9204. _media.forEach(function (c) {
  9205. var queries = c.queries,
  9206. conditions = c.conditions,
  9207. match,
  9208. p,
  9209. anyMatch,
  9210. toggled;
  9211. for (p in queries) {
  9212. match = _win.matchMedia(queries[p]).matches;
  9213. match && (anyMatch = 1);
  9214. if (match !== conditions[p]) {
  9215. conditions[p] = match;
  9216. toggled = 1;
  9217. }
  9218. }
  9219. if (toggled) {
  9220. c.revert();
  9221. anyMatch && matches.push(c);
  9222. }
  9223. });
  9224. _dispatch("matchMediaRevert");
  9225. matches.forEach(function (c) {
  9226. return c.onMatch(c, function (func) {
  9227. return c.add(null, func);
  9228. });
  9229. });
  9230. _lastMediaTime = time;
  9231. _dispatch("matchMedia");
  9232. }
  9233. };
  9234. var Context = function () {
  9235. function Context(func, scope) {
  9236. this.selector = scope && selector(scope);
  9237. this.data = [];
  9238. this._r = [];
  9239. this.isReverted = false;
  9240. this.id = _contextID++;
  9241. func && this.add(func);
  9242. }
  9243. var _proto5 = Context.prototype;
  9244. _proto5.add = function add(name, func, scope) {
  9245. if (_isFunction(name)) {
  9246. scope = func;
  9247. func = name;
  9248. name = _isFunction;
  9249. }
  9250. var self = this,
  9251. f = function f() {
  9252. var prev = _context,
  9253. prevSelector = self.selector,
  9254. result;
  9255. prev && prev !== self && prev.data.push(self);
  9256. scope && (self.selector = selector(scope));
  9257. _context = self;
  9258. result = func.apply(self, arguments);
  9259. _isFunction(result) && self._r.push(result);
  9260. _context = prev;
  9261. self.selector = prevSelector;
  9262. self.isReverted = false;
  9263. return result;
  9264. };
  9265. self.last = f;
  9266. return name === _isFunction ? f(self, function (func) {
  9267. return self.add(null, func);
  9268. }) : name ? self[name] = f : f;
  9269. };
  9270. _proto5.ignore = function ignore(func) {
  9271. var prev = _context;
  9272. _context = null;
  9273. func(this);
  9274. _context = prev;
  9275. };
  9276. _proto5.getTweens = function getTweens() {
  9277. var a = [];
  9278. this.data.forEach(function (e) {
  9279. return e instanceof Context ? a.push.apply(a, e.getTweens()) : e instanceof Tween && !(e.parent && e.parent.data === "nested") && a.push(e);
  9280. });
  9281. return a;
  9282. };
  9283. _proto5.clear = function clear() {
  9284. this._r.length = this.data.length = 0;
  9285. };
  9286. _proto5.kill = function kill(revert, matchMedia) {
  9287. var _this4 = this;
  9288. if (revert) {
  9289. (function () {
  9290. var tweens = _this4.getTweens(),
  9291. i = _this4.data.length,
  9292. t;
  9293. while (i--) {
  9294. t = _this4.data[i];
  9295. if (t.data === "isFlip") {
  9296. t.revert();
  9297. t.getChildren(true, true, false).forEach(function (tween) {
  9298. return tweens.splice(tweens.indexOf(tween), 1);
  9299. });
  9300. }
  9301. }
  9302. tweens.map(function (t) {
  9303. return {
  9304. g: t._dur || t._delay || t._sat && !t._sat.vars.immediateRender ? t.globalTime(0) : -Infinity,
  9305. t: t
  9306. };
  9307. }).sort(function (a, b) {
  9308. return b.g - a.g || -Infinity;
  9309. }).forEach(function (o) {
  9310. return o.t.revert(revert);
  9311. });
  9312. i = _this4.data.length;
  9313. while (i--) {
  9314. t = _this4.data[i];
  9315. if (t instanceof Timeline) {
  9316. if (t.data !== "nested") {
  9317. t.scrollTrigger && t.scrollTrigger.revert();
  9318. t.kill();
  9319. }
  9320. } else {
  9321. !(t instanceof Tween) && t.revert && t.revert(revert);
  9322. }
  9323. }
  9324. _this4._r.forEach(function (f) {
  9325. return f(revert, _this4);
  9326. });
  9327. _this4.isReverted = true;
  9328. })();
  9329. } else {
  9330. this.data.forEach(function (e) {
  9331. return e.kill && e.kill();
  9332. });
  9333. }
  9334. this.clear();
  9335. if (matchMedia) {
  9336. var i = _media.length;
  9337. while (i--) {
  9338. _media[i].id === this.id && _media.splice(i, 1);
  9339. }
  9340. }
  9341. };
  9342. _proto5.revert = function revert(config) {
  9343. this.kill(config || {});
  9344. };
  9345. return Context;
  9346. }();
  9347. var MatchMedia = function () {
  9348. function MatchMedia(scope) {
  9349. this.contexts = [];
  9350. this.scope = scope;
  9351. _context && _context.data.push(this);
  9352. }
  9353. var _proto6 = MatchMedia.prototype;
  9354. _proto6.add = function add(conditions, func, scope) {
  9355. _isObject(conditions) || (conditions = {
  9356. matches: conditions
  9357. });
  9358. var context = new Context(0, scope || this.scope),
  9359. cond = context.conditions = {},
  9360. mq,
  9361. p,
  9362. active;
  9363. _context && !context.selector && (context.selector = _context.selector);
  9364. this.contexts.push(context);
  9365. func = context.add("onMatch", func);
  9366. context.queries = conditions;
  9367. for (p in conditions) {
  9368. if (p === "all") {
  9369. active = 1;
  9370. } else {
  9371. mq = _win.matchMedia(conditions[p]);
  9372. if (mq) {
  9373. _media.indexOf(context) < 0 && _media.push(context);
  9374. (cond[p] = mq.matches) && (active = 1);
  9375. mq.addListener ? mq.addListener(_onMediaChange) : mq.addEventListener("change", _onMediaChange);
  9376. }
  9377. }
  9378. }
  9379. active && func(context, function (f) {
  9380. return context.add(null, f);
  9381. });
  9382. return this;
  9383. };
  9384. _proto6.revert = function revert(config) {
  9385. this.kill(config || {});
  9386. };
  9387. _proto6.kill = function kill(revert) {
  9388. this.contexts.forEach(function (c) {
  9389. return c.kill(revert, true);
  9390. });
  9391. };
  9392. return MatchMedia;
  9393. }();
  9394. var _gsap = {
  9395. registerPlugin: function registerPlugin() {
  9396. for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
  9397. args[_key2] = arguments[_key2];
  9398. }
  9399. args.forEach(function (config) {
  9400. return _createPlugin(config);
  9401. });
  9402. },
  9403. timeline: function timeline(vars) {
  9404. return new Timeline(vars);
  9405. },
  9406. getTweensOf: function getTweensOf(targets, onlyActive) {
  9407. return _globalTimeline.getTweensOf(targets, onlyActive);
  9408. },
  9409. getProperty: function getProperty(target, property, unit, uncache) {
  9410. _isString(target) && (target = toArray(target)[0]);
  9411. var getter = _getCache(target || {}).get,
  9412. format = unit ? _passThrough : _numericIfPossible;
  9413. unit === "native" && (unit = "");
  9414. return !target ? target : !property ? function (property, unit, uncache) {
  9415. return format((_plugins[property] && _plugins[property].get || getter)(target, property, unit, uncache));
  9416. } : format((_plugins[property] && _plugins[property].get || getter)(target, property, unit, uncache));
  9417. },
  9418. quickSetter: function quickSetter(target, property, unit) {
  9419. target = toArray(target);
  9420. if (target.length > 1) {
  9421. var setters = target.map(function (t) {
  9422. return gsap.quickSetter(t, property, unit);
  9423. }),
  9424. l = setters.length;
  9425. return function (value) {
  9426. var i = l;
  9427. while (i--) {
  9428. setters[i](value);
  9429. }
  9430. };
  9431. }
  9432. target = target[0] || {};
  9433. var Plugin = _plugins[property],
  9434. cache = _getCache(target),
  9435. p = cache.harness && (cache.harness.aliases || {})[property] || property,
  9436. setter = Plugin ? function (value) {
  9437. var p = new Plugin();
  9438. _quickTween._pt = 0;
  9439. p.init(target, unit ? value + unit : value, _quickTween, 0, [target]);
  9440. p.render(1, p);
  9441. _quickTween._pt && _renderPropTweens(1, _quickTween);
  9442. } : cache.set(target, p);
  9443. return Plugin ? setter : function (value) {
  9444. return setter(target, p, unit ? value + unit : value, cache, 1);
  9445. };
  9446. },
  9447. quickTo: function quickTo(target, property, vars) {
  9448. var _setDefaults2;
  9449. var tween = gsap.to(target, _setDefaults((_setDefaults2 = {}, _setDefaults2[property] = "+=0.1", _setDefaults2.paused = true, _setDefaults2.stagger = 0, _setDefaults2), vars || {})),
  9450. func = function func(value, start, startIsRelative) {
  9451. return tween.resetTo(property, value, start, startIsRelative);
  9452. };
  9453. func.tween = tween;
  9454. return func;
  9455. },
  9456. isTweening: function isTweening(targets) {
  9457. return _globalTimeline.getTweensOf(targets, true).length > 0;
  9458. },
  9459. defaults: function defaults(value) {
  9460. value && value.ease && (value.ease = _parseEase(value.ease, _defaults.ease));
  9461. return _mergeDeep(_defaults, value || {});
  9462. },
  9463. config: function config(value) {
  9464. return _mergeDeep(_config, value || {});
  9465. },
  9466. registerEffect: function registerEffect(_ref3) {
  9467. var name = _ref3.name,
  9468. effect = _ref3.effect,
  9469. plugins = _ref3.plugins,
  9470. defaults = _ref3.defaults,
  9471. extendTimeline = _ref3.extendTimeline;
  9472. (plugins || "").split(",").forEach(function (pluginName) {
  9473. return pluginName && !_plugins[pluginName] && !_globals[pluginName] && _warn(name + " effect requires " + pluginName + " plugin.");
  9474. });
  9475. _effects[name] = function (targets, vars, tl) {
  9476. return effect(toArray(targets), _setDefaults(vars || {}, defaults), tl);
  9477. };
  9478. if (extendTimeline) {
  9479. Timeline.prototype[name] = function (targets, vars, position) {
  9480. return this.add(_effects[name](targets, _isObject(vars) ? vars : (position = vars) && {}, this), position);
  9481. };
  9482. }
  9483. },
  9484. registerEase: function registerEase(name, ease) {
  9485. _easeMap[name] = _parseEase(ease);
  9486. },
  9487. parseEase: function parseEase(ease, defaultEase) {
  9488. return arguments.length ? _parseEase(ease, defaultEase) : _easeMap;
  9489. },
  9490. getById: function getById(id) {
  9491. return _globalTimeline.getById(id);
  9492. },
  9493. exportRoot: function exportRoot(vars, includeDelayedCalls) {
  9494. if (vars === void 0) {
  9495. vars = {};
  9496. }
  9497. var tl = new Timeline(vars),
  9498. child,
  9499. next;
  9500. tl.smoothChildTiming = _isNotFalse(vars.smoothChildTiming);
  9501. _globalTimeline.remove(tl);
  9502. tl._dp = 0;
  9503. tl._time = tl._tTime = _globalTimeline._time;
  9504. child = _globalTimeline._first;
  9505. while (child) {
  9506. next = child._next;
  9507. if (includeDelayedCalls || !(!child._dur && child instanceof Tween && child.vars.onComplete === child._targets[0])) {
  9508. _addToTimeline(tl, child, child._start - child._delay);
  9509. }
  9510. child = next;
  9511. }
  9512. _addToTimeline(_globalTimeline, tl, 0);
  9513. return tl;
  9514. },
  9515. context: function context(func, scope) {
  9516. return func ? new Context(func, scope) : _context;
  9517. },
  9518. matchMedia: function matchMedia(scope) {
  9519. return new MatchMedia(scope);
  9520. },
  9521. matchMediaRefresh: function matchMediaRefresh() {
  9522. return _media.forEach(function (c) {
  9523. var cond = c.conditions,
  9524. found,
  9525. p;
  9526. for (p in cond) {
  9527. if (cond[p]) {
  9528. cond[p] = false;
  9529. found = 1;
  9530. }
  9531. }
  9532. found && c.revert();
  9533. }) || _onMediaChange();
  9534. },
  9535. addEventListener: function addEventListener(type, callback) {
  9536. var a = _listeners[type] || (_listeners[type] = []);
  9537. ~a.indexOf(callback) || a.push(callback);
  9538. },
  9539. removeEventListener: function removeEventListener(type, callback) {
  9540. var a = _listeners[type],
  9541. i = a && a.indexOf(callback);
  9542. i >= 0 && a.splice(i, 1);
  9543. },
  9544. utils: {
  9545. wrap: wrap,
  9546. wrapYoyo: wrapYoyo,
  9547. distribute: distribute,
  9548. random: random,
  9549. snap: snap,
  9550. normalize: normalize,
  9551. getUnit: getUnit,
  9552. clamp: clamp,
  9553. splitColor: splitColor,
  9554. toArray: toArray,
  9555. selector: selector,
  9556. mapRange: mapRange,
  9557. pipe: pipe,
  9558. unitize: unitize,
  9559. interpolate: interpolate,
  9560. shuffle: shuffle
  9561. },
  9562. install: _install,
  9563. effects: _effects,
  9564. ticker: _ticker,
  9565. updateRoot: Timeline.updateRoot,
  9566. plugins: _plugins,
  9567. globalTimeline: _globalTimeline,
  9568. core: {
  9569. PropTween: PropTween,
  9570. globals: _addGlobal,
  9571. Tween: Tween,
  9572. Timeline: Timeline,
  9573. Animation: Animation,
  9574. getCache: _getCache,
  9575. _removeLinkedListItem: _removeLinkedListItem,
  9576. reverting: function reverting() {
  9577. return _reverting;
  9578. },
  9579. context: function context(toAdd) {
  9580. if (toAdd && _context) {
  9581. _context.data.push(toAdd);
  9582. toAdd._ctx = _context;
  9583. }
  9584. return _context;
  9585. },
  9586. suppressOverwrites: function suppressOverwrites(value) {
  9587. return _suppressOverwrites = value;
  9588. }
  9589. }
  9590. };
  9591. _forEachName("to,from,fromTo,delayedCall,set,killTweensOf", function (name) {
  9592. return _gsap[name] = Tween[name];
  9593. });
  9594. _ticker.add(Timeline.updateRoot);
  9595. _quickTween = _gsap.to({}, {
  9596. duration: 0
  9597. });
  9598. var _getPluginPropTween = function _getPluginPropTween(plugin, prop) {
  9599. var pt = plugin._pt;
  9600. while (pt && pt.p !== prop && pt.op !== prop && pt.fp !== prop) {
  9601. pt = pt._next;
  9602. }
  9603. return pt;
  9604. },
  9605. _addModifiers = function _addModifiers(tween, modifiers) {
  9606. var targets = tween._targets,
  9607. p,
  9608. i,
  9609. pt;
  9610. for (p in modifiers) {
  9611. i = targets.length;
  9612. while (i--) {
  9613. pt = tween._ptLookup[i][p];
  9614. if (pt && (pt = pt.d)) {
  9615. if (pt._pt) {
  9616. pt = _getPluginPropTween(pt, p);
  9617. }
  9618. pt && pt.modifier && pt.modifier(modifiers[p], tween, targets[i], p);
  9619. }
  9620. }
  9621. }
  9622. },
  9623. _buildModifierPlugin = function _buildModifierPlugin(name, modifier) {
  9624. return {
  9625. name: name,
  9626. headless: 1,
  9627. rawVars: 1,
  9628. init: function init(target, vars, tween) {
  9629. tween._onInit = function (tween) {
  9630. var temp, p;
  9631. if (_isString(vars)) {
  9632. temp = {};
  9633. _forEachName(vars, function (name) {
  9634. return temp[name] = 1;
  9635. });
  9636. vars = temp;
  9637. }
  9638. if (modifier) {
  9639. temp = {};
  9640. for (p in vars) {
  9641. temp[p] = modifier(vars[p]);
  9642. }
  9643. vars = temp;
  9644. }
  9645. _addModifiers(tween, vars);
  9646. };
  9647. }
  9648. };
  9649. };
  9650. var gsap = _gsap.registerPlugin({
  9651. name: "attr",
  9652. init: function init(target, vars, tween, index, targets) {
  9653. var p, pt, v;
  9654. this.tween = tween;
  9655. for (p in vars) {
  9656. v = target.getAttribute(p) || "";
  9657. pt = this.add(target, "setAttribute", (v || 0) + "", vars[p], index, targets, 0, 0, p);
  9658. pt.op = p;
  9659. pt.b = v;
  9660. this._props.push(p);
  9661. }
  9662. },
  9663. render: function render(ratio, data) {
  9664. var pt = data._pt;
  9665. while (pt) {
  9666. _reverting ? pt.set(pt.t, pt.p, pt.b, pt) : pt.r(ratio, pt.d);
  9667. pt = pt._next;
  9668. }
  9669. }
  9670. }, {
  9671. name: "endArray",
  9672. headless: 1,
  9673. init: function init(target, value) {
  9674. var i = value.length;
  9675. while (i--) {
  9676. this.add(target, i, target[i] || 0, value[i], 0, 0, 0, 0, 0, 1);
  9677. }
  9678. }
  9679. }, _buildModifierPlugin("roundProps", _roundModifier), _buildModifierPlugin("modifiers"), _buildModifierPlugin("snap", snap)) || _gsap;
  9680. Tween.version = Timeline.version = gsap.version = "3.13.0";
  9681. _coreReady = 1;
  9682. _windowExists() && _wake();
  9683. var Power0 = _easeMap.Power0,
  9684. Power1 = _easeMap.Power1,
  9685. Power2 = _easeMap.Power2,
  9686. Power3 = _easeMap.Power3,
  9687. Power4 = _easeMap.Power4,
  9688. Linear = _easeMap.Linear,
  9689. Quad = _easeMap.Quad,
  9690. Cubic = _easeMap.Cubic,
  9691. Quart = _easeMap.Quart,
  9692. Quint = _easeMap.Quint,
  9693. Strong = _easeMap.Strong,
  9694. Elastic = _easeMap.Elastic,
  9695. Back = _easeMap.Back,
  9696. SteppedEase = _easeMap.SteppedEase,
  9697. Bounce = _easeMap.Bounce,
  9698. Sine = _easeMap.Sine,
  9699. Expo = _easeMap.Expo,
  9700. Circ = _easeMap.Circ;
  9701. var _win$1,
  9702. _doc$1,
  9703. _docElement,
  9704. _pluginInitted,
  9705. _tempDiv,
  9706. _tempDivStyler,
  9707. _recentSetterPlugin,
  9708. _reverting$1,
  9709. _windowExists$1 = function _windowExists() {
  9710. return typeof window !== "undefined";
  9711. },
  9712. _transformProps = {},
  9713. _RAD2DEG = 180 / Math.PI,
  9714. _DEG2RAD = Math.PI / 180,
  9715. _atan2 = Math.atan2,
  9716. _bigNum$1 = 1e8,
  9717. _capsExp = /([A-Z])/g,
  9718. _horizontalExp = /(left|right|width|margin|padding|x)/i,
  9719. _complexExp = /[\s,\(]\S/,
  9720. _propertyAliases = {
  9721. autoAlpha: "opacity,visibility",
  9722. scale: "scaleX,scaleY",
  9723. alpha: "opacity"
  9724. },
  9725. _renderCSSProp = function _renderCSSProp(ratio, data) {
  9726. return data.set(data.t, data.p, Math.round((data.s + data.c * ratio) * 10000) / 10000 + data.u, data);
  9727. },
  9728. _renderPropWithEnd = function _renderPropWithEnd(ratio, data) {
  9729. return data.set(data.t, data.p, ratio === 1 ? data.e : Math.round((data.s + data.c * ratio) * 10000) / 10000 + data.u, data);
  9730. },
  9731. _renderCSSPropWithBeginning = function _renderCSSPropWithBeginning(ratio, data) {
  9732. return data.set(data.t, data.p, ratio ? Math.round((data.s + data.c * ratio) * 10000) / 10000 + data.u : data.b, data);
  9733. },
  9734. _renderRoundedCSSProp = function _renderRoundedCSSProp(ratio, data) {
  9735. var value = data.s + data.c * ratio;
  9736. data.set(data.t, data.p, ~~(value + (value < 0 ? -.5 : .5)) + data.u, data);
  9737. },
  9738. _renderNonTweeningValue = function _renderNonTweeningValue(ratio, data) {
  9739. return data.set(data.t, data.p, ratio ? data.e : data.b, data);
  9740. },
  9741. _renderNonTweeningValueOnlyAtEnd = function _renderNonTweeningValueOnlyAtEnd(ratio, data) {
  9742. return data.set(data.t, data.p, ratio !== 1 ? data.b : data.e, data);
  9743. },
  9744. _setterCSSStyle = function _setterCSSStyle(target, property, value) {
  9745. return target.style[property] = value;
  9746. },
  9747. _setterCSSProp = function _setterCSSProp(target, property, value) {
  9748. return target.style.setProperty(property, value);
  9749. },
  9750. _setterTransform = function _setterTransform(target, property, value) {
  9751. return target._gsap[property] = value;
  9752. },
  9753. _setterScale = function _setterScale(target, property, value) {
  9754. return target._gsap.scaleX = target._gsap.scaleY = value;
  9755. },
  9756. _setterScaleWithRender = function _setterScaleWithRender(target, property, value, data, ratio) {
  9757. var cache = target._gsap;
  9758. cache.scaleX = cache.scaleY = value;
  9759. cache.renderTransform(ratio, cache);
  9760. },
  9761. _setterTransformWithRender = function _setterTransformWithRender(target, property, value, data, ratio) {
  9762. var cache = target._gsap;
  9763. cache[property] = value;
  9764. cache.renderTransform(ratio, cache);
  9765. },
  9766. _transformProp = "transform",
  9767. _transformOriginProp = _transformProp + "Origin",
  9768. _saveStyle = function _saveStyle(property, isNotCSS) {
  9769. var _this = this;
  9770. var target = this.target,
  9771. style = target.style,
  9772. cache = target._gsap;
  9773. if (property in _transformProps && style) {
  9774. this.tfm = this.tfm || {};
  9775. if (property !== "transform") {
  9776. property = _propertyAliases[property] || property;
  9777. ~property.indexOf(",") ? property.split(",").forEach(function (a) {
  9778. return _this.tfm[a] = _get(target, a);
  9779. }) : this.tfm[property] = cache.x ? cache[property] : _get(target, property);
  9780. property === _transformOriginProp && (this.tfm.zOrigin = cache.zOrigin);
  9781. } else {
  9782. return _propertyAliases.transform.split(",").forEach(function (p) {
  9783. return _saveStyle.call(_this, p, isNotCSS);
  9784. });
  9785. }
  9786. if (this.props.indexOf(_transformProp) >= 0) {
  9787. return;
  9788. }
  9789. if (cache.svg) {
  9790. this.svgo = target.getAttribute("data-svg-origin");
  9791. this.props.push(_transformOriginProp, isNotCSS, "");
  9792. }
  9793. property = _transformProp;
  9794. }
  9795. (style || isNotCSS) && this.props.push(property, isNotCSS, style[property]);
  9796. },
  9797. _removeIndependentTransforms = function _removeIndependentTransforms(style) {
  9798. if (style.translate) {
  9799. style.removeProperty("translate");
  9800. style.removeProperty("scale");
  9801. style.removeProperty("rotate");
  9802. }
  9803. },
  9804. _revertStyle = function _revertStyle() {
  9805. var props = this.props,
  9806. target = this.target,
  9807. style = target.style,
  9808. cache = target._gsap,
  9809. i,
  9810. p;
  9811. for (i = 0; i < props.length; i += 3) {
  9812. if (!props[i + 1]) {
  9813. props[i + 2] ? style[props[i]] = props[i + 2] : style.removeProperty(props[i].substr(0, 2) === "--" ? props[i] : props[i].replace(_capsExp, "-$1").toLowerCase());
  9814. } else if (props[i + 1] === 2) {
  9815. target[props[i]](props[i + 2]);
  9816. } else {
  9817. target[props[i]] = props[i + 2];
  9818. }
  9819. }
  9820. if (this.tfm) {
  9821. for (p in this.tfm) {
  9822. cache[p] = this.tfm[p];
  9823. }
  9824. if (cache.svg) {
  9825. cache.renderTransform();
  9826. target.setAttribute("data-svg-origin", this.svgo || "");
  9827. }
  9828. i = _reverting$1();
  9829. if ((!i || !i.isStart) && !style[_transformProp]) {
  9830. _removeIndependentTransforms(style);
  9831. if (cache.zOrigin && style[_transformOriginProp]) {
  9832. style[_transformOriginProp] += " " + cache.zOrigin + "px";
  9833. cache.zOrigin = 0;
  9834. cache.renderTransform();
  9835. }
  9836. cache.uncache = 1;
  9837. }
  9838. }
  9839. },
  9840. _getStyleSaver = function _getStyleSaver(target, properties) {
  9841. var saver = {
  9842. target: target,
  9843. props: [],
  9844. revert: _revertStyle,
  9845. save: _saveStyle
  9846. };
  9847. target._gsap || gsap.core.getCache(target);
  9848. properties && target.style && target.nodeType && properties.split(",").forEach(function (p) {
  9849. return saver.save(p);
  9850. });
  9851. return saver;
  9852. },
  9853. _supports3D,
  9854. _createElement = function _createElement(type, ns) {
  9855. var e = _doc$1.createElementNS ? _doc$1.createElementNS((ns || "http://www.w3.org/1999/xhtml").replace(/^https/, "http"), type) : _doc$1.createElement(type);
  9856. return e && e.style ? e : _doc$1.createElement(type);
  9857. },
  9858. _getComputedProperty = function _getComputedProperty(target, property, skipPrefixFallback) {
  9859. var cs = getComputedStyle(target);
  9860. return cs[property] || cs.getPropertyValue(property.replace(_capsExp, "-$1").toLowerCase()) || cs.getPropertyValue(property) || !skipPrefixFallback && _getComputedProperty(target, _checkPropPrefix(property) || property, 1) || "";
  9861. },
  9862. _prefixes = "O,Moz,ms,Ms,Webkit".split(","),
  9863. _checkPropPrefix = function _checkPropPrefix(property, element, preferPrefix) {
  9864. var e = element || _tempDiv,
  9865. s = e.style,
  9866. i = 5;
  9867. if (property in s && !preferPrefix) {
  9868. return property;
  9869. }
  9870. property = property.charAt(0).toUpperCase() + property.substr(1);
  9871. while (i-- && !(_prefixes[i] + property in s)) {}
  9872. return i < 0 ? null : (i === 3 ? "ms" : i >= 0 ? _prefixes[i] : "") + property;
  9873. },
  9874. _initCore = function _initCore() {
  9875. if (_windowExists$1() && window.document) {
  9876. _win$1 = window;
  9877. _doc$1 = _win$1.document;
  9878. _docElement = _doc$1.documentElement;
  9879. _tempDiv = _createElement("div") || {
  9880. style: {}
  9881. };
  9882. _tempDivStyler = _createElement("div");
  9883. _transformProp = _checkPropPrefix(_transformProp);
  9884. _transformOriginProp = _transformProp + "Origin";
  9885. _tempDiv.style.cssText = "border-width:0;line-height:0;position:absolute;padding:0";
  9886. _supports3D = !!_checkPropPrefix("perspective");
  9887. _reverting$1 = gsap.core.reverting;
  9888. _pluginInitted = 1;
  9889. }
  9890. },
  9891. _getReparentedCloneBBox = function _getReparentedCloneBBox(target) {
  9892. var owner = target.ownerSVGElement,
  9893. svg = _createElement("svg", owner && owner.getAttribute("xmlns") || "http://www.w3.org/2000/svg"),
  9894. clone = target.cloneNode(true),
  9895. bbox;
  9896. clone.style.display = "block";
  9897. svg.appendChild(clone);
  9898. _docElement.appendChild(svg);
  9899. try {
  9900. bbox = clone.getBBox();
  9901. } catch (e) {}
  9902. svg.removeChild(clone);
  9903. _docElement.removeChild(svg);
  9904. return bbox;
  9905. },
  9906. _getAttributeFallbacks = function _getAttributeFallbacks(target, attributesArray) {
  9907. var i = attributesArray.length;
  9908. while (i--) {
  9909. if (target.hasAttribute(attributesArray[i])) {
  9910. return target.getAttribute(attributesArray[i]);
  9911. }
  9912. }
  9913. },
  9914. _getBBox = function _getBBox(target) {
  9915. var bounds, cloned;
  9916. try {
  9917. bounds = target.getBBox();
  9918. } catch (error) {
  9919. bounds = _getReparentedCloneBBox(target);
  9920. cloned = 1;
  9921. }
  9922. bounds && (bounds.width || bounds.height) || cloned || (bounds = _getReparentedCloneBBox(target));
  9923. return bounds && !bounds.width && !bounds.x && !bounds.y ? {
  9924. x: +_getAttributeFallbacks(target, ["x", "cx", "x1"]) || 0,
  9925. y: +_getAttributeFallbacks(target, ["y", "cy", "y1"]) || 0,
  9926. width: 0,
  9927. height: 0
  9928. } : bounds;
  9929. },
  9930. _isSVG = function _isSVG(e) {
  9931. return !!(e.getCTM && (!e.parentNode || e.ownerSVGElement) && _getBBox(e));
  9932. },
  9933. _removeProperty = function _removeProperty(target, property) {
  9934. if (property) {
  9935. var style = target.style,
  9936. first2Chars;
  9937. if (property in _transformProps && property !== _transformOriginProp) {
  9938. property = _transformProp;
  9939. }
  9940. if (style.removeProperty) {
  9941. first2Chars = property.substr(0, 2);
  9942. if (first2Chars === "ms" || property.substr(0, 6) === "webkit") {
  9943. property = "-" + property;
  9944. }
  9945. style.removeProperty(first2Chars === "--" ? property : property.replace(_capsExp, "-$1").toLowerCase());
  9946. } else {
  9947. style.removeAttribute(property);
  9948. }
  9949. }
  9950. },
  9951. _addNonTweeningPT = function _addNonTweeningPT(plugin, target, property, beginning, end, onlySetAtEnd) {
  9952. var pt = new PropTween(plugin._pt, target, property, 0, 1, onlySetAtEnd ? _renderNonTweeningValueOnlyAtEnd : _renderNonTweeningValue);
  9953. plugin._pt = pt;
  9954. pt.b = beginning;
  9955. pt.e = end;
  9956. plugin._props.push(property);
  9957. return pt;
  9958. },
  9959. _nonConvertibleUnits = {
  9960. deg: 1,
  9961. rad: 1,
  9962. turn: 1
  9963. },
  9964. _nonStandardLayouts = {
  9965. grid: 1,
  9966. flex: 1
  9967. },
  9968. _convertToUnit = function _convertToUnit(target, property, value, unit) {
  9969. var curValue = parseFloat(value) || 0,
  9970. curUnit = (value + "").trim().substr((curValue + "").length) || "px",
  9971. style = _tempDiv.style,
  9972. horizontal = _horizontalExp.test(property),
  9973. isRootSVG = target.tagName.toLowerCase() === "svg",
  9974. measureProperty = (isRootSVG ? "client" : "offset") + (horizontal ? "Width" : "Height"),
  9975. amount = 100,
  9976. toPixels = unit === "px",
  9977. toPercent = unit === "%",
  9978. px,
  9979. parent,
  9980. cache,
  9981. isSVG;
  9982. if (unit === curUnit || !curValue || _nonConvertibleUnits[unit] || _nonConvertibleUnits[curUnit]) {
  9983. return curValue;
  9984. }
  9985. curUnit !== "px" && !toPixels && (curValue = _convertToUnit(target, property, value, "px"));
  9986. isSVG = target.getCTM && _isSVG(target);
  9987. if ((toPercent || curUnit === "%") && (_transformProps[property] || ~property.indexOf("adius"))) {
  9988. px = isSVG ? target.getBBox()[horizontal ? "width" : "height"] : target[measureProperty];
  9989. return _round(toPercent ? curValue / px * amount : curValue / 100 * px);
  9990. }
  9991. style[horizontal ? "width" : "height"] = amount + (toPixels ? curUnit : unit);
  9992. parent = unit !== "rem" && ~property.indexOf("adius") || unit === "em" && target.appendChild && !isRootSVG ? target : target.parentNode;
  9993. if (isSVG) {
  9994. parent = (target.ownerSVGElement || {}).parentNode;
  9995. }
  9996. if (!parent || parent === _doc$1 || !parent.appendChild) {
  9997. parent = _doc$1.body;
  9998. }
  9999. cache = parent._gsap;
  10000. if (cache && toPercent && cache.width && horizontal && cache.time === _ticker.time && !cache.uncache) {
  10001. return _round(curValue / cache.width * amount);
  10002. } else {
  10003. if (toPercent && (property === "height" || property === "width")) {
  10004. var v = target.style[property];
  10005. target.style[property] = amount + unit;
  10006. px = target[measureProperty];
  10007. v ? target.style[property] = v : _removeProperty(target, property);
  10008. } else {
  10009. (toPercent || curUnit === "%") && !_nonStandardLayouts[_getComputedProperty(parent, "display")] && (style.position = _getComputedProperty(target, "position"));
  10010. parent === target && (style.position = "static");
  10011. parent.appendChild(_tempDiv);
  10012. px = _tempDiv[measureProperty];
  10013. parent.removeChild(_tempDiv);
  10014. style.position = "absolute";
  10015. }
  10016. if (horizontal && toPercent) {
  10017. cache = _getCache(parent);
  10018. cache.time = _ticker.time;
  10019. cache.width = parent[measureProperty];
  10020. }
  10021. }
  10022. return _round(toPixels ? px * curValue / amount : px && curValue ? amount / px * curValue : 0);
  10023. },
  10024. _get = function _get(target, property, unit, uncache) {
  10025. var value;
  10026. _pluginInitted || _initCore();
  10027. if (property in _propertyAliases && property !== "transform") {
  10028. property = _propertyAliases[property];
  10029. if (~property.indexOf(",")) {
  10030. property = property.split(",")[0];
  10031. }
  10032. }
  10033. if (_transformProps[property] && property !== "transform") {
  10034. value = _parseTransform(target, uncache);
  10035. value = property !== "transformOrigin" ? value[property] : value.svg ? value.origin : _firstTwoOnly(_getComputedProperty(target, _transformOriginProp)) + " " + value.zOrigin + "px";
  10036. } else {
  10037. value = target.style[property];
  10038. if (!value || value === "auto" || uncache || ~(value + "").indexOf("calc(")) {
  10039. value = _specialProps[property] && _specialProps[property](target, property, unit) || _getComputedProperty(target, property) || _getProperty(target, property) || (property === "opacity" ? 1 : 0);
  10040. }
  10041. }
  10042. return unit && !~(value + "").trim().indexOf(" ") ? _convertToUnit(target, property, value, unit) + unit : value;
  10043. },
  10044. _tweenComplexCSSString = function _tweenComplexCSSString(target, prop, start, end) {
  10045. if (!start || start === "none") {
  10046. var p = _checkPropPrefix(prop, target, 1),
  10047. s = p && _getComputedProperty(target, p, 1);
  10048. if (s && s !== start) {
  10049. prop = p;
  10050. start = s;
  10051. } else if (prop === "borderColor") {
  10052. start = _getComputedProperty(target, "borderTopColor");
  10053. }
  10054. }
  10055. var pt = new PropTween(this._pt, target.style, prop, 0, 1, _renderComplexString),
  10056. index = 0,
  10057. matchIndex = 0,
  10058. a,
  10059. result,
  10060. startValues,
  10061. startNum,
  10062. color,
  10063. startValue,
  10064. endValue,
  10065. endNum,
  10066. chunk,
  10067. endUnit,
  10068. startUnit,
  10069. endValues;
  10070. pt.b = start;
  10071. pt.e = end;
  10072. start += "";
  10073. end += "";
  10074. if (end.substring(0, 6) === "var(--") {
  10075. end = _getComputedProperty(target, end.substring(4, end.indexOf(")")));
  10076. }
  10077. if (end === "auto") {
  10078. startValue = target.style[prop];
  10079. target.style[prop] = end;
  10080. end = _getComputedProperty(target, prop) || end;
  10081. startValue ? target.style[prop] = startValue : _removeProperty(target, prop);
  10082. }
  10083. a = [start, end];
  10084. _colorStringFilter(a);
  10085. start = a[0];
  10086. end = a[1];
  10087. startValues = start.match(_numWithUnitExp) || [];
  10088. endValues = end.match(_numWithUnitExp) || [];
  10089. if (endValues.length) {
  10090. while (result = _numWithUnitExp.exec(end)) {
  10091. endValue = result[0];
  10092. chunk = end.substring(index, result.index);
  10093. if (color) {
  10094. color = (color + 1) % 5;
  10095. } else if (chunk.substr(-5) === "rgba(" || chunk.substr(-5) === "hsla(") {
  10096. color = 1;
  10097. }
  10098. if (endValue !== (startValue = startValues[matchIndex++] || "")) {
  10099. startNum = parseFloat(startValue) || 0;
  10100. startUnit = startValue.substr((startNum + "").length);
  10101. endValue.charAt(1) === "=" && (endValue = _parseRelative(startNum, endValue) + startUnit);
  10102. endNum = parseFloat(endValue);
  10103. endUnit = endValue.substr((endNum + "").length);
  10104. index = _numWithUnitExp.lastIndex - endUnit.length;
  10105. if (!endUnit) {
  10106. endUnit = endUnit || _config.units[prop] || startUnit;
  10107. if (index === end.length) {
  10108. end += endUnit;
  10109. pt.e += endUnit;
  10110. }
  10111. }
  10112. if (startUnit !== endUnit) {
  10113. startNum = _convertToUnit(target, prop, startValue, endUnit) || 0;
  10114. }
  10115. pt._pt = {
  10116. _next: pt._pt,
  10117. p: chunk || matchIndex === 1 ? chunk : ",",
  10118. s: startNum,
  10119. c: endNum - startNum,
  10120. m: color && color < 4 || prop === "zIndex" ? Math.round : 0
  10121. };
  10122. }
  10123. }
  10124. pt.c = index < end.length ? end.substring(index, end.length) : "";
  10125. } else {
  10126. pt.r = prop === "display" && end === "none" ? _renderNonTweeningValueOnlyAtEnd : _renderNonTweeningValue;
  10127. }
  10128. _relExp.test(end) && (pt.e = 0);
  10129. this._pt = pt;
  10130. return pt;
  10131. },
  10132. _keywordToPercent = {
  10133. top: "0%",
  10134. bottom: "100%",
  10135. left: "0%",
  10136. right: "100%",
  10137. center: "50%"
  10138. },
  10139. _convertKeywordsToPercentages = function _convertKeywordsToPercentages(value) {
  10140. var split = value.split(" "),
  10141. x = split[0],
  10142. y = split[1] || "50%";
  10143. if (x === "top" || x === "bottom" || y === "left" || y === "right") {
  10144. value = x;
  10145. x = y;
  10146. y = value;
  10147. }
  10148. split[0] = _keywordToPercent[x] || x;
  10149. split[1] = _keywordToPercent[y] || y;
  10150. return split.join(" ");
  10151. },
  10152. _renderClearProps = function _renderClearProps(ratio, data) {
  10153. if (data.tween && data.tween._time === data.tween._dur) {
  10154. var target = data.t,
  10155. style = target.style,
  10156. props = data.u,
  10157. cache = target._gsap,
  10158. prop,
  10159. clearTransforms,
  10160. i;
  10161. if (props === "all" || props === true) {
  10162. style.cssText = "";
  10163. clearTransforms = 1;
  10164. } else {
  10165. props = props.split(",");
  10166. i = props.length;
  10167. while (--i > -1) {
  10168. prop = props[i];
  10169. if (_transformProps[prop]) {
  10170. clearTransforms = 1;
  10171. prop = prop === "transformOrigin" ? _transformOriginProp : _transformProp;
  10172. }
  10173. _removeProperty(target, prop);
  10174. }
  10175. }
  10176. if (clearTransforms) {
  10177. _removeProperty(target, _transformProp);
  10178. if (cache) {
  10179. cache.svg && target.removeAttribute("transform");
  10180. style.scale = style.rotate = style.translate = "none";
  10181. _parseTransform(target, 1);
  10182. cache.uncache = 1;
  10183. _removeIndependentTransforms(style);
  10184. }
  10185. }
  10186. }
  10187. },
  10188. _specialProps = {
  10189. clearProps: function clearProps(plugin, target, property, endValue, tween) {
  10190. if (tween.data !== "isFromStart") {
  10191. var pt = plugin._pt = new PropTween(plugin._pt, target, property, 0, 0, _renderClearProps);
  10192. pt.u = endValue;
  10193. pt.pr = -10;
  10194. pt.tween = tween;
  10195. plugin._props.push(property);
  10196. return 1;
  10197. }
  10198. }
  10199. },
  10200. _identity2DMatrix = [1, 0, 0, 1, 0, 0],
  10201. _rotationalProperties = {},
  10202. _isNullTransform = function _isNullTransform(value) {
  10203. return value === "matrix(1, 0, 0, 1, 0, 0)" || value === "none" || !value;
  10204. },
  10205. _getComputedTransformMatrixAsArray = function _getComputedTransformMatrixAsArray(target) {
  10206. var matrixString = _getComputedProperty(target, _transformProp);
  10207. return _isNullTransform(matrixString) ? _identity2DMatrix : matrixString.substr(7).match(_numExp).map(_round);
  10208. },
  10209. _getMatrix = function _getMatrix(target, force2D) {
  10210. var cache = target._gsap || _getCache(target),
  10211. style = target.style,
  10212. matrix = _getComputedTransformMatrixAsArray(target),
  10213. parent,
  10214. nextSibling,
  10215. temp,
  10216. addedToDOM;
  10217. if (cache.svg && target.getAttribute("transform")) {
  10218. temp = target.transform.baseVal.consolidate().matrix;
  10219. matrix = [temp.a, temp.b, temp.c, temp.d, temp.e, temp.f];
  10220. return matrix.join(",") === "1,0,0,1,0,0" ? _identity2DMatrix : matrix;
  10221. } else if (matrix === _identity2DMatrix && !target.offsetParent && target !== _docElement && !cache.svg) {
  10222. temp = style.display;
  10223. style.display = "block";
  10224. parent = target.parentNode;
  10225. if (!parent || !target.offsetParent && !target.getBoundingClientRect().width) {
  10226. addedToDOM = 1;
  10227. nextSibling = target.nextElementSibling;
  10228. _docElement.appendChild(target);
  10229. }
  10230. matrix = _getComputedTransformMatrixAsArray(target);
  10231. temp ? style.display = temp : _removeProperty(target, "display");
  10232. if (addedToDOM) {
  10233. nextSibling ? parent.insertBefore(target, nextSibling) : parent ? parent.appendChild(target) : _docElement.removeChild(target);
  10234. }
  10235. }
  10236. return force2D && matrix.length > 6 ? [matrix[0], matrix[1], matrix[4], matrix[5], matrix[12], matrix[13]] : matrix;
  10237. },
  10238. _applySVGOrigin = function _applySVGOrigin(target, origin, originIsAbsolute, smooth, matrixArray, pluginToAddPropTweensTo) {
  10239. var cache = target._gsap,
  10240. matrix = matrixArray || _getMatrix(target, true),
  10241. xOriginOld = cache.xOrigin || 0,
  10242. yOriginOld = cache.yOrigin || 0,
  10243. xOffsetOld = cache.xOffset || 0,
  10244. yOffsetOld = cache.yOffset || 0,
  10245. a = matrix[0],
  10246. b = matrix[1],
  10247. c = matrix[2],
  10248. d = matrix[3],
  10249. tx = matrix[4],
  10250. ty = matrix[5],
  10251. originSplit = origin.split(" "),
  10252. xOrigin = parseFloat(originSplit[0]) || 0,
  10253. yOrigin = parseFloat(originSplit[1]) || 0,
  10254. bounds,
  10255. determinant,
  10256. x,
  10257. y;
  10258. if (!originIsAbsolute) {
  10259. bounds = _getBBox(target);
  10260. xOrigin = bounds.x + (~originSplit[0].indexOf("%") ? xOrigin / 100 * bounds.width : xOrigin);
  10261. yOrigin = bounds.y + (~(originSplit[1] || originSplit[0]).indexOf("%") ? yOrigin / 100 * bounds.height : yOrigin);
  10262. } else if (matrix !== _identity2DMatrix && (determinant = a * d - b * c)) {
  10263. x = xOrigin * (d / determinant) + yOrigin * (-c / determinant) + (c * ty - d * tx) / determinant;
  10264. y = xOrigin * (-b / determinant) + yOrigin * (a / determinant) - (a * ty - b * tx) / determinant;
  10265. xOrigin = x;
  10266. yOrigin = y;
  10267. }
  10268. if (smooth || smooth !== false && cache.smooth) {
  10269. tx = xOrigin - xOriginOld;
  10270. ty = yOrigin - yOriginOld;
  10271. cache.xOffset = xOffsetOld + (tx * a + ty * c) - tx;
  10272. cache.yOffset = yOffsetOld + (tx * b + ty * d) - ty;
  10273. } else {
  10274. cache.xOffset = cache.yOffset = 0;
  10275. }
  10276. cache.xOrigin = xOrigin;
  10277. cache.yOrigin = yOrigin;
  10278. cache.smooth = !!smooth;
  10279. cache.origin = origin;
  10280. cache.originIsAbsolute = !!originIsAbsolute;
  10281. target.style[_transformOriginProp] = "0px 0px";
  10282. if (pluginToAddPropTweensTo) {
  10283. _addNonTweeningPT(pluginToAddPropTweensTo, cache, "xOrigin", xOriginOld, xOrigin);
  10284. _addNonTweeningPT(pluginToAddPropTweensTo, cache, "yOrigin", yOriginOld, yOrigin);
  10285. _addNonTweeningPT(pluginToAddPropTweensTo, cache, "xOffset", xOffsetOld, cache.xOffset);
  10286. _addNonTweeningPT(pluginToAddPropTweensTo, cache, "yOffset", yOffsetOld, cache.yOffset);
  10287. }
  10288. target.setAttribute("data-svg-origin", xOrigin + " " + yOrigin);
  10289. },
  10290. _parseTransform = function _parseTransform(target, uncache) {
  10291. var cache = target._gsap || new GSCache(target);
  10292. if ("x" in cache && !uncache && !cache.uncache) {
  10293. return cache;
  10294. }
  10295. var style = target.style,
  10296. invertedScaleX = cache.scaleX < 0,
  10297. px = "px",
  10298. deg = "deg",
  10299. cs = getComputedStyle(target),
  10300. origin = _getComputedProperty(target, _transformOriginProp) || "0",
  10301. x,
  10302. y,
  10303. z,
  10304. scaleX,
  10305. scaleY,
  10306. rotation,
  10307. rotationX,
  10308. rotationY,
  10309. skewX,
  10310. skewY,
  10311. perspective,
  10312. xOrigin,
  10313. yOrigin,
  10314. matrix,
  10315. angle,
  10316. cos,
  10317. sin,
  10318. a,
  10319. b,
  10320. c,
  10321. d,
  10322. a12,
  10323. a22,
  10324. t1,
  10325. t2,
  10326. t3,
  10327. a13,
  10328. a23,
  10329. a33,
  10330. a42,
  10331. a43,
  10332. a32;
  10333. x = y = z = rotation = rotationX = rotationY = skewX = skewY = perspective = 0;
  10334. scaleX = scaleY = 1;
  10335. cache.svg = !!(target.getCTM && _isSVG(target));
  10336. if (cs.translate) {
  10337. if (cs.translate !== "none" || cs.scale !== "none" || cs.rotate !== "none") {
  10338. 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] : "");
  10339. }
  10340. style.scale = style.rotate = style.translate = "none";
  10341. }
  10342. matrix = _getMatrix(target, cache.svg);
  10343. if (cache.svg) {
  10344. if (cache.uncache) {
  10345. t2 = target.getBBox();
  10346. origin = cache.xOrigin - t2.x + "px " + (cache.yOrigin - t2.y) + "px";
  10347. t1 = "";
  10348. } else {
  10349. t1 = !uncache && target.getAttribute("data-svg-origin");
  10350. }
  10351. _applySVGOrigin(target, t1 || origin, !!t1 || cache.originIsAbsolute, cache.smooth !== false, matrix);
  10352. }
  10353. xOrigin = cache.xOrigin || 0;
  10354. yOrigin = cache.yOrigin || 0;
  10355. if (matrix !== _identity2DMatrix) {
  10356. a = matrix[0];
  10357. b = matrix[1];
  10358. c = matrix[2];
  10359. d = matrix[3];
  10360. x = a12 = matrix[4];
  10361. y = a22 = matrix[5];
  10362. if (matrix.length === 6) {
  10363. scaleX = Math.sqrt(a * a + b * b);
  10364. scaleY = Math.sqrt(d * d + c * c);
  10365. rotation = a || b ? _atan2(b, a) * _RAD2DEG : 0;
  10366. skewX = c || d ? _atan2(c, d) * _RAD2DEG + rotation : 0;
  10367. skewX && (scaleY *= Math.abs(Math.cos(skewX * _DEG2RAD)));
  10368. if (cache.svg) {
  10369. x -= xOrigin - (xOrigin * a + yOrigin * c);
  10370. y -= yOrigin - (xOrigin * b + yOrigin * d);
  10371. }
  10372. } else {
  10373. a32 = matrix[6];
  10374. a42 = matrix[7];
  10375. a13 = matrix[8];
  10376. a23 = matrix[9];
  10377. a33 = matrix[10];
  10378. a43 = matrix[11];
  10379. x = matrix[12];
  10380. y = matrix[13];
  10381. z = matrix[14];
  10382. angle = _atan2(a32, a33);
  10383. rotationX = angle * _RAD2DEG;
  10384. if (angle) {
  10385. cos = Math.cos(-angle);
  10386. sin = Math.sin(-angle);
  10387. t1 = a12 * cos + a13 * sin;
  10388. t2 = a22 * cos + a23 * sin;
  10389. t3 = a32 * cos + a33 * sin;
  10390. a13 = a12 * -sin + a13 * cos;
  10391. a23 = a22 * -sin + a23 * cos;
  10392. a33 = a32 * -sin + a33 * cos;
  10393. a43 = a42 * -sin + a43 * cos;
  10394. a12 = t1;
  10395. a22 = t2;
  10396. a32 = t3;
  10397. }
  10398. angle = _atan2(-c, a33);
  10399. rotationY = angle * _RAD2DEG;
  10400. if (angle) {
  10401. cos = Math.cos(-angle);
  10402. sin = Math.sin(-angle);
  10403. t1 = a * cos - a13 * sin;
  10404. t2 = b * cos - a23 * sin;
  10405. t3 = c * cos - a33 * sin;
  10406. a43 = d * sin + a43 * cos;
  10407. a = t1;
  10408. b = t2;
  10409. c = t3;
  10410. }
  10411. angle = _atan2(b, a);
  10412. rotation = angle * _RAD2DEG;
  10413. if (angle) {
  10414. cos = Math.cos(angle);
  10415. sin = Math.sin(angle);
  10416. t1 = a * cos + b * sin;
  10417. t2 = a12 * cos + a22 * sin;
  10418. b = b * cos - a * sin;
  10419. a22 = a22 * cos - a12 * sin;
  10420. a = t1;
  10421. a12 = t2;
  10422. }
  10423. if (rotationX && Math.abs(rotationX) + Math.abs(rotation) > 359.9) {
  10424. rotationX = rotation = 0;
  10425. rotationY = 180 - rotationY;
  10426. }
  10427. scaleX = _round(Math.sqrt(a * a + b * b + c * c));
  10428. scaleY = _round(Math.sqrt(a22 * a22 + a32 * a32));
  10429. angle = _atan2(a12, a22);
  10430. skewX = Math.abs(angle) > 0.0002 ? angle * _RAD2DEG : 0;
  10431. perspective = a43 ? 1 / (a43 < 0 ? -a43 : a43) : 0;
  10432. }
  10433. if (cache.svg) {
  10434. t1 = target.getAttribute("transform");
  10435. cache.forceCSS = target.setAttribute("transform", "") || !_isNullTransform(_getComputedProperty(target, _transformProp));
  10436. t1 && target.setAttribute("transform", t1);
  10437. }
  10438. }
  10439. if (Math.abs(skewX) > 90 && Math.abs(skewX) < 270) {
  10440. if (invertedScaleX) {
  10441. scaleX *= -1;
  10442. skewX += rotation <= 0 ? 180 : -180;
  10443. rotation += rotation <= 0 ? 180 : -180;
  10444. } else {
  10445. scaleY *= -1;
  10446. skewX += skewX <= 0 ? 180 : -180;
  10447. }
  10448. }
  10449. uncache = uncache || cache.uncache;
  10450. 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;
  10451. 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;
  10452. cache.z = z + px;
  10453. cache.scaleX = _round(scaleX);
  10454. cache.scaleY = _round(scaleY);
  10455. cache.rotation = _round(rotation) + deg;
  10456. cache.rotationX = _round(rotationX) + deg;
  10457. cache.rotationY = _round(rotationY) + deg;
  10458. cache.skewX = skewX + deg;
  10459. cache.skewY = skewY + deg;
  10460. cache.transformPerspective = perspective + px;
  10461. if (cache.zOrigin = parseFloat(origin.split(" ")[2]) || !uncache && cache.zOrigin || 0) {
  10462. style[_transformOriginProp] = _firstTwoOnly(origin);
  10463. }
  10464. cache.xOffset = cache.yOffset = 0;
  10465. cache.force3D = _config.force3D;
  10466. cache.renderTransform = cache.svg ? _renderSVGTransforms : _supports3D ? _renderCSSTransforms : _renderNon3DTransforms;
  10467. cache.uncache = 0;
  10468. return cache;
  10469. },
  10470. _firstTwoOnly = function _firstTwoOnly(value) {
  10471. return (value = value.split(" "))[0] + " " + value[1];
  10472. },
  10473. _addPxTranslate = function _addPxTranslate(target, start, value) {
  10474. var unit = getUnit(start);
  10475. return _round(parseFloat(start) + parseFloat(_convertToUnit(target, "x", value + "px", unit))) + unit;
  10476. },
  10477. _renderNon3DTransforms = function _renderNon3DTransforms(ratio, cache) {
  10478. cache.z = "0px";
  10479. cache.rotationY = cache.rotationX = "0deg";
  10480. cache.force3D = 0;
  10481. _renderCSSTransforms(ratio, cache);
  10482. },
  10483. _zeroDeg = "0deg",
  10484. _zeroPx = "0px",
  10485. _endParenthesis = ") ",
  10486. _renderCSSTransforms = function _renderCSSTransforms(ratio, cache) {
  10487. var _ref = cache || this,
  10488. xPercent = _ref.xPercent,
  10489. yPercent = _ref.yPercent,
  10490. x = _ref.x,
  10491. y = _ref.y,
  10492. z = _ref.z,
  10493. rotation = _ref.rotation,
  10494. rotationY = _ref.rotationY,
  10495. rotationX = _ref.rotationX,
  10496. skewX = _ref.skewX,
  10497. skewY = _ref.skewY,
  10498. scaleX = _ref.scaleX,
  10499. scaleY = _ref.scaleY,
  10500. transformPerspective = _ref.transformPerspective,
  10501. force3D = _ref.force3D,
  10502. target = _ref.target,
  10503. zOrigin = _ref.zOrigin,
  10504. transforms = "",
  10505. use3D = force3D === "auto" && ratio && ratio !== 1 || force3D === true;
  10506. if (zOrigin && (rotationX !== _zeroDeg || rotationY !== _zeroDeg)) {
  10507. var angle = parseFloat(rotationY) * _DEG2RAD,
  10508. a13 = Math.sin(angle),
  10509. a33 = Math.cos(angle),
  10510. cos;
  10511. angle = parseFloat(rotationX) * _DEG2RAD;
  10512. cos = Math.cos(angle);
  10513. x = _addPxTranslate(target, x, a13 * cos * -zOrigin);
  10514. y = _addPxTranslate(target, y, -Math.sin(angle) * -zOrigin);
  10515. z = _addPxTranslate(target, z, a33 * cos * -zOrigin + zOrigin);
  10516. }
  10517. if (transformPerspective !== _zeroPx) {
  10518. transforms += "perspective(" + transformPerspective + _endParenthesis;
  10519. }
  10520. if (xPercent || yPercent) {
  10521. transforms += "translate(" + xPercent + "%, " + yPercent + "%) ";
  10522. }
  10523. if (use3D || x !== _zeroPx || y !== _zeroPx || z !== _zeroPx) {
  10524. transforms += z !== _zeroPx || use3D ? "translate3d(" + x + ", " + y + ", " + z + ") " : "translate(" + x + ", " + y + _endParenthesis;
  10525. }
  10526. if (rotation !== _zeroDeg) {
  10527. transforms += "rotate(" + rotation + _endParenthesis;
  10528. }
  10529. if (rotationY !== _zeroDeg) {
  10530. transforms += "rotateY(" + rotationY + _endParenthesis;
  10531. }
  10532. if (rotationX !== _zeroDeg) {
  10533. transforms += "rotateX(" + rotationX + _endParenthesis;
  10534. }
  10535. if (skewX !== _zeroDeg || skewY !== _zeroDeg) {
  10536. transforms += "skew(" + skewX + ", " + skewY + _endParenthesis;
  10537. }
  10538. if (scaleX !== 1 || scaleY !== 1) {
  10539. transforms += "scale(" + scaleX + ", " + scaleY + _endParenthesis;
  10540. }
  10541. target.style[_transformProp] = transforms || "translate(0, 0)";
  10542. },
  10543. _renderSVGTransforms = function _renderSVGTransforms(ratio, cache) {
  10544. var _ref2 = cache || this,
  10545. xPercent = _ref2.xPercent,
  10546. yPercent = _ref2.yPercent,
  10547. x = _ref2.x,
  10548. y = _ref2.y,
  10549. rotation = _ref2.rotation,
  10550. skewX = _ref2.skewX,
  10551. skewY = _ref2.skewY,
  10552. scaleX = _ref2.scaleX,
  10553. scaleY = _ref2.scaleY,
  10554. target = _ref2.target,
  10555. xOrigin = _ref2.xOrigin,
  10556. yOrigin = _ref2.yOrigin,
  10557. xOffset = _ref2.xOffset,
  10558. yOffset = _ref2.yOffset,
  10559. forceCSS = _ref2.forceCSS,
  10560. tx = parseFloat(x),
  10561. ty = parseFloat(y),
  10562. a11,
  10563. a21,
  10564. a12,
  10565. a22,
  10566. temp;
  10567. rotation = parseFloat(rotation);
  10568. skewX = parseFloat(skewX);
  10569. skewY = parseFloat(skewY);
  10570. if (skewY) {
  10571. skewY = parseFloat(skewY);
  10572. skewX += skewY;
  10573. rotation += skewY;
  10574. }
  10575. if (rotation || skewX) {
  10576. rotation *= _DEG2RAD;
  10577. skewX *= _DEG2RAD;
  10578. a11 = Math.cos(rotation) * scaleX;
  10579. a21 = Math.sin(rotation) * scaleX;
  10580. a12 = Math.sin(rotation - skewX) * -scaleY;
  10581. a22 = Math.cos(rotation - skewX) * scaleY;
  10582. if (skewX) {
  10583. skewY *= _DEG2RAD;
  10584. temp = Math.tan(skewX - skewY);
  10585. temp = Math.sqrt(1 + temp * temp);
  10586. a12 *= temp;
  10587. a22 *= temp;
  10588. if (skewY) {
  10589. temp = Math.tan(skewY);
  10590. temp = Math.sqrt(1 + temp * temp);
  10591. a11 *= temp;
  10592. a21 *= temp;
  10593. }
  10594. }
  10595. a11 = _round(a11);
  10596. a21 = _round(a21);
  10597. a12 = _round(a12);
  10598. a22 = _round(a22);
  10599. } else {
  10600. a11 = scaleX;
  10601. a22 = scaleY;
  10602. a21 = a12 = 0;
  10603. }
  10604. if (tx && !~(x + "").indexOf("px") || ty && !~(y + "").indexOf("px")) {
  10605. tx = _convertToUnit(target, "x", x, "px");
  10606. ty = _convertToUnit(target, "y", y, "px");
  10607. }
  10608. if (xOrigin || yOrigin || xOffset || yOffset) {
  10609. tx = _round(tx + xOrigin - (xOrigin * a11 + yOrigin * a12) + xOffset);
  10610. ty = _round(ty + yOrigin - (xOrigin * a21 + yOrigin * a22) + yOffset);
  10611. }
  10612. if (xPercent || yPercent) {
  10613. temp = target.getBBox();
  10614. tx = _round(tx + xPercent / 100 * temp.width);
  10615. ty = _round(ty + yPercent / 100 * temp.height);
  10616. }
  10617. temp = "matrix(" + a11 + "," + a21 + "," + a12 + "," + a22 + "," + tx + "," + ty + ")";
  10618. target.setAttribute("transform", temp);
  10619. forceCSS && (target.style[_transformProp] = temp);
  10620. },
  10621. _addRotationalPropTween = function _addRotationalPropTween(plugin, target, property, startNum, endValue) {
  10622. var cap = 360,
  10623. isString = _isString(endValue),
  10624. endNum = parseFloat(endValue) * (isString && ~endValue.indexOf("rad") ? _RAD2DEG : 1),
  10625. change = endNum - startNum,
  10626. finalValue = startNum + change + "deg",
  10627. direction,
  10628. pt;
  10629. if (isString) {
  10630. direction = endValue.split("_")[1];
  10631. if (direction === "short") {
  10632. change %= cap;
  10633. if (change !== change % (cap / 2)) {
  10634. change += change < 0 ? cap : -cap;
  10635. }
  10636. }
  10637. if (direction === "cw" && change < 0) {
  10638. change = (change + cap * _bigNum$1) % cap - ~~(change / cap) * cap;
  10639. } else if (direction === "ccw" && change > 0) {
  10640. change = (change - cap * _bigNum$1) % cap - ~~(change / cap) * cap;
  10641. }
  10642. }
  10643. plugin._pt = pt = new PropTween(plugin._pt, target, property, startNum, change, _renderPropWithEnd);
  10644. pt.e = finalValue;
  10645. pt.u = "deg";
  10646. plugin._props.push(property);
  10647. return pt;
  10648. },
  10649. _assign = function _assign(target, source) {
  10650. for (var p in source) {
  10651. target[p] = source[p];
  10652. }
  10653. return target;
  10654. },
  10655. _addRawTransformPTs = function _addRawTransformPTs(plugin, transforms, target) {
  10656. var startCache = _assign({}, target._gsap),
  10657. exclude = "perspective,force3D,transformOrigin,svgOrigin",
  10658. style = target.style,
  10659. endCache,
  10660. p,
  10661. startValue,
  10662. endValue,
  10663. startNum,
  10664. endNum,
  10665. startUnit,
  10666. endUnit;
  10667. if (startCache.svg) {
  10668. startValue = target.getAttribute("transform");
  10669. target.setAttribute("transform", "");
  10670. style[_transformProp] = transforms;
  10671. endCache = _parseTransform(target, 1);
  10672. _removeProperty(target, _transformProp);
  10673. target.setAttribute("transform", startValue);
  10674. } else {
  10675. startValue = getComputedStyle(target)[_transformProp];
  10676. style[_transformProp] = transforms;
  10677. endCache = _parseTransform(target, 1);
  10678. style[_transformProp] = startValue;
  10679. }
  10680. for (p in _transformProps) {
  10681. startValue = startCache[p];
  10682. endValue = endCache[p];
  10683. if (startValue !== endValue && exclude.indexOf(p) < 0) {
  10684. startUnit = getUnit(startValue);
  10685. endUnit = getUnit(endValue);
  10686. startNum = startUnit !== endUnit ? _convertToUnit(target, p, startValue, endUnit) : parseFloat(startValue);
  10687. endNum = parseFloat(endValue);
  10688. plugin._pt = new PropTween(plugin._pt, endCache, p, startNum, endNum - startNum, _renderCSSProp);
  10689. plugin._pt.u = endUnit || 0;
  10690. plugin._props.push(p);
  10691. }
  10692. }
  10693. _assign(endCache, startCache);
  10694. };
  10695. _forEachName("padding,margin,Width,Radius", function (name, index) {
  10696. var t = "Top",
  10697. r = "Right",
  10698. b = "Bottom",
  10699. l = "Left",
  10700. props = (index < 3 ? [t, r, b, l] : [t + l, t + r, b + r, b + l]).map(function (side) {
  10701. return index < 2 ? name + side : "border" + side + name;
  10702. });
  10703. _specialProps[index > 1 ? "border" + name : name] = function (plugin, target, property, endValue, tween) {
  10704. var a, vars;
  10705. if (arguments.length < 4) {
  10706. a = props.map(function (prop) {
  10707. return _get(plugin, prop, property);
  10708. });
  10709. vars = a.join(" ");
  10710. return vars.split(a[0]).length === 5 ? a[0] : vars;
  10711. }
  10712. a = (endValue + "").split(" ");
  10713. vars = {};
  10714. props.forEach(function (prop, i) {
  10715. return vars[prop] = a[i] = a[i] || a[(i - 1) / 2 | 0];
  10716. });
  10717. plugin.init(target, vars, tween);
  10718. };
  10719. });
  10720. var CSSPlugin = {
  10721. name: "css",
  10722. register: _initCore,
  10723. targetTest: function targetTest(target) {
  10724. return target.style && target.nodeType;
  10725. },
  10726. init: function init(target, vars, tween, index, targets) {
  10727. var props = this._props,
  10728. style = target.style,
  10729. startAt = tween.vars.startAt,
  10730. startValue,
  10731. endValue,
  10732. endNum,
  10733. startNum,
  10734. type,
  10735. specialProp,
  10736. p,
  10737. startUnit,
  10738. endUnit,
  10739. relative,
  10740. isTransformRelated,
  10741. transformPropTween,
  10742. cache,
  10743. smooth,
  10744. hasPriority,
  10745. inlineProps;
  10746. _pluginInitted || _initCore();
  10747. this.styles = this.styles || _getStyleSaver(target);
  10748. inlineProps = this.styles.props;
  10749. this.tween = tween;
  10750. for (p in vars) {
  10751. if (p === "autoRound") {
  10752. continue;
  10753. }
  10754. endValue = vars[p];
  10755. if (_plugins[p] && _checkPlugin(p, vars, tween, index, target, targets)) {
  10756. continue;
  10757. }
  10758. type = typeof endValue;
  10759. specialProp = _specialProps[p];
  10760. if (type === "function") {
  10761. endValue = endValue.call(tween, index, target, targets);
  10762. type = typeof endValue;
  10763. }
  10764. if (type === "string" && ~endValue.indexOf("random(")) {
  10765. endValue = _replaceRandom(endValue);
  10766. }
  10767. if (specialProp) {
  10768. specialProp(this, target, p, endValue, tween) && (hasPriority = 1);
  10769. } else if (p.substr(0, 2) === "--") {
  10770. startValue = (getComputedStyle(target).getPropertyValue(p) + "").trim();
  10771. endValue += "";
  10772. _colorExp.lastIndex = 0;
  10773. if (!_colorExp.test(startValue)) {
  10774. startUnit = getUnit(startValue);
  10775. endUnit = getUnit(endValue);
  10776. }
  10777. endUnit ? startUnit !== endUnit && (startValue = _convertToUnit(target, p, startValue, endUnit) + endUnit) : startUnit && (endValue += startUnit);
  10778. this.add(style, "setProperty", startValue, endValue, index, targets, 0, 0, p);
  10779. props.push(p);
  10780. inlineProps.push(p, 0, style[p]);
  10781. } else if (type !== "undefined") {
  10782. if (startAt && p in startAt) {
  10783. startValue = typeof startAt[p] === "function" ? startAt[p].call(tween, index, target, targets) : startAt[p];
  10784. _isString(startValue) && ~startValue.indexOf("random(") && (startValue = _replaceRandom(startValue));
  10785. getUnit(startValue + "") || startValue === "auto" || (startValue += _config.units[p] || getUnit(_get(target, p)) || "");
  10786. (startValue + "").charAt(1) === "=" && (startValue = _get(target, p));
  10787. } else {
  10788. startValue = _get(target, p);
  10789. }
  10790. startNum = parseFloat(startValue);
  10791. relative = type === "string" && endValue.charAt(1) === "=" && endValue.substr(0, 2);
  10792. relative && (endValue = endValue.substr(2));
  10793. endNum = parseFloat(endValue);
  10794. if (p in _propertyAliases) {
  10795. if (p === "autoAlpha") {
  10796. if (startNum === 1 && _get(target, "visibility") === "hidden" && endNum) {
  10797. startNum = 0;
  10798. }
  10799. inlineProps.push("visibility", 0, style.visibility);
  10800. _addNonTweeningPT(this, style, "visibility", startNum ? "inherit" : "hidden", endNum ? "inherit" : "hidden", !endNum);
  10801. }
  10802. if (p !== "scale" && p !== "transform") {
  10803. p = _propertyAliases[p];
  10804. ~p.indexOf(",") && (p = p.split(",")[0]);
  10805. }
  10806. }
  10807. isTransformRelated = p in _transformProps;
  10808. if (isTransformRelated) {
  10809. this.styles.save(p);
  10810. if (type === "string" && endValue.substring(0, 6) === "var(--") {
  10811. endValue = _getComputedProperty(target, endValue.substring(4, endValue.indexOf(")")));
  10812. endNum = parseFloat(endValue);
  10813. }
  10814. if (!transformPropTween) {
  10815. cache = target._gsap;
  10816. cache.renderTransform && !vars.parseTransform || _parseTransform(target, vars.parseTransform);
  10817. smooth = vars.smoothOrigin !== false && cache.smooth;
  10818. transformPropTween = this._pt = new PropTween(this._pt, style, _transformProp, 0, 1, cache.renderTransform, cache, 0, -1);
  10819. transformPropTween.dep = 1;
  10820. }
  10821. if (p === "scale") {
  10822. this._pt = new PropTween(this._pt, cache, "scaleY", cache.scaleY, (relative ? _parseRelative(cache.scaleY, relative + endNum) : endNum) - cache.scaleY || 0, _renderCSSProp);
  10823. this._pt.u = 0;
  10824. props.push("scaleY", p);
  10825. p += "X";
  10826. } else if (p === "transformOrigin") {
  10827. inlineProps.push(_transformOriginProp, 0, style[_transformOriginProp]);
  10828. endValue = _convertKeywordsToPercentages(endValue);
  10829. if (cache.svg) {
  10830. _applySVGOrigin(target, endValue, 0, smooth, 0, this);
  10831. } else {
  10832. endUnit = parseFloat(endValue.split(" ")[2]) || 0;
  10833. endUnit !== cache.zOrigin && _addNonTweeningPT(this, cache, "zOrigin", cache.zOrigin, endUnit);
  10834. _addNonTweeningPT(this, style, p, _firstTwoOnly(startValue), _firstTwoOnly(endValue));
  10835. }
  10836. continue;
  10837. } else if (p === "svgOrigin") {
  10838. _applySVGOrigin(target, endValue, 1, smooth, 0, this);
  10839. continue;
  10840. } else if (p in _rotationalProperties) {
  10841. _addRotationalPropTween(this, cache, p, startNum, relative ? _parseRelative(startNum, relative + endValue) : endValue);
  10842. continue;
  10843. } else if (p === "smoothOrigin") {
  10844. _addNonTweeningPT(this, cache, "smooth", cache.smooth, endValue);
  10845. continue;
  10846. } else if (p === "force3D") {
  10847. cache[p] = endValue;
  10848. continue;
  10849. } else if (p === "transform") {
  10850. _addRawTransformPTs(this, endValue, target);
  10851. continue;
  10852. }
  10853. } else if (!(p in style)) {
  10854. p = _checkPropPrefix(p) || p;
  10855. }
  10856. if (isTransformRelated || (endNum || endNum === 0) && (startNum || startNum === 0) && !_complexExp.test(endValue) && p in style) {
  10857. startUnit = (startValue + "").substr((startNum + "").length);
  10858. endNum || (endNum = 0);
  10859. endUnit = getUnit(endValue) || (p in _config.units ? _config.units[p] : startUnit);
  10860. startUnit !== endUnit && (startNum = _convertToUnit(target, p, startValue, endUnit));
  10861. 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);
  10862. this._pt.u = endUnit || 0;
  10863. if (startUnit !== endUnit && endUnit !== "%") {
  10864. this._pt.b = startValue;
  10865. this._pt.r = _renderCSSPropWithBeginning;
  10866. }
  10867. } else if (!(p in style)) {
  10868. if (p in target) {
  10869. this.add(target, p, startValue || target[p], relative ? relative + endValue : endValue, index, targets);
  10870. } else if (p !== "parseTransform") {
  10871. _missingPlugin(p, endValue);
  10872. continue;
  10873. }
  10874. } else {
  10875. _tweenComplexCSSString.call(this, target, p, startValue, relative ? relative + endValue : endValue);
  10876. }
  10877. isTransformRelated || (p in style ? inlineProps.push(p, 0, style[p]) : typeof target[p] === "function" ? inlineProps.push(p, 2, target[p]()) : inlineProps.push(p, 1, startValue || target[p]));
  10878. props.push(p);
  10879. }
  10880. }
  10881. hasPriority && _sortPropTweensByPriority(this);
  10882. },
  10883. render: function render(ratio, data) {
  10884. if (data.tween._time || !_reverting$1()) {
  10885. var pt = data._pt;
  10886. while (pt) {
  10887. pt.r(ratio, pt.d);
  10888. pt = pt._next;
  10889. }
  10890. } else {
  10891. data.styles.revert();
  10892. }
  10893. },
  10894. get: _get,
  10895. aliases: _propertyAliases,
  10896. getSetter: function getSetter(target, property, plugin) {
  10897. var p = _propertyAliases[property];
  10898. p && p.indexOf(",") < 0 && (property = p);
  10899. 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);
  10900. },
  10901. core: {
  10902. _removeProperty: _removeProperty,
  10903. _getMatrix: _getMatrix
  10904. }
  10905. };
  10906. gsap.utils.checkPrefix = _checkPropPrefix;
  10907. gsap.core.getStyleSaver = _getStyleSaver;
  10908. (function (positionAndScale, rotation, others, aliases) {
  10909. var all = _forEachName(positionAndScale + "," + rotation + "," + others, function (name) {
  10910. _transformProps[name] = 1;
  10911. });
  10912. _forEachName(rotation, function (name) {
  10913. _config.units[name] = "deg";
  10914. _rotationalProperties[name] = 1;
  10915. });
  10916. _propertyAliases[all[13]] = positionAndScale + "," + rotation;
  10917. _forEachName(aliases, function (name) {
  10918. var split = name.split(":");
  10919. _propertyAliases[split[1]] = all[split[0]];
  10920. });
  10921. })("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");
  10922. _forEachName("x,y,z,top,right,bottom,left,width,height,fontSize,padding,margin,perspective", function (name) {
  10923. _config.units[name] = "px";
  10924. });
  10925. gsap.registerPlugin(CSSPlugin);
  10926. var gsapWithCSS = gsap.registerPlugin(CSSPlugin) || gsap,
  10927. TweenMaxWithCSS = gsapWithCSS.core.Tween;
  10928. exports.Back = Back;
  10929. exports.Bounce = Bounce;
  10930. exports.CSSPlugin = CSSPlugin;
  10931. exports.Circ = Circ;
  10932. exports.Cubic = Cubic;
  10933. exports.Elastic = Elastic;
  10934. exports.Expo = Expo;
  10935. exports.Linear = Linear;
  10936. exports.Power0 = Power0;
  10937. exports.Power1 = Power1;
  10938. exports.Power2 = Power2;
  10939. exports.Power3 = Power3;
  10940. exports.Power4 = Power4;
  10941. exports.Quad = Quad;
  10942. exports.Quart = Quart;
  10943. exports.Quint = Quint;
  10944. exports.Sine = Sine;
  10945. exports.SteppedEase = SteppedEase;
  10946. exports.Strong = Strong;
  10947. exports.TimelineLite = Timeline;
  10948. exports.TimelineMax = Timeline;
  10949. exports.TweenLite = Tween;
  10950. exports.TweenMax = TweenMaxWithCSS;
  10951. exports.default = gsapWithCSS;
  10952. exports.gsap = gsapWithCSS;
  10953. if (typeof(window) === 'undefined' || window !== exports) {Object.defineProperty(exports, '__esModule', { value: true });} else {delete window.default;}
  10954. })));
  10955. /*!
  10956. Images Loaded Packaged
  10957. Version: v5.0.0
  10958. Plugin URL: https://imagesloaded.desandro.com/
  10959. License: Copyright 2021-2024 | Released under the MIT License
  10960. !*/
  10961. /**
  10962. * EvEmitter v2.1.1
  10963. * Lil' event emitter
  10964. * MIT License
  10965. */
  10966. ( function( global, factory ) {
  10967. // universal module definition
  10968. if ( typeof module == 'object' && module.exports ) {
  10969. // CommonJS - Browserify, Webpack
  10970. module.exports = factory();
  10971. } else {
  10972. // Browser globals
  10973. global.EvEmitter = factory();
  10974. }
  10975. }( typeof window != 'undefined' ? window : this, function() {
  10976. function EvEmitter() {}
  10977. let proto = EvEmitter.prototype;
  10978. proto.on = function( eventName, listener ) {
  10979. if ( !eventName || !listener ) return this;
  10980. // set events hash
  10981. let events = this._events = this._events || {};
  10982. // set listeners array
  10983. let listeners = events[ eventName ] = events[ eventName ] || [];
  10984. // only add once
  10985. if ( !listeners.includes( listener ) ) {
  10986. listeners.push( listener );
  10987. }
  10988. return this;
  10989. };
  10990. proto.once = function( eventName, listener ) {
  10991. if ( !eventName || !listener ) return this;
  10992. // add event
  10993. this.on( eventName, listener );
  10994. // set once flag
  10995. // set onceEvents hash
  10996. let onceEvents = this._onceEvents = this._onceEvents || {};
  10997. // set onceListeners object
  10998. let onceListeners = onceEvents[ eventName ] = onceEvents[ eventName ] || {};
  10999. // set flag
  11000. onceListeners[ listener ] = true;
  11001. return this;
  11002. };
  11003. proto.off = function( eventName, listener ) {
  11004. let listeners = this._events && this._events[ eventName ];
  11005. if ( !listeners || !listeners.length ) return this;
  11006. let index = listeners.indexOf( listener );
  11007. if ( index != -1 ) {
  11008. listeners.splice( index, 1 );
  11009. }
  11010. return this;
  11011. };
  11012. proto.emitEvent = function( eventName, args ) {
  11013. let listeners = this._events && this._events[ eventName ];
  11014. if ( !listeners || !listeners.length ) return this;
  11015. // copy over to avoid interference if .off() in listener
  11016. listeners = listeners.slice( 0 );
  11017. args = args || [];
  11018. // once stuff
  11019. let onceListeners = this._onceEvents && this._onceEvents[ eventName ];
  11020. for ( let listener of listeners ) {
  11021. let isOnce = onceListeners && onceListeners[ listener ];
  11022. if ( isOnce ) {
  11023. // remove listener
  11024. // remove before trigger to prevent recursion
  11025. this.off( eventName, listener );
  11026. // unset once flag
  11027. delete onceListeners[ listener ];
  11028. }
  11029. // trigger listener
  11030. listener.apply( this, args );
  11031. }
  11032. return this;
  11033. };
  11034. proto.allOff = function() {
  11035. delete this._events;
  11036. delete this._onceEvents;
  11037. return this;
  11038. };
  11039. return EvEmitter;
  11040. } ) );
  11041. /*!
  11042. * imagesLoaded v5.0.0
  11043. * JavaScript is all like "You images are done yet or what?"
  11044. * MIT License
  11045. */
  11046. ( function( window, factory ) {
  11047. // universal module definition
  11048. if ( typeof module == 'object' && module.exports ) {
  11049. // CommonJS
  11050. module.exports = factory( window, require('ev-emitter') );
  11051. } else {
  11052. // browser global
  11053. window.imagesLoaded = factory( window, window.EvEmitter );
  11054. }
  11055. } )( typeof window !== 'undefined' ? window : this,
  11056. function factory( window, EvEmitter ) {
  11057. let $ = window.jQuery;
  11058. let console = window.console;
  11059. // -------------------------- helpers -------------------------- //
  11060. // turn element or nodeList into an array
  11061. function makeArray( obj ) {
  11062. // use object if already an array
  11063. if ( Array.isArray( obj ) ) return obj;
  11064. let isArrayLike = typeof obj == 'object' && typeof obj.length == 'number';
  11065. // convert nodeList to array
  11066. if ( isArrayLike ) return [ ...obj ];
  11067. // array of single index
  11068. return [ obj ];
  11069. }
  11070. // -------------------------- imagesLoaded -------------------------- //
  11071. /**
  11072. * @param {[Array, Element, NodeList, String]} elem
  11073. * @param {[Object, Function]} options - if function, use as callback
  11074. * @param {Function} onAlways - callback function
  11075. * @returns {ImagesLoaded}
  11076. */
  11077. function ImagesLoaded( elem, options, onAlways ) {
  11078. // coerce ImagesLoaded() without new, to be new ImagesLoaded()
  11079. if ( !( this instanceof ImagesLoaded ) ) {
  11080. return new ImagesLoaded( elem, options, onAlways );
  11081. }
  11082. // use elem as selector string
  11083. let queryElem = elem;
  11084. if ( typeof elem == 'string' ) {
  11085. queryElem = document.querySelectorAll( elem );
  11086. }
  11087. // bail if bad element
  11088. if ( !queryElem ) {
  11089. console.error(`Bad element for imagesLoaded ${queryElem || elem}`);
  11090. return;
  11091. }
  11092. this.elements = makeArray( queryElem );
  11093. this.options = {};
  11094. // shift arguments if no options set
  11095. if ( typeof options == 'function' ) {
  11096. onAlways = options;
  11097. } else {
  11098. Object.assign( this.options, options );
  11099. }
  11100. if ( onAlways ) this.on( 'always', onAlways );
  11101. this.getImages();
  11102. // add jQuery Deferred object
  11103. if ( $ ) this.jqDeferred = new $.Deferred();
  11104. // HACK check async to allow time to bind listeners
  11105. setTimeout( this.check.bind( this ) );
  11106. }
  11107. ImagesLoaded.prototype = Object.create( EvEmitter.prototype );
  11108. ImagesLoaded.prototype.getImages = function() {
  11109. this.images = [];
  11110. // filter & find items if we have an item selector
  11111. this.elements.forEach( this.addElementImages, this );
  11112. };
  11113. const elementNodeTypes = [ 1, 9, 11 ];
  11114. /**
  11115. * @param {Node} elem
  11116. */
  11117. ImagesLoaded.prototype.addElementImages = function( elem ) {
  11118. // filter siblings
  11119. if ( elem.nodeName === 'IMG' ) {
  11120. this.addImage( elem );
  11121. }
  11122. // get background image on element
  11123. if ( this.options.background === true ) {
  11124. this.addElementBackgroundImages( elem );
  11125. }
  11126. // find children
  11127. // no non-element nodes, #143
  11128. let { nodeType } = elem;
  11129. if ( !nodeType || !elementNodeTypes.includes( nodeType ) ) return;
  11130. let childImgs = elem.querySelectorAll('img');
  11131. // concat childElems to filterFound array
  11132. for ( let img of childImgs ) {
  11133. this.addImage( img );
  11134. }
  11135. // get child background images
  11136. if ( typeof this.options.background == 'string' ) {
  11137. let children = elem.querySelectorAll( this.options.background );
  11138. for ( let child of children ) {
  11139. this.addElementBackgroundImages( child );
  11140. }
  11141. }
  11142. };
  11143. const reURL = /url\((['"])?(.*?)\1\)/gi;
  11144. ImagesLoaded.prototype.addElementBackgroundImages = function( elem ) {
  11145. let style = getComputedStyle( elem );
  11146. // Firefox returns null if in a hidden iframe https://bugzil.la/548397
  11147. if ( !style ) return;
  11148. // get url inside url("...")
  11149. let matches = reURL.exec( style.backgroundImage );
  11150. while ( matches !== null ) {
  11151. let url = matches && matches[2];
  11152. if ( url ) {
  11153. this.addBackground( url, elem );
  11154. }
  11155. matches = reURL.exec( style.backgroundImage );
  11156. }
  11157. };
  11158. /**
  11159. * @param {Image} img
  11160. */
  11161. ImagesLoaded.prototype.addImage = function( img ) {
  11162. let loadingImage = new LoadingImage( img );
  11163. this.images.push( loadingImage );
  11164. };
  11165. ImagesLoaded.prototype.addBackground = function( url, elem ) {
  11166. let background = new Background( url, elem );
  11167. this.images.push( background );
  11168. };
  11169. ImagesLoaded.prototype.check = function() {
  11170. this.progressedCount = 0;
  11171. this.hasAnyBroken = false;
  11172. // complete if no images
  11173. if ( !this.images.length ) {
  11174. this.complete();
  11175. return;
  11176. }
  11177. /* eslint-disable-next-line func-style */
  11178. let onProgress = ( image, elem, message ) => {
  11179. // HACK - Chrome triggers event before object properties have changed. #83
  11180. setTimeout( () => {
  11181. this.progress( image, elem, message );
  11182. } );
  11183. };
  11184. this.images.forEach( function( loadingImage ) {
  11185. loadingImage.once( 'progress', onProgress );
  11186. loadingImage.check();
  11187. } );
  11188. };
  11189. ImagesLoaded.prototype.progress = function( image, elem, message ) {
  11190. this.progressedCount++;
  11191. this.hasAnyBroken = this.hasAnyBroken || !image.isLoaded;
  11192. // progress event
  11193. this.emitEvent( 'progress', [ this, image, elem ] );
  11194. if ( this.jqDeferred && this.jqDeferred.notify ) {
  11195. this.jqDeferred.notify( this, image );
  11196. }
  11197. // check if completed
  11198. if ( this.progressedCount === this.images.length ) {
  11199. this.complete();
  11200. }
  11201. if ( this.options.debug && console ) {
  11202. console.log( `progress: ${message}`, image, elem );
  11203. }
  11204. };
  11205. ImagesLoaded.prototype.complete = function() {
  11206. let eventName = this.hasAnyBroken ? 'fail' : 'done';
  11207. this.isComplete = true;
  11208. this.emitEvent( eventName, [ this ] );
  11209. this.emitEvent( 'always', [ this ] );
  11210. if ( this.jqDeferred ) {
  11211. let jqMethod = this.hasAnyBroken ? 'reject' : 'resolve';
  11212. this.jqDeferred[ jqMethod ]( this );
  11213. }
  11214. };
  11215. // -------------------------- -------------------------- //
  11216. function LoadingImage( img ) {
  11217. this.img = img;
  11218. }
  11219. LoadingImage.prototype = Object.create( EvEmitter.prototype );
  11220. LoadingImage.prototype.check = function() {
  11221. // If complete is true and browser supports natural sizes,
  11222. // try to check for image status manually.
  11223. let isComplete = this.getIsImageComplete();
  11224. if ( isComplete ) {
  11225. // report based on naturalWidth
  11226. this.confirm( this.img.naturalWidth !== 0, 'naturalWidth' );
  11227. return;
  11228. }
  11229. // If none of the checks above matched, simulate loading on detached element.
  11230. this.proxyImage = new Image();
  11231. // add crossOrigin attribute. #204
  11232. if ( this.img.crossOrigin ) {
  11233. this.proxyImage.crossOrigin = this.img.crossOrigin;
  11234. }
  11235. this.proxyImage.addEventListener( 'load', this );
  11236. this.proxyImage.addEventListener( 'error', this );
  11237. // bind to image as well for Firefox. #191
  11238. this.img.addEventListener( 'load', this );
  11239. this.img.addEventListener( 'error', this );
  11240. this.proxyImage.src = this.img.currentSrc || this.img.src;
  11241. };
  11242. LoadingImage.prototype.getIsImageComplete = function() {
  11243. // check for non-zero, non-undefined naturalWidth
  11244. // fixes Safari+InfiniteScroll+Masonry bug infinite-scroll#671
  11245. return this.img.complete && this.img.naturalWidth;
  11246. };
  11247. LoadingImage.prototype.confirm = function( isLoaded, message ) {
  11248. this.isLoaded = isLoaded;
  11249. let { parentNode } = this.img;
  11250. // emit progress with parent <picture> or self <img>
  11251. let elem = parentNode.nodeName === 'PICTURE' ? parentNode : this.img;
  11252. this.emitEvent( 'progress', [ this, elem, message ] );
  11253. };
  11254. // ----- events ----- //
  11255. // trigger specified handler for event type
  11256. LoadingImage.prototype.handleEvent = function( event ) {
  11257. let method = 'on' + event.type;
  11258. if ( this[ method ] ) {
  11259. this[ method ]( event );
  11260. }
  11261. };
  11262. LoadingImage.prototype.onload = function() {
  11263. this.confirm( true, 'onload' );
  11264. this.unbindEvents();
  11265. };
  11266. LoadingImage.prototype.onerror = function() {
  11267. this.confirm( false, 'onerror' );
  11268. this.unbindEvents();
  11269. };
  11270. LoadingImage.prototype.unbindEvents = function() {
  11271. this.proxyImage.removeEventListener( 'load', this );
  11272. this.proxyImage.removeEventListener( 'error', this );
  11273. this.img.removeEventListener( 'load', this );
  11274. this.img.removeEventListener( 'error', this );
  11275. };
  11276. // -------------------------- Background -------------------------- //
  11277. function Background( url, element ) {
  11278. this.url = url;
  11279. this.element = element;
  11280. this.img = new Image();
  11281. }
  11282. // inherit LoadingImage prototype
  11283. Background.prototype = Object.create( LoadingImage.prototype );
  11284. Background.prototype.check = function() {
  11285. this.img.addEventListener( 'load', this );
  11286. this.img.addEventListener( 'error', this );
  11287. this.img.src = this.url;
  11288. // check if image is already complete
  11289. let isComplete = this.getIsImageComplete();
  11290. if ( isComplete ) {
  11291. this.confirm( this.img.naturalWidth !== 0, 'naturalWidth' );
  11292. this.unbindEvents();
  11293. }
  11294. };
  11295. Background.prototype.unbindEvents = function() {
  11296. this.img.removeEventListener( 'load', this );
  11297. this.img.removeEventListener( 'error', this );
  11298. };
  11299. Background.prototype.confirm = function( isLoaded, message ) {
  11300. this.isLoaded = isLoaded;
  11301. this.emitEvent( 'progress', [ this, this.element, message ] );
  11302. };
  11303. // -------------------------- jQuery -------------------------- //
  11304. ImagesLoaded.makeJQueryPlugin = function( jQuery ) {
  11305. jQuery = jQuery || window.jQuery;
  11306. if ( !jQuery ) return;
  11307. // set local variable
  11308. $ = jQuery;
  11309. // $().imagesLoaded()
  11310. $.fn.imagesLoaded = function( options, onAlways ) {
  11311. let instance = new ImagesLoaded( this, options, onAlways );
  11312. return instance.jqDeferred.promise( $( this ) );
  11313. };
  11314. };
  11315. // try making plugin
  11316. ImagesLoaded.makeJQueryPlugin();
  11317. // -------------------------- -------------------------- //
  11318. return ImagesLoaded;
  11319. } );
  11320. /*!
  11321. Carto - Interactive portfolio
  11322. Created by ThemeZaa
  11323. !*/
  11324. $(function() {
  11325. "use strict";
  11326. const container = document.getElementById("stickyImgContainer");
  11327. if (typeof (container) != 'undefined' && container != null) {
  11328. const sliders = document.querySelector(".slides").querySelectorAll(".slide")
  11329. const slidesData = Array.from(sliders).map(item => {
  11330. return {
  11331. image: "",
  11332. title: "title1",
  11333. meta: ""
  11334. }
  11335. })
  11336. const createEleWithClass = (tag, className) => {
  11337. const ele = document.createElement(tag);
  11338. ele.className = className;
  11339. return ele;
  11340. };
  11341. class Slides {
  11342. constructor(data) {
  11343. this.data = document.querySelectorAll(".slide");
  11344. this.container = document.querySelector(".slides");
  11345. this.currentIdx = 0;
  11346. this.slides = document.querySelectorAll(".slide");
  11347. }
  11348. mount(container) {
  11349. container.appendChild(this.container);
  11350. let activeIndex = 0;
  11351. for (let i = 0; i < this.slides.length; i++) {
  11352. if (activeIndex === i) {
  11353. this.slides[i].classList.remove("next");
  11354. this.slides[i].classList.remove("prev");
  11355. this.slides[i].classList.add("show-meta");
  11356. document.querySelector(".bg-overlay").style.backgroundImage = `url("${this.slides[i].dataset.bg}")`
  11357. } else {
  11358. if (activeIndex > i) {
  11359. this.slides[i].classList.remove("next");
  11360. this.slides[i].classList.add("prev");
  11361. } else {
  11362. this.slides[i].classList.add("next");
  11363. this.slides[i].classList.remove("prev");
  11364. }
  11365. }
  11366. }
  11367. }
  11368. onActiveIndexChange(activeIndex) {
  11369. this.currentIdx = activeIndex;
  11370. for (let i = 0; i < this.slides.length; i++) {
  11371. if (activeIndex === i) {
  11372. this.slides[i].classList.remove("next");
  11373. this.slides[i].classList.remove("prev");
  11374. document.querySelector(".bg-overlay").style.backgroundImage = `url("${this.slides[i].dataset.bg}")`
  11375. } else {
  11376. if (activeIndex > i) {
  11377. this.slides[i].classList.remove("next");
  11378. this.slides[i].classList.add("prev");
  11379. } else {
  11380. this.slides[i].classList.add("next");
  11381. this.slides[i].classList.remove("prev");
  11382. }
  11383. }
  11384. }
  11385. }
  11386. onMove(indexFloat) {
  11387. this.container.style.transform = `translateY(${(indexFloat * 100) /
  11388. this.slides.length}%)`;
  11389. }
  11390. appear() {
  11391. this.container.classList.add("scrolling");
  11392. container.classList.add("scrolling");
  11393. this.slides[this.currentIdx].classList.remove("show-meta");
  11394. }
  11395. disperse(activeIndex) {
  11396. this.currentIdx = activeIndex;
  11397. this.slides[this.currentIdx].classList.add("show-meta");
  11398. this.container.classList.remove("scrolling");
  11399. container.classList.remove("scrolling");
  11400. for (let index = 0; index < this.data.length; index++) {
  11401. if (index > activeIndex) {
  11402. this.slides[index].classList.add("next");
  11403. this.slides[index].classList.remove("prev");
  11404. } else if (index < activeIndex) {
  11405. this.slides[index].classList.remove("next");
  11406. this.slides[index].classList.add("prev");
  11407. } else {
  11408. this.slides[index].classList.remove("next");
  11409. this.slides[index].classList.remove("prev");
  11410. }
  11411. }
  11412. }
  11413. }
  11414. class Grab {
  11415. constructor({
  11416. indexSize,
  11417. onIndexChange,
  11418. onGrabStart,
  11419. onGrabMove,
  11420. onGrabEnd
  11421. }) {
  11422. this.onGrabEnd = onGrabEnd;
  11423. this.onGrabStart = onGrabStart;
  11424. this.onGrabMove = onGrabMove;
  11425. this.scroll = {
  11426. start: 0,
  11427. current: 0,
  11428. initial: 0
  11429. };
  11430. this.listen("mousedown", this.onMouseDown.bind(this));
  11431. this.listen("mousemove", this.onMouseMove.bind(this));
  11432. this.listen("mouseup", this.onMouseUp.bind(this));
  11433. this.listen("touchstart", this.onMouseDown.bind(this), true);
  11434. this.listen("touchmove", this.onMouseMove.bind(this), true);
  11435. this.listen(["touchend", "touchcancel"], this.onMouseUp.bind(this), true);
  11436. }
  11437. listen(events, grabListener, isTouch) {
  11438. const _this = this;
  11439. let mouseListener = function (ev) {
  11440. if (ev.type === "mouseout" && ev.relatedTarget != null) return;
  11441. grabListener({
  11442. y: ev.clientY
  11443. });
  11444. };
  11445. let touchListener = function (ev) {
  11446. grabListener({
  11447. y: ev.targetTouches[0] ? ev.targetTouches[0].clientY : null
  11448. });
  11449. };
  11450. let listener = mouseListener;
  11451. if (isTouch) {
  11452. listener = touchListener;
  11453. }
  11454. if (Array.isArray(events)) {
  11455. for (let i = 0; i < events.length; i++) {
  11456. window.addEventListener(events[i], listener, false);
  11457. }
  11458. } else {
  11459. window.addEventListener(events, function (event) {
  11460. if (event.target.closest(".stickyImageContainer") === container) {
  11461. listener(event);
  11462. } else {
  11463. _this.onMouseUp()
  11464. }
  11465. }, false);
  11466. }
  11467. }
  11468. onMouseDown(position) {
  11469. this.scroll.inital = this.scroll.current;
  11470. this.scroll.start = position.y;
  11471. this.scroll.current = position.y;
  11472. this.scroll.delta = this.scroll.current - this.scroll.start;
  11473. this.onGrabStart({
  11474. delta: this.scroll.delta,
  11475. direction: Math.abs(this.scroll.delta),
  11476. current: this.scroll.current,
  11477. start: this.scroll.start
  11478. });
  11479. }
  11480. onMouseMove(position) {
  11481. if (this.scroll.start) {
  11482. this.scroll.current = position.y;
  11483. this.scroll.delta = this.scroll.current - this.scroll.start;
  11484. this.onGrabMove({
  11485. delta: this.scroll.delta,
  11486. direction: Math.abs(this.scroll.delta),
  11487. current: this.scroll.current,
  11488. start: this.scroll.start
  11489. });
  11490. }
  11491. }
  11492. onMouseUp() {
  11493. if (this.scroll.start) {
  11494. this.onGrabEnd({
  11495. delta: this.scroll.delta,
  11496. direction: Math.abs(this.scroll.delta),
  11497. current: this.scroll.current,
  11498. start: this.scroll.start
  11499. });
  11500. this.scroll.start = null;
  11501. this.scroll.current = null;
  11502. this.scroll.delta = null;
  11503. }
  11504. }
  11505. }
  11506. const reach = function ({ from, to, restDelta = 0.01 }) {
  11507. let current = Object.assign({}, from);
  11508. let keys = Object.keys(from);
  11509. let raf = {
  11510. current: null
  11511. };
  11512. let _update = function (update, complete) {
  11513. if (keys.length === 0) {
  11514. cancelAnimationFrame(raf.current);
  11515. raf.current = null;
  11516. complete(current);
  11517. return;
  11518. }
  11519. let cacheKeys = keys.slice();
  11520. for (var i = keys.length, val, key; i >= 0; i--) {
  11521. key = keys[i];
  11522. val = current[key] + (to[key] - current[key]) * 0.1;
  11523. if (Math.abs(to[key] - val) < restDelta) {
  11524. current[key] = to[key];
  11525. // Remove key
  11526. keys.splice(i, 1);
  11527. // Move i down by pne
  11528. i--;
  11529. } else {
  11530. current[key] = val;
  11531. }
  11532. }
  11533. update(current);
  11534. raf.current = requestAnimationFrame(_update);
  11535. };
  11536. return {
  11537. start: function ({
  11538. update,
  11539. complete
  11540. }) {
  11541. _update = _update.bind(null, update, complete);
  11542. raf.current = requestAnimationFrame(_update);
  11543. return {
  11544. stop: function () {
  11545. cancelAnimationFrame(raf.current);
  11546. raf.current = null;
  11547. }
  11548. };
  11549. }
  11550. };
  11551. };
  11552. function Showcase(data, options = {}) {
  11553. this.data = data;
  11554. this.progress = 0;
  11555. this.direction = 1;
  11556. this.waveIntensity = 0;
  11557. this.options = options;
  11558. this.index = {
  11559. target: 0,
  11560. current: 0,
  11561. initial: 0,
  11562. scrollSize: window.innerHeight / 6,
  11563. active: 0
  11564. };
  11565. this.follower = {
  11566. x: 0,
  11567. y: 0
  11568. };
  11569. this.followerSpring = null;
  11570. this.slidesSpring = null;
  11571. this.grab = new Grab({
  11572. onGrabStart: this.onGrabStart.bind(this),
  11573. onGrabMove: this.onGrabMove.bind(this),
  11574. onGrabEnd: this.onGrabEnd.bind(this)
  11575. });
  11576. }
  11577. function clamp(num, min, max) {
  11578. return Math.max(min, Math.min(num, max));
  11579. }
  11580. Showcase.prototype.onGrabMove = function (scroll) {
  11581. this.index.target = clamp(
  11582. this.index.initial + scroll.delta / this.index.scrollSize,
  11583. -this.data.length + 0.51,
  11584. 0.49
  11585. );
  11586. const index = clamp(Math.round(-this.index.target), 0, this.data.length - 1);
  11587. if (this.index.active !== index) {
  11588. this.index.active = index;
  11589. if (this.options.onActiveIndexChange) {
  11590. this.options.onActiveIndexChange(this.index.active);
  11591. }
  11592. }
  11593. if (this.slidesPop) {
  11594. this.slidesPop.stop();
  11595. }
  11596. this.slidesPop = reach({
  11597. from: {
  11598. index: this.index.current
  11599. },
  11600. to: {
  11601. index: this.index.target
  11602. },
  11603. restDelta: 0.001
  11604. }).start({
  11605. update: val => {
  11606. if (this.options.onIndexChange) {
  11607. this.options.onIndexChange(val.index);
  11608. }
  11609. this.index.current = val.index;
  11610. },
  11611. complete: val => {
  11612. if (this.options.onIndexChange) {
  11613. this.options.onIndexChange(val.index);
  11614. }
  11615. this.index.current = val.index;
  11616. }
  11617. });
  11618. };
  11619. Showcase.prototype.onGrabStart = function () {
  11620. if (this.options.onZoomOutStart) {
  11621. this.options.onZoomOutStart({
  11622. activeIndex: this.index.active
  11623. });
  11624. }
  11625. this.index.initial = this.index.current;
  11626. };
  11627. Showcase.prototype.snapCurrentToActiveIndex = function () {
  11628. if (this.slidesPop) {
  11629. this.slidesPop.stop();
  11630. }
  11631. this.slidesPop = reach({
  11632. from: {
  11633. index: this.index.current
  11634. },
  11635. to: {
  11636. index: Math.round(this.index.target)
  11637. },
  11638. restDelta: 0.001
  11639. }).start({
  11640. complete: () => { },
  11641. update: val => {
  11642. // this.slides.onMove(val);
  11643. if (this.options.onIndexChange) {
  11644. this.options.onIndexChange(val.index);
  11645. }
  11646. this.index.current = val.index;
  11647. }
  11648. });
  11649. };
  11650. Showcase.prototype.onGrabEnd = function () {
  11651. if (this.options.onFullscreenStart) {
  11652. this.options.onFullscreenStart({
  11653. activeIndex: this.index.active
  11654. });
  11655. this.snapCurrentToActiveIndex();
  11656. }
  11657. };
  11658. Showcase.prototype.onResize = function () {
  11659. };
  11660. const slides = new Slides();
  11661. const showcase = new Showcase(slidesData, {
  11662. onActiveIndexChange: activeIndex => {
  11663. slides.onActiveIndexChange(activeIndex);
  11664. },
  11665. onIndexChange: index => {
  11666. slides.onMove(index);
  11667. },
  11668. onZoomOutStart: ({ activeIndex }) => {
  11669. slides.appear();
  11670. },
  11671. onZoomOutFinish: ({ activeIndex }) => { },
  11672. onFullscreenStart: ({ activeIndex }) => {
  11673. slides.disperse(activeIndex);
  11674. },
  11675. onFullscreenFinish: ({ activeIndex }) => { }
  11676. });
  11677. slides.mount(container);
  11678. }
  11679. });
  11680. /*!
  11681. Isotope
  11682. Version: v3.0.6
  11683. Plugin URL: https://isotope.metafizzy.co
  11684. License: Copyright 2010-2018 Metafizzy | Licensed GPLv3 for open source use or Isotope Commercial License for commercial use
  11685. !*/
  11686. /**
  11687. * Bridget makes jQuery widgets
  11688. * v2.0.1
  11689. * MIT license
  11690. */
  11691. /* jshint browser: true, strict: true, undef: true, unused: true */
  11692. ( function( window, factory ) {
  11693. // universal module definition
  11694. /*jshint strict: false */ /* globals define, module, require */
  11695. if ( typeof define == 'function' && define.amd ) {
  11696. // AMD
  11697. define( 'jquery-bridget/jquery-bridget',[ 'jquery' ], function( jQuery ) {
  11698. return factory( window, jQuery );
  11699. });
  11700. } else if ( typeof module == 'object' && module.exports ) {
  11701. // CommonJS
  11702. module.exports = factory(
  11703. window,
  11704. require('jquery')
  11705. );
  11706. } else {
  11707. // browser global
  11708. window.jQueryBridget = factory(
  11709. window,
  11710. window.jQuery
  11711. );
  11712. }
  11713. }( window, function factory( window, jQuery ) {
  11714. 'use strict';
  11715. // ----- utils ----- //
  11716. var arraySlice = Array.prototype.slice;
  11717. // helper function for logging errors
  11718. // $.error breaks jQuery chaining
  11719. var console = window.console;
  11720. var logError = typeof console == 'undefined' ? function() {} :
  11721. function( message ) {
  11722. console.error( message );
  11723. };
  11724. // ----- jQueryBridget ----- //
  11725. function jQueryBridget( namespace, PluginClass, $ ) {
  11726. $ = $ || jQuery || window.jQuery;
  11727. if ( !$ ) {
  11728. return;
  11729. }
  11730. // add option method -> $().plugin('option', {...})
  11731. if ( !PluginClass.prototype.option ) {
  11732. // option setter
  11733. PluginClass.prototype.option = function( opts ) {
  11734. // bail out if not an object
  11735. if ( !$.isPlainObject( opts ) ){
  11736. return;
  11737. }
  11738. this.options = $.extend( true, this.options, opts );
  11739. };
  11740. }
  11741. // make jQuery plugin
  11742. $.fn[ namespace ] = function( arg0 /*, arg1 */ ) {
  11743. if ( typeof arg0 == 'string' ) {
  11744. // method call $().plugin( 'methodName', { options } )
  11745. // shift arguments by 1
  11746. var args = arraySlice.call( arguments, 1 );
  11747. return methodCall( this, arg0, args );
  11748. }
  11749. // just $().plugin({ options })
  11750. plainCall( this, arg0 );
  11751. return this;
  11752. };
  11753. // $().plugin('methodName')
  11754. function methodCall( $elems, methodName, args ) {
  11755. var returnValue;
  11756. var pluginMethodStr = '$().' + namespace + '("' + methodName + '")';
  11757. $elems.each( function( i, elem ) {
  11758. // get instance
  11759. var instance = $.data( elem, namespace );
  11760. if ( !instance ) {
  11761. logError( namespace + ' not initialized. Cannot call methods, i.e. ' +
  11762. pluginMethodStr );
  11763. return;
  11764. }
  11765. var method = instance[ methodName ];
  11766. if ( !method || methodName.charAt(0) == '_' ) {
  11767. logError( pluginMethodStr + ' is not a valid method' );
  11768. return;
  11769. }
  11770. // apply method, get return value
  11771. var value = method.apply( instance, args );
  11772. // set return value if value is returned, use only first value
  11773. returnValue = returnValue === undefined ? value : returnValue;
  11774. });
  11775. return returnValue !== undefined ? returnValue : $elems;
  11776. }
  11777. function plainCall( $elems, options ) {
  11778. $elems.each( function( i, elem ) {
  11779. var instance = $.data( elem, namespace );
  11780. if ( instance ) {
  11781. // set options & init
  11782. instance.option( options );
  11783. instance._init();
  11784. } else {
  11785. // initialize new instance
  11786. instance = new PluginClass( elem, options );
  11787. $.data( elem, namespace, instance );
  11788. }
  11789. });
  11790. }
  11791. updateJQuery( $ );
  11792. }
  11793. // ----- updateJQuery ----- //
  11794. // set $.bridget for v1 backwards compatibility
  11795. function updateJQuery( $ ) {
  11796. if ( !$ || ( $ && $.bridget ) ) {
  11797. return;
  11798. }
  11799. $.bridget = jQueryBridget;
  11800. }
  11801. updateJQuery( jQuery || window.jQuery );
  11802. // ----- ----- //
  11803. return jQueryBridget;
  11804. }));
  11805. /**
  11806. * EvEmitter v1.1.0
  11807. * Lil' event emitter
  11808. * MIT License
  11809. */
  11810. /* jshint unused: true, undef: true, strict: true */
  11811. ( function( global, factory ) {
  11812. // universal module definition
  11813. /* jshint strict: false */ /* globals define, module, window */
  11814. if ( typeof define == 'function' && define.amd ) {
  11815. // AMD - RequireJS
  11816. define( 'ev-emitter/ev-emitter',factory );
  11817. } else if ( typeof module == 'object' && module.exports ) {
  11818. // CommonJS - Browserify, Webpack
  11819. module.exports = factory();
  11820. } else {
  11821. // Browser globals
  11822. global.EvEmitter = factory();
  11823. }
  11824. }( typeof window != 'undefined' ? window : this, function() {
  11825. function EvEmitter() {}
  11826. var proto = EvEmitter.prototype;
  11827. proto.on = function( eventName, listener ) {
  11828. if ( !eventName || !listener ) {
  11829. return;
  11830. }
  11831. // set events hash
  11832. var events = this._events = this._events || {};
  11833. // set listeners array
  11834. var listeners = events[ eventName ] = events[ eventName ] || [];
  11835. // only add once
  11836. if ( listeners.indexOf( listener ) == -1 ) {
  11837. listeners.push( listener );
  11838. }
  11839. return this;
  11840. };
  11841. proto.once = function( eventName, listener ) {
  11842. if ( !eventName || !listener ) {
  11843. return;
  11844. }
  11845. // add event
  11846. this.on( eventName, listener );
  11847. // set once flag
  11848. // set onceEvents hash
  11849. var onceEvents = this._onceEvents = this._onceEvents || {};
  11850. // set onceListeners object
  11851. var onceListeners = onceEvents[ eventName ] = onceEvents[ eventName ] || {};
  11852. // set flag
  11853. onceListeners[ listener ] = true;
  11854. return this;
  11855. };
  11856. proto.off = function( eventName, listener ) {
  11857. var listeners = this._events && this._events[ eventName ];
  11858. if ( !listeners || !listeners.length ) {
  11859. return;
  11860. }
  11861. var index = listeners.indexOf( listener );
  11862. if ( index != -1 ) {
  11863. listeners.splice( index, 1 );
  11864. }
  11865. return this;
  11866. };
  11867. proto.emitEvent = function( eventName, args ) {
  11868. var listeners = this._events && this._events[ eventName ];
  11869. if ( !listeners || !listeners.length ) {
  11870. return;
  11871. }
  11872. // copy over to avoid interference if .off() in listener
  11873. listeners = listeners.slice(0);
  11874. args = args || [];
  11875. // once stuff
  11876. var onceListeners = this._onceEvents && this._onceEvents[ eventName ];
  11877. for ( var i=0; i < listeners.length; i++ ) {
  11878. var listener = listeners[i]
  11879. var isOnce = onceListeners && onceListeners[ listener ];
  11880. if ( isOnce ) {
  11881. // remove listener
  11882. // remove before trigger to prevent recursion
  11883. this.off( eventName, listener );
  11884. // unset once flag
  11885. delete onceListeners[ listener ];
  11886. }
  11887. // trigger listener
  11888. listener.apply( this, args );
  11889. }
  11890. return this;
  11891. };
  11892. proto.allOff = function() {
  11893. delete this._events;
  11894. delete this._onceEvents;
  11895. };
  11896. return EvEmitter;
  11897. }));
  11898. /*!
  11899. * getSize v2.0.3
  11900. * measure size of elements
  11901. * MIT license
  11902. */
  11903. /* jshint browser: true, strict: true, undef: true, unused: true */
  11904. /* globals console: false */
  11905. ( function( window, factory ) {
  11906. /* jshint strict: false */ /* globals define, module */
  11907. if ( typeof define == 'function' && define.amd ) {
  11908. // AMD
  11909. define( 'get-size/get-size',factory );
  11910. } else if ( typeof module == 'object' && module.exports ) {
  11911. // CommonJS
  11912. module.exports = factory();
  11913. } else {
  11914. // browser global
  11915. window.getSize = factory();
  11916. }
  11917. })( window, function factory() {
  11918. 'use strict';
  11919. // -------------------------- helpers -------------------------- //
  11920. // get a number from a string, not a percentage
  11921. function getStyleSize( value ) {
  11922. var num = parseFloat( value );
  11923. // not a percent like '100%', and a number
  11924. var isValid = value.indexOf('%') == -1 && !isNaN( num );
  11925. return isValid && num;
  11926. }
  11927. function noop() {}
  11928. var logError = typeof console == 'undefined' ? noop :
  11929. function( message ) {
  11930. console.error( message );
  11931. };
  11932. // -------------------------- measurements -------------------------- //
  11933. var measurements = [
  11934. 'paddingLeft',
  11935. 'paddingRight',
  11936. 'paddingTop',
  11937. 'paddingBottom',
  11938. 'marginLeft',
  11939. 'marginRight',
  11940. 'marginTop',
  11941. 'marginBottom',
  11942. 'borderLeftWidth',
  11943. 'borderRightWidth',
  11944. 'borderTopWidth',
  11945. 'borderBottomWidth'
  11946. ];
  11947. var measurementsLength = measurements.length;
  11948. function getZeroSize() {
  11949. var size = {
  11950. width: 0,
  11951. height: 0,
  11952. innerWidth: 0,
  11953. innerHeight: 0,
  11954. outerWidth: 0,
  11955. outerHeight: 0
  11956. };
  11957. for ( var i=0; i < measurementsLength; i++ ) {
  11958. var measurement = measurements[i];
  11959. size[ measurement ] = 0;
  11960. }
  11961. return size;
  11962. }
  11963. // -------------------------- getStyle -------------------------- //
  11964. /**
  11965. * getStyle, get style of element, check for Firefox bug
  11966. * https://bugzilla.mozilla.org/show_bug.cgi?id=548397
  11967. */
  11968. function getStyle( elem ) {
  11969. var style = getComputedStyle( elem );
  11970. if ( !style ) {
  11971. logError( 'Style returned ' + style +
  11972. '. Are you running this code in a hidden iframe on Firefox? ' +
  11973. 'See https://bit.ly/getsizebug1' );
  11974. }
  11975. return style;
  11976. }
  11977. // -------------------------- setup -------------------------- //
  11978. var isSetup = false;
  11979. var isBoxSizeOuter;
  11980. /**
  11981. * setup
  11982. * check isBoxSizerOuter
  11983. * do on first getSize() rather than on page load for Firefox bug
  11984. */
  11985. function setup() {
  11986. // setup once
  11987. if ( isSetup ) {
  11988. return;
  11989. }
  11990. isSetup = true;
  11991. // -------------------------- box sizing -------------------------- //
  11992. /**
  11993. * Chrome & Safari measure the outer-width on style.width on border-box elems
  11994. * IE11 & Firefox<29 measures the inner-width
  11995. */
  11996. var div = document.createElement('div');
  11997. div.style.width = '200px';
  11998. div.style.padding = '1px 2px 3px 4px';
  11999. div.style.borderStyle = 'solid';
  12000. div.style.borderWidth = '1px 2px 3px 4px';
  12001. div.style.boxSizing = 'border-box';
  12002. var body = document.body || document.documentElement;
  12003. body.appendChild( div );
  12004. var style = getStyle( div );
  12005. // round value for browser zoom. desandro/masonry#928
  12006. isBoxSizeOuter = Math.round( getStyleSize( style.width ) ) == 200;
  12007. getSize.isBoxSizeOuter = isBoxSizeOuter;
  12008. body.removeChild( div );
  12009. }
  12010. // -------------------------- getSize -------------------------- //
  12011. function getSize( elem ) {
  12012. setup();
  12013. // use querySeletor if elem is string
  12014. if ( typeof elem == 'string' ) {
  12015. elem = document.querySelector( elem );
  12016. }
  12017. // do not proceed on non-objects
  12018. if ( !elem || typeof elem != 'object' || !elem.nodeType ) {
  12019. return;
  12020. }
  12021. var style = getStyle( elem );
  12022. // if hidden, everything is 0
  12023. if ( style.display == 'none' ) {
  12024. return getZeroSize();
  12025. }
  12026. var size = {};
  12027. size.width = elem.offsetWidth;
  12028. size.height = elem.offsetHeight;
  12029. var isBorderBox = size.isBorderBox = style.boxSizing == 'border-box';
  12030. // get all measurements
  12031. for ( var i=0; i < measurementsLength; i++ ) {
  12032. var measurement = measurements[i];
  12033. var value = style[ measurement ];
  12034. var num = parseFloat( value );
  12035. // any 'auto', 'medium' value will be 0
  12036. size[ measurement ] = !isNaN( num ) ? num : 0;
  12037. }
  12038. var paddingWidth = size.paddingLeft + size.paddingRight;
  12039. var paddingHeight = size.paddingTop + size.paddingBottom;
  12040. var marginWidth = size.marginLeft + size.marginRight;
  12041. var marginHeight = size.marginTop + size.marginBottom;
  12042. var borderWidth = size.borderLeftWidth + size.borderRightWidth;
  12043. var borderHeight = size.borderTopWidth + size.borderBottomWidth;
  12044. var isBorderBoxSizeOuter = isBorderBox && isBoxSizeOuter;
  12045. // overwrite width and height if we can get it from style
  12046. var styleWidth = getStyleSize( style.width );
  12047. if ( styleWidth !== false ) {
  12048. size.width = styleWidth +
  12049. // add padding and border unless it's already including it
  12050. ( isBorderBoxSizeOuter ? 0 : paddingWidth + borderWidth );
  12051. }
  12052. var styleHeight = getStyleSize( style.height );
  12053. if ( styleHeight !== false ) {
  12054. size.height = styleHeight +
  12055. // add padding and border unless it's already including it
  12056. ( isBorderBoxSizeOuter ? 0 : paddingHeight + borderHeight );
  12057. }
  12058. size.innerWidth = size.width - ( paddingWidth + borderWidth );
  12059. size.innerHeight = size.height - ( paddingHeight + borderHeight );
  12060. size.outerWidth = size.width + marginWidth;
  12061. size.outerHeight = size.height + marginHeight;
  12062. return size;
  12063. }
  12064. return getSize;
  12065. });
  12066. /**
  12067. * matchesSelector v2.0.2
  12068. * matchesSelector( element, '.selector' )
  12069. * MIT license
  12070. */
  12071. /*jshint browser: true, strict: true, undef: true, unused: true */
  12072. ( function( window, factory ) {
  12073. /*global define: false, module: false */
  12074. 'use strict';
  12075. // universal module definition
  12076. if ( typeof define == 'function' && define.amd ) {
  12077. // AMD
  12078. define( 'desandro-matches-selector/matches-selector',factory );
  12079. } else if ( typeof module == 'object' && module.exports ) {
  12080. // CommonJS
  12081. module.exports = factory();
  12082. } else {
  12083. // browser global
  12084. window.matchesSelector = factory();
  12085. }
  12086. }( window, function factory() {
  12087. 'use strict';
  12088. var matchesMethod = ( function() {
  12089. var ElemProto = window.Element.prototype;
  12090. // check for the standard method name first
  12091. if ( ElemProto.matches ) {
  12092. return 'matches';
  12093. }
  12094. // check un-prefixed
  12095. if ( ElemProto.matchesSelector ) {
  12096. return 'matchesSelector';
  12097. }
  12098. // check vendor prefixes
  12099. var prefixes = [ 'webkit', 'moz', 'ms', 'o' ];
  12100. for ( var i=0; i < prefixes.length; i++ ) {
  12101. var prefix = prefixes[i];
  12102. var method = prefix + 'MatchesSelector';
  12103. if ( ElemProto[ method ] ) {
  12104. return method;
  12105. }
  12106. }
  12107. })();
  12108. return function matchesSelector( elem, selector ) {
  12109. return elem[ matchesMethod ]( selector );
  12110. };
  12111. }));
  12112. /**
  12113. * Fizzy UI utils v2.0.7
  12114. * MIT license
  12115. */
  12116. /*jshint browser: true, undef: true, unused: true, strict: true */
  12117. ( function( window, factory ) {
  12118. // universal module definition
  12119. /*jshint strict: false */ /*globals define, module, require */
  12120. if ( typeof define == 'function' && define.amd ) {
  12121. // AMD
  12122. define( 'fizzy-ui-utils/utils',[
  12123. 'desandro-matches-selector/matches-selector'
  12124. ], function( matchesSelector ) {
  12125. return factory( window, matchesSelector );
  12126. });
  12127. } else if ( typeof module == 'object' && module.exports ) {
  12128. // CommonJS
  12129. module.exports = factory(
  12130. window,
  12131. require('desandro-matches-selector')
  12132. );
  12133. } else {
  12134. // browser global
  12135. window.fizzyUIUtils = factory(
  12136. window,
  12137. window.matchesSelector
  12138. );
  12139. }
  12140. }( window, function factory( window, matchesSelector ) {
  12141. var utils = {};
  12142. // ----- extend ----- //
  12143. // extends objects
  12144. utils.extend = function( a, b ) {
  12145. for ( var prop in b ) {
  12146. a[ prop ] = b[ prop ];
  12147. }
  12148. return a;
  12149. };
  12150. // ----- modulo ----- //
  12151. utils.modulo = function( num, div ) {
  12152. return ( ( num % div ) + div ) % div;
  12153. };
  12154. // ----- makeArray ----- //
  12155. var arraySlice = Array.prototype.slice;
  12156. // turn element or nodeList into an array
  12157. utils.makeArray = function( obj ) {
  12158. if ( Array.isArray( obj ) ) {
  12159. // use object if already an array
  12160. return obj;
  12161. }
  12162. // return empty array if undefined or null. #6
  12163. if ( obj === null || obj === undefined ) {
  12164. return [];
  12165. }
  12166. var isArrayLike = typeof obj == 'object' && typeof obj.length == 'number';
  12167. if ( isArrayLike ) {
  12168. // convert nodeList to array
  12169. return arraySlice.call( obj );
  12170. }
  12171. // array of single index
  12172. return [ obj ];
  12173. };
  12174. // ----- removeFrom ----- //
  12175. utils.removeFrom = function( ary, obj ) {
  12176. var index = ary.indexOf( obj );
  12177. if ( index != -1 ) {
  12178. ary.splice( index, 1 );
  12179. }
  12180. };
  12181. // ----- getParent ----- //
  12182. utils.getParent = function( elem, selector ) {
  12183. while ( elem.parentNode && elem != document.body ) {
  12184. elem = elem.parentNode;
  12185. if ( matchesSelector( elem, selector ) ) {
  12186. return elem;
  12187. }
  12188. }
  12189. };
  12190. // ----- getQueryElement ----- //
  12191. // use element as selector string
  12192. utils.getQueryElement = function( elem ) {
  12193. if ( typeof elem == 'string' ) {
  12194. return document.querySelector( elem );
  12195. }
  12196. return elem;
  12197. };
  12198. // ----- handleEvent ----- //
  12199. // enable .ontype to trigger from .addEventListener( elem, 'type' )
  12200. utils.handleEvent = function( event ) {
  12201. var method = 'on' + event.type;
  12202. if ( this[ method ] ) {
  12203. this[ method ]( event );
  12204. }
  12205. };
  12206. // ----- filterFindElements ----- //
  12207. utils.filterFindElements = function( elems, selector ) {
  12208. // make array of elems
  12209. elems = utils.makeArray( elems );
  12210. var ffElems = [];
  12211. elems.forEach( function( elem ) {
  12212. // check that elem is an actual element
  12213. if ( !( elem instanceof HTMLElement ) ) {
  12214. return;
  12215. }
  12216. // add elem if no selector
  12217. if ( !selector ) {
  12218. ffElems.push( elem );
  12219. return;
  12220. }
  12221. // filter & find items if we have a selector
  12222. // filter
  12223. if ( matchesSelector( elem, selector ) ) {
  12224. ffElems.push( elem );
  12225. }
  12226. // find children
  12227. var childElems = elem.querySelectorAll( selector );
  12228. // concat childElems to filterFound array
  12229. for ( var i=0; i < childElems.length; i++ ) {
  12230. ffElems.push( childElems[i] );
  12231. }
  12232. });
  12233. return ffElems;
  12234. };
  12235. // ----- debounceMethod ----- //
  12236. utils.debounceMethod = function( _class, methodName, threshold ) {
  12237. threshold = threshold || 100;
  12238. // original method
  12239. var method = _class.prototype[ methodName ];
  12240. var timeoutName = methodName + 'Timeout';
  12241. _class.prototype[ methodName ] = function() {
  12242. var timeout = this[ timeoutName ];
  12243. clearTimeout( timeout );
  12244. var args = arguments;
  12245. var _this = this;
  12246. this[ timeoutName ] = setTimeout( function() {
  12247. method.apply( _this, args );
  12248. delete _this[ timeoutName ];
  12249. }, threshold );
  12250. };
  12251. };
  12252. // ----- docReady ----- //
  12253. utils.docReady = function( callback ) {
  12254. var readyState = document.readyState;
  12255. if ( readyState == 'complete' || readyState == 'interactive' ) {
  12256. // do async to allow for other scripts to run. metafizzy/flickity#441
  12257. setTimeout( callback );
  12258. } else {
  12259. document.addEventListener( 'DOMContentLoaded', callback );
  12260. }
  12261. };
  12262. // ----- htmlInit ----- //
  12263. // http://jamesroberts.name/blog/2010/02/22/string-functions-for-javascript-trim-to-camel-case-to-dashed-and-to-underscore/
  12264. utils.toDashed = function( str ) {
  12265. return str.replace( /(.)([A-Z])/g, function( match, $1, $2 ) {
  12266. return $1 + '-' + $2;
  12267. }).toLowerCase();
  12268. };
  12269. var console = window.console;
  12270. /**
  12271. * allow user to initialize classes via [data-namespace] or .js-namespace class
  12272. * htmlInit( Widget, 'widgetName' )
  12273. * options are parsed from data-namespace-options
  12274. */
  12275. utils.htmlInit = function( WidgetClass, namespace ) {
  12276. utils.docReady( function() {
  12277. var dashedNamespace = utils.toDashed( namespace );
  12278. var dataAttr = 'data-' + dashedNamespace;
  12279. var dataAttrElems = document.querySelectorAll( '[' + dataAttr + ']' );
  12280. var jsDashElems = document.querySelectorAll( '.js-' + dashedNamespace );
  12281. var elems = utils.makeArray( dataAttrElems )
  12282. .concat( utils.makeArray( jsDashElems ) );
  12283. var dataOptionsAttr = dataAttr + '-options';
  12284. var jQuery = window.jQuery;
  12285. elems.forEach( function( elem ) {
  12286. var attr = elem.getAttribute( dataAttr ) ||
  12287. elem.getAttribute( dataOptionsAttr );
  12288. var options;
  12289. try {
  12290. options = attr && JSON.parse( attr );
  12291. } catch ( error ) {
  12292. // log error, do not initialize
  12293. if ( console ) {
  12294. console.error( 'Error parsing ' + dataAttr + ' on ' + elem.className +
  12295. ': ' + error );
  12296. }
  12297. return;
  12298. }
  12299. // initialize
  12300. var instance = new WidgetClass( elem, options );
  12301. // make available via $().data('namespace')
  12302. if ( jQuery ) {
  12303. jQuery.data( elem, namespace, instance );
  12304. }
  12305. });
  12306. });
  12307. };
  12308. // ----- ----- //
  12309. return utils;
  12310. }));
  12311. /**
  12312. * Outlayer Item
  12313. */
  12314. ( function( window, factory ) {
  12315. // universal module definition
  12316. /* jshint strict: false */ /* globals define, module, require */
  12317. if ( typeof define == 'function' && define.amd ) {
  12318. // AMD - RequireJS
  12319. define( 'outlayer/item',[
  12320. 'ev-emitter/ev-emitter',
  12321. 'get-size/get-size'
  12322. ],
  12323. factory
  12324. );
  12325. } else if ( typeof module == 'object' && module.exports ) {
  12326. // CommonJS - Browserify, Webpack
  12327. module.exports = factory(
  12328. require('ev-emitter'),
  12329. require('get-size')
  12330. );
  12331. } else {
  12332. // browser global
  12333. window.Outlayer = {};
  12334. window.Outlayer.Item = factory(
  12335. window.EvEmitter,
  12336. window.getSize
  12337. );
  12338. }
  12339. }( window, function factory( EvEmitter, getSize ) {
  12340. 'use strict';
  12341. // ----- helpers ----- //
  12342. function isEmptyObj( obj ) {
  12343. for ( var prop in obj ) {
  12344. return false;
  12345. }
  12346. prop = null;
  12347. return true;
  12348. }
  12349. // -------------------------- CSS3 support -------------------------- //
  12350. var docElemStyle = document.documentElement.style;
  12351. var transitionProperty = typeof docElemStyle.transition == 'string' ?
  12352. 'transition' : 'WebkitTransition';
  12353. var transformProperty = typeof docElemStyle.transform == 'string' ?
  12354. 'transform' : 'WebkitTransform';
  12355. var transitionEndEvent = {
  12356. WebkitTransition: 'webkitTransitionEnd',
  12357. transition: 'transitionend'
  12358. }[ transitionProperty ];
  12359. // cache all vendor properties that could have vendor prefix
  12360. var vendorProperties = {
  12361. transform: transformProperty,
  12362. transition: transitionProperty,
  12363. transitionDuration: transitionProperty + 'Duration',
  12364. transitionProperty: transitionProperty + 'Property',
  12365. transitionDelay: transitionProperty + 'Delay'
  12366. };
  12367. // -------------------------- Item -------------------------- //
  12368. function Item( element, layout ) {
  12369. if ( !element ) {
  12370. return;
  12371. }
  12372. this.element = element;
  12373. // parent layout class, i.e. Masonry, Isotope, or Packery
  12374. this.layout = layout;
  12375. this.position = {
  12376. x: 0,
  12377. y: 0
  12378. };
  12379. this._create();
  12380. }
  12381. // inherit EvEmitter
  12382. var proto = Item.prototype = Object.create( EvEmitter.prototype );
  12383. proto.constructor = Item;
  12384. proto._create = function() {
  12385. // transition objects
  12386. this._transn = {
  12387. ingProperties: {},
  12388. clean: {},
  12389. onEnd: {}
  12390. };
  12391. this.css({
  12392. position: 'absolute'
  12393. });
  12394. };
  12395. // trigger specified handler for event type
  12396. proto.handleEvent = function( event ) {
  12397. var method = 'on' + event.type;
  12398. if ( this[ method ] ) {
  12399. this[ method ]( event );
  12400. }
  12401. };
  12402. proto.getSize = function() {
  12403. this.size = getSize( this.element );
  12404. };
  12405. /**
  12406. * apply CSS styles to element
  12407. * @param {Object} style
  12408. */
  12409. proto.css = function( style ) {
  12410. var elemStyle = this.element.style;
  12411. for ( var prop in style ) {
  12412. // use vendor property if available
  12413. var supportedProp = vendorProperties[ prop ] || prop;
  12414. elemStyle[ supportedProp ] = style[ prop ];
  12415. }
  12416. };
  12417. // measure position, and sets it
  12418. proto.getPosition = function() {
  12419. var style = getComputedStyle( this.element );
  12420. var isOriginLeft = this.layout._getOption('originLeft');
  12421. var isOriginTop = this.layout._getOption('originTop');
  12422. var xValue = style[ isOriginLeft ? 'left' : 'right' ];
  12423. var yValue = style[ isOriginTop ? 'top' : 'bottom' ];
  12424. var x = parseFloat( xValue );
  12425. var y = parseFloat( yValue );
  12426. // convert percent to pixels
  12427. var layoutSize = this.layout.size;
  12428. if ( xValue.indexOf('%') != -1 ) {
  12429. x = ( x / 100 ) * layoutSize.width;
  12430. }
  12431. if ( yValue.indexOf('%') != -1 ) {
  12432. y = ( y / 100 ) * layoutSize.height;
  12433. }
  12434. // clean up 'auto' or other non-integer values
  12435. x = isNaN( x ) ? 0 : x;
  12436. y = isNaN( y ) ? 0 : y;
  12437. // remove padding from measurement
  12438. x -= isOriginLeft ? layoutSize.paddingLeft : layoutSize.paddingRight;
  12439. y -= isOriginTop ? layoutSize.paddingTop : layoutSize.paddingBottom;
  12440. this.position.x = x;
  12441. this.position.y = y;
  12442. };
  12443. // set settled position, apply padding
  12444. proto.layoutPosition = function() {
  12445. var layoutSize = this.layout.size;
  12446. var style = {};
  12447. var isOriginLeft = this.layout._getOption('originLeft');
  12448. var isOriginTop = this.layout._getOption('originTop');
  12449. // x
  12450. var xPadding = isOriginLeft ? 'paddingLeft' : 'paddingRight';
  12451. var xProperty = isOriginLeft ? 'left' : 'right';
  12452. var xResetProperty = isOriginLeft ? 'right' : 'left';
  12453. var x = this.position.x + layoutSize[ xPadding ];
  12454. // set in percentage or pixels
  12455. style[ xProperty ] = this.getXValue( x );
  12456. // reset other property
  12457. style[ xResetProperty ] = '';
  12458. // y
  12459. var yPadding = isOriginTop ? 'paddingTop' : 'paddingBottom';
  12460. var yProperty = isOriginTop ? 'top' : 'bottom';
  12461. var yResetProperty = isOriginTop ? 'bottom' : 'top';
  12462. var y = this.position.y + layoutSize[ yPadding ];
  12463. // set in percentage or pixels
  12464. style[ yProperty ] = this.getYValue( y );
  12465. // reset other property
  12466. style[ yResetProperty ] = '';
  12467. this.css( style );
  12468. this.emitEvent( 'layout', [ this ] );
  12469. };
  12470. proto.getXValue = function( x ) {
  12471. var isHorizontal = this.layout._getOption('horizontal');
  12472. return this.layout.options.percentPosition && !isHorizontal ?
  12473. ( ( x / this.layout.size.width ) * 100 ) + '%' : x + 'px';
  12474. };
  12475. proto.getYValue = function( y ) {
  12476. var isHorizontal = this.layout._getOption('horizontal');
  12477. return this.layout.options.percentPosition && isHorizontal ?
  12478. ( ( y / this.layout.size.height ) * 100 ) + '%' : y + 'px';
  12479. };
  12480. proto._transitionTo = function( x, y ) {
  12481. this.getPosition();
  12482. // get current x & y from top/left
  12483. var curX = this.position.x;
  12484. var curY = this.position.y;
  12485. var didNotMove = x == this.position.x && y == this.position.y;
  12486. // save end position
  12487. this.setPosition( x, y );
  12488. // if did not move and not transitioning, just go to layout
  12489. if ( didNotMove && !this.isTransitioning ) {
  12490. this.layoutPosition();
  12491. return;
  12492. }
  12493. var transX = x - curX;
  12494. var transY = y - curY;
  12495. var transitionStyle = {};
  12496. transitionStyle.transform = this.getTranslate( transX, transY );
  12497. this.transition({
  12498. to: transitionStyle,
  12499. onTransitionEnd: {
  12500. transform: this.layoutPosition
  12501. },
  12502. isCleaning: true
  12503. });
  12504. };
  12505. proto.getTranslate = function( x, y ) {
  12506. // flip cooridinates if origin on right or bottom
  12507. var isOriginLeft = this.layout._getOption('originLeft');
  12508. var isOriginTop = this.layout._getOption('originTop');
  12509. x = isOriginLeft ? x : -x;
  12510. y = isOriginTop ? y : -y;
  12511. return 'translate3d(' + x + 'px, ' + y + 'px, 0)';
  12512. };
  12513. // non transition + transform support
  12514. proto.goTo = function( x, y ) {
  12515. this.setPosition( x, y );
  12516. this.layoutPosition();
  12517. };
  12518. proto.moveTo = proto._transitionTo;
  12519. proto.setPosition = function( x, y ) {
  12520. this.position.x = parseFloat( x );
  12521. this.position.y = parseFloat( y );
  12522. };
  12523. // ----- transition ----- //
  12524. /**
  12525. * @param {Object} style - CSS
  12526. * @param {Function} onTransitionEnd
  12527. */
  12528. // non transition, just trigger callback
  12529. proto._nonTransition = function( args ) {
  12530. this.css( args.to );
  12531. if ( args.isCleaning ) {
  12532. this._removeStyles( args.to );
  12533. }
  12534. for ( var prop in args.onTransitionEnd ) {
  12535. args.onTransitionEnd[ prop ].call( this );
  12536. }
  12537. };
  12538. /**
  12539. * proper transition
  12540. * @param {Object} args - arguments
  12541. * @param {Object} to - style to transition to
  12542. * @param {Object} from - style to start transition from
  12543. * @param {Boolean} isCleaning - removes transition styles after transition
  12544. * @param {Function} onTransitionEnd - callback
  12545. */
  12546. proto.transition = function( args ) {
  12547. // redirect to nonTransition if no transition duration
  12548. if ( !parseFloat( this.layout.options.transitionDuration ) ) {
  12549. this._nonTransition( args );
  12550. return;
  12551. }
  12552. var _transition = this._transn;
  12553. // keep track of onTransitionEnd callback by css property
  12554. for ( var prop in args.onTransitionEnd ) {
  12555. _transition.onEnd[ prop ] = args.onTransitionEnd[ prop ];
  12556. }
  12557. // keep track of properties that are transitioning
  12558. for ( prop in args.to ) {
  12559. _transition.ingProperties[ prop ] = true;
  12560. // keep track of properties to clean up when transition is done
  12561. if ( args.isCleaning ) {
  12562. _transition.clean[ prop ] = true;
  12563. }
  12564. }
  12565. // set from styles
  12566. if ( args.from ) {
  12567. this.css( args.from );
  12568. // force redraw. http://blog.alexmaccaw.com/css-transitions
  12569. var h = this.element.offsetHeight;
  12570. // hack for JSHint to hush about unused var
  12571. h = null;
  12572. }
  12573. // enable transition
  12574. this.enableTransition( args.to );
  12575. // set styles that are transitioning
  12576. this.css( args.to );
  12577. this.isTransitioning = true;
  12578. };
  12579. // dash before all cap letters, including first for
  12580. // WebkitTransform => -webkit-transform
  12581. function toDashedAll( str ) {
  12582. return str.replace( /([A-Z])/g, function( $1 ) {
  12583. return '-' + $1.toLowerCase();
  12584. });
  12585. }
  12586. var transitionProps = 'opacity,' + toDashedAll( transformProperty );
  12587. proto.enableTransition = function(/* style */) {
  12588. // HACK changing transitionProperty during a transition
  12589. // will cause transition to jump
  12590. if ( this.isTransitioning ) {
  12591. return;
  12592. }
  12593. // make `transition: foo, bar, baz` from style object
  12594. // HACK un-comment this when enableTransition can work
  12595. // while a transition is happening
  12596. // var transitionValues = [];
  12597. // for ( var prop in style ) {
  12598. // // dash-ify camelCased properties like WebkitTransition
  12599. // prop = vendorProperties[ prop ] || prop;
  12600. // transitionValues.push( toDashedAll( prop ) );
  12601. // }
  12602. // munge number to millisecond, to match stagger
  12603. var duration = this.layout.options.transitionDuration;
  12604. duration = typeof duration == 'number' ? duration + 'ms' : duration;
  12605. // enable transition styles
  12606. this.css({
  12607. transitionProperty: transitionProps,
  12608. transitionDuration: duration,
  12609. transitionDelay: this.staggerDelay || 0
  12610. });
  12611. // listen for transition end event
  12612. this.element.addEventListener( transitionEndEvent, this, false );
  12613. };
  12614. // ----- events ----- //
  12615. proto.onwebkitTransitionEnd = function( event ) {
  12616. this.ontransitionend( event );
  12617. };
  12618. proto.onotransitionend = function( event ) {
  12619. this.ontransitionend( event );
  12620. };
  12621. // properties that I munge to make my life easier
  12622. var dashedVendorProperties = {
  12623. '-webkit-transform': 'transform'
  12624. };
  12625. proto.ontransitionend = function( event ) {
  12626. // disregard bubbled events from children
  12627. if ( event.target !== this.element ) {
  12628. return;
  12629. }
  12630. var _transition = this._transn;
  12631. // get property name of transitioned property, convert to prefix-free
  12632. var propertyName = dashedVendorProperties[ event.propertyName ] || event.propertyName;
  12633. // remove property that has completed transitioning
  12634. delete _transition.ingProperties[ propertyName ];
  12635. // check if any properties are still transitioning
  12636. if ( isEmptyObj( _transition.ingProperties ) ) {
  12637. // all properties have completed transitioning
  12638. this.disableTransition();
  12639. }
  12640. // clean style
  12641. if ( propertyName in _transition.clean ) {
  12642. // clean up style
  12643. this.element.style[ event.propertyName ] = '';
  12644. delete _transition.clean[ propertyName ];
  12645. }
  12646. // trigger onTransitionEnd callback
  12647. if ( propertyName in _transition.onEnd ) {
  12648. var onTransitionEnd = _transition.onEnd[ propertyName ];
  12649. onTransitionEnd.call( this );
  12650. delete _transition.onEnd[ propertyName ];
  12651. }
  12652. this.emitEvent( 'transitionEnd', [ this ] );
  12653. };
  12654. proto.disableTransition = function() {
  12655. this.removeTransitionStyles();
  12656. this.element.removeEventListener( transitionEndEvent, this, false );
  12657. this.isTransitioning = false;
  12658. };
  12659. /**
  12660. * removes style property from element
  12661. * @param {Object} style
  12662. **/
  12663. proto._removeStyles = function( style ) {
  12664. // clean up transition styles
  12665. var cleanStyle = {};
  12666. for ( var prop in style ) {
  12667. cleanStyle[ prop ] = '';
  12668. }
  12669. this.css( cleanStyle );
  12670. };
  12671. var cleanTransitionStyle = {
  12672. transitionProperty: '',
  12673. transitionDuration: '',
  12674. transitionDelay: ''
  12675. };
  12676. proto.removeTransitionStyles = function() {
  12677. // remove transition
  12678. this.css( cleanTransitionStyle );
  12679. };
  12680. // ----- stagger ----- //
  12681. proto.stagger = function( delay ) {
  12682. delay = isNaN( delay ) ? 0 : delay;
  12683. this.staggerDelay = delay + 'ms';
  12684. };
  12685. // ----- show/hide/remove ----- //
  12686. // remove element from DOM
  12687. proto.removeElem = function() {
  12688. this.element.parentNode.removeChild( this.element );
  12689. // remove display: none
  12690. this.css({ display: '' });
  12691. this.emitEvent( 'remove', [ this ] );
  12692. };
  12693. proto.remove = function() {
  12694. // just remove element if no transition support or no transition
  12695. if ( !transitionProperty || !parseFloat( this.layout.options.transitionDuration ) ) {
  12696. this.removeElem();
  12697. return;
  12698. }
  12699. // start transition
  12700. this.once( 'transitionEnd', function() {
  12701. this.removeElem();
  12702. });
  12703. this.hide();
  12704. };
  12705. proto.reveal = function() {
  12706. delete this.isHidden;
  12707. // remove display: none
  12708. this.css({ display: '' });
  12709. var options = this.layout.options;
  12710. var onTransitionEnd = {};
  12711. var transitionEndProperty = this.getHideRevealTransitionEndProperty('visibleStyle');
  12712. onTransitionEnd[ transitionEndProperty ] = this.onRevealTransitionEnd;
  12713. this.transition({
  12714. from: options.hiddenStyle,
  12715. to: options.visibleStyle,
  12716. isCleaning: true,
  12717. onTransitionEnd: onTransitionEnd
  12718. });
  12719. };
  12720. proto.onRevealTransitionEnd = function() {
  12721. // check if still visible
  12722. // during transition, item may have been hidden
  12723. if ( !this.isHidden ) {
  12724. this.emitEvent('reveal');
  12725. }
  12726. };
  12727. /**
  12728. * get style property use for hide/reveal transition end
  12729. * @param {String} styleProperty - hiddenStyle/visibleStyle
  12730. * @returns {String}
  12731. */
  12732. proto.getHideRevealTransitionEndProperty = function( styleProperty ) {
  12733. var optionStyle = this.layout.options[ styleProperty ];
  12734. // use opacity
  12735. if ( optionStyle.opacity ) {
  12736. return 'opacity';
  12737. }
  12738. // get first property
  12739. for ( var prop in optionStyle ) {
  12740. return prop;
  12741. }
  12742. };
  12743. proto.hide = function() {
  12744. // set flag
  12745. this.isHidden = true;
  12746. // remove display: none
  12747. this.css({ display: '' });
  12748. var options = this.layout.options;
  12749. var onTransitionEnd = {};
  12750. var transitionEndProperty = this.getHideRevealTransitionEndProperty('hiddenStyle');
  12751. onTransitionEnd[ transitionEndProperty ] = this.onHideTransitionEnd;
  12752. this.transition({
  12753. from: options.visibleStyle,
  12754. to: options.hiddenStyle,
  12755. // keep hidden stuff hidden
  12756. isCleaning: true,
  12757. onTransitionEnd: onTransitionEnd
  12758. });
  12759. };
  12760. proto.onHideTransitionEnd = function() {
  12761. // check if still hidden
  12762. // during transition, item may have been un-hidden
  12763. if ( this.isHidden ) {
  12764. this.css({ display: 'none' });
  12765. this.emitEvent('hide');
  12766. }
  12767. };
  12768. proto.destroy = function() {
  12769. this.css({
  12770. position: '',
  12771. left: '',
  12772. right: '',
  12773. top: '',
  12774. bottom: '',
  12775. transition: '',
  12776. transform: ''
  12777. });
  12778. };
  12779. return Item;
  12780. }));
  12781. /*!
  12782. * Outlayer v2.1.1
  12783. * the brains and guts of a layout library
  12784. * MIT license
  12785. */
  12786. ( function( window, factory ) {
  12787. 'use strict';
  12788. // universal module definition
  12789. /* jshint strict: false */ /* globals define, module, require */
  12790. if ( typeof define == 'function' && define.amd ) {
  12791. // AMD - RequireJS
  12792. define( 'outlayer/outlayer',[
  12793. 'ev-emitter/ev-emitter',
  12794. 'get-size/get-size',
  12795. 'fizzy-ui-utils/utils',
  12796. './item'
  12797. ],
  12798. function( EvEmitter, getSize, utils, Item ) {
  12799. return factory( window, EvEmitter, getSize, utils, Item);
  12800. }
  12801. );
  12802. } else if ( typeof module == 'object' && module.exports ) {
  12803. // CommonJS - Browserify, Webpack
  12804. module.exports = factory(
  12805. window,
  12806. require('ev-emitter'),
  12807. require('get-size'),
  12808. require('fizzy-ui-utils'),
  12809. require('./item')
  12810. );
  12811. } else {
  12812. // browser global
  12813. window.Outlayer = factory(
  12814. window,
  12815. window.EvEmitter,
  12816. window.getSize,
  12817. window.fizzyUIUtils,
  12818. window.Outlayer.Item
  12819. );
  12820. }
  12821. }( window, function factory( window, EvEmitter, getSize, utils, Item ) {
  12822. 'use strict';
  12823. // ----- vars ----- //
  12824. var console = window.console;
  12825. var jQuery = window.jQuery;
  12826. var noop = function() {};
  12827. // -------------------------- Outlayer -------------------------- //
  12828. // globally unique identifiers
  12829. var GUID = 0;
  12830. // internal store of all Outlayer intances
  12831. var instances = {};
  12832. /**
  12833. * @param {Element, String} element
  12834. * @param {Object} options
  12835. * @constructor
  12836. */
  12837. function Outlayer( element, options ) {
  12838. var queryElement = utils.getQueryElement( element );
  12839. if ( !queryElement ) {
  12840. if ( console ) {
  12841. console.error( 'Bad element for ' + this.constructor.namespace +
  12842. ': ' + ( queryElement || element ) );
  12843. }
  12844. return;
  12845. }
  12846. this.element = queryElement;
  12847. // add jQuery
  12848. if ( jQuery ) {
  12849. this.$element = jQuery( this.element );
  12850. }
  12851. // options
  12852. this.options = utils.extend( {}, this.constructor.defaults );
  12853. this.option( options );
  12854. // add id for Outlayer.getFromElement
  12855. var id = ++GUID;
  12856. this.element.outlayerGUID = id; // expando
  12857. instances[ id ] = this; // associate via id
  12858. // kick it off
  12859. this._create();
  12860. var isInitLayout = this._getOption('initLayout');
  12861. if ( isInitLayout ) {
  12862. this.layout();
  12863. }
  12864. }
  12865. // settings are for internal use only
  12866. Outlayer.namespace = 'outlayer';
  12867. Outlayer.Item = Item;
  12868. // default options
  12869. Outlayer.defaults = {
  12870. containerStyle: {
  12871. position: 'relative'
  12872. },
  12873. initLayout: true,
  12874. originLeft: true,
  12875. originTop: true,
  12876. resize: true,
  12877. resizeContainer: true,
  12878. // item options
  12879. transitionDuration: '0.4s',
  12880. hiddenStyle: {
  12881. opacity: 0,
  12882. transform: 'scale(0.001)'
  12883. },
  12884. visibleStyle: {
  12885. opacity: 1,
  12886. transform: 'scale(1)'
  12887. }
  12888. };
  12889. var proto = Outlayer.prototype;
  12890. // inherit EvEmitter
  12891. utils.extend( proto, EvEmitter.prototype );
  12892. /**
  12893. * set options
  12894. * @param {Object} opts
  12895. */
  12896. proto.option = function( opts ) {
  12897. utils.extend( this.options, opts );
  12898. };
  12899. /**
  12900. * get backwards compatible option value, check old name
  12901. */
  12902. proto._getOption = function( option ) {
  12903. var oldOption = this.constructor.compatOptions[ option ];
  12904. return oldOption && this.options[ oldOption ] !== undefined ?
  12905. this.options[ oldOption ] : this.options[ option ];
  12906. };
  12907. Outlayer.compatOptions = {
  12908. // currentName: oldName
  12909. initLayout: 'isInitLayout',
  12910. horizontal: 'isHorizontal',
  12911. layoutInstant: 'isLayoutInstant',
  12912. originLeft: 'isOriginLeft',
  12913. originTop: 'isOriginTop',
  12914. resize: 'isResizeBound',
  12915. resizeContainer: 'isResizingContainer'
  12916. };
  12917. proto._create = function() {
  12918. // get items from children
  12919. this.reloadItems();
  12920. // elements that affect layout, but are not laid out
  12921. this.stamps = [];
  12922. this.stamp( this.options.stamp );
  12923. // set container style
  12924. utils.extend( this.element.style, this.options.containerStyle );
  12925. // bind resize method
  12926. var canBindResize = this._getOption('resize');
  12927. if ( canBindResize ) {
  12928. this.bindResize();
  12929. }
  12930. };
  12931. // goes through all children again and gets bricks in proper order
  12932. proto.reloadItems = function() {
  12933. // collection of item elements
  12934. this.items = this._itemize( this.element.children );
  12935. };
  12936. /**
  12937. * turn elements into Outlayer.Items to be used in layout
  12938. * @param {Array or NodeList or HTMLElement} elems
  12939. * @returns {Array} items - collection of new Outlayer Items
  12940. */
  12941. proto._itemize = function( elems ) {
  12942. var itemElems = this._filterFindItemElements( elems );
  12943. var Item = this.constructor.Item;
  12944. // create new Outlayer Items for collection
  12945. var items = [];
  12946. for ( var i=0; i < itemElems.length; i++ ) {
  12947. var elem = itemElems[i];
  12948. var item = new Item( elem, this );
  12949. items.push( item );
  12950. }
  12951. return items;
  12952. };
  12953. /**
  12954. * get item elements to be used in layout
  12955. * @param {Array or NodeList or HTMLElement} elems
  12956. * @returns {Array} items - item elements
  12957. */
  12958. proto._filterFindItemElements = function( elems ) {
  12959. return utils.filterFindElements( elems, this.options.itemSelector );
  12960. };
  12961. /**
  12962. * getter method for getting item elements
  12963. * @returns {Array} elems - collection of item elements
  12964. */
  12965. proto.getItemElements = function() {
  12966. return this.items.map( function( item ) {
  12967. return item.element;
  12968. });
  12969. };
  12970. // ----- init & layout ----- //
  12971. /**
  12972. * lays out all items
  12973. */
  12974. proto.layout = function() {
  12975. this._resetLayout();
  12976. this._manageStamps();
  12977. // don't animate first layout
  12978. var layoutInstant = this._getOption('layoutInstant');
  12979. var isInstant = layoutInstant !== undefined ?
  12980. layoutInstant : !this._isLayoutInited;
  12981. this.layoutItems( this.items, isInstant );
  12982. // flag for initalized
  12983. this._isLayoutInited = true;
  12984. };
  12985. // _init is alias for layout
  12986. proto._init = proto.layout;
  12987. /**
  12988. * logic before any new layout
  12989. */
  12990. proto._resetLayout = function() {
  12991. this.getSize();
  12992. };
  12993. proto.getSize = function() {
  12994. this.size = getSize( this.element );
  12995. };
  12996. /**
  12997. * get measurement from option, for columnWidth, rowHeight, gutter
  12998. * if option is String -> get element from selector string, & get size of element
  12999. * if option is Element -> get size of element
  13000. * else use option as a number
  13001. *
  13002. * @param {String} measurement
  13003. * @param {String} size - width or height
  13004. * @private
  13005. */
  13006. proto._getMeasurement = function( measurement, size ) {
  13007. var option = this.options[ measurement ];
  13008. var elem;
  13009. if ( !option ) {
  13010. // default to 0
  13011. this[ measurement ] = 0;
  13012. } else {
  13013. // use option as an element
  13014. if ( typeof option == 'string' ) {
  13015. elem = this.element.querySelector( option );
  13016. } else if ( option instanceof HTMLElement ) {
  13017. elem = option;
  13018. }
  13019. // use size of element, if element
  13020. this[ measurement ] = elem ? getSize( elem )[ size ] : option;
  13021. }
  13022. };
  13023. /**
  13024. * layout a collection of item elements
  13025. * @api public
  13026. */
  13027. proto.layoutItems = function( items, isInstant ) {
  13028. items = this._getItemsForLayout( items );
  13029. this._layoutItems( items, isInstant );
  13030. this._postLayout();
  13031. };
  13032. /**
  13033. * get the items to be laid out
  13034. * you may want to skip over some items
  13035. * @param {Array} items
  13036. * @returns {Array} items
  13037. */
  13038. proto._getItemsForLayout = function( items ) {
  13039. return items.filter( function( item ) {
  13040. return !item.isIgnored;
  13041. });
  13042. };
  13043. /**
  13044. * layout items
  13045. * @param {Array} items
  13046. * @param {Boolean} isInstant
  13047. */
  13048. proto._layoutItems = function( items, isInstant ) {
  13049. this._emitCompleteOnItems( 'layout', items );
  13050. if ( !items || !items.length ) {
  13051. // no items, emit event with empty array
  13052. return;
  13053. }
  13054. var queue = [];
  13055. items.forEach( function( item ) {
  13056. // get x/y object from method
  13057. var position = this._getItemLayoutPosition( item );
  13058. // enqueue
  13059. position.item = item;
  13060. position.isInstant = isInstant || item.isLayoutInstant;
  13061. queue.push( position );
  13062. }, this );
  13063. this._processLayoutQueue( queue );
  13064. };
  13065. /**
  13066. * get item layout position
  13067. * @param {Outlayer.Item} item
  13068. * @returns {Object} x and y position
  13069. */
  13070. proto._getItemLayoutPosition = function( /* item */ ) {
  13071. return {
  13072. x: 0,
  13073. y: 0
  13074. };
  13075. };
  13076. /**
  13077. * iterate over array and position each item
  13078. * Reason being - separating this logic prevents 'layout invalidation'
  13079. * thx @paul_irish
  13080. * @param {Array} queue
  13081. */
  13082. proto._processLayoutQueue = function( queue ) {
  13083. this.updateStagger();
  13084. queue.forEach( function( obj, i ) {
  13085. this._positionItem( obj.item, obj.x, obj.y, obj.isInstant, i );
  13086. }, this );
  13087. };
  13088. // set stagger from option in milliseconds number
  13089. proto.updateStagger = function() {
  13090. var stagger = this.options.stagger;
  13091. if ( stagger === null || stagger === undefined ) {
  13092. this.stagger = 0;
  13093. return;
  13094. }
  13095. this.stagger = getMilliseconds( stagger );
  13096. return this.stagger;
  13097. };
  13098. /**
  13099. * Sets position of item in DOM
  13100. * @param {Outlayer.Item} item
  13101. * @param {Number} x - horizontal position
  13102. * @param {Number} y - vertical position
  13103. * @param {Boolean} isInstant - disables transitions
  13104. */
  13105. proto._positionItem = function( item, x, y, isInstant, i ) {
  13106. if ( isInstant ) {
  13107. // if not transition, just set CSS
  13108. item.goTo( x, y );
  13109. } else {
  13110. item.stagger( i * this.stagger );
  13111. item.moveTo( x, y );
  13112. }
  13113. };
  13114. /**
  13115. * Any logic you want to do after each layout,
  13116. * i.e. size the container
  13117. */
  13118. proto._postLayout = function() {
  13119. this.resizeContainer();
  13120. };
  13121. proto.resizeContainer = function() {
  13122. var isResizingContainer = this._getOption('resizeContainer');
  13123. if ( !isResizingContainer ) {
  13124. return;
  13125. }
  13126. var size = this._getContainerSize();
  13127. if ( size ) {
  13128. this._setContainerMeasure( size.width, true );
  13129. this._setContainerMeasure( size.height, false );
  13130. }
  13131. };
  13132. /**
  13133. * Sets width or height of container if returned
  13134. * @returns {Object} size
  13135. * @param {Number} width
  13136. * @param {Number} height
  13137. */
  13138. proto._getContainerSize = noop;
  13139. /**
  13140. * @param {Number} measure - size of width or height
  13141. * @param {Boolean} isWidth
  13142. */
  13143. proto._setContainerMeasure = function( measure, isWidth ) {
  13144. if ( measure === undefined ) {
  13145. return;
  13146. }
  13147. var elemSize = this.size;
  13148. // add padding and border width if border box
  13149. if ( elemSize.isBorderBox ) {
  13150. measure += isWidth ? elemSize.paddingLeft + elemSize.paddingRight +
  13151. elemSize.borderLeftWidth + elemSize.borderRightWidth :
  13152. elemSize.paddingBottom + elemSize.paddingTop +
  13153. elemSize.borderTopWidth + elemSize.borderBottomWidth;
  13154. }
  13155. measure = Math.max( measure, 0 );
  13156. this.element.style[ isWidth ? 'width' : 'height' ] = measure + 'px';
  13157. };
  13158. /**
  13159. * emit eventComplete on a collection of items events
  13160. * @param {String} eventName
  13161. * @param {Array} items - Outlayer.Items
  13162. */
  13163. proto._emitCompleteOnItems = function( eventName, items ) {
  13164. var _this = this;
  13165. function onComplete() {
  13166. _this.dispatchEvent( eventName + 'Complete', null, [ items ] );
  13167. }
  13168. var count = items.length;
  13169. if ( !items || !count ) {
  13170. onComplete();
  13171. return;
  13172. }
  13173. var doneCount = 0;
  13174. function tick() {
  13175. doneCount++;
  13176. if ( doneCount == count ) {
  13177. onComplete();
  13178. }
  13179. }
  13180. // bind callback
  13181. items.forEach( function( item ) {
  13182. item.once( eventName, tick );
  13183. });
  13184. };
  13185. /**
  13186. * emits events via EvEmitter and jQuery events
  13187. * @param {String} type - name of event
  13188. * @param {Event} event - original event
  13189. * @param {Array} args - extra arguments
  13190. */
  13191. proto.dispatchEvent = function( type, event, args ) {
  13192. // add original event to arguments
  13193. var emitArgs = event ? [ event ].concat( args ) : args;
  13194. this.emitEvent( type, emitArgs );
  13195. if ( jQuery ) {
  13196. // set this.$element
  13197. this.$element = this.$element || jQuery( this.element );
  13198. if ( event ) {
  13199. // create jQuery event
  13200. var $event = jQuery.Event( event );
  13201. $event.type = type;
  13202. this.$element.trigger( $event, args );
  13203. } else {
  13204. // just trigger with type if no event available
  13205. this.$element.trigger( type, args );
  13206. }
  13207. }
  13208. };
  13209. // -------------------------- ignore & stamps -------------------------- //
  13210. /**
  13211. * keep item in collection, but do not lay it out
  13212. * ignored items do not get skipped in layout
  13213. * @param {Element} elem
  13214. */
  13215. proto.ignore = function( elem ) {
  13216. var item = this.getItem( elem );
  13217. if ( item ) {
  13218. item.isIgnored = true;
  13219. }
  13220. };
  13221. /**
  13222. * return item to layout collection
  13223. * @param {Element} elem
  13224. */
  13225. proto.unignore = function( elem ) {
  13226. var item = this.getItem( elem );
  13227. if ( item ) {
  13228. delete item.isIgnored;
  13229. }
  13230. };
  13231. /**
  13232. * adds elements to stamps
  13233. * @param {NodeList, Array, Element, or String} elems
  13234. */
  13235. proto.stamp = function( elems ) {
  13236. elems = this._find( elems );
  13237. if ( !elems ) {
  13238. return;
  13239. }
  13240. this.stamps = this.stamps.concat( elems );
  13241. // ignore
  13242. elems.forEach( this.ignore, this );
  13243. };
  13244. /**
  13245. * removes elements to stamps
  13246. * @param {NodeList, Array, or Element} elems
  13247. */
  13248. proto.unstamp = function( elems ) {
  13249. elems = this._find( elems );
  13250. if ( !elems ){
  13251. return;
  13252. }
  13253. elems.forEach( function( elem ) {
  13254. // filter out removed stamp elements
  13255. utils.removeFrom( this.stamps, elem );
  13256. this.unignore( elem );
  13257. }, this );
  13258. };
  13259. /**
  13260. * finds child elements
  13261. * @param {NodeList, Array, Element, or String} elems
  13262. * @returns {Array} elems
  13263. */
  13264. proto._find = function( elems ) {
  13265. if ( !elems ) {
  13266. return;
  13267. }
  13268. // if string, use argument as selector string
  13269. if ( typeof elems == 'string' ) {
  13270. elems = this.element.querySelectorAll( elems );
  13271. }
  13272. elems = utils.makeArray( elems );
  13273. return elems;
  13274. };
  13275. proto._manageStamps = function() {
  13276. if ( !this.stamps || !this.stamps.length ) {
  13277. return;
  13278. }
  13279. this._getBoundingRect();
  13280. this.stamps.forEach( this._manageStamp, this );
  13281. };
  13282. // update boundingLeft / Top
  13283. proto._getBoundingRect = function() {
  13284. // get bounding rect for container element
  13285. var boundingRect = this.element.getBoundingClientRect();
  13286. var size = this.size;
  13287. this._boundingRect = {
  13288. left: boundingRect.left + size.paddingLeft + size.borderLeftWidth,
  13289. top: boundingRect.top + size.paddingTop + size.borderTopWidth,
  13290. right: boundingRect.right - ( size.paddingRight + size.borderRightWidth ),
  13291. bottom: boundingRect.bottom - ( size.paddingBottom + size.borderBottomWidth )
  13292. };
  13293. };
  13294. /**
  13295. * @param {Element} stamp
  13296. **/
  13297. proto._manageStamp = noop;
  13298. /**
  13299. * get x/y position of element relative to container element
  13300. * @param {Element} elem
  13301. * @returns {Object} offset - has left, top, right, bottom
  13302. */
  13303. proto._getElementOffset = function( elem ) {
  13304. var boundingRect = elem.getBoundingClientRect();
  13305. var thisRect = this._boundingRect;
  13306. var size = getSize( elem );
  13307. var offset = {
  13308. left: boundingRect.left - thisRect.left - size.marginLeft,
  13309. top: boundingRect.top - thisRect.top - size.marginTop,
  13310. right: thisRect.right - boundingRect.right - size.marginRight,
  13311. bottom: thisRect.bottom - boundingRect.bottom - size.marginBottom
  13312. };
  13313. return offset;
  13314. };
  13315. // -------------------------- resize -------------------------- //
  13316. // enable event handlers for listeners
  13317. // i.e. resize -> onresize
  13318. proto.handleEvent = utils.handleEvent;
  13319. /**
  13320. * Bind layout to window resizing
  13321. */
  13322. proto.bindResize = function() {
  13323. window.addEventListener( 'resize', this );
  13324. this.isResizeBound = true;
  13325. };
  13326. /**
  13327. * Unbind layout to window resizing
  13328. */
  13329. proto.unbindResize = function() {
  13330. window.removeEventListener( 'resize', this );
  13331. this.isResizeBound = false;
  13332. };
  13333. proto.onresize = function() {
  13334. this.resize();
  13335. };
  13336. utils.debounceMethod( Outlayer, 'onresize', 100 );
  13337. proto.resize = function() {
  13338. // don't trigger if size did not change
  13339. // or if resize was unbound. See #9
  13340. if ( !this.isResizeBound || !this.needsResizeLayout() ) {
  13341. return;
  13342. }
  13343. this.layout();
  13344. };
  13345. /**
  13346. * check if layout is needed post layout
  13347. * @returns Boolean
  13348. */
  13349. proto.needsResizeLayout = function() {
  13350. var size = getSize( this.element );
  13351. // check that this.size and size are there
  13352. // IE8 triggers resize on body size change, so they might not be
  13353. var hasSizes = this.size && size;
  13354. return hasSizes && size.innerWidth !== this.size.innerWidth;
  13355. };
  13356. // -------------------------- methods -------------------------- //
  13357. /**
  13358. * add items to Outlayer instance
  13359. * @param {Array or NodeList or Element} elems
  13360. * @returns {Array} items - Outlayer.Items
  13361. **/
  13362. proto.addItems = function( elems ) {
  13363. var items = this._itemize( elems );
  13364. // add items to collection
  13365. if ( items.length ) {
  13366. this.items = this.items.concat( items );
  13367. }
  13368. return items;
  13369. };
  13370. /**
  13371. * Layout newly-appended item elements
  13372. * @param {Array or NodeList or Element} elems
  13373. */
  13374. proto.appended = function( elems ) {
  13375. var items = this.addItems( elems );
  13376. if ( !items.length ) {
  13377. return;
  13378. }
  13379. // layout and reveal just the new items
  13380. this.layoutItems( items, true );
  13381. this.reveal( items );
  13382. };
  13383. /**
  13384. * Layout prepended elements
  13385. * @param {Array or NodeList or Element} elems
  13386. */
  13387. proto.prepended = function( elems ) {
  13388. var items = this._itemize( elems );
  13389. if ( !items.length ) {
  13390. return;
  13391. }
  13392. // add items to beginning of collection
  13393. var previousItems = this.items.slice(0);
  13394. this.items = items.concat( previousItems );
  13395. // start new layout
  13396. this._resetLayout();
  13397. this._manageStamps();
  13398. // layout new stuff without transition
  13399. this.layoutItems( items, true );
  13400. this.reveal( items );
  13401. // layout previous items
  13402. this.layoutItems( previousItems );
  13403. };
  13404. /**
  13405. * reveal a collection of items
  13406. * @param {Array of Outlayer.Items} items
  13407. */
  13408. proto.reveal = function( items ) {
  13409. this._emitCompleteOnItems( 'reveal', items );
  13410. if ( !items || !items.length ) {
  13411. return;
  13412. }
  13413. var stagger = this.updateStagger();
  13414. items.forEach( function( item, i ) {
  13415. item.stagger( i * stagger );
  13416. item.reveal();
  13417. });
  13418. };
  13419. /**
  13420. * hide a collection of items
  13421. * @param {Array of Outlayer.Items} items
  13422. */
  13423. proto.hide = function( items ) {
  13424. this._emitCompleteOnItems( 'hide', items );
  13425. if ( !items || !items.length ) {
  13426. return;
  13427. }
  13428. var stagger = this.updateStagger();
  13429. items.forEach( function( item, i ) {
  13430. item.stagger( i * stagger );
  13431. item.hide();
  13432. });
  13433. };
  13434. /**
  13435. * reveal item elements
  13436. * @param {Array}, {Element}, {NodeList} items
  13437. */
  13438. proto.revealItemElements = function( elems ) {
  13439. var items = this.getItems( elems );
  13440. this.reveal( items );
  13441. };
  13442. /**
  13443. * hide item elements
  13444. * @param {Array}, {Element}, {NodeList} items
  13445. */
  13446. proto.hideItemElements = function( elems ) {
  13447. var items = this.getItems( elems );
  13448. this.hide( items );
  13449. };
  13450. /**
  13451. * get Outlayer.Item, given an Element
  13452. * @param {Element} elem
  13453. * @param {Function} callback
  13454. * @returns {Outlayer.Item} item
  13455. */
  13456. proto.getItem = function( elem ) {
  13457. // loop through items to get the one that matches
  13458. for ( var i=0; i < this.items.length; i++ ) {
  13459. var item = this.items[i];
  13460. if ( item.element == elem ) {
  13461. // return item
  13462. return item;
  13463. }
  13464. }
  13465. };
  13466. /**
  13467. * get collection of Outlayer.Items, given Elements
  13468. * @param {Array} elems
  13469. * @returns {Array} items - Outlayer.Items
  13470. */
  13471. proto.getItems = function( elems ) {
  13472. elems = utils.makeArray( elems );
  13473. var items = [];
  13474. elems.forEach( function( elem ) {
  13475. var item = this.getItem( elem );
  13476. if ( item ) {
  13477. items.push( item );
  13478. }
  13479. }, this );
  13480. return items;
  13481. };
  13482. /**
  13483. * remove element(s) from instance and DOM
  13484. * @param {Array or NodeList or Element} elems
  13485. */
  13486. proto.remove = function( elems ) {
  13487. var removeItems = this.getItems( elems );
  13488. this._emitCompleteOnItems( 'remove', removeItems );
  13489. // bail if no items to remove
  13490. if ( !removeItems || !removeItems.length ) {
  13491. return;
  13492. }
  13493. removeItems.forEach( function( item ) {
  13494. item.remove();
  13495. // remove item from collection
  13496. utils.removeFrom( this.items, item );
  13497. }, this );
  13498. };
  13499. // ----- destroy ----- //
  13500. // remove and disable Outlayer instance
  13501. proto.destroy = function() {
  13502. // clean up dynamic styles
  13503. var style = this.element.style;
  13504. style.height = '';
  13505. style.position = '';
  13506. style.width = '';
  13507. // destroy items
  13508. this.items.forEach( function( item ) {
  13509. item.destroy();
  13510. });
  13511. this.unbindResize();
  13512. var id = this.element.outlayerGUID;
  13513. delete instances[ id ]; // remove reference to instance by id
  13514. delete this.element.outlayerGUID;
  13515. // remove data for jQuery
  13516. if ( jQuery ) {
  13517. jQuery.removeData( this.element, this.constructor.namespace );
  13518. }
  13519. };
  13520. // -------------------------- data -------------------------- //
  13521. /**
  13522. * get Outlayer instance from element
  13523. * @param {Element} elem
  13524. * @returns {Outlayer}
  13525. */
  13526. Outlayer.data = function( elem ) {
  13527. elem = utils.getQueryElement( elem );
  13528. var id = elem && elem.outlayerGUID;
  13529. return id && instances[ id ];
  13530. };
  13531. // -------------------------- create Outlayer class -------------------------- //
  13532. /**
  13533. * create a layout class
  13534. * @param {String} namespace
  13535. */
  13536. Outlayer.create = function( namespace, options ) {
  13537. // sub-class Outlayer
  13538. var Layout = subclass( Outlayer );
  13539. // apply new options and compatOptions
  13540. Layout.defaults = utils.extend( {}, Outlayer.defaults );
  13541. utils.extend( Layout.defaults, options );
  13542. Layout.compatOptions = utils.extend( {}, Outlayer.compatOptions );
  13543. Layout.namespace = namespace;
  13544. Layout.data = Outlayer.data;
  13545. // sub-class Item
  13546. Layout.Item = subclass( Item );
  13547. // -------------------------- declarative -------------------------- //
  13548. utils.htmlInit( Layout, namespace );
  13549. // -------------------------- jQuery bridge -------------------------- //
  13550. // make into jQuery plugin
  13551. if ( jQuery && jQuery.bridget ) {
  13552. jQuery.bridget( namespace, Layout );
  13553. }
  13554. return Layout;
  13555. };
  13556. function subclass( Parent ) {
  13557. function SubClass() {
  13558. Parent.apply( this, arguments );
  13559. }
  13560. SubClass.prototype = Object.create( Parent.prototype );
  13561. SubClass.prototype.constructor = SubClass;
  13562. return SubClass;
  13563. }
  13564. // ----- helpers ----- //
  13565. // how many milliseconds are in each unit
  13566. var msUnits = {
  13567. ms: 1,
  13568. s: 1000
  13569. };
  13570. // munge time-like parameter into millisecond number
  13571. // '0.4s' -> 40
  13572. function getMilliseconds( time ) {
  13573. if ( typeof time == 'number' ) {
  13574. return time;
  13575. }
  13576. var matches = time.match( /(^\d*\.?\d*)(\w*)/ );
  13577. var num = matches && matches[1];
  13578. var unit = matches && matches[2];
  13579. if ( !num.length ) {
  13580. return 0;
  13581. }
  13582. num = parseFloat( num );
  13583. var mult = msUnits[ unit ] || 1;
  13584. return num * mult;
  13585. }
  13586. // ----- fin ----- //
  13587. // back in global
  13588. Outlayer.Item = Item;
  13589. return Outlayer;
  13590. }));
  13591. /**
  13592. * Isotope Item
  13593. **/
  13594. ( function( window, factory ) {
  13595. // universal module definition
  13596. /* jshint strict: false */ /*globals define, module, require */
  13597. if ( typeof define == 'function' && define.amd ) {
  13598. // AMD
  13599. define( 'isotope-layout/js/item',[
  13600. 'outlayer/outlayer'
  13601. ],
  13602. factory );
  13603. } else if ( typeof module == 'object' && module.exports ) {
  13604. // CommonJS
  13605. module.exports = factory(
  13606. require('outlayer')
  13607. );
  13608. } else {
  13609. // browser global
  13610. window.Isotope = window.Isotope || {};
  13611. window.Isotope.Item = factory(
  13612. window.Outlayer
  13613. );
  13614. }
  13615. }( window, function factory( Outlayer ) {
  13616. 'use strict';
  13617. // -------------------------- Item -------------------------- //
  13618. // sub-class Outlayer Item
  13619. function Item() {
  13620. Outlayer.Item.apply( this, arguments );
  13621. }
  13622. var proto = Item.prototype = Object.create( Outlayer.Item.prototype );
  13623. var _create = proto._create;
  13624. proto._create = function() {
  13625. // assign id, used for original-order sorting
  13626. this.id = this.layout.itemGUID++;
  13627. _create.call( this );
  13628. this.sortData = {};
  13629. };
  13630. proto.updateSortData = function() {
  13631. if ( this.isIgnored ) {
  13632. return;
  13633. }
  13634. // default sorters
  13635. this.sortData.id = this.id;
  13636. // for backward compatibility
  13637. this.sortData['original-order'] = this.id;
  13638. this.sortData.random = Math.random();
  13639. // go thru getSortData obj and apply the sorters
  13640. var getSortData = this.layout.options.getSortData;
  13641. var sorters = this.layout._sorters;
  13642. for ( var key in getSortData ) {
  13643. var sorter = sorters[ key ];
  13644. this.sortData[ key ] = sorter( this.element, this );
  13645. }
  13646. };
  13647. var _destroy = proto.destroy;
  13648. proto.destroy = function() {
  13649. // call super
  13650. _destroy.apply( this, arguments );
  13651. // reset display, #741
  13652. this.css({
  13653. display: ''
  13654. });
  13655. };
  13656. return Item;
  13657. }));
  13658. /**
  13659. * Isotope LayoutMode
  13660. */
  13661. ( function( window, factory ) {
  13662. // universal module definition
  13663. /* jshint strict: false */ /*globals define, module, require */
  13664. if ( typeof define == 'function' && define.amd ) {
  13665. // AMD
  13666. define( 'isotope-layout/js/layout-mode',[
  13667. 'get-size/get-size',
  13668. 'outlayer/outlayer'
  13669. ],
  13670. factory );
  13671. } else if ( typeof module == 'object' && module.exports ) {
  13672. // CommonJS
  13673. module.exports = factory(
  13674. require('get-size'),
  13675. require('outlayer')
  13676. );
  13677. } else {
  13678. // browser global
  13679. window.Isotope = window.Isotope || {};
  13680. window.Isotope.LayoutMode = factory(
  13681. window.getSize,
  13682. window.Outlayer
  13683. );
  13684. }
  13685. }( window, function factory( getSize, Outlayer ) {
  13686. 'use strict';
  13687. // layout mode class
  13688. function LayoutMode( isotope ) {
  13689. this.isotope = isotope;
  13690. // link properties
  13691. if ( isotope ) {
  13692. this.options = isotope.options[ this.namespace ];
  13693. this.element = isotope.element;
  13694. this.items = isotope.filteredItems;
  13695. this.size = isotope.size;
  13696. }
  13697. }
  13698. var proto = LayoutMode.prototype;
  13699. /**
  13700. * some methods should just defer to default Outlayer method
  13701. * and reference the Isotope instance as `this`
  13702. **/
  13703. var facadeMethods = [
  13704. '_resetLayout',
  13705. '_getItemLayoutPosition',
  13706. '_manageStamp',
  13707. '_getContainerSize',
  13708. '_getElementOffset',
  13709. 'needsResizeLayout',
  13710. '_getOption'
  13711. ];
  13712. facadeMethods.forEach( function( methodName ) {
  13713. proto[ methodName ] = function() {
  13714. return Outlayer.prototype[ methodName ].apply( this.isotope, arguments );
  13715. };
  13716. });
  13717. // ----- ----- //
  13718. // for horizontal layout modes, check vertical size
  13719. proto.needsVerticalResizeLayout = function() {
  13720. // don't trigger if size did not change
  13721. var size = getSize( this.isotope.element );
  13722. // check that this.size and size are there
  13723. // IE8 triggers resize on body size change, so they might not be
  13724. var hasSizes = this.isotope.size && size;
  13725. return hasSizes && size.innerHeight != this.isotope.size.innerHeight;
  13726. };
  13727. // ----- measurements ----- //
  13728. proto._getMeasurement = function() {
  13729. this.isotope._getMeasurement.apply( this, arguments );
  13730. };
  13731. proto.getColumnWidth = function() {
  13732. this.getSegmentSize( 'column', 'Width' );
  13733. };
  13734. proto.getRowHeight = function() {
  13735. this.getSegmentSize( 'row', 'Height' );
  13736. };
  13737. /**
  13738. * get columnWidth or rowHeight
  13739. * segment: 'column' or 'row'
  13740. * size 'Width' or 'Height'
  13741. **/
  13742. proto.getSegmentSize = function( segment, size ) {
  13743. var segmentName = segment + size;
  13744. var outerSize = 'outer' + size;
  13745. // columnWidth / outerWidth // rowHeight / outerHeight
  13746. this._getMeasurement( segmentName, outerSize );
  13747. // got rowHeight or columnWidth, we can chill
  13748. if ( this[ segmentName ] ) {
  13749. return;
  13750. }
  13751. // fall back to item of first element
  13752. var firstItemSize = this.getFirstItemSize();
  13753. this[ segmentName ] = firstItemSize && firstItemSize[ outerSize ] ||
  13754. // or size of container
  13755. this.isotope.size[ 'inner' + size ];
  13756. };
  13757. proto.getFirstItemSize = function() {
  13758. var firstItem = this.isotope.filteredItems[0];
  13759. return firstItem && firstItem.element && getSize( firstItem.element );
  13760. };
  13761. // ----- methods that should reference isotope ----- //
  13762. proto.layout = function() {
  13763. this.isotope.layout.apply( this.isotope, arguments );
  13764. };
  13765. proto.getSize = function() {
  13766. this.isotope.getSize();
  13767. this.size = this.isotope.size;
  13768. };
  13769. // -------------------------- create -------------------------- //
  13770. LayoutMode.modes = {};
  13771. LayoutMode.create = function( namespace, options ) {
  13772. function Mode() {
  13773. LayoutMode.apply( this, arguments );
  13774. }
  13775. Mode.prototype = Object.create( proto );
  13776. Mode.prototype.constructor = Mode;
  13777. // default options
  13778. if ( options ) {
  13779. Mode.options = options;
  13780. }
  13781. Mode.prototype.namespace = namespace;
  13782. // register in Isotope
  13783. LayoutMode.modes[ namespace ] = Mode;
  13784. return Mode;
  13785. };
  13786. return LayoutMode;
  13787. }));
  13788. /*!
  13789. * Masonry v4.2.1
  13790. * Cascading grid layout library
  13791. * https://masonry.desandro.com
  13792. * MIT License
  13793. * by David DeSandro
  13794. */
  13795. ( function( window, factory ) {
  13796. // universal module definition
  13797. /* jshint strict: false */ /*globals define, module, require */
  13798. if ( typeof define == 'function' && define.amd ) {
  13799. // AMD
  13800. define( 'masonry-layout/masonry',[
  13801. 'outlayer/outlayer',
  13802. 'get-size/get-size'
  13803. ],
  13804. factory );
  13805. } else if ( typeof module == 'object' && module.exports ) {
  13806. // CommonJS
  13807. module.exports = factory(
  13808. require('outlayer'),
  13809. require('get-size')
  13810. );
  13811. } else {
  13812. // browser global
  13813. window.Masonry = factory(
  13814. window.Outlayer,
  13815. window.getSize
  13816. );
  13817. }
  13818. }( window, function factory( Outlayer, getSize ) {
  13819. // -------------------------- masonryDefinition -------------------------- //
  13820. // create an Outlayer layout class
  13821. var Masonry = Outlayer.create('masonry');
  13822. // isFitWidth -> fitWidth
  13823. Masonry.compatOptions.fitWidth = 'isFitWidth';
  13824. var proto = Masonry.prototype;
  13825. proto._resetLayout = function() {
  13826. this.getSize();
  13827. this._getMeasurement( 'columnWidth', 'outerWidth' );
  13828. this._getMeasurement( 'gutter', 'outerWidth' );
  13829. this.measureColumns();
  13830. // reset column Y
  13831. this.colYs = [];
  13832. for ( var i=0; i < this.cols; i++ ) {
  13833. this.colYs.push( 0 );
  13834. }
  13835. this.maxY = 0;
  13836. this.horizontalColIndex = 0;
  13837. };
  13838. proto.measureColumns = function() {
  13839. this.getContainerWidth();
  13840. // if columnWidth is 0, default to outerWidth of first item
  13841. if ( !this.columnWidth ) {
  13842. var firstItem = this.items[0];
  13843. var firstItemElem = firstItem && firstItem.element;
  13844. // columnWidth fall back to item of first element
  13845. this.columnWidth = firstItemElem && getSize( firstItemElem ).outerWidth ||
  13846. // if first elem has no width, default to size of container
  13847. this.containerWidth;
  13848. }
  13849. var columnWidth = this.columnWidth += this.gutter;
  13850. // calculate columns
  13851. var containerWidth = this.containerWidth + this.gutter;
  13852. var cols = containerWidth / columnWidth;
  13853. // fix rounding errors, typically with gutters
  13854. var excess = columnWidth - containerWidth % columnWidth;
  13855. // if overshoot is less than a pixel, round up, otherwise floor it
  13856. var mathMethod = excess && excess < 1 ? 'round' : 'floor';
  13857. cols = Math[ mathMethod ]( cols );
  13858. this.cols = Math.max( cols, 1 );
  13859. };
  13860. proto.getContainerWidth = function() {
  13861. // container is parent if fit width
  13862. var isFitWidth = this._getOption('fitWidth');
  13863. var container = isFitWidth ? this.element.parentNode : this.element;
  13864. // check that this.size and size are there
  13865. // IE8 triggers resize on body size change, so they might not be
  13866. var size = getSize( container );
  13867. this.containerWidth = size && size.innerWidth;
  13868. };
  13869. proto._getItemLayoutPosition = function( item ) {
  13870. item.getSize();
  13871. // how many columns does this brick span
  13872. var remainder = item.size.outerWidth % this.columnWidth;
  13873. var mathMethod = remainder && remainder < 1 ? 'round' : 'ceil';
  13874. // round if off by 1 pixel, otherwise use ceil
  13875. var colSpan = Math[ mathMethod ]( item.size.outerWidth / this.columnWidth );
  13876. colSpan = Math.min( colSpan, this.cols );
  13877. // use horizontal or top column position
  13878. var colPosMethod = this.options.horizontalOrder ?
  13879. '_getHorizontalColPosition' : '_getTopColPosition';
  13880. var colPosition = this[ colPosMethod ]( colSpan, item );
  13881. // position the brick
  13882. var position = {
  13883. x: this.columnWidth * colPosition.col,
  13884. y: colPosition.y
  13885. };
  13886. // apply setHeight to necessary columns
  13887. var setHeight = colPosition.y + item.size.outerHeight;
  13888. var setMax = colSpan + colPosition.col;
  13889. for ( var i = colPosition.col; i < setMax; i++ ) {
  13890. this.colYs[i] = setHeight;
  13891. }
  13892. return position;
  13893. };
  13894. proto._getTopColPosition = function( colSpan ) {
  13895. var colGroup = this._getTopColGroup( colSpan );
  13896. // get the minimum Y value from the columns
  13897. var minimumY = Math.min.apply( Math, colGroup );
  13898. return {
  13899. col: colGroup.indexOf( minimumY ),
  13900. y: minimumY,
  13901. };
  13902. };
  13903. /**
  13904. * @param {Number} colSpan - number of columns the element spans
  13905. * @returns {Array} colGroup
  13906. */
  13907. proto._getTopColGroup = function( colSpan ) {
  13908. if ( colSpan < 2 ) {
  13909. // if brick spans only one column, use all the column Ys
  13910. return this.colYs;
  13911. }
  13912. var colGroup = [];
  13913. // how many different places could this brick fit horizontally
  13914. var groupCount = this.cols + 1 - colSpan;
  13915. // for each group potential horizontal position
  13916. for ( var i = 0; i < groupCount; i++ ) {
  13917. colGroup[i] = this._getColGroupY( i, colSpan );
  13918. }
  13919. return colGroup;
  13920. };
  13921. proto._getColGroupY = function( col, colSpan ) {
  13922. if ( colSpan < 2 ) {
  13923. return this.colYs[ col ];
  13924. }
  13925. // make an array of colY values for that one group
  13926. var groupColYs = this.colYs.slice( col, col + colSpan );
  13927. // and get the max value of the array
  13928. return Math.max.apply( Math, groupColYs );
  13929. };
  13930. // get column position based on horizontal index. #873
  13931. proto._getHorizontalColPosition = function( colSpan, item ) {
  13932. var col = this.horizontalColIndex % this.cols;
  13933. var isOver = colSpan > 1 && col + colSpan > this.cols;
  13934. // shift to next row if item can't fit on current row
  13935. col = isOver ? 0 : col;
  13936. // don't let zero-size items take up space
  13937. var hasSize = item.size.outerWidth && item.size.outerHeight;
  13938. this.horizontalColIndex = hasSize ? col + colSpan : this.horizontalColIndex;
  13939. return {
  13940. col: col,
  13941. y: this._getColGroupY( col, colSpan ),
  13942. };
  13943. };
  13944. proto._manageStamp = function( stamp ) {
  13945. var stampSize = getSize( stamp );
  13946. var offset = this._getElementOffset( stamp );
  13947. // get the columns that this stamp affects
  13948. var isOriginLeft = this._getOption('originLeft');
  13949. var firstX = isOriginLeft ? offset.left : offset.right;
  13950. var lastX = firstX + stampSize.outerWidth;
  13951. var firstCol = Math.floor( firstX / this.columnWidth );
  13952. firstCol = Math.max( 0, firstCol );
  13953. var lastCol = Math.floor( lastX / this.columnWidth );
  13954. // lastCol should not go over if multiple of columnWidth #425
  13955. lastCol -= lastX % this.columnWidth ? 0 : 1;
  13956. lastCol = Math.min( this.cols - 1, lastCol );
  13957. // set colYs to bottom of the stamp
  13958. var isOriginTop = this._getOption('originTop');
  13959. var stampMaxY = ( isOriginTop ? offset.top : offset.bottom ) +
  13960. stampSize.outerHeight;
  13961. for ( var i = firstCol; i <= lastCol; i++ ) {
  13962. this.colYs[i] = Math.max( stampMaxY, this.colYs[i] );
  13963. }
  13964. };
  13965. proto._getContainerSize = function() {
  13966. this.maxY = Math.max.apply( Math, this.colYs );
  13967. var size = {
  13968. height: this.maxY
  13969. };
  13970. if ( this._getOption('fitWidth') ) {
  13971. size.width = this._getContainerFitWidth();
  13972. }
  13973. return size;
  13974. };
  13975. proto._getContainerFitWidth = function() {
  13976. var unusedCols = 0;
  13977. // count unused columns
  13978. var i = this.cols;
  13979. while ( --i ) {
  13980. if ( this.colYs[i] !== 0 ) {
  13981. break;
  13982. }
  13983. unusedCols++;
  13984. }
  13985. // fit container to columns that have been used
  13986. return ( this.cols - unusedCols ) * this.columnWidth - this.gutter;
  13987. };
  13988. proto.needsResizeLayout = function() {
  13989. var previousWidth = this.containerWidth;
  13990. this.getContainerWidth();
  13991. return previousWidth != this.containerWidth;
  13992. };
  13993. return Masonry;
  13994. }));
  13995. /*!
  13996. * Masonry layout mode
  13997. * sub-classes Masonry
  13998. * https://masonry.desandro.com
  13999. */
  14000. ( function( window, factory ) {
  14001. // universal module definition
  14002. /* jshint strict: false */ /*globals define, module, require */
  14003. if ( typeof define == 'function' && define.amd ) {
  14004. // AMD
  14005. define( 'isotope-layout/js/layout-modes/masonry',[
  14006. '../layout-mode',
  14007. 'masonry-layout/masonry'
  14008. ],
  14009. factory );
  14010. } else if ( typeof module == 'object' && module.exports ) {
  14011. // CommonJS
  14012. module.exports = factory(
  14013. require('../layout-mode'),
  14014. require('masonry-layout')
  14015. );
  14016. } else {
  14017. // browser global
  14018. factory(
  14019. window.Isotope.LayoutMode,
  14020. window.Masonry
  14021. );
  14022. }
  14023. }( window, function factory( LayoutMode, Masonry ) {
  14024. 'use strict';
  14025. // -------------------------- masonryDefinition -------------------------- //
  14026. // create an Outlayer layout class
  14027. var MasonryMode = LayoutMode.create('masonry');
  14028. var proto = MasonryMode.prototype;
  14029. var keepModeMethods = {
  14030. _getElementOffset: true,
  14031. layout: true,
  14032. _getMeasurement: true
  14033. };
  14034. // inherit Masonry prototype
  14035. for ( var method in Masonry.prototype ) {
  14036. // do not inherit mode methods
  14037. if ( !keepModeMethods[ method ] ) {
  14038. proto[ method ] = Masonry.prototype[ method ];
  14039. }
  14040. }
  14041. var measureColumns = proto.measureColumns;
  14042. proto.measureColumns = function() {
  14043. // set items, used if measuring first item
  14044. this.items = this.isotope.filteredItems;
  14045. measureColumns.call( this );
  14046. };
  14047. // point to mode options for fitWidth
  14048. var _getOption = proto._getOption;
  14049. proto._getOption = function( option ) {
  14050. if ( option == 'fitWidth' ) {
  14051. return this.options.isFitWidth !== undefined ?
  14052. this.options.isFitWidth : this.options.fitWidth;
  14053. }
  14054. return _getOption.apply( this.isotope, arguments );
  14055. };
  14056. return MasonryMode;
  14057. }));
  14058. /**
  14059. * fitRows layout mode
  14060. */
  14061. ( function( window, factory ) {
  14062. // universal module definition
  14063. /* jshint strict: false */ /*globals define, module, require */
  14064. if ( typeof define == 'function' && define.amd ) {
  14065. // AMD
  14066. define( 'isotope-layout/js/layout-modes/fit-rows',[
  14067. '../layout-mode'
  14068. ],
  14069. factory );
  14070. } else if ( typeof exports == 'object' ) {
  14071. // CommonJS
  14072. module.exports = factory(
  14073. require('../layout-mode')
  14074. );
  14075. } else {
  14076. // browser global
  14077. factory(
  14078. window.Isotope.LayoutMode
  14079. );
  14080. }
  14081. }( window, function factory( LayoutMode ) {
  14082. 'use strict';
  14083. var FitRows = LayoutMode.create('fitRows');
  14084. var proto = FitRows.prototype;
  14085. proto._resetLayout = function() {
  14086. this.x = 0;
  14087. this.y = 0;
  14088. this.maxY = 0;
  14089. this._getMeasurement( 'gutter', 'outerWidth' );
  14090. };
  14091. proto._getItemLayoutPosition = function( item ) {
  14092. item.getSize();
  14093. var itemWidth = item.size.outerWidth + this.gutter;
  14094. // if this element cannot fit in the current row
  14095. var containerWidth = this.isotope.size.innerWidth + this.gutter;
  14096. if ( this.x !== 0 && itemWidth + this.x > containerWidth ) {
  14097. this.x = 0;
  14098. this.y = this.maxY;
  14099. }
  14100. var position = {
  14101. x: this.x,
  14102. y: this.y
  14103. };
  14104. this.maxY = Math.max( this.maxY, this.y + item.size.outerHeight );
  14105. this.x += itemWidth;
  14106. return position;
  14107. };
  14108. proto._getContainerSize = function() {
  14109. return { height: this.maxY };
  14110. };
  14111. return FitRows;
  14112. }));
  14113. /**
  14114. * vertical layout mode
  14115. */
  14116. ( function( window, factory ) {
  14117. // universal module definition
  14118. /* jshint strict: false */ /*globals define, module, require */
  14119. if ( typeof define == 'function' && define.amd ) {
  14120. // AMD
  14121. define( 'isotope-layout/js/layout-modes/vertical',[
  14122. '../layout-mode'
  14123. ],
  14124. factory );
  14125. } else if ( typeof module == 'object' && module.exports ) {
  14126. // CommonJS
  14127. module.exports = factory(
  14128. require('../layout-mode')
  14129. );
  14130. } else {
  14131. // browser global
  14132. factory(
  14133. window.Isotope.LayoutMode
  14134. );
  14135. }
  14136. }( window, function factory( LayoutMode ) {
  14137. 'use strict';
  14138. var Vertical = LayoutMode.create( 'vertical', {
  14139. horizontalAlignment: 0
  14140. });
  14141. var proto = Vertical.prototype;
  14142. proto._resetLayout = function() {
  14143. this.y = 0;
  14144. };
  14145. proto._getItemLayoutPosition = function( item ) {
  14146. item.getSize();
  14147. var x = ( this.isotope.size.innerWidth - item.size.outerWidth ) *
  14148. this.options.horizontalAlignment;
  14149. var y = this.y;
  14150. this.y += item.size.outerHeight;
  14151. return { x: x, y: y };
  14152. };
  14153. proto._getContainerSize = function() {
  14154. return { height: this.y };
  14155. };
  14156. return Vertical;
  14157. }));
  14158. /*!
  14159. * Isotope v3.0.6
  14160. *
  14161. * Licensed GPLv3 for open source use
  14162. * or Isotope Commercial License for commercial use
  14163. *
  14164. * https://isotope.metafizzy.co
  14165. * Copyright 2010-2018 Metafizzy
  14166. */
  14167. ( function( window, factory ) {
  14168. // universal module definition
  14169. /* jshint strict: false */ /*globals define, module, require */
  14170. if ( typeof define == 'function' && define.amd ) {
  14171. // AMD
  14172. define( [
  14173. 'outlayer/outlayer',
  14174. 'get-size/get-size',
  14175. 'desandro-matches-selector/matches-selector',
  14176. 'fizzy-ui-utils/utils',
  14177. 'isotope-layout/js/item',
  14178. 'isotope-layout/js/layout-mode',
  14179. // include default layout modes
  14180. 'isotope-layout/js/layout-modes/masonry',
  14181. 'isotope-layout/js/layout-modes/fit-rows',
  14182. 'isotope-layout/js/layout-modes/vertical'
  14183. ],
  14184. function( Outlayer, getSize, matchesSelector, utils, Item, LayoutMode ) {
  14185. return factory( window, Outlayer, getSize, matchesSelector, utils, Item, LayoutMode );
  14186. });
  14187. } else if ( typeof module == 'object' && module.exports ) {
  14188. // CommonJS
  14189. module.exports = factory(
  14190. window,
  14191. require('outlayer'),
  14192. require('get-size'),
  14193. require('desandro-matches-selector'),
  14194. require('fizzy-ui-utils'),
  14195. require('isotope-layout/js/item'),
  14196. require('isotope-layout/js/layout-mode'),
  14197. // include default layout modes
  14198. require('isotope-layout/js/layout-modes/masonry'),
  14199. require('isotope-layout/js/layout-modes/fit-rows'),
  14200. require('isotope-layout/js/layout-modes/vertical')
  14201. );
  14202. } else {
  14203. // browser global
  14204. window.Isotope = factory(
  14205. window,
  14206. window.Outlayer,
  14207. window.getSize,
  14208. window.matchesSelector,
  14209. window.fizzyUIUtils,
  14210. window.Isotope.Item,
  14211. window.Isotope.LayoutMode
  14212. );
  14213. }
  14214. }( window, function factory( window, Outlayer, getSize, matchesSelector, utils,
  14215. Item, LayoutMode ) {
  14216. // -------------------------- vars -------------------------- //
  14217. var jQuery = window.jQuery;
  14218. // -------------------------- helpers -------------------------- //
  14219. var trim = String.prototype.trim ?
  14220. function( str ) {
  14221. return str.trim();
  14222. } :
  14223. function( str ) {
  14224. return str.replace( /^\s+|\s+$/g, '' );
  14225. };
  14226. // -------------------------- isotopeDefinition -------------------------- //
  14227. // create an Outlayer layout class
  14228. var Isotope = Outlayer.create( 'isotope', {
  14229. layoutMode: 'masonry',
  14230. isJQueryFiltering: true,
  14231. sortAscending: true
  14232. });
  14233. Isotope.Item = Item;
  14234. Isotope.LayoutMode = LayoutMode;
  14235. var proto = Isotope.prototype;
  14236. proto._create = function() {
  14237. this.itemGUID = 0;
  14238. // functions that sort items
  14239. this._sorters = {};
  14240. this._getSorters();
  14241. // call super
  14242. Outlayer.prototype._create.call( this );
  14243. // create layout modes
  14244. this.modes = {};
  14245. // start filteredItems with all items
  14246. this.filteredItems = this.items;
  14247. // keep of track of sortBys
  14248. this.sortHistory = [ 'original-order' ];
  14249. // create from registered layout modes
  14250. for ( var name in LayoutMode.modes ) {
  14251. this._initLayoutMode( name );
  14252. }
  14253. };
  14254. proto.reloadItems = function() {
  14255. // reset item ID counter
  14256. this.itemGUID = 0;
  14257. // call super
  14258. Outlayer.prototype.reloadItems.call( this );
  14259. };
  14260. proto._itemize = function() {
  14261. var items = Outlayer.prototype._itemize.apply( this, arguments );
  14262. // assign ID for original-order
  14263. for ( var i=0; i < items.length; i++ ) {
  14264. var item = items[i];
  14265. item.id = this.itemGUID++;
  14266. }
  14267. this._updateItemsSortData( items );
  14268. return items;
  14269. };
  14270. // -------------------------- layout -------------------------- //
  14271. proto._initLayoutMode = function( name ) {
  14272. var Mode = LayoutMode.modes[ name ];
  14273. // set mode options
  14274. // HACK extend initial options, back-fill in default options
  14275. var initialOpts = this.options[ name ] || {};
  14276. this.options[ name ] = Mode.options ?
  14277. utils.extend( Mode.options, initialOpts ) : initialOpts;
  14278. // init layout mode instance
  14279. this.modes[ name ] = new Mode( this );
  14280. };
  14281. proto.layout = function() {
  14282. // if first time doing layout, do all magic
  14283. if ( !this._isLayoutInited && this._getOption('initLayout') ) {
  14284. this.arrange();
  14285. return;
  14286. }
  14287. this._layout();
  14288. };
  14289. // private method to be used in layout() & magic()
  14290. proto._layout = function() {
  14291. // don't animate first layout
  14292. var isInstant = this._getIsInstant();
  14293. // layout flow
  14294. this._resetLayout();
  14295. this._manageStamps();
  14296. this.layoutItems( this.filteredItems, isInstant );
  14297. // flag for initalized
  14298. this._isLayoutInited = true;
  14299. };
  14300. // filter + sort + layout
  14301. proto.arrange = function( opts ) {
  14302. // set any options pass
  14303. this.option( opts );
  14304. this._getIsInstant();
  14305. // filter, sort, and layout
  14306. // filter
  14307. var filtered = this._filter( this.items );
  14308. this.filteredItems = filtered.matches;
  14309. this._bindArrangeComplete();
  14310. if ( this._isInstant ) {
  14311. this._noTransition( this._hideReveal, [ filtered ] );
  14312. } else {
  14313. this._hideReveal( filtered );
  14314. }
  14315. this._sort();
  14316. this._layout();
  14317. };
  14318. // alias to _init for main plugin method
  14319. proto._init = proto.arrange;
  14320. proto._hideReveal = function( filtered ) {
  14321. this.reveal( filtered.needReveal );
  14322. this.hide( filtered.needHide );
  14323. };
  14324. // HACK
  14325. // Don't animate/transition first layout
  14326. // Or don't animate/transition other layouts
  14327. proto._getIsInstant = function() {
  14328. var isLayoutInstant = this._getOption('layoutInstant');
  14329. var isInstant = isLayoutInstant !== undefined ? isLayoutInstant :
  14330. !this._isLayoutInited;
  14331. this._isInstant = isInstant;
  14332. return isInstant;
  14333. };
  14334. // listen for layoutComplete, hideComplete and revealComplete
  14335. // to trigger arrangeComplete
  14336. proto._bindArrangeComplete = function() {
  14337. // listen for 3 events to trigger arrangeComplete
  14338. var isLayoutComplete, isHideComplete, isRevealComplete;
  14339. var _this = this;
  14340. function arrangeParallelCallback() {
  14341. if ( isLayoutComplete && isHideComplete && isRevealComplete ) {
  14342. _this.dispatchEvent( 'arrangeComplete', null, [ _this.filteredItems ] );
  14343. }
  14344. }
  14345. this.once( 'layoutComplete', function() {
  14346. isLayoutComplete = true;
  14347. arrangeParallelCallback();
  14348. });
  14349. this.once( 'hideComplete', function() {
  14350. isHideComplete = true;
  14351. arrangeParallelCallback();
  14352. });
  14353. this.once( 'revealComplete', function() {
  14354. isRevealComplete = true;
  14355. arrangeParallelCallback();
  14356. });
  14357. };
  14358. // -------------------------- filter -------------------------- //
  14359. proto._filter = function( items ) {
  14360. var filter = this.options.filter;
  14361. filter = filter || '*';
  14362. var matches = [];
  14363. var hiddenMatched = [];
  14364. var visibleUnmatched = [];
  14365. var test = this._getFilterTest( filter );
  14366. // test each item
  14367. for ( var i=0; i < items.length; i++ ) {
  14368. var item = items[i];
  14369. if ( item.isIgnored ) {
  14370. continue;
  14371. }
  14372. // add item to either matched or unmatched group
  14373. var isMatched = test( item );
  14374. // item.isFilterMatched = isMatched;
  14375. // add to matches if its a match
  14376. if ( isMatched ) {
  14377. matches.push( item );
  14378. }
  14379. // add to additional group if item needs to be hidden or revealed
  14380. if ( isMatched && item.isHidden ) {
  14381. hiddenMatched.push( item );
  14382. } else if ( !isMatched && !item.isHidden ) {
  14383. visibleUnmatched.push( item );
  14384. }
  14385. }
  14386. // return collections of items to be manipulated
  14387. return {
  14388. matches: matches,
  14389. needReveal: hiddenMatched,
  14390. needHide: visibleUnmatched
  14391. };
  14392. };
  14393. // get a jQuery, function, or a matchesSelector test given the filter
  14394. proto._getFilterTest = function( filter ) {
  14395. if ( jQuery && this.options.isJQueryFiltering ) {
  14396. // use jQuery
  14397. return function( item ) {
  14398. return jQuery( item.element ).is( filter );
  14399. };
  14400. }
  14401. if ( typeof filter == 'function' ) {
  14402. // use filter as function
  14403. return function( item ) {
  14404. return filter( item.element );
  14405. };
  14406. }
  14407. // default, use filter as selector string
  14408. return function( item ) {
  14409. return matchesSelector( item.element, filter );
  14410. };
  14411. };
  14412. // -------------------------- sorting -------------------------- //
  14413. /**
  14414. * @params {Array} elems
  14415. * @public
  14416. */
  14417. proto.updateSortData = function( elems ) {
  14418. // get items
  14419. var items;
  14420. if ( elems ) {
  14421. elems = utils.makeArray( elems );
  14422. items = this.getItems( elems );
  14423. } else {
  14424. // update all items if no elems provided
  14425. items = this.items;
  14426. }
  14427. this._getSorters();
  14428. this._updateItemsSortData( items );
  14429. };
  14430. proto._getSorters = function() {
  14431. var getSortData = this.options.getSortData;
  14432. for ( var key in getSortData ) {
  14433. var sorter = getSortData[ key ];
  14434. this._sorters[ key ] = mungeSorter( sorter );
  14435. }
  14436. };
  14437. /**
  14438. * @params {Array} items - of Isotope.Items
  14439. * @private
  14440. */
  14441. proto._updateItemsSortData = function( items ) {
  14442. // do not update if no items
  14443. var len = items && items.length;
  14444. for ( var i=0; len && i < len; i++ ) {
  14445. var item = items[i];
  14446. item.updateSortData();
  14447. }
  14448. };
  14449. // ----- munge sorter ----- //
  14450. // encapsulate this, as we just need mungeSorter
  14451. // other functions in here are just for munging
  14452. var mungeSorter = ( function() {
  14453. // add a magic layer to sorters for convienent shorthands
  14454. // `.foo-bar` will use the text of .foo-bar querySelector
  14455. // `[foo-bar]` will use attribute
  14456. // you can also add parser
  14457. // `.foo-bar parseInt` will parse that as a number
  14458. function mungeSorter( sorter ) {
  14459. // if not a string, return function or whatever it is
  14460. if ( typeof sorter != 'string' ) {
  14461. return sorter;
  14462. }
  14463. // parse the sorter string
  14464. var args = trim( sorter ).split(' ');
  14465. var query = args[0];
  14466. // check if query looks like [an-attribute]
  14467. var attrMatch = query.match( /^\[(.+)\]$/ );
  14468. var attr = attrMatch && attrMatch[1];
  14469. var getValue = getValueGetter( attr, query );
  14470. // use second argument as a parser
  14471. var parser = Isotope.sortDataParsers[ args[1] ];
  14472. // parse the value, if there was a parser
  14473. sorter = parser ? function( elem ) {
  14474. return elem && parser( getValue( elem ) );
  14475. } :
  14476. // otherwise just return value
  14477. function( elem ) {
  14478. return elem && getValue( elem );
  14479. };
  14480. return sorter;
  14481. }
  14482. // get an attribute getter, or get text of the querySelector
  14483. function getValueGetter( attr, query ) {
  14484. // if query looks like [foo-bar], get attribute
  14485. if ( attr ) {
  14486. return function getAttribute( elem ) {
  14487. return elem.getAttribute( attr );
  14488. };
  14489. }
  14490. // otherwise, assume its a querySelector, and get its text
  14491. return function getChildText( elem ) {
  14492. var child = elem.querySelector( query );
  14493. return child && child.textContent;
  14494. };
  14495. }
  14496. return mungeSorter;
  14497. })();
  14498. // parsers used in getSortData shortcut strings
  14499. Isotope.sortDataParsers = {
  14500. 'parseInt': function( val ) {
  14501. return parseInt( val, 10 );
  14502. },
  14503. 'parseFloat': function( val ) {
  14504. return parseFloat( val );
  14505. }
  14506. };
  14507. // ----- sort method ----- //
  14508. // sort filteredItem order
  14509. proto._sort = function() {
  14510. if ( !this.options.sortBy ) {
  14511. return;
  14512. }
  14513. // keep track of sortBy History
  14514. var sortBys = utils.makeArray( this.options.sortBy );
  14515. if ( !this._getIsSameSortBy( sortBys ) ) {
  14516. // concat all sortBy and sortHistory, add to front, oldest goes in last
  14517. this.sortHistory = sortBys.concat( this.sortHistory );
  14518. }
  14519. // sort magic
  14520. var itemSorter = getItemSorter( this.sortHistory, this.options.sortAscending );
  14521. this.filteredItems.sort( itemSorter );
  14522. };
  14523. // check if sortBys is same as start of sortHistory
  14524. proto._getIsSameSortBy = function( sortBys ) {
  14525. for ( var i=0; i < sortBys.length; i++ ) {
  14526. if ( sortBys[i] != this.sortHistory[i] ) {
  14527. return false;
  14528. }
  14529. }
  14530. return true;
  14531. };
  14532. // returns a function used for sorting
  14533. function getItemSorter( sortBys, sortAsc ) {
  14534. return function sorter( itemA, itemB ) {
  14535. // cycle through all sortKeys
  14536. for ( var i = 0; i < sortBys.length; i++ ) {
  14537. var sortBy = sortBys[i];
  14538. var a = itemA.sortData[ sortBy ];
  14539. var b = itemB.sortData[ sortBy ];
  14540. if ( a > b || a < b ) {
  14541. // if sortAsc is an object, use the value given the sortBy key
  14542. var isAscending = sortAsc[ sortBy ] !== undefined ? sortAsc[ sortBy ] : sortAsc;
  14543. var direction = isAscending ? 1 : -1;
  14544. return ( a > b ? 1 : -1 ) * direction;
  14545. }
  14546. }
  14547. return 0;
  14548. };
  14549. }
  14550. // -------------------------- methods -------------------------- //
  14551. // get layout mode
  14552. proto._mode = function() {
  14553. var layoutMode = this.options.layoutMode;
  14554. var mode = this.modes[ layoutMode ];
  14555. if ( !mode ) {
  14556. // TODO console.error
  14557. throw new Error( 'No layout mode: ' + layoutMode );
  14558. }
  14559. // HACK sync mode's options
  14560. // any options set after init for layout mode need to be synced
  14561. mode.options = this.options[ layoutMode ];
  14562. return mode;
  14563. };
  14564. proto._resetLayout = function() {
  14565. // trigger original reset layout
  14566. Outlayer.prototype._resetLayout.call( this );
  14567. this._mode()._resetLayout();
  14568. };
  14569. proto._getItemLayoutPosition = function( item ) {
  14570. return this._mode()._getItemLayoutPosition( item );
  14571. };
  14572. proto._manageStamp = function( stamp ) {
  14573. this._mode()._manageStamp( stamp );
  14574. };
  14575. proto._getContainerSize = function() {
  14576. return this._mode()._getContainerSize();
  14577. };
  14578. proto.needsResizeLayout = function() {
  14579. return this._mode().needsResizeLayout();
  14580. };
  14581. // -------------------------- adding & removing -------------------------- //
  14582. // HEADS UP overwrites default Outlayer appended
  14583. proto.appended = function( elems ) {
  14584. var items = this.addItems( elems );
  14585. if ( !items.length ) {
  14586. return;
  14587. }
  14588. // filter, layout, reveal new items
  14589. var filteredItems = this._filterRevealAdded( items );
  14590. // add to filteredItems
  14591. this.filteredItems = this.filteredItems.concat( filteredItems );
  14592. };
  14593. // HEADS UP overwrites default Outlayer prepended
  14594. proto.prepended = function( elems ) {
  14595. var items = this._itemize( elems );
  14596. if ( !items.length ) {
  14597. return;
  14598. }
  14599. // start new layout
  14600. this._resetLayout();
  14601. this._manageStamps();
  14602. // filter, layout, reveal new items
  14603. var filteredItems = this._filterRevealAdded( items );
  14604. // layout previous items
  14605. this.layoutItems( this.filteredItems );
  14606. // add to items and filteredItems
  14607. this.filteredItems = filteredItems.concat( this.filteredItems );
  14608. this.items = items.concat( this.items );
  14609. };
  14610. proto._filterRevealAdded = function( items ) {
  14611. var filtered = this._filter( items );
  14612. this.hide( filtered.needHide );
  14613. // reveal all new items
  14614. this.reveal( filtered.matches );
  14615. // layout new items, no transition
  14616. this.layoutItems( filtered.matches, true );
  14617. return filtered.matches;
  14618. };
  14619. /**
  14620. * Filter, sort, and layout newly-appended item elements
  14621. * @param {Array or NodeList or Element} elems
  14622. */
  14623. proto.insert = function( elems ) {
  14624. var items = this.addItems( elems );
  14625. if ( !items.length ) {
  14626. return;
  14627. }
  14628. // append item elements
  14629. var i, item;
  14630. var len = items.length;
  14631. for ( i=0; i < len; i++ ) {
  14632. item = items[i];
  14633. this.element.appendChild( item.element );
  14634. }
  14635. // filter new stuff
  14636. var filteredInsertItems = this._filter( items ).matches;
  14637. // set flag
  14638. for ( i=0; i < len; i++ ) {
  14639. items[i].isLayoutInstant = true;
  14640. }
  14641. this.arrange();
  14642. // reset flag
  14643. for ( i=0; i < len; i++ ) {
  14644. delete items[i].isLayoutInstant;
  14645. }
  14646. this.reveal( filteredInsertItems );
  14647. };
  14648. var _remove = proto.remove;
  14649. proto.remove = function( elems ) {
  14650. elems = utils.makeArray( elems );
  14651. var removeItems = this.getItems( elems );
  14652. // do regular thing
  14653. _remove.call( this, elems );
  14654. // bail if no items to remove
  14655. var len = removeItems && removeItems.length;
  14656. // remove elems from filteredItems
  14657. for ( var i=0; len && i < len; i++ ) {
  14658. var item = removeItems[i];
  14659. // remove item from collection
  14660. utils.removeFrom( this.filteredItems, item );
  14661. }
  14662. };
  14663. proto.shuffle = function() {
  14664. // update random sortData
  14665. for ( var i=0; i < this.items.length; i++ ) {
  14666. var item = this.items[i];
  14667. item.sortData.random = Math.random();
  14668. }
  14669. this.options.sortBy = 'random';
  14670. this._sort();
  14671. this._layout();
  14672. };
  14673. /**
  14674. * trigger fn without transition
  14675. * kind of hacky to have this in the first place
  14676. * @param {Function} fn
  14677. * @param {Array} args
  14678. * @returns ret
  14679. * @private
  14680. */
  14681. proto._noTransition = function( fn, args ) {
  14682. // save transitionDuration before disabling
  14683. var transitionDuration = this.options.transitionDuration;
  14684. // disable transition
  14685. this.options.transitionDuration = 0;
  14686. // do it
  14687. var returnValue = fn.apply( this, args );
  14688. // re-enable transition for reveal
  14689. this.options.transitionDuration = transitionDuration;
  14690. return returnValue;
  14691. };
  14692. // ----- helper methods ----- //
  14693. /**
  14694. * getter method for getting filtered item elements
  14695. * @returns {Array} elems - collection of item elements
  14696. */
  14697. proto.getFilteredItemElements = function() {
  14698. return this.filteredItems.map( function( item ) {
  14699. return item.element;
  14700. });
  14701. };
  14702. // ----- ----- //
  14703. return Isotope;
  14704. }));
  14705. /*!
  14706. jQuery Cookie Plugin
  14707. Version: v1.4.1
  14708. Plugin URL: https://github.com/carhartl/jquery-cookie
  14709. License: Copyright 2006, 2014 Klaus Hartl | Released under the MIT license
  14710. !*/
  14711. (function (factory) {
  14712. if (typeof define === 'function' && define.amd) {
  14713. // AMD (Register as an anonymous module)
  14714. define(['jquery'], factory);
  14715. } else if (typeof exports === 'object') {
  14716. // Node/CommonJS
  14717. module.exports = factory(require('jquery'));
  14718. } else {
  14719. // Browser globals
  14720. factory(jQuery);
  14721. }
  14722. }(function ($) {
  14723. var pluses = /\+/g;
  14724. function encode(s) {
  14725. return config.raw ? s : encodeURIComponent(s);
  14726. }
  14727. function decode(s) {
  14728. return config.raw ? s : decodeURIComponent(s);
  14729. }
  14730. function stringifyCookieValue(value) {
  14731. return encode(config.json ? JSON.stringify(value) : String(value));
  14732. }
  14733. function parseCookieValue(s) {
  14734. if (s.indexOf('"') === 0) {
  14735. // This is a quoted cookie as according to RFC2068, unescape...
  14736. s = s.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, '\\');
  14737. }
  14738. try {
  14739. // Replace server-side written pluses with spaces.
  14740. // If we can't decode the cookie, ignore it, it's unusable.
  14741. // If we can't parse the cookie, ignore it, it's unusable.
  14742. s = decodeURIComponent(s.replace(pluses, ' '));
  14743. return config.json ? JSON.parse(s) : s;
  14744. } catch(e) {}
  14745. }
  14746. function read(s, converter) {
  14747. var value = config.raw ? s : parseCookieValue(s);
  14748. return $.isFunction(converter) ? converter(value) : value;
  14749. }
  14750. var config = $.cookie = function (key, value, options) {
  14751. // Write
  14752. if (arguments.length > 1 && !$.isFunction(value)) {
  14753. options = $.extend({}, config.defaults, options);
  14754. if (typeof options.expires === 'number') {
  14755. var days = options.expires, t = options.expires = new Date();
  14756. t.setMilliseconds(t.getMilliseconds() + days * 864e+5);
  14757. }
  14758. return (document.cookie = [
  14759. encode(key), '=', stringifyCookieValue(value),
  14760. options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
  14761. options.path ? '; path=' + options.path : '',
  14762. options.domain ? '; domain=' + options.domain : '',
  14763. options.secure ? '; secure' : ''
  14764. ].join(''));
  14765. }
  14766. // Read
  14767. var result = key ? undefined : {},
  14768. // To prevent the for loop in the first place assign an empty array
  14769. // in case there are no cookies at all. Also prevents odd result when
  14770. // calling $.cookie().
  14771. cookies = document.cookie ? document.cookie.split('; ') : [],
  14772. i = 0,
  14773. l = cookies.length;
  14774. for (; i < l; i++) {
  14775. var parts = cookies[i].split('='),
  14776. name = decode(parts.shift()),
  14777. cookie = parts.join('=');
  14778. if (key === name) {
  14779. // If second argument (value) is a function it's a converter...
  14780. result = read(cookie, value);
  14781. break;
  14782. }
  14783. // Prevent storing a cookie that we couldn't decode.
  14784. if (!key && (cookie = read(cookie)) !== undefined) {
  14785. result[name] = cookie;
  14786. }
  14787. }
  14788. return result;
  14789. };
  14790. config.defaults = {};
  14791. $.removeCookie = function (key, options) {
  14792. // Must not alter options, thus extending a fresh object...
  14793. $.cookie(key, '', $.extend({}, options, { expires: -1 }));
  14794. return !$.cookie(key);
  14795. };
  14796. }));
  14797. /*!
  14798. jQuery appear plugin
  14799. Version: 0.4
  14800. Plugin URL: https://github.com/morr/jquery.appear/
  14801. License: Copyright (c) 2012 Andrey Sidorov | Released under the MIT license
  14802. !*/
  14803. (function($) {
  14804. var selectors = [];
  14805. var check_binded = false;
  14806. var check_lock = false;
  14807. var defaults = {
  14808. interval: 250,
  14809. force_process: false
  14810. };
  14811. var $window = $(window);
  14812. var $prior_appeared = [];
  14813. function appeared(selector) {
  14814. return $(selector).filter(function() {
  14815. return $(this).is(':appeared');
  14816. });
  14817. }
  14818. function process() {
  14819. check_lock = false;
  14820. for (var index = 0, selectorsLength = selectors.length; index < selectorsLength; index++) {
  14821. var $appeared = appeared(selectors[index]);
  14822. $appeared.trigger('appear', [$appeared]);
  14823. if ($prior_appeared[index]) {
  14824. var $disappeared = $prior_appeared[index].not($appeared);
  14825. $disappeared.trigger('disappear', [$disappeared]);
  14826. }
  14827. $prior_appeared[index] = $appeared;
  14828. }
  14829. }
  14830. function add_selector(selector) {
  14831. selectors.push(selector);
  14832. $prior_appeared.push();
  14833. }
  14834. // ":appeared" custom filter
  14835. $.expr.pseudos.appeared = $.expr.createPseudo(function(arg) {
  14836. return function(element) {
  14837. var $element = $(element);
  14838. if (!$element.is(':visible')) {
  14839. return false;
  14840. }
  14841. var window_left = $window.scrollLeft();
  14842. var window_top = $window.scrollTop();
  14843. var offset = $element.offset();
  14844. var left = offset.left;
  14845. var top = offset.top;
  14846. if (top + $element.height() >= window_top &&
  14847. top - ($element.data('appear-top-offset') || 0) <= window_top + $window.height() &&
  14848. left + $element.width() >= window_left &&
  14849. left - ($element.data('appear-left-offset') || 0) <= window_left + $window.width()) {
  14850. return true;
  14851. } else {
  14852. return false;
  14853. }
  14854. };
  14855. });
  14856. $.fn.extend({
  14857. // watching for element's appearance in browser viewport
  14858. appear: function(selector, options) {
  14859. $.appear(this, options);
  14860. return this;
  14861. }
  14862. });
  14863. $.extend({
  14864. appear: function(selector, options) {
  14865. var opts = $.extend({}, defaults, options || {});
  14866. if (!check_binded) {
  14867. var on_check = function() {
  14868. if (check_lock) {
  14869. return;
  14870. }
  14871. check_lock = true;
  14872. setTimeout(process, opts.interval);
  14873. };
  14874. $(window).scroll(on_check).resize(on_check);
  14875. check_binded = true;
  14876. }
  14877. if (opts.force_process) {
  14878. setTimeout(process, opts.interval);
  14879. }
  14880. add_selector(selector);
  14881. },
  14882. // force elements's appearance check
  14883. force_appear: function() {
  14884. if (check_binded) {
  14885. process();
  14886. return true;
  14887. }
  14888. return false;
  14889. }
  14890. });
  14891. })(function() {
  14892. if (typeof module !== 'undefined') {
  14893. // Node
  14894. return require('jquery');
  14895. } else {
  14896. return jQuery;
  14897. }
  14898. }());
  14899. /*!
  14900. jQuery countTo Plugin
  14901. Version: v1.2.0
  14902. Plugin URL: https://github.com/mhuggins/jquery-countTo
  14903. License: Copyright (c) Matt Huggins | Released under the MIT license
  14904. !*/
  14905. (function (factory) {
  14906. if (typeof define === 'function' && define.amd) {
  14907. // AMD
  14908. define(['jquery'], factory);
  14909. } else if (typeof exports === 'object') {
  14910. // CommonJS
  14911. factory(require('jquery'));
  14912. } else {
  14913. // Browser globals
  14914. factory(jQuery);
  14915. }
  14916. }(function ($) {
  14917. var CountTo = function (element, options) {
  14918. this.$element = $(element);
  14919. this.options = $.extend({}, CountTo.DEFAULTS, this.dataOptions(), options);
  14920. this.init();
  14921. };
  14922. CountTo.DEFAULTS = {
  14923. from: 0, // the number the element should start at
  14924. to: 0, // the number the element should end at
  14925. speed: 1000, // how long it should take to count between the target numbers
  14926. refreshInterval: 100, // how often the element should be updated
  14927. decimals: 0, // the number of decimal places to show
  14928. formatter: formatter, // handler for formatting the value before rendering
  14929. onUpdate: null, // callback method for every time the element is updated
  14930. onComplete: null // callback method for when the element finishes updating
  14931. };
  14932. CountTo.prototype.init = function () {
  14933. this.value = this.options.from;
  14934. this.loops = Math.ceil(this.options.speed / this.options.refreshInterval);
  14935. this.loopCount = 0;
  14936. this.increment = (this.options.to - this.options.from) / this.loops;
  14937. };
  14938. CountTo.prototype.dataOptions = function () {
  14939. var options = {
  14940. from: this.$element.data('from'),
  14941. to: this.$element.data('to'),
  14942. speed: this.$element.data('speed'),
  14943. refreshInterval: this.$element.data('refresh-interval'),
  14944. decimals: this.$element.data('decimals')
  14945. };
  14946. var keys = Object.keys(options);
  14947. for (var i in keys) {
  14948. var key = keys[i];
  14949. if (typeof(options[key]) === 'undefined') {
  14950. delete options[key];
  14951. }
  14952. }
  14953. return options;
  14954. };
  14955. CountTo.prototype.update = function () {
  14956. this.value += this.increment;
  14957. this.loopCount++;
  14958. this.render();
  14959. if (typeof(this.options.onUpdate) == 'function') {
  14960. this.options.onUpdate.call(this.$element, this.value);
  14961. }
  14962. if (this.loopCount >= this.loops) {
  14963. clearInterval(this.interval);
  14964. this.value = this.options.to;
  14965. if (typeof(this.options.onComplete) == 'function') {
  14966. this.options.onComplete.call(this.$element, this.value);
  14967. }
  14968. }
  14969. };
  14970. CountTo.prototype.render = function () {
  14971. var formattedValue = this.options.formatter.call(this.$element, this.value, this.options);
  14972. this.$element.text(formattedValue);
  14973. };
  14974. CountTo.prototype.restart = function () {
  14975. this.stop();
  14976. this.init();
  14977. this.start();
  14978. };
  14979. CountTo.prototype.start = function () {
  14980. this.stop();
  14981. this.render();
  14982. this.interval = setInterval(this.update.bind(this), this.options.refreshInterval);
  14983. };
  14984. CountTo.prototype.stop = function () {
  14985. if (this.interval) {
  14986. clearInterval(this.interval);
  14987. }
  14988. };
  14989. CountTo.prototype.toggle = function () {
  14990. if (this.interval) {
  14991. this.stop();
  14992. } else {
  14993. this.start();
  14994. }
  14995. };
  14996. function formatter(value, options) {
  14997. return value.toFixed(options.decimals);
  14998. }
  14999. $.fn.countTo = function (option) {
  15000. return this.each(function () {
  15001. var $this = $(this);
  15002. var data = $this.data('countTo');
  15003. var init = !data || typeof(option) === 'object';
  15004. var options = typeof(option) === 'object' ? option : {};
  15005. var method = typeof(option) === 'string' ? option : 'start';
  15006. if (init) {
  15007. if (data) data.stop();
  15008. $this.data('countTo', data = new CountTo(this, options));
  15009. }
  15010. data[method].call(data);
  15011. });
  15012. };
  15013. }));
  15014. /*!
  15015. The Final Countdown
  15016. Version: 2.2.0
  15017. Plugin URL: http://hilios.github.io/jQuery.countdown/
  15018. License: Copyright (c) 2016 Edson Hilios
  15019. !*/
  15020. (function(factory) {
  15021. "use strict";
  15022. if (typeof define === "function" && define.amd) {
  15023. define([ "jquery" ], factory);
  15024. } else {
  15025. factory(jQuery);
  15026. }
  15027. })(function($) {
  15028. "use strict";
  15029. var instances = [], matchers = [], defaultOptions = {
  15030. precision: 100,
  15031. elapse: false,
  15032. defer: false
  15033. };
  15034. matchers.push(/^[0-9]*$/.source);
  15035. matchers.push(/([0-9]{1,2}\/){2}[0-9]{4}( [0-9]{1,2}(:[0-9]{2}){2})?/.source);
  15036. matchers.push(/[0-9]{4}([\/\-][0-9]{1,2}){2}( [0-9]{1,2}(:[0-9]{2}){2})?/.source);
  15037. matchers = new RegExp(matchers.join("|"));
  15038. function parseDateString(dateString) {
  15039. if (dateString instanceof Date) {
  15040. return dateString;
  15041. }
  15042. if (String(dateString).match(matchers)) {
  15043. if (String(dateString).match(/^[0-9]*$/)) {
  15044. dateString = Number(dateString);
  15045. }
  15046. if (String(dateString).match(/\-/)) {
  15047. dateString = String(dateString).replace(/\-/g, "/");
  15048. }
  15049. return new Date(dateString);
  15050. } else {
  15051. throw new Error("Couldn't cast `" + dateString + "` to a date object.");
  15052. }
  15053. }
  15054. var DIRECTIVE_KEY_MAP = {
  15055. Y: "years",
  15056. m: "months",
  15057. n: "daysToMonth",
  15058. d: "daysToWeek",
  15059. w: "weeks",
  15060. W: "weeksToMonth",
  15061. H: "hours",
  15062. M: "minutes",
  15063. S: "seconds",
  15064. D: "totalDays",
  15065. I: "totalHours",
  15066. N: "totalMinutes",
  15067. T: "totalSeconds"
  15068. };
  15069. function escapedRegExp(str) {
  15070. var sanitize = str.toString().replace(/([.?*+^$[\]\\(){}|-])/g, "\\$1");
  15071. return new RegExp(sanitize);
  15072. }
  15073. function strftime(offsetObject) {
  15074. return function(format) {
  15075. var directives = format.match(/%(-|!)?[A-Z]{1}(:[^;]+;)?/gi);
  15076. if (directives) {
  15077. for (var i = 0, len = directives.length; i < len; ++i) {
  15078. var directive = directives[i].match(/%(-|!)?([a-zA-Z]{1})(:[^;]+;)?/), regexp = escapedRegExp(directive[0]), modifier = directive[1] || "", plural = directive[3] || "", value = null;
  15079. directive = directive[2];
  15080. if (DIRECTIVE_KEY_MAP.hasOwnProperty(directive)) {
  15081. value = DIRECTIVE_KEY_MAP[directive];
  15082. value = Number(offsetObject[value]);
  15083. }
  15084. if (value !== null) {
  15085. if (modifier === "!") {
  15086. value = pluralize(plural, value);
  15087. }
  15088. if (modifier === "") {
  15089. if (value < 10) {
  15090. value = "0" + value.toString();
  15091. }
  15092. }
  15093. format = format.replace(regexp, value.toString());
  15094. }
  15095. }
  15096. }
  15097. format = format.replace(/%%/, "%");
  15098. return format;
  15099. };
  15100. }
  15101. function pluralize(format, count) {
  15102. var plural = "s", singular = "";
  15103. if (format) {
  15104. format = format.replace(/(:|;|\s)/gi, "").split(/\,/);
  15105. if (format.length === 1) {
  15106. plural = format[0];
  15107. } else {
  15108. singular = format[0];
  15109. plural = format[1];
  15110. }
  15111. }
  15112. if (Math.abs(count) > 1) {
  15113. return plural;
  15114. } else {
  15115. return singular;
  15116. }
  15117. }
  15118. var Countdown = function(el, finalDate, options) {
  15119. this.el = el;
  15120. this.$el = $(el);
  15121. this.interval = null;
  15122. this.offset = {};
  15123. this.options = $.extend({}, defaultOptions);
  15124. this.instanceNumber = instances.length;
  15125. instances.push(this);
  15126. this.$el.data("countdown-instance", this.instanceNumber);
  15127. if (options) {
  15128. if (typeof options === "function") {
  15129. this.$el.on("update.countdown", options);
  15130. this.$el.on("stoped.countdown", options);
  15131. this.$el.on("finish.countdown", options);
  15132. } else {
  15133. this.options = $.extend({}, defaultOptions, options);
  15134. }
  15135. }
  15136. this.setFinalDate(finalDate);
  15137. if (this.options.defer === false) {
  15138. this.start();
  15139. }
  15140. };
  15141. $.extend(Countdown.prototype, {
  15142. start: function() {
  15143. if (this.interval !== null) {
  15144. clearInterval(this.interval);
  15145. }
  15146. var self = this;
  15147. this.update();
  15148. this.interval = setInterval(function() {
  15149. self.update.call(self);
  15150. }, this.options.precision);
  15151. },
  15152. stop: function() {
  15153. clearInterval(this.interval);
  15154. this.interval = null;
  15155. this.dispatchEvent("stoped");
  15156. },
  15157. toggle: function() {
  15158. if (this.interval) {
  15159. this.stop();
  15160. } else {
  15161. this.start();
  15162. }
  15163. },
  15164. pause: function() {
  15165. this.stop();
  15166. },
  15167. resume: function() {
  15168. this.start();
  15169. },
  15170. remove: function() {
  15171. this.stop.call(this);
  15172. instances[this.instanceNumber] = null;
  15173. delete this.$el.data().countdownInstance;
  15174. },
  15175. setFinalDate: function(value) {
  15176. this.finalDate = parseDateString(value);
  15177. },
  15178. update: function() {
  15179. if (this.$el.closest("html").length === 0) {
  15180. this.remove();
  15181. return;
  15182. }
  15183. var hasEventsAttached = $._data(this.el, "events") !== undefined, now = new Date(), newTotalSecsLeft;
  15184. newTotalSecsLeft = this.finalDate.getTime() - now.getTime();
  15185. newTotalSecsLeft = Math.ceil(newTotalSecsLeft / 1e3);
  15186. newTotalSecsLeft = !this.options.elapse && newTotalSecsLeft < 0 ? 0 : Math.abs(newTotalSecsLeft);
  15187. if (this.totalSecsLeft === newTotalSecsLeft || !hasEventsAttached) {
  15188. return;
  15189. } else {
  15190. this.totalSecsLeft = newTotalSecsLeft;
  15191. }
  15192. this.elapsed = now >= this.finalDate;
  15193. this.offset = {
  15194. seconds: this.totalSecsLeft % 60,
  15195. minutes: Math.floor(this.totalSecsLeft / 60) % 60,
  15196. hours: Math.floor(this.totalSecsLeft / 60 / 60) % 24,
  15197. days: Math.floor(this.totalSecsLeft / 60 / 60 / 24) % 7,
  15198. daysToWeek: Math.floor(this.totalSecsLeft / 60 / 60 / 24) % 7,
  15199. daysToMonth: Math.floor(this.totalSecsLeft / 60 / 60 / 24 % 30.4368),
  15200. weeks: Math.floor(this.totalSecsLeft / 60 / 60 / 24 / 7),
  15201. weeksToMonth: Math.floor(this.totalSecsLeft / 60 / 60 / 24 / 7) % 4,
  15202. months: Math.floor(this.totalSecsLeft / 60 / 60 / 24 / 30.4368),
  15203. years: Math.abs(this.finalDate.getFullYear() - now.getFullYear()),
  15204. totalDays: Math.floor(this.totalSecsLeft / 60 / 60 / 24),
  15205. totalHours: Math.floor(this.totalSecsLeft / 60 / 60),
  15206. totalMinutes: Math.floor(this.totalSecsLeft / 60),
  15207. totalSeconds: this.totalSecsLeft
  15208. };
  15209. if (!this.options.elapse && this.totalSecsLeft === 0) {
  15210. this.stop();
  15211. this.dispatchEvent("finish");
  15212. } else {
  15213. this.dispatchEvent("update");
  15214. }
  15215. },
  15216. dispatchEvent: function(eventName) {
  15217. var event = $.Event(eventName + ".countdown");
  15218. event.finalDate = this.finalDate;
  15219. event.elapsed = this.elapsed;
  15220. event.offset = $.extend({}, this.offset);
  15221. event.strftime = strftime(this.offset);
  15222. this.$el.trigger(event);
  15223. }
  15224. });
  15225. $.fn.countdown = function() {
  15226. var argumentsArray = Array.prototype.slice.call(arguments, 0);
  15227. return this.each(function() {
  15228. var instanceNumber = $(this).data("countdown-instance");
  15229. if (instanceNumber !== undefined) {
  15230. var instance = instances[instanceNumber], method = argumentsArray[0];
  15231. if (Countdown.prototype.hasOwnProperty(method)) {
  15232. instance[method].apply(instance, argumentsArray.slice(1));
  15233. } else if (String(method).match(/^[$A-Z_][0-9A-Z_$]*$/i) === null) {
  15234. instance.setFinalDate.call(instance, method);
  15235. instance.start();
  15236. } else {
  15237. $.error("Method %s does not exist on jQuery.countdown".replace(/\%s/gi, method));
  15238. }
  15239. } else {
  15240. new Countdown(this, argumentsArray[0], argumentsArray[1]);
  15241. }
  15242. });
  15243. };
  15244. });
  15245. /*!
  15246. Easy pie chart
  15247. Version: 2.1.7
  15248. Plugin URL: https://github.com/rendro/easy-pie-chart
  15249. License: Copyright | Robert Fleischmann
  15250. !*/
  15251. (function (root, factory) {
  15252. if (typeof define === 'function' && define.amd) {
  15253. // AMD. Register as an anonymous module unless amdModuleId is set
  15254. define(["jquery"], function (a0) {
  15255. return (factory(a0));
  15256. });
  15257. } else if (typeof exports === 'object') {
  15258. // Node. Does not work with strict CommonJS, but
  15259. // only CommonJS-like environments that support module.exports,
  15260. // like Node.
  15261. module.exports = factory(require("jquery"));
  15262. } else {
  15263. factory(jQuery);
  15264. }
  15265. }(this, function ($) {
  15266. /**
  15267. * Renderer to render the chart on a canvas object
  15268. * @param {DOMElement} el DOM element to host the canvas (root of the plugin)
  15269. * @param {object} options options object of the plugin
  15270. */
  15271. var CanvasRenderer = function(el, options) {
  15272. var cachedBackground;
  15273. var canvas = document.createElement('canvas');
  15274. el.appendChild(canvas);
  15275. if (typeof(G_vmlCanvasManager) === 'object') {
  15276. G_vmlCanvasManager.initElement(canvas);
  15277. }
  15278. var ctx = canvas.getContext('2d');
  15279. canvas.width = canvas.height = options.size;
  15280. // canvas on retina devices
  15281. var scaleBy = 1;
  15282. if (window.devicePixelRatio > 1) {
  15283. scaleBy = window.devicePixelRatio;
  15284. canvas.style.width = canvas.style.height = [options.size, 'px'].join('');
  15285. canvas.width = canvas.height = options.size * scaleBy;
  15286. ctx.scale(scaleBy, scaleBy);
  15287. }
  15288. // move 0,0 coordinates to the center
  15289. ctx.translate(options.size / 2, options.size / 2);
  15290. // rotate canvas -90deg
  15291. ctx.rotate((-1 / 2 + options.rotate / 180) * Math.PI);
  15292. var radius = (options.size - options.lineWidth) / 2;
  15293. if (options.scaleColor && options.scaleLength) {
  15294. radius -= options.scaleLength + 2; // 2 is the distance between scale and bar
  15295. }
  15296. // IE polyfill for Date
  15297. Date.now = Date.now || function() {
  15298. return +(new Date());
  15299. };
  15300. /**
  15301. * Draw a circle around the center of the canvas
  15302. * @param {strong} color Valid CSS color string
  15303. * @param {number} lineWidth Width of the line in px
  15304. * @param {number} percent Percentage to draw (float between -1 and 1)
  15305. */
  15306. var drawCircle = function(color, lineWidth, percent) {
  15307. percent = Math.min(Math.max(-1, percent || 0), 1);
  15308. var isNegative = percent <= 0 ? true : false;
  15309. ctx.beginPath();
  15310. ctx.arc(0, 0, radius, 0, Math.PI * 2 * percent, isNegative);
  15311. ctx.strokeStyle = color;
  15312. ctx.lineWidth = lineWidth;
  15313. ctx.stroke();
  15314. };
  15315. /**
  15316. * Draw the scale of the chart
  15317. */
  15318. var drawScale = function() {
  15319. var offset;
  15320. var length;
  15321. ctx.lineWidth = 1;
  15322. ctx.fillStyle = options.scaleColor;
  15323. ctx.save();
  15324. for (var i = 24; i > 0; --i) {
  15325. if (i % 6 === 0) {
  15326. length = options.scaleLength;
  15327. offset = 0;
  15328. } else {
  15329. length = options.scaleLength * 0.6;
  15330. offset = options.scaleLength - length;
  15331. }
  15332. ctx.fillRect(-options.size/2 + offset, 0, length, 1);
  15333. ctx.rotate(Math.PI / 12);
  15334. }
  15335. ctx.restore();
  15336. };
  15337. /**
  15338. * Request animation frame wrapper with polyfill
  15339. * @return {function} Request animation frame method or timeout fallback
  15340. */
  15341. var reqAnimationFrame = (function() {
  15342. return window.requestAnimationFrame ||
  15343. window.webkitRequestAnimationFrame ||
  15344. window.mozRequestAnimationFrame ||
  15345. function(callback) {
  15346. window.setTimeout(callback, 1000 / 60);
  15347. };
  15348. }());
  15349. /**
  15350. * Draw the background of the plugin including the scale and the track
  15351. */
  15352. var drawBackground = function() {
  15353. if(options.scaleColor) drawScale();
  15354. if(options.trackColor) drawCircle(options.trackColor, options.trackWidth || options.lineWidth, 1);
  15355. };
  15356. /**
  15357. * Canvas accessor
  15358. */
  15359. this.getCanvas = function() {
  15360. return canvas;
  15361. };
  15362. /**
  15363. * Canvas 2D context 'ctx' accessor
  15364. */
  15365. this.getCtx = function() {
  15366. return ctx;
  15367. };
  15368. /**
  15369. * Clear the complete canvas
  15370. */
  15371. this.clear = function() {
  15372. ctx.clearRect(options.size / -2, options.size / -2, options.size, options.size);
  15373. };
  15374. /**
  15375. * Draw the complete chart
  15376. * @param {number} percent Percent shown by the chart between -100 and 100
  15377. */
  15378. this.draw = function(percent) {
  15379. // do we need to render a background
  15380. if (!!options.scaleColor || !!options.trackColor) {
  15381. // getImageData and putImageData are supported
  15382. if (ctx.getImageData && ctx.putImageData) {
  15383. if (!cachedBackground) {
  15384. drawBackground();
  15385. cachedBackground = ctx.getImageData(0, 0, options.size * scaleBy, options.size * scaleBy);
  15386. } else {
  15387. ctx.putImageData(cachedBackground, 0, 0);
  15388. }
  15389. } else {
  15390. this.clear();
  15391. drawBackground();
  15392. }
  15393. } else {
  15394. this.clear();
  15395. }
  15396. ctx.lineCap = options.lineCap;
  15397. // if barcolor is a function execute it and pass the percent as a value
  15398. var color;
  15399. if (typeof(options.barColor) === 'function') {
  15400. color = options.barColor(percent);
  15401. } else {
  15402. color = options.barColor;
  15403. }
  15404. // draw bar
  15405. drawCircle(color, options.lineWidth, percent / 100);
  15406. }.bind(this);
  15407. /**
  15408. * Animate from some percent to some other percentage
  15409. * @param {number} from Starting percentage
  15410. * @param {number} to Final percentage
  15411. */
  15412. this.animate = function(from, to) {
  15413. var startTime = Date.now();
  15414. options.onStart(from, to);
  15415. var animation = function() {
  15416. var process = Math.min(Date.now() - startTime, options.animate.duration);
  15417. var currentValue = options.easing(this, process, from, to - from, options.animate.duration);
  15418. this.draw(currentValue);
  15419. options.onStep(from, to, currentValue);
  15420. if (process >= options.animate.duration) {
  15421. options.onStop(from, to);
  15422. } else {
  15423. reqAnimationFrame(animation);
  15424. }
  15425. }.bind(this);
  15426. reqAnimationFrame(animation);
  15427. }.bind(this);
  15428. };
  15429. var EasyPieChart = function(el, opts) {
  15430. var defaultOptions = {
  15431. barColor: '#ef1e25',
  15432. trackColor: '#f9f9f9',
  15433. scaleColor: '#dfe0e0',
  15434. scaleLength: 5,
  15435. lineCap: 'round',
  15436. lineWidth: 3,
  15437. trackWidth: undefined,
  15438. size: 110,
  15439. rotate: 0,
  15440. animate: {
  15441. duration: 1000,
  15442. enabled: true
  15443. },
  15444. easing: function (x, t, b, c, d) { // more can be found here: http://gsgd.co.uk/sandbox/jquery/easing/
  15445. t = t / (d/2);
  15446. if (t < 1) {
  15447. return c / 2 * t * t + b;
  15448. }
  15449. return -c/2 * ((--t)*(t-2) - 1) + b;
  15450. },
  15451. onStart: function(from, to) {
  15452. return;
  15453. },
  15454. onStep: function(from, to, currentValue) {
  15455. return;
  15456. },
  15457. onStop: function(from, to) {
  15458. return;
  15459. }
  15460. };
  15461. // detect present renderer
  15462. if (typeof(CanvasRenderer) !== 'undefined') {
  15463. defaultOptions.renderer = CanvasRenderer;
  15464. } else if (typeof(SVGRenderer) !== 'undefined') {
  15465. defaultOptions.renderer = SVGRenderer;
  15466. } else {
  15467. throw new Error('Please load either the SVG- or the CanvasRenderer');
  15468. }
  15469. var options = {};
  15470. var currentValue = 0;
  15471. /**
  15472. * Initialize the plugin by creating the options object and initialize rendering
  15473. */
  15474. var init = function() {
  15475. this.el = el;
  15476. this.options = options;
  15477. // merge user options into default options
  15478. for (var i in defaultOptions) {
  15479. if (defaultOptions.hasOwnProperty(i)) {
  15480. options[i] = opts && typeof(opts[i]) !== 'undefined' ? opts[i] : defaultOptions[i];
  15481. if (typeof(options[i]) === 'function') {
  15482. options[i] = options[i].bind(this);
  15483. }
  15484. }
  15485. }
  15486. // check for jQuery easing
  15487. if (typeof(options.easing) === 'string' && typeof(jQuery) !== 'undefined' && jQuery.isFunction(jQuery.easing[options.easing])) {
  15488. options.easing = jQuery.easing[options.easing];
  15489. } else {
  15490. options.easing = defaultOptions.easing;
  15491. }
  15492. // process earlier animate option to avoid bc breaks
  15493. if (typeof(options.animate) === 'number') {
  15494. options.animate = {
  15495. duration: options.animate,
  15496. enabled: true
  15497. };
  15498. }
  15499. if (typeof(options.animate) === 'boolean' && !options.animate) {
  15500. options.animate = {
  15501. duration: 1000,
  15502. enabled: options.animate
  15503. };
  15504. }
  15505. // create renderer
  15506. this.renderer = new options.renderer(el, options);
  15507. // initial draw
  15508. this.renderer.draw(currentValue);
  15509. // initial update
  15510. if (el.dataset && el.dataset.percent) {
  15511. this.update(parseFloat(el.dataset.percent));
  15512. } else if (el.getAttribute && el.getAttribute('data-percent')) {
  15513. this.update(parseFloat(el.getAttribute('data-percent')));
  15514. }
  15515. }.bind(this);
  15516. /**
  15517. * Update the value of the chart
  15518. * @param {number} newValue Number between 0 and 100
  15519. * @return {object} Instance of the plugin for method chaining
  15520. */
  15521. this.update = function(newValue) {
  15522. newValue = parseFloat(newValue);
  15523. if (options.animate.enabled) {
  15524. this.renderer.animate(currentValue, newValue);
  15525. } else {
  15526. this.renderer.draw(newValue);
  15527. }
  15528. currentValue = newValue;
  15529. return this;
  15530. }.bind(this);
  15531. /**
  15532. * Disable animation
  15533. * @return {object} Instance of the plugin for method chaining
  15534. */
  15535. this.disableAnimation = function() {
  15536. options.animate.enabled = false;
  15537. return this;
  15538. };
  15539. /**
  15540. * Enable animation
  15541. * @return {object} Instance of the plugin for method chaining
  15542. */
  15543. this.enableAnimation = function() {
  15544. options.animate.enabled = true;
  15545. return this;
  15546. };
  15547. init();
  15548. };
  15549. $.fn.easyPieChart = function(options) {
  15550. return this.each(function() {
  15551. var instanceOptions;
  15552. if (!$.data(this, 'easyPieChart')) {
  15553. instanceOptions = $.extend({}, options, $(this).data());
  15554. $.data(this, 'easyPieChart', new EasyPieChart(this, instanceOptions));
  15555. }
  15556. });
  15557. };
  15558. }));
  15559. /*!
  15560. FitVids
  15561. Version: 1.1
  15562. Plugin URI: http://fitvidsjs.com/
  15563. 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/
  15564. !*/
  15565. (function( $ ){
  15566. 'use strict';
  15567. $.fn.fitVids = function( options ) {
  15568. var settings = {
  15569. customSelector: null,
  15570. ignore: null
  15571. };
  15572. if(!document.getElementById('fit-vids-style')) {
  15573. // appendStyles: https://github.com/toddmotto/fluidvids/blob/master/dist/fluidvids.js
  15574. var head = document.head || document.getElementsByTagName('head')[0];
  15575. 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%;}';
  15576. var div = document.createElement("div");
  15577. div.innerHTML = '<p>x</p><style id="fit-vids-style">' + css + '</style>';
  15578. head.appendChild(div.childNodes[1]);
  15579. }
  15580. if ( options ) {
  15581. $.extend( settings, options );
  15582. }
  15583. return this.each(function(){
  15584. var selectors = [
  15585. 'iframe[src*="player.vimeo.com"]',
  15586. 'iframe[src*="youtube.com"]',
  15587. 'iframe[src*="youtube-nocookie.com"]',
  15588. 'iframe[src*="kickstarter.com"][src*="video.html"]',
  15589. 'object',
  15590. 'embed'
  15591. ];
  15592. if (settings.customSelector) {
  15593. selectors.push(settings.customSelector);
  15594. }
  15595. var ignoreList = '.fitvidsignore';
  15596. if(settings.ignore) {
  15597. ignoreList = ignoreList + ', ' + settings.ignore;
  15598. }
  15599. var $allVideos = $(this).find(selectors.join(','));
  15600. $allVideos = $allVideos.not('object object'); // SwfObj conflict patch
  15601. $allVideos = $allVideos.not(ignoreList); // Disable FitVids on this video.
  15602. $allVideos.each(function(){
  15603. var $this = $(this);
  15604. if($this.parents(ignoreList).length > 0) {
  15605. return; // Disable FitVids on this video.
  15606. }
  15607. if (this.tagName.toLowerCase() === 'embed' && $this.parent('object').length || $this.parent('.fluid-width-video-wrapper').length) { return; }
  15608. if ((!$this.css('height') && !$this.css('width')) && (isNaN($this.attr('height')) || isNaN($this.attr('width'))))
  15609. {
  15610. $this.attr('height', 9);
  15611. $this.attr('width', 16);
  15612. }
  15613. var height = ( this.tagName.toLowerCase() === 'object' || ($this.attr('height') && !isNaN(parseInt($this.attr('height'), 10))) ) ? parseInt($this.attr('height'), 10) : $this.height(),
  15614. width = !isNaN(parseInt($this.attr('width'), 10)) ? parseInt($this.attr('width'), 10) : $this.width(),
  15615. aspectRatio = height / width;
  15616. if(!$this.attr('name')){
  15617. var videoName = 'fitvid' + $.fn.fitVids._count;
  15618. $this.attr('name', videoName);
  15619. $.fn.fitVids._count++;
  15620. }
  15621. $this.wrap('<div class="fluid-width-video-wrapper"></div>').parent('.fluid-width-video-wrapper').css('padding-top', (aspectRatio * 100)+'%');
  15622. $this.removeAttr('height').removeAttr('width');
  15623. });
  15624. });
  15625. };
  15626. // Internal counter for unique video names.
  15627. $.fn.fitVids._count = 0;
  15628. // Works with either jQuery or Zepto
  15629. })( window.jQuery || window.Zepto );
  15630. /*!
  15631. Magnific Popup
  15632. Version: 1.2.0 - 2024-06-08
  15633. Plugin URL: http://dimsemenov.com/plugins/magnific-popup/
  15634. License: Copyright (c) 2024 Dmitry Semenov
  15635. !*/
  15636. ;(function (factory) {
  15637. if (typeof define === 'function' && define.amd) {
  15638. // AMD. Register as an anonymous module.
  15639. define(['jquery'], factory);
  15640. } else if (typeof exports === 'object') {
  15641. // Node/CommonJS
  15642. factory(require('jquery'));
  15643. } else {
  15644. // Browser globals
  15645. factory(window.jQuery || window.Zepto);
  15646. }
  15647. }(function($) {
  15648. /*>>core*/
  15649. /**
  15650. *
  15651. * Magnific Popup Core JS file
  15652. *
  15653. */
  15654. /**
  15655. * Private static constants
  15656. */
  15657. var CLOSE_EVENT = 'Close',
  15658. BEFORE_CLOSE_EVENT = 'BeforeClose',
  15659. AFTER_CLOSE_EVENT = 'AfterClose',
  15660. BEFORE_APPEND_EVENT = 'BeforeAppend',
  15661. MARKUP_PARSE_EVENT = 'MarkupParse',
  15662. OPEN_EVENT = 'Open',
  15663. CHANGE_EVENT = 'Change',
  15664. NS = 'mfp',
  15665. EVENT_NS = '.' + NS,
  15666. READY_CLASS = 'mfp-ready',
  15667. REMOVING_CLASS = 'mfp-removing',
  15668. PREVENT_CLOSE_CLASS = 'mfp-prevent-close';
  15669. /**
  15670. * Private vars
  15671. */
  15672. /*jshint -W079 */
  15673. var mfp, // As we have only one instance of MagnificPopup object, we define it locally to not to use 'this'
  15674. MagnificPopup = function(){},
  15675. _isJQ = !!(window.jQuery),
  15676. _prevStatus,
  15677. _window = $(window),
  15678. _document,
  15679. _prevContentType,
  15680. _wrapClasses,
  15681. _currPopupType;
  15682. /**
  15683. * Private functions
  15684. */
  15685. var _mfpOn = function(name, f) {
  15686. mfp.ev.on(NS + name + EVENT_NS, f);
  15687. },
  15688. _getEl = function(className, appendTo, html, raw) {
  15689. var el = document.createElement('div');
  15690. el.className = 'mfp-'+className;
  15691. if(html) {
  15692. el.innerHTML = html;
  15693. }
  15694. if(!raw) {
  15695. el = $(el);
  15696. if(appendTo) {
  15697. el.appendTo(appendTo);
  15698. }
  15699. } else if(appendTo) {
  15700. appendTo.appendChild(el);
  15701. }
  15702. return el;
  15703. },
  15704. _mfpTrigger = function(e, data) {
  15705. mfp.ev.triggerHandler(NS + e, data);
  15706. if(mfp.st.callbacks) {
  15707. // converts "mfpEventName" to "eventName" callback and triggers it if it's present
  15708. e = e.charAt(0).toLowerCase() + e.slice(1);
  15709. if(mfp.st.callbacks[e]) {
  15710. mfp.st.callbacks[e].apply(mfp, Array.isArray(data) ? data : [data]);
  15711. }
  15712. }
  15713. },
  15714. _getCloseBtn = function(type) {
  15715. if(type !== _currPopupType || !mfp.currTemplate.closeBtn) {
  15716. mfp.currTemplate.closeBtn = $( mfp.st.closeMarkup.replace('%title%', mfp.st.tClose ) );
  15717. _currPopupType = type;
  15718. }
  15719. return mfp.currTemplate.closeBtn;
  15720. },
  15721. // Initialize Magnific Popup only when called at least once
  15722. _checkInstance = function() {
  15723. if(!$.magnificPopup.instance) {
  15724. /*jshint -W020 */
  15725. mfp = new MagnificPopup();
  15726. mfp.init();
  15727. $.magnificPopup.instance = mfp;
  15728. }
  15729. },
  15730. // CSS transition detection, http://stackoverflow.com/questions/7264899/detect-css-transitions-using-javascript-and-without-modernizr
  15731. supportsTransitions = function() {
  15732. var s = document.createElement('p').style, // 's' for style. better to create an element if body yet to exist
  15733. v = ['ms','O','Moz','Webkit']; // 'v' for vendor
  15734. if( s['transition'] !== undefined ) {
  15735. return true;
  15736. }
  15737. while( v.length ) {
  15738. if( v.pop() + 'Transition' in s ) {
  15739. return true;
  15740. }
  15741. }
  15742. return false;
  15743. };
  15744. /**
  15745. * Public functions
  15746. */
  15747. MagnificPopup.prototype = {
  15748. constructor: MagnificPopup,
  15749. /**
  15750. * Initializes Magnific Popup plugin.
  15751. * This function is triggered only once when $.fn.magnificPopup or $.magnificPopup is executed
  15752. */
  15753. init: function() {
  15754. var appVersion = navigator.appVersion;
  15755. mfp.isLowIE = mfp.isIE8 = document.all && !document.addEventListener;
  15756. mfp.isAndroid = (/android/gi).test(appVersion);
  15757. mfp.isIOS = (/iphone|ipad|ipod/gi).test(appVersion);
  15758. mfp.supportsTransition = supportsTransitions();
  15759. // We disable fixed positioned lightbox on devices that don't handle it nicely.
  15760. // If you know a better way of detecting this - let me know.
  15761. mfp.probablyMobile = (mfp.isAndroid || mfp.isIOS || /(Opera Mini)|Kindle|webOS|BlackBerry|(Opera Mobi)|(Windows Phone)|IEMobile/i.test(navigator.userAgent) );
  15762. _document = $(document);
  15763. mfp.popupsCache = {};
  15764. },
  15765. /**
  15766. * Opens popup
  15767. * @param data [description]
  15768. */
  15769. open: function(data) {
  15770. var i;
  15771. if(data.isObj === false) {
  15772. // convert jQuery collection to array to avoid conflicts later
  15773. mfp.items = data.items.toArray();
  15774. mfp.index = 0;
  15775. var items = data.items,
  15776. item;
  15777. for(i = 0; i < items.length; i++) {
  15778. item = items[i];
  15779. if(item.parsed) {
  15780. item = item.el[0];
  15781. }
  15782. if(item === data.el[0]) {
  15783. mfp.index = i;
  15784. break;
  15785. }
  15786. }
  15787. } else {
  15788. mfp.items = Array.isArray(data.items) ? data.items : [data.items];
  15789. mfp.index = data.index || 0;
  15790. }
  15791. // if popup is already opened - we just update the content
  15792. if(mfp.isOpen) {
  15793. mfp.updateItemHTML();
  15794. return;
  15795. }
  15796. mfp.types = [];
  15797. _wrapClasses = '';
  15798. if(data.mainEl && data.mainEl.length) {
  15799. mfp.ev = data.mainEl.eq(0);
  15800. } else {
  15801. mfp.ev = _document;
  15802. }
  15803. if(data.key) {
  15804. if(!mfp.popupsCache[data.key]) {
  15805. mfp.popupsCache[data.key] = {};
  15806. }
  15807. mfp.currTemplate = mfp.popupsCache[data.key];
  15808. } else {
  15809. mfp.currTemplate = {};
  15810. }
  15811. mfp.st = $.extend(true, {}, $.magnificPopup.defaults, data );
  15812. mfp.fixedContentPos = mfp.st.fixedContentPos === 'auto' ? !mfp.probablyMobile : mfp.st.fixedContentPos;
  15813. if(mfp.st.modal) {
  15814. mfp.st.closeOnContentClick = false;
  15815. mfp.st.closeOnBgClick = false;
  15816. mfp.st.showCloseBtn = false;
  15817. mfp.st.enableEscapeKey = false;
  15818. }
  15819. // Building markup
  15820. // main containers are created only once
  15821. if(!mfp.bgOverlay) {
  15822. // Dark overlay
  15823. mfp.bgOverlay = _getEl('bg').on('click'+EVENT_NS, function() {
  15824. mfp.close();
  15825. });
  15826. mfp.wrap = _getEl('wrap').attr('tabindex', -1).on('click'+EVENT_NS, function(e) {
  15827. if(mfp._checkIfClose(e.target)) {
  15828. mfp.close();
  15829. }
  15830. });
  15831. mfp.container = _getEl('container', mfp.wrap);
  15832. }
  15833. mfp.contentContainer = _getEl('content');
  15834. if(mfp.st.preloader) {
  15835. mfp.preloader = _getEl('preloader', mfp.container, mfp.st.tLoading);
  15836. }
  15837. // Initializing modules
  15838. var modules = $.magnificPopup.modules;
  15839. for(i = 0; i < modules.length; i++) {
  15840. var n = modules[i];
  15841. n = n.charAt(0).toUpperCase() + n.slice(1);
  15842. mfp['init'+n].call(mfp);
  15843. }
  15844. _mfpTrigger('BeforeOpen');
  15845. if(mfp.st.showCloseBtn) {
  15846. // Close button
  15847. if(!mfp.st.closeBtnInside) {
  15848. mfp.wrap.append( _getCloseBtn() );
  15849. } else {
  15850. _mfpOn(MARKUP_PARSE_EVENT, function(e, template, values, item) {
  15851. values.close_replaceWith = _getCloseBtn(item.type);
  15852. });
  15853. _wrapClasses += ' mfp-close-btn-in';
  15854. }
  15855. }
  15856. if(mfp.st.alignTop) {
  15857. _wrapClasses += ' mfp-align-top';
  15858. }
  15859. if(mfp.fixedContentPos) {
  15860. mfp.wrap.css({
  15861. overflow: mfp.st.overflowY,
  15862. overflowX: 'hidden',
  15863. overflowY: mfp.st.overflowY
  15864. });
  15865. } else {
  15866. mfp.wrap.css({
  15867. top: _window.scrollTop(),
  15868. position: 'absolute'
  15869. });
  15870. }
  15871. if( mfp.st.fixedBgPos === false || (mfp.st.fixedBgPos === 'auto' && !mfp.fixedContentPos) ) {
  15872. mfp.bgOverlay.css({
  15873. height: _document.height(),
  15874. position: 'absolute'
  15875. });
  15876. }
  15877. if(mfp.st.enableEscapeKey) {
  15878. // Close on ESC key
  15879. _document.on('keyup' + EVENT_NS, function(e) {
  15880. if(e.keyCode === 27) {
  15881. mfp.close();
  15882. }
  15883. });
  15884. }
  15885. _window.on('resize' + EVENT_NS, function() {
  15886. mfp.updateSize();
  15887. });
  15888. if(!mfp.st.closeOnContentClick) {
  15889. _wrapClasses += ' mfp-auto-cursor';
  15890. }
  15891. if(_wrapClasses)
  15892. mfp.wrap.addClass(_wrapClasses);
  15893. // this triggers recalculation of layout, so we get it once to not to trigger twice
  15894. var windowHeight = mfp.wH = _window.height();
  15895. var windowStyles = {};
  15896. if( mfp.fixedContentPos ) {
  15897. if(mfp._hasScrollBar(windowHeight)){
  15898. var s = mfp._getScrollbarSize();
  15899. if(s) {
  15900. windowStyles.marginRight = s;
  15901. }
  15902. }
  15903. }
  15904. if(mfp.fixedContentPos) {
  15905. if(!mfp.isIE7) {
  15906. windowStyles.overflow = 'hidden';
  15907. } else {
  15908. // ie7 double-scroll bug
  15909. $('body, html').css('overflow', 'hidden');
  15910. }
  15911. }
  15912. var classesToadd = mfp.st.mainClass;
  15913. if(mfp.isIE7) {
  15914. classesToadd += ' mfp-ie7';
  15915. }
  15916. if(classesToadd) {
  15917. mfp._addClassToMFP( classesToadd );
  15918. }
  15919. // add content
  15920. mfp.updateItemHTML();
  15921. _mfpTrigger('BuildControls');
  15922. // remove scrollbar, add margin e.t.c
  15923. $('html').css(windowStyles);
  15924. // add everything to DOM
  15925. mfp.bgOverlay.add(mfp.wrap).prependTo( mfp.st.prependTo || $(document.body) );
  15926. // Save last focused element
  15927. mfp._lastFocusedEl = document.activeElement;
  15928. // Wait for next cycle to allow CSS transition
  15929. setTimeout(function() {
  15930. if(mfp.content) {
  15931. mfp._addClassToMFP(READY_CLASS);
  15932. mfp._setFocus();
  15933. } else {
  15934. // if content is not defined (not loaded e.t.c) we add class only for BG
  15935. mfp.bgOverlay.addClass(READY_CLASS);
  15936. }
  15937. // Trap the focus in popup
  15938. _document.on('focusin' + EVENT_NS, mfp._onFocusIn);
  15939. }, 16);
  15940. mfp.isOpen = true;
  15941. mfp.updateSize(windowHeight);
  15942. _mfpTrigger(OPEN_EVENT);
  15943. return data;
  15944. },
  15945. /**
  15946. * Closes the popup
  15947. */
  15948. close: function() {
  15949. if(!mfp.isOpen) return;
  15950. _mfpTrigger(BEFORE_CLOSE_EVENT);
  15951. mfp.isOpen = false;
  15952. // for CSS3 animation
  15953. if(mfp.st.removalDelay && !mfp.isLowIE && mfp.supportsTransition ) {
  15954. mfp._addClassToMFP(REMOVING_CLASS);
  15955. setTimeout(function() {
  15956. mfp._close();
  15957. }, mfp.st.removalDelay);
  15958. } else {
  15959. mfp._close();
  15960. }
  15961. },
  15962. /**
  15963. * Helper for close() function
  15964. */
  15965. _close: function() {
  15966. _mfpTrigger(CLOSE_EVENT);
  15967. var classesToRemove = REMOVING_CLASS + ' ' + READY_CLASS + ' ';
  15968. mfp.bgOverlay.detach();
  15969. mfp.wrap.detach();
  15970. mfp.container.empty();
  15971. if(mfp.st.mainClass) {
  15972. classesToRemove += mfp.st.mainClass + ' ';
  15973. }
  15974. mfp._removeClassFromMFP(classesToRemove);
  15975. if(mfp.fixedContentPos) {
  15976. var windowStyles = {marginRight: ''};
  15977. if(mfp.isIE7) {
  15978. $('body, html').css('overflow', '');
  15979. } else {
  15980. windowStyles.overflow = '';
  15981. }
  15982. $('html').css(windowStyles);
  15983. }
  15984. _document.off('keyup' + EVENT_NS + ' focusin' + EVENT_NS);
  15985. mfp.ev.off(EVENT_NS);
  15986. // clean up DOM elements that aren't removed
  15987. mfp.wrap.attr('class', 'mfp-wrap').removeAttr('style');
  15988. mfp.bgOverlay.attr('class', 'mfp-bg');
  15989. mfp.container.attr('class', 'mfp-container');
  15990. // remove close button from target element
  15991. if(mfp.st.showCloseBtn &&
  15992. (!mfp.st.closeBtnInside || mfp.currTemplate[mfp.currItem.type] === true)) {
  15993. if(mfp.currTemplate.closeBtn)
  15994. mfp.currTemplate.closeBtn.detach();
  15995. }
  15996. if(mfp.st.autoFocusLast && mfp._lastFocusedEl) {
  15997. $(mfp._lastFocusedEl).trigger('focus'); // put tab focus back
  15998. }
  15999. mfp.currItem = null;
  16000. mfp.content = null;
  16001. mfp.currTemplate = null;
  16002. mfp.prevHeight = 0;
  16003. _mfpTrigger(AFTER_CLOSE_EVENT);
  16004. },
  16005. updateSize: function(winHeight) {
  16006. if(mfp.isIOS) {
  16007. // fixes iOS nav bars https://github.com/dimsemenov/Magnific-Popup/issues/2
  16008. var zoomLevel = document.documentElement.clientWidth / window.innerWidth;
  16009. var height = window.innerHeight * zoomLevel;
  16010. mfp.wrap.css('height', height);
  16011. mfp.wH = height;
  16012. } else {
  16013. mfp.wH = winHeight || _window.height();
  16014. }
  16015. // Fixes #84: popup incorrectly positioned with position:relative on body
  16016. if(!mfp.fixedContentPos) {
  16017. mfp.wrap.css('height', mfp.wH);
  16018. }
  16019. _mfpTrigger('Resize');
  16020. },
  16021. /**
  16022. * Set content of popup based on current index
  16023. */
  16024. updateItemHTML: function() {
  16025. var item = mfp.items[mfp.index];
  16026. // Detach and perform modifications
  16027. mfp.contentContainer.detach();
  16028. if(mfp.content)
  16029. mfp.content.detach();
  16030. if(!item.parsed) {
  16031. item = mfp.parseEl( mfp.index );
  16032. }
  16033. var type = item.type;
  16034. _mfpTrigger('BeforeChange', [mfp.currItem ? mfp.currItem.type : '', type]);
  16035. // BeforeChange event works like so:
  16036. // _mfpOn('BeforeChange', function(e, prevType, newType) { });
  16037. mfp.currItem = item;
  16038. if(!mfp.currTemplate[type]) {
  16039. var markup = mfp.st[type] ? mfp.st[type].markup : false;
  16040. // allows to modify markup
  16041. _mfpTrigger('FirstMarkupParse', markup);
  16042. if(markup) {
  16043. mfp.currTemplate[type] = $(markup);
  16044. } else {
  16045. // if there is no markup found we just define that template is parsed
  16046. mfp.currTemplate[type] = true;
  16047. }
  16048. }
  16049. if(_prevContentType && _prevContentType !== item.type) {
  16050. mfp.container.removeClass('mfp-'+_prevContentType+'-holder');
  16051. }
  16052. var newContent = mfp['get' + type.charAt(0).toUpperCase() + type.slice(1)](item, mfp.currTemplate[type]);
  16053. mfp.appendContent(newContent, type);
  16054. item.preloaded = true;
  16055. _mfpTrigger(CHANGE_EVENT, item);
  16056. _prevContentType = item.type;
  16057. // Append container back after its content changed
  16058. mfp.container.prepend(mfp.contentContainer);
  16059. _mfpTrigger('AfterChange');
  16060. },
  16061. /**
  16062. * Set HTML content of popup
  16063. */
  16064. appendContent: function(newContent, type) {
  16065. mfp.content = newContent;
  16066. if(newContent) {
  16067. if(mfp.st.showCloseBtn && mfp.st.closeBtnInside &&
  16068. mfp.currTemplate[type] === true) {
  16069. // if there is no markup, we just append close button element inside
  16070. if(!mfp.content.find('.mfp-close').length) {
  16071. mfp.content.append(_getCloseBtn());
  16072. }
  16073. } else {
  16074. mfp.content = newContent;
  16075. }
  16076. } else {
  16077. mfp.content = '';
  16078. }
  16079. _mfpTrigger(BEFORE_APPEND_EVENT);
  16080. mfp.container.addClass('mfp-'+type+'-holder');
  16081. mfp.contentContainer.append(mfp.content);
  16082. },
  16083. /**
  16084. * Creates Magnific Popup data object based on given data
  16085. * @param {int} index Index of item to parse
  16086. */
  16087. parseEl: function(index) {
  16088. var item = mfp.items[index],
  16089. type;
  16090. if(item.tagName) {
  16091. item = { el: $(item) };
  16092. } else {
  16093. type = item.type;
  16094. item = { data: item, src: item.src };
  16095. }
  16096. if(item.el) {
  16097. var types = mfp.types;
  16098. // check for 'mfp-TYPE' class
  16099. for(var i = 0; i < types.length; i++) {
  16100. if( item.el.hasClass('mfp-'+types[i]) ) {
  16101. type = types[i];
  16102. break;
  16103. }
  16104. }
  16105. item.src = item.el.attr('data-mfp-src');
  16106. if(!item.src) {
  16107. item.src = item.el.attr('href');
  16108. }
  16109. }
  16110. item.type = type || mfp.st.type || 'inline';
  16111. item.index = index;
  16112. item.parsed = true;
  16113. mfp.items[index] = item;
  16114. _mfpTrigger('ElementParse', item);
  16115. return mfp.items[index];
  16116. },
  16117. /**
  16118. * Initializes single popup or a group of popups
  16119. */
  16120. addGroup: function(el, options) {
  16121. var eHandler = function(e) {
  16122. e.mfpEl = this;
  16123. mfp._openClick(e, el, options);
  16124. };
  16125. if(!options) {
  16126. options = {};
  16127. }
  16128. var eName = 'click.magnificPopup';
  16129. options.mainEl = el;
  16130. if(options.items) {
  16131. options.isObj = true;
  16132. el.off(eName).on(eName, eHandler);
  16133. } else {
  16134. options.isObj = false;
  16135. if(options.delegate) {
  16136. el.off(eName).on(eName, options.delegate , eHandler);
  16137. } else {
  16138. options.items = el;
  16139. el.off(eName).on(eName, eHandler);
  16140. }
  16141. }
  16142. },
  16143. _openClick: function(e, el, options) {
  16144. var midClick = options.midClick !== undefined ? options.midClick : $.magnificPopup.defaults.midClick;
  16145. if(!midClick && ( e.which === 2 || e.ctrlKey || e.metaKey || e.altKey || e.shiftKey ) ) {
  16146. return;
  16147. }
  16148. var disableOn = options.disableOn !== undefined ? options.disableOn : $.magnificPopup.defaults.disableOn;
  16149. if(disableOn) {
  16150. if(typeof disableOn === "function") {
  16151. if( !disableOn.call(mfp) ) {
  16152. return true;
  16153. }
  16154. } else { // else it's number
  16155. if( _window.width() < disableOn ) {
  16156. return true;
  16157. }
  16158. }
  16159. }
  16160. if(e.type) {
  16161. e.preventDefault();
  16162. // This will prevent popup from closing if element is inside and popup is already opened
  16163. if(mfp.isOpen) {
  16164. e.stopPropagation();
  16165. }
  16166. }
  16167. options.el = $(e.mfpEl);
  16168. if(options.delegate) {
  16169. options.items = el.find(options.delegate);
  16170. }
  16171. mfp.open(options);
  16172. },
  16173. /**
  16174. * Updates text on preloader
  16175. */
  16176. updateStatus: function(status, text) {
  16177. if(mfp.preloader) {
  16178. if(_prevStatus !== status) {
  16179. mfp.container.removeClass('mfp-s-'+_prevStatus);
  16180. }
  16181. if(!text && status === 'loading') {
  16182. text = mfp.st.tLoading;
  16183. }
  16184. var data = {
  16185. status: status,
  16186. text: text
  16187. };
  16188. // allows to modify status
  16189. _mfpTrigger('UpdateStatus', data);
  16190. status = data.status;
  16191. text = data.text;
  16192. if (mfp.st.allowHTMLInStatusIndicator) {
  16193. mfp.preloader.html(text);
  16194. } else {
  16195. mfp.preloader.text(text);
  16196. }
  16197. mfp.preloader.find('a').on('click', function(e) {
  16198. e.stopImmediatePropagation();
  16199. });
  16200. mfp.container.addClass('mfp-s-'+status);
  16201. _prevStatus = status;
  16202. }
  16203. },
  16204. /*
  16205. "Private" helpers that aren't private at all
  16206. */
  16207. // Check to close popup or not
  16208. // "target" is an element that was clicked
  16209. _checkIfClose: function(target) {
  16210. if($(target).closest('.' + PREVENT_CLOSE_CLASS).length) {
  16211. return;
  16212. }
  16213. var closeOnContent = mfp.st.closeOnContentClick;
  16214. var closeOnBg = mfp.st.closeOnBgClick;
  16215. if(closeOnContent && closeOnBg) {
  16216. return true;
  16217. } else {
  16218. // We close the popup if click is on close button or on preloader. Or if there is no content.
  16219. if(!mfp.content || $(target).closest('.mfp-close').length || (mfp.preloader && target === mfp.preloader[0]) ) {
  16220. return true;
  16221. }
  16222. // if click is outside the content
  16223. if( (target !== mfp.content[0] && !$.contains(mfp.content[0], target)) ) {
  16224. if(closeOnBg) {
  16225. // last check, if the clicked element is in DOM, (in case it's removed onclick)
  16226. if( $.contains(document, target) ) {
  16227. return true;
  16228. }
  16229. }
  16230. } else if(closeOnContent) {
  16231. return true;
  16232. }
  16233. }
  16234. return false;
  16235. },
  16236. _addClassToMFP: function(cName) {
  16237. mfp.bgOverlay.addClass(cName);
  16238. mfp.wrap.addClass(cName);
  16239. },
  16240. _removeClassFromMFP: function(cName) {
  16241. this.bgOverlay.removeClass(cName);
  16242. mfp.wrap.removeClass(cName);
  16243. },
  16244. _hasScrollBar: function(winHeight) {
  16245. return ( (mfp.isIE7 ? _document.height() : document.body.scrollHeight) > (winHeight || _window.height()) );
  16246. },
  16247. _setFocus: function() {
  16248. (mfp.st.focus ? mfp.content.find(mfp.st.focus).eq(0) : mfp.wrap).trigger('focus');
  16249. },
  16250. _onFocusIn: function(e) {
  16251. if( e.target !== mfp.wrap[0] && !$.contains(mfp.wrap[0], e.target) ) {
  16252. mfp._setFocus();
  16253. return false;
  16254. }
  16255. },
  16256. _parseMarkup: function(template, values, item) {
  16257. var arr;
  16258. if(item.data) {
  16259. values = $.extend(item.data, values);
  16260. }
  16261. _mfpTrigger(MARKUP_PARSE_EVENT, [template, values, item] );
  16262. $.each(values, function(key, value) {
  16263. if(value === undefined || value === false) {
  16264. return true;
  16265. }
  16266. arr = key.split('_');
  16267. if(arr.length > 1) {
  16268. var el = template.find(EVENT_NS + '-'+arr[0]);
  16269. if(el.length > 0) {
  16270. var attr = arr[1];
  16271. if(attr === 'replaceWith') {
  16272. if(el[0] !== value[0]) {
  16273. el.replaceWith(value);
  16274. }
  16275. } else if(attr === 'img') {
  16276. if(el.is('img')) {
  16277. el.attr('src', value);
  16278. } else {
  16279. el.replaceWith( $('<img>').attr('src', value).attr('class', el.attr('class')) );
  16280. }
  16281. } else {
  16282. el.attr(arr[1], value);
  16283. }
  16284. }
  16285. } else {
  16286. if (mfp.st.allowHTMLInTemplate) {
  16287. template.find(EVENT_NS + '-'+key).html(value);
  16288. } else {
  16289. template.find(EVENT_NS + '-'+key).text(value);
  16290. }
  16291. }
  16292. });
  16293. },
  16294. _getScrollbarSize: function() {
  16295. // thx David
  16296. if(mfp.scrollbarSize === undefined) {
  16297. var scrollDiv = document.createElement("div");
  16298. scrollDiv.style.cssText = 'width: 99px; height: 99px; overflow: scroll; position: absolute; top: -9999px;';
  16299. document.body.appendChild(scrollDiv);
  16300. mfp.scrollbarSize = scrollDiv.offsetWidth - scrollDiv.clientWidth;
  16301. document.body.removeChild(scrollDiv);
  16302. }
  16303. return mfp.scrollbarSize;
  16304. }
  16305. }; /* MagnificPopup core prototype end */
  16306. /**
  16307. * Public static functions
  16308. */
  16309. $.magnificPopup = {
  16310. instance: null,
  16311. proto: MagnificPopup.prototype,
  16312. modules: [],
  16313. open: function(options, index) {
  16314. _checkInstance();
  16315. if(!options) {
  16316. options = {};
  16317. } else {
  16318. options = $.extend(true, {}, options);
  16319. }
  16320. options.isObj = true;
  16321. options.index = index || 0;
  16322. return this.instance.open(options);
  16323. },
  16324. close: function() {
  16325. return $.magnificPopup.instance && $.magnificPopup.instance.close();
  16326. },
  16327. registerModule: function(name, module) {
  16328. if(module.options) {
  16329. $.magnificPopup.defaults[name] = module.options;
  16330. }
  16331. $.extend(this.proto, module.proto);
  16332. this.modules.push(name);
  16333. },
  16334. defaults: {
  16335. // Info about options is in docs:
  16336. // http://dimsemenov.com/plugins/magnific-popup/documentation.html#options
  16337. disableOn: 0,
  16338. key: null,
  16339. midClick: false,
  16340. mainClass: '',
  16341. preloader: true,
  16342. focus: '', // CSS selector of input to focus after popup is opened
  16343. closeOnContentClick: false,
  16344. closeOnBgClick: true,
  16345. closeBtnInside: true,
  16346. showCloseBtn: true,
  16347. enableEscapeKey: true,
  16348. modal: false,
  16349. alignTop: false,
  16350. removalDelay: 0,
  16351. prependTo: null,
  16352. fixedContentPos: 'auto',
  16353. fixedBgPos: 'auto',
  16354. overflowY: 'auto',
  16355. closeMarkup: '<button title="%title%" type="button" class="mfp-close">&#215;</button>',
  16356. tClose: 'Close (Esc)',
  16357. tLoading: 'Loading...',
  16358. autoFocusLast: true,
  16359. allowHTMLInStatusIndicator: false,
  16360. allowHTMLInTemplate: false
  16361. }
  16362. };
  16363. $.fn.magnificPopup = function(options) {
  16364. _checkInstance();
  16365. var jqEl = $(this);
  16366. // We call some API method of first param is a string
  16367. if (typeof options === "string" ) {
  16368. if(options === 'open') {
  16369. var items,
  16370. itemOpts = _isJQ ? jqEl.data('magnificPopup') : jqEl[0].magnificPopup,
  16371. index = parseInt(arguments[1], 10) || 0;
  16372. if(itemOpts.items) {
  16373. items = itemOpts.items[index];
  16374. } else {
  16375. items = jqEl;
  16376. if(itemOpts.delegate) {
  16377. items = items.find(itemOpts.delegate);
  16378. }
  16379. items = items.eq( index );
  16380. }
  16381. mfp._openClick({mfpEl:items}, jqEl, itemOpts);
  16382. } else {
  16383. if(mfp.isOpen)
  16384. mfp[options].apply(mfp, Array.prototype.slice.call(arguments, 1));
  16385. }
  16386. } else {
  16387. // clone options obj
  16388. options = $.extend(true, {}, options);
  16389. /*
  16390. * As Zepto doesn't support .data() method for objects
  16391. * and it works only in normal browsers
  16392. * we assign "options" object directly to the DOM element. FTW!
  16393. */
  16394. if(_isJQ) {
  16395. jqEl.data('magnificPopup', options);
  16396. } else {
  16397. jqEl[0].magnificPopup = options;
  16398. }
  16399. mfp.addGroup(jqEl, options);
  16400. }
  16401. return jqEl;
  16402. };
  16403. /*>>core*/
  16404. /*>>inline*/
  16405. var INLINE_NS = 'inline',
  16406. _hiddenClass,
  16407. _inlinePlaceholder,
  16408. _lastInlineElement,
  16409. _putInlineElementsBack = function() {
  16410. if(_lastInlineElement) {
  16411. _inlinePlaceholder.after( _lastInlineElement.addClass(_hiddenClass) ).detach();
  16412. _lastInlineElement = null;
  16413. }
  16414. };
  16415. $.magnificPopup.registerModule(INLINE_NS, {
  16416. options: {
  16417. hiddenClass: 'hide', // will be appended with `mfp-` prefix
  16418. markup: '',
  16419. tNotFound: 'Content not found'
  16420. },
  16421. proto: {
  16422. initInline: function() {
  16423. mfp.types.push(INLINE_NS);
  16424. _mfpOn(CLOSE_EVENT+'.'+INLINE_NS, function() {
  16425. _putInlineElementsBack();
  16426. });
  16427. },
  16428. getInline: function(item, template) {
  16429. _putInlineElementsBack();
  16430. if(item.src) {
  16431. var inlineSt = mfp.st.inline,
  16432. el = $(item.src);
  16433. if(el.length) {
  16434. // If target element has parent - we replace it with placeholder and put it back after popup is closed
  16435. var parent = el[0].parentNode;
  16436. if(parent && parent.tagName) {
  16437. if(!_inlinePlaceholder) {
  16438. _hiddenClass = inlineSt.hiddenClass;
  16439. _inlinePlaceholder = _getEl(_hiddenClass);
  16440. _hiddenClass = 'mfp-'+_hiddenClass;
  16441. }
  16442. // replace target inline element with placeholder
  16443. _lastInlineElement = el.after(_inlinePlaceholder).detach().removeClass(_hiddenClass);
  16444. }
  16445. mfp.updateStatus('ready');
  16446. } else {
  16447. mfp.updateStatus('error', inlineSt.tNotFound);
  16448. el = $('<div>');
  16449. }
  16450. item.inlineElement = el;
  16451. return el;
  16452. }
  16453. mfp.updateStatus('ready');
  16454. mfp._parseMarkup(template, {}, item);
  16455. return template;
  16456. }
  16457. }
  16458. });
  16459. /*>>inline*/
  16460. /*>>ajax*/
  16461. var AJAX_NS = 'ajax',
  16462. _ajaxCur,
  16463. _removeAjaxCursor = function() {
  16464. if(_ajaxCur) {
  16465. $(document.body).removeClass(_ajaxCur);
  16466. }
  16467. },
  16468. _destroyAjaxRequest = function() {
  16469. _removeAjaxCursor();
  16470. if(mfp.req) {
  16471. mfp.req.abort();
  16472. }
  16473. };
  16474. $.magnificPopup.registerModule(AJAX_NS, {
  16475. options: {
  16476. settings: null,
  16477. cursor: 'mfp-ajax-cur',
  16478. tError: 'The content could not be loaded.'
  16479. },
  16480. proto: {
  16481. initAjax: function() {
  16482. mfp.types.push(AJAX_NS);
  16483. _ajaxCur = mfp.st.ajax.cursor;
  16484. _mfpOn(CLOSE_EVENT+'.'+AJAX_NS, _destroyAjaxRequest);
  16485. _mfpOn('BeforeChange.' + AJAX_NS, _destroyAjaxRequest);
  16486. },
  16487. getAjax: function(item) {
  16488. if(_ajaxCur) {
  16489. $(document.body).addClass(_ajaxCur);
  16490. }
  16491. mfp.updateStatus('loading');
  16492. var opts = $.extend({
  16493. url: item.src,
  16494. success: function(data, textStatus, jqXHR) {
  16495. var temp = {
  16496. data:data,
  16497. xhr:jqXHR
  16498. };
  16499. _mfpTrigger('ParseAjax', temp);
  16500. mfp.appendContent( $(temp.data), AJAX_NS );
  16501. item.finished = true;
  16502. _removeAjaxCursor();
  16503. mfp._setFocus();
  16504. setTimeout(function() {
  16505. mfp.wrap.addClass(READY_CLASS);
  16506. }, 16);
  16507. mfp.updateStatus('ready');
  16508. _mfpTrigger('AjaxContentAdded');
  16509. },
  16510. error: function() {
  16511. _removeAjaxCursor();
  16512. item.finished = item.loadError = true;
  16513. mfp.updateStatus('error', mfp.st.ajax.tError.replace('%url%', item.src));
  16514. }
  16515. }, mfp.st.ajax.settings);
  16516. mfp.req = $.ajax(opts);
  16517. return '';
  16518. }
  16519. }
  16520. });
  16521. /*>>ajax*/
  16522. /*>>image*/
  16523. var _imgInterval,
  16524. _getTitle = function(item) {
  16525. if(item.data && item.data.title !== undefined)
  16526. return item.data.title;
  16527. var src = mfp.st.image.titleSrc;
  16528. if(src) {
  16529. if(typeof src === "function") {
  16530. return src.call(mfp, item);
  16531. } else if(item.el) {
  16532. return item.el.attr(src) || '';
  16533. }
  16534. }
  16535. return '';
  16536. };
  16537. $.magnificPopup.registerModule('image', {
  16538. options: {
  16539. markup: '<div class="mfp-figure">'+
  16540. '<div class="mfp-close"></div>'+
  16541. '<figure>'+
  16542. '<div class="mfp-img"></div>'+
  16543. '<figcaption>'+
  16544. '<div class="mfp-bottom-bar">'+
  16545. '<div class="mfp-title"></div>'+
  16546. '<div class="mfp-counter"></div>'+
  16547. '</div>'+
  16548. '</figcaption>'+
  16549. '</figure>'+
  16550. '</div>',
  16551. cursor: 'mfp-zoom-out-cur',
  16552. titleSrc: 'title',
  16553. verticalFit: true,
  16554. tError: 'The image could not be loaded.'
  16555. },
  16556. proto: {
  16557. initImage: function() {
  16558. var imgSt = mfp.st.image,
  16559. ns = '.image';
  16560. mfp.types.push('image');
  16561. _mfpOn(OPEN_EVENT+ns, function() {
  16562. if(mfp.currItem.type === 'image' && imgSt.cursor) {
  16563. $(document.body).addClass(imgSt.cursor);
  16564. }
  16565. });
  16566. _mfpOn(CLOSE_EVENT+ns, function() {
  16567. if(imgSt.cursor) {
  16568. $(document.body).removeClass(imgSt.cursor);
  16569. }
  16570. _window.off('resize' + EVENT_NS);
  16571. });
  16572. _mfpOn('Resize'+ns, mfp.resizeImage);
  16573. if(mfp.isLowIE) {
  16574. _mfpOn('AfterChange', mfp.resizeImage);
  16575. }
  16576. },
  16577. resizeImage: function() {
  16578. var item = mfp.currItem;
  16579. if(!item || !item.img) return;
  16580. if(mfp.st.image.verticalFit) {
  16581. var decr = 0;
  16582. // fix box-sizing in ie7/8
  16583. if(mfp.isLowIE) {
  16584. decr = parseInt(item.img.css('padding-top'), 10) + parseInt(item.img.css('padding-bottom'),10);
  16585. }
  16586. item.img.css('max-height', mfp.wH-decr);
  16587. }
  16588. },
  16589. _onImageHasSize: function(item) {
  16590. if(item.img) {
  16591. item.hasSize = true;
  16592. if(_imgInterval) {
  16593. clearInterval(_imgInterval);
  16594. }
  16595. item.isCheckingImgSize = false;
  16596. _mfpTrigger('ImageHasSize', item);
  16597. if(item.imgHidden) {
  16598. if(mfp.content)
  16599. mfp.content.removeClass('mfp-loading');
  16600. item.imgHidden = false;
  16601. }
  16602. }
  16603. },
  16604. /**
  16605. * Function that loops until the image has size to display elements that rely on it asap
  16606. */
  16607. findImageSize: function(item) {
  16608. var counter = 0,
  16609. img = item.img[0],
  16610. mfpSetInterval = function(delay) {
  16611. if(_imgInterval) {
  16612. clearInterval(_imgInterval);
  16613. }
  16614. // decelerating interval that checks for size of an image
  16615. _imgInterval = setInterval(function() {
  16616. if(img.naturalWidth > 0) {
  16617. mfp._onImageHasSize(item);
  16618. return;
  16619. }
  16620. if(counter > 200) {
  16621. clearInterval(_imgInterval);
  16622. }
  16623. counter++;
  16624. if(counter === 3) {
  16625. mfpSetInterval(10);
  16626. } else if(counter === 40) {
  16627. mfpSetInterval(50);
  16628. } else if(counter === 100) {
  16629. mfpSetInterval(500);
  16630. }
  16631. }, delay);
  16632. };
  16633. mfpSetInterval(1);
  16634. },
  16635. getImage: function(item, template) {
  16636. var guard = 0,
  16637. imgSt = mfp.st.image,
  16638. // image error handler
  16639. onLoadError = function() {
  16640. if(item) {
  16641. item.img.off('.mfploader');
  16642. if(item === mfp.currItem){
  16643. mfp._onImageHasSize(item);
  16644. mfp.updateStatus('error', imgSt.tError.replace('%url%', item.src) );
  16645. }
  16646. item.hasSize = true;
  16647. item.loaded = true;
  16648. item.loadError = true;
  16649. }
  16650. },
  16651. // image load complete handler
  16652. onLoadComplete = function() {
  16653. if(item) {
  16654. if (item.img[0].complete) {
  16655. item.img.off('.mfploader');
  16656. if(item === mfp.currItem){
  16657. mfp._onImageHasSize(item);
  16658. mfp.updateStatus('ready');
  16659. }
  16660. item.hasSize = true;
  16661. item.loaded = true;
  16662. _mfpTrigger('ImageLoadComplete');
  16663. }
  16664. else {
  16665. // if image complete check fails 200 times (20 sec), we assume that there was an error.
  16666. guard++;
  16667. if(guard < 200) {
  16668. setTimeout(onLoadComplete,100);
  16669. } else {
  16670. onLoadError();
  16671. }
  16672. }
  16673. }
  16674. };
  16675. var el = template.find('.mfp-img');
  16676. if(el.length) {
  16677. var img = document.createElement('img');
  16678. img.className = 'mfp-img';
  16679. if(item.el && item.el.find('img').length) {
  16680. img.alt = item.el.find('img').attr('alt');
  16681. }
  16682. item.img = $(img).on('load.mfploader', onLoadComplete).on('error.mfploader', onLoadError);
  16683. img.src = item.src;
  16684. // without clone() "error" event is not firing when IMG is replaced by new IMG
  16685. // TODO: find a way to avoid such cloning
  16686. if(el.is('img')) {
  16687. item.img = item.img.clone();
  16688. }
  16689. img = item.img[0];
  16690. if(img.naturalWidth > 0) {
  16691. item.hasSize = true;
  16692. } else if(!img.width) {
  16693. item.hasSize = false;
  16694. }
  16695. }
  16696. mfp._parseMarkup(template, {
  16697. title: _getTitle(item),
  16698. img_replaceWith: item.img
  16699. }, item);
  16700. mfp.resizeImage();
  16701. if(item.hasSize) {
  16702. if(_imgInterval) clearInterval(_imgInterval);
  16703. if(item.loadError) {
  16704. template.addClass('mfp-loading');
  16705. mfp.updateStatus('error', imgSt.tError.replace('%url%', item.src) );
  16706. } else {
  16707. template.removeClass('mfp-loading');
  16708. mfp.updateStatus('ready');
  16709. }
  16710. return template;
  16711. }
  16712. mfp.updateStatus('loading');
  16713. item.loading = true;
  16714. if(!item.hasSize) {
  16715. item.imgHidden = true;
  16716. template.addClass('mfp-loading');
  16717. mfp.findImageSize(item);
  16718. }
  16719. return template;
  16720. }
  16721. }
  16722. });
  16723. /*>>image*/
  16724. /*>>zoom*/
  16725. var hasMozTransform,
  16726. getHasMozTransform = function() {
  16727. if(hasMozTransform === undefined) {
  16728. hasMozTransform = document.createElement('p').style.MozTransform !== undefined;
  16729. }
  16730. return hasMozTransform;
  16731. };
  16732. $.magnificPopup.registerModule('zoom', {
  16733. options: {
  16734. enabled: false,
  16735. easing: 'ease-in-out',
  16736. duration: 300,
  16737. opener: function(element) {
  16738. return element.is('img') ? element : element.find('img');
  16739. }
  16740. },
  16741. proto: {
  16742. initZoom: function() {
  16743. var zoomSt = mfp.st.zoom,
  16744. ns = '.zoom',
  16745. image;
  16746. if(!zoomSt.enabled || !mfp.supportsTransition) {
  16747. return;
  16748. }
  16749. var duration = zoomSt.duration,
  16750. getElToAnimate = function(image) {
  16751. var newImg = image.clone().removeAttr('style').removeAttr('class').addClass('mfp-animated-image'),
  16752. transition = 'all '+(zoomSt.duration/1000)+'s ' + zoomSt.easing,
  16753. cssObj = {
  16754. position: 'fixed',
  16755. zIndex: 9999,
  16756. left: 0,
  16757. top: 0,
  16758. '-webkit-backface-visibility': 'hidden'
  16759. },
  16760. t = 'transition';
  16761. cssObj['-webkit-'+t] = cssObj['-moz-'+t] = cssObj['-o-'+t] = cssObj[t] = transition;
  16762. newImg.css(cssObj);
  16763. return newImg;
  16764. },
  16765. showMainContent = function() {
  16766. mfp.content.css('visibility', 'visible');
  16767. },
  16768. openTimeout,
  16769. animatedImg;
  16770. _mfpOn('BuildControls'+ns, function() {
  16771. if(mfp._allowZoom()) {
  16772. clearTimeout(openTimeout);
  16773. mfp.content.css('visibility', 'hidden');
  16774. // Basically, all code below does is clones existing image, puts in on top of the current one and animated it
  16775. image = mfp._getItemToZoom();
  16776. if(!image) {
  16777. showMainContent();
  16778. return;
  16779. }
  16780. animatedImg = getElToAnimate(image);
  16781. animatedImg.css( mfp._getOffset() );
  16782. mfp.wrap.append(animatedImg);
  16783. openTimeout = setTimeout(function() {
  16784. animatedImg.css( mfp._getOffset( true ) );
  16785. openTimeout = setTimeout(function() {
  16786. showMainContent();
  16787. setTimeout(function() {
  16788. animatedImg.remove();
  16789. image = animatedImg = null;
  16790. _mfpTrigger('ZoomAnimationEnded');
  16791. }, 16); // avoid blink when switching images
  16792. }, duration); // this timeout equals animation duration
  16793. }, 16); // by adding this timeout we avoid short glitch at the beginning of animation
  16794. // Lots of timeouts...
  16795. }
  16796. });
  16797. _mfpOn(BEFORE_CLOSE_EVENT+ns, function() {
  16798. if(mfp._allowZoom()) {
  16799. clearTimeout(openTimeout);
  16800. mfp.st.removalDelay = duration;
  16801. if(!image) {
  16802. image = mfp._getItemToZoom();
  16803. if(!image) {
  16804. return;
  16805. }
  16806. animatedImg = getElToAnimate(image);
  16807. }
  16808. animatedImg.css( mfp._getOffset(true) );
  16809. mfp.wrap.append(animatedImg);
  16810. mfp.content.css('visibility', 'hidden');
  16811. setTimeout(function() {
  16812. animatedImg.css( mfp._getOffset() );
  16813. }, 16);
  16814. }
  16815. });
  16816. _mfpOn(CLOSE_EVENT+ns, function() {
  16817. if(mfp._allowZoom()) {
  16818. showMainContent();
  16819. if(animatedImg) {
  16820. animatedImg.remove();
  16821. }
  16822. image = null;
  16823. }
  16824. });
  16825. },
  16826. _allowZoom: function() {
  16827. return mfp.currItem.type === 'image';
  16828. },
  16829. _getItemToZoom: function() {
  16830. if(mfp.currItem.hasSize) {
  16831. return mfp.currItem.img;
  16832. } else {
  16833. return false;
  16834. }
  16835. },
  16836. // Get element postion relative to viewport
  16837. _getOffset: function(isLarge) {
  16838. var el;
  16839. if(isLarge) {
  16840. el = mfp.currItem.img;
  16841. } else {
  16842. el = mfp.st.zoom.opener(mfp.currItem.el || mfp.currItem);
  16843. }
  16844. var offset = el.offset();
  16845. var paddingTop = parseInt(el.css('padding-top'),10);
  16846. var paddingBottom = parseInt(el.css('padding-bottom'),10);
  16847. offset.top -= ( $(window).scrollTop() - paddingTop );
  16848. /*
  16849. Animating left + top + width/height looks glitchy in Firefox, but perfect in Chrome. And vice-versa.
  16850. */
  16851. var obj = {
  16852. width: el.width(),
  16853. // fix Zepto height+padding issue
  16854. height: (_isJQ ? el.innerHeight() : el[0].offsetHeight) - paddingBottom - paddingTop
  16855. };
  16856. // I hate to do this, but there is no another option
  16857. if( getHasMozTransform() ) {
  16858. obj['-moz-transform'] = obj['transform'] = 'translate(' + offset.left + 'px,' + offset.top + 'px)';
  16859. } else {
  16860. obj.left = offset.left;
  16861. obj.top = offset.top;
  16862. }
  16863. return obj;
  16864. }
  16865. }
  16866. });
  16867. /*>>zoom*/
  16868. /*>>iframe*/
  16869. var IFRAME_NS = 'iframe',
  16870. _emptyPage = '//about:blank',
  16871. _fixIframeBugs = function(isShowing) {
  16872. if(mfp.currTemplate[IFRAME_NS]) {
  16873. var el = mfp.currTemplate[IFRAME_NS].find('iframe');
  16874. if(el.length) {
  16875. // reset src after the popup is closed to avoid "video keeps playing after popup is closed" bug
  16876. if(!isShowing) {
  16877. el[0].src = _emptyPage;
  16878. }
  16879. // IE8 black screen bug fix
  16880. if(mfp.isIE8) {
  16881. el.css('display', isShowing ? 'block' : 'none');
  16882. }
  16883. }
  16884. }
  16885. };
  16886. $.magnificPopup.registerModule(IFRAME_NS, {
  16887. options: {
  16888. markup: '<div class="mfp-iframe-scaler">'+
  16889. '<div class="mfp-close"></div>'+
  16890. '<iframe class="mfp-iframe" src="//about:blank" frameborder="0" allowfullscreen></iframe>'+
  16891. '</div>',
  16892. srcAction: 'iframe_src',
  16893. // we don't care and support only one default type of URL by default
  16894. patterns: {
  16895. youtube: {
  16896. index: 'youtube.com',
  16897. id: 'v=',
  16898. src: '//www.youtube.com/embed/%id%?autoplay=1'
  16899. },
  16900. vimeo: {
  16901. index: 'vimeo.com/',
  16902. id: '/',
  16903. src: '//player.vimeo.com/video/%id%?autoplay=1'
  16904. },
  16905. gmaps: {
  16906. index: '//maps.google.',
  16907. src: '%id%&output=embed'
  16908. }
  16909. }
  16910. },
  16911. proto: {
  16912. initIframe: function() {
  16913. mfp.types.push(IFRAME_NS);
  16914. _mfpOn('BeforeChange', function(e, prevType, newType) {
  16915. if(prevType !== newType) {
  16916. if(prevType === IFRAME_NS) {
  16917. _fixIframeBugs(); // iframe if removed
  16918. } else if(newType === IFRAME_NS) {
  16919. _fixIframeBugs(true); // iframe is showing
  16920. }
  16921. }// else {
  16922. // iframe source is switched, don't do anything
  16923. //}
  16924. });
  16925. _mfpOn(CLOSE_EVENT + '.' + IFRAME_NS, function() {
  16926. _fixIframeBugs();
  16927. });
  16928. },
  16929. getIframe: function(item, template) {
  16930. var embedSrc = item.src;
  16931. var iframeSt = mfp.st.iframe;
  16932. $.each(iframeSt.patterns, function() {
  16933. if(embedSrc.indexOf( this.index ) > -1) {
  16934. if(this.id) {
  16935. if(typeof this.id === 'string') {
  16936. embedSrc = embedSrc.substr(embedSrc.lastIndexOf(this.id)+this.id.length, embedSrc.length);
  16937. } else {
  16938. embedSrc = this.id.call( this, embedSrc );
  16939. }
  16940. }
  16941. embedSrc = this.src.replace('%id%', embedSrc );
  16942. return false; // break;
  16943. }
  16944. });
  16945. var dataObj = {};
  16946. if(iframeSt.srcAction) {
  16947. dataObj[iframeSt.srcAction] = embedSrc;
  16948. }
  16949. mfp._parseMarkup(template, dataObj, item);
  16950. mfp.updateStatus('ready');
  16951. return template;
  16952. }
  16953. }
  16954. });
  16955. /*>>iframe*/
  16956. /*>>gallery*/
  16957. /**
  16958. * Get looped index depending on number of slides
  16959. */
  16960. var _getLoopedId = function(index) {
  16961. var numSlides = mfp.items.length;
  16962. if(index > numSlides - 1) {
  16963. return index - numSlides;
  16964. } else if(index < 0) {
  16965. return numSlides + index;
  16966. }
  16967. return index;
  16968. },
  16969. _replaceCurrTotal = function(text, curr, total) {
  16970. return text.replace(/%curr%/gi, curr + 1).replace(/%total%/gi, total);
  16971. };
  16972. $.magnificPopup.registerModule('gallery', {
  16973. options: {
  16974. enabled: false,
  16975. arrowMarkup: '<button title="%title%" type="button" class="mfp-arrow mfp-arrow-%dir%"></button>',
  16976. preload: [0,2],
  16977. navigateByImgClick: true,
  16978. arrows: true,
  16979. tPrev: 'Previous (Left arrow key)',
  16980. tNext: 'Next (Right arrow key)',
  16981. tCounter: '%curr% of %total%',
  16982. langDir: null,
  16983. loop: true,
  16984. },
  16985. proto: {
  16986. initGallery: function() {
  16987. var gSt = mfp.st.gallery,
  16988. ns = '.mfp-gallery';
  16989. mfp.direction = true; // true - next, false - prev
  16990. if(!gSt || !gSt.enabled ) return false;
  16991. if (!gSt.langDir) {
  16992. gSt.langDir = document.dir || 'ltr';
  16993. }
  16994. _wrapClasses += ' mfp-gallery';
  16995. _mfpOn(OPEN_EVENT+ns, function() {
  16996. if(gSt.navigateByImgClick) {
  16997. mfp.wrap.on('click'+ns, '.mfp-img', function() {
  16998. if(mfp.items.length > 1) {
  16999. mfp.next();
  17000. return false;
  17001. }
  17002. });
  17003. }
  17004. _document.on('keydown'+ns, function(e) {
  17005. if (e.keyCode === 37) {
  17006. if (gSt.langDir === 'rtl') mfp.next();
  17007. else mfp.prev();
  17008. } else if (e.keyCode === 39) {
  17009. if (gSt.langDir === 'rtl') mfp.prev();
  17010. else mfp.next();
  17011. }
  17012. });
  17013. mfp.updateGalleryButtons();
  17014. });
  17015. _mfpOn('UpdateStatus'+ns, function(/*e, data*/) {
  17016. mfp.updateGalleryButtons();
  17017. });
  17018. _mfpOn('UpdateStatus'+ns, function(e, data) {
  17019. if(data.text) {
  17020. data.text = _replaceCurrTotal(data.text, mfp.currItem.index, mfp.items.length);
  17021. }
  17022. });
  17023. _mfpOn(MARKUP_PARSE_EVENT+ns, function(e, element, values, item) {
  17024. var l = mfp.items.length;
  17025. values.counter = l > 1 ? _replaceCurrTotal(gSt.tCounter, item.index, l) : '';
  17026. });
  17027. _mfpOn('BuildControls' + ns, function() {
  17028. if(mfp.items.length > 1 && gSt.arrows && !mfp.arrowLeft) {
  17029. var arrowLeftDesc, arrowRightDesc, arrowLeftAction, arrowRightAction;
  17030. if (gSt.langDir === 'rtl') {
  17031. arrowLeftDesc = gSt.tNext;
  17032. arrowRightDesc = gSt.tPrev;
  17033. arrowLeftAction = 'next';
  17034. arrowRightAction = 'prev';
  17035. } else {
  17036. arrowLeftDesc = gSt.tPrev;
  17037. arrowRightDesc = gSt.tNext;
  17038. arrowLeftAction = 'prev';
  17039. arrowRightAction = 'next';
  17040. }
  17041. var markup = gSt.arrowMarkup,
  17042. arrowLeft = mfp.arrowLeft = $( markup.replace(/%title%/gi, arrowLeftDesc).replace(/%action%/gi, arrowLeftAction).replace(/%dir%/gi, 'left') ).addClass(PREVENT_CLOSE_CLASS),
  17043. arrowRight = mfp.arrowRight = $( markup.replace(/%title%/gi, arrowRightDesc).replace(/%action%/gi, arrowRightAction).replace(/%dir%/gi, 'right') ).addClass(PREVENT_CLOSE_CLASS);
  17044. if (gSt.langDir === 'rtl') {
  17045. mfp.arrowNext = arrowLeft;
  17046. mfp.arrowPrev = arrowRight;
  17047. } else {
  17048. mfp.arrowNext = arrowRight;
  17049. mfp.arrowPrev = arrowLeft;
  17050. }
  17051. arrowLeft.on('click', function() {
  17052. if (gSt.langDir === 'rtl') mfp.next();
  17053. else mfp.prev();
  17054. });
  17055. arrowRight.on('click', function() {
  17056. if (gSt.langDir === 'rtl') mfp.prev();
  17057. else mfp.next();
  17058. });
  17059. mfp.container.append(arrowLeft.add(arrowRight));
  17060. }
  17061. });
  17062. _mfpOn(CHANGE_EVENT+ns, function() {
  17063. if(mfp._preloadTimeout) clearTimeout(mfp._preloadTimeout);
  17064. mfp._preloadTimeout = setTimeout(function() {
  17065. mfp.preloadNearbyImages();
  17066. mfp._preloadTimeout = null;
  17067. }, 16);
  17068. });
  17069. _mfpOn(CLOSE_EVENT+ns, function() {
  17070. _document.off(ns);
  17071. mfp.wrap.off('click'+ns);
  17072. mfp.arrowRight = mfp.arrowLeft = null;
  17073. });
  17074. },
  17075. next: function() {
  17076. var newIndex = _getLoopedId(mfp.index + 1);
  17077. if (!mfp.st.gallery.loop && newIndex === 0 ) return false;
  17078. mfp.direction = true;
  17079. mfp.index = newIndex;
  17080. mfp.updateItemHTML();
  17081. },
  17082. prev: function() {
  17083. var newIndex = mfp.index - 1;
  17084. if (!mfp.st.gallery.loop && newIndex < 0) return false;
  17085. mfp.direction = false;
  17086. mfp.index = _getLoopedId(newIndex);
  17087. mfp.updateItemHTML();
  17088. },
  17089. goTo: function(newIndex) {
  17090. mfp.direction = (newIndex >= mfp.index);
  17091. mfp.index = newIndex;
  17092. mfp.updateItemHTML();
  17093. },
  17094. preloadNearbyImages: function() {
  17095. var p = mfp.st.gallery.preload,
  17096. preloadBefore = Math.min(p[0], mfp.items.length),
  17097. preloadAfter = Math.min(p[1], mfp.items.length),
  17098. i;
  17099. for(i = 1; i <= (mfp.direction ? preloadAfter : preloadBefore); i++) {
  17100. mfp._preloadItem(mfp.index+i);
  17101. }
  17102. for(i = 1; i <= (mfp.direction ? preloadBefore : preloadAfter); i++) {
  17103. mfp._preloadItem(mfp.index-i);
  17104. }
  17105. },
  17106. _preloadItem: function(index) {
  17107. index = _getLoopedId(index);
  17108. if(mfp.items[index].preloaded) {
  17109. return;
  17110. }
  17111. var item = mfp.items[index];
  17112. if(!item.parsed) {
  17113. item = mfp.parseEl( index );
  17114. }
  17115. _mfpTrigger('LazyLoad', item);
  17116. if(item.type === 'image') {
  17117. item.img = $('<img class="mfp-img" />').on('load.mfploader', function() {
  17118. item.hasSize = true;
  17119. }).on('error.mfploader', function() {
  17120. item.hasSize = true;
  17121. item.loadError = true;
  17122. _mfpTrigger('LazyLoadError', item);
  17123. }).attr('src', item.src);
  17124. }
  17125. item.preloaded = true;
  17126. },
  17127. /**
  17128. * Show/hide the gallery prev/next buttons if we're at the start/end, if looping is turned off
  17129. * Added by Joloco for Veg
  17130. */
  17131. updateGalleryButtons: function() {
  17132. if ( !mfp.st.gallery.loop && typeof mfp.arrowPrev === 'object' && mfp.arrowPrev !== null) {
  17133. if (mfp.index === 0) mfp.arrowPrev.hide();
  17134. else mfp.arrowPrev.show();
  17135. if (mfp.index === (mfp.items.length - 1)) mfp.arrowNext.hide();
  17136. else mfp.arrowNext.show();
  17137. }
  17138. },
  17139. }
  17140. });
  17141. /*>>gallery*/
  17142. /*>>retina*/
  17143. var RETINA_NS = 'retina';
  17144. $.magnificPopup.registerModule(RETINA_NS, {
  17145. options: {
  17146. replaceSrc: function(item) {
  17147. return item.src.replace(/\.\w+$/, function(m) { return '@2x' + m; });
  17148. },
  17149. ratio: 1 // Function or number. Set to 1 to disable.
  17150. },
  17151. proto: {
  17152. initRetina: function() {
  17153. if(window.devicePixelRatio > 1) {
  17154. var st = mfp.st.retina,
  17155. ratio = st.ratio;
  17156. ratio = !isNaN(ratio) ? ratio : ratio();
  17157. if(ratio > 1) {
  17158. _mfpOn('ImageHasSize' + '.' + RETINA_NS, function(e, item) {
  17159. item.img.css({
  17160. 'max-width': item.img[0].naturalWidth / ratio,
  17161. 'width': '100%'
  17162. });
  17163. });
  17164. _mfpOn('ElementParse' + '.' + RETINA_NS, function(e, item) {
  17165. item.src = st.replaceSrc(item, ratio);
  17166. });
  17167. }
  17168. }
  17169. }
  17170. }
  17171. });
  17172. /*>>retina*/
  17173. _checkInstance(); }));
  17174. /*!
  17175. Custom scrollbar
  17176. Version: 3.1.13
  17177. Plugin URI: http://manos.malihu.gr/jquery-custom-content-scroller
  17178. License: Copyright Manos Malihutsakis | Released under the MIT license
  17179. !*/
  17180. !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)}})});
  17181. /*!
  17182. Custom scrollbar
  17183. Version: 3.1.5
  17184. Plugin URI: http://manos.malihu.gr/jquery-custom-content-scroller
  17185. License: Copyright Manos Malihutsakis | Released under the MIT license
  17186. !*/
  17187. !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(){
  17188. 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]}})})})});
  17189. /*!
  17190. Justified Gallery
  17191. Version: 3.8.1
  17192. Plugin URL: http://miromannino.github.io/Justified-Gallery/
  17193. License: Copyright (c) 2020 Miro Mannino | Released under the MIT License
  17194. !*/
  17195. (function (factory) {
  17196. if (typeof define === 'function' && define.amd) {
  17197. // AMD. Register as an anonymous module.
  17198. define(['jquery'], factory);
  17199. } else if (typeof module === 'object' && module.exports) {
  17200. // Node/CommonJS
  17201. module.exports = function (root, jQuery) {
  17202. if (jQuery === undefined) {
  17203. // require('jQuery') returns a factory that requires window to
  17204. // build a jQuery instance, we normalize how we use modules
  17205. // that require this pattern but the window provided is a noop
  17206. // if it's defined (how jquery works)
  17207. if (typeof window !== 'undefined') {
  17208. jQuery = require('jquery');
  17209. }
  17210. else {
  17211. jQuery = require('jquery')(root);
  17212. }
  17213. }
  17214. factory(jQuery);
  17215. return jQuery;
  17216. };
  17217. } else {
  17218. // Browser globals
  17219. factory(jQuery);
  17220. }
  17221. }(function ($) {
  17222. /**
  17223. * Justified Gallery controller constructor
  17224. *
  17225. * @param $gallery the gallery to build
  17226. * @param settings the settings (the defaults are in JustifiedGallery.defaults)
  17227. * @constructor
  17228. */
  17229. var JustifiedGallery = function ($gallery, settings) {
  17230. this.settings = settings;
  17231. this.checkSettings();
  17232. this.imgAnalyzerTimeout = null;
  17233. this.entries = null;
  17234. this.buildingRow = {
  17235. entriesBuff: [],
  17236. width: 0,
  17237. height: 0,
  17238. aspectRatio: 0
  17239. };
  17240. this.lastFetchedEntry = null;
  17241. this.lastAnalyzedIndex = -1;
  17242. this.yield = {
  17243. every: 2, // do a flush every n flushes (must be greater than 1)
  17244. flushed: 0 // flushed rows without a yield
  17245. };
  17246. this.border = settings.border >= 0 ? settings.border : settings.margins;
  17247. this.maxRowHeight = this.retrieveMaxRowHeight();
  17248. this.suffixRanges = this.retrieveSuffixRanges();
  17249. this.offY = this.border;
  17250. this.rows = 0;
  17251. this.spinner = {
  17252. phase: 0,
  17253. timeSlot: 150,
  17254. $el: $('<div class="jg-spinner"><span></span><span></span><span></span></div>'),
  17255. intervalId: null
  17256. };
  17257. this.scrollBarOn = false;
  17258. this.checkWidthIntervalId = null;
  17259. this.galleryWidth = $gallery.width();
  17260. this.$gallery = $gallery;
  17261. };
  17262. /** @returns {String} the best suffix given the width and the height */
  17263. JustifiedGallery.prototype.getSuffix = function (width, height) {
  17264. var longestSide, i;
  17265. longestSide = (width > height) ? width : height;
  17266. for (i = 0; i < this.suffixRanges.length; i++) {
  17267. if (longestSide <= this.suffixRanges[i]) {
  17268. return this.settings.sizeRangeSuffixes[this.suffixRanges[i]];
  17269. }
  17270. }
  17271. return this.settings.sizeRangeSuffixes[this.suffixRanges[i - 1]];
  17272. };
  17273. /**
  17274. * Remove the suffix from the string
  17275. *
  17276. * @returns {string} a new string without the suffix
  17277. */
  17278. JustifiedGallery.prototype.removeSuffix = function (str, suffix) {
  17279. return str.substring(0, str.length - suffix.length);
  17280. };
  17281. /**
  17282. * @returns {boolean} a boolean to say if the suffix is contained in the str or not
  17283. */
  17284. JustifiedGallery.prototype.endsWith = function (str, suffix) {
  17285. return str.indexOf(suffix, str.length - suffix.length) !== -1;
  17286. };
  17287. /**
  17288. * Get the used suffix of a particular url
  17289. *
  17290. * @param str
  17291. * @returns {String} return the used suffix
  17292. */
  17293. JustifiedGallery.prototype.getUsedSuffix = function (str) {
  17294. for (var si in this.settings.sizeRangeSuffixes) {
  17295. if (this.settings.sizeRangeSuffixes.hasOwnProperty(si)) {
  17296. if (this.settings.sizeRangeSuffixes[si].length === 0) continue;
  17297. if (this.endsWith(str, this.settings.sizeRangeSuffixes[si])) return this.settings.sizeRangeSuffixes[si];
  17298. }
  17299. }
  17300. return '';
  17301. };
  17302. /**
  17303. * Given an image src, with the width and the height, returns the new image src with the
  17304. * best suffix to show the best quality thumbnail.
  17305. *
  17306. * @returns {String} the suffix to use
  17307. */
  17308. JustifiedGallery.prototype.newSrc = function (imageSrc, imgWidth, imgHeight, image) {
  17309. var newImageSrc;
  17310. if (this.settings.thumbnailPath) {
  17311. newImageSrc = this.settings.thumbnailPath(imageSrc, imgWidth, imgHeight, image);
  17312. } else {
  17313. var matchRes = imageSrc.match(this.settings.extension);
  17314. var ext = (matchRes !== null) ? matchRes[0] : '';
  17315. newImageSrc = imageSrc.replace(this.settings.extension, '');
  17316. newImageSrc = this.removeSuffix(newImageSrc, this.getUsedSuffix(newImageSrc));
  17317. newImageSrc += this.getSuffix(imgWidth, imgHeight) + ext;
  17318. }
  17319. return newImageSrc;
  17320. };
  17321. /**
  17322. * Shows the images that is in the given entry
  17323. *
  17324. * @param $entry the entry
  17325. * @param callback the callback that is called when the show animation is finished
  17326. */
  17327. JustifiedGallery.prototype.showImg = function ($entry, callback) {
  17328. if (this.settings.cssAnimation) {
  17329. $entry.addClass('jg-entry-visible');
  17330. if (callback) callback();
  17331. } else {
  17332. $entry.stop().fadeTo(this.settings.imagesAnimationDuration, 1.0, callback);
  17333. $entry.find(this.settings.imgSelector).stop().fadeTo(this.settings.imagesAnimationDuration, 1.0, callback);
  17334. }
  17335. };
  17336. /**
  17337. * Extract the image src form the image, looking from the 'safe-src', and if it can't be found, from the
  17338. * 'src' attribute. It saves in the image data the 'jg.originalSrc' field, with the extracted src.
  17339. *
  17340. * @param $image the image to analyze
  17341. * @returns {String} the extracted src
  17342. */
  17343. JustifiedGallery.prototype.extractImgSrcFromImage = function ($image) {
  17344. var imageSrc = $image.data('safe-src');
  17345. var imageSrcLoc = 'data-safe-src';
  17346. if (typeof imageSrc === 'undefined') {
  17347. imageSrc = $image.attr('src');
  17348. imageSrcLoc = 'src';
  17349. }
  17350. $image.data('jg.originalSrc', imageSrc); // this is saved for the destroy method
  17351. $image.data('jg.src', imageSrc); // this will change overtime
  17352. $image.data('jg.originalSrcLoc', imageSrcLoc); // this is saved for the destroy method
  17353. return imageSrc;
  17354. };
  17355. /** @returns {jQuery} the image in the given entry */
  17356. JustifiedGallery.prototype.imgFromEntry = function ($entry) {
  17357. var $img = $entry.find(this.settings.imgSelector);
  17358. return $img.length === 0 ? null : $img;
  17359. };
  17360. /** @returns {jQuery} the caption in the given entry */
  17361. JustifiedGallery.prototype.captionFromEntry = function ($entry) {
  17362. var $caption = $entry.find('> .jg-caption');
  17363. return $caption.length === 0 ? null : $caption;
  17364. };
  17365. /**
  17366. * Display the entry
  17367. *
  17368. * @param {jQuery} $entry the entry to display
  17369. * @param {int} x the x position where the entry must be positioned
  17370. * @param y the y position where the entry must be positioned
  17371. * @param imgWidth the image width
  17372. * @param imgHeight the image height
  17373. * @param rowHeight the row height of the row that owns the entry
  17374. */
  17375. JustifiedGallery.prototype.displayEntry = function ($entry, x, y, imgWidth, imgHeight, rowHeight) {
  17376. $entry.width(imgWidth);
  17377. $entry.height(rowHeight);
  17378. $entry.css('top', y);
  17379. $entry.css('left', x);
  17380. var $image = this.imgFromEntry($entry);
  17381. if ($image !== null) {
  17382. $image.css('width', imgWidth);
  17383. $image.css('height', imgHeight);
  17384. $image.css('margin-left', - imgWidth / 2);
  17385. $image.css('margin-top', - imgHeight / 2);
  17386. // Image reloading for an high quality of thumbnails
  17387. var imageSrc = $image.data('jg.src');
  17388. if (imageSrc) {
  17389. imageSrc = this.newSrc(imageSrc, imgWidth, imgHeight, $image[0]);
  17390. $image.one('error', function () {
  17391. this.resetImgSrc($image); //revert to the original thumbnail
  17392. });
  17393. var loadNewImage = function () {
  17394. // if (imageSrc !== newImageSrc) {
  17395. $image.attr('src', imageSrc);
  17396. // }
  17397. };
  17398. if ($entry.data('jg.loaded') === 'skipped' && imageSrc) {
  17399. this.onImageEvent(imageSrc, (function() {
  17400. this.showImg($entry, loadNewImage); //load the new image after the fadeIn
  17401. $entry.data('jg.loaded', true);
  17402. }).bind(this));
  17403. } else {
  17404. this.showImg($entry, loadNewImage); //load the new image after the fadeIn
  17405. }
  17406. }
  17407. } else {
  17408. this.showImg($entry);
  17409. }
  17410. this.displayEntryCaption($entry);
  17411. };
  17412. /**
  17413. * Display the entry caption. If the caption element doesn't exists, it creates the caption using the 'alt'
  17414. * or the 'title' attributes.
  17415. *
  17416. * @param {jQuery} $entry the entry to process
  17417. */
  17418. JustifiedGallery.prototype.displayEntryCaption = function ($entry) {
  17419. var $image = this.imgFromEntry($entry);
  17420. if ($image !== null && this.settings.captions) {
  17421. var $imgCaption = this.captionFromEntry($entry);
  17422. // Create it if it doesn't exists
  17423. if ($imgCaption === null) {
  17424. var caption = $image.attr('alt');
  17425. if (!this.isValidCaption(caption)) caption = $entry.attr('title');
  17426. if (this.isValidCaption(caption)) { // Create only we found something
  17427. $imgCaption = $('<div class="jg-caption">' + caption + '</div>');
  17428. $entry.append($imgCaption);
  17429. $entry.data('jg.createdCaption', true);
  17430. }
  17431. }
  17432. // Create events (we check again the $imgCaption because it can be still inexistent)
  17433. if ($imgCaption !== null) {
  17434. if (!this.settings.cssAnimation) $imgCaption.stop().fadeTo(0, this.settings.captionSettings.nonVisibleOpacity);
  17435. this.addCaptionEventsHandlers($entry);
  17436. }
  17437. } else {
  17438. this.removeCaptionEventsHandlers($entry);
  17439. }
  17440. };
  17441. /**
  17442. * Validates the caption
  17443. *
  17444. * @param caption The caption that should be validated
  17445. * @return {boolean} Validation result
  17446. */
  17447. JustifiedGallery.prototype.isValidCaption = function (caption) {
  17448. return (typeof caption !== 'undefined' && caption.length > 0);
  17449. };
  17450. /**
  17451. * The callback for the event 'mouseenter'. It assumes that the event currentTarget is an entry.
  17452. * It shows the caption using jQuery (or using CSS if it is configured so)
  17453. *
  17454. * @param {Event} eventObject the event object
  17455. */
  17456. JustifiedGallery.prototype.onEntryMouseEnterForCaption = function (eventObject) {
  17457. var $caption = this.captionFromEntry($(eventObject.currentTarget));
  17458. if (this.settings.cssAnimation) {
  17459. $caption.addClass('jg-caption-visible').removeClass('jg-caption-hidden');
  17460. } else {
  17461. $caption.stop().fadeTo(this.settings.captionSettings.animationDuration,
  17462. this.settings.captionSettings.visibleOpacity);
  17463. }
  17464. };
  17465. /**
  17466. * The callback for the event 'mouseleave'. It assumes that the event currentTarget is an entry.
  17467. * It hides the caption using jQuery (or using CSS if it is configured so)
  17468. *
  17469. * @param {Event} eventObject the event object
  17470. */
  17471. JustifiedGallery.prototype.onEntryMouseLeaveForCaption = function (eventObject) {
  17472. var $caption = this.captionFromEntry($(eventObject.currentTarget));
  17473. if (this.settings.cssAnimation) {
  17474. $caption.removeClass('jg-caption-visible').removeClass('jg-caption-hidden');
  17475. } else {
  17476. $caption.stop().fadeTo(this.settings.captionSettings.animationDuration,
  17477. this.settings.captionSettings.nonVisibleOpacity);
  17478. }
  17479. };
  17480. /**
  17481. * Add the handlers of the entry for the caption
  17482. *
  17483. * @param $entry the entry to modify
  17484. */
  17485. JustifiedGallery.prototype.addCaptionEventsHandlers = function ($entry) {
  17486. var captionMouseEvents = $entry.data('jg.captionMouseEvents');
  17487. if (typeof captionMouseEvents === 'undefined') {
  17488. captionMouseEvents = {
  17489. mouseenter: $.proxy(this.onEntryMouseEnterForCaption, this),
  17490. mouseleave: $.proxy(this.onEntryMouseLeaveForCaption, this)
  17491. };
  17492. $entry.on('mouseenter', undefined, undefined, captionMouseEvents.mouseenter);
  17493. $entry.on('mouseleave', undefined, undefined, captionMouseEvents.mouseleave);
  17494. $entry.data('jg.captionMouseEvents', captionMouseEvents);
  17495. }
  17496. };
  17497. /**
  17498. * Remove the handlers of the entry for the caption
  17499. *
  17500. * @param $entry the entry to modify
  17501. */
  17502. JustifiedGallery.prototype.removeCaptionEventsHandlers = function ($entry) {
  17503. var captionMouseEvents = $entry.data('jg.captionMouseEvents');
  17504. if (typeof captionMouseEvents !== 'undefined') {
  17505. $entry.off('mouseenter', undefined, captionMouseEvents.mouseenter);
  17506. $entry.off('mouseleave', undefined, captionMouseEvents.mouseleave);
  17507. $entry.removeData('jg.captionMouseEvents');
  17508. }
  17509. };
  17510. /**
  17511. * Clear the building row data to be used for a new row
  17512. */
  17513. JustifiedGallery.prototype.clearBuildingRow = function () {
  17514. this.buildingRow.entriesBuff = [];
  17515. this.buildingRow.aspectRatio = 0;
  17516. this.buildingRow.width = 0;
  17517. };
  17518. /**
  17519. * Justify the building row, preparing it to
  17520. *
  17521. * @param isLastRow
  17522. * @param hiddenRow undefined or false for normal behavior. hiddenRow = true to hide the row.
  17523. * @returns a boolean to know if the row has been justified or not
  17524. */
  17525. JustifiedGallery.prototype.prepareBuildingRow = function (isLastRow, hiddenRow) {
  17526. var i, $entry, imgAspectRatio, newImgW, newImgH, justify = true;
  17527. var minHeight = 0;
  17528. var availableWidth = this.galleryWidth - 2 * this.border - (
  17529. (this.buildingRow.entriesBuff.length - 1) * this.settings.margins);
  17530. var rowHeight = availableWidth / this.buildingRow.aspectRatio;
  17531. var defaultRowHeight = this.settings.rowHeight;
  17532. var justifiable = this.buildingRow.width / availableWidth > this.settings.justifyThreshold;
  17533. //Skip the last row if we can't justify it and the lastRow == 'hide'
  17534. if (hiddenRow || (isLastRow && this.settings.lastRow === 'hide' && !justifiable)) {
  17535. for (i = 0; i < this.buildingRow.entriesBuff.length; i++) {
  17536. $entry = this.buildingRow.entriesBuff[i];
  17537. if (this.settings.cssAnimation)
  17538. $entry.removeClass('jg-entry-visible');
  17539. else {
  17540. $entry.stop().fadeTo(0, 0.1);
  17541. $entry.find('> img, > a > img').fadeTo(0, 0);
  17542. }
  17543. }
  17544. return -1;
  17545. }
  17546. // With lastRow = nojustify, justify if is justificable (the images will not become too big)
  17547. if (isLastRow && !justifiable && this.settings.lastRow !== 'justify' && this.settings.lastRow !== 'hide') {
  17548. justify = false;
  17549. if (this.rows > 0) {
  17550. defaultRowHeight = (this.offY - this.border - this.settings.margins * this.rows) / this.rows;
  17551. justify = defaultRowHeight * this.buildingRow.aspectRatio / availableWidth > this.settings.justifyThreshold;
  17552. }
  17553. }
  17554. for (i = 0; i < this.buildingRow.entriesBuff.length; i++) {
  17555. $entry = this.buildingRow.entriesBuff[i];
  17556. imgAspectRatio = $entry.data('jg.width') / $entry.data('jg.height');
  17557. if (justify) {
  17558. newImgW = (i === this.buildingRow.entriesBuff.length - 1) ? availableWidth : rowHeight * imgAspectRatio;
  17559. newImgH = rowHeight;
  17560. } else {
  17561. newImgW = defaultRowHeight * imgAspectRatio;
  17562. newImgH = defaultRowHeight;
  17563. }
  17564. availableWidth -= Math.round(newImgW);
  17565. $entry.data('jg.jwidth', Math.round(newImgW));
  17566. $entry.data('jg.jheight', Math.ceil(newImgH));
  17567. if (i === 0 || minHeight > newImgH) minHeight = newImgH;
  17568. }
  17569. this.buildingRow.height = minHeight;
  17570. return justify;
  17571. };
  17572. /**
  17573. * Flush a row: justify it, modify the gallery height accordingly to the row height
  17574. *
  17575. * @param isLastRow
  17576. * @param hiddenRow undefined or false for normal behavior. hiddenRow = true to hide the row.
  17577. */
  17578. JustifiedGallery.prototype.flushRow = function (isLastRow, hiddenRow) {
  17579. var settings = this.settings;
  17580. var $entry, buildingRowRes, offX = this.border, i;
  17581. buildingRowRes = this.prepareBuildingRow(isLastRow, hiddenRow);
  17582. if (hiddenRow || (isLastRow && settings.lastRow === 'hide' && buildingRowRes === -1)) {
  17583. this.clearBuildingRow();
  17584. return;
  17585. }
  17586. if (this.maxRowHeight) {
  17587. if (this.maxRowHeight < this.buildingRow.height) this.buildingRow.height = this.maxRowHeight;
  17588. }
  17589. //Align last (unjustified) row
  17590. if (isLastRow && (settings.lastRow === 'center' || settings.lastRow === 'right')) {
  17591. var availableWidth = this.galleryWidth - 2 * this.border - (this.buildingRow.entriesBuff.length - 1) * settings.margins;
  17592. for (i = 0; i < this.buildingRow.entriesBuff.length; i++) {
  17593. $entry = this.buildingRow.entriesBuff[i];
  17594. availableWidth -= $entry.data('jg.jwidth');
  17595. }
  17596. if (settings.lastRow === 'center')
  17597. offX += Math.round(availableWidth / 2);
  17598. else if (settings.lastRow === 'right')
  17599. offX += availableWidth;
  17600. }
  17601. var lastEntryIdx = this.buildingRow.entriesBuff.length - 1;
  17602. for (i = 0; i <= lastEntryIdx; i++) {
  17603. $entry = this.buildingRow.entriesBuff[this.settings.rtl ? lastEntryIdx - i : i];
  17604. this.displayEntry($entry, offX, this.offY, $entry.data('jg.jwidth'), $entry.data('jg.jheight'), this.buildingRow.height);
  17605. offX += $entry.data('jg.jwidth') + settings.margins;
  17606. }
  17607. //Gallery Height
  17608. this.galleryHeightToSet = this.offY + this.buildingRow.height + this.border;
  17609. this.setGalleryTempHeight(this.galleryHeightToSet + this.getSpinnerHeight());
  17610. if (!isLastRow || (this.buildingRow.height <= settings.rowHeight && buildingRowRes)) {
  17611. //Ready for a new row
  17612. this.offY += this.buildingRow.height + settings.margins;
  17613. this.rows += 1;
  17614. this.clearBuildingRow();
  17615. this.settings.triggerEvent.call(this, 'jg.rowflush');
  17616. }
  17617. };
  17618. // Scroll position not restoring: https://github.com/miromannino/Justified-Gallery/issues/221
  17619. var galleryPrevStaticHeight = 0;
  17620. JustifiedGallery.prototype.rememberGalleryHeight = function () {
  17621. galleryPrevStaticHeight = this.$gallery.height();
  17622. this.$gallery.height(galleryPrevStaticHeight);
  17623. };
  17624. // grow only
  17625. JustifiedGallery.prototype.setGalleryTempHeight = function (height) {
  17626. galleryPrevStaticHeight = Math.max(height, galleryPrevStaticHeight);
  17627. this.$gallery.height(galleryPrevStaticHeight);
  17628. };
  17629. JustifiedGallery.prototype.setGalleryFinalHeight = function (height) {
  17630. galleryPrevStaticHeight = height;
  17631. this.$gallery.height(height);
  17632. };
  17633. /**
  17634. * Checks the width of the gallery container, to know if a new justification is needed
  17635. */
  17636. JustifiedGallery.prototype.checkWidth = function () {
  17637. this.checkWidthIntervalId = setInterval($.proxy(function () {
  17638. // if the gallery is not currently visible, abort.
  17639. if (!this.$gallery.is(":visible")) return;
  17640. var galleryWidth = parseFloat(this.$gallery.width());
  17641. if (Math.abs(galleryWidth - this.galleryWidth) > this.settings.refreshSensitivity) {
  17642. this.galleryWidth = galleryWidth;
  17643. this.rewind();
  17644. this.rememberGalleryHeight();
  17645. // Restart to analyze
  17646. this.startImgAnalyzer(true);
  17647. }
  17648. }, this), this.settings.refreshTime);
  17649. };
  17650. /**
  17651. * @returns {boolean} a boolean saying if the spinner is active or not
  17652. */
  17653. JustifiedGallery.prototype.isSpinnerActive = function () {
  17654. return this.spinner.intervalId !== null;
  17655. };
  17656. /**
  17657. * @returns {int} the spinner height
  17658. */
  17659. JustifiedGallery.prototype.getSpinnerHeight = function () {
  17660. return this.spinner.$el.innerHeight();
  17661. };
  17662. /**
  17663. * Stops the spinner animation and modify the gallery height to exclude the spinner
  17664. */
  17665. JustifiedGallery.prototype.stopLoadingSpinnerAnimation = function () {
  17666. clearInterval(this.spinner.intervalId);
  17667. this.spinner.intervalId = null;
  17668. this.setGalleryTempHeight(this.$gallery.height() - this.getSpinnerHeight());
  17669. this.spinner.$el.detach();
  17670. };
  17671. /**
  17672. * Starts the spinner animation
  17673. */
  17674. JustifiedGallery.prototype.startLoadingSpinnerAnimation = function () {
  17675. var spinnerContext = this.spinner;
  17676. var $spinnerPoints = spinnerContext.$el.find('span');
  17677. clearInterval(spinnerContext.intervalId);
  17678. this.$gallery.append(spinnerContext.$el);
  17679. this.setGalleryTempHeight(this.offY + this.buildingRow.height + this.getSpinnerHeight());
  17680. spinnerContext.intervalId = setInterval(function () {
  17681. if (spinnerContext.phase < $spinnerPoints.length) {
  17682. $spinnerPoints.eq(spinnerContext.phase).fadeTo(spinnerContext.timeSlot, 1);
  17683. } else {
  17684. $spinnerPoints.eq(spinnerContext.phase - $spinnerPoints.length).fadeTo(spinnerContext.timeSlot, 0);
  17685. }
  17686. spinnerContext.phase = (spinnerContext.phase + 1) % ($spinnerPoints.length * 2);
  17687. }, spinnerContext.timeSlot);
  17688. };
  17689. /**
  17690. * Rewind the image analysis to start from the first entry.
  17691. */
  17692. JustifiedGallery.prototype.rewind = function () {
  17693. this.lastFetchedEntry = null;
  17694. this.lastAnalyzedIndex = -1;
  17695. this.offY = this.border;
  17696. this.rows = 0;
  17697. this.clearBuildingRow();
  17698. };
  17699. /**
  17700. * @returns {String} `settings.selector` rejecting spinner element
  17701. */
  17702. JustifiedGallery.prototype.getSelectorWithoutSpinner = function () {
  17703. return this.settings.selector + ', div:not(.jg-spinner)';
  17704. };
  17705. /**
  17706. * @returns {Array} all entries matched by `settings.selector`
  17707. */
  17708. JustifiedGallery.prototype.getAllEntries = function () {
  17709. var selector = this.getSelectorWithoutSpinner();
  17710. return this.$gallery.children(selector).toArray();
  17711. };
  17712. /**
  17713. * Update the entries searching it from the justified gallery HTML element
  17714. *
  17715. * @param norewind if norewind only the new entries will be changed (i.e. randomized, sorted or filtered)
  17716. * @returns {boolean} true if some entries has been founded
  17717. */
  17718. JustifiedGallery.prototype.updateEntries = function (norewind) {
  17719. var newEntries;
  17720. if (norewind && this.lastFetchedEntry != null) {
  17721. var selector = this.getSelectorWithoutSpinner();
  17722. newEntries = $(this.lastFetchedEntry).nextAll(selector).toArray();
  17723. } else {
  17724. this.entries = [];
  17725. newEntries = this.getAllEntries();
  17726. }
  17727. if (newEntries.length > 0) {
  17728. // Sort or randomize
  17729. if ($.isFunction(this.settings.sort)) {
  17730. newEntries = this.sortArray(newEntries);
  17731. } else if (this.settings.randomize) {
  17732. newEntries = this.shuffleArray(newEntries);
  17733. }
  17734. this.lastFetchedEntry = newEntries[newEntries.length - 1];
  17735. // Filter
  17736. if (this.settings.filter) {
  17737. newEntries = this.filterArray(newEntries);
  17738. } else {
  17739. this.resetFilters(newEntries);
  17740. }
  17741. }
  17742. this.entries = this.entries.concat(newEntries);
  17743. return true;
  17744. };
  17745. /**
  17746. * Apply the entries order to the DOM, iterating the entries and appending the images
  17747. *
  17748. * @param entries the entries that has been modified and that must be re-ordered in the DOM
  17749. */
  17750. JustifiedGallery.prototype.insertToGallery = function (entries) {
  17751. var that = this;
  17752. $.each(entries, function () {
  17753. $(this).appendTo(that.$gallery);
  17754. });
  17755. };
  17756. /**
  17757. * Shuffle the array using the Fisher-Yates shuffle algorithm
  17758. *
  17759. * @param a the array to shuffle
  17760. * @return the shuffled array
  17761. */
  17762. JustifiedGallery.prototype.shuffleArray = function (a) {
  17763. var i, j, temp;
  17764. for (i = a.length - 1; i > 0; i--) {
  17765. j = Math.floor(Math.random() * (i + 1));
  17766. temp = a[i];
  17767. a[i] = a[j];
  17768. a[j] = temp;
  17769. }
  17770. this.insertToGallery(a);
  17771. return a;
  17772. };
  17773. /**
  17774. * Sort the array using settings.comparator as comparator
  17775. *
  17776. * @param a the array to sort (it is sorted)
  17777. * @return the sorted array
  17778. */
  17779. JustifiedGallery.prototype.sortArray = function (a) {
  17780. a.sort(this.settings.sort);
  17781. this.insertToGallery(a);
  17782. return a;
  17783. };
  17784. /**
  17785. * Reset the filters removing the 'jg-filtered' class from all the entries
  17786. *
  17787. * @param a the array to reset
  17788. */
  17789. JustifiedGallery.prototype.resetFilters = function (a) {
  17790. for (var i = 0; i < a.length; i++) $(a[i]).removeClass('jg-filtered');
  17791. };
  17792. /**
  17793. * Filter the entries considering theirs classes (if a string has been passed) or using a function for filtering.
  17794. *
  17795. * @param a the array to filter
  17796. * @return the filtered array
  17797. */
  17798. JustifiedGallery.prototype.filterArray = function (a) {
  17799. var settings = this.settings;
  17800. if ($.type(settings.filter) === 'string') {
  17801. // Filter only keeping the entries passed in the string
  17802. return a.filter(function (el) {
  17803. var $el = $(el);
  17804. if ($el.is(settings.filter)) {
  17805. $el.removeClass('jg-filtered');
  17806. return true;
  17807. } else {
  17808. $el.addClass('jg-filtered').removeClass('jg-visible');
  17809. return false;
  17810. }
  17811. });
  17812. } else if ($.isFunction(settings.filter)) {
  17813. // Filter using the passed function
  17814. var filteredArr = a.filter(settings.filter);
  17815. for (var i = 0; i < a.length; i++) {
  17816. if (filteredArr.indexOf(a[i]) === -1) {
  17817. $(a[i]).addClass('jg-filtered').removeClass('jg-visible');
  17818. } else {
  17819. $(a[i]).removeClass('jg-filtered');
  17820. }
  17821. }
  17822. return filteredArr;
  17823. }
  17824. };
  17825. /**
  17826. * Revert the image src to the default value.
  17827. */
  17828. JustifiedGallery.prototype.resetImgSrc = function ($img) {
  17829. if ($img.data('jg.originalSrcLoc') === 'src') {
  17830. $img.attr('src', $img.data('jg.originalSrc'));
  17831. } else {
  17832. $img.attr('src', '');
  17833. }
  17834. };
  17835. /**
  17836. * Destroy the Justified Gallery instance.
  17837. *
  17838. * It clears all the css properties added in the style attributes. We doesn't backup the original
  17839. * values for those css attributes, because it costs (performance) and because in general one
  17840. * shouldn't use the style attribute for an uniform set of images (where we suppose the use of
  17841. * classes). Creating a backup is also difficult because JG could be called multiple times and
  17842. * with different style attributes.
  17843. */
  17844. JustifiedGallery.prototype.destroy = function () {
  17845. clearInterval(this.checkWidthIntervalId);
  17846. this.stopImgAnalyzerStarter();
  17847. // Get fresh entries list since filtered entries are absent in `this.entries`
  17848. $.each(this.getAllEntries(), $.proxy(function (_, entry) {
  17849. var $entry = $(entry);
  17850. // Reset entry style
  17851. $entry.css('width', '');
  17852. $entry.css('height', '');
  17853. $entry.css('top', '');
  17854. $entry.css('left', '');
  17855. $entry.data('jg.loaded', undefined);
  17856. $entry.removeClass('jg-entry jg-filtered jg-entry-visible');
  17857. // Reset image style
  17858. var $img = this.imgFromEntry($entry);
  17859. if ($img) {
  17860. $img.css('width', '');
  17861. $img.css('height', '');
  17862. $img.css('margin-left', '');
  17863. $img.css('margin-top', '');
  17864. this.resetImgSrc($img);
  17865. $img.data('jg.originalSrc', undefined);
  17866. $img.data('jg.originalSrcLoc', undefined);
  17867. $img.data('jg.src', undefined);
  17868. }
  17869. // Remove caption
  17870. this.removeCaptionEventsHandlers($entry);
  17871. var $caption = this.captionFromEntry($entry);
  17872. if ($entry.data('jg.createdCaption')) {
  17873. // remove also the caption element (if created by jg)
  17874. $entry.data('jg.createdCaption', undefined);
  17875. if ($caption !== null) $caption.remove();
  17876. } else {
  17877. if ($caption !== null) $caption.fadeTo(0, 1);
  17878. }
  17879. }, this));
  17880. this.$gallery.css('height', '');
  17881. this.$gallery.removeClass('justified-gallery');
  17882. this.$gallery.data('jg.controller', undefined);
  17883. this.settings.triggerEvent.call(this, 'jg.destroy');
  17884. };
  17885. /**
  17886. * Analyze the images and builds the rows. It returns if it found an image that is not loaded.
  17887. *
  17888. * @param isForResize if the image analyzer is called for resizing or not, to call a different callback at the end
  17889. */
  17890. JustifiedGallery.prototype.analyzeImages = function (isForResize) {
  17891. for (var i = this.lastAnalyzedIndex + 1; i < this.entries.length; i++) {
  17892. var $entry = $(this.entries[i]);
  17893. if ($entry.data('jg.loaded') === true || $entry.data('jg.loaded') === 'skipped') {
  17894. var availableWidth = this.galleryWidth - 2 * this.border - (
  17895. (this.buildingRow.entriesBuff.length - 1) * this.settings.margins);
  17896. var imgAspectRatio = $entry.data('jg.width') / $entry.data('jg.height');
  17897. this.buildingRow.entriesBuff.push($entry);
  17898. this.buildingRow.aspectRatio += imgAspectRatio;
  17899. this.buildingRow.width += imgAspectRatio * this.settings.rowHeight;
  17900. this.lastAnalyzedIndex = i;
  17901. if (availableWidth / (this.buildingRow.aspectRatio + imgAspectRatio) < this.settings.rowHeight) {
  17902. this.flushRow(false, this.settings.maxRowsCount > 0 && this.rows === this.settings.maxRowsCount);
  17903. if (++this.yield.flushed >= this.yield.every) {
  17904. this.startImgAnalyzer(isForResize);
  17905. return;
  17906. }
  17907. }
  17908. } else if ($entry.data('jg.loaded') !== 'error') {
  17909. return;
  17910. }
  17911. }
  17912. // Last row flush (the row is not full)
  17913. if (this.buildingRow.entriesBuff.length > 0) {
  17914. this.flushRow(true, this.settings.maxRowsCount > 0 && this.rows === this.settings.maxRowsCount);
  17915. }
  17916. if (this.isSpinnerActive()) {
  17917. this.stopLoadingSpinnerAnimation();
  17918. }
  17919. /* Stop, if there is, the timeout to start the analyzeImages.
  17920. This is because an image can be set loaded, and the timeout can be set,
  17921. but this image can be analyzed yet.
  17922. */
  17923. this.stopImgAnalyzerStarter();
  17924. this.setGalleryFinalHeight(this.galleryHeightToSet);
  17925. //On complete callback
  17926. this.settings.triggerEvent.call(this, isForResize ? 'jg.resize' : 'jg.complete');
  17927. };
  17928. /**
  17929. * Stops any ImgAnalyzer starter (that has an assigned timeout)
  17930. */
  17931. JustifiedGallery.prototype.stopImgAnalyzerStarter = function () {
  17932. this.yield.flushed = 0;
  17933. if (this.imgAnalyzerTimeout !== null) {
  17934. clearTimeout(this.imgAnalyzerTimeout);
  17935. this.imgAnalyzerTimeout = null;
  17936. }
  17937. };
  17938. /**
  17939. * Starts the image analyzer. It is not immediately called to let the browser to update the view
  17940. *
  17941. * @param isForResize specifies if the image analyzer must be called for resizing or not
  17942. */
  17943. JustifiedGallery.prototype.startImgAnalyzer = function (isForResize) {
  17944. var that = this;
  17945. this.stopImgAnalyzerStarter();
  17946. this.imgAnalyzerTimeout = setTimeout(function () {
  17947. that.analyzeImages(isForResize);
  17948. }, 0.001); // we can't start it immediately due to a IE different behaviour
  17949. };
  17950. /**
  17951. * Checks if the image is loaded or not using another image object. We cannot use the 'complete' image property,
  17952. * because some browsers, with a 404 set complete = true.
  17953. *
  17954. * @param imageSrc the image src to load
  17955. * @param onLoad callback that is called when the image has been loaded
  17956. * @param onError callback that is called in case of an error
  17957. */
  17958. JustifiedGallery.prototype.onImageEvent = function (imageSrc, onLoad, onError) {
  17959. if (!onLoad && !onError) return;
  17960. var memImage = new Image();
  17961. var $memImage = $(memImage);
  17962. if (onLoad) {
  17963. $memImage.one('load', function () {
  17964. $memImage.off('load error');
  17965. onLoad(memImage);
  17966. });
  17967. }
  17968. if (onError) {
  17969. $memImage.one('error', function () {
  17970. $memImage.off('load error');
  17971. onError(memImage);
  17972. });
  17973. }
  17974. memImage.src = imageSrc;
  17975. };
  17976. /**
  17977. * Init of Justified Gallery controlled
  17978. * It analyzes all the entries starting theirs loading and calling the image analyzer (that works with loaded images)
  17979. */
  17980. JustifiedGallery.prototype.init = function () {
  17981. var imagesToLoad = false, skippedImages = false, that = this;
  17982. $.each(this.entries, function (index, entry) {
  17983. var $entry = $(entry);
  17984. var $image = that.imgFromEntry($entry);
  17985. $entry.addClass('jg-entry');
  17986. if ($entry.data('jg.loaded') !== true && $entry.data('jg.loaded') !== 'skipped') {
  17987. // Link Rel global overwrite
  17988. if (that.settings.rel !== null) $entry.attr('rel', that.settings.rel);
  17989. // Link Target global overwrite
  17990. if (that.settings.target !== null) $entry.attr('target', that.settings.target);
  17991. if ($image !== null) {
  17992. // Image src
  17993. var imageSrc = that.extractImgSrcFromImage($image);
  17994. /* If we have the height and the width, we don't wait that the image is loaded,
  17995. but we start directly with the justification */
  17996. if (that.settings.waitThumbnailsLoad === false || !imageSrc) {
  17997. var width = parseFloat($image.attr('width'));
  17998. var height = parseFloat($image.attr('height'));
  17999. if ($image.prop('tagName') === 'svg') {
  18000. width = parseFloat($image[0].getBBox().width);
  18001. height = parseFloat($image[0].getBBox().height);
  18002. }
  18003. if (!isNaN(width) && !isNaN(height)) {
  18004. $entry.data('jg.width', width);
  18005. $entry.data('jg.height', height);
  18006. $entry.data('jg.loaded', 'skipped');
  18007. skippedImages = true;
  18008. that.startImgAnalyzer(false);
  18009. return true; // continue
  18010. }
  18011. }
  18012. $entry.data('jg.loaded', false);
  18013. imagesToLoad = true;
  18014. // Spinner start
  18015. if (!that.isSpinnerActive()) that.startLoadingSpinnerAnimation();
  18016. that.onImageEvent(imageSrc, function (loadImg) { // image loaded
  18017. $entry.data('jg.width', loadImg.width);
  18018. $entry.data('jg.height', loadImg.height);
  18019. $entry.data('jg.loaded', true);
  18020. that.startImgAnalyzer(false);
  18021. }, function () { // image load error
  18022. $entry.data('jg.loaded', 'error');
  18023. that.startImgAnalyzer(false);
  18024. });
  18025. } else {
  18026. $entry.data('jg.loaded', true);
  18027. $entry.data('jg.width', $entry.width() | parseFloat($entry.css('width')) | 1);
  18028. $entry.data('jg.height', $entry.height() | parseFloat($entry.css('height')) | 1);
  18029. }
  18030. }
  18031. });
  18032. if (!imagesToLoad && !skippedImages) this.startImgAnalyzer(false);
  18033. this.checkWidth();
  18034. };
  18035. /**
  18036. * Checks that it is a valid number. If a string is passed it is converted to a number
  18037. *
  18038. * @param settingContainer the object that contains the setting (to allow the conversion)
  18039. * @param settingName the setting name
  18040. */
  18041. JustifiedGallery.prototype.checkOrConvertNumber = function (settingContainer, settingName) {
  18042. if ($.type(settingContainer[settingName]) === 'string') {
  18043. settingContainer[settingName] = parseFloat(settingContainer[settingName]);
  18044. }
  18045. if ($.type(settingContainer[settingName]) === 'number') {
  18046. if (isNaN(settingContainer[settingName])) throw 'invalid number for ' + settingName;
  18047. } else {
  18048. throw settingName + ' must be a number';
  18049. }
  18050. };
  18051. /**
  18052. * Checks the sizeRangeSuffixes and, if necessary, converts
  18053. * its keys from string (e.g. old settings with 'lt100') to int.
  18054. */
  18055. JustifiedGallery.prototype.checkSizeRangesSuffixes = function () {
  18056. if ($.type(this.settings.sizeRangeSuffixes) !== 'object') {
  18057. throw 'sizeRangeSuffixes must be defined and must be an object';
  18058. }
  18059. var suffixRanges = [];
  18060. for (var rangeIdx in this.settings.sizeRangeSuffixes) {
  18061. if (this.settings.sizeRangeSuffixes.hasOwnProperty(rangeIdx)) suffixRanges.push(rangeIdx);
  18062. }
  18063. var newSizeRngSuffixes = { 0: '' };
  18064. for (var i = 0; i < suffixRanges.length; i++) {
  18065. if ($.type(suffixRanges[i]) === 'string') {
  18066. try {
  18067. var numIdx = parseInt(suffixRanges[i].replace(/^[a-z]+/, ''), 10);
  18068. newSizeRngSuffixes[numIdx] = this.settings.sizeRangeSuffixes[suffixRanges[i]];
  18069. } catch (e) {
  18070. throw 'sizeRangeSuffixes keys must contains correct numbers (' + e + ')';
  18071. }
  18072. } else {
  18073. newSizeRngSuffixes[suffixRanges[i]] = this.settings.sizeRangeSuffixes[suffixRanges[i]];
  18074. }
  18075. }
  18076. this.settings.sizeRangeSuffixes = newSizeRngSuffixes;
  18077. };
  18078. /**
  18079. * check and convert the maxRowHeight setting
  18080. * requires rowHeight to be already set
  18081. * TODO: should be always called when only rowHeight is changed
  18082. * @return number or null
  18083. */
  18084. JustifiedGallery.prototype.retrieveMaxRowHeight = function () {
  18085. var newMaxRowHeight = null;
  18086. var rowHeight = this.settings.rowHeight;
  18087. if ($.type(this.settings.maxRowHeight) === 'string') {
  18088. if (this.settings.maxRowHeight.match(/^[0-9]+%$/)) {
  18089. newMaxRowHeight = rowHeight * parseFloat(this.settings.maxRowHeight.match(/^([0-9]+)%$/)[1]) / 100;
  18090. } else {
  18091. newMaxRowHeight = parseFloat(this.settings.maxRowHeight);
  18092. }
  18093. } else if ($.type(this.settings.maxRowHeight) === 'number') {
  18094. newMaxRowHeight = this.settings.maxRowHeight;
  18095. } else if (this.settings.maxRowHeight === false || this.settings.maxRowHeight == null) {
  18096. return null;
  18097. } else {
  18098. throw 'maxRowHeight must be a number or a percentage';
  18099. }
  18100. // check if the converted value is not a number
  18101. if (isNaN(newMaxRowHeight)) throw 'invalid number for maxRowHeight';
  18102. // check values, maxRowHeight must be >= rowHeight
  18103. if (newMaxRowHeight < rowHeight) newMaxRowHeight = rowHeight;
  18104. return newMaxRowHeight;
  18105. };
  18106. /**
  18107. * Checks the settings
  18108. */
  18109. JustifiedGallery.prototype.checkSettings = function () {
  18110. this.checkSizeRangesSuffixes();
  18111. this.checkOrConvertNumber(this.settings, 'rowHeight');
  18112. this.checkOrConvertNumber(this.settings, 'margins');
  18113. this.checkOrConvertNumber(this.settings, 'border');
  18114. this.checkOrConvertNumber(this.settings, 'maxRowsCount');
  18115. var lastRowModes = [
  18116. 'justify',
  18117. 'nojustify',
  18118. 'left',
  18119. 'center',
  18120. 'right',
  18121. 'hide'
  18122. ];
  18123. if (lastRowModes.indexOf(this.settings.lastRow) === -1) {
  18124. throw 'lastRow must be one of: ' + lastRowModes.join(', ');
  18125. }
  18126. this.checkOrConvertNumber(this.settings, 'justifyThreshold');
  18127. if (this.settings.justifyThreshold < 0 || this.settings.justifyThreshold > 1) {
  18128. throw 'justifyThreshold must be in the interval [0,1]';
  18129. }
  18130. if ($.type(this.settings.cssAnimation) !== 'boolean') {
  18131. throw 'cssAnimation must be a boolean';
  18132. }
  18133. if ($.type(this.settings.captions) !== 'boolean') throw 'captions must be a boolean';
  18134. this.checkOrConvertNumber(this.settings.captionSettings, 'animationDuration');
  18135. this.checkOrConvertNumber(this.settings.captionSettings, 'visibleOpacity');
  18136. if (this.settings.captionSettings.visibleOpacity < 0 ||
  18137. this.settings.captionSettings.visibleOpacity > 1) {
  18138. throw 'captionSettings.visibleOpacity must be in the interval [0, 1]';
  18139. }
  18140. this.checkOrConvertNumber(this.settings.captionSettings, 'nonVisibleOpacity');
  18141. if (this.settings.captionSettings.nonVisibleOpacity < 0 ||
  18142. this.settings.captionSettings.nonVisibleOpacity > 1) {
  18143. throw 'captionSettings.nonVisibleOpacity must be in the interval [0, 1]';
  18144. }
  18145. this.checkOrConvertNumber(this.settings, 'imagesAnimationDuration');
  18146. this.checkOrConvertNumber(this.settings, 'refreshTime');
  18147. this.checkOrConvertNumber(this.settings, 'refreshSensitivity');
  18148. if ($.type(this.settings.randomize) !== 'boolean') throw 'randomize must be a boolean';
  18149. if ($.type(this.settings.selector) !== 'string') throw 'selector must be a string';
  18150. if (this.settings.sort !== false && !$.isFunction(this.settings.sort)) {
  18151. throw 'sort must be false or a comparison function';
  18152. }
  18153. if (this.settings.filter !== false && !$.isFunction(this.settings.filter) &&
  18154. $.type(this.settings.filter) !== 'string') {
  18155. throw 'filter must be false, a string or a filter function';
  18156. }
  18157. };
  18158. /**
  18159. * It brings all the indexes from the sizeRangeSuffixes and it orders them. They are then sorted and returned.
  18160. * @returns {Array} sorted suffix ranges
  18161. */
  18162. JustifiedGallery.prototype.retrieveSuffixRanges = function () {
  18163. var suffixRanges = [];
  18164. for (var rangeIdx in this.settings.sizeRangeSuffixes) {
  18165. if (this.settings.sizeRangeSuffixes.hasOwnProperty(rangeIdx)) suffixRanges.push(parseInt(rangeIdx, 10));
  18166. }
  18167. suffixRanges.sort(function (a, b) { return a > b ? 1 : a < b ? -1 : 0; });
  18168. return suffixRanges;
  18169. };
  18170. /**
  18171. * Update the existing settings only changing some of them
  18172. *
  18173. * @param newSettings the new settings (or a subgroup of them)
  18174. */
  18175. JustifiedGallery.prototype.updateSettings = function (newSettings) {
  18176. // In this case Justified Gallery has been called again changing only some options
  18177. this.settings = $.extend({}, this.settings, newSettings);
  18178. this.checkSettings();
  18179. // As reported in the settings: negative value = same as margins, 0 = disabled
  18180. this.border = this.settings.border >= 0 ? this.settings.border : this.settings.margins;
  18181. this.maxRowHeight = this.retrieveMaxRowHeight();
  18182. this.suffixRanges = this.retrieveSuffixRanges();
  18183. };
  18184. JustifiedGallery.prototype.defaults = {
  18185. sizeRangeSuffixes: {}, /* e.g. Flickr configuration
  18186. {
  18187. 100: '_t', // used when longest is less than 100px
  18188. 240: '_m', // used when longest is between 101px and 240px
  18189. 320: '_n', // ...
  18190. 500: '',
  18191. 640: '_z',
  18192. 1024: '_b' // used as else case because it is the last
  18193. }
  18194. */
  18195. thumbnailPath: undefined, /* If defined, sizeRangeSuffixes is not used, and this function is used to determine the
  18196. path relative to a specific thumbnail size. The function should accept respectively three arguments:
  18197. current path, width and height */
  18198. rowHeight: 120, // required? required to be > 0?
  18199. maxRowHeight: false, // false or negative value to deactivate. Positive number to express the value in pixels,
  18200. // A string '[0-9]+%' to express in percentage (e.g. 300% means that the row height
  18201. // can't exceed 3 * rowHeight)
  18202. maxRowsCount: 0, // maximum number of rows to be displayed (0 = disabled)
  18203. margins: 1,
  18204. border: -1, // negative value = same as margins, 0 = disabled, any other value to set the border
  18205. lastRow: 'nojustify', // … which is the same as 'left', or can be 'justify', 'center', 'right' or 'hide'
  18206. justifyThreshold: 0.90, /* if row width / available space > 0.90 it will be always justified
  18207. * (i.e. lastRow setting is not considered) */
  18208. waitThumbnailsLoad: true,
  18209. captions: true,
  18210. cssAnimation: true,
  18211. imagesAnimationDuration: 500, // ignored with css animations
  18212. captionSettings: { // ignored with css animations
  18213. animationDuration: 500,
  18214. visibleOpacity: 0.7,
  18215. nonVisibleOpacity: 0.0
  18216. },
  18217. rel: null, // rewrite the rel of each analyzed links
  18218. target: null, // rewrite the target of all links
  18219. extension: /\.[^.\\/]+$/, // regexp to capture the extension of an image
  18220. refreshTime: 200, // time interval (in ms) to check if the page changes its width
  18221. refreshSensitivity: 0, // change in width allowed (in px) without re-building the gallery
  18222. randomize: false,
  18223. rtl: false, // right-to-left mode
  18224. sort: false, /*
  18225. - false: to do not sort
  18226. - function: to sort them using the function as comparator (see Array.prototype.sort())
  18227. */
  18228. filter: false, /*
  18229. - false, null or undefined: for a disabled filter
  18230. - a string: an entry is kept if entry.is(filter string) returns true
  18231. see jQuery's .is() function for further information
  18232. - a function: invoked with arguments (entry, index, array). Return true to keep the entry, false otherwise.
  18233. It follows the specifications of the Array.prototype.filter() function of JavaScript.
  18234. */
  18235. selector: 'a', // The selector that is used to know what are the entries of the gallery
  18236. imgSelector: '> img, > a > img, > svg, > a > svg', // The selector that is used to know what are the images of each entry
  18237. triggerEvent: function (event) { // This is called to trigger events, the default behavior is to call $.trigger
  18238. this.$gallery.trigger(event); // Consider that 'this' is this set to the JustifiedGallery object, so it can
  18239. } // access to fields such as $gallery, useful to trigger events with jQuery.
  18240. };
  18241. /**
  18242. * Justified Gallery plugin for jQuery
  18243. *
  18244. * Events
  18245. * - jg.complete : called when all the gallery has been created
  18246. * - jg.resize : called when the gallery has been resized
  18247. * - jg.rowflush : when a new row appears
  18248. *
  18249. * @param arg the action (or the settings) passed when the plugin is called
  18250. * @returns {*} the object itself
  18251. */
  18252. $.fn.justifiedGallery = function (arg) {
  18253. return this.each(function (index, gallery) {
  18254. var $gallery = $(gallery);
  18255. $gallery.addClass('justified-gallery');
  18256. var controller = $gallery.data('jg.controller');
  18257. if (typeof controller === 'undefined') {
  18258. // Create controller and assign it to the object data
  18259. if (typeof arg !== 'undefined' && arg !== null && $.type(arg) !== 'object') {
  18260. if (arg === 'destroy') return; // Just a call to an unexisting object
  18261. throw 'The argument must be an object';
  18262. }
  18263. controller = new JustifiedGallery($gallery, $.extend({}, JustifiedGallery.prototype.defaults, arg));
  18264. $gallery.data('jg.controller', controller);
  18265. } else if (arg === 'norewind') {
  18266. // In this case we don't rewind: we analyze only the latest images (e.g. to complete the last unfinished row
  18267. // ... left to be more readable
  18268. } else if (arg === 'destroy') {
  18269. controller.destroy();
  18270. return;
  18271. } else {
  18272. // In this case Justified Gallery has been called again changing only some options
  18273. controller.updateSettings(arg);
  18274. controller.rewind();
  18275. }
  18276. // Update the entries list
  18277. if (!controller.updateEntries(arg === 'norewind')) return;
  18278. // Init justified gallery
  18279. controller.init();
  18280. });
  18281. };
  18282. }));
  18283. /*!
  18284. Google Map Style
  18285. !*/
  18286. const Retro = [
  18287. {
  18288. "elementType": "geometry",
  18289. "stylers": [
  18290. {
  18291. "color": "#ebe3cd"
  18292. }
  18293. ]
  18294. },
  18295. {
  18296. "elementType": "labels.text.fill",
  18297. "stylers": [
  18298. {
  18299. "color": "#523735"
  18300. }
  18301. ]
  18302. },
  18303. {
  18304. "elementType": "labels.text.stroke",
  18305. "stylers": [
  18306. {
  18307. "color": "#f5f1e6"
  18308. }
  18309. ]
  18310. },
  18311. {
  18312. "featureType": "administrative",
  18313. "elementType": "geometry",
  18314. "stylers": [
  18315. {
  18316. "visibility": "off"
  18317. }
  18318. ]
  18319. },
  18320. {
  18321. "featureType": "administrative",
  18322. "elementType": "geometry.stroke",
  18323. "stylers": [
  18324. {
  18325. "color": "#c9b2a6"
  18326. }
  18327. ]
  18328. },
  18329. {
  18330. "featureType": "administrative.land_parcel",
  18331. "elementType": "geometry.stroke",
  18332. "stylers": [
  18333. {
  18334. "color": "#dcd2be"
  18335. }
  18336. ]
  18337. },
  18338. {
  18339. "featureType": "administrative.land_parcel",
  18340. "elementType": "labels.text.fill",
  18341. "stylers": [
  18342. {
  18343. "color": "#ae9e90"
  18344. }
  18345. ]
  18346. },
  18347. {
  18348. "featureType": "landscape.natural",
  18349. "elementType": "geometry",
  18350. "stylers": [
  18351. {
  18352. "color": "#dfd2ae"
  18353. }
  18354. ]
  18355. },
  18356. {
  18357. "featureType": "poi",
  18358. "stylers": [
  18359. {
  18360. "visibility": "off"
  18361. }
  18362. ]
  18363. },
  18364. {
  18365. "featureType": "poi",
  18366. "elementType": "geometry",
  18367. "stylers": [
  18368. {
  18369. "color": "#dfd2ae"
  18370. }
  18371. ]
  18372. },
  18373. {
  18374. "featureType": "poi",
  18375. "elementType": "labels.text.fill",
  18376. "stylers": [
  18377. {
  18378. "color": "#93817c"
  18379. }
  18380. ]
  18381. },
  18382. {
  18383. "featureType": "poi.park",
  18384. "elementType": "geometry.fill",
  18385. "stylers": [
  18386. {
  18387. "color": "#a5b076"
  18388. }
  18389. ]
  18390. },
  18391. {
  18392. "featureType": "poi.park",
  18393. "elementType": "labels.text.fill",
  18394. "stylers": [
  18395. {
  18396. "color": "#447530"
  18397. }
  18398. ]
  18399. },
  18400. {
  18401. "featureType": "road",
  18402. "elementType": "geometry",
  18403. "stylers": [
  18404. {
  18405. "color": "#f5f1e6"
  18406. }
  18407. ]
  18408. },
  18409. {
  18410. "featureType": "road",
  18411. "elementType": "labels.icon",
  18412. "stylers": [
  18413. {
  18414. "visibility": "off"
  18415. }
  18416. ]
  18417. },
  18418. {
  18419. "featureType": "road.arterial",
  18420. "elementType": "geometry",
  18421. "stylers": [
  18422. {
  18423. "color": "#fdfcf8"
  18424. }
  18425. ]
  18426. },
  18427. {
  18428. "featureType": "road.highway",
  18429. "elementType": "geometry",
  18430. "stylers": [
  18431. {
  18432. "color": "#f8c967"
  18433. }
  18434. ]
  18435. },
  18436. {
  18437. "featureType": "road.highway",
  18438. "elementType": "geometry.stroke",
  18439. "stylers": [
  18440. {
  18441. "color": "#e9bc62"
  18442. }
  18443. ]
  18444. },
  18445. {
  18446. "featureType": "road.highway.controlled_access",
  18447. "elementType": "geometry",
  18448. "stylers": [
  18449. {
  18450. "color": "#e98d58"
  18451. }
  18452. ]
  18453. },
  18454. {
  18455. "featureType": "road.highway.controlled_access",
  18456. "elementType": "geometry.stroke",
  18457. "stylers": [
  18458. {
  18459. "color": "#db8555"
  18460. }
  18461. ]
  18462. },
  18463. {
  18464. "featureType": "road.local",
  18465. "elementType": "labels.text.fill",
  18466. "stylers": [
  18467. {
  18468. "color": "#806b63"
  18469. }
  18470. ]
  18471. },
  18472. {
  18473. "featureType": "transit",
  18474. "stylers": [
  18475. {
  18476. "visibility": "off"
  18477. }
  18478. ]
  18479. },
  18480. {
  18481. "featureType": "transit.line",
  18482. "elementType": "geometry",
  18483. "stylers": [
  18484. {
  18485. "color": "#dfd2ae"
  18486. }
  18487. ]
  18488. },
  18489. {
  18490. "featureType": "transit.line",
  18491. "elementType": "labels.text.fill",
  18492. "stylers": [
  18493. {
  18494. "color": "#8f7d77"
  18495. }
  18496. ]
  18497. },
  18498. {
  18499. "featureType": "transit.line",
  18500. "elementType": "labels.text.stroke",
  18501. "stylers": [
  18502. {
  18503. "color": "#ebe3cd"
  18504. }
  18505. ]
  18506. },
  18507. {
  18508. "featureType": "transit.station",
  18509. "elementType": "geometry",
  18510. "stylers": [
  18511. {
  18512. "color": "#dfd2ae"
  18513. }
  18514. ]
  18515. },
  18516. {
  18517. "featureType": "water",
  18518. "elementType": "geometry.fill",
  18519. "stylers": [
  18520. {
  18521. "color": "#b9d3c2"
  18522. }
  18523. ]
  18524. },
  18525. {
  18526. "featureType": "water",
  18527. "elementType": "labels.text.fill",
  18528. "stylers": [
  18529. {
  18530. "color": "#92998d"
  18531. }
  18532. ]
  18533. }
  18534. ]
  18535. // Standard Style
  18536. const Standard = []
  18537. // Silver Style
  18538. const Silver = [
  18539. {
  18540. "elementType": "geometry",
  18541. "stylers": [
  18542. {
  18543. "color": "#f5f5f5"
  18544. }
  18545. ]
  18546. },
  18547. {
  18548. "elementType": "labels.icon",
  18549. "stylers": [
  18550. {
  18551. "visibility": "off"
  18552. }
  18553. ]
  18554. },
  18555. {
  18556. "elementType": "labels.text.fill",
  18557. "stylers": [
  18558. {
  18559. "color": "#616161"
  18560. }
  18561. ]
  18562. },
  18563. {
  18564. "elementType": "labels.text.stroke",
  18565. "stylers": [
  18566. {
  18567. "color": "#f5f5f5"
  18568. }
  18569. ]
  18570. },
  18571. {
  18572. "featureType": "administrative.land_parcel",
  18573. "elementType": "labels.text.fill",
  18574. "stylers": [
  18575. {
  18576. "color": "#bdbdbd"
  18577. }
  18578. ]
  18579. },
  18580. {
  18581. "featureType": "poi",
  18582. "elementType": "geometry",
  18583. "stylers": [
  18584. {
  18585. "color": "#eeeeee"
  18586. }
  18587. ]
  18588. },
  18589. {
  18590. "featureType": "poi",
  18591. "elementType": "labels.text.fill",
  18592. "stylers": [
  18593. {
  18594. "color": "#757575"
  18595. }
  18596. ]
  18597. },
  18598. {
  18599. "featureType": "poi.park",
  18600. "elementType": "geometry",
  18601. "stylers": [
  18602. {
  18603. "color": "#e5e5e5"
  18604. }
  18605. ]
  18606. },
  18607. {
  18608. "featureType": "poi.park",
  18609. "elementType": "labels.text.fill",
  18610. "stylers": [
  18611. {
  18612. "color": "#9e9e9e"
  18613. }
  18614. ]
  18615. },
  18616. {
  18617. "featureType": "road",
  18618. "elementType": "geometry",
  18619. "stylers": [
  18620. {
  18621. "color": "#ffffff"
  18622. }
  18623. ]
  18624. },
  18625. {
  18626. "featureType": "road.arterial",
  18627. "elementType": "labels.text.fill",
  18628. "stylers": [
  18629. {
  18630. "color": "#757575"
  18631. }
  18632. ]
  18633. },
  18634. {
  18635. "featureType": "road.highway",
  18636. "elementType": "geometry",
  18637. "stylers": [
  18638. {
  18639. "color": "#dadada"
  18640. }
  18641. ]
  18642. },
  18643. {
  18644. "featureType": "road.highway",
  18645. "elementType": "labels.text.fill",
  18646. "stylers": [
  18647. {
  18648. "color": "#616161"
  18649. }
  18650. ]
  18651. },
  18652. {
  18653. "featureType": "road.local",
  18654. "elementType": "labels.text.fill",
  18655. "stylers": [
  18656. {
  18657. "color": "#9e9e9e"
  18658. }
  18659. ]
  18660. },
  18661. {
  18662. "featureType": "transit.line",
  18663. "elementType": "geometry",
  18664. "stylers": [
  18665. {
  18666. "color": "#e5e5e5"
  18667. }
  18668. ]
  18669. },
  18670. {
  18671. "featureType": "transit.station",
  18672. "elementType": "geometry",
  18673. "stylers": [
  18674. {
  18675. "color": "#eeeeee"
  18676. }
  18677. ]
  18678. },
  18679. {
  18680. "featureType": "water",
  18681. "elementType": "geometry",
  18682. "stylers": [
  18683. {
  18684. "color": "#c9c9c9"
  18685. }
  18686. ]
  18687. },
  18688. {
  18689. "featureType": "water",
  18690. "elementType": "labels.text.fill",
  18691. "stylers": [
  18692. {
  18693. "color": "#9e9e9e"
  18694. }
  18695. ]
  18696. }
  18697. ]
  18698. // Dark Style
  18699. const Dark = [
  18700. {
  18701. "elementType": "geometry",
  18702. "stylers": [
  18703. {
  18704. "color": "#212121"
  18705. }
  18706. ]
  18707. },
  18708. {
  18709. "elementType": "labels.icon",
  18710. "stylers": [
  18711. {
  18712. "visibility": "off"
  18713. }
  18714. ]
  18715. },
  18716. {
  18717. "elementType": "labels.text.fill",
  18718. "stylers": [
  18719. {
  18720. "color": "#757575"
  18721. }
  18722. ]
  18723. },
  18724. {
  18725. "elementType": "labels.text.stroke",
  18726. "stylers": [
  18727. {
  18728. "color": "#212121"
  18729. }
  18730. ]
  18731. },
  18732. {
  18733. "featureType": "administrative",
  18734. "elementType": "geometry",
  18735. "stylers": [
  18736. {
  18737. "color": "#757575"
  18738. },
  18739. {
  18740. "visibility": "off"
  18741. }
  18742. ]
  18743. },
  18744. {
  18745. "featureType": "administrative.country",
  18746. "elementType": "labels.text.fill",
  18747. "stylers": [
  18748. {
  18749. "color": "#9e9e9e"
  18750. }
  18751. ]
  18752. },
  18753. {
  18754. "featureType": "administrative.land_parcel",
  18755. "stylers": [
  18756. {
  18757. "visibility": "off"
  18758. }
  18759. ]
  18760. },
  18761. {
  18762. "featureType": "administrative.locality",
  18763. "elementType": "labels.text.fill",
  18764. "stylers": [
  18765. {
  18766. "color": "#bdbdbd"
  18767. }
  18768. ]
  18769. },
  18770. {
  18771. "featureType": "poi",
  18772. "stylers": [
  18773. {
  18774. "visibility": "off"
  18775. }
  18776. ]
  18777. },
  18778. {
  18779. "featureType": "poi",
  18780. "elementType": "labels.text.fill",
  18781. "stylers": [
  18782. {
  18783. "color": "#757575"
  18784. }
  18785. ]
  18786. },
  18787. {
  18788. "featureType": "poi.park",
  18789. "elementType": "geometry",
  18790. "stylers": [
  18791. {
  18792. "color": "#181818"
  18793. }
  18794. ]
  18795. },
  18796. {
  18797. "featureType": "poi.park",
  18798. "elementType": "labels.text.fill",
  18799. "stylers": [
  18800. {
  18801. "color": "#616161"
  18802. }
  18803. ]
  18804. },
  18805. {
  18806. "featureType": "poi.park",
  18807. "elementType": "labels.text.stroke",
  18808. "stylers": [
  18809. {
  18810. "color": "#1b1b1b"
  18811. }
  18812. ]
  18813. },
  18814. {
  18815. "featureType": "road",
  18816. "elementType": "geometry.fill",
  18817. "stylers": [
  18818. {
  18819. "color": "#2c2c2c"
  18820. }
  18821. ]
  18822. },
  18823. {
  18824. "featureType": "road",
  18825. "elementType": "labels.icon",
  18826. "stylers": [
  18827. {
  18828. "visibility": "off"
  18829. }
  18830. ]
  18831. },
  18832. {
  18833. "featureType": "road",
  18834. "elementType": "labels.text.fill",
  18835. "stylers": [
  18836. {
  18837. "color": "#8a8a8a"
  18838. }
  18839. ]
  18840. },
  18841. {
  18842. "featureType": "road.arterial",
  18843. "elementType": "geometry",
  18844. "stylers": [
  18845. {
  18846. "color": "#373737"
  18847. }
  18848. ]
  18849. },
  18850. {
  18851. "featureType": "road.highway",
  18852. "elementType": "geometry",
  18853. "stylers": [
  18854. {
  18855. "color": "#3c3c3c"
  18856. }
  18857. ]
  18858. },
  18859. {
  18860. "featureType": "road.highway.controlled_access",
  18861. "elementType": "geometry",
  18862. "stylers": [
  18863. {
  18864. "color": "#4e4e4e"
  18865. }
  18866. ]
  18867. },
  18868. {
  18869. "featureType": "road.local",
  18870. "elementType": "labels.text.fill",
  18871. "stylers": [
  18872. {
  18873. "color": "#616161"
  18874. }
  18875. ]
  18876. },
  18877. {
  18878. "featureType": "transit",
  18879. "stylers": [
  18880. {
  18881. "visibility": "off"
  18882. }
  18883. ]
  18884. },
  18885. {
  18886. "featureType": "transit",
  18887. "elementType": "labels.text.fill",
  18888. "stylers": [
  18889. {
  18890. "color": "#757575"
  18891. }
  18892. ]
  18893. },
  18894. {
  18895. "featureType": "water",
  18896. "elementType": "geometry",
  18897. "stylers": [
  18898. {
  18899. "color": "#000000"
  18900. }
  18901. ]
  18902. },
  18903. {
  18904. "featureType": "water",
  18905. "elementType": "labels.text.fill",
  18906. "stylers": [
  18907. {
  18908. "color": "#3d3d3d"
  18909. }
  18910. ]
  18911. }
  18912. ]
  18913. // Night Style
  18914. const Night = [
  18915. {
  18916. "elementType": "geometry",
  18917. "stylers": [
  18918. {
  18919. "color": "#242f3e"
  18920. }
  18921. ]
  18922. },
  18923. {
  18924. "elementType": "labels.text.fill",
  18925. "stylers": [
  18926. {
  18927. "color": "#746855"
  18928. }
  18929. ]
  18930. },
  18931. {
  18932. "elementType": "labels.text.stroke",
  18933. "stylers": [
  18934. {
  18935. "color": "#242f3e"
  18936. }
  18937. ]
  18938. },
  18939. {
  18940. "featureType": "administrative",
  18941. "elementType": "geometry",
  18942. "stylers": [
  18943. {
  18944. "visibility": "off"
  18945. }
  18946. ]
  18947. },
  18948. {
  18949. "featureType": "administrative.locality",
  18950. "elementType": "labels.text.fill",
  18951. "stylers": [
  18952. {
  18953. "color": "#d59563"
  18954. }
  18955. ]
  18956. },
  18957. {
  18958. "featureType": "poi",
  18959. "stylers": [
  18960. {
  18961. "visibility": "off"
  18962. }
  18963. ]
  18964. },
  18965. {
  18966. "featureType": "poi",
  18967. "elementType": "labels.text.fill",
  18968. "stylers": [
  18969. {
  18970. "color": "#d59563"
  18971. }
  18972. ]
  18973. },
  18974. {
  18975. "featureType": "poi.park",
  18976. "elementType": "geometry",
  18977. "stylers": [
  18978. {
  18979. "color": "#263c3f"
  18980. }
  18981. ]
  18982. },
  18983. {
  18984. "featureType": "poi.park",
  18985. "elementType": "labels.text.fill",
  18986. "stylers": [
  18987. {
  18988. "color": "#6b9a76"
  18989. }
  18990. ]
  18991. },
  18992. {
  18993. "featureType": "road",
  18994. "elementType": "geometry",
  18995. "stylers": [
  18996. {
  18997. "color": "#38414e"
  18998. }
  18999. ]
  19000. },
  19001. {
  19002. "featureType": "road",
  19003. "elementType": "geometry.stroke",
  19004. "stylers": [
  19005. {
  19006. "color": "#212a37"
  19007. }
  19008. ]
  19009. },
  19010. {
  19011. "featureType": "road",
  19012. "elementType": "labels.icon",
  19013. "stylers": [
  19014. {
  19015. "visibility": "off"
  19016. }
  19017. ]
  19018. },
  19019. {
  19020. "featureType": "road",
  19021. "elementType": "labels.text.fill",
  19022. "stylers": [
  19023. {
  19024. "color": "#9ca5b3"
  19025. }
  19026. ]
  19027. },
  19028. {
  19029. "featureType": "road.highway",
  19030. "elementType": "geometry",
  19031. "stylers": [
  19032. {
  19033. "color": "#746855"
  19034. }
  19035. ]
  19036. },
  19037. {
  19038. "featureType": "road.highway",
  19039. "elementType": "geometry.stroke",
  19040. "stylers": [
  19041. {
  19042. "color": "#1f2835"
  19043. }
  19044. ]
  19045. },
  19046. {
  19047. "featureType": "road.highway",
  19048. "elementType": "labels.text.fill",
  19049. "stylers": [
  19050. {
  19051. "color": "#f3d19c"
  19052. }
  19053. ]
  19054. },
  19055. {
  19056. "featureType": "transit",
  19057. "stylers": [
  19058. {
  19059. "visibility": "off"
  19060. }
  19061. ]
  19062. },
  19063. {
  19064. "featureType": "transit",
  19065. "elementType": "geometry",
  19066. "stylers": [
  19067. {
  19068. "color": "#2f3948"
  19069. }
  19070. ]
  19071. },
  19072. {
  19073. "featureType": "transit.station",
  19074. "elementType": "labels.text.fill",
  19075. "stylers": [
  19076. {
  19077. "color": "#d59563"
  19078. }
  19079. ]
  19080. },
  19081. {
  19082. "featureType": "water",
  19083. "elementType": "geometry",
  19084. "stylers": [
  19085. {
  19086. "color": "#17263c"
  19087. }
  19088. ]
  19089. },
  19090. {
  19091. "featureType": "water",
  19092. "elementType": "labels.text.fill",
  19093. "stylers": [
  19094. {
  19095. "color": "#515c6d"
  19096. }
  19097. ]
  19098. },
  19099. {
  19100. "featureType": "water",
  19101. "elementType": "labels.text.stroke",
  19102. "stylers": [
  19103. {
  19104. "color": "#17263c"
  19105. }
  19106. ]
  19107. }
  19108. ]
  19109. // Aubergine Style
  19110. const Aubergine = [
  19111. {
  19112. "elementType": "geometry",
  19113. "stylers": [
  19114. {
  19115. "color": "#1d2c4d"
  19116. }
  19117. ]
  19118. },
  19119. {
  19120. "elementType": "labels.text.fill",
  19121. "stylers": [
  19122. {
  19123. "color": "#8ec3b9"
  19124. }
  19125. ]
  19126. },
  19127. {
  19128. "elementType": "labels.text.stroke",
  19129. "stylers": [
  19130. {
  19131. "color": "#1a3646"
  19132. }
  19133. ]
  19134. },
  19135. {
  19136. "featureType": "administrative",
  19137. "elementType": "geometry",
  19138. "stylers": [
  19139. {
  19140. "visibility": "off"
  19141. }
  19142. ]
  19143. },
  19144. {
  19145. "featureType": "administrative.country",
  19146. "elementType": "geometry.stroke",
  19147. "stylers": [
  19148. {
  19149. "color": "#4b6878"
  19150. }
  19151. ]
  19152. },
  19153. {
  19154. "featureType": "administrative.land_parcel",
  19155. "elementType": "labels.text.fill",
  19156. "stylers": [
  19157. {
  19158. "color": "#64779e"
  19159. }
  19160. ]
  19161. },
  19162. {
  19163. "featureType": "administrative.province",
  19164. "elementType": "geometry.stroke",
  19165. "stylers": [
  19166. {
  19167. "color": "#4b6878"
  19168. }
  19169. ]
  19170. },
  19171. {
  19172. "featureType": "landscape.man_made",
  19173. "elementType": "geometry.stroke",
  19174. "stylers": [
  19175. {
  19176. "color": "#334e87"
  19177. }
  19178. ]
  19179. },
  19180. {
  19181. "featureType": "landscape.natural",
  19182. "elementType": "geometry",
  19183. "stylers": [
  19184. {
  19185. "color": "#023e58"
  19186. }
  19187. ]
  19188. },
  19189. {
  19190. "featureType": "poi",
  19191. "stylers": [
  19192. {
  19193. "visibility": "off"
  19194. }
  19195. ]
  19196. },
  19197. {
  19198. "featureType": "poi",
  19199. "elementType": "geometry",
  19200. "stylers": [
  19201. {
  19202. "color": "#283d6a"
  19203. }
  19204. ]
  19205. },
  19206. {
  19207. "featureType": "poi",
  19208. "elementType": "labels.text.fill",
  19209. "stylers": [
  19210. {
  19211. "color": "#6f9ba5"
  19212. }
  19213. ]
  19214. },
  19215. {
  19216. "featureType": "poi",
  19217. "elementType": "labels.text.stroke",
  19218. "stylers": [
  19219. {
  19220. "color": "#1d2c4d"
  19221. }
  19222. ]
  19223. },
  19224. {
  19225. "featureType": "poi.park",
  19226. "elementType": "geometry.fill",
  19227. "stylers": [
  19228. {
  19229. "color": "#023e58"
  19230. }
  19231. ]
  19232. },
  19233. {
  19234. "featureType": "poi.park",
  19235. "elementType": "labels.text.fill",
  19236. "stylers": [
  19237. {
  19238. "color": "#3C7680"
  19239. }
  19240. ]
  19241. },
  19242. {
  19243. "featureType": "road",
  19244. "elementType": "geometry",
  19245. "stylers": [
  19246. {
  19247. "color": "#304a7d"
  19248. }
  19249. ]
  19250. },
  19251. {
  19252. "featureType": "road",
  19253. "elementType": "labels.icon",
  19254. "stylers": [
  19255. {
  19256. "visibility": "off"
  19257. }
  19258. ]
  19259. },
  19260. {
  19261. "featureType": "road",
  19262. "elementType": "labels.text.fill",
  19263. "stylers": [
  19264. {
  19265. "color": "#98a5be"
  19266. }
  19267. ]
  19268. },
  19269. {
  19270. "featureType": "road",
  19271. "elementType": "labels.text.stroke",
  19272. "stylers": [
  19273. {
  19274. "color": "#1d2c4d"
  19275. }
  19276. ]
  19277. },
  19278. {
  19279. "featureType": "road.highway",
  19280. "elementType": "geometry",
  19281. "stylers": [
  19282. {
  19283. "color": "#2c6675"
  19284. }
  19285. ]
  19286. },
  19287. {
  19288. "featureType": "road.highway",
  19289. "elementType": "geometry.stroke",
  19290. "stylers": [
  19291. {
  19292. "color": "#255763"
  19293. }
  19294. ]
  19295. },
  19296. {
  19297. "featureType": "road.highway",
  19298. "elementType": "labels.text.fill",
  19299. "stylers": [
  19300. {
  19301. "color": "#b0d5ce"
  19302. }
  19303. ]
  19304. },
  19305. {
  19306. "featureType": "road.highway",
  19307. "elementType": "labels.text.stroke",
  19308. "stylers": [
  19309. {
  19310. "color": "#023e58"
  19311. }
  19312. ]
  19313. },
  19314. {
  19315. "featureType": "transit",
  19316. "stylers": [
  19317. {
  19318. "visibility": "off"
  19319. }
  19320. ]
  19321. },
  19322. {
  19323. "featureType": "transit",
  19324. "elementType": "labels.text.fill",
  19325. "stylers": [
  19326. {
  19327. "color": "#98a5be"
  19328. }
  19329. ]
  19330. },
  19331. {
  19332. "featureType": "transit",
  19333. "elementType": "labels.text.stroke",
  19334. "stylers": [
  19335. {
  19336. "color": "#1d2c4d"
  19337. }
  19338. ]
  19339. },
  19340. {
  19341. "featureType": "transit.line",
  19342. "elementType": "geometry.fill",
  19343. "stylers": [
  19344. {
  19345. "color": "#283d6a"
  19346. }
  19347. ]
  19348. },
  19349. {
  19350. "featureType": "transit.station",
  19351. "elementType": "geometry",
  19352. "stylers": [
  19353. {
  19354. "color": "#3a4762"
  19355. }
  19356. ]
  19357. },
  19358. {
  19359. "featureType": "water",
  19360. "elementType": "geometry",
  19361. "stylers": [
  19362. {
  19363. "color": "#0e1626"
  19364. }
  19365. ]
  19366. },
  19367. {
  19368. "featureType": "water",
  19369. "elementType": "labels.text.fill",
  19370. "stylers": [
  19371. {
  19372. "color": "#4e6d70"
  19373. }
  19374. ]
  19375. }
  19376. ]
  19377. /*!
  19378. Crafto - Parallax
  19379. Created by ThemeZaa
  19380. !*/
  19381. !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);
  19382. /*!
  19383. Crafto - Parallax Liquid Image
  19384. Created by ThemeZaa
  19385. !*/
  19386. ! function(n) {
  19387. var t = n(window),
  19388. o = t.height();
  19389. t.resize(function() {
  19390. o = t.height()
  19391. }), n.fn.parallaxLiquidImg = function(i, scale, scaleFraction, reverse, e) {
  19392. var l, r = n(this);
  19393. var canScale = scale ? 1 : 0;
  19394. var scale = scale ? scale : 1.2;
  19395. var scaleFraction = scaleFraction ? scaleFraction : 0.001;
  19396. var lastScrollPos = 0;
  19397. var scrollDir = '';
  19398. const { animate } = anime;
  19399. function u() {
  19400. var e = t.scrollTop();
  19401. r.each(function() {
  19402. var t = n(this),
  19403. u = t.offset().top,
  19404. tHeight = t.outerHeight(),
  19405. uOffesetBottom = u + tHeight;
  19406. if(e > lastScrollPos) {
  19407. scrollDir = 'forward';
  19408. } else{
  19409. scrollDir = 'reverse';
  19410. }
  19411. lastScrollPos = e;
  19412. if (u < n(window).height()+e && uOffesetBottom > e) {
  19413. if (scrollDir == 'forward') {
  19414. scale = scale + scaleFraction;
  19415. } else {
  19416. scale = scale - scaleFraction;
  19417. }
  19418. }
  19419. if (reverse) {
  19420. if (t.attr('data-parallax-scale')) {
  19421. u + l(t) < e || u > e + o || (
  19422. n(window).width() > 1050
  19423. ? (animate(r[0],{translateY: i / 6 * (u - e) + "px", scale: canScale ? scale : 1}))
  19424. : r.css("transform", "translateY(0px)")
  19425. )
  19426. } else {
  19427. u + l(t) < e || u > e + o || (
  19428. n(window).width() > 1050
  19429. ? (animate(r[0],{translateY: i / 20 * -(u - e) + "px", scale: canScale ? scale : 1}))
  19430. : r.css("transform", "translateY(0px)")
  19431. )
  19432. }
  19433. } else {
  19434. if (t.attr('data-parallax-scale')) {
  19435. u + l(t) < e || u > e + o || (
  19436. n(window).width() > 1050
  19437. ? (animate(r[0],{ translateY: i / 6 * -(u - e) + "px", scale: canScale ? scale : 1}))
  19438. : r.css("transform", "translateY(0px)")
  19439. )
  19440. } else {
  19441. u + l(t) < e || u > e + o || (
  19442. n(window).width() > 1050
  19443. ? (animate(r[0],{translateY: i / 20 * (u - e) + "px", scale: canScale ? scale : 1}))
  19444. : r.css("transform", "translateY(0px)")
  19445. )
  19446. }
  19447. }
  19448. })
  19449. }(arguments.length < 1 || null === i) && (i = 1), (arguments.length < 2 || null === e) && (e = !0), l = e ? function(n) {
  19450. return n.outerHeight(!0)
  19451. } : function(n) {
  19452. return n.height()
  19453. }, t.bind("scroll", u).resize(u), u()
  19454. }
  19455. }(jQuery);
  19456. /*!
  19457. Particles
  19458. Version: 2.0.0
  19459. Plugin URL: https://vincentgarreau.com/particles.js/
  19460. License: Copyright Vincent Garreau - vincentgarreau.com | Licensed under MIT
  19461. !*/
  19462. var pJS = function(tag_id, params){
  19463. var canvas_el = document.querySelector('#'+tag_id+' > .particles-js-canvas-el');
  19464. /* particles.js variables with default values */
  19465. this.pJS = {
  19466. canvas: {
  19467. el: canvas_el,
  19468. w: canvas_el.offsetWidth,
  19469. h: canvas_el.offsetHeight
  19470. },
  19471. particles: {
  19472. number: {
  19473. value: 400,
  19474. density: {
  19475. enable: true,
  19476. value_area: 800
  19477. }
  19478. },
  19479. color: {
  19480. value: '#fff'
  19481. },
  19482. shape: {
  19483. type: 'circle',
  19484. stroke: {
  19485. width: 0,
  19486. color: '#ff0000'
  19487. },
  19488. polygon: {
  19489. nb_sides: 5
  19490. },
  19491. image: {
  19492. src: '',
  19493. width: 100,
  19494. height: 100
  19495. }
  19496. },
  19497. opacity: {
  19498. value: 1,
  19499. random: false,
  19500. anim: {
  19501. enable: false,
  19502. speed: 2,
  19503. opacity_min: 0,
  19504. sync: false
  19505. }
  19506. },
  19507. size: {
  19508. value: 20,
  19509. random: false,
  19510. anim: {
  19511. enable: false,
  19512. speed: 20,
  19513. size_min: 0,
  19514. sync: false
  19515. }
  19516. },
  19517. line_linked: {
  19518. enable: true,
  19519. distance: 100,
  19520. color: '#fff',
  19521. opacity: 1,
  19522. width: 1
  19523. },
  19524. move: {
  19525. enable: true,
  19526. speed: 2,
  19527. direction: 'none',
  19528. random: false,
  19529. straight: false,
  19530. out_mode: 'out',
  19531. bounce: false,
  19532. attract: {
  19533. enable: false,
  19534. rotateX: 3000,
  19535. rotateY: 3000
  19536. }
  19537. },
  19538. array: []
  19539. },
  19540. interactivity: {
  19541. detect_on: 'canvas',
  19542. events: {
  19543. onhover: {
  19544. enable: true,
  19545. mode: 'grab'
  19546. },
  19547. onclick: {
  19548. enable: true,
  19549. mode: 'push'
  19550. },
  19551. resize: true
  19552. },
  19553. modes: {
  19554. grab:{
  19555. distance: 100,
  19556. line_linked:{
  19557. opacity: 1
  19558. }
  19559. },
  19560. bubble:{
  19561. distance: 200,
  19562. size: 80,
  19563. duration: 0.4
  19564. },
  19565. repulse:{
  19566. distance: 200,
  19567. duration: 0.4
  19568. },
  19569. push:{
  19570. particles_nb: 4
  19571. },
  19572. remove:{
  19573. particles_nb: 2
  19574. }
  19575. },
  19576. mouse:{}
  19577. },
  19578. retina_detect: false,
  19579. fn: {
  19580. interact: {},
  19581. modes: {},
  19582. vendors:{}
  19583. },
  19584. tmp: {}
  19585. };
  19586. var pJS = this.pJS;
  19587. /* params settings */
  19588. if(params){
  19589. Object.deepExtend(pJS, params);
  19590. }
  19591. pJS.tmp.obj = {
  19592. size_value: pJS.particles.size.value,
  19593. size_anim_speed: pJS.particles.size.anim.speed,
  19594. move_speed: pJS.particles.move.speed,
  19595. line_linked_distance: pJS.particles.line_linked.distance,
  19596. line_linked_width: pJS.particles.line_linked.width,
  19597. mode_grab_distance: pJS.interactivity.modes.grab.distance,
  19598. mode_bubble_distance: pJS.interactivity.modes.bubble.distance,
  19599. mode_bubble_size: pJS.interactivity.modes.bubble.size,
  19600. mode_repulse_distance: pJS.interactivity.modes.repulse.distance
  19601. };
  19602. pJS.fn.retinaInit = function(){
  19603. if(pJS.retina_detect && window.devicePixelRatio > 1){
  19604. pJS.canvas.pxratio = window.devicePixelRatio;
  19605. pJS.tmp.retina = true;
  19606. }
  19607. else{
  19608. pJS.canvas.pxratio = 1;
  19609. pJS.tmp.retina = false;
  19610. }
  19611. pJS.canvas.w = pJS.canvas.el.offsetWidth * pJS.canvas.pxratio;
  19612. pJS.canvas.h = pJS.canvas.el.offsetHeight * pJS.canvas.pxratio;
  19613. pJS.particles.size.value = pJS.tmp.obj.size_value * pJS.canvas.pxratio;
  19614. pJS.particles.size.anim.speed = pJS.tmp.obj.size_anim_speed * pJS.canvas.pxratio;
  19615. pJS.particles.move.speed = pJS.tmp.obj.move_speed * pJS.canvas.pxratio;
  19616. pJS.particles.line_linked.distance = pJS.tmp.obj.line_linked_distance * pJS.canvas.pxratio;
  19617. pJS.interactivity.modes.grab.distance = pJS.tmp.obj.mode_grab_distance * pJS.canvas.pxratio;
  19618. pJS.interactivity.modes.bubble.distance = pJS.tmp.obj.mode_bubble_distance * pJS.canvas.pxratio;
  19619. pJS.particles.line_linked.width = pJS.tmp.obj.line_linked_width * pJS.canvas.pxratio;
  19620. pJS.interactivity.modes.bubble.size = pJS.tmp.obj.mode_bubble_size * pJS.canvas.pxratio;
  19621. pJS.interactivity.modes.repulse.distance = pJS.tmp.obj.mode_repulse_distance * pJS.canvas.pxratio;
  19622. };
  19623. /* ---------- pJS functions - canvas ------------ */
  19624. pJS.fn.canvasInit = function(){
  19625. pJS.canvas.ctx = pJS.canvas.el.getContext('2d');
  19626. };
  19627. pJS.fn.canvasSize = function(){
  19628. pJS.canvas.el.width = pJS.canvas.w;
  19629. pJS.canvas.el.height = pJS.canvas.h;
  19630. if(pJS && pJS.interactivity.events.resize){
  19631. window.addEventListener('resize', function(){
  19632. pJS.canvas.w = pJS.canvas.el.offsetWidth;
  19633. pJS.canvas.h = pJS.canvas.el.offsetHeight;
  19634. /* resize canvas */
  19635. if(pJS.tmp.retina){
  19636. pJS.canvas.w *= pJS.canvas.pxratio;
  19637. pJS.canvas.h *= pJS.canvas.pxratio;
  19638. }
  19639. pJS.canvas.el.width = pJS.canvas.w;
  19640. pJS.canvas.el.height = pJS.canvas.h;
  19641. /* repaint canvas on anim disabled */
  19642. if(!pJS.particles.move.enable){
  19643. pJS.fn.particlesEmpty();
  19644. pJS.fn.particlesCreate();
  19645. pJS.fn.particlesDraw();
  19646. pJS.fn.vendors.densityAutoParticles();
  19647. }
  19648. /* density particles enabled */
  19649. pJS.fn.vendors.densityAutoParticles();
  19650. });
  19651. }
  19652. };
  19653. pJS.fn.canvasPaint = function(){
  19654. pJS.canvas.ctx.fillRect(0, 0, pJS.canvas.w, pJS.canvas.h);
  19655. };
  19656. pJS.fn.canvasClear = function(){
  19657. pJS.canvas.ctx.clearRect(0, 0, pJS.canvas.w, pJS.canvas.h);
  19658. };
  19659. /* --------- pJS functions - particles ----------- */
  19660. pJS.fn.particle = function(color, opacity, position){
  19661. /* size */
  19662. this.radius = (pJS.particles.size.random ? Math.random() : 1) * pJS.particles.size.value;
  19663. if(pJS.particles.size.anim.enable){
  19664. this.size_status = false;
  19665. this.vs = pJS.particles.size.anim.speed / 100;
  19666. if(!pJS.particles.size.anim.sync){
  19667. this.vs = this.vs * Math.random();
  19668. }
  19669. }
  19670. /* position */
  19671. this.x = position ? position.x : Math.random() * pJS.canvas.w;
  19672. this.y = position ? position.y : Math.random() * pJS.canvas.h;
  19673. /* check position - into the canvas */
  19674. if(this.x > pJS.canvas.w - this.radius*2) this.x = this.x - this.radius;
  19675. else if(this.x < this.radius*2) this.x = this.x + this.radius;
  19676. if(this.y > pJS.canvas.h - this.radius*2) this.y = this.y - this.radius;
  19677. else if(this.y < this.radius*2) this.y = this.y + this.radius;
  19678. /* check position - avoid overlap */
  19679. if(pJS.particles.move.bounce){
  19680. pJS.fn.vendors.checkOverlap(this, position);
  19681. }
  19682. /* color */
  19683. this.color = {};
  19684. if(typeof(color.value) == 'object'){
  19685. if(color.value instanceof Array){
  19686. var color_selected = color.value[Math.floor(Math.random() * pJS.particles.color.value.length)];
  19687. this.color.rgb = hexToRgb(color_selected);
  19688. }else{
  19689. if(color.value.r != undefined && color.value.g != undefined && color.value.b != undefined){
  19690. this.color.rgb = {
  19691. r: color.value.r,
  19692. g: color.value.g,
  19693. b: color.value.b
  19694. }
  19695. }
  19696. if(color.value.h != undefined && color.value.s != undefined && color.value.l != undefined){
  19697. this.color.hsl = {
  19698. h: color.value.h,
  19699. s: color.value.s,
  19700. l: color.value.l
  19701. }
  19702. }
  19703. }
  19704. }
  19705. else if(color.value == 'random'){
  19706. this.color.rgb = {
  19707. r: (Math.floor(Math.random() * (255 - 0 + 1)) + 0),
  19708. g: (Math.floor(Math.random() * (255 - 0 + 1)) + 0),
  19709. b: (Math.floor(Math.random() * (255 - 0 + 1)) + 0)
  19710. }
  19711. }
  19712. else if(typeof(color.value) == 'string'){
  19713. this.color = color;
  19714. this.color.rgb = hexToRgb(this.color.value);
  19715. }
  19716. /* opacity */
  19717. this.opacity = (pJS.particles.opacity.random ? Math.random() : 1) * pJS.particles.opacity.value;
  19718. if(pJS.particles.opacity.anim.enable){
  19719. this.opacity_status = false;
  19720. this.vo = pJS.particles.opacity.anim.speed / 100;
  19721. if(!pJS.particles.opacity.anim.sync){
  19722. this.vo = this.vo * Math.random();
  19723. }
  19724. }
  19725. /* animation - velocity for speed */
  19726. var velbase = {}
  19727. switch(pJS.particles.move.direction){
  19728. case 'top':
  19729. velbase = { x:0, y:-1 };
  19730. break;
  19731. case 'top-right':
  19732. velbase = { x:0.5, y:-0.5 };
  19733. break;
  19734. case 'right':
  19735. velbase = { x:1, y:-0 };
  19736. break;
  19737. case 'bottom-right':
  19738. velbase = { x:0.5, y:0.5 };
  19739. break;
  19740. case 'bottom':
  19741. velbase = { x:0, y:1 };
  19742. break;
  19743. case 'bottom-left':
  19744. velbase = { x:-0.5, y:1 };
  19745. break;
  19746. case 'left':
  19747. velbase = { x:-1, y:0 };
  19748. break;
  19749. case 'top-left':
  19750. velbase = { x:-0.5, y:-0.5 };
  19751. break;
  19752. default:
  19753. velbase = { x:0, y:0 };
  19754. break;
  19755. }
  19756. if(pJS.particles.move.straight){
  19757. this.vx = velbase.x;
  19758. this.vy = velbase.y;
  19759. if(pJS.particles.move.random){
  19760. this.vx = this.vx * (Math.random());
  19761. this.vy = this.vy * (Math.random());
  19762. }
  19763. }else{
  19764. this.vx = velbase.x + Math.random()-0.5;
  19765. this.vy = velbase.y + Math.random()-0.5;
  19766. }
  19767. // var theta = 2.0 * Math.PI * Math.random();
  19768. // this.vx = Math.cos(theta);
  19769. // this.vy = Math.sin(theta);
  19770. this.vx_i = this.vx;
  19771. this.vy_i = this.vy;
  19772. /* if shape is image */
  19773. var shape_type = pJS.particles.shape.type;
  19774. if(typeof(shape_type) == 'object'){
  19775. if(shape_type instanceof Array){
  19776. var shape_selected = shape_type[Math.floor(Math.random() * shape_type.length)];
  19777. this.shape = shape_selected;
  19778. }
  19779. }else{
  19780. this.shape = shape_type;
  19781. }
  19782. if(this.shape == 'image'){
  19783. var sh = pJS.particles.shape;
  19784. this.img = {
  19785. src: sh.image.src,
  19786. ratio: sh.image.width / sh.image.height
  19787. }
  19788. if(!this.img.ratio) this.img.ratio = 1;
  19789. if(pJS.tmp.img_type == 'svg' && pJS.tmp.source_svg != undefined){
  19790. pJS.fn.vendors.createSvgImg(this);
  19791. if(pJS.tmp.pushing){
  19792. this.img.loaded = false;
  19793. }
  19794. }
  19795. }
  19796. };
  19797. pJS.fn.particle.prototype.draw = function() {
  19798. var p = this;
  19799. if(p.radius_bubble != undefined){
  19800. var radius = p.radius_bubble;
  19801. }else{
  19802. var radius = p.radius;
  19803. }
  19804. if(p.opacity_bubble != undefined){
  19805. var opacity = p.opacity_bubble;
  19806. }else{
  19807. var opacity = p.opacity;
  19808. }
  19809. if(p.color.rgb){
  19810. var color_value = 'rgba('+p.color.rgb.r+','+p.color.rgb.g+','+p.color.rgb.b+','+opacity+')';
  19811. }else{
  19812. var color_value = 'hsla('+p.color.hsl.h+','+p.color.hsl.s+'%,'+p.color.hsl.l+'%,'+opacity+')';
  19813. }
  19814. pJS.canvas.ctx.fillStyle = color_value;
  19815. pJS.canvas.ctx.beginPath();
  19816. switch(p.shape){
  19817. case 'circle':
  19818. pJS.canvas.ctx.arc(p.x, p.y, radius, 0, Math.PI * 2, false);
  19819. break;
  19820. case 'edge':
  19821. pJS.canvas.ctx.rect(p.x-radius, p.y-radius, radius*2, radius*2);
  19822. break;
  19823. case 'triangle':
  19824. pJS.fn.vendors.drawShape(pJS.canvas.ctx, p.x-radius, p.y+radius / 1.66, radius*2, 3, 2);
  19825. break;
  19826. case 'polygon':
  19827. pJS.fn.vendors.drawShape(
  19828. pJS.canvas.ctx,
  19829. p.x - radius / (pJS.particles.shape.polygon.nb_sides/3.5), // startX
  19830. p.y - radius / (2.66/3.5), // startY
  19831. radius*2.66 / (pJS.particles.shape.polygon.nb_sides/3), // sideLength
  19832. pJS.particles.shape.polygon.nb_sides, // sideCountNumerator
  19833. 1 // sideCountDenominator
  19834. );
  19835. break;
  19836. case 'star':
  19837. pJS.fn.vendors.drawShape(
  19838. pJS.canvas.ctx,
  19839. p.x - radius*2 / (pJS.particles.shape.polygon.nb_sides/4), // startX
  19840. p.y - radius / (2*2.66/3.5), // startY
  19841. radius*2*2.66 / (pJS.particles.shape.polygon.nb_sides/3), // sideLength
  19842. pJS.particles.shape.polygon.nb_sides, // sideCountNumerator
  19843. 2 // sideCountDenominator
  19844. );
  19845. break;
  19846. case 'image':
  19847. function draw(){
  19848. pJS.canvas.ctx.drawImage(
  19849. img_obj,
  19850. p.x-radius,
  19851. p.y-radius,
  19852. radius*2,
  19853. radius*2 / p.img.ratio
  19854. );
  19855. }
  19856. if(pJS.tmp.img_type == 'svg'){
  19857. var img_obj = p.img.obj;
  19858. }else{
  19859. var img_obj = pJS.tmp.img_obj;
  19860. }
  19861. if(img_obj){
  19862. draw();
  19863. }
  19864. break;
  19865. }
  19866. pJS.canvas.ctx.closePath();
  19867. if(pJS.particles.shape.stroke.width > 0){
  19868. pJS.canvas.ctx.strokeStyle = pJS.particles.shape.stroke.color;
  19869. pJS.canvas.ctx.lineWidth = pJS.particles.shape.stroke.width;
  19870. pJS.canvas.ctx.stroke();
  19871. }
  19872. pJS.canvas.ctx.fill();
  19873. };
  19874. pJS.fn.particlesCreate = function(){
  19875. for(var i = 0; i < pJS.particles.number.value; i++) {
  19876. pJS.particles.array.push(new pJS.fn.particle(pJS.particles.color, pJS.particles.opacity.value));
  19877. }
  19878. };
  19879. pJS.fn.particlesUpdate = function(){
  19880. for(var i = 0; i < pJS.particles.array.length; i++){
  19881. /* the particle */
  19882. var p = pJS.particles.array[i];
  19883. // var d = ( dx = pJS.interactivity.mouse.click_pos_x - p.x ) * dx + ( dy = pJS.interactivity.mouse.click_pos_y - p.y ) * dy;
  19884. // var f = -BANG_SIZE / d;
  19885. // if ( d < BANG_SIZE ) {
  19886. // var t = Math.atan2( dy, dx );
  19887. // p.vx = f * Math.cos(t);
  19888. // p.vy = f * Math.sin(t);
  19889. // }
  19890. /* move the particle */
  19891. if(pJS.particles.move.enable){
  19892. var ms = pJS.particles.move.speed/2;
  19893. p.x += p.vx * ms;
  19894. p.y += p.vy * ms;
  19895. }
  19896. /* change opacity status */
  19897. if(pJS.particles.opacity.anim.enable) {
  19898. if(p.opacity_status == true) {
  19899. if(p.opacity >= pJS.particles.opacity.value) p.opacity_status = false;
  19900. p.opacity += p.vo;
  19901. }else {
  19902. if(p.opacity <= pJS.particles.opacity.anim.opacity_min) p.opacity_status = true;
  19903. p.opacity -= p.vo;
  19904. }
  19905. if(p.opacity < 0) p.opacity = 0;
  19906. }
  19907. /* change size */
  19908. if(pJS.particles.size.anim.enable){
  19909. if(p.size_status == true){
  19910. if(p.radius >= pJS.particles.size.value) p.size_status = false;
  19911. p.radius += p.vs;
  19912. }else{
  19913. if(p.radius <= pJS.particles.size.anim.size_min) p.size_status = true;
  19914. p.radius -= p.vs;
  19915. }
  19916. if(p.radius < 0) p.radius = 0;
  19917. }
  19918. /* change particle position if it is out of canvas */
  19919. if(pJS.particles.move.out_mode == 'bounce'){
  19920. var new_pos = {
  19921. x_left: p.radius,
  19922. x_right: pJS.canvas.w,
  19923. y_top: p.radius,
  19924. y_bottom: pJS.canvas.h
  19925. }
  19926. }else{
  19927. var new_pos = {
  19928. x_left: -p.radius,
  19929. x_right: pJS.canvas.w + p.radius,
  19930. y_top: -p.radius,
  19931. y_bottom: pJS.canvas.h + p.radius
  19932. }
  19933. }
  19934. if(p.x - p.radius > pJS.canvas.w){
  19935. p.x = new_pos.x_left;
  19936. p.y = Math.random() * pJS.canvas.h;
  19937. }
  19938. else if(p.x + p.radius < 0){
  19939. p.x = new_pos.x_right;
  19940. p.y = Math.random() * pJS.canvas.h;
  19941. }
  19942. if(p.y - p.radius > pJS.canvas.h){
  19943. p.y = new_pos.y_top;
  19944. p.x = Math.random() * pJS.canvas.w;
  19945. }
  19946. else if(p.y + p.radius < 0){
  19947. p.y = new_pos.y_bottom;
  19948. p.x = Math.random() * pJS.canvas.w;
  19949. }
  19950. /* out of canvas modes */
  19951. switch(pJS.particles.move.out_mode){
  19952. case 'bounce':
  19953. if (p.x + p.radius > pJS.canvas.w) p.vx = -p.vx;
  19954. else if (p.x - p.radius < 0) p.vx = -p.vx;
  19955. if (p.y + p.radius > pJS.canvas.h) p.vy = -p.vy;
  19956. else if (p.y - p.radius < 0) p.vy = -p.vy;
  19957. break;
  19958. }
  19959. /* events */
  19960. if(isInArray('grab', pJS.interactivity.events.onhover.mode)){
  19961. pJS.fn.modes.grabParticle(p);
  19962. }
  19963. if(isInArray('bubble', pJS.interactivity.events.onhover.mode) || isInArray('bubble', pJS.interactivity.events.onclick.mode)){
  19964. pJS.fn.modes.bubbleParticle(p);
  19965. }
  19966. if(isInArray('repulse', pJS.interactivity.events.onhover.mode) || isInArray('repulse', pJS.interactivity.events.onclick.mode)){
  19967. pJS.fn.modes.repulseParticle(p);
  19968. }
  19969. /* interaction auto between particles */
  19970. if(pJS.particles.line_linked.enable || pJS.particles.move.attract.enable){
  19971. for(var j = i + 1; j < pJS.particles.array.length; j++){
  19972. var p2 = pJS.particles.array[j];
  19973. /* link particles */
  19974. if(pJS.particles.line_linked.enable){
  19975. pJS.fn.interact.linkParticles(p,p2);
  19976. }
  19977. /* attract particles */
  19978. if(pJS.particles.move.attract.enable){
  19979. pJS.fn.interact.attractParticles(p,p2);
  19980. }
  19981. /* bounce particles */
  19982. if(pJS.particles.move.bounce){
  19983. pJS.fn.interact.bounceParticles(p,p2);
  19984. }
  19985. }
  19986. }
  19987. }
  19988. };
  19989. pJS.fn.particlesDraw = function(){
  19990. /* clear canvas */
  19991. pJS.canvas.ctx.clearRect(0, 0, pJS.canvas.w, pJS.canvas.h);
  19992. /* update each particles param */
  19993. pJS.fn.particlesUpdate();
  19994. /* draw each particle */
  19995. for(var i = 0; i < pJS.particles.array.length; i++){
  19996. var p = pJS.particles.array[i];
  19997. p.draw();
  19998. }
  19999. };
  20000. pJS.fn.particlesEmpty = function(){
  20001. pJS.particles.array = [];
  20002. };
  20003. pJS.fn.particlesRefresh = function(){
  20004. /* init all */
  20005. cancelRequestAnimFrame(pJS.fn.checkAnimFrame);
  20006. cancelRequestAnimFrame(pJS.fn.drawAnimFrame);
  20007. pJS.tmp.source_svg = undefined;
  20008. pJS.tmp.img_obj = undefined;
  20009. pJS.tmp.count_svg = 0;
  20010. pJS.fn.particlesEmpty();
  20011. pJS.fn.canvasClear();
  20012. /* restart */
  20013. pJS.fn.vendors.start();
  20014. };
  20015. /* ---------- pJS functions - particles interaction ------------ */
  20016. pJS.fn.interact.linkParticles = function(p1, p2){
  20017. var dx = p1.x - p2.x,
  20018. dy = p1.y - p2.y,
  20019. dist = Math.sqrt(dx*dx + dy*dy);
  20020. /* draw a line between p1 and p2 if the distance between them is under the config distance */
  20021. if(dist <= pJS.particles.line_linked.distance){
  20022. var opacity_line = pJS.particles.line_linked.opacity - (dist / (1/pJS.particles.line_linked.opacity)) / pJS.particles.line_linked.distance;
  20023. if(opacity_line > 0){
  20024. /* style */
  20025. var color_line = pJS.particles.line_linked.color_rgb_line;
  20026. pJS.canvas.ctx.strokeStyle = 'rgba('+color_line.r+','+color_line.g+','+color_line.b+','+opacity_line+')';
  20027. pJS.canvas.ctx.lineWidth = pJS.particles.line_linked.width;
  20028. //pJS.canvas.ctx.lineCap = 'round'; /* performance issue */
  20029. /* path */
  20030. pJS.canvas.ctx.beginPath();
  20031. pJS.canvas.ctx.moveTo(p1.x, p1.y);
  20032. pJS.canvas.ctx.lineTo(p2.x, p2.y);
  20033. pJS.canvas.ctx.stroke();
  20034. pJS.canvas.ctx.closePath();
  20035. }
  20036. }
  20037. };
  20038. pJS.fn.interact.attractParticles = function(p1, p2){
  20039. /* condensed particles */
  20040. var dx = p1.x - p2.x,
  20041. dy = p1.y - p2.y,
  20042. dist = Math.sqrt(dx*dx + dy*dy);
  20043. if(dist <= pJS.particles.line_linked.distance){
  20044. var ax = dx/(pJS.particles.move.attract.rotateX*1000),
  20045. ay = dy/(pJS.particles.move.attract.rotateY*1000);
  20046. p1.vx -= ax;
  20047. p1.vy -= ay;
  20048. p2.vx += ax;
  20049. p2.vy += ay;
  20050. }
  20051. }
  20052. pJS.fn.interact.bounceParticles = function(p1, p2){
  20053. var dx = p1.x - p2.x,
  20054. dy = p1.y - p2.y,
  20055. dist = Math.sqrt(dx*dx + dy*dy),
  20056. dist_p = p1.radius+p2.radius;
  20057. if(dist <= dist_p){
  20058. p1.vx = -p1.vx;
  20059. p1.vy = -p1.vy;
  20060. p2.vx = -p2.vx;
  20061. p2.vy = -p2.vy;
  20062. }
  20063. }
  20064. /* ---------- pJS functions - modes events ------------ */
  20065. pJS.fn.modes.pushParticles = function(nb, pos){
  20066. pJS.tmp.pushing = true;
  20067. for(var i = 0; i < nb; i++){
  20068. pJS.particles.array.push(
  20069. new pJS.fn.particle(
  20070. pJS.particles.color,
  20071. pJS.particles.opacity.value,
  20072. {
  20073. 'x': pos ? pos.pos_x : Math.random() * pJS.canvas.w,
  20074. 'y': pos ? pos.pos_y : Math.random() * pJS.canvas.h
  20075. }
  20076. )
  20077. )
  20078. if(i == nb-1){
  20079. if(!pJS.particles.move.enable){
  20080. pJS.fn.particlesDraw();
  20081. }
  20082. pJS.tmp.pushing = false;
  20083. }
  20084. }
  20085. };
  20086. pJS.fn.modes.removeParticles = function(nb){
  20087. pJS.particles.array.splice(0, nb);
  20088. if(!pJS.particles.move.enable){
  20089. pJS.fn.particlesDraw();
  20090. }
  20091. };
  20092. pJS.fn.modes.bubbleParticle = function(p){
  20093. /* on hover event */
  20094. if(pJS.interactivity.events.onhover.enable && isInArray('bubble', pJS.interactivity.events.onhover.mode)){
  20095. var dx_mouse = p.x - pJS.interactivity.mouse.pos_x,
  20096. dy_mouse = p.y - pJS.interactivity.mouse.pos_y,
  20097. dist_mouse = Math.sqrt(dx_mouse*dx_mouse + dy_mouse*dy_mouse),
  20098. ratio = 1 - dist_mouse / pJS.interactivity.modes.bubble.distance;
  20099. function init(){
  20100. p.opacity_bubble = p.opacity;
  20101. p.radius_bubble = p.radius;
  20102. }
  20103. /* mousemove - check ratio */
  20104. if(dist_mouse <= pJS.interactivity.modes.bubble.distance){
  20105. if(ratio >= 0 && pJS.interactivity.status == 'mousemove'){
  20106. /* size */
  20107. if(pJS.interactivity.modes.bubble.size != pJS.particles.size.value){
  20108. if(pJS.interactivity.modes.bubble.size > pJS.particles.size.value){
  20109. var size = p.radius + (pJS.interactivity.modes.bubble.size*ratio);
  20110. if(size >= 0){
  20111. p.radius_bubble = size;
  20112. }
  20113. }else{
  20114. var dif = p.radius - pJS.interactivity.modes.bubble.size,
  20115. size = p.radius - (dif*ratio);
  20116. if(size > 0){
  20117. p.radius_bubble = size;
  20118. }else{
  20119. p.radius_bubble = 0;
  20120. }
  20121. }
  20122. }
  20123. /* opacity */
  20124. if(pJS.interactivity.modes.bubble.opacity != pJS.particles.opacity.value){
  20125. if(pJS.interactivity.modes.bubble.opacity > pJS.particles.opacity.value){
  20126. var opacity = pJS.interactivity.modes.bubble.opacity*ratio;
  20127. if(opacity > p.opacity && opacity <= pJS.interactivity.modes.bubble.opacity){
  20128. p.opacity_bubble = opacity;
  20129. }
  20130. }else{
  20131. var opacity = p.opacity - (pJS.particles.opacity.value-pJS.interactivity.modes.bubble.opacity)*ratio;
  20132. if(opacity < p.opacity && opacity >= pJS.interactivity.modes.bubble.opacity){
  20133. p.opacity_bubble = opacity;
  20134. }
  20135. }
  20136. }
  20137. }
  20138. }else{
  20139. init();
  20140. }
  20141. /* mouseleave */
  20142. if(pJS.interactivity.status == 'mouseleave'){
  20143. init();
  20144. }
  20145. }
  20146. /* on click event */
  20147. else if(pJS.interactivity.events.onclick.enable && isInArray('bubble', pJS.interactivity.events.onclick.mode)){
  20148. if(pJS.tmp.bubble_clicking){
  20149. var dx_mouse = p.x - pJS.interactivity.mouse.click_pos_x,
  20150. dy_mouse = p.y - pJS.interactivity.mouse.click_pos_y,
  20151. dist_mouse = Math.sqrt(dx_mouse*dx_mouse + dy_mouse*dy_mouse),
  20152. time_spent = (new Date().getTime() - pJS.interactivity.mouse.click_time)/1000;
  20153. if(time_spent > pJS.interactivity.modes.bubble.duration){
  20154. pJS.tmp.bubble_duration_end = true;
  20155. }
  20156. if(time_spent > pJS.interactivity.modes.bubble.duration*2){
  20157. pJS.tmp.bubble_clicking = false;
  20158. pJS.tmp.bubble_duration_end = false;
  20159. }
  20160. }
  20161. function process(bubble_param, particles_param, p_obj_bubble, p_obj, id){
  20162. if(bubble_param != particles_param){
  20163. if(!pJS.tmp.bubble_duration_end){
  20164. if(dist_mouse <= pJS.interactivity.modes.bubble.distance){
  20165. if(p_obj_bubble != undefined) var obj = p_obj_bubble;
  20166. else var obj = p_obj;
  20167. if(obj != bubble_param){
  20168. var value = p_obj - (time_spent * (p_obj - bubble_param) / pJS.interactivity.modes.bubble.duration);
  20169. if(id == 'size') p.radius_bubble = value;
  20170. if(id == 'opacity') p.opacity_bubble = value;
  20171. }
  20172. }else{
  20173. if(id == 'size') p.radius_bubble = undefined;
  20174. if(id == 'opacity') p.opacity_bubble = undefined;
  20175. }
  20176. }else{
  20177. if(p_obj_bubble != undefined){
  20178. var value_tmp = p_obj - (time_spent * (p_obj - bubble_param) / pJS.interactivity.modes.bubble.duration),
  20179. dif = bubble_param - value_tmp;
  20180. value = bubble_param + dif;
  20181. if(id == 'size') p.radius_bubble = value;
  20182. if(id == 'opacity') p.opacity_bubble = value;
  20183. }
  20184. }
  20185. }
  20186. }
  20187. if(pJS.tmp.bubble_clicking){
  20188. /* size */
  20189. process(pJS.interactivity.modes.bubble.size, pJS.particles.size.value, p.radius_bubble, p.radius, 'size');
  20190. /* opacity */
  20191. process(pJS.interactivity.modes.bubble.opacity, pJS.particles.opacity.value, p.opacity_bubble, p.opacity, 'opacity');
  20192. }
  20193. }
  20194. };
  20195. pJS.fn.modes.repulseParticle = function(p){
  20196. if(pJS.interactivity.events.onhover.enable && isInArray('repulse', pJS.interactivity.events.onhover.mode) && pJS.interactivity.status == 'mousemove') {
  20197. var dx_mouse = p.x - pJS.interactivity.mouse.pos_x,
  20198. dy_mouse = p.y - pJS.interactivity.mouse.pos_y,
  20199. dist_mouse = Math.sqrt(dx_mouse*dx_mouse + dy_mouse*dy_mouse);
  20200. var normVec = {x: dx_mouse/dist_mouse, y: dy_mouse/dist_mouse},
  20201. repulseRadius = pJS.interactivity.modes.repulse.distance,
  20202. velocity = 100,
  20203. repulseFactor = clamp((1/repulseRadius)*(-1*Math.pow(dist_mouse/repulseRadius,2)+1)*repulseRadius*velocity, 0, 50);
  20204. var pos = {
  20205. x: p.x + normVec.x * repulseFactor,
  20206. y: p.y + normVec.y * repulseFactor
  20207. }
  20208. if(pJS.particles.move.out_mode == 'bounce'){
  20209. if(pos.x - p.radius > 0 && pos.x + p.radius < pJS.canvas.w) p.x = pos.x;
  20210. if(pos.y - p.radius > 0 && pos.y + p.radius < pJS.canvas.h) p.y = pos.y;
  20211. }else{
  20212. p.x = pos.x;
  20213. p.y = pos.y;
  20214. }
  20215. }
  20216. else if(pJS.interactivity.events.onclick.enable && isInArray('repulse', pJS.interactivity.events.onclick.mode)) {
  20217. if(!pJS.tmp.repulse_finish){
  20218. pJS.tmp.repulse_count++;
  20219. if(pJS.tmp.repulse_count == pJS.particles.array.length){
  20220. pJS.tmp.repulse_finish = true;
  20221. }
  20222. }
  20223. if(pJS.tmp.repulse_clicking){
  20224. var repulseRadius = Math.pow(pJS.interactivity.modes.repulse.distance/6, 3);
  20225. var dx = pJS.interactivity.mouse.click_pos_x - p.x,
  20226. dy = pJS.interactivity.mouse.click_pos_y - p.y,
  20227. d = dx*dx + dy*dy;
  20228. var force = -repulseRadius / d * 1;
  20229. function process(){
  20230. var f = Math.atan2(dy,dx);
  20231. p.vx = force * Math.cos(f);
  20232. p.vy = force * Math.sin(f);
  20233. if(pJS.particles.move.out_mode == 'bounce'){
  20234. var pos = {
  20235. x: p.x + p.vx,
  20236. y: p.y + p.vy
  20237. }
  20238. if (pos.x + p.radius > pJS.canvas.w) p.vx = -p.vx;
  20239. else if (pos.x - p.radius < 0) p.vx = -p.vx;
  20240. if (pos.y + p.radius > pJS.canvas.h) p.vy = -p.vy;
  20241. else if (pos.y - p.radius < 0) p.vy = -p.vy;
  20242. }
  20243. }
  20244. // default
  20245. if(d <= repulseRadius){
  20246. process();
  20247. }
  20248. // bang - slow motion mode
  20249. // if(!pJS.tmp.repulse_finish){
  20250. // if(d <= repulseRadius){
  20251. // process();
  20252. // }
  20253. // }else{
  20254. // process();
  20255. // }
  20256. }else{
  20257. if(pJS.tmp.repulse_clicking == false){
  20258. p.vx = p.vx_i;
  20259. p.vy = p.vy_i;
  20260. }
  20261. }
  20262. }
  20263. }
  20264. pJS.fn.modes.grabParticle = function(p){
  20265. if(pJS.interactivity.events.onhover.enable && pJS.interactivity.status == 'mousemove'){
  20266. var dx_mouse = p.x - pJS.interactivity.mouse.pos_x,
  20267. dy_mouse = p.y - pJS.interactivity.mouse.pos_y,
  20268. dist_mouse = Math.sqrt(dx_mouse*dx_mouse + dy_mouse*dy_mouse);
  20269. /* draw a line between the cursor and the particle if the distance between them is under the config distance */
  20270. if(dist_mouse <= pJS.interactivity.modes.grab.distance){
  20271. 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;
  20272. if(opacity_line > 0){
  20273. /* style */
  20274. var color_line = pJS.particles.line_linked.color_rgb_line;
  20275. pJS.canvas.ctx.strokeStyle = 'rgba('+color_line.r+','+color_line.g+','+color_line.b+','+opacity_line+')';
  20276. pJS.canvas.ctx.lineWidth = pJS.particles.line_linked.width;
  20277. //pJS.canvas.ctx.lineCap = 'round'; /* performance issue */
  20278. /* path */
  20279. pJS.canvas.ctx.beginPath();
  20280. pJS.canvas.ctx.moveTo(p.x, p.y);
  20281. pJS.canvas.ctx.lineTo(pJS.interactivity.mouse.pos_x, pJS.interactivity.mouse.pos_y);
  20282. pJS.canvas.ctx.stroke();
  20283. pJS.canvas.ctx.closePath();
  20284. }
  20285. }
  20286. }
  20287. };
  20288. /* ---------- pJS functions - vendors ------------ */
  20289. pJS.fn.vendors.eventsListeners = function(){
  20290. /* events target element */
  20291. if(pJS.interactivity.detect_on == 'window'){
  20292. pJS.interactivity.el = window;
  20293. }else{
  20294. pJS.interactivity.el = pJS.canvas.el;
  20295. }
  20296. /* detect mouse pos - on hover / click event */
  20297. if(pJS.interactivity.events.onhover.enable || pJS.interactivity.events.onclick.enable){
  20298. /* el on mousemove */
  20299. pJS.interactivity.el.addEventListener('mousemove', function(e){
  20300. if(pJS.interactivity.el == window){
  20301. var pos_x = e.clientX,
  20302. pos_y = e.clientY;
  20303. }
  20304. else{
  20305. var pos_x = e.offsetX || e.clientX,
  20306. pos_y = e.offsetY || e.clientY;
  20307. }
  20308. pJS.interactivity.mouse.pos_x = pos_x;
  20309. pJS.interactivity.mouse.pos_y = pos_y;
  20310. if(pJS.tmp.retina){
  20311. pJS.interactivity.mouse.pos_x *= pJS.canvas.pxratio;
  20312. pJS.interactivity.mouse.pos_y *= pJS.canvas.pxratio;
  20313. }
  20314. pJS.interactivity.status = 'mousemove';
  20315. });
  20316. /* el on onmouseleave */
  20317. pJS.interactivity.el.addEventListener('mouseleave', function(e){
  20318. pJS.interactivity.mouse.pos_x = null;
  20319. pJS.interactivity.mouse.pos_y = null;
  20320. pJS.interactivity.status = 'mouseleave';
  20321. });
  20322. }
  20323. /* on click event */
  20324. if(pJS.interactivity.events.onclick.enable){
  20325. pJS.interactivity.el.addEventListener('click', function(){
  20326. pJS.interactivity.mouse.click_pos_x = pJS.interactivity.mouse.pos_x;
  20327. pJS.interactivity.mouse.click_pos_y = pJS.interactivity.mouse.pos_y;
  20328. pJS.interactivity.mouse.click_time = new Date().getTime();
  20329. if(pJS.interactivity.events.onclick.enable){
  20330. switch(pJS.interactivity.events.onclick.mode){
  20331. case 'push':
  20332. if(pJS.particles.move.enable){
  20333. pJS.fn.modes.pushParticles(pJS.interactivity.modes.push.particles_nb, pJS.interactivity.mouse);
  20334. }else{
  20335. if(pJS.interactivity.modes.push.particles_nb == 1){
  20336. pJS.fn.modes.pushParticles(pJS.interactivity.modes.push.particles_nb, pJS.interactivity.mouse);
  20337. }
  20338. else if(pJS.interactivity.modes.push.particles_nb > 1){
  20339. pJS.fn.modes.pushParticles(pJS.interactivity.modes.push.particles_nb);
  20340. }
  20341. }
  20342. break;
  20343. case 'remove':
  20344. pJS.fn.modes.removeParticles(pJS.interactivity.modes.remove.particles_nb);
  20345. break;
  20346. case 'bubble':
  20347. pJS.tmp.bubble_clicking = true;
  20348. break;
  20349. case 'repulse':
  20350. pJS.tmp.repulse_clicking = true;
  20351. pJS.tmp.repulse_count = 0;
  20352. pJS.tmp.repulse_finish = false;
  20353. setTimeout(function(){
  20354. pJS.tmp.repulse_clicking = false;
  20355. }, pJS.interactivity.modes.repulse.duration*1000)
  20356. break;
  20357. }
  20358. }
  20359. });
  20360. }
  20361. };
  20362. pJS.fn.vendors.densityAutoParticles = function(){
  20363. if(pJS.particles.number.density.enable){
  20364. /* calc area */
  20365. var area = pJS.canvas.el.width * pJS.canvas.el.height / 1000;
  20366. if(pJS.tmp.retina){
  20367. area = area/(pJS.canvas.pxratio*2);
  20368. }
  20369. /* calc number of particles based on density area */
  20370. var nb_particles = area * pJS.particles.number.value / pJS.particles.number.density.value_area;
  20371. /* add or remove X particles */
  20372. var missing_particles = pJS.particles.array.length - nb_particles;
  20373. if(missing_particles < 0) pJS.fn.modes.pushParticles(Math.abs(missing_particles));
  20374. else pJS.fn.modes.removeParticles(missing_particles);
  20375. }
  20376. };
  20377. pJS.fn.vendors.checkOverlap = function(p1, position){
  20378. for(var i = 0; i < pJS.particles.array.length; i++){
  20379. var p2 = pJS.particles.array[i];
  20380. var dx = p1.x - p2.x,
  20381. dy = p1.y - p2.y,
  20382. dist = Math.sqrt(dx*dx + dy*dy);
  20383. if(dist <= p1.radius + p2.radius){
  20384. p1.x = position ? position.x : Math.random() * pJS.canvas.w;
  20385. p1.y = position ? position.y : Math.random() * pJS.canvas.h;
  20386. pJS.fn.vendors.checkOverlap(p1);
  20387. }
  20388. }
  20389. };
  20390. pJS.fn.vendors.createSvgImg = function(p){
  20391. /* set color to svg element */
  20392. var svgXml = pJS.tmp.source_svg,
  20393. rgbHex = /#([0-9A-F]{3,6})/gi,
  20394. coloredSvgXml = svgXml.replace(rgbHex, function (m, r, g, b) {
  20395. if(p.color.rgb){
  20396. var color_value = 'rgba('+p.color.rgb.r+','+p.color.rgb.g+','+p.color.rgb.b+','+p.opacity+')';
  20397. }else{
  20398. var color_value = 'hsla('+p.color.hsl.h+','+p.color.hsl.s+'%,'+p.color.hsl.l+'%,'+p.opacity+')';
  20399. }
  20400. return color_value;
  20401. });
  20402. /* prepare to create img with colored svg */
  20403. var svg = new Blob([coloredSvgXml], {type: 'image/svg+xml;charset=utf-8'}),
  20404. DOMURL = window.URL || window.webkitURL || window,
  20405. url = DOMURL.createObjectURL(svg);
  20406. /* create particle img obj */
  20407. var img = new Image();
  20408. img.addEventListener('load', function(){
  20409. p.img.obj = img;
  20410. p.img.loaded = true;
  20411. DOMURL.revokeObjectURL(url);
  20412. pJS.tmp.count_svg++;
  20413. });
  20414. img.src = url;
  20415. };
  20416. pJS.fn.vendors.destroypJS = function(){
  20417. cancelAnimationFrame(pJS.fn.drawAnimFrame);
  20418. canvas_el.remove();
  20419. pJSDom = null;
  20420. };
  20421. pJS.fn.vendors.drawShape = function(c, startX, startY, sideLength, sideCountNumerator, sideCountDenominator){
  20422. // By Programming Thomas - https://programmingthomas.wordpress.com/2013/04/03/n-sided-shapes/
  20423. var sideCount = sideCountNumerator * sideCountDenominator;
  20424. var decimalSides = sideCountNumerator / sideCountDenominator;
  20425. var interiorAngleDegrees = (180 * (decimalSides - 2)) / decimalSides;
  20426. var interiorAngle = Math.PI - Math.PI * interiorAngleDegrees / 180; // convert to radians
  20427. c.save();
  20428. c.beginPath();
  20429. c.translate(startX, startY);
  20430. c.moveTo(0,0);
  20431. for (var i = 0; i < sideCount; i++) {
  20432. c.lineTo(sideLength,0);
  20433. c.translate(sideLength,0);
  20434. c.rotate(interiorAngle);
  20435. }
  20436. //c.stroke();
  20437. c.fill();
  20438. c.restore();
  20439. };
  20440. pJS.fn.vendors.exportImg = function(){
  20441. window.open(pJS.canvas.el.toDataURL('image/png'), '_blank');
  20442. };
  20443. pJS.fn.vendors.loadImg = function(type){
  20444. pJS.tmp.img_error = undefined;
  20445. if(pJS.particles.shape.image.src != ''){
  20446. if(type == 'svg'){
  20447. var xhr = new XMLHttpRequest();
  20448. xhr.open('GET', pJS.particles.shape.image.src);
  20449. xhr.onreadystatechange = function (data) {
  20450. if(xhr.readyState == 4){
  20451. if(xhr.status == 200){
  20452. pJS.tmp.source_svg = data.currentTarget.response;
  20453. pJS.fn.vendors.checkBeforeDraw();
  20454. }else{
  20455. console.log('Error pJS - Image not found');
  20456. pJS.tmp.img_error = true;
  20457. }
  20458. }
  20459. }
  20460. xhr.send();
  20461. }else{
  20462. var img = new Image();
  20463. img.addEventListener('load', function(){
  20464. pJS.tmp.img_obj = img;
  20465. pJS.fn.vendors.checkBeforeDraw();
  20466. });
  20467. img.src = pJS.particles.shape.image.src;
  20468. }
  20469. }else{
  20470. console.log('Error pJS - No image.src');
  20471. pJS.tmp.img_error = true;
  20472. }
  20473. };
  20474. pJS.fn.vendors.draw = function(){
  20475. if(pJS.particles.shape.type == 'image'){
  20476. if(pJS.tmp.img_type == 'svg'){
  20477. if(pJS.tmp.count_svg >= pJS.particles.number.value){
  20478. pJS.fn.particlesDraw();
  20479. if(!pJS.particles.move.enable) cancelRequestAnimFrame(pJS.fn.drawAnimFrame);
  20480. else pJS.fn.drawAnimFrame = requestAnimFrame(pJS.fn.vendors.draw);
  20481. }else{
  20482. //console.log('still loading...');
  20483. if(!pJS.tmp.img_error) pJS.fn.drawAnimFrame = requestAnimFrame(pJS.fn.vendors.draw);
  20484. }
  20485. }else{
  20486. if(pJS.tmp.img_obj != undefined){
  20487. pJS.fn.particlesDraw();
  20488. if(!pJS.particles.move.enable) cancelRequestAnimFrame(pJS.fn.drawAnimFrame);
  20489. else pJS.fn.drawAnimFrame = requestAnimFrame(pJS.fn.vendors.draw);
  20490. }else{
  20491. if(!pJS.tmp.img_error) pJS.fn.drawAnimFrame = requestAnimFrame(pJS.fn.vendors.draw);
  20492. }
  20493. }
  20494. }else{
  20495. pJS.fn.particlesDraw();
  20496. if(!pJS.particles.move.enable) cancelRequestAnimFrame(pJS.fn.drawAnimFrame);
  20497. else pJS.fn.drawAnimFrame = requestAnimFrame(pJS.fn.vendors.draw);
  20498. }
  20499. };
  20500. pJS.fn.vendors.checkBeforeDraw = function(){
  20501. // if shape is image
  20502. if(pJS.particles.shape.type == 'image'){
  20503. if(pJS.tmp.img_type == 'svg' && pJS.tmp.source_svg == undefined){
  20504. pJS.tmp.checkAnimFrame = requestAnimFrame(check);
  20505. }else{
  20506. //console.log('images loaded! cancel check');
  20507. cancelRequestAnimFrame(pJS.tmp.checkAnimFrame);
  20508. if(!pJS.tmp.img_error){
  20509. pJS.fn.vendors.init();
  20510. pJS.fn.vendors.draw();
  20511. }
  20512. }
  20513. }else{
  20514. pJS.fn.vendors.init();
  20515. pJS.fn.vendors.draw();
  20516. }
  20517. };
  20518. pJS.fn.vendors.init = function(){
  20519. /* init canvas + particles */
  20520. pJS.fn.retinaInit();
  20521. pJS.fn.canvasInit();
  20522. pJS.fn.canvasSize();
  20523. pJS.fn.canvasPaint();
  20524. pJS.fn.particlesCreate();
  20525. pJS.fn.vendors.densityAutoParticles();
  20526. /* particles.line_linked - convert hex colors to rgb */
  20527. pJS.particles.line_linked.color_rgb_line = hexToRgb(pJS.particles.line_linked.color);
  20528. };
  20529. pJS.fn.vendors.start = function(){
  20530. if(isInArray('image', pJS.particles.shape.type)){
  20531. pJS.tmp.img_type = pJS.particles.shape.image.src.substr(pJS.particles.shape.image.src.length - 3);
  20532. pJS.fn.vendors.loadImg(pJS.tmp.img_type);
  20533. }else{
  20534. pJS.fn.vendors.checkBeforeDraw();
  20535. }
  20536. };
  20537. /* ---------- pJS - start ------------ */
  20538. pJS.fn.vendors.eventsListeners();
  20539. pJS.fn.vendors.start();
  20540. };
  20541. /* ---------- global functions - vendors ------------ */
  20542. Object.deepExtend = function(destination, source) {
  20543. for (var property in source) {
  20544. if (source[property] && source[property].constructor &&
  20545. source[property].constructor === Object) {
  20546. destination[property] = destination[property] || {};
  20547. arguments.callee(destination[property], source[property]);
  20548. } else {
  20549. destination[property] = source[property];
  20550. }
  20551. }
  20552. return destination;
  20553. };
  20554. window.requestAnimFrame = (function(){
  20555. return window.requestAnimationFrame ||
  20556. window.webkitRequestAnimationFrame ||
  20557. window.mozRequestAnimationFrame ||
  20558. window.oRequestAnimationFrame ||
  20559. window.msRequestAnimationFrame ||
  20560. function(callback){
  20561. window.setTimeout(callback, 1000 / 60);
  20562. };
  20563. })();
  20564. window.cancelRequestAnimFrame = ( function() {
  20565. return window.cancelAnimationFrame ||
  20566. window.webkitCancelRequestAnimationFrame ||
  20567. window.mozCancelRequestAnimationFrame ||
  20568. window.oCancelRequestAnimationFrame ||
  20569. window.msCancelRequestAnimationFrame ||
  20570. clearTimeout
  20571. } )();
  20572. function hexToRgb(hex){
  20573. // By Tim Down - http://stackoverflow.com/a/5624139/3493650
  20574. // Expand shorthand form (e.g. "03F") to full form (e.g. "0033FF")
  20575. var shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
  20576. hex = hex.replace(shorthandRegex, function(m, r, g, b) {
  20577. return r + r + g + g + b + b;
  20578. });
  20579. var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
  20580. return result ? {
  20581. r: parseInt(result[1], 16),
  20582. g: parseInt(result[2], 16),
  20583. b: parseInt(result[3], 16)
  20584. } : null;
  20585. };
  20586. function clamp(number, min, max) {
  20587. return Math.min(Math.max(number, min), max);
  20588. };
  20589. function isInArray(value, array) {
  20590. return array.indexOf(value) > -1;
  20591. }
  20592. /* ---------- particles.js functions - start ------------ */
  20593. window.pJSDom = [];
  20594. window.particlesJS = function(tag_id, params){
  20595. //console.log(params);
  20596. /* no string id? so it's object params, and set the id with default id */
  20597. if(typeof(tag_id) != 'string'){
  20598. params = tag_id;
  20599. tag_id = 'particles-js';
  20600. }
  20601. /* no id? set the id to default id */
  20602. if(!tag_id){
  20603. tag_id = 'particles-js';
  20604. }
  20605. /* pJS elements */
  20606. var pJS_tag = document.getElementById(tag_id),
  20607. pJS_canvas_class = 'particles-js-canvas-el',
  20608. exist_canvas = pJS_tag.getElementsByClassName(pJS_canvas_class);
  20609. /* remove canvas if exists into the pJS target tag */
  20610. if(exist_canvas.length){
  20611. while(exist_canvas.length > 0){
  20612. pJS_tag.removeChild(exist_canvas[0]);
  20613. }
  20614. }
  20615. /* create canvas element */
  20616. var canvas_el = document.createElement('canvas');
  20617. canvas_el.className = pJS_canvas_class;
  20618. /* set size canvas */
  20619. canvas_el.style.width = "100%";
  20620. canvas_el.style.height = "100%";
  20621. /* append canvas */
  20622. var canvas = document.getElementById(tag_id).appendChild(canvas_el);
  20623. /* launch particle.js */
  20624. if(canvas != null){
  20625. pJSDom.push(new pJS(tag_id, params));
  20626. }
  20627. };
  20628. window.particlesJS.load = function(tag_id, path_config_json, callback){
  20629. /* load json config */
  20630. var xhr = new XMLHttpRequest();
  20631. xhr.open('GET', path_config_json);
  20632. xhr.onreadystatechange = function (data) {
  20633. if(xhr.readyState == 4){
  20634. if(xhr.status == 200){
  20635. var params = JSON.parse(data.currentTarget.response);
  20636. window.particlesJS(tag_id, params);
  20637. if(callback) callback();
  20638. }else{
  20639. console.log('Error pJS - XMLHttpRequest status: '+xhr.status);
  20640. console.log('Error pJS - File config not found');
  20641. }
  20642. }
  20643. };
  20644. xhr.send();
  20645. };
  20646. /*!
  20647. Retina
  20648. Version: 1.3.0
  20649. Plugin URL: http://imulus.github.io/retinajs/
  20650. License: Copyright 2014 Imulus, LLC | Released under the MIT license
  20651. !*/
  20652. !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)}();
  20653. /*!
  20654. Skrollr
  20655. Plugin URL: https://github.com/Prinzhorn/skrollr
  20656. License: Copyright Alexander Prinzhorn | Free to use under terms of MIT license
  20657. !*/
  20658. (function(window, document, undefined) {
  20659. 'use strict';
  20660. /*
  20661. * Global api.
  20662. */
  20663. var skrollr = {
  20664. get: function() {
  20665. return _instance;
  20666. },
  20667. //Main entry point.
  20668. init: function(options) {
  20669. return _instance || new Skrollr(options);
  20670. },
  20671. VERSION: '0.6.30'
  20672. };
  20673. //Minify optimization.
  20674. var hasProp = Object.prototype.hasOwnProperty;
  20675. var Math = window.Math;
  20676. var getStyle = window.getComputedStyle;
  20677. //They will be filled when skrollr gets initialized.
  20678. var documentElement;
  20679. var body;
  20680. var EVENT_TOUCHSTART = 'touchstart';
  20681. var EVENT_TOUCHMOVE = 'touchmove';
  20682. var EVENT_TOUCHCANCEL = 'touchcancel';
  20683. var EVENT_TOUCHEND = 'touchend';
  20684. var SKROLLABLE_CLASS = 'skrollable';
  20685. var SKROLLABLE_BEFORE_CLASS = SKROLLABLE_CLASS + '-before';
  20686. var SKROLLABLE_BETWEEN_CLASS = SKROLLABLE_CLASS + '-between';
  20687. var SKROLLABLE_AFTER_CLASS = SKROLLABLE_CLASS + '-after';
  20688. var SKROLLR_CLASS = 'skrollr';
  20689. var NO_SKROLLR_CLASS = 'no-' + SKROLLR_CLASS;
  20690. var SKROLLR_DESKTOP_CLASS = SKROLLR_CLASS + '-desktop';
  20691. var SKROLLR_MOBILE_CLASS = SKROLLR_CLASS + '-mobile';
  20692. var DEFAULT_EASING = 'linear';
  20693. var DEFAULT_DURATION = 1000;//ms
  20694. var DEFAULT_MOBILE_DECELERATION = 0.004;//pixel/ms²
  20695. var DEFAULT_SKROLLRBODY = 'skrollr-body';
  20696. var DEFAULT_SMOOTH_SCROLLING_DURATION = 200;//ms
  20697. var ANCHOR_START = 'start';
  20698. var ANCHOR_END = 'end';
  20699. var ANCHOR_CENTER = 'center';
  20700. var ANCHOR_BOTTOM = 'bottom';
  20701. //The property which will be added to the DOM element to hold the ID of the skrollable.
  20702. var SKROLLABLE_ID_DOM_PROPERTY = '___skrollable_id';
  20703. var rxTouchIgnoreTags = /^(?:input|textarea|button|select)$/i;
  20704. var rxTrim = /^\s+|\s+$/g;
  20705. //Find all data-attributes. data-[_constant]-[offset]-[anchor]-[anchor].
  20706. var rxKeyframeAttribute = /^data(?:-(_\w+))?(?:-?(-?\d*\.?\d+p?))?(?:-?(start|end|top|center|bottom))?(?:-?(top|center|bottom))?$/;
  20707. var rxPropValue = /\s*(@?[\w\-\[\]]+)\s*:\s*(.+?)\s*(?:;|$)/gi;
  20708. //Easing function names follow the property in square brackets.
  20709. var rxPropEasing = /^(@?[a-z\-]+)\[(\w+)\]$/;
  20710. var rxCamelCase = /-([a-z0-9_])/g;
  20711. var rxCamelCaseFn = function(str, letter) {
  20712. return letter.toUpperCase();
  20713. };
  20714. //Numeric values with optional sign.
  20715. var rxNumericValue = /[\-+]?[\d]*\.?[\d]+/g;
  20716. //Used to replace occurences of {?} with a number.
  20717. var rxInterpolateString = /\{\?\}/g;
  20718. //Finds rgb(a) colors, which don't use the percentage notation.
  20719. var rxRGBAIntegerColor = /rgba?\(\s*-?\d+\s*,\s*-?\d+\s*,\s*-?\d+/g;
  20720. //Finds all gradients.
  20721. var rxGradient = /[a-z\-]+-gradient/g;
  20722. //Vendor prefix. Will be set once skrollr gets initialized.
  20723. var theCSSPrefix = '';
  20724. var theDashedCSSPrefix = '';
  20725. //Will be called once (when skrollr gets initialized).
  20726. var detectCSSPrefix = function() {
  20727. //Only relevant prefixes. May be extended.
  20728. //Could be dangerous if there will ever be a CSS property which actually starts with "ms". Don't hope so.
  20729. var rxPrefixes = /^(?:O|Moz|webkit|ms)|(?:-(?:o|moz|webkit|ms)-)/;
  20730. //Detect prefix for current browser by finding the first property using a prefix.
  20731. if(!getStyle) {
  20732. return;
  20733. }
  20734. var style = getStyle(body, null);
  20735. for(var k in style) {
  20736. //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.
  20737. theCSSPrefix = (k.match(rxPrefixes) || (+k == k && style[k].match(rxPrefixes)));
  20738. if(theCSSPrefix) {
  20739. break;
  20740. }
  20741. }
  20742. //Did we even detect a prefix?
  20743. if(!theCSSPrefix) {
  20744. theCSSPrefix = theDashedCSSPrefix = '';
  20745. return;
  20746. }
  20747. theCSSPrefix = theCSSPrefix[0];
  20748. //We could have detected either a dashed prefix or this camelCaseish-inconsistent stuff.
  20749. if(theCSSPrefix.slice(0,1) === '-') {
  20750. theDashedCSSPrefix = theCSSPrefix;
  20751. //There's no logic behind these. Need a look up.
  20752. theCSSPrefix = ({
  20753. '-webkit-': 'webkit',
  20754. '-moz-': 'Moz',
  20755. '-ms-': 'ms',
  20756. '-o-': 'O'
  20757. })[theCSSPrefix];
  20758. } else {
  20759. theDashedCSSPrefix = '-' + theCSSPrefix.toLowerCase() + '-';
  20760. }
  20761. };
  20762. var polyfillRAF = function() {
  20763. var requestAnimFrame = window.requestAnimationFrame || window[theCSSPrefix.toLowerCase() + 'RequestAnimationFrame'];
  20764. var lastTime = _now();
  20765. if(_isMobile || !requestAnimFrame) {
  20766. requestAnimFrame = function(callback) {
  20767. //How long did it take to render?
  20768. var deltaTime = _now() - lastTime;
  20769. var delay = Math.max(0, 1000 / 60 - deltaTime);
  20770. return window.setTimeout(function() {
  20771. lastTime = _now();
  20772. callback();
  20773. }, delay);
  20774. };
  20775. }
  20776. return requestAnimFrame;
  20777. };
  20778. var polyfillCAF = function() {
  20779. var cancelAnimFrame = window.cancelAnimationFrame || window[theCSSPrefix.toLowerCase() + 'CancelAnimationFrame'];
  20780. if(_isMobile || !cancelAnimFrame) {
  20781. cancelAnimFrame = function(timeout) {
  20782. return window.clearTimeout(timeout);
  20783. };
  20784. }
  20785. return cancelAnimFrame;
  20786. };
  20787. //Built-in easing functions.
  20788. var easings = {
  20789. begin: function() {
  20790. return 0;
  20791. },
  20792. end: function() {
  20793. return 1;
  20794. },
  20795. linear: function(p) {
  20796. return p;
  20797. },
  20798. quadratic: function(p) {
  20799. return p * p;
  20800. },
  20801. cubic: function(p) {
  20802. return p * p * p;
  20803. },
  20804. swing: function(p) {
  20805. return (-Math.cos(p * Math.PI) / 2) + 0.5;
  20806. },
  20807. sqrt: function(p) {
  20808. return Math.sqrt(p);
  20809. },
  20810. outCubic: function(p) {
  20811. return (Math.pow((p - 1), 3) + 1);
  20812. },
  20813. //see https://www.desmos.com/calculator/tbr20s8vd2 for how I did this
  20814. bounce: function(p) {
  20815. var a;
  20816. if(p <= 0.5083) {
  20817. a = 3;
  20818. } else if(p <= 0.8489) {
  20819. a = 9;
  20820. } else if(p <= 0.96208) {
  20821. a = 27;
  20822. } else if(p <= 0.99981) {
  20823. a = 91;
  20824. } else {
  20825. return 1;
  20826. }
  20827. return 1 - Math.abs(3 * Math.cos(p * a * 1.028) / a);
  20828. }
  20829. };
  20830. /**
  20831. * Constructor.
  20832. */
  20833. function Skrollr(options) {
  20834. documentElement = document.documentElement;
  20835. body = document.body;
  20836. detectCSSPrefix();
  20837. _instance = this;
  20838. options = options || {};
  20839. _constants = options.constants || {};
  20840. //We allow defining custom easings or overwrite existing.
  20841. if(options.easing) {
  20842. for(var e in options.easing) {
  20843. easings[e] = options.easing[e];
  20844. }
  20845. }
  20846. _edgeStrategy = options.edgeStrategy || 'set';
  20847. _listeners = {
  20848. //Function to be called right before rendering.
  20849. beforerender: options.beforerender,
  20850. //Function to be called right after finishing rendering.
  20851. render: options.render,
  20852. //Function to be called whenever an element with the `data-emit-events` attribute passes a keyframe.
  20853. keyframe: options.keyframe
  20854. };
  20855. //forceHeight is true by default
  20856. _forceHeight = options.forceHeight !== false;
  20857. if(_forceHeight) {
  20858. _scale = options.scale || 1;
  20859. }
  20860. _mobileDeceleration = options.mobileDeceleration || DEFAULT_MOBILE_DECELERATION;
  20861. _smoothScrollingEnabled = options.smoothScrolling !== false;
  20862. _smoothScrollingDuration = options.smoothScrollingDuration || DEFAULT_SMOOTH_SCROLLING_DURATION;
  20863. //Dummy object. Will be overwritten in the _render method when smooth scrolling is calculated.
  20864. _smoothScrolling = {
  20865. targetTop: _instance.getScrollTop()
  20866. };
  20867. //A custom check function may be passed.
  20868. _isMobile = ((options.mobileCheck || function() {
  20869. return (/Android|iPhone|iPad|iPod|BlackBerry/i).test(navigator.userAgent || navigator.vendor || window.opera);
  20870. })());
  20871. if(_isMobile) {
  20872. _skrollrBody = document.getElementById(options.skrollrBody || DEFAULT_SKROLLRBODY);
  20873. //Detect 3d transform if there's a skrollr-body (only needed for #skrollr-body).
  20874. if(_skrollrBody) {
  20875. _detect3DTransforms();
  20876. }
  20877. _initMobile();
  20878. _updateClass(documentElement, [SKROLLR_CLASS, SKROLLR_MOBILE_CLASS], [NO_SKROLLR_CLASS]);
  20879. } else {
  20880. _updateClass(documentElement, [SKROLLR_CLASS, SKROLLR_DESKTOP_CLASS], [NO_SKROLLR_CLASS]);
  20881. }
  20882. //Triggers parsing of elements and a first reflow.
  20883. _instance.refresh();
  20884. _addEvent(window, 'resize orientationchange', function() {
  20885. var width = documentElement.clientWidth;
  20886. var height = documentElement.clientHeight;
  20887. //Only reflow if the size actually changed (#271).
  20888. if(height !== _lastViewportHeight || width !== _lastViewportWidth) {
  20889. _lastViewportHeight = height;
  20890. _lastViewportWidth = width;
  20891. _requestReflow = true;
  20892. }
  20893. });
  20894. var requestAnimFrame = polyfillRAF();
  20895. //Let's go.
  20896. (function animloop(){
  20897. _render();
  20898. _animFrame = requestAnimFrame(animloop);
  20899. }());
  20900. return _instance;
  20901. }
  20902. /**
  20903. * (Re)parses some or all elements.
  20904. */
  20905. Skrollr.prototype.refresh = function(elements) {
  20906. var elementIndex;
  20907. var elementsLength;
  20908. var ignoreID = false;
  20909. //Completely reparse anything without argument.
  20910. if(elements === undefined) {
  20911. //Ignore that some elements may already have a skrollable ID.
  20912. ignoreID = true;
  20913. _skrollables = [];
  20914. _skrollableIdCounter = 0;
  20915. elements = document.getElementsByTagName('*');
  20916. } else if(elements.length === undefined) {
  20917. //We also accept a single element as parameter.
  20918. elements = [elements];
  20919. }
  20920. elementIndex = 0;
  20921. elementsLength = elements.length;
  20922. for(; elementIndex < elementsLength; elementIndex++) {
  20923. var el = elements[elementIndex];
  20924. var anchorTarget = el;
  20925. var keyFrames = [];
  20926. //If this particular element should be smooth scrolled.
  20927. var smoothScrollThis = _smoothScrollingEnabled;
  20928. //The edge strategy for this particular element.
  20929. var edgeStrategy = _edgeStrategy;
  20930. //If this particular element should emit keyframe events.
  20931. var emitEvents = false;
  20932. //If we're reseting the counter, remove any old element ids that may be hanging around.
  20933. if(ignoreID && SKROLLABLE_ID_DOM_PROPERTY in el) {
  20934. delete el[SKROLLABLE_ID_DOM_PROPERTY];
  20935. }
  20936. if(!el.attributes) {
  20937. continue;
  20938. }
  20939. //Iterate over all attributes and search for key frame attributes.
  20940. var attributeIndex = 0;
  20941. var attributesLength = el.attributes.length;
  20942. for (; attributeIndex < attributesLength; attributeIndex++) {
  20943. var attr = el.attributes[attributeIndex];
  20944. if(attr.name === 'data-anchor-target') {
  20945. anchorTarget = document.querySelector(attr.value);
  20946. if(anchorTarget === null) {
  20947. throw 'Unable to find anchor target "' + attr.value + '"';
  20948. }
  20949. continue;
  20950. }
  20951. //Global smooth scrolling can be overridden by the element attribute.
  20952. if(attr.name === 'data-smooth-scrolling') {
  20953. smoothScrollThis = attr.value !== 'off';
  20954. continue;
  20955. }
  20956. //Global edge strategy can be overridden by the element attribute.
  20957. if(attr.name === 'data-edge-strategy') {
  20958. edgeStrategy = attr.value;
  20959. continue;
  20960. }
  20961. //Is this element tagged with the `data-emit-events` attribute?
  20962. if(attr.name === 'data-emit-events') {
  20963. emitEvents = true;
  20964. continue;
  20965. }
  20966. var match = attr.name.match(rxKeyframeAttribute);
  20967. if(match === null) {
  20968. continue;
  20969. }
  20970. var kf = {
  20971. props: attr.value,
  20972. //Point back to the element as well.
  20973. element: el,
  20974. //The name of the event which this keyframe will fire, if emitEvents is
  20975. eventType: attr.name.replace(rxCamelCase, rxCamelCaseFn)
  20976. };
  20977. keyFrames.push(kf);
  20978. var constant = match[1];
  20979. if(constant) {
  20980. //Strip the underscore prefix.
  20981. kf.constant = constant.substr(1);
  20982. }
  20983. //Get the key frame offset.
  20984. var offset = match[2];
  20985. //Is it a percentage offset?
  20986. if(/p$/.test(offset)) {
  20987. kf.isPercentage = true;
  20988. kf.offset = (offset.slice(0, -1) | 0) / 100;
  20989. } else {
  20990. kf.offset = (offset | 0);
  20991. }
  20992. var anchor1 = match[3];
  20993. //If second anchor is not set, the first will be taken for both.
  20994. var anchor2 = match[4] || anchor1;
  20995. //"absolute" (or "classic") mode, where numbers mean absolute scroll offset.
  20996. if(!anchor1 || anchor1 === ANCHOR_START || anchor1 === ANCHOR_END) {
  20997. kf.mode = 'absolute';
  20998. //data-end needs to be calculated after all key frames are known.
  20999. if(anchor1 === ANCHOR_END) {
  21000. kf.isEnd = true;
  21001. } else if(!kf.isPercentage) {
  21002. //For data-start we can already set the key frame w/o calculations.
  21003. //#59: "scale" options should only affect absolute mode.
  21004. kf.offset = kf.offset * _scale;
  21005. }
  21006. }
  21007. //"relative" mode, where numbers are relative to anchors.
  21008. else {
  21009. kf.mode = 'relative';
  21010. kf.anchors = [anchor1, anchor2];
  21011. }
  21012. }
  21013. //Does this element have key frames?
  21014. if(!keyFrames.length) {
  21015. continue;
  21016. }
  21017. //Will hold the original style and class attributes before we controlled the element (see #80).
  21018. var styleAttr, classAttr;
  21019. var id;
  21020. if(!ignoreID && SKROLLABLE_ID_DOM_PROPERTY in el) {
  21021. //We already have this element under control. Grab the corresponding skrollable id.
  21022. id = el[SKROLLABLE_ID_DOM_PROPERTY];
  21023. styleAttr = _skrollables[id].styleAttr;
  21024. classAttr = _skrollables[id].classAttr;
  21025. } else {
  21026. //It's an unknown element. Asign it a new skrollable id.
  21027. id = (el[SKROLLABLE_ID_DOM_PROPERTY] = _skrollableIdCounter++);
  21028. styleAttr = el.style.cssText;
  21029. classAttr = _getClass(el);
  21030. }
  21031. _skrollables[id] = {
  21032. element: el,
  21033. styleAttr: styleAttr,
  21034. classAttr: classAttr,
  21035. anchorTarget: anchorTarget,
  21036. keyFrames: keyFrames,
  21037. smoothScrolling: smoothScrollThis,
  21038. edgeStrategy: edgeStrategy,
  21039. emitEvents: emitEvents,
  21040. lastFrameIndex: -1
  21041. };
  21042. _updateClass(el, [SKROLLABLE_CLASS], []);
  21043. }
  21044. //Reflow for the first time.
  21045. _reflow();
  21046. //Now that we got all key frame numbers right, actually parse the properties.
  21047. elementIndex = 0;
  21048. elementsLength = elements.length;
  21049. for(; elementIndex < elementsLength; elementIndex++) {
  21050. var sk = _skrollables[elements[elementIndex][SKROLLABLE_ID_DOM_PROPERTY]];
  21051. if(sk === undefined) {
  21052. continue;
  21053. }
  21054. //Parse the property string to objects
  21055. _parseProps(sk);
  21056. //Fill key frames with missing properties from left and right
  21057. _fillProps(sk);
  21058. }
  21059. return _instance;
  21060. };
  21061. /**
  21062. * Transform "relative" mode to "absolute" mode.
  21063. * That is, calculate anchor position and offset of element.
  21064. */
  21065. Skrollr.prototype.relativeToAbsolute = function(element, viewportAnchor, elementAnchor) {
  21066. var viewportHeight = documentElement.clientHeight;
  21067. var box = element.getBoundingClientRect();
  21068. var absolute = box.top;
  21069. //#100: IE doesn't supply "height" with getBoundingClientRect.
  21070. var boxHeight = box.bottom - box.top;
  21071. if(viewportAnchor === ANCHOR_BOTTOM) {
  21072. absolute -= viewportHeight;
  21073. } else if(viewportAnchor === ANCHOR_CENTER) {
  21074. absolute -= viewportHeight / 2;
  21075. }
  21076. if(elementAnchor === ANCHOR_BOTTOM) {
  21077. absolute += boxHeight;
  21078. } else if(elementAnchor === ANCHOR_CENTER) {
  21079. absolute += boxHeight / 2;
  21080. }
  21081. //Compensate scrolling since getBoundingClientRect is relative to viewport.
  21082. absolute += _instance.getScrollTop();
  21083. return (absolute + 0.5) | 0;
  21084. };
  21085. /**
  21086. * Animates scroll top to new position.
  21087. */
  21088. Skrollr.prototype.animateTo = function(top, options) {
  21089. options = options || {};
  21090. var now = _now();
  21091. var scrollTop = _instance.getScrollTop();
  21092. var duration = options.duration === undefined ? DEFAULT_DURATION : options.duration;
  21093. //Setting this to a new value will automatically cause the current animation to stop, if any.
  21094. _scrollAnimation = {
  21095. startTop: scrollTop,
  21096. topDiff: top - scrollTop,
  21097. targetTop: top,
  21098. duration: duration,
  21099. startTime: now,
  21100. endTime: now + duration,
  21101. easing: easings[options.easing || DEFAULT_EASING],
  21102. done: options.done
  21103. };
  21104. //Don't queue the animation if there's nothing to animate.
  21105. if(!_scrollAnimation.topDiff) {
  21106. if(_scrollAnimation.done) {
  21107. _scrollAnimation.done.call(_instance, false);
  21108. }
  21109. _scrollAnimation = undefined;
  21110. }
  21111. return _instance;
  21112. };
  21113. /**
  21114. * Stops animateTo animation.
  21115. */
  21116. Skrollr.prototype.stopAnimateTo = function() {
  21117. if(_scrollAnimation && _scrollAnimation.done) {
  21118. _scrollAnimation.done.call(_instance, true);
  21119. }
  21120. _scrollAnimation = undefined;
  21121. };
  21122. /**
  21123. * Returns if an animation caused by animateTo is currently running.
  21124. */
  21125. Skrollr.prototype.isAnimatingTo = function() {
  21126. return !!_scrollAnimation;
  21127. };
  21128. Skrollr.prototype.isMobile = function() {
  21129. return _isMobile;
  21130. };
  21131. Skrollr.prototype.setScrollTop = function(top, force) {
  21132. _forceRender = (force === true);
  21133. if(_isMobile) {
  21134. _mobileOffset = Math.min(Math.max(top, 0), _maxKeyFrame);
  21135. } else {
  21136. window.scrollTo(0, top);
  21137. }
  21138. return _instance;
  21139. };
  21140. Skrollr.prototype.getScrollTop = function() {
  21141. if(_isMobile) {
  21142. return _mobileOffset;
  21143. } else {
  21144. return window.pageYOffset || documentElement.scrollTop || body.scrollTop || 0;
  21145. }
  21146. };
  21147. Skrollr.prototype.getMaxScrollTop = function() {
  21148. return _maxKeyFrame;
  21149. };
  21150. Skrollr.prototype.on = function(name, fn) {
  21151. _listeners[name] = fn;
  21152. return _instance;
  21153. };
  21154. Skrollr.prototype.off = function(name) {
  21155. delete _listeners[name];
  21156. return _instance;
  21157. };
  21158. Skrollr.prototype.destroy = function() {
  21159. var cancelAnimFrame = polyfillCAF();
  21160. cancelAnimFrame(_animFrame);
  21161. _removeAllEvents();
  21162. _updateClass(documentElement, [NO_SKROLLR_CLASS], [SKROLLR_CLASS, SKROLLR_DESKTOP_CLASS, SKROLLR_MOBILE_CLASS]);
  21163. var skrollableIndex = 0;
  21164. var skrollablesLength = _skrollables.length;
  21165. for(; skrollableIndex < skrollablesLength; skrollableIndex++) {
  21166. _reset(_skrollables[skrollableIndex].element);
  21167. }
  21168. documentElement.style.overflow = body.style.overflow = '';
  21169. documentElement.style.height = body.style.height = '';
  21170. if(_skrollrBody) {
  21171. skrollr.setStyle(_skrollrBody, 'transform', 'none');
  21172. }
  21173. _instance = undefined;
  21174. _skrollrBody = undefined;
  21175. _listeners = undefined;
  21176. _forceHeight = undefined;
  21177. _maxKeyFrame = 0;
  21178. _scale = 1;
  21179. _constants = undefined;
  21180. _mobileDeceleration = undefined;
  21181. _direction = 'down';
  21182. _lastTop = -1;
  21183. _lastViewportWidth = 0;
  21184. _lastViewportHeight = 0;
  21185. _requestReflow = false;
  21186. _scrollAnimation = undefined;
  21187. _smoothScrollingEnabled = undefined;
  21188. _smoothScrollingDuration = undefined;
  21189. _smoothScrolling = undefined;
  21190. _forceRender = undefined;
  21191. _skrollableIdCounter = 0;
  21192. _edgeStrategy = undefined;
  21193. _isMobile = false;
  21194. _mobileOffset = 0;
  21195. _translateZ = undefined;
  21196. };
  21197. /*
  21198. Private methods.
  21199. */
  21200. var _initMobile = function() {
  21201. var initialElement;
  21202. var initialTouchY;
  21203. var initialTouchX;
  21204. var currentElement;
  21205. var currentTouchY;
  21206. var currentTouchX;
  21207. var lastTouchY;
  21208. var deltaY;
  21209. var initialTouchTime;
  21210. var currentTouchTime;
  21211. var lastTouchTime;
  21212. var deltaTime;
  21213. _addEvent(documentElement, [EVENT_TOUCHSTART, EVENT_TOUCHMOVE, EVENT_TOUCHCANCEL, EVENT_TOUCHEND].join(' '), function(e) {
  21214. var touch = e.changedTouches[0];
  21215. currentElement = e.target;
  21216. //We don't want text nodes.
  21217. while(currentElement.nodeType === 3) {
  21218. currentElement = currentElement.parentNode;
  21219. }
  21220. currentTouchY = touch.clientY;
  21221. currentTouchX = touch.clientX;
  21222. currentTouchTime = e.timeStamp;
  21223. if(!rxTouchIgnoreTags.test(currentElement.tagName)) {
  21224. e.preventDefault();
  21225. }
  21226. switch(e.type) {
  21227. case EVENT_TOUCHSTART:
  21228. //The last element we tapped on.
  21229. if(initialElement) {
  21230. initialElement.blur();
  21231. }
  21232. _instance.stopAnimateTo();
  21233. initialElement = currentElement;
  21234. initialTouchY = lastTouchY = currentTouchY;
  21235. initialTouchX = currentTouchX;
  21236. initialTouchTime = currentTouchTime;
  21237. break;
  21238. case EVENT_TOUCHMOVE:
  21239. //Prevent default event on touchIgnore elements in case they don't have focus yet.
  21240. if(rxTouchIgnoreTags.test(currentElement.tagName) && document.activeElement !== currentElement) {
  21241. e.preventDefault();
  21242. }
  21243. deltaY = currentTouchY - lastTouchY;
  21244. deltaTime = currentTouchTime - lastTouchTime;
  21245. _instance.setScrollTop(_mobileOffset - deltaY, true);
  21246. lastTouchY = currentTouchY;
  21247. lastTouchTime = currentTouchTime;
  21248. break;
  21249. default:
  21250. case EVENT_TOUCHCANCEL:
  21251. case EVENT_TOUCHEND:
  21252. var distanceY = initialTouchY - currentTouchY;
  21253. var distanceX = initialTouchX - currentTouchX;
  21254. var distance2 = distanceX * distanceX + distanceY * distanceY;
  21255. //Check if it was more like a tap (moved less than 7px).
  21256. if(distance2 < 49) {
  21257. if(!rxTouchIgnoreTags.test(initialElement.tagName)) {
  21258. initialElement.focus();
  21259. //It was a tap, click the element.
  21260. var clickEvent = document.createEvent('MouseEvents');
  21261. 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);
  21262. initialElement.dispatchEvent(clickEvent);
  21263. }
  21264. return;
  21265. }
  21266. initialElement = undefined;
  21267. var speed = deltaY / deltaTime;
  21268. //Cap speed at 3 pixel/ms.
  21269. speed = Math.max(Math.min(speed, 3), -3);
  21270. var duration = Math.abs(speed / _mobileDeceleration);
  21271. var targetOffset = speed * duration + 0.5 * _mobileDeceleration * duration * duration;
  21272. var targetTop = _instance.getScrollTop() - targetOffset;
  21273. //Relative duration change for when scrolling above bounds.
  21274. var targetRatio = 0;
  21275. //Change duration proportionally when scrolling would leave bounds.
  21276. if(targetTop > _maxKeyFrame) {
  21277. targetRatio = (_maxKeyFrame - targetTop) / targetOffset;
  21278. targetTop = _maxKeyFrame;
  21279. } else if(targetTop < 0) {
  21280. targetRatio = -targetTop / targetOffset;
  21281. targetTop = 0;
  21282. }
  21283. duration = duration * (1 - targetRatio);
  21284. _instance.animateTo((targetTop + 0.5) | 0, {easing: 'outCubic', duration: duration});
  21285. break;
  21286. }
  21287. });
  21288. //Just in case there has already been some native scrolling, reset it.
  21289. window.scrollTo(0, 0);
  21290. documentElement.style.overflow = body.style.overflow = 'hidden';
  21291. };
  21292. /**
  21293. * Updates key frames which depend on others / need to be updated on resize.
  21294. * That is "end" in "absolute" mode and all key frames in "relative" mode.
  21295. * Also handles constants, because they may change on resize.
  21296. */
  21297. var _updateDependentKeyFrames = function() {
  21298. var viewportHeight = documentElement.clientHeight;
  21299. var processedConstants = _processConstants();
  21300. var skrollable;
  21301. var element;
  21302. var anchorTarget;
  21303. var keyFrames;
  21304. var keyFrameIndex;
  21305. var keyFramesLength;
  21306. var kf;
  21307. var skrollableIndex;
  21308. var skrollablesLength;
  21309. var offset;
  21310. var constantValue;
  21311. //First process all relative-mode elements and find the max key frame.
  21312. skrollableIndex = 0;
  21313. skrollablesLength = _skrollables.length;
  21314. for(; skrollableIndex < skrollablesLength; skrollableIndex++) {
  21315. skrollable = _skrollables[skrollableIndex];
  21316. element = skrollable.element;
  21317. anchorTarget = skrollable.anchorTarget;
  21318. keyFrames = skrollable.keyFrames;
  21319. keyFrameIndex = 0;
  21320. keyFramesLength = keyFrames.length;
  21321. for(; keyFrameIndex < keyFramesLength; keyFrameIndex++) {
  21322. kf = keyFrames[keyFrameIndex];
  21323. offset = kf.offset;
  21324. constantValue = processedConstants[kf.constant] || 0;
  21325. kf.frame = offset;
  21326. if(kf.isPercentage) {
  21327. //Convert the offset to percentage of the viewport height.
  21328. offset = offset * viewportHeight;
  21329. //Absolute + percentage mode.
  21330. kf.frame = offset;
  21331. }
  21332. if(kf.mode === 'relative') {
  21333. _reset(element);
  21334. kf.frame = _instance.relativeToAbsolute(anchorTarget, kf.anchors[0], kf.anchors[1]) - offset;
  21335. _reset(element, true);
  21336. }
  21337. kf.frame += constantValue;
  21338. //Only search for max key frame when forceHeight is enabled.
  21339. if(_forceHeight) {
  21340. //Find the max key frame, but don't use one of the data-end ones for comparison.
  21341. if(!kf.isEnd && kf.frame > _maxKeyFrame) {
  21342. _maxKeyFrame = kf.frame;
  21343. }
  21344. }
  21345. }
  21346. }
  21347. //#133: The document can be larger than the maxKeyFrame we found.
  21348. _maxKeyFrame = Math.max(_maxKeyFrame, _getDocumentHeight());
  21349. //Now process all data-end keyframes.
  21350. skrollableIndex = 0;
  21351. skrollablesLength = _skrollables.length;
  21352. for(; skrollableIndex < skrollablesLength; skrollableIndex++) {
  21353. skrollable = _skrollables[skrollableIndex];
  21354. keyFrames = skrollable.keyFrames;
  21355. keyFrameIndex = 0;
  21356. keyFramesLength = keyFrames.length;
  21357. for(; keyFrameIndex < keyFramesLength; keyFrameIndex++) {
  21358. kf = keyFrames[keyFrameIndex];
  21359. constantValue = processedConstants[kf.constant] || 0;
  21360. if(kf.isEnd) {
  21361. kf.frame = _maxKeyFrame - kf.offset + constantValue;
  21362. }
  21363. }
  21364. skrollable.keyFrames.sort(_keyFrameComparator);
  21365. }
  21366. };
  21367. /**
  21368. * Calculates and sets the style properties for the element at the given frame.
  21369. * @param fakeFrame The frame to render at when smooth scrolling is enabled.
  21370. * @param actualFrame The actual frame we are at.
  21371. */
  21372. var _calcSteps = function(fakeFrame, actualFrame) {
  21373. //Iterate over all skrollables.
  21374. var skrollableIndex = 0;
  21375. var skrollablesLength = _skrollables.length;
  21376. for(; skrollableIndex < skrollablesLength; skrollableIndex++) {
  21377. var skrollable = _skrollables[skrollableIndex];
  21378. var element = skrollable.element;
  21379. var frame = skrollable.smoothScrolling ? fakeFrame : actualFrame;
  21380. var frames = skrollable.keyFrames;
  21381. var framesLength = frames.length;
  21382. var firstFrame = frames[0];
  21383. var lastFrame = frames[frames.length - 1];
  21384. var beforeFirst = frame < firstFrame.frame;
  21385. var afterLast = frame > lastFrame.frame;
  21386. var firstOrLastFrame = beforeFirst ? firstFrame : lastFrame;
  21387. var emitEvents = skrollable.emitEvents;
  21388. var lastFrameIndex = skrollable.lastFrameIndex;
  21389. var key;
  21390. var value;
  21391. //If we are before/after the first/last frame, set the styles according to the given edge strategy.
  21392. if(beforeFirst || afterLast) {
  21393. //Check if we already handled this edge case last time.
  21394. //Note: using setScrollTop it's possible that we jumped from one edge to the other.
  21395. if(beforeFirst && skrollable.edge === -1 || afterLast && skrollable.edge === 1) {
  21396. continue;
  21397. }
  21398. //Add the skrollr-before or -after class.
  21399. if(beforeFirst) {
  21400. _updateClass(element, [SKROLLABLE_BEFORE_CLASS], [SKROLLABLE_AFTER_CLASS, SKROLLABLE_BETWEEN_CLASS]);
  21401. //This handles the special case where we exit the first keyframe.
  21402. if(emitEvents && lastFrameIndex > -1) {
  21403. _emitEvent(element, firstFrame.eventType, _direction);
  21404. skrollable.lastFrameIndex = -1;
  21405. }
  21406. } else {
  21407. _updateClass(element, [SKROLLABLE_AFTER_CLASS], [SKROLLABLE_BEFORE_CLASS, SKROLLABLE_BETWEEN_CLASS]);
  21408. //This handles the special case where we exit the last keyframe.
  21409. if(emitEvents && lastFrameIndex < framesLength) {
  21410. _emitEvent(element, lastFrame.eventType, _direction);
  21411. skrollable.lastFrameIndex = framesLength;
  21412. }
  21413. }
  21414. //Remember that we handled the edge case (before/after the first/last keyframe).
  21415. skrollable.edge = beforeFirst ? -1 : 1;
  21416. switch(skrollable.edgeStrategy) {
  21417. case 'reset':
  21418. _reset(element);
  21419. continue;
  21420. case 'ease':
  21421. //Handle this case like it would be exactly at first/last keyframe and just pass it on.
  21422. frame = firstOrLastFrame.frame;
  21423. break;
  21424. default:
  21425. case 'set':
  21426. var props = firstOrLastFrame.props;
  21427. for(key in props) {
  21428. if(hasProp.call(props, key)) {
  21429. value = _interpolateString(props[key].value);
  21430. //Set style or attribute.
  21431. if(key.indexOf('@') === 0) {
  21432. element.setAttribute(key.substr(1), value);
  21433. } else {
  21434. skrollr.setStyle(element, key, value);
  21435. }
  21436. }
  21437. }
  21438. continue;
  21439. }
  21440. } else {
  21441. //Did we handle an edge last time?
  21442. if(skrollable.edge !== 0) {
  21443. _updateClass(element, [SKROLLABLE_CLASS, SKROLLABLE_BETWEEN_CLASS], [SKROLLABLE_BEFORE_CLASS, SKROLLABLE_AFTER_CLASS]);
  21444. skrollable.edge = 0;
  21445. }
  21446. }
  21447. //Find out between which two key frames we are right now.
  21448. var keyFrameIndex = 0;
  21449. for(; keyFrameIndex < framesLength - 1; keyFrameIndex++) {
  21450. if(frame >= frames[keyFrameIndex].frame && frame <= frames[keyFrameIndex + 1].frame) {
  21451. var left = frames[keyFrameIndex];
  21452. var right = frames[keyFrameIndex + 1];
  21453. for(key in left.props) {
  21454. if(hasProp.call(left.props, key)) {
  21455. var progress = (frame - left.frame) / (right.frame - left.frame);
  21456. //Transform the current progress using the given easing function.
  21457. progress = left.props[key].easing(progress);
  21458. //Interpolate between the two values
  21459. value = _calcInterpolation(left.props[key].value, right.props[key].value, progress);
  21460. value = _interpolateString(value);
  21461. //Set style or attribute.
  21462. if(key.indexOf('@') === 0) {
  21463. element.setAttribute(key.substr(1), value);
  21464. } else {
  21465. skrollr.setStyle(element, key, value);
  21466. }
  21467. }
  21468. }
  21469. //Are events enabled on this element?
  21470. //This code handles the usual cases of scrolling through different keyframes.
  21471. //The special cases of before first and after last keyframe are handled above.
  21472. if(emitEvents) {
  21473. //Did we pass a new keyframe?
  21474. if(lastFrameIndex !== keyFrameIndex) {
  21475. if(_direction === 'down') {
  21476. _emitEvent(element, left.eventType, _direction);
  21477. } else {
  21478. _emitEvent(element, right.eventType, _direction);
  21479. }
  21480. skrollable.lastFrameIndex = keyFrameIndex;
  21481. }
  21482. }
  21483. break;
  21484. }
  21485. }
  21486. }
  21487. };
  21488. /**
  21489. * Renders all elements.
  21490. */
  21491. var _render = function() {
  21492. if(_requestReflow) {
  21493. _requestReflow = false;
  21494. _reflow();
  21495. }
  21496. //We may render something else than the actual scrollbar position.
  21497. var renderTop = _instance.getScrollTop();
  21498. //If there's an animation, which ends in current render call, call the callback after rendering.
  21499. var afterAnimationCallback;
  21500. var now = _now();
  21501. var progress;
  21502. //Before actually rendering handle the scroll animation, if any.
  21503. if(_scrollAnimation) {
  21504. //It's over
  21505. if(now >= _scrollAnimation.endTime) {
  21506. renderTop = _scrollAnimation.targetTop;
  21507. afterAnimationCallback = _scrollAnimation.done;
  21508. _scrollAnimation = undefined;
  21509. } else {
  21510. //Map the current progress to the new progress using given easing function.
  21511. progress = _scrollAnimation.easing((now - _scrollAnimation.startTime) / _scrollAnimation.duration);
  21512. renderTop = (_scrollAnimation.startTop + progress * _scrollAnimation.topDiff) | 0;
  21513. }
  21514. _instance.setScrollTop(renderTop, true);
  21515. }
  21516. //Smooth scrolling only if there's no animation running and if we're not forcing the rendering.
  21517. else if(!_forceRender) {
  21518. var smoothScrollingDiff = _smoothScrolling.targetTop - renderTop;
  21519. //The user scrolled, start new smooth scrolling.
  21520. if(smoothScrollingDiff) {
  21521. _smoothScrolling = {
  21522. startTop: _lastTop,
  21523. topDiff: renderTop - _lastTop,
  21524. targetTop: renderTop,
  21525. startTime: _lastRenderCall,
  21526. endTime: _lastRenderCall + _smoothScrollingDuration
  21527. };
  21528. }
  21529. //Interpolate the internal scroll position (not the actual scrollbar).
  21530. if(now <= _smoothScrolling.endTime) {
  21531. //Map the current progress to the new progress using easing function.
  21532. progress = easings.sqrt((now - _smoothScrolling.startTime) / _smoothScrollingDuration);
  21533. renderTop = (_smoothScrolling.startTop + progress * _smoothScrolling.topDiff) | 0;
  21534. }
  21535. }
  21536. //Did the scroll position even change?
  21537. if(_forceRender || _lastTop !== renderTop) {
  21538. //Remember in which direction are we scrolling?
  21539. _direction = (renderTop > _lastTop) ? 'down' : (renderTop < _lastTop ? 'up' : _direction);
  21540. _forceRender = false;
  21541. var listenerParams = {
  21542. curTop: renderTop,
  21543. lastTop: _lastTop,
  21544. maxTop: _maxKeyFrame,
  21545. direction: _direction
  21546. };
  21547. //Tell the listener we are about to render.
  21548. var continueRendering = _listeners.beforerender && _listeners.beforerender.call(_instance, listenerParams);
  21549. //The beforerender listener function is able the cancel rendering.
  21550. if(continueRendering !== false) {
  21551. //Now actually interpolate all the styles.
  21552. _calcSteps(renderTop, _instance.getScrollTop());
  21553. //That's were we actually "scroll" on mobile.
  21554. if(_isMobile && _skrollrBody) {
  21555. //Set the transform ("scroll it").
  21556. skrollr.setStyle(_skrollrBody, 'transform', 'translate(0, ' + -(_mobileOffset) + 'px) ' + _translateZ);
  21557. }
  21558. //Remember when we last rendered.
  21559. _lastTop = renderTop;
  21560. if(_listeners.render) {
  21561. _listeners.render.call(_instance, listenerParams);
  21562. }
  21563. }
  21564. if(afterAnimationCallback) {
  21565. afterAnimationCallback.call(_instance, false);
  21566. }
  21567. }
  21568. _lastRenderCall = now;
  21569. };
  21570. /**
  21571. * Parses the properties for each key frame of the given skrollable.
  21572. */
  21573. var _parseProps = function(skrollable) {
  21574. //Iterate over all key frames
  21575. var keyFrameIndex = 0;
  21576. var keyFramesLength = skrollable.keyFrames.length;
  21577. for(; keyFrameIndex < keyFramesLength; keyFrameIndex++) {
  21578. var frame = skrollable.keyFrames[keyFrameIndex];
  21579. var easing;
  21580. var value;
  21581. var prop;
  21582. var props = {};
  21583. var match;
  21584. while((match = rxPropValue.exec(frame.props)) !== null) {
  21585. prop = match[1];
  21586. value = match[2];
  21587. easing = prop.match(rxPropEasing);
  21588. //Is there an easing specified for this prop?
  21589. if(easing !== null) {
  21590. prop = easing[1];
  21591. easing = easing[2];
  21592. } else {
  21593. easing = DEFAULT_EASING;
  21594. }
  21595. //Exclamation point at first position forces the value to be taken literal.
  21596. value = value.indexOf('!') ? _parseProp(value) : [value.slice(1)];
  21597. //Save the prop for this key frame with his value and easing function
  21598. props[prop] = {
  21599. value: value,
  21600. easing: easings[easing]
  21601. };
  21602. }
  21603. frame.props = props;
  21604. }
  21605. };
  21606. /**
  21607. * Parses a value extracting numeric values and generating a format string
  21608. * for later interpolation of the new values in old string.
  21609. *
  21610. * @param val The CSS value to be parsed.
  21611. * @return Something like ["rgba(?%,?%, ?%,?)", 100, 50, 0, .7]
  21612. * where the first element is the format string later used
  21613. * and all following elements are the numeric value.
  21614. */
  21615. var _parseProp = function(val) {
  21616. var numbers = [];
  21617. //One special case, where floats don't work.
  21618. //We replace all occurences of rgba colors
  21619. //which don't use percentage notation with the percentage notation.
  21620. rxRGBAIntegerColor.lastIndex = 0;
  21621. val = val.replace(rxRGBAIntegerColor, function(rgba) {
  21622. return rgba.replace(rxNumericValue, function(n) {
  21623. return n / 255 * 100 + '%';
  21624. });
  21625. });
  21626. //Handle prefixing of "gradient" values.
  21627. //For now only the prefixed value will be set. Unprefixed isn't supported anyway.
  21628. if(theDashedCSSPrefix) {
  21629. rxGradient.lastIndex = 0;
  21630. val = val.replace(rxGradient, function(s) {
  21631. return theDashedCSSPrefix + s;
  21632. });
  21633. }
  21634. //Now parse ANY number inside this string and create a format string.
  21635. val = val.replace(rxNumericValue, function(n) {
  21636. numbers.push(+n);
  21637. return '{?}';
  21638. });
  21639. //Add the formatstring as first value.
  21640. numbers.unshift(val);
  21641. return numbers;
  21642. };
  21643. /**
  21644. * Fills the key frames with missing left and right hand properties.
  21645. * If key frame 1 has property X and key frame 2 is missing X,
  21646. * but key frame 3 has X again, then we need to assign X to key frame 2 too.
  21647. *
  21648. * @param sk A skrollable.
  21649. */
  21650. var _fillProps = function(sk) {
  21651. //Will collect the properties key frame by key frame
  21652. var propList = {};
  21653. var keyFrameIndex;
  21654. var keyFramesLength;
  21655. //Iterate over all key frames from left to right
  21656. keyFrameIndex = 0;
  21657. keyFramesLength = sk.keyFrames.length;
  21658. for(; keyFrameIndex < keyFramesLength; keyFrameIndex++) {
  21659. _fillPropForFrame(sk.keyFrames[keyFrameIndex], propList);
  21660. }
  21661. //Now do the same from right to fill the last gaps
  21662. propList = {};
  21663. //Iterate over all key frames from right to left
  21664. keyFrameIndex = sk.keyFrames.length - 1;
  21665. for(; keyFrameIndex >= 0; keyFrameIndex--) {
  21666. _fillPropForFrame(sk.keyFrames[keyFrameIndex], propList);
  21667. }
  21668. };
  21669. var _fillPropForFrame = function(frame, propList) {
  21670. var key;
  21671. //For each key frame iterate over all right hand properties and assign them,
  21672. //but only if the current key frame doesn't have the property by itself
  21673. for(key in propList) {
  21674. //The current frame misses this property, so assign it.
  21675. if(!hasProp.call(frame.props, key)) {
  21676. frame.props[key] = propList[key];
  21677. }
  21678. }
  21679. //Iterate over all props of the current frame and collect them
  21680. for(key in frame.props) {
  21681. propList[key] = frame.props[key];
  21682. }
  21683. };
  21684. /**
  21685. * Calculates the new values for two given values array.
  21686. */
  21687. var _calcInterpolation = function(val1, val2, progress) {
  21688. var valueIndex;
  21689. var val1Length = val1.length;
  21690. //They both need to have the same length
  21691. if(val1Length !== val2.length) {
  21692. throw 'Can\'t interpolate between "' + val1[0] + '" and "' + val2[0] + '"';
  21693. }
  21694. //Add the format string as first element.
  21695. var interpolated = [val1[0]];
  21696. valueIndex = 1;
  21697. for(; valueIndex < val1Length; valueIndex++) {
  21698. //That's the line where the two numbers are actually interpolated.
  21699. interpolated[valueIndex] = val1[valueIndex] + ((val2[valueIndex] - val1[valueIndex]) * progress);
  21700. }
  21701. return interpolated;
  21702. };
  21703. /**
  21704. * Interpolates the numeric values into the format string.
  21705. */
  21706. var _interpolateString = function(val) {
  21707. var valueIndex = 1;
  21708. rxInterpolateString.lastIndex = 0;
  21709. return val[0].replace(rxInterpolateString, function() {
  21710. return val[valueIndex++];
  21711. });
  21712. };
  21713. /**
  21714. * Resets the class and style attribute to what it was before skrollr manipulated the element.
  21715. * Also remembers the values it had before reseting, in order to undo the reset.
  21716. */
  21717. var _reset = function(elements, undo) {
  21718. //We accept a single element or an array of elements.
  21719. elements = [].concat(elements);
  21720. var skrollable;
  21721. var element;
  21722. var elementsIndex = 0;
  21723. var elementsLength = elements.length;
  21724. for(; elementsIndex < elementsLength; elementsIndex++) {
  21725. element = elements[elementsIndex];
  21726. skrollable = _skrollables[element[SKROLLABLE_ID_DOM_PROPERTY]];
  21727. //Couldn't find the skrollable for this DOM element.
  21728. if(!skrollable) {
  21729. continue;
  21730. }
  21731. if(undo) {
  21732. //Reset class and style to the "dirty" (set by skrollr) values.
  21733. element.style.cssText = skrollable.dirtyStyleAttr;
  21734. _updateClass(element, skrollable.dirtyClassAttr);
  21735. } else {
  21736. //Remember the "dirty" (set by skrollr) class and style.
  21737. skrollable.dirtyStyleAttr = element.style.cssText;
  21738. skrollable.dirtyClassAttr = _getClass(element);
  21739. //Reset class and style to what it originally was.
  21740. element.style.cssText = skrollable.styleAttr;
  21741. _updateClass(element, skrollable.classAttr);
  21742. }
  21743. }
  21744. };
  21745. /**
  21746. * Detects support for 3d transforms by applying it to the skrollr-body.
  21747. */
  21748. var _detect3DTransforms = function() {
  21749. _translateZ = 'translateZ(0)';
  21750. skrollr.setStyle(_skrollrBody, 'transform', _translateZ);
  21751. var computedStyle = getStyle(_skrollrBody);
  21752. var computedTransform = computedStyle.getPropertyValue('transform');
  21753. var computedTransformWithPrefix = computedStyle.getPropertyValue(theDashedCSSPrefix + 'transform');
  21754. var has3D = (computedTransform && computedTransform !== 'none') || (computedTransformWithPrefix && computedTransformWithPrefix !== 'none');
  21755. if(!has3D) {
  21756. _translateZ = '';
  21757. }
  21758. };
  21759. /**
  21760. * Set the CSS property on the given element. Sets prefixed properties as well.
  21761. */
  21762. skrollr.setStyle = function(el, prop, val) {
  21763. var style = el.style;
  21764. //Camel case.
  21765. prop = prop.replace(rxCamelCase, rxCamelCaseFn).replace('-', '');
  21766. //Make sure z-index gets a <integer>.
  21767. //This is the only <integer> case we need to handle.
  21768. if(prop === 'zIndex') {
  21769. if(isNaN(val)) {
  21770. //If it's not a number, don't touch it.
  21771. //It could for example be "auto" (#351).
  21772. style[prop] = val;
  21773. } else {
  21774. //Floor the number.
  21775. style[prop] = '' + (val | 0);
  21776. }
  21777. }
  21778. //#64: "float" can't be set across browsers. Needs to use "cssFloat" for all except IE.
  21779. else if(prop === 'float') {
  21780. style.styleFloat = style.cssFloat = val;
  21781. }
  21782. else {
  21783. //Need try-catch for old IE.
  21784. try {
  21785. //Set prefixed property if there's a prefix.
  21786. if(theCSSPrefix) {
  21787. style[theCSSPrefix + prop.slice(0,1).toUpperCase() + prop.slice(1)] = val;
  21788. }
  21789. //Set unprefixed.
  21790. style[prop] = val;
  21791. } catch(ignore) {}
  21792. }
  21793. };
  21794. /**
  21795. * Cross browser event handling.
  21796. */
  21797. var _addEvent = skrollr.addEvent = function(element, names, callback) {
  21798. var intermediate = function(e) {
  21799. //Normalize IE event stuff.
  21800. e = e || window.event;
  21801. if(!e.target) {
  21802. e.target = e.srcElement;
  21803. }
  21804. if(!e.preventDefault) {
  21805. e.preventDefault = function() {
  21806. e.returnValue = false;
  21807. e.defaultPrevented = true;
  21808. };
  21809. }
  21810. return callback.call(this, e);
  21811. };
  21812. names = names.split(' ');
  21813. var name;
  21814. var nameCounter = 0;
  21815. var namesLength = names.length;
  21816. for(; nameCounter < namesLength; nameCounter++) {
  21817. name = names[nameCounter];
  21818. if(element.addEventListener) {
  21819. element.addEventListener(name, callback, false);
  21820. } else {
  21821. element.attachEvent('on' + name, intermediate);
  21822. }
  21823. //Remember the events to be able to flush them later.
  21824. _registeredEvents.push({
  21825. element: element,
  21826. name: name,
  21827. listener: callback
  21828. });
  21829. }
  21830. };
  21831. var _removeEvent = skrollr.removeEvent = function(element, names, callback) {
  21832. names = names.split(' ');
  21833. var nameCounter = 0;
  21834. var namesLength = names.length;
  21835. for(; nameCounter < namesLength; nameCounter++) {
  21836. if(element.removeEventListener) {
  21837. element.removeEventListener(names[nameCounter], callback, false);
  21838. } else {
  21839. element.detachEvent('on' + names[nameCounter], callback);
  21840. }
  21841. }
  21842. };
  21843. var _removeAllEvents = function() {
  21844. var eventData;
  21845. var eventCounter = 0;
  21846. var eventsLength = _registeredEvents.length;
  21847. for(; eventCounter < eventsLength; eventCounter++) {
  21848. eventData = _registeredEvents[eventCounter];
  21849. _removeEvent(eventData.element, eventData.name, eventData.listener);
  21850. }
  21851. _registeredEvents = [];
  21852. };
  21853. var _emitEvent = function(element, name, direction) {
  21854. if(_listeners.keyframe) {
  21855. _listeners.keyframe.call(_instance, element, name, direction);
  21856. }
  21857. };
  21858. var _reflow = function() {
  21859. var pos = _instance.getScrollTop();
  21860. //Will be recalculated by _updateDependentKeyFrames.
  21861. _maxKeyFrame = 0;
  21862. if(_forceHeight && !_isMobile) {
  21863. //un-"force" the height to not mess with the calculations in _updateDependentKeyFrames (#216).
  21864. body.style.height = '';
  21865. }
  21866. _updateDependentKeyFrames();
  21867. if(_forceHeight && !_isMobile) {
  21868. //"force" the height.
  21869. body.style.height = (_maxKeyFrame + documentElement.clientHeight) + 'px';
  21870. }
  21871. //The scroll offset may now be larger than needed (on desktop the browser/os prevents scrolling farther than the bottom).
  21872. if(_isMobile) {
  21873. _instance.setScrollTop(Math.min(_instance.getScrollTop(), _maxKeyFrame));
  21874. } else {
  21875. //Remember and reset the scroll pos (#217).
  21876. _instance.setScrollTop(pos, true);
  21877. }
  21878. _forceRender = true;
  21879. };
  21880. /*
  21881. * Returns a copy of the constants object where all functions and strings have been evaluated.
  21882. */
  21883. var _processConstants = function() {
  21884. var viewportHeight = documentElement.clientHeight;
  21885. var copy = {};
  21886. var prop;
  21887. var value;
  21888. for(prop in _constants) {
  21889. value = _constants[prop];
  21890. if(typeof value === 'function') {
  21891. value = value.call(_instance);
  21892. }
  21893. //Percentage offset.
  21894. else if((/p$/).test(value)) {
  21895. value = (value.slice(0, -1) / 100) * viewportHeight;
  21896. }
  21897. copy[prop] = value;
  21898. }
  21899. return copy;
  21900. };
  21901. /*
  21902. * Returns the height of the document.
  21903. */
  21904. var _getDocumentHeight = function() {
  21905. var skrollrBodyHeight = 0;
  21906. var bodyHeight;
  21907. if(_skrollrBody) {
  21908. skrollrBodyHeight = Math.max(_skrollrBody.offsetHeight, _skrollrBody.scrollHeight);
  21909. }
  21910. bodyHeight = Math.max(skrollrBodyHeight, body.scrollHeight, body.offsetHeight, documentElement.scrollHeight, documentElement.offsetHeight, documentElement.clientHeight);
  21911. return bodyHeight - documentElement.clientHeight;
  21912. };
  21913. /**
  21914. * Returns a string of space separated classnames for the current element.
  21915. * Works with SVG as well.
  21916. */
  21917. var _getClass = function(element) {
  21918. var prop = 'className';
  21919. //SVG support by using className.baseVal instead of just className.
  21920. if(window.SVGElement && element instanceof window.SVGElement) {
  21921. element = element[prop];
  21922. prop = 'baseVal';
  21923. }
  21924. return element[prop];
  21925. };
  21926. /**
  21927. * Adds and removes a CSS classes.
  21928. * Works with SVG as well.
  21929. * add and remove are arrays of strings,
  21930. * or if remove is ommited add is a string and overwrites all classes.
  21931. */
  21932. var _updateClass = function(element, add, remove) {
  21933. var prop = 'className';
  21934. //SVG support by using className.baseVal instead of just className.
  21935. if(window.SVGElement && element instanceof window.SVGElement) {
  21936. element = element[prop];
  21937. prop = 'baseVal';
  21938. }
  21939. //When remove is ommited, we want to overwrite/set the classes.
  21940. if(remove === undefined) {
  21941. element[prop] = add;
  21942. return;
  21943. }
  21944. //Cache current classes. We will work on a string before passing back to DOM.
  21945. var val = element[prop];
  21946. //All classes to be removed.
  21947. var classRemoveIndex = 0;
  21948. var removeLength = remove.length;
  21949. for(; classRemoveIndex < removeLength; classRemoveIndex++) {
  21950. val = _untrim(val).replace(_untrim(remove[classRemoveIndex]), ' ');
  21951. }
  21952. val = _trim(val);
  21953. //All classes to be added.
  21954. var classAddIndex = 0;
  21955. var addLength = add.length;
  21956. for(; classAddIndex < addLength; classAddIndex++) {
  21957. //Only add if el not already has class.
  21958. if(_untrim(val).indexOf(_untrim(add[classAddIndex])) === -1) {
  21959. val += ' ' + add[classAddIndex];
  21960. }
  21961. }
  21962. element[prop] = _trim(val);
  21963. };
  21964. var _trim = function(a) {
  21965. return a.replace(rxTrim, '');
  21966. };
  21967. /**
  21968. * Adds a space before and after the string.
  21969. */
  21970. var _untrim = function(a) {
  21971. return ' ' + a + ' ';
  21972. };
  21973. var _now = Date.now || function() {
  21974. return +new Date();
  21975. };
  21976. var _keyFrameComparator = function(a, b) {
  21977. return a.frame - b.frame;
  21978. };
  21979. /*
  21980. * Private variables.
  21981. */
  21982. //Singleton
  21983. var _instance;
  21984. /*
  21985. A list of all elements which should be animated associated with their the metadata.
  21986. Exmaple skrollable with two key frames animating from 100px width to 20px:
  21987. skrollable = {
  21988. element: <the DOM element>,
  21989. styleAttr: <style attribute of the element before skrollr>,
  21990. classAttr: <class attribute of the element before skrollr>,
  21991. keyFrames: [
  21992. {
  21993. frame: 100,
  21994. props: {
  21995. width: {
  21996. value: ['{?}px', 100],
  21997. easing: <reference to easing function>
  21998. }
  21999. },
  22000. mode: "absolute"
  22001. },
  22002. {
  22003. frame: 200,
  22004. props: {
  22005. width: {
  22006. value: ['{?}px', 20],
  22007. easing: <reference to easing function>
  22008. }
  22009. },
  22010. mode: "absolute"
  22011. }
  22012. ]
  22013. };
  22014. */
  22015. var _skrollables;
  22016. var _skrollrBody;
  22017. var _listeners;
  22018. var _forceHeight;
  22019. var _maxKeyFrame = 0;
  22020. var _scale = 1;
  22021. var _constants;
  22022. var _mobileDeceleration;
  22023. //Current direction (up/down).
  22024. var _direction = 'down';
  22025. //The last top offset value. Needed to determine direction.
  22026. var _lastTop = -1;
  22027. //The last time we called the render method (doesn't mean we rendered!).
  22028. var _lastRenderCall = _now();
  22029. //For detecting if it actually resized (#271).
  22030. var _lastViewportWidth = 0;
  22031. var _lastViewportHeight = 0;
  22032. var _requestReflow = false;
  22033. //Will contain data about a running scrollbar animation, if any.
  22034. var _scrollAnimation;
  22035. var _smoothScrollingEnabled;
  22036. var _smoothScrollingDuration;
  22037. //Will contain settins for smooth scrolling if enabled.
  22038. var _smoothScrolling;
  22039. //Can be set by any operation/event to force rendering even if the scrollbar didn't move.
  22040. var _forceRender;
  22041. //Each skrollable gets an unique ID incremented for each skrollable.
  22042. //The ID is the index in the _skrollables array.
  22043. var _skrollableIdCounter = 0;
  22044. var _edgeStrategy;
  22045. //Mobile specific vars. Will be stripped by UglifyJS when not in use.
  22046. var _isMobile = false;
  22047. //The virtual scroll offset when using mobile scrolling.
  22048. var _mobileOffset = 0;
  22049. //If the browser supports 3d transforms, this will be filled with 'translateZ(0)' (empty string otherwise).
  22050. var _translateZ;
  22051. //Will contain data about registered events by skrollr.
  22052. var _registeredEvents = [];
  22053. //Animation frame id returned by RequestAnimationFrame (or timeout when RAF is not supported).
  22054. var _animFrame;
  22055. //Expose skrollr as either a global variable or a require.js module.
  22056. if(typeof define === 'function' && define.amd) {
  22057. define([], function () {
  22058. return skrollr;
  22059. });
  22060. } else if (typeof module !== 'undefined' && module.exports) {
  22061. module.exports = skrollr;
  22062. } else {
  22063. window.skrollr = skrollr;
  22064. }
  22065. }(window, document));
  22066. /*!
  22067. jQuery Smooth Scroll
  22068. Version: 2.2.0
  22069. Plugin URL: https://github.com/kswedberg/jquery-smooth-scroll
  22070. License: Copyright (c) 2017 Karl Swedberg | Licensed under MIT
  22071. !*/
  22072. (function(factory) {
  22073. if (typeof define === 'function' && define.amd) {
  22074. // AMD. Register as an anonymous module.
  22075. define(['jquery'], factory);
  22076. } else if (typeof module === 'object' && module.exports) {
  22077. // CommonJS
  22078. factory(require('jquery'));
  22079. } else {
  22080. // Browser globals
  22081. factory(jQuery);
  22082. }
  22083. }(function($) {
  22084. var version = '2.2.0';
  22085. var optionOverrides = {};
  22086. var defaults = {
  22087. exclude: [],
  22088. excludeWithin: [],
  22089. offset: 0,
  22090. // one of 'top' or 'left'
  22091. direction: 'top',
  22092. // if set, bind click events through delegation
  22093. // supported since jQuery 1.4.2
  22094. delegateSelector: null,
  22095. // jQuery set of elements you wish to scroll (for $.smoothScroll).
  22096. // if null (default), $('html, body').firstScrollable() is used.
  22097. scrollElement: null,
  22098. // only use if you want to override default behavior
  22099. scrollTarget: null,
  22100. // automatically focus the target element after scrolling to it
  22101. autoFocus: false,
  22102. // fn(opts) function to be called before scrolling occurs.
  22103. // `this` is the element(s) being scrolled
  22104. beforeScroll: function() {},
  22105. // fn(opts) function to be called after scrolling occurs.
  22106. // `this` is the triggering element
  22107. afterScroll: function() {},
  22108. // easing name. jQuery comes with "swing" and "linear." For others, you'll need an easing plugin
  22109. // from jQuery UI or elsewhere
  22110. easing: 'swing',
  22111. // speed can be a number or 'auto'
  22112. // if 'auto', the speed will be calculated based on the formula:
  22113. // (current scroll position - target scroll position) / autoCoeffic
  22114. speed: 400,
  22115. // coefficient for "auto" speed
  22116. autoCoefficient: 2,
  22117. // $.fn.smoothScroll only: whether to prevent the default click action
  22118. preventDefault: true
  22119. };
  22120. var getScrollable = function(opts) {
  22121. var scrollable = [];
  22122. var scrolled = false;
  22123. var dir = opts.dir && opts.dir === 'left' ? 'scrollLeft' : 'scrollTop';
  22124. this.each(function() {
  22125. var el = $(this);
  22126. if (this === document || this === window) {
  22127. return;
  22128. }
  22129. if (document.scrollingElement && (this === document.documentElement || this === document.body)) {
  22130. scrollable.push(document.scrollingElement);
  22131. return false;
  22132. }
  22133. if (el[dir]() > 0) {
  22134. scrollable.push(this);
  22135. } else {
  22136. // if scroll(Top|Left) === 0, nudge the element 1px and see if it moves
  22137. el[dir](1);
  22138. scrolled = el[dir]() > 0;
  22139. if (scrolled) {
  22140. scrollable.push(this);
  22141. }
  22142. // then put it back, of course
  22143. el[dir](0);
  22144. }
  22145. });
  22146. if (!scrollable.length) {
  22147. this.each(function() {
  22148. // If no scrollable elements and <html> has scroll-behavior:smooth because
  22149. // "When this property is specified on the root element, it applies to the viewport instead."
  22150. // and "The scroll-behavior property of the … body element is *not* propagated to the viewport."
  22151. // → https://drafts.csswg.org/cssom-view/#propdef-scroll-behavior
  22152. if (this === document.documentElement && $(this).css('scrollBehavior') === 'smooth') {
  22153. scrollable = [this];
  22154. }
  22155. // If still no scrollable elements, fall back to <body>,
  22156. // if it's in the jQuery collection
  22157. // (doing this because Safari sets scrollTop async,
  22158. // so can't set it to 1 and immediately get the value.)
  22159. if (!scrollable.length && this.nodeName === 'BODY') {
  22160. scrollable = [this];
  22161. }
  22162. });
  22163. }
  22164. // Use the first scrollable element if we're calling firstScrollable()
  22165. if (opts.el === 'first' && scrollable.length > 1) {
  22166. scrollable = [scrollable[0]];
  22167. }
  22168. return scrollable;
  22169. };
  22170. var rRelative = /^([\-\+]=)(\d+)/;
  22171. $.fn.extend({
  22172. scrollable: function(dir) {
  22173. var scrl = getScrollable.call(this, {dir: dir});
  22174. return this.pushStack(scrl);
  22175. },
  22176. firstScrollable: function(dir) {
  22177. var scrl = getScrollable.call(this, {el: 'first', dir: dir});
  22178. return this.pushStack(scrl);
  22179. },
  22180. smoothScroll: function(options, extra) {
  22181. options = options || {};
  22182. if (options === 'options') {
  22183. if (!extra) {
  22184. return this.first().data('ssOpts');
  22185. }
  22186. return this.each(function() {
  22187. var $this = $(this);
  22188. var opts = $.extend($this.data('ssOpts') || {}, extra);
  22189. $(this).data('ssOpts', opts);
  22190. });
  22191. }
  22192. var opts = $.extend({}, $.fn.smoothScroll.defaults, options);
  22193. var clickHandler = function(event) {
  22194. var escapeSelector = function(str) {
  22195. return str.replace(/(:|\.|\/)/g, '\\$1');
  22196. };
  22197. var link = this;
  22198. var $link = $(this);
  22199. var thisOpts = $.extend({}, opts, $link.data('ssOpts') || {});
  22200. var exclude = opts.exclude;
  22201. var excludeWithin = thisOpts.excludeWithin;
  22202. var elCounter = 0;
  22203. var ewlCounter = 0;
  22204. var include = true;
  22205. var clickOpts = {};
  22206. var locationPath = $.smoothScroll.filterPath(location.pathname);
  22207. var linkPath = $.smoothScroll.filterPath(link.pathname);
  22208. var hostMatch = location.hostname === link.hostname || !link.hostname;
  22209. var pathMatch = thisOpts.scrollTarget || (linkPath === locationPath);
  22210. var thisHash = escapeSelector(link.hash);
  22211. if (thisHash && !$(thisHash).length) {
  22212. include = false;
  22213. }
  22214. if (!thisOpts.scrollTarget && (!hostMatch || !pathMatch || !thisHash)) {
  22215. include = false;
  22216. } else {
  22217. while (include && elCounter < exclude.length) {
  22218. if ($link.is(escapeSelector(exclude[elCounter++]))) {
  22219. include = false;
  22220. }
  22221. }
  22222. while (include && ewlCounter < excludeWithin.length) {
  22223. if ($link.closest(excludeWithin[ewlCounter++]).length) {
  22224. include = false;
  22225. }
  22226. }
  22227. }
  22228. if (include) {
  22229. if (thisOpts.preventDefault) {
  22230. event.preventDefault();
  22231. }
  22232. $.extend(clickOpts, thisOpts, {
  22233. scrollTarget: thisOpts.scrollTarget || thisHash,
  22234. link: link
  22235. });
  22236. $.smoothScroll(clickOpts);
  22237. }
  22238. };
  22239. if (options.delegateSelector !== null) {
  22240. this
  22241. .off('click.smoothscroll', options.delegateSelector)
  22242. .on('click.smoothscroll', options.delegateSelector, clickHandler);
  22243. } else {
  22244. this
  22245. .off('click.smoothscroll')
  22246. .on('click.smoothscroll', clickHandler);
  22247. }
  22248. return this;
  22249. }
  22250. });
  22251. var getExplicitOffset = function(val) {
  22252. var explicit = {relative: ''};
  22253. var parts = typeof val === 'string' && rRelative.exec(val);
  22254. if (typeof val === 'number') {
  22255. explicit.px = val;
  22256. } else if (parts) {
  22257. explicit.relative = parts[1];
  22258. explicit.px = parseFloat(parts[2]) || 0;
  22259. }
  22260. return explicit;
  22261. };
  22262. var onAfterScroll = function(opts) {
  22263. var $tgt = $(opts.scrollTarget);
  22264. if (opts.autoFocus && $tgt.length) {
  22265. $tgt[0].focus();
  22266. if (!$tgt.is(document.activeElement)) {
  22267. $tgt.prop({tabIndex: -1});
  22268. $tgt[0].focus();
  22269. }
  22270. }
  22271. opts.afterScroll.call(opts.link, opts);
  22272. };
  22273. $.smoothScroll = function(options, px) {
  22274. if (options === 'options' && typeof px === 'object') {
  22275. return $.extend(optionOverrides, px);
  22276. }
  22277. var opts, $scroller, speed, delta;
  22278. var explicitOffset = getExplicitOffset(options);
  22279. var scrollTargetOffset = {};
  22280. var scrollerOffset = 0;
  22281. var offPos = 'offset';
  22282. var scrollDir = 'scrollTop';
  22283. var aniProps = {};
  22284. var aniOpts = {};
  22285. if (explicitOffset.px) {
  22286. opts = $.extend({link: null}, $.fn.smoothScroll.defaults, optionOverrides);
  22287. } else {
  22288. opts = $.extend({link: null}, $.fn.smoothScroll.defaults, options || {}, optionOverrides);
  22289. if (opts.scrollElement) {
  22290. offPos = 'position';
  22291. if (opts.scrollElement.css('position') === 'static') {
  22292. opts.scrollElement.css('position', 'relative');
  22293. }
  22294. }
  22295. if (px) {
  22296. explicitOffset = getExplicitOffset(px);
  22297. }
  22298. }
  22299. scrollDir = opts.direction === 'left' ? 'scrollLeft' : scrollDir;
  22300. if (opts.scrollElement) {
  22301. $scroller = opts.scrollElement;
  22302. if (!explicitOffset.px && !(/^(?:HTML|BODY)$/).test($scroller[0].nodeName)) {
  22303. scrollerOffset = $scroller[scrollDir]();
  22304. }
  22305. } else {
  22306. $scroller = $('html, body').firstScrollable(opts.direction);
  22307. }
  22308. // beforeScroll callback function must fire before calculating offset
  22309. opts.beforeScroll.call($scroller, opts);
  22310. scrollTargetOffset = explicitOffset.px ? explicitOffset : {
  22311. relative: '',
  22312. px: ($(opts.scrollTarget)[offPos]() && $(opts.scrollTarget)[offPos]()[opts.direction]) || 0
  22313. };
  22314. aniProps[scrollDir] = scrollTargetOffset.relative + (scrollTargetOffset.px + scrollerOffset + opts.offset);
  22315. speed = opts.speed;
  22316. // automatically calculate the speed of the scroll based on distance / coefficient
  22317. if (speed === 'auto') {
  22318. // $scroller[scrollDir]() is position before scroll, aniProps[scrollDir] is position after
  22319. // When delta is greater, speed will be greater.
  22320. delta = Math.abs(aniProps[scrollDir] - $scroller[scrollDir]());
  22321. // Divide the delta by the coefficient
  22322. speed = delta / opts.autoCoefficient;
  22323. }
  22324. aniOpts = {
  22325. duration: speed,
  22326. easing: opts.easing,
  22327. complete: function() {
  22328. onAfterScroll(opts);
  22329. }
  22330. };
  22331. if (opts.step) {
  22332. aniOpts.step = opts.step;
  22333. }
  22334. if ($scroller.length) {
  22335. $scroller.stop().animate(aniProps, aniOpts);
  22336. } else {
  22337. onAfterScroll(opts);
  22338. }
  22339. };
  22340. $.smoothScroll.version = version;
  22341. $.smoothScroll.filterPath = function(string) {
  22342. string = string || '';
  22343. return string
  22344. .replace(/^\//, '')
  22345. .replace(/(?:index|default).[a-zA-Z]{3,4}$/, '')
  22346. .replace(/\/$/, '');
  22347. };
  22348. // default options
  22349. $.fn.smoothScroll.defaults = defaults;
  22350. }));
  22351. /*!
  22352. Splitting
  22353. Version: 1.0.5
  22354. Plugin URL: https://splitting.js.org/
  22355. License: Copyright © 2018-present Stephen Shaw | Licensed under the MIT license
  22356. !*/
  22357. (function (global, factory) {
  22358. typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
  22359. typeof define === 'function' && define.amd ? define(factory) :
  22360. (global.Splitting = factory());
  22361. }(this, (function () { 'use strict';
  22362. var root = document;
  22363. var createText = root.createTextNode.bind(root);
  22364. /**
  22365. * # setProperty
  22366. * Apply a CSS var
  22367. * @param {HTMLElement} el
  22368. * @param {string} varName
  22369. * @param {string|number} value
  22370. */
  22371. function setProperty(el, varName, value) {
  22372. el.style.setProperty(varName, value);
  22373. }
  22374. /**
  22375. *
  22376. * @param {!HTMLElement} el
  22377. * @param {!HTMLElement} child
  22378. */
  22379. function appendChild(el, child) {
  22380. return el.appendChild(child);
  22381. }
  22382. /**
  22383. *
  22384. * @param {!HTMLElement} parent
  22385. * @param {string} key
  22386. * @param {string} text
  22387. * @param {boolean} whitespace
  22388. */
  22389. function createElement(parent, key, text, whitespace) {
  22390. var el = root.createElement('span');
  22391. key && (el.className = key);
  22392. if (text) {
  22393. !whitespace && el.setAttribute("data-" + key, text);
  22394. el.textContent = text;
  22395. }
  22396. return (parent && appendChild(parent, el)) || el;
  22397. }
  22398. /**
  22399. *
  22400. * @param {!HTMLElement} el
  22401. * @param {string} key
  22402. */
  22403. function getData(el, key) {
  22404. return el.getAttribute("data-" + key)
  22405. }
  22406. /**
  22407. *
  22408. * @param {import('../types').Target} e
  22409. * @param {!HTMLElement} parent
  22410. * @returns {!Array<!HTMLElement>}
  22411. */
  22412. function $(e, parent) {
  22413. return !e || e.length == 0
  22414. ? // null or empty string returns empty array
  22415. []
  22416. : e.nodeName
  22417. ? // a single element is wrapped in an array
  22418. [e]
  22419. : // selector and NodeList are converted to Element[]
  22420. [].slice.call(e[0].nodeName ? e : (parent || root).querySelectorAll(e));
  22421. }
  22422. /**
  22423. * Creates and fills an array with the value provided
  22424. * @param {number} len
  22425. * @param {() => T} valueProvider
  22426. * @return {T}
  22427. * @template T
  22428. */
  22429. function Array2D(len) {
  22430. var a = [];
  22431. for (; len--; ) {
  22432. a[len] = [];
  22433. }
  22434. return a;
  22435. }
  22436. /**
  22437. * A for loop wrapper used to reduce js minified size.
  22438. * @param {!Array<T>} items
  22439. * @param {function(T):void} consumer
  22440. * @template T
  22441. */
  22442. function each(items, consumer) {
  22443. items && items.some(consumer);
  22444. }
  22445. /**
  22446. * @param {T} obj
  22447. * @return {function(string):*}
  22448. * @template T
  22449. */
  22450. function selectFrom(obj) {
  22451. return function (key) {
  22452. return obj[key];
  22453. }
  22454. }
  22455. /**
  22456. * # Splitting.index
  22457. * Index split elements and add them to a Splitting instance.
  22458. *
  22459. * @param {HTMLElement} element
  22460. * @param {string} key
  22461. * @param {!Array<!HTMLElement> | !Array<!Array<!HTMLElement>>} items
  22462. */
  22463. function index(element, key, items) {
  22464. var prefix = '--' + key;
  22465. var cssVar = prefix + "-index";
  22466. each(items, function (items, i) {
  22467. if (Array.isArray(items)) {
  22468. each(items, function(item) {
  22469. setProperty(item, cssVar, i);
  22470. });
  22471. } else {
  22472. setProperty(items, cssVar, i);
  22473. }
  22474. });
  22475. setProperty(element, prefix + "-total", items.length);
  22476. }
  22477. /**
  22478. * @type {Record<string, import('./types').ISplittingPlugin>}
  22479. */
  22480. var plugins = {};
  22481. /**
  22482. * @param {string} by
  22483. * @param {string} parent
  22484. * @param {!Array<string>} deps
  22485. * @return {!Array<string>}
  22486. */
  22487. function resolvePlugins(by, parent, deps) {
  22488. // skip if already visited this dependency
  22489. var index = deps.indexOf(by);
  22490. if (index == -1) {
  22491. // if new to dependency array, add to the beginning
  22492. deps.unshift(by);
  22493. // recursively call this function for all dependencies
  22494. var plugin = plugins[by];
  22495. if (!plugin) {
  22496. throw new Error("plugin not loaded: " + by);
  22497. }
  22498. each(plugin.depends, function(p) {
  22499. resolvePlugins(p, by, deps);
  22500. });
  22501. } else {
  22502. // if this dependency was added already move to the left of
  22503. // the parent dependency so it gets loaded in order
  22504. var indexOfParent = deps.indexOf(parent);
  22505. deps.splice(index, 1);
  22506. deps.splice(indexOfParent, 0, by);
  22507. }
  22508. return deps;
  22509. }
  22510. /**
  22511. * Internal utility for creating plugins... essentially to reduce
  22512. * the size of the library
  22513. * @param {string} by
  22514. * @param {string} key
  22515. * @param {string[]} depends
  22516. * @param {Function} split
  22517. * @returns {import('./types').ISplittingPlugin}
  22518. */
  22519. function createPlugin(by, depends, key, split) {
  22520. return {
  22521. by: by,
  22522. depends: depends,
  22523. key: key,
  22524. split: split
  22525. }
  22526. }
  22527. /**
  22528. *
  22529. * @param {string} by
  22530. * @returns {import('./types').ISplittingPlugin[]}
  22531. */
  22532. function resolve(by) {
  22533. return resolvePlugins(by, 0, []).map(selectFrom(plugins));
  22534. }
  22535. /**
  22536. * Adds a new plugin to splitting
  22537. * @param {import('./types').ISplittingPlugin} opts
  22538. */
  22539. function add(opts) {
  22540. plugins[opts.by] = opts;
  22541. }
  22542. /**
  22543. * # Splitting.split
  22544. * Split an element's textContent into individual elements
  22545. * @param {!HTMLElement} el Element to split
  22546. * @param {string} key
  22547. * @param {string} splitOn
  22548. * @param {boolean} includePrevious
  22549. * @param {boolean} preserveWhitespace
  22550. * @return {!Array<!HTMLElement>}
  22551. */
  22552. function splitText(el, key, splitOn, includePrevious, preserveWhitespace) {
  22553. // Combine any strange text nodes or empty whitespace.
  22554. el.normalize();
  22555. // Use fragment to prevent unnecessary DOM thrashing.
  22556. var elements = [];
  22557. var F = document.createDocumentFragment();
  22558. if (includePrevious) {
  22559. elements.push(el.previousSibling);
  22560. }
  22561. var allElements = [];
  22562. $(el.childNodes).some(function(next) {
  22563. if (next.tagName && !next.hasChildNodes()) {
  22564. // keep elements without child nodes (no text and no children)
  22565. allElements.push(next);
  22566. return;
  22567. }
  22568. // Recursively run through child nodes
  22569. if (next.childNodes && next.childNodes.length) {
  22570. allElements.push(next);
  22571. elements.push.apply(elements, splitText(next, key, splitOn, includePrevious, preserveWhitespace));
  22572. return;
  22573. }
  22574. // Get the text to split, trimming out the whitespace
  22575. /** @type {string} */
  22576. var wholeText = next.wholeText || '';
  22577. var contents = wholeText.trim();
  22578. // If there's no text left after trimming whitespace, continue the loop
  22579. if (contents.length) {
  22580. // insert leading space if there was one
  22581. if (wholeText[0] === ' ') {
  22582. allElements.push(createText(' '));
  22583. }
  22584. // Concatenate the split text children back into the full array
  22585. each(contents.split(splitOn), function(splitText, i) {
  22586. if (i && preserveWhitespace) {
  22587. allElements.push(createElement(F, "whitespace", " ", preserveWhitespace));
  22588. }
  22589. var splitEl = createElement(F, key, splitText);
  22590. elements.push(splitEl);
  22591. allElements.push(splitEl);
  22592. });
  22593. // insert trailing space if there was one
  22594. if (wholeText[wholeText.length - 1] === ' ') {
  22595. allElements.push(createText(' '));
  22596. }
  22597. }
  22598. });
  22599. each(allElements, function(el) {
  22600. appendChild(F, el);
  22601. });
  22602. // Clear out the existing element
  22603. el.innerHTML = "";
  22604. appendChild(el, F);
  22605. return elements;
  22606. }
  22607. /** an empty value */
  22608. var _ = 0;
  22609. function copy(dest, src) {
  22610. for (var k in src) {
  22611. dest[k] = src[k];
  22612. }
  22613. return dest;
  22614. }
  22615. var WORDS = 'words';
  22616. var wordPlugin = createPlugin(
  22617. /* by= */ WORDS,
  22618. /* depends= */ _,
  22619. /* key= */ 'word',
  22620. /* split= */ function(el) {
  22621. return splitText(el, 'word', /\s+/, 0, 1)
  22622. }
  22623. );
  22624. var CHARS = "chars";
  22625. var charPlugin = createPlugin(
  22626. /* by= */ CHARS,
  22627. /* depends= */ [WORDS],
  22628. /* key= */ "char",
  22629. /* split= */ function(el, options, ctx) {
  22630. var results = [];
  22631. each(ctx[WORDS], function(word, i) {
  22632. results.push.apply(results, splitText(word, "char", "", options.whitespace && i));
  22633. });
  22634. return results;
  22635. }
  22636. );
  22637. /**
  22638. * # Splitting
  22639. *
  22640. * @param {import('./types').ISplittingOptions} opts
  22641. * @return {!Array<*>}
  22642. */
  22643. function Splitting (opts) {
  22644. opts = opts || {};
  22645. var key = opts.key;
  22646. return $(opts.target || '[data-splitting]').map(function(el) {
  22647. var ctx = el['🍌'];
  22648. if (!opts.force && ctx) {
  22649. return ctx;
  22650. }
  22651. ctx = el['🍌'] = { el: el };
  22652. var by = opts.by || getData(el, 'splitting');
  22653. if (!by || by == 'true') {
  22654. by = CHARS;
  22655. }
  22656. var items = resolve(by);
  22657. var opts2 = copy({}, opts);
  22658. each(items, function(plugin) {
  22659. if (plugin.split) {
  22660. var pluginBy = plugin.by;
  22661. var key2 = (key ? '-' + key : '') + plugin.key;
  22662. var results = plugin.split(el, opts2, ctx);
  22663. key2 && index(el, key2, results);
  22664. ctx[pluginBy] = results;
  22665. el.classList.add(pluginBy);
  22666. }
  22667. });
  22668. el.classList.add('splitting');
  22669. return ctx;
  22670. })
  22671. }
  22672. /**
  22673. * # Splitting.html
  22674. *
  22675. * @param {import('./types').ISplittingOptions} opts
  22676. */
  22677. function html(opts) {
  22678. opts = opts || {};
  22679. var parent = opts.target = createElement();
  22680. parent.innerHTML = opts.content;
  22681. Splitting(opts);
  22682. return parent.outerHTML
  22683. }
  22684. Splitting.html = html;
  22685. Splitting.add = add;
  22686. /**
  22687. * Detects the grid by measuring which elements align to a side of it.
  22688. * @param {!HTMLElement} el
  22689. * @param {import('../core/types').ISplittingOptions} options
  22690. * @param {*} side
  22691. */
  22692. function detectGrid(el, options, side) {
  22693. var items = $(options.matching || el.children, el);
  22694. var c = {};
  22695. each(items, function(w) {
  22696. var val = Math.round(w[side]);
  22697. (c[val] || (c[val] = [])).push(w);
  22698. });
  22699. return Object.keys(c).map(Number).sort(byNumber).map(selectFrom(c));
  22700. }
  22701. /**
  22702. * Sorting function for numbers.
  22703. * @param {number} a
  22704. * @param {number} b
  22705. * @return {number}
  22706. */
  22707. function byNumber(a, b) {
  22708. return a - b;
  22709. }
  22710. var linePlugin = createPlugin(
  22711. /* by= */ 'lines',
  22712. /* depends= */ [WORDS],
  22713. /* key= */ 'line',
  22714. /* split= */ function(el, options, ctx) {
  22715. return detectGrid(el, { matching: ctx[WORDS] }, 'offsetTop')
  22716. }
  22717. );
  22718. var itemPlugin = createPlugin(
  22719. /* by= */ 'items',
  22720. /* depends= */ _,
  22721. /* key= */ 'item',
  22722. /* split= */ function(el, options) {
  22723. return $(options.matching || el.children, el)
  22724. }
  22725. );
  22726. var rowPlugin = createPlugin(
  22727. /* by= */ 'rows',
  22728. /* depends= */ _,
  22729. /* key= */ 'row',
  22730. /* split= */ function(el, options) {
  22731. return detectGrid(el, options, "offsetTop");
  22732. }
  22733. );
  22734. var columnPlugin = createPlugin(
  22735. /* by= */ 'cols',
  22736. /* depends= */ _,
  22737. /* key= */ "col",
  22738. /* split= */ function(el, options) {
  22739. return detectGrid(el, options, "offsetLeft");
  22740. }
  22741. );
  22742. var gridPlugin = createPlugin(
  22743. /* by= */ 'grid',
  22744. /* depends= */ ['rows', 'cols']
  22745. );
  22746. var LAYOUT = "layout";
  22747. var layoutPlugin = createPlugin(
  22748. /* by= */ LAYOUT,
  22749. /* depends= */ _,
  22750. /* key= */ _,
  22751. /* split= */ function(el, opts) {
  22752. // detect and set options
  22753. var rows = opts.rows = +(opts.rows || getData(el, 'rows') || 1);
  22754. var columns = opts.columns = +(opts.columns || getData(el, 'columns') || 1);
  22755. // Seek out the first <img> if the value is true
  22756. opts.image = opts.image || getData(el, 'image') || el.currentSrc || el.src;
  22757. if (opts.image) {
  22758. var img = $("img", el)[0];
  22759. opts.image = img && (img.currentSrc || img.src);
  22760. }
  22761. // add optional image to background
  22762. if (opts.image) {
  22763. setProperty(el, "background-image", "url(" + opts.image + ")");
  22764. }
  22765. var totalCells = rows * columns;
  22766. var elements = [];
  22767. var container = createElement(_, "cell-grid");
  22768. while (totalCells--) {
  22769. // Create a span
  22770. var cell = createElement(container, "cell");
  22771. createElement(cell, "cell-inner");
  22772. elements.push(cell);
  22773. }
  22774. // Append elements back into the parent
  22775. appendChild(el, container);
  22776. return elements;
  22777. }
  22778. );
  22779. var cellRowPlugin = createPlugin(
  22780. /* by= */ "cellRows",
  22781. /* depends= */ [LAYOUT],
  22782. /* key= */ "row",
  22783. /* split= */ function(el, opts, ctx) {
  22784. var rowCount = opts.rows;
  22785. var result = Array2D(rowCount);
  22786. each(ctx[LAYOUT], function(cell, i, src) {
  22787. result[Math.floor(i / (src.length / rowCount))].push(cell);
  22788. });
  22789. return result;
  22790. }
  22791. );
  22792. var cellColumnPlugin = createPlugin(
  22793. /* by= */ "cellColumns",
  22794. /* depends= */ [LAYOUT],
  22795. /* key= */ "col",
  22796. /* split= */ function(el, opts, ctx) {
  22797. var columnCount = opts.columns;
  22798. var result = Array2D(columnCount);
  22799. each(ctx[LAYOUT], function(cell, i) {
  22800. result[i % columnCount].push(cell);
  22801. });
  22802. return result;
  22803. }
  22804. );
  22805. var cellPlugin = createPlugin(
  22806. /* by= */ "cells",
  22807. /* depends= */ ['cellRows', 'cellColumns'],
  22808. /* key= */ "cell",
  22809. /* split= */ function(el, opt, ctx) {
  22810. // re-index the layout as the cells
  22811. return ctx[LAYOUT];
  22812. }
  22813. );
  22814. // install plugins
  22815. // word/char plugins
  22816. add(wordPlugin);
  22817. add(charPlugin);
  22818. add(linePlugin);
  22819. // grid plugins
  22820. add(itemPlugin);
  22821. add(rowPlugin);
  22822. add(columnPlugin);
  22823. add(gridPlugin);
  22824. // cell-layout plugins
  22825. add(layoutPlugin);
  22826. add(cellRowPlugin);
  22827. add(cellColumnPlugin);
  22828. add(cellPlugin);
  22829. return Splitting;
  22830. })));
  22831. /*!
  22832. Sticky-kit
  22833. Version: 1.1.3
  22834. Plugin URL: https://github.com/leafo/sticky-kit
  22835. License: Leaf Corcoran 2015 | Licensed under MIT
  22836. !*/
  22837. (function() {
  22838. var $, win;
  22839. $ = window.jQuery;
  22840. win = $(window);
  22841. $.fn.stick_in_parent = function(opts) {
  22842. var doc, elm, enable_bottoming, fn, i, inner_scrolling, len, manual_spacer, offset_top, outer_width, parent_selector, recalc_every, sticky_class;
  22843. if (opts == null) {
  22844. opts = {};
  22845. }
  22846. 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;
  22847. if (offset_top == null) {
  22848. offset_top = 0;
  22849. }
  22850. if (parent_selector == null) {
  22851. parent_selector = void 0;
  22852. }
  22853. if (inner_scrolling == null) {
  22854. inner_scrolling = true;
  22855. }
  22856. if (sticky_class == null) {
  22857. sticky_class = "is_stuck";
  22858. }
  22859. doc = $(document);
  22860. if (enable_bottoming == null) {
  22861. enable_bottoming = true;
  22862. }
  22863. outer_width = function(el) {
  22864. var _el, computed, w;
  22865. if (window.getComputedStyle) {
  22866. _el = el[0];
  22867. computed = window.getComputedStyle(el[0]);
  22868. w = parseFloat(computed.getPropertyValue("width")) + parseFloat(computed.getPropertyValue("margin-left")) + parseFloat(computed.getPropertyValue("margin-right"));
  22869. if (computed.getPropertyValue("box-sizing") !== "border-box") {
  22870. w += parseFloat(computed.getPropertyValue("border-left-width")) + parseFloat(computed.getPropertyValue("border-right-width")) + parseFloat(computed.getPropertyValue("padding-left")) + parseFloat(computed.getPropertyValue("padding-right"));
  22871. }
  22872. return w;
  22873. } else {
  22874. return el.outerWidth(true);
  22875. }
  22876. };
  22877. fn = function(elm, padding_bottom, parent_top, parent_height, top, height, el_float, detached) {
  22878. var bottomed, detach, fixed, last_pos, last_scroll_height, offset, parent, recalc, recalc_and_tick, recalc_counter, spacer, tick;
  22879. if (elm.data("sticky_kit")) {
  22880. return;
  22881. }
  22882. elm.data("sticky_kit", true);
  22883. last_scroll_height = doc.height();
  22884. parent = elm.parent();
  22885. if (parent_selector != null) {
  22886. parent = parent.closest(parent_selector);
  22887. }
  22888. if (!parent.length) {
  22889. throw "failed to find stick parent";
  22890. }
  22891. fixed = false;
  22892. bottomed = false;
  22893. spacer = manual_spacer != null ? manual_spacer && elm.closest(manual_spacer) : $("<div />");
  22894. if (spacer) {
  22895. spacer.css('position', elm.css('position'));
  22896. }
  22897. recalc = function() {
  22898. var border_top, padding_top, restore;
  22899. if (detached) {
  22900. return;
  22901. }
  22902. last_scroll_height = doc.height();
  22903. border_top = parseInt(parent.css("border-top-width"), 10);
  22904. padding_top = parseInt(parent.css("padding-top"), 10);
  22905. padding_bottom = parseInt(parent.css("padding-bottom"), 10);
  22906. parent_top = parent.offset().top + border_top + padding_top;
  22907. parent_height = parent.height();
  22908. if (fixed) {
  22909. fixed = false;
  22910. bottomed = false;
  22911. if (manual_spacer == null) {
  22912. elm.insertAfter(spacer);
  22913. spacer.detach();
  22914. }
  22915. elm.css({
  22916. position: "",
  22917. top: "",
  22918. width: "",
  22919. bottom: ""
  22920. }).removeClass(sticky_class);
  22921. restore = true;
  22922. }
  22923. top = elm.offset().top - (parseInt(elm.css("margin-top"), 10) || 0) - offset_top;
  22924. height = elm.outerHeight(true);
  22925. el_float = elm.css("float");
  22926. if (spacer) {
  22927. spacer.css({
  22928. width: outer_width(elm),
  22929. height: height,
  22930. display: elm.css("display"),
  22931. "vertical-align": elm.css("vertical-align"),
  22932. "float": el_float
  22933. });
  22934. }
  22935. if (restore) {
  22936. return tick();
  22937. }
  22938. };
  22939. recalc();
  22940. if (height === parent_height) {
  22941. return;
  22942. }
  22943. last_pos = void 0;
  22944. offset = offset_top;
  22945. recalc_counter = recalc_every;
  22946. tick = function() {
  22947. var css, delta, recalced, scroll, will_bottom, win_height;
  22948. if (detached) {
  22949. return;
  22950. }
  22951. recalced = false;
  22952. if (recalc_counter != null) {
  22953. recalc_counter -= 1;
  22954. if (recalc_counter <= 0) {
  22955. recalc_counter = recalc_every;
  22956. recalc();
  22957. recalced = true;
  22958. }
  22959. }
  22960. if (!recalced && doc.height() !== last_scroll_height) {
  22961. recalc();
  22962. recalced = true;
  22963. }
  22964. scroll = win.scrollTop();
  22965. if (last_pos != null) {
  22966. delta = scroll - last_pos;
  22967. }
  22968. last_pos = scroll;
  22969. if (fixed) {
  22970. if (enable_bottoming) {
  22971. will_bottom = scroll + height + offset > parent_height + parent_top;
  22972. if (bottomed && !will_bottom) {
  22973. bottomed = false;
  22974. elm.css({
  22975. position: "fixed",
  22976. bottom: "",
  22977. top: offset
  22978. }).trigger("sticky_kit:unbottom");
  22979. }
  22980. }
  22981. if (scroll < top) {
  22982. fixed = false;
  22983. offset = offset_top;
  22984. if (manual_spacer == null) {
  22985. if (el_float === "left" || el_float === "right") {
  22986. elm.insertAfter(spacer);
  22987. }
  22988. spacer.detach();
  22989. }
  22990. css = {
  22991. position: "",
  22992. width: "",
  22993. top: ""
  22994. };
  22995. elm.css(css).removeClass(sticky_class).trigger("sticky_kit:unstick");
  22996. }
  22997. if (inner_scrolling) {
  22998. win_height = win.height();
  22999. if (height + offset_top > win_height) {
  23000. if (!bottomed) {
  23001. offset -= delta;
  23002. offset = Math.max(win_height - height, offset);
  23003. offset = Math.min(offset_top, offset);
  23004. if (fixed) {
  23005. elm.css({
  23006. top: offset + "px"
  23007. });
  23008. }
  23009. }
  23010. }
  23011. }
  23012. } else {
  23013. if (scroll > top) {
  23014. fixed = true;
  23015. css = {
  23016. position: "fixed",
  23017. top: offset
  23018. };
  23019. css.width = elm.css("box-sizing") === "border-box" ? elm.outerWidth() + "px" : elm.width() + "px";
  23020. elm.css(css).addClass(sticky_class);
  23021. if (manual_spacer == null) {
  23022. elm.after(spacer);
  23023. if (el_float === "left" || el_float === "right") {
  23024. spacer.append(elm);
  23025. }
  23026. }
  23027. elm.trigger("sticky_kit:stick");
  23028. }
  23029. }
  23030. if (fixed && enable_bottoming) {
  23031. if (will_bottom == null) {
  23032. will_bottom = scroll + height + offset > parent_height + parent_top;
  23033. }
  23034. if (!bottomed && will_bottom) {
  23035. bottomed = true;
  23036. if (parent.css("position") === "static") {
  23037. parent.css({
  23038. position: "relative"
  23039. });
  23040. }
  23041. return elm.css({
  23042. position: "absolute",
  23043. bottom: padding_bottom,
  23044. top: "auto"
  23045. }).trigger("sticky_kit:bottom");
  23046. }
  23047. }
  23048. };
  23049. recalc_and_tick = function() {
  23050. recalc();
  23051. return tick();
  23052. };
  23053. detach = function() {
  23054. detached = true;
  23055. win.off("touchmove", tick);
  23056. win.off("scroll", tick);
  23057. win.off("resize", recalc_and_tick);
  23058. $(document.body).off("sticky_kit:recalc", recalc_and_tick);
  23059. elm.off("sticky_kit:detach", detach);
  23060. elm.removeData("sticky_kit");
  23061. elm.css({
  23062. position: "",
  23063. bottom: "",
  23064. top: "",
  23065. width: ""
  23066. });
  23067. parent.position("position", "");
  23068. if (fixed) {
  23069. if (manual_spacer == null) {
  23070. if (el_float === "left" || el_float === "right") {
  23071. elm.insertAfter(spacer);
  23072. }
  23073. spacer.remove();
  23074. }
  23075. return elm.removeClass(sticky_class);
  23076. }
  23077. };
  23078. win.on("touchmove", tick);
  23079. win.on("scroll", tick);
  23080. win.on("resize", recalc_and_tick);
  23081. $(document.body).on("sticky_kit:recalc", recalc_and_tick);
  23082. elm.on("sticky_kit:detach", detach);
  23083. return setTimeout(tick, 0);
  23084. };
  23085. for (i = 0, len = this.length; i < len; i++) {
  23086. elm = this[i];
  23087. fn($(elm));
  23088. }
  23089. return this;
  23090. };
  23091. }).call(this);
  23092. /*!
  23093. Swiper
  23094. Version: 11.2.10
  23095. Plugin URL: https://swiperjs.com
  23096. License: Copyright 2014-2025 Vladimir Kharlampidi | Released under the MIT License
  23097. !*/
  23098. var Swiper = (function () {
  23099. 'use strict';
  23100. /**
  23101. * SSR Window 5.0.1
  23102. * Better handling for window object in SSR environment
  23103. * https://github.com/nolimits4web/ssr-window
  23104. *
  23105. * Copyright 2025, Vladimir Kharlampidi
  23106. *
  23107. * Licensed under MIT
  23108. *
  23109. * Released on: June 27, 2025
  23110. */
  23111. /* eslint-disable no-param-reassign */
  23112. function isObject$1(obj) {
  23113. return obj !== null && typeof obj === 'object' && 'constructor' in obj && obj.constructor === Object;
  23114. }
  23115. function extend$1(target, src) {
  23116. if (target === void 0) {
  23117. target = {};
  23118. }
  23119. if (src === void 0) {
  23120. src = {};
  23121. }
  23122. const noExtend = ['__proto__', 'constructor', 'prototype'];
  23123. Object.keys(src).filter(key => noExtend.indexOf(key) < 0).forEach(key => {
  23124. 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) {
  23125. extend$1(target[key], src[key]);
  23126. }
  23127. });
  23128. }
  23129. const ssrDocument = {
  23130. body: {},
  23131. addEventListener() {},
  23132. removeEventListener() {},
  23133. activeElement: {
  23134. blur() {},
  23135. nodeName: ''
  23136. },
  23137. querySelector() {
  23138. return null;
  23139. },
  23140. querySelectorAll() {
  23141. return [];
  23142. },
  23143. getElementById() {
  23144. return null;
  23145. },
  23146. createEvent() {
  23147. return {
  23148. initEvent() {}
  23149. };
  23150. },
  23151. createElement() {
  23152. return {
  23153. children: [],
  23154. childNodes: [],
  23155. style: {},
  23156. setAttribute() {},
  23157. getElementsByTagName() {
  23158. return [];
  23159. }
  23160. };
  23161. },
  23162. createElementNS() {
  23163. return {};
  23164. },
  23165. importNode() {
  23166. return null;
  23167. },
  23168. location: {
  23169. hash: '',
  23170. host: '',
  23171. hostname: '',
  23172. href: '',
  23173. origin: '',
  23174. pathname: '',
  23175. protocol: '',
  23176. search: ''
  23177. }
  23178. };
  23179. function getDocument() {
  23180. const doc = typeof document !== 'undefined' ? document : {};
  23181. extend$1(doc, ssrDocument);
  23182. return doc;
  23183. }
  23184. const ssrWindow = {
  23185. document: ssrDocument,
  23186. navigator: {
  23187. userAgent: ''
  23188. },
  23189. location: {
  23190. hash: '',
  23191. host: '',
  23192. hostname: '',
  23193. href: '',
  23194. origin: '',
  23195. pathname: '',
  23196. protocol: '',
  23197. search: ''
  23198. },
  23199. history: {
  23200. replaceState() {},
  23201. pushState() {},
  23202. go() {},
  23203. back() {}
  23204. },
  23205. CustomEvent: function CustomEvent() {
  23206. return this;
  23207. },
  23208. addEventListener() {},
  23209. removeEventListener() {},
  23210. getComputedStyle() {
  23211. return {
  23212. getPropertyValue() {
  23213. return '';
  23214. }
  23215. };
  23216. },
  23217. Image() {},
  23218. Date() {},
  23219. screen: {},
  23220. setTimeout() {},
  23221. clearTimeout() {},
  23222. matchMedia() {
  23223. return {};
  23224. },
  23225. requestAnimationFrame(callback) {
  23226. if (typeof setTimeout === 'undefined') {
  23227. callback();
  23228. return null;
  23229. }
  23230. return setTimeout(callback, 0);
  23231. },
  23232. cancelAnimationFrame(id) {
  23233. if (typeof setTimeout === 'undefined') {
  23234. return;
  23235. }
  23236. clearTimeout(id);
  23237. }
  23238. };
  23239. function getWindow() {
  23240. const win = typeof window !== 'undefined' ? window : {};
  23241. extend$1(win, ssrWindow);
  23242. return win;
  23243. }
  23244. function classesToTokens(classes) {
  23245. if (classes === void 0) {
  23246. classes = '';
  23247. }
  23248. return classes.trim().split(' ').filter(c => !!c.trim());
  23249. }
  23250. function deleteProps(obj) {
  23251. const object = obj;
  23252. Object.keys(object).forEach(key => {
  23253. try {
  23254. object[key] = null;
  23255. } catch (e) {
  23256. // no getter for object
  23257. }
  23258. try {
  23259. delete object[key];
  23260. } catch (e) {
  23261. // something got wrong
  23262. }
  23263. });
  23264. }
  23265. function nextTick(callback, delay) {
  23266. if (delay === void 0) {
  23267. delay = 0;
  23268. }
  23269. return setTimeout(callback, delay);
  23270. }
  23271. function now() {
  23272. return Date.now();
  23273. }
  23274. function getComputedStyle$1(el) {
  23275. const window = getWindow();
  23276. let style;
  23277. if (window.getComputedStyle) {
  23278. style = window.getComputedStyle(el, null);
  23279. }
  23280. if (!style && el.currentStyle) {
  23281. style = el.currentStyle;
  23282. }
  23283. if (!style) {
  23284. style = el.style;
  23285. }
  23286. return style;
  23287. }
  23288. function getTranslate(el, axis) {
  23289. if (axis === void 0) {
  23290. axis = 'x';
  23291. }
  23292. const window = getWindow();
  23293. let matrix;
  23294. let curTransform;
  23295. let transformMatrix;
  23296. const curStyle = getComputedStyle$1(el);
  23297. if (window.WebKitCSSMatrix) {
  23298. curTransform = curStyle.transform || curStyle.webkitTransform;
  23299. if (curTransform.split(',').length > 6) {
  23300. curTransform = curTransform.split(', ').map(a => a.replace(',', '.')).join(', ');
  23301. }
  23302. // Some old versions of Webkit choke when 'none' is passed; pass
  23303. // empty string instead in this case
  23304. transformMatrix = new window.WebKitCSSMatrix(curTransform === 'none' ? '' : curTransform);
  23305. } else {
  23306. transformMatrix = curStyle.MozTransform || curStyle.OTransform || curStyle.MsTransform || curStyle.msTransform || curStyle.transform || curStyle.getPropertyValue('transform').replace('translate(', 'matrix(1, 0, 0, 1,');
  23307. matrix = transformMatrix.toString().split(',');
  23308. }
  23309. if (axis === 'x') {
  23310. // Latest Chrome and webkits Fix
  23311. if (window.WebKitCSSMatrix) curTransform = transformMatrix.m41;
  23312. // Crazy IE10 Matrix
  23313. else if (matrix.length === 16) curTransform = parseFloat(matrix[12]);
  23314. // Normal Browsers
  23315. else curTransform = parseFloat(matrix[4]);
  23316. }
  23317. if (axis === 'y') {
  23318. // Latest Chrome and webkits Fix
  23319. if (window.WebKitCSSMatrix) curTransform = transformMatrix.m42;
  23320. // Crazy IE10 Matrix
  23321. else if (matrix.length === 16) curTransform = parseFloat(matrix[13]);
  23322. // Normal Browsers
  23323. else curTransform = parseFloat(matrix[5]);
  23324. }
  23325. return curTransform || 0;
  23326. }
  23327. function isObject(o) {
  23328. return typeof o === 'object' && o !== null && o.constructor && Object.prototype.toString.call(o).slice(8, -1) === 'Object';
  23329. }
  23330. function isNode(node) {
  23331. // eslint-disable-next-line
  23332. if (typeof window !== 'undefined' && typeof window.HTMLElement !== 'undefined') {
  23333. return node instanceof HTMLElement;
  23334. }
  23335. return node && (node.nodeType === 1 || node.nodeType === 11);
  23336. }
  23337. function extend() {
  23338. const to = Object(arguments.length <= 0 ? undefined : arguments[0]);
  23339. const noExtend = ['__proto__', 'constructor', 'prototype'];
  23340. for (let i = 1; i < arguments.length; i += 1) {
  23341. const nextSource = i < 0 || arguments.length <= i ? undefined : arguments[i];
  23342. if (nextSource !== undefined && nextSource !== null && !isNode(nextSource)) {
  23343. const keysArray = Object.keys(Object(nextSource)).filter(key => noExtend.indexOf(key) < 0);
  23344. for (let nextIndex = 0, len = keysArray.length; nextIndex < len; nextIndex += 1) {
  23345. const nextKey = keysArray[nextIndex];
  23346. const desc = Object.getOwnPropertyDescriptor(nextSource, nextKey);
  23347. if (desc !== undefined && desc.enumerable) {
  23348. if (isObject(to[nextKey]) && isObject(nextSource[nextKey])) {
  23349. if (nextSource[nextKey].__swiper__) {
  23350. to[nextKey] = nextSource[nextKey];
  23351. } else {
  23352. extend(to[nextKey], nextSource[nextKey]);
  23353. }
  23354. } else if (!isObject(to[nextKey]) && isObject(nextSource[nextKey])) {
  23355. to[nextKey] = {};
  23356. if (nextSource[nextKey].__swiper__) {
  23357. to[nextKey] = nextSource[nextKey];
  23358. } else {
  23359. extend(to[nextKey], nextSource[nextKey]);
  23360. }
  23361. } else {
  23362. to[nextKey] = nextSource[nextKey];
  23363. }
  23364. }
  23365. }
  23366. }
  23367. }
  23368. return to;
  23369. }
  23370. function setCSSProperty(el, varName, varValue) {
  23371. el.style.setProperty(varName, varValue);
  23372. }
  23373. function animateCSSModeScroll(_ref) {
  23374. let {
  23375. swiper,
  23376. targetPosition,
  23377. side
  23378. } = _ref;
  23379. const window = getWindow();
  23380. const startPosition = -swiper.translate;
  23381. let startTime = null;
  23382. let time;
  23383. const duration = swiper.params.speed;
  23384. swiper.wrapperEl.style.scrollSnapType = 'none';
  23385. window.cancelAnimationFrame(swiper.cssModeFrameID);
  23386. const dir = targetPosition > startPosition ? 'next' : 'prev';
  23387. const isOutOfBound = (current, target) => {
  23388. return dir === 'next' && current >= target || dir === 'prev' && current <= target;
  23389. };
  23390. const animate = () => {
  23391. time = new Date().getTime();
  23392. if (startTime === null) {
  23393. startTime = time;
  23394. }
  23395. const progress = Math.max(Math.min((time - startTime) / duration, 1), 0);
  23396. const easeProgress = 0.5 - Math.cos(progress * Math.PI) / 2;
  23397. let currentPosition = startPosition + easeProgress * (targetPosition - startPosition);
  23398. if (isOutOfBound(currentPosition, targetPosition)) {
  23399. currentPosition = targetPosition;
  23400. }
  23401. swiper.wrapperEl.scrollTo({
  23402. [side]: currentPosition
  23403. });
  23404. if (isOutOfBound(currentPosition, targetPosition)) {
  23405. swiper.wrapperEl.style.overflow = 'hidden';
  23406. swiper.wrapperEl.style.scrollSnapType = '';
  23407. setTimeout(() => {
  23408. swiper.wrapperEl.style.overflow = '';
  23409. swiper.wrapperEl.scrollTo({
  23410. [side]: currentPosition
  23411. });
  23412. });
  23413. window.cancelAnimationFrame(swiper.cssModeFrameID);
  23414. return;
  23415. }
  23416. swiper.cssModeFrameID = window.requestAnimationFrame(animate);
  23417. };
  23418. animate();
  23419. }
  23420. function getSlideTransformEl(slideEl) {
  23421. return slideEl.querySelector('.swiper-slide-transform') || slideEl.shadowRoot && slideEl.shadowRoot.querySelector('.swiper-slide-transform') || slideEl;
  23422. }
  23423. function elementChildren(element, selector) {
  23424. if (selector === void 0) {
  23425. selector = '';
  23426. }
  23427. const window = getWindow();
  23428. const children = [...element.children];
  23429. if (window.HTMLSlotElement && element instanceof HTMLSlotElement) {
  23430. children.push(...element.assignedElements());
  23431. }
  23432. if (!selector) {
  23433. return children;
  23434. }
  23435. return children.filter(el => el.matches(selector));
  23436. }
  23437. function elementIsChildOfSlot(el, slot) {
  23438. // Breadth-first search through all parent's children and assigned elements
  23439. const elementsQueue = [slot];
  23440. while (elementsQueue.length > 0) {
  23441. const elementToCheck = elementsQueue.shift();
  23442. if (el === elementToCheck) {
  23443. return true;
  23444. }
  23445. elementsQueue.push(...elementToCheck.children, ...(elementToCheck.shadowRoot ? elementToCheck.shadowRoot.children : []), ...(elementToCheck.assignedElements ? elementToCheck.assignedElements() : []));
  23446. }
  23447. }
  23448. function elementIsChildOf(el, parent) {
  23449. const window = getWindow();
  23450. let isChild = parent.contains(el);
  23451. if (!isChild && window.HTMLSlotElement && parent instanceof HTMLSlotElement) {
  23452. const children = [...parent.assignedElements()];
  23453. isChild = children.includes(el);
  23454. if (!isChild) {
  23455. isChild = elementIsChildOfSlot(el, parent);
  23456. }
  23457. }
  23458. return isChild;
  23459. }
  23460. function showWarning(text) {
  23461. try {
  23462. console.warn(text);
  23463. return;
  23464. } catch (err) {
  23465. // err
  23466. }
  23467. }
  23468. function createElement(tag, classes) {
  23469. if (classes === void 0) {
  23470. classes = [];
  23471. }
  23472. const el = document.createElement(tag);
  23473. el.classList.add(...(Array.isArray(classes) ? classes : classesToTokens(classes)));
  23474. return el;
  23475. }
  23476. function elementOffset(el) {
  23477. const window = getWindow();
  23478. const document = getDocument();
  23479. const box = el.getBoundingClientRect();
  23480. const body = document.body;
  23481. const clientTop = el.clientTop || body.clientTop || 0;
  23482. const clientLeft = el.clientLeft || body.clientLeft || 0;
  23483. const scrollTop = el === window ? window.scrollY : el.scrollTop;
  23484. const scrollLeft = el === window ? window.scrollX : el.scrollLeft;
  23485. return {
  23486. top: box.top + scrollTop - clientTop,
  23487. left: box.left + scrollLeft - clientLeft
  23488. };
  23489. }
  23490. function elementPrevAll(el, selector) {
  23491. const prevEls = [];
  23492. while (el.previousElementSibling) {
  23493. const prev = el.previousElementSibling; // eslint-disable-line
  23494. if (selector) {
  23495. if (prev.matches(selector)) prevEls.push(prev);
  23496. } else prevEls.push(prev);
  23497. el = prev;
  23498. }
  23499. return prevEls;
  23500. }
  23501. function elementNextAll(el, selector) {
  23502. const nextEls = [];
  23503. while (el.nextElementSibling) {
  23504. const next = el.nextElementSibling; // eslint-disable-line
  23505. if (selector) {
  23506. if (next.matches(selector)) nextEls.push(next);
  23507. } else nextEls.push(next);
  23508. el = next;
  23509. }
  23510. return nextEls;
  23511. }
  23512. function elementStyle(el, prop) {
  23513. const window = getWindow();
  23514. return window.getComputedStyle(el, null).getPropertyValue(prop);
  23515. }
  23516. function elementIndex(el) {
  23517. let child = el;
  23518. let i;
  23519. if (child) {
  23520. i = 0;
  23521. // eslint-disable-next-line
  23522. while ((child = child.previousSibling) !== null) {
  23523. if (child.nodeType === 1) i += 1;
  23524. }
  23525. return i;
  23526. }
  23527. return undefined;
  23528. }
  23529. function elementParents(el, selector) {
  23530. const parents = []; // eslint-disable-line
  23531. let parent = el.parentElement; // eslint-disable-line
  23532. while (parent) {
  23533. if (selector) {
  23534. if (parent.matches(selector)) parents.push(parent);
  23535. } else {
  23536. parents.push(parent);
  23537. }
  23538. parent = parent.parentElement;
  23539. }
  23540. return parents;
  23541. }
  23542. function elementTransitionEnd(el, callback) {
  23543. function fireCallBack(e) {
  23544. if (e.target !== el) return;
  23545. callback.call(el, e);
  23546. el.removeEventListener('transitionend', fireCallBack);
  23547. }
  23548. if (callback) {
  23549. el.addEventListener('transitionend', fireCallBack);
  23550. }
  23551. }
  23552. function elementOuterSize(el, size, includeMargins) {
  23553. const window = getWindow();
  23554. if (includeMargins) {
  23555. 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'));
  23556. }
  23557. return el.offsetWidth;
  23558. }
  23559. function makeElementsArray(el) {
  23560. return (Array.isArray(el) ? el : [el]).filter(e => !!e);
  23561. }
  23562. function getRotateFix(swiper) {
  23563. return v => {
  23564. if (Math.abs(v) > 0 && swiper.browser && swiper.browser.need3dFix && Math.abs(v) % 90 === 0) {
  23565. return v + 0.001;
  23566. }
  23567. return v;
  23568. };
  23569. }
  23570. function setInnerHTML(el, html) {
  23571. if (html === void 0) {
  23572. html = '';
  23573. }
  23574. if (typeof trustedTypes !== 'undefined') {
  23575. el.innerHTML = trustedTypes.createPolicy('html', {
  23576. createHTML: s => s
  23577. }).createHTML(html);
  23578. } else {
  23579. el.innerHTML = html;
  23580. }
  23581. }
  23582. let support;
  23583. function calcSupport() {
  23584. const window = getWindow();
  23585. const document = getDocument();
  23586. return {
  23587. smoothScroll: document.documentElement && document.documentElement.style && 'scrollBehavior' in document.documentElement.style,
  23588. touch: !!('ontouchstart' in window || window.DocumentTouch && document instanceof window.DocumentTouch)
  23589. };
  23590. }
  23591. function getSupport() {
  23592. if (!support) {
  23593. support = calcSupport();
  23594. }
  23595. return support;
  23596. }
  23597. let deviceCached;
  23598. function calcDevice(_temp) {
  23599. let {
  23600. userAgent
  23601. } = _temp === void 0 ? {} : _temp;
  23602. const support = getSupport();
  23603. const window = getWindow();
  23604. const platform = window.navigator.platform;
  23605. const ua = userAgent || window.navigator.userAgent;
  23606. const device = {
  23607. ios: false,
  23608. android: false
  23609. };
  23610. const screenWidth = window.screen.width;
  23611. const screenHeight = window.screen.height;
  23612. const android = ua.match(/(Android);?[\s\/]+([\d.]+)?/); // eslint-disable-line
  23613. let ipad = ua.match(/(iPad).*OS\s([\d_]+)/);
  23614. const ipod = ua.match(/(iPod)(.*OS\s([\d_]+))?/);
  23615. const iphone = !ipad && ua.match(/(iPhone\sOS|iOS)\s([\d_]+)/);
  23616. const windows = platform === 'Win32';
  23617. let macos = platform === 'MacIntel';
  23618. // iPadOs 13 fix
  23619. const iPadScreens = ['1024x1366', '1366x1024', '834x1194', '1194x834', '834x1112', '1112x834', '768x1024', '1024x768', '820x1180', '1180x820', '810x1080', '1080x810'];
  23620. if (!ipad && macos && support.touch && iPadScreens.indexOf(`${screenWidth}x${screenHeight}`) >= 0) {
  23621. ipad = ua.match(/(Version)\/([\d.]+)/);
  23622. if (!ipad) ipad = [0, 1, '13_0_0'];
  23623. macos = false;
  23624. }
  23625. // Android
  23626. if (android && !windows) {
  23627. device.os = 'android';
  23628. device.android = true;
  23629. }
  23630. if (ipad || iphone || ipod) {
  23631. device.os = 'ios';
  23632. device.ios = true;
  23633. }
  23634. // Export object
  23635. return device;
  23636. }
  23637. function getDevice(overrides) {
  23638. if (overrides === void 0) {
  23639. overrides = {};
  23640. }
  23641. if (!deviceCached) {
  23642. deviceCached = calcDevice(overrides);
  23643. }
  23644. return deviceCached;
  23645. }
  23646. let browser;
  23647. function calcBrowser() {
  23648. const window = getWindow();
  23649. const device = getDevice();
  23650. let needPerspectiveFix = false;
  23651. function isSafari() {
  23652. const ua = window.navigator.userAgent.toLowerCase();
  23653. return ua.indexOf('safari') >= 0 && ua.indexOf('chrome') < 0 && ua.indexOf('android') < 0;
  23654. }
  23655. if (isSafari()) {
  23656. const ua = String(window.navigator.userAgent);
  23657. if (ua.includes('Version/')) {
  23658. const [major, minor] = ua.split('Version/')[1].split(' ')[0].split('.').map(num => Number(num));
  23659. needPerspectiveFix = major < 16 || major === 16 && minor < 2;
  23660. }
  23661. }
  23662. const isWebView = /(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/i.test(window.navigator.userAgent);
  23663. const isSafariBrowser = isSafari();
  23664. const need3dFix = isSafariBrowser || isWebView && device.ios;
  23665. return {
  23666. isSafari: needPerspectiveFix || isSafariBrowser,
  23667. needPerspectiveFix,
  23668. need3dFix,
  23669. isWebView
  23670. };
  23671. }
  23672. function getBrowser() {
  23673. if (!browser) {
  23674. browser = calcBrowser();
  23675. }
  23676. return browser;
  23677. }
  23678. function Resize(_ref) {
  23679. let {
  23680. swiper,
  23681. on,
  23682. emit
  23683. } = _ref;
  23684. const window = getWindow();
  23685. let observer = null;
  23686. let animationFrame = null;
  23687. const resizeHandler = () => {
  23688. if (!swiper || swiper.destroyed || !swiper.initialized) return;
  23689. emit('beforeResize');
  23690. emit('resize');
  23691. };
  23692. const createObserver = () => {
  23693. if (!swiper || swiper.destroyed || !swiper.initialized) return;
  23694. observer = new ResizeObserver(entries => {
  23695. animationFrame = window.requestAnimationFrame(() => {
  23696. const {
  23697. width,
  23698. height
  23699. } = swiper;
  23700. let newWidth = width;
  23701. let newHeight = height;
  23702. entries.forEach(_ref2 => {
  23703. let {
  23704. contentBoxSize,
  23705. contentRect,
  23706. target
  23707. } = _ref2;
  23708. if (target && target !== swiper.el) return;
  23709. newWidth = contentRect ? contentRect.width : (contentBoxSize[0] || contentBoxSize).inlineSize;
  23710. newHeight = contentRect ? contentRect.height : (contentBoxSize[0] || contentBoxSize).blockSize;
  23711. });
  23712. if (newWidth !== width || newHeight !== height) {
  23713. resizeHandler();
  23714. }
  23715. });
  23716. });
  23717. observer.observe(swiper.el);
  23718. };
  23719. const removeObserver = () => {
  23720. if (animationFrame) {
  23721. window.cancelAnimationFrame(animationFrame);
  23722. }
  23723. if (observer && observer.unobserve && swiper.el) {
  23724. observer.unobserve(swiper.el);
  23725. observer = null;
  23726. }
  23727. };
  23728. const orientationChangeHandler = () => {
  23729. if (!swiper || swiper.destroyed || !swiper.initialized) return;
  23730. emit('orientationchange');
  23731. };
  23732. on('init', () => {
  23733. if (swiper.params.resizeObserver && typeof window.ResizeObserver !== 'undefined') {
  23734. createObserver();
  23735. return;
  23736. }
  23737. window.addEventListener('resize', resizeHandler);
  23738. window.addEventListener('orientationchange', orientationChangeHandler);
  23739. });
  23740. on('destroy', () => {
  23741. removeObserver();
  23742. window.removeEventListener('resize', resizeHandler);
  23743. window.removeEventListener('orientationchange', orientationChangeHandler);
  23744. });
  23745. }
  23746. function Observer(_ref) {
  23747. let {
  23748. swiper,
  23749. extendParams,
  23750. on,
  23751. emit
  23752. } = _ref;
  23753. const observers = [];
  23754. const window = getWindow();
  23755. const attach = function (target, options) {
  23756. if (options === void 0) {
  23757. options = {};
  23758. }
  23759. const ObserverFunc = window.MutationObserver || window.WebkitMutationObserver;
  23760. const observer = new ObserverFunc(mutations => {
  23761. // The observerUpdate event should only be triggered
  23762. // once despite the number of mutations. Additional
  23763. // triggers are redundant and are very costly
  23764. if (swiper.__preventObserver__) return;
  23765. if (mutations.length === 1) {
  23766. emit('observerUpdate', mutations[0]);
  23767. return;
  23768. }
  23769. const observerUpdate = function observerUpdate() {
  23770. emit('observerUpdate', mutations[0]);
  23771. };
  23772. if (window.requestAnimationFrame) {
  23773. window.requestAnimationFrame(observerUpdate);
  23774. } else {
  23775. window.setTimeout(observerUpdate, 0);
  23776. }
  23777. });
  23778. observer.observe(target, {
  23779. attributes: typeof options.attributes === 'undefined' ? true : options.attributes,
  23780. childList: swiper.isElement || (typeof options.childList === 'undefined' ? true : options).childList,
  23781. characterData: typeof options.characterData === 'undefined' ? true : options.characterData
  23782. });
  23783. observers.push(observer);
  23784. };
  23785. const init = () => {
  23786. if (!swiper.params.observer) return;
  23787. if (swiper.params.observeParents) {
  23788. const containerParents = elementParents(swiper.hostEl);
  23789. for (let i = 0; i < containerParents.length; i += 1) {
  23790. attach(containerParents[i]);
  23791. }
  23792. }
  23793. // Observe container
  23794. attach(swiper.hostEl, {
  23795. childList: swiper.params.observeSlideChildren
  23796. });
  23797. // Observe wrapper
  23798. attach(swiper.wrapperEl, {
  23799. attributes: false
  23800. });
  23801. };
  23802. const destroy = () => {
  23803. observers.forEach(observer => {
  23804. observer.disconnect();
  23805. });
  23806. observers.splice(0, observers.length);
  23807. };
  23808. extendParams({
  23809. observer: false,
  23810. observeParents: false,
  23811. observeSlideChildren: false
  23812. });
  23813. on('init', init);
  23814. on('destroy', destroy);
  23815. }
  23816. /* eslint-disable no-underscore-dangle */
  23817. var eventsEmitter = {
  23818. on(events, handler, priority) {
  23819. const self = this;
  23820. if (!self.eventsListeners || self.destroyed) return self;
  23821. if (typeof handler !== 'function') return self;
  23822. const method = priority ? 'unshift' : 'push';
  23823. events.split(' ').forEach(event => {
  23824. if (!self.eventsListeners[event]) self.eventsListeners[event] = [];
  23825. self.eventsListeners[event][method](handler);
  23826. });
  23827. return self;
  23828. },
  23829. once(events, handler, priority) {
  23830. const self = this;
  23831. if (!self.eventsListeners || self.destroyed) return self;
  23832. if (typeof handler !== 'function') return self;
  23833. function onceHandler() {
  23834. self.off(events, onceHandler);
  23835. if (onceHandler.__emitterProxy) {
  23836. delete onceHandler.__emitterProxy;
  23837. }
  23838. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  23839. args[_key] = arguments[_key];
  23840. }
  23841. handler.apply(self, args);
  23842. }
  23843. onceHandler.__emitterProxy = handler;
  23844. return self.on(events, onceHandler, priority);
  23845. },
  23846. onAny(handler, priority) {
  23847. const self = this;
  23848. if (!self.eventsListeners || self.destroyed) return self;
  23849. if (typeof handler !== 'function') return self;
  23850. const method = priority ? 'unshift' : 'push';
  23851. if (self.eventsAnyListeners.indexOf(handler) < 0) {
  23852. self.eventsAnyListeners[method](handler);
  23853. }
  23854. return self;
  23855. },
  23856. offAny(handler) {
  23857. const self = this;
  23858. if (!self.eventsListeners || self.destroyed) return self;
  23859. if (!self.eventsAnyListeners) return self;
  23860. const index = self.eventsAnyListeners.indexOf(handler);
  23861. if (index >= 0) {
  23862. self.eventsAnyListeners.splice(index, 1);
  23863. }
  23864. return self;
  23865. },
  23866. off(events, handler) {
  23867. const self = this;
  23868. if (!self.eventsListeners || self.destroyed) return self;
  23869. if (!self.eventsListeners) return self;
  23870. events.split(' ').forEach(event => {
  23871. if (typeof handler === 'undefined') {
  23872. self.eventsListeners[event] = [];
  23873. } else if (self.eventsListeners[event]) {
  23874. self.eventsListeners[event].forEach((eventHandler, index) => {
  23875. if (eventHandler === handler || eventHandler.__emitterProxy && eventHandler.__emitterProxy === handler) {
  23876. self.eventsListeners[event].splice(index, 1);
  23877. }
  23878. });
  23879. }
  23880. });
  23881. return self;
  23882. },
  23883. emit() {
  23884. const self = this;
  23885. if (!self.eventsListeners || self.destroyed) return self;
  23886. if (!self.eventsListeners) return self;
  23887. let events;
  23888. let data;
  23889. let context;
  23890. for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
  23891. args[_key2] = arguments[_key2];
  23892. }
  23893. if (typeof args[0] === 'string' || Array.isArray(args[0])) {
  23894. events = args[0];
  23895. data = args.slice(1, args.length);
  23896. context = self;
  23897. } else {
  23898. events = args[0].events;
  23899. data = args[0].data;
  23900. context = args[0].context || self;
  23901. }
  23902. data.unshift(context);
  23903. const eventsArray = Array.isArray(events) ? events : events.split(' ');
  23904. eventsArray.forEach(event => {
  23905. if (self.eventsAnyListeners && self.eventsAnyListeners.length) {
  23906. self.eventsAnyListeners.forEach(eventHandler => {
  23907. eventHandler.apply(context, [event, ...data]);
  23908. });
  23909. }
  23910. if (self.eventsListeners && self.eventsListeners[event]) {
  23911. self.eventsListeners[event].forEach(eventHandler => {
  23912. eventHandler.apply(context, data);
  23913. });
  23914. }
  23915. });
  23916. return self;
  23917. }
  23918. };
  23919. function updateSize() {
  23920. const swiper = this;
  23921. let width;
  23922. let height;
  23923. const el = swiper.el;
  23924. if (typeof swiper.params.width !== 'undefined' && swiper.params.width !== null) {
  23925. width = swiper.params.width;
  23926. } else {
  23927. width = el.clientWidth;
  23928. }
  23929. if (typeof swiper.params.height !== 'undefined' && swiper.params.height !== null) {
  23930. height = swiper.params.height;
  23931. } else {
  23932. height = el.clientHeight;
  23933. }
  23934. if (width === 0 && swiper.isHorizontal() || height === 0 && swiper.isVertical()) {
  23935. return;
  23936. }
  23937. // Subtract paddings
  23938. width = width - parseInt(elementStyle(el, 'padding-left') || 0, 10) - parseInt(elementStyle(el, 'padding-right') || 0, 10);
  23939. height = height - parseInt(elementStyle(el, 'padding-top') || 0, 10) - parseInt(elementStyle(el, 'padding-bottom') || 0, 10);
  23940. if (Number.isNaN(width)) width = 0;
  23941. if (Number.isNaN(height)) height = 0;
  23942. Object.assign(swiper, {
  23943. width,
  23944. height,
  23945. size: swiper.isHorizontal() ? width : height
  23946. });
  23947. }
  23948. function updateSlides() {
  23949. const swiper = this;
  23950. function getDirectionPropertyValue(node, label) {
  23951. return parseFloat(node.getPropertyValue(swiper.getDirectionLabel(label)) || 0);
  23952. }
  23953. const params = swiper.params;
  23954. const {
  23955. wrapperEl,
  23956. slidesEl,
  23957. size: swiperSize,
  23958. rtlTranslate: rtl,
  23959. wrongRTL
  23960. } = swiper;
  23961. const isVirtual = swiper.virtual && params.virtual.enabled;
  23962. const previousSlidesLength = isVirtual ? swiper.virtual.slides.length : swiper.slides.length;
  23963. const slides = elementChildren(slidesEl, `.${swiper.params.slideClass}, swiper-slide`);
  23964. const slidesLength = isVirtual ? swiper.virtual.slides.length : slides.length;
  23965. let snapGrid = [];
  23966. const slidesGrid = [];
  23967. const slidesSizesGrid = [];
  23968. let offsetBefore = params.slidesOffsetBefore;
  23969. if (typeof offsetBefore === 'function') {
  23970. offsetBefore = params.slidesOffsetBefore.call(swiper);
  23971. }
  23972. let offsetAfter = params.slidesOffsetAfter;
  23973. if (typeof offsetAfter === 'function') {
  23974. offsetAfter = params.slidesOffsetAfter.call(swiper);
  23975. }
  23976. const previousSnapGridLength = swiper.snapGrid.length;
  23977. const previousSlidesGridLength = swiper.slidesGrid.length;
  23978. let spaceBetween = params.spaceBetween;
  23979. let slidePosition = -offsetBefore;
  23980. let prevSlideSize = 0;
  23981. let index = 0;
  23982. if (typeof swiperSize === 'undefined') {
  23983. return;
  23984. }
  23985. if (typeof spaceBetween === 'string' && spaceBetween.indexOf('%') >= 0) {
  23986. spaceBetween = parseFloat(spaceBetween.replace('%', '')) / 100 * swiperSize;
  23987. } else if (typeof spaceBetween === 'string') {
  23988. spaceBetween = parseFloat(spaceBetween);
  23989. }
  23990. swiper.virtualSize = -spaceBetween;
  23991. // reset margins
  23992. slides.forEach(slideEl => {
  23993. if (rtl) {
  23994. slideEl.style.marginLeft = '';
  23995. } else {
  23996. slideEl.style.marginRight = '';
  23997. }
  23998. slideEl.style.marginBottom = '';
  23999. slideEl.style.marginTop = '';
  24000. });
  24001. // reset cssMode offsets
  24002. if (params.centeredSlides && params.cssMode) {
  24003. setCSSProperty(wrapperEl, '--swiper-centered-offset-before', '');
  24004. setCSSProperty(wrapperEl, '--swiper-centered-offset-after', '');
  24005. }
  24006. const gridEnabled = params.grid && params.grid.rows > 1 && swiper.grid;
  24007. if (gridEnabled) {
  24008. swiper.grid.initSlides(slides);
  24009. } else if (swiper.grid) {
  24010. swiper.grid.unsetSlides();
  24011. }
  24012. // Calc slides
  24013. let slideSize;
  24014. const shouldResetSlideSize = params.slidesPerView === 'auto' && params.breakpoints && Object.keys(params.breakpoints).filter(key => {
  24015. return typeof params.breakpoints[key].slidesPerView !== 'undefined';
  24016. }).length > 0;
  24017. for (let i = 0; i < slidesLength; i += 1) {
  24018. slideSize = 0;
  24019. let slide;
  24020. if (slides[i]) slide = slides[i];
  24021. if (gridEnabled) {
  24022. swiper.grid.updateSlide(i, slide, slides);
  24023. }
  24024. if (slides[i] && elementStyle(slide, 'display') === 'none') continue; // eslint-disable-line
  24025. if (params.slidesPerView === 'auto') {
  24026. if (shouldResetSlideSize) {
  24027. slides[i].style[swiper.getDirectionLabel('width')] = ``;
  24028. }
  24029. const slideStyles = getComputedStyle(slide);
  24030. const currentTransform = slide.style.transform;
  24031. const currentWebKitTransform = slide.style.webkitTransform;
  24032. if (currentTransform) {
  24033. slide.style.transform = 'none';
  24034. }
  24035. if (currentWebKitTransform) {
  24036. slide.style.webkitTransform = 'none';
  24037. }
  24038. if (params.roundLengths) {
  24039. slideSize = swiper.isHorizontal() ? elementOuterSize(slide, 'width', true) : elementOuterSize(slide, 'height', true);
  24040. } else {
  24041. // eslint-disable-next-line
  24042. const width = getDirectionPropertyValue(slideStyles, 'width');
  24043. const paddingLeft = getDirectionPropertyValue(slideStyles, 'padding-left');
  24044. const paddingRight = getDirectionPropertyValue(slideStyles, 'padding-right');
  24045. const marginLeft = getDirectionPropertyValue(slideStyles, 'margin-left');
  24046. const marginRight = getDirectionPropertyValue(slideStyles, 'margin-right');
  24047. const boxSizing = slideStyles.getPropertyValue('box-sizing');
  24048. if (boxSizing && boxSizing === 'border-box') {
  24049. slideSize = width + marginLeft + marginRight;
  24050. } else {
  24051. const {
  24052. clientWidth,
  24053. offsetWidth
  24054. } = slide;
  24055. slideSize = width + paddingLeft + paddingRight + marginLeft + marginRight + (offsetWidth - clientWidth);
  24056. }
  24057. }
  24058. if (currentTransform) {
  24059. slide.style.transform = currentTransform;
  24060. }
  24061. if (currentWebKitTransform) {
  24062. slide.style.webkitTransform = currentWebKitTransform;
  24063. }
  24064. if (params.roundLengths) slideSize = Math.floor(slideSize);
  24065. } else {
  24066. slideSize = (swiperSize - (params.slidesPerView - 1) * spaceBetween) / params.slidesPerView;
  24067. if (params.roundLengths) slideSize = Math.floor(slideSize);
  24068. if (slides[i]) {
  24069. slides[i].style[swiper.getDirectionLabel('width')] = `${slideSize}px`;
  24070. }
  24071. }
  24072. if (slides[i]) {
  24073. slides[i].swiperSlideSize = slideSize;
  24074. }
  24075. slidesSizesGrid.push(slideSize);
  24076. if (params.centeredSlides) {
  24077. slidePosition = slidePosition + slideSize / 2 + prevSlideSize / 2 + spaceBetween;
  24078. if (prevSlideSize === 0 && i !== 0) slidePosition = slidePosition - swiperSize / 2 - spaceBetween;
  24079. if (i === 0) slidePosition = slidePosition - swiperSize / 2 - spaceBetween;
  24080. if (Math.abs(slidePosition) < 1 / 1000) slidePosition = 0;
  24081. if (params.roundLengths) slidePosition = Math.floor(slidePosition);
  24082. if (index % params.slidesPerGroup === 0) snapGrid.push(slidePosition);
  24083. slidesGrid.push(slidePosition);
  24084. } else {
  24085. if (params.roundLengths) slidePosition = Math.floor(slidePosition);
  24086. if ((index - Math.min(swiper.params.slidesPerGroupSkip, index)) % swiper.params.slidesPerGroup === 0) snapGrid.push(slidePosition);
  24087. slidesGrid.push(slidePosition);
  24088. slidePosition = slidePosition + slideSize + spaceBetween;
  24089. }
  24090. swiper.virtualSize += slideSize + spaceBetween;
  24091. prevSlideSize = slideSize;
  24092. index += 1;
  24093. }
  24094. swiper.virtualSize = Math.max(swiper.virtualSize, swiperSize) + offsetAfter;
  24095. if (rtl && wrongRTL && (params.effect === 'slide' || params.effect === 'coverflow')) {
  24096. wrapperEl.style.width = `${swiper.virtualSize + spaceBetween}px`;
  24097. }
  24098. if (params.setWrapperSize) {
  24099. wrapperEl.style[swiper.getDirectionLabel('width')] = `${swiper.virtualSize + spaceBetween}px`;
  24100. }
  24101. if (gridEnabled) {
  24102. swiper.grid.updateWrapperSize(slideSize, snapGrid);
  24103. }
  24104. // Remove last grid elements depending on width
  24105. if (!params.centeredSlides) {
  24106. const newSlidesGrid = [];
  24107. for (let i = 0; i < snapGrid.length; i += 1) {
  24108. let slidesGridItem = snapGrid[i];
  24109. if (params.roundLengths) slidesGridItem = Math.floor(slidesGridItem);
  24110. if (snapGrid[i] <= swiper.virtualSize - swiperSize) {
  24111. newSlidesGrid.push(slidesGridItem);
  24112. }
  24113. }
  24114. snapGrid = newSlidesGrid;
  24115. if (Math.floor(swiper.virtualSize - swiperSize) - Math.floor(snapGrid[snapGrid.length - 1]) > 1) {
  24116. snapGrid.push(swiper.virtualSize - swiperSize);
  24117. }
  24118. }
  24119. if (isVirtual && params.loop) {
  24120. const size = slidesSizesGrid[0] + spaceBetween;
  24121. if (params.slidesPerGroup > 1) {
  24122. const groups = Math.ceil((swiper.virtual.slidesBefore + swiper.virtual.slidesAfter) / params.slidesPerGroup);
  24123. const groupSize = size * params.slidesPerGroup;
  24124. for (let i = 0; i < groups; i += 1) {
  24125. snapGrid.push(snapGrid[snapGrid.length - 1] + groupSize);
  24126. }
  24127. }
  24128. for (let i = 0; i < swiper.virtual.slidesBefore + swiper.virtual.slidesAfter; i += 1) {
  24129. if (params.slidesPerGroup === 1) {
  24130. snapGrid.push(snapGrid[snapGrid.length - 1] + size);
  24131. }
  24132. slidesGrid.push(slidesGrid[slidesGrid.length - 1] + size);
  24133. swiper.virtualSize += size;
  24134. }
  24135. }
  24136. if (snapGrid.length === 0) snapGrid = [0];
  24137. if (spaceBetween !== 0) {
  24138. const key = swiper.isHorizontal() && rtl ? 'marginLeft' : swiper.getDirectionLabel('marginRight');
  24139. slides.filter((_, slideIndex) => {
  24140. if (!params.cssMode || params.loop) return true;
  24141. if (slideIndex === slides.length - 1) {
  24142. return false;
  24143. }
  24144. return true;
  24145. }).forEach(slideEl => {
  24146. slideEl.style[key] = `${spaceBetween}px`;
  24147. });
  24148. }
  24149. if (params.centeredSlides && params.centeredSlidesBounds) {
  24150. let allSlidesSize = 0;
  24151. slidesSizesGrid.forEach(slideSizeValue => {
  24152. allSlidesSize += slideSizeValue + (spaceBetween || 0);
  24153. });
  24154. allSlidesSize -= spaceBetween;
  24155. const maxSnap = allSlidesSize > swiperSize ? allSlidesSize - swiperSize : 0;
  24156. snapGrid = snapGrid.map(snap => {
  24157. if (snap <= 0) return -offsetBefore;
  24158. if (snap > maxSnap) return maxSnap + offsetAfter;
  24159. return snap;
  24160. });
  24161. }
  24162. if (params.centerInsufficientSlides) {
  24163. let allSlidesSize = 0;
  24164. slidesSizesGrid.forEach(slideSizeValue => {
  24165. allSlidesSize += slideSizeValue + (spaceBetween || 0);
  24166. });
  24167. allSlidesSize -= spaceBetween;
  24168. const offsetSize = (params.slidesOffsetBefore || 0) + (params.slidesOffsetAfter || 0);
  24169. if (allSlidesSize + offsetSize < swiperSize) {
  24170. const allSlidesOffset = (swiperSize - allSlidesSize - offsetSize) / 2;
  24171. snapGrid.forEach((snap, snapIndex) => {
  24172. snapGrid[snapIndex] = snap - allSlidesOffset;
  24173. });
  24174. slidesGrid.forEach((snap, snapIndex) => {
  24175. slidesGrid[snapIndex] = snap + allSlidesOffset;
  24176. });
  24177. }
  24178. }
  24179. Object.assign(swiper, {
  24180. slides,
  24181. snapGrid,
  24182. slidesGrid,
  24183. slidesSizesGrid
  24184. });
  24185. if (params.centeredSlides && params.cssMode && !params.centeredSlidesBounds) {
  24186. setCSSProperty(wrapperEl, '--swiper-centered-offset-before', `${-snapGrid[0]}px`);
  24187. setCSSProperty(wrapperEl, '--swiper-centered-offset-after', `${swiper.size / 2 - slidesSizesGrid[slidesSizesGrid.length - 1] / 2}px`);
  24188. const addToSnapGrid = -swiper.snapGrid[0];
  24189. const addToSlidesGrid = -swiper.slidesGrid[0];
  24190. swiper.snapGrid = swiper.snapGrid.map(v => v + addToSnapGrid);
  24191. swiper.slidesGrid = swiper.slidesGrid.map(v => v + addToSlidesGrid);
  24192. }
  24193. if (slidesLength !== previousSlidesLength) {
  24194. swiper.emit('slidesLengthChange');
  24195. }
  24196. if (snapGrid.length !== previousSnapGridLength) {
  24197. if (swiper.params.watchOverflow) swiper.checkOverflow();
  24198. swiper.emit('snapGridLengthChange');
  24199. }
  24200. if (slidesGrid.length !== previousSlidesGridLength) {
  24201. swiper.emit('slidesGridLengthChange');
  24202. }
  24203. if (params.watchSlidesProgress) {
  24204. swiper.updateSlidesOffset();
  24205. }
  24206. swiper.emit('slidesUpdated');
  24207. if (!isVirtual && !params.cssMode && (params.effect === 'slide' || params.effect === 'fade')) {
  24208. const backFaceHiddenClass = `${params.containerModifierClass}backface-hidden`;
  24209. const hasClassBackfaceClassAdded = swiper.el.classList.contains(backFaceHiddenClass);
  24210. if (slidesLength <= params.maxBackfaceHiddenSlides) {
  24211. if (!hasClassBackfaceClassAdded) swiper.el.classList.add(backFaceHiddenClass);
  24212. } else if (hasClassBackfaceClassAdded) {
  24213. swiper.el.classList.remove(backFaceHiddenClass);
  24214. }
  24215. }
  24216. }
  24217. function updateAutoHeight(speed) {
  24218. const swiper = this;
  24219. const activeSlides = [];
  24220. const isVirtual = swiper.virtual && swiper.params.virtual.enabled;
  24221. let newHeight = 0;
  24222. let i;
  24223. if (typeof speed === 'number') {
  24224. swiper.setTransition(speed);
  24225. } else if (speed === true) {
  24226. swiper.setTransition(swiper.params.speed);
  24227. }
  24228. const getSlideByIndex = index => {
  24229. if (isVirtual) {
  24230. return swiper.slides[swiper.getSlideIndexByData(index)];
  24231. }
  24232. return swiper.slides[index];
  24233. };
  24234. // Find slides currently in view
  24235. if (swiper.params.slidesPerView !== 'auto' && swiper.params.slidesPerView > 1) {
  24236. if (swiper.params.centeredSlides) {
  24237. (swiper.visibleSlides || []).forEach(slide => {
  24238. activeSlides.push(slide);
  24239. });
  24240. } else {
  24241. for (i = 0; i < Math.ceil(swiper.params.slidesPerView); i += 1) {
  24242. const index = swiper.activeIndex + i;
  24243. if (index > swiper.slides.length && !isVirtual) break;
  24244. activeSlides.push(getSlideByIndex(index));
  24245. }
  24246. }
  24247. } else {
  24248. activeSlides.push(getSlideByIndex(swiper.activeIndex));
  24249. }
  24250. // Find new height from highest slide in view
  24251. for (i = 0; i < activeSlides.length; i += 1) {
  24252. if (typeof activeSlides[i] !== 'undefined') {
  24253. const height = activeSlides[i].offsetHeight;
  24254. newHeight = height > newHeight ? height : newHeight;
  24255. }
  24256. }
  24257. // Update Height
  24258. if (newHeight || newHeight === 0) swiper.wrapperEl.style.height = `${newHeight}px`;
  24259. }
  24260. function updateSlidesOffset() {
  24261. const swiper = this;
  24262. const slides = swiper.slides;
  24263. // eslint-disable-next-line
  24264. const minusOffset = swiper.isElement ? swiper.isHorizontal() ? swiper.wrapperEl.offsetLeft : swiper.wrapperEl.offsetTop : 0;
  24265. for (let i = 0; i < slides.length; i += 1) {
  24266. slides[i].swiperSlideOffset = (swiper.isHorizontal() ? slides[i].offsetLeft : slides[i].offsetTop) - minusOffset - swiper.cssOverflowAdjustment();
  24267. }
  24268. }
  24269. const toggleSlideClasses$1 = (slideEl, condition, className) => {
  24270. if (condition && !slideEl.classList.contains(className)) {
  24271. slideEl.classList.add(className);
  24272. } else if (!condition && slideEl.classList.contains(className)) {
  24273. slideEl.classList.remove(className);
  24274. }
  24275. };
  24276. function updateSlidesProgress(translate) {
  24277. if (translate === void 0) {
  24278. translate = this && this.translate || 0;
  24279. }
  24280. const swiper = this;
  24281. const params = swiper.params;
  24282. const {
  24283. slides,
  24284. rtlTranslate: rtl,
  24285. snapGrid
  24286. } = swiper;
  24287. if (slides.length === 0) return;
  24288. if (typeof slides[0].swiperSlideOffset === 'undefined') swiper.updateSlidesOffset();
  24289. let offsetCenter = -translate;
  24290. if (rtl) offsetCenter = translate;
  24291. swiper.visibleSlidesIndexes = [];
  24292. swiper.visibleSlides = [];
  24293. let spaceBetween = params.spaceBetween;
  24294. if (typeof spaceBetween === 'string' && spaceBetween.indexOf('%') >= 0) {
  24295. spaceBetween = parseFloat(spaceBetween.replace('%', '')) / 100 * swiper.size;
  24296. } else if (typeof spaceBetween === 'string') {
  24297. spaceBetween = parseFloat(spaceBetween);
  24298. }
  24299. for (let i = 0; i < slides.length; i += 1) {
  24300. const slide = slides[i];
  24301. let slideOffset = slide.swiperSlideOffset;
  24302. if (params.cssMode && params.centeredSlides) {
  24303. slideOffset -= slides[0].swiperSlideOffset;
  24304. }
  24305. const slideProgress = (offsetCenter + (params.centeredSlides ? swiper.minTranslate() : 0) - slideOffset) / (slide.swiperSlideSize + spaceBetween);
  24306. const originalSlideProgress = (offsetCenter - snapGrid[0] + (params.centeredSlides ? swiper.minTranslate() : 0) - slideOffset) / (slide.swiperSlideSize + spaceBetween);
  24307. const slideBefore = -(offsetCenter - slideOffset);
  24308. const slideAfter = slideBefore + swiper.slidesSizesGrid[i];
  24309. const isFullyVisible = slideBefore >= 0 && slideBefore <= swiper.size - swiper.slidesSizesGrid[i];
  24310. const isVisible = slideBefore >= 0 && slideBefore < swiper.size - 1 || slideAfter > 1 && slideAfter <= swiper.size || slideBefore <= 0 && slideAfter >= swiper.size;
  24311. if (isVisible) {
  24312. swiper.visibleSlides.push(slide);
  24313. swiper.visibleSlidesIndexes.push(i);
  24314. }
  24315. toggleSlideClasses$1(slide, isVisible, params.slideVisibleClass);
  24316. toggleSlideClasses$1(slide, isFullyVisible, params.slideFullyVisibleClass);
  24317. slide.progress = rtl ? -slideProgress : slideProgress;
  24318. slide.originalProgress = rtl ? -originalSlideProgress : originalSlideProgress;
  24319. }
  24320. }
  24321. function updateProgress(translate) {
  24322. const swiper = this;
  24323. if (typeof translate === 'undefined') {
  24324. const multiplier = swiper.rtlTranslate ? -1 : 1;
  24325. // eslint-disable-next-line
  24326. translate = swiper && swiper.translate && swiper.translate * multiplier || 0;
  24327. }
  24328. const params = swiper.params;
  24329. const translatesDiff = swiper.maxTranslate() - swiper.minTranslate();
  24330. let {
  24331. progress,
  24332. isBeginning,
  24333. isEnd,
  24334. progressLoop
  24335. } = swiper;
  24336. const wasBeginning = isBeginning;
  24337. const wasEnd = isEnd;
  24338. if (translatesDiff === 0) {
  24339. progress = 0;
  24340. isBeginning = true;
  24341. isEnd = true;
  24342. } else {
  24343. progress = (translate - swiper.minTranslate()) / translatesDiff;
  24344. const isBeginningRounded = Math.abs(translate - swiper.minTranslate()) < 1;
  24345. const isEndRounded = Math.abs(translate - swiper.maxTranslate()) < 1;
  24346. isBeginning = isBeginningRounded || progress <= 0;
  24347. isEnd = isEndRounded || progress >= 1;
  24348. if (isBeginningRounded) progress = 0;
  24349. if (isEndRounded) progress = 1;
  24350. }
  24351. if (params.loop) {
  24352. const firstSlideIndex = swiper.getSlideIndexByData(0);
  24353. const lastSlideIndex = swiper.getSlideIndexByData(swiper.slides.length - 1);
  24354. const firstSlideTranslate = swiper.slidesGrid[firstSlideIndex];
  24355. const lastSlideTranslate = swiper.slidesGrid[lastSlideIndex];
  24356. const translateMax = swiper.slidesGrid[swiper.slidesGrid.length - 1];
  24357. const translateAbs = Math.abs(translate);
  24358. if (translateAbs >= firstSlideTranslate) {
  24359. progressLoop = (translateAbs - firstSlideTranslate) / translateMax;
  24360. } else {
  24361. progressLoop = (translateAbs + translateMax - lastSlideTranslate) / translateMax;
  24362. }
  24363. if (progressLoop > 1) progressLoop -= 1;
  24364. }
  24365. Object.assign(swiper, {
  24366. progress,
  24367. progressLoop,
  24368. isBeginning,
  24369. isEnd
  24370. });
  24371. if (params.watchSlidesProgress || params.centeredSlides && params.autoHeight) swiper.updateSlidesProgress(translate);
  24372. if (isBeginning && !wasBeginning) {
  24373. swiper.emit('reachBeginning toEdge');
  24374. }
  24375. if (isEnd && !wasEnd) {
  24376. swiper.emit('reachEnd toEdge');
  24377. }
  24378. if (wasBeginning && !isBeginning || wasEnd && !isEnd) {
  24379. swiper.emit('fromEdge');
  24380. }
  24381. swiper.emit('progress', progress);
  24382. }
  24383. const toggleSlideClasses = (slideEl, condition, className) => {
  24384. if (condition && !slideEl.classList.contains(className)) {
  24385. slideEl.classList.add(className);
  24386. } else if (!condition && slideEl.classList.contains(className)) {
  24387. slideEl.classList.remove(className);
  24388. }
  24389. };
  24390. function updateSlidesClasses() {
  24391. const swiper = this;
  24392. const {
  24393. slides,
  24394. params,
  24395. slidesEl,
  24396. activeIndex
  24397. } = swiper;
  24398. const isVirtual = swiper.virtual && params.virtual.enabled;
  24399. const gridEnabled = swiper.grid && params.grid && params.grid.rows > 1;
  24400. const getFilteredSlide = selector => {
  24401. return elementChildren(slidesEl, `.${params.slideClass}${selector}, swiper-slide${selector}`)[0];
  24402. };
  24403. let activeSlide;
  24404. let prevSlide;
  24405. let nextSlide;
  24406. if (isVirtual) {
  24407. if (params.loop) {
  24408. let slideIndex = activeIndex - swiper.virtual.slidesBefore;
  24409. if (slideIndex < 0) slideIndex = swiper.virtual.slides.length + slideIndex;
  24410. if (slideIndex >= swiper.virtual.slides.length) slideIndex -= swiper.virtual.slides.length;
  24411. activeSlide = getFilteredSlide(`[data-swiper-slide-index="${slideIndex}"]`);
  24412. } else {
  24413. activeSlide = getFilteredSlide(`[data-swiper-slide-index="${activeIndex}"]`);
  24414. }
  24415. } else {
  24416. if (gridEnabled) {
  24417. activeSlide = slides.find(slideEl => slideEl.column === activeIndex);
  24418. nextSlide = slides.find(slideEl => slideEl.column === activeIndex + 1);
  24419. prevSlide = slides.find(slideEl => slideEl.column === activeIndex - 1);
  24420. } else {
  24421. activeSlide = slides[activeIndex];
  24422. }
  24423. }
  24424. if (activeSlide) {
  24425. if (!gridEnabled) {
  24426. // Next Slide
  24427. nextSlide = elementNextAll(activeSlide, `.${params.slideClass}, swiper-slide`)[0];
  24428. if (params.loop && !nextSlide) {
  24429. nextSlide = slides[0];
  24430. }
  24431. // Prev Slide
  24432. prevSlide = elementPrevAll(activeSlide, `.${params.slideClass}, swiper-slide`)[0];
  24433. if (params.loop && !prevSlide === 0) {
  24434. prevSlide = slides[slides.length - 1];
  24435. }
  24436. }
  24437. }
  24438. slides.forEach(slideEl => {
  24439. toggleSlideClasses(slideEl, slideEl === activeSlide, params.slideActiveClass);
  24440. toggleSlideClasses(slideEl, slideEl === nextSlide, params.slideNextClass);
  24441. toggleSlideClasses(slideEl, slideEl === prevSlide, params.slidePrevClass);
  24442. });
  24443. swiper.emitSlidesClasses();
  24444. }
  24445. const processLazyPreloader = (swiper, imageEl) => {
  24446. if (!swiper || swiper.destroyed || !swiper.params) return;
  24447. const slideSelector = () => swiper.isElement ? `swiper-slide` : `.${swiper.params.slideClass}`;
  24448. const slideEl = imageEl.closest(slideSelector());
  24449. if (slideEl) {
  24450. let lazyEl = slideEl.querySelector(`.${swiper.params.lazyPreloaderClass}`);
  24451. if (!lazyEl && swiper.isElement) {
  24452. if (slideEl.shadowRoot) {
  24453. lazyEl = slideEl.shadowRoot.querySelector(`.${swiper.params.lazyPreloaderClass}`);
  24454. } else {
  24455. // init later
  24456. requestAnimationFrame(() => {
  24457. if (slideEl.shadowRoot) {
  24458. lazyEl = slideEl.shadowRoot.querySelector(`.${swiper.params.lazyPreloaderClass}`);
  24459. if (lazyEl) lazyEl.remove();
  24460. }
  24461. });
  24462. }
  24463. }
  24464. if (lazyEl) lazyEl.remove();
  24465. }
  24466. };
  24467. const unlazy = (swiper, index) => {
  24468. if (!swiper.slides[index]) return;
  24469. const imageEl = swiper.slides[index].querySelector('[loading="lazy"]');
  24470. if (imageEl) imageEl.removeAttribute('loading');
  24471. };
  24472. const preload = swiper => {
  24473. if (!swiper || swiper.destroyed || !swiper.params) return;
  24474. let amount = swiper.params.lazyPreloadPrevNext;
  24475. const len = swiper.slides.length;
  24476. if (!len || !amount || amount < 0) return;
  24477. amount = Math.min(amount, len);
  24478. const slidesPerView = swiper.params.slidesPerView === 'auto' ? swiper.slidesPerViewDynamic() : Math.ceil(swiper.params.slidesPerView);
  24479. const activeIndex = swiper.activeIndex;
  24480. if (swiper.params.grid && swiper.params.grid.rows > 1) {
  24481. const activeColumn = activeIndex;
  24482. const preloadColumns = [activeColumn - amount];
  24483. preloadColumns.push(...Array.from({
  24484. length: amount
  24485. }).map((_, i) => {
  24486. return activeColumn + slidesPerView + i;
  24487. }));
  24488. swiper.slides.forEach((slideEl, i) => {
  24489. if (preloadColumns.includes(slideEl.column)) unlazy(swiper, i);
  24490. });
  24491. return;
  24492. }
  24493. const slideIndexLastInView = activeIndex + slidesPerView - 1;
  24494. if (swiper.params.rewind || swiper.params.loop) {
  24495. for (let i = activeIndex - amount; i <= slideIndexLastInView + amount; i += 1) {
  24496. const realIndex = (i % len + len) % len;
  24497. if (realIndex < activeIndex || realIndex > slideIndexLastInView) unlazy(swiper, realIndex);
  24498. }
  24499. } else {
  24500. for (let i = Math.max(activeIndex - amount, 0); i <= Math.min(slideIndexLastInView + amount, len - 1); i += 1) {
  24501. if (i !== activeIndex && (i > slideIndexLastInView || i < activeIndex)) {
  24502. unlazy(swiper, i);
  24503. }
  24504. }
  24505. }
  24506. };
  24507. function getActiveIndexByTranslate(swiper) {
  24508. const {
  24509. slidesGrid,
  24510. params
  24511. } = swiper;
  24512. const translate = swiper.rtlTranslate ? swiper.translate : -swiper.translate;
  24513. let activeIndex;
  24514. for (let i = 0; i < slidesGrid.length; i += 1) {
  24515. if (typeof slidesGrid[i + 1] !== 'undefined') {
  24516. if (translate >= slidesGrid[i] && translate < slidesGrid[i + 1] - (slidesGrid[i + 1] - slidesGrid[i]) / 2) {
  24517. activeIndex = i;
  24518. } else if (translate >= slidesGrid[i] && translate < slidesGrid[i + 1]) {
  24519. activeIndex = i + 1;
  24520. }
  24521. } else if (translate >= slidesGrid[i]) {
  24522. activeIndex = i;
  24523. }
  24524. }
  24525. // Normalize slideIndex
  24526. if (params.normalizeSlideIndex) {
  24527. if (activeIndex < 0 || typeof activeIndex === 'undefined') activeIndex = 0;
  24528. }
  24529. return activeIndex;
  24530. }
  24531. function updateActiveIndex(newActiveIndex) {
  24532. const swiper = this;
  24533. const translate = swiper.rtlTranslate ? swiper.translate : -swiper.translate;
  24534. const {
  24535. snapGrid,
  24536. params,
  24537. activeIndex: previousIndex,
  24538. realIndex: previousRealIndex,
  24539. snapIndex: previousSnapIndex
  24540. } = swiper;
  24541. let activeIndex = newActiveIndex;
  24542. let snapIndex;
  24543. const getVirtualRealIndex = aIndex => {
  24544. let realIndex = aIndex - swiper.virtual.slidesBefore;
  24545. if (realIndex < 0) {
  24546. realIndex = swiper.virtual.slides.length + realIndex;
  24547. }
  24548. if (realIndex >= swiper.virtual.slides.length) {
  24549. realIndex -= swiper.virtual.slides.length;
  24550. }
  24551. return realIndex;
  24552. };
  24553. if (typeof activeIndex === 'undefined') {
  24554. activeIndex = getActiveIndexByTranslate(swiper);
  24555. }
  24556. if (snapGrid.indexOf(translate) >= 0) {
  24557. snapIndex = snapGrid.indexOf(translate);
  24558. } else {
  24559. const skip = Math.min(params.slidesPerGroupSkip, activeIndex);
  24560. snapIndex = skip + Math.floor((activeIndex - skip) / params.slidesPerGroup);
  24561. }
  24562. if (snapIndex >= snapGrid.length) snapIndex = snapGrid.length - 1;
  24563. if (activeIndex === previousIndex && !swiper.params.loop) {
  24564. if (snapIndex !== previousSnapIndex) {
  24565. swiper.snapIndex = snapIndex;
  24566. swiper.emit('snapIndexChange');
  24567. }
  24568. return;
  24569. }
  24570. if (activeIndex === previousIndex && swiper.params.loop && swiper.virtual && swiper.params.virtual.enabled) {
  24571. swiper.realIndex = getVirtualRealIndex(activeIndex);
  24572. return;
  24573. }
  24574. const gridEnabled = swiper.grid && params.grid && params.grid.rows > 1;
  24575. // Get real index
  24576. let realIndex;
  24577. if (swiper.virtual && params.virtual.enabled && params.loop) {
  24578. realIndex = getVirtualRealIndex(activeIndex);
  24579. } else if (gridEnabled) {
  24580. const firstSlideInColumn = swiper.slides.find(slideEl => slideEl.column === activeIndex);
  24581. let activeSlideIndex = parseInt(firstSlideInColumn.getAttribute('data-swiper-slide-index'), 10);
  24582. if (Number.isNaN(activeSlideIndex)) {
  24583. activeSlideIndex = Math.max(swiper.slides.indexOf(firstSlideInColumn), 0);
  24584. }
  24585. realIndex = Math.floor(activeSlideIndex / params.grid.rows);
  24586. } else if (swiper.slides[activeIndex]) {
  24587. const slideIndex = swiper.slides[activeIndex].getAttribute('data-swiper-slide-index');
  24588. if (slideIndex) {
  24589. realIndex = parseInt(slideIndex, 10);
  24590. } else {
  24591. realIndex = activeIndex;
  24592. }
  24593. } else {
  24594. realIndex = activeIndex;
  24595. }
  24596. Object.assign(swiper, {
  24597. previousSnapIndex,
  24598. snapIndex,
  24599. previousRealIndex,
  24600. realIndex,
  24601. previousIndex,
  24602. activeIndex
  24603. });
  24604. if (swiper.initialized) {
  24605. preload(swiper);
  24606. }
  24607. swiper.emit('activeIndexChange');
  24608. swiper.emit('snapIndexChange');
  24609. if (swiper.initialized || swiper.params.runCallbacksOnInit) {
  24610. if (previousRealIndex !== realIndex) {
  24611. swiper.emit('realIndexChange');
  24612. }
  24613. swiper.emit('slideChange');
  24614. }
  24615. }
  24616. function updateClickedSlide(el, path) {
  24617. const swiper = this;
  24618. const params = swiper.params;
  24619. let slide = el.closest(`.${params.slideClass}, swiper-slide`);
  24620. if (!slide && swiper.isElement && path && path.length > 1 && path.includes(el)) {
  24621. [...path.slice(path.indexOf(el) + 1, path.length)].forEach(pathEl => {
  24622. if (!slide && pathEl.matches && pathEl.matches(`.${params.slideClass}, swiper-slide`)) {
  24623. slide = pathEl;
  24624. }
  24625. });
  24626. }
  24627. let slideFound = false;
  24628. let slideIndex;
  24629. if (slide) {
  24630. for (let i = 0; i < swiper.slides.length; i += 1) {
  24631. if (swiper.slides[i] === slide) {
  24632. slideFound = true;
  24633. slideIndex = i;
  24634. break;
  24635. }
  24636. }
  24637. }
  24638. if (slide && slideFound) {
  24639. swiper.clickedSlide = slide;
  24640. if (swiper.virtual && swiper.params.virtual.enabled) {
  24641. swiper.clickedIndex = parseInt(slide.getAttribute('data-swiper-slide-index'), 10);
  24642. } else {
  24643. swiper.clickedIndex = slideIndex;
  24644. }
  24645. } else {
  24646. swiper.clickedSlide = undefined;
  24647. swiper.clickedIndex = undefined;
  24648. return;
  24649. }
  24650. if (params.slideToClickedSlide && swiper.clickedIndex !== undefined && swiper.clickedIndex !== swiper.activeIndex) {
  24651. swiper.slideToClickedSlide();
  24652. }
  24653. }
  24654. var update = {
  24655. updateSize,
  24656. updateSlides,
  24657. updateAutoHeight,
  24658. updateSlidesOffset,
  24659. updateSlidesProgress,
  24660. updateProgress,
  24661. updateSlidesClasses,
  24662. updateActiveIndex,
  24663. updateClickedSlide
  24664. };
  24665. function getSwiperTranslate(axis) {
  24666. if (axis === void 0) {
  24667. axis = this.isHorizontal() ? 'x' : 'y';
  24668. }
  24669. const swiper = this;
  24670. const {
  24671. params,
  24672. rtlTranslate: rtl,
  24673. translate,
  24674. wrapperEl
  24675. } = swiper;
  24676. if (params.virtualTranslate) {
  24677. return rtl ? -translate : translate;
  24678. }
  24679. if (params.cssMode) {
  24680. return translate;
  24681. }
  24682. let currentTranslate = getTranslate(wrapperEl, axis);
  24683. currentTranslate += swiper.cssOverflowAdjustment();
  24684. if (rtl) currentTranslate = -currentTranslate;
  24685. return currentTranslate || 0;
  24686. }
  24687. function setTranslate(translate, byController) {
  24688. const swiper = this;
  24689. const {
  24690. rtlTranslate: rtl,
  24691. params,
  24692. wrapperEl,
  24693. progress
  24694. } = swiper;
  24695. let x = 0;
  24696. let y = 0;
  24697. const z = 0;
  24698. if (swiper.isHorizontal()) {
  24699. x = rtl ? -translate : translate;
  24700. } else {
  24701. y = translate;
  24702. }
  24703. if (params.roundLengths) {
  24704. x = Math.floor(x);
  24705. y = Math.floor(y);
  24706. }
  24707. swiper.previousTranslate = swiper.translate;
  24708. swiper.translate = swiper.isHorizontal() ? x : y;
  24709. if (params.cssMode) {
  24710. wrapperEl[swiper.isHorizontal() ? 'scrollLeft' : 'scrollTop'] = swiper.isHorizontal() ? -x : -y;
  24711. } else if (!params.virtualTranslate) {
  24712. if (swiper.isHorizontal()) {
  24713. x -= swiper.cssOverflowAdjustment();
  24714. } else {
  24715. y -= swiper.cssOverflowAdjustment();
  24716. }
  24717. wrapperEl.style.transform = `translate3d(${x}px, ${y}px, ${z}px)`;
  24718. }
  24719. // Check if we need to update progress
  24720. let newProgress;
  24721. const translatesDiff = swiper.maxTranslate() - swiper.minTranslate();
  24722. if (translatesDiff === 0) {
  24723. newProgress = 0;
  24724. } else {
  24725. newProgress = (translate - swiper.minTranslate()) / translatesDiff;
  24726. }
  24727. if (newProgress !== progress) {
  24728. swiper.updateProgress(translate);
  24729. }
  24730. swiper.emit('setTranslate', swiper.translate, byController);
  24731. }
  24732. function minTranslate() {
  24733. return -this.snapGrid[0];
  24734. }
  24735. function maxTranslate() {
  24736. return -this.snapGrid[this.snapGrid.length - 1];
  24737. }
  24738. function translateTo(translate, speed, runCallbacks, translateBounds, internal) {
  24739. if (translate === void 0) {
  24740. translate = 0;
  24741. }
  24742. if (speed === void 0) {
  24743. speed = this.params.speed;
  24744. }
  24745. if (runCallbacks === void 0) {
  24746. runCallbacks = true;
  24747. }
  24748. if (translateBounds === void 0) {
  24749. translateBounds = true;
  24750. }
  24751. const swiper = this;
  24752. const {
  24753. params,
  24754. wrapperEl
  24755. } = swiper;
  24756. if (swiper.animating && params.preventInteractionOnTransition) {
  24757. return false;
  24758. }
  24759. const minTranslate = swiper.minTranslate();
  24760. const maxTranslate = swiper.maxTranslate();
  24761. let newTranslate;
  24762. if (translateBounds && translate > minTranslate) newTranslate = minTranslate;else if (translateBounds && translate < maxTranslate) newTranslate = maxTranslate;else newTranslate = translate;
  24763. // Update progress
  24764. swiper.updateProgress(newTranslate);
  24765. if (params.cssMode) {
  24766. const isH = swiper.isHorizontal();
  24767. if (speed === 0) {
  24768. wrapperEl[isH ? 'scrollLeft' : 'scrollTop'] = -newTranslate;
  24769. } else {
  24770. if (!swiper.support.smoothScroll) {
  24771. animateCSSModeScroll({
  24772. swiper,
  24773. targetPosition: -newTranslate,
  24774. side: isH ? 'left' : 'top'
  24775. });
  24776. return true;
  24777. }
  24778. wrapperEl.scrollTo({
  24779. [isH ? 'left' : 'top']: -newTranslate,
  24780. behavior: 'smooth'
  24781. });
  24782. }
  24783. return true;
  24784. }
  24785. if (speed === 0) {
  24786. swiper.setTransition(0);
  24787. swiper.setTranslate(newTranslate);
  24788. if (runCallbacks) {
  24789. swiper.emit('beforeTransitionStart', speed, internal);
  24790. swiper.emit('transitionEnd');
  24791. }
  24792. } else {
  24793. swiper.setTransition(speed);
  24794. swiper.setTranslate(newTranslate);
  24795. if (runCallbacks) {
  24796. swiper.emit('beforeTransitionStart', speed, internal);
  24797. swiper.emit('transitionStart');
  24798. }
  24799. if (!swiper.animating) {
  24800. swiper.animating = true;
  24801. if (!swiper.onTranslateToWrapperTransitionEnd) {
  24802. swiper.onTranslateToWrapperTransitionEnd = function transitionEnd(e) {
  24803. if (!swiper || swiper.destroyed) return;
  24804. if (e.target !== this) return;
  24805. swiper.wrapperEl.removeEventListener('transitionend', swiper.onTranslateToWrapperTransitionEnd);
  24806. swiper.onTranslateToWrapperTransitionEnd = null;
  24807. delete swiper.onTranslateToWrapperTransitionEnd;
  24808. swiper.animating = false;
  24809. if (runCallbacks) {
  24810. swiper.emit('transitionEnd');
  24811. }
  24812. };
  24813. }
  24814. swiper.wrapperEl.addEventListener('transitionend', swiper.onTranslateToWrapperTransitionEnd);
  24815. }
  24816. }
  24817. return true;
  24818. }
  24819. var translate = {
  24820. getTranslate: getSwiperTranslate,
  24821. setTranslate,
  24822. minTranslate,
  24823. maxTranslate,
  24824. translateTo
  24825. };
  24826. function setTransition(duration, byController) {
  24827. const swiper = this;
  24828. if (!swiper.params.cssMode) {
  24829. swiper.wrapperEl.style.transitionDuration = `${duration}ms`;
  24830. swiper.wrapperEl.style.transitionDelay = duration === 0 ? `0ms` : '';
  24831. }
  24832. swiper.emit('setTransition', duration, byController);
  24833. }
  24834. function transitionEmit(_ref) {
  24835. let {
  24836. swiper,
  24837. runCallbacks,
  24838. direction,
  24839. step
  24840. } = _ref;
  24841. const {
  24842. activeIndex,
  24843. previousIndex
  24844. } = swiper;
  24845. let dir = direction;
  24846. if (!dir) {
  24847. if (activeIndex > previousIndex) dir = 'next';else if (activeIndex < previousIndex) dir = 'prev';else dir = 'reset';
  24848. }
  24849. swiper.emit(`transition${step}`);
  24850. if (runCallbacks && dir === 'reset') {
  24851. swiper.emit(`slideResetTransition${step}`);
  24852. } else if (runCallbacks && activeIndex !== previousIndex) {
  24853. swiper.emit(`slideChangeTransition${step}`);
  24854. if (dir === 'next') {
  24855. swiper.emit(`slideNextTransition${step}`);
  24856. } else {
  24857. swiper.emit(`slidePrevTransition${step}`);
  24858. }
  24859. }
  24860. }
  24861. function transitionStart(runCallbacks, direction) {
  24862. if (runCallbacks === void 0) {
  24863. runCallbacks = true;
  24864. }
  24865. const swiper = this;
  24866. const {
  24867. params
  24868. } = swiper;
  24869. if (params.cssMode) return;
  24870. if (params.autoHeight) {
  24871. swiper.updateAutoHeight();
  24872. }
  24873. transitionEmit({
  24874. swiper,
  24875. runCallbacks,
  24876. direction,
  24877. step: 'Start'
  24878. });
  24879. }
  24880. function transitionEnd(runCallbacks, direction) {
  24881. if (runCallbacks === void 0) {
  24882. runCallbacks = true;
  24883. }
  24884. const swiper = this;
  24885. const {
  24886. params
  24887. } = swiper;
  24888. swiper.animating = false;
  24889. if (params.cssMode) return;
  24890. swiper.setTransition(0);
  24891. transitionEmit({
  24892. swiper,
  24893. runCallbacks,
  24894. direction,
  24895. step: 'End'
  24896. });
  24897. }
  24898. var transition = {
  24899. setTransition,
  24900. transitionStart,
  24901. transitionEnd
  24902. };
  24903. function slideTo(index, speed, runCallbacks, internal, initial) {
  24904. if (index === void 0) {
  24905. index = 0;
  24906. }
  24907. if (runCallbacks === void 0) {
  24908. runCallbacks = true;
  24909. }
  24910. if (typeof index === 'string') {
  24911. index = parseInt(index, 10);
  24912. }
  24913. const swiper = this;
  24914. let slideIndex = index;
  24915. if (slideIndex < 0) slideIndex = 0;
  24916. const {
  24917. params,
  24918. snapGrid,
  24919. slidesGrid,
  24920. previousIndex,
  24921. activeIndex,
  24922. rtlTranslate: rtl,
  24923. wrapperEl,
  24924. enabled
  24925. } = swiper;
  24926. if (!enabled && !internal && !initial || swiper.destroyed || swiper.animating && params.preventInteractionOnTransition) {
  24927. return false;
  24928. }
  24929. if (typeof speed === 'undefined') {
  24930. speed = swiper.params.speed;
  24931. }
  24932. const skip = Math.min(swiper.params.slidesPerGroupSkip, slideIndex);
  24933. let snapIndex = skip + Math.floor((slideIndex - skip) / swiper.params.slidesPerGroup);
  24934. if (snapIndex >= snapGrid.length) snapIndex = snapGrid.length - 1;
  24935. const translate = -snapGrid[snapIndex];
  24936. // Normalize slideIndex
  24937. if (params.normalizeSlideIndex) {
  24938. for (let i = 0; i < slidesGrid.length; i += 1) {
  24939. const normalizedTranslate = -Math.floor(translate * 100);
  24940. const normalizedGrid = Math.floor(slidesGrid[i] * 100);
  24941. const normalizedGridNext = Math.floor(slidesGrid[i + 1] * 100);
  24942. if (typeof slidesGrid[i + 1] !== 'undefined') {
  24943. if (normalizedTranslate >= normalizedGrid && normalizedTranslate < normalizedGridNext - (normalizedGridNext - normalizedGrid) / 2) {
  24944. slideIndex = i;
  24945. } else if (normalizedTranslate >= normalizedGrid && normalizedTranslate < normalizedGridNext) {
  24946. slideIndex = i + 1;
  24947. }
  24948. } else if (normalizedTranslate >= normalizedGrid) {
  24949. slideIndex = i;
  24950. }
  24951. }
  24952. }
  24953. // Directions locks
  24954. if (swiper.initialized && slideIndex !== activeIndex) {
  24955. if (!swiper.allowSlideNext && (rtl ? translate > swiper.translate && translate > swiper.minTranslate() : translate < swiper.translate && translate < swiper.minTranslate())) {
  24956. return false;
  24957. }
  24958. if (!swiper.allowSlidePrev && translate > swiper.translate && translate > swiper.maxTranslate()) {
  24959. if ((activeIndex || 0) !== slideIndex) {
  24960. return false;
  24961. }
  24962. }
  24963. }
  24964. if (slideIndex !== (previousIndex || 0) && runCallbacks) {
  24965. swiper.emit('beforeSlideChangeStart');
  24966. }
  24967. // Update progress
  24968. swiper.updateProgress(translate);
  24969. let direction;
  24970. if (slideIndex > activeIndex) direction = 'next';else if (slideIndex < activeIndex) direction = 'prev';else direction = 'reset';
  24971. // initial virtual
  24972. const isVirtual = swiper.virtual && swiper.params.virtual.enabled;
  24973. const isInitialVirtual = isVirtual && initial;
  24974. // Update Index
  24975. if (!isInitialVirtual && (rtl && -translate === swiper.translate || !rtl && translate === swiper.translate)) {
  24976. swiper.updateActiveIndex(slideIndex);
  24977. // Update Height
  24978. if (params.autoHeight) {
  24979. swiper.updateAutoHeight();
  24980. }
  24981. swiper.updateSlidesClasses();
  24982. if (params.effect !== 'slide') {
  24983. swiper.setTranslate(translate);
  24984. }
  24985. if (direction !== 'reset') {
  24986. swiper.transitionStart(runCallbacks, direction);
  24987. swiper.transitionEnd(runCallbacks, direction);
  24988. }
  24989. return false;
  24990. }
  24991. if (params.cssMode) {
  24992. const isH = swiper.isHorizontal();
  24993. const t = rtl ? translate : -translate;
  24994. if (speed === 0) {
  24995. if (isVirtual) {
  24996. swiper.wrapperEl.style.scrollSnapType = 'none';
  24997. swiper._immediateVirtual = true;
  24998. }
  24999. if (isVirtual && !swiper._cssModeVirtualInitialSet && swiper.params.initialSlide > 0) {
  25000. swiper._cssModeVirtualInitialSet = true;
  25001. requestAnimationFrame(() => {
  25002. wrapperEl[isH ? 'scrollLeft' : 'scrollTop'] = t;
  25003. });
  25004. } else {
  25005. wrapperEl[isH ? 'scrollLeft' : 'scrollTop'] = t;
  25006. }
  25007. if (isVirtual) {
  25008. requestAnimationFrame(() => {
  25009. swiper.wrapperEl.style.scrollSnapType = '';
  25010. swiper._immediateVirtual = false;
  25011. });
  25012. }
  25013. } else {
  25014. if (!swiper.support.smoothScroll) {
  25015. animateCSSModeScroll({
  25016. swiper,
  25017. targetPosition: t,
  25018. side: isH ? 'left' : 'top'
  25019. });
  25020. return true;
  25021. }
  25022. wrapperEl.scrollTo({
  25023. [isH ? 'left' : 'top']: t,
  25024. behavior: 'smooth'
  25025. });
  25026. }
  25027. return true;
  25028. }
  25029. const browser = getBrowser();
  25030. const isSafari = browser.isSafari;
  25031. if (isVirtual && !initial && isSafari && swiper.isElement) {
  25032. swiper.virtual.update(false, false, slideIndex);
  25033. }
  25034. swiper.setTransition(speed);
  25035. swiper.setTranslate(translate);
  25036. swiper.updateActiveIndex(slideIndex);
  25037. swiper.updateSlidesClasses();
  25038. swiper.emit('beforeTransitionStart', speed, internal);
  25039. swiper.transitionStart(runCallbacks, direction);
  25040. if (speed === 0) {
  25041. swiper.transitionEnd(runCallbacks, direction);
  25042. } else if (!swiper.animating) {
  25043. swiper.animating = true;
  25044. if (!swiper.onSlideToWrapperTransitionEnd) {
  25045. swiper.onSlideToWrapperTransitionEnd = function transitionEnd(e) {
  25046. if (!swiper || swiper.destroyed) return;
  25047. if (e.target !== this) return;
  25048. swiper.wrapperEl.removeEventListener('transitionend', swiper.onSlideToWrapperTransitionEnd);
  25049. swiper.onSlideToWrapperTransitionEnd = null;
  25050. delete swiper.onSlideToWrapperTransitionEnd;
  25051. swiper.transitionEnd(runCallbacks, direction);
  25052. };
  25053. }
  25054. swiper.wrapperEl.addEventListener('transitionend', swiper.onSlideToWrapperTransitionEnd);
  25055. }
  25056. return true;
  25057. }
  25058. function slideToLoop(index, speed, runCallbacks, internal) {
  25059. if (index === void 0) {
  25060. index = 0;
  25061. }
  25062. if (runCallbacks === void 0) {
  25063. runCallbacks = true;
  25064. }
  25065. if (typeof index === 'string') {
  25066. const indexAsNumber = parseInt(index, 10);
  25067. index = indexAsNumber;
  25068. }
  25069. const swiper = this;
  25070. if (swiper.destroyed) return;
  25071. if (typeof speed === 'undefined') {
  25072. speed = swiper.params.speed;
  25073. }
  25074. const gridEnabled = swiper.grid && swiper.params.grid && swiper.params.grid.rows > 1;
  25075. let newIndex = index;
  25076. if (swiper.params.loop) {
  25077. if (swiper.virtual && swiper.params.virtual.enabled) {
  25078. // eslint-disable-next-line
  25079. newIndex = newIndex + swiper.virtual.slidesBefore;
  25080. } else {
  25081. let targetSlideIndex;
  25082. if (gridEnabled) {
  25083. const slideIndex = newIndex * swiper.params.grid.rows;
  25084. targetSlideIndex = swiper.slides.find(slideEl => slideEl.getAttribute('data-swiper-slide-index') * 1 === slideIndex).column;
  25085. } else {
  25086. targetSlideIndex = swiper.getSlideIndexByData(newIndex);
  25087. }
  25088. const cols = gridEnabled ? Math.ceil(swiper.slides.length / swiper.params.grid.rows) : swiper.slides.length;
  25089. const {
  25090. centeredSlides
  25091. } = swiper.params;
  25092. let slidesPerView = swiper.params.slidesPerView;
  25093. if (slidesPerView === 'auto') {
  25094. slidesPerView = swiper.slidesPerViewDynamic();
  25095. } else {
  25096. slidesPerView = Math.ceil(parseFloat(swiper.params.slidesPerView, 10));
  25097. if (centeredSlides && slidesPerView % 2 === 0) {
  25098. slidesPerView = slidesPerView + 1;
  25099. }
  25100. }
  25101. let needLoopFix = cols - targetSlideIndex < slidesPerView;
  25102. if (centeredSlides) {
  25103. needLoopFix = needLoopFix || targetSlideIndex < Math.ceil(slidesPerView / 2);
  25104. }
  25105. if (internal && centeredSlides && swiper.params.slidesPerView !== 'auto' && !gridEnabled) {
  25106. needLoopFix = false;
  25107. }
  25108. if (needLoopFix) {
  25109. const direction = centeredSlides ? targetSlideIndex < swiper.activeIndex ? 'prev' : 'next' : targetSlideIndex - swiper.activeIndex - 1 < swiper.params.slidesPerView ? 'next' : 'prev';
  25110. swiper.loopFix({
  25111. direction,
  25112. slideTo: true,
  25113. activeSlideIndex: direction === 'next' ? targetSlideIndex + 1 : targetSlideIndex - cols + 1,
  25114. slideRealIndex: direction === 'next' ? swiper.realIndex : undefined
  25115. });
  25116. }
  25117. if (gridEnabled) {
  25118. const slideIndex = newIndex * swiper.params.grid.rows;
  25119. newIndex = swiper.slides.find(slideEl => slideEl.getAttribute('data-swiper-slide-index') * 1 === slideIndex).column;
  25120. } else {
  25121. newIndex = swiper.getSlideIndexByData(newIndex);
  25122. }
  25123. }
  25124. }
  25125. requestAnimationFrame(() => {
  25126. swiper.slideTo(newIndex, speed, runCallbacks, internal);
  25127. });
  25128. return swiper;
  25129. }
  25130. /* eslint no-unused-vars: "off" */
  25131. function slideNext(speed, runCallbacks, internal) {
  25132. if (runCallbacks === void 0) {
  25133. runCallbacks = true;
  25134. }
  25135. const swiper = this;
  25136. const {
  25137. enabled,
  25138. params,
  25139. animating
  25140. } = swiper;
  25141. if (!enabled || swiper.destroyed) return swiper;
  25142. if (typeof speed === 'undefined') {
  25143. speed = swiper.params.speed;
  25144. }
  25145. let perGroup = params.slidesPerGroup;
  25146. if (params.slidesPerView === 'auto' && params.slidesPerGroup === 1 && params.slidesPerGroupAuto) {
  25147. perGroup = Math.max(swiper.slidesPerViewDynamic('current', true), 1);
  25148. }
  25149. const increment = swiper.activeIndex < params.slidesPerGroupSkip ? 1 : perGroup;
  25150. const isVirtual = swiper.virtual && params.virtual.enabled;
  25151. if (params.loop) {
  25152. if (animating && !isVirtual && params.loopPreventsSliding) return false;
  25153. swiper.loopFix({
  25154. direction: 'next'
  25155. });
  25156. // eslint-disable-next-line
  25157. swiper._clientLeft = swiper.wrapperEl.clientLeft;
  25158. if (swiper.activeIndex === swiper.slides.length - 1 && params.cssMode) {
  25159. requestAnimationFrame(() => {
  25160. swiper.slideTo(swiper.activeIndex + increment, speed, runCallbacks, internal);
  25161. });
  25162. return true;
  25163. }
  25164. }
  25165. if (params.rewind && swiper.isEnd) {
  25166. return swiper.slideTo(0, speed, runCallbacks, internal);
  25167. }
  25168. return swiper.slideTo(swiper.activeIndex + increment, speed, runCallbacks, internal);
  25169. }
  25170. /* eslint no-unused-vars: "off" */
  25171. function slidePrev(speed, runCallbacks, internal) {
  25172. if (runCallbacks === void 0) {
  25173. runCallbacks = true;
  25174. }
  25175. const swiper = this;
  25176. const {
  25177. params,
  25178. snapGrid,
  25179. slidesGrid,
  25180. rtlTranslate,
  25181. enabled,
  25182. animating
  25183. } = swiper;
  25184. if (!enabled || swiper.destroyed) return swiper;
  25185. if (typeof speed === 'undefined') {
  25186. speed = swiper.params.speed;
  25187. }
  25188. const isVirtual = swiper.virtual && params.virtual.enabled;
  25189. if (params.loop) {
  25190. if (animating && !isVirtual && params.loopPreventsSliding) return false;
  25191. swiper.loopFix({
  25192. direction: 'prev'
  25193. });
  25194. // eslint-disable-next-line
  25195. swiper._clientLeft = swiper.wrapperEl.clientLeft;
  25196. }
  25197. const translate = rtlTranslate ? swiper.translate : -swiper.translate;
  25198. function normalize(val) {
  25199. if (val < 0) return -Math.floor(Math.abs(val));
  25200. return Math.floor(val);
  25201. }
  25202. const normalizedTranslate = normalize(translate);
  25203. const normalizedSnapGrid = snapGrid.map(val => normalize(val));
  25204. const isFreeMode = params.freeMode && params.freeMode.enabled;
  25205. let prevSnap = snapGrid[normalizedSnapGrid.indexOf(normalizedTranslate) - 1];
  25206. if (typeof prevSnap === 'undefined' && (params.cssMode || isFreeMode)) {
  25207. let prevSnapIndex;
  25208. snapGrid.forEach((snap, snapIndex) => {
  25209. if (normalizedTranslate >= snap) {
  25210. // prevSnap = snap;
  25211. prevSnapIndex = snapIndex;
  25212. }
  25213. });
  25214. if (typeof prevSnapIndex !== 'undefined') {
  25215. prevSnap = isFreeMode ? snapGrid[prevSnapIndex] : snapGrid[prevSnapIndex > 0 ? prevSnapIndex - 1 : prevSnapIndex];
  25216. }
  25217. }
  25218. let prevIndex = 0;
  25219. if (typeof prevSnap !== 'undefined') {
  25220. prevIndex = slidesGrid.indexOf(prevSnap);
  25221. if (prevIndex < 0) prevIndex = swiper.activeIndex - 1;
  25222. if (params.slidesPerView === 'auto' && params.slidesPerGroup === 1 && params.slidesPerGroupAuto) {
  25223. prevIndex = prevIndex - swiper.slidesPerViewDynamic('previous', true) + 1;
  25224. prevIndex = Math.max(prevIndex, 0);
  25225. }
  25226. }
  25227. if (params.rewind && swiper.isBeginning) {
  25228. const lastIndex = swiper.params.virtual && swiper.params.virtual.enabled && swiper.virtual ? swiper.virtual.slides.length - 1 : swiper.slides.length - 1;
  25229. return swiper.slideTo(lastIndex, speed, runCallbacks, internal);
  25230. } else if (params.loop && swiper.activeIndex === 0 && params.cssMode) {
  25231. requestAnimationFrame(() => {
  25232. swiper.slideTo(prevIndex, speed, runCallbacks, internal);
  25233. });
  25234. return true;
  25235. }
  25236. return swiper.slideTo(prevIndex, speed, runCallbacks, internal);
  25237. }
  25238. /* eslint no-unused-vars: "off" */
  25239. function slideReset(speed, runCallbacks, internal) {
  25240. if (runCallbacks === void 0) {
  25241. runCallbacks = true;
  25242. }
  25243. const swiper = this;
  25244. if (swiper.destroyed) return;
  25245. if (typeof speed === 'undefined') {
  25246. speed = swiper.params.speed;
  25247. }
  25248. return swiper.slideTo(swiper.activeIndex, speed, runCallbacks, internal);
  25249. }
  25250. /* eslint no-unused-vars: "off" */
  25251. function slideToClosest(speed, runCallbacks, internal, threshold) {
  25252. if (runCallbacks === void 0) {
  25253. runCallbacks = true;
  25254. }
  25255. if (threshold === void 0) {
  25256. threshold = 0.5;
  25257. }
  25258. const swiper = this;
  25259. if (swiper.destroyed) return;
  25260. if (typeof speed === 'undefined') {
  25261. speed = swiper.params.speed;
  25262. }
  25263. let index = swiper.activeIndex;
  25264. const skip = Math.min(swiper.params.slidesPerGroupSkip, index);
  25265. const snapIndex = skip + Math.floor((index - skip) / swiper.params.slidesPerGroup);
  25266. const translate = swiper.rtlTranslate ? swiper.translate : -swiper.translate;
  25267. if (translate >= swiper.snapGrid[snapIndex]) {
  25268. // The current translate is on or after the current snap index, so the choice
  25269. // is between the current index and the one after it.
  25270. const currentSnap = swiper.snapGrid[snapIndex];
  25271. const nextSnap = swiper.snapGrid[snapIndex + 1];
  25272. if (translate - currentSnap > (nextSnap - currentSnap) * threshold) {
  25273. index += swiper.params.slidesPerGroup;
  25274. }
  25275. } else {
  25276. // The current translate is before the current snap index, so the choice
  25277. // is between the current index and the one before it.
  25278. const prevSnap = swiper.snapGrid[snapIndex - 1];
  25279. const currentSnap = swiper.snapGrid[snapIndex];
  25280. if (translate - prevSnap <= (currentSnap - prevSnap) * threshold) {
  25281. index -= swiper.params.slidesPerGroup;
  25282. }
  25283. }
  25284. index = Math.max(index, 0);
  25285. index = Math.min(index, swiper.slidesGrid.length - 1);
  25286. return swiper.slideTo(index, speed, runCallbacks, internal);
  25287. }
  25288. function slideToClickedSlide() {
  25289. const swiper = this;
  25290. if (swiper.destroyed) return;
  25291. const {
  25292. params,
  25293. slidesEl
  25294. } = swiper;
  25295. const slidesPerView = params.slidesPerView === 'auto' ? swiper.slidesPerViewDynamic() : params.slidesPerView;
  25296. let slideToIndex = swiper.getSlideIndexWhenGrid(swiper.clickedIndex);
  25297. let realIndex;
  25298. const slideSelector = swiper.isElement ? `swiper-slide` : `.${params.slideClass}`;
  25299. const isGrid = swiper.grid && swiper.params.grid && swiper.params.grid.rows > 1;
  25300. if (params.loop) {
  25301. if (swiper.animating) return;
  25302. realIndex = parseInt(swiper.clickedSlide.getAttribute('data-swiper-slide-index'), 10);
  25303. if (params.centeredSlides) {
  25304. swiper.slideToLoop(realIndex);
  25305. } else if (slideToIndex > (isGrid ? (swiper.slides.length - slidesPerView) / 2 - (swiper.params.grid.rows - 1) : swiper.slides.length - slidesPerView)) {
  25306. swiper.loopFix();
  25307. slideToIndex = swiper.getSlideIndex(elementChildren(slidesEl, `${slideSelector}[data-swiper-slide-index="${realIndex}"]`)[0]);
  25308. nextTick(() => {
  25309. swiper.slideTo(slideToIndex);
  25310. });
  25311. } else {
  25312. swiper.slideTo(slideToIndex);
  25313. }
  25314. } else {
  25315. swiper.slideTo(slideToIndex);
  25316. }
  25317. }
  25318. var slide = {
  25319. slideTo,
  25320. slideToLoop,
  25321. slideNext,
  25322. slidePrev,
  25323. slideReset,
  25324. slideToClosest,
  25325. slideToClickedSlide
  25326. };
  25327. function loopCreate(slideRealIndex, initial) {
  25328. const swiper = this;
  25329. const {
  25330. params,
  25331. slidesEl
  25332. } = swiper;
  25333. if (!params.loop || swiper.virtual && swiper.params.virtual.enabled) return;
  25334. const initSlides = () => {
  25335. const slides = elementChildren(slidesEl, `.${params.slideClass}, swiper-slide`);
  25336. slides.forEach((el, index) => {
  25337. el.setAttribute('data-swiper-slide-index', index);
  25338. });
  25339. };
  25340. const clearBlankSlides = () => {
  25341. const slides = elementChildren(slidesEl, `.${params.slideBlankClass}`);
  25342. slides.forEach(el => {
  25343. el.remove();
  25344. });
  25345. if (slides.length > 0) {
  25346. swiper.recalcSlides();
  25347. swiper.updateSlides();
  25348. }
  25349. };
  25350. const gridEnabled = swiper.grid && params.grid && params.grid.rows > 1;
  25351. if (params.loopAddBlankSlides && (params.slidesPerGroup > 1 || gridEnabled)) {
  25352. clearBlankSlides();
  25353. }
  25354. const slidesPerGroup = params.slidesPerGroup * (gridEnabled ? params.grid.rows : 1);
  25355. const shouldFillGroup = swiper.slides.length % slidesPerGroup !== 0;
  25356. const shouldFillGrid = gridEnabled && swiper.slides.length % params.grid.rows !== 0;
  25357. const addBlankSlides = amountOfSlides => {
  25358. for (let i = 0; i < amountOfSlides; i += 1) {
  25359. const slideEl = swiper.isElement ? createElement('swiper-slide', [params.slideBlankClass]) : createElement('div', [params.slideClass, params.slideBlankClass]);
  25360. swiper.slidesEl.append(slideEl);
  25361. }
  25362. };
  25363. if (shouldFillGroup) {
  25364. if (params.loopAddBlankSlides) {
  25365. const slidesToAdd = slidesPerGroup - swiper.slides.length % slidesPerGroup;
  25366. addBlankSlides(slidesToAdd);
  25367. swiper.recalcSlides();
  25368. swiper.updateSlides();
  25369. } else {
  25370. 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)');
  25371. }
  25372. initSlides();
  25373. } else if (shouldFillGrid) {
  25374. if (params.loopAddBlankSlides) {
  25375. const slidesToAdd = params.grid.rows - swiper.slides.length % params.grid.rows;
  25376. addBlankSlides(slidesToAdd);
  25377. swiper.recalcSlides();
  25378. swiper.updateSlides();
  25379. } else {
  25380. 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)');
  25381. }
  25382. initSlides();
  25383. } else {
  25384. initSlides();
  25385. }
  25386. swiper.loopFix({
  25387. slideRealIndex,
  25388. direction: params.centeredSlides ? undefined : 'next',
  25389. initial
  25390. });
  25391. }
  25392. function loopFix(_temp) {
  25393. let {
  25394. slideRealIndex,
  25395. slideTo = true,
  25396. direction,
  25397. setTranslate,
  25398. activeSlideIndex,
  25399. initial,
  25400. byController,
  25401. byMousewheel
  25402. } = _temp === void 0 ? {} : _temp;
  25403. const swiper = this;
  25404. if (!swiper.params.loop) return;
  25405. swiper.emit('beforeLoopFix');
  25406. const {
  25407. slides,
  25408. allowSlidePrev,
  25409. allowSlideNext,
  25410. slidesEl,
  25411. params
  25412. } = swiper;
  25413. const {
  25414. centeredSlides,
  25415. initialSlide
  25416. } = params;
  25417. swiper.allowSlidePrev = true;
  25418. swiper.allowSlideNext = true;
  25419. if (swiper.virtual && params.virtual.enabled) {
  25420. if (slideTo) {
  25421. if (!params.centeredSlides && swiper.snapIndex === 0) {
  25422. swiper.slideTo(swiper.virtual.slides.length, 0, false, true);
  25423. } else if (params.centeredSlides && swiper.snapIndex < params.slidesPerView) {
  25424. swiper.slideTo(swiper.virtual.slides.length + swiper.snapIndex, 0, false, true);
  25425. } else if (swiper.snapIndex === swiper.snapGrid.length - 1) {
  25426. swiper.slideTo(swiper.virtual.slidesBefore, 0, false, true);
  25427. }
  25428. }
  25429. swiper.allowSlidePrev = allowSlidePrev;
  25430. swiper.allowSlideNext = allowSlideNext;
  25431. swiper.emit('loopFix');
  25432. return;
  25433. }
  25434. let slidesPerView = params.slidesPerView;
  25435. if (slidesPerView === 'auto') {
  25436. slidesPerView = swiper.slidesPerViewDynamic();
  25437. } else {
  25438. slidesPerView = Math.ceil(parseFloat(params.slidesPerView, 10));
  25439. if (centeredSlides && slidesPerView % 2 === 0) {
  25440. slidesPerView = slidesPerView + 1;
  25441. }
  25442. }
  25443. const slidesPerGroup = params.slidesPerGroupAuto ? slidesPerView : params.slidesPerGroup;
  25444. let loopedSlides = centeredSlides ? Math.max(slidesPerGroup, Math.ceil(slidesPerView / 2)) : slidesPerGroup;
  25445. if (loopedSlides % slidesPerGroup !== 0) {
  25446. loopedSlides += slidesPerGroup - loopedSlides % slidesPerGroup;
  25447. }
  25448. loopedSlides += params.loopAdditionalSlides;
  25449. swiper.loopedSlides = loopedSlides;
  25450. const gridEnabled = swiper.grid && params.grid && params.grid.rows > 1;
  25451. if (slides.length < slidesPerView + loopedSlides || swiper.params.effect === 'cards' && slides.length < slidesPerView + loopedSlides * 2) {
  25452. showWarning('Swiper Loop Warning: The number of slides is not enough for loop mode, it will be disabled or not function properly. You need to add more slides (or make duplicates) or lower the values of slidesPerView and slidesPerGroup parameters');
  25453. } else if (gridEnabled && params.grid.fill === 'row') {
  25454. showWarning('Swiper Loop Warning: Loop mode is not compatible with grid.fill = `row`');
  25455. }
  25456. const prependSlidesIndexes = [];
  25457. const appendSlidesIndexes = [];
  25458. const cols = gridEnabled ? Math.ceil(slides.length / params.grid.rows) : slides.length;
  25459. const isInitialOverflow = initial && cols - initialSlide < slidesPerView && !centeredSlides;
  25460. let activeIndex = isInitialOverflow ? initialSlide : swiper.activeIndex;
  25461. if (typeof activeSlideIndex === 'undefined') {
  25462. activeSlideIndex = swiper.getSlideIndex(slides.find(el => el.classList.contains(params.slideActiveClass)));
  25463. } else {
  25464. activeIndex = activeSlideIndex;
  25465. }
  25466. const isNext = direction === 'next' || !direction;
  25467. const isPrev = direction === 'prev' || !direction;
  25468. let slidesPrepended = 0;
  25469. let slidesAppended = 0;
  25470. const activeColIndex = gridEnabled ? slides[activeSlideIndex].column : activeSlideIndex;
  25471. const activeColIndexWithShift = activeColIndex + (centeredSlides && typeof setTranslate === 'undefined' ? -slidesPerView / 2 + 0.5 : 0);
  25472. // prepend last slides before start
  25473. if (activeColIndexWithShift < loopedSlides) {
  25474. slidesPrepended = Math.max(loopedSlides - activeColIndexWithShift, slidesPerGroup);
  25475. for (let i = 0; i < loopedSlides - activeColIndexWithShift; i += 1) {
  25476. const index = i - Math.floor(i / cols) * cols;
  25477. if (gridEnabled) {
  25478. const colIndexToPrepend = cols - index - 1;
  25479. for (let i = slides.length - 1; i >= 0; i -= 1) {
  25480. if (slides[i].column === colIndexToPrepend) prependSlidesIndexes.push(i);
  25481. }
  25482. // slides.forEach((slide, slideIndex) => {
  25483. // if (slide.column === colIndexToPrepend) prependSlidesIndexes.push(slideIndex);
  25484. // });
  25485. } else {
  25486. prependSlidesIndexes.push(cols - index - 1);
  25487. }
  25488. }
  25489. } else if (activeColIndexWithShift + slidesPerView > cols - loopedSlides) {
  25490. slidesAppended = Math.max(activeColIndexWithShift - (cols - loopedSlides * 2), slidesPerGroup);
  25491. if (isInitialOverflow) {
  25492. slidesAppended = Math.max(slidesAppended, slidesPerView - cols + initialSlide + 1);
  25493. }
  25494. for (let i = 0; i < slidesAppended; i += 1) {
  25495. const index = i - Math.floor(i / cols) * cols;
  25496. if (gridEnabled) {
  25497. slides.forEach((slide, slideIndex) => {
  25498. if (slide.column === index) appendSlidesIndexes.push(slideIndex);
  25499. });
  25500. } else {
  25501. appendSlidesIndexes.push(index);
  25502. }
  25503. }
  25504. }
  25505. swiper.__preventObserver__ = true;
  25506. requestAnimationFrame(() => {
  25507. swiper.__preventObserver__ = false;
  25508. });
  25509. if (swiper.params.effect === 'cards' && slides.length < slidesPerView + loopedSlides * 2) {
  25510. if (appendSlidesIndexes.includes(activeSlideIndex)) {
  25511. appendSlidesIndexes.splice(appendSlidesIndexes.indexOf(activeSlideIndex), 1);
  25512. }
  25513. if (prependSlidesIndexes.includes(activeSlideIndex)) {
  25514. prependSlidesIndexes.splice(prependSlidesIndexes.indexOf(activeSlideIndex), 1);
  25515. }
  25516. }
  25517. if (isPrev) {
  25518. prependSlidesIndexes.forEach(index => {
  25519. slides[index].swiperLoopMoveDOM = true;
  25520. slidesEl.prepend(slides[index]);
  25521. slides[index].swiperLoopMoveDOM = false;
  25522. });
  25523. }
  25524. if (isNext) {
  25525. appendSlidesIndexes.forEach(index => {
  25526. slides[index].swiperLoopMoveDOM = true;
  25527. slidesEl.append(slides[index]);
  25528. slides[index].swiperLoopMoveDOM = false;
  25529. });
  25530. }
  25531. swiper.recalcSlides();
  25532. if (params.slidesPerView === 'auto') {
  25533. swiper.updateSlides();
  25534. } else if (gridEnabled && (prependSlidesIndexes.length > 0 && isPrev || appendSlidesIndexes.length > 0 && isNext)) {
  25535. swiper.slides.forEach((slide, slideIndex) => {
  25536. swiper.grid.updateSlide(slideIndex, slide, swiper.slides);
  25537. });
  25538. }
  25539. if (params.watchSlidesProgress) {
  25540. swiper.updateSlidesOffset();
  25541. }
  25542. if (slideTo) {
  25543. if (prependSlidesIndexes.length > 0 && isPrev) {
  25544. if (typeof slideRealIndex === 'undefined') {
  25545. const currentSlideTranslate = swiper.slidesGrid[activeIndex];
  25546. const newSlideTranslate = swiper.slidesGrid[activeIndex + slidesPrepended];
  25547. const diff = newSlideTranslate - currentSlideTranslate;
  25548. if (byMousewheel) {
  25549. swiper.setTranslate(swiper.translate - diff);
  25550. } else {
  25551. swiper.slideTo(activeIndex + Math.ceil(slidesPrepended), 0, false, true);
  25552. if (setTranslate) {
  25553. swiper.touchEventsData.startTranslate = swiper.touchEventsData.startTranslate - diff;
  25554. swiper.touchEventsData.currentTranslate = swiper.touchEventsData.currentTranslate - diff;
  25555. }
  25556. }
  25557. } else {
  25558. if (setTranslate) {
  25559. const shift = gridEnabled ? prependSlidesIndexes.length / params.grid.rows : prependSlidesIndexes.length;
  25560. swiper.slideTo(swiper.activeIndex + shift, 0, false, true);
  25561. swiper.touchEventsData.currentTranslate = swiper.translate;
  25562. }
  25563. }
  25564. } else if (appendSlidesIndexes.length > 0 && isNext) {
  25565. if (typeof slideRealIndex === 'undefined') {
  25566. const currentSlideTranslate = swiper.slidesGrid[activeIndex];
  25567. const newSlideTranslate = swiper.slidesGrid[activeIndex - slidesAppended];
  25568. const diff = newSlideTranslate - currentSlideTranslate;
  25569. if (byMousewheel) {
  25570. swiper.setTranslate(swiper.translate - diff);
  25571. } else {
  25572. swiper.slideTo(activeIndex - slidesAppended, 0, false, true);
  25573. if (setTranslate) {
  25574. swiper.touchEventsData.startTranslate = swiper.touchEventsData.startTranslate - diff;
  25575. swiper.touchEventsData.currentTranslate = swiper.touchEventsData.currentTranslate - diff;
  25576. }
  25577. }
  25578. } else {
  25579. const shift = gridEnabled ? appendSlidesIndexes.length / params.grid.rows : appendSlidesIndexes.length;
  25580. swiper.slideTo(swiper.activeIndex - shift, 0, false, true);
  25581. }
  25582. }
  25583. }
  25584. swiper.allowSlidePrev = allowSlidePrev;
  25585. swiper.allowSlideNext = allowSlideNext;
  25586. if (swiper.controller && swiper.controller.control && !byController) {
  25587. const loopParams = {
  25588. slideRealIndex,
  25589. direction,
  25590. setTranslate,
  25591. activeSlideIndex,
  25592. byController: true
  25593. };
  25594. if (Array.isArray(swiper.controller.control)) {
  25595. swiper.controller.control.forEach(c => {
  25596. if (!c.destroyed && c.params.loop) c.loopFix({
  25597. ...loopParams,
  25598. slideTo: c.params.slidesPerView === params.slidesPerView ? slideTo : false
  25599. });
  25600. });
  25601. } else if (swiper.controller.control instanceof swiper.constructor && swiper.controller.control.params.loop) {
  25602. swiper.controller.control.loopFix({
  25603. ...loopParams,
  25604. slideTo: swiper.controller.control.params.slidesPerView === params.slidesPerView ? slideTo : false
  25605. });
  25606. }
  25607. }
  25608. swiper.emit('loopFix');
  25609. }
  25610. function loopDestroy() {
  25611. const swiper = this;
  25612. const {
  25613. params,
  25614. slidesEl
  25615. } = swiper;
  25616. if (!params.loop || !slidesEl || swiper.virtual && swiper.params.virtual.enabled) return;
  25617. swiper.recalcSlides();
  25618. const newSlidesOrder = [];
  25619. swiper.slides.forEach(slideEl => {
  25620. const index = typeof slideEl.swiperSlideIndex === 'undefined' ? slideEl.getAttribute('data-swiper-slide-index') * 1 : slideEl.swiperSlideIndex;
  25621. newSlidesOrder[index] = slideEl;
  25622. });
  25623. swiper.slides.forEach(slideEl => {
  25624. slideEl.removeAttribute('data-swiper-slide-index');
  25625. });
  25626. newSlidesOrder.forEach(slideEl => {
  25627. slidesEl.append(slideEl);
  25628. });
  25629. swiper.recalcSlides();
  25630. swiper.slideTo(swiper.realIndex, 0);
  25631. }
  25632. var loop = {
  25633. loopCreate,
  25634. loopFix,
  25635. loopDestroy
  25636. };
  25637. function setGrabCursor(moving) {
  25638. const swiper = this;
  25639. if (!swiper.params.simulateTouch || swiper.params.watchOverflow && swiper.isLocked || swiper.params.cssMode) return;
  25640. const el = swiper.params.touchEventsTarget === 'container' ? swiper.el : swiper.wrapperEl;
  25641. if (swiper.isElement) {
  25642. swiper.__preventObserver__ = true;
  25643. }
  25644. el.style.cursor = 'move';
  25645. el.style.cursor = moving ? 'grabbing' : 'grab';
  25646. if (swiper.isElement) {
  25647. requestAnimationFrame(() => {
  25648. swiper.__preventObserver__ = false;
  25649. });
  25650. }
  25651. }
  25652. function unsetGrabCursor() {
  25653. const swiper = this;
  25654. if (swiper.params.watchOverflow && swiper.isLocked || swiper.params.cssMode) {
  25655. return;
  25656. }
  25657. if (swiper.isElement) {
  25658. swiper.__preventObserver__ = true;
  25659. }
  25660. swiper[swiper.params.touchEventsTarget === 'container' ? 'el' : 'wrapperEl'].style.cursor = '';
  25661. if (swiper.isElement) {
  25662. requestAnimationFrame(() => {
  25663. swiper.__preventObserver__ = false;
  25664. });
  25665. }
  25666. }
  25667. var grabCursor = {
  25668. setGrabCursor,
  25669. unsetGrabCursor
  25670. };
  25671. // Modified from https://stackoverflow.com/questions/54520554/custom-element-getrootnode-closest-function-crossing-multiple-parent-shadowd
  25672. function closestElement(selector, base) {
  25673. if (base === void 0) {
  25674. base = this;
  25675. }
  25676. function __closestFrom(el) {
  25677. if (!el || el === getDocument() || el === getWindow()) return null;
  25678. if (el.assignedSlot) el = el.assignedSlot;
  25679. const found = el.closest(selector);
  25680. if (!found && !el.getRootNode) {
  25681. return null;
  25682. }
  25683. return found || __closestFrom(el.getRootNode().host);
  25684. }
  25685. return __closestFrom(base);
  25686. }
  25687. function preventEdgeSwipe(swiper, event, startX) {
  25688. const window = getWindow();
  25689. const {
  25690. params
  25691. } = swiper;
  25692. const edgeSwipeDetection = params.edgeSwipeDetection;
  25693. const edgeSwipeThreshold = params.edgeSwipeThreshold;
  25694. if (edgeSwipeDetection && (startX <= edgeSwipeThreshold || startX >= window.innerWidth - edgeSwipeThreshold)) {
  25695. if (edgeSwipeDetection === 'prevent') {
  25696. event.preventDefault();
  25697. return true;
  25698. }
  25699. return false;
  25700. }
  25701. return true;
  25702. }
  25703. function onTouchStart(event) {
  25704. const swiper = this;
  25705. const document = getDocument();
  25706. let e = event;
  25707. if (e.originalEvent) e = e.originalEvent;
  25708. const data = swiper.touchEventsData;
  25709. if (e.type === 'pointerdown') {
  25710. if (data.pointerId !== null && data.pointerId !== e.pointerId) {
  25711. return;
  25712. }
  25713. data.pointerId = e.pointerId;
  25714. } else if (e.type === 'touchstart' && e.targetTouches.length === 1) {
  25715. data.touchId = e.targetTouches[0].identifier;
  25716. }
  25717. if (e.type === 'touchstart') {
  25718. // don't proceed touch event
  25719. preventEdgeSwipe(swiper, e, e.targetTouches[0].pageX);
  25720. return;
  25721. }
  25722. const {
  25723. params,
  25724. touches,
  25725. enabled
  25726. } = swiper;
  25727. if (!enabled) return;
  25728. if (!params.simulateTouch && e.pointerType === 'mouse') return;
  25729. if (swiper.animating && params.preventInteractionOnTransition) {
  25730. return;
  25731. }
  25732. if (!swiper.animating && params.cssMode && params.loop) {
  25733. swiper.loopFix();
  25734. }
  25735. let targetEl = e.target;
  25736. if (params.touchEventsTarget === 'wrapper') {
  25737. if (!elementIsChildOf(targetEl, swiper.wrapperEl)) return;
  25738. }
  25739. if ('which' in e && e.which === 3) return;
  25740. if ('button' in e && e.button > 0) return;
  25741. if (data.isTouched && data.isMoved) return;
  25742. // change target el for shadow root component
  25743. const swipingClassHasValue = !!params.noSwipingClass && params.noSwipingClass !== '';
  25744. // eslint-disable-next-line
  25745. const eventPath = e.composedPath ? e.composedPath() : e.path;
  25746. if (swipingClassHasValue && e.target && e.target.shadowRoot && eventPath) {
  25747. targetEl = eventPath[0];
  25748. }
  25749. const noSwipingSelector = params.noSwipingSelector ? params.noSwipingSelector : `.${params.noSwipingClass}`;
  25750. const isTargetShadow = !!(e.target && e.target.shadowRoot);
  25751. // use closestElement for shadow root element to get the actual closest for nested shadow root element
  25752. if (params.noSwiping && (isTargetShadow ? closestElement(noSwipingSelector, targetEl) : targetEl.closest(noSwipingSelector))) {
  25753. swiper.allowClick = true;
  25754. return;
  25755. }
  25756. if (params.swipeHandler) {
  25757. if (!targetEl.closest(params.swipeHandler)) return;
  25758. }
  25759. touches.currentX = e.pageX;
  25760. touches.currentY = e.pageY;
  25761. const startX = touches.currentX;
  25762. const startY = touches.currentY;
  25763. // Do NOT start if iOS edge swipe is detected. Otherwise iOS app cannot swipe-to-go-back anymore
  25764. if (!preventEdgeSwipe(swiper, e, startX)) {
  25765. return;
  25766. }
  25767. Object.assign(data, {
  25768. isTouched: true,
  25769. isMoved: false,
  25770. allowTouchCallbacks: true,
  25771. isScrolling: undefined,
  25772. startMoving: undefined
  25773. });
  25774. touches.startX = startX;
  25775. touches.startY = startY;
  25776. data.touchStartTime = now();
  25777. swiper.allowClick = true;
  25778. swiper.updateSize();
  25779. swiper.swipeDirection = undefined;
  25780. if (params.threshold > 0) data.allowThresholdMove = false;
  25781. let preventDefault = true;
  25782. if (targetEl.matches(data.focusableElements)) {
  25783. preventDefault = false;
  25784. if (targetEl.nodeName === 'SELECT') {
  25785. data.isTouched = false;
  25786. }
  25787. }
  25788. if (document.activeElement && document.activeElement.matches(data.focusableElements) && document.activeElement !== targetEl && (e.pointerType === 'mouse' || e.pointerType !== 'mouse' && !targetEl.matches(data.focusableElements))) {
  25789. document.activeElement.blur();
  25790. }
  25791. const shouldPreventDefault = preventDefault && swiper.allowTouchMove && params.touchStartPreventDefault;
  25792. if ((params.touchStartForcePreventDefault || shouldPreventDefault) && !targetEl.isContentEditable) {
  25793. e.preventDefault();
  25794. }
  25795. if (params.freeMode && params.freeMode.enabled && swiper.freeMode && swiper.animating && !params.cssMode) {
  25796. swiper.freeMode.onTouchStart();
  25797. }
  25798. swiper.emit('touchStart', e);
  25799. }
  25800. function onTouchMove(event) {
  25801. const document = getDocument();
  25802. const swiper = this;
  25803. const data = swiper.touchEventsData;
  25804. const {
  25805. params,
  25806. touches,
  25807. rtlTranslate: rtl,
  25808. enabled
  25809. } = swiper;
  25810. if (!enabled) return;
  25811. if (!params.simulateTouch && event.pointerType === 'mouse') return;
  25812. let e = event;
  25813. if (e.originalEvent) e = e.originalEvent;
  25814. if (e.type === 'pointermove') {
  25815. if (data.touchId !== null) return; // return from pointer if we use touch
  25816. const id = e.pointerId;
  25817. if (id !== data.pointerId) return;
  25818. }
  25819. let targetTouch;
  25820. if (e.type === 'touchmove') {
  25821. targetTouch = [...e.changedTouches].find(t => t.identifier === data.touchId);
  25822. if (!targetTouch || targetTouch.identifier !== data.touchId) return;
  25823. } else {
  25824. targetTouch = e;
  25825. }
  25826. if (!data.isTouched) {
  25827. if (data.startMoving && data.isScrolling) {
  25828. swiper.emit('touchMoveOpposite', e);
  25829. }
  25830. return;
  25831. }
  25832. const pageX = targetTouch.pageX;
  25833. const pageY = targetTouch.pageY;
  25834. if (e.preventedByNestedSwiper) {
  25835. touches.startX = pageX;
  25836. touches.startY = pageY;
  25837. return;
  25838. }
  25839. if (!swiper.allowTouchMove) {
  25840. if (!e.target.matches(data.focusableElements)) {
  25841. swiper.allowClick = false;
  25842. }
  25843. if (data.isTouched) {
  25844. Object.assign(touches, {
  25845. startX: pageX,
  25846. startY: pageY,
  25847. currentX: pageX,
  25848. currentY: pageY
  25849. });
  25850. data.touchStartTime = now();
  25851. }
  25852. return;
  25853. }
  25854. if (params.touchReleaseOnEdges && !params.loop) {
  25855. if (swiper.isVertical()) {
  25856. // Vertical
  25857. if (pageY < touches.startY && swiper.translate <= swiper.maxTranslate() || pageY > touches.startY && swiper.translate >= swiper.minTranslate()) {
  25858. data.isTouched = false;
  25859. data.isMoved = false;
  25860. return;
  25861. }
  25862. } else if (rtl && (pageX > touches.startX && -swiper.translate <= swiper.maxTranslate() || pageX < touches.startX && -swiper.translate >= swiper.minTranslate())) {
  25863. return;
  25864. } else if (!rtl && (pageX < touches.startX && swiper.translate <= swiper.maxTranslate() || pageX > touches.startX && swiper.translate >= swiper.minTranslate())) {
  25865. return;
  25866. }
  25867. }
  25868. if (document.activeElement && document.activeElement.matches(data.focusableElements) && document.activeElement !== e.target && e.pointerType !== 'mouse') {
  25869. document.activeElement.blur();
  25870. }
  25871. if (document.activeElement) {
  25872. if (e.target === document.activeElement && e.target.matches(data.focusableElements)) {
  25873. data.isMoved = true;
  25874. swiper.allowClick = false;
  25875. return;
  25876. }
  25877. }
  25878. if (data.allowTouchCallbacks) {
  25879. swiper.emit('touchMove', e);
  25880. }
  25881. touches.previousX = touches.currentX;
  25882. touches.previousY = touches.currentY;
  25883. touches.currentX = pageX;
  25884. touches.currentY = pageY;
  25885. const diffX = touches.currentX - touches.startX;
  25886. const diffY = touches.currentY - touches.startY;
  25887. if (swiper.params.threshold && Math.sqrt(diffX ** 2 + diffY ** 2) < swiper.params.threshold) return;
  25888. if (typeof data.isScrolling === 'undefined') {
  25889. let touchAngle;
  25890. if (swiper.isHorizontal() && touches.currentY === touches.startY || swiper.isVertical() && touches.currentX === touches.startX) {
  25891. data.isScrolling = false;
  25892. } else {
  25893. // eslint-disable-next-line
  25894. if (diffX * diffX + diffY * diffY >= 25) {
  25895. touchAngle = Math.atan2(Math.abs(diffY), Math.abs(diffX)) * 180 / Math.PI;
  25896. data.isScrolling = swiper.isHorizontal() ? touchAngle > params.touchAngle : 90 - touchAngle > params.touchAngle;
  25897. }
  25898. }
  25899. }
  25900. if (data.isScrolling) {
  25901. swiper.emit('touchMoveOpposite', e);
  25902. }
  25903. if (typeof data.startMoving === 'undefined') {
  25904. if (touches.currentX !== touches.startX || touches.currentY !== touches.startY) {
  25905. data.startMoving = true;
  25906. }
  25907. }
  25908. if (data.isScrolling || e.type === 'touchmove' && data.preventTouchMoveFromPointerMove) {
  25909. data.isTouched = false;
  25910. return;
  25911. }
  25912. if (!data.startMoving) {
  25913. return;
  25914. }
  25915. swiper.allowClick = false;
  25916. if (!params.cssMode && e.cancelable) {
  25917. e.preventDefault();
  25918. }
  25919. if (params.touchMoveStopPropagation && !params.nested) {
  25920. e.stopPropagation();
  25921. }
  25922. let diff = swiper.isHorizontal() ? diffX : diffY;
  25923. let touchesDiff = swiper.isHorizontal() ? touches.currentX - touches.previousX : touches.currentY - touches.previousY;
  25924. if (params.oneWayMovement) {
  25925. diff = Math.abs(diff) * (rtl ? 1 : -1);
  25926. touchesDiff = Math.abs(touchesDiff) * (rtl ? 1 : -1);
  25927. }
  25928. touches.diff = diff;
  25929. diff *= params.touchRatio;
  25930. if (rtl) {
  25931. diff = -diff;
  25932. touchesDiff = -touchesDiff;
  25933. }
  25934. const prevTouchesDirection = swiper.touchesDirection;
  25935. swiper.swipeDirection = diff > 0 ? 'prev' : 'next';
  25936. swiper.touchesDirection = touchesDiff > 0 ? 'prev' : 'next';
  25937. const isLoop = swiper.params.loop && !params.cssMode;
  25938. const allowLoopFix = swiper.touchesDirection === 'next' && swiper.allowSlideNext || swiper.touchesDirection === 'prev' && swiper.allowSlidePrev;
  25939. if (!data.isMoved) {
  25940. if (isLoop && allowLoopFix) {
  25941. swiper.loopFix({
  25942. direction: swiper.swipeDirection
  25943. });
  25944. }
  25945. data.startTranslate = swiper.getTranslate();
  25946. swiper.setTransition(0);
  25947. if (swiper.animating) {
  25948. const evt = new window.CustomEvent('transitionend', {
  25949. bubbles: true,
  25950. cancelable: true,
  25951. detail: {
  25952. bySwiperTouchMove: true
  25953. }
  25954. });
  25955. swiper.wrapperEl.dispatchEvent(evt);
  25956. }
  25957. data.allowMomentumBounce = false;
  25958. // Grab Cursor
  25959. if (params.grabCursor && (swiper.allowSlideNext === true || swiper.allowSlidePrev === true)) {
  25960. swiper.setGrabCursor(true);
  25961. }
  25962. swiper.emit('sliderFirstMove', e);
  25963. }
  25964. let loopFixed;
  25965. new Date().getTime();
  25966. if (params._loopSwapReset !== false && data.isMoved && data.allowThresholdMove && prevTouchesDirection !== swiper.touchesDirection && isLoop && allowLoopFix && Math.abs(diff) >= 1) {
  25967. Object.assign(touches, {
  25968. startX: pageX,
  25969. startY: pageY,
  25970. currentX: pageX,
  25971. currentY: pageY,
  25972. startTranslate: data.currentTranslate
  25973. });
  25974. data.loopSwapReset = true;
  25975. data.startTranslate = data.currentTranslate;
  25976. return;
  25977. }
  25978. swiper.emit('sliderMove', e);
  25979. data.isMoved = true;
  25980. data.currentTranslate = diff + data.startTranslate;
  25981. let disableParentSwiper = true;
  25982. let resistanceRatio = params.resistanceRatio;
  25983. if (params.touchReleaseOnEdges) {
  25984. resistanceRatio = 0;
  25985. }
  25986. if (diff > 0) {
  25987. if (isLoop && allowLoopFix && !loopFixed && data.allowThresholdMove && data.currentTranslate > (params.centeredSlides ? swiper.minTranslate() - swiper.slidesSizesGrid[swiper.activeIndex + 1] - (params.slidesPerView !== 'auto' && swiper.slides.length - params.slidesPerView >= 2 ? swiper.slidesSizesGrid[swiper.activeIndex + 1] + swiper.params.spaceBetween : 0) - swiper.params.spaceBetween : swiper.minTranslate())) {
  25988. swiper.loopFix({
  25989. direction: 'prev',
  25990. setTranslate: true,
  25991. activeSlideIndex: 0
  25992. });
  25993. }
  25994. if (data.currentTranslate > swiper.minTranslate()) {
  25995. disableParentSwiper = false;
  25996. if (params.resistance) {
  25997. data.currentTranslate = swiper.minTranslate() - 1 + (-swiper.minTranslate() + data.startTranslate + diff) ** resistanceRatio;
  25998. }
  25999. }
  26000. } else if (diff < 0) {
  26001. if (isLoop && allowLoopFix && !loopFixed && data.allowThresholdMove && data.currentTranslate < (params.centeredSlides ? swiper.maxTranslate() + swiper.slidesSizesGrid[swiper.slidesSizesGrid.length - 1] + swiper.params.spaceBetween + (params.slidesPerView !== 'auto' && swiper.slides.length - params.slidesPerView >= 2 ? swiper.slidesSizesGrid[swiper.slidesSizesGrid.length - 1] + swiper.params.spaceBetween : 0) : swiper.maxTranslate())) {
  26002. swiper.loopFix({
  26003. direction: 'next',
  26004. setTranslate: true,
  26005. activeSlideIndex: swiper.slides.length - (params.slidesPerView === 'auto' ? swiper.slidesPerViewDynamic() : Math.ceil(parseFloat(params.slidesPerView, 10)))
  26006. });
  26007. }
  26008. if (data.currentTranslate < swiper.maxTranslate()) {
  26009. disableParentSwiper = false;
  26010. if (params.resistance) {
  26011. data.currentTranslate = swiper.maxTranslate() + 1 - (swiper.maxTranslate() - data.startTranslate - diff) ** resistanceRatio;
  26012. }
  26013. }
  26014. }
  26015. if (disableParentSwiper) {
  26016. e.preventedByNestedSwiper = true;
  26017. }
  26018. // Directions locks
  26019. if (!swiper.allowSlideNext && swiper.swipeDirection === 'next' && data.currentTranslate < data.startTranslate) {
  26020. data.currentTranslate = data.startTranslate;
  26021. }
  26022. if (!swiper.allowSlidePrev && swiper.swipeDirection === 'prev' && data.currentTranslate > data.startTranslate) {
  26023. data.currentTranslate = data.startTranslate;
  26024. }
  26025. if (!swiper.allowSlidePrev && !swiper.allowSlideNext) {
  26026. data.currentTranslate = data.startTranslate;
  26027. }
  26028. // Threshold
  26029. if (params.threshold > 0) {
  26030. if (Math.abs(diff) > params.threshold || data.allowThresholdMove) {
  26031. if (!data.allowThresholdMove) {
  26032. data.allowThresholdMove = true;
  26033. touches.startX = touches.currentX;
  26034. touches.startY = touches.currentY;
  26035. data.currentTranslate = data.startTranslate;
  26036. touches.diff = swiper.isHorizontal() ? touches.currentX - touches.startX : touches.currentY - touches.startY;
  26037. return;
  26038. }
  26039. } else {
  26040. data.currentTranslate = data.startTranslate;
  26041. return;
  26042. }
  26043. }
  26044. if (!params.followFinger || params.cssMode) return;
  26045. // Update active index in free mode
  26046. if (params.freeMode && params.freeMode.enabled && swiper.freeMode || params.watchSlidesProgress) {
  26047. swiper.updateActiveIndex();
  26048. swiper.updateSlidesClasses();
  26049. }
  26050. if (params.freeMode && params.freeMode.enabled && swiper.freeMode) {
  26051. swiper.freeMode.onTouchMove();
  26052. }
  26053. // Update progress
  26054. swiper.updateProgress(data.currentTranslate);
  26055. // Update translate
  26056. swiper.setTranslate(data.currentTranslate);
  26057. }
  26058. function onTouchEnd(event) {
  26059. const swiper = this;
  26060. const data = swiper.touchEventsData;
  26061. let e = event;
  26062. if (e.originalEvent) e = e.originalEvent;
  26063. let targetTouch;
  26064. const isTouchEvent = e.type === 'touchend' || e.type === 'touchcancel';
  26065. if (!isTouchEvent) {
  26066. if (data.touchId !== null) return; // return from pointer if we use touch
  26067. if (e.pointerId !== data.pointerId) return;
  26068. targetTouch = e;
  26069. } else {
  26070. targetTouch = [...e.changedTouches].find(t => t.identifier === data.touchId);
  26071. if (!targetTouch || targetTouch.identifier !== data.touchId) return;
  26072. }
  26073. if (['pointercancel', 'pointerout', 'pointerleave', 'contextmenu'].includes(e.type)) {
  26074. const proceed = ['pointercancel', 'contextmenu'].includes(e.type) && (swiper.browser.isSafari || swiper.browser.isWebView);
  26075. if (!proceed) {
  26076. return;
  26077. }
  26078. }
  26079. data.pointerId = null;
  26080. data.touchId = null;
  26081. const {
  26082. params,
  26083. touches,
  26084. rtlTranslate: rtl,
  26085. slidesGrid,
  26086. enabled
  26087. } = swiper;
  26088. if (!enabled) return;
  26089. if (!params.simulateTouch && e.pointerType === 'mouse') return;
  26090. if (data.allowTouchCallbacks) {
  26091. swiper.emit('touchEnd', e);
  26092. }
  26093. data.allowTouchCallbacks = false;
  26094. if (!data.isTouched) {
  26095. if (data.isMoved && params.grabCursor) {
  26096. swiper.setGrabCursor(false);
  26097. }
  26098. data.isMoved = false;
  26099. data.startMoving = false;
  26100. return;
  26101. }
  26102. // Return Grab Cursor
  26103. if (params.grabCursor && data.isMoved && data.isTouched && (swiper.allowSlideNext === true || swiper.allowSlidePrev === true)) {
  26104. swiper.setGrabCursor(false);
  26105. }
  26106. // Time diff
  26107. const touchEndTime = now();
  26108. const timeDiff = touchEndTime - data.touchStartTime;
  26109. // Tap, doubleTap, Click
  26110. if (swiper.allowClick) {
  26111. const pathTree = e.path || e.composedPath && e.composedPath();
  26112. swiper.updateClickedSlide(pathTree && pathTree[0] || e.target, pathTree);
  26113. swiper.emit('tap click', e);
  26114. if (timeDiff < 300 && touchEndTime - data.lastClickTime < 300) {
  26115. swiper.emit('doubleTap doubleClick', e);
  26116. }
  26117. }
  26118. data.lastClickTime = now();
  26119. nextTick(() => {
  26120. if (!swiper.destroyed) swiper.allowClick = true;
  26121. });
  26122. if (!data.isTouched || !data.isMoved || !swiper.swipeDirection || touches.diff === 0 && !data.loopSwapReset || data.currentTranslate === data.startTranslate && !data.loopSwapReset) {
  26123. data.isTouched = false;
  26124. data.isMoved = false;
  26125. data.startMoving = false;
  26126. return;
  26127. }
  26128. data.isTouched = false;
  26129. data.isMoved = false;
  26130. data.startMoving = false;
  26131. let currentPos;
  26132. if (params.followFinger) {
  26133. currentPos = rtl ? swiper.translate : -swiper.translate;
  26134. } else {
  26135. currentPos = -data.currentTranslate;
  26136. }
  26137. if (params.cssMode) {
  26138. return;
  26139. }
  26140. if (params.freeMode && params.freeMode.enabled) {
  26141. swiper.freeMode.onTouchEnd({
  26142. currentPos
  26143. });
  26144. return;
  26145. }
  26146. // Find current slide
  26147. const swipeToLast = currentPos >= -swiper.maxTranslate() && !swiper.params.loop;
  26148. let stopIndex = 0;
  26149. let groupSize = swiper.slidesSizesGrid[0];
  26150. for (let i = 0; i < slidesGrid.length; i += i < params.slidesPerGroupSkip ? 1 : params.slidesPerGroup) {
  26151. const increment = i < params.slidesPerGroupSkip - 1 ? 1 : params.slidesPerGroup;
  26152. if (typeof slidesGrid[i + increment] !== 'undefined') {
  26153. if (swipeToLast || currentPos >= slidesGrid[i] && currentPos < slidesGrid[i + increment]) {
  26154. stopIndex = i;
  26155. groupSize = slidesGrid[i + increment] - slidesGrid[i];
  26156. }
  26157. } else if (swipeToLast || currentPos >= slidesGrid[i]) {
  26158. stopIndex = i;
  26159. groupSize = slidesGrid[slidesGrid.length - 1] - slidesGrid[slidesGrid.length - 2];
  26160. }
  26161. }
  26162. let rewindFirstIndex = null;
  26163. let rewindLastIndex = null;
  26164. if (params.rewind) {
  26165. if (swiper.isBeginning) {
  26166. rewindLastIndex = params.virtual && params.virtual.enabled && swiper.virtual ? swiper.virtual.slides.length - 1 : swiper.slides.length - 1;
  26167. } else if (swiper.isEnd) {
  26168. rewindFirstIndex = 0;
  26169. }
  26170. }
  26171. // Find current slide size
  26172. const ratio = (currentPos - slidesGrid[stopIndex]) / groupSize;
  26173. const increment = stopIndex < params.slidesPerGroupSkip - 1 ? 1 : params.slidesPerGroup;
  26174. if (timeDiff > params.longSwipesMs) {
  26175. // Long touches
  26176. if (!params.longSwipes) {
  26177. swiper.slideTo(swiper.activeIndex);
  26178. return;
  26179. }
  26180. if (swiper.swipeDirection === 'next') {
  26181. if (ratio >= params.longSwipesRatio) swiper.slideTo(params.rewind && swiper.isEnd ? rewindFirstIndex : stopIndex + increment);else swiper.slideTo(stopIndex);
  26182. }
  26183. if (swiper.swipeDirection === 'prev') {
  26184. if (ratio > 1 - params.longSwipesRatio) {
  26185. swiper.slideTo(stopIndex + increment);
  26186. } else if (rewindLastIndex !== null && ratio < 0 && Math.abs(ratio) > params.longSwipesRatio) {
  26187. swiper.slideTo(rewindLastIndex);
  26188. } else {
  26189. swiper.slideTo(stopIndex);
  26190. }
  26191. }
  26192. } else {
  26193. // Short swipes
  26194. if (!params.shortSwipes) {
  26195. swiper.slideTo(swiper.activeIndex);
  26196. return;
  26197. }
  26198. const isNavButtonTarget = swiper.navigation && (e.target === swiper.navigation.nextEl || e.target === swiper.navigation.prevEl);
  26199. if (!isNavButtonTarget) {
  26200. if (swiper.swipeDirection === 'next') {
  26201. swiper.slideTo(rewindFirstIndex !== null ? rewindFirstIndex : stopIndex + increment);
  26202. }
  26203. if (swiper.swipeDirection === 'prev') {
  26204. swiper.slideTo(rewindLastIndex !== null ? rewindLastIndex : stopIndex);
  26205. }
  26206. } else if (e.target === swiper.navigation.nextEl) {
  26207. swiper.slideTo(stopIndex + increment);
  26208. } else {
  26209. swiper.slideTo(stopIndex);
  26210. }
  26211. }
  26212. }
  26213. function onResize() {
  26214. const swiper = this;
  26215. const {
  26216. params,
  26217. el
  26218. } = swiper;
  26219. if (el && el.offsetWidth === 0) return;
  26220. // Breakpoints
  26221. if (params.breakpoints) {
  26222. swiper.setBreakpoint();
  26223. }
  26224. // Save locks
  26225. const {
  26226. allowSlideNext,
  26227. allowSlidePrev,
  26228. snapGrid
  26229. } = swiper;
  26230. const isVirtual = swiper.virtual && swiper.params.virtual.enabled;
  26231. // Disable locks on resize
  26232. swiper.allowSlideNext = true;
  26233. swiper.allowSlidePrev = true;
  26234. swiper.updateSize();
  26235. swiper.updateSlides();
  26236. swiper.updateSlidesClasses();
  26237. const isVirtualLoop = isVirtual && params.loop;
  26238. if ((params.slidesPerView === 'auto' || params.slidesPerView > 1) && swiper.isEnd && !swiper.isBeginning && !swiper.params.centeredSlides && !isVirtualLoop) {
  26239. swiper.slideTo(swiper.slides.length - 1, 0, false, true);
  26240. } else {
  26241. if (swiper.params.loop && !isVirtual) {
  26242. swiper.slideToLoop(swiper.realIndex, 0, false, true);
  26243. } else {
  26244. swiper.slideTo(swiper.activeIndex, 0, false, true);
  26245. }
  26246. }
  26247. if (swiper.autoplay && swiper.autoplay.running && swiper.autoplay.paused) {
  26248. clearTimeout(swiper.autoplay.resizeTimeout);
  26249. swiper.autoplay.resizeTimeout = setTimeout(() => {
  26250. if (swiper.autoplay && swiper.autoplay.running && swiper.autoplay.paused) {
  26251. swiper.autoplay.resume();
  26252. }
  26253. }, 500);
  26254. }
  26255. // Return locks after resize
  26256. swiper.allowSlidePrev = allowSlidePrev;
  26257. swiper.allowSlideNext = allowSlideNext;
  26258. if (swiper.params.watchOverflow && snapGrid !== swiper.snapGrid) {
  26259. swiper.checkOverflow();
  26260. }
  26261. }
  26262. function onClick(e) {
  26263. const swiper = this;
  26264. if (!swiper.enabled) return;
  26265. if (!swiper.allowClick) {
  26266. if (swiper.params.preventClicks) e.preventDefault();
  26267. if (swiper.params.preventClicksPropagation && swiper.animating) {
  26268. e.stopPropagation();
  26269. e.stopImmediatePropagation();
  26270. }
  26271. }
  26272. }
  26273. function onScroll() {
  26274. const swiper = this;
  26275. const {
  26276. wrapperEl,
  26277. rtlTranslate,
  26278. enabled
  26279. } = swiper;
  26280. if (!enabled) return;
  26281. swiper.previousTranslate = swiper.translate;
  26282. if (swiper.isHorizontal()) {
  26283. swiper.translate = -wrapperEl.scrollLeft;
  26284. } else {
  26285. swiper.translate = -wrapperEl.scrollTop;
  26286. }
  26287. // eslint-disable-next-line
  26288. if (swiper.translate === 0) swiper.translate = 0;
  26289. swiper.updateActiveIndex();
  26290. swiper.updateSlidesClasses();
  26291. let newProgress;
  26292. const translatesDiff = swiper.maxTranslate() - swiper.minTranslate();
  26293. if (translatesDiff === 0) {
  26294. newProgress = 0;
  26295. } else {
  26296. newProgress = (swiper.translate - swiper.minTranslate()) / translatesDiff;
  26297. }
  26298. if (newProgress !== swiper.progress) {
  26299. swiper.updateProgress(rtlTranslate ? -swiper.translate : swiper.translate);
  26300. }
  26301. swiper.emit('setTranslate', swiper.translate, false);
  26302. }
  26303. function onLoad(e) {
  26304. const swiper = this;
  26305. processLazyPreloader(swiper, e.target);
  26306. if (swiper.params.cssMode || swiper.params.slidesPerView !== 'auto' && !swiper.params.autoHeight) {
  26307. return;
  26308. }
  26309. swiper.update();
  26310. }
  26311. function onDocumentTouchStart() {
  26312. const swiper = this;
  26313. if (swiper.documentTouchHandlerProceeded) return;
  26314. swiper.documentTouchHandlerProceeded = true;
  26315. if (swiper.params.touchReleaseOnEdges) {
  26316. swiper.el.style.touchAction = 'auto';
  26317. }
  26318. }
  26319. const events = (swiper, method) => {
  26320. const document = getDocument();
  26321. const {
  26322. params,
  26323. el,
  26324. wrapperEl,
  26325. device
  26326. } = swiper;
  26327. const capture = !!params.nested;
  26328. const domMethod = method === 'on' ? 'addEventListener' : 'removeEventListener';
  26329. const swiperMethod = method;
  26330. if (!el || typeof el === 'string') return;
  26331. // Touch Events
  26332. document[domMethod]('touchstart', swiper.onDocumentTouchStart, {
  26333. passive: false,
  26334. capture
  26335. });
  26336. el[domMethod]('touchstart', swiper.onTouchStart, {
  26337. passive: false
  26338. });
  26339. el[domMethod]('pointerdown', swiper.onTouchStart, {
  26340. passive: false
  26341. });
  26342. document[domMethod]('touchmove', swiper.onTouchMove, {
  26343. passive: false,
  26344. capture
  26345. });
  26346. document[domMethod]('pointermove', swiper.onTouchMove, {
  26347. passive: false,
  26348. capture
  26349. });
  26350. document[domMethod]('touchend', swiper.onTouchEnd, {
  26351. passive: true
  26352. });
  26353. document[domMethod]('pointerup', swiper.onTouchEnd, {
  26354. passive: true
  26355. });
  26356. document[domMethod]('pointercancel', swiper.onTouchEnd, {
  26357. passive: true
  26358. });
  26359. document[domMethod]('touchcancel', swiper.onTouchEnd, {
  26360. passive: true
  26361. });
  26362. document[domMethod]('pointerout', swiper.onTouchEnd, {
  26363. passive: true
  26364. });
  26365. document[domMethod]('pointerleave', swiper.onTouchEnd, {
  26366. passive: true
  26367. });
  26368. document[domMethod]('contextmenu', swiper.onTouchEnd, {
  26369. passive: true
  26370. });
  26371. // Prevent Links Clicks
  26372. if (params.preventClicks || params.preventClicksPropagation) {
  26373. el[domMethod]('click', swiper.onClick, true);
  26374. }
  26375. if (params.cssMode) {
  26376. wrapperEl[domMethod]('scroll', swiper.onScroll);
  26377. }
  26378. // Resize handler
  26379. if (params.updateOnWindowResize) {
  26380. swiper[swiperMethod](device.ios || device.android ? 'resize orientationchange observerUpdate' : 'resize observerUpdate', onResize, true);
  26381. } else {
  26382. swiper[swiperMethod]('observerUpdate', onResize, true);
  26383. }
  26384. // Images loader
  26385. el[domMethod]('load', swiper.onLoad, {
  26386. capture: true
  26387. });
  26388. };
  26389. function attachEvents() {
  26390. const swiper = this;
  26391. const {
  26392. params
  26393. } = swiper;
  26394. swiper.onTouchStart = onTouchStart.bind(swiper);
  26395. swiper.onTouchMove = onTouchMove.bind(swiper);
  26396. swiper.onTouchEnd = onTouchEnd.bind(swiper);
  26397. swiper.onDocumentTouchStart = onDocumentTouchStart.bind(swiper);
  26398. if (params.cssMode) {
  26399. swiper.onScroll = onScroll.bind(swiper);
  26400. }
  26401. swiper.onClick = onClick.bind(swiper);
  26402. swiper.onLoad = onLoad.bind(swiper);
  26403. events(swiper, 'on');
  26404. }
  26405. function detachEvents() {
  26406. const swiper = this;
  26407. events(swiper, 'off');
  26408. }
  26409. var events$1 = {
  26410. attachEvents,
  26411. detachEvents
  26412. };
  26413. const isGridEnabled = (swiper, params) => {
  26414. return swiper.grid && params.grid && params.grid.rows > 1;
  26415. };
  26416. function setBreakpoint() {
  26417. const swiper = this;
  26418. const {
  26419. realIndex,
  26420. initialized,
  26421. params,
  26422. el
  26423. } = swiper;
  26424. const breakpoints = params.breakpoints;
  26425. if (!breakpoints || breakpoints && Object.keys(breakpoints).length === 0) return;
  26426. const document = getDocument();
  26427. // Get breakpoint for window/container width and update parameters
  26428. const breakpointsBase = params.breakpointsBase === 'window' || !params.breakpointsBase ? params.breakpointsBase : 'container';
  26429. const breakpointContainer = ['window', 'container'].includes(params.breakpointsBase) || !params.breakpointsBase ? swiper.el : document.querySelector(params.breakpointsBase);
  26430. const breakpoint = swiper.getBreakpoint(breakpoints, breakpointsBase, breakpointContainer);
  26431. if (!breakpoint || swiper.currentBreakpoint === breakpoint) return;
  26432. const breakpointOnlyParams = breakpoint in breakpoints ? breakpoints[breakpoint] : undefined;
  26433. const breakpointParams = breakpointOnlyParams || swiper.originalParams;
  26434. const wasMultiRow = isGridEnabled(swiper, params);
  26435. const isMultiRow = isGridEnabled(swiper, breakpointParams);
  26436. const wasGrabCursor = swiper.params.grabCursor;
  26437. const isGrabCursor = breakpointParams.grabCursor;
  26438. const wasEnabled = params.enabled;
  26439. if (wasMultiRow && !isMultiRow) {
  26440. el.classList.remove(`${params.containerModifierClass}grid`, `${params.containerModifierClass}grid-column`);
  26441. swiper.emitContainerClasses();
  26442. } else if (!wasMultiRow && isMultiRow) {
  26443. el.classList.add(`${params.containerModifierClass}grid`);
  26444. if (breakpointParams.grid.fill && breakpointParams.grid.fill === 'column' || !breakpointParams.grid.fill && params.grid.fill === 'column') {
  26445. el.classList.add(`${params.containerModifierClass}grid-column`);
  26446. }
  26447. swiper.emitContainerClasses();
  26448. }
  26449. if (wasGrabCursor && !isGrabCursor) {
  26450. swiper.unsetGrabCursor();
  26451. } else if (!wasGrabCursor && isGrabCursor) {
  26452. swiper.setGrabCursor();
  26453. }
  26454. // Toggle navigation, pagination, scrollbar
  26455. ['navigation', 'pagination', 'scrollbar'].forEach(prop => {
  26456. if (typeof breakpointParams[prop] === 'undefined') return;
  26457. const wasModuleEnabled = params[prop] && params[prop].enabled;
  26458. const isModuleEnabled = breakpointParams[prop] && breakpointParams[prop].enabled;
  26459. if (wasModuleEnabled && !isModuleEnabled) {
  26460. swiper[prop].disable();
  26461. }
  26462. if (!wasModuleEnabled && isModuleEnabled) {
  26463. swiper[prop].enable();
  26464. }
  26465. });
  26466. const directionChanged = breakpointParams.direction && breakpointParams.direction !== params.direction;
  26467. const needsReLoop = params.loop && (breakpointParams.slidesPerView !== params.slidesPerView || directionChanged);
  26468. const wasLoop = params.loop;
  26469. if (directionChanged && initialized) {
  26470. swiper.changeDirection();
  26471. }
  26472. extend(swiper.params, breakpointParams);
  26473. const isEnabled = swiper.params.enabled;
  26474. const hasLoop = swiper.params.loop;
  26475. Object.assign(swiper, {
  26476. allowTouchMove: swiper.params.allowTouchMove,
  26477. allowSlideNext: swiper.params.allowSlideNext,
  26478. allowSlidePrev: swiper.params.allowSlidePrev
  26479. });
  26480. if (wasEnabled && !isEnabled) {
  26481. swiper.disable();
  26482. } else if (!wasEnabled && isEnabled) {
  26483. swiper.enable();
  26484. }
  26485. swiper.currentBreakpoint = breakpoint;
  26486. swiper.emit('_beforeBreakpoint', breakpointParams);
  26487. if (initialized) {
  26488. if (needsReLoop) {
  26489. swiper.loopDestroy();
  26490. swiper.loopCreate(realIndex);
  26491. swiper.updateSlides();
  26492. } else if (!wasLoop && hasLoop) {
  26493. swiper.loopCreate(realIndex);
  26494. swiper.updateSlides();
  26495. } else if (wasLoop && !hasLoop) {
  26496. swiper.loopDestroy();
  26497. }
  26498. }
  26499. swiper.emit('breakpoint', breakpointParams);
  26500. }
  26501. function getBreakpoint(breakpoints, base, containerEl) {
  26502. if (base === void 0) {
  26503. base = 'window';
  26504. }
  26505. if (!breakpoints || base === 'container' && !containerEl) return undefined;
  26506. let breakpoint = false;
  26507. const window = getWindow();
  26508. const currentHeight = base === 'window' ? window.innerHeight : containerEl.clientHeight;
  26509. const points = Object.keys(breakpoints).map(point => {
  26510. if (typeof point === 'string' && point.indexOf('@') === 0) {
  26511. const minRatio = parseFloat(point.substr(1));
  26512. const value = currentHeight * minRatio;
  26513. return {
  26514. value,
  26515. point
  26516. };
  26517. }
  26518. return {
  26519. value: point,
  26520. point
  26521. };
  26522. });
  26523. points.sort((a, b) => parseInt(a.value, 10) - parseInt(b.value, 10));
  26524. for (let i = 0; i < points.length; i += 1) {
  26525. const {
  26526. point,
  26527. value
  26528. } = points[i];
  26529. if (base === 'window') {
  26530. if (window.matchMedia(`(min-width: ${value}px)`).matches) {
  26531. breakpoint = point;
  26532. }
  26533. } else if (value <= containerEl.clientWidth) {
  26534. breakpoint = point;
  26535. }
  26536. }
  26537. return breakpoint || 'max';
  26538. }
  26539. var breakpoints = {
  26540. setBreakpoint,
  26541. getBreakpoint
  26542. };
  26543. function prepareClasses(entries, prefix) {
  26544. const resultClasses = [];
  26545. entries.forEach(item => {
  26546. if (typeof item === 'object') {
  26547. Object.keys(item).forEach(classNames => {
  26548. if (item[classNames]) {
  26549. resultClasses.push(prefix + classNames);
  26550. }
  26551. });
  26552. } else if (typeof item === 'string') {
  26553. resultClasses.push(prefix + item);
  26554. }
  26555. });
  26556. return resultClasses;
  26557. }
  26558. function addClasses() {
  26559. const swiper = this;
  26560. const {
  26561. classNames,
  26562. params,
  26563. rtl,
  26564. el,
  26565. device
  26566. } = swiper;
  26567. // prettier-ignore
  26568. const suffixes = prepareClasses(['initialized', params.direction, {
  26569. 'free-mode': swiper.params.freeMode && params.freeMode.enabled
  26570. }, {
  26571. 'autoheight': params.autoHeight
  26572. }, {
  26573. 'rtl': rtl
  26574. }, {
  26575. 'grid': params.grid && params.grid.rows > 1
  26576. }, {
  26577. 'grid-column': params.grid && params.grid.rows > 1 && params.grid.fill === 'column'
  26578. }, {
  26579. 'android': device.android
  26580. }, {
  26581. 'ios': device.ios
  26582. }, {
  26583. 'css-mode': params.cssMode
  26584. }, {
  26585. 'centered': params.cssMode && params.centeredSlides
  26586. }, {
  26587. 'watch-progress': params.watchSlidesProgress
  26588. }], params.containerModifierClass);
  26589. classNames.push(...suffixes);
  26590. el.classList.add(...classNames);
  26591. swiper.emitContainerClasses();
  26592. }
  26593. function removeClasses() {
  26594. const swiper = this;
  26595. const {
  26596. el,
  26597. classNames
  26598. } = swiper;
  26599. if (!el || typeof el === 'string') return;
  26600. el.classList.remove(...classNames);
  26601. swiper.emitContainerClasses();
  26602. }
  26603. var classes = {
  26604. addClasses,
  26605. removeClasses
  26606. };
  26607. function checkOverflow() {
  26608. const swiper = this;
  26609. const {
  26610. isLocked: wasLocked,
  26611. params
  26612. } = swiper;
  26613. const {
  26614. slidesOffsetBefore
  26615. } = params;
  26616. if (slidesOffsetBefore) {
  26617. const lastSlideIndex = swiper.slides.length - 1;
  26618. const lastSlideRightEdge = swiper.slidesGrid[lastSlideIndex] + swiper.slidesSizesGrid[lastSlideIndex] + slidesOffsetBefore * 2;
  26619. swiper.isLocked = swiper.size > lastSlideRightEdge;
  26620. } else {
  26621. swiper.isLocked = swiper.snapGrid.length === 1;
  26622. }
  26623. if (params.allowSlideNext === true) {
  26624. swiper.allowSlideNext = !swiper.isLocked;
  26625. }
  26626. if (params.allowSlidePrev === true) {
  26627. swiper.allowSlidePrev = !swiper.isLocked;
  26628. }
  26629. if (wasLocked && wasLocked !== swiper.isLocked) {
  26630. swiper.isEnd = false;
  26631. }
  26632. if (wasLocked !== swiper.isLocked) {
  26633. swiper.emit(swiper.isLocked ? 'lock' : 'unlock');
  26634. }
  26635. }
  26636. var checkOverflow$1 = {
  26637. checkOverflow
  26638. };
  26639. var defaults = {
  26640. init: true,
  26641. direction: 'horizontal',
  26642. oneWayMovement: false,
  26643. swiperElementNodeName: 'SWIPER-CONTAINER',
  26644. touchEventsTarget: 'wrapper',
  26645. initialSlide: 0,
  26646. speed: 300,
  26647. cssMode: false,
  26648. updateOnWindowResize: true,
  26649. resizeObserver: true,
  26650. nested: false,
  26651. createElements: false,
  26652. eventsPrefix: 'swiper',
  26653. enabled: true,
  26654. focusableElements: 'input, select, option, textarea, button, video, label',
  26655. // Overrides
  26656. width: null,
  26657. height: null,
  26658. //
  26659. preventInteractionOnTransition: false,
  26660. // ssr
  26661. userAgent: null,
  26662. url: null,
  26663. // To support iOS's swipe-to-go-back gesture (when being used in-app).
  26664. edgeSwipeDetection: false,
  26665. edgeSwipeThreshold: 20,
  26666. // Autoheight
  26667. autoHeight: false,
  26668. // Set wrapper width
  26669. setWrapperSize: false,
  26670. // Virtual Translate
  26671. virtualTranslate: false,
  26672. // Effects
  26673. effect: 'slide',
  26674. // 'slide' or 'fade' or 'cube' or 'coverflow' or 'flip'
  26675. // Breakpoints
  26676. breakpoints: undefined,
  26677. breakpointsBase: 'window',
  26678. // Slides grid
  26679. spaceBetween: 0,
  26680. slidesPerView: 1,
  26681. slidesPerGroup: 1,
  26682. slidesPerGroupSkip: 0,
  26683. slidesPerGroupAuto: false,
  26684. centeredSlides: false,
  26685. centeredSlidesBounds: false,
  26686. slidesOffsetBefore: 0,
  26687. // in px
  26688. slidesOffsetAfter: 0,
  26689. // in px
  26690. normalizeSlideIndex: true,
  26691. centerInsufficientSlides: false,
  26692. // Disable swiper and hide navigation when container not overflow
  26693. watchOverflow: true,
  26694. // Round length
  26695. roundLengths: false,
  26696. // Touches
  26697. touchRatio: 1,
  26698. touchAngle: 45,
  26699. simulateTouch: true,
  26700. shortSwipes: true,
  26701. longSwipes: true,
  26702. longSwipesRatio: 0.5,
  26703. longSwipesMs: 300,
  26704. followFinger: true,
  26705. allowTouchMove: true,
  26706. threshold: 5,
  26707. touchMoveStopPropagation: false,
  26708. touchStartPreventDefault: true,
  26709. touchStartForcePreventDefault: false,
  26710. touchReleaseOnEdges: false,
  26711. // Unique Navigation Elements
  26712. uniqueNavElements: true,
  26713. // Resistance
  26714. resistance: true,
  26715. resistanceRatio: 0.85,
  26716. // Progress
  26717. watchSlidesProgress: false,
  26718. // Cursor
  26719. grabCursor: false,
  26720. // Clicks
  26721. preventClicks: true,
  26722. preventClicksPropagation: true,
  26723. slideToClickedSlide: false,
  26724. // loop
  26725. loop: false,
  26726. loopAddBlankSlides: true,
  26727. loopAdditionalSlides: 0,
  26728. loopPreventsSliding: true,
  26729. // rewind
  26730. rewind: false,
  26731. // Swiping/no swiping
  26732. allowSlidePrev: true,
  26733. allowSlideNext: true,
  26734. swipeHandler: null,
  26735. // '.swipe-handler',
  26736. noSwiping: true,
  26737. noSwipingClass: 'swiper-no-swiping',
  26738. noSwipingSelector: null,
  26739. // Passive Listeners
  26740. passiveListeners: true,
  26741. maxBackfaceHiddenSlides: 10,
  26742. // NS
  26743. containerModifierClass: 'swiper-',
  26744. // NEW
  26745. slideClass: 'swiper-slide',
  26746. slideBlankClass: 'swiper-slide-blank',
  26747. slideActiveClass: 'swiper-slide-active',
  26748. slideVisibleClass: 'swiper-slide-visible',
  26749. slideFullyVisibleClass: 'swiper-slide-fully-visible',
  26750. slideNextClass: 'swiper-slide-next',
  26751. slidePrevClass: 'swiper-slide-prev',
  26752. wrapperClass: 'swiper-wrapper',
  26753. lazyPreloaderClass: 'swiper-lazy-preloader',
  26754. lazyPreloadPrevNext: 0,
  26755. // Callbacks
  26756. runCallbacksOnInit: true,
  26757. // Internals
  26758. _emitClasses: false
  26759. };
  26760. function moduleExtendParams(params, allModulesParams) {
  26761. return function extendParams(obj) {
  26762. if (obj === void 0) {
  26763. obj = {};
  26764. }
  26765. const moduleParamName = Object.keys(obj)[0];
  26766. const moduleParams = obj[moduleParamName];
  26767. if (typeof moduleParams !== 'object' || moduleParams === null) {
  26768. extend(allModulesParams, obj);
  26769. return;
  26770. }
  26771. if (params[moduleParamName] === true) {
  26772. params[moduleParamName] = {
  26773. enabled: true
  26774. };
  26775. }
  26776. if (moduleParamName === 'navigation' && params[moduleParamName] && params[moduleParamName].enabled && !params[moduleParamName].prevEl && !params[moduleParamName].nextEl) {
  26777. params[moduleParamName].auto = true;
  26778. }
  26779. if (['pagination', 'scrollbar'].indexOf(moduleParamName) >= 0 && params[moduleParamName] && params[moduleParamName].enabled && !params[moduleParamName].el) {
  26780. params[moduleParamName].auto = true;
  26781. }
  26782. if (!(moduleParamName in params && 'enabled' in moduleParams)) {
  26783. extend(allModulesParams, obj);
  26784. return;
  26785. }
  26786. if (typeof params[moduleParamName] === 'object' && !('enabled' in params[moduleParamName])) {
  26787. params[moduleParamName].enabled = true;
  26788. }
  26789. if (!params[moduleParamName]) params[moduleParamName] = {
  26790. enabled: false
  26791. };
  26792. extend(allModulesParams, obj);
  26793. };
  26794. }
  26795. /* eslint no-param-reassign: "off" */
  26796. const prototypes = {
  26797. eventsEmitter,
  26798. update,
  26799. translate,
  26800. transition,
  26801. slide,
  26802. loop,
  26803. grabCursor,
  26804. events: events$1,
  26805. breakpoints,
  26806. checkOverflow: checkOverflow$1,
  26807. classes
  26808. };
  26809. const extendedDefaults = {};
  26810. class Swiper {
  26811. constructor() {
  26812. let el;
  26813. let params;
  26814. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  26815. args[_key] = arguments[_key];
  26816. }
  26817. if (args.length === 1 && args[0].constructor && Object.prototype.toString.call(args[0]).slice(8, -1) === 'Object') {
  26818. params = args[0];
  26819. } else {
  26820. [el, params] = args;
  26821. }
  26822. if (!params) params = {};
  26823. params = extend({}, params);
  26824. if (el && !params.el) params.el = el;
  26825. const document = getDocument();
  26826. if (params.el && typeof params.el === 'string' && document.querySelectorAll(params.el).length > 1) {
  26827. const swipers = [];
  26828. document.querySelectorAll(params.el).forEach(containerEl => {
  26829. const newParams = extend({}, params, {
  26830. el: containerEl
  26831. });
  26832. swipers.push(new Swiper(newParams));
  26833. });
  26834. // eslint-disable-next-line no-constructor-return
  26835. return swipers;
  26836. }
  26837. // Swiper Instance
  26838. const swiper = this;
  26839. swiper.__swiper__ = true;
  26840. swiper.support = getSupport();
  26841. swiper.device = getDevice({
  26842. userAgent: params.userAgent
  26843. });
  26844. swiper.browser = getBrowser();
  26845. swiper.eventsListeners = {};
  26846. swiper.eventsAnyListeners = [];
  26847. swiper.modules = [...swiper.__modules__];
  26848. if (params.modules && Array.isArray(params.modules)) {
  26849. swiper.modules.push(...params.modules);
  26850. }
  26851. const allModulesParams = {};
  26852. swiper.modules.forEach(mod => {
  26853. mod({
  26854. params,
  26855. swiper,
  26856. extendParams: moduleExtendParams(params, allModulesParams),
  26857. on: swiper.on.bind(swiper),
  26858. once: swiper.once.bind(swiper),
  26859. off: swiper.off.bind(swiper),
  26860. emit: swiper.emit.bind(swiper)
  26861. });
  26862. });
  26863. // Extend defaults with modules params
  26864. const swiperParams = extend({}, defaults, allModulesParams);
  26865. // Extend defaults with passed params
  26866. swiper.params = extend({}, swiperParams, extendedDefaults, params);
  26867. swiper.originalParams = extend({}, swiper.params);
  26868. swiper.passedParams = extend({}, params);
  26869. // add event listeners
  26870. if (swiper.params && swiper.params.on) {
  26871. Object.keys(swiper.params.on).forEach(eventName => {
  26872. swiper.on(eventName, swiper.params.on[eventName]);
  26873. });
  26874. }
  26875. if (swiper.params && swiper.params.onAny) {
  26876. swiper.onAny(swiper.params.onAny);
  26877. }
  26878. // Extend Swiper
  26879. Object.assign(swiper, {
  26880. enabled: swiper.params.enabled,
  26881. el,
  26882. // Classes
  26883. classNames: [],
  26884. // Slides
  26885. slides: [],
  26886. slidesGrid: [],
  26887. snapGrid: [],
  26888. slidesSizesGrid: [],
  26889. // isDirection
  26890. isHorizontal() {
  26891. return swiper.params.direction === 'horizontal';
  26892. },
  26893. isVertical() {
  26894. return swiper.params.direction === 'vertical';
  26895. },
  26896. // Indexes
  26897. activeIndex: 0,
  26898. realIndex: 0,
  26899. //
  26900. isBeginning: true,
  26901. isEnd: false,
  26902. // Props
  26903. translate: 0,
  26904. previousTranslate: 0,
  26905. progress: 0,
  26906. velocity: 0,
  26907. animating: false,
  26908. cssOverflowAdjustment() {
  26909. // Returns 0 unless `translate` is > 2**23
  26910. // Should be subtracted from css values to prevent overflow
  26911. return Math.trunc(this.translate / 2 ** 23) * 2 ** 23;
  26912. },
  26913. // Locks
  26914. allowSlideNext: swiper.params.allowSlideNext,
  26915. allowSlidePrev: swiper.params.allowSlidePrev,
  26916. // Touch Events
  26917. touchEventsData: {
  26918. isTouched: undefined,
  26919. isMoved: undefined,
  26920. allowTouchCallbacks: undefined,
  26921. touchStartTime: undefined,
  26922. isScrolling: undefined,
  26923. currentTranslate: undefined,
  26924. startTranslate: undefined,
  26925. allowThresholdMove: undefined,
  26926. // Form elements to match
  26927. focusableElements: swiper.params.focusableElements,
  26928. // Last click time
  26929. lastClickTime: 0,
  26930. clickTimeout: undefined,
  26931. // Velocities
  26932. velocities: [],
  26933. allowMomentumBounce: undefined,
  26934. startMoving: undefined,
  26935. pointerId: null,
  26936. touchId: null
  26937. },
  26938. // Clicks
  26939. allowClick: true,
  26940. // Touches
  26941. allowTouchMove: swiper.params.allowTouchMove,
  26942. touches: {
  26943. startX: 0,
  26944. startY: 0,
  26945. currentX: 0,
  26946. currentY: 0,
  26947. diff: 0
  26948. },
  26949. // Images
  26950. imagesToLoad: [],
  26951. imagesLoaded: 0
  26952. });
  26953. swiper.emit('_swiper');
  26954. // Init
  26955. if (swiper.params.init) {
  26956. swiper.init();
  26957. }
  26958. // Return app instance
  26959. // eslint-disable-next-line no-constructor-return
  26960. return swiper;
  26961. }
  26962. getDirectionLabel(property) {
  26963. if (this.isHorizontal()) {
  26964. return property;
  26965. }
  26966. // prettier-ignore
  26967. return {
  26968. 'width': 'height',
  26969. 'margin-top': 'margin-left',
  26970. 'margin-bottom ': 'margin-right',
  26971. 'margin-left': 'margin-top',
  26972. 'margin-right': 'margin-bottom',
  26973. 'padding-left': 'padding-top',
  26974. 'padding-right': 'padding-bottom',
  26975. 'marginRight': 'marginBottom'
  26976. }[property];
  26977. }
  26978. getSlideIndex(slideEl) {
  26979. const {
  26980. slidesEl,
  26981. params
  26982. } = this;
  26983. const slides = elementChildren(slidesEl, `.${params.slideClass}, swiper-slide`);
  26984. const firstSlideIndex = elementIndex(slides[0]);
  26985. return elementIndex(slideEl) - firstSlideIndex;
  26986. }
  26987. getSlideIndexByData(index) {
  26988. return this.getSlideIndex(this.slides.find(slideEl => slideEl.getAttribute('data-swiper-slide-index') * 1 === index));
  26989. }
  26990. getSlideIndexWhenGrid(index) {
  26991. if (this.grid && this.params.grid && this.params.grid.rows > 1) {
  26992. if (this.params.grid.fill === 'column') {
  26993. index = Math.floor(index / this.params.grid.rows);
  26994. } else if (this.params.grid.fill === 'row') {
  26995. index = index % Math.ceil(this.slides.length / this.params.grid.rows);
  26996. }
  26997. }
  26998. return index;
  26999. }
  27000. recalcSlides() {
  27001. const swiper = this;
  27002. const {
  27003. slidesEl,
  27004. params
  27005. } = swiper;
  27006. swiper.slides = elementChildren(slidesEl, `.${params.slideClass}, swiper-slide`);
  27007. }
  27008. enable() {
  27009. const swiper = this;
  27010. if (swiper.enabled) return;
  27011. swiper.enabled = true;
  27012. if (swiper.params.grabCursor) {
  27013. swiper.setGrabCursor();
  27014. }
  27015. swiper.emit('enable');
  27016. }
  27017. disable() {
  27018. const swiper = this;
  27019. if (!swiper.enabled) return;
  27020. swiper.enabled = false;
  27021. if (swiper.params.grabCursor) {
  27022. swiper.unsetGrabCursor();
  27023. }
  27024. swiper.emit('disable');
  27025. }
  27026. setProgress(progress, speed) {
  27027. const swiper = this;
  27028. progress = Math.min(Math.max(progress, 0), 1);
  27029. const min = swiper.minTranslate();
  27030. const max = swiper.maxTranslate();
  27031. const current = (max - min) * progress + min;
  27032. swiper.translateTo(current, typeof speed === 'undefined' ? 0 : speed);
  27033. swiper.updateActiveIndex();
  27034. swiper.updateSlidesClasses();
  27035. }
  27036. emitContainerClasses() {
  27037. const swiper = this;
  27038. if (!swiper.params._emitClasses || !swiper.el) return;
  27039. const cls = swiper.el.className.split(' ').filter(className => {
  27040. return className.indexOf('swiper') === 0 || className.indexOf(swiper.params.containerModifierClass) === 0;
  27041. });
  27042. swiper.emit('_containerClasses', cls.join(' '));
  27043. }
  27044. getSlideClasses(slideEl) {
  27045. const swiper = this;
  27046. if (swiper.destroyed) return '';
  27047. return slideEl.className.split(' ').filter(className => {
  27048. return className.indexOf('swiper-slide') === 0 || className.indexOf(swiper.params.slideClass) === 0;
  27049. }).join(' ');
  27050. }
  27051. emitSlidesClasses() {
  27052. const swiper = this;
  27053. if (!swiper.params._emitClasses || !swiper.el) return;
  27054. const updates = [];
  27055. swiper.slides.forEach(slideEl => {
  27056. const classNames = swiper.getSlideClasses(slideEl);
  27057. updates.push({
  27058. slideEl,
  27059. classNames
  27060. });
  27061. swiper.emit('_slideClass', slideEl, classNames);
  27062. });
  27063. swiper.emit('_slideClasses', updates);
  27064. }
  27065. slidesPerViewDynamic(view, exact) {
  27066. if (view === void 0) {
  27067. view = 'current';
  27068. }
  27069. if (exact === void 0) {
  27070. exact = false;
  27071. }
  27072. const swiper = this;
  27073. const {
  27074. params,
  27075. slides,
  27076. slidesGrid,
  27077. slidesSizesGrid,
  27078. size: swiperSize,
  27079. activeIndex
  27080. } = swiper;
  27081. let spv = 1;
  27082. if (typeof params.slidesPerView === 'number') return params.slidesPerView;
  27083. if (params.centeredSlides) {
  27084. let slideSize = slides[activeIndex] ? Math.ceil(slides[activeIndex].swiperSlideSize) : 0;
  27085. let breakLoop;
  27086. for (let i = activeIndex + 1; i < slides.length; i += 1) {
  27087. if (slides[i] && !breakLoop) {
  27088. slideSize += Math.ceil(slides[i].swiperSlideSize);
  27089. spv += 1;
  27090. if (slideSize > swiperSize) breakLoop = true;
  27091. }
  27092. }
  27093. for (let i = activeIndex - 1; i >= 0; i -= 1) {
  27094. if (slides[i] && !breakLoop) {
  27095. slideSize += slides[i].swiperSlideSize;
  27096. spv += 1;
  27097. if (slideSize > swiperSize) breakLoop = true;
  27098. }
  27099. }
  27100. } else {
  27101. // eslint-disable-next-line
  27102. if (view === 'current') {
  27103. for (let i = activeIndex + 1; i < slides.length; i += 1) {
  27104. const slideInView = exact ? slidesGrid[i] + slidesSizesGrid[i] - slidesGrid[activeIndex] < swiperSize : slidesGrid[i] - slidesGrid[activeIndex] < swiperSize;
  27105. if (slideInView) {
  27106. spv += 1;
  27107. }
  27108. }
  27109. } else {
  27110. // previous
  27111. for (let i = activeIndex - 1; i >= 0; i -= 1) {
  27112. const slideInView = slidesGrid[activeIndex] - slidesGrid[i] < swiperSize;
  27113. if (slideInView) {
  27114. spv += 1;
  27115. }
  27116. }
  27117. }
  27118. }
  27119. return spv;
  27120. }
  27121. update() {
  27122. const swiper = this;
  27123. if (!swiper || swiper.destroyed) return;
  27124. const {
  27125. snapGrid,
  27126. params
  27127. } = swiper;
  27128. // Breakpoints
  27129. if (params.breakpoints) {
  27130. swiper.setBreakpoint();
  27131. }
  27132. [...swiper.el.querySelectorAll('[loading="lazy"]')].forEach(imageEl => {
  27133. if (imageEl.complete) {
  27134. processLazyPreloader(swiper, imageEl);
  27135. }
  27136. });
  27137. swiper.updateSize();
  27138. swiper.updateSlides();
  27139. swiper.updateProgress();
  27140. swiper.updateSlidesClasses();
  27141. function setTranslate() {
  27142. const translateValue = swiper.rtlTranslate ? swiper.translate * -1 : swiper.translate;
  27143. const newTranslate = Math.min(Math.max(translateValue, swiper.maxTranslate()), swiper.minTranslate());
  27144. swiper.setTranslate(newTranslate);
  27145. swiper.updateActiveIndex();
  27146. swiper.updateSlidesClasses();
  27147. }
  27148. let translated;
  27149. if (params.freeMode && params.freeMode.enabled && !params.cssMode) {
  27150. setTranslate();
  27151. if (params.autoHeight) {
  27152. swiper.updateAutoHeight();
  27153. }
  27154. } else {
  27155. if ((params.slidesPerView === 'auto' || params.slidesPerView > 1) && swiper.isEnd && !params.centeredSlides) {
  27156. const slides = swiper.virtual && params.virtual.enabled ? swiper.virtual.slides : swiper.slides;
  27157. translated = swiper.slideTo(slides.length - 1, 0, false, true);
  27158. } else {
  27159. translated = swiper.slideTo(swiper.activeIndex, 0, false, true);
  27160. }
  27161. if (!translated) {
  27162. setTranslate();
  27163. }
  27164. }
  27165. if (params.watchOverflow && snapGrid !== swiper.snapGrid) {
  27166. swiper.checkOverflow();
  27167. }
  27168. swiper.emit('update');
  27169. }
  27170. changeDirection(newDirection, needUpdate) {
  27171. if (needUpdate === void 0) {
  27172. needUpdate = true;
  27173. }
  27174. const swiper = this;
  27175. const currentDirection = swiper.params.direction;
  27176. if (!newDirection) {
  27177. // eslint-disable-next-line
  27178. newDirection = currentDirection === 'horizontal' ? 'vertical' : 'horizontal';
  27179. }
  27180. if (newDirection === currentDirection || newDirection !== 'horizontal' && newDirection !== 'vertical') {
  27181. return swiper;
  27182. }
  27183. swiper.el.classList.remove(`${swiper.params.containerModifierClass}${currentDirection}`);
  27184. swiper.el.classList.add(`${swiper.params.containerModifierClass}${newDirection}`);
  27185. swiper.emitContainerClasses();
  27186. swiper.params.direction = newDirection;
  27187. swiper.slides.forEach(slideEl => {
  27188. if (newDirection === 'vertical') {
  27189. slideEl.style.width = '';
  27190. } else {
  27191. slideEl.style.height = '';
  27192. }
  27193. });
  27194. swiper.emit('changeDirection');
  27195. if (needUpdate) swiper.update();
  27196. return swiper;
  27197. }
  27198. changeLanguageDirection(direction) {
  27199. const swiper = this;
  27200. if (swiper.rtl && direction === 'rtl' || !swiper.rtl && direction === 'ltr') return;
  27201. swiper.rtl = direction === 'rtl';
  27202. swiper.rtlTranslate = swiper.params.direction === 'horizontal' && swiper.rtl;
  27203. if (swiper.rtl) {
  27204. swiper.el.classList.add(`${swiper.params.containerModifierClass}rtl`);
  27205. swiper.el.dir = 'rtl';
  27206. } else {
  27207. swiper.el.classList.remove(`${swiper.params.containerModifierClass}rtl`);
  27208. swiper.el.dir = 'ltr';
  27209. }
  27210. swiper.update();
  27211. }
  27212. mount(element) {
  27213. const swiper = this;
  27214. if (swiper.mounted) return true;
  27215. // Find el
  27216. let el = element || swiper.params.el;
  27217. if (typeof el === 'string') {
  27218. el = document.querySelector(el);
  27219. }
  27220. if (!el) {
  27221. return false;
  27222. }
  27223. el.swiper = swiper;
  27224. if (el.parentNode && el.parentNode.host && el.parentNode.host.nodeName === swiper.params.swiperElementNodeName.toUpperCase()) {
  27225. swiper.isElement = true;
  27226. }
  27227. const getWrapperSelector = () => {
  27228. return `.${(swiper.params.wrapperClass || '').trim().split(' ').join('.')}`;
  27229. };
  27230. const getWrapper = () => {
  27231. if (el && el.shadowRoot && el.shadowRoot.querySelector) {
  27232. const res = el.shadowRoot.querySelector(getWrapperSelector());
  27233. // Children needs to return slot items
  27234. return res;
  27235. }
  27236. return elementChildren(el, getWrapperSelector())[0];
  27237. };
  27238. // Find Wrapper
  27239. let wrapperEl = getWrapper();
  27240. if (!wrapperEl && swiper.params.createElements) {
  27241. wrapperEl = createElement('div', swiper.params.wrapperClass);
  27242. el.append(wrapperEl);
  27243. elementChildren(el, `.${swiper.params.slideClass}`).forEach(slideEl => {
  27244. wrapperEl.append(slideEl);
  27245. });
  27246. }
  27247. Object.assign(swiper, {
  27248. el,
  27249. wrapperEl,
  27250. slidesEl: swiper.isElement && !el.parentNode.host.slideSlots ? el.parentNode.host : wrapperEl,
  27251. hostEl: swiper.isElement ? el.parentNode.host : el,
  27252. mounted: true,
  27253. // RTL
  27254. rtl: el.dir.toLowerCase() === 'rtl' || elementStyle(el, 'direction') === 'rtl',
  27255. rtlTranslate: swiper.params.direction === 'horizontal' && (el.dir.toLowerCase() === 'rtl' || elementStyle(el, 'direction') === 'rtl'),
  27256. wrongRTL: elementStyle(wrapperEl, 'display') === '-webkit-box'
  27257. });
  27258. return true;
  27259. }
  27260. init(el) {
  27261. const swiper = this;
  27262. if (swiper.initialized) return swiper;
  27263. const mounted = swiper.mount(el);
  27264. if (mounted === false) return swiper;
  27265. swiper.emit('beforeInit');
  27266. // Set breakpoint
  27267. if (swiper.params.breakpoints) {
  27268. swiper.setBreakpoint();
  27269. }
  27270. // Add Classes
  27271. swiper.addClasses();
  27272. // Update size
  27273. swiper.updateSize();
  27274. // Update slides
  27275. swiper.updateSlides();
  27276. if (swiper.params.watchOverflow) {
  27277. swiper.checkOverflow();
  27278. }
  27279. // Set Grab Cursor
  27280. if (swiper.params.grabCursor && swiper.enabled) {
  27281. swiper.setGrabCursor();
  27282. }
  27283. // Slide To Initial Slide
  27284. if (swiper.params.loop && swiper.virtual && swiper.params.virtual.enabled) {
  27285. swiper.slideTo(swiper.params.initialSlide + swiper.virtual.slidesBefore, 0, swiper.params.runCallbacksOnInit, false, true);
  27286. } else {
  27287. swiper.slideTo(swiper.params.initialSlide, 0, swiper.params.runCallbacksOnInit, false, true);
  27288. }
  27289. // Create loop
  27290. if (swiper.params.loop) {
  27291. swiper.loopCreate(undefined, true);
  27292. }
  27293. // Attach events
  27294. swiper.attachEvents();
  27295. const lazyElements = [...swiper.el.querySelectorAll('[loading="lazy"]')];
  27296. if (swiper.isElement) {
  27297. lazyElements.push(...swiper.hostEl.querySelectorAll('[loading="lazy"]'));
  27298. }
  27299. lazyElements.forEach(imageEl => {
  27300. if (imageEl.complete) {
  27301. processLazyPreloader(swiper, imageEl);
  27302. } else {
  27303. imageEl.addEventListener('load', e => {
  27304. processLazyPreloader(swiper, e.target);
  27305. });
  27306. }
  27307. });
  27308. preload(swiper);
  27309. // Init Flag
  27310. swiper.initialized = true;
  27311. preload(swiper);
  27312. // Emit
  27313. swiper.emit('init');
  27314. swiper.emit('afterInit');
  27315. return swiper;
  27316. }
  27317. destroy(deleteInstance, cleanStyles) {
  27318. if (deleteInstance === void 0) {
  27319. deleteInstance = true;
  27320. }
  27321. if (cleanStyles === void 0) {
  27322. cleanStyles = true;
  27323. }
  27324. const swiper = this;
  27325. const {
  27326. params,
  27327. el,
  27328. wrapperEl,
  27329. slides
  27330. } = swiper;
  27331. if (typeof swiper.params === 'undefined' || swiper.destroyed) {
  27332. return null;
  27333. }
  27334. swiper.emit('beforeDestroy');
  27335. // Init Flag
  27336. swiper.initialized = false;
  27337. // Detach events
  27338. swiper.detachEvents();
  27339. // Destroy loop
  27340. if (params.loop) {
  27341. swiper.loopDestroy();
  27342. }
  27343. // Cleanup styles
  27344. if (cleanStyles) {
  27345. swiper.removeClasses();
  27346. if (el && typeof el !== 'string') {
  27347. el.removeAttribute('style');
  27348. }
  27349. if (wrapperEl) {
  27350. wrapperEl.removeAttribute('style');
  27351. }
  27352. if (slides && slides.length) {
  27353. slides.forEach(slideEl => {
  27354. slideEl.classList.remove(params.slideVisibleClass, params.slideFullyVisibleClass, params.slideActiveClass, params.slideNextClass, params.slidePrevClass);
  27355. slideEl.removeAttribute('style');
  27356. slideEl.removeAttribute('data-swiper-slide-index');
  27357. });
  27358. }
  27359. }
  27360. swiper.emit('destroy');
  27361. // Detach emitter events
  27362. Object.keys(swiper.eventsListeners).forEach(eventName => {
  27363. swiper.off(eventName);
  27364. });
  27365. if (deleteInstance !== false) {
  27366. if (swiper.el && typeof swiper.el !== 'string') {
  27367. swiper.el.swiper = null;
  27368. }
  27369. deleteProps(swiper);
  27370. }
  27371. swiper.destroyed = true;
  27372. return null;
  27373. }
  27374. static extendDefaults(newDefaults) {
  27375. extend(extendedDefaults, newDefaults);
  27376. }
  27377. static get extendedDefaults() {
  27378. return extendedDefaults;
  27379. }
  27380. static get defaults() {
  27381. return defaults;
  27382. }
  27383. static installModule(mod) {
  27384. if (!Swiper.prototype.__modules__) Swiper.prototype.__modules__ = [];
  27385. const modules = Swiper.prototype.__modules__;
  27386. if (typeof mod === 'function' && modules.indexOf(mod) < 0) {
  27387. modules.push(mod);
  27388. }
  27389. }
  27390. static use(module) {
  27391. if (Array.isArray(module)) {
  27392. module.forEach(m => Swiper.installModule(m));
  27393. return Swiper;
  27394. }
  27395. Swiper.installModule(module);
  27396. return Swiper;
  27397. }
  27398. }
  27399. Object.keys(prototypes).forEach(prototypeGroup => {
  27400. Object.keys(prototypes[prototypeGroup]).forEach(protoMethod => {
  27401. Swiper.prototype[protoMethod] = prototypes[prototypeGroup][protoMethod];
  27402. });
  27403. });
  27404. Swiper.use([Resize, Observer]);
  27405. function Virtual(_ref) {
  27406. let {
  27407. swiper,
  27408. extendParams,
  27409. on,
  27410. emit
  27411. } = _ref;
  27412. extendParams({
  27413. virtual: {
  27414. enabled: false,
  27415. slides: [],
  27416. cache: true,
  27417. renderSlide: null,
  27418. renderExternal: null,
  27419. renderExternalUpdate: true,
  27420. addSlidesBefore: 0,
  27421. addSlidesAfter: 0
  27422. }
  27423. });
  27424. let cssModeTimeout;
  27425. const document = getDocument();
  27426. swiper.virtual = {
  27427. cache: {},
  27428. from: undefined,
  27429. to: undefined,
  27430. slides: [],
  27431. offset: 0,
  27432. slidesGrid: []
  27433. };
  27434. const tempDOM = document.createElement('div');
  27435. function renderSlide(slide, index) {
  27436. const params = swiper.params.virtual;
  27437. if (params.cache && swiper.virtual.cache[index]) {
  27438. return swiper.virtual.cache[index];
  27439. }
  27440. // eslint-disable-next-line
  27441. let slideEl;
  27442. if (params.renderSlide) {
  27443. slideEl = params.renderSlide.call(swiper, slide, index);
  27444. if (typeof slideEl === 'string') {
  27445. setInnerHTML(tempDOM, slideEl);
  27446. slideEl = tempDOM.children[0];
  27447. }
  27448. } else if (swiper.isElement) {
  27449. slideEl = createElement('swiper-slide');
  27450. } else {
  27451. slideEl = createElement('div', swiper.params.slideClass);
  27452. }
  27453. slideEl.setAttribute('data-swiper-slide-index', index);
  27454. if (!params.renderSlide) {
  27455. setInnerHTML(slideEl, slide);
  27456. }
  27457. if (params.cache) {
  27458. swiper.virtual.cache[index] = slideEl;
  27459. }
  27460. return slideEl;
  27461. }
  27462. function update(force, beforeInit, forceActiveIndex) {
  27463. const {
  27464. slidesPerView,
  27465. slidesPerGroup,
  27466. centeredSlides,
  27467. loop: isLoop,
  27468. initialSlide
  27469. } = swiper.params;
  27470. if (beforeInit && !isLoop && initialSlide > 0) {
  27471. return;
  27472. }
  27473. const {
  27474. addSlidesBefore,
  27475. addSlidesAfter
  27476. } = swiper.params.virtual;
  27477. const {
  27478. from: previousFrom,
  27479. to: previousTo,
  27480. slides,
  27481. slidesGrid: previousSlidesGrid,
  27482. offset: previousOffset
  27483. } = swiper.virtual;
  27484. if (!swiper.params.cssMode) {
  27485. swiper.updateActiveIndex();
  27486. }
  27487. const activeIndex = typeof forceActiveIndex === 'undefined' ? swiper.activeIndex || 0 : forceActiveIndex;
  27488. let offsetProp;
  27489. if (swiper.rtlTranslate) offsetProp = 'right';else offsetProp = swiper.isHorizontal() ? 'left' : 'top';
  27490. let slidesAfter;
  27491. let slidesBefore;
  27492. if (centeredSlides) {
  27493. slidesAfter = Math.floor(slidesPerView / 2) + slidesPerGroup + addSlidesAfter;
  27494. slidesBefore = Math.floor(slidesPerView / 2) + slidesPerGroup + addSlidesBefore;
  27495. } else {
  27496. slidesAfter = slidesPerView + (slidesPerGroup - 1) + addSlidesAfter;
  27497. slidesBefore = (isLoop ? slidesPerView : slidesPerGroup) + addSlidesBefore;
  27498. }
  27499. let from = activeIndex - slidesBefore;
  27500. let to = activeIndex + slidesAfter;
  27501. if (!isLoop) {
  27502. from = Math.max(from, 0);
  27503. to = Math.min(to, slides.length - 1);
  27504. }
  27505. let offset = (swiper.slidesGrid[from] || 0) - (swiper.slidesGrid[0] || 0);
  27506. if (isLoop && activeIndex >= slidesBefore) {
  27507. from -= slidesBefore;
  27508. if (!centeredSlides) offset += swiper.slidesGrid[0];
  27509. } else if (isLoop && activeIndex < slidesBefore) {
  27510. from = -slidesBefore;
  27511. if (centeredSlides) offset += swiper.slidesGrid[0];
  27512. }
  27513. Object.assign(swiper.virtual, {
  27514. from,
  27515. to,
  27516. offset,
  27517. slidesGrid: swiper.slidesGrid,
  27518. slidesBefore,
  27519. slidesAfter
  27520. });
  27521. function onRendered() {
  27522. swiper.updateSlides();
  27523. swiper.updateProgress();
  27524. swiper.updateSlidesClasses();
  27525. emit('virtualUpdate');
  27526. }
  27527. if (previousFrom === from && previousTo === to && !force) {
  27528. if (swiper.slidesGrid !== previousSlidesGrid && offset !== previousOffset) {
  27529. swiper.slides.forEach(slideEl => {
  27530. slideEl.style[offsetProp] = `${offset - Math.abs(swiper.cssOverflowAdjustment())}px`;
  27531. });
  27532. }
  27533. swiper.updateProgress();
  27534. emit('virtualUpdate');
  27535. return;
  27536. }
  27537. if (swiper.params.virtual.renderExternal) {
  27538. swiper.params.virtual.renderExternal.call(swiper, {
  27539. offset,
  27540. from,
  27541. to,
  27542. slides: function getSlides() {
  27543. const slidesToRender = [];
  27544. for (let i = from; i <= to; i += 1) {
  27545. slidesToRender.push(slides[i]);
  27546. }
  27547. return slidesToRender;
  27548. }()
  27549. });
  27550. if (swiper.params.virtual.renderExternalUpdate) {
  27551. onRendered();
  27552. } else {
  27553. emit('virtualUpdate');
  27554. }
  27555. return;
  27556. }
  27557. const prependIndexes = [];
  27558. const appendIndexes = [];
  27559. const getSlideIndex = index => {
  27560. let slideIndex = index;
  27561. if (index < 0) {
  27562. slideIndex = slides.length + index;
  27563. } else if (slideIndex >= slides.length) {
  27564. // eslint-disable-next-line
  27565. slideIndex = slideIndex - slides.length;
  27566. }
  27567. return slideIndex;
  27568. };
  27569. if (force) {
  27570. swiper.slides.filter(el => el.matches(`.${swiper.params.slideClass}, swiper-slide`)).forEach(slideEl => {
  27571. slideEl.remove();
  27572. });
  27573. } else {
  27574. for (let i = previousFrom; i <= previousTo; i += 1) {
  27575. if (i < from || i > to) {
  27576. const slideIndex = getSlideIndex(i);
  27577. swiper.slides.filter(el => el.matches(`.${swiper.params.slideClass}[data-swiper-slide-index="${slideIndex}"], swiper-slide[data-swiper-slide-index="${slideIndex}"]`)).forEach(slideEl => {
  27578. slideEl.remove();
  27579. });
  27580. }
  27581. }
  27582. }
  27583. const loopFrom = isLoop ? -slides.length : 0;
  27584. const loopTo = isLoop ? slides.length * 2 : slides.length;
  27585. for (let i = loopFrom; i < loopTo; i += 1) {
  27586. if (i >= from && i <= to) {
  27587. const slideIndex = getSlideIndex(i);
  27588. if (typeof previousTo === 'undefined' || force) {
  27589. appendIndexes.push(slideIndex);
  27590. } else {
  27591. if (i > previousTo) appendIndexes.push(slideIndex);
  27592. if (i < previousFrom) prependIndexes.push(slideIndex);
  27593. }
  27594. }
  27595. }
  27596. appendIndexes.forEach(index => {
  27597. swiper.slidesEl.append(renderSlide(slides[index], index));
  27598. });
  27599. if (isLoop) {
  27600. for (let i = prependIndexes.length - 1; i >= 0; i -= 1) {
  27601. const index = prependIndexes[i];
  27602. swiper.slidesEl.prepend(renderSlide(slides[index], index));
  27603. }
  27604. } else {
  27605. prependIndexes.sort((a, b) => b - a);
  27606. prependIndexes.forEach(index => {
  27607. swiper.slidesEl.prepend(renderSlide(slides[index], index));
  27608. });
  27609. }
  27610. elementChildren(swiper.slidesEl, '.swiper-slide, swiper-slide').forEach(slideEl => {
  27611. slideEl.style[offsetProp] = `${offset - Math.abs(swiper.cssOverflowAdjustment())}px`;
  27612. });
  27613. onRendered();
  27614. }
  27615. function appendSlide(slides) {
  27616. if (typeof slides === 'object' && 'length' in slides) {
  27617. for (let i = 0; i < slides.length; i += 1) {
  27618. if (slides[i]) swiper.virtual.slides.push(slides[i]);
  27619. }
  27620. } else {
  27621. swiper.virtual.slides.push(slides);
  27622. }
  27623. update(true);
  27624. }
  27625. function prependSlide(slides) {
  27626. const activeIndex = swiper.activeIndex;
  27627. let newActiveIndex = activeIndex + 1;
  27628. let numberOfNewSlides = 1;
  27629. if (Array.isArray(slides)) {
  27630. for (let i = 0; i < slides.length; i += 1) {
  27631. if (slides[i]) swiper.virtual.slides.unshift(slides[i]);
  27632. }
  27633. newActiveIndex = activeIndex + slides.length;
  27634. numberOfNewSlides = slides.length;
  27635. } else {
  27636. swiper.virtual.slides.unshift(slides);
  27637. }
  27638. if (swiper.params.virtual.cache) {
  27639. const cache = swiper.virtual.cache;
  27640. const newCache = {};
  27641. Object.keys(cache).forEach(cachedIndex => {
  27642. const cachedEl = cache[cachedIndex];
  27643. const cachedElIndex = cachedEl.getAttribute('data-swiper-slide-index');
  27644. if (cachedElIndex) {
  27645. cachedEl.setAttribute('data-swiper-slide-index', parseInt(cachedElIndex, 10) + numberOfNewSlides);
  27646. }
  27647. newCache[parseInt(cachedIndex, 10) + numberOfNewSlides] = cachedEl;
  27648. });
  27649. swiper.virtual.cache = newCache;
  27650. }
  27651. update(true);
  27652. swiper.slideTo(newActiveIndex, 0);
  27653. }
  27654. function removeSlide(slidesIndexes) {
  27655. if (typeof slidesIndexes === 'undefined' || slidesIndexes === null) return;
  27656. let activeIndex = swiper.activeIndex;
  27657. if (Array.isArray(slidesIndexes)) {
  27658. for (let i = slidesIndexes.length - 1; i >= 0; i -= 1) {
  27659. if (swiper.params.virtual.cache) {
  27660. delete swiper.virtual.cache[slidesIndexes[i]];
  27661. // shift cache indexes
  27662. Object.keys(swiper.virtual.cache).forEach(key => {
  27663. if (key > slidesIndexes) {
  27664. swiper.virtual.cache[key - 1] = swiper.virtual.cache[key];
  27665. swiper.virtual.cache[key - 1].setAttribute('data-swiper-slide-index', key - 1);
  27666. delete swiper.virtual.cache[key];
  27667. }
  27668. });
  27669. }
  27670. swiper.virtual.slides.splice(slidesIndexes[i], 1);
  27671. if (slidesIndexes[i] < activeIndex) activeIndex -= 1;
  27672. activeIndex = Math.max(activeIndex, 0);
  27673. }
  27674. } else {
  27675. if (swiper.params.virtual.cache) {
  27676. delete swiper.virtual.cache[slidesIndexes];
  27677. // shift cache indexes
  27678. Object.keys(swiper.virtual.cache).forEach(key => {
  27679. if (key > slidesIndexes) {
  27680. swiper.virtual.cache[key - 1] = swiper.virtual.cache[key];
  27681. swiper.virtual.cache[key - 1].setAttribute('data-swiper-slide-index', key - 1);
  27682. delete swiper.virtual.cache[key];
  27683. }
  27684. });
  27685. }
  27686. swiper.virtual.slides.splice(slidesIndexes, 1);
  27687. if (slidesIndexes < activeIndex) activeIndex -= 1;
  27688. activeIndex = Math.max(activeIndex, 0);
  27689. }
  27690. update(true);
  27691. swiper.slideTo(activeIndex, 0);
  27692. }
  27693. function removeAllSlides() {
  27694. swiper.virtual.slides = [];
  27695. if (swiper.params.virtual.cache) {
  27696. swiper.virtual.cache = {};
  27697. }
  27698. update(true);
  27699. swiper.slideTo(0, 0);
  27700. }
  27701. on('beforeInit', () => {
  27702. if (!swiper.params.virtual.enabled) return;
  27703. let domSlidesAssigned;
  27704. if (typeof swiper.passedParams.virtual.slides === 'undefined') {
  27705. const slides = [...swiper.slidesEl.children].filter(el => el.matches(`.${swiper.params.slideClass}, swiper-slide`));
  27706. if (slides && slides.length) {
  27707. swiper.virtual.slides = [...slides];
  27708. domSlidesAssigned = true;
  27709. slides.forEach((slideEl, slideIndex) => {
  27710. slideEl.setAttribute('data-swiper-slide-index', slideIndex);
  27711. swiper.virtual.cache[slideIndex] = slideEl;
  27712. slideEl.remove();
  27713. });
  27714. }
  27715. }
  27716. if (!domSlidesAssigned) {
  27717. swiper.virtual.slides = swiper.params.virtual.slides;
  27718. }
  27719. swiper.classNames.push(`${swiper.params.containerModifierClass}virtual`);
  27720. swiper.params.watchSlidesProgress = true;
  27721. swiper.originalParams.watchSlidesProgress = true;
  27722. update(false, true);
  27723. });
  27724. on('setTranslate', () => {
  27725. if (!swiper.params.virtual.enabled) return;
  27726. if (swiper.params.cssMode && !swiper._immediateVirtual) {
  27727. clearTimeout(cssModeTimeout);
  27728. cssModeTimeout = setTimeout(() => {
  27729. update();
  27730. }, 100);
  27731. } else {
  27732. update();
  27733. }
  27734. });
  27735. on('init update resize', () => {
  27736. if (!swiper.params.virtual.enabled) return;
  27737. if (swiper.params.cssMode) {
  27738. setCSSProperty(swiper.wrapperEl, '--swiper-virtual-size', `${swiper.virtualSize}px`);
  27739. }
  27740. });
  27741. Object.assign(swiper.virtual, {
  27742. appendSlide,
  27743. prependSlide,
  27744. removeSlide,
  27745. removeAllSlides,
  27746. update
  27747. });
  27748. }
  27749. /* eslint-disable consistent-return */
  27750. function Keyboard(_ref) {
  27751. let {
  27752. swiper,
  27753. extendParams,
  27754. on,
  27755. emit
  27756. } = _ref;
  27757. const document = getDocument();
  27758. const window = getWindow();
  27759. swiper.keyboard = {
  27760. enabled: false
  27761. };
  27762. extendParams({
  27763. keyboard: {
  27764. enabled: false,
  27765. onlyInViewport: true,
  27766. pageUpDown: true
  27767. }
  27768. });
  27769. function handle(event) {
  27770. if (!swiper.enabled) return;
  27771. const {
  27772. rtlTranslate: rtl
  27773. } = swiper;
  27774. let e = event;
  27775. if (e.originalEvent) e = e.originalEvent; // jquery fix
  27776. const kc = e.keyCode || e.charCode;
  27777. const pageUpDown = swiper.params.keyboard.pageUpDown;
  27778. const isPageUp = pageUpDown && kc === 33;
  27779. const isPageDown = pageUpDown && kc === 34;
  27780. const isArrowLeft = kc === 37;
  27781. const isArrowRight = kc === 39;
  27782. const isArrowUp = kc === 38;
  27783. const isArrowDown = kc === 40;
  27784. // Directions locks
  27785. if (!swiper.allowSlideNext && (swiper.isHorizontal() && isArrowRight || swiper.isVertical() && isArrowDown || isPageDown)) {
  27786. return false;
  27787. }
  27788. if (!swiper.allowSlidePrev && (swiper.isHorizontal() && isArrowLeft || swiper.isVertical() && isArrowUp || isPageUp)) {
  27789. return false;
  27790. }
  27791. if (e.shiftKey || e.altKey || e.ctrlKey || e.metaKey) {
  27792. return undefined;
  27793. }
  27794. if (document.activeElement && (document.activeElement.isContentEditable || document.activeElement.nodeName && (document.activeElement.nodeName.toLowerCase() === 'input' || document.activeElement.nodeName.toLowerCase() === 'textarea'))) {
  27795. return undefined;
  27796. }
  27797. if (swiper.params.keyboard.onlyInViewport && (isPageUp || isPageDown || isArrowLeft || isArrowRight || isArrowUp || isArrowDown)) {
  27798. let inView = false;
  27799. // Check that swiper should be inside of visible area of window
  27800. if (elementParents(swiper.el, `.${swiper.params.slideClass}, swiper-slide`).length > 0 && elementParents(swiper.el, `.${swiper.params.slideActiveClass}`).length === 0) {
  27801. return undefined;
  27802. }
  27803. const el = swiper.el;
  27804. const swiperWidth = el.clientWidth;
  27805. const swiperHeight = el.clientHeight;
  27806. const windowWidth = window.innerWidth;
  27807. const windowHeight = window.innerHeight;
  27808. const swiperOffset = elementOffset(el);
  27809. if (rtl) swiperOffset.left -= el.scrollLeft;
  27810. const swiperCoord = [[swiperOffset.left, swiperOffset.top], [swiperOffset.left + swiperWidth, swiperOffset.top], [swiperOffset.left, swiperOffset.top + swiperHeight], [swiperOffset.left + swiperWidth, swiperOffset.top + swiperHeight]];
  27811. for (let i = 0; i < swiperCoord.length; i += 1) {
  27812. const point = swiperCoord[i];
  27813. if (point[0] >= 0 && point[0] <= windowWidth && point[1] >= 0 && point[1] <= windowHeight) {
  27814. if (point[0] === 0 && point[1] === 0) continue; // eslint-disable-line
  27815. inView = true;
  27816. }
  27817. }
  27818. if (!inView) return undefined;
  27819. }
  27820. if (swiper.isHorizontal()) {
  27821. if (isPageUp || isPageDown || isArrowLeft || isArrowRight) {
  27822. if (e.preventDefault) e.preventDefault();else e.returnValue = false;
  27823. }
  27824. if ((isPageDown || isArrowRight) && !rtl || (isPageUp || isArrowLeft) && rtl) swiper.slideNext();
  27825. if ((isPageUp || isArrowLeft) && !rtl || (isPageDown || isArrowRight) && rtl) swiper.slidePrev();
  27826. } else {
  27827. if (isPageUp || isPageDown || isArrowUp || isArrowDown) {
  27828. if (e.preventDefault) e.preventDefault();else e.returnValue = false;
  27829. }
  27830. if (isPageDown || isArrowDown) swiper.slideNext();
  27831. if (isPageUp || isArrowUp) swiper.slidePrev();
  27832. }
  27833. emit('keyPress', kc);
  27834. return undefined;
  27835. }
  27836. function enable() {
  27837. if (swiper.keyboard.enabled) return;
  27838. document.addEventListener('keydown', handle);
  27839. swiper.keyboard.enabled = true;
  27840. }
  27841. function disable() {
  27842. if (!swiper.keyboard.enabled) return;
  27843. document.removeEventListener('keydown', handle);
  27844. swiper.keyboard.enabled = false;
  27845. }
  27846. on('init', () => {
  27847. if (swiper.params.keyboard.enabled) {
  27848. enable();
  27849. }
  27850. });
  27851. on('destroy', () => {
  27852. if (swiper.keyboard.enabled) {
  27853. disable();
  27854. }
  27855. });
  27856. Object.assign(swiper.keyboard, {
  27857. enable,
  27858. disable
  27859. });
  27860. }
  27861. /* eslint-disable consistent-return */
  27862. function Mousewheel(_ref) {
  27863. let {
  27864. swiper,
  27865. extendParams,
  27866. on,
  27867. emit
  27868. } = _ref;
  27869. const window = getWindow();
  27870. extendParams({
  27871. mousewheel: {
  27872. enabled: false,
  27873. releaseOnEdges: false,
  27874. invert: false,
  27875. forceToAxis: false,
  27876. sensitivity: 1,
  27877. eventsTarget: 'container',
  27878. thresholdDelta: null,
  27879. thresholdTime: null,
  27880. noMousewheelClass: 'swiper-no-mousewheel'
  27881. }
  27882. });
  27883. swiper.mousewheel = {
  27884. enabled: false
  27885. };
  27886. let timeout;
  27887. let lastScrollTime = now();
  27888. let lastEventBeforeSnap;
  27889. const recentWheelEvents = [];
  27890. function normalize(e) {
  27891. // Reasonable defaults
  27892. const PIXEL_STEP = 10;
  27893. const LINE_HEIGHT = 40;
  27894. const PAGE_HEIGHT = 800;
  27895. let sX = 0;
  27896. let sY = 0; // spinX, spinY
  27897. let pX = 0;
  27898. let pY = 0; // pixelX, pixelY
  27899. // Legacy
  27900. if ('detail' in e) {
  27901. sY = e.detail;
  27902. }
  27903. if ('wheelDelta' in e) {
  27904. sY = -e.wheelDelta / 120;
  27905. }
  27906. if ('wheelDeltaY' in e) {
  27907. sY = -e.wheelDeltaY / 120;
  27908. }
  27909. if ('wheelDeltaX' in e) {
  27910. sX = -e.wheelDeltaX / 120;
  27911. }
  27912. // side scrolling on FF with DOMMouseScroll
  27913. if ('axis' in e && e.axis === e.HORIZONTAL_AXIS) {
  27914. sX = sY;
  27915. sY = 0;
  27916. }
  27917. pX = sX * PIXEL_STEP;
  27918. pY = sY * PIXEL_STEP;
  27919. if ('deltaY' in e) {
  27920. pY = e.deltaY;
  27921. }
  27922. if ('deltaX' in e) {
  27923. pX = e.deltaX;
  27924. }
  27925. if (e.shiftKey && !pX) {
  27926. // if user scrolls with shift he wants horizontal scroll
  27927. pX = pY;
  27928. pY = 0;
  27929. }
  27930. if ((pX || pY) && e.deltaMode) {
  27931. if (e.deltaMode === 1) {
  27932. // delta in LINE units
  27933. pX *= LINE_HEIGHT;
  27934. pY *= LINE_HEIGHT;
  27935. } else {
  27936. // delta in PAGE units
  27937. pX *= PAGE_HEIGHT;
  27938. pY *= PAGE_HEIGHT;
  27939. }
  27940. }
  27941. // Fall-back if spin cannot be determined
  27942. if (pX && !sX) {
  27943. sX = pX < 1 ? -1 : 1;
  27944. }
  27945. if (pY && !sY) {
  27946. sY = pY < 1 ? -1 : 1;
  27947. }
  27948. return {
  27949. spinX: sX,
  27950. spinY: sY,
  27951. pixelX: pX,
  27952. pixelY: pY
  27953. };
  27954. }
  27955. function handleMouseEnter() {
  27956. if (!swiper.enabled) return;
  27957. swiper.mouseEntered = true;
  27958. }
  27959. function handleMouseLeave() {
  27960. if (!swiper.enabled) return;
  27961. swiper.mouseEntered = false;
  27962. }
  27963. function animateSlider(newEvent) {
  27964. if (swiper.params.mousewheel.thresholdDelta && newEvent.delta < swiper.params.mousewheel.thresholdDelta) {
  27965. // Prevent if delta of wheel scroll delta is below configured threshold
  27966. return false;
  27967. }
  27968. if (swiper.params.mousewheel.thresholdTime && now() - lastScrollTime < swiper.params.mousewheel.thresholdTime) {
  27969. // Prevent if time between scrolls is below configured threshold
  27970. return false;
  27971. }
  27972. // If the movement is NOT big enough and
  27973. // if the last time the user scrolled was too close to the current one (avoid continuously triggering the slider):
  27974. // Don't go any further (avoid insignificant scroll movement).
  27975. if (newEvent.delta >= 6 && now() - lastScrollTime < 60) {
  27976. // Return false as a default
  27977. return true;
  27978. }
  27979. // If user is scrolling towards the end:
  27980. // If the slider hasn't hit the latest slide or
  27981. // if the slider is a loop and
  27982. // if the slider isn't moving right now:
  27983. // Go to next slide and
  27984. // emit a scroll event.
  27985. // Else (the user is scrolling towards the beginning) and
  27986. // if the slider hasn't hit the first slide or
  27987. // if the slider is a loop and
  27988. // if the slider isn't moving right now:
  27989. // Go to prev slide and
  27990. // emit a scroll event.
  27991. if (newEvent.direction < 0) {
  27992. if ((!swiper.isEnd || swiper.params.loop) && !swiper.animating) {
  27993. swiper.slideNext();
  27994. emit('scroll', newEvent.raw);
  27995. }
  27996. } else if ((!swiper.isBeginning || swiper.params.loop) && !swiper.animating) {
  27997. swiper.slidePrev();
  27998. emit('scroll', newEvent.raw);
  27999. }
  28000. // If you got here is because an animation has been triggered so store the current time
  28001. lastScrollTime = new window.Date().getTime();
  28002. // Return false as a default
  28003. return false;
  28004. }
  28005. function releaseScroll(newEvent) {
  28006. const params = swiper.params.mousewheel;
  28007. if (newEvent.direction < 0) {
  28008. if (swiper.isEnd && !swiper.params.loop && params.releaseOnEdges) {
  28009. // Return true to animate scroll on edges
  28010. return true;
  28011. }
  28012. } else if (swiper.isBeginning && !swiper.params.loop && params.releaseOnEdges) {
  28013. // Return true to animate scroll on edges
  28014. return true;
  28015. }
  28016. return false;
  28017. }
  28018. function handle(event) {
  28019. let e = event;
  28020. let disableParentSwiper = true;
  28021. if (!swiper.enabled) return;
  28022. // Ignore event if the target or its parents have the swiper-no-mousewheel class
  28023. if (event.target.closest(`.${swiper.params.mousewheel.noMousewheelClass}`)) return;
  28024. const params = swiper.params.mousewheel;
  28025. if (swiper.params.cssMode) {
  28026. e.preventDefault();
  28027. }
  28028. let targetEl = swiper.el;
  28029. if (swiper.params.mousewheel.eventsTarget !== 'container') {
  28030. targetEl = document.querySelector(swiper.params.mousewheel.eventsTarget);
  28031. }
  28032. const targetElContainsTarget = targetEl && targetEl.contains(e.target);
  28033. if (!swiper.mouseEntered && !targetElContainsTarget && !params.releaseOnEdges) return true;
  28034. if (e.originalEvent) e = e.originalEvent; // jquery fix
  28035. let delta = 0;
  28036. const rtlFactor = swiper.rtlTranslate ? -1 : 1;
  28037. const data = normalize(e);
  28038. if (params.forceToAxis) {
  28039. if (swiper.isHorizontal()) {
  28040. if (Math.abs(data.pixelX) > Math.abs(data.pixelY)) delta = -data.pixelX * rtlFactor;else return true;
  28041. } else if (Math.abs(data.pixelY) > Math.abs(data.pixelX)) delta = -data.pixelY;else return true;
  28042. } else {
  28043. delta = Math.abs(data.pixelX) > Math.abs(data.pixelY) ? -data.pixelX * rtlFactor : -data.pixelY;
  28044. }
  28045. if (delta === 0) return true;
  28046. if (params.invert) delta = -delta;
  28047. // Get the scroll positions
  28048. let positions = swiper.getTranslate() + delta * params.sensitivity;
  28049. if (positions >= swiper.minTranslate()) positions = swiper.minTranslate();
  28050. if (positions <= swiper.maxTranslate()) positions = swiper.maxTranslate();
  28051. // When loop is true:
  28052. // the disableParentSwiper will be true.
  28053. // When loop is false:
  28054. // if the scroll positions is not on edge,
  28055. // then the disableParentSwiper will be true.
  28056. // if the scroll on edge positions,
  28057. // then the disableParentSwiper will be false.
  28058. disableParentSwiper = swiper.params.loop ? true : !(positions === swiper.minTranslate() || positions === swiper.maxTranslate());
  28059. if (disableParentSwiper && swiper.params.nested) e.stopPropagation();
  28060. if (!swiper.params.freeMode || !swiper.params.freeMode.enabled) {
  28061. // Register the new event in a variable which stores the relevant data
  28062. const newEvent = {
  28063. time: now(),
  28064. delta: Math.abs(delta),
  28065. direction: Math.sign(delta),
  28066. raw: event
  28067. };
  28068. // Keep the most recent events
  28069. if (recentWheelEvents.length >= 2) {
  28070. recentWheelEvents.shift(); // only store the last N events
  28071. }
  28072. const prevEvent = recentWheelEvents.length ? recentWheelEvents[recentWheelEvents.length - 1] : undefined;
  28073. recentWheelEvents.push(newEvent);
  28074. // If there is at least one previous recorded event:
  28075. // If direction has changed or
  28076. // if the scroll is quicker than the previous one:
  28077. // Animate the slider.
  28078. // Else (this is the first time the wheel is moved):
  28079. // Animate the slider.
  28080. if (prevEvent) {
  28081. if (newEvent.direction !== prevEvent.direction || newEvent.delta > prevEvent.delta || newEvent.time > prevEvent.time + 150) {
  28082. animateSlider(newEvent);
  28083. }
  28084. } else {
  28085. animateSlider(newEvent);
  28086. }
  28087. // If it's time to release the scroll:
  28088. // Return now so you don't hit the preventDefault.
  28089. if (releaseScroll(newEvent)) {
  28090. return true;
  28091. }
  28092. } else {
  28093. // Freemode or scrollContainer:
  28094. // If we recently snapped after a momentum scroll, then ignore wheel events
  28095. // to give time for the deceleration to finish. Stop ignoring after 500 msecs
  28096. // or if it's a new scroll (larger delta or inverse sign as last event before
  28097. // an end-of-momentum snap).
  28098. const newEvent = {
  28099. time: now(),
  28100. delta: Math.abs(delta),
  28101. direction: Math.sign(delta)
  28102. };
  28103. const ignoreWheelEvents = lastEventBeforeSnap && newEvent.time < lastEventBeforeSnap.time + 500 && newEvent.delta <= lastEventBeforeSnap.delta && newEvent.direction === lastEventBeforeSnap.direction;
  28104. if (!ignoreWheelEvents) {
  28105. lastEventBeforeSnap = undefined;
  28106. let position = swiper.getTranslate() + delta * params.sensitivity;
  28107. const wasBeginning = swiper.isBeginning;
  28108. const wasEnd = swiper.isEnd;
  28109. if (position >= swiper.minTranslate()) position = swiper.minTranslate();
  28110. if (position <= swiper.maxTranslate()) position = swiper.maxTranslate();
  28111. swiper.setTransition(0);
  28112. swiper.setTranslate(position);
  28113. swiper.updateProgress();
  28114. swiper.updateActiveIndex();
  28115. swiper.updateSlidesClasses();
  28116. if (!wasBeginning && swiper.isBeginning || !wasEnd && swiper.isEnd) {
  28117. swiper.updateSlidesClasses();
  28118. }
  28119. if (swiper.params.loop) {
  28120. swiper.loopFix({
  28121. direction: newEvent.direction < 0 ? 'next' : 'prev',
  28122. byMousewheel: true
  28123. });
  28124. }
  28125. if (swiper.params.freeMode.sticky) {
  28126. // When wheel scrolling starts with sticky (aka snap) enabled, then detect
  28127. // the end of a momentum scroll by storing recent (N=15?) wheel events.
  28128. // 1. do all N events have decreasing or same (absolute value) delta?
  28129. // 2. did all N events arrive in the last M (M=500?) msecs?
  28130. // 3. does the earliest event have an (absolute value) delta that's
  28131. // at least P (P=1?) larger than the most recent event's delta?
  28132. // 4. does the latest event have a delta that's smaller than Q (Q=6?) pixels?
  28133. // If 1-4 are "yes" then we're near the end of a momentum scroll deceleration.
  28134. // Snap immediately and ignore remaining wheel events in this scroll.
  28135. // See comment above for "remaining wheel events in this scroll" determination.
  28136. // If 1-4 aren't satisfied, then wait to snap until 500ms after the last event.
  28137. clearTimeout(timeout);
  28138. timeout = undefined;
  28139. if (recentWheelEvents.length >= 15) {
  28140. recentWheelEvents.shift(); // only store the last N events
  28141. }
  28142. const prevEvent = recentWheelEvents.length ? recentWheelEvents[recentWheelEvents.length - 1] : undefined;
  28143. const firstEvent = recentWheelEvents[0];
  28144. recentWheelEvents.push(newEvent);
  28145. if (prevEvent && (newEvent.delta > prevEvent.delta || newEvent.direction !== prevEvent.direction)) {
  28146. // Increasing or reverse-sign delta means the user started scrolling again. Clear the wheel event log.
  28147. recentWheelEvents.splice(0);
  28148. } else if (recentWheelEvents.length >= 15 && newEvent.time - firstEvent.time < 500 && firstEvent.delta - newEvent.delta >= 1 && newEvent.delta <= 6) {
  28149. // We're at the end of the deceleration of a momentum scroll, so there's no need
  28150. // to wait for more events. Snap ASAP on the next tick.
  28151. // Also, because there's some remaining momentum we'll bias the snap in the
  28152. // direction of the ongoing scroll because it's better UX for the scroll to snap
  28153. // in the same direction as the scroll instead of reversing to snap. Therefore,
  28154. // if it's already scrolled more than 20% in the current direction, keep going.
  28155. const snapToThreshold = delta > 0 ? 0.8 : 0.2;
  28156. lastEventBeforeSnap = newEvent;
  28157. recentWheelEvents.splice(0);
  28158. timeout = nextTick(() => {
  28159. if (swiper.destroyed || !swiper.params) return;
  28160. swiper.slideToClosest(swiper.params.speed, true, undefined, snapToThreshold);
  28161. }, 0); // no delay; move on next tick
  28162. }
  28163. if (!timeout) {
  28164. // if we get here, then we haven't detected the end of a momentum scroll, so
  28165. // we'll consider a scroll "complete" when there haven't been any wheel events
  28166. // for 500ms.
  28167. timeout = nextTick(() => {
  28168. if (swiper.destroyed || !swiper.params) return;
  28169. const snapToThreshold = 0.5;
  28170. lastEventBeforeSnap = newEvent;
  28171. recentWheelEvents.splice(0);
  28172. swiper.slideToClosest(swiper.params.speed, true, undefined, snapToThreshold);
  28173. }, 500);
  28174. }
  28175. }
  28176. // Emit event
  28177. if (!ignoreWheelEvents) emit('scroll', e);
  28178. // Stop autoplay
  28179. if (swiper.params.autoplay && swiper.params.autoplay.disableOnInteraction) swiper.autoplay.stop();
  28180. // Return page scroll on edge positions
  28181. if (params.releaseOnEdges && (position === swiper.minTranslate() || position === swiper.maxTranslate())) {
  28182. return true;
  28183. }
  28184. }
  28185. }
  28186. if (e.preventDefault) e.preventDefault();else e.returnValue = false;
  28187. return false;
  28188. }
  28189. function events(method) {
  28190. let targetEl = swiper.el;
  28191. if (swiper.params.mousewheel.eventsTarget !== 'container') {
  28192. targetEl = document.querySelector(swiper.params.mousewheel.eventsTarget);
  28193. }
  28194. targetEl[method]('mouseenter', handleMouseEnter);
  28195. targetEl[method]('mouseleave', handleMouseLeave);
  28196. targetEl[method]('wheel', handle);
  28197. }
  28198. function enable() {
  28199. if (swiper.params.cssMode) {
  28200. swiper.wrapperEl.removeEventListener('wheel', handle);
  28201. return true;
  28202. }
  28203. if (swiper.mousewheel.enabled) return false;
  28204. events('addEventListener');
  28205. swiper.mousewheel.enabled = true;
  28206. return true;
  28207. }
  28208. function disable() {
  28209. if (swiper.params.cssMode) {
  28210. swiper.wrapperEl.addEventListener(event, handle);
  28211. return true;
  28212. }
  28213. if (!swiper.mousewheel.enabled) return false;
  28214. events('removeEventListener');
  28215. swiper.mousewheel.enabled = false;
  28216. return true;
  28217. }
  28218. on('init', () => {
  28219. if (!swiper.params.mousewheel.enabled && swiper.params.cssMode) {
  28220. disable();
  28221. }
  28222. if (swiper.params.mousewheel.enabled) enable();
  28223. });
  28224. on('destroy', () => {
  28225. if (swiper.params.cssMode) {
  28226. enable();
  28227. }
  28228. if (swiper.mousewheel.enabled) disable();
  28229. });
  28230. Object.assign(swiper.mousewheel, {
  28231. enable,
  28232. disable
  28233. });
  28234. }
  28235. function createElementIfNotDefined(swiper, originalParams, params, checkProps) {
  28236. if (swiper.params.createElements) {
  28237. Object.keys(checkProps).forEach(key => {
  28238. if (!params[key] && params.auto === true) {
  28239. let element = elementChildren(swiper.el, `.${checkProps[key]}`)[0];
  28240. if (!element) {
  28241. element = createElement('div', checkProps[key]);
  28242. element.className = checkProps[key];
  28243. swiper.el.append(element);
  28244. }
  28245. params[key] = element;
  28246. originalParams[key] = element;
  28247. }
  28248. });
  28249. }
  28250. return params;
  28251. }
  28252. function Navigation(_ref) {
  28253. let {
  28254. swiper,
  28255. extendParams,
  28256. on,
  28257. emit
  28258. } = _ref;
  28259. extendParams({
  28260. navigation: {
  28261. nextEl: null,
  28262. prevEl: null,
  28263. hideOnClick: false,
  28264. disabledClass: 'swiper-button-disabled',
  28265. hiddenClass: 'swiper-button-hidden',
  28266. lockClass: 'swiper-button-lock',
  28267. navigationDisabledClass: 'swiper-navigation-disabled'
  28268. }
  28269. });
  28270. swiper.navigation = {
  28271. nextEl: null,
  28272. prevEl: null
  28273. };
  28274. function getEl(el) {
  28275. let res;
  28276. if (el && typeof el === 'string' && swiper.isElement) {
  28277. res = swiper.el.querySelector(el) || swiper.hostEl.querySelector(el);
  28278. if (res) return res;
  28279. }
  28280. if (el) {
  28281. if (typeof el === 'string') res = [...document.querySelectorAll(el)];
  28282. if (swiper.params.uniqueNavElements && typeof el === 'string' && res && res.length > 1 && swiper.el.querySelectorAll(el).length === 1) {
  28283. res = swiper.el.querySelector(el);
  28284. } else if (res && res.length === 1) {
  28285. res = res[0];
  28286. }
  28287. }
  28288. if (el && !res) return el;
  28289. // if (Array.isArray(res) && res.length === 1) res = res[0];
  28290. return res;
  28291. }
  28292. function toggleEl(el, disabled) {
  28293. const params = swiper.params.navigation;
  28294. el = makeElementsArray(el);
  28295. el.forEach(subEl => {
  28296. if (subEl) {
  28297. subEl.classList[disabled ? 'add' : 'remove'](...params.disabledClass.split(' '));
  28298. if (subEl.tagName === 'BUTTON') subEl.disabled = disabled;
  28299. if (swiper.params.watchOverflow && swiper.enabled) {
  28300. subEl.classList[swiper.isLocked ? 'add' : 'remove'](params.lockClass);
  28301. }
  28302. }
  28303. });
  28304. }
  28305. function update() {
  28306. // Update Navigation Buttons
  28307. const {
  28308. nextEl,
  28309. prevEl
  28310. } = swiper.navigation;
  28311. if (swiper.params.loop) {
  28312. toggleEl(prevEl, false);
  28313. toggleEl(nextEl, false);
  28314. return;
  28315. }
  28316. toggleEl(prevEl, swiper.isBeginning && !swiper.params.rewind);
  28317. toggleEl(nextEl, swiper.isEnd && !swiper.params.rewind);
  28318. }
  28319. function onPrevClick(e) {
  28320. e.preventDefault();
  28321. if (swiper.isBeginning && !swiper.params.loop && !swiper.params.rewind) return;
  28322. swiper.slidePrev();
  28323. emit('navigationPrev');
  28324. }
  28325. function onNextClick(e) {
  28326. e.preventDefault();
  28327. if (swiper.isEnd && !swiper.params.loop && !swiper.params.rewind) return;
  28328. swiper.slideNext();
  28329. emit('navigationNext');
  28330. }
  28331. function init() {
  28332. const params = swiper.params.navigation;
  28333. swiper.params.navigation = createElementIfNotDefined(swiper, swiper.originalParams.navigation, swiper.params.navigation, {
  28334. nextEl: 'swiper-button-next',
  28335. prevEl: 'swiper-button-prev'
  28336. });
  28337. if (!(params.nextEl || params.prevEl)) return;
  28338. let nextEl = getEl(params.nextEl);
  28339. let prevEl = getEl(params.prevEl);
  28340. Object.assign(swiper.navigation, {
  28341. nextEl,
  28342. prevEl
  28343. });
  28344. nextEl = makeElementsArray(nextEl);
  28345. prevEl = makeElementsArray(prevEl);
  28346. const initButton = (el, dir) => {
  28347. if (el) {
  28348. el.addEventListener('click', dir === 'next' ? onNextClick : onPrevClick);
  28349. }
  28350. if (!swiper.enabled && el) {
  28351. el.classList.add(...params.lockClass.split(' '));
  28352. }
  28353. };
  28354. nextEl.forEach(el => initButton(el, 'next'));
  28355. prevEl.forEach(el => initButton(el, 'prev'));
  28356. }
  28357. function destroy() {
  28358. let {
  28359. nextEl,
  28360. prevEl
  28361. } = swiper.navigation;
  28362. nextEl = makeElementsArray(nextEl);
  28363. prevEl = makeElementsArray(prevEl);
  28364. const destroyButton = (el, dir) => {
  28365. el.removeEventListener('click', dir === 'next' ? onNextClick : onPrevClick);
  28366. el.classList.remove(...swiper.params.navigation.disabledClass.split(' '));
  28367. };
  28368. nextEl.forEach(el => destroyButton(el, 'next'));
  28369. prevEl.forEach(el => destroyButton(el, 'prev'));
  28370. }
  28371. on('init', () => {
  28372. if (swiper.params.navigation.enabled === false) {
  28373. // eslint-disable-next-line
  28374. disable();
  28375. } else {
  28376. init();
  28377. update();
  28378. }
  28379. });
  28380. on('toEdge fromEdge lock unlock', () => {
  28381. update();
  28382. });
  28383. on('destroy', () => {
  28384. destroy();
  28385. });
  28386. on('enable disable', () => {
  28387. let {
  28388. nextEl,
  28389. prevEl
  28390. } = swiper.navigation;
  28391. nextEl = makeElementsArray(nextEl);
  28392. prevEl = makeElementsArray(prevEl);
  28393. if (swiper.enabled) {
  28394. update();
  28395. return;
  28396. }
  28397. [...nextEl, ...prevEl].filter(el => !!el).forEach(el => el.classList.add(swiper.params.navigation.lockClass));
  28398. });
  28399. on('click', (_s, e) => {
  28400. let {
  28401. nextEl,
  28402. prevEl
  28403. } = swiper.navigation;
  28404. nextEl = makeElementsArray(nextEl);
  28405. prevEl = makeElementsArray(prevEl);
  28406. const targetEl = e.target;
  28407. let targetIsButton = prevEl.includes(targetEl) || nextEl.includes(targetEl);
  28408. if (swiper.isElement && !targetIsButton) {
  28409. const path = e.path || e.composedPath && e.composedPath();
  28410. if (path) {
  28411. targetIsButton = path.find(pathEl => nextEl.includes(pathEl) || prevEl.includes(pathEl));
  28412. }
  28413. }
  28414. if (swiper.params.navigation.hideOnClick && !targetIsButton) {
  28415. if (swiper.pagination && swiper.params.pagination && swiper.params.pagination.clickable && (swiper.pagination.el === targetEl || swiper.pagination.el.contains(targetEl))) return;
  28416. let isHidden;
  28417. if (nextEl.length) {
  28418. isHidden = nextEl[0].classList.contains(swiper.params.navigation.hiddenClass);
  28419. } else if (prevEl.length) {
  28420. isHidden = prevEl[0].classList.contains(swiper.params.navigation.hiddenClass);
  28421. }
  28422. if (isHidden === true) {
  28423. emit('navigationShow');
  28424. } else {
  28425. emit('navigationHide');
  28426. }
  28427. [...nextEl, ...prevEl].filter(el => !!el).forEach(el => el.classList.toggle(swiper.params.navigation.hiddenClass));
  28428. }
  28429. });
  28430. const enable = () => {
  28431. swiper.el.classList.remove(...swiper.params.navigation.navigationDisabledClass.split(' '));
  28432. init();
  28433. update();
  28434. };
  28435. const disable = () => {
  28436. swiper.el.classList.add(...swiper.params.navigation.navigationDisabledClass.split(' '));
  28437. destroy();
  28438. };
  28439. Object.assign(swiper.navigation, {
  28440. enable,
  28441. disable,
  28442. update,
  28443. init,
  28444. destroy
  28445. });
  28446. }
  28447. function classesToSelector(classes) {
  28448. if (classes === void 0) {
  28449. classes = '';
  28450. }
  28451. return `.${classes.trim().replace(/([\.:!+\/()[\]])/g, '\\$1') // eslint-disable-line
  28452. .replace(/ /g, '.')}`;
  28453. }
  28454. function Pagination(_ref) {
  28455. let {
  28456. swiper,
  28457. extendParams,
  28458. on,
  28459. emit
  28460. } = _ref;
  28461. const pfx = 'swiper-pagination';
  28462. extendParams({
  28463. pagination: {
  28464. el: null,
  28465. bulletElement: 'span',
  28466. clickable: false,
  28467. hideOnClick: false,
  28468. renderBullet: null,
  28469. renderProgressbar: null,
  28470. renderFraction: null,
  28471. renderCustom: null,
  28472. progressbarOpposite: false,
  28473. type: 'bullets',
  28474. // 'bullets' or 'progressbar' or 'fraction' or 'custom'
  28475. dynamicBullets: false,
  28476. dynamicMainBullets: 1,
  28477. formatFractionCurrent: number => number,
  28478. formatFractionTotal: number => number,
  28479. bulletClass: `${pfx}-bullet`,
  28480. bulletActiveClass: `${pfx}-bullet-active`,
  28481. modifierClass: `${pfx}-`,
  28482. currentClass: `${pfx}-current`,
  28483. totalClass: `${pfx}-total`,
  28484. hiddenClass: `${pfx}-hidden`,
  28485. progressbarFillClass: `${pfx}-progressbar-fill`,
  28486. progressbarOppositeClass: `${pfx}-progressbar-opposite`,
  28487. clickableClass: `${pfx}-clickable`,
  28488. lockClass: `${pfx}-lock`,
  28489. horizontalClass: `${pfx}-horizontal`,
  28490. verticalClass: `${pfx}-vertical`,
  28491. paginationDisabledClass: `${pfx}-disabled`
  28492. }
  28493. });
  28494. swiper.pagination = {
  28495. el: null,
  28496. bullets: []
  28497. };
  28498. let bulletSize;
  28499. let dynamicBulletIndex = 0;
  28500. function isPaginationDisabled() {
  28501. return !swiper.params.pagination.el || !swiper.pagination.el || Array.isArray(swiper.pagination.el) && swiper.pagination.el.length === 0;
  28502. }
  28503. function setSideBullets(bulletEl, position) {
  28504. const {
  28505. bulletActiveClass
  28506. } = swiper.params.pagination;
  28507. if (!bulletEl) return;
  28508. bulletEl = bulletEl[`${position === 'prev' ? 'previous' : 'next'}ElementSibling`];
  28509. if (bulletEl) {
  28510. bulletEl.classList.add(`${bulletActiveClass}-${position}`);
  28511. bulletEl = bulletEl[`${position === 'prev' ? 'previous' : 'next'}ElementSibling`];
  28512. if (bulletEl) {
  28513. bulletEl.classList.add(`${bulletActiveClass}-${position}-${position}`);
  28514. }
  28515. }
  28516. }
  28517. function getMoveDirection(prevIndex, nextIndex, length) {
  28518. prevIndex = prevIndex % length;
  28519. nextIndex = nextIndex % length;
  28520. if (nextIndex === prevIndex + 1) {
  28521. return 'next';
  28522. } else if (nextIndex === prevIndex - 1) {
  28523. return 'previous';
  28524. }
  28525. return;
  28526. }
  28527. function onBulletClick(e) {
  28528. const bulletEl = e.target.closest(classesToSelector(swiper.params.pagination.bulletClass));
  28529. if (!bulletEl) {
  28530. return;
  28531. }
  28532. e.preventDefault();
  28533. const index = elementIndex(bulletEl) * swiper.params.slidesPerGroup;
  28534. if (swiper.params.loop) {
  28535. if (swiper.realIndex === index) return;
  28536. const moveDirection = getMoveDirection(swiper.realIndex, index, swiper.slides.length);
  28537. if (moveDirection === 'next') {
  28538. swiper.slideNext();
  28539. } else if (moveDirection === 'previous') {
  28540. swiper.slidePrev();
  28541. } else {
  28542. swiper.slideToLoop(index);
  28543. }
  28544. } else {
  28545. swiper.slideTo(index);
  28546. }
  28547. }
  28548. function update() {
  28549. // Render || Update Pagination bullets/items
  28550. const rtl = swiper.rtl;
  28551. const params = swiper.params.pagination;
  28552. if (isPaginationDisabled()) return;
  28553. let el = swiper.pagination.el;
  28554. el = makeElementsArray(el);
  28555. // Current/Total
  28556. let current;
  28557. let previousIndex;
  28558. const slidesLength = swiper.virtual && swiper.params.virtual.enabled ? swiper.virtual.slides.length : swiper.slides.length;
  28559. const total = swiper.params.loop ? Math.ceil(slidesLength / swiper.params.slidesPerGroup) : swiper.snapGrid.length;
  28560. if (swiper.params.loop) {
  28561. previousIndex = swiper.previousRealIndex || 0;
  28562. current = swiper.params.slidesPerGroup > 1 ? Math.floor(swiper.realIndex / swiper.params.slidesPerGroup) : swiper.realIndex;
  28563. } else if (typeof swiper.snapIndex !== 'undefined') {
  28564. current = swiper.snapIndex;
  28565. previousIndex = swiper.previousSnapIndex;
  28566. } else {
  28567. previousIndex = swiper.previousIndex || 0;
  28568. current = swiper.activeIndex || 0;
  28569. }
  28570. // Types
  28571. if (params.type === 'bullets' && swiper.pagination.bullets && swiper.pagination.bullets.length > 0) {
  28572. const bullets = swiper.pagination.bullets;
  28573. let firstIndex;
  28574. let lastIndex;
  28575. let midIndex;
  28576. if (params.dynamicBullets) {
  28577. bulletSize = elementOuterSize(bullets[0], swiper.isHorizontal() ? 'width' : 'height', true);
  28578. el.forEach(subEl => {
  28579. subEl.style[swiper.isHorizontal() ? 'width' : 'height'] = `${bulletSize * (params.dynamicMainBullets + 4)}px`;
  28580. });
  28581. if (params.dynamicMainBullets > 1 && previousIndex !== undefined) {
  28582. dynamicBulletIndex += current - (previousIndex || 0);
  28583. if (dynamicBulletIndex > params.dynamicMainBullets - 1) {
  28584. dynamicBulletIndex = params.dynamicMainBullets - 1;
  28585. } else if (dynamicBulletIndex < 0) {
  28586. dynamicBulletIndex = 0;
  28587. }
  28588. }
  28589. firstIndex = Math.max(current - dynamicBulletIndex, 0);
  28590. lastIndex = firstIndex + (Math.min(bullets.length, params.dynamicMainBullets) - 1);
  28591. midIndex = (lastIndex + firstIndex) / 2;
  28592. }
  28593. bullets.forEach(bulletEl => {
  28594. 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();
  28595. bulletEl.classList.remove(...classesToRemove);
  28596. });
  28597. if (el.length > 1) {
  28598. bullets.forEach(bullet => {
  28599. const bulletIndex = elementIndex(bullet);
  28600. if (bulletIndex === current) {
  28601. bullet.classList.add(...params.bulletActiveClass.split(' '));
  28602. } else if (swiper.isElement) {
  28603. bullet.setAttribute('part', 'bullet');
  28604. }
  28605. if (params.dynamicBullets) {
  28606. if (bulletIndex >= firstIndex && bulletIndex <= lastIndex) {
  28607. bullet.classList.add(...`${params.bulletActiveClass}-main`.split(' '));
  28608. }
  28609. if (bulletIndex === firstIndex) {
  28610. setSideBullets(bullet, 'prev');
  28611. }
  28612. if (bulletIndex === lastIndex) {
  28613. setSideBullets(bullet, 'next');
  28614. }
  28615. }
  28616. });
  28617. } else {
  28618. const bullet = bullets[current];
  28619. if (bullet) {
  28620. bullet.classList.add(...params.bulletActiveClass.split(' '));
  28621. }
  28622. if (swiper.isElement) {
  28623. bullets.forEach((bulletEl, bulletIndex) => {
  28624. bulletEl.setAttribute('part', bulletIndex === current ? 'bullet-active' : 'bullet');
  28625. });
  28626. }
  28627. if (params.dynamicBullets) {
  28628. const firstDisplayedBullet = bullets[firstIndex];
  28629. const lastDisplayedBullet = bullets[lastIndex];
  28630. for (let i = firstIndex; i <= lastIndex; i += 1) {
  28631. if (bullets[i]) {
  28632. bullets[i].classList.add(...`${params.bulletActiveClass}-main`.split(' '));
  28633. }
  28634. }
  28635. setSideBullets(firstDisplayedBullet, 'prev');
  28636. setSideBullets(lastDisplayedBullet, 'next');
  28637. }
  28638. }
  28639. if (params.dynamicBullets) {
  28640. const dynamicBulletsLength = Math.min(bullets.length, params.dynamicMainBullets + 4);
  28641. const bulletsOffset = (bulletSize * dynamicBulletsLength - bulletSize) / 2 - midIndex * bulletSize;
  28642. const offsetProp = rtl ? 'right' : 'left';
  28643. bullets.forEach(bullet => {
  28644. bullet.style[swiper.isHorizontal() ? offsetProp : 'top'] = `${bulletsOffset}px`;
  28645. });
  28646. }
  28647. }
  28648. el.forEach((subEl, subElIndex) => {
  28649. if (params.type === 'fraction') {
  28650. subEl.querySelectorAll(classesToSelector(params.currentClass)).forEach(fractionEl => {
  28651. fractionEl.textContent = params.formatFractionCurrent(current + 1);
  28652. });
  28653. subEl.querySelectorAll(classesToSelector(params.totalClass)).forEach(totalEl => {
  28654. totalEl.textContent = params.formatFractionTotal(total);
  28655. });
  28656. }
  28657. if (params.type === 'progressbar') {
  28658. let progressbarDirection;
  28659. if (params.progressbarOpposite) {
  28660. progressbarDirection = swiper.isHorizontal() ? 'vertical' : 'horizontal';
  28661. } else {
  28662. progressbarDirection = swiper.isHorizontal() ? 'horizontal' : 'vertical';
  28663. }
  28664. const scale = (current + 1) / total;
  28665. let scaleX = 1;
  28666. let scaleY = 1;
  28667. if (progressbarDirection === 'horizontal') {
  28668. scaleX = scale;
  28669. } else {
  28670. scaleY = scale;
  28671. }
  28672. subEl.querySelectorAll(classesToSelector(params.progressbarFillClass)).forEach(progressEl => {
  28673. progressEl.style.transform = `translate3d(0,0,0) scaleX(${scaleX}) scaleY(${scaleY})`;
  28674. progressEl.style.transitionDuration = `${swiper.params.speed}ms`;
  28675. });
  28676. }
  28677. if (params.type === 'custom' && params.renderCustom) {
  28678. setInnerHTML(subEl, params.renderCustom(swiper, current + 1, total));
  28679. if (subElIndex === 0) emit('paginationRender', subEl);
  28680. } else {
  28681. if (subElIndex === 0) emit('paginationRender', subEl);
  28682. emit('paginationUpdate', subEl);
  28683. }
  28684. if (swiper.params.watchOverflow && swiper.enabled) {
  28685. subEl.classList[swiper.isLocked ? 'add' : 'remove'](params.lockClass);
  28686. }
  28687. });
  28688. }
  28689. function render() {
  28690. // Render Container
  28691. const params = swiper.params.pagination;
  28692. if (isPaginationDisabled()) return;
  28693. 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;
  28694. let el = swiper.pagination.el;
  28695. el = makeElementsArray(el);
  28696. let paginationHTML = '';
  28697. if (params.type === 'bullets') {
  28698. let numberOfBullets = swiper.params.loop ? Math.ceil(slidesLength / swiper.params.slidesPerGroup) : swiper.snapGrid.length;
  28699. if (swiper.params.freeMode && swiper.params.freeMode.enabled && numberOfBullets > slidesLength) {
  28700. numberOfBullets = slidesLength;
  28701. }
  28702. for (let i = 0; i < numberOfBullets; i += 1) {
  28703. if (params.renderBullet) {
  28704. paginationHTML += params.renderBullet.call(swiper, i, params.bulletClass);
  28705. } else {
  28706. // prettier-ignore
  28707. paginationHTML += `<${params.bulletElement} ${swiper.isElement ? 'part="bullet"' : ''} class="${params.bulletClass}"></${params.bulletElement}>`;
  28708. }
  28709. }
  28710. }
  28711. if (params.type === 'fraction') {
  28712. if (params.renderFraction) {
  28713. paginationHTML = params.renderFraction.call(swiper, params.currentClass, params.totalClass);
  28714. } else {
  28715. paginationHTML = `<span class="${params.currentClass}"></span>` + ' / ' + `<span class="${params.totalClass}"></span>`;
  28716. }
  28717. }
  28718. if (params.type === 'progressbar') {
  28719. if (params.renderProgressbar) {
  28720. paginationHTML = params.renderProgressbar.call(swiper, params.progressbarFillClass);
  28721. } else {
  28722. paginationHTML = `<span class="${params.progressbarFillClass}"></span>`;
  28723. }
  28724. }
  28725. swiper.pagination.bullets = [];
  28726. el.forEach(subEl => {
  28727. if (params.type !== 'custom') {
  28728. setInnerHTML(subEl, paginationHTML || '');
  28729. }
  28730. if (params.type === 'bullets') {
  28731. swiper.pagination.bullets.push(...subEl.querySelectorAll(classesToSelector(params.bulletClass)));
  28732. }
  28733. });
  28734. if (params.type !== 'custom') {
  28735. emit('paginationRender', el[0]);
  28736. }
  28737. }
  28738. function init() {
  28739. swiper.params.pagination = createElementIfNotDefined(swiper, swiper.originalParams.pagination, swiper.params.pagination, {
  28740. el: 'swiper-pagination'
  28741. });
  28742. const params = swiper.params.pagination;
  28743. if (!params.el) return;
  28744. let el;
  28745. if (typeof params.el === 'string' && swiper.isElement) {
  28746. el = swiper.el.querySelector(params.el);
  28747. }
  28748. if (!el && typeof params.el === 'string') {
  28749. el = [...document.querySelectorAll(params.el)];
  28750. }
  28751. if (!el) {
  28752. el = params.el;
  28753. }
  28754. if (!el || el.length === 0) return;
  28755. if (swiper.params.uniqueNavElements && typeof params.el === 'string' && Array.isArray(el) && el.length > 1) {
  28756. el = [...swiper.el.querySelectorAll(params.el)];
  28757. // check if it belongs to another nested Swiper
  28758. if (el.length > 1) {
  28759. el = el.find(subEl => {
  28760. if (elementParents(subEl, '.swiper')[0] !== swiper.el) return false;
  28761. return true;
  28762. });
  28763. }
  28764. }
  28765. if (Array.isArray(el) && el.length === 1) el = el[0];
  28766. Object.assign(swiper.pagination, {
  28767. el
  28768. });
  28769. el = makeElementsArray(el);
  28770. el.forEach(subEl => {
  28771. if (params.type === 'bullets' && params.clickable) {
  28772. subEl.classList.add(...(params.clickableClass || '').split(' '));
  28773. }
  28774. subEl.classList.add(params.modifierClass + params.type);
  28775. subEl.classList.add(swiper.isHorizontal() ? params.horizontalClass : params.verticalClass);
  28776. if (params.type === 'bullets' && params.dynamicBullets) {
  28777. subEl.classList.add(`${params.modifierClass}${params.type}-dynamic`);
  28778. dynamicBulletIndex = 0;
  28779. if (params.dynamicMainBullets < 1) {
  28780. params.dynamicMainBullets = 1;
  28781. }
  28782. }
  28783. if (params.type === 'progressbar' && params.progressbarOpposite) {
  28784. subEl.classList.add(params.progressbarOppositeClass);
  28785. }
  28786. if (params.clickable) {
  28787. subEl.addEventListener('click', onBulletClick);
  28788. }
  28789. if (!swiper.enabled) {
  28790. subEl.classList.add(params.lockClass);
  28791. }
  28792. });
  28793. }
  28794. function destroy() {
  28795. const params = swiper.params.pagination;
  28796. if (isPaginationDisabled()) return;
  28797. let el = swiper.pagination.el;
  28798. if (el) {
  28799. el = makeElementsArray(el);
  28800. el.forEach(subEl => {
  28801. subEl.classList.remove(params.hiddenClass);
  28802. subEl.classList.remove(params.modifierClass + params.type);
  28803. subEl.classList.remove(swiper.isHorizontal() ? params.horizontalClass : params.verticalClass);
  28804. if (params.clickable) {
  28805. subEl.classList.remove(...(params.clickableClass || '').split(' '));
  28806. subEl.removeEventListener('click', onBulletClick);
  28807. }
  28808. });
  28809. }
  28810. if (swiper.pagination.bullets) swiper.pagination.bullets.forEach(subEl => subEl.classList.remove(...params.bulletActiveClass.split(' ')));
  28811. }
  28812. on('changeDirection', () => {
  28813. if (!swiper.pagination || !swiper.pagination.el) return;
  28814. const params = swiper.params.pagination;
  28815. let {
  28816. el
  28817. } = swiper.pagination;
  28818. el = makeElementsArray(el);
  28819. el.forEach(subEl => {
  28820. subEl.classList.remove(params.horizontalClass, params.verticalClass);
  28821. subEl.classList.add(swiper.isHorizontal() ? params.horizontalClass : params.verticalClass);
  28822. });
  28823. });
  28824. on('init', () => {
  28825. if (swiper.params.pagination.enabled === false) {
  28826. // eslint-disable-next-line
  28827. disable();
  28828. } else {
  28829. init();
  28830. render();
  28831. update();
  28832. }
  28833. });
  28834. on('activeIndexChange', () => {
  28835. if (typeof swiper.snapIndex === 'undefined') {
  28836. update();
  28837. }
  28838. });
  28839. on('snapIndexChange', () => {
  28840. update();
  28841. });
  28842. on('snapGridLengthChange', () => {
  28843. render();
  28844. update();
  28845. });
  28846. on('destroy', () => {
  28847. destroy();
  28848. });
  28849. on('enable disable', () => {
  28850. let {
  28851. el
  28852. } = swiper.pagination;
  28853. if (el) {
  28854. el = makeElementsArray(el);
  28855. el.forEach(subEl => subEl.classList[swiper.enabled ? 'remove' : 'add'](swiper.params.pagination.lockClass));
  28856. }
  28857. });
  28858. on('lock unlock', () => {
  28859. update();
  28860. });
  28861. on('click', (_s, e) => {
  28862. const targetEl = e.target;
  28863. const el = makeElementsArray(swiper.pagination.el);
  28864. if (swiper.params.pagination.el && swiper.params.pagination.hideOnClick && el && el.length > 0 && !targetEl.classList.contains(swiper.params.pagination.bulletClass)) {
  28865. if (swiper.navigation && (swiper.navigation.nextEl && targetEl === swiper.navigation.nextEl || swiper.navigation.prevEl && targetEl === swiper.navigation.prevEl)) return;
  28866. const isHidden = el[0].classList.contains(swiper.params.pagination.hiddenClass);
  28867. if (isHidden === true) {
  28868. emit('paginationShow');
  28869. } else {
  28870. emit('paginationHide');
  28871. }
  28872. el.forEach(subEl => subEl.classList.toggle(swiper.params.pagination.hiddenClass));
  28873. }
  28874. });
  28875. const enable = () => {
  28876. swiper.el.classList.remove(swiper.params.pagination.paginationDisabledClass);
  28877. let {
  28878. el
  28879. } = swiper.pagination;
  28880. if (el) {
  28881. el = makeElementsArray(el);
  28882. el.forEach(subEl => subEl.classList.remove(swiper.params.pagination.paginationDisabledClass));
  28883. }
  28884. init();
  28885. render();
  28886. update();
  28887. };
  28888. const disable = () => {
  28889. swiper.el.classList.add(swiper.params.pagination.paginationDisabledClass);
  28890. let {
  28891. el
  28892. } = swiper.pagination;
  28893. if (el) {
  28894. el = makeElementsArray(el);
  28895. el.forEach(subEl => subEl.classList.add(swiper.params.pagination.paginationDisabledClass));
  28896. }
  28897. destroy();
  28898. };
  28899. Object.assign(swiper.pagination, {
  28900. enable,
  28901. disable,
  28902. render,
  28903. update,
  28904. init,
  28905. destroy
  28906. });
  28907. }
  28908. function Scrollbar(_ref) {
  28909. let {
  28910. swiper,
  28911. extendParams,
  28912. on,
  28913. emit
  28914. } = _ref;
  28915. const document = getDocument();
  28916. let isTouched = false;
  28917. let timeout = null;
  28918. let dragTimeout = null;
  28919. let dragStartPos;
  28920. let dragSize;
  28921. let trackSize;
  28922. let divider;
  28923. extendParams({
  28924. scrollbar: {
  28925. el: null,
  28926. dragSize: 'auto',
  28927. hide: false,
  28928. draggable: false,
  28929. snapOnRelease: true,
  28930. lockClass: 'swiper-scrollbar-lock',
  28931. dragClass: 'swiper-scrollbar-drag',
  28932. scrollbarDisabledClass: 'swiper-scrollbar-disabled',
  28933. horizontalClass: `swiper-scrollbar-horizontal`,
  28934. verticalClass: `swiper-scrollbar-vertical`
  28935. }
  28936. });
  28937. swiper.scrollbar = {
  28938. el: null,
  28939. dragEl: null
  28940. };
  28941. function setTranslate() {
  28942. if (!swiper.params.scrollbar.el || !swiper.scrollbar.el) return;
  28943. const {
  28944. scrollbar,
  28945. rtlTranslate: rtl
  28946. } = swiper;
  28947. const {
  28948. dragEl,
  28949. el
  28950. } = scrollbar;
  28951. const params = swiper.params.scrollbar;
  28952. const progress = swiper.params.loop ? swiper.progressLoop : swiper.progress;
  28953. let newSize = dragSize;
  28954. let newPos = (trackSize - dragSize) * progress;
  28955. if (rtl) {
  28956. newPos = -newPos;
  28957. if (newPos > 0) {
  28958. newSize = dragSize - newPos;
  28959. newPos = 0;
  28960. } else if (-newPos + dragSize > trackSize) {
  28961. newSize = trackSize + newPos;
  28962. }
  28963. } else if (newPos < 0) {
  28964. newSize = dragSize + newPos;
  28965. newPos = 0;
  28966. } else if (newPos + dragSize > trackSize) {
  28967. newSize = trackSize - newPos;
  28968. }
  28969. if (swiper.isHorizontal()) {
  28970. dragEl.style.transform = `translate3d(${newPos}px, 0, 0)`;
  28971. dragEl.style.width = `${newSize}px`;
  28972. } else {
  28973. dragEl.style.transform = `translate3d(0px, ${newPos}px, 0)`;
  28974. dragEl.style.height = `${newSize}px`;
  28975. }
  28976. if (params.hide) {
  28977. clearTimeout(timeout);
  28978. el.style.opacity = 1;
  28979. timeout = setTimeout(() => {
  28980. el.style.opacity = 0;
  28981. el.style.transitionDuration = '400ms';
  28982. }, 1000);
  28983. }
  28984. }
  28985. function setTransition(duration) {
  28986. if (!swiper.params.scrollbar.el || !swiper.scrollbar.el) return;
  28987. swiper.scrollbar.dragEl.style.transitionDuration = `${duration}ms`;
  28988. }
  28989. function updateSize() {
  28990. if (!swiper.params.scrollbar.el || !swiper.scrollbar.el) return;
  28991. const {
  28992. scrollbar
  28993. } = swiper;
  28994. const {
  28995. dragEl,
  28996. el
  28997. } = scrollbar;
  28998. dragEl.style.width = '';
  28999. dragEl.style.height = '';
  29000. trackSize = swiper.isHorizontal() ? el.offsetWidth : el.offsetHeight;
  29001. divider = swiper.size / (swiper.virtualSize + swiper.params.slidesOffsetBefore - (swiper.params.centeredSlides ? swiper.snapGrid[0] : 0));
  29002. if (swiper.params.scrollbar.dragSize === 'auto') {
  29003. dragSize = trackSize * divider;
  29004. } else {
  29005. dragSize = parseInt(swiper.params.scrollbar.dragSize, 10);
  29006. }
  29007. if (swiper.isHorizontal()) {
  29008. dragEl.style.width = `${dragSize}px`;
  29009. } else {
  29010. dragEl.style.height = `${dragSize}px`;
  29011. }
  29012. if (divider >= 1) {
  29013. el.style.display = 'none';
  29014. } else {
  29015. el.style.display = '';
  29016. }
  29017. if (swiper.params.scrollbar.hide) {
  29018. el.style.opacity = 0;
  29019. }
  29020. if (swiper.params.watchOverflow && swiper.enabled) {
  29021. scrollbar.el.classList[swiper.isLocked ? 'add' : 'remove'](swiper.params.scrollbar.lockClass);
  29022. }
  29023. }
  29024. function getPointerPosition(e) {
  29025. return swiper.isHorizontal() ? e.clientX : e.clientY;
  29026. }
  29027. function setDragPosition(e) {
  29028. const {
  29029. scrollbar,
  29030. rtlTranslate: rtl
  29031. } = swiper;
  29032. const {
  29033. el
  29034. } = scrollbar;
  29035. let positionRatio;
  29036. positionRatio = (getPointerPosition(e) - elementOffset(el)[swiper.isHorizontal() ? 'left' : 'top'] - (dragStartPos !== null ? dragStartPos : dragSize / 2)) / (trackSize - dragSize);
  29037. positionRatio = Math.max(Math.min(positionRatio, 1), 0);
  29038. if (rtl) {
  29039. positionRatio = 1 - positionRatio;
  29040. }
  29041. const position = swiper.minTranslate() + (swiper.maxTranslate() - swiper.minTranslate()) * positionRatio;
  29042. swiper.updateProgress(position);
  29043. swiper.setTranslate(position);
  29044. swiper.updateActiveIndex();
  29045. swiper.updateSlidesClasses();
  29046. }
  29047. function onDragStart(e) {
  29048. const params = swiper.params.scrollbar;
  29049. const {
  29050. scrollbar,
  29051. wrapperEl
  29052. } = swiper;
  29053. const {
  29054. el,
  29055. dragEl
  29056. } = scrollbar;
  29057. isTouched = true;
  29058. dragStartPos = e.target === dragEl ? getPointerPosition(e) - e.target.getBoundingClientRect()[swiper.isHorizontal() ? 'left' : 'top'] : null;
  29059. e.preventDefault();
  29060. e.stopPropagation();
  29061. wrapperEl.style.transitionDuration = '100ms';
  29062. dragEl.style.transitionDuration = '100ms';
  29063. setDragPosition(e);
  29064. clearTimeout(dragTimeout);
  29065. el.style.transitionDuration = '0ms';
  29066. if (params.hide) {
  29067. el.style.opacity = 1;
  29068. }
  29069. if (swiper.params.cssMode) {
  29070. swiper.wrapperEl.style['scroll-snap-type'] = 'none';
  29071. }
  29072. emit('scrollbarDragStart', e);
  29073. }
  29074. function onDragMove(e) {
  29075. const {
  29076. scrollbar,
  29077. wrapperEl
  29078. } = swiper;
  29079. const {
  29080. el,
  29081. dragEl
  29082. } = scrollbar;
  29083. if (!isTouched) return;
  29084. if (e.preventDefault && e.cancelable) e.preventDefault();else e.returnValue = false;
  29085. setDragPosition(e);
  29086. wrapperEl.style.transitionDuration = '0ms';
  29087. el.style.transitionDuration = '0ms';
  29088. dragEl.style.transitionDuration = '0ms';
  29089. emit('scrollbarDragMove', e);
  29090. }
  29091. function onDragEnd(e) {
  29092. const params = swiper.params.scrollbar;
  29093. const {
  29094. scrollbar,
  29095. wrapperEl
  29096. } = swiper;
  29097. const {
  29098. el
  29099. } = scrollbar;
  29100. if (!isTouched) return;
  29101. isTouched = false;
  29102. if (swiper.params.cssMode) {
  29103. swiper.wrapperEl.style['scroll-snap-type'] = '';
  29104. wrapperEl.style.transitionDuration = '';
  29105. }
  29106. if (params.hide) {
  29107. clearTimeout(dragTimeout);
  29108. dragTimeout = nextTick(() => {
  29109. el.style.opacity = 0;
  29110. el.style.transitionDuration = '400ms';
  29111. }, 1000);
  29112. }
  29113. emit('scrollbarDragEnd', e);
  29114. if (params.snapOnRelease) {
  29115. swiper.slideToClosest();
  29116. }
  29117. }
  29118. function events(method) {
  29119. const {
  29120. scrollbar,
  29121. params
  29122. } = swiper;
  29123. const el = scrollbar.el;
  29124. if (!el) return;
  29125. const target = el;
  29126. const activeListener = params.passiveListeners ? {
  29127. passive: false,
  29128. capture: false
  29129. } : false;
  29130. const passiveListener = params.passiveListeners ? {
  29131. passive: true,
  29132. capture: false
  29133. } : false;
  29134. if (!target) return;
  29135. const eventMethod = method === 'on' ? 'addEventListener' : 'removeEventListener';
  29136. target[eventMethod]('pointerdown', onDragStart, activeListener);
  29137. document[eventMethod]('pointermove', onDragMove, activeListener);
  29138. document[eventMethod]('pointerup', onDragEnd, passiveListener);
  29139. }
  29140. function enableDraggable() {
  29141. if (!swiper.params.scrollbar.el || !swiper.scrollbar.el) return;
  29142. events('on');
  29143. }
  29144. function disableDraggable() {
  29145. if (!swiper.params.scrollbar.el || !swiper.scrollbar.el) return;
  29146. events('off');
  29147. }
  29148. function init() {
  29149. const {
  29150. scrollbar,
  29151. el: swiperEl
  29152. } = swiper;
  29153. swiper.params.scrollbar = createElementIfNotDefined(swiper, swiper.originalParams.scrollbar, swiper.params.scrollbar, {
  29154. el: 'swiper-scrollbar'
  29155. });
  29156. const params = swiper.params.scrollbar;
  29157. if (!params.el) return;
  29158. let el;
  29159. if (typeof params.el === 'string' && swiper.isElement) {
  29160. el = swiper.el.querySelector(params.el);
  29161. }
  29162. if (!el && typeof params.el === 'string') {
  29163. el = document.querySelectorAll(params.el);
  29164. if (!el.length) return;
  29165. } else if (!el) {
  29166. el = params.el;
  29167. }
  29168. if (swiper.params.uniqueNavElements && typeof params.el === 'string' && el.length > 1 && swiperEl.querySelectorAll(params.el).length === 1) {
  29169. el = swiperEl.querySelector(params.el);
  29170. }
  29171. if (el.length > 0) el = el[0];
  29172. el.classList.add(swiper.isHorizontal() ? params.horizontalClass : params.verticalClass);
  29173. let dragEl;
  29174. if (el) {
  29175. dragEl = el.querySelector(classesToSelector(swiper.params.scrollbar.dragClass));
  29176. if (!dragEl) {
  29177. dragEl = createElement('div', swiper.params.scrollbar.dragClass);
  29178. el.append(dragEl);
  29179. }
  29180. }
  29181. Object.assign(scrollbar, {
  29182. el,
  29183. dragEl
  29184. });
  29185. if (params.draggable) {
  29186. enableDraggable();
  29187. }
  29188. if (el) {
  29189. el.classList[swiper.enabled ? 'remove' : 'add'](...classesToTokens(swiper.params.scrollbar.lockClass));
  29190. }
  29191. }
  29192. function destroy() {
  29193. const params = swiper.params.scrollbar;
  29194. const el = swiper.scrollbar.el;
  29195. if (el) {
  29196. el.classList.remove(...classesToTokens(swiper.isHorizontal() ? params.horizontalClass : params.verticalClass));
  29197. }
  29198. disableDraggable();
  29199. }
  29200. on('changeDirection', () => {
  29201. if (!swiper.scrollbar || !swiper.scrollbar.el) return;
  29202. const params = swiper.params.scrollbar;
  29203. let {
  29204. el
  29205. } = swiper.scrollbar;
  29206. el = makeElementsArray(el);
  29207. el.forEach(subEl => {
  29208. subEl.classList.remove(params.horizontalClass, params.verticalClass);
  29209. subEl.classList.add(swiper.isHorizontal() ? params.horizontalClass : params.verticalClass);
  29210. });
  29211. });
  29212. on('init', () => {
  29213. if (swiper.params.scrollbar.enabled === false) {
  29214. // eslint-disable-next-line
  29215. disable();
  29216. } else {
  29217. init();
  29218. updateSize();
  29219. setTranslate();
  29220. }
  29221. });
  29222. on('update resize observerUpdate lock unlock changeDirection', () => {
  29223. updateSize();
  29224. });
  29225. on('setTranslate', () => {
  29226. setTranslate();
  29227. });
  29228. on('setTransition', (_s, duration) => {
  29229. setTransition(duration);
  29230. });
  29231. on('enable disable', () => {
  29232. const {
  29233. el
  29234. } = swiper.scrollbar;
  29235. if (el) {
  29236. el.classList[swiper.enabled ? 'remove' : 'add'](...classesToTokens(swiper.params.scrollbar.lockClass));
  29237. }
  29238. });
  29239. on('destroy', () => {
  29240. destroy();
  29241. });
  29242. const enable = () => {
  29243. swiper.el.classList.remove(...classesToTokens(swiper.params.scrollbar.scrollbarDisabledClass));
  29244. if (swiper.scrollbar.el) {
  29245. swiper.scrollbar.el.classList.remove(...classesToTokens(swiper.params.scrollbar.scrollbarDisabledClass));
  29246. }
  29247. init();
  29248. updateSize();
  29249. setTranslate();
  29250. };
  29251. const disable = () => {
  29252. swiper.el.classList.add(...classesToTokens(swiper.params.scrollbar.scrollbarDisabledClass));
  29253. if (swiper.scrollbar.el) {
  29254. swiper.scrollbar.el.classList.add(...classesToTokens(swiper.params.scrollbar.scrollbarDisabledClass));
  29255. }
  29256. destroy();
  29257. };
  29258. Object.assign(swiper.scrollbar, {
  29259. enable,
  29260. disable,
  29261. updateSize,
  29262. setTranslate,
  29263. init,
  29264. destroy
  29265. });
  29266. }
  29267. function Parallax(_ref) {
  29268. let {
  29269. swiper,
  29270. extendParams,
  29271. on
  29272. } = _ref;
  29273. extendParams({
  29274. parallax: {
  29275. enabled: false
  29276. }
  29277. });
  29278. const elementsSelector = '[data-swiper-parallax], [data-swiper-parallax-x], [data-swiper-parallax-y], [data-swiper-parallax-opacity], [data-swiper-parallax-scale]';
  29279. const setTransform = (el, progress) => {
  29280. const {
  29281. rtl
  29282. } = swiper;
  29283. const rtlFactor = rtl ? -1 : 1;
  29284. const p = el.getAttribute('data-swiper-parallax') || '0';
  29285. let x = el.getAttribute('data-swiper-parallax-x');
  29286. let y = el.getAttribute('data-swiper-parallax-y');
  29287. const scale = el.getAttribute('data-swiper-parallax-scale');
  29288. const opacity = el.getAttribute('data-swiper-parallax-opacity');
  29289. const rotate = el.getAttribute('data-swiper-parallax-rotate');
  29290. if (x || y) {
  29291. x = x || '0';
  29292. y = y || '0';
  29293. } else if (swiper.isHorizontal()) {
  29294. x = p;
  29295. y = '0';
  29296. } else {
  29297. y = p;
  29298. x = '0';
  29299. }
  29300. if (x.indexOf('%') >= 0) {
  29301. x = `${parseInt(x, 10) * progress * rtlFactor}%`;
  29302. } else {
  29303. x = `${x * progress * rtlFactor}px`;
  29304. }
  29305. if (y.indexOf('%') >= 0) {
  29306. y = `${parseInt(y, 10) * progress}%`;
  29307. } else {
  29308. y = `${y * progress}px`;
  29309. }
  29310. if (typeof opacity !== 'undefined' && opacity !== null) {
  29311. const currentOpacity = opacity - (opacity - 1) * (1 - Math.abs(progress));
  29312. el.style.opacity = currentOpacity;
  29313. }
  29314. let transform = `translate3d(${x}, ${y}, 0px)`;
  29315. if (typeof scale !== 'undefined' && scale !== null) {
  29316. const currentScale = scale - (scale - 1) * (1 - Math.abs(progress));
  29317. transform += ` scale(${currentScale})`;
  29318. }
  29319. if (rotate && typeof rotate !== 'undefined' && rotate !== null) {
  29320. const currentRotate = rotate * progress * -1;
  29321. transform += ` rotate(${currentRotate}deg)`;
  29322. }
  29323. el.style.transform = transform;
  29324. };
  29325. const setTranslate = () => {
  29326. const {
  29327. el,
  29328. slides,
  29329. progress,
  29330. snapGrid,
  29331. isElement
  29332. } = swiper;
  29333. const elements = elementChildren(el, elementsSelector);
  29334. if (swiper.isElement) {
  29335. elements.push(...elementChildren(swiper.hostEl, elementsSelector));
  29336. }
  29337. elements.forEach(subEl => {
  29338. setTransform(subEl, progress);
  29339. });
  29340. slides.forEach((slideEl, slideIndex) => {
  29341. let slideProgress = slideEl.progress;
  29342. if (swiper.params.slidesPerGroup > 1 && swiper.params.slidesPerView !== 'auto') {
  29343. slideProgress += Math.ceil(slideIndex / 2) - progress * (snapGrid.length - 1);
  29344. }
  29345. slideProgress = Math.min(Math.max(slideProgress, -1), 1);
  29346. slideEl.querySelectorAll(`${elementsSelector}, [data-swiper-parallax-rotate]`).forEach(subEl => {
  29347. setTransform(subEl, slideProgress);
  29348. });
  29349. });
  29350. };
  29351. const setTransition = function (duration) {
  29352. if (duration === void 0) {
  29353. duration = swiper.params.speed;
  29354. }
  29355. const {
  29356. el,
  29357. hostEl
  29358. } = swiper;
  29359. const elements = [...el.querySelectorAll(elementsSelector)];
  29360. if (swiper.isElement) {
  29361. elements.push(...hostEl.querySelectorAll(elementsSelector));
  29362. }
  29363. elements.forEach(parallaxEl => {
  29364. let parallaxDuration = parseInt(parallaxEl.getAttribute('data-swiper-parallax-duration'), 10) || duration;
  29365. if (duration === 0) parallaxDuration = 0;
  29366. parallaxEl.style.transitionDuration = `${parallaxDuration}ms`;
  29367. });
  29368. };
  29369. on('beforeInit', () => {
  29370. if (!swiper.params.parallax.enabled) return;
  29371. swiper.params.watchSlidesProgress = true;
  29372. swiper.originalParams.watchSlidesProgress = true;
  29373. });
  29374. on('init', () => {
  29375. if (!swiper.params.parallax.enabled) return;
  29376. setTranslate();
  29377. });
  29378. on('setTranslate', () => {
  29379. if (!swiper.params.parallax.enabled) return;
  29380. setTranslate();
  29381. });
  29382. on('setTransition', (_swiper, duration) => {
  29383. if (!swiper.params.parallax.enabled) return;
  29384. setTransition(duration);
  29385. });
  29386. }
  29387. function Zoom(_ref) {
  29388. let {
  29389. swiper,
  29390. extendParams,
  29391. on,
  29392. emit
  29393. } = _ref;
  29394. const window = getWindow();
  29395. extendParams({
  29396. zoom: {
  29397. enabled: false,
  29398. limitToOriginalSize: false,
  29399. maxRatio: 3,
  29400. minRatio: 1,
  29401. panOnMouseMove: false,
  29402. toggle: true,
  29403. containerClass: 'swiper-zoom-container',
  29404. zoomedSlideClass: 'swiper-slide-zoomed'
  29405. }
  29406. });
  29407. swiper.zoom = {
  29408. enabled: false
  29409. };
  29410. let currentScale = 1;
  29411. let isScaling = false;
  29412. let isPanningWithMouse = false;
  29413. let mousePanStart = {
  29414. x: 0,
  29415. y: 0
  29416. };
  29417. const mousePanSensitivity = -3; // Negative to invert pan direction
  29418. let fakeGestureTouched;
  29419. let fakeGestureMoved;
  29420. const evCache = [];
  29421. const gesture = {
  29422. originX: 0,
  29423. originY: 0,
  29424. slideEl: undefined,
  29425. slideWidth: undefined,
  29426. slideHeight: undefined,
  29427. imageEl: undefined,
  29428. imageWrapEl: undefined,
  29429. maxRatio: 3
  29430. };
  29431. const image = {
  29432. isTouched: undefined,
  29433. isMoved: undefined,
  29434. currentX: undefined,
  29435. currentY: undefined,
  29436. minX: undefined,
  29437. minY: undefined,
  29438. maxX: undefined,
  29439. maxY: undefined,
  29440. width: undefined,
  29441. height: undefined,
  29442. startX: undefined,
  29443. startY: undefined,
  29444. touchesStart: {},
  29445. touchesCurrent: {}
  29446. };
  29447. const velocity = {
  29448. x: undefined,
  29449. y: undefined,
  29450. prevPositionX: undefined,
  29451. prevPositionY: undefined,
  29452. prevTime: undefined
  29453. };
  29454. let scale = 1;
  29455. Object.defineProperty(swiper.zoom, 'scale', {
  29456. get() {
  29457. return scale;
  29458. },
  29459. set(value) {
  29460. if (scale !== value) {
  29461. const imageEl = gesture.imageEl;
  29462. const slideEl = gesture.slideEl;
  29463. emit('zoomChange', value, imageEl, slideEl);
  29464. }
  29465. scale = value;
  29466. }
  29467. });
  29468. function getDistanceBetweenTouches() {
  29469. if (evCache.length < 2) return 1;
  29470. const x1 = evCache[0].pageX;
  29471. const y1 = evCache[0].pageY;
  29472. const x2 = evCache[1].pageX;
  29473. const y2 = evCache[1].pageY;
  29474. const distance = Math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2);
  29475. return distance;
  29476. }
  29477. function getMaxRatio() {
  29478. const params = swiper.params.zoom;
  29479. const maxRatio = gesture.imageWrapEl.getAttribute('data-swiper-zoom') || params.maxRatio;
  29480. if (params.limitToOriginalSize && gesture.imageEl && gesture.imageEl.naturalWidth) {
  29481. const imageMaxRatio = gesture.imageEl.naturalWidth / gesture.imageEl.offsetWidth;
  29482. return Math.min(imageMaxRatio, maxRatio);
  29483. }
  29484. return maxRatio;
  29485. }
  29486. function getScaleOrigin() {
  29487. if (evCache.length < 2) return {
  29488. x: null,
  29489. y: null
  29490. };
  29491. const box = gesture.imageEl.getBoundingClientRect();
  29492. 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];
  29493. }
  29494. function getSlideSelector() {
  29495. return swiper.isElement ? `swiper-slide` : `.${swiper.params.slideClass}`;
  29496. }
  29497. function eventWithinSlide(e) {
  29498. const slideSelector = getSlideSelector();
  29499. if (e.target.matches(slideSelector)) return true;
  29500. if (swiper.slides.filter(slideEl => slideEl.contains(e.target)).length > 0) return true;
  29501. return false;
  29502. }
  29503. function eventWithinZoomContainer(e) {
  29504. const selector = `.${swiper.params.zoom.containerClass}`;
  29505. if (e.target.matches(selector)) return true;
  29506. if ([...swiper.hostEl.querySelectorAll(selector)].filter(containerEl => containerEl.contains(e.target)).length > 0) return true;
  29507. return false;
  29508. }
  29509. // Events
  29510. function onGestureStart(e) {
  29511. if (e.pointerType === 'mouse') {
  29512. evCache.splice(0, evCache.length);
  29513. }
  29514. if (!eventWithinSlide(e)) return;
  29515. const params = swiper.params.zoom;
  29516. fakeGestureTouched = false;
  29517. fakeGestureMoved = false;
  29518. evCache.push(e);
  29519. if (evCache.length < 2) {
  29520. return;
  29521. }
  29522. fakeGestureTouched = true;
  29523. gesture.scaleStart = getDistanceBetweenTouches();
  29524. if (!gesture.slideEl) {
  29525. gesture.slideEl = e.target.closest(`.${swiper.params.slideClass}, swiper-slide`);
  29526. if (!gesture.slideEl) gesture.slideEl = swiper.slides[swiper.activeIndex];
  29527. let imageEl = gesture.slideEl.querySelector(`.${params.containerClass}`);
  29528. if (imageEl) {
  29529. imageEl = imageEl.querySelectorAll('picture, img, svg, canvas, .swiper-zoom-target')[0];
  29530. }
  29531. gesture.imageEl = imageEl;
  29532. if (imageEl) {
  29533. gesture.imageWrapEl = elementParents(gesture.imageEl, `.${params.containerClass}`)[0];
  29534. } else {
  29535. gesture.imageWrapEl = undefined;
  29536. }
  29537. if (!gesture.imageWrapEl) {
  29538. gesture.imageEl = undefined;
  29539. return;
  29540. }
  29541. gesture.maxRatio = getMaxRatio();
  29542. }
  29543. if (gesture.imageEl) {
  29544. const [originX, originY] = getScaleOrigin();
  29545. gesture.originX = originX;
  29546. gesture.originY = originY;
  29547. gesture.imageEl.style.transitionDuration = '0ms';
  29548. }
  29549. isScaling = true;
  29550. }
  29551. function onGestureChange(e) {
  29552. if (!eventWithinSlide(e)) return;
  29553. const params = swiper.params.zoom;
  29554. const zoom = swiper.zoom;
  29555. const pointerIndex = evCache.findIndex(cachedEv => cachedEv.pointerId === e.pointerId);
  29556. if (pointerIndex >= 0) evCache[pointerIndex] = e;
  29557. if (evCache.length < 2) {
  29558. return;
  29559. }
  29560. fakeGestureMoved = true;
  29561. gesture.scaleMove = getDistanceBetweenTouches();
  29562. if (!gesture.imageEl) {
  29563. return;
  29564. }
  29565. zoom.scale = gesture.scaleMove / gesture.scaleStart * currentScale;
  29566. if (zoom.scale > gesture.maxRatio) {
  29567. zoom.scale = gesture.maxRatio - 1 + (zoom.scale - gesture.maxRatio + 1) ** 0.5;
  29568. }
  29569. if (zoom.scale < params.minRatio) {
  29570. zoom.scale = params.minRatio + 1 - (params.minRatio - zoom.scale + 1) ** 0.5;
  29571. }
  29572. gesture.imageEl.style.transform = `translate3d(0,0,0) scale(${zoom.scale})`;
  29573. }
  29574. function onGestureEnd(e) {
  29575. if (!eventWithinSlide(e)) return;
  29576. if (e.pointerType === 'mouse' && e.type === 'pointerout') return;
  29577. const params = swiper.params.zoom;
  29578. const zoom = swiper.zoom;
  29579. const pointerIndex = evCache.findIndex(cachedEv => cachedEv.pointerId === e.pointerId);
  29580. if (pointerIndex >= 0) evCache.splice(pointerIndex, 1);
  29581. if (!fakeGestureTouched || !fakeGestureMoved) {
  29582. return;
  29583. }
  29584. fakeGestureTouched = false;
  29585. fakeGestureMoved = false;
  29586. if (!gesture.imageEl) return;
  29587. zoom.scale = Math.max(Math.min(zoom.scale, gesture.maxRatio), params.minRatio);
  29588. gesture.imageEl.style.transitionDuration = `${swiper.params.speed}ms`;
  29589. gesture.imageEl.style.transform = `translate3d(0,0,0) scale(${zoom.scale})`;
  29590. currentScale = zoom.scale;
  29591. isScaling = false;
  29592. if (zoom.scale > 1 && gesture.slideEl) {
  29593. gesture.slideEl.classList.add(`${params.zoomedSlideClass}`);
  29594. } else if (zoom.scale <= 1 && gesture.slideEl) {
  29595. gesture.slideEl.classList.remove(`${params.zoomedSlideClass}`);
  29596. }
  29597. if (zoom.scale === 1) {
  29598. gesture.originX = 0;
  29599. gesture.originY = 0;
  29600. gesture.slideEl = undefined;
  29601. }
  29602. }
  29603. let allowTouchMoveTimeout;
  29604. function allowTouchMove() {
  29605. swiper.touchEventsData.preventTouchMoveFromPointerMove = false;
  29606. }
  29607. function preventTouchMove() {
  29608. clearTimeout(allowTouchMoveTimeout);
  29609. swiper.touchEventsData.preventTouchMoveFromPointerMove = true;
  29610. allowTouchMoveTimeout = setTimeout(() => {
  29611. if (swiper.destroyed) return;
  29612. allowTouchMove();
  29613. });
  29614. }
  29615. function onTouchStart(e) {
  29616. const device = swiper.device;
  29617. if (!gesture.imageEl) return;
  29618. if (image.isTouched) return;
  29619. if (device.android && e.cancelable) e.preventDefault();
  29620. image.isTouched = true;
  29621. const event = evCache.length > 0 ? evCache[0] : e;
  29622. image.touchesStart.x = event.pageX;
  29623. image.touchesStart.y = event.pageY;
  29624. }
  29625. function onTouchMove(e) {
  29626. const isMouseEvent = e.pointerType === 'mouse';
  29627. const isMousePan = isMouseEvent && swiper.params.zoom.panOnMouseMove;
  29628. if (!eventWithinSlide(e) || !eventWithinZoomContainer(e)) {
  29629. return;
  29630. }
  29631. const zoom = swiper.zoom;
  29632. if (!gesture.imageEl) {
  29633. return;
  29634. }
  29635. if (!image.isTouched || !gesture.slideEl) {
  29636. if (isMousePan) onMouseMove(e);
  29637. return;
  29638. }
  29639. if (isMousePan) {
  29640. onMouseMove(e);
  29641. return;
  29642. }
  29643. if (!image.isMoved) {
  29644. image.width = gesture.imageEl.offsetWidth || gesture.imageEl.clientWidth;
  29645. image.height = gesture.imageEl.offsetHeight || gesture.imageEl.clientHeight;
  29646. image.startX = getTranslate(gesture.imageWrapEl, 'x') || 0;
  29647. image.startY = getTranslate(gesture.imageWrapEl, 'y') || 0;
  29648. gesture.slideWidth = gesture.slideEl.offsetWidth;
  29649. gesture.slideHeight = gesture.slideEl.offsetHeight;
  29650. gesture.imageWrapEl.style.transitionDuration = '0ms';
  29651. }
  29652. // Define if we need image drag
  29653. const scaledWidth = image.width * zoom.scale;
  29654. const scaledHeight = image.height * zoom.scale;
  29655. image.minX = Math.min(gesture.slideWidth / 2 - scaledWidth / 2, 0);
  29656. image.maxX = -image.minX;
  29657. image.minY = Math.min(gesture.slideHeight / 2 - scaledHeight / 2, 0);
  29658. image.maxY = -image.minY;
  29659. image.touchesCurrent.x = evCache.length > 0 ? evCache[0].pageX : e.pageX;
  29660. image.touchesCurrent.y = evCache.length > 0 ? evCache[0].pageY : e.pageY;
  29661. const touchesDiff = Math.max(Math.abs(image.touchesCurrent.x - image.touchesStart.x), Math.abs(image.touchesCurrent.y - image.touchesStart.y));
  29662. if (touchesDiff > 5) {
  29663. swiper.allowClick = false;
  29664. }
  29665. if (!image.isMoved && !isScaling) {
  29666. 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)) {
  29667. image.isTouched = false;
  29668. allowTouchMove();
  29669. return;
  29670. }
  29671. 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)) {
  29672. image.isTouched = false;
  29673. allowTouchMove();
  29674. return;
  29675. }
  29676. }
  29677. if (e.cancelable) {
  29678. e.preventDefault();
  29679. }
  29680. e.stopPropagation();
  29681. preventTouchMove();
  29682. image.isMoved = true;
  29683. const scaleRatio = (zoom.scale - currentScale) / (gesture.maxRatio - swiper.params.zoom.minRatio);
  29684. const {
  29685. originX,
  29686. originY
  29687. } = gesture;
  29688. image.currentX = image.touchesCurrent.x - image.touchesStart.x + image.startX + scaleRatio * (image.width - originX * 2);
  29689. image.currentY = image.touchesCurrent.y - image.touchesStart.y + image.startY + scaleRatio * (image.height - originY * 2);
  29690. if (image.currentX < image.minX) {
  29691. image.currentX = image.minX + 1 - (image.minX - image.currentX + 1) ** 0.8;
  29692. }
  29693. if (image.currentX > image.maxX) {
  29694. image.currentX = image.maxX - 1 + (image.currentX - image.maxX + 1) ** 0.8;
  29695. }
  29696. if (image.currentY < image.minY) {
  29697. image.currentY = image.minY + 1 - (image.minY - image.currentY + 1) ** 0.8;
  29698. }
  29699. if (image.currentY > image.maxY) {
  29700. image.currentY = image.maxY - 1 + (image.currentY - image.maxY + 1) ** 0.8;
  29701. }
  29702. // Velocity
  29703. if (!velocity.prevPositionX) velocity.prevPositionX = image.touchesCurrent.x;
  29704. if (!velocity.prevPositionY) velocity.prevPositionY = image.touchesCurrent.y;
  29705. if (!velocity.prevTime) velocity.prevTime = Date.now();
  29706. velocity.x = (image.touchesCurrent.x - velocity.prevPositionX) / (Date.now() - velocity.prevTime) / 2;
  29707. velocity.y = (image.touchesCurrent.y - velocity.prevPositionY) / (Date.now() - velocity.prevTime) / 2;
  29708. if (Math.abs(image.touchesCurrent.x - velocity.prevPositionX) < 2) velocity.x = 0;
  29709. if (Math.abs(image.touchesCurrent.y - velocity.prevPositionY) < 2) velocity.y = 0;
  29710. velocity.prevPositionX = image.touchesCurrent.x;
  29711. velocity.prevPositionY = image.touchesCurrent.y;
  29712. velocity.prevTime = Date.now();
  29713. gesture.imageWrapEl.style.transform = `translate3d(${image.currentX}px, ${image.currentY}px,0)`;
  29714. }
  29715. function onTouchEnd() {
  29716. const zoom = swiper.zoom;
  29717. evCache.length = 0;
  29718. if (!gesture.imageEl) return;
  29719. if (!image.isTouched || !image.isMoved) {
  29720. image.isTouched = false;
  29721. image.isMoved = false;
  29722. return;
  29723. }
  29724. image.isTouched = false;
  29725. image.isMoved = false;
  29726. let momentumDurationX = 300;
  29727. let momentumDurationY = 300;
  29728. const momentumDistanceX = velocity.x * momentumDurationX;
  29729. const newPositionX = image.currentX + momentumDistanceX;
  29730. const momentumDistanceY = velocity.y * momentumDurationY;
  29731. const newPositionY = image.currentY + momentumDistanceY;
  29732. // Fix duration
  29733. if (velocity.x !== 0) momentumDurationX = Math.abs((newPositionX - image.currentX) / velocity.x);
  29734. if (velocity.y !== 0) momentumDurationY = Math.abs((newPositionY - image.currentY) / velocity.y);
  29735. const momentumDuration = Math.max(momentumDurationX, momentumDurationY);
  29736. image.currentX = newPositionX;
  29737. image.currentY = newPositionY;
  29738. // Define if we need image drag
  29739. const scaledWidth = image.width * zoom.scale;
  29740. const scaledHeight = image.height * zoom.scale;
  29741. image.minX = Math.min(gesture.slideWidth / 2 - scaledWidth / 2, 0);
  29742. image.maxX = -image.minX;
  29743. image.minY = Math.min(gesture.slideHeight / 2 - scaledHeight / 2, 0);
  29744. image.maxY = -image.minY;
  29745. image.currentX = Math.max(Math.min(image.currentX, image.maxX), image.minX);
  29746. image.currentY = Math.max(Math.min(image.currentY, image.maxY), image.minY);
  29747. gesture.imageWrapEl.style.transitionDuration = `${momentumDuration}ms`;
  29748. gesture.imageWrapEl.style.transform = `translate3d(${image.currentX}px, ${image.currentY}px,0)`;
  29749. }
  29750. function onTransitionEnd() {
  29751. const zoom = swiper.zoom;
  29752. if (gesture.slideEl && swiper.activeIndex !== swiper.slides.indexOf(gesture.slideEl)) {
  29753. if (gesture.imageEl) {
  29754. gesture.imageEl.style.transform = 'translate3d(0,0,0) scale(1)';
  29755. }
  29756. if (gesture.imageWrapEl) {
  29757. gesture.imageWrapEl.style.transform = 'translate3d(0,0,0)';
  29758. }
  29759. gesture.slideEl.classList.remove(`${swiper.params.zoom.zoomedSlideClass}`);
  29760. zoom.scale = 1;
  29761. currentScale = 1;
  29762. gesture.slideEl = undefined;
  29763. gesture.imageEl = undefined;
  29764. gesture.imageWrapEl = undefined;
  29765. gesture.originX = 0;
  29766. gesture.originY = 0;
  29767. }
  29768. }
  29769. function onMouseMove(e) {
  29770. // Only pan if zoomed in and mouse panning is enabled
  29771. if (currentScale <= 1 || !gesture.imageWrapEl) return;
  29772. if (!eventWithinSlide(e) || !eventWithinZoomContainer(e)) return;
  29773. const currentTransform = window.getComputedStyle(gesture.imageWrapEl).transform;
  29774. const matrix = new window.DOMMatrix(currentTransform);
  29775. if (!isPanningWithMouse) {
  29776. isPanningWithMouse = true;
  29777. mousePanStart.x = e.clientX;
  29778. mousePanStart.y = e.clientY;
  29779. image.startX = matrix.e;
  29780. image.startY = matrix.f;
  29781. image.width = gesture.imageEl.offsetWidth || gesture.imageEl.clientWidth;
  29782. image.height = gesture.imageEl.offsetHeight || gesture.imageEl.clientHeight;
  29783. gesture.slideWidth = gesture.slideEl.offsetWidth;
  29784. gesture.slideHeight = gesture.slideEl.offsetHeight;
  29785. return;
  29786. }
  29787. const deltaX = (e.clientX - mousePanStart.x) * mousePanSensitivity;
  29788. const deltaY = (e.clientY - mousePanStart.y) * mousePanSensitivity;
  29789. const scaledWidth = image.width * currentScale;
  29790. const scaledHeight = image.height * currentScale;
  29791. const slideWidth = gesture.slideWidth;
  29792. const slideHeight = gesture.slideHeight;
  29793. const minX = Math.min(slideWidth / 2 - scaledWidth / 2, 0);
  29794. const maxX = -minX;
  29795. const minY = Math.min(slideHeight / 2 - scaledHeight / 2, 0);
  29796. const maxY = -minY;
  29797. const newX = Math.max(Math.min(image.startX + deltaX, maxX), minX);
  29798. const newY = Math.max(Math.min(image.startY + deltaY, maxY), minY);
  29799. gesture.imageWrapEl.style.transitionDuration = '0ms';
  29800. gesture.imageWrapEl.style.transform = `translate3d(${newX}px, ${newY}px, 0)`;
  29801. mousePanStart.x = e.clientX;
  29802. mousePanStart.y = e.clientY;
  29803. image.startX = newX;
  29804. image.startY = newY;
  29805. image.currentX = newX;
  29806. image.currentY = newY;
  29807. }
  29808. function zoomIn(e) {
  29809. const zoom = swiper.zoom;
  29810. const params = swiper.params.zoom;
  29811. if (!gesture.slideEl) {
  29812. if (e && e.target) {
  29813. gesture.slideEl = e.target.closest(`.${swiper.params.slideClass}, swiper-slide`);
  29814. }
  29815. if (!gesture.slideEl) {
  29816. if (swiper.params.virtual && swiper.params.virtual.enabled && swiper.virtual) {
  29817. gesture.slideEl = elementChildren(swiper.slidesEl, `.${swiper.params.slideActiveClass}`)[0];
  29818. } else {
  29819. gesture.slideEl = swiper.slides[swiper.activeIndex];
  29820. }
  29821. }
  29822. let imageEl = gesture.slideEl.querySelector(`.${params.containerClass}`);
  29823. if (imageEl) {
  29824. imageEl = imageEl.querySelectorAll('picture, img, svg, canvas, .swiper-zoom-target')[0];
  29825. }
  29826. gesture.imageEl = imageEl;
  29827. if (imageEl) {
  29828. gesture.imageWrapEl = elementParents(gesture.imageEl, `.${params.containerClass}`)[0];
  29829. } else {
  29830. gesture.imageWrapEl = undefined;
  29831. }
  29832. }
  29833. if (!gesture.imageEl || !gesture.imageWrapEl) return;
  29834. if (swiper.params.cssMode) {
  29835. swiper.wrapperEl.style.overflow = 'hidden';
  29836. swiper.wrapperEl.style.touchAction = 'none';
  29837. }
  29838. gesture.slideEl.classList.add(`${params.zoomedSlideClass}`);
  29839. let touchX;
  29840. let touchY;
  29841. let offsetX;
  29842. let offsetY;
  29843. let diffX;
  29844. let diffY;
  29845. let translateX;
  29846. let translateY;
  29847. let imageWidth;
  29848. let imageHeight;
  29849. let scaledWidth;
  29850. let scaledHeight;
  29851. let translateMinX;
  29852. let translateMinY;
  29853. let translateMaxX;
  29854. let translateMaxY;
  29855. let slideWidth;
  29856. let slideHeight;
  29857. if (typeof image.touchesStart.x === 'undefined' && e) {
  29858. touchX = e.pageX;
  29859. touchY = e.pageY;
  29860. } else {
  29861. touchX = image.touchesStart.x;
  29862. touchY = image.touchesStart.y;
  29863. }
  29864. const prevScale = currentScale;
  29865. const forceZoomRatio = typeof e === 'number' ? e : null;
  29866. if (currentScale === 1 && forceZoomRatio) {
  29867. touchX = undefined;
  29868. touchY = undefined;
  29869. image.touchesStart.x = undefined;
  29870. image.touchesStart.y = undefined;
  29871. }
  29872. const maxRatio = getMaxRatio();
  29873. zoom.scale = forceZoomRatio || maxRatio;
  29874. currentScale = forceZoomRatio || maxRatio;
  29875. if (e && !(currentScale === 1 && forceZoomRatio)) {
  29876. slideWidth = gesture.slideEl.offsetWidth;
  29877. slideHeight = gesture.slideEl.offsetHeight;
  29878. offsetX = elementOffset(gesture.slideEl).left + window.scrollX;
  29879. offsetY = elementOffset(gesture.slideEl).top + window.scrollY;
  29880. diffX = offsetX + slideWidth / 2 - touchX;
  29881. diffY = offsetY + slideHeight / 2 - touchY;
  29882. imageWidth = gesture.imageEl.offsetWidth || gesture.imageEl.clientWidth;
  29883. imageHeight = gesture.imageEl.offsetHeight || gesture.imageEl.clientHeight;
  29884. scaledWidth = imageWidth * zoom.scale;
  29885. scaledHeight = imageHeight * zoom.scale;
  29886. translateMinX = Math.min(slideWidth / 2 - scaledWidth / 2, 0);
  29887. translateMinY = Math.min(slideHeight / 2 - scaledHeight / 2, 0);
  29888. translateMaxX = -translateMinX;
  29889. translateMaxY = -translateMinY;
  29890. if (prevScale > 0 && forceZoomRatio && typeof image.currentX === 'number' && typeof image.currentY === 'number') {
  29891. translateX = image.currentX * zoom.scale / prevScale;
  29892. translateY = image.currentY * zoom.scale / prevScale;
  29893. } else {
  29894. translateX = diffX * zoom.scale;
  29895. translateY = diffY * zoom.scale;
  29896. }
  29897. if (translateX < translateMinX) {
  29898. translateX = translateMinX;
  29899. }
  29900. if (translateX > translateMaxX) {
  29901. translateX = translateMaxX;
  29902. }
  29903. if (translateY < translateMinY) {
  29904. translateY = translateMinY;
  29905. }
  29906. if (translateY > translateMaxY) {
  29907. translateY = translateMaxY;
  29908. }
  29909. } else {
  29910. translateX = 0;
  29911. translateY = 0;
  29912. }
  29913. if (forceZoomRatio && zoom.scale === 1) {
  29914. gesture.originX = 0;
  29915. gesture.originY = 0;
  29916. }
  29917. image.currentX = translateX;
  29918. image.currentY = translateY;
  29919. gesture.imageWrapEl.style.transitionDuration = '300ms';
  29920. gesture.imageWrapEl.style.transform = `translate3d(${translateX}px, ${translateY}px,0)`;
  29921. gesture.imageEl.style.transitionDuration = '300ms';
  29922. gesture.imageEl.style.transform = `translate3d(0,0,0) scale(${zoom.scale})`;
  29923. }
  29924. function zoomOut() {
  29925. const zoom = swiper.zoom;
  29926. const params = swiper.params.zoom;
  29927. if (!gesture.slideEl) {
  29928. if (swiper.params.virtual && swiper.params.virtual.enabled && swiper.virtual) {
  29929. gesture.slideEl = elementChildren(swiper.slidesEl, `.${swiper.params.slideActiveClass}`)[0];
  29930. } else {
  29931. gesture.slideEl = swiper.slides[swiper.activeIndex];
  29932. }
  29933. let imageEl = gesture.slideEl.querySelector(`.${params.containerClass}`);
  29934. if (imageEl) {
  29935. imageEl = imageEl.querySelectorAll('picture, img, svg, canvas, .swiper-zoom-target')[0];
  29936. }
  29937. gesture.imageEl = imageEl;
  29938. if (imageEl) {
  29939. gesture.imageWrapEl = elementParents(gesture.imageEl, `.${params.containerClass}`)[0];
  29940. } else {
  29941. gesture.imageWrapEl = undefined;
  29942. }
  29943. }
  29944. if (!gesture.imageEl || !gesture.imageWrapEl) return;
  29945. if (swiper.params.cssMode) {
  29946. swiper.wrapperEl.style.overflow = '';
  29947. swiper.wrapperEl.style.touchAction = '';
  29948. }
  29949. zoom.scale = 1;
  29950. currentScale = 1;
  29951. image.currentX = undefined;
  29952. image.currentY = undefined;
  29953. image.touchesStart.x = undefined;
  29954. image.touchesStart.y = undefined;
  29955. gesture.imageWrapEl.style.transitionDuration = '300ms';
  29956. gesture.imageWrapEl.style.transform = 'translate3d(0,0,0)';
  29957. gesture.imageEl.style.transitionDuration = '300ms';
  29958. gesture.imageEl.style.transform = 'translate3d(0,0,0) scale(1)';
  29959. gesture.slideEl.classList.remove(`${params.zoomedSlideClass}`);
  29960. gesture.slideEl = undefined;
  29961. gesture.originX = 0;
  29962. gesture.originY = 0;
  29963. if (swiper.params.zoom.panOnMouseMove) {
  29964. mousePanStart = {
  29965. x: 0,
  29966. y: 0
  29967. };
  29968. if (isPanningWithMouse) {
  29969. isPanningWithMouse = false;
  29970. image.startX = 0;
  29971. image.startY = 0;
  29972. }
  29973. }
  29974. }
  29975. // Toggle Zoom
  29976. function zoomToggle(e) {
  29977. const zoom = swiper.zoom;
  29978. if (zoom.scale && zoom.scale !== 1) {
  29979. // Zoom Out
  29980. zoomOut();
  29981. } else {
  29982. // Zoom In
  29983. zoomIn(e);
  29984. }
  29985. }
  29986. function getListeners() {
  29987. const passiveListener = swiper.params.passiveListeners ? {
  29988. passive: true,
  29989. capture: false
  29990. } : false;
  29991. const activeListenerWithCapture = swiper.params.passiveListeners ? {
  29992. passive: false,
  29993. capture: true
  29994. } : true;
  29995. return {
  29996. passiveListener,
  29997. activeListenerWithCapture
  29998. };
  29999. }
  30000. // Attach/Detach Events
  30001. function enable() {
  30002. const zoom = swiper.zoom;
  30003. if (zoom.enabled) return;
  30004. zoom.enabled = true;
  30005. const {
  30006. passiveListener,
  30007. activeListenerWithCapture
  30008. } = getListeners();
  30009. // Scale image
  30010. swiper.wrapperEl.addEventListener('pointerdown', onGestureStart, passiveListener);
  30011. swiper.wrapperEl.addEventListener('pointermove', onGestureChange, activeListenerWithCapture);
  30012. ['pointerup', 'pointercancel', 'pointerout'].forEach(eventName => {
  30013. swiper.wrapperEl.addEventListener(eventName, onGestureEnd, passiveListener);
  30014. });
  30015. // Move image
  30016. swiper.wrapperEl.addEventListener('pointermove', onTouchMove, activeListenerWithCapture);
  30017. }
  30018. function disable() {
  30019. const zoom = swiper.zoom;
  30020. if (!zoom.enabled) return;
  30021. zoom.enabled = false;
  30022. const {
  30023. passiveListener,
  30024. activeListenerWithCapture
  30025. } = getListeners();
  30026. // Scale image
  30027. swiper.wrapperEl.removeEventListener('pointerdown', onGestureStart, passiveListener);
  30028. swiper.wrapperEl.removeEventListener('pointermove', onGestureChange, activeListenerWithCapture);
  30029. ['pointerup', 'pointercancel', 'pointerout'].forEach(eventName => {
  30030. swiper.wrapperEl.removeEventListener(eventName, onGestureEnd, passiveListener);
  30031. });
  30032. // Move image
  30033. swiper.wrapperEl.removeEventListener('pointermove', onTouchMove, activeListenerWithCapture);
  30034. }
  30035. on('init', () => {
  30036. if (swiper.params.zoom.enabled) {
  30037. enable();
  30038. }
  30039. });
  30040. on('destroy', () => {
  30041. disable();
  30042. });
  30043. on('touchStart', (_s, e) => {
  30044. if (!swiper.zoom.enabled) return;
  30045. onTouchStart(e);
  30046. });
  30047. on('touchEnd', (_s, e) => {
  30048. if (!swiper.zoom.enabled) return;
  30049. onTouchEnd();
  30050. });
  30051. on('doubleTap', (_s, e) => {
  30052. if (!swiper.animating && swiper.params.zoom.enabled && swiper.zoom.enabled && swiper.params.zoom.toggle) {
  30053. zoomToggle(e);
  30054. }
  30055. });
  30056. on('transitionEnd', () => {
  30057. if (swiper.zoom.enabled && swiper.params.zoom.enabled) {
  30058. onTransitionEnd();
  30059. }
  30060. });
  30061. on('slideChange', () => {
  30062. if (swiper.zoom.enabled && swiper.params.zoom.enabled && swiper.params.cssMode) {
  30063. onTransitionEnd();
  30064. }
  30065. });
  30066. Object.assign(swiper.zoom, {
  30067. enable,
  30068. disable,
  30069. in: zoomIn,
  30070. out: zoomOut,
  30071. toggle: zoomToggle
  30072. });
  30073. }
  30074. /* eslint no-bitwise: ["error", { "allow": [">>"] }] */
  30075. function Controller(_ref) {
  30076. let {
  30077. swiper,
  30078. extendParams,
  30079. on
  30080. } = _ref;
  30081. extendParams({
  30082. controller: {
  30083. control: undefined,
  30084. inverse: false,
  30085. by: 'slide' // or 'container'
  30086. }
  30087. });
  30088. swiper.controller = {
  30089. control: undefined
  30090. };
  30091. function LinearSpline(x, y) {
  30092. const binarySearch = function search() {
  30093. let maxIndex;
  30094. let minIndex;
  30095. let guess;
  30096. return (array, val) => {
  30097. minIndex = -1;
  30098. maxIndex = array.length;
  30099. while (maxIndex - minIndex > 1) {
  30100. guess = maxIndex + minIndex >> 1;
  30101. if (array[guess] <= val) {
  30102. minIndex = guess;
  30103. } else {
  30104. maxIndex = guess;
  30105. }
  30106. }
  30107. return maxIndex;
  30108. };
  30109. }();
  30110. this.x = x;
  30111. this.y = y;
  30112. this.lastIndex = x.length - 1;
  30113. // Given an x value (x2), return the expected y2 value:
  30114. // (x1,y1) is the known point before given value,
  30115. // (x3,y3) is the known point after given value.
  30116. let i1;
  30117. let i3;
  30118. this.interpolate = function interpolate(x2) {
  30119. if (!x2) return 0;
  30120. // Get the indexes of x1 and x3 (the array indexes before and after given x2):
  30121. i3 = binarySearch(this.x, x2);
  30122. i1 = i3 - 1;
  30123. // We have our indexes i1 & i3, so we can calculate already:
  30124. // y2 := ((x2−x1) × (y3−y1)) ÷ (x3−x1) + y1
  30125. return (x2 - this.x[i1]) * (this.y[i3] - this.y[i1]) / (this.x[i3] - this.x[i1]) + this.y[i1];
  30126. };
  30127. return this;
  30128. }
  30129. function getInterpolateFunction(c) {
  30130. swiper.controller.spline = swiper.params.loop ? new LinearSpline(swiper.slidesGrid, c.slidesGrid) : new LinearSpline(swiper.snapGrid, c.snapGrid);
  30131. }
  30132. function setTranslate(_t, byController) {
  30133. const controlled = swiper.controller.control;
  30134. let multiplier;
  30135. let controlledTranslate;
  30136. const Swiper = swiper.constructor;
  30137. function setControlledTranslate(c) {
  30138. if (c.destroyed) return;
  30139. // this will create an Interpolate function based on the snapGrids
  30140. // x is the Grid of the scrolled scroller and y will be the controlled scroller
  30141. // it makes sense to create this only once and recall it for the interpolation
  30142. // the function does a lot of value caching for performance
  30143. const translate = swiper.rtlTranslate ? -swiper.translate : swiper.translate;
  30144. if (swiper.params.controller.by === 'slide') {
  30145. getInterpolateFunction(c);
  30146. // i am not sure why the values have to be multiplicated this way, tried to invert the snapGrid
  30147. // but it did not work out
  30148. controlledTranslate = -swiper.controller.spline.interpolate(-translate);
  30149. }
  30150. if (!controlledTranslate || swiper.params.controller.by === 'container') {
  30151. multiplier = (c.maxTranslate() - c.minTranslate()) / (swiper.maxTranslate() - swiper.minTranslate());
  30152. if (Number.isNaN(multiplier) || !Number.isFinite(multiplier)) {
  30153. multiplier = 1;
  30154. }
  30155. controlledTranslate = (translate - swiper.minTranslate()) * multiplier + c.minTranslate();
  30156. }
  30157. if (swiper.params.controller.inverse) {
  30158. controlledTranslate = c.maxTranslate() - controlledTranslate;
  30159. }
  30160. c.updateProgress(controlledTranslate);
  30161. c.setTranslate(controlledTranslate, swiper);
  30162. c.updateActiveIndex();
  30163. c.updateSlidesClasses();
  30164. }
  30165. if (Array.isArray(controlled)) {
  30166. for (let i = 0; i < controlled.length; i += 1) {
  30167. if (controlled[i] !== byController && controlled[i] instanceof Swiper) {
  30168. setControlledTranslate(controlled[i]);
  30169. }
  30170. }
  30171. } else if (controlled instanceof Swiper && byController !== controlled) {
  30172. setControlledTranslate(controlled);
  30173. }
  30174. }
  30175. function setTransition(duration, byController) {
  30176. const Swiper = swiper.constructor;
  30177. const controlled = swiper.controller.control;
  30178. let i;
  30179. function setControlledTransition(c) {
  30180. if (c.destroyed) return;
  30181. c.setTransition(duration, swiper);
  30182. if (duration !== 0) {
  30183. c.transitionStart();
  30184. if (c.params.autoHeight) {
  30185. nextTick(() => {
  30186. c.updateAutoHeight();
  30187. });
  30188. }
  30189. elementTransitionEnd(c.wrapperEl, () => {
  30190. if (!controlled) return;
  30191. c.transitionEnd();
  30192. });
  30193. }
  30194. }
  30195. if (Array.isArray(controlled)) {
  30196. for (i = 0; i < controlled.length; i += 1) {
  30197. if (controlled[i] !== byController && controlled[i] instanceof Swiper) {
  30198. setControlledTransition(controlled[i]);
  30199. }
  30200. }
  30201. } else if (controlled instanceof Swiper && byController !== controlled) {
  30202. setControlledTransition(controlled);
  30203. }
  30204. }
  30205. function removeSpline() {
  30206. if (!swiper.controller.control) return;
  30207. if (swiper.controller.spline) {
  30208. swiper.controller.spline = undefined;
  30209. delete swiper.controller.spline;
  30210. }
  30211. }
  30212. on('beforeInit', () => {
  30213. if (typeof window !== 'undefined' && (
  30214. // eslint-disable-line
  30215. typeof swiper.params.controller.control === 'string' || swiper.params.controller.control instanceof HTMLElement)) {
  30216. const controlElements = typeof swiper.params.controller.control === 'string' ? [...document.querySelectorAll(swiper.params.controller.control)] : [swiper.params.controller.control];
  30217. controlElements.forEach(controlElement => {
  30218. if (!swiper.controller.control) swiper.controller.control = [];
  30219. if (controlElement && controlElement.swiper) {
  30220. swiper.controller.control.push(controlElement.swiper);
  30221. } else if (controlElement) {
  30222. const eventName = `${swiper.params.eventsPrefix}init`;
  30223. const onControllerSwiper = e => {
  30224. swiper.controller.control.push(e.detail[0]);
  30225. swiper.update();
  30226. controlElement.removeEventListener(eventName, onControllerSwiper);
  30227. };
  30228. controlElement.addEventListener(eventName, onControllerSwiper);
  30229. }
  30230. });
  30231. return;
  30232. }
  30233. swiper.controller.control = swiper.params.controller.control;
  30234. });
  30235. on('update', () => {
  30236. removeSpline();
  30237. });
  30238. on('resize', () => {
  30239. removeSpline();
  30240. });
  30241. on('observerUpdate', () => {
  30242. removeSpline();
  30243. });
  30244. on('setTranslate', (_s, translate, byController) => {
  30245. if (!swiper.controller.control || swiper.controller.control.destroyed) return;
  30246. swiper.controller.setTranslate(translate, byController);
  30247. });
  30248. on('setTransition', (_s, duration, byController) => {
  30249. if (!swiper.controller.control || swiper.controller.control.destroyed) return;
  30250. swiper.controller.setTransition(duration, byController);
  30251. });
  30252. Object.assign(swiper.controller, {
  30253. setTranslate,
  30254. setTransition
  30255. });
  30256. }
  30257. function A11y(_ref) {
  30258. let {
  30259. swiper,
  30260. extendParams,
  30261. on
  30262. } = _ref;
  30263. extendParams({
  30264. a11y: {
  30265. enabled: true,
  30266. notificationClass: 'swiper-notification',
  30267. prevSlideMessage: 'Previous slide',
  30268. nextSlideMessage: 'Next slide',
  30269. firstSlideMessage: 'This is the first slide',
  30270. lastSlideMessage: 'This is the last slide',
  30271. paginationBulletMessage: 'Go to slide {{index}}',
  30272. slideLabelMessage: '{{index}} / {{slidesLength}}',
  30273. containerMessage: null,
  30274. containerRoleDescriptionMessage: null,
  30275. containerRole: null,
  30276. itemRoleDescriptionMessage: null,
  30277. slideRole: 'group',
  30278. id: null,
  30279. scrollOnFocus: true
  30280. }
  30281. });
  30282. swiper.a11y = {
  30283. clicked: false
  30284. };
  30285. let liveRegion = null;
  30286. let preventFocusHandler;
  30287. let focusTargetSlideEl;
  30288. let visibilityChangedTimestamp = new Date().getTime();
  30289. function notify(message) {
  30290. const notification = liveRegion;
  30291. if (notification.length === 0) return;
  30292. setInnerHTML(notification, message);
  30293. }
  30294. function getRandomNumber(size) {
  30295. if (size === void 0) {
  30296. size = 16;
  30297. }
  30298. const randomChar = () => Math.round(16 * Math.random()).toString(16);
  30299. return 'x'.repeat(size).replace(/x/g, randomChar);
  30300. }
  30301. function makeElFocusable(el) {
  30302. el = makeElementsArray(el);
  30303. el.forEach(subEl => {
  30304. subEl.setAttribute('tabIndex', '0');
  30305. });
  30306. }
  30307. function makeElNotFocusable(el) {
  30308. el = makeElementsArray(el);
  30309. el.forEach(subEl => {
  30310. subEl.setAttribute('tabIndex', '-1');
  30311. });
  30312. }
  30313. function addElRole(el, role) {
  30314. el = makeElementsArray(el);
  30315. el.forEach(subEl => {
  30316. subEl.setAttribute('role', role);
  30317. });
  30318. }
  30319. function addElRoleDescription(el, description) {
  30320. el = makeElementsArray(el);
  30321. el.forEach(subEl => {
  30322. subEl.setAttribute('aria-roledescription', description);
  30323. });
  30324. }
  30325. function addElControls(el, controls) {
  30326. el = makeElementsArray(el);
  30327. el.forEach(subEl => {
  30328. subEl.setAttribute('aria-controls', controls);
  30329. });
  30330. }
  30331. function addElLabel(el, label) {
  30332. el = makeElementsArray(el);
  30333. el.forEach(subEl => {
  30334. subEl.setAttribute('aria-label', label);
  30335. });
  30336. }
  30337. function addElId(el, id) {
  30338. el = makeElementsArray(el);
  30339. el.forEach(subEl => {
  30340. subEl.setAttribute('id', id);
  30341. });
  30342. }
  30343. function addElLive(el, live) {
  30344. el = makeElementsArray(el);
  30345. el.forEach(subEl => {
  30346. subEl.setAttribute('aria-live', live);
  30347. });
  30348. }
  30349. function disableEl(el) {
  30350. el = makeElementsArray(el);
  30351. el.forEach(subEl => {
  30352. subEl.setAttribute('aria-disabled', true);
  30353. });
  30354. }
  30355. function enableEl(el) {
  30356. el = makeElementsArray(el);
  30357. el.forEach(subEl => {
  30358. subEl.setAttribute('aria-disabled', false);
  30359. });
  30360. }
  30361. function onEnterOrSpaceKey(e) {
  30362. if (e.keyCode !== 13 && e.keyCode !== 32) return;
  30363. const params = swiper.params.a11y;
  30364. const targetEl = e.target;
  30365. if (swiper.pagination && swiper.pagination.el && (targetEl === swiper.pagination.el || swiper.pagination.el.contains(e.target))) {
  30366. if (!e.target.matches(classesToSelector(swiper.params.pagination.bulletClass))) return;
  30367. }
  30368. if (swiper.navigation && swiper.navigation.prevEl && swiper.navigation.nextEl) {
  30369. const prevEls = makeElementsArray(swiper.navigation.prevEl);
  30370. const nextEls = makeElementsArray(swiper.navigation.nextEl);
  30371. if (nextEls.includes(targetEl)) {
  30372. if (!(swiper.isEnd && !swiper.params.loop)) {
  30373. swiper.slideNext();
  30374. }
  30375. if (swiper.isEnd) {
  30376. notify(params.lastSlideMessage);
  30377. } else {
  30378. notify(params.nextSlideMessage);
  30379. }
  30380. }
  30381. if (prevEls.includes(targetEl)) {
  30382. if (!(swiper.isBeginning && !swiper.params.loop)) {
  30383. swiper.slidePrev();
  30384. }
  30385. if (swiper.isBeginning) {
  30386. notify(params.firstSlideMessage);
  30387. } else {
  30388. notify(params.prevSlideMessage);
  30389. }
  30390. }
  30391. }
  30392. if (swiper.pagination && targetEl.matches(classesToSelector(swiper.params.pagination.bulletClass))) {
  30393. targetEl.click();
  30394. }
  30395. }
  30396. function updateNavigation() {
  30397. if (swiper.params.loop || swiper.params.rewind || !swiper.navigation) return;
  30398. const {
  30399. nextEl,
  30400. prevEl
  30401. } = swiper.navigation;
  30402. if (prevEl) {
  30403. if (swiper.isBeginning) {
  30404. disableEl(prevEl);
  30405. makeElNotFocusable(prevEl);
  30406. } else {
  30407. enableEl(prevEl);
  30408. makeElFocusable(prevEl);
  30409. }
  30410. }
  30411. if (nextEl) {
  30412. if (swiper.isEnd) {
  30413. disableEl(nextEl);
  30414. makeElNotFocusable(nextEl);
  30415. } else {
  30416. enableEl(nextEl);
  30417. makeElFocusable(nextEl);
  30418. }
  30419. }
  30420. }
  30421. function hasPagination() {
  30422. return swiper.pagination && swiper.pagination.bullets && swiper.pagination.bullets.length;
  30423. }
  30424. function hasClickablePagination() {
  30425. return hasPagination() && swiper.params.pagination.clickable;
  30426. }
  30427. function updatePagination() {
  30428. const params = swiper.params.a11y;
  30429. if (!hasPagination()) return;
  30430. swiper.pagination.bullets.forEach(bulletEl => {
  30431. if (swiper.params.pagination.clickable) {
  30432. makeElFocusable(bulletEl);
  30433. if (!swiper.params.pagination.renderBullet) {
  30434. addElRole(bulletEl, 'button');
  30435. addElLabel(bulletEl, params.paginationBulletMessage.replace(/\{\{index\}\}/, elementIndex(bulletEl) + 1));
  30436. }
  30437. }
  30438. if (bulletEl.matches(classesToSelector(swiper.params.pagination.bulletActiveClass))) {
  30439. bulletEl.setAttribute('aria-current', 'true');
  30440. } else {
  30441. bulletEl.removeAttribute('aria-current');
  30442. }
  30443. });
  30444. }
  30445. const initNavEl = (el, wrapperId, message) => {
  30446. makeElFocusable(el);
  30447. if (el.tagName !== 'BUTTON') {
  30448. addElRole(el, 'button');
  30449. el.addEventListener('keydown', onEnterOrSpaceKey);
  30450. }
  30451. addElLabel(el, message);
  30452. addElControls(el, wrapperId);
  30453. };
  30454. const handlePointerDown = e => {
  30455. if (focusTargetSlideEl && focusTargetSlideEl !== e.target && !focusTargetSlideEl.contains(e.target)) {
  30456. preventFocusHandler = true;
  30457. }
  30458. swiper.a11y.clicked = true;
  30459. };
  30460. const handlePointerUp = () => {
  30461. preventFocusHandler = false;
  30462. requestAnimationFrame(() => {
  30463. requestAnimationFrame(() => {
  30464. if (!swiper.destroyed) {
  30465. swiper.a11y.clicked = false;
  30466. }
  30467. });
  30468. });
  30469. };
  30470. const onVisibilityChange = e => {
  30471. visibilityChangedTimestamp = new Date().getTime();
  30472. };
  30473. const handleFocus = e => {
  30474. if (swiper.a11y.clicked || !swiper.params.a11y.scrollOnFocus) return;
  30475. if (new Date().getTime() - visibilityChangedTimestamp < 100) return;
  30476. const slideEl = e.target.closest(`.${swiper.params.slideClass}, swiper-slide`);
  30477. if (!slideEl || !swiper.slides.includes(slideEl)) return;
  30478. focusTargetSlideEl = slideEl;
  30479. const isActive = swiper.slides.indexOf(slideEl) === swiper.activeIndex;
  30480. const isVisible = swiper.params.watchSlidesProgress && swiper.visibleSlides && swiper.visibleSlides.includes(slideEl);
  30481. if (isActive || isVisible) return;
  30482. if (e.sourceCapabilities && e.sourceCapabilities.firesTouchEvents) return;
  30483. if (swiper.isHorizontal()) {
  30484. swiper.el.scrollLeft = 0;
  30485. } else {
  30486. swiper.el.scrollTop = 0;
  30487. }
  30488. requestAnimationFrame(() => {
  30489. if (preventFocusHandler) return;
  30490. if (swiper.params.loop) {
  30491. swiper.slideToLoop(swiper.getSlideIndexWhenGrid(parseInt(slideEl.getAttribute('data-swiper-slide-index'))), 0);
  30492. } else {
  30493. swiper.slideTo(swiper.getSlideIndexWhenGrid(swiper.slides.indexOf(slideEl)), 0);
  30494. }
  30495. preventFocusHandler = false;
  30496. });
  30497. };
  30498. const initSlides = () => {
  30499. const params = swiper.params.a11y;
  30500. if (params.itemRoleDescriptionMessage) {
  30501. addElRoleDescription(swiper.slides, params.itemRoleDescriptionMessage);
  30502. }
  30503. if (params.slideRole) {
  30504. addElRole(swiper.slides, params.slideRole);
  30505. }
  30506. const slidesLength = swiper.slides.length;
  30507. if (params.slideLabelMessage) {
  30508. swiper.slides.forEach((slideEl, index) => {
  30509. const slideIndex = swiper.params.loop ? parseInt(slideEl.getAttribute('data-swiper-slide-index'), 10) : index;
  30510. const ariaLabelMessage = params.slideLabelMessage.replace(/\{\{index\}\}/, slideIndex + 1).replace(/\{\{slidesLength\}\}/, slidesLength);
  30511. addElLabel(slideEl, ariaLabelMessage);
  30512. });
  30513. }
  30514. };
  30515. const init = () => {
  30516. const params = swiper.params.a11y;
  30517. swiper.el.append(liveRegion);
  30518. // Container
  30519. const containerEl = swiper.el;
  30520. if (params.containerRoleDescriptionMessage) {
  30521. addElRoleDescription(containerEl, params.containerRoleDescriptionMessage);
  30522. }
  30523. if (params.containerMessage) {
  30524. addElLabel(containerEl, params.containerMessage);
  30525. }
  30526. if (params.containerRole) {
  30527. addElRole(containerEl, params.containerRole);
  30528. }
  30529. // Wrapper
  30530. const wrapperEl = swiper.wrapperEl;
  30531. const wrapperId = params.id || wrapperEl.getAttribute('id') || `swiper-wrapper-${getRandomNumber(16)}`;
  30532. const live = swiper.params.autoplay && swiper.params.autoplay.enabled ? 'off' : 'polite';
  30533. addElId(wrapperEl, wrapperId);
  30534. addElLive(wrapperEl, live);
  30535. // Slide
  30536. initSlides();
  30537. // Navigation
  30538. let {
  30539. nextEl,
  30540. prevEl
  30541. } = swiper.navigation ? swiper.navigation : {};
  30542. nextEl = makeElementsArray(nextEl);
  30543. prevEl = makeElementsArray(prevEl);
  30544. if (nextEl) {
  30545. nextEl.forEach(el => initNavEl(el, wrapperId, params.nextSlideMessage));
  30546. }
  30547. if (prevEl) {
  30548. prevEl.forEach(el => initNavEl(el, wrapperId, params.prevSlideMessage));
  30549. }
  30550. // Pagination
  30551. if (hasClickablePagination()) {
  30552. const paginationEl = makeElementsArray(swiper.pagination.el);
  30553. paginationEl.forEach(el => {
  30554. el.addEventListener('keydown', onEnterOrSpaceKey);
  30555. });
  30556. }
  30557. // Tab focus
  30558. const document = getDocument();
  30559. document.addEventListener('visibilitychange', onVisibilityChange);
  30560. swiper.el.addEventListener('focus', handleFocus, true);
  30561. swiper.el.addEventListener('focus', handleFocus, true);
  30562. swiper.el.addEventListener('pointerdown', handlePointerDown, true);
  30563. swiper.el.addEventListener('pointerup', handlePointerUp, true);
  30564. };
  30565. function destroy() {
  30566. if (liveRegion) liveRegion.remove();
  30567. let {
  30568. nextEl,
  30569. prevEl
  30570. } = swiper.navigation ? swiper.navigation : {};
  30571. nextEl = makeElementsArray(nextEl);
  30572. prevEl = makeElementsArray(prevEl);
  30573. if (nextEl) {
  30574. nextEl.forEach(el => el.removeEventListener('keydown', onEnterOrSpaceKey));
  30575. }
  30576. if (prevEl) {
  30577. prevEl.forEach(el => el.removeEventListener('keydown', onEnterOrSpaceKey));
  30578. }
  30579. // Pagination
  30580. if (hasClickablePagination()) {
  30581. const paginationEl = makeElementsArray(swiper.pagination.el);
  30582. paginationEl.forEach(el => {
  30583. el.removeEventListener('keydown', onEnterOrSpaceKey);
  30584. });
  30585. }
  30586. const document = getDocument();
  30587. document.removeEventListener('visibilitychange', onVisibilityChange);
  30588. // Tab focus
  30589. if (swiper.el && typeof swiper.el !== 'string') {
  30590. swiper.el.removeEventListener('focus', handleFocus, true);
  30591. swiper.el.removeEventListener('pointerdown', handlePointerDown, true);
  30592. swiper.el.removeEventListener('pointerup', handlePointerUp, true);
  30593. }
  30594. }
  30595. on('beforeInit', () => {
  30596. liveRegion = createElement('span', swiper.params.a11y.notificationClass);
  30597. liveRegion.setAttribute('aria-live', 'assertive');
  30598. liveRegion.setAttribute('aria-atomic', 'true');
  30599. });
  30600. on('afterInit', () => {
  30601. if (!swiper.params.a11y.enabled) return;
  30602. init();
  30603. });
  30604. on('slidesLengthChange snapGridLengthChange slidesGridLengthChange', () => {
  30605. if (!swiper.params.a11y.enabled) return;
  30606. initSlides();
  30607. });
  30608. on('fromEdge toEdge afterInit lock unlock', () => {
  30609. if (!swiper.params.a11y.enabled) return;
  30610. updateNavigation();
  30611. });
  30612. on('paginationUpdate', () => {
  30613. if (!swiper.params.a11y.enabled) return;
  30614. updatePagination();
  30615. });
  30616. on('destroy', () => {
  30617. if (!swiper.params.a11y.enabled) return;
  30618. destroy();
  30619. });
  30620. }
  30621. function History(_ref) {
  30622. let {
  30623. swiper,
  30624. extendParams,
  30625. on
  30626. } = _ref;
  30627. extendParams({
  30628. history: {
  30629. enabled: false,
  30630. root: '',
  30631. replaceState: false,
  30632. key: 'slides',
  30633. keepQuery: false
  30634. }
  30635. });
  30636. let initialized = false;
  30637. let paths = {};
  30638. const slugify = text => {
  30639. return text.toString().replace(/\s+/g, '-').replace(/[^\w-]+/g, '').replace(/--+/g, '-').replace(/^-+/, '').replace(/-+$/, '');
  30640. };
  30641. const getPathValues = urlOverride => {
  30642. const window = getWindow();
  30643. let location;
  30644. if (urlOverride) {
  30645. location = new URL(urlOverride);
  30646. } else {
  30647. location = window.location;
  30648. }
  30649. const pathArray = location.pathname.slice(1).split('/').filter(part => part !== '');
  30650. const total = pathArray.length;
  30651. const key = pathArray[total - 2];
  30652. const value = pathArray[total - 1];
  30653. return {
  30654. key,
  30655. value
  30656. };
  30657. };
  30658. const setHistory = (key, index) => {
  30659. const window = getWindow();
  30660. if (!initialized || !swiper.params.history.enabled) return;
  30661. let location;
  30662. if (swiper.params.url) {
  30663. location = new URL(swiper.params.url);
  30664. } else {
  30665. location = window.location;
  30666. }
  30667. const slide = swiper.virtual && swiper.params.virtual.enabled ? swiper.slidesEl.querySelector(`[data-swiper-slide-index="${index}"]`) : swiper.slides[index];
  30668. let value = slugify(slide.getAttribute('data-history'));
  30669. if (swiper.params.history.root.length > 0) {
  30670. let root = swiper.params.history.root;
  30671. if (root[root.length - 1] === '/') root = root.slice(0, root.length - 1);
  30672. value = `${root}/${key ? `${key}/` : ''}${value}`;
  30673. } else if (!location.pathname.includes(key)) {
  30674. value = `${key ? `${key}/` : ''}${value}`;
  30675. }
  30676. if (swiper.params.history.keepQuery) {
  30677. value += location.search;
  30678. }
  30679. const currentState = window.history.state;
  30680. if (currentState && currentState.value === value) {
  30681. return;
  30682. }
  30683. if (swiper.params.history.replaceState) {
  30684. window.history.replaceState({
  30685. value
  30686. }, null, value);
  30687. } else {
  30688. window.history.pushState({
  30689. value
  30690. }, null, value);
  30691. }
  30692. };
  30693. const scrollToSlide = (speed, value, runCallbacks) => {
  30694. if (value) {
  30695. for (let i = 0, length = swiper.slides.length; i < length; i += 1) {
  30696. const slide = swiper.slides[i];
  30697. const slideHistory = slugify(slide.getAttribute('data-history'));
  30698. if (slideHistory === value) {
  30699. const index = swiper.getSlideIndex(slide);
  30700. swiper.slideTo(index, speed, runCallbacks);
  30701. }
  30702. }
  30703. } else {
  30704. swiper.slideTo(0, speed, runCallbacks);
  30705. }
  30706. };
  30707. const setHistoryPopState = () => {
  30708. paths = getPathValues(swiper.params.url);
  30709. scrollToSlide(swiper.params.speed, paths.value, false);
  30710. };
  30711. const init = () => {
  30712. const window = getWindow();
  30713. if (!swiper.params.history) return;
  30714. if (!window.history || !window.history.pushState) {
  30715. swiper.params.history.enabled = false;
  30716. swiper.params.hashNavigation.enabled = true;
  30717. return;
  30718. }
  30719. initialized = true;
  30720. paths = getPathValues(swiper.params.url);
  30721. if (!paths.key && !paths.value) {
  30722. if (!swiper.params.history.replaceState) {
  30723. window.addEventListener('popstate', setHistoryPopState);
  30724. }
  30725. return;
  30726. }
  30727. scrollToSlide(0, paths.value, swiper.params.runCallbacksOnInit);
  30728. if (!swiper.params.history.replaceState) {
  30729. window.addEventListener('popstate', setHistoryPopState);
  30730. }
  30731. };
  30732. const destroy = () => {
  30733. const window = getWindow();
  30734. if (!swiper.params.history.replaceState) {
  30735. window.removeEventListener('popstate', setHistoryPopState);
  30736. }
  30737. };
  30738. on('init', () => {
  30739. if (swiper.params.history.enabled) {
  30740. init();
  30741. }
  30742. });
  30743. on('destroy', () => {
  30744. if (swiper.params.history.enabled) {
  30745. destroy();
  30746. }
  30747. });
  30748. on('transitionEnd _freeModeNoMomentumRelease', () => {
  30749. if (initialized) {
  30750. setHistory(swiper.params.history.key, swiper.activeIndex);
  30751. }
  30752. });
  30753. on('slideChange', () => {
  30754. if (initialized && swiper.params.cssMode) {
  30755. setHistory(swiper.params.history.key, swiper.activeIndex);
  30756. }
  30757. });
  30758. }
  30759. function HashNavigation(_ref) {
  30760. let {
  30761. swiper,
  30762. extendParams,
  30763. emit,
  30764. on
  30765. } = _ref;
  30766. let initialized = false;
  30767. const document = getDocument();
  30768. const window = getWindow();
  30769. extendParams({
  30770. hashNavigation: {
  30771. enabled: false,
  30772. replaceState: false,
  30773. watchState: false,
  30774. getSlideIndex(_s, hash) {
  30775. if (swiper.virtual && swiper.params.virtual.enabled) {
  30776. const slideWithHash = swiper.slides.find(slideEl => slideEl.getAttribute('data-hash') === hash);
  30777. if (!slideWithHash) return 0;
  30778. const index = parseInt(slideWithHash.getAttribute('data-swiper-slide-index'), 10);
  30779. return index;
  30780. }
  30781. return swiper.getSlideIndex(elementChildren(swiper.slidesEl, `.${swiper.params.slideClass}[data-hash="${hash}"], swiper-slide[data-hash="${hash}"]`)[0]);
  30782. }
  30783. }
  30784. });
  30785. const onHashChange = () => {
  30786. emit('hashChange');
  30787. const newHash = document.location.hash.replace('#', '');
  30788. const activeSlideEl = swiper.virtual && swiper.params.virtual.enabled ? swiper.slidesEl.querySelector(`[data-swiper-slide-index="${swiper.activeIndex}"]`) : swiper.slides[swiper.activeIndex];
  30789. const activeSlideHash = activeSlideEl ? activeSlideEl.getAttribute('data-hash') : '';
  30790. if (newHash !== activeSlideHash) {
  30791. const newIndex = swiper.params.hashNavigation.getSlideIndex(swiper, newHash);
  30792. if (typeof newIndex === 'undefined' || Number.isNaN(newIndex)) return;
  30793. swiper.slideTo(newIndex);
  30794. }
  30795. };
  30796. const setHash = () => {
  30797. if (!initialized || !swiper.params.hashNavigation.enabled) return;
  30798. const activeSlideEl = swiper.virtual && swiper.params.virtual.enabled ? swiper.slidesEl.querySelector(`[data-swiper-slide-index="${swiper.activeIndex}"]`) : swiper.slides[swiper.activeIndex];
  30799. const activeSlideHash = activeSlideEl ? activeSlideEl.getAttribute('data-hash') || activeSlideEl.getAttribute('data-history') : '';
  30800. if (swiper.params.hashNavigation.replaceState && window.history && window.history.replaceState) {
  30801. window.history.replaceState(null, null, `#${activeSlideHash}` || '');
  30802. emit('hashSet');
  30803. } else {
  30804. document.location.hash = activeSlideHash || '';
  30805. emit('hashSet');
  30806. }
  30807. };
  30808. const init = () => {
  30809. if (!swiper.params.hashNavigation.enabled || swiper.params.history && swiper.params.history.enabled) return;
  30810. initialized = true;
  30811. const hash = document.location.hash.replace('#', '');
  30812. if (hash) {
  30813. const speed = 0;
  30814. const index = swiper.params.hashNavigation.getSlideIndex(swiper, hash);
  30815. swiper.slideTo(index || 0, speed, swiper.params.runCallbacksOnInit, true);
  30816. }
  30817. if (swiper.params.hashNavigation.watchState) {
  30818. window.addEventListener('hashchange', onHashChange);
  30819. }
  30820. };
  30821. const destroy = () => {
  30822. if (swiper.params.hashNavigation.watchState) {
  30823. window.removeEventListener('hashchange', onHashChange);
  30824. }
  30825. };
  30826. on('init', () => {
  30827. if (swiper.params.hashNavigation.enabled) {
  30828. init();
  30829. }
  30830. });
  30831. on('destroy', () => {
  30832. if (swiper.params.hashNavigation.enabled) {
  30833. destroy();
  30834. }
  30835. });
  30836. on('transitionEnd _freeModeNoMomentumRelease', () => {
  30837. if (initialized) {
  30838. setHash();
  30839. }
  30840. });
  30841. on('slideChange', () => {
  30842. if (initialized && swiper.params.cssMode) {
  30843. setHash();
  30844. }
  30845. });
  30846. }
  30847. /* eslint no-underscore-dangle: "off" */
  30848. /* eslint no-use-before-define: "off" */
  30849. function Autoplay(_ref) {
  30850. let {
  30851. swiper,
  30852. extendParams,
  30853. on,
  30854. emit,
  30855. params
  30856. } = _ref;
  30857. swiper.autoplay = {
  30858. running: false,
  30859. paused: false,
  30860. timeLeft: 0
  30861. };
  30862. extendParams({
  30863. autoplay: {
  30864. enabled: false,
  30865. delay: 3000,
  30866. waitForTransition: true,
  30867. disableOnInteraction: false,
  30868. stopOnLastSlide: false,
  30869. reverseDirection: false,
  30870. pauseOnMouseEnter: false
  30871. }
  30872. });
  30873. let timeout;
  30874. let raf;
  30875. let autoplayDelayTotal = params && params.autoplay ? params.autoplay.delay : 3000;
  30876. let autoplayDelayCurrent = params && params.autoplay ? params.autoplay.delay : 3000;
  30877. let autoplayTimeLeft;
  30878. let autoplayStartTime = new Date().getTime();
  30879. let wasPaused;
  30880. let isTouched;
  30881. let pausedByTouch;
  30882. let touchStartTimeout;
  30883. let slideChanged;
  30884. let pausedByInteraction;
  30885. let pausedByPointerEnter;
  30886. function onTransitionEnd(e) {
  30887. if (!swiper || swiper.destroyed || !swiper.wrapperEl) return;
  30888. if (e.target !== swiper.wrapperEl) return;
  30889. swiper.wrapperEl.removeEventListener('transitionend', onTransitionEnd);
  30890. if (pausedByPointerEnter || e.detail && e.detail.bySwiperTouchMove) {
  30891. return;
  30892. }
  30893. resume();
  30894. }
  30895. const calcTimeLeft = () => {
  30896. if (swiper.destroyed || !swiper.autoplay.running) return;
  30897. if (swiper.autoplay.paused) {
  30898. wasPaused = true;
  30899. } else if (wasPaused) {
  30900. autoplayDelayCurrent = autoplayTimeLeft;
  30901. wasPaused = false;
  30902. }
  30903. const timeLeft = swiper.autoplay.paused ? autoplayTimeLeft : autoplayStartTime + autoplayDelayCurrent - new Date().getTime();
  30904. swiper.autoplay.timeLeft = timeLeft;
  30905. emit('autoplayTimeLeft', timeLeft, timeLeft / autoplayDelayTotal);
  30906. raf = requestAnimationFrame(() => {
  30907. calcTimeLeft();
  30908. });
  30909. };
  30910. const getSlideDelay = () => {
  30911. let activeSlideEl;
  30912. if (swiper.virtual && swiper.params.virtual.enabled) {
  30913. activeSlideEl = swiper.slides.find(slideEl => slideEl.classList.contains('swiper-slide-active'));
  30914. } else {
  30915. activeSlideEl = swiper.slides[swiper.activeIndex];
  30916. }
  30917. if (!activeSlideEl) return undefined;
  30918. const currentSlideDelay = parseInt(activeSlideEl.getAttribute('data-swiper-autoplay'), 10);
  30919. return currentSlideDelay;
  30920. };
  30921. const run = delayForce => {
  30922. if (swiper.destroyed || !swiper.autoplay.running) return;
  30923. cancelAnimationFrame(raf);
  30924. calcTimeLeft();
  30925. let delay = typeof delayForce === 'undefined' ? swiper.params.autoplay.delay : delayForce;
  30926. autoplayDelayTotal = swiper.params.autoplay.delay;
  30927. autoplayDelayCurrent = swiper.params.autoplay.delay;
  30928. const currentSlideDelay = getSlideDelay();
  30929. if (!Number.isNaN(currentSlideDelay) && currentSlideDelay > 0 && typeof delayForce === 'undefined') {
  30930. delay = currentSlideDelay;
  30931. autoplayDelayTotal = currentSlideDelay;
  30932. autoplayDelayCurrent = currentSlideDelay;
  30933. }
  30934. autoplayTimeLeft = delay;
  30935. const speed = swiper.params.speed;
  30936. const proceed = () => {
  30937. if (!swiper || swiper.destroyed) return;
  30938. if (swiper.params.autoplay.reverseDirection) {
  30939. if (!swiper.isBeginning || swiper.params.loop || swiper.params.rewind) {
  30940. swiper.slidePrev(speed, true, true);
  30941. emit('autoplay');
  30942. } else if (!swiper.params.autoplay.stopOnLastSlide) {
  30943. swiper.slideTo(swiper.slides.length - 1, speed, true, true);
  30944. emit('autoplay');
  30945. }
  30946. } else {
  30947. if (!swiper.isEnd || swiper.params.loop || swiper.params.rewind) {
  30948. swiper.slideNext(speed, true, true);
  30949. emit('autoplay');
  30950. } else if (!swiper.params.autoplay.stopOnLastSlide) {
  30951. swiper.slideTo(0, speed, true, true);
  30952. emit('autoplay');
  30953. }
  30954. }
  30955. if (swiper.params.cssMode) {
  30956. autoplayStartTime = new Date().getTime();
  30957. requestAnimationFrame(() => {
  30958. run();
  30959. });
  30960. }
  30961. };
  30962. if (delay > 0) {
  30963. clearTimeout(timeout);
  30964. timeout = setTimeout(() => {
  30965. proceed();
  30966. }, delay);
  30967. } else {
  30968. requestAnimationFrame(() => {
  30969. proceed();
  30970. });
  30971. }
  30972. // eslint-disable-next-line
  30973. return delay;
  30974. };
  30975. const start = () => {
  30976. autoplayStartTime = new Date().getTime();
  30977. swiper.autoplay.running = true;
  30978. run();
  30979. emit('autoplayStart');
  30980. };
  30981. const stop = () => {
  30982. swiper.autoplay.running = false;
  30983. clearTimeout(timeout);
  30984. cancelAnimationFrame(raf);
  30985. emit('autoplayStop');
  30986. };
  30987. const pause = (internal, reset) => {
  30988. if (swiper.destroyed || !swiper.autoplay.running) return;
  30989. clearTimeout(timeout);
  30990. if (!internal) {
  30991. pausedByInteraction = true;
  30992. }
  30993. const proceed = () => {
  30994. emit('autoplayPause');
  30995. if (swiper.params.autoplay.waitForTransition) {
  30996. swiper.wrapperEl.addEventListener('transitionend', onTransitionEnd);
  30997. } else {
  30998. resume();
  30999. }
  31000. };
  31001. swiper.autoplay.paused = true;
  31002. if (reset) {
  31003. if (slideChanged) {
  31004. autoplayTimeLeft = swiper.params.autoplay.delay;
  31005. }
  31006. slideChanged = false;
  31007. proceed();
  31008. return;
  31009. }
  31010. const delay = autoplayTimeLeft || swiper.params.autoplay.delay;
  31011. autoplayTimeLeft = delay - (new Date().getTime() - autoplayStartTime);
  31012. if (swiper.isEnd && autoplayTimeLeft < 0 && !swiper.params.loop) return;
  31013. if (autoplayTimeLeft < 0) autoplayTimeLeft = 0;
  31014. proceed();
  31015. };
  31016. const resume = () => {
  31017. if (swiper.isEnd && autoplayTimeLeft < 0 && !swiper.params.loop || swiper.destroyed || !swiper.autoplay.running) return;
  31018. autoplayStartTime = new Date().getTime();
  31019. if (pausedByInteraction) {
  31020. pausedByInteraction = false;
  31021. run(autoplayTimeLeft);
  31022. } else {
  31023. run();
  31024. }
  31025. swiper.autoplay.paused = false;
  31026. emit('autoplayResume');
  31027. };
  31028. const onVisibilityChange = () => {
  31029. if (swiper.destroyed || !swiper.autoplay.running) return;
  31030. const document = getDocument();
  31031. if (document.visibilityState === 'hidden') {
  31032. pausedByInteraction = true;
  31033. pause(true);
  31034. }
  31035. if (document.visibilityState === 'visible') {
  31036. resume();
  31037. }
  31038. };
  31039. const onPointerEnter = e => {
  31040. if (e.pointerType !== 'mouse') return;
  31041. pausedByInteraction = true;
  31042. pausedByPointerEnter = true;
  31043. if (swiper.animating || swiper.autoplay.paused) return;
  31044. pause(true);
  31045. };
  31046. const onPointerLeave = e => {
  31047. if (e.pointerType !== 'mouse') return;
  31048. pausedByPointerEnter = false;
  31049. if (swiper.autoplay.paused) {
  31050. resume();
  31051. }
  31052. };
  31053. const attachMouseEvents = () => {
  31054. if (swiper.params.autoplay.pauseOnMouseEnter) {
  31055. swiper.el.addEventListener('pointerenter', onPointerEnter);
  31056. swiper.el.addEventListener('pointerleave', onPointerLeave);
  31057. }
  31058. };
  31059. const detachMouseEvents = () => {
  31060. if (swiper.el && typeof swiper.el !== 'string') {
  31061. swiper.el.removeEventListener('pointerenter', onPointerEnter);
  31062. swiper.el.removeEventListener('pointerleave', onPointerLeave);
  31063. }
  31064. };
  31065. const attachDocumentEvents = () => {
  31066. const document = getDocument();
  31067. document.addEventListener('visibilitychange', onVisibilityChange);
  31068. };
  31069. const detachDocumentEvents = () => {
  31070. const document = getDocument();
  31071. document.removeEventListener('visibilitychange', onVisibilityChange);
  31072. };
  31073. on('init', () => {
  31074. if (swiper.params.autoplay.enabled) {
  31075. attachMouseEvents();
  31076. attachDocumentEvents();
  31077. start();
  31078. }
  31079. });
  31080. on('destroy', () => {
  31081. detachMouseEvents();
  31082. detachDocumentEvents();
  31083. if (swiper.autoplay.running) {
  31084. stop();
  31085. }
  31086. });
  31087. on('_freeModeStaticRelease', () => {
  31088. if (pausedByTouch || pausedByInteraction) {
  31089. resume();
  31090. }
  31091. });
  31092. on('_freeModeNoMomentumRelease', () => {
  31093. if (!swiper.params.autoplay.disableOnInteraction) {
  31094. pause(true, true);
  31095. } else {
  31096. stop();
  31097. }
  31098. });
  31099. on('beforeTransitionStart', (_s, speed, internal) => {
  31100. if (swiper.destroyed || !swiper.autoplay.running) return;
  31101. if (internal || !swiper.params.autoplay.disableOnInteraction) {
  31102. pause(true, true);
  31103. } else {
  31104. stop();
  31105. }
  31106. });
  31107. on('sliderFirstMove', () => {
  31108. if (swiper.destroyed || !swiper.autoplay.running) return;
  31109. if (swiper.params.autoplay.disableOnInteraction) {
  31110. stop();
  31111. return;
  31112. }
  31113. isTouched = true;
  31114. pausedByTouch = false;
  31115. pausedByInteraction = false;
  31116. touchStartTimeout = setTimeout(() => {
  31117. pausedByInteraction = true;
  31118. pausedByTouch = true;
  31119. pause(true);
  31120. }, 200);
  31121. });
  31122. on('touchEnd', () => {
  31123. if (swiper.destroyed || !swiper.autoplay.running || !isTouched) return;
  31124. clearTimeout(touchStartTimeout);
  31125. clearTimeout(timeout);
  31126. if (swiper.params.autoplay.disableOnInteraction) {
  31127. pausedByTouch = false;
  31128. isTouched = false;
  31129. return;
  31130. }
  31131. if (pausedByTouch && swiper.params.cssMode) resume();
  31132. pausedByTouch = false;
  31133. isTouched = false;
  31134. });
  31135. on('slideChange', () => {
  31136. if (swiper.destroyed || !swiper.autoplay.running) return;
  31137. slideChanged = true;
  31138. });
  31139. Object.assign(swiper.autoplay, {
  31140. start,
  31141. stop,
  31142. pause,
  31143. resume
  31144. });
  31145. }
  31146. function Thumb(_ref) {
  31147. let {
  31148. swiper,
  31149. extendParams,
  31150. on
  31151. } = _ref;
  31152. extendParams({
  31153. thumbs: {
  31154. swiper: null,
  31155. multipleActiveThumbs: true,
  31156. autoScrollOffset: 0,
  31157. slideThumbActiveClass: 'swiper-slide-thumb-active',
  31158. thumbsContainerClass: 'swiper-thumbs'
  31159. }
  31160. });
  31161. let initialized = false;
  31162. let swiperCreated = false;
  31163. swiper.thumbs = {
  31164. swiper: null
  31165. };
  31166. function onThumbClick() {
  31167. const thumbsSwiper = swiper.thumbs.swiper;
  31168. if (!thumbsSwiper || thumbsSwiper.destroyed) return;
  31169. const clickedIndex = thumbsSwiper.clickedIndex;
  31170. const clickedSlide = thumbsSwiper.clickedSlide;
  31171. if (clickedSlide && clickedSlide.classList.contains(swiper.params.thumbs.slideThumbActiveClass)) return;
  31172. if (typeof clickedIndex === 'undefined' || clickedIndex === null) return;
  31173. let slideToIndex;
  31174. if (thumbsSwiper.params.loop) {
  31175. slideToIndex = parseInt(thumbsSwiper.clickedSlide.getAttribute('data-swiper-slide-index'), 10);
  31176. } else {
  31177. slideToIndex = clickedIndex;
  31178. }
  31179. if (swiper.params.loop) {
  31180. swiper.slideToLoop(slideToIndex);
  31181. } else {
  31182. swiper.slideTo(slideToIndex);
  31183. }
  31184. }
  31185. function init() {
  31186. const {
  31187. thumbs: thumbsParams
  31188. } = swiper.params;
  31189. if (initialized) return false;
  31190. initialized = true;
  31191. const SwiperClass = swiper.constructor;
  31192. if (thumbsParams.swiper instanceof SwiperClass) {
  31193. if (thumbsParams.swiper.destroyed) {
  31194. initialized = false;
  31195. return false;
  31196. }
  31197. swiper.thumbs.swiper = thumbsParams.swiper;
  31198. Object.assign(swiper.thumbs.swiper.originalParams, {
  31199. watchSlidesProgress: true,
  31200. slideToClickedSlide: false
  31201. });
  31202. Object.assign(swiper.thumbs.swiper.params, {
  31203. watchSlidesProgress: true,
  31204. slideToClickedSlide: false
  31205. });
  31206. swiper.thumbs.swiper.update();
  31207. } else if (isObject(thumbsParams.swiper)) {
  31208. const thumbsSwiperParams = Object.assign({}, thumbsParams.swiper);
  31209. Object.assign(thumbsSwiperParams, {
  31210. watchSlidesProgress: true,
  31211. slideToClickedSlide: false
  31212. });
  31213. swiper.thumbs.swiper = new SwiperClass(thumbsSwiperParams);
  31214. swiperCreated = true;
  31215. }
  31216. swiper.thumbs.swiper.el.classList.add(swiper.params.thumbs.thumbsContainerClass);
  31217. swiper.thumbs.swiper.on('tap', onThumbClick);
  31218. return true;
  31219. }
  31220. function update(initial) {
  31221. const thumbsSwiper = swiper.thumbs.swiper;
  31222. if (!thumbsSwiper || thumbsSwiper.destroyed) return;
  31223. const slidesPerView = thumbsSwiper.params.slidesPerView === 'auto' ? thumbsSwiper.slidesPerViewDynamic() : thumbsSwiper.params.slidesPerView;
  31224. // Activate thumbs
  31225. let thumbsToActivate = 1;
  31226. const thumbActiveClass = swiper.params.thumbs.slideThumbActiveClass;
  31227. if (swiper.params.slidesPerView > 1 && !swiper.params.centeredSlides) {
  31228. thumbsToActivate = swiper.params.slidesPerView;
  31229. }
  31230. if (!swiper.params.thumbs.multipleActiveThumbs) {
  31231. thumbsToActivate = 1;
  31232. }
  31233. thumbsToActivate = Math.floor(thumbsToActivate);
  31234. thumbsSwiper.slides.forEach(slideEl => slideEl.classList.remove(thumbActiveClass));
  31235. if (thumbsSwiper.params.loop || thumbsSwiper.params.virtual && thumbsSwiper.params.virtual.enabled) {
  31236. for (let i = 0; i < thumbsToActivate; i += 1) {
  31237. elementChildren(thumbsSwiper.slidesEl, `[data-swiper-slide-index="${swiper.realIndex + i}"]`).forEach(slideEl => {
  31238. slideEl.classList.add(thumbActiveClass);
  31239. });
  31240. }
  31241. } else {
  31242. for (let i = 0; i < thumbsToActivate; i += 1) {
  31243. if (thumbsSwiper.slides[swiper.realIndex + i]) {
  31244. thumbsSwiper.slides[swiper.realIndex + i].classList.add(thumbActiveClass);
  31245. }
  31246. }
  31247. }
  31248. const autoScrollOffset = swiper.params.thumbs.autoScrollOffset;
  31249. const useOffset = autoScrollOffset && !thumbsSwiper.params.loop;
  31250. if (swiper.realIndex !== thumbsSwiper.realIndex || useOffset) {
  31251. const currentThumbsIndex = thumbsSwiper.activeIndex;
  31252. let newThumbsIndex;
  31253. let direction;
  31254. if (thumbsSwiper.params.loop) {
  31255. const newThumbsSlide = thumbsSwiper.slides.find(slideEl => slideEl.getAttribute('data-swiper-slide-index') === `${swiper.realIndex}`);
  31256. newThumbsIndex = thumbsSwiper.slides.indexOf(newThumbsSlide);
  31257. direction = swiper.activeIndex > swiper.previousIndex ? 'next' : 'prev';
  31258. } else {
  31259. newThumbsIndex = swiper.realIndex;
  31260. direction = newThumbsIndex > swiper.previousIndex ? 'next' : 'prev';
  31261. }
  31262. if (useOffset) {
  31263. newThumbsIndex += direction === 'next' ? autoScrollOffset : -1 * autoScrollOffset;
  31264. }
  31265. if (thumbsSwiper.visibleSlidesIndexes && thumbsSwiper.visibleSlidesIndexes.indexOf(newThumbsIndex) < 0) {
  31266. if (thumbsSwiper.params.centeredSlides) {
  31267. if (newThumbsIndex > currentThumbsIndex) {
  31268. newThumbsIndex = newThumbsIndex - Math.floor(slidesPerView / 2) + 1;
  31269. } else {
  31270. newThumbsIndex = newThumbsIndex + Math.floor(slidesPerView / 2) - 1;
  31271. }
  31272. } else if (newThumbsIndex > currentThumbsIndex && thumbsSwiper.params.slidesPerGroup === 1) ;
  31273. thumbsSwiper.slideTo(newThumbsIndex, initial ? 0 : undefined);
  31274. }
  31275. }
  31276. }
  31277. on('beforeInit', () => {
  31278. const {
  31279. thumbs
  31280. } = swiper.params;
  31281. if (!thumbs || !thumbs.swiper) return;
  31282. if (typeof thumbs.swiper === 'string' || thumbs.swiper instanceof HTMLElement) {
  31283. const document = getDocument();
  31284. const getThumbsElementAndInit = () => {
  31285. const thumbsElement = typeof thumbs.swiper === 'string' ? document.querySelector(thumbs.swiper) : thumbs.swiper;
  31286. if (thumbsElement && thumbsElement.swiper) {
  31287. thumbs.swiper = thumbsElement.swiper;
  31288. init();
  31289. update(true);
  31290. } else if (thumbsElement) {
  31291. const eventName = `${swiper.params.eventsPrefix}init`;
  31292. const onThumbsSwiper = e => {
  31293. thumbs.swiper = e.detail[0];
  31294. thumbsElement.removeEventListener(eventName, onThumbsSwiper);
  31295. init();
  31296. update(true);
  31297. thumbs.swiper.update();
  31298. swiper.update();
  31299. };
  31300. thumbsElement.addEventListener(eventName, onThumbsSwiper);
  31301. }
  31302. return thumbsElement;
  31303. };
  31304. const watchForThumbsToAppear = () => {
  31305. if (swiper.destroyed) return;
  31306. const thumbsElement = getThumbsElementAndInit();
  31307. if (!thumbsElement) {
  31308. requestAnimationFrame(watchForThumbsToAppear);
  31309. }
  31310. };
  31311. requestAnimationFrame(watchForThumbsToAppear);
  31312. } else {
  31313. init();
  31314. update(true);
  31315. }
  31316. });
  31317. on('slideChange update resize observerUpdate', () => {
  31318. update();
  31319. });
  31320. on('setTransition', (_s, duration) => {
  31321. const thumbsSwiper = swiper.thumbs.swiper;
  31322. if (!thumbsSwiper || thumbsSwiper.destroyed) return;
  31323. thumbsSwiper.setTransition(duration);
  31324. });
  31325. on('beforeDestroy', () => {
  31326. const thumbsSwiper = swiper.thumbs.swiper;
  31327. if (!thumbsSwiper || thumbsSwiper.destroyed) return;
  31328. if (swiperCreated) {
  31329. thumbsSwiper.destroy();
  31330. }
  31331. });
  31332. Object.assign(swiper.thumbs, {
  31333. init,
  31334. update
  31335. });
  31336. }
  31337. function freeMode(_ref) {
  31338. let {
  31339. swiper,
  31340. extendParams,
  31341. emit,
  31342. once
  31343. } = _ref;
  31344. extendParams({
  31345. freeMode: {
  31346. enabled: false,
  31347. momentum: true,
  31348. momentumRatio: 1,
  31349. momentumBounce: true,
  31350. momentumBounceRatio: 1,
  31351. momentumVelocityRatio: 1,
  31352. sticky: false,
  31353. minimumVelocity: 0.02
  31354. }
  31355. });
  31356. function onTouchStart() {
  31357. if (swiper.params.cssMode) return;
  31358. const translate = swiper.getTranslate();
  31359. swiper.setTranslate(translate);
  31360. swiper.setTransition(0);
  31361. swiper.touchEventsData.velocities.length = 0;
  31362. swiper.freeMode.onTouchEnd({
  31363. currentPos: swiper.rtl ? swiper.translate : -swiper.translate
  31364. });
  31365. }
  31366. function onTouchMove() {
  31367. if (swiper.params.cssMode) return;
  31368. const {
  31369. touchEventsData: data,
  31370. touches
  31371. } = swiper;
  31372. // Velocity
  31373. if (data.velocities.length === 0) {
  31374. data.velocities.push({
  31375. position: touches[swiper.isHorizontal() ? 'startX' : 'startY'],
  31376. time: data.touchStartTime
  31377. });
  31378. }
  31379. data.velocities.push({
  31380. position: touches[swiper.isHorizontal() ? 'currentX' : 'currentY'],
  31381. time: now()
  31382. });
  31383. }
  31384. function onTouchEnd(_ref2) {
  31385. let {
  31386. currentPos
  31387. } = _ref2;
  31388. if (swiper.params.cssMode) return;
  31389. const {
  31390. params,
  31391. wrapperEl,
  31392. rtlTranslate: rtl,
  31393. snapGrid,
  31394. touchEventsData: data
  31395. } = swiper;
  31396. // Time diff
  31397. const touchEndTime = now();
  31398. const timeDiff = touchEndTime - data.touchStartTime;
  31399. if (currentPos < -swiper.minTranslate()) {
  31400. swiper.slideTo(swiper.activeIndex);
  31401. return;
  31402. }
  31403. if (currentPos > -swiper.maxTranslate()) {
  31404. if (swiper.slides.length < snapGrid.length) {
  31405. swiper.slideTo(snapGrid.length - 1);
  31406. } else {
  31407. swiper.slideTo(swiper.slides.length - 1);
  31408. }
  31409. return;
  31410. }
  31411. if (params.freeMode.momentum) {
  31412. if (data.velocities.length > 1) {
  31413. const lastMoveEvent = data.velocities.pop();
  31414. const velocityEvent = data.velocities.pop();
  31415. const distance = lastMoveEvent.position - velocityEvent.position;
  31416. const time = lastMoveEvent.time - velocityEvent.time;
  31417. swiper.velocity = distance / time;
  31418. swiper.velocity /= 2;
  31419. if (Math.abs(swiper.velocity) < params.freeMode.minimumVelocity) {
  31420. swiper.velocity = 0;
  31421. }
  31422. // this implies that the user stopped moving a finger then released.
  31423. // There would be no events with distance zero, so the last event is stale.
  31424. if (time > 150 || now() - lastMoveEvent.time > 300) {
  31425. swiper.velocity = 0;
  31426. }
  31427. } else {
  31428. swiper.velocity = 0;
  31429. }
  31430. swiper.velocity *= params.freeMode.momentumVelocityRatio;
  31431. data.velocities.length = 0;
  31432. let momentumDuration = 1000 * params.freeMode.momentumRatio;
  31433. const momentumDistance = swiper.velocity * momentumDuration;
  31434. let newPosition = swiper.translate + momentumDistance;
  31435. if (rtl) newPosition = -newPosition;
  31436. let doBounce = false;
  31437. let afterBouncePosition;
  31438. const bounceAmount = Math.abs(swiper.velocity) * 20 * params.freeMode.momentumBounceRatio;
  31439. let needsLoopFix;
  31440. if (newPosition < swiper.maxTranslate()) {
  31441. if (params.freeMode.momentumBounce) {
  31442. if (newPosition + swiper.maxTranslate() < -bounceAmount) {
  31443. newPosition = swiper.maxTranslate() - bounceAmount;
  31444. }
  31445. afterBouncePosition = swiper.maxTranslate();
  31446. doBounce = true;
  31447. data.allowMomentumBounce = true;
  31448. } else {
  31449. newPosition = swiper.maxTranslate();
  31450. }
  31451. if (params.loop && params.centeredSlides) needsLoopFix = true;
  31452. } else if (newPosition > swiper.minTranslate()) {
  31453. if (params.freeMode.momentumBounce) {
  31454. if (newPosition - swiper.minTranslate() > bounceAmount) {
  31455. newPosition = swiper.minTranslate() + bounceAmount;
  31456. }
  31457. afterBouncePosition = swiper.minTranslate();
  31458. doBounce = true;
  31459. data.allowMomentumBounce = true;
  31460. } else {
  31461. newPosition = swiper.minTranslate();
  31462. }
  31463. if (params.loop && params.centeredSlides) needsLoopFix = true;
  31464. } else if (params.freeMode.sticky) {
  31465. let nextSlide;
  31466. for (let j = 0; j < snapGrid.length; j += 1) {
  31467. if (snapGrid[j] > -newPosition) {
  31468. nextSlide = j;
  31469. break;
  31470. }
  31471. }
  31472. if (Math.abs(snapGrid[nextSlide] - newPosition) < Math.abs(snapGrid[nextSlide - 1] - newPosition) || swiper.swipeDirection === 'next') {
  31473. newPosition = snapGrid[nextSlide];
  31474. } else {
  31475. newPosition = snapGrid[nextSlide - 1];
  31476. }
  31477. newPosition = -newPosition;
  31478. }
  31479. if (needsLoopFix) {
  31480. once('transitionEnd', () => {
  31481. swiper.loopFix();
  31482. });
  31483. }
  31484. // Fix duration
  31485. if (swiper.velocity !== 0) {
  31486. if (rtl) {
  31487. momentumDuration = Math.abs((-newPosition - swiper.translate) / swiper.velocity);
  31488. } else {
  31489. momentumDuration = Math.abs((newPosition - swiper.translate) / swiper.velocity);
  31490. }
  31491. if (params.freeMode.sticky) {
  31492. // If freeMode.sticky is active and the user ends a swipe with a slow-velocity
  31493. // event, then durations can be 20+ seconds to slide one (or zero!) slides.
  31494. // It's easy to see this when simulating touch with mouse events. To fix this,
  31495. // limit single-slide swipes to the default slide duration. This also has the
  31496. // nice side effect of matching slide speed if the user stopped moving before
  31497. // lifting finger or mouse vs. moving slowly before lifting the finger/mouse.
  31498. // For faster swipes, also apply limits (albeit higher ones).
  31499. const moveDistance = Math.abs((rtl ? -newPosition : newPosition) - swiper.translate);
  31500. const currentSlideSize = swiper.slidesSizesGrid[swiper.activeIndex];
  31501. if (moveDistance < currentSlideSize) {
  31502. momentumDuration = params.speed;
  31503. } else if (moveDistance < 2 * currentSlideSize) {
  31504. momentumDuration = params.speed * 1.5;
  31505. } else {
  31506. momentumDuration = params.speed * 2.5;
  31507. }
  31508. }
  31509. } else if (params.freeMode.sticky) {
  31510. swiper.slideToClosest();
  31511. return;
  31512. }
  31513. if (params.freeMode.momentumBounce && doBounce) {
  31514. swiper.updateProgress(afterBouncePosition);
  31515. swiper.setTransition(momentumDuration);
  31516. swiper.setTranslate(newPosition);
  31517. swiper.transitionStart(true, swiper.swipeDirection);
  31518. swiper.animating = true;
  31519. elementTransitionEnd(wrapperEl, () => {
  31520. if (!swiper || swiper.destroyed || !data.allowMomentumBounce) return;
  31521. emit('momentumBounce');
  31522. swiper.setTransition(params.speed);
  31523. setTimeout(() => {
  31524. swiper.setTranslate(afterBouncePosition);
  31525. elementTransitionEnd(wrapperEl, () => {
  31526. if (!swiper || swiper.destroyed) return;
  31527. swiper.transitionEnd();
  31528. });
  31529. }, 0);
  31530. });
  31531. } else if (swiper.velocity) {
  31532. emit('_freeModeNoMomentumRelease');
  31533. swiper.updateProgress(newPosition);
  31534. swiper.setTransition(momentumDuration);
  31535. swiper.setTranslate(newPosition);
  31536. swiper.transitionStart(true, swiper.swipeDirection);
  31537. if (!swiper.animating) {
  31538. swiper.animating = true;
  31539. elementTransitionEnd(wrapperEl, () => {
  31540. if (!swiper || swiper.destroyed) return;
  31541. swiper.transitionEnd();
  31542. });
  31543. }
  31544. } else {
  31545. swiper.updateProgress(newPosition);
  31546. }
  31547. swiper.updateActiveIndex();
  31548. swiper.updateSlidesClasses();
  31549. } else if (params.freeMode.sticky) {
  31550. swiper.slideToClosest();
  31551. return;
  31552. } else if (params.freeMode) {
  31553. emit('_freeModeNoMomentumRelease');
  31554. }
  31555. if (!params.freeMode.momentum || timeDiff >= params.longSwipesMs) {
  31556. emit('_freeModeStaticRelease');
  31557. swiper.updateProgress();
  31558. swiper.updateActiveIndex();
  31559. swiper.updateSlidesClasses();
  31560. }
  31561. }
  31562. Object.assign(swiper, {
  31563. freeMode: {
  31564. onTouchStart,
  31565. onTouchMove,
  31566. onTouchEnd
  31567. }
  31568. });
  31569. }
  31570. function Grid(_ref) {
  31571. let {
  31572. swiper,
  31573. extendParams,
  31574. on
  31575. } = _ref;
  31576. extendParams({
  31577. grid: {
  31578. rows: 1,
  31579. fill: 'column'
  31580. }
  31581. });
  31582. let slidesNumberEvenToRows;
  31583. let slidesPerRow;
  31584. let numFullColumns;
  31585. let wasMultiRow;
  31586. const getSpaceBetween = () => {
  31587. let spaceBetween = swiper.params.spaceBetween;
  31588. if (typeof spaceBetween === 'string' && spaceBetween.indexOf('%') >= 0) {
  31589. spaceBetween = parseFloat(spaceBetween.replace('%', '')) / 100 * swiper.size;
  31590. } else if (typeof spaceBetween === 'string') {
  31591. spaceBetween = parseFloat(spaceBetween);
  31592. }
  31593. return spaceBetween;
  31594. };
  31595. const initSlides = slides => {
  31596. const {
  31597. slidesPerView
  31598. } = swiper.params;
  31599. const {
  31600. rows,
  31601. fill
  31602. } = swiper.params.grid;
  31603. const slidesLength = swiper.virtual && swiper.params.virtual.enabled ? swiper.virtual.slides.length : slides.length;
  31604. numFullColumns = Math.floor(slidesLength / rows);
  31605. if (Math.floor(slidesLength / rows) === slidesLength / rows) {
  31606. slidesNumberEvenToRows = slidesLength;
  31607. } else {
  31608. slidesNumberEvenToRows = Math.ceil(slidesLength / rows) * rows;
  31609. }
  31610. if (slidesPerView !== 'auto' && fill === 'row') {
  31611. slidesNumberEvenToRows = Math.max(slidesNumberEvenToRows, slidesPerView * rows);
  31612. }
  31613. slidesPerRow = slidesNumberEvenToRows / rows;
  31614. };
  31615. const unsetSlides = () => {
  31616. if (swiper.slides) {
  31617. swiper.slides.forEach(slide => {
  31618. if (slide.swiperSlideGridSet) {
  31619. slide.style.height = '';
  31620. slide.style[swiper.getDirectionLabel('margin-top')] = '';
  31621. }
  31622. });
  31623. }
  31624. };
  31625. const updateSlide = (i, slide, slides) => {
  31626. const {
  31627. slidesPerGroup
  31628. } = swiper.params;
  31629. const spaceBetween = getSpaceBetween();
  31630. const {
  31631. rows,
  31632. fill
  31633. } = swiper.params.grid;
  31634. const slidesLength = swiper.virtual && swiper.params.virtual.enabled ? swiper.virtual.slides.length : slides.length;
  31635. // Set slides order
  31636. let newSlideOrderIndex;
  31637. let column;
  31638. let row;
  31639. if (fill === 'row' && slidesPerGroup > 1) {
  31640. const groupIndex = Math.floor(i / (slidesPerGroup * rows));
  31641. const slideIndexInGroup = i - rows * slidesPerGroup * groupIndex;
  31642. const columnsInGroup = groupIndex === 0 ? slidesPerGroup : Math.min(Math.ceil((slidesLength - groupIndex * rows * slidesPerGroup) / rows), slidesPerGroup);
  31643. row = Math.floor(slideIndexInGroup / columnsInGroup);
  31644. column = slideIndexInGroup - row * columnsInGroup + groupIndex * slidesPerGroup;
  31645. newSlideOrderIndex = column + row * slidesNumberEvenToRows / rows;
  31646. slide.style.order = newSlideOrderIndex;
  31647. } else if (fill === 'column') {
  31648. column = Math.floor(i / rows);
  31649. row = i - column * rows;
  31650. if (column > numFullColumns || column === numFullColumns && row === rows - 1) {
  31651. row += 1;
  31652. if (row >= rows) {
  31653. row = 0;
  31654. column += 1;
  31655. }
  31656. }
  31657. } else {
  31658. row = Math.floor(i / slidesPerRow);
  31659. column = i - row * slidesPerRow;
  31660. }
  31661. slide.row = row;
  31662. slide.column = column;
  31663. slide.style.height = `calc((100% - ${(rows - 1) * spaceBetween}px) / ${rows})`;
  31664. slide.style[swiper.getDirectionLabel('margin-top')] = row !== 0 ? spaceBetween && `${spaceBetween}px` : '';
  31665. slide.swiperSlideGridSet = true;
  31666. };
  31667. const updateWrapperSize = (slideSize, snapGrid) => {
  31668. const {
  31669. centeredSlides,
  31670. roundLengths
  31671. } = swiper.params;
  31672. const spaceBetween = getSpaceBetween();
  31673. const {
  31674. rows
  31675. } = swiper.params.grid;
  31676. swiper.virtualSize = (slideSize + spaceBetween) * slidesNumberEvenToRows;
  31677. swiper.virtualSize = Math.ceil(swiper.virtualSize / rows) - spaceBetween;
  31678. if (!swiper.params.cssMode) {
  31679. swiper.wrapperEl.style[swiper.getDirectionLabel('width')] = `${swiper.virtualSize + spaceBetween}px`;
  31680. }
  31681. if (centeredSlides) {
  31682. const newSlidesGrid = [];
  31683. for (let i = 0; i < snapGrid.length; i += 1) {
  31684. let slidesGridItem = snapGrid[i];
  31685. if (roundLengths) slidesGridItem = Math.floor(slidesGridItem);
  31686. if (snapGrid[i] < swiper.virtualSize + snapGrid[0]) newSlidesGrid.push(slidesGridItem);
  31687. }
  31688. snapGrid.splice(0, snapGrid.length);
  31689. snapGrid.push(...newSlidesGrid);
  31690. }
  31691. };
  31692. const onInit = () => {
  31693. wasMultiRow = swiper.params.grid && swiper.params.grid.rows > 1;
  31694. };
  31695. const onUpdate = () => {
  31696. const {
  31697. params,
  31698. el
  31699. } = swiper;
  31700. const isMultiRow = params.grid && params.grid.rows > 1;
  31701. if (wasMultiRow && !isMultiRow) {
  31702. el.classList.remove(`${params.containerModifierClass}grid`, `${params.containerModifierClass}grid-column`);
  31703. numFullColumns = 1;
  31704. swiper.emitContainerClasses();
  31705. } else if (!wasMultiRow && isMultiRow) {
  31706. el.classList.add(`${params.containerModifierClass}grid`);
  31707. if (params.grid.fill === 'column') {
  31708. el.classList.add(`${params.containerModifierClass}grid-column`);
  31709. }
  31710. swiper.emitContainerClasses();
  31711. }
  31712. wasMultiRow = isMultiRow;
  31713. };
  31714. on('init', onInit);
  31715. on('update', onUpdate);
  31716. swiper.grid = {
  31717. initSlides,
  31718. unsetSlides,
  31719. updateSlide,
  31720. updateWrapperSize
  31721. };
  31722. }
  31723. function appendSlide(slides) {
  31724. const swiper = this;
  31725. const {
  31726. params,
  31727. slidesEl
  31728. } = swiper;
  31729. if (params.loop) {
  31730. swiper.loopDestroy();
  31731. }
  31732. const appendElement = slideEl => {
  31733. if (typeof slideEl === 'string') {
  31734. const tempDOM = document.createElement('div');
  31735. setInnerHTML(tempDOM, slideEl);
  31736. slidesEl.append(tempDOM.children[0]);
  31737. setInnerHTML(tempDOM, '');
  31738. } else {
  31739. slidesEl.append(slideEl);
  31740. }
  31741. };
  31742. if (typeof slides === 'object' && 'length' in slides) {
  31743. for (let i = 0; i < slides.length; i += 1) {
  31744. if (slides[i]) appendElement(slides[i]);
  31745. }
  31746. } else {
  31747. appendElement(slides);
  31748. }
  31749. swiper.recalcSlides();
  31750. if (params.loop) {
  31751. swiper.loopCreate();
  31752. }
  31753. if (!params.observer || swiper.isElement) {
  31754. swiper.update();
  31755. }
  31756. }
  31757. function prependSlide(slides) {
  31758. const swiper = this;
  31759. const {
  31760. params,
  31761. activeIndex,
  31762. slidesEl
  31763. } = swiper;
  31764. if (params.loop) {
  31765. swiper.loopDestroy();
  31766. }
  31767. let newActiveIndex = activeIndex + 1;
  31768. const prependElement = slideEl => {
  31769. if (typeof slideEl === 'string') {
  31770. const tempDOM = document.createElement('div');
  31771. setInnerHTML(tempDOM, slideEl);
  31772. slidesEl.prepend(tempDOM.children[0]);
  31773. setInnerHTML(tempDOM, '');
  31774. } else {
  31775. slidesEl.prepend(slideEl);
  31776. }
  31777. };
  31778. if (typeof slides === 'object' && 'length' in slides) {
  31779. for (let i = 0; i < slides.length; i += 1) {
  31780. if (slides[i]) prependElement(slides[i]);
  31781. }
  31782. newActiveIndex = activeIndex + slides.length;
  31783. } else {
  31784. prependElement(slides);
  31785. }
  31786. swiper.recalcSlides();
  31787. if (params.loop) {
  31788. swiper.loopCreate();
  31789. }
  31790. if (!params.observer || swiper.isElement) {
  31791. swiper.update();
  31792. }
  31793. swiper.slideTo(newActiveIndex, 0, false);
  31794. }
  31795. function addSlide(index, slides) {
  31796. const swiper = this;
  31797. const {
  31798. params,
  31799. activeIndex,
  31800. slidesEl
  31801. } = swiper;
  31802. let activeIndexBuffer = activeIndex;
  31803. if (params.loop) {
  31804. activeIndexBuffer -= swiper.loopedSlides;
  31805. swiper.loopDestroy();
  31806. swiper.recalcSlides();
  31807. }
  31808. const baseLength = swiper.slides.length;
  31809. if (index <= 0) {
  31810. swiper.prependSlide(slides);
  31811. return;
  31812. }
  31813. if (index >= baseLength) {
  31814. swiper.appendSlide(slides);
  31815. return;
  31816. }
  31817. let newActiveIndex = activeIndexBuffer > index ? activeIndexBuffer + 1 : activeIndexBuffer;
  31818. const slidesBuffer = [];
  31819. for (let i = baseLength - 1; i >= index; i -= 1) {
  31820. const currentSlide = swiper.slides[i];
  31821. currentSlide.remove();
  31822. slidesBuffer.unshift(currentSlide);
  31823. }
  31824. if (typeof slides === 'object' && 'length' in slides) {
  31825. for (let i = 0; i < slides.length; i += 1) {
  31826. if (slides[i]) slidesEl.append(slides[i]);
  31827. }
  31828. newActiveIndex = activeIndexBuffer > index ? activeIndexBuffer + slides.length : activeIndexBuffer;
  31829. } else {
  31830. slidesEl.append(slides);
  31831. }
  31832. for (let i = 0; i < slidesBuffer.length; i += 1) {
  31833. slidesEl.append(slidesBuffer[i]);
  31834. }
  31835. swiper.recalcSlides();
  31836. if (params.loop) {
  31837. swiper.loopCreate();
  31838. }
  31839. if (!params.observer || swiper.isElement) {
  31840. swiper.update();
  31841. }
  31842. if (params.loop) {
  31843. swiper.slideTo(newActiveIndex + swiper.loopedSlides, 0, false);
  31844. } else {
  31845. swiper.slideTo(newActiveIndex, 0, false);
  31846. }
  31847. }
  31848. function removeSlide(slidesIndexes) {
  31849. const swiper = this;
  31850. const {
  31851. params,
  31852. activeIndex
  31853. } = swiper;
  31854. let activeIndexBuffer = activeIndex;
  31855. if (params.loop) {
  31856. activeIndexBuffer -= swiper.loopedSlides;
  31857. swiper.loopDestroy();
  31858. }
  31859. let newActiveIndex = activeIndexBuffer;
  31860. let indexToRemove;
  31861. if (typeof slidesIndexes === 'object' && 'length' in slidesIndexes) {
  31862. for (let i = 0; i < slidesIndexes.length; i += 1) {
  31863. indexToRemove = slidesIndexes[i];
  31864. if (swiper.slides[indexToRemove]) swiper.slides[indexToRemove].remove();
  31865. if (indexToRemove < newActiveIndex) newActiveIndex -= 1;
  31866. }
  31867. newActiveIndex = Math.max(newActiveIndex, 0);
  31868. } else {
  31869. indexToRemove = slidesIndexes;
  31870. if (swiper.slides[indexToRemove]) swiper.slides[indexToRemove].remove();
  31871. if (indexToRemove < newActiveIndex) newActiveIndex -= 1;
  31872. newActiveIndex = Math.max(newActiveIndex, 0);
  31873. }
  31874. swiper.recalcSlides();
  31875. if (params.loop) {
  31876. swiper.loopCreate();
  31877. }
  31878. if (!params.observer || swiper.isElement) {
  31879. swiper.update();
  31880. }
  31881. if (params.loop) {
  31882. swiper.slideTo(newActiveIndex + swiper.loopedSlides, 0, false);
  31883. } else {
  31884. swiper.slideTo(newActiveIndex, 0, false);
  31885. }
  31886. }
  31887. function removeAllSlides() {
  31888. const swiper = this;
  31889. const slidesIndexes = [];
  31890. for (let i = 0; i < swiper.slides.length; i += 1) {
  31891. slidesIndexes.push(i);
  31892. }
  31893. swiper.removeSlide(slidesIndexes);
  31894. }
  31895. function Manipulation(_ref) {
  31896. let {
  31897. swiper
  31898. } = _ref;
  31899. Object.assign(swiper, {
  31900. appendSlide: appendSlide.bind(swiper),
  31901. prependSlide: prependSlide.bind(swiper),
  31902. addSlide: addSlide.bind(swiper),
  31903. removeSlide: removeSlide.bind(swiper),
  31904. removeAllSlides: removeAllSlides.bind(swiper)
  31905. });
  31906. }
  31907. function effectInit(params) {
  31908. const {
  31909. effect,
  31910. swiper,
  31911. on,
  31912. setTranslate,
  31913. setTransition,
  31914. overwriteParams,
  31915. perspective,
  31916. recreateShadows,
  31917. getEffectParams
  31918. } = params;
  31919. on('beforeInit', () => {
  31920. if (swiper.params.effect !== effect) return;
  31921. swiper.classNames.push(`${swiper.params.containerModifierClass}${effect}`);
  31922. if (perspective && perspective()) {
  31923. swiper.classNames.push(`${swiper.params.containerModifierClass}3d`);
  31924. }
  31925. const overwriteParamsResult = overwriteParams ? overwriteParams() : {};
  31926. Object.assign(swiper.params, overwriteParamsResult);
  31927. Object.assign(swiper.originalParams, overwriteParamsResult);
  31928. });
  31929. on('setTranslate _virtualUpdated', () => {
  31930. if (swiper.params.effect !== effect) return;
  31931. setTranslate();
  31932. });
  31933. on('setTransition', (_s, duration) => {
  31934. if (swiper.params.effect !== effect) return;
  31935. setTransition(duration);
  31936. });
  31937. on('transitionEnd', () => {
  31938. if (swiper.params.effect !== effect) return;
  31939. if (recreateShadows) {
  31940. if (!getEffectParams || !getEffectParams().slideShadows) return;
  31941. // remove shadows
  31942. swiper.slides.forEach(slideEl => {
  31943. slideEl.querySelectorAll('.swiper-slide-shadow-top, .swiper-slide-shadow-right, .swiper-slide-shadow-bottom, .swiper-slide-shadow-left').forEach(shadowEl => shadowEl.remove());
  31944. });
  31945. // create new one
  31946. recreateShadows();
  31947. }
  31948. });
  31949. let requireUpdateOnVirtual;
  31950. on('virtualUpdate', () => {
  31951. if (swiper.params.effect !== effect) return;
  31952. if (!swiper.slides.length) {
  31953. requireUpdateOnVirtual = true;
  31954. }
  31955. requestAnimationFrame(() => {
  31956. if (requireUpdateOnVirtual && swiper.slides && swiper.slides.length) {
  31957. setTranslate();
  31958. requireUpdateOnVirtual = false;
  31959. }
  31960. });
  31961. });
  31962. }
  31963. function effectTarget(effectParams, slideEl) {
  31964. const transformEl = getSlideTransformEl(slideEl);
  31965. if (transformEl !== slideEl) {
  31966. transformEl.style.backfaceVisibility = 'hidden';
  31967. transformEl.style['-webkit-backface-visibility'] = 'hidden';
  31968. }
  31969. return transformEl;
  31970. }
  31971. function effectVirtualTransitionEnd(_ref) {
  31972. let {
  31973. swiper,
  31974. duration,
  31975. transformElements,
  31976. allSlides
  31977. } = _ref;
  31978. const {
  31979. activeIndex
  31980. } = swiper;
  31981. const getSlide = el => {
  31982. if (!el.parentElement) {
  31983. // assume shadow root
  31984. const slide = swiper.slides.find(slideEl => slideEl.shadowRoot && slideEl.shadowRoot === el.parentNode);
  31985. return slide;
  31986. }
  31987. return el.parentElement;
  31988. };
  31989. if (swiper.params.virtualTranslate && duration !== 0) {
  31990. let eventTriggered = false;
  31991. let transitionEndTarget;
  31992. if (allSlides) {
  31993. transitionEndTarget = transformElements;
  31994. } else {
  31995. transitionEndTarget = transformElements.filter(transformEl => {
  31996. const el = transformEl.classList.contains('swiper-slide-transform') ? getSlide(transformEl) : transformEl;
  31997. return swiper.getSlideIndex(el) === activeIndex;
  31998. });
  31999. }
  32000. transitionEndTarget.forEach(el => {
  32001. elementTransitionEnd(el, () => {
  32002. if (eventTriggered) return;
  32003. if (!swiper || swiper.destroyed) return;
  32004. eventTriggered = true;
  32005. swiper.animating = false;
  32006. const evt = new window.CustomEvent('transitionend', {
  32007. bubbles: true,
  32008. cancelable: true
  32009. });
  32010. swiper.wrapperEl.dispatchEvent(evt);
  32011. });
  32012. });
  32013. }
  32014. }
  32015. function EffectFade(_ref) {
  32016. let {
  32017. swiper,
  32018. extendParams,
  32019. on
  32020. } = _ref;
  32021. extendParams({
  32022. fadeEffect: {
  32023. crossFade: false
  32024. }
  32025. });
  32026. const setTranslate = () => {
  32027. const {
  32028. slides
  32029. } = swiper;
  32030. const params = swiper.params.fadeEffect;
  32031. for (let i = 0; i < slides.length; i += 1) {
  32032. const slideEl = swiper.slides[i];
  32033. const offset = slideEl.swiperSlideOffset;
  32034. let tx = -offset;
  32035. if (!swiper.params.virtualTranslate) tx -= swiper.translate;
  32036. let ty = 0;
  32037. if (!swiper.isHorizontal()) {
  32038. ty = tx;
  32039. tx = 0;
  32040. }
  32041. const slideOpacity = swiper.params.fadeEffect.crossFade ? Math.max(1 - Math.abs(slideEl.progress), 0) : 1 + Math.min(Math.max(slideEl.progress, -1), 0);
  32042. const targetEl = effectTarget(params, slideEl);
  32043. targetEl.style.opacity = slideOpacity;
  32044. targetEl.style.transform = `translate3d(${tx}px, ${ty}px, 0px)`;
  32045. }
  32046. };
  32047. const setTransition = duration => {
  32048. const transformElements = swiper.slides.map(slideEl => getSlideTransformEl(slideEl));
  32049. transformElements.forEach(el => {
  32050. el.style.transitionDuration = `${duration}ms`;
  32051. });
  32052. effectVirtualTransitionEnd({
  32053. swiper,
  32054. duration,
  32055. transformElements,
  32056. allSlides: true
  32057. });
  32058. };
  32059. effectInit({
  32060. effect: 'fade',
  32061. swiper,
  32062. on,
  32063. setTranslate,
  32064. setTransition,
  32065. overwriteParams: () => ({
  32066. slidesPerView: 1,
  32067. slidesPerGroup: 1,
  32068. watchSlidesProgress: true,
  32069. spaceBetween: 0,
  32070. virtualTranslate: !swiper.params.cssMode
  32071. })
  32072. });
  32073. }
  32074. function EffectCube(_ref) {
  32075. let {
  32076. swiper,
  32077. extendParams,
  32078. on
  32079. } = _ref;
  32080. extendParams({
  32081. cubeEffect: {
  32082. slideShadows: true,
  32083. shadow: true,
  32084. shadowOffset: 20,
  32085. shadowScale: 0.94
  32086. }
  32087. });
  32088. const createSlideShadows = (slideEl, progress, isHorizontal) => {
  32089. let shadowBefore = isHorizontal ? slideEl.querySelector('.swiper-slide-shadow-left') : slideEl.querySelector('.swiper-slide-shadow-top');
  32090. let shadowAfter = isHorizontal ? slideEl.querySelector('.swiper-slide-shadow-right') : slideEl.querySelector('.swiper-slide-shadow-bottom');
  32091. if (!shadowBefore) {
  32092. shadowBefore = createElement('div', `swiper-slide-shadow-cube swiper-slide-shadow-${isHorizontal ? 'left' : 'top'}`.split(' '));
  32093. slideEl.append(shadowBefore);
  32094. }
  32095. if (!shadowAfter) {
  32096. shadowAfter = createElement('div', `swiper-slide-shadow-cube swiper-slide-shadow-${isHorizontal ? 'right' : 'bottom'}`.split(' '));
  32097. slideEl.append(shadowAfter);
  32098. }
  32099. if (shadowBefore) shadowBefore.style.opacity = Math.max(-progress, 0);
  32100. if (shadowAfter) shadowAfter.style.opacity = Math.max(progress, 0);
  32101. };
  32102. const recreateShadows = () => {
  32103. // create new ones
  32104. const isHorizontal = swiper.isHorizontal();
  32105. swiper.slides.forEach(slideEl => {
  32106. const progress = Math.max(Math.min(slideEl.progress, 1), -1);
  32107. createSlideShadows(slideEl, progress, isHorizontal);
  32108. });
  32109. };
  32110. const setTranslate = () => {
  32111. const {
  32112. el,
  32113. wrapperEl,
  32114. slides,
  32115. width: swiperWidth,
  32116. height: swiperHeight,
  32117. rtlTranslate: rtl,
  32118. size: swiperSize,
  32119. browser
  32120. } = swiper;
  32121. const r = getRotateFix(swiper);
  32122. const params = swiper.params.cubeEffect;
  32123. const isHorizontal = swiper.isHorizontal();
  32124. const isVirtual = swiper.virtual && swiper.params.virtual.enabled;
  32125. let wrapperRotate = 0;
  32126. let cubeShadowEl;
  32127. if (params.shadow) {
  32128. if (isHorizontal) {
  32129. cubeShadowEl = swiper.wrapperEl.querySelector('.swiper-cube-shadow');
  32130. if (!cubeShadowEl) {
  32131. cubeShadowEl = createElement('div', 'swiper-cube-shadow');
  32132. swiper.wrapperEl.append(cubeShadowEl);
  32133. }
  32134. cubeShadowEl.style.height = `${swiperWidth}px`;
  32135. } else {
  32136. cubeShadowEl = el.querySelector('.swiper-cube-shadow');
  32137. if (!cubeShadowEl) {
  32138. cubeShadowEl = createElement('div', 'swiper-cube-shadow');
  32139. el.append(cubeShadowEl);
  32140. }
  32141. }
  32142. }
  32143. for (let i = 0; i < slides.length; i += 1) {
  32144. const slideEl = slides[i];
  32145. let slideIndex = i;
  32146. if (isVirtual) {
  32147. slideIndex = parseInt(slideEl.getAttribute('data-swiper-slide-index'), 10);
  32148. }
  32149. let slideAngle = slideIndex * 90;
  32150. let round = Math.floor(slideAngle / 360);
  32151. if (rtl) {
  32152. slideAngle = -slideAngle;
  32153. round = Math.floor(-slideAngle / 360);
  32154. }
  32155. const progress = Math.max(Math.min(slideEl.progress, 1), -1);
  32156. let tx = 0;
  32157. let ty = 0;
  32158. let tz = 0;
  32159. if (slideIndex % 4 === 0) {
  32160. tx = -round * 4 * swiperSize;
  32161. tz = 0;
  32162. } else if ((slideIndex - 1) % 4 === 0) {
  32163. tx = 0;
  32164. tz = -round * 4 * swiperSize;
  32165. } else if ((slideIndex - 2) % 4 === 0) {
  32166. tx = swiperSize + round * 4 * swiperSize;
  32167. tz = swiperSize;
  32168. } else if ((slideIndex - 3) % 4 === 0) {
  32169. tx = -swiperSize;
  32170. tz = 3 * swiperSize + swiperSize * 4 * round;
  32171. }
  32172. if (rtl) {
  32173. tx = -tx;
  32174. }
  32175. if (!isHorizontal) {
  32176. ty = tx;
  32177. tx = 0;
  32178. }
  32179. const transform = `rotateX(${r(isHorizontal ? 0 : -slideAngle)}deg) rotateY(${r(isHorizontal ? slideAngle : 0)}deg) translate3d(${tx}px, ${ty}px, ${tz}px)`;
  32180. if (progress <= 1 && progress > -1) {
  32181. wrapperRotate = slideIndex * 90 + progress * 90;
  32182. if (rtl) wrapperRotate = -slideIndex * 90 - progress * 90;
  32183. }
  32184. slideEl.style.transform = transform;
  32185. if (params.slideShadows) {
  32186. createSlideShadows(slideEl, progress, isHorizontal);
  32187. }
  32188. }
  32189. wrapperEl.style.transformOrigin = `50% 50% -${swiperSize / 2}px`;
  32190. wrapperEl.style['-webkit-transform-origin'] = `50% 50% -${swiperSize / 2}px`;
  32191. if (params.shadow) {
  32192. if (isHorizontal) {
  32193. cubeShadowEl.style.transform = `translate3d(0px, ${swiperWidth / 2 + params.shadowOffset}px, ${-swiperWidth / 2}px) rotateX(89.99deg) rotateZ(0deg) scale(${params.shadowScale})`;
  32194. } else {
  32195. const shadowAngle = Math.abs(wrapperRotate) - Math.floor(Math.abs(wrapperRotate) / 90) * 90;
  32196. const multiplier = 1.5 - (Math.sin(shadowAngle * 2 * Math.PI / 360) / 2 + Math.cos(shadowAngle * 2 * Math.PI / 360) / 2);
  32197. const scale1 = params.shadowScale;
  32198. const scale2 = params.shadowScale / multiplier;
  32199. const offset = params.shadowOffset;
  32200. cubeShadowEl.style.transform = `scale3d(${scale1}, 1, ${scale2}) translate3d(0px, ${swiperHeight / 2 + offset}px, ${-swiperHeight / 2 / scale2}px) rotateX(-89.99deg)`;
  32201. }
  32202. }
  32203. const zFactor = (browser.isSafari || browser.isWebView) && browser.needPerspectiveFix ? -swiperSize / 2 : 0;
  32204. wrapperEl.style.transform = `translate3d(0px,0,${zFactor}px) rotateX(${r(swiper.isHorizontal() ? 0 : wrapperRotate)}deg) rotateY(${r(swiper.isHorizontal() ? -wrapperRotate : 0)}deg)`;
  32205. wrapperEl.style.setProperty('--swiper-cube-translate-z', `${zFactor}px`);
  32206. };
  32207. const setTransition = duration => {
  32208. const {
  32209. el,
  32210. slides
  32211. } = swiper;
  32212. slides.forEach(slideEl => {
  32213. slideEl.style.transitionDuration = `${duration}ms`;
  32214. slideEl.querySelectorAll('.swiper-slide-shadow-top, .swiper-slide-shadow-right, .swiper-slide-shadow-bottom, .swiper-slide-shadow-left').forEach(subEl => {
  32215. subEl.style.transitionDuration = `${duration}ms`;
  32216. });
  32217. });
  32218. if (swiper.params.cubeEffect.shadow && !swiper.isHorizontal()) {
  32219. const shadowEl = el.querySelector('.swiper-cube-shadow');
  32220. if (shadowEl) shadowEl.style.transitionDuration = `${duration}ms`;
  32221. }
  32222. };
  32223. effectInit({
  32224. effect: 'cube',
  32225. swiper,
  32226. on,
  32227. setTranslate,
  32228. setTransition,
  32229. recreateShadows,
  32230. getEffectParams: () => swiper.params.cubeEffect,
  32231. perspective: () => true,
  32232. overwriteParams: () => ({
  32233. slidesPerView: 1,
  32234. slidesPerGroup: 1,
  32235. watchSlidesProgress: true,
  32236. resistanceRatio: 0,
  32237. spaceBetween: 0,
  32238. centeredSlides: false,
  32239. virtualTranslate: true
  32240. })
  32241. });
  32242. }
  32243. function createShadow(suffix, slideEl, side) {
  32244. const shadowClass = `swiper-slide-shadow${side ? `-${side}` : ''}${suffix ? ` swiper-slide-shadow-${suffix}` : ''}`;
  32245. const shadowContainer = getSlideTransformEl(slideEl);
  32246. let shadowEl = shadowContainer.querySelector(`.${shadowClass.split(' ').join('.')}`);
  32247. if (!shadowEl) {
  32248. shadowEl = createElement('div', shadowClass.split(' '));
  32249. shadowContainer.append(shadowEl);
  32250. }
  32251. return shadowEl;
  32252. }
  32253. function EffectFlip(_ref) {
  32254. let {
  32255. swiper,
  32256. extendParams,
  32257. on
  32258. } = _ref;
  32259. extendParams({
  32260. flipEffect: {
  32261. slideShadows: true,
  32262. limitRotation: true
  32263. }
  32264. });
  32265. const createSlideShadows = (slideEl, progress) => {
  32266. let shadowBefore = swiper.isHorizontal() ? slideEl.querySelector('.swiper-slide-shadow-left') : slideEl.querySelector('.swiper-slide-shadow-top');
  32267. let shadowAfter = swiper.isHorizontal() ? slideEl.querySelector('.swiper-slide-shadow-right') : slideEl.querySelector('.swiper-slide-shadow-bottom');
  32268. if (!shadowBefore) {
  32269. shadowBefore = createShadow('flip', slideEl, swiper.isHorizontal() ? 'left' : 'top');
  32270. }
  32271. if (!shadowAfter) {
  32272. shadowAfter = createShadow('flip', slideEl, swiper.isHorizontal() ? 'right' : 'bottom');
  32273. }
  32274. if (shadowBefore) shadowBefore.style.opacity = Math.max(-progress, 0);
  32275. if (shadowAfter) shadowAfter.style.opacity = Math.max(progress, 0);
  32276. };
  32277. const recreateShadows = () => {
  32278. // Set shadows
  32279. swiper.params.flipEffect;
  32280. swiper.slides.forEach(slideEl => {
  32281. let progress = slideEl.progress;
  32282. if (swiper.params.flipEffect.limitRotation) {
  32283. progress = Math.max(Math.min(slideEl.progress, 1), -1);
  32284. }
  32285. createSlideShadows(slideEl, progress);
  32286. });
  32287. };
  32288. const setTranslate = () => {
  32289. const {
  32290. slides,
  32291. rtlTranslate: rtl
  32292. } = swiper;
  32293. const params = swiper.params.flipEffect;
  32294. const rotateFix = getRotateFix(swiper);
  32295. for (let i = 0; i < slides.length; i += 1) {
  32296. const slideEl = slides[i];
  32297. let progress = slideEl.progress;
  32298. if (swiper.params.flipEffect.limitRotation) {
  32299. progress = Math.max(Math.min(slideEl.progress, 1), -1);
  32300. }
  32301. const offset = slideEl.swiperSlideOffset;
  32302. const rotate = -180 * progress;
  32303. let rotateY = rotate;
  32304. let rotateX = 0;
  32305. let tx = swiper.params.cssMode ? -offset - swiper.translate : -offset;
  32306. let ty = 0;
  32307. if (!swiper.isHorizontal()) {
  32308. ty = tx;
  32309. tx = 0;
  32310. rotateX = -rotateY;
  32311. rotateY = 0;
  32312. } else if (rtl) {
  32313. rotateY = -rotateY;
  32314. }
  32315. slideEl.style.zIndex = -Math.abs(Math.round(progress)) + slides.length;
  32316. if (params.slideShadows) {
  32317. createSlideShadows(slideEl, progress);
  32318. }
  32319. const transform = `translate3d(${tx}px, ${ty}px, 0px) rotateX(${rotateFix(rotateX)}deg) rotateY(${rotateFix(rotateY)}deg)`;
  32320. const targetEl = effectTarget(params, slideEl);
  32321. targetEl.style.transform = transform;
  32322. }
  32323. };
  32324. const setTransition = duration => {
  32325. const transformElements = swiper.slides.map(slideEl => getSlideTransformEl(slideEl));
  32326. transformElements.forEach(el => {
  32327. el.style.transitionDuration = `${duration}ms`;
  32328. el.querySelectorAll('.swiper-slide-shadow-top, .swiper-slide-shadow-right, .swiper-slide-shadow-bottom, .swiper-slide-shadow-left').forEach(shadowEl => {
  32329. shadowEl.style.transitionDuration = `${duration}ms`;
  32330. });
  32331. });
  32332. effectVirtualTransitionEnd({
  32333. swiper,
  32334. duration,
  32335. transformElements
  32336. });
  32337. };
  32338. effectInit({
  32339. effect: 'flip',
  32340. swiper,
  32341. on,
  32342. setTranslate,
  32343. setTransition,
  32344. recreateShadows,
  32345. getEffectParams: () => swiper.params.flipEffect,
  32346. perspective: () => true,
  32347. overwriteParams: () => ({
  32348. slidesPerView: 1,
  32349. slidesPerGroup: 1,
  32350. watchSlidesProgress: true,
  32351. spaceBetween: 0,
  32352. virtualTranslate: !swiper.params.cssMode
  32353. })
  32354. });
  32355. }
  32356. function EffectCoverflow(_ref) {
  32357. let {
  32358. swiper,
  32359. extendParams,
  32360. on
  32361. } = _ref;
  32362. extendParams({
  32363. coverflowEffect: {
  32364. rotate: 50,
  32365. stretch: 0,
  32366. depth: 100,
  32367. scale: 1,
  32368. modifier: 1,
  32369. slideShadows: true
  32370. }
  32371. });
  32372. const setTranslate = () => {
  32373. const {
  32374. width: swiperWidth,
  32375. height: swiperHeight,
  32376. slides,
  32377. slidesSizesGrid
  32378. } = swiper;
  32379. const params = swiper.params.coverflowEffect;
  32380. const isHorizontal = swiper.isHorizontal();
  32381. const transform = swiper.translate;
  32382. const center = isHorizontal ? -transform + swiperWidth / 2 : -transform + swiperHeight / 2;
  32383. const rotate = isHorizontal ? params.rotate : -params.rotate;
  32384. const translate = params.depth;
  32385. const r = getRotateFix(swiper);
  32386. // Each slide offset from center
  32387. for (let i = 0, length = slides.length; i < length; i += 1) {
  32388. const slideEl = slides[i];
  32389. const slideSize = slidesSizesGrid[i];
  32390. const slideOffset = slideEl.swiperSlideOffset;
  32391. const centerOffset = (center - slideOffset - slideSize / 2) / slideSize;
  32392. const offsetMultiplier = typeof params.modifier === 'function' ? params.modifier(centerOffset) : centerOffset * params.modifier;
  32393. let rotateY = isHorizontal ? rotate * offsetMultiplier : 0;
  32394. let rotateX = isHorizontal ? 0 : rotate * offsetMultiplier;
  32395. // var rotateZ = 0
  32396. let translateZ = -translate * Math.abs(offsetMultiplier);
  32397. let stretch = params.stretch;
  32398. // Allow percentage to make a relative stretch for responsive sliders
  32399. if (typeof stretch === 'string' && stretch.indexOf('%') !== -1) {
  32400. stretch = parseFloat(params.stretch) / 100 * slideSize;
  32401. }
  32402. let translateY = isHorizontal ? 0 : stretch * offsetMultiplier;
  32403. let translateX = isHorizontal ? stretch * offsetMultiplier : 0;
  32404. let scale = 1 - (1 - params.scale) * Math.abs(offsetMultiplier);
  32405. // Fix for ultra small values
  32406. if (Math.abs(translateX) < 0.001) translateX = 0;
  32407. if (Math.abs(translateY) < 0.001) translateY = 0;
  32408. if (Math.abs(translateZ) < 0.001) translateZ = 0;
  32409. if (Math.abs(rotateY) < 0.001) rotateY = 0;
  32410. if (Math.abs(rotateX) < 0.001) rotateX = 0;
  32411. if (Math.abs(scale) < 0.001) scale = 0;
  32412. const slideTransform = `translate3d(${translateX}px,${translateY}px,${translateZ}px) rotateX(${r(rotateX)}deg) rotateY(${r(rotateY)}deg) scale(${scale})`;
  32413. const targetEl = effectTarget(params, slideEl);
  32414. targetEl.style.transform = slideTransform;
  32415. slideEl.style.zIndex = -Math.abs(Math.round(offsetMultiplier)) + 1;
  32416. if (params.slideShadows) {
  32417. // Set shadows
  32418. let shadowBeforeEl = isHorizontal ? slideEl.querySelector('.swiper-slide-shadow-left') : slideEl.querySelector('.swiper-slide-shadow-top');
  32419. let shadowAfterEl = isHorizontal ? slideEl.querySelector('.swiper-slide-shadow-right') : slideEl.querySelector('.swiper-slide-shadow-bottom');
  32420. if (!shadowBeforeEl) {
  32421. shadowBeforeEl = createShadow('coverflow', slideEl, isHorizontal ? 'left' : 'top');
  32422. }
  32423. if (!shadowAfterEl) {
  32424. shadowAfterEl = createShadow('coverflow', slideEl, isHorizontal ? 'right' : 'bottom');
  32425. }
  32426. if (shadowBeforeEl) shadowBeforeEl.style.opacity = offsetMultiplier > 0 ? offsetMultiplier : 0;
  32427. if (shadowAfterEl) shadowAfterEl.style.opacity = -offsetMultiplier > 0 ? -offsetMultiplier : 0;
  32428. }
  32429. }
  32430. };
  32431. const setTransition = duration => {
  32432. const transformElements = swiper.slides.map(slideEl => getSlideTransformEl(slideEl));
  32433. transformElements.forEach(el => {
  32434. el.style.transitionDuration = `${duration}ms`;
  32435. el.querySelectorAll('.swiper-slide-shadow-top, .swiper-slide-shadow-right, .swiper-slide-shadow-bottom, .swiper-slide-shadow-left').forEach(shadowEl => {
  32436. shadowEl.style.transitionDuration = `${duration}ms`;
  32437. });
  32438. });
  32439. };
  32440. effectInit({
  32441. effect: 'coverflow',
  32442. swiper,
  32443. on,
  32444. setTranslate,
  32445. setTransition,
  32446. perspective: () => true,
  32447. overwriteParams: () => ({
  32448. watchSlidesProgress: true
  32449. })
  32450. });
  32451. }
  32452. function EffectCreative(_ref) {
  32453. let {
  32454. swiper,
  32455. extendParams,
  32456. on
  32457. } = _ref;
  32458. extendParams({
  32459. creativeEffect: {
  32460. limitProgress: 1,
  32461. shadowPerProgress: false,
  32462. progressMultiplier: 1,
  32463. perspective: true,
  32464. prev: {
  32465. translate: [0, 0, 0],
  32466. rotate: [0, 0, 0],
  32467. opacity: 1,
  32468. scale: 1
  32469. },
  32470. next: {
  32471. translate: [0, 0, 0],
  32472. rotate: [0, 0, 0],
  32473. opacity: 1,
  32474. scale: 1
  32475. }
  32476. }
  32477. });
  32478. const getTranslateValue = value => {
  32479. if (typeof value === 'string') return value;
  32480. return `${value}px`;
  32481. };
  32482. const setTranslate = () => {
  32483. const {
  32484. slides,
  32485. wrapperEl,
  32486. slidesSizesGrid
  32487. } = swiper;
  32488. const params = swiper.params.creativeEffect;
  32489. const {
  32490. progressMultiplier: multiplier
  32491. } = params;
  32492. const isCenteredSlides = swiper.params.centeredSlides;
  32493. const rotateFix = getRotateFix(swiper);
  32494. if (isCenteredSlides) {
  32495. const margin = slidesSizesGrid[0] / 2 - swiper.params.slidesOffsetBefore || 0;
  32496. wrapperEl.style.transform = `translateX(calc(50% - ${margin}px))`;
  32497. }
  32498. for (let i = 0; i < slides.length; i += 1) {
  32499. const slideEl = slides[i];
  32500. const slideProgress = slideEl.progress;
  32501. const progress = Math.min(Math.max(slideEl.progress, -params.limitProgress), params.limitProgress);
  32502. let originalProgress = progress;
  32503. if (!isCenteredSlides) {
  32504. originalProgress = Math.min(Math.max(slideEl.originalProgress, -params.limitProgress), params.limitProgress);
  32505. }
  32506. const offset = slideEl.swiperSlideOffset;
  32507. const t = [swiper.params.cssMode ? -offset - swiper.translate : -offset, 0, 0];
  32508. const r = [0, 0, 0];
  32509. let custom = false;
  32510. if (!swiper.isHorizontal()) {
  32511. t[1] = t[0];
  32512. t[0] = 0;
  32513. }
  32514. let data = {
  32515. translate: [0, 0, 0],
  32516. rotate: [0, 0, 0],
  32517. scale: 1,
  32518. opacity: 1
  32519. };
  32520. if (progress < 0) {
  32521. data = params.next;
  32522. custom = true;
  32523. } else if (progress > 0) {
  32524. data = params.prev;
  32525. custom = true;
  32526. }
  32527. // set translate
  32528. t.forEach((value, index) => {
  32529. t[index] = `calc(${value}px + (${getTranslateValue(data.translate[index])} * ${Math.abs(progress * multiplier)}))`;
  32530. });
  32531. // set rotates
  32532. r.forEach((value, index) => {
  32533. let val = data.rotate[index] * Math.abs(progress * multiplier);
  32534. r[index] = val;
  32535. });
  32536. slideEl.style.zIndex = -Math.abs(Math.round(slideProgress)) + slides.length;
  32537. const translateString = t.join(', ');
  32538. const rotateString = `rotateX(${rotateFix(r[0])}deg) rotateY(${rotateFix(r[1])}deg) rotateZ(${rotateFix(r[2])}deg)`;
  32539. const scaleString = originalProgress < 0 ? `scale(${1 + (1 - data.scale) * originalProgress * multiplier})` : `scale(${1 - (1 - data.scale) * originalProgress * multiplier})`;
  32540. const opacityString = originalProgress < 0 ? 1 + (1 - data.opacity) * originalProgress * multiplier : 1 - (1 - data.opacity) * originalProgress * multiplier;
  32541. const transform = `translate3d(${translateString}) ${rotateString} ${scaleString}`;
  32542. // Set shadows
  32543. if (custom && data.shadow || !custom) {
  32544. let shadowEl = slideEl.querySelector('.swiper-slide-shadow');
  32545. if (!shadowEl && data.shadow) {
  32546. shadowEl = createShadow('creative', slideEl);
  32547. }
  32548. if (shadowEl) {
  32549. const shadowOpacity = params.shadowPerProgress ? progress * (1 / params.limitProgress) : progress;
  32550. shadowEl.style.opacity = Math.min(Math.max(Math.abs(shadowOpacity), 0), 1);
  32551. }
  32552. }
  32553. const targetEl = effectTarget(params, slideEl);
  32554. targetEl.style.transform = transform;
  32555. targetEl.style.opacity = opacityString;
  32556. if (data.origin) {
  32557. targetEl.style.transformOrigin = data.origin;
  32558. }
  32559. }
  32560. };
  32561. const setTransition = duration => {
  32562. const transformElements = swiper.slides.map(slideEl => getSlideTransformEl(slideEl));
  32563. transformElements.forEach(el => {
  32564. el.style.transitionDuration = `${duration}ms`;
  32565. el.querySelectorAll('.swiper-slide-shadow').forEach(shadowEl => {
  32566. shadowEl.style.transitionDuration = `${duration}ms`;
  32567. });
  32568. });
  32569. effectVirtualTransitionEnd({
  32570. swiper,
  32571. duration,
  32572. transformElements,
  32573. allSlides: true
  32574. });
  32575. };
  32576. effectInit({
  32577. effect: 'creative',
  32578. swiper,
  32579. on,
  32580. setTranslate,
  32581. setTransition,
  32582. perspective: () => swiper.params.creativeEffect.perspective,
  32583. overwriteParams: () => ({
  32584. watchSlidesProgress: true,
  32585. virtualTranslate: !swiper.params.cssMode
  32586. })
  32587. });
  32588. }
  32589. function EffectCards(_ref) {
  32590. let {
  32591. swiper,
  32592. extendParams,
  32593. on
  32594. } = _ref;
  32595. extendParams({
  32596. cardsEffect: {
  32597. slideShadows: true,
  32598. rotate: true,
  32599. perSlideRotate: 2,
  32600. perSlideOffset: 8
  32601. }
  32602. });
  32603. const setTranslate = () => {
  32604. const {
  32605. slides,
  32606. activeIndex,
  32607. rtlTranslate: rtl
  32608. } = swiper;
  32609. const params = swiper.params.cardsEffect;
  32610. const {
  32611. startTranslate,
  32612. isTouched
  32613. } = swiper.touchEventsData;
  32614. const currentTranslate = rtl ? -swiper.translate : swiper.translate;
  32615. for (let i = 0; i < slides.length; i += 1) {
  32616. const slideEl = slides[i];
  32617. const slideProgress = slideEl.progress;
  32618. const progress = Math.min(Math.max(slideProgress, -4), 4);
  32619. let offset = slideEl.swiperSlideOffset;
  32620. if (swiper.params.centeredSlides && !swiper.params.cssMode) {
  32621. swiper.wrapperEl.style.transform = `translateX(${swiper.minTranslate()}px)`;
  32622. }
  32623. if (swiper.params.centeredSlides && swiper.params.cssMode) {
  32624. offset -= slides[0].swiperSlideOffset;
  32625. }
  32626. let tX = swiper.params.cssMode ? -offset - swiper.translate : -offset;
  32627. let tY = 0;
  32628. const tZ = -100 * Math.abs(progress);
  32629. let scale = 1;
  32630. let rotate = -params.perSlideRotate * progress;
  32631. let tXAdd = params.perSlideOffset - Math.abs(progress) * 0.75;
  32632. const slideIndex = swiper.virtual && swiper.params.virtual.enabled ? swiper.virtual.from + i : i;
  32633. const isSwipeToNext = (slideIndex === activeIndex || slideIndex === activeIndex - 1) && progress > 0 && progress < 1 && (isTouched || swiper.params.cssMode) && currentTranslate < startTranslate;
  32634. const isSwipeToPrev = (slideIndex === activeIndex || slideIndex === activeIndex + 1) && progress < 0 && progress > -1 && (isTouched || swiper.params.cssMode) && currentTranslate > startTranslate;
  32635. if (isSwipeToNext || isSwipeToPrev) {
  32636. const subProgress = (1 - Math.abs((Math.abs(progress) - 0.5) / 0.5)) ** 0.5;
  32637. rotate += -28 * progress * subProgress;
  32638. scale += -0.5 * subProgress;
  32639. tXAdd += 96 * subProgress;
  32640. tY = `${-25 * subProgress * Math.abs(progress)}%`;
  32641. }
  32642. if (progress < 0) {
  32643. // next
  32644. tX = `calc(${tX}px ${rtl ? '-' : '+'} (${tXAdd * Math.abs(progress)}%))`;
  32645. } else if (progress > 0) {
  32646. // prev
  32647. tX = `calc(${tX}px ${rtl ? '-' : '+'} (-${tXAdd * Math.abs(progress)}%))`;
  32648. } else {
  32649. tX = `${tX}px`;
  32650. }
  32651. if (!swiper.isHorizontal()) {
  32652. const prevY = tY;
  32653. tY = tX;
  32654. tX = prevY;
  32655. }
  32656. const scaleString = progress < 0 ? `${1 + (1 - scale) * progress}` : `${1 - (1 - scale) * progress}`;
  32657. /* eslint-disable */
  32658. const transform = `
  32659. translate3d(${tX}, ${tY}, ${tZ}px)
  32660. rotateZ(${params.rotate ? rtl ? -rotate : rotate : 0}deg)
  32661. scale(${scaleString})
  32662. `;
  32663. /* eslint-enable */
  32664. if (params.slideShadows) {
  32665. // Set shadows
  32666. let shadowEl = slideEl.querySelector('.swiper-slide-shadow');
  32667. if (!shadowEl) {
  32668. shadowEl = createShadow('cards', slideEl);
  32669. }
  32670. if (shadowEl) shadowEl.style.opacity = Math.min(Math.max((Math.abs(progress) - 0.5) / 0.5, 0), 1);
  32671. }
  32672. slideEl.style.zIndex = -Math.abs(Math.round(slideProgress)) + slides.length;
  32673. const targetEl = effectTarget(params, slideEl);
  32674. targetEl.style.transform = transform;
  32675. }
  32676. };
  32677. const setTransition = duration => {
  32678. const transformElements = swiper.slides.map(slideEl => getSlideTransformEl(slideEl));
  32679. transformElements.forEach(el => {
  32680. el.style.transitionDuration = `${duration}ms`;
  32681. el.querySelectorAll('.swiper-slide-shadow').forEach(shadowEl => {
  32682. shadowEl.style.transitionDuration = `${duration}ms`;
  32683. });
  32684. });
  32685. effectVirtualTransitionEnd({
  32686. swiper,
  32687. duration,
  32688. transformElements
  32689. });
  32690. };
  32691. effectInit({
  32692. effect: 'cards',
  32693. swiper,
  32694. on,
  32695. setTranslate,
  32696. setTransition,
  32697. perspective: () => true,
  32698. overwriteParams: () => ({
  32699. _loopSwapReset: false,
  32700. watchSlidesProgress: true,
  32701. loopAdditionalSlides: swiper.params.cardsEffect.rotate ? 3 : 2,
  32702. centeredSlides: true,
  32703. virtualTranslate: !swiper.params.cssMode
  32704. })
  32705. });
  32706. }
  32707. /**
  32708. * Swiper 11.2.10
  32709. * Most modern mobile touch slider and framework with hardware accelerated transitions
  32710. * https://swiperjs.com
  32711. *
  32712. * Copyright 2014-2025 Vladimir Kharlampidi
  32713. *
  32714. * Released under the MIT License
  32715. *
  32716. * Released on: June 28, 2025
  32717. */
  32718. // Swiper Class
  32719. 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];
  32720. Swiper.use(modules);
  32721. return Swiper;
  32722. })();