tabler.esm.js 279 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330
  1. /*!
  2. * Tabler v1.0.0-beta17 (https://tabler.io)
  3. * @version 1.0.0-beta17
  4. * @link https://tabler.io
  5. * Copyright 2018-2023 The Tabler Authors
  6. * Copyright 2018-2023 codecalm.net Paweł Kuna
  7. * Licensed under MIT (https://github.com/tabler/tabler/blob/master/LICENSE)
  8. */
  9. var e,t,n="function"==typeof Map?new Map:(e=[],t=[],{has:function(t){return e.indexOf(t)>-1},get:function(n){return t[e.indexOf(n)]},set:function(n,o){-1===e.indexOf(n)&&(e.push(n),t.push(o));},delete:function(n){var o=e.indexOf(n);o>-1&&(e.splice(o,1),t.splice(o,1));}}),o=function(e){return new Event(e,{bubbles:!0})};try{new Event("test");}catch(e){o=function(e){var t=document.createEvent("Event");return t.initEvent(e,!0,!1),t};}function r(e){var t=n.get(e);t&&t.destroy();}function i(e){var t=n.get(e);t&&t.update();}var l=null;"undefined"==typeof window||"function"!=typeof window.getComputedStyle?((l=function(e){return e}).destroy=function(e){return e},l.update=function(e){return e}):((l=function(e,t){return e&&Array.prototype.forEach.call(e.length?e:[e],function(e){return function(e){if(e&&e.nodeName&&"TEXTAREA"===e.nodeName&&!n.has(e)){var t,r=null,i=null,l=null,a=function(){e.clientWidth!==i&&p();},d=function(t){window.removeEventListener("resize",a,!1),e.removeEventListener("input",p,!1),e.removeEventListener("keyup",p,!1),e.removeEventListener("autosize:destroy",d,!1),e.removeEventListener("autosize:update",p,!1),Object.keys(t).forEach(function(n){e.style[n]=t[n];}),n.delete(e);}.bind(e,{height:e.style.height,resize:e.style.resize,overflowY:e.style.overflowY,overflowX:e.style.overflowX,wordWrap:e.style.wordWrap});e.addEventListener("autosize:destroy",d,!1),"onpropertychange"in e&&"oninput"in e&&e.addEventListener("keyup",p,!1),window.addEventListener("resize",a,!1),e.addEventListener("input",p,!1),e.addEventListener("autosize:update",p,!1),e.style.overflowX="hidden",e.style.wordWrap="break-word",n.set(e,{destroy:d,update:p}),"vertical"===(t=window.getComputedStyle(e,null)).resize?e.style.resize="none":"both"===t.resize&&(e.style.resize="horizontal"),r="content-box"===t.boxSizing?-(parseFloat(t.paddingTop)+parseFloat(t.paddingBottom)):parseFloat(t.borderTopWidth)+parseFloat(t.borderBottomWidth),isNaN(r)&&(r=0),p();}function s(t){var n=e.style.width;e.style.width="0px",e.style.width=n,e.style.overflowY=t;}function u(){if(0!==e.scrollHeight){var t=function(e){for(var t=[];e&&e.parentNode&&e.parentNode instanceof Element;)e.parentNode.scrollTop&&(e.parentNode.style.scrollBehavior="auto",t.push([e.parentNode,e.parentNode.scrollTop])),e=e.parentNode;return function(){return t.forEach(function(e){var t=e[0];t.scrollTop=e[1],t.style.scrollBehavior=null;})}}(e);e.style.height="",e.style.height=e.scrollHeight+r+"px",i=e.clientWidth,t();}}function p(){u();var t=Math.round(parseFloat(e.style.height)),n=window.getComputedStyle(e,null),r="content-box"===n.boxSizing?Math.round(parseFloat(n.height)):e.offsetHeight;if(r<t?"hidden"===n.overflowY&&(s("scroll"),u(),r="content-box"===n.boxSizing?Math.round(parseFloat(window.getComputedStyle(e,null).height)):e.offsetHeight):"hidden"!==n.overflowY&&(s("hidden"),u(),r="content-box"===n.boxSizing?Math.round(parseFloat(window.getComputedStyle(e,null).height)):e.offsetHeight),l!==r){l=r;var i=o("autosize:resized");try{e.dispatchEvent(i);}catch(e){}}}}(e)}),e}).destroy=function(e){return e&&Array.prototype.forEach.call(e.length?e:[e],r),e},l.update=function(e){return e&&Array.prototype.forEach.call(e.length?e:[e],i),e});var a=l;
  10. var elements = document.querySelectorAll('[data-bs-toggle="autosize"]');
  11. if (elements.length) {
  12. elements.forEach(function (element) {
  13. a(element);
  14. });
  15. }
  16. function _typeof(obj) {
  17. "@babel/helpers - typeof";
  18. return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
  19. return typeof obj;
  20. } : function (obj) {
  21. return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
  22. }, _typeof(obj);
  23. }
  24. function _classCallCheck(instance, Constructor) {
  25. if (!(instance instanceof Constructor)) {
  26. throw new TypeError("Cannot call a class as a function");
  27. }
  28. }
  29. function _defineProperties(target, props) {
  30. for (var i = 0; i < props.length; i++) {
  31. var descriptor = props[i];
  32. descriptor.enumerable = descriptor.enumerable || false;
  33. descriptor.configurable = true;
  34. if ("value" in descriptor) descriptor.writable = true;
  35. Object.defineProperty(target, descriptor.key, descriptor);
  36. }
  37. }
  38. function _createClass(Constructor, protoProps, staticProps) {
  39. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  40. if (staticProps) _defineProperties(Constructor, staticProps);
  41. Object.defineProperty(Constructor, "prototype", {
  42. writable: false
  43. });
  44. return Constructor;
  45. }
  46. function _defineProperty(obj, key, value) {
  47. if (key in obj) {
  48. Object.defineProperty(obj, key, {
  49. value: value,
  50. enumerable: true,
  51. configurable: true,
  52. writable: true
  53. });
  54. } else {
  55. obj[key] = value;
  56. }
  57. return obj;
  58. }
  59. function _inherits(subClass, superClass) {
  60. if (typeof superClass !== "function" && superClass !== null) {
  61. throw new TypeError("Super expression must either be null or a function");
  62. }
  63. subClass.prototype = Object.create(superClass && superClass.prototype, {
  64. constructor: {
  65. value: subClass,
  66. writable: true,
  67. configurable: true
  68. }
  69. });
  70. Object.defineProperty(subClass, "prototype", {
  71. writable: false
  72. });
  73. if (superClass) _setPrototypeOf(subClass, superClass);
  74. }
  75. function _getPrototypeOf(o) {
  76. _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
  77. return o.__proto__ || Object.getPrototypeOf(o);
  78. };
  79. return _getPrototypeOf(o);
  80. }
  81. function _setPrototypeOf(o, p) {
  82. _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
  83. o.__proto__ = p;
  84. return o;
  85. };
  86. return _setPrototypeOf(o, p);
  87. }
  88. function _isNativeReflectConstruct() {
  89. if (typeof Reflect === "undefined" || !Reflect.construct) return false;
  90. if (Reflect.construct.sham) return false;
  91. if (typeof Proxy === "function") return true;
  92. try {
  93. Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
  94. return true;
  95. } catch (e) {
  96. return false;
  97. }
  98. }
  99. function _objectWithoutPropertiesLoose(source, excluded) {
  100. if (source == null) return {};
  101. var target = {};
  102. var sourceKeys = Object.keys(source);
  103. var key, i;
  104. for (i = 0; i < sourceKeys.length; i++) {
  105. key = sourceKeys[i];
  106. if (excluded.indexOf(key) >= 0) continue;
  107. target[key] = source[key];
  108. }
  109. return target;
  110. }
  111. function _objectWithoutProperties(source, excluded) {
  112. if (source == null) return {};
  113. var target = _objectWithoutPropertiesLoose(source, excluded);
  114. var key, i;
  115. if (Object.getOwnPropertySymbols) {
  116. var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
  117. for (i = 0; i < sourceSymbolKeys.length; i++) {
  118. key = sourceSymbolKeys[i];
  119. if (excluded.indexOf(key) >= 0) continue;
  120. if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
  121. target[key] = source[key];
  122. }
  123. }
  124. return target;
  125. }
  126. function _assertThisInitialized(self) {
  127. if (self === void 0) {
  128. throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
  129. }
  130. return self;
  131. }
  132. function _possibleConstructorReturn(self, call) {
  133. if (call && (typeof call === "object" || typeof call === "function")) {
  134. return call;
  135. } else if (call !== void 0) {
  136. throw new TypeError("Derived constructors may only return object or undefined");
  137. }
  138. return _assertThisInitialized(self);
  139. }
  140. function _createSuper(Derived) {
  141. var hasNativeReflectConstruct = _isNativeReflectConstruct();
  142. return function _createSuperInternal() {
  143. var Super = _getPrototypeOf(Derived),
  144. result;
  145. if (hasNativeReflectConstruct) {
  146. var NewTarget = _getPrototypeOf(this).constructor;
  147. result = Reflect.construct(Super, arguments, NewTarget);
  148. } else {
  149. result = Super.apply(this, arguments);
  150. }
  151. return _possibleConstructorReturn(this, result);
  152. };
  153. }
  154. function _superPropBase(object, property) {
  155. while (!Object.prototype.hasOwnProperty.call(object, property)) {
  156. object = _getPrototypeOf(object);
  157. if (object === null) break;
  158. }
  159. return object;
  160. }
  161. function _get() {
  162. if (typeof Reflect !== "undefined" && Reflect.get) {
  163. _get = Reflect.get.bind();
  164. } else {
  165. _get = function _get(target, property, receiver) {
  166. var base = _superPropBase(target, property);
  167. if (!base) return;
  168. var desc = Object.getOwnPropertyDescriptor(base, property);
  169. if (desc.get) {
  170. return desc.get.call(arguments.length < 3 ? target : receiver);
  171. }
  172. return desc.value;
  173. };
  174. }
  175. return _get.apply(this, arguments);
  176. }
  177. function set(target, property, value, receiver) {
  178. if (typeof Reflect !== "undefined" && Reflect.set) {
  179. set = Reflect.set;
  180. } else {
  181. set = function set(target, property, value, receiver) {
  182. var base = _superPropBase(target, property);
  183. var desc;
  184. if (base) {
  185. desc = Object.getOwnPropertyDescriptor(base, property);
  186. if (desc.set) {
  187. desc.set.call(receiver, value);
  188. return true;
  189. } else if (!desc.writable) {
  190. return false;
  191. }
  192. }
  193. desc = Object.getOwnPropertyDescriptor(receiver, property);
  194. if (desc) {
  195. if (!desc.writable) {
  196. return false;
  197. }
  198. desc.value = value;
  199. Object.defineProperty(receiver, property, desc);
  200. } else {
  201. _defineProperty(receiver, property, value);
  202. }
  203. return true;
  204. };
  205. }
  206. return set(target, property, value, receiver);
  207. }
  208. function _set(target, property, value, receiver, isStrict) {
  209. var s = set(target, property, value, receiver || target);
  210. if (!s && isStrict) {
  211. throw new Error('failed to set property');
  212. }
  213. return value;
  214. }
  215. function _slicedToArray(arr, i) {
  216. return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
  217. }
  218. function _toConsumableArray(arr) {
  219. return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
  220. }
  221. function _arrayWithoutHoles(arr) {
  222. if (Array.isArray(arr)) return _arrayLikeToArray(arr);
  223. }
  224. function _arrayWithHoles(arr) {
  225. if (Array.isArray(arr)) return arr;
  226. }
  227. function _iterableToArray(iter) {
  228. if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
  229. }
  230. function _iterableToArrayLimit(arr, i) {
  231. var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
  232. if (_i == null) return;
  233. var _arr = [];
  234. var _n = true;
  235. var _d = false;
  236. var _s, _e;
  237. try {
  238. for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
  239. _arr.push(_s.value);
  240. if (i && _arr.length === i) break;
  241. }
  242. } catch (err) {
  243. _d = true;
  244. _e = err;
  245. } finally {
  246. try {
  247. if (!_n && _i["return"] != null) _i["return"]();
  248. } finally {
  249. if (_d) throw _e;
  250. }
  251. }
  252. return _arr;
  253. }
  254. function _unsupportedIterableToArray(o, minLen) {
  255. if (!o) return;
  256. if (typeof o === "string") return _arrayLikeToArray(o, minLen);
  257. var n = Object.prototype.toString.call(o).slice(8, -1);
  258. if (n === "Object" && o.constructor) n = o.constructor.name;
  259. if (n === "Map" || n === "Set") return Array.from(o);
  260. if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
  261. }
  262. function _arrayLikeToArray(arr, len) {
  263. if (len == null || len > arr.length) len = arr.length;
  264. for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
  265. return arr2;
  266. }
  267. function _nonIterableSpread() {
  268. throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  269. }
  270. function _nonIterableRest() {
  271. throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  272. }
  273. var ChangeDetails = function () {
  274. function ChangeDetails(details) {
  275. _classCallCheck(this, ChangeDetails);
  276. Object.assign(this, {
  277. inserted: '',
  278. rawInserted: '',
  279. skip: false,
  280. tailShift: 0
  281. }, details);
  282. }
  283. _createClass(ChangeDetails, [{
  284. key: "aggregate",
  285. value: function aggregate(details) {
  286. this.rawInserted += details.rawInserted;
  287. this.skip = this.skip || details.skip;
  288. this.inserted += details.inserted;
  289. this.tailShift += details.tailShift;
  290. return this;
  291. }
  292. }, {
  293. key: "offset",
  294. get: function get() {
  295. return this.tailShift + this.inserted.length;
  296. }
  297. }]);
  298. return ChangeDetails;
  299. }();
  300. function isString(str) {
  301. return typeof str === 'string' || str instanceof String;
  302. }
  303. var DIRECTION = {
  304. NONE: 'NONE',
  305. LEFT: 'LEFT',
  306. FORCE_LEFT: 'FORCE_LEFT',
  307. RIGHT: 'RIGHT',
  308. FORCE_RIGHT: 'FORCE_RIGHT'
  309. };
  310. function forceDirection(direction) {
  311. switch (direction) {
  312. case DIRECTION.LEFT:
  313. return DIRECTION.FORCE_LEFT;
  314. case DIRECTION.RIGHT:
  315. return DIRECTION.FORCE_RIGHT;
  316. default:
  317. return direction;
  318. }
  319. }
  320. function escapeRegExp(str) {
  321. return str.replace(/([.*+?^=!:${}()|[\]\/\\])/g, '\\$1');
  322. }
  323. function normalizePrepare(prep) {
  324. return Array.isArray(prep) ? prep : [prep, new ChangeDetails()];
  325. }
  326. function objectIncludes(b, a) {
  327. if (a === b) return true;
  328. var arrA = Array.isArray(a),
  329. arrB = Array.isArray(b),
  330. i;
  331. if (arrA && arrB) {
  332. if (a.length != b.length) return false;
  333. for (i = 0; i < a.length; i++) {
  334. if (!objectIncludes(a[i], b[i])) return false;
  335. }
  336. return true;
  337. }
  338. if (arrA != arrB) return false;
  339. if (a && b && _typeof(a) === 'object' && _typeof(b) === 'object') {
  340. var dateA = a instanceof Date,
  341. dateB = b instanceof Date;
  342. if (dateA && dateB) return a.getTime() == b.getTime();
  343. if (dateA != dateB) return false;
  344. var regexpA = a instanceof RegExp,
  345. regexpB = b instanceof RegExp;
  346. if (regexpA && regexpB) return a.toString() == b.toString();
  347. if (regexpA != regexpB) return false;
  348. var keys = Object.keys(a);
  349. for (i = 0; i < keys.length; i++) {
  350. if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
  351. }
  352. for (i = 0; i < keys.length; i++) {
  353. if (!objectIncludes(b[keys[i]], a[keys[i]])) return false;
  354. }
  355. return true;
  356. } else if (a && b && typeof a === 'function' && typeof b === 'function') {
  357. return a.toString() === b.toString();
  358. }
  359. return false;
  360. }
  361. var ActionDetails = function () {
  362. function ActionDetails(value, cursorPos, oldValue, oldSelection) {
  363. _classCallCheck(this, ActionDetails);
  364. this.value = value;
  365. this.cursorPos = cursorPos;
  366. this.oldValue = oldValue;
  367. this.oldSelection = oldSelection;
  368. while (this.value.slice(0, this.startChangePos) !== this.oldValue.slice(0, this.startChangePos)) {
  369. --this.oldSelection.start;
  370. }
  371. }
  372. _createClass(ActionDetails, [{
  373. key: "startChangePos",
  374. get: function get() {
  375. return Math.min(this.cursorPos, this.oldSelection.start);
  376. }
  377. }, {
  378. key: "insertedCount",
  379. get: function get() {
  380. return this.cursorPos - this.startChangePos;
  381. }
  382. }, {
  383. key: "inserted",
  384. get: function get() {
  385. return this.value.substr(this.startChangePos, this.insertedCount);
  386. }
  387. }, {
  388. key: "removedCount",
  389. get: function get() {
  390. return Math.max(this.oldSelection.end - this.startChangePos ||
  391. this.oldValue.length - this.value.length, 0);
  392. }
  393. }, {
  394. key: "removed",
  395. get: function get() {
  396. return this.oldValue.substr(this.startChangePos, this.removedCount);
  397. }
  398. }, {
  399. key: "head",
  400. get: function get() {
  401. return this.value.substring(0, this.startChangePos);
  402. }
  403. }, {
  404. key: "tail",
  405. get: function get() {
  406. return this.value.substring(this.startChangePos + this.insertedCount);
  407. }
  408. }, {
  409. key: "removeDirection",
  410. get: function get() {
  411. if (!this.removedCount || this.insertedCount) return DIRECTION.NONE;
  412. return (this.oldSelection.end === this.cursorPos || this.oldSelection.start === this.cursorPos) &&
  413. this.oldSelection.end === this.oldSelection.start ? DIRECTION.RIGHT : DIRECTION.LEFT;
  414. }
  415. }]);
  416. return ActionDetails;
  417. }();
  418. var ContinuousTailDetails = function () {
  419. function ContinuousTailDetails() {
  420. var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
  421. var from = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
  422. var stop = arguments.length > 2 ? arguments[2] : undefined;
  423. _classCallCheck(this, ContinuousTailDetails);
  424. this.value = value;
  425. this.from = from;
  426. this.stop = stop;
  427. }
  428. _createClass(ContinuousTailDetails, [{
  429. key: "toString",
  430. value: function toString() {
  431. return this.value;
  432. }
  433. }, {
  434. key: "extend",
  435. value: function extend(tail) {
  436. this.value += String(tail);
  437. }
  438. }, {
  439. key: "appendTo",
  440. value: function appendTo(masked) {
  441. return masked.append(this.toString(), {
  442. tail: true
  443. }).aggregate(masked._appendPlaceholder());
  444. }
  445. }, {
  446. key: "state",
  447. get: function get() {
  448. return {
  449. value: this.value,
  450. from: this.from,
  451. stop: this.stop
  452. };
  453. },
  454. set: function set(state) {
  455. Object.assign(this, state);
  456. }
  457. }, {
  458. key: "unshift",
  459. value: function unshift(beforePos) {
  460. if (!this.value.length || beforePos != null && this.from >= beforePos) return '';
  461. var shiftChar = this.value[0];
  462. this.value = this.value.slice(1);
  463. return shiftChar;
  464. }
  465. }, {
  466. key: "shift",
  467. value: function shift() {
  468. if (!this.value.length) return '';
  469. var shiftChar = this.value[this.value.length - 1];
  470. this.value = this.value.slice(0, -1);
  471. return shiftChar;
  472. }
  473. }]);
  474. return ContinuousTailDetails;
  475. }();
  476. function IMask(el) {
  477. var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  478. return new IMask.InputMask(el, opts);
  479. }
  480. var Masked = function () {
  481. function Masked(opts) {
  482. _classCallCheck(this, Masked);
  483. this._value = '';
  484. this._update(Object.assign({}, Masked.DEFAULTS, opts));
  485. this.isInitialized = true;
  486. }
  487. _createClass(Masked, [{
  488. key: "updateOptions",
  489. value: function updateOptions(opts) {
  490. if (!Object.keys(opts).length) return;
  491. this.withValueRefresh(this._update.bind(this, opts));
  492. }
  493. }, {
  494. key: "_update",
  495. value: function _update(opts) {
  496. Object.assign(this, opts);
  497. }
  498. }, {
  499. key: "state",
  500. get: function get() {
  501. return {
  502. _value: this.value
  503. };
  504. },
  505. set: function set(state) {
  506. this._value = state._value;
  507. }
  508. }, {
  509. key: "reset",
  510. value: function reset() {
  511. this._value = '';
  512. }
  513. }, {
  514. key: "value",
  515. get: function get() {
  516. return this._value;
  517. },
  518. set: function set(value) {
  519. this.resolve(value);
  520. }
  521. }, {
  522. key: "resolve",
  523. value: function resolve(value) {
  524. this.reset();
  525. this.append(value, {
  526. input: true
  527. }, '');
  528. this.doCommit();
  529. return this.value;
  530. }
  531. }, {
  532. key: "unmaskedValue",
  533. get: function get() {
  534. return this.value;
  535. },
  536. set: function set(value) {
  537. this.reset();
  538. this.append(value, {}, '');
  539. this.doCommit();
  540. }
  541. }, {
  542. key: "typedValue",
  543. get: function get() {
  544. return this.doParse(this.value);
  545. },
  546. set: function set(value) {
  547. this.value = this.doFormat(value);
  548. }
  549. }, {
  550. key: "rawInputValue",
  551. get: function get() {
  552. return this.extractInput(0, this.value.length, {
  553. raw: true
  554. });
  555. },
  556. set: function set(value) {
  557. this.reset();
  558. this.append(value, {
  559. raw: true
  560. }, '');
  561. this.doCommit();
  562. }
  563. }, {
  564. key: "isComplete",
  565. get: function get() {
  566. return true;
  567. }
  568. }, {
  569. key: "isFilled",
  570. get: function get() {
  571. return this.isComplete;
  572. }
  573. }, {
  574. key: "nearestInputPos",
  575. value: function nearestInputPos(cursorPos, direction) {
  576. return cursorPos;
  577. }
  578. }, {
  579. key: "extractInput",
  580. value: function extractInput() {
  581. var fromPos = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  582. var toPos = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.value.length;
  583. return this.value.slice(fromPos, toPos);
  584. }
  585. }, {
  586. key: "extractTail",
  587. value: function extractTail() {
  588. var fromPos = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  589. var toPos = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.value.length;
  590. return new ContinuousTailDetails(this.extractInput(fromPos, toPos), fromPos);
  591. }
  592. }, {
  593. key: "appendTail",
  594. value: function appendTail(tail) {
  595. if (isString(tail)) tail = new ContinuousTailDetails(String(tail));
  596. return tail.appendTo(this);
  597. }
  598. }, {
  599. key: "_appendCharRaw",
  600. value: function _appendCharRaw(ch) {
  601. if (!ch) return new ChangeDetails();
  602. this._value += ch;
  603. return new ChangeDetails({
  604. inserted: ch,
  605. rawInserted: ch
  606. });
  607. }
  608. }, {
  609. key: "_appendChar",
  610. value: function _appendChar(ch) {
  611. var flags = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  612. var checkTail = arguments.length > 2 ? arguments[2] : undefined;
  613. var consistentState = this.state;
  614. var details;
  615. var _normalizePrepare = normalizePrepare(this.doPrepare(ch, flags));
  616. var _normalizePrepare2 = _slicedToArray(_normalizePrepare, 2);
  617. ch = _normalizePrepare2[0];
  618. details = _normalizePrepare2[1];
  619. details = details.aggregate(this._appendCharRaw(ch, flags));
  620. if (details.inserted) {
  621. var consistentTail;
  622. var appended = this.doValidate(flags) !== false;
  623. if (appended && checkTail != null) {
  624. var beforeTailState = this.state;
  625. if (this.overwrite === true) {
  626. consistentTail = checkTail.state;
  627. checkTail.unshift(this.value.length);
  628. }
  629. var tailDetails = this.appendTail(checkTail);
  630. appended = tailDetails.rawInserted === checkTail.toString();
  631. if (!(appended && tailDetails.inserted) && this.overwrite === 'shift') {
  632. this.state = beforeTailState;
  633. consistentTail = checkTail.state;
  634. checkTail.shift();
  635. tailDetails = this.appendTail(checkTail);
  636. appended = tailDetails.rawInserted === checkTail.toString();
  637. }
  638. if (appended && tailDetails.inserted) this.state = beforeTailState;
  639. }
  640. if (!appended) {
  641. details = new ChangeDetails();
  642. this.state = consistentState;
  643. if (checkTail && consistentTail) checkTail.state = consistentTail;
  644. }
  645. }
  646. return details;
  647. }
  648. }, {
  649. key: "_appendPlaceholder",
  650. value: function _appendPlaceholder() {
  651. return new ChangeDetails();
  652. }
  653. }, {
  654. key: "_appendEager",
  655. value: function _appendEager() {
  656. return new ChangeDetails();
  657. }
  658. }, {
  659. key: "append",
  660. value: function append(str, flags, tail) {
  661. if (!isString(str)) throw new Error('value should be string');
  662. var details = new ChangeDetails();
  663. var checkTail = isString(tail) ? new ContinuousTailDetails(String(tail)) : tail;
  664. if (flags !== null && flags !== void 0 && flags.tail) flags._beforeTailState = this.state;
  665. for (var ci = 0; ci < str.length; ++ci) {
  666. details.aggregate(this._appendChar(str[ci], flags, checkTail));
  667. }
  668. if (checkTail != null) {
  669. details.tailShift += this.appendTail(checkTail).tailShift;
  670. }
  671. if (this.eager && flags !== null && flags !== void 0 && flags.input && str) {
  672. details.aggregate(this._appendEager());
  673. }
  674. return details;
  675. }
  676. }, {
  677. key: "remove",
  678. value: function remove() {
  679. var fromPos = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  680. var toPos = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.value.length;
  681. this._value = this.value.slice(0, fromPos) + this.value.slice(toPos);
  682. return new ChangeDetails();
  683. }
  684. }, {
  685. key: "withValueRefresh",
  686. value: function withValueRefresh(fn) {
  687. if (this._refreshing || !this.isInitialized) return fn();
  688. this._refreshing = true;
  689. var rawInput = this.rawInputValue;
  690. var value = this.value;
  691. var ret = fn();
  692. this.rawInputValue = rawInput;
  693. if (this.value && this.value !== value && value.indexOf(this.value) === 0) {
  694. this.append(value.slice(this.value.length), {}, '');
  695. }
  696. delete this._refreshing;
  697. return ret;
  698. }
  699. }, {
  700. key: "runIsolated",
  701. value: function runIsolated(fn) {
  702. if (this._isolated || !this.isInitialized) return fn(this);
  703. this._isolated = true;
  704. var state = this.state;
  705. var ret = fn(this);
  706. this.state = state;
  707. delete this._isolated;
  708. return ret;
  709. }
  710. }, {
  711. key: "doPrepare",
  712. value: function doPrepare(str) {
  713. var flags = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  714. return this.prepare ? this.prepare(str, this, flags) : str;
  715. }
  716. }, {
  717. key: "doValidate",
  718. value: function doValidate(flags) {
  719. return (!this.validate || this.validate(this.value, this, flags)) && (!this.parent || this.parent.doValidate(flags));
  720. }
  721. }, {
  722. key: "doCommit",
  723. value: function doCommit() {
  724. if (this.commit) this.commit(this.value, this);
  725. }
  726. }, {
  727. key: "doFormat",
  728. value: function doFormat(value) {
  729. return this.format ? this.format(value, this) : value;
  730. }
  731. }, {
  732. key: "doParse",
  733. value: function doParse(str) {
  734. return this.parse ? this.parse(str, this) : str;
  735. }
  736. }, {
  737. key: "splice",
  738. value: function splice(start, deleteCount, inserted, removeDirection) {
  739. var flags = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {
  740. input: true
  741. };
  742. var tailPos = start + deleteCount;
  743. var tail = this.extractTail(tailPos);
  744. var oldRawValue;
  745. if (this.eager) {
  746. removeDirection = forceDirection(removeDirection);
  747. oldRawValue = this.extractInput(0, tailPos, {
  748. raw: true
  749. });
  750. }
  751. var startChangePos = this.nearestInputPos(start, deleteCount > 1 && start !== 0 && !this.eager ? DIRECTION.NONE : removeDirection);
  752. var details = new ChangeDetails({
  753. tailShift: startChangePos - start
  754. }).aggregate(this.remove(startChangePos));
  755. if (this.eager && removeDirection !== DIRECTION.NONE && oldRawValue === this.rawInputValue) {
  756. if (removeDirection === DIRECTION.FORCE_LEFT) {
  757. var valLength;
  758. while (oldRawValue === this.rawInputValue && (valLength = this.value.length)) {
  759. details.aggregate(new ChangeDetails({
  760. tailShift: -1
  761. })).aggregate(this.remove(valLength - 1));
  762. }
  763. } else if (removeDirection === DIRECTION.FORCE_RIGHT) {
  764. tail.unshift();
  765. }
  766. }
  767. return details.aggregate(this.append(inserted, flags, tail));
  768. }
  769. }, {
  770. key: "maskEquals",
  771. value: function maskEquals(mask) {
  772. return this.mask === mask;
  773. }
  774. }, {
  775. key: "typedValueEquals",
  776. value: function typedValueEquals(value) {
  777. var tval = this.typedValue;
  778. return value === tval || Masked.EMPTY_VALUES.includes(value) && Masked.EMPTY_VALUES.includes(tval) || this.doFormat(value) === this.doFormat(this.typedValue);
  779. }
  780. }]);
  781. return Masked;
  782. }();
  783. Masked.DEFAULTS = {
  784. format: function format(v) {
  785. return v;
  786. },
  787. parse: function parse(v) {
  788. return v;
  789. }
  790. };
  791. Masked.EMPTY_VALUES = [undefined, null, ''];
  792. IMask.Masked = Masked;
  793. function maskedClass(mask) {
  794. if (mask == null) {
  795. throw new Error('mask property should be defined');
  796. }
  797. if (mask instanceof RegExp) return IMask.MaskedRegExp;
  798. if (isString(mask)) return IMask.MaskedPattern;
  799. if (mask instanceof Date || mask === Date) return IMask.MaskedDate;
  800. if (mask instanceof Number || typeof mask === 'number' || mask === Number) return IMask.MaskedNumber;
  801. if (Array.isArray(mask) || mask === Array) return IMask.MaskedDynamic;
  802. if (IMask.Masked && mask.prototype instanceof IMask.Masked) return mask;
  803. if (mask instanceof IMask.Masked) return mask.constructor;
  804. if (mask instanceof Function) return IMask.MaskedFunction;
  805. console.warn('Mask not found for mask', mask);
  806. return IMask.Masked;
  807. }
  808. function createMask(opts) {
  809. if (IMask.Masked && opts instanceof IMask.Masked) return opts;
  810. opts = Object.assign({}, opts);
  811. var mask = opts.mask;
  812. if (IMask.Masked && mask instanceof IMask.Masked) return mask;
  813. var MaskedClass = maskedClass(mask);
  814. if (!MaskedClass) throw new Error('Masked class is not found for provided mask, appropriate module needs to be import manually before creating mask.');
  815. return new MaskedClass(opts);
  816. }
  817. IMask.createMask = createMask;
  818. var _excluded$4 = ["mask"];
  819. var DEFAULT_INPUT_DEFINITIONS = {
  820. '0': /\d/,
  821. 'a': /[\u0041-\u005A\u0061-\u007A\u00AA\u00B5\u00BA\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0\u08A2-\u08AC\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097F\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C33\u0C35-\u0C39\u0C3D\u0C58\u0C59\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D60\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191C\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19C1-\u19C7\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA697\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA793\uA7A0-\uA7AA\uA7F8-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA80-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]/,
  822. '*': /./
  823. };
  824. var PatternInputDefinition = function () {
  825. function PatternInputDefinition(opts) {
  826. _classCallCheck(this, PatternInputDefinition);
  827. var mask = opts.mask,
  828. blockOpts = _objectWithoutProperties(opts, _excluded$4);
  829. this.masked = createMask({
  830. mask: mask
  831. });
  832. Object.assign(this, blockOpts);
  833. }
  834. _createClass(PatternInputDefinition, [{
  835. key: "reset",
  836. value: function reset() {
  837. this.isFilled = false;
  838. this.masked.reset();
  839. }
  840. }, {
  841. key: "remove",
  842. value: function remove() {
  843. var fromPos = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  844. var toPos = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.value.length;
  845. if (fromPos === 0 && toPos >= 1) {
  846. this.isFilled = false;
  847. return this.masked.remove(fromPos, toPos);
  848. }
  849. return new ChangeDetails();
  850. }
  851. }, {
  852. key: "value",
  853. get: function get() {
  854. return this.masked.value || (this.isFilled && !this.isOptional ? this.placeholderChar : '');
  855. }
  856. }, {
  857. key: "unmaskedValue",
  858. get: function get() {
  859. return this.masked.unmaskedValue;
  860. }
  861. }, {
  862. key: "isComplete",
  863. get: function get() {
  864. return Boolean(this.masked.value) || this.isOptional;
  865. }
  866. }, {
  867. key: "_appendChar",
  868. value: function _appendChar(ch) {
  869. var flags = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  870. if (this.isFilled) return new ChangeDetails();
  871. var state = this.masked.state;
  872. var details = this.masked._appendChar(ch, flags);
  873. if (details.inserted && this.doValidate(flags) === false) {
  874. details.inserted = details.rawInserted = '';
  875. this.masked.state = state;
  876. }
  877. if (!details.inserted && !this.isOptional && !this.lazy && !flags.input) {
  878. details.inserted = this.placeholderChar;
  879. }
  880. details.skip = !details.inserted && !this.isOptional;
  881. this.isFilled = Boolean(details.inserted);
  882. return details;
  883. }
  884. }, {
  885. key: "append",
  886. value: function append() {
  887. var _this$masked;
  888. return (_this$masked = this.masked).append.apply(_this$masked, arguments);
  889. }
  890. }, {
  891. key: "_appendPlaceholder",
  892. value: function _appendPlaceholder() {
  893. var details = new ChangeDetails();
  894. if (this.isFilled || this.isOptional) return details;
  895. this.isFilled = true;
  896. details.inserted = this.placeholderChar;
  897. return details;
  898. }
  899. }, {
  900. key: "_appendEager",
  901. value: function _appendEager() {
  902. return new ChangeDetails();
  903. }
  904. }, {
  905. key: "extractTail",
  906. value: function extractTail() {
  907. var _this$masked2;
  908. return (_this$masked2 = this.masked).extractTail.apply(_this$masked2, arguments);
  909. }
  910. }, {
  911. key: "appendTail",
  912. value: function appendTail() {
  913. var _this$masked3;
  914. return (_this$masked3 = this.masked).appendTail.apply(_this$masked3, arguments);
  915. }
  916. }, {
  917. key: "extractInput",
  918. value: function extractInput() {
  919. var fromPos = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  920. var toPos = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.value.length;
  921. var flags = arguments.length > 2 ? arguments[2] : undefined;
  922. return this.masked.extractInput(fromPos, toPos, flags);
  923. }
  924. }, {
  925. key: "nearestInputPos",
  926. value: function nearestInputPos(cursorPos) {
  927. var direction = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DIRECTION.NONE;
  928. var minPos = 0;
  929. var maxPos = this.value.length;
  930. var boundPos = Math.min(Math.max(cursorPos, minPos), maxPos);
  931. switch (direction) {
  932. case DIRECTION.LEFT:
  933. case DIRECTION.FORCE_LEFT:
  934. return this.isComplete ? boundPos : minPos;
  935. case DIRECTION.RIGHT:
  936. case DIRECTION.FORCE_RIGHT:
  937. return this.isComplete ? boundPos : maxPos;
  938. case DIRECTION.NONE:
  939. default:
  940. return boundPos;
  941. }
  942. }
  943. }, {
  944. key: "doValidate",
  945. value: function doValidate() {
  946. var _this$masked4, _this$parent;
  947. return (_this$masked4 = this.masked).doValidate.apply(_this$masked4, arguments) && (!this.parent || (_this$parent = this.parent).doValidate.apply(_this$parent, arguments));
  948. }
  949. }, {
  950. key: "doCommit",
  951. value: function doCommit() {
  952. this.masked.doCommit();
  953. }
  954. }, {
  955. key: "state",
  956. get: function get() {
  957. return {
  958. masked: this.masked.state,
  959. isFilled: this.isFilled
  960. };
  961. },
  962. set: function set(state) {
  963. this.masked.state = state.masked;
  964. this.isFilled = state.isFilled;
  965. }
  966. }]);
  967. return PatternInputDefinition;
  968. }();
  969. var PatternFixedDefinition = function () {
  970. function PatternFixedDefinition(opts) {
  971. _classCallCheck(this, PatternFixedDefinition);
  972. Object.assign(this, opts);
  973. this._value = '';
  974. this.isFixed = true;
  975. }
  976. _createClass(PatternFixedDefinition, [{
  977. key: "value",
  978. get: function get() {
  979. return this._value;
  980. }
  981. }, {
  982. key: "unmaskedValue",
  983. get: function get() {
  984. return this.isUnmasking ? this.value : '';
  985. }
  986. }, {
  987. key: "reset",
  988. value: function reset() {
  989. this._isRawInput = false;
  990. this._value = '';
  991. }
  992. }, {
  993. key: "remove",
  994. value: function remove() {
  995. var fromPos = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  996. var toPos = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this._value.length;
  997. this._value = this._value.slice(0, fromPos) + this._value.slice(toPos);
  998. if (!this._value) this._isRawInput = false;
  999. return new ChangeDetails();
  1000. }
  1001. }, {
  1002. key: "nearestInputPos",
  1003. value: function nearestInputPos(cursorPos) {
  1004. var direction = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DIRECTION.NONE;
  1005. var minPos = 0;
  1006. var maxPos = this._value.length;
  1007. switch (direction) {
  1008. case DIRECTION.LEFT:
  1009. case DIRECTION.FORCE_LEFT:
  1010. return minPos;
  1011. case DIRECTION.NONE:
  1012. case DIRECTION.RIGHT:
  1013. case DIRECTION.FORCE_RIGHT:
  1014. default:
  1015. return maxPos;
  1016. }
  1017. }
  1018. }, {
  1019. key: "extractInput",
  1020. value: function extractInput() {
  1021. var fromPos = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  1022. var toPos = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this._value.length;
  1023. var flags = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  1024. return flags.raw && this._isRawInput && this._value.slice(fromPos, toPos) || '';
  1025. }
  1026. }, {
  1027. key: "isComplete",
  1028. get: function get() {
  1029. return true;
  1030. }
  1031. }, {
  1032. key: "isFilled",
  1033. get: function get() {
  1034. return Boolean(this._value);
  1035. }
  1036. }, {
  1037. key: "_appendChar",
  1038. value: function _appendChar(ch) {
  1039. var flags = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  1040. var details = new ChangeDetails();
  1041. if (this._value) return details;
  1042. var appended = this.char === ch;
  1043. var isResolved = appended && (this.isUnmasking || flags.input || flags.raw) && (!flags.raw || !this.eager) && !flags.tail;
  1044. if (isResolved) details.rawInserted = this.char;
  1045. this._value = details.inserted = this.char;
  1046. this._isRawInput = isResolved && (flags.raw || flags.input);
  1047. return details;
  1048. }
  1049. }, {
  1050. key: "_appendEager",
  1051. value: function _appendEager() {
  1052. return this._appendChar(this.char, {
  1053. tail: true
  1054. });
  1055. }
  1056. }, {
  1057. key: "_appendPlaceholder",
  1058. value: function _appendPlaceholder() {
  1059. var details = new ChangeDetails();
  1060. if (this._value) return details;
  1061. this._value = details.inserted = this.char;
  1062. return details;
  1063. }
  1064. }, {
  1065. key: "extractTail",
  1066. value: function extractTail() {
  1067. arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.value.length;
  1068. return new ContinuousTailDetails('');
  1069. }
  1070. }, {
  1071. key: "appendTail",
  1072. value: function appendTail(tail) {
  1073. if (isString(tail)) tail = new ContinuousTailDetails(String(tail));
  1074. return tail.appendTo(this);
  1075. }
  1076. }, {
  1077. key: "append",
  1078. value: function append(str, flags, tail) {
  1079. var details = this._appendChar(str[0], flags);
  1080. if (tail != null) {
  1081. details.tailShift += this.appendTail(tail).tailShift;
  1082. }
  1083. return details;
  1084. }
  1085. }, {
  1086. key: "doCommit",
  1087. value: function doCommit() {}
  1088. }, {
  1089. key: "state",
  1090. get: function get() {
  1091. return {
  1092. _value: this._value,
  1093. _isRawInput: this._isRawInput
  1094. };
  1095. },
  1096. set: function set(state) {
  1097. Object.assign(this, state);
  1098. }
  1099. }]);
  1100. return PatternFixedDefinition;
  1101. }();
  1102. var _excluded$3 = ["chunks"];
  1103. var ChunksTailDetails = function () {
  1104. function ChunksTailDetails() {
  1105. var chunks = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
  1106. var from = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
  1107. _classCallCheck(this, ChunksTailDetails);
  1108. this.chunks = chunks;
  1109. this.from = from;
  1110. }
  1111. _createClass(ChunksTailDetails, [{
  1112. key: "toString",
  1113. value: function toString() {
  1114. return this.chunks.map(String).join('');
  1115. }
  1116. }, {
  1117. key: "extend",
  1118. value: function extend(tailChunk) {
  1119. if (!String(tailChunk)) return;
  1120. if (isString(tailChunk)) tailChunk = new ContinuousTailDetails(String(tailChunk));
  1121. var lastChunk = this.chunks[this.chunks.length - 1];
  1122. var extendLast = lastChunk && (
  1123. lastChunk.stop === tailChunk.stop || tailChunk.stop == null) &&
  1124. tailChunk.from === lastChunk.from + lastChunk.toString().length;
  1125. if (tailChunk instanceof ContinuousTailDetails) {
  1126. if (extendLast) {
  1127. lastChunk.extend(tailChunk.toString());
  1128. } else {
  1129. this.chunks.push(tailChunk);
  1130. }
  1131. } else if (tailChunk instanceof ChunksTailDetails) {
  1132. if (tailChunk.stop == null) {
  1133. var firstTailChunk;
  1134. while (tailChunk.chunks.length && tailChunk.chunks[0].stop == null) {
  1135. firstTailChunk = tailChunk.chunks.shift();
  1136. firstTailChunk.from += tailChunk.from;
  1137. this.extend(firstTailChunk);
  1138. }
  1139. }
  1140. if (tailChunk.toString()) {
  1141. tailChunk.stop = tailChunk.blockIndex;
  1142. this.chunks.push(tailChunk);
  1143. }
  1144. }
  1145. }
  1146. }, {
  1147. key: "appendTo",
  1148. value: function appendTo(masked) {
  1149. if (!(masked instanceof IMask.MaskedPattern)) {
  1150. var tail = new ContinuousTailDetails(this.toString());
  1151. return tail.appendTo(masked);
  1152. }
  1153. var details = new ChangeDetails();
  1154. for (var ci = 0; ci < this.chunks.length && !details.skip; ++ci) {
  1155. var chunk = this.chunks[ci];
  1156. var lastBlockIter = masked._mapPosToBlock(masked.value.length);
  1157. var stop = chunk.stop;
  1158. var chunkBlock = void 0;
  1159. if (stop != null && (
  1160. !lastBlockIter || lastBlockIter.index <= stop)) {
  1161. if (chunk instanceof ChunksTailDetails ||
  1162. masked._stops.indexOf(stop) >= 0) {
  1163. details.aggregate(masked._appendPlaceholder(stop));
  1164. }
  1165. chunkBlock = chunk instanceof ChunksTailDetails && masked._blocks[stop];
  1166. }
  1167. if (chunkBlock) {
  1168. var tailDetails = chunkBlock.appendTail(chunk);
  1169. tailDetails.skip = false;
  1170. details.aggregate(tailDetails);
  1171. masked._value += tailDetails.inserted;
  1172. var remainChars = chunk.toString().slice(tailDetails.rawInserted.length);
  1173. if (remainChars) details.aggregate(masked.append(remainChars, {
  1174. tail: true
  1175. }));
  1176. } else {
  1177. details.aggregate(masked.append(chunk.toString(), {
  1178. tail: true
  1179. }));
  1180. }
  1181. }
  1182. return details;
  1183. }
  1184. }, {
  1185. key: "state",
  1186. get: function get() {
  1187. return {
  1188. chunks: this.chunks.map(function (c) {
  1189. return c.state;
  1190. }),
  1191. from: this.from,
  1192. stop: this.stop,
  1193. blockIndex: this.blockIndex
  1194. };
  1195. },
  1196. set: function set(state) {
  1197. var chunks = state.chunks,
  1198. props = _objectWithoutProperties(state, _excluded$3);
  1199. Object.assign(this, props);
  1200. this.chunks = chunks.map(function (cstate) {
  1201. var chunk = "chunks" in cstate ? new ChunksTailDetails() : new ContinuousTailDetails();
  1202. chunk.state = cstate;
  1203. return chunk;
  1204. });
  1205. }
  1206. }, {
  1207. key: "unshift",
  1208. value: function unshift(beforePos) {
  1209. if (!this.chunks.length || beforePos != null && this.from >= beforePos) return '';
  1210. var chunkShiftPos = beforePos != null ? beforePos - this.from : beforePos;
  1211. var ci = 0;
  1212. while (ci < this.chunks.length) {
  1213. var chunk = this.chunks[ci];
  1214. var shiftChar = chunk.unshift(chunkShiftPos);
  1215. if (chunk.toString()) {
  1216. if (!shiftChar) break;
  1217. ++ci;
  1218. } else {
  1219. this.chunks.splice(ci, 1);
  1220. }
  1221. if (shiftChar) return shiftChar;
  1222. }
  1223. return '';
  1224. }
  1225. }, {
  1226. key: "shift",
  1227. value: function shift() {
  1228. if (!this.chunks.length) return '';
  1229. var ci = this.chunks.length - 1;
  1230. while (0 <= ci) {
  1231. var chunk = this.chunks[ci];
  1232. var shiftChar = chunk.shift();
  1233. if (chunk.toString()) {
  1234. if (!shiftChar) break;
  1235. --ci;
  1236. } else {
  1237. this.chunks.splice(ci, 1);
  1238. }
  1239. if (shiftChar) return shiftChar;
  1240. }
  1241. return '';
  1242. }
  1243. }]);
  1244. return ChunksTailDetails;
  1245. }();
  1246. var PatternCursor = function () {
  1247. function PatternCursor(masked, pos) {
  1248. _classCallCheck(this, PatternCursor);
  1249. this.masked = masked;
  1250. this._log = [];
  1251. var _ref = masked._mapPosToBlock(pos) || (pos < 0 ?
  1252. {
  1253. index: 0,
  1254. offset: 0
  1255. } :
  1256. {
  1257. index: this.masked._blocks.length,
  1258. offset: 0
  1259. }),
  1260. offset = _ref.offset,
  1261. index = _ref.index;
  1262. this.offset = offset;
  1263. this.index = index;
  1264. this.ok = false;
  1265. }
  1266. _createClass(PatternCursor, [{
  1267. key: "block",
  1268. get: function get() {
  1269. return this.masked._blocks[this.index];
  1270. }
  1271. }, {
  1272. key: "pos",
  1273. get: function get() {
  1274. return this.masked._blockStartPos(this.index) + this.offset;
  1275. }
  1276. }, {
  1277. key: "state",
  1278. get: function get() {
  1279. return {
  1280. index: this.index,
  1281. offset: this.offset,
  1282. ok: this.ok
  1283. };
  1284. },
  1285. set: function set(s) {
  1286. Object.assign(this, s);
  1287. }
  1288. }, {
  1289. key: "pushState",
  1290. value: function pushState() {
  1291. this._log.push(this.state);
  1292. }
  1293. }, {
  1294. key: "popState",
  1295. value: function popState() {
  1296. var s = this._log.pop();
  1297. this.state = s;
  1298. return s;
  1299. }
  1300. }, {
  1301. key: "bindBlock",
  1302. value: function bindBlock() {
  1303. if (this.block) return;
  1304. if (this.index < 0) {
  1305. this.index = 0;
  1306. this.offset = 0;
  1307. }
  1308. if (this.index >= this.masked._blocks.length) {
  1309. this.index = this.masked._blocks.length - 1;
  1310. this.offset = this.block.value.length;
  1311. }
  1312. }
  1313. }, {
  1314. key: "_pushLeft",
  1315. value: function _pushLeft(fn) {
  1316. this.pushState();
  1317. for (this.bindBlock(); 0 <= this.index; --this.index, this.offset = ((_this$block = this.block) === null || _this$block === void 0 ? void 0 : _this$block.value.length) || 0) {
  1318. var _this$block;
  1319. if (fn()) return this.ok = true;
  1320. }
  1321. return this.ok = false;
  1322. }
  1323. }, {
  1324. key: "_pushRight",
  1325. value: function _pushRight(fn) {
  1326. this.pushState();
  1327. for (this.bindBlock(); this.index < this.masked._blocks.length; ++this.index, this.offset = 0) {
  1328. if (fn()) return this.ok = true;
  1329. }
  1330. return this.ok = false;
  1331. }
  1332. }, {
  1333. key: "pushLeftBeforeFilled",
  1334. value: function pushLeftBeforeFilled() {
  1335. var _this = this;
  1336. return this._pushLeft(function () {
  1337. if (_this.block.isFixed || !_this.block.value) return;
  1338. _this.offset = _this.block.nearestInputPos(_this.offset, DIRECTION.FORCE_LEFT);
  1339. if (_this.offset !== 0) return true;
  1340. });
  1341. }
  1342. }, {
  1343. key: "pushLeftBeforeInput",
  1344. value: function pushLeftBeforeInput() {
  1345. var _this2 = this;
  1346. return this._pushLeft(function () {
  1347. if (_this2.block.isFixed) return;
  1348. _this2.offset = _this2.block.nearestInputPos(_this2.offset, DIRECTION.LEFT);
  1349. return true;
  1350. });
  1351. }
  1352. }, {
  1353. key: "pushLeftBeforeRequired",
  1354. value: function pushLeftBeforeRequired() {
  1355. var _this3 = this;
  1356. return this._pushLeft(function () {
  1357. if (_this3.block.isFixed || _this3.block.isOptional && !_this3.block.value) return;
  1358. _this3.offset = _this3.block.nearestInputPos(_this3.offset, DIRECTION.LEFT);
  1359. return true;
  1360. });
  1361. }
  1362. }, {
  1363. key: "pushRightBeforeFilled",
  1364. value: function pushRightBeforeFilled() {
  1365. var _this4 = this;
  1366. return this._pushRight(function () {
  1367. if (_this4.block.isFixed || !_this4.block.value) return;
  1368. _this4.offset = _this4.block.nearestInputPos(_this4.offset, DIRECTION.FORCE_RIGHT);
  1369. if (_this4.offset !== _this4.block.value.length) return true;
  1370. });
  1371. }
  1372. }, {
  1373. key: "pushRightBeforeInput",
  1374. value: function pushRightBeforeInput() {
  1375. var _this5 = this;
  1376. return this._pushRight(function () {
  1377. if (_this5.block.isFixed) return;
  1378. _this5.offset = _this5.block.nearestInputPos(_this5.offset, DIRECTION.NONE);
  1379. return true;
  1380. });
  1381. }
  1382. }, {
  1383. key: "pushRightBeforeRequired",
  1384. value: function pushRightBeforeRequired() {
  1385. var _this6 = this;
  1386. return this._pushRight(function () {
  1387. if (_this6.block.isFixed || _this6.block.isOptional && !_this6.block.value) return;
  1388. _this6.offset = _this6.block.nearestInputPos(_this6.offset, DIRECTION.NONE);
  1389. return true;
  1390. });
  1391. }
  1392. }]);
  1393. return PatternCursor;
  1394. }();
  1395. var MaskedRegExp = function (_Masked) {
  1396. _inherits(MaskedRegExp, _Masked);
  1397. var _super = _createSuper(MaskedRegExp);
  1398. function MaskedRegExp() {
  1399. _classCallCheck(this, MaskedRegExp);
  1400. return _super.apply(this, arguments);
  1401. }
  1402. _createClass(MaskedRegExp, [{
  1403. key: "_update",
  1404. value:
  1405. function _update(opts) {
  1406. if (opts.mask) opts.validate = function (value) {
  1407. return value.search(opts.mask) >= 0;
  1408. };
  1409. _get(_getPrototypeOf(MaskedRegExp.prototype), "_update", this).call(this, opts);
  1410. }
  1411. }]);
  1412. return MaskedRegExp;
  1413. }(Masked);
  1414. IMask.MaskedRegExp = MaskedRegExp;
  1415. var _excluded$2 = ["_blocks"];
  1416. var MaskedPattern = function (_Masked) {
  1417. _inherits(MaskedPattern, _Masked);
  1418. var _super = _createSuper(MaskedPattern);
  1419. function MaskedPattern() {
  1420. var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  1421. _classCallCheck(this, MaskedPattern);
  1422. opts.definitions = Object.assign({}, DEFAULT_INPUT_DEFINITIONS, opts.definitions);
  1423. return _super.call(this, Object.assign({}, MaskedPattern.DEFAULTS, opts));
  1424. }
  1425. _createClass(MaskedPattern, [{
  1426. key: "_update",
  1427. value: function _update() {
  1428. var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  1429. opts.definitions = Object.assign({}, this.definitions, opts.definitions);
  1430. _get(_getPrototypeOf(MaskedPattern.prototype), "_update", this).call(this, opts);
  1431. this._rebuildMask();
  1432. }
  1433. }, {
  1434. key: "_rebuildMask",
  1435. value: function _rebuildMask() {
  1436. var _this = this;
  1437. var defs = this.definitions;
  1438. this._blocks = [];
  1439. this._stops = [];
  1440. this._maskedBlocks = {};
  1441. var pattern = this.mask;
  1442. if (!pattern || !defs) return;
  1443. var unmaskingBlock = false;
  1444. var optionalBlock = false;
  1445. for (var i = 0; i < pattern.length; ++i) {
  1446. if (this.blocks) {
  1447. var _ret = function () {
  1448. var p = pattern.slice(i);
  1449. var bNames = Object.keys(_this.blocks).filter(function (bName) {
  1450. return p.indexOf(bName) === 0;
  1451. });
  1452. bNames.sort(function (a, b) {
  1453. return b.length - a.length;
  1454. });
  1455. var bName = bNames[0];
  1456. if (bName) {
  1457. var maskedBlock = createMask(Object.assign({
  1458. parent: _this,
  1459. lazy: _this.lazy,
  1460. eager: _this.eager,
  1461. placeholderChar: _this.placeholderChar,
  1462. overwrite: _this.overwrite
  1463. }, _this.blocks[bName]));
  1464. if (maskedBlock) {
  1465. _this._blocks.push(maskedBlock);
  1466. if (!_this._maskedBlocks[bName]) _this._maskedBlocks[bName] = [];
  1467. _this._maskedBlocks[bName].push(_this._blocks.length - 1);
  1468. }
  1469. i += bName.length - 1;
  1470. return "continue";
  1471. }
  1472. }();
  1473. if (_ret === "continue") continue;
  1474. }
  1475. var char = pattern[i];
  1476. var isInput = (char in defs);
  1477. if (char === MaskedPattern.STOP_CHAR) {
  1478. this._stops.push(this._blocks.length);
  1479. continue;
  1480. }
  1481. if (char === '{' || char === '}') {
  1482. unmaskingBlock = !unmaskingBlock;
  1483. continue;
  1484. }
  1485. if (char === '[' || char === ']') {
  1486. optionalBlock = !optionalBlock;
  1487. continue;
  1488. }
  1489. if (char === MaskedPattern.ESCAPE_CHAR) {
  1490. ++i;
  1491. char = pattern[i];
  1492. if (!char) break;
  1493. isInput = false;
  1494. }
  1495. var def = isInput ? new PatternInputDefinition({
  1496. parent: this,
  1497. lazy: this.lazy,
  1498. eager: this.eager,
  1499. placeholderChar: this.placeholderChar,
  1500. mask: defs[char],
  1501. isOptional: optionalBlock
  1502. }) : new PatternFixedDefinition({
  1503. char: char,
  1504. eager: this.eager,
  1505. isUnmasking: unmaskingBlock
  1506. });
  1507. this._blocks.push(def);
  1508. }
  1509. }
  1510. }, {
  1511. key: "state",
  1512. get: function get() {
  1513. return Object.assign({}, _get(_getPrototypeOf(MaskedPattern.prototype), "state", this), {
  1514. _blocks: this._blocks.map(function (b) {
  1515. return b.state;
  1516. })
  1517. });
  1518. },
  1519. set: function set(state) {
  1520. var _blocks = state._blocks,
  1521. maskedState = _objectWithoutProperties(state, _excluded$2);
  1522. this._blocks.forEach(function (b, bi) {
  1523. return b.state = _blocks[bi];
  1524. });
  1525. _set(_getPrototypeOf(MaskedPattern.prototype), "state", maskedState, this, true);
  1526. }
  1527. }, {
  1528. key: "reset",
  1529. value: function reset() {
  1530. _get(_getPrototypeOf(MaskedPattern.prototype), "reset", this).call(this);
  1531. this._blocks.forEach(function (b) {
  1532. return b.reset();
  1533. });
  1534. }
  1535. }, {
  1536. key: "isComplete",
  1537. get: function get() {
  1538. return this._blocks.every(function (b) {
  1539. return b.isComplete;
  1540. });
  1541. }
  1542. }, {
  1543. key: "isFilled",
  1544. get: function get() {
  1545. return this._blocks.every(function (b) {
  1546. return b.isFilled;
  1547. });
  1548. }
  1549. }, {
  1550. key: "isFixed",
  1551. get: function get() {
  1552. return this._blocks.every(function (b) {
  1553. return b.isFixed;
  1554. });
  1555. }
  1556. }, {
  1557. key: "isOptional",
  1558. get: function get() {
  1559. return this._blocks.every(function (b) {
  1560. return b.isOptional;
  1561. });
  1562. }
  1563. }, {
  1564. key: "doCommit",
  1565. value: function doCommit() {
  1566. this._blocks.forEach(function (b) {
  1567. return b.doCommit();
  1568. });
  1569. _get(_getPrototypeOf(MaskedPattern.prototype), "doCommit", this).call(this);
  1570. }
  1571. }, {
  1572. key: "unmaskedValue",
  1573. get: function get() {
  1574. return this._blocks.reduce(function (str, b) {
  1575. return str += b.unmaskedValue;
  1576. }, '');
  1577. },
  1578. set: function set(unmaskedValue) {
  1579. _set(_getPrototypeOf(MaskedPattern.prototype), "unmaskedValue", unmaskedValue, this, true);
  1580. }
  1581. }, {
  1582. key: "value",
  1583. get: function get() {
  1584. return this._blocks.reduce(function (str, b) {
  1585. return str += b.value;
  1586. }, '');
  1587. },
  1588. set: function set(value) {
  1589. _set(_getPrototypeOf(MaskedPattern.prototype), "value", value, this, true);
  1590. }
  1591. }, {
  1592. key: "appendTail",
  1593. value: function appendTail(tail) {
  1594. return _get(_getPrototypeOf(MaskedPattern.prototype), "appendTail", this).call(this, tail).aggregate(this._appendPlaceholder());
  1595. }
  1596. }, {
  1597. key: "_appendEager",
  1598. value: function _appendEager() {
  1599. var _this$_mapPosToBlock;
  1600. var details = new ChangeDetails();
  1601. var startBlockIndex = (_this$_mapPosToBlock = this._mapPosToBlock(this.value.length)) === null || _this$_mapPosToBlock === void 0 ? void 0 : _this$_mapPosToBlock.index;
  1602. if (startBlockIndex == null) return details;
  1603. if (this._blocks[startBlockIndex].isFilled) ++startBlockIndex;
  1604. for (var bi = startBlockIndex; bi < this._blocks.length; ++bi) {
  1605. var d = this._blocks[bi]._appendEager();
  1606. if (!d.inserted) break;
  1607. details.aggregate(d);
  1608. }
  1609. return details;
  1610. }
  1611. }, {
  1612. key: "_appendCharRaw",
  1613. value: function _appendCharRaw(ch) {
  1614. var flags = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  1615. var blockIter = this._mapPosToBlock(this.value.length);
  1616. var details = new ChangeDetails();
  1617. if (!blockIter) return details;
  1618. for (var bi = blockIter.index;; ++bi) {
  1619. var _flags$_beforeTailSta, _flags$_beforeTailSta2;
  1620. var _block = this._blocks[bi];
  1621. if (!_block) break;
  1622. var blockDetails = _block._appendChar(ch, Object.assign({}, flags, {
  1623. _beforeTailState: (_flags$_beforeTailSta = flags._beforeTailState) === null || _flags$_beforeTailSta === void 0 ? void 0 : (_flags$_beforeTailSta2 = _flags$_beforeTailSta._blocks) === null || _flags$_beforeTailSta2 === void 0 ? void 0 : _flags$_beforeTailSta2[bi]
  1624. }));
  1625. var skip = blockDetails.skip;
  1626. details.aggregate(blockDetails);
  1627. if (skip || blockDetails.rawInserted) break;
  1628. }
  1629. return details;
  1630. }
  1631. }, {
  1632. key: "extractTail",
  1633. value: function extractTail() {
  1634. var _this2 = this;
  1635. var fromPos = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  1636. var toPos = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.value.length;
  1637. var chunkTail = new ChunksTailDetails();
  1638. if (fromPos === toPos) return chunkTail;
  1639. this._forEachBlocksInRange(fromPos, toPos, function (b, bi, bFromPos, bToPos) {
  1640. var blockChunk = b.extractTail(bFromPos, bToPos);
  1641. blockChunk.stop = _this2._findStopBefore(bi);
  1642. blockChunk.from = _this2._blockStartPos(bi);
  1643. if (blockChunk instanceof ChunksTailDetails) blockChunk.blockIndex = bi;
  1644. chunkTail.extend(blockChunk);
  1645. });
  1646. return chunkTail;
  1647. }
  1648. }, {
  1649. key: "extractInput",
  1650. value: function extractInput() {
  1651. var fromPos = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  1652. var toPos = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.value.length;
  1653. var flags = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  1654. if (fromPos === toPos) return '';
  1655. var input = '';
  1656. this._forEachBlocksInRange(fromPos, toPos, function (b, _, fromPos, toPos) {
  1657. input += b.extractInput(fromPos, toPos, flags);
  1658. });
  1659. return input;
  1660. }
  1661. }, {
  1662. key: "_findStopBefore",
  1663. value: function _findStopBefore(blockIndex) {
  1664. var stopBefore;
  1665. for (var si = 0; si < this._stops.length; ++si) {
  1666. var stop = this._stops[si];
  1667. if (stop <= blockIndex) stopBefore = stop;else break;
  1668. }
  1669. return stopBefore;
  1670. }
  1671. }, {
  1672. key: "_appendPlaceholder",
  1673. value: function _appendPlaceholder(toBlockIndex) {
  1674. var _this3 = this;
  1675. var details = new ChangeDetails();
  1676. if (this.lazy && toBlockIndex == null) return details;
  1677. var startBlockIter = this._mapPosToBlock(this.value.length);
  1678. if (!startBlockIter) return details;
  1679. var startBlockIndex = startBlockIter.index;
  1680. var endBlockIndex = toBlockIndex != null ? toBlockIndex : this._blocks.length;
  1681. this._blocks.slice(startBlockIndex, endBlockIndex).forEach(function (b) {
  1682. if (!b.lazy || toBlockIndex != null) {
  1683. var args = b._blocks != null ? [b._blocks.length] : [];
  1684. var bDetails = b._appendPlaceholder.apply(b, args);
  1685. _this3._value += bDetails.inserted;
  1686. details.aggregate(bDetails);
  1687. }
  1688. });
  1689. return details;
  1690. }
  1691. }, {
  1692. key: "_mapPosToBlock",
  1693. value: function _mapPosToBlock(pos) {
  1694. var accVal = '';
  1695. for (var bi = 0; bi < this._blocks.length; ++bi) {
  1696. var _block2 = this._blocks[bi];
  1697. var blockStartPos = accVal.length;
  1698. accVal += _block2.value;
  1699. if (pos <= accVal.length) {
  1700. return {
  1701. index: bi,
  1702. offset: pos - blockStartPos
  1703. };
  1704. }
  1705. }
  1706. }
  1707. }, {
  1708. key: "_blockStartPos",
  1709. value: function _blockStartPos(blockIndex) {
  1710. return this._blocks.slice(0, blockIndex).reduce(function (pos, b) {
  1711. return pos += b.value.length;
  1712. }, 0);
  1713. }
  1714. }, {
  1715. key: "_forEachBlocksInRange",
  1716. value: function _forEachBlocksInRange(fromPos) {
  1717. var toPos = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.value.length;
  1718. var fn = arguments.length > 2 ? arguments[2] : undefined;
  1719. var fromBlockIter = this._mapPosToBlock(fromPos);
  1720. if (fromBlockIter) {
  1721. var toBlockIter = this._mapPosToBlock(toPos);
  1722. var isSameBlock = toBlockIter && fromBlockIter.index === toBlockIter.index;
  1723. var fromBlockStartPos = fromBlockIter.offset;
  1724. var fromBlockEndPos = toBlockIter && isSameBlock ? toBlockIter.offset : this._blocks[fromBlockIter.index].value.length;
  1725. fn(this._blocks[fromBlockIter.index], fromBlockIter.index, fromBlockStartPos, fromBlockEndPos);
  1726. if (toBlockIter && !isSameBlock) {
  1727. for (var bi = fromBlockIter.index + 1; bi < toBlockIter.index; ++bi) {
  1728. fn(this._blocks[bi], bi, 0, this._blocks[bi].value.length);
  1729. }
  1730. fn(this._blocks[toBlockIter.index], toBlockIter.index, 0, toBlockIter.offset);
  1731. }
  1732. }
  1733. }
  1734. }, {
  1735. key: "remove",
  1736. value: function remove() {
  1737. var fromPos = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  1738. var toPos = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.value.length;
  1739. var removeDetails = _get(_getPrototypeOf(MaskedPattern.prototype), "remove", this).call(this, fromPos, toPos);
  1740. this._forEachBlocksInRange(fromPos, toPos, function (b, _, bFromPos, bToPos) {
  1741. removeDetails.aggregate(b.remove(bFromPos, bToPos));
  1742. });
  1743. return removeDetails;
  1744. }
  1745. }, {
  1746. key: "nearestInputPos",
  1747. value: function nearestInputPos(cursorPos) {
  1748. var direction = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DIRECTION.NONE;
  1749. if (!this._blocks.length) return 0;
  1750. var cursor = new PatternCursor(this, cursorPos);
  1751. if (direction === DIRECTION.NONE) {
  1752. if (cursor.pushRightBeforeInput()) return cursor.pos;
  1753. cursor.popState();
  1754. if (cursor.pushLeftBeforeInput()) return cursor.pos;
  1755. return this.value.length;
  1756. }
  1757. if (direction === DIRECTION.LEFT || direction === DIRECTION.FORCE_LEFT) {
  1758. if (direction === DIRECTION.LEFT) {
  1759. cursor.pushRightBeforeFilled();
  1760. if (cursor.ok && cursor.pos === cursorPos) return cursorPos;
  1761. cursor.popState();
  1762. }
  1763. cursor.pushLeftBeforeInput();
  1764. cursor.pushLeftBeforeRequired();
  1765. cursor.pushLeftBeforeFilled();
  1766. if (direction === DIRECTION.LEFT) {
  1767. cursor.pushRightBeforeInput();
  1768. cursor.pushRightBeforeRequired();
  1769. if (cursor.ok && cursor.pos <= cursorPos) return cursor.pos;
  1770. cursor.popState();
  1771. if (cursor.ok && cursor.pos <= cursorPos) return cursor.pos;
  1772. cursor.popState();
  1773. }
  1774. if (cursor.ok) return cursor.pos;
  1775. if (direction === DIRECTION.FORCE_LEFT) return 0;
  1776. cursor.popState();
  1777. if (cursor.ok) return cursor.pos;
  1778. cursor.popState();
  1779. if (cursor.ok) return cursor.pos;
  1780. return 0;
  1781. }
  1782. if (direction === DIRECTION.RIGHT || direction === DIRECTION.FORCE_RIGHT) {
  1783. cursor.pushRightBeforeInput();
  1784. cursor.pushRightBeforeRequired();
  1785. if (cursor.pushRightBeforeFilled()) return cursor.pos;
  1786. if (direction === DIRECTION.FORCE_RIGHT) return this.value.length;
  1787. cursor.popState();
  1788. if (cursor.ok) return cursor.pos;
  1789. cursor.popState();
  1790. if (cursor.ok) return cursor.pos;
  1791. return this.nearestInputPos(cursorPos, DIRECTION.LEFT);
  1792. }
  1793. return cursorPos;
  1794. }
  1795. }, {
  1796. key: "maskedBlock",
  1797. value: function maskedBlock(name) {
  1798. return this.maskedBlocks(name)[0];
  1799. }
  1800. }, {
  1801. key: "maskedBlocks",
  1802. value: function maskedBlocks(name) {
  1803. var _this4 = this;
  1804. var indices = this._maskedBlocks[name];
  1805. if (!indices) return [];
  1806. return indices.map(function (gi) {
  1807. return _this4._blocks[gi];
  1808. });
  1809. }
  1810. }]);
  1811. return MaskedPattern;
  1812. }(Masked);
  1813. MaskedPattern.DEFAULTS = {
  1814. lazy: true,
  1815. placeholderChar: '_'
  1816. };
  1817. MaskedPattern.STOP_CHAR = '`';
  1818. MaskedPattern.ESCAPE_CHAR = '\\';
  1819. MaskedPattern.InputDefinition = PatternInputDefinition;
  1820. MaskedPattern.FixedDefinition = PatternFixedDefinition;
  1821. IMask.MaskedPattern = MaskedPattern;
  1822. var MaskedRange = function (_MaskedPattern) {
  1823. _inherits(MaskedRange, _MaskedPattern);
  1824. var _super = _createSuper(MaskedRange);
  1825. function MaskedRange() {
  1826. _classCallCheck(this, MaskedRange);
  1827. return _super.apply(this, arguments);
  1828. }
  1829. _createClass(MaskedRange, [{
  1830. key: "_matchFrom",
  1831. get:
  1832. function get() {
  1833. return this.maxLength - String(this.from).length;
  1834. }
  1835. }, {
  1836. key: "_update",
  1837. value: function _update(opts) {
  1838. opts = Object.assign({
  1839. to: this.to || 0,
  1840. from: this.from || 0,
  1841. maxLength: this.maxLength || 0
  1842. }, opts);
  1843. var maxLength = String(opts.to).length;
  1844. if (opts.maxLength != null) maxLength = Math.max(maxLength, opts.maxLength);
  1845. opts.maxLength = maxLength;
  1846. var fromStr = String(opts.from).padStart(maxLength, '0');
  1847. var toStr = String(opts.to).padStart(maxLength, '0');
  1848. var sameCharsCount = 0;
  1849. while (sameCharsCount < toStr.length && toStr[sameCharsCount] === fromStr[sameCharsCount]) {
  1850. ++sameCharsCount;
  1851. }
  1852. opts.mask = toStr.slice(0, sameCharsCount).replace(/0/g, '\\0') + '0'.repeat(maxLength - sameCharsCount);
  1853. _get(_getPrototypeOf(MaskedRange.prototype), "_update", this).call(this, opts);
  1854. }
  1855. }, {
  1856. key: "isComplete",
  1857. get: function get() {
  1858. return _get(_getPrototypeOf(MaskedRange.prototype), "isComplete", this) && Boolean(this.value);
  1859. }
  1860. }, {
  1861. key: "boundaries",
  1862. value: function boundaries(str) {
  1863. var minstr = '';
  1864. var maxstr = '';
  1865. var _ref = str.match(/^(\D*)(\d*)(\D*)/) || [],
  1866. _ref2 = _slicedToArray(_ref, 3),
  1867. placeholder = _ref2[1],
  1868. num = _ref2[2];
  1869. if (num) {
  1870. minstr = '0'.repeat(placeholder.length) + num;
  1871. maxstr = '9'.repeat(placeholder.length) + num;
  1872. }
  1873. minstr = minstr.padEnd(this.maxLength, '0');
  1874. maxstr = maxstr.padEnd(this.maxLength, '9');
  1875. return [minstr, maxstr];
  1876. }
  1877. }, {
  1878. key: "doPrepare",
  1879. value: function doPrepare(ch) {
  1880. var flags = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  1881. var details;
  1882. var _normalizePrepare = normalizePrepare(_get(_getPrototypeOf(MaskedRange.prototype), "doPrepare", this).call(this, ch.replace(/\D/g, ''), flags));
  1883. var _normalizePrepare2 = _slicedToArray(_normalizePrepare, 2);
  1884. ch = _normalizePrepare2[0];
  1885. details = _normalizePrepare2[1];
  1886. if (!this.autofix || !ch) return ch;
  1887. var fromStr = String(this.from).padStart(this.maxLength, '0');
  1888. var toStr = String(this.to).padStart(this.maxLength, '0');
  1889. var nextVal = this.value + ch;
  1890. if (nextVal.length > this.maxLength) return '';
  1891. var _this$boundaries = this.boundaries(nextVal),
  1892. _this$boundaries2 = _slicedToArray(_this$boundaries, 2),
  1893. minstr = _this$boundaries2[0],
  1894. maxstr = _this$boundaries2[1];
  1895. if (Number(maxstr) < this.from) return fromStr[nextVal.length - 1];
  1896. if (Number(minstr) > this.to) {
  1897. if (this.autofix === 'pad' && nextVal.length < this.maxLength) {
  1898. return ['', details.aggregate(this.append(fromStr[nextVal.length - 1] + ch, flags))];
  1899. }
  1900. return toStr[nextVal.length - 1];
  1901. }
  1902. return ch;
  1903. }
  1904. }, {
  1905. key: "doValidate",
  1906. value: function doValidate() {
  1907. var _get2;
  1908. var str = this.value;
  1909. var firstNonZero = str.search(/[^0]/);
  1910. if (firstNonZero === -1 && str.length <= this._matchFrom) return true;
  1911. var _this$boundaries3 = this.boundaries(str),
  1912. _this$boundaries4 = _slicedToArray(_this$boundaries3, 2),
  1913. minstr = _this$boundaries4[0],
  1914. maxstr = _this$boundaries4[1];
  1915. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  1916. args[_key] = arguments[_key];
  1917. }
  1918. return this.from <= Number(maxstr) && Number(minstr) <= this.to && (_get2 = _get(_getPrototypeOf(MaskedRange.prototype), "doValidate", this)).call.apply(_get2, [this].concat(args));
  1919. }
  1920. }]);
  1921. return MaskedRange;
  1922. }(MaskedPattern);
  1923. IMask.MaskedRange = MaskedRange;
  1924. var MaskedDate = function (_MaskedPattern) {
  1925. _inherits(MaskedDate, _MaskedPattern);
  1926. var _super = _createSuper(MaskedDate);
  1927. function MaskedDate(opts) {
  1928. _classCallCheck(this, MaskedDate);
  1929. return _super.call(this, Object.assign({}, MaskedDate.DEFAULTS, opts));
  1930. }
  1931. _createClass(MaskedDate, [{
  1932. key: "_update",
  1933. value: function _update(opts) {
  1934. if (opts.mask === Date) delete opts.mask;
  1935. if (opts.pattern) opts.mask = opts.pattern;
  1936. var blocks = opts.blocks;
  1937. opts.blocks = Object.assign({}, MaskedDate.GET_DEFAULT_BLOCKS());
  1938. if (opts.min) opts.blocks.Y.from = opts.min.getFullYear();
  1939. if (opts.max) opts.blocks.Y.to = opts.max.getFullYear();
  1940. if (opts.min && opts.max && opts.blocks.Y.from === opts.blocks.Y.to) {
  1941. opts.blocks.m.from = opts.min.getMonth() + 1;
  1942. opts.blocks.m.to = opts.max.getMonth() + 1;
  1943. if (opts.blocks.m.from === opts.blocks.m.to) {
  1944. opts.blocks.d.from = opts.min.getDate();
  1945. opts.blocks.d.to = opts.max.getDate();
  1946. }
  1947. }
  1948. Object.assign(opts.blocks, this.blocks, blocks);
  1949. Object.keys(opts.blocks).forEach(function (bk) {
  1950. var b = opts.blocks[bk];
  1951. if (!('autofix' in b) && 'autofix' in opts) b.autofix = opts.autofix;
  1952. });
  1953. _get(_getPrototypeOf(MaskedDate.prototype), "_update", this).call(this, opts);
  1954. }
  1955. }, {
  1956. key: "doValidate",
  1957. value: function doValidate() {
  1958. var _get2;
  1959. var date = this.date;
  1960. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  1961. args[_key] = arguments[_key];
  1962. }
  1963. return (_get2 = _get(_getPrototypeOf(MaskedDate.prototype), "doValidate", this)).call.apply(_get2, [this].concat(args)) && (!this.isComplete || this.isDateExist(this.value) && date != null && (this.min == null || this.min <= date) && (this.max == null || date <= this.max));
  1964. }
  1965. }, {
  1966. key: "isDateExist",
  1967. value: function isDateExist(str) {
  1968. return this.format(this.parse(str, this), this).indexOf(str) >= 0;
  1969. }
  1970. }, {
  1971. key: "date",
  1972. get: function get() {
  1973. return this.typedValue;
  1974. },
  1975. set: function set(date) {
  1976. this.typedValue = date;
  1977. }
  1978. }, {
  1979. key: "typedValue",
  1980. get: function get() {
  1981. return this.isComplete ? _get(_getPrototypeOf(MaskedDate.prototype), "typedValue", this) : null;
  1982. },
  1983. set: function set(value) {
  1984. _set(_getPrototypeOf(MaskedDate.prototype), "typedValue", value, this, true);
  1985. }
  1986. }, {
  1987. key: "maskEquals",
  1988. value: function maskEquals(mask) {
  1989. return mask === Date || _get(_getPrototypeOf(MaskedDate.prototype), "maskEquals", this).call(this, mask);
  1990. }
  1991. }]);
  1992. return MaskedDate;
  1993. }(MaskedPattern);
  1994. MaskedDate.DEFAULTS = {
  1995. pattern: 'd{.}`m{.}`Y',
  1996. format: function format(date) {
  1997. if (!date) return '';
  1998. var day = String(date.getDate()).padStart(2, '0');
  1999. var month = String(date.getMonth() + 1).padStart(2, '0');
  2000. var year = date.getFullYear();
  2001. return [day, month, year].join('.');
  2002. },
  2003. parse: function parse(str) {
  2004. var _str$split = str.split('.'),
  2005. _str$split2 = _slicedToArray(_str$split, 3),
  2006. day = _str$split2[0],
  2007. month = _str$split2[1],
  2008. year = _str$split2[2];
  2009. return new Date(year, month - 1, day);
  2010. }
  2011. };
  2012. MaskedDate.GET_DEFAULT_BLOCKS = function () {
  2013. return {
  2014. d: {
  2015. mask: MaskedRange,
  2016. from: 1,
  2017. to: 31,
  2018. maxLength: 2
  2019. },
  2020. m: {
  2021. mask: MaskedRange,
  2022. from: 1,
  2023. to: 12,
  2024. maxLength: 2
  2025. },
  2026. Y: {
  2027. mask: MaskedRange,
  2028. from: 1900,
  2029. to: 9999
  2030. }
  2031. };
  2032. };
  2033. IMask.MaskedDate = MaskedDate;
  2034. var MaskElement = function () {
  2035. function MaskElement() {
  2036. _classCallCheck(this, MaskElement);
  2037. }
  2038. _createClass(MaskElement, [{
  2039. key: "selectionStart",
  2040. get:
  2041. function get() {
  2042. var start;
  2043. try {
  2044. start = this._unsafeSelectionStart;
  2045. } catch (e) {}
  2046. return start != null ? start : this.value.length;
  2047. }
  2048. }, {
  2049. key: "selectionEnd",
  2050. get: function get() {
  2051. var end;
  2052. try {
  2053. end = this._unsafeSelectionEnd;
  2054. } catch (e) {}
  2055. return end != null ? end : this.value.length;
  2056. }
  2057. }, {
  2058. key: "select",
  2059. value: function select(start, end) {
  2060. if (start == null || end == null || start === this.selectionStart && end === this.selectionEnd) return;
  2061. try {
  2062. this._unsafeSelect(start, end);
  2063. } catch (e) {}
  2064. }
  2065. }, {
  2066. key: "_unsafeSelect",
  2067. value: function _unsafeSelect(start, end) {}
  2068. }, {
  2069. key: "isActive",
  2070. get: function get() {
  2071. return false;
  2072. }
  2073. }, {
  2074. key: "bindEvents",
  2075. value: function bindEvents(handlers) {}
  2076. }, {
  2077. key: "unbindEvents",
  2078. value: function unbindEvents() {}
  2079. }]);
  2080. return MaskElement;
  2081. }();
  2082. IMask.MaskElement = MaskElement;
  2083. var HTMLMaskElement = function (_MaskElement) {
  2084. _inherits(HTMLMaskElement, _MaskElement);
  2085. var _super = _createSuper(HTMLMaskElement);
  2086. function HTMLMaskElement(input) {
  2087. var _this;
  2088. _classCallCheck(this, HTMLMaskElement);
  2089. _this = _super.call(this);
  2090. _this.input = input;
  2091. _this._handlers = {};
  2092. return _this;
  2093. }
  2094. _createClass(HTMLMaskElement, [{
  2095. key: "rootElement",
  2096. get: function get() {
  2097. var _this$input$getRootNo, _this$input$getRootNo2, _this$input;
  2098. return (_this$input$getRootNo = (_this$input$getRootNo2 = (_this$input = this.input).getRootNode) === null || _this$input$getRootNo2 === void 0 ? void 0 : _this$input$getRootNo2.call(_this$input)) !== null && _this$input$getRootNo !== void 0 ? _this$input$getRootNo : document;
  2099. }
  2100. }, {
  2101. key: "isActive",
  2102. get: function get() {
  2103. return this.input === this.rootElement.activeElement;
  2104. }
  2105. }, {
  2106. key: "_unsafeSelectionStart",
  2107. get: function get() {
  2108. return this.input.selectionStart;
  2109. }
  2110. }, {
  2111. key: "_unsafeSelectionEnd",
  2112. get: function get() {
  2113. return this.input.selectionEnd;
  2114. }
  2115. }, {
  2116. key: "_unsafeSelect",
  2117. value: function _unsafeSelect(start, end) {
  2118. this.input.setSelectionRange(start, end);
  2119. }
  2120. }, {
  2121. key: "value",
  2122. get: function get() {
  2123. return this.input.value;
  2124. },
  2125. set: function set(value) {
  2126. this.input.value = value;
  2127. }
  2128. }, {
  2129. key: "bindEvents",
  2130. value: function bindEvents(handlers) {
  2131. var _this2 = this;
  2132. Object.keys(handlers).forEach(function (event) {
  2133. return _this2._toggleEventHandler(HTMLMaskElement.EVENTS_MAP[event], handlers[event]);
  2134. });
  2135. }
  2136. }, {
  2137. key: "unbindEvents",
  2138. value: function unbindEvents() {
  2139. var _this3 = this;
  2140. Object.keys(this._handlers).forEach(function (event) {
  2141. return _this3._toggleEventHandler(event);
  2142. });
  2143. }
  2144. }, {
  2145. key: "_toggleEventHandler",
  2146. value: function _toggleEventHandler(event, handler) {
  2147. if (this._handlers[event]) {
  2148. this.input.removeEventListener(event, this._handlers[event]);
  2149. delete this._handlers[event];
  2150. }
  2151. if (handler) {
  2152. this.input.addEventListener(event, handler);
  2153. this._handlers[event] = handler;
  2154. }
  2155. }
  2156. }]);
  2157. return HTMLMaskElement;
  2158. }(MaskElement);
  2159. HTMLMaskElement.EVENTS_MAP = {
  2160. selectionChange: 'keydown',
  2161. input: 'input',
  2162. drop: 'drop',
  2163. click: 'click',
  2164. focus: 'focus',
  2165. commit: 'blur'
  2166. };
  2167. IMask.HTMLMaskElement = HTMLMaskElement;
  2168. var HTMLContenteditableMaskElement = function (_HTMLMaskElement) {
  2169. _inherits(HTMLContenteditableMaskElement, _HTMLMaskElement);
  2170. var _super = _createSuper(HTMLContenteditableMaskElement);
  2171. function HTMLContenteditableMaskElement() {
  2172. _classCallCheck(this, HTMLContenteditableMaskElement);
  2173. return _super.apply(this, arguments);
  2174. }
  2175. _createClass(HTMLContenteditableMaskElement, [{
  2176. key: "_unsafeSelectionStart",
  2177. get:
  2178. function get() {
  2179. var root = this.rootElement;
  2180. var selection = root.getSelection && root.getSelection();
  2181. var anchorOffset = selection && selection.anchorOffset;
  2182. var focusOffset = selection && selection.focusOffset;
  2183. if (focusOffset == null || anchorOffset == null || anchorOffset < focusOffset) {
  2184. return anchorOffset;
  2185. }
  2186. return focusOffset;
  2187. }
  2188. }, {
  2189. key: "_unsafeSelectionEnd",
  2190. get: function get() {
  2191. var root = this.rootElement;
  2192. var selection = root.getSelection && root.getSelection();
  2193. var anchorOffset = selection && selection.anchorOffset;
  2194. var focusOffset = selection && selection.focusOffset;
  2195. if (focusOffset == null || anchorOffset == null || anchorOffset > focusOffset) {
  2196. return anchorOffset;
  2197. }
  2198. return focusOffset;
  2199. }
  2200. }, {
  2201. key: "_unsafeSelect",
  2202. value: function _unsafeSelect(start, end) {
  2203. if (!this.rootElement.createRange) return;
  2204. var range = this.rootElement.createRange();
  2205. range.setStart(this.input.firstChild || this.input, start);
  2206. range.setEnd(this.input.lastChild || this.input, end);
  2207. var root = this.rootElement;
  2208. var selection = root.getSelection && root.getSelection();
  2209. if (selection) {
  2210. selection.removeAllRanges();
  2211. selection.addRange(range);
  2212. }
  2213. }
  2214. }, {
  2215. key: "value",
  2216. get: function get() {
  2217. return this.input.textContent;
  2218. },
  2219. set: function set(value) {
  2220. this.input.textContent = value;
  2221. }
  2222. }]);
  2223. return HTMLContenteditableMaskElement;
  2224. }(HTMLMaskElement);
  2225. IMask.HTMLContenteditableMaskElement = HTMLContenteditableMaskElement;
  2226. var _excluded$1 = ["mask"];
  2227. var InputMask = function () {
  2228. function InputMask(el, opts) {
  2229. _classCallCheck(this, InputMask);
  2230. this.el = el instanceof MaskElement ? el : el.isContentEditable && el.tagName !== 'INPUT' && el.tagName !== 'TEXTAREA' ? new HTMLContenteditableMaskElement(el) : new HTMLMaskElement(el);
  2231. this.masked = createMask(opts);
  2232. this._listeners = {};
  2233. this._value = '';
  2234. this._unmaskedValue = '';
  2235. this._saveSelection = this._saveSelection.bind(this);
  2236. this._onInput = this._onInput.bind(this);
  2237. this._onChange = this._onChange.bind(this);
  2238. this._onDrop = this._onDrop.bind(this);
  2239. this._onFocus = this._onFocus.bind(this);
  2240. this._onClick = this._onClick.bind(this);
  2241. this.alignCursor = this.alignCursor.bind(this);
  2242. this.alignCursorFriendly = this.alignCursorFriendly.bind(this);
  2243. this._bindEvents();
  2244. this.updateValue();
  2245. this._onChange();
  2246. }
  2247. _createClass(InputMask, [{
  2248. key: "mask",
  2249. get: function get() {
  2250. return this.masked.mask;
  2251. },
  2252. set: function set(mask) {
  2253. if (this.maskEquals(mask)) return;
  2254. if (!(mask instanceof IMask.Masked) && this.masked.constructor === maskedClass(mask)) {
  2255. this.masked.updateOptions({
  2256. mask: mask
  2257. });
  2258. return;
  2259. }
  2260. var masked = createMask({
  2261. mask: mask
  2262. });
  2263. masked.unmaskedValue = this.masked.unmaskedValue;
  2264. this.masked = masked;
  2265. }
  2266. }, {
  2267. key: "maskEquals",
  2268. value: function maskEquals(mask) {
  2269. var _this$masked;
  2270. return mask == null || ((_this$masked = this.masked) === null || _this$masked === void 0 ? void 0 : _this$masked.maskEquals(mask));
  2271. }
  2272. }, {
  2273. key: "value",
  2274. get: function get() {
  2275. return this._value;
  2276. },
  2277. set: function set(str) {
  2278. if (this.value === str) return;
  2279. this.masked.value = str;
  2280. this.updateControl();
  2281. this.alignCursor();
  2282. }
  2283. }, {
  2284. key: "unmaskedValue",
  2285. get: function get() {
  2286. return this._unmaskedValue;
  2287. },
  2288. set: function set(str) {
  2289. if (this.unmaskedValue === str) return;
  2290. this.masked.unmaskedValue = str;
  2291. this.updateControl();
  2292. this.alignCursor();
  2293. }
  2294. }, {
  2295. key: "typedValue",
  2296. get: function get() {
  2297. return this.masked.typedValue;
  2298. },
  2299. set: function set(val) {
  2300. if (this.masked.typedValueEquals(val)) return;
  2301. this.masked.typedValue = val;
  2302. this.updateControl();
  2303. this.alignCursor();
  2304. }
  2305. }, {
  2306. key: "_bindEvents",
  2307. value: function _bindEvents() {
  2308. this.el.bindEvents({
  2309. selectionChange: this._saveSelection,
  2310. input: this._onInput,
  2311. drop: this._onDrop,
  2312. click: this._onClick,
  2313. focus: this._onFocus,
  2314. commit: this._onChange
  2315. });
  2316. }
  2317. }, {
  2318. key: "_unbindEvents",
  2319. value: function _unbindEvents() {
  2320. if (this.el) this.el.unbindEvents();
  2321. }
  2322. }, {
  2323. key: "_fireEvent",
  2324. value: function _fireEvent(ev) {
  2325. for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  2326. args[_key - 1] = arguments[_key];
  2327. }
  2328. var listeners = this._listeners[ev];
  2329. if (!listeners) return;
  2330. listeners.forEach(function (l) {
  2331. return l.apply(void 0, args);
  2332. });
  2333. }
  2334. }, {
  2335. key: "selectionStart",
  2336. get: function get() {
  2337. return this._cursorChanging ? this._changingCursorPos : this.el.selectionStart;
  2338. }
  2339. }, {
  2340. key: "cursorPos",
  2341. get: function get() {
  2342. return this._cursorChanging ? this._changingCursorPos : this.el.selectionEnd;
  2343. },
  2344. set: function set(pos) {
  2345. if (!this.el || !this.el.isActive) return;
  2346. this.el.select(pos, pos);
  2347. this._saveSelection();
  2348. }
  2349. }, {
  2350. key: "_saveSelection",
  2351. value: function
  2352. _saveSelection() {
  2353. if (this.value !== this.el.value) {
  2354. console.warn('Element value was changed outside of mask. Syncronize mask using `mask.updateValue()` to work properly.');
  2355. }
  2356. this._selection = {
  2357. start: this.selectionStart,
  2358. end: this.cursorPos
  2359. };
  2360. }
  2361. }, {
  2362. key: "updateValue",
  2363. value: function updateValue() {
  2364. this.masked.value = this.el.value;
  2365. this._value = this.masked.value;
  2366. }
  2367. }, {
  2368. key: "updateControl",
  2369. value: function updateControl() {
  2370. var newUnmaskedValue = this.masked.unmaskedValue;
  2371. var newValue = this.masked.value;
  2372. var isChanged = this.unmaskedValue !== newUnmaskedValue || this.value !== newValue;
  2373. this._unmaskedValue = newUnmaskedValue;
  2374. this._value = newValue;
  2375. if (this.el.value !== newValue) this.el.value = newValue;
  2376. if (isChanged) this._fireChangeEvents();
  2377. }
  2378. }, {
  2379. key: "updateOptions",
  2380. value: function updateOptions(opts) {
  2381. var mask = opts.mask,
  2382. restOpts = _objectWithoutProperties(opts, _excluded$1);
  2383. var updateMask = !this.maskEquals(mask);
  2384. var updateOpts = !objectIncludes(this.masked, restOpts);
  2385. if (updateMask) this.mask = mask;
  2386. if (updateOpts) this.masked.updateOptions(restOpts);
  2387. if (updateMask || updateOpts) this.updateControl();
  2388. }
  2389. }, {
  2390. key: "updateCursor",
  2391. value: function updateCursor(cursorPos) {
  2392. if (cursorPos == null) return;
  2393. this.cursorPos = cursorPos;
  2394. this._delayUpdateCursor(cursorPos);
  2395. }
  2396. }, {
  2397. key: "_delayUpdateCursor",
  2398. value: function _delayUpdateCursor(cursorPos) {
  2399. var _this = this;
  2400. this._abortUpdateCursor();
  2401. this._changingCursorPos = cursorPos;
  2402. this._cursorChanging = setTimeout(function () {
  2403. if (!_this.el) return;
  2404. _this.cursorPos = _this._changingCursorPos;
  2405. _this._abortUpdateCursor();
  2406. }, 10);
  2407. }
  2408. }, {
  2409. key: "_fireChangeEvents",
  2410. value: function _fireChangeEvents() {
  2411. this._fireEvent('accept', this._inputEvent);
  2412. if (this.masked.isComplete) this._fireEvent('complete', this._inputEvent);
  2413. }
  2414. }, {
  2415. key: "_abortUpdateCursor",
  2416. value: function _abortUpdateCursor() {
  2417. if (this._cursorChanging) {
  2418. clearTimeout(this._cursorChanging);
  2419. delete this._cursorChanging;
  2420. }
  2421. }
  2422. }, {
  2423. key: "alignCursor",
  2424. value: function alignCursor() {
  2425. this.cursorPos = this.masked.nearestInputPos(this.masked.nearestInputPos(this.cursorPos, DIRECTION.LEFT));
  2426. }
  2427. }, {
  2428. key: "alignCursorFriendly",
  2429. value: function alignCursorFriendly() {
  2430. if (this.selectionStart !== this.cursorPos) return;
  2431. this.alignCursor();
  2432. }
  2433. }, {
  2434. key: "on",
  2435. value: function on(ev, handler) {
  2436. if (!this._listeners[ev]) this._listeners[ev] = [];
  2437. this._listeners[ev].push(handler);
  2438. return this;
  2439. }
  2440. }, {
  2441. key: "off",
  2442. value: function off(ev, handler) {
  2443. if (!this._listeners[ev]) return this;
  2444. if (!handler) {
  2445. delete this._listeners[ev];
  2446. return this;
  2447. }
  2448. var hIndex = this._listeners[ev].indexOf(handler);
  2449. if (hIndex >= 0) this._listeners[ev].splice(hIndex, 1);
  2450. return this;
  2451. }
  2452. }, {
  2453. key: "_onInput",
  2454. value: function _onInput(e) {
  2455. this._inputEvent = e;
  2456. this._abortUpdateCursor();
  2457. if (!this._selection) return this.updateValue();
  2458. var details = new ActionDetails(
  2459. this.el.value, this.cursorPos,
  2460. this.value, this._selection);
  2461. var oldRawValue = this.masked.rawInputValue;
  2462. var offset = this.masked.splice(details.startChangePos, details.removed.length, details.inserted, details.removeDirection, {
  2463. input: true,
  2464. raw: true
  2465. }).offset;
  2466. var removeDirection = oldRawValue === this.masked.rawInputValue ? details.removeDirection : DIRECTION.NONE;
  2467. var cursorPos = this.masked.nearestInputPos(details.startChangePos + offset, removeDirection);
  2468. if (removeDirection !== DIRECTION.NONE) cursorPos = this.masked.nearestInputPos(cursorPos, DIRECTION.NONE);
  2469. this.updateControl();
  2470. this.updateCursor(cursorPos);
  2471. delete this._inputEvent;
  2472. }
  2473. }, {
  2474. key: "_onChange",
  2475. value: function _onChange() {
  2476. if (this.value !== this.el.value) {
  2477. this.updateValue();
  2478. }
  2479. this.masked.doCommit();
  2480. this.updateControl();
  2481. this._saveSelection();
  2482. }
  2483. }, {
  2484. key: "_onDrop",
  2485. value: function _onDrop(ev) {
  2486. ev.preventDefault();
  2487. ev.stopPropagation();
  2488. }
  2489. }, {
  2490. key: "_onFocus",
  2491. value: function _onFocus(ev) {
  2492. this.alignCursorFriendly();
  2493. }
  2494. }, {
  2495. key: "_onClick",
  2496. value: function _onClick(ev) {
  2497. this.alignCursorFriendly();
  2498. }
  2499. }, {
  2500. key: "destroy",
  2501. value: function destroy() {
  2502. this._unbindEvents();
  2503. this._listeners.length = 0;
  2504. delete this.el;
  2505. }
  2506. }]);
  2507. return InputMask;
  2508. }();
  2509. IMask.InputMask = InputMask;
  2510. var MaskedEnum = function (_MaskedPattern) {
  2511. _inherits(MaskedEnum, _MaskedPattern);
  2512. var _super = _createSuper(MaskedEnum);
  2513. function MaskedEnum() {
  2514. _classCallCheck(this, MaskedEnum);
  2515. return _super.apply(this, arguments);
  2516. }
  2517. _createClass(MaskedEnum, [{
  2518. key: "_update",
  2519. value:
  2520. function _update(opts) {
  2521. if (opts.enum) opts.mask = '*'.repeat(opts.enum[0].length);
  2522. _get(_getPrototypeOf(MaskedEnum.prototype), "_update", this).call(this, opts);
  2523. }
  2524. }, {
  2525. key: "doValidate",
  2526. value: function doValidate() {
  2527. var _this = this,
  2528. _get2;
  2529. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  2530. args[_key] = arguments[_key];
  2531. }
  2532. return this.enum.some(function (e) {
  2533. return e.indexOf(_this.unmaskedValue) >= 0;
  2534. }) && (_get2 = _get(_getPrototypeOf(MaskedEnum.prototype), "doValidate", this)).call.apply(_get2, [this].concat(args));
  2535. }
  2536. }]);
  2537. return MaskedEnum;
  2538. }(MaskedPattern);
  2539. IMask.MaskedEnum = MaskedEnum;
  2540. var MaskedNumber = function (_Masked) {
  2541. _inherits(MaskedNumber, _Masked);
  2542. var _super = _createSuper(MaskedNumber);
  2543. function MaskedNumber(opts) {
  2544. _classCallCheck(this, MaskedNumber);
  2545. return _super.call(this, Object.assign({}, MaskedNumber.DEFAULTS, opts));
  2546. }
  2547. _createClass(MaskedNumber, [{
  2548. key: "_update",
  2549. value: function _update(opts) {
  2550. _get(_getPrototypeOf(MaskedNumber.prototype), "_update", this).call(this, opts);
  2551. this._updateRegExps();
  2552. }
  2553. }, {
  2554. key: "_updateRegExps",
  2555. value: function _updateRegExps() {
  2556. var start = '^' + (this.allowNegative ? '[+|\\-]?' : '');
  2557. var midInput = '(0|([1-9]+\\d*))?';
  2558. var mid = '\\d*';
  2559. var end = (this.scale ? '(' + escapeRegExp(this.radix) + '\\d{0,' + this.scale + '})?' : '') + '$';
  2560. this._numberRegExpInput = new RegExp(start + midInput + end);
  2561. this._numberRegExp = new RegExp(start + mid + end);
  2562. this._mapToRadixRegExp = new RegExp('[' + this.mapToRadix.map(escapeRegExp).join('') + ']', 'g');
  2563. this._thousandsSeparatorRegExp = new RegExp(escapeRegExp(this.thousandsSeparator), 'g');
  2564. }
  2565. }, {
  2566. key: "_removeThousandsSeparators",
  2567. value: function _removeThousandsSeparators(value) {
  2568. return value.replace(this._thousandsSeparatorRegExp, '');
  2569. }
  2570. }, {
  2571. key: "_insertThousandsSeparators",
  2572. value: function _insertThousandsSeparators(value) {
  2573. var parts = value.split(this.radix);
  2574. parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, this.thousandsSeparator);
  2575. return parts.join(this.radix);
  2576. }
  2577. }, {
  2578. key: "doPrepare",
  2579. value: function doPrepare(ch) {
  2580. var _get2;
  2581. ch = ch.replace(this._mapToRadixRegExp, this.radix);
  2582. var noSepCh = this._removeThousandsSeparators(ch);
  2583. for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  2584. args[_key - 1] = arguments[_key];
  2585. }
  2586. var _normalizePrepare = normalizePrepare((_get2 = _get(_getPrototypeOf(MaskedNumber.prototype), "doPrepare", this)).call.apply(_get2, [this, noSepCh].concat(args))),
  2587. _normalizePrepare2 = _slicedToArray(_normalizePrepare, 2),
  2588. prepCh = _normalizePrepare2[0],
  2589. details = _normalizePrepare2[1];
  2590. if (ch && !noSepCh) details.skip = true;
  2591. return [prepCh, details];
  2592. }
  2593. }, {
  2594. key: "_separatorsCount",
  2595. value: function _separatorsCount(to) {
  2596. var extendOnSeparators = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  2597. var count = 0;
  2598. for (var pos = 0; pos < to; ++pos) {
  2599. if (this._value.indexOf(this.thousandsSeparator, pos) === pos) {
  2600. ++count;
  2601. if (extendOnSeparators) to += this.thousandsSeparator.length;
  2602. }
  2603. }
  2604. return count;
  2605. }
  2606. }, {
  2607. key: "_separatorsCountFromSlice",
  2608. value: function _separatorsCountFromSlice() {
  2609. var slice = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this._value;
  2610. return this._separatorsCount(this._removeThousandsSeparators(slice).length, true);
  2611. }
  2612. }, {
  2613. key: "extractInput",
  2614. value: function extractInput() {
  2615. var fromPos = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  2616. var toPos = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.value.length;
  2617. var flags = arguments.length > 2 ? arguments[2] : undefined;
  2618. var _this$_adjustRangeWit = this._adjustRangeWithSeparators(fromPos, toPos);
  2619. var _this$_adjustRangeWit2 = _slicedToArray(_this$_adjustRangeWit, 2);
  2620. fromPos = _this$_adjustRangeWit2[0];
  2621. toPos = _this$_adjustRangeWit2[1];
  2622. return this._removeThousandsSeparators(_get(_getPrototypeOf(MaskedNumber.prototype), "extractInput", this).call(this, fromPos, toPos, flags));
  2623. }
  2624. }, {
  2625. key: "_appendCharRaw",
  2626. value: function _appendCharRaw(ch) {
  2627. var flags = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  2628. if (!this.thousandsSeparator) return _get(_getPrototypeOf(MaskedNumber.prototype), "_appendCharRaw", this).call(this, ch, flags);
  2629. var prevBeforeTailValue = flags.tail && flags._beforeTailState ? flags._beforeTailState._value : this._value;
  2630. var prevBeforeTailSeparatorsCount = this._separatorsCountFromSlice(prevBeforeTailValue);
  2631. this._value = this._removeThousandsSeparators(this.value);
  2632. var appendDetails = _get(_getPrototypeOf(MaskedNumber.prototype), "_appendCharRaw", this).call(this, ch, flags);
  2633. this._value = this._insertThousandsSeparators(this._value);
  2634. var beforeTailValue = flags.tail && flags._beforeTailState ? flags._beforeTailState._value : this._value;
  2635. var beforeTailSeparatorsCount = this._separatorsCountFromSlice(beforeTailValue);
  2636. appendDetails.tailShift += (beforeTailSeparatorsCount - prevBeforeTailSeparatorsCount) * this.thousandsSeparator.length;
  2637. appendDetails.skip = !appendDetails.rawInserted && ch === this.thousandsSeparator;
  2638. return appendDetails;
  2639. }
  2640. }, {
  2641. key: "_findSeparatorAround",
  2642. value: function _findSeparatorAround(pos) {
  2643. if (this.thousandsSeparator) {
  2644. var searchFrom = pos - this.thousandsSeparator.length + 1;
  2645. var separatorPos = this.value.indexOf(this.thousandsSeparator, searchFrom);
  2646. if (separatorPos <= pos) return separatorPos;
  2647. }
  2648. return -1;
  2649. }
  2650. }, {
  2651. key: "_adjustRangeWithSeparators",
  2652. value: function _adjustRangeWithSeparators(from, to) {
  2653. var separatorAroundFromPos = this._findSeparatorAround(from);
  2654. if (separatorAroundFromPos >= 0) from = separatorAroundFromPos;
  2655. var separatorAroundToPos = this._findSeparatorAround(to);
  2656. if (separatorAroundToPos >= 0) to = separatorAroundToPos + this.thousandsSeparator.length;
  2657. return [from, to];
  2658. }
  2659. }, {
  2660. key: "remove",
  2661. value: function remove() {
  2662. var fromPos = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  2663. var toPos = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.value.length;
  2664. var _this$_adjustRangeWit3 = this._adjustRangeWithSeparators(fromPos, toPos);
  2665. var _this$_adjustRangeWit4 = _slicedToArray(_this$_adjustRangeWit3, 2);
  2666. fromPos = _this$_adjustRangeWit4[0];
  2667. toPos = _this$_adjustRangeWit4[1];
  2668. var valueBeforePos = this.value.slice(0, fromPos);
  2669. var valueAfterPos = this.value.slice(toPos);
  2670. var prevBeforeTailSeparatorsCount = this._separatorsCount(valueBeforePos.length);
  2671. this._value = this._insertThousandsSeparators(this._removeThousandsSeparators(valueBeforePos + valueAfterPos));
  2672. var beforeTailSeparatorsCount = this._separatorsCountFromSlice(valueBeforePos);
  2673. return new ChangeDetails({
  2674. tailShift: (beforeTailSeparatorsCount - prevBeforeTailSeparatorsCount) * this.thousandsSeparator.length
  2675. });
  2676. }
  2677. }, {
  2678. key: "nearestInputPos",
  2679. value: function nearestInputPos(cursorPos, direction) {
  2680. if (!this.thousandsSeparator) return cursorPos;
  2681. switch (direction) {
  2682. case DIRECTION.NONE:
  2683. case DIRECTION.LEFT:
  2684. case DIRECTION.FORCE_LEFT:
  2685. {
  2686. var separatorAtLeftPos = this._findSeparatorAround(cursorPos - 1);
  2687. if (separatorAtLeftPos >= 0) {
  2688. var separatorAtLeftEndPos = separatorAtLeftPos + this.thousandsSeparator.length;
  2689. if (cursorPos < separatorAtLeftEndPos || this.value.length <= separatorAtLeftEndPos || direction === DIRECTION.FORCE_LEFT) {
  2690. return separatorAtLeftPos;
  2691. }
  2692. }
  2693. break;
  2694. }
  2695. case DIRECTION.RIGHT:
  2696. case DIRECTION.FORCE_RIGHT:
  2697. {
  2698. var separatorAtRightPos = this._findSeparatorAround(cursorPos);
  2699. if (separatorAtRightPos >= 0) {
  2700. return separatorAtRightPos + this.thousandsSeparator.length;
  2701. }
  2702. }
  2703. }
  2704. return cursorPos;
  2705. }
  2706. }, {
  2707. key: "doValidate",
  2708. value: function doValidate(flags) {
  2709. var regexp = flags.input ? this._numberRegExpInput : this._numberRegExp;
  2710. var valid = regexp.test(this._removeThousandsSeparators(this.value));
  2711. if (valid) {
  2712. var number = this.number;
  2713. valid = valid && !isNaN(number) && (
  2714. this.min == null || this.min >= 0 || this.min <= this.number) && (
  2715. this.max == null || this.max <= 0 || this.number <= this.max);
  2716. }
  2717. return valid && _get(_getPrototypeOf(MaskedNumber.prototype), "doValidate", this).call(this, flags);
  2718. }
  2719. }, {
  2720. key: "doCommit",
  2721. value: function doCommit() {
  2722. if (this.value) {
  2723. var number = this.number;
  2724. var validnum = number;
  2725. if (this.min != null) validnum = Math.max(validnum, this.min);
  2726. if (this.max != null) validnum = Math.min(validnum, this.max);
  2727. if (validnum !== number) this.unmaskedValue = String(validnum);
  2728. var formatted = this.value;
  2729. if (this.normalizeZeros) formatted = this._normalizeZeros(formatted);
  2730. if (this.padFractionalZeros && this.scale > 0) formatted = this._padFractionalZeros(formatted);
  2731. this._value = formatted;
  2732. }
  2733. _get(_getPrototypeOf(MaskedNumber.prototype), "doCommit", this).call(this);
  2734. }
  2735. }, {
  2736. key: "_normalizeZeros",
  2737. value: function _normalizeZeros(value) {
  2738. var parts = this._removeThousandsSeparators(value).split(this.radix);
  2739. parts[0] = parts[0].replace(/^(\D*)(0*)(\d*)/, function (match, sign, zeros, num) {
  2740. return sign + num;
  2741. });
  2742. if (value.length && !/\d$/.test(parts[0])) parts[0] = parts[0] + '0';
  2743. if (parts.length > 1) {
  2744. parts[1] = parts[1].replace(/0*$/, '');
  2745. if (!parts[1].length) parts.length = 1;
  2746. }
  2747. return this._insertThousandsSeparators(parts.join(this.radix));
  2748. }
  2749. }, {
  2750. key: "_padFractionalZeros",
  2751. value: function _padFractionalZeros(value) {
  2752. if (!value) return value;
  2753. var parts = value.split(this.radix);
  2754. if (parts.length < 2) parts.push('');
  2755. parts[1] = parts[1].padEnd(this.scale, '0');
  2756. return parts.join(this.radix);
  2757. }
  2758. }, {
  2759. key: "unmaskedValue",
  2760. get: function get() {
  2761. return this._removeThousandsSeparators(this._normalizeZeros(this.value)).replace(this.radix, '.');
  2762. },
  2763. set: function set(unmaskedValue) {
  2764. _set(_getPrototypeOf(MaskedNumber.prototype), "unmaskedValue", unmaskedValue.replace('.', this.radix), this, true);
  2765. }
  2766. }, {
  2767. key: "typedValue",
  2768. get: function get() {
  2769. return Number(this.unmaskedValue);
  2770. },
  2771. set: function set(n) {
  2772. _set(_getPrototypeOf(MaskedNumber.prototype), "unmaskedValue", String(n), this, true);
  2773. }
  2774. }, {
  2775. key: "number",
  2776. get: function get() {
  2777. return this.typedValue;
  2778. },
  2779. set: function set(number) {
  2780. this.typedValue = number;
  2781. }
  2782. }, {
  2783. key: "allowNegative",
  2784. get: function get() {
  2785. return this.signed || this.min != null && this.min < 0 || this.max != null && this.max < 0;
  2786. }
  2787. }, {
  2788. key: "typedValueEquals",
  2789. value: function typedValueEquals(value) {
  2790. return (_get(_getPrototypeOf(MaskedNumber.prototype), "typedValueEquals", this).call(this, value) || MaskedNumber.EMPTY_VALUES.includes(value) && MaskedNumber.EMPTY_VALUES.includes(this.typedValue)) && !(value === 0 && this.value === '');
  2791. }
  2792. }]);
  2793. return MaskedNumber;
  2794. }(Masked);
  2795. MaskedNumber.DEFAULTS = {
  2796. radix: ',',
  2797. thousandsSeparator: '',
  2798. mapToRadix: ['.'],
  2799. scale: 2,
  2800. signed: false,
  2801. normalizeZeros: true,
  2802. padFractionalZeros: false
  2803. };
  2804. MaskedNumber.EMPTY_VALUES = [].concat(_toConsumableArray(Masked.EMPTY_VALUES), [0]);
  2805. IMask.MaskedNumber = MaskedNumber;
  2806. var MaskedFunction = function (_Masked) {
  2807. _inherits(MaskedFunction, _Masked);
  2808. var _super = _createSuper(MaskedFunction);
  2809. function MaskedFunction() {
  2810. _classCallCheck(this, MaskedFunction);
  2811. return _super.apply(this, arguments);
  2812. }
  2813. _createClass(MaskedFunction, [{
  2814. key: "_update",
  2815. value:
  2816. function _update(opts) {
  2817. if (opts.mask) opts.validate = opts.mask;
  2818. _get(_getPrototypeOf(MaskedFunction.prototype), "_update", this).call(this, opts);
  2819. }
  2820. }]);
  2821. return MaskedFunction;
  2822. }(Masked);
  2823. IMask.MaskedFunction = MaskedFunction;
  2824. var _excluded = ["compiledMasks", "currentMaskRef", "currentMask"];
  2825. var MaskedDynamic = function (_Masked) {
  2826. _inherits(MaskedDynamic, _Masked);
  2827. var _super = _createSuper(MaskedDynamic);
  2828. function MaskedDynamic(opts) {
  2829. var _this;
  2830. _classCallCheck(this, MaskedDynamic);
  2831. _this = _super.call(this, Object.assign({}, MaskedDynamic.DEFAULTS, opts));
  2832. _this.currentMask = null;
  2833. return _this;
  2834. }
  2835. _createClass(MaskedDynamic, [{
  2836. key: "_update",
  2837. value: function _update(opts) {
  2838. _get(_getPrototypeOf(MaskedDynamic.prototype), "_update", this).call(this, opts);
  2839. if ('mask' in opts) {
  2840. this.compiledMasks = Array.isArray(opts.mask) ? opts.mask.map(function (m) {
  2841. return createMask(m);
  2842. }) : [];
  2843. }
  2844. }
  2845. }, {
  2846. key: "_appendCharRaw",
  2847. value: function _appendCharRaw(ch) {
  2848. var flags = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  2849. var details = this._applyDispatch(ch, flags);
  2850. if (this.currentMask) {
  2851. details.aggregate(this.currentMask._appendChar(ch, this.currentMaskFlags(flags)));
  2852. }
  2853. return details;
  2854. }
  2855. }, {
  2856. key: "_applyDispatch",
  2857. value: function _applyDispatch() {
  2858. var appended = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
  2859. var flags = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  2860. var prevValueBeforeTail = flags.tail && flags._beforeTailState != null ? flags._beforeTailState._value : this.value;
  2861. var inputValue = this.rawInputValue;
  2862. var insertValue = flags.tail && flags._beforeTailState != null ?
  2863. flags._beforeTailState._rawInputValue : inputValue;
  2864. var tailValue = inputValue.slice(insertValue.length);
  2865. var prevMask = this.currentMask;
  2866. var details = new ChangeDetails();
  2867. var prevMaskState = prevMask === null || prevMask === void 0 ? void 0 : prevMask.state;
  2868. this.currentMask = this.doDispatch(appended, Object.assign({}, flags));
  2869. if (this.currentMask) {
  2870. if (this.currentMask !== prevMask) {
  2871. this.currentMask.reset();
  2872. if (insertValue) {
  2873. var d = this.currentMask.append(insertValue, {
  2874. raw: true
  2875. });
  2876. details.tailShift = d.inserted.length - prevValueBeforeTail.length;
  2877. }
  2878. if (tailValue) {
  2879. details.tailShift += this.currentMask.append(tailValue, {
  2880. raw: true,
  2881. tail: true
  2882. }).tailShift;
  2883. }
  2884. } else {
  2885. this.currentMask.state = prevMaskState;
  2886. }
  2887. }
  2888. return details;
  2889. }
  2890. }, {
  2891. key: "_appendPlaceholder",
  2892. value: function _appendPlaceholder() {
  2893. var details = this._applyDispatch.apply(this, arguments);
  2894. if (this.currentMask) {
  2895. details.aggregate(this.currentMask._appendPlaceholder());
  2896. }
  2897. return details;
  2898. }
  2899. }, {
  2900. key: "_appendEager",
  2901. value: function _appendEager() {
  2902. var details = this._applyDispatch.apply(this, arguments);
  2903. if (this.currentMask) {
  2904. details.aggregate(this.currentMask._appendEager());
  2905. }
  2906. return details;
  2907. }
  2908. }, {
  2909. key: "currentMaskFlags",
  2910. value: function currentMaskFlags(flags) {
  2911. var _flags$_beforeTailSta, _flags$_beforeTailSta2;
  2912. return Object.assign({}, flags, {
  2913. _beforeTailState: ((_flags$_beforeTailSta = flags._beforeTailState) === null || _flags$_beforeTailSta === void 0 ? void 0 : _flags$_beforeTailSta.currentMaskRef) === this.currentMask && ((_flags$_beforeTailSta2 = flags._beforeTailState) === null || _flags$_beforeTailSta2 === void 0 ? void 0 : _flags$_beforeTailSta2.currentMask) || flags._beforeTailState
  2914. });
  2915. }
  2916. }, {
  2917. key: "doDispatch",
  2918. value: function doDispatch(appended) {
  2919. var flags = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  2920. return this.dispatch(appended, this, flags);
  2921. }
  2922. }, {
  2923. key: "doValidate",
  2924. value: function doValidate(flags) {
  2925. return _get(_getPrototypeOf(MaskedDynamic.prototype), "doValidate", this).call(this, flags) && (!this.currentMask || this.currentMask.doValidate(this.currentMaskFlags(flags)));
  2926. }
  2927. }, {
  2928. key: "doPrepare",
  2929. value: function doPrepare(str) {
  2930. var flags = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  2931. var _normalizePrepare = normalizePrepare(_get(_getPrototypeOf(MaskedDynamic.prototype), "doPrepare", this).call(this, str, flags)),
  2932. _normalizePrepare2 = _slicedToArray(_normalizePrepare, 2),
  2933. s = _normalizePrepare2[0],
  2934. details = _normalizePrepare2[1];
  2935. if (this.currentMask) {
  2936. var currentDetails;
  2937. var _normalizePrepare3 = normalizePrepare(_get(_getPrototypeOf(MaskedDynamic.prototype), "doPrepare", this).call(this, s, this.currentMaskFlags(flags)));
  2938. var _normalizePrepare4 = _slicedToArray(_normalizePrepare3, 2);
  2939. s = _normalizePrepare4[0];
  2940. currentDetails = _normalizePrepare4[1];
  2941. details = details.aggregate(currentDetails);
  2942. }
  2943. return [s, details];
  2944. }
  2945. }, {
  2946. key: "reset",
  2947. value: function reset() {
  2948. var _this$currentMask;
  2949. (_this$currentMask = this.currentMask) === null || _this$currentMask === void 0 ? void 0 : _this$currentMask.reset();
  2950. this.compiledMasks.forEach(function (m) {
  2951. return m.reset();
  2952. });
  2953. }
  2954. }, {
  2955. key: "value",
  2956. get: function get() {
  2957. return this.currentMask ? this.currentMask.value : '';
  2958. },
  2959. set: function set(value) {
  2960. _set(_getPrototypeOf(MaskedDynamic.prototype), "value", value, this, true);
  2961. }
  2962. }, {
  2963. key: "unmaskedValue",
  2964. get: function get() {
  2965. return this.currentMask ? this.currentMask.unmaskedValue : '';
  2966. },
  2967. set: function set(unmaskedValue) {
  2968. _set(_getPrototypeOf(MaskedDynamic.prototype), "unmaskedValue", unmaskedValue, this, true);
  2969. }
  2970. }, {
  2971. key: "typedValue",
  2972. get: function get() {
  2973. return this.currentMask ? this.currentMask.typedValue : '';
  2974. }
  2975. ,
  2976. set: function set(value) {
  2977. var unmaskedValue = String(value);
  2978. if (this.currentMask) {
  2979. this.currentMask.typedValue = value;
  2980. unmaskedValue = this.currentMask.unmaskedValue;
  2981. }
  2982. this.unmaskedValue = unmaskedValue;
  2983. }
  2984. }, {
  2985. key: "isComplete",
  2986. get: function get() {
  2987. var _this$currentMask2;
  2988. return Boolean((_this$currentMask2 = this.currentMask) === null || _this$currentMask2 === void 0 ? void 0 : _this$currentMask2.isComplete);
  2989. }
  2990. }, {
  2991. key: "isFilled",
  2992. get: function get() {
  2993. var _this$currentMask3;
  2994. return Boolean((_this$currentMask3 = this.currentMask) === null || _this$currentMask3 === void 0 ? void 0 : _this$currentMask3.isFilled);
  2995. }
  2996. }, {
  2997. key: "remove",
  2998. value: function remove() {
  2999. var details = new ChangeDetails();
  3000. if (this.currentMask) {
  3001. var _this$currentMask4;
  3002. details.aggregate((_this$currentMask4 = this.currentMask).remove.apply(_this$currentMask4, arguments))
  3003. .aggregate(this._applyDispatch());
  3004. }
  3005. return details;
  3006. }
  3007. }, {
  3008. key: "state",
  3009. get: function get() {
  3010. var _this$currentMask5;
  3011. return Object.assign({}, _get(_getPrototypeOf(MaskedDynamic.prototype), "state", this), {
  3012. _rawInputValue: this.rawInputValue,
  3013. compiledMasks: this.compiledMasks.map(function (m) {
  3014. return m.state;
  3015. }),
  3016. currentMaskRef: this.currentMask,
  3017. currentMask: (_this$currentMask5 = this.currentMask) === null || _this$currentMask5 === void 0 ? void 0 : _this$currentMask5.state
  3018. });
  3019. },
  3020. set: function set(state) {
  3021. var compiledMasks = state.compiledMasks,
  3022. currentMaskRef = state.currentMaskRef,
  3023. currentMask = state.currentMask,
  3024. maskedState = _objectWithoutProperties(state, _excluded);
  3025. this.compiledMasks.forEach(function (m, mi) {
  3026. return m.state = compiledMasks[mi];
  3027. });
  3028. if (currentMaskRef != null) {
  3029. this.currentMask = currentMaskRef;
  3030. this.currentMask.state = currentMask;
  3031. }
  3032. _set(_getPrototypeOf(MaskedDynamic.prototype), "state", maskedState, this, true);
  3033. }
  3034. }, {
  3035. key: "extractInput",
  3036. value: function extractInput() {
  3037. var _this$currentMask6;
  3038. return this.currentMask ? (_this$currentMask6 = this.currentMask).extractInput.apply(_this$currentMask6, arguments) : '';
  3039. }
  3040. }, {
  3041. key: "extractTail",
  3042. value: function extractTail() {
  3043. var _this$currentMask7, _get2;
  3044. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  3045. args[_key] = arguments[_key];
  3046. }
  3047. return this.currentMask ? (_this$currentMask7 = this.currentMask).extractTail.apply(_this$currentMask7, args) : (_get2 = _get(_getPrototypeOf(MaskedDynamic.prototype), "extractTail", this)).call.apply(_get2, [this].concat(args));
  3048. }
  3049. }, {
  3050. key: "doCommit",
  3051. value: function doCommit() {
  3052. if (this.currentMask) this.currentMask.doCommit();
  3053. _get(_getPrototypeOf(MaskedDynamic.prototype), "doCommit", this).call(this);
  3054. }
  3055. }, {
  3056. key: "nearestInputPos",
  3057. value: function nearestInputPos() {
  3058. var _this$currentMask8, _get3;
  3059. for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
  3060. args[_key2] = arguments[_key2];
  3061. }
  3062. return this.currentMask ? (_this$currentMask8 = this.currentMask).nearestInputPos.apply(_this$currentMask8, args) : (_get3 = _get(_getPrototypeOf(MaskedDynamic.prototype), "nearestInputPos", this)).call.apply(_get3, [this].concat(args));
  3063. }
  3064. }, {
  3065. key: "overwrite",
  3066. get: function get() {
  3067. return this.currentMask ? this.currentMask.overwrite : _get(_getPrototypeOf(MaskedDynamic.prototype), "overwrite", this);
  3068. },
  3069. set: function set(overwrite) {
  3070. console.warn('"overwrite" option is not available in dynamic mask, use this option in siblings');
  3071. }
  3072. }, {
  3073. key: "eager",
  3074. get: function get() {
  3075. return this.currentMask ? this.currentMask.eager : _get(_getPrototypeOf(MaskedDynamic.prototype), "eager", this);
  3076. },
  3077. set: function set(eager) {
  3078. console.warn('"eager" option is not available in dynamic mask, use this option in siblings');
  3079. }
  3080. }, {
  3081. key: "maskEquals",
  3082. value: function maskEquals(mask) {
  3083. return Array.isArray(mask) && this.compiledMasks.every(function (m, mi) {
  3084. var _mask$mi;
  3085. return m.maskEquals((_mask$mi = mask[mi]) === null || _mask$mi === void 0 ? void 0 : _mask$mi.mask);
  3086. });
  3087. }
  3088. }, {
  3089. key: "typedValueEquals",
  3090. value: function typedValueEquals(value) {
  3091. var _this$currentMask9;
  3092. return Boolean((_this$currentMask9 = this.currentMask) === null || _this$currentMask9 === void 0 ? void 0 : _this$currentMask9.typedValueEquals(value));
  3093. }
  3094. }]);
  3095. return MaskedDynamic;
  3096. }(Masked);
  3097. MaskedDynamic.DEFAULTS = {
  3098. dispatch: function dispatch(appended, masked, flags) {
  3099. if (!masked.compiledMasks.length) return;
  3100. var inputValue = masked.rawInputValue;
  3101. var inputs = masked.compiledMasks.map(function (m, index) {
  3102. m.reset();
  3103. m.append(inputValue, {
  3104. raw: true
  3105. });
  3106. m.append(appended, masked.currentMaskFlags(flags));
  3107. var weight = m.rawInputValue.length;
  3108. return {
  3109. weight: weight,
  3110. index: index
  3111. };
  3112. });
  3113. inputs.sort(function (i1, i2) {
  3114. return i2.weight - i1.weight;
  3115. });
  3116. return masked.compiledMasks[inputs[0].index];
  3117. }
  3118. };
  3119. IMask.MaskedDynamic = MaskedDynamic;
  3120. var PIPE_TYPE = {
  3121. MASKED: 'value',
  3122. UNMASKED: 'unmaskedValue',
  3123. TYPED: 'typedValue'
  3124. };
  3125. function createPipe(mask) {
  3126. var from = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : PIPE_TYPE.MASKED;
  3127. var to = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : PIPE_TYPE.MASKED;
  3128. var masked = createMask(mask);
  3129. return function (value) {
  3130. return masked.runIsolated(function (m) {
  3131. m[from] = value;
  3132. return m[to];
  3133. });
  3134. };
  3135. }
  3136. function pipe(value) {
  3137. for (var _len = arguments.length, pipeArgs = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  3138. pipeArgs[_key - 1] = arguments[_key];
  3139. }
  3140. return createPipe.apply(void 0, pipeArgs)(value);
  3141. }
  3142. IMask.PIPE_TYPE = PIPE_TYPE;
  3143. IMask.createPipe = createPipe;
  3144. IMask.pipe = pipe;
  3145. try {
  3146. globalThis.IMask = IMask;
  3147. } catch (e) {}
  3148. var maskElementList = [].slice.call(document.querySelectorAll('[data-mask]'));
  3149. maskElementList.map(function (maskEl) {
  3150. return new IMask(maskEl, {
  3151. mask: maskEl.dataset.mask,
  3152. lazy: maskEl.dataset['mask-visible'] === 'true'
  3153. });
  3154. });
  3155. var top = 'top';
  3156. var bottom = 'bottom';
  3157. var right = 'right';
  3158. var left = 'left';
  3159. var auto = 'auto';
  3160. var basePlacements = [top, bottom, right, left];
  3161. var start = 'start';
  3162. var end = 'end';
  3163. var clippingParents = 'clippingParents';
  3164. var viewport = 'viewport';
  3165. var popper = 'popper';
  3166. var reference = 'reference';
  3167. var variationPlacements = basePlacements.reduce(function (acc, placement) {
  3168. return acc.concat([placement + "-" + start, placement + "-" + end]);
  3169. }, []);
  3170. var placements = [].concat(basePlacements, [auto]).reduce(function (acc, placement) {
  3171. return acc.concat([placement, placement + "-" + start, placement + "-" + end]);
  3172. }, []);
  3173. var beforeRead = 'beforeRead';
  3174. var read = 'read';
  3175. var afterRead = 'afterRead';
  3176. var beforeMain = 'beforeMain';
  3177. var main = 'main';
  3178. var afterMain = 'afterMain';
  3179. var beforeWrite = 'beforeWrite';
  3180. var write = 'write';
  3181. var afterWrite = 'afterWrite';
  3182. var modifierPhases = [beforeRead, read, afterRead, beforeMain, main, afterMain, beforeWrite, write, afterWrite];
  3183. function getNodeName(element) {
  3184. return element ? (element.nodeName || '').toLowerCase() : null;
  3185. }
  3186. function getWindow(node) {
  3187. if (node == null) {
  3188. return window;
  3189. }
  3190. if (node.toString() !== '[object Window]') {
  3191. var ownerDocument = node.ownerDocument;
  3192. return ownerDocument ? ownerDocument.defaultView || window : window;
  3193. }
  3194. return node;
  3195. }
  3196. function isElement$1(node) {
  3197. var OwnElement = getWindow(node).Element;
  3198. return node instanceof OwnElement || node instanceof Element;
  3199. }
  3200. function isHTMLElement(node) {
  3201. var OwnElement = getWindow(node).HTMLElement;
  3202. return node instanceof OwnElement || node instanceof HTMLElement;
  3203. }
  3204. function isShadowRoot(node) {
  3205. if (typeof ShadowRoot === 'undefined') {
  3206. return false;
  3207. }
  3208. var OwnElement = getWindow(node).ShadowRoot;
  3209. return node instanceof OwnElement || node instanceof ShadowRoot;
  3210. }
  3211. function applyStyles(_ref) {
  3212. var state = _ref.state;
  3213. Object.keys(state.elements).forEach(function (name) {
  3214. var style = state.styles[name] || {};
  3215. var attributes = state.attributes[name] || {};
  3216. var element = state.elements[name];
  3217. if (!isHTMLElement(element) || !getNodeName(element)) {
  3218. return;
  3219. }
  3220. Object.assign(element.style, style);
  3221. Object.keys(attributes).forEach(function (name) {
  3222. var value = attributes[name];
  3223. if (value === false) {
  3224. element.removeAttribute(name);
  3225. } else {
  3226. element.setAttribute(name, value === true ? '' : value);
  3227. }
  3228. });
  3229. });
  3230. }
  3231. function effect$2(_ref2) {
  3232. var state = _ref2.state;
  3233. var initialStyles = {
  3234. popper: {
  3235. position: state.options.strategy,
  3236. left: '0',
  3237. top: '0',
  3238. margin: '0'
  3239. },
  3240. arrow: {
  3241. position: 'absolute'
  3242. },
  3243. reference: {}
  3244. };
  3245. Object.assign(state.elements.popper.style, initialStyles.popper);
  3246. state.styles = initialStyles;
  3247. if (state.elements.arrow) {
  3248. Object.assign(state.elements.arrow.style, initialStyles.arrow);
  3249. }
  3250. return function () {
  3251. Object.keys(state.elements).forEach(function (name) {
  3252. var element = state.elements[name];
  3253. var attributes = state.attributes[name] || {};
  3254. var styleProperties = Object.keys(state.styles.hasOwnProperty(name) ? state.styles[name] : initialStyles[name]);
  3255. var style = styleProperties.reduce(function (style, property) {
  3256. style[property] = '';
  3257. return style;
  3258. }, {});
  3259. if (!isHTMLElement(element) || !getNodeName(element)) {
  3260. return;
  3261. }
  3262. Object.assign(element.style, style);
  3263. Object.keys(attributes).forEach(function (attribute) {
  3264. element.removeAttribute(attribute);
  3265. });
  3266. });
  3267. };
  3268. }
  3269. var applyStyles$1 = {
  3270. name: 'applyStyles',
  3271. enabled: true,
  3272. phase: 'write',
  3273. fn: applyStyles,
  3274. effect: effect$2,
  3275. requires: ['computeStyles']
  3276. };
  3277. function getBasePlacement(placement) {
  3278. return placement.split('-')[0];
  3279. }
  3280. var max = Math.max;
  3281. var min = Math.min;
  3282. var round = Math.round;
  3283. function getUAString() {
  3284. var uaData = navigator.userAgentData;
  3285. if (uaData != null && uaData.brands) {
  3286. return uaData.brands.map(function (item) {
  3287. return item.brand + "/" + item.version;
  3288. }).join(' ');
  3289. }
  3290. return navigator.userAgent;
  3291. }
  3292. function isLayoutViewport() {
  3293. return !/^((?!chrome|android).)*safari/i.test(getUAString());
  3294. }
  3295. function getBoundingClientRect(element, includeScale, isFixedStrategy) {
  3296. if (includeScale === void 0) {
  3297. includeScale = false;
  3298. }
  3299. if (isFixedStrategy === void 0) {
  3300. isFixedStrategy = false;
  3301. }
  3302. var clientRect = element.getBoundingClientRect();
  3303. var scaleX = 1;
  3304. var scaleY = 1;
  3305. if (includeScale && isHTMLElement(element)) {
  3306. scaleX = element.offsetWidth > 0 ? round(clientRect.width) / element.offsetWidth || 1 : 1;
  3307. scaleY = element.offsetHeight > 0 ? round(clientRect.height) / element.offsetHeight || 1 : 1;
  3308. }
  3309. var _ref = isElement$1(element) ? getWindow(element) : window,
  3310. visualViewport = _ref.visualViewport;
  3311. var addVisualOffsets = !isLayoutViewport() && isFixedStrategy;
  3312. var x = (clientRect.left + (addVisualOffsets && visualViewport ? visualViewport.offsetLeft : 0)) / scaleX;
  3313. var y = (clientRect.top + (addVisualOffsets && visualViewport ? visualViewport.offsetTop : 0)) / scaleY;
  3314. var width = clientRect.width / scaleX;
  3315. var height = clientRect.height / scaleY;
  3316. return {
  3317. width: width,
  3318. height: height,
  3319. top: y,
  3320. right: x + width,
  3321. bottom: y + height,
  3322. left: x,
  3323. x: x,
  3324. y: y
  3325. };
  3326. }
  3327. function getLayoutRect(element) {
  3328. var clientRect = getBoundingClientRect(element);
  3329. var width = element.offsetWidth;
  3330. var height = element.offsetHeight;
  3331. if (Math.abs(clientRect.width - width) <= 1) {
  3332. width = clientRect.width;
  3333. }
  3334. if (Math.abs(clientRect.height - height) <= 1) {
  3335. height = clientRect.height;
  3336. }
  3337. return {
  3338. x: element.offsetLeft,
  3339. y: element.offsetTop,
  3340. width: width,
  3341. height: height
  3342. };
  3343. }
  3344. function contains(parent, child) {
  3345. var rootNode = child.getRootNode && child.getRootNode();
  3346. if (parent.contains(child)) {
  3347. return true;
  3348. }
  3349. else if (rootNode && isShadowRoot(rootNode)) {
  3350. var next = child;
  3351. do {
  3352. if (next && parent.isSameNode(next)) {
  3353. return true;
  3354. }
  3355. next = next.parentNode || next.host;
  3356. } while (next);
  3357. }
  3358. return false;
  3359. }
  3360. function getComputedStyle$1(element) {
  3361. return getWindow(element).getComputedStyle(element);
  3362. }
  3363. function isTableElement(element) {
  3364. return ['table', 'td', 'th'].indexOf(getNodeName(element)) >= 0;
  3365. }
  3366. function getDocumentElement(element) {
  3367. return ((isElement$1(element) ? element.ownerDocument :
  3368. element.document) || window.document).documentElement;
  3369. }
  3370. function getParentNode(element) {
  3371. if (getNodeName(element) === 'html') {
  3372. return element;
  3373. }
  3374. return (
  3375. element.assignedSlot ||
  3376. element.parentNode || (
  3377. isShadowRoot(element) ? element.host : null) ||
  3378. getDocumentElement(element)
  3379. );
  3380. }
  3381. function getTrueOffsetParent(element) {
  3382. if (!isHTMLElement(element) ||
  3383. getComputedStyle$1(element).position === 'fixed') {
  3384. return null;
  3385. }
  3386. return element.offsetParent;
  3387. }
  3388. function getContainingBlock(element) {
  3389. var isFirefox = /firefox/i.test(getUAString());
  3390. var isIE = /Trident/i.test(getUAString());
  3391. if (isIE && isHTMLElement(element)) {
  3392. var elementCss = getComputedStyle$1(element);
  3393. if (elementCss.position === 'fixed') {
  3394. return null;
  3395. }
  3396. }
  3397. var currentNode = getParentNode(element);
  3398. if (isShadowRoot(currentNode)) {
  3399. currentNode = currentNode.host;
  3400. }
  3401. while (isHTMLElement(currentNode) && ['html', 'body'].indexOf(getNodeName(currentNode)) < 0) {
  3402. var css = getComputedStyle$1(currentNode);
  3403. 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') {
  3404. return currentNode;
  3405. } else {
  3406. currentNode = currentNode.parentNode;
  3407. }
  3408. }
  3409. return null;
  3410. }
  3411. function getOffsetParent(element) {
  3412. var window = getWindow(element);
  3413. var offsetParent = getTrueOffsetParent(element);
  3414. while (offsetParent && isTableElement(offsetParent) && getComputedStyle$1(offsetParent).position === 'static') {
  3415. offsetParent = getTrueOffsetParent(offsetParent);
  3416. }
  3417. if (offsetParent && (getNodeName(offsetParent) === 'html' || getNodeName(offsetParent) === 'body' && getComputedStyle$1(offsetParent).position === 'static')) {
  3418. return window;
  3419. }
  3420. return offsetParent || getContainingBlock(element) || window;
  3421. }
  3422. function getMainAxisFromPlacement(placement) {
  3423. return ['top', 'bottom'].indexOf(placement) >= 0 ? 'x' : 'y';
  3424. }
  3425. function within(min$1, value, max$1) {
  3426. return max(min$1, min(value, max$1));
  3427. }
  3428. function withinMaxClamp(min, value, max) {
  3429. var v = within(min, value, max);
  3430. return v > max ? max : v;
  3431. }
  3432. function getFreshSideObject() {
  3433. return {
  3434. top: 0,
  3435. right: 0,
  3436. bottom: 0,
  3437. left: 0
  3438. };
  3439. }
  3440. function mergePaddingObject(paddingObject) {
  3441. return Object.assign({}, getFreshSideObject(), paddingObject);
  3442. }
  3443. function expandToHashMap(value, keys) {
  3444. return keys.reduce(function (hashMap, key) {
  3445. hashMap[key] = value;
  3446. return hashMap;
  3447. }, {});
  3448. }
  3449. var toPaddingObject = function toPaddingObject(padding, state) {
  3450. padding = typeof padding === 'function' ? padding(Object.assign({}, state.rects, {
  3451. placement: state.placement
  3452. })) : padding;
  3453. return mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements));
  3454. };
  3455. function arrow(_ref) {
  3456. var _state$modifiersData$;
  3457. var state = _ref.state,
  3458. name = _ref.name,
  3459. options = _ref.options;
  3460. var arrowElement = state.elements.arrow;
  3461. var popperOffsets = state.modifiersData.popperOffsets;
  3462. var basePlacement = getBasePlacement(state.placement);
  3463. var axis = getMainAxisFromPlacement(basePlacement);
  3464. var isVertical = [left, right].indexOf(basePlacement) >= 0;
  3465. var len = isVertical ? 'height' : 'width';
  3466. if (!arrowElement || !popperOffsets) {
  3467. return;
  3468. }
  3469. var paddingObject = toPaddingObject(options.padding, state);
  3470. var arrowRect = getLayoutRect(arrowElement);
  3471. var minProp = axis === 'y' ? top : left;
  3472. var maxProp = axis === 'y' ? bottom : right;
  3473. var endDiff = state.rects.reference[len] + state.rects.reference[axis] - popperOffsets[axis] - state.rects.popper[len];
  3474. var startDiff = popperOffsets[axis] - state.rects.reference[axis];
  3475. var arrowOffsetParent = getOffsetParent(arrowElement);
  3476. var clientSize = arrowOffsetParent ? axis === 'y' ? arrowOffsetParent.clientHeight || 0 : arrowOffsetParent.clientWidth || 0 : 0;
  3477. var centerToReference = endDiff / 2 - startDiff / 2;
  3478. var min = paddingObject[minProp];
  3479. var max = clientSize - arrowRect[len] - paddingObject[maxProp];
  3480. var center = clientSize / 2 - arrowRect[len] / 2 + centerToReference;
  3481. var offset = within(min, center, max);
  3482. var axisProp = axis;
  3483. state.modifiersData[name] = (_state$modifiersData$ = {}, _state$modifiersData$[axisProp] = offset, _state$modifiersData$.centerOffset = offset - center, _state$modifiersData$);
  3484. }
  3485. function effect$1(_ref2) {
  3486. var state = _ref2.state,
  3487. options = _ref2.options;
  3488. var _options$element = options.element,
  3489. arrowElement = _options$element === void 0 ? '[data-popper-arrow]' : _options$element;
  3490. if (arrowElement == null) {
  3491. return;
  3492. }
  3493. if (typeof arrowElement === 'string') {
  3494. arrowElement = state.elements.popper.querySelector(arrowElement);
  3495. if (!arrowElement) {
  3496. return;
  3497. }
  3498. }
  3499. if (!contains(state.elements.popper, arrowElement)) {
  3500. return;
  3501. }
  3502. state.elements.arrow = arrowElement;
  3503. }
  3504. var arrow$1 = {
  3505. name: 'arrow',
  3506. enabled: true,
  3507. phase: 'main',
  3508. fn: arrow,
  3509. effect: effect$1,
  3510. requires: ['popperOffsets'],
  3511. requiresIfExists: ['preventOverflow']
  3512. };
  3513. function getVariation(placement) {
  3514. return placement.split('-')[1];
  3515. }
  3516. var unsetSides = {
  3517. top: 'auto',
  3518. right: 'auto',
  3519. bottom: 'auto',
  3520. left: 'auto'
  3521. };
  3522. function roundOffsetsByDPR(_ref) {
  3523. var x = _ref.x,
  3524. y = _ref.y;
  3525. var win = window;
  3526. var dpr = win.devicePixelRatio || 1;
  3527. return {
  3528. x: round(x * dpr) / dpr || 0,
  3529. y: round(y * dpr) / dpr || 0
  3530. };
  3531. }
  3532. function mapToStyles(_ref2) {
  3533. var _Object$assign2;
  3534. var popper = _ref2.popper,
  3535. popperRect = _ref2.popperRect,
  3536. placement = _ref2.placement,
  3537. variation = _ref2.variation,
  3538. offsets = _ref2.offsets,
  3539. position = _ref2.position,
  3540. gpuAcceleration = _ref2.gpuAcceleration,
  3541. adaptive = _ref2.adaptive,
  3542. roundOffsets = _ref2.roundOffsets,
  3543. isFixed = _ref2.isFixed;
  3544. var _offsets$x = offsets.x,
  3545. x = _offsets$x === void 0 ? 0 : _offsets$x,
  3546. _offsets$y = offsets.y,
  3547. y = _offsets$y === void 0 ? 0 : _offsets$y;
  3548. var _ref3 = typeof roundOffsets === 'function' ? roundOffsets({
  3549. x: x,
  3550. y: y
  3551. }) : {
  3552. x: x,
  3553. y: y
  3554. };
  3555. x = _ref3.x;
  3556. y = _ref3.y;
  3557. var hasX = offsets.hasOwnProperty('x');
  3558. var hasY = offsets.hasOwnProperty('y');
  3559. var sideX = left;
  3560. var sideY = top;
  3561. var win = window;
  3562. if (adaptive) {
  3563. var offsetParent = getOffsetParent(popper);
  3564. var heightProp = 'clientHeight';
  3565. var widthProp = 'clientWidth';
  3566. if (offsetParent === getWindow(popper)) {
  3567. offsetParent = getDocumentElement(popper);
  3568. if (getComputedStyle$1(offsetParent).position !== 'static' && position === 'absolute') {
  3569. heightProp = 'scrollHeight';
  3570. widthProp = 'scrollWidth';
  3571. }
  3572. }
  3573. offsetParent = offsetParent;
  3574. if (placement === top || (placement === left || placement === right) && variation === end) {
  3575. sideY = bottom;
  3576. var offsetY = isFixed && offsetParent === win && win.visualViewport ? win.visualViewport.height :
  3577. offsetParent[heightProp];
  3578. y -= offsetY - popperRect.height;
  3579. y *= gpuAcceleration ? 1 : -1;
  3580. }
  3581. if (placement === left || (placement === top || placement === bottom) && variation === end) {
  3582. sideX = right;
  3583. var offsetX = isFixed && offsetParent === win && win.visualViewport ? win.visualViewport.width :
  3584. offsetParent[widthProp];
  3585. x -= offsetX - popperRect.width;
  3586. x *= gpuAcceleration ? 1 : -1;
  3587. }
  3588. }
  3589. var commonStyles = Object.assign({
  3590. position: position
  3591. }, adaptive && unsetSides);
  3592. var _ref4 = roundOffsets === true ? roundOffsetsByDPR({
  3593. x: x,
  3594. y: y
  3595. }) : {
  3596. x: x,
  3597. y: y
  3598. };
  3599. x = _ref4.x;
  3600. y = _ref4.y;
  3601. if (gpuAcceleration) {
  3602. var _Object$assign;
  3603. 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));
  3604. }
  3605. return Object.assign({}, commonStyles, (_Object$assign2 = {}, _Object$assign2[sideY] = hasY ? y + "px" : '', _Object$assign2[sideX] = hasX ? x + "px" : '', _Object$assign2.transform = '', _Object$assign2));
  3606. }
  3607. function computeStyles(_ref5) {
  3608. var state = _ref5.state,
  3609. options = _ref5.options;
  3610. var _options$gpuAccelerat = options.gpuAcceleration,
  3611. gpuAcceleration = _options$gpuAccelerat === void 0 ? true : _options$gpuAccelerat,
  3612. _options$adaptive = options.adaptive,
  3613. adaptive = _options$adaptive === void 0 ? true : _options$adaptive,
  3614. _options$roundOffsets = options.roundOffsets,
  3615. roundOffsets = _options$roundOffsets === void 0 ? true : _options$roundOffsets;
  3616. var commonStyles = {
  3617. placement: getBasePlacement(state.placement),
  3618. variation: getVariation(state.placement),
  3619. popper: state.elements.popper,
  3620. popperRect: state.rects.popper,
  3621. gpuAcceleration: gpuAcceleration,
  3622. isFixed: state.options.strategy === 'fixed'
  3623. };
  3624. if (state.modifiersData.popperOffsets != null) {
  3625. state.styles.popper = Object.assign({}, state.styles.popper, mapToStyles(Object.assign({}, commonStyles, {
  3626. offsets: state.modifiersData.popperOffsets,
  3627. position: state.options.strategy,
  3628. adaptive: adaptive,
  3629. roundOffsets: roundOffsets
  3630. })));
  3631. }
  3632. if (state.modifiersData.arrow != null) {
  3633. state.styles.arrow = Object.assign({}, state.styles.arrow, mapToStyles(Object.assign({}, commonStyles, {
  3634. offsets: state.modifiersData.arrow,
  3635. position: 'absolute',
  3636. adaptive: false,
  3637. roundOffsets: roundOffsets
  3638. })));
  3639. }
  3640. state.attributes.popper = Object.assign({}, state.attributes.popper, {
  3641. 'data-popper-placement': state.placement
  3642. });
  3643. }
  3644. var computeStyles$1 = {
  3645. name: 'computeStyles',
  3646. enabled: true,
  3647. phase: 'beforeWrite',
  3648. fn: computeStyles,
  3649. data: {}
  3650. };
  3651. var passive = {
  3652. passive: true
  3653. };
  3654. function effect(_ref) {
  3655. var state = _ref.state,
  3656. instance = _ref.instance,
  3657. options = _ref.options;
  3658. var _options$scroll = options.scroll,
  3659. scroll = _options$scroll === void 0 ? true : _options$scroll,
  3660. _options$resize = options.resize,
  3661. resize = _options$resize === void 0 ? true : _options$resize;
  3662. var window = getWindow(state.elements.popper);
  3663. var scrollParents = [].concat(state.scrollParents.reference, state.scrollParents.popper);
  3664. if (scroll) {
  3665. scrollParents.forEach(function (scrollParent) {
  3666. scrollParent.addEventListener('scroll', instance.update, passive);
  3667. });
  3668. }
  3669. if (resize) {
  3670. window.addEventListener('resize', instance.update, passive);
  3671. }
  3672. return function () {
  3673. if (scroll) {
  3674. scrollParents.forEach(function (scrollParent) {
  3675. scrollParent.removeEventListener('scroll', instance.update, passive);
  3676. });
  3677. }
  3678. if (resize) {
  3679. window.removeEventListener('resize', instance.update, passive);
  3680. }
  3681. };
  3682. }
  3683. var eventListeners = {
  3684. name: 'eventListeners',
  3685. enabled: true,
  3686. phase: 'write',
  3687. fn: function fn() {},
  3688. effect: effect,
  3689. data: {}
  3690. };
  3691. var hash$1 = {
  3692. left: 'right',
  3693. right: 'left',
  3694. bottom: 'top',
  3695. top: 'bottom'
  3696. };
  3697. function getOppositePlacement(placement) {
  3698. return placement.replace(/left|right|bottom|top/g, function (matched) {
  3699. return hash$1[matched];
  3700. });
  3701. }
  3702. var hash = {
  3703. start: 'end',
  3704. end: 'start'
  3705. };
  3706. function getOppositeVariationPlacement(placement) {
  3707. return placement.replace(/start|end/g, function (matched) {
  3708. return hash[matched];
  3709. });
  3710. }
  3711. function getWindowScroll(node) {
  3712. var win = getWindow(node);
  3713. var scrollLeft = win.pageXOffset;
  3714. var scrollTop = win.pageYOffset;
  3715. return {
  3716. scrollLeft: scrollLeft,
  3717. scrollTop: scrollTop
  3718. };
  3719. }
  3720. function getWindowScrollBarX(element) {
  3721. return getBoundingClientRect(getDocumentElement(element)).left + getWindowScroll(element).scrollLeft;
  3722. }
  3723. function getViewportRect(element, strategy) {
  3724. var win = getWindow(element);
  3725. var html = getDocumentElement(element);
  3726. var visualViewport = win.visualViewport;
  3727. var width = html.clientWidth;
  3728. var height = html.clientHeight;
  3729. var x = 0;
  3730. var y = 0;
  3731. if (visualViewport) {
  3732. width = visualViewport.width;
  3733. height = visualViewport.height;
  3734. var layoutViewport = isLayoutViewport();
  3735. if (layoutViewport || !layoutViewport && strategy === 'fixed') {
  3736. x = visualViewport.offsetLeft;
  3737. y = visualViewport.offsetTop;
  3738. }
  3739. }
  3740. return {
  3741. width: width,
  3742. height: height,
  3743. x: x + getWindowScrollBarX(element),
  3744. y: y
  3745. };
  3746. }
  3747. function getDocumentRect(element) {
  3748. var _element$ownerDocumen;
  3749. var html = getDocumentElement(element);
  3750. var winScroll = getWindowScroll(element);
  3751. var body = (_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body;
  3752. var width = max(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0);
  3753. var height = max(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0);
  3754. var x = -winScroll.scrollLeft + getWindowScrollBarX(element);
  3755. var y = -winScroll.scrollTop;
  3756. if (getComputedStyle$1(body || html).direction === 'rtl') {
  3757. x += max(html.clientWidth, body ? body.clientWidth : 0) - width;
  3758. }
  3759. return {
  3760. width: width,
  3761. height: height,
  3762. x: x,
  3763. y: y
  3764. };
  3765. }
  3766. function isScrollParent(element) {
  3767. var _getComputedStyle = getComputedStyle$1(element),
  3768. overflow = _getComputedStyle.overflow,
  3769. overflowX = _getComputedStyle.overflowX,
  3770. overflowY = _getComputedStyle.overflowY;
  3771. return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);
  3772. }
  3773. function getScrollParent(node) {
  3774. if (['html', 'body', '#document'].indexOf(getNodeName(node)) >= 0) {
  3775. return node.ownerDocument.body;
  3776. }
  3777. if (isHTMLElement(node) && isScrollParent(node)) {
  3778. return node;
  3779. }
  3780. return getScrollParent(getParentNode(node));
  3781. }
  3782. function listScrollParents(element, list) {
  3783. var _element$ownerDocumen;
  3784. if (list === void 0) {
  3785. list = [];
  3786. }
  3787. var scrollParent = getScrollParent(element);
  3788. var isBody = scrollParent === ((_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body);
  3789. var win = getWindow(scrollParent);
  3790. var target = isBody ? [win].concat(win.visualViewport || [], isScrollParent(scrollParent) ? scrollParent : []) : scrollParent;
  3791. var updatedList = list.concat(target);
  3792. return isBody ? updatedList :
  3793. updatedList.concat(listScrollParents(getParentNode(target)));
  3794. }
  3795. function rectToClientRect(rect) {
  3796. return Object.assign({}, rect, {
  3797. left: rect.x,
  3798. top: rect.y,
  3799. right: rect.x + rect.width,
  3800. bottom: rect.y + rect.height
  3801. });
  3802. }
  3803. function getInnerBoundingClientRect(element, strategy) {
  3804. var rect = getBoundingClientRect(element, false, strategy === 'fixed');
  3805. rect.top = rect.top + element.clientTop;
  3806. rect.left = rect.left + element.clientLeft;
  3807. rect.bottom = rect.top + element.clientHeight;
  3808. rect.right = rect.left + element.clientWidth;
  3809. rect.width = element.clientWidth;
  3810. rect.height = element.clientHeight;
  3811. rect.x = rect.left;
  3812. rect.y = rect.top;
  3813. return rect;
  3814. }
  3815. function getClientRectFromMixedType(element, clippingParent, strategy) {
  3816. return clippingParent === viewport ? rectToClientRect(getViewportRect(element, strategy)) : isElement$1(clippingParent) ? getInnerBoundingClientRect(clippingParent, strategy) : rectToClientRect(getDocumentRect(getDocumentElement(element)));
  3817. }
  3818. function getClippingParents(element) {
  3819. var clippingParents = listScrollParents(getParentNode(element));
  3820. var canEscapeClipping = ['absolute', 'fixed'].indexOf(getComputedStyle$1(element).position) >= 0;
  3821. var clipperElement = canEscapeClipping && isHTMLElement(element) ? getOffsetParent(element) : element;
  3822. if (!isElement$1(clipperElement)) {
  3823. return [];
  3824. }
  3825. return clippingParents.filter(function (clippingParent) {
  3826. return isElement$1(clippingParent) && contains(clippingParent, clipperElement) && getNodeName(clippingParent) !== 'body';
  3827. });
  3828. }
  3829. function getClippingRect(element, boundary, rootBoundary, strategy) {
  3830. var mainClippingParents = boundary === 'clippingParents' ? getClippingParents(element) : [].concat(boundary);
  3831. var clippingParents = [].concat(mainClippingParents, [rootBoundary]);
  3832. var firstClippingParent = clippingParents[0];
  3833. var clippingRect = clippingParents.reduce(function (accRect, clippingParent) {
  3834. var rect = getClientRectFromMixedType(element, clippingParent, strategy);
  3835. accRect.top = max(rect.top, accRect.top);
  3836. accRect.right = min(rect.right, accRect.right);
  3837. accRect.bottom = min(rect.bottom, accRect.bottom);
  3838. accRect.left = max(rect.left, accRect.left);
  3839. return accRect;
  3840. }, getClientRectFromMixedType(element, firstClippingParent, strategy));
  3841. clippingRect.width = clippingRect.right - clippingRect.left;
  3842. clippingRect.height = clippingRect.bottom - clippingRect.top;
  3843. clippingRect.x = clippingRect.left;
  3844. clippingRect.y = clippingRect.top;
  3845. return clippingRect;
  3846. }
  3847. function computeOffsets(_ref) {
  3848. var reference = _ref.reference,
  3849. element = _ref.element,
  3850. placement = _ref.placement;
  3851. var basePlacement = placement ? getBasePlacement(placement) : null;
  3852. var variation = placement ? getVariation(placement) : null;
  3853. var commonX = reference.x + reference.width / 2 - element.width / 2;
  3854. var commonY = reference.y + reference.height / 2 - element.height / 2;
  3855. var offsets;
  3856. switch (basePlacement) {
  3857. case top:
  3858. offsets = {
  3859. x: commonX,
  3860. y: reference.y - element.height
  3861. };
  3862. break;
  3863. case bottom:
  3864. offsets = {
  3865. x: commonX,
  3866. y: reference.y + reference.height
  3867. };
  3868. break;
  3869. case right:
  3870. offsets = {
  3871. x: reference.x + reference.width,
  3872. y: commonY
  3873. };
  3874. break;
  3875. case left:
  3876. offsets = {
  3877. x: reference.x - element.width,
  3878. y: commonY
  3879. };
  3880. break;
  3881. default:
  3882. offsets = {
  3883. x: reference.x,
  3884. y: reference.y
  3885. };
  3886. }
  3887. var mainAxis = basePlacement ? getMainAxisFromPlacement(basePlacement) : null;
  3888. if (mainAxis != null) {
  3889. var len = mainAxis === 'y' ? 'height' : 'width';
  3890. switch (variation) {
  3891. case start:
  3892. offsets[mainAxis] = offsets[mainAxis] - (reference[len] / 2 - element[len] / 2);
  3893. break;
  3894. case end:
  3895. offsets[mainAxis] = offsets[mainAxis] + (reference[len] / 2 - element[len] / 2);
  3896. break;
  3897. }
  3898. }
  3899. return offsets;
  3900. }
  3901. function detectOverflow(state, options) {
  3902. if (options === void 0) {
  3903. options = {};
  3904. }
  3905. var _options = options,
  3906. _options$placement = _options.placement,
  3907. placement = _options$placement === void 0 ? state.placement : _options$placement,
  3908. _options$strategy = _options.strategy,
  3909. strategy = _options$strategy === void 0 ? state.strategy : _options$strategy,
  3910. _options$boundary = _options.boundary,
  3911. boundary = _options$boundary === void 0 ? clippingParents : _options$boundary,
  3912. _options$rootBoundary = _options.rootBoundary,
  3913. rootBoundary = _options$rootBoundary === void 0 ? viewport : _options$rootBoundary,
  3914. _options$elementConte = _options.elementContext,
  3915. elementContext = _options$elementConte === void 0 ? popper : _options$elementConte,
  3916. _options$altBoundary = _options.altBoundary,
  3917. altBoundary = _options$altBoundary === void 0 ? false : _options$altBoundary,
  3918. _options$padding = _options.padding,
  3919. padding = _options$padding === void 0 ? 0 : _options$padding;
  3920. var paddingObject = mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements));
  3921. var altContext = elementContext === popper ? reference : popper;
  3922. var popperRect = state.rects.popper;
  3923. var element = state.elements[altBoundary ? altContext : elementContext];
  3924. var clippingClientRect = getClippingRect(isElement$1(element) ? element : element.contextElement || getDocumentElement(state.elements.popper), boundary, rootBoundary, strategy);
  3925. var referenceClientRect = getBoundingClientRect(state.elements.reference);
  3926. var popperOffsets = computeOffsets({
  3927. reference: referenceClientRect,
  3928. element: popperRect,
  3929. strategy: 'absolute',
  3930. placement: placement
  3931. });
  3932. var popperClientRect = rectToClientRect(Object.assign({}, popperRect, popperOffsets));
  3933. var elementClientRect = elementContext === popper ? popperClientRect : referenceClientRect;
  3934. var overflowOffsets = {
  3935. top: clippingClientRect.top - elementClientRect.top + paddingObject.top,
  3936. bottom: elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom,
  3937. left: clippingClientRect.left - elementClientRect.left + paddingObject.left,
  3938. right: elementClientRect.right - clippingClientRect.right + paddingObject.right
  3939. };
  3940. var offsetData = state.modifiersData.offset;
  3941. if (elementContext === popper && offsetData) {
  3942. var offset = offsetData[placement];
  3943. Object.keys(overflowOffsets).forEach(function (key) {
  3944. var multiply = [right, bottom].indexOf(key) >= 0 ? 1 : -1;
  3945. var axis = [top, bottom].indexOf(key) >= 0 ? 'y' : 'x';
  3946. overflowOffsets[key] += offset[axis] * multiply;
  3947. });
  3948. }
  3949. return overflowOffsets;
  3950. }
  3951. function computeAutoPlacement(state, options) {
  3952. if (options === void 0) {
  3953. options = {};
  3954. }
  3955. var _options = options,
  3956. placement = _options.placement,
  3957. boundary = _options.boundary,
  3958. rootBoundary = _options.rootBoundary,
  3959. padding = _options.padding,
  3960. flipVariations = _options.flipVariations,
  3961. _options$allowedAutoP = _options.allowedAutoPlacements,
  3962. allowedAutoPlacements = _options$allowedAutoP === void 0 ? placements : _options$allowedAutoP;
  3963. var variation = getVariation(placement);
  3964. var placements$1 = variation ? flipVariations ? variationPlacements : variationPlacements.filter(function (placement) {
  3965. return getVariation(placement) === variation;
  3966. }) : basePlacements;
  3967. var allowedPlacements = placements$1.filter(function (placement) {
  3968. return allowedAutoPlacements.indexOf(placement) >= 0;
  3969. });
  3970. if (allowedPlacements.length === 0) {
  3971. allowedPlacements = placements$1;
  3972. }
  3973. var overflows = allowedPlacements.reduce(function (acc, placement) {
  3974. acc[placement] = detectOverflow(state, {
  3975. placement: placement,
  3976. boundary: boundary,
  3977. rootBoundary: rootBoundary,
  3978. padding: padding
  3979. })[getBasePlacement(placement)];
  3980. return acc;
  3981. }, {});
  3982. return Object.keys(overflows).sort(function (a, b) {
  3983. return overflows[a] - overflows[b];
  3984. });
  3985. }
  3986. function getExpandedFallbackPlacements(placement) {
  3987. if (getBasePlacement(placement) === auto) {
  3988. return [];
  3989. }
  3990. var oppositePlacement = getOppositePlacement(placement);
  3991. return [getOppositeVariationPlacement(placement), oppositePlacement, getOppositeVariationPlacement(oppositePlacement)];
  3992. }
  3993. function flip(_ref) {
  3994. var state = _ref.state,
  3995. options = _ref.options,
  3996. name = _ref.name;
  3997. if (state.modifiersData[name]._skip) {
  3998. return;
  3999. }
  4000. var _options$mainAxis = options.mainAxis,
  4001. checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis,
  4002. _options$altAxis = options.altAxis,
  4003. checkAltAxis = _options$altAxis === void 0 ? true : _options$altAxis,
  4004. specifiedFallbackPlacements = options.fallbackPlacements,
  4005. padding = options.padding,
  4006. boundary = options.boundary,
  4007. rootBoundary = options.rootBoundary,
  4008. altBoundary = options.altBoundary,
  4009. _options$flipVariatio = options.flipVariations,
  4010. flipVariations = _options$flipVariatio === void 0 ? true : _options$flipVariatio,
  4011. allowedAutoPlacements = options.allowedAutoPlacements;
  4012. var preferredPlacement = state.options.placement;
  4013. var basePlacement = getBasePlacement(preferredPlacement);
  4014. var isBasePlacement = basePlacement === preferredPlacement;
  4015. var fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipVariations ? [getOppositePlacement(preferredPlacement)] : getExpandedFallbackPlacements(preferredPlacement));
  4016. var placements = [preferredPlacement].concat(fallbackPlacements).reduce(function (acc, placement) {
  4017. return acc.concat(getBasePlacement(placement) === auto ? computeAutoPlacement(state, {
  4018. placement: placement,
  4019. boundary: boundary,
  4020. rootBoundary: rootBoundary,
  4021. padding: padding,
  4022. flipVariations: flipVariations,
  4023. allowedAutoPlacements: allowedAutoPlacements
  4024. }) : placement);
  4025. }, []);
  4026. var referenceRect = state.rects.reference;
  4027. var popperRect = state.rects.popper;
  4028. var checksMap = new Map();
  4029. var makeFallbackChecks = true;
  4030. var firstFittingPlacement = placements[0];
  4031. for (var i = 0; i < placements.length; i++) {
  4032. var placement = placements[i];
  4033. var _basePlacement = getBasePlacement(placement);
  4034. var isStartVariation = getVariation(placement) === start;
  4035. var isVertical = [top, bottom].indexOf(_basePlacement) >= 0;
  4036. var len = isVertical ? 'width' : 'height';
  4037. var overflow = detectOverflow(state, {
  4038. placement: placement,
  4039. boundary: boundary,
  4040. rootBoundary: rootBoundary,
  4041. altBoundary: altBoundary,
  4042. padding: padding
  4043. });
  4044. var mainVariationSide = isVertical ? isStartVariation ? right : left : isStartVariation ? bottom : top;
  4045. if (referenceRect[len] > popperRect[len]) {
  4046. mainVariationSide = getOppositePlacement(mainVariationSide);
  4047. }
  4048. var altVariationSide = getOppositePlacement(mainVariationSide);
  4049. var checks = [];
  4050. if (checkMainAxis) {
  4051. checks.push(overflow[_basePlacement] <= 0);
  4052. }
  4053. if (checkAltAxis) {
  4054. checks.push(overflow[mainVariationSide] <= 0, overflow[altVariationSide] <= 0);
  4055. }
  4056. if (checks.every(function (check) {
  4057. return check;
  4058. })) {
  4059. firstFittingPlacement = placement;
  4060. makeFallbackChecks = false;
  4061. break;
  4062. }
  4063. checksMap.set(placement, checks);
  4064. }
  4065. if (makeFallbackChecks) {
  4066. var numberOfChecks = flipVariations ? 3 : 1;
  4067. var _loop = function _loop(_i) {
  4068. var fittingPlacement = placements.find(function (placement) {
  4069. var checks = checksMap.get(placement);
  4070. if (checks) {
  4071. return checks.slice(0, _i).every(function (check) {
  4072. return check;
  4073. });
  4074. }
  4075. });
  4076. if (fittingPlacement) {
  4077. firstFittingPlacement = fittingPlacement;
  4078. return "break";
  4079. }
  4080. };
  4081. for (var _i = numberOfChecks; _i > 0; _i--) {
  4082. var _ret = _loop(_i);
  4083. if (_ret === "break") break;
  4084. }
  4085. }
  4086. if (state.placement !== firstFittingPlacement) {
  4087. state.modifiersData[name]._skip = true;
  4088. state.placement = firstFittingPlacement;
  4089. state.reset = true;
  4090. }
  4091. }
  4092. var flip$1 = {
  4093. name: 'flip',
  4094. enabled: true,
  4095. phase: 'main',
  4096. fn: flip,
  4097. requiresIfExists: ['offset'],
  4098. data: {
  4099. _skip: false
  4100. }
  4101. };
  4102. function getSideOffsets(overflow, rect, preventedOffsets) {
  4103. if (preventedOffsets === void 0) {
  4104. preventedOffsets = {
  4105. x: 0,
  4106. y: 0
  4107. };
  4108. }
  4109. return {
  4110. top: overflow.top - rect.height - preventedOffsets.y,
  4111. right: overflow.right - rect.width + preventedOffsets.x,
  4112. bottom: overflow.bottom - rect.height + preventedOffsets.y,
  4113. left: overflow.left - rect.width - preventedOffsets.x
  4114. };
  4115. }
  4116. function isAnySideFullyClipped(overflow) {
  4117. return [top, right, bottom, left].some(function (side) {
  4118. return overflow[side] >= 0;
  4119. });
  4120. }
  4121. function hide(_ref) {
  4122. var state = _ref.state,
  4123. name = _ref.name;
  4124. var referenceRect = state.rects.reference;
  4125. var popperRect = state.rects.popper;
  4126. var preventedOffsets = state.modifiersData.preventOverflow;
  4127. var referenceOverflow = detectOverflow(state, {
  4128. elementContext: 'reference'
  4129. });
  4130. var popperAltOverflow = detectOverflow(state, {
  4131. altBoundary: true
  4132. });
  4133. var referenceClippingOffsets = getSideOffsets(referenceOverflow, referenceRect);
  4134. var popperEscapeOffsets = getSideOffsets(popperAltOverflow, popperRect, preventedOffsets);
  4135. var isReferenceHidden = isAnySideFullyClipped(referenceClippingOffsets);
  4136. var hasPopperEscaped = isAnySideFullyClipped(popperEscapeOffsets);
  4137. state.modifiersData[name] = {
  4138. referenceClippingOffsets: referenceClippingOffsets,
  4139. popperEscapeOffsets: popperEscapeOffsets,
  4140. isReferenceHidden: isReferenceHidden,
  4141. hasPopperEscaped: hasPopperEscaped
  4142. };
  4143. state.attributes.popper = Object.assign({}, state.attributes.popper, {
  4144. 'data-popper-reference-hidden': isReferenceHidden,
  4145. 'data-popper-escaped': hasPopperEscaped
  4146. });
  4147. }
  4148. var hide$1 = {
  4149. name: 'hide',
  4150. enabled: true,
  4151. phase: 'main',
  4152. requiresIfExists: ['preventOverflow'],
  4153. fn: hide
  4154. };
  4155. function distanceAndSkiddingToXY(placement, rects, offset) {
  4156. var basePlacement = getBasePlacement(placement);
  4157. var invertDistance = [left, top].indexOf(basePlacement) >= 0 ? -1 : 1;
  4158. var _ref = typeof offset === 'function' ? offset(Object.assign({}, rects, {
  4159. placement: placement
  4160. })) : offset,
  4161. skidding = _ref[0],
  4162. distance = _ref[1];
  4163. skidding = skidding || 0;
  4164. distance = (distance || 0) * invertDistance;
  4165. return [left, right].indexOf(basePlacement) >= 0 ? {
  4166. x: distance,
  4167. y: skidding
  4168. } : {
  4169. x: skidding,
  4170. y: distance
  4171. };
  4172. }
  4173. function offset(_ref2) {
  4174. var state = _ref2.state,
  4175. options = _ref2.options,
  4176. name = _ref2.name;
  4177. var _options$offset = options.offset,
  4178. offset = _options$offset === void 0 ? [0, 0] : _options$offset;
  4179. var data = placements.reduce(function (acc, placement) {
  4180. acc[placement] = distanceAndSkiddingToXY(placement, state.rects, offset);
  4181. return acc;
  4182. }, {});
  4183. var _data$state$placement = data[state.placement],
  4184. x = _data$state$placement.x,
  4185. y = _data$state$placement.y;
  4186. if (state.modifiersData.popperOffsets != null) {
  4187. state.modifiersData.popperOffsets.x += x;
  4188. state.modifiersData.popperOffsets.y += y;
  4189. }
  4190. state.modifiersData[name] = data;
  4191. }
  4192. var offset$1 = {
  4193. name: 'offset',
  4194. enabled: true,
  4195. phase: 'main',
  4196. requires: ['popperOffsets'],
  4197. fn: offset
  4198. };
  4199. function popperOffsets(_ref) {
  4200. var state = _ref.state,
  4201. name = _ref.name;
  4202. state.modifiersData[name] = computeOffsets({
  4203. reference: state.rects.reference,
  4204. element: state.rects.popper,
  4205. strategy: 'absolute',
  4206. placement: state.placement
  4207. });
  4208. }
  4209. var popperOffsets$1 = {
  4210. name: 'popperOffsets',
  4211. enabled: true,
  4212. phase: 'read',
  4213. fn: popperOffsets,
  4214. data: {}
  4215. };
  4216. function getAltAxis(axis) {
  4217. return axis === 'x' ? 'y' : 'x';
  4218. }
  4219. function preventOverflow(_ref) {
  4220. var state = _ref.state,
  4221. options = _ref.options,
  4222. name = _ref.name;
  4223. var _options$mainAxis = options.mainAxis,
  4224. checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis,
  4225. _options$altAxis = options.altAxis,
  4226. checkAltAxis = _options$altAxis === void 0 ? false : _options$altAxis,
  4227. boundary = options.boundary,
  4228. rootBoundary = options.rootBoundary,
  4229. altBoundary = options.altBoundary,
  4230. padding = options.padding,
  4231. _options$tether = options.tether,
  4232. tether = _options$tether === void 0 ? true : _options$tether,
  4233. _options$tetherOffset = options.tetherOffset,
  4234. tetherOffset = _options$tetherOffset === void 0 ? 0 : _options$tetherOffset;
  4235. var overflow = detectOverflow(state, {
  4236. boundary: boundary,
  4237. rootBoundary: rootBoundary,
  4238. padding: padding,
  4239. altBoundary: altBoundary
  4240. });
  4241. var basePlacement = getBasePlacement(state.placement);
  4242. var variation = getVariation(state.placement);
  4243. var isBasePlacement = !variation;
  4244. var mainAxis = getMainAxisFromPlacement(basePlacement);
  4245. var altAxis = getAltAxis(mainAxis);
  4246. var popperOffsets = state.modifiersData.popperOffsets;
  4247. var referenceRect = state.rects.reference;
  4248. var popperRect = state.rects.popper;
  4249. var tetherOffsetValue = typeof tetherOffset === 'function' ? tetherOffset(Object.assign({}, state.rects, {
  4250. placement: state.placement
  4251. })) : tetherOffset;
  4252. var normalizedTetherOffsetValue = typeof tetherOffsetValue === 'number' ? {
  4253. mainAxis: tetherOffsetValue,
  4254. altAxis: tetherOffsetValue
  4255. } : Object.assign({
  4256. mainAxis: 0,
  4257. altAxis: 0
  4258. }, tetherOffsetValue);
  4259. var offsetModifierState = state.modifiersData.offset ? state.modifiersData.offset[state.placement] : null;
  4260. var data = {
  4261. x: 0,
  4262. y: 0
  4263. };
  4264. if (!popperOffsets) {
  4265. return;
  4266. }
  4267. if (checkMainAxis) {
  4268. var _offsetModifierState$;
  4269. var mainSide = mainAxis === 'y' ? top : left;
  4270. var altSide = mainAxis === 'y' ? bottom : right;
  4271. var len = mainAxis === 'y' ? 'height' : 'width';
  4272. var offset = popperOffsets[mainAxis];
  4273. var min$1 = offset + overflow[mainSide];
  4274. var max$1 = offset - overflow[altSide];
  4275. var additive = tether ? -popperRect[len] / 2 : 0;
  4276. var minLen = variation === start ? referenceRect[len] : popperRect[len];
  4277. var maxLen = variation === start ? -popperRect[len] : -referenceRect[len];
  4278. var arrowElement = state.elements.arrow;
  4279. var arrowRect = tether && arrowElement ? getLayoutRect(arrowElement) : {
  4280. width: 0,
  4281. height: 0
  4282. };
  4283. var arrowPaddingObject = state.modifiersData['arrow#persistent'] ? state.modifiersData['arrow#persistent'].padding : getFreshSideObject();
  4284. var arrowPaddingMin = arrowPaddingObject[mainSide];
  4285. var arrowPaddingMax = arrowPaddingObject[altSide];
  4286. var arrowLen = within(0, referenceRect[len], arrowRect[len]);
  4287. var minOffset = isBasePlacement ? referenceRect[len] / 2 - additive - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis : minLen - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis;
  4288. var maxOffset = isBasePlacement ? -referenceRect[len] / 2 + additive + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis : maxLen + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis;
  4289. var arrowOffsetParent = state.elements.arrow && getOffsetParent(state.elements.arrow);
  4290. var clientOffset = arrowOffsetParent ? mainAxis === 'y' ? arrowOffsetParent.clientTop || 0 : arrowOffsetParent.clientLeft || 0 : 0;
  4291. var offsetModifierValue = (_offsetModifierState$ = offsetModifierState == null ? void 0 : offsetModifierState[mainAxis]) != null ? _offsetModifierState$ : 0;
  4292. var tetherMin = offset + minOffset - offsetModifierValue - clientOffset;
  4293. var tetherMax = offset + maxOffset - offsetModifierValue;
  4294. var preventedOffset = within(tether ? min(min$1, tetherMin) : min$1, offset, tether ? max(max$1, tetherMax) : max$1);
  4295. popperOffsets[mainAxis] = preventedOffset;
  4296. data[mainAxis] = preventedOffset - offset;
  4297. }
  4298. if (checkAltAxis) {
  4299. var _offsetModifierState$2;
  4300. var _mainSide = mainAxis === 'x' ? top : left;
  4301. var _altSide = mainAxis === 'x' ? bottom : right;
  4302. var _offset = popperOffsets[altAxis];
  4303. var _len = altAxis === 'y' ? 'height' : 'width';
  4304. var _min = _offset + overflow[_mainSide];
  4305. var _max = _offset - overflow[_altSide];
  4306. var isOriginSide = [top, left].indexOf(basePlacement) !== -1;
  4307. var _offsetModifierValue = (_offsetModifierState$2 = offsetModifierState == null ? void 0 : offsetModifierState[altAxis]) != null ? _offsetModifierState$2 : 0;
  4308. var _tetherMin = isOriginSide ? _min : _offset - referenceRect[_len] - popperRect[_len] - _offsetModifierValue + normalizedTetherOffsetValue.altAxis;
  4309. var _tetherMax = isOriginSide ? _offset + referenceRect[_len] + popperRect[_len] - _offsetModifierValue - normalizedTetherOffsetValue.altAxis : _max;
  4310. var _preventedOffset = tether && isOriginSide ? withinMaxClamp(_tetherMin, _offset, _tetherMax) : within(tether ? _tetherMin : _min, _offset, tether ? _tetherMax : _max);
  4311. popperOffsets[altAxis] = _preventedOffset;
  4312. data[altAxis] = _preventedOffset - _offset;
  4313. }
  4314. state.modifiersData[name] = data;
  4315. }
  4316. var preventOverflow$1 = {
  4317. name: 'preventOverflow',
  4318. enabled: true,
  4319. phase: 'main',
  4320. fn: preventOverflow,
  4321. requiresIfExists: ['offset']
  4322. };
  4323. function getHTMLElementScroll(element) {
  4324. return {
  4325. scrollLeft: element.scrollLeft,
  4326. scrollTop: element.scrollTop
  4327. };
  4328. }
  4329. function getNodeScroll(node) {
  4330. if (node === getWindow(node) || !isHTMLElement(node)) {
  4331. return getWindowScroll(node);
  4332. } else {
  4333. return getHTMLElementScroll(node);
  4334. }
  4335. }
  4336. function isElementScaled(element) {
  4337. var rect = element.getBoundingClientRect();
  4338. var scaleX = round(rect.width) / element.offsetWidth || 1;
  4339. var scaleY = round(rect.height) / element.offsetHeight || 1;
  4340. return scaleX !== 1 || scaleY !== 1;
  4341. }
  4342. function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) {
  4343. if (isFixed === void 0) {
  4344. isFixed = false;
  4345. }
  4346. var isOffsetParentAnElement = isHTMLElement(offsetParent);
  4347. var offsetParentIsScaled = isHTMLElement(offsetParent) && isElementScaled(offsetParent);
  4348. var documentElement = getDocumentElement(offsetParent);
  4349. var rect = getBoundingClientRect(elementOrVirtualElement, offsetParentIsScaled, isFixed);
  4350. var scroll = {
  4351. scrollLeft: 0,
  4352. scrollTop: 0
  4353. };
  4354. var offsets = {
  4355. x: 0,
  4356. y: 0
  4357. };
  4358. if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
  4359. if (getNodeName(offsetParent) !== 'body' ||
  4360. isScrollParent(documentElement)) {
  4361. scroll = getNodeScroll(offsetParent);
  4362. }
  4363. if (isHTMLElement(offsetParent)) {
  4364. offsets = getBoundingClientRect(offsetParent, true);
  4365. offsets.x += offsetParent.clientLeft;
  4366. offsets.y += offsetParent.clientTop;
  4367. } else if (documentElement) {
  4368. offsets.x = getWindowScrollBarX(documentElement);
  4369. }
  4370. }
  4371. return {
  4372. x: rect.left + scroll.scrollLeft - offsets.x,
  4373. y: rect.top + scroll.scrollTop - offsets.y,
  4374. width: rect.width,
  4375. height: rect.height
  4376. };
  4377. }
  4378. function order(modifiers) {
  4379. var map = new Map();
  4380. var visited = new Set();
  4381. var result = [];
  4382. modifiers.forEach(function (modifier) {
  4383. map.set(modifier.name, modifier);
  4384. });
  4385. function sort(modifier) {
  4386. visited.add(modifier.name);
  4387. var requires = [].concat(modifier.requires || [], modifier.requiresIfExists || []);
  4388. requires.forEach(function (dep) {
  4389. if (!visited.has(dep)) {
  4390. var depModifier = map.get(dep);
  4391. if (depModifier) {
  4392. sort(depModifier);
  4393. }
  4394. }
  4395. });
  4396. result.push(modifier);
  4397. }
  4398. modifiers.forEach(function (modifier) {
  4399. if (!visited.has(modifier.name)) {
  4400. sort(modifier);
  4401. }
  4402. });
  4403. return result;
  4404. }
  4405. function orderModifiers(modifiers) {
  4406. var orderedModifiers = order(modifiers);
  4407. return modifierPhases.reduce(function (acc, phase) {
  4408. return acc.concat(orderedModifiers.filter(function (modifier) {
  4409. return modifier.phase === phase;
  4410. }));
  4411. }, []);
  4412. }
  4413. function debounce(fn) {
  4414. var pending;
  4415. return function () {
  4416. if (!pending) {
  4417. pending = new Promise(function (resolve) {
  4418. Promise.resolve().then(function () {
  4419. pending = undefined;
  4420. resolve(fn());
  4421. });
  4422. });
  4423. }
  4424. return pending;
  4425. };
  4426. }
  4427. function mergeByName(modifiers) {
  4428. var merged = modifiers.reduce(function (merged, current) {
  4429. var existing = merged[current.name];
  4430. merged[current.name] = existing ? Object.assign({}, existing, current, {
  4431. options: Object.assign({}, existing.options, current.options),
  4432. data: Object.assign({}, existing.data, current.data)
  4433. }) : current;
  4434. return merged;
  4435. }, {});
  4436. return Object.keys(merged).map(function (key) {
  4437. return merged[key];
  4438. });
  4439. }
  4440. var DEFAULT_OPTIONS = {
  4441. placement: 'bottom',
  4442. modifiers: [],
  4443. strategy: 'absolute'
  4444. };
  4445. function areValidElements() {
  4446. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  4447. args[_key] = arguments[_key];
  4448. }
  4449. return !args.some(function (element) {
  4450. return !(element && typeof element.getBoundingClientRect === 'function');
  4451. });
  4452. }
  4453. function popperGenerator(generatorOptions) {
  4454. if (generatorOptions === void 0) {
  4455. generatorOptions = {};
  4456. }
  4457. var _generatorOptions = generatorOptions,
  4458. _generatorOptions$def = _generatorOptions.defaultModifiers,
  4459. defaultModifiers = _generatorOptions$def === void 0 ? [] : _generatorOptions$def,
  4460. _generatorOptions$def2 = _generatorOptions.defaultOptions,
  4461. defaultOptions = _generatorOptions$def2 === void 0 ? DEFAULT_OPTIONS : _generatorOptions$def2;
  4462. return function createPopper(reference, popper, options) {
  4463. if (options === void 0) {
  4464. options = defaultOptions;
  4465. }
  4466. var state = {
  4467. placement: 'bottom',
  4468. orderedModifiers: [],
  4469. options: Object.assign({}, DEFAULT_OPTIONS, defaultOptions),
  4470. modifiersData: {},
  4471. elements: {
  4472. reference: reference,
  4473. popper: popper
  4474. },
  4475. attributes: {},
  4476. styles: {}
  4477. };
  4478. var effectCleanupFns = [];
  4479. var isDestroyed = false;
  4480. var instance = {
  4481. state: state,
  4482. setOptions: function setOptions(setOptionsAction) {
  4483. var options = typeof setOptionsAction === 'function' ? setOptionsAction(state.options) : setOptionsAction;
  4484. cleanupModifierEffects();
  4485. state.options = Object.assign({}, defaultOptions, state.options, options);
  4486. state.scrollParents = {
  4487. reference: isElement$1(reference) ? listScrollParents(reference) : reference.contextElement ? listScrollParents(reference.contextElement) : [],
  4488. popper: listScrollParents(popper)
  4489. };
  4490. var orderedModifiers = orderModifiers(mergeByName([].concat(defaultModifiers, state.options.modifiers)));
  4491. state.orderedModifiers = orderedModifiers.filter(function (m) {
  4492. return m.enabled;
  4493. });
  4494. runModifierEffects();
  4495. return instance.update();
  4496. },
  4497. forceUpdate: function forceUpdate() {
  4498. if (isDestroyed) {
  4499. return;
  4500. }
  4501. var _state$elements = state.elements,
  4502. reference = _state$elements.reference,
  4503. popper = _state$elements.popper;
  4504. if (!areValidElements(reference, popper)) {
  4505. return;
  4506. }
  4507. state.rects = {
  4508. reference: getCompositeRect(reference, getOffsetParent(popper), state.options.strategy === 'fixed'),
  4509. popper: getLayoutRect(popper)
  4510. };
  4511. state.reset = false;
  4512. state.placement = state.options.placement;
  4513. state.orderedModifiers.forEach(function (modifier) {
  4514. return state.modifiersData[modifier.name] = Object.assign({}, modifier.data);
  4515. });
  4516. for (var index = 0; index < state.orderedModifiers.length; index++) {
  4517. if (state.reset === true) {
  4518. state.reset = false;
  4519. index = -1;
  4520. continue;
  4521. }
  4522. var _state$orderedModifie = state.orderedModifiers[index],
  4523. fn = _state$orderedModifie.fn,
  4524. _state$orderedModifie2 = _state$orderedModifie.options,
  4525. _options = _state$orderedModifie2 === void 0 ? {} : _state$orderedModifie2,
  4526. name = _state$orderedModifie.name;
  4527. if (typeof fn === 'function') {
  4528. state = fn({
  4529. state: state,
  4530. options: _options,
  4531. name: name,
  4532. instance: instance
  4533. }) || state;
  4534. }
  4535. }
  4536. },
  4537. update: debounce(function () {
  4538. return new Promise(function (resolve) {
  4539. instance.forceUpdate();
  4540. resolve(state);
  4541. });
  4542. }),
  4543. destroy: function destroy() {
  4544. cleanupModifierEffects();
  4545. isDestroyed = true;
  4546. }
  4547. };
  4548. if (!areValidElements(reference, popper)) {
  4549. return instance;
  4550. }
  4551. instance.setOptions(options).then(function (state) {
  4552. if (!isDestroyed && options.onFirstUpdate) {
  4553. options.onFirstUpdate(state);
  4554. }
  4555. });
  4556. function runModifierEffects() {
  4557. state.orderedModifiers.forEach(function (_ref3) {
  4558. var name = _ref3.name,
  4559. _ref3$options = _ref3.options,
  4560. options = _ref3$options === void 0 ? {} : _ref3$options,
  4561. effect = _ref3.effect;
  4562. if (typeof effect === 'function') {
  4563. var cleanupFn = effect({
  4564. state: state,
  4565. name: name,
  4566. instance: instance,
  4567. options: options
  4568. });
  4569. var noopFn = function noopFn() {};
  4570. effectCleanupFns.push(cleanupFn || noopFn);
  4571. }
  4572. });
  4573. }
  4574. function cleanupModifierEffects() {
  4575. effectCleanupFns.forEach(function (fn) {
  4576. return fn();
  4577. });
  4578. effectCleanupFns = [];
  4579. }
  4580. return instance;
  4581. };
  4582. }
  4583. var createPopper$2 = popperGenerator();
  4584. var defaultModifiers$1 = [eventListeners, popperOffsets$1, computeStyles$1, applyStyles$1];
  4585. var createPopper$1 = popperGenerator({
  4586. defaultModifiers: defaultModifiers$1
  4587. });
  4588. var defaultModifiers = [eventListeners, popperOffsets$1, computeStyles$1, applyStyles$1, offset$1, flip$1, preventOverflow$1, arrow$1, hide$1];
  4589. var createPopper = popperGenerator({
  4590. defaultModifiers: defaultModifiers
  4591. });
  4592. var Popper = /*#__PURE__*/Object.freeze({
  4593. __proto__: null,
  4594. popperGenerator: popperGenerator,
  4595. detectOverflow: detectOverflow,
  4596. createPopperBase: createPopper$2,
  4597. createPopper: createPopper,
  4598. createPopperLite: createPopper$1,
  4599. top: top,
  4600. bottom: bottom,
  4601. right: right,
  4602. left: left,
  4603. auto: auto,
  4604. basePlacements: basePlacements,
  4605. start: start,
  4606. end: end,
  4607. clippingParents: clippingParents,
  4608. viewport: viewport,
  4609. popper: popper,
  4610. reference: reference,
  4611. variationPlacements: variationPlacements,
  4612. placements: placements,
  4613. beforeRead: beforeRead,
  4614. read: read,
  4615. afterRead: afterRead,
  4616. beforeMain: beforeMain,
  4617. main: main,
  4618. afterMain: afterMain,
  4619. beforeWrite: beforeWrite,
  4620. write: write,
  4621. afterWrite: afterWrite,
  4622. modifierPhases: modifierPhases,
  4623. applyStyles: applyStyles$1,
  4624. arrow: arrow$1,
  4625. computeStyles: computeStyles$1,
  4626. eventListeners: eventListeners,
  4627. flip: flip$1,
  4628. hide: hide$1,
  4629. offset: offset$1,
  4630. popperOffsets: popperOffsets$1,
  4631. preventOverflow: preventOverflow$1
  4632. });
  4633. /*!
  4634. * Bootstrap v5.3.0-alpha1 (https://getbootstrap.com/)
  4635. * Copyright 2011-2022 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
  4636. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  4637. */
  4638. const MAX_UID = 1000000;
  4639. const MILLISECONDS_MULTIPLIER = 1000;
  4640. const TRANSITION_END = 'transitionend';
  4641. const parseSelector = selector => {
  4642. if (selector && window.CSS && window.CSS.escape) {
  4643. selector = selector.replace(/#([^\s"#']+)/g, (match, id) => `#${CSS.escape(id)}`);
  4644. }
  4645. return selector;
  4646. };
  4647. const toType = object => {
  4648. if (object === null || object === undefined) {
  4649. return `${object}`;
  4650. }
  4651. return Object.prototype.toString.call(object).match(/\s([a-z]+)/i)[1].toLowerCase();
  4652. };
  4653. const getUID = prefix => {
  4654. do {
  4655. prefix += Math.floor(Math.random() * MAX_UID);
  4656. } while (document.getElementById(prefix));
  4657. return prefix;
  4658. };
  4659. const getTransitionDurationFromElement = element => {
  4660. if (!element) {
  4661. return 0;
  4662. }
  4663. let {
  4664. transitionDuration,
  4665. transitionDelay
  4666. } = window.getComputedStyle(element);
  4667. const floatTransitionDuration = Number.parseFloat(transitionDuration);
  4668. const floatTransitionDelay = Number.parseFloat(transitionDelay);
  4669. if (!floatTransitionDuration && !floatTransitionDelay) {
  4670. return 0;
  4671. }
  4672. transitionDuration = transitionDuration.split(',')[0];
  4673. transitionDelay = transitionDelay.split(',')[0];
  4674. return (Number.parseFloat(transitionDuration) + Number.parseFloat(transitionDelay)) * MILLISECONDS_MULTIPLIER;
  4675. };
  4676. const triggerTransitionEnd = element => {
  4677. element.dispatchEvent(new Event(TRANSITION_END));
  4678. };
  4679. const isElement = object => {
  4680. if (!object || typeof object !== 'object') {
  4681. return false;
  4682. }
  4683. if (typeof object.jquery !== 'undefined') {
  4684. object = object[0];
  4685. }
  4686. return typeof object.nodeType !== 'undefined';
  4687. };
  4688. const getElement = object => {
  4689. if (isElement(object)) {
  4690. return object.jquery ? object[0] : object;
  4691. }
  4692. if (typeof object === 'string' && object.length > 0) {
  4693. return document.querySelector(parseSelector(object));
  4694. }
  4695. return null;
  4696. };
  4697. const isVisible = element => {
  4698. if (!isElement(element) || element.getClientRects().length === 0) {
  4699. return false;
  4700. }
  4701. const elementIsVisible = getComputedStyle(element).getPropertyValue('visibility') === 'visible';
  4702. const closedDetails = element.closest('details:not([open])');
  4703. if (!closedDetails) {
  4704. return elementIsVisible;
  4705. }
  4706. if (closedDetails !== element) {
  4707. const summary = element.closest('summary');
  4708. if (summary && summary.parentNode !== closedDetails) {
  4709. return false;
  4710. }
  4711. if (summary === null) {
  4712. return false;
  4713. }
  4714. }
  4715. return elementIsVisible;
  4716. };
  4717. const isDisabled = element => {
  4718. if (!element || element.nodeType !== Node.ELEMENT_NODE) {
  4719. return true;
  4720. }
  4721. if (element.classList.contains('disabled')) {
  4722. return true;
  4723. }
  4724. if (typeof element.disabled !== 'undefined') {
  4725. return element.disabled;
  4726. }
  4727. return element.hasAttribute('disabled') && element.getAttribute('disabled') !== 'false';
  4728. };
  4729. const findShadowRoot = element => {
  4730. if (!document.documentElement.attachShadow) {
  4731. return null;
  4732. }
  4733. if (typeof element.getRootNode === 'function') {
  4734. const root = element.getRootNode();
  4735. return root instanceof ShadowRoot ? root : null;
  4736. }
  4737. if (element instanceof ShadowRoot) {
  4738. return element;
  4739. }
  4740. if (!element.parentNode) {
  4741. return null;
  4742. }
  4743. return findShadowRoot(element.parentNode);
  4744. };
  4745. const noop = () => {};
  4746. const reflow = element => {
  4747. element.offsetHeight;
  4748. };
  4749. const getjQuery = () => {
  4750. if (window.jQuery && !document.body.hasAttribute('data-bs-no-jquery')) {
  4751. return window.jQuery;
  4752. }
  4753. return null;
  4754. };
  4755. const DOMContentLoadedCallbacks = [];
  4756. const onDOMContentLoaded = callback => {
  4757. if (document.readyState === 'loading') {
  4758. if (!DOMContentLoadedCallbacks.length) {
  4759. document.addEventListener('DOMContentLoaded', () => {
  4760. for (const callback of DOMContentLoadedCallbacks) {
  4761. callback();
  4762. }
  4763. });
  4764. }
  4765. DOMContentLoadedCallbacks.push(callback);
  4766. } else {
  4767. callback();
  4768. }
  4769. };
  4770. const isRTL = () => document.documentElement.dir === 'rtl';
  4771. const defineJQueryPlugin = plugin => {
  4772. onDOMContentLoaded(() => {
  4773. const $ = getjQuery();
  4774. if ($) {
  4775. const name = plugin.NAME;
  4776. const JQUERY_NO_CONFLICT = $.fn[name];
  4777. $.fn[name] = plugin.jQueryInterface;
  4778. $.fn[name].Constructor = plugin;
  4779. $.fn[name].noConflict = () => {
  4780. $.fn[name] = JQUERY_NO_CONFLICT;
  4781. return plugin.jQueryInterface;
  4782. };
  4783. }
  4784. });
  4785. };
  4786. const execute = (possibleCallback, args = [], defaultValue = possibleCallback) => {
  4787. return typeof possibleCallback === 'function' ? possibleCallback(...args) : defaultValue;
  4788. };
  4789. const executeAfterTransition = (callback, transitionElement, waitForTransition = true) => {
  4790. if (!waitForTransition) {
  4791. execute(callback);
  4792. return;
  4793. }
  4794. const durationPadding = 5;
  4795. const emulatedDuration = getTransitionDurationFromElement(transitionElement) + durationPadding;
  4796. let called = false;
  4797. const handler = ({
  4798. target
  4799. }) => {
  4800. if (target !== transitionElement) {
  4801. return;
  4802. }
  4803. called = true;
  4804. transitionElement.removeEventListener(TRANSITION_END, handler);
  4805. execute(callback);
  4806. };
  4807. transitionElement.addEventListener(TRANSITION_END, handler);
  4808. setTimeout(() => {
  4809. if (!called) {
  4810. triggerTransitionEnd(transitionElement);
  4811. }
  4812. }, emulatedDuration);
  4813. };
  4814. const getNextActiveElement = (list, activeElement, shouldGetNext, isCycleAllowed) => {
  4815. const listLength = list.length;
  4816. let index = list.indexOf(activeElement);
  4817. if (index === -1) {
  4818. return !shouldGetNext && isCycleAllowed ? list[listLength - 1] : list[0];
  4819. }
  4820. index += shouldGetNext ? 1 : -1;
  4821. if (isCycleAllowed) {
  4822. index = (index + listLength) % listLength;
  4823. }
  4824. return list[Math.max(0, Math.min(index, listLength - 1))];
  4825. };
  4826. const namespaceRegex = /[^.]*(?=\..*)\.|.*/;
  4827. const stripNameRegex = /\..*/;
  4828. const stripUidRegex = /::\d+$/;
  4829. const eventRegistry = {};
  4830. let uidEvent = 1;
  4831. const customEvents = {
  4832. mouseenter: 'mouseover',
  4833. mouseleave: 'mouseout'
  4834. };
  4835. 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']);
  4836. function makeEventUid(element, uid) {
  4837. return uid && `${uid}::${uidEvent++}` || element.uidEvent || uidEvent++;
  4838. }
  4839. function getElementEvents(element) {
  4840. const uid = makeEventUid(element);
  4841. element.uidEvent = uid;
  4842. eventRegistry[uid] = eventRegistry[uid] || {};
  4843. return eventRegistry[uid];
  4844. }
  4845. function bootstrapHandler(element, fn) {
  4846. return function handler(event) {
  4847. hydrateObj(event, {
  4848. delegateTarget: element
  4849. });
  4850. if (handler.oneOff) {
  4851. EventHandler.off(element, event.type, fn);
  4852. }
  4853. return fn.apply(element, [event]);
  4854. };
  4855. }
  4856. function bootstrapDelegationHandler(element, selector, fn) {
  4857. return function handler(event) {
  4858. const domElements = element.querySelectorAll(selector);
  4859. for (let {
  4860. target
  4861. } = event; target && target !== this; target = target.parentNode) {
  4862. for (const domElement of domElements) {
  4863. if (domElement !== target) {
  4864. continue;
  4865. }
  4866. hydrateObj(event, {
  4867. delegateTarget: target
  4868. });
  4869. if (handler.oneOff) {
  4870. EventHandler.off(element, event.type, selector, fn);
  4871. }
  4872. return fn.apply(target, [event]);
  4873. }
  4874. }
  4875. };
  4876. }
  4877. function findHandler(events, callable, delegationSelector = null) {
  4878. return Object.values(events).find(event => event.callable === callable && event.delegationSelector === delegationSelector);
  4879. }
  4880. function normalizeParameters(originalTypeEvent, handler, delegationFunction) {
  4881. const isDelegated = typeof handler === 'string';
  4882. const callable = isDelegated ? delegationFunction : handler || delegationFunction;
  4883. let typeEvent = getTypeEvent(originalTypeEvent);
  4884. if (!nativeEvents.has(typeEvent)) {
  4885. typeEvent = originalTypeEvent;
  4886. }
  4887. return [isDelegated, callable, typeEvent];
  4888. }
  4889. function addHandler(element, originalTypeEvent, handler, delegationFunction, oneOff) {
  4890. if (typeof originalTypeEvent !== 'string' || !element) {
  4891. return;
  4892. }
  4893. let [isDelegated, callable, typeEvent] = normalizeParameters(originalTypeEvent, handler, delegationFunction);
  4894. if (originalTypeEvent in customEvents) {
  4895. const wrapFunction = fn => {
  4896. return function (event) {
  4897. if (!event.relatedTarget || event.relatedTarget !== event.delegateTarget && !event.delegateTarget.contains(event.relatedTarget)) {
  4898. return fn.call(this, event);
  4899. }
  4900. };
  4901. };
  4902. callable = wrapFunction(callable);
  4903. }
  4904. const events = getElementEvents(element);
  4905. const handlers = events[typeEvent] || (events[typeEvent] = {});
  4906. const previousFunction = findHandler(handlers, callable, isDelegated ? handler : null);
  4907. if (previousFunction) {
  4908. previousFunction.oneOff = previousFunction.oneOff && oneOff;
  4909. return;
  4910. }
  4911. const uid = makeEventUid(callable, originalTypeEvent.replace(namespaceRegex, ''));
  4912. const fn = isDelegated ? bootstrapDelegationHandler(element, handler, callable) : bootstrapHandler(element, callable);
  4913. fn.delegationSelector = isDelegated ? handler : null;
  4914. fn.callable = callable;
  4915. fn.oneOff = oneOff;
  4916. fn.uidEvent = uid;
  4917. handlers[uid] = fn;
  4918. element.addEventListener(typeEvent, fn, isDelegated);
  4919. }
  4920. function removeHandler(element, events, typeEvent, handler, delegationSelector) {
  4921. const fn = findHandler(events[typeEvent], handler, delegationSelector);
  4922. if (!fn) {
  4923. return;
  4924. }
  4925. element.removeEventListener(typeEvent, fn, Boolean(delegationSelector));
  4926. delete events[typeEvent][fn.uidEvent];
  4927. }
  4928. function removeNamespacedHandlers(element, events, typeEvent, namespace) {
  4929. const storeElementEvent = events[typeEvent] || {};
  4930. for (const [handlerKey, event] of Object.entries(storeElementEvent)) {
  4931. if (handlerKey.includes(namespace)) {
  4932. removeHandler(element, events, typeEvent, event.callable, event.delegationSelector);
  4933. }
  4934. }
  4935. }
  4936. function getTypeEvent(event) {
  4937. event = event.replace(stripNameRegex, '');
  4938. return customEvents[event] || event;
  4939. }
  4940. const EventHandler = {
  4941. on(element, event, handler, delegationFunction) {
  4942. addHandler(element, event, handler, delegationFunction, false);
  4943. },
  4944. one(element, event, handler, delegationFunction) {
  4945. addHandler(element, event, handler, delegationFunction, true);
  4946. },
  4947. off(element, originalTypeEvent, handler, delegationFunction) {
  4948. if (typeof originalTypeEvent !== 'string' || !element) {
  4949. return;
  4950. }
  4951. const [isDelegated, callable, typeEvent] = normalizeParameters(originalTypeEvent, handler, delegationFunction);
  4952. const inNamespace = typeEvent !== originalTypeEvent;
  4953. const events = getElementEvents(element);
  4954. const storeElementEvent = events[typeEvent] || {};
  4955. const isNamespace = originalTypeEvent.startsWith('.');
  4956. if (typeof callable !== 'undefined') {
  4957. if (!Object.keys(storeElementEvent).length) {
  4958. return;
  4959. }
  4960. removeHandler(element, events, typeEvent, callable, isDelegated ? handler : null);
  4961. return;
  4962. }
  4963. if (isNamespace) {
  4964. for (const elementEvent of Object.keys(events)) {
  4965. removeNamespacedHandlers(element, events, elementEvent, originalTypeEvent.slice(1));
  4966. }
  4967. }
  4968. for (const [keyHandlers, event] of Object.entries(storeElementEvent)) {
  4969. const handlerKey = keyHandlers.replace(stripUidRegex, '');
  4970. if (!inNamespace || originalTypeEvent.includes(handlerKey)) {
  4971. removeHandler(element, events, typeEvent, event.callable, event.delegationSelector);
  4972. }
  4973. }
  4974. },
  4975. trigger(element, event, args) {
  4976. if (typeof event !== 'string' || !element) {
  4977. return null;
  4978. }
  4979. const $ = getjQuery();
  4980. const typeEvent = getTypeEvent(event);
  4981. const inNamespace = event !== typeEvent;
  4982. let jQueryEvent = null;
  4983. let bubbles = true;
  4984. let nativeDispatch = true;
  4985. let defaultPrevented = false;
  4986. if (inNamespace && $) {
  4987. jQueryEvent = $.Event(event, args);
  4988. $(element).trigger(jQueryEvent);
  4989. bubbles = !jQueryEvent.isPropagationStopped();
  4990. nativeDispatch = !jQueryEvent.isImmediatePropagationStopped();
  4991. defaultPrevented = jQueryEvent.isDefaultPrevented();
  4992. }
  4993. let evt = new Event(event, {
  4994. bubbles,
  4995. cancelable: true
  4996. });
  4997. evt = hydrateObj(evt, args);
  4998. if (defaultPrevented) {
  4999. evt.preventDefault();
  5000. }
  5001. if (nativeDispatch) {
  5002. element.dispatchEvent(evt);
  5003. }
  5004. if (evt.defaultPrevented && jQueryEvent) {
  5005. jQueryEvent.preventDefault();
  5006. }
  5007. return evt;
  5008. }
  5009. };
  5010. function hydrateObj(obj, meta = {}) {
  5011. for (const [key, value] of Object.entries(meta)) {
  5012. try {
  5013. obj[key] = value;
  5014. } catch (_unused) {
  5015. Object.defineProperty(obj, key, {
  5016. configurable: true,
  5017. get() {
  5018. return value;
  5019. }
  5020. });
  5021. }
  5022. }
  5023. return obj;
  5024. }
  5025. const elementMap = new Map();
  5026. const Data = {
  5027. set(element, key, instance) {
  5028. if (!elementMap.has(element)) {
  5029. elementMap.set(element, new Map());
  5030. }
  5031. const instanceMap = elementMap.get(element);
  5032. if (!instanceMap.has(key) && instanceMap.size !== 0) {
  5033. console.error(`Bootstrap doesn't allow more than one instance per element. Bound instance: ${Array.from(instanceMap.keys())[0]}.`);
  5034. return;
  5035. }
  5036. instanceMap.set(key, instance);
  5037. },
  5038. get(element, key) {
  5039. if (elementMap.has(element)) {
  5040. return elementMap.get(element).get(key) || null;
  5041. }
  5042. return null;
  5043. },
  5044. remove(element, key) {
  5045. if (!elementMap.has(element)) {
  5046. return;
  5047. }
  5048. const instanceMap = elementMap.get(element);
  5049. instanceMap.delete(key);
  5050. if (instanceMap.size === 0) {
  5051. elementMap.delete(element);
  5052. }
  5053. }
  5054. };
  5055. function normalizeData(value) {
  5056. if (value === 'true') {
  5057. return true;
  5058. }
  5059. if (value === 'false') {
  5060. return false;
  5061. }
  5062. if (value === Number(value).toString()) {
  5063. return Number(value);
  5064. }
  5065. if (value === '' || value === 'null') {
  5066. return null;
  5067. }
  5068. if (typeof value !== 'string') {
  5069. return value;
  5070. }
  5071. try {
  5072. return JSON.parse(decodeURIComponent(value));
  5073. } catch (_unused) {
  5074. return value;
  5075. }
  5076. }
  5077. function normalizeDataKey(key) {
  5078. return key.replace(/[A-Z]/g, chr => `-${chr.toLowerCase()}`);
  5079. }
  5080. const Manipulator = {
  5081. setDataAttribute(element, key, value) {
  5082. element.setAttribute(`data-bs-${normalizeDataKey(key)}`, value);
  5083. },
  5084. removeDataAttribute(element, key) {
  5085. element.removeAttribute(`data-bs-${normalizeDataKey(key)}`);
  5086. },
  5087. getDataAttributes(element) {
  5088. if (!element) {
  5089. return {};
  5090. }
  5091. const attributes = {};
  5092. const bsKeys = Object.keys(element.dataset).filter(key => key.startsWith('bs') && !key.startsWith('bsConfig'));
  5093. for (const key of bsKeys) {
  5094. let pureKey = key.replace(/^bs/, '');
  5095. pureKey = pureKey.charAt(0).toLowerCase() + pureKey.slice(1, pureKey.length);
  5096. attributes[pureKey] = normalizeData(element.dataset[key]);
  5097. }
  5098. return attributes;
  5099. },
  5100. getDataAttribute(element, key) {
  5101. return normalizeData(element.getAttribute(`data-bs-${normalizeDataKey(key)}`));
  5102. }
  5103. };
  5104. class Config {
  5105. static get Default() {
  5106. return {};
  5107. }
  5108. static get DefaultType() {
  5109. return {};
  5110. }
  5111. static get NAME() {
  5112. throw new Error('You have to implement the static method "NAME", for each component!');
  5113. }
  5114. _getConfig(config) {
  5115. config = this._mergeConfigObj(config);
  5116. config = this._configAfterMerge(config);
  5117. this._typeCheckConfig(config);
  5118. return config;
  5119. }
  5120. _configAfterMerge(config) {
  5121. return config;
  5122. }
  5123. _mergeConfigObj(config, element) {
  5124. const jsonConfig = isElement(element) ? Manipulator.getDataAttribute(element, 'config') : {};
  5125. return {
  5126. ...this.constructor.Default,
  5127. ...(typeof jsonConfig === 'object' ? jsonConfig : {}),
  5128. ...(isElement(element) ? Manipulator.getDataAttributes(element) : {}),
  5129. ...(typeof config === 'object' ? config : {})
  5130. };
  5131. }
  5132. _typeCheckConfig(config, configTypes = this.constructor.DefaultType) {
  5133. for (const [property, expectedTypes] of Object.entries(configTypes)) {
  5134. const value = config[property];
  5135. const valueType = isElement(value) ? 'element' : toType(value);
  5136. if (!new RegExp(expectedTypes).test(valueType)) {
  5137. throw new TypeError(`${this.constructor.NAME.toUpperCase()}: Option "${property}" provided type "${valueType}" but expected type "${expectedTypes}".`);
  5138. }
  5139. }
  5140. }
  5141. }
  5142. const VERSION = '5.3.0-alpha1';
  5143. class BaseComponent extends Config {
  5144. constructor(element, config) {
  5145. super();
  5146. element = getElement(element);
  5147. if (!element) {
  5148. return;
  5149. }
  5150. this._element = element;
  5151. this._config = this._getConfig(config);
  5152. Data.set(this._element, this.constructor.DATA_KEY, this);
  5153. }
  5154. dispose() {
  5155. Data.remove(this._element, this.constructor.DATA_KEY);
  5156. EventHandler.off(this._element, this.constructor.EVENT_KEY);
  5157. for (const propertyName of Object.getOwnPropertyNames(this)) {
  5158. this[propertyName] = null;
  5159. }
  5160. }
  5161. _queueCallback(callback, element, isAnimated = true) {
  5162. executeAfterTransition(callback, element, isAnimated);
  5163. }
  5164. _getConfig(config) {
  5165. config = this._mergeConfigObj(config, this._element);
  5166. config = this._configAfterMerge(config);
  5167. this._typeCheckConfig(config);
  5168. return config;
  5169. }
  5170. static getInstance(element) {
  5171. return Data.get(getElement(element), this.DATA_KEY);
  5172. }
  5173. static getOrCreateInstance(element, config = {}) {
  5174. return this.getInstance(element) || new this(element, typeof config === 'object' ? config : null);
  5175. }
  5176. static get VERSION() {
  5177. return VERSION;
  5178. }
  5179. static get DATA_KEY() {
  5180. return `bs.${this.NAME}`;
  5181. }
  5182. static get EVENT_KEY() {
  5183. return `.${this.DATA_KEY}`;
  5184. }
  5185. static eventName(name) {
  5186. return `${name}${this.EVENT_KEY}`;
  5187. }
  5188. }
  5189. const getSelector = element => {
  5190. let selector = element.getAttribute('data-bs-target');
  5191. if (!selector || selector === '#') {
  5192. let hrefAttribute = element.getAttribute('href');
  5193. if (!hrefAttribute || !hrefAttribute.includes('#') && !hrefAttribute.startsWith('.')) {
  5194. return null;
  5195. }
  5196. if (hrefAttribute.includes('#') && !hrefAttribute.startsWith('#')) {
  5197. hrefAttribute = `#${hrefAttribute.split('#')[1]}`;
  5198. }
  5199. selector = hrefAttribute && hrefAttribute !== '#' ? hrefAttribute.trim() : null;
  5200. }
  5201. return parseSelector(selector);
  5202. };
  5203. const SelectorEngine = {
  5204. find(selector, element = document.documentElement) {
  5205. return [].concat(...Element.prototype.querySelectorAll.call(element, selector));
  5206. },
  5207. findOne(selector, element = document.documentElement) {
  5208. return Element.prototype.querySelector.call(element, selector);
  5209. },
  5210. children(element, selector) {
  5211. return [].concat(...element.children).filter(child => child.matches(selector));
  5212. },
  5213. parents(element, selector) {
  5214. const parents = [];
  5215. let ancestor = element.parentNode.closest(selector);
  5216. while (ancestor) {
  5217. parents.push(ancestor);
  5218. ancestor = ancestor.parentNode.closest(selector);
  5219. }
  5220. return parents;
  5221. },
  5222. prev(element, selector) {
  5223. let previous = element.previousElementSibling;
  5224. while (previous) {
  5225. if (previous.matches(selector)) {
  5226. return [previous];
  5227. }
  5228. previous = previous.previousElementSibling;
  5229. }
  5230. return [];
  5231. },
  5232. next(element, selector) {
  5233. let next = element.nextElementSibling;
  5234. while (next) {
  5235. if (next.matches(selector)) {
  5236. return [next];
  5237. }
  5238. next = next.nextElementSibling;
  5239. }
  5240. return [];
  5241. },
  5242. focusableChildren(element) {
  5243. const focusables = ['a', 'button', 'input', 'textarea', 'select', 'details', '[tabindex]', '[contenteditable="true"]'].map(selector => `${selector}:not([tabindex^="-"])`).join(',');
  5244. return this.find(focusables, element).filter(el => !isDisabled(el) && isVisible(el));
  5245. },
  5246. getSelectorFromElement(element) {
  5247. const selector = getSelector(element);
  5248. if (selector) {
  5249. return SelectorEngine.findOne(selector) ? selector : null;
  5250. }
  5251. return null;
  5252. },
  5253. getElementFromSelector(element) {
  5254. const selector = getSelector(element);
  5255. return selector ? SelectorEngine.findOne(selector) : null;
  5256. },
  5257. getMultipleElementsFromSelector(element) {
  5258. const selector = getSelector(element);
  5259. return selector ? SelectorEngine.find(selector) : [];
  5260. }
  5261. };
  5262. const enableDismissTrigger = (component, method = 'hide') => {
  5263. const clickEvent = `click.dismiss${component.EVENT_KEY}`;
  5264. const name = component.NAME;
  5265. EventHandler.on(document, clickEvent, `[data-bs-dismiss="${name}"]`, function (event) {
  5266. if (['A', 'AREA'].includes(this.tagName)) {
  5267. event.preventDefault();
  5268. }
  5269. if (isDisabled(this)) {
  5270. return;
  5271. }
  5272. const target = SelectorEngine.getElementFromSelector(this) || this.closest(`.${name}`);
  5273. const instance = component.getOrCreateInstance(target);
  5274. instance[method]();
  5275. });
  5276. };
  5277. const NAME$f = 'alert';
  5278. const DATA_KEY$a = 'bs.alert';
  5279. const EVENT_KEY$b = `.${DATA_KEY$a}`;
  5280. const EVENT_CLOSE = `close${EVENT_KEY$b}`;
  5281. const EVENT_CLOSED = `closed${EVENT_KEY$b}`;
  5282. const CLASS_NAME_FADE$5 = 'fade';
  5283. const CLASS_NAME_SHOW$8 = 'show';
  5284. class Alert extends BaseComponent {
  5285. static get NAME() {
  5286. return NAME$f;
  5287. }
  5288. close() {
  5289. const closeEvent = EventHandler.trigger(this._element, EVENT_CLOSE);
  5290. if (closeEvent.defaultPrevented) {
  5291. return;
  5292. }
  5293. this._element.classList.remove(CLASS_NAME_SHOW$8);
  5294. const isAnimated = this._element.classList.contains(CLASS_NAME_FADE$5);
  5295. this._queueCallback(() => this._destroyElement(), this._element, isAnimated);
  5296. }
  5297. _destroyElement() {
  5298. this._element.remove();
  5299. EventHandler.trigger(this._element, EVENT_CLOSED);
  5300. this.dispose();
  5301. }
  5302. static jQueryInterface(config) {
  5303. return this.each(function () {
  5304. const data = Alert.getOrCreateInstance(this);
  5305. if (typeof config !== 'string') {
  5306. return;
  5307. }
  5308. if (data[config] === undefined || config.startsWith('_') || config === 'constructor') {
  5309. throw new TypeError(`No method named "${config}"`);
  5310. }
  5311. data[config](this);
  5312. });
  5313. }
  5314. }
  5315. enableDismissTrigger(Alert, 'close');
  5316. defineJQueryPlugin(Alert);
  5317. const NAME$e = 'button';
  5318. const DATA_KEY$9 = 'bs.button';
  5319. const EVENT_KEY$a = `.${DATA_KEY$9}`;
  5320. const DATA_API_KEY$6 = '.data-api';
  5321. const CLASS_NAME_ACTIVE$3 = 'active';
  5322. const SELECTOR_DATA_TOGGLE$5 = '[data-bs-toggle="button"]';
  5323. const EVENT_CLICK_DATA_API$6 = `click${EVENT_KEY$a}${DATA_API_KEY$6}`;
  5324. class Button extends BaseComponent {
  5325. static get NAME() {
  5326. return NAME$e;
  5327. }
  5328. toggle() {
  5329. this._element.setAttribute('aria-pressed', this._element.classList.toggle(CLASS_NAME_ACTIVE$3));
  5330. }
  5331. static jQueryInterface(config) {
  5332. return this.each(function () {
  5333. const data = Button.getOrCreateInstance(this);
  5334. if (config === 'toggle') {
  5335. data[config]();
  5336. }
  5337. });
  5338. }
  5339. }
  5340. EventHandler.on(document, EVENT_CLICK_DATA_API$6, SELECTOR_DATA_TOGGLE$5, event => {
  5341. event.preventDefault();
  5342. const button = event.target.closest(SELECTOR_DATA_TOGGLE$5);
  5343. const data = Button.getOrCreateInstance(button);
  5344. data.toggle();
  5345. });
  5346. defineJQueryPlugin(Button);
  5347. const NAME$d = 'swipe';
  5348. const EVENT_KEY$9 = '.bs.swipe';
  5349. const EVENT_TOUCHSTART = `touchstart${EVENT_KEY$9}`;
  5350. const EVENT_TOUCHMOVE = `touchmove${EVENT_KEY$9}`;
  5351. const EVENT_TOUCHEND = `touchend${EVENT_KEY$9}`;
  5352. const EVENT_POINTERDOWN = `pointerdown${EVENT_KEY$9}`;
  5353. const EVENT_POINTERUP = `pointerup${EVENT_KEY$9}`;
  5354. const POINTER_TYPE_TOUCH = 'touch';
  5355. const POINTER_TYPE_PEN = 'pen';
  5356. const CLASS_NAME_POINTER_EVENT = 'pointer-event';
  5357. const SWIPE_THRESHOLD = 40;
  5358. const Default$c = {
  5359. endCallback: null,
  5360. leftCallback: null,
  5361. rightCallback: null
  5362. };
  5363. const DefaultType$c = {
  5364. endCallback: '(function|null)',
  5365. leftCallback: '(function|null)',
  5366. rightCallback: '(function|null)'
  5367. };
  5368. class Swipe extends Config {
  5369. constructor(element, config) {
  5370. super();
  5371. this._element = element;
  5372. if (!element || !Swipe.isSupported()) {
  5373. return;
  5374. }
  5375. this._config = this._getConfig(config);
  5376. this._deltaX = 0;
  5377. this._supportPointerEvents = Boolean(window.PointerEvent);
  5378. this._initEvents();
  5379. }
  5380. static get Default() {
  5381. return Default$c;
  5382. }
  5383. static get DefaultType() {
  5384. return DefaultType$c;
  5385. }
  5386. static get NAME() {
  5387. return NAME$d;
  5388. }
  5389. dispose() {
  5390. EventHandler.off(this._element, EVENT_KEY$9);
  5391. }
  5392. _start(event) {
  5393. if (!this._supportPointerEvents) {
  5394. this._deltaX = event.touches[0].clientX;
  5395. return;
  5396. }
  5397. if (this._eventIsPointerPenTouch(event)) {
  5398. this._deltaX = event.clientX;
  5399. }
  5400. }
  5401. _end(event) {
  5402. if (this._eventIsPointerPenTouch(event)) {
  5403. this._deltaX = event.clientX - this._deltaX;
  5404. }
  5405. this._handleSwipe();
  5406. execute(this._config.endCallback);
  5407. }
  5408. _move(event) {
  5409. this._deltaX = event.touches && event.touches.length > 1 ? 0 : event.touches[0].clientX - this._deltaX;
  5410. }
  5411. _handleSwipe() {
  5412. const absDeltaX = Math.abs(this._deltaX);
  5413. if (absDeltaX <= SWIPE_THRESHOLD) {
  5414. return;
  5415. }
  5416. const direction = absDeltaX / this._deltaX;
  5417. this._deltaX = 0;
  5418. if (!direction) {
  5419. return;
  5420. }
  5421. execute(direction > 0 ? this._config.rightCallback : this._config.leftCallback);
  5422. }
  5423. _initEvents() {
  5424. if (this._supportPointerEvents) {
  5425. EventHandler.on(this._element, EVENT_POINTERDOWN, event => this._start(event));
  5426. EventHandler.on(this._element, EVENT_POINTERUP, event => this._end(event));
  5427. this._element.classList.add(CLASS_NAME_POINTER_EVENT);
  5428. } else {
  5429. EventHandler.on(this._element, EVENT_TOUCHSTART, event => this._start(event));
  5430. EventHandler.on(this._element, EVENT_TOUCHMOVE, event => this._move(event));
  5431. EventHandler.on(this._element, EVENT_TOUCHEND, event => this._end(event));
  5432. }
  5433. }
  5434. _eventIsPointerPenTouch(event) {
  5435. return this._supportPointerEvents && (event.pointerType === POINTER_TYPE_PEN || event.pointerType === POINTER_TYPE_TOUCH);
  5436. }
  5437. static isSupported() {
  5438. return 'ontouchstart' in document.documentElement || navigator.maxTouchPoints > 0;
  5439. }
  5440. }
  5441. const NAME$c = 'carousel';
  5442. const DATA_KEY$8 = 'bs.carousel';
  5443. const EVENT_KEY$8 = `.${DATA_KEY$8}`;
  5444. const DATA_API_KEY$5 = '.data-api';
  5445. const ARROW_LEFT_KEY$1 = 'ArrowLeft';
  5446. const ARROW_RIGHT_KEY$1 = 'ArrowRight';
  5447. const TOUCHEVENT_COMPAT_WAIT = 500;
  5448. const ORDER_NEXT = 'next';
  5449. const ORDER_PREV = 'prev';
  5450. const DIRECTION_LEFT = 'left';
  5451. const DIRECTION_RIGHT = 'right';
  5452. const EVENT_SLIDE = `slide${EVENT_KEY$8}`;
  5453. const EVENT_SLID = `slid${EVENT_KEY$8}`;
  5454. const EVENT_KEYDOWN$1 = `keydown${EVENT_KEY$8}`;
  5455. const EVENT_MOUSEENTER$1 = `mouseenter${EVENT_KEY$8}`;
  5456. const EVENT_MOUSELEAVE$1 = `mouseleave${EVENT_KEY$8}`;
  5457. const EVENT_DRAG_START = `dragstart${EVENT_KEY$8}`;
  5458. const EVENT_LOAD_DATA_API$3 = `load${EVENT_KEY$8}${DATA_API_KEY$5}`;
  5459. const EVENT_CLICK_DATA_API$5 = `click${EVENT_KEY$8}${DATA_API_KEY$5}`;
  5460. const CLASS_NAME_CAROUSEL = 'carousel';
  5461. const CLASS_NAME_ACTIVE$2 = 'active';
  5462. const CLASS_NAME_SLIDE = 'slide';
  5463. const CLASS_NAME_END = 'carousel-item-end';
  5464. const CLASS_NAME_START = 'carousel-item-start';
  5465. const CLASS_NAME_NEXT = 'carousel-item-next';
  5466. const CLASS_NAME_PREV = 'carousel-item-prev';
  5467. const SELECTOR_ACTIVE = '.active';
  5468. const SELECTOR_ITEM = '.carousel-item';
  5469. const SELECTOR_ACTIVE_ITEM = SELECTOR_ACTIVE + SELECTOR_ITEM;
  5470. const SELECTOR_ITEM_IMG = '.carousel-item img';
  5471. const SELECTOR_INDICATORS = '.carousel-indicators';
  5472. const SELECTOR_DATA_SLIDE = '[data-bs-slide], [data-bs-slide-to]';
  5473. const SELECTOR_DATA_RIDE = '[data-bs-ride="carousel"]';
  5474. const KEY_TO_DIRECTION = {
  5475. [ARROW_LEFT_KEY$1]: DIRECTION_RIGHT,
  5476. [ARROW_RIGHT_KEY$1]: DIRECTION_LEFT
  5477. };
  5478. const Default$b = {
  5479. interval: 5000,
  5480. keyboard: true,
  5481. pause: 'hover',
  5482. ride: false,
  5483. touch: true,
  5484. wrap: true
  5485. };
  5486. const DefaultType$b = {
  5487. interval: '(number|boolean)',
  5488. keyboard: 'boolean',
  5489. pause: '(string|boolean)',
  5490. ride: '(boolean|string)',
  5491. touch: 'boolean',
  5492. wrap: 'boolean'
  5493. };
  5494. class Carousel extends BaseComponent {
  5495. constructor(element, config) {
  5496. super(element, config);
  5497. this._interval = null;
  5498. this._activeElement = null;
  5499. this._isSliding = false;
  5500. this.touchTimeout = null;
  5501. this._swipeHelper = null;
  5502. this._indicatorsElement = SelectorEngine.findOne(SELECTOR_INDICATORS, this._element);
  5503. this._addEventListeners();
  5504. if (this._config.ride === CLASS_NAME_CAROUSEL) {
  5505. this.cycle();
  5506. }
  5507. }
  5508. static get Default() {
  5509. return Default$b;
  5510. }
  5511. static get DefaultType() {
  5512. return DefaultType$b;
  5513. }
  5514. static get NAME() {
  5515. return NAME$c;
  5516. }
  5517. next() {
  5518. this._slide(ORDER_NEXT);
  5519. }
  5520. nextWhenVisible() {
  5521. if (!document.hidden && isVisible(this._element)) {
  5522. this.next();
  5523. }
  5524. }
  5525. prev() {
  5526. this._slide(ORDER_PREV);
  5527. }
  5528. pause() {
  5529. if (this._isSliding) {
  5530. triggerTransitionEnd(this._element);
  5531. }
  5532. this._clearInterval();
  5533. }
  5534. cycle() {
  5535. this._clearInterval();
  5536. this._updateInterval();
  5537. this._interval = setInterval(() => this.nextWhenVisible(), this._config.interval);
  5538. }
  5539. _maybeEnableCycle() {
  5540. if (!this._config.ride) {
  5541. return;
  5542. }
  5543. if (this._isSliding) {
  5544. EventHandler.one(this._element, EVENT_SLID, () => this.cycle());
  5545. return;
  5546. }
  5547. this.cycle();
  5548. }
  5549. to(index) {
  5550. const items = this._getItems();
  5551. if (index > items.length - 1 || index < 0) {
  5552. return;
  5553. }
  5554. if (this._isSliding) {
  5555. EventHandler.one(this._element, EVENT_SLID, () => this.to(index));
  5556. return;
  5557. }
  5558. const activeIndex = this._getItemIndex(this._getActive());
  5559. if (activeIndex === index) {
  5560. return;
  5561. }
  5562. const order = index > activeIndex ? ORDER_NEXT : ORDER_PREV;
  5563. this._slide(order, items[index]);
  5564. }
  5565. dispose() {
  5566. if (this._swipeHelper) {
  5567. this._swipeHelper.dispose();
  5568. }
  5569. super.dispose();
  5570. }
  5571. _configAfterMerge(config) {
  5572. config.defaultInterval = config.interval;
  5573. return config;
  5574. }
  5575. _addEventListeners() {
  5576. if (this._config.keyboard) {
  5577. EventHandler.on(this._element, EVENT_KEYDOWN$1, event => this._keydown(event));
  5578. }
  5579. if (this._config.pause === 'hover') {
  5580. EventHandler.on(this._element, EVENT_MOUSEENTER$1, () => this.pause());
  5581. EventHandler.on(this._element, EVENT_MOUSELEAVE$1, () => this._maybeEnableCycle());
  5582. }
  5583. if (this._config.touch && Swipe.isSupported()) {
  5584. this._addTouchEventListeners();
  5585. }
  5586. }
  5587. _addTouchEventListeners() {
  5588. for (const img of SelectorEngine.find(SELECTOR_ITEM_IMG, this._element)) {
  5589. EventHandler.on(img, EVENT_DRAG_START, event => event.preventDefault());
  5590. }
  5591. const endCallBack = () => {
  5592. if (this._config.pause !== 'hover') {
  5593. return;
  5594. }
  5595. this.pause();
  5596. if (this.touchTimeout) {
  5597. clearTimeout(this.touchTimeout);
  5598. }
  5599. this.touchTimeout = setTimeout(() => this._maybeEnableCycle(), TOUCHEVENT_COMPAT_WAIT + this._config.interval);
  5600. };
  5601. const swipeConfig = {
  5602. leftCallback: () => this._slide(this._directionToOrder(DIRECTION_LEFT)),
  5603. rightCallback: () => this._slide(this._directionToOrder(DIRECTION_RIGHT)),
  5604. endCallback: endCallBack
  5605. };
  5606. this._swipeHelper = new Swipe(this._element, swipeConfig);
  5607. }
  5608. _keydown(event) {
  5609. if (/input|textarea/i.test(event.target.tagName)) {
  5610. return;
  5611. }
  5612. const direction = KEY_TO_DIRECTION[event.key];
  5613. if (direction) {
  5614. event.preventDefault();
  5615. this._slide(this._directionToOrder(direction));
  5616. }
  5617. }
  5618. _getItemIndex(element) {
  5619. return this._getItems().indexOf(element);
  5620. }
  5621. _setActiveIndicatorElement(index) {
  5622. if (!this._indicatorsElement) {
  5623. return;
  5624. }
  5625. const activeIndicator = SelectorEngine.findOne(SELECTOR_ACTIVE, this._indicatorsElement);
  5626. activeIndicator.classList.remove(CLASS_NAME_ACTIVE$2);
  5627. activeIndicator.removeAttribute('aria-current');
  5628. const newActiveIndicator = SelectorEngine.findOne(`[data-bs-slide-to="${index}"]`, this._indicatorsElement);
  5629. if (newActiveIndicator) {
  5630. newActiveIndicator.classList.add(CLASS_NAME_ACTIVE$2);
  5631. newActiveIndicator.setAttribute('aria-current', 'true');
  5632. }
  5633. }
  5634. _updateInterval() {
  5635. const element = this._activeElement || this._getActive();
  5636. if (!element) {
  5637. return;
  5638. }
  5639. const elementInterval = Number.parseInt(element.getAttribute('data-bs-interval'), 10);
  5640. this._config.interval = elementInterval || this._config.defaultInterval;
  5641. }
  5642. _slide(order, element = null) {
  5643. if (this._isSliding) {
  5644. return;
  5645. }
  5646. const activeElement = this._getActive();
  5647. const isNext = order === ORDER_NEXT;
  5648. const nextElement = element || getNextActiveElement(this._getItems(), activeElement, isNext, this._config.wrap);
  5649. if (nextElement === activeElement) {
  5650. return;
  5651. }
  5652. const nextElementIndex = this._getItemIndex(nextElement);
  5653. const triggerEvent = eventName => {
  5654. return EventHandler.trigger(this._element, eventName, {
  5655. relatedTarget: nextElement,
  5656. direction: this._orderToDirection(order),
  5657. from: this._getItemIndex(activeElement),
  5658. to: nextElementIndex
  5659. });
  5660. };
  5661. const slideEvent = triggerEvent(EVENT_SLIDE);
  5662. if (slideEvent.defaultPrevented) {
  5663. return;
  5664. }
  5665. if (!activeElement || !nextElement) {
  5666. return;
  5667. }
  5668. const isCycling = Boolean(this._interval);
  5669. this.pause();
  5670. this._isSliding = true;
  5671. this._setActiveIndicatorElement(nextElementIndex);
  5672. this._activeElement = nextElement;
  5673. const directionalClassName = isNext ? CLASS_NAME_START : CLASS_NAME_END;
  5674. const orderClassName = isNext ? CLASS_NAME_NEXT : CLASS_NAME_PREV;
  5675. nextElement.classList.add(orderClassName);
  5676. reflow(nextElement);
  5677. activeElement.classList.add(directionalClassName);
  5678. nextElement.classList.add(directionalClassName);
  5679. const completeCallBack = () => {
  5680. nextElement.classList.remove(directionalClassName, orderClassName);
  5681. nextElement.classList.add(CLASS_NAME_ACTIVE$2);
  5682. activeElement.classList.remove(CLASS_NAME_ACTIVE$2, orderClassName, directionalClassName);
  5683. this._isSliding = false;
  5684. triggerEvent(EVENT_SLID);
  5685. };
  5686. this._queueCallback(completeCallBack, activeElement, this._isAnimated());
  5687. if (isCycling) {
  5688. this.cycle();
  5689. }
  5690. }
  5691. _isAnimated() {
  5692. return this._element.classList.contains(CLASS_NAME_SLIDE);
  5693. }
  5694. _getActive() {
  5695. return SelectorEngine.findOne(SELECTOR_ACTIVE_ITEM, this._element);
  5696. }
  5697. _getItems() {
  5698. return SelectorEngine.find(SELECTOR_ITEM, this._element);
  5699. }
  5700. _clearInterval() {
  5701. if (this._interval) {
  5702. clearInterval(this._interval);
  5703. this._interval = null;
  5704. }
  5705. }
  5706. _directionToOrder(direction) {
  5707. if (isRTL()) {
  5708. return direction === DIRECTION_LEFT ? ORDER_PREV : ORDER_NEXT;
  5709. }
  5710. return direction === DIRECTION_LEFT ? ORDER_NEXT : ORDER_PREV;
  5711. }
  5712. _orderToDirection(order) {
  5713. if (isRTL()) {
  5714. return order === ORDER_PREV ? DIRECTION_LEFT : DIRECTION_RIGHT;
  5715. }
  5716. return order === ORDER_PREV ? DIRECTION_RIGHT : DIRECTION_LEFT;
  5717. }
  5718. static jQueryInterface(config) {
  5719. return this.each(function () {
  5720. const data = Carousel.getOrCreateInstance(this, config);
  5721. if (typeof config === 'number') {
  5722. data.to(config);
  5723. return;
  5724. }
  5725. if (typeof config === 'string') {
  5726. if (data[config] === undefined || config.startsWith('_') || config === 'constructor') {
  5727. throw new TypeError(`No method named "${config}"`);
  5728. }
  5729. data[config]();
  5730. }
  5731. });
  5732. }
  5733. }
  5734. EventHandler.on(document, EVENT_CLICK_DATA_API$5, SELECTOR_DATA_SLIDE, function (event) {
  5735. const target = SelectorEngine.getElementFromSelector(this);
  5736. if (!target || !target.classList.contains(CLASS_NAME_CAROUSEL)) {
  5737. return;
  5738. }
  5739. event.preventDefault();
  5740. const carousel = Carousel.getOrCreateInstance(target);
  5741. const slideIndex = this.getAttribute('data-bs-slide-to');
  5742. if (slideIndex) {
  5743. carousel.to(slideIndex);
  5744. carousel._maybeEnableCycle();
  5745. return;
  5746. }
  5747. if (Manipulator.getDataAttribute(this, 'slide') === 'next') {
  5748. carousel.next();
  5749. carousel._maybeEnableCycle();
  5750. return;
  5751. }
  5752. carousel.prev();
  5753. carousel._maybeEnableCycle();
  5754. });
  5755. EventHandler.on(window, EVENT_LOAD_DATA_API$3, () => {
  5756. const carousels = SelectorEngine.find(SELECTOR_DATA_RIDE);
  5757. for (const carousel of carousels) {
  5758. Carousel.getOrCreateInstance(carousel);
  5759. }
  5760. });
  5761. defineJQueryPlugin(Carousel);
  5762. const NAME$b = 'collapse';
  5763. const DATA_KEY$7 = 'bs.collapse';
  5764. const EVENT_KEY$7 = `.${DATA_KEY$7}`;
  5765. const DATA_API_KEY$4 = '.data-api';
  5766. const EVENT_SHOW$6 = `show${EVENT_KEY$7}`;
  5767. const EVENT_SHOWN$6 = `shown${EVENT_KEY$7}`;
  5768. const EVENT_HIDE$6 = `hide${EVENT_KEY$7}`;
  5769. const EVENT_HIDDEN$6 = `hidden${EVENT_KEY$7}`;
  5770. const EVENT_CLICK_DATA_API$4 = `click${EVENT_KEY$7}${DATA_API_KEY$4}`;
  5771. const CLASS_NAME_SHOW$7 = 'show';
  5772. const CLASS_NAME_COLLAPSE = 'collapse';
  5773. const CLASS_NAME_COLLAPSING = 'collapsing';
  5774. const CLASS_NAME_COLLAPSED = 'collapsed';
  5775. const CLASS_NAME_DEEPER_CHILDREN = `:scope .${CLASS_NAME_COLLAPSE} .${CLASS_NAME_COLLAPSE}`;
  5776. const CLASS_NAME_HORIZONTAL = 'collapse-horizontal';
  5777. const WIDTH = 'width';
  5778. const HEIGHT = 'height';
  5779. const SELECTOR_ACTIVES = '.collapse.show, .collapse.collapsing';
  5780. const SELECTOR_DATA_TOGGLE$4 = '[data-bs-toggle="collapse"]';
  5781. const Default$a = {
  5782. parent: null,
  5783. toggle: true
  5784. };
  5785. const DefaultType$a = {
  5786. parent: '(null|element)',
  5787. toggle: 'boolean'
  5788. };
  5789. class Collapse extends BaseComponent {
  5790. constructor(element, config) {
  5791. super(element, config);
  5792. this._isTransitioning = false;
  5793. this._triggerArray = [];
  5794. const toggleList = SelectorEngine.find(SELECTOR_DATA_TOGGLE$4);
  5795. for (const elem of toggleList) {
  5796. const selector = SelectorEngine.getSelectorFromElement(elem);
  5797. const filterElement = SelectorEngine.find(selector).filter(foundElement => foundElement === this._element);
  5798. if (selector !== null && filterElement.length) {
  5799. this._triggerArray.push(elem);
  5800. }
  5801. }
  5802. this._initializeChildren();
  5803. if (!this._config.parent) {
  5804. this._addAriaAndCollapsedClass(this._triggerArray, this._isShown());
  5805. }
  5806. if (this._config.toggle) {
  5807. this.toggle();
  5808. }
  5809. }
  5810. static get Default() {
  5811. return Default$a;
  5812. }
  5813. static get DefaultType() {
  5814. return DefaultType$a;
  5815. }
  5816. static get NAME() {
  5817. return NAME$b;
  5818. }
  5819. toggle() {
  5820. if (this._isShown()) {
  5821. this.hide();
  5822. } else {
  5823. this.show();
  5824. }
  5825. }
  5826. show() {
  5827. if (this._isTransitioning || this._isShown()) {
  5828. return;
  5829. }
  5830. let activeChildren = [];
  5831. if (this._config.parent) {
  5832. activeChildren = this._getFirstLevelChildren(SELECTOR_ACTIVES).filter(element => element !== this._element).map(element => Collapse.getOrCreateInstance(element, {
  5833. toggle: false
  5834. }));
  5835. }
  5836. if (activeChildren.length && activeChildren[0]._isTransitioning) {
  5837. return;
  5838. }
  5839. const startEvent = EventHandler.trigger(this._element, EVENT_SHOW$6);
  5840. if (startEvent.defaultPrevented) {
  5841. return;
  5842. }
  5843. for (const activeInstance of activeChildren) {
  5844. activeInstance.hide();
  5845. }
  5846. const dimension = this._getDimension();
  5847. this._element.classList.remove(CLASS_NAME_COLLAPSE);
  5848. this._element.classList.add(CLASS_NAME_COLLAPSING);
  5849. this._element.style[dimension] = 0;
  5850. this._addAriaAndCollapsedClass(this._triggerArray, true);
  5851. this._isTransitioning = true;
  5852. const complete = () => {
  5853. this._isTransitioning = false;
  5854. this._element.classList.remove(CLASS_NAME_COLLAPSING);
  5855. this._element.classList.add(CLASS_NAME_COLLAPSE, CLASS_NAME_SHOW$7);
  5856. this._element.style[dimension] = '';
  5857. EventHandler.trigger(this._element, EVENT_SHOWN$6);
  5858. };
  5859. const capitalizedDimension = dimension[0].toUpperCase() + dimension.slice(1);
  5860. const scrollSize = `scroll${capitalizedDimension}`;
  5861. this._queueCallback(complete, this._element, true);
  5862. this._element.style[dimension] = `${this._element[scrollSize]}px`;
  5863. }
  5864. hide() {
  5865. if (this._isTransitioning || !this._isShown()) {
  5866. return;
  5867. }
  5868. const startEvent = EventHandler.trigger(this._element, EVENT_HIDE$6);
  5869. if (startEvent.defaultPrevented) {
  5870. return;
  5871. }
  5872. const dimension = this._getDimension();
  5873. this._element.style[dimension] = `${this._element.getBoundingClientRect()[dimension]}px`;
  5874. reflow(this._element);
  5875. this._element.classList.add(CLASS_NAME_COLLAPSING);
  5876. this._element.classList.remove(CLASS_NAME_COLLAPSE, CLASS_NAME_SHOW$7);
  5877. for (const trigger of this._triggerArray) {
  5878. const element = SelectorEngine.getElementFromSelector(trigger);
  5879. if (element && !this._isShown(element)) {
  5880. this._addAriaAndCollapsedClass([trigger], false);
  5881. }
  5882. }
  5883. this._isTransitioning = true;
  5884. const complete = () => {
  5885. this._isTransitioning = false;
  5886. this._element.classList.remove(CLASS_NAME_COLLAPSING);
  5887. this._element.classList.add(CLASS_NAME_COLLAPSE);
  5888. EventHandler.trigger(this._element, EVENT_HIDDEN$6);
  5889. };
  5890. this._element.style[dimension] = '';
  5891. this._queueCallback(complete, this._element, true);
  5892. }
  5893. _isShown(element = this._element) {
  5894. return element.classList.contains(CLASS_NAME_SHOW$7);
  5895. }
  5896. _configAfterMerge(config) {
  5897. config.toggle = Boolean(config.toggle);
  5898. config.parent = getElement(config.parent);
  5899. return config;
  5900. }
  5901. _getDimension() {
  5902. return this._element.classList.contains(CLASS_NAME_HORIZONTAL) ? WIDTH : HEIGHT;
  5903. }
  5904. _initializeChildren() {
  5905. if (!this._config.parent) {
  5906. return;
  5907. }
  5908. const children = this._getFirstLevelChildren(SELECTOR_DATA_TOGGLE$4);
  5909. for (const element of children) {
  5910. const selected = SelectorEngine.getElementFromSelector(element);
  5911. if (selected) {
  5912. this._addAriaAndCollapsedClass([element], this._isShown(selected));
  5913. }
  5914. }
  5915. }
  5916. _getFirstLevelChildren(selector) {
  5917. const children = SelectorEngine.find(CLASS_NAME_DEEPER_CHILDREN, this._config.parent);
  5918. return SelectorEngine.find(selector, this._config.parent).filter(element => !children.includes(element));
  5919. }
  5920. _addAriaAndCollapsedClass(triggerArray, isOpen) {
  5921. if (!triggerArray.length) {
  5922. return;
  5923. }
  5924. for (const element of triggerArray) {
  5925. element.classList.toggle(CLASS_NAME_COLLAPSED, !isOpen);
  5926. element.setAttribute('aria-expanded', isOpen);
  5927. }
  5928. }
  5929. static jQueryInterface(config) {
  5930. const _config = {};
  5931. if (typeof config === 'string' && /show|hide/.test(config)) {
  5932. _config.toggle = false;
  5933. }
  5934. return this.each(function () {
  5935. const data = Collapse.getOrCreateInstance(this, _config);
  5936. if (typeof config === 'string') {
  5937. if (typeof data[config] === 'undefined') {
  5938. throw new TypeError(`No method named "${config}"`);
  5939. }
  5940. data[config]();
  5941. }
  5942. });
  5943. }
  5944. }
  5945. EventHandler.on(document, EVENT_CLICK_DATA_API$4, SELECTOR_DATA_TOGGLE$4, function (event) {
  5946. if (event.target.tagName === 'A' || event.delegateTarget && event.delegateTarget.tagName === 'A') {
  5947. event.preventDefault();
  5948. }
  5949. for (const element of SelectorEngine.getMultipleElementsFromSelector(this)) {
  5950. Collapse.getOrCreateInstance(element, {
  5951. toggle: false
  5952. }).toggle();
  5953. }
  5954. });
  5955. defineJQueryPlugin(Collapse);
  5956. const NAME$a = 'dropdown';
  5957. const DATA_KEY$6 = 'bs.dropdown';
  5958. const EVENT_KEY$6 = `.${DATA_KEY$6}`;
  5959. const DATA_API_KEY$3 = '.data-api';
  5960. const ESCAPE_KEY$2 = 'Escape';
  5961. const TAB_KEY$1 = 'Tab';
  5962. const ARROW_UP_KEY$1 = 'ArrowUp';
  5963. const ARROW_DOWN_KEY$1 = 'ArrowDown';
  5964. const RIGHT_MOUSE_BUTTON = 2;
  5965. const EVENT_HIDE$5 = `hide${EVENT_KEY$6}`;
  5966. const EVENT_HIDDEN$5 = `hidden${EVENT_KEY$6}`;
  5967. const EVENT_SHOW$5 = `show${EVENT_KEY$6}`;
  5968. const EVENT_SHOWN$5 = `shown${EVENT_KEY$6}`;
  5969. const EVENT_CLICK_DATA_API$3 = `click${EVENT_KEY$6}${DATA_API_KEY$3}`;
  5970. const EVENT_KEYDOWN_DATA_API = `keydown${EVENT_KEY$6}${DATA_API_KEY$3}`;
  5971. const EVENT_KEYUP_DATA_API = `keyup${EVENT_KEY$6}${DATA_API_KEY$3}`;
  5972. const CLASS_NAME_SHOW$6 = 'show';
  5973. const CLASS_NAME_DROPUP = 'dropup';
  5974. const CLASS_NAME_DROPEND = 'dropend';
  5975. const CLASS_NAME_DROPSTART = 'dropstart';
  5976. const CLASS_NAME_DROPUP_CENTER = 'dropup-center';
  5977. const CLASS_NAME_DROPDOWN_CENTER = 'dropdown-center';
  5978. const SELECTOR_DATA_TOGGLE$3 = '[data-bs-toggle="dropdown"]:not(.disabled):not(:disabled)';
  5979. const SELECTOR_DATA_TOGGLE_SHOWN = `${SELECTOR_DATA_TOGGLE$3}.${CLASS_NAME_SHOW$6}`;
  5980. const SELECTOR_MENU = '.dropdown-menu';
  5981. const SELECTOR_NAVBAR = '.navbar';
  5982. const SELECTOR_NAVBAR_NAV = '.navbar-nav';
  5983. const SELECTOR_VISIBLE_ITEMS = '.dropdown-menu .dropdown-item:not(.disabled):not(:disabled)';
  5984. const PLACEMENT_TOP = isRTL() ? 'top-end' : 'top-start';
  5985. const PLACEMENT_TOPEND = isRTL() ? 'top-start' : 'top-end';
  5986. const PLACEMENT_BOTTOM = isRTL() ? 'bottom-end' : 'bottom-start';
  5987. const PLACEMENT_BOTTOMEND = isRTL() ? 'bottom-start' : 'bottom-end';
  5988. const PLACEMENT_RIGHT = isRTL() ? 'left-start' : 'right-start';
  5989. const PLACEMENT_LEFT = isRTL() ? 'right-start' : 'left-start';
  5990. const PLACEMENT_TOPCENTER = 'top';
  5991. const PLACEMENT_BOTTOMCENTER = 'bottom';
  5992. const Default$9 = {
  5993. autoClose: true,
  5994. boundary: 'clippingParents',
  5995. display: 'dynamic',
  5996. offset: [0, 2],
  5997. popperConfig: null,
  5998. reference: 'toggle'
  5999. };
  6000. const DefaultType$9 = {
  6001. autoClose: '(boolean|string)',
  6002. boundary: '(string|element)',
  6003. display: 'string',
  6004. offset: '(array|string|function)',
  6005. popperConfig: '(null|object|function)',
  6006. reference: '(string|element|object)'
  6007. };
  6008. class Dropdown extends BaseComponent {
  6009. constructor(element, config) {
  6010. super(element, config);
  6011. this._popper = null;
  6012. this._parent = this._element.parentNode;
  6013. this._menu = SelectorEngine.next(this._element, SELECTOR_MENU)[0] || SelectorEngine.prev(this._element, SELECTOR_MENU)[0] || SelectorEngine.findOne(SELECTOR_MENU, this._parent);
  6014. this._inNavbar = this._detectNavbar();
  6015. }
  6016. static get Default() {
  6017. return Default$9;
  6018. }
  6019. static get DefaultType() {
  6020. return DefaultType$9;
  6021. }
  6022. static get NAME() {
  6023. return NAME$a;
  6024. }
  6025. toggle() {
  6026. return this._isShown() ? this.hide() : this.show();
  6027. }
  6028. show() {
  6029. if (isDisabled(this._element) || this._isShown()) {
  6030. return;
  6031. }
  6032. const relatedTarget = {
  6033. relatedTarget: this._element
  6034. };
  6035. const showEvent = EventHandler.trigger(this._element, EVENT_SHOW$5, relatedTarget);
  6036. if (showEvent.defaultPrevented) {
  6037. return;
  6038. }
  6039. this._createPopper();
  6040. if ('ontouchstart' in document.documentElement && !this._parent.closest(SELECTOR_NAVBAR_NAV)) {
  6041. for (const element of [].concat(...document.body.children)) {
  6042. EventHandler.on(element, 'mouseover', noop);
  6043. }
  6044. }
  6045. this._element.focus();
  6046. this._element.setAttribute('aria-expanded', true);
  6047. this._menu.classList.add(CLASS_NAME_SHOW$6);
  6048. this._element.classList.add(CLASS_NAME_SHOW$6);
  6049. EventHandler.trigger(this._element, EVENT_SHOWN$5, relatedTarget);
  6050. }
  6051. hide() {
  6052. if (isDisabled(this._element) || !this._isShown()) {
  6053. return;
  6054. }
  6055. const relatedTarget = {
  6056. relatedTarget: this._element
  6057. };
  6058. this._completeHide(relatedTarget);
  6059. }
  6060. dispose() {
  6061. if (this._popper) {
  6062. this._popper.destroy();
  6063. }
  6064. super.dispose();
  6065. }
  6066. update() {
  6067. this._inNavbar = this._detectNavbar();
  6068. if (this._popper) {
  6069. this._popper.update();
  6070. }
  6071. }
  6072. _completeHide(relatedTarget) {
  6073. const hideEvent = EventHandler.trigger(this._element, EVENT_HIDE$5, relatedTarget);
  6074. if (hideEvent.defaultPrevented) {
  6075. return;
  6076. }
  6077. if ('ontouchstart' in document.documentElement) {
  6078. for (const element of [].concat(...document.body.children)) {
  6079. EventHandler.off(element, 'mouseover', noop);
  6080. }
  6081. }
  6082. if (this._popper) {
  6083. this._popper.destroy();
  6084. }
  6085. this._menu.classList.remove(CLASS_NAME_SHOW$6);
  6086. this._element.classList.remove(CLASS_NAME_SHOW$6);
  6087. this._element.setAttribute('aria-expanded', 'false');
  6088. Manipulator.removeDataAttribute(this._menu, 'popper');
  6089. EventHandler.trigger(this._element, EVENT_HIDDEN$5, relatedTarget);
  6090. }
  6091. _getConfig(config) {
  6092. config = super._getConfig(config);
  6093. if (typeof config.reference === 'object' && !isElement(config.reference) && typeof config.reference.getBoundingClientRect !== 'function') {
  6094. throw new TypeError(`${NAME$a.toUpperCase()}: Option "reference" provided type "object" without a required "getBoundingClientRect" method.`);
  6095. }
  6096. return config;
  6097. }
  6098. _createPopper() {
  6099. if (typeof Popper === 'undefined') {
  6100. throw new TypeError('Bootstrap\'s dropdowns require Popper (https://popper.js.org)');
  6101. }
  6102. let referenceElement = this._element;
  6103. if (this._config.reference === 'parent') {
  6104. referenceElement = this._parent;
  6105. } else if (isElement(this._config.reference)) {
  6106. referenceElement = getElement(this._config.reference);
  6107. } else if (typeof this._config.reference === 'object') {
  6108. referenceElement = this._config.reference;
  6109. }
  6110. const popperConfig = this._getPopperConfig();
  6111. this._popper = createPopper(referenceElement, this._menu, popperConfig);
  6112. }
  6113. _isShown() {
  6114. return this._menu.classList.contains(CLASS_NAME_SHOW$6);
  6115. }
  6116. _getPlacement() {
  6117. const parentDropdown = this._parent;
  6118. if (parentDropdown.classList.contains(CLASS_NAME_DROPEND)) {
  6119. return PLACEMENT_RIGHT;
  6120. }
  6121. if (parentDropdown.classList.contains(CLASS_NAME_DROPSTART)) {
  6122. return PLACEMENT_LEFT;
  6123. }
  6124. if (parentDropdown.classList.contains(CLASS_NAME_DROPUP_CENTER)) {
  6125. return PLACEMENT_TOPCENTER;
  6126. }
  6127. if (parentDropdown.classList.contains(CLASS_NAME_DROPDOWN_CENTER)) {
  6128. return PLACEMENT_BOTTOMCENTER;
  6129. }
  6130. const isEnd = getComputedStyle(this._menu).getPropertyValue('--bs-position').trim() === 'end';
  6131. if (parentDropdown.classList.contains(CLASS_NAME_DROPUP)) {
  6132. return isEnd ? PLACEMENT_TOPEND : PLACEMENT_TOP;
  6133. }
  6134. return isEnd ? PLACEMENT_BOTTOMEND : PLACEMENT_BOTTOM;
  6135. }
  6136. _detectNavbar() {
  6137. return this._element.closest(SELECTOR_NAVBAR) !== null;
  6138. }
  6139. _getOffset() {
  6140. const {
  6141. offset
  6142. } = this._config;
  6143. if (typeof offset === 'string') {
  6144. return offset.split(',').map(value => Number.parseInt(value, 10));
  6145. }
  6146. if (typeof offset === 'function') {
  6147. return popperData => offset(popperData, this._element);
  6148. }
  6149. return offset;
  6150. }
  6151. _getPopperConfig() {
  6152. const defaultBsPopperConfig = {
  6153. placement: this._getPlacement(),
  6154. modifiers: [{
  6155. name: 'preventOverflow',
  6156. options: {
  6157. boundary: this._config.boundary
  6158. }
  6159. }, {
  6160. name: 'offset',
  6161. options: {
  6162. offset: this._getOffset()
  6163. }
  6164. }]
  6165. };
  6166. if (this._inNavbar || this._config.display === 'static') {
  6167. Manipulator.setDataAttribute(this._menu, 'popper', 'static');
  6168. defaultBsPopperConfig.modifiers = [{
  6169. name: 'applyStyles',
  6170. enabled: false
  6171. }];
  6172. }
  6173. return {
  6174. ...defaultBsPopperConfig,
  6175. ...execute(this._config.popperConfig, [defaultBsPopperConfig])
  6176. };
  6177. }
  6178. _selectMenuItem({
  6179. key,
  6180. target
  6181. }) {
  6182. const items = SelectorEngine.find(SELECTOR_VISIBLE_ITEMS, this._menu).filter(element => isVisible(element));
  6183. if (!items.length) {
  6184. return;
  6185. }
  6186. getNextActiveElement(items, target, key === ARROW_DOWN_KEY$1, !items.includes(target)).focus();
  6187. }
  6188. static jQueryInterface(config) {
  6189. return this.each(function () {
  6190. const data = Dropdown.getOrCreateInstance(this, config);
  6191. if (typeof config !== 'string') {
  6192. return;
  6193. }
  6194. if (typeof data[config] === 'undefined') {
  6195. throw new TypeError(`No method named "${config}"`);
  6196. }
  6197. data[config]();
  6198. });
  6199. }
  6200. static clearMenus(event) {
  6201. if (event.button === RIGHT_MOUSE_BUTTON || event.type === 'keyup' && event.key !== TAB_KEY$1) {
  6202. return;
  6203. }
  6204. const openToggles = SelectorEngine.find(SELECTOR_DATA_TOGGLE_SHOWN);
  6205. for (const toggle of openToggles) {
  6206. const context = Dropdown.getInstance(toggle);
  6207. if (!context || context._config.autoClose === false) {
  6208. continue;
  6209. }
  6210. const composedPath = event.composedPath();
  6211. const isMenuTarget = composedPath.includes(context._menu);
  6212. if (composedPath.includes(context._element) || context._config.autoClose === 'inside' && !isMenuTarget || context._config.autoClose === 'outside' && isMenuTarget) {
  6213. continue;
  6214. }
  6215. if (context._menu.contains(event.target) && (event.type === 'keyup' && event.key === TAB_KEY$1 || /input|select|option|textarea|form/i.test(event.target.tagName))) {
  6216. continue;
  6217. }
  6218. const relatedTarget = {
  6219. relatedTarget: context._element
  6220. };
  6221. if (event.type === 'click') {
  6222. relatedTarget.clickEvent = event;
  6223. }
  6224. context._completeHide(relatedTarget);
  6225. }
  6226. }
  6227. static dataApiKeydownHandler(event) {
  6228. const isInput = /input|textarea/i.test(event.target.tagName);
  6229. const isEscapeEvent = event.key === ESCAPE_KEY$2;
  6230. const isUpOrDownEvent = [ARROW_UP_KEY$1, ARROW_DOWN_KEY$1].includes(event.key);
  6231. if (!isUpOrDownEvent && !isEscapeEvent) {
  6232. return;
  6233. }
  6234. if (isInput && !isEscapeEvent) {
  6235. return;
  6236. }
  6237. event.preventDefault();
  6238. 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);
  6239. const instance = Dropdown.getOrCreateInstance(getToggleButton);
  6240. if (isUpOrDownEvent) {
  6241. event.stopPropagation();
  6242. instance.show();
  6243. instance._selectMenuItem(event);
  6244. return;
  6245. }
  6246. if (instance._isShown()) {
  6247. event.stopPropagation();
  6248. instance.hide();
  6249. getToggleButton.focus();
  6250. }
  6251. }
  6252. }
  6253. EventHandler.on(document, EVENT_KEYDOWN_DATA_API, SELECTOR_DATA_TOGGLE$3, Dropdown.dataApiKeydownHandler);
  6254. EventHandler.on(document, EVENT_KEYDOWN_DATA_API, SELECTOR_MENU, Dropdown.dataApiKeydownHandler);
  6255. EventHandler.on(document, EVENT_CLICK_DATA_API$3, Dropdown.clearMenus);
  6256. EventHandler.on(document, EVENT_KEYUP_DATA_API, Dropdown.clearMenus);
  6257. EventHandler.on(document, EVENT_CLICK_DATA_API$3, SELECTOR_DATA_TOGGLE$3, function (event) {
  6258. event.preventDefault();
  6259. Dropdown.getOrCreateInstance(this).toggle();
  6260. });
  6261. defineJQueryPlugin(Dropdown);
  6262. const SELECTOR_FIXED_CONTENT = '.fixed-top, .fixed-bottom, .is-fixed, .sticky-top';
  6263. const SELECTOR_STICKY_CONTENT = '.sticky-top';
  6264. const PROPERTY_PADDING = 'padding-right';
  6265. const PROPERTY_MARGIN = 'margin-right';
  6266. class ScrollBarHelper {
  6267. constructor() {
  6268. this._element = document.body;
  6269. }
  6270. getWidth() {
  6271. const documentWidth = document.documentElement.clientWidth;
  6272. return Math.abs(window.innerWidth - documentWidth);
  6273. }
  6274. hide() {
  6275. const width = this.getWidth();
  6276. this._disableOverFlow();
  6277. this._setElementAttributes(this._element, PROPERTY_PADDING, calculatedValue => calculatedValue + width);
  6278. this._setElementAttributes(SELECTOR_FIXED_CONTENT, PROPERTY_PADDING, calculatedValue => calculatedValue + width);
  6279. this._setElementAttributes(SELECTOR_STICKY_CONTENT, PROPERTY_MARGIN, calculatedValue => calculatedValue - width);
  6280. }
  6281. reset() {
  6282. this._resetElementAttributes(this._element, 'overflow');
  6283. this._resetElementAttributes(this._element, PROPERTY_PADDING);
  6284. this._resetElementAttributes(SELECTOR_FIXED_CONTENT, PROPERTY_PADDING);
  6285. this._resetElementAttributes(SELECTOR_STICKY_CONTENT, PROPERTY_MARGIN);
  6286. }
  6287. isOverflowing() {
  6288. return this.getWidth() > 0;
  6289. }
  6290. _disableOverFlow() {
  6291. this._saveInitialAttribute(this._element, 'overflow');
  6292. this._element.style.overflow = 'hidden';
  6293. }
  6294. _setElementAttributes(selector, styleProperty, callback) {
  6295. const scrollbarWidth = this.getWidth();
  6296. const manipulationCallBack = element => {
  6297. if (element !== this._element && window.innerWidth > element.clientWidth + scrollbarWidth) {
  6298. return;
  6299. }
  6300. this._saveInitialAttribute(element, styleProperty);
  6301. const calculatedValue = window.getComputedStyle(element).getPropertyValue(styleProperty);
  6302. element.style.setProperty(styleProperty, `${callback(Number.parseFloat(calculatedValue))}px`);
  6303. };
  6304. this._applyManipulationCallback(selector, manipulationCallBack);
  6305. }
  6306. _saveInitialAttribute(element, styleProperty) {
  6307. const actualValue = element.style.getPropertyValue(styleProperty);
  6308. if (actualValue) {
  6309. Manipulator.setDataAttribute(element, styleProperty, actualValue);
  6310. }
  6311. }
  6312. _resetElementAttributes(selector, styleProperty) {
  6313. const manipulationCallBack = element => {
  6314. const value = Manipulator.getDataAttribute(element, styleProperty);
  6315. if (value === null) {
  6316. element.style.removeProperty(styleProperty);
  6317. return;
  6318. }
  6319. Manipulator.removeDataAttribute(element, styleProperty);
  6320. element.style.setProperty(styleProperty, value);
  6321. };
  6322. this._applyManipulationCallback(selector, manipulationCallBack);
  6323. }
  6324. _applyManipulationCallback(selector, callBack) {
  6325. if (isElement(selector)) {
  6326. callBack(selector);
  6327. return;
  6328. }
  6329. for (const sel of SelectorEngine.find(selector, this._element)) {
  6330. callBack(sel);
  6331. }
  6332. }
  6333. }
  6334. const NAME$9 = 'backdrop';
  6335. const CLASS_NAME_FADE$4 = 'fade';
  6336. const CLASS_NAME_SHOW$5 = 'show';
  6337. const EVENT_MOUSEDOWN = `mousedown.bs.${NAME$9}`;
  6338. const Default$8 = {
  6339. className: 'modal-backdrop',
  6340. clickCallback: null,
  6341. isAnimated: false,
  6342. isVisible: true,
  6343. rootElement: 'body'
  6344. };
  6345. const DefaultType$8 = {
  6346. className: 'string',
  6347. clickCallback: '(function|null)',
  6348. isAnimated: 'boolean',
  6349. isVisible: 'boolean',
  6350. rootElement: '(element|string)'
  6351. };
  6352. class Backdrop extends Config {
  6353. constructor(config) {
  6354. super();
  6355. this._config = this._getConfig(config);
  6356. this._isAppended = false;
  6357. this._element = null;
  6358. }
  6359. static get Default() {
  6360. return Default$8;
  6361. }
  6362. static get DefaultType() {
  6363. return DefaultType$8;
  6364. }
  6365. static get NAME() {
  6366. return NAME$9;
  6367. }
  6368. show(callback) {
  6369. if (!this._config.isVisible) {
  6370. execute(callback);
  6371. return;
  6372. }
  6373. this._append();
  6374. const element = this._getElement();
  6375. if (this._config.isAnimated) {
  6376. reflow(element);
  6377. }
  6378. element.classList.add(CLASS_NAME_SHOW$5);
  6379. this._emulateAnimation(() => {
  6380. execute(callback);
  6381. });
  6382. }
  6383. hide(callback) {
  6384. if (!this._config.isVisible) {
  6385. execute(callback);
  6386. return;
  6387. }
  6388. this._getElement().classList.remove(CLASS_NAME_SHOW$5);
  6389. this._emulateAnimation(() => {
  6390. this.dispose();
  6391. execute(callback);
  6392. });
  6393. }
  6394. dispose() {
  6395. if (!this._isAppended) {
  6396. return;
  6397. }
  6398. EventHandler.off(this._element, EVENT_MOUSEDOWN);
  6399. this._element.remove();
  6400. this._isAppended = false;
  6401. }
  6402. _getElement() {
  6403. if (!this._element) {
  6404. const backdrop = document.createElement('div');
  6405. backdrop.className = this._config.className;
  6406. if (this._config.isAnimated) {
  6407. backdrop.classList.add(CLASS_NAME_FADE$4);
  6408. }
  6409. this._element = backdrop;
  6410. }
  6411. return this._element;
  6412. }
  6413. _configAfterMerge(config) {
  6414. config.rootElement = getElement(config.rootElement);
  6415. return config;
  6416. }
  6417. _append() {
  6418. if (this._isAppended) {
  6419. return;
  6420. }
  6421. const element = this._getElement();
  6422. this._config.rootElement.append(element);
  6423. EventHandler.on(element, EVENT_MOUSEDOWN, () => {
  6424. execute(this._config.clickCallback);
  6425. });
  6426. this._isAppended = true;
  6427. }
  6428. _emulateAnimation(callback) {
  6429. executeAfterTransition(callback, this._getElement(), this._config.isAnimated);
  6430. }
  6431. }
  6432. const NAME$8 = 'focustrap';
  6433. const DATA_KEY$5 = 'bs.focustrap';
  6434. const EVENT_KEY$5 = `.${DATA_KEY$5}`;
  6435. const EVENT_FOCUSIN$2 = `focusin${EVENT_KEY$5}`;
  6436. const EVENT_KEYDOWN_TAB = `keydown.tab${EVENT_KEY$5}`;
  6437. const TAB_KEY = 'Tab';
  6438. const TAB_NAV_FORWARD = 'forward';
  6439. const TAB_NAV_BACKWARD = 'backward';
  6440. const Default$7 = {
  6441. autofocus: true,
  6442. trapElement: null
  6443. };
  6444. const DefaultType$7 = {
  6445. autofocus: 'boolean',
  6446. trapElement: 'element'
  6447. };
  6448. class FocusTrap extends Config {
  6449. constructor(config) {
  6450. super();
  6451. this._config = this._getConfig(config);
  6452. this._isActive = false;
  6453. this._lastTabNavDirection = null;
  6454. }
  6455. static get Default() {
  6456. return Default$7;
  6457. }
  6458. static get DefaultType() {
  6459. return DefaultType$7;
  6460. }
  6461. static get NAME() {
  6462. return NAME$8;
  6463. }
  6464. activate() {
  6465. if (this._isActive) {
  6466. return;
  6467. }
  6468. if (this._config.autofocus) {
  6469. this._config.trapElement.focus();
  6470. }
  6471. EventHandler.off(document, EVENT_KEY$5);
  6472. EventHandler.on(document, EVENT_FOCUSIN$2, event => this._handleFocusin(event));
  6473. EventHandler.on(document, EVENT_KEYDOWN_TAB, event => this._handleKeydown(event));
  6474. this._isActive = true;
  6475. }
  6476. deactivate() {
  6477. if (!this._isActive) {
  6478. return;
  6479. }
  6480. this._isActive = false;
  6481. EventHandler.off(document, EVENT_KEY$5);
  6482. }
  6483. _handleFocusin(event) {
  6484. const {
  6485. trapElement
  6486. } = this._config;
  6487. if (event.target === document || event.target === trapElement || trapElement.contains(event.target)) {
  6488. return;
  6489. }
  6490. const elements = SelectorEngine.focusableChildren(trapElement);
  6491. if (elements.length === 0) {
  6492. trapElement.focus();
  6493. } else if (this._lastTabNavDirection === TAB_NAV_BACKWARD) {
  6494. elements[elements.length - 1].focus();
  6495. } else {
  6496. elements[0].focus();
  6497. }
  6498. }
  6499. _handleKeydown(event) {
  6500. if (event.key !== TAB_KEY) {
  6501. return;
  6502. }
  6503. this._lastTabNavDirection = event.shiftKey ? TAB_NAV_BACKWARD : TAB_NAV_FORWARD;
  6504. }
  6505. }
  6506. const NAME$7 = 'modal';
  6507. const DATA_KEY$4 = 'bs.modal';
  6508. const EVENT_KEY$4 = `.${DATA_KEY$4}`;
  6509. const DATA_API_KEY$2 = '.data-api';
  6510. const ESCAPE_KEY$1 = 'Escape';
  6511. const EVENT_HIDE$4 = `hide${EVENT_KEY$4}`;
  6512. const EVENT_HIDE_PREVENTED$1 = `hidePrevented${EVENT_KEY$4}`;
  6513. const EVENT_HIDDEN$4 = `hidden${EVENT_KEY$4}`;
  6514. const EVENT_SHOW$4 = `show${EVENT_KEY$4}`;
  6515. const EVENT_SHOWN$4 = `shown${EVENT_KEY$4}`;
  6516. const EVENT_RESIZE$1 = `resize${EVENT_KEY$4}`;
  6517. const EVENT_CLICK_DISMISS = `click.dismiss${EVENT_KEY$4}`;
  6518. const EVENT_MOUSEDOWN_DISMISS = `mousedown.dismiss${EVENT_KEY$4}`;
  6519. const EVENT_KEYDOWN_DISMISS$1 = `keydown.dismiss${EVENT_KEY$4}`;
  6520. const EVENT_CLICK_DATA_API$2 = `click${EVENT_KEY$4}${DATA_API_KEY$2}`;
  6521. const CLASS_NAME_OPEN = 'modal-open';
  6522. const CLASS_NAME_FADE$3 = 'fade';
  6523. const CLASS_NAME_SHOW$4 = 'show';
  6524. const CLASS_NAME_STATIC = 'modal-static';
  6525. const OPEN_SELECTOR$1 = '.modal.show';
  6526. const SELECTOR_DIALOG = '.modal-dialog';
  6527. const SELECTOR_MODAL_BODY = '.modal-body';
  6528. const SELECTOR_DATA_TOGGLE$2 = '[data-bs-toggle="modal"]';
  6529. const Default$6 = {
  6530. backdrop: true,
  6531. focus: true,
  6532. keyboard: true
  6533. };
  6534. const DefaultType$6 = {
  6535. backdrop: '(boolean|string)',
  6536. focus: 'boolean',
  6537. keyboard: 'boolean'
  6538. };
  6539. class Modal extends BaseComponent {
  6540. constructor(element, config) {
  6541. super(element, config);
  6542. this._dialog = SelectorEngine.findOne(SELECTOR_DIALOG, this._element);
  6543. this._backdrop = this._initializeBackDrop();
  6544. this._focustrap = this._initializeFocusTrap();
  6545. this._isShown = false;
  6546. this._isTransitioning = false;
  6547. this._scrollBar = new ScrollBarHelper();
  6548. this._addEventListeners();
  6549. }
  6550. static get Default() {
  6551. return Default$6;
  6552. }
  6553. static get DefaultType() {
  6554. return DefaultType$6;
  6555. }
  6556. static get NAME() {
  6557. return NAME$7;
  6558. }
  6559. toggle(relatedTarget) {
  6560. return this._isShown ? this.hide() : this.show(relatedTarget);
  6561. }
  6562. show(relatedTarget) {
  6563. if (this._isShown || this._isTransitioning) {
  6564. return;
  6565. }
  6566. const showEvent = EventHandler.trigger(this._element, EVENT_SHOW$4, {
  6567. relatedTarget
  6568. });
  6569. if (showEvent.defaultPrevented) {
  6570. return;
  6571. }
  6572. this._isShown = true;
  6573. this._isTransitioning = true;
  6574. this._scrollBar.hide();
  6575. document.body.classList.add(CLASS_NAME_OPEN);
  6576. this._adjustDialog();
  6577. this._backdrop.show(() => this._showElement(relatedTarget));
  6578. }
  6579. hide() {
  6580. if (!this._isShown || this._isTransitioning) {
  6581. return;
  6582. }
  6583. const hideEvent = EventHandler.trigger(this._element, EVENT_HIDE$4);
  6584. if (hideEvent.defaultPrevented) {
  6585. return;
  6586. }
  6587. this._isShown = false;
  6588. this._isTransitioning = true;
  6589. this._focustrap.deactivate();
  6590. this._element.classList.remove(CLASS_NAME_SHOW$4);
  6591. this._queueCallback(() => this._hideModal(), this._element, this._isAnimated());
  6592. }
  6593. dispose() {
  6594. for (const htmlElement of [window, this._dialog]) {
  6595. EventHandler.off(htmlElement, EVENT_KEY$4);
  6596. }
  6597. this._backdrop.dispose();
  6598. this._focustrap.deactivate();
  6599. super.dispose();
  6600. }
  6601. handleUpdate() {
  6602. this._adjustDialog();
  6603. }
  6604. _initializeBackDrop() {
  6605. return new Backdrop({
  6606. isVisible: Boolean(this._config.backdrop),
  6607. isAnimated: this._isAnimated()
  6608. });
  6609. }
  6610. _initializeFocusTrap() {
  6611. return new FocusTrap({
  6612. trapElement: this._element
  6613. });
  6614. }
  6615. _showElement(relatedTarget) {
  6616. if (!document.body.contains(this._element)) {
  6617. document.body.append(this._element);
  6618. }
  6619. this._element.style.display = 'block';
  6620. this._element.removeAttribute('aria-hidden');
  6621. this._element.setAttribute('aria-modal', true);
  6622. this._element.setAttribute('role', 'dialog');
  6623. this._element.scrollTop = 0;
  6624. const modalBody = SelectorEngine.findOne(SELECTOR_MODAL_BODY, this._dialog);
  6625. if (modalBody) {
  6626. modalBody.scrollTop = 0;
  6627. }
  6628. reflow(this._element);
  6629. this._element.classList.add(CLASS_NAME_SHOW$4);
  6630. const transitionComplete = () => {
  6631. if (this._config.focus) {
  6632. this._focustrap.activate();
  6633. }
  6634. this._isTransitioning = false;
  6635. EventHandler.trigger(this._element, EVENT_SHOWN$4, {
  6636. relatedTarget
  6637. });
  6638. };
  6639. this._queueCallback(transitionComplete, this._dialog, this._isAnimated());
  6640. }
  6641. _addEventListeners() {
  6642. EventHandler.on(this._element, EVENT_KEYDOWN_DISMISS$1, event => {
  6643. if (event.key !== ESCAPE_KEY$1) {
  6644. return;
  6645. }
  6646. if (this._config.keyboard) {
  6647. event.preventDefault();
  6648. this.hide();
  6649. return;
  6650. }
  6651. this._triggerBackdropTransition();
  6652. });
  6653. EventHandler.on(window, EVENT_RESIZE$1, () => {
  6654. if (this._isShown && !this._isTransitioning) {
  6655. this._adjustDialog();
  6656. }
  6657. });
  6658. EventHandler.on(this._element, EVENT_MOUSEDOWN_DISMISS, event => {
  6659. EventHandler.one(this._element, EVENT_CLICK_DISMISS, event2 => {
  6660. if (this._element !== event.target || this._element !== event2.target) {
  6661. return;
  6662. }
  6663. if (this._config.backdrop === 'static') {
  6664. this._triggerBackdropTransition();
  6665. return;
  6666. }
  6667. if (this._config.backdrop) {
  6668. this.hide();
  6669. }
  6670. });
  6671. });
  6672. }
  6673. _hideModal() {
  6674. this._element.style.display = 'none';
  6675. this._element.setAttribute('aria-hidden', true);
  6676. this._element.removeAttribute('aria-modal');
  6677. this._element.removeAttribute('role');
  6678. this._isTransitioning = false;
  6679. this._backdrop.hide(() => {
  6680. document.body.classList.remove(CLASS_NAME_OPEN);
  6681. this._resetAdjustments();
  6682. this._scrollBar.reset();
  6683. EventHandler.trigger(this._element, EVENT_HIDDEN$4);
  6684. });
  6685. }
  6686. _isAnimated() {
  6687. return this._element.classList.contains(CLASS_NAME_FADE$3);
  6688. }
  6689. _triggerBackdropTransition() {
  6690. const hideEvent = EventHandler.trigger(this._element, EVENT_HIDE_PREVENTED$1);
  6691. if (hideEvent.defaultPrevented) {
  6692. return;
  6693. }
  6694. const isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight;
  6695. const initialOverflowY = this._element.style.overflowY;
  6696. if (initialOverflowY === 'hidden' || this._element.classList.contains(CLASS_NAME_STATIC)) {
  6697. return;
  6698. }
  6699. if (!isModalOverflowing) {
  6700. this._element.style.overflowY = 'hidden';
  6701. }
  6702. this._element.classList.add(CLASS_NAME_STATIC);
  6703. this._queueCallback(() => {
  6704. this._element.classList.remove(CLASS_NAME_STATIC);
  6705. this._queueCallback(() => {
  6706. this._element.style.overflowY = initialOverflowY;
  6707. }, this._dialog);
  6708. }, this._dialog);
  6709. this._element.focus();
  6710. }
  6711. _adjustDialog() {
  6712. const isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight;
  6713. const scrollbarWidth = this._scrollBar.getWidth();
  6714. const isBodyOverflowing = scrollbarWidth > 0;
  6715. if (isBodyOverflowing && !isModalOverflowing) {
  6716. const property = isRTL() ? 'paddingLeft' : 'paddingRight';
  6717. this._element.style[property] = `${scrollbarWidth}px`;
  6718. }
  6719. if (!isBodyOverflowing && isModalOverflowing) {
  6720. const property = isRTL() ? 'paddingRight' : 'paddingLeft';
  6721. this._element.style[property] = `${scrollbarWidth}px`;
  6722. }
  6723. }
  6724. _resetAdjustments() {
  6725. this._element.style.paddingLeft = '';
  6726. this._element.style.paddingRight = '';
  6727. }
  6728. static jQueryInterface(config, relatedTarget) {
  6729. return this.each(function () {
  6730. const data = Modal.getOrCreateInstance(this, config);
  6731. if (typeof config !== 'string') {
  6732. return;
  6733. }
  6734. if (typeof data[config] === 'undefined') {
  6735. throw new TypeError(`No method named "${config}"`);
  6736. }
  6737. data[config](relatedTarget);
  6738. });
  6739. }
  6740. }
  6741. EventHandler.on(document, EVENT_CLICK_DATA_API$2, SELECTOR_DATA_TOGGLE$2, function (event) {
  6742. const target = SelectorEngine.getElementFromSelector(this);
  6743. if (['A', 'AREA'].includes(this.tagName)) {
  6744. event.preventDefault();
  6745. }
  6746. EventHandler.one(target, EVENT_SHOW$4, showEvent => {
  6747. if (showEvent.defaultPrevented) {
  6748. return;
  6749. }
  6750. EventHandler.one(target, EVENT_HIDDEN$4, () => {
  6751. if (isVisible(this)) {
  6752. this.focus();
  6753. }
  6754. });
  6755. });
  6756. const alreadyOpen = SelectorEngine.findOne(OPEN_SELECTOR$1);
  6757. if (alreadyOpen) {
  6758. Modal.getInstance(alreadyOpen).hide();
  6759. }
  6760. const data = Modal.getOrCreateInstance(target);
  6761. data.toggle(this);
  6762. });
  6763. enableDismissTrigger(Modal);
  6764. defineJQueryPlugin(Modal);
  6765. const NAME$6 = 'offcanvas';
  6766. const DATA_KEY$3 = 'bs.offcanvas';
  6767. const EVENT_KEY$3 = `.${DATA_KEY$3}`;
  6768. const DATA_API_KEY$1 = '.data-api';
  6769. const EVENT_LOAD_DATA_API$2 = `load${EVENT_KEY$3}${DATA_API_KEY$1}`;
  6770. const ESCAPE_KEY = 'Escape';
  6771. const CLASS_NAME_SHOW$3 = 'show';
  6772. const CLASS_NAME_SHOWING$1 = 'showing';
  6773. const CLASS_NAME_HIDING = 'hiding';
  6774. const CLASS_NAME_BACKDROP = 'offcanvas-backdrop';
  6775. const OPEN_SELECTOR = '.offcanvas.show';
  6776. const EVENT_SHOW$3 = `show${EVENT_KEY$3}`;
  6777. const EVENT_SHOWN$3 = `shown${EVENT_KEY$3}`;
  6778. const EVENT_HIDE$3 = `hide${EVENT_KEY$3}`;
  6779. const EVENT_HIDE_PREVENTED = `hidePrevented${EVENT_KEY$3}`;
  6780. const EVENT_HIDDEN$3 = `hidden${EVENT_KEY$3}`;
  6781. const EVENT_RESIZE = `resize${EVENT_KEY$3}`;
  6782. const EVENT_CLICK_DATA_API$1 = `click${EVENT_KEY$3}${DATA_API_KEY$1}`;
  6783. const EVENT_KEYDOWN_DISMISS = `keydown.dismiss${EVENT_KEY$3}`;
  6784. const SELECTOR_DATA_TOGGLE$1 = '[data-bs-toggle="offcanvas"]';
  6785. const Default$5 = {
  6786. backdrop: true,
  6787. keyboard: true,
  6788. scroll: false
  6789. };
  6790. const DefaultType$5 = {
  6791. backdrop: '(boolean|string)',
  6792. keyboard: 'boolean',
  6793. scroll: 'boolean'
  6794. };
  6795. class Offcanvas extends BaseComponent {
  6796. constructor(element, config) {
  6797. super(element, config);
  6798. this._isShown = false;
  6799. this._backdrop = this._initializeBackDrop();
  6800. this._focustrap = this._initializeFocusTrap();
  6801. this._addEventListeners();
  6802. }
  6803. static get Default() {
  6804. return Default$5;
  6805. }
  6806. static get DefaultType() {
  6807. return DefaultType$5;
  6808. }
  6809. static get NAME() {
  6810. return NAME$6;
  6811. }
  6812. toggle(relatedTarget) {
  6813. return this._isShown ? this.hide() : this.show(relatedTarget);
  6814. }
  6815. show(relatedTarget) {
  6816. if (this._isShown) {
  6817. return;
  6818. }
  6819. const showEvent = EventHandler.trigger(this._element, EVENT_SHOW$3, {
  6820. relatedTarget
  6821. });
  6822. if (showEvent.defaultPrevented) {
  6823. return;
  6824. }
  6825. this._isShown = true;
  6826. this._backdrop.show();
  6827. if (!this._config.scroll) {
  6828. new ScrollBarHelper().hide();
  6829. }
  6830. this._element.setAttribute('aria-modal', true);
  6831. this._element.setAttribute('role', 'dialog');
  6832. this._element.classList.add(CLASS_NAME_SHOWING$1);
  6833. const completeCallBack = () => {
  6834. if (!this._config.scroll || this._config.backdrop) {
  6835. this._focustrap.activate();
  6836. }
  6837. this._element.classList.add(CLASS_NAME_SHOW$3);
  6838. this._element.classList.remove(CLASS_NAME_SHOWING$1);
  6839. EventHandler.trigger(this._element, EVENT_SHOWN$3, {
  6840. relatedTarget
  6841. });
  6842. };
  6843. this._queueCallback(completeCallBack, this._element, true);
  6844. }
  6845. hide() {
  6846. if (!this._isShown) {
  6847. return;
  6848. }
  6849. const hideEvent = EventHandler.trigger(this._element, EVENT_HIDE$3);
  6850. if (hideEvent.defaultPrevented) {
  6851. return;
  6852. }
  6853. this._focustrap.deactivate();
  6854. this._element.blur();
  6855. this._isShown = false;
  6856. this._element.classList.add(CLASS_NAME_HIDING);
  6857. this._backdrop.hide();
  6858. const completeCallback = () => {
  6859. this._element.classList.remove(CLASS_NAME_SHOW$3, CLASS_NAME_HIDING);
  6860. this._element.removeAttribute('aria-modal');
  6861. this._element.removeAttribute('role');
  6862. if (!this._config.scroll) {
  6863. new ScrollBarHelper().reset();
  6864. }
  6865. EventHandler.trigger(this._element, EVENT_HIDDEN$3);
  6866. };
  6867. this._queueCallback(completeCallback, this._element, true);
  6868. }
  6869. dispose() {
  6870. this._backdrop.dispose();
  6871. this._focustrap.deactivate();
  6872. super.dispose();
  6873. }
  6874. _initializeBackDrop() {
  6875. const clickCallback = () => {
  6876. if (this._config.backdrop === 'static') {
  6877. EventHandler.trigger(this._element, EVENT_HIDE_PREVENTED);
  6878. return;
  6879. }
  6880. this.hide();
  6881. };
  6882. const isVisible = Boolean(this._config.backdrop);
  6883. return new Backdrop({
  6884. className: CLASS_NAME_BACKDROP,
  6885. isVisible,
  6886. isAnimated: true,
  6887. rootElement: this._element.parentNode,
  6888. clickCallback: isVisible ? clickCallback : null
  6889. });
  6890. }
  6891. _initializeFocusTrap() {
  6892. return new FocusTrap({
  6893. trapElement: this._element
  6894. });
  6895. }
  6896. _addEventListeners() {
  6897. EventHandler.on(this._element, EVENT_KEYDOWN_DISMISS, event => {
  6898. if (event.key !== ESCAPE_KEY) {
  6899. return;
  6900. }
  6901. if (!this._config.keyboard) {
  6902. EventHandler.trigger(this._element, EVENT_HIDE_PREVENTED);
  6903. return;
  6904. }
  6905. this.hide();
  6906. });
  6907. }
  6908. static jQueryInterface(config) {
  6909. return this.each(function () {
  6910. const data = Offcanvas.getOrCreateInstance(this, config);
  6911. if (typeof config !== 'string') {
  6912. return;
  6913. }
  6914. if (data[config] === undefined || config.startsWith('_') || config === 'constructor') {
  6915. throw new TypeError(`No method named "${config}"`);
  6916. }
  6917. data[config](this);
  6918. });
  6919. }
  6920. }
  6921. EventHandler.on(document, EVENT_CLICK_DATA_API$1, SELECTOR_DATA_TOGGLE$1, function (event) {
  6922. const target = SelectorEngine.getElementFromSelector(this);
  6923. if (['A', 'AREA'].includes(this.tagName)) {
  6924. event.preventDefault();
  6925. }
  6926. if (isDisabled(this)) {
  6927. return;
  6928. }
  6929. EventHandler.one(target, EVENT_HIDDEN$3, () => {
  6930. if (isVisible(this)) {
  6931. this.focus();
  6932. }
  6933. });
  6934. const alreadyOpen = SelectorEngine.findOne(OPEN_SELECTOR);
  6935. if (alreadyOpen && alreadyOpen !== target) {
  6936. Offcanvas.getInstance(alreadyOpen).hide();
  6937. }
  6938. const data = Offcanvas.getOrCreateInstance(target);
  6939. data.toggle(this);
  6940. });
  6941. EventHandler.on(window, EVENT_LOAD_DATA_API$2, () => {
  6942. for (const selector of SelectorEngine.find(OPEN_SELECTOR)) {
  6943. Offcanvas.getOrCreateInstance(selector).show();
  6944. }
  6945. });
  6946. EventHandler.on(window, EVENT_RESIZE, () => {
  6947. for (const element of SelectorEngine.find('[aria-modal][class*=show][class*=offcanvas-]')) {
  6948. if (getComputedStyle(element).position !== 'fixed') {
  6949. Offcanvas.getOrCreateInstance(element).hide();
  6950. }
  6951. }
  6952. });
  6953. enableDismissTrigger(Offcanvas);
  6954. defineJQueryPlugin(Offcanvas);
  6955. const uriAttributes = new Set(['background', 'cite', 'href', 'itemtype', 'longdesc', 'poster', 'src', 'xlink:href']);
  6956. const ARIA_ATTRIBUTE_PATTERN = /^aria-[\w-]*$/i;
  6957. const SAFE_URL_PATTERN = /^(?:(?:https?|mailto|ftp|tel|file|sms):|[^#&/:?]*(?:[#/?]|$))/i;
  6958. const DATA_URL_PATTERN = /^data:(?:image\/(?:bmp|gif|jpeg|jpg|png|tiff|webp)|video\/(?:mpeg|mp4|ogg|webm)|audio\/(?:mp3|oga|ogg|opus));base64,[\d+/a-z]+=*$/i;
  6959. const allowedAttribute = (attribute, allowedAttributeList) => {
  6960. const attributeName = attribute.nodeName.toLowerCase();
  6961. if (allowedAttributeList.includes(attributeName)) {
  6962. if (uriAttributes.has(attributeName)) {
  6963. return Boolean(SAFE_URL_PATTERN.test(attribute.nodeValue) || DATA_URL_PATTERN.test(attribute.nodeValue));
  6964. }
  6965. return true;
  6966. }
  6967. return allowedAttributeList.filter(attributeRegex => attributeRegex instanceof RegExp).some(regex => regex.test(attributeName));
  6968. };
  6969. const DefaultAllowlist = {
  6970. '*': ['class', 'dir', 'id', 'lang', 'role', ARIA_ATTRIBUTE_PATTERN],
  6971. a: ['target', 'href', 'title', 'rel'],
  6972. area: [],
  6973. b: [],
  6974. br: [],
  6975. col: [],
  6976. code: [],
  6977. div: [],
  6978. em: [],
  6979. hr: [],
  6980. h1: [],
  6981. h2: [],
  6982. h3: [],
  6983. h4: [],
  6984. h5: [],
  6985. h6: [],
  6986. i: [],
  6987. img: ['src', 'srcset', 'alt', 'title', 'width', 'height'],
  6988. li: [],
  6989. ol: [],
  6990. p: [],
  6991. pre: [],
  6992. s: [],
  6993. small: [],
  6994. span: [],
  6995. sub: [],
  6996. sup: [],
  6997. strong: [],
  6998. u: [],
  6999. ul: []
  7000. };
  7001. function sanitizeHtml(unsafeHtml, allowList, sanitizeFunction) {
  7002. if (!unsafeHtml.length) {
  7003. return unsafeHtml;
  7004. }
  7005. if (sanitizeFunction && typeof sanitizeFunction === 'function') {
  7006. return sanitizeFunction(unsafeHtml);
  7007. }
  7008. const domParser = new window.DOMParser();
  7009. const createdDocument = domParser.parseFromString(unsafeHtml, 'text/html');
  7010. const elements = [].concat(...createdDocument.body.querySelectorAll('*'));
  7011. for (const element of elements) {
  7012. const elementName = element.nodeName.toLowerCase();
  7013. if (!Object.keys(allowList).includes(elementName)) {
  7014. element.remove();
  7015. continue;
  7016. }
  7017. const attributeList = [].concat(...element.attributes);
  7018. const allowedAttributes = [].concat(allowList['*'] || [], allowList[elementName] || []);
  7019. for (const attribute of attributeList) {
  7020. if (!allowedAttribute(attribute, allowedAttributes)) {
  7021. element.removeAttribute(attribute.nodeName);
  7022. }
  7023. }
  7024. }
  7025. return createdDocument.body.innerHTML;
  7026. }
  7027. const NAME$5 = 'TemplateFactory';
  7028. const Default$4 = {
  7029. allowList: DefaultAllowlist,
  7030. content: {},
  7031. extraClass: '',
  7032. html: false,
  7033. sanitize: true,
  7034. sanitizeFn: null,
  7035. template: '<div></div>'
  7036. };
  7037. const DefaultType$4 = {
  7038. allowList: 'object',
  7039. content: 'object',
  7040. extraClass: '(string|function)',
  7041. html: 'boolean',
  7042. sanitize: 'boolean',
  7043. sanitizeFn: '(null|function)',
  7044. template: 'string'
  7045. };
  7046. const DefaultContentType = {
  7047. entry: '(string|element|function|null)',
  7048. selector: '(string|element)'
  7049. };
  7050. class TemplateFactory extends Config {
  7051. constructor(config) {
  7052. super();
  7053. this._config = this._getConfig(config);
  7054. }
  7055. static get Default() {
  7056. return Default$4;
  7057. }
  7058. static get DefaultType() {
  7059. return DefaultType$4;
  7060. }
  7061. static get NAME() {
  7062. return NAME$5;
  7063. }
  7064. getContent() {
  7065. return Object.values(this._config.content).map(config => this._resolvePossibleFunction(config)).filter(Boolean);
  7066. }
  7067. hasContent() {
  7068. return this.getContent().length > 0;
  7069. }
  7070. changeContent(content) {
  7071. this._checkContent(content);
  7072. this._config.content = {
  7073. ...this._config.content,
  7074. ...content
  7075. };
  7076. return this;
  7077. }
  7078. toHtml() {
  7079. const templateWrapper = document.createElement('div');
  7080. templateWrapper.innerHTML = this._maybeSanitize(this._config.template);
  7081. for (const [selector, text] of Object.entries(this._config.content)) {
  7082. this._setContent(templateWrapper, text, selector);
  7083. }
  7084. const template = templateWrapper.children[0];
  7085. const extraClass = this._resolvePossibleFunction(this._config.extraClass);
  7086. if (extraClass) {
  7087. template.classList.add(...extraClass.split(' '));
  7088. }
  7089. return template;
  7090. }
  7091. _typeCheckConfig(config) {
  7092. super._typeCheckConfig(config);
  7093. this._checkContent(config.content);
  7094. }
  7095. _checkContent(arg) {
  7096. for (const [selector, content] of Object.entries(arg)) {
  7097. super._typeCheckConfig({
  7098. selector,
  7099. entry: content
  7100. }, DefaultContentType);
  7101. }
  7102. }
  7103. _setContent(template, content, selector) {
  7104. const templateElement = SelectorEngine.findOne(selector, template);
  7105. if (!templateElement) {
  7106. return;
  7107. }
  7108. content = this._resolvePossibleFunction(content);
  7109. if (!content) {
  7110. templateElement.remove();
  7111. return;
  7112. }
  7113. if (isElement(content)) {
  7114. this._putElementInTemplate(getElement(content), templateElement);
  7115. return;
  7116. }
  7117. if (this._config.html) {
  7118. templateElement.innerHTML = this._maybeSanitize(content);
  7119. return;
  7120. }
  7121. templateElement.textContent = content;
  7122. }
  7123. _maybeSanitize(arg) {
  7124. return this._config.sanitize ? sanitizeHtml(arg, this._config.allowList, this._config.sanitizeFn) : arg;
  7125. }
  7126. _resolvePossibleFunction(arg) {
  7127. return execute(arg, [this]);
  7128. }
  7129. _putElementInTemplate(element, templateElement) {
  7130. if (this._config.html) {
  7131. templateElement.innerHTML = '';
  7132. templateElement.append(element);
  7133. return;
  7134. }
  7135. templateElement.textContent = element.textContent;
  7136. }
  7137. }
  7138. const NAME$4 = 'tooltip';
  7139. const DISALLOWED_ATTRIBUTES = new Set(['sanitize', 'allowList', 'sanitizeFn']);
  7140. const CLASS_NAME_FADE$2 = 'fade';
  7141. const CLASS_NAME_MODAL = 'modal';
  7142. const CLASS_NAME_SHOW$2 = 'show';
  7143. const SELECTOR_TOOLTIP_INNER = '.tooltip-inner';
  7144. const SELECTOR_MODAL = `.${CLASS_NAME_MODAL}`;
  7145. const EVENT_MODAL_HIDE = 'hide.bs.modal';
  7146. const TRIGGER_HOVER = 'hover';
  7147. const TRIGGER_FOCUS = 'focus';
  7148. const TRIGGER_CLICK = 'click';
  7149. const TRIGGER_MANUAL = 'manual';
  7150. const EVENT_HIDE$2 = 'hide';
  7151. const EVENT_HIDDEN$2 = 'hidden';
  7152. const EVENT_SHOW$2 = 'show';
  7153. const EVENT_SHOWN$2 = 'shown';
  7154. const EVENT_INSERTED = 'inserted';
  7155. const EVENT_CLICK$1 = 'click';
  7156. const EVENT_FOCUSIN$1 = 'focusin';
  7157. const EVENT_FOCUSOUT$1 = 'focusout';
  7158. const EVENT_MOUSEENTER = 'mouseenter';
  7159. const EVENT_MOUSELEAVE = 'mouseleave';
  7160. const AttachmentMap = {
  7161. AUTO: 'auto',
  7162. TOP: 'top',
  7163. RIGHT: isRTL() ? 'left' : 'right',
  7164. BOTTOM: 'bottom',
  7165. LEFT: isRTL() ? 'right' : 'left'
  7166. };
  7167. const Default$3 = {
  7168. allowList: DefaultAllowlist,
  7169. animation: true,
  7170. boundary: 'clippingParents',
  7171. container: false,
  7172. customClass: '',
  7173. delay: 0,
  7174. fallbackPlacements: ['top', 'right', 'bottom', 'left'],
  7175. html: false,
  7176. offset: [0, 0],
  7177. placement: 'top',
  7178. popperConfig: null,
  7179. sanitize: true,
  7180. sanitizeFn: null,
  7181. selector: false,
  7182. template: '<div class="tooltip" role="tooltip">' + '<div class="tooltip-arrow"></div>' + '<div class="tooltip-inner"></div>' + '</div>',
  7183. title: '',
  7184. trigger: 'hover focus'
  7185. };
  7186. const DefaultType$3 = {
  7187. allowList: 'object',
  7188. animation: 'boolean',
  7189. boundary: '(string|element)',
  7190. container: '(string|element|boolean)',
  7191. customClass: '(string|function)',
  7192. delay: '(number|object)',
  7193. fallbackPlacements: 'array',
  7194. html: 'boolean',
  7195. offset: '(array|string|function)',
  7196. placement: '(string|function)',
  7197. popperConfig: '(null|object|function)',
  7198. sanitize: 'boolean',
  7199. sanitizeFn: '(null|function)',
  7200. selector: '(string|boolean)',
  7201. template: 'string',
  7202. title: '(string|element|function)',
  7203. trigger: 'string'
  7204. };
  7205. class Tooltip extends BaseComponent {
  7206. constructor(element, config) {
  7207. if (typeof Popper === 'undefined') {
  7208. throw new TypeError('Bootstrap\'s tooltips require Popper (https://popper.js.org)');
  7209. }
  7210. super(element, config);
  7211. this._isEnabled = true;
  7212. this._timeout = 0;
  7213. this._isHovered = null;
  7214. this._activeTrigger = {};
  7215. this._popper = null;
  7216. this._templateFactory = null;
  7217. this._newContent = null;
  7218. this.tip = null;
  7219. this._setListeners();
  7220. if (!this._config.selector) {
  7221. this._fixTitle();
  7222. }
  7223. }
  7224. static get Default() {
  7225. return Default$3;
  7226. }
  7227. static get DefaultType() {
  7228. return DefaultType$3;
  7229. }
  7230. static get NAME() {
  7231. return NAME$4;
  7232. }
  7233. enable() {
  7234. this._isEnabled = true;
  7235. }
  7236. disable() {
  7237. this._isEnabled = false;
  7238. }
  7239. toggleEnabled() {
  7240. this._isEnabled = !this._isEnabled;
  7241. }
  7242. toggle() {
  7243. if (!this._isEnabled) {
  7244. return;
  7245. }
  7246. this._activeTrigger.click = !this._activeTrigger.click;
  7247. if (this._isShown()) {
  7248. this._leave();
  7249. return;
  7250. }
  7251. this._enter();
  7252. }
  7253. dispose() {
  7254. clearTimeout(this._timeout);
  7255. EventHandler.off(this._element.closest(SELECTOR_MODAL), EVENT_MODAL_HIDE, this._hideModalHandler);
  7256. if (this._element.getAttribute('data-bs-original-title')) {
  7257. this._element.setAttribute('title', this._element.getAttribute('data-bs-original-title'));
  7258. }
  7259. this._disposePopper();
  7260. super.dispose();
  7261. }
  7262. show() {
  7263. if (this._element.style.display === 'none') {
  7264. throw new Error('Please use show on visible elements');
  7265. }
  7266. if (!(this._isWithContent() && this._isEnabled)) {
  7267. return;
  7268. }
  7269. const showEvent = EventHandler.trigger(this._element, this.constructor.eventName(EVENT_SHOW$2));
  7270. const shadowRoot = findShadowRoot(this._element);
  7271. const isInTheDom = (shadowRoot || this._element.ownerDocument.documentElement).contains(this._element);
  7272. if (showEvent.defaultPrevented || !isInTheDom) {
  7273. return;
  7274. }
  7275. this._disposePopper();
  7276. const tip = this._getTipElement();
  7277. this._element.setAttribute('aria-describedby', tip.getAttribute('id'));
  7278. const {
  7279. container
  7280. } = this._config;
  7281. if (!this._element.ownerDocument.documentElement.contains(this.tip)) {
  7282. container.append(tip);
  7283. EventHandler.trigger(this._element, this.constructor.eventName(EVENT_INSERTED));
  7284. }
  7285. this._popper = this._createPopper(tip);
  7286. tip.classList.add(CLASS_NAME_SHOW$2);
  7287. if ('ontouchstart' in document.documentElement) {
  7288. for (const element of [].concat(...document.body.children)) {
  7289. EventHandler.on(element, 'mouseover', noop);
  7290. }
  7291. }
  7292. const complete = () => {
  7293. EventHandler.trigger(this._element, this.constructor.eventName(EVENT_SHOWN$2));
  7294. if (this._isHovered === false) {
  7295. this._leave();
  7296. }
  7297. this._isHovered = false;
  7298. };
  7299. this._queueCallback(complete, this.tip, this._isAnimated());
  7300. }
  7301. hide() {
  7302. if (!this._isShown()) {
  7303. return;
  7304. }
  7305. const hideEvent = EventHandler.trigger(this._element, this.constructor.eventName(EVENT_HIDE$2));
  7306. if (hideEvent.defaultPrevented) {
  7307. return;
  7308. }
  7309. const tip = this._getTipElement();
  7310. tip.classList.remove(CLASS_NAME_SHOW$2);
  7311. if ('ontouchstart' in document.documentElement) {
  7312. for (const element of [].concat(...document.body.children)) {
  7313. EventHandler.off(element, 'mouseover', noop);
  7314. }
  7315. }
  7316. this._activeTrigger[TRIGGER_CLICK] = false;
  7317. this._activeTrigger[TRIGGER_FOCUS] = false;
  7318. this._activeTrigger[TRIGGER_HOVER] = false;
  7319. this._isHovered = null;
  7320. const complete = () => {
  7321. if (this._isWithActiveTrigger()) {
  7322. return;
  7323. }
  7324. if (!this._isHovered) {
  7325. this._disposePopper();
  7326. }
  7327. this._element.removeAttribute('aria-describedby');
  7328. EventHandler.trigger(this._element, this.constructor.eventName(EVENT_HIDDEN$2));
  7329. };
  7330. this._queueCallback(complete, this.tip, this._isAnimated());
  7331. }
  7332. update() {
  7333. if (this._popper) {
  7334. this._popper.update();
  7335. }
  7336. }
  7337. _isWithContent() {
  7338. return Boolean(this._getTitle());
  7339. }
  7340. _getTipElement() {
  7341. if (!this.tip) {
  7342. this.tip = this._createTipElement(this._newContent || this._getContentForTemplate());
  7343. }
  7344. return this.tip;
  7345. }
  7346. _createTipElement(content) {
  7347. const tip = this._getTemplateFactory(content).toHtml();
  7348. if (!tip) {
  7349. return null;
  7350. }
  7351. tip.classList.remove(CLASS_NAME_FADE$2, CLASS_NAME_SHOW$2);
  7352. tip.classList.add(`bs-${this.constructor.NAME}-auto`);
  7353. const tipId = getUID(this.constructor.NAME).toString();
  7354. tip.setAttribute('id', tipId);
  7355. if (this._isAnimated()) {
  7356. tip.classList.add(CLASS_NAME_FADE$2);
  7357. }
  7358. return tip;
  7359. }
  7360. setContent(content) {
  7361. this._newContent = content;
  7362. if (this._isShown()) {
  7363. this._disposePopper();
  7364. this.show();
  7365. }
  7366. }
  7367. _getTemplateFactory(content) {
  7368. if (this._templateFactory) {
  7369. this._templateFactory.changeContent(content);
  7370. } else {
  7371. this._templateFactory = new TemplateFactory({
  7372. ...this._config,
  7373. content,
  7374. extraClass: this._resolvePossibleFunction(this._config.customClass)
  7375. });
  7376. }
  7377. return this._templateFactory;
  7378. }
  7379. _getContentForTemplate() {
  7380. return {
  7381. [SELECTOR_TOOLTIP_INNER]: this._getTitle()
  7382. };
  7383. }
  7384. _getTitle() {
  7385. return this._resolvePossibleFunction(this._config.title) || this._element.getAttribute('data-bs-original-title');
  7386. }
  7387. _initializeOnDelegatedTarget(event) {
  7388. return this.constructor.getOrCreateInstance(event.delegateTarget, this._getDelegateConfig());
  7389. }
  7390. _isAnimated() {
  7391. return this._config.animation || this.tip && this.tip.classList.contains(CLASS_NAME_FADE$2);
  7392. }
  7393. _isShown() {
  7394. return this.tip && this.tip.classList.contains(CLASS_NAME_SHOW$2);
  7395. }
  7396. _createPopper(tip) {
  7397. const placement = execute(this._config.placement, [this, tip, this._element]);
  7398. const attachment = AttachmentMap[placement.toUpperCase()];
  7399. return createPopper(this._element, tip, this._getPopperConfig(attachment));
  7400. }
  7401. _getOffset() {
  7402. const {
  7403. offset
  7404. } = this._config;
  7405. if (typeof offset === 'string') {
  7406. return offset.split(',').map(value => Number.parseInt(value, 10));
  7407. }
  7408. if (typeof offset === 'function') {
  7409. return popperData => offset(popperData, this._element);
  7410. }
  7411. return offset;
  7412. }
  7413. _resolvePossibleFunction(arg) {
  7414. return execute(arg, [this._element]);
  7415. }
  7416. _getPopperConfig(attachment) {
  7417. const defaultBsPopperConfig = {
  7418. placement: attachment,
  7419. modifiers: [{
  7420. name: 'flip',
  7421. options: {
  7422. fallbackPlacements: this._config.fallbackPlacements
  7423. }
  7424. }, {
  7425. name: 'offset',
  7426. options: {
  7427. offset: this._getOffset()
  7428. }
  7429. }, {
  7430. name: 'preventOverflow',
  7431. options: {
  7432. boundary: this._config.boundary
  7433. }
  7434. }, {
  7435. name: 'arrow',
  7436. options: {
  7437. element: `.${this.constructor.NAME}-arrow`
  7438. }
  7439. }, {
  7440. name: 'preSetPlacement',
  7441. enabled: true,
  7442. phase: 'beforeMain',
  7443. fn: data => {
  7444. this._getTipElement().setAttribute('data-popper-placement', data.state.placement);
  7445. }
  7446. }]
  7447. };
  7448. return {
  7449. ...defaultBsPopperConfig,
  7450. ...execute(this._config.popperConfig, [defaultBsPopperConfig])
  7451. };
  7452. }
  7453. _setListeners() {
  7454. const triggers = this._config.trigger.split(' ');
  7455. for (const trigger of triggers) {
  7456. if (trigger === 'click') {
  7457. EventHandler.on(this._element, this.constructor.eventName(EVENT_CLICK$1), this._config.selector, event => {
  7458. const context = this._initializeOnDelegatedTarget(event);
  7459. context.toggle();
  7460. });
  7461. } else if (trigger !== TRIGGER_MANUAL) {
  7462. const eventIn = trigger === TRIGGER_HOVER ? this.constructor.eventName(EVENT_MOUSEENTER) : this.constructor.eventName(EVENT_FOCUSIN$1);
  7463. const eventOut = trigger === TRIGGER_HOVER ? this.constructor.eventName(EVENT_MOUSELEAVE) : this.constructor.eventName(EVENT_FOCUSOUT$1);
  7464. EventHandler.on(this._element, eventIn, this._config.selector, event => {
  7465. const context = this._initializeOnDelegatedTarget(event);
  7466. context._activeTrigger[event.type === 'focusin' ? TRIGGER_FOCUS : TRIGGER_HOVER] = true;
  7467. context._enter();
  7468. });
  7469. EventHandler.on(this._element, eventOut, this._config.selector, event => {
  7470. const context = this._initializeOnDelegatedTarget(event);
  7471. context._activeTrigger[event.type === 'focusout' ? TRIGGER_FOCUS : TRIGGER_HOVER] = context._element.contains(event.relatedTarget);
  7472. context._leave();
  7473. });
  7474. }
  7475. }
  7476. this._hideModalHandler = () => {
  7477. if (this._element) {
  7478. this.hide();
  7479. }
  7480. };
  7481. EventHandler.on(this._element.closest(SELECTOR_MODAL), EVENT_MODAL_HIDE, this._hideModalHandler);
  7482. }
  7483. _fixTitle() {
  7484. const title = this._element.getAttribute('title');
  7485. if (!title) {
  7486. return;
  7487. }
  7488. if (!this._element.getAttribute('aria-label') && !this._element.textContent.trim()) {
  7489. this._element.setAttribute('aria-label', title);
  7490. }
  7491. this._element.setAttribute('data-bs-original-title', title);
  7492. this._element.removeAttribute('title');
  7493. }
  7494. _enter() {
  7495. if (this._isShown() || this._isHovered) {
  7496. this._isHovered = true;
  7497. return;
  7498. }
  7499. this._isHovered = true;
  7500. this._setTimeout(() => {
  7501. if (this._isHovered) {
  7502. this.show();
  7503. }
  7504. }, this._config.delay.show);
  7505. }
  7506. _leave() {
  7507. if (this._isWithActiveTrigger()) {
  7508. return;
  7509. }
  7510. this._isHovered = false;
  7511. this._setTimeout(() => {
  7512. if (!this._isHovered) {
  7513. this.hide();
  7514. }
  7515. }, this._config.delay.hide);
  7516. }
  7517. _setTimeout(handler, timeout) {
  7518. clearTimeout(this._timeout);
  7519. this._timeout = setTimeout(handler, timeout);
  7520. }
  7521. _isWithActiveTrigger() {
  7522. return Object.values(this._activeTrigger).includes(true);
  7523. }
  7524. _getConfig(config) {
  7525. const dataAttributes = Manipulator.getDataAttributes(this._element);
  7526. for (const dataAttribute of Object.keys(dataAttributes)) {
  7527. if (DISALLOWED_ATTRIBUTES.has(dataAttribute)) {
  7528. delete dataAttributes[dataAttribute];
  7529. }
  7530. }
  7531. config = {
  7532. ...dataAttributes,
  7533. ...(typeof config === 'object' && config ? config : {})
  7534. };
  7535. config = this._mergeConfigObj(config);
  7536. config = this._configAfterMerge(config);
  7537. this._typeCheckConfig(config);
  7538. return config;
  7539. }
  7540. _configAfterMerge(config) {
  7541. config.container = config.container === false ? document.body : getElement(config.container);
  7542. if (typeof config.delay === 'number') {
  7543. config.delay = {
  7544. show: config.delay,
  7545. hide: config.delay
  7546. };
  7547. }
  7548. if (typeof config.title === 'number') {
  7549. config.title = config.title.toString();
  7550. }
  7551. if (typeof config.content === 'number') {
  7552. config.content = config.content.toString();
  7553. }
  7554. return config;
  7555. }
  7556. _getDelegateConfig() {
  7557. const config = {};
  7558. for (const [key, value] of Object.entries(this._config)) {
  7559. if (this.constructor.Default[key] !== value) {
  7560. config[key] = value;
  7561. }
  7562. }
  7563. config.selector = false;
  7564. config.trigger = 'manual';
  7565. return config;
  7566. }
  7567. _disposePopper() {
  7568. if (this._popper) {
  7569. this._popper.destroy();
  7570. this._popper = null;
  7571. }
  7572. if (this.tip) {
  7573. this.tip.remove();
  7574. this.tip = null;
  7575. }
  7576. }
  7577. static jQueryInterface(config) {
  7578. return this.each(function () {
  7579. const data = Tooltip.getOrCreateInstance(this, config);
  7580. if (typeof config !== 'string') {
  7581. return;
  7582. }
  7583. if (typeof data[config] === 'undefined') {
  7584. throw new TypeError(`No method named "${config}"`);
  7585. }
  7586. data[config]();
  7587. });
  7588. }
  7589. }
  7590. defineJQueryPlugin(Tooltip);
  7591. const NAME$3 = 'popover';
  7592. const SELECTOR_TITLE = '.popover-header';
  7593. const SELECTOR_CONTENT = '.popover-body';
  7594. const Default$2 = {
  7595. ...Tooltip.Default,
  7596. content: '',
  7597. offset: [0, 8],
  7598. placement: 'right',
  7599. template: '<div class="popover" role="tooltip">' + '<div class="popover-arrow"></div>' + '<h3 class="popover-header"></h3>' + '<div class="popover-body"></div>' + '</div>',
  7600. trigger: 'click'
  7601. };
  7602. const DefaultType$2 = {
  7603. ...Tooltip.DefaultType,
  7604. content: '(null|string|element|function)'
  7605. };
  7606. class Popover extends Tooltip {
  7607. static get Default() {
  7608. return Default$2;
  7609. }
  7610. static get DefaultType() {
  7611. return DefaultType$2;
  7612. }
  7613. static get NAME() {
  7614. return NAME$3;
  7615. }
  7616. _isWithContent() {
  7617. return this._getTitle() || this._getContent();
  7618. }
  7619. _getContentForTemplate() {
  7620. return {
  7621. [SELECTOR_TITLE]: this._getTitle(),
  7622. [SELECTOR_CONTENT]: this._getContent()
  7623. };
  7624. }
  7625. _getContent() {
  7626. return this._resolvePossibleFunction(this._config.content);
  7627. }
  7628. static jQueryInterface(config) {
  7629. return this.each(function () {
  7630. const data = Popover.getOrCreateInstance(this, config);
  7631. if (typeof config !== 'string') {
  7632. return;
  7633. }
  7634. if (typeof data[config] === 'undefined') {
  7635. throw new TypeError(`No method named "${config}"`);
  7636. }
  7637. data[config]();
  7638. });
  7639. }
  7640. }
  7641. defineJQueryPlugin(Popover);
  7642. const NAME$2 = 'scrollspy';
  7643. const DATA_KEY$2 = 'bs.scrollspy';
  7644. const EVENT_KEY$2 = `.${DATA_KEY$2}`;
  7645. const DATA_API_KEY = '.data-api';
  7646. const EVENT_ACTIVATE = `activate${EVENT_KEY$2}`;
  7647. const EVENT_CLICK = `click${EVENT_KEY$2}`;
  7648. const EVENT_LOAD_DATA_API$1 = `load${EVENT_KEY$2}${DATA_API_KEY}`;
  7649. const CLASS_NAME_DROPDOWN_ITEM = 'dropdown-item';
  7650. const CLASS_NAME_ACTIVE$1 = 'active';
  7651. const SELECTOR_DATA_SPY = '[data-bs-spy="scroll"]';
  7652. const SELECTOR_TARGET_LINKS = '[href]';
  7653. const SELECTOR_NAV_LIST_GROUP = '.nav, .list-group';
  7654. const SELECTOR_NAV_LINKS = '.nav-link';
  7655. const SELECTOR_NAV_ITEMS = '.nav-item';
  7656. const SELECTOR_LIST_ITEMS = '.list-group-item';
  7657. const SELECTOR_LINK_ITEMS = `${SELECTOR_NAV_LINKS}, ${SELECTOR_NAV_ITEMS} > ${SELECTOR_NAV_LINKS}, ${SELECTOR_LIST_ITEMS}`;
  7658. const SELECTOR_DROPDOWN = '.dropdown';
  7659. const SELECTOR_DROPDOWN_TOGGLE$1 = '.dropdown-toggle';
  7660. const Default$1 = {
  7661. offset: null,
  7662. rootMargin: '0px 0px -25%',
  7663. smoothScroll: false,
  7664. target: null,
  7665. threshold: [0.1, 0.5, 1]
  7666. };
  7667. const DefaultType$1 = {
  7668. offset: '(number|null)',
  7669. rootMargin: 'string',
  7670. smoothScroll: 'boolean',
  7671. target: 'element',
  7672. threshold: 'array'
  7673. };
  7674. class ScrollSpy extends BaseComponent {
  7675. constructor(element, config) {
  7676. super(element, config);
  7677. this._targetLinks = new Map();
  7678. this._observableSections = new Map();
  7679. this._rootElement = getComputedStyle(this._element).overflowY === 'visible' ? null : this._element;
  7680. this._activeTarget = null;
  7681. this._observer = null;
  7682. this._previousScrollData = {
  7683. visibleEntryTop: 0,
  7684. parentScrollTop: 0
  7685. };
  7686. this.refresh();
  7687. }
  7688. static get Default() {
  7689. return Default$1;
  7690. }
  7691. static get DefaultType() {
  7692. return DefaultType$1;
  7693. }
  7694. static get NAME() {
  7695. return NAME$2;
  7696. }
  7697. refresh() {
  7698. this._initializeTargetsAndObservables();
  7699. this._maybeEnableSmoothScroll();
  7700. if (this._observer) {
  7701. this._observer.disconnect();
  7702. } else {
  7703. this._observer = this._getNewObserver();
  7704. }
  7705. for (const section of this._observableSections.values()) {
  7706. this._observer.observe(section);
  7707. }
  7708. }
  7709. dispose() {
  7710. this._observer.disconnect();
  7711. super.dispose();
  7712. }
  7713. _configAfterMerge(config) {
  7714. config.target = getElement(config.target) || document.body;
  7715. config.rootMargin = config.offset ? `${config.offset}px 0px -30%` : config.rootMargin;
  7716. if (typeof config.threshold === 'string') {
  7717. config.threshold = config.threshold.split(',').map(value => Number.parseFloat(value));
  7718. }
  7719. return config;
  7720. }
  7721. _maybeEnableSmoothScroll() {
  7722. if (!this._config.smoothScroll) {
  7723. return;
  7724. }
  7725. EventHandler.off(this._config.target, EVENT_CLICK);
  7726. EventHandler.on(this._config.target, EVENT_CLICK, SELECTOR_TARGET_LINKS, event => {
  7727. const observableSection = this._observableSections.get(event.target.hash);
  7728. if (observableSection) {
  7729. event.preventDefault();
  7730. const root = this._rootElement || window;
  7731. const height = observableSection.offsetTop - this._element.offsetTop;
  7732. if (root.scrollTo) {
  7733. root.scrollTo({
  7734. top: height,
  7735. behavior: 'smooth'
  7736. });
  7737. return;
  7738. }
  7739. root.scrollTop = height;
  7740. }
  7741. });
  7742. }
  7743. _getNewObserver() {
  7744. const options = {
  7745. root: this._rootElement,
  7746. threshold: this._config.threshold,
  7747. rootMargin: this._config.rootMargin
  7748. };
  7749. return new IntersectionObserver(entries => this._observerCallback(entries), options);
  7750. }
  7751. _observerCallback(entries) {
  7752. const targetElement = entry => this._targetLinks.get(`#${entry.target.id}`);
  7753. const activate = entry => {
  7754. this._previousScrollData.visibleEntryTop = entry.target.offsetTop;
  7755. this._process(targetElement(entry));
  7756. };
  7757. const parentScrollTop = (this._rootElement || document.documentElement).scrollTop;
  7758. const userScrollsDown = parentScrollTop >= this._previousScrollData.parentScrollTop;
  7759. this._previousScrollData.parentScrollTop = parentScrollTop;
  7760. for (const entry of entries) {
  7761. if (!entry.isIntersecting) {
  7762. this._activeTarget = null;
  7763. this._clearActiveClass(targetElement(entry));
  7764. continue;
  7765. }
  7766. const entryIsLowerThanPrevious = entry.target.offsetTop >= this._previousScrollData.visibleEntryTop;
  7767. if (userScrollsDown && entryIsLowerThanPrevious) {
  7768. activate(entry);
  7769. if (!parentScrollTop) {
  7770. return;
  7771. }
  7772. continue;
  7773. }
  7774. if (!userScrollsDown && !entryIsLowerThanPrevious) {
  7775. activate(entry);
  7776. }
  7777. }
  7778. }
  7779. _initializeTargetsAndObservables() {
  7780. this._targetLinks = new Map();
  7781. this._observableSections = new Map();
  7782. const targetLinks = SelectorEngine.find(SELECTOR_TARGET_LINKS, this._config.target);
  7783. for (const anchor of targetLinks) {
  7784. if (!anchor.hash || isDisabled(anchor)) {
  7785. continue;
  7786. }
  7787. const observableSection = SelectorEngine.findOne(anchor.hash, this._element);
  7788. if (isVisible(observableSection)) {
  7789. this._targetLinks.set(anchor.hash, anchor);
  7790. this._observableSections.set(anchor.hash, observableSection);
  7791. }
  7792. }
  7793. }
  7794. _process(target) {
  7795. if (this._activeTarget === target) {
  7796. return;
  7797. }
  7798. this._clearActiveClass(this._config.target);
  7799. this._activeTarget = target;
  7800. target.classList.add(CLASS_NAME_ACTIVE$1);
  7801. this._activateParents(target);
  7802. EventHandler.trigger(this._element, EVENT_ACTIVATE, {
  7803. relatedTarget: target
  7804. });
  7805. }
  7806. _activateParents(target) {
  7807. if (target.classList.contains(CLASS_NAME_DROPDOWN_ITEM)) {
  7808. SelectorEngine.findOne(SELECTOR_DROPDOWN_TOGGLE$1, target.closest(SELECTOR_DROPDOWN)).classList.add(CLASS_NAME_ACTIVE$1);
  7809. return;
  7810. }
  7811. for (const listGroup of SelectorEngine.parents(target, SELECTOR_NAV_LIST_GROUP)) {
  7812. for (const item of SelectorEngine.prev(listGroup, SELECTOR_LINK_ITEMS)) {
  7813. item.classList.add(CLASS_NAME_ACTIVE$1);
  7814. }
  7815. }
  7816. }
  7817. _clearActiveClass(parent) {
  7818. parent.classList.remove(CLASS_NAME_ACTIVE$1);
  7819. const activeNodes = SelectorEngine.find(`${SELECTOR_TARGET_LINKS}.${CLASS_NAME_ACTIVE$1}`, parent);
  7820. for (const node of activeNodes) {
  7821. node.classList.remove(CLASS_NAME_ACTIVE$1);
  7822. }
  7823. }
  7824. static jQueryInterface(config) {
  7825. return this.each(function () {
  7826. const data = ScrollSpy.getOrCreateInstance(this, config);
  7827. if (typeof config !== 'string') {
  7828. return;
  7829. }
  7830. if (data[config] === undefined || config.startsWith('_') || config === 'constructor') {
  7831. throw new TypeError(`No method named "${config}"`);
  7832. }
  7833. data[config]();
  7834. });
  7835. }
  7836. }
  7837. EventHandler.on(window, EVENT_LOAD_DATA_API$1, () => {
  7838. for (const spy of SelectorEngine.find(SELECTOR_DATA_SPY)) {
  7839. ScrollSpy.getOrCreateInstance(spy);
  7840. }
  7841. });
  7842. defineJQueryPlugin(ScrollSpy);
  7843. const NAME$1 = 'tab';
  7844. const DATA_KEY$1 = 'bs.tab';
  7845. const EVENT_KEY$1 = `.${DATA_KEY$1}`;
  7846. const EVENT_HIDE$1 = `hide${EVENT_KEY$1}`;
  7847. const EVENT_HIDDEN$1 = `hidden${EVENT_KEY$1}`;
  7848. const EVENT_SHOW$1 = `show${EVENT_KEY$1}`;
  7849. const EVENT_SHOWN$1 = `shown${EVENT_KEY$1}`;
  7850. const EVENT_CLICK_DATA_API = `click${EVENT_KEY$1}`;
  7851. const EVENT_KEYDOWN = `keydown${EVENT_KEY$1}`;
  7852. const EVENT_LOAD_DATA_API = `load${EVENT_KEY$1}`;
  7853. const ARROW_LEFT_KEY = 'ArrowLeft';
  7854. const ARROW_RIGHT_KEY = 'ArrowRight';
  7855. const ARROW_UP_KEY = 'ArrowUp';
  7856. const ARROW_DOWN_KEY = 'ArrowDown';
  7857. const CLASS_NAME_ACTIVE = 'active';
  7858. const CLASS_NAME_FADE$1 = 'fade';
  7859. const CLASS_NAME_SHOW$1 = 'show';
  7860. const CLASS_DROPDOWN = 'dropdown';
  7861. const SELECTOR_DROPDOWN_TOGGLE = '.dropdown-toggle';
  7862. const SELECTOR_DROPDOWN_MENU = '.dropdown-menu';
  7863. const NOT_SELECTOR_DROPDOWN_TOGGLE = ':not(.dropdown-toggle)';
  7864. const SELECTOR_TAB_PANEL = '.list-group, .nav, [role="tablist"]';
  7865. const SELECTOR_OUTER = '.nav-item, .list-group-item';
  7866. const SELECTOR_INNER = `.nav-link${NOT_SELECTOR_DROPDOWN_TOGGLE}, .list-group-item${NOT_SELECTOR_DROPDOWN_TOGGLE}, [role="tab"]${NOT_SELECTOR_DROPDOWN_TOGGLE}`;
  7867. const SELECTOR_DATA_TOGGLE = '[data-bs-toggle="tab"], [data-bs-toggle="pill"], [data-bs-toggle="list"]';
  7868. const SELECTOR_INNER_ELEM = `${SELECTOR_INNER}, ${SELECTOR_DATA_TOGGLE}`;
  7869. 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"]`;
  7870. class Tab extends BaseComponent {
  7871. constructor(element) {
  7872. super(element);
  7873. this._parent = this._element.closest(SELECTOR_TAB_PANEL);
  7874. if (!this._parent) {
  7875. return;
  7876. }
  7877. this._setInitialAttributes(this._parent, this._getChildren());
  7878. EventHandler.on(this._element, EVENT_KEYDOWN, event => this._keydown(event));
  7879. }
  7880. static get NAME() {
  7881. return NAME$1;
  7882. }
  7883. show() {
  7884. const innerElem = this._element;
  7885. if (this._elemIsActive(innerElem)) {
  7886. return;
  7887. }
  7888. const active = this._getActiveElem();
  7889. const hideEvent = active ? EventHandler.trigger(active, EVENT_HIDE$1, {
  7890. relatedTarget: innerElem
  7891. }) : null;
  7892. const showEvent = EventHandler.trigger(innerElem, EVENT_SHOW$1, {
  7893. relatedTarget: active
  7894. });
  7895. if (showEvent.defaultPrevented || hideEvent && hideEvent.defaultPrevented) {
  7896. return;
  7897. }
  7898. this._deactivate(active, innerElem);
  7899. this._activate(innerElem, active);
  7900. }
  7901. _activate(element, relatedElem) {
  7902. if (!element) {
  7903. return;
  7904. }
  7905. element.classList.add(CLASS_NAME_ACTIVE);
  7906. this._activate(SelectorEngine.getElementFromSelector(element));
  7907. const complete = () => {
  7908. if (element.getAttribute('role') !== 'tab') {
  7909. element.classList.add(CLASS_NAME_SHOW$1);
  7910. return;
  7911. }
  7912. element.removeAttribute('tabindex');
  7913. element.setAttribute('aria-selected', true);
  7914. this._toggleDropDown(element, true);
  7915. EventHandler.trigger(element, EVENT_SHOWN$1, {
  7916. relatedTarget: relatedElem
  7917. });
  7918. };
  7919. this._queueCallback(complete, element, element.classList.contains(CLASS_NAME_FADE$1));
  7920. }
  7921. _deactivate(element, relatedElem) {
  7922. if (!element) {
  7923. return;
  7924. }
  7925. element.classList.remove(CLASS_NAME_ACTIVE);
  7926. element.blur();
  7927. this._deactivate(SelectorEngine.getElementFromSelector(element));
  7928. const complete = () => {
  7929. if (element.getAttribute('role') !== 'tab') {
  7930. element.classList.remove(CLASS_NAME_SHOW$1);
  7931. return;
  7932. }
  7933. element.setAttribute('aria-selected', false);
  7934. element.setAttribute('tabindex', '-1');
  7935. this._toggleDropDown(element, false);
  7936. EventHandler.trigger(element, EVENT_HIDDEN$1, {
  7937. relatedTarget: relatedElem
  7938. });
  7939. };
  7940. this._queueCallback(complete, element, element.classList.contains(CLASS_NAME_FADE$1));
  7941. }
  7942. _keydown(event) {
  7943. if (![ARROW_LEFT_KEY, ARROW_RIGHT_KEY, ARROW_UP_KEY, ARROW_DOWN_KEY].includes(event.key)) {
  7944. return;
  7945. }
  7946. event.stopPropagation();
  7947. event.preventDefault();
  7948. const isNext = [ARROW_RIGHT_KEY, ARROW_DOWN_KEY].includes(event.key);
  7949. const nextActiveElement = getNextActiveElement(this._getChildren().filter(element => !isDisabled(element)), event.target, isNext, true);
  7950. if (nextActiveElement) {
  7951. nextActiveElement.focus({
  7952. preventScroll: true
  7953. });
  7954. Tab.getOrCreateInstance(nextActiveElement).show();
  7955. }
  7956. }
  7957. _getChildren() {
  7958. return SelectorEngine.find(SELECTOR_INNER_ELEM, this._parent);
  7959. }
  7960. _getActiveElem() {
  7961. return this._getChildren().find(child => this._elemIsActive(child)) || null;
  7962. }
  7963. _setInitialAttributes(parent, children) {
  7964. this._setAttributeIfNotExists(parent, 'role', 'tablist');
  7965. for (const child of children) {
  7966. this._setInitialAttributesOnChild(child);
  7967. }
  7968. }
  7969. _setInitialAttributesOnChild(child) {
  7970. child = this._getInnerElement(child);
  7971. const isActive = this._elemIsActive(child);
  7972. const outerElem = this._getOuterElement(child);
  7973. child.setAttribute('aria-selected', isActive);
  7974. if (outerElem !== child) {
  7975. this._setAttributeIfNotExists(outerElem, 'role', 'presentation');
  7976. }
  7977. if (!isActive) {
  7978. child.setAttribute('tabindex', '-1');
  7979. }
  7980. this._setAttributeIfNotExists(child, 'role', 'tab');
  7981. this._setInitialAttributesOnTargetPanel(child);
  7982. }
  7983. _setInitialAttributesOnTargetPanel(child) {
  7984. const target = SelectorEngine.getElementFromSelector(child);
  7985. if (!target) {
  7986. return;
  7987. }
  7988. this._setAttributeIfNotExists(target, 'role', 'tabpanel');
  7989. if (child.id) {
  7990. this._setAttributeIfNotExists(target, 'aria-labelledby', `#${child.id}`);
  7991. }
  7992. }
  7993. _toggleDropDown(element, open) {
  7994. const outerElem = this._getOuterElement(element);
  7995. if (!outerElem.classList.contains(CLASS_DROPDOWN)) {
  7996. return;
  7997. }
  7998. const toggle = (selector, className) => {
  7999. const element = SelectorEngine.findOne(selector, outerElem);
  8000. if (element) {
  8001. element.classList.toggle(className, open);
  8002. }
  8003. };
  8004. toggle(SELECTOR_DROPDOWN_TOGGLE, CLASS_NAME_ACTIVE);
  8005. toggle(SELECTOR_DROPDOWN_MENU, CLASS_NAME_SHOW$1);
  8006. outerElem.setAttribute('aria-expanded', open);
  8007. }
  8008. _setAttributeIfNotExists(element, attribute, value) {
  8009. if (!element.hasAttribute(attribute)) {
  8010. element.setAttribute(attribute, value);
  8011. }
  8012. }
  8013. _elemIsActive(elem) {
  8014. return elem.classList.contains(CLASS_NAME_ACTIVE);
  8015. }
  8016. _getInnerElement(elem) {
  8017. return elem.matches(SELECTOR_INNER_ELEM) ? elem : SelectorEngine.findOne(SELECTOR_INNER_ELEM, elem);
  8018. }
  8019. _getOuterElement(elem) {
  8020. return elem.closest(SELECTOR_OUTER) || elem;
  8021. }
  8022. static jQueryInterface(config) {
  8023. return this.each(function () {
  8024. const data = Tab.getOrCreateInstance(this);
  8025. if (typeof config !== 'string') {
  8026. return;
  8027. }
  8028. if (data[config] === undefined || config.startsWith('_') || config === 'constructor') {
  8029. throw new TypeError(`No method named "${config}"`);
  8030. }
  8031. data[config]();
  8032. });
  8033. }
  8034. }
  8035. EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, function (event) {
  8036. if (['A', 'AREA'].includes(this.tagName)) {
  8037. event.preventDefault();
  8038. }
  8039. if (isDisabled(this)) {
  8040. return;
  8041. }
  8042. Tab.getOrCreateInstance(this).show();
  8043. });
  8044. EventHandler.on(window, EVENT_LOAD_DATA_API, () => {
  8045. for (const element of SelectorEngine.find(SELECTOR_DATA_TOGGLE_ACTIVE)) {
  8046. Tab.getOrCreateInstance(element);
  8047. }
  8048. });
  8049. defineJQueryPlugin(Tab);
  8050. const NAME = 'toast';
  8051. const DATA_KEY = 'bs.toast';
  8052. const EVENT_KEY = `.${DATA_KEY}`;
  8053. const EVENT_MOUSEOVER = `mouseover${EVENT_KEY}`;
  8054. const EVENT_MOUSEOUT = `mouseout${EVENT_KEY}`;
  8055. const EVENT_FOCUSIN = `focusin${EVENT_KEY}`;
  8056. const EVENT_FOCUSOUT = `focusout${EVENT_KEY}`;
  8057. const EVENT_HIDE = `hide${EVENT_KEY}`;
  8058. const EVENT_HIDDEN = `hidden${EVENT_KEY}`;
  8059. const EVENT_SHOW = `show${EVENT_KEY}`;
  8060. const EVENT_SHOWN = `shown${EVENT_KEY}`;
  8061. const CLASS_NAME_FADE = 'fade';
  8062. const CLASS_NAME_HIDE = 'hide';
  8063. const CLASS_NAME_SHOW = 'show';
  8064. const CLASS_NAME_SHOWING = 'showing';
  8065. const DefaultType = {
  8066. animation: 'boolean',
  8067. autohide: 'boolean',
  8068. delay: 'number'
  8069. };
  8070. const Default = {
  8071. animation: true,
  8072. autohide: true,
  8073. delay: 5000
  8074. };
  8075. class Toast extends BaseComponent {
  8076. constructor(element, config) {
  8077. super(element, config);
  8078. this._timeout = null;
  8079. this._hasMouseInteraction = false;
  8080. this._hasKeyboardInteraction = false;
  8081. this._setListeners();
  8082. }
  8083. static get Default() {
  8084. return Default;
  8085. }
  8086. static get DefaultType() {
  8087. return DefaultType;
  8088. }
  8089. static get NAME() {
  8090. return NAME;
  8091. }
  8092. show() {
  8093. const showEvent = EventHandler.trigger(this._element, EVENT_SHOW);
  8094. if (showEvent.defaultPrevented) {
  8095. return;
  8096. }
  8097. this._clearTimeout();
  8098. if (this._config.animation) {
  8099. this._element.classList.add(CLASS_NAME_FADE);
  8100. }
  8101. const complete = () => {
  8102. this._element.classList.remove(CLASS_NAME_SHOWING);
  8103. EventHandler.trigger(this._element, EVENT_SHOWN);
  8104. this._maybeScheduleHide();
  8105. };
  8106. this._element.classList.remove(CLASS_NAME_HIDE);
  8107. reflow(this._element);
  8108. this._element.classList.add(CLASS_NAME_SHOW, CLASS_NAME_SHOWING);
  8109. this._queueCallback(complete, this._element, this._config.animation);
  8110. }
  8111. hide() {
  8112. if (!this.isShown()) {
  8113. return;
  8114. }
  8115. const hideEvent = EventHandler.trigger(this._element, EVENT_HIDE);
  8116. if (hideEvent.defaultPrevented) {
  8117. return;
  8118. }
  8119. const complete = () => {
  8120. this._element.classList.add(CLASS_NAME_HIDE);
  8121. this._element.classList.remove(CLASS_NAME_SHOWING, CLASS_NAME_SHOW);
  8122. EventHandler.trigger(this._element, EVENT_HIDDEN);
  8123. };
  8124. this._element.classList.add(CLASS_NAME_SHOWING);
  8125. this._queueCallback(complete, this._element, this._config.animation);
  8126. }
  8127. dispose() {
  8128. this._clearTimeout();
  8129. if (this.isShown()) {
  8130. this._element.classList.remove(CLASS_NAME_SHOW);
  8131. }
  8132. super.dispose();
  8133. }
  8134. isShown() {
  8135. return this._element.classList.contains(CLASS_NAME_SHOW);
  8136. }
  8137. _maybeScheduleHide() {
  8138. if (!this._config.autohide) {
  8139. return;
  8140. }
  8141. if (this._hasMouseInteraction || this._hasKeyboardInteraction) {
  8142. return;
  8143. }
  8144. this._timeout = setTimeout(() => {
  8145. this.hide();
  8146. }, this._config.delay);
  8147. }
  8148. _onInteraction(event, isInteracting) {
  8149. switch (event.type) {
  8150. case 'mouseover':
  8151. case 'mouseout':
  8152. {
  8153. this._hasMouseInteraction = isInteracting;
  8154. break;
  8155. }
  8156. case 'focusin':
  8157. case 'focusout':
  8158. {
  8159. this._hasKeyboardInteraction = isInteracting;
  8160. break;
  8161. }
  8162. }
  8163. if (isInteracting) {
  8164. this._clearTimeout();
  8165. return;
  8166. }
  8167. const nextElement = event.relatedTarget;
  8168. if (this._element === nextElement || this._element.contains(nextElement)) {
  8169. return;
  8170. }
  8171. this._maybeScheduleHide();
  8172. }
  8173. _setListeners() {
  8174. EventHandler.on(this._element, EVENT_MOUSEOVER, event => this._onInteraction(event, true));
  8175. EventHandler.on(this._element, EVENT_MOUSEOUT, event => this._onInteraction(event, false));
  8176. EventHandler.on(this._element, EVENT_FOCUSIN, event => this._onInteraction(event, true));
  8177. EventHandler.on(this._element, EVENT_FOCUSOUT, event => this._onInteraction(event, false));
  8178. }
  8179. _clearTimeout() {
  8180. clearTimeout(this._timeout);
  8181. this._timeout = null;
  8182. }
  8183. static jQueryInterface(config) {
  8184. return this.each(function () {
  8185. const data = Toast.getOrCreateInstance(this, config);
  8186. if (typeof config === 'string') {
  8187. if (typeof data[config] === 'undefined') {
  8188. throw new TypeError(`No method named "${config}"`);
  8189. }
  8190. data[config](this);
  8191. }
  8192. });
  8193. }
  8194. }
  8195. enableDismissTrigger(Toast);
  8196. defineJQueryPlugin(Toast);
  8197. var dropdownTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="dropdown"]'));
  8198. dropdownTriggerList.map(function (dropdownTriggerEl) {
  8199. var options = {
  8200. boundary: dropdownTriggerEl.getAttribute('data-bs-boundary') === 'viewport' ? document.querySelector('.btn') : 'clippingParents'
  8201. };
  8202. return new Dropdown(dropdownTriggerEl, options);
  8203. });
  8204. var tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'));
  8205. tooltipTriggerList.map(function (tooltipTriggerEl) {
  8206. var _ref, _tooltipTriggerEl$get;
  8207. var options = {
  8208. delay: {
  8209. show: 50,
  8210. hide: 50
  8211. },
  8212. html: (_ref = tooltipTriggerEl.getAttribute("data-bs-html") === "true") !== null && _ref !== void 0 ? _ref : false,
  8213. placement: (_tooltipTriggerEl$get = tooltipTriggerEl.getAttribute('data-bs-placement')) !== null && _tooltipTriggerEl$get !== void 0 ? _tooltipTriggerEl$get : 'auto'
  8214. };
  8215. return new Tooltip(tooltipTriggerEl, options);
  8216. });
  8217. var popoverTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="popover"]'));
  8218. popoverTriggerList.map(function (popoverTriggerEl) {
  8219. var _ref, _popoverTriggerEl$get;
  8220. var options = {
  8221. delay: {
  8222. show: 50,
  8223. hide: 50
  8224. },
  8225. html: (_ref = popoverTriggerEl.getAttribute('data-bs-html') === "true") !== null && _ref !== void 0 ? _ref : false,
  8226. placement: (_popoverTriggerEl$get = popoverTriggerEl.getAttribute('data-bs-placement')) !== null && _popoverTriggerEl$get !== void 0 ? _popoverTriggerEl$get : 'auto'
  8227. };
  8228. return new Popover(popoverTriggerEl, options);
  8229. });
  8230. var switchesTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="switch-icon"]'));
  8231. switchesTriggerList.map(function (switchTriggerEl) {
  8232. switchTriggerEl.addEventListener('click', function (e) {
  8233. e.stopPropagation();
  8234. switchTriggerEl.classList.toggle('active');
  8235. });
  8236. });
  8237. var toastsTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="toast"]'));
  8238. toastsTriggerList.map(function (toastTriggerEl) {
  8239. return new Toast(toastTriggerEl);
  8240. });