vant.es.js 418 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161
  1. import { useWindowSize, useRect, useChildren, useParent, onMountedOrActivated, getScrollParent, useEventListener, CUSTOM_FIELD_INJECTION_KEY, useCustomFieldValue, useToggle, raf, useScrollParent, usePageVisibility, doubleRaf, cancelRaf, useCountDown, useClickAway, inBrowser as inBrowser$1 } from "@vant/use";
  2. import { unref, ref, reactive, inject, watch, onMounted, nextTick, createVNode, defineComponent, getCurrentInstance, computed, provide, watchEffect, mergeProps, onDeactivated, onBeforeUnmount, Transition, withDirectives, vShow, onActivated, Teleport, Fragment, createTextVNode, createApp, onUnmounted, onBeforeUpdate, resolveDirective, withKeys, onUpdated, h } from "vue";
  3. import { offsetModifier, createPopper } from "@vant/popperjs";
  4. const isDef = (val) => val !== void 0 && val !== null;
  5. const isFunction = (val) => typeof val === "function";
  6. const isObject = (val) => val !== null && typeof val === "object";
  7. const isPromise = (val) => isObject(val) && isFunction(val.then) && isFunction(val.catch);
  8. const isDate = (val) => Object.prototype.toString.call(val) === "[object Date]" && !Number.isNaN(val.getTime());
  9. function isMobile(value) {
  10. value = value.replace(/[^-|\d]/g, "");
  11. return /^((\+86)|(86))?(1)\d{10}$/.test(value) || /^0[0-9-]{10,13}$/.test(value);
  12. }
  13. const isNumeric = (val) => typeof val === "number" || /^\d+(\.\d+)?$/.test(val);
  14. const isIOS$1 = () => inBrowser ? /ios|iphone|ipad|ipod/.test(navigator.userAgent.toLowerCase()) : false;
  15. function noop() {
  16. }
  17. const extend = Object.assign;
  18. const inBrowser = typeof window !== "undefined";
  19. function get(object, path) {
  20. const keys = path.split(".");
  21. let result = object;
  22. keys.forEach((key) => {
  23. var _a;
  24. result = isObject(result) ? (_a = result[key]) != null ? _a : "" : "";
  25. });
  26. return result;
  27. }
  28. function pick(obj, keys, ignoreUndefined) {
  29. return keys.reduce((ret, key) => {
  30. if (!ignoreUndefined || obj[key] !== void 0) {
  31. ret[key] = obj[key];
  32. }
  33. return ret;
  34. }, {});
  35. }
  36. const toArray = (item) => Array.isArray(item) ? item : [item];
  37. const unknownProp = null;
  38. const numericProp = [Number, String];
  39. const truthProp = {
  40. type: Boolean,
  41. default: true
  42. };
  43. const makeRequiredProp = (type) => ({
  44. type,
  45. required: true
  46. });
  47. const makeArrayProp = () => ({
  48. type: Array,
  49. default: () => []
  50. });
  51. const makeNumberProp = (defaultVal) => ({
  52. type: Number,
  53. default: defaultVal
  54. });
  55. const makeNumericProp = (defaultVal) => ({
  56. type: numericProp,
  57. default: defaultVal
  58. });
  59. const makeStringProp = (defaultVal) => ({
  60. type: String,
  61. default: defaultVal
  62. });
  63. function getScrollTop(el) {
  64. const top = "scrollTop" in el ? el.scrollTop : el.pageYOffset;
  65. return Math.max(top, 0);
  66. }
  67. function setScrollTop(el, value) {
  68. if ("scrollTop" in el) {
  69. el.scrollTop = value;
  70. } else {
  71. el.scrollTo(el.scrollX, value);
  72. }
  73. }
  74. function getRootScrollTop() {
  75. return window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0;
  76. }
  77. function setRootScrollTop(value) {
  78. setScrollTop(window, value);
  79. setScrollTop(document.body, value);
  80. }
  81. function getElementTop(el, scroller) {
  82. if (el === window) {
  83. return 0;
  84. }
  85. const scrollTop = scroller ? getScrollTop(scroller) : getRootScrollTop();
  86. return useRect(el).top + scrollTop;
  87. }
  88. const isIOS = isIOS$1();
  89. function resetScroll() {
  90. if (isIOS) {
  91. setRootScrollTop(getRootScrollTop());
  92. }
  93. }
  94. const stopPropagation = (event) => event.stopPropagation();
  95. function preventDefault(event, isStopPropagation) {
  96. if (typeof event.cancelable !== "boolean" || event.cancelable) {
  97. event.preventDefault();
  98. }
  99. if (isStopPropagation) {
  100. stopPropagation(event);
  101. }
  102. }
  103. function isHidden(elementRef) {
  104. const el = unref(elementRef);
  105. if (!el) {
  106. return false;
  107. }
  108. const style = window.getComputedStyle(el);
  109. const hidden = style.display === "none";
  110. const parentHidden = el.offsetParent === null && style.position !== "fixed";
  111. return hidden || parentHidden;
  112. }
  113. const { width: windowWidth, height: windowHeight } = useWindowSize();
  114. function addUnit(value) {
  115. if (isDef(value)) {
  116. return isNumeric(value) ? `${value}px` : String(value);
  117. }
  118. return void 0;
  119. }
  120. function getSizeStyle(originSize) {
  121. if (isDef(originSize)) {
  122. if (Array.isArray(originSize)) {
  123. return {
  124. width: addUnit(originSize[0]),
  125. height: addUnit(originSize[1])
  126. };
  127. }
  128. const size = addUnit(originSize);
  129. return {
  130. width: size,
  131. height: size
  132. };
  133. }
  134. }
  135. function getZIndexStyle(zIndex) {
  136. const style = {};
  137. if (zIndex !== void 0) {
  138. style.zIndex = +zIndex;
  139. }
  140. return style;
  141. }
  142. let rootFontSize;
  143. function getRootFontSize() {
  144. if (!rootFontSize) {
  145. const doc = document.documentElement;
  146. const fontSize = doc.style.fontSize || window.getComputedStyle(doc).fontSize;
  147. rootFontSize = parseFloat(fontSize);
  148. }
  149. return rootFontSize;
  150. }
  151. function convertRem(value) {
  152. value = value.replace(/rem/g, "");
  153. return +value * getRootFontSize();
  154. }
  155. function convertVw(value) {
  156. value = value.replace(/vw/g, "");
  157. return +value * windowWidth.value / 100;
  158. }
  159. function convertVh(value) {
  160. value = value.replace(/vh/g, "");
  161. return +value * windowHeight.value / 100;
  162. }
  163. function unitToPx(value) {
  164. if (typeof value === "number") {
  165. return value;
  166. }
  167. if (inBrowser) {
  168. if (value.includes("rem")) {
  169. return convertRem(value);
  170. }
  171. if (value.includes("vw")) {
  172. return convertVw(value);
  173. }
  174. if (value.includes("vh")) {
  175. return convertVh(value);
  176. }
  177. }
  178. return parseFloat(value);
  179. }
  180. const camelizeRE = /-(\w)/g;
  181. const camelize = (str) => str.replace(camelizeRE, (_, c) => c.toUpperCase());
  182. const kebabCase = (str) => str.replace(/([A-Z])/g, "-$1").toLowerCase().replace(/^-/, "");
  183. function padZero(num, targetLength = 2) {
  184. let str = num + "";
  185. while (str.length < targetLength) {
  186. str = "0" + str;
  187. }
  188. return str;
  189. }
  190. const clamp = (num, min, max) => Math.min(Math.max(num, min), max);
  191. function trimExtraChar(value, char, regExp) {
  192. const index = value.indexOf(char);
  193. if (index === -1) {
  194. return value;
  195. }
  196. if (char === "-" && index !== 0) {
  197. return value.slice(0, index);
  198. }
  199. return value.slice(0, index + 1) + value.slice(index).replace(regExp, "");
  200. }
  201. function formatNumber(value, allowDot = true, allowMinus = true) {
  202. if (allowDot) {
  203. value = trimExtraChar(value, ".", /\./g);
  204. } else {
  205. value = value.split(".")[0];
  206. }
  207. if (allowMinus) {
  208. value = trimExtraChar(value, "-", /-/g);
  209. } else {
  210. value = value.replace(/-/, "");
  211. }
  212. const regExp = allowDot ? /[^-0-9.]/g : /[^-0-9]/g;
  213. return value.replace(regExp, "");
  214. }
  215. function addNumber(num1, num2) {
  216. const cardinal = 10 ** 10;
  217. return Math.round((num1 + num2) * cardinal) / cardinal;
  218. }
  219. const { hasOwnProperty } = Object.prototype;
  220. function assignKey(to, from, key) {
  221. const val = from[key];
  222. if (!isDef(val)) {
  223. return;
  224. }
  225. if (!hasOwnProperty.call(to, key) || !isObject(val)) {
  226. to[key] = val;
  227. } else {
  228. to[key] = deepAssign(Object(to[key]), val);
  229. }
  230. }
  231. function deepAssign(to, from) {
  232. Object.keys(from).forEach((key) => {
  233. assignKey(to, from, key);
  234. });
  235. return to;
  236. }
  237. var stdin_default$1E = {
  238. name: "\u59D3\u540D",
  239. tel: "\u7535\u8BDD",
  240. save: "\u4FDD\u5B58",
  241. confirm: "\u786E\u8BA4",
  242. cancel: "\u53D6\u6D88",
  243. delete: "\u5220\u9664",
  244. loading: "\u52A0\u8F7D\u4E2D...",
  245. noCoupon: "\u6682\u65E0\u4F18\u60E0\u5238",
  246. nameEmpty: "\u8BF7\u586B\u5199\u59D3\u540D",
  247. addContact: "\u6DFB\u52A0\u8054\u7CFB\u4EBA",
  248. telInvalid: "\u8BF7\u586B\u5199\u6B63\u786E\u7684\u7535\u8BDD",
  249. vanCalendar: {
  250. end: "\u7ED3\u675F",
  251. start: "\u5F00\u59CB",
  252. title: "\u65E5\u671F\u9009\u62E9",
  253. weekdays: ["\u65E5", "\u4E00", "\u4E8C", "\u4E09", "\u56DB", "\u4E94", "\u516D"],
  254. monthTitle: (year, month) => `${year}\u5E74${month}\u6708`,
  255. rangePrompt: (maxRange) => `\u6700\u591A\u9009\u62E9 ${maxRange} \u5929`
  256. },
  257. vanCascader: {
  258. select: "\u8BF7\u9009\u62E9"
  259. },
  260. vanPagination: {
  261. prev: "\u4E0A\u4E00\u9875",
  262. next: "\u4E0B\u4E00\u9875"
  263. },
  264. vanPullRefresh: {
  265. pulling: "\u4E0B\u62C9\u5373\u53EF\u5237\u65B0...",
  266. loosing: "\u91CA\u653E\u5373\u53EF\u5237\u65B0..."
  267. },
  268. vanSubmitBar: {
  269. label: "\u5408\u8BA1:"
  270. },
  271. vanCoupon: {
  272. unlimited: "\u65E0\u95E8\u69DB",
  273. discount: (discount) => `${discount}\u6298`,
  274. condition: (condition) => `\u6EE1${condition}\u5143\u53EF\u7528`
  275. },
  276. vanCouponCell: {
  277. title: "\u4F18\u60E0\u5238",
  278. count: (count) => `${count}\u5F20\u53EF\u7528`
  279. },
  280. vanCouponList: {
  281. exchange: "\u5151\u6362",
  282. close: "\u4E0D\u4F7F\u7528",
  283. enable: "\u53EF\u7528",
  284. disabled: "\u4E0D\u53EF\u7528",
  285. placeholder: "\u8F93\u5165\u4F18\u60E0\u7801"
  286. },
  287. vanAddressEdit: {
  288. area: "\u5730\u533A",
  289. postal: "\u90AE\u653F\u7F16\u7801",
  290. areaEmpty: "\u8BF7\u9009\u62E9\u5730\u533A",
  291. addressEmpty: "\u8BF7\u586B\u5199\u8BE6\u7EC6\u5730\u5740",
  292. postalEmpty: "\u90AE\u653F\u7F16\u7801\u4E0D\u6B63\u786E",
  293. addressDetail: "\u8BE6\u7EC6\u5730\u5740",
  294. defaultAddress: "\u8BBE\u4E3A\u9ED8\u8BA4\u6536\u8D27\u5730\u5740"
  295. },
  296. vanAddressList: {
  297. add: "\u65B0\u589E\u5730\u5740"
  298. }
  299. };
  300. const lang = ref("zh-CN");
  301. const messages = reactive({
  302. "zh-CN": stdin_default$1E
  303. });
  304. const Locale = {
  305. messages() {
  306. return messages[lang.value];
  307. },
  308. use(newLang, newMessages) {
  309. lang.value = newLang;
  310. this.add({ [newLang]: newMessages });
  311. },
  312. add(newMessages = {}) {
  313. deepAssign(messages, newMessages);
  314. }
  315. };
  316. var stdin_default$1D = Locale;
  317. function createTranslate(name2) {
  318. const prefix = camelize(name2) + ".";
  319. return (path, ...args) => {
  320. const messages2 = stdin_default$1D.messages();
  321. const message = get(messages2, prefix + path) || get(messages2, path);
  322. return isFunction(message) ? message(...args) : message;
  323. };
  324. }
  325. function genBem(name2, mods) {
  326. if (!mods) {
  327. return "";
  328. }
  329. if (typeof mods === "string") {
  330. return ` ${name2}--${mods}`;
  331. }
  332. if (Array.isArray(mods)) {
  333. return mods.reduce(
  334. (ret, item) => ret + genBem(name2, item),
  335. ""
  336. );
  337. }
  338. return Object.keys(mods).reduce(
  339. (ret, key) => ret + (mods[key] ? genBem(name2, key) : ""),
  340. ""
  341. );
  342. }
  343. function createBEM(name2) {
  344. return (el, mods) => {
  345. if (el && typeof el !== "string") {
  346. mods = el;
  347. el = "";
  348. }
  349. el = el ? `${name2}__${el}` : name2;
  350. return `${el}${genBem(el, mods)}`;
  351. };
  352. }
  353. function createNamespace(name2) {
  354. const prefixedName = `van-${name2}`;
  355. return [
  356. prefixedName,
  357. createBEM(prefixedName),
  358. createTranslate(prefixedName)
  359. ];
  360. }
  361. const BORDER = "van-hairline";
  362. const BORDER_TOP = `${BORDER}--top`;
  363. const BORDER_LEFT = `${BORDER}--left`;
  364. const BORDER_BOTTOM = `${BORDER}--bottom`;
  365. const BORDER_SURROUND = `${BORDER}--surround`;
  366. const BORDER_TOP_BOTTOM = `${BORDER}--top-bottom`;
  367. const BORDER_UNSET_TOP_BOTTOM = `${BORDER}-unset--top-bottom`;
  368. const HAPTICS_FEEDBACK = "van-haptics-feedback";
  369. const FORM_KEY = Symbol("van-form");
  370. function callInterceptor(interceptor, {
  371. args = [],
  372. done,
  373. canceled
  374. }) {
  375. if (interceptor) {
  376. const returnVal = interceptor.apply(null, args);
  377. if (isPromise(returnVal)) {
  378. returnVal.then((value) => {
  379. if (value) {
  380. done();
  381. } else if (canceled) {
  382. canceled();
  383. }
  384. }).catch(noop);
  385. } else if (returnVal) {
  386. done();
  387. } else if (canceled) {
  388. canceled();
  389. }
  390. } else {
  391. done();
  392. }
  393. }
  394. function withInstall(options) {
  395. options.install = (app) => {
  396. const { name: name2 } = options;
  397. if (name2) {
  398. app.component(name2, options);
  399. app.component(camelize(`-${name2}`), options);
  400. }
  401. };
  402. return options;
  403. }
  404. const POPUP_TOGGLE_KEY = Symbol();
  405. function onPopupReopen(callback) {
  406. const popupToggleStatus = inject(POPUP_TOGGLE_KEY, null);
  407. if (popupToggleStatus) {
  408. watch(popupToggleStatus, (show) => {
  409. if (show) {
  410. callback();
  411. }
  412. });
  413. }
  414. }
  415. const useHeight = (element, withSafeArea) => {
  416. const height = ref();
  417. const setHeight = () => {
  418. height.value = useRect(element).height;
  419. };
  420. onMounted(() => {
  421. nextTick(setHeight);
  422. if (withSafeArea) {
  423. for (let i = 1; i <= 3; i++) {
  424. setTimeout(setHeight, 100 * i);
  425. }
  426. }
  427. });
  428. onPopupReopen(() => nextTick(setHeight));
  429. return height;
  430. };
  431. function usePlaceholder(contentRef, bem2) {
  432. const height = useHeight(contentRef, true);
  433. return (renderContent) => createVNode("div", {
  434. "class": bem2("placeholder"),
  435. "style": {
  436. height: height.value ? `${height.value}px` : void 0
  437. }
  438. }, [renderContent()]);
  439. }
  440. const [name$1v, bem$1r] = createNamespace("action-bar");
  441. const ACTION_BAR_KEY = Symbol(name$1v);
  442. const actionBarProps = {
  443. placeholder: Boolean,
  444. safeAreaInsetBottom: truthProp
  445. };
  446. var stdin_default$1C = defineComponent({
  447. name: name$1v,
  448. props: actionBarProps,
  449. setup(props, {
  450. slots
  451. }) {
  452. const root = ref();
  453. const renderPlaceholder = usePlaceholder(root, bem$1r);
  454. const {
  455. linkChildren
  456. } = useChildren(ACTION_BAR_KEY);
  457. linkChildren();
  458. const renderActionBar = () => {
  459. var _a;
  460. return createVNode("div", {
  461. "ref": root,
  462. "class": [bem$1r(), {
  463. "van-safe-area-bottom": props.safeAreaInsetBottom
  464. }]
  465. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  466. };
  467. return () => {
  468. if (props.placeholder) {
  469. return renderPlaceholder(renderActionBar);
  470. }
  471. return renderActionBar();
  472. };
  473. }
  474. });
  475. const ActionBar = withInstall(stdin_default$1C);
  476. function useExpose(apis) {
  477. const instance2 = getCurrentInstance();
  478. if (instance2) {
  479. extend(instance2.proxy, apis);
  480. }
  481. }
  482. const routeProps = {
  483. to: [String, Object],
  484. url: String,
  485. replace: Boolean
  486. };
  487. function route({
  488. to,
  489. url,
  490. replace,
  491. $router: router
  492. }) {
  493. if (to && router) {
  494. router[replace ? "replace" : "push"](to);
  495. } else if (url) {
  496. replace ? location.replace(url) : location.href = url;
  497. }
  498. }
  499. function useRoute() {
  500. const vm = getCurrentInstance().proxy;
  501. return () => route(vm);
  502. }
  503. const [name$1u, bem$1q] = createNamespace("badge");
  504. const badgeProps = {
  505. dot: Boolean,
  506. max: numericProp,
  507. tag: makeStringProp("div"),
  508. color: String,
  509. offset: Array,
  510. content: numericProp,
  511. showZero: truthProp,
  512. position: makeStringProp("top-right")
  513. };
  514. var stdin_default$1B = defineComponent({
  515. name: name$1u,
  516. props: badgeProps,
  517. setup(props, {
  518. slots
  519. }) {
  520. const hasContent = () => {
  521. if (slots.content) {
  522. return true;
  523. }
  524. const {
  525. content,
  526. showZero
  527. } = props;
  528. return isDef(content) && content !== "" && (showZero || content !== 0 && content !== "0");
  529. };
  530. const renderContent = () => {
  531. const {
  532. dot,
  533. max,
  534. content
  535. } = props;
  536. if (!dot && hasContent()) {
  537. if (slots.content) {
  538. return slots.content();
  539. }
  540. if (isDef(max) && isNumeric(content) && +content > max) {
  541. return `${max}+`;
  542. }
  543. return content;
  544. }
  545. };
  546. const style = computed(() => {
  547. const style2 = {
  548. background: props.color
  549. };
  550. if (props.offset) {
  551. const [x, y] = props.offset;
  552. if (slots.default) {
  553. style2.top = addUnit(y);
  554. if (typeof x === "number") {
  555. style2.right = addUnit(-x);
  556. } else {
  557. style2.right = x.startsWith("-") ? x.replace("-", "") : `-${x}`;
  558. }
  559. } else {
  560. style2.marginTop = addUnit(y);
  561. style2.marginLeft = addUnit(x);
  562. }
  563. }
  564. return style2;
  565. });
  566. const renderBadge = () => {
  567. if (hasContent() || props.dot) {
  568. return createVNode("div", {
  569. "class": bem$1q([props.position, {
  570. dot: props.dot,
  571. fixed: !!slots.default
  572. }]),
  573. "style": style.value
  574. }, [renderContent()]);
  575. }
  576. };
  577. return () => {
  578. if (slots.default) {
  579. const {
  580. tag
  581. } = props;
  582. return createVNode(tag, {
  583. "class": bem$1q("wrapper")
  584. }, {
  585. default: () => [slots.default(), renderBadge()]
  586. });
  587. }
  588. return renderBadge();
  589. };
  590. }
  591. });
  592. const Badge = withInstall(stdin_default$1B);
  593. let globalZIndex = 2e3;
  594. const useGlobalZIndex = () => ++globalZIndex;
  595. const setGlobalZIndex = (val) => {
  596. globalZIndex = val;
  597. };
  598. const [name$1t, bem$1p] = createNamespace("config-provider");
  599. const CONFIG_PROVIDER_KEY = Symbol(name$1t);
  600. const configProviderProps = {
  601. tag: makeStringProp("div"),
  602. zIndex: Number,
  603. themeVars: Object,
  604. iconPrefix: String
  605. };
  606. function mapThemeVarsToCSSVars(themeVars) {
  607. const cssVars = {};
  608. Object.keys(themeVars).forEach((key) => {
  609. cssVars[`--van-${kebabCase(key)}`] = themeVars[key];
  610. });
  611. return cssVars;
  612. }
  613. var stdin_default$1A = defineComponent({
  614. name: name$1t,
  615. props: configProviderProps,
  616. setup(props, {
  617. slots
  618. }) {
  619. const style = computed(() => {
  620. if (props.themeVars) {
  621. return mapThemeVarsToCSSVars(props.themeVars);
  622. }
  623. });
  624. provide(CONFIG_PROVIDER_KEY, props);
  625. watchEffect(() => {
  626. if (props.zIndex !== void 0) {
  627. setGlobalZIndex(props.zIndex);
  628. }
  629. });
  630. return () => createVNode(props.tag, {
  631. "class": bem$1p(),
  632. "style": style.value
  633. }, {
  634. default: () => {
  635. var _a;
  636. return [(_a = slots.default) == null ? void 0 : _a.call(slots)];
  637. }
  638. });
  639. }
  640. });
  641. const [name$1s, bem$1o] = createNamespace("icon");
  642. const isImage = (name2) => name2 == null ? void 0 : name2.includes("/");
  643. const iconProps = {
  644. dot: Boolean,
  645. tag: makeStringProp("i"),
  646. name: String,
  647. size: numericProp,
  648. badge: numericProp,
  649. color: String,
  650. badgeProps: Object,
  651. classPrefix: String
  652. };
  653. var stdin_default$1z = defineComponent({
  654. name: name$1s,
  655. props: iconProps,
  656. setup(props, {
  657. slots
  658. }) {
  659. const config = inject(CONFIG_PROVIDER_KEY, null);
  660. const classPrefix = computed(() => props.classPrefix || (config == null ? void 0 : config.iconPrefix) || bem$1o());
  661. return () => {
  662. const {
  663. tag,
  664. dot,
  665. name: name2,
  666. size,
  667. badge,
  668. color
  669. } = props;
  670. const isImageIcon = isImage(name2);
  671. return createVNode(Badge, mergeProps({
  672. "dot": dot,
  673. "tag": tag,
  674. "class": [classPrefix.value, isImageIcon ? "" : `${classPrefix.value}-${name2}`],
  675. "style": {
  676. color,
  677. fontSize: addUnit(size)
  678. },
  679. "content": badge
  680. }, props.badgeProps), {
  681. default: () => {
  682. var _a;
  683. return [(_a = slots.default) == null ? void 0 : _a.call(slots), isImageIcon && createVNode("img", {
  684. "class": bem$1o("image"),
  685. "src": name2
  686. }, null)];
  687. }
  688. });
  689. };
  690. }
  691. });
  692. const Icon = withInstall(stdin_default$1z);
  693. const [name$1r, bem$1n] = createNamespace("loading");
  694. const SpinIcon = Array(12).fill(null).map((_, index) => createVNode("i", {
  695. "class": bem$1n("line", String(index + 1))
  696. }, null));
  697. const CircularIcon = createVNode("svg", {
  698. "class": bem$1n("circular"),
  699. "viewBox": "25 25 50 50"
  700. }, [createVNode("circle", {
  701. "cx": "50",
  702. "cy": "50",
  703. "r": "20",
  704. "fill": "none"
  705. }, null)]);
  706. const loadingProps = {
  707. size: numericProp,
  708. type: makeStringProp("circular"),
  709. color: String,
  710. vertical: Boolean,
  711. textSize: numericProp,
  712. textColor: String
  713. };
  714. var stdin_default$1y = defineComponent({
  715. name: name$1r,
  716. props: loadingProps,
  717. setup(props, {
  718. slots
  719. }) {
  720. const spinnerStyle = computed(() => extend({
  721. color: props.color
  722. }, getSizeStyle(props.size)));
  723. const renderText = () => {
  724. var _a;
  725. if (slots.default) {
  726. return createVNode("span", {
  727. "class": bem$1n("text"),
  728. "style": {
  729. fontSize: addUnit(props.textSize),
  730. color: (_a = props.textColor) != null ? _a : props.color
  731. }
  732. }, [slots.default()]);
  733. }
  734. };
  735. return () => {
  736. const {
  737. type,
  738. vertical
  739. } = props;
  740. return createVNode("div", {
  741. "class": bem$1n([type, {
  742. vertical
  743. }]),
  744. "aria-live": "polite",
  745. "aria-busy": true
  746. }, [createVNode("span", {
  747. "class": bem$1n("spinner", type),
  748. "style": spinnerStyle.value
  749. }, [type === "spinner" ? SpinIcon : CircularIcon]), renderText()]);
  750. };
  751. }
  752. });
  753. const Loading = withInstall(stdin_default$1y);
  754. const [name$1q, bem$1m] = createNamespace("button");
  755. const buttonProps = extend({}, routeProps, {
  756. tag: makeStringProp("button"),
  757. text: String,
  758. icon: String,
  759. type: makeStringProp("default"),
  760. size: makeStringProp("normal"),
  761. color: String,
  762. block: Boolean,
  763. plain: Boolean,
  764. round: Boolean,
  765. square: Boolean,
  766. loading: Boolean,
  767. hairline: Boolean,
  768. disabled: Boolean,
  769. iconPrefix: String,
  770. nativeType: makeStringProp("button"),
  771. loadingSize: numericProp,
  772. loadingText: String,
  773. loadingType: String,
  774. iconPosition: makeStringProp("left")
  775. });
  776. var stdin_default$1x = defineComponent({
  777. name: name$1q,
  778. props: buttonProps,
  779. emits: ["click"],
  780. setup(props, {
  781. emit,
  782. slots
  783. }) {
  784. const route2 = useRoute();
  785. const renderLoadingIcon = () => {
  786. if (slots.loading) {
  787. return slots.loading();
  788. }
  789. return createVNode(Loading, {
  790. "size": props.loadingSize,
  791. "type": props.loadingType,
  792. "class": bem$1m("loading")
  793. }, null);
  794. };
  795. const renderIcon = () => {
  796. if (props.loading) {
  797. return renderLoadingIcon();
  798. }
  799. if (slots.icon) {
  800. return createVNode("div", {
  801. "class": bem$1m("icon")
  802. }, [slots.icon()]);
  803. }
  804. if (props.icon) {
  805. return createVNode(Icon, {
  806. "name": props.icon,
  807. "class": bem$1m("icon"),
  808. "classPrefix": props.iconPrefix
  809. }, null);
  810. }
  811. };
  812. const renderText = () => {
  813. let text;
  814. if (props.loading) {
  815. text = props.loadingText;
  816. } else {
  817. text = slots.default ? slots.default() : props.text;
  818. }
  819. if (text) {
  820. return createVNode("span", {
  821. "class": bem$1m("text")
  822. }, [text]);
  823. }
  824. };
  825. const getStyle = () => {
  826. const {
  827. color,
  828. plain
  829. } = props;
  830. if (color) {
  831. const style = {
  832. color: plain ? color : "white"
  833. };
  834. if (!plain) {
  835. style.background = color;
  836. }
  837. if (color.includes("gradient")) {
  838. style.border = 0;
  839. } else {
  840. style.borderColor = color;
  841. }
  842. return style;
  843. }
  844. };
  845. const onClick = (event) => {
  846. if (props.loading) {
  847. preventDefault(event);
  848. } else if (!props.disabled) {
  849. emit("click", event);
  850. route2();
  851. }
  852. };
  853. return () => {
  854. const {
  855. tag,
  856. type,
  857. size,
  858. block,
  859. round,
  860. plain,
  861. square,
  862. loading,
  863. disabled,
  864. hairline,
  865. nativeType,
  866. iconPosition
  867. } = props;
  868. const classes = [bem$1m([type, size, {
  869. plain,
  870. block,
  871. round,
  872. square,
  873. loading,
  874. disabled,
  875. hairline
  876. }]), {
  877. [BORDER_SURROUND]: hairline
  878. }];
  879. return createVNode(tag, {
  880. "type": nativeType,
  881. "class": classes,
  882. "style": getStyle(),
  883. "disabled": disabled,
  884. "onClick": onClick
  885. }, {
  886. default: () => [createVNode("div", {
  887. "class": bem$1m("content")
  888. }, [iconPosition === "left" && renderIcon(), renderText(), iconPosition === "right" && renderIcon()])]
  889. });
  890. };
  891. }
  892. });
  893. const Button = withInstall(stdin_default$1x);
  894. const [name$1p, bem$1l] = createNamespace("action-bar-button");
  895. const actionBarButtonProps = extend({}, routeProps, {
  896. type: String,
  897. text: String,
  898. icon: String,
  899. color: String,
  900. loading: Boolean,
  901. disabled: Boolean
  902. });
  903. var stdin_default$1w = defineComponent({
  904. name: name$1p,
  905. props: actionBarButtonProps,
  906. setup(props, {
  907. slots
  908. }) {
  909. const route2 = useRoute();
  910. const {
  911. parent,
  912. index
  913. } = useParent(ACTION_BAR_KEY);
  914. const isFirst = computed(() => {
  915. if (parent) {
  916. const prev = parent.children[index.value - 1];
  917. return !(prev && "isButton" in prev);
  918. }
  919. });
  920. const isLast = computed(() => {
  921. if (parent) {
  922. const next = parent.children[index.value + 1];
  923. return !(next && "isButton" in next);
  924. }
  925. });
  926. useExpose({
  927. isButton: true
  928. });
  929. return () => {
  930. const {
  931. type,
  932. icon,
  933. text,
  934. color,
  935. loading,
  936. disabled
  937. } = props;
  938. return createVNode(Button, {
  939. "class": bem$1l([type, {
  940. last: isLast.value,
  941. first: isFirst.value
  942. }]),
  943. "size": "large",
  944. "type": type,
  945. "icon": icon,
  946. "color": color,
  947. "loading": loading,
  948. "disabled": disabled,
  949. "onClick": route2
  950. }, {
  951. default: () => [slots.default ? slots.default() : text]
  952. });
  953. };
  954. }
  955. });
  956. const ActionBarButton = withInstall(stdin_default$1w);
  957. const [name$1o, bem$1k] = createNamespace("action-bar-icon");
  958. const actionBarIconProps = extend({}, routeProps, {
  959. dot: Boolean,
  960. text: String,
  961. icon: String,
  962. color: String,
  963. badge: numericProp,
  964. iconClass: unknownProp,
  965. badgeProps: Object,
  966. iconPrefix: String
  967. });
  968. var stdin_default$1v = defineComponent({
  969. name: name$1o,
  970. props: actionBarIconProps,
  971. setup(props, {
  972. slots
  973. }) {
  974. const route2 = useRoute();
  975. useParent(ACTION_BAR_KEY);
  976. const renderIcon = () => {
  977. const {
  978. dot,
  979. badge,
  980. icon,
  981. color,
  982. iconClass,
  983. badgeProps: badgeProps2,
  984. iconPrefix
  985. } = props;
  986. if (slots.icon) {
  987. return createVNode(Badge, mergeProps({
  988. "dot": dot,
  989. "class": bem$1k("icon"),
  990. "content": badge
  991. }, badgeProps2), {
  992. default: slots.icon
  993. });
  994. }
  995. return createVNode(Icon, {
  996. "tag": "div",
  997. "dot": dot,
  998. "name": icon,
  999. "badge": badge,
  1000. "color": color,
  1001. "class": [bem$1k("icon"), iconClass],
  1002. "badgeProps": badgeProps2,
  1003. "classPrefix": iconPrefix
  1004. }, null);
  1005. };
  1006. return () => createVNode("div", {
  1007. "role": "button",
  1008. "class": bem$1k(),
  1009. "tabindex": 0,
  1010. "onClick": route2
  1011. }, [renderIcon(), slots.default ? slots.default() : props.text]);
  1012. }
  1013. });
  1014. const ActionBarIcon = withInstall(stdin_default$1v);
  1015. const popupSharedProps = {
  1016. show: Boolean,
  1017. zIndex: numericProp,
  1018. overlay: truthProp,
  1019. duration: numericProp,
  1020. teleport: [String, Object],
  1021. lockScroll: truthProp,
  1022. lazyRender: truthProp,
  1023. beforeClose: Function,
  1024. overlayStyle: Object,
  1025. overlayClass: unknownProp,
  1026. transitionAppear: Boolean,
  1027. closeOnClickOverlay: truthProp
  1028. };
  1029. const popupSharedPropKeys = Object.keys(
  1030. popupSharedProps
  1031. );
  1032. function getDirection(x, y) {
  1033. if (x > y) {
  1034. return "horizontal";
  1035. }
  1036. if (y > x) {
  1037. return "vertical";
  1038. }
  1039. return "";
  1040. }
  1041. function useTouch() {
  1042. const startX = ref(0);
  1043. const startY = ref(0);
  1044. const deltaX = ref(0);
  1045. const deltaY = ref(0);
  1046. const offsetX = ref(0);
  1047. const offsetY = ref(0);
  1048. const direction = ref("");
  1049. const isVertical = () => direction.value === "vertical";
  1050. const isHorizontal = () => direction.value === "horizontal";
  1051. const reset = () => {
  1052. deltaX.value = 0;
  1053. deltaY.value = 0;
  1054. offsetX.value = 0;
  1055. offsetY.value = 0;
  1056. direction.value = "";
  1057. };
  1058. const start = (event) => {
  1059. reset();
  1060. startX.value = event.touches[0].clientX;
  1061. startY.value = event.touches[0].clientY;
  1062. };
  1063. const move = (event) => {
  1064. const touch = event.touches[0];
  1065. deltaX.value = (touch.clientX < 0 ? 0 : touch.clientX) - startX.value;
  1066. deltaY.value = touch.clientY - startY.value;
  1067. offsetX.value = Math.abs(deltaX.value);
  1068. offsetY.value = Math.abs(deltaY.value);
  1069. const LOCK_DIRECTION_DISTANCE = 10;
  1070. if (!direction.value || offsetX.value < LOCK_DIRECTION_DISTANCE && offsetY.value < LOCK_DIRECTION_DISTANCE) {
  1071. direction.value = getDirection(offsetX.value, offsetY.value);
  1072. }
  1073. };
  1074. return {
  1075. move,
  1076. start,
  1077. reset,
  1078. startX,
  1079. startY,
  1080. deltaX,
  1081. deltaY,
  1082. offsetX,
  1083. offsetY,
  1084. direction,
  1085. isVertical,
  1086. isHorizontal
  1087. };
  1088. }
  1089. let totalLockCount = 0;
  1090. const BODY_LOCK_CLASS = "van-overflow-hidden";
  1091. function useLockScroll(rootRef, shouldLock) {
  1092. const touch = useTouch();
  1093. const DIRECTION_UP = "01";
  1094. const DIRECTION_DOWN = "10";
  1095. const onTouchMove = (event) => {
  1096. touch.move(event);
  1097. const direction = touch.deltaY.value > 0 ? DIRECTION_DOWN : DIRECTION_UP;
  1098. const el = getScrollParent(
  1099. event.target,
  1100. rootRef.value
  1101. );
  1102. const { scrollHeight, offsetHeight, scrollTop } = el;
  1103. let status = "11";
  1104. if (scrollTop === 0) {
  1105. status = offsetHeight >= scrollHeight ? "00" : "01";
  1106. } else if (scrollTop + offsetHeight >= scrollHeight) {
  1107. status = "10";
  1108. }
  1109. if (status !== "11" && touch.isVertical() && !(parseInt(status, 2) & parseInt(direction, 2))) {
  1110. preventDefault(event, true);
  1111. }
  1112. };
  1113. const lock = () => {
  1114. document.addEventListener("touchstart", touch.start);
  1115. document.addEventListener("touchmove", onTouchMove, { passive: false });
  1116. if (!totalLockCount) {
  1117. document.body.classList.add(BODY_LOCK_CLASS);
  1118. }
  1119. totalLockCount++;
  1120. };
  1121. const unlock = () => {
  1122. if (totalLockCount) {
  1123. document.removeEventListener("touchstart", touch.start);
  1124. document.removeEventListener("touchmove", onTouchMove);
  1125. totalLockCount--;
  1126. if (!totalLockCount) {
  1127. document.body.classList.remove(BODY_LOCK_CLASS);
  1128. }
  1129. }
  1130. };
  1131. const init = () => shouldLock() && lock();
  1132. const destroy = () => shouldLock() && unlock();
  1133. onMountedOrActivated(init);
  1134. onDeactivated(destroy);
  1135. onBeforeUnmount(destroy);
  1136. watch(shouldLock, (value) => {
  1137. value ? lock() : unlock();
  1138. });
  1139. }
  1140. function useLazyRender(show) {
  1141. const inited = ref(false);
  1142. watch(
  1143. show,
  1144. (value) => {
  1145. if (value) {
  1146. inited.value = value;
  1147. }
  1148. },
  1149. { immediate: true }
  1150. );
  1151. return (render) => () => inited.value ? render() : null;
  1152. }
  1153. const [name$1n, bem$1j] = createNamespace("overlay");
  1154. const overlayProps = {
  1155. show: Boolean,
  1156. zIndex: numericProp,
  1157. duration: numericProp,
  1158. className: unknownProp,
  1159. lockScroll: truthProp,
  1160. lazyRender: truthProp,
  1161. customStyle: Object
  1162. };
  1163. var stdin_default$1u = defineComponent({
  1164. name: name$1n,
  1165. props: overlayProps,
  1166. setup(props, {
  1167. slots
  1168. }) {
  1169. const root = ref();
  1170. const lazyRender = useLazyRender(() => props.show || !props.lazyRender);
  1171. const onTouchMove = (event) => {
  1172. if (props.lockScroll) {
  1173. preventDefault(event, true);
  1174. }
  1175. };
  1176. const renderOverlay = lazyRender(() => {
  1177. var _a;
  1178. const style = extend(getZIndexStyle(props.zIndex), props.customStyle);
  1179. if (isDef(props.duration)) {
  1180. style.animationDuration = `${props.duration}s`;
  1181. }
  1182. return withDirectives(createVNode("div", {
  1183. "ref": root,
  1184. "style": style,
  1185. "class": [bem$1j(), props.className]
  1186. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]), [[vShow, props.show]]);
  1187. });
  1188. useEventListener("touchmove", onTouchMove, {
  1189. target: root
  1190. });
  1191. return () => createVNode(Transition, {
  1192. "name": "van-fade",
  1193. "appear": true
  1194. }, {
  1195. default: renderOverlay
  1196. });
  1197. }
  1198. });
  1199. const Overlay = withInstall(stdin_default$1u);
  1200. const popupProps$2 = extend({}, popupSharedProps, {
  1201. round: Boolean,
  1202. position: makeStringProp("center"),
  1203. closeIcon: makeStringProp("cross"),
  1204. closeable: Boolean,
  1205. transition: String,
  1206. iconPrefix: String,
  1207. closeOnPopstate: Boolean,
  1208. closeIconPosition: makeStringProp("top-right"),
  1209. safeAreaInsetTop: Boolean,
  1210. safeAreaInsetBottom: Boolean
  1211. });
  1212. const [name$1m, bem$1i] = createNamespace("popup");
  1213. var stdin_default$1t = defineComponent({
  1214. name: name$1m,
  1215. inheritAttrs: false,
  1216. props: popupProps$2,
  1217. emits: ["open", "close", "opened", "closed", "keydown", "update:show", "click-overlay", "click-close-icon"],
  1218. setup(props, {
  1219. emit,
  1220. attrs,
  1221. slots
  1222. }) {
  1223. let opened;
  1224. let shouldReopen;
  1225. const zIndex = ref();
  1226. const popupRef = ref();
  1227. const lazyRender = useLazyRender(() => props.show || !props.lazyRender);
  1228. const style = computed(() => {
  1229. const style2 = {
  1230. zIndex: zIndex.value
  1231. };
  1232. if (isDef(props.duration)) {
  1233. const key = props.position === "center" ? "animationDuration" : "transitionDuration";
  1234. style2[key] = `${props.duration}s`;
  1235. }
  1236. return style2;
  1237. });
  1238. const open = () => {
  1239. if (!opened) {
  1240. opened = true;
  1241. zIndex.value = props.zIndex !== void 0 ? +props.zIndex : useGlobalZIndex();
  1242. emit("open");
  1243. }
  1244. };
  1245. const close = () => {
  1246. if (opened) {
  1247. callInterceptor(props.beforeClose, {
  1248. done() {
  1249. opened = false;
  1250. emit("close");
  1251. emit("update:show", false);
  1252. }
  1253. });
  1254. }
  1255. };
  1256. const onClickOverlay = (event) => {
  1257. emit("click-overlay", event);
  1258. if (props.closeOnClickOverlay) {
  1259. close();
  1260. }
  1261. };
  1262. const renderOverlay = () => {
  1263. if (props.overlay) {
  1264. return createVNode(Overlay, {
  1265. "show": props.show,
  1266. "class": props.overlayClass,
  1267. "zIndex": zIndex.value,
  1268. "duration": props.duration,
  1269. "customStyle": props.overlayStyle,
  1270. "role": props.closeOnClickOverlay ? "button" : void 0,
  1271. "tabindex": props.closeOnClickOverlay ? 0 : void 0,
  1272. "onClick": onClickOverlay
  1273. }, {
  1274. default: slots["overlay-content"]
  1275. });
  1276. }
  1277. };
  1278. const onClickCloseIcon = (event) => {
  1279. emit("click-close-icon", event);
  1280. close();
  1281. };
  1282. const renderCloseIcon = () => {
  1283. if (props.closeable) {
  1284. return createVNode(Icon, {
  1285. "role": "button",
  1286. "tabindex": 0,
  1287. "name": props.closeIcon,
  1288. "class": [bem$1i("close-icon", props.closeIconPosition), HAPTICS_FEEDBACK],
  1289. "classPrefix": props.iconPrefix,
  1290. "onClick": onClickCloseIcon
  1291. }, null);
  1292. }
  1293. };
  1294. const onOpened = () => emit("opened");
  1295. const onClosed = () => emit("closed");
  1296. const onKeydown = (event) => emit("keydown", event);
  1297. const renderPopup = lazyRender(() => {
  1298. var _a;
  1299. const {
  1300. round,
  1301. position,
  1302. safeAreaInsetTop,
  1303. safeAreaInsetBottom
  1304. } = props;
  1305. return withDirectives(createVNode("div", mergeProps({
  1306. "ref": popupRef,
  1307. "style": style.value,
  1308. "role": "dialog",
  1309. "tabindex": 0,
  1310. "class": [bem$1i({
  1311. round,
  1312. [position]: position
  1313. }), {
  1314. "van-safe-area-top": safeAreaInsetTop,
  1315. "van-safe-area-bottom": safeAreaInsetBottom
  1316. }],
  1317. "onKeydown": onKeydown
  1318. }, attrs), [(_a = slots.default) == null ? void 0 : _a.call(slots), renderCloseIcon()]), [[vShow, props.show]]);
  1319. });
  1320. const renderTransition = () => {
  1321. const {
  1322. position,
  1323. transition,
  1324. transitionAppear
  1325. } = props;
  1326. const name2 = position === "center" ? "van-fade" : `van-popup-slide-${position}`;
  1327. return createVNode(Transition, {
  1328. "name": transition || name2,
  1329. "appear": transitionAppear,
  1330. "onAfterEnter": onOpened,
  1331. "onAfterLeave": onClosed
  1332. }, {
  1333. default: renderPopup
  1334. });
  1335. };
  1336. watch(() => props.show, (show) => {
  1337. if (show && !opened) {
  1338. open();
  1339. if (attrs.tabindex === 0) {
  1340. nextTick(() => {
  1341. var _a;
  1342. (_a = popupRef.value) == null ? void 0 : _a.focus();
  1343. });
  1344. }
  1345. }
  1346. if (!show && opened) {
  1347. opened = false;
  1348. emit("close");
  1349. }
  1350. });
  1351. useExpose({
  1352. popupRef
  1353. });
  1354. useLockScroll(popupRef, () => props.show && props.lockScroll);
  1355. useEventListener("popstate", () => {
  1356. if (props.closeOnPopstate) {
  1357. close();
  1358. shouldReopen = false;
  1359. }
  1360. });
  1361. onMounted(() => {
  1362. if (props.show) {
  1363. open();
  1364. }
  1365. });
  1366. onActivated(() => {
  1367. if (shouldReopen) {
  1368. emit("update:show", true);
  1369. shouldReopen = false;
  1370. }
  1371. });
  1372. onDeactivated(() => {
  1373. if (props.show && props.teleport) {
  1374. close();
  1375. shouldReopen = true;
  1376. }
  1377. });
  1378. provide(POPUP_TOGGLE_KEY, () => props.show);
  1379. return () => {
  1380. if (props.teleport) {
  1381. return createVNode(Teleport, {
  1382. "to": props.teleport
  1383. }, {
  1384. default: () => [renderOverlay(), renderTransition()]
  1385. });
  1386. }
  1387. return createVNode(Fragment, null, [renderOverlay(), renderTransition()]);
  1388. };
  1389. }
  1390. });
  1391. const Popup = withInstall(stdin_default$1t);
  1392. const [name$1l, bem$1h] = createNamespace("action-sheet");
  1393. const actionSheetProps = extend({}, popupSharedProps, {
  1394. title: String,
  1395. round: truthProp,
  1396. actions: makeArrayProp(),
  1397. closeIcon: makeStringProp("cross"),
  1398. closeable: truthProp,
  1399. cancelText: String,
  1400. description: String,
  1401. closeOnPopstate: truthProp,
  1402. closeOnClickAction: Boolean,
  1403. safeAreaInsetBottom: truthProp
  1404. });
  1405. const popupInheritKeys$2 = [...popupSharedPropKeys, "round", "closeOnPopstate", "safeAreaInsetBottom"];
  1406. var stdin_default$1s = defineComponent({
  1407. name: name$1l,
  1408. props: actionSheetProps,
  1409. emits: ["select", "cancel", "update:show"],
  1410. setup(props, {
  1411. slots,
  1412. emit
  1413. }) {
  1414. const updateShow = (show) => emit("update:show", show);
  1415. const onCancel = () => {
  1416. updateShow(false);
  1417. emit("cancel");
  1418. };
  1419. const renderHeader = () => {
  1420. if (props.title) {
  1421. return createVNode("div", {
  1422. "class": bem$1h("header")
  1423. }, [props.title, props.closeable && createVNode(Icon, {
  1424. "name": props.closeIcon,
  1425. "class": [bem$1h("close"), HAPTICS_FEEDBACK],
  1426. "onClick": onCancel
  1427. }, null)]);
  1428. }
  1429. };
  1430. const renderCancel = () => {
  1431. if (slots.cancel || props.cancelText) {
  1432. return [createVNode("div", {
  1433. "class": bem$1h("gap")
  1434. }, null), createVNode("button", {
  1435. "type": "button",
  1436. "class": bem$1h("cancel"),
  1437. "onClick": onCancel
  1438. }, [slots.cancel ? slots.cancel() : props.cancelText])];
  1439. }
  1440. };
  1441. const renderActionContent = (action, index) => {
  1442. if (action.loading) {
  1443. return createVNode(Loading, {
  1444. "class": bem$1h("loading-icon")
  1445. }, null);
  1446. }
  1447. if (slots.action) {
  1448. return slots.action({
  1449. action,
  1450. index
  1451. });
  1452. }
  1453. return [createVNode("span", {
  1454. "class": bem$1h("name")
  1455. }, [action.name]), action.subname && createVNode("div", {
  1456. "class": bem$1h("subname")
  1457. }, [action.subname])];
  1458. };
  1459. const renderAction = (action, index) => {
  1460. const {
  1461. color,
  1462. loading,
  1463. callback,
  1464. disabled,
  1465. className
  1466. } = action;
  1467. const onClick = () => {
  1468. if (disabled || loading) {
  1469. return;
  1470. }
  1471. if (callback) {
  1472. callback(action);
  1473. }
  1474. if (props.closeOnClickAction) {
  1475. updateShow(false);
  1476. }
  1477. nextTick(() => emit("select", action, index));
  1478. };
  1479. return createVNode("button", {
  1480. "type": "button",
  1481. "style": {
  1482. color
  1483. },
  1484. "class": [bem$1h("item", {
  1485. loading,
  1486. disabled
  1487. }), className],
  1488. "onClick": onClick
  1489. }, [renderActionContent(action, index)]);
  1490. };
  1491. const renderDescription = () => {
  1492. if (props.description || slots.description) {
  1493. const content = slots.description ? slots.description() : props.description;
  1494. return createVNode("div", {
  1495. "class": bem$1h("description")
  1496. }, [content]);
  1497. }
  1498. };
  1499. return () => createVNode(Popup, mergeProps({
  1500. "class": bem$1h(),
  1501. "position": "bottom",
  1502. "onUpdate:show": updateShow
  1503. }, pick(props, popupInheritKeys$2)), {
  1504. default: () => {
  1505. var _a;
  1506. return [renderHeader(), renderDescription(), createVNode("div", {
  1507. "class": bem$1h("content")
  1508. }, [props.actions.map(renderAction), (_a = slots.default) == null ? void 0 : _a.call(slots)]), renderCancel()];
  1509. }
  1510. });
  1511. }
  1512. });
  1513. const ActionSheet = withInstall(stdin_default$1s);
  1514. function deepClone(obj) {
  1515. if (!isDef(obj)) {
  1516. return obj;
  1517. }
  1518. if (Array.isArray(obj)) {
  1519. return obj.map((item) => deepClone(item));
  1520. }
  1521. if (isObject(obj)) {
  1522. const to = {};
  1523. Object.keys(obj).forEach((key) => {
  1524. to[key] = deepClone(obj[key]);
  1525. });
  1526. return to;
  1527. }
  1528. return obj;
  1529. }
  1530. const DEFAULT_DURATION = 200;
  1531. const MOMENTUM_LIMIT_TIME = 300;
  1532. const MOMENTUM_LIMIT_DISTANCE = 15;
  1533. const [name$1k, bem$1g] = createNamespace("picker-column");
  1534. function getElementTranslateY(element) {
  1535. const {
  1536. transform
  1537. } = window.getComputedStyle(element);
  1538. const translateY = transform.slice(7, transform.length - 1).split(", ")[5];
  1539. return Number(translateY);
  1540. }
  1541. const PICKER_KEY = Symbol(name$1k);
  1542. const isOptionDisabled = (option) => isObject(option) && option.disabled;
  1543. var stdin_default$1r = defineComponent({
  1544. name: name$1k,
  1545. props: {
  1546. textKey: makeRequiredProp(String),
  1547. readonly: Boolean,
  1548. allowHtml: Boolean,
  1549. className: unknownProp,
  1550. itemHeight: makeRequiredProp(Number),
  1551. defaultIndex: makeNumberProp(0),
  1552. swipeDuration: makeRequiredProp(numericProp),
  1553. initialOptions: makeArrayProp(),
  1554. visibleItemCount: makeRequiredProp(numericProp)
  1555. },
  1556. emits: ["change"],
  1557. setup(props, {
  1558. emit,
  1559. slots
  1560. }) {
  1561. let moving;
  1562. let startOffset;
  1563. let touchStartTime;
  1564. let momentumOffset;
  1565. let transitionEndTrigger;
  1566. const root = ref();
  1567. const wrapper = ref();
  1568. const state = reactive({
  1569. index: props.defaultIndex,
  1570. offset: 0,
  1571. duration: 0,
  1572. options: deepClone(props.initialOptions)
  1573. });
  1574. const touch = useTouch();
  1575. const count = () => state.options.length;
  1576. const baseOffset = () => props.itemHeight * (+props.visibleItemCount - 1) / 2;
  1577. const adjustIndex = (index) => {
  1578. index = clamp(index, 0, count());
  1579. for (let i = index; i < count(); i++) {
  1580. if (!isOptionDisabled(state.options[i]))
  1581. return i;
  1582. }
  1583. for (let i = index - 1; i >= 0; i--) {
  1584. if (!isOptionDisabled(state.options[i]))
  1585. return i;
  1586. }
  1587. };
  1588. const setIndex = (index, emitChange) => {
  1589. index = adjustIndex(index) || 0;
  1590. const offset = -index * props.itemHeight;
  1591. const trigger = () => {
  1592. if (index !== state.index) {
  1593. state.index = index;
  1594. if (emitChange) {
  1595. emit("change", index);
  1596. }
  1597. }
  1598. };
  1599. if (moving && offset !== state.offset) {
  1600. transitionEndTrigger = trigger;
  1601. } else {
  1602. trigger();
  1603. }
  1604. state.offset = offset;
  1605. };
  1606. const setOptions = (options) => {
  1607. if (JSON.stringify(options) !== JSON.stringify(state.options)) {
  1608. state.options = deepClone(options);
  1609. setIndex(props.defaultIndex);
  1610. }
  1611. };
  1612. const onClickItem = (index) => {
  1613. if (moving || props.readonly) {
  1614. return;
  1615. }
  1616. transitionEndTrigger = null;
  1617. state.duration = DEFAULT_DURATION;
  1618. setIndex(index, true);
  1619. };
  1620. const getOptionText = (option) => {
  1621. if (isObject(option) && props.textKey in option) {
  1622. return option[props.textKey];
  1623. }
  1624. return option;
  1625. };
  1626. const getIndexByOffset = (offset) => clamp(Math.round(-offset / props.itemHeight), 0, count() - 1);
  1627. const momentum = (distance, duration) => {
  1628. const speed = Math.abs(distance / duration);
  1629. distance = state.offset + speed / 3e-3 * (distance < 0 ? -1 : 1);
  1630. const index = getIndexByOffset(distance);
  1631. state.duration = +props.swipeDuration;
  1632. setIndex(index, true);
  1633. };
  1634. const stopMomentum = () => {
  1635. moving = false;
  1636. state.duration = 0;
  1637. if (transitionEndTrigger) {
  1638. transitionEndTrigger();
  1639. transitionEndTrigger = null;
  1640. }
  1641. };
  1642. const onTouchStart = (event) => {
  1643. if (props.readonly) {
  1644. return;
  1645. }
  1646. touch.start(event);
  1647. if (moving) {
  1648. const translateY = getElementTranslateY(wrapper.value);
  1649. state.offset = Math.min(0, translateY - baseOffset());
  1650. startOffset = state.offset;
  1651. } else {
  1652. startOffset = state.offset;
  1653. }
  1654. state.duration = 0;
  1655. touchStartTime = Date.now();
  1656. momentumOffset = startOffset;
  1657. transitionEndTrigger = null;
  1658. };
  1659. const onTouchMove = (event) => {
  1660. if (props.readonly) {
  1661. return;
  1662. }
  1663. touch.move(event);
  1664. if (touch.isVertical()) {
  1665. moving = true;
  1666. preventDefault(event, true);
  1667. }
  1668. state.offset = clamp(startOffset + touch.deltaY.value, -(count() * props.itemHeight), props.itemHeight);
  1669. const now = Date.now();
  1670. if (now - touchStartTime > MOMENTUM_LIMIT_TIME) {
  1671. touchStartTime = now;
  1672. momentumOffset = state.offset;
  1673. }
  1674. };
  1675. const onTouchEnd = () => {
  1676. if (props.readonly) {
  1677. return;
  1678. }
  1679. const distance = state.offset - momentumOffset;
  1680. const duration = Date.now() - touchStartTime;
  1681. const allowMomentum = duration < MOMENTUM_LIMIT_TIME && Math.abs(distance) > MOMENTUM_LIMIT_DISTANCE;
  1682. if (allowMomentum) {
  1683. momentum(distance, duration);
  1684. return;
  1685. }
  1686. const index = getIndexByOffset(state.offset);
  1687. state.duration = DEFAULT_DURATION;
  1688. setIndex(index, true);
  1689. setTimeout(() => {
  1690. moving = false;
  1691. }, 0);
  1692. };
  1693. const renderOptions = () => {
  1694. const optionStyle = {
  1695. height: `${props.itemHeight}px`
  1696. };
  1697. return state.options.map((option, index) => {
  1698. const text = getOptionText(option);
  1699. const disabled = isOptionDisabled(option);
  1700. const data = {
  1701. role: "button",
  1702. style: optionStyle,
  1703. tabindex: disabled ? -1 : 0,
  1704. class: bem$1g("item", {
  1705. disabled,
  1706. selected: index === state.index
  1707. }),
  1708. onClick: () => onClickItem(index)
  1709. };
  1710. const childData = {
  1711. class: "van-ellipsis",
  1712. [props.allowHtml ? "innerHTML" : "textContent"]: text
  1713. };
  1714. return createVNode("li", data, [slots.option ? slots.option(option) : createVNode("div", childData, null)]);
  1715. });
  1716. };
  1717. const setValue = (value) => {
  1718. const {
  1719. options
  1720. } = state;
  1721. for (let i = 0; i < options.length; i++) {
  1722. if (getOptionText(options[i]) === value) {
  1723. return setIndex(i);
  1724. }
  1725. }
  1726. };
  1727. const getValue = () => state.options[state.index];
  1728. const hasOptions = () => state.options.length;
  1729. setIndex(state.index);
  1730. useParent(PICKER_KEY);
  1731. useExpose({
  1732. state,
  1733. setIndex,
  1734. getValue,
  1735. setValue,
  1736. setOptions,
  1737. hasOptions,
  1738. stopMomentum
  1739. });
  1740. watch(() => props.initialOptions, setOptions);
  1741. watch(() => props.defaultIndex, (value) => setIndex(value));
  1742. useEventListener("touchmove", onTouchMove, {
  1743. target: root
  1744. });
  1745. return () => createVNode("div", {
  1746. "ref": root,
  1747. "class": [bem$1g(), props.className],
  1748. "onTouchstartPassive": onTouchStart,
  1749. "onTouchend": onTouchEnd,
  1750. "onTouchcancel": onTouchEnd
  1751. }, [createVNode("ul", {
  1752. "ref": wrapper,
  1753. "style": {
  1754. transform: `translate3d(0, ${state.offset + baseOffset()}px, 0)`,
  1755. transitionDuration: `${state.duration}ms`,
  1756. transitionProperty: state.duration ? "all" : "none"
  1757. },
  1758. "class": bem$1g("wrapper"),
  1759. "onTransitionend": stopMomentum
  1760. }, [renderOptions()])]);
  1761. }
  1762. });
  1763. const [name$1j, bem$1f, t$j] = createNamespace("picker");
  1764. const pickerSharedProps = {
  1765. title: String,
  1766. loading: Boolean,
  1767. readonly: Boolean,
  1768. allowHtml: Boolean,
  1769. itemHeight: makeNumericProp(44),
  1770. showToolbar: truthProp,
  1771. swipeDuration: makeNumericProp(1e3),
  1772. visibleItemCount: makeNumericProp(6),
  1773. cancelButtonText: String,
  1774. confirmButtonText: String
  1775. };
  1776. const pickerProps = extend({}, pickerSharedProps, {
  1777. columns: makeArrayProp(),
  1778. valueKey: String,
  1779. defaultIndex: makeNumericProp(0),
  1780. toolbarPosition: makeStringProp("top"),
  1781. columnsFieldNames: Object
  1782. });
  1783. var stdin_default$1q = defineComponent({
  1784. name: name$1j,
  1785. props: pickerProps,
  1786. emits: ["confirm", "cancel", "change"],
  1787. setup(props, {
  1788. emit,
  1789. slots
  1790. }) {
  1791. if (process.env.NODE_ENV !== "production") {
  1792. if (slots.default) {
  1793. console.warn('[Vant] Picker: "default" slot is deprecated, please use "toolbar" slot instead.');
  1794. }
  1795. if (props.valueKey) {
  1796. console.warn('[Vant] Picker: "valueKey" prop is deprecated, please use "columnsFieldNames" prop instead.');
  1797. }
  1798. }
  1799. const hasOptions = ref(false);
  1800. const columnsRef = ref();
  1801. const formattedColumns = ref([]);
  1802. const columnsFieldNames = computed(() => {
  1803. const {
  1804. columnsFieldNames: columnsFieldNames2
  1805. } = props;
  1806. return {
  1807. text: (columnsFieldNames2 == null ? void 0 : columnsFieldNames2.text) || props.valueKey || "text",
  1808. values: (columnsFieldNames2 == null ? void 0 : columnsFieldNames2.values) || "values",
  1809. children: (columnsFieldNames2 == null ? void 0 : columnsFieldNames2.children) || "children"
  1810. };
  1811. });
  1812. const {
  1813. children,
  1814. linkChildren
  1815. } = useChildren(PICKER_KEY);
  1816. linkChildren();
  1817. const itemHeight = computed(() => unitToPx(props.itemHeight));
  1818. const dataType = computed(() => {
  1819. const firstColumn = props.columns[0];
  1820. if (typeof firstColumn === "object") {
  1821. if (columnsFieldNames.value.children in firstColumn) {
  1822. return "cascade";
  1823. }
  1824. if (columnsFieldNames.value.values in firstColumn) {
  1825. return "object";
  1826. }
  1827. }
  1828. return "plain";
  1829. });
  1830. const formatCascade = () => {
  1831. var _a;
  1832. const formatted = [];
  1833. let cursor = {
  1834. [columnsFieldNames.value.children]: props.columns
  1835. };
  1836. while (cursor && cursor[columnsFieldNames.value.children]) {
  1837. const children2 = cursor[columnsFieldNames.value.children];
  1838. let defaultIndex = (_a = cursor.defaultIndex) != null ? _a : +props.defaultIndex;
  1839. while (children2[defaultIndex] && children2[defaultIndex].disabled) {
  1840. if (defaultIndex < children2.length - 1) {
  1841. defaultIndex++;
  1842. } else {
  1843. defaultIndex = 0;
  1844. break;
  1845. }
  1846. }
  1847. formatted.push({
  1848. [columnsFieldNames.value.values]: cursor[columnsFieldNames.value.children],
  1849. className: cursor.className,
  1850. defaultIndex
  1851. });
  1852. cursor = children2[defaultIndex];
  1853. }
  1854. formattedColumns.value = formatted;
  1855. };
  1856. const format2 = () => {
  1857. const {
  1858. columns
  1859. } = props;
  1860. if (dataType.value === "plain") {
  1861. formattedColumns.value = [{
  1862. [columnsFieldNames.value.values]: columns
  1863. }];
  1864. } else if (dataType.value === "cascade") {
  1865. formatCascade();
  1866. } else {
  1867. formattedColumns.value = columns;
  1868. }
  1869. hasOptions.value = formattedColumns.value.some((item) => item[columnsFieldNames.value.values] && item[columnsFieldNames.value.values].length !== 0) || children.some((item) => item.hasOptions);
  1870. };
  1871. const getIndexes = () => children.map((child) => child.state.index);
  1872. const setColumnValues = (index, options) => {
  1873. const column = children[index];
  1874. if (column) {
  1875. column.setOptions(options);
  1876. hasOptions.value = true;
  1877. }
  1878. };
  1879. const onCascadeChange = (columnIndex) => {
  1880. let cursor = {
  1881. [columnsFieldNames.value.children]: props.columns
  1882. };
  1883. const indexes = getIndexes();
  1884. for (let i = 0; i <= columnIndex; i++) {
  1885. cursor = cursor[columnsFieldNames.value.children][indexes[i]];
  1886. }
  1887. while (cursor && cursor[columnsFieldNames.value.children]) {
  1888. columnIndex++;
  1889. setColumnValues(columnIndex, cursor[columnsFieldNames.value.children]);
  1890. cursor = cursor[columnsFieldNames.value.children][cursor.defaultIndex || 0];
  1891. }
  1892. };
  1893. const getChild = (index) => children[index];
  1894. const getColumnValue = (index) => {
  1895. const column = getChild(index);
  1896. if (column) {
  1897. return column.getValue();
  1898. }
  1899. };
  1900. const setColumnValue = (index, value) => {
  1901. const column = getChild(index);
  1902. if (column) {
  1903. column.setValue(value);
  1904. if (dataType.value === "cascade") {
  1905. onCascadeChange(index);
  1906. }
  1907. }
  1908. };
  1909. const getColumnIndex = (index) => {
  1910. const column = getChild(index);
  1911. if (column) {
  1912. return column.state.index;
  1913. }
  1914. };
  1915. const setColumnIndex = (columnIndex, optionIndex) => {
  1916. const column = getChild(columnIndex);
  1917. if (column) {
  1918. column.setIndex(optionIndex);
  1919. if (dataType.value === "cascade") {
  1920. onCascadeChange(columnIndex);
  1921. }
  1922. }
  1923. };
  1924. const getColumnValues = (index) => {
  1925. const column = getChild(index);
  1926. if (column) {
  1927. return column.state.options;
  1928. }
  1929. };
  1930. const getValues = () => children.map((child) => child.getValue());
  1931. const setValues = (values) => {
  1932. values.forEach((value, index) => {
  1933. setColumnValue(index, value);
  1934. });
  1935. };
  1936. const setIndexes = (indexes) => {
  1937. indexes.forEach((optionIndex, columnIndex) => {
  1938. setColumnIndex(columnIndex, optionIndex);
  1939. });
  1940. };
  1941. const emitAction = (event) => {
  1942. if (dataType.value === "plain") {
  1943. emit(event, getColumnValue(0), getColumnIndex(0));
  1944. } else {
  1945. emit(event, getValues(), getIndexes());
  1946. }
  1947. };
  1948. const onChange = (columnIndex) => {
  1949. if (dataType.value === "cascade") {
  1950. onCascadeChange(columnIndex);
  1951. }
  1952. if (dataType.value === "plain") {
  1953. emit("change", getColumnValue(0), getColumnIndex(0));
  1954. } else {
  1955. emit("change", getValues(), columnIndex);
  1956. }
  1957. };
  1958. const confirm = () => {
  1959. children.forEach((child) => child.stopMomentum());
  1960. emitAction("confirm");
  1961. };
  1962. const cancel = () => emitAction("cancel");
  1963. const renderTitle = () => {
  1964. if (slots.title) {
  1965. return slots.title();
  1966. }
  1967. if (props.title) {
  1968. return createVNode("div", {
  1969. "class": [bem$1f("title"), "van-ellipsis"]
  1970. }, [props.title]);
  1971. }
  1972. };
  1973. const renderCancel = () => {
  1974. const text = props.cancelButtonText || t$j("cancel");
  1975. return createVNode("button", {
  1976. "type": "button",
  1977. "class": [bem$1f("cancel"), HAPTICS_FEEDBACK],
  1978. "onClick": cancel
  1979. }, [slots.cancel ? slots.cancel() : text]);
  1980. };
  1981. const renderConfirm = () => {
  1982. const text = props.confirmButtonText || t$j("confirm");
  1983. return createVNode("button", {
  1984. "type": "button",
  1985. "class": [bem$1f("confirm"), HAPTICS_FEEDBACK],
  1986. "onClick": confirm
  1987. }, [slots.confirm ? slots.confirm() : text]);
  1988. };
  1989. const renderToolbar = () => {
  1990. if (props.showToolbar) {
  1991. const slot = slots.toolbar || slots.default;
  1992. return createVNode("div", {
  1993. "class": bem$1f("toolbar")
  1994. }, [slot ? slot() : [renderCancel(), renderTitle(), renderConfirm()]]);
  1995. }
  1996. };
  1997. const renderColumnItems = () => formattedColumns.value.map((item, columnIndex) => {
  1998. var _a;
  1999. return createVNode(stdin_default$1r, {
  2000. "textKey": columnsFieldNames.value.text,
  2001. "readonly": props.readonly,
  2002. "allowHtml": props.allowHtml,
  2003. "className": item.className,
  2004. "itemHeight": itemHeight.value,
  2005. "defaultIndex": (_a = item.defaultIndex) != null ? _a : +props.defaultIndex,
  2006. "swipeDuration": props.swipeDuration,
  2007. "initialOptions": item[columnsFieldNames.value.values],
  2008. "visibleItemCount": props.visibleItemCount,
  2009. "onChange": () => onChange(columnIndex)
  2010. }, {
  2011. option: slots.option
  2012. });
  2013. });
  2014. const renderMask = (wrapHeight) => {
  2015. if (hasOptions.value) {
  2016. const frameStyle = {
  2017. height: `${itemHeight.value}px`
  2018. };
  2019. const maskStyle = {
  2020. backgroundSize: `100% ${(wrapHeight - itemHeight.value) / 2}px`
  2021. };
  2022. return [createVNode("div", {
  2023. "class": bem$1f("mask"),
  2024. "style": maskStyle
  2025. }, null), createVNode("div", {
  2026. "class": [BORDER_UNSET_TOP_BOTTOM, bem$1f("frame")],
  2027. "style": frameStyle
  2028. }, null)];
  2029. }
  2030. };
  2031. const renderColumns = () => {
  2032. const wrapHeight = itemHeight.value * +props.visibleItemCount;
  2033. const columnsStyle = {
  2034. height: `${wrapHeight}px`
  2035. };
  2036. return createVNode("div", {
  2037. "ref": columnsRef,
  2038. "class": bem$1f("columns"),
  2039. "style": columnsStyle
  2040. }, [renderColumnItems(), renderMask(wrapHeight)]);
  2041. };
  2042. watch(() => props.columns, format2, {
  2043. immediate: true
  2044. });
  2045. useEventListener("touchmove", preventDefault, {
  2046. target: columnsRef
  2047. });
  2048. useExpose({
  2049. confirm,
  2050. getValues,
  2051. setValues,
  2052. getIndexes,
  2053. setIndexes,
  2054. getColumnIndex,
  2055. setColumnIndex,
  2056. getColumnValue,
  2057. setColumnValue,
  2058. getColumnValues,
  2059. setColumnValues
  2060. });
  2061. return () => {
  2062. var _a, _b;
  2063. return createVNode("div", {
  2064. "class": bem$1f()
  2065. }, [props.toolbarPosition === "top" ? renderToolbar() : null, props.loading ? createVNode(Loading, {
  2066. "class": bem$1f("loading")
  2067. }, null) : null, (_a = slots["columns-top"]) == null ? void 0 : _a.call(slots), renderColumns(), (_b = slots["columns-bottom"]) == null ? void 0 : _b.call(slots), props.toolbarPosition === "bottom" ? renderToolbar() : null]);
  2068. };
  2069. }
  2070. });
  2071. const Picker = withInstall(stdin_default$1q);
  2072. const [name$1i, bem$1e] = createNamespace("area");
  2073. const EMPTY_CODE = "000000";
  2074. const INHERIT_SLOTS = ["title", "cancel", "confirm", "toolbar", "columns-top", "columns-bottom"];
  2075. const INHERIT_PROPS = ["title", "loading", "readonly", "itemHeight", "swipeDuration", "visibleItemCount", "cancelButtonText", "confirmButtonText"];
  2076. const isOverseaCode = (code) => code[0] === "9";
  2077. const areaProps = extend({}, pickerSharedProps, {
  2078. value: String,
  2079. columnsNum: makeNumericProp(3),
  2080. columnsPlaceholder: makeArrayProp(),
  2081. areaList: {
  2082. type: Object,
  2083. default: () => ({})
  2084. },
  2085. isOverseaCode: {
  2086. type: Function,
  2087. default: isOverseaCode
  2088. }
  2089. });
  2090. var stdin_default$1p = defineComponent({
  2091. name: name$1i,
  2092. props: areaProps,
  2093. emits: ["change", "confirm", "cancel"],
  2094. setup(props, {
  2095. emit,
  2096. slots
  2097. }) {
  2098. const pickerRef = ref();
  2099. const state = reactive({
  2100. code: props.value,
  2101. columns: [{
  2102. values: []
  2103. }, {
  2104. values: []
  2105. }, {
  2106. values: []
  2107. }]
  2108. });
  2109. const areaList = computed(() => {
  2110. const {
  2111. areaList: areaList2
  2112. } = props;
  2113. return {
  2114. province: areaList2.province_list || {},
  2115. city: areaList2.city_list || {},
  2116. county: areaList2.county_list || {}
  2117. };
  2118. });
  2119. const placeholderMap = computed(() => {
  2120. const {
  2121. columnsPlaceholder
  2122. } = props;
  2123. return {
  2124. province: columnsPlaceholder[0] || "",
  2125. city: columnsPlaceholder[1] || "",
  2126. county: columnsPlaceholder[2] || ""
  2127. };
  2128. });
  2129. const getDefaultCode = () => {
  2130. if (props.columnsPlaceholder.length) {
  2131. return EMPTY_CODE;
  2132. }
  2133. const {
  2134. county,
  2135. city
  2136. } = areaList.value;
  2137. const countyCodes = Object.keys(county);
  2138. if (countyCodes[0]) {
  2139. return countyCodes[0];
  2140. }
  2141. const cityCodes = Object.keys(city);
  2142. if (cityCodes[0]) {
  2143. return cityCodes[0];
  2144. }
  2145. return "";
  2146. };
  2147. const getColumnValues = (type, code) => {
  2148. let column = [];
  2149. if (type !== "province" && !code) {
  2150. return column;
  2151. }
  2152. const list = areaList.value[type];
  2153. column = Object.keys(list).map((listCode) => ({
  2154. code: listCode,
  2155. name: list[listCode]
  2156. }));
  2157. if (code) {
  2158. if (type === "city" && props.isOverseaCode(code)) {
  2159. code = "9";
  2160. }
  2161. column = column.filter((item) => item.code.indexOf(code) === 0);
  2162. }
  2163. if (placeholderMap.value[type] && column.length) {
  2164. let codeFill = "";
  2165. if (type === "city") {
  2166. codeFill = EMPTY_CODE.slice(2, 4);
  2167. } else if (type === "county") {
  2168. codeFill = EMPTY_CODE.slice(4, 6);
  2169. }
  2170. column.unshift({
  2171. code: code + codeFill,
  2172. name: placeholderMap.value[type]
  2173. });
  2174. }
  2175. return column;
  2176. };
  2177. const getIndex = (type, code) => {
  2178. let compareNum = code.length;
  2179. if (type === "province") {
  2180. compareNum = props.isOverseaCode(code) ? 1 : 2;
  2181. }
  2182. if (type === "city") {
  2183. compareNum = 4;
  2184. }
  2185. code = code.slice(0, compareNum);
  2186. const list = getColumnValues(type, compareNum > 2 ? code.slice(0, compareNum - 2) : "");
  2187. for (let i = 0; i < list.length; i++) {
  2188. if (list[i].code.slice(0, compareNum) === code) {
  2189. return i;
  2190. }
  2191. }
  2192. return 0;
  2193. };
  2194. const setValues = () => {
  2195. const picker = pickerRef.value;
  2196. if (!picker) {
  2197. return;
  2198. }
  2199. let code = state.code || getDefaultCode();
  2200. const province = getColumnValues("province");
  2201. const city = getColumnValues("city", code.slice(0, 2));
  2202. picker.setColumnValues(0, province);
  2203. picker.setColumnValues(1, city);
  2204. if (city.length && code.slice(2, 4) === "00" && !props.isOverseaCode(code)) {
  2205. [{
  2206. code
  2207. }] = city;
  2208. }
  2209. picker.setColumnValues(2, getColumnValues("county", code.slice(0, 4)));
  2210. picker.setIndexes([getIndex("province", code), getIndex("city", code), getIndex("county", code)]);
  2211. };
  2212. const parseValues = (values) => values.map((value, index) => {
  2213. if (value) {
  2214. value = deepClone(value);
  2215. if (!value.code || value.name === props.columnsPlaceholder[index]) {
  2216. value.code = "";
  2217. value.name = "";
  2218. }
  2219. }
  2220. return value;
  2221. });
  2222. const getValues = () => {
  2223. if (pickerRef.value) {
  2224. const values = pickerRef.value.getValues().filter(Boolean);
  2225. return parseValues(values);
  2226. }
  2227. return [];
  2228. };
  2229. const getArea = () => {
  2230. const values = getValues();
  2231. const area = {
  2232. code: "",
  2233. country: "",
  2234. province: "",
  2235. city: "",
  2236. county: ""
  2237. };
  2238. if (!values.length) {
  2239. return area;
  2240. }
  2241. const names = values.map((item) => item.name);
  2242. const validValues = values.filter((value) => value.code);
  2243. area.code = validValues.length ? validValues[validValues.length - 1].code : "";
  2244. if (props.isOverseaCode(area.code)) {
  2245. area.country = names[1] || "";
  2246. area.province = names[2] || "";
  2247. } else {
  2248. area.province = names[0] || "";
  2249. area.city = names[1] || "";
  2250. area.county = names[2] || "";
  2251. }
  2252. return area;
  2253. };
  2254. const reset = (newCode = "") => {
  2255. state.code = newCode;
  2256. setValues();
  2257. };
  2258. const onChange = (values, index) => {
  2259. state.code = values[index].code;
  2260. setValues();
  2261. if (pickerRef.value) {
  2262. const parsedValues = parseValues(pickerRef.value.getValues());
  2263. emit("change", parsedValues, index);
  2264. }
  2265. };
  2266. const onConfirm = (values, index) => {
  2267. setValues();
  2268. emit("confirm", parseValues(values), index);
  2269. };
  2270. const onCancel = (...args) => emit("cancel", ...args);
  2271. onMounted(setValues);
  2272. watch(() => props.value, (value) => {
  2273. state.code = value;
  2274. setValues();
  2275. });
  2276. watch(() => props.areaList, setValues, {
  2277. deep: true
  2278. });
  2279. watch(() => props.columnsNum, () => {
  2280. nextTick(setValues);
  2281. });
  2282. useExpose({
  2283. reset,
  2284. getArea,
  2285. getValues
  2286. });
  2287. return () => {
  2288. const columns = state.columns.slice(0, +props.columnsNum);
  2289. return createVNode(Picker, mergeProps({
  2290. "ref": pickerRef,
  2291. "class": bem$1e(),
  2292. "columns": columns,
  2293. "columnsFieldNames": {
  2294. text: "name"
  2295. },
  2296. "onChange": onChange,
  2297. "onCancel": onCancel,
  2298. "onConfirm": onConfirm
  2299. }, pick(props, INHERIT_PROPS)), pick(slots, INHERIT_SLOTS));
  2300. };
  2301. }
  2302. });
  2303. const Area = withInstall(stdin_default$1p);
  2304. const [name$1h, bem$1d] = createNamespace("cell");
  2305. const cellSharedProps = {
  2306. icon: String,
  2307. size: String,
  2308. title: numericProp,
  2309. value: numericProp,
  2310. label: numericProp,
  2311. center: Boolean,
  2312. isLink: Boolean,
  2313. border: truthProp,
  2314. required: Boolean,
  2315. iconPrefix: String,
  2316. valueClass: unknownProp,
  2317. labelClass: unknownProp,
  2318. titleClass: unknownProp,
  2319. titleStyle: null,
  2320. arrowDirection: String,
  2321. clickable: {
  2322. type: Boolean,
  2323. default: null
  2324. }
  2325. };
  2326. const cellProps = extend({}, cellSharedProps, routeProps);
  2327. var stdin_default$1o = defineComponent({
  2328. name: name$1h,
  2329. props: cellProps,
  2330. setup(props, {
  2331. slots
  2332. }) {
  2333. const route2 = useRoute();
  2334. const renderLabel = () => {
  2335. const showLabel = slots.label || isDef(props.label);
  2336. if (showLabel) {
  2337. return createVNode("div", {
  2338. "class": [bem$1d("label"), props.labelClass]
  2339. }, [slots.label ? slots.label() : props.label]);
  2340. }
  2341. };
  2342. const renderTitle = () => {
  2343. if (slots.title || isDef(props.title)) {
  2344. return createVNode("div", {
  2345. "class": [bem$1d("title"), props.titleClass],
  2346. "style": props.titleStyle
  2347. }, [slots.title ? slots.title() : createVNode("span", null, [props.title]), renderLabel()]);
  2348. }
  2349. };
  2350. const renderValue = () => {
  2351. const slot = slots.value || slots.default;
  2352. const hasValue = slot || isDef(props.value);
  2353. if (hasValue) {
  2354. const hasTitle = slots.title || isDef(props.title);
  2355. return createVNode("div", {
  2356. "class": [bem$1d("value", {
  2357. alone: !hasTitle
  2358. }), props.valueClass]
  2359. }, [slot ? slot() : createVNode("span", null, [props.value])]);
  2360. }
  2361. };
  2362. const renderLeftIcon = () => {
  2363. if (slots.icon) {
  2364. return slots.icon();
  2365. }
  2366. if (props.icon) {
  2367. return createVNode(Icon, {
  2368. "name": props.icon,
  2369. "class": bem$1d("left-icon"),
  2370. "classPrefix": props.iconPrefix
  2371. }, null);
  2372. }
  2373. };
  2374. const renderRightIcon = () => {
  2375. if (slots["right-icon"]) {
  2376. return slots["right-icon"]();
  2377. }
  2378. if (props.isLink) {
  2379. const name2 = props.arrowDirection && props.arrowDirection !== "right" ? `arrow-${props.arrowDirection}` : "arrow";
  2380. return createVNode(Icon, {
  2381. "name": name2,
  2382. "class": bem$1d("right-icon")
  2383. }, null);
  2384. }
  2385. };
  2386. return () => {
  2387. var _a, _b;
  2388. const {
  2389. size,
  2390. center,
  2391. border,
  2392. isLink,
  2393. required
  2394. } = props;
  2395. const clickable = (_a = props.clickable) != null ? _a : isLink;
  2396. const classes = {
  2397. center,
  2398. required,
  2399. clickable,
  2400. borderless: !border
  2401. };
  2402. if (size) {
  2403. classes[size] = !!size;
  2404. }
  2405. return createVNode("div", {
  2406. "class": bem$1d(classes),
  2407. "role": clickable ? "button" : void 0,
  2408. "tabindex": clickable ? 0 : void 0,
  2409. "onClick": route2
  2410. }, [renderLeftIcon(), renderTitle(), renderValue(), renderRightIcon(), (_b = slots.extra) == null ? void 0 : _b.call(slots)]);
  2411. };
  2412. }
  2413. });
  2414. const Cell = withInstall(stdin_default$1o);
  2415. const [name$1g, bem$1c] = createNamespace("form");
  2416. const formProps = {
  2417. colon: Boolean,
  2418. disabled: Boolean,
  2419. readonly: Boolean,
  2420. showError: Boolean,
  2421. labelWidth: numericProp,
  2422. labelAlign: String,
  2423. inputAlign: String,
  2424. scrollToError: Boolean,
  2425. validateFirst: Boolean,
  2426. submitOnEnter: truthProp,
  2427. showErrorMessage: truthProp,
  2428. errorMessageAlign: String,
  2429. validateTrigger: {
  2430. type: [String, Array],
  2431. default: "onBlur"
  2432. }
  2433. };
  2434. var stdin_default$1n = defineComponent({
  2435. name: name$1g,
  2436. props: formProps,
  2437. emits: ["submit", "failed"],
  2438. setup(props, {
  2439. emit,
  2440. slots
  2441. }) {
  2442. const {
  2443. children,
  2444. linkChildren
  2445. } = useChildren(FORM_KEY);
  2446. const getFieldsByNames = (names) => {
  2447. if (names) {
  2448. return children.filter((field) => names.includes(field.name));
  2449. }
  2450. return children;
  2451. };
  2452. const validateSeq = (names) => new Promise((resolve, reject) => {
  2453. const errors = [];
  2454. const fields = getFieldsByNames(names);
  2455. fields.reduce((promise, field) => promise.then(() => {
  2456. if (!errors.length) {
  2457. return field.validate().then((error) => {
  2458. if (error) {
  2459. errors.push(error);
  2460. }
  2461. });
  2462. }
  2463. }), Promise.resolve()).then(() => {
  2464. if (errors.length) {
  2465. reject(errors);
  2466. } else {
  2467. resolve();
  2468. }
  2469. });
  2470. });
  2471. const validateAll = (names) => new Promise((resolve, reject) => {
  2472. const fields = getFieldsByNames(names);
  2473. Promise.all(fields.map((item) => item.validate())).then((errors) => {
  2474. errors = errors.filter(Boolean);
  2475. if (errors.length) {
  2476. reject(errors);
  2477. } else {
  2478. resolve();
  2479. }
  2480. });
  2481. });
  2482. const validateField = (name2) => {
  2483. const matched = children.find((item) => item.name === name2);
  2484. if (matched) {
  2485. return new Promise((resolve, reject) => {
  2486. matched.validate().then((error) => {
  2487. if (error) {
  2488. reject(error);
  2489. } else {
  2490. resolve();
  2491. }
  2492. });
  2493. });
  2494. }
  2495. return Promise.reject();
  2496. };
  2497. const validate = (name2) => {
  2498. if (typeof name2 === "string") {
  2499. return validateField(name2);
  2500. }
  2501. return props.validateFirst ? validateSeq(name2) : validateAll(name2);
  2502. };
  2503. const resetValidation = (name2) => {
  2504. if (typeof name2 === "string") {
  2505. name2 = [name2];
  2506. }
  2507. const fields = getFieldsByNames(name2);
  2508. fields.forEach((item) => {
  2509. item.resetValidation();
  2510. });
  2511. };
  2512. const getValidationStatus = () => children.reduce((form, field) => {
  2513. form[field.name] = field.getValidationStatus();
  2514. return form;
  2515. }, {});
  2516. const scrollToField = (name2, options) => {
  2517. children.some((item) => {
  2518. if (item.name === name2) {
  2519. item.$el.scrollIntoView(options);
  2520. return true;
  2521. }
  2522. return false;
  2523. });
  2524. };
  2525. const getValues = () => children.reduce((form, field) => {
  2526. form[field.name] = field.formValue.value;
  2527. return form;
  2528. }, {});
  2529. const submit = () => {
  2530. const values = getValues();
  2531. validate().then(() => emit("submit", values)).catch((errors) => {
  2532. emit("failed", {
  2533. values,
  2534. errors
  2535. });
  2536. if (props.scrollToError && errors[0].name) {
  2537. scrollToField(errors[0].name);
  2538. }
  2539. });
  2540. };
  2541. const onSubmit = (event) => {
  2542. preventDefault(event);
  2543. submit();
  2544. };
  2545. linkChildren({
  2546. props
  2547. });
  2548. useExpose({
  2549. submit,
  2550. validate,
  2551. getValues,
  2552. scrollToField,
  2553. resetValidation,
  2554. getValidationStatus
  2555. });
  2556. return () => {
  2557. var _a;
  2558. return createVNode("form", {
  2559. "class": bem$1c(),
  2560. "onSubmit": onSubmit
  2561. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  2562. };
  2563. }
  2564. });
  2565. const Form = withInstall(stdin_default$1n);
  2566. function isEmptyValue(value) {
  2567. if (Array.isArray(value)) {
  2568. return !value.length;
  2569. }
  2570. if (value === 0) {
  2571. return false;
  2572. }
  2573. return !value;
  2574. }
  2575. function runSyncRule(value, rule) {
  2576. if (isEmptyValue(value)) {
  2577. if (rule.required) {
  2578. return false;
  2579. }
  2580. if (rule.validateEmpty === false) {
  2581. return true;
  2582. }
  2583. }
  2584. if (rule.pattern && !rule.pattern.test(String(value))) {
  2585. return false;
  2586. }
  2587. return true;
  2588. }
  2589. function runRuleValidator(value, rule) {
  2590. return new Promise((resolve) => {
  2591. const returnVal = rule.validator(value, rule);
  2592. if (isPromise(returnVal)) {
  2593. returnVal.then(resolve);
  2594. return;
  2595. }
  2596. resolve(returnVal);
  2597. });
  2598. }
  2599. function getRuleMessage(value, rule) {
  2600. const { message } = rule;
  2601. if (isFunction(message)) {
  2602. return message(value, rule);
  2603. }
  2604. return message || "";
  2605. }
  2606. function startComposing({ target }) {
  2607. target.composing = true;
  2608. }
  2609. function endComposing({ target }) {
  2610. if (target.composing) {
  2611. target.composing = false;
  2612. target.dispatchEvent(new Event("input"));
  2613. }
  2614. }
  2615. function resizeTextarea(input, autosize) {
  2616. const scrollTop = getRootScrollTop();
  2617. input.style.height = "auto";
  2618. let height = input.scrollHeight;
  2619. if (isObject(autosize)) {
  2620. const { maxHeight, minHeight } = autosize;
  2621. if (maxHeight !== void 0) {
  2622. height = Math.min(height, maxHeight);
  2623. }
  2624. if (minHeight !== void 0) {
  2625. height = Math.max(height, minHeight);
  2626. }
  2627. }
  2628. if (height) {
  2629. input.style.height = `${height}px`;
  2630. setRootScrollTop(scrollTop);
  2631. }
  2632. }
  2633. function mapInputType(type) {
  2634. if (type === "number") {
  2635. return {
  2636. type: "text",
  2637. inputmode: "decimal"
  2638. };
  2639. }
  2640. if (type === "digit") {
  2641. return {
  2642. type: "tel",
  2643. inputmode: "numeric"
  2644. };
  2645. }
  2646. return { type };
  2647. }
  2648. function getStringLength(str) {
  2649. return [...str].length;
  2650. }
  2651. function cutString(str, maxlength) {
  2652. return [...str].slice(0, maxlength).join("");
  2653. }
  2654. let current = 0;
  2655. function useId() {
  2656. const vm = getCurrentInstance();
  2657. const { name: name2 = "unknown" } = (vm == null ? void 0 : vm.type) || {};
  2658. if (process.env.NODE_ENV === "test") {
  2659. return name2;
  2660. }
  2661. return `${name2}-${++current}`;
  2662. }
  2663. const [name$1f, bem$1b] = createNamespace("field");
  2664. const fieldSharedProps = {
  2665. id: String,
  2666. name: String,
  2667. leftIcon: String,
  2668. rightIcon: String,
  2669. autofocus: Boolean,
  2670. clearable: Boolean,
  2671. maxlength: numericProp,
  2672. formatter: Function,
  2673. clearIcon: makeStringProp("clear"),
  2674. modelValue: makeNumericProp(""),
  2675. inputAlign: String,
  2676. placeholder: String,
  2677. autocomplete: String,
  2678. errorMessage: String,
  2679. enterkeyhint: String,
  2680. clearTrigger: makeStringProp("focus"),
  2681. formatTrigger: makeStringProp("onChange"),
  2682. error: {
  2683. type: Boolean,
  2684. default: null
  2685. },
  2686. disabled: {
  2687. type: Boolean,
  2688. default: null
  2689. },
  2690. readonly: {
  2691. type: Boolean,
  2692. default: null
  2693. }
  2694. };
  2695. const fieldProps = extend({}, cellSharedProps, fieldSharedProps, {
  2696. rows: numericProp,
  2697. type: makeStringProp("text"),
  2698. rules: Array,
  2699. autosize: [Boolean, Object],
  2700. labelWidth: numericProp,
  2701. labelClass: unknownProp,
  2702. labelAlign: String,
  2703. showWordLimit: Boolean,
  2704. errorMessageAlign: String,
  2705. colon: {
  2706. type: Boolean,
  2707. default: null
  2708. }
  2709. });
  2710. var stdin_default$1m = defineComponent({
  2711. name: name$1f,
  2712. props: fieldProps,
  2713. emits: ["blur", "focus", "clear", "keypress", "click-input", "end-validate", "start-validate", "click-left-icon", "click-right-icon", "update:modelValue"],
  2714. setup(props, {
  2715. emit,
  2716. slots
  2717. }) {
  2718. const id = useId();
  2719. const state = reactive({
  2720. status: "unvalidated",
  2721. focused: false,
  2722. validateMessage: ""
  2723. });
  2724. const inputRef = ref();
  2725. const clearIconRef = ref();
  2726. const customValue = ref();
  2727. const {
  2728. parent: form
  2729. } = useParent(FORM_KEY);
  2730. const getModelValue = () => {
  2731. var _a;
  2732. return String((_a = props.modelValue) != null ? _a : "");
  2733. };
  2734. const getProp = (key) => {
  2735. if (isDef(props[key])) {
  2736. return props[key];
  2737. }
  2738. if (form && isDef(form.props[key])) {
  2739. return form.props[key];
  2740. }
  2741. };
  2742. const showClear = computed(() => {
  2743. const readonly = getProp("readonly");
  2744. if (props.clearable && !readonly) {
  2745. const hasValue = getModelValue() !== "";
  2746. const trigger = props.clearTrigger === "always" || props.clearTrigger === "focus" && state.focused;
  2747. return hasValue && trigger;
  2748. }
  2749. return false;
  2750. });
  2751. const formValue = computed(() => {
  2752. if (customValue.value && slots.input) {
  2753. return customValue.value();
  2754. }
  2755. return props.modelValue;
  2756. });
  2757. const runRules = (rules) => rules.reduce((promise, rule) => promise.then(() => {
  2758. if (state.status === "failed") {
  2759. return;
  2760. }
  2761. let {
  2762. value
  2763. } = formValue;
  2764. if (rule.formatter) {
  2765. value = rule.formatter(value, rule);
  2766. }
  2767. if (!runSyncRule(value, rule)) {
  2768. state.status = "failed";
  2769. state.validateMessage = getRuleMessage(value, rule);
  2770. return;
  2771. }
  2772. if (rule.validator) {
  2773. if (isEmptyValue(value) && rule.validateEmpty === false) {
  2774. return;
  2775. }
  2776. return runRuleValidator(value, rule).then((result) => {
  2777. if (result && typeof result === "string") {
  2778. state.status = "failed";
  2779. state.validateMessage = result;
  2780. } else if (result === false) {
  2781. state.status = "failed";
  2782. state.validateMessage = getRuleMessage(value, rule);
  2783. }
  2784. });
  2785. }
  2786. }), Promise.resolve());
  2787. const resetValidation = () => {
  2788. state.status = "unvalidated";
  2789. state.validateMessage = "";
  2790. };
  2791. const endValidate = () => emit("end-validate", {
  2792. status: state.status
  2793. });
  2794. const validate = (rules = props.rules) => new Promise((resolve) => {
  2795. resetValidation();
  2796. if (rules) {
  2797. emit("start-validate");
  2798. runRules(rules).then(() => {
  2799. if (state.status === "failed") {
  2800. resolve({
  2801. name: props.name,
  2802. message: state.validateMessage
  2803. });
  2804. endValidate();
  2805. } else {
  2806. state.status = "passed";
  2807. resolve();
  2808. endValidate();
  2809. }
  2810. });
  2811. } else {
  2812. resolve();
  2813. }
  2814. });
  2815. const validateWithTrigger = (trigger) => {
  2816. if (form && props.rules) {
  2817. const {
  2818. validateTrigger
  2819. } = form.props;
  2820. const defaultTrigger = toArray(validateTrigger).includes(trigger);
  2821. const rules = props.rules.filter((rule) => {
  2822. if (rule.trigger) {
  2823. return toArray(rule.trigger).includes(trigger);
  2824. }
  2825. return defaultTrigger;
  2826. });
  2827. if (rules.length) {
  2828. validate(rules);
  2829. }
  2830. }
  2831. };
  2832. const limitValueLength = (value) => {
  2833. const {
  2834. maxlength
  2835. } = props;
  2836. if (isDef(maxlength) && getStringLength(value) > maxlength) {
  2837. const modelValue = getModelValue();
  2838. if (modelValue && getStringLength(modelValue) === +maxlength) {
  2839. return modelValue;
  2840. }
  2841. return cutString(value, +maxlength);
  2842. }
  2843. return value;
  2844. };
  2845. const updateValue = (value, trigger = "onChange") => {
  2846. const originalValue = value;
  2847. value = limitValueLength(value);
  2848. const isExceedLimit = value !== originalValue;
  2849. if (props.type === "number" || props.type === "digit") {
  2850. const isNumber = props.type === "number";
  2851. value = formatNumber(value, isNumber, isNumber);
  2852. }
  2853. if (props.formatter && trigger === props.formatTrigger) {
  2854. value = props.formatter(value);
  2855. }
  2856. if (inputRef.value && inputRef.value.value !== value) {
  2857. if (state.focused && isExceedLimit) {
  2858. const {
  2859. selectionStart,
  2860. selectionEnd
  2861. } = inputRef.value;
  2862. inputRef.value.value = value;
  2863. inputRef.value.setSelectionRange(selectionStart - 1, selectionEnd - 1);
  2864. } else {
  2865. inputRef.value.value = value;
  2866. }
  2867. }
  2868. if (value !== props.modelValue) {
  2869. emit("update:modelValue", value);
  2870. }
  2871. };
  2872. const onInput = (event) => {
  2873. if (!event.target.composing) {
  2874. updateValue(event.target.value);
  2875. }
  2876. };
  2877. const blur = () => {
  2878. var _a;
  2879. return (_a = inputRef.value) == null ? void 0 : _a.blur();
  2880. };
  2881. const focus = () => {
  2882. var _a;
  2883. return (_a = inputRef.value) == null ? void 0 : _a.focus();
  2884. };
  2885. const adjustTextareaSize = () => {
  2886. const input = inputRef.value;
  2887. if (props.type === "textarea" && props.autosize && input) {
  2888. resizeTextarea(input, props.autosize);
  2889. }
  2890. };
  2891. const onFocus = (event) => {
  2892. state.focused = true;
  2893. emit("focus", event);
  2894. nextTick(adjustTextareaSize);
  2895. if (getProp("readonly")) {
  2896. blur();
  2897. }
  2898. };
  2899. const onBlur = (event) => {
  2900. if (getProp("readonly")) {
  2901. return;
  2902. }
  2903. state.focused = false;
  2904. updateValue(getModelValue(), "onBlur");
  2905. emit("blur", event);
  2906. validateWithTrigger("onBlur");
  2907. nextTick(adjustTextareaSize);
  2908. resetScroll();
  2909. };
  2910. const onClickInput = (event) => emit("click-input", event);
  2911. const onClickLeftIcon = (event) => emit("click-left-icon", event);
  2912. const onClickRightIcon = (event) => emit("click-right-icon", event);
  2913. const onClear = (event) => {
  2914. preventDefault(event);
  2915. emit("update:modelValue", "");
  2916. emit("clear", event);
  2917. };
  2918. const showError = computed(() => {
  2919. if (typeof props.error === "boolean") {
  2920. return props.error;
  2921. }
  2922. if (form && form.props.showError && state.status === "failed") {
  2923. return true;
  2924. }
  2925. });
  2926. const labelStyle = computed(() => {
  2927. const labelWidth = getProp("labelWidth");
  2928. if (labelWidth) {
  2929. return {
  2930. width: addUnit(labelWidth)
  2931. };
  2932. }
  2933. });
  2934. const onKeypress = (event) => {
  2935. const ENTER_CODE = 13;
  2936. if (event.keyCode === ENTER_CODE) {
  2937. const submitOnEnter = form && form.props.submitOnEnter;
  2938. if (!submitOnEnter && props.type !== "textarea") {
  2939. preventDefault(event);
  2940. }
  2941. if (props.type === "search") {
  2942. blur();
  2943. }
  2944. }
  2945. emit("keypress", event);
  2946. };
  2947. const getInputId = () => props.id || `${id}-input`;
  2948. const getValidationStatus = () => state.status;
  2949. const renderInput = () => {
  2950. const controlClass = bem$1b("control", [getProp("inputAlign"), {
  2951. error: showError.value,
  2952. custom: !!slots.input,
  2953. "min-height": props.type === "textarea" && !props.autosize
  2954. }]);
  2955. if (slots.input) {
  2956. return createVNode("div", {
  2957. "class": controlClass,
  2958. "onClick": onClickInput
  2959. }, [slots.input()]);
  2960. }
  2961. const inputAttrs = {
  2962. id: getInputId(),
  2963. ref: inputRef,
  2964. name: props.name,
  2965. rows: props.rows !== void 0 ? +props.rows : void 0,
  2966. class: controlClass,
  2967. disabled: getProp("disabled"),
  2968. readonly: getProp("readonly"),
  2969. autofocus: props.autofocus,
  2970. placeholder: props.placeholder,
  2971. autocomplete: props.autocomplete,
  2972. enterkeyhint: props.enterkeyhint,
  2973. "aria-labelledby": props.label ? `${id}-label` : void 0,
  2974. onBlur,
  2975. onFocus,
  2976. onInput,
  2977. onClick: onClickInput,
  2978. onChange: endComposing,
  2979. onKeypress,
  2980. onCompositionend: endComposing,
  2981. onCompositionstart: startComposing
  2982. };
  2983. if (props.type === "textarea") {
  2984. return createVNode("textarea", inputAttrs, null);
  2985. }
  2986. return createVNode("input", mergeProps(mapInputType(props.type), inputAttrs), null);
  2987. };
  2988. const renderLeftIcon = () => {
  2989. const leftIconSlot = slots["left-icon"];
  2990. if (props.leftIcon || leftIconSlot) {
  2991. return createVNode("div", {
  2992. "class": bem$1b("left-icon"),
  2993. "onClick": onClickLeftIcon
  2994. }, [leftIconSlot ? leftIconSlot() : createVNode(Icon, {
  2995. "name": props.leftIcon,
  2996. "classPrefix": props.iconPrefix
  2997. }, null)]);
  2998. }
  2999. };
  3000. const renderRightIcon = () => {
  3001. const rightIconSlot = slots["right-icon"];
  3002. if (props.rightIcon || rightIconSlot) {
  3003. return createVNode("div", {
  3004. "class": bem$1b("right-icon"),
  3005. "onClick": onClickRightIcon
  3006. }, [rightIconSlot ? rightIconSlot() : createVNode(Icon, {
  3007. "name": props.rightIcon,
  3008. "classPrefix": props.iconPrefix
  3009. }, null)]);
  3010. }
  3011. };
  3012. const renderWordLimit = () => {
  3013. if (props.showWordLimit && props.maxlength) {
  3014. const count = getStringLength(getModelValue());
  3015. return createVNode("div", {
  3016. "class": bem$1b("word-limit")
  3017. }, [createVNode("span", {
  3018. "class": bem$1b("word-num")
  3019. }, [count]), createTextVNode("/"), props.maxlength]);
  3020. }
  3021. };
  3022. const renderMessage = () => {
  3023. if (form && form.props.showErrorMessage === false) {
  3024. return;
  3025. }
  3026. const message = props.errorMessage || state.validateMessage;
  3027. if (message) {
  3028. const slot = slots["error-message"];
  3029. const errorMessageAlign = getProp("errorMessageAlign");
  3030. return createVNode("div", {
  3031. "class": bem$1b("error-message", errorMessageAlign)
  3032. }, [slot ? slot({
  3033. message
  3034. }) : message]);
  3035. }
  3036. };
  3037. const renderLabel = () => {
  3038. const colon = getProp("colon") ? ":" : "";
  3039. if (slots.label) {
  3040. return [slots.label(), colon];
  3041. }
  3042. if (props.label) {
  3043. return createVNode("label", {
  3044. "id": `${id}-label`,
  3045. "for": getInputId()
  3046. }, [props.label + colon]);
  3047. }
  3048. };
  3049. const renderFieldBody = () => [createVNode("div", {
  3050. "class": bem$1b("body")
  3051. }, [renderInput(), showClear.value && createVNode(Icon, {
  3052. "ref": clearIconRef,
  3053. "name": props.clearIcon,
  3054. "class": bem$1b("clear")
  3055. }, null), renderRightIcon(), slots.button && createVNode("div", {
  3056. "class": bem$1b("button")
  3057. }, [slots.button()])]), renderWordLimit(), renderMessage()];
  3058. useExpose({
  3059. blur,
  3060. focus,
  3061. validate,
  3062. formValue,
  3063. resetValidation,
  3064. getValidationStatus
  3065. });
  3066. provide(CUSTOM_FIELD_INJECTION_KEY, {
  3067. customValue,
  3068. resetValidation,
  3069. validateWithTrigger
  3070. });
  3071. watch(() => props.modelValue, () => {
  3072. updateValue(getModelValue());
  3073. resetValidation();
  3074. validateWithTrigger("onChange");
  3075. nextTick(adjustTextareaSize);
  3076. });
  3077. onMounted(() => {
  3078. updateValue(getModelValue(), props.formatTrigger);
  3079. nextTick(adjustTextareaSize);
  3080. });
  3081. useEventListener("touchstart", onClear, {
  3082. target: computed(() => {
  3083. var _a;
  3084. return (_a = clearIconRef.value) == null ? void 0 : _a.$el;
  3085. })
  3086. });
  3087. return () => {
  3088. const disabled = getProp("disabled");
  3089. const labelAlign = getProp("labelAlign");
  3090. const Label = renderLabel();
  3091. const LeftIcon = renderLeftIcon();
  3092. return createVNode(Cell, {
  3093. "size": props.size,
  3094. "icon": props.leftIcon,
  3095. "class": bem$1b({
  3096. error: showError.value,
  3097. disabled,
  3098. [`label-${labelAlign}`]: labelAlign
  3099. }),
  3100. "center": props.center,
  3101. "border": props.border,
  3102. "isLink": props.isLink,
  3103. "clickable": props.clickable,
  3104. "titleStyle": labelStyle.value,
  3105. "valueClass": bem$1b("value"),
  3106. "titleClass": [bem$1b("label", [labelAlign, {
  3107. required: props.required
  3108. }]), props.labelClass],
  3109. "arrowDirection": props.arrowDirection
  3110. }, {
  3111. icon: LeftIcon ? () => LeftIcon : null,
  3112. title: Label ? () => Label : null,
  3113. value: renderFieldBody,
  3114. extra: slots.extra
  3115. });
  3116. };
  3117. }
  3118. });
  3119. const Field = withInstall(stdin_default$1m);
  3120. function usePopupState() {
  3121. const state = reactive({
  3122. show: false
  3123. });
  3124. const toggle = (show) => {
  3125. state.show = show;
  3126. };
  3127. const open = (props) => {
  3128. extend(state, props, { transitionAppear: true });
  3129. toggle(true);
  3130. };
  3131. const close = () => toggle(false);
  3132. useExpose({ open, close, toggle });
  3133. return {
  3134. open,
  3135. close,
  3136. state,
  3137. toggle
  3138. };
  3139. }
  3140. function mountComponent(RootComponent) {
  3141. const app = createApp(RootComponent);
  3142. const root = document.createElement("div");
  3143. document.body.appendChild(root);
  3144. return {
  3145. instance: app.mount(root),
  3146. unmount() {
  3147. app.unmount();
  3148. document.body.removeChild(root);
  3149. }
  3150. };
  3151. }
  3152. let lockCount = 0;
  3153. function lockClick(lock) {
  3154. if (lock) {
  3155. if (!lockCount) {
  3156. document.body.classList.add("van-toast--unclickable");
  3157. }
  3158. lockCount++;
  3159. } else if (lockCount) {
  3160. lockCount--;
  3161. if (!lockCount) {
  3162. document.body.classList.remove("van-toast--unclickable");
  3163. }
  3164. }
  3165. }
  3166. const [name$1e, bem$1a] = createNamespace("toast");
  3167. const popupInheritProps = ["show", "overlay", "teleport", "transition", "overlayClass", "overlayStyle", "closeOnClickOverlay"];
  3168. const toastProps = {
  3169. icon: String,
  3170. show: Boolean,
  3171. type: makeStringProp("text"),
  3172. overlay: Boolean,
  3173. message: numericProp,
  3174. iconSize: numericProp,
  3175. duration: makeNumberProp(2e3),
  3176. position: makeStringProp("middle"),
  3177. teleport: [String, Object],
  3178. className: unknownProp,
  3179. iconPrefix: String,
  3180. transition: makeStringProp("van-fade"),
  3181. loadingType: String,
  3182. forbidClick: Boolean,
  3183. overlayClass: unknownProp,
  3184. overlayStyle: Object,
  3185. closeOnClick: Boolean,
  3186. closeOnClickOverlay: Boolean
  3187. };
  3188. var stdin_default$1l = defineComponent({
  3189. name: name$1e,
  3190. props: toastProps,
  3191. emits: ["update:show"],
  3192. setup(props, {
  3193. emit
  3194. }) {
  3195. let timer2;
  3196. let clickable = false;
  3197. const toggleClickable = () => {
  3198. const newValue = props.show && props.forbidClick;
  3199. if (clickable !== newValue) {
  3200. clickable = newValue;
  3201. lockClick(clickable);
  3202. }
  3203. };
  3204. const updateShow = (show) => emit("update:show", show);
  3205. const onClick = () => {
  3206. if (props.closeOnClick) {
  3207. updateShow(false);
  3208. }
  3209. };
  3210. const clearTimer = () => clearTimeout(timer2);
  3211. const renderIcon = () => {
  3212. const {
  3213. icon,
  3214. type,
  3215. iconSize,
  3216. iconPrefix,
  3217. loadingType
  3218. } = props;
  3219. const hasIcon = icon || type === "success" || type === "fail";
  3220. if (hasIcon) {
  3221. return createVNode(Icon, {
  3222. "name": icon || type,
  3223. "size": iconSize,
  3224. "class": bem$1a("icon"),
  3225. "classPrefix": iconPrefix
  3226. }, null);
  3227. }
  3228. if (type === "loading") {
  3229. return createVNode(Loading, {
  3230. "class": bem$1a("loading"),
  3231. "size": iconSize,
  3232. "type": loadingType
  3233. }, null);
  3234. }
  3235. };
  3236. const renderMessage = () => {
  3237. const {
  3238. type,
  3239. message
  3240. } = props;
  3241. if (isDef(message) && message !== "") {
  3242. return type === "html" ? createVNode("div", {
  3243. "key": 0,
  3244. "class": bem$1a("text"),
  3245. "innerHTML": String(message)
  3246. }, null) : createVNode("div", {
  3247. "class": bem$1a("text")
  3248. }, [message]);
  3249. }
  3250. };
  3251. watch(() => [props.show, props.forbidClick], toggleClickable);
  3252. watch(() => [props.show, props.type, props.message, props.duration], () => {
  3253. clearTimer();
  3254. if (props.show && props.duration > 0) {
  3255. timer2 = setTimeout(() => {
  3256. updateShow(false);
  3257. }, props.duration);
  3258. }
  3259. });
  3260. onMounted(toggleClickable);
  3261. onUnmounted(toggleClickable);
  3262. return () => createVNode(Popup, mergeProps({
  3263. "class": [bem$1a([props.position, {
  3264. [props.type]: !props.icon
  3265. }]), props.className],
  3266. "lockScroll": false,
  3267. "onClick": onClick,
  3268. "onClosed": clearTimer,
  3269. "onUpdate:show": updateShow
  3270. }, pick(props, popupInheritProps)), {
  3271. default: () => [renderIcon(), renderMessage()]
  3272. });
  3273. }
  3274. });
  3275. const defaultOptions$1 = {
  3276. icon: "",
  3277. type: "text",
  3278. message: "",
  3279. className: "",
  3280. overlay: false,
  3281. onClose: void 0,
  3282. onOpened: void 0,
  3283. duration: 2e3,
  3284. teleport: "body",
  3285. iconSize: void 0,
  3286. iconPrefix: void 0,
  3287. position: "middle",
  3288. transition: "van-fade",
  3289. forbidClick: false,
  3290. loadingType: void 0,
  3291. overlayClass: "",
  3292. overlayStyle: void 0,
  3293. closeOnClick: false,
  3294. closeOnClickOverlay: false
  3295. };
  3296. let queue = [];
  3297. let allowMultiple = false;
  3298. let currentOptions = extend({}, defaultOptions$1);
  3299. const defaultOptionsMap = /* @__PURE__ */ new Map();
  3300. function parseOptions$1(message) {
  3301. if (isObject(message)) {
  3302. return message;
  3303. }
  3304. return {
  3305. message
  3306. };
  3307. }
  3308. function createInstance() {
  3309. const {
  3310. instance: instance2,
  3311. unmount
  3312. } = mountComponent({
  3313. setup() {
  3314. const message = ref("");
  3315. const {
  3316. open,
  3317. state,
  3318. close,
  3319. toggle
  3320. } = usePopupState();
  3321. const onClosed = () => {
  3322. if (allowMultiple) {
  3323. queue = queue.filter((item) => item !== instance2);
  3324. unmount();
  3325. }
  3326. };
  3327. const render = () => {
  3328. const attrs = {
  3329. onClosed,
  3330. "onUpdate:show": toggle
  3331. };
  3332. return createVNode(stdin_default$1l, mergeProps(state, attrs), null);
  3333. };
  3334. watch(message, (val) => {
  3335. state.message = val;
  3336. });
  3337. getCurrentInstance().render = render;
  3338. return {
  3339. open,
  3340. clear: close,
  3341. message
  3342. };
  3343. }
  3344. });
  3345. return instance2;
  3346. }
  3347. function getInstance() {
  3348. if (!queue.length || allowMultiple) {
  3349. const instance2 = createInstance();
  3350. queue.push(instance2);
  3351. }
  3352. return queue[queue.length - 1];
  3353. }
  3354. function Toast(options = {}) {
  3355. if (!inBrowser) {
  3356. return {};
  3357. }
  3358. const toast = getInstance();
  3359. const parsedOptions = parseOptions$1(options);
  3360. toast.open(extend({}, currentOptions, defaultOptionsMap.get(parsedOptions.type || currentOptions.type), parsedOptions));
  3361. return toast;
  3362. }
  3363. const createMethod = (type) => (options) => Toast(extend({
  3364. type
  3365. }, parseOptions$1(options)));
  3366. Toast.loading = createMethod("loading");
  3367. Toast.success = createMethod("success");
  3368. Toast.fail = createMethod("fail");
  3369. Toast.clear = (all) => {
  3370. var _a;
  3371. if (queue.length) {
  3372. if (all) {
  3373. queue.forEach((toast) => {
  3374. toast.clear();
  3375. });
  3376. queue = [];
  3377. } else if (!allowMultiple) {
  3378. queue[0].clear();
  3379. } else {
  3380. (_a = queue.shift()) == null ? void 0 : _a.clear();
  3381. }
  3382. }
  3383. };
  3384. function setDefaultOptions(type, options) {
  3385. if (typeof type === "string") {
  3386. defaultOptionsMap.set(type, options);
  3387. } else {
  3388. extend(currentOptions, type);
  3389. }
  3390. }
  3391. Toast.setDefaultOptions = setDefaultOptions;
  3392. Toast.resetDefaultOptions = (type) => {
  3393. if (typeof type === "string") {
  3394. defaultOptionsMap.delete(type);
  3395. } else {
  3396. currentOptions = extend({}, defaultOptions$1);
  3397. defaultOptionsMap.clear();
  3398. }
  3399. };
  3400. Toast.allowMultiple = (value = true) => {
  3401. allowMultiple = value;
  3402. };
  3403. Toast.install = (app) => {
  3404. app.use(withInstall(stdin_default$1l));
  3405. app.config.globalProperties.$toast = Toast;
  3406. };
  3407. const [name$1d, bem$19] = createNamespace("switch");
  3408. const switchProps = {
  3409. size: numericProp,
  3410. loading: Boolean,
  3411. disabled: Boolean,
  3412. modelValue: unknownProp,
  3413. activeColor: String,
  3414. inactiveColor: String,
  3415. activeValue: {
  3416. type: unknownProp,
  3417. default: true
  3418. },
  3419. inactiveValue: {
  3420. type: unknownProp,
  3421. default: false
  3422. }
  3423. };
  3424. var stdin_default$1k = defineComponent({
  3425. name: name$1d,
  3426. props: switchProps,
  3427. emits: ["change", "update:modelValue"],
  3428. setup(props, {
  3429. emit,
  3430. slots
  3431. }) {
  3432. const isChecked = () => props.modelValue === props.activeValue;
  3433. const onClick = () => {
  3434. if (!props.disabled && !props.loading) {
  3435. const newValue = isChecked() ? props.inactiveValue : props.activeValue;
  3436. emit("update:modelValue", newValue);
  3437. emit("change", newValue);
  3438. }
  3439. };
  3440. const renderLoading = () => {
  3441. if (props.loading) {
  3442. const color = isChecked() ? props.activeColor : props.inactiveColor;
  3443. return createVNode(Loading, {
  3444. "class": bem$19("loading"),
  3445. "color": color
  3446. }, null);
  3447. }
  3448. if (slots.node) {
  3449. return slots.node();
  3450. }
  3451. };
  3452. useCustomFieldValue(() => props.modelValue);
  3453. return () => {
  3454. var _a;
  3455. const {
  3456. size,
  3457. loading,
  3458. disabled,
  3459. activeColor,
  3460. inactiveColor
  3461. } = props;
  3462. const checked = isChecked();
  3463. const style = {
  3464. fontSize: addUnit(size),
  3465. backgroundColor: checked ? activeColor : inactiveColor
  3466. };
  3467. return createVNode("div", {
  3468. "role": "switch",
  3469. "class": bem$19({
  3470. on: checked,
  3471. loading,
  3472. disabled
  3473. }),
  3474. "style": style,
  3475. "tabindex": disabled ? void 0 : 0,
  3476. "aria-checked": checked,
  3477. "onClick": onClick
  3478. }, [createVNode("div", {
  3479. "class": bem$19("node")
  3480. }, [renderLoading()]), (_a = slots.background) == null ? void 0 : _a.call(slots)]);
  3481. };
  3482. }
  3483. });
  3484. const Switch = withInstall(stdin_default$1k);
  3485. const [name$1c, bem$18] = createNamespace("address-edit-detail");
  3486. const t$i = createNamespace("address-edit")[2];
  3487. var stdin_default$1j = defineComponent({
  3488. name: name$1c,
  3489. props: {
  3490. show: Boolean,
  3491. rows: numericProp,
  3492. value: String,
  3493. rules: Array,
  3494. focused: Boolean,
  3495. maxlength: numericProp,
  3496. searchResult: Array,
  3497. showSearchResult: Boolean
  3498. },
  3499. emits: ["blur", "focus", "input", "select-search"],
  3500. setup(props, {
  3501. emit
  3502. }) {
  3503. const field = ref();
  3504. const showSearchResult = () => props.focused && props.searchResult && props.showSearchResult;
  3505. const onSelect = (express) => {
  3506. emit("select-search", express);
  3507. emit("input", `${express.address || ""} ${express.name || ""}`.trim());
  3508. };
  3509. const renderSearchTitle = (express) => {
  3510. if (express.name) {
  3511. const text = express.name.replace(props.value, `<span class=${bem$18("keyword")}>${props.value}</span>`);
  3512. return createVNode("div", {
  3513. "innerHTML": text
  3514. }, null);
  3515. }
  3516. };
  3517. const renderSearchResult = () => {
  3518. if (!showSearchResult()) {
  3519. return;
  3520. }
  3521. const {
  3522. searchResult
  3523. } = props;
  3524. return searchResult.map((express) => createVNode(Cell, {
  3525. "clickable": true,
  3526. "key": express.name + express.address,
  3527. "icon": "location-o",
  3528. "label": express.address,
  3529. "class": bem$18("search-item"),
  3530. "border": false,
  3531. "onClick": () => onSelect(express)
  3532. }, {
  3533. title: () => renderSearchTitle(express)
  3534. }));
  3535. };
  3536. const onBlur = (event) => emit("blur", event);
  3537. const onFocus = (event) => emit("focus", event);
  3538. const onInput = (value) => emit("input", value);
  3539. return () => {
  3540. if (props.show) {
  3541. return createVNode(Fragment, null, [createVNode(Field, {
  3542. "autosize": true,
  3543. "clearable": true,
  3544. "ref": field,
  3545. "class": bem$18(),
  3546. "rows": props.rows,
  3547. "type": "textarea",
  3548. "rules": props.rules,
  3549. "label": t$i("addressDetail"),
  3550. "border": !showSearchResult(),
  3551. "maxlength": props.maxlength,
  3552. "modelValue": props.value,
  3553. "placeholder": t$i("addressDetail"),
  3554. "onBlur": onBlur,
  3555. "onFocus": onFocus,
  3556. "onUpdate:modelValue": onInput
  3557. }, null), renderSearchResult()]);
  3558. }
  3559. };
  3560. }
  3561. });
  3562. const [name$1b, bem$17, t$h] = createNamespace("address-edit");
  3563. const DEFAULT_DATA = {
  3564. name: "",
  3565. tel: "",
  3566. city: "",
  3567. county: "",
  3568. country: "",
  3569. province: "",
  3570. areaCode: "",
  3571. isDefault: false,
  3572. postalCode: "",
  3573. addressDetail: ""
  3574. };
  3575. const isPostal = (value) => /^\d{6}$/.test(value);
  3576. const addressEditProps = {
  3577. areaList: Object,
  3578. isSaving: Boolean,
  3579. isDeleting: Boolean,
  3580. validator: Function,
  3581. showArea: truthProp,
  3582. showDetail: truthProp,
  3583. showDelete: Boolean,
  3584. showPostal: Boolean,
  3585. disableArea: Boolean,
  3586. searchResult: Array,
  3587. telMaxlength: numericProp,
  3588. showSetDefault: Boolean,
  3589. saveButtonText: String,
  3590. areaPlaceholder: String,
  3591. deleteButtonText: String,
  3592. showSearchResult: Boolean,
  3593. detailRows: makeNumericProp(1),
  3594. detailMaxlength: makeNumericProp(200),
  3595. areaColumnsPlaceholder: makeArrayProp(),
  3596. addressInfo: {
  3597. type: Object,
  3598. default: () => extend({}, DEFAULT_DATA)
  3599. },
  3600. telValidator: {
  3601. type: Function,
  3602. default: isMobile
  3603. },
  3604. postalValidator: {
  3605. type: Function,
  3606. default: isPostal
  3607. }
  3608. };
  3609. var stdin_default$1i = defineComponent({
  3610. name: name$1b,
  3611. props: addressEditProps,
  3612. emits: ["save", "focus", "delete", "click-area", "change-area", "change-detail", "select-search", "change-default"],
  3613. setup(props, {
  3614. emit,
  3615. slots
  3616. }) {
  3617. const areaRef = ref();
  3618. const data = reactive({});
  3619. const showAreaPopup = ref(false);
  3620. const detailFocused = ref(false);
  3621. const areaListLoaded = computed(() => isObject(props.areaList) && Object.keys(props.areaList).length);
  3622. const areaText = computed(() => {
  3623. const {
  3624. country,
  3625. province,
  3626. city,
  3627. county,
  3628. areaCode
  3629. } = data;
  3630. if (areaCode) {
  3631. const arr = [country, province, city, county];
  3632. if (province && province === city) {
  3633. arr.splice(1, 1);
  3634. }
  3635. return arr.filter(Boolean).join("/");
  3636. }
  3637. return "";
  3638. });
  3639. const hideBottomFields = computed(() => {
  3640. var _a;
  3641. return ((_a = props.searchResult) == null ? void 0 : _a.length) && detailFocused.value;
  3642. });
  3643. const assignAreaValues = () => {
  3644. if (areaRef.value) {
  3645. const detail = areaRef.value.getArea();
  3646. detail.areaCode = detail.code;
  3647. delete detail.code;
  3648. extend(data, detail);
  3649. }
  3650. };
  3651. const onFocus = (key) => {
  3652. detailFocused.value = key === "addressDetail";
  3653. emit("focus", key);
  3654. };
  3655. const rules = computed(() => {
  3656. const {
  3657. validator,
  3658. telValidator,
  3659. postalValidator
  3660. } = props;
  3661. const makeRule = (name2, emptyMessage) => ({
  3662. validator: (value) => {
  3663. if (validator) {
  3664. const message = validator(name2, value);
  3665. if (message) {
  3666. return message;
  3667. }
  3668. }
  3669. if (!value) {
  3670. return emptyMessage;
  3671. }
  3672. return true;
  3673. }
  3674. });
  3675. return {
  3676. name: [makeRule("name", t$h("nameEmpty"))],
  3677. tel: [makeRule("tel", t$h("telInvalid")), {
  3678. validator: telValidator,
  3679. message: t$h("telInvalid")
  3680. }],
  3681. areaCode: [makeRule("areaCode", t$h("areaEmpty"))],
  3682. addressDetail: [makeRule("addressDetail", t$h("addressEmpty"))],
  3683. postalCode: [makeRule("addressDetail", t$h("postalEmpty")), {
  3684. validator: postalValidator,
  3685. message: t$h("postalEmpty")
  3686. }]
  3687. };
  3688. });
  3689. const onSave = () => emit("save", data);
  3690. const onChangeDetail = (val) => {
  3691. data.addressDetail = val;
  3692. emit("change-detail", val);
  3693. };
  3694. const onAreaConfirm = (values) => {
  3695. values = values.filter(Boolean);
  3696. if (values.some((value) => !value.code)) {
  3697. Toast(t$h("areaEmpty"));
  3698. } else {
  3699. showAreaPopup.value = false;
  3700. assignAreaValues();
  3701. emit("change-area", values);
  3702. }
  3703. };
  3704. const onDelete = () => emit("delete", data);
  3705. const getArea = () => {
  3706. var _a;
  3707. return ((_a = areaRef.value) == null ? void 0 : _a.getValues()) || [];
  3708. };
  3709. const setAreaCode = (code) => {
  3710. data.areaCode = code || "";
  3711. if (code) {
  3712. nextTick(assignAreaValues);
  3713. }
  3714. };
  3715. const onDetailBlur = () => {
  3716. setTimeout(() => {
  3717. detailFocused.value = false;
  3718. });
  3719. };
  3720. const setAddressDetail = (value) => {
  3721. data.addressDetail = value;
  3722. };
  3723. const renderSetDefaultCell = () => {
  3724. if (props.showSetDefault) {
  3725. const slots2 = {
  3726. "right-icon": () => createVNode(Switch, {
  3727. "modelValue": data.isDefault,
  3728. "onUpdate:modelValue": ($event) => data.isDefault = $event,
  3729. "size": "24",
  3730. "onChange": (event) => emit("change-default", event)
  3731. }, null)
  3732. };
  3733. return withDirectives(createVNode(Cell, {
  3734. "center": true,
  3735. "title": t$h("defaultAddress"),
  3736. "class": bem$17("default")
  3737. }, slots2), [[vShow, !hideBottomFields.value]]);
  3738. }
  3739. };
  3740. useExpose({
  3741. getArea,
  3742. setAreaCode,
  3743. setAddressDetail
  3744. });
  3745. watch(() => props.areaList, () => setAreaCode(data.areaCode));
  3746. watch(() => props.addressInfo, (value) => {
  3747. extend(data, DEFAULT_DATA, value);
  3748. setAreaCode(value.areaCode);
  3749. }, {
  3750. deep: true,
  3751. immediate: true
  3752. });
  3753. return () => {
  3754. const {
  3755. disableArea
  3756. } = props;
  3757. return createVNode(Form, {
  3758. "class": bem$17(),
  3759. "onSubmit": onSave
  3760. }, {
  3761. default: () => {
  3762. var _a;
  3763. return [createVNode("div", {
  3764. "class": bem$17("fields")
  3765. }, [createVNode(Field, {
  3766. "modelValue": data.name,
  3767. "onUpdate:modelValue": ($event) => data.name = $event,
  3768. "clearable": true,
  3769. "label": t$h("name"),
  3770. "rules": rules.value.name,
  3771. "placeholder": t$h("name"),
  3772. "onFocus": () => onFocus("name")
  3773. }, null), createVNode(Field, {
  3774. "modelValue": data.tel,
  3775. "onUpdate:modelValue": ($event) => data.tel = $event,
  3776. "clearable": true,
  3777. "type": "tel",
  3778. "label": t$h("tel"),
  3779. "rules": rules.value.tel,
  3780. "maxlength": props.telMaxlength,
  3781. "placeholder": t$h("tel"),
  3782. "onFocus": () => onFocus("tel")
  3783. }, null), withDirectives(createVNode(Field, {
  3784. "readonly": true,
  3785. "label": t$h("area"),
  3786. "is-link": !disableArea,
  3787. "modelValue": areaText.value,
  3788. "rules": rules.value.areaCode,
  3789. "placeholder": props.areaPlaceholder || t$h("area"),
  3790. "onFocus": () => onFocus("areaCode"),
  3791. "onClick": () => {
  3792. emit("click-area");
  3793. showAreaPopup.value = !disableArea;
  3794. }
  3795. }, null), [[vShow, props.showArea]]), createVNode(stdin_default$1j, {
  3796. "show": props.showDetail,
  3797. "rows": props.detailRows,
  3798. "rules": rules.value.addressDetail,
  3799. "value": data.addressDetail,
  3800. "focused": detailFocused.value,
  3801. "maxlength": props.detailMaxlength,
  3802. "searchResult": props.searchResult,
  3803. "showSearchResult": props.showSearchResult,
  3804. "onBlur": onDetailBlur,
  3805. "onFocus": () => onFocus("addressDetail"),
  3806. "onInput": onChangeDetail,
  3807. "onSelect-search": (event) => emit("select-search", event)
  3808. }, null), props.showPostal && withDirectives(createVNode(Field, {
  3809. "modelValue": data.postalCode,
  3810. "onUpdate:modelValue": ($event) => data.postalCode = $event,
  3811. "type": "tel",
  3812. "rules": rules.value.postalCode,
  3813. "label": t$h("postal"),
  3814. "maxlength": "6",
  3815. "placeholder": t$h("postal"),
  3816. "onFocus": () => onFocus("postalCode")
  3817. }, null), [[vShow, !hideBottomFields.value]]), (_a = slots.default) == null ? void 0 : _a.call(slots)]), renderSetDefaultCell(), withDirectives(createVNode("div", {
  3818. "class": bem$17("buttons")
  3819. }, [createVNode(Button, {
  3820. "block": true,
  3821. "round": true,
  3822. "type": "danger",
  3823. "text": props.saveButtonText || t$h("save"),
  3824. "class": bem$17("button"),
  3825. "loading": props.isSaving,
  3826. "nativeType": "submit"
  3827. }, null), props.showDelete && createVNode(Button, {
  3828. "block": true,
  3829. "round": true,
  3830. "class": bem$17("button"),
  3831. "loading": props.isDeleting,
  3832. "text": props.deleteButtonText || t$h("delete"),
  3833. "onClick": onDelete
  3834. }, null)]), [[vShow, !hideBottomFields.value]]), createVNode(Popup, {
  3835. "show": showAreaPopup.value,
  3836. "onUpdate:show": ($event) => showAreaPopup.value = $event,
  3837. "round": true,
  3838. "teleport": "body",
  3839. "position": "bottom",
  3840. "lazyRender": false
  3841. }, {
  3842. default: () => [createVNode(Area, {
  3843. "ref": areaRef,
  3844. "value": data.areaCode,
  3845. "loading": !areaListLoaded.value,
  3846. "areaList": props.areaList,
  3847. "columnsPlaceholder": props.areaColumnsPlaceholder,
  3848. "onConfirm": onAreaConfirm,
  3849. "onCancel": () => {
  3850. showAreaPopup.value = false;
  3851. }
  3852. }, null)]
  3853. })];
  3854. }
  3855. });
  3856. };
  3857. }
  3858. });
  3859. const AddressEdit = withInstall(stdin_default$1i);
  3860. const [name$1a, bem$16] = createNamespace("radio-group");
  3861. const radioGroupProps = {
  3862. disabled: Boolean,
  3863. iconSize: numericProp,
  3864. direction: String,
  3865. modelValue: unknownProp,
  3866. checkedColor: String
  3867. };
  3868. const RADIO_KEY = Symbol(name$1a);
  3869. var stdin_default$1h = defineComponent({
  3870. name: name$1a,
  3871. props: radioGroupProps,
  3872. emits: ["change", "update:modelValue"],
  3873. setup(props, {
  3874. emit,
  3875. slots
  3876. }) {
  3877. const {
  3878. linkChildren
  3879. } = useChildren(RADIO_KEY);
  3880. const updateValue = (value) => emit("update:modelValue", value);
  3881. watch(() => props.modelValue, (value) => emit("change", value));
  3882. linkChildren({
  3883. props,
  3884. updateValue
  3885. });
  3886. useCustomFieldValue(() => props.modelValue);
  3887. return () => {
  3888. var _a;
  3889. return createVNode("div", {
  3890. "class": bem$16([props.direction]),
  3891. "role": "radiogroup"
  3892. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  3893. };
  3894. }
  3895. });
  3896. const RadioGroup = withInstall(stdin_default$1h);
  3897. const [name$19, bem$15] = createNamespace("tag");
  3898. const tagProps = {
  3899. size: String,
  3900. mark: Boolean,
  3901. show: truthProp,
  3902. type: makeStringProp("default"),
  3903. color: String,
  3904. plain: Boolean,
  3905. round: Boolean,
  3906. textColor: String,
  3907. closeable: Boolean
  3908. };
  3909. var stdin_default$1g = defineComponent({
  3910. name: name$19,
  3911. props: tagProps,
  3912. emits: ["close"],
  3913. setup(props, {
  3914. slots,
  3915. emit
  3916. }) {
  3917. const onClose = (event) => {
  3918. event.stopPropagation();
  3919. emit("close", event);
  3920. };
  3921. const getStyle = () => {
  3922. if (props.plain) {
  3923. return {
  3924. color: props.textColor || props.color,
  3925. borderColor: props.color
  3926. };
  3927. }
  3928. return {
  3929. color: props.textColor,
  3930. background: props.color
  3931. };
  3932. };
  3933. const renderTag = () => {
  3934. var _a;
  3935. const {
  3936. type,
  3937. mark,
  3938. plain,
  3939. round,
  3940. size,
  3941. closeable
  3942. } = props;
  3943. const classes = {
  3944. mark,
  3945. plain,
  3946. round
  3947. };
  3948. if (size) {
  3949. classes[size] = size;
  3950. }
  3951. const CloseIcon = closeable && createVNode(Icon, {
  3952. "name": "cross",
  3953. "class": [bem$15("close"), HAPTICS_FEEDBACK],
  3954. "onClick": onClose
  3955. }, null);
  3956. return createVNode("span", {
  3957. "style": getStyle(),
  3958. "class": bem$15([classes, type])
  3959. }, [(_a = slots.default) == null ? void 0 : _a.call(slots), CloseIcon]);
  3960. };
  3961. return () => createVNode(Transition, {
  3962. "name": props.closeable ? "van-fade" : void 0
  3963. }, {
  3964. default: () => [props.show ? renderTag() : null]
  3965. });
  3966. }
  3967. });
  3968. const Tag = withInstall(stdin_default$1g);
  3969. const checkerProps = {
  3970. name: unknownProp,
  3971. shape: makeStringProp("round"),
  3972. disabled: Boolean,
  3973. iconSize: numericProp,
  3974. modelValue: unknownProp,
  3975. checkedColor: String,
  3976. labelPosition: String,
  3977. labelDisabled: Boolean
  3978. };
  3979. var stdin_default$1f = defineComponent({
  3980. props: extend({}, checkerProps, {
  3981. bem: makeRequiredProp(Function),
  3982. role: String,
  3983. parent: Object,
  3984. checked: Boolean,
  3985. bindGroup: truthProp
  3986. }),
  3987. emits: ["click", "toggle"],
  3988. setup(props, {
  3989. emit,
  3990. slots
  3991. }) {
  3992. const iconRef = ref();
  3993. const getParentProp = (name2) => {
  3994. if (props.parent && props.bindGroup) {
  3995. return props.parent.props[name2];
  3996. }
  3997. };
  3998. const disabled = computed(() => getParentProp("disabled") || props.disabled);
  3999. const direction = computed(() => getParentProp("direction"));
  4000. const iconStyle = computed(() => {
  4001. const checkedColor = props.checkedColor || getParentProp("checkedColor");
  4002. if (checkedColor && props.checked && !disabled.value) {
  4003. return {
  4004. borderColor: checkedColor,
  4005. backgroundColor: checkedColor
  4006. };
  4007. }
  4008. });
  4009. const onClick = (event) => {
  4010. const {
  4011. target
  4012. } = event;
  4013. const icon = iconRef.value;
  4014. const iconClicked = icon === target || (icon == null ? void 0 : icon.contains(target));
  4015. if (!disabled.value && (iconClicked || !props.labelDisabled)) {
  4016. emit("toggle");
  4017. }
  4018. emit("click", event);
  4019. };
  4020. const renderIcon = () => {
  4021. const {
  4022. bem: bem2,
  4023. shape,
  4024. checked
  4025. } = props;
  4026. const iconSize = props.iconSize || getParentProp("iconSize");
  4027. return createVNode("div", {
  4028. "ref": iconRef,
  4029. "class": bem2("icon", [shape, {
  4030. disabled: disabled.value,
  4031. checked
  4032. }]),
  4033. "style": {
  4034. fontSize: addUnit(iconSize)
  4035. }
  4036. }, [slots.icon ? slots.icon({
  4037. checked,
  4038. disabled: disabled.value
  4039. }) : createVNode(Icon, {
  4040. "name": "success",
  4041. "style": iconStyle.value
  4042. }, null)]);
  4043. };
  4044. const renderLabel = () => {
  4045. if (slots.default) {
  4046. return createVNode("span", {
  4047. "class": props.bem("label", [props.labelPosition, {
  4048. disabled: disabled.value
  4049. }])
  4050. }, [slots.default()]);
  4051. }
  4052. };
  4053. return () => {
  4054. const nodes = props.labelPosition === "left" ? [renderLabel(), renderIcon()] : [renderIcon(), renderLabel()];
  4055. return createVNode("div", {
  4056. "role": props.role,
  4057. "class": props.bem([{
  4058. disabled: disabled.value,
  4059. "label-disabled": props.labelDisabled
  4060. }, direction.value]),
  4061. "tabindex": disabled.value ? void 0 : 0,
  4062. "aria-checked": props.checked,
  4063. "onClick": onClick
  4064. }, [nodes]);
  4065. };
  4066. }
  4067. });
  4068. const [name$18, bem$14] = createNamespace("radio");
  4069. var stdin_default$1e = defineComponent({
  4070. name: name$18,
  4071. props: checkerProps,
  4072. emits: ["update:modelValue"],
  4073. setup(props, {
  4074. emit,
  4075. slots
  4076. }) {
  4077. const {
  4078. parent
  4079. } = useParent(RADIO_KEY);
  4080. const checked = () => {
  4081. const value = parent ? parent.props.modelValue : props.modelValue;
  4082. return value === props.name;
  4083. };
  4084. const toggle = () => {
  4085. if (parent) {
  4086. parent.updateValue(props.name);
  4087. } else {
  4088. emit("update:modelValue", props.name);
  4089. }
  4090. };
  4091. return () => createVNode(stdin_default$1f, mergeProps({
  4092. "bem": bem$14,
  4093. "role": "radio",
  4094. "parent": parent,
  4095. "checked": checked(),
  4096. "onToggle": toggle
  4097. }, props), pick(slots, ["default", "icon"]));
  4098. }
  4099. });
  4100. const Radio = withInstall(stdin_default$1e);
  4101. const [name$17, bem$13] = createNamespace("address-item");
  4102. var stdin_default$1d = defineComponent({
  4103. name: name$17,
  4104. props: {
  4105. address: makeRequiredProp(Object),
  4106. disabled: Boolean,
  4107. switchable: Boolean,
  4108. defaultTagText: String
  4109. },
  4110. emits: ["edit", "click", "select"],
  4111. setup(props, {
  4112. slots,
  4113. emit
  4114. }) {
  4115. const onClick = () => {
  4116. if (props.switchable) {
  4117. emit("select");
  4118. }
  4119. emit("click");
  4120. };
  4121. const renderRightIcon = () => createVNode(Icon, {
  4122. "name": "edit",
  4123. "class": bem$13("edit"),
  4124. "onClick": (event) => {
  4125. event.stopPropagation();
  4126. emit("edit");
  4127. emit("click");
  4128. }
  4129. }, null);
  4130. const renderTag = () => {
  4131. if (slots.tag) {
  4132. return slots.tag(props.address);
  4133. }
  4134. if (props.address.isDefault && props.defaultTagText) {
  4135. return createVNode(Tag, {
  4136. "type": "danger",
  4137. "round": true,
  4138. "class": bem$13("tag")
  4139. }, {
  4140. default: () => [props.defaultTagText]
  4141. });
  4142. }
  4143. };
  4144. const renderContent = () => {
  4145. const {
  4146. address,
  4147. disabled,
  4148. switchable
  4149. } = props;
  4150. const Info = [createVNode("div", {
  4151. "class": bem$13("name")
  4152. }, [`${address.name} ${address.tel}`, renderTag()]), createVNode("div", {
  4153. "class": bem$13("address")
  4154. }, [address.address])];
  4155. if (switchable && !disabled) {
  4156. return createVNode(Radio, {
  4157. "name": address.id,
  4158. "iconSize": 18
  4159. }, {
  4160. default: () => [Info]
  4161. });
  4162. }
  4163. return Info;
  4164. };
  4165. return () => {
  4166. var _a;
  4167. const {
  4168. disabled
  4169. } = props;
  4170. return createVNode("div", {
  4171. "class": bem$13({
  4172. disabled
  4173. }),
  4174. "onClick": onClick
  4175. }, [createVNode(Cell, {
  4176. "border": false,
  4177. "valueClass": bem$13("value")
  4178. }, {
  4179. value: renderContent,
  4180. "right-icon": renderRightIcon
  4181. }), (_a = slots.bottom) == null ? void 0 : _a.call(slots, extend({}, props.address, {
  4182. disabled
  4183. }))]);
  4184. };
  4185. }
  4186. });
  4187. const [name$16, bem$12, t$g] = createNamespace("address-list");
  4188. const addressListProps = {
  4189. list: makeArrayProp(),
  4190. modelValue: numericProp,
  4191. switchable: truthProp,
  4192. disabledText: String,
  4193. disabledList: makeArrayProp(),
  4194. addButtonText: String,
  4195. defaultTagText: String
  4196. };
  4197. var stdin_default$1c = defineComponent({
  4198. name: name$16,
  4199. props: addressListProps,
  4200. emits: ["add", "edit", "select", "click-item", "edit-disabled", "select-disabled", "update:modelValue"],
  4201. setup(props, {
  4202. slots,
  4203. emit
  4204. }) {
  4205. const renderItem = (item, index, disabled) => {
  4206. const onEdit = () => emit(disabled ? "edit-disabled" : "edit", item, index);
  4207. const onClick = () => emit("click-item", item, index);
  4208. const onSelect = () => {
  4209. emit(disabled ? "select-disabled" : "select", item, index);
  4210. if (!disabled) {
  4211. emit("update:modelValue", item.id);
  4212. }
  4213. };
  4214. return createVNode(stdin_default$1d, {
  4215. "key": item.id,
  4216. "address": item,
  4217. "disabled": disabled,
  4218. "switchable": props.switchable,
  4219. "defaultTagText": props.defaultTagText,
  4220. "onEdit": onEdit,
  4221. "onClick": onClick,
  4222. "onSelect": onSelect
  4223. }, {
  4224. bottom: slots["item-bottom"],
  4225. tag: slots.tag
  4226. });
  4227. };
  4228. const renderList = (list, disabled) => {
  4229. if (list) {
  4230. return list.map((item, index) => renderItem(item, index, disabled));
  4231. }
  4232. };
  4233. const renderBottom = () => createVNode("div", {
  4234. "class": [bem$12("bottom"), "van-safe-area-bottom"]
  4235. }, [createVNode(Button, {
  4236. "round": true,
  4237. "block": true,
  4238. "type": "danger",
  4239. "text": props.addButtonText || t$g("add"),
  4240. "class": bem$12("add"),
  4241. "onClick": () => emit("add")
  4242. }, null)]);
  4243. return () => {
  4244. var _a, _b;
  4245. const List2 = renderList(props.list);
  4246. const DisabledList = renderList(props.disabledList, true);
  4247. const DisabledText = props.disabledText && createVNode("div", {
  4248. "class": bem$12("disabled-text")
  4249. }, [props.disabledText]);
  4250. return createVNode("div", {
  4251. "class": bem$12()
  4252. }, [(_a = slots.top) == null ? void 0 : _a.call(slots), createVNode(RadioGroup, {
  4253. "modelValue": props.modelValue
  4254. }, {
  4255. default: () => [List2]
  4256. }), DisabledText, DisabledList, (_b = slots.default) == null ? void 0 : _b.call(slots), renderBottom()]);
  4257. };
  4258. }
  4259. });
  4260. const AddressList = withInstall(stdin_default$1c);
  4261. const [name$15, bem$11, t$f] = createNamespace("calendar");
  4262. const formatMonthTitle = (date) => t$f("monthTitle", date.getFullYear(), date.getMonth() + 1);
  4263. function compareMonth(date1, date2) {
  4264. const year1 = date1.getFullYear();
  4265. const year2 = date2.getFullYear();
  4266. if (year1 === year2) {
  4267. const month1 = date1.getMonth();
  4268. const month2 = date2.getMonth();
  4269. return month1 === month2 ? 0 : month1 > month2 ? 1 : -1;
  4270. }
  4271. return year1 > year2 ? 1 : -1;
  4272. }
  4273. function compareDay(day1, day2) {
  4274. const compareMonthResult = compareMonth(day1, day2);
  4275. if (compareMonthResult === 0) {
  4276. const date1 = day1.getDate();
  4277. const date2 = day2.getDate();
  4278. return date1 === date2 ? 0 : date1 > date2 ? 1 : -1;
  4279. }
  4280. return compareMonthResult;
  4281. }
  4282. const cloneDate = (date) => new Date(date);
  4283. const cloneDates = (dates) => Array.isArray(dates) ? dates.map(cloneDate) : cloneDate(dates);
  4284. function getDayByOffset(date, offset) {
  4285. const cloned = cloneDate(date);
  4286. cloned.setDate(cloned.getDate() + offset);
  4287. return cloned;
  4288. }
  4289. const getPrevDay = (date) => getDayByOffset(date, -1);
  4290. const getNextDay = (date) => getDayByOffset(date, 1);
  4291. const getToday = () => {
  4292. const today = new Date();
  4293. today.setHours(0, 0, 0, 0);
  4294. return today;
  4295. };
  4296. function calcDateNum(date) {
  4297. const day1 = date[0].getTime();
  4298. const day2 = date[1].getTime();
  4299. return (day2 - day1) / (1e3 * 60 * 60 * 24) + 1;
  4300. }
  4301. function useRefs() {
  4302. const refs = ref([]);
  4303. const cache = [];
  4304. onBeforeUpdate(() => {
  4305. refs.value = [];
  4306. });
  4307. const setRefs = (index) => {
  4308. if (!cache[index]) {
  4309. cache[index] = (el) => {
  4310. refs.value[index] = el;
  4311. };
  4312. }
  4313. return cache[index];
  4314. };
  4315. return [refs, setRefs];
  4316. }
  4317. const sharedProps = extend({}, pickerSharedProps, {
  4318. filter: Function,
  4319. columnsOrder: Array,
  4320. formatter: {
  4321. type: Function,
  4322. default: (type, value) => value
  4323. }
  4324. });
  4325. const pickerInheritKeys = Object.keys(pickerSharedProps);
  4326. function times(n, iteratee) {
  4327. if (n < 0) {
  4328. return [];
  4329. }
  4330. const result = Array(n);
  4331. let index = -1;
  4332. while (++index < n) {
  4333. result[index] = iteratee(index);
  4334. }
  4335. return result;
  4336. }
  4337. function getTrueValue(value) {
  4338. if (!value) {
  4339. return 0;
  4340. }
  4341. while (Number.isNaN(parseInt(value, 10))) {
  4342. if (value.length > 1) {
  4343. value = value.slice(1);
  4344. } else {
  4345. return 0;
  4346. }
  4347. }
  4348. return parseInt(value, 10);
  4349. }
  4350. const getMonthEndDay = (year, month) => 32 - new Date(year, month - 1, 32).getDate();
  4351. const proxyPickerMethods = (picker, callback) => {
  4352. const methods = [
  4353. "setValues",
  4354. "setIndexes",
  4355. "setColumnIndex",
  4356. "setColumnValue"
  4357. ];
  4358. return new Proxy(picker, {
  4359. get: (target, prop) => {
  4360. if (methods.includes(prop)) {
  4361. return (...args) => {
  4362. target[prop](...args);
  4363. callback();
  4364. };
  4365. }
  4366. return target[prop];
  4367. }
  4368. });
  4369. };
  4370. const [name$14] = createNamespace("calendar-day");
  4371. var stdin_default$1b = defineComponent({
  4372. name: name$14,
  4373. props: {
  4374. item: makeRequiredProp(Object),
  4375. color: String,
  4376. index: Number,
  4377. offset: makeNumberProp(0),
  4378. rowHeight: String
  4379. },
  4380. emits: ["click"],
  4381. setup(props, {
  4382. emit,
  4383. slots
  4384. }) {
  4385. const style = computed(() => {
  4386. var _a;
  4387. const {
  4388. item,
  4389. index,
  4390. color,
  4391. offset,
  4392. rowHeight
  4393. } = props;
  4394. const style2 = {
  4395. height: rowHeight
  4396. };
  4397. if (item.type === "placeholder") {
  4398. style2.width = "100%";
  4399. return style2;
  4400. }
  4401. if (index === 0) {
  4402. style2.marginLeft = `${100 * offset / 7}%`;
  4403. }
  4404. if (color) {
  4405. switch (item.type) {
  4406. case "end":
  4407. case "start":
  4408. case "start-end":
  4409. case "multiple-middle":
  4410. case "multiple-selected":
  4411. style2.background = color;
  4412. break;
  4413. case "middle":
  4414. style2.color = color;
  4415. break;
  4416. }
  4417. }
  4418. if (offset + (((_a = item.date) == null ? void 0 : _a.getDate()) || 1) > 28) {
  4419. style2.marginBottom = 0;
  4420. }
  4421. return style2;
  4422. });
  4423. const onClick = () => {
  4424. if (props.item.type !== "disabled") {
  4425. emit("click", props.item);
  4426. }
  4427. };
  4428. const renderTopInfo = () => {
  4429. const {
  4430. topInfo
  4431. } = props.item;
  4432. if (topInfo || slots["top-info"]) {
  4433. return createVNode("div", {
  4434. "class": bem$11("top-info")
  4435. }, [slots["top-info"] ? slots["top-info"](props.item) : topInfo]);
  4436. }
  4437. };
  4438. const renderBottomInfo = () => {
  4439. const {
  4440. bottomInfo
  4441. } = props.item;
  4442. if (bottomInfo || slots["bottom-info"]) {
  4443. return createVNode("div", {
  4444. "class": bem$11("bottom-info")
  4445. }, [slots["bottom-info"] ? slots["bottom-info"](props.item) : bottomInfo]);
  4446. }
  4447. };
  4448. const renderContent = () => {
  4449. const {
  4450. item,
  4451. color,
  4452. rowHeight
  4453. } = props;
  4454. const {
  4455. type,
  4456. text
  4457. } = item;
  4458. const Nodes = [renderTopInfo(), text, renderBottomInfo()];
  4459. if (type === "selected") {
  4460. return createVNode("div", {
  4461. "class": bem$11("selected-day"),
  4462. "style": {
  4463. width: rowHeight,
  4464. height: rowHeight,
  4465. background: color
  4466. }
  4467. }, [Nodes]);
  4468. }
  4469. return Nodes;
  4470. };
  4471. return () => {
  4472. const {
  4473. type,
  4474. className
  4475. } = props.item;
  4476. if (type === "placeholder") {
  4477. return createVNode("div", {
  4478. "class": bem$11("day"),
  4479. "style": style.value
  4480. }, null);
  4481. }
  4482. return createVNode("div", {
  4483. "role": "gridcell",
  4484. "style": style.value,
  4485. "class": [bem$11("day", type), className],
  4486. "tabindex": type === "disabled" ? void 0 : -1,
  4487. "onClick": onClick
  4488. }, [renderContent()]);
  4489. };
  4490. }
  4491. });
  4492. const [name$13] = createNamespace("calendar-month");
  4493. const calendarMonthProps = {
  4494. date: makeRequiredProp(Date),
  4495. type: String,
  4496. color: String,
  4497. minDate: makeRequiredProp(Date),
  4498. maxDate: makeRequiredProp(Date),
  4499. showMark: Boolean,
  4500. rowHeight: numericProp,
  4501. formatter: Function,
  4502. lazyRender: Boolean,
  4503. currentDate: [Date, Array],
  4504. allowSameDay: Boolean,
  4505. showSubtitle: Boolean,
  4506. showMonthTitle: Boolean,
  4507. firstDayOfWeek: Number
  4508. };
  4509. var stdin_default$1a = defineComponent({
  4510. name: name$13,
  4511. props: calendarMonthProps,
  4512. emits: ["click", "update-height"],
  4513. setup(props, {
  4514. emit,
  4515. slots
  4516. }) {
  4517. const [visible, setVisible] = useToggle();
  4518. const daysRef = ref();
  4519. const monthRef = ref();
  4520. const height = useHeight(monthRef);
  4521. const title = computed(() => formatMonthTitle(props.date));
  4522. const rowHeight = computed(() => addUnit(props.rowHeight));
  4523. const offset = computed(() => {
  4524. const realDay = props.date.getDay();
  4525. if (props.firstDayOfWeek) {
  4526. return (realDay + 7 - props.firstDayOfWeek) % 7;
  4527. }
  4528. return realDay;
  4529. });
  4530. const totalDay = computed(() => getMonthEndDay(props.date.getFullYear(), props.date.getMonth() + 1));
  4531. const shouldRender = computed(() => visible.value || !props.lazyRender);
  4532. const getTitle = () => title.value;
  4533. const getMultipleDayType = (day) => {
  4534. const isSelected = (date) => props.currentDate.some((item) => compareDay(item, date) === 0);
  4535. if (isSelected(day)) {
  4536. const prevDay = getPrevDay(day);
  4537. const nextDay = getNextDay(day);
  4538. const prevSelected = isSelected(prevDay);
  4539. const nextSelected = isSelected(nextDay);
  4540. if (prevSelected && nextSelected) {
  4541. return "multiple-middle";
  4542. }
  4543. if (prevSelected) {
  4544. return "end";
  4545. }
  4546. if (nextSelected) {
  4547. return "start";
  4548. }
  4549. return "multiple-selected";
  4550. }
  4551. return "";
  4552. };
  4553. const getRangeDayType = (day) => {
  4554. const [startDay, endDay] = props.currentDate;
  4555. if (!startDay) {
  4556. return "";
  4557. }
  4558. const compareToStart = compareDay(day, startDay);
  4559. if (!endDay) {
  4560. return compareToStart === 0 ? "start" : "";
  4561. }
  4562. const compareToEnd = compareDay(day, endDay);
  4563. if (props.allowSameDay && compareToStart === 0 && compareToEnd === 0) {
  4564. return "start-end";
  4565. }
  4566. if (compareToStart === 0) {
  4567. return "start";
  4568. }
  4569. if (compareToEnd === 0) {
  4570. return "end";
  4571. }
  4572. if (compareToStart > 0 && compareToEnd < 0) {
  4573. return "middle";
  4574. }
  4575. return "";
  4576. };
  4577. const getDayType = (day) => {
  4578. const {
  4579. type,
  4580. minDate,
  4581. maxDate,
  4582. currentDate
  4583. } = props;
  4584. if (compareDay(day, minDate) < 0 || compareDay(day, maxDate) > 0) {
  4585. return "disabled";
  4586. }
  4587. if (currentDate === null) {
  4588. return "";
  4589. }
  4590. if (Array.isArray(currentDate)) {
  4591. if (type === "multiple") {
  4592. return getMultipleDayType(day);
  4593. }
  4594. if (type === "range") {
  4595. return getRangeDayType(day);
  4596. }
  4597. } else if (type === "single") {
  4598. return compareDay(day, currentDate) === 0 ? "selected" : "";
  4599. }
  4600. return "";
  4601. };
  4602. const getBottomInfo = (dayType) => {
  4603. if (props.type === "range") {
  4604. if (dayType === "start" || dayType === "end") {
  4605. return t$f(dayType);
  4606. }
  4607. if (dayType === "start-end") {
  4608. return `${t$f("start")}/${t$f("end")}`;
  4609. }
  4610. }
  4611. };
  4612. const renderTitle = () => {
  4613. if (props.showMonthTitle) {
  4614. return createVNode("div", {
  4615. "class": bem$11("month-title")
  4616. }, [title.value]);
  4617. }
  4618. };
  4619. const renderMark = () => {
  4620. if (props.showMark && shouldRender.value) {
  4621. return createVNode("div", {
  4622. "class": bem$11("month-mark")
  4623. }, [props.date.getMonth() + 1]);
  4624. }
  4625. };
  4626. const placeholders = computed(() => {
  4627. const count = Math.ceil((totalDay.value + offset.value) / 7);
  4628. return Array(count).fill({
  4629. type: "placeholder"
  4630. });
  4631. });
  4632. const days = computed(() => {
  4633. const days2 = [];
  4634. const year = props.date.getFullYear();
  4635. const month = props.date.getMonth();
  4636. for (let day = 1; day <= totalDay.value; day++) {
  4637. const date = new Date(year, month, day);
  4638. const type = getDayType(date);
  4639. let config = {
  4640. date,
  4641. type,
  4642. text: day,
  4643. bottomInfo: getBottomInfo(type)
  4644. };
  4645. if (props.formatter) {
  4646. config = props.formatter(config);
  4647. }
  4648. days2.push(config);
  4649. }
  4650. return days2;
  4651. });
  4652. const disabledDays = computed(() => days.value.filter((day) => day.type === "disabled"));
  4653. const scrollToDate = (body, targetDate) => {
  4654. if (daysRef.value) {
  4655. const daysRect = useRect(daysRef.value);
  4656. const totalRows = placeholders.value.length;
  4657. const currentRow = Math.ceil((targetDate.getDate() + offset.value) / 7);
  4658. const rowOffset = (currentRow - 1) * daysRect.height / totalRows;
  4659. setScrollTop(body, daysRect.top + rowOffset + body.scrollTop - useRect(body).top);
  4660. }
  4661. };
  4662. const renderDay = (item, index) => createVNode(stdin_default$1b, {
  4663. "item": item,
  4664. "index": index,
  4665. "color": props.color,
  4666. "offset": offset.value,
  4667. "rowHeight": rowHeight.value,
  4668. "onClick": (item2) => emit("click", item2)
  4669. }, pick(slots, ["top-info", "bottom-info"]));
  4670. const renderDays = () => createVNode("div", {
  4671. "ref": daysRef,
  4672. "role": "grid",
  4673. "class": bem$11("days")
  4674. }, [renderMark(), (shouldRender.value ? days : placeholders).value.map(renderDay)]);
  4675. useExpose({
  4676. getTitle,
  4677. getHeight: () => height.value,
  4678. setVisible,
  4679. scrollToDate,
  4680. disabledDays
  4681. });
  4682. return () => createVNode("div", {
  4683. "class": bem$11("month"),
  4684. "ref": monthRef
  4685. }, [renderTitle(), renderDays()]);
  4686. }
  4687. });
  4688. const [name$12] = createNamespace("calendar-header");
  4689. var stdin_default$19 = defineComponent({
  4690. name: name$12,
  4691. props: {
  4692. title: String,
  4693. subtitle: String,
  4694. showTitle: Boolean,
  4695. showSubtitle: Boolean,
  4696. firstDayOfWeek: Number
  4697. },
  4698. emits: ["click-subtitle"],
  4699. setup(props, {
  4700. slots,
  4701. emit
  4702. }) {
  4703. const renderTitle = () => {
  4704. if (props.showTitle) {
  4705. const text = props.title || t$f("title");
  4706. const title = slots.title ? slots.title() : text;
  4707. return createVNode("div", {
  4708. "class": bem$11("header-title")
  4709. }, [title]);
  4710. }
  4711. };
  4712. const onClickSubtitle = (event) => emit("click-subtitle", event);
  4713. const renderSubtitle = () => {
  4714. if (props.showSubtitle) {
  4715. const title = slots.subtitle ? slots.subtitle() : props.subtitle;
  4716. return createVNode("div", {
  4717. "class": bem$11("header-subtitle"),
  4718. "onClick": onClickSubtitle
  4719. }, [title]);
  4720. }
  4721. };
  4722. const renderWeekDays = () => {
  4723. const {
  4724. firstDayOfWeek
  4725. } = props;
  4726. const weekdays = t$f("weekdays");
  4727. const renderWeekDays2 = [...weekdays.slice(firstDayOfWeek, 7), ...weekdays.slice(0, firstDayOfWeek)];
  4728. return createVNode("div", {
  4729. "class": bem$11("weekdays")
  4730. }, [renderWeekDays2.map((text) => createVNode("span", {
  4731. "class": bem$11("weekday")
  4732. }, [text]))]);
  4733. };
  4734. return () => createVNode("div", {
  4735. "class": bem$11("header")
  4736. }, [renderTitle(), renderSubtitle(), renderWeekDays()]);
  4737. }
  4738. });
  4739. const calendarProps = {
  4740. show: Boolean,
  4741. type: makeStringProp("single"),
  4742. title: String,
  4743. color: String,
  4744. round: truthProp,
  4745. readonly: Boolean,
  4746. poppable: truthProp,
  4747. maxRange: makeNumericProp(null),
  4748. position: makeStringProp("bottom"),
  4749. teleport: [String, Object],
  4750. showMark: truthProp,
  4751. showTitle: truthProp,
  4752. formatter: Function,
  4753. rowHeight: numericProp,
  4754. confirmText: String,
  4755. rangePrompt: String,
  4756. lazyRender: truthProp,
  4757. showConfirm: truthProp,
  4758. defaultDate: [Date, Array],
  4759. allowSameDay: Boolean,
  4760. showSubtitle: truthProp,
  4761. closeOnPopstate: truthProp,
  4762. showRangePrompt: truthProp,
  4763. confirmDisabledText: String,
  4764. closeOnClickOverlay: truthProp,
  4765. safeAreaInsetTop: Boolean,
  4766. safeAreaInsetBottom: truthProp,
  4767. minDate: {
  4768. type: Date,
  4769. validator: isDate,
  4770. default: getToday
  4771. },
  4772. maxDate: {
  4773. type: Date,
  4774. validator: isDate,
  4775. default: () => {
  4776. const now = getToday();
  4777. return new Date(now.getFullYear(), now.getMonth() + 6, now.getDate());
  4778. }
  4779. },
  4780. firstDayOfWeek: {
  4781. type: numericProp,
  4782. default: 0,
  4783. validator: (val) => val >= 0 && val <= 6
  4784. }
  4785. };
  4786. var stdin_default$18 = defineComponent({
  4787. name: name$15,
  4788. props: calendarProps,
  4789. emits: ["select", "confirm", "unselect", "month-show", "over-range", "update:show", "click-subtitle"],
  4790. setup(props, {
  4791. emit,
  4792. slots
  4793. }) {
  4794. const limitDateRange = (date, minDate = props.minDate, maxDate = props.maxDate) => {
  4795. if (compareDay(date, minDate) === -1) {
  4796. return minDate;
  4797. }
  4798. if (compareDay(date, maxDate) === 1) {
  4799. return maxDate;
  4800. }
  4801. return date;
  4802. };
  4803. const getInitialDate = (defaultDate = props.defaultDate) => {
  4804. const {
  4805. type,
  4806. minDate,
  4807. maxDate,
  4808. allowSameDay
  4809. } = props;
  4810. if (defaultDate === null) {
  4811. return defaultDate;
  4812. }
  4813. const now = getToday();
  4814. if (type === "range") {
  4815. if (!Array.isArray(defaultDate)) {
  4816. defaultDate = [];
  4817. }
  4818. const start = limitDateRange(defaultDate[0] || now, minDate, allowSameDay ? maxDate : getPrevDay(maxDate));
  4819. const end = limitDateRange(defaultDate[1] || now, allowSameDay ? minDate : getNextDay(minDate));
  4820. return [start, end];
  4821. }
  4822. if (type === "multiple") {
  4823. if (Array.isArray(defaultDate)) {
  4824. return defaultDate.map((date) => limitDateRange(date));
  4825. }
  4826. return [limitDateRange(now)];
  4827. }
  4828. if (!defaultDate || Array.isArray(defaultDate)) {
  4829. defaultDate = now;
  4830. }
  4831. return limitDateRange(defaultDate);
  4832. };
  4833. let bodyHeight;
  4834. const bodyRef = ref();
  4835. const subtitle = ref("");
  4836. const currentDate = ref(getInitialDate());
  4837. const [monthRefs, setMonthRefs] = useRefs();
  4838. const dayOffset = computed(() => props.firstDayOfWeek ? +props.firstDayOfWeek % 7 : 0);
  4839. const months = computed(() => {
  4840. const months2 = [];
  4841. const cursor = new Date(props.minDate);
  4842. cursor.setDate(1);
  4843. do {
  4844. months2.push(new Date(cursor));
  4845. cursor.setMonth(cursor.getMonth() + 1);
  4846. } while (compareMonth(cursor, props.maxDate) !== 1);
  4847. return months2;
  4848. });
  4849. const buttonDisabled = computed(() => {
  4850. if (currentDate.value) {
  4851. if (props.type === "range") {
  4852. return !currentDate.value[0] || !currentDate.value[1];
  4853. }
  4854. if (props.type === "multiple") {
  4855. return !currentDate.value.length;
  4856. }
  4857. }
  4858. return !currentDate.value;
  4859. });
  4860. const getSelectedDate = () => currentDate.value;
  4861. const onScroll = () => {
  4862. const top = getScrollTop(bodyRef.value);
  4863. const bottom = top + bodyHeight;
  4864. const heights = months.value.map((item, index) => monthRefs.value[index].getHeight());
  4865. const heightSum = heights.reduce((a, b) => a + b, 0);
  4866. if (bottom > heightSum && top > 0) {
  4867. return;
  4868. }
  4869. let height = 0;
  4870. let currentMonth;
  4871. const visibleRange = [-1, -1];
  4872. for (let i = 0; i < months.value.length; i++) {
  4873. const month = monthRefs.value[i];
  4874. const visible = height <= bottom && height + heights[i] >= top;
  4875. if (visible) {
  4876. visibleRange[1] = i;
  4877. if (!currentMonth) {
  4878. currentMonth = month;
  4879. visibleRange[0] = i;
  4880. }
  4881. if (!monthRefs.value[i].showed) {
  4882. monthRefs.value[i].showed = true;
  4883. emit("month-show", {
  4884. date: month.date,
  4885. title: month.getTitle()
  4886. });
  4887. }
  4888. }
  4889. height += heights[i];
  4890. }
  4891. months.value.forEach((month, index) => {
  4892. const visible = index >= visibleRange[0] - 1 && index <= visibleRange[1] + 1;
  4893. monthRefs.value[index].setVisible(visible);
  4894. });
  4895. if (currentMonth) {
  4896. subtitle.value = currentMonth.getTitle();
  4897. }
  4898. };
  4899. const scrollToDate = (targetDate) => {
  4900. raf(() => {
  4901. months.value.some((month, index) => {
  4902. if (compareMonth(month, targetDate) === 0) {
  4903. if (bodyRef.value) {
  4904. monthRefs.value[index].scrollToDate(bodyRef.value, targetDate);
  4905. }
  4906. return true;
  4907. }
  4908. return false;
  4909. });
  4910. onScroll();
  4911. });
  4912. };
  4913. const scrollToCurrentDate = () => {
  4914. if (props.poppable && !props.show) {
  4915. return;
  4916. }
  4917. if (currentDate.value) {
  4918. const targetDate = props.type === "single" ? currentDate.value : currentDate.value[0];
  4919. if (isDate(targetDate)) {
  4920. scrollToDate(targetDate);
  4921. }
  4922. } else {
  4923. raf(onScroll);
  4924. }
  4925. };
  4926. const init = () => {
  4927. if (props.poppable && !props.show) {
  4928. return;
  4929. }
  4930. raf(() => {
  4931. bodyHeight = Math.floor(useRect(bodyRef).height);
  4932. });
  4933. scrollToCurrentDate();
  4934. };
  4935. const reset = (date = getInitialDate()) => {
  4936. currentDate.value = date;
  4937. scrollToCurrentDate();
  4938. };
  4939. const checkRange = (date) => {
  4940. const {
  4941. maxRange,
  4942. rangePrompt,
  4943. showRangePrompt
  4944. } = props;
  4945. if (maxRange && calcDateNum(date) > maxRange) {
  4946. if (showRangePrompt) {
  4947. Toast(rangePrompt || t$f("rangePrompt", maxRange));
  4948. }
  4949. emit("over-range");
  4950. return false;
  4951. }
  4952. return true;
  4953. };
  4954. const onConfirm = () => {
  4955. var _a;
  4956. return emit("confirm", (_a = currentDate.value) != null ? _a : cloneDates(currentDate.value));
  4957. };
  4958. const select = (date, complete) => {
  4959. const setCurrentDate = (date2) => {
  4960. currentDate.value = date2;
  4961. emit("select", cloneDates(date2));
  4962. };
  4963. if (complete && props.type === "range") {
  4964. const valid = checkRange(date);
  4965. if (!valid) {
  4966. setCurrentDate([date[0], getDayByOffset(date[0], +props.maxRange - 1)]);
  4967. return;
  4968. }
  4969. }
  4970. setCurrentDate(date);
  4971. if (complete && !props.showConfirm) {
  4972. onConfirm();
  4973. }
  4974. };
  4975. const getDisabledDate = (disabledDays2, startDay, date) => {
  4976. var _a;
  4977. return (_a = disabledDays2.find((day) => compareDay(startDay, day.date) === -1 && compareDay(day.date, date) === -1)) == null ? void 0 : _a.date;
  4978. };
  4979. const disabledDays = computed(() => monthRefs.value.reduce((arr, ref2) => {
  4980. var _a, _b;
  4981. arr.push(...(_b = (_a = ref2.disabledDays) == null ? void 0 : _a.value) != null ? _b : []);
  4982. return arr;
  4983. }, []));
  4984. const onClickDay = (item) => {
  4985. if (props.readonly || !item.date) {
  4986. return;
  4987. }
  4988. const {
  4989. date
  4990. } = item;
  4991. const {
  4992. type
  4993. } = props;
  4994. if (type === "range") {
  4995. if (!currentDate.value) {
  4996. select([date]);
  4997. return;
  4998. }
  4999. const [startDay, endDay] = currentDate.value;
  5000. if (startDay && !endDay) {
  5001. const compareToStart = compareDay(date, startDay);
  5002. if (compareToStart === 1) {
  5003. const disabledDay = getDisabledDate(disabledDays.value, startDay, date);
  5004. if (disabledDay) {
  5005. const endDay2 = getPrevDay(disabledDay);
  5006. if (compareDay(startDay, endDay2) === -1) {
  5007. select([startDay, endDay2]);
  5008. } else {
  5009. select([date]);
  5010. }
  5011. } else {
  5012. select([startDay, date], true);
  5013. }
  5014. } else if (compareToStart === -1) {
  5015. select([date]);
  5016. } else if (props.allowSameDay) {
  5017. select([date, date], true);
  5018. }
  5019. } else {
  5020. select([date]);
  5021. }
  5022. } else if (type === "multiple") {
  5023. if (!currentDate.value) {
  5024. select([date]);
  5025. return;
  5026. }
  5027. const dates = currentDate.value;
  5028. const selectedIndex = dates.findIndex((dateItem) => compareDay(dateItem, date) === 0);
  5029. if (selectedIndex !== -1) {
  5030. const [unselectedDate] = dates.splice(selectedIndex, 1);
  5031. emit("unselect", cloneDate(unselectedDate));
  5032. } else if (props.maxRange && dates.length >= props.maxRange) {
  5033. Toast(props.rangePrompt || t$f("rangePrompt", props.maxRange));
  5034. } else {
  5035. select([...dates, date]);
  5036. }
  5037. } else {
  5038. select(date, true);
  5039. }
  5040. };
  5041. const updateShow = (value) => emit("update:show", value);
  5042. const renderMonth = (date, index) => {
  5043. const showMonthTitle = index !== 0 || !props.showSubtitle;
  5044. return createVNode(stdin_default$1a, mergeProps({
  5045. "ref": setMonthRefs(index),
  5046. "date": date,
  5047. "currentDate": currentDate.value,
  5048. "showMonthTitle": showMonthTitle,
  5049. "firstDayOfWeek": dayOffset.value
  5050. }, pick(props, ["type", "color", "minDate", "maxDate", "showMark", "formatter", "rowHeight", "lazyRender", "showSubtitle", "allowSameDay"]), {
  5051. "onClick": onClickDay
  5052. }), pick(slots, ["top-info", "bottom-info"]));
  5053. };
  5054. const renderFooterButton = () => {
  5055. if (slots.footer) {
  5056. return slots.footer();
  5057. }
  5058. if (props.showConfirm) {
  5059. const slot = slots["confirm-text"];
  5060. const disabled = buttonDisabled.value;
  5061. const text = disabled ? props.confirmDisabledText : props.confirmText;
  5062. return createVNode(Button, {
  5063. "round": true,
  5064. "block": true,
  5065. "type": "danger",
  5066. "color": props.color,
  5067. "class": bem$11("confirm"),
  5068. "disabled": disabled,
  5069. "nativeType": "button",
  5070. "onClick": onConfirm
  5071. }, {
  5072. default: () => [slot ? slot({
  5073. disabled
  5074. }) : text || t$f("confirm")]
  5075. });
  5076. }
  5077. };
  5078. const renderFooter = () => createVNode("div", {
  5079. "class": [bem$11("footer"), {
  5080. "van-safe-area-bottom": props.safeAreaInsetBottom
  5081. }]
  5082. }, [renderFooterButton()]);
  5083. const renderCalendar = () => createVNode("div", {
  5084. "class": bem$11()
  5085. }, [createVNode(stdin_default$19, {
  5086. "title": props.title,
  5087. "subtitle": subtitle.value,
  5088. "showTitle": props.showTitle,
  5089. "showSubtitle": props.showSubtitle,
  5090. "firstDayOfWeek": dayOffset.value,
  5091. "onClick-subtitle": (event) => emit("click-subtitle", event)
  5092. }, pick(slots, ["title", "subtitle"])), createVNode("div", {
  5093. "ref": bodyRef,
  5094. "class": bem$11("body"),
  5095. "onScroll": onScroll
  5096. }, [months.value.map(renderMonth)]), renderFooter()]);
  5097. watch(() => props.show, init);
  5098. watch(() => [props.type, props.minDate, props.maxDate], () => reset(getInitialDate(currentDate.value)));
  5099. watch(() => props.defaultDate, (value = null) => {
  5100. currentDate.value = value;
  5101. scrollToCurrentDate();
  5102. });
  5103. useExpose({
  5104. reset,
  5105. scrollToDate,
  5106. getSelectedDate
  5107. });
  5108. onMountedOrActivated(init);
  5109. return () => {
  5110. if (props.poppable) {
  5111. return createVNode(Popup, {
  5112. "show": props.show,
  5113. "class": bem$11("popup"),
  5114. "round": props.round,
  5115. "position": props.position,
  5116. "closeable": props.showTitle || props.showSubtitle,
  5117. "teleport": props.teleport,
  5118. "closeOnPopstate": props.closeOnPopstate,
  5119. "safeAreaInsetTop": props.safeAreaInsetTop,
  5120. "closeOnClickOverlay": props.closeOnClickOverlay,
  5121. "onUpdate:show": updateShow
  5122. }, {
  5123. default: renderCalendar
  5124. });
  5125. }
  5126. return renderCalendar();
  5127. };
  5128. }
  5129. });
  5130. const Calendar = withInstall(stdin_default$18);
  5131. const [name$11, bem$10] = createNamespace("image");
  5132. const imageProps = {
  5133. src: String,
  5134. alt: String,
  5135. fit: String,
  5136. position: String,
  5137. round: Boolean,
  5138. block: Boolean,
  5139. width: numericProp,
  5140. height: numericProp,
  5141. radius: numericProp,
  5142. lazyLoad: Boolean,
  5143. iconSize: numericProp,
  5144. showError: truthProp,
  5145. errorIcon: makeStringProp("photo-fail"),
  5146. iconPrefix: String,
  5147. showLoading: truthProp,
  5148. loadingIcon: makeStringProp("photo")
  5149. };
  5150. var stdin_default$17 = defineComponent({
  5151. name: name$11,
  5152. props: imageProps,
  5153. emits: ["load", "error"],
  5154. setup(props, {
  5155. emit,
  5156. slots
  5157. }) {
  5158. const error = ref(false);
  5159. const loading = ref(true);
  5160. const imageRef = ref();
  5161. const {
  5162. $Lazyload
  5163. } = getCurrentInstance().proxy;
  5164. const style = computed(() => {
  5165. const style2 = {
  5166. width: addUnit(props.width),
  5167. height: addUnit(props.height)
  5168. };
  5169. if (isDef(props.radius)) {
  5170. style2.overflow = "hidden";
  5171. style2.borderRadius = addUnit(props.radius);
  5172. }
  5173. return style2;
  5174. });
  5175. watch(() => props.src, () => {
  5176. error.value = false;
  5177. loading.value = true;
  5178. });
  5179. const onLoad = (event) => {
  5180. loading.value = false;
  5181. emit("load", event);
  5182. };
  5183. const onError = (event) => {
  5184. error.value = true;
  5185. loading.value = false;
  5186. emit("error", event);
  5187. };
  5188. const renderIcon = (name2, className, slot) => {
  5189. if (slot) {
  5190. return slot();
  5191. }
  5192. return createVNode(Icon, {
  5193. "name": name2,
  5194. "size": props.iconSize,
  5195. "class": className,
  5196. "classPrefix": props.iconPrefix
  5197. }, null);
  5198. };
  5199. const renderPlaceholder = () => {
  5200. if (loading.value && props.showLoading) {
  5201. return createVNode("div", {
  5202. "class": bem$10("loading")
  5203. }, [renderIcon(props.loadingIcon, bem$10("loading-icon"), slots.loading)]);
  5204. }
  5205. if (error.value && props.showError) {
  5206. return createVNode("div", {
  5207. "class": bem$10("error")
  5208. }, [renderIcon(props.errorIcon, bem$10("error-icon"), slots.error)]);
  5209. }
  5210. };
  5211. const renderImage = () => {
  5212. if (error.value || !props.src) {
  5213. return;
  5214. }
  5215. const attrs = {
  5216. alt: props.alt,
  5217. class: bem$10("img"),
  5218. style: {
  5219. objectFit: props.fit,
  5220. objectPosition: props.position
  5221. }
  5222. };
  5223. if (props.lazyLoad) {
  5224. return withDirectives(createVNode("img", mergeProps({
  5225. "ref": imageRef
  5226. }, attrs), null), [[resolveDirective("lazy"), props.src]]);
  5227. }
  5228. return createVNode("img", mergeProps({
  5229. "src": props.src,
  5230. "onLoad": onLoad,
  5231. "onError": onError
  5232. }, attrs), null);
  5233. };
  5234. const onLazyLoaded = ({
  5235. el
  5236. }) => {
  5237. const check = () => {
  5238. if (el === imageRef.value && loading.value) {
  5239. onLoad();
  5240. }
  5241. };
  5242. if (imageRef.value) {
  5243. check();
  5244. } else {
  5245. nextTick(check);
  5246. }
  5247. };
  5248. const onLazyLoadError = ({
  5249. el
  5250. }) => {
  5251. if (el === imageRef.value && !error.value) {
  5252. onError();
  5253. }
  5254. };
  5255. if ($Lazyload && inBrowser) {
  5256. $Lazyload.$on("loaded", onLazyLoaded);
  5257. $Lazyload.$on("error", onLazyLoadError);
  5258. onBeforeUnmount(() => {
  5259. $Lazyload.$off("loaded", onLazyLoaded);
  5260. $Lazyload.$off("error", onLazyLoadError);
  5261. });
  5262. }
  5263. return () => {
  5264. var _a;
  5265. return createVNode("div", {
  5266. "class": bem$10({
  5267. round: props.round,
  5268. block: props.block
  5269. }),
  5270. "style": style.value
  5271. }, [renderImage(), renderPlaceholder(), (_a = slots.default) == null ? void 0 : _a.call(slots)]);
  5272. };
  5273. }
  5274. });
  5275. const Image$1 = withInstall(stdin_default$17);
  5276. const [name$10, bem$$] = createNamespace("card");
  5277. const cardProps = {
  5278. tag: String,
  5279. num: numericProp,
  5280. desc: String,
  5281. thumb: String,
  5282. title: String,
  5283. price: numericProp,
  5284. centered: Boolean,
  5285. lazyLoad: Boolean,
  5286. currency: makeStringProp("\xA5"),
  5287. thumbLink: String,
  5288. originPrice: numericProp
  5289. };
  5290. var stdin_default$16 = defineComponent({
  5291. name: name$10,
  5292. props: cardProps,
  5293. emits: ["click-thumb"],
  5294. setup(props, {
  5295. slots,
  5296. emit
  5297. }) {
  5298. const renderTitle = () => {
  5299. if (slots.title) {
  5300. return slots.title();
  5301. }
  5302. if (props.title) {
  5303. return createVNode("div", {
  5304. "class": [bem$$("title"), "van-multi-ellipsis--l2"]
  5305. }, [props.title]);
  5306. }
  5307. };
  5308. const renderThumbTag = () => {
  5309. if (slots.tag || props.tag) {
  5310. return createVNode("div", {
  5311. "class": bem$$("tag")
  5312. }, [slots.tag ? slots.tag() : createVNode(Tag, {
  5313. "mark": true,
  5314. "type": "danger"
  5315. }, {
  5316. default: () => [props.tag]
  5317. })]);
  5318. }
  5319. };
  5320. const renderThumbImage = () => {
  5321. if (slots.thumb) {
  5322. return slots.thumb();
  5323. }
  5324. return createVNode(Image$1, {
  5325. "src": props.thumb,
  5326. "fit": "cover",
  5327. "width": "100%",
  5328. "height": "100%",
  5329. "lazyLoad": props.lazyLoad
  5330. }, null);
  5331. };
  5332. const renderThumb = () => {
  5333. if (slots.thumb || props.thumb) {
  5334. return createVNode("a", {
  5335. "href": props.thumbLink,
  5336. "class": bem$$("thumb"),
  5337. "onClick": (event) => emit("click-thumb", event)
  5338. }, [renderThumbImage(), renderThumbTag()]);
  5339. }
  5340. };
  5341. const renderDesc = () => {
  5342. if (slots.desc) {
  5343. return slots.desc();
  5344. }
  5345. if (props.desc) {
  5346. return createVNode("div", {
  5347. "class": [bem$$("desc"), "van-ellipsis"]
  5348. }, [props.desc]);
  5349. }
  5350. };
  5351. const renderPriceText = () => {
  5352. const priceArr = props.price.toString().split(".");
  5353. return createVNode("div", null, [createVNode("span", {
  5354. "class": bem$$("price-currency")
  5355. }, [props.currency]), createVNode("span", {
  5356. "class": bem$$("price-integer")
  5357. }, [priceArr[0]]), createTextVNode("."), createVNode("span", {
  5358. "class": bem$$("price-decimal")
  5359. }, [priceArr[1]])]);
  5360. };
  5361. return () => {
  5362. var _a, _b, _c;
  5363. const showNum = slots.num || isDef(props.num);
  5364. const showPrice = slots.price || isDef(props.price);
  5365. const showOriginPrice = slots["origin-price"] || isDef(props.originPrice);
  5366. const showBottom = showNum || showPrice || showOriginPrice || slots.bottom;
  5367. const Price = showPrice && createVNode("div", {
  5368. "class": bem$$("price")
  5369. }, [slots.price ? slots.price() : renderPriceText()]);
  5370. const OriginPrice = showOriginPrice && createVNode("div", {
  5371. "class": bem$$("origin-price")
  5372. }, [slots["origin-price"] ? slots["origin-price"]() : `${props.currency} ${props.originPrice}`]);
  5373. const Num = showNum && createVNode("div", {
  5374. "class": bem$$("num")
  5375. }, [slots.num ? slots.num() : `x${props.num}`]);
  5376. const Footer = slots.footer && createVNode("div", {
  5377. "class": bem$$("footer")
  5378. }, [slots.footer()]);
  5379. const Bottom = showBottom && createVNode("div", {
  5380. "class": bem$$("bottom")
  5381. }, [(_a = slots["price-top"]) == null ? void 0 : _a.call(slots), Price, OriginPrice, Num, (_b = slots.bottom) == null ? void 0 : _b.call(slots)]);
  5382. return createVNode("div", {
  5383. "class": bem$$()
  5384. }, [createVNode("div", {
  5385. "class": bem$$("header")
  5386. }, [renderThumb(), createVNode("div", {
  5387. "class": bem$$("content", {
  5388. centered: props.centered
  5389. })
  5390. }, [createVNode("div", null, [renderTitle(), renderDesc(), (_c = slots.tags) == null ? void 0 : _c.call(slots)]), Bottom])]), Footer]);
  5391. };
  5392. }
  5393. });
  5394. const Card = withInstall(stdin_default$16);
  5395. function scrollLeftTo(scroller, to, duration) {
  5396. let count = 0;
  5397. const from = scroller.scrollLeft;
  5398. const frames = duration === 0 ? 1 : Math.round(duration * 1e3 / 16);
  5399. function animate() {
  5400. scroller.scrollLeft += (to - from) / frames;
  5401. if (++count < frames) {
  5402. raf(animate);
  5403. }
  5404. }
  5405. animate();
  5406. }
  5407. function scrollTopTo(scroller, to, duration, callback) {
  5408. let current2 = getScrollTop(scroller);
  5409. const isDown = current2 < to;
  5410. const frames = duration === 0 ? 1 : Math.round(duration * 1e3 / 16);
  5411. const step = (to - current2) / frames;
  5412. function animate() {
  5413. current2 += step;
  5414. if (isDown && current2 > to || !isDown && current2 < to) {
  5415. current2 = to;
  5416. }
  5417. setScrollTop(scroller, current2);
  5418. if (isDown && current2 < to || !isDown && current2 > to) {
  5419. raf(animate);
  5420. } else if (callback) {
  5421. raf(callback);
  5422. }
  5423. }
  5424. animate();
  5425. }
  5426. function useVisibilityChange(target, onChange) {
  5427. if (!inBrowser || !window.IntersectionObserver) {
  5428. return;
  5429. }
  5430. const observer = new IntersectionObserver(
  5431. (entries) => {
  5432. onChange(entries[0].intersectionRatio > 0);
  5433. },
  5434. { root: document.body }
  5435. );
  5436. const observe = () => {
  5437. if (target.value) {
  5438. observer.observe(target.value);
  5439. }
  5440. };
  5441. const unobserve = () => {
  5442. if (target.value) {
  5443. observer.unobserve(target.value);
  5444. }
  5445. };
  5446. onDeactivated(unobserve);
  5447. onBeforeUnmount(unobserve);
  5448. onMountedOrActivated(observe);
  5449. }
  5450. const [name$$, bem$_] = createNamespace("sticky");
  5451. const stickyProps = {
  5452. zIndex: numericProp,
  5453. position: makeStringProp("top"),
  5454. container: Object,
  5455. offsetTop: makeNumericProp(0),
  5456. offsetBottom: makeNumericProp(0)
  5457. };
  5458. var stdin_default$15 = defineComponent({
  5459. name: name$$,
  5460. props: stickyProps,
  5461. emits: ["scroll", "change"],
  5462. setup(props, {
  5463. emit,
  5464. slots
  5465. }) {
  5466. const root = ref();
  5467. const scrollParent = useScrollParent(root);
  5468. const state = reactive({
  5469. fixed: false,
  5470. width: 0,
  5471. height: 0,
  5472. transform: 0
  5473. });
  5474. const offset = computed(() => unitToPx(props.position === "top" ? props.offsetTop : props.offsetBottom));
  5475. const rootStyle = computed(() => {
  5476. const {
  5477. fixed,
  5478. height,
  5479. width
  5480. } = state;
  5481. if (fixed) {
  5482. return {
  5483. width: `${width}px`,
  5484. height: `${height}px`
  5485. };
  5486. }
  5487. });
  5488. const stickyStyle = computed(() => {
  5489. if (!state.fixed) {
  5490. return;
  5491. }
  5492. const style = extend(getZIndexStyle(props.zIndex), {
  5493. width: `${state.width}px`,
  5494. height: `${state.height}px`,
  5495. [props.position]: `${offset.value}px`
  5496. });
  5497. if (state.transform) {
  5498. style.transform = `translate3d(0, ${state.transform}px, 0)`;
  5499. }
  5500. return style;
  5501. });
  5502. const emitScroll = (scrollTop) => emit("scroll", {
  5503. scrollTop,
  5504. isFixed: state.fixed
  5505. });
  5506. const onScroll = () => {
  5507. if (!root.value || isHidden(root)) {
  5508. return;
  5509. }
  5510. const {
  5511. container,
  5512. position
  5513. } = props;
  5514. const rootRect = useRect(root);
  5515. const scrollTop = getScrollTop(window);
  5516. state.width = rootRect.width;
  5517. state.height = rootRect.height;
  5518. if (position === "top") {
  5519. if (container) {
  5520. const containerRect = useRect(container);
  5521. const difference = containerRect.bottom - offset.value - state.height;
  5522. state.fixed = offset.value > rootRect.top && containerRect.bottom > 0;
  5523. state.transform = difference < 0 ? difference : 0;
  5524. } else {
  5525. state.fixed = offset.value > rootRect.top;
  5526. }
  5527. } else {
  5528. const {
  5529. clientHeight
  5530. } = document.documentElement;
  5531. if (container) {
  5532. const containerRect = useRect(container);
  5533. const difference = clientHeight - containerRect.top - offset.value - state.height;
  5534. state.fixed = clientHeight - offset.value < rootRect.bottom && clientHeight > containerRect.top;
  5535. state.transform = difference < 0 ? -difference : 0;
  5536. } else {
  5537. state.fixed = clientHeight - offset.value < rootRect.bottom;
  5538. }
  5539. }
  5540. emitScroll(scrollTop);
  5541. };
  5542. watch(() => state.fixed, (value) => emit("change", value));
  5543. useEventListener("scroll", onScroll, {
  5544. target: scrollParent,
  5545. passive: true
  5546. });
  5547. useVisibilityChange(root, onScroll);
  5548. return () => {
  5549. var _a;
  5550. return createVNode("div", {
  5551. "ref": root,
  5552. "style": rootStyle.value
  5553. }, [createVNode("div", {
  5554. "class": bem$_({
  5555. fixed: state.fixed
  5556. }),
  5557. "style": stickyStyle.value
  5558. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)])]);
  5559. };
  5560. }
  5561. });
  5562. const Sticky = withInstall(stdin_default$15);
  5563. const [name$_, bem$Z] = createNamespace("tab");
  5564. var stdin_default$14 = defineComponent({
  5565. name: name$_,
  5566. props: {
  5567. id: String,
  5568. dot: Boolean,
  5569. type: String,
  5570. color: String,
  5571. title: String,
  5572. badge: numericProp,
  5573. shrink: Boolean,
  5574. isActive: Boolean,
  5575. disabled: Boolean,
  5576. controls: String,
  5577. scrollable: Boolean,
  5578. activeColor: String,
  5579. inactiveColor: String,
  5580. showZeroBadge: truthProp
  5581. },
  5582. setup(props, {
  5583. slots
  5584. }) {
  5585. const style = computed(() => {
  5586. const style2 = {};
  5587. const {
  5588. type,
  5589. color,
  5590. disabled,
  5591. isActive,
  5592. activeColor,
  5593. inactiveColor
  5594. } = props;
  5595. const isCard = type === "card";
  5596. if (color && isCard) {
  5597. style2.borderColor = color;
  5598. if (!disabled) {
  5599. if (isActive) {
  5600. style2.backgroundColor = color;
  5601. } else {
  5602. style2.color = color;
  5603. }
  5604. }
  5605. }
  5606. const titleColor = isActive ? activeColor : inactiveColor;
  5607. if (titleColor) {
  5608. style2.color = titleColor;
  5609. }
  5610. return style2;
  5611. });
  5612. const renderText = () => {
  5613. const Text2 = createVNode("span", {
  5614. "class": bem$Z("text", {
  5615. ellipsis: !props.scrollable
  5616. })
  5617. }, [slots.title ? slots.title() : props.title]);
  5618. if (props.dot || isDef(props.badge) && props.badge !== "") {
  5619. return createVNode(Badge, {
  5620. "dot": props.dot,
  5621. "content": props.badge,
  5622. "showZero": props.showZeroBadge
  5623. }, {
  5624. default: () => [Text2]
  5625. });
  5626. }
  5627. return Text2;
  5628. };
  5629. return () => createVNode("div", {
  5630. "id": props.id,
  5631. "role": "tab",
  5632. "class": [bem$Z([props.type, {
  5633. grow: props.scrollable && !props.shrink,
  5634. shrink: props.shrink,
  5635. active: props.isActive,
  5636. disabled: props.disabled
  5637. }])],
  5638. "style": style.value,
  5639. "tabindex": props.disabled ? void 0 : props.isActive ? 0 : -1,
  5640. "aria-selected": props.isActive,
  5641. "aria-disabled": props.disabled || void 0,
  5642. "aria-controls": props.controls
  5643. }, [renderText()]);
  5644. }
  5645. });
  5646. const [name$Z, bem$Y] = createNamespace("swipe");
  5647. const swipeProps = {
  5648. loop: truthProp,
  5649. width: numericProp,
  5650. height: numericProp,
  5651. vertical: Boolean,
  5652. autoplay: makeNumericProp(0),
  5653. duration: makeNumericProp(500),
  5654. touchable: truthProp,
  5655. lazyRender: Boolean,
  5656. initialSwipe: makeNumericProp(0),
  5657. indicatorColor: String,
  5658. showIndicators: truthProp,
  5659. stopPropagation: truthProp
  5660. };
  5661. const SWIPE_KEY = Symbol(name$Z);
  5662. var stdin_default$13 = defineComponent({
  5663. name: name$Z,
  5664. props: swipeProps,
  5665. emits: ["change"],
  5666. setup(props, {
  5667. emit,
  5668. slots
  5669. }) {
  5670. const root = ref();
  5671. const track = ref();
  5672. const state = reactive({
  5673. rect: null,
  5674. width: 0,
  5675. height: 0,
  5676. offset: 0,
  5677. active: 0,
  5678. swiping: false
  5679. });
  5680. const touch = useTouch();
  5681. const {
  5682. children,
  5683. linkChildren
  5684. } = useChildren(SWIPE_KEY);
  5685. const count = computed(() => children.length);
  5686. const size = computed(() => state[props.vertical ? "height" : "width"]);
  5687. const delta = computed(() => props.vertical ? touch.deltaY.value : touch.deltaX.value);
  5688. const minOffset = computed(() => {
  5689. if (state.rect) {
  5690. const base = props.vertical ? state.rect.height : state.rect.width;
  5691. return base - size.value * count.value;
  5692. }
  5693. return 0;
  5694. });
  5695. const maxCount = computed(() => Math.ceil(Math.abs(minOffset.value) / size.value));
  5696. const trackSize = computed(() => count.value * size.value);
  5697. const activeIndicator = computed(() => (state.active + count.value) % count.value);
  5698. const isCorrectDirection = computed(() => {
  5699. const expect = props.vertical ? "vertical" : "horizontal";
  5700. return touch.direction.value === expect;
  5701. });
  5702. const trackStyle = computed(() => {
  5703. const style = {
  5704. transitionDuration: `${state.swiping ? 0 : props.duration}ms`,
  5705. transform: `translate${props.vertical ? "Y" : "X"}(${state.offset}px)`
  5706. };
  5707. if (size.value) {
  5708. const mainAxis = props.vertical ? "height" : "width";
  5709. const crossAxis = props.vertical ? "width" : "height";
  5710. style[mainAxis] = `${trackSize.value}px`;
  5711. style[crossAxis] = props[crossAxis] ? `${props[crossAxis]}px` : "";
  5712. }
  5713. return style;
  5714. });
  5715. const getTargetActive = (pace) => {
  5716. const {
  5717. active
  5718. } = state;
  5719. if (pace) {
  5720. if (props.loop) {
  5721. return clamp(active + pace, -1, count.value);
  5722. }
  5723. return clamp(active + pace, 0, maxCount.value);
  5724. }
  5725. return active;
  5726. };
  5727. const getTargetOffset = (targetActive, offset = 0) => {
  5728. let currentPosition = targetActive * size.value;
  5729. if (!props.loop) {
  5730. currentPosition = Math.min(currentPosition, -minOffset.value);
  5731. }
  5732. let targetOffset = offset - currentPosition;
  5733. if (!props.loop) {
  5734. targetOffset = clamp(targetOffset, minOffset.value, 0);
  5735. }
  5736. return targetOffset;
  5737. };
  5738. const move = ({
  5739. pace = 0,
  5740. offset = 0,
  5741. emitChange
  5742. }) => {
  5743. if (count.value <= 1) {
  5744. return;
  5745. }
  5746. const {
  5747. active
  5748. } = state;
  5749. const targetActive = getTargetActive(pace);
  5750. const targetOffset = getTargetOffset(targetActive, offset);
  5751. if (props.loop) {
  5752. if (children[0] && targetOffset !== minOffset.value) {
  5753. const outRightBound = targetOffset < minOffset.value;
  5754. children[0].setOffset(outRightBound ? trackSize.value : 0);
  5755. }
  5756. if (children[count.value - 1] && targetOffset !== 0) {
  5757. const outLeftBound = targetOffset > 0;
  5758. children[count.value - 1].setOffset(outLeftBound ? -trackSize.value : 0);
  5759. }
  5760. }
  5761. state.active = targetActive;
  5762. state.offset = targetOffset;
  5763. if (emitChange && targetActive !== active) {
  5764. emit("change", activeIndicator.value);
  5765. }
  5766. };
  5767. const correctPosition = () => {
  5768. state.swiping = true;
  5769. if (state.active <= -1) {
  5770. move({
  5771. pace: count.value
  5772. });
  5773. } else if (state.active >= count.value) {
  5774. move({
  5775. pace: -count.value
  5776. });
  5777. }
  5778. };
  5779. const prev = () => {
  5780. correctPosition();
  5781. touch.reset();
  5782. doubleRaf(() => {
  5783. state.swiping = false;
  5784. move({
  5785. pace: -1,
  5786. emitChange: true
  5787. });
  5788. });
  5789. };
  5790. const next = () => {
  5791. correctPosition();
  5792. touch.reset();
  5793. doubleRaf(() => {
  5794. state.swiping = false;
  5795. move({
  5796. pace: 1,
  5797. emitChange: true
  5798. });
  5799. });
  5800. };
  5801. let autoplayTimer;
  5802. const stopAutoplay = () => clearTimeout(autoplayTimer);
  5803. const autoplay = () => {
  5804. stopAutoplay();
  5805. if (props.autoplay > 0 && count.value > 1) {
  5806. autoplayTimer = setTimeout(() => {
  5807. next();
  5808. autoplay();
  5809. }, +props.autoplay);
  5810. }
  5811. };
  5812. const initialize = (active = +props.initialSwipe) => {
  5813. if (!root.value) {
  5814. return;
  5815. }
  5816. const cb = () => {
  5817. var _a, _b;
  5818. if (!isHidden(root)) {
  5819. const rect = {
  5820. width: root.value.offsetWidth,
  5821. height: root.value.offsetHeight
  5822. };
  5823. state.rect = rect;
  5824. state.width = +((_a = props.width) != null ? _a : rect.width);
  5825. state.height = +((_b = props.height) != null ? _b : rect.height);
  5826. }
  5827. if (count.value) {
  5828. active = Math.min(count.value - 1, active);
  5829. }
  5830. state.active = active;
  5831. state.swiping = true;
  5832. state.offset = getTargetOffset(active);
  5833. children.forEach((swipe) => {
  5834. swipe.setOffset(0);
  5835. });
  5836. autoplay();
  5837. };
  5838. if (isHidden(root)) {
  5839. nextTick().then(cb);
  5840. } else {
  5841. cb();
  5842. }
  5843. };
  5844. const resize = () => initialize(state.active);
  5845. let touchStartTime;
  5846. const onTouchStart = (event) => {
  5847. if (!props.touchable)
  5848. return;
  5849. touch.start(event);
  5850. touchStartTime = Date.now();
  5851. stopAutoplay();
  5852. correctPosition();
  5853. };
  5854. const onTouchMove = (event) => {
  5855. if (props.touchable && state.swiping) {
  5856. touch.move(event);
  5857. if (isCorrectDirection.value) {
  5858. const isEdgeTouch = !props.loop && (state.active === 0 && delta.value > 0 || state.active === count.value - 1 && delta.value < 0);
  5859. if (!isEdgeTouch) {
  5860. preventDefault(event, props.stopPropagation);
  5861. move({
  5862. offset: delta.value
  5863. });
  5864. }
  5865. }
  5866. }
  5867. };
  5868. const onTouchEnd = () => {
  5869. if (!props.touchable || !state.swiping) {
  5870. return;
  5871. }
  5872. const duration = Date.now() - touchStartTime;
  5873. const speed = delta.value / duration;
  5874. const shouldSwipe = Math.abs(speed) > 0.25 || Math.abs(delta.value) > size.value / 2;
  5875. if (shouldSwipe && isCorrectDirection.value) {
  5876. const offset = props.vertical ? touch.offsetY.value : touch.offsetX.value;
  5877. let pace = 0;
  5878. if (props.loop) {
  5879. pace = offset > 0 ? delta.value > 0 ? -1 : 1 : 0;
  5880. } else {
  5881. pace = -Math[delta.value > 0 ? "ceil" : "floor"](delta.value / size.value);
  5882. }
  5883. move({
  5884. pace,
  5885. emitChange: true
  5886. });
  5887. } else if (delta.value) {
  5888. move({
  5889. pace: 0
  5890. });
  5891. }
  5892. state.swiping = false;
  5893. autoplay();
  5894. };
  5895. const swipeTo = (index, options = {}) => {
  5896. correctPosition();
  5897. touch.reset();
  5898. doubleRaf(() => {
  5899. let targetIndex;
  5900. if (props.loop && index === count.value) {
  5901. targetIndex = state.active === 0 ? 0 : index;
  5902. } else {
  5903. targetIndex = index % count.value;
  5904. }
  5905. if (options.immediate) {
  5906. doubleRaf(() => {
  5907. state.swiping = false;
  5908. });
  5909. } else {
  5910. state.swiping = false;
  5911. }
  5912. move({
  5913. pace: targetIndex - state.active,
  5914. emitChange: true
  5915. });
  5916. });
  5917. };
  5918. const renderDot = (_, index) => {
  5919. const active = index === activeIndicator.value;
  5920. const style = active ? {
  5921. backgroundColor: props.indicatorColor
  5922. } : void 0;
  5923. return createVNode("i", {
  5924. "style": style,
  5925. "class": bem$Y("indicator", {
  5926. active
  5927. })
  5928. }, null);
  5929. };
  5930. const renderIndicator = () => {
  5931. if (slots.indicator) {
  5932. return slots.indicator({
  5933. active: activeIndicator.value,
  5934. total: count.value
  5935. });
  5936. }
  5937. if (props.showIndicators && count.value > 1) {
  5938. return createVNode("div", {
  5939. "class": bem$Y("indicators", {
  5940. vertical: props.vertical
  5941. })
  5942. }, [Array(count.value).fill("").map(renderDot)]);
  5943. }
  5944. };
  5945. useExpose({
  5946. prev,
  5947. next,
  5948. state,
  5949. resize,
  5950. swipeTo
  5951. });
  5952. linkChildren({
  5953. size,
  5954. props,
  5955. count,
  5956. activeIndicator
  5957. });
  5958. watch(() => props.initialSwipe, (value) => initialize(+value));
  5959. watch(count, () => initialize(state.active));
  5960. watch(() => props.autoplay, autoplay);
  5961. watch([windowWidth, windowHeight], resize);
  5962. watch(usePageVisibility(), (visible) => {
  5963. if (visible === "visible") {
  5964. autoplay();
  5965. } else {
  5966. stopAutoplay();
  5967. }
  5968. });
  5969. onMounted(initialize);
  5970. onActivated(() => initialize(state.active));
  5971. onPopupReopen(() => initialize(state.active));
  5972. onDeactivated(stopAutoplay);
  5973. onBeforeUnmount(stopAutoplay);
  5974. useEventListener("touchmove", onTouchMove, {
  5975. target: track
  5976. });
  5977. return () => {
  5978. var _a;
  5979. return createVNode("div", {
  5980. "ref": root,
  5981. "class": bem$Y()
  5982. }, [createVNode("div", {
  5983. "ref": track,
  5984. "style": trackStyle.value,
  5985. "class": bem$Y("track", {
  5986. vertical: props.vertical
  5987. }),
  5988. "onTouchstartPassive": onTouchStart,
  5989. "onTouchend": onTouchEnd,
  5990. "onTouchcancel": onTouchEnd
  5991. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]), renderIndicator()]);
  5992. };
  5993. }
  5994. });
  5995. const Swipe = withInstall(stdin_default$13);
  5996. const [name$Y, bem$X] = createNamespace("tabs");
  5997. var stdin_default$12 = defineComponent({
  5998. name: name$Y,
  5999. props: {
  6000. count: makeRequiredProp(Number),
  6001. inited: Boolean,
  6002. animated: Boolean,
  6003. duration: makeRequiredProp(numericProp),
  6004. swipeable: Boolean,
  6005. lazyRender: Boolean,
  6006. currentIndex: makeRequiredProp(Number)
  6007. },
  6008. emits: ["change"],
  6009. setup(props, {
  6010. emit,
  6011. slots
  6012. }) {
  6013. const swipeRef = ref();
  6014. const onChange = (index) => emit("change", index);
  6015. const renderChildren = () => {
  6016. var _a;
  6017. const Content = (_a = slots.default) == null ? void 0 : _a.call(slots);
  6018. if (props.animated || props.swipeable) {
  6019. return createVNode(Swipe, {
  6020. "ref": swipeRef,
  6021. "loop": false,
  6022. "class": bem$X("track"),
  6023. "duration": +props.duration * 1e3,
  6024. "touchable": props.swipeable,
  6025. "lazyRender": props.lazyRender,
  6026. "showIndicators": false,
  6027. "onChange": onChange
  6028. }, {
  6029. default: () => [Content]
  6030. });
  6031. }
  6032. return Content;
  6033. };
  6034. const swipeToCurrentTab = (index) => {
  6035. const swipe = swipeRef.value;
  6036. if (swipe && swipe.state.active !== index) {
  6037. swipe.swipeTo(index, {
  6038. immediate: !props.inited
  6039. });
  6040. }
  6041. };
  6042. watch(() => props.currentIndex, swipeToCurrentTab);
  6043. onMounted(() => {
  6044. swipeToCurrentTab(props.currentIndex);
  6045. });
  6046. useExpose({
  6047. swipeRef
  6048. });
  6049. return () => createVNode("div", {
  6050. "class": bem$X("content", {
  6051. animated: props.animated || props.swipeable
  6052. })
  6053. }, [renderChildren()]);
  6054. }
  6055. });
  6056. const [name$X, bem$W] = createNamespace("tabs");
  6057. const tabsProps = {
  6058. type: makeStringProp("line"),
  6059. color: String,
  6060. border: Boolean,
  6061. sticky: Boolean,
  6062. shrink: Boolean,
  6063. active: makeNumericProp(0),
  6064. duration: makeNumericProp(0.3),
  6065. animated: Boolean,
  6066. ellipsis: truthProp,
  6067. swipeable: Boolean,
  6068. scrollspy: Boolean,
  6069. offsetTop: makeNumericProp(0),
  6070. background: String,
  6071. lazyRender: truthProp,
  6072. lineWidth: numericProp,
  6073. lineHeight: numericProp,
  6074. beforeChange: Function,
  6075. swipeThreshold: makeNumericProp(5),
  6076. titleActiveColor: String,
  6077. titleInactiveColor: String
  6078. };
  6079. const TABS_KEY = Symbol(name$X);
  6080. var stdin_default$11 = defineComponent({
  6081. name: name$X,
  6082. props: tabsProps,
  6083. emits: ["click", "change", "scroll", "disabled", "rendered", "click-tab", "update:active"],
  6084. setup(props, {
  6085. emit,
  6086. slots
  6087. }) {
  6088. var _a, _b;
  6089. if (process.env.NODE_ENV !== "production") {
  6090. const props2 = (_b = (_a = getCurrentInstance()) == null ? void 0 : _a.vnode) == null ? void 0 : _b.props;
  6091. if (props2 && "onClick" in props2) {
  6092. console.warn('[Vant] Tabs: "click" event is deprecated, using "click-tab" instead.');
  6093. }
  6094. if (props2 && "onDisabled" in props2) {
  6095. console.warn('[Vant] Tabs: "disabled" event is deprecated, using "click-tab" instead.');
  6096. }
  6097. }
  6098. let tabHeight;
  6099. let lockScroll;
  6100. let stickyFixed;
  6101. const root = ref();
  6102. const navRef = ref();
  6103. const wrapRef = ref();
  6104. const contentRef = ref();
  6105. const id = useId();
  6106. const scroller = useScrollParent(root);
  6107. const [titleRefs, setTitleRefs] = useRefs();
  6108. const {
  6109. children,
  6110. linkChildren
  6111. } = useChildren(TABS_KEY);
  6112. const state = reactive({
  6113. inited: false,
  6114. position: "",
  6115. lineStyle: {},
  6116. currentIndex: -1
  6117. });
  6118. const scrollable = computed(() => children.length > props.swipeThreshold || !props.ellipsis || props.shrink);
  6119. const navStyle = computed(() => ({
  6120. borderColor: props.color,
  6121. background: props.background
  6122. }));
  6123. const getTabName = (tab, index) => {
  6124. var _a2;
  6125. return (_a2 = tab.name) != null ? _a2 : index;
  6126. };
  6127. const currentName = computed(() => {
  6128. const activeTab = children[state.currentIndex];
  6129. if (activeTab) {
  6130. return getTabName(activeTab, state.currentIndex);
  6131. }
  6132. });
  6133. const offsetTopPx = computed(() => unitToPx(props.offsetTop));
  6134. const scrollOffset = computed(() => {
  6135. if (props.sticky) {
  6136. return offsetTopPx.value + tabHeight;
  6137. }
  6138. return 0;
  6139. });
  6140. const scrollIntoView = (immediate) => {
  6141. const nav = navRef.value;
  6142. const titles = titleRefs.value;
  6143. if (!scrollable.value || !nav || !titles || !titles[state.currentIndex]) {
  6144. return;
  6145. }
  6146. const title = titles[state.currentIndex].$el;
  6147. const to = title.offsetLeft - (nav.offsetWidth - title.offsetWidth) / 2;
  6148. scrollLeftTo(nav, to, immediate ? 0 : +props.duration);
  6149. };
  6150. const setLine = () => {
  6151. const shouldAnimate = state.inited;
  6152. nextTick(() => {
  6153. const titles = titleRefs.value;
  6154. if (!titles || !titles[state.currentIndex] || props.type !== "line" || isHidden(root.value)) {
  6155. return;
  6156. }
  6157. const title = titles[state.currentIndex].$el;
  6158. const {
  6159. lineWidth,
  6160. lineHeight
  6161. } = props;
  6162. const left = title.offsetLeft + title.offsetWidth / 2;
  6163. const lineStyle = {
  6164. width: addUnit(lineWidth),
  6165. backgroundColor: props.color,
  6166. transform: `translateX(${left}px) translateX(-50%)`
  6167. };
  6168. if (shouldAnimate) {
  6169. lineStyle.transitionDuration = `${props.duration}s`;
  6170. }
  6171. if (isDef(lineHeight)) {
  6172. const height = addUnit(lineHeight);
  6173. lineStyle.height = height;
  6174. lineStyle.borderRadius = height;
  6175. }
  6176. state.lineStyle = lineStyle;
  6177. });
  6178. };
  6179. const findAvailableTab = (index) => {
  6180. const diff = index < state.currentIndex ? -1 : 1;
  6181. while (index >= 0 && index < children.length) {
  6182. if (!children[index].disabled) {
  6183. return index;
  6184. }
  6185. index += diff;
  6186. }
  6187. };
  6188. const setCurrentIndex = (currentIndex, skipScrollIntoView) => {
  6189. const newIndex = findAvailableTab(currentIndex);
  6190. if (!isDef(newIndex)) {
  6191. return;
  6192. }
  6193. const newTab = children[newIndex];
  6194. const newName = getTabName(newTab, newIndex);
  6195. const shouldEmitChange = state.currentIndex !== null;
  6196. if (state.currentIndex !== newIndex) {
  6197. state.currentIndex = newIndex;
  6198. if (!skipScrollIntoView) {
  6199. scrollIntoView();
  6200. }
  6201. setLine();
  6202. }
  6203. if (newName !== props.active) {
  6204. emit("update:active", newName);
  6205. if (shouldEmitChange) {
  6206. emit("change", newName, newTab.title);
  6207. }
  6208. }
  6209. if (stickyFixed && !props.scrollspy) {
  6210. setRootScrollTop(Math.ceil(getElementTop(root.value) - offsetTopPx.value));
  6211. }
  6212. };
  6213. const setCurrentIndexByName = (name2, skipScrollIntoView) => {
  6214. const matched = children.find((tab, index2) => getTabName(tab, index2) === name2);
  6215. const index = matched ? children.indexOf(matched) : 0;
  6216. setCurrentIndex(index, skipScrollIntoView);
  6217. };
  6218. const scrollToCurrentContent = (immediate = false) => {
  6219. if (props.scrollspy) {
  6220. const target = children[state.currentIndex].$el;
  6221. if (target && scroller.value) {
  6222. const to = getElementTop(target, scroller.value) - scrollOffset.value;
  6223. lockScroll = true;
  6224. scrollTopTo(scroller.value, to, immediate ? 0 : +props.duration, () => {
  6225. lockScroll = false;
  6226. });
  6227. }
  6228. }
  6229. };
  6230. const onClickTab = (item, index, event) => {
  6231. const {
  6232. title,
  6233. disabled
  6234. } = children[index];
  6235. const name2 = getTabName(children[index], index);
  6236. if (disabled) {
  6237. emit("disabled", name2, title);
  6238. } else {
  6239. callInterceptor(props.beforeChange, {
  6240. args: [name2],
  6241. done: () => {
  6242. setCurrentIndex(index);
  6243. scrollToCurrentContent();
  6244. }
  6245. });
  6246. emit("click", name2, title);
  6247. route(item);
  6248. }
  6249. emit("click-tab", {
  6250. name: name2,
  6251. title,
  6252. event,
  6253. disabled
  6254. });
  6255. };
  6256. const onStickyScroll = (params) => {
  6257. stickyFixed = params.isFixed;
  6258. emit("scroll", params);
  6259. };
  6260. const scrollTo = (name2) => {
  6261. nextTick(() => {
  6262. setCurrentIndexByName(name2);
  6263. scrollToCurrentContent(true);
  6264. });
  6265. };
  6266. const getCurrentIndexOnScroll = () => {
  6267. for (let index = 0; index < children.length; index++) {
  6268. const {
  6269. top
  6270. } = useRect(children[index].$el);
  6271. if (top > scrollOffset.value) {
  6272. return index === 0 ? 0 : index - 1;
  6273. }
  6274. }
  6275. return children.length - 1;
  6276. };
  6277. const onScroll = () => {
  6278. if (props.scrollspy && !lockScroll) {
  6279. const index = getCurrentIndexOnScroll();
  6280. setCurrentIndex(index);
  6281. }
  6282. };
  6283. const renderNav = () => children.map((item, index) => createVNode(stdin_default$14, mergeProps({
  6284. "key": item.id,
  6285. "id": `${id}-${index}`,
  6286. "ref": setTitleRefs(index),
  6287. "type": props.type,
  6288. "color": props.color,
  6289. "style": item.titleStyle,
  6290. "class": item.titleClass,
  6291. "shrink": props.shrink,
  6292. "isActive": index === state.currentIndex,
  6293. "controls": item.id,
  6294. "scrollable": scrollable.value,
  6295. "activeColor": props.titleActiveColor,
  6296. "inactiveColor": props.titleInactiveColor,
  6297. "onClick": (event) => onClickTab(item, index, event)
  6298. }, pick(item, ["dot", "badge", "title", "disabled", "showZeroBadge"])), {
  6299. title: item.$slots.title
  6300. }));
  6301. const renderLine = () => {
  6302. if (props.type === "line" && children.length) {
  6303. return createVNode("div", {
  6304. "class": bem$W("line"),
  6305. "style": state.lineStyle
  6306. }, null);
  6307. }
  6308. };
  6309. const renderHeader = () => {
  6310. var _a2, _b2, _c;
  6311. const {
  6312. type,
  6313. border,
  6314. sticky
  6315. } = props;
  6316. const Header = [createVNode("div", {
  6317. "ref": sticky ? void 0 : wrapRef,
  6318. "class": [bem$W("wrap"), {
  6319. [BORDER_TOP_BOTTOM]: type === "line" && border
  6320. }]
  6321. }, [createVNode("div", {
  6322. "ref": navRef,
  6323. "role": "tablist",
  6324. "class": bem$W("nav", [type, {
  6325. shrink: props.shrink,
  6326. complete: scrollable.value
  6327. }]),
  6328. "style": navStyle.value,
  6329. "aria-orientation": "horizontal"
  6330. }, [(_a2 = slots["nav-left"]) == null ? void 0 : _a2.call(slots), renderNav(), renderLine(), (_b2 = slots["nav-right"]) == null ? void 0 : _b2.call(slots)])]), (_c = slots["nav-bottom"]) == null ? void 0 : _c.call(slots)];
  6331. if (sticky) {
  6332. return createVNode("div", {
  6333. "ref": wrapRef
  6334. }, [Header]);
  6335. }
  6336. return Header;
  6337. };
  6338. watch([() => props.color, windowWidth], setLine);
  6339. watch(() => props.active, (value) => {
  6340. if (value !== currentName.value) {
  6341. setCurrentIndexByName(value);
  6342. }
  6343. });
  6344. watch(() => children.length, () => {
  6345. if (state.inited) {
  6346. setCurrentIndexByName(props.active);
  6347. setLine();
  6348. nextTick(() => {
  6349. scrollIntoView(true);
  6350. });
  6351. }
  6352. });
  6353. const init = () => {
  6354. setCurrentIndexByName(props.active, true);
  6355. nextTick(() => {
  6356. state.inited = true;
  6357. if (wrapRef.value) {
  6358. tabHeight = useRect(wrapRef.value).height;
  6359. }
  6360. scrollIntoView(true);
  6361. });
  6362. };
  6363. const onRendered = (name2, title) => emit("rendered", name2, title);
  6364. const resize = () => {
  6365. setLine();
  6366. nextTick(() => {
  6367. var _a2, _b2;
  6368. return (_b2 = (_a2 = contentRef.value) == null ? void 0 : _a2.swipeRef.value) == null ? void 0 : _b2.resize();
  6369. });
  6370. };
  6371. useExpose({
  6372. resize,
  6373. scrollTo
  6374. });
  6375. onActivated(setLine);
  6376. onPopupReopen(setLine);
  6377. onMountedOrActivated(init);
  6378. useEventListener("scroll", onScroll, {
  6379. target: scroller,
  6380. passive: true
  6381. });
  6382. linkChildren({
  6383. id,
  6384. props,
  6385. setLine,
  6386. onRendered,
  6387. currentName,
  6388. scrollIntoView
  6389. });
  6390. return () => createVNode("div", {
  6391. "ref": root,
  6392. "class": bem$W([props.type])
  6393. }, [props.sticky ? createVNode(Sticky, {
  6394. "container": root.value,
  6395. "offsetTop": offsetTopPx.value,
  6396. "onScroll": onStickyScroll
  6397. }, {
  6398. default: () => [renderHeader()]
  6399. }) : renderHeader(), createVNode(stdin_default$12, {
  6400. "ref": contentRef,
  6401. "count": children.length,
  6402. "inited": state.inited,
  6403. "animated": props.animated,
  6404. "duration": props.duration,
  6405. "swipeable": props.swipeable,
  6406. "lazyRender": props.lazyRender,
  6407. "currentIndex": state.currentIndex,
  6408. "onChange": setCurrentIndex
  6409. }, {
  6410. default: () => {
  6411. var _a2;
  6412. return [(_a2 = slots.default) == null ? void 0 : _a2.call(slots)];
  6413. }
  6414. })]);
  6415. }
  6416. });
  6417. const TAB_STATUS_KEY = Symbol();
  6418. const useTabStatus = () => inject(TAB_STATUS_KEY, null);
  6419. const [name$W, bem$V] = createNamespace("swipe-item");
  6420. var stdin_default$10 = defineComponent({
  6421. name: name$W,
  6422. setup(props, {
  6423. slots
  6424. }) {
  6425. let rendered;
  6426. const state = reactive({
  6427. offset: 0,
  6428. inited: false,
  6429. mounted: false
  6430. });
  6431. const {
  6432. parent,
  6433. index
  6434. } = useParent(SWIPE_KEY);
  6435. if (!parent) {
  6436. if (process.env.NODE_ENV !== "production") {
  6437. console.error("[Vant] <SwipeItem> must be a child component of <Swipe>.");
  6438. }
  6439. return;
  6440. }
  6441. const style = computed(() => {
  6442. const style2 = {};
  6443. const {
  6444. vertical
  6445. } = parent.props;
  6446. if (parent.size.value) {
  6447. style2[vertical ? "height" : "width"] = `${parent.size.value}px`;
  6448. }
  6449. if (state.offset) {
  6450. style2.transform = `translate${vertical ? "Y" : "X"}(${state.offset}px)`;
  6451. }
  6452. return style2;
  6453. });
  6454. const shouldRender = computed(() => {
  6455. const {
  6456. loop,
  6457. lazyRender
  6458. } = parent.props;
  6459. if (!lazyRender || rendered) {
  6460. return true;
  6461. }
  6462. if (!state.mounted) {
  6463. return false;
  6464. }
  6465. const active = parent.activeIndicator.value;
  6466. const maxActive = parent.count.value - 1;
  6467. const prevActive = active === 0 && loop ? maxActive : active - 1;
  6468. const nextActive = active === maxActive && loop ? 0 : active + 1;
  6469. rendered = index.value === active || index.value === prevActive || index.value === nextActive;
  6470. return rendered;
  6471. });
  6472. const setOffset = (offset) => {
  6473. state.offset = offset;
  6474. };
  6475. onMounted(() => {
  6476. nextTick(() => {
  6477. state.mounted = true;
  6478. });
  6479. });
  6480. useExpose({
  6481. setOffset
  6482. });
  6483. return () => {
  6484. var _a;
  6485. return createVNode("div", {
  6486. "class": bem$V(),
  6487. "style": style.value
  6488. }, [shouldRender.value ? (_a = slots.default) == null ? void 0 : _a.call(slots) : null]);
  6489. };
  6490. }
  6491. });
  6492. const SwipeItem = withInstall(stdin_default$10);
  6493. const [name$V, bem$U] = createNamespace("tab");
  6494. const tabProps = extend({}, routeProps, {
  6495. dot: Boolean,
  6496. name: numericProp,
  6497. badge: numericProp,
  6498. title: String,
  6499. disabled: Boolean,
  6500. titleClass: unknownProp,
  6501. titleStyle: [String, Object],
  6502. showZeroBadge: truthProp
  6503. });
  6504. var stdin_default$$ = defineComponent({
  6505. name: name$V,
  6506. props: tabProps,
  6507. setup(props, {
  6508. slots
  6509. }) {
  6510. const id = useId();
  6511. const inited = ref(false);
  6512. const {
  6513. parent,
  6514. index
  6515. } = useParent(TABS_KEY);
  6516. if (!parent) {
  6517. if (process.env.NODE_ENV !== "production") {
  6518. console.error("[Vant] <Tab> must be a child component of <Tabs>.");
  6519. }
  6520. return;
  6521. }
  6522. const getName = () => {
  6523. var _a;
  6524. return (_a = props.name) != null ? _a : index.value;
  6525. };
  6526. const init = () => {
  6527. inited.value = true;
  6528. if (parent.props.lazyRender) {
  6529. nextTick(() => {
  6530. parent.onRendered(getName(), props.title);
  6531. });
  6532. }
  6533. };
  6534. const active = computed(() => {
  6535. const isActive = getName() === parent.currentName.value;
  6536. if (isActive && !inited.value) {
  6537. init();
  6538. }
  6539. return isActive;
  6540. });
  6541. const hasInactiveClass = ref(!active.value);
  6542. watch(active, (val) => {
  6543. if (val) {
  6544. hasInactiveClass.value = false;
  6545. } else {
  6546. doubleRaf(() => {
  6547. hasInactiveClass.value = true;
  6548. });
  6549. }
  6550. });
  6551. watch(() => props.title, () => {
  6552. parent.setLine();
  6553. parent.scrollIntoView();
  6554. });
  6555. provide(TAB_STATUS_KEY, active);
  6556. return () => {
  6557. var _a;
  6558. const label = `${parent.id}-${index.value}`;
  6559. const {
  6560. animated,
  6561. swipeable,
  6562. scrollspy,
  6563. lazyRender
  6564. } = parent.props;
  6565. if (!slots.default && !animated) {
  6566. return;
  6567. }
  6568. const show = scrollspy || active.value;
  6569. if (animated || swipeable) {
  6570. return createVNode(SwipeItem, {
  6571. "id": id,
  6572. "role": "tabpanel",
  6573. "class": bem$U("panel-wrapper", {
  6574. inactive: hasInactiveClass.value
  6575. }),
  6576. "tabindex": active.value ? 0 : -1,
  6577. "aria-hidden": !active.value,
  6578. "aria-labelledby": label
  6579. }, {
  6580. default: () => {
  6581. var _a2;
  6582. return [createVNode("div", {
  6583. "class": bem$U("panel")
  6584. }, [(_a2 = slots.default) == null ? void 0 : _a2.call(slots)])];
  6585. }
  6586. });
  6587. }
  6588. const shouldRender = inited.value || scrollspy || !lazyRender;
  6589. const Content = shouldRender ? (_a = slots.default) == null ? void 0 : _a.call(slots) : null;
  6590. useExpose({
  6591. id
  6592. });
  6593. return withDirectives(createVNode("div", {
  6594. "id": id,
  6595. "role": "tabpanel",
  6596. "class": bem$U("panel"),
  6597. "tabindex": show ? 0 : -1,
  6598. "aria-labelledby": label
  6599. }, [Content]), [[vShow, show]]);
  6600. };
  6601. }
  6602. });
  6603. const Tab = withInstall(stdin_default$$);
  6604. const Tabs = withInstall(stdin_default$11);
  6605. const [name$U, bem$T, t$e] = createNamespace("cascader");
  6606. const cascaderProps = {
  6607. title: String,
  6608. options: makeArrayProp(),
  6609. closeable: truthProp,
  6610. swipeable: truthProp,
  6611. closeIcon: makeStringProp("cross"),
  6612. showHeader: truthProp,
  6613. modelValue: numericProp,
  6614. fieldNames: Object,
  6615. placeholder: String,
  6616. activeColor: String
  6617. };
  6618. var stdin_default$_ = defineComponent({
  6619. name: name$U,
  6620. props: cascaderProps,
  6621. emits: ["close", "change", "finish", "click-tab", "update:modelValue"],
  6622. setup(props, {
  6623. slots,
  6624. emit
  6625. }) {
  6626. const tabs = ref([]);
  6627. const activeTab = ref(0);
  6628. const {
  6629. text: textKey,
  6630. value: valueKey,
  6631. children: childrenKey
  6632. } = extend({
  6633. text: "text",
  6634. value: "value",
  6635. children: "children"
  6636. }, props.fieldNames);
  6637. const getSelectedOptionsByValue = (options, value) => {
  6638. for (const option of options) {
  6639. if (option[valueKey] === value) {
  6640. return [option];
  6641. }
  6642. if (option[childrenKey]) {
  6643. const selectedOptions = getSelectedOptionsByValue(option[childrenKey], value);
  6644. if (selectedOptions) {
  6645. return [option, ...selectedOptions];
  6646. }
  6647. }
  6648. }
  6649. };
  6650. const updateTabs = () => {
  6651. const {
  6652. options,
  6653. modelValue
  6654. } = props;
  6655. if (modelValue !== void 0) {
  6656. const selectedOptions = getSelectedOptionsByValue(options, modelValue);
  6657. if (selectedOptions) {
  6658. let optionsCursor = options;
  6659. tabs.value = selectedOptions.map((option) => {
  6660. const tab = {
  6661. options: optionsCursor,
  6662. selected: option
  6663. };
  6664. const next = optionsCursor.find((item) => item[valueKey] === option[valueKey]);
  6665. if (next) {
  6666. optionsCursor = next[childrenKey];
  6667. }
  6668. return tab;
  6669. });
  6670. if (optionsCursor) {
  6671. tabs.value.push({
  6672. options: optionsCursor,
  6673. selected: null
  6674. });
  6675. }
  6676. nextTick(() => {
  6677. activeTab.value = tabs.value.length - 1;
  6678. });
  6679. return;
  6680. }
  6681. }
  6682. tabs.value = [{
  6683. options,
  6684. selected: null
  6685. }];
  6686. };
  6687. const onSelect = (option, tabIndex) => {
  6688. if (option.disabled) {
  6689. return;
  6690. }
  6691. tabs.value[tabIndex].selected = option;
  6692. if (tabs.value.length > tabIndex + 1) {
  6693. tabs.value = tabs.value.slice(0, tabIndex + 1);
  6694. }
  6695. if (option[childrenKey]) {
  6696. const nextTab = {
  6697. options: option[childrenKey],
  6698. selected: null
  6699. };
  6700. if (tabs.value[tabIndex + 1]) {
  6701. tabs.value[tabIndex + 1] = nextTab;
  6702. } else {
  6703. tabs.value.push(nextTab);
  6704. }
  6705. nextTick(() => {
  6706. activeTab.value++;
  6707. });
  6708. }
  6709. const selectedOptions = tabs.value.map((tab) => tab.selected).filter(Boolean);
  6710. emit("update:modelValue", option[valueKey]);
  6711. const params = {
  6712. value: option[valueKey],
  6713. tabIndex,
  6714. selectedOptions
  6715. };
  6716. emit("change", params);
  6717. if (!option[childrenKey]) {
  6718. emit("finish", params);
  6719. }
  6720. };
  6721. const onClose = () => emit("close");
  6722. const onClickTab = ({
  6723. name: name2,
  6724. title
  6725. }) => emit("click-tab", name2, title);
  6726. const renderHeader = () => props.showHeader ? createVNode("div", {
  6727. "class": bem$T("header")
  6728. }, [createVNode("h2", {
  6729. "class": bem$T("title")
  6730. }, [slots.title ? slots.title() : props.title]), props.closeable ? createVNode(Icon, {
  6731. "name": props.closeIcon,
  6732. "class": [bem$T("close-icon"), HAPTICS_FEEDBACK],
  6733. "onClick": onClose
  6734. }, null) : null]) : null;
  6735. const renderOption = (option, selectedOption, tabIndex) => {
  6736. const {
  6737. disabled
  6738. } = option;
  6739. const selected = !!(selectedOption && option[valueKey] === selectedOption[valueKey]);
  6740. const color = option.color || (selected ? props.activeColor : void 0);
  6741. const Text2 = slots.option ? slots.option({
  6742. option,
  6743. selected
  6744. }) : createVNode("span", null, [option[textKey]]);
  6745. return createVNode("li", {
  6746. "role": "menuitemradio",
  6747. "class": [bem$T("option", {
  6748. selected,
  6749. disabled
  6750. }), option.className],
  6751. "style": {
  6752. color
  6753. },
  6754. "tabindex": disabled ? void 0 : selected ? 0 : -1,
  6755. "aria-checked": selected,
  6756. "aria-disabled": disabled || void 0,
  6757. "onClick": () => onSelect(option, tabIndex)
  6758. }, [Text2, selected ? createVNode(Icon, {
  6759. "name": "success",
  6760. "class": bem$T("selected-icon")
  6761. }, null) : null]);
  6762. };
  6763. const renderOptions = (options, selectedOption, tabIndex) => createVNode("ul", {
  6764. "role": "menu",
  6765. "class": bem$T("options")
  6766. }, [options.map((option) => renderOption(option, selectedOption, tabIndex))]);
  6767. const renderTab = (tab, tabIndex) => {
  6768. const {
  6769. options,
  6770. selected
  6771. } = tab;
  6772. const placeholder = props.placeholder || t$e("select");
  6773. const title = selected ? selected[textKey] : placeholder;
  6774. return createVNode(Tab, {
  6775. "title": title,
  6776. "titleClass": bem$T("tab", {
  6777. unselected: !selected
  6778. })
  6779. }, {
  6780. default: () => {
  6781. var _a, _b;
  6782. return [(_a = slots["options-top"]) == null ? void 0 : _a.call(slots, {
  6783. tabIndex
  6784. }), renderOptions(options, selected, tabIndex), (_b = slots["options-bottom"]) == null ? void 0 : _b.call(slots, {
  6785. tabIndex
  6786. })];
  6787. }
  6788. });
  6789. };
  6790. const renderTabs = () => createVNode(Tabs, {
  6791. "active": activeTab.value,
  6792. "onUpdate:active": ($event) => activeTab.value = $event,
  6793. "shrink": true,
  6794. "animated": true,
  6795. "class": bem$T("tabs"),
  6796. "color": props.activeColor,
  6797. "swipeable": props.swipeable,
  6798. "onClick-tab": onClickTab
  6799. }, {
  6800. default: () => [tabs.value.map(renderTab)]
  6801. });
  6802. updateTabs();
  6803. watch(() => props.options, updateTabs, {
  6804. deep: true
  6805. });
  6806. watch(() => props.modelValue, (value) => {
  6807. if (value !== void 0) {
  6808. const values = tabs.value.map((tab) => {
  6809. var _a;
  6810. return (_a = tab.selected) == null ? void 0 : _a[valueKey];
  6811. });
  6812. if (values.includes(value)) {
  6813. return;
  6814. }
  6815. }
  6816. updateTabs();
  6817. });
  6818. return () => createVNode("div", {
  6819. "class": bem$T()
  6820. }, [renderHeader(), renderTabs()]);
  6821. }
  6822. });
  6823. const Cascader = withInstall(stdin_default$_);
  6824. const [name$T, bem$S] = createNamespace("cell-group");
  6825. const cellGroupProps = {
  6826. title: String,
  6827. inset: Boolean,
  6828. border: truthProp
  6829. };
  6830. var stdin_default$Z = defineComponent({
  6831. name: name$T,
  6832. inheritAttrs: false,
  6833. props: cellGroupProps,
  6834. setup(props, {
  6835. slots,
  6836. attrs
  6837. }) {
  6838. const renderGroup = () => {
  6839. var _a;
  6840. return createVNode("div", mergeProps({
  6841. "class": [bem$S({
  6842. inset: props.inset
  6843. }), {
  6844. [BORDER_TOP_BOTTOM]: props.border && !props.inset
  6845. }]
  6846. }, attrs), [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  6847. };
  6848. const renderTitle = () => createVNode("div", {
  6849. "class": bem$S("title", {
  6850. inset: props.inset
  6851. })
  6852. }, [slots.title ? slots.title() : props.title]);
  6853. return () => {
  6854. if (props.title || slots.title) {
  6855. return createVNode(Fragment, null, [renderTitle(), renderGroup()]);
  6856. }
  6857. return renderGroup();
  6858. };
  6859. }
  6860. });
  6861. const CellGroup = withInstall(stdin_default$Z);
  6862. const [name$S, bem$R] = createNamespace("checkbox-group");
  6863. const checkboxGroupProps = {
  6864. max: numericProp,
  6865. disabled: Boolean,
  6866. iconSize: numericProp,
  6867. direction: String,
  6868. modelValue: makeArrayProp(),
  6869. checkedColor: String
  6870. };
  6871. const CHECKBOX_GROUP_KEY = Symbol(name$S);
  6872. var stdin_default$Y = defineComponent({
  6873. name: name$S,
  6874. props: checkboxGroupProps,
  6875. emits: ["change", "update:modelValue"],
  6876. setup(props, {
  6877. emit,
  6878. slots
  6879. }) {
  6880. const {
  6881. children,
  6882. linkChildren
  6883. } = useChildren(CHECKBOX_GROUP_KEY);
  6884. const updateValue = (value) => emit("update:modelValue", value);
  6885. const toggleAll = (options = {}) => {
  6886. if (typeof options === "boolean") {
  6887. options = {
  6888. checked: options
  6889. };
  6890. }
  6891. const {
  6892. checked,
  6893. skipDisabled
  6894. } = options;
  6895. const checkedChildren = children.filter((item) => {
  6896. if (!item.props.bindGroup) {
  6897. return false;
  6898. }
  6899. if (item.props.disabled && skipDisabled) {
  6900. return item.checked.value;
  6901. }
  6902. return checked != null ? checked : !item.checked.value;
  6903. });
  6904. const names = checkedChildren.map((item) => item.name);
  6905. updateValue(names);
  6906. };
  6907. watch(() => props.modelValue, (value) => emit("change", value));
  6908. useExpose({
  6909. toggleAll
  6910. });
  6911. useCustomFieldValue(() => props.modelValue);
  6912. linkChildren({
  6913. props,
  6914. updateValue
  6915. });
  6916. return () => {
  6917. var _a;
  6918. return createVNode("div", {
  6919. "class": bem$R([props.direction])
  6920. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  6921. };
  6922. }
  6923. });
  6924. const [name$R, bem$Q] = createNamespace("checkbox");
  6925. const checkboxProps = extend({}, checkerProps, {
  6926. bindGroup: truthProp
  6927. });
  6928. var stdin_default$X = defineComponent({
  6929. name: name$R,
  6930. props: checkboxProps,
  6931. emits: ["change", "update:modelValue"],
  6932. setup(props, {
  6933. emit,
  6934. slots
  6935. }) {
  6936. const {
  6937. parent
  6938. } = useParent(CHECKBOX_GROUP_KEY);
  6939. const setParentValue = (checked2) => {
  6940. const {
  6941. name: name2
  6942. } = props;
  6943. const {
  6944. max,
  6945. modelValue
  6946. } = parent.props;
  6947. const value = modelValue.slice();
  6948. if (checked2) {
  6949. const overlimit = max && value.length >= max;
  6950. if (!overlimit && !value.includes(name2)) {
  6951. value.push(name2);
  6952. if (props.bindGroup) {
  6953. parent.updateValue(value);
  6954. }
  6955. }
  6956. } else {
  6957. const index = value.indexOf(name2);
  6958. if (index !== -1) {
  6959. value.splice(index, 1);
  6960. if (props.bindGroup) {
  6961. parent.updateValue(value);
  6962. }
  6963. }
  6964. }
  6965. };
  6966. const checked = computed(() => {
  6967. if (parent && props.bindGroup) {
  6968. return parent.props.modelValue.indexOf(props.name) !== -1;
  6969. }
  6970. return !!props.modelValue;
  6971. });
  6972. const toggle = (newValue = !checked.value) => {
  6973. if (parent && props.bindGroup) {
  6974. setParentValue(newValue);
  6975. } else {
  6976. emit("update:modelValue", newValue);
  6977. }
  6978. };
  6979. watch(() => props.modelValue, (value) => emit("change", value));
  6980. useExpose({
  6981. toggle,
  6982. props,
  6983. checked
  6984. });
  6985. useCustomFieldValue(() => props.modelValue);
  6986. return () => createVNode(stdin_default$1f, mergeProps({
  6987. "bem": bem$Q,
  6988. "role": "checkbox",
  6989. "parent": parent,
  6990. "checked": checked.value,
  6991. "onToggle": toggle
  6992. }, props), pick(slots, ["default", "icon"]));
  6993. }
  6994. });
  6995. const Checkbox = withInstall(stdin_default$X);
  6996. const CheckboxGroup = withInstall(stdin_default$Y);
  6997. const [name$Q, bem$P] = createNamespace("circle");
  6998. let uid = 0;
  6999. const format = (rate) => Math.min(Math.max(+rate, 0), 100);
  7000. function getPath(clockwise, viewBoxSize) {
  7001. const sweepFlag = clockwise ? 1 : 0;
  7002. return `M ${viewBoxSize / 2} ${viewBoxSize / 2} m 0, -500 a 500, 500 0 1, ${sweepFlag} 0, 1000 a 500, 500 0 1, ${sweepFlag} 0, -1000`;
  7003. }
  7004. const circleProps = {
  7005. text: String,
  7006. size: numericProp,
  7007. fill: makeStringProp("none"),
  7008. rate: makeNumericProp(100),
  7009. speed: makeNumericProp(0),
  7010. color: [String, Object],
  7011. clockwise: truthProp,
  7012. layerColor: String,
  7013. currentRate: makeNumberProp(0),
  7014. strokeWidth: makeNumericProp(40),
  7015. strokeLinecap: String,
  7016. startPosition: makeStringProp("top")
  7017. };
  7018. var stdin_default$W = defineComponent({
  7019. name: name$Q,
  7020. props: circleProps,
  7021. emits: ["update:currentRate"],
  7022. setup(props, {
  7023. emit,
  7024. slots
  7025. }) {
  7026. const id = `van-circle-${uid++}`;
  7027. const viewBoxSize = computed(() => +props.strokeWidth + 1e3);
  7028. const path = computed(() => getPath(props.clockwise, viewBoxSize.value));
  7029. const svgStyle = computed(() => {
  7030. const ROTATE_ANGLE_MAP = {
  7031. top: 0,
  7032. right: 90,
  7033. bottom: 180,
  7034. left: 270
  7035. };
  7036. const angleValue = ROTATE_ANGLE_MAP[props.startPosition];
  7037. if (angleValue) {
  7038. return {
  7039. transform: `rotate(${angleValue}deg)`
  7040. };
  7041. }
  7042. });
  7043. watch(() => props.rate, (rate) => {
  7044. let rafId;
  7045. const startTime = Date.now();
  7046. const startRate = props.currentRate;
  7047. const endRate = format(rate);
  7048. const duration = Math.abs((startRate - endRate) * 1e3 / +props.speed);
  7049. const animate = () => {
  7050. const now = Date.now();
  7051. const progress = Math.min((now - startTime) / duration, 1);
  7052. const rate2 = progress * (endRate - startRate) + startRate;
  7053. emit("update:currentRate", format(parseFloat(rate2.toFixed(1))));
  7054. if (endRate > startRate ? rate2 < endRate : rate2 > endRate) {
  7055. rafId = raf(animate);
  7056. }
  7057. };
  7058. if (props.speed) {
  7059. if (rafId) {
  7060. cancelRaf(rafId);
  7061. }
  7062. rafId = raf(animate);
  7063. } else {
  7064. emit("update:currentRate", endRate);
  7065. }
  7066. }, {
  7067. immediate: true
  7068. });
  7069. const renderHover = () => {
  7070. const PERIMETER = 3140;
  7071. const {
  7072. strokeWidth,
  7073. currentRate,
  7074. strokeLinecap
  7075. } = props;
  7076. const offset = PERIMETER * currentRate / 100;
  7077. const color = isObject(props.color) ? `url(#${id})` : props.color;
  7078. const style = {
  7079. stroke: color,
  7080. strokeWidth: `${+strokeWidth + 1}px`,
  7081. strokeLinecap,
  7082. strokeDasharray: `${offset}px ${PERIMETER}px`
  7083. };
  7084. return createVNode("path", {
  7085. "d": path.value,
  7086. "style": style,
  7087. "class": bem$P("hover"),
  7088. "stroke": color
  7089. }, null);
  7090. };
  7091. const renderLayer = () => {
  7092. const style = {
  7093. fill: props.fill,
  7094. stroke: props.layerColor,
  7095. strokeWidth: `${props.strokeWidth}px`
  7096. };
  7097. return createVNode("path", {
  7098. "class": bem$P("layer"),
  7099. "style": style,
  7100. "d": path.value
  7101. }, null);
  7102. };
  7103. const renderGradient = () => {
  7104. const {
  7105. color
  7106. } = props;
  7107. if (!isObject(color)) {
  7108. return;
  7109. }
  7110. const Stops = Object.keys(color).sort((a, b) => parseFloat(a) - parseFloat(b)).map((key, index) => createVNode("stop", {
  7111. "key": index,
  7112. "offset": key,
  7113. "stop-color": color[key]
  7114. }, null));
  7115. return createVNode("defs", null, [createVNode("linearGradient", {
  7116. "id": id,
  7117. "x1": "100%",
  7118. "y1": "0%",
  7119. "x2": "0%",
  7120. "y2": "0%"
  7121. }, [Stops])]);
  7122. };
  7123. const renderText = () => {
  7124. if (slots.default) {
  7125. return slots.default();
  7126. }
  7127. if (props.text) {
  7128. return createVNode("div", {
  7129. "class": bem$P("text")
  7130. }, [props.text]);
  7131. }
  7132. };
  7133. return () => createVNode("div", {
  7134. "class": bem$P(),
  7135. "style": getSizeStyle(props.size)
  7136. }, [createVNode("svg", {
  7137. "viewBox": `0 0 ${viewBoxSize.value} ${viewBoxSize.value}`,
  7138. "style": svgStyle.value
  7139. }, [renderGradient(), renderLayer(), renderHover()]), renderText()]);
  7140. }
  7141. });
  7142. const Circle = withInstall(stdin_default$W);
  7143. const [name$P, bem$O] = createNamespace("row");
  7144. const ROW_KEY = Symbol(name$P);
  7145. const rowProps = {
  7146. tag: makeStringProp("div"),
  7147. wrap: truthProp,
  7148. align: String,
  7149. gutter: makeNumericProp(0),
  7150. justify: String
  7151. };
  7152. var stdin_default$V = defineComponent({
  7153. name: name$P,
  7154. props: rowProps,
  7155. setup(props, {
  7156. slots
  7157. }) {
  7158. const {
  7159. children,
  7160. linkChildren
  7161. } = useChildren(ROW_KEY);
  7162. const groups = computed(() => {
  7163. const groups2 = [[]];
  7164. let totalSpan = 0;
  7165. children.forEach((child, index) => {
  7166. totalSpan += Number(child.span);
  7167. if (totalSpan > 24) {
  7168. groups2.push([index]);
  7169. totalSpan -= 24;
  7170. } else {
  7171. groups2[groups2.length - 1].push(index);
  7172. }
  7173. });
  7174. return groups2;
  7175. });
  7176. const spaces = computed(() => {
  7177. const gutter = Number(props.gutter);
  7178. const spaces2 = [];
  7179. if (!gutter) {
  7180. return spaces2;
  7181. }
  7182. groups.value.forEach((group) => {
  7183. const averagePadding = gutter * (group.length - 1) / group.length;
  7184. group.forEach((item, index) => {
  7185. if (index === 0) {
  7186. spaces2.push({
  7187. right: averagePadding
  7188. });
  7189. } else {
  7190. const left = gutter - spaces2[item - 1].right;
  7191. const right = averagePadding - left;
  7192. spaces2.push({
  7193. left,
  7194. right
  7195. });
  7196. }
  7197. });
  7198. });
  7199. return spaces2;
  7200. });
  7201. linkChildren({
  7202. spaces
  7203. });
  7204. return () => {
  7205. const {
  7206. tag,
  7207. wrap,
  7208. align,
  7209. justify
  7210. } = props;
  7211. return createVNode(tag, {
  7212. "class": bem$O({
  7213. [`align-${align}`]: align,
  7214. [`justify-${justify}`]: justify,
  7215. nowrap: !wrap
  7216. })
  7217. }, {
  7218. default: () => {
  7219. var _a;
  7220. return [(_a = slots.default) == null ? void 0 : _a.call(slots)];
  7221. }
  7222. });
  7223. };
  7224. }
  7225. });
  7226. const [name$O, bem$N] = createNamespace("col");
  7227. const colProps = {
  7228. tag: makeStringProp("div"),
  7229. span: makeNumericProp(0),
  7230. offset: numericProp
  7231. };
  7232. var stdin_default$U = defineComponent({
  7233. name: name$O,
  7234. props: colProps,
  7235. setup(props, {
  7236. slots
  7237. }) {
  7238. const {
  7239. parent,
  7240. index
  7241. } = useParent(ROW_KEY);
  7242. const style = computed(() => {
  7243. if (!parent) {
  7244. return;
  7245. }
  7246. const {
  7247. spaces
  7248. } = parent;
  7249. if (spaces && spaces.value && spaces.value[index.value]) {
  7250. const {
  7251. left,
  7252. right
  7253. } = spaces.value[index.value];
  7254. return {
  7255. paddingLeft: left ? `${left}px` : null,
  7256. paddingRight: right ? `${right}px` : null
  7257. };
  7258. }
  7259. });
  7260. return () => {
  7261. const {
  7262. tag,
  7263. span,
  7264. offset
  7265. } = props;
  7266. return createVNode(tag, {
  7267. "style": style.value,
  7268. "class": bem$N({
  7269. [span]: span,
  7270. [`offset-${offset}`]: offset
  7271. })
  7272. }, {
  7273. default: () => {
  7274. var _a;
  7275. return [(_a = slots.default) == null ? void 0 : _a.call(slots)];
  7276. }
  7277. });
  7278. };
  7279. }
  7280. });
  7281. const Col = withInstall(stdin_default$U);
  7282. const [name$N, bem$M] = createNamespace("collapse");
  7283. const COLLAPSE_KEY = Symbol(name$N);
  7284. const collapseProps = {
  7285. border: truthProp,
  7286. accordion: Boolean,
  7287. modelValue: {
  7288. type: [String, Number, Array],
  7289. default: ""
  7290. }
  7291. };
  7292. function validateModelValue(modelValue, accordion) {
  7293. if (accordion && Array.isArray(modelValue)) {
  7294. console.error('[Vant] Collapse: "v-model" should not be Array in accordion mode');
  7295. return false;
  7296. }
  7297. if (!accordion && !Array.isArray(modelValue)) {
  7298. console.error('[Vant] Collapse: "v-model" should be Array in non-accordion mode');
  7299. return false;
  7300. }
  7301. return true;
  7302. }
  7303. var stdin_default$T = defineComponent({
  7304. name: name$N,
  7305. props: collapseProps,
  7306. emits: ["change", "update:modelValue"],
  7307. setup(props, {
  7308. emit,
  7309. slots
  7310. }) {
  7311. const {
  7312. linkChildren,
  7313. children
  7314. } = useChildren(COLLAPSE_KEY);
  7315. const updateName = (name2) => {
  7316. emit("change", name2);
  7317. emit("update:modelValue", name2);
  7318. };
  7319. const toggle = (name2, expanded) => {
  7320. const {
  7321. accordion,
  7322. modelValue
  7323. } = props;
  7324. if (accordion) {
  7325. updateName(name2 === modelValue ? "" : name2);
  7326. } else if (expanded) {
  7327. updateName(modelValue.concat(name2));
  7328. } else {
  7329. updateName(modelValue.filter((activeName) => activeName !== name2));
  7330. }
  7331. };
  7332. const toggleAll = (options = {}) => {
  7333. if (props.accordion) {
  7334. return;
  7335. }
  7336. if (typeof options === "boolean") {
  7337. options = {
  7338. expanded: options
  7339. };
  7340. }
  7341. const {
  7342. expanded,
  7343. skipDisabled
  7344. } = options;
  7345. const expandedChildren = children.filter((item) => {
  7346. if (item.disabled && skipDisabled) {
  7347. return item.expanded.value;
  7348. }
  7349. return expanded != null ? expanded : !item.expanded.value;
  7350. });
  7351. const names = expandedChildren.map((item) => item.itemName.value);
  7352. updateName(names);
  7353. };
  7354. const isExpanded = (name2) => {
  7355. const {
  7356. accordion,
  7357. modelValue
  7358. } = props;
  7359. if (process.env.NODE_ENV !== "production" && !validateModelValue(modelValue, accordion)) {
  7360. return false;
  7361. }
  7362. return accordion ? modelValue === name2 : modelValue.includes(name2);
  7363. };
  7364. useExpose({
  7365. toggleAll
  7366. });
  7367. linkChildren({
  7368. toggle,
  7369. isExpanded
  7370. });
  7371. return () => {
  7372. var _a;
  7373. return createVNode("div", {
  7374. "class": [bem$M(), {
  7375. [BORDER_TOP_BOTTOM]: props.border
  7376. }]
  7377. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  7378. };
  7379. }
  7380. });
  7381. const Collapse = withInstall(stdin_default$T);
  7382. const [name$M, bem$L] = createNamespace("collapse-item");
  7383. const CELL_SLOTS = ["icon", "title", "value", "label", "right-icon"];
  7384. const collapseItemProps = extend({}, cellSharedProps, {
  7385. name: numericProp,
  7386. isLink: truthProp,
  7387. disabled: Boolean,
  7388. readonly: Boolean,
  7389. lazyRender: truthProp
  7390. });
  7391. var stdin_default$S = defineComponent({
  7392. name: name$M,
  7393. props: collapseItemProps,
  7394. setup(props, {
  7395. slots
  7396. }) {
  7397. const wrapperRef = ref();
  7398. const contentRef = ref();
  7399. const {
  7400. parent,
  7401. index
  7402. } = useParent(COLLAPSE_KEY);
  7403. if (!parent) {
  7404. if (process.env.NODE_ENV !== "production") {
  7405. console.error("[Vant] <CollapseItem> must be a child component of <Collapse>.");
  7406. }
  7407. return;
  7408. }
  7409. const name2 = computed(() => {
  7410. var _a;
  7411. return (_a = props.name) != null ? _a : index.value;
  7412. });
  7413. const expanded = computed(() => parent.isExpanded(name2.value));
  7414. const show = ref(expanded.value);
  7415. const lazyRender = useLazyRender(() => show.value || !props.lazyRender);
  7416. const onTransitionEnd = () => {
  7417. if (!expanded.value) {
  7418. show.value = false;
  7419. } else if (wrapperRef.value) {
  7420. wrapperRef.value.style.height = "";
  7421. }
  7422. };
  7423. watch(expanded, (value, oldValue) => {
  7424. if (oldValue === null) {
  7425. return;
  7426. }
  7427. if (value) {
  7428. show.value = true;
  7429. }
  7430. const tick = value ? nextTick : raf;
  7431. tick(() => {
  7432. if (!contentRef.value || !wrapperRef.value) {
  7433. return;
  7434. }
  7435. const {
  7436. offsetHeight
  7437. } = contentRef.value;
  7438. if (offsetHeight) {
  7439. const contentHeight = `${offsetHeight}px`;
  7440. wrapperRef.value.style.height = value ? "0" : contentHeight;
  7441. doubleRaf(() => {
  7442. if (wrapperRef.value) {
  7443. wrapperRef.value.style.height = value ? contentHeight : "0";
  7444. }
  7445. });
  7446. } else {
  7447. onTransitionEnd();
  7448. }
  7449. });
  7450. });
  7451. const toggle = (newValue = !expanded.value) => {
  7452. parent.toggle(name2.value, newValue);
  7453. };
  7454. const onClickTitle = () => {
  7455. if (!props.disabled && !props.readonly) {
  7456. toggle();
  7457. }
  7458. };
  7459. const renderTitle = () => {
  7460. const {
  7461. border,
  7462. disabled,
  7463. readonly
  7464. } = props;
  7465. const attrs = pick(props, Object.keys(cellSharedProps));
  7466. if (readonly) {
  7467. attrs.isLink = false;
  7468. }
  7469. if (disabled || readonly) {
  7470. attrs.clickable = false;
  7471. }
  7472. return createVNode(Cell, mergeProps({
  7473. "role": "button",
  7474. "class": bem$L("title", {
  7475. disabled,
  7476. expanded: expanded.value,
  7477. borderless: !border
  7478. }),
  7479. "aria-expanded": String(expanded.value),
  7480. "onClick": onClickTitle
  7481. }, attrs), pick(slots, CELL_SLOTS));
  7482. };
  7483. const renderContent = lazyRender(() => {
  7484. var _a;
  7485. return withDirectives(createVNode("div", {
  7486. "ref": wrapperRef,
  7487. "class": bem$L("wrapper"),
  7488. "onTransitionend": onTransitionEnd
  7489. }, [createVNode("div", {
  7490. "ref": contentRef,
  7491. "class": bem$L("content")
  7492. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)])]), [[vShow, show.value]]);
  7493. });
  7494. useExpose({
  7495. toggle,
  7496. expanded,
  7497. itemName: name2
  7498. });
  7499. return () => createVNode("div", {
  7500. "class": [bem$L({
  7501. border: index.value && props.border
  7502. })]
  7503. }, [renderTitle(), renderContent()]);
  7504. }
  7505. });
  7506. const CollapseItem = withInstall(stdin_default$S);
  7507. const ConfigProvider = withInstall(stdin_default$1A);
  7508. const [name$L, bem$K, t$d] = createNamespace("contact-card");
  7509. const contactCardProps = {
  7510. tel: String,
  7511. name: String,
  7512. type: makeStringProp("add"),
  7513. addText: String,
  7514. editable: truthProp
  7515. };
  7516. var stdin_default$R = defineComponent({
  7517. name: name$L,
  7518. props: contactCardProps,
  7519. emits: ["click"],
  7520. setup(props, {
  7521. emit
  7522. }) {
  7523. const onClick = (event) => {
  7524. if (props.editable) {
  7525. emit("click", event);
  7526. }
  7527. };
  7528. const renderContent = () => {
  7529. if (props.type === "add") {
  7530. return props.addText || t$d("addContact");
  7531. }
  7532. return [createVNode("div", null, [`${t$d("name")}\uFF1A${props.name}`]), createVNode("div", null, [`${t$d("tel")}\uFF1A${props.tel}`])];
  7533. };
  7534. return () => createVNode(Cell, {
  7535. "center": true,
  7536. "icon": props.type === "edit" ? "contact" : "add-square",
  7537. "class": bem$K([props.type]),
  7538. "border": false,
  7539. "isLink": props.editable,
  7540. "valueClass": bem$K("value"),
  7541. "onClick": onClick
  7542. }, {
  7543. value: renderContent
  7544. });
  7545. }
  7546. });
  7547. const ContactCard = withInstall(stdin_default$R);
  7548. const [name$K, bem$J, t$c] = createNamespace("contact-edit");
  7549. const DEFAULT_CONTACT = {
  7550. tel: "",
  7551. name: ""
  7552. };
  7553. const contactEditProps = {
  7554. isEdit: Boolean,
  7555. isSaving: Boolean,
  7556. isDeleting: Boolean,
  7557. showSetDefault: Boolean,
  7558. setDefaultLabel: String,
  7559. contactInfo: {
  7560. type: Object,
  7561. default: () => extend({}, DEFAULT_CONTACT)
  7562. },
  7563. telValidator: {
  7564. type: Function,
  7565. default: isMobile
  7566. }
  7567. };
  7568. var stdin_default$Q = defineComponent({
  7569. name: name$K,
  7570. props: contactEditProps,
  7571. emits: ["save", "delete", "change-default"],
  7572. setup(props, {
  7573. emit
  7574. }) {
  7575. const contact = reactive(extend({}, DEFAULT_CONTACT, props.contactInfo));
  7576. const onSave = () => {
  7577. if (!props.isSaving) {
  7578. emit("save", contact);
  7579. }
  7580. };
  7581. const onDelete = () => emit("delete", contact);
  7582. const renderButtons = () => createVNode("div", {
  7583. "class": bem$J("buttons")
  7584. }, [createVNode(Button, {
  7585. "block": true,
  7586. "round": true,
  7587. "type": "danger",
  7588. "text": t$c("save"),
  7589. "class": bem$J("button"),
  7590. "loading": props.isSaving,
  7591. "nativeType": "submit"
  7592. }, null), props.isEdit && createVNode(Button, {
  7593. "block": true,
  7594. "round": true,
  7595. "text": t$c("delete"),
  7596. "class": bem$J("button"),
  7597. "loading": props.isDeleting,
  7598. "onClick": onDelete
  7599. }, null)]);
  7600. const renderSwitch = () => createVNode(Switch, {
  7601. "modelValue": contact.isDefault,
  7602. "onUpdate:modelValue": ($event) => contact.isDefault = $event,
  7603. "size": 24,
  7604. "onChange": (checked) => emit("change-default", checked)
  7605. }, null);
  7606. const renderSetDefault = () => {
  7607. if (props.showSetDefault) {
  7608. return createVNode(Cell, {
  7609. "title": props.setDefaultLabel,
  7610. "class": bem$J("switch-cell"),
  7611. "border": false
  7612. }, {
  7613. "right-icon": renderSwitch
  7614. });
  7615. }
  7616. };
  7617. watch(() => props.contactInfo, (value) => extend(contact, DEFAULT_CONTACT, value));
  7618. return () => createVNode(Form, {
  7619. "class": bem$J(),
  7620. "onSubmit": onSave
  7621. }, {
  7622. default: () => [createVNode("div", {
  7623. "class": bem$J("fields")
  7624. }, [createVNode(Field, {
  7625. "modelValue": contact.name,
  7626. "onUpdate:modelValue": ($event) => contact.name = $event,
  7627. "clearable": true,
  7628. "label": t$c("name"),
  7629. "rules": [{
  7630. required: true,
  7631. message: t$c("nameEmpty")
  7632. }],
  7633. "maxlength": "30",
  7634. "placeholder": t$c("name")
  7635. }, null), createVNode(Field, {
  7636. "modelValue": contact.tel,
  7637. "onUpdate:modelValue": ($event) => contact.tel = $event,
  7638. "clearable": true,
  7639. "type": "tel",
  7640. "label": t$c("tel"),
  7641. "rules": [{
  7642. validator: props.telValidator,
  7643. message: t$c("telInvalid")
  7644. }],
  7645. "placeholder": t$c("tel")
  7646. }, null)]), renderSetDefault(), renderButtons()]
  7647. });
  7648. }
  7649. });
  7650. const ContactEdit = withInstall(stdin_default$Q);
  7651. const [name$J, bem$I, t$b] = createNamespace("contact-list");
  7652. const contactListProps = {
  7653. list: Array,
  7654. addText: String,
  7655. modelValue: unknownProp,
  7656. defaultTagText: String
  7657. };
  7658. var stdin_default$P = defineComponent({
  7659. name: name$J,
  7660. props: contactListProps,
  7661. emits: ["add", "edit", "select", "update:modelValue"],
  7662. setup(props, {
  7663. emit
  7664. }) {
  7665. const renderItem = (item, index) => {
  7666. const onClick = () => {
  7667. emit("update:modelValue", item.id);
  7668. emit("select", item, index);
  7669. };
  7670. const renderRightIcon = () => createVNode(Radio, {
  7671. "class": bem$I("radio"),
  7672. "name": item.id,
  7673. "iconSize": 16
  7674. }, null);
  7675. const renderEditIcon = () => createVNode(Icon, {
  7676. "name": "edit",
  7677. "class": bem$I("edit"),
  7678. "onClick": (event) => {
  7679. event.stopPropagation();
  7680. emit("edit", item, index);
  7681. }
  7682. }, null);
  7683. const renderContent = () => {
  7684. const nodes = [`${item.name}\uFF0C${item.tel}`];
  7685. if (item.isDefault && props.defaultTagText) {
  7686. nodes.push(createVNode(Tag, {
  7687. "type": "danger",
  7688. "round": true,
  7689. "class": bem$I("item-tag")
  7690. }, {
  7691. default: () => [props.defaultTagText]
  7692. }));
  7693. }
  7694. return nodes;
  7695. };
  7696. return createVNode(Cell, {
  7697. "key": item.id,
  7698. "isLink": true,
  7699. "center": true,
  7700. "class": bem$I("item"),
  7701. "valueClass": bem$I("item-value"),
  7702. "onClick": onClick
  7703. }, {
  7704. icon: renderEditIcon,
  7705. value: renderContent,
  7706. "right-icon": renderRightIcon
  7707. });
  7708. };
  7709. return () => createVNode("div", {
  7710. "class": bem$I()
  7711. }, [createVNode(RadioGroup, {
  7712. "modelValue": props.modelValue,
  7713. "class": bem$I("group")
  7714. }, {
  7715. default: () => [props.list && props.list.map(renderItem)]
  7716. }), createVNode("div", {
  7717. "class": [bem$I("bottom"), "van-safe-area-bottom"]
  7718. }, [createVNode(Button, {
  7719. "round": true,
  7720. "block": true,
  7721. "type": "danger",
  7722. "class": bem$I("add"),
  7723. "text": props.addText || t$b("addContact"),
  7724. "onClick": () => emit("add")
  7725. }, null)])]);
  7726. }
  7727. });
  7728. const ContactList = withInstall(stdin_default$P);
  7729. function parseFormat(format2, currentTime) {
  7730. const { days } = currentTime;
  7731. let { hours, minutes, seconds, milliseconds } = currentTime;
  7732. if (format2.includes("DD")) {
  7733. format2 = format2.replace("DD", padZero(days));
  7734. } else {
  7735. hours += days * 24;
  7736. }
  7737. if (format2.includes("HH")) {
  7738. format2 = format2.replace("HH", padZero(hours));
  7739. } else {
  7740. minutes += hours * 60;
  7741. }
  7742. if (format2.includes("mm")) {
  7743. format2 = format2.replace("mm", padZero(minutes));
  7744. } else {
  7745. seconds += minutes * 60;
  7746. }
  7747. if (format2.includes("ss")) {
  7748. format2 = format2.replace("ss", padZero(seconds));
  7749. } else {
  7750. milliseconds += seconds * 1e3;
  7751. }
  7752. if (format2.includes("S")) {
  7753. const ms = padZero(milliseconds, 3);
  7754. if (format2.includes("SSS")) {
  7755. format2 = format2.replace("SSS", ms);
  7756. } else if (format2.includes("SS")) {
  7757. format2 = format2.replace("SS", ms.slice(0, 2));
  7758. } else {
  7759. format2 = format2.replace("S", ms.charAt(0));
  7760. }
  7761. }
  7762. return format2;
  7763. }
  7764. const [name$I, bem$H] = createNamespace("count-down");
  7765. const countDownProps = {
  7766. time: makeNumericProp(0),
  7767. format: makeStringProp("HH:mm:ss"),
  7768. autoStart: truthProp,
  7769. millisecond: Boolean
  7770. };
  7771. var stdin_default$O = defineComponent({
  7772. name: name$I,
  7773. props: countDownProps,
  7774. emits: ["change", "finish"],
  7775. setup(props, {
  7776. emit,
  7777. slots
  7778. }) {
  7779. const {
  7780. start,
  7781. pause,
  7782. reset,
  7783. current: current2
  7784. } = useCountDown({
  7785. time: +props.time,
  7786. millisecond: props.millisecond,
  7787. onChange: (current22) => emit("change", current22),
  7788. onFinish: () => emit("finish")
  7789. });
  7790. const timeText = computed(() => parseFormat(props.format, current2.value));
  7791. const resetTime = () => {
  7792. reset(+props.time);
  7793. if (props.autoStart) {
  7794. start();
  7795. }
  7796. };
  7797. watch(() => props.time, resetTime, {
  7798. immediate: true
  7799. });
  7800. useExpose({
  7801. start,
  7802. pause,
  7803. reset: resetTime
  7804. });
  7805. return () => createVNode("div", {
  7806. "role": "timer",
  7807. "class": bem$H()
  7808. }, [slots.default ? slots.default(current2.value) : timeText.value]);
  7809. }
  7810. });
  7811. const CountDown = withInstall(stdin_default$O);
  7812. function getDate(timeStamp) {
  7813. const date = new Date(timeStamp * 1e3);
  7814. return `${date.getFullYear()}.${padZero(date.getMonth() + 1)}.${padZero(
  7815. date.getDate()
  7816. )}`;
  7817. }
  7818. const formatDiscount = (discount) => (discount / 10).toFixed(discount % 10 === 0 ? 0 : 1);
  7819. const formatAmount = (amount) => (amount / 100).toFixed(amount % 100 === 0 ? 0 : amount % 10 === 0 ? 1 : 2);
  7820. const [name$H, bem$G, t$a] = createNamespace("coupon");
  7821. var stdin_default$N = defineComponent({
  7822. name: name$H,
  7823. props: {
  7824. chosen: Boolean,
  7825. coupon: makeRequiredProp(Object),
  7826. disabled: Boolean,
  7827. currency: makeStringProp("\xA5")
  7828. },
  7829. setup(props) {
  7830. const validPeriod = computed(() => {
  7831. const {
  7832. startAt,
  7833. endAt
  7834. } = props.coupon;
  7835. return `${getDate(startAt)} - ${getDate(endAt)}`;
  7836. });
  7837. const faceAmount = computed(() => {
  7838. const {
  7839. coupon,
  7840. currency
  7841. } = props;
  7842. if (coupon.valueDesc) {
  7843. return [coupon.valueDesc, createVNode("span", null, [coupon.unitDesc || ""])];
  7844. }
  7845. if (coupon.denominations) {
  7846. const denominations = formatAmount(coupon.denominations);
  7847. return [createVNode("span", null, [currency]), ` ${denominations}`];
  7848. }
  7849. if (coupon.discount) {
  7850. return t$a("discount", formatDiscount(coupon.discount));
  7851. }
  7852. return "";
  7853. });
  7854. const conditionMessage = computed(() => {
  7855. const condition = formatAmount(props.coupon.originCondition || 0);
  7856. return condition === "0" ? t$a("unlimited") : t$a("condition", condition);
  7857. });
  7858. return () => {
  7859. const {
  7860. chosen,
  7861. coupon,
  7862. disabled
  7863. } = props;
  7864. const description = disabled && coupon.reason || coupon.description;
  7865. return createVNode("div", {
  7866. "class": bem$G({
  7867. disabled
  7868. })
  7869. }, [createVNode("div", {
  7870. "class": bem$G("content")
  7871. }, [createVNode("div", {
  7872. "class": bem$G("head")
  7873. }, [createVNode("h2", {
  7874. "class": bem$G("amount")
  7875. }, [faceAmount.value]), createVNode("p", {
  7876. "class": bem$G("condition")
  7877. }, [coupon.condition || conditionMessage.value])]), createVNode("div", {
  7878. "class": bem$G("body")
  7879. }, [createVNode("p", {
  7880. "class": bem$G("name")
  7881. }, [coupon.name]), createVNode("p", {
  7882. "class": bem$G("valid")
  7883. }, [validPeriod.value]), !disabled && createVNode(Checkbox, {
  7884. "class": bem$G("corner"),
  7885. "modelValue": chosen
  7886. }, null)])]), description && createVNode("p", {
  7887. "class": bem$G("description")
  7888. }, [description])]);
  7889. };
  7890. }
  7891. });
  7892. const Coupon = withInstall(stdin_default$N);
  7893. const [name$G, bem$F, t$9] = createNamespace("coupon-cell");
  7894. const couponCellProps = {
  7895. title: String,
  7896. border: truthProp,
  7897. editable: truthProp,
  7898. coupons: makeArrayProp(),
  7899. currency: makeStringProp("\xA5"),
  7900. chosenCoupon: makeNumericProp(-1)
  7901. };
  7902. function formatValue({
  7903. coupons,
  7904. chosenCoupon,
  7905. currency
  7906. }) {
  7907. const coupon = coupons[+chosenCoupon];
  7908. if (coupon) {
  7909. let value = 0;
  7910. if (isDef(coupon.value)) {
  7911. ({
  7912. value
  7913. } = coupon);
  7914. } else if (isDef(coupon.denominations)) {
  7915. value = coupon.denominations;
  7916. }
  7917. return `-${currency} ${(value / 100).toFixed(2)}`;
  7918. }
  7919. return coupons.length === 0 ? t$9("noCoupon") : t$9("count", coupons.length);
  7920. }
  7921. var stdin_default$M = defineComponent({
  7922. name: name$G,
  7923. props: couponCellProps,
  7924. setup(props) {
  7925. return () => {
  7926. const selected = props.coupons[+props.chosenCoupon];
  7927. return createVNode(Cell, {
  7928. "class": bem$F(),
  7929. "value": formatValue(props),
  7930. "title": props.title || t$9("title"),
  7931. "border": props.border,
  7932. "isLink": props.editable,
  7933. "valueClass": bem$F("value", {
  7934. selected
  7935. })
  7936. }, null);
  7937. };
  7938. }
  7939. });
  7940. const CouponCell = withInstall(stdin_default$M);
  7941. const [name$F, bem$E] = createNamespace("empty");
  7942. const emptyProps = {
  7943. image: makeStringProp("default"),
  7944. imageSize: [Number, String, Array],
  7945. description: String
  7946. };
  7947. var stdin_default$L = defineComponent({
  7948. name: name$F,
  7949. props: emptyProps,
  7950. setup(props, {
  7951. slots
  7952. }) {
  7953. const renderDescription = () => {
  7954. const description = slots.description ? slots.description() : props.description;
  7955. if (description) {
  7956. return createVNode("p", {
  7957. "class": bem$E("description")
  7958. }, [description]);
  7959. }
  7960. };
  7961. const renderBottom = () => {
  7962. if (slots.default) {
  7963. return createVNode("div", {
  7964. "class": bem$E("bottom")
  7965. }, [slots.default()]);
  7966. }
  7967. };
  7968. const baseId = useId();
  7969. const getId = (num) => `${baseId}-${num}`;
  7970. const getUrlById = (num) => `url(#${getId(num)})`;
  7971. const renderStop = (color, offset, opacity) => createVNode("stop", {
  7972. "stop-color": color,
  7973. "offset": `${offset}%`,
  7974. "stop-opacity": opacity
  7975. }, null);
  7976. const renderStops = (fromColor, toColor) => [renderStop(fromColor, 0), renderStop(toColor, 100)];
  7977. const renderShadow = (id) => [createVNode("defs", null, [createVNode("radialGradient", {
  7978. "id": getId(id),
  7979. "cx": "50%",
  7980. "cy": "54%",
  7981. "fx": "50%",
  7982. "fy": "54%",
  7983. "r": "297%",
  7984. "gradientTransform": "matrix(-.16 0 0 -.33 .58 .72)"
  7985. }, [renderStop("#EBEDF0", 0), renderStop("#F2F3F5", 100, 0.3)])]), createVNode("ellipse", {
  7986. "fill": getUrlById(id),
  7987. "opacity": ".8",
  7988. "cx": "80",
  7989. "cy": "140",
  7990. "rx": "46",
  7991. "ry": "8"
  7992. }, null)];
  7993. const renderBuilding = () => [createVNode("defs", null, [createVNode("linearGradient", {
  7994. "id": getId("a"),
  7995. "x1": "64%",
  7996. "y1": "100%",
  7997. "x2": "64%"
  7998. }, [renderStop("#FFF", 0, 0.5), renderStop("#F2F3F5", 100)])]), createVNode("g", {
  7999. "opacity": ".8"
  8000. }, [createVNode("path", {
  8001. "d": "M36 131V53H16v20H2v58h34z",
  8002. "fill": getUrlById("a")
  8003. }, null), createVNode("path", {
  8004. "d": "M123 15h22v14h9v77h-31V15z",
  8005. "fill": getUrlById("a")
  8006. }, null)])];
  8007. const renderCloud = () => [createVNode("defs", null, [createVNode("linearGradient", {
  8008. "id": getId("b"),
  8009. "x1": "64%",
  8010. "y1": "97%",
  8011. "x2": "64%",
  8012. "y2": "0%"
  8013. }, [renderStop("#F2F3F5", 0, 0.3), renderStop("#F2F3F5", 100)])]), createVNode("g", {
  8014. "opacity": ".8"
  8015. }, [createVNode("path", {
  8016. "d": "M87 6c3 0 7 3 8 6a8 8 0 1 1-1 16H80a7 7 0 0 1-8-6c0-4 3-7 6-7 0-5 4-9 9-9Z",
  8017. "fill": getUrlById("b")
  8018. }, null), createVNode("path", {
  8019. "d": "M19 23c2 0 3 1 4 3 2 0 4 2 4 4a4 4 0 0 1-4 3v1h-7v-1l-1 1c-2 0-3-2-3-4 0-1 1-3 3-3 0-2 2-4 4-4Z",
  8020. "fill": getUrlById("b")
  8021. }, null)])];
  8022. const renderNetwork = () => createVNode("svg", {
  8023. "viewBox": "0 0 160 160"
  8024. }, [createVNode("defs", null, [createVNode("linearGradient", {
  8025. "id": getId(1),
  8026. "x1": "64%",
  8027. "y1": "100%",
  8028. "x2": "64%"
  8029. }, [renderStop("#FFF", 0, 0.5), renderStop("#F2F3F5", 100)]), createVNode("linearGradient", {
  8030. "id": getId(2),
  8031. "x1": "50%",
  8032. "x2": "50%",
  8033. "y2": "84%"
  8034. }, [renderStop("#EBEDF0", 0), renderStop("#DCDEE0", 100, 0)]), createVNode("linearGradient", {
  8035. "id": getId(3),
  8036. "x1": "100%",
  8037. "x2": "100%",
  8038. "y2": "100%"
  8039. }, [renderStops("#EAEDF0", "#DCDEE0")]), createVNode("radialGradient", {
  8040. "id": getId(4),
  8041. "cx": "50%",
  8042. "cy": "0%",
  8043. "fx": "50%",
  8044. "fy": "0%",
  8045. "r": "100%",
  8046. "gradientTransform": "matrix(0 1 -.54 0 .5 -.5)"
  8047. }, [renderStop("#EBEDF0", 0), renderStop("#FFF", 100, 0)])]), createVNode("g", {
  8048. "fill": "none"
  8049. }, [renderBuilding(), createVNode("path", {
  8050. "fill": getUrlById(4),
  8051. "d": "M0 139h160v21H0z"
  8052. }, null), createVNode("path", {
  8053. "d": "M80 54a7 7 0 0 1 3 13v27l-2 2h-2a2 2 0 0 1-2-2V67a7 7 0 0 1 3-13z",
  8054. "fill": getUrlById(2)
  8055. }, null), createVNode("g", {
  8056. "opacity": ".6",
  8057. "stroke-linecap": "round",
  8058. "stroke-width": "7"
  8059. }, [createVNode("path", {
  8060. "d": "M64 47a19 19 0 0 0-5 13c0 5 2 10 5 13",
  8061. "stroke": getUrlById(3)
  8062. }, null), createVNode("path", {
  8063. "d": "M53 36a34 34 0 0 0 0 48",
  8064. "stroke": getUrlById(3)
  8065. }, null), createVNode("path", {
  8066. "d": "M95 73a19 19 0 0 0 6-13c0-5-2-9-6-13",
  8067. "stroke": getUrlById(3)
  8068. }, null), createVNode("path", {
  8069. "d": "M106 84a34 34 0 0 0 0-48",
  8070. "stroke": getUrlById(3)
  8071. }, null)]), createVNode("g", {
  8072. "transform": "translate(31 105)"
  8073. }, [createVNode("rect", {
  8074. "fill": "#EBEDF0",
  8075. "width": "98",
  8076. "height": "34",
  8077. "rx": "2"
  8078. }, null), createVNode("rect", {
  8079. "fill": "#FFF",
  8080. "x": "9",
  8081. "y": "8",
  8082. "width": "80",
  8083. "height": "18",
  8084. "rx": "1.1"
  8085. }, null), createVNode("rect", {
  8086. "fill": "#EBEDF0",
  8087. "x": "15",
  8088. "y": "12",
  8089. "width": "18",
  8090. "height": "6",
  8091. "rx": "1.1"
  8092. }, null)])])]);
  8093. const renderMaterial = () => createVNode("svg", {
  8094. "viewBox": "0 0 160 160"
  8095. }, [createVNode("defs", null, [createVNode("linearGradient", {
  8096. "x1": "50%",
  8097. "x2": "50%",
  8098. "y2": "100%",
  8099. "id": getId(5)
  8100. }, [renderStops("#F2F3F5", "#DCDEE0")]), createVNode("linearGradient", {
  8101. "x1": "95%",
  8102. "y1": "48%",
  8103. "x2": "5.5%",
  8104. "y2": "51%",
  8105. "id": getId(6)
  8106. }, [renderStops("#EAEDF1", "#DCDEE0")]), createVNode("linearGradient", {
  8107. "y1": "45%",
  8108. "x2": "100%",
  8109. "y2": "54%",
  8110. "id": getId(7)
  8111. }, [renderStops("#EAEDF1", "#DCDEE0")])]), renderBuilding(), renderCloud(), createVNode("g", {
  8112. "transform": "translate(36 50)",
  8113. "fill": "none"
  8114. }, [createVNode("g", {
  8115. "transform": "translate(8)"
  8116. }, [createVNode("rect", {
  8117. "fill": "#EBEDF0",
  8118. "opacity": ".6",
  8119. "x": "38",
  8120. "y": "13",
  8121. "width": "36",
  8122. "height": "53",
  8123. "rx": "2"
  8124. }, null), createVNode("rect", {
  8125. "fill": getUrlById(5),
  8126. "width": "64",
  8127. "height": "66",
  8128. "rx": "2"
  8129. }, null), createVNode("rect", {
  8130. "fill": "#FFF",
  8131. "x": "6",
  8132. "y": "6",
  8133. "width": "52",
  8134. "height": "55",
  8135. "rx": "1"
  8136. }, null), createVNode("g", {
  8137. "transform": "translate(15 17)",
  8138. "fill": getUrlById(6)
  8139. }, [createVNode("rect", {
  8140. "width": "34",
  8141. "height": "6",
  8142. "rx": "1"
  8143. }, null), createVNode("path", {
  8144. "d": "M0 14h34v6H0z"
  8145. }, null), createVNode("rect", {
  8146. "y": "28",
  8147. "width": "34",
  8148. "height": "6",
  8149. "rx": "1"
  8150. }, null)])]), createVNode("rect", {
  8151. "fill": getUrlById(7),
  8152. "y": "61",
  8153. "width": "88",
  8154. "height": "28",
  8155. "rx": "1"
  8156. }, null), createVNode("rect", {
  8157. "fill": "#F7F8FA",
  8158. "x": "29",
  8159. "y": "72",
  8160. "width": "30",
  8161. "height": "6",
  8162. "rx": "1"
  8163. }, null)])]);
  8164. const renderError = () => createVNode("svg", {
  8165. "viewBox": "0 0 160 160"
  8166. }, [createVNode("defs", null, [createVNode("linearGradient", {
  8167. "x1": "50%",
  8168. "x2": "50%",
  8169. "y2": "100%",
  8170. "id": getId(8)
  8171. }, [renderStops("#EAEDF1", "#DCDEE0")])]), renderBuilding(), renderCloud(), renderShadow("c"), createVNode("path", {
  8172. "d": "m59 60 21 21 21-21h3l9 9v3L92 93l21 21v3l-9 9h-3l-21-21-21 21h-3l-9-9v-3l21-21-21-21v-3l9-9h3Z",
  8173. "fill": getUrlById(8)
  8174. }, null)]);
  8175. const renderSearch = () => createVNode("svg", {
  8176. "viewBox": "0 0 160 160"
  8177. }, [createVNode("defs", null, [createVNode("linearGradient", {
  8178. "x1": "50%",
  8179. "y1": "100%",
  8180. "x2": "50%",
  8181. "id": getId(9)
  8182. }, [renderStops("#EEE", "#D8D8D8")]), createVNode("linearGradient", {
  8183. "x1": "100%",
  8184. "y1": "50%",
  8185. "y2": "50%",
  8186. "id": getId(10)
  8187. }, [renderStops("#F2F3F5", "#DCDEE0")]), createVNode("linearGradient", {
  8188. "x1": "50%",
  8189. "x2": "50%",
  8190. "y2": "100%",
  8191. "id": getId(11)
  8192. }, [renderStops("#F2F3F5", "#DCDEE0")]), createVNode("linearGradient", {
  8193. "x1": "50%",
  8194. "x2": "50%",
  8195. "y2": "100%",
  8196. "id": getId(12)
  8197. }, [renderStops("#FFF", "#F7F8FA")])]), renderBuilding(), renderCloud(), renderShadow("d"), createVNode("g", {
  8198. "transform": "rotate(-45 113 -4)",
  8199. "fill": "none"
  8200. }, [createVNode("rect", {
  8201. "fill": getUrlById(9),
  8202. "x": "24",
  8203. "y": "52.8",
  8204. "width": "5.8",
  8205. "height": "19",
  8206. "rx": "1"
  8207. }, null), createVNode("rect", {
  8208. "fill": getUrlById(10),
  8209. "x": "22.1",
  8210. "y": "67.3",
  8211. "width": "9.9",
  8212. "height": "28",
  8213. "rx": "1"
  8214. }, null), createVNode("circle", {
  8215. "stroke": getUrlById(11),
  8216. "stroke-width": "8",
  8217. "cx": "27",
  8218. "cy": "27",
  8219. "r": "27"
  8220. }, null), createVNode("circle", {
  8221. "fill": getUrlById(12),
  8222. "cx": "27",
  8223. "cy": "27",
  8224. "r": "16"
  8225. }, null), createVNode("path", {
  8226. "d": "M37 7c-8 0-15 5-16 12",
  8227. "stroke": getUrlById(11),
  8228. "stroke-width": "3",
  8229. "opacity": ".5",
  8230. "stroke-linecap": "round",
  8231. "transform": "rotate(45 29 13)"
  8232. }, null)])]);
  8233. const renderImage = () => {
  8234. var _a;
  8235. if (slots.image) {
  8236. return slots.image();
  8237. }
  8238. const PRESET_IMAGES = {
  8239. error: renderError,
  8240. search: renderSearch,
  8241. network: renderNetwork,
  8242. default: renderMaterial
  8243. };
  8244. return ((_a = PRESET_IMAGES[props.image]) == null ? void 0 : _a.call(PRESET_IMAGES)) || createVNode("img", {
  8245. "src": props.image
  8246. }, null);
  8247. };
  8248. return () => createVNode("div", {
  8249. "class": bem$E()
  8250. }, [createVNode("div", {
  8251. "class": bem$E("image"),
  8252. "style": getSizeStyle(props.imageSize)
  8253. }, [renderImage()]), renderDescription(), renderBottom()]);
  8254. }
  8255. });
  8256. const Empty = withInstall(stdin_default$L);
  8257. const [name$E, bem$D, t$8] = createNamespace("coupon-list");
  8258. const couponListProps = {
  8259. code: makeStringProp(""),
  8260. coupons: makeArrayProp(),
  8261. currency: makeStringProp("\xA5"),
  8262. showCount: truthProp,
  8263. emptyImage: String,
  8264. chosenCoupon: makeNumberProp(-1),
  8265. enabledTitle: String,
  8266. disabledTitle: String,
  8267. disabledCoupons: makeArrayProp(),
  8268. showExchangeBar: truthProp,
  8269. showCloseButton: truthProp,
  8270. closeButtonText: String,
  8271. inputPlaceholder: String,
  8272. exchangeMinLength: makeNumberProp(1),
  8273. exchangeButtonText: String,
  8274. displayedCouponIndex: makeNumberProp(-1),
  8275. exchangeButtonLoading: Boolean,
  8276. exchangeButtonDisabled: Boolean
  8277. };
  8278. var stdin_default$K = defineComponent({
  8279. name: name$E,
  8280. props: couponListProps,
  8281. emits: ["change", "exchange", "update:code"],
  8282. setup(props, {
  8283. emit,
  8284. slots
  8285. }) {
  8286. const [couponRefs, setCouponRefs] = useRefs();
  8287. const root = ref();
  8288. const barRef = ref();
  8289. const activeTab = ref(0);
  8290. const listHeight = ref(0);
  8291. const currentCode = ref(props.code);
  8292. const buttonDisabled = computed(() => !props.exchangeButtonLoading && (props.exchangeButtonDisabled || !currentCode.value || currentCode.value.length < props.exchangeMinLength));
  8293. const updateListHeight = () => {
  8294. const TABS_HEIGHT = 44;
  8295. const rootHeight = useRect(root).height;
  8296. const headerHeight = useRect(barRef).height + TABS_HEIGHT;
  8297. listHeight.value = (rootHeight > headerHeight ? rootHeight : windowHeight.value) - headerHeight;
  8298. };
  8299. const onExchange = () => {
  8300. emit("exchange", currentCode.value);
  8301. if (!props.code) {
  8302. currentCode.value = "";
  8303. }
  8304. };
  8305. const scrollToCoupon = (index) => {
  8306. nextTick(() => {
  8307. var _a;
  8308. return (_a = couponRefs.value[index]) == null ? void 0 : _a.scrollIntoView();
  8309. });
  8310. };
  8311. const renderEmpty = () => createVNode(Empty, {
  8312. "image": props.emptyImage
  8313. }, {
  8314. default: () => [createVNode("p", {
  8315. "class": bem$D("empty-tip")
  8316. }, [t$8("noCoupon")])]
  8317. });
  8318. const renderExchangeBar = () => {
  8319. if (props.showExchangeBar) {
  8320. return createVNode("div", {
  8321. "ref": barRef,
  8322. "class": bem$D("exchange-bar")
  8323. }, [createVNode(Field, {
  8324. "modelValue": currentCode.value,
  8325. "onUpdate:modelValue": ($event) => currentCode.value = $event,
  8326. "clearable": true,
  8327. "border": false,
  8328. "class": bem$D("field"),
  8329. "placeholder": props.inputPlaceholder || t$8("placeholder"),
  8330. "maxlength": "20"
  8331. }, null), createVNode(Button, {
  8332. "plain": true,
  8333. "type": "danger",
  8334. "class": bem$D("exchange"),
  8335. "text": props.exchangeButtonText || t$8("exchange"),
  8336. "loading": props.exchangeButtonLoading,
  8337. "disabled": buttonDisabled.value,
  8338. "onClick": onExchange
  8339. }, null)]);
  8340. }
  8341. };
  8342. const renderCouponTab = () => {
  8343. const {
  8344. coupons
  8345. } = props;
  8346. const count = props.showCount ? ` (${coupons.length})` : "";
  8347. const title = (props.enabledTitle || t$8("enable")) + count;
  8348. return createVNode(Tab, {
  8349. "title": title
  8350. }, {
  8351. default: () => {
  8352. var _a;
  8353. return [createVNode("div", {
  8354. "class": bem$D("list", {
  8355. "with-bottom": props.showCloseButton
  8356. }),
  8357. "style": {
  8358. height: `${listHeight.value}px`
  8359. }
  8360. }, [coupons.map((coupon, index) => createVNode(Coupon, {
  8361. "key": coupon.id,
  8362. "ref": setCouponRefs(index),
  8363. "coupon": coupon,
  8364. "chosen": index === props.chosenCoupon,
  8365. "currency": props.currency,
  8366. "onClick": () => emit("change", index)
  8367. }, null)), !coupons.length && renderEmpty(), (_a = slots["list-footer"]) == null ? void 0 : _a.call(slots)])];
  8368. }
  8369. });
  8370. };
  8371. const renderDisabledTab = () => {
  8372. const {
  8373. disabledCoupons
  8374. } = props;
  8375. const count = props.showCount ? ` (${disabledCoupons.length})` : "";
  8376. const title = (props.disabledTitle || t$8("disabled")) + count;
  8377. return createVNode(Tab, {
  8378. "title": title
  8379. }, {
  8380. default: () => {
  8381. var _a;
  8382. return [createVNode("div", {
  8383. "class": bem$D("list", {
  8384. "with-bottom": props.showCloseButton
  8385. }),
  8386. "style": {
  8387. height: `${listHeight.value}px`
  8388. }
  8389. }, [disabledCoupons.map((coupon) => createVNode(Coupon, {
  8390. "disabled": true,
  8391. "key": coupon.id,
  8392. "coupon": coupon,
  8393. "currency": props.currency
  8394. }, null)), !disabledCoupons.length && renderEmpty(), (_a = slots["disabled-list-footer"]) == null ? void 0 : _a.call(slots)])];
  8395. }
  8396. });
  8397. };
  8398. watch(() => props.code, (value) => {
  8399. currentCode.value = value;
  8400. });
  8401. watch(windowHeight, updateListHeight);
  8402. watch(currentCode, (value) => emit("update:code", value));
  8403. watch(() => props.displayedCouponIndex, scrollToCoupon);
  8404. onMounted(() => {
  8405. updateListHeight();
  8406. scrollToCoupon(props.displayedCouponIndex);
  8407. });
  8408. return () => createVNode("div", {
  8409. "ref": root,
  8410. "class": bem$D()
  8411. }, [renderExchangeBar(), createVNode(Tabs, {
  8412. "active": activeTab.value,
  8413. "onUpdate:active": ($event) => activeTab.value = $event,
  8414. "class": bem$D("tab")
  8415. }, {
  8416. default: () => [renderCouponTab(), renderDisabledTab()]
  8417. }), createVNode("div", {
  8418. "class": bem$D("bottom")
  8419. }, [withDirectives(createVNode(Button, {
  8420. "round": true,
  8421. "block": true,
  8422. "type": "danger",
  8423. "class": bem$D("close"),
  8424. "text": props.closeButtonText || t$8("close"),
  8425. "onClick": () => emit("change", -1)
  8426. }, null), [[vShow, props.showCloseButton]])])]);
  8427. }
  8428. });
  8429. const CouponList = withInstall(stdin_default$K);
  8430. const [name$D] = createNamespace("time-picker");
  8431. var stdin_default$J = defineComponent({
  8432. name: name$D,
  8433. props: extend({}, sharedProps, {
  8434. minHour: makeNumericProp(0),
  8435. maxHour: makeNumericProp(23),
  8436. minMinute: makeNumericProp(0),
  8437. maxMinute: makeNumericProp(59),
  8438. modelValue: String
  8439. }),
  8440. emits: ["confirm", "cancel", "change", "update:modelValue"],
  8441. setup(props, {
  8442. emit,
  8443. slots
  8444. }) {
  8445. const formatValue2 = (value) => {
  8446. const {
  8447. minHour,
  8448. maxHour,
  8449. maxMinute,
  8450. minMinute
  8451. } = props;
  8452. if (!value) {
  8453. value = `${padZero(minHour)}:${padZero(minMinute)}`;
  8454. }
  8455. let [hour, minute] = value.split(":");
  8456. hour = padZero(clamp(+hour, +minHour, +maxHour));
  8457. minute = padZero(clamp(+minute, +minMinute, +maxMinute));
  8458. return `${hour}:${minute}`;
  8459. };
  8460. const picker = ref();
  8461. const currentDate = ref(formatValue2(props.modelValue));
  8462. const ranges = computed(() => [{
  8463. type: "hour",
  8464. range: [+props.minHour, +props.maxHour]
  8465. }, {
  8466. type: "minute",
  8467. range: [+props.minMinute, +props.maxMinute]
  8468. }]);
  8469. const originColumns = computed(() => ranges.value.map(({
  8470. type,
  8471. range: rangeArr
  8472. }) => {
  8473. let values = times(rangeArr[1] - rangeArr[0] + 1, (index) => padZero(rangeArr[0] + index));
  8474. if (props.filter) {
  8475. values = props.filter(type, values);
  8476. }
  8477. return {
  8478. type,
  8479. values
  8480. };
  8481. }));
  8482. const columns = computed(() => originColumns.value.map((column) => ({
  8483. values: column.values.map((value) => props.formatter(column.type, value))
  8484. })));
  8485. const updateColumnValue = () => {
  8486. const pair = currentDate.value.split(":");
  8487. const values = [props.formatter("hour", pair[0]), props.formatter("minute", pair[1])];
  8488. nextTick(() => {
  8489. var _a;
  8490. (_a = picker.value) == null ? void 0 : _a.setValues(values);
  8491. });
  8492. };
  8493. const updateInnerValue = () => {
  8494. const [hourIndex, minuteIndex] = picker.value.getIndexes();
  8495. const [hourColumn, minuteColumn] = originColumns.value;
  8496. const hour = hourColumn.values[hourIndex] || hourColumn.values[0];
  8497. const minute = minuteColumn.values[minuteIndex] || minuteColumn.values[0];
  8498. currentDate.value = formatValue2(`${hour}:${minute}`);
  8499. updateColumnValue();
  8500. };
  8501. const onConfirm = () => emit("confirm", currentDate.value);
  8502. const onCancel = () => emit("cancel");
  8503. const onChange = () => {
  8504. updateInnerValue();
  8505. nextTick(() => {
  8506. nextTick(() => emit("change", currentDate.value));
  8507. });
  8508. };
  8509. onMounted(() => {
  8510. updateColumnValue();
  8511. nextTick(updateInnerValue);
  8512. });
  8513. watch(columns, updateColumnValue);
  8514. watch(() => [props.filter, props.maxHour, props.minMinute, props.maxMinute], updateInnerValue);
  8515. watch(() => props.minHour, () => {
  8516. nextTick(updateInnerValue);
  8517. });
  8518. watch(currentDate, (value) => emit("update:modelValue", value));
  8519. watch(() => props.modelValue, (value) => {
  8520. value = formatValue2(value);
  8521. if (value !== currentDate.value) {
  8522. currentDate.value = value;
  8523. updateColumnValue();
  8524. }
  8525. });
  8526. useExpose({
  8527. getPicker: () => picker.value && proxyPickerMethods(picker.value, updateInnerValue)
  8528. });
  8529. return () => createVNode(Picker, mergeProps({
  8530. "ref": picker,
  8531. "columns": columns.value,
  8532. "onChange": onChange,
  8533. "onCancel": onCancel,
  8534. "onConfirm": onConfirm
  8535. }, pick(props, pickerInheritKeys)), slots);
  8536. }
  8537. });
  8538. const currentYear = new Date().getFullYear();
  8539. const [name$C] = createNamespace("date-picker");
  8540. var stdin_default$I = defineComponent({
  8541. name: name$C,
  8542. props: extend({}, sharedProps, {
  8543. type: makeStringProp("datetime"),
  8544. modelValue: Date,
  8545. minDate: {
  8546. type: Date,
  8547. default: () => new Date(currentYear - 10, 0, 1),
  8548. validator: isDate
  8549. },
  8550. maxDate: {
  8551. type: Date,
  8552. default: () => new Date(currentYear + 10, 11, 31),
  8553. validator: isDate
  8554. }
  8555. }),
  8556. emits: ["confirm", "cancel", "change", "update:modelValue"],
  8557. setup(props, {
  8558. emit,
  8559. slots
  8560. }) {
  8561. const formatValue2 = (value) => {
  8562. if (isDate(value)) {
  8563. const timestamp = clamp(value.getTime(), props.minDate.getTime(), props.maxDate.getTime());
  8564. return new Date(timestamp);
  8565. }
  8566. return void 0;
  8567. };
  8568. const picker = ref();
  8569. const currentDate = ref(formatValue2(props.modelValue));
  8570. const getBoundary = (type, value) => {
  8571. const boundary = props[`${type}Date`];
  8572. const year = boundary.getFullYear();
  8573. let month = 1;
  8574. let date = 1;
  8575. let hour = 0;
  8576. let minute = 0;
  8577. if (type === "max") {
  8578. month = 12;
  8579. date = getMonthEndDay(value.getFullYear(), value.getMonth() + 1);
  8580. hour = 23;
  8581. minute = 59;
  8582. }
  8583. if (value.getFullYear() === year) {
  8584. month = boundary.getMonth() + 1;
  8585. if (value.getMonth() + 1 === month) {
  8586. date = boundary.getDate();
  8587. if (value.getDate() === date) {
  8588. hour = boundary.getHours();
  8589. if (value.getHours() === hour) {
  8590. minute = boundary.getMinutes();
  8591. }
  8592. }
  8593. }
  8594. }
  8595. return {
  8596. [`${type}Year`]: year,
  8597. [`${type}Month`]: month,
  8598. [`${type}Date`]: date,
  8599. [`${type}Hour`]: hour,
  8600. [`${type}Minute`]: minute
  8601. };
  8602. };
  8603. const ranges = computed(() => {
  8604. const {
  8605. maxYear,
  8606. maxDate,
  8607. maxMonth,
  8608. maxHour,
  8609. maxMinute
  8610. } = getBoundary("max", currentDate.value || props.minDate);
  8611. const {
  8612. minYear,
  8613. minDate,
  8614. minMonth,
  8615. minHour,
  8616. minMinute
  8617. } = getBoundary("min", currentDate.value || props.minDate);
  8618. let result = [{
  8619. type: "year",
  8620. range: [minYear, maxYear]
  8621. }, {
  8622. type: "month",
  8623. range: [minMonth, maxMonth]
  8624. }, {
  8625. type: "day",
  8626. range: [minDate, maxDate]
  8627. }, {
  8628. type: "hour",
  8629. range: [minHour, maxHour]
  8630. }, {
  8631. type: "minute",
  8632. range: [minMinute, maxMinute]
  8633. }];
  8634. switch (props.type) {
  8635. case "date":
  8636. result = result.slice(0, 3);
  8637. break;
  8638. case "year-month":
  8639. result = result.slice(0, 2);
  8640. break;
  8641. case "month-day":
  8642. result = result.slice(1, 3);
  8643. break;
  8644. case "datehour":
  8645. result = result.slice(0, 4);
  8646. break;
  8647. }
  8648. if (props.columnsOrder) {
  8649. const columnsOrder = props.columnsOrder.concat(result.map((column) => column.type));
  8650. result.sort((a, b) => columnsOrder.indexOf(a.type) - columnsOrder.indexOf(b.type));
  8651. }
  8652. return result;
  8653. });
  8654. const originColumns = computed(() => ranges.value.map(({
  8655. type,
  8656. range: rangeArr
  8657. }) => {
  8658. let values = times(rangeArr[1] - rangeArr[0] + 1, (index) => padZero(rangeArr[0] + index));
  8659. if (props.filter) {
  8660. values = props.filter(type, values);
  8661. }
  8662. return {
  8663. type,
  8664. values
  8665. };
  8666. }));
  8667. const columns = computed(() => originColumns.value.map((column) => ({
  8668. values: column.values.map((value) => props.formatter(column.type, value))
  8669. })));
  8670. const updateColumnValue = () => {
  8671. const value = currentDate.value || props.minDate;
  8672. const {
  8673. formatter
  8674. } = props;
  8675. const values = originColumns.value.map((column) => {
  8676. switch (column.type) {
  8677. case "year":
  8678. return formatter("year", `${value.getFullYear()}`);
  8679. case "month":
  8680. return formatter("month", padZero(value.getMonth() + 1));
  8681. case "day":
  8682. return formatter("day", padZero(value.getDate()));
  8683. case "hour":
  8684. return formatter("hour", padZero(value.getHours()));
  8685. case "minute":
  8686. return formatter("minute", padZero(value.getMinutes()));
  8687. default:
  8688. return "";
  8689. }
  8690. });
  8691. nextTick(() => {
  8692. var _a;
  8693. (_a = picker.value) == null ? void 0 : _a.setValues(values);
  8694. });
  8695. };
  8696. const updateInnerValue = () => {
  8697. const {
  8698. type
  8699. } = props;
  8700. const indexes = picker.value.getIndexes();
  8701. const getValue = (type2) => {
  8702. let index = 0;
  8703. originColumns.value.forEach((column, columnIndex) => {
  8704. if (type2 === column.type) {
  8705. index = columnIndex;
  8706. }
  8707. });
  8708. const {
  8709. values
  8710. } = originColumns.value[index];
  8711. return getTrueValue(values[indexes[index]]);
  8712. };
  8713. let year;
  8714. let month;
  8715. let day;
  8716. if (type === "month-day") {
  8717. year = (currentDate.value || props.minDate).getFullYear();
  8718. month = getValue("month");
  8719. day = getValue("day");
  8720. } else {
  8721. year = getValue("year");
  8722. month = getValue("month");
  8723. day = type === "year-month" ? 1 : getValue("day");
  8724. }
  8725. const maxDay = getMonthEndDay(year, month);
  8726. day = day > maxDay ? maxDay : day;
  8727. let hour = 0;
  8728. let minute = 0;
  8729. if (type === "datehour") {
  8730. hour = getValue("hour");
  8731. }
  8732. if (type === "datetime") {
  8733. hour = getValue("hour");
  8734. minute = getValue("minute");
  8735. }
  8736. const value = new Date(year, month - 1, day, hour, minute);
  8737. currentDate.value = formatValue2(value);
  8738. };
  8739. const onConfirm = () => {
  8740. emit("update:modelValue", currentDate.value);
  8741. emit("confirm", currentDate.value);
  8742. };
  8743. const onCancel = () => emit("cancel");
  8744. const onChange = () => {
  8745. updateInnerValue();
  8746. nextTick(() => {
  8747. updateInnerValue();
  8748. nextTick(() => emit("change", currentDate.value));
  8749. });
  8750. };
  8751. onMounted(() => {
  8752. updateColumnValue();
  8753. nextTick(updateInnerValue);
  8754. });
  8755. watch(columns, updateColumnValue);
  8756. watch(currentDate, (value, oldValue) => emit("update:modelValue", oldValue ? value : null));
  8757. watch(() => [props.filter, props.minDate, props.maxDate], () => {
  8758. nextTick(updateInnerValue);
  8759. });
  8760. watch(() => props.modelValue, (value) => {
  8761. var _a;
  8762. value = formatValue2(value);
  8763. if (value && value.valueOf() !== ((_a = currentDate.value) == null ? void 0 : _a.valueOf())) {
  8764. currentDate.value = value;
  8765. }
  8766. });
  8767. useExpose({
  8768. getPicker: () => picker.value && proxyPickerMethods(picker.value, updateInnerValue)
  8769. });
  8770. return () => createVNode(Picker, mergeProps({
  8771. "ref": picker,
  8772. "columns": columns.value,
  8773. "onChange": onChange,
  8774. "onCancel": onCancel,
  8775. "onConfirm": onConfirm
  8776. }, pick(props, pickerInheritKeys)), slots);
  8777. }
  8778. });
  8779. const [name$B, bem$C] = createNamespace("datetime-picker");
  8780. const timePickerPropKeys = Object.keys(stdin_default$J.props);
  8781. const datePickerPropKeys = Object.keys(stdin_default$I.props);
  8782. const datetimePickerProps = extend({}, stdin_default$J.props, stdin_default$I.props, {
  8783. modelValue: [String, Date]
  8784. });
  8785. var stdin_default$H = defineComponent({
  8786. name: name$B,
  8787. props: datetimePickerProps,
  8788. setup(props, {
  8789. attrs,
  8790. slots
  8791. }) {
  8792. const root = ref();
  8793. useExpose({
  8794. getPicker: () => {
  8795. var _a;
  8796. return (_a = root.value) == null ? void 0 : _a.getPicker();
  8797. }
  8798. });
  8799. return () => {
  8800. const isTimePicker = props.type === "time";
  8801. const Component = isTimePicker ? stdin_default$J : stdin_default$I;
  8802. const inheritProps = pick(props, isTimePicker ? timePickerPropKeys : datePickerPropKeys);
  8803. return createVNode(Component, mergeProps({
  8804. "ref": root,
  8805. "class": bem$C()
  8806. }, inheritProps, attrs), slots);
  8807. };
  8808. }
  8809. });
  8810. const DatetimePicker = withInstall(stdin_default$H);
  8811. const [name$A, bem$B, t$7] = createNamespace("dialog");
  8812. const dialogProps = extend({}, popupSharedProps, {
  8813. title: String,
  8814. theme: String,
  8815. width: numericProp,
  8816. message: [String, Function],
  8817. callback: Function,
  8818. allowHtml: Boolean,
  8819. className: unknownProp,
  8820. transition: makeStringProp("van-dialog-bounce"),
  8821. messageAlign: String,
  8822. closeOnPopstate: truthProp,
  8823. showCancelButton: Boolean,
  8824. cancelButtonText: String,
  8825. cancelButtonColor: String,
  8826. cancelButtonDisabled: Boolean,
  8827. confirmButtonText: String,
  8828. confirmButtonColor: String,
  8829. confirmButtonDisabled: Boolean,
  8830. showConfirmButton: truthProp,
  8831. closeOnClickOverlay: Boolean
  8832. });
  8833. const popupInheritKeys$1 = [...popupSharedPropKeys, "transition", "closeOnPopstate"];
  8834. var stdin_default$G = defineComponent({
  8835. name: name$A,
  8836. props: dialogProps,
  8837. emits: ["confirm", "cancel", "keydown", "update:show"],
  8838. setup(props, {
  8839. emit,
  8840. slots
  8841. }) {
  8842. const root = ref();
  8843. const loading = reactive({
  8844. confirm: false,
  8845. cancel: false
  8846. });
  8847. const updateShow = (value) => emit("update:show", value);
  8848. const close = (action) => {
  8849. var _a;
  8850. updateShow(false);
  8851. (_a = props.callback) == null ? void 0 : _a.call(props, action);
  8852. };
  8853. const getActionHandler = (action) => () => {
  8854. if (!props.show) {
  8855. return;
  8856. }
  8857. emit(action);
  8858. if (props.beforeClose) {
  8859. loading[action] = true;
  8860. callInterceptor(props.beforeClose, {
  8861. args: [action],
  8862. done() {
  8863. close(action);
  8864. loading[action] = false;
  8865. },
  8866. canceled() {
  8867. loading[action] = false;
  8868. }
  8869. });
  8870. } else {
  8871. close(action);
  8872. }
  8873. };
  8874. const onCancel = getActionHandler("cancel");
  8875. const onConfirm = getActionHandler("confirm");
  8876. const onKeydown = withKeys((event) => {
  8877. var _a, _b;
  8878. if (event.target !== ((_b = (_a = root.value) == null ? void 0 : _a.popupRef) == null ? void 0 : _b.value)) {
  8879. return;
  8880. }
  8881. const onEventType = {
  8882. Enter: props.showConfirmButton ? onConfirm : noop,
  8883. Escape: props.showCancelButton ? onCancel : noop
  8884. };
  8885. onEventType[event.key]();
  8886. emit("keydown", event);
  8887. }, ["enter", "esc"]);
  8888. const renderTitle = () => {
  8889. const title = slots.title ? slots.title() : props.title;
  8890. if (title) {
  8891. return createVNode("div", {
  8892. "class": bem$B("header", {
  8893. isolated: !props.message && !slots.default
  8894. })
  8895. }, [title]);
  8896. }
  8897. };
  8898. const renderMessage = (hasTitle) => {
  8899. const {
  8900. message,
  8901. allowHtml,
  8902. messageAlign
  8903. } = props;
  8904. const classNames = bem$B("message", {
  8905. "has-title": hasTitle,
  8906. [messageAlign]: messageAlign
  8907. });
  8908. const content = isFunction(message) ? message() : message;
  8909. if (allowHtml && typeof content === "string") {
  8910. return createVNode("div", {
  8911. "class": classNames,
  8912. "innerHTML": content
  8913. }, null);
  8914. }
  8915. return createVNode("div", {
  8916. "class": classNames
  8917. }, [content]);
  8918. };
  8919. const renderContent = () => {
  8920. if (slots.default) {
  8921. return createVNode("div", {
  8922. "class": bem$B("content")
  8923. }, [slots.default()]);
  8924. }
  8925. const {
  8926. title,
  8927. message,
  8928. allowHtml
  8929. } = props;
  8930. if (message) {
  8931. const hasTitle = !!(title || slots.title);
  8932. return createVNode("div", {
  8933. "key": allowHtml ? 1 : 0,
  8934. "class": bem$B("content", {
  8935. isolated: !hasTitle
  8936. })
  8937. }, [renderMessage(hasTitle)]);
  8938. }
  8939. };
  8940. const renderButtons = () => createVNode("div", {
  8941. "class": [BORDER_TOP, bem$B("footer")]
  8942. }, [props.showCancelButton && createVNode(Button, {
  8943. "size": "large",
  8944. "text": props.cancelButtonText || t$7("cancel"),
  8945. "class": bem$B("cancel"),
  8946. "style": {
  8947. color: props.cancelButtonColor
  8948. },
  8949. "loading": loading.cancel,
  8950. "disabled": props.cancelButtonDisabled,
  8951. "onClick": onCancel
  8952. }, null), props.showConfirmButton && createVNode(Button, {
  8953. "size": "large",
  8954. "text": props.confirmButtonText || t$7("confirm"),
  8955. "class": [bem$B("confirm"), {
  8956. [BORDER_LEFT]: props.showCancelButton
  8957. }],
  8958. "style": {
  8959. color: props.confirmButtonColor
  8960. },
  8961. "loading": loading.confirm,
  8962. "disabled": props.confirmButtonDisabled,
  8963. "onClick": onConfirm
  8964. }, null)]);
  8965. const renderRoundButtons = () => createVNode(ActionBar, {
  8966. "class": bem$B("footer")
  8967. }, {
  8968. default: () => [props.showCancelButton && createVNode(ActionBarButton, {
  8969. "type": "warning",
  8970. "text": props.cancelButtonText || t$7("cancel"),
  8971. "class": bem$B("cancel"),
  8972. "color": props.cancelButtonColor,
  8973. "loading": loading.cancel,
  8974. "disabled": props.cancelButtonDisabled,
  8975. "onClick": onCancel
  8976. }, null), props.showConfirmButton && createVNode(ActionBarButton, {
  8977. "type": "danger",
  8978. "text": props.confirmButtonText || t$7("confirm"),
  8979. "class": bem$B("confirm"),
  8980. "color": props.confirmButtonColor,
  8981. "loading": loading.confirm,
  8982. "disabled": props.confirmButtonDisabled,
  8983. "onClick": onConfirm
  8984. }, null)]
  8985. });
  8986. const renderFooter = () => {
  8987. if (slots.footer) {
  8988. return slots.footer();
  8989. }
  8990. return props.theme === "round-button" ? renderRoundButtons() : renderButtons();
  8991. };
  8992. return () => {
  8993. const {
  8994. width,
  8995. title,
  8996. theme,
  8997. message,
  8998. className
  8999. } = props;
  9000. return createVNode(Popup, mergeProps({
  9001. "ref": root,
  9002. "role": "dialog",
  9003. "class": [bem$B([theme]), className],
  9004. "style": {
  9005. width: addUnit(width)
  9006. },
  9007. "tabindex": 0,
  9008. "aria-labelledby": title || message,
  9009. "onKeydown": onKeydown,
  9010. "onUpdate:show": updateShow
  9011. }, pick(props, popupInheritKeys$1)), {
  9012. default: () => [renderTitle(), renderContent(), renderFooter()]
  9013. });
  9014. };
  9015. }
  9016. });
  9017. let instance$2;
  9018. function initInstance$2() {
  9019. const Wrapper = {
  9020. setup() {
  9021. const {
  9022. state,
  9023. toggle
  9024. } = usePopupState();
  9025. return () => createVNode(stdin_default$G, mergeProps(state, {
  9026. "onUpdate:show": toggle
  9027. }), null);
  9028. }
  9029. };
  9030. ({
  9031. instance: instance$2
  9032. } = mountComponent(Wrapper));
  9033. }
  9034. function Dialog(options) {
  9035. if (!inBrowser) {
  9036. return Promise.resolve();
  9037. }
  9038. return new Promise((resolve, reject) => {
  9039. if (!instance$2) {
  9040. initInstance$2();
  9041. }
  9042. instance$2.open(extend({}, Dialog.currentOptions, options, {
  9043. callback: (action) => {
  9044. (action === "confirm" ? resolve : reject)(action);
  9045. }
  9046. }));
  9047. });
  9048. }
  9049. Dialog.defaultOptions = {
  9050. title: "",
  9051. width: "",
  9052. theme: null,
  9053. message: "",
  9054. overlay: true,
  9055. callback: null,
  9056. teleport: "body",
  9057. className: "",
  9058. allowHtml: false,
  9059. lockScroll: true,
  9060. transition: void 0,
  9061. beforeClose: null,
  9062. overlayClass: "",
  9063. overlayStyle: void 0,
  9064. messageAlign: "",
  9065. cancelButtonText: "",
  9066. cancelButtonColor: null,
  9067. cancelButtonDisabled: false,
  9068. confirmButtonText: "",
  9069. confirmButtonColor: null,
  9070. confirmButtonDisabled: false,
  9071. showConfirmButton: true,
  9072. showCancelButton: false,
  9073. closeOnPopstate: true,
  9074. closeOnClickOverlay: false
  9075. };
  9076. Dialog.currentOptions = extend({}, Dialog.defaultOptions);
  9077. Dialog.alert = Dialog;
  9078. Dialog.confirm = (options) => Dialog(extend({
  9079. showCancelButton: true
  9080. }, options));
  9081. Dialog.close = () => {
  9082. if (instance$2) {
  9083. instance$2.toggle(false);
  9084. }
  9085. };
  9086. Dialog.setDefaultOptions = (options) => {
  9087. extend(Dialog.currentOptions, options);
  9088. };
  9089. Dialog.resetDefaultOptions = () => {
  9090. Dialog.currentOptions = extend({}, Dialog.defaultOptions);
  9091. };
  9092. Dialog.Component = withInstall(stdin_default$G);
  9093. Dialog.install = (app) => {
  9094. app.use(Dialog.Component);
  9095. app.config.globalProperties.$dialog = Dialog;
  9096. };
  9097. const [name$z, bem$A] = createNamespace("divider");
  9098. const dividerProps = {
  9099. dashed: Boolean,
  9100. hairline: truthProp,
  9101. contentPosition: makeStringProp("center")
  9102. };
  9103. var stdin_default$F = defineComponent({
  9104. name: name$z,
  9105. props: dividerProps,
  9106. setup(props, {
  9107. slots
  9108. }) {
  9109. return () => {
  9110. var _a;
  9111. return createVNode("div", {
  9112. "role": "separator",
  9113. "class": bem$A({
  9114. dashed: props.dashed,
  9115. hairline: props.hairline,
  9116. [`content-${props.contentPosition}`]: !!slots.default
  9117. })
  9118. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  9119. };
  9120. }
  9121. });
  9122. const Divider = withInstall(stdin_default$F);
  9123. const [name$y, bem$z] = createNamespace("dropdown-menu");
  9124. const dropdownMenuProps = {
  9125. overlay: truthProp,
  9126. zIndex: numericProp,
  9127. duration: makeNumericProp(0.2),
  9128. direction: makeStringProp("down"),
  9129. activeColor: String,
  9130. closeOnClickOutside: truthProp,
  9131. closeOnClickOverlay: truthProp
  9132. };
  9133. const DROPDOWN_KEY = Symbol(name$y);
  9134. var stdin_default$E = defineComponent({
  9135. name: name$y,
  9136. props: dropdownMenuProps,
  9137. setup(props, {
  9138. slots
  9139. }) {
  9140. const id = useId();
  9141. const root = ref();
  9142. const barRef = ref();
  9143. const offset = ref(0);
  9144. const {
  9145. children,
  9146. linkChildren
  9147. } = useChildren(DROPDOWN_KEY);
  9148. const scrollParent = useScrollParent(root);
  9149. const opened = computed(() => children.some((item) => item.state.showWrapper));
  9150. const barStyle = computed(() => {
  9151. if (opened.value && isDef(props.zIndex)) {
  9152. return {
  9153. zIndex: +props.zIndex + 1
  9154. };
  9155. }
  9156. });
  9157. const onClickAway = () => {
  9158. if (props.closeOnClickOutside) {
  9159. children.forEach((item) => {
  9160. item.toggle(false);
  9161. });
  9162. }
  9163. };
  9164. const updateOffset = () => {
  9165. if (barRef.value) {
  9166. const rect = useRect(barRef);
  9167. if (props.direction === "down") {
  9168. offset.value = rect.bottom;
  9169. } else {
  9170. offset.value = windowHeight.value - rect.top;
  9171. }
  9172. }
  9173. };
  9174. const onScroll = () => {
  9175. if (opened.value) {
  9176. updateOffset();
  9177. }
  9178. };
  9179. const toggleItem = (active) => {
  9180. children.forEach((item, index) => {
  9181. if (index === active) {
  9182. updateOffset();
  9183. item.toggle();
  9184. } else if (item.state.showPopup) {
  9185. item.toggle(false, {
  9186. immediate: true
  9187. });
  9188. }
  9189. });
  9190. };
  9191. const renderTitle = (item, index) => {
  9192. const {
  9193. showPopup
  9194. } = item.state;
  9195. const {
  9196. disabled,
  9197. titleClass
  9198. } = item;
  9199. return createVNode("div", {
  9200. "id": `${id}-${index}`,
  9201. "role": "button",
  9202. "tabindex": disabled ? void 0 : 0,
  9203. "class": [bem$z("item", {
  9204. disabled
  9205. }), {
  9206. [HAPTICS_FEEDBACK]: !disabled
  9207. }],
  9208. "onClick": () => {
  9209. if (!disabled) {
  9210. toggleItem(index);
  9211. }
  9212. }
  9213. }, [createVNode("span", {
  9214. "class": [bem$z("title", {
  9215. down: showPopup === (props.direction === "down"),
  9216. active: showPopup
  9217. }), titleClass],
  9218. "style": {
  9219. color: showPopup ? props.activeColor : ""
  9220. }
  9221. }, [createVNode("div", {
  9222. "class": "van-ellipsis"
  9223. }, [item.renderTitle()])])]);
  9224. };
  9225. linkChildren({
  9226. id,
  9227. props,
  9228. offset
  9229. });
  9230. useClickAway(root, onClickAway);
  9231. useEventListener("scroll", onScroll, {
  9232. target: scrollParent,
  9233. passive: true
  9234. });
  9235. return () => {
  9236. var _a;
  9237. return createVNode("div", {
  9238. "ref": root,
  9239. "class": bem$z()
  9240. }, [createVNode("div", {
  9241. "ref": barRef,
  9242. "style": barStyle.value,
  9243. "class": bem$z("bar", {
  9244. opened: opened.value
  9245. })
  9246. }, [children.map(renderTitle)]), (_a = slots.default) == null ? void 0 : _a.call(slots)]);
  9247. };
  9248. }
  9249. });
  9250. const [name$x, bem$y] = createNamespace("dropdown-item");
  9251. const dropdownItemProps = {
  9252. title: String,
  9253. options: makeArrayProp(),
  9254. disabled: Boolean,
  9255. teleport: [String, Object],
  9256. lazyRender: truthProp,
  9257. modelValue: unknownProp,
  9258. titleClass: unknownProp
  9259. };
  9260. var stdin_default$D = defineComponent({
  9261. name: name$x,
  9262. props: dropdownItemProps,
  9263. emits: ["open", "opened", "close", "closed", "change", "update:modelValue"],
  9264. setup(props, {
  9265. emit,
  9266. slots
  9267. }) {
  9268. const state = reactive({
  9269. showPopup: false,
  9270. transition: true,
  9271. showWrapper: false
  9272. });
  9273. const {
  9274. parent,
  9275. index
  9276. } = useParent(DROPDOWN_KEY);
  9277. if (!parent) {
  9278. if (process.env.NODE_ENV !== "production") {
  9279. console.error("[Vant] <DropdownItem> must be a child component of <DropdownMenu>.");
  9280. }
  9281. return;
  9282. }
  9283. const getEmitter = (name2) => () => emit(name2);
  9284. const onOpen = getEmitter("open");
  9285. const onClose = getEmitter("close");
  9286. const onOpened = getEmitter("opened");
  9287. const onClosed = () => {
  9288. state.showWrapper = false;
  9289. emit("closed");
  9290. };
  9291. const onClickWrapper = (event) => {
  9292. if (props.teleport) {
  9293. event.stopPropagation();
  9294. }
  9295. };
  9296. const toggle = (show = !state.showPopup, options = {}) => {
  9297. if (show === state.showPopup) {
  9298. return;
  9299. }
  9300. state.showPopup = show;
  9301. state.transition = !options.immediate;
  9302. if (show) {
  9303. state.showWrapper = true;
  9304. }
  9305. };
  9306. const renderTitle = () => {
  9307. if (slots.title) {
  9308. return slots.title();
  9309. }
  9310. if (props.title) {
  9311. return props.title;
  9312. }
  9313. const match = props.options.find((option) => option.value === props.modelValue);
  9314. return match ? match.text : "";
  9315. };
  9316. const renderOption = (option) => {
  9317. const {
  9318. activeColor
  9319. } = parent.props;
  9320. const active = option.value === props.modelValue;
  9321. const onClick = () => {
  9322. state.showPopup = false;
  9323. if (option.value !== props.modelValue) {
  9324. emit("update:modelValue", option.value);
  9325. emit("change", option.value);
  9326. }
  9327. };
  9328. const renderIcon = () => {
  9329. if (active) {
  9330. return createVNode(Icon, {
  9331. "class": bem$y("icon"),
  9332. "color": activeColor,
  9333. "name": "success"
  9334. }, null);
  9335. }
  9336. };
  9337. return createVNode(Cell, {
  9338. "role": "menuitem",
  9339. "key": option.value,
  9340. "icon": option.icon,
  9341. "title": option.text,
  9342. "class": bem$y("option", {
  9343. active
  9344. }),
  9345. "style": {
  9346. color: active ? activeColor : ""
  9347. },
  9348. "tabindex": active ? 0 : -1,
  9349. "clickable": true,
  9350. "onClick": onClick
  9351. }, {
  9352. value: renderIcon
  9353. });
  9354. };
  9355. const renderContent = () => {
  9356. const {
  9357. offset
  9358. } = parent;
  9359. const {
  9360. zIndex,
  9361. overlay,
  9362. duration,
  9363. direction,
  9364. closeOnClickOverlay
  9365. } = parent.props;
  9366. const style = getZIndexStyle(zIndex);
  9367. if (direction === "down") {
  9368. style.top = `${offset.value}px`;
  9369. } else {
  9370. style.bottom = `${offset.value}px`;
  9371. }
  9372. return withDirectives(createVNode("div", {
  9373. "style": style,
  9374. "class": bem$y([direction]),
  9375. "onClick": onClickWrapper
  9376. }, [createVNode(Popup, {
  9377. "show": state.showPopup,
  9378. "onUpdate:show": ($event) => state.showPopup = $event,
  9379. "role": "menu",
  9380. "class": bem$y("content"),
  9381. "overlay": overlay,
  9382. "position": direction === "down" ? "top" : "bottom",
  9383. "duration": state.transition ? duration : 0,
  9384. "lazyRender": props.lazyRender,
  9385. "overlayStyle": {
  9386. position: "absolute"
  9387. },
  9388. "aria-labelledby": `${parent.id}-${index.value}`,
  9389. "closeOnClickOverlay": closeOnClickOverlay,
  9390. "onOpen": onOpen,
  9391. "onClose": onClose,
  9392. "onOpened": onOpened,
  9393. "onClosed": onClosed
  9394. }, {
  9395. default: () => {
  9396. var _a;
  9397. return [props.options.map(renderOption), (_a = slots.default) == null ? void 0 : _a.call(slots)];
  9398. }
  9399. })]), [[vShow, state.showWrapper]]);
  9400. };
  9401. useExpose({
  9402. state,
  9403. toggle,
  9404. renderTitle
  9405. });
  9406. return () => {
  9407. if (props.teleport) {
  9408. return createVNode(Teleport, {
  9409. "to": props.teleport
  9410. }, {
  9411. default: () => [renderContent()]
  9412. });
  9413. }
  9414. return renderContent();
  9415. };
  9416. }
  9417. });
  9418. const DropdownItem = withInstall(stdin_default$D);
  9419. const DropdownMenu = withInstall(stdin_default$E);
  9420. const [name$w, bem$x] = createNamespace("grid");
  9421. const gridProps = {
  9422. square: Boolean,
  9423. center: truthProp,
  9424. border: truthProp,
  9425. gutter: numericProp,
  9426. reverse: Boolean,
  9427. iconSize: numericProp,
  9428. direction: String,
  9429. clickable: Boolean,
  9430. columnNum: makeNumericProp(4)
  9431. };
  9432. const GRID_KEY = Symbol(name$w);
  9433. var stdin_default$C = defineComponent({
  9434. name: name$w,
  9435. props: gridProps,
  9436. setup(props, {
  9437. slots
  9438. }) {
  9439. const {
  9440. linkChildren
  9441. } = useChildren(GRID_KEY);
  9442. linkChildren({
  9443. props
  9444. });
  9445. return () => {
  9446. var _a;
  9447. return createVNode("div", {
  9448. "style": {
  9449. paddingLeft: addUnit(props.gutter)
  9450. },
  9451. "class": [bem$x(), {
  9452. [BORDER_TOP]: props.border && !props.gutter
  9453. }]
  9454. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  9455. };
  9456. }
  9457. });
  9458. const Grid = withInstall(stdin_default$C);
  9459. const [name$v, bem$w] = createNamespace("grid-item");
  9460. const gridItemProps = extend({}, routeProps, {
  9461. dot: Boolean,
  9462. text: String,
  9463. icon: String,
  9464. badge: numericProp,
  9465. iconColor: String,
  9466. iconPrefix: String,
  9467. badgeProps: Object
  9468. });
  9469. var stdin_default$B = defineComponent({
  9470. name: name$v,
  9471. props: gridItemProps,
  9472. setup(props, {
  9473. slots
  9474. }) {
  9475. const {
  9476. parent,
  9477. index
  9478. } = useParent(GRID_KEY);
  9479. const route2 = useRoute();
  9480. if (!parent) {
  9481. if (process.env.NODE_ENV !== "production") {
  9482. console.error("[Vant] <GridItem> must be a child component of <Grid>.");
  9483. }
  9484. return;
  9485. }
  9486. const rootStyle = computed(() => {
  9487. const {
  9488. square,
  9489. gutter,
  9490. columnNum
  9491. } = parent.props;
  9492. const percent = `${100 / +columnNum}%`;
  9493. const style = {
  9494. flexBasis: percent
  9495. };
  9496. if (square) {
  9497. style.paddingTop = percent;
  9498. } else if (gutter) {
  9499. const gutterValue = addUnit(gutter);
  9500. style.paddingRight = gutterValue;
  9501. if (index.value >= columnNum) {
  9502. style.marginTop = gutterValue;
  9503. }
  9504. }
  9505. return style;
  9506. });
  9507. const contentStyle = computed(() => {
  9508. const {
  9509. square,
  9510. gutter
  9511. } = parent.props;
  9512. if (square && gutter) {
  9513. const gutterValue = addUnit(gutter);
  9514. return {
  9515. right: gutterValue,
  9516. bottom: gutterValue,
  9517. height: "auto"
  9518. };
  9519. }
  9520. });
  9521. const renderIcon = () => {
  9522. if (slots.icon) {
  9523. return createVNode(Badge, mergeProps({
  9524. "dot": props.dot,
  9525. "content": props.badge
  9526. }, props.badgeProps), {
  9527. default: slots.icon
  9528. });
  9529. }
  9530. if (props.icon) {
  9531. return createVNode(Icon, {
  9532. "dot": props.dot,
  9533. "name": props.icon,
  9534. "size": parent.props.iconSize,
  9535. "badge": props.badge,
  9536. "class": bem$w("icon"),
  9537. "color": props.iconColor,
  9538. "badgeProps": props.badgeProps,
  9539. "classPrefix": props.iconPrefix
  9540. }, null);
  9541. }
  9542. };
  9543. const renderText = () => {
  9544. if (slots.text) {
  9545. return slots.text();
  9546. }
  9547. if (props.text) {
  9548. return createVNode("span", {
  9549. "class": bem$w("text")
  9550. }, [props.text]);
  9551. }
  9552. };
  9553. const renderContent = () => {
  9554. if (slots.default) {
  9555. return slots.default();
  9556. }
  9557. return [renderIcon(), renderText()];
  9558. };
  9559. return () => {
  9560. const {
  9561. center,
  9562. border,
  9563. square,
  9564. gutter,
  9565. reverse,
  9566. direction,
  9567. clickable
  9568. } = parent.props;
  9569. const classes = [bem$w("content", [direction, {
  9570. center,
  9571. square,
  9572. reverse,
  9573. clickable,
  9574. surround: border && gutter
  9575. }]), {
  9576. [BORDER]: border
  9577. }];
  9578. return createVNode("div", {
  9579. "class": [bem$w({
  9580. square
  9581. })],
  9582. "style": rootStyle.value
  9583. }, [createVNode("div", {
  9584. "role": clickable ? "button" : void 0,
  9585. "class": classes,
  9586. "style": contentStyle.value,
  9587. "tabindex": clickable ? 0 : void 0,
  9588. "onClick": route2
  9589. }, [renderContent()])]);
  9590. };
  9591. }
  9592. });
  9593. const GridItem = withInstall(stdin_default$B);
  9594. const getDistance = (touches) => Math.sqrt((touches[0].clientX - touches[1].clientX) ** 2 + (touches[0].clientY - touches[1].clientY) ** 2);
  9595. const bem$v = createNamespace("image-preview")[1];
  9596. var stdin_default$A = defineComponent({
  9597. props: {
  9598. src: String,
  9599. show: Boolean,
  9600. active: Number,
  9601. minZoom: makeRequiredProp(numericProp),
  9602. maxZoom: makeRequiredProp(numericProp),
  9603. rootWidth: makeRequiredProp(Number),
  9604. rootHeight: makeRequiredProp(Number)
  9605. },
  9606. emits: ["scale", "close"],
  9607. setup(props, {
  9608. emit,
  9609. slots
  9610. }) {
  9611. const state = reactive({
  9612. scale: 1,
  9613. moveX: 0,
  9614. moveY: 0,
  9615. moving: false,
  9616. zooming: false,
  9617. imageRatio: 0,
  9618. displayWidth: 0,
  9619. displayHeight: 0
  9620. });
  9621. const touch = useTouch();
  9622. const swipeItem = ref();
  9623. const vertical = computed(() => {
  9624. const {
  9625. rootWidth,
  9626. rootHeight
  9627. } = props;
  9628. const rootRatio = rootHeight / rootWidth;
  9629. return state.imageRatio > rootRatio;
  9630. });
  9631. const imageStyle = computed(() => {
  9632. const {
  9633. scale,
  9634. moveX,
  9635. moveY,
  9636. moving,
  9637. zooming
  9638. } = state;
  9639. const style = {
  9640. transitionDuration: zooming || moving ? "0s" : ".3s"
  9641. };
  9642. if (scale !== 1) {
  9643. const offsetX = moveX / scale;
  9644. const offsetY = moveY / scale;
  9645. style.transform = `scale(${scale}, ${scale}) translate(${offsetX}px, ${offsetY}px)`;
  9646. }
  9647. return style;
  9648. });
  9649. const maxMoveX = computed(() => {
  9650. if (state.imageRatio) {
  9651. const {
  9652. rootWidth,
  9653. rootHeight
  9654. } = props;
  9655. const displayWidth = vertical.value ? rootHeight / state.imageRatio : rootWidth;
  9656. return Math.max(0, (state.scale * displayWidth - rootWidth) / 2);
  9657. }
  9658. return 0;
  9659. });
  9660. const maxMoveY = computed(() => {
  9661. if (state.imageRatio) {
  9662. const {
  9663. rootWidth,
  9664. rootHeight
  9665. } = props;
  9666. const displayHeight = vertical.value ? rootHeight : rootWidth * state.imageRatio;
  9667. return Math.max(0, (state.scale * displayHeight - rootHeight) / 2);
  9668. }
  9669. return 0;
  9670. });
  9671. const setScale = (scale) => {
  9672. scale = clamp(scale, +props.minZoom, +props.maxZoom + 1);
  9673. if (scale !== state.scale) {
  9674. state.scale = scale;
  9675. emit("scale", {
  9676. scale,
  9677. index: props.active
  9678. });
  9679. }
  9680. };
  9681. const resetScale = () => {
  9682. setScale(1);
  9683. state.moveX = 0;
  9684. state.moveY = 0;
  9685. };
  9686. const toggleScale = () => {
  9687. const scale = state.scale > 1 ? 1 : 2;
  9688. setScale(scale);
  9689. state.moveX = 0;
  9690. state.moveY = 0;
  9691. };
  9692. let fingerNum;
  9693. let startMoveX;
  9694. let startMoveY;
  9695. let startScale;
  9696. let startDistance;
  9697. let doubleTapTimer;
  9698. let touchStartTime;
  9699. const onTouchStart = (event) => {
  9700. const {
  9701. touches
  9702. } = event;
  9703. const {
  9704. offsetX
  9705. } = touch;
  9706. touch.start(event);
  9707. fingerNum = touches.length;
  9708. startMoveX = state.moveX;
  9709. startMoveY = state.moveY;
  9710. touchStartTime = Date.now();
  9711. state.moving = fingerNum === 1 && state.scale !== 1;
  9712. state.zooming = fingerNum === 2 && !offsetX.value;
  9713. if (state.zooming) {
  9714. startScale = state.scale;
  9715. startDistance = getDistance(event.touches);
  9716. }
  9717. };
  9718. const onTouchMove = (event) => {
  9719. const {
  9720. touches
  9721. } = event;
  9722. touch.move(event);
  9723. if (state.moving || state.zooming) {
  9724. preventDefault(event, true);
  9725. }
  9726. if (state.moving) {
  9727. const {
  9728. deltaX,
  9729. deltaY
  9730. } = touch;
  9731. const moveX = deltaX.value + startMoveX;
  9732. const moveY = deltaY.value + startMoveY;
  9733. state.moveX = clamp(moveX, -maxMoveX.value, maxMoveX.value);
  9734. state.moveY = clamp(moveY, -maxMoveY.value, maxMoveY.value);
  9735. }
  9736. if (state.zooming && touches.length === 2) {
  9737. const distance = getDistance(touches);
  9738. const scale = startScale * distance / startDistance;
  9739. setScale(scale);
  9740. }
  9741. };
  9742. const checkTap = () => {
  9743. if (fingerNum > 1) {
  9744. return;
  9745. }
  9746. const {
  9747. offsetX,
  9748. offsetY
  9749. } = touch;
  9750. const deltaTime = Date.now() - touchStartTime;
  9751. const TAP_TIME = 250;
  9752. const TAP_OFFSET = 5;
  9753. if (offsetX.value < TAP_OFFSET && offsetY.value < TAP_OFFSET && deltaTime < TAP_TIME) {
  9754. if (doubleTapTimer) {
  9755. clearTimeout(doubleTapTimer);
  9756. doubleTapTimer = null;
  9757. toggleScale();
  9758. } else {
  9759. doubleTapTimer = setTimeout(() => {
  9760. emit("close");
  9761. doubleTapTimer = null;
  9762. }, TAP_TIME);
  9763. }
  9764. }
  9765. };
  9766. const onTouchEnd = (event) => {
  9767. let stopPropagation2 = false;
  9768. if (state.moving || state.zooming) {
  9769. stopPropagation2 = true;
  9770. if (state.moving && startMoveX === state.moveX && startMoveY === state.moveY) {
  9771. stopPropagation2 = false;
  9772. }
  9773. if (!event.touches.length) {
  9774. if (state.zooming) {
  9775. state.moveX = clamp(state.moveX, -maxMoveX.value, maxMoveX.value);
  9776. state.moveY = clamp(state.moveY, -maxMoveY.value, maxMoveY.value);
  9777. state.zooming = false;
  9778. }
  9779. state.moving = false;
  9780. startMoveX = 0;
  9781. startMoveY = 0;
  9782. startScale = 1;
  9783. if (state.scale < 1) {
  9784. resetScale();
  9785. }
  9786. if (state.scale > props.maxZoom) {
  9787. state.scale = +props.maxZoom;
  9788. }
  9789. }
  9790. }
  9791. preventDefault(event, stopPropagation2);
  9792. checkTap();
  9793. touch.reset();
  9794. };
  9795. const onLoad = (event) => {
  9796. const {
  9797. naturalWidth,
  9798. naturalHeight
  9799. } = event.target;
  9800. state.imageRatio = naturalHeight / naturalWidth;
  9801. };
  9802. watch(() => props.active, resetScale);
  9803. watch(() => props.show, (value) => {
  9804. if (!value) {
  9805. resetScale();
  9806. }
  9807. });
  9808. useEventListener("touchmove", onTouchMove, {
  9809. target: computed(() => {
  9810. var _a;
  9811. return (_a = swipeItem.value) == null ? void 0 : _a.$el;
  9812. })
  9813. });
  9814. return () => {
  9815. const imageSlots = {
  9816. loading: () => createVNode(Loading, {
  9817. "type": "spinner"
  9818. }, null)
  9819. };
  9820. return createVNode(SwipeItem, {
  9821. "ref": swipeItem,
  9822. "class": bem$v("swipe-item"),
  9823. "onTouchstartPassive": onTouchStart,
  9824. "onTouchend": onTouchEnd,
  9825. "onTouchcancel": onTouchEnd
  9826. }, {
  9827. default: () => [slots.image ? createVNode("div", {
  9828. "class": bem$v("image-wrap")
  9829. }, [slots.image({
  9830. src: props.src
  9831. })]) : createVNode(Image$1, {
  9832. "src": props.src,
  9833. "fit": "contain",
  9834. "class": bem$v("image", {
  9835. vertical: vertical.value
  9836. }),
  9837. "style": imageStyle.value,
  9838. "onLoad": onLoad
  9839. }, imageSlots)]
  9840. });
  9841. };
  9842. }
  9843. });
  9844. const [name$u, bem$u] = createNamespace("image-preview");
  9845. const popupProps$1 = ["show", "transition", "overlayStyle", "closeOnPopstate"];
  9846. const imagePreviewProps = {
  9847. show: Boolean,
  9848. loop: truthProp,
  9849. images: makeArrayProp(),
  9850. minZoom: makeNumericProp(1 / 3),
  9851. maxZoom: makeNumericProp(3),
  9852. overlay: truthProp,
  9853. closeable: Boolean,
  9854. showIndex: truthProp,
  9855. className: unknownProp,
  9856. closeIcon: makeStringProp("clear"),
  9857. transition: String,
  9858. beforeClose: Function,
  9859. overlayClass: unknownProp,
  9860. overlayStyle: Object,
  9861. swipeDuration: makeNumericProp(300),
  9862. startPosition: makeNumericProp(0),
  9863. showIndicators: Boolean,
  9864. closeOnPopstate: truthProp,
  9865. closeIconPosition: makeStringProp("top-right")
  9866. };
  9867. var stdin_default$z = defineComponent({
  9868. name: name$u,
  9869. props: imagePreviewProps,
  9870. emits: ["scale", "close", "closed", "change", "update:show"],
  9871. setup(props, {
  9872. emit,
  9873. slots
  9874. }) {
  9875. const swipeRef = ref();
  9876. const state = reactive({
  9877. active: 0,
  9878. rootWidth: 0,
  9879. rootHeight: 0
  9880. });
  9881. const resize = () => {
  9882. if (swipeRef.value) {
  9883. const rect = useRect(swipeRef.value.$el);
  9884. state.rootWidth = rect.width;
  9885. state.rootHeight = rect.height;
  9886. swipeRef.value.resize();
  9887. }
  9888. };
  9889. const emitScale = (args) => emit("scale", args);
  9890. const updateShow = (show) => emit("update:show", show);
  9891. const emitClose = () => {
  9892. callInterceptor(props.beforeClose, {
  9893. args: [state.active],
  9894. done: () => updateShow(false)
  9895. });
  9896. };
  9897. const setActive = (active) => {
  9898. if (active !== state.active) {
  9899. state.active = active;
  9900. emit("change", active);
  9901. }
  9902. };
  9903. const renderIndex = () => {
  9904. if (props.showIndex) {
  9905. return createVNode("div", {
  9906. "class": bem$u("index")
  9907. }, [slots.index ? slots.index({
  9908. index: state.active
  9909. }) : `${state.active + 1} / ${props.images.length}`]);
  9910. }
  9911. };
  9912. const renderCover = () => {
  9913. if (slots.cover) {
  9914. return createVNode("div", {
  9915. "class": bem$u("cover")
  9916. }, [slots.cover()]);
  9917. }
  9918. };
  9919. const renderImages = () => createVNode(Swipe, {
  9920. "ref": swipeRef,
  9921. "lazyRender": true,
  9922. "loop": props.loop,
  9923. "class": bem$u("swipe"),
  9924. "duration": props.swipeDuration,
  9925. "initialSwipe": props.startPosition,
  9926. "showIndicators": props.showIndicators,
  9927. "indicatorColor": "white",
  9928. "onChange": setActive
  9929. }, {
  9930. default: () => [props.images.map((image) => createVNode(stdin_default$A, {
  9931. "src": image,
  9932. "show": props.show,
  9933. "active": state.active,
  9934. "maxZoom": props.maxZoom,
  9935. "minZoom": props.minZoom,
  9936. "rootWidth": state.rootWidth,
  9937. "rootHeight": state.rootHeight,
  9938. "onScale": emitScale,
  9939. "onClose": emitClose
  9940. }, {
  9941. image: slots.image
  9942. }))]
  9943. });
  9944. const renderClose = () => {
  9945. if (props.closeable) {
  9946. return createVNode(Icon, {
  9947. "role": "button",
  9948. "name": props.closeIcon,
  9949. "class": [bem$u("close-icon", props.closeIconPosition), HAPTICS_FEEDBACK],
  9950. "onClick": emitClose
  9951. }, null);
  9952. }
  9953. };
  9954. const onClosed = () => emit("closed");
  9955. const swipeTo = (index, options) => {
  9956. var _a;
  9957. return (_a = swipeRef.value) == null ? void 0 : _a.swipeTo(index, options);
  9958. };
  9959. useExpose({
  9960. swipeTo
  9961. });
  9962. onMounted(resize);
  9963. watch([windowWidth, windowHeight], resize);
  9964. watch(() => props.startPosition, (value) => setActive(+value));
  9965. watch(() => props.show, (value) => {
  9966. const {
  9967. images,
  9968. startPosition
  9969. } = props;
  9970. if (value) {
  9971. setActive(+startPosition);
  9972. nextTick(() => {
  9973. resize();
  9974. swipeTo(+startPosition, {
  9975. immediate: true
  9976. });
  9977. });
  9978. } else {
  9979. emit("close", {
  9980. index: state.active,
  9981. url: images[state.active]
  9982. });
  9983. }
  9984. });
  9985. return () => createVNode(Popup, mergeProps({
  9986. "class": [bem$u(), props.className],
  9987. "overlayClass": [bem$u("overlay"), props.overlayClass],
  9988. "onClosed": onClosed,
  9989. "onUpdate:show": updateShow
  9990. }, pick(props, popupProps$1)), {
  9991. default: () => [renderClose(), renderImages(), renderIndex(), renderCover()]
  9992. });
  9993. }
  9994. });
  9995. let instance$1;
  9996. const defaultConfig = {
  9997. loop: true,
  9998. images: [],
  9999. maxZoom: 3,
  10000. minZoom: 1 / 3,
  10001. onScale: void 0,
  10002. onClose: void 0,
  10003. onChange: void 0,
  10004. teleport: "body",
  10005. className: "",
  10006. showIndex: true,
  10007. closeable: false,
  10008. closeIcon: "clear",
  10009. transition: void 0,
  10010. beforeClose: void 0,
  10011. overlayStyle: void 0,
  10012. overlayClass: void 0,
  10013. startPosition: 0,
  10014. swipeDuration: 300,
  10015. showIndicators: false,
  10016. closeOnPopstate: true,
  10017. closeIconPosition: "top-right"
  10018. };
  10019. function initInstance$1() {
  10020. ({
  10021. instance: instance$1
  10022. } = mountComponent({
  10023. setup() {
  10024. const {
  10025. state,
  10026. toggle
  10027. } = usePopupState();
  10028. const onClosed = () => {
  10029. state.images = [];
  10030. };
  10031. return () => createVNode(stdin_default$z, mergeProps(state, {
  10032. "onClosed": onClosed,
  10033. "onUpdate:show": toggle
  10034. }), null);
  10035. }
  10036. }));
  10037. }
  10038. const ImagePreview = (options, startPosition = 0) => {
  10039. if (!inBrowser) {
  10040. return;
  10041. }
  10042. if (!instance$1) {
  10043. initInstance$1();
  10044. }
  10045. options = Array.isArray(options) ? {
  10046. images: options,
  10047. startPosition
  10048. } : options;
  10049. instance$1.open(extend({}, defaultConfig, options));
  10050. return instance$1;
  10051. };
  10052. ImagePreview.Component = withInstall(stdin_default$z);
  10053. ImagePreview.install = (app) => {
  10054. app.use(ImagePreview.Component);
  10055. };
  10056. function genAlphabet() {
  10057. const charCodeOfA = "A".charCodeAt(0);
  10058. const indexList = Array(26).fill("").map((_, i) => String.fromCharCode(charCodeOfA + i));
  10059. return indexList;
  10060. }
  10061. const [name$t, bem$t] = createNamespace("index-bar");
  10062. const indexBarProps = {
  10063. sticky: truthProp,
  10064. zIndex: numericProp,
  10065. teleport: [String, Object],
  10066. highlightColor: String,
  10067. stickyOffsetTop: makeNumberProp(0),
  10068. indexList: {
  10069. type: Array,
  10070. default: genAlphabet
  10071. }
  10072. };
  10073. const INDEX_BAR_KEY = Symbol(name$t);
  10074. var stdin_default$y = defineComponent({
  10075. name: name$t,
  10076. props: indexBarProps,
  10077. emits: ["select", "change"],
  10078. setup(props, {
  10079. emit,
  10080. slots
  10081. }) {
  10082. const root = ref();
  10083. const sidebar = ref();
  10084. const activeAnchor = ref("");
  10085. const touch = useTouch();
  10086. const scrollParent = useScrollParent(root);
  10087. const {
  10088. children,
  10089. linkChildren
  10090. } = useChildren(INDEX_BAR_KEY);
  10091. let selectActiveIndex;
  10092. linkChildren({
  10093. props
  10094. });
  10095. const sidebarStyle = computed(() => {
  10096. if (isDef(props.zIndex)) {
  10097. return {
  10098. zIndex: +props.zIndex + 1
  10099. };
  10100. }
  10101. });
  10102. const highlightStyle = computed(() => {
  10103. if (props.highlightColor) {
  10104. return {
  10105. color: props.highlightColor
  10106. };
  10107. }
  10108. });
  10109. const getActiveAnchor = (scrollTop, rects) => {
  10110. for (let i = children.length - 1; i >= 0; i--) {
  10111. const prevHeight = i > 0 ? rects[i - 1].height : 0;
  10112. const reachTop = props.sticky ? prevHeight + props.stickyOffsetTop : 0;
  10113. if (scrollTop + reachTop >= rects[i].top) {
  10114. return i;
  10115. }
  10116. }
  10117. return -1;
  10118. };
  10119. const getMatchAnchor = (index) => children.find((item) => String(item.index) === index);
  10120. const onScroll = () => {
  10121. if (isHidden(root)) {
  10122. return;
  10123. }
  10124. const {
  10125. sticky,
  10126. indexList
  10127. } = props;
  10128. const scrollTop = getScrollTop(scrollParent.value);
  10129. const scrollParentRect = useRect(scrollParent);
  10130. const rects = children.map((item) => item.getRect(scrollParent.value, scrollParentRect));
  10131. let active = -1;
  10132. if (selectActiveIndex) {
  10133. const match = getMatchAnchor(selectActiveIndex);
  10134. if (match) {
  10135. const rect = match.getRect(scrollParent.value, scrollParentRect);
  10136. active = getActiveAnchor(rect.top, rects);
  10137. }
  10138. } else {
  10139. active = getActiveAnchor(scrollTop, rects);
  10140. }
  10141. activeAnchor.value = indexList[active];
  10142. if (sticky) {
  10143. children.forEach((item, index) => {
  10144. const {
  10145. state,
  10146. $el
  10147. } = item;
  10148. if (index === active || index === active - 1) {
  10149. const rect = $el.getBoundingClientRect();
  10150. state.left = rect.left;
  10151. state.width = rect.width;
  10152. } else {
  10153. state.left = null;
  10154. state.width = null;
  10155. }
  10156. if (index === active) {
  10157. state.active = true;
  10158. state.top = Math.max(props.stickyOffsetTop, rects[index].top - scrollTop) + scrollParentRect.top;
  10159. } else if (index === active - 1 && selectActiveIndex === "") {
  10160. const activeItemTop = rects[active].top - scrollTop;
  10161. state.active = activeItemTop > 0;
  10162. state.top = activeItemTop + scrollParentRect.top - rects[index].height;
  10163. } else {
  10164. state.active = false;
  10165. }
  10166. });
  10167. }
  10168. selectActiveIndex = "";
  10169. };
  10170. const init = () => {
  10171. nextTick(onScroll);
  10172. };
  10173. useEventListener("scroll", onScroll, {
  10174. target: scrollParent,
  10175. passive: true
  10176. });
  10177. onMounted(init);
  10178. watch(() => props.indexList, init);
  10179. watch(activeAnchor, (value) => {
  10180. if (value) {
  10181. emit("change", value);
  10182. }
  10183. });
  10184. const renderIndexes = () => props.indexList.map((index) => {
  10185. const active = index === activeAnchor.value;
  10186. return createVNode("span", {
  10187. "class": bem$t("index", {
  10188. active
  10189. }),
  10190. "style": active ? highlightStyle.value : void 0,
  10191. "data-index": index
  10192. }, [index]);
  10193. });
  10194. const scrollTo = (index) => {
  10195. selectActiveIndex = String(index);
  10196. const match = getMatchAnchor(selectActiveIndex);
  10197. if (match) {
  10198. const scrollTop = getScrollTop(scrollParent.value);
  10199. const scrollParentRect = useRect(scrollParent);
  10200. const {
  10201. offsetHeight
  10202. } = document.documentElement;
  10203. match.$el.scrollIntoView();
  10204. if (scrollTop === offsetHeight - scrollParentRect.height) {
  10205. onScroll();
  10206. return;
  10207. }
  10208. if (props.sticky && props.stickyOffsetTop) {
  10209. setRootScrollTop(getRootScrollTop() - props.stickyOffsetTop);
  10210. }
  10211. emit("select", match.index);
  10212. }
  10213. };
  10214. const scrollToElement = (element) => {
  10215. const {
  10216. index
  10217. } = element.dataset;
  10218. if (index) {
  10219. scrollTo(index);
  10220. }
  10221. };
  10222. const onClickSidebar = (event) => {
  10223. scrollToElement(event.target);
  10224. };
  10225. let touchActiveIndex;
  10226. const onTouchMove = (event) => {
  10227. touch.move(event);
  10228. if (touch.isVertical()) {
  10229. preventDefault(event);
  10230. const {
  10231. clientX,
  10232. clientY
  10233. } = event.touches[0];
  10234. const target = document.elementFromPoint(clientX, clientY);
  10235. if (target) {
  10236. const {
  10237. index
  10238. } = target.dataset;
  10239. if (index && touchActiveIndex !== index) {
  10240. touchActiveIndex = index;
  10241. scrollToElement(target);
  10242. }
  10243. }
  10244. }
  10245. };
  10246. const renderSidebar = () => createVNode("div", {
  10247. "ref": sidebar,
  10248. "class": bem$t("sidebar"),
  10249. "style": sidebarStyle.value,
  10250. "onClick": onClickSidebar,
  10251. "onTouchstartPassive": touch.start
  10252. }, [renderIndexes()]);
  10253. useExpose({
  10254. scrollTo
  10255. });
  10256. useEventListener("touchmove", onTouchMove, {
  10257. target: sidebar
  10258. });
  10259. return () => {
  10260. var _a;
  10261. return createVNode("div", {
  10262. "ref": root,
  10263. "class": bem$t()
  10264. }, [props.teleport ? createVNode(Teleport, {
  10265. "to": props.teleport
  10266. }, {
  10267. default: () => [renderSidebar()]
  10268. }) : renderSidebar(), (_a = slots.default) == null ? void 0 : _a.call(slots)]);
  10269. };
  10270. }
  10271. });
  10272. const [name$s, bem$s] = createNamespace("index-anchor");
  10273. const indexAnchorProps = {
  10274. index: numericProp
  10275. };
  10276. var stdin_default$x = defineComponent({
  10277. name: name$s,
  10278. props: indexAnchorProps,
  10279. setup(props, {
  10280. slots
  10281. }) {
  10282. const state = reactive({
  10283. top: 0,
  10284. left: null,
  10285. rect: {
  10286. top: 0,
  10287. height: 0
  10288. },
  10289. width: null,
  10290. active: false
  10291. });
  10292. const root = ref();
  10293. const {
  10294. parent
  10295. } = useParent(INDEX_BAR_KEY);
  10296. if (!parent) {
  10297. if (process.env.NODE_ENV !== "production") {
  10298. console.error("[Vant] <IndexAnchor> must be a child component of <IndexBar>.");
  10299. }
  10300. return;
  10301. }
  10302. const isSticky = () => state.active && parent.props.sticky;
  10303. const anchorStyle = computed(() => {
  10304. const {
  10305. zIndex,
  10306. highlightColor
  10307. } = parent.props;
  10308. if (isSticky()) {
  10309. return extend(getZIndexStyle(zIndex), {
  10310. left: state.left ? `${state.left}px` : void 0,
  10311. width: state.width ? `${state.width}px` : void 0,
  10312. transform: state.top ? `translate3d(0, ${state.top}px, 0)` : void 0,
  10313. color: highlightColor
  10314. });
  10315. }
  10316. });
  10317. const getRect = (scrollParent, scrollParentRect) => {
  10318. const rootRect = useRect(root);
  10319. state.rect.height = rootRect.height;
  10320. if (scrollParent === window || scrollParent === document.body) {
  10321. state.rect.top = rootRect.top + getRootScrollTop();
  10322. } else {
  10323. state.rect.top = rootRect.top + getScrollTop(scrollParent) - scrollParentRect.top;
  10324. }
  10325. return state.rect;
  10326. };
  10327. useExpose({
  10328. state,
  10329. getRect
  10330. });
  10331. return () => {
  10332. const sticky = isSticky();
  10333. return createVNode("div", {
  10334. "ref": root,
  10335. "style": {
  10336. height: sticky ? `${state.rect.height}px` : void 0
  10337. }
  10338. }, [createVNode("div", {
  10339. "style": anchorStyle.value,
  10340. "class": [bem$s({
  10341. sticky
  10342. }), {
  10343. [BORDER_BOTTOM]: sticky
  10344. }]
  10345. }, [slots.default ? slots.default() : props.index])]);
  10346. };
  10347. }
  10348. });
  10349. const IndexAnchor = withInstall(stdin_default$x);
  10350. const IndexBar = withInstall(stdin_default$y);
  10351. const [name$r, bem$r, t$6] = createNamespace("list");
  10352. const listProps = {
  10353. error: Boolean,
  10354. offset: makeNumericProp(300),
  10355. loading: Boolean,
  10356. finished: Boolean,
  10357. errorText: String,
  10358. direction: makeStringProp("down"),
  10359. loadingText: String,
  10360. finishedText: String,
  10361. immediateCheck: truthProp
  10362. };
  10363. var stdin_default$w = defineComponent({
  10364. name: name$r,
  10365. props: listProps,
  10366. emits: ["load", "update:error", "update:loading"],
  10367. setup(props, {
  10368. emit,
  10369. slots
  10370. }) {
  10371. const loading = ref(props.loading);
  10372. const root = ref();
  10373. const placeholder = ref();
  10374. const tabStatus = useTabStatus();
  10375. const scrollParent = useScrollParent(root);
  10376. const check = () => {
  10377. nextTick(() => {
  10378. if (loading.value || props.finished || props.error || (tabStatus == null ? void 0 : tabStatus.value) === false) {
  10379. return;
  10380. }
  10381. const {
  10382. offset,
  10383. direction
  10384. } = props;
  10385. const scrollParentRect = useRect(scrollParent);
  10386. if (!scrollParentRect.height || isHidden(root)) {
  10387. return;
  10388. }
  10389. let isReachEdge = false;
  10390. const placeholderRect = useRect(placeholder);
  10391. if (direction === "up") {
  10392. isReachEdge = scrollParentRect.top - placeholderRect.top <= offset;
  10393. } else {
  10394. isReachEdge = placeholderRect.bottom - scrollParentRect.bottom <= offset;
  10395. }
  10396. if (isReachEdge) {
  10397. loading.value = true;
  10398. emit("update:loading", true);
  10399. emit("load");
  10400. }
  10401. });
  10402. };
  10403. const renderFinishedText = () => {
  10404. if (props.finished) {
  10405. const text = slots.finished ? slots.finished() : props.finishedText;
  10406. if (text) {
  10407. return createVNode("div", {
  10408. "class": bem$r("finished-text")
  10409. }, [text]);
  10410. }
  10411. }
  10412. };
  10413. const clickErrorText = () => {
  10414. emit("update:error", false);
  10415. check();
  10416. };
  10417. const renderErrorText = () => {
  10418. if (props.error) {
  10419. const text = slots.error ? slots.error() : props.errorText;
  10420. if (text) {
  10421. return createVNode("div", {
  10422. "role": "button",
  10423. "class": bem$r("error-text"),
  10424. "tabindex": 0,
  10425. "onClick": clickErrorText
  10426. }, [text]);
  10427. }
  10428. }
  10429. };
  10430. const renderLoading = () => {
  10431. if (loading.value && !props.finished) {
  10432. return createVNode("div", {
  10433. "class": bem$r("loading")
  10434. }, [slots.loading ? slots.loading() : createVNode(Loading, {
  10435. "class": bem$r("loading-icon")
  10436. }, {
  10437. default: () => [props.loadingText || t$6("loading")]
  10438. })]);
  10439. }
  10440. };
  10441. watch(() => [props.loading, props.finished, props.error], check);
  10442. if (tabStatus) {
  10443. watch(tabStatus, (tabActive) => {
  10444. if (tabActive) {
  10445. check();
  10446. }
  10447. });
  10448. }
  10449. onUpdated(() => {
  10450. loading.value = props.loading;
  10451. });
  10452. onMounted(() => {
  10453. if (props.immediateCheck) {
  10454. check();
  10455. }
  10456. });
  10457. useExpose({
  10458. check
  10459. });
  10460. useEventListener("scroll", check, {
  10461. target: scrollParent,
  10462. passive: true
  10463. });
  10464. return () => {
  10465. var _a;
  10466. const Content = (_a = slots.default) == null ? void 0 : _a.call(slots);
  10467. const Placeholder = createVNode("div", {
  10468. "ref": placeholder,
  10469. "class": bem$r("placeholder")
  10470. }, null);
  10471. return createVNode("div", {
  10472. "ref": root,
  10473. "role": "feed",
  10474. "class": bem$r(),
  10475. "aria-busy": loading.value
  10476. }, [props.direction === "down" ? Content : Placeholder, renderLoading(), renderFinishedText(), renderErrorText(), props.direction === "up" ? Content : Placeholder]);
  10477. };
  10478. }
  10479. });
  10480. const List = withInstall(stdin_default$w);
  10481. const [name$q, bem$q] = createNamespace("nav-bar");
  10482. const navBarProps = {
  10483. title: String,
  10484. fixed: Boolean,
  10485. zIndex: numericProp,
  10486. border: truthProp,
  10487. leftText: String,
  10488. rightText: String,
  10489. leftArrow: Boolean,
  10490. placeholder: Boolean,
  10491. safeAreaInsetTop: Boolean
  10492. };
  10493. var stdin_default$v = defineComponent({
  10494. name: name$q,
  10495. props: navBarProps,
  10496. emits: ["click-left", "click-right"],
  10497. setup(props, {
  10498. emit,
  10499. slots
  10500. }) {
  10501. const navBarRef = ref();
  10502. const renderPlaceholder = usePlaceholder(navBarRef, bem$q);
  10503. const onClickLeft = (event) => emit("click-left", event);
  10504. const onClickRight = (event) => emit("click-right", event);
  10505. const renderLeft = () => {
  10506. if (slots.left) {
  10507. return slots.left();
  10508. }
  10509. return [props.leftArrow && createVNode(Icon, {
  10510. "class": bem$q("arrow"),
  10511. "name": "arrow-left"
  10512. }, null), props.leftText && createVNode("span", {
  10513. "class": bem$q("text")
  10514. }, [props.leftText])];
  10515. };
  10516. const renderRight = () => {
  10517. if (slots.right) {
  10518. return slots.right();
  10519. }
  10520. return createVNode("span", {
  10521. "class": bem$q("text")
  10522. }, [props.rightText]);
  10523. };
  10524. const renderNavBar = () => {
  10525. const {
  10526. title,
  10527. fixed,
  10528. border,
  10529. zIndex
  10530. } = props;
  10531. const style = getZIndexStyle(zIndex);
  10532. const hasLeft = props.leftArrow || props.leftText || slots.left;
  10533. const hasRight = props.rightText || slots.right;
  10534. return createVNode("div", {
  10535. "ref": navBarRef,
  10536. "style": style,
  10537. "class": [bem$q({
  10538. fixed
  10539. }), {
  10540. [BORDER_BOTTOM]: border,
  10541. "van-safe-area-top": props.safeAreaInsetTop
  10542. }]
  10543. }, [createVNode("div", {
  10544. "class": bem$q("content")
  10545. }, [hasLeft && createVNode("div", {
  10546. "class": [bem$q("left"), HAPTICS_FEEDBACK],
  10547. "onClick": onClickLeft
  10548. }, [renderLeft()]), createVNode("div", {
  10549. "class": [bem$q("title"), "van-ellipsis"]
  10550. }, [slots.title ? slots.title() : title]), hasRight && createVNode("div", {
  10551. "class": [bem$q("right"), HAPTICS_FEEDBACK],
  10552. "onClick": onClickRight
  10553. }, [renderRight()])])]);
  10554. };
  10555. return () => {
  10556. if (props.fixed && props.placeholder) {
  10557. return renderPlaceholder(renderNavBar);
  10558. }
  10559. return renderNavBar();
  10560. };
  10561. }
  10562. });
  10563. const NavBar = withInstall(stdin_default$v);
  10564. const [name$p, bem$p] = createNamespace("notice-bar");
  10565. const noticeBarProps = {
  10566. text: String,
  10567. mode: String,
  10568. color: String,
  10569. delay: makeNumericProp(1),
  10570. speed: makeNumericProp(60),
  10571. leftIcon: String,
  10572. wrapable: Boolean,
  10573. background: String,
  10574. scrollable: {
  10575. type: Boolean,
  10576. default: null
  10577. }
  10578. };
  10579. var stdin_default$u = defineComponent({
  10580. name: name$p,
  10581. props: noticeBarProps,
  10582. emits: ["close", "replay"],
  10583. setup(props, {
  10584. emit,
  10585. slots
  10586. }) {
  10587. let wrapWidth = 0;
  10588. let contentWidth = 0;
  10589. let startTimer;
  10590. const wrapRef = ref();
  10591. const contentRef = ref();
  10592. const state = reactive({
  10593. show: true,
  10594. offset: 0,
  10595. duration: 0
  10596. });
  10597. const renderLeftIcon = () => {
  10598. if (slots["left-icon"]) {
  10599. return slots["left-icon"]();
  10600. }
  10601. if (props.leftIcon) {
  10602. return createVNode(Icon, {
  10603. "class": bem$p("left-icon"),
  10604. "name": props.leftIcon
  10605. }, null);
  10606. }
  10607. };
  10608. const getRightIconName = () => {
  10609. if (props.mode === "closeable") {
  10610. return "cross";
  10611. }
  10612. if (props.mode === "link") {
  10613. return "arrow";
  10614. }
  10615. };
  10616. const onClickRightIcon = (event) => {
  10617. if (props.mode === "closeable") {
  10618. state.show = false;
  10619. emit("close", event);
  10620. }
  10621. };
  10622. const renderRightIcon = () => {
  10623. if (slots["right-icon"]) {
  10624. return slots["right-icon"]();
  10625. }
  10626. const name2 = getRightIconName();
  10627. if (name2) {
  10628. return createVNode(Icon, {
  10629. "name": name2,
  10630. "class": bem$p("right-icon"),
  10631. "onClick": onClickRightIcon
  10632. }, null);
  10633. }
  10634. };
  10635. const onTransitionEnd = () => {
  10636. state.offset = wrapWidth;
  10637. state.duration = 0;
  10638. raf(() => {
  10639. doubleRaf(() => {
  10640. state.offset = -contentWidth;
  10641. state.duration = (contentWidth + wrapWidth) / +props.speed;
  10642. emit("replay");
  10643. });
  10644. });
  10645. };
  10646. const renderMarquee = () => {
  10647. const ellipsis = props.scrollable === false && !props.wrapable;
  10648. const style = {
  10649. transform: state.offset ? `translateX(${state.offset}px)` : "",
  10650. transitionDuration: `${state.duration}s`
  10651. };
  10652. return createVNode("div", {
  10653. "ref": wrapRef,
  10654. "role": "marquee",
  10655. "class": bem$p("wrap")
  10656. }, [createVNode("div", {
  10657. "ref": contentRef,
  10658. "style": style,
  10659. "class": [bem$p("content"), {
  10660. "van-ellipsis": ellipsis
  10661. }],
  10662. "onTransitionend": onTransitionEnd
  10663. }, [slots.default ? slots.default() : props.text])]);
  10664. };
  10665. const reset = () => {
  10666. const {
  10667. delay,
  10668. speed,
  10669. scrollable
  10670. } = props;
  10671. const ms = isDef(delay) ? +delay * 1e3 : 0;
  10672. wrapWidth = 0;
  10673. contentWidth = 0;
  10674. state.offset = 0;
  10675. state.duration = 0;
  10676. clearTimeout(startTimer);
  10677. startTimer = setTimeout(() => {
  10678. if (!wrapRef.value || !contentRef.value || scrollable === false) {
  10679. return;
  10680. }
  10681. const wrapRefWidth = useRect(wrapRef).width;
  10682. const contentRefWidth = useRect(contentRef).width;
  10683. if (scrollable || contentRefWidth > wrapRefWidth) {
  10684. doubleRaf(() => {
  10685. wrapWidth = wrapRefWidth;
  10686. contentWidth = contentRefWidth;
  10687. state.offset = -contentWidth;
  10688. state.duration = contentWidth / +speed;
  10689. });
  10690. }
  10691. }, ms);
  10692. };
  10693. onPopupReopen(reset);
  10694. onMountedOrActivated(reset);
  10695. useEventListener("pageshow", reset);
  10696. useExpose({
  10697. reset
  10698. });
  10699. watch(() => [props.text, props.scrollable], reset);
  10700. return () => {
  10701. const {
  10702. color,
  10703. wrapable,
  10704. background
  10705. } = props;
  10706. return withDirectives(createVNode("div", {
  10707. "role": "alert",
  10708. "class": bem$p({
  10709. wrapable
  10710. }),
  10711. "style": {
  10712. color,
  10713. background
  10714. }
  10715. }, [renderLeftIcon(), renderMarquee(), renderRightIcon()]), [[vShow, state.show]]);
  10716. };
  10717. }
  10718. });
  10719. const NoticeBar = withInstall(stdin_default$u);
  10720. const [name$o, bem$o] = createNamespace("notify");
  10721. const notifyProps = extend({}, popupSharedProps, {
  10722. type: makeStringProp("danger"),
  10723. color: String,
  10724. message: numericProp,
  10725. position: makeStringProp("top"),
  10726. className: unknownProp,
  10727. background: String,
  10728. lockScroll: Boolean
  10729. });
  10730. var stdin_default$t = defineComponent({
  10731. name: name$o,
  10732. props: notifyProps,
  10733. emits: ["update:show"],
  10734. setup(props, {
  10735. emit,
  10736. slots
  10737. }) {
  10738. const updateShow = (show) => emit("update:show", show);
  10739. return () => createVNode(Popup, {
  10740. "show": props.show,
  10741. "class": [bem$o([props.type]), props.className],
  10742. "style": {
  10743. color: props.color,
  10744. background: props.background
  10745. },
  10746. "overlay": false,
  10747. "position": props.position,
  10748. "duration": 0.2,
  10749. "lockScroll": props.lockScroll,
  10750. "onUpdate:show": updateShow
  10751. }, {
  10752. default: () => [slots.default ? slots.default() : props.message]
  10753. });
  10754. }
  10755. });
  10756. let timer;
  10757. let instance;
  10758. const parseOptions = (message) => isObject(message) ? message : {
  10759. message
  10760. };
  10761. function initInstance() {
  10762. ({
  10763. instance
  10764. } = mountComponent({
  10765. setup() {
  10766. const {
  10767. state,
  10768. toggle
  10769. } = usePopupState();
  10770. return () => createVNode(stdin_default$t, mergeProps(state, {
  10771. "onUpdate:show": toggle
  10772. }), null);
  10773. }
  10774. }));
  10775. }
  10776. function Notify(options) {
  10777. if (!inBrowser) {
  10778. return;
  10779. }
  10780. if (!instance) {
  10781. initInstance();
  10782. }
  10783. options = extend({}, Notify.currentOptions, parseOptions(options));
  10784. instance.open(options);
  10785. clearTimeout(timer);
  10786. if (options.duration > 0) {
  10787. timer = window.setTimeout(Notify.clear, options.duration);
  10788. }
  10789. return instance;
  10790. }
  10791. const getDefaultOptions = () => ({
  10792. type: "danger",
  10793. color: void 0,
  10794. message: "",
  10795. onClose: void 0,
  10796. onClick: void 0,
  10797. onOpened: void 0,
  10798. duration: 3e3,
  10799. position: void 0,
  10800. className: "",
  10801. lockScroll: false,
  10802. background: void 0
  10803. });
  10804. Notify.clear = () => {
  10805. if (instance) {
  10806. instance.toggle(false);
  10807. }
  10808. };
  10809. Notify.currentOptions = getDefaultOptions();
  10810. Notify.setDefaultOptions = (options) => {
  10811. extend(Notify.currentOptions, options);
  10812. };
  10813. Notify.resetDefaultOptions = () => {
  10814. Notify.currentOptions = getDefaultOptions();
  10815. };
  10816. Notify.Component = withInstall(stdin_default$t);
  10817. Notify.install = (app) => {
  10818. app.use(Notify.Component);
  10819. app.config.globalProperties.$notify = Notify;
  10820. };
  10821. const [name$n, bem$n] = createNamespace("key");
  10822. const CollapseIcon = createVNode("svg", {
  10823. "class": bem$n("collapse-icon"),
  10824. "viewBox": "0 0 30 24"
  10825. }, [createVNode("path", {
  10826. "d": "M26 13h-2v2h2v-2zm-8-3h2V8h-2v2zm2-4h2V4h-2v2zm2 4h4V4h-2v4h-2v2zm-7 14 3-3h-6l3 3zM6 13H4v2h2v-2zm16 0H8v2h14v-2zm-12-3h2V8h-2v2zM28 0l1 1 1 1v15l-1 2H1l-1-2V2l1-1 1-1zm0 2H2v15h26V2zM6 4v2H4V4zm10 2h2V4h-2v2zM8 9v1H4V8zm8 0v1h-2V8zm-6-5v2H8V4zm4 0v2h-2V4z",
  10827. "fill": "currentColor"
  10828. }, null)]);
  10829. const DeleteIcon = createVNode("svg", {
  10830. "class": bem$n("delete-icon"),
  10831. "viewBox": "0 0 32 22"
  10832. }, [createVNode("path", {
  10833. "d": "M28 0a4 4 0 0 1 4 4v14a4 4 0 0 1-4 4H10.4a2 2 0 0 1-1.4-.6L1 13.1c-.6-.5-.9-1.3-.9-2 0-1 .3-1.7.9-2.2L9 .6a2 2 0 0 1 1.4-.6zm0 2H10.4l-8.2 8.3a1 1 0 0 0-.3.7c0 .3.1.5.3.7l8.2 8.4H28a2 2 0 0 0 2-2V4c0-1.1-.9-2-2-2zm-5 4a1 1 0 0 1 .7.3 1 1 0 0 1 0 1.4L20.4 11l3.3 3.3c.2.2.3.5.3.7 0 .3-.1.5-.3.7a1 1 0 0 1-.7.3 1 1 0 0 1-.7-.3L19 12.4l-3.4 3.3a1 1 0 0 1-.6.3 1 1 0 0 1-.7-.3 1 1 0 0 1-.3-.7c0-.2.1-.5.3-.7l3.3-3.3-3.3-3.3A1 1 0 0 1 14 7c0-.3.1-.5.3-.7A1 1 0 0 1 15 6a1 1 0 0 1 .6.3L19 9.6l3.3-3.3A1 1 0 0 1 23 6z",
  10834. "fill": "currentColor"
  10835. }, null)]);
  10836. var stdin_default$s = defineComponent({
  10837. name: name$n,
  10838. props: {
  10839. type: String,
  10840. text: numericProp,
  10841. color: String,
  10842. wider: Boolean,
  10843. large: Boolean,
  10844. loading: Boolean
  10845. },
  10846. emits: ["press"],
  10847. setup(props, {
  10848. emit,
  10849. slots
  10850. }) {
  10851. const active = ref(false);
  10852. const touch = useTouch();
  10853. const onTouchStart = (event) => {
  10854. touch.start(event);
  10855. active.value = true;
  10856. };
  10857. const onTouchMove = (event) => {
  10858. touch.move(event);
  10859. if (touch.direction.value) {
  10860. active.value = false;
  10861. }
  10862. };
  10863. const onTouchEnd = (event) => {
  10864. if (active.value) {
  10865. if (!slots.default) {
  10866. preventDefault(event);
  10867. }
  10868. active.value = false;
  10869. emit("press", props.text, props.type);
  10870. }
  10871. };
  10872. const renderContent = () => {
  10873. if (props.loading) {
  10874. return createVNode(Loading, {
  10875. "class": bem$n("loading-icon")
  10876. }, null);
  10877. }
  10878. const text = slots.default ? slots.default() : props.text;
  10879. switch (props.type) {
  10880. case "delete":
  10881. return text || DeleteIcon;
  10882. case "extra":
  10883. return text || CollapseIcon;
  10884. default:
  10885. return text;
  10886. }
  10887. };
  10888. return () => createVNode("div", {
  10889. "class": bem$n("wrapper", {
  10890. wider: props.wider
  10891. }),
  10892. "onTouchstartPassive": onTouchStart,
  10893. "onTouchmovePassive": onTouchMove,
  10894. "onTouchend": onTouchEnd,
  10895. "onTouchcancel": onTouchEnd
  10896. }, [createVNode("div", {
  10897. "role": "button",
  10898. "tabindex": 0,
  10899. "class": bem$n([props.color, {
  10900. large: props.large,
  10901. active: active.value,
  10902. delete: props.type === "delete"
  10903. }])
  10904. }, [renderContent()])]);
  10905. }
  10906. });
  10907. const [name$m, bem$m] = createNamespace("number-keyboard");
  10908. const numberKeyboardProps = {
  10909. show: Boolean,
  10910. title: String,
  10911. theme: makeStringProp("default"),
  10912. zIndex: numericProp,
  10913. teleport: [String, Object],
  10914. maxlength: makeNumericProp(Infinity),
  10915. modelValue: makeStringProp(""),
  10916. transition: truthProp,
  10917. blurOnClose: truthProp,
  10918. showDeleteKey: truthProp,
  10919. randomKeyOrder: Boolean,
  10920. closeButtonText: String,
  10921. deleteButtonText: String,
  10922. closeButtonLoading: Boolean,
  10923. hideOnClickOutside: truthProp,
  10924. safeAreaInsetBottom: truthProp,
  10925. extraKey: {
  10926. type: [String, Array],
  10927. default: ""
  10928. }
  10929. };
  10930. function shuffle(array) {
  10931. for (let i = array.length - 1; i > 0; i--) {
  10932. const j = Math.floor(Math.random() * (i + 1));
  10933. const temp = array[i];
  10934. array[i] = array[j];
  10935. array[j] = temp;
  10936. }
  10937. return array;
  10938. }
  10939. var stdin_default$r = defineComponent({
  10940. name: name$m,
  10941. inheritAttrs: false,
  10942. props: numberKeyboardProps,
  10943. emits: ["show", "hide", "blur", "input", "close", "delete", "update:modelValue"],
  10944. setup(props, {
  10945. emit,
  10946. slots,
  10947. attrs
  10948. }) {
  10949. const root = ref();
  10950. const genBasicKeys = () => {
  10951. const keys2 = Array(9).fill("").map((_, i) => ({
  10952. text: i + 1
  10953. }));
  10954. if (props.randomKeyOrder) {
  10955. shuffle(keys2);
  10956. }
  10957. return keys2;
  10958. };
  10959. const genDefaultKeys = () => [...genBasicKeys(), {
  10960. text: props.extraKey,
  10961. type: "extra"
  10962. }, {
  10963. text: 0
  10964. }, {
  10965. text: props.showDeleteKey ? props.deleteButtonText : "",
  10966. type: props.showDeleteKey ? "delete" : ""
  10967. }];
  10968. const genCustomKeys = () => {
  10969. const keys2 = genBasicKeys();
  10970. const {
  10971. extraKey
  10972. } = props;
  10973. const extraKeys = Array.isArray(extraKey) ? extraKey : [extraKey];
  10974. if (extraKeys.length === 1) {
  10975. keys2.push({
  10976. text: 0,
  10977. wider: true
  10978. }, {
  10979. text: extraKeys[0],
  10980. type: "extra"
  10981. });
  10982. } else if (extraKeys.length === 2) {
  10983. keys2.push({
  10984. text: extraKeys[0],
  10985. type: "extra"
  10986. }, {
  10987. text: 0
  10988. }, {
  10989. text: extraKeys[1],
  10990. type: "extra"
  10991. });
  10992. }
  10993. return keys2;
  10994. };
  10995. const keys = computed(() => props.theme === "custom" ? genCustomKeys() : genDefaultKeys());
  10996. const onBlur = () => {
  10997. if (props.show) {
  10998. emit("blur");
  10999. }
  11000. };
  11001. const onClose = () => {
  11002. emit("close");
  11003. if (props.blurOnClose) {
  11004. onBlur();
  11005. }
  11006. };
  11007. const onAnimationEnd = () => emit(props.show ? "show" : "hide");
  11008. const onPress = (text, type) => {
  11009. if (text === "") {
  11010. if (type === "extra") {
  11011. onBlur();
  11012. }
  11013. return;
  11014. }
  11015. const value = props.modelValue;
  11016. if (type === "delete") {
  11017. emit("delete");
  11018. emit("update:modelValue", value.slice(0, value.length - 1));
  11019. } else if (type === "close") {
  11020. onClose();
  11021. } else if (value.length < props.maxlength) {
  11022. emit("input", text);
  11023. emit("update:modelValue", value + text);
  11024. }
  11025. };
  11026. const renderTitle = () => {
  11027. const {
  11028. title,
  11029. theme,
  11030. closeButtonText
  11031. } = props;
  11032. const leftSlot = slots["title-left"];
  11033. const showClose = closeButtonText && theme === "default";
  11034. const showTitle = title || showClose || leftSlot;
  11035. if (!showTitle) {
  11036. return;
  11037. }
  11038. return createVNode("div", {
  11039. "class": bem$m("header")
  11040. }, [leftSlot && createVNode("span", {
  11041. "class": bem$m("title-left")
  11042. }, [leftSlot()]), title && createVNode("h2", {
  11043. "class": bem$m("title")
  11044. }, [title]), showClose && createVNode("button", {
  11045. "type": "button",
  11046. "class": [bem$m("close"), HAPTICS_FEEDBACK],
  11047. "onClick": onClose
  11048. }, [closeButtonText])]);
  11049. };
  11050. const renderKeys = () => keys.value.map((key) => {
  11051. const keySlots = {};
  11052. if (key.type === "delete") {
  11053. keySlots.default = slots.delete;
  11054. }
  11055. if (key.type === "extra") {
  11056. keySlots.default = slots["extra-key"];
  11057. }
  11058. return createVNode(stdin_default$s, {
  11059. "key": key.text,
  11060. "text": key.text,
  11061. "type": key.type,
  11062. "wider": key.wider,
  11063. "color": key.color,
  11064. "onPress": onPress
  11065. }, keySlots);
  11066. });
  11067. const renderSidebar = () => {
  11068. if (props.theme === "custom") {
  11069. return createVNode("div", {
  11070. "class": bem$m("sidebar")
  11071. }, [props.showDeleteKey && createVNode(stdin_default$s, {
  11072. "large": true,
  11073. "text": props.deleteButtonText,
  11074. "type": "delete",
  11075. "onPress": onPress
  11076. }, {
  11077. delete: slots.delete
  11078. }), createVNode(stdin_default$s, {
  11079. "large": true,
  11080. "text": props.closeButtonText,
  11081. "type": "close",
  11082. "color": "blue",
  11083. "loading": props.closeButtonLoading,
  11084. "onPress": onPress
  11085. }, null)]);
  11086. }
  11087. };
  11088. watch(() => props.show, (value) => {
  11089. if (!props.transition) {
  11090. emit(value ? "show" : "hide");
  11091. }
  11092. });
  11093. if (props.hideOnClickOutside) {
  11094. useClickAway(root, onBlur, {
  11095. eventName: "touchstart"
  11096. });
  11097. }
  11098. return () => {
  11099. const Title = renderTitle();
  11100. const Content = createVNode(Transition, {
  11101. "name": props.transition ? "van-slide-up" : ""
  11102. }, {
  11103. default: () => [withDirectives(createVNode("div", mergeProps({
  11104. "ref": root,
  11105. "style": getZIndexStyle(props.zIndex),
  11106. "class": bem$m({
  11107. unfit: !props.safeAreaInsetBottom,
  11108. "with-title": !!Title
  11109. }),
  11110. "onAnimationend": onAnimationEnd,
  11111. "onTouchstartPassive": stopPropagation
  11112. }, attrs), [Title, createVNode("div", {
  11113. "class": bem$m("body")
  11114. }, [createVNode("div", {
  11115. "class": bem$m("keys")
  11116. }, [renderKeys()]), renderSidebar()])]), [[vShow, props.show]])]
  11117. });
  11118. if (props.teleport) {
  11119. return createVNode(Teleport, {
  11120. "to": props.teleport
  11121. }, {
  11122. default: () => [Content]
  11123. });
  11124. }
  11125. return Content;
  11126. };
  11127. }
  11128. });
  11129. const NumberKeyboard = withInstall(stdin_default$r);
  11130. const [name$l, bem$l, t$5] = createNamespace("pagination");
  11131. const makePage = (number, text, active) => ({
  11132. number,
  11133. text,
  11134. active
  11135. });
  11136. const paginationProps = {
  11137. mode: makeStringProp("multi"),
  11138. prevText: String,
  11139. nextText: String,
  11140. pageCount: makeNumericProp(0),
  11141. modelValue: makeNumberProp(0),
  11142. totalItems: makeNumericProp(0),
  11143. showPageSize: makeNumericProp(5),
  11144. itemsPerPage: makeNumericProp(10),
  11145. forceEllipses: Boolean
  11146. };
  11147. var stdin_default$q = defineComponent({
  11148. name: name$l,
  11149. props: paginationProps,
  11150. emits: ["change", "update:modelValue"],
  11151. setup(props, {
  11152. emit,
  11153. slots
  11154. }) {
  11155. const count = computed(() => {
  11156. const {
  11157. pageCount,
  11158. totalItems,
  11159. itemsPerPage
  11160. } = props;
  11161. const count2 = +pageCount || Math.ceil(+totalItems / +itemsPerPage);
  11162. return Math.max(1, count2);
  11163. });
  11164. const pages = computed(() => {
  11165. const items = [];
  11166. const pageCount = count.value;
  11167. const showPageSize = +props.showPageSize;
  11168. const {
  11169. modelValue,
  11170. forceEllipses
  11171. } = props;
  11172. let startPage = 1;
  11173. let endPage = pageCount;
  11174. const isMaxSized = showPageSize < pageCount;
  11175. if (isMaxSized) {
  11176. startPage = Math.max(modelValue - Math.floor(showPageSize / 2), 1);
  11177. endPage = startPage + showPageSize - 1;
  11178. if (endPage > pageCount) {
  11179. endPage = pageCount;
  11180. startPage = endPage - showPageSize + 1;
  11181. }
  11182. }
  11183. for (let number = startPage; number <= endPage; number++) {
  11184. const page = makePage(number, number, number === modelValue);
  11185. items.push(page);
  11186. }
  11187. if (isMaxSized && showPageSize > 0 && forceEllipses) {
  11188. if (startPage > 1) {
  11189. const prevPages = makePage(startPage - 1, "...");
  11190. items.unshift(prevPages);
  11191. }
  11192. if (endPage < pageCount) {
  11193. const nextPages = makePage(endPage + 1, "...");
  11194. items.push(nextPages);
  11195. }
  11196. }
  11197. return items;
  11198. });
  11199. const updateModelValue = (value, emitChange) => {
  11200. value = clamp(value, 1, count.value);
  11201. if (props.modelValue !== value) {
  11202. emit("update:modelValue", value);
  11203. if (emitChange) {
  11204. emit("change", value);
  11205. }
  11206. }
  11207. };
  11208. watchEffect(() => updateModelValue(props.modelValue));
  11209. const renderDesc = () => createVNode("li", {
  11210. "class": bem$l("page-desc")
  11211. }, [slots.pageDesc ? slots.pageDesc() : `${props.modelValue}/${count.value}`]);
  11212. const renderPrevButton = () => {
  11213. const {
  11214. mode,
  11215. modelValue
  11216. } = props;
  11217. const slot = slots["prev-text"];
  11218. const disabled = modelValue === 1;
  11219. return createVNode("li", {
  11220. "class": [bem$l("item", {
  11221. disabled,
  11222. border: mode === "simple",
  11223. prev: true
  11224. }), BORDER_SURROUND]
  11225. }, [createVNode("button", {
  11226. "type": "button",
  11227. "disabled": disabled,
  11228. "onClick": () => updateModelValue(modelValue - 1, true)
  11229. }, [slot ? slot() : props.prevText || t$5("prev")])]);
  11230. };
  11231. const renderNextButton = () => {
  11232. const {
  11233. mode,
  11234. modelValue
  11235. } = props;
  11236. const slot = slots["next-text"];
  11237. const disabled = modelValue === count.value;
  11238. return createVNode("li", {
  11239. "class": [bem$l("item", {
  11240. disabled,
  11241. border: mode === "simple",
  11242. next: true
  11243. }), BORDER_SURROUND]
  11244. }, [createVNode("button", {
  11245. "type": "button",
  11246. "disabled": disabled,
  11247. "onClick": () => updateModelValue(modelValue + 1, true)
  11248. }, [slot ? slot() : props.nextText || t$5("next")])]);
  11249. };
  11250. const renderPages = () => pages.value.map((page) => createVNode("li", {
  11251. "class": [bem$l("item", {
  11252. active: page.active,
  11253. page: true
  11254. }), BORDER_SURROUND]
  11255. }, [createVNode("button", {
  11256. "type": "button",
  11257. "aria-current": page.active || void 0,
  11258. "onClick": () => updateModelValue(page.number, true)
  11259. }, [slots.page ? slots.page(page) : page.text])]));
  11260. return () => createVNode("nav", {
  11261. "role": "navigation",
  11262. "class": bem$l()
  11263. }, [createVNode("ul", {
  11264. "class": bem$l("items")
  11265. }, [renderPrevButton(), props.mode === "simple" ? renderDesc() : renderPages(), renderNextButton()])]);
  11266. }
  11267. });
  11268. const Pagination = withInstall(stdin_default$q);
  11269. const [name$k, bem$k] = createNamespace("password-input");
  11270. const passwordInputProps = {
  11271. info: String,
  11272. mask: truthProp,
  11273. value: makeStringProp(""),
  11274. gutter: numericProp,
  11275. length: makeNumericProp(6),
  11276. focused: Boolean,
  11277. errorInfo: String
  11278. };
  11279. var stdin_default$p = defineComponent({
  11280. name: name$k,
  11281. props: passwordInputProps,
  11282. emits: ["focus"],
  11283. setup(props, {
  11284. emit
  11285. }) {
  11286. const onTouchStart = (event) => {
  11287. event.stopPropagation();
  11288. emit("focus", event);
  11289. };
  11290. const renderPoints = () => {
  11291. const Points = [];
  11292. const {
  11293. mask,
  11294. value,
  11295. length,
  11296. gutter,
  11297. focused
  11298. } = props;
  11299. for (let i = 0; i < length; i++) {
  11300. const char = value[i];
  11301. const showBorder = i !== 0 && !gutter;
  11302. const showCursor = focused && i === value.length;
  11303. let style;
  11304. if (i !== 0 && gutter) {
  11305. style = {
  11306. marginLeft: addUnit(gutter)
  11307. };
  11308. }
  11309. Points.push(createVNode("li", {
  11310. "class": [{
  11311. [BORDER_LEFT]: showBorder
  11312. }, bem$k("item", {
  11313. focus: showCursor
  11314. })],
  11315. "style": style
  11316. }, [mask ? createVNode("i", {
  11317. "style": {
  11318. visibility: char ? "visible" : "hidden"
  11319. }
  11320. }, null) : char, showCursor && createVNode("div", {
  11321. "class": bem$k("cursor")
  11322. }, null)]));
  11323. }
  11324. return Points;
  11325. };
  11326. return () => {
  11327. const info = props.errorInfo || props.info;
  11328. return createVNode("div", {
  11329. "class": bem$k()
  11330. }, [createVNode("ul", {
  11331. "class": [bem$k("security"), {
  11332. [BORDER_SURROUND]: !props.gutter
  11333. }],
  11334. "onTouchstartPassive": onTouchStart
  11335. }, [renderPoints()]), info && createVNode("div", {
  11336. "class": bem$k(props.errorInfo ? "error-info" : "info")
  11337. }, [info])]);
  11338. };
  11339. }
  11340. });
  11341. const PasswordInput = withInstall(stdin_default$p);
  11342. const [name$j, bem$j] = createNamespace("popover");
  11343. const popupProps = ["show", "overlay", "duration", "teleport", "overlayStyle", "overlayClass", "closeOnClickOverlay"];
  11344. const popoverProps = {
  11345. show: Boolean,
  11346. theme: makeStringProp("light"),
  11347. overlay: Boolean,
  11348. actions: makeArrayProp(),
  11349. trigger: makeStringProp("click"),
  11350. duration: numericProp,
  11351. showArrow: truthProp,
  11352. placement: makeStringProp("bottom"),
  11353. iconPrefix: String,
  11354. overlayClass: unknownProp,
  11355. overlayStyle: Object,
  11356. closeOnClickAction: truthProp,
  11357. closeOnClickOverlay: truthProp,
  11358. closeOnClickOutside: truthProp,
  11359. offset: {
  11360. type: Array,
  11361. default: () => [0, 8]
  11362. },
  11363. teleport: {
  11364. type: [String, Object],
  11365. default: "body"
  11366. }
  11367. };
  11368. var stdin_default$o = defineComponent({
  11369. name: name$j,
  11370. props: popoverProps,
  11371. emits: ["select", "touchstart", "update:show"],
  11372. setup(props, {
  11373. emit,
  11374. slots,
  11375. attrs
  11376. }) {
  11377. let popper;
  11378. const popupRef = ref();
  11379. const wrapperRef = ref();
  11380. const popoverRef = ref();
  11381. const getPopoverOptions = () => ({
  11382. placement: props.placement,
  11383. modifiers: [{
  11384. name: "computeStyles",
  11385. options: {
  11386. adaptive: false,
  11387. gpuAcceleration: false
  11388. }
  11389. }, extend({}, offsetModifier, {
  11390. options: {
  11391. offset: props.offset
  11392. }
  11393. })]
  11394. });
  11395. const createPopperInstance = () => {
  11396. if (wrapperRef.value && popoverRef.value) {
  11397. return createPopper(wrapperRef.value, popoverRef.value.popupRef.value, getPopoverOptions());
  11398. }
  11399. return null;
  11400. };
  11401. const updateLocation = () => {
  11402. nextTick(() => {
  11403. if (!props.show) {
  11404. return;
  11405. }
  11406. if (!popper) {
  11407. popper = createPopperInstance();
  11408. } else {
  11409. popper.setOptions(getPopoverOptions());
  11410. }
  11411. });
  11412. };
  11413. const updateShow = (value) => emit("update:show", value);
  11414. const onClickWrapper = () => {
  11415. if (props.trigger === "click") {
  11416. updateShow(!props.show);
  11417. }
  11418. };
  11419. const onClickAction = (action, index) => {
  11420. if (action.disabled) {
  11421. return;
  11422. }
  11423. emit("select", action, index);
  11424. if (props.closeOnClickAction) {
  11425. updateShow(false);
  11426. }
  11427. };
  11428. const onClickAway = () => {
  11429. if (props.show && props.closeOnClickOutside && (!props.overlay || props.closeOnClickOverlay)) {
  11430. updateShow(false);
  11431. }
  11432. };
  11433. const renderActionContent = (action, index) => {
  11434. if (slots.action) {
  11435. return slots.action({
  11436. action,
  11437. index
  11438. });
  11439. }
  11440. return [action.icon && createVNode(Icon, {
  11441. "name": action.icon,
  11442. "classPrefix": props.iconPrefix,
  11443. "class": bem$j("action-icon")
  11444. }, null), createVNode("div", {
  11445. "class": [bem$j("action-text"), BORDER_BOTTOM]
  11446. }, [action.text])];
  11447. };
  11448. const renderAction = (action, index) => {
  11449. const {
  11450. icon,
  11451. color,
  11452. disabled,
  11453. className
  11454. } = action;
  11455. return createVNode("div", {
  11456. "role": "menuitem",
  11457. "class": [bem$j("action", {
  11458. disabled,
  11459. "with-icon": icon
  11460. }), className],
  11461. "style": {
  11462. color
  11463. },
  11464. "tabindex": disabled ? void 0 : 0,
  11465. "aria-disabled": disabled || void 0,
  11466. "onClick": () => onClickAction(action, index)
  11467. }, [renderActionContent(action, index)]);
  11468. };
  11469. onMounted(() => {
  11470. updateLocation();
  11471. watchEffect(() => {
  11472. var _a;
  11473. popupRef.value = (_a = popoverRef.value) == null ? void 0 : _a.popupRef.value;
  11474. });
  11475. });
  11476. onBeforeUnmount(() => {
  11477. if (popper) {
  11478. popper.destroy();
  11479. popper = null;
  11480. }
  11481. });
  11482. watch(() => [props.show, props.offset, props.placement], updateLocation);
  11483. useClickAway([wrapperRef, popupRef], onClickAway, {
  11484. eventName: "touchstart"
  11485. });
  11486. return () => {
  11487. var _a;
  11488. return createVNode(Fragment, null, [createVNode("span", {
  11489. "ref": wrapperRef,
  11490. "class": bem$j("wrapper"),
  11491. "onClick": onClickWrapper
  11492. }, [(_a = slots.reference) == null ? void 0 : _a.call(slots)]), createVNode(Popup, mergeProps({
  11493. "ref": popoverRef,
  11494. "class": bem$j([props.theme]),
  11495. "position": "",
  11496. "transition": "van-popover-zoom",
  11497. "lockScroll": false,
  11498. "onUpdate:show": updateShow
  11499. }, attrs, pick(props, popupProps)), {
  11500. default: () => [props.showArrow && createVNode("div", {
  11501. "class": bem$j("arrow")
  11502. }, null), createVNode("div", {
  11503. "role": "menu",
  11504. "class": bem$j("content")
  11505. }, [slots.default ? slots.default() : props.actions.map(renderAction)])]
  11506. })]);
  11507. };
  11508. }
  11509. });
  11510. const Popover = withInstall(stdin_default$o);
  11511. const [name$i, bem$i] = createNamespace("progress");
  11512. const progressProps = {
  11513. color: String,
  11514. inactive: Boolean,
  11515. pivotText: String,
  11516. textColor: String,
  11517. showPivot: truthProp,
  11518. pivotColor: String,
  11519. trackColor: String,
  11520. strokeWidth: numericProp,
  11521. percentage: {
  11522. type: numericProp,
  11523. default: 0,
  11524. validator: (value) => value >= 0 && value <= 100
  11525. }
  11526. };
  11527. var stdin_default$n = defineComponent({
  11528. name: name$i,
  11529. props: progressProps,
  11530. setup(props) {
  11531. const background = computed(() => props.inactive ? void 0 : props.color);
  11532. const renderPivot = () => {
  11533. const {
  11534. textColor,
  11535. pivotText,
  11536. pivotColor,
  11537. percentage
  11538. } = props;
  11539. const text = pivotText != null ? pivotText : `${percentage}%`;
  11540. if (props.showPivot && text) {
  11541. const style = {
  11542. color: textColor,
  11543. left: `${+percentage}%`,
  11544. transform: `translate(-${+percentage}%,-50%)`,
  11545. background: pivotColor || background.value
  11546. };
  11547. return createVNode("span", {
  11548. "style": style,
  11549. "class": bem$i("pivot", {
  11550. inactive: props.inactive
  11551. })
  11552. }, [text]);
  11553. }
  11554. };
  11555. return () => {
  11556. const {
  11557. trackColor,
  11558. percentage,
  11559. strokeWidth
  11560. } = props;
  11561. const rootStyle = {
  11562. background: trackColor,
  11563. height: addUnit(strokeWidth)
  11564. };
  11565. const portionStyle = {
  11566. width: `${percentage}%`,
  11567. background: background.value
  11568. };
  11569. return createVNode("div", {
  11570. "class": bem$i(),
  11571. "style": rootStyle
  11572. }, [createVNode("span", {
  11573. "class": bem$i("portion", {
  11574. inactive: props.inactive
  11575. }),
  11576. "style": portionStyle
  11577. }, null), renderPivot()]);
  11578. };
  11579. }
  11580. });
  11581. const Progress = withInstall(stdin_default$n);
  11582. const [name$h, bem$h, t$4] = createNamespace("pull-refresh");
  11583. const DEFAULT_HEAD_HEIGHT = 50;
  11584. const TEXT_STATUS = ["pulling", "loosing", "success"];
  11585. const pullRefreshProps = {
  11586. disabled: Boolean,
  11587. modelValue: Boolean,
  11588. headHeight: makeNumericProp(DEFAULT_HEAD_HEIGHT),
  11589. successText: String,
  11590. pullingText: String,
  11591. loosingText: String,
  11592. loadingText: String,
  11593. pullDistance: numericProp,
  11594. successDuration: makeNumericProp(500),
  11595. animationDuration: makeNumericProp(300)
  11596. };
  11597. var stdin_default$m = defineComponent({
  11598. name: name$h,
  11599. props: pullRefreshProps,
  11600. emits: ["change", "refresh", "update:modelValue"],
  11601. setup(props, {
  11602. emit,
  11603. slots
  11604. }) {
  11605. let reachTop;
  11606. const root = ref();
  11607. const track = ref();
  11608. const scrollParent = useScrollParent(root);
  11609. const state = reactive({
  11610. status: "normal",
  11611. distance: 0,
  11612. duration: 0
  11613. });
  11614. const touch = useTouch();
  11615. const getHeadStyle = () => {
  11616. if (props.headHeight !== DEFAULT_HEAD_HEIGHT) {
  11617. return {
  11618. height: `${props.headHeight}px`
  11619. };
  11620. }
  11621. };
  11622. const isTouchable = () => state.status !== "loading" && state.status !== "success" && !props.disabled;
  11623. const ease = (distance) => {
  11624. const pullDistance = +(props.pullDistance || props.headHeight);
  11625. if (distance > pullDistance) {
  11626. if (distance < pullDistance * 2) {
  11627. distance = pullDistance + (distance - pullDistance) / 2;
  11628. } else {
  11629. distance = pullDistance * 1.5 + (distance - pullDistance * 2) / 4;
  11630. }
  11631. }
  11632. return Math.round(distance);
  11633. };
  11634. const setStatus = (distance, isLoading) => {
  11635. const pullDistance = +(props.pullDistance || props.headHeight);
  11636. state.distance = distance;
  11637. if (isLoading) {
  11638. state.status = "loading";
  11639. } else if (distance === 0) {
  11640. state.status = "normal";
  11641. } else if (distance < pullDistance) {
  11642. state.status = "pulling";
  11643. } else {
  11644. state.status = "loosing";
  11645. }
  11646. emit("change", {
  11647. status: state.status,
  11648. distance
  11649. });
  11650. };
  11651. const getStatusText = () => {
  11652. const {
  11653. status
  11654. } = state;
  11655. if (status === "normal") {
  11656. return "";
  11657. }
  11658. return props[`${status}Text`] || t$4(status);
  11659. };
  11660. const renderStatus = () => {
  11661. const {
  11662. status,
  11663. distance
  11664. } = state;
  11665. if (slots[status]) {
  11666. return slots[status]({
  11667. distance
  11668. });
  11669. }
  11670. const nodes = [];
  11671. if (TEXT_STATUS.includes(status)) {
  11672. nodes.push(createVNode("div", {
  11673. "class": bem$h("text")
  11674. }, [getStatusText()]));
  11675. }
  11676. if (status === "loading") {
  11677. nodes.push(createVNode(Loading, {
  11678. "class": bem$h("loading")
  11679. }, {
  11680. default: getStatusText
  11681. }));
  11682. }
  11683. return nodes;
  11684. };
  11685. const showSuccessTip = () => {
  11686. state.status = "success";
  11687. setTimeout(() => {
  11688. setStatus(0);
  11689. }, +props.successDuration);
  11690. };
  11691. const checkPosition = (event) => {
  11692. reachTop = getScrollTop(scrollParent.value) === 0;
  11693. if (reachTop) {
  11694. state.duration = 0;
  11695. touch.start(event);
  11696. }
  11697. };
  11698. const onTouchStart = (event) => {
  11699. if (isTouchable()) {
  11700. checkPosition(event);
  11701. }
  11702. };
  11703. const onTouchMove = (event) => {
  11704. if (isTouchable()) {
  11705. if (!reachTop) {
  11706. checkPosition(event);
  11707. }
  11708. const {
  11709. deltaY
  11710. } = touch;
  11711. touch.move(event);
  11712. if (reachTop && deltaY.value >= 0 && touch.isVertical()) {
  11713. preventDefault(event);
  11714. setStatus(ease(deltaY.value));
  11715. }
  11716. }
  11717. };
  11718. const onTouchEnd = () => {
  11719. if (reachTop && touch.deltaY.value && isTouchable()) {
  11720. state.duration = +props.animationDuration;
  11721. if (state.status === "loosing") {
  11722. setStatus(+props.headHeight, true);
  11723. emit("update:modelValue", true);
  11724. nextTick(() => emit("refresh"));
  11725. } else {
  11726. setStatus(0);
  11727. }
  11728. }
  11729. };
  11730. watch(() => props.modelValue, (value) => {
  11731. state.duration = +props.animationDuration;
  11732. if (value) {
  11733. setStatus(+props.headHeight, true);
  11734. } else if (slots.success || props.successText) {
  11735. showSuccessTip();
  11736. } else {
  11737. setStatus(0, false);
  11738. }
  11739. });
  11740. useEventListener("touchmove", onTouchMove, {
  11741. target: track
  11742. });
  11743. return () => {
  11744. var _a;
  11745. const trackStyle = {
  11746. transitionDuration: `${state.duration}ms`,
  11747. transform: state.distance ? `translate3d(0,${state.distance}px, 0)` : ""
  11748. };
  11749. return createVNode("div", {
  11750. "ref": root,
  11751. "class": bem$h()
  11752. }, [createVNode("div", {
  11753. "ref": track,
  11754. "class": bem$h("track"),
  11755. "style": trackStyle,
  11756. "onTouchstartPassive": onTouchStart,
  11757. "onTouchend": onTouchEnd,
  11758. "onTouchcancel": onTouchEnd
  11759. }, [createVNode("div", {
  11760. "class": bem$h("head"),
  11761. "style": getHeadStyle()
  11762. }, [renderStatus()]), (_a = slots.default) == null ? void 0 : _a.call(slots)])]);
  11763. };
  11764. }
  11765. });
  11766. const PullRefresh = withInstall(stdin_default$m);
  11767. const [name$g, bem$g] = createNamespace("rate");
  11768. function getRateStatus(value, index, allowHalf, readonly) {
  11769. if (value >= index) {
  11770. return {
  11771. status: "full",
  11772. value: 1
  11773. };
  11774. }
  11775. if (value + 0.5 >= index && allowHalf && !readonly) {
  11776. return {
  11777. status: "half",
  11778. value: 0.5
  11779. };
  11780. }
  11781. if (value + 1 >= index && allowHalf && readonly) {
  11782. const cardinal = 10 ** 10;
  11783. return {
  11784. status: "half",
  11785. value: Math.round((value - index + 1) * cardinal) / cardinal
  11786. };
  11787. }
  11788. return {
  11789. status: "void",
  11790. value: 0
  11791. };
  11792. }
  11793. const rateProps = {
  11794. size: numericProp,
  11795. icon: makeStringProp("star"),
  11796. color: String,
  11797. count: makeNumericProp(5),
  11798. gutter: numericProp,
  11799. readonly: Boolean,
  11800. disabled: Boolean,
  11801. voidIcon: makeStringProp("star-o"),
  11802. allowHalf: Boolean,
  11803. voidColor: String,
  11804. touchable: truthProp,
  11805. iconPrefix: String,
  11806. modelValue: makeNumberProp(0),
  11807. disabledColor: String
  11808. };
  11809. var stdin_default$l = defineComponent({
  11810. name: name$g,
  11811. props: rateProps,
  11812. emits: ["change", "update:modelValue"],
  11813. setup(props, {
  11814. emit
  11815. }) {
  11816. const touch = useTouch();
  11817. const [itemRefs, setItemRefs] = useRefs();
  11818. const groupRef = ref();
  11819. const untouchable = () => props.readonly || props.disabled || !props.touchable;
  11820. const list = computed(() => Array(+props.count).fill("").map((_, i) => getRateStatus(props.modelValue, i + 1, props.allowHalf, props.readonly)));
  11821. let ranges;
  11822. let groupRefRect;
  11823. let minRectTop = Number.MAX_SAFE_INTEGER;
  11824. let maxRectTop = Number.MIN_SAFE_INTEGER;
  11825. const updateRanges = () => {
  11826. groupRefRect = useRect(groupRef);
  11827. const rects = itemRefs.value.map(useRect);
  11828. ranges = [];
  11829. rects.forEach((rect, index) => {
  11830. minRectTop = Math.min(rect.top, minRectTop);
  11831. maxRectTop = Math.max(rect.top, maxRectTop);
  11832. if (props.allowHalf) {
  11833. ranges.push({
  11834. score: index + 0.5,
  11835. left: rect.left,
  11836. top: rect.top,
  11837. height: rect.height
  11838. }, {
  11839. score: index + 1,
  11840. left: rect.left + rect.width / 2,
  11841. top: rect.top,
  11842. height: rect.height
  11843. });
  11844. } else {
  11845. ranges.push({
  11846. score: index + 1,
  11847. left: rect.left,
  11848. top: rect.top,
  11849. height: rect.height
  11850. });
  11851. }
  11852. });
  11853. };
  11854. const getScoreByPosition = (x, y) => {
  11855. for (let i = ranges.length - 1; i > 0; i--) {
  11856. if (y >= groupRefRect.top && y <= groupRefRect.bottom) {
  11857. if (x > ranges[i].left && y >= ranges[i].top && y <= ranges[i].top + ranges[i].height) {
  11858. return ranges[i].score;
  11859. }
  11860. } else {
  11861. const curTop = y < groupRefRect.top ? minRectTop : maxRectTop;
  11862. if (x > ranges[i].left && ranges[i].top === curTop) {
  11863. return ranges[i].score;
  11864. }
  11865. }
  11866. }
  11867. return props.allowHalf ? 0.5 : 1;
  11868. };
  11869. const select = (index) => {
  11870. if (!props.disabled && !props.readonly && index !== props.modelValue) {
  11871. emit("update:modelValue", index);
  11872. emit("change", index);
  11873. }
  11874. };
  11875. const onTouchStart = (event) => {
  11876. if (untouchable()) {
  11877. return;
  11878. }
  11879. touch.start(event);
  11880. updateRanges();
  11881. };
  11882. const onTouchMove = (event) => {
  11883. if (untouchable()) {
  11884. return;
  11885. }
  11886. touch.move(event);
  11887. if (touch.isHorizontal()) {
  11888. const {
  11889. clientX,
  11890. clientY
  11891. } = event.touches[0];
  11892. preventDefault(event);
  11893. select(getScoreByPosition(clientX, clientY));
  11894. }
  11895. };
  11896. const renderStar = (item, index) => {
  11897. const {
  11898. icon,
  11899. size,
  11900. color,
  11901. count,
  11902. gutter,
  11903. voidIcon,
  11904. disabled,
  11905. voidColor,
  11906. allowHalf,
  11907. iconPrefix,
  11908. disabledColor
  11909. } = props;
  11910. const score = index + 1;
  11911. const isFull = item.status === "full";
  11912. const isVoid = item.status === "void";
  11913. const renderHalf = allowHalf && item.value > 0 && item.value < 1;
  11914. let style;
  11915. if (gutter && score !== +count) {
  11916. style = {
  11917. paddingRight: addUnit(gutter)
  11918. };
  11919. }
  11920. const onClickItem = (event) => {
  11921. updateRanges();
  11922. select(allowHalf ? getScoreByPosition(event.clientX, event.clientY) : score);
  11923. };
  11924. return createVNode("div", {
  11925. "key": index,
  11926. "ref": setItemRefs(index),
  11927. "role": "radio",
  11928. "style": style,
  11929. "class": bem$g("item"),
  11930. "tabindex": disabled ? void 0 : 0,
  11931. "aria-setsize": count,
  11932. "aria-posinset": score,
  11933. "aria-checked": !isVoid,
  11934. "onClick": onClickItem
  11935. }, [createVNode(Icon, {
  11936. "size": size,
  11937. "name": isFull ? icon : voidIcon,
  11938. "class": bem$g("icon", {
  11939. disabled,
  11940. full: isFull
  11941. }),
  11942. "color": disabled ? disabledColor : isFull ? color : voidColor,
  11943. "classPrefix": iconPrefix
  11944. }, null), renderHalf && createVNode(Icon, {
  11945. "size": size,
  11946. "style": {
  11947. width: item.value + "em"
  11948. },
  11949. "name": isVoid ? voidIcon : icon,
  11950. "class": bem$g("icon", ["half", {
  11951. disabled,
  11952. full: !isVoid
  11953. }]),
  11954. "color": disabled ? disabledColor : isVoid ? voidColor : color,
  11955. "classPrefix": iconPrefix
  11956. }, null)]);
  11957. };
  11958. useCustomFieldValue(() => props.modelValue);
  11959. useEventListener("touchmove", onTouchMove, {
  11960. target: groupRef
  11961. });
  11962. return () => createVNode("div", {
  11963. "ref": groupRef,
  11964. "role": "radiogroup",
  11965. "class": bem$g({
  11966. readonly: props.readonly,
  11967. disabled: props.disabled
  11968. }),
  11969. "tabindex": props.disabled ? void 0 : 0,
  11970. "aria-disabled": props.disabled,
  11971. "aria-readonly": props.readonly,
  11972. "onTouchstartPassive": onTouchStart
  11973. }, [list.value.map(renderStar)]);
  11974. }
  11975. });
  11976. const Rate = withInstall(stdin_default$l);
  11977. const Row = withInstall(stdin_default$V);
  11978. const [name$f, bem$f, t$3] = createNamespace("search");
  11979. const searchProps = extend({}, fieldSharedProps, {
  11980. label: String,
  11981. shape: makeStringProp("square"),
  11982. leftIcon: makeStringProp("search"),
  11983. clearable: truthProp,
  11984. actionText: String,
  11985. background: String,
  11986. showAction: Boolean
  11987. });
  11988. var stdin_default$k = defineComponent({
  11989. name: name$f,
  11990. props: searchProps,
  11991. emits: ["blur", "focus", "clear", "search", "cancel", "click-input", "click-left-icon", "click-right-icon", "update:modelValue"],
  11992. setup(props, {
  11993. emit,
  11994. slots,
  11995. attrs
  11996. }) {
  11997. const id = useId();
  11998. const filedRef = ref();
  11999. const onCancel = () => {
  12000. if (!slots.action) {
  12001. emit("update:modelValue", "");
  12002. emit("cancel");
  12003. }
  12004. };
  12005. const onKeypress = (event) => {
  12006. const ENTER_CODE = 13;
  12007. if (event.keyCode === ENTER_CODE) {
  12008. preventDefault(event);
  12009. emit("search", props.modelValue);
  12010. }
  12011. };
  12012. const getInputId = () => props.id || `${id}-input`;
  12013. const renderLabel = () => {
  12014. if (slots.label || props.label) {
  12015. return createVNode("label", {
  12016. "class": bem$f("label"),
  12017. "for": getInputId()
  12018. }, [slots.label ? slots.label() : props.label]);
  12019. }
  12020. };
  12021. const renderAction = () => {
  12022. if (props.showAction) {
  12023. const text = props.actionText || t$3("cancel");
  12024. return createVNode("div", {
  12025. "class": bem$f("action"),
  12026. "role": "button",
  12027. "tabindex": 0,
  12028. "onClick": onCancel
  12029. }, [slots.action ? slots.action() : text]);
  12030. }
  12031. };
  12032. const blur = () => {
  12033. var _a;
  12034. return (_a = filedRef.value) == null ? void 0 : _a.blur();
  12035. };
  12036. const focus = () => {
  12037. var _a;
  12038. return (_a = filedRef.value) == null ? void 0 : _a.focus();
  12039. };
  12040. const onBlur = (event) => emit("blur", event);
  12041. const onFocus = (event) => emit("focus", event);
  12042. const onClear = (event) => emit("clear", event);
  12043. const onClickInput = (event) => emit("click-input", event);
  12044. const onClickLeftIcon = (event) => emit("click-left-icon", event);
  12045. const onClickRightIcon = (event) => emit("click-right-icon", event);
  12046. const fieldPropNames = Object.keys(fieldSharedProps);
  12047. const renderField = () => {
  12048. const fieldAttrs = extend({}, attrs, pick(props, fieldPropNames), {
  12049. id: getInputId()
  12050. });
  12051. const onInput = (value) => emit("update:modelValue", value);
  12052. return createVNode(Field, mergeProps({
  12053. "ref": filedRef,
  12054. "type": "search",
  12055. "class": bem$f("field"),
  12056. "border": false,
  12057. "onBlur": onBlur,
  12058. "onFocus": onFocus,
  12059. "onClear": onClear,
  12060. "onKeypress": onKeypress,
  12061. "onClick-input": onClickInput,
  12062. "onClick-left-icon": onClickLeftIcon,
  12063. "onClick-right-icon": onClickRightIcon,
  12064. "onUpdate:modelValue": onInput
  12065. }, fieldAttrs), pick(slots, ["left-icon", "right-icon"]));
  12066. };
  12067. useExpose({
  12068. focus,
  12069. blur
  12070. });
  12071. return () => {
  12072. var _a;
  12073. return createVNode("div", {
  12074. "class": bem$f({
  12075. "show-action": props.showAction
  12076. }),
  12077. "style": {
  12078. background: props.background
  12079. }
  12080. }, [(_a = slots.left) == null ? void 0 : _a.call(slots), createVNode("div", {
  12081. "class": bem$f("content", props.shape)
  12082. }, [renderLabel(), renderField()]), renderAction()]);
  12083. };
  12084. }
  12085. });
  12086. const Search = withInstall(stdin_default$k);
  12087. const popupInheritKeys = [...popupSharedPropKeys, "round", "closeOnPopstate", "safeAreaInsetBottom"];
  12088. const iconMap = {
  12089. qq: "qq",
  12090. link: "link-o",
  12091. weibo: "weibo",
  12092. qrcode: "qr",
  12093. poster: "photo-o",
  12094. wechat: "wechat",
  12095. "weapp-qrcode": "miniprogram-o",
  12096. "wechat-moments": "wechat-moments"
  12097. };
  12098. const [name$e, bem$e, t$2] = createNamespace("share-sheet");
  12099. const shareSheetProps = extend({}, popupSharedProps, {
  12100. title: String,
  12101. round: truthProp,
  12102. options: makeArrayProp(),
  12103. cancelText: String,
  12104. description: String,
  12105. closeOnPopstate: truthProp,
  12106. safeAreaInsetBottom: truthProp
  12107. });
  12108. var stdin_default$j = defineComponent({
  12109. name: name$e,
  12110. props: shareSheetProps,
  12111. emits: ["cancel", "select", "update:show"],
  12112. setup(props, {
  12113. emit,
  12114. slots
  12115. }) {
  12116. const updateShow = (value) => emit("update:show", value);
  12117. const onCancel = () => {
  12118. updateShow(false);
  12119. emit("cancel");
  12120. };
  12121. const onSelect = (option, index) => emit("select", option, index);
  12122. const renderHeader = () => {
  12123. const title = slots.title ? slots.title() : props.title;
  12124. const description = slots.description ? slots.description() : props.description;
  12125. if (title || description) {
  12126. return createVNode("div", {
  12127. "class": bem$e("header")
  12128. }, [title && createVNode("h2", {
  12129. "class": bem$e("title")
  12130. }, [title]), description && createVNode("span", {
  12131. "class": bem$e("description")
  12132. }, [description])]);
  12133. }
  12134. };
  12135. const renderIcon = (icon) => {
  12136. if (iconMap[icon]) {
  12137. return createVNode("div", {
  12138. "class": bem$e("icon", [icon])
  12139. }, [createVNode(Icon, {
  12140. "name": iconMap[icon] || icon
  12141. }, null)]);
  12142. }
  12143. return createVNode("img", {
  12144. "src": icon,
  12145. "class": bem$e("image-icon")
  12146. }, null);
  12147. };
  12148. const renderOption = (option, index) => {
  12149. const {
  12150. name: name2,
  12151. icon,
  12152. className,
  12153. description
  12154. } = option;
  12155. return createVNode("div", {
  12156. "role": "button",
  12157. "tabindex": 0,
  12158. "class": [bem$e("option"), className, HAPTICS_FEEDBACK],
  12159. "onClick": () => onSelect(option, index)
  12160. }, [renderIcon(icon), name2 && createVNode("span", {
  12161. "class": bem$e("name")
  12162. }, [name2]), description && createVNode("span", {
  12163. "class": bem$e("option-description")
  12164. }, [description])]);
  12165. };
  12166. const renderOptions = (options, border) => createVNode("div", {
  12167. "class": bem$e("options", {
  12168. border
  12169. })
  12170. }, [options.map(renderOption)]);
  12171. const renderRows = () => {
  12172. const {
  12173. options
  12174. } = props;
  12175. if (Array.isArray(options[0])) {
  12176. return options.map((item, index) => renderOptions(item, index !== 0));
  12177. }
  12178. return renderOptions(options);
  12179. };
  12180. const renderCancelButton = () => {
  12181. var _a;
  12182. const cancelText = (_a = props.cancelText) != null ? _a : t$2("cancel");
  12183. if (slots.cancel || cancelText) {
  12184. return createVNode("button", {
  12185. "type": "button",
  12186. "class": bem$e("cancel"),
  12187. "onClick": onCancel
  12188. }, [slots.cancel ? slots.cancel() : cancelText]);
  12189. }
  12190. };
  12191. return () => createVNode(Popup, mergeProps({
  12192. "class": bem$e(),
  12193. "position": "bottom",
  12194. "onUpdate:show": updateShow
  12195. }, pick(props, popupInheritKeys)), {
  12196. default: () => [renderHeader(), renderRows(), renderCancelButton()]
  12197. });
  12198. }
  12199. });
  12200. const ShareSheet = withInstall(stdin_default$j);
  12201. const [name$d, bem$d] = createNamespace("sidebar");
  12202. const SIDEBAR_KEY = Symbol(name$d);
  12203. const sidebarProps = {
  12204. modelValue: makeNumericProp(0)
  12205. };
  12206. var stdin_default$i = defineComponent({
  12207. name: name$d,
  12208. props: sidebarProps,
  12209. emits: ["change", "update:modelValue"],
  12210. setup(props, {
  12211. emit,
  12212. slots
  12213. }) {
  12214. const {
  12215. linkChildren
  12216. } = useChildren(SIDEBAR_KEY);
  12217. const getActive = () => +props.modelValue;
  12218. const setActive = (value) => {
  12219. if (value !== getActive()) {
  12220. emit("update:modelValue", value);
  12221. emit("change", value);
  12222. }
  12223. };
  12224. linkChildren({
  12225. getActive,
  12226. setActive
  12227. });
  12228. return () => {
  12229. var _a;
  12230. return createVNode("div", {
  12231. "role": "tablist",
  12232. "class": bem$d()
  12233. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  12234. };
  12235. }
  12236. });
  12237. const Sidebar = withInstall(stdin_default$i);
  12238. const [name$c, bem$c] = createNamespace("sidebar-item");
  12239. const sidebarItemProps = extend({}, routeProps, {
  12240. dot: Boolean,
  12241. title: String,
  12242. badge: numericProp,
  12243. disabled: Boolean,
  12244. badgeProps: Object
  12245. });
  12246. var stdin_default$h = defineComponent({
  12247. name: name$c,
  12248. props: sidebarItemProps,
  12249. emits: ["click"],
  12250. setup(props, {
  12251. emit,
  12252. slots
  12253. }) {
  12254. const route2 = useRoute();
  12255. const {
  12256. parent,
  12257. index
  12258. } = useParent(SIDEBAR_KEY);
  12259. if (!parent) {
  12260. if (process.env.NODE_ENV !== "production") {
  12261. console.error("[Vant] <SidebarItem> must be a child component of <Sidebar>.");
  12262. }
  12263. return;
  12264. }
  12265. const onClick = () => {
  12266. if (props.disabled) {
  12267. return;
  12268. }
  12269. emit("click", index.value);
  12270. parent.setActive(index.value);
  12271. route2();
  12272. };
  12273. return () => {
  12274. const {
  12275. dot,
  12276. badge,
  12277. title,
  12278. disabled
  12279. } = props;
  12280. const selected = index.value === parent.getActive();
  12281. return createVNode("div", {
  12282. "role": "tab",
  12283. "class": bem$c({
  12284. select: selected,
  12285. disabled
  12286. }),
  12287. "tabindex": disabled ? void 0 : 0,
  12288. "aria-selected": selected,
  12289. "onClick": onClick
  12290. }, [createVNode(Badge, mergeProps({
  12291. "dot": dot,
  12292. "class": bem$c("text"),
  12293. "content": badge
  12294. }, props.badgeProps), {
  12295. default: () => [slots.title ? slots.title() : title]
  12296. })]);
  12297. };
  12298. }
  12299. });
  12300. const SidebarItem = withInstall(stdin_default$h);
  12301. const [name$b, bem$b] = createNamespace("skeleton");
  12302. const DEFAULT_ROW_WIDTH = "100%";
  12303. const DEFAULT_LAST_ROW_WIDTH = "60%";
  12304. const skeletonProps = {
  12305. row: makeNumericProp(0),
  12306. title: Boolean,
  12307. round: Boolean,
  12308. avatar: Boolean,
  12309. loading: truthProp,
  12310. animate: truthProp,
  12311. avatarSize: numericProp,
  12312. titleWidth: numericProp,
  12313. avatarShape: makeStringProp("round"),
  12314. rowWidth: {
  12315. type: [Number, String, Array],
  12316. default: DEFAULT_ROW_WIDTH
  12317. }
  12318. };
  12319. var stdin_default$g = defineComponent({
  12320. name: name$b,
  12321. inheritAttrs: false,
  12322. props: skeletonProps,
  12323. setup(props, {
  12324. slots,
  12325. attrs
  12326. }) {
  12327. const renderAvatar = () => {
  12328. if (props.avatar) {
  12329. return createVNode("div", {
  12330. "class": bem$b("avatar", props.avatarShape),
  12331. "style": getSizeStyle(props.avatarSize)
  12332. }, null);
  12333. }
  12334. };
  12335. const renderTitle = () => {
  12336. if (props.title) {
  12337. return createVNode("h3", {
  12338. "class": bem$b("title"),
  12339. "style": {
  12340. width: addUnit(props.titleWidth)
  12341. }
  12342. }, null);
  12343. }
  12344. };
  12345. const getRowWidth = (index) => {
  12346. const {
  12347. rowWidth
  12348. } = props;
  12349. if (rowWidth === DEFAULT_ROW_WIDTH && index === +props.row - 1) {
  12350. return DEFAULT_LAST_ROW_WIDTH;
  12351. }
  12352. if (Array.isArray(rowWidth)) {
  12353. return rowWidth[index];
  12354. }
  12355. return rowWidth;
  12356. };
  12357. const renderRows = () => Array(+props.row).fill("").map((_, i) => createVNode("div", {
  12358. "class": bem$b("row"),
  12359. "style": {
  12360. width: addUnit(getRowWidth(i))
  12361. }
  12362. }, null));
  12363. return () => {
  12364. var _a;
  12365. if (!props.loading) {
  12366. return (_a = slots.default) == null ? void 0 : _a.call(slots);
  12367. }
  12368. return createVNode("div", mergeProps({
  12369. "class": bem$b({
  12370. animate: props.animate,
  12371. round: props.round
  12372. })
  12373. }, attrs), [renderAvatar(), createVNode("div", {
  12374. "class": bem$b("content")
  12375. }, [renderTitle(), renderRows()])]);
  12376. };
  12377. }
  12378. });
  12379. const Skeleton = withInstall(stdin_default$g);
  12380. const [name$a, bem$a] = createNamespace("slider");
  12381. const sliderProps = {
  12382. min: makeNumericProp(0),
  12383. max: makeNumericProp(100),
  12384. step: makeNumericProp(1),
  12385. range: Boolean,
  12386. reverse: Boolean,
  12387. disabled: Boolean,
  12388. readonly: Boolean,
  12389. vertical: Boolean,
  12390. barHeight: numericProp,
  12391. buttonSize: numericProp,
  12392. activeColor: String,
  12393. inactiveColor: String,
  12394. modelValue: {
  12395. type: [Number, Array],
  12396. default: 0
  12397. }
  12398. };
  12399. var stdin_default$f = defineComponent({
  12400. name: name$a,
  12401. props: sliderProps,
  12402. emits: ["change", "drag-end", "drag-start", "update:modelValue"],
  12403. setup(props, {
  12404. emit,
  12405. slots
  12406. }) {
  12407. let buttonIndex;
  12408. let current2;
  12409. let startValue;
  12410. const root = ref();
  12411. const slider = ref();
  12412. const dragStatus = ref();
  12413. const touch = useTouch();
  12414. const scope = computed(() => Number(props.max) - Number(props.min));
  12415. const wrapperStyle = computed(() => {
  12416. const crossAxis = props.vertical ? "width" : "height";
  12417. return {
  12418. background: props.inactiveColor,
  12419. [crossAxis]: addUnit(props.barHeight)
  12420. };
  12421. });
  12422. const isRange = (val) => props.range && Array.isArray(val);
  12423. const calcMainAxis = () => {
  12424. const {
  12425. modelValue,
  12426. min
  12427. } = props;
  12428. if (isRange(modelValue)) {
  12429. return `${(modelValue[1] - modelValue[0]) * 100 / scope.value}%`;
  12430. }
  12431. return `${(modelValue - Number(min)) * 100 / scope.value}%`;
  12432. };
  12433. const calcOffset = () => {
  12434. const {
  12435. modelValue,
  12436. min
  12437. } = props;
  12438. if (isRange(modelValue)) {
  12439. return `${(modelValue[0] - Number(min)) * 100 / scope.value}%`;
  12440. }
  12441. return "0%";
  12442. };
  12443. const barStyle = computed(() => {
  12444. const mainAxis = props.vertical ? "height" : "width";
  12445. const style = {
  12446. [mainAxis]: calcMainAxis(),
  12447. background: props.activeColor
  12448. };
  12449. if (dragStatus.value) {
  12450. style.transition = "none";
  12451. }
  12452. const getPositionKey = () => {
  12453. if (props.vertical) {
  12454. return props.reverse ? "bottom" : "top";
  12455. }
  12456. return props.reverse ? "right" : "left";
  12457. };
  12458. style[getPositionKey()] = calcOffset();
  12459. return style;
  12460. });
  12461. const format2 = (value) => {
  12462. const min = +props.min;
  12463. const max = +props.max;
  12464. const step = +props.step;
  12465. value = clamp(value, min, max);
  12466. const diff = Math.round((value - min) / step) * step;
  12467. return addNumber(min, diff);
  12468. };
  12469. const isSameValue = (newValue, oldValue) => JSON.stringify(newValue) === JSON.stringify(oldValue);
  12470. const handleRangeValue = (value) => {
  12471. var _a, _b;
  12472. const left = (_a = value[0]) != null ? _a : Number(props.min);
  12473. const right = (_b = value[1]) != null ? _b : Number(props.max);
  12474. return left > right ? [right, left] : [left, right];
  12475. };
  12476. const updateValue = (value, end) => {
  12477. if (isRange(value)) {
  12478. value = handleRangeValue(value).map(format2);
  12479. } else {
  12480. value = format2(value);
  12481. }
  12482. if (!isSameValue(value, props.modelValue)) {
  12483. emit("update:modelValue", value);
  12484. }
  12485. if (end && !isSameValue(value, startValue)) {
  12486. emit("change", value);
  12487. }
  12488. };
  12489. const onClick = (event) => {
  12490. event.stopPropagation();
  12491. if (props.disabled || props.readonly) {
  12492. return;
  12493. }
  12494. const {
  12495. min,
  12496. reverse,
  12497. vertical,
  12498. modelValue
  12499. } = props;
  12500. const rect = useRect(root);
  12501. const getDelta = () => {
  12502. if (vertical) {
  12503. if (reverse) {
  12504. return rect.bottom - event.clientY;
  12505. }
  12506. return event.clientY - rect.top;
  12507. }
  12508. if (reverse) {
  12509. return rect.right - event.clientX;
  12510. }
  12511. return event.clientX - rect.left;
  12512. };
  12513. const total = vertical ? rect.height : rect.width;
  12514. const value = Number(min) + getDelta() / total * scope.value;
  12515. if (isRange(modelValue)) {
  12516. const [left, right] = modelValue;
  12517. const middle = (left + right) / 2;
  12518. if (value <= middle) {
  12519. updateValue([value, right], true);
  12520. } else {
  12521. updateValue([left, value], true);
  12522. }
  12523. } else {
  12524. updateValue(value, true);
  12525. }
  12526. };
  12527. const onTouchStart = (event) => {
  12528. if (props.disabled || props.readonly) {
  12529. return;
  12530. }
  12531. touch.start(event);
  12532. current2 = props.modelValue;
  12533. if (isRange(current2)) {
  12534. startValue = current2.map(format2);
  12535. } else {
  12536. startValue = format2(current2);
  12537. }
  12538. dragStatus.value = "start";
  12539. };
  12540. const onTouchMove = (event) => {
  12541. if (props.disabled || props.readonly) {
  12542. return;
  12543. }
  12544. if (dragStatus.value === "start") {
  12545. emit("drag-start", event);
  12546. }
  12547. preventDefault(event, true);
  12548. touch.move(event);
  12549. dragStatus.value = "dragging";
  12550. const rect = useRect(root);
  12551. const delta = props.vertical ? touch.deltaY.value : touch.deltaX.value;
  12552. const total = props.vertical ? rect.height : rect.width;
  12553. let diff = delta / total * scope.value;
  12554. if (props.reverse) {
  12555. diff = -diff;
  12556. }
  12557. if (isRange(startValue)) {
  12558. const index = props.reverse ? 1 - buttonIndex : buttonIndex;
  12559. current2[index] = startValue[index] + diff;
  12560. } else {
  12561. current2 = startValue + diff;
  12562. }
  12563. updateValue(current2);
  12564. };
  12565. const onTouchEnd = (event) => {
  12566. if (props.disabled || props.readonly) {
  12567. return;
  12568. }
  12569. if (dragStatus.value === "dragging") {
  12570. updateValue(current2, true);
  12571. emit("drag-end", event);
  12572. }
  12573. dragStatus.value = "";
  12574. };
  12575. const getButtonClassName = (index) => {
  12576. if (typeof index === "number") {
  12577. const position = ["left", "right"];
  12578. return bem$a(`button-wrapper`, position[index]);
  12579. }
  12580. return bem$a("button-wrapper", props.reverse ? "left" : "right");
  12581. };
  12582. const renderButtonContent = (value, index) => {
  12583. if (typeof index === "number") {
  12584. const slot = slots[index === 0 ? "left-button" : "right-button"];
  12585. if (slot) {
  12586. return slot({
  12587. value
  12588. });
  12589. }
  12590. }
  12591. if (slots.button) {
  12592. return slots.button({
  12593. value
  12594. });
  12595. }
  12596. return createVNode("div", {
  12597. "class": bem$a("button"),
  12598. "style": getSizeStyle(props.buttonSize)
  12599. }, null);
  12600. };
  12601. const renderButton = (index) => {
  12602. const current22 = typeof index === "number" ? props.modelValue[index] : props.modelValue;
  12603. return createVNode("div", {
  12604. "ref": slider,
  12605. "role": "slider",
  12606. "class": getButtonClassName(index),
  12607. "tabindex": props.disabled ? void 0 : 0,
  12608. "aria-valuemin": props.min,
  12609. "aria-valuenow": current22,
  12610. "aria-valuemax": props.max,
  12611. "aria-disabled": props.disabled || void 0,
  12612. "aria-readonly": props.readonly || void 0,
  12613. "aria-orientation": props.vertical ? "vertical" : "horizontal",
  12614. "onTouchstartPassive": (event) => {
  12615. if (typeof index === "number") {
  12616. buttonIndex = index;
  12617. }
  12618. onTouchStart(event);
  12619. },
  12620. "onTouchend": onTouchEnd,
  12621. "onTouchcancel": onTouchEnd,
  12622. "onClick": stopPropagation
  12623. }, [renderButtonContent(current22, index)]);
  12624. };
  12625. updateValue(props.modelValue);
  12626. useCustomFieldValue(() => props.modelValue);
  12627. useEventListener("touchmove", onTouchMove, {
  12628. target: slider
  12629. });
  12630. return () => createVNode("div", {
  12631. "ref": root,
  12632. "style": wrapperStyle.value,
  12633. "class": bem$a({
  12634. vertical: props.vertical,
  12635. disabled: props.disabled
  12636. }),
  12637. "onClick": onClick
  12638. }, [createVNode("div", {
  12639. "class": bem$a("bar"),
  12640. "style": barStyle.value
  12641. }, [props.range ? [renderButton(0), renderButton(1)] : renderButton()])]);
  12642. }
  12643. });
  12644. const Slider = withInstall(stdin_default$f);
  12645. const [name$9, bem$9] = createNamespace("space");
  12646. const spaceProps = {
  12647. align: String,
  12648. direction: {
  12649. type: String,
  12650. default: "horizontal"
  12651. },
  12652. size: {
  12653. type: [Number, String, Array],
  12654. default: 8
  12655. },
  12656. wrap: Boolean,
  12657. fill: Boolean
  12658. };
  12659. function filterEmpty(children = []) {
  12660. const nodes = [];
  12661. children.forEach((child) => {
  12662. if (Array.isArray(child)) {
  12663. nodes.push(...child);
  12664. } else if (child.type === Fragment) {
  12665. nodes.push(...filterEmpty(child.children));
  12666. } else {
  12667. nodes.push(child);
  12668. }
  12669. });
  12670. return nodes.filter((c) => {
  12671. var _a;
  12672. return !(c && (typeof Comment !== "undefined" && c.type === Comment || c.type === Fragment && ((_a = c.children) == null ? void 0 : _a.length) === 0 || c.type === Text && c.children.trim() === ""));
  12673. });
  12674. }
  12675. var stdin_default$e = defineComponent({
  12676. name: name$9,
  12677. props: spaceProps,
  12678. setup(props, {
  12679. slots
  12680. }) {
  12681. const mergedAlign = computed(() => {
  12682. var _a;
  12683. return (_a = props.align) != null ? _a : props.direction === "horizontal" ? "center" : "";
  12684. });
  12685. const getMargin = (size) => {
  12686. if (typeof size === "number") {
  12687. return size + "px";
  12688. }
  12689. return size;
  12690. };
  12691. const getMarginStyle = (isLast) => {
  12692. const style = {};
  12693. const marginRight = `${getMargin(Array.isArray(props.size) ? props.size[0] : props.size)}`;
  12694. const marginBottom = `${getMargin(Array.isArray(props.size) ? props.size[1] : props.size)}`;
  12695. if (isLast) {
  12696. return props.wrap ? {
  12697. marginBottom
  12698. } : {};
  12699. }
  12700. if (props.direction === "horizontal") {
  12701. style.marginRight = marginRight;
  12702. }
  12703. if (props.direction === "vertical" || props.wrap) {
  12704. style.marginBottom = marginBottom;
  12705. }
  12706. return style;
  12707. };
  12708. return () => {
  12709. var _a;
  12710. const children = filterEmpty((_a = slots.default) == null ? void 0 : _a.call(slots));
  12711. return createVNode("div", {
  12712. "class": [bem$9({
  12713. [props.direction]: props.direction,
  12714. [`align-${mergedAlign.value}`]: mergedAlign.value,
  12715. wrap: props.wrap,
  12716. fill: props.fill
  12717. })]
  12718. }, [children.map((c, i) => createVNode("div", {
  12719. "key": `item-${i}`,
  12720. "class": `${name$9}-item`,
  12721. "style": getMarginStyle(i === children.length - 1)
  12722. }, [c]))]);
  12723. };
  12724. }
  12725. });
  12726. const Space = withInstall(stdin_default$e);
  12727. const [name$8, bem$8] = createNamespace("steps");
  12728. const stepsProps = {
  12729. active: makeNumericProp(0),
  12730. direction: makeStringProp("horizontal"),
  12731. activeIcon: makeStringProp("checked"),
  12732. iconPrefix: String,
  12733. finishIcon: String,
  12734. activeColor: String,
  12735. inactiveIcon: String,
  12736. inactiveColor: String
  12737. };
  12738. const STEPS_KEY = Symbol(name$8);
  12739. var stdin_default$d = defineComponent({
  12740. name: name$8,
  12741. props: stepsProps,
  12742. emits: ["click-step"],
  12743. setup(props, {
  12744. emit,
  12745. slots
  12746. }) {
  12747. const {
  12748. linkChildren
  12749. } = useChildren(STEPS_KEY);
  12750. const onClickStep = (index) => emit("click-step", index);
  12751. linkChildren({
  12752. props,
  12753. onClickStep
  12754. });
  12755. return () => {
  12756. var _a;
  12757. return createVNode("div", {
  12758. "class": bem$8([props.direction])
  12759. }, [createVNode("div", {
  12760. "class": bem$8("items")
  12761. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)])]);
  12762. };
  12763. }
  12764. });
  12765. const [name$7, bem$7] = createNamespace("step");
  12766. var stdin_default$c = defineComponent({
  12767. name: name$7,
  12768. setup(props, {
  12769. slots
  12770. }) {
  12771. const {
  12772. parent,
  12773. index
  12774. } = useParent(STEPS_KEY);
  12775. if (!parent) {
  12776. if (process.env.NODE_ENV !== "production") {
  12777. console.error("[Vant] <Step> must be a child component of <Steps>.");
  12778. }
  12779. return;
  12780. }
  12781. const parentProps = parent.props;
  12782. const getStatus = () => {
  12783. const active = +parentProps.active;
  12784. if (index.value < active) {
  12785. return "finish";
  12786. }
  12787. return index.value === active ? "process" : "waiting";
  12788. };
  12789. const isActive = () => getStatus() === "process";
  12790. const lineStyle = computed(() => ({
  12791. background: getStatus() === "finish" ? parentProps.activeColor : parentProps.inactiveColor
  12792. }));
  12793. const titleStyle = computed(() => {
  12794. if (isActive()) {
  12795. return {
  12796. color: parentProps.activeColor
  12797. };
  12798. }
  12799. if (getStatus() === "waiting") {
  12800. return {
  12801. color: parentProps.inactiveColor
  12802. };
  12803. }
  12804. });
  12805. const onClickStep = () => parent.onClickStep(index.value);
  12806. const renderCircle = () => {
  12807. const {
  12808. iconPrefix,
  12809. finishIcon,
  12810. activeIcon,
  12811. activeColor,
  12812. inactiveIcon
  12813. } = parentProps;
  12814. if (isActive()) {
  12815. if (slots["active-icon"]) {
  12816. return slots["active-icon"]();
  12817. }
  12818. return createVNode(Icon, {
  12819. "class": bem$7("icon", "active"),
  12820. "name": activeIcon,
  12821. "color": activeColor,
  12822. "classPrefix": iconPrefix
  12823. }, null);
  12824. }
  12825. if (getStatus() === "finish" && (finishIcon || slots["finish-icon"])) {
  12826. if (slots["finish-icon"]) {
  12827. return slots["finish-icon"]();
  12828. }
  12829. return createVNode(Icon, {
  12830. "class": bem$7("icon", "finish"),
  12831. "name": finishIcon,
  12832. "color": activeColor,
  12833. "classPrefix": iconPrefix
  12834. }, null);
  12835. }
  12836. if (slots["inactive-icon"]) {
  12837. return slots["inactive-icon"]();
  12838. }
  12839. if (inactiveIcon) {
  12840. return createVNode(Icon, {
  12841. "class": bem$7("icon"),
  12842. "name": inactiveIcon,
  12843. "classPrefix": iconPrefix
  12844. }, null);
  12845. }
  12846. return createVNode("i", {
  12847. "class": bem$7("circle"),
  12848. "style": lineStyle.value
  12849. }, null);
  12850. };
  12851. return () => {
  12852. var _a;
  12853. const status = getStatus();
  12854. return createVNode("div", {
  12855. "class": [BORDER, bem$7([parentProps.direction, {
  12856. [status]: status
  12857. }])]
  12858. }, [createVNode("div", {
  12859. "class": bem$7("title", {
  12860. active: isActive()
  12861. }),
  12862. "style": titleStyle.value,
  12863. "onClick": onClickStep
  12864. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]), createVNode("div", {
  12865. "class": bem$7("circle-container"),
  12866. "onClick": onClickStep
  12867. }, [renderCircle()]), createVNode("div", {
  12868. "class": bem$7("line"),
  12869. "style": lineStyle.value
  12870. }, null)]);
  12871. };
  12872. }
  12873. });
  12874. const Step = withInstall(stdin_default$c);
  12875. const [name$6, bem$6] = createNamespace("stepper");
  12876. const LONG_PRESS_INTERVAL = 200;
  12877. const LONG_PRESS_START_TIME = 600;
  12878. const isEqual = (value1, value2) => String(value1) === String(value2);
  12879. const stepperProps = {
  12880. min: makeNumericProp(1),
  12881. max: makeNumericProp(Infinity),
  12882. name: makeNumericProp(""),
  12883. step: makeNumericProp(1),
  12884. theme: String,
  12885. integer: Boolean,
  12886. disabled: Boolean,
  12887. showPlus: truthProp,
  12888. showMinus: truthProp,
  12889. showInput: truthProp,
  12890. longPress: truthProp,
  12891. allowEmpty: Boolean,
  12892. modelValue: numericProp,
  12893. inputWidth: numericProp,
  12894. buttonSize: numericProp,
  12895. placeholder: String,
  12896. disablePlus: Boolean,
  12897. disableMinus: Boolean,
  12898. disableInput: Boolean,
  12899. beforeChange: Function,
  12900. defaultValue: makeNumericProp(1),
  12901. decimalLength: numericProp
  12902. };
  12903. var stdin_default$b = defineComponent({
  12904. name: name$6,
  12905. props: stepperProps,
  12906. emits: ["plus", "blur", "minus", "focus", "change", "overlimit", "update:modelValue"],
  12907. setup(props, {
  12908. emit
  12909. }) {
  12910. const format2 = (value) => {
  12911. const {
  12912. min,
  12913. max,
  12914. allowEmpty,
  12915. decimalLength
  12916. } = props;
  12917. if (allowEmpty && value === "") {
  12918. return value;
  12919. }
  12920. value = formatNumber(String(value), !props.integer);
  12921. value = value === "" ? 0 : +value;
  12922. value = Number.isNaN(value) ? +min : value;
  12923. value = Math.max(Math.min(+max, value), +min);
  12924. if (isDef(decimalLength)) {
  12925. value = value.toFixed(+decimalLength);
  12926. }
  12927. return value;
  12928. };
  12929. const getInitialValue = () => {
  12930. var _a;
  12931. const defaultValue = (_a = props.modelValue) != null ? _a : props.defaultValue;
  12932. const value = format2(defaultValue);
  12933. if (!isEqual(value, props.modelValue)) {
  12934. emit("update:modelValue", value);
  12935. }
  12936. return value;
  12937. };
  12938. let actionType;
  12939. const inputRef = ref();
  12940. const current2 = ref(getInitialValue());
  12941. const minusDisabled = computed(() => props.disabled || props.disableMinus || current2.value <= +props.min);
  12942. const plusDisabled = computed(() => props.disabled || props.disablePlus || current2.value >= +props.max);
  12943. const inputStyle = computed(() => ({
  12944. width: addUnit(props.inputWidth),
  12945. height: addUnit(props.buttonSize)
  12946. }));
  12947. const buttonStyle = computed(() => getSizeStyle(props.buttonSize));
  12948. const check = () => {
  12949. const value = format2(current2.value);
  12950. if (!isEqual(value, current2.value)) {
  12951. current2.value = value;
  12952. }
  12953. };
  12954. const setValue = (value) => {
  12955. if (props.beforeChange) {
  12956. callInterceptor(props.beforeChange, {
  12957. args: [value],
  12958. done() {
  12959. current2.value = value;
  12960. }
  12961. });
  12962. } else {
  12963. current2.value = value;
  12964. }
  12965. };
  12966. const onChange = () => {
  12967. if (actionType === "plus" && plusDisabled.value || actionType === "minus" && minusDisabled.value) {
  12968. emit("overlimit", actionType);
  12969. return;
  12970. }
  12971. const diff = actionType === "minus" ? -props.step : +props.step;
  12972. const value = format2(addNumber(+current2.value, diff));
  12973. setValue(value);
  12974. emit(actionType);
  12975. };
  12976. const onInput = (event) => {
  12977. const input = event.target;
  12978. const {
  12979. value
  12980. } = input;
  12981. const {
  12982. decimalLength
  12983. } = props;
  12984. let formatted = formatNumber(String(value), !props.integer);
  12985. if (isDef(decimalLength) && formatted.includes(".")) {
  12986. const pair = formatted.split(".");
  12987. formatted = `${pair[0]}.${pair[1].slice(0, +decimalLength)}`;
  12988. }
  12989. if (props.beforeChange) {
  12990. input.value = String(current2.value);
  12991. } else if (!isEqual(value, formatted)) {
  12992. input.value = formatted;
  12993. }
  12994. const isNumeric2 = formatted === String(+formatted);
  12995. setValue(isNumeric2 ? +formatted : formatted);
  12996. };
  12997. const onFocus = (event) => {
  12998. var _a;
  12999. if (props.disableInput) {
  13000. (_a = inputRef.value) == null ? void 0 : _a.blur();
  13001. } else {
  13002. emit("focus", event);
  13003. }
  13004. };
  13005. const onBlur = (event) => {
  13006. const input = event.target;
  13007. const value = format2(input.value);
  13008. input.value = String(value);
  13009. current2.value = value;
  13010. nextTick(() => {
  13011. emit("blur", event);
  13012. resetScroll();
  13013. });
  13014. };
  13015. let isLongPress;
  13016. let longPressTimer;
  13017. const longPressStep = () => {
  13018. longPressTimer = setTimeout(() => {
  13019. onChange();
  13020. longPressStep();
  13021. }, LONG_PRESS_INTERVAL);
  13022. };
  13023. const onTouchStart = () => {
  13024. if (props.longPress) {
  13025. isLongPress = false;
  13026. clearTimeout(longPressTimer);
  13027. longPressTimer = setTimeout(() => {
  13028. isLongPress = true;
  13029. onChange();
  13030. longPressStep();
  13031. }, LONG_PRESS_START_TIME);
  13032. }
  13033. };
  13034. const onTouchEnd = (event) => {
  13035. if (props.longPress) {
  13036. clearTimeout(longPressTimer);
  13037. if (isLongPress) {
  13038. preventDefault(event);
  13039. }
  13040. }
  13041. };
  13042. const onMousedown = (event) => {
  13043. if (props.disableInput) {
  13044. preventDefault(event);
  13045. }
  13046. };
  13047. const createListeners = (type) => ({
  13048. onClick: (event) => {
  13049. preventDefault(event);
  13050. actionType = type;
  13051. onChange();
  13052. },
  13053. onTouchstartPassive: () => {
  13054. actionType = type;
  13055. onTouchStart();
  13056. },
  13057. onTouchend: onTouchEnd,
  13058. onTouchcancel: onTouchEnd
  13059. });
  13060. watch(() => [props.max, props.min, props.integer, props.decimalLength], check);
  13061. watch(() => props.modelValue, (value) => {
  13062. if (!isEqual(value, current2.value)) {
  13063. current2.value = format2(value);
  13064. }
  13065. });
  13066. watch(current2, (value) => {
  13067. emit("update:modelValue", value);
  13068. emit("change", value, {
  13069. name: props.name
  13070. });
  13071. });
  13072. useCustomFieldValue(() => props.modelValue);
  13073. return () => createVNode("div", {
  13074. "role": "group",
  13075. "class": bem$6([props.theme])
  13076. }, [withDirectives(createVNode("button", mergeProps({
  13077. "type": "button",
  13078. "style": buttonStyle.value,
  13079. "class": [bem$6("minus", {
  13080. disabled: minusDisabled.value
  13081. }), {
  13082. [HAPTICS_FEEDBACK]: !minusDisabled.value
  13083. }],
  13084. "aria-disabled": minusDisabled.value || void 0
  13085. }, createListeners("minus")), null), [[vShow, props.showMinus]]), withDirectives(createVNode("input", {
  13086. "ref": inputRef,
  13087. "type": props.integer ? "tel" : "text",
  13088. "role": "spinbutton",
  13089. "class": bem$6("input"),
  13090. "value": current2.value,
  13091. "style": inputStyle.value,
  13092. "disabled": props.disabled,
  13093. "readonly": props.disableInput,
  13094. "inputmode": props.integer ? "numeric" : "decimal",
  13095. "placeholder": props.placeholder,
  13096. "aria-valuemax": props.max,
  13097. "aria-valuemin": props.min,
  13098. "aria-valuenow": current2.value,
  13099. "onBlur": onBlur,
  13100. "onInput": onInput,
  13101. "onFocus": onFocus,
  13102. "onMousedown": onMousedown
  13103. }, null), [[vShow, props.showInput]]), withDirectives(createVNode("button", mergeProps({
  13104. "type": "button",
  13105. "style": buttonStyle.value,
  13106. "class": [bem$6("plus", {
  13107. disabled: plusDisabled.value
  13108. }), {
  13109. [HAPTICS_FEEDBACK]: !plusDisabled.value
  13110. }],
  13111. "aria-disabled": plusDisabled.value || void 0
  13112. }, createListeners("plus")), null), [[vShow, props.showPlus]])]);
  13113. }
  13114. });
  13115. const Stepper = withInstall(stdin_default$b);
  13116. const Steps = withInstall(stdin_default$d);
  13117. const [name$5, bem$5, t$1] = createNamespace("submit-bar");
  13118. const submitBarProps = {
  13119. tip: String,
  13120. label: String,
  13121. price: Number,
  13122. tipIcon: String,
  13123. loading: Boolean,
  13124. currency: makeStringProp("\xA5"),
  13125. disabled: Boolean,
  13126. textAlign: String,
  13127. buttonText: String,
  13128. buttonType: makeStringProp("danger"),
  13129. buttonColor: String,
  13130. suffixLabel: String,
  13131. placeholder: Boolean,
  13132. decimalLength: makeNumericProp(2),
  13133. safeAreaInsetBottom: truthProp
  13134. };
  13135. var stdin_default$a = defineComponent({
  13136. name: name$5,
  13137. props: submitBarProps,
  13138. emits: ["submit"],
  13139. setup(props, {
  13140. emit,
  13141. slots
  13142. }) {
  13143. const root = ref();
  13144. const renderPlaceholder = usePlaceholder(root, bem$5);
  13145. const renderText = () => {
  13146. const {
  13147. price,
  13148. label,
  13149. currency,
  13150. textAlign,
  13151. suffixLabel,
  13152. decimalLength
  13153. } = props;
  13154. if (typeof price === "number") {
  13155. const pricePair = (price / 100).toFixed(+decimalLength).split(".");
  13156. const decimal = decimalLength ? `.${pricePair[1]}` : "";
  13157. return createVNode("div", {
  13158. "class": bem$5("text"),
  13159. "style": {
  13160. textAlign
  13161. }
  13162. }, [createVNode("span", null, [label || t$1("label")]), createVNode("span", {
  13163. "class": bem$5("price")
  13164. }, [currency, createVNode("span", {
  13165. "class": bem$5("price-integer")
  13166. }, [pricePair[0]]), decimal]), suffixLabel && createVNode("span", {
  13167. "class": bem$5("suffix-label")
  13168. }, [suffixLabel])]);
  13169. }
  13170. };
  13171. const renderTip = () => {
  13172. var _a;
  13173. const {
  13174. tip,
  13175. tipIcon
  13176. } = props;
  13177. if (slots.tip || tip) {
  13178. return createVNode("div", {
  13179. "class": bem$5("tip")
  13180. }, [tipIcon && createVNode(Icon, {
  13181. "class": bem$5("tip-icon"),
  13182. "name": tipIcon
  13183. }, null), tip && createVNode("span", {
  13184. "class": bem$5("tip-text")
  13185. }, [tip]), (_a = slots.tip) == null ? void 0 : _a.call(slots)]);
  13186. }
  13187. };
  13188. const onClickButton = () => emit("submit");
  13189. const renderButton = () => {
  13190. if (slots.button) {
  13191. return slots.button();
  13192. }
  13193. return createVNode(Button, {
  13194. "round": true,
  13195. "type": props.buttonType,
  13196. "text": props.buttonText,
  13197. "class": bem$5("button", props.buttonType),
  13198. "color": props.buttonColor,
  13199. "loading": props.loading,
  13200. "disabled": props.disabled,
  13201. "onClick": onClickButton
  13202. }, null);
  13203. };
  13204. const renderSubmitBar = () => {
  13205. var _a, _b;
  13206. return createVNode("div", {
  13207. "ref": root,
  13208. "class": [bem$5(), {
  13209. "van-safe-area-bottom": props.safeAreaInsetBottom
  13210. }]
  13211. }, [(_a = slots.top) == null ? void 0 : _a.call(slots), renderTip(), createVNode("div", {
  13212. "class": bem$5("bar")
  13213. }, [(_b = slots.default) == null ? void 0 : _b.call(slots), renderText(), renderButton()])]);
  13214. };
  13215. return () => {
  13216. if (props.placeholder) {
  13217. return renderPlaceholder(renderSubmitBar);
  13218. }
  13219. return renderSubmitBar();
  13220. };
  13221. }
  13222. });
  13223. const SubmitBar = withInstall(stdin_default$a);
  13224. const [name$4, bem$4] = createNamespace("swipe-cell");
  13225. const swipeCellProps = {
  13226. name: makeNumericProp(""),
  13227. disabled: Boolean,
  13228. leftWidth: numericProp,
  13229. rightWidth: numericProp,
  13230. beforeClose: Function,
  13231. stopPropagation: Boolean
  13232. };
  13233. var stdin_default$9 = defineComponent({
  13234. name: name$4,
  13235. props: swipeCellProps,
  13236. emits: ["open", "close", "click"],
  13237. setup(props, {
  13238. emit,
  13239. slots
  13240. }) {
  13241. let opened;
  13242. let lockClick2;
  13243. let startOffset;
  13244. const root = ref();
  13245. const leftRef = ref();
  13246. const rightRef = ref();
  13247. const state = reactive({
  13248. offset: 0,
  13249. dragging: false
  13250. });
  13251. const touch = useTouch();
  13252. const getWidthByRef = (ref2) => ref2.value ? useRect(ref2).width : 0;
  13253. const leftWidth = computed(() => isDef(props.leftWidth) ? +props.leftWidth : getWidthByRef(leftRef));
  13254. const rightWidth = computed(() => isDef(props.rightWidth) ? +props.rightWidth : getWidthByRef(rightRef));
  13255. const open = (side) => {
  13256. state.offset = side === "left" ? leftWidth.value : -rightWidth.value;
  13257. if (!opened) {
  13258. opened = true;
  13259. emit("open", {
  13260. name: props.name,
  13261. position: side
  13262. });
  13263. }
  13264. };
  13265. const close = (position) => {
  13266. state.offset = 0;
  13267. if (opened) {
  13268. opened = false;
  13269. emit("close", {
  13270. name: props.name,
  13271. position
  13272. });
  13273. }
  13274. };
  13275. const toggle = (side) => {
  13276. const offset = Math.abs(state.offset);
  13277. const THRESHOLD = 0.15;
  13278. const threshold = opened ? 1 - THRESHOLD : THRESHOLD;
  13279. const width = side === "left" ? leftWidth.value : rightWidth.value;
  13280. if (width && offset > width * threshold) {
  13281. open(side);
  13282. } else {
  13283. close(side);
  13284. }
  13285. };
  13286. const onTouchStart = (event) => {
  13287. if (!props.disabled) {
  13288. startOffset = state.offset;
  13289. touch.start(event);
  13290. }
  13291. };
  13292. const onTouchMove = (event) => {
  13293. if (props.disabled) {
  13294. return;
  13295. }
  13296. const {
  13297. deltaX
  13298. } = touch;
  13299. touch.move(event);
  13300. if (touch.isHorizontal()) {
  13301. lockClick2 = true;
  13302. state.dragging = true;
  13303. const isEdge = !opened || deltaX.value * startOffset < 0;
  13304. if (isEdge) {
  13305. preventDefault(event, props.stopPropagation);
  13306. }
  13307. state.offset = clamp(deltaX.value + startOffset, -rightWidth.value, leftWidth.value);
  13308. }
  13309. };
  13310. const onTouchEnd = () => {
  13311. if (state.dragging) {
  13312. state.dragging = false;
  13313. toggle(state.offset > 0 ? "left" : "right");
  13314. setTimeout(() => {
  13315. lockClick2 = false;
  13316. }, 0);
  13317. }
  13318. };
  13319. const onClick = (position = "outside") => {
  13320. emit("click", position);
  13321. if (opened && !lockClick2) {
  13322. callInterceptor(props.beforeClose, {
  13323. args: [{
  13324. name: props.name,
  13325. position
  13326. }],
  13327. done: () => close(position)
  13328. });
  13329. }
  13330. };
  13331. const getClickHandler = (position, stop) => (event) => {
  13332. if (stop) {
  13333. event.stopPropagation();
  13334. }
  13335. onClick(position);
  13336. };
  13337. const renderSideContent = (side, ref2) => {
  13338. const contentSlot = slots[side];
  13339. if (contentSlot) {
  13340. return createVNode("div", {
  13341. "ref": ref2,
  13342. "class": bem$4(side),
  13343. "onClick": getClickHandler(side, true)
  13344. }, [contentSlot()]);
  13345. }
  13346. };
  13347. useExpose({
  13348. open,
  13349. close
  13350. });
  13351. useClickAway(root, () => onClick("outside"), {
  13352. eventName: "touchstart"
  13353. });
  13354. useEventListener("touchmove", onTouchMove, {
  13355. target: root
  13356. });
  13357. return () => {
  13358. var _a;
  13359. const wrapperStyle = {
  13360. transform: `translate3d(${state.offset}px, 0, 0)`,
  13361. transitionDuration: state.dragging ? "0s" : ".6s"
  13362. };
  13363. return createVNode("div", {
  13364. "ref": root,
  13365. "class": bem$4(),
  13366. "onClick": getClickHandler("cell", lockClick2),
  13367. "onTouchstartPassive": onTouchStart,
  13368. "onTouchend": onTouchEnd,
  13369. "onTouchcancel": onTouchEnd
  13370. }, [createVNode("div", {
  13371. "class": bem$4("wrapper"),
  13372. "style": wrapperStyle
  13373. }, [renderSideContent("left", leftRef), (_a = slots.default) == null ? void 0 : _a.call(slots), renderSideContent("right", rightRef)])]);
  13374. };
  13375. }
  13376. });
  13377. const SwipeCell = withInstall(stdin_default$9);
  13378. const [name$3, bem$3] = createNamespace("tabbar");
  13379. const tabbarProps = {
  13380. route: Boolean,
  13381. fixed: truthProp,
  13382. border: truthProp,
  13383. zIndex: numericProp,
  13384. placeholder: Boolean,
  13385. activeColor: String,
  13386. beforeChange: Function,
  13387. inactiveColor: String,
  13388. modelValue: makeNumericProp(0),
  13389. safeAreaInsetBottom: {
  13390. type: Boolean,
  13391. default: null
  13392. }
  13393. };
  13394. const TABBAR_KEY = Symbol(name$3);
  13395. var stdin_default$8 = defineComponent({
  13396. name: name$3,
  13397. props: tabbarProps,
  13398. emits: ["change", "update:modelValue"],
  13399. setup(props, {
  13400. emit,
  13401. slots
  13402. }) {
  13403. const root = ref();
  13404. const {
  13405. linkChildren
  13406. } = useChildren(TABBAR_KEY);
  13407. const renderPlaceholder = usePlaceholder(root, bem$3);
  13408. const enableSafeArea = () => {
  13409. var _a;
  13410. return (_a = props.safeAreaInsetBottom) != null ? _a : props.fixed;
  13411. };
  13412. const renderTabbar = () => {
  13413. var _a;
  13414. const {
  13415. fixed,
  13416. zIndex,
  13417. border
  13418. } = props;
  13419. return createVNode("div", {
  13420. "ref": root,
  13421. "role": "tablist",
  13422. "style": getZIndexStyle(zIndex),
  13423. "class": [bem$3({
  13424. fixed
  13425. }), {
  13426. [BORDER_TOP_BOTTOM]: border,
  13427. "van-safe-area-bottom": enableSafeArea()
  13428. }]
  13429. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  13430. };
  13431. const setActive = (active, afterChange) => {
  13432. callInterceptor(props.beforeChange, {
  13433. args: [active],
  13434. done() {
  13435. emit("update:modelValue", active);
  13436. emit("change", active);
  13437. afterChange();
  13438. }
  13439. });
  13440. };
  13441. linkChildren({
  13442. props,
  13443. setActive
  13444. });
  13445. return () => {
  13446. if (props.fixed && props.placeholder) {
  13447. return renderPlaceholder(renderTabbar);
  13448. }
  13449. return renderTabbar();
  13450. };
  13451. }
  13452. });
  13453. const Tabbar = withInstall(stdin_default$8);
  13454. const [name$2, bem$2] = createNamespace("tabbar-item");
  13455. const tabbarItemProps = extend({}, routeProps, {
  13456. dot: Boolean,
  13457. icon: String,
  13458. name: numericProp,
  13459. badge: numericProp,
  13460. badgeProps: Object,
  13461. iconPrefix: String
  13462. });
  13463. var stdin_default$7 = defineComponent({
  13464. name: name$2,
  13465. props: tabbarItemProps,
  13466. emits: ["click"],
  13467. setup(props, {
  13468. emit,
  13469. slots
  13470. }) {
  13471. const route2 = useRoute();
  13472. const vm = getCurrentInstance().proxy;
  13473. const {
  13474. parent,
  13475. index
  13476. } = useParent(TABBAR_KEY);
  13477. if (!parent) {
  13478. if (process.env.NODE_ENV !== "production") {
  13479. console.error("[Vant] <TabbarItem> must be a child component of <Tabbar>.");
  13480. }
  13481. return;
  13482. }
  13483. const active = computed(() => {
  13484. var _a;
  13485. const {
  13486. route: route22,
  13487. modelValue
  13488. } = parent.props;
  13489. if (route22 && "$route" in vm) {
  13490. const {
  13491. $route
  13492. } = vm;
  13493. const {
  13494. to
  13495. } = props;
  13496. const config = isObject(to) ? to : {
  13497. path: to
  13498. };
  13499. return !!$route.matched.find((val) => {
  13500. const pathMatched = "path" in config && config.path === val.path;
  13501. const nameMatched = "name" in config && config.name === val.name;
  13502. return pathMatched || nameMatched;
  13503. });
  13504. }
  13505. return ((_a = props.name) != null ? _a : index.value) === modelValue;
  13506. });
  13507. const onClick = (event) => {
  13508. var _a;
  13509. if (!active.value) {
  13510. parent.setActive((_a = props.name) != null ? _a : index.value, route2);
  13511. }
  13512. emit("click", event);
  13513. };
  13514. const renderIcon = () => {
  13515. if (slots.icon) {
  13516. return slots.icon({
  13517. active: active.value
  13518. });
  13519. }
  13520. if (props.icon) {
  13521. return createVNode(Icon, {
  13522. "name": props.icon,
  13523. "classPrefix": props.iconPrefix
  13524. }, null);
  13525. }
  13526. };
  13527. return () => {
  13528. var _a;
  13529. const {
  13530. dot,
  13531. badge
  13532. } = props;
  13533. const {
  13534. activeColor,
  13535. inactiveColor
  13536. } = parent.props;
  13537. const color = active.value ? activeColor : inactiveColor;
  13538. return createVNode("div", {
  13539. "role": "tab",
  13540. "class": bem$2({
  13541. active: active.value
  13542. }),
  13543. "style": {
  13544. color
  13545. },
  13546. "tabindex": 0,
  13547. "aria-selected": active.value,
  13548. "onClick": onClick
  13549. }, [createVNode(Badge, mergeProps({
  13550. "dot": dot,
  13551. "class": bem$2("icon"),
  13552. "content": badge
  13553. }, props.badgeProps), {
  13554. default: renderIcon
  13555. }), createVNode("div", {
  13556. "class": bem$2("text")
  13557. }, [(_a = slots.default) == null ? void 0 : _a.call(slots, {
  13558. active: active.value
  13559. })])]);
  13560. };
  13561. }
  13562. });
  13563. const TabbarItem = withInstall(stdin_default$7);
  13564. const [name$1, bem$1] = createNamespace("tree-select");
  13565. const treeSelectProps = {
  13566. max: makeNumericProp(Infinity),
  13567. items: makeArrayProp(),
  13568. height: makeNumericProp(300),
  13569. selectedIcon: makeStringProp("success"),
  13570. mainActiveIndex: makeNumericProp(0),
  13571. activeId: {
  13572. type: [Number, String, Array],
  13573. default: 0
  13574. }
  13575. };
  13576. var stdin_default$6 = defineComponent({
  13577. name: name$1,
  13578. props: treeSelectProps,
  13579. emits: ["click-nav", "click-item", "update:activeId", "update:mainActiveIndex"],
  13580. setup(props, {
  13581. emit,
  13582. slots
  13583. }) {
  13584. const isActiveItem = (id) => Array.isArray(props.activeId) ? props.activeId.includes(id) : props.activeId === id;
  13585. const renderSubItem = (item) => {
  13586. const onClick = () => {
  13587. if (item.disabled) {
  13588. return;
  13589. }
  13590. let activeId;
  13591. if (Array.isArray(props.activeId)) {
  13592. activeId = props.activeId.slice();
  13593. const index = activeId.indexOf(item.id);
  13594. if (index !== -1) {
  13595. activeId.splice(index, 1);
  13596. } else if (activeId.length < props.max) {
  13597. activeId.push(item.id);
  13598. }
  13599. } else {
  13600. activeId = item.id;
  13601. }
  13602. emit("update:activeId", activeId);
  13603. emit("click-item", item);
  13604. };
  13605. return createVNode("div", {
  13606. "key": item.id,
  13607. "class": ["van-ellipsis", bem$1("item", {
  13608. active: isActiveItem(item.id),
  13609. disabled: item.disabled
  13610. })],
  13611. "onClick": onClick
  13612. }, [item.text, isActiveItem(item.id) && createVNode(Icon, {
  13613. "name": props.selectedIcon,
  13614. "class": bem$1("selected")
  13615. }, null)]);
  13616. };
  13617. const onSidebarChange = (index) => {
  13618. emit("update:mainActiveIndex", index);
  13619. };
  13620. const onClickSidebarItem = (index) => emit("click-nav", index);
  13621. const renderSidebar = () => {
  13622. const Items = props.items.map((item) => createVNode(SidebarItem, {
  13623. "dot": item.dot,
  13624. "title": item.text,
  13625. "badge": item.badge,
  13626. "class": [bem$1("nav-item"), item.className],
  13627. "disabled": item.disabled,
  13628. "onClick": onClickSidebarItem
  13629. }, null));
  13630. return createVNode(Sidebar, {
  13631. "class": bem$1("nav"),
  13632. "modelValue": props.mainActiveIndex,
  13633. "onChange": onSidebarChange
  13634. }, {
  13635. default: () => [Items]
  13636. });
  13637. };
  13638. const renderContent = () => {
  13639. if (slots.content) {
  13640. return slots.content();
  13641. }
  13642. const selected = props.items[+props.mainActiveIndex] || {};
  13643. if (selected.children) {
  13644. return selected.children.map(renderSubItem);
  13645. }
  13646. };
  13647. return () => createVNode("div", {
  13648. "class": bem$1(),
  13649. "style": {
  13650. height: addUnit(props.height)
  13651. }
  13652. }, [renderSidebar(), createVNode("div", {
  13653. "class": bem$1("content")
  13654. }, [renderContent()])]);
  13655. }
  13656. });
  13657. const TreeSelect = withInstall(stdin_default$6);
  13658. const [name, bem, t] = createNamespace("uploader");
  13659. function readFileContent(file, resultType) {
  13660. return new Promise((resolve) => {
  13661. if (resultType === "file") {
  13662. resolve();
  13663. return;
  13664. }
  13665. const reader = new FileReader();
  13666. reader.onload = (event) => {
  13667. resolve(event.target.result);
  13668. };
  13669. if (resultType === "dataUrl") {
  13670. reader.readAsDataURL(file);
  13671. } else if (resultType === "text") {
  13672. reader.readAsText(file);
  13673. }
  13674. });
  13675. }
  13676. function isOversize(items, maxSize) {
  13677. return toArray(items).some((item) => {
  13678. if (item.file) {
  13679. if (isFunction(maxSize)) {
  13680. return maxSize(item.file);
  13681. }
  13682. return item.file.size > maxSize;
  13683. }
  13684. return false;
  13685. });
  13686. }
  13687. function filterFiles(items, maxSize) {
  13688. const valid = [];
  13689. const invalid = [];
  13690. items.forEach((item) => {
  13691. if (isOversize(item, maxSize)) {
  13692. invalid.push(item);
  13693. } else {
  13694. valid.push(item);
  13695. }
  13696. });
  13697. return { valid, invalid };
  13698. }
  13699. const IMAGE_REGEXP = /\.(jpeg|jpg|gif|png|svg|webp|jfif|bmp|dpg)/i;
  13700. const isImageUrl = (url) => IMAGE_REGEXP.test(url);
  13701. function isImageFile(item) {
  13702. if (item.isImage) {
  13703. return true;
  13704. }
  13705. if (item.file && item.file.type) {
  13706. return item.file.type.indexOf("image") === 0;
  13707. }
  13708. if (item.url) {
  13709. return isImageUrl(item.url);
  13710. }
  13711. if (typeof item.content === "string") {
  13712. return item.content.indexOf("data:image") === 0;
  13713. }
  13714. return false;
  13715. }
  13716. var stdin_default$5 = defineComponent({
  13717. props: {
  13718. name: numericProp,
  13719. item: makeRequiredProp(Object),
  13720. index: Number,
  13721. imageFit: String,
  13722. lazyLoad: Boolean,
  13723. deletable: Boolean,
  13724. previewSize: [Number, String, Array],
  13725. beforeDelete: Function
  13726. },
  13727. emits: ["delete", "preview"],
  13728. setup(props, {
  13729. emit,
  13730. slots
  13731. }) {
  13732. const renderMask = () => {
  13733. const {
  13734. status,
  13735. message
  13736. } = props.item;
  13737. if (status === "uploading" || status === "failed") {
  13738. const MaskIcon = status === "failed" ? createVNode(Icon, {
  13739. "name": "close",
  13740. "class": bem("mask-icon")
  13741. }, null) : createVNode(Loading, {
  13742. "class": bem("loading")
  13743. }, null);
  13744. const showMessage = isDef(message) && message !== "";
  13745. return createVNode("div", {
  13746. "class": bem("mask")
  13747. }, [MaskIcon, showMessage && createVNode("div", {
  13748. "class": bem("mask-message")
  13749. }, [message])]);
  13750. }
  13751. };
  13752. const onDelete = (event) => {
  13753. const {
  13754. name: name2,
  13755. item,
  13756. index,
  13757. beforeDelete
  13758. } = props;
  13759. event.stopPropagation();
  13760. callInterceptor(beforeDelete, {
  13761. args: [item, {
  13762. name: name2,
  13763. index
  13764. }],
  13765. done: () => emit("delete")
  13766. });
  13767. };
  13768. const onPreview = () => emit("preview");
  13769. const renderDeleteIcon = () => {
  13770. if (props.deletable && props.item.status !== "uploading") {
  13771. const slot = slots["preview-delete"];
  13772. return createVNode("div", {
  13773. "role": "button",
  13774. "class": bem("preview-delete", {
  13775. shadow: !slot
  13776. }),
  13777. "tabindex": 0,
  13778. "aria-label": t("delete"),
  13779. "onClick": onDelete
  13780. }, [slot ? slot() : createVNode(Icon, {
  13781. "name": "cross",
  13782. "class": bem("preview-delete-icon")
  13783. }, null)]);
  13784. }
  13785. };
  13786. const renderCover = () => {
  13787. if (slots["preview-cover"]) {
  13788. const {
  13789. index,
  13790. item
  13791. } = props;
  13792. return createVNode("div", {
  13793. "class": bem("preview-cover")
  13794. }, [slots["preview-cover"](extend({
  13795. index
  13796. }, item))]);
  13797. }
  13798. };
  13799. const renderPreview = () => {
  13800. const {
  13801. item,
  13802. lazyLoad,
  13803. imageFit,
  13804. previewSize
  13805. } = props;
  13806. if (isImageFile(item)) {
  13807. return createVNode(Image$1, {
  13808. "fit": imageFit,
  13809. "src": item.content || item.url,
  13810. "class": bem("preview-image"),
  13811. "width": Array.isArray(previewSize) ? previewSize[0] : previewSize,
  13812. "height": Array.isArray(previewSize) ? previewSize[1] : previewSize,
  13813. "lazyLoad": lazyLoad,
  13814. "onClick": onPreview
  13815. }, {
  13816. default: renderCover
  13817. });
  13818. }
  13819. return createVNode("div", {
  13820. "class": bem("file"),
  13821. "style": getSizeStyle(props.previewSize)
  13822. }, [createVNode(Icon, {
  13823. "class": bem("file-icon"),
  13824. "name": "description"
  13825. }, null), createVNode("div", {
  13826. "class": [bem("file-name"), "van-ellipsis"]
  13827. }, [item.file ? item.file.name : item.url]), renderCover()]);
  13828. };
  13829. return () => createVNode("div", {
  13830. "class": bem("preview")
  13831. }, [renderPreview(), renderMask(), renderDeleteIcon()]);
  13832. }
  13833. });
  13834. const uploaderProps = {
  13835. name: makeNumericProp(""),
  13836. accept: makeStringProp("image/*"),
  13837. capture: String,
  13838. multiple: Boolean,
  13839. disabled: Boolean,
  13840. readonly: Boolean,
  13841. lazyLoad: Boolean,
  13842. maxCount: makeNumericProp(Infinity),
  13843. imageFit: makeStringProp("cover"),
  13844. resultType: makeStringProp("dataUrl"),
  13845. uploadIcon: makeStringProp("photograph"),
  13846. uploadText: String,
  13847. deletable: truthProp,
  13848. afterRead: Function,
  13849. showUpload: truthProp,
  13850. modelValue: makeArrayProp(),
  13851. beforeRead: Function,
  13852. beforeDelete: Function,
  13853. previewSize: [Number, String, Array],
  13854. previewImage: truthProp,
  13855. previewOptions: Object,
  13856. previewFullImage: truthProp,
  13857. maxSize: {
  13858. type: [Number, String, Function],
  13859. default: Infinity
  13860. }
  13861. };
  13862. var stdin_default$4 = defineComponent({
  13863. name,
  13864. props: uploaderProps,
  13865. emits: ["delete", "oversize", "click-upload", "close-preview", "click-preview", "update:modelValue"],
  13866. setup(props, {
  13867. emit,
  13868. slots
  13869. }) {
  13870. const inputRef = ref();
  13871. const urls = [];
  13872. const getDetail = (index = props.modelValue.length) => ({
  13873. name: props.name,
  13874. index
  13875. });
  13876. const resetInput = () => {
  13877. if (inputRef.value) {
  13878. inputRef.value.value = "";
  13879. }
  13880. };
  13881. const onAfterRead = (items) => {
  13882. resetInput();
  13883. if (isOversize(items, props.maxSize)) {
  13884. if (Array.isArray(items)) {
  13885. const result = filterFiles(items, props.maxSize);
  13886. items = result.valid;
  13887. emit("oversize", result.invalid, getDetail());
  13888. if (!items.length) {
  13889. return;
  13890. }
  13891. } else {
  13892. emit("oversize", items, getDetail());
  13893. return;
  13894. }
  13895. }
  13896. items = reactive(items);
  13897. emit("update:modelValue", [...props.modelValue, ...toArray(items)]);
  13898. if (props.afterRead) {
  13899. props.afterRead(items, getDetail());
  13900. }
  13901. };
  13902. const readFile = (files) => {
  13903. const {
  13904. maxCount,
  13905. modelValue,
  13906. resultType
  13907. } = props;
  13908. if (Array.isArray(files)) {
  13909. const remainCount = +maxCount - modelValue.length;
  13910. if (files.length > remainCount) {
  13911. files = files.slice(0, remainCount);
  13912. }
  13913. Promise.all(files.map((file) => readFileContent(file, resultType))).then((contents) => {
  13914. const fileList = files.map((file, index) => {
  13915. const result = {
  13916. file,
  13917. status: "",
  13918. message: ""
  13919. };
  13920. if (contents[index]) {
  13921. result.content = contents[index];
  13922. }
  13923. return result;
  13924. });
  13925. onAfterRead(fileList);
  13926. });
  13927. } else {
  13928. readFileContent(files, resultType).then((content) => {
  13929. const result = {
  13930. file: files,
  13931. status: "",
  13932. message: ""
  13933. };
  13934. if (content) {
  13935. result.content = content;
  13936. }
  13937. onAfterRead(result);
  13938. });
  13939. }
  13940. };
  13941. const onChange = (event) => {
  13942. const {
  13943. files
  13944. } = event.target;
  13945. if (props.disabled || !files || !files.length) {
  13946. return;
  13947. }
  13948. const file = files.length === 1 ? files[0] : [].slice.call(files);
  13949. if (props.beforeRead) {
  13950. const response = props.beforeRead(file, getDetail());
  13951. if (!response) {
  13952. resetInput();
  13953. return;
  13954. }
  13955. if (isPromise(response)) {
  13956. response.then((data) => {
  13957. if (data) {
  13958. readFile(data);
  13959. } else {
  13960. readFile(file);
  13961. }
  13962. }).catch(resetInput);
  13963. return;
  13964. }
  13965. }
  13966. readFile(file);
  13967. };
  13968. let imagePreview;
  13969. const onClosePreview = () => emit("close-preview");
  13970. const previewImage = (item) => {
  13971. if (props.previewFullImage) {
  13972. const imageFiles = props.modelValue.filter(isImageFile);
  13973. const images = imageFiles.map((item2) => {
  13974. if (item2.file && !item2.url && item2.status !== "failed") {
  13975. item2.url = URL.createObjectURL(item2.file);
  13976. urls.push(item2.url);
  13977. }
  13978. return item2.url;
  13979. }).filter(Boolean);
  13980. imagePreview = ImagePreview(extend({
  13981. images,
  13982. startPosition: imageFiles.indexOf(item),
  13983. onClose: onClosePreview
  13984. }, props.previewOptions));
  13985. }
  13986. };
  13987. const closeImagePreview = () => {
  13988. if (imagePreview) {
  13989. imagePreview.close();
  13990. }
  13991. };
  13992. const deleteFile = (item, index) => {
  13993. const fileList = props.modelValue.slice(0);
  13994. fileList.splice(index, 1);
  13995. emit("update:modelValue", fileList);
  13996. emit("delete", item, getDetail(index));
  13997. };
  13998. const renderPreviewItem = (item, index) => {
  13999. const needPickData = ["imageFit", "deletable", "previewSize", "beforeDelete"];
  14000. const previewData = extend(pick(props, needPickData), pick(item, needPickData, true));
  14001. return createVNode(stdin_default$5, mergeProps({
  14002. "item": item,
  14003. "index": index,
  14004. "onClick": () => emit("click-preview", item, getDetail(index)),
  14005. "onDelete": () => deleteFile(item, index),
  14006. "onPreview": () => previewImage(item)
  14007. }, pick(props, ["name", "lazyLoad"]), previewData), pick(slots, ["preview-cover", "preview-delete"]));
  14008. };
  14009. const renderPreviewList = () => {
  14010. if (props.previewImage) {
  14011. return props.modelValue.map(renderPreviewItem);
  14012. }
  14013. };
  14014. const onClickUpload = (event) => emit("click-upload", event);
  14015. const renderUpload = () => {
  14016. if (props.modelValue.length >= props.maxCount || !props.showUpload) {
  14017. return;
  14018. }
  14019. const Input = props.readonly ? null : createVNode("input", {
  14020. "ref": inputRef,
  14021. "type": "file",
  14022. "class": bem("input"),
  14023. "accept": props.accept,
  14024. "capture": props.capture,
  14025. "multiple": props.multiple,
  14026. "disabled": props.disabled,
  14027. "onChange": onChange
  14028. }, null);
  14029. if (slots.default) {
  14030. return createVNode("div", {
  14031. "class": bem("input-wrapper"),
  14032. "onClick": onClickUpload
  14033. }, [slots.default(), Input]);
  14034. }
  14035. return createVNode("div", {
  14036. "class": bem("upload", {
  14037. readonly: props.readonly
  14038. }),
  14039. "style": getSizeStyle(props.previewSize),
  14040. "onClick": onClickUpload
  14041. }, [createVNode(Icon, {
  14042. "name": props.uploadIcon,
  14043. "class": bem("upload-icon")
  14044. }, null), props.uploadText && createVNode("span", {
  14045. "class": bem("upload-text")
  14046. }, [props.uploadText]), Input]);
  14047. };
  14048. const chooseFile = () => {
  14049. if (inputRef.value && !props.disabled) {
  14050. inputRef.value.click();
  14051. }
  14052. };
  14053. onBeforeUnmount(() => {
  14054. urls.forEach((url) => URL.revokeObjectURL(url));
  14055. });
  14056. useExpose({
  14057. chooseFile,
  14058. closeImagePreview
  14059. });
  14060. useCustomFieldValue(() => props.modelValue);
  14061. return () => createVNode("div", {
  14062. "class": bem()
  14063. }, [createVNode("div", {
  14064. "class": bem("wrapper", {
  14065. disabled: props.disabled
  14066. })
  14067. }, [renderPreviewList(), renderUpload()])]);
  14068. }
  14069. });
  14070. const Uploader = withInstall(stdin_default$4);
  14071. const hasIntersectionObserver = inBrowser$1 && "IntersectionObserver" in window && "IntersectionObserverEntry" in window && "intersectionRatio" in window.IntersectionObserverEntry.prototype;
  14072. const modeType = {
  14073. event: "event",
  14074. observer: "observer"
  14075. };
  14076. function remove(arr, item) {
  14077. if (!arr.length)
  14078. return;
  14079. const index = arr.indexOf(item);
  14080. if (index > -1)
  14081. return arr.splice(index, 1);
  14082. }
  14083. function getBestSelectionFromSrcset(el, scale) {
  14084. if (el.tagName !== "IMG" || !el.getAttribute("data-srcset"))
  14085. return;
  14086. let options = el.getAttribute("data-srcset");
  14087. const container = el.parentNode;
  14088. const containerWidth = container.offsetWidth * scale;
  14089. let spaceIndex;
  14090. let tmpSrc;
  14091. let tmpWidth;
  14092. options = options.trim().split(",");
  14093. const result = options.map((item) => {
  14094. item = item.trim();
  14095. spaceIndex = item.lastIndexOf(" ");
  14096. if (spaceIndex === -1) {
  14097. tmpSrc = item;
  14098. tmpWidth = 999998;
  14099. } else {
  14100. tmpSrc = item.substr(0, spaceIndex);
  14101. tmpWidth = parseInt(
  14102. item.substr(spaceIndex + 1, item.length - spaceIndex - 2),
  14103. 10
  14104. );
  14105. }
  14106. return [tmpWidth, tmpSrc];
  14107. });
  14108. result.sort((a, b) => {
  14109. if (a[0] < b[0]) {
  14110. return 1;
  14111. }
  14112. if (a[0] > b[0]) {
  14113. return -1;
  14114. }
  14115. if (a[0] === b[0]) {
  14116. if (b[1].indexOf(".webp", b[1].length - 5) !== -1) {
  14117. return 1;
  14118. }
  14119. if (a[1].indexOf(".webp", a[1].length - 5) !== -1) {
  14120. return -1;
  14121. }
  14122. }
  14123. return 0;
  14124. });
  14125. let bestSelectedSrc = "";
  14126. let tmpOption;
  14127. for (let i = 0; i < result.length; i++) {
  14128. tmpOption = result[i];
  14129. bestSelectedSrc = tmpOption[1];
  14130. const next = result[i + 1];
  14131. if (next && next[0] < containerWidth) {
  14132. bestSelectedSrc = tmpOption[1];
  14133. break;
  14134. } else if (!next) {
  14135. bestSelectedSrc = tmpOption[1];
  14136. break;
  14137. }
  14138. }
  14139. return bestSelectedSrc;
  14140. }
  14141. const getDPR = (scale = 1) => inBrowser$1 ? window.devicePixelRatio || scale : scale;
  14142. function supportWebp() {
  14143. if (!inBrowser$1)
  14144. return false;
  14145. let support = true;
  14146. try {
  14147. const elem = document.createElement("canvas");
  14148. if (elem.getContext && elem.getContext("2d")) {
  14149. support = elem.toDataURL("image/webp").indexOf("data:image/webp") === 0;
  14150. }
  14151. } catch (err) {
  14152. support = false;
  14153. }
  14154. return support;
  14155. }
  14156. function throttle(action, delay) {
  14157. let timeout = null;
  14158. let lastRun = 0;
  14159. return function(...args) {
  14160. if (timeout) {
  14161. return;
  14162. }
  14163. const elapsed = Date.now() - lastRun;
  14164. const runCallback = () => {
  14165. lastRun = Date.now();
  14166. timeout = false;
  14167. action.apply(this, args);
  14168. };
  14169. if (elapsed >= delay) {
  14170. runCallback();
  14171. } else {
  14172. timeout = setTimeout(runCallback, delay);
  14173. }
  14174. };
  14175. }
  14176. function on(el, type, func) {
  14177. el.addEventListener(type, func, {
  14178. capture: false,
  14179. passive: true
  14180. });
  14181. }
  14182. function off(el, type, func) {
  14183. el.removeEventListener(type, func, false);
  14184. }
  14185. const loadImageAsync = (item, resolve, reject) => {
  14186. const image = new Image();
  14187. if (!item || !item.src) {
  14188. return reject(new Error("image src is required"));
  14189. }
  14190. image.src = item.src;
  14191. if (item.cors) {
  14192. image.crossOrigin = item.cors;
  14193. }
  14194. image.onload = () => resolve({
  14195. naturalHeight: image.naturalHeight,
  14196. naturalWidth: image.naturalWidth,
  14197. src: image.src
  14198. });
  14199. image.onerror = (e) => reject(e);
  14200. };
  14201. class ImageCache {
  14202. constructor({ max }) {
  14203. this.options = {
  14204. max: max || 100
  14205. };
  14206. this.caches = [];
  14207. }
  14208. has(key) {
  14209. return this.caches.indexOf(key) > -1;
  14210. }
  14211. add(key) {
  14212. if (this.has(key))
  14213. return;
  14214. this.caches.push(key);
  14215. if (this.caches.length > this.options.max) {
  14216. this.free();
  14217. }
  14218. }
  14219. free() {
  14220. this.caches.shift();
  14221. }
  14222. }
  14223. class ReactiveListener {
  14224. constructor({
  14225. el,
  14226. src,
  14227. error,
  14228. loading,
  14229. bindType,
  14230. $parent,
  14231. options,
  14232. cors,
  14233. elRenderer,
  14234. imageCache
  14235. }) {
  14236. this.el = el;
  14237. this.src = src;
  14238. this.error = error;
  14239. this.loading = loading;
  14240. this.bindType = bindType;
  14241. this.attempt = 0;
  14242. this.cors = cors;
  14243. this.naturalHeight = 0;
  14244. this.naturalWidth = 0;
  14245. this.options = options;
  14246. this.$parent = $parent;
  14247. this.elRenderer = elRenderer;
  14248. this.imageCache = imageCache;
  14249. this.performanceData = {
  14250. loadStart: 0,
  14251. loadEnd: 0
  14252. };
  14253. this.filter();
  14254. this.initState();
  14255. this.render("loading", false);
  14256. }
  14257. initState() {
  14258. if ("dataset" in this.el) {
  14259. this.el.dataset.src = this.src;
  14260. } else {
  14261. this.el.setAttribute("data-src", this.src);
  14262. }
  14263. this.state = {
  14264. loading: false,
  14265. error: false,
  14266. loaded: false,
  14267. rendered: false
  14268. };
  14269. }
  14270. record(event) {
  14271. this.performanceData[event] = Date.now();
  14272. }
  14273. update({ src, loading, error }) {
  14274. const oldSrc = this.src;
  14275. this.src = src;
  14276. this.loading = loading;
  14277. this.error = error;
  14278. this.filter();
  14279. if (oldSrc !== this.src) {
  14280. this.attempt = 0;
  14281. this.initState();
  14282. }
  14283. }
  14284. checkInView() {
  14285. const rect = useRect(this.el);
  14286. return rect.top < window.innerHeight * this.options.preLoad && rect.bottom > this.options.preLoadTop && rect.left < window.innerWidth * this.options.preLoad && rect.right > 0;
  14287. }
  14288. filter() {
  14289. Object.keys(this.options.filter).forEach((key) => {
  14290. this.options.filter[key](this, this.options);
  14291. });
  14292. }
  14293. renderLoading(cb) {
  14294. this.state.loading = true;
  14295. loadImageAsync(
  14296. {
  14297. src: this.loading,
  14298. cors: this.cors
  14299. },
  14300. () => {
  14301. this.render("loading", false);
  14302. this.state.loading = false;
  14303. cb();
  14304. },
  14305. () => {
  14306. cb();
  14307. this.state.loading = false;
  14308. if (process.env.NODE_ENV !== "production" && !this.options.silent)
  14309. console.warn(
  14310. `[@vant/lazyload] load failed with loading image(${this.loading})`
  14311. );
  14312. }
  14313. );
  14314. }
  14315. load(onFinish = noop) {
  14316. if (this.attempt > this.options.attempt - 1 && this.state.error) {
  14317. if (process.env.NODE_ENV !== "production" && !this.options.silent) {
  14318. console.log(
  14319. `[@vant/lazyload] ${this.src} tried too more than ${this.options.attempt} times`
  14320. );
  14321. }
  14322. onFinish();
  14323. return;
  14324. }
  14325. if (this.state.rendered && this.state.loaded)
  14326. return;
  14327. if (this.imageCache.has(this.src)) {
  14328. this.state.loaded = true;
  14329. this.render("loaded", true);
  14330. this.state.rendered = true;
  14331. return onFinish();
  14332. }
  14333. this.renderLoading(() => {
  14334. var _a, _b;
  14335. this.attempt++;
  14336. (_b = (_a = this.options.adapter).beforeLoad) == null ? void 0 : _b.call(_a, this, this.options);
  14337. this.record("loadStart");
  14338. loadImageAsync(
  14339. {
  14340. src: this.src,
  14341. cors: this.cors
  14342. },
  14343. (data) => {
  14344. this.naturalHeight = data.naturalHeight;
  14345. this.naturalWidth = data.naturalWidth;
  14346. this.state.loaded = true;
  14347. this.state.error = false;
  14348. this.record("loadEnd");
  14349. this.render("loaded", false);
  14350. this.state.rendered = true;
  14351. this.imageCache.add(this.src);
  14352. onFinish();
  14353. },
  14354. (err) => {
  14355. !this.options.silent && console.error(err);
  14356. this.state.error = true;
  14357. this.state.loaded = false;
  14358. this.render("error", false);
  14359. }
  14360. );
  14361. });
  14362. }
  14363. render(state, cache) {
  14364. this.elRenderer(this, state, cache);
  14365. }
  14366. performance() {
  14367. let state = "loading";
  14368. let time = 0;
  14369. if (this.state.loaded) {
  14370. state = "loaded";
  14371. time = (this.performanceData.loadEnd - this.performanceData.loadStart) / 1e3;
  14372. }
  14373. if (this.state.error)
  14374. state = "error";
  14375. return {
  14376. src: this.src,
  14377. state,
  14378. time
  14379. };
  14380. }
  14381. $destroy() {
  14382. this.el = null;
  14383. this.src = null;
  14384. this.error = null;
  14385. this.loading = null;
  14386. this.bindType = null;
  14387. this.attempt = 0;
  14388. }
  14389. }
  14390. const DEFAULT_URL = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";
  14391. const DEFAULT_EVENTS = [
  14392. "scroll",
  14393. "wheel",
  14394. "mousewheel",
  14395. "resize",
  14396. "animationend",
  14397. "transitionend",
  14398. "touchmove"
  14399. ];
  14400. const DEFAULT_OBSERVER_OPTIONS = {
  14401. rootMargin: "0px",
  14402. threshold: 0
  14403. };
  14404. function stdin_default$3() {
  14405. return class Lazy {
  14406. constructor({
  14407. preLoad,
  14408. error,
  14409. throttleWait,
  14410. preLoadTop,
  14411. dispatchEvent,
  14412. loading,
  14413. attempt,
  14414. silent = true,
  14415. scale,
  14416. listenEvents,
  14417. filter,
  14418. adapter,
  14419. observer,
  14420. observerOptions
  14421. }) {
  14422. this.mode = modeType.event;
  14423. this.listeners = [];
  14424. this.targetIndex = 0;
  14425. this.targets = [];
  14426. this.options = {
  14427. silent,
  14428. dispatchEvent: !!dispatchEvent,
  14429. throttleWait: throttleWait || 200,
  14430. preLoad: preLoad || 1.3,
  14431. preLoadTop: preLoadTop || 0,
  14432. error: error || DEFAULT_URL,
  14433. loading: loading || DEFAULT_URL,
  14434. attempt: attempt || 3,
  14435. scale: scale || getDPR(scale),
  14436. ListenEvents: listenEvents || DEFAULT_EVENTS,
  14437. supportWebp: supportWebp(),
  14438. filter: filter || {},
  14439. adapter: adapter || {},
  14440. observer: !!observer,
  14441. observerOptions: observerOptions || DEFAULT_OBSERVER_OPTIONS
  14442. };
  14443. this.initEvent();
  14444. this.imageCache = new ImageCache({ max: 200 });
  14445. this.lazyLoadHandler = throttle(
  14446. this.lazyLoadHandler.bind(this),
  14447. this.options.throttleWait
  14448. );
  14449. this.setMode(this.options.observer ? modeType.observer : modeType.event);
  14450. }
  14451. config(options = {}) {
  14452. Object.assign(this.options, options);
  14453. }
  14454. performance() {
  14455. return this.listeners.map((item) => item.performance());
  14456. }
  14457. addLazyBox(vm) {
  14458. this.listeners.push(vm);
  14459. if (inBrowser$1) {
  14460. this.addListenerTarget(window);
  14461. this.observer && this.observer.observe(vm.el);
  14462. if (vm.$el && vm.$el.parentNode) {
  14463. this.addListenerTarget(vm.$el.parentNode);
  14464. }
  14465. }
  14466. }
  14467. add(el, binding, vnode) {
  14468. if (this.listeners.some((item) => item.el === el)) {
  14469. this.update(el, binding);
  14470. return nextTick(this.lazyLoadHandler);
  14471. }
  14472. const value = this.valueFormatter(binding.value);
  14473. let { src } = value;
  14474. nextTick(() => {
  14475. src = getBestSelectionFromSrcset(el, this.options.scale) || src;
  14476. this.observer && this.observer.observe(el);
  14477. const container = Object.keys(binding.modifiers)[0];
  14478. let $parent;
  14479. if (container) {
  14480. $parent = vnode.context.$refs[container];
  14481. $parent = $parent ? $parent.$el || $parent : document.getElementById(container);
  14482. }
  14483. if (!$parent) {
  14484. $parent = getScrollParent(el);
  14485. }
  14486. const newListener = new ReactiveListener({
  14487. bindType: binding.arg,
  14488. $parent,
  14489. el,
  14490. src,
  14491. loading: value.loading,
  14492. error: value.error,
  14493. cors: value.cors,
  14494. elRenderer: this.elRenderer.bind(this),
  14495. options: this.options,
  14496. imageCache: this.imageCache
  14497. });
  14498. this.listeners.push(newListener);
  14499. if (inBrowser$1) {
  14500. this.addListenerTarget(window);
  14501. this.addListenerTarget($parent);
  14502. }
  14503. this.lazyLoadHandler();
  14504. nextTick(() => this.lazyLoadHandler());
  14505. });
  14506. }
  14507. update(el, binding, vnode) {
  14508. const value = this.valueFormatter(binding.value);
  14509. let { src } = value;
  14510. src = getBestSelectionFromSrcset(el, this.options.scale) || src;
  14511. const exist = this.listeners.find((item) => item.el === el);
  14512. if (!exist) {
  14513. this.add(el, binding, vnode);
  14514. } else {
  14515. exist.update({
  14516. src,
  14517. error: value.error,
  14518. loading: value.loading
  14519. });
  14520. }
  14521. if (this.observer) {
  14522. this.observer.unobserve(el);
  14523. this.observer.observe(el);
  14524. }
  14525. this.lazyLoadHandler();
  14526. nextTick(() => this.lazyLoadHandler());
  14527. }
  14528. remove(el) {
  14529. if (!el)
  14530. return;
  14531. this.observer && this.observer.unobserve(el);
  14532. const existItem = this.listeners.find((item) => item.el === el);
  14533. if (existItem) {
  14534. this.removeListenerTarget(existItem.$parent);
  14535. this.removeListenerTarget(window);
  14536. remove(this.listeners, existItem);
  14537. existItem.$destroy();
  14538. }
  14539. }
  14540. removeComponent(vm) {
  14541. if (!vm)
  14542. return;
  14543. remove(this.listeners, vm);
  14544. this.observer && this.observer.unobserve(vm.el);
  14545. if (vm.$parent && vm.$el.parentNode) {
  14546. this.removeListenerTarget(vm.$el.parentNode);
  14547. }
  14548. this.removeListenerTarget(window);
  14549. }
  14550. setMode(mode) {
  14551. if (!hasIntersectionObserver && mode === modeType.observer) {
  14552. mode = modeType.event;
  14553. }
  14554. this.mode = mode;
  14555. if (mode === modeType.event) {
  14556. if (this.observer) {
  14557. this.listeners.forEach((listener) => {
  14558. this.observer.unobserve(listener.el);
  14559. });
  14560. this.observer = null;
  14561. }
  14562. this.targets.forEach((target) => {
  14563. this.initListen(target.el, true);
  14564. });
  14565. } else {
  14566. this.targets.forEach((target) => {
  14567. this.initListen(target.el, false);
  14568. });
  14569. this.initIntersectionObserver();
  14570. }
  14571. }
  14572. addListenerTarget(el) {
  14573. if (!el)
  14574. return;
  14575. let target = this.targets.find((target2) => target2.el === el);
  14576. if (!target) {
  14577. target = {
  14578. el,
  14579. id: ++this.targetIndex,
  14580. childrenCount: 1,
  14581. listened: true
  14582. };
  14583. this.mode === modeType.event && this.initListen(target.el, true);
  14584. this.targets.push(target);
  14585. } else {
  14586. target.childrenCount++;
  14587. }
  14588. return this.targetIndex;
  14589. }
  14590. removeListenerTarget(el) {
  14591. this.targets.forEach((target, index) => {
  14592. if (target.el === el) {
  14593. target.childrenCount--;
  14594. if (!target.childrenCount) {
  14595. this.initListen(target.el, false);
  14596. this.targets.splice(index, 1);
  14597. target = null;
  14598. }
  14599. }
  14600. });
  14601. }
  14602. initListen(el, start) {
  14603. this.options.ListenEvents.forEach(
  14604. (evt) => (start ? on : off)(el, evt, this.lazyLoadHandler)
  14605. );
  14606. }
  14607. initEvent() {
  14608. this.Event = {
  14609. listeners: {
  14610. loading: [],
  14611. loaded: [],
  14612. error: []
  14613. }
  14614. };
  14615. this.$on = (event, func) => {
  14616. if (!this.Event.listeners[event])
  14617. this.Event.listeners[event] = [];
  14618. this.Event.listeners[event].push(func);
  14619. };
  14620. this.$once = (event, func) => {
  14621. const on2 = (...args) => {
  14622. this.$off(event, on2);
  14623. func.apply(this, args);
  14624. };
  14625. this.$on(event, on2);
  14626. };
  14627. this.$off = (event, func) => {
  14628. if (!func) {
  14629. if (!this.Event.listeners[event])
  14630. return;
  14631. this.Event.listeners[event].length = 0;
  14632. return;
  14633. }
  14634. remove(this.Event.listeners[event], func);
  14635. };
  14636. this.$emit = (event, context, inCache) => {
  14637. if (!this.Event.listeners[event])
  14638. return;
  14639. this.Event.listeners[event].forEach((func) => func(context, inCache));
  14640. };
  14641. }
  14642. lazyLoadHandler() {
  14643. const freeList = [];
  14644. this.listeners.forEach((listener) => {
  14645. if (!listener.el || !listener.el.parentNode) {
  14646. freeList.push(listener);
  14647. }
  14648. const catIn = listener.checkInView();
  14649. if (!catIn)
  14650. return;
  14651. listener.load();
  14652. });
  14653. freeList.forEach((item) => {
  14654. remove(this.listeners, item);
  14655. item.$destroy();
  14656. });
  14657. }
  14658. initIntersectionObserver() {
  14659. if (!hasIntersectionObserver) {
  14660. return;
  14661. }
  14662. this.observer = new IntersectionObserver(
  14663. this.observerHandler.bind(this),
  14664. this.options.observerOptions
  14665. );
  14666. if (this.listeners.length) {
  14667. this.listeners.forEach((listener) => {
  14668. this.observer.observe(listener.el);
  14669. });
  14670. }
  14671. }
  14672. observerHandler(entries) {
  14673. entries.forEach((entry) => {
  14674. if (entry.isIntersecting) {
  14675. this.listeners.forEach((listener) => {
  14676. if (listener.el === entry.target) {
  14677. if (listener.state.loaded)
  14678. return this.observer.unobserve(listener.el);
  14679. listener.load();
  14680. }
  14681. });
  14682. }
  14683. });
  14684. }
  14685. elRenderer(listener, state, cache) {
  14686. if (!listener.el)
  14687. return;
  14688. const { el, bindType } = listener;
  14689. let src;
  14690. switch (state) {
  14691. case "loading":
  14692. src = listener.loading;
  14693. break;
  14694. case "error":
  14695. src = listener.error;
  14696. break;
  14697. default:
  14698. ({ src } = listener);
  14699. break;
  14700. }
  14701. if (bindType) {
  14702. el.style[bindType] = 'url("' + src + '")';
  14703. } else if (el.getAttribute("src") !== src) {
  14704. el.setAttribute("src", src);
  14705. }
  14706. el.setAttribute("lazy", state);
  14707. this.$emit(state, listener, cache);
  14708. this.options.adapter[state] && this.options.adapter[state](listener, this.options);
  14709. if (this.options.dispatchEvent) {
  14710. const event = new CustomEvent(state, {
  14711. detail: listener
  14712. });
  14713. el.dispatchEvent(event);
  14714. }
  14715. }
  14716. valueFormatter(value) {
  14717. let src = value;
  14718. let { loading, error } = this.options;
  14719. if (isObject(value)) {
  14720. if (process.env.NODE_ENV !== "production" && !value.src && !this.options.silent) {
  14721. console.error("[@vant/lazyload] miss src with " + value);
  14722. }
  14723. ({ src } = value);
  14724. loading = value.loading || this.options.loading;
  14725. error = value.error || this.options.error;
  14726. }
  14727. return {
  14728. src,
  14729. loading,
  14730. error
  14731. };
  14732. }
  14733. };
  14734. }
  14735. var stdin_default$2 = (lazy) => ({
  14736. props: {
  14737. tag: {
  14738. type: String,
  14739. default: "div"
  14740. }
  14741. },
  14742. emits: ["show"],
  14743. render() {
  14744. return h(
  14745. this.tag,
  14746. this.show && this.$slots.default ? this.$slots.default() : null
  14747. );
  14748. },
  14749. data() {
  14750. return {
  14751. el: null,
  14752. state: {
  14753. loaded: false
  14754. },
  14755. show: false
  14756. };
  14757. },
  14758. mounted() {
  14759. this.el = this.$el;
  14760. lazy.addLazyBox(this);
  14761. lazy.lazyLoadHandler();
  14762. },
  14763. beforeUnmount() {
  14764. lazy.removeComponent(this);
  14765. },
  14766. methods: {
  14767. checkInView() {
  14768. const rect = useRect(this.$el);
  14769. return inBrowser$1 && rect.top < window.innerHeight * lazy.options.preLoad && rect.bottom > 0 && rect.left < window.innerWidth * lazy.options.preLoad && rect.right > 0;
  14770. },
  14771. load() {
  14772. this.show = true;
  14773. this.state.loaded = true;
  14774. this.$emit("show", this);
  14775. },
  14776. destroy() {
  14777. return this.$destroy;
  14778. }
  14779. }
  14780. });
  14781. const defaultOptions = {
  14782. selector: "img"
  14783. };
  14784. class LazyContainer {
  14785. constructor({ el, binding, vnode, lazy }) {
  14786. this.el = null;
  14787. this.vnode = vnode;
  14788. this.binding = binding;
  14789. this.options = {};
  14790. this.lazy = lazy;
  14791. this.queue = [];
  14792. this.update({ el, binding });
  14793. }
  14794. update({ el, binding }) {
  14795. this.el = el;
  14796. this.options = Object.assign({}, defaultOptions, binding.value);
  14797. const imgs = this.getImgs();
  14798. imgs.forEach((el2) => {
  14799. this.lazy.add(
  14800. el2,
  14801. Object.assign({}, this.binding, {
  14802. value: {
  14803. src: "dataset" in el2 ? el2.dataset.src : el2.getAttribute("data-src"),
  14804. error: ("dataset" in el2 ? el2.dataset.error : el2.getAttribute("data-error")) || this.options.error,
  14805. loading: ("dataset" in el2 ? el2.dataset.loading : el2.getAttribute("data-loading")) || this.options.loading
  14806. }
  14807. }),
  14808. this.vnode
  14809. );
  14810. });
  14811. }
  14812. getImgs() {
  14813. return Array.from(this.el.querySelectorAll(this.options.selector));
  14814. }
  14815. clear() {
  14816. const imgs = this.getImgs();
  14817. imgs.forEach((el) => this.lazy.remove(el));
  14818. this.vnode = null;
  14819. this.binding = null;
  14820. this.lazy = null;
  14821. }
  14822. }
  14823. class LazyContainerManager {
  14824. constructor({ lazy }) {
  14825. this.lazy = lazy;
  14826. this.queue = [];
  14827. }
  14828. bind(el, binding, vnode) {
  14829. const container = new LazyContainer({
  14830. el,
  14831. binding,
  14832. vnode,
  14833. lazy: this.lazy
  14834. });
  14835. this.queue.push(container);
  14836. }
  14837. update(el, binding, vnode) {
  14838. const container = this.queue.find((item) => item.el === el);
  14839. if (!container)
  14840. return;
  14841. container.update({ el, binding, vnode });
  14842. }
  14843. unbind(el) {
  14844. const container = this.queue.find((item) => item.el === el);
  14845. if (!container)
  14846. return;
  14847. container.clear();
  14848. remove(this.queue, container);
  14849. }
  14850. }
  14851. var stdin_default$1 = (lazyManager) => ({
  14852. props: {
  14853. src: [String, Object],
  14854. tag: {
  14855. type: String,
  14856. default: "img"
  14857. }
  14858. },
  14859. render() {
  14860. var _a, _b;
  14861. return h(
  14862. this.tag,
  14863. {
  14864. src: this.renderSrc
  14865. },
  14866. (_b = (_a = this.$slots).default) == null ? void 0 : _b.call(_a)
  14867. );
  14868. },
  14869. data() {
  14870. return {
  14871. el: null,
  14872. options: {
  14873. src: "",
  14874. error: "",
  14875. loading: "",
  14876. attempt: lazyManager.options.attempt
  14877. },
  14878. state: {
  14879. loaded: false,
  14880. error: false,
  14881. attempt: 0
  14882. },
  14883. renderSrc: ""
  14884. };
  14885. },
  14886. watch: {
  14887. src() {
  14888. this.init();
  14889. lazyManager.addLazyBox(this);
  14890. lazyManager.lazyLoadHandler();
  14891. }
  14892. },
  14893. created() {
  14894. this.init();
  14895. this.renderSrc = this.options.loading;
  14896. },
  14897. mounted() {
  14898. this.el = this.$el;
  14899. lazyManager.addLazyBox(this);
  14900. lazyManager.lazyLoadHandler();
  14901. },
  14902. beforeUnmount() {
  14903. lazyManager.removeComponent(this);
  14904. },
  14905. methods: {
  14906. init() {
  14907. const { src, loading, error } = lazyManager.valueFormatter(this.src);
  14908. this.state.loaded = false;
  14909. this.options.src = src;
  14910. this.options.error = error;
  14911. this.options.loading = loading;
  14912. this.renderSrc = this.options.loading;
  14913. },
  14914. checkInView() {
  14915. const rect = useRect(this.$el);
  14916. return rect.top < window.innerHeight * lazyManager.options.preLoad && rect.bottom > 0 && rect.left < window.innerWidth * lazyManager.options.preLoad && rect.right > 0;
  14917. },
  14918. load(onFinish = noop) {
  14919. if (this.state.attempt > this.options.attempt - 1 && this.state.error) {
  14920. if (process.env.NODE_ENV !== "production" && !lazyManager.options.silent) {
  14921. console.log(
  14922. `[@vant/lazyload] ${this.options.src} tried too more than ${this.options.attempt} times`
  14923. );
  14924. }
  14925. onFinish();
  14926. return;
  14927. }
  14928. const { src } = this.options;
  14929. loadImageAsync(
  14930. { src },
  14931. ({ src: src2 }) => {
  14932. this.renderSrc = src2;
  14933. this.state.loaded = true;
  14934. },
  14935. () => {
  14936. this.state.attempt++;
  14937. this.renderSrc = this.options.error;
  14938. this.state.error = true;
  14939. }
  14940. );
  14941. }
  14942. }
  14943. });
  14944. const Lazyload = {
  14945. install(app, options = {}) {
  14946. const LazyClass = stdin_default$3();
  14947. const lazy = new LazyClass(options);
  14948. const lazyContainer = new LazyContainerManager({ lazy });
  14949. app.config.globalProperties.$Lazyload = lazy;
  14950. if (options.lazyComponent) {
  14951. app.component("LazyComponent", stdin_default$2(lazy));
  14952. }
  14953. if (options.lazyImage) {
  14954. app.component("LazyImage", stdin_default$1(lazy));
  14955. }
  14956. app.directive("lazy", {
  14957. beforeMount: lazy.add.bind(lazy),
  14958. updated: lazy.update.bind(lazy),
  14959. unmounted: lazy.remove.bind(lazy)
  14960. });
  14961. app.directive("lazy-container", {
  14962. beforeMount: lazyContainer.bind.bind(lazyContainer),
  14963. updated: lazyContainer.update.bind(lazyContainer),
  14964. unmounted: lazyContainer.unbind.bind(lazyContainer)
  14965. });
  14966. }
  14967. };
  14968. const version = "3.6.10";
  14969. function install(app) {
  14970. const components = [
  14971. ActionBar,
  14972. ActionBarButton,
  14973. ActionBarIcon,
  14974. ActionSheet,
  14975. AddressEdit,
  14976. AddressList,
  14977. Area,
  14978. Badge,
  14979. Button,
  14980. Calendar,
  14981. Card,
  14982. Cascader,
  14983. Cell,
  14984. CellGroup,
  14985. Checkbox,
  14986. CheckboxGroup,
  14987. Circle,
  14988. Col,
  14989. Collapse,
  14990. CollapseItem,
  14991. ConfigProvider,
  14992. ContactCard,
  14993. ContactEdit,
  14994. ContactList,
  14995. CountDown,
  14996. Coupon,
  14997. CouponCell,
  14998. CouponList,
  14999. DatetimePicker,
  15000. Dialog,
  15001. Divider,
  15002. DropdownItem,
  15003. DropdownMenu,
  15004. Empty,
  15005. Field,
  15006. Form,
  15007. Grid,
  15008. GridItem,
  15009. Icon,
  15010. Image$1,
  15011. ImagePreview,
  15012. IndexAnchor,
  15013. IndexBar,
  15014. List,
  15015. Loading,
  15016. Locale,
  15017. NavBar,
  15018. NoticeBar,
  15019. Notify,
  15020. NumberKeyboard,
  15021. Overlay,
  15022. Pagination,
  15023. PasswordInput,
  15024. Picker,
  15025. Popover,
  15026. Popup,
  15027. Progress,
  15028. PullRefresh,
  15029. Radio,
  15030. RadioGroup,
  15031. Rate,
  15032. Row,
  15033. Search,
  15034. ShareSheet,
  15035. Sidebar,
  15036. SidebarItem,
  15037. Skeleton,
  15038. Slider,
  15039. Space,
  15040. Step,
  15041. Stepper,
  15042. Steps,
  15043. Sticky,
  15044. SubmitBar,
  15045. Swipe,
  15046. SwipeCell,
  15047. SwipeItem,
  15048. Switch,
  15049. Tab,
  15050. Tabbar,
  15051. TabbarItem,
  15052. Tabs,
  15053. Tag,
  15054. Toast,
  15055. TreeSelect,
  15056. Uploader
  15057. ];
  15058. components.forEach((item) => {
  15059. if (item.install) {
  15060. app.use(item);
  15061. } else if (item.name) {
  15062. app.component(item.name, item);
  15063. }
  15064. });
  15065. }
  15066. var stdin_default = {
  15067. install,
  15068. version
  15069. };
  15070. export {
  15071. ActionBar,
  15072. ActionBarButton,
  15073. ActionBarIcon,
  15074. ActionSheet,
  15075. AddressEdit,
  15076. AddressList,
  15077. Area,
  15078. Badge,
  15079. Button,
  15080. Calendar,
  15081. Card,
  15082. Cascader,
  15083. Cell,
  15084. CellGroup,
  15085. Checkbox,
  15086. CheckboxGroup,
  15087. Circle,
  15088. Col,
  15089. Collapse,
  15090. CollapseItem,
  15091. ConfigProvider,
  15092. ContactCard,
  15093. ContactEdit,
  15094. ContactList,
  15095. CountDown,
  15096. Coupon,
  15097. CouponCell,
  15098. CouponList,
  15099. DatetimePicker,
  15100. Dialog,
  15101. Divider,
  15102. DropdownItem,
  15103. DropdownMenu,
  15104. Empty,
  15105. Field,
  15106. Form,
  15107. Grid,
  15108. GridItem,
  15109. Icon,
  15110. Image$1 as Image,
  15111. ImagePreview,
  15112. IndexAnchor,
  15113. IndexBar,
  15114. Lazyload,
  15115. List,
  15116. Loading,
  15117. Locale,
  15118. NavBar,
  15119. NoticeBar,
  15120. Notify,
  15121. NumberKeyboard,
  15122. Overlay,
  15123. Pagination,
  15124. PasswordInput,
  15125. Picker,
  15126. Popover,
  15127. Popup,
  15128. Progress,
  15129. PullRefresh,
  15130. Radio,
  15131. RadioGroup,
  15132. Rate,
  15133. Row,
  15134. Search,
  15135. ShareSheet,
  15136. Sidebar,
  15137. SidebarItem,
  15138. Skeleton,
  15139. Slider,
  15140. Space,
  15141. Step,
  15142. Stepper,
  15143. Steps,
  15144. Sticky,
  15145. SubmitBar,
  15146. Swipe,
  15147. SwipeCell,
  15148. SwipeItem,
  15149. Switch,
  15150. Tab,
  15151. Tabbar,
  15152. TabbarItem,
  15153. Tabs,
  15154. Tag,
  15155. Toast,
  15156. TreeSelect,
  15157. Uploader,
  15158. stdin_default as default,
  15159. install,
  15160. version
  15161. };