index.mjs 216 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387
  1. import { noop, makeDestructurable, toValue, isClient, tryOnScopeDispose, isIOS, tryOnMounted, computedWithControl, isObject, objectOmit, promiseTimeout, until, toRef, increaseWithUnit, objectEntries, useTimeoutFn, pausableWatch, createEventHook, timestamp, pausableFilter, watchIgnorable, debounceFilter, createFilterWrapper, bypassFilter, createSingletonPromise, toRefs, notNullish, containsProp, hasOwn, throttleFilter, useDebounceFn, useThrottleFn, useIntervalFn, clamp, syncRef, objectPick, tryOnUnmounted, watchWithFilter, identity, isDef } from '@vueuse/shared';
  2. export * from '@vueuse/shared';
  3. import { isRef, ref, shallowRef, watchEffect, computed, inject, isVue3, version, defineComponent, h, TransitionGroup, shallowReactive, Fragment, watch, getCurrentInstance, customRef, onUpdated, onMounted, readonly, nextTick, reactive, markRaw, getCurrentScope, isVue2, set, del, isReadonly, onBeforeUpdate } from 'vue-demi';
  4. function computedAsync(evaluationCallback, initialState, optionsOrRef) {
  5. let options;
  6. if (isRef(optionsOrRef)) {
  7. options = {
  8. evaluating: optionsOrRef
  9. };
  10. } else {
  11. options = optionsOrRef || {};
  12. }
  13. const {
  14. lazy = false,
  15. evaluating = void 0,
  16. shallow = true,
  17. onError = noop
  18. } = options;
  19. const started = ref(!lazy);
  20. const current = shallow ? shallowRef(initialState) : ref(initialState);
  21. let counter = 0;
  22. watchEffect(async (onInvalidate) => {
  23. if (!started.value)
  24. return;
  25. counter++;
  26. const counterAtBeginning = counter;
  27. let hasFinished = false;
  28. if (evaluating) {
  29. Promise.resolve().then(() => {
  30. evaluating.value = true;
  31. });
  32. }
  33. try {
  34. const result = await evaluationCallback((cancelCallback) => {
  35. onInvalidate(() => {
  36. if (evaluating)
  37. evaluating.value = false;
  38. if (!hasFinished)
  39. cancelCallback();
  40. });
  41. });
  42. if (counterAtBeginning === counter)
  43. current.value = result;
  44. } catch (e) {
  45. onError(e);
  46. } finally {
  47. if (evaluating && counterAtBeginning === counter)
  48. evaluating.value = false;
  49. hasFinished = true;
  50. }
  51. });
  52. if (lazy) {
  53. return computed(() => {
  54. started.value = true;
  55. return current.value;
  56. });
  57. } else {
  58. return current;
  59. }
  60. }
  61. function computedInject(key, options, defaultSource, treatDefaultAsFactory) {
  62. let source = inject(key);
  63. if (defaultSource)
  64. source = inject(key, defaultSource);
  65. if (treatDefaultAsFactory)
  66. source = inject(key, defaultSource, treatDefaultAsFactory);
  67. if (typeof options === "function") {
  68. return computed((ctx) => options(source, ctx));
  69. } else {
  70. return computed({
  71. get: (ctx) => options.get(source, ctx),
  72. set: options.set
  73. });
  74. }
  75. }
  76. var __defProp$p = Object.defineProperty;
  77. var __defProps$c = Object.defineProperties;
  78. var __getOwnPropDescs$c = Object.getOwnPropertyDescriptors;
  79. var __getOwnPropSymbols$s = Object.getOwnPropertySymbols;
  80. var __hasOwnProp$s = Object.prototype.hasOwnProperty;
  81. var __propIsEnum$s = Object.prototype.propertyIsEnumerable;
  82. var __defNormalProp$p = (obj, key, value) => key in obj ? __defProp$p(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  83. var __spreadValues$p = (a, b) => {
  84. for (var prop in b || (b = {}))
  85. if (__hasOwnProp$s.call(b, prop))
  86. __defNormalProp$p(a, prop, b[prop]);
  87. if (__getOwnPropSymbols$s)
  88. for (var prop of __getOwnPropSymbols$s(b)) {
  89. if (__propIsEnum$s.call(b, prop))
  90. __defNormalProp$p(a, prop, b[prop]);
  91. }
  92. return a;
  93. };
  94. var __spreadProps$c = (a, b) => __defProps$c(a, __getOwnPropDescs$c(b));
  95. function createReusableTemplate() {
  96. if (!isVue3 && !version.startsWith("2.7.")) {
  97. if (process.env.NODE_ENV !== "production")
  98. throw new Error("[VueUse] createReusableTemplate only works in Vue 2.7 or above.");
  99. return;
  100. }
  101. const render = shallowRef();
  102. const define = /* #__PURE__ */ defineComponent({
  103. setup(_, { slots }) {
  104. return () => {
  105. render.value = slots.default;
  106. };
  107. }
  108. });
  109. const reuse = /* #__PURE__ */ defineComponent({
  110. inheritAttrs: false,
  111. setup(_, { attrs, slots }) {
  112. return () => {
  113. var _a;
  114. if (!render.value && process.env.NODE_ENV !== "production")
  115. throw new Error("[VueUse] Failed to find the definition of reusable template");
  116. return (_a = render.value) == null ? void 0 : _a.call(render, __spreadProps$c(__spreadValues$p({}, attrs), { $slots: slots }));
  117. };
  118. }
  119. });
  120. return makeDestructurable(
  121. { define, reuse },
  122. [define, reuse]
  123. );
  124. }
  125. function createTemplatePromise(options = {}) {
  126. if (!isVue3) {
  127. if (process.env.NODE_ENV !== "production")
  128. throw new Error("[VueUse] createTemplatePromise only works in Vue 3 or above.");
  129. return;
  130. }
  131. let index = 0;
  132. const instances = ref([]);
  133. function create(...args) {
  134. const props = shallowReactive({
  135. key: index++,
  136. args,
  137. promise: void 0,
  138. resolve: () => {
  139. },
  140. reject: () => {
  141. },
  142. isResolving: false,
  143. options
  144. });
  145. instances.value.push(props);
  146. props.promise = new Promise((_resolve, _reject) => {
  147. props.resolve = (v) => {
  148. props.isResolving = true;
  149. return _resolve(v);
  150. };
  151. props.reject = _reject;
  152. }).finally(() => {
  153. props.promise = void 0;
  154. const index2 = instances.value.indexOf(props);
  155. if (index2 !== -1)
  156. instances.value.splice(index2, 1);
  157. });
  158. return props.promise;
  159. }
  160. function start(...args) {
  161. if (options.singleton && instances.value.length > 0)
  162. return instances.value[0].promise;
  163. return create(...args);
  164. }
  165. const component = /* #__PURE__ */ defineComponent((_, { slots }) => {
  166. const renderList = () => instances.value.map((props) => {
  167. var _a;
  168. return h(Fragment, { key: props.key }, (_a = slots.default) == null ? void 0 : _a.call(slots, props));
  169. });
  170. if (options.transition)
  171. return () => h(TransitionGroup, options.transition, renderList);
  172. return renderList;
  173. });
  174. component.start = start;
  175. return component;
  176. }
  177. function createUnrefFn(fn) {
  178. return function(...args) {
  179. return fn.apply(this, args.map((i) => toValue(i)));
  180. };
  181. }
  182. function unrefElement(elRef) {
  183. var _a;
  184. const plain = toValue(elRef);
  185. return (_a = plain == null ? void 0 : plain.$el) != null ? _a : plain;
  186. }
  187. const defaultWindow = isClient ? window : void 0;
  188. const defaultDocument = isClient ? window.document : void 0;
  189. const defaultNavigator = isClient ? window.navigator : void 0;
  190. const defaultLocation = isClient ? window.location : void 0;
  191. function useEventListener(...args) {
  192. let target;
  193. let events;
  194. let listeners;
  195. let options;
  196. if (typeof args[0] === "string" || Array.isArray(args[0])) {
  197. [events, listeners, options] = args;
  198. target = defaultWindow;
  199. } else {
  200. [target, events, listeners, options] = args;
  201. }
  202. if (!target)
  203. return noop;
  204. if (!Array.isArray(events))
  205. events = [events];
  206. if (!Array.isArray(listeners))
  207. listeners = [listeners];
  208. const cleanups = [];
  209. const cleanup = () => {
  210. cleanups.forEach((fn) => fn());
  211. cleanups.length = 0;
  212. };
  213. const register = (el, event, listener, options2) => {
  214. el.addEventListener(event, listener, options2);
  215. return () => el.removeEventListener(event, listener, options2);
  216. };
  217. const stopWatch = watch(
  218. () => [unrefElement(target), toValue(options)],
  219. ([el, options2]) => {
  220. cleanup();
  221. if (!el)
  222. return;
  223. cleanups.push(
  224. ...events.flatMap((event) => {
  225. return listeners.map((listener) => register(el, event, listener, options2));
  226. })
  227. );
  228. },
  229. { immediate: true, flush: "post" }
  230. );
  231. const stop = () => {
  232. stopWatch();
  233. cleanup();
  234. };
  235. tryOnScopeDispose(stop);
  236. return stop;
  237. }
  238. let _iOSWorkaround = false;
  239. function onClickOutside(target, handler, options = {}) {
  240. const { window = defaultWindow, ignore = [], capture = true, detectIframe = false } = options;
  241. if (!window)
  242. return;
  243. if (isIOS && !_iOSWorkaround) {
  244. _iOSWorkaround = true;
  245. Array.from(window.document.body.children).forEach((el) => el.addEventListener("click", noop));
  246. }
  247. let shouldListen = true;
  248. const shouldIgnore = (event) => {
  249. return ignore.some((target2) => {
  250. if (typeof target2 === "string") {
  251. return Array.from(window.document.querySelectorAll(target2)).some((el) => el === event.target || event.composedPath().includes(el));
  252. } else {
  253. const el = unrefElement(target2);
  254. return el && (event.target === el || event.composedPath().includes(el));
  255. }
  256. });
  257. };
  258. const listener = (event) => {
  259. const el = unrefElement(target);
  260. if (!el || el === event.target || event.composedPath().includes(el))
  261. return;
  262. if (event.detail === 0)
  263. shouldListen = !shouldIgnore(event);
  264. if (!shouldListen) {
  265. shouldListen = true;
  266. return;
  267. }
  268. handler(event);
  269. };
  270. const cleanup = [
  271. useEventListener(window, "click", listener, { passive: true, capture }),
  272. useEventListener(window, "pointerdown", (e) => {
  273. const el = unrefElement(target);
  274. if (el)
  275. shouldListen = !e.composedPath().includes(el) && !shouldIgnore(e);
  276. }, { passive: true }),
  277. detectIframe && useEventListener(window, "blur", (event) => {
  278. var _a;
  279. const el = unrefElement(target);
  280. if (((_a = window.document.activeElement) == null ? void 0 : _a.tagName) === "IFRAME" && !(el == null ? void 0 : el.contains(window.document.activeElement)))
  281. handler(event);
  282. })
  283. ].filter(Boolean);
  284. const stop = () => cleanup.forEach((fn) => fn());
  285. return stop;
  286. }
  287. var __defProp$o = Object.defineProperty;
  288. var __defProps$b = Object.defineProperties;
  289. var __getOwnPropDescs$b = Object.getOwnPropertyDescriptors;
  290. var __getOwnPropSymbols$r = Object.getOwnPropertySymbols;
  291. var __hasOwnProp$r = Object.prototype.hasOwnProperty;
  292. var __propIsEnum$r = Object.prototype.propertyIsEnumerable;
  293. var __defNormalProp$o = (obj, key, value) => key in obj ? __defProp$o(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  294. var __spreadValues$o = (a, b) => {
  295. for (var prop in b || (b = {}))
  296. if (__hasOwnProp$r.call(b, prop))
  297. __defNormalProp$o(a, prop, b[prop]);
  298. if (__getOwnPropSymbols$r)
  299. for (var prop of __getOwnPropSymbols$r(b)) {
  300. if (__propIsEnum$r.call(b, prop))
  301. __defNormalProp$o(a, prop, b[prop]);
  302. }
  303. return a;
  304. };
  305. var __spreadProps$b = (a, b) => __defProps$b(a, __getOwnPropDescs$b(b));
  306. function createKeyPredicate(keyFilter) {
  307. if (typeof keyFilter === "function")
  308. return keyFilter;
  309. else if (typeof keyFilter === "string")
  310. return (event) => event.key === keyFilter;
  311. else if (Array.isArray(keyFilter))
  312. return (event) => keyFilter.includes(event.key);
  313. return () => true;
  314. }
  315. function onKeyStroke(...args) {
  316. let key;
  317. let handler;
  318. let options = {};
  319. if (args.length === 3) {
  320. key = args[0];
  321. handler = args[1];
  322. options = args[2];
  323. } else if (args.length === 2) {
  324. if (typeof args[1] === "object") {
  325. key = true;
  326. handler = args[0];
  327. options = args[1];
  328. } else {
  329. key = args[0];
  330. handler = args[1];
  331. }
  332. } else {
  333. key = true;
  334. handler = args[0];
  335. }
  336. const {
  337. target = defaultWindow,
  338. eventName = "keydown",
  339. passive = false,
  340. dedupe = false
  341. } = options;
  342. const predicate = createKeyPredicate(key);
  343. const listener = (e) => {
  344. if (e.repeat && toValue(dedupe))
  345. return;
  346. if (predicate(e))
  347. handler(e);
  348. };
  349. return useEventListener(target, eventName, listener, passive);
  350. }
  351. function onKeyDown(key, handler, options = {}) {
  352. return onKeyStroke(key, handler, __spreadProps$b(__spreadValues$o({}, options), { eventName: "keydown" }));
  353. }
  354. function onKeyPressed(key, handler, options = {}) {
  355. return onKeyStroke(key, handler, __spreadProps$b(__spreadValues$o({}, options), { eventName: "keypress" }));
  356. }
  357. function onKeyUp(key, handler, options = {}) {
  358. return onKeyStroke(key, handler, __spreadProps$b(__spreadValues$o({}, options), { eventName: "keyup" }));
  359. }
  360. const DEFAULT_DELAY = 500;
  361. function onLongPress(target, handler, options) {
  362. var _a, _b;
  363. const elementRef = computed(() => unrefElement(target));
  364. let timeout;
  365. function clear() {
  366. if (timeout) {
  367. clearTimeout(timeout);
  368. timeout = void 0;
  369. }
  370. }
  371. function onDown(ev) {
  372. var _a2, _b2, _c, _d;
  373. if (((_a2 = options == null ? void 0 : options.modifiers) == null ? void 0 : _a2.self) && ev.target !== elementRef.value)
  374. return;
  375. clear();
  376. if ((_b2 = options == null ? void 0 : options.modifiers) == null ? void 0 : _b2.prevent)
  377. ev.preventDefault();
  378. if ((_c = options == null ? void 0 : options.modifiers) == null ? void 0 : _c.stop)
  379. ev.stopPropagation();
  380. timeout = setTimeout(
  381. () => handler(ev),
  382. (_d = options == null ? void 0 : options.delay) != null ? _d : DEFAULT_DELAY
  383. );
  384. }
  385. const listenerOptions = {
  386. capture: (_a = options == null ? void 0 : options.modifiers) == null ? void 0 : _a.capture,
  387. once: (_b = options == null ? void 0 : options.modifiers) == null ? void 0 : _b.once
  388. };
  389. useEventListener(elementRef, "pointerdown", onDown, listenerOptions);
  390. useEventListener(elementRef, "pointerup", clear, listenerOptions);
  391. useEventListener(elementRef, "pointerleave", clear, listenerOptions);
  392. }
  393. function isFocusedElementEditable() {
  394. const { activeElement, body } = document;
  395. if (!activeElement)
  396. return false;
  397. if (activeElement === body)
  398. return false;
  399. switch (activeElement.tagName) {
  400. case "INPUT":
  401. case "TEXTAREA":
  402. return true;
  403. }
  404. return activeElement.hasAttribute("contenteditable");
  405. }
  406. function isTypedCharValid({
  407. keyCode,
  408. metaKey,
  409. ctrlKey,
  410. altKey
  411. }) {
  412. if (metaKey || ctrlKey || altKey)
  413. return false;
  414. if (keyCode >= 48 && keyCode <= 57)
  415. return true;
  416. if (keyCode >= 65 && keyCode <= 90)
  417. return true;
  418. if (keyCode >= 97 && keyCode <= 122)
  419. return true;
  420. return false;
  421. }
  422. function onStartTyping(callback, options = {}) {
  423. const { document: document2 = defaultDocument } = options;
  424. const keydown = (event) => {
  425. !isFocusedElementEditable() && isTypedCharValid(event) && callback(event);
  426. };
  427. if (document2)
  428. useEventListener(document2, "keydown", keydown, { passive: true });
  429. }
  430. function templateRef(key, initialValue = null) {
  431. const instance = getCurrentInstance();
  432. let _trigger = () => {
  433. };
  434. const element = customRef((track, trigger) => {
  435. _trigger = trigger;
  436. return {
  437. get() {
  438. var _a, _b;
  439. track();
  440. return (_b = (_a = instance == null ? void 0 : instance.proxy) == null ? void 0 : _a.$refs[key]) != null ? _b : initialValue;
  441. },
  442. set() {
  443. }
  444. };
  445. });
  446. tryOnMounted(_trigger);
  447. onUpdated(_trigger);
  448. return element;
  449. }
  450. function useActiveElement(options = {}) {
  451. var _a;
  452. const { window = defaultWindow } = options;
  453. const document = (_a = options.document) != null ? _a : window == null ? void 0 : window.document;
  454. const activeElement = computedWithControl(
  455. () => null,
  456. () => document == null ? void 0 : document.activeElement
  457. );
  458. if (window) {
  459. useEventListener(window, "blur", (event) => {
  460. if (event.relatedTarget !== null)
  461. return;
  462. activeElement.trigger();
  463. }, true);
  464. useEventListener(window, "focus", activeElement.trigger, true);
  465. }
  466. return activeElement;
  467. }
  468. function useMounted() {
  469. const isMounted = ref(false);
  470. if (getCurrentInstance()) {
  471. onMounted(() => {
  472. isMounted.value = true;
  473. });
  474. }
  475. return isMounted;
  476. }
  477. function useSupported(callback) {
  478. const isMounted = useMounted();
  479. return computed(() => {
  480. isMounted.value;
  481. return Boolean(callback());
  482. });
  483. }
  484. function useRafFn(fn, options = {}) {
  485. const {
  486. immediate = true,
  487. window = defaultWindow
  488. } = options;
  489. const isActive = ref(false);
  490. let previousFrameTimestamp = 0;
  491. let rafId = null;
  492. function loop(timestamp) {
  493. if (!isActive.value || !window)
  494. return;
  495. const delta = timestamp - previousFrameTimestamp;
  496. fn({ delta, timestamp });
  497. previousFrameTimestamp = timestamp;
  498. rafId = window.requestAnimationFrame(loop);
  499. }
  500. function resume() {
  501. if (!isActive.value && window) {
  502. isActive.value = true;
  503. rafId = window.requestAnimationFrame(loop);
  504. }
  505. }
  506. function pause() {
  507. isActive.value = false;
  508. if (rafId != null && window) {
  509. window.cancelAnimationFrame(rafId);
  510. rafId = null;
  511. }
  512. }
  513. if (immediate)
  514. resume();
  515. tryOnScopeDispose(pause);
  516. return {
  517. isActive: readonly(isActive),
  518. pause,
  519. resume
  520. };
  521. }
  522. function useAnimate(target, keyframes, options) {
  523. let config;
  524. let animateOptions;
  525. if (isObject(options)) {
  526. config = options;
  527. animateOptions = objectOmit(options, ["window", "immediate", "commitStyles", "persist", "onReady", "onError"]);
  528. } else {
  529. config = { duration: options };
  530. animateOptions = options;
  531. }
  532. const {
  533. window = defaultWindow,
  534. immediate = true,
  535. commitStyles,
  536. persist,
  537. playbackRate: _playbackRate = 1,
  538. onReady,
  539. onError = (e) => {
  540. console.error(e);
  541. }
  542. } = config;
  543. const isSupported = useSupported(() => window && HTMLElement && "animate" in HTMLElement.prototype);
  544. const animate = shallowRef(void 0);
  545. const store = shallowReactive({
  546. startTime: null,
  547. currentTime: null,
  548. timeline: null,
  549. playbackRate: _playbackRate,
  550. pending: false,
  551. playState: immediate ? "idle" : "paused",
  552. replaceState: "active"
  553. });
  554. const pending = computed(() => store.pending);
  555. const playState = computed(() => store.playState);
  556. const replaceState = computed(() => store.replaceState);
  557. const startTime = computed({
  558. get() {
  559. return store.startTime;
  560. },
  561. set(value) {
  562. store.startTime = value;
  563. if (animate.value)
  564. animate.value.startTime = value;
  565. }
  566. });
  567. const currentTime = computed({
  568. get() {
  569. return store.currentTime;
  570. },
  571. set(value) {
  572. store.currentTime = value;
  573. if (animate.value) {
  574. animate.value.currentTime = value;
  575. syncResume();
  576. }
  577. }
  578. });
  579. const timeline = computed({
  580. get() {
  581. return store.timeline;
  582. },
  583. set(value) {
  584. store.timeline = value;
  585. if (animate.value)
  586. animate.value.timeline = value;
  587. }
  588. });
  589. const playbackRate = computed({
  590. get() {
  591. return store.playbackRate;
  592. },
  593. set(value) {
  594. store.playbackRate = value;
  595. if (animate.value)
  596. animate.value.playbackRate = value;
  597. }
  598. });
  599. const play = () => {
  600. if (animate.value) {
  601. try {
  602. animate.value.play();
  603. syncResume();
  604. } catch (e) {
  605. syncPause();
  606. onError(e);
  607. }
  608. } else {
  609. update();
  610. }
  611. };
  612. const pause = () => {
  613. var _a;
  614. try {
  615. (_a = animate.value) == null ? void 0 : _a.pause();
  616. syncPause();
  617. } catch (e) {
  618. onError(e);
  619. }
  620. };
  621. const reverse = () => {
  622. var _a;
  623. !animate.value && update();
  624. try {
  625. (_a = animate.value) == null ? void 0 : _a.reverse();
  626. syncResume();
  627. } catch (e) {
  628. syncPause();
  629. onError(e);
  630. }
  631. };
  632. const finish = () => {
  633. var _a;
  634. try {
  635. (_a = animate.value) == null ? void 0 : _a.finish();
  636. syncPause();
  637. } catch (e) {
  638. onError(e);
  639. }
  640. };
  641. const cancel = () => {
  642. var _a;
  643. try {
  644. (_a = animate.value) == null ? void 0 : _a.cancel();
  645. syncPause();
  646. } catch (e) {
  647. onError(e);
  648. }
  649. };
  650. watch(() => unrefElement(target), (el) => {
  651. el && update();
  652. });
  653. watch(() => keyframes, (value) => {
  654. !animate.value && update();
  655. if (!unrefElement(target) && animate.value) {
  656. animate.value.effect = new KeyframeEffect(
  657. unrefElement(target),
  658. toValue(value),
  659. animateOptions
  660. );
  661. }
  662. }, { deep: true });
  663. tryOnMounted(() => {
  664. nextTick(() => update(true));
  665. });
  666. tryOnScopeDispose(cancel);
  667. function update(init) {
  668. const el = unrefElement(target);
  669. if (!isSupported.value || !el)
  670. return;
  671. animate.value = el.animate(toValue(keyframes), animateOptions);
  672. if (commitStyles)
  673. animate.value.commitStyles();
  674. if (persist)
  675. animate.value.persist();
  676. if (_playbackRate !== 1)
  677. animate.value.playbackRate = _playbackRate;
  678. if (init && !immediate)
  679. animate.value.pause();
  680. else
  681. syncResume();
  682. onReady == null ? void 0 : onReady(animate.value);
  683. }
  684. useEventListener(animate, "cancel", syncPause);
  685. useEventListener(animate, "finish", syncPause);
  686. useEventListener(animate, "remove", syncPause);
  687. const { resume: resumeRef, pause: pauseRef } = useRafFn(() => {
  688. if (!animate.value)
  689. return;
  690. store.pending = animate.value.pending;
  691. store.playState = animate.value.playState;
  692. store.replaceState = animate.value.replaceState;
  693. store.startTime = animate.value.startTime;
  694. store.currentTime = animate.value.currentTime;
  695. store.timeline = animate.value.timeline;
  696. store.playbackRate = animate.value.playbackRate;
  697. }, { immediate: false });
  698. function syncResume() {
  699. if (isSupported.value)
  700. resumeRef();
  701. }
  702. function syncPause() {
  703. if (isSupported.value && window)
  704. window.requestAnimationFrame(pauseRef);
  705. }
  706. return {
  707. isSupported,
  708. animate,
  709. // actions
  710. play,
  711. pause,
  712. reverse,
  713. finish,
  714. cancel,
  715. // state
  716. pending,
  717. playState,
  718. replaceState,
  719. startTime,
  720. currentTime,
  721. timeline,
  722. playbackRate
  723. };
  724. }
  725. function useAsyncQueue(tasks, options = {}) {
  726. const {
  727. interrupt = true,
  728. onError = noop,
  729. onFinished = noop
  730. } = options;
  731. const promiseState = {
  732. pending: "pending",
  733. rejected: "rejected",
  734. fulfilled: "fulfilled"
  735. };
  736. const initialResult = Array.from(new Array(tasks.length), () => ({ state: promiseState.pending, data: null }));
  737. const result = reactive(initialResult);
  738. const activeIndex = ref(-1);
  739. if (!tasks || tasks.length === 0) {
  740. onFinished();
  741. return {
  742. activeIndex,
  743. result
  744. };
  745. }
  746. function updateResult(state, res) {
  747. activeIndex.value++;
  748. result[activeIndex.value].data = res;
  749. result[activeIndex.value].state = state;
  750. }
  751. tasks.reduce((prev, curr) => {
  752. return prev.then((prevRes) => {
  753. var _a;
  754. if (((_a = result[activeIndex.value]) == null ? void 0 : _a.state) === promiseState.rejected && interrupt) {
  755. onFinished();
  756. return;
  757. }
  758. return curr(prevRes).then((currentRes) => {
  759. updateResult(promiseState.fulfilled, currentRes);
  760. activeIndex.value === tasks.length - 1 && onFinished();
  761. return currentRes;
  762. });
  763. }).catch((e) => {
  764. updateResult(promiseState.rejected, e);
  765. onError();
  766. return e;
  767. });
  768. }, Promise.resolve());
  769. return {
  770. activeIndex,
  771. result
  772. };
  773. }
  774. var __defProp$n = Object.defineProperty;
  775. var __defProps$a = Object.defineProperties;
  776. var __getOwnPropDescs$a = Object.getOwnPropertyDescriptors;
  777. var __getOwnPropSymbols$q = Object.getOwnPropertySymbols;
  778. var __hasOwnProp$q = Object.prototype.hasOwnProperty;
  779. var __propIsEnum$q = Object.prototype.propertyIsEnumerable;
  780. var __defNormalProp$n = (obj, key, value) => key in obj ? __defProp$n(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  781. var __spreadValues$n = (a, b) => {
  782. for (var prop in b || (b = {}))
  783. if (__hasOwnProp$q.call(b, prop))
  784. __defNormalProp$n(a, prop, b[prop]);
  785. if (__getOwnPropSymbols$q)
  786. for (var prop of __getOwnPropSymbols$q(b)) {
  787. if (__propIsEnum$q.call(b, prop))
  788. __defNormalProp$n(a, prop, b[prop]);
  789. }
  790. return a;
  791. };
  792. var __spreadProps$a = (a, b) => __defProps$a(a, __getOwnPropDescs$a(b));
  793. function useAsyncState(promise, initialState, options) {
  794. const {
  795. immediate = true,
  796. delay = 0,
  797. onError = noop,
  798. onSuccess = noop,
  799. resetOnExecute = true,
  800. shallow = true,
  801. throwError
  802. } = options != null ? options : {};
  803. const state = shallow ? shallowRef(initialState) : ref(initialState);
  804. const isReady = ref(false);
  805. const isLoading = ref(false);
  806. const error = shallowRef(void 0);
  807. async function execute(delay2 = 0, ...args) {
  808. if (resetOnExecute)
  809. state.value = initialState;
  810. error.value = void 0;
  811. isReady.value = false;
  812. isLoading.value = true;
  813. if (delay2 > 0)
  814. await promiseTimeout(delay2);
  815. const _promise = typeof promise === "function" ? promise(...args) : promise;
  816. try {
  817. const data = await _promise;
  818. state.value = data;
  819. isReady.value = true;
  820. onSuccess(data);
  821. } catch (e) {
  822. error.value = e;
  823. onError(e);
  824. if (throwError)
  825. throw e;
  826. } finally {
  827. isLoading.value = false;
  828. }
  829. return state.value;
  830. }
  831. if (immediate)
  832. execute(delay);
  833. const shell = {
  834. state,
  835. isReady,
  836. isLoading,
  837. error,
  838. execute
  839. };
  840. function waitUntilIsLoaded() {
  841. return new Promise((resolve, reject) => {
  842. until(isLoading).toBe(false).then(() => resolve(shell)).catch(reject);
  843. });
  844. }
  845. return __spreadProps$a(__spreadValues$n({}, shell), {
  846. then(onFulfilled, onRejected) {
  847. return waitUntilIsLoaded().then(onFulfilled, onRejected);
  848. }
  849. });
  850. }
  851. const defaults = {
  852. array: (v) => JSON.stringify(v),
  853. object: (v) => JSON.stringify(v),
  854. set: (v) => JSON.stringify(Array.from(v)),
  855. map: (v) => JSON.stringify(Object.fromEntries(v)),
  856. null: () => ""
  857. };
  858. function getDefaultSerialization(target) {
  859. if (!target)
  860. return defaults.null;
  861. if (target instanceof Map)
  862. return defaults.map;
  863. else if (target instanceof Set)
  864. return defaults.set;
  865. else if (Array.isArray(target))
  866. return defaults.array;
  867. else
  868. return defaults.object;
  869. }
  870. function useBase64(target, options) {
  871. const base64 = ref("");
  872. const promise = ref();
  873. function execute() {
  874. if (!isClient)
  875. return;
  876. promise.value = new Promise((resolve, reject) => {
  877. try {
  878. const _target = toValue(target);
  879. if (_target == null) {
  880. resolve("");
  881. } else if (typeof _target === "string") {
  882. resolve(blobToBase64(new Blob([_target], { type: "text/plain" })));
  883. } else if (_target instanceof Blob) {
  884. resolve(blobToBase64(_target));
  885. } else if (_target instanceof ArrayBuffer) {
  886. resolve(window.btoa(String.fromCharCode(...new Uint8Array(_target))));
  887. } else if (_target instanceof HTMLCanvasElement) {
  888. resolve(_target.toDataURL(options == null ? void 0 : options.type, options == null ? void 0 : options.quality));
  889. } else if (_target instanceof HTMLImageElement) {
  890. const img = _target.cloneNode(false);
  891. img.crossOrigin = "Anonymous";
  892. imgLoaded(img).then(() => {
  893. const canvas = document.createElement("canvas");
  894. const ctx = canvas.getContext("2d");
  895. canvas.width = img.width;
  896. canvas.height = img.height;
  897. ctx.drawImage(img, 0, 0, canvas.width, canvas.height);
  898. resolve(canvas.toDataURL(options == null ? void 0 : options.type, options == null ? void 0 : options.quality));
  899. }).catch(reject);
  900. } else if (typeof _target === "object") {
  901. const _serializeFn = (options == null ? void 0 : options.serializer) || getDefaultSerialization(_target);
  902. const serialized = _serializeFn(_target);
  903. return resolve(blobToBase64(new Blob([serialized], { type: "application/json" })));
  904. } else {
  905. reject(new Error("target is unsupported types"));
  906. }
  907. } catch (error) {
  908. reject(error);
  909. }
  910. });
  911. promise.value.then((res) => base64.value = res);
  912. return promise.value;
  913. }
  914. if (isRef(target) || typeof target === "function")
  915. watch(target, execute, { immediate: true });
  916. else
  917. execute();
  918. return {
  919. base64,
  920. promise,
  921. execute
  922. };
  923. }
  924. function imgLoaded(img) {
  925. return new Promise((resolve, reject) => {
  926. if (!img.complete) {
  927. img.onload = () => {
  928. resolve();
  929. };
  930. img.onerror = reject;
  931. } else {
  932. resolve();
  933. }
  934. });
  935. }
  936. function blobToBase64(blob) {
  937. return new Promise((resolve, reject) => {
  938. const fr = new FileReader();
  939. fr.onload = (e) => {
  940. resolve(e.target.result);
  941. };
  942. fr.onerror = reject;
  943. fr.readAsDataURL(blob);
  944. });
  945. }
  946. function useBattery({ navigator = defaultNavigator } = {}) {
  947. const events = ["chargingchange", "chargingtimechange", "dischargingtimechange", "levelchange"];
  948. const isSupported = useSupported(() => navigator && "getBattery" in navigator);
  949. const charging = ref(false);
  950. const chargingTime = ref(0);
  951. const dischargingTime = ref(0);
  952. const level = ref(1);
  953. let battery;
  954. function updateBatteryInfo() {
  955. charging.value = this.charging;
  956. chargingTime.value = this.chargingTime || 0;
  957. dischargingTime.value = this.dischargingTime || 0;
  958. level.value = this.level;
  959. }
  960. if (isSupported.value) {
  961. navigator.getBattery().then((_battery) => {
  962. battery = _battery;
  963. updateBatteryInfo.call(battery);
  964. for (const event of events)
  965. useEventListener(battery, event, updateBatteryInfo, { passive: true });
  966. });
  967. }
  968. return {
  969. isSupported,
  970. charging,
  971. chargingTime,
  972. dischargingTime,
  973. level
  974. };
  975. }
  976. function useBluetooth(options) {
  977. let {
  978. acceptAllDevices = false
  979. } = options || {};
  980. const {
  981. filters = void 0,
  982. optionalServices = void 0,
  983. navigator = defaultNavigator
  984. } = options || {};
  985. const isSupported = useSupported(() => navigator && "bluetooth" in navigator);
  986. const device = shallowRef(void 0);
  987. const error = shallowRef(null);
  988. watch(device, () => {
  989. connectToBluetoothGATTServer();
  990. });
  991. async function requestDevice() {
  992. if (!isSupported.value)
  993. return;
  994. error.value = null;
  995. if (filters && filters.length > 0)
  996. acceptAllDevices = false;
  997. try {
  998. device.value = await (navigator == null ? void 0 : navigator.bluetooth.requestDevice({
  999. acceptAllDevices,
  1000. filters,
  1001. optionalServices
  1002. }));
  1003. } catch (err) {
  1004. error.value = err;
  1005. }
  1006. }
  1007. const server = ref();
  1008. const isConnected = computed(() => {
  1009. var _a;
  1010. return ((_a = server.value) == null ? void 0 : _a.connected) || false;
  1011. });
  1012. async function connectToBluetoothGATTServer() {
  1013. error.value = null;
  1014. if (device.value && device.value.gatt) {
  1015. device.value.addEventListener("gattserverdisconnected", () => {
  1016. });
  1017. try {
  1018. server.value = await device.value.gatt.connect();
  1019. } catch (err) {
  1020. error.value = err;
  1021. }
  1022. }
  1023. }
  1024. tryOnMounted(() => {
  1025. var _a;
  1026. if (device.value)
  1027. (_a = device.value.gatt) == null ? void 0 : _a.connect();
  1028. });
  1029. tryOnScopeDispose(() => {
  1030. var _a;
  1031. if (device.value)
  1032. (_a = device.value.gatt) == null ? void 0 : _a.disconnect();
  1033. });
  1034. return {
  1035. isSupported,
  1036. isConnected,
  1037. // Device:
  1038. device,
  1039. requestDevice,
  1040. // Server:
  1041. server,
  1042. // Errors:
  1043. error
  1044. };
  1045. }
  1046. function useMediaQuery(query, options = {}) {
  1047. const { window = defaultWindow } = options;
  1048. const isSupported = useSupported(() => window && "matchMedia" in window && typeof window.matchMedia === "function");
  1049. let mediaQuery;
  1050. const matches = ref(false);
  1051. const cleanup = () => {
  1052. if (!mediaQuery)
  1053. return;
  1054. if ("removeEventListener" in mediaQuery)
  1055. mediaQuery.removeEventListener("change", update);
  1056. else
  1057. mediaQuery.removeListener(update);
  1058. };
  1059. const update = () => {
  1060. if (!isSupported.value)
  1061. return;
  1062. cleanup();
  1063. mediaQuery = window.matchMedia(toRef(query).value);
  1064. matches.value = !!(mediaQuery == null ? void 0 : mediaQuery.matches);
  1065. if (!mediaQuery)
  1066. return;
  1067. if ("addEventListener" in mediaQuery)
  1068. mediaQuery.addEventListener("change", update);
  1069. else
  1070. mediaQuery.addListener(update);
  1071. };
  1072. watchEffect(update);
  1073. tryOnScopeDispose(() => cleanup());
  1074. return matches;
  1075. }
  1076. const breakpointsTailwind = {
  1077. "sm": 640,
  1078. "md": 768,
  1079. "lg": 1024,
  1080. "xl": 1280,
  1081. "2xl": 1536
  1082. };
  1083. const breakpointsBootstrapV5 = {
  1084. sm: 576,
  1085. md: 768,
  1086. lg: 992,
  1087. xl: 1200,
  1088. xxl: 1400
  1089. };
  1090. const breakpointsVuetify = {
  1091. xs: 600,
  1092. sm: 960,
  1093. md: 1264,
  1094. lg: 1904
  1095. };
  1096. const breakpointsAntDesign = {
  1097. xs: 480,
  1098. sm: 576,
  1099. md: 768,
  1100. lg: 992,
  1101. xl: 1200,
  1102. xxl: 1600
  1103. };
  1104. const breakpointsQuasar = {
  1105. xs: 600,
  1106. sm: 1024,
  1107. md: 1440,
  1108. lg: 1920
  1109. };
  1110. const breakpointsSematic = {
  1111. mobileS: 320,
  1112. mobileM: 375,
  1113. mobileL: 425,
  1114. tablet: 768,
  1115. laptop: 1024,
  1116. laptopL: 1440,
  1117. desktop4K: 2560
  1118. };
  1119. const breakpointsMasterCss = {
  1120. "3xs": 360,
  1121. "2xs": 480,
  1122. "xs": 600,
  1123. "sm": 768,
  1124. "md": 1024,
  1125. "lg": 1280,
  1126. "xl": 1440,
  1127. "2xl": 1600,
  1128. "3xl": 1920,
  1129. "4xl": 2560
  1130. };
  1131. function useBreakpoints(breakpoints, options = {}) {
  1132. function getValue(k, delta) {
  1133. let v = breakpoints[k];
  1134. if (delta != null)
  1135. v = increaseWithUnit(v, delta);
  1136. if (typeof v === "number")
  1137. v = `${v}px`;
  1138. return v;
  1139. }
  1140. const { window = defaultWindow } = options;
  1141. function match(query) {
  1142. if (!window)
  1143. return false;
  1144. return window.matchMedia(query).matches;
  1145. }
  1146. const greaterOrEqual = (k) => {
  1147. return useMediaQuery(`(min-width: ${getValue(k)})`, options);
  1148. };
  1149. const shortcutMethods = Object.keys(breakpoints).reduce((shortcuts, k) => {
  1150. Object.defineProperty(shortcuts, k, {
  1151. get: () => greaterOrEqual(k),
  1152. enumerable: true,
  1153. configurable: true
  1154. });
  1155. return shortcuts;
  1156. }, {});
  1157. return Object.assign(shortcutMethods, {
  1158. greater(k) {
  1159. return useMediaQuery(`(min-width: ${getValue(k, 0.1)})`, options);
  1160. },
  1161. greaterOrEqual,
  1162. smaller(k) {
  1163. return useMediaQuery(`(max-width: ${getValue(k, -0.1)})`, options);
  1164. },
  1165. smallerOrEqual(k) {
  1166. return useMediaQuery(`(max-width: ${getValue(k)})`, options);
  1167. },
  1168. between(a, b) {
  1169. return useMediaQuery(`(min-width: ${getValue(a)}) and (max-width: ${getValue(b, -0.1)})`, options);
  1170. },
  1171. isGreater(k) {
  1172. return match(`(min-width: ${getValue(k, 0.1)})`);
  1173. },
  1174. isGreaterOrEqual(k) {
  1175. return match(`(min-width: ${getValue(k)})`);
  1176. },
  1177. isSmaller(k) {
  1178. return match(`(max-width: ${getValue(k, -0.1)})`);
  1179. },
  1180. isSmallerOrEqual(k) {
  1181. return match(`(max-width: ${getValue(k)})`);
  1182. },
  1183. isInBetween(a, b) {
  1184. return match(`(min-width: ${getValue(a)}) and (max-width: ${getValue(b, -0.1)})`);
  1185. },
  1186. current() {
  1187. const points = Object.keys(breakpoints).map((i) => [i, greaterOrEqual(i)]);
  1188. return computed(() => points.filter(([, v]) => v.value).map(([k]) => k));
  1189. }
  1190. });
  1191. }
  1192. function useBroadcastChannel(options) {
  1193. const {
  1194. name,
  1195. window = defaultWindow
  1196. } = options;
  1197. const isSupported = useSupported(() => window && "BroadcastChannel" in window);
  1198. const isClosed = ref(false);
  1199. const channel = ref();
  1200. const data = ref();
  1201. const error = shallowRef(null);
  1202. const post = (data2) => {
  1203. if (channel.value)
  1204. channel.value.postMessage(data2);
  1205. };
  1206. const close = () => {
  1207. if (channel.value)
  1208. channel.value.close();
  1209. isClosed.value = true;
  1210. };
  1211. if (isSupported.value) {
  1212. tryOnMounted(() => {
  1213. error.value = null;
  1214. channel.value = new BroadcastChannel(name);
  1215. channel.value.addEventListener("message", (e) => {
  1216. data.value = e.data;
  1217. }, { passive: true });
  1218. channel.value.addEventListener("messageerror", (e) => {
  1219. error.value = e;
  1220. }, { passive: true });
  1221. channel.value.addEventListener("close", () => {
  1222. isClosed.value = true;
  1223. });
  1224. });
  1225. }
  1226. tryOnScopeDispose(() => {
  1227. close();
  1228. });
  1229. return {
  1230. isSupported,
  1231. channel,
  1232. data,
  1233. post,
  1234. close,
  1235. error,
  1236. isClosed
  1237. };
  1238. }
  1239. var __defProp$m = Object.defineProperty;
  1240. var __getOwnPropSymbols$p = Object.getOwnPropertySymbols;
  1241. var __hasOwnProp$p = Object.prototype.hasOwnProperty;
  1242. var __propIsEnum$p = Object.prototype.propertyIsEnumerable;
  1243. var __defNormalProp$m = (obj, key, value) => key in obj ? __defProp$m(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  1244. var __spreadValues$m = (a, b) => {
  1245. for (var prop in b || (b = {}))
  1246. if (__hasOwnProp$p.call(b, prop))
  1247. __defNormalProp$m(a, prop, b[prop]);
  1248. if (__getOwnPropSymbols$p)
  1249. for (var prop of __getOwnPropSymbols$p(b)) {
  1250. if (__propIsEnum$p.call(b, prop))
  1251. __defNormalProp$m(a, prop, b[prop]);
  1252. }
  1253. return a;
  1254. };
  1255. const WRITABLE_PROPERTIES = [
  1256. "hash",
  1257. "host",
  1258. "hostname",
  1259. "href",
  1260. "pathname",
  1261. "port",
  1262. "protocol",
  1263. "search"
  1264. ];
  1265. function useBrowserLocation({ window = defaultWindow } = {}) {
  1266. const refs = Object.fromEntries(
  1267. WRITABLE_PROPERTIES.map((key) => [key, ref()])
  1268. );
  1269. for (const [key, ref2] of objectEntries(refs)) {
  1270. watch(ref2, (value) => {
  1271. if (!(window == null ? void 0 : window.location) || window.location[key] === value)
  1272. return;
  1273. window.location[key] = value;
  1274. });
  1275. }
  1276. const buildState = (trigger) => {
  1277. var _a;
  1278. const { state: state2, length } = (window == null ? void 0 : window.history) || {};
  1279. const { origin } = (window == null ? void 0 : window.location) || {};
  1280. for (const key of WRITABLE_PROPERTIES)
  1281. refs[key].value = (_a = window == null ? void 0 : window.location) == null ? void 0 : _a[key];
  1282. return reactive(__spreadValues$m({
  1283. trigger,
  1284. state: state2,
  1285. length,
  1286. origin
  1287. }, refs));
  1288. };
  1289. const state = ref(buildState("load"));
  1290. if (window) {
  1291. useEventListener(window, "popstate", () => state.value = buildState("popstate"), { passive: true });
  1292. useEventListener(window, "hashchange", () => state.value = buildState("hashchange"), { passive: true });
  1293. }
  1294. return state;
  1295. }
  1296. function useCached(refValue, comparator = (a, b) => a === b, watchOptions) {
  1297. const cachedValue = ref(refValue.value);
  1298. watch(() => refValue.value, (value) => {
  1299. if (!comparator(value, cachedValue.value))
  1300. cachedValue.value = value;
  1301. }, watchOptions);
  1302. return cachedValue;
  1303. }
  1304. function useClipboard(options = {}) {
  1305. const {
  1306. navigator = defaultNavigator,
  1307. read = false,
  1308. source,
  1309. copiedDuring = 1500,
  1310. legacy = false
  1311. } = options;
  1312. const events = ["copy", "cut"];
  1313. const isClipboardApiSupported = useSupported(() => navigator && "clipboard" in navigator);
  1314. const isSupported = computed(() => isClipboardApiSupported.value || legacy);
  1315. const text = ref("");
  1316. const copied = ref(false);
  1317. const timeout = useTimeoutFn(() => copied.value = false, copiedDuring);
  1318. function updateText() {
  1319. if (isClipboardApiSupported.value) {
  1320. navigator.clipboard.readText().then((value) => {
  1321. text.value = value;
  1322. });
  1323. } else {
  1324. text.value = legacyRead();
  1325. }
  1326. }
  1327. if (isSupported.value && read) {
  1328. for (const event of events)
  1329. useEventListener(event, updateText);
  1330. }
  1331. async function copy(value = toValue(source)) {
  1332. if (isSupported.value && value != null) {
  1333. if (isClipboardApiSupported.value)
  1334. await navigator.clipboard.writeText(value);
  1335. else
  1336. legacyCopy(value);
  1337. text.value = value;
  1338. copied.value = true;
  1339. timeout.start();
  1340. }
  1341. }
  1342. function legacyCopy(value) {
  1343. const ta = document.createElement("textarea");
  1344. ta.value = value != null ? value : "";
  1345. ta.style.position = "absolute";
  1346. ta.style.opacity = "0";
  1347. document.body.appendChild(ta);
  1348. ta.select();
  1349. document.execCommand("copy");
  1350. ta.remove();
  1351. }
  1352. function legacyRead() {
  1353. var _a, _b, _c;
  1354. return (_c = (_b = (_a = document == null ? void 0 : document.getSelection) == null ? void 0 : _a.call(document)) == null ? void 0 : _b.toString()) != null ? _c : "";
  1355. }
  1356. return {
  1357. isSupported,
  1358. text,
  1359. copied,
  1360. copy
  1361. };
  1362. }
  1363. var __defProp$l = Object.defineProperty;
  1364. var __defProps$9 = Object.defineProperties;
  1365. var __getOwnPropDescs$9 = Object.getOwnPropertyDescriptors;
  1366. var __getOwnPropSymbols$o = Object.getOwnPropertySymbols;
  1367. var __hasOwnProp$o = Object.prototype.hasOwnProperty;
  1368. var __propIsEnum$o = Object.prototype.propertyIsEnumerable;
  1369. var __defNormalProp$l = (obj, key, value) => key in obj ? __defProp$l(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  1370. var __spreadValues$l = (a, b) => {
  1371. for (var prop in b || (b = {}))
  1372. if (__hasOwnProp$o.call(b, prop))
  1373. __defNormalProp$l(a, prop, b[prop]);
  1374. if (__getOwnPropSymbols$o)
  1375. for (var prop of __getOwnPropSymbols$o(b)) {
  1376. if (__propIsEnum$o.call(b, prop))
  1377. __defNormalProp$l(a, prop, b[prop]);
  1378. }
  1379. return a;
  1380. };
  1381. var __spreadProps$9 = (a, b) => __defProps$9(a, __getOwnPropDescs$9(b));
  1382. function cloneFnJSON(source) {
  1383. return JSON.parse(JSON.stringify(source));
  1384. }
  1385. function useCloned(source, options = {}) {
  1386. const cloned = ref({});
  1387. const {
  1388. manual,
  1389. clone = cloneFnJSON,
  1390. // watch options
  1391. deep = true,
  1392. immediate = true
  1393. } = options;
  1394. function sync() {
  1395. cloned.value = clone(toValue(source));
  1396. }
  1397. if (!manual && isRef(source)) {
  1398. watch(source, sync, __spreadProps$9(__spreadValues$l({}, options), {
  1399. deep,
  1400. immediate
  1401. }));
  1402. } else {
  1403. sync();
  1404. }
  1405. return { cloned, sync };
  1406. }
  1407. const _global = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
  1408. const globalKey = "__vueuse_ssr_handlers__";
  1409. const handlers = /* @__PURE__ */ getHandlers();
  1410. function getHandlers() {
  1411. if (!(globalKey in _global))
  1412. _global[globalKey] = _global[globalKey] || {};
  1413. return _global[globalKey];
  1414. }
  1415. function getSSRHandler(key, fallback) {
  1416. return handlers[key] || fallback;
  1417. }
  1418. function setSSRHandler(key, fn) {
  1419. handlers[key] = fn;
  1420. }
  1421. function guessSerializerType(rawInit) {
  1422. return rawInit == null ? "any" : rawInit instanceof Set ? "set" : rawInit instanceof Map ? "map" : rawInit instanceof Date ? "date" : typeof rawInit === "boolean" ? "boolean" : typeof rawInit === "string" ? "string" : typeof rawInit === "object" ? "object" : !Number.isNaN(rawInit) ? "number" : "any";
  1423. }
  1424. var __defProp$k = Object.defineProperty;
  1425. var __getOwnPropSymbols$n = Object.getOwnPropertySymbols;
  1426. var __hasOwnProp$n = Object.prototype.hasOwnProperty;
  1427. var __propIsEnum$n = Object.prototype.propertyIsEnumerable;
  1428. var __defNormalProp$k = (obj, key, value) => key in obj ? __defProp$k(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  1429. var __spreadValues$k = (a, b) => {
  1430. for (var prop in b || (b = {}))
  1431. if (__hasOwnProp$n.call(b, prop))
  1432. __defNormalProp$k(a, prop, b[prop]);
  1433. if (__getOwnPropSymbols$n)
  1434. for (var prop of __getOwnPropSymbols$n(b)) {
  1435. if (__propIsEnum$n.call(b, prop))
  1436. __defNormalProp$k(a, prop, b[prop]);
  1437. }
  1438. return a;
  1439. };
  1440. const StorageSerializers = {
  1441. boolean: {
  1442. read: (v) => v === "true",
  1443. write: (v) => String(v)
  1444. },
  1445. object: {
  1446. read: (v) => JSON.parse(v),
  1447. write: (v) => JSON.stringify(v)
  1448. },
  1449. number: {
  1450. read: (v) => Number.parseFloat(v),
  1451. write: (v) => String(v)
  1452. },
  1453. any: {
  1454. read: (v) => v,
  1455. write: (v) => String(v)
  1456. },
  1457. string: {
  1458. read: (v) => v,
  1459. write: (v) => String(v)
  1460. },
  1461. map: {
  1462. read: (v) => new Map(JSON.parse(v)),
  1463. write: (v) => JSON.stringify(Array.from(v.entries()))
  1464. },
  1465. set: {
  1466. read: (v) => new Set(JSON.parse(v)),
  1467. write: (v) => JSON.stringify(Array.from(v))
  1468. },
  1469. date: {
  1470. read: (v) => new Date(v),
  1471. write: (v) => v.toISOString()
  1472. }
  1473. };
  1474. const customStorageEventName = "vueuse-storage";
  1475. function useStorage(key, defaults, storage, options = {}) {
  1476. var _a;
  1477. const {
  1478. flush = "pre",
  1479. deep = true,
  1480. listenToStorageChanges = true,
  1481. writeDefaults = true,
  1482. mergeDefaults = false,
  1483. shallow,
  1484. window = defaultWindow,
  1485. eventFilter,
  1486. onError = (e) => {
  1487. console.error(e);
  1488. }
  1489. } = options;
  1490. const data = (shallow ? shallowRef : ref)(defaults);
  1491. if (!storage) {
  1492. try {
  1493. storage = getSSRHandler("getDefaultStorage", () => {
  1494. var _a2;
  1495. return (_a2 = defaultWindow) == null ? void 0 : _a2.localStorage;
  1496. })();
  1497. } catch (e) {
  1498. onError(e);
  1499. }
  1500. }
  1501. if (!storage)
  1502. return data;
  1503. const rawInit = toValue(defaults);
  1504. const type = guessSerializerType(rawInit);
  1505. const serializer = (_a = options.serializer) != null ? _a : StorageSerializers[type];
  1506. const { pause: pauseWatch, resume: resumeWatch } = pausableWatch(
  1507. data,
  1508. () => write(data.value),
  1509. { flush, deep, eventFilter }
  1510. );
  1511. if (window && listenToStorageChanges) {
  1512. useEventListener(window, "storage", update);
  1513. useEventListener(window, customStorageEventName, updateFromCustomEvent);
  1514. }
  1515. update();
  1516. return data;
  1517. function write(v) {
  1518. try {
  1519. if (v == null) {
  1520. storage.removeItem(key);
  1521. } else {
  1522. const serialized = serializer.write(v);
  1523. const oldValue = storage.getItem(key);
  1524. if (oldValue !== serialized) {
  1525. storage.setItem(key, serialized);
  1526. if (window) {
  1527. window.dispatchEvent(new CustomEvent(customStorageEventName, {
  1528. detail: {
  1529. key,
  1530. oldValue,
  1531. newValue: serialized,
  1532. storageArea: storage
  1533. }
  1534. }));
  1535. }
  1536. }
  1537. }
  1538. } catch (e) {
  1539. onError(e);
  1540. }
  1541. }
  1542. function read(event) {
  1543. const rawValue = event ? event.newValue : storage.getItem(key);
  1544. if (rawValue == null) {
  1545. if (writeDefaults && rawInit !== null)
  1546. storage.setItem(key, serializer.write(rawInit));
  1547. return rawInit;
  1548. } else if (!event && mergeDefaults) {
  1549. const value = serializer.read(rawValue);
  1550. if (typeof mergeDefaults === "function")
  1551. return mergeDefaults(value, rawInit);
  1552. else if (type === "object" && !Array.isArray(value))
  1553. return __spreadValues$k(__spreadValues$k({}, rawInit), value);
  1554. return value;
  1555. } else if (typeof rawValue !== "string") {
  1556. return rawValue;
  1557. } else {
  1558. return serializer.read(rawValue);
  1559. }
  1560. }
  1561. function updateFromCustomEvent(event) {
  1562. update(event.detail);
  1563. }
  1564. function update(event) {
  1565. if (event && event.storageArea !== storage)
  1566. return;
  1567. if (event && event.key == null) {
  1568. data.value = rawInit;
  1569. return;
  1570. }
  1571. if (event && event.key !== key)
  1572. return;
  1573. pauseWatch();
  1574. try {
  1575. data.value = read(event);
  1576. } catch (e) {
  1577. onError(e);
  1578. } finally {
  1579. if (event)
  1580. nextTick(resumeWatch);
  1581. else
  1582. resumeWatch();
  1583. }
  1584. }
  1585. }
  1586. function usePreferredDark(options) {
  1587. return useMediaQuery("(prefers-color-scheme: dark)", options);
  1588. }
  1589. var __defProp$j = Object.defineProperty;
  1590. var __getOwnPropSymbols$m = Object.getOwnPropertySymbols;
  1591. var __hasOwnProp$m = Object.prototype.hasOwnProperty;
  1592. var __propIsEnum$m = Object.prototype.propertyIsEnumerable;
  1593. var __defNormalProp$j = (obj, key, value) => key in obj ? __defProp$j(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  1594. var __spreadValues$j = (a, b) => {
  1595. for (var prop in b || (b = {}))
  1596. if (__hasOwnProp$m.call(b, prop))
  1597. __defNormalProp$j(a, prop, b[prop]);
  1598. if (__getOwnPropSymbols$m)
  1599. for (var prop of __getOwnPropSymbols$m(b)) {
  1600. if (__propIsEnum$m.call(b, prop))
  1601. __defNormalProp$j(a, prop, b[prop]);
  1602. }
  1603. return a;
  1604. };
  1605. function useColorMode(options = {}) {
  1606. const {
  1607. selector = "html",
  1608. attribute = "class",
  1609. initialValue = "auto",
  1610. window = defaultWindow,
  1611. storage,
  1612. storageKey = "vueuse-color-scheme",
  1613. listenToStorageChanges = true,
  1614. storageRef,
  1615. emitAuto,
  1616. disableTransition = true
  1617. } = options;
  1618. const modes = __spreadValues$j({
  1619. auto: "",
  1620. light: "light",
  1621. dark: "dark"
  1622. }, options.modes || {});
  1623. const preferredDark = usePreferredDark({ window });
  1624. const system = computed(() => preferredDark.value ? "dark" : "light");
  1625. const store = storageRef || (storageKey == null ? toRef(initialValue) : useStorage(storageKey, initialValue, storage, { window, listenToStorageChanges }));
  1626. const state = computed(
  1627. () => store.value === "auto" ? system.value : store.value
  1628. );
  1629. const updateHTMLAttrs = getSSRHandler(
  1630. "updateHTMLAttrs",
  1631. (selector2, attribute2, value) => {
  1632. const el = typeof selector2 === "string" ? window == null ? void 0 : window.document.querySelector(selector2) : unrefElement(selector2);
  1633. if (!el)
  1634. return;
  1635. let style;
  1636. if (disableTransition) {
  1637. style = window.document.createElement("style");
  1638. style.appendChild(document.createTextNode("*{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}"));
  1639. window.document.head.appendChild(style);
  1640. }
  1641. if (attribute2 === "class") {
  1642. const current = value.split(/\s/g);
  1643. Object.values(modes).flatMap((i) => (i || "").split(/\s/g)).filter(Boolean).forEach((v) => {
  1644. if (current.includes(v))
  1645. el.classList.add(v);
  1646. else
  1647. el.classList.remove(v);
  1648. });
  1649. } else {
  1650. el.setAttribute(attribute2, value);
  1651. }
  1652. if (disableTransition) {
  1653. window.getComputedStyle(style).opacity;
  1654. document.head.removeChild(style);
  1655. }
  1656. }
  1657. );
  1658. function defaultOnChanged(mode) {
  1659. var _a;
  1660. updateHTMLAttrs(selector, attribute, (_a = modes[mode]) != null ? _a : mode);
  1661. }
  1662. function onChanged(mode) {
  1663. if (options.onChanged)
  1664. options.onChanged(mode, defaultOnChanged);
  1665. else
  1666. defaultOnChanged(mode);
  1667. }
  1668. watch(state, onChanged, { flush: "post", immediate: true });
  1669. tryOnMounted(() => onChanged(state.value));
  1670. const auto = computed({
  1671. get() {
  1672. return emitAuto ? store.value : state.value;
  1673. },
  1674. set(v) {
  1675. store.value = v;
  1676. }
  1677. });
  1678. try {
  1679. return Object.assign(auto, { store, system, state });
  1680. } catch (e) {
  1681. return auto;
  1682. }
  1683. }
  1684. function useConfirmDialog(revealed = ref(false)) {
  1685. const confirmHook = createEventHook();
  1686. const cancelHook = createEventHook();
  1687. const revealHook = createEventHook();
  1688. let _resolve = noop;
  1689. const reveal = (data) => {
  1690. revealHook.trigger(data);
  1691. revealed.value = true;
  1692. return new Promise((resolve) => {
  1693. _resolve = resolve;
  1694. });
  1695. };
  1696. const confirm = (data) => {
  1697. revealed.value = false;
  1698. confirmHook.trigger(data);
  1699. _resolve({ data, isCanceled: false });
  1700. };
  1701. const cancel = (data) => {
  1702. revealed.value = false;
  1703. cancelHook.trigger(data);
  1704. _resolve({ data, isCanceled: true });
  1705. };
  1706. return {
  1707. isRevealed: computed(() => revealed.value),
  1708. reveal,
  1709. confirm,
  1710. cancel,
  1711. onReveal: revealHook.on,
  1712. onConfirm: confirmHook.on,
  1713. onCancel: cancelHook.on
  1714. };
  1715. }
  1716. var __getOwnPropSymbols$l = Object.getOwnPropertySymbols;
  1717. var __hasOwnProp$l = Object.prototype.hasOwnProperty;
  1718. var __propIsEnum$l = Object.prototype.propertyIsEnumerable;
  1719. var __objRest$3 = (source, exclude) => {
  1720. var target = {};
  1721. for (var prop in source)
  1722. if (__hasOwnProp$l.call(source, prop) && exclude.indexOf(prop) < 0)
  1723. target[prop] = source[prop];
  1724. if (source != null && __getOwnPropSymbols$l)
  1725. for (var prop of __getOwnPropSymbols$l(source)) {
  1726. if (exclude.indexOf(prop) < 0 && __propIsEnum$l.call(source, prop))
  1727. target[prop] = source[prop];
  1728. }
  1729. return target;
  1730. };
  1731. function useMutationObserver(target, callback, options = {}) {
  1732. const _a = options, { window = defaultWindow } = _a, mutationOptions = __objRest$3(_a, ["window"]);
  1733. let observer;
  1734. const isSupported = useSupported(() => window && "MutationObserver" in window);
  1735. const cleanup = () => {
  1736. if (observer) {
  1737. observer.disconnect();
  1738. observer = void 0;
  1739. }
  1740. };
  1741. const stopWatch = watch(
  1742. () => unrefElement(target),
  1743. (el) => {
  1744. cleanup();
  1745. if (isSupported.value && window && el) {
  1746. observer = new MutationObserver(callback);
  1747. observer.observe(el, mutationOptions);
  1748. }
  1749. },
  1750. { immediate: true }
  1751. );
  1752. const stop = () => {
  1753. cleanup();
  1754. stopWatch();
  1755. };
  1756. tryOnScopeDispose(stop);
  1757. return {
  1758. isSupported,
  1759. stop
  1760. };
  1761. }
  1762. function useCssVar(prop, target, options = {}) {
  1763. const { window = defaultWindow, initialValue = "", observe = false } = options;
  1764. const variable = ref(initialValue);
  1765. const elRef = computed(() => {
  1766. var _a;
  1767. return unrefElement(target) || ((_a = window == null ? void 0 : window.document) == null ? void 0 : _a.documentElement);
  1768. });
  1769. function updateCssVar() {
  1770. var _a;
  1771. const key = toValue(prop);
  1772. const el = toValue(elRef);
  1773. if (el && window) {
  1774. const value = (_a = window.getComputedStyle(el).getPropertyValue(key)) == null ? void 0 : _a.trim();
  1775. variable.value = value || initialValue;
  1776. }
  1777. }
  1778. if (observe) {
  1779. useMutationObserver(elRef, updateCssVar, {
  1780. attributes: true,
  1781. window
  1782. });
  1783. }
  1784. watch(
  1785. [elRef, () => toValue(prop)],
  1786. updateCssVar,
  1787. { immediate: true }
  1788. );
  1789. watch(
  1790. variable,
  1791. (val) => {
  1792. var _a;
  1793. if ((_a = elRef.value) == null ? void 0 : _a.style)
  1794. elRef.value.style.setProperty(toValue(prop), val);
  1795. }
  1796. );
  1797. return variable;
  1798. }
  1799. function useCurrentElement() {
  1800. const vm = getCurrentInstance();
  1801. const currentElement = computedWithControl(
  1802. () => null,
  1803. () => vm.proxy.$el
  1804. );
  1805. onUpdated(currentElement.trigger);
  1806. onMounted(currentElement.trigger);
  1807. return currentElement;
  1808. }
  1809. function useCycleList(list, options) {
  1810. const state = shallowRef(getInitialValue());
  1811. const listRef = toRef(list);
  1812. const index = computed({
  1813. get() {
  1814. var _a;
  1815. const targetList = listRef.value;
  1816. let index2 = (options == null ? void 0 : options.getIndexOf) ? options.getIndexOf(state.value, targetList) : targetList.indexOf(state.value);
  1817. if (index2 < 0)
  1818. index2 = (_a = options == null ? void 0 : options.fallbackIndex) != null ? _a : 0;
  1819. return index2;
  1820. },
  1821. set(v) {
  1822. set(v);
  1823. }
  1824. });
  1825. function set(i) {
  1826. const targetList = listRef.value;
  1827. const length = targetList.length;
  1828. const index2 = (i % length + length) % length;
  1829. const value = targetList[index2];
  1830. state.value = value;
  1831. return value;
  1832. }
  1833. function shift(delta = 1) {
  1834. return set(index.value + delta);
  1835. }
  1836. function next(n = 1) {
  1837. return shift(n);
  1838. }
  1839. function prev(n = 1) {
  1840. return shift(-n);
  1841. }
  1842. function getInitialValue() {
  1843. var _a, _b;
  1844. return (_b = toValue((_a = options == null ? void 0 : options.initialValue) != null ? _a : toValue(list)[0])) != null ? _b : void 0;
  1845. }
  1846. watch(listRef, () => set(index.value));
  1847. return {
  1848. state,
  1849. index,
  1850. next,
  1851. prev
  1852. };
  1853. }
  1854. var __defProp$i = Object.defineProperty;
  1855. var __defProps$8 = Object.defineProperties;
  1856. var __getOwnPropDescs$8 = Object.getOwnPropertyDescriptors;
  1857. var __getOwnPropSymbols$k = Object.getOwnPropertySymbols;
  1858. var __hasOwnProp$k = Object.prototype.hasOwnProperty;
  1859. var __propIsEnum$k = Object.prototype.propertyIsEnumerable;
  1860. var __defNormalProp$i = (obj, key, value) => key in obj ? __defProp$i(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  1861. var __spreadValues$i = (a, b) => {
  1862. for (var prop in b || (b = {}))
  1863. if (__hasOwnProp$k.call(b, prop))
  1864. __defNormalProp$i(a, prop, b[prop]);
  1865. if (__getOwnPropSymbols$k)
  1866. for (var prop of __getOwnPropSymbols$k(b)) {
  1867. if (__propIsEnum$k.call(b, prop))
  1868. __defNormalProp$i(a, prop, b[prop]);
  1869. }
  1870. return a;
  1871. };
  1872. var __spreadProps$8 = (a, b) => __defProps$8(a, __getOwnPropDescs$8(b));
  1873. function useDark(options = {}) {
  1874. const {
  1875. valueDark = "dark",
  1876. valueLight = ""
  1877. } = options;
  1878. const mode = useColorMode(__spreadProps$8(__spreadValues$i({}, options), {
  1879. onChanged: (mode2, defaultHandler) => {
  1880. var _a;
  1881. if (options.onChanged)
  1882. (_a = options.onChanged) == null ? void 0 : _a.call(options, mode2 === "dark", defaultHandler, mode2);
  1883. else
  1884. defaultHandler(mode2);
  1885. },
  1886. modes: {
  1887. dark: valueDark,
  1888. light: valueLight
  1889. }
  1890. }));
  1891. const isDark = computed({
  1892. get() {
  1893. return mode.value === "dark";
  1894. },
  1895. set(v) {
  1896. const modeVal = v ? "dark" : "light";
  1897. if (mode.system.value === modeVal)
  1898. mode.value = "auto";
  1899. else
  1900. mode.value = modeVal;
  1901. }
  1902. });
  1903. return isDark;
  1904. }
  1905. function fnBypass(v) {
  1906. return v;
  1907. }
  1908. function fnSetSource(source, value) {
  1909. return source.value = value;
  1910. }
  1911. function defaultDump(clone) {
  1912. return clone ? typeof clone === "function" ? clone : cloneFnJSON : fnBypass;
  1913. }
  1914. function defaultParse(clone) {
  1915. return clone ? typeof clone === "function" ? clone : cloneFnJSON : fnBypass;
  1916. }
  1917. function useManualRefHistory(source, options = {}) {
  1918. const {
  1919. clone = false,
  1920. dump = defaultDump(clone),
  1921. parse = defaultParse(clone),
  1922. setSource = fnSetSource
  1923. } = options;
  1924. function _createHistoryRecord() {
  1925. return markRaw({
  1926. snapshot: dump(source.value),
  1927. timestamp: timestamp()
  1928. });
  1929. }
  1930. const last = ref(_createHistoryRecord());
  1931. const undoStack = ref([]);
  1932. const redoStack = ref([]);
  1933. const _setSource = (record) => {
  1934. setSource(source, parse(record.snapshot));
  1935. last.value = record;
  1936. };
  1937. const commit = () => {
  1938. undoStack.value.unshift(last.value);
  1939. last.value = _createHistoryRecord();
  1940. if (options.capacity && undoStack.value.length > options.capacity)
  1941. undoStack.value.splice(options.capacity, Infinity);
  1942. if (redoStack.value.length)
  1943. redoStack.value.splice(0, redoStack.value.length);
  1944. };
  1945. const clear = () => {
  1946. undoStack.value.splice(0, undoStack.value.length);
  1947. redoStack.value.splice(0, redoStack.value.length);
  1948. };
  1949. const undo = () => {
  1950. const state = undoStack.value.shift();
  1951. if (state) {
  1952. redoStack.value.unshift(last.value);
  1953. _setSource(state);
  1954. }
  1955. };
  1956. const redo = () => {
  1957. const state = redoStack.value.shift();
  1958. if (state) {
  1959. undoStack.value.unshift(last.value);
  1960. _setSource(state);
  1961. }
  1962. };
  1963. const reset = () => {
  1964. _setSource(last.value);
  1965. };
  1966. const history = computed(() => [last.value, ...undoStack.value]);
  1967. const canUndo = computed(() => undoStack.value.length > 0);
  1968. const canRedo = computed(() => redoStack.value.length > 0);
  1969. return {
  1970. source,
  1971. undoStack,
  1972. redoStack,
  1973. last,
  1974. history,
  1975. canUndo,
  1976. canRedo,
  1977. clear,
  1978. commit,
  1979. reset,
  1980. undo,
  1981. redo
  1982. };
  1983. }
  1984. var __defProp$h = Object.defineProperty;
  1985. var __defProps$7 = Object.defineProperties;
  1986. var __getOwnPropDescs$7 = Object.getOwnPropertyDescriptors;
  1987. var __getOwnPropSymbols$j = Object.getOwnPropertySymbols;
  1988. var __hasOwnProp$j = Object.prototype.hasOwnProperty;
  1989. var __propIsEnum$j = Object.prototype.propertyIsEnumerable;
  1990. var __defNormalProp$h = (obj, key, value) => key in obj ? __defProp$h(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  1991. var __spreadValues$h = (a, b) => {
  1992. for (var prop in b || (b = {}))
  1993. if (__hasOwnProp$j.call(b, prop))
  1994. __defNormalProp$h(a, prop, b[prop]);
  1995. if (__getOwnPropSymbols$j)
  1996. for (var prop of __getOwnPropSymbols$j(b)) {
  1997. if (__propIsEnum$j.call(b, prop))
  1998. __defNormalProp$h(a, prop, b[prop]);
  1999. }
  2000. return a;
  2001. };
  2002. var __spreadProps$7 = (a, b) => __defProps$7(a, __getOwnPropDescs$7(b));
  2003. function useRefHistory(source, options = {}) {
  2004. const {
  2005. deep = false,
  2006. flush = "pre",
  2007. eventFilter
  2008. } = options;
  2009. const {
  2010. eventFilter: composedFilter,
  2011. pause,
  2012. resume: resumeTracking,
  2013. isActive: isTracking
  2014. } = pausableFilter(eventFilter);
  2015. const {
  2016. ignoreUpdates,
  2017. ignorePrevAsyncUpdates,
  2018. stop
  2019. } = watchIgnorable(
  2020. source,
  2021. commit,
  2022. { deep, flush, eventFilter: composedFilter }
  2023. );
  2024. function setSource(source2, value) {
  2025. ignorePrevAsyncUpdates();
  2026. ignoreUpdates(() => {
  2027. source2.value = value;
  2028. });
  2029. }
  2030. const manualHistory = useManualRefHistory(source, __spreadProps$7(__spreadValues$h({}, options), { clone: options.clone || deep, setSource }));
  2031. const { clear, commit: manualCommit } = manualHistory;
  2032. function commit() {
  2033. ignorePrevAsyncUpdates();
  2034. manualCommit();
  2035. }
  2036. function resume(commitNow) {
  2037. resumeTracking();
  2038. if (commitNow)
  2039. commit();
  2040. }
  2041. function batch(fn) {
  2042. let canceled = false;
  2043. const cancel = () => canceled = true;
  2044. ignoreUpdates(() => {
  2045. fn(cancel);
  2046. });
  2047. if (!canceled)
  2048. commit();
  2049. }
  2050. function dispose() {
  2051. stop();
  2052. clear();
  2053. }
  2054. return __spreadProps$7(__spreadValues$h({}, manualHistory), {
  2055. isTracking,
  2056. pause,
  2057. resume,
  2058. commit,
  2059. batch,
  2060. dispose
  2061. });
  2062. }
  2063. var __defProp$g = Object.defineProperty;
  2064. var __defProps$6 = Object.defineProperties;
  2065. var __getOwnPropDescs$6 = Object.getOwnPropertyDescriptors;
  2066. var __getOwnPropSymbols$i = Object.getOwnPropertySymbols;
  2067. var __hasOwnProp$i = Object.prototype.hasOwnProperty;
  2068. var __propIsEnum$i = Object.prototype.propertyIsEnumerable;
  2069. var __defNormalProp$g = (obj, key, value) => key in obj ? __defProp$g(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  2070. var __spreadValues$g = (a, b) => {
  2071. for (var prop in b || (b = {}))
  2072. if (__hasOwnProp$i.call(b, prop))
  2073. __defNormalProp$g(a, prop, b[prop]);
  2074. if (__getOwnPropSymbols$i)
  2075. for (var prop of __getOwnPropSymbols$i(b)) {
  2076. if (__propIsEnum$i.call(b, prop))
  2077. __defNormalProp$g(a, prop, b[prop]);
  2078. }
  2079. return a;
  2080. };
  2081. var __spreadProps$6 = (a, b) => __defProps$6(a, __getOwnPropDescs$6(b));
  2082. function useDebouncedRefHistory(source, options = {}) {
  2083. const filter = options.debounce ? debounceFilter(options.debounce) : void 0;
  2084. const history = useRefHistory(source, __spreadProps$6(__spreadValues$g({}, options), { eventFilter: filter }));
  2085. return __spreadValues$g({}, history);
  2086. }
  2087. function useDeviceMotion(options = {}) {
  2088. const {
  2089. window = defaultWindow,
  2090. eventFilter = bypassFilter
  2091. } = options;
  2092. const acceleration = ref({ x: null, y: null, z: null });
  2093. const rotationRate = ref({ alpha: null, beta: null, gamma: null });
  2094. const interval = ref(0);
  2095. const accelerationIncludingGravity = ref({
  2096. x: null,
  2097. y: null,
  2098. z: null
  2099. });
  2100. if (window) {
  2101. const onDeviceMotion = createFilterWrapper(
  2102. eventFilter,
  2103. (event) => {
  2104. acceleration.value = event.acceleration;
  2105. accelerationIncludingGravity.value = event.accelerationIncludingGravity;
  2106. rotationRate.value = event.rotationRate;
  2107. interval.value = event.interval;
  2108. }
  2109. );
  2110. useEventListener(window, "devicemotion", onDeviceMotion);
  2111. }
  2112. return {
  2113. acceleration,
  2114. accelerationIncludingGravity,
  2115. rotationRate,
  2116. interval
  2117. };
  2118. }
  2119. function useDeviceOrientation(options = {}) {
  2120. const { window = defaultWindow } = options;
  2121. const isSupported = useSupported(() => window && "DeviceOrientationEvent" in window);
  2122. const isAbsolute = ref(false);
  2123. const alpha = ref(null);
  2124. const beta = ref(null);
  2125. const gamma = ref(null);
  2126. if (window && isSupported.value) {
  2127. useEventListener(window, "deviceorientation", (event) => {
  2128. isAbsolute.value = event.absolute;
  2129. alpha.value = event.alpha;
  2130. beta.value = event.beta;
  2131. gamma.value = event.gamma;
  2132. });
  2133. }
  2134. return {
  2135. isSupported,
  2136. isAbsolute,
  2137. alpha,
  2138. beta,
  2139. gamma
  2140. };
  2141. }
  2142. function useDevicePixelRatio({
  2143. window = defaultWindow
  2144. } = {}) {
  2145. const pixelRatio = ref(1);
  2146. if (window) {
  2147. let observe = function() {
  2148. pixelRatio.value = window.devicePixelRatio;
  2149. cleanup();
  2150. media = window.matchMedia(`(resolution: ${pixelRatio.value}dppx)`);
  2151. media.addEventListener("change", observe, { once: true });
  2152. }, cleanup = function() {
  2153. media == null ? void 0 : media.removeEventListener("change", observe);
  2154. };
  2155. let media;
  2156. observe();
  2157. tryOnScopeDispose(cleanup);
  2158. }
  2159. return { pixelRatio };
  2160. }
  2161. function usePermission(permissionDesc, options = {}) {
  2162. const {
  2163. controls = false,
  2164. navigator = defaultNavigator
  2165. } = options;
  2166. const isSupported = useSupported(() => navigator && "permissions" in navigator);
  2167. let permissionStatus;
  2168. const desc = typeof permissionDesc === "string" ? { name: permissionDesc } : permissionDesc;
  2169. const state = ref();
  2170. const onChange = () => {
  2171. if (permissionStatus)
  2172. state.value = permissionStatus.state;
  2173. };
  2174. const query = createSingletonPromise(async () => {
  2175. if (!isSupported.value)
  2176. return;
  2177. if (!permissionStatus) {
  2178. try {
  2179. permissionStatus = await navigator.permissions.query(desc);
  2180. useEventListener(permissionStatus, "change", onChange);
  2181. onChange();
  2182. } catch (e) {
  2183. state.value = "prompt";
  2184. }
  2185. }
  2186. return permissionStatus;
  2187. });
  2188. query();
  2189. if (controls) {
  2190. return {
  2191. state,
  2192. isSupported,
  2193. query
  2194. };
  2195. } else {
  2196. return state;
  2197. }
  2198. }
  2199. function useDevicesList(options = {}) {
  2200. const {
  2201. navigator = defaultNavigator,
  2202. requestPermissions = false,
  2203. constraints = { audio: true, video: true },
  2204. onUpdated
  2205. } = options;
  2206. const devices = ref([]);
  2207. const videoInputs = computed(() => devices.value.filter((i) => i.kind === "videoinput"));
  2208. const audioInputs = computed(() => devices.value.filter((i) => i.kind === "audioinput"));
  2209. const audioOutputs = computed(() => devices.value.filter((i) => i.kind === "audiooutput"));
  2210. const isSupported = useSupported(() => navigator && navigator.mediaDevices && navigator.mediaDevices.enumerateDevices);
  2211. const permissionGranted = ref(false);
  2212. let stream;
  2213. async function update() {
  2214. if (!isSupported.value)
  2215. return;
  2216. devices.value = await navigator.mediaDevices.enumerateDevices();
  2217. onUpdated == null ? void 0 : onUpdated(devices.value);
  2218. if (stream) {
  2219. stream.getTracks().forEach((t) => t.stop());
  2220. stream = null;
  2221. }
  2222. }
  2223. async function ensurePermissions() {
  2224. if (!isSupported.value)
  2225. return false;
  2226. if (permissionGranted.value)
  2227. return true;
  2228. const { state, query } = usePermission("camera", { controls: true });
  2229. await query();
  2230. if (state.value !== "granted") {
  2231. stream = await navigator.mediaDevices.getUserMedia(constraints);
  2232. update();
  2233. permissionGranted.value = true;
  2234. } else {
  2235. permissionGranted.value = true;
  2236. }
  2237. return permissionGranted.value;
  2238. }
  2239. if (isSupported.value) {
  2240. if (requestPermissions)
  2241. ensurePermissions();
  2242. useEventListener(navigator.mediaDevices, "devicechange", update);
  2243. update();
  2244. }
  2245. return {
  2246. devices,
  2247. ensurePermissions,
  2248. permissionGranted,
  2249. videoInputs,
  2250. audioInputs,
  2251. audioOutputs,
  2252. isSupported
  2253. };
  2254. }
  2255. function useDisplayMedia(options = {}) {
  2256. var _a;
  2257. const enabled = ref((_a = options.enabled) != null ? _a : false);
  2258. const video = options.video;
  2259. const audio = options.audio;
  2260. const { navigator = defaultNavigator } = options;
  2261. const isSupported = useSupported(() => {
  2262. var _a2;
  2263. return (_a2 = navigator == null ? void 0 : navigator.mediaDevices) == null ? void 0 : _a2.getDisplayMedia;
  2264. });
  2265. const constraint = { audio, video };
  2266. const stream = shallowRef();
  2267. async function _start() {
  2268. if (!isSupported.value || stream.value)
  2269. return;
  2270. stream.value = await navigator.mediaDevices.getDisplayMedia(constraint);
  2271. return stream.value;
  2272. }
  2273. async function _stop() {
  2274. var _a2;
  2275. (_a2 = stream.value) == null ? void 0 : _a2.getTracks().forEach((t) => t.stop());
  2276. stream.value = void 0;
  2277. }
  2278. function stop() {
  2279. _stop();
  2280. enabled.value = false;
  2281. }
  2282. async function start() {
  2283. await _start();
  2284. if (stream.value)
  2285. enabled.value = true;
  2286. return stream.value;
  2287. }
  2288. watch(
  2289. enabled,
  2290. (v) => {
  2291. if (v)
  2292. _start();
  2293. else
  2294. _stop();
  2295. },
  2296. { immediate: true }
  2297. );
  2298. return {
  2299. isSupported,
  2300. stream,
  2301. start,
  2302. stop,
  2303. enabled
  2304. };
  2305. }
  2306. function useDocumentVisibility({ document = defaultDocument } = {}) {
  2307. if (!document)
  2308. return ref("visible");
  2309. const visibility = ref(document.visibilityState);
  2310. useEventListener(document, "visibilitychange", () => {
  2311. visibility.value = document.visibilityState;
  2312. });
  2313. return visibility;
  2314. }
  2315. var __defProp$f = Object.defineProperty;
  2316. var __defProps$5 = Object.defineProperties;
  2317. var __getOwnPropDescs$5 = Object.getOwnPropertyDescriptors;
  2318. var __getOwnPropSymbols$h = Object.getOwnPropertySymbols;
  2319. var __hasOwnProp$h = Object.prototype.hasOwnProperty;
  2320. var __propIsEnum$h = Object.prototype.propertyIsEnumerable;
  2321. var __defNormalProp$f = (obj, key, value) => key in obj ? __defProp$f(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  2322. var __spreadValues$f = (a, b) => {
  2323. for (var prop in b || (b = {}))
  2324. if (__hasOwnProp$h.call(b, prop))
  2325. __defNormalProp$f(a, prop, b[prop]);
  2326. if (__getOwnPropSymbols$h)
  2327. for (var prop of __getOwnPropSymbols$h(b)) {
  2328. if (__propIsEnum$h.call(b, prop))
  2329. __defNormalProp$f(a, prop, b[prop]);
  2330. }
  2331. return a;
  2332. };
  2333. var __spreadProps$5 = (a, b) => __defProps$5(a, __getOwnPropDescs$5(b));
  2334. function useDraggable(target, options = {}) {
  2335. var _a, _b;
  2336. const {
  2337. pointerTypes,
  2338. preventDefault,
  2339. stopPropagation,
  2340. exact,
  2341. onMove,
  2342. onEnd,
  2343. onStart,
  2344. initialValue,
  2345. axis = "both",
  2346. draggingElement = defaultWindow,
  2347. handle: draggingHandle = target
  2348. } = options;
  2349. const position = ref(
  2350. (_a = toValue(initialValue)) != null ? _a : { x: 0, y: 0 }
  2351. );
  2352. const pressedDelta = ref();
  2353. const filterEvent = (e) => {
  2354. if (pointerTypes)
  2355. return pointerTypes.includes(e.pointerType);
  2356. return true;
  2357. };
  2358. const handleEvent = (e) => {
  2359. if (toValue(preventDefault))
  2360. e.preventDefault();
  2361. if (toValue(stopPropagation))
  2362. e.stopPropagation();
  2363. };
  2364. const start = (e) => {
  2365. if (!filterEvent(e))
  2366. return;
  2367. if (toValue(exact) && e.target !== toValue(target))
  2368. return;
  2369. const rect = toValue(target).getBoundingClientRect();
  2370. const pos = {
  2371. x: e.clientX - rect.left,
  2372. y: e.clientY - rect.top
  2373. };
  2374. if ((onStart == null ? void 0 : onStart(pos, e)) === false)
  2375. return;
  2376. pressedDelta.value = pos;
  2377. handleEvent(e);
  2378. };
  2379. const move = (e) => {
  2380. if (!filterEvent(e))
  2381. return;
  2382. if (!pressedDelta.value)
  2383. return;
  2384. let { x, y } = position.value;
  2385. if (axis === "x" || axis === "both")
  2386. x = e.clientX - pressedDelta.value.x;
  2387. if (axis === "y" || axis === "both")
  2388. y = e.clientY - pressedDelta.value.y;
  2389. position.value = {
  2390. x,
  2391. y
  2392. };
  2393. onMove == null ? void 0 : onMove(position.value, e);
  2394. handleEvent(e);
  2395. };
  2396. const end = (e) => {
  2397. if (!filterEvent(e))
  2398. return;
  2399. if (!pressedDelta.value)
  2400. return;
  2401. pressedDelta.value = void 0;
  2402. onEnd == null ? void 0 : onEnd(position.value, e);
  2403. handleEvent(e);
  2404. };
  2405. if (isClient) {
  2406. const config = { capture: (_b = options.capture) != null ? _b : true };
  2407. useEventListener(draggingHandle, "pointerdown", start, config);
  2408. useEventListener(draggingElement, "pointermove", move, config);
  2409. useEventListener(draggingElement, "pointerup", end, config);
  2410. }
  2411. return __spreadProps$5(__spreadValues$f({}, toRefs(position)), {
  2412. position,
  2413. isDragging: computed(() => !!pressedDelta.value),
  2414. style: computed(
  2415. () => `left:${position.value.x}px;top:${position.value.y}px;`
  2416. )
  2417. });
  2418. }
  2419. function useDropZone(target, onDrop) {
  2420. const isOverDropZone = ref(false);
  2421. let counter = 0;
  2422. if (isClient) {
  2423. useEventListener(target, "dragenter", (event) => {
  2424. event.preventDefault();
  2425. counter += 1;
  2426. isOverDropZone.value = true;
  2427. });
  2428. useEventListener(target, "dragover", (event) => {
  2429. event.preventDefault();
  2430. });
  2431. useEventListener(target, "dragleave", (event) => {
  2432. event.preventDefault();
  2433. counter -= 1;
  2434. if (counter === 0)
  2435. isOverDropZone.value = false;
  2436. });
  2437. useEventListener(target, "drop", (event) => {
  2438. var _a, _b;
  2439. event.preventDefault();
  2440. counter = 0;
  2441. isOverDropZone.value = false;
  2442. const files = Array.from((_b = (_a = event.dataTransfer) == null ? void 0 : _a.files) != null ? _b : []);
  2443. onDrop == null ? void 0 : onDrop(files.length === 0 ? null : files);
  2444. });
  2445. }
  2446. return {
  2447. isOverDropZone
  2448. };
  2449. }
  2450. var __getOwnPropSymbols$g = Object.getOwnPropertySymbols;
  2451. var __hasOwnProp$g = Object.prototype.hasOwnProperty;
  2452. var __propIsEnum$g = Object.prototype.propertyIsEnumerable;
  2453. var __objRest$2 = (source, exclude) => {
  2454. var target = {};
  2455. for (var prop in source)
  2456. if (__hasOwnProp$g.call(source, prop) && exclude.indexOf(prop) < 0)
  2457. target[prop] = source[prop];
  2458. if (source != null && __getOwnPropSymbols$g)
  2459. for (var prop of __getOwnPropSymbols$g(source)) {
  2460. if (exclude.indexOf(prop) < 0 && __propIsEnum$g.call(source, prop))
  2461. target[prop] = source[prop];
  2462. }
  2463. return target;
  2464. };
  2465. function useResizeObserver(target, callback, options = {}) {
  2466. const _a = options, { window = defaultWindow } = _a, observerOptions = __objRest$2(_a, ["window"]);
  2467. let observer;
  2468. const isSupported = useSupported(() => window && "ResizeObserver" in window);
  2469. const cleanup = () => {
  2470. if (observer) {
  2471. observer.disconnect();
  2472. observer = void 0;
  2473. }
  2474. };
  2475. const targets = computed(
  2476. () => Array.isArray(target) ? target.map((el) => unrefElement(el)) : [unrefElement(target)]
  2477. );
  2478. const stopWatch = watch(
  2479. targets,
  2480. (els) => {
  2481. cleanup();
  2482. if (isSupported.value && window) {
  2483. observer = new ResizeObserver(callback);
  2484. for (const _el of els)
  2485. _el && observer.observe(_el, observerOptions);
  2486. }
  2487. },
  2488. { immediate: true, flush: "post", deep: true }
  2489. );
  2490. const stop = () => {
  2491. cleanup();
  2492. stopWatch();
  2493. };
  2494. tryOnScopeDispose(stop);
  2495. return {
  2496. isSupported,
  2497. stop
  2498. };
  2499. }
  2500. function useElementBounding(target, options = {}) {
  2501. const {
  2502. reset = true,
  2503. windowResize = true,
  2504. windowScroll = true,
  2505. immediate = true
  2506. } = options;
  2507. const height = ref(0);
  2508. const bottom = ref(0);
  2509. const left = ref(0);
  2510. const right = ref(0);
  2511. const top = ref(0);
  2512. const width = ref(0);
  2513. const x = ref(0);
  2514. const y = ref(0);
  2515. function update() {
  2516. const el = unrefElement(target);
  2517. if (!el) {
  2518. if (reset) {
  2519. height.value = 0;
  2520. bottom.value = 0;
  2521. left.value = 0;
  2522. right.value = 0;
  2523. top.value = 0;
  2524. width.value = 0;
  2525. x.value = 0;
  2526. y.value = 0;
  2527. }
  2528. return;
  2529. }
  2530. const rect = el.getBoundingClientRect();
  2531. height.value = rect.height;
  2532. bottom.value = rect.bottom;
  2533. left.value = rect.left;
  2534. right.value = rect.right;
  2535. top.value = rect.top;
  2536. width.value = rect.width;
  2537. x.value = rect.x;
  2538. y.value = rect.y;
  2539. }
  2540. useResizeObserver(target, update);
  2541. watch(() => unrefElement(target), (ele) => !ele && update());
  2542. if (windowScroll)
  2543. useEventListener("scroll", update, { capture: true, passive: true });
  2544. if (windowResize)
  2545. useEventListener("resize", update, { passive: true });
  2546. tryOnMounted(() => {
  2547. if (immediate)
  2548. update();
  2549. });
  2550. return {
  2551. height,
  2552. bottom,
  2553. left,
  2554. right,
  2555. top,
  2556. width,
  2557. x,
  2558. y,
  2559. update
  2560. };
  2561. }
  2562. var __defProp$e = Object.defineProperty;
  2563. var __getOwnPropSymbols$f = Object.getOwnPropertySymbols;
  2564. var __hasOwnProp$f = Object.prototype.hasOwnProperty;
  2565. var __propIsEnum$f = Object.prototype.propertyIsEnumerable;
  2566. var __defNormalProp$e = (obj, key, value) => key in obj ? __defProp$e(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  2567. var __spreadValues$e = (a, b) => {
  2568. for (var prop in b || (b = {}))
  2569. if (__hasOwnProp$f.call(b, prop))
  2570. __defNormalProp$e(a, prop, b[prop]);
  2571. if (__getOwnPropSymbols$f)
  2572. for (var prop of __getOwnPropSymbols$f(b)) {
  2573. if (__propIsEnum$f.call(b, prop))
  2574. __defNormalProp$e(a, prop, b[prop]);
  2575. }
  2576. return a;
  2577. };
  2578. function useElementByPoint(options) {
  2579. const element = ref(null);
  2580. const { x, y, document = defaultDocument } = options;
  2581. const controls = useRafFn(() => {
  2582. element.value = (document == null ? void 0 : document.elementFromPoint(toValue(x), toValue(y))) || null;
  2583. });
  2584. return __spreadValues$e({
  2585. element
  2586. }, controls);
  2587. }
  2588. function useElementHover(el, options = {}) {
  2589. const {
  2590. delayEnter = 0,
  2591. delayLeave = 0,
  2592. window = defaultWindow
  2593. } = options;
  2594. const isHovered = ref(false);
  2595. let timer;
  2596. const toggle = (entering) => {
  2597. const delay = entering ? delayEnter : delayLeave;
  2598. if (timer) {
  2599. clearTimeout(timer);
  2600. timer = void 0;
  2601. }
  2602. if (delay)
  2603. timer = setTimeout(() => isHovered.value = entering, delay);
  2604. else
  2605. isHovered.value = entering;
  2606. };
  2607. if (!window)
  2608. return isHovered;
  2609. useEventListener(el, "mouseenter", () => toggle(true), { passive: true });
  2610. useEventListener(el, "mouseleave", () => toggle(false), { passive: true });
  2611. return isHovered;
  2612. }
  2613. function useElementSize(target, initialSize = { width: 0, height: 0 }, options = {}) {
  2614. const { window = defaultWindow, box = "content-box" } = options;
  2615. const isSVG = computed(() => {
  2616. var _a, _b;
  2617. return (_b = (_a = unrefElement(target)) == null ? void 0 : _a.namespaceURI) == null ? void 0 : _b.includes("svg");
  2618. });
  2619. const width = ref(initialSize.width);
  2620. const height = ref(initialSize.height);
  2621. useResizeObserver(
  2622. target,
  2623. ([entry]) => {
  2624. const boxSize = box === "border-box" ? entry.borderBoxSize : box === "content-box" ? entry.contentBoxSize : entry.devicePixelContentBoxSize;
  2625. if (window && isSVG.value) {
  2626. const $elem = unrefElement(target);
  2627. if ($elem) {
  2628. const styles = window.getComputedStyle($elem);
  2629. width.value = parseFloat(styles.width);
  2630. height.value = parseFloat(styles.height);
  2631. }
  2632. } else {
  2633. if (boxSize) {
  2634. const formatBoxSize = Array.isArray(boxSize) ? boxSize : [boxSize];
  2635. width.value = formatBoxSize.reduce((acc, { inlineSize }) => acc + inlineSize, 0);
  2636. height.value = formatBoxSize.reduce((acc, { blockSize }) => acc + blockSize, 0);
  2637. } else {
  2638. width.value = entry.contentRect.width;
  2639. height.value = entry.contentRect.height;
  2640. }
  2641. }
  2642. },
  2643. options
  2644. );
  2645. watch(
  2646. () => unrefElement(target),
  2647. (ele) => {
  2648. width.value = ele ? initialSize.width : 0;
  2649. height.value = ele ? initialSize.height : 0;
  2650. }
  2651. );
  2652. return {
  2653. width,
  2654. height
  2655. };
  2656. }
  2657. function useIntersectionObserver(target, callback, options = {}) {
  2658. const {
  2659. root,
  2660. rootMargin = "0px",
  2661. threshold = 0.1,
  2662. window = defaultWindow,
  2663. immediate = true
  2664. } = options;
  2665. const isSupported = useSupported(() => window && "IntersectionObserver" in window);
  2666. const targets = computed(() => {
  2667. const _target = toValue(target);
  2668. return (Array.isArray(_target) ? _target : [_target]).map(unrefElement).filter(notNullish);
  2669. });
  2670. let cleanup = noop;
  2671. const isActive = ref(immediate);
  2672. const stopWatch = isSupported.value ? watch(
  2673. () => [targets.value, unrefElement(root), isActive.value],
  2674. ([targets2, root2]) => {
  2675. cleanup();
  2676. if (!isActive.value)
  2677. return;
  2678. if (!targets2.length)
  2679. return;
  2680. const observer = new IntersectionObserver(
  2681. callback,
  2682. {
  2683. root: unrefElement(root2),
  2684. rootMargin,
  2685. threshold
  2686. }
  2687. );
  2688. targets2.forEach((el) => el && observer.observe(el));
  2689. cleanup = () => {
  2690. observer.disconnect();
  2691. cleanup = noop;
  2692. };
  2693. },
  2694. { immediate, flush: "post" }
  2695. ) : noop;
  2696. const stop = () => {
  2697. cleanup();
  2698. stopWatch();
  2699. isActive.value = false;
  2700. };
  2701. tryOnScopeDispose(stop);
  2702. return {
  2703. isSupported,
  2704. isActive,
  2705. pause() {
  2706. cleanup();
  2707. isActive.value = false;
  2708. },
  2709. resume() {
  2710. isActive.value = true;
  2711. },
  2712. stop
  2713. };
  2714. }
  2715. function useElementVisibility(element, { window = defaultWindow, scrollTarget } = {}) {
  2716. const elementIsVisible = ref(false);
  2717. useIntersectionObserver(
  2718. element,
  2719. ([{ isIntersecting }]) => {
  2720. elementIsVisible.value = isIntersecting;
  2721. },
  2722. {
  2723. root: scrollTarget,
  2724. window
  2725. }
  2726. );
  2727. return elementIsVisible;
  2728. }
  2729. const events = /* @__PURE__ */ new Map();
  2730. function useEventBus(key) {
  2731. const scope = getCurrentScope();
  2732. function on(listener) {
  2733. var _a;
  2734. const listeners = events.get(key) || /* @__PURE__ */ new Set();
  2735. listeners.add(listener);
  2736. events.set(key, listeners);
  2737. const _off = () => off(listener);
  2738. (_a = scope == null ? void 0 : scope.cleanups) == null ? void 0 : _a.push(_off);
  2739. return _off;
  2740. }
  2741. function once(listener) {
  2742. function _listener(...args) {
  2743. off(_listener);
  2744. listener(...args);
  2745. }
  2746. return on(_listener);
  2747. }
  2748. function off(listener) {
  2749. const listeners = events.get(key);
  2750. if (!listeners)
  2751. return;
  2752. listeners.delete(listener);
  2753. if (!listeners.size)
  2754. reset();
  2755. }
  2756. function reset() {
  2757. events.delete(key);
  2758. }
  2759. function emit(event, payload) {
  2760. var _a;
  2761. (_a = events.get(key)) == null ? void 0 : _a.forEach((v) => v(event, payload));
  2762. }
  2763. return { on, once, off, emit, reset };
  2764. }
  2765. function useEventSource(url, events = [], options = {}) {
  2766. const event = ref(null);
  2767. const data = ref(null);
  2768. const status = ref("CONNECTING");
  2769. const eventSource = ref(null);
  2770. const error = shallowRef(null);
  2771. const {
  2772. withCredentials = false
  2773. } = options;
  2774. const close = () => {
  2775. if (eventSource.value) {
  2776. eventSource.value.close();
  2777. eventSource.value = null;
  2778. status.value = "CLOSED";
  2779. }
  2780. };
  2781. const es = new EventSource(url, { withCredentials });
  2782. eventSource.value = es;
  2783. es.onopen = () => {
  2784. status.value = "OPEN";
  2785. error.value = null;
  2786. };
  2787. es.onerror = (e) => {
  2788. status.value = "CLOSED";
  2789. error.value = e;
  2790. };
  2791. es.onmessage = (e) => {
  2792. event.value = null;
  2793. data.value = e.data;
  2794. };
  2795. for (const event_name of events) {
  2796. useEventListener(es, event_name, (e) => {
  2797. event.value = event_name;
  2798. data.value = e.data || null;
  2799. });
  2800. }
  2801. tryOnScopeDispose(() => {
  2802. close();
  2803. });
  2804. return {
  2805. eventSource,
  2806. event,
  2807. data,
  2808. status,
  2809. error,
  2810. close
  2811. };
  2812. }
  2813. function useEyeDropper(options = {}) {
  2814. const { initialValue = "" } = options;
  2815. const isSupported = useSupported(() => typeof window !== "undefined" && "EyeDropper" in window);
  2816. const sRGBHex = ref(initialValue);
  2817. async function open(openOptions) {
  2818. if (!isSupported.value)
  2819. return;
  2820. const eyeDropper = new window.EyeDropper();
  2821. const result = await eyeDropper.open(openOptions);
  2822. sRGBHex.value = result.sRGBHex;
  2823. return result;
  2824. }
  2825. return { isSupported, sRGBHex, open };
  2826. }
  2827. function useFavicon(newIcon = null, options = {}) {
  2828. const {
  2829. baseUrl = "",
  2830. rel = "icon",
  2831. document = defaultDocument
  2832. } = options;
  2833. const favicon = toRef(newIcon);
  2834. const applyIcon = (icon) => {
  2835. document == null ? void 0 : document.head.querySelectorAll(`link[rel*="${rel}"]`).forEach((el) => el.href = `${baseUrl}${icon}`);
  2836. };
  2837. watch(
  2838. favicon,
  2839. (i, o) => {
  2840. if (typeof i === "string" && i !== o)
  2841. applyIcon(i);
  2842. },
  2843. { immediate: true }
  2844. );
  2845. return favicon;
  2846. }
  2847. var __defProp$d = Object.defineProperty;
  2848. var __defProps$4 = Object.defineProperties;
  2849. var __getOwnPropDescs$4 = Object.getOwnPropertyDescriptors;
  2850. var __getOwnPropSymbols$e = Object.getOwnPropertySymbols;
  2851. var __hasOwnProp$e = Object.prototype.hasOwnProperty;
  2852. var __propIsEnum$e = Object.prototype.propertyIsEnumerable;
  2853. var __defNormalProp$d = (obj, key, value) => key in obj ? __defProp$d(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  2854. var __spreadValues$d = (a, b) => {
  2855. for (var prop in b || (b = {}))
  2856. if (__hasOwnProp$e.call(b, prop))
  2857. __defNormalProp$d(a, prop, b[prop]);
  2858. if (__getOwnPropSymbols$e)
  2859. for (var prop of __getOwnPropSymbols$e(b)) {
  2860. if (__propIsEnum$e.call(b, prop))
  2861. __defNormalProp$d(a, prop, b[prop]);
  2862. }
  2863. return a;
  2864. };
  2865. var __spreadProps$4 = (a, b) => __defProps$4(a, __getOwnPropDescs$4(b));
  2866. const payloadMapping = {
  2867. json: "application/json",
  2868. text: "text/plain"
  2869. };
  2870. function isFetchOptions(obj) {
  2871. return obj && containsProp(obj, "immediate", "refetch", "initialData", "timeout", "beforeFetch", "afterFetch", "onFetchError", "fetch");
  2872. }
  2873. function isAbsoluteURL(url) {
  2874. return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
  2875. }
  2876. function headersToObject(headers) {
  2877. if (typeof Headers !== "undefined" && headers instanceof Headers)
  2878. return Object.fromEntries([...headers.entries()]);
  2879. return headers;
  2880. }
  2881. function combineCallbacks(combination, ...callbacks) {
  2882. if (combination === "overwrite") {
  2883. return async (ctx) => {
  2884. const callback = callbacks[callbacks.length - 1];
  2885. if (callback)
  2886. return __spreadValues$d(__spreadValues$d({}, ctx), await callback(ctx));
  2887. return ctx;
  2888. };
  2889. } else {
  2890. return async (ctx) => {
  2891. for (const callback of callbacks) {
  2892. if (callback)
  2893. ctx = __spreadValues$d(__spreadValues$d({}, ctx), await callback(ctx));
  2894. }
  2895. return ctx;
  2896. };
  2897. }
  2898. }
  2899. function createFetch(config = {}) {
  2900. const _combination = config.combination || "chain";
  2901. const _options = config.options || {};
  2902. const _fetchOptions = config.fetchOptions || {};
  2903. function useFactoryFetch(url, ...args) {
  2904. const computedUrl = computed(() => {
  2905. const baseUrl = toValue(config.baseUrl);
  2906. const targetUrl = toValue(url);
  2907. return baseUrl && !isAbsoluteURL(targetUrl) ? joinPaths(baseUrl, targetUrl) : targetUrl;
  2908. });
  2909. let options = _options;
  2910. let fetchOptions = _fetchOptions;
  2911. if (args.length > 0) {
  2912. if (isFetchOptions(args[0])) {
  2913. options = __spreadProps$4(__spreadValues$d(__spreadValues$d({}, options), args[0]), {
  2914. beforeFetch: combineCallbacks(_combination, _options.beforeFetch, args[0].beforeFetch),
  2915. afterFetch: combineCallbacks(_combination, _options.afterFetch, args[0].afterFetch),
  2916. onFetchError: combineCallbacks(_combination, _options.onFetchError, args[0].onFetchError)
  2917. });
  2918. } else {
  2919. fetchOptions = __spreadProps$4(__spreadValues$d(__spreadValues$d({}, fetchOptions), args[0]), {
  2920. headers: __spreadValues$d(__spreadValues$d({}, headersToObject(fetchOptions.headers) || {}), headersToObject(args[0].headers) || {})
  2921. });
  2922. }
  2923. }
  2924. if (args.length > 1 && isFetchOptions(args[1])) {
  2925. options = __spreadProps$4(__spreadValues$d(__spreadValues$d({}, options), args[1]), {
  2926. beforeFetch: combineCallbacks(_combination, _options.beforeFetch, args[1].beforeFetch),
  2927. afterFetch: combineCallbacks(_combination, _options.afterFetch, args[1].afterFetch),
  2928. onFetchError: combineCallbacks(_combination, _options.onFetchError, args[1].onFetchError)
  2929. });
  2930. }
  2931. return useFetch(computedUrl, fetchOptions, options);
  2932. }
  2933. return useFactoryFetch;
  2934. }
  2935. function useFetch(url, ...args) {
  2936. var _a;
  2937. const supportsAbort = typeof AbortController === "function";
  2938. let fetchOptions = {};
  2939. let options = { immediate: true, refetch: false, timeout: 0 };
  2940. const config = {
  2941. method: "GET",
  2942. type: "text",
  2943. payload: void 0
  2944. };
  2945. if (args.length > 0) {
  2946. if (isFetchOptions(args[0]))
  2947. options = __spreadValues$d(__spreadValues$d({}, options), args[0]);
  2948. else
  2949. fetchOptions = args[0];
  2950. }
  2951. if (args.length > 1) {
  2952. if (isFetchOptions(args[1]))
  2953. options = __spreadValues$d(__spreadValues$d({}, options), args[1]);
  2954. }
  2955. const {
  2956. fetch = (_a = defaultWindow) == null ? void 0 : _a.fetch,
  2957. initialData,
  2958. timeout
  2959. } = options;
  2960. const responseEvent = createEventHook();
  2961. const errorEvent = createEventHook();
  2962. const finallyEvent = createEventHook();
  2963. const isFinished = ref(false);
  2964. const isFetching = ref(false);
  2965. const aborted = ref(false);
  2966. const statusCode = ref(null);
  2967. const response = shallowRef(null);
  2968. const error = shallowRef(null);
  2969. const data = shallowRef(initialData || null);
  2970. const canAbort = computed(() => supportsAbort && isFetching.value);
  2971. let controller;
  2972. let timer;
  2973. const abort = () => {
  2974. if (supportsAbort) {
  2975. controller == null ? void 0 : controller.abort();
  2976. controller = new AbortController();
  2977. controller.signal.onabort = () => aborted.value = true;
  2978. fetchOptions = __spreadProps$4(__spreadValues$d({}, fetchOptions), {
  2979. signal: controller.signal
  2980. });
  2981. }
  2982. };
  2983. const loading = (isLoading) => {
  2984. isFetching.value = isLoading;
  2985. isFinished.value = !isLoading;
  2986. };
  2987. if (timeout)
  2988. timer = useTimeoutFn(abort, timeout, { immediate: false });
  2989. const execute = async (throwOnFailed = false) => {
  2990. var _a2;
  2991. abort();
  2992. loading(true);
  2993. error.value = null;
  2994. statusCode.value = null;
  2995. aborted.value = false;
  2996. const defaultFetchOptions = {
  2997. method: config.method,
  2998. headers: {}
  2999. };
  3000. if (config.payload) {
  3001. const headers = headersToObject(defaultFetchOptions.headers);
  3002. if (config.payloadType)
  3003. headers["Content-Type"] = (_a2 = payloadMapping[config.payloadType]) != null ? _a2 : config.payloadType;
  3004. const payload = toValue(config.payload);
  3005. defaultFetchOptions.body = config.payloadType === "json" ? JSON.stringify(payload) : payload;
  3006. }
  3007. let isCanceled = false;
  3008. const context = {
  3009. url: toValue(url),
  3010. options: __spreadValues$d(__spreadValues$d({}, defaultFetchOptions), fetchOptions),
  3011. cancel: () => {
  3012. isCanceled = true;
  3013. }
  3014. };
  3015. if (options.beforeFetch)
  3016. Object.assign(context, await options.beforeFetch(context));
  3017. if (isCanceled || !fetch) {
  3018. loading(false);
  3019. return Promise.resolve(null);
  3020. }
  3021. let responseData = null;
  3022. if (timer)
  3023. timer.start();
  3024. return new Promise((resolve, reject) => {
  3025. var _a3;
  3026. fetch(
  3027. context.url,
  3028. __spreadProps$4(__spreadValues$d(__spreadValues$d({}, defaultFetchOptions), context.options), {
  3029. headers: __spreadValues$d(__spreadValues$d({}, headersToObject(defaultFetchOptions.headers)), headersToObject((_a3 = context.options) == null ? void 0 : _a3.headers))
  3030. })
  3031. ).then(async (fetchResponse) => {
  3032. response.value = fetchResponse;
  3033. statusCode.value = fetchResponse.status;
  3034. responseData = await fetchResponse[config.type]();
  3035. if (!fetchResponse.ok) {
  3036. data.value = initialData || null;
  3037. throw new Error(fetchResponse.statusText);
  3038. }
  3039. if (options.afterFetch)
  3040. ({ data: responseData } = await options.afterFetch({ data: responseData, response: fetchResponse }));
  3041. data.value = responseData;
  3042. responseEvent.trigger(fetchResponse);
  3043. return resolve(fetchResponse);
  3044. }).catch(async (fetchError) => {
  3045. let errorData = fetchError.message || fetchError.name;
  3046. if (options.onFetchError)
  3047. ({ error: errorData } = await options.onFetchError({ data: responseData, error: fetchError, response: response.value }));
  3048. error.value = errorData;
  3049. errorEvent.trigger(fetchError);
  3050. if (throwOnFailed)
  3051. return reject(fetchError);
  3052. return resolve(null);
  3053. }).finally(() => {
  3054. loading(false);
  3055. if (timer)
  3056. timer.stop();
  3057. finallyEvent.trigger(null);
  3058. });
  3059. });
  3060. };
  3061. const refetch = toRef(options.refetch);
  3062. watch(
  3063. [
  3064. refetch,
  3065. toRef(url)
  3066. ],
  3067. ([refetch2]) => refetch2 && execute(),
  3068. { deep: true }
  3069. );
  3070. const shell = {
  3071. isFinished,
  3072. statusCode,
  3073. response,
  3074. error,
  3075. data,
  3076. isFetching,
  3077. canAbort,
  3078. aborted,
  3079. abort,
  3080. execute,
  3081. onFetchResponse: responseEvent.on,
  3082. onFetchError: errorEvent.on,
  3083. onFetchFinally: finallyEvent.on,
  3084. // method
  3085. get: setMethod("GET"),
  3086. put: setMethod("PUT"),
  3087. post: setMethod("POST"),
  3088. delete: setMethod("DELETE"),
  3089. patch: setMethod("PATCH"),
  3090. head: setMethod("HEAD"),
  3091. options: setMethod("OPTIONS"),
  3092. // type
  3093. json: setType("json"),
  3094. text: setType("text"),
  3095. blob: setType("blob"),
  3096. arrayBuffer: setType("arrayBuffer"),
  3097. formData: setType("formData")
  3098. };
  3099. function setMethod(method) {
  3100. return (payload, payloadType) => {
  3101. if (!isFetching.value) {
  3102. config.method = method;
  3103. config.payload = payload;
  3104. config.payloadType = payloadType;
  3105. if (isRef(config.payload)) {
  3106. watch(
  3107. [
  3108. refetch,
  3109. toRef(config.payload)
  3110. ],
  3111. ([refetch2]) => refetch2 && execute(),
  3112. { deep: true }
  3113. );
  3114. }
  3115. const rawPayload = toValue(config.payload);
  3116. if (!payloadType && rawPayload && Object.getPrototypeOf(rawPayload) === Object.prototype && !(rawPayload instanceof FormData))
  3117. config.payloadType = "json";
  3118. return __spreadProps$4(__spreadValues$d({}, shell), {
  3119. then(onFulfilled, onRejected) {
  3120. return waitUntilFinished().then(onFulfilled, onRejected);
  3121. }
  3122. });
  3123. }
  3124. return void 0;
  3125. };
  3126. }
  3127. function waitUntilFinished() {
  3128. return new Promise((resolve, reject) => {
  3129. until(isFinished).toBe(true).then(() => resolve(shell)).catch((error2) => reject(error2));
  3130. });
  3131. }
  3132. function setType(type) {
  3133. return () => {
  3134. if (!isFetching.value) {
  3135. config.type = type;
  3136. return __spreadProps$4(__spreadValues$d({}, shell), {
  3137. then(onFulfilled, onRejected) {
  3138. return waitUntilFinished().then(onFulfilled, onRejected);
  3139. }
  3140. });
  3141. }
  3142. return void 0;
  3143. };
  3144. }
  3145. if (options.immediate)
  3146. Promise.resolve().then(() => execute());
  3147. return __spreadProps$4(__spreadValues$d({}, shell), {
  3148. then(onFulfilled, onRejected) {
  3149. return waitUntilFinished().then(onFulfilled, onRejected);
  3150. }
  3151. });
  3152. }
  3153. function joinPaths(start, end) {
  3154. if (!start.endsWith("/") && !end.startsWith("/"))
  3155. return `${start}/${end}`;
  3156. return `${start}${end}`;
  3157. }
  3158. var __defProp$c = Object.defineProperty;
  3159. var __getOwnPropSymbols$d = Object.getOwnPropertySymbols;
  3160. var __hasOwnProp$d = Object.prototype.hasOwnProperty;
  3161. var __propIsEnum$d = Object.prototype.propertyIsEnumerable;
  3162. var __defNormalProp$c = (obj, key, value) => key in obj ? __defProp$c(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  3163. var __spreadValues$c = (a, b) => {
  3164. for (var prop in b || (b = {}))
  3165. if (__hasOwnProp$d.call(b, prop))
  3166. __defNormalProp$c(a, prop, b[prop]);
  3167. if (__getOwnPropSymbols$d)
  3168. for (var prop of __getOwnPropSymbols$d(b)) {
  3169. if (__propIsEnum$d.call(b, prop))
  3170. __defNormalProp$c(a, prop, b[prop]);
  3171. }
  3172. return a;
  3173. };
  3174. const DEFAULT_OPTIONS = {
  3175. multiple: true,
  3176. accept: "*"
  3177. };
  3178. function useFileDialog(options = {}) {
  3179. const {
  3180. document = defaultDocument
  3181. } = options;
  3182. const files = ref(null);
  3183. const { on: onChange, trigger } = createEventHook();
  3184. let input;
  3185. if (document) {
  3186. input = document.createElement("input");
  3187. input.type = "file";
  3188. input.onchange = (event) => {
  3189. const result = event.target;
  3190. files.value = result.files;
  3191. trigger(files.value);
  3192. };
  3193. }
  3194. const open = (localOptions) => {
  3195. if (!input)
  3196. return;
  3197. const _options = __spreadValues$c(__spreadValues$c(__spreadValues$c({}, DEFAULT_OPTIONS), options), localOptions);
  3198. input.multiple = _options.multiple;
  3199. input.accept = _options.accept;
  3200. if (hasOwn(_options, "capture"))
  3201. input.capture = _options.capture;
  3202. input.click();
  3203. };
  3204. const reset = () => {
  3205. files.value = null;
  3206. if (input)
  3207. input.value = "";
  3208. };
  3209. return {
  3210. files: readonly(files),
  3211. open,
  3212. reset,
  3213. onChange
  3214. };
  3215. }
  3216. var __defProp$b = Object.defineProperty;
  3217. var __getOwnPropSymbols$c = Object.getOwnPropertySymbols;
  3218. var __hasOwnProp$c = Object.prototype.hasOwnProperty;
  3219. var __propIsEnum$c = Object.prototype.propertyIsEnumerable;
  3220. var __defNormalProp$b = (obj, key, value) => key in obj ? __defProp$b(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  3221. var __spreadValues$b = (a, b) => {
  3222. for (var prop in b || (b = {}))
  3223. if (__hasOwnProp$c.call(b, prop))
  3224. __defNormalProp$b(a, prop, b[prop]);
  3225. if (__getOwnPropSymbols$c)
  3226. for (var prop of __getOwnPropSymbols$c(b)) {
  3227. if (__propIsEnum$c.call(b, prop))
  3228. __defNormalProp$b(a, prop, b[prop]);
  3229. }
  3230. return a;
  3231. };
  3232. function useFileSystemAccess(options = {}) {
  3233. const {
  3234. window: _window = defaultWindow,
  3235. dataType = "Text"
  3236. } = options;
  3237. const window = _window;
  3238. const isSupported = useSupported(() => window && "showSaveFilePicker" in window && "showOpenFilePicker" in window);
  3239. const fileHandle = ref();
  3240. const data = ref();
  3241. const file = ref();
  3242. const fileName = computed(() => {
  3243. var _a, _b;
  3244. return (_b = (_a = file.value) == null ? void 0 : _a.name) != null ? _b : "";
  3245. });
  3246. const fileMIME = computed(() => {
  3247. var _a, _b;
  3248. return (_b = (_a = file.value) == null ? void 0 : _a.type) != null ? _b : "";
  3249. });
  3250. const fileSize = computed(() => {
  3251. var _a, _b;
  3252. return (_b = (_a = file.value) == null ? void 0 : _a.size) != null ? _b : 0;
  3253. });
  3254. const fileLastModified = computed(() => {
  3255. var _a, _b;
  3256. return (_b = (_a = file.value) == null ? void 0 : _a.lastModified) != null ? _b : 0;
  3257. });
  3258. async function open(_options = {}) {
  3259. if (!isSupported.value)
  3260. return;
  3261. const [handle] = await window.showOpenFilePicker(__spreadValues$b(__spreadValues$b({}, toValue(options)), _options));
  3262. fileHandle.value = handle;
  3263. await updateFile();
  3264. await updateData();
  3265. }
  3266. async function create(_options = {}) {
  3267. if (!isSupported.value)
  3268. return;
  3269. fileHandle.value = await window.showSaveFilePicker(__spreadValues$b(__spreadValues$b({}, options), _options));
  3270. data.value = void 0;
  3271. await updateFile();
  3272. await updateData();
  3273. }
  3274. async function save(_options = {}) {
  3275. if (!isSupported.value)
  3276. return;
  3277. if (!fileHandle.value)
  3278. return saveAs(_options);
  3279. if (data.value) {
  3280. const writableStream = await fileHandle.value.createWritable();
  3281. await writableStream.write(data.value);
  3282. await writableStream.close();
  3283. }
  3284. await updateFile();
  3285. }
  3286. async function saveAs(_options = {}) {
  3287. if (!isSupported.value)
  3288. return;
  3289. fileHandle.value = await window.showSaveFilePicker(__spreadValues$b(__spreadValues$b({}, options), _options));
  3290. if (data.value) {
  3291. const writableStream = await fileHandle.value.createWritable();
  3292. await writableStream.write(data.value);
  3293. await writableStream.close();
  3294. }
  3295. await updateFile();
  3296. }
  3297. async function updateFile() {
  3298. var _a;
  3299. file.value = await ((_a = fileHandle.value) == null ? void 0 : _a.getFile());
  3300. }
  3301. async function updateData() {
  3302. var _a, _b;
  3303. const type = toValue(dataType);
  3304. if (type === "Text")
  3305. data.value = await ((_a = file.value) == null ? void 0 : _a.text());
  3306. else if (type === "ArrayBuffer")
  3307. data.value = await ((_b = file.value) == null ? void 0 : _b.arrayBuffer());
  3308. else if (type === "Blob")
  3309. data.value = file.value;
  3310. }
  3311. watch(() => toValue(dataType), updateData);
  3312. return {
  3313. isSupported,
  3314. data,
  3315. file,
  3316. fileName,
  3317. fileMIME,
  3318. fileSize,
  3319. fileLastModified,
  3320. open,
  3321. create,
  3322. save,
  3323. saveAs,
  3324. updateData
  3325. };
  3326. }
  3327. function useFocus(target, options = {}) {
  3328. const { initialValue = false } = options;
  3329. const innerFocused = ref(false);
  3330. const targetElement = computed(() => unrefElement(target));
  3331. useEventListener(targetElement, "focus", () => innerFocused.value = true);
  3332. useEventListener(targetElement, "blur", () => innerFocused.value = false);
  3333. const focused = computed({
  3334. get: () => innerFocused.value,
  3335. set(value) {
  3336. var _a, _b;
  3337. if (!value && innerFocused.value)
  3338. (_a = targetElement.value) == null ? void 0 : _a.blur();
  3339. else if (value && !innerFocused.value)
  3340. (_b = targetElement.value) == null ? void 0 : _b.focus();
  3341. }
  3342. });
  3343. watch(
  3344. targetElement,
  3345. () => {
  3346. focused.value = initialValue;
  3347. },
  3348. { immediate: true, flush: "post" }
  3349. );
  3350. return { focused };
  3351. }
  3352. function useFocusWithin(target, options = {}) {
  3353. const activeElement = useActiveElement(options);
  3354. const targetElement = computed(() => unrefElement(target));
  3355. const focused = computed(() => targetElement.value && activeElement.value ? targetElement.value.contains(activeElement.value) : false);
  3356. return { focused };
  3357. }
  3358. function useFps(options) {
  3359. var _a;
  3360. const fps = ref(0);
  3361. if (typeof performance === "undefined")
  3362. return fps;
  3363. const every = (_a = options == null ? void 0 : options.every) != null ? _a : 10;
  3364. let last = performance.now();
  3365. let ticks = 0;
  3366. useRafFn(() => {
  3367. ticks += 1;
  3368. if (ticks >= every) {
  3369. const now = performance.now();
  3370. const diff = now - last;
  3371. fps.value = Math.round(1e3 / (diff / ticks));
  3372. last = now;
  3373. ticks = 0;
  3374. }
  3375. });
  3376. return fps;
  3377. }
  3378. const eventHandlers = [
  3379. "fullscreenchange",
  3380. "webkitfullscreenchange",
  3381. "webkitendfullscreen",
  3382. "mozfullscreenchange",
  3383. "MSFullscreenChange"
  3384. ];
  3385. function useFullscreen(target, options = {}) {
  3386. const {
  3387. document = defaultDocument,
  3388. autoExit = false
  3389. } = options;
  3390. const targetRef = computed(() => {
  3391. var _a;
  3392. return (_a = unrefElement(target)) != null ? _a : document == null ? void 0 : document.querySelector("html");
  3393. });
  3394. const isFullscreen = ref(false);
  3395. const requestMethod = computed(() => {
  3396. return [
  3397. "requestFullscreen",
  3398. "webkitRequestFullscreen",
  3399. "webkitEnterFullscreen",
  3400. "webkitEnterFullScreen",
  3401. "webkitRequestFullScreen",
  3402. "mozRequestFullScreen",
  3403. "msRequestFullscreen"
  3404. ].find((m) => document && m in document || targetRef.value && m in targetRef.value);
  3405. });
  3406. const exitMethod = computed(() => {
  3407. return [
  3408. "exitFullscreen",
  3409. "webkitExitFullscreen",
  3410. "webkitExitFullScreen",
  3411. "webkitCancelFullScreen",
  3412. "mozCancelFullScreen",
  3413. "msExitFullscreen"
  3414. ].find((m) => document && m in document || targetRef.value && m in targetRef.value);
  3415. });
  3416. const fullscreenEnabled = computed(() => {
  3417. return [
  3418. "fullScreen",
  3419. "webkitIsFullScreen",
  3420. "webkitDisplayingFullscreen",
  3421. "mozFullScreen",
  3422. "msFullscreenElement"
  3423. ].find((m) => document && m in document || targetRef.value && m in targetRef.value);
  3424. });
  3425. const fullscreenElementMethod = [
  3426. "fullscreenElement",
  3427. "webkitFullscreenElement",
  3428. "mozFullScreenElement",
  3429. "msFullscreenElement"
  3430. ].find((m) => document && m in document);
  3431. const isSupported = useSupported(
  3432. () => targetRef.value && document && requestMethod.value !== void 0 && exitMethod.value !== void 0 && fullscreenEnabled.value !== void 0
  3433. );
  3434. const isCurrentElementFullScreen = () => {
  3435. if (fullscreenElementMethod)
  3436. return (document == null ? void 0 : document[fullscreenElementMethod]) === targetRef.value;
  3437. return false;
  3438. };
  3439. const isElementFullScreen = () => {
  3440. if (fullscreenEnabled.value) {
  3441. if (document && document[fullscreenEnabled.value] != null) {
  3442. return document[fullscreenEnabled.value];
  3443. } else {
  3444. const target2 = targetRef.value;
  3445. if ((target2 == null ? void 0 : target2[fullscreenEnabled.value]) != null) {
  3446. return Boolean(target2[fullscreenEnabled.value]);
  3447. }
  3448. }
  3449. }
  3450. return false;
  3451. };
  3452. async function exit() {
  3453. if (!isSupported.value)
  3454. return;
  3455. if (exitMethod.value) {
  3456. if ((document == null ? void 0 : document[exitMethod.value]) != null) {
  3457. await document[exitMethod.value]();
  3458. } else {
  3459. const target2 = targetRef.value;
  3460. if ((target2 == null ? void 0 : target2[exitMethod.value]) != null)
  3461. await target2[exitMethod.value]();
  3462. }
  3463. }
  3464. isFullscreen.value = false;
  3465. }
  3466. async function enter() {
  3467. if (!isSupported.value)
  3468. return;
  3469. if (isElementFullScreen())
  3470. await exit();
  3471. const target2 = targetRef.value;
  3472. if (requestMethod.value && (target2 == null ? void 0 : target2[requestMethod.value]) != null) {
  3473. await target2[requestMethod.value]();
  3474. isFullscreen.value = true;
  3475. }
  3476. }
  3477. async function toggle() {
  3478. await (isFullscreen.value ? exit() : enter());
  3479. }
  3480. const handlerCallback = () => {
  3481. const isElementFullScreenValue = isElementFullScreen();
  3482. if (!isElementFullScreenValue || isElementFullScreenValue && isCurrentElementFullScreen())
  3483. isFullscreen.value = isElementFullScreenValue;
  3484. };
  3485. useEventListener(document, eventHandlers, handlerCallback, false);
  3486. useEventListener(() => unrefElement(targetRef), eventHandlers, handlerCallback, false);
  3487. if (autoExit)
  3488. tryOnScopeDispose(exit);
  3489. return {
  3490. isSupported,
  3491. isFullscreen,
  3492. enter,
  3493. exit,
  3494. toggle
  3495. };
  3496. }
  3497. function mapGamepadToXbox360Controller(gamepad) {
  3498. return computed(() => {
  3499. if (gamepad.value) {
  3500. return {
  3501. buttons: {
  3502. a: gamepad.value.buttons[0],
  3503. b: gamepad.value.buttons[1],
  3504. x: gamepad.value.buttons[2],
  3505. y: gamepad.value.buttons[3]
  3506. },
  3507. bumper: {
  3508. left: gamepad.value.buttons[4],
  3509. right: gamepad.value.buttons[5]
  3510. },
  3511. triggers: {
  3512. left: gamepad.value.buttons[6],
  3513. right: gamepad.value.buttons[7]
  3514. },
  3515. stick: {
  3516. left: {
  3517. horizontal: gamepad.value.axes[0],
  3518. vertical: gamepad.value.axes[1],
  3519. button: gamepad.value.buttons[10]
  3520. },
  3521. right: {
  3522. horizontal: gamepad.value.axes[2],
  3523. vertical: gamepad.value.axes[3],
  3524. button: gamepad.value.buttons[11]
  3525. }
  3526. },
  3527. dpad: {
  3528. up: gamepad.value.buttons[12],
  3529. down: gamepad.value.buttons[13],
  3530. left: gamepad.value.buttons[14],
  3531. right: gamepad.value.buttons[15]
  3532. },
  3533. back: gamepad.value.buttons[8],
  3534. start: gamepad.value.buttons[9]
  3535. };
  3536. }
  3537. return null;
  3538. });
  3539. }
  3540. function useGamepad(options = {}) {
  3541. const {
  3542. navigator = defaultNavigator
  3543. } = options;
  3544. const isSupported = useSupported(() => navigator && "getGamepads" in navigator);
  3545. const gamepads = ref([]);
  3546. const onConnectedHook = createEventHook();
  3547. const onDisconnectedHook = createEventHook();
  3548. const stateFromGamepad = (gamepad) => {
  3549. const hapticActuators = [];
  3550. const vibrationActuator = "vibrationActuator" in gamepad ? gamepad.vibrationActuator : null;
  3551. if (vibrationActuator)
  3552. hapticActuators.push(vibrationActuator);
  3553. if (gamepad.hapticActuators)
  3554. hapticActuators.push(...gamepad.hapticActuators);
  3555. return {
  3556. id: gamepad.id,
  3557. hapticActuators,
  3558. index: gamepad.index,
  3559. mapping: gamepad.mapping,
  3560. connected: gamepad.connected,
  3561. timestamp: gamepad.timestamp,
  3562. axes: gamepad.axes.map((axes) => axes),
  3563. buttons: gamepad.buttons.map((button) => ({ pressed: button.pressed, touched: button.touched, value: button.value }))
  3564. };
  3565. };
  3566. const updateGamepadState = () => {
  3567. const _gamepads = (navigator == null ? void 0 : navigator.getGamepads()) || [];
  3568. for (let i = 0; i < _gamepads.length; ++i) {
  3569. const gamepad = _gamepads[i];
  3570. if (gamepad) {
  3571. const index = gamepads.value.findIndex(({ index: index2 }) => index2 === gamepad.index);
  3572. if (index > -1)
  3573. gamepads.value[index] = stateFromGamepad(gamepad);
  3574. }
  3575. }
  3576. };
  3577. const { isActive, pause, resume } = useRafFn(updateGamepadState);
  3578. const onGamepadConnected = (gamepad) => {
  3579. if (!gamepads.value.some(({ index }) => index === gamepad.index)) {
  3580. gamepads.value.push(stateFromGamepad(gamepad));
  3581. onConnectedHook.trigger(gamepad.index);
  3582. }
  3583. resume();
  3584. };
  3585. const onGamepadDisconnected = (gamepad) => {
  3586. gamepads.value = gamepads.value.filter((x) => x.index !== gamepad.index);
  3587. onDisconnectedHook.trigger(gamepad.index);
  3588. };
  3589. useEventListener("gamepadconnected", (e) => onGamepadConnected(e.gamepad));
  3590. useEventListener("gamepaddisconnected", (e) => onGamepadDisconnected(e.gamepad));
  3591. tryOnMounted(() => {
  3592. const _gamepads = (navigator == null ? void 0 : navigator.getGamepads()) || [];
  3593. if (_gamepads) {
  3594. for (let i = 0; i < _gamepads.length; ++i) {
  3595. const gamepad = _gamepads[i];
  3596. if (gamepad)
  3597. onGamepadConnected(gamepad);
  3598. }
  3599. }
  3600. });
  3601. pause();
  3602. return {
  3603. isSupported,
  3604. onConnected: onConnectedHook.on,
  3605. onDisconnected: onDisconnectedHook.on,
  3606. gamepads,
  3607. pause,
  3608. resume,
  3609. isActive
  3610. };
  3611. }
  3612. function useGeolocation(options = {}) {
  3613. const {
  3614. enableHighAccuracy = true,
  3615. maximumAge = 3e4,
  3616. timeout = 27e3,
  3617. navigator = defaultNavigator,
  3618. immediate = true
  3619. } = options;
  3620. const isSupported = useSupported(() => navigator && "geolocation" in navigator);
  3621. const locatedAt = ref(null);
  3622. const error = shallowRef(null);
  3623. const coords = ref({
  3624. accuracy: 0,
  3625. latitude: Infinity,
  3626. longitude: Infinity,
  3627. altitude: null,
  3628. altitudeAccuracy: null,
  3629. heading: null,
  3630. speed: null
  3631. });
  3632. function updatePosition(position) {
  3633. locatedAt.value = position.timestamp;
  3634. coords.value = position.coords;
  3635. error.value = null;
  3636. }
  3637. let watcher;
  3638. function resume() {
  3639. if (isSupported.value) {
  3640. watcher = navigator.geolocation.watchPosition(
  3641. updatePosition,
  3642. (err) => error.value = err,
  3643. {
  3644. enableHighAccuracy,
  3645. maximumAge,
  3646. timeout
  3647. }
  3648. );
  3649. }
  3650. }
  3651. if (immediate)
  3652. resume();
  3653. function pause() {
  3654. if (watcher && navigator)
  3655. navigator.geolocation.clearWatch(watcher);
  3656. }
  3657. tryOnScopeDispose(() => {
  3658. pause();
  3659. });
  3660. return {
  3661. isSupported,
  3662. coords,
  3663. locatedAt,
  3664. error,
  3665. resume,
  3666. pause
  3667. };
  3668. }
  3669. const defaultEvents$1 = ["mousemove", "mousedown", "resize", "keydown", "touchstart", "wheel"];
  3670. const oneMinute = 6e4;
  3671. function useIdle(timeout = oneMinute, options = {}) {
  3672. const {
  3673. initialState = false,
  3674. listenForVisibilityChange = true,
  3675. events = defaultEvents$1,
  3676. window = defaultWindow,
  3677. eventFilter = throttleFilter(50)
  3678. } = options;
  3679. const idle = ref(initialState);
  3680. const lastActive = ref(timestamp());
  3681. let timer;
  3682. const reset = () => {
  3683. idle.value = false;
  3684. clearTimeout(timer);
  3685. timer = setTimeout(() => idle.value = true, timeout);
  3686. };
  3687. const onEvent = createFilterWrapper(
  3688. eventFilter,
  3689. () => {
  3690. lastActive.value = timestamp();
  3691. reset();
  3692. }
  3693. );
  3694. if (window) {
  3695. const document = window.document;
  3696. for (const event of events)
  3697. useEventListener(window, event, onEvent, { passive: true });
  3698. if (listenForVisibilityChange) {
  3699. useEventListener(document, "visibilitychange", () => {
  3700. if (!document.hidden)
  3701. onEvent();
  3702. });
  3703. }
  3704. reset();
  3705. }
  3706. return {
  3707. idle,
  3708. lastActive,
  3709. reset
  3710. };
  3711. }
  3712. var __defProp$a = Object.defineProperty;
  3713. var __getOwnPropSymbols$b = Object.getOwnPropertySymbols;
  3714. var __hasOwnProp$b = Object.prototype.hasOwnProperty;
  3715. var __propIsEnum$b = Object.prototype.propertyIsEnumerable;
  3716. var __defNormalProp$a = (obj, key, value) => key in obj ? __defProp$a(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  3717. var __spreadValues$a = (a, b) => {
  3718. for (var prop in b || (b = {}))
  3719. if (__hasOwnProp$b.call(b, prop))
  3720. __defNormalProp$a(a, prop, b[prop]);
  3721. if (__getOwnPropSymbols$b)
  3722. for (var prop of __getOwnPropSymbols$b(b)) {
  3723. if (__propIsEnum$b.call(b, prop))
  3724. __defNormalProp$a(a, prop, b[prop]);
  3725. }
  3726. return a;
  3727. };
  3728. async function loadImage(options) {
  3729. return new Promise((resolve, reject) => {
  3730. const img = new Image();
  3731. const { src, srcset, sizes, class: clazz, loading, crossorigin } = options;
  3732. img.src = src;
  3733. if (srcset)
  3734. img.srcset = srcset;
  3735. if (sizes)
  3736. img.sizes = sizes;
  3737. if (clazz)
  3738. img.className = clazz;
  3739. if (loading)
  3740. img.loading = loading;
  3741. if (crossorigin)
  3742. img.crossOrigin = crossorigin;
  3743. img.onload = () => resolve(img);
  3744. img.onerror = reject;
  3745. });
  3746. }
  3747. function useImage(options, asyncStateOptions = {}) {
  3748. const state = useAsyncState(
  3749. () => loadImage(toValue(options)),
  3750. void 0,
  3751. __spreadValues$a({
  3752. resetOnExecute: true
  3753. }, asyncStateOptions)
  3754. );
  3755. watch(
  3756. () => toValue(options),
  3757. () => state.execute(asyncStateOptions.delay),
  3758. { deep: true }
  3759. );
  3760. return state;
  3761. }
  3762. const ARRIVED_STATE_THRESHOLD_PIXELS = 1;
  3763. function useScroll(element, options = {}) {
  3764. const {
  3765. throttle = 0,
  3766. idle = 200,
  3767. onStop = noop,
  3768. onScroll = noop,
  3769. offset = {
  3770. left: 0,
  3771. right: 0,
  3772. top: 0,
  3773. bottom: 0
  3774. },
  3775. eventListenerOptions = {
  3776. capture: false,
  3777. passive: true
  3778. },
  3779. behavior = "auto"
  3780. } = options;
  3781. const internalX = ref(0);
  3782. const internalY = ref(0);
  3783. const x = computed({
  3784. get() {
  3785. return internalX.value;
  3786. },
  3787. set(x2) {
  3788. scrollTo(x2, void 0);
  3789. }
  3790. });
  3791. const y = computed({
  3792. get() {
  3793. return internalY.value;
  3794. },
  3795. set(y2) {
  3796. scrollTo(void 0, y2);
  3797. }
  3798. });
  3799. function scrollTo(_x, _y) {
  3800. var _a, _b, _c;
  3801. const _element = toValue(element);
  3802. if (!_element)
  3803. return;
  3804. (_c = _element instanceof Document ? document.body : _element) == null ? void 0 : _c.scrollTo({
  3805. top: (_a = toValue(_y)) != null ? _a : y.value,
  3806. left: (_b = toValue(_x)) != null ? _b : x.value,
  3807. behavior: toValue(behavior)
  3808. });
  3809. }
  3810. const isScrolling = ref(false);
  3811. const arrivedState = reactive({
  3812. left: true,
  3813. right: false,
  3814. top: true,
  3815. bottom: false
  3816. });
  3817. const directions = reactive({
  3818. left: false,
  3819. right: false,
  3820. top: false,
  3821. bottom: false
  3822. });
  3823. const onScrollEnd = (e) => {
  3824. if (!isScrolling.value)
  3825. return;
  3826. isScrolling.value = false;
  3827. directions.left = false;
  3828. directions.right = false;
  3829. directions.top = false;
  3830. directions.bottom = false;
  3831. onStop(e);
  3832. };
  3833. const onScrollEndDebounced = useDebounceFn(onScrollEnd, throttle + idle);
  3834. const setArrivedState = (target) => {
  3835. const el = target === document ? target.documentElement : target;
  3836. const { display, flexDirection } = getComputedStyle(el);
  3837. const scrollLeft = el.scrollLeft;
  3838. directions.left = scrollLeft < internalX.value;
  3839. directions.right = scrollLeft > internalX.value;
  3840. const left = Math.abs(scrollLeft) <= 0 + (offset.left || 0);
  3841. const right = Math.abs(scrollLeft) + el.clientWidth >= el.scrollWidth - (offset.right || 0) - ARRIVED_STATE_THRESHOLD_PIXELS;
  3842. if (display === "flex" && flexDirection === "row-reverse") {
  3843. arrivedState.left = right;
  3844. arrivedState.right = left;
  3845. } else {
  3846. arrivedState.left = left;
  3847. arrivedState.right = right;
  3848. }
  3849. internalX.value = scrollLeft;
  3850. let scrollTop = el.scrollTop;
  3851. if (target === document && !scrollTop)
  3852. scrollTop = document.body.scrollTop;
  3853. directions.top = scrollTop < internalY.value;
  3854. directions.bottom = scrollTop > internalY.value;
  3855. const top = Math.abs(scrollTop) <= 0 + (offset.top || 0);
  3856. const bottom = Math.abs(scrollTop) + el.clientHeight >= el.scrollHeight - (offset.bottom || 0) - ARRIVED_STATE_THRESHOLD_PIXELS;
  3857. if (display === "flex" && flexDirection === "column-reverse") {
  3858. arrivedState.top = bottom;
  3859. arrivedState.bottom = top;
  3860. } else {
  3861. arrivedState.top = top;
  3862. arrivedState.bottom = bottom;
  3863. }
  3864. internalY.value = scrollTop;
  3865. };
  3866. const onScrollHandler = (e) => {
  3867. const eventTarget = e.target === document ? e.target.documentElement : e.target;
  3868. setArrivedState(eventTarget);
  3869. isScrolling.value = true;
  3870. onScrollEndDebounced(e);
  3871. onScroll(e);
  3872. };
  3873. useEventListener(
  3874. element,
  3875. "scroll",
  3876. throttle ? useThrottleFn(onScrollHandler, throttle, true, false) : onScrollHandler,
  3877. eventListenerOptions
  3878. );
  3879. useEventListener(
  3880. element,
  3881. "scrollend",
  3882. onScrollEnd,
  3883. eventListenerOptions
  3884. );
  3885. return {
  3886. x,
  3887. y,
  3888. isScrolling,
  3889. arrivedState,
  3890. directions,
  3891. measure() {
  3892. const _element = toValue(element);
  3893. if (_element)
  3894. setArrivedState(_element);
  3895. }
  3896. };
  3897. }
  3898. var __defProp$9 = Object.defineProperty;
  3899. var __defProps$3 = Object.defineProperties;
  3900. var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
  3901. var __getOwnPropSymbols$a = Object.getOwnPropertySymbols;
  3902. var __hasOwnProp$a = Object.prototype.hasOwnProperty;
  3903. var __propIsEnum$a = Object.prototype.propertyIsEnumerable;
  3904. var __defNormalProp$9 = (obj, key, value) => key in obj ? __defProp$9(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  3905. var __spreadValues$9 = (a, b) => {
  3906. for (var prop in b || (b = {}))
  3907. if (__hasOwnProp$a.call(b, prop))
  3908. __defNormalProp$9(a, prop, b[prop]);
  3909. if (__getOwnPropSymbols$a)
  3910. for (var prop of __getOwnPropSymbols$a(b)) {
  3911. if (__propIsEnum$a.call(b, prop))
  3912. __defNormalProp$9(a, prop, b[prop]);
  3913. }
  3914. return a;
  3915. };
  3916. var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
  3917. function useInfiniteScroll(element, onLoadMore, options = {}) {
  3918. var _a;
  3919. const {
  3920. direction = "bottom",
  3921. interval = 100
  3922. } = options;
  3923. const state = reactive(useScroll(
  3924. element,
  3925. __spreadProps$3(__spreadValues$9({}, options), {
  3926. offset: __spreadValues$9({
  3927. [direction]: (_a = options.distance) != null ? _a : 0
  3928. }, options.offset)
  3929. })
  3930. ));
  3931. const promise = ref();
  3932. const isLoading = computed(() => !!promise.value);
  3933. function checkAndLoad() {
  3934. state.measure();
  3935. const el = toValue(element);
  3936. if (!el)
  3937. return;
  3938. const isNarrower = direction === "bottom" || direction === "top" ? el.scrollHeight <= el.clientHeight : el.scrollWidth <= el.clientWidth;
  3939. if (state.arrivedState[direction] || isNarrower) {
  3940. if (!promise.value) {
  3941. promise.value = Promise.all([
  3942. onLoadMore(state),
  3943. new Promise((resolve) => setTimeout(resolve, interval))
  3944. ]).finally(() => {
  3945. promise.value = null;
  3946. nextTick(() => checkAndLoad());
  3947. });
  3948. }
  3949. }
  3950. }
  3951. watch(
  3952. () => [state.arrivedState[direction], toValue(element)],
  3953. checkAndLoad,
  3954. { immediate: true }
  3955. );
  3956. return {
  3957. isLoading
  3958. };
  3959. }
  3960. const defaultEvents = ["mousedown", "mouseup", "keydown", "keyup"];
  3961. function useKeyModifier(modifier, options = {}) {
  3962. const {
  3963. events = defaultEvents,
  3964. document = defaultDocument,
  3965. initial = null
  3966. } = options;
  3967. const state = ref(initial);
  3968. if (document) {
  3969. events.forEach((listenerEvent) => {
  3970. useEventListener(document, listenerEvent, (evt) => {
  3971. if (typeof evt.getModifierState === "function")
  3972. state.value = evt.getModifierState(modifier);
  3973. });
  3974. });
  3975. }
  3976. return state;
  3977. }
  3978. function useLocalStorage(key, initialValue, options = {}) {
  3979. const { window = defaultWindow } = options;
  3980. return useStorage(key, initialValue, window == null ? void 0 : window.localStorage, options);
  3981. }
  3982. const DefaultMagicKeysAliasMap = {
  3983. ctrl: "control",
  3984. command: "meta",
  3985. cmd: "meta",
  3986. option: "alt",
  3987. up: "arrowup",
  3988. down: "arrowdown",
  3989. left: "arrowleft",
  3990. right: "arrowright"
  3991. };
  3992. function useMagicKeys(options = {}) {
  3993. const {
  3994. reactive: useReactive = false,
  3995. target = defaultWindow,
  3996. aliasMap = DefaultMagicKeysAliasMap,
  3997. passive = true,
  3998. onEventFired = noop
  3999. } = options;
  4000. const current = reactive(/* @__PURE__ */ new Set());
  4001. const obj = {
  4002. toJSON() {
  4003. return {};
  4004. },
  4005. current
  4006. };
  4007. const refs = useReactive ? reactive(obj) : obj;
  4008. const metaDeps = /* @__PURE__ */ new Set();
  4009. const usedKeys = /* @__PURE__ */ new Set();
  4010. function setRefs(key, value) {
  4011. if (key in refs) {
  4012. if (useReactive)
  4013. refs[key] = value;
  4014. else
  4015. refs[key].value = value;
  4016. }
  4017. }
  4018. function reset() {
  4019. current.clear();
  4020. for (const key of usedKeys)
  4021. setRefs(key, false);
  4022. }
  4023. function updateRefs(e, value) {
  4024. var _a, _b;
  4025. const key = (_a = e.key) == null ? void 0 : _a.toLowerCase();
  4026. const code = (_b = e.code) == null ? void 0 : _b.toLowerCase();
  4027. const values = [code, key].filter(Boolean);
  4028. if (key) {
  4029. if (value)
  4030. current.add(key);
  4031. else
  4032. current.delete(key);
  4033. }
  4034. for (const key2 of values) {
  4035. usedKeys.add(key2);
  4036. setRefs(key2, value);
  4037. }
  4038. if (key === "meta" && !value) {
  4039. metaDeps.forEach((key2) => {
  4040. current.delete(key2);
  4041. setRefs(key2, false);
  4042. });
  4043. metaDeps.clear();
  4044. } else if (typeof e.getModifierState === "function" && e.getModifierState("Meta") && value) {
  4045. [...current, ...values].forEach((key2) => metaDeps.add(key2));
  4046. }
  4047. }
  4048. useEventListener(target, "keydown", (e) => {
  4049. updateRefs(e, true);
  4050. return onEventFired(e);
  4051. }, { passive });
  4052. useEventListener(target, "keyup", (e) => {
  4053. updateRefs(e, false);
  4054. return onEventFired(e);
  4055. }, { passive });
  4056. useEventListener("blur", reset, { passive: true });
  4057. useEventListener("focus", reset, { passive: true });
  4058. const proxy = new Proxy(
  4059. refs,
  4060. {
  4061. get(target2, prop, rec) {
  4062. if (typeof prop !== "string")
  4063. return Reflect.get(target2, prop, rec);
  4064. prop = prop.toLowerCase();
  4065. if (prop in aliasMap)
  4066. prop = aliasMap[prop];
  4067. if (!(prop in refs)) {
  4068. if (/[+_-]/.test(prop)) {
  4069. const keys = prop.split(/[+_-]/g).map((i) => i.trim());
  4070. refs[prop] = computed(() => keys.every((key) => toValue(proxy[key])));
  4071. } else {
  4072. refs[prop] = ref(false);
  4073. }
  4074. }
  4075. const r = Reflect.get(target2, prop, rec);
  4076. return useReactive ? toValue(r) : r;
  4077. }
  4078. }
  4079. );
  4080. return proxy;
  4081. }
  4082. var __defProp$8 = Object.defineProperty;
  4083. var __getOwnPropSymbols$9 = Object.getOwnPropertySymbols;
  4084. var __hasOwnProp$9 = Object.prototype.hasOwnProperty;
  4085. var __propIsEnum$9 = Object.prototype.propertyIsEnumerable;
  4086. var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  4087. var __spreadValues$8 = (a, b) => {
  4088. for (var prop in b || (b = {}))
  4089. if (__hasOwnProp$9.call(b, prop))
  4090. __defNormalProp$8(a, prop, b[prop]);
  4091. if (__getOwnPropSymbols$9)
  4092. for (var prop of __getOwnPropSymbols$9(b)) {
  4093. if (__propIsEnum$9.call(b, prop))
  4094. __defNormalProp$8(a, prop, b[prop]);
  4095. }
  4096. return a;
  4097. };
  4098. function usingElRef(source, cb) {
  4099. if (toValue(source))
  4100. cb(toValue(source));
  4101. }
  4102. function timeRangeToArray(timeRanges) {
  4103. let ranges = [];
  4104. for (let i = 0; i < timeRanges.length; ++i)
  4105. ranges = [...ranges, [timeRanges.start(i), timeRanges.end(i)]];
  4106. return ranges;
  4107. }
  4108. function tracksToArray(tracks) {
  4109. return Array.from(tracks).map(({ label, kind, language, mode, activeCues, cues, inBandMetadataTrackDispatchType }, id) => ({ id, label, kind, language, mode, activeCues, cues, inBandMetadataTrackDispatchType }));
  4110. }
  4111. const defaultOptions = {
  4112. src: "",
  4113. tracks: []
  4114. };
  4115. function useMediaControls(target, options = {}) {
  4116. options = __spreadValues$8(__spreadValues$8({}, defaultOptions), options);
  4117. const {
  4118. document = defaultDocument
  4119. } = options;
  4120. const currentTime = ref(0);
  4121. const duration = ref(0);
  4122. const seeking = ref(false);
  4123. const volume = ref(1);
  4124. const waiting = ref(false);
  4125. const ended = ref(false);
  4126. const playing = ref(false);
  4127. const rate = ref(1);
  4128. const stalled = ref(false);
  4129. const buffered = ref([]);
  4130. const tracks = ref([]);
  4131. const selectedTrack = ref(-1);
  4132. const isPictureInPicture = ref(false);
  4133. const muted = ref(false);
  4134. const supportsPictureInPicture = document && "pictureInPictureEnabled" in document;
  4135. const sourceErrorEvent = createEventHook();
  4136. const disableTrack = (track) => {
  4137. usingElRef(target, (el) => {
  4138. if (track) {
  4139. const id = typeof track === "number" ? track : track.id;
  4140. el.textTracks[id].mode = "disabled";
  4141. } else {
  4142. for (let i = 0; i < el.textTracks.length; ++i)
  4143. el.textTracks[i].mode = "disabled";
  4144. }
  4145. selectedTrack.value = -1;
  4146. });
  4147. };
  4148. const enableTrack = (track, disableTracks = true) => {
  4149. usingElRef(target, (el) => {
  4150. const id = typeof track === "number" ? track : track.id;
  4151. if (disableTracks)
  4152. disableTrack();
  4153. el.textTracks[id].mode = "showing";
  4154. selectedTrack.value = id;
  4155. });
  4156. };
  4157. const togglePictureInPicture = () => {
  4158. return new Promise((resolve, reject) => {
  4159. usingElRef(target, async (el) => {
  4160. if (supportsPictureInPicture) {
  4161. if (!isPictureInPicture.value) {
  4162. el.requestPictureInPicture().then(resolve).catch(reject);
  4163. } else {
  4164. document.exitPictureInPicture().then(resolve).catch(reject);
  4165. }
  4166. }
  4167. });
  4168. });
  4169. };
  4170. watchEffect(() => {
  4171. if (!document)
  4172. return;
  4173. const el = toValue(target);
  4174. if (!el)
  4175. return;
  4176. const src = toValue(options.src);
  4177. let sources = [];
  4178. if (!src)
  4179. return;
  4180. if (typeof src === "string")
  4181. sources = [{ src }];
  4182. else if (Array.isArray(src))
  4183. sources = src;
  4184. else if (isObject(src))
  4185. sources = [src];
  4186. el.querySelectorAll("source").forEach((e) => {
  4187. e.removeEventListener("error", sourceErrorEvent.trigger);
  4188. e.remove();
  4189. });
  4190. sources.forEach(({ src: src2, type }) => {
  4191. const source = document.createElement("source");
  4192. source.setAttribute("src", src2);
  4193. source.setAttribute("type", type || "");
  4194. source.addEventListener("error", sourceErrorEvent.trigger);
  4195. el.appendChild(source);
  4196. });
  4197. el.load();
  4198. });
  4199. tryOnScopeDispose(() => {
  4200. const el = toValue(target);
  4201. if (!el)
  4202. return;
  4203. el.querySelectorAll("source").forEach((e) => e.removeEventListener("error", sourceErrorEvent.trigger));
  4204. });
  4205. watch([target, volume], () => {
  4206. const el = toValue(target);
  4207. if (!el)
  4208. return;
  4209. el.volume = volume.value;
  4210. });
  4211. watch([target, muted], () => {
  4212. const el = toValue(target);
  4213. if (!el)
  4214. return;
  4215. el.muted = muted.value;
  4216. });
  4217. watch([target, rate], () => {
  4218. const el = toValue(target);
  4219. if (!el)
  4220. return;
  4221. el.playbackRate = rate.value;
  4222. });
  4223. watchEffect(() => {
  4224. if (!document)
  4225. return;
  4226. const textTracks = toValue(options.tracks);
  4227. const el = toValue(target);
  4228. if (!textTracks || !textTracks.length || !el)
  4229. return;
  4230. el.querySelectorAll("track").forEach((e) => e.remove());
  4231. textTracks.forEach(({ default: isDefault, kind, label, src, srcLang }, i) => {
  4232. const track = document.createElement("track");
  4233. track.default = isDefault || false;
  4234. track.kind = kind;
  4235. track.label = label;
  4236. track.src = src;
  4237. track.srclang = srcLang;
  4238. if (track.default)
  4239. selectedTrack.value = i;
  4240. el.appendChild(track);
  4241. });
  4242. });
  4243. const { ignoreUpdates: ignoreCurrentTimeUpdates } = watchIgnorable(currentTime, (time) => {
  4244. const el = toValue(target);
  4245. if (!el)
  4246. return;
  4247. el.currentTime = time;
  4248. });
  4249. const { ignoreUpdates: ignorePlayingUpdates } = watchIgnorable(playing, (isPlaying) => {
  4250. const el = toValue(target);
  4251. if (!el)
  4252. return;
  4253. isPlaying ? el.play() : el.pause();
  4254. });
  4255. useEventListener(target, "timeupdate", () => ignoreCurrentTimeUpdates(() => currentTime.value = toValue(target).currentTime));
  4256. useEventListener(target, "durationchange", () => duration.value = toValue(target).duration);
  4257. useEventListener(target, "progress", () => buffered.value = timeRangeToArray(toValue(target).buffered));
  4258. useEventListener(target, "seeking", () => seeking.value = true);
  4259. useEventListener(target, "seeked", () => seeking.value = false);
  4260. useEventListener(target, "waiting", () => waiting.value = true);
  4261. useEventListener(target, "playing", () => {
  4262. waiting.value = false;
  4263. ended.value = false;
  4264. });
  4265. useEventListener(target, "ratechange", () => rate.value = toValue(target).playbackRate);
  4266. useEventListener(target, "stalled", () => stalled.value = true);
  4267. useEventListener(target, "ended", () => ended.value = true);
  4268. useEventListener(target, "pause", () => ignorePlayingUpdates(() => playing.value = false));
  4269. useEventListener(target, "play", () => ignorePlayingUpdates(() => playing.value = true));
  4270. useEventListener(target, "enterpictureinpicture", () => isPictureInPicture.value = true);
  4271. useEventListener(target, "leavepictureinpicture", () => isPictureInPicture.value = false);
  4272. useEventListener(target, "volumechange", () => {
  4273. const el = toValue(target);
  4274. if (!el)
  4275. return;
  4276. volume.value = el.volume;
  4277. muted.value = el.muted;
  4278. });
  4279. const listeners = [];
  4280. const stop = watch([target], () => {
  4281. const el = toValue(target);
  4282. if (!el)
  4283. return;
  4284. stop();
  4285. listeners[0] = useEventListener(el.textTracks, "addtrack", () => tracks.value = tracksToArray(el.textTracks));
  4286. listeners[1] = useEventListener(el.textTracks, "removetrack", () => tracks.value = tracksToArray(el.textTracks));
  4287. listeners[2] = useEventListener(el.textTracks, "change", () => tracks.value = tracksToArray(el.textTracks));
  4288. });
  4289. tryOnScopeDispose(() => listeners.forEach((listener) => listener()));
  4290. return {
  4291. currentTime,
  4292. duration,
  4293. waiting,
  4294. seeking,
  4295. ended,
  4296. stalled,
  4297. buffered,
  4298. playing,
  4299. rate,
  4300. // Volume
  4301. volume,
  4302. muted,
  4303. // Tracks
  4304. tracks,
  4305. selectedTrack,
  4306. enableTrack,
  4307. disableTrack,
  4308. // Picture in Picture
  4309. supportsPictureInPicture,
  4310. togglePictureInPicture,
  4311. isPictureInPicture,
  4312. // Events
  4313. onSourceError: sourceErrorEvent.on
  4314. };
  4315. }
  4316. function getMapVue2Compat() {
  4317. const data = reactive({});
  4318. return {
  4319. get: (key) => data[key],
  4320. set: (key, value) => set(data, key, value),
  4321. has: (key) => hasOwn(data, key),
  4322. delete: (key) => del(data, key),
  4323. clear: () => {
  4324. Object.keys(data).forEach((key) => {
  4325. del(data, key);
  4326. });
  4327. }
  4328. };
  4329. }
  4330. function useMemoize(resolver, options) {
  4331. const initCache = () => {
  4332. if (options == null ? void 0 : options.cache)
  4333. return reactive(options.cache);
  4334. if (isVue2)
  4335. return getMapVue2Compat();
  4336. return reactive(/* @__PURE__ */ new Map());
  4337. };
  4338. const cache = initCache();
  4339. const generateKey = (...args) => (options == null ? void 0 : options.getKey) ? options.getKey(...args) : JSON.stringify(args);
  4340. const _loadData = (key, ...args) => {
  4341. cache.set(key, resolver(...args));
  4342. return cache.get(key);
  4343. };
  4344. const loadData = (...args) => _loadData(generateKey(...args), ...args);
  4345. const deleteData = (...args) => {
  4346. cache.delete(generateKey(...args));
  4347. };
  4348. const clearData = () => {
  4349. cache.clear();
  4350. };
  4351. const memoized = (...args) => {
  4352. const key = generateKey(...args);
  4353. if (cache.has(key))
  4354. return cache.get(key);
  4355. return _loadData(key, ...args);
  4356. };
  4357. memoized.load = loadData;
  4358. memoized.delete = deleteData;
  4359. memoized.clear = clearData;
  4360. memoized.generateKey = generateKey;
  4361. memoized.cache = cache;
  4362. return memoized;
  4363. }
  4364. function useMemory(options = {}) {
  4365. const memory = ref();
  4366. const isSupported = useSupported(() => typeof performance !== "undefined" && "memory" in performance);
  4367. if (isSupported.value) {
  4368. const { interval = 1e3 } = options;
  4369. useIntervalFn(() => {
  4370. memory.value = performance.memory;
  4371. }, interval, { immediate: options.immediate, immediateCallback: options.immediateCallback });
  4372. }
  4373. return { isSupported, memory };
  4374. }
  4375. const BuiltinExtractors = {
  4376. page: (event) => [event.pageX, event.pageY],
  4377. client: (event) => [event.clientX, event.clientY],
  4378. screen: (event) => [event.screenX, event.screenY],
  4379. movement: (event) => event instanceof Touch ? null : [event.movementX, event.movementY]
  4380. };
  4381. function useMouse(options = {}) {
  4382. const {
  4383. type = "page",
  4384. touch = true,
  4385. resetOnTouchEnds = false,
  4386. initialValue = { x: 0, y: 0 },
  4387. window = defaultWindow,
  4388. target = window,
  4389. eventFilter
  4390. } = options;
  4391. const x = ref(initialValue.x);
  4392. const y = ref(initialValue.y);
  4393. const sourceType = ref(null);
  4394. const extractor = typeof type === "function" ? type : BuiltinExtractors[type];
  4395. const mouseHandler = (event) => {
  4396. const result = extractor(event);
  4397. if (result) {
  4398. [x.value, y.value] = result;
  4399. sourceType.value = "mouse";
  4400. }
  4401. };
  4402. const touchHandler = (event) => {
  4403. if (event.touches.length > 0) {
  4404. const result = extractor(event.touches[0]);
  4405. if (result) {
  4406. [x.value, y.value] = result;
  4407. sourceType.value = "touch";
  4408. }
  4409. }
  4410. };
  4411. const reset = () => {
  4412. x.value = initialValue.x;
  4413. y.value = initialValue.y;
  4414. };
  4415. const mouseHandlerWrapper = eventFilter ? (event) => eventFilter(() => mouseHandler(event), {}) : (event) => mouseHandler(event);
  4416. const touchHandlerWrapper = eventFilter ? (event) => eventFilter(() => touchHandler(event), {}) : (event) => touchHandler(event);
  4417. if (target) {
  4418. useEventListener(target, "mousemove", mouseHandlerWrapper, { passive: true });
  4419. useEventListener(target, "dragover", mouseHandlerWrapper, { passive: true });
  4420. if (touch && type !== "movement") {
  4421. useEventListener(target, "touchstart", touchHandlerWrapper, { passive: true });
  4422. useEventListener(target, "touchmove", touchHandlerWrapper, { passive: true });
  4423. if (resetOnTouchEnds)
  4424. useEventListener(target, "touchend", reset, { passive: true });
  4425. }
  4426. }
  4427. return {
  4428. x,
  4429. y,
  4430. sourceType
  4431. };
  4432. }
  4433. function useMouseInElement(target, options = {}) {
  4434. const {
  4435. handleOutside = true,
  4436. window = defaultWindow
  4437. } = options;
  4438. const { x, y, sourceType } = useMouse(options);
  4439. const targetRef = ref(target != null ? target : window == null ? void 0 : window.document.body);
  4440. const elementX = ref(0);
  4441. const elementY = ref(0);
  4442. const elementPositionX = ref(0);
  4443. const elementPositionY = ref(0);
  4444. const elementHeight = ref(0);
  4445. const elementWidth = ref(0);
  4446. const isOutside = ref(true);
  4447. let stop = () => {
  4448. };
  4449. if (window) {
  4450. stop = watch(
  4451. [targetRef, x, y],
  4452. () => {
  4453. const el = unrefElement(targetRef);
  4454. if (!el)
  4455. return;
  4456. const {
  4457. left,
  4458. top,
  4459. width,
  4460. height
  4461. } = el.getBoundingClientRect();
  4462. elementPositionX.value = left + window.pageXOffset;
  4463. elementPositionY.value = top + window.pageYOffset;
  4464. elementHeight.value = height;
  4465. elementWidth.value = width;
  4466. const elX = x.value - elementPositionX.value;
  4467. const elY = y.value - elementPositionY.value;
  4468. isOutside.value = width === 0 || height === 0 || elX < 0 || elY < 0 || elX > width || elY > height;
  4469. if (handleOutside || !isOutside.value) {
  4470. elementX.value = elX;
  4471. elementY.value = elY;
  4472. }
  4473. },
  4474. { immediate: true }
  4475. );
  4476. useEventListener(document, "mouseleave", () => {
  4477. isOutside.value = true;
  4478. });
  4479. }
  4480. return {
  4481. x,
  4482. y,
  4483. sourceType,
  4484. elementX,
  4485. elementY,
  4486. elementPositionX,
  4487. elementPositionY,
  4488. elementHeight,
  4489. elementWidth,
  4490. isOutside,
  4491. stop
  4492. };
  4493. }
  4494. function useMousePressed(options = {}) {
  4495. const {
  4496. touch = true,
  4497. drag = true,
  4498. initialValue = false,
  4499. window = defaultWindow
  4500. } = options;
  4501. const pressed = ref(initialValue);
  4502. const sourceType = ref(null);
  4503. if (!window) {
  4504. return {
  4505. pressed,
  4506. sourceType
  4507. };
  4508. }
  4509. const onPressed = (srcType) => () => {
  4510. pressed.value = true;
  4511. sourceType.value = srcType;
  4512. };
  4513. const onReleased = () => {
  4514. pressed.value = false;
  4515. sourceType.value = null;
  4516. };
  4517. const target = computed(() => unrefElement(options.target) || window);
  4518. useEventListener(target, "mousedown", onPressed("mouse"), { passive: true });
  4519. useEventListener(window, "mouseleave", onReleased, { passive: true });
  4520. useEventListener(window, "mouseup", onReleased, { passive: true });
  4521. if (drag) {
  4522. useEventListener(target, "dragstart", onPressed("mouse"), { passive: true });
  4523. useEventListener(window, "drop", onReleased, { passive: true });
  4524. useEventListener(window, "dragend", onReleased, { passive: true });
  4525. }
  4526. if (touch) {
  4527. useEventListener(target, "touchstart", onPressed("touch"), { passive: true });
  4528. useEventListener(window, "touchend", onReleased, { passive: true });
  4529. useEventListener(window, "touchcancel", onReleased, { passive: true });
  4530. }
  4531. return {
  4532. pressed,
  4533. sourceType
  4534. };
  4535. }
  4536. function useNavigatorLanguage(options = {}) {
  4537. const { window = defaultWindow } = options;
  4538. const navigator = window == null ? void 0 : window.navigator;
  4539. const isSupported = useSupported(() => navigator && "language" in navigator);
  4540. const language = ref(navigator == null ? void 0 : navigator.language);
  4541. useEventListener(window, "languagechange", () => {
  4542. if (navigator)
  4543. language.value = navigator.language;
  4544. });
  4545. return {
  4546. isSupported,
  4547. language
  4548. };
  4549. }
  4550. function useNetwork(options = {}) {
  4551. const { window = defaultWindow } = options;
  4552. const navigator = window == null ? void 0 : window.navigator;
  4553. const isSupported = useSupported(() => navigator && "connection" in navigator);
  4554. const isOnline = ref(true);
  4555. const saveData = ref(false);
  4556. const offlineAt = ref(void 0);
  4557. const onlineAt = ref(void 0);
  4558. const downlink = ref(void 0);
  4559. const downlinkMax = ref(void 0);
  4560. const rtt = ref(void 0);
  4561. const effectiveType = ref(void 0);
  4562. const type = ref("unknown");
  4563. const connection = isSupported.value && navigator.connection;
  4564. function updateNetworkInformation() {
  4565. if (!navigator)
  4566. return;
  4567. isOnline.value = navigator.onLine;
  4568. offlineAt.value = isOnline.value ? void 0 : Date.now();
  4569. onlineAt.value = isOnline.value ? Date.now() : void 0;
  4570. if (connection) {
  4571. downlink.value = connection.downlink;
  4572. downlinkMax.value = connection.downlinkMax;
  4573. effectiveType.value = connection.effectiveType;
  4574. rtt.value = connection.rtt;
  4575. saveData.value = connection.saveData;
  4576. type.value = connection.type;
  4577. }
  4578. }
  4579. if (window) {
  4580. useEventListener(window, "offline", () => {
  4581. isOnline.value = false;
  4582. offlineAt.value = Date.now();
  4583. });
  4584. useEventListener(window, "online", () => {
  4585. isOnline.value = true;
  4586. onlineAt.value = Date.now();
  4587. });
  4588. }
  4589. if (connection)
  4590. useEventListener(connection, "change", updateNetworkInformation, false);
  4591. updateNetworkInformation();
  4592. return {
  4593. isSupported,
  4594. isOnline,
  4595. saveData,
  4596. offlineAt,
  4597. onlineAt,
  4598. downlink,
  4599. downlinkMax,
  4600. effectiveType,
  4601. rtt,
  4602. type
  4603. };
  4604. }
  4605. var __defProp$7 = Object.defineProperty;
  4606. var __getOwnPropSymbols$8 = Object.getOwnPropertySymbols;
  4607. var __hasOwnProp$8 = Object.prototype.hasOwnProperty;
  4608. var __propIsEnum$8 = Object.prototype.propertyIsEnumerable;
  4609. var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  4610. var __spreadValues$7 = (a, b) => {
  4611. for (var prop in b || (b = {}))
  4612. if (__hasOwnProp$8.call(b, prop))
  4613. __defNormalProp$7(a, prop, b[prop]);
  4614. if (__getOwnPropSymbols$8)
  4615. for (var prop of __getOwnPropSymbols$8(b)) {
  4616. if (__propIsEnum$8.call(b, prop))
  4617. __defNormalProp$7(a, prop, b[prop]);
  4618. }
  4619. return a;
  4620. };
  4621. function useNow(options = {}) {
  4622. const {
  4623. controls: exposeControls = false,
  4624. interval = "requestAnimationFrame"
  4625. } = options;
  4626. const now = ref(/* @__PURE__ */ new Date());
  4627. const update = () => now.value = /* @__PURE__ */ new Date();
  4628. const controls = interval === "requestAnimationFrame" ? useRafFn(update, { immediate: true }) : useIntervalFn(update, interval, { immediate: true });
  4629. if (exposeControls) {
  4630. return __spreadValues$7({
  4631. now
  4632. }, controls);
  4633. } else {
  4634. return now;
  4635. }
  4636. }
  4637. function useObjectUrl(object) {
  4638. const url = ref();
  4639. const release = () => {
  4640. if (url.value)
  4641. URL.revokeObjectURL(url.value);
  4642. url.value = void 0;
  4643. };
  4644. watch(
  4645. () => toValue(object),
  4646. (newObject) => {
  4647. release();
  4648. if (newObject)
  4649. url.value = URL.createObjectURL(newObject);
  4650. },
  4651. { immediate: true }
  4652. );
  4653. tryOnScopeDispose(release);
  4654. return readonly(url);
  4655. }
  4656. function useClamp(value, min, max) {
  4657. if (typeof value === "function" || isReadonly(value))
  4658. return computed(() => clamp(toValue(value), toValue(min), toValue(max)));
  4659. const _value = ref(value);
  4660. return computed({
  4661. get() {
  4662. return _value.value = clamp(_value.value, toValue(min), toValue(max));
  4663. },
  4664. set(value2) {
  4665. _value.value = clamp(value2, toValue(min), toValue(max));
  4666. }
  4667. });
  4668. }
  4669. function useOffsetPagination(options) {
  4670. const {
  4671. total = Infinity,
  4672. pageSize = 10,
  4673. page = 1,
  4674. onPageChange = noop,
  4675. onPageSizeChange = noop,
  4676. onPageCountChange = noop
  4677. } = options;
  4678. const currentPageSize = useClamp(pageSize, 1, Infinity);
  4679. const pageCount = computed(() => Math.max(
  4680. 1,
  4681. Math.ceil(toValue(total) / toValue(currentPageSize))
  4682. ));
  4683. const currentPage = useClamp(page, 1, pageCount);
  4684. const isFirstPage = computed(() => currentPage.value === 1);
  4685. const isLastPage = computed(() => currentPage.value === pageCount.value);
  4686. if (isRef(page))
  4687. syncRef(page, currentPage);
  4688. if (isRef(pageSize))
  4689. syncRef(pageSize, currentPageSize);
  4690. function prev() {
  4691. currentPage.value--;
  4692. }
  4693. function next() {
  4694. currentPage.value++;
  4695. }
  4696. const returnValue = {
  4697. currentPage,
  4698. currentPageSize,
  4699. pageCount,
  4700. isFirstPage,
  4701. isLastPage,
  4702. prev,
  4703. next
  4704. };
  4705. watch(currentPage, () => {
  4706. onPageChange(reactive(returnValue));
  4707. });
  4708. watch(currentPageSize, () => {
  4709. onPageSizeChange(reactive(returnValue));
  4710. });
  4711. watch(pageCount, () => {
  4712. onPageCountChange(reactive(returnValue));
  4713. });
  4714. return returnValue;
  4715. }
  4716. function useOnline(options = {}) {
  4717. const { isOnline } = useNetwork(options);
  4718. return isOnline;
  4719. }
  4720. function usePageLeave(options = {}) {
  4721. const { window = defaultWindow } = options;
  4722. const isLeft = ref(false);
  4723. const handler = (event) => {
  4724. if (!window)
  4725. return;
  4726. event = event || window.event;
  4727. const from = event.relatedTarget || event.toElement;
  4728. isLeft.value = !from;
  4729. };
  4730. if (window) {
  4731. useEventListener(window, "mouseout", handler, { passive: true });
  4732. useEventListener(window.document, "mouseleave", handler, { passive: true });
  4733. useEventListener(window.document, "mouseenter", handler, { passive: true });
  4734. }
  4735. return isLeft;
  4736. }
  4737. function useParallax(target, options = {}) {
  4738. const {
  4739. deviceOrientationTiltAdjust = (i) => i,
  4740. deviceOrientationRollAdjust = (i) => i,
  4741. mouseTiltAdjust = (i) => i,
  4742. mouseRollAdjust = (i) => i,
  4743. window = defaultWindow
  4744. } = options;
  4745. const orientation = reactive(useDeviceOrientation({ window }));
  4746. const {
  4747. elementX: x,
  4748. elementY: y,
  4749. elementWidth: width,
  4750. elementHeight: height
  4751. } = useMouseInElement(target, { handleOutside: false, window });
  4752. const source = computed(() => {
  4753. if (orientation.isSupported && (orientation.alpha != null && orientation.alpha !== 0 || orientation.gamma != null && orientation.gamma !== 0))
  4754. return "deviceOrientation";
  4755. return "mouse";
  4756. });
  4757. const roll = computed(() => {
  4758. if (source.value === "deviceOrientation") {
  4759. const value = -orientation.beta / 90;
  4760. return deviceOrientationRollAdjust(value);
  4761. } else {
  4762. const value = -(y.value - height.value / 2) / height.value;
  4763. return mouseRollAdjust(value);
  4764. }
  4765. });
  4766. const tilt = computed(() => {
  4767. if (source.value === "deviceOrientation") {
  4768. const value = orientation.gamma / 90;
  4769. return deviceOrientationTiltAdjust(value);
  4770. } else {
  4771. const value = (x.value - width.value / 2) / width.value;
  4772. return mouseTiltAdjust(value);
  4773. }
  4774. });
  4775. return { roll, tilt, source };
  4776. }
  4777. function useParentElement(element = useCurrentElement()) {
  4778. const parentElement = shallowRef();
  4779. const update = () => {
  4780. const el = unrefElement(element);
  4781. if (el)
  4782. parentElement.value = el.parentElement;
  4783. };
  4784. tryOnMounted(update);
  4785. watch(() => toValue(element), update);
  4786. return parentElement;
  4787. }
  4788. var __getOwnPropSymbols$7 = Object.getOwnPropertySymbols;
  4789. var __hasOwnProp$7 = Object.prototype.hasOwnProperty;
  4790. var __propIsEnum$7 = Object.prototype.propertyIsEnumerable;
  4791. var __objRest$1 = (source, exclude) => {
  4792. var target = {};
  4793. for (var prop in source)
  4794. if (__hasOwnProp$7.call(source, prop) && exclude.indexOf(prop) < 0)
  4795. target[prop] = source[prop];
  4796. if (source != null && __getOwnPropSymbols$7)
  4797. for (var prop of __getOwnPropSymbols$7(source)) {
  4798. if (exclude.indexOf(prop) < 0 && __propIsEnum$7.call(source, prop))
  4799. target[prop] = source[prop];
  4800. }
  4801. return target;
  4802. };
  4803. function usePerformanceObserver(options, callback) {
  4804. const _a = options, {
  4805. window = defaultWindow,
  4806. immediate = true
  4807. } = _a, performanceOptions = __objRest$1(_a, [
  4808. "window",
  4809. "immediate"
  4810. ]);
  4811. const isSupported = useSupported(() => window && "PerformanceObserver" in window);
  4812. let observer;
  4813. const stop = () => {
  4814. observer == null ? void 0 : observer.disconnect();
  4815. };
  4816. const start = () => {
  4817. if (isSupported.value) {
  4818. stop();
  4819. observer = new PerformanceObserver(callback);
  4820. observer.observe(performanceOptions);
  4821. }
  4822. };
  4823. tryOnScopeDispose(stop);
  4824. if (immediate)
  4825. start();
  4826. return {
  4827. isSupported,
  4828. start,
  4829. stop
  4830. };
  4831. }
  4832. var __defProp$6 = Object.defineProperty;
  4833. var __defProps$2 = Object.defineProperties;
  4834. var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
  4835. var __getOwnPropSymbols$6 = Object.getOwnPropertySymbols;
  4836. var __hasOwnProp$6 = Object.prototype.hasOwnProperty;
  4837. var __propIsEnum$6 = Object.prototype.propertyIsEnumerable;
  4838. var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  4839. var __spreadValues$6 = (a, b) => {
  4840. for (var prop in b || (b = {}))
  4841. if (__hasOwnProp$6.call(b, prop))
  4842. __defNormalProp$6(a, prop, b[prop]);
  4843. if (__getOwnPropSymbols$6)
  4844. for (var prop of __getOwnPropSymbols$6(b)) {
  4845. if (__propIsEnum$6.call(b, prop))
  4846. __defNormalProp$6(a, prop, b[prop]);
  4847. }
  4848. return a;
  4849. };
  4850. var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
  4851. const defaultState = {
  4852. x: 0,
  4853. y: 0,
  4854. pointerId: 0,
  4855. pressure: 0,
  4856. tiltX: 0,
  4857. tiltY: 0,
  4858. width: 0,
  4859. height: 0,
  4860. twist: 0,
  4861. pointerType: null
  4862. };
  4863. const keys = /* @__PURE__ */ Object.keys(defaultState);
  4864. function usePointer(options = {}) {
  4865. const {
  4866. target = defaultWindow
  4867. } = options;
  4868. const isInside = ref(false);
  4869. const state = ref(options.initialValue || {});
  4870. Object.assign(state.value, defaultState, state.value);
  4871. const handler = (event) => {
  4872. isInside.value = true;
  4873. if (options.pointerTypes && !options.pointerTypes.includes(event.pointerType))
  4874. return;
  4875. state.value = objectPick(event, keys, false);
  4876. };
  4877. if (target) {
  4878. useEventListener(target, "pointerdown", handler, { passive: true });
  4879. useEventListener(target, "pointermove", handler, { passive: true });
  4880. useEventListener(target, "pointerleave", () => isInside.value = false, { passive: true });
  4881. }
  4882. return __spreadProps$2(__spreadValues$6({}, toRefs(state)), {
  4883. isInside
  4884. });
  4885. }
  4886. function usePointerLock(target, options = {}) {
  4887. const { document = defaultDocument, pointerLockOptions } = options;
  4888. const isSupported = useSupported(() => document && "pointerLockElement" in document);
  4889. const element = ref();
  4890. const triggerElement = ref();
  4891. let targetElement;
  4892. if (isSupported.value) {
  4893. useEventListener(document, "pointerlockchange", () => {
  4894. var _a;
  4895. const currentElement = (_a = document.pointerLockElement) != null ? _a : element.value;
  4896. if (targetElement && currentElement === targetElement) {
  4897. element.value = document.pointerLockElement;
  4898. if (!element.value)
  4899. targetElement = triggerElement.value = null;
  4900. }
  4901. });
  4902. useEventListener(document, "pointerlockerror", () => {
  4903. var _a;
  4904. const currentElement = (_a = document.pointerLockElement) != null ? _a : element.value;
  4905. if (targetElement && currentElement === targetElement) {
  4906. const action = document.pointerLockElement ? "release" : "acquire";
  4907. throw new Error(`Failed to ${action} pointer lock.`);
  4908. }
  4909. });
  4910. }
  4911. async function lock(e, options2) {
  4912. var _a;
  4913. if (!isSupported.value)
  4914. throw new Error("Pointer Lock API is not supported by your browser.");
  4915. triggerElement.value = e instanceof Event ? e.currentTarget : null;
  4916. targetElement = e instanceof Event ? (_a = unrefElement(target)) != null ? _a : triggerElement.value : unrefElement(e);
  4917. if (!targetElement)
  4918. throw new Error("Target element undefined.");
  4919. targetElement.requestPointerLock(options2 != null ? options2 : pointerLockOptions);
  4920. return await until(element).toBe(targetElement);
  4921. }
  4922. async function unlock() {
  4923. if (!element.value)
  4924. return false;
  4925. document.exitPointerLock();
  4926. await until(element).toBeNull();
  4927. return true;
  4928. }
  4929. return {
  4930. isSupported,
  4931. element,
  4932. triggerElement,
  4933. lock,
  4934. unlock
  4935. };
  4936. }
  4937. function usePointerSwipe(target, options = {}) {
  4938. const targetRef = toRef(target);
  4939. const {
  4940. threshold = 50,
  4941. onSwipe,
  4942. onSwipeEnd,
  4943. onSwipeStart
  4944. } = options;
  4945. const posStart = reactive({ x: 0, y: 0 });
  4946. const updatePosStart = (x, y) => {
  4947. posStart.x = x;
  4948. posStart.y = y;
  4949. };
  4950. const posEnd = reactive({ x: 0, y: 0 });
  4951. const updatePosEnd = (x, y) => {
  4952. posEnd.x = x;
  4953. posEnd.y = y;
  4954. };
  4955. const distanceX = computed(() => posStart.x - posEnd.x);
  4956. const distanceY = computed(() => posStart.y - posEnd.y);
  4957. const { max, abs } = Math;
  4958. const isThresholdExceeded = computed(() => max(abs(distanceX.value), abs(distanceY.value)) >= threshold);
  4959. const isSwiping = ref(false);
  4960. const isPointerDown = ref(false);
  4961. const direction = computed(() => {
  4962. if (!isThresholdExceeded.value)
  4963. return "none";
  4964. if (abs(distanceX.value) > abs(distanceY.value)) {
  4965. return distanceX.value > 0 ? "left" : "right";
  4966. } else {
  4967. return distanceY.value > 0 ? "up" : "down";
  4968. }
  4969. });
  4970. const eventIsAllowed = (e) => {
  4971. var _a, _b, _c;
  4972. const isReleasingButton = e.buttons === 0;
  4973. const isPrimaryButton = e.buttons === 1;
  4974. return (_c = (_b = (_a = options.pointerTypes) == null ? void 0 : _a.includes(e.pointerType)) != null ? _b : isReleasingButton || isPrimaryButton) != null ? _c : true;
  4975. };
  4976. const stops = [
  4977. useEventListener(target, "pointerdown", (e) => {
  4978. var _a, _b;
  4979. if (!eventIsAllowed(e))
  4980. return;
  4981. isPointerDown.value = true;
  4982. (_b = (_a = targetRef.value) == null ? void 0 : _a.style) == null ? void 0 : _b.setProperty("touch-action", "none");
  4983. const eventTarget = e.target;
  4984. eventTarget == null ? void 0 : eventTarget.setPointerCapture(e.pointerId);
  4985. const { clientX: x, clientY: y } = e;
  4986. updatePosStart(x, y);
  4987. updatePosEnd(x, y);
  4988. onSwipeStart == null ? void 0 : onSwipeStart(e);
  4989. }),
  4990. useEventListener(target, "pointermove", (e) => {
  4991. if (!eventIsAllowed(e))
  4992. return;
  4993. if (!isPointerDown.value)
  4994. return;
  4995. const { clientX: x, clientY: y } = e;
  4996. updatePosEnd(x, y);
  4997. if (!isSwiping.value && isThresholdExceeded.value)
  4998. isSwiping.value = true;
  4999. if (isSwiping.value)
  5000. onSwipe == null ? void 0 : onSwipe(e);
  5001. }),
  5002. useEventListener(target, "pointerup", (e) => {
  5003. var _a, _b;
  5004. if (!eventIsAllowed(e))
  5005. return;
  5006. if (isSwiping.value)
  5007. onSwipeEnd == null ? void 0 : onSwipeEnd(e, direction.value);
  5008. isPointerDown.value = false;
  5009. isSwiping.value = false;
  5010. (_b = (_a = targetRef.value) == null ? void 0 : _a.style) == null ? void 0 : _b.setProperty("touch-action", "initial");
  5011. })
  5012. ];
  5013. const stop = () => stops.forEach((s) => s());
  5014. return {
  5015. isSwiping: readonly(isSwiping),
  5016. direction: readonly(direction),
  5017. posStart: readonly(posStart),
  5018. posEnd: readonly(posEnd),
  5019. distanceX,
  5020. distanceY,
  5021. stop
  5022. };
  5023. }
  5024. function usePreferredColorScheme(options) {
  5025. const isLight = useMediaQuery("(prefers-color-scheme: light)", options);
  5026. const isDark = useMediaQuery("(prefers-color-scheme: dark)", options);
  5027. return computed(() => {
  5028. if (isDark.value)
  5029. return "dark";
  5030. if (isLight.value)
  5031. return "light";
  5032. return "no-preference";
  5033. });
  5034. }
  5035. function usePreferredContrast(options) {
  5036. const isMore = useMediaQuery("(prefers-contrast: more)", options);
  5037. const isLess = useMediaQuery("(prefers-contrast: less)", options);
  5038. const isCustom = useMediaQuery("(prefers-contrast: custom)", options);
  5039. return computed(() => {
  5040. if (isMore.value)
  5041. return "more";
  5042. if (isLess.value)
  5043. return "less";
  5044. if (isCustom.value)
  5045. return "custom";
  5046. return "no-preference";
  5047. });
  5048. }
  5049. function usePreferredLanguages(options = {}) {
  5050. const { window = defaultWindow } = options;
  5051. if (!window)
  5052. return ref(["en"]);
  5053. const navigator = window.navigator;
  5054. const value = ref(navigator.languages);
  5055. useEventListener(window, "languagechange", () => {
  5056. value.value = navigator.languages;
  5057. });
  5058. return value;
  5059. }
  5060. function usePreferredReducedMotion(options) {
  5061. const isReduced = useMediaQuery("(prefers-reduced-motion: reduce)", options);
  5062. return computed(() => {
  5063. if (isReduced.value)
  5064. return "reduce";
  5065. return "no-preference";
  5066. });
  5067. }
  5068. function usePrevious(value, initialValue) {
  5069. const previous = shallowRef(initialValue);
  5070. watch(
  5071. toRef(value),
  5072. (_, oldValue) => {
  5073. previous.value = oldValue;
  5074. },
  5075. { flush: "sync" }
  5076. );
  5077. return readonly(previous);
  5078. }
  5079. function useScreenOrientation(options = {}) {
  5080. const {
  5081. window = defaultWindow
  5082. } = options;
  5083. const isSupported = useSupported(() => window && "screen" in window && "orientation" in window.screen);
  5084. const screenOrientation = isSupported.value ? window.screen.orientation : {};
  5085. const orientation = ref(screenOrientation.type);
  5086. const angle = ref(screenOrientation.angle || 0);
  5087. if (isSupported.value) {
  5088. useEventListener(window, "orientationchange", () => {
  5089. orientation.value = screenOrientation.type;
  5090. angle.value = screenOrientation.angle;
  5091. });
  5092. }
  5093. const lockOrientation = (type) => {
  5094. if (!isSupported.value)
  5095. return Promise.reject(new Error("Not supported"));
  5096. return screenOrientation.lock(type);
  5097. };
  5098. const unlockOrientation = () => {
  5099. if (isSupported.value)
  5100. screenOrientation.unlock();
  5101. };
  5102. return {
  5103. isSupported,
  5104. orientation,
  5105. angle,
  5106. lockOrientation,
  5107. unlockOrientation
  5108. };
  5109. }
  5110. const topVarName = "--vueuse-safe-area-top";
  5111. const rightVarName = "--vueuse-safe-area-right";
  5112. const bottomVarName = "--vueuse-safe-area-bottom";
  5113. const leftVarName = "--vueuse-safe-area-left";
  5114. function useScreenSafeArea() {
  5115. const top = ref("");
  5116. const right = ref("");
  5117. const bottom = ref("");
  5118. const left = ref("");
  5119. if (isClient) {
  5120. const topCssVar = useCssVar(topVarName);
  5121. const rightCssVar = useCssVar(rightVarName);
  5122. const bottomCssVar = useCssVar(bottomVarName);
  5123. const leftCssVar = useCssVar(leftVarName);
  5124. topCssVar.value = "env(safe-area-inset-top, 0px)";
  5125. rightCssVar.value = "env(safe-area-inset-right, 0px)";
  5126. bottomCssVar.value = "env(safe-area-inset-bottom, 0px)";
  5127. leftCssVar.value = "env(safe-area-inset-left, 0px)";
  5128. update();
  5129. useEventListener("resize", useDebounceFn(update));
  5130. }
  5131. function update() {
  5132. top.value = getValue(topVarName);
  5133. right.value = getValue(rightVarName);
  5134. bottom.value = getValue(bottomVarName);
  5135. left.value = getValue(leftVarName);
  5136. }
  5137. return {
  5138. top,
  5139. right,
  5140. bottom,
  5141. left,
  5142. update
  5143. };
  5144. }
  5145. function getValue(position) {
  5146. return getComputedStyle(document.documentElement).getPropertyValue(position);
  5147. }
  5148. function useScriptTag(src, onLoaded = noop, options = {}) {
  5149. const {
  5150. immediate = true,
  5151. manual = false,
  5152. type = "text/javascript",
  5153. async = true,
  5154. crossOrigin,
  5155. referrerPolicy,
  5156. noModule,
  5157. defer,
  5158. document = defaultDocument,
  5159. attrs = {}
  5160. } = options;
  5161. const scriptTag = ref(null);
  5162. let _promise = null;
  5163. const loadScript = (waitForScriptLoad) => new Promise((resolve, reject) => {
  5164. const resolveWithElement = (el2) => {
  5165. scriptTag.value = el2;
  5166. resolve(el2);
  5167. return el2;
  5168. };
  5169. if (!document) {
  5170. resolve(false);
  5171. return;
  5172. }
  5173. let shouldAppend = false;
  5174. let el = document.querySelector(`script[src="${toValue(src)}"]`);
  5175. if (!el) {
  5176. el = document.createElement("script");
  5177. el.type = type;
  5178. el.async = async;
  5179. el.src = toValue(src);
  5180. if (defer)
  5181. el.defer = defer;
  5182. if (crossOrigin)
  5183. el.crossOrigin = crossOrigin;
  5184. if (noModule)
  5185. el.noModule = noModule;
  5186. if (referrerPolicy)
  5187. el.referrerPolicy = referrerPolicy;
  5188. Object.entries(attrs).forEach(([name, value]) => el == null ? void 0 : el.setAttribute(name, value));
  5189. shouldAppend = true;
  5190. } else if (el.hasAttribute("data-loaded")) {
  5191. resolveWithElement(el);
  5192. }
  5193. el.addEventListener("error", (event) => reject(event));
  5194. el.addEventListener("abort", (event) => reject(event));
  5195. el.addEventListener("load", () => {
  5196. el.setAttribute("data-loaded", "true");
  5197. onLoaded(el);
  5198. resolveWithElement(el);
  5199. });
  5200. if (shouldAppend)
  5201. el = document.head.appendChild(el);
  5202. if (!waitForScriptLoad)
  5203. resolveWithElement(el);
  5204. });
  5205. const load = (waitForScriptLoad = true) => {
  5206. if (!_promise)
  5207. _promise = loadScript(waitForScriptLoad);
  5208. return _promise;
  5209. };
  5210. const unload = () => {
  5211. if (!document)
  5212. return;
  5213. _promise = null;
  5214. if (scriptTag.value)
  5215. scriptTag.value = null;
  5216. const el = document.querySelector(`script[src="${toValue(src)}"]`);
  5217. if (el)
  5218. document.head.removeChild(el);
  5219. };
  5220. if (immediate && !manual)
  5221. tryOnMounted(load);
  5222. if (!manual)
  5223. tryOnUnmounted(unload);
  5224. return { scriptTag, load, unload };
  5225. }
  5226. function checkOverflowScroll(ele) {
  5227. const style = window.getComputedStyle(ele);
  5228. if (style.overflowX === "scroll" || style.overflowY === "scroll" || style.overflowX === "auto" && ele.clientHeight < ele.scrollHeight || style.overflowY === "auto" && ele.clientWidth < ele.scrollWidth) {
  5229. return true;
  5230. } else {
  5231. const parent = ele.parentNode;
  5232. if (!parent || parent.tagName === "BODY")
  5233. return false;
  5234. return checkOverflowScroll(parent);
  5235. }
  5236. }
  5237. function preventDefault(rawEvent) {
  5238. const e = rawEvent || window.event;
  5239. const _target = e.target;
  5240. if (checkOverflowScroll(_target))
  5241. return false;
  5242. if (e.touches.length > 1)
  5243. return true;
  5244. if (e.preventDefault)
  5245. e.preventDefault();
  5246. return false;
  5247. }
  5248. function useScrollLock(element, initialState = false) {
  5249. const isLocked = ref(initialState);
  5250. let stopTouchMoveListener = null;
  5251. let initialOverflow;
  5252. watch(toRef(element), (el) => {
  5253. if (el) {
  5254. const ele = el;
  5255. initialOverflow = ele.style.overflow;
  5256. if (isLocked.value)
  5257. ele.style.overflow = "hidden";
  5258. }
  5259. }, {
  5260. immediate: true
  5261. });
  5262. const lock = () => {
  5263. const ele = toValue(element);
  5264. if (!ele || isLocked.value)
  5265. return;
  5266. if (isIOS) {
  5267. stopTouchMoveListener = useEventListener(
  5268. ele,
  5269. "touchmove",
  5270. (e) => {
  5271. preventDefault(e);
  5272. },
  5273. { passive: false }
  5274. );
  5275. }
  5276. ele.style.overflow = "hidden";
  5277. isLocked.value = true;
  5278. };
  5279. const unlock = () => {
  5280. const ele = toValue(element);
  5281. if (!ele || !isLocked.value)
  5282. return;
  5283. isIOS && (stopTouchMoveListener == null ? void 0 : stopTouchMoveListener());
  5284. ele.style.overflow = initialOverflow;
  5285. isLocked.value = false;
  5286. };
  5287. tryOnScopeDispose(unlock);
  5288. return computed({
  5289. get() {
  5290. return isLocked.value;
  5291. },
  5292. set(v) {
  5293. if (v)
  5294. lock();
  5295. else
  5296. unlock();
  5297. }
  5298. });
  5299. }
  5300. function useSessionStorage(key, initialValue, options = {}) {
  5301. const { window = defaultWindow } = options;
  5302. return useStorage(key, initialValue, window == null ? void 0 : window.sessionStorage, options);
  5303. }
  5304. var __defProp$5 = Object.defineProperty;
  5305. var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
  5306. var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
  5307. var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
  5308. var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  5309. var __spreadValues$5 = (a, b) => {
  5310. for (var prop in b || (b = {}))
  5311. if (__hasOwnProp$5.call(b, prop))
  5312. __defNormalProp$5(a, prop, b[prop]);
  5313. if (__getOwnPropSymbols$5)
  5314. for (var prop of __getOwnPropSymbols$5(b)) {
  5315. if (__propIsEnum$5.call(b, prop))
  5316. __defNormalProp$5(a, prop, b[prop]);
  5317. }
  5318. return a;
  5319. };
  5320. function useShare(shareOptions = {}, options = {}) {
  5321. const { navigator = defaultNavigator } = options;
  5322. const _navigator = navigator;
  5323. const isSupported = useSupported(() => _navigator && "canShare" in _navigator);
  5324. const share = async (overrideOptions = {}) => {
  5325. if (isSupported.value) {
  5326. const data = __spreadValues$5(__spreadValues$5({}, toValue(shareOptions)), toValue(overrideOptions));
  5327. let granted = true;
  5328. if (data.files && _navigator.canShare)
  5329. granted = _navigator.canShare({ files: data.files });
  5330. if (granted)
  5331. return _navigator.share(data);
  5332. }
  5333. };
  5334. return {
  5335. isSupported,
  5336. share
  5337. };
  5338. }
  5339. const defaultSortFn = (source, compareFn) => source.sort(compareFn);
  5340. const defaultCompare = (a, b) => a - b;
  5341. function useSorted(...args) {
  5342. var _a, _b, _c, _d;
  5343. const [source] = args;
  5344. let compareFn = defaultCompare;
  5345. let options = {};
  5346. if (args.length === 2) {
  5347. if (typeof args[1] === "object") {
  5348. options = args[1];
  5349. compareFn = (_a = options.compareFn) != null ? _a : defaultCompare;
  5350. } else {
  5351. compareFn = (_b = args[1]) != null ? _b : defaultCompare;
  5352. }
  5353. } else if (args.length > 2) {
  5354. compareFn = (_c = args[1]) != null ? _c : defaultCompare;
  5355. options = (_d = args[2]) != null ? _d : {};
  5356. }
  5357. const {
  5358. dirty = false,
  5359. sortFn = defaultSortFn
  5360. } = options;
  5361. if (!dirty)
  5362. return computed(() => sortFn([...toValue(source)], compareFn));
  5363. watchEffect(() => {
  5364. const result = sortFn(toValue(source), compareFn);
  5365. if (isRef(source))
  5366. source.value = result;
  5367. else
  5368. source.splice(0, source.length, ...result);
  5369. });
  5370. return source;
  5371. }
  5372. function useSpeechRecognition(options = {}) {
  5373. const {
  5374. interimResults = true,
  5375. continuous = true,
  5376. window = defaultWindow
  5377. } = options;
  5378. const lang = toRef(options.lang || "en-US");
  5379. const isListening = ref(false);
  5380. const isFinal = ref(false);
  5381. const result = ref("");
  5382. const error = shallowRef(void 0);
  5383. const toggle = (value = !isListening.value) => {
  5384. isListening.value = value;
  5385. };
  5386. const start = () => {
  5387. isListening.value = true;
  5388. };
  5389. const stop = () => {
  5390. isListening.value = false;
  5391. };
  5392. const SpeechRecognition = window && (window.SpeechRecognition || window.webkitSpeechRecognition);
  5393. const isSupported = useSupported(() => SpeechRecognition);
  5394. let recognition;
  5395. if (isSupported.value) {
  5396. recognition = new SpeechRecognition();
  5397. recognition.continuous = continuous;
  5398. recognition.interimResults = interimResults;
  5399. recognition.lang = toValue(lang);
  5400. recognition.onstart = () => {
  5401. isFinal.value = false;
  5402. };
  5403. watch(lang, (lang2) => {
  5404. if (recognition && !isListening.value)
  5405. recognition.lang = lang2;
  5406. });
  5407. recognition.onresult = (event) => {
  5408. const transcript = Array.from(event.results).map((result2) => {
  5409. isFinal.value = result2.isFinal;
  5410. return result2[0];
  5411. }).map((result2) => result2.transcript).join("");
  5412. result.value = transcript;
  5413. error.value = void 0;
  5414. };
  5415. recognition.onerror = (event) => {
  5416. error.value = event;
  5417. };
  5418. recognition.onend = () => {
  5419. isListening.value = false;
  5420. recognition.lang = toValue(lang);
  5421. };
  5422. watch(isListening, () => {
  5423. if (isListening.value)
  5424. recognition.start();
  5425. else
  5426. recognition.stop();
  5427. });
  5428. }
  5429. tryOnScopeDispose(() => {
  5430. isListening.value = false;
  5431. });
  5432. return {
  5433. isSupported,
  5434. isListening,
  5435. isFinal,
  5436. recognition,
  5437. result,
  5438. error,
  5439. toggle,
  5440. start,
  5441. stop
  5442. };
  5443. }
  5444. function useSpeechSynthesis(text, options = {}) {
  5445. const {
  5446. pitch = 1,
  5447. rate = 1,
  5448. volume = 1,
  5449. window = defaultWindow
  5450. } = options;
  5451. const synth = window && window.speechSynthesis;
  5452. const isSupported = useSupported(() => synth);
  5453. const isPlaying = ref(false);
  5454. const status = ref("init");
  5455. const spokenText = toRef(text || "");
  5456. const lang = toRef(options.lang || "en-US");
  5457. const error = shallowRef(void 0);
  5458. const toggle = (value = !isPlaying.value) => {
  5459. isPlaying.value = value;
  5460. };
  5461. const bindEventsForUtterance = (utterance2) => {
  5462. utterance2.lang = toValue(lang);
  5463. utterance2.voice = toValue(options.voice) || null;
  5464. utterance2.pitch = pitch;
  5465. utterance2.rate = rate;
  5466. utterance2.volume = volume;
  5467. utterance2.onstart = () => {
  5468. isPlaying.value = true;
  5469. status.value = "play";
  5470. };
  5471. utterance2.onpause = () => {
  5472. isPlaying.value = false;
  5473. status.value = "pause";
  5474. };
  5475. utterance2.onresume = () => {
  5476. isPlaying.value = true;
  5477. status.value = "play";
  5478. };
  5479. utterance2.onend = () => {
  5480. isPlaying.value = false;
  5481. status.value = "end";
  5482. };
  5483. utterance2.onerror = (event) => {
  5484. error.value = event;
  5485. };
  5486. };
  5487. const utterance = computed(() => {
  5488. isPlaying.value = false;
  5489. status.value = "init";
  5490. const newUtterance = new SpeechSynthesisUtterance(spokenText.value);
  5491. bindEventsForUtterance(newUtterance);
  5492. return newUtterance;
  5493. });
  5494. const speak = () => {
  5495. synth.cancel();
  5496. utterance && synth.speak(utterance.value);
  5497. };
  5498. const stop = () => {
  5499. synth.cancel();
  5500. isPlaying.value = false;
  5501. };
  5502. if (isSupported.value) {
  5503. bindEventsForUtterance(utterance.value);
  5504. watch(lang, (lang2) => {
  5505. if (utterance.value && !isPlaying.value)
  5506. utterance.value.lang = lang2;
  5507. });
  5508. if (options.voice) {
  5509. watch(options.voice, () => {
  5510. synth.cancel();
  5511. });
  5512. }
  5513. watch(isPlaying, () => {
  5514. if (isPlaying.value)
  5515. synth.resume();
  5516. else
  5517. synth.pause();
  5518. });
  5519. }
  5520. tryOnScopeDispose(() => {
  5521. isPlaying.value = false;
  5522. });
  5523. return {
  5524. isSupported,
  5525. isPlaying,
  5526. status,
  5527. utterance,
  5528. error,
  5529. stop,
  5530. toggle,
  5531. speak
  5532. };
  5533. }
  5534. function useStepper(steps, initialStep) {
  5535. const stepsRef = ref(steps);
  5536. const stepNames = computed(() => Array.isArray(stepsRef.value) ? stepsRef.value : Object.keys(stepsRef.value));
  5537. const index = ref(stepNames.value.indexOf(initialStep != null ? initialStep : stepNames.value[0]));
  5538. const current = computed(() => at(index.value));
  5539. const isFirst = computed(() => index.value === 0);
  5540. const isLast = computed(() => index.value === stepNames.value.length - 1);
  5541. const next = computed(() => stepNames.value[index.value + 1]);
  5542. const previous = computed(() => stepNames.value[index.value - 1]);
  5543. function at(index2) {
  5544. if (Array.isArray(stepsRef.value))
  5545. return stepsRef.value[index2];
  5546. return stepsRef.value[stepNames.value[index2]];
  5547. }
  5548. function get(step) {
  5549. if (!stepNames.value.includes(step))
  5550. return;
  5551. return at(stepNames.value.indexOf(step));
  5552. }
  5553. function goTo(step) {
  5554. if (stepNames.value.includes(step))
  5555. index.value = stepNames.value.indexOf(step);
  5556. }
  5557. function goToNext() {
  5558. if (isLast.value)
  5559. return;
  5560. index.value++;
  5561. }
  5562. function goToPrevious() {
  5563. if (isFirst.value)
  5564. return;
  5565. index.value--;
  5566. }
  5567. function goBackTo(step) {
  5568. if (isAfter(step))
  5569. goTo(step);
  5570. }
  5571. function isNext(step) {
  5572. return stepNames.value.indexOf(step) === index.value + 1;
  5573. }
  5574. function isPrevious(step) {
  5575. return stepNames.value.indexOf(step) === index.value - 1;
  5576. }
  5577. function isCurrent(step) {
  5578. return stepNames.value.indexOf(step) === index.value;
  5579. }
  5580. function isBefore(step) {
  5581. return index.value < stepNames.value.indexOf(step);
  5582. }
  5583. function isAfter(step) {
  5584. return index.value > stepNames.value.indexOf(step);
  5585. }
  5586. return {
  5587. steps: stepsRef,
  5588. stepNames,
  5589. index,
  5590. current,
  5591. next,
  5592. previous,
  5593. isFirst,
  5594. isLast,
  5595. at,
  5596. get,
  5597. goTo,
  5598. goToNext,
  5599. goToPrevious,
  5600. goBackTo,
  5601. isNext,
  5602. isPrevious,
  5603. isCurrent,
  5604. isBefore,
  5605. isAfter
  5606. };
  5607. }
  5608. var __defProp$4 = Object.defineProperty;
  5609. var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
  5610. var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
  5611. var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
  5612. var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  5613. var __spreadValues$4 = (a, b) => {
  5614. for (var prop in b || (b = {}))
  5615. if (__hasOwnProp$4.call(b, prop))
  5616. __defNormalProp$4(a, prop, b[prop]);
  5617. if (__getOwnPropSymbols$4)
  5618. for (var prop of __getOwnPropSymbols$4(b)) {
  5619. if (__propIsEnum$4.call(b, prop))
  5620. __defNormalProp$4(a, prop, b[prop]);
  5621. }
  5622. return a;
  5623. };
  5624. function useStorageAsync(key, initialValue, storage, options = {}) {
  5625. var _a;
  5626. const {
  5627. flush = "pre",
  5628. deep = true,
  5629. listenToStorageChanges = true,
  5630. writeDefaults = true,
  5631. mergeDefaults = false,
  5632. shallow,
  5633. window = defaultWindow,
  5634. eventFilter,
  5635. onError = (e) => {
  5636. console.error(e);
  5637. }
  5638. } = options;
  5639. const rawInit = toValue(initialValue);
  5640. const type = guessSerializerType(rawInit);
  5641. const data = (shallow ? shallowRef : ref)(initialValue);
  5642. const serializer = (_a = options.serializer) != null ? _a : StorageSerializers[type];
  5643. if (!storage) {
  5644. try {
  5645. storage = getSSRHandler("getDefaultStorage", () => {
  5646. var _a2;
  5647. return (_a2 = defaultWindow) == null ? void 0 : _a2.localStorage;
  5648. })();
  5649. } catch (e) {
  5650. onError(e);
  5651. }
  5652. }
  5653. async function read(event) {
  5654. if (!storage || event && event.key !== key)
  5655. return;
  5656. try {
  5657. const rawValue = event ? event.newValue : await storage.getItem(key);
  5658. if (rawValue == null) {
  5659. data.value = rawInit;
  5660. if (writeDefaults && rawInit !== null)
  5661. await storage.setItem(key, await serializer.write(rawInit));
  5662. } else if (mergeDefaults) {
  5663. const value = await serializer.read(rawValue);
  5664. if (typeof mergeDefaults === "function")
  5665. data.value = mergeDefaults(value, rawInit);
  5666. else if (type === "object" && !Array.isArray(value))
  5667. data.value = __spreadValues$4(__spreadValues$4({}, rawInit), value);
  5668. else
  5669. data.value = value;
  5670. } else {
  5671. data.value = await serializer.read(rawValue);
  5672. }
  5673. } catch (e) {
  5674. onError(e);
  5675. }
  5676. }
  5677. read();
  5678. if (window && listenToStorageChanges)
  5679. useEventListener(window, "storage", (e) => Promise.resolve().then(() => read(e)));
  5680. if (storage) {
  5681. watchWithFilter(
  5682. data,
  5683. async () => {
  5684. try {
  5685. if (data.value == null)
  5686. await storage.removeItem(key);
  5687. else
  5688. await storage.setItem(key, await serializer.write(data.value));
  5689. } catch (e) {
  5690. onError(e);
  5691. }
  5692. },
  5693. {
  5694. flush,
  5695. deep,
  5696. eventFilter
  5697. }
  5698. );
  5699. }
  5700. return data;
  5701. }
  5702. let _id = 0;
  5703. function useStyleTag(css, options = {}) {
  5704. const isLoaded = ref(false);
  5705. const {
  5706. document = defaultDocument,
  5707. immediate = true,
  5708. manual = false,
  5709. id = `vueuse_styletag_${++_id}`
  5710. } = options;
  5711. const cssRef = ref(css);
  5712. let stop = () => {
  5713. };
  5714. const load = () => {
  5715. if (!document)
  5716. return;
  5717. const el = document.getElementById(id) || document.createElement("style");
  5718. if (!el.isConnected) {
  5719. el.type = "text/css";
  5720. el.id = id;
  5721. if (options.media)
  5722. el.media = options.media;
  5723. document.head.appendChild(el);
  5724. }
  5725. if (isLoaded.value)
  5726. return;
  5727. stop = watch(
  5728. cssRef,
  5729. (value) => {
  5730. el.textContent = value;
  5731. },
  5732. { immediate: true }
  5733. );
  5734. isLoaded.value = true;
  5735. };
  5736. const unload = () => {
  5737. if (!document || !isLoaded.value)
  5738. return;
  5739. stop();
  5740. document.head.removeChild(document.getElementById(id));
  5741. isLoaded.value = false;
  5742. };
  5743. if (immediate && !manual)
  5744. tryOnMounted(load);
  5745. if (!manual)
  5746. tryOnScopeDispose(unload);
  5747. return {
  5748. id,
  5749. css: cssRef,
  5750. unload,
  5751. load,
  5752. isLoaded: readonly(isLoaded)
  5753. };
  5754. }
  5755. function useSwipe(target, options = {}) {
  5756. const {
  5757. threshold = 50,
  5758. onSwipe,
  5759. onSwipeEnd,
  5760. onSwipeStart,
  5761. passive = true,
  5762. window = defaultWindow
  5763. } = options;
  5764. const coordsStart = reactive({ x: 0, y: 0 });
  5765. const coordsEnd = reactive({ x: 0, y: 0 });
  5766. const diffX = computed(() => coordsStart.x - coordsEnd.x);
  5767. const diffY = computed(() => coordsStart.y - coordsEnd.y);
  5768. const { max, abs } = Math;
  5769. const isThresholdExceeded = computed(() => max(abs(diffX.value), abs(diffY.value)) >= threshold);
  5770. const isSwiping = ref(false);
  5771. const direction = computed(() => {
  5772. if (!isThresholdExceeded.value)
  5773. return "none";
  5774. if (abs(diffX.value) > abs(diffY.value)) {
  5775. return diffX.value > 0 ? "left" : "right";
  5776. } else {
  5777. return diffY.value > 0 ? "up" : "down";
  5778. }
  5779. });
  5780. const getTouchEventCoords = (e) => [e.touches[0].clientX, e.touches[0].clientY];
  5781. const updateCoordsStart = (x, y) => {
  5782. coordsStart.x = x;
  5783. coordsStart.y = y;
  5784. };
  5785. const updateCoordsEnd = (x, y) => {
  5786. coordsEnd.x = x;
  5787. coordsEnd.y = y;
  5788. };
  5789. let listenerOptions;
  5790. const isPassiveEventSupported = checkPassiveEventSupport(window == null ? void 0 : window.document);
  5791. if (!passive)
  5792. listenerOptions = isPassiveEventSupported ? { passive: false, capture: true } : { capture: true };
  5793. else
  5794. listenerOptions = isPassiveEventSupported ? { passive: true } : { capture: false };
  5795. const onTouchEnd = (e) => {
  5796. if (isSwiping.value)
  5797. onSwipeEnd == null ? void 0 : onSwipeEnd(e, direction.value);
  5798. isSwiping.value = false;
  5799. };
  5800. const stops = [
  5801. useEventListener(target, "touchstart", (e) => {
  5802. if (e.touches.length !== 1)
  5803. return;
  5804. if (listenerOptions.capture && !listenerOptions.passive)
  5805. e.preventDefault();
  5806. const [x, y] = getTouchEventCoords(e);
  5807. updateCoordsStart(x, y);
  5808. updateCoordsEnd(x, y);
  5809. onSwipeStart == null ? void 0 : onSwipeStart(e);
  5810. }, listenerOptions),
  5811. useEventListener(target, "touchmove", (e) => {
  5812. if (e.touches.length !== 1)
  5813. return;
  5814. const [x, y] = getTouchEventCoords(e);
  5815. updateCoordsEnd(x, y);
  5816. if (!isSwiping.value && isThresholdExceeded.value)
  5817. isSwiping.value = true;
  5818. if (isSwiping.value)
  5819. onSwipe == null ? void 0 : onSwipe(e);
  5820. }, listenerOptions),
  5821. useEventListener(target, "touchend", onTouchEnd, listenerOptions),
  5822. useEventListener(target, "touchcancel", onTouchEnd, listenerOptions)
  5823. ];
  5824. const stop = () => stops.forEach((s) => s());
  5825. return {
  5826. isPassiveEventSupported,
  5827. isSwiping,
  5828. direction,
  5829. coordsStart,
  5830. coordsEnd,
  5831. lengthX: diffX,
  5832. lengthY: diffY,
  5833. stop
  5834. };
  5835. }
  5836. function checkPassiveEventSupport(document) {
  5837. if (!document)
  5838. return false;
  5839. let supportsPassive = false;
  5840. const optionsBlock = {
  5841. get passive() {
  5842. supportsPassive = true;
  5843. return false;
  5844. }
  5845. };
  5846. document.addEventListener("x", noop, optionsBlock);
  5847. document.removeEventListener("x", noop);
  5848. return supportsPassive;
  5849. }
  5850. function useTemplateRefsList() {
  5851. const refs = ref([]);
  5852. refs.value.set = (el) => {
  5853. if (el)
  5854. refs.value.push(el);
  5855. };
  5856. onBeforeUpdate(() => {
  5857. refs.value.length = 0;
  5858. });
  5859. return refs;
  5860. }
  5861. function useTextDirection(options = {}) {
  5862. const {
  5863. document = defaultDocument,
  5864. selector = "html",
  5865. observe = false,
  5866. initialValue = "ltr"
  5867. } = options;
  5868. function getValue() {
  5869. var _a, _b;
  5870. return (_b = (_a = document == null ? void 0 : document.querySelector(selector)) == null ? void 0 : _a.getAttribute("dir")) != null ? _b : initialValue;
  5871. }
  5872. const dir = ref(getValue());
  5873. tryOnMounted(() => dir.value = getValue());
  5874. if (observe && document) {
  5875. useMutationObserver(
  5876. document.querySelector(selector),
  5877. () => dir.value = getValue(),
  5878. { attributes: true }
  5879. );
  5880. }
  5881. return computed({
  5882. get() {
  5883. return dir.value;
  5884. },
  5885. set(v) {
  5886. var _a, _b;
  5887. dir.value = v;
  5888. if (!document)
  5889. return;
  5890. if (dir.value)
  5891. (_a = document.querySelector(selector)) == null ? void 0 : _a.setAttribute("dir", dir.value);
  5892. else
  5893. (_b = document.querySelector(selector)) == null ? void 0 : _b.removeAttribute("dir");
  5894. }
  5895. });
  5896. }
  5897. function getRangesFromSelection(selection) {
  5898. var _a;
  5899. const rangeCount = (_a = selection.rangeCount) != null ? _a : 0;
  5900. const ranges = new Array(rangeCount);
  5901. for (let i = 0; i < rangeCount; i++) {
  5902. const range = selection.getRangeAt(i);
  5903. ranges[i] = range;
  5904. }
  5905. return ranges;
  5906. }
  5907. function useTextSelection(options = {}) {
  5908. const {
  5909. window = defaultWindow
  5910. } = options;
  5911. const selection = ref(null);
  5912. const text = computed(() => {
  5913. var _a, _b;
  5914. return (_b = (_a = selection.value) == null ? void 0 : _a.toString()) != null ? _b : "";
  5915. });
  5916. const ranges = computed(() => selection.value ? getRangesFromSelection(selection.value) : []);
  5917. const rects = computed(() => ranges.value.map((range) => range.getBoundingClientRect()));
  5918. function onSelectionChange() {
  5919. selection.value = null;
  5920. if (window)
  5921. selection.value = window.getSelection();
  5922. }
  5923. if (window)
  5924. useEventListener(window.document, "selectionchange", onSelectionChange);
  5925. return {
  5926. text,
  5927. rects,
  5928. ranges,
  5929. selection
  5930. };
  5931. }
  5932. function useTextareaAutosize(options) {
  5933. const textarea = ref(options == null ? void 0 : options.element);
  5934. const input = ref(options == null ? void 0 : options.input);
  5935. const textareaScrollHeight = ref(1);
  5936. function triggerResize() {
  5937. var _a, _b;
  5938. if (!textarea.value)
  5939. return;
  5940. let height = "";
  5941. textarea.value.style.height = "1px";
  5942. textareaScrollHeight.value = (_a = textarea.value) == null ? void 0 : _a.scrollHeight;
  5943. if (options == null ? void 0 : options.styleTarget)
  5944. toValue(options.styleTarget).style.height = `${textareaScrollHeight.value}px`;
  5945. else
  5946. height = `${textareaScrollHeight.value}px`;
  5947. textarea.value.style.height = height;
  5948. (_b = options == null ? void 0 : options.onResize) == null ? void 0 : _b.call(options);
  5949. }
  5950. watch([input, textarea], triggerResize, { immediate: true });
  5951. useResizeObserver(textarea, () => triggerResize());
  5952. if (options == null ? void 0 : options.watch)
  5953. watch(options.watch, triggerResize, { immediate: true, deep: true });
  5954. return {
  5955. textarea,
  5956. input,
  5957. triggerResize
  5958. };
  5959. }
  5960. var __defProp$3 = Object.defineProperty;
  5961. var __defProps$1 = Object.defineProperties;
  5962. var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
  5963. var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
  5964. var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
  5965. var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
  5966. var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  5967. var __spreadValues$3 = (a, b) => {
  5968. for (var prop in b || (b = {}))
  5969. if (__hasOwnProp$3.call(b, prop))
  5970. __defNormalProp$3(a, prop, b[prop]);
  5971. if (__getOwnPropSymbols$3)
  5972. for (var prop of __getOwnPropSymbols$3(b)) {
  5973. if (__propIsEnum$3.call(b, prop))
  5974. __defNormalProp$3(a, prop, b[prop]);
  5975. }
  5976. return a;
  5977. };
  5978. var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
  5979. function useThrottledRefHistory(source, options = {}) {
  5980. const { throttle = 200, trailing = true } = options;
  5981. const filter = throttleFilter(throttle, trailing);
  5982. const history = useRefHistory(source, __spreadProps$1(__spreadValues$3({}, options), { eventFilter: filter }));
  5983. return __spreadValues$3({}, history);
  5984. }
  5985. var __defProp$2 = Object.defineProperty;
  5986. var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
  5987. var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
  5988. var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
  5989. var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  5990. var __spreadValues$2 = (a, b) => {
  5991. for (var prop in b || (b = {}))
  5992. if (__hasOwnProp$2.call(b, prop))
  5993. __defNormalProp$2(a, prop, b[prop]);
  5994. if (__getOwnPropSymbols$2)
  5995. for (var prop of __getOwnPropSymbols$2(b)) {
  5996. if (__propIsEnum$2.call(b, prop))
  5997. __defNormalProp$2(a, prop, b[prop]);
  5998. }
  5999. return a;
  6000. };
  6001. var __objRest = (source, exclude) => {
  6002. var target = {};
  6003. for (var prop in source)
  6004. if (__hasOwnProp$2.call(source, prop) && exclude.indexOf(prop) < 0)
  6005. target[prop] = source[prop];
  6006. if (source != null && __getOwnPropSymbols$2)
  6007. for (var prop of __getOwnPropSymbols$2(source)) {
  6008. if (exclude.indexOf(prop) < 0 && __propIsEnum$2.call(source, prop))
  6009. target[prop] = source[prop];
  6010. }
  6011. return target;
  6012. };
  6013. const DEFAULT_UNITS = [
  6014. { max: 6e4, value: 1e3, name: "second" },
  6015. { max: 276e4, value: 6e4, name: "minute" },
  6016. { max: 72e6, value: 36e5, name: "hour" },
  6017. { max: 5184e5, value: 864e5, name: "day" },
  6018. { max: 24192e5, value: 6048e5, name: "week" },
  6019. { max: 28512e6, value: 2592e6, name: "month" },
  6020. { max: Infinity, value: 31536e6, name: "year" }
  6021. ];
  6022. const DEFAULT_MESSAGES = {
  6023. justNow: "just now",
  6024. past: (n) => n.match(/\d/) ? `${n} ago` : n,
  6025. future: (n) => n.match(/\d/) ? `in ${n}` : n,
  6026. month: (n, past) => n === 1 ? past ? "last month" : "next month" : `${n} month${n > 1 ? "s" : ""}`,
  6027. year: (n, past) => n === 1 ? past ? "last year" : "next year" : `${n} year${n > 1 ? "s" : ""}`,
  6028. day: (n, past) => n === 1 ? past ? "yesterday" : "tomorrow" : `${n} day${n > 1 ? "s" : ""}`,
  6029. week: (n, past) => n === 1 ? past ? "last week" : "next week" : `${n} week${n > 1 ? "s" : ""}`,
  6030. hour: (n) => `${n} hour${n > 1 ? "s" : ""}`,
  6031. minute: (n) => `${n} minute${n > 1 ? "s" : ""}`,
  6032. second: (n) => `${n} second${n > 1 ? "s" : ""}`,
  6033. invalid: ""
  6034. };
  6035. function DEFAULT_FORMATTER(date) {
  6036. return date.toISOString().slice(0, 10);
  6037. }
  6038. function useTimeAgo(time, options = {}) {
  6039. const {
  6040. controls: exposeControls = false,
  6041. updateInterval = 3e4
  6042. } = options;
  6043. const _a = useNow({ interval: updateInterval, controls: true }), { now } = _a, controls = __objRest(_a, ["now"]);
  6044. const timeAgo = computed(() => formatTimeAgo(new Date(toValue(time)), options, toValue(now.value)));
  6045. if (exposeControls) {
  6046. return __spreadValues$2({
  6047. timeAgo
  6048. }, controls);
  6049. } else {
  6050. return timeAgo;
  6051. }
  6052. }
  6053. function formatTimeAgo(from, options = {}, now = Date.now()) {
  6054. var _a;
  6055. const {
  6056. max,
  6057. messages = DEFAULT_MESSAGES,
  6058. fullDateFormatter = DEFAULT_FORMATTER,
  6059. units = DEFAULT_UNITS,
  6060. showSecond = false,
  6061. rounding = "round"
  6062. } = options;
  6063. const roundFn = typeof rounding === "number" ? (n) => +n.toFixed(rounding) : Math[rounding];
  6064. const diff = +now - +from;
  6065. const absDiff = Math.abs(diff);
  6066. function getValue(diff2, unit) {
  6067. return roundFn(Math.abs(diff2) / unit.value);
  6068. }
  6069. function format(diff2, unit) {
  6070. const val = getValue(diff2, unit);
  6071. const past = diff2 > 0;
  6072. const str = applyFormat(unit.name, val, past);
  6073. return applyFormat(past ? "past" : "future", str, past);
  6074. }
  6075. function applyFormat(name, val, isPast) {
  6076. const formatter = messages[name];
  6077. if (typeof formatter === "function")
  6078. return formatter(val, isPast);
  6079. return formatter.replace("{0}", val.toString());
  6080. }
  6081. if (absDiff < 6e4 && !showSecond)
  6082. return messages.justNow;
  6083. if (typeof max === "number" && absDiff > max)
  6084. return fullDateFormatter(new Date(from));
  6085. if (typeof max === "string") {
  6086. const unitMax = (_a = units.find((i) => i.name === max)) == null ? void 0 : _a.max;
  6087. if (unitMax && absDiff > unitMax)
  6088. return fullDateFormatter(new Date(from));
  6089. }
  6090. for (const [idx, unit] of units.entries()) {
  6091. const val = getValue(diff, unit);
  6092. if (val <= 0 && units[idx - 1])
  6093. return format(diff, units[idx - 1]);
  6094. if (absDiff < unit.max)
  6095. return format(diff, unit);
  6096. }
  6097. return messages.invalid;
  6098. }
  6099. function useTimeoutPoll(fn, interval, timeoutPollOptions) {
  6100. const { start } = useTimeoutFn(loop, interval);
  6101. const isActive = ref(false);
  6102. async function loop() {
  6103. if (!isActive.value)
  6104. return;
  6105. await fn();
  6106. start();
  6107. }
  6108. function resume() {
  6109. if (!isActive.value) {
  6110. isActive.value = true;
  6111. loop();
  6112. }
  6113. }
  6114. function pause() {
  6115. isActive.value = false;
  6116. }
  6117. if (timeoutPollOptions == null ? void 0 : timeoutPollOptions.immediate)
  6118. resume();
  6119. tryOnScopeDispose(pause);
  6120. return {
  6121. isActive,
  6122. pause,
  6123. resume
  6124. };
  6125. }
  6126. var __defProp$1 = Object.defineProperty;
  6127. var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
  6128. var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
  6129. var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
  6130. var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  6131. var __spreadValues$1 = (a, b) => {
  6132. for (var prop in b || (b = {}))
  6133. if (__hasOwnProp$1.call(b, prop))
  6134. __defNormalProp$1(a, prop, b[prop]);
  6135. if (__getOwnPropSymbols$1)
  6136. for (var prop of __getOwnPropSymbols$1(b)) {
  6137. if (__propIsEnum$1.call(b, prop))
  6138. __defNormalProp$1(a, prop, b[prop]);
  6139. }
  6140. return a;
  6141. };
  6142. function useTimestamp(options = {}) {
  6143. const {
  6144. controls: exposeControls = false,
  6145. offset = 0,
  6146. immediate = true,
  6147. interval = "requestAnimationFrame",
  6148. callback
  6149. } = options;
  6150. const ts = ref(timestamp() + offset);
  6151. const update = () => ts.value = timestamp() + offset;
  6152. const cb = callback ? () => {
  6153. update();
  6154. callback(ts.value);
  6155. } : update;
  6156. const controls = interval === "requestAnimationFrame" ? useRafFn(cb, { immediate }) : useIntervalFn(cb, interval, { immediate });
  6157. if (exposeControls) {
  6158. return __spreadValues$1({
  6159. timestamp: ts
  6160. }, controls);
  6161. } else {
  6162. return ts;
  6163. }
  6164. }
  6165. function useTitle(newTitle = null, options = {}) {
  6166. var _a, _b;
  6167. const {
  6168. document = defaultDocument
  6169. } = options;
  6170. const title = toRef((_a = newTitle != null ? newTitle : document == null ? void 0 : document.title) != null ? _a : null);
  6171. const isReadonly = newTitle && typeof newTitle === "function";
  6172. function format(t) {
  6173. if (!("titleTemplate" in options))
  6174. return t;
  6175. const template = options.titleTemplate || "%s";
  6176. return typeof template === "function" ? template(t) : toValue(template).replace(/%s/g, t);
  6177. }
  6178. watch(
  6179. title,
  6180. (t, o) => {
  6181. if (t !== o && document)
  6182. document.title = format(typeof t === "string" ? t : "");
  6183. },
  6184. { immediate: true }
  6185. );
  6186. if (options.observe && !options.titleTemplate && document && !isReadonly) {
  6187. useMutationObserver(
  6188. (_b = document.head) == null ? void 0 : _b.querySelector("title"),
  6189. () => {
  6190. if (document && document.title !== title.value)
  6191. title.value = format(document.title);
  6192. },
  6193. { childList: true }
  6194. );
  6195. }
  6196. return title;
  6197. }
  6198. var __defProp = Object.defineProperty;
  6199. var __defProps = Object.defineProperties;
  6200. var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
  6201. var __getOwnPropSymbols = Object.getOwnPropertySymbols;
  6202. var __hasOwnProp = Object.prototype.hasOwnProperty;
  6203. var __propIsEnum = Object.prototype.propertyIsEnumerable;
  6204. var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  6205. var __spreadValues = (a, b) => {
  6206. for (var prop in b || (b = {}))
  6207. if (__hasOwnProp.call(b, prop))
  6208. __defNormalProp(a, prop, b[prop]);
  6209. if (__getOwnPropSymbols)
  6210. for (var prop of __getOwnPropSymbols(b)) {
  6211. if (__propIsEnum.call(b, prop))
  6212. __defNormalProp(a, prop, b[prop]);
  6213. }
  6214. return a;
  6215. };
  6216. var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
  6217. const _TransitionPresets = {
  6218. easeInSine: [0.12, 0, 0.39, 0],
  6219. easeOutSine: [0.61, 1, 0.88, 1],
  6220. easeInOutSine: [0.37, 0, 0.63, 1],
  6221. easeInQuad: [0.11, 0, 0.5, 0],
  6222. easeOutQuad: [0.5, 1, 0.89, 1],
  6223. easeInOutQuad: [0.45, 0, 0.55, 1],
  6224. easeInCubic: [0.32, 0, 0.67, 0],
  6225. easeOutCubic: [0.33, 1, 0.68, 1],
  6226. easeInOutCubic: [0.65, 0, 0.35, 1],
  6227. easeInQuart: [0.5, 0, 0.75, 0],
  6228. easeOutQuart: [0.25, 1, 0.5, 1],
  6229. easeInOutQuart: [0.76, 0, 0.24, 1],
  6230. easeInQuint: [0.64, 0, 0.78, 0],
  6231. easeOutQuint: [0.22, 1, 0.36, 1],
  6232. easeInOutQuint: [0.83, 0, 0.17, 1],
  6233. easeInExpo: [0.7, 0, 0.84, 0],
  6234. easeOutExpo: [0.16, 1, 0.3, 1],
  6235. easeInOutExpo: [0.87, 0, 0.13, 1],
  6236. easeInCirc: [0.55, 0, 1, 0.45],
  6237. easeOutCirc: [0, 0.55, 0.45, 1],
  6238. easeInOutCirc: [0.85, 0, 0.15, 1],
  6239. easeInBack: [0.36, 0, 0.66, -0.56],
  6240. easeOutBack: [0.34, 1.56, 0.64, 1],
  6241. easeInOutBack: [0.68, -0.6, 0.32, 1.6]
  6242. };
  6243. const TransitionPresets = /* @__PURE__ */ Object.assign({}, { linear: identity }, _TransitionPresets);
  6244. function createEasingFunction([p0, p1, p2, p3]) {
  6245. const a = (a1, a2) => 1 - 3 * a2 + 3 * a1;
  6246. const b = (a1, a2) => 3 * a2 - 6 * a1;
  6247. const c = (a1) => 3 * a1;
  6248. const calcBezier = (t, a1, a2) => ((a(a1, a2) * t + b(a1, a2)) * t + c(a1)) * t;
  6249. const getSlope = (t, a1, a2) => 3 * a(a1, a2) * t * t + 2 * b(a1, a2) * t + c(a1);
  6250. const getTforX = (x) => {
  6251. let aGuessT = x;
  6252. for (let i = 0; i < 4; ++i) {
  6253. const currentSlope = getSlope(aGuessT, p0, p2);
  6254. if (currentSlope === 0)
  6255. return aGuessT;
  6256. const currentX = calcBezier(aGuessT, p0, p2) - x;
  6257. aGuessT -= currentX / currentSlope;
  6258. }
  6259. return aGuessT;
  6260. };
  6261. return (x) => p0 === p1 && p2 === p3 ? x : calcBezier(getTforX(x), p1, p3);
  6262. }
  6263. function lerp(a, b, alpha) {
  6264. return a + alpha * (b - a);
  6265. }
  6266. function toVec(t) {
  6267. return (typeof t === "number" ? [t] : t) || [];
  6268. }
  6269. function executeTransition(source, from, to, options = {}) {
  6270. var _a, _b;
  6271. const fromVal = toValue(from);
  6272. const toVal = toValue(to);
  6273. const v1 = toVec(fromVal);
  6274. const v2 = toVec(toVal);
  6275. const duration = (_a = toValue(options.duration)) != null ? _a : 1e3;
  6276. const startedAt = Date.now();
  6277. const endAt = Date.now() + duration;
  6278. const trans = typeof options.transition === "function" ? options.transition : (_b = toValue(options.transition)) != null ? _b : identity;
  6279. const ease = typeof trans === "function" ? trans : createEasingFunction(trans);
  6280. return new Promise((resolve) => {
  6281. source.value = fromVal;
  6282. const tick = () => {
  6283. var _a2;
  6284. if ((_a2 = options.abort) == null ? void 0 : _a2.call(options)) {
  6285. resolve();
  6286. return;
  6287. }
  6288. const now = Date.now();
  6289. const alpha = ease((now - startedAt) / duration);
  6290. const arr = toVec(source.value).map((n, i) => lerp(v1[i], v2[i], alpha));
  6291. if (Array.isArray(source.value))
  6292. source.value = arr.map((n, i) => {
  6293. var _a3, _b2;
  6294. return lerp((_a3 = v1[i]) != null ? _a3 : 0, (_b2 = v2[i]) != null ? _b2 : 0, alpha);
  6295. });
  6296. else if (typeof source.value === "number")
  6297. source.value = arr[0];
  6298. if (now < endAt) {
  6299. requestAnimationFrame(tick);
  6300. } else {
  6301. source.value = toVal;
  6302. resolve();
  6303. }
  6304. };
  6305. tick();
  6306. });
  6307. }
  6308. function useTransition(source, options = {}) {
  6309. let currentId = 0;
  6310. const sourceVal = () => {
  6311. const v = toValue(source);
  6312. return typeof v === "number" ? v : v.map(toValue);
  6313. };
  6314. const outputRef = ref(sourceVal());
  6315. watch(sourceVal, async (to) => {
  6316. var _a, _b;
  6317. if (toValue(options.disabled))
  6318. return;
  6319. const id = ++currentId;
  6320. if (options.delay)
  6321. await promiseTimeout(toValue(options.delay));
  6322. if (id !== currentId)
  6323. return;
  6324. const toVal = Array.isArray(to) ? to.map(toValue) : toValue(to);
  6325. (_a = options.onStarted) == null ? void 0 : _a.call(options);
  6326. await executeTransition(outputRef, outputRef.value, toVal, __spreadProps(__spreadValues({}, options), {
  6327. abort: () => {
  6328. var _a2;
  6329. return id !== currentId || ((_a2 = options.abort) == null ? void 0 : _a2.call(options));
  6330. }
  6331. }));
  6332. (_b = options.onFinished) == null ? void 0 : _b.call(options);
  6333. }, { deep: true });
  6334. watch(() => toValue(options.disabled), (disabled) => {
  6335. if (disabled) {
  6336. currentId++;
  6337. outputRef.value = sourceVal();
  6338. }
  6339. });
  6340. tryOnScopeDispose(() => {
  6341. currentId++;
  6342. });
  6343. return computed(() => toValue(options.disabled) ? sourceVal() : outputRef.value);
  6344. }
  6345. function useUrlSearchParams(mode = "history", options = {}) {
  6346. const {
  6347. initialValue = {},
  6348. removeNullishValues = true,
  6349. removeFalsyValues = false,
  6350. write: enableWrite = true,
  6351. window = defaultWindow
  6352. } = options;
  6353. if (!window)
  6354. return reactive(initialValue);
  6355. const state = reactive({});
  6356. function getRawParams() {
  6357. if (mode === "history") {
  6358. return window.location.search || "";
  6359. } else if (mode === "hash") {
  6360. const hash = window.location.hash || "";
  6361. const index = hash.indexOf("?");
  6362. return index > 0 ? hash.slice(index) : "";
  6363. } else {
  6364. return (window.location.hash || "").replace(/^#/, "");
  6365. }
  6366. }
  6367. function constructQuery(params) {
  6368. const stringified = params.toString();
  6369. if (mode === "history")
  6370. return `${stringified ? `?${stringified}` : ""}${window.location.hash || ""}`;
  6371. if (mode === "hash-params")
  6372. return `${window.location.search || ""}${stringified ? `#${stringified}` : ""}`;
  6373. const hash = window.location.hash || "#";
  6374. const index = hash.indexOf("?");
  6375. if (index > 0)
  6376. return `${hash.slice(0, index)}${stringified ? `?${stringified}` : ""}`;
  6377. return `${hash}${stringified ? `?${stringified}` : ""}`;
  6378. }
  6379. function read() {
  6380. return new URLSearchParams(getRawParams());
  6381. }
  6382. function updateState(params) {
  6383. const unusedKeys = new Set(Object.keys(state));
  6384. for (const key of params.keys()) {
  6385. const paramsForKey = params.getAll(key);
  6386. state[key] = paramsForKey.length > 1 ? paramsForKey : params.get(key) || "";
  6387. unusedKeys.delete(key);
  6388. }
  6389. Array.from(unusedKeys).forEach((key) => delete state[key]);
  6390. }
  6391. const { pause, resume } = pausableWatch(
  6392. state,
  6393. () => {
  6394. const params = new URLSearchParams("");
  6395. Object.keys(state).forEach((key) => {
  6396. const mapEntry = state[key];
  6397. if (Array.isArray(mapEntry))
  6398. mapEntry.forEach((value) => params.append(key, value));
  6399. else if (removeNullishValues && mapEntry == null)
  6400. params.delete(key);
  6401. else if (removeFalsyValues && !mapEntry)
  6402. params.delete(key);
  6403. else
  6404. params.set(key, mapEntry);
  6405. });
  6406. write(params);
  6407. },
  6408. { deep: true }
  6409. );
  6410. function write(params, shouldUpdate) {
  6411. pause();
  6412. if (shouldUpdate)
  6413. updateState(params);
  6414. window.history.replaceState(
  6415. window.history.state,
  6416. window.document.title,
  6417. window.location.pathname + constructQuery(params)
  6418. );
  6419. resume();
  6420. }
  6421. function onChanged() {
  6422. if (!enableWrite)
  6423. return;
  6424. write(read(), true);
  6425. }
  6426. useEventListener(window, "popstate", onChanged, false);
  6427. if (mode !== "history")
  6428. useEventListener(window, "hashchange", onChanged, false);
  6429. const initial = read();
  6430. if (initial.keys().next().value)
  6431. updateState(initial);
  6432. else
  6433. Object.assign(state, initialValue);
  6434. return state;
  6435. }
  6436. function useUserMedia(options = {}) {
  6437. var _a, _b;
  6438. const enabled = ref((_a = options.enabled) != null ? _a : false);
  6439. const autoSwitch = ref((_b = options.autoSwitch) != null ? _b : true);
  6440. const constraints = ref(options.constraints);
  6441. const { navigator = defaultNavigator } = options;
  6442. const isSupported = useSupported(() => {
  6443. var _a2;
  6444. return (_a2 = navigator == null ? void 0 : navigator.mediaDevices) == null ? void 0 : _a2.getUserMedia;
  6445. });
  6446. const stream = shallowRef();
  6447. function getDeviceOptions(type) {
  6448. switch (type) {
  6449. case "video": {
  6450. if (constraints.value)
  6451. return constraints.value.video || false;
  6452. break;
  6453. }
  6454. case "audio": {
  6455. if (constraints.value)
  6456. return constraints.value.audio || false;
  6457. break;
  6458. }
  6459. }
  6460. }
  6461. async function _start() {
  6462. if (!isSupported.value || stream.value)
  6463. return;
  6464. stream.value = await navigator.mediaDevices.getUserMedia({
  6465. video: getDeviceOptions("video"),
  6466. audio: getDeviceOptions("audio")
  6467. });
  6468. return stream.value;
  6469. }
  6470. function _stop() {
  6471. var _a2;
  6472. (_a2 = stream.value) == null ? void 0 : _a2.getTracks().forEach((t) => t.stop());
  6473. stream.value = void 0;
  6474. }
  6475. function stop() {
  6476. _stop();
  6477. enabled.value = false;
  6478. }
  6479. async function start() {
  6480. await _start();
  6481. if (stream.value)
  6482. enabled.value = true;
  6483. return stream.value;
  6484. }
  6485. async function restart() {
  6486. _stop();
  6487. return await start();
  6488. }
  6489. watch(
  6490. enabled,
  6491. (v) => {
  6492. if (v)
  6493. _start();
  6494. else
  6495. _stop();
  6496. },
  6497. { immediate: true }
  6498. );
  6499. watch(
  6500. constraints,
  6501. () => {
  6502. if (autoSwitch.value && stream.value)
  6503. restart();
  6504. },
  6505. { immediate: true }
  6506. );
  6507. return {
  6508. isSupported,
  6509. stream,
  6510. start,
  6511. stop,
  6512. restart,
  6513. constraints,
  6514. enabled,
  6515. autoSwitch
  6516. };
  6517. }
  6518. function useVModel(props, key, emit, options = {}) {
  6519. var _a, _b, _c, _d, _e;
  6520. const {
  6521. clone = false,
  6522. passive = false,
  6523. eventName,
  6524. deep = false,
  6525. defaultValue,
  6526. shouldEmit
  6527. } = options;
  6528. const vm = getCurrentInstance();
  6529. const _emit = emit || (vm == null ? void 0 : vm.emit) || ((_a = vm == null ? void 0 : vm.$emit) == null ? void 0 : _a.bind(vm)) || ((_c = (_b = vm == null ? void 0 : vm.proxy) == null ? void 0 : _b.$emit) == null ? void 0 : _c.bind(vm == null ? void 0 : vm.proxy));
  6530. let event = eventName;
  6531. if (!key) {
  6532. if (isVue2) {
  6533. const modelOptions = (_e = (_d = vm == null ? void 0 : vm.proxy) == null ? void 0 : _d.$options) == null ? void 0 : _e.model;
  6534. key = (modelOptions == null ? void 0 : modelOptions.value) || "value";
  6535. if (!eventName)
  6536. event = (modelOptions == null ? void 0 : modelOptions.event) || "input";
  6537. } else {
  6538. key = "modelValue";
  6539. }
  6540. }
  6541. event = eventName || event || `update:${key.toString()}`;
  6542. const cloneFn = (val) => !clone ? val : typeof clone === "function" ? clone(val) : cloneFnJSON(val);
  6543. const getValue = () => isDef(props[key]) ? cloneFn(props[key]) : defaultValue;
  6544. const triggerEmit = (value) => {
  6545. if (shouldEmit) {
  6546. if (shouldEmit(value))
  6547. _emit(event, value);
  6548. } else {
  6549. _emit(event, value);
  6550. }
  6551. };
  6552. if (passive) {
  6553. const initialValue = getValue();
  6554. const proxy = ref(initialValue);
  6555. watch(
  6556. () => props[key],
  6557. (v) => proxy.value = cloneFn(v)
  6558. );
  6559. watch(
  6560. proxy,
  6561. (v) => {
  6562. if (v !== props[key] || deep)
  6563. triggerEmit(v);
  6564. },
  6565. { deep }
  6566. );
  6567. return proxy;
  6568. } else {
  6569. return computed({
  6570. get() {
  6571. return getValue();
  6572. },
  6573. set(value) {
  6574. triggerEmit(value);
  6575. }
  6576. });
  6577. }
  6578. }
  6579. function useVModels(props, emit, options = {}) {
  6580. const ret = {};
  6581. for (const key in props)
  6582. ret[key] = useVModel(props, key, emit, options);
  6583. return ret;
  6584. }
  6585. function useVibrate(options) {
  6586. const {
  6587. pattern = [],
  6588. interval = 0,
  6589. navigator = defaultNavigator
  6590. } = options || {};
  6591. const isSupported = useSupported(() => typeof navigator !== "undefined" && "vibrate" in navigator);
  6592. const patternRef = toRef(pattern);
  6593. let intervalControls;
  6594. const vibrate = (pattern2 = patternRef.value) => {
  6595. if (isSupported.value)
  6596. navigator.vibrate(pattern2);
  6597. };
  6598. const stop = () => {
  6599. if (isSupported.value)
  6600. navigator.vibrate(0);
  6601. intervalControls == null ? void 0 : intervalControls.pause();
  6602. };
  6603. if (interval > 0) {
  6604. intervalControls = useIntervalFn(
  6605. vibrate,
  6606. interval,
  6607. {
  6608. immediate: false,
  6609. immediateCallback: false
  6610. }
  6611. );
  6612. }
  6613. return {
  6614. isSupported,
  6615. pattern,
  6616. intervalControls,
  6617. vibrate,
  6618. stop
  6619. };
  6620. }
  6621. function useVirtualList(list, options) {
  6622. const { containerStyle, wrapperProps, scrollTo, calculateRange, currentList, containerRef } = "itemHeight" in options ? useVerticalVirtualList(options, list) : useHorizontalVirtualList(options, list);
  6623. return {
  6624. list: currentList,
  6625. scrollTo,
  6626. containerProps: {
  6627. ref: containerRef,
  6628. onScroll: () => {
  6629. calculateRange();
  6630. },
  6631. style: containerStyle
  6632. },
  6633. wrapperProps
  6634. };
  6635. }
  6636. function useVirtualListResources(list) {
  6637. const containerRef = ref(null);
  6638. const size = useElementSize(containerRef);
  6639. const currentList = ref([]);
  6640. const source = shallowRef(list);
  6641. const state = ref({ start: 0, end: 10 });
  6642. return { state, source, currentList, size, containerRef };
  6643. }
  6644. function createGetViewCapacity(state, source, itemSize) {
  6645. return (containerSize) => {
  6646. if (typeof itemSize === "number")
  6647. return Math.ceil(containerSize / itemSize);
  6648. const { start = 0 } = state.value;
  6649. let sum = 0;
  6650. let capacity = 0;
  6651. for (let i = start; i < source.value.length; i++) {
  6652. const size = itemSize(i);
  6653. sum += size;
  6654. capacity = i;
  6655. if (sum > containerSize)
  6656. break;
  6657. }
  6658. return capacity - start;
  6659. };
  6660. }
  6661. function createGetOffset(source, itemSize) {
  6662. return (scrollDirection) => {
  6663. if (typeof itemSize === "number")
  6664. return Math.floor(scrollDirection / itemSize) + 1;
  6665. let sum = 0;
  6666. let offset = 0;
  6667. for (let i = 0; i < source.value.length; i++) {
  6668. const size = itemSize(i);
  6669. sum += size;
  6670. if (sum >= scrollDirection) {
  6671. offset = i;
  6672. break;
  6673. }
  6674. }
  6675. return offset + 1;
  6676. };
  6677. }
  6678. function createCalculateRange(type, overscan, getOffset, getViewCapacity, { containerRef, state, currentList, source }) {
  6679. return () => {
  6680. const element = containerRef.value;
  6681. if (element) {
  6682. const offset = getOffset(type === "vertical" ? element.scrollTop : element.scrollLeft);
  6683. const viewCapacity = getViewCapacity(type === "vertical" ? element.clientHeight : element.clientWidth);
  6684. const from = offset - overscan;
  6685. const to = offset + viewCapacity + overscan;
  6686. state.value = {
  6687. start: from < 0 ? 0 : from,
  6688. end: to > source.value.length ? source.value.length : to
  6689. };
  6690. currentList.value = source.value.slice(state.value.start, state.value.end).map((ele, index) => ({
  6691. data: ele,
  6692. index: index + state.value.start
  6693. }));
  6694. }
  6695. };
  6696. }
  6697. function createGetDistance(itemSize, source) {
  6698. return (index) => {
  6699. if (typeof itemSize === "number") {
  6700. const size2 = index * itemSize;
  6701. return size2;
  6702. }
  6703. const size = source.value.slice(0, index).reduce((sum, _, i) => sum + itemSize(i), 0);
  6704. return size;
  6705. };
  6706. }
  6707. function useWatchForSizes(size, list, calculateRange) {
  6708. watch([size.width, size.height, list], () => {
  6709. calculateRange();
  6710. });
  6711. }
  6712. function createComputedTotalSize(itemSize, source) {
  6713. return computed(() => {
  6714. if (typeof itemSize === "number")
  6715. return source.value.length * itemSize;
  6716. return source.value.reduce((sum, _, index) => sum + itemSize(index), 0);
  6717. });
  6718. }
  6719. const scrollToDictionaryForElementScrollKey = {
  6720. horizontal: "scrollLeft",
  6721. vertical: "scrollTop"
  6722. };
  6723. function createScrollTo(type, calculateRange, getDistance, containerRef) {
  6724. return (index) => {
  6725. if (containerRef.value) {
  6726. containerRef.value[scrollToDictionaryForElementScrollKey[type]] = getDistance(index);
  6727. calculateRange();
  6728. }
  6729. };
  6730. }
  6731. function useHorizontalVirtualList(options, list) {
  6732. const resources = useVirtualListResources(list);
  6733. const { state, source, currentList, size, containerRef } = resources;
  6734. const containerStyle = { overflowX: "auto" };
  6735. const { itemWidth, overscan = 5 } = options;
  6736. const getViewCapacity = createGetViewCapacity(state, source, itemWidth);
  6737. const getOffset = createGetOffset(source, itemWidth);
  6738. const calculateRange = createCalculateRange("horizontal", overscan, getOffset, getViewCapacity, resources);
  6739. const getDistanceLeft = createGetDistance(itemWidth, source);
  6740. const offsetLeft = computed(() => getDistanceLeft(state.value.start));
  6741. const totalWidth = createComputedTotalSize(itemWidth, source);
  6742. useWatchForSizes(size, list, calculateRange);
  6743. const scrollTo = createScrollTo("horizontal", calculateRange, getDistanceLeft, containerRef);
  6744. const wrapperProps = computed(() => {
  6745. return {
  6746. style: {
  6747. height: "100%",
  6748. width: `${totalWidth.value - offsetLeft.value}px`,
  6749. marginLeft: `${offsetLeft.value}px`,
  6750. display: "flex"
  6751. }
  6752. };
  6753. });
  6754. return {
  6755. scrollTo,
  6756. calculateRange,
  6757. wrapperProps,
  6758. containerStyle,
  6759. currentList,
  6760. containerRef
  6761. };
  6762. }
  6763. function useVerticalVirtualList(options, list) {
  6764. const resources = useVirtualListResources(list);
  6765. const { state, source, currentList, size, containerRef } = resources;
  6766. const containerStyle = { overflowY: "auto" };
  6767. const { itemHeight, overscan = 5 } = options;
  6768. const getViewCapacity = createGetViewCapacity(state, source, itemHeight);
  6769. const getOffset = createGetOffset(source, itemHeight);
  6770. const calculateRange = createCalculateRange("vertical", overscan, getOffset, getViewCapacity, resources);
  6771. const getDistanceTop = createGetDistance(itemHeight, source);
  6772. const offsetTop = computed(() => getDistanceTop(state.value.start));
  6773. const totalHeight = createComputedTotalSize(itemHeight, source);
  6774. useWatchForSizes(size, list, calculateRange);
  6775. const scrollTo = createScrollTo("vertical", calculateRange, getDistanceTop, containerRef);
  6776. const wrapperProps = computed(() => {
  6777. return {
  6778. style: {
  6779. width: "100%",
  6780. height: `${totalHeight.value - offsetTop.value}px`,
  6781. marginTop: `${offsetTop.value}px`
  6782. }
  6783. };
  6784. });
  6785. return {
  6786. calculateRange,
  6787. scrollTo,
  6788. containerStyle,
  6789. wrapperProps,
  6790. currentList,
  6791. containerRef
  6792. };
  6793. }
  6794. function useWakeLock(options = {}) {
  6795. const {
  6796. navigator = defaultNavigator,
  6797. document = defaultDocument
  6798. } = options;
  6799. let wakeLock;
  6800. const isSupported = useSupported(() => navigator && "wakeLock" in navigator);
  6801. const isActive = ref(false);
  6802. async function onVisibilityChange() {
  6803. if (!isSupported.value || !wakeLock)
  6804. return;
  6805. if (document && document.visibilityState === "visible")
  6806. wakeLock = await navigator.wakeLock.request("screen");
  6807. isActive.value = !wakeLock.released;
  6808. }
  6809. if (document)
  6810. useEventListener(document, "visibilitychange", onVisibilityChange, { passive: true });
  6811. async function request(type) {
  6812. if (!isSupported.value)
  6813. return;
  6814. wakeLock = await navigator.wakeLock.request(type);
  6815. isActive.value = !wakeLock.released;
  6816. }
  6817. async function release() {
  6818. if (!isSupported.value || !wakeLock)
  6819. return;
  6820. await wakeLock.release();
  6821. isActive.value = !wakeLock.released;
  6822. wakeLock = null;
  6823. }
  6824. return {
  6825. isSupported,
  6826. isActive,
  6827. request,
  6828. release
  6829. };
  6830. }
  6831. function useWebNotification(defaultOptions = {}) {
  6832. const {
  6833. window = defaultWindow
  6834. } = defaultOptions;
  6835. const isSupported = useSupported(() => !!window && "Notification" in window);
  6836. const notification = ref(null);
  6837. const requestPermission = async () => {
  6838. if (!isSupported.value)
  6839. return;
  6840. if ("permission" in Notification && Notification.permission !== "denied")
  6841. await Notification.requestPermission();
  6842. };
  6843. const { on: onClick, trigger: clickTrigger } = createEventHook();
  6844. const { on: onShow, trigger: showTrigger } = createEventHook();
  6845. const { on: onError, trigger: errorTrigger } = createEventHook();
  6846. const { on: onClose, trigger: closeTrigger } = createEventHook();
  6847. const show = async (overrides) => {
  6848. if (!isSupported.value)
  6849. return;
  6850. await requestPermission();
  6851. const options = Object.assign({}, defaultOptions, overrides);
  6852. notification.value = new Notification(options.title || "", options);
  6853. notification.value.onclick = clickTrigger;
  6854. notification.value.onshow = showTrigger;
  6855. notification.value.onerror = errorTrigger;
  6856. notification.value.onclose = closeTrigger;
  6857. return notification.value;
  6858. };
  6859. const close = () => {
  6860. if (notification.value)
  6861. notification.value.close();
  6862. notification.value = null;
  6863. };
  6864. tryOnMounted(async () => {
  6865. if (isSupported.value)
  6866. await requestPermission();
  6867. });
  6868. tryOnScopeDispose(close);
  6869. if (isSupported.value && window) {
  6870. const document = window.document;
  6871. useEventListener(document, "visibilitychange", (e) => {
  6872. e.preventDefault();
  6873. if (document.visibilityState === "visible") {
  6874. close();
  6875. }
  6876. });
  6877. }
  6878. return {
  6879. isSupported,
  6880. notification,
  6881. show,
  6882. close,
  6883. onClick,
  6884. onShow,
  6885. onError,
  6886. onClose
  6887. };
  6888. }
  6889. const DEFAULT_PING_MESSAGE = "ping";
  6890. function resolveNestedOptions(options) {
  6891. if (options === true)
  6892. return {};
  6893. return options;
  6894. }
  6895. function useWebSocket(url, options = {}) {
  6896. const {
  6897. onConnected,
  6898. onDisconnected,
  6899. onError,
  6900. onMessage,
  6901. immediate = true,
  6902. autoClose = true,
  6903. protocols = []
  6904. } = options;
  6905. const data = ref(null);
  6906. const status = ref("CLOSED");
  6907. const wsRef = ref();
  6908. const urlRef = toRef(url);
  6909. let heartbeatPause;
  6910. let heartbeatResume;
  6911. let explicitlyClosed = false;
  6912. let retried = 0;
  6913. let bufferedData = [];
  6914. let pongTimeoutWait;
  6915. const close = (code = 1e3, reason) => {
  6916. if (!wsRef.value)
  6917. return;
  6918. explicitlyClosed = true;
  6919. heartbeatPause == null ? void 0 : heartbeatPause();
  6920. wsRef.value.close(code, reason);
  6921. };
  6922. const _sendBuffer = () => {
  6923. if (bufferedData.length && wsRef.value && status.value === "OPEN") {
  6924. for (const buffer of bufferedData)
  6925. wsRef.value.send(buffer);
  6926. bufferedData = [];
  6927. }
  6928. };
  6929. const resetHeartbeat = () => {
  6930. clearTimeout(pongTimeoutWait);
  6931. pongTimeoutWait = void 0;
  6932. };
  6933. const send = (data2, useBuffer = true) => {
  6934. if (!wsRef.value || status.value !== "OPEN") {
  6935. if (useBuffer)
  6936. bufferedData.push(data2);
  6937. return false;
  6938. }
  6939. _sendBuffer();
  6940. wsRef.value.send(data2);
  6941. return true;
  6942. };
  6943. const _init = () => {
  6944. if (explicitlyClosed || typeof urlRef.value === "undefined")
  6945. return;
  6946. const ws = new WebSocket(urlRef.value, protocols);
  6947. wsRef.value = ws;
  6948. status.value = "CONNECTING";
  6949. ws.onopen = () => {
  6950. status.value = "OPEN";
  6951. onConnected == null ? void 0 : onConnected(ws);
  6952. heartbeatResume == null ? void 0 : heartbeatResume();
  6953. _sendBuffer();
  6954. };
  6955. ws.onclose = (ev) => {
  6956. status.value = "CLOSED";
  6957. wsRef.value = void 0;
  6958. onDisconnected == null ? void 0 : onDisconnected(ws, ev);
  6959. if (!explicitlyClosed && options.autoReconnect) {
  6960. const {
  6961. retries = -1,
  6962. delay = 1e3,
  6963. onFailed
  6964. } = resolveNestedOptions(options.autoReconnect);
  6965. retried += 1;
  6966. if (typeof retries === "number" && (retries < 0 || retried < retries))
  6967. setTimeout(_init, delay);
  6968. else if (typeof retries === "function" && retries())
  6969. setTimeout(_init, delay);
  6970. else
  6971. onFailed == null ? void 0 : onFailed();
  6972. }
  6973. };
  6974. ws.onerror = (e) => {
  6975. onError == null ? void 0 : onError(ws, e);
  6976. };
  6977. ws.onmessage = (e) => {
  6978. if (options.heartbeat) {
  6979. resetHeartbeat();
  6980. const {
  6981. message = DEFAULT_PING_MESSAGE
  6982. } = resolveNestedOptions(options.heartbeat);
  6983. if (e.data === message)
  6984. return;
  6985. }
  6986. data.value = e.data;
  6987. onMessage == null ? void 0 : onMessage(ws, e);
  6988. };
  6989. };
  6990. if (options.heartbeat) {
  6991. const {
  6992. message = DEFAULT_PING_MESSAGE,
  6993. interval = 1e3,
  6994. pongTimeout = 1e3
  6995. } = resolveNestedOptions(options.heartbeat);
  6996. const { pause, resume } = useIntervalFn(
  6997. () => {
  6998. send(message, false);
  6999. if (pongTimeoutWait != null)
  7000. return;
  7001. pongTimeoutWait = setTimeout(() => {
  7002. close();
  7003. }, pongTimeout);
  7004. },
  7005. interval,
  7006. { immediate: false }
  7007. );
  7008. heartbeatPause = pause;
  7009. heartbeatResume = resume;
  7010. }
  7011. if (autoClose) {
  7012. useEventListener(window, "beforeunload", () => close());
  7013. tryOnScopeDispose(close);
  7014. }
  7015. const open = () => {
  7016. close();
  7017. explicitlyClosed = false;
  7018. retried = 0;
  7019. _init();
  7020. };
  7021. if (immediate)
  7022. watch(urlRef, open, { immediate: true });
  7023. return {
  7024. data,
  7025. status,
  7026. close,
  7027. send,
  7028. open,
  7029. ws: wsRef
  7030. };
  7031. }
  7032. function useWebWorker(arg0, workerOptions, options) {
  7033. const {
  7034. window = defaultWindow
  7035. } = options != null ? options : {};
  7036. const data = ref(null);
  7037. const worker = shallowRef();
  7038. const post = function post2(val) {
  7039. if (!worker.value)
  7040. return;
  7041. worker.value.postMessage(val);
  7042. };
  7043. const terminate = function terminate2() {
  7044. if (!worker.value)
  7045. return;
  7046. worker.value.terminate();
  7047. };
  7048. if (window) {
  7049. if (typeof arg0 === "string")
  7050. worker.value = new Worker(arg0, workerOptions);
  7051. else if (typeof arg0 === "function")
  7052. worker.value = arg0();
  7053. else
  7054. worker.value = arg0;
  7055. worker.value.onmessage = (e) => {
  7056. data.value = e.data;
  7057. };
  7058. tryOnScopeDispose(() => {
  7059. if (worker.value)
  7060. worker.value.terminate();
  7061. });
  7062. }
  7063. return {
  7064. data,
  7065. post,
  7066. terminate,
  7067. worker
  7068. };
  7069. }
  7070. function jobRunner(userFunc) {
  7071. return (e) => {
  7072. const userFuncArgs = e.data[0];
  7073. return Promise.resolve(userFunc.apply(void 0, userFuncArgs)).then((result) => {
  7074. postMessage(["SUCCESS", result]);
  7075. }).catch((error) => {
  7076. postMessage(["ERROR", error]);
  7077. });
  7078. };
  7079. }
  7080. function depsParser(deps) {
  7081. if (deps.length === 0)
  7082. return "";
  7083. const depsString = deps.map((dep) => `'${dep}'`).toString();
  7084. return `importScripts(${depsString})`;
  7085. }
  7086. function createWorkerBlobUrl(fn, deps) {
  7087. const blobCode = `${depsParser(deps)}; onmessage=(${jobRunner})(${fn})`;
  7088. const blob = new Blob([blobCode], { type: "text/javascript" });
  7089. const url = URL.createObjectURL(blob);
  7090. return url;
  7091. }
  7092. function useWebWorkerFn(fn, options = {}) {
  7093. const {
  7094. dependencies = [],
  7095. timeout,
  7096. window = defaultWindow
  7097. } = options;
  7098. const worker = ref();
  7099. const workerStatus = ref("PENDING");
  7100. const promise = ref({});
  7101. const timeoutId = ref();
  7102. const workerTerminate = (status = "PENDING") => {
  7103. if (worker.value && worker.value._url && window) {
  7104. worker.value.terminate();
  7105. URL.revokeObjectURL(worker.value._url);
  7106. promise.value = {};
  7107. worker.value = void 0;
  7108. window.clearTimeout(timeoutId.value);
  7109. workerStatus.value = status;
  7110. }
  7111. };
  7112. workerTerminate();
  7113. tryOnScopeDispose(workerTerminate);
  7114. const generateWorker = () => {
  7115. const blobUrl = createWorkerBlobUrl(fn, dependencies);
  7116. const newWorker = new Worker(blobUrl);
  7117. newWorker._url = blobUrl;
  7118. newWorker.onmessage = (e) => {
  7119. const { resolve = () => {
  7120. }, reject = () => {
  7121. } } = promise.value;
  7122. const [status, result] = e.data;
  7123. switch (status) {
  7124. case "SUCCESS":
  7125. resolve(result);
  7126. workerTerminate(status);
  7127. break;
  7128. default:
  7129. reject(result);
  7130. workerTerminate("ERROR");
  7131. break;
  7132. }
  7133. };
  7134. newWorker.onerror = (e) => {
  7135. const { reject = () => {
  7136. } } = promise.value;
  7137. reject(e);
  7138. workerTerminate("ERROR");
  7139. };
  7140. if (timeout) {
  7141. timeoutId.value = setTimeout(
  7142. () => workerTerminate("TIMEOUT_EXPIRED"),
  7143. timeout
  7144. );
  7145. }
  7146. return newWorker;
  7147. };
  7148. const callWorker = (...fnArgs) => new Promise((resolve, reject) => {
  7149. promise.value = {
  7150. resolve,
  7151. reject
  7152. };
  7153. worker.value && worker.value.postMessage([[...fnArgs]]);
  7154. workerStatus.value = "RUNNING";
  7155. });
  7156. const workerFn = (...fnArgs) => {
  7157. if (workerStatus.value === "RUNNING") {
  7158. console.error(
  7159. "[useWebWorkerFn] You can only run one instance of the worker at a time."
  7160. );
  7161. return Promise.reject();
  7162. }
  7163. worker.value = generateWorker();
  7164. return callWorker(...fnArgs);
  7165. };
  7166. return {
  7167. workerFn,
  7168. workerStatus,
  7169. workerTerminate
  7170. };
  7171. }
  7172. function useWindowFocus({ window = defaultWindow } = {}) {
  7173. if (!window)
  7174. return ref(false);
  7175. const focused = ref(window.document.hasFocus());
  7176. useEventListener(window, "blur", () => {
  7177. focused.value = false;
  7178. });
  7179. useEventListener(window, "focus", () => {
  7180. focused.value = true;
  7181. });
  7182. return focused;
  7183. }
  7184. function useWindowScroll({ window = defaultWindow } = {}) {
  7185. if (!window) {
  7186. return {
  7187. x: ref(0),
  7188. y: ref(0)
  7189. };
  7190. }
  7191. const x = ref(window.scrollX);
  7192. const y = ref(window.scrollY);
  7193. useEventListener(
  7194. window,
  7195. "scroll",
  7196. () => {
  7197. x.value = window.scrollX;
  7198. y.value = window.scrollY;
  7199. },
  7200. {
  7201. capture: false,
  7202. passive: true
  7203. }
  7204. );
  7205. return { x, y };
  7206. }
  7207. function useWindowSize(options = {}) {
  7208. const {
  7209. window = defaultWindow,
  7210. initialWidth = Infinity,
  7211. initialHeight = Infinity,
  7212. listenOrientation = true,
  7213. includeScrollbar = true
  7214. } = options;
  7215. const width = ref(initialWidth);
  7216. const height = ref(initialHeight);
  7217. const update = () => {
  7218. if (window) {
  7219. if (includeScrollbar) {
  7220. width.value = window.innerWidth;
  7221. height.value = window.innerHeight;
  7222. } else {
  7223. width.value = window.document.documentElement.clientWidth;
  7224. height.value = window.document.documentElement.clientHeight;
  7225. }
  7226. }
  7227. };
  7228. update();
  7229. tryOnMounted(update);
  7230. useEventListener("resize", update, { passive: true });
  7231. if (listenOrientation) {
  7232. const matches = useMediaQuery("(orientation: portrait)");
  7233. watch(matches, () => update());
  7234. }
  7235. return { width, height };
  7236. }
  7237. export { DefaultMagicKeysAliasMap, StorageSerializers, TransitionPresets, computedAsync as asyncComputed, breakpointsAntDesign, breakpointsBootstrapV5, breakpointsMasterCss, breakpointsQuasar, breakpointsSematic, breakpointsTailwind, breakpointsVuetify, cloneFnJSON, computedAsync, computedInject, createFetch, createReusableTemplate, createTemplatePromise, createUnrefFn, customStorageEventName, defaultDocument, defaultLocation, defaultNavigator, defaultWindow, executeTransition, formatTimeAgo, getSSRHandler, mapGamepadToXbox360Controller, onClickOutside, onKeyDown, onKeyPressed, onKeyStroke, onKeyUp, onLongPress, onStartTyping, setSSRHandler, templateRef, unrefElement, useActiveElement, useAnimate, useAsyncQueue, useAsyncState, useBase64, useBattery, useBluetooth, useBreakpoints, useBroadcastChannel, useBrowserLocation, useCached, useClipboard, useCloned, useColorMode, useConfirmDialog, useCssVar, useCurrentElement, useCycleList, useDark, useDebouncedRefHistory, useDeviceMotion, useDeviceOrientation, useDevicePixelRatio, useDevicesList, useDisplayMedia, useDocumentVisibility, useDraggable, useDropZone, useElementBounding, useElementByPoint, useElementHover, useElementSize, useElementVisibility, useEventBus, useEventListener, useEventSource, useEyeDropper, useFavicon, useFetch, useFileDialog, useFileSystemAccess, useFocus, useFocusWithin, useFps, useFullscreen, useGamepad, useGeolocation, useIdle, useImage, useInfiniteScroll, useIntersectionObserver, useKeyModifier, useLocalStorage, useMagicKeys, useManualRefHistory, useMediaControls, useMediaQuery, useMemoize, useMemory, useMounted, useMouse, useMouseInElement, useMousePressed, useMutationObserver, useNavigatorLanguage, useNetwork, useNow, useObjectUrl, useOffsetPagination, useOnline, usePageLeave, useParallax, useParentElement, usePerformanceObserver, usePermission, usePointer, usePointerLock, usePointerSwipe, usePreferredColorScheme, usePreferredContrast, usePreferredDark, usePreferredLanguages, usePreferredReducedMotion, usePrevious, useRafFn, useRefHistory, useResizeObserver, useScreenOrientation, useScreenSafeArea, useScriptTag, useScroll, useScrollLock, useSessionStorage, useShare, useSorted, useSpeechRecognition, useSpeechSynthesis, useStepper, useStorage, useStorageAsync, useStyleTag, useSupported, useSwipe, useTemplateRefsList, useTextDirection, useTextSelection, useTextareaAutosize, useThrottledRefHistory, useTimeAgo, useTimeoutPoll, useTimestamp, useTitle, useTransition, useUrlSearchParams, useUserMedia, useVModel, useVModels, useVibrate, useVirtualList, useWakeLock, useWebNotification, useWebSocket, useWebWorker, useWebWorkerFn, useWindowFocus, useWindowScroll, useWindowSize };