livewire.js 339 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227
  1. (() => {
  2. var __create = Object.create;
  3. var __defProp = Object.defineProperty;
  4. var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
  5. var __getOwnPropNames = Object.getOwnPropertyNames;
  6. var __getProtoOf = Object.getPrototypeOf;
  7. var __hasOwnProp = Object.prototype.hasOwnProperty;
  8. var __commonJS = (cb, mod) => function __require() {
  9. return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
  10. };
  11. var __copyProps = (to, from, except, desc) => {
  12. if (from && typeof from === "object" || typeof from === "function") {
  13. for (let key of __getOwnPropNames(from))
  14. if (!__hasOwnProp.call(to, key) && key !== except)
  15. __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  16. }
  17. return to;
  18. };
  19. var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
  20. // node_modules/nprogress/nprogress.js
  21. var require_nprogress = __commonJS({
  22. "node_modules/nprogress/nprogress.js"(exports, module) {
  23. (function(root, factory) {
  24. if (typeof define === "function" && define.amd) {
  25. define(factory);
  26. } else if (typeof exports === "object") {
  27. module.exports = factory();
  28. } else {
  29. root.NProgress = factory();
  30. }
  31. })(exports, function() {
  32. var NProgress2 = {};
  33. NProgress2.version = "0.2.0";
  34. var Settings = NProgress2.settings = {
  35. minimum: 0.08,
  36. easing: "ease",
  37. positionUsing: "",
  38. speed: 200,
  39. trickle: true,
  40. trickleRate: 0.02,
  41. trickleSpeed: 800,
  42. showSpinner: true,
  43. barSelector: '[role="bar"]',
  44. spinnerSelector: '[role="spinner"]',
  45. parent: "body",
  46. template: '<div class="bar" role="bar"><div class="peg"></div></div><div class="spinner" role="spinner"><div class="spinner-icon"></div></div>'
  47. };
  48. NProgress2.configure = function(options) {
  49. var key, value;
  50. for (key in options) {
  51. value = options[key];
  52. if (value !== void 0 && options.hasOwnProperty(key))
  53. Settings[key] = value;
  54. }
  55. return this;
  56. };
  57. NProgress2.status = null;
  58. NProgress2.set = function(n) {
  59. var started2 = NProgress2.isStarted();
  60. n = clamp2(n, Settings.minimum, 1);
  61. NProgress2.status = n === 1 ? null : n;
  62. var progress = NProgress2.render(!started2), bar = progress.querySelector(Settings.barSelector), speed = Settings.speed, ease = Settings.easing;
  63. progress.offsetWidth;
  64. queue2(function(next) {
  65. if (Settings.positionUsing === "")
  66. Settings.positionUsing = NProgress2.getPositioningCSS();
  67. css(bar, barPositionCSS(n, speed, ease));
  68. if (n === 1) {
  69. css(progress, {
  70. transition: "none",
  71. opacity: 1
  72. });
  73. progress.offsetWidth;
  74. setTimeout(function() {
  75. css(progress, {
  76. transition: "all " + speed + "ms linear",
  77. opacity: 0
  78. });
  79. setTimeout(function() {
  80. NProgress2.remove();
  81. next();
  82. }, speed);
  83. }, speed);
  84. } else {
  85. setTimeout(next, speed);
  86. }
  87. });
  88. return this;
  89. };
  90. NProgress2.isStarted = function() {
  91. return typeof NProgress2.status === "number";
  92. };
  93. NProgress2.start = function() {
  94. if (!NProgress2.status)
  95. NProgress2.set(0);
  96. var work = function() {
  97. setTimeout(function() {
  98. if (!NProgress2.status)
  99. return;
  100. NProgress2.trickle();
  101. work();
  102. }, Settings.trickleSpeed);
  103. };
  104. if (Settings.trickle)
  105. work();
  106. return this;
  107. };
  108. NProgress2.done = function(force) {
  109. if (!force && !NProgress2.status)
  110. return this;
  111. return NProgress2.inc(0.3 + 0.5 * Math.random()).set(1);
  112. };
  113. NProgress2.inc = function(amount) {
  114. var n = NProgress2.status;
  115. if (!n) {
  116. return NProgress2.start();
  117. } else {
  118. if (typeof amount !== "number") {
  119. amount = (1 - n) * clamp2(Math.random() * n, 0.1, 0.95);
  120. }
  121. n = clamp2(n + amount, 0, 0.994);
  122. return NProgress2.set(n);
  123. }
  124. };
  125. NProgress2.trickle = function() {
  126. return NProgress2.inc(Math.random() * Settings.trickleRate);
  127. };
  128. (function() {
  129. var initial = 0, current = 0;
  130. NProgress2.promise = function($promise) {
  131. if (!$promise || $promise.state() === "resolved") {
  132. return this;
  133. }
  134. if (current === 0) {
  135. NProgress2.start();
  136. }
  137. initial++;
  138. current++;
  139. $promise.always(function() {
  140. current--;
  141. if (current === 0) {
  142. initial = 0;
  143. NProgress2.done();
  144. } else {
  145. NProgress2.set((initial - current) / initial);
  146. }
  147. });
  148. return this;
  149. };
  150. })();
  151. NProgress2.render = function(fromStart) {
  152. if (NProgress2.isRendered())
  153. return document.getElementById("nprogress");
  154. addClass(document.documentElement, "nprogress-busy");
  155. var progress = document.createElement("div");
  156. progress.id = "nprogress";
  157. progress.innerHTML = Settings.template;
  158. var bar = progress.querySelector(Settings.barSelector), perc = fromStart ? "-100" : toBarPerc(NProgress2.status || 0), parent = document.querySelector(Settings.parent), spinner;
  159. css(bar, {
  160. transition: "all 0 linear",
  161. transform: "translate3d(" + perc + "%,0,0)"
  162. });
  163. if (!Settings.showSpinner) {
  164. spinner = progress.querySelector(Settings.spinnerSelector);
  165. spinner && removeElement(spinner);
  166. }
  167. if (parent != document.body) {
  168. addClass(parent, "nprogress-custom-parent");
  169. }
  170. parent.appendChild(progress);
  171. return progress;
  172. };
  173. NProgress2.remove = function() {
  174. removeClass(document.documentElement, "nprogress-busy");
  175. removeClass(document.querySelector(Settings.parent), "nprogress-custom-parent");
  176. var progress = document.getElementById("nprogress");
  177. progress && removeElement(progress);
  178. };
  179. NProgress2.isRendered = function() {
  180. return !!document.getElementById("nprogress");
  181. };
  182. NProgress2.getPositioningCSS = function() {
  183. var bodyStyle = document.body.style;
  184. var vendorPrefix = "WebkitTransform" in bodyStyle ? "Webkit" : "MozTransform" in bodyStyle ? "Moz" : "msTransform" in bodyStyle ? "ms" : "OTransform" in bodyStyle ? "O" : "";
  185. if (vendorPrefix + "Perspective" in bodyStyle) {
  186. return "translate3d";
  187. } else if (vendorPrefix + "Transform" in bodyStyle) {
  188. return "translate";
  189. } else {
  190. return "margin";
  191. }
  192. };
  193. function clamp2(n, min2, max2) {
  194. if (n < min2)
  195. return min2;
  196. if (n > max2)
  197. return max2;
  198. return n;
  199. }
  200. function toBarPerc(n) {
  201. return (-1 + n) * 100;
  202. }
  203. function barPositionCSS(n, speed, ease) {
  204. var barCSS;
  205. if (Settings.positionUsing === "translate3d") {
  206. barCSS = { transform: "translate3d(" + toBarPerc(n) + "%,0,0)" };
  207. } else if (Settings.positionUsing === "translate") {
  208. barCSS = { transform: "translate(" + toBarPerc(n) + "%,0)" };
  209. } else {
  210. barCSS = { "margin-left": toBarPerc(n) + "%" };
  211. }
  212. barCSS.transition = "all " + speed + "ms " + ease;
  213. return barCSS;
  214. }
  215. var queue2 = function() {
  216. var pending = [];
  217. function next() {
  218. var fn = pending.shift();
  219. if (fn) {
  220. fn(next);
  221. }
  222. }
  223. return function(fn) {
  224. pending.push(fn);
  225. if (pending.length == 1)
  226. next();
  227. };
  228. }();
  229. var css = function() {
  230. var cssPrefixes = ["Webkit", "O", "Moz", "ms"], cssProps = {};
  231. function camelCase3(string) {
  232. return string.replace(/^-ms-/, "ms-").replace(/-([\da-z])/gi, function(match, letter) {
  233. return letter.toUpperCase();
  234. });
  235. }
  236. function getVendorProp(name) {
  237. var style = document.body.style;
  238. if (name in style)
  239. return name;
  240. var i = cssPrefixes.length, capName = name.charAt(0).toUpperCase() + name.slice(1), vendorName;
  241. while (i--) {
  242. vendorName = cssPrefixes[i] + capName;
  243. if (vendorName in style)
  244. return vendorName;
  245. }
  246. return name;
  247. }
  248. function getStyleProp(name) {
  249. name = camelCase3(name);
  250. return cssProps[name] || (cssProps[name] = getVendorProp(name));
  251. }
  252. function applyCss(element, prop, value) {
  253. prop = getStyleProp(prop);
  254. element.style[prop] = value;
  255. }
  256. return function(element, properties2) {
  257. var args = arguments, prop, value;
  258. if (args.length == 2) {
  259. for (prop in properties2) {
  260. value = properties2[prop];
  261. if (value !== void 0 && properties2.hasOwnProperty(prop))
  262. applyCss(element, prop, value);
  263. }
  264. } else {
  265. applyCss(element, args[1], args[2]);
  266. }
  267. };
  268. }();
  269. function hasClass(element, name) {
  270. var list = typeof element == "string" ? element : classList(element);
  271. return list.indexOf(" " + name + " ") >= 0;
  272. }
  273. function addClass(element, name) {
  274. var oldList = classList(element), newList = oldList + name;
  275. if (hasClass(oldList, name))
  276. return;
  277. element.className = newList.substring(1);
  278. }
  279. function removeClass(element, name) {
  280. var oldList = classList(element), newList;
  281. if (!hasClass(element, name))
  282. return;
  283. newList = oldList.replace(" " + name + " ", " ");
  284. element.className = newList.substring(1, newList.length - 1);
  285. }
  286. function classList(element) {
  287. return (" " + (element.className || "") + " ").replace(/\s+/gi, " ");
  288. }
  289. function removeElement(element) {
  290. element && element.parentNode && element.parentNode.removeChild(element);
  291. }
  292. return NProgress2;
  293. });
  294. }
  295. });
  296. // js/utils.js
  297. var Bag = class {
  298. constructor() {
  299. this.arrays = {};
  300. }
  301. add(key, value) {
  302. if (!this.arrays[key])
  303. this.arrays[key] = [];
  304. this.arrays[key].push(value);
  305. }
  306. remove(key) {
  307. if (this.arrays[key])
  308. delete this.arrays[key];
  309. }
  310. get(key) {
  311. return this.arrays[key] || [];
  312. }
  313. each(key, callback) {
  314. return this.get(key).forEach(callback);
  315. }
  316. };
  317. var WeakBag = class {
  318. constructor() {
  319. this.arrays = /* @__PURE__ */ new WeakMap();
  320. }
  321. add(key, value) {
  322. if (!this.arrays.has(key))
  323. this.arrays.set(key, []);
  324. this.arrays.get(key).push(value);
  325. }
  326. remove(key) {
  327. if (this.arrays.has(key))
  328. this.arrays.delete(key, []);
  329. }
  330. get(key) {
  331. return this.arrays.has(key) ? this.arrays.get(key) : [];
  332. }
  333. each(key, callback) {
  334. return this.get(key).forEach(callback);
  335. }
  336. };
  337. function dispatch(target, name, detail = {}, bubbles = true) {
  338. target.dispatchEvent(new CustomEvent(name, {
  339. detail,
  340. bubbles,
  341. composed: true,
  342. cancelable: true
  343. }));
  344. }
  345. function listen(target, name, handler4) {
  346. target.addEventListener(name, handler4);
  347. return () => target.removeEventListener(name, handler4);
  348. }
  349. function isObjecty(subject) {
  350. return typeof subject === "object" && subject !== null;
  351. }
  352. function isObject(subject) {
  353. return isObjecty(subject) && !isArray(subject);
  354. }
  355. function isArray(subject) {
  356. return Array.isArray(subject);
  357. }
  358. function isFunction(subject) {
  359. return typeof subject === "function";
  360. }
  361. function isPrimitive(subject) {
  362. return typeof subject !== "object" || subject === null;
  363. }
  364. function deepClone(obj) {
  365. return JSON.parse(JSON.stringify(obj));
  366. }
  367. function dataGet(object, key) {
  368. if (key === "")
  369. return object;
  370. return key.split(".").reduce((carry, i) => {
  371. return carry?.[i];
  372. }, object);
  373. }
  374. function dataSet(object, key, value) {
  375. let segments = key.split(".");
  376. if (segments.length === 1) {
  377. return object[key] = value;
  378. }
  379. let firstSegment = segments.shift();
  380. let restOfSegments = segments.join(".");
  381. if (object[firstSegment] === void 0) {
  382. object[firstSegment] = {};
  383. }
  384. dataSet(object[firstSegment], restOfSegments, value);
  385. }
  386. function diff(left, right, diffs = {}, path = "") {
  387. if (left === right)
  388. return diffs;
  389. if (typeof left !== typeof right || isObject(left) && isArray(right) || isArray(left) && isObject(right)) {
  390. diffs[path] = right;
  391. return diffs;
  392. }
  393. if (isPrimitive(left) || isPrimitive(right)) {
  394. diffs[path] = right;
  395. return diffs;
  396. }
  397. let leftKeys = Object.keys(left);
  398. Object.entries(right).forEach(([key, value]) => {
  399. diffs = { ...diffs, ...diff(left[key], right[key], diffs, path === "" ? key : `${path}.${key}`) };
  400. leftKeys = leftKeys.filter((i) => i !== key);
  401. });
  402. leftKeys.forEach((key) => {
  403. diffs[`${path}.${key}`] = "__rm__";
  404. });
  405. return diffs;
  406. }
  407. function extractData(payload) {
  408. let value = isSynthetic(payload) ? payload[0] : payload;
  409. let meta = isSynthetic(payload) ? payload[1] : void 0;
  410. if (isObjecty(value)) {
  411. Object.entries(value).forEach(([key, iValue]) => {
  412. value[key] = extractData(iValue);
  413. });
  414. }
  415. return value;
  416. }
  417. function isSynthetic(subject) {
  418. return Array.isArray(subject) && subject.length === 2 && typeof subject[1] === "object" && Object.keys(subject[1]).includes("s");
  419. }
  420. function getCsrfToken() {
  421. if (document.querySelector('meta[name="csrf-token"]')) {
  422. return document.querySelector('meta[name="csrf-token"]').getAttribute("content");
  423. }
  424. if (document.querySelector("[data-csrf]")) {
  425. return document.querySelector("[data-csrf]").getAttribute("data-csrf");
  426. }
  427. if (window.livewireScriptConfig["csrf"] ?? false) {
  428. return window.livewireScriptConfig["csrf"];
  429. }
  430. throw "Livewire: No CSRF token detected";
  431. }
  432. var nonce;
  433. function getNonce() {
  434. if (nonce)
  435. return nonce;
  436. if (window.livewireScriptConfig && (window.livewireScriptConfig["nonce"] ?? false)) {
  437. nonce = window.livewireScriptConfig["nonce"];
  438. return nonce;
  439. }
  440. const elWithNonce = document.querySelector("style[data-livewire-style][nonce]");
  441. if (elWithNonce) {
  442. nonce = elWithNonce.nonce;
  443. return nonce;
  444. }
  445. return null;
  446. }
  447. function getUpdateUri() {
  448. return document.querySelector("[data-update-uri]")?.getAttribute("data-update-uri") ?? window.livewireScriptConfig["uri"] ?? null;
  449. }
  450. function contentIsFromDump(content) {
  451. return !!content.match(/<script>Sfdump\(".+"\)<\/script>/);
  452. }
  453. function splitDumpFromContent(content) {
  454. let dump = content.match(/.*<script>Sfdump\(".+"\)<\/script>/s);
  455. return [dump, content.replace(dump, "")];
  456. }
  457. // js/features/supportFileUploads.js
  458. var uploadManagers = /* @__PURE__ */ new WeakMap();
  459. function getUploadManager(component) {
  460. if (!uploadManagers.has(component)) {
  461. let manager = new UploadManager(component);
  462. uploadManagers.set(component, manager);
  463. manager.registerListeners();
  464. }
  465. return uploadManagers.get(component);
  466. }
  467. function handleFileUpload(el, property, component, cleanup2) {
  468. let manager = getUploadManager(component);
  469. let start3 = () => el.dispatchEvent(new CustomEvent("livewire-upload-start", { bubbles: true, detail: { id: component.id, property } }));
  470. let finish = () => el.dispatchEvent(new CustomEvent("livewire-upload-finish", { bubbles: true, detail: { id: component.id, property } }));
  471. let error2 = () => el.dispatchEvent(new CustomEvent("livewire-upload-error", { bubbles: true, detail: { id: component.id, property } }));
  472. let cancel = () => el.dispatchEvent(new CustomEvent("livewire-upload-cancel", { bubbles: true, detail: { id: component.id, property } }));
  473. let progress = (progressEvent) => {
  474. var percentCompleted = Math.round(progressEvent.loaded * 100 / progressEvent.total);
  475. el.dispatchEvent(new CustomEvent("livewire-upload-progress", {
  476. bubbles: true,
  477. detail: { progress: percentCompleted }
  478. }));
  479. };
  480. let eventHandler = (e) => {
  481. if (e.target.files.length === 0)
  482. return;
  483. start3();
  484. if (e.target.multiple) {
  485. manager.uploadMultiple(property, e.target.files, finish, error2, progress, cancel);
  486. } else {
  487. manager.upload(property, e.target.files[0], finish, error2, progress, cancel);
  488. }
  489. };
  490. el.addEventListener("change", eventHandler);
  491. component.$wire.$watch(property, (value) => {
  492. if (!el.isConnected)
  493. return;
  494. if (value === null || value === "") {
  495. el.value = "";
  496. }
  497. if (el.multiple && Array.isArray(value) && value.length === 0) {
  498. el.value = "";
  499. }
  500. });
  501. let clearFileInputValue = () => {
  502. el.value = null;
  503. };
  504. el.addEventListener("click", clearFileInputValue);
  505. el.addEventListener("livewire-upload-cancel", clearFileInputValue);
  506. cleanup2(() => {
  507. el.removeEventListener("change", eventHandler);
  508. el.removeEventListener("click", clearFileInputValue);
  509. });
  510. }
  511. var UploadManager = class {
  512. constructor(component) {
  513. this.component = component;
  514. this.uploadBag = new MessageBag();
  515. this.removeBag = new MessageBag();
  516. }
  517. registerListeners() {
  518. this.component.$wire.$on("upload:generatedSignedUrl", ({ name, url }) => {
  519. setUploadLoading(this.component, name);
  520. this.handleSignedUrl(name, url);
  521. });
  522. this.component.$wire.$on("upload:generatedSignedUrlForS3", ({ name, payload }) => {
  523. setUploadLoading(this.component, name);
  524. this.handleS3PreSignedUrl(name, payload);
  525. });
  526. this.component.$wire.$on("upload:finished", ({ name, tmpFilenames }) => this.markUploadFinished(name, tmpFilenames));
  527. this.component.$wire.$on("upload:errored", ({ name }) => this.markUploadErrored(name));
  528. this.component.$wire.$on("upload:removed", ({ name, tmpFilename }) => this.removeBag.shift(name).finishCallback(tmpFilename));
  529. }
  530. upload(name, file, finishCallback, errorCallback, progressCallback, cancelledCallback) {
  531. this.setUpload(name, {
  532. files: [file],
  533. multiple: false,
  534. finishCallback,
  535. errorCallback,
  536. progressCallback,
  537. cancelledCallback
  538. });
  539. }
  540. uploadMultiple(name, files, finishCallback, errorCallback, progressCallback, cancelledCallback) {
  541. this.setUpload(name, {
  542. files: Array.from(files),
  543. multiple: true,
  544. finishCallback,
  545. errorCallback,
  546. progressCallback,
  547. cancelledCallback
  548. });
  549. }
  550. removeUpload(name, tmpFilename, finishCallback) {
  551. this.removeBag.push(name, {
  552. tmpFilename,
  553. finishCallback
  554. });
  555. this.component.$wire.call("_removeUpload", name, tmpFilename);
  556. }
  557. setUpload(name, uploadObject) {
  558. this.uploadBag.add(name, uploadObject);
  559. if (this.uploadBag.get(name).length === 1) {
  560. this.startUpload(name, uploadObject);
  561. }
  562. }
  563. handleSignedUrl(name, url) {
  564. let formData = new FormData();
  565. Array.from(this.uploadBag.first(name).files).forEach((file) => formData.append("files[]", file, file.name));
  566. let headers = {
  567. "Accept": "application/json"
  568. };
  569. let csrfToken = getCsrfToken();
  570. if (csrfToken)
  571. headers["X-CSRF-TOKEN"] = csrfToken;
  572. this.makeRequest(name, formData, "post", url, headers, (response) => {
  573. return response.paths;
  574. });
  575. }
  576. handleS3PreSignedUrl(name, payload) {
  577. let formData = this.uploadBag.first(name).files[0];
  578. let headers = payload.headers;
  579. if ("Host" in headers)
  580. delete headers.Host;
  581. let url = payload.url;
  582. this.makeRequest(name, formData, "put", url, headers, (response) => {
  583. return [payload.path];
  584. });
  585. }
  586. makeRequest(name, formData, method, url, headers, retrievePaths) {
  587. let request = new XMLHttpRequest();
  588. request.open(method, url);
  589. Object.entries(headers).forEach(([key, value]) => {
  590. request.setRequestHeader(key, value);
  591. });
  592. request.upload.addEventListener("progress", (e) => {
  593. e.detail = {};
  594. e.detail.progress = Math.floor(e.loaded * 100 / e.total);
  595. this.uploadBag.first(name).progressCallback(e);
  596. });
  597. request.addEventListener("load", () => {
  598. if ((request.status + "")[0] === "2") {
  599. let paths = retrievePaths(request.response && JSON.parse(request.response));
  600. this.component.$wire.call("_finishUpload", name, paths, this.uploadBag.first(name).multiple);
  601. return;
  602. }
  603. let errors = null;
  604. if (request.status === 422) {
  605. errors = request.response;
  606. }
  607. this.component.$wire.call("_uploadErrored", name, errors, this.uploadBag.first(name).multiple);
  608. });
  609. this.uploadBag.first(name).request = request;
  610. request.send(formData);
  611. }
  612. startUpload(name, uploadObject) {
  613. let fileInfos = uploadObject.files.map((file) => {
  614. return { name: file.name, size: file.size, type: file.type };
  615. });
  616. this.component.$wire.call("_startUpload", name, fileInfos, uploadObject.multiple);
  617. setUploadLoading(this.component, name);
  618. }
  619. markUploadFinished(name, tmpFilenames) {
  620. unsetUploadLoading(this.component);
  621. let uploadObject = this.uploadBag.shift(name);
  622. uploadObject.finishCallback(uploadObject.multiple ? tmpFilenames : tmpFilenames[0]);
  623. if (this.uploadBag.get(name).length > 0)
  624. this.startUpload(name, this.uploadBag.last(name));
  625. }
  626. markUploadErrored(name) {
  627. unsetUploadLoading(this.component);
  628. this.uploadBag.shift(name).errorCallback();
  629. if (this.uploadBag.get(name).length > 0)
  630. this.startUpload(name, this.uploadBag.last(name));
  631. }
  632. cancelUpload(name, cancelledCallback = null) {
  633. unsetUploadLoading(this.component);
  634. let uploadItem = this.uploadBag.first(name);
  635. if (uploadItem) {
  636. if (uploadItem.request) {
  637. uploadItem.request.abort();
  638. }
  639. this.uploadBag.shift(name).cancelledCallback();
  640. if (cancelledCallback)
  641. cancelledCallback();
  642. }
  643. }
  644. };
  645. var MessageBag = class {
  646. constructor() {
  647. this.bag = {};
  648. }
  649. add(name, thing) {
  650. if (!this.bag[name]) {
  651. this.bag[name] = [];
  652. }
  653. this.bag[name].push(thing);
  654. }
  655. push(name, thing) {
  656. this.add(name, thing);
  657. }
  658. first(name) {
  659. if (!this.bag[name])
  660. return null;
  661. return this.bag[name][0];
  662. }
  663. last(name) {
  664. return this.bag[name].slice(-1)[0];
  665. }
  666. get(name) {
  667. return this.bag[name];
  668. }
  669. shift(name) {
  670. return this.bag[name].shift();
  671. }
  672. call(name, ...params) {
  673. (this.listeners[name] || []).forEach((callback) => {
  674. callback(...params);
  675. });
  676. }
  677. has(name) {
  678. return Object.keys(this.listeners).includes(name);
  679. }
  680. };
  681. function setUploadLoading() {
  682. }
  683. function unsetUploadLoading() {
  684. }
  685. function upload(component, name, file, finishCallback = () => {
  686. }, errorCallback = () => {
  687. }, progressCallback = () => {
  688. }, cancelledCallback = () => {
  689. }) {
  690. let uploadManager = getUploadManager(component);
  691. uploadManager.upload(name, file, finishCallback, errorCallback, progressCallback, cancelledCallback);
  692. }
  693. function uploadMultiple(component, name, files, finishCallback = () => {
  694. }, errorCallback = () => {
  695. }, progressCallback = () => {
  696. }, cancelledCallback = () => {
  697. }) {
  698. let uploadManager = getUploadManager(component);
  699. uploadManager.uploadMultiple(name, files, finishCallback, errorCallback, progressCallback, cancelledCallback);
  700. }
  701. function removeUpload(component, name, tmpFilename, finishCallback = () => {
  702. }, errorCallback = () => {
  703. }) {
  704. let uploadManager = getUploadManager(component);
  705. uploadManager.removeUpload(name, tmpFilename, finishCallback, errorCallback);
  706. }
  707. function cancelUpload(component, name, cancelledCallback = () => {
  708. }) {
  709. let uploadManager = getUploadManager(component);
  710. uploadManager.cancelUpload(name, cancelledCallback);
  711. }
  712. // ../alpine/packages/alpinejs/dist/module.esm.js
  713. var flushPending = false;
  714. var flushing = false;
  715. var queue = [];
  716. var lastFlushedIndex = -1;
  717. function scheduler(callback) {
  718. queueJob(callback);
  719. }
  720. function queueJob(job) {
  721. if (!queue.includes(job))
  722. queue.push(job);
  723. queueFlush();
  724. }
  725. function dequeueJob(job) {
  726. let index = queue.indexOf(job);
  727. if (index !== -1 && index > lastFlushedIndex)
  728. queue.splice(index, 1);
  729. }
  730. function queueFlush() {
  731. if (!flushing && !flushPending) {
  732. flushPending = true;
  733. queueMicrotask(flushJobs);
  734. }
  735. }
  736. function flushJobs() {
  737. flushPending = false;
  738. flushing = true;
  739. for (let i = 0; i < queue.length; i++) {
  740. queue[i]();
  741. lastFlushedIndex = i;
  742. }
  743. queue.length = 0;
  744. lastFlushedIndex = -1;
  745. flushing = false;
  746. }
  747. var reactive;
  748. var effect;
  749. var release;
  750. var raw;
  751. var shouldSchedule = true;
  752. function disableEffectScheduling(callback) {
  753. shouldSchedule = false;
  754. callback();
  755. shouldSchedule = true;
  756. }
  757. function setReactivityEngine(engine) {
  758. reactive = engine.reactive;
  759. release = engine.release;
  760. effect = (callback) => engine.effect(callback, { scheduler: (task) => {
  761. if (shouldSchedule) {
  762. scheduler(task);
  763. } else {
  764. task();
  765. }
  766. } });
  767. raw = engine.raw;
  768. }
  769. function overrideEffect(override) {
  770. effect = override;
  771. }
  772. function elementBoundEffect(el) {
  773. let cleanup2 = () => {
  774. };
  775. let wrappedEffect = (callback) => {
  776. let effectReference = effect(callback);
  777. if (!el._x_effects) {
  778. el._x_effects = /* @__PURE__ */ new Set();
  779. el._x_runEffects = () => {
  780. el._x_effects.forEach((i) => i());
  781. };
  782. }
  783. el._x_effects.add(effectReference);
  784. cleanup2 = () => {
  785. if (effectReference === void 0)
  786. return;
  787. el._x_effects.delete(effectReference);
  788. release(effectReference);
  789. };
  790. return effectReference;
  791. };
  792. return [wrappedEffect, () => {
  793. cleanup2();
  794. }];
  795. }
  796. function watch(getter, callback) {
  797. let firstTime = true;
  798. let oldValue;
  799. let effectReference = effect(() => {
  800. let value = getter();
  801. JSON.stringify(value);
  802. if (!firstTime) {
  803. queueMicrotask(() => {
  804. callback(value, oldValue);
  805. oldValue = value;
  806. });
  807. } else {
  808. oldValue = value;
  809. }
  810. firstTime = false;
  811. });
  812. return () => release(effectReference);
  813. }
  814. var onAttributeAddeds = [];
  815. var onElRemoveds = [];
  816. var onElAddeds = [];
  817. function onElAdded(callback) {
  818. onElAddeds.push(callback);
  819. }
  820. function onElRemoved(el, callback) {
  821. if (typeof callback === "function") {
  822. if (!el._x_cleanups)
  823. el._x_cleanups = [];
  824. el._x_cleanups.push(callback);
  825. } else {
  826. callback = el;
  827. onElRemoveds.push(callback);
  828. }
  829. }
  830. function onAttributesAdded(callback) {
  831. onAttributeAddeds.push(callback);
  832. }
  833. function onAttributeRemoved(el, name, callback) {
  834. if (!el._x_attributeCleanups)
  835. el._x_attributeCleanups = {};
  836. if (!el._x_attributeCleanups[name])
  837. el._x_attributeCleanups[name] = [];
  838. el._x_attributeCleanups[name].push(callback);
  839. }
  840. function cleanupAttributes(el, names) {
  841. if (!el._x_attributeCleanups)
  842. return;
  843. Object.entries(el._x_attributeCleanups).forEach(([name, value]) => {
  844. if (names === void 0 || names.includes(name)) {
  845. value.forEach((i) => i());
  846. delete el._x_attributeCleanups[name];
  847. }
  848. });
  849. }
  850. function cleanupElement(el) {
  851. el._x_effects?.forEach(dequeueJob);
  852. while (el._x_cleanups?.length)
  853. el._x_cleanups.pop()();
  854. }
  855. var observer = new MutationObserver(onMutate);
  856. var currentlyObserving = false;
  857. function startObservingMutations() {
  858. observer.observe(document, { subtree: true, childList: true, attributes: true, attributeOldValue: true });
  859. currentlyObserving = true;
  860. }
  861. function stopObservingMutations() {
  862. flushObserver();
  863. observer.disconnect();
  864. currentlyObserving = false;
  865. }
  866. var queuedMutations = [];
  867. function flushObserver() {
  868. let records = observer.takeRecords();
  869. queuedMutations.push(() => records.length > 0 && onMutate(records));
  870. let queueLengthWhenTriggered = queuedMutations.length;
  871. queueMicrotask(() => {
  872. if (queuedMutations.length === queueLengthWhenTriggered) {
  873. while (queuedMutations.length > 0)
  874. queuedMutations.shift()();
  875. }
  876. });
  877. }
  878. function mutateDom(callback) {
  879. if (!currentlyObserving)
  880. return callback();
  881. stopObservingMutations();
  882. let result = callback();
  883. startObservingMutations();
  884. return result;
  885. }
  886. var isCollecting = false;
  887. var deferredMutations = [];
  888. function deferMutations() {
  889. isCollecting = true;
  890. }
  891. function flushAndStopDeferringMutations() {
  892. isCollecting = false;
  893. onMutate(deferredMutations);
  894. deferredMutations = [];
  895. }
  896. function onMutate(mutations) {
  897. if (isCollecting) {
  898. deferredMutations = deferredMutations.concat(mutations);
  899. return;
  900. }
  901. let addedNodes = [];
  902. let removedNodes = /* @__PURE__ */ new Set();
  903. let addedAttributes = /* @__PURE__ */ new Map();
  904. let removedAttributes = /* @__PURE__ */ new Map();
  905. for (let i = 0; i < mutations.length; i++) {
  906. if (mutations[i].target._x_ignoreMutationObserver)
  907. continue;
  908. if (mutations[i].type === "childList") {
  909. mutations[i].removedNodes.forEach((node) => {
  910. if (node.nodeType !== 1)
  911. return;
  912. if (!node._x_marker)
  913. return;
  914. removedNodes.add(node);
  915. });
  916. mutations[i].addedNodes.forEach((node) => {
  917. if (node.nodeType !== 1)
  918. return;
  919. if (removedNodes.has(node)) {
  920. removedNodes.delete(node);
  921. return;
  922. }
  923. if (node._x_marker)
  924. return;
  925. addedNodes.push(node);
  926. });
  927. }
  928. if (mutations[i].type === "attributes") {
  929. let el = mutations[i].target;
  930. let name = mutations[i].attributeName;
  931. let oldValue = mutations[i].oldValue;
  932. let add2 = () => {
  933. if (!addedAttributes.has(el))
  934. addedAttributes.set(el, []);
  935. addedAttributes.get(el).push({ name, value: el.getAttribute(name) });
  936. };
  937. let remove = () => {
  938. if (!removedAttributes.has(el))
  939. removedAttributes.set(el, []);
  940. removedAttributes.get(el).push(name);
  941. };
  942. if (el.hasAttribute(name) && oldValue === null) {
  943. add2();
  944. } else if (el.hasAttribute(name)) {
  945. remove();
  946. add2();
  947. } else {
  948. remove();
  949. }
  950. }
  951. }
  952. removedAttributes.forEach((attrs, el) => {
  953. cleanupAttributes(el, attrs);
  954. });
  955. addedAttributes.forEach((attrs, el) => {
  956. onAttributeAddeds.forEach((i) => i(el, attrs));
  957. });
  958. for (let node of removedNodes) {
  959. if (addedNodes.some((i) => i.contains(node)))
  960. continue;
  961. onElRemoveds.forEach((i) => i(node));
  962. }
  963. for (let node of addedNodes) {
  964. if (!node.isConnected)
  965. continue;
  966. onElAddeds.forEach((i) => i(node));
  967. }
  968. addedNodes = null;
  969. removedNodes = null;
  970. addedAttributes = null;
  971. removedAttributes = null;
  972. }
  973. function scope(node) {
  974. return mergeProxies(closestDataStack(node));
  975. }
  976. function addScopeToNode(node, data2, referenceNode) {
  977. node._x_dataStack = [data2, ...closestDataStack(referenceNode || node)];
  978. return () => {
  979. node._x_dataStack = node._x_dataStack.filter((i) => i !== data2);
  980. };
  981. }
  982. function closestDataStack(node) {
  983. if (node._x_dataStack)
  984. return node._x_dataStack;
  985. if (typeof ShadowRoot === "function" && node instanceof ShadowRoot) {
  986. return closestDataStack(node.host);
  987. }
  988. if (!node.parentNode) {
  989. return [];
  990. }
  991. return closestDataStack(node.parentNode);
  992. }
  993. function mergeProxies(objects) {
  994. return new Proxy({ objects }, mergeProxyTrap);
  995. }
  996. var mergeProxyTrap = {
  997. ownKeys({ objects }) {
  998. return Array.from(new Set(objects.flatMap((i) => Object.keys(i))));
  999. },
  1000. has({ objects }, name) {
  1001. if (name == Symbol.unscopables)
  1002. return false;
  1003. return objects.some((obj) => Object.prototype.hasOwnProperty.call(obj, name) || Reflect.has(obj, name));
  1004. },
  1005. get({ objects }, name, thisProxy) {
  1006. if (name == "toJSON")
  1007. return collapseProxies;
  1008. return Reflect.get(objects.find((obj) => Reflect.has(obj, name)) || {}, name, thisProxy);
  1009. },
  1010. set({ objects }, name, value, thisProxy) {
  1011. const target = objects.find((obj) => Object.prototype.hasOwnProperty.call(obj, name)) || objects[objects.length - 1];
  1012. const descriptor = Object.getOwnPropertyDescriptor(target, name);
  1013. if (descriptor?.set && descriptor?.get)
  1014. return descriptor.set.call(thisProxy, value) || true;
  1015. return Reflect.set(target, name, value);
  1016. }
  1017. };
  1018. function collapseProxies() {
  1019. let keys = Reflect.ownKeys(this);
  1020. return keys.reduce((acc, key) => {
  1021. acc[key] = Reflect.get(this, key);
  1022. return acc;
  1023. }, {});
  1024. }
  1025. function initInterceptors(data2) {
  1026. let isObject22 = (val) => typeof val === "object" && !Array.isArray(val) && val !== null;
  1027. let recurse = (obj, basePath = "") => {
  1028. Object.entries(Object.getOwnPropertyDescriptors(obj)).forEach(([key, { value, enumerable }]) => {
  1029. if (enumerable === false || value === void 0)
  1030. return;
  1031. if (typeof value === "object" && value !== null && value.__v_skip)
  1032. return;
  1033. let path = basePath === "" ? key : `${basePath}.${key}`;
  1034. if (typeof value === "object" && value !== null && value._x_interceptor) {
  1035. obj[key] = value.initialize(data2, path, key);
  1036. } else {
  1037. if (isObject22(value) && value !== obj && !(value instanceof Element)) {
  1038. recurse(value, path);
  1039. }
  1040. }
  1041. });
  1042. };
  1043. return recurse(data2);
  1044. }
  1045. function interceptor(callback, mutateObj = () => {
  1046. }) {
  1047. let obj = {
  1048. initialValue: void 0,
  1049. _x_interceptor: true,
  1050. initialize(data2, path, key) {
  1051. return callback(this.initialValue, () => get(data2, path), (value) => set(data2, path, value), path, key);
  1052. }
  1053. };
  1054. mutateObj(obj);
  1055. return (initialValue) => {
  1056. if (typeof initialValue === "object" && initialValue !== null && initialValue._x_interceptor) {
  1057. let initialize = obj.initialize.bind(obj);
  1058. obj.initialize = (data2, path, key) => {
  1059. let innerValue = initialValue.initialize(data2, path, key);
  1060. obj.initialValue = innerValue;
  1061. return initialize(data2, path, key);
  1062. };
  1063. } else {
  1064. obj.initialValue = initialValue;
  1065. }
  1066. return obj;
  1067. };
  1068. }
  1069. function get(obj, path) {
  1070. return path.split(".").reduce((carry, segment) => carry[segment], obj);
  1071. }
  1072. function set(obj, path, value) {
  1073. if (typeof path === "string")
  1074. path = path.split(".");
  1075. if (path.length === 1)
  1076. obj[path[0]] = value;
  1077. else if (path.length === 0)
  1078. throw error;
  1079. else {
  1080. if (obj[path[0]])
  1081. return set(obj[path[0]], path.slice(1), value);
  1082. else {
  1083. obj[path[0]] = {};
  1084. return set(obj[path[0]], path.slice(1), value);
  1085. }
  1086. }
  1087. }
  1088. var magics = {};
  1089. function magic(name, callback) {
  1090. magics[name] = callback;
  1091. }
  1092. function injectMagics(obj, el) {
  1093. let memoizedUtilities = getUtilities(el);
  1094. Object.entries(magics).forEach(([name, callback]) => {
  1095. Object.defineProperty(obj, `$${name}`, {
  1096. get() {
  1097. return callback(el, memoizedUtilities);
  1098. },
  1099. enumerable: false
  1100. });
  1101. });
  1102. return obj;
  1103. }
  1104. function getUtilities(el) {
  1105. let [utilities, cleanup2] = getElementBoundUtilities(el);
  1106. let utils = { interceptor, ...utilities };
  1107. onElRemoved(el, cleanup2);
  1108. return utils;
  1109. }
  1110. function tryCatch(el, expression, callback, ...args) {
  1111. try {
  1112. return callback(...args);
  1113. } catch (e) {
  1114. handleError(e, el, expression);
  1115. }
  1116. }
  1117. function handleError(error2, el, expression = void 0) {
  1118. error2 = Object.assign(error2 ?? { message: "No error message given." }, { el, expression });
  1119. console.warn(`Alpine Expression Error: ${error2.message}
  1120. ${expression ? 'Expression: "' + expression + '"\n\n' : ""}`, el);
  1121. setTimeout(() => {
  1122. throw error2;
  1123. }, 0);
  1124. }
  1125. var shouldAutoEvaluateFunctions = true;
  1126. function dontAutoEvaluateFunctions(callback) {
  1127. let cache = shouldAutoEvaluateFunctions;
  1128. shouldAutoEvaluateFunctions = false;
  1129. let result = callback();
  1130. shouldAutoEvaluateFunctions = cache;
  1131. return result;
  1132. }
  1133. function evaluate(el, expression, extras = {}) {
  1134. let result;
  1135. evaluateLater(el, expression)((value) => result = value, extras);
  1136. return result;
  1137. }
  1138. function evaluateLater(...args) {
  1139. return theEvaluatorFunction(...args);
  1140. }
  1141. var theEvaluatorFunction = normalEvaluator;
  1142. function setEvaluator(newEvaluator) {
  1143. theEvaluatorFunction = newEvaluator;
  1144. }
  1145. function normalEvaluator(el, expression) {
  1146. let overriddenMagics = {};
  1147. injectMagics(overriddenMagics, el);
  1148. let dataStack = [overriddenMagics, ...closestDataStack(el)];
  1149. let evaluator = typeof expression === "function" ? generateEvaluatorFromFunction(dataStack, expression) : generateEvaluatorFromString(dataStack, expression, el);
  1150. return tryCatch.bind(null, el, expression, evaluator);
  1151. }
  1152. function generateEvaluatorFromFunction(dataStack, func) {
  1153. return (receiver = () => {
  1154. }, { scope: scope2 = {}, params = [] } = {}) => {
  1155. let result = func.apply(mergeProxies([scope2, ...dataStack]), params);
  1156. runIfTypeOfFunction(receiver, result);
  1157. };
  1158. }
  1159. var evaluatorMemo = {};
  1160. function generateFunctionFromString(expression, el) {
  1161. if (evaluatorMemo[expression]) {
  1162. return evaluatorMemo[expression];
  1163. }
  1164. let AsyncFunction = Object.getPrototypeOf(async function() {
  1165. }).constructor;
  1166. let rightSideSafeExpression = /^[\n\s]*if.*\(.*\)/.test(expression.trim()) || /^(let|const)\s/.test(expression.trim()) ? `(async()=>{ ${expression} })()` : expression;
  1167. const safeAsyncFunction = () => {
  1168. try {
  1169. let func2 = new AsyncFunction(["__self", "scope"], `with (scope) { __self.result = ${rightSideSafeExpression} }; __self.finished = true; return __self.result;`);
  1170. Object.defineProperty(func2, "name", {
  1171. value: `[Alpine] ${expression}`
  1172. });
  1173. return func2;
  1174. } catch (error2) {
  1175. handleError(error2, el, expression);
  1176. return Promise.resolve();
  1177. }
  1178. };
  1179. let func = safeAsyncFunction();
  1180. evaluatorMemo[expression] = func;
  1181. return func;
  1182. }
  1183. function generateEvaluatorFromString(dataStack, expression, el) {
  1184. let func = generateFunctionFromString(expression, el);
  1185. return (receiver = () => {
  1186. }, { scope: scope2 = {}, params = [] } = {}) => {
  1187. func.result = void 0;
  1188. func.finished = false;
  1189. let completeScope = mergeProxies([scope2, ...dataStack]);
  1190. if (typeof func === "function") {
  1191. let promise = func(func, completeScope).catch((error2) => handleError(error2, el, expression));
  1192. if (func.finished) {
  1193. runIfTypeOfFunction(receiver, func.result, completeScope, params, el);
  1194. func.result = void 0;
  1195. } else {
  1196. promise.then((result) => {
  1197. runIfTypeOfFunction(receiver, result, completeScope, params, el);
  1198. }).catch((error2) => handleError(error2, el, expression)).finally(() => func.result = void 0);
  1199. }
  1200. }
  1201. };
  1202. }
  1203. function runIfTypeOfFunction(receiver, value, scope2, params, el) {
  1204. if (shouldAutoEvaluateFunctions && typeof value === "function") {
  1205. let result = value.apply(scope2, params);
  1206. if (result instanceof Promise) {
  1207. result.then((i) => runIfTypeOfFunction(receiver, i, scope2, params)).catch((error2) => handleError(error2, el, value));
  1208. } else {
  1209. receiver(result);
  1210. }
  1211. } else if (typeof value === "object" && value instanceof Promise) {
  1212. value.then((i) => receiver(i));
  1213. } else {
  1214. receiver(value);
  1215. }
  1216. }
  1217. var prefixAsString = "x-";
  1218. function prefix(subject = "") {
  1219. return prefixAsString + subject;
  1220. }
  1221. function setPrefix(newPrefix) {
  1222. prefixAsString = newPrefix;
  1223. }
  1224. var directiveHandlers = {};
  1225. function directive(name, callback) {
  1226. directiveHandlers[name] = callback;
  1227. return {
  1228. before(directive22) {
  1229. if (!directiveHandlers[directive22]) {
  1230. console.warn(String.raw`Cannot find directive \`${directive22}\`. \`${name}\` will use the default order of execution`);
  1231. return;
  1232. }
  1233. const pos = directiveOrder.indexOf(directive22);
  1234. directiveOrder.splice(pos >= 0 ? pos : directiveOrder.indexOf("DEFAULT"), 0, name);
  1235. }
  1236. };
  1237. }
  1238. function directiveExists(name) {
  1239. return Object.keys(directiveHandlers).includes(name);
  1240. }
  1241. function directives(el, attributes, originalAttributeOverride) {
  1242. attributes = Array.from(attributes);
  1243. if (el._x_virtualDirectives) {
  1244. let vAttributes = Object.entries(el._x_virtualDirectives).map(([name, value]) => ({ name, value }));
  1245. let staticAttributes = attributesOnly(vAttributes);
  1246. vAttributes = vAttributes.map((attribute) => {
  1247. if (staticAttributes.find((attr) => attr.name === attribute.name)) {
  1248. return {
  1249. name: `x-bind:${attribute.name}`,
  1250. value: `"${attribute.value}"`
  1251. };
  1252. }
  1253. return attribute;
  1254. });
  1255. attributes = attributes.concat(vAttributes);
  1256. }
  1257. let transformedAttributeMap = {};
  1258. let directives2 = attributes.map(toTransformedAttributes((newName, oldName) => transformedAttributeMap[newName] = oldName)).filter(outNonAlpineAttributes).map(toParsedDirectives(transformedAttributeMap, originalAttributeOverride)).sort(byPriority);
  1259. return directives2.map((directive22) => {
  1260. return getDirectiveHandler(el, directive22);
  1261. });
  1262. }
  1263. function attributesOnly(attributes) {
  1264. return Array.from(attributes).map(toTransformedAttributes()).filter((attr) => !outNonAlpineAttributes(attr));
  1265. }
  1266. var isDeferringHandlers = false;
  1267. var directiveHandlerStacks = /* @__PURE__ */ new Map();
  1268. var currentHandlerStackKey = Symbol();
  1269. function deferHandlingDirectives(callback) {
  1270. isDeferringHandlers = true;
  1271. let key = Symbol();
  1272. currentHandlerStackKey = key;
  1273. directiveHandlerStacks.set(key, []);
  1274. let flushHandlers = () => {
  1275. while (directiveHandlerStacks.get(key).length)
  1276. directiveHandlerStacks.get(key).shift()();
  1277. directiveHandlerStacks.delete(key);
  1278. };
  1279. let stopDeferring = () => {
  1280. isDeferringHandlers = false;
  1281. flushHandlers();
  1282. };
  1283. callback(flushHandlers);
  1284. stopDeferring();
  1285. }
  1286. function getElementBoundUtilities(el) {
  1287. let cleanups2 = [];
  1288. let cleanup2 = (callback) => cleanups2.push(callback);
  1289. let [effect3, cleanupEffect] = elementBoundEffect(el);
  1290. cleanups2.push(cleanupEffect);
  1291. let utilities = {
  1292. Alpine: alpine_default,
  1293. effect: effect3,
  1294. cleanup: cleanup2,
  1295. evaluateLater: evaluateLater.bind(evaluateLater, el),
  1296. evaluate: evaluate.bind(evaluate, el)
  1297. };
  1298. let doCleanup = () => cleanups2.forEach((i) => i());
  1299. return [utilities, doCleanup];
  1300. }
  1301. function getDirectiveHandler(el, directive22) {
  1302. let noop = () => {
  1303. };
  1304. let handler4 = directiveHandlers[directive22.type] || noop;
  1305. let [utilities, cleanup2] = getElementBoundUtilities(el);
  1306. onAttributeRemoved(el, directive22.original, cleanup2);
  1307. let fullHandler = () => {
  1308. if (el._x_ignore || el._x_ignoreSelf)
  1309. return;
  1310. handler4.inline && handler4.inline(el, directive22, utilities);
  1311. handler4 = handler4.bind(handler4, el, directive22, utilities);
  1312. isDeferringHandlers ? directiveHandlerStacks.get(currentHandlerStackKey).push(handler4) : handler4();
  1313. };
  1314. fullHandler.runCleanups = cleanup2;
  1315. return fullHandler;
  1316. }
  1317. var startingWith = (subject, replacement) => ({ name, value }) => {
  1318. if (name.startsWith(subject))
  1319. name = name.replace(subject, replacement);
  1320. return { name, value };
  1321. };
  1322. var into = (i) => i;
  1323. function toTransformedAttributes(callback = () => {
  1324. }) {
  1325. return ({ name, value }) => {
  1326. let { name: newName, value: newValue } = attributeTransformers.reduce((carry, transform) => {
  1327. return transform(carry);
  1328. }, { name, value });
  1329. if (newName !== name)
  1330. callback(newName, name);
  1331. return { name: newName, value: newValue };
  1332. };
  1333. }
  1334. var attributeTransformers = [];
  1335. function mapAttributes(callback) {
  1336. attributeTransformers.push(callback);
  1337. }
  1338. function outNonAlpineAttributes({ name }) {
  1339. return alpineAttributeRegex().test(name);
  1340. }
  1341. var alpineAttributeRegex = () => new RegExp(`^${prefixAsString}([^:^.]+)\\b`);
  1342. function toParsedDirectives(transformedAttributeMap, originalAttributeOverride) {
  1343. return ({ name, value }) => {
  1344. let typeMatch = name.match(alpineAttributeRegex());
  1345. let valueMatch = name.match(/:([a-zA-Z0-9\-_:]+)/);
  1346. let modifiers = name.match(/\.[^.\]]+(?=[^\]]*$)/g) || [];
  1347. let original = originalAttributeOverride || transformedAttributeMap[name] || name;
  1348. return {
  1349. type: typeMatch ? typeMatch[1] : null,
  1350. value: valueMatch ? valueMatch[1] : null,
  1351. modifiers: modifiers.map((i) => i.replace(".", "")),
  1352. expression: value,
  1353. original
  1354. };
  1355. };
  1356. }
  1357. var DEFAULT = "DEFAULT";
  1358. var directiveOrder = [
  1359. "ignore",
  1360. "ref",
  1361. "data",
  1362. "id",
  1363. "anchor",
  1364. "bind",
  1365. "init",
  1366. "for",
  1367. "model",
  1368. "modelable",
  1369. "transition",
  1370. "show",
  1371. "if",
  1372. DEFAULT,
  1373. "teleport"
  1374. ];
  1375. function byPriority(a, b) {
  1376. let typeA = directiveOrder.indexOf(a.type) === -1 ? DEFAULT : a.type;
  1377. let typeB = directiveOrder.indexOf(b.type) === -1 ? DEFAULT : b.type;
  1378. return directiveOrder.indexOf(typeA) - directiveOrder.indexOf(typeB);
  1379. }
  1380. function dispatch2(el, name, detail = {}) {
  1381. el.dispatchEvent(new CustomEvent(name, {
  1382. detail,
  1383. bubbles: true,
  1384. composed: true,
  1385. cancelable: true
  1386. }));
  1387. }
  1388. function walk(el, callback) {
  1389. if (typeof ShadowRoot === "function" && el instanceof ShadowRoot) {
  1390. Array.from(el.children).forEach((el2) => walk(el2, callback));
  1391. return;
  1392. }
  1393. let skip = false;
  1394. callback(el, () => skip = true);
  1395. if (skip)
  1396. return;
  1397. let node = el.firstElementChild;
  1398. while (node) {
  1399. walk(node, callback, false);
  1400. node = node.nextElementSibling;
  1401. }
  1402. }
  1403. function warn(message, ...args) {
  1404. console.warn(`Alpine Warning: ${message}`, ...args);
  1405. }
  1406. var started = false;
  1407. function start() {
  1408. if (started)
  1409. warn("Alpine has already been initialized on this page. Calling Alpine.start() more than once can cause problems.");
  1410. started = true;
  1411. if (!document.body)
  1412. warn("Unable to initialize. Trying to load Alpine before `<body>` is available. Did you forget to add `defer` in Alpine's `<script>` tag?");
  1413. dispatch2(document, "alpine:init");
  1414. dispatch2(document, "alpine:initializing");
  1415. startObservingMutations();
  1416. onElAdded((el) => initTree(el, walk));
  1417. onElRemoved((el) => destroyTree(el));
  1418. onAttributesAdded((el, attrs) => {
  1419. directives(el, attrs).forEach((handle) => handle());
  1420. });
  1421. let outNestedComponents = (el) => !closestRoot(el.parentElement, true);
  1422. Array.from(document.querySelectorAll(allSelectors().join(","))).filter(outNestedComponents).forEach((el) => {
  1423. initTree(el);
  1424. });
  1425. dispatch2(document, "alpine:initialized");
  1426. setTimeout(() => {
  1427. warnAboutMissingPlugins();
  1428. });
  1429. }
  1430. var rootSelectorCallbacks = [];
  1431. var initSelectorCallbacks = [];
  1432. function rootSelectors() {
  1433. return rootSelectorCallbacks.map((fn) => fn());
  1434. }
  1435. function allSelectors() {
  1436. return rootSelectorCallbacks.concat(initSelectorCallbacks).map((fn) => fn());
  1437. }
  1438. function addRootSelector(selectorCallback) {
  1439. rootSelectorCallbacks.push(selectorCallback);
  1440. }
  1441. function addInitSelector(selectorCallback) {
  1442. initSelectorCallbacks.push(selectorCallback);
  1443. }
  1444. function closestRoot(el, includeInitSelectors = false) {
  1445. return findClosest(el, (element) => {
  1446. const selectors = includeInitSelectors ? allSelectors() : rootSelectors();
  1447. if (selectors.some((selector) => element.matches(selector)))
  1448. return true;
  1449. });
  1450. }
  1451. function findClosest(el, callback) {
  1452. if (!el)
  1453. return;
  1454. if (callback(el))
  1455. return el;
  1456. if (el._x_teleportBack)
  1457. el = el._x_teleportBack;
  1458. if (!el.parentElement)
  1459. return;
  1460. return findClosest(el.parentElement, callback);
  1461. }
  1462. function isRoot(el) {
  1463. return rootSelectors().some((selector) => el.matches(selector));
  1464. }
  1465. var initInterceptors2 = [];
  1466. function interceptInit(callback) {
  1467. initInterceptors2.push(callback);
  1468. }
  1469. var markerDispenser = 1;
  1470. function initTree(el, walker = walk, intercept = () => {
  1471. }) {
  1472. if (findClosest(el, (i) => i._x_ignore))
  1473. return;
  1474. deferHandlingDirectives(() => {
  1475. walker(el, (el2, skip) => {
  1476. if (el2._x_marker)
  1477. return;
  1478. intercept(el2, skip);
  1479. initInterceptors2.forEach((i) => i(el2, skip));
  1480. directives(el2, el2.attributes).forEach((handle) => handle());
  1481. if (!el2._x_ignore)
  1482. el2._x_marker = markerDispenser++;
  1483. el2._x_ignore && skip();
  1484. });
  1485. });
  1486. }
  1487. function destroyTree(root, walker = walk) {
  1488. walker(root, (el) => {
  1489. cleanupElement(el);
  1490. cleanupAttributes(el);
  1491. delete el._x_marker;
  1492. });
  1493. }
  1494. function warnAboutMissingPlugins() {
  1495. let pluginDirectives = [
  1496. ["ui", "dialog", ["[x-dialog], [x-popover]"]],
  1497. ["anchor", "anchor", ["[x-anchor]"]],
  1498. ["sort", "sort", ["[x-sort]"]]
  1499. ];
  1500. pluginDirectives.forEach(([plugin2, directive22, selectors]) => {
  1501. if (directiveExists(directive22))
  1502. return;
  1503. selectors.some((selector) => {
  1504. if (document.querySelector(selector)) {
  1505. warn(`found "${selector}", but missing ${plugin2} plugin`);
  1506. return true;
  1507. }
  1508. });
  1509. });
  1510. }
  1511. var tickStack = [];
  1512. var isHolding = false;
  1513. function nextTick(callback = () => {
  1514. }) {
  1515. queueMicrotask(() => {
  1516. isHolding || setTimeout(() => {
  1517. releaseNextTicks();
  1518. });
  1519. });
  1520. return new Promise((res) => {
  1521. tickStack.push(() => {
  1522. callback();
  1523. res();
  1524. });
  1525. });
  1526. }
  1527. function releaseNextTicks() {
  1528. isHolding = false;
  1529. while (tickStack.length)
  1530. tickStack.shift()();
  1531. }
  1532. function holdNextTicks() {
  1533. isHolding = true;
  1534. }
  1535. function setClasses(el, value) {
  1536. if (Array.isArray(value)) {
  1537. return setClassesFromString(el, value.join(" "));
  1538. } else if (typeof value === "object" && value !== null) {
  1539. return setClassesFromObject(el, value);
  1540. } else if (typeof value === "function") {
  1541. return setClasses(el, value());
  1542. }
  1543. return setClassesFromString(el, value);
  1544. }
  1545. function setClassesFromString(el, classString) {
  1546. let split = (classString2) => classString2.split(" ").filter(Boolean);
  1547. let missingClasses = (classString2) => classString2.split(" ").filter((i) => !el.classList.contains(i)).filter(Boolean);
  1548. let addClassesAndReturnUndo = (classes) => {
  1549. el.classList.add(...classes);
  1550. return () => {
  1551. el.classList.remove(...classes);
  1552. };
  1553. };
  1554. classString = classString === true ? classString = "" : classString || "";
  1555. return addClassesAndReturnUndo(missingClasses(classString));
  1556. }
  1557. function setClassesFromObject(el, classObject) {
  1558. let split = (classString) => classString.split(" ").filter(Boolean);
  1559. let forAdd = Object.entries(classObject).flatMap(([classString, bool]) => bool ? split(classString) : false).filter(Boolean);
  1560. let forRemove = Object.entries(classObject).flatMap(([classString, bool]) => !bool ? split(classString) : false).filter(Boolean);
  1561. let added = [];
  1562. let removed = [];
  1563. forRemove.forEach((i) => {
  1564. if (el.classList.contains(i)) {
  1565. el.classList.remove(i);
  1566. removed.push(i);
  1567. }
  1568. });
  1569. forAdd.forEach((i) => {
  1570. if (!el.classList.contains(i)) {
  1571. el.classList.add(i);
  1572. added.push(i);
  1573. }
  1574. });
  1575. return () => {
  1576. removed.forEach((i) => el.classList.add(i));
  1577. added.forEach((i) => el.classList.remove(i));
  1578. };
  1579. }
  1580. function setStyles(el, value) {
  1581. if (typeof value === "object" && value !== null) {
  1582. return setStylesFromObject(el, value);
  1583. }
  1584. return setStylesFromString(el, value);
  1585. }
  1586. function setStylesFromObject(el, value) {
  1587. let previousStyles = {};
  1588. Object.entries(value).forEach(([key, value2]) => {
  1589. previousStyles[key] = el.style[key];
  1590. if (!key.startsWith("--")) {
  1591. key = kebabCase(key);
  1592. }
  1593. el.style.setProperty(key, value2);
  1594. });
  1595. setTimeout(() => {
  1596. if (el.style.length === 0) {
  1597. el.removeAttribute("style");
  1598. }
  1599. });
  1600. return () => {
  1601. setStyles(el, previousStyles);
  1602. };
  1603. }
  1604. function setStylesFromString(el, value) {
  1605. let cache = el.getAttribute("style", value);
  1606. el.setAttribute("style", value);
  1607. return () => {
  1608. el.setAttribute("style", cache || "");
  1609. };
  1610. }
  1611. function kebabCase(subject) {
  1612. return subject.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
  1613. }
  1614. function once(callback, fallback2 = () => {
  1615. }) {
  1616. let called = false;
  1617. return function() {
  1618. if (!called) {
  1619. called = true;
  1620. callback.apply(this, arguments);
  1621. } else {
  1622. fallback2.apply(this, arguments);
  1623. }
  1624. };
  1625. }
  1626. directive("transition", (el, { value, modifiers, expression }, { evaluate: evaluate22 }) => {
  1627. if (typeof expression === "function")
  1628. expression = evaluate22(expression);
  1629. if (expression === false)
  1630. return;
  1631. if (!expression || typeof expression === "boolean") {
  1632. registerTransitionsFromHelper(el, modifiers, value);
  1633. } else {
  1634. registerTransitionsFromClassString(el, expression, value);
  1635. }
  1636. });
  1637. function registerTransitionsFromClassString(el, classString, stage) {
  1638. registerTransitionObject(el, setClasses, "");
  1639. let directiveStorageMap = {
  1640. "enter": (classes) => {
  1641. el._x_transition.enter.during = classes;
  1642. },
  1643. "enter-start": (classes) => {
  1644. el._x_transition.enter.start = classes;
  1645. },
  1646. "enter-end": (classes) => {
  1647. el._x_transition.enter.end = classes;
  1648. },
  1649. "leave": (classes) => {
  1650. el._x_transition.leave.during = classes;
  1651. },
  1652. "leave-start": (classes) => {
  1653. el._x_transition.leave.start = classes;
  1654. },
  1655. "leave-end": (classes) => {
  1656. el._x_transition.leave.end = classes;
  1657. }
  1658. };
  1659. directiveStorageMap[stage](classString);
  1660. }
  1661. function registerTransitionsFromHelper(el, modifiers, stage) {
  1662. registerTransitionObject(el, setStyles);
  1663. let doesntSpecify = !modifiers.includes("in") && !modifiers.includes("out") && !stage;
  1664. let transitioningIn = doesntSpecify || modifiers.includes("in") || ["enter"].includes(stage);
  1665. let transitioningOut = doesntSpecify || modifiers.includes("out") || ["leave"].includes(stage);
  1666. if (modifiers.includes("in") && !doesntSpecify) {
  1667. modifiers = modifiers.filter((i, index) => index < modifiers.indexOf("out"));
  1668. }
  1669. if (modifiers.includes("out") && !doesntSpecify) {
  1670. modifiers = modifiers.filter((i, index) => index > modifiers.indexOf("out"));
  1671. }
  1672. let wantsAll = !modifiers.includes("opacity") && !modifiers.includes("scale");
  1673. let wantsOpacity = wantsAll || modifiers.includes("opacity");
  1674. let wantsScale = wantsAll || modifiers.includes("scale");
  1675. let opacityValue = wantsOpacity ? 0 : 1;
  1676. let scaleValue = wantsScale ? modifierValue(modifiers, "scale", 95) / 100 : 1;
  1677. let delay3 = modifierValue(modifiers, "delay", 0) / 1e3;
  1678. let origin = modifierValue(modifiers, "origin", "center");
  1679. let property = "opacity, transform";
  1680. let durationIn = modifierValue(modifiers, "duration", 150) / 1e3;
  1681. let durationOut = modifierValue(modifiers, "duration", 75) / 1e3;
  1682. let easing = `cubic-bezier(0.4, 0.0, 0.2, 1)`;
  1683. if (transitioningIn) {
  1684. el._x_transition.enter.during = {
  1685. transformOrigin: origin,
  1686. transitionDelay: `${delay3}s`,
  1687. transitionProperty: property,
  1688. transitionDuration: `${durationIn}s`,
  1689. transitionTimingFunction: easing
  1690. };
  1691. el._x_transition.enter.start = {
  1692. opacity: opacityValue,
  1693. transform: `scale(${scaleValue})`
  1694. };
  1695. el._x_transition.enter.end = {
  1696. opacity: 1,
  1697. transform: `scale(1)`
  1698. };
  1699. }
  1700. if (transitioningOut) {
  1701. el._x_transition.leave.during = {
  1702. transformOrigin: origin,
  1703. transitionDelay: `${delay3}s`,
  1704. transitionProperty: property,
  1705. transitionDuration: `${durationOut}s`,
  1706. transitionTimingFunction: easing
  1707. };
  1708. el._x_transition.leave.start = {
  1709. opacity: 1,
  1710. transform: `scale(1)`
  1711. };
  1712. el._x_transition.leave.end = {
  1713. opacity: opacityValue,
  1714. transform: `scale(${scaleValue})`
  1715. };
  1716. }
  1717. }
  1718. function registerTransitionObject(el, setFunction, defaultValue = {}) {
  1719. if (!el._x_transition)
  1720. el._x_transition = {
  1721. enter: { during: defaultValue, start: defaultValue, end: defaultValue },
  1722. leave: { during: defaultValue, start: defaultValue, end: defaultValue },
  1723. in(before = () => {
  1724. }, after = () => {
  1725. }) {
  1726. transition(el, setFunction, {
  1727. during: this.enter.during,
  1728. start: this.enter.start,
  1729. end: this.enter.end
  1730. }, before, after);
  1731. },
  1732. out(before = () => {
  1733. }, after = () => {
  1734. }) {
  1735. transition(el, setFunction, {
  1736. during: this.leave.during,
  1737. start: this.leave.start,
  1738. end: this.leave.end
  1739. }, before, after);
  1740. }
  1741. };
  1742. }
  1743. window.Element.prototype._x_toggleAndCascadeWithTransitions = function(el, value, show, hide) {
  1744. const nextTick2 = document.visibilityState === "visible" ? requestAnimationFrame : setTimeout;
  1745. let clickAwayCompatibleShow = () => nextTick2(show);
  1746. if (value) {
  1747. if (el._x_transition && (el._x_transition.enter || el._x_transition.leave)) {
  1748. el._x_transition.enter && (Object.entries(el._x_transition.enter.during).length || Object.entries(el._x_transition.enter.start).length || Object.entries(el._x_transition.enter.end).length) ? el._x_transition.in(show) : clickAwayCompatibleShow();
  1749. } else {
  1750. el._x_transition ? el._x_transition.in(show) : clickAwayCompatibleShow();
  1751. }
  1752. return;
  1753. }
  1754. el._x_hidePromise = el._x_transition ? new Promise((resolve, reject) => {
  1755. el._x_transition.out(() => {
  1756. }, () => resolve(hide));
  1757. el._x_transitioning && el._x_transitioning.beforeCancel(() => reject({ isFromCancelledTransition: true }));
  1758. }) : Promise.resolve(hide);
  1759. queueMicrotask(() => {
  1760. let closest = closestHide(el);
  1761. if (closest) {
  1762. if (!closest._x_hideChildren)
  1763. closest._x_hideChildren = [];
  1764. closest._x_hideChildren.push(el);
  1765. } else {
  1766. nextTick2(() => {
  1767. let hideAfterChildren = (el2) => {
  1768. let carry = Promise.all([
  1769. el2._x_hidePromise,
  1770. ...(el2._x_hideChildren || []).map(hideAfterChildren)
  1771. ]).then(([i]) => i?.());
  1772. delete el2._x_hidePromise;
  1773. delete el2._x_hideChildren;
  1774. return carry;
  1775. };
  1776. hideAfterChildren(el).catch((e) => {
  1777. if (!e.isFromCancelledTransition)
  1778. throw e;
  1779. });
  1780. });
  1781. }
  1782. });
  1783. };
  1784. function closestHide(el) {
  1785. let parent = el.parentNode;
  1786. if (!parent)
  1787. return;
  1788. return parent._x_hidePromise ? parent : closestHide(parent);
  1789. }
  1790. function transition(el, setFunction, { during, start: start22, end } = {}, before = () => {
  1791. }, after = () => {
  1792. }) {
  1793. if (el._x_transitioning)
  1794. el._x_transitioning.cancel();
  1795. if (Object.keys(during).length === 0 && Object.keys(start22).length === 0 && Object.keys(end).length === 0) {
  1796. before();
  1797. after();
  1798. return;
  1799. }
  1800. let undoStart, undoDuring, undoEnd;
  1801. performTransition(el, {
  1802. start() {
  1803. undoStart = setFunction(el, start22);
  1804. },
  1805. during() {
  1806. undoDuring = setFunction(el, during);
  1807. },
  1808. before,
  1809. end() {
  1810. undoStart();
  1811. undoEnd = setFunction(el, end);
  1812. },
  1813. after,
  1814. cleanup() {
  1815. undoDuring();
  1816. undoEnd();
  1817. }
  1818. });
  1819. }
  1820. function performTransition(el, stages) {
  1821. let interrupted, reachedBefore, reachedEnd;
  1822. let finish = once(() => {
  1823. mutateDom(() => {
  1824. interrupted = true;
  1825. if (!reachedBefore)
  1826. stages.before();
  1827. if (!reachedEnd) {
  1828. stages.end();
  1829. releaseNextTicks();
  1830. }
  1831. stages.after();
  1832. if (el.isConnected)
  1833. stages.cleanup();
  1834. delete el._x_transitioning;
  1835. });
  1836. });
  1837. el._x_transitioning = {
  1838. beforeCancels: [],
  1839. beforeCancel(callback) {
  1840. this.beforeCancels.push(callback);
  1841. },
  1842. cancel: once(function() {
  1843. while (this.beforeCancels.length) {
  1844. this.beforeCancels.shift()();
  1845. }
  1846. ;
  1847. finish();
  1848. }),
  1849. finish
  1850. };
  1851. mutateDom(() => {
  1852. stages.start();
  1853. stages.during();
  1854. });
  1855. holdNextTicks();
  1856. requestAnimationFrame(() => {
  1857. if (interrupted)
  1858. return;
  1859. let duration = Number(getComputedStyle(el).transitionDuration.replace(/,.*/, "").replace("s", "")) * 1e3;
  1860. let delay3 = Number(getComputedStyle(el).transitionDelay.replace(/,.*/, "").replace("s", "")) * 1e3;
  1861. if (duration === 0)
  1862. duration = Number(getComputedStyle(el).animationDuration.replace("s", "")) * 1e3;
  1863. mutateDom(() => {
  1864. stages.before();
  1865. });
  1866. reachedBefore = true;
  1867. requestAnimationFrame(() => {
  1868. if (interrupted)
  1869. return;
  1870. mutateDom(() => {
  1871. stages.end();
  1872. });
  1873. releaseNextTicks();
  1874. setTimeout(el._x_transitioning.finish, duration + delay3);
  1875. reachedEnd = true;
  1876. });
  1877. });
  1878. }
  1879. function modifierValue(modifiers, key, fallback2) {
  1880. if (modifiers.indexOf(key) === -1)
  1881. return fallback2;
  1882. const rawValue = modifiers[modifiers.indexOf(key) + 1];
  1883. if (!rawValue)
  1884. return fallback2;
  1885. if (key === "scale") {
  1886. if (isNaN(rawValue))
  1887. return fallback2;
  1888. }
  1889. if (key === "duration" || key === "delay") {
  1890. let match = rawValue.match(/([0-9]+)ms/);
  1891. if (match)
  1892. return match[1];
  1893. }
  1894. if (key === "origin") {
  1895. if (["top", "right", "left", "center", "bottom"].includes(modifiers[modifiers.indexOf(key) + 2])) {
  1896. return [rawValue, modifiers[modifiers.indexOf(key) + 2]].join(" ");
  1897. }
  1898. }
  1899. return rawValue;
  1900. }
  1901. var isCloning = false;
  1902. function skipDuringClone(callback, fallback2 = () => {
  1903. }) {
  1904. return (...args) => isCloning ? fallback2(...args) : callback(...args);
  1905. }
  1906. function onlyDuringClone(callback) {
  1907. return (...args) => isCloning && callback(...args);
  1908. }
  1909. var interceptors = [];
  1910. function interceptClone(callback) {
  1911. interceptors.push(callback);
  1912. }
  1913. function cloneNode(from, to) {
  1914. interceptors.forEach((i) => i(from, to));
  1915. isCloning = true;
  1916. dontRegisterReactiveSideEffects(() => {
  1917. initTree(to, (el, callback) => {
  1918. callback(el, () => {
  1919. });
  1920. });
  1921. });
  1922. isCloning = false;
  1923. }
  1924. var isCloningLegacy = false;
  1925. function clone(oldEl, newEl) {
  1926. if (!newEl._x_dataStack)
  1927. newEl._x_dataStack = oldEl._x_dataStack;
  1928. isCloning = true;
  1929. isCloningLegacy = true;
  1930. dontRegisterReactiveSideEffects(() => {
  1931. cloneTree(newEl);
  1932. });
  1933. isCloning = false;
  1934. isCloningLegacy = false;
  1935. }
  1936. function cloneTree(el) {
  1937. let hasRunThroughFirstEl = false;
  1938. let shallowWalker = (el2, callback) => {
  1939. walk(el2, (el3, skip) => {
  1940. if (hasRunThroughFirstEl && isRoot(el3))
  1941. return skip();
  1942. hasRunThroughFirstEl = true;
  1943. callback(el3, skip);
  1944. });
  1945. };
  1946. initTree(el, shallowWalker);
  1947. }
  1948. function dontRegisterReactiveSideEffects(callback) {
  1949. let cache = effect;
  1950. overrideEffect((callback2, el) => {
  1951. let storedEffect = cache(callback2);
  1952. release(storedEffect);
  1953. return () => {
  1954. };
  1955. });
  1956. callback();
  1957. overrideEffect(cache);
  1958. }
  1959. function bind(el, name, value, modifiers = []) {
  1960. if (!el._x_bindings)
  1961. el._x_bindings = reactive({});
  1962. el._x_bindings[name] = value;
  1963. name = modifiers.includes("camel") ? camelCase(name) : name;
  1964. switch (name) {
  1965. case "value":
  1966. bindInputValue(el, value);
  1967. break;
  1968. case "style":
  1969. bindStyles(el, value);
  1970. break;
  1971. case "class":
  1972. bindClasses(el, value);
  1973. break;
  1974. case "selected":
  1975. case "checked":
  1976. bindAttributeAndProperty(el, name, value);
  1977. break;
  1978. default:
  1979. bindAttribute(el, name, value);
  1980. break;
  1981. }
  1982. }
  1983. function bindInputValue(el, value) {
  1984. if (isRadio(el)) {
  1985. if (el.attributes.value === void 0) {
  1986. el.value = value;
  1987. }
  1988. if (window.fromModel) {
  1989. if (typeof value === "boolean") {
  1990. el.checked = safeParseBoolean(el.value) === value;
  1991. } else {
  1992. el.checked = checkedAttrLooseCompare(el.value, value);
  1993. }
  1994. }
  1995. } else if (isCheckbox(el)) {
  1996. if (Number.isInteger(value)) {
  1997. el.value = value;
  1998. } else if (!Array.isArray(value) && typeof value !== "boolean" && ![null, void 0].includes(value)) {
  1999. el.value = String(value);
  2000. } else {
  2001. if (Array.isArray(value)) {
  2002. el.checked = value.some((val) => checkedAttrLooseCompare(val, el.value));
  2003. } else {
  2004. el.checked = !!value;
  2005. }
  2006. }
  2007. } else if (el.tagName === "SELECT") {
  2008. updateSelect(el, value);
  2009. } else {
  2010. if (el.value === value)
  2011. return;
  2012. el.value = value === void 0 ? "" : value;
  2013. }
  2014. }
  2015. function bindClasses(el, value) {
  2016. if (el._x_undoAddedClasses)
  2017. el._x_undoAddedClasses();
  2018. el._x_undoAddedClasses = setClasses(el, value);
  2019. }
  2020. function bindStyles(el, value) {
  2021. if (el._x_undoAddedStyles)
  2022. el._x_undoAddedStyles();
  2023. el._x_undoAddedStyles = setStyles(el, value);
  2024. }
  2025. function bindAttributeAndProperty(el, name, value) {
  2026. bindAttribute(el, name, value);
  2027. setPropertyIfChanged(el, name, value);
  2028. }
  2029. function bindAttribute(el, name, value) {
  2030. if ([null, void 0, false].includes(value) && attributeShouldntBePreservedIfFalsy(name)) {
  2031. el.removeAttribute(name);
  2032. } else {
  2033. if (isBooleanAttr(name))
  2034. value = name;
  2035. setIfChanged(el, name, value);
  2036. }
  2037. }
  2038. function setIfChanged(el, attrName, value) {
  2039. if (el.getAttribute(attrName) != value) {
  2040. el.setAttribute(attrName, value);
  2041. }
  2042. }
  2043. function setPropertyIfChanged(el, propName, value) {
  2044. if (el[propName] !== value) {
  2045. el[propName] = value;
  2046. }
  2047. }
  2048. function updateSelect(el, value) {
  2049. const arrayWrappedValue = [].concat(value).map((value2) => {
  2050. return value2 + "";
  2051. });
  2052. Array.from(el.options).forEach((option) => {
  2053. option.selected = arrayWrappedValue.includes(option.value);
  2054. });
  2055. }
  2056. function camelCase(subject) {
  2057. return subject.toLowerCase().replace(/-(\w)/g, (match, char) => char.toUpperCase());
  2058. }
  2059. function checkedAttrLooseCompare(valueA, valueB) {
  2060. return valueA == valueB;
  2061. }
  2062. function safeParseBoolean(rawValue) {
  2063. if ([1, "1", "true", "on", "yes", true].includes(rawValue)) {
  2064. return true;
  2065. }
  2066. if ([0, "0", "false", "off", "no", false].includes(rawValue)) {
  2067. return false;
  2068. }
  2069. return rawValue ? Boolean(rawValue) : null;
  2070. }
  2071. var booleanAttributes = /* @__PURE__ */ new Set([
  2072. "allowfullscreen",
  2073. "async",
  2074. "autofocus",
  2075. "autoplay",
  2076. "checked",
  2077. "controls",
  2078. "default",
  2079. "defer",
  2080. "disabled",
  2081. "formnovalidate",
  2082. "inert",
  2083. "ismap",
  2084. "itemscope",
  2085. "loop",
  2086. "multiple",
  2087. "muted",
  2088. "nomodule",
  2089. "novalidate",
  2090. "open",
  2091. "playsinline",
  2092. "readonly",
  2093. "required",
  2094. "reversed",
  2095. "selected",
  2096. "shadowrootclonable",
  2097. "shadowrootdelegatesfocus",
  2098. "shadowrootserializable"
  2099. ]);
  2100. function isBooleanAttr(attrName) {
  2101. return booleanAttributes.has(attrName);
  2102. }
  2103. function attributeShouldntBePreservedIfFalsy(name) {
  2104. return !["aria-pressed", "aria-checked", "aria-expanded", "aria-selected"].includes(name);
  2105. }
  2106. function getBinding(el, name, fallback2) {
  2107. if (el._x_bindings && el._x_bindings[name] !== void 0)
  2108. return el._x_bindings[name];
  2109. return getAttributeBinding(el, name, fallback2);
  2110. }
  2111. function extractProp(el, name, fallback2, extract = true) {
  2112. if (el._x_bindings && el._x_bindings[name] !== void 0)
  2113. return el._x_bindings[name];
  2114. if (el._x_inlineBindings && el._x_inlineBindings[name] !== void 0) {
  2115. let binding = el._x_inlineBindings[name];
  2116. binding.extract = extract;
  2117. return dontAutoEvaluateFunctions(() => {
  2118. return evaluate(el, binding.expression);
  2119. });
  2120. }
  2121. return getAttributeBinding(el, name, fallback2);
  2122. }
  2123. function getAttributeBinding(el, name, fallback2) {
  2124. let attr = el.getAttribute(name);
  2125. if (attr === null)
  2126. return typeof fallback2 === "function" ? fallback2() : fallback2;
  2127. if (attr === "")
  2128. return true;
  2129. if (isBooleanAttr(name)) {
  2130. return !![name, "true"].includes(attr);
  2131. }
  2132. return attr;
  2133. }
  2134. function isCheckbox(el) {
  2135. return el.type === "checkbox" || el.localName === "ui-checkbox" || el.localName === "ui-switch";
  2136. }
  2137. function isRadio(el) {
  2138. return el.type === "radio" || el.localName === "ui-radio";
  2139. }
  2140. function debounce(func, wait) {
  2141. var timeout;
  2142. return function() {
  2143. var context = this, args = arguments;
  2144. var later = function() {
  2145. timeout = null;
  2146. func.apply(context, args);
  2147. };
  2148. clearTimeout(timeout);
  2149. timeout = setTimeout(later, wait);
  2150. };
  2151. }
  2152. function throttle(func, limit) {
  2153. let inThrottle;
  2154. return function() {
  2155. let context = this, args = arguments;
  2156. if (!inThrottle) {
  2157. func.apply(context, args);
  2158. inThrottle = true;
  2159. setTimeout(() => inThrottle = false, limit);
  2160. }
  2161. };
  2162. }
  2163. function entangle({ get: outerGet, set: outerSet }, { get: innerGet, set: innerSet }) {
  2164. let firstRun = true;
  2165. let outerHash;
  2166. let innerHash;
  2167. let reference = effect(() => {
  2168. let outer = outerGet();
  2169. let inner = innerGet();
  2170. if (firstRun) {
  2171. innerSet(cloneIfObject(outer));
  2172. firstRun = false;
  2173. } else {
  2174. let outerHashLatest = JSON.stringify(outer);
  2175. let innerHashLatest = JSON.stringify(inner);
  2176. if (outerHashLatest !== outerHash) {
  2177. innerSet(cloneIfObject(outer));
  2178. } else if (outerHashLatest !== innerHashLatest) {
  2179. outerSet(cloneIfObject(inner));
  2180. } else {
  2181. }
  2182. }
  2183. outerHash = JSON.stringify(outerGet());
  2184. innerHash = JSON.stringify(innerGet());
  2185. });
  2186. return () => {
  2187. release(reference);
  2188. };
  2189. }
  2190. function cloneIfObject(value) {
  2191. return typeof value === "object" ? JSON.parse(JSON.stringify(value)) : value;
  2192. }
  2193. function plugin(callback) {
  2194. let callbacks = Array.isArray(callback) ? callback : [callback];
  2195. callbacks.forEach((i) => i(alpine_default));
  2196. }
  2197. var stores = {};
  2198. var isReactive = false;
  2199. function store(name, value) {
  2200. if (!isReactive) {
  2201. stores = reactive(stores);
  2202. isReactive = true;
  2203. }
  2204. if (value === void 0) {
  2205. return stores[name];
  2206. }
  2207. stores[name] = value;
  2208. initInterceptors(stores[name]);
  2209. if (typeof value === "object" && value !== null && value.hasOwnProperty("init") && typeof value.init === "function") {
  2210. stores[name].init();
  2211. }
  2212. }
  2213. function getStores() {
  2214. return stores;
  2215. }
  2216. var binds = {};
  2217. function bind2(name, bindings) {
  2218. let getBindings = typeof bindings !== "function" ? () => bindings : bindings;
  2219. if (name instanceof Element) {
  2220. return applyBindingsObject(name, getBindings());
  2221. } else {
  2222. binds[name] = getBindings;
  2223. }
  2224. return () => {
  2225. };
  2226. }
  2227. function injectBindingProviders(obj) {
  2228. Object.entries(binds).forEach(([name, callback]) => {
  2229. Object.defineProperty(obj, name, {
  2230. get() {
  2231. return (...args) => {
  2232. return callback(...args);
  2233. };
  2234. }
  2235. });
  2236. });
  2237. return obj;
  2238. }
  2239. function applyBindingsObject(el, obj, original) {
  2240. let cleanupRunners = [];
  2241. while (cleanupRunners.length)
  2242. cleanupRunners.pop()();
  2243. let attributes = Object.entries(obj).map(([name, value]) => ({ name, value }));
  2244. let staticAttributes = attributesOnly(attributes);
  2245. attributes = attributes.map((attribute) => {
  2246. if (staticAttributes.find((attr) => attr.name === attribute.name)) {
  2247. return {
  2248. name: `x-bind:${attribute.name}`,
  2249. value: `"${attribute.value}"`
  2250. };
  2251. }
  2252. return attribute;
  2253. });
  2254. directives(el, attributes, original).map((handle) => {
  2255. cleanupRunners.push(handle.runCleanups);
  2256. handle();
  2257. });
  2258. return () => {
  2259. while (cleanupRunners.length)
  2260. cleanupRunners.pop()();
  2261. };
  2262. }
  2263. var datas = {};
  2264. function data(name, callback) {
  2265. datas[name] = callback;
  2266. }
  2267. function injectDataProviders(obj, context) {
  2268. Object.entries(datas).forEach(([name, callback]) => {
  2269. Object.defineProperty(obj, name, {
  2270. get() {
  2271. return (...args) => {
  2272. return callback.bind(context)(...args);
  2273. };
  2274. },
  2275. enumerable: false
  2276. });
  2277. });
  2278. return obj;
  2279. }
  2280. var Alpine2 = {
  2281. get reactive() {
  2282. return reactive;
  2283. },
  2284. get release() {
  2285. return release;
  2286. },
  2287. get effect() {
  2288. return effect;
  2289. },
  2290. get raw() {
  2291. return raw;
  2292. },
  2293. version: "3.14.9",
  2294. flushAndStopDeferringMutations,
  2295. dontAutoEvaluateFunctions,
  2296. disableEffectScheduling,
  2297. startObservingMutations,
  2298. stopObservingMutations,
  2299. setReactivityEngine,
  2300. onAttributeRemoved,
  2301. onAttributesAdded,
  2302. closestDataStack,
  2303. skipDuringClone,
  2304. onlyDuringClone,
  2305. addRootSelector,
  2306. addInitSelector,
  2307. interceptClone,
  2308. addScopeToNode,
  2309. deferMutations,
  2310. mapAttributes,
  2311. evaluateLater,
  2312. interceptInit,
  2313. setEvaluator,
  2314. mergeProxies,
  2315. extractProp,
  2316. findClosest,
  2317. onElRemoved,
  2318. closestRoot,
  2319. destroyTree,
  2320. interceptor,
  2321. transition,
  2322. setStyles,
  2323. mutateDom,
  2324. directive,
  2325. entangle,
  2326. throttle,
  2327. debounce,
  2328. evaluate,
  2329. initTree,
  2330. nextTick,
  2331. prefixed: prefix,
  2332. prefix: setPrefix,
  2333. plugin,
  2334. magic,
  2335. store,
  2336. start,
  2337. clone,
  2338. cloneNode,
  2339. bound: getBinding,
  2340. $data: scope,
  2341. watch,
  2342. walk,
  2343. data,
  2344. bind: bind2
  2345. };
  2346. var alpine_default = Alpine2;
  2347. function makeMap(str, expectsLowerCase) {
  2348. const map = /* @__PURE__ */ Object.create(null);
  2349. const list = str.split(",");
  2350. for (let i = 0; i < list.length; i++) {
  2351. map[list[i]] = true;
  2352. }
  2353. return expectsLowerCase ? (val) => !!map[val.toLowerCase()] : (val) => !!map[val];
  2354. }
  2355. var specialBooleanAttrs = `itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly`;
  2356. var isBooleanAttr2 = /* @__PURE__ */ makeMap(specialBooleanAttrs + `,async,autofocus,autoplay,controls,default,defer,disabled,hidden,loop,open,required,reversed,scoped,seamless,checked,muted,multiple,selected`);
  2357. var EMPTY_OBJ = true ? Object.freeze({}) : {};
  2358. var EMPTY_ARR = true ? Object.freeze([]) : [];
  2359. var hasOwnProperty = Object.prototype.hasOwnProperty;
  2360. var hasOwn = (val, key) => hasOwnProperty.call(val, key);
  2361. var isArray2 = Array.isArray;
  2362. var isMap = (val) => toTypeString(val) === "[object Map]";
  2363. var isString = (val) => typeof val === "string";
  2364. var isSymbol = (val) => typeof val === "symbol";
  2365. var isObject2 = (val) => val !== null && typeof val === "object";
  2366. var objectToString = Object.prototype.toString;
  2367. var toTypeString = (value) => objectToString.call(value);
  2368. var toRawType = (value) => {
  2369. return toTypeString(value).slice(8, -1);
  2370. };
  2371. var isIntegerKey = (key) => isString(key) && key !== "NaN" && key[0] !== "-" && "" + parseInt(key, 10) === key;
  2372. var cacheStringFunction = (fn) => {
  2373. const cache = /* @__PURE__ */ Object.create(null);
  2374. return (str) => {
  2375. const hit = cache[str];
  2376. return hit || (cache[str] = fn(str));
  2377. };
  2378. };
  2379. var camelizeRE = /-(\w)/g;
  2380. var camelize = cacheStringFunction((str) => {
  2381. return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : "");
  2382. });
  2383. var hyphenateRE = /\B([A-Z])/g;
  2384. var hyphenate = cacheStringFunction((str) => str.replace(hyphenateRE, "-$1").toLowerCase());
  2385. var capitalize = cacheStringFunction((str) => str.charAt(0).toUpperCase() + str.slice(1));
  2386. var toHandlerKey = cacheStringFunction((str) => str ? `on${capitalize(str)}` : ``);
  2387. var hasChanged = (value, oldValue) => value !== oldValue && (value === value || oldValue === oldValue);
  2388. var targetMap = /* @__PURE__ */ new WeakMap();
  2389. var effectStack = [];
  2390. var activeEffect;
  2391. var ITERATE_KEY = Symbol(true ? "iterate" : "");
  2392. var MAP_KEY_ITERATE_KEY = Symbol(true ? "Map key iterate" : "");
  2393. function isEffect(fn) {
  2394. return fn && fn._isEffect === true;
  2395. }
  2396. function effect2(fn, options = EMPTY_OBJ) {
  2397. if (isEffect(fn)) {
  2398. fn = fn.raw;
  2399. }
  2400. const effect3 = createReactiveEffect(fn, options);
  2401. if (!options.lazy) {
  2402. effect3();
  2403. }
  2404. return effect3;
  2405. }
  2406. function stop(effect3) {
  2407. if (effect3.active) {
  2408. cleanup(effect3);
  2409. if (effect3.options.onStop) {
  2410. effect3.options.onStop();
  2411. }
  2412. effect3.active = false;
  2413. }
  2414. }
  2415. var uid = 0;
  2416. function createReactiveEffect(fn, options) {
  2417. const effect3 = function reactiveEffect() {
  2418. if (!effect3.active) {
  2419. return fn();
  2420. }
  2421. if (!effectStack.includes(effect3)) {
  2422. cleanup(effect3);
  2423. try {
  2424. enableTracking();
  2425. effectStack.push(effect3);
  2426. activeEffect = effect3;
  2427. return fn();
  2428. } finally {
  2429. effectStack.pop();
  2430. resetTracking();
  2431. activeEffect = effectStack[effectStack.length - 1];
  2432. }
  2433. }
  2434. };
  2435. effect3.id = uid++;
  2436. effect3.allowRecurse = !!options.allowRecurse;
  2437. effect3._isEffect = true;
  2438. effect3.active = true;
  2439. effect3.raw = fn;
  2440. effect3.deps = [];
  2441. effect3.options = options;
  2442. return effect3;
  2443. }
  2444. function cleanup(effect3) {
  2445. const { deps } = effect3;
  2446. if (deps.length) {
  2447. for (let i = 0; i < deps.length; i++) {
  2448. deps[i].delete(effect3);
  2449. }
  2450. deps.length = 0;
  2451. }
  2452. }
  2453. var shouldTrack = true;
  2454. var trackStack = [];
  2455. function pauseTracking() {
  2456. trackStack.push(shouldTrack);
  2457. shouldTrack = false;
  2458. }
  2459. function enableTracking() {
  2460. trackStack.push(shouldTrack);
  2461. shouldTrack = true;
  2462. }
  2463. function resetTracking() {
  2464. const last = trackStack.pop();
  2465. shouldTrack = last === void 0 ? true : last;
  2466. }
  2467. function track(target, type, key) {
  2468. if (!shouldTrack || activeEffect === void 0) {
  2469. return;
  2470. }
  2471. let depsMap = targetMap.get(target);
  2472. if (!depsMap) {
  2473. targetMap.set(target, depsMap = /* @__PURE__ */ new Map());
  2474. }
  2475. let dep = depsMap.get(key);
  2476. if (!dep) {
  2477. depsMap.set(key, dep = /* @__PURE__ */ new Set());
  2478. }
  2479. if (!dep.has(activeEffect)) {
  2480. dep.add(activeEffect);
  2481. activeEffect.deps.push(dep);
  2482. if (activeEffect.options.onTrack) {
  2483. activeEffect.options.onTrack({
  2484. effect: activeEffect,
  2485. target,
  2486. type,
  2487. key
  2488. });
  2489. }
  2490. }
  2491. }
  2492. function trigger(target, type, key, newValue, oldValue, oldTarget) {
  2493. const depsMap = targetMap.get(target);
  2494. if (!depsMap) {
  2495. return;
  2496. }
  2497. const effects = /* @__PURE__ */ new Set();
  2498. const add2 = (effectsToAdd) => {
  2499. if (effectsToAdd) {
  2500. effectsToAdd.forEach((effect3) => {
  2501. if (effect3 !== activeEffect || effect3.allowRecurse) {
  2502. effects.add(effect3);
  2503. }
  2504. });
  2505. }
  2506. };
  2507. if (type === "clear") {
  2508. depsMap.forEach(add2);
  2509. } else if (key === "length" && isArray2(target)) {
  2510. depsMap.forEach((dep, key2) => {
  2511. if (key2 === "length" || key2 >= newValue) {
  2512. add2(dep);
  2513. }
  2514. });
  2515. } else {
  2516. if (key !== void 0) {
  2517. add2(depsMap.get(key));
  2518. }
  2519. switch (type) {
  2520. case "add":
  2521. if (!isArray2(target)) {
  2522. add2(depsMap.get(ITERATE_KEY));
  2523. if (isMap(target)) {
  2524. add2(depsMap.get(MAP_KEY_ITERATE_KEY));
  2525. }
  2526. } else if (isIntegerKey(key)) {
  2527. add2(depsMap.get("length"));
  2528. }
  2529. break;
  2530. case "delete":
  2531. if (!isArray2(target)) {
  2532. add2(depsMap.get(ITERATE_KEY));
  2533. if (isMap(target)) {
  2534. add2(depsMap.get(MAP_KEY_ITERATE_KEY));
  2535. }
  2536. }
  2537. break;
  2538. case "set":
  2539. if (isMap(target)) {
  2540. add2(depsMap.get(ITERATE_KEY));
  2541. }
  2542. break;
  2543. }
  2544. }
  2545. const run = (effect3) => {
  2546. if (effect3.options.onTrigger) {
  2547. effect3.options.onTrigger({
  2548. effect: effect3,
  2549. target,
  2550. key,
  2551. type,
  2552. newValue,
  2553. oldValue,
  2554. oldTarget
  2555. });
  2556. }
  2557. if (effect3.options.scheduler) {
  2558. effect3.options.scheduler(effect3);
  2559. } else {
  2560. effect3();
  2561. }
  2562. };
  2563. effects.forEach(run);
  2564. }
  2565. var isNonTrackableKeys = /* @__PURE__ */ makeMap(`__proto__,__v_isRef,__isVue`);
  2566. var builtInSymbols = new Set(Object.getOwnPropertyNames(Symbol).map((key) => Symbol[key]).filter(isSymbol));
  2567. var get2 = /* @__PURE__ */ createGetter();
  2568. var readonlyGet = /* @__PURE__ */ createGetter(true);
  2569. var arrayInstrumentations = /* @__PURE__ */ createArrayInstrumentations();
  2570. function createArrayInstrumentations() {
  2571. const instrumentations = {};
  2572. ["includes", "indexOf", "lastIndexOf"].forEach((key) => {
  2573. instrumentations[key] = function(...args) {
  2574. const arr = toRaw(this);
  2575. for (let i = 0, l = this.length; i < l; i++) {
  2576. track(arr, "get", i + "");
  2577. }
  2578. const res = arr[key](...args);
  2579. if (res === -1 || res === false) {
  2580. return arr[key](...args.map(toRaw));
  2581. } else {
  2582. return res;
  2583. }
  2584. };
  2585. });
  2586. ["push", "pop", "shift", "unshift", "splice"].forEach((key) => {
  2587. instrumentations[key] = function(...args) {
  2588. pauseTracking();
  2589. const res = toRaw(this)[key].apply(this, args);
  2590. resetTracking();
  2591. return res;
  2592. };
  2593. });
  2594. return instrumentations;
  2595. }
  2596. function createGetter(isReadonly = false, shallow = false) {
  2597. return function get3(target, key, receiver) {
  2598. if (key === "__v_isReactive") {
  2599. return !isReadonly;
  2600. } else if (key === "__v_isReadonly") {
  2601. return isReadonly;
  2602. } else if (key === "__v_raw" && receiver === (isReadonly ? shallow ? shallowReadonlyMap : readonlyMap : shallow ? shallowReactiveMap : reactiveMap).get(target)) {
  2603. return target;
  2604. }
  2605. const targetIsArray = isArray2(target);
  2606. if (!isReadonly && targetIsArray && hasOwn(arrayInstrumentations, key)) {
  2607. return Reflect.get(arrayInstrumentations, key, receiver);
  2608. }
  2609. const res = Reflect.get(target, key, receiver);
  2610. if (isSymbol(key) ? builtInSymbols.has(key) : isNonTrackableKeys(key)) {
  2611. return res;
  2612. }
  2613. if (!isReadonly) {
  2614. track(target, "get", key);
  2615. }
  2616. if (shallow) {
  2617. return res;
  2618. }
  2619. if (isRef(res)) {
  2620. const shouldUnwrap = !targetIsArray || !isIntegerKey(key);
  2621. return shouldUnwrap ? res.value : res;
  2622. }
  2623. if (isObject2(res)) {
  2624. return isReadonly ? readonly(res) : reactive2(res);
  2625. }
  2626. return res;
  2627. };
  2628. }
  2629. var set2 = /* @__PURE__ */ createSetter();
  2630. function createSetter(shallow = false) {
  2631. return function set3(target, key, value, receiver) {
  2632. let oldValue = target[key];
  2633. if (!shallow) {
  2634. value = toRaw(value);
  2635. oldValue = toRaw(oldValue);
  2636. if (!isArray2(target) && isRef(oldValue) && !isRef(value)) {
  2637. oldValue.value = value;
  2638. return true;
  2639. }
  2640. }
  2641. const hadKey = isArray2(target) && isIntegerKey(key) ? Number(key) < target.length : hasOwn(target, key);
  2642. const result = Reflect.set(target, key, value, receiver);
  2643. if (target === toRaw(receiver)) {
  2644. if (!hadKey) {
  2645. trigger(target, "add", key, value);
  2646. } else if (hasChanged(value, oldValue)) {
  2647. trigger(target, "set", key, value, oldValue);
  2648. }
  2649. }
  2650. return result;
  2651. };
  2652. }
  2653. function deleteProperty(target, key) {
  2654. const hadKey = hasOwn(target, key);
  2655. const oldValue = target[key];
  2656. const result = Reflect.deleteProperty(target, key);
  2657. if (result && hadKey) {
  2658. trigger(target, "delete", key, void 0, oldValue);
  2659. }
  2660. return result;
  2661. }
  2662. function has(target, key) {
  2663. const result = Reflect.has(target, key);
  2664. if (!isSymbol(key) || !builtInSymbols.has(key)) {
  2665. track(target, "has", key);
  2666. }
  2667. return result;
  2668. }
  2669. function ownKeys(target) {
  2670. track(target, "iterate", isArray2(target) ? "length" : ITERATE_KEY);
  2671. return Reflect.ownKeys(target);
  2672. }
  2673. var mutableHandlers = {
  2674. get: get2,
  2675. set: set2,
  2676. deleteProperty,
  2677. has,
  2678. ownKeys
  2679. };
  2680. var readonlyHandlers = {
  2681. get: readonlyGet,
  2682. set(target, key) {
  2683. if (true) {
  2684. console.warn(`Set operation on key "${String(key)}" failed: target is readonly.`, target);
  2685. }
  2686. return true;
  2687. },
  2688. deleteProperty(target, key) {
  2689. if (true) {
  2690. console.warn(`Delete operation on key "${String(key)}" failed: target is readonly.`, target);
  2691. }
  2692. return true;
  2693. }
  2694. };
  2695. var toReactive = (value) => isObject2(value) ? reactive2(value) : value;
  2696. var toReadonly = (value) => isObject2(value) ? readonly(value) : value;
  2697. var toShallow = (value) => value;
  2698. var getProto = (v) => Reflect.getPrototypeOf(v);
  2699. function get$1(target, key, isReadonly = false, isShallow = false) {
  2700. target = target["__v_raw"];
  2701. const rawTarget = toRaw(target);
  2702. const rawKey = toRaw(key);
  2703. if (key !== rawKey) {
  2704. !isReadonly && track(rawTarget, "get", key);
  2705. }
  2706. !isReadonly && track(rawTarget, "get", rawKey);
  2707. const { has: has2 } = getProto(rawTarget);
  2708. const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive;
  2709. if (has2.call(rawTarget, key)) {
  2710. return wrap(target.get(key));
  2711. } else if (has2.call(rawTarget, rawKey)) {
  2712. return wrap(target.get(rawKey));
  2713. } else if (target !== rawTarget) {
  2714. target.get(key);
  2715. }
  2716. }
  2717. function has$1(key, isReadonly = false) {
  2718. const target = this["__v_raw"];
  2719. const rawTarget = toRaw(target);
  2720. const rawKey = toRaw(key);
  2721. if (key !== rawKey) {
  2722. !isReadonly && track(rawTarget, "has", key);
  2723. }
  2724. !isReadonly && track(rawTarget, "has", rawKey);
  2725. return key === rawKey ? target.has(key) : target.has(key) || target.has(rawKey);
  2726. }
  2727. function size(target, isReadonly = false) {
  2728. target = target["__v_raw"];
  2729. !isReadonly && track(toRaw(target), "iterate", ITERATE_KEY);
  2730. return Reflect.get(target, "size", target);
  2731. }
  2732. function add(value) {
  2733. value = toRaw(value);
  2734. const target = toRaw(this);
  2735. const proto = getProto(target);
  2736. const hadKey = proto.has.call(target, value);
  2737. if (!hadKey) {
  2738. target.add(value);
  2739. trigger(target, "add", value, value);
  2740. }
  2741. return this;
  2742. }
  2743. function set$1(key, value) {
  2744. value = toRaw(value);
  2745. const target = toRaw(this);
  2746. const { has: has2, get: get3 } = getProto(target);
  2747. let hadKey = has2.call(target, key);
  2748. if (!hadKey) {
  2749. key = toRaw(key);
  2750. hadKey = has2.call(target, key);
  2751. } else if (true) {
  2752. checkIdentityKeys(target, has2, key);
  2753. }
  2754. const oldValue = get3.call(target, key);
  2755. target.set(key, value);
  2756. if (!hadKey) {
  2757. trigger(target, "add", key, value);
  2758. } else if (hasChanged(value, oldValue)) {
  2759. trigger(target, "set", key, value, oldValue);
  2760. }
  2761. return this;
  2762. }
  2763. function deleteEntry(key) {
  2764. const target = toRaw(this);
  2765. const { has: has2, get: get3 } = getProto(target);
  2766. let hadKey = has2.call(target, key);
  2767. if (!hadKey) {
  2768. key = toRaw(key);
  2769. hadKey = has2.call(target, key);
  2770. } else if (true) {
  2771. checkIdentityKeys(target, has2, key);
  2772. }
  2773. const oldValue = get3 ? get3.call(target, key) : void 0;
  2774. const result = target.delete(key);
  2775. if (hadKey) {
  2776. trigger(target, "delete", key, void 0, oldValue);
  2777. }
  2778. return result;
  2779. }
  2780. function clear() {
  2781. const target = toRaw(this);
  2782. const hadItems = target.size !== 0;
  2783. const oldTarget = true ? isMap(target) ? new Map(target) : new Set(target) : void 0;
  2784. const result = target.clear();
  2785. if (hadItems) {
  2786. trigger(target, "clear", void 0, void 0, oldTarget);
  2787. }
  2788. return result;
  2789. }
  2790. function createForEach(isReadonly, isShallow) {
  2791. return function forEach(callback, thisArg) {
  2792. const observed = this;
  2793. const target = observed["__v_raw"];
  2794. const rawTarget = toRaw(target);
  2795. const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive;
  2796. !isReadonly && track(rawTarget, "iterate", ITERATE_KEY);
  2797. return target.forEach((value, key) => {
  2798. return callback.call(thisArg, wrap(value), wrap(key), observed);
  2799. });
  2800. };
  2801. }
  2802. function createIterableMethod(method, isReadonly, isShallow) {
  2803. return function(...args) {
  2804. const target = this["__v_raw"];
  2805. const rawTarget = toRaw(target);
  2806. const targetIsMap = isMap(rawTarget);
  2807. const isPair = method === "entries" || method === Symbol.iterator && targetIsMap;
  2808. const isKeyOnly = method === "keys" && targetIsMap;
  2809. const innerIterator = target[method](...args);
  2810. const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive;
  2811. !isReadonly && track(rawTarget, "iterate", isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY);
  2812. return {
  2813. next() {
  2814. const { value, done } = innerIterator.next();
  2815. return done ? { value, done } : {
  2816. value: isPair ? [wrap(value[0]), wrap(value[1])] : wrap(value),
  2817. done
  2818. };
  2819. },
  2820. [Symbol.iterator]() {
  2821. return this;
  2822. }
  2823. };
  2824. };
  2825. }
  2826. function createReadonlyMethod(type) {
  2827. return function(...args) {
  2828. if (true) {
  2829. const key = args[0] ? `on key "${args[0]}" ` : ``;
  2830. console.warn(`${capitalize(type)} operation ${key}failed: target is readonly.`, toRaw(this));
  2831. }
  2832. return type === "delete" ? false : this;
  2833. };
  2834. }
  2835. function createInstrumentations() {
  2836. const mutableInstrumentations2 = {
  2837. get(key) {
  2838. return get$1(this, key);
  2839. },
  2840. get size() {
  2841. return size(this);
  2842. },
  2843. has: has$1,
  2844. add,
  2845. set: set$1,
  2846. delete: deleteEntry,
  2847. clear,
  2848. forEach: createForEach(false, false)
  2849. };
  2850. const shallowInstrumentations2 = {
  2851. get(key) {
  2852. return get$1(this, key, false, true);
  2853. },
  2854. get size() {
  2855. return size(this);
  2856. },
  2857. has: has$1,
  2858. add,
  2859. set: set$1,
  2860. delete: deleteEntry,
  2861. clear,
  2862. forEach: createForEach(false, true)
  2863. };
  2864. const readonlyInstrumentations2 = {
  2865. get(key) {
  2866. return get$1(this, key, true);
  2867. },
  2868. get size() {
  2869. return size(this, true);
  2870. },
  2871. has(key) {
  2872. return has$1.call(this, key, true);
  2873. },
  2874. add: createReadonlyMethod("add"),
  2875. set: createReadonlyMethod("set"),
  2876. delete: createReadonlyMethod("delete"),
  2877. clear: createReadonlyMethod("clear"),
  2878. forEach: createForEach(true, false)
  2879. };
  2880. const shallowReadonlyInstrumentations2 = {
  2881. get(key) {
  2882. return get$1(this, key, true, true);
  2883. },
  2884. get size() {
  2885. return size(this, true);
  2886. },
  2887. has(key) {
  2888. return has$1.call(this, key, true);
  2889. },
  2890. add: createReadonlyMethod("add"),
  2891. set: createReadonlyMethod("set"),
  2892. delete: createReadonlyMethod("delete"),
  2893. clear: createReadonlyMethod("clear"),
  2894. forEach: createForEach(true, true)
  2895. };
  2896. const iteratorMethods = ["keys", "values", "entries", Symbol.iterator];
  2897. iteratorMethods.forEach((method) => {
  2898. mutableInstrumentations2[method] = createIterableMethod(method, false, false);
  2899. readonlyInstrumentations2[method] = createIterableMethod(method, true, false);
  2900. shallowInstrumentations2[method] = createIterableMethod(method, false, true);
  2901. shallowReadonlyInstrumentations2[method] = createIterableMethod(method, true, true);
  2902. });
  2903. return [
  2904. mutableInstrumentations2,
  2905. readonlyInstrumentations2,
  2906. shallowInstrumentations2,
  2907. shallowReadonlyInstrumentations2
  2908. ];
  2909. }
  2910. var [mutableInstrumentations, readonlyInstrumentations, shallowInstrumentations, shallowReadonlyInstrumentations] = /* @__PURE__ */ createInstrumentations();
  2911. function createInstrumentationGetter(isReadonly, shallow) {
  2912. const instrumentations = shallow ? isReadonly ? shallowReadonlyInstrumentations : shallowInstrumentations : isReadonly ? readonlyInstrumentations : mutableInstrumentations;
  2913. return (target, key, receiver) => {
  2914. if (key === "__v_isReactive") {
  2915. return !isReadonly;
  2916. } else if (key === "__v_isReadonly") {
  2917. return isReadonly;
  2918. } else if (key === "__v_raw") {
  2919. return target;
  2920. }
  2921. return Reflect.get(hasOwn(instrumentations, key) && key in target ? instrumentations : target, key, receiver);
  2922. };
  2923. }
  2924. var mutableCollectionHandlers = {
  2925. get: /* @__PURE__ */ createInstrumentationGetter(false, false)
  2926. };
  2927. var readonlyCollectionHandlers = {
  2928. get: /* @__PURE__ */ createInstrumentationGetter(true, false)
  2929. };
  2930. function checkIdentityKeys(target, has2, key) {
  2931. const rawKey = toRaw(key);
  2932. if (rawKey !== key && has2.call(target, rawKey)) {
  2933. const type = toRawType(target);
  2934. console.warn(`Reactive ${type} contains both the raw and reactive versions of the same object${type === `Map` ? ` as keys` : ``}, which can lead to inconsistencies. Avoid differentiating between the raw and reactive versions of an object and only use the reactive version if possible.`);
  2935. }
  2936. }
  2937. var reactiveMap = /* @__PURE__ */ new WeakMap();
  2938. var shallowReactiveMap = /* @__PURE__ */ new WeakMap();
  2939. var readonlyMap = /* @__PURE__ */ new WeakMap();
  2940. var shallowReadonlyMap = /* @__PURE__ */ new WeakMap();
  2941. function targetTypeMap(rawType) {
  2942. switch (rawType) {
  2943. case "Object":
  2944. case "Array":
  2945. return 1;
  2946. case "Map":
  2947. case "Set":
  2948. case "WeakMap":
  2949. case "WeakSet":
  2950. return 2;
  2951. default:
  2952. return 0;
  2953. }
  2954. }
  2955. function getTargetType(value) {
  2956. return value["__v_skip"] || !Object.isExtensible(value) ? 0 : targetTypeMap(toRawType(value));
  2957. }
  2958. function reactive2(target) {
  2959. if (target && target["__v_isReadonly"]) {
  2960. return target;
  2961. }
  2962. return createReactiveObject(target, false, mutableHandlers, mutableCollectionHandlers, reactiveMap);
  2963. }
  2964. function readonly(target) {
  2965. return createReactiveObject(target, true, readonlyHandlers, readonlyCollectionHandlers, readonlyMap);
  2966. }
  2967. function createReactiveObject(target, isReadonly, baseHandlers, collectionHandlers, proxyMap) {
  2968. if (!isObject2(target)) {
  2969. if (true) {
  2970. console.warn(`value cannot be made reactive: ${String(target)}`);
  2971. }
  2972. return target;
  2973. }
  2974. if (target["__v_raw"] && !(isReadonly && target["__v_isReactive"])) {
  2975. return target;
  2976. }
  2977. const existingProxy = proxyMap.get(target);
  2978. if (existingProxy) {
  2979. return existingProxy;
  2980. }
  2981. const targetType = getTargetType(target);
  2982. if (targetType === 0) {
  2983. return target;
  2984. }
  2985. const proxy = new Proxy(target, targetType === 2 ? collectionHandlers : baseHandlers);
  2986. proxyMap.set(target, proxy);
  2987. return proxy;
  2988. }
  2989. function toRaw(observed) {
  2990. return observed && toRaw(observed["__v_raw"]) || observed;
  2991. }
  2992. function isRef(r) {
  2993. return Boolean(r && r.__v_isRef === true);
  2994. }
  2995. magic("nextTick", () => nextTick);
  2996. magic("dispatch", (el) => dispatch2.bind(dispatch2, el));
  2997. magic("watch", (el, { evaluateLater: evaluateLater2, cleanup: cleanup2 }) => (key, callback) => {
  2998. let evaluate22 = evaluateLater2(key);
  2999. let getter = () => {
  3000. let value;
  3001. evaluate22((i) => value = i);
  3002. return value;
  3003. };
  3004. let unwatch = watch(getter, callback);
  3005. cleanup2(unwatch);
  3006. });
  3007. magic("store", getStores);
  3008. magic("data", (el) => scope(el));
  3009. magic("root", (el) => closestRoot(el));
  3010. magic("refs", (el) => {
  3011. if (el._x_refs_proxy)
  3012. return el._x_refs_proxy;
  3013. el._x_refs_proxy = mergeProxies(getArrayOfRefObject(el));
  3014. return el._x_refs_proxy;
  3015. });
  3016. function getArrayOfRefObject(el) {
  3017. let refObjects = [];
  3018. findClosest(el, (i) => {
  3019. if (i._x_refs)
  3020. refObjects.push(i._x_refs);
  3021. });
  3022. return refObjects;
  3023. }
  3024. var globalIdMemo = {};
  3025. function findAndIncrementId(name) {
  3026. if (!globalIdMemo[name])
  3027. globalIdMemo[name] = 0;
  3028. return ++globalIdMemo[name];
  3029. }
  3030. function closestIdRoot(el, name) {
  3031. return findClosest(el, (element) => {
  3032. if (element._x_ids && element._x_ids[name])
  3033. return true;
  3034. });
  3035. }
  3036. function setIdRoot(el, name) {
  3037. if (!el._x_ids)
  3038. el._x_ids = {};
  3039. if (!el._x_ids[name])
  3040. el._x_ids[name] = findAndIncrementId(name);
  3041. }
  3042. magic("id", (el, { cleanup: cleanup2 }) => (name, key = null) => {
  3043. let cacheKey = `${name}${key ? `-${key}` : ""}`;
  3044. return cacheIdByNameOnElement(el, cacheKey, cleanup2, () => {
  3045. let root = closestIdRoot(el, name);
  3046. let id = root ? root._x_ids[name] : findAndIncrementId(name);
  3047. return key ? `${name}-${id}-${key}` : `${name}-${id}`;
  3048. });
  3049. });
  3050. interceptClone((from, to) => {
  3051. if (from._x_id) {
  3052. to._x_id = from._x_id;
  3053. }
  3054. });
  3055. function cacheIdByNameOnElement(el, cacheKey, cleanup2, callback) {
  3056. if (!el._x_id)
  3057. el._x_id = {};
  3058. if (el._x_id[cacheKey])
  3059. return el._x_id[cacheKey];
  3060. let output = callback();
  3061. el._x_id[cacheKey] = output;
  3062. cleanup2(() => {
  3063. delete el._x_id[cacheKey];
  3064. });
  3065. return output;
  3066. }
  3067. magic("el", (el) => el);
  3068. warnMissingPluginMagic("Focus", "focus", "focus");
  3069. warnMissingPluginMagic("Persist", "persist", "persist");
  3070. function warnMissingPluginMagic(name, magicName, slug) {
  3071. magic(magicName, (el) => warn(`You can't use [$${magicName}] without first installing the "${name}" plugin here: https://alpinejs.dev/plugins/${slug}`, el));
  3072. }
  3073. directive("modelable", (el, { expression }, { effect: effect3, evaluateLater: evaluateLater2, cleanup: cleanup2 }) => {
  3074. let func = evaluateLater2(expression);
  3075. let innerGet = () => {
  3076. let result;
  3077. func((i) => result = i);
  3078. return result;
  3079. };
  3080. let evaluateInnerSet = evaluateLater2(`${expression} = __placeholder`);
  3081. let innerSet = (val) => evaluateInnerSet(() => {
  3082. }, { scope: { "__placeholder": val } });
  3083. let initialValue = innerGet();
  3084. innerSet(initialValue);
  3085. queueMicrotask(() => {
  3086. if (!el._x_model)
  3087. return;
  3088. el._x_removeModelListeners["default"]();
  3089. let outerGet = el._x_model.get;
  3090. let outerSet = el._x_model.set;
  3091. let releaseEntanglement = entangle({
  3092. get() {
  3093. return outerGet();
  3094. },
  3095. set(value) {
  3096. outerSet(value);
  3097. }
  3098. }, {
  3099. get() {
  3100. return innerGet();
  3101. },
  3102. set(value) {
  3103. innerSet(value);
  3104. }
  3105. });
  3106. cleanup2(releaseEntanglement);
  3107. });
  3108. });
  3109. directive("teleport", (el, { modifiers, expression }, { cleanup: cleanup2 }) => {
  3110. if (el.tagName.toLowerCase() !== "template")
  3111. warn("x-teleport can only be used on a <template> tag", el);
  3112. let target = getTarget(expression);
  3113. let clone2 = el.content.cloneNode(true).firstElementChild;
  3114. el._x_teleport = clone2;
  3115. clone2._x_teleportBack = el;
  3116. el.setAttribute("data-teleport-template", true);
  3117. clone2.setAttribute("data-teleport-target", true);
  3118. if (el._x_forwardEvents) {
  3119. el._x_forwardEvents.forEach((eventName) => {
  3120. clone2.addEventListener(eventName, (e) => {
  3121. e.stopPropagation();
  3122. el.dispatchEvent(new e.constructor(e.type, e));
  3123. });
  3124. });
  3125. }
  3126. addScopeToNode(clone2, {}, el);
  3127. let placeInDom = (clone3, target2, modifiers2) => {
  3128. if (modifiers2.includes("prepend")) {
  3129. target2.parentNode.insertBefore(clone3, target2);
  3130. } else if (modifiers2.includes("append")) {
  3131. target2.parentNode.insertBefore(clone3, target2.nextSibling);
  3132. } else {
  3133. target2.appendChild(clone3);
  3134. }
  3135. };
  3136. mutateDom(() => {
  3137. placeInDom(clone2, target, modifiers);
  3138. skipDuringClone(() => {
  3139. initTree(clone2);
  3140. })();
  3141. });
  3142. el._x_teleportPutBack = () => {
  3143. let target2 = getTarget(expression);
  3144. mutateDom(() => {
  3145. placeInDom(el._x_teleport, target2, modifiers);
  3146. });
  3147. };
  3148. cleanup2(() => mutateDom(() => {
  3149. clone2.remove();
  3150. destroyTree(clone2);
  3151. }));
  3152. });
  3153. var teleportContainerDuringClone = document.createElement("div");
  3154. function getTarget(expression) {
  3155. let target = skipDuringClone(() => {
  3156. return document.querySelector(expression);
  3157. }, () => {
  3158. return teleportContainerDuringClone;
  3159. })();
  3160. if (!target)
  3161. warn(`Cannot find x-teleport element for selector: "${expression}"`);
  3162. return target;
  3163. }
  3164. var handler = () => {
  3165. };
  3166. handler.inline = (el, { modifiers }, { cleanup: cleanup2 }) => {
  3167. modifiers.includes("self") ? el._x_ignoreSelf = true : el._x_ignore = true;
  3168. cleanup2(() => {
  3169. modifiers.includes("self") ? delete el._x_ignoreSelf : delete el._x_ignore;
  3170. });
  3171. };
  3172. directive("ignore", handler);
  3173. directive("effect", skipDuringClone((el, { expression }, { effect: effect3 }) => {
  3174. effect3(evaluateLater(el, expression));
  3175. }));
  3176. function on(el, event, modifiers, callback) {
  3177. let listenerTarget = el;
  3178. let handler4 = (e) => callback(e);
  3179. let options = {};
  3180. let wrapHandler = (callback2, wrapper) => (e) => wrapper(callback2, e);
  3181. if (modifiers.includes("dot"))
  3182. event = dotSyntax(event);
  3183. if (modifiers.includes("camel"))
  3184. event = camelCase2(event);
  3185. if (modifiers.includes("passive"))
  3186. options.passive = true;
  3187. if (modifiers.includes("capture"))
  3188. options.capture = true;
  3189. if (modifiers.includes("window"))
  3190. listenerTarget = window;
  3191. if (modifiers.includes("document"))
  3192. listenerTarget = document;
  3193. if (modifiers.includes("debounce")) {
  3194. let nextModifier = modifiers[modifiers.indexOf("debounce") + 1] || "invalid-wait";
  3195. let wait = isNumeric(nextModifier.split("ms")[0]) ? Number(nextModifier.split("ms")[0]) : 250;
  3196. handler4 = debounce(handler4, wait);
  3197. }
  3198. if (modifiers.includes("throttle")) {
  3199. let nextModifier = modifiers[modifiers.indexOf("throttle") + 1] || "invalid-wait";
  3200. let wait = isNumeric(nextModifier.split("ms")[0]) ? Number(nextModifier.split("ms")[0]) : 250;
  3201. handler4 = throttle(handler4, wait);
  3202. }
  3203. if (modifiers.includes("prevent"))
  3204. handler4 = wrapHandler(handler4, (next, e) => {
  3205. e.preventDefault();
  3206. next(e);
  3207. });
  3208. if (modifiers.includes("stop"))
  3209. handler4 = wrapHandler(handler4, (next, e) => {
  3210. e.stopPropagation();
  3211. next(e);
  3212. });
  3213. if (modifiers.includes("once")) {
  3214. handler4 = wrapHandler(handler4, (next, e) => {
  3215. next(e);
  3216. listenerTarget.removeEventListener(event, handler4, options);
  3217. });
  3218. }
  3219. if (modifiers.includes("away") || modifiers.includes("outside")) {
  3220. listenerTarget = document;
  3221. handler4 = wrapHandler(handler4, (next, e) => {
  3222. if (el.contains(e.target))
  3223. return;
  3224. if (e.target.isConnected === false)
  3225. return;
  3226. if (el.offsetWidth < 1 && el.offsetHeight < 1)
  3227. return;
  3228. if (el._x_isShown === false)
  3229. return;
  3230. next(e);
  3231. });
  3232. }
  3233. if (modifiers.includes("self"))
  3234. handler4 = wrapHandler(handler4, (next, e) => {
  3235. e.target === el && next(e);
  3236. });
  3237. if (isKeyEvent(event) || isClickEvent(event)) {
  3238. handler4 = wrapHandler(handler4, (next, e) => {
  3239. if (isListeningForASpecificKeyThatHasntBeenPressed(e, modifiers)) {
  3240. return;
  3241. }
  3242. next(e);
  3243. });
  3244. }
  3245. listenerTarget.addEventListener(event, handler4, options);
  3246. return () => {
  3247. listenerTarget.removeEventListener(event, handler4, options);
  3248. };
  3249. }
  3250. function dotSyntax(subject) {
  3251. return subject.replace(/-/g, ".");
  3252. }
  3253. function camelCase2(subject) {
  3254. return subject.toLowerCase().replace(/-(\w)/g, (match, char) => char.toUpperCase());
  3255. }
  3256. function isNumeric(subject) {
  3257. return !Array.isArray(subject) && !isNaN(subject);
  3258. }
  3259. function kebabCase2(subject) {
  3260. if ([" ", "_"].includes(subject))
  3261. return subject;
  3262. return subject.replace(/([a-z])([A-Z])/g, "$1-$2").replace(/[_\s]/, "-").toLowerCase();
  3263. }
  3264. function isKeyEvent(event) {
  3265. return ["keydown", "keyup"].includes(event);
  3266. }
  3267. function isClickEvent(event) {
  3268. return ["contextmenu", "click", "mouse"].some((i) => event.includes(i));
  3269. }
  3270. function isListeningForASpecificKeyThatHasntBeenPressed(e, modifiers) {
  3271. let keyModifiers = modifiers.filter((i) => {
  3272. return !["window", "document", "prevent", "stop", "once", "capture", "self", "away", "outside", "passive"].includes(i);
  3273. });
  3274. if (keyModifiers.includes("debounce")) {
  3275. let debounceIndex = keyModifiers.indexOf("debounce");
  3276. keyModifiers.splice(debounceIndex, isNumeric((keyModifiers[debounceIndex + 1] || "invalid-wait").split("ms")[0]) ? 2 : 1);
  3277. }
  3278. if (keyModifiers.includes("throttle")) {
  3279. let debounceIndex = keyModifiers.indexOf("throttle");
  3280. keyModifiers.splice(debounceIndex, isNumeric((keyModifiers[debounceIndex + 1] || "invalid-wait").split("ms")[0]) ? 2 : 1);
  3281. }
  3282. if (keyModifiers.length === 0)
  3283. return false;
  3284. if (keyModifiers.length === 1 && keyToModifiers(e.key).includes(keyModifiers[0]))
  3285. return false;
  3286. const systemKeyModifiers = ["ctrl", "shift", "alt", "meta", "cmd", "super"];
  3287. const selectedSystemKeyModifiers = systemKeyModifiers.filter((modifier) => keyModifiers.includes(modifier));
  3288. keyModifiers = keyModifiers.filter((i) => !selectedSystemKeyModifiers.includes(i));
  3289. if (selectedSystemKeyModifiers.length > 0) {
  3290. const activelyPressedKeyModifiers = selectedSystemKeyModifiers.filter((modifier) => {
  3291. if (modifier === "cmd" || modifier === "super")
  3292. modifier = "meta";
  3293. return e[`${modifier}Key`];
  3294. });
  3295. if (activelyPressedKeyModifiers.length === selectedSystemKeyModifiers.length) {
  3296. if (isClickEvent(e.type))
  3297. return false;
  3298. if (keyToModifiers(e.key).includes(keyModifiers[0]))
  3299. return false;
  3300. }
  3301. }
  3302. return true;
  3303. }
  3304. function keyToModifiers(key) {
  3305. if (!key)
  3306. return [];
  3307. key = kebabCase2(key);
  3308. let modifierToKeyMap = {
  3309. "ctrl": "control",
  3310. "slash": "/",
  3311. "space": " ",
  3312. "spacebar": " ",
  3313. "cmd": "meta",
  3314. "esc": "escape",
  3315. "up": "arrow-up",
  3316. "down": "arrow-down",
  3317. "left": "arrow-left",
  3318. "right": "arrow-right",
  3319. "period": ".",
  3320. "comma": ",",
  3321. "equal": "=",
  3322. "minus": "-",
  3323. "underscore": "_"
  3324. };
  3325. modifierToKeyMap[key] = key;
  3326. return Object.keys(modifierToKeyMap).map((modifier) => {
  3327. if (modifierToKeyMap[modifier] === key)
  3328. return modifier;
  3329. }).filter((modifier) => modifier);
  3330. }
  3331. directive("model", (el, { modifiers, expression }, { effect: effect3, cleanup: cleanup2 }) => {
  3332. let scopeTarget = el;
  3333. if (modifiers.includes("parent")) {
  3334. scopeTarget = el.parentNode;
  3335. }
  3336. let evaluateGet = evaluateLater(scopeTarget, expression);
  3337. let evaluateSet;
  3338. if (typeof expression === "string") {
  3339. evaluateSet = evaluateLater(scopeTarget, `${expression} = __placeholder`);
  3340. } else if (typeof expression === "function" && typeof expression() === "string") {
  3341. evaluateSet = evaluateLater(scopeTarget, `${expression()} = __placeholder`);
  3342. } else {
  3343. evaluateSet = () => {
  3344. };
  3345. }
  3346. let getValue = () => {
  3347. let result;
  3348. evaluateGet((value) => result = value);
  3349. return isGetterSetter(result) ? result.get() : result;
  3350. };
  3351. let setValue = (value) => {
  3352. let result;
  3353. evaluateGet((value2) => result = value2);
  3354. if (isGetterSetter(result)) {
  3355. result.set(value);
  3356. } else {
  3357. evaluateSet(() => {
  3358. }, {
  3359. scope: { "__placeholder": value }
  3360. });
  3361. }
  3362. };
  3363. if (typeof expression === "string" && el.type === "radio") {
  3364. mutateDom(() => {
  3365. if (!el.hasAttribute("name"))
  3366. el.setAttribute("name", expression);
  3367. });
  3368. }
  3369. var event = el.tagName.toLowerCase() === "select" || ["checkbox", "radio"].includes(el.type) || modifiers.includes("lazy") ? "change" : "input";
  3370. let removeListener = isCloning ? () => {
  3371. } : on(el, event, modifiers, (e) => {
  3372. setValue(getInputValue(el, modifiers, e, getValue()));
  3373. });
  3374. if (modifiers.includes("fill")) {
  3375. if ([void 0, null, ""].includes(getValue()) || isCheckbox(el) && Array.isArray(getValue()) || el.tagName.toLowerCase() === "select" && el.multiple) {
  3376. setValue(getInputValue(el, modifiers, { target: el }, getValue()));
  3377. }
  3378. }
  3379. if (!el._x_removeModelListeners)
  3380. el._x_removeModelListeners = {};
  3381. el._x_removeModelListeners["default"] = removeListener;
  3382. cleanup2(() => el._x_removeModelListeners["default"]());
  3383. if (el.form) {
  3384. let removeResetListener = on(el.form, "reset", [], (e) => {
  3385. nextTick(() => el._x_model && el._x_model.set(getInputValue(el, modifiers, { target: el }, getValue())));
  3386. });
  3387. cleanup2(() => removeResetListener());
  3388. }
  3389. el._x_model = {
  3390. get() {
  3391. return getValue();
  3392. },
  3393. set(value) {
  3394. setValue(value);
  3395. }
  3396. };
  3397. el._x_forceModelUpdate = (value) => {
  3398. if (value === void 0 && typeof expression === "string" && expression.match(/\./))
  3399. value = "";
  3400. window.fromModel = true;
  3401. mutateDom(() => bind(el, "value", value));
  3402. delete window.fromModel;
  3403. };
  3404. effect3(() => {
  3405. let value = getValue();
  3406. if (modifiers.includes("unintrusive") && document.activeElement.isSameNode(el))
  3407. return;
  3408. el._x_forceModelUpdate(value);
  3409. });
  3410. });
  3411. function getInputValue(el, modifiers, event, currentValue) {
  3412. return mutateDom(() => {
  3413. if (event instanceof CustomEvent && event.detail !== void 0)
  3414. return event.detail !== null && event.detail !== void 0 ? event.detail : event.target.value;
  3415. else if (isCheckbox(el)) {
  3416. if (Array.isArray(currentValue)) {
  3417. let newValue = null;
  3418. if (modifiers.includes("number")) {
  3419. newValue = safeParseNumber(event.target.value);
  3420. } else if (modifiers.includes("boolean")) {
  3421. newValue = safeParseBoolean(event.target.value);
  3422. } else {
  3423. newValue = event.target.value;
  3424. }
  3425. return event.target.checked ? currentValue.includes(newValue) ? currentValue : currentValue.concat([newValue]) : currentValue.filter((el2) => !checkedAttrLooseCompare2(el2, newValue));
  3426. } else {
  3427. return event.target.checked;
  3428. }
  3429. } else if (el.tagName.toLowerCase() === "select" && el.multiple) {
  3430. if (modifiers.includes("number")) {
  3431. return Array.from(event.target.selectedOptions).map((option) => {
  3432. let rawValue = option.value || option.text;
  3433. return safeParseNumber(rawValue);
  3434. });
  3435. } else if (modifiers.includes("boolean")) {
  3436. return Array.from(event.target.selectedOptions).map((option) => {
  3437. let rawValue = option.value || option.text;
  3438. return safeParseBoolean(rawValue);
  3439. });
  3440. }
  3441. return Array.from(event.target.selectedOptions).map((option) => {
  3442. return option.value || option.text;
  3443. });
  3444. } else {
  3445. let newValue;
  3446. if (isRadio(el)) {
  3447. if (event.target.checked) {
  3448. newValue = event.target.value;
  3449. } else {
  3450. newValue = currentValue;
  3451. }
  3452. } else {
  3453. newValue = event.target.value;
  3454. }
  3455. if (modifiers.includes("number")) {
  3456. return safeParseNumber(newValue);
  3457. } else if (modifiers.includes("boolean")) {
  3458. return safeParseBoolean(newValue);
  3459. } else if (modifiers.includes("trim")) {
  3460. return newValue.trim();
  3461. } else {
  3462. return newValue;
  3463. }
  3464. }
  3465. });
  3466. }
  3467. function safeParseNumber(rawValue) {
  3468. let number = rawValue ? parseFloat(rawValue) : null;
  3469. return isNumeric2(number) ? number : rawValue;
  3470. }
  3471. function checkedAttrLooseCompare2(valueA, valueB) {
  3472. return valueA == valueB;
  3473. }
  3474. function isNumeric2(subject) {
  3475. return !Array.isArray(subject) && !isNaN(subject);
  3476. }
  3477. function isGetterSetter(value) {
  3478. return value !== null && typeof value === "object" && typeof value.get === "function" && typeof value.set === "function";
  3479. }
  3480. directive("cloak", (el) => queueMicrotask(() => mutateDom(() => el.removeAttribute(prefix("cloak")))));
  3481. addInitSelector(() => `[${prefix("init")}]`);
  3482. directive("init", skipDuringClone((el, { expression }, { evaluate: evaluate22 }) => {
  3483. if (typeof expression === "string") {
  3484. return !!expression.trim() && evaluate22(expression, {}, false);
  3485. }
  3486. return evaluate22(expression, {}, false);
  3487. }));
  3488. directive("text", (el, { expression }, { effect: effect3, evaluateLater: evaluateLater2 }) => {
  3489. let evaluate22 = evaluateLater2(expression);
  3490. effect3(() => {
  3491. evaluate22((value) => {
  3492. mutateDom(() => {
  3493. el.textContent = value;
  3494. });
  3495. });
  3496. });
  3497. });
  3498. directive("html", (el, { expression }, { effect: effect3, evaluateLater: evaluateLater2 }) => {
  3499. let evaluate22 = evaluateLater2(expression);
  3500. effect3(() => {
  3501. evaluate22((value) => {
  3502. mutateDom(() => {
  3503. el.innerHTML = value;
  3504. el._x_ignoreSelf = true;
  3505. initTree(el);
  3506. delete el._x_ignoreSelf;
  3507. });
  3508. });
  3509. });
  3510. });
  3511. mapAttributes(startingWith(":", into(prefix("bind:"))));
  3512. var handler2 = (el, { value, modifiers, expression, original }, { effect: effect3, cleanup: cleanup2 }) => {
  3513. if (!value) {
  3514. let bindingProviders = {};
  3515. injectBindingProviders(bindingProviders);
  3516. let getBindings = evaluateLater(el, expression);
  3517. getBindings((bindings) => {
  3518. applyBindingsObject(el, bindings, original);
  3519. }, { scope: bindingProviders });
  3520. return;
  3521. }
  3522. if (value === "key")
  3523. return storeKeyForXFor(el, expression);
  3524. if (el._x_inlineBindings && el._x_inlineBindings[value] && el._x_inlineBindings[value].extract) {
  3525. return;
  3526. }
  3527. let evaluate22 = evaluateLater(el, expression);
  3528. effect3(() => evaluate22((result) => {
  3529. if (result === void 0 && typeof expression === "string" && expression.match(/\./)) {
  3530. result = "";
  3531. }
  3532. mutateDom(() => bind(el, value, result, modifiers));
  3533. }));
  3534. cleanup2(() => {
  3535. el._x_undoAddedClasses && el._x_undoAddedClasses();
  3536. el._x_undoAddedStyles && el._x_undoAddedStyles();
  3537. });
  3538. };
  3539. handler2.inline = (el, { value, modifiers, expression }) => {
  3540. if (!value)
  3541. return;
  3542. if (!el._x_inlineBindings)
  3543. el._x_inlineBindings = {};
  3544. el._x_inlineBindings[value] = { expression, extract: false };
  3545. };
  3546. directive("bind", handler2);
  3547. function storeKeyForXFor(el, expression) {
  3548. el._x_keyExpression = expression;
  3549. }
  3550. addRootSelector(() => `[${prefix("data")}]`);
  3551. directive("data", (el, { expression }, { cleanup: cleanup2 }) => {
  3552. if (shouldSkipRegisteringDataDuringClone(el))
  3553. return;
  3554. expression = expression === "" ? "{}" : expression;
  3555. let magicContext = {};
  3556. injectMagics(magicContext, el);
  3557. let dataProviderContext = {};
  3558. injectDataProviders(dataProviderContext, magicContext);
  3559. let data2 = evaluate(el, expression, { scope: dataProviderContext });
  3560. if (data2 === void 0 || data2 === true)
  3561. data2 = {};
  3562. injectMagics(data2, el);
  3563. let reactiveData = reactive(data2);
  3564. initInterceptors(reactiveData);
  3565. let undo = addScopeToNode(el, reactiveData);
  3566. reactiveData["init"] && evaluate(el, reactiveData["init"]);
  3567. cleanup2(() => {
  3568. reactiveData["destroy"] && evaluate(el, reactiveData["destroy"]);
  3569. undo();
  3570. });
  3571. });
  3572. interceptClone((from, to) => {
  3573. if (from._x_dataStack) {
  3574. to._x_dataStack = from._x_dataStack;
  3575. to.setAttribute("data-has-alpine-state", true);
  3576. }
  3577. });
  3578. function shouldSkipRegisteringDataDuringClone(el) {
  3579. if (!isCloning)
  3580. return false;
  3581. if (isCloningLegacy)
  3582. return true;
  3583. return el.hasAttribute("data-has-alpine-state");
  3584. }
  3585. directive("show", (el, { modifiers, expression }, { effect: effect3 }) => {
  3586. let evaluate22 = evaluateLater(el, expression);
  3587. if (!el._x_doHide)
  3588. el._x_doHide = () => {
  3589. mutateDom(() => {
  3590. el.style.setProperty("display", "none", modifiers.includes("important") ? "important" : void 0);
  3591. });
  3592. };
  3593. if (!el._x_doShow)
  3594. el._x_doShow = () => {
  3595. mutateDom(() => {
  3596. if (el.style.length === 1 && el.style.display === "none") {
  3597. el.removeAttribute("style");
  3598. } else {
  3599. el.style.removeProperty("display");
  3600. }
  3601. });
  3602. };
  3603. let hide = () => {
  3604. el._x_doHide();
  3605. el._x_isShown = false;
  3606. };
  3607. let show = () => {
  3608. el._x_doShow();
  3609. el._x_isShown = true;
  3610. };
  3611. let clickAwayCompatibleShow = () => setTimeout(show);
  3612. let toggle = once((value) => value ? show() : hide(), (value) => {
  3613. if (typeof el._x_toggleAndCascadeWithTransitions === "function") {
  3614. el._x_toggleAndCascadeWithTransitions(el, value, show, hide);
  3615. } else {
  3616. value ? clickAwayCompatibleShow() : hide();
  3617. }
  3618. });
  3619. let oldValue;
  3620. let firstTime = true;
  3621. effect3(() => evaluate22((value) => {
  3622. if (!firstTime && value === oldValue)
  3623. return;
  3624. if (modifiers.includes("immediate"))
  3625. value ? clickAwayCompatibleShow() : hide();
  3626. toggle(value);
  3627. oldValue = value;
  3628. firstTime = false;
  3629. }));
  3630. });
  3631. directive("for", (el, { expression }, { effect: effect3, cleanup: cleanup2 }) => {
  3632. let iteratorNames = parseForExpression(expression);
  3633. let evaluateItems = evaluateLater(el, iteratorNames.items);
  3634. let evaluateKey = evaluateLater(el, el._x_keyExpression || "index");
  3635. el._x_prevKeys = [];
  3636. el._x_lookup = {};
  3637. effect3(() => loop(el, iteratorNames, evaluateItems, evaluateKey));
  3638. cleanup2(() => {
  3639. Object.values(el._x_lookup).forEach((el2) => mutateDom(() => {
  3640. destroyTree(el2);
  3641. el2.remove();
  3642. }));
  3643. delete el._x_prevKeys;
  3644. delete el._x_lookup;
  3645. });
  3646. });
  3647. function loop(el, iteratorNames, evaluateItems, evaluateKey) {
  3648. let isObject22 = (i) => typeof i === "object" && !Array.isArray(i);
  3649. let templateEl = el;
  3650. evaluateItems((items) => {
  3651. if (isNumeric3(items) && items >= 0) {
  3652. items = Array.from(Array(items).keys(), (i) => i + 1);
  3653. }
  3654. if (items === void 0)
  3655. items = [];
  3656. let lookup = el._x_lookup;
  3657. let prevKeys = el._x_prevKeys;
  3658. let scopes = [];
  3659. let keys = [];
  3660. if (isObject22(items)) {
  3661. items = Object.entries(items).map(([key, value]) => {
  3662. let scope2 = getIterationScopeVariables(iteratorNames, value, key, items);
  3663. evaluateKey((value2) => {
  3664. if (keys.includes(value2))
  3665. warn("Duplicate key on x-for", el);
  3666. keys.push(value2);
  3667. }, { scope: { index: key, ...scope2 } });
  3668. scopes.push(scope2);
  3669. });
  3670. } else {
  3671. for (let i = 0; i < items.length; i++) {
  3672. let scope2 = getIterationScopeVariables(iteratorNames, items[i], i, items);
  3673. evaluateKey((value) => {
  3674. if (keys.includes(value))
  3675. warn("Duplicate key on x-for", el);
  3676. keys.push(value);
  3677. }, { scope: { index: i, ...scope2 } });
  3678. scopes.push(scope2);
  3679. }
  3680. }
  3681. let adds = [];
  3682. let moves = [];
  3683. let removes = [];
  3684. let sames = [];
  3685. for (let i = 0; i < prevKeys.length; i++) {
  3686. let key = prevKeys[i];
  3687. if (keys.indexOf(key) === -1)
  3688. removes.push(key);
  3689. }
  3690. prevKeys = prevKeys.filter((key) => !removes.includes(key));
  3691. let lastKey = "template";
  3692. for (let i = 0; i < keys.length; i++) {
  3693. let key = keys[i];
  3694. let prevIndex = prevKeys.indexOf(key);
  3695. if (prevIndex === -1) {
  3696. prevKeys.splice(i, 0, key);
  3697. adds.push([lastKey, i]);
  3698. } else if (prevIndex !== i) {
  3699. let keyInSpot = prevKeys.splice(i, 1)[0];
  3700. let keyForSpot = prevKeys.splice(prevIndex - 1, 1)[0];
  3701. prevKeys.splice(i, 0, keyForSpot);
  3702. prevKeys.splice(prevIndex, 0, keyInSpot);
  3703. moves.push([keyInSpot, keyForSpot]);
  3704. } else {
  3705. sames.push(key);
  3706. }
  3707. lastKey = key;
  3708. }
  3709. for (let i = 0; i < removes.length; i++) {
  3710. let key = removes[i];
  3711. if (!(key in lookup))
  3712. continue;
  3713. mutateDom(() => {
  3714. destroyTree(lookup[key]);
  3715. lookup[key].remove();
  3716. });
  3717. delete lookup[key];
  3718. }
  3719. for (let i = 0; i < moves.length; i++) {
  3720. let [keyInSpot, keyForSpot] = moves[i];
  3721. let elInSpot = lookup[keyInSpot];
  3722. let elForSpot = lookup[keyForSpot];
  3723. let marker = document.createElement("div");
  3724. mutateDom(() => {
  3725. if (!elForSpot)
  3726. warn(`x-for ":key" is undefined or invalid`, templateEl, keyForSpot, lookup);
  3727. elForSpot.after(marker);
  3728. elInSpot.after(elForSpot);
  3729. elForSpot._x_currentIfEl && elForSpot.after(elForSpot._x_currentIfEl);
  3730. marker.before(elInSpot);
  3731. elInSpot._x_currentIfEl && elInSpot.after(elInSpot._x_currentIfEl);
  3732. marker.remove();
  3733. });
  3734. elForSpot._x_refreshXForScope(scopes[keys.indexOf(keyForSpot)]);
  3735. }
  3736. for (let i = 0; i < adds.length; i++) {
  3737. let [lastKey2, index] = adds[i];
  3738. let lastEl = lastKey2 === "template" ? templateEl : lookup[lastKey2];
  3739. if (lastEl._x_currentIfEl)
  3740. lastEl = lastEl._x_currentIfEl;
  3741. let scope2 = scopes[index];
  3742. let key = keys[index];
  3743. let clone2 = document.importNode(templateEl.content, true).firstElementChild;
  3744. let reactiveScope = reactive(scope2);
  3745. addScopeToNode(clone2, reactiveScope, templateEl);
  3746. clone2._x_refreshXForScope = (newScope) => {
  3747. Object.entries(newScope).forEach(([key2, value]) => {
  3748. reactiveScope[key2] = value;
  3749. });
  3750. };
  3751. mutateDom(() => {
  3752. lastEl.after(clone2);
  3753. skipDuringClone(() => initTree(clone2))();
  3754. });
  3755. if (typeof key === "object") {
  3756. warn("x-for key cannot be an object, it must be a string or an integer", templateEl);
  3757. }
  3758. lookup[key] = clone2;
  3759. }
  3760. for (let i = 0; i < sames.length; i++) {
  3761. lookup[sames[i]]._x_refreshXForScope(scopes[keys.indexOf(sames[i])]);
  3762. }
  3763. templateEl._x_prevKeys = keys;
  3764. });
  3765. }
  3766. function parseForExpression(expression) {
  3767. let forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/;
  3768. let stripParensRE = /^\s*\(|\)\s*$/g;
  3769. let forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
  3770. let inMatch = expression.match(forAliasRE);
  3771. if (!inMatch)
  3772. return;
  3773. let res = {};
  3774. res.items = inMatch[2].trim();
  3775. let item = inMatch[1].replace(stripParensRE, "").trim();
  3776. let iteratorMatch = item.match(forIteratorRE);
  3777. if (iteratorMatch) {
  3778. res.item = item.replace(forIteratorRE, "").trim();
  3779. res.index = iteratorMatch[1].trim();
  3780. if (iteratorMatch[2]) {
  3781. res.collection = iteratorMatch[2].trim();
  3782. }
  3783. } else {
  3784. res.item = item;
  3785. }
  3786. return res;
  3787. }
  3788. function getIterationScopeVariables(iteratorNames, item, index, items) {
  3789. let scopeVariables = {};
  3790. if (/^\[.*\]$/.test(iteratorNames.item) && Array.isArray(item)) {
  3791. let names = iteratorNames.item.replace("[", "").replace("]", "").split(",").map((i) => i.trim());
  3792. names.forEach((name, i) => {
  3793. scopeVariables[name] = item[i];
  3794. });
  3795. } else if (/^\{.*\}$/.test(iteratorNames.item) && !Array.isArray(item) && typeof item === "object") {
  3796. let names = iteratorNames.item.replace("{", "").replace("}", "").split(",").map((i) => i.trim());
  3797. names.forEach((name) => {
  3798. scopeVariables[name] = item[name];
  3799. });
  3800. } else {
  3801. scopeVariables[iteratorNames.item] = item;
  3802. }
  3803. if (iteratorNames.index)
  3804. scopeVariables[iteratorNames.index] = index;
  3805. if (iteratorNames.collection)
  3806. scopeVariables[iteratorNames.collection] = items;
  3807. return scopeVariables;
  3808. }
  3809. function isNumeric3(subject) {
  3810. return !Array.isArray(subject) && !isNaN(subject);
  3811. }
  3812. function handler3() {
  3813. }
  3814. handler3.inline = (el, { expression }, { cleanup: cleanup2 }) => {
  3815. let root = closestRoot(el);
  3816. if (!root._x_refs)
  3817. root._x_refs = {};
  3818. root._x_refs[expression] = el;
  3819. cleanup2(() => delete root._x_refs[expression]);
  3820. };
  3821. directive("ref", handler3);
  3822. directive("if", (el, { expression }, { effect: effect3, cleanup: cleanup2 }) => {
  3823. if (el.tagName.toLowerCase() !== "template")
  3824. warn("x-if can only be used on a <template> tag", el);
  3825. let evaluate22 = evaluateLater(el, expression);
  3826. let show = () => {
  3827. if (el._x_currentIfEl)
  3828. return el._x_currentIfEl;
  3829. let clone2 = el.content.cloneNode(true).firstElementChild;
  3830. addScopeToNode(clone2, {}, el);
  3831. mutateDom(() => {
  3832. el.after(clone2);
  3833. skipDuringClone(() => initTree(clone2))();
  3834. });
  3835. el._x_currentIfEl = clone2;
  3836. el._x_undoIf = () => {
  3837. mutateDom(() => {
  3838. destroyTree(clone2);
  3839. clone2.remove();
  3840. });
  3841. delete el._x_currentIfEl;
  3842. };
  3843. return clone2;
  3844. };
  3845. let hide = () => {
  3846. if (!el._x_undoIf)
  3847. return;
  3848. el._x_undoIf();
  3849. delete el._x_undoIf;
  3850. };
  3851. effect3(() => evaluate22((value) => {
  3852. value ? show() : hide();
  3853. }));
  3854. cleanup2(() => el._x_undoIf && el._x_undoIf());
  3855. });
  3856. directive("id", (el, { expression }, { evaluate: evaluate22 }) => {
  3857. let names = evaluate22(expression);
  3858. names.forEach((name) => setIdRoot(el, name));
  3859. });
  3860. interceptClone((from, to) => {
  3861. if (from._x_ids) {
  3862. to._x_ids = from._x_ids;
  3863. }
  3864. });
  3865. mapAttributes(startingWith("@", into(prefix("on:"))));
  3866. directive("on", skipDuringClone((el, { value, modifiers, expression }, { cleanup: cleanup2 }) => {
  3867. let evaluate22 = expression ? evaluateLater(el, expression) : () => {
  3868. };
  3869. if (el.tagName.toLowerCase() === "template") {
  3870. if (!el._x_forwardEvents)
  3871. el._x_forwardEvents = [];
  3872. if (!el._x_forwardEvents.includes(value))
  3873. el._x_forwardEvents.push(value);
  3874. }
  3875. let removeListener = on(el, value, modifiers, (e) => {
  3876. evaluate22(() => {
  3877. }, { scope: { "$event": e }, params: [e] });
  3878. });
  3879. cleanup2(() => removeListener());
  3880. }));
  3881. warnMissingPluginDirective("Collapse", "collapse", "collapse");
  3882. warnMissingPluginDirective("Intersect", "intersect", "intersect");
  3883. warnMissingPluginDirective("Focus", "trap", "focus");
  3884. warnMissingPluginDirective("Mask", "mask", "mask");
  3885. function warnMissingPluginDirective(name, directiveName, slug) {
  3886. directive(directiveName, (el) => warn(`You can't use [x-${directiveName}] without first installing the "${name}" plugin here: https://alpinejs.dev/plugins/${slug}`, el));
  3887. }
  3888. alpine_default.setEvaluator(normalEvaluator);
  3889. alpine_default.setReactivityEngine({ reactive: reactive2, effect: effect2, release: stop, raw: toRaw });
  3890. var src_default = alpine_default;
  3891. var module_default = src_default;
  3892. // js/features/supportEntangle.js
  3893. function generateEntangleFunction(component, cleanup2) {
  3894. if (!cleanup2)
  3895. cleanup2 = () => {
  3896. };
  3897. return (name, live = false) => {
  3898. let isLive = live;
  3899. let livewireProperty = name;
  3900. let livewireComponent = component.$wire;
  3901. let livewirePropertyValue = livewireComponent.get(livewireProperty);
  3902. let interceptor2 = module_default.interceptor((initialValue, getter, setter, path, key) => {
  3903. if (typeof livewirePropertyValue === "undefined") {
  3904. console.error(`Livewire Entangle Error: Livewire property ['${livewireProperty}'] cannot be found on component: ['${component.name}']`);
  3905. return;
  3906. }
  3907. let release2 = module_default.entangle({
  3908. get() {
  3909. return livewireComponent.get(name);
  3910. },
  3911. set(value) {
  3912. livewireComponent.set(name, value, isLive);
  3913. }
  3914. }, {
  3915. get() {
  3916. return getter();
  3917. },
  3918. set(value) {
  3919. setter(value);
  3920. }
  3921. });
  3922. cleanup2(() => release2());
  3923. return cloneIfObject2(livewireComponent.get(name));
  3924. }, (obj) => {
  3925. Object.defineProperty(obj, "live", {
  3926. get() {
  3927. isLive = true;
  3928. return obj;
  3929. }
  3930. });
  3931. });
  3932. return interceptor2(livewirePropertyValue);
  3933. };
  3934. }
  3935. function cloneIfObject2(value) {
  3936. return typeof value === "object" ? JSON.parse(JSON.stringify(value)) : value;
  3937. }
  3938. // js/hooks.js
  3939. var listeners = [];
  3940. function on2(name, callback) {
  3941. if (!listeners[name])
  3942. listeners[name] = [];
  3943. listeners[name].push(callback);
  3944. return () => {
  3945. listeners[name] = listeners[name].filter((i) => i !== callback);
  3946. };
  3947. }
  3948. function trigger2(name, ...params) {
  3949. let callbacks = listeners[name] || [];
  3950. let finishers = [];
  3951. for (let i = 0; i < callbacks.length; i++) {
  3952. let finisher = callbacks[i](...params);
  3953. if (isFunction(finisher))
  3954. finishers.push(finisher);
  3955. }
  3956. return (result) => {
  3957. return runFinishers(finishers, result);
  3958. };
  3959. }
  3960. async function triggerAsync(name, ...params) {
  3961. let callbacks = listeners[name] || [];
  3962. let finishers = [];
  3963. for (let i = 0; i < callbacks.length; i++) {
  3964. let finisher = await callbacks[i](...params);
  3965. if (isFunction(finisher))
  3966. finishers.push(finisher);
  3967. }
  3968. return (result) => {
  3969. return runFinishers(finishers, result);
  3970. };
  3971. }
  3972. function runFinishers(finishers, result) {
  3973. let latest = result;
  3974. for (let i = 0; i < finishers.length; i++) {
  3975. let iResult = finishers[i](latest);
  3976. if (iResult !== void 0) {
  3977. latest = iResult;
  3978. }
  3979. }
  3980. return latest;
  3981. }
  3982. // js/request/modal.js
  3983. function showHtmlModal(html) {
  3984. let page = document.createElement("html");
  3985. page.innerHTML = html;
  3986. page.querySelectorAll("a").forEach((a) => a.setAttribute("target", "_top"));
  3987. let modal = document.getElementById("livewire-error");
  3988. if (typeof modal != "undefined" && modal != null) {
  3989. modal.innerHTML = "";
  3990. } else {
  3991. modal = document.createElement("div");
  3992. modal.id = "livewire-error";
  3993. modal.style.position = "fixed";
  3994. modal.style.width = "100vw";
  3995. modal.style.height = "100vh";
  3996. modal.style.padding = "50px";
  3997. modal.style.backgroundColor = "rgba(0, 0, 0, .6)";
  3998. modal.style.zIndex = 2e5;
  3999. }
  4000. let iframe = document.createElement("iframe");
  4001. iframe.style.backgroundColor = "#17161A";
  4002. iframe.style.borderRadius = "5px";
  4003. iframe.style.width = "100%";
  4004. iframe.style.height = "100%";
  4005. modal.appendChild(iframe);
  4006. document.body.prepend(modal);
  4007. document.body.style.overflow = "hidden";
  4008. iframe.contentWindow.document.open();
  4009. iframe.contentWindow.document.write(page.outerHTML);
  4010. iframe.contentWindow.document.close();
  4011. modal.addEventListener("click", () => hideHtmlModal(modal));
  4012. modal.setAttribute("tabindex", 0);
  4013. modal.addEventListener("keydown", (e) => {
  4014. if (e.key === "Escape")
  4015. hideHtmlModal(modal);
  4016. });
  4017. modal.focus();
  4018. }
  4019. function hideHtmlModal(modal) {
  4020. modal.outerHTML = "";
  4021. document.body.style.overflow = "visible";
  4022. }
  4023. // js/request/pool.js
  4024. var RequestPool = class {
  4025. constructor() {
  4026. this.commits = /* @__PURE__ */ new Set();
  4027. }
  4028. add(commit) {
  4029. this.commits.add(commit);
  4030. }
  4031. delete(commit) {
  4032. this.commits.delete(commit);
  4033. }
  4034. hasCommitFor(component) {
  4035. return !!this.findCommitByComponent(component);
  4036. }
  4037. findCommitByComponent(component) {
  4038. for (let [idx, commit] of this.commits.entries()) {
  4039. if (commit.component === component)
  4040. return commit;
  4041. }
  4042. }
  4043. shouldHoldCommit(commit) {
  4044. return !commit.isolate;
  4045. }
  4046. empty() {
  4047. return this.commits.size === 0;
  4048. }
  4049. async send() {
  4050. this.prepare();
  4051. await sendRequest(this);
  4052. }
  4053. prepare() {
  4054. this.commits.forEach((i) => i.prepare());
  4055. }
  4056. payload() {
  4057. let commitPayloads = [];
  4058. let successReceivers = [];
  4059. let failureReceivers = [];
  4060. this.commits.forEach((commit) => {
  4061. let [payload, succeed2, fail2] = commit.toRequestPayload();
  4062. commitPayloads.push(payload);
  4063. successReceivers.push(succeed2);
  4064. failureReceivers.push(fail2);
  4065. });
  4066. let succeed = (components2) => successReceivers.forEach((receiver) => receiver(components2.shift()));
  4067. let fail = () => failureReceivers.forEach((receiver) => receiver());
  4068. return [commitPayloads, succeed, fail];
  4069. }
  4070. };
  4071. // js/request/commit.js
  4072. var Commit = class {
  4073. constructor(component) {
  4074. this.component = component;
  4075. this.isolate = false;
  4076. this.calls = [];
  4077. this.receivers = [];
  4078. this.resolvers = [];
  4079. }
  4080. addResolver(resolver) {
  4081. this.resolvers.push(resolver);
  4082. }
  4083. addCall(method, params, receiver) {
  4084. this.calls.push({
  4085. path: "",
  4086. method,
  4087. params,
  4088. handleReturn(value) {
  4089. receiver(value);
  4090. }
  4091. });
  4092. }
  4093. prepare() {
  4094. trigger2("commit.prepare", { component: this.component });
  4095. }
  4096. toRequestPayload() {
  4097. let propertiesDiff = diff(this.component.canonical, this.component.ephemeral);
  4098. let updates = this.component.mergeQueuedUpdates(propertiesDiff);
  4099. let payload = {
  4100. snapshot: this.component.snapshotEncoded,
  4101. updates,
  4102. calls: this.calls.map((i) => ({
  4103. path: i.path,
  4104. method: i.method,
  4105. params: i.params
  4106. }))
  4107. };
  4108. let succeedCallbacks = [];
  4109. let failCallbacks = [];
  4110. let respondCallbacks = [];
  4111. let succeed = (fwd) => succeedCallbacks.forEach((i) => i(fwd));
  4112. let fail = () => failCallbacks.forEach((i) => i());
  4113. let respond = () => respondCallbacks.forEach((i) => i());
  4114. let finishTarget = trigger2("commit", {
  4115. component: this.component,
  4116. commit: payload,
  4117. succeed: (callback) => {
  4118. succeedCallbacks.push(callback);
  4119. },
  4120. fail: (callback) => {
  4121. failCallbacks.push(callback);
  4122. },
  4123. respond: (callback) => {
  4124. respondCallbacks.push(callback);
  4125. }
  4126. });
  4127. let handleResponse = (response) => {
  4128. let { snapshot, effects } = response;
  4129. respond();
  4130. this.component.mergeNewSnapshot(snapshot, effects, updates);
  4131. this.component.processEffects(this.component.effects);
  4132. if (effects["returns"]) {
  4133. let returns = effects["returns"];
  4134. let returnHandlerStack = this.calls.map(({ handleReturn }) => handleReturn);
  4135. returnHandlerStack.forEach((handleReturn, index) => {
  4136. handleReturn(returns[index]);
  4137. });
  4138. }
  4139. let parsedSnapshot = JSON.parse(snapshot);
  4140. finishTarget({ snapshot: parsedSnapshot, effects });
  4141. this.resolvers.forEach((i) => i());
  4142. succeed(response);
  4143. };
  4144. let handleFailure = () => {
  4145. respond();
  4146. fail();
  4147. };
  4148. return [payload, handleResponse, handleFailure];
  4149. }
  4150. };
  4151. // js/request/bus.js
  4152. var CommitBus = class {
  4153. constructor() {
  4154. this.commits = /* @__PURE__ */ new Set();
  4155. this.pools = /* @__PURE__ */ new Set();
  4156. }
  4157. add(component) {
  4158. let commit = this.findCommitOr(component, () => {
  4159. let newCommit = new Commit(component);
  4160. this.commits.add(newCommit);
  4161. return newCommit;
  4162. });
  4163. bufferPoolingForFiveMs(commit, () => {
  4164. let pool = this.findPoolWithComponent(commit.component);
  4165. if (!pool) {
  4166. this.createAndSendNewPool();
  4167. }
  4168. });
  4169. return commit;
  4170. }
  4171. findCommitOr(component, callback) {
  4172. for (let [idx, commit] of this.commits.entries()) {
  4173. if (commit.component === component) {
  4174. return commit;
  4175. }
  4176. }
  4177. return callback();
  4178. }
  4179. findPoolWithComponent(component) {
  4180. for (let [idx, pool] of this.pools.entries()) {
  4181. if (pool.hasCommitFor(component))
  4182. return pool;
  4183. }
  4184. }
  4185. createAndSendNewPool() {
  4186. trigger2("commit.pooling", { commits: this.commits });
  4187. let pools = this.corraleCommitsIntoPools();
  4188. this.commits.clear();
  4189. trigger2("commit.pooled", { pools });
  4190. pools.forEach((pool) => {
  4191. if (pool.empty())
  4192. return;
  4193. this.pools.add(pool);
  4194. pool.send().then(() => {
  4195. this.pools.delete(pool);
  4196. this.sendAnyQueuedCommits();
  4197. });
  4198. });
  4199. }
  4200. corraleCommitsIntoPools() {
  4201. let pools = /* @__PURE__ */ new Set();
  4202. for (let [idx, commit] of this.commits.entries()) {
  4203. let hasFoundPool = false;
  4204. pools.forEach((pool) => {
  4205. if (pool.shouldHoldCommit(commit)) {
  4206. pool.add(commit);
  4207. hasFoundPool = true;
  4208. }
  4209. });
  4210. if (!hasFoundPool) {
  4211. let newPool = new RequestPool();
  4212. newPool.add(commit);
  4213. pools.add(newPool);
  4214. }
  4215. }
  4216. return pools;
  4217. }
  4218. sendAnyQueuedCommits() {
  4219. if (this.commits.size > 0) {
  4220. this.createAndSendNewPool();
  4221. }
  4222. }
  4223. };
  4224. var buffersByCommit = /* @__PURE__ */ new WeakMap();
  4225. function bufferPoolingForFiveMs(commit, callback) {
  4226. if (buffersByCommit.has(commit))
  4227. return;
  4228. buffersByCommit.set(commit, setTimeout(() => {
  4229. callback();
  4230. buffersByCommit.delete(commit);
  4231. }, 5));
  4232. }
  4233. // js/request/index.js
  4234. var commitBus = new CommitBus();
  4235. async function requestCommit(component) {
  4236. let commit = commitBus.add(component);
  4237. let promise = new Promise((resolve) => {
  4238. commit.addResolver(resolve);
  4239. });
  4240. promise.commit = commit;
  4241. return promise;
  4242. }
  4243. async function requestCall(component, method, params) {
  4244. let commit = commitBus.add(component);
  4245. let promise = new Promise((resolve) => {
  4246. commit.addCall(method, params, (value) => resolve(value));
  4247. });
  4248. promise.commit = commit;
  4249. return promise;
  4250. }
  4251. async function sendRequest(pool) {
  4252. let [payload, handleSuccess, handleFailure] = pool.payload();
  4253. let options = {
  4254. method: "POST",
  4255. body: JSON.stringify({
  4256. _token: getCsrfToken(),
  4257. components: payload
  4258. }),
  4259. headers: {
  4260. "Content-type": "application/json",
  4261. "X-Livewire": ""
  4262. }
  4263. };
  4264. let succeedCallbacks = [];
  4265. let failCallbacks = [];
  4266. let respondCallbacks = [];
  4267. let succeed = (fwd) => succeedCallbacks.forEach((i) => i(fwd));
  4268. let fail = (fwd) => failCallbacks.forEach((i) => i(fwd));
  4269. let respond = (fwd) => respondCallbacks.forEach((i) => i(fwd));
  4270. let finishProfile = trigger2("request.profile", options);
  4271. let updateUri = getUpdateUri();
  4272. trigger2("request", {
  4273. url: updateUri,
  4274. options,
  4275. payload: options.body,
  4276. respond: (i) => respondCallbacks.push(i),
  4277. succeed: (i) => succeedCallbacks.push(i),
  4278. fail: (i) => failCallbacks.push(i)
  4279. });
  4280. let response;
  4281. try {
  4282. response = await fetch(updateUri, options);
  4283. } catch (e) {
  4284. finishProfile({ content: "{}", failed: true });
  4285. handleFailure();
  4286. fail({
  4287. status: 503,
  4288. content: null,
  4289. preventDefault: () => {
  4290. }
  4291. });
  4292. return;
  4293. }
  4294. let mutableObject = {
  4295. status: response.status,
  4296. response
  4297. };
  4298. respond(mutableObject);
  4299. response = mutableObject.response;
  4300. let content = await response.text();
  4301. if (!response.ok) {
  4302. finishProfile({ content: "{}", failed: true });
  4303. let preventDefault = false;
  4304. handleFailure();
  4305. fail({
  4306. status: response.status,
  4307. content,
  4308. preventDefault: () => preventDefault = true
  4309. });
  4310. if (preventDefault)
  4311. return;
  4312. if (response.status === 419) {
  4313. handlePageExpiry();
  4314. }
  4315. return showFailureModal(content);
  4316. }
  4317. if (response.redirected) {
  4318. window.location.href = response.url;
  4319. }
  4320. if (contentIsFromDump(content)) {
  4321. let dump;
  4322. [dump, content] = splitDumpFromContent(content);
  4323. showHtmlModal(dump);
  4324. finishProfile({ content: "{}", failed: true });
  4325. } else {
  4326. finishProfile({ content, failed: false });
  4327. }
  4328. let { components: components2, assets } = JSON.parse(content);
  4329. await triggerAsync("payload.intercept", { components: components2, assets });
  4330. await handleSuccess(components2);
  4331. succeed({ status: response.status, json: JSON.parse(content) });
  4332. }
  4333. function handlePageExpiry() {
  4334. confirm("This page has expired.\nWould you like to refresh the page?") && window.location.reload();
  4335. }
  4336. function showFailureModal(content) {
  4337. let html = content;
  4338. showHtmlModal(html);
  4339. }
  4340. // js/$wire.js
  4341. var properties = {};
  4342. var fallback;
  4343. function wireProperty(name, callback, component = null) {
  4344. properties[name] = callback;
  4345. }
  4346. function wireFallback(callback) {
  4347. fallback = callback;
  4348. }
  4349. var aliases = {
  4350. "on": "$on",
  4351. "el": "$el",
  4352. "id": "$id",
  4353. "js": "$js",
  4354. "get": "$get",
  4355. "set": "$set",
  4356. "call": "$call",
  4357. "hook": "$hook",
  4358. "commit": "$commit",
  4359. "watch": "$watch",
  4360. "entangle": "$entangle",
  4361. "dispatch": "$dispatch",
  4362. "dispatchTo": "$dispatchTo",
  4363. "dispatchSelf": "$dispatchSelf",
  4364. "upload": "$upload",
  4365. "uploadMultiple": "$uploadMultiple",
  4366. "removeUpload": "$removeUpload",
  4367. "cancelUpload": "$cancelUpload"
  4368. };
  4369. function generateWireObject(component, state) {
  4370. return new Proxy({}, {
  4371. get(target, property) {
  4372. if (property === "__instance")
  4373. return component;
  4374. if (property in aliases) {
  4375. return getProperty(component, aliases[property]);
  4376. } else if (property in properties) {
  4377. return getProperty(component, property);
  4378. } else if (property in state) {
  4379. return state[property];
  4380. } else if (!["then"].includes(property)) {
  4381. return getFallback(component)(property);
  4382. }
  4383. },
  4384. set(target, property, value) {
  4385. if (property in state) {
  4386. state[property] = value;
  4387. }
  4388. return true;
  4389. }
  4390. });
  4391. }
  4392. function getProperty(component, name) {
  4393. return properties[name](component);
  4394. }
  4395. function getFallback(component) {
  4396. return fallback(component);
  4397. }
  4398. module_default.magic("wire", (el, { cleanup: cleanup2 }) => {
  4399. let component;
  4400. return new Proxy({}, {
  4401. get(target, property) {
  4402. if (!component)
  4403. component = closestComponent(el);
  4404. if (["$entangle", "entangle"].includes(property)) {
  4405. return generateEntangleFunction(component, cleanup2);
  4406. }
  4407. return component.$wire[property];
  4408. },
  4409. set(target, property, value) {
  4410. if (!component)
  4411. component = closestComponent(el);
  4412. component.$wire[property] = value;
  4413. return true;
  4414. }
  4415. });
  4416. });
  4417. wireProperty("__instance", (component) => component);
  4418. wireProperty("$get", (component) => (property, reactive3 = true) => dataGet(reactive3 ? component.reactive : component.ephemeral, property));
  4419. wireProperty("$el", (component) => {
  4420. return component.el;
  4421. });
  4422. wireProperty("$id", (component) => {
  4423. return component.id;
  4424. });
  4425. wireProperty("$js", (component) => {
  4426. let fn = component.addJsAction.bind(component);
  4427. let jsActions = component.getJsActions();
  4428. Object.keys(jsActions).forEach((name) => {
  4429. fn[name] = component.getJsAction(name);
  4430. });
  4431. return fn;
  4432. });
  4433. wireProperty("$set", (component) => async (property, value, live = true) => {
  4434. dataSet(component.reactive, property, value);
  4435. if (live) {
  4436. component.queueUpdate(property, value);
  4437. return await requestCommit(component);
  4438. }
  4439. return Promise.resolve();
  4440. });
  4441. wireProperty("$call", (component) => async (method, ...params) => {
  4442. return await component.$wire[method](...params);
  4443. });
  4444. wireProperty("$entangle", (component) => (name, live = false) => {
  4445. return generateEntangleFunction(component)(name, live);
  4446. });
  4447. wireProperty("$toggle", (component) => (name, live = true) => {
  4448. return component.$wire.set(name, !component.$wire.get(name), live);
  4449. });
  4450. wireProperty("$watch", (component) => (path, callback) => {
  4451. let getter = () => {
  4452. return dataGet(component.reactive, path);
  4453. };
  4454. let unwatch = module_default.watch(getter, callback);
  4455. component.addCleanup(unwatch);
  4456. });
  4457. wireProperty("$refresh", (component) => component.$wire.$commit);
  4458. wireProperty("$commit", (component) => async () => await requestCommit(component));
  4459. wireProperty("$on", (component) => (...params) => listen2(component, ...params));
  4460. wireProperty("$hook", (component) => (name, callback) => {
  4461. let unhook = on2(name, ({ component: hookComponent, ...params }) => {
  4462. if (hookComponent === void 0)
  4463. return callback(params);
  4464. if (hookComponent.id === component.id)
  4465. return callback({ component: hookComponent, ...params });
  4466. });
  4467. component.addCleanup(unhook);
  4468. return unhook;
  4469. });
  4470. wireProperty("$dispatch", (component) => (...params) => dispatch3(component, ...params));
  4471. wireProperty("$dispatchSelf", (component) => (...params) => dispatchSelf(component, ...params));
  4472. wireProperty("$dispatchTo", () => (...params) => dispatchTo(...params));
  4473. wireProperty("$upload", (component) => (...params) => upload(component, ...params));
  4474. wireProperty("$uploadMultiple", (component) => (...params) => uploadMultiple(component, ...params));
  4475. wireProperty("$removeUpload", (component) => (...params) => removeUpload(component, ...params));
  4476. wireProperty("$cancelUpload", (component) => (...params) => cancelUpload(component, ...params));
  4477. var parentMemo = /* @__PURE__ */ new WeakMap();
  4478. wireProperty("$parent", (component) => {
  4479. if (parentMemo.has(component))
  4480. return parentMemo.get(component).$wire;
  4481. let parent = component.parent;
  4482. parentMemo.set(component, parent);
  4483. return parent.$wire;
  4484. });
  4485. var overriddenMethods = /* @__PURE__ */ new WeakMap();
  4486. function overrideMethod(component, method, callback) {
  4487. if (!overriddenMethods.has(component)) {
  4488. overriddenMethods.set(component, {});
  4489. }
  4490. let obj = overriddenMethods.get(component);
  4491. obj[method] = callback;
  4492. overriddenMethods.set(component, obj);
  4493. }
  4494. wireFallback((component) => (property) => async (...params) => {
  4495. if (params.length === 1 && params[0] instanceof Event) {
  4496. params = [];
  4497. }
  4498. if (overriddenMethods.has(component)) {
  4499. let overrides = overriddenMethods.get(component);
  4500. if (typeof overrides[property] === "function") {
  4501. return overrides[property](params);
  4502. }
  4503. }
  4504. return await requestCall(component, property, params);
  4505. });
  4506. // js/component.js
  4507. var Component = class {
  4508. constructor(el) {
  4509. if (el.__livewire)
  4510. throw "Component already initialized";
  4511. el.__livewire = this;
  4512. this.el = el;
  4513. this.id = el.getAttribute("wire:id");
  4514. this.__livewireId = this.id;
  4515. this.snapshotEncoded = el.getAttribute("wire:snapshot");
  4516. this.snapshot = JSON.parse(this.snapshotEncoded);
  4517. if (!this.snapshot) {
  4518. throw `Snapshot missing on Livewire component with id: ` + this.id;
  4519. }
  4520. this.name = this.snapshot.memo.name;
  4521. this.effects = JSON.parse(el.getAttribute("wire:effects"));
  4522. this.originalEffects = deepClone(this.effects);
  4523. this.canonical = extractData(deepClone(this.snapshot.data));
  4524. this.ephemeral = extractData(deepClone(this.snapshot.data));
  4525. this.reactive = Alpine.reactive(this.ephemeral);
  4526. this.queuedUpdates = {};
  4527. this.jsActions = {};
  4528. this.$wire = generateWireObject(this, this.reactive);
  4529. this.cleanups = [];
  4530. this.processEffects(this.effects);
  4531. }
  4532. mergeNewSnapshot(snapshotEncoded, effects, updates = {}) {
  4533. let snapshot = JSON.parse(snapshotEncoded);
  4534. let oldCanonical = deepClone(this.canonical);
  4535. let updatedOldCanonical = this.applyUpdates(oldCanonical, updates);
  4536. let newCanonical = extractData(deepClone(snapshot.data));
  4537. let dirty = diff(updatedOldCanonical, newCanonical);
  4538. this.snapshotEncoded = snapshotEncoded;
  4539. this.snapshot = snapshot;
  4540. this.effects = effects;
  4541. this.canonical = extractData(deepClone(snapshot.data));
  4542. let newData = extractData(deepClone(snapshot.data));
  4543. Object.entries(dirty).forEach(([key, value]) => {
  4544. let rootKey = key.split(".")[0];
  4545. this.reactive[rootKey] = newData[rootKey];
  4546. });
  4547. return dirty;
  4548. }
  4549. queueUpdate(propertyName, value) {
  4550. this.queuedUpdates[propertyName] = value;
  4551. }
  4552. mergeQueuedUpdates(diff2) {
  4553. Object.entries(this.queuedUpdates).forEach(([updateKey, updateValue]) => {
  4554. Object.entries(diff2).forEach(([diffKey, diffValue]) => {
  4555. if (diffKey.startsWith(updateValue)) {
  4556. delete diff2[diffKey];
  4557. }
  4558. });
  4559. diff2[updateKey] = updateValue;
  4560. });
  4561. this.queuedUpdates = [];
  4562. return diff2;
  4563. }
  4564. applyUpdates(object, updates) {
  4565. for (let key in updates) {
  4566. dataSet(object, key, updates[key]);
  4567. }
  4568. return object;
  4569. }
  4570. replayUpdate(snapshot, html) {
  4571. let effects = { ...this.effects, html };
  4572. this.mergeNewSnapshot(JSON.stringify(snapshot), effects);
  4573. this.processEffects({ html });
  4574. }
  4575. processEffects(effects) {
  4576. trigger2("effects", this, effects);
  4577. trigger2("effect", {
  4578. component: this,
  4579. effects,
  4580. cleanup: (i) => this.addCleanup(i)
  4581. });
  4582. }
  4583. get children() {
  4584. let meta = this.snapshot.memo;
  4585. let childIds = Object.values(meta.children).map((i) => i[1]);
  4586. return childIds.map((id) => findComponent(id));
  4587. }
  4588. get parent() {
  4589. return closestComponent(this.el.parentElement);
  4590. }
  4591. inscribeSnapshotAndEffectsOnElement() {
  4592. let el = this.el;
  4593. el.setAttribute("wire:snapshot", this.snapshotEncoded);
  4594. let effects = this.originalEffects.listeners ? { listeners: this.originalEffects.listeners } : {};
  4595. if (this.originalEffects.url) {
  4596. effects.url = this.originalEffects.url;
  4597. }
  4598. if (this.originalEffects.scripts) {
  4599. effects.scripts = this.originalEffects.scripts;
  4600. }
  4601. el.setAttribute("wire:effects", JSON.stringify(effects));
  4602. }
  4603. addJsAction(name, action) {
  4604. this.jsActions[name] = action;
  4605. }
  4606. hasJsAction(name) {
  4607. return this.jsActions[name] !== void 0;
  4608. }
  4609. getJsAction(name) {
  4610. return this.jsActions[name].bind(this.$wire);
  4611. }
  4612. getJsActions() {
  4613. return this.jsActions;
  4614. }
  4615. addCleanup(cleanup2) {
  4616. this.cleanups.push(cleanup2);
  4617. }
  4618. cleanup() {
  4619. delete this.el.__livewire;
  4620. while (this.cleanups.length > 0) {
  4621. this.cleanups.pop()();
  4622. }
  4623. }
  4624. };
  4625. // js/store.js
  4626. var components = {};
  4627. function initComponent(el) {
  4628. let component = new Component(el);
  4629. if (components[component.id])
  4630. throw "Component already registered";
  4631. let cleanup2 = (i) => component.addCleanup(i);
  4632. trigger2("component.init", { component, cleanup: cleanup2 });
  4633. components[component.id] = component;
  4634. return component;
  4635. }
  4636. function destroyComponent(id) {
  4637. let component = components[id];
  4638. if (!component)
  4639. return;
  4640. component.cleanup();
  4641. delete components[id];
  4642. }
  4643. function findComponent(id) {
  4644. let component = components[id];
  4645. if (!component)
  4646. throw "Component not found: " + id;
  4647. return component;
  4648. }
  4649. function closestComponent(el, strict = true) {
  4650. let closestRoot2 = Alpine.findClosest(el, (i) => i.__livewire);
  4651. if (!closestRoot2) {
  4652. if (strict)
  4653. throw "Could not find Livewire component in DOM tree";
  4654. return;
  4655. }
  4656. return closestRoot2.__livewire;
  4657. }
  4658. function componentsByName(name) {
  4659. return Object.values(components).filter((component) => {
  4660. return name == component.name;
  4661. });
  4662. }
  4663. function getByName(name) {
  4664. return componentsByName(name).map((i) => i.$wire);
  4665. }
  4666. function find(id) {
  4667. let component = components[id];
  4668. return component && component.$wire;
  4669. }
  4670. function first() {
  4671. return Object.values(components)[0].$wire;
  4672. }
  4673. function all() {
  4674. return Object.values(components);
  4675. }
  4676. // js/events.js
  4677. function dispatch3(component, name, params) {
  4678. dispatchEvent(component.el, name, params);
  4679. }
  4680. function dispatchGlobal(name, params) {
  4681. dispatchEvent(window, name, params);
  4682. }
  4683. function dispatchSelf(component, name, params) {
  4684. dispatchEvent(component.el, name, params, false);
  4685. }
  4686. function dispatchTo(componentName, name, params) {
  4687. let targets = componentsByName(componentName);
  4688. targets.forEach((target) => {
  4689. dispatchEvent(target.el, name, params, false);
  4690. });
  4691. }
  4692. function listen2(component, name, callback) {
  4693. component.el.addEventListener(name, (e) => {
  4694. callback(e.detail);
  4695. });
  4696. }
  4697. function on3(eventName, callback) {
  4698. let handler4 = (e) => {
  4699. if (!e.__livewire)
  4700. return;
  4701. callback(e.detail);
  4702. };
  4703. window.addEventListener(eventName, handler4);
  4704. return () => {
  4705. window.removeEventListener(eventName, handler4);
  4706. };
  4707. }
  4708. function dispatchEvent(target, name, params, bubbles = true) {
  4709. let e = new CustomEvent(name, { bubbles, detail: params });
  4710. e.__livewire = { name, params, receivedBy: [] };
  4711. target.dispatchEvent(e);
  4712. }
  4713. // js/directives.js
  4714. var customDirectiveNames = /* @__PURE__ */ new Set();
  4715. function matchesForLivewireDirective(attributeName) {
  4716. return attributeName.match(new RegExp("wire:"));
  4717. }
  4718. function extractDirective(el, name) {
  4719. let [value, ...modifiers] = name.replace(new RegExp("wire:"), "").split(".");
  4720. return new Directive(value, modifiers, name, el);
  4721. }
  4722. function directive2(name, callback) {
  4723. if (customDirectiveNames.has(name))
  4724. return;
  4725. customDirectiveNames.add(name);
  4726. on2("directive.init", ({ el, component, directive: directive3, cleanup: cleanup2 }) => {
  4727. if (directive3.value === name) {
  4728. callback({
  4729. el,
  4730. directive: directive3,
  4731. component,
  4732. $wire: component.$wire,
  4733. cleanup: cleanup2
  4734. });
  4735. }
  4736. });
  4737. }
  4738. function globalDirective(name, callback) {
  4739. if (customDirectiveNames.has(name))
  4740. return;
  4741. customDirectiveNames.add(name);
  4742. on2("directive.global.init", ({ el, directive: directive3, cleanup: cleanup2 }) => {
  4743. if (directive3.value === name) {
  4744. callback({ el, directive: directive3, cleanup: cleanup2 });
  4745. }
  4746. });
  4747. }
  4748. function getDirectives(el) {
  4749. return new DirectiveManager(el);
  4750. }
  4751. function customDirectiveHasBeenRegistered(name) {
  4752. return customDirectiveNames.has(name);
  4753. }
  4754. var DirectiveManager = class {
  4755. constructor(el) {
  4756. this.el = el;
  4757. this.directives = this.extractTypeModifiersAndValue();
  4758. }
  4759. all() {
  4760. return this.directives;
  4761. }
  4762. has(value) {
  4763. return this.directives.map((directive3) => directive3.value).includes(value);
  4764. }
  4765. missing(value) {
  4766. return !this.has(value);
  4767. }
  4768. get(value) {
  4769. return this.directives.find((directive3) => directive3.value === value);
  4770. }
  4771. extractTypeModifiersAndValue() {
  4772. return Array.from(this.el.getAttributeNames().filter((name) => matchesForLivewireDirective(name)).map((name) => extractDirective(this.el, name)));
  4773. }
  4774. };
  4775. var Directive = class {
  4776. constructor(value, modifiers, rawName, el) {
  4777. this.rawName = this.raw = rawName;
  4778. this.el = el;
  4779. this.eventContext;
  4780. this.value = value;
  4781. this.modifiers = modifiers;
  4782. this.expression = this.el.getAttribute(this.rawName);
  4783. }
  4784. get method() {
  4785. const { method } = this.parseOutMethodAndParams(this.expression);
  4786. return method;
  4787. }
  4788. get params() {
  4789. const { params } = this.parseOutMethodAndParams(this.expression);
  4790. return params;
  4791. }
  4792. parseOutMethodAndParams(rawMethod) {
  4793. let method = rawMethod;
  4794. let params = [];
  4795. const methodAndParamString = method.match(/(.*?)\((.*)\)/s);
  4796. if (methodAndParamString) {
  4797. method = methodAndParamString[1];
  4798. let func = new Function("$event", `return (function () {
  4799. for (var l=arguments.length, p=new Array(l), k=0; k<l; k++) {
  4800. p[k] = arguments[k];
  4801. }
  4802. return [].concat(p);
  4803. })(${methodAndParamString[2]})`);
  4804. params = func(this.eventContext);
  4805. }
  4806. return { method, params };
  4807. }
  4808. };
  4809. // ../alpine/packages/collapse/dist/module.esm.js
  4810. function src_default2(Alpine3) {
  4811. Alpine3.directive("collapse", collapse);
  4812. collapse.inline = (el, { modifiers }) => {
  4813. if (!modifiers.includes("min"))
  4814. return;
  4815. el._x_doShow = () => {
  4816. };
  4817. el._x_doHide = () => {
  4818. };
  4819. };
  4820. function collapse(el, { modifiers }) {
  4821. let duration = modifierValue2(modifiers, "duration", 250) / 1e3;
  4822. let floor2 = modifierValue2(modifiers, "min", 0);
  4823. let fullyHide = !modifiers.includes("min");
  4824. if (!el._x_isShown)
  4825. el.style.height = `${floor2}px`;
  4826. if (!el._x_isShown && fullyHide)
  4827. el.hidden = true;
  4828. if (!el._x_isShown)
  4829. el.style.overflow = "hidden";
  4830. let setFunction = (el2, styles) => {
  4831. let revertFunction = Alpine3.setStyles(el2, styles);
  4832. return styles.height ? () => {
  4833. } : revertFunction;
  4834. };
  4835. let transitionStyles = {
  4836. transitionProperty: "height",
  4837. transitionDuration: `${duration}s`,
  4838. transitionTimingFunction: "cubic-bezier(0.4, 0.0, 0.2, 1)"
  4839. };
  4840. el._x_transition = {
  4841. in(before = () => {
  4842. }, after = () => {
  4843. }) {
  4844. if (fullyHide)
  4845. el.hidden = false;
  4846. if (fullyHide)
  4847. el.style.display = null;
  4848. let current = el.getBoundingClientRect().height;
  4849. el.style.height = "auto";
  4850. let full = el.getBoundingClientRect().height;
  4851. if (current === full) {
  4852. current = floor2;
  4853. }
  4854. Alpine3.transition(el, Alpine3.setStyles, {
  4855. during: transitionStyles,
  4856. start: { height: current + "px" },
  4857. end: { height: full + "px" }
  4858. }, () => el._x_isShown = true, () => {
  4859. if (Math.abs(el.getBoundingClientRect().height - full) < 1) {
  4860. el.style.overflow = null;
  4861. }
  4862. });
  4863. },
  4864. out(before = () => {
  4865. }, after = () => {
  4866. }) {
  4867. let full = el.getBoundingClientRect().height;
  4868. Alpine3.transition(el, setFunction, {
  4869. during: transitionStyles,
  4870. start: { height: full + "px" },
  4871. end: { height: floor2 + "px" }
  4872. }, () => el.style.overflow = "hidden", () => {
  4873. el._x_isShown = false;
  4874. if (el.style.height == `${floor2}px` && fullyHide) {
  4875. el.style.display = "none";
  4876. el.hidden = true;
  4877. }
  4878. });
  4879. }
  4880. };
  4881. }
  4882. }
  4883. function modifierValue2(modifiers, key, fallback2) {
  4884. if (modifiers.indexOf(key) === -1)
  4885. return fallback2;
  4886. const rawValue = modifiers[modifiers.indexOf(key) + 1];
  4887. if (!rawValue)
  4888. return fallback2;
  4889. if (key === "duration") {
  4890. let match = rawValue.match(/([0-9]+)ms/);
  4891. if (match)
  4892. return match[1];
  4893. }
  4894. if (key === "min") {
  4895. let match = rawValue.match(/([0-9]+)px/);
  4896. if (match)
  4897. return match[1];
  4898. }
  4899. return rawValue;
  4900. }
  4901. var module_default2 = src_default2;
  4902. // ../alpine/packages/focus/dist/module.esm.js
  4903. var candidateSelectors = ["input", "select", "textarea", "a[href]", "button", "[tabindex]:not(slot)", "audio[controls]", "video[controls]", '[contenteditable]:not([contenteditable="false"])', "details>summary:first-of-type", "details"];
  4904. var candidateSelector = /* @__PURE__ */ candidateSelectors.join(",");
  4905. var NoElement = typeof Element === "undefined";
  4906. var matches = NoElement ? function() {
  4907. } : Element.prototype.matches || Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector;
  4908. var getRootNode = !NoElement && Element.prototype.getRootNode ? function(element) {
  4909. return element.getRootNode();
  4910. } : function(element) {
  4911. return element.ownerDocument;
  4912. };
  4913. var getCandidates = function getCandidates2(el, includeContainer, filter) {
  4914. var candidates = Array.prototype.slice.apply(el.querySelectorAll(candidateSelector));
  4915. if (includeContainer && matches.call(el, candidateSelector)) {
  4916. candidates.unshift(el);
  4917. }
  4918. candidates = candidates.filter(filter);
  4919. return candidates;
  4920. };
  4921. var getCandidatesIteratively = function getCandidatesIteratively2(elements, includeContainer, options) {
  4922. var candidates = [];
  4923. var elementsToCheck = Array.from(elements);
  4924. while (elementsToCheck.length) {
  4925. var element = elementsToCheck.shift();
  4926. if (element.tagName === "SLOT") {
  4927. var assigned = element.assignedElements();
  4928. var content = assigned.length ? assigned : element.children;
  4929. var nestedCandidates = getCandidatesIteratively2(content, true, options);
  4930. if (options.flatten) {
  4931. candidates.push.apply(candidates, nestedCandidates);
  4932. } else {
  4933. candidates.push({
  4934. scope: element,
  4935. candidates: nestedCandidates
  4936. });
  4937. }
  4938. } else {
  4939. var validCandidate = matches.call(element, candidateSelector);
  4940. if (validCandidate && options.filter(element) && (includeContainer || !elements.includes(element))) {
  4941. candidates.push(element);
  4942. }
  4943. var shadowRoot = element.shadowRoot || typeof options.getShadowRoot === "function" && options.getShadowRoot(element);
  4944. var validShadowRoot = !options.shadowRootFilter || options.shadowRootFilter(element);
  4945. if (shadowRoot && validShadowRoot) {
  4946. var _nestedCandidates = getCandidatesIteratively2(shadowRoot === true ? element.children : shadowRoot.children, true, options);
  4947. if (options.flatten) {
  4948. candidates.push.apply(candidates, _nestedCandidates);
  4949. } else {
  4950. candidates.push({
  4951. scope: element,
  4952. candidates: _nestedCandidates
  4953. });
  4954. }
  4955. } else {
  4956. elementsToCheck.unshift.apply(elementsToCheck, element.children);
  4957. }
  4958. }
  4959. }
  4960. return candidates;
  4961. };
  4962. var getTabindex = function getTabindex2(node, isScope) {
  4963. if (node.tabIndex < 0) {
  4964. if ((isScope || /^(AUDIO|VIDEO|DETAILS)$/.test(node.tagName) || node.isContentEditable) && isNaN(parseInt(node.getAttribute("tabindex"), 10))) {
  4965. return 0;
  4966. }
  4967. }
  4968. return node.tabIndex;
  4969. };
  4970. var sortOrderedTabbables = function sortOrderedTabbables2(a, b) {
  4971. return a.tabIndex === b.tabIndex ? a.documentOrder - b.documentOrder : a.tabIndex - b.tabIndex;
  4972. };
  4973. var isInput = function isInput2(node) {
  4974. return node.tagName === "INPUT";
  4975. };
  4976. var isHiddenInput = function isHiddenInput2(node) {
  4977. return isInput(node) && node.type === "hidden";
  4978. };
  4979. var isDetailsWithSummary = function isDetailsWithSummary2(node) {
  4980. var r = node.tagName === "DETAILS" && Array.prototype.slice.apply(node.children).some(function(child) {
  4981. return child.tagName === "SUMMARY";
  4982. });
  4983. return r;
  4984. };
  4985. var getCheckedRadio = function getCheckedRadio2(nodes, form) {
  4986. for (var i = 0; i < nodes.length; i++) {
  4987. if (nodes[i].checked && nodes[i].form === form) {
  4988. return nodes[i];
  4989. }
  4990. }
  4991. };
  4992. var isTabbableRadio = function isTabbableRadio2(node) {
  4993. if (!node.name) {
  4994. return true;
  4995. }
  4996. var radioScope = node.form || getRootNode(node);
  4997. var queryRadios = function queryRadios2(name) {
  4998. return radioScope.querySelectorAll('input[type="radio"][name="' + name + '"]');
  4999. };
  5000. var radioSet;
  5001. if (typeof window !== "undefined" && typeof window.CSS !== "undefined" && typeof window.CSS.escape === "function") {
  5002. radioSet = queryRadios(window.CSS.escape(node.name));
  5003. } else {
  5004. try {
  5005. radioSet = queryRadios(node.name);
  5006. } catch (err) {
  5007. console.error("Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s", err.message);
  5008. return false;
  5009. }
  5010. }
  5011. var checked = getCheckedRadio(radioSet, node.form);
  5012. return !checked || checked === node;
  5013. };
  5014. var isRadio2 = function isRadio22(node) {
  5015. return isInput(node) && node.type === "radio";
  5016. };
  5017. var isNonTabbableRadio = function isNonTabbableRadio2(node) {
  5018. return isRadio2(node) && !isTabbableRadio(node);
  5019. };
  5020. var isZeroArea = function isZeroArea2(node) {
  5021. var _node$getBoundingClie = node.getBoundingClientRect(), width = _node$getBoundingClie.width, height = _node$getBoundingClie.height;
  5022. return width === 0 && height === 0;
  5023. };
  5024. var isHidden = function isHidden2(node, _ref) {
  5025. var displayCheck = _ref.displayCheck, getShadowRoot = _ref.getShadowRoot;
  5026. if (getComputedStyle(node).visibility === "hidden") {
  5027. return true;
  5028. }
  5029. var isDirectSummary = matches.call(node, "details>summary:first-of-type");
  5030. var nodeUnderDetails = isDirectSummary ? node.parentElement : node;
  5031. if (matches.call(nodeUnderDetails, "details:not([open]) *")) {
  5032. return true;
  5033. }
  5034. var nodeRootHost = getRootNode(node).host;
  5035. var nodeIsAttached = (nodeRootHost === null || nodeRootHost === void 0 ? void 0 : nodeRootHost.ownerDocument.contains(nodeRootHost)) || node.ownerDocument.contains(node);
  5036. if (!displayCheck || displayCheck === "full") {
  5037. if (typeof getShadowRoot === "function") {
  5038. var originalNode = node;
  5039. while (node) {
  5040. var parentElement = node.parentElement;
  5041. var rootNode = getRootNode(node);
  5042. if (parentElement && !parentElement.shadowRoot && getShadowRoot(parentElement) === true) {
  5043. return isZeroArea(node);
  5044. } else if (node.assignedSlot) {
  5045. node = node.assignedSlot;
  5046. } else if (!parentElement && rootNode !== node.ownerDocument) {
  5047. node = rootNode.host;
  5048. } else {
  5049. node = parentElement;
  5050. }
  5051. }
  5052. node = originalNode;
  5053. }
  5054. if (nodeIsAttached) {
  5055. return !node.getClientRects().length;
  5056. }
  5057. } else if (displayCheck === "non-zero-area") {
  5058. return isZeroArea(node);
  5059. }
  5060. return false;
  5061. };
  5062. var isDisabledFromFieldset = function isDisabledFromFieldset2(node) {
  5063. if (/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(node.tagName)) {
  5064. var parentNode = node.parentElement;
  5065. while (parentNode) {
  5066. if (parentNode.tagName === "FIELDSET" && parentNode.disabled) {
  5067. for (var i = 0; i < parentNode.children.length; i++) {
  5068. var child = parentNode.children.item(i);
  5069. if (child.tagName === "LEGEND") {
  5070. return matches.call(parentNode, "fieldset[disabled] *") ? true : !child.contains(node);
  5071. }
  5072. }
  5073. return true;
  5074. }
  5075. parentNode = parentNode.parentElement;
  5076. }
  5077. }
  5078. return false;
  5079. };
  5080. var isNodeMatchingSelectorFocusable = function isNodeMatchingSelectorFocusable2(options, node) {
  5081. if (node.disabled || isHiddenInput(node) || isHidden(node, options) || isDetailsWithSummary(node) || isDisabledFromFieldset(node)) {
  5082. return false;
  5083. }
  5084. return true;
  5085. };
  5086. var isNodeMatchingSelectorTabbable = function isNodeMatchingSelectorTabbable2(options, node) {
  5087. if (isNonTabbableRadio(node) || getTabindex(node) < 0 || !isNodeMatchingSelectorFocusable(options, node)) {
  5088. return false;
  5089. }
  5090. return true;
  5091. };
  5092. var isValidShadowRootTabbable = function isValidShadowRootTabbable2(shadowHostNode) {
  5093. var tabIndex = parseInt(shadowHostNode.getAttribute("tabindex"), 10);
  5094. if (isNaN(tabIndex) || tabIndex >= 0) {
  5095. return true;
  5096. }
  5097. return false;
  5098. };
  5099. var sortByOrder = function sortByOrder2(candidates) {
  5100. var regularTabbables = [];
  5101. var orderedTabbables = [];
  5102. candidates.forEach(function(item, i) {
  5103. var isScope = !!item.scope;
  5104. var element = isScope ? item.scope : item;
  5105. var candidateTabindex = getTabindex(element, isScope);
  5106. var elements = isScope ? sortByOrder2(item.candidates) : element;
  5107. if (candidateTabindex === 0) {
  5108. isScope ? regularTabbables.push.apply(regularTabbables, elements) : regularTabbables.push(element);
  5109. } else {
  5110. orderedTabbables.push({
  5111. documentOrder: i,
  5112. tabIndex: candidateTabindex,
  5113. item,
  5114. isScope,
  5115. content: elements
  5116. });
  5117. }
  5118. });
  5119. return orderedTabbables.sort(sortOrderedTabbables).reduce(function(acc, sortable) {
  5120. sortable.isScope ? acc.push.apply(acc, sortable.content) : acc.push(sortable.content);
  5121. return acc;
  5122. }, []).concat(regularTabbables);
  5123. };
  5124. var tabbable = function tabbable2(el, options) {
  5125. options = options || {};
  5126. var candidates;
  5127. if (options.getShadowRoot) {
  5128. candidates = getCandidatesIteratively([el], options.includeContainer, {
  5129. filter: isNodeMatchingSelectorTabbable.bind(null, options),
  5130. flatten: false,
  5131. getShadowRoot: options.getShadowRoot,
  5132. shadowRootFilter: isValidShadowRootTabbable
  5133. });
  5134. } else {
  5135. candidates = getCandidates(el, options.includeContainer, isNodeMatchingSelectorTabbable.bind(null, options));
  5136. }
  5137. return sortByOrder(candidates);
  5138. };
  5139. var focusable = function focusable2(el, options) {
  5140. options = options || {};
  5141. var candidates;
  5142. if (options.getShadowRoot) {
  5143. candidates = getCandidatesIteratively([el], options.includeContainer, {
  5144. filter: isNodeMatchingSelectorFocusable.bind(null, options),
  5145. flatten: true,
  5146. getShadowRoot: options.getShadowRoot
  5147. });
  5148. } else {
  5149. candidates = getCandidates(el, options.includeContainer, isNodeMatchingSelectorFocusable.bind(null, options));
  5150. }
  5151. return candidates;
  5152. };
  5153. var isTabbable = function isTabbable2(node, options) {
  5154. options = options || {};
  5155. if (!node) {
  5156. throw new Error("No node provided");
  5157. }
  5158. if (matches.call(node, candidateSelector) === false) {
  5159. return false;
  5160. }
  5161. return isNodeMatchingSelectorTabbable(options, node);
  5162. };
  5163. var focusableCandidateSelector = /* @__PURE__ */ candidateSelectors.concat("iframe").join(",");
  5164. var isFocusable = function isFocusable2(node, options) {
  5165. options = options || {};
  5166. if (!node) {
  5167. throw new Error("No node provided");
  5168. }
  5169. if (matches.call(node, focusableCandidateSelector) === false) {
  5170. return false;
  5171. }
  5172. return isNodeMatchingSelectorFocusable(options, node);
  5173. };
  5174. function ownKeys2(object, enumerableOnly) {
  5175. var keys = Object.keys(object);
  5176. if (Object.getOwnPropertySymbols) {
  5177. var symbols = Object.getOwnPropertySymbols(object);
  5178. enumerableOnly && (symbols = symbols.filter(function(sym) {
  5179. return Object.getOwnPropertyDescriptor(object, sym).enumerable;
  5180. })), keys.push.apply(keys, symbols);
  5181. }
  5182. return keys;
  5183. }
  5184. function _objectSpread2(target) {
  5185. for (var i = 1; i < arguments.length; i++) {
  5186. var source = null != arguments[i] ? arguments[i] : {};
  5187. i % 2 ? ownKeys2(Object(source), true).forEach(function(key) {
  5188. _defineProperty(target, key, source[key]);
  5189. }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys2(Object(source)).forEach(function(key) {
  5190. Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
  5191. });
  5192. }
  5193. return target;
  5194. }
  5195. function _defineProperty(obj, key, value) {
  5196. if (key in obj) {
  5197. Object.defineProperty(obj, key, {
  5198. value,
  5199. enumerable: true,
  5200. configurable: true,
  5201. writable: true
  5202. });
  5203. } else {
  5204. obj[key] = value;
  5205. }
  5206. return obj;
  5207. }
  5208. var activeFocusTraps = function() {
  5209. var trapQueue = [];
  5210. return {
  5211. activateTrap: function activateTrap(trap) {
  5212. if (trapQueue.length > 0) {
  5213. var activeTrap = trapQueue[trapQueue.length - 1];
  5214. if (activeTrap !== trap) {
  5215. activeTrap.pause();
  5216. }
  5217. }
  5218. var trapIndex = trapQueue.indexOf(trap);
  5219. if (trapIndex === -1) {
  5220. trapQueue.push(trap);
  5221. } else {
  5222. trapQueue.splice(trapIndex, 1);
  5223. trapQueue.push(trap);
  5224. }
  5225. },
  5226. deactivateTrap: function deactivateTrap(trap) {
  5227. var trapIndex = trapQueue.indexOf(trap);
  5228. if (trapIndex !== -1) {
  5229. trapQueue.splice(trapIndex, 1);
  5230. }
  5231. if (trapQueue.length > 0) {
  5232. trapQueue[trapQueue.length - 1].unpause();
  5233. }
  5234. }
  5235. };
  5236. }();
  5237. var isSelectableInput = function isSelectableInput2(node) {
  5238. return node.tagName && node.tagName.toLowerCase() === "input" && typeof node.select === "function";
  5239. };
  5240. var isEscapeEvent = function isEscapeEvent2(e) {
  5241. return e.key === "Escape" || e.key === "Esc" || e.keyCode === 27;
  5242. };
  5243. var isTabEvent = function isTabEvent2(e) {
  5244. return e.key === "Tab" || e.keyCode === 9;
  5245. };
  5246. var delay = function delay2(fn) {
  5247. return setTimeout(fn, 0);
  5248. };
  5249. var findIndex = function findIndex2(arr, fn) {
  5250. var idx = -1;
  5251. arr.every(function(value, i) {
  5252. if (fn(value)) {
  5253. idx = i;
  5254. return false;
  5255. }
  5256. return true;
  5257. });
  5258. return idx;
  5259. };
  5260. var valueOrHandler = function valueOrHandler2(value) {
  5261. for (var _len = arguments.length, params = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  5262. params[_key - 1] = arguments[_key];
  5263. }
  5264. return typeof value === "function" ? value.apply(void 0, params) : value;
  5265. };
  5266. var getActualTarget = function getActualTarget2(event) {
  5267. return event.target.shadowRoot && typeof event.composedPath === "function" ? event.composedPath()[0] : event.target;
  5268. };
  5269. var createFocusTrap = function createFocusTrap2(elements, userOptions) {
  5270. var doc = (userOptions === null || userOptions === void 0 ? void 0 : userOptions.document) || document;
  5271. var config = _objectSpread2({
  5272. returnFocusOnDeactivate: true,
  5273. escapeDeactivates: true,
  5274. delayInitialFocus: true
  5275. }, userOptions);
  5276. var state = {
  5277. containers: [],
  5278. containerGroups: [],
  5279. tabbableGroups: [],
  5280. nodeFocusedBeforeActivation: null,
  5281. mostRecentlyFocusedNode: null,
  5282. active: false,
  5283. paused: false,
  5284. delayInitialFocusTimer: void 0
  5285. };
  5286. var trap;
  5287. var getOption = function getOption2(configOverrideOptions, optionName, configOptionName) {
  5288. return configOverrideOptions && configOverrideOptions[optionName] !== void 0 ? configOverrideOptions[optionName] : config[configOptionName || optionName];
  5289. };
  5290. var findContainerIndex = function findContainerIndex2(element) {
  5291. return state.containerGroups.findIndex(function(_ref) {
  5292. var container = _ref.container, tabbableNodes = _ref.tabbableNodes;
  5293. return container.contains(element) || tabbableNodes.find(function(node) {
  5294. return node === element;
  5295. });
  5296. });
  5297. };
  5298. var getNodeForOption = function getNodeForOption2(optionName) {
  5299. var optionValue = config[optionName];
  5300. if (typeof optionValue === "function") {
  5301. for (var _len2 = arguments.length, params = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
  5302. params[_key2 - 1] = arguments[_key2];
  5303. }
  5304. optionValue = optionValue.apply(void 0, params);
  5305. }
  5306. if (optionValue === true) {
  5307. optionValue = void 0;
  5308. }
  5309. if (!optionValue) {
  5310. if (optionValue === void 0 || optionValue === false) {
  5311. return optionValue;
  5312. }
  5313. throw new Error("`".concat(optionName, "` was specified but was not a node, or did not return a node"));
  5314. }
  5315. var node = optionValue;
  5316. if (typeof optionValue === "string") {
  5317. node = doc.querySelector(optionValue);
  5318. if (!node) {
  5319. throw new Error("`".concat(optionName, "` as selector refers to no known node"));
  5320. }
  5321. }
  5322. return node;
  5323. };
  5324. var getInitialFocusNode = function getInitialFocusNode2() {
  5325. var node = getNodeForOption("initialFocus");
  5326. if (node === false) {
  5327. return false;
  5328. }
  5329. if (node === void 0) {
  5330. if (findContainerIndex(doc.activeElement) >= 0) {
  5331. node = doc.activeElement;
  5332. } else {
  5333. var firstTabbableGroup = state.tabbableGroups[0];
  5334. var firstTabbableNode = firstTabbableGroup && firstTabbableGroup.firstTabbableNode;
  5335. node = firstTabbableNode || getNodeForOption("fallbackFocus");
  5336. }
  5337. }
  5338. if (!node) {
  5339. throw new Error("Your focus-trap needs to have at least one focusable element");
  5340. }
  5341. return node;
  5342. };
  5343. var updateTabbableNodes = function updateTabbableNodes2() {
  5344. state.containerGroups = state.containers.map(function(container) {
  5345. var tabbableNodes = tabbable(container, config.tabbableOptions);
  5346. var focusableNodes = focusable(container, config.tabbableOptions);
  5347. return {
  5348. container,
  5349. tabbableNodes,
  5350. focusableNodes,
  5351. firstTabbableNode: tabbableNodes.length > 0 ? tabbableNodes[0] : null,
  5352. lastTabbableNode: tabbableNodes.length > 0 ? tabbableNodes[tabbableNodes.length - 1] : null,
  5353. nextTabbableNode: function nextTabbableNode(node) {
  5354. var forward = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : true;
  5355. var nodeIdx = focusableNodes.findIndex(function(n) {
  5356. return n === node;
  5357. });
  5358. if (nodeIdx < 0) {
  5359. return void 0;
  5360. }
  5361. if (forward) {
  5362. return focusableNodes.slice(nodeIdx + 1).find(function(n) {
  5363. return isTabbable(n, config.tabbableOptions);
  5364. });
  5365. }
  5366. return focusableNodes.slice(0, nodeIdx).reverse().find(function(n) {
  5367. return isTabbable(n, config.tabbableOptions);
  5368. });
  5369. }
  5370. };
  5371. });
  5372. state.tabbableGroups = state.containerGroups.filter(function(group) {
  5373. return group.tabbableNodes.length > 0;
  5374. });
  5375. if (state.tabbableGroups.length <= 0 && !getNodeForOption("fallbackFocus")) {
  5376. throw new Error("Your focus-trap must have at least one container with at least one tabbable node in it at all times");
  5377. }
  5378. };
  5379. var tryFocus = function tryFocus2(node) {
  5380. if (node === false) {
  5381. return;
  5382. }
  5383. if (node === doc.activeElement) {
  5384. return;
  5385. }
  5386. if (!node || !node.focus) {
  5387. tryFocus2(getInitialFocusNode());
  5388. return;
  5389. }
  5390. node.focus({
  5391. preventScroll: !!config.preventScroll
  5392. });
  5393. state.mostRecentlyFocusedNode = node;
  5394. if (isSelectableInput(node)) {
  5395. node.select();
  5396. }
  5397. };
  5398. var getReturnFocusNode = function getReturnFocusNode2(previousActiveElement) {
  5399. var node = getNodeForOption("setReturnFocus", previousActiveElement);
  5400. return node ? node : node === false ? false : previousActiveElement;
  5401. };
  5402. var checkPointerDown = function checkPointerDown2(e) {
  5403. var target = getActualTarget(e);
  5404. if (findContainerIndex(target) >= 0) {
  5405. return;
  5406. }
  5407. if (valueOrHandler(config.clickOutsideDeactivates, e)) {
  5408. trap.deactivate({
  5409. returnFocus: config.returnFocusOnDeactivate && !isFocusable(target, config.tabbableOptions)
  5410. });
  5411. return;
  5412. }
  5413. if (valueOrHandler(config.allowOutsideClick, e)) {
  5414. return;
  5415. }
  5416. e.preventDefault();
  5417. };
  5418. var checkFocusIn = function checkFocusIn2(e) {
  5419. var target = getActualTarget(e);
  5420. var targetContained = findContainerIndex(target) >= 0;
  5421. if (targetContained || target instanceof Document) {
  5422. if (targetContained) {
  5423. state.mostRecentlyFocusedNode = target;
  5424. }
  5425. } else {
  5426. e.stopImmediatePropagation();
  5427. tryFocus(state.mostRecentlyFocusedNode || getInitialFocusNode());
  5428. }
  5429. };
  5430. var checkTab = function checkTab2(e) {
  5431. var target = getActualTarget(e);
  5432. updateTabbableNodes();
  5433. var destinationNode = null;
  5434. if (state.tabbableGroups.length > 0) {
  5435. var containerIndex = findContainerIndex(target);
  5436. var containerGroup = containerIndex >= 0 ? state.containerGroups[containerIndex] : void 0;
  5437. if (containerIndex < 0) {
  5438. if (e.shiftKey) {
  5439. destinationNode = state.tabbableGroups[state.tabbableGroups.length - 1].lastTabbableNode;
  5440. } else {
  5441. destinationNode = state.tabbableGroups[0].firstTabbableNode;
  5442. }
  5443. } else if (e.shiftKey) {
  5444. var startOfGroupIndex = findIndex(state.tabbableGroups, function(_ref2) {
  5445. var firstTabbableNode = _ref2.firstTabbableNode;
  5446. return target === firstTabbableNode;
  5447. });
  5448. if (startOfGroupIndex < 0 && (containerGroup.container === target || isFocusable(target, config.tabbableOptions) && !isTabbable(target, config.tabbableOptions) && !containerGroup.nextTabbableNode(target, false))) {
  5449. startOfGroupIndex = containerIndex;
  5450. }
  5451. if (startOfGroupIndex >= 0) {
  5452. var destinationGroupIndex = startOfGroupIndex === 0 ? state.tabbableGroups.length - 1 : startOfGroupIndex - 1;
  5453. var destinationGroup = state.tabbableGroups[destinationGroupIndex];
  5454. destinationNode = destinationGroup.lastTabbableNode;
  5455. }
  5456. } else {
  5457. var lastOfGroupIndex = findIndex(state.tabbableGroups, function(_ref3) {
  5458. var lastTabbableNode = _ref3.lastTabbableNode;
  5459. return target === lastTabbableNode;
  5460. });
  5461. if (lastOfGroupIndex < 0 && (containerGroup.container === target || isFocusable(target, config.tabbableOptions) && !isTabbable(target, config.tabbableOptions) && !containerGroup.nextTabbableNode(target))) {
  5462. lastOfGroupIndex = containerIndex;
  5463. }
  5464. if (lastOfGroupIndex >= 0) {
  5465. var _destinationGroupIndex = lastOfGroupIndex === state.tabbableGroups.length - 1 ? 0 : lastOfGroupIndex + 1;
  5466. var _destinationGroup = state.tabbableGroups[_destinationGroupIndex];
  5467. destinationNode = _destinationGroup.firstTabbableNode;
  5468. }
  5469. }
  5470. } else {
  5471. destinationNode = getNodeForOption("fallbackFocus");
  5472. }
  5473. if (destinationNode) {
  5474. e.preventDefault();
  5475. tryFocus(destinationNode);
  5476. }
  5477. };
  5478. var checkKey = function checkKey2(e) {
  5479. if (isEscapeEvent(e) && valueOrHandler(config.escapeDeactivates, e) !== false) {
  5480. e.preventDefault();
  5481. trap.deactivate();
  5482. return;
  5483. }
  5484. if (isTabEvent(e)) {
  5485. checkTab(e);
  5486. return;
  5487. }
  5488. };
  5489. var checkClick = function checkClick2(e) {
  5490. var target = getActualTarget(e);
  5491. if (findContainerIndex(target) >= 0) {
  5492. return;
  5493. }
  5494. if (valueOrHandler(config.clickOutsideDeactivates, e)) {
  5495. return;
  5496. }
  5497. if (valueOrHandler(config.allowOutsideClick, e)) {
  5498. return;
  5499. }
  5500. e.preventDefault();
  5501. e.stopImmediatePropagation();
  5502. };
  5503. var addListeners = function addListeners2() {
  5504. if (!state.active) {
  5505. return;
  5506. }
  5507. activeFocusTraps.activateTrap(trap);
  5508. state.delayInitialFocusTimer = config.delayInitialFocus ? delay(function() {
  5509. tryFocus(getInitialFocusNode());
  5510. }) : tryFocus(getInitialFocusNode());
  5511. doc.addEventListener("focusin", checkFocusIn, true);
  5512. doc.addEventListener("mousedown", checkPointerDown, {
  5513. capture: true,
  5514. passive: false
  5515. });
  5516. doc.addEventListener("touchstart", checkPointerDown, {
  5517. capture: true,
  5518. passive: false
  5519. });
  5520. doc.addEventListener("click", checkClick, {
  5521. capture: true,
  5522. passive: false
  5523. });
  5524. doc.addEventListener("keydown", checkKey, {
  5525. capture: true,
  5526. passive: false
  5527. });
  5528. return trap;
  5529. };
  5530. var removeListeners = function removeListeners2() {
  5531. if (!state.active) {
  5532. return;
  5533. }
  5534. doc.removeEventListener("focusin", checkFocusIn, true);
  5535. doc.removeEventListener("mousedown", checkPointerDown, true);
  5536. doc.removeEventListener("touchstart", checkPointerDown, true);
  5537. doc.removeEventListener("click", checkClick, true);
  5538. doc.removeEventListener("keydown", checkKey, true);
  5539. return trap;
  5540. };
  5541. trap = {
  5542. get active() {
  5543. return state.active;
  5544. },
  5545. get paused() {
  5546. return state.paused;
  5547. },
  5548. activate: function activate(activateOptions) {
  5549. if (state.active) {
  5550. return this;
  5551. }
  5552. var onActivate = getOption(activateOptions, "onActivate");
  5553. var onPostActivate = getOption(activateOptions, "onPostActivate");
  5554. var checkCanFocusTrap = getOption(activateOptions, "checkCanFocusTrap");
  5555. if (!checkCanFocusTrap) {
  5556. updateTabbableNodes();
  5557. }
  5558. state.active = true;
  5559. state.paused = false;
  5560. state.nodeFocusedBeforeActivation = doc.activeElement;
  5561. if (onActivate) {
  5562. onActivate();
  5563. }
  5564. var finishActivation = function finishActivation2() {
  5565. if (checkCanFocusTrap) {
  5566. updateTabbableNodes();
  5567. }
  5568. addListeners();
  5569. if (onPostActivate) {
  5570. onPostActivate();
  5571. }
  5572. };
  5573. if (checkCanFocusTrap) {
  5574. checkCanFocusTrap(state.containers.concat()).then(finishActivation, finishActivation);
  5575. return this;
  5576. }
  5577. finishActivation();
  5578. return this;
  5579. },
  5580. deactivate: function deactivate(deactivateOptions) {
  5581. if (!state.active) {
  5582. return this;
  5583. }
  5584. var options = _objectSpread2({
  5585. onDeactivate: config.onDeactivate,
  5586. onPostDeactivate: config.onPostDeactivate,
  5587. checkCanReturnFocus: config.checkCanReturnFocus
  5588. }, deactivateOptions);
  5589. clearTimeout(state.delayInitialFocusTimer);
  5590. state.delayInitialFocusTimer = void 0;
  5591. removeListeners();
  5592. state.active = false;
  5593. state.paused = false;
  5594. activeFocusTraps.deactivateTrap(trap);
  5595. var onDeactivate = getOption(options, "onDeactivate");
  5596. var onPostDeactivate = getOption(options, "onPostDeactivate");
  5597. var checkCanReturnFocus = getOption(options, "checkCanReturnFocus");
  5598. var returnFocus = getOption(options, "returnFocus", "returnFocusOnDeactivate");
  5599. if (onDeactivate) {
  5600. onDeactivate();
  5601. }
  5602. var finishDeactivation = function finishDeactivation2() {
  5603. delay(function() {
  5604. if (returnFocus) {
  5605. tryFocus(getReturnFocusNode(state.nodeFocusedBeforeActivation));
  5606. }
  5607. if (onPostDeactivate) {
  5608. onPostDeactivate();
  5609. }
  5610. });
  5611. };
  5612. if (returnFocus && checkCanReturnFocus) {
  5613. checkCanReturnFocus(getReturnFocusNode(state.nodeFocusedBeforeActivation)).then(finishDeactivation, finishDeactivation);
  5614. return this;
  5615. }
  5616. finishDeactivation();
  5617. return this;
  5618. },
  5619. pause: function pause() {
  5620. if (state.paused || !state.active) {
  5621. return this;
  5622. }
  5623. state.paused = true;
  5624. removeListeners();
  5625. return this;
  5626. },
  5627. unpause: function unpause() {
  5628. if (!state.paused || !state.active) {
  5629. return this;
  5630. }
  5631. state.paused = false;
  5632. updateTabbableNodes();
  5633. addListeners();
  5634. return this;
  5635. },
  5636. updateContainerElements: function updateContainerElements(containerElements) {
  5637. var elementsAsArray = [].concat(containerElements).filter(Boolean);
  5638. state.containers = elementsAsArray.map(function(element) {
  5639. return typeof element === "string" ? doc.querySelector(element) : element;
  5640. });
  5641. if (state.active) {
  5642. updateTabbableNodes();
  5643. }
  5644. return this;
  5645. }
  5646. };
  5647. trap.updateContainerElements(elements);
  5648. return trap;
  5649. };
  5650. function src_default3(Alpine3) {
  5651. let lastFocused;
  5652. let currentFocused;
  5653. window.addEventListener("focusin", () => {
  5654. lastFocused = currentFocused;
  5655. currentFocused = document.activeElement;
  5656. });
  5657. Alpine3.magic("focus", (el) => {
  5658. let within = el;
  5659. return {
  5660. __noscroll: false,
  5661. __wrapAround: false,
  5662. within(el2) {
  5663. within = el2;
  5664. return this;
  5665. },
  5666. withoutScrolling() {
  5667. this.__noscroll = true;
  5668. return this;
  5669. },
  5670. noscroll() {
  5671. this.__noscroll = true;
  5672. return this;
  5673. },
  5674. withWrapAround() {
  5675. this.__wrapAround = true;
  5676. return this;
  5677. },
  5678. wrap() {
  5679. return this.withWrapAround();
  5680. },
  5681. focusable(el2) {
  5682. return isFocusable(el2);
  5683. },
  5684. previouslyFocused() {
  5685. return lastFocused;
  5686. },
  5687. lastFocused() {
  5688. return lastFocused;
  5689. },
  5690. focused() {
  5691. return currentFocused;
  5692. },
  5693. focusables() {
  5694. if (Array.isArray(within))
  5695. return within;
  5696. return focusable(within, { displayCheck: "none" });
  5697. },
  5698. all() {
  5699. return this.focusables();
  5700. },
  5701. isFirst(el2) {
  5702. let els2 = this.all();
  5703. return els2[0] && els2[0].isSameNode(el2);
  5704. },
  5705. isLast(el2) {
  5706. let els2 = this.all();
  5707. return els2.length && els2.slice(-1)[0].isSameNode(el2);
  5708. },
  5709. getFirst() {
  5710. return this.all()[0];
  5711. },
  5712. getLast() {
  5713. return this.all().slice(-1)[0];
  5714. },
  5715. getNext() {
  5716. let list = this.all();
  5717. let current = document.activeElement;
  5718. if (list.indexOf(current) === -1)
  5719. return;
  5720. if (this.__wrapAround && list.indexOf(current) === list.length - 1) {
  5721. return list[0];
  5722. }
  5723. return list[list.indexOf(current) + 1];
  5724. },
  5725. getPrevious() {
  5726. let list = this.all();
  5727. let current = document.activeElement;
  5728. if (list.indexOf(current) === -1)
  5729. return;
  5730. if (this.__wrapAround && list.indexOf(current) === 0) {
  5731. return list.slice(-1)[0];
  5732. }
  5733. return list[list.indexOf(current) - 1];
  5734. },
  5735. first() {
  5736. this.focus(this.getFirst());
  5737. },
  5738. last() {
  5739. this.focus(this.getLast());
  5740. },
  5741. next() {
  5742. this.focus(this.getNext());
  5743. },
  5744. previous() {
  5745. this.focus(this.getPrevious());
  5746. },
  5747. prev() {
  5748. return this.previous();
  5749. },
  5750. focus(el2) {
  5751. if (!el2)
  5752. return;
  5753. setTimeout(() => {
  5754. if (!el2.hasAttribute("tabindex"))
  5755. el2.setAttribute("tabindex", "0");
  5756. el2.focus({ preventScroll: this.__noscroll });
  5757. });
  5758. }
  5759. };
  5760. });
  5761. Alpine3.directive("trap", Alpine3.skipDuringClone((el, { expression, modifiers }, { effect: effect3, evaluateLater: evaluateLater2, cleanup: cleanup2 }) => {
  5762. let evaluator = evaluateLater2(expression);
  5763. let oldValue = false;
  5764. let options = {
  5765. escapeDeactivates: false,
  5766. allowOutsideClick: true,
  5767. fallbackFocus: () => el
  5768. };
  5769. if (modifiers.includes("noautofocus")) {
  5770. options.initialFocus = false;
  5771. } else {
  5772. let autofocusEl = el.querySelector("[autofocus]");
  5773. if (autofocusEl)
  5774. options.initialFocus = autofocusEl;
  5775. }
  5776. let trap = createFocusTrap(el, options);
  5777. let undoInert = () => {
  5778. };
  5779. let undoDisableScrolling = () => {
  5780. };
  5781. const releaseFocus = () => {
  5782. undoInert();
  5783. undoInert = () => {
  5784. };
  5785. undoDisableScrolling();
  5786. undoDisableScrolling = () => {
  5787. };
  5788. trap.deactivate({
  5789. returnFocus: !modifiers.includes("noreturn")
  5790. });
  5791. };
  5792. effect3(() => evaluator((value) => {
  5793. if (oldValue === value)
  5794. return;
  5795. if (value && !oldValue) {
  5796. if (modifiers.includes("noscroll"))
  5797. undoDisableScrolling = disableScrolling();
  5798. if (modifiers.includes("inert"))
  5799. undoInert = setInert(el);
  5800. setTimeout(() => {
  5801. trap.activate();
  5802. }, 15);
  5803. }
  5804. if (!value && oldValue) {
  5805. releaseFocus();
  5806. }
  5807. oldValue = !!value;
  5808. }));
  5809. cleanup2(releaseFocus);
  5810. }, (el, { expression, modifiers }, { evaluate: evaluate3 }) => {
  5811. if (modifiers.includes("inert") && evaluate3(expression))
  5812. setInert(el);
  5813. }));
  5814. }
  5815. function setInert(el) {
  5816. let undos = [];
  5817. crawlSiblingsUp(el, (sibling) => {
  5818. let cache = sibling.hasAttribute("aria-hidden");
  5819. sibling.setAttribute("aria-hidden", "true");
  5820. undos.push(() => cache || sibling.removeAttribute("aria-hidden"));
  5821. });
  5822. return () => {
  5823. while (undos.length)
  5824. undos.pop()();
  5825. };
  5826. }
  5827. function crawlSiblingsUp(el, callback) {
  5828. if (el.isSameNode(document.body) || !el.parentNode)
  5829. return;
  5830. Array.from(el.parentNode.children).forEach((sibling) => {
  5831. if (sibling.isSameNode(el)) {
  5832. crawlSiblingsUp(el.parentNode, callback);
  5833. } else {
  5834. callback(sibling);
  5835. }
  5836. });
  5837. }
  5838. function disableScrolling() {
  5839. let overflow = document.documentElement.style.overflow;
  5840. let paddingRight = document.documentElement.style.paddingRight;
  5841. let scrollbarWidth = window.innerWidth - document.documentElement.clientWidth;
  5842. document.documentElement.style.overflow = "hidden";
  5843. document.documentElement.style.paddingRight = `${scrollbarWidth}px`;
  5844. return () => {
  5845. document.documentElement.style.overflow = overflow;
  5846. document.documentElement.style.paddingRight = paddingRight;
  5847. };
  5848. }
  5849. var module_default3 = src_default3;
  5850. // ../alpine/packages/persist/dist/module.esm.js
  5851. function src_default4(Alpine3) {
  5852. let persist = () => {
  5853. let alias;
  5854. let storage;
  5855. try {
  5856. storage = localStorage;
  5857. } catch (e) {
  5858. console.error(e);
  5859. console.warn("Alpine: $persist is using temporary storage since localStorage is unavailable.");
  5860. let dummy = /* @__PURE__ */ new Map();
  5861. storage = {
  5862. getItem: dummy.get.bind(dummy),
  5863. setItem: dummy.set.bind(dummy)
  5864. };
  5865. }
  5866. return Alpine3.interceptor((initialValue, getter, setter, path, key) => {
  5867. let lookup = alias || `_x_${path}`;
  5868. let initial = storageHas(lookup, storage) ? storageGet(lookup, storage) : initialValue;
  5869. setter(initial);
  5870. Alpine3.effect(() => {
  5871. let value = getter();
  5872. storageSet(lookup, value, storage);
  5873. setter(value);
  5874. });
  5875. return initial;
  5876. }, (func) => {
  5877. func.as = (key) => {
  5878. alias = key;
  5879. return func;
  5880. }, func.using = (target) => {
  5881. storage = target;
  5882. return func;
  5883. };
  5884. });
  5885. };
  5886. Object.defineProperty(Alpine3, "$persist", { get: () => persist() });
  5887. Alpine3.magic("persist", persist);
  5888. Alpine3.persist = (key, { get: get3, set: set3 }, storage = localStorage) => {
  5889. let initial = storageHas(key, storage) ? storageGet(key, storage) : get3();
  5890. set3(initial);
  5891. Alpine3.effect(() => {
  5892. let value = get3();
  5893. storageSet(key, value, storage);
  5894. set3(value);
  5895. });
  5896. };
  5897. }
  5898. function storageHas(key, storage) {
  5899. return storage.getItem(key) !== null;
  5900. }
  5901. function storageGet(key, storage) {
  5902. let value = storage.getItem(key, storage);
  5903. if (value === void 0)
  5904. return;
  5905. return JSON.parse(value);
  5906. }
  5907. function storageSet(key, value, storage) {
  5908. storage.setItem(key, JSON.stringify(value));
  5909. }
  5910. var module_default4 = src_default4;
  5911. // ../alpine/packages/intersect/dist/module.esm.js
  5912. function src_default5(Alpine3) {
  5913. Alpine3.directive("intersect", Alpine3.skipDuringClone((el, { value, expression, modifiers }, { evaluateLater: evaluateLater2, cleanup: cleanup2 }) => {
  5914. let evaluate3 = evaluateLater2(expression);
  5915. let options = {
  5916. rootMargin: getRootMargin(modifiers),
  5917. threshold: getThreshold(modifiers)
  5918. };
  5919. let observer2 = new IntersectionObserver((entries) => {
  5920. entries.forEach((entry) => {
  5921. if (entry.isIntersecting === (value === "leave"))
  5922. return;
  5923. evaluate3();
  5924. modifiers.includes("once") && observer2.disconnect();
  5925. });
  5926. }, options);
  5927. observer2.observe(el);
  5928. cleanup2(() => {
  5929. observer2.disconnect();
  5930. });
  5931. }));
  5932. }
  5933. function getThreshold(modifiers) {
  5934. if (modifiers.includes("full"))
  5935. return 0.99;
  5936. if (modifiers.includes("half"))
  5937. return 0.5;
  5938. if (!modifiers.includes("threshold"))
  5939. return 0;
  5940. let threshold = modifiers[modifiers.indexOf("threshold") + 1];
  5941. if (threshold === "100")
  5942. return 1;
  5943. if (threshold === "0")
  5944. return 0;
  5945. return Number(`.${threshold}`);
  5946. }
  5947. function getLengthValue(rawValue) {
  5948. let match = rawValue.match(/^(-?[0-9]+)(px|%)?$/);
  5949. return match ? match[1] + (match[2] || "px") : void 0;
  5950. }
  5951. function getRootMargin(modifiers) {
  5952. const key = "margin";
  5953. const fallback2 = "0px 0px 0px 0px";
  5954. const index = modifiers.indexOf(key);
  5955. if (index === -1)
  5956. return fallback2;
  5957. let values = [];
  5958. for (let i = 1; i < 5; i++) {
  5959. values.push(getLengthValue(modifiers[index + i] || ""));
  5960. }
  5961. values = values.filter((v) => v !== void 0);
  5962. return values.length ? values.join(" ").trim() : fallback2;
  5963. }
  5964. var module_default5 = src_default5;
  5965. // node_modules/@alpinejs/resize/dist/module.esm.js
  5966. function src_default6(Alpine3) {
  5967. Alpine3.directive("resize", Alpine3.skipDuringClone((el, { value, expression, modifiers }, { evaluateLater: evaluateLater2, cleanup: cleanup2 }) => {
  5968. let evaluator = evaluateLater2(expression);
  5969. let evaluate3 = (width, height) => {
  5970. evaluator(() => {
  5971. }, { scope: { "$width": width, "$height": height } });
  5972. };
  5973. let off = modifiers.includes("document") ? onDocumentResize(evaluate3) : onElResize(el, evaluate3);
  5974. cleanup2(() => off());
  5975. }));
  5976. }
  5977. function onElResize(el, callback) {
  5978. let observer2 = new ResizeObserver((entries) => {
  5979. let [width, height] = dimensions(entries);
  5980. callback(width, height);
  5981. });
  5982. observer2.observe(el);
  5983. return () => observer2.disconnect();
  5984. }
  5985. var documentResizeObserver;
  5986. var documentResizeObserverCallbacks = /* @__PURE__ */ new Set();
  5987. function onDocumentResize(callback) {
  5988. documentResizeObserverCallbacks.add(callback);
  5989. if (!documentResizeObserver) {
  5990. documentResizeObserver = new ResizeObserver((entries) => {
  5991. let [width, height] = dimensions(entries);
  5992. documentResizeObserverCallbacks.forEach((i) => i(width, height));
  5993. });
  5994. documentResizeObserver.observe(document.documentElement);
  5995. }
  5996. return () => {
  5997. documentResizeObserverCallbacks.delete(callback);
  5998. };
  5999. }
  6000. function dimensions(entries) {
  6001. let width, height;
  6002. for (let entry of entries) {
  6003. width = entry.borderBoxSize[0].inlineSize;
  6004. height = entry.borderBoxSize[0].blockSize;
  6005. }
  6006. return [width, height];
  6007. }
  6008. var module_default6 = src_default6;
  6009. // ../alpine/packages/anchor/dist/module.esm.js
  6010. var min = Math.min;
  6011. var max = Math.max;
  6012. var round = Math.round;
  6013. var floor = Math.floor;
  6014. var createCoords = (v) => ({
  6015. x: v,
  6016. y: v
  6017. });
  6018. var oppositeSideMap = {
  6019. left: "right",
  6020. right: "left",
  6021. bottom: "top",
  6022. top: "bottom"
  6023. };
  6024. var oppositeAlignmentMap = {
  6025. start: "end",
  6026. end: "start"
  6027. };
  6028. function clamp(start3, value, end) {
  6029. return max(start3, min(value, end));
  6030. }
  6031. function evaluate2(value, param) {
  6032. return typeof value === "function" ? value(param) : value;
  6033. }
  6034. function getSide(placement) {
  6035. return placement.split("-")[0];
  6036. }
  6037. function getAlignment(placement) {
  6038. return placement.split("-")[1];
  6039. }
  6040. function getOppositeAxis(axis) {
  6041. return axis === "x" ? "y" : "x";
  6042. }
  6043. function getAxisLength(axis) {
  6044. return axis === "y" ? "height" : "width";
  6045. }
  6046. function getSideAxis(placement) {
  6047. return ["top", "bottom"].includes(getSide(placement)) ? "y" : "x";
  6048. }
  6049. function getAlignmentAxis(placement) {
  6050. return getOppositeAxis(getSideAxis(placement));
  6051. }
  6052. function getAlignmentSides(placement, rects, rtl) {
  6053. if (rtl === void 0) {
  6054. rtl = false;
  6055. }
  6056. const alignment = getAlignment(placement);
  6057. const alignmentAxis = getAlignmentAxis(placement);
  6058. const length = getAxisLength(alignmentAxis);
  6059. let mainAlignmentSide = alignmentAxis === "x" ? alignment === (rtl ? "end" : "start") ? "right" : "left" : alignment === "start" ? "bottom" : "top";
  6060. if (rects.reference[length] > rects.floating[length]) {
  6061. mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
  6062. }
  6063. return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
  6064. }
  6065. function getExpandedPlacements(placement) {
  6066. const oppositePlacement = getOppositePlacement(placement);
  6067. return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
  6068. }
  6069. function getOppositeAlignmentPlacement(placement) {
  6070. return placement.replace(/start|end/g, (alignment) => oppositeAlignmentMap[alignment]);
  6071. }
  6072. function getSideList(side, isStart, rtl) {
  6073. const lr = ["left", "right"];
  6074. const rl = ["right", "left"];
  6075. const tb = ["top", "bottom"];
  6076. const bt = ["bottom", "top"];
  6077. switch (side) {
  6078. case "top":
  6079. case "bottom":
  6080. if (rtl)
  6081. return isStart ? rl : lr;
  6082. return isStart ? lr : rl;
  6083. case "left":
  6084. case "right":
  6085. return isStart ? tb : bt;
  6086. default:
  6087. return [];
  6088. }
  6089. }
  6090. function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
  6091. const alignment = getAlignment(placement);
  6092. let list = getSideList(getSide(placement), direction === "start", rtl);
  6093. if (alignment) {
  6094. list = list.map((side) => side + "-" + alignment);
  6095. if (flipAlignment) {
  6096. list = list.concat(list.map(getOppositeAlignmentPlacement));
  6097. }
  6098. }
  6099. return list;
  6100. }
  6101. function getOppositePlacement(placement) {
  6102. return placement.replace(/left|right|bottom|top/g, (side) => oppositeSideMap[side]);
  6103. }
  6104. function expandPaddingObject(padding) {
  6105. return {
  6106. top: 0,
  6107. right: 0,
  6108. bottom: 0,
  6109. left: 0,
  6110. ...padding
  6111. };
  6112. }
  6113. function getPaddingObject(padding) {
  6114. return typeof padding !== "number" ? expandPaddingObject(padding) : {
  6115. top: padding,
  6116. right: padding,
  6117. bottom: padding,
  6118. left: padding
  6119. };
  6120. }
  6121. function rectToClientRect(rect) {
  6122. return {
  6123. ...rect,
  6124. top: rect.y,
  6125. left: rect.x,
  6126. right: rect.x + rect.width,
  6127. bottom: rect.y + rect.height
  6128. };
  6129. }
  6130. function computeCoordsFromPlacement(_ref, placement, rtl) {
  6131. let {
  6132. reference,
  6133. floating
  6134. } = _ref;
  6135. const sideAxis = getSideAxis(placement);
  6136. const alignmentAxis = getAlignmentAxis(placement);
  6137. const alignLength = getAxisLength(alignmentAxis);
  6138. const side = getSide(placement);
  6139. const isVertical = sideAxis === "y";
  6140. const commonX = reference.x + reference.width / 2 - floating.width / 2;
  6141. const commonY = reference.y + reference.height / 2 - floating.height / 2;
  6142. const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
  6143. let coords;
  6144. switch (side) {
  6145. case "top":
  6146. coords = {
  6147. x: commonX,
  6148. y: reference.y - floating.height
  6149. };
  6150. break;
  6151. case "bottom":
  6152. coords = {
  6153. x: commonX,
  6154. y: reference.y + reference.height
  6155. };
  6156. break;
  6157. case "right":
  6158. coords = {
  6159. x: reference.x + reference.width,
  6160. y: commonY
  6161. };
  6162. break;
  6163. case "left":
  6164. coords = {
  6165. x: reference.x - floating.width,
  6166. y: commonY
  6167. };
  6168. break;
  6169. default:
  6170. coords = {
  6171. x: reference.x,
  6172. y: reference.y
  6173. };
  6174. }
  6175. switch (getAlignment(placement)) {
  6176. case "start":
  6177. coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
  6178. break;
  6179. case "end":
  6180. coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
  6181. break;
  6182. }
  6183. return coords;
  6184. }
  6185. var computePosition = async (reference, floating, config) => {
  6186. const {
  6187. placement = "bottom",
  6188. strategy = "absolute",
  6189. middleware = [],
  6190. platform: platform2
  6191. } = config;
  6192. const validMiddleware = middleware.filter(Boolean);
  6193. const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(floating));
  6194. let rects = await platform2.getElementRects({
  6195. reference,
  6196. floating,
  6197. strategy
  6198. });
  6199. let {
  6200. x,
  6201. y
  6202. } = computeCoordsFromPlacement(rects, placement, rtl);
  6203. let statefulPlacement = placement;
  6204. let middlewareData = {};
  6205. let resetCount = 0;
  6206. for (let i = 0; i < validMiddleware.length; i++) {
  6207. const {
  6208. name,
  6209. fn
  6210. } = validMiddleware[i];
  6211. const {
  6212. x: nextX,
  6213. y: nextY,
  6214. data: data2,
  6215. reset
  6216. } = await fn({
  6217. x,
  6218. y,
  6219. initialPlacement: placement,
  6220. placement: statefulPlacement,
  6221. strategy,
  6222. middlewareData,
  6223. rects,
  6224. platform: platform2,
  6225. elements: {
  6226. reference,
  6227. floating
  6228. }
  6229. });
  6230. x = nextX != null ? nextX : x;
  6231. y = nextY != null ? nextY : y;
  6232. middlewareData = {
  6233. ...middlewareData,
  6234. [name]: {
  6235. ...middlewareData[name],
  6236. ...data2
  6237. }
  6238. };
  6239. if (reset && resetCount <= 50) {
  6240. resetCount++;
  6241. if (typeof reset === "object") {
  6242. if (reset.placement) {
  6243. statefulPlacement = reset.placement;
  6244. }
  6245. if (reset.rects) {
  6246. rects = reset.rects === true ? await platform2.getElementRects({
  6247. reference,
  6248. floating,
  6249. strategy
  6250. }) : reset.rects;
  6251. }
  6252. ({
  6253. x,
  6254. y
  6255. } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
  6256. }
  6257. i = -1;
  6258. continue;
  6259. }
  6260. }
  6261. return {
  6262. x,
  6263. y,
  6264. placement: statefulPlacement,
  6265. strategy,
  6266. middlewareData
  6267. };
  6268. };
  6269. async function detectOverflow(state, options) {
  6270. var _await$platform$isEle;
  6271. if (options === void 0) {
  6272. options = {};
  6273. }
  6274. const {
  6275. x,
  6276. y,
  6277. platform: platform2,
  6278. rects,
  6279. elements,
  6280. strategy
  6281. } = state;
  6282. const {
  6283. boundary = "clippingAncestors",
  6284. rootBoundary = "viewport",
  6285. elementContext = "floating",
  6286. altBoundary = false,
  6287. padding = 0
  6288. } = evaluate2(options, state);
  6289. const paddingObject = getPaddingObject(padding);
  6290. const altContext = elementContext === "floating" ? "reference" : "floating";
  6291. const element = elements[altBoundary ? altContext : elementContext];
  6292. const clippingClientRect = rectToClientRect(await platform2.getClippingRect({
  6293. element: ((_await$platform$isEle = await (platform2.isElement == null ? void 0 : platform2.isElement(element))) != null ? _await$platform$isEle : true) ? element : element.contextElement || await (platform2.getDocumentElement == null ? void 0 : platform2.getDocumentElement(elements.floating)),
  6294. boundary,
  6295. rootBoundary,
  6296. strategy
  6297. }));
  6298. const rect = elementContext === "floating" ? {
  6299. ...rects.floating,
  6300. x,
  6301. y
  6302. } : rects.reference;
  6303. const offsetParent = await (platform2.getOffsetParent == null ? void 0 : platform2.getOffsetParent(elements.floating));
  6304. const offsetScale = await (platform2.isElement == null ? void 0 : platform2.isElement(offsetParent)) ? await (platform2.getScale == null ? void 0 : platform2.getScale(offsetParent)) || {
  6305. x: 1,
  6306. y: 1
  6307. } : {
  6308. x: 1,
  6309. y: 1
  6310. };
  6311. const elementClientRect = rectToClientRect(platform2.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform2.convertOffsetParentRelativeRectToViewportRelativeRect({
  6312. rect,
  6313. offsetParent,
  6314. strategy
  6315. }) : rect);
  6316. return {
  6317. top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
  6318. bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
  6319. left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
  6320. right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
  6321. };
  6322. }
  6323. var flip = function(options) {
  6324. if (options === void 0) {
  6325. options = {};
  6326. }
  6327. return {
  6328. name: "flip",
  6329. options,
  6330. async fn(state) {
  6331. var _middlewareData$arrow, _middlewareData$flip;
  6332. const {
  6333. placement,
  6334. middlewareData,
  6335. rects,
  6336. initialPlacement,
  6337. platform: platform2,
  6338. elements
  6339. } = state;
  6340. const {
  6341. mainAxis: checkMainAxis = true,
  6342. crossAxis: checkCrossAxis = true,
  6343. fallbackPlacements: specifiedFallbackPlacements,
  6344. fallbackStrategy = "bestFit",
  6345. fallbackAxisSideDirection = "none",
  6346. flipAlignment = true,
  6347. ...detectOverflowOptions
  6348. } = evaluate2(options, state);
  6349. if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
  6350. return {};
  6351. }
  6352. const side = getSide(placement);
  6353. const isBasePlacement = getSide(initialPlacement) === initialPlacement;
  6354. const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating));
  6355. const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
  6356. if (!specifiedFallbackPlacements && fallbackAxisSideDirection !== "none") {
  6357. fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
  6358. }
  6359. const placements2 = [initialPlacement, ...fallbackPlacements];
  6360. const overflow = await detectOverflow(state, detectOverflowOptions);
  6361. const overflows = [];
  6362. let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
  6363. if (checkMainAxis) {
  6364. overflows.push(overflow[side]);
  6365. }
  6366. if (checkCrossAxis) {
  6367. const sides2 = getAlignmentSides(placement, rects, rtl);
  6368. overflows.push(overflow[sides2[0]], overflow[sides2[1]]);
  6369. }
  6370. overflowsData = [...overflowsData, {
  6371. placement,
  6372. overflows
  6373. }];
  6374. if (!overflows.every((side2) => side2 <= 0)) {
  6375. var _middlewareData$flip2, _overflowsData$filter;
  6376. const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
  6377. const nextPlacement = placements2[nextIndex];
  6378. if (nextPlacement) {
  6379. return {
  6380. data: {
  6381. index: nextIndex,
  6382. overflows: overflowsData
  6383. },
  6384. reset: {
  6385. placement: nextPlacement
  6386. }
  6387. };
  6388. }
  6389. let resetPlacement = (_overflowsData$filter = overflowsData.filter((d) => d.overflows[0] <= 0).sort((a, b) => a.overflows[1] - b.overflows[1])[0]) == null ? void 0 : _overflowsData$filter.placement;
  6390. if (!resetPlacement) {
  6391. switch (fallbackStrategy) {
  6392. case "bestFit": {
  6393. var _overflowsData$map$so;
  6394. const placement2 = (_overflowsData$map$so = overflowsData.map((d) => [d.placement, d.overflows.filter((overflow2) => overflow2 > 0).reduce((acc, overflow2) => acc + overflow2, 0)]).sort((a, b) => a[1] - b[1])[0]) == null ? void 0 : _overflowsData$map$so[0];
  6395. if (placement2) {
  6396. resetPlacement = placement2;
  6397. }
  6398. break;
  6399. }
  6400. case "initialPlacement":
  6401. resetPlacement = initialPlacement;
  6402. break;
  6403. }
  6404. }
  6405. if (placement !== resetPlacement) {
  6406. return {
  6407. reset: {
  6408. placement: resetPlacement
  6409. }
  6410. };
  6411. }
  6412. }
  6413. return {};
  6414. }
  6415. };
  6416. };
  6417. async function convertValueToCoords(state, options) {
  6418. const {
  6419. placement,
  6420. platform: platform2,
  6421. elements
  6422. } = state;
  6423. const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating));
  6424. const side = getSide(placement);
  6425. const alignment = getAlignment(placement);
  6426. const isVertical = getSideAxis(placement) === "y";
  6427. const mainAxisMulti = ["left", "top"].includes(side) ? -1 : 1;
  6428. const crossAxisMulti = rtl && isVertical ? -1 : 1;
  6429. const rawValue = evaluate2(options, state);
  6430. let {
  6431. mainAxis,
  6432. crossAxis,
  6433. alignmentAxis
  6434. } = typeof rawValue === "number" ? {
  6435. mainAxis: rawValue,
  6436. crossAxis: 0,
  6437. alignmentAxis: null
  6438. } : {
  6439. mainAxis: 0,
  6440. crossAxis: 0,
  6441. alignmentAxis: null,
  6442. ...rawValue
  6443. };
  6444. if (alignment && typeof alignmentAxis === "number") {
  6445. crossAxis = alignment === "end" ? alignmentAxis * -1 : alignmentAxis;
  6446. }
  6447. return isVertical ? {
  6448. x: crossAxis * crossAxisMulti,
  6449. y: mainAxis * mainAxisMulti
  6450. } : {
  6451. x: mainAxis * mainAxisMulti,
  6452. y: crossAxis * crossAxisMulti
  6453. };
  6454. }
  6455. var offset = function(options) {
  6456. if (options === void 0) {
  6457. options = 0;
  6458. }
  6459. return {
  6460. name: "offset",
  6461. options,
  6462. async fn(state) {
  6463. const {
  6464. x,
  6465. y
  6466. } = state;
  6467. const diffCoords = await convertValueToCoords(state, options);
  6468. return {
  6469. x: x + diffCoords.x,
  6470. y: y + diffCoords.y,
  6471. data: diffCoords
  6472. };
  6473. }
  6474. };
  6475. };
  6476. var shift = function(options) {
  6477. if (options === void 0) {
  6478. options = {};
  6479. }
  6480. return {
  6481. name: "shift",
  6482. options,
  6483. async fn(state) {
  6484. const {
  6485. x,
  6486. y,
  6487. placement
  6488. } = state;
  6489. const {
  6490. mainAxis: checkMainAxis = true,
  6491. crossAxis: checkCrossAxis = false,
  6492. limiter = {
  6493. fn: (_ref) => {
  6494. let {
  6495. x: x2,
  6496. y: y2
  6497. } = _ref;
  6498. return {
  6499. x: x2,
  6500. y: y2
  6501. };
  6502. }
  6503. },
  6504. ...detectOverflowOptions
  6505. } = evaluate2(options, state);
  6506. const coords = {
  6507. x,
  6508. y
  6509. };
  6510. const overflow = await detectOverflow(state, detectOverflowOptions);
  6511. const crossAxis = getSideAxis(getSide(placement));
  6512. const mainAxis = getOppositeAxis(crossAxis);
  6513. let mainAxisCoord = coords[mainAxis];
  6514. let crossAxisCoord = coords[crossAxis];
  6515. if (checkMainAxis) {
  6516. const minSide = mainAxis === "y" ? "top" : "left";
  6517. const maxSide = mainAxis === "y" ? "bottom" : "right";
  6518. const min2 = mainAxisCoord + overflow[minSide];
  6519. const max2 = mainAxisCoord - overflow[maxSide];
  6520. mainAxisCoord = clamp(min2, mainAxisCoord, max2);
  6521. }
  6522. if (checkCrossAxis) {
  6523. const minSide = crossAxis === "y" ? "top" : "left";
  6524. const maxSide = crossAxis === "y" ? "bottom" : "right";
  6525. const min2 = crossAxisCoord + overflow[minSide];
  6526. const max2 = crossAxisCoord - overflow[maxSide];
  6527. crossAxisCoord = clamp(min2, crossAxisCoord, max2);
  6528. }
  6529. const limitedCoords = limiter.fn({
  6530. ...state,
  6531. [mainAxis]: mainAxisCoord,
  6532. [crossAxis]: crossAxisCoord
  6533. });
  6534. return {
  6535. ...limitedCoords,
  6536. data: {
  6537. x: limitedCoords.x - x,
  6538. y: limitedCoords.y - y
  6539. }
  6540. };
  6541. }
  6542. };
  6543. };
  6544. function getNodeName(node) {
  6545. if (isNode(node)) {
  6546. return (node.nodeName || "").toLowerCase();
  6547. }
  6548. return "#document";
  6549. }
  6550. function getWindow(node) {
  6551. var _node$ownerDocument;
  6552. return (node == null ? void 0 : (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
  6553. }
  6554. function getDocumentElement(node) {
  6555. var _ref;
  6556. return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
  6557. }
  6558. function isNode(value) {
  6559. return value instanceof Node || value instanceof getWindow(value).Node;
  6560. }
  6561. function isElement(value) {
  6562. return value instanceof Element || value instanceof getWindow(value).Element;
  6563. }
  6564. function isHTMLElement(value) {
  6565. return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
  6566. }
  6567. function isShadowRoot(value) {
  6568. if (typeof ShadowRoot === "undefined") {
  6569. return false;
  6570. }
  6571. return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
  6572. }
  6573. function isOverflowElement(element) {
  6574. const {
  6575. overflow,
  6576. overflowX,
  6577. overflowY,
  6578. display
  6579. } = getComputedStyle2(element);
  6580. return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !["inline", "contents"].includes(display);
  6581. }
  6582. function isTableElement(element) {
  6583. return ["table", "td", "th"].includes(getNodeName(element));
  6584. }
  6585. function isContainingBlock(element) {
  6586. const webkit = isWebKit();
  6587. const css = getComputedStyle2(element);
  6588. return css.transform !== "none" || css.perspective !== "none" || (css.containerType ? css.containerType !== "normal" : false) || !webkit && (css.backdropFilter ? css.backdropFilter !== "none" : false) || !webkit && (css.filter ? css.filter !== "none" : false) || ["transform", "perspective", "filter"].some((value) => (css.willChange || "").includes(value)) || ["paint", "layout", "strict", "content"].some((value) => (css.contain || "").includes(value));
  6589. }
  6590. function getContainingBlock(element) {
  6591. let currentNode = getParentNode(element);
  6592. while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
  6593. if (isContainingBlock(currentNode)) {
  6594. return currentNode;
  6595. } else {
  6596. currentNode = getParentNode(currentNode);
  6597. }
  6598. }
  6599. return null;
  6600. }
  6601. function isWebKit() {
  6602. if (typeof CSS === "undefined" || !CSS.supports)
  6603. return false;
  6604. return CSS.supports("-webkit-backdrop-filter", "none");
  6605. }
  6606. function isLastTraversableNode(node) {
  6607. return ["html", "body", "#document"].includes(getNodeName(node));
  6608. }
  6609. function getComputedStyle2(element) {
  6610. return getWindow(element).getComputedStyle(element);
  6611. }
  6612. function getNodeScroll(element) {
  6613. if (isElement(element)) {
  6614. return {
  6615. scrollLeft: element.scrollLeft,
  6616. scrollTop: element.scrollTop
  6617. };
  6618. }
  6619. return {
  6620. scrollLeft: element.pageXOffset,
  6621. scrollTop: element.pageYOffset
  6622. };
  6623. }
  6624. function getParentNode(node) {
  6625. if (getNodeName(node) === "html") {
  6626. return node;
  6627. }
  6628. const result = node.assignedSlot || node.parentNode || isShadowRoot(node) && node.host || getDocumentElement(node);
  6629. return isShadowRoot(result) ? result.host : result;
  6630. }
  6631. function getNearestOverflowAncestor(node) {
  6632. const parentNode = getParentNode(node);
  6633. if (isLastTraversableNode(parentNode)) {
  6634. return node.ownerDocument ? node.ownerDocument.body : node.body;
  6635. }
  6636. if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
  6637. return parentNode;
  6638. }
  6639. return getNearestOverflowAncestor(parentNode);
  6640. }
  6641. function getOverflowAncestors(node, list, traverseIframes) {
  6642. var _node$ownerDocument2;
  6643. if (list === void 0) {
  6644. list = [];
  6645. }
  6646. if (traverseIframes === void 0) {
  6647. traverseIframes = true;
  6648. }
  6649. const scrollableAncestor = getNearestOverflowAncestor(node);
  6650. const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
  6651. const win = getWindow(scrollableAncestor);
  6652. if (isBody) {
  6653. return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], win.frameElement && traverseIframes ? getOverflowAncestors(win.frameElement) : []);
  6654. }
  6655. return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
  6656. }
  6657. function getCssDimensions(element) {
  6658. const css = getComputedStyle2(element);
  6659. let width = parseFloat(css.width) || 0;
  6660. let height = parseFloat(css.height) || 0;
  6661. const hasOffset = isHTMLElement(element);
  6662. const offsetWidth = hasOffset ? element.offsetWidth : width;
  6663. const offsetHeight = hasOffset ? element.offsetHeight : height;
  6664. const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
  6665. if (shouldFallback) {
  6666. width = offsetWidth;
  6667. height = offsetHeight;
  6668. }
  6669. return {
  6670. width,
  6671. height,
  6672. $: shouldFallback
  6673. };
  6674. }
  6675. function unwrapElement(element) {
  6676. return !isElement(element) ? element.contextElement : element;
  6677. }
  6678. function getScale(element) {
  6679. const domElement = unwrapElement(element);
  6680. if (!isHTMLElement(domElement)) {
  6681. return createCoords(1);
  6682. }
  6683. const rect = domElement.getBoundingClientRect();
  6684. const {
  6685. width,
  6686. height,
  6687. $
  6688. } = getCssDimensions(domElement);
  6689. let x = ($ ? round(rect.width) : rect.width) / width;
  6690. let y = ($ ? round(rect.height) : rect.height) / height;
  6691. if (!x || !Number.isFinite(x)) {
  6692. x = 1;
  6693. }
  6694. if (!y || !Number.isFinite(y)) {
  6695. y = 1;
  6696. }
  6697. return {
  6698. x,
  6699. y
  6700. };
  6701. }
  6702. var noOffsets = /* @__PURE__ */ createCoords(0);
  6703. function getVisualOffsets(element) {
  6704. const win = getWindow(element);
  6705. if (!isWebKit() || !win.visualViewport) {
  6706. return noOffsets;
  6707. }
  6708. return {
  6709. x: win.visualViewport.offsetLeft,
  6710. y: win.visualViewport.offsetTop
  6711. };
  6712. }
  6713. function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
  6714. if (isFixed === void 0) {
  6715. isFixed = false;
  6716. }
  6717. if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
  6718. return false;
  6719. }
  6720. return isFixed;
  6721. }
  6722. function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
  6723. if (includeScale === void 0) {
  6724. includeScale = false;
  6725. }
  6726. if (isFixedStrategy === void 0) {
  6727. isFixedStrategy = false;
  6728. }
  6729. const clientRect = element.getBoundingClientRect();
  6730. const domElement = unwrapElement(element);
  6731. let scale = createCoords(1);
  6732. if (includeScale) {
  6733. if (offsetParent) {
  6734. if (isElement(offsetParent)) {
  6735. scale = getScale(offsetParent);
  6736. }
  6737. } else {
  6738. scale = getScale(element);
  6739. }
  6740. }
  6741. const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
  6742. let x = (clientRect.left + visualOffsets.x) / scale.x;
  6743. let y = (clientRect.top + visualOffsets.y) / scale.y;
  6744. let width = clientRect.width / scale.x;
  6745. let height = clientRect.height / scale.y;
  6746. if (domElement) {
  6747. const win = getWindow(domElement);
  6748. const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
  6749. let currentIFrame = win.frameElement;
  6750. while (currentIFrame && offsetParent && offsetWin !== win) {
  6751. const iframeScale = getScale(currentIFrame);
  6752. const iframeRect = currentIFrame.getBoundingClientRect();
  6753. const css = getComputedStyle2(currentIFrame);
  6754. const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
  6755. const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
  6756. x *= iframeScale.x;
  6757. y *= iframeScale.y;
  6758. width *= iframeScale.x;
  6759. height *= iframeScale.y;
  6760. x += left;
  6761. y += top;
  6762. currentIFrame = getWindow(currentIFrame).frameElement;
  6763. }
  6764. }
  6765. return rectToClientRect({
  6766. width,
  6767. height,
  6768. x,
  6769. y
  6770. });
  6771. }
  6772. function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
  6773. let {
  6774. rect,
  6775. offsetParent,
  6776. strategy
  6777. } = _ref;
  6778. const isOffsetParentAnElement = isHTMLElement(offsetParent);
  6779. const documentElement = getDocumentElement(offsetParent);
  6780. if (offsetParent === documentElement) {
  6781. return rect;
  6782. }
  6783. let scroll = {
  6784. scrollLeft: 0,
  6785. scrollTop: 0
  6786. };
  6787. let scale = createCoords(1);
  6788. const offsets = createCoords(0);
  6789. if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== "fixed") {
  6790. if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
  6791. scroll = getNodeScroll(offsetParent);
  6792. }
  6793. if (isHTMLElement(offsetParent)) {
  6794. const offsetRect = getBoundingClientRect(offsetParent);
  6795. scale = getScale(offsetParent);
  6796. offsets.x = offsetRect.x + offsetParent.clientLeft;
  6797. offsets.y = offsetRect.y + offsetParent.clientTop;
  6798. }
  6799. }
  6800. return {
  6801. width: rect.width * scale.x,
  6802. height: rect.height * scale.y,
  6803. x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x,
  6804. y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y
  6805. };
  6806. }
  6807. function getClientRects(element) {
  6808. return Array.from(element.getClientRects());
  6809. }
  6810. function getWindowScrollBarX(element) {
  6811. return getBoundingClientRect(getDocumentElement(element)).left + getNodeScroll(element).scrollLeft;
  6812. }
  6813. function getDocumentRect(element) {
  6814. const html = getDocumentElement(element);
  6815. const scroll = getNodeScroll(element);
  6816. const body = element.ownerDocument.body;
  6817. const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
  6818. const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
  6819. let x = -scroll.scrollLeft + getWindowScrollBarX(element);
  6820. const y = -scroll.scrollTop;
  6821. if (getComputedStyle2(body).direction === "rtl") {
  6822. x += max(html.clientWidth, body.clientWidth) - width;
  6823. }
  6824. return {
  6825. width,
  6826. height,
  6827. x,
  6828. y
  6829. };
  6830. }
  6831. function getViewportRect(element, strategy) {
  6832. const win = getWindow(element);
  6833. const html = getDocumentElement(element);
  6834. const visualViewport = win.visualViewport;
  6835. let width = html.clientWidth;
  6836. let height = html.clientHeight;
  6837. let x = 0;
  6838. let y = 0;
  6839. if (visualViewport) {
  6840. width = visualViewport.width;
  6841. height = visualViewport.height;
  6842. const visualViewportBased = isWebKit();
  6843. if (!visualViewportBased || visualViewportBased && strategy === "fixed") {
  6844. x = visualViewport.offsetLeft;
  6845. y = visualViewport.offsetTop;
  6846. }
  6847. }
  6848. return {
  6849. width,
  6850. height,
  6851. x,
  6852. y
  6853. };
  6854. }
  6855. function getInnerBoundingClientRect(element, strategy) {
  6856. const clientRect = getBoundingClientRect(element, true, strategy === "fixed");
  6857. const top = clientRect.top + element.clientTop;
  6858. const left = clientRect.left + element.clientLeft;
  6859. const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
  6860. const width = element.clientWidth * scale.x;
  6861. const height = element.clientHeight * scale.y;
  6862. const x = left * scale.x;
  6863. const y = top * scale.y;
  6864. return {
  6865. width,
  6866. height,
  6867. x,
  6868. y
  6869. };
  6870. }
  6871. function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
  6872. let rect;
  6873. if (clippingAncestor === "viewport") {
  6874. rect = getViewportRect(element, strategy);
  6875. } else if (clippingAncestor === "document") {
  6876. rect = getDocumentRect(getDocumentElement(element));
  6877. } else if (isElement(clippingAncestor)) {
  6878. rect = getInnerBoundingClientRect(clippingAncestor, strategy);
  6879. } else {
  6880. const visualOffsets = getVisualOffsets(element);
  6881. rect = {
  6882. ...clippingAncestor,
  6883. x: clippingAncestor.x - visualOffsets.x,
  6884. y: clippingAncestor.y - visualOffsets.y
  6885. };
  6886. }
  6887. return rectToClientRect(rect);
  6888. }
  6889. function hasFixedPositionAncestor(element, stopNode) {
  6890. const parentNode = getParentNode(element);
  6891. if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
  6892. return false;
  6893. }
  6894. return getComputedStyle2(parentNode).position === "fixed" || hasFixedPositionAncestor(parentNode, stopNode);
  6895. }
  6896. function getClippingElementAncestors(element, cache) {
  6897. const cachedResult = cache.get(element);
  6898. if (cachedResult) {
  6899. return cachedResult;
  6900. }
  6901. let result = getOverflowAncestors(element, [], false).filter((el) => isElement(el) && getNodeName(el) !== "body");
  6902. let currentContainingBlockComputedStyle = null;
  6903. const elementIsFixed = getComputedStyle2(element).position === "fixed";
  6904. let currentNode = elementIsFixed ? getParentNode(element) : element;
  6905. while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
  6906. const computedStyle = getComputedStyle2(currentNode);
  6907. const currentNodeIsContaining = isContainingBlock(currentNode);
  6908. if (!currentNodeIsContaining && computedStyle.position === "fixed") {
  6909. currentContainingBlockComputedStyle = null;
  6910. }
  6911. const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === "static" && !!currentContainingBlockComputedStyle && ["absolute", "fixed"].includes(currentContainingBlockComputedStyle.position) || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
  6912. if (shouldDropCurrentNode) {
  6913. result = result.filter((ancestor) => ancestor !== currentNode);
  6914. } else {
  6915. currentContainingBlockComputedStyle = computedStyle;
  6916. }
  6917. currentNode = getParentNode(currentNode);
  6918. }
  6919. cache.set(element, result);
  6920. return result;
  6921. }
  6922. function getClippingRect(_ref) {
  6923. let {
  6924. element,
  6925. boundary,
  6926. rootBoundary,
  6927. strategy
  6928. } = _ref;
  6929. const elementClippingAncestors = boundary === "clippingAncestors" ? getClippingElementAncestors(element, this._c) : [].concat(boundary);
  6930. const clippingAncestors = [...elementClippingAncestors, rootBoundary];
  6931. const firstClippingAncestor = clippingAncestors[0];
  6932. const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
  6933. const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
  6934. accRect.top = max(rect.top, accRect.top);
  6935. accRect.right = min(rect.right, accRect.right);
  6936. accRect.bottom = min(rect.bottom, accRect.bottom);
  6937. accRect.left = max(rect.left, accRect.left);
  6938. return accRect;
  6939. }, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
  6940. return {
  6941. width: clippingRect.right - clippingRect.left,
  6942. height: clippingRect.bottom - clippingRect.top,
  6943. x: clippingRect.left,
  6944. y: clippingRect.top
  6945. };
  6946. }
  6947. function getDimensions(element) {
  6948. return getCssDimensions(element);
  6949. }
  6950. function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
  6951. const isOffsetParentAnElement = isHTMLElement(offsetParent);
  6952. const documentElement = getDocumentElement(offsetParent);
  6953. const isFixed = strategy === "fixed";
  6954. const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
  6955. let scroll = {
  6956. scrollLeft: 0,
  6957. scrollTop: 0
  6958. };
  6959. const offsets = createCoords(0);
  6960. if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
  6961. if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
  6962. scroll = getNodeScroll(offsetParent);
  6963. }
  6964. if (isOffsetParentAnElement) {
  6965. const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
  6966. offsets.x = offsetRect.x + offsetParent.clientLeft;
  6967. offsets.y = offsetRect.y + offsetParent.clientTop;
  6968. } else if (documentElement) {
  6969. offsets.x = getWindowScrollBarX(documentElement);
  6970. }
  6971. }
  6972. return {
  6973. x: rect.left + scroll.scrollLeft - offsets.x,
  6974. y: rect.top + scroll.scrollTop - offsets.y,
  6975. width: rect.width,
  6976. height: rect.height
  6977. };
  6978. }
  6979. function getTrueOffsetParent(element, polyfill) {
  6980. if (!isHTMLElement(element) || getComputedStyle2(element).position === "fixed") {
  6981. return null;
  6982. }
  6983. if (polyfill) {
  6984. return polyfill(element);
  6985. }
  6986. return element.offsetParent;
  6987. }
  6988. function getOffsetParent(element, polyfill) {
  6989. const window2 = getWindow(element);
  6990. if (!isHTMLElement(element)) {
  6991. return window2;
  6992. }
  6993. let offsetParent = getTrueOffsetParent(element, polyfill);
  6994. while (offsetParent && isTableElement(offsetParent) && getComputedStyle2(offsetParent).position === "static") {
  6995. offsetParent = getTrueOffsetParent(offsetParent, polyfill);
  6996. }
  6997. if (offsetParent && (getNodeName(offsetParent) === "html" || getNodeName(offsetParent) === "body" && getComputedStyle2(offsetParent).position === "static" && !isContainingBlock(offsetParent))) {
  6998. return window2;
  6999. }
  7000. return offsetParent || getContainingBlock(element) || window2;
  7001. }
  7002. var getElementRects = async function(_ref) {
  7003. let {
  7004. reference,
  7005. floating,
  7006. strategy
  7007. } = _ref;
  7008. const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
  7009. const getDimensionsFn = this.getDimensions;
  7010. return {
  7011. reference: getRectRelativeToOffsetParent(reference, await getOffsetParentFn(floating), strategy),
  7012. floating: {
  7013. x: 0,
  7014. y: 0,
  7015. ...await getDimensionsFn(floating)
  7016. }
  7017. };
  7018. };
  7019. function isRTL(element) {
  7020. return getComputedStyle2(element).direction === "rtl";
  7021. }
  7022. var platform = {
  7023. convertOffsetParentRelativeRectToViewportRelativeRect,
  7024. getDocumentElement,
  7025. getClippingRect,
  7026. getOffsetParent,
  7027. getElementRects,
  7028. getClientRects,
  7029. getDimensions,
  7030. getScale,
  7031. isElement,
  7032. isRTL
  7033. };
  7034. function observeMove(element, onMove) {
  7035. let io = null;
  7036. let timeoutId;
  7037. const root = getDocumentElement(element);
  7038. function cleanup2() {
  7039. clearTimeout(timeoutId);
  7040. io && io.disconnect();
  7041. io = null;
  7042. }
  7043. function refresh(skip, threshold) {
  7044. if (skip === void 0) {
  7045. skip = false;
  7046. }
  7047. if (threshold === void 0) {
  7048. threshold = 1;
  7049. }
  7050. cleanup2();
  7051. const {
  7052. left,
  7053. top,
  7054. width,
  7055. height
  7056. } = element.getBoundingClientRect();
  7057. if (!skip) {
  7058. onMove();
  7059. }
  7060. if (!width || !height) {
  7061. return;
  7062. }
  7063. const insetTop = floor(top);
  7064. const insetRight = floor(root.clientWidth - (left + width));
  7065. const insetBottom = floor(root.clientHeight - (top + height));
  7066. const insetLeft = floor(left);
  7067. const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
  7068. const options = {
  7069. rootMargin,
  7070. threshold: max(0, min(1, threshold)) || 1
  7071. };
  7072. let isFirstUpdate = true;
  7073. function handleObserve(entries) {
  7074. const ratio = entries[0].intersectionRatio;
  7075. if (ratio !== threshold) {
  7076. if (!isFirstUpdate) {
  7077. return refresh();
  7078. }
  7079. if (!ratio) {
  7080. timeoutId = setTimeout(() => {
  7081. refresh(false, 1e-7);
  7082. }, 100);
  7083. } else {
  7084. refresh(false, ratio);
  7085. }
  7086. }
  7087. isFirstUpdate = false;
  7088. }
  7089. try {
  7090. io = new IntersectionObserver(handleObserve, {
  7091. ...options,
  7092. root: root.ownerDocument
  7093. });
  7094. } catch (e) {
  7095. io = new IntersectionObserver(handleObserve, options);
  7096. }
  7097. io.observe(element);
  7098. }
  7099. refresh(true);
  7100. return cleanup2;
  7101. }
  7102. function autoUpdate(reference, floating, update, options) {
  7103. if (options === void 0) {
  7104. options = {};
  7105. }
  7106. const {
  7107. ancestorScroll = true,
  7108. ancestorResize = true,
  7109. elementResize = typeof ResizeObserver === "function",
  7110. layoutShift = typeof IntersectionObserver === "function",
  7111. animationFrame = false
  7112. } = options;
  7113. const referenceEl = unwrapElement(reference);
  7114. const ancestors = ancestorScroll || ancestorResize ? [...referenceEl ? getOverflowAncestors(referenceEl) : [], ...getOverflowAncestors(floating)] : [];
  7115. ancestors.forEach((ancestor) => {
  7116. ancestorScroll && ancestor.addEventListener("scroll", update, {
  7117. passive: true
  7118. });
  7119. ancestorResize && ancestor.addEventListener("resize", update);
  7120. });
  7121. const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update) : null;
  7122. let reobserveFrame = -1;
  7123. let resizeObserver = null;
  7124. if (elementResize) {
  7125. resizeObserver = new ResizeObserver((_ref) => {
  7126. let [firstEntry] = _ref;
  7127. if (firstEntry && firstEntry.target === referenceEl && resizeObserver) {
  7128. resizeObserver.unobserve(floating);
  7129. cancelAnimationFrame(reobserveFrame);
  7130. reobserveFrame = requestAnimationFrame(() => {
  7131. resizeObserver && resizeObserver.observe(floating);
  7132. });
  7133. }
  7134. update();
  7135. });
  7136. if (referenceEl && !animationFrame) {
  7137. resizeObserver.observe(referenceEl);
  7138. }
  7139. resizeObserver.observe(floating);
  7140. }
  7141. let frameId;
  7142. let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
  7143. if (animationFrame) {
  7144. frameLoop();
  7145. }
  7146. function frameLoop() {
  7147. const nextRefRect = getBoundingClientRect(reference);
  7148. if (prevRefRect && (nextRefRect.x !== prevRefRect.x || nextRefRect.y !== prevRefRect.y || nextRefRect.width !== prevRefRect.width || nextRefRect.height !== prevRefRect.height)) {
  7149. update();
  7150. }
  7151. prevRefRect = nextRefRect;
  7152. frameId = requestAnimationFrame(frameLoop);
  7153. }
  7154. update();
  7155. return () => {
  7156. ancestors.forEach((ancestor) => {
  7157. ancestorScroll && ancestor.removeEventListener("scroll", update);
  7158. ancestorResize && ancestor.removeEventListener("resize", update);
  7159. });
  7160. cleanupIo && cleanupIo();
  7161. resizeObserver && resizeObserver.disconnect();
  7162. resizeObserver = null;
  7163. if (animationFrame) {
  7164. cancelAnimationFrame(frameId);
  7165. }
  7166. };
  7167. }
  7168. var computePosition2 = (reference, floating, options) => {
  7169. const cache = /* @__PURE__ */ new Map();
  7170. const mergedOptions = {
  7171. platform,
  7172. ...options
  7173. };
  7174. const platformWithCache = {
  7175. ...mergedOptions.platform,
  7176. _c: cache
  7177. };
  7178. return computePosition(reference, floating, {
  7179. ...mergedOptions,
  7180. platform: platformWithCache
  7181. });
  7182. };
  7183. function src_default7(Alpine3) {
  7184. Alpine3.magic("anchor", (el) => {
  7185. if (!el._x_anchor)
  7186. throw "Alpine: No x-anchor directive found on element using $anchor...";
  7187. return el._x_anchor;
  7188. });
  7189. Alpine3.interceptClone((from, to) => {
  7190. if (from && from._x_anchor && !to._x_anchor) {
  7191. to._x_anchor = from._x_anchor;
  7192. }
  7193. });
  7194. Alpine3.directive("anchor", Alpine3.skipDuringClone((el, { expression, modifiers, value }, { cleanup: cleanup2, evaluate: evaluate22 }) => {
  7195. let { placement, offsetValue, unstyled } = getOptions(modifiers);
  7196. el._x_anchor = Alpine3.reactive({ x: 0, y: 0 });
  7197. let reference = evaluate22(expression);
  7198. if (!reference)
  7199. throw "Alpine: no element provided to x-anchor...";
  7200. let compute = () => {
  7201. let previousValue;
  7202. computePosition2(reference, el, {
  7203. placement,
  7204. middleware: [flip(), shift({ padding: 5 }), offset(offsetValue)]
  7205. }).then(({ x, y }) => {
  7206. unstyled || setStyles2(el, x, y);
  7207. if (JSON.stringify({ x, y }) !== previousValue) {
  7208. el._x_anchor.x = x;
  7209. el._x_anchor.y = y;
  7210. }
  7211. previousValue = JSON.stringify({ x, y });
  7212. });
  7213. };
  7214. let release2 = autoUpdate(reference, el, () => compute());
  7215. cleanup2(() => release2());
  7216. }, (el, { expression, modifiers, value }, { cleanup: cleanup2, evaluate: evaluate22 }) => {
  7217. let { placement, offsetValue, unstyled } = getOptions(modifiers);
  7218. if (el._x_anchor) {
  7219. unstyled || setStyles2(el, el._x_anchor.x, el._x_anchor.y);
  7220. }
  7221. }));
  7222. }
  7223. function setStyles2(el, x, y) {
  7224. Object.assign(el.style, {
  7225. left: x + "px",
  7226. top: y + "px",
  7227. position: "absolute"
  7228. });
  7229. }
  7230. function getOptions(modifiers) {
  7231. let positions = ["top", "top-start", "top-end", "right", "right-start", "right-end", "bottom", "bottom-start", "bottom-end", "left", "left-start", "left-end"];
  7232. let placement = positions.find((i) => modifiers.includes(i));
  7233. let offsetValue = 0;
  7234. if (modifiers.includes("offset")) {
  7235. let idx = modifiers.findIndex((i) => i === "offset");
  7236. offsetValue = modifiers[idx + 1] !== void 0 ? Number(modifiers[idx + 1]) : offsetValue;
  7237. }
  7238. let unstyled = modifiers.includes("no-style");
  7239. return { placement, offsetValue, unstyled };
  7240. }
  7241. var module_default7 = src_default7;
  7242. // js/plugins/navigate/history.js
  7243. var Snapshot = class {
  7244. constructor(url, html) {
  7245. this.url = url;
  7246. this.html = html;
  7247. }
  7248. };
  7249. var snapshotCache = {
  7250. currentKey: null,
  7251. currentUrl: null,
  7252. keys: [],
  7253. lookup: {},
  7254. limit: 10,
  7255. has(location) {
  7256. return this.lookup[location] !== void 0;
  7257. },
  7258. retrieve(location) {
  7259. let snapshot = this.lookup[location];
  7260. if (snapshot === void 0)
  7261. throw "No back button cache found for current location: " + location;
  7262. return snapshot;
  7263. },
  7264. replace(key, snapshot) {
  7265. if (this.has(key)) {
  7266. this.lookup[key] = snapshot;
  7267. } else {
  7268. this.push(key, snapshot);
  7269. }
  7270. },
  7271. push(key, snapshot) {
  7272. this.lookup[key] = snapshot;
  7273. let index = this.keys.indexOf(key);
  7274. if (index > -1)
  7275. this.keys.splice(index, 1);
  7276. this.keys.unshift(key);
  7277. this.trim();
  7278. },
  7279. trim() {
  7280. for (let key of this.keys.splice(this.limit)) {
  7281. delete this.lookup[key];
  7282. }
  7283. }
  7284. };
  7285. function updateCurrentPageHtmlInHistoryStateForLaterBackButtonClicks() {
  7286. let url = new URL(window.location.href, document.baseURI);
  7287. replaceUrl(url, document.documentElement.outerHTML);
  7288. }
  7289. function updateCurrentPageHtmlInSnapshotCacheForLaterBackButtonClicks(key, url) {
  7290. let html = document.documentElement.outerHTML;
  7291. snapshotCache.replace(key, new Snapshot(url, html));
  7292. }
  7293. function whenTheBackOrForwardButtonIsClicked(registerFallback, handleHtml) {
  7294. let fallback2;
  7295. registerFallback((i) => fallback2 = i);
  7296. window.addEventListener("popstate", (e) => {
  7297. let state = e.state || {};
  7298. let alpine = state.alpine || {};
  7299. if (Object.keys(state).length === 0)
  7300. return;
  7301. if (!alpine.snapshotIdx)
  7302. return;
  7303. if (snapshotCache.has(alpine.snapshotIdx)) {
  7304. let snapshot = snapshotCache.retrieve(alpine.snapshotIdx);
  7305. handleHtml(snapshot.html, snapshot.url, snapshotCache.currentUrl, snapshotCache.currentKey);
  7306. } else {
  7307. fallback2(alpine.url);
  7308. }
  7309. });
  7310. }
  7311. function updateUrlAndStoreLatestHtmlForFutureBackButtons(html, destination) {
  7312. pushUrl(destination, html);
  7313. }
  7314. function pushUrl(url, html) {
  7315. updateUrl("pushState", url, html);
  7316. }
  7317. function replaceUrl(url, html) {
  7318. updateUrl("replaceState", url, html);
  7319. }
  7320. function updateUrl(method, url, html) {
  7321. let key = url.toString() + "-" + Math.random();
  7322. method === "pushState" ? snapshotCache.push(key, new Snapshot(url, html)) : snapshotCache.replace(key = snapshotCache.currentKey ?? key, new Snapshot(url, html));
  7323. let state = history.state || {};
  7324. if (!state.alpine)
  7325. state.alpine = {};
  7326. state.alpine.snapshotIdx = key;
  7327. state.alpine.url = url.toString();
  7328. try {
  7329. history[method](state, JSON.stringify(document.title), url);
  7330. snapshotCache.currentKey = key;
  7331. snapshotCache.currentUrl = url;
  7332. } catch (error2) {
  7333. if (error2 instanceof DOMException && error2.name === "SecurityError") {
  7334. console.error("Livewire: You can't use wire:navigate with a link to a different root domain: " + url);
  7335. }
  7336. console.error(error2);
  7337. }
  7338. }
  7339. // js/plugins/navigate/links.js
  7340. function whenThisLinkIsPressed(el, callback) {
  7341. let isProgrammaticClick = (e) => !e.isTrusted;
  7342. let isNotPlainLeftClick = (e) => e.which > 1 || e.altKey || e.ctrlKey || e.metaKey || e.shiftKey;
  7343. let isNotPlainEnterKey = (e) => e.which !== 13 || e.altKey || e.ctrlKey || e.metaKey || e.shiftKey;
  7344. el.addEventListener("click", (e) => {
  7345. if (isProgrammaticClick(e)) {
  7346. e.preventDefault();
  7347. callback((whenReleased) => whenReleased());
  7348. return;
  7349. }
  7350. if (isNotPlainLeftClick(e))
  7351. return;
  7352. e.preventDefault();
  7353. });
  7354. el.addEventListener("mousedown", (e) => {
  7355. if (isNotPlainLeftClick(e))
  7356. return;
  7357. e.preventDefault();
  7358. callback((whenReleased) => {
  7359. let handler4 = (e2) => {
  7360. e2.preventDefault();
  7361. whenReleased();
  7362. el.removeEventListener("mouseup", handler4);
  7363. };
  7364. el.addEventListener("mouseup", handler4);
  7365. });
  7366. });
  7367. el.addEventListener("keydown", (e) => {
  7368. if (isNotPlainEnterKey(e))
  7369. return;
  7370. e.preventDefault();
  7371. callback((whenReleased) => whenReleased());
  7372. });
  7373. }
  7374. function whenThisLinkIsHoveredFor(el, ms = 60, callback) {
  7375. el.addEventListener("mouseenter", (e) => {
  7376. let timeout = setTimeout(() => {
  7377. callback(e);
  7378. }, ms);
  7379. let handler4 = () => {
  7380. clearTimeout(timeout);
  7381. el.removeEventListener("mouseleave", handler4);
  7382. };
  7383. el.addEventListener("mouseleave", handler4);
  7384. });
  7385. }
  7386. function extractDestinationFromLink(linkEl) {
  7387. return createUrlObjectFromString(linkEl.getAttribute("href"));
  7388. }
  7389. function createUrlObjectFromString(urlString) {
  7390. return urlString !== null && new URL(urlString, document.baseURI);
  7391. }
  7392. function getUriStringFromUrlObject(urlObject) {
  7393. return urlObject.pathname + urlObject.search + urlObject.hash;
  7394. }
  7395. // js/plugins/navigate/fetch.js
  7396. function fetchHtml(destination, callback) {
  7397. let uri = getUriStringFromUrlObject(destination);
  7398. performFetch(uri, (html, finalDestination) => {
  7399. callback(html, finalDestination);
  7400. });
  7401. }
  7402. function performFetch(uri, callback) {
  7403. let options = {
  7404. headers: {
  7405. "X-Livewire-Navigate": ""
  7406. }
  7407. };
  7408. trigger2("navigate.request", {
  7409. url: uri,
  7410. options
  7411. });
  7412. let finalDestination;
  7413. fetch(uri, options).then((response) => {
  7414. let destination = createUrlObjectFromString(uri);
  7415. finalDestination = createUrlObjectFromString(response.url);
  7416. if (destination.pathname + destination.search === finalDestination.pathname + finalDestination.search) {
  7417. finalDestination.hash = destination.hash;
  7418. }
  7419. return response.text();
  7420. }).then((html) => {
  7421. callback(html, finalDestination);
  7422. });
  7423. }
  7424. // js/plugins/navigate/prefetch.js
  7425. var prefetches = {};
  7426. function prefetchHtml(destination, callback) {
  7427. let uri = getUriStringFromUrlObject(destination);
  7428. if (prefetches[uri])
  7429. return;
  7430. prefetches[uri] = { finished: false, html: null, whenFinished: () => {
  7431. } };
  7432. performFetch(uri, (html, routedUri) => {
  7433. callback(html, routedUri);
  7434. });
  7435. }
  7436. function storeThePrefetchedHtmlForWhenALinkIsClicked(html, destination, finalDestination) {
  7437. let state = prefetches[getUriStringFromUrlObject(destination)];
  7438. state.html = html;
  7439. state.finished = true;
  7440. state.finalDestination = finalDestination;
  7441. state.whenFinished();
  7442. }
  7443. function getPretchedHtmlOr(destination, receive, ifNoPrefetchExists) {
  7444. let uri = getUriStringFromUrlObject(destination);
  7445. if (!prefetches[uri])
  7446. return ifNoPrefetchExists();
  7447. if (prefetches[uri].finished) {
  7448. let html = prefetches[uri].html;
  7449. let finalDestination = prefetches[uri].finalDestination;
  7450. delete prefetches[uri];
  7451. return receive(html, finalDestination);
  7452. } else {
  7453. prefetches[uri].whenFinished = () => {
  7454. let html = prefetches[uri].html;
  7455. let finalDestination = prefetches[uri].finalDestination;
  7456. delete prefetches[uri];
  7457. receive(html, finalDestination);
  7458. };
  7459. }
  7460. }
  7461. // js/plugins/navigate/teleport.js
  7462. function packUpPersistedTeleports(persistedEl) {
  7463. module_default.mutateDom(() => {
  7464. persistedEl.querySelectorAll("[data-teleport-template]").forEach((i) => i._x_teleport.remove());
  7465. });
  7466. }
  7467. function removeAnyLeftOverStaleTeleportTargets(body) {
  7468. module_default.mutateDom(() => {
  7469. body.querySelectorAll("[data-teleport-target]").forEach((i) => i.remove());
  7470. });
  7471. }
  7472. function unPackPersistedTeleports(persistedEl) {
  7473. module_default.walk(persistedEl, (el, skip) => {
  7474. if (!el._x_teleport)
  7475. return;
  7476. el._x_teleportPutBack();
  7477. skip();
  7478. });
  7479. }
  7480. function isTeleportTarget(el) {
  7481. return el.hasAttribute("data-teleport-target");
  7482. }
  7483. // js/plugins/navigate/scroll.js
  7484. function storeScrollInformationInHtmlBeforeNavigatingAway() {
  7485. document.body.setAttribute("data-scroll-x", document.body.scrollLeft);
  7486. document.body.setAttribute("data-scroll-y", document.body.scrollTop);
  7487. document.querySelectorAll(["[x-navigate\\:scroll]", "[wire\\:scroll]"]).forEach((el) => {
  7488. el.setAttribute("data-scroll-x", el.scrollLeft);
  7489. el.setAttribute("data-scroll-y", el.scrollTop);
  7490. });
  7491. }
  7492. function restoreScrollPositionOrScrollToTop() {
  7493. let scroll = (el) => {
  7494. if (!el.hasAttribute("data-scroll-x")) {
  7495. window.scrollTo({ top: 0, left: 0, behavior: "instant" });
  7496. } else {
  7497. el.scrollTo({
  7498. top: Number(el.getAttribute("data-scroll-y")),
  7499. left: Number(el.getAttribute("data-scroll-x")),
  7500. behavior: "instant"
  7501. });
  7502. el.removeAttribute("data-scroll-x");
  7503. el.removeAttribute("data-scroll-y");
  7504. }
  7505. };
  7506. queueMicrotask(() => {
  7507. queueMicrotask(() => {
  7508. scroll(document.body);
  7509. document.querySelectorAll(["[x-navigate\\:scroll]", "[wire\\:scroll]"]).forEach(scroll);
  7510. });
  7511. });
  7512. }
  7513. // js/plugins/navigate/persist.js
  7514. var els = {};
  7515. function storePersistantElementsForLater(callback) {
  7516. els = {};
  7517. document.querySelectorAll("[x-persist]").forEach((i) => {
  7518. els[i.getAttribute("x-persist")] = i;
  7519. callback(i);
  7520. module_default.mutateDom(() => {
  7521. i.remove();
  7522. });
  7523. });
  7524. }
  7525. function putPersistantElementsBack(callback) {
  7526. let usedPersists = [];
  7527. document.querySelectorAll("[x-persist]").forEach((i) => {
  7528. let old = els[i.getAttribute("x-persist")];
  7529. if (!old)
  7530. return;
  7531. usedPersists.push(i.getAttribute("x-persist"));
  7532. old._x_wasPersisted = true;
  7533. callback(old, i);
  7534. module_default.mutateDom(() => {
  7535. i.replaceWith(old);
  7536. });
  7537. });
  7538. Object.entries(els).forEach(([key, el]) => {
  7539. if (usedPersists.includes(key))
  7540. return;
  7541. module_default.destroyTree(el);
  7542. });
  7543. els = {};
  7544. }
  7545. function isPersistedElement(el) {
  7546. return el.hasAttribute("x-persist");
  7547. }
  7548. // js/plugins/navigate/bar.js
  7549. var import_nprogress = __toESM(require_nprogress());
  7550. import_nprogress.default.configure({
  7551. minimum: 0.1,
  7552. trickleSpeed: 200,
  7553. showSpinner: false,
  7554. parent: "body"
  7555. });
  7556. injectStyles();
  7557. var inProgress = false;
  7558. function showAndStartProgressBar() {
  7559. inProgress = true;
  7560. setTimeout(() => {
  7561. if (!inProgress)
  7562. return;
  7563. import_nprogress.default.start();
  7564. }, 150);
  7565. }
  7566. function finishAndHideProgressBar() {
  7567. inProgress = false;
  7568. import_nprogress.default.done();
  7569. }
  7570. function removeAnyLeftOverStaleProgressBars() {
  7571. import_nprogress.default.remove();
  7572. }
  7573. function injectStyles() {
  7574. let style = document.createElement("style");
  7575. style.innerHTML = `/* Make clicks pass-through */
  7576. #nprogress {
  7577. pointer-events: none;
  7578. }
  7579. #nprogress .bar {
  7580. background: var(--livewire-progress-bar-color, #29d);
  7581. position: fixed;
  7582. z-index: 1031;
  7583. top: 0;
  7584. left: 0;
  7585. width: 100%;
  7586. height: 2px;
  7587. }
  7588. /* Fancy blur effect */
  7589. #nprogress .peg {
  7590. display: block;
  7591. position: absolute;
  7592. right: 0px;
  7593. width: 100px;
  7594. height: 100%;
  7595. box-shadow: 0 0 10px var(--livewire-progress-bar-color, #29d), 0 0 5px var(--livewire-progress-bar-color, #29d);
  7596. opacity: 1.0;
  7597. -webkit-transform: rotate(3deg) translate(0px, -4px);
  7598. -ms-transform: rotate(3deg) translate(0px, -4px);
  7599. transform: rotate(3deg) translate(0px, -4px);
  7600. }
  7601. /* Remove these to get rid of the spinner */
  7602. #nprogress .spinner {
  7603. display: block;
  7604. position: fixed;
  7605. z-index: 1031;
  7606. top: 15px;
  7607. right: 15px;
  7608. }
  7609. #nprogress .spinner-icon {
  7610. width: 18px;
  7611. height: 18px;
  7612. box-sizing: border-box;
  7613. border: solid 2px transparent;
  7614. border-top-color: var(--livewire-progress-bar-color, #29d);
  7615. border-left-color: var(--livewire-progress-bar-color, #29d);
  7616. border-radius: 50%;
  7617. -webkit-animation: nprogress-spinner 400ms linear infinite;
  7618. animation: nprogress-spinner 400ms linear infinite;
  7619. }
  7620. .nprogress-custom-parent {
  7621. overflow: hidden;
  7622. position: relative;
  7623. }
  7624. .nprogress-custom-parent #nprogress .spinner,
  7625. .nprogress-custom-parent #nprogress .bar {
  7626. position: absolute;
  7627. }
  7628. @-webkit-keyframes nprogress-spinner {
  7629. 0% { -webkit-transform: rotate(0deg); }
  7630. 100% { -webkit-transform: rotate(360deg); }
  7631. }
  7632. @keyframes nprogress-spinner {
  7633. 0% { transform: rotate(0deg); }
  7634. 100% { transform: rotate(360deg); }
  7635. }
  7636. `;
  7637. let nonce2 = getNonce();
  7638. if (nonce2)
  7639. style.nonce = nonce2;
  7640. document.head.appendChild(style);
  7641. }
  7642. // js/plugins/navigate/popover.js
  7643. function packUpPersistedPopovers(persistedEl) {
  7644. if (!isPopoverSupported())
  7645. return;
  7646. persistedEl.querySelectorAll(":popover-open").forEach((el) => {
  7647. el.setAttribute("data-navigate-popover-open", "");
  7648. let animations = el.getAnimations();
  7649. el._pausedAnimations = animations.map((animation) => ({
  7650. keyframes: animation.effect.getKeyframes(),
  7651. options: {
  7652. duration: animation.effect.getTiming().duration,
  7653. easing: animation.effect.getTiming().easing,
  7654. fill: animation.effect.getTiming().fill,
  7655. iterations: animation.effect.getTiming().iterations
  7656. },
  7657. currentTime: animation.currentTime,
  7658. playState: animation.playState
  7659. }));
  7660. animations.forEach((i) => i.pause());
  7661. });
  7662. }
  7663. function unPackPersistedPopovers(persistedEl) {
  7664. if (!isPopoverSupported())
  7665. return;
  7666. persistedEl.querySelectorAll("[data-navigate-popover-open]").forEach((el) => {
  7667. el.removeAttribute("data-navigate-popover-open");
  7668. queueMicrotask(() => {
  7669. if (!el.isConnected)
  7670. return;
  7671. el.showPopover();
  7672. el.getAnimations().forEach((i) => i.finish());
  7673. if (el._pausedAnimations) {
  7674. el._pausedAnimations.forEach(({ keyframes, options, currentTime, now, playState }) => {
  7675. let animation = el.animate(keyframes, options);
  7676. animation.currentTime = currentTime;
  7677. });
  7678. delete el._pausedAnimations;
  7679. }
  7680. });
  7681. });
  7682. }
  7683. function isPopoverSupported() {
  7684. return typeof document.createElement("div").showPopover === "function";
  7685. }
  7686. // js/plugins/navigate/page.js
  7687. var oldBodyScriptTagHashes = [];
  7688. var attributesExemptFromScriptTagHashing = [
  7689. "data-csrf",
  7690. "aria-hidden"
  7691. ];
  7692. function swapCurrentPageWithNewHtml(html, andThen) {
  7693. let newDocument = new DOMParser().parseFromString(html, "text/html");
  7694. let newHtml = newDocument.documentElement;
  7695. let newBody = document.adoptNode(newDocument.body);
  7696. let newHead = document.adoptNode(newDocument.head);
  7697. oldBodyScriptTagHashes = oldBodyScriptTagHashes.concat(Array.from(document.body.querySelectorAll("script")).map((i) => {
  7698. return simpleHash(ignoreAttributes(i.outerHTML, attributesExemptFromScriptTagHashing));
  7699. }));
  7700. let afterRemoteScriptsHaveLoaded = () => {
  7701. };
  7702. replaceHtmlAttributes(newHtml);
  7703. mergeNewHead(newHead).finally(() => {
  7704. afterRemoteScriptsHaveLoaded();
  7705. });
  7706. prepNewBodyScriptTagsToRun(newBody, oldBodyScriptTagHashes);
  7707. let oldBody = document.body;
  7708. document.body.replaceWith(newBody);
  7709. Alpine.destroyTree(oldBody);
  7710. andThen((i) => afterRemoteScriptsHaveLoaded = i);
  7711. }
  7712. function prepNewBodyScriptTagsToRun(newBody, oldBodyScriptTagHashes2) {
  7713. newBody.querySelectorAll("script").forEach((i) => {
  7714. if (i.hasAttribute("data-navigate-once")) {
  7715. let hash = simpleHash(ignoreAttributes(i.outerHTML, attributesExemptFromScriptTagHashing));
  7716. if (oldBodyScriptTagHashes2.includes(hash))
  7717. return;
  7718. }
  7719. i.replaceWith(cloneScriptTag(i));
  7720. });
  7721. }
  7722. function replaceHtmlAttributes(newHtmlElement) {
  7723. let currentHtmlElement = document.documentElement;
  7724. Array.from(newHtmlElement.attributes).forEach((attr) => {
  7725. const name = attr.name;
  7726. const value = attr.value;
  7727. if (currentHtmlElement.getAttribute(name) !== value) {
  7728. currentHtmlElement.setAttribute(name, value);
  7729. }
  7730. });
  7731. Array.from(currentHtmlElement.attributes).forEach((attr) => {
  7732. if (!newHtmlElement.hasAttribute(attr.name)) {
  7733. currentHtmlElement.removeAttribute(attr.name);
  7734. }
  7735. });
  7736. }
  7737. function mergeNewHead(newHead) {
  7738. let children = Array.from(document.head.children);
  7739. let headChildrenHtmlLookup = children.map((i) => i.outerHTML);
  7740. let garbageCollector = document.createDocumentFragment();
  7741. let touchedHeadElements = [];
  7742. let remoteScriptsPromises = [];
  7743. for (let child of Array.from(newHead.children)) {
  7744. if (isAsset(child)) {
  7745. if (!headChildrenHtmlLookup.includes(child.outerHTML)) {
  7746. if (isTracked(child)) {
  7747. if (ifTheQueryStringChangedSinceLastRequest(child, children)) {
  7748. setTimeout(() => window.location.reload());
  7749. }
  7750. }
  7751. if (isScript(child)) {
  7752. try {
  7753. remoteScriptsPromises.push(injectScriptTagAndWaitForItToFullyLoad(cloneScriptTag(child)));
  7754. } catch (error2) {
  7755. }
  7756. } else {
  7757. document.head.appendChild(child);
  7758. }
  7759. } else {
  7760. garbageCollector.appendChild(child);
  7761. }
  7762. touchedHeadElements.push(child);
  7763. }
  7764. }
  7765. for (let child of Array.from(document.head.children)) {
  7766. if (!isAsset(child))
  7767. child.remove();
  7768. }
  7769. for (let child of Array.from(newHead.children)) {
  7770. if (child.tagName.toLowerCase() === "noscript")
  7771. continue;
  7772. document.head.appendChild(child);
  7773. }
  7774. return Promise.all(remoteScriptsPromises);
  7775. }
  7776. async function injectScriptTagAndWaitForItToFullyLoad(script) {
  7777. return new Promise((resolve, reject) => {
  7778. if (script.src) {
  7779. script.onload = () => resolve();
  7780. script.onerror = () => reject();
  7781. } else {
  7782. resolve();
  7783. }
  7784. document.head.appendChild(script);
  7785. });
  7786. }
  7787. function cloneScriptTag(el) {
  7788. let script = document.createElement("script");
  7789. script.textContent = el.textContent;
  7790. script.async = el.async;
  7791. for (let attr of el.attributes) {
  7792. script.setAttribute(attr.name, attr.value);
  7793. }
  7794. return script;
  7795. }
  7796. function isTracked(el) {
  7797. return el.hasAttribute("data-navigate-track");
  7798. }
  7799. function ifTheQueryStringChangedSinceLastRequest(el, currentHeadChildren) {
  7800. let [uri, queryString] = extractUriAndQueryString(el);
  7801. return currentHeadChildren.some((child) => {
  7802. if (!isTracked(child))
  7803. return false;
  7804. let [currentUri, currentQueryString] = extractUriAndQueryString(child);
  7805. if (currentUri === uri && queryString !== currentQueryString)
  7806. return true;
  7807. });
  7808. }
  7809. function extractUriAndQueryString(el) {
  7810. let url = isScript(el) ? el.src : el.href;
  7811. return url.split("?");
  7812. }
  7813. function isAsset(el) {
  7814. return el.tagName.toLowerCase() === "link" && el.getAttribute("rel").toLowerCase() === "stylesheet" || el.tagName.toLowerCase() === "style" || el.tagName.toLowerCase() === "script";
  7815. }
  7816. function isScript(el) {
  7817. return el.tagName.toLowerCase() === "script";
  7818. }
  7819. function simpleHash(str) {
  7820. return str.split("").reduce((a, b) => {
  7821. a = (a << 5) - a + b.charCodeAt(0);
  7822. return a & a;
  7823. }, 0);
  7824. }
  7825. function ignoreAttributes(subject, attributesToRemove) {
  7826. let result = subject;
  7827. attributesToRemove.forEach((attr) => {
  7828. const regex = new RegExp(`${attr}="[^"]*"|${attr}='[^']*'`, "g");
  7829. result = result.replace(regex, "");
  7830. });
  7831. result = result.replaceAll(" ", "");
  7832. return result.trim();
  7833. }
  7834. // js/plugins/navigate/index.js
  7835. var enablePersist = true;
  7836. var showProgressBar = true;
  7837. var restoreScroll = true;
  7838. var autofocus = false;
  7839. function navigate_default(Alpine3) {
  7840. Alpine3.navigate = (url) => {
  7841. let destination = createUrlObjectFromString(url);
  7842. let prevented = fireEventForOtherLibrariesToHookInto("alpine:navigate", {
  7843. url: destination,
  7844. history: false,
  7845. cached: false
  7846. });
  7847. if (prevented)
  7848. return;
  7849. navigateTo(destination);
  7850. };
  7851. Alpine3.navigate.disableProgressBar = () => {
  7852. showProgressBar = false;
  7853. };
  7854. Alpine3.addInitSelector(() => `[${Alpine3.prefixed("navigate")}]`);
  7855. Alpine3.directive("navigate", (el, { modifiers }) => {
  7856. let shouldPrefetchOnHover = modifiers.includes("hover");
  7857. shouldPrefetchOnHover && whenThisLinkIsHoveredFor(el, 60, () => {
  7858. let destination = extractDestinationFromLink(el);
  7859. if (!destination)
  7860. return;
  7861. prefetchHtml(destination, (html, finalDestination) => {
  7862. storeThePrefetchedHtmlForWhenALinkIsClicked(html, destination, finalDestination);
  7863. });
  7864. });
  7865. whenThisLinkIsPressed(el, (whenItIsReleased) => {
  7866. let destination = extractDestinationFromLink(el);
  7867. if (!destination)
  7868. return;
  7869. prefetchHtml(destination, (html, finalDestination) => {
  7870. storeThePrefetchedHtmlForWhenALinkIsClicked(html, destination, finalDestination);
  7871. });
  7872. whenItIsReleased(() => {
  7873. let prevented = fireEventForOtherLibrariesToHookInto("alpine:navigate", {
  7874. url: destination,
  7875. history: false,
  7876. cached: false
  7877. });
  7878. if (prevented)
  7879. return;
  7880. navigateTo(destination);
  7881. });
  7882. });
  7883. });
  7884. function navigateTo(destination, shouldPushToHistoryState = true) {
  7885. showProgressBar && showAndStartProgressBar();
  7886. fetchHtmlOrUsePrefetchedHtml(destination, (html, finalDestination) => {
  7887. fireEventForOtherLibrariesToHookInto("alpine:navigating");
  7888. restoreScroll && storeScrollInformationInHtmlBeforeNavigatingAway();
  7889. showProgressBar && finishAndHideProgressBar();
  7890. cleanupAlpineElementsOnThePageThatArentInsideAPersistedElement();
  7891. updateCurrentPageHtmlInHistoryStateForLaterBackButtonClicks();
  7892. preventAlpineFromPickingUpDomChanges(Alpine3, (andAfterAllThis) => {
  7893. enablePersist && storePersistantElementsForLater((persistedEl) => {
  7894. packUpPersistedTeleports(persistedEl);
  7895. packUpPersistedPopovers(persistedEl);
  7896. });
  7897. if (shouldPushToHistoryState) {
  7898. updateUrlAndStoreLatestHtmlForFutureBackButtons(html, finalDestination);
  7899. } else {
  7900. replaceUrl(finalDestination, html);
  7901. }
  7902. swapCurrentPageWithNewHtml(html, (afterNewScriptsAreDoneLoading) => {
  7903. removeAnyLeftOverStaleTeleportTargets(document.body);
  7904. enablePersist && putPersistantElementsBack((persistedEl, newStub) => {
  7905. unPackPersistedTeleports(persistedEl);
  7906. unPackPersistedPopovers(persistedEl);
  7907. });
  7908. restoreScrollPositionOrScrollToTop();
  7909. afterNewScriptsAreDoneLoading(() => {
  7910. andAfterAllThis(() => {
  7911. setTimeout(() => {
  7912. autofocus && autofocusElementsWithTheAutofocusAttribute();
  7913. });
  7914. nowInitializeAlpineOnTheNewPage(Alpine3);
  7915. fireEventForOtherLibrariesToHookInto("alpine:navigated");
  7916. });
  7917. });
  7918. });
  7919. });
  7920. });
  7921. }
  7922. whenTheBackOrForwardButtonIsClicked((ifThePageBeingVisitedHasntBeenCached) => {
  7923. ifThePageBeingVisitedHasntBeenCached((url) => {
  7924. let destination = createUrlObjectFromString(url);
  7925. let prevented = fireEventForOtherLibrariesToHookInto("alpine:navigate", {
  7926. url: destination,
  7927. history: true,
  7928. cached: false
  7929. });
  7930. if (prevented)
  7931. return;
  7932. let shouldPushToHistoryState = false;
  7933. navigateTo(destination, shouldPushToHistoryState);
  7934. });
  7935. }, (html, url, currentPageUrl, currentPageKey) => {
  7936. let destination = createUrlObjectFromString(url);
  7937. let prevented = fireEventForOtherLibrariesToHookInto("alpine:navigate", {
  7938. url: destination,
  7939. history: true,
  7940. cached: true
  7941. });
  7942. if (prevented)
  7943. return;
  7944. storeScrollInformationInHtmlBeforeNavigatingAway();
  7945. fireEventForOtherLibrariesToHookInto("alpine:navigating");
  7946. updateCurrentPageHtmlInSnapshotCacheForLaterBackButtonClicks(currentPageUrl, currentPageKey);
  7947. preventAlpineFromPickingUpDomChanges(Alpine3, (andAfterAllThis) => {
  7948. enablePersist && storePersistantElementsForLater((persistedEl) => {
  7949. packUpPersistedTeleports(persistedEl);
  7950. packUpPersistedPopovers(persistedEl);
  7951. });
  7952. swapCurrentPageWithNewHtml(html, () => {
  7953. removeAnyLeftOverStaleProgressBars();
  7954. removeAnyLeftOverStaleTeleportTargets(document.body);
  7955. enablePersist && putPersistantElementsBack((persistedEl, newStub) => {
  7956. unPackPersistedTeleports(persistedEl);
  7957. unPackPersistedPopovers(persistedEl);
  7958. });
  7959. restoreScrollPositionOrScrollToTop();
  7960. andAfterAllThis(() => {
  7961. autofocus && autofocusElementsWithTheAutofocusAttribute();
  7962. nowInitializeAlpineOnTheNewPage(Alpine3);
  7963. fireEventForOtherLibrariesToHookInto("alpine:navigated");
  7964. });
  7965. });
  7966. });
  7967. });
  7968. setTimeout(() => {
  7969. fireEventForOtherLibrariesToHookInto("alpine:navigated");
  7970. });
  7971. }
  7972. function fetchHtmlOrUsePrefetchedHtml(fromDestination, callback) {
  7973. getPretchedHtmlOr(fromDestination, callback, () => {
  7974. fetchHtml(fromDestination, callback);
  7975. });
  7976. }
  7977. function preventAlpineFromPickingUpDomChanges(Alpine3, callback) {
  7978. Alpine3.stopObservingMutations();
  7979. callback((afterAllThis) => {
  7980. Alpine3.startObservingMutations();
  7981. queueMicrotask(() => {
  7982. afterAllThis();
  7983. });
  7984. });
  7985. }
  7986. function fireEventForOtherLibrariesToHookInto(name, detail) {
  7987. let event = new CustomEvent(name, {
  7988. cancelable: true,
  7989. bubbles: true,
  7990. detail
  7991. });
  7992. document.dispatchEvent(event);
  7993. return event.defaultPrevented;
  7994. }
  7995. function nowInitializeAlpineOnTheNewPage(Alpine3) {
  7996. Alpine3.initTree(document.body, void 0, (el, skip) => {
  7997. if (el._x_wasPersisted)
  7998. skip();
  7999. });
  8000. }
  8001. function autofocusElementsWithTheAutofocusAttribute() {
  8002. document.querySelector("[autofocus]") && document.querySelector("[autofocus]").focus();
  8003. }
  8004. function cleanupAlpineElementsOnThePageThatArentInsideAPersistedElement() {
  8005. let walker = function(root, callback) {
  8006. Alpine.walk(root, (el, skip) => {
  8007. if (isPersistedElement(el))
  8008. skip();
  8009. if (isTeleportTarget(el))
  8010. skip();
  8011. else
  8012. callback(el, skip);
  8013. });
  8014. };
  8015. Alpine.destroyTree(document.body, walker);
  8016. }
  8017. // js/plugins/history/index.js
  8018. function history2(Alpine3) {
  8019. Alpine3.magic("queryString", (el, { interceptor: interceptor2 }) => {
  8020. let alias;
  8021. let alwaysShow = false;
  8022. let usePush = false;
  8023. return interceptor2((initialSeedValue, getter, setter, path, key) => {
  8024. let queryKey = alias || path;
  8025. let { initial, replace: replace2, push: push2, pop } = track2(queryKey, initialSeedValue, alwaysShow);
  8026. setter(initial);
  8027. if (!usePush) {
  8028. Alpine3.effect(() => replace2(getter()));
  8029. } else {
  8030. Alpine3.effect(() => push2(getter()));
  8031. pop(async (newValue) => {
  8032. setter(newValue);
  8033. let tillTheEndOfTheMicrotaskQueue = () => Promise.resolve();
  8034. await tillTheEndOfTheMicrotaskQueue();
  8035. });
  8036. }
  8037. return initial;
  8038. }, (func) => {
  8039. func.alwaysShow = () => {
  8040. alwaysShow = true;
  8041. return func;
  8042. };
  8043. func.usePush = () => {
  8044. usePush = true;
  8045. return func;
  8046. };
  8047. func.as = (key) => {
  8048. alias = key;
  8049. return func;
  8050. };
  8051. });
  8052. });
  8053. Alpine3.history = { track: track2 };
  8054. }
  8055. function track2(name, initialSeedValue, alwaysShow = false, except = null) {
  8056. let { has: has2, get: get3, set: set3, remove } = queryStringUtils();
  8057. let url = new URL(window.location.href);
  8058. let isInitiallyPresentInUrl = has2(url, name);
  8059. let initialValue = isInitiallyPresentInUrl ? get3(url, name) : initialSeedValue;
  8060. let initialValueMemo = JSON.stringify(initialValue);
  8061. let exceptValueMemo = [false, null, void 0].includes(except) ? initialSeedValue : JSON.stringify(except);
  8062. let hasReturnedToInitialValue = (newValue) => JSON.stringify(newValue) === initialValueMemo;
  8063. let hasReturnedToExceptValue = (newValue) => JSON.stringify(newValue) === exceptValueMemo;
  8064. if (alwaysShow)
  8065. url = set3(url, name, initialValue);
  8066. replace(url, name, { value: initialValue });
  8067. let lock = false;
  8068. let update = (strategy, newValue) => {
  8069. if (lock)
  8070. return;
  8071. let url2 = new URL(window.location.href);
  8072. if (!alwaysShow && !isInitiallyPresentInUrl && hasReturnedToInitialValue(newValue)) {
  8073. url2 = remove(url2, name);
  8074. } else if (newValue === void 0) {
  8075. url2 = remove(url2, name);
  8076. } else if (!alwaysShow && hasReturnedToExceptValue(newValue)) {
  8077. url2 = remove(url2, name);
  8078. } else {
  8079. url2 = set3(url2, name, newValue);
  8080. }
  8081. strategy(url2, name, { value: newValue });
  8082. };
  8083. return {
  8084. initial: initialValue,
  8085. replace(newValue) {
  8086. update(replace, newValue);
  8087. },
  8088. push(newValue) {
  8089. update(push, newValue);
  8090. },
  8091. pop(receiver) {
  8092. let handler4 = (e) => {
  8093. if (!e.state || !e.state.alpine)
  8094. return;
  8095. Object.entries(e.state.alpine).forEach(([iName, { value: newValue }]) => {
  8096. if (iName !== name)
  8097. return;
  8098. lock = true;
  8099. let result = receiver(newValue);
  8100. if (result instanceof Promise) {
  8101. result.finally(() => lock = false);
  8102. } else {
  8103. lock = false;
  8104. }
  8105. });
  8106. };
  8107. window.addEventListener("popstate", handler4);
  8108. return () => window.removeEventListener("popstate", handler4);
  8109. }
  8110. };
  8111. }
  8112. function replace(url, key, object) {
  8113. let state = window.history.state || {};
  8114. if (!state.alpine)
  8115. state.alpine = {};
  8116. state.alpine[key] = unwrap(object);
  8117. window.history.replaceState(state, "", url.toString());
  8118. }
  8119. function push(url, key, object) {
  8120. let state = window.history.state || {};
  8121. if (!state.alpine)
  8122. state.alpine = {};
  8123. state = { alpine: { ...state.alpine, ...{ [key]: unwrap(object) } } };
  8124. window.history.pushState(state, "", url.toString());
  8125. }
  8126. function unwrap(object) {
  8127. if (object === void 0)
  8128. return void 0;
  8129. return JSON.parse(JSON.stringify(object));
  8130. }
  8131. function queryStringUtils() {
  8132. return {
  8133. has(url, key) {
  8134. let search = url.search;
  8135. if (!search)
  8136. return false;
  8137. let data2 = fromQueryString(search, key);
  8138. return Object.keys(data2).includes(key);
  8139. },
  8140. get(url, key) {
  8141. let search = url.search;
  8142. if (!search)
  8143. return false;
  8144. let data2 = fromQueryString(search, key);
  8145. return data2[key];
  8146. },
  8147. set(url, key, value) {
  8148. let data2 = fromQueryString(url.search, key);
  8149. data2[key] = stripNulls(unwrap(value));
  8150. url.search = toQueryString(data2);
  8151. return url;
  8152. },
  8153. remove(url, key) {
  8154. let data2 = fromQueryString(url.search, key);
  8155. delete data2[key];
  8156. url.search = toQueryString(data2);
  8157. return url;
  8158. }
  8159. };
  8160. }
  8161. function stripNulls(value) {
  8162. if (!isObjecty(value))
  8163. return value;
  8164. for (let key in value) {
  8165. if (value[key] === null)
  8166. delete value[key];
  8167. else
  8168. value[key] = stripNulls(value[key]);
  8169. }
  8170. return value;
  8171. }
  8172. function toQueryString(data2) {
  8173. let isObjecty2 = (subject) => typeof subject === "object" && subject !== null;
  8174. let buildQueryStringEntries = (data3, entries2 = {}, baseKey = "") => {
  8175. Object.entries(data3).forEach(([iKey, iValue]) => {
  8176. let key = baseKey === "" ? iKey : `${baseKey}[${iKey}]`;
  8177. if (iValue === null) {
  8178. entries2[key] = "";
  8179. } else if (!isObjecty2(iValue)) {
  8180. entries2[key] = encodeURIComponent(iValue).replaceAll("%20", "+").replaceAll("%2C", ",");
  8181. } else {
  8182. entries2 = { ...entries2, ...buildQueryStringEntries(iValue, entries2, key) };
  8183. }
  8184. });
  8185. return entries2;
  8186. };
  8187. let entries = buildQueryStringEntries(data2);
  8188. return Object.entries(entries).map(([key, value]) => `${key}=${value}`).join("&");
  8189. }
  8190. function fromQueryString(search, queryKey) {
  8191. search = search.replace("?", "");
  8192. if (search === "")
  8193. return {};
  8194. let insertDotNotatedValueIntoData = (key, value, data3) => {
  8195. let [first2, second, ...rest] = key.split(".");
  8196. if (!second)
  8197. return data3[key] = value;
  8198. if (data3[first2] === void 0) {
  8199. data3[first2] = isNaN(second) ? {} : [];
  8200. }
  8201. insertDotNotatedValueIntoData([second, ...rest].join("."), value, data3[first2]);
  8202. };
  8203. let entries = search.split("&").map((i) => i.split("="));
  8204. let data2 = /* @__PURE__ */ Object.create(null);
  8205. entries.forEach(([key, value]) => {
  8206. if (typeof value == "undefined")
  8207. return;
  8208. value = decodeURIComponent(value.replaceAll("+", "%20"));
  8209. let decodedKey = decodeURIComponent(key);
  8210. let shouldBeHandledAsArray = decodedKey.includes("[") && decodedKey.startsWith(queryKey);
  8211. if (!shouldBeHandledAsArray) {
  8212. data2[key] = value;
  8213. } else {
  8214. let dotNotatedKey = decodedKey.replaceAll("[", ".").replaceAll("]", "");
  8215. insertDotNotatedValueIntoData(dotNotatedKey, value, data2);
  8216. }
  8217. });
  8218. return data2;
  8219. }
  8220. // ../alpine/packages/morph/dist/module.esm.js
  8221. function morph(from, toHtml, options) {
  8222. monkeyPatchDomSetAttributeToAllowAtSymbols();
  8223. let fromEl;
  8224. let toEl;
  8225. let key, lookahead, updating, updated, removing, removed, adding, added;
  8226. function assignOptions(options2 = {}) {
  8227. let defaultGetKey = (el) => el.getAttribute("key");
  8228. let noop = () => {
  8229. };
  8230. updating = options2.updating || noop;
  8231. updated = options2.updated || noop;
  8232. removing = options2.removing || noop;
  8233. removed = options2.removed || noop;
  8234. adding = options2.adding || noop;
  8235. added = options2.added || noop;
  8236. key = options2.key || defaultGetKey;
  8237. lookahead = options2.lookahead || false;
  8238. }
  8239. function patch(from2, to) {
  8240. if (differentElementNamesTypesOrKeys(from2, to)) {
  8241. return swapElements(from2, to);
  8242. }
  8243. let updateChildrenOnly = false;
  8244. let skipChildren = false;
  8245. if (shouldSkipChildren(updating, () => skipChildren = true, from2, to, () => updateChildrenOnly = true))
  8246. return;
  8247. if (from2.nodeType === 1 && window.Alpine) {
  8248. window.Alpine.cloneNode(from2, to);
  8249. if (from2._x_teleport && to._x_teleport) {
  8250. patch(from2._x_teleport, to._x_teleport);
  8251. }
  8252. }
  8253. if (textOrComment(to)) {
  8254. patchNodeValue(from2, to);
  8255. updated(from2, to);
  8256. return;
  8257. }
  8258. if (!updateChildrenOnly) {
  8259. patchAttributes(from2, to);
  8260. }
  8261. updated(from2, to);
  8262. if (!skipChildren) {
  8263. patchChildren(from2, to);
  8264. }
  8265. }
  8266. function differentElementNamesTypesOrKeys(from2, to) {
  8267. return from2.nodeType != to.nodeType || from2.nodeName != to.nodeName || getKey(from2) != getKey(to);
  8268. }
  8269. function swapElements(from2, to) {
  8270. if (shouldSkip(removing, from2))
  8271. return;
  8272. let toCloned = to.cloneNode(true);
  8273. if (shouldSkip(adding, toCloned))
  8274. return;
  8275. from2.replaceWith(toCloned);
  8276. removed(from2);
  8277. added(toCloned);
  8278. }
  8279. function patchNodeValue(from2, to) {
  8280. let value = to.nodeValue;
  8281. if (from2.nodeValue !== value) {
  8282. from2.nodeValue = value;
  8283. }
  8284. }
  8285. function patchAttributes(from2, to) {
  8286. if (from2._x_transitioning)
  8287. return;
  8288. if (from2._x_isShown && !to._x_isShown) {
  8289. return;
  8290. }
  8291. if (!from2._x_isShown && to._x_isShown) {
  8292. return;
  8293. }
  8294. let domAttributes = Array.from(from2.attributes);
  8295. let toAttributes = Array.from(to.attributes);
  8296. for (let i = domAttributes.length - 1; i >= 0; i--) {
  8297. let name = domAttributes[i].name;
  8298. if (!to.hasAttribute(name)) {
  8299. from2.removeAttribute(name);
  8300. }
  8301. }
  8302. for (let i = toAttributes.length - 1; i >= 0; i--) {
  8303. let name = toAttributes[i].name;
  8304. let value = toAttributes[i].value;
  8305. if (from2.getAttribute(name) !== value) {
  8306. from2.setAttribute(name, value);
  8307. }
  8308. }
  8309. }
  8310. function patchChildren(from2, to) {
  8311. let fromKeys = keyToMap(from2.children);
  8312. let fromKeyHoldovers = {};
  8313. let currentTo = getFirstNode(to);
  8314. let currentFrom = getFirstNode(from2);
  8315. while (currentTo) {
  8316. seedingMatchingId(currentTo, currentFrom);
  8317. let toKey = getKey(currentTo);
  8318. let fromKey = getKey(currentFrom);
  8319. if (!currentFrom) {
  8320. if (toKey && fromKeyHoldovers[toKey]) {
  8321. let holdover = fromKeyHoldovers[toKey];
  8322. from2.appendChild(holdover);
  8323. currentFrom = holdover;
  8324. fromKey = getKey(currentFrom);
  8325. } else {
  8326. if (!shouldSkip(adding, currentTo)) {
  8327. let clone2 = currentTo.cloneNode(true);
  8328. from2.appendChild(clone2);
  8329. added(clone2);
  8330. }
  8331. currentTo = getNextSibling(to, currentTo);
  8332. continue;
  8333. }
  8334. }
  8335. let isIf = (node) => node && node.nodeType === 8 && node.textContent === "[if BLOCK]><![endif]";
  8336. let isEnd = (node) => node && node.nodeType === 8 && node.textContent === "[if ENDBLOCK]><![endif]";
  8337. if (isIf(currentTo) && isIf(currentFrom)) {
  8338. let nestedIfCount = 0;
  8339. let fromBlockStart = currentFrom;
  8340. while (currentFrom) {
  8341. let next = getNextSibling(from2, currentFrom);
  8342. if (isIf(next)) {
  8343. nestedIfCount++;
  8344. } else if (isEnd(next) && nestedIfCount > 0) {
  8345. nestedIfCount--;
  8346. } else if (isEnd(next) && nestedIfCount === 0) {
  8347. currentFrom = next;
  8348. break;
  8349. }
  8350. currentFrom = next;
  8351. }
  8352. let fromBlockEnd = currentFrom;
  8353. nestedIfCount = 0;
  8354. let toBlockStart = currentTo;
  8355. while (currentTo) {
  8356. let next = getNextSibling(to, currentTo);
  8357. if (isIf(next)) {
  8358. nestedIfCount++;
  8359. } else if (isEnd(next) && nestedIfCount > 0) {
  8360. nestedIfCount--;
  8361. } else if (isEnd(next) && nestedIfCount === 0) {
  8362. currentTo = next;
  8363. break;
  8364. }
  8365. currentTo = next;
  8366. }
  8367. let toBlockEnd = currentTo;
  8368. let fromBlock = new Block(fromBlockStart, fromBlockEnd);
  8369. let toBlock = new Block(toBlockStart, toBlockEnd);
  8370. patchChildren(fromBlock, toBlock);
  8371. continue;
  8372. }
  8373. if (currentFrom.nodeType === 1 && lookahead && !currentFrom.isEqualNode(currentTo)) {
  8374. let nextToElementSibling = getNextSibling(to, currentTo);
  8375. let found = false;
  8376. while (!found && nextToElementSibling) {
  8377. if (nextToElementSibling.nodeType === 1 && currentFrom.isEqualNode(nextToElementSibling)) {
  8378. found = true;
  8379. currentFrom = addNodeBefore(from2, currentTo, currentFrom);
  8380. fromKey = getKey(currentFrom);
  8381. }
  8382. nextToElementSibling = getNextSibling(to, nextToElementSibling);
  8383. }
  8384. }
  8385. if (toKey !== fromKey) {
  8386. if (!toKey && fromKey) {
  8387. fromKeyHoldovers[fromKey] = currentFrom;
  8388. currentFrom = addNodeBefore(from2, currentTo, currentFrom);
  8389. fromKeyHoldovers[fromKey].remove();
  8390. currentFrom = getNextSibling(from2, currentFrom);
  8391. currentTo = getNextSibling(to, currentTo);
  8392. continue;
  8393. }
  8394. if (toKey && !fromKey) {
  8395. if (fromKeys[toKey]) {
  8396. currentFrom.replaceWith(fromKeys[toKey]);
  8397. currentFrom = fromKeys[toKey];
  8398. fromKey = getKey(currentFrom);
  8399. }
  8400. }
  8401. if (toKey && fromKey) {
  8402. let fromKeyNode = fromKeys[toKey];
  8403. if (fromKeyNode) {
  8404. fromKeyHoldovers[fromKey] = currentFrom;
  8405. currentFrom.replaceWith(fromKeyNode);
  8406. currentFrom = fromKeyNode;
  8407. fromKey = getKey(currentFrom);
  8408. } else {
  8409. fromKeyHoldovers[fromKey] = currentFrom;
  8410. currentFrom = addNodeBefore(from2, currentTo, currentFrom);
  8411. fromKeyHoldovers[fromKey].remove();
  8412. currentFrom = getNextSibling(from2, currentFrom);
  8413. currentTo = getNextSibling(to, currentTo);
  8414. continue;
  8415. }
  8416. }
  8417. }
  8418. let currentFromNext = currentFrom && getNextSibling(from2, currentFrom);
  8419. patch(currentFrom, currentTo);
  8420. currentTo = currentTo && getNextSibling(to, currentTo);
  8421. currentFrom = currentFromNext;
  8422. }
  8423. let removals = [];
  8424. while (currentFrom) {
  8425. if (!shouldSkip(removing, currentFrom))
  8426. removals.push(currentFrom);
  8427. currentFrom = getNextSibling(from2, currentFrom);
  8428. }
  8429. while (removals.length) {
  8430. let domForRemoval = removals.shift();
  8431. domForRemoval.remove();
  8432. removed(domForRemoval);
  8433. }
  8434. }
  8435. function getKey(el) {
  8436. return el && el.nodeType === 1 && key(el);
  8437. }
  8438. function keyToMap(els2) {
  8439. let map = {};
  8440. for (let el of els2) {
  8441. let theKey = getKey(el);
  8442. if (theKey) {
  8443. map[theKey] = el;
  8444. }
  8445. }
  8446. return map;
  8447. }
  8448. function addNodeBefore(parent, node, beforeMe) {
  8449. if (!shouldSkip(adding, node)) {
  8450. let clone2 = node.cloneNode(true);
  8451. parent.insertBefore(clone2, beforeMe);
  8452. added(clone2);
  8453. return clone2;
  8454. }
  8455. return node;
  8456. }
  8457. assignOptions(options);
  8458. fromEl = from;
  8459. toEl = typeof toHtml === "string" ? createElement(toHtml) : toHtml;
  8460. if (window.Alpine && window.Alpine.closestDataStack && !from._x_dataStack) {
  8461. toEl._x_dataStack = window.Alpine.closestDataStack(from);
  8462. toEl._x_dataStack && window.Alpine.cloneNode(from, toEl);
  8463. }
  8464. patch(from, toEl);
  8465. fromEl = void 0;
  8466. toEl = void 0;
  8467. return from;
  8468. }
  8469. morph.step = () => {
  8470. };
  8471. morph.log = () => {
  8472. };
  8473. function shouldSkip(hook, ...args) {
  8474. let skip = false;
  8475. hook(...args, () => skip = true);
  8476. return skip;
  8477. }
  8478. function shouldSkipChildren(hook, skipChildren, ...args) {
  8479. let skip = false;
  8480. hook(...args, () => skip = true, skipChildren);
  8481. return skip;
  8482. }
  8483. var patched = false;
  8484. function createElement(html) {
  8485. const template = document.createElement("template");
  8486. template.innerHTML = html;
  8487. return template.content.firstElementChild;
  8488. }
  8489. function textOrComment(el) {
  8490. return el.nodeType === 3 || el.nodeType === 8;
  8491. }
  8492. var Block = class {
  8493. constructor(start3, end) {
  8494. this.startComment = start3;
  8495. this.endComment = end;
  8496. }
  8497. get children() {
  8498. let children = [];
  8499. let currentNode = this.startComment.nextSibling;
  8500. while (currentNode && currentNode !== this.endComment) {
  8501. children.push(currentNode);
  8502. currentNode = currentNode.nextSibling;
  8503. }
  8504. return children;
  8505. }
  8506. appendChild(child) {
  8507. this.endComment.before(child);
  8508. }
  8509. get firstChild() {
  8510. let first2 = this.startComment.nextSibling;
  8511. if (first2 === this.endComment)
  8512. return;
  8513. return first2;
  8514. }
  8515. nextNode(reference) {
  8516. let next = reference.nextSibling;
  8517. if (next === this.endComment)
  8518. return;
  8519. return next;
  8520. }
  8521. insertBefore(newNode, reference) {
  8522. reference.before(newNode);
  8523. return newNode;
  8524. }
  8525. };
  8526. function getFirstNode(parent) {
  8527. return parent.firstChild;
  8528. }
  8529. function getNextSibling(parent, reference) {
  8530. let next;
  8531. if (parent instanceof Block) {
  8532. next = parent.nextNode(reference);
  8533. } else {
  8534. next = reference.nextSibling;
  8535. }
  8536. return next;
  8537. }
  8538. function monkeyPatchDomSetAttributeToAllowAtSymbols() {
  8539. if (patched)
  8540. return;
  8541. patched = true;
  8542. let original = Element.prototype.setAttribute;
  8543. let hostDiv = document.createElement("div");
  8544. Element.prototype.setAttribute = function newSetAttribute(name, value) {
  8545. if (!name.includes("@")) {
  8546. return original.call(this, name, value);
  8547. }
  8548. hostDiv.innerHTML = `<span ${name}="${value}"></span>`;
  8549. let attr = hostDiv.firstElementChild.getAttributeNode(name);
  8550. hostDiv.firstElementChild.removeAttributeNode(attr);
  8551. this.setAttributeNode(attr);
  8552. };
  8553. }
  8554. function seedingMatchingId(to, from) {
  8555. let fromId = from && from._x_bindings && from._x_bindings.id;
  8556. if (!fromId)
  8557. return;
  8558. if (!to.setAttribute)
  8559. return;
  8560. to.setAttribute("id", fromId);
  8561. to.id = fromId;
  8562. }
  8563. function src_default8(Alpine3) {
  8564. Alpine3.morph = morph;
  8565. }
  8566. var module_default8 = src_default8;
  8567. // ../alpine/packages/mask/dist/module.esm.js
  8568. function src_default9(Alpine3) {
  8569. Alpine3.directive("mask", (el, { value, expression }, { effect: effect3, evaluateLater: evaluateLater2, cleanup: cleanup2 }) => {
  8570. let templateFn = () => expression;
  8571. let lastInputValue = "";
  8572. queueMicrotask(() => {
  8573. if (["function", "dynamic"].includes(value)) {
  8574. let evaluator = evaluateLater2(expression);
  8575. effect3(() => {
  8576. templateFn = (input) => {
  8577. let result;
  8578. Alpine3.dontAutoEvaluateFunctions(() => {
  8579. evaluator((value2) => {
  8580. result = typeof value2 === "function" ? value2(input) : value2;
  8581. }, { scope: {
  8582. "$input": input,
  8583. "$money": formatMoney.bind({ el })
  8584. } });
  8585. });
  8586. return result;
  8587. };
  8588. processInputValue(el, false);
  8589. });
  8590. } else {
  8591. processInputValue(el, false);
  8592. }
  8593. if (el._x_model) {
  8594. if (el._x_model.get() === el.value)
  8595. return;
  8596. if (el._x_model.get() === null && el.value === "")
  8597. return;
  8598. el._x_model.set(el.value);
  8599. }
  8600. });
  8601. const controller = new AbortController();
  8602. cleanup2(() => {
  8603. controller.abort();
  8604. });
  8605. el.addEventListener("input", () => processInputValue(el), {
  8606. signal: controller.signal,
  8607. capture: true
  8608. });
  8609. el.addEventListener("blur", () => processInputValue(el, false), { signal: controller.signal });
  8610. function processInputValue(el2, shouldRestoreCursor = true) {
  8611. let input = el2.value;
  8612. let template = templateFn(input);
  8613. if (!template || template === "false")
  8614. return false;
  8615. if (lastInputValue.length - el2.value.length === 1) {
  8616. return lastInputValue = el2.value;
  8617. }
  8618. let setInput = () => {
  8619. lastInputValue = el2.value = formatInput(input, template);
  8620. };
  8621. if (shouldRestoreCursor) {
  8622. restoreCursorPosition(el2, template, () => {
  8623. setInput();
  8624. });
  8625. } else {
  8626. setInput();
  8627. }
  8628. }
  8629. function formatInput(input, template) {
  8630. if (input === "")
  8631. return "";
  8632. let strippedDownInput = stripDown(template, input);
  8633. let rebuiltInput = buildUp(template, strippedDownInput);
  8634. return rebuiltInput;
  8635. }
  8636. }).before("model");
  8637. }
  8638. function restoreCursorPosition(el, template, callback) {
  8639. let cursorPosition = el.selectionStart;
  8640. let unformattedValue = el.value;
  8641. callback();
  8642. let beforeLeftOfCursorBeforeFormatting = unformattedValue.slice(0, cursorPosition);
  8643. let newPosition = buildUp(template, stripDown(template, beforeLeftOfCursorBeforeFormatting)).length;
  8644. el.setSelectionRange(newPosition, newPosition);
  8645. }
  8646. function stripDown(template, input) {
  8647. let inputToBeStripped = input;
  8648. let output = "";
  8649. let regexes = {
  8650. "9": /[0-9]/,
  8651. "a": /[a-zA-Z]/,
  8652. "*": /[a-zA-Z0-9]/
  8653. };
  8654. let wildcardTemplate = "";
  8655. for (let i = 0; i < template.length; i++) {
  8656. if (["9", "a", "*"].includes(template[i])) {
  8657. wildcardTemplate += template[i];
  8658. continue;
  8659. }
  8660. for (let j = 0; j < inputToBeStripped.length; j++) {
  8661. if (inputToBeStripped[j] === template[i]) {
  8662. inputToBeStripped = inputToBeStripped.slice(0, j) + inputToBeStripped.slice(j + 1);
  8663. break;
  8664. }
  8665. }
  8666. }
  8667. for (let i = 0; i < wildcardTemplate.length; i++) {
  8668. let found = false;
  8669. for (let j = 0; j < inputToBeStripped.length; j++) {
  8670. if (regexes[wildcardTemplate[i]].test(inputToBeStripped[j])) {
  8671. output += inputToBeStripped[j];
  8672. inputToBeStripped = inputToBeStripped.slice(0, j) + inputToBeStripped.slice(j + 1);
  8673. found = true;
  8674. break;
  8675. }
  8676. }
  8677. if (!found)
  8678. break;
  8679. }
  8680. return output;
  8681. }
  8682. function buildUp(template, input) {
  8683. let clean = Array.from(input);
  8684. let output = "";
  8685. for (let i = 0; i < template.length; i++) {
  8686. if (!["9", "a", "*"].includes(template[i])) {
  8687. output += template[i];
  8688. continue;
  8689. }
  8690. if (clean.length === 0)
  8691. break;
  8692. output += clean.shift();
  8693. }
  8694. return output;
  8695. }
  8696. function formatMoney(input, delimiter = ".", thousands, precision = 2) {
  8697. if (input === "-")
  8698. return "-";
  8699. if (/^\D+$/.test(input))
  8700. return "9";
  8701. if (thousands === null || thousands === void 0) {
  8702. thousands = delimiter === "," ? "." : ",";
  8703. }
  8704. let addThousands = (input2, thousands2) => {
  8705. let output = "";
  8706. let counter = 0;
  8707. for (let i = input2.length - 1; i >= 0; i--) {
  8708. if (input2[i] === thousands2)
  8709. continue;
  8710. if (counter === 3) {
  8711. output = input2[i] + thousands2 + output;
  8712. counter = 0;
  8713. } else {
  8714. output = input2[i] + output;
  8715. }
  8716. counter++;
  8717. }
  8718. return output;
  8719. };
  8720. let minus = input.startsWith("-") ? "-" : "";
  8721. let strippedInput = input.replaceAll(new RegExp(`[^0-9\\${delimiter}]`, "g"), "");
  8722. let template = Array.from({ length: strippedInput.split(delimiter)[0].length }).fill("9").join("");
  8723. template = `${minus}${addThousands(template, thousands)}`;
  8724. if (precision > 0 && input.includes(delimiter))
  8725. template += `${delimiter}` + "9".repeat(precision);
  8726. queueMicrotask(() => {
  8727. if (this.el.value.endsWith(delimiter))
  8728. return;
  8729. if (this.el.value[this.el.selectionStart - 1] === delimiter) {
  8730. this.el.setSelectionRange(this.el.selectionStart - 1, this.el.selectionStart - 1);
  8731. }
  8732. });
  8733. return template;
  8734. }
  8735. var module_default9 = src_default9;
  8736. // js/lifecycle.js
  8737. function start2() {
  8738. setTimeout(() => ensureLivewireScriptIsntMisplaced());
  8739. dispatch(document, "livewire:init");
  8740. dispatch(document, "livewire:initializing");
  8741. module_default.plugin(module_default8);
  8742. module_default.plugin(history2);
  8743. module_default.plugin(module_default5);
  8744. module_default.plugin(module_default6);
  8745. module_default.plugin(module_default2);
  8746. module_default.plugin(module_default7);
  8747. module_default.plugin(module_default3);
  8748. module_default.plugin(module_default4);
  8749. module_default.plugin(navigate_default);
  8750. module_default.plugin(module_default9);
  8751. module_default.addRootSelector(() => "[wire\\:id]");
  8752. module_default.onAttributesAdded((el, attributes) => {
  8753. if (!Array.from(attributes).some((attribute) => matchesForLivewireDirective(attribute.name)))
  8754. return;
  8755. let component = closestComponent(el, false);
  8756. if (!component)
  8757. return;
  8758. attributes.forEach((attribute) => {
  8759. if (!matchesForLivewireDirective(attribute.name))
  8760. return;
  8761. let directive3 = extractDirective(el, attribute.name);
  8762. trigger2("directive.init", { el, component, directive: directive3, cleanup: (callback) => {
  8763. module_default.onAttributeRemoved(el, directive3.raw, callback);
  8764. } });
  8765. });
  8766. });
  8767. module_default.interceptInit(module_default.skipDuringClone((el) => {
  8768. if (!Array.from(el.attributes).some((attribute) => matchesForLivewireDirective(attribute.name)))
  8769. return;
  8770. if (el.hasAttribute("wire:id")) {
  8771. let component2 = initComponent(el);
  8772. module_default.onAttributeRemoved(el, "wire:id", () => {
  8773. destroyComponent(component2.id);
  8774. });
  8775. }
  8776. let directives2 = Array.from(el.getAttributeNames()).filter((name) => matchesForLivewireDirective(name)).map((name) => extractDirective(el, name));
  8777. directives2.forEach((directive3) => {
  8778. trigger2("directive.global.init", { el, directive: directive3, cleanup: (callback) => {
  8779. module_default.onAttributeRemoved(el, directive3.raw, callback);
  8780. } });
  8781. });
  8782. let component = closestComponent(el, false);
  8783. if (component) {
  8784. trigger2("element.init", { el, component });
  8785. directives2.forEach((directive3) => {
  8786. trigger2("directive.init", { el, component, directive: directive3, cleanup: (callback) => {
  8787. module_default.onAttributeRemoved(el, directive3.raw, callback);
  8788. } });
  8789. });
  8790. }
  8791. }));
  8792. module_default.start();
  8793. setTimeout(() => window.Livewire.initialRenderIsFinished = true);
  8794. dispatch(document, "livewire:initialized");
  8795. }
  8796. function ensureLivewireScriptIsntMisplaced() {
  8797. let el = document.querySelector("script[data-update-uri][data-csrf]");
  8798. if (!el)
  8799. return;
  8800. let livewireEl = el.closest("[wire\\:id]");
  8801. if (livewireEl) {
  8802. console.warn("Livewire: missing closing tags found. Ensure your template elements contain matching closing tags.", livewireEl);
  8803. }
  8804. }
  8805. // js/features/supportListeners.js
  8806. on2("effect", ({ component, effects }) => {
  8807. registerListeners(component, effects.listeners || []);
  8808. });
  8809. function registerListeners(component, listeners2) {
  8810. listeners2.forEach((name) => {
  8811. let handler4 = (e) => {
  8812. if (e.__livewire)
  8813. e.__livewire.receivedBy.push(component);
  8814. component.$wire.call("__dispatch", name, e.detail || {});
  8815. };
  8816. window.addEventListener(name, handler4);
  8817. component.addCleanup(() => window.removeEventListener(name, handler4));
  8818. component.el.addEventListener(name, (e) => {
  8819. if (!e.__livewire)
  8820. return;
  8821. if (e.bubbles)
  8822. return;
  8823. if (e.__livewire)
  8824. e.__livewire.receivedBy.push(component.id);
  8825. component.$wire.call("__dispatch", name, e.detail || {});
  8826. });
  8827. });
  8828. }
  8829. // js/features/supportScriptsAndAssets.js
  8830. var executedScripts = /* @__PURE__ */ new WeakMap();
  8831. var executedAssets = /* @__PURE__ */ new Set();
  8832. on2("payload.intercept", async ({ assets }) => {
  8833. if (!assets)
  8834. return;
  8835. for (let [key, asset] of Object.entries(assets)) {
  8836. await onlyIfAssetsHaventBeenLoadedAlreadyOnThisPage(key, async () => {
  8837. await addAssetsToHeadTagOfPage(asset);
  8838. });
  8839. }
  8840. });
  8841. on2("component.init", ({ component }) => {
  8842. let assets = component.snapshot.memo.assets;
  8843. if (assets) {
  8844. assets.forEach((key) => {
  8845. if (executedAssets.has(key))
  8846. return;
  8847. executedAssets.add(key);
  8848. });
  8849. }
  8850. });
  8851. on2("effect", ({ component, effects }) => {
  8852. let scripts = effects.scripts;
  8853. if (scripts) {
  8854. Object.entries(scripts).forEach(([key, content]) => {
  8855. onlyIfScriptHasntBeenRunAlreadyForThisComponent(component, key, () => {
  8856. let scriptContent = extractScriptTagContent(content);
  8857. module_default.dontAutoEvaluateFunctions(() => {
  8858. module_default.evaluate(component.el, scriptContent, { "$wire": component.$wire, "$js": component.$wire.$js });
  8859. });
  8860. });
  8861. });
  8862. }
  8863. });
  8864. function onlyIfScriptHasntBeenRunAlreadyForThisComponent(component, key, callback) {
  8865. if (executedScripts.has(component)) {
  8866. let alreadyRunKeys2 = executedScripts.get(component);
  8867. if (alreadyRunKeys2.includes(key))
  8868. return;
  8869. }
  8870. callback();
  8871. if (!executedScripts.has(component))
  8872. executedScripts.set(component, []);
  8873. let alreadyRunKeys = executedScripts.get(component);
  8874. alreadyRunKeys.push(key);
  8875. executedScripts.set(component, alreadyRunKeys);
  8876. }
  8877. function extractScriptTagContent(rawHtml) {
  8878. let scriptRegex = /<script\b[^>]*>([\s\S]*?)<\/script>/gm;
  8879. let matches2 = scriptRegex.exec(rawHtml);
  8880. let innards = matches2 && matches2[1] ? matches2[1].trim() : "";
  8881. return innards;
  8882. }
  8883. async function onlyIfAssetsHaventBeenLoadedAlreadyOnThisPage(key, callback) {
  8884. if (executedAssets.has(key))
  8885. return;
  8886. await callback();
  8887. executedAssets.add(key);
  8888. }
  8889. async function addAssetsToHeadTagOfPage(rawHtml) {
  8890. let newDocument = new DOMParser().parseFromString(rawHtml, "text/html");
  8891. let newHead = document.adoptNode(newDocument.head);
  8892. for (let child of newHead.children) {
  8893. try {
  8894. await runAssetSynchronously(child);
  8895. } catch (error2) {
  8896. }
  8897. }
  8898. }
  8899. async function runAssetSynchronously(child) {
  8900. return new Promise((resolve, reject) => {
  8901. if (isScript2(child)) {
  8902. let script = cloneScriptTag2(child);
  8903. if (script.src) {
  8904. script.onload = () => resolve();
  8905. script.onerror = () => reject();
  8906. } else {
  8907. resolve();
  8908. }
  8909. document.head.appendChild(script);
  8910. } else {
  8911. document.head.appendChild(child);
  8912. resolve();
  8913. }
  8914. });
  8915. }
  8916. function isScript2(el) {
  8917. return el.tagName.toLowerCase() === "script";
  8918. }
  8919. function cloneScriptTag2(el) {
  8920. let script = document.createElement("script");
  8921. script.textContent = el.textContent;
  8922. script.async = el.async;
  8923. for (let attr of el.attributes) {
  8924. script.setAttribute(attr.name, attr.value);
  8925. }
  8926. return script;
  8927. }
  8928. // js/features/supportJsEvaluation.js
  8929. module_default.magic("js", (el) => {
  8930. let component = closestComponent(el);
  8931. return component.$wire.js;
  8932. });
  8933. on2("effect", ({ component, effects }) => {
  8934. let js = effects.js;
  8935. let xjs = effects.xjs;
  8936. if (js) {
  8937. Object.entries(js).forEach(([method, body]) => {
  8938. overrideMethod(component, method, () => {
  8939. module_default.evaluate(component.el, body);
  8940. });
  8941. });
  8942. }
  8943. if (xjs) {
  8944. xjs.forEach(({ expression, params }) => {
  8945. params = Object.values(params);
  8946. module_default.evaluate(component.el, expression, { scope: component.jsActions, params });
  8947. });
  8948. }
  8949. });
  8950. // js/morph.js
  8951. function morph2(component, el, html) {
  8952. let wrapperTag = el.parentElement ? el.parentElement.tagName.toLowerCase() : "div";
  8953. let wrapper = document.createElement(wrapperTag);
  8954. wrapper.innerHTML = html;
  8955. let parentComponent;
  8956. try {
  8957. parentComponent = closestComponent(el.parentElement);
  8958. } catch (e) {
  8959. }
  8960. parentComponent && (wrapper.__livewire = parentComponent);
  8961. let to = wrapper.firstElementChild;
  8962. to.__livewire = component;
  8963. trigger2("morph", { el, toEl: to, component });
  8964. module_default.morph(el, to, {
  8965. updating: (el2, toEl, childrenOnly, skip, skipChildren) => {
  8966. if (isntElement(el2))
  8967. return;
  8968. trigger2("morph.updating", { el: el2, toEl, component, skip, childrenOnly, skipChildren });
  8969. if (el2.__livewire_replace === true)
  8970. el2.innerHTML = toEl.innerHTML;
  8971. if (el2.__livewire_replace_self === true) {
  8972. el2.outerHTML = toEl.outerHTML;
  8973. return skip();
  8974. }
  8975. if (el2.__livewire_ignore === true)
  8976. return skip();
  8977. if (el2.__livewire_ignore_self === true)
  8978. childrenOnly();
  8979. if (el2.__livewire_ignore_children === true)
  8980. return skipChildren();
  8981. if (isComponentRootEl(el2) && el2.getAttribute("wire:id") !== component.id)
  8982. return skip();
  8983. if (isComponentRootEl(el2))
  8984. toEl.__livewire = component;
  8985. },
  8986. updated: (el2) => {
  8987. if (isntElement(el2))
  8988. return;
  8989. trigger2("morph.updated", { el: el2, component });
  8990. },
  8991. removing: (el2, skip) => {
  8992. if (isntElement(el2))
  8993. return;
  8994. trigger2("morph.removing", { el: el2, component, skip });
  8995. },
  8996. removed: (el2) => {
  8997. if (isntElement(el2))
  8998. return;
  8999. trigger2("morph.removed", { el: el2, component });
  9000. },
  9001. adding: (el2) => {
  9002. trigger2("morph.adding", { el: el2, component });
  9003. },
  9004. added: (el2) => {
  9005. if (isntElement(el2))
  9006. return;
  9007. const closestComponentId = closestComponent(el2).id;
  9008. trigger2("morph.added", { el: el2 });
  9009. },
  9010. key: (el2) => {
  9011. if (isntElement(el2))
  9012. return;
  9013. return el2.hasAttribute(`wire:key`) ? el2.getAttribute(`wire:key`) : el2.hasAttribute(`wire:id`) ? el2.getAttribute(`wire:id`) : el2.id;
  9014. },
  9015. lookahead: false
  9016. });
  9017. trigger2("morphed", { el, component });
  9018. }
  9019. function isntElement(el) {
  9020. return typeof el.hasAttribute !== "function";
  9021. }
  9022. function isComponentRootEl(el) {
  9023. return el.hasAttribute("wire:id");
  9024. }
  9025. // js/features/supportMorphDom.js
  9026. on2("effect", ({ component, effects }) => {
  9027. let html = effects.html;
  9028. if (!html)
  9029. return;
  9030. queueMicrotask(() => {
  9031. queueMicrotask(() => {
  9032. morph2(component, component.el, html);
  9033. });
  9034. });
  9035. });
  9036. // js/features/supportDispatches.js
  9037. on2("effect", ({ component, effects }) => {
  9038. dispatchEvents(component, effects.dispatches || []);
  9039. });
  9040. function dispatchEvents(component, dispatches) {
  9041. dispatches.forEach(({ name, params = {}, self = false, to }) => {
  9042. if (self)
  9043. dispatchSelf(component, name, params);
  9044. else if (to)
  9045. dispatchTo(to, name, params);
  9046. else
  9047. dispatch3(component, name, params);
  9048. });
  9049. }
  9050. // js/features/supportDisablingFormsDuringRequest.js
  9051. var cleanups = new Bag();
  9052. on2("directive.init", ({ el, directive: directive3, cleanup: cleanup2, component }) => setTimeout(() => {
  9053. if (directive3.value !== "submit")
  9054. return;
  9055. el.addEventListener("submit", () => {
  9056. let componentId = directive3.expression.startsWith("$parent") ? component.parent.id : component.id;
  9057. let cleanup3 = disableForm(el);
  9058. cleanups.add(componentId, cleanup3);
  9059. });
  9060. }));
  9061. on2("commit", ({ component, respond }) => {
  9062. respond(() => {
  9063. cleanups.each(component.id, (i) => i());
  9064. cleanups.remove(component.id);
  9065. });
  9066. });
  9067. function disableForm(formEl) {
  9068. let undos = [];
  9069. module_default.walk(formEl, (el, skip) => {
  9070. if (!formEl.contains(el))
  9071. return;
  9072. if (el.hasAttribute("wire:ignore"))
  9073. return skip();
  9074. if (shouldMarkDisabled(el)) {
  9075. undos.push(markDisabled(el));
  9076. } else if (shouldMarkReadOnly(el)) {
  9077. undos.push(markReadOnly(el));
  9078. }
  9079. });
  9080. return () => {
  9081. while (undos.length > 0)
  9082. undos.shift()();
  9083. };
  9084. }
  9085. function shouldMarkDisabled(el) {
  9086. let tag = el.tagName.toLowerCase();
  9087. if (tag === "select")
  9088. return true;
  9089. if (tag === "button" && el.type === "submit")
  9090. return true;
  9091. if (tag === "input" && (el.type === "checkbox" || el.type === "radio"))
  9092. return true;
  9093. return false;
  9094. }
  9095. function shouldMarkReadOnly(el) {
  9096. return ["input", "textarea"].includes(el.tagName.toLowerCase());
  9097. }
  9098. function markDisabled(el) {
  9099. let undo = el.disabled ? () => {
  9100. } : () => el.disabled = false;
  9101. el.disabled = true;
  9102. return undo;
  9103. }
  9104. function markReadOnly(el) {
  9105. let undo = el.readOnly ? () => {
  9106. } : () => el.readOnly = false;
  9107. el.readOnly = true;
  9108. return undo;
  9109. }
  9110. // js/features/supportPropsAndModelables.js
  9111. on2("commit.pooling", ({ commits }) => {
  9112. commits.forEach((commit) => {
  9113. let component = commit.component;
  9114. getDeepChildrenWithBindings(component, (child) => {
  9115. child.$wire.$commit();
  9116. });
  9117. });
  9118. });
  9119. on2("commit.pooled", ({ pools }) => {
  9120. let commits = getPooledCommits(pools);
  9121. commits.forEach((commit) => {
  9122. let component = commit.component;
  9123. getDeepChildrenWithBindings(component, (child) => {
  9124. colocateCommitsByComponent(pools, component, child);
  9125. });
  9126. });
  9127. });
  9128. function getPooledCommits(pools) {
  9129. let commits = [];
  9130. pools.forEach((pool) => {
  9131. pool.commits.forEach((commit) => {
  9132. commits.push(commit);
  9133. });
  9134. });
  9135. return commits;
  9136. }
  9137. function colocateCommitsByComponent(pools, component, foreignComponent) {
  9138. let pool = findPoolWithComponent(pools, component);
  9139. let foreignPool = findPoolWithComponent(pools, foreignComponent);
  9140. let foreignCommit = foreignPool.findCommitByComponent(foreignComponent);
  9141. foreignPool.delete(foreignCommit);
  9142. pool.add(foreignCommit);
  9143. pools.forEach((pool2) => {
  9144. if (pool2.empty())
  9145. pools.delete(pool2);
  9146. });
  9147. }
  9148. function findPoolWithComponent(pools, component) {
  9149. for (let [idx, pool] of pools.entries()) {
  9150. if (pool.hasCommitFor(component))
  9151. return pool;
  9152. }
  9153. }
  9154. function getDeepChildrenWithBindings(component, callback) {
  9155. getDeepChildren(component, (child) => {
  9156. if (hasReactiveProps(child) || hasWireModelableBindings(child)) {
  9157. callback(child);
  9158. }
  9159. });
  9160. }
  9161. function hasReactiveProps(component) {
  9162. let meta = component.snapshot.memo;
  9163. let props = meta.props;
  9164. return !!props;
  9165. }
  9166. function hasWireModelableBindings(component) {
  9167. let meta = component.snapshot.memo;
  9168. let bindings = meta.bindings;
  9169. return !!bindings;
  9170. }
  9171. function getDeepChildren(component, callback) {
  9172. component.children.forEach((child) => {
  9173. callback(child);
  9174. getDeepChildren(child, callback);
  9175. });
  9176. }
  9177. // js/features/supportFileDownloads.js
  9178. on2("commit", ({ succeed }) => {
  9179. succeed(({ effects }) => {
  9180. let download = effects.download;
  9181. if (!download)
  9182. return;
  9183. let urlObject = window.webkitURL || window.URL;
  9184. let url = urlObject.createObjectURL(base64toBlob(download.content, download.contentType));
  9185. let invisibleLink = document.createElement("a");
  9186. invisibleLink.style.display = "none";
  9187. invisibleLink.href = url;
  9188. invisibleLink.download = download.name;
  9189. document.body.appendChild(invisibleLink);
  9190. invisibleLink.click();
  9191. setTimeout(function() {
  9192. urlObject.revokeObjectURL(url);
  9193. }, 0);
  9194. });
  9195. });
  9196. function base64toBlob(b64Data, contentType = "", sliceSize = 512) {
  9197. const byteCharacters = atob(b64Data);
  9198. const byteArrays = [];
  9199. if (contentType === null)
  9200. contentType = "";
  9201. for (let offset2 = 0; offset2 < byteCharacters.length; offset2 += sliceSize) {
  9202. let slice = byteCharacters.slice(offset2, offset2 + sliceSize);
  9203. let byteNumbers = new Array(slice.length);
  9204. for (let i = 0; i < slice.length; i++) {
  9205. byteNumbers[i] = slice.charCodeAt(i);
  9206. }
  9207. let byteArray = new Uint8Array(byteNumbers);
  9208. byteArrays.push(byteArray);
  9209. }
  9210. return new Blob(byteArrays, { type: contentType });
  9211. }
  9212. // js/features/supportLazyLoading.js
  9213. var componentsThatWantToBeBundled = /* @__PURE__ */ new WeakSet();
  9214. var componentsThatAreLazy = /* @__PURE__ */ new WeakSet();
  9215. on2("component.init", ({ component }) => {
  9216. let memo = component.snapshot.memo;
  9217. if (memo.lazyLoaded === void 0)
  9218. return;
  9219. componentsThatAreLazy.add(component);
  9220. if (memo.lazyIsolated !== void 0 && memo.lazyIsolated === false) {
  9221. componentsThatWantToBeBundled.add(component);
  9222. }
  9223. });
  9224. on2("commit.pooling", ({ commits }) => {
  9225. commits.forEach((commit) => {
  9226. if (!componentsThatAreLazy.has(commit.component))
  9227. return;
  9228. if (componentsThatWantToBeBundled.has(commit.component)) {
  9229. commit.isolate = false;
  9230. componentsThatWantToBeBundled.delete(commit.component);
  9231. } else {
  9232. commit.isolate = true;
  9233. }
  9234. componentsThatAreLazy.delete(commit.component);
  9235. });
  9236. });
  9237. // js/features/supportQueryString.js
  9238. on2("effect", ({ component, effects, cleanup: cleanup2 }) => {
  9239. let queryString = effects["url"];
  9240. if (!queryString)
  9241. return;
  9242. Object.entries(queryString).forEach(([key, value]) => {
  9243. let { name, as, use, alwaysShow, except } = normalizeQueryStringEntry(key, value);
  9244. if (!as)
  9245. as = name;
  9246. let initialValue = [false, null, void 0].includes(except) ? dataGet(component.ephemeral, name) : except;
  9247. let { replace: replace2, push: push2, pop } = track2(as, initialValue, alwaysShow, except);
  9248. if (use === "replace") {
  9249. let effectReference = module_default.effect(() => {
  9250. replace2(dataGet(component.reactive, name));
  9251. });
  9252. cleanup2(() => module_default.release(effectReference));
  9253. } else if (use === "push") {
  9254. let forgetCommitHandler = on2("commit", ({ component: commitComponent, succeed }) => {
  9255. if (component !== commitComponent)
  9256. return;
  9257. let beforeValue = dataGet(component.canonical, name);
  9258. succeed(() => {
  9259. let afterValue = dataGet(component.canonical, name);
  9260. if (JSON.stringify(beforeValue) === JSON.stringify(afterValue))
  9261. return;
  9262. push2(afterValue);
  9263. });
  9264. });
  9265. let forgetPopHandler = pop(async (newValue) => {
  9266. await component.$wire.set(name, newValue);
  9267. document.querySelectorAll("input").forEach((el) => {
  9268. el._x_forceModelUpdate && el._x_forceModelUpdate(el._x_model.get());
  9269. });
  9270. });
  9271. cleanup2(() => {
  9272. forgetCommitHandler();
  9273. forgetPopHandler();
  9274. });
  9275. }
  9276. });
  9277. });
  9278. function normalizeQueryStringEntry(key, value) {
  9279. let defaults = { use: "replace", alwaysShow: false };
  9280. if (typeof value === "string") {
  9281. return { ...defaults, name: value, as: value };
  9282. } else {
  9283. let fullerDefaults = { ...defaults, name: key, as: key };
  9284. return { ...fullerDefaults, ...value };
  9285. }
  9286. }
  9287. // js/features/supportLaravelEcho.js
  9288. on2("request", ({ options }) => {
  9289. if (window.Echo) {
  9290. options.headers["X-Socket-ID"] = window.Echo.socketId();
  9291. }
  9292. });
  9293. on2("effect", ({ component, effects }) => {
  9294. let listeners2 = effects.listeners || [];
  9295. listeners2.forEach((event) => {
  9296. if (event.startsWith("echo")) {
  9297. if (typeof window.Echo === "undefined") {
  9298. console.warn("Laravel Echo cannot be found");
  9299. return;
  9300. }
  9301. let event_parts = event.split(/(echo:|echo-)|:|,/);
  9302. if (event_parts[1] == "echo:") {
  9303. event_parts.splice(2, 0, "channel", void 0);
  9304. }
  9305. if (event_parts[2] == "notification") {
  9306. event_parts.push(void 0, void 0);
  9307. }
  9308. let [
  9309. s1,
  9310. signature,
  9311. channel_type,
  9312. s2,
  9313. channel,
  9314. s3,
  9315. event_name
  9316. ] = event_parts;
  9317. if (["channel", "private", "encryptedPrivate"].includes(channel_type)) {
  9318. let handler4 = (e) => dispatchSelf(component, event, [e]);
  9319. window.Echo[channel_type](channel).listen(event_name, handler4);
  9320. component.addCleanup(() => {
  9321. window.Echo[channel_type](channel).stopListening(event_name, handler4);
  9322. });
  9323. } else if (channel_type == "presence") {
  9324. if (["here", "joining", "leaving"].includes(event_name)) {
  9325. window.Echo.join(channel)[event_name]((e) => {
  9326. dispatchSelf(component, event, [e]);
  9327. });
  9328. } else {
  9329. let handler4 = (e) => dispatchSelf(component, event, [e]);
  9330. window.Echo.join(channel).listen(event_name, handler4);
  9331. component.addCleanup(() => {
  9332. window.Echo.leaveChannel(channel);
  9333. });
  9334. }
  9335. } else if (channel_type == "notification") {
  9336. window.Echo.private(channel).notification((notification) => {
  9337. dispatchSelf(component, event, [notification]);
  9338. });
  9339. } else {
  9340. console.warn("Echo channel type not yet supported");
  9341. }
  9342. }
  9343. });
  9344. });
  9345. // js/features/supportIsolating.js
  9346. var componentsThatAreIsolated = /* @__PURE__ */ new WeakSet();
  9347. on2("component.init", ({ component }) => {
  9348. let memo = component.snapshot.memo;
  9349. if (memo.isolate !== true)
  9350. return;
  9351. componentsThatAreIsolated.add(component);
  9352. });
  9353. on2("commit.pooling", ({ commits }) => {
  9354. commits.forEach((commit) => {
  9355. if (!componentsThatAreIsolated.has(commit.component))
  9356. return;
  9357. commit.isolate = true;
  9358. });
  9359. });
  9360. // js/features/supportNavigate.js
  9361. shouldHideProgressBar() && Alpine.navigate.disableProgressBar();
  9362. document.addEventListener("alpine:navigate", (e) => forwardEvent("livewire:navigate", e));
  9363. document.addEventListener("alpine:navigating", (e) => forwardEvent("livewire:navigating", e));
  9364. document.addEventListener("alpine:navigated", (e) => forwardEvent("livewire:navigated", e));
  9365. function forwardEvent(name, original) {
  9366. let event = new CustomEvent(name, { cancelable: true, bubbles: true, detail: original.detail });
  9367. document.dispatchEvent(event);
  9368. if (event.defaultPrevented) {
  9369. original.preventDefault();
  9370. }
  9371. }
  9372. function shouldRedirectUsingNavigateOr(effects, url, or) {
  9373. let forceNavigate = effects.redirectUsingNavigate;
  9374. if (forceNavigate) {
  9375. Alpine.navigate(url);
  9376. } else {
  9377. or();
  9378. }
  9379. }
  9380. function shouldHideProgressBar() {
  9381. if (!!document.querySelector("[data-no-progress-bar]"))
  9382. return true;
  9383. if (window.livewireScriptConfig && window.livewireScriptConfig.progressBar === false)
  9384. return true;
  9385. return false;
  9386. }
  9387. // js/features/supportRedirects.js
  9388. on2("effect", ({ effects }) => {
  9389. if (!effects["redirect"])
  9390. return;
  9391. let url = effects["redirect"];
  9392. shouldRedirectUsingNavigateOr(effects, url, () => {
  9393. window.location.href = url;
  9394. });
  9395. });
  9396. // js/directives/wire-transition.js
  9397. on2("morph.added", ({ el }) => {
  9398. el.__addedByMorph = true;
  9399. });
  9400. directive2("transition", ({ el, directive: directive3, component, cleanup: cleanup2 }) => {
  9401. for (let i = 0; i < el.attributes.length; i++) {
  9402. if (el.attributes[i].name.startsWith("wire:show")) {
  9403. module_default.bind(el, {
  9404. [directive3.rawName.replace("wire:transition", "x-transition")]: directive3.expression
  9405. });
  9406. return;
  9407. }
  9408. }
  9409. let visibility = module_default.reactive({ state: el.__addedByMorph ? false : true });
  9410. module_default.bind(el, {
  9411. [directive3.rawName.replace("wire:", "x-")]: "",
  9412. "x-show"() {
  9413. return visibility.state;
  9414. }
  9415. });
  9416. el.__addedByMorph && setTimeout(() => visibility.state = true);
  9417. let cleanups2 = [];
  9418. cleanups2.push(on2("morph.removing", ({ el: el2, skip }) => {
  9419. skip();
  9420. el2.addEventListener("transitionend", () => {
  9421. el2.remove();
  9422. });
  9423. visibility.state = false;
  9424. cleanups2.push(on2("morph", ({ component: morphComponent }) => {
  9425. if (morphComponent !== component)
  9426. return;
  9427. el2.remove();
  9428. cleanups2.forEach((i) => i());
  9429. }));
  9430. }));
  9431. cleanup2(() => cleanups2.forEach((i) => i()));
  9432. });
  9433. // js/debounce.js
  9434. var callbacksByComponent = new WeakBag();
  9435. function callAndClearComponentDebounces(component, callback) {
  9436. callbacksByComponent.each(component, (callbackRegister) => {
  9437. callbackRegister.callback();
  9438. callbackRegister.callback = () => {
  9439. };
  9440. });
  9441. callback();
  9442. }
  9443. // js/directives/wire-wildcard.js
  9444. on2("directive.init", ({ el, directive: directive3, cleanup: cleanup2, component }) => {
  9445. if (["snapshot", "effects", "model", "init", "loading", "poll", "ignore", "id", "data", "key", "target", "dirty"].includes(directive3.value))
  9446. return;
  9447. if (customDirectiveHasBeenRegistered(directive3.value))
  9448. return;
  9449. let attribute = directive3.rawName.replace("wire:", "x-on:");
  9450. if (directive3.value === "submit" && !directive3.modifiers.includes("prevent")) {
  9451. attribute = attribute + ".prevent";
  9452. }
  9453. let cleanupBinding = module_default.bind(el, {
  9454. [attribute](e) {
  9455. let execute = () => {
  9456. callAndClearComponentDebounces(component, () => {
  9457. module_default.evaluate(el, "$wire." + directive3.expression, { scope: { $event: e } });
  9458. });
  9459. };
  9460. if (el.__livewire_confirm) {
  9461. el.__livewire_confirm(() => {
  9462. execute();
  9463. }, () => {
  9464. e.stopImmediatePropagation();
  9465. });
  9466. } else {
  9467. execute();
  9468. }
  9469. }
  9470. });
  9471. cleanup2(cleanupBinding);
  9472. });
  9473. // js/directives/wire-navigate.js
  9474. module_default.addInitSelector(() => `[wire\\:navigate]`);
  9475. module_default.addInitSelector(() => `[wire\\:navigate\\.hover]`);
  9476. module_default.interceptInit(module_default.skipDuringClone((el) => {
  9477. if (el.hasAttribute("wire:navigate")) {
  9478. module_default.bind(el, { ["x-navigate"]: true });
  9479. } else if (el.hasAttribute("wire:navigate.hover")) {
  9480. module_default.bind(el, { ["x-navigate.hover"]: true });
  9481. }
  9482. }));
  9483. document.addEventListener("alpine:navigating", () => {
  9484. Livewire.all().forEach((component) => {
  9485. component.inscribeSnapshotAndEffectsOnElement();
  9486. });
  9487. });
  9488. // js/directives/wire-confirm.js
  9489. directive2("confirm", ({ el, directive: directive3 }) => {
  9490. let message = directive3.expression;
  9491. let shouldPrompt = directive3.modifiers.includes("prompt");
  9492. message = message.replaceAll("\\n", "\n");
  9493. if (message === "")
  9494. message = "Are you sure?";
  9495. el.__livewire_confirm = (action, instead) => {
  9496. if (shouldPrompt) {
  9497. let [question, expected] = message.split("|");
  9498. if (!expected) {
  9499. console.warn("Livewire: Must provide expectation with wire:confirm.prompt");
  9500. } else {
  9501. let input = prompt(question);
  9502. if (input === expected) {
  9503. action();
  9504. } else {
  9505. instead();
  9506. }
  9507. }
  9508. } else {
  9509. if (confirm(message))
  9510. action();
  9511. else
  9512. instead();
  9513. }
  9514. };
  9515. });
  9516. // js/directives/wire-current.js
  9517. module_default.addInitSelector(() => `[wire\\:current]`);
  9518. var onPageChanges = /* @__PURE__ */ new Map();
  9519. document.addEventListener("livewire:navigated", () => {
  9520. onPageChanges.forEach((i) => i(new URL(window.location.href)));
  9521. });
  9522. globalDirective("current", ({ el, directive: directive3, cleanup: cleanup2 }) => {
  9523. let expression = directive3.expression;
  9524. let options = {
  9525. exact: directive3.modifiers.includes("exact"),
  9526. strict: directive3.modifiers.includes("strict")
  9527. };
  9528. if (expression.startsWith("#"))
  9529. return;
  9530. if (!el.hasAttribute("href"))
  9531. return;
  9532. let href = el.getAttribute("href");
  9533. let hrefUrl = new URL(href, window.location.href);
  9534. let classes = expression.split(" ").filter(String);
  9535. let refreshCurrent = (url) => {
  9536. if (pathMatches(hrefUrl, url, options)) {
  9537. el.classList.add(...classes);
  9538. el.setAttribute("data-current", "");
  9539. } else {
  9540. el.classList.remove(...classes);
  9541. el.removeAttribute("data-current");
  9542. }
  9543. };
  9544. refreshCurrent(new URL(window.location.href));
  9545. onPageChanges.set(el, refreshCurrent);
  9546. cleanup2(() => onPageChanges.delete(el));
  9547. });
  9548. function pathMatches(hrefUrl, actualUrl, options) {
  9549. if (hrefUrl.hostname !== actualUrl.hostname)
  9550. return false;
  9551. let hrefPath = options.strict ? hrefUrl.pathname : hrefUrl.pathname.replace(/\/+$/, "");
  9552. let actualPath = options.strict ? actualUrl.pathname : actualUrl.pathname.replace(/\/+$/, "");
  9553. if (options.exact) {
  9554. return hrefPath === actualPath;
  9555. }
  9556. let hrefPathSegments = hrefPath.split("/");
  9557. let actualPathSegments = actualPath.split("/");
  9558. for (let i = 0; i < hrefPathSegments.length; i++) {
  9559. if (hrefPathSegments[i] !== actualPathSegments[i])
  9560. return false;
  9561. }
  9562. return true;
  9563. }
  9564. // js/directives/shared.js
  9565. function toggleBooleanStateDirective(el, directive3, isTruthy, cachedDisplay = null) {
  9566. isTruthy = directive3.modifiers.includes("remove") ? !isTruthy : isTruthy;
  9567. if (directive3.modifiers.includes("class")) {
  9568. let classes = directive3.expression.split(" ").filter(String);
  9569. if (isTruthy) {
  9570. el.classList.add(...classes);
  9571. } else {
  9572. el.classList.remove(...classes);
  9573. }
  9574. } else if (directive3.modifiers.includes("attr")) {
  9575. if (isTruthy) {
  9576. el.setAttribute(directive3.expression, true);
  9577. } else {
  9578. el.removeAttribute(directive3.expression);
  9579. }
  9580. } else {
  9581. let cache = cachedDisplay ?? window.getComputedStyle(el, null).getPropertyValue("display");
  9582. let display = ["inline", "block", "table", "flex", "grid", "inline-flex"].filter((i) => directive3.modifiers.includes(i))[0] || "inline-block";
  9583. display = directive3.modifiers.includes("remove") && !isTruthy ? cache : display;
  9584. el.style.display = isTruthy ? display : "none";
  9585. }
  9586. }
  9587. // js/directives/wire-offline.js
  9588. var offlineHandlers = /* @__PURE__ */ new Set();
  9589. var onlineHandlers = /* @__PURE__ */ new Set();
  9590. window.addEventListener("offline", () => offlineHandlers.forEach((i) => i()));
  9591. window.addEventListener("online", () => onlineHandlers.forEach((i) => i()));
  9592. directive2("offline", ({ el, directive: directive3, cleanup: cleanup2 }) => {
  9593. let setOffline = () => toggleBooleanStateDirective(el, directive3, true);
  9594. let setOnline = () => toggleBooleanStateDirective(el, directive3, false);
  9595. offlineHandlers.add(setOffline);
  9596. onlineHandlers.add(setOnline);
  9597. cleanup2(() => {
  9598. offlineHandlers.delete(setOffline);
  9599. onlineHandlers.delete(setOnline);
  9600. });
  9601. });
  9602. // js/directives/wire-loading.js
  9603. directive2("loading", ({ el, directive: directive3, component, cleanup: cleanup2 }) => {
  9604. let { targets, inverted } = getTargets(el);
  9605. let [delay3, abortDelay] = applyDelay(directive3);
  9606. let cleanupA = whenTargetsArePartOfRequest(component, targets, inverted, [
  9607. () => delay3(() => toggleBooleanStateDirective(el, directive3, true)),
  9608. () => abortDelay(() => toggleBooleanStateDirective(el, directive3, false))
  9609. ]);
  9610. let cleanupB = whenTargetsArePartOfFileUpload(component, targets, [
  9611. () => delay3(() => toggleBooleanStateDirective(el, directive3, true)),
  9612. () => abortDelay(() => toggleBooleanStateDirective(el, directive3, false))
  9613. ]);
  9614. cleanup2(() => {
  9615. cleanupA();
  9616. cleanupB();
  9617. });
  9618. });
  9619. function applyDelay(directive3) {
  9620. if (!directive3.modifiers.includes("delay") || directive3.modifiers.includes("none"))
  9621. return [(i) => i(), (i) => i()];
  9622. let duration = 200;
  9623. let delayModifiers = {
  9624. "shortest": 50,
  9625. "shorter": 100,
  9626. "short": 150,
  9627. "default": 200,
  9628. "long": 300,
  9629. "longer": 500,
  9630. "longest": 1e3
  9631. };
  9632. Object.keys(delayModifiers).some((key) => {
  9633. if (directive3.modifiers.includes(key)) {
  9634. duration = delayModifiers[key];
  9635. return true;
  9636. }
  9637. });
  9638. let timeout;
  9639. let started2 = false;
  9640. return [
  9641. (callback) => {
  9642. timeout = setTimeout(() => {
  9643. callback();
  9644. started2 = true;
  9645. }, duration);
  9646. },
  9647. async (callback) => {
  9648. if (started2) {
  9649. await callback();
  9650. started2 = false;
  9651. } else {
  9652. clearTimeout(timeout);
  9653. }
  9654. }
  9655. ];
  9656. }
  9657. function whenTargetsArePartOfRequest(component, targets, inverted, [startLoading, endLoading]) {
  9658. return on2("commit", ({ component: iComponent, commit: payload, respond }) => {
  9659. if (iComponent !== component)
  9660. return;
  9661. if (targets.length > 0 && containsTargets(payload, targets) === inverted)
  9662. return;
  9663. startLoading();
  9664. respond(() => {
  9665. endLoading();
  9666. });
  9667. });
  9668. }
  9669. function whenTargetsArePartOfFileUpload(component, targets, [startLoading, endLoading]) {
  9670. let eventMismatch = (e) => {
  9671. let { id, property } = e.detail;
  9672. if (id !== component.id)
  9673. return true;
  9674. if (targets.length > 0 && !targets.map((i) => i.target).includes(property))
  9675. return true;
  9676. return false;
  9677. };
  9678. let cleanupA = listen(window, "livewire-upload-start", (e) => {
  9679. if (eventMismatch(e))
  9680. return;
  9681. startLoading();
  9682. });
  9683. let cleanupB = listen(window, "livewire-upload-finish", (e) => {
  9684. if (eventMismatch(e))
  9685. return;
  9686. endLoading();
  9687. });
  9688. let cleanupC = listen(window, "livewire-upload-error", (e) => {
  9689. if (eventMismatch(e))
  9690. return;
  9691. endLoading();
  9692. });
  9693. return () => {
  9694. cleanupA();
  9695. cleanupB();
  9696. cleanupC();
  9697. };
  9698. }
  9699. function containsTargets(payload, targets) {
  9700. let { updates, calls } = payload;
  9701. return targets.some(({ target, params }) => {
  9702. if (params) {
  9703. return calls.some(({ method, params: methodParams }) => {
  9704. return target === method && params === quickHash(JSON.stringify(methodParams));
  9705. });
  9706. }
  9707. let hasMatchingUpdate = Object.keys(updates).some((property) => {
  9708. if (property.includes(".")) {
  9709. let propertyRoot = property.split(".")[0];
  9710. if (propertyRoot === target)
  9711. return true;
  9712. }
  9713. return property === target;
  9714. });
  9715. if (hasMatchingUpdate)
  9716. return true;
  9717. if (calls.map((i) => i.method).includes(target))
  9718. return true;
  9719. });
  9720. }
  9721. function getTargets(el) {
  9722. let directives2 = getDirectives(el);
  9723. let targets = [];
  9724. let inverted = false;
  9725. if (directives2.has("target")) {
  9726. let directive3 = directives2.get("target");
  9727. let raw2 = directive3.expression;
  9728. if (directive3.modifiers.includes("except"))
  9729. inverted = true;
  9730. if (raw2.includes("(") && raw2.includes(")")) {
  9731. targets.push({ target: directive3.method, params: quickHash(JSON.stringify(directive3.params)) });
  9732. } else if (raw2.includes(",")) {
  9733. raw2.split(",").map((i) => i.trim()).forEach((target) => {
  9734. targets.push({ target });
  9735. });
  9736. } else {
  9737. targets.push({ target: raw2 });
  9738. }
  9739. } else {
  9740. let nonActionOrModelLivewireDirectives = ["init", "dirty", "offline", "target", "loading", "poll", "ignore", "key", "id"];
  9741. directives2.all().filter((i) => !nonActionOrModelLivewireDirectives.includes(i.value)).map((i) => i.expression.split("(")[0]).forEach((target) => targets.push({ target }));
  9742. }
  9743. return { targets, inverted };
  9744. }
  9745. function quickHash(subject) {
  9746. return btoa(encodeURIComponent(subject));
  9747. }
  9748. // js/directives/wire-stream.js
  9749. directive2("stream", ({ el, directive: directive3, cleanup: cleanup2 }) => {
  9750. let { expression, modifiers } = directive3;
  9751. let off = on2("stream", ({ name, content, replace: replace2 }) => {
  9752. if (name !== expression)
  9753. return;
  9754. if (modifiers.includes("replace") || replace2) {
  9755. el.innerHTML = content;
  9756. } else {
  9757. el.innerHTML = el.innerHTML + content;
  9758. }
  9759. });
  9760. cleanup2(off);
  9761. });
  9762. on2("request", ({ respond }) => {
  9763. respond((mutableObject) => {
  9764. let response = mutableObject.response;
  9765. if (!response.headers.has("X-Livewire-Stream"))
  9766. return;
  9767. mutableObject.response = {
  9768. ok: true,
  9769. redirected: false,
  9770. status: 200,
  9771. async text() {
  9772. let finalResponse = await interceptStreamAndReturnFinalResponse(response, (streamed) => {
  9773. trigger2("stream", streamed);
  9774. });
  9775. if (contentIsFromDump(finalResponse)) {
  9776. this.ok = false;
  9777. }
  9778. return finalResponse;
  9779. }
  9780. };
  9781. });
  9782. });
  9783. async function interceptStreamAndReturnFinalResponse(response, callback) {
  9784. let reader = response.body.getReader();
  9785. let remainingResponse = "";
  9786. while (true) {
  9787. let { done, value: chunk } = await reader.read();
  9788. let decoder = new TextDecoder();
  9789. let output = decoder.decode(chunk);
  9790. let [streams, remaining] = extractStreamObjects(remainingResponse + output);
  9791. streams.forEach((stream) => {
  9792. callback(stream);
  9793. });
  9794. remainingResponse = remaining;
  9795. if (done)
  9796. return remainingResponse;
  9797. }
  9798. }
  9799. function extractStreamObjects(raw2) {
  9800. let regex = /({"stream":true.*?"endStream":true})/g;
  9801. let matches2 = raw2.match(regex);
  9802. let parsed = [];
  9803. if (matches2) {
  9804. for (let i = 0; i < matches2.length; i++) {
  9805. parsed.push(JSON.parse(matches2[i]).body);
  9806. }
  9807. }
  9808. let remaining = raw2.replace(regex, "");
  9809. return [parsed, remaining];
  9810. }
  9811. // js/directives/wire-replace.js
  9812. directive2("replace", ({ el, directive: directive3 }) => {
  9813. if (directive3.modifiers.includes("self")) {
  9814. el.__livewire_replace_self = true;
  9815. } else {
  9816. el.__livewire_replace = true;
  9817. }
  9818. });
  9819. // js/directives/wire-ignore.js
  9820. directive2("ignore", ({ el, directive: directive3 }) => {
  9821. if (directive3.modifiers.includes("self")) {
  9822. el.__livewire_ignore_self = true;
  9823. } else if (directive3.modifiers.includes("children")) {
  9824. el.__livewire_ignore_children = true;
  9825. } else {
  9826. el.__livewire_ignore = true;
  9827. }
  9828. });
  9829. // js/directives/wire-cloak.js
  9830. module_default.interceptInit((el) => {
  9831. if (el.hasAttribute("wire:cloak")) {
  9832. module_default.mutateDom(() => el.removeAttribute("wire:cloak"));
  9833. }
  9834. });
  9835. // js/directives/wire-dirty.js
  9836. var refreshDirtyStatesByComponent = new WeakBag();
  9837. on2("commit", ({ component, succeed }) => {
  9838. succeed(() => {
  9839. setTimeout(() => {
  9840. refreshDirtyStatesByComponent.each(component, (i) => i(false));
  9841. });
  9842. });
  9843. });
  9844. directive2("dirty", ({ el, directive: directive3, component }) => {
  9845. let targets = dirtyTargets(el);
  9846. let dirty = Alpine.reactive({ state: false });
  9847. let oldIsDirty = false;
  9848. let initialDisplay = el.style.display;
  9849. let refreshDirtyState = (isDirty) => {
  9850. toggleBooleanStateDirective(el, directive3, isDirty, initialDisplay);
  9851. oldIsDirty = isDirty;
  9852. };
  9853. refreshDirtyStatesByComponent.add(component, refreshDirtyState);
  9854. Alpine.effect(() => {
  9855. let isDirty = false;
  9856. if (targets.length === 0) {
  9857. isDirty = JSON.stringify(component.canonical) !== JSON.stringify(component.reactive);
  9858. } else {
  9859. for (let i = 0; i < targets.length; i++) {
  9860. if (isDirty)
  9861. break;
  9862. let target = targets[i];
  9863. isDirty = JSON.stringify(dataGet(component.canonical, target)) !== JSON.stringify(dataGet(component.reactive, target));
  9864. }
  9865. }
  9866. if (oldIsDirty !== isDirty) {
  9867. refreshDirtyState(isDirty);
  9868. }
  9869. oldIsDirty = isDirty;
  9870. });
  9871. });
  9872. function dirtyTargets(el) {
  9873. let directives2 = getDirectives(el);
  9874. let targets = [];
  9875. if (directives2.has("model")) {
  9876. targets.push(directives2.get("model").expression);
  9877. }
  9878. if (directives2.has("target")) {
  9879. targets = targets.concat(directives2.get("target").expression.split(",").map((s) => s.trim()));
  9880. }
  9881. return targets;
  9882. }
  9883. // js/directives/wire-model.js
  9884. directive2("model", ({ el, directive: directive3, component, cleanup: cleanup2 }) => {
  9885. let { expression, modifiers } = directive3;
  9886. if (!expression) {
  9887. return console.warn("Livewire: [wire:model] is missing a value.", el);
  9888. }
  9889. if (componentIsMissingProperty(component, expression)) {
  9890. return console.warn('Livewire: [wire:model="' + expression + '"] property does not exist on component: [' + component.name + "]", el);
  9891. }
  9892. if (el.type && el.type.toLowerCase() === "file") {
  9893. return handleFileUpload(el, expression, component, cleanup2);
  9894. }
  9895. let isLive = modifiers.includes("live");
  9896. let isLazy = modifiers.includes("lazy") || modifiers.includes("change");
  9897. let onBlur = modifiers.includes("blur");
  9898. let isDebounced = modifiers.includes("debounce");
  9899. let update = expression.startsWith("$parent") ? () => component.$wire.$parent.$commit() : () => component.$wire.$commit();
  9900. let debouncedUpdate = isTextInput(el) && !isDebounced && isLive ? debounce2(update, 150) : update;
  9901. module_default.bind(el, {
  9902. ["@change"]() {
  9903. isLazy && update();
  9904. },
  9905. ["@blur"]() {
  9906. onBlur && update();
  9907. },
  9908. ["x-model" + getModifierTail(modifiers)]() {
  9909. return {
  9910. get() {
  9911. return dataGet(component.$wire, expression);
  9912. },
  9913. set(value) {
  9914. dataSet(component.$wire, expression, value);
  9915. isLive && !isLazy && !onBlur && debouncedUpdate();
  9916. }
  9917. };
  9918. }
  9919. });
  9920. });
  9921. function getModifierTail(modifiers) {
  9922. modifiers = modifiers.filter((i) => ![
  9923. "lazy",
  9924. "defer"
  9925. ].includes(i));
  9926. if (modifiers.length === 0)
  9927. return "";
  9928. return "." + modifiers.join(".");
  9929. }
  9930. function isTextInput(el) {
  9931. return ["INPUT", "TEXTAREA"].includes(el.tagName.toUpperCase()) && !["checkbox", "radio"].includes(el.type);
  9932. }
  9933. function componentIsMissingProperty(component, property) {
  9934. if (property.startsWith("$parent")) {
  9935. let parent = closestComponent(component.el.parentElement, false);
  9936. if (!parent)
  9937. return true;
  9938. return componentIsMissingProperty(parent, property.split("$parent.")[1]);
  9939. }
  9940. let baseProperty = property.split(".")[0];
  9941. return !Object.keys(component.canonical).includes(baseProperty);
  9942. }
  9943. function debounce2(func, wait) {
  9944. var timeout;
  9945. return function() {
  9946. var context = this, args = arguments;
  9947. var later = function() {
  9948. timeout = null;
  9949. func.apply(context, args);
  9950. };
  9951. clearTimeout(timeout);
  9952. timeout = setTimeout(later, wait);
  9953. };
  9954. }
  9955. // js/directives/wire-init.js
  9956. directive2("init", ({ el, directive: directive3 }) => {
  9957. let fullMethod = directive3.expression ?? "$refresh";
  9958. module_default.evaluate(el, `$wire.${fullMethod}`);
  9959. });
  9960. // js/directives/wire-poll.js
  9961. directive2("poll", ({ el, directive: directive3 }) => {
  9962. let interval = extractDurationFrom(directive3.modifiers, 2e3);
  9963. let { start: start3, pauseWhile, throttleWhile, stopWhen } = poll(() => {
  9964. triggerComponentRequest(el, directive3);
  9965. }, interval);
  9966. start3();
  9967. throttleWhile(() => theTabIsInTheBackground() && theDirectiveIsMissingKeepAlive(directive3));
  9968. pauseWhile(() => theDirectiveHasVisible(directive3) && theElementIsNotInTheViewport(el));
  9969. pauseWhile(() => theDirectiveIsOffTheElement(el));
  9970. pauseWhile(() => livewireIsOffline());
  9971. stopWhen(() => theElementIsDisconnected(el));
  9972. });
  9973. function triggerComponentRequest(el, directive3) {
  9974. module_default.evaluate(el, directive3.expression ? "$wire." + directive3.expression : "$wire.$commit()");
  9975. }
  9976. function poll(callback, interval = 2e3) {
  9977. let pauseConditions = [];
  9978. let throttleConditions = [];
  9979. let stopConditions = [];
  9980. return {
  9981. start() {
  9982. let clear2 = syncronizedInterval(interval, () => {
  9983. if (stopConditions.some((i) => i()))
  9984. return clear2();
  9985. if (pauseConditions.some((i) => i()))
  9986. return;
  9987. if (throttleConditions.some((i) => i()) && Math.random() < 0.95)
  9988. return;
  9989. callback();
  9990. });
  9991. },
  9992. pauseWhile(condition) {
  9993. pauseConditions.push(condition);
  9994. },
  9995. throttleWhile(condition) {
  9996. throttleConditions.push(condition);
  9997. },
  9998. stopWhen(condition) {
  9999. stopConditions.push(condition);
  10000. }
  10001. };
  10002. }
  10003. var clocks = [];
  10004. function syncronizedInterval(ms, callback) {
  10005. if (!clocks[ms]) {
  10006. let clock = {
  10007. timer: setInterval(() => clock.callbacks.forEach((i) => i()), ms),
  10008. callbacks: /* @__PURE__ */ new Set()
  10009. };
  10010. clocks[ms] = clock;
  10011. }
  10012. clocks[ms].callbacks.add(callback);
  10013. return () => {
  10014. clocks[ms].callbacks.delete(callback);
  10015. if (clocks[ms].callbacks.size === 0) {
  10016. clearInterval(clocks[ms].timer);
  10017. delete clocks[ms];
  10018. }
  10019. };
  10020. }
  10021. var isOffline = false;
  10022. window.addEventListener("offline", () => isOffline = true);
  10023. window.addEventListener("online", () => isOffline = false);
  10024. function livewireIsOffline() {
  10025. return isOffline;
  10026. }
  10027. var inBackground = false;
  10028. document.addEventListener("visibilitychange", () => {
  10029. inBackground = document.hidden;
  10030. }, false);
  10031. function theTabIsInTheBackground() {
  10032. return inBackground;
  10033. }
  10034. function theDirectiveIsOffTheElement(el) {
  10035. return !getDirectives(el).has("poll");
  10036. }
  10037. function theDirectiveIsMissingKeepAlive(directive3) {
  10038. return !directive3.modifiers.includes("keep-alive");
  10039. }
  10040. function theDirectiveHasVisible(directive3) {
  10041. return directive3.modifiers.includes("visible");
  10042. }
  10043. function theElementIsNotInTheViewport(el) {
  10044. let bounding = el.getBoundingClientRect();
  10045. return !(bounding.top < (window.innerHeight || document.documentElement.clientHeight) && bounding.left < (window.innerWidth || document.documentElement.clientWidth) && bounding.bottom > 0 && bounding.right > 0);
  10046. }
  10047. function theElementIsDisconnected(el) {
  10048. return el.isConnected === false;
  10049. }
  10050. function extractDurationFrom(modifiers, defaultDuration) {
  10051. let durationInMilliSeconds;
  10052. let durationInMilliSecondsString = modifiers.find((mod) => mod.match(/([0-9]+)ms/));
  10053. let durationInSecondsString = modifiers.find((mod) => mod.match(/([0-9]+)s/));
  10054. if (durationInMilliSecondsString) {
  10055. durationInMilliSeconds = Number(durationInMilliSecondsString.replace("ms", ""));
  10056. } else if (durationInSecondsString) {
  10057. durationInMilliSeconds = Number(durationInSecondsString.replace("s", "")) * 1e3;
  10058. }
  10059. return durationInMilliSeconds || defaultDuration;
  10060. }
  10061. // js/directives/wire-show.js
  10062. module_default.interceptInit((el) => {
  10063. for (let i = 0; i < el.attributes.length; i++) {
  10064. if (el.attributes[i].name.startsWith("wire:show")) {
  10065. let { name, value } = el.attributes[i];
  10066. let modifierString = name.split("wire:show")[1];
  10067. let expression = value.startsWith("!") ? "!$wire." + value.slice(1).trim() : "$wire." + value.trim();
  10068. module_default.bind(el, {
  10069. ["x-show" + modifierString]() {
  10070. return module_default.evaluate(el, expression);
  10071. }
  10072. });
  10073. }
  10074. }
  10075. });
  10076. // js/directives/wire-text.js
  10077. module_default.interceptInit((el) => {
  10078. for (let i = 0; i < el.attributes.length; i++) {
  10079. if (el.attributes[i].name.startsWith("wire:text")) {
  10080. let { name, value } = el.attributes[i];
  10081. let modifierString = name.split("wire:text")[1];
  10082. let expression = value.startsWith("!") ? "!$wire." + value.slice(1).trim() : "$wire." + value.trim();
  10083. module_default.bind(el, {
  10084. ["x-text" + modifierString]() {
  10085. return module_default.evaluate(el, expression);
  10086. }
  10087. });
  10088. }
  10089. }
  10090. });
  10091. // js/index.js
  10092. var Livewire2 = {
  10093. directive: directive2,
  10094. dispatchTo,
  10095. start: start2,
  10096. first,
  10097. find,
  10098. getByName,
  10099. all,
  10100. hook: on2,
  10101. trigger: trigger2,
  10102. triggerAsync,
  10103. dispatch: dispatchGlobal,
  10104. on: on3,
  10105. get navigate() {
  10106. return module_default.navigate;
  10107. }
  10108. };
  10109. var warnAboutMultipleInstancesOf = (entity) => console.warn(`Detected multiple instances of ${entity} running`);
  10110. if (window.Livewire)
  10111. warnAboutMultipleInstancesOf("Livewire");
  10112. if (window.Alpine)
  10113. warnAboutMultipleInstancesOf("Alpine");
  10114. window.Livewire = Livewire2;
  10115. window.Alpine = module_default;
  10116. if (window.livewireScriptConfig === void 0) {
  10117. window.Alpine.__fromLivewire = true;
  10118. document.addEventListener("DOMContentLoaded", () => {
  10119. if (window.Alpine.__fromLivewire === void 0) {
  10120. warnAboutMultipleInstancesOf("Alpine");
  10121. }
  10122. Livewire2.start();
  10123. });
  10124. }
  10125. })();
  10126. /* NProgress, (c) 2013, 2014 Rico Sta. Cruz - http://ricostacruz.com/nprogress
  10127. * @license MIT */
  10128. /*! Bundled license information:
  10129. tabbable/dist/index.esm.js:
  10130. (*!
  10131. * tabbable 5.3.3
  10132. * @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE
  10133. *)
  10134. focus-trap/dist/focus-trap.esm.js:
  10135. (*!
  10136. * focus-trap 6.9.4
  10137. * @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE
  10138. *)
  10139. */