vant.js 493 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341
  1. (function(global, factory) {
  2. typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("vue")) : typeof define === "function" && define.amd ? define(["exports", "vue"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.vant = {}, global.Vue));
  3. })(this, function(exports2, vue) {
  4. "use strict";
  5. const isDef = (val) => val !== void 0 && val !== null;
  6. const isFunction = (val) => typeof val === "function";
  7. const isObject = (val) => val !== null && typeof val === "object";
  8. const isPromise = (val) => isObject(val) && isFunction(val.then) && isFunction(val.catch);
  9. const isDate = (val) => Object.prototype.toString.call(val) === "[object Date]" && !Number.isNaN(val.getTime());
  10. function isMobile(value) {
  11. value = value.replace(/[^-|\d]/g, "");
  12. return /^((\+86)|(86))?(1)\d{10}$/.test(value) || /^0[0-9-]{10,13}$/.test(value);
  13. }
  14. const isNumeric = (val) => typeof val === "number" || /^\d+(\.\d+)?$/.test(val);
  15. const isIOS$1 = () => inBrowser$1 ? /ios|iphone|ipad|ipod/.test(navigator.userAgent.toLowerCase()) : false;
  16. function noop() {
  17. }
  18. const extend = Object.assign;
  19. const inBrowser$1 = typeof window !== "undefined";
  20. function get(object, path) {
  21. const keys = path.split(".");
  22. let result = object;
  23. keys.forEach((key) => {
  24. var _a;
  25. result = isObject(result) ? (_a = result[key]) != null ? _a : "" : "";
  26. });
  27. return result;
  28. }
  29. function pick(obj, keys, ignoreUndefined) {
  30. return keys.reduce((ret, key) => {
  31. if (!ignoreUndefined || obj[key] !== void 0) {
  32. ret[key] = obj[key];
  33. }
  34. return ret;
  35. }, {});
  36. }
  37. const toArray = (item) => Array.isArray(item) ? item : [item];
  38. const unknownProp = null;
  39. const numericProp = [Number, String];
  40. const truthProp = {
  41. type: Boolean,
  42. default: true
  43. };
  44. const makeRequiredProp = (type) => ({
  45. type,
  46. required: true
  47. });
  48. const makeArrayProp = () => ({
  49. type: Array,
  50. default: () => []
  51. });
  52. const makeNumberProp = (defaultVal) => ({
  53. type: Number,
  54. default: defaultVal
  55. });
  56. const makeNumericProp = (defaultVal) => ({
  57. type: numericProp,
  58. default: defaultVal
  59. });
  60. const makeStringProp = (defaultVal) => ({
  61. type: String,
  62. default: defaultVal
  63. });
  64. var inBrowser = typeof window !== "undefined";
  65. function raf(fn) {
  66. return inBrowser ? requestAnimationFrame(fn) : -1;
  67. }
  68. function cancelRaf(id) {
  69. if (inBrowser) {
  70. cancelAnimationFrame(id);
  71. }
  72. }
  73. function doubleRaf(fn) {
  74. raf(() => raf(fn));
  75. }
  76. var isWindow = (val) => val === window;
  77. var makeDOMRect = (width2, height2) => ({
  78. top: 0,
  79. left: 0,
  80. right: width2,
  81. bottom: height2,
  82. width: width2,
  83. height: height2
  84. });
  85. var useRect = (elementOrRef) => {
  86. const element = vue.unref(elementOrRef);
  87. if (isWindow(element)) {
  88. const width2 = element.innerWidth;
  89. const height2 = element.innerHeight;
  90. return makeDOMRect(width2, height2);
  91. }
  92. if (element == null ? void 0 : element.getBoundingClientRect) {
  93. return element.getBoundingClientRect();
  94. }
  95. return makeDOMRect(0, 0);
  96. };
  97. function useToggle(defaultValue = false) {
  98. const state = vue.ref(defaultValue);
  99. const toggle = (value = !state.value) => {
  100. state.value = value;
  101. };
  102. return [state, toggle];
  103. }
  104. function useParent(key) {
  105. const parent = vue.inject(key, null);
  106. if (parent) {
  107. const instance2 = vue.getCurrentInstance();
  108. const { link, unlink, internalChildren } = parent;
  109. link(instance2);
  110. vue.onUnmounted(() => unlink(instance2));
  111. const index = vue.computed(() => internalChildren.indexOf(instance2));
  112. return {
  113. parent,
  114. index
  115. };
  116. }
  117. return {
  118. parent: null,
  119. index: vue.ref(-1)
  120. };
  121. }
  122. function flattenVNodes(children) {
  123. const result = [];
  124. const traverse = (children2) => {
  125. if (Array.isArray(children2)) {
  126. children2.forEach((child) => {
  127. var _a;
  128. if (vue.isVNode(child)) {
  129. result.push(child);
  130. if ((_a = child.component) == null ? void 0 : _a.subTree) {
  131. result.push(child.component.subTree);
  132. traverse(child.component.subTree.children);
  133. }
  134. if (child.children) {
  135. traverse(child.children);
  136. }
  137. }
  138. });
  139. }
  140. };
  141. traverse(children);
  142. return result;
  143. }
  144. function sortChildren(parent, publicChildren, internalChildren) {
  145. const vnodes = flattenVNodes(parent.subTree.children);
  146. internalChildren.sort(
  147. (a, b) => vnodes.indexOf(a.vnode) - vnodes.indexOf(b.vnode)
  148. );
  149. const orderedPublicChildren = internalChildren.map((item) => item.proxy);
  150. publicChildren.sort((a, b) => {
  151. const indexA = orderedPublicChildren.indexOf(a);
  152. const indexB = orderedPublicChildren.indexOf(b);
  153. return indexA - indexB;
  154. });
  155. }
  156. function useChildren(key) {
  157. const publicChildren = vue.reactive([]);
  158. const internalChildren = vue.reactive([]);
  159. const parent = vue.getCurrentInstance();
  160. const linkChildren = (value) => {
  161. const link = (child) => {
  162. if (child.proxy) {
  163. internalChildren.push(child);
  164. publicChildren.push(child.proxy);
  165. sortChildren(parent, publicChildren, internalChildren);
  166. }
  167. };
  168. const unlink = (child) => {
  169. const index = internalChildren.indexOf(child);
  170. publicChildren.splice(index, 1);
  171. internalChildren.splice(index, 1);
  172. };
  173. vue.provide(
  174. key,
  175. Object.assign(
  176. {
  177. link,
  178. unlink,
  179. children: publicChildren,
  180. internalChildren
  181. },
  182. value
  183. )
  184. );
  185. };
  186. return {
  187. children: publicChildren,
  188. linkChildren
  189. };
  190. }
  191. var SECOND = 1e3;
  192. var MINUTE = 60 * SECOND;
  193. var HOUR = 60 * MINUTE;
  194. var DAY = 24 * HOUR;
  195. function parseTime(time) {
  196. const days = Math.floor(time / DAY);
  197. const hours = Math.floor(time % DAY / HOUR);
  198. const minutes = Math.floor(time % HOUR / MINUTE);
  199. const seconds = Math.floor(time % MINUTE / SECOND);
  200. const milliseconds = Math.floor(time % SECOND);
  201. return {
  202. total: time,
  203. days,
  204. hours,
  205. minutes,
  206. seconds,
  207. milliseconds
  208. };
  209. }
  210. function isSameSecond(time1, time2) {
  211. return Math.floor(time1 / 1e3) === Math.floor(time2 / 1e3);
  212. }
  213. function useCountDown(options) {
  214. let rafId;
  215. let endTime;
  216. let counting;
  217. let deactivated;
  218. const remain = vue.ref(options.time);
  219. const current2 = vue.computed(() => parseTime(remain.value));
  220. const pause = () => {
  221. counting = false;
  222. cancelRaf(rafId);
  223. };
  224. const getCurrentRemain = () => Math.max(endTime - Date.now(), 0);
  225. const setRemain = (value) => {
  226. var _a, _b;
  227. remain.value = value;
  228. (_a = options.onChange) == null ? void 0 : _a.call(options, current2.value);
  229. if (value === 0) {
  230. pause();
  231. (_b = options.onFinish) == null ? void 0 : _b.call(options);
  232. }
  233. };
  234. const microTick = () => {
  235. rafId = raf(() => {
  236. if (counting) {
  237. setRemain(getCurrentRemain());
  238. if (remain.value > 0) {
  239. microTick();
  240. }
  241. }
  242. });
  243. };
  244. const macroTick = () => {
  245. rafId = raf(() => {
  246. if (counting) {
  247. const remainRemain = getCurrentRemain();
  248. if (!isSameSecond(remainRemain, remain.value) || remainRemain === 0) {
  249. setRemain(remainRemain);
  250. }
  251. if (remain.value > 0) {
  252. macroTick();
  253. }
  254. }
  255. });
  256. };
  257. const tick = () => {
  258. if (!inBrowser) {
  259. return;
  260. }
  261. if (options.millisecond) {
  262. microTick();
  263. } else {
  264. macroTick();
  265. }
  266. };
  267. const start2 = () => {
  268. if (!counting) {
  269. endTime = Date.now() + remain.value;
  270. counting = true;
  271. tick();
  272. }
  273. };
  274. const reset = (totalTime = options.time) => {
  275. pause();
  276. remain.value = totalTime;
  277. };
  278. vue.onBeforeUnmount(pause);
  279. vue.onActivated(() => {
  280. if (deactivated) {
  281. counting = true;
  282. deactivated = false;
  283. tick();
  284. }
  285. });
  286. vue.onDeactivated(() => {
  287. if (counting) {
  288. pause();
  289. deactivated = true;
  290. }
  291. });
  292. return {
  293. start: start2,
  294. pause,
  295. reset,
  296. current: current2
  297. };
  298. }
  299. function onMountedOrActivated(hook) {
  300. let mounted;
  301. vue.onMounted(() => {
  302. hook();
  303. vue.nextTick(() => {
  304. mounted = true;
  305. });
  306. });
  307. vue.onActivated(() => {
  308. if (mounted) {
  309. hook();
  310. }
  311. });
  312. }
  313. function useEventListener(type, listener, options = {}) {
  314. if (!inBrowser) {
  315. return;
  316. }
  317. const { target = window, passive: passive2 = false, capture = false } = options;
  318. let attached;
  319. const add = (target2) => {
  320. const element = vue.unref(target2);
  321. if (element && !attached) {
  322. element.addEventListener(type, listener, {
  323. capture,
  324. passive: passive2
  325. });
  326. attached = true;
  327. }
  328. };
  329. const remove2 = (target2) => {
  330. const element = vue.unref(target2);
  331. if (element && attached) {
  332. element.removeEventListener(type, listener, capture);
  333. attached = false;
  334. }
  335. };
  336. vue.onUnmounted(() => remove2(target));
  337. vue.onDeactivated(() => remove2(target));
  338. onMountedOrActivated(() => add(target));
  339. if (vue.isRef(target)) {
  340. vue.watch(target, (val, oldVal) => {
  341. remove2(oldVal);
  342. add(val);
  343. });
  344. }
  345. }
  346. function useClickAway(target, listener, options = {}) {
  347. if (!inBrowser) {
  348. return;
  349. }
  350. const { eventName = "click" } = options;
  351. const onClick = (event) => {
  352. const targets = Array.isArray(target) ? target : [target];
  353. const isClickAway = targets.every((item) => {
  354. const element = vue.unref(item);
  355. return element && !element.contains(event.target);
  356. });
  357. if (isClickAway) {
  358. listener(event);
  359. }
  360. };
  361. useEventListener(eventName, onClick, { target: document });
  362. }
  363. var width;
  364. var height;
  365. function useWindowSize() {
  366. if (!width) {
  367. width = vue.ref(0);
  368. height = vue.ref(0);
  369. if (inBrowser) {
  370. const update = () => {
  371. width.value = window.innerWidth;
  372. height.value = window.innerHeight;
  373. };
  374. update();
  375. window.addEventListener("resize", update, { passive: true });
  376. window.addEventListener("orientationchange", update, { passive: true });
  377. }
  378. }
  379. return { width, height };
  380. }
  381. var overflowScrollReg = /scroll|auto|overlay/i;
  382. var defaultRoot = inBrowser ? window : void 0;
  383. function isElement$1(node) {
  384. const ELEMENT_NODE_TYPE = 1;
  385. return node.tagName !== "HTML" && node.tagName !== "BODY" && node.nodeType === ELEMENT_NODE_TYPE;
  386. }
  387. function getScrollParent$1(el, root = defaultRoot) {
  388. let node = el;
  389. while (node && node !== root && isElement$1(node)) {
  390. const { overflowY } = window.getComputedStyle(node);
  391. if (overflowScrollReg.test(overflowY)) {
  392. return node;
  393. }
  394. node = node.parentNode;
  395. }
  396. return root;
  397. }
  398. function useScrollParent(el, root = defaultRoot) {
  399. const scrollParent = vue.ref();
  400. vue.onMounted(() => {
  401. if (el.value) {
  402. scrollParent.value = getScrollParent$1(el.value, root);
  403. }
  404. });
  405. return scrollParent;
  406. }
  407. var visibility;
  408. function usePageVisibility() {
  409. if (!visibility) {
  410. visibility = vue.ref("visible");
  411. if (inBrowser) {
  412. const update = () => {
  413. visibility.value = document.hidden ? "hidden" : "visible";
  414. };
  415. update();
  416. window.addEventListener("visibilitychange", update);
  417. }
  418. }
  419. return visibility;
  420. }
  421. var CUSTOM_FIELD_INJECTION_KEY = Symbol("van-field");
  422. function useCustomFieldValue(customValue) {
  423. const field = vue.inject(CUSTOM_FIELD_INJECTION_KEY, null);
  424. if (field && !field.customValue.value) {
  425. field.customValue.value = customValue;
  426. vue.watch(customValue, () => {
  427. field.resetValidation();
  428. field.validateWithTrigger("onChange");
  429. });
  430. }
  431. }
  432. function getScrollTop(el) {
  433. const top2 = "scrollTop" in el ? el.scrollTop : el.pageYOffset;
  434. return Math.max(top2, 0);
  435. }
  436. function setScrollTop(el, value) {
  437. if ("scrollTop" in el) {
  438. el.scrollTop = value;
  439. } else {
  440. el.scrollTo(el.scrollX, value);
  441. }
  442. }
  443. function getRootScrollTop() {
  444. return window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0;
  445. }
  446. function setRootScrollTop(value) {
  447. setScrollTop(window, value);
  448. setScrollTop(document.body, value);
  449. }
  450. function getElementTop(el, scroller) {
  451. if (el === window) {
  452. return 0;
  453. }
  454. const scrollTop = scroller ? getScrollTop(scroller) : getRootScrollTop();
  455. return useRect(el).top + scrollTop;
  456. }
  457. const isIOS = isIOS$1();
  458. function resetScroll() {
  459. if (isIOS) {
  460. setRootScrollTop(getRootScrollTop());
  461. }
  462. }
  463. const stopPropagation = (event) => event.stopPropagation();
  464. function preventDefault(event, isStopPropagation) {
  465. if (typeof event.cancelable !== "boolean" || event.cancelable) {
  466. event.preventDefault();
  467. }
  468. if (isStopPropagation) {
  469. stopPropagation(event);
  470. }
  471. }
  472. function isHidden(elementRef) {
  473. const el = vue.unref(elementRef);
  474. if (!el) {
  475. return false;
  476. }
  477. const style = window.getComputedStyle(el);
  478. const hidden = style.display === "none";
  479. const parentHidden = el.offsetParent === null && style.position !== "fixed";
  480. return hidden || parentHidden;
  481. }
  482. const { width: windowWidth, height: windowHeight } = useWindowSize();
  483. function addUnit(value) {
  484. if (isDef(value)) {
  485. return isNumeric(value) ? `${value}px` : String(value);
  486. }
  487. return void 0;
  488. }
  489. function getSizeStyle(originSize) {
  490. if (isDef(originSize)) {
  491. if (Array.isArray(originSize)) {
  492. return {
  493. width: addUnit(originSize[0]),
  494. height: addUnit(originSize[1])
  495. };
  496. }
  497. const size = addUnit(originSize);
  498. return {
  499. width: size,
  500. height: size
  501. };
  502. }
  503. }
  504. function getZIndexStyle(zIndex) {
  505. const style = {};
  506. if (zIndex !== void 0) {
  507. style.zIndex = +zIndex;
  508. }
  509. return style;
  510. }
  511. let rootFontSize;
  512. function getRootFontSize() {
  513. if (!rootFontSize) {
  514. const doc = document.documentElement;
  515. const fontSize = doc.style.fontSize || window.getComputedStyle(doc).fontSize;
  516. rootFontSize = parseFloat(fontSize);
  517. }
  518. return rootFontSize;
  519. }
  520. function convertRem(value) {
  521. value = value.replace(/rem/g, "");
  522. return +value * getRootFontSize();
  523. }
  524. function convertVw(value) {
  525. value = value.replace(/vw/g, "");
  526. return +value * windowWidth.value / 100;
  527. }
  528. function convertVh(value) {
  529. value = value.replace(/vh/g, "");
  530. return +value * windowHeight.value / 100;
  531. }
  532. function unitToPx(value) {
  533. if (typeof value === "number") {
  534. return value;
  535. }
  536. if (inBrowser$1) {
  537. if (value.includes("rem")) {
  538. return convertRem(value);
  539. }
  540. if (value.includes("vw")) {
  541. return convertVw(value);
  542. }
  543. if (value.includes("vh")) {
  544. return convertVh(value);
  545. }
  546. }
  547. return parseFloat(value);
  548. }
  549. const camelizeRE = /-(\w)/g;
  550. const camelize = (str) => str.replace(camelizeRE, (_, c) => c.toUpperCase());
  551. const kebabCase = (str) => str.replace(/([A-Z])/g, "-$1").toLowerCase().replace(/^-/, "");
  552. function padZero(num, targetLength = 2) {
  553. let str = num + "";
  554. while (str.length < targetLength) {
  555. str = "0" + str;
  556. }
  557. return str;
  558. }
  559. const clamp = (num, min, max) => Math.min(Math.max(num, min), max);
  560. function trimExtraChar(value, char, regExp) {
  561. const index = value.indexOf(char);
  562. if (index === -1) {
  563. return value;
  564. }
  565. if (char === "-" && index !== 0) {
  566. return value.slice(0, index);
  567. }
  568. return value.slice(0, index + 1) + value.slice(index).replace(regExp, "");
  569. }
  570. function formatNumber(value, allowDot = true, allowMinus = true) {
  571. if (allowDot) {
  572. value = trimExtraChar(value, ".", /\./g);
  573. } else {
  574. value = value.split(".")[0];
  575. }
  576. if (allowMinus) {
  577. value = trimExtraChar(value, "-", /-/g);
  578. } else {
  579. value = value.replace(/-/, "");
  580. }
  581. const regExp = allowDot ? /[^-0-9.]/g : /[^-0-9]/g;
  582. return value.replace(regExp, "");
  583. }
  584. function addNumber(num1, num2) {
  585. const cardinal = 10 ** 10;
  586. return Math.round((num1 + num2) * cardinal) / cardinal;
  587. }
  588. const { hasOwnProperty } = Object.prototype;
  589. function assignKey(to, from, key) {
  590. const val = from[key];
  591. if (!isDef(val)) {
  592. return;
  593. }
  594. if (!hasOwnProperty.call(to, key) || !isObject(val)) {
  595. to[key] = val;
  596. } else {
  597. to[key] = deepAssign(Object(to[key]), val);
  598. }
  599. }
  600. function deepAssign(to, from) {
  601. Object.keys(from).forEach((key) => {
  602. assignKey(to, from, key);
  603. });
  604. return to;
  605. }
  606. var stdin_default$1E = {
  607. name: "\u59D3\u540D",
  608. tel: "\u7535\u8BDD",
  609. save: "\u4FDD\u5B58",
  610. confirm: "\u786E\u8BA4",
  611. cancel: "\u53D6\u6D88",
  612. delete: "\u5220\u9664",
  613. loading: "\u52A0\u8F7D\u4E2D...",
  614. noCoupon: "\u6682\u65E0\u4F18\u60E0\u5238",
  615. nameEmpty: "\u8BF7\u586B\u5199\u59D3\u540D",
  616. addContact: "\u6DFB\u52A0\u8054\u7CFB\u4EBA",
  617. telInvalid: "\u8BF7\u586B\u5199\u6B63\u786E\u7684\u7535\u8BDD",
  618. vanCalendar: {
  619. end: "\u7ED3\u675F",
  620. start: "\u5F00\u59CB",
  621. title: "\u65E5\u671F\u9009\u62E9",
  622. weekdays: ["\u65E5", "\u4E00", "\u4E8C", "\u4E09", "\u56DB", "\u4E94", "\u516D"],
  623. monthTitle: (year, month) => `${year}\u5E74${month}\u6708`,
  624. rangePrompt: (maxRange) => `\u6700\u591A\u9009\u62E9 ${maxRange} \u5929`
  625. },
  626. vanCascader: {
  627. select: "\u8BF7\u9009\u62E9"
  628. },
  629. vanPagination: {
  630. prev: "\u4E0A\u4E00\u9875",
  631. next: "\u4E0B\u4E00\u9875"
  632. },
  633. vanPullRefresh: {
  634. pulling: "\u4E0B\u62C9\u5373\u53EF\u5237\u65B0...",
  635. loosing: "\u91CA\u653E\u5373\u53EF\u5237\u65B0..."
  636. },
  637. vanSubmitBar: {
  638. label: "\u5408\u8BA1:"
  639. },
  640. vanCoupon: {
  641. unlimited: "\u65E0\u95E8\u69DB",
  642. discount: (discount) => `${discount}\u6298`,
  643. condition: (condition) => `\u6EE1${condition}\u5143\u53EF\u7528`
  644. },
  645. vanCouponCell: {
  646. title: "\u4F18\u60E0\u5238",
  647. count: (count) => `${count}\u5F20\u53EF\u7528`
  648. },
  649. vanCouponList: {
  650. exchange: "\u5151\u6362",
  651. close: "\u4E0D\u4F7F\u7528",
  652. enable: "\u53EF\u7528",
  653. disabled: "\u4E0D\u53EF\u7528",
  654. placeholder: "\u8F93\u5165\u4F18\u60E0\u7801"
  655. },
  656. vanAddressEdit: {
  657. area: "\u5730\u533A",
  658. postal: "\u90AE\u653F\u7F16\u7801",
  659. areaEmpty: "\u8BF7\u9009\u62E9\u5730\u533A",
  660. addressEmpty: "\u8BF7\u586B\u5199\u8BE6\u7EC6\u5730\u5740",
  661. postalEmpty: "\u90AE\u653F\u7F16\u7801\u4E0D\u6B63\u786E",
  662. addressDetail: "\u8BE6\u7EC6\u5730\u5740",
  663. defaultAddress: "\u8BBE\u4E3A\u9ED8\u8BA4\u6536\u8D27\u5730\u5740"
  664. },
  665. vanAddressList: {
  666. add: "\u65B0\u589E\u5730\u5740"
  667. }
  668. };
  669. const lang = vue.ref("zh-CN");
  670. const messages = vue.reactive({
  671. "zh-CN": stdin_default$1E
  672. });
  673. const Locale = {
  674. messages() {
  675. return messages[lang.value];
  676. },
  677. use(newLang, newMessages) {
  678. lang.value = newLang;
  679. this.add({ [newLang]: newMessages });
  680. },
  681. add(newMessages = {}) {
  682. deepAssign(messages, newMessages);
  683. }
  684. };
  685. var stdin_default$1D = Locale;
  686. function createTranslate(name2) {
  687. const prefix = camelize(name2) + ".";
  688. return (path, ...args) => {
  689. const messages2 = stdin_default$1D.messages();
  690. const message = get(messages2, prefix + path) || get(messages2, path);
  691. return isFunction(message) ? message(...args) : message;
  692. };
  693. }
  694. function genBem(name2, mods) {
  695. if (!mods) {
  696. return "";
  697. }
  698. if (typeof mods === "string") {
  699. return ` ${name2}--${mods}`;
  700. }
  701. if (Array.isArray(mods)) {
  702. return mods.reduce(
  703. (ret, item) => ret + genBem(name2, item),
  704. ""
  705. );
  706. }
  707. return Object.keys(mods).reduce(
  708. (ret, key) => ret + (mods[key] ? genBem(name2, key) : ""),
  709. ""
  710. );
  711. }
  712. function createBEM(name2) {
  713. return (el, mods) => {
  714. if (el && typeof el !== "string") {
  715. mods = el;
  716. el = "";
  717. }
  718. el = el ? `${name2}__${el}` : name2;
  719. return `${el}${genBem(el, mods)}`;
  720. };
  721. }
  722. function createNamespace(name2) {
  723. const prefixedName = `van-${name2}`;
  724. return [
  725. prefixedName,
  726. createBEM(prefixedName),
  727. createTranslate(prefixedName)
  728. ];
  729. }
  730. const BORDER = "van-hairline";
  731. const BORDER_TOP = `${BORDER}--top`;
  732. const BORDER_LEFT = `${BORDER}--left`;
  733. const BORDER_BOTTOM = `${BORDER}--bottom`;
  734. const BORDER_SURROUND = `${BORDER}--surround`;
  735. const BORDER_TOP_BOTTOM = `${BORDER}--top-bottom`;
  736. const BORDER_UNSET_TOP_BOTTOM = `${BORDER}-unset--top-bottom`;
  737. const HAPTICS_FEEDBACK = "van-haptics-feedback";
  738. const FORM_KEY = Symbol("van-form");
  739. function callInterceptor(interceptor, {
  740. args = [],
  741. done,
  742. canceled
  743. }) {
  744. if (interceptor) {
  745. const returnVal = interceptor.apply(null, args);
  746. if (isPromise(returnVal)) {
  747. returnVal.then((value) => {
  748. if (value) {
  749. done();
  750. } else if (canceled) {
  751. canceled();
  752. }
  753. }).catch(noop);
  754. } else if (returnVal) {
  755. done();
  756. } else if (canceled) {
  757. canceled();
  758. }
  759. } else {
  760. done();
  761. }
  762. }
  763. function withInstall(options) {
  764. options.install = (app) => {
  765. const { name: name2 } = options;
  766. if (name2) {
  767. app.component(name2, options);
  768. app.component(camelize(`-${name2}`), options);
  769. }
  770. };
  771. return options;
  772. }
  773. const POPUP_TOGGLE_KEY = Symbol();
  774. function onPopupReopen(callback) {
  775. const popupToggleStatus = vue.inject(POPUP_TOGGLE_KEY, null);
  776. if (popupToggleStatus) {
  777. vue.watch(popupToggleStatus, (show) => {
  778. if (show) {
  779. callback();
  780. }
  781. });
  782. }
  783. }
  784. const useHeight = (element, withSafeArea) => {
  785. const height2 = vue.ref();
  786. const setHeight = () => {
  787. height2.value = useRect(element).height;
  788. };
  789. vue.onMounted(() => {
  790. vue.nextTick(setHeight);
  791. if (withSafeArea) {
  792. for (let i = 1; i <= 3; i++) {
  793. setTimeout(setHeight, 100 * i);
  794. }
  795. }
  796. });
  797. onPopupReopen(() => vue.nextTick(setHeight));
  798. return height2;
  799. };
  800. function usePlaceholder(contentRef, bem2) {
  801. const height2 = useHeight(contentRef, true);
  802. return (renderContent) => vue.createVNode("div", {
  803. "class": bem2("placeholder"),
  804. "style": {
  805. height: height2.value ? `${height2.value}px` : void 0
  806. }
  807. }, [renderContent()]);
  808. }
  809. const [name$1v, bem$1r] = createNamespace("action-bar");
  810. const ACTION_BAR_KEY = Symbol(name$1v);
  811. const actionBarProps = {
  812. placeholder: Boolean,
  813. safeAreaInsetBottom: truthProp
  814. };
  815. var stdin_default$1C = vue.defineComponent({
  816. name: name$1v,
  817. props: actionBarProps,
  818. setup(props, {
  819. slots
  820. }) {
  821. const root = vue.ref();
  822. const renderPlaceholder = usePlaceholder(root, bem$1r);
  823. const {
  824. linkChildren
  825. } = useChildren(ACTION_BAR_KEY);
  826. linkChildren();
  827. const renderActionBar = () => {
  828. var _a;
  829. return vue.createVNode("div", {
  830. "ref": root,
  831. "class": [bem$1r(), {
  832. "van-safe-area-bottom": props.safeAreaInsetBottom
  833. }]
  834. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  835. };
  836. return () => {
  837. if (props.placeholder) {
  838. return renderPlaceholder(renderActionBar);
  839. }
  840. return renderActionBar();
  841. };
  842. }
  843. });
  844. const ActionBar = withInstall(stdin_default$1C);
  845. function useExpose(apis) {
  846. const instance2 = vue.getCurrentInstance();
  847. if (instance2) {
  848. extend(instance2.proxy, apis);
  849. }
  850. }
  851. const routeProps = {
  852. to: [String, Object],
  853. url: String,
  854. replace: Boolean
  855. };
  856. function route({
  857. to,
  858. url,
  859. replace,
  860. $router: router
  861. }) {
  862. if (to && router) {
  863. router[replace ? "replace" : "push"](to);
  864. } else if (url) {
  865. replace ? location.replace(url) : location.href = url;
  866. }
  867. }
  868. function useRoute() {
  869. const vm = vue.getCurrentInstance().proxy;
  870. return () => route(vm);
  871. }
  872. const [name$1u, bem$1q] = createNamespace("badge");
  873. const badgeProps = {
  874. dot: Boolean,
  875. max: numericProp,
  876. tag: makeStringProp("div"),
  877. color: String,
  878. offset: Array,
  879. content: numericProp,
  880. showZero: truthProp,
  881. position: makeStringProp("top-right")
  882. };
  883. var stdin_default$1B = vue.defineComponent({
  884. name: name$1u,
  885. props: badgeProps,
  886. setup(props, {
  887. slots
  888. }) {
  889. const hasContent = () => {
  890. if (slots.content) {
  891. return true;
  892. }
  893. const {
  894. content,
  895. showZero
  896. } = props;
  897. return isDef(content) && content !== "" && (showZero || content !== 0 && content !== "0");
  898. };
  899. const renderContent = () => {
  900. const {
  901. dot,
  902. max,
  903. content
  904. } = props;
  905. if (!dot && hasContent()) {
  906. if (slots.content) {
  907. return slots.content();
  908. }
  909. if (isDef(max) && isNumeric(content) && +content > max) {
  910. return `${max}+`;
  911. }
  912. return content;
  913. }
  914. };
  915. const style = vue.computed(() => {
  916. const style2 = {
  917. background: props.color
  918. };
  919. if (props.offset) {
  920. const [x, y] = props.offset;
  921. if (slots.default) {
  922. style2.top = addUnit(y);
  923. if (typeof x === "number") {
  924. style2.right = addUnit(-x);
  925. } else {
  926. style2.right = x.startsWith("-") ? x.replace("-", "") : `-${x}`;
  927. }
  928. } else {
  929. style2.marginTop = addUnit(y);
  930. style2.marginLeft = addUnit(x);
  931. }
  932. }
  933. return style2;
  934. });
  935. const renderBadge = () => {
  936. if (hasContent() || props.dot) {
  937. return vue.createVNode("div", {
  938. "class": bem$1q([props.position, {
  939. dot: props.dot,
  940. fixed: !!slots.default
  941. }]),
  942. "style": style.value
  943. }, [renderContent()]);
  944. }
  945. };
  946. return () => {
  947. if (slots.default) {
  948. const {
  949. tag
  950. } = props;
  951. return vue.createVNode(tag, {
  952. "class": bem$1q("wrapper")
  953. }, {
  954. default: () => [slots.default(), renderBadge()]
  955. });
  956. }
  957. return renderBadge();
  958. };
  959. }
  960. });
  961. const Badge = withInstall(stdin_default$1B);
  962. let globalZIndex = 2e3;
  963. const useGlobalZIndex = () => ++globalZIndex;
  964. const setGlobalZIndex = (val) => {
  965. globalZIndex = val;
  966. };
  967. const [name$1t, bem$1p] = createNamespace("config-provider");
  968. const CONFIG_PROVIDER_KEY = Symbol(name$1t);
  969. const configProviderProps = {
  970. tag: makeStringProp("div"),
  971. zIndex: Number,
  972. themeVars: Object,
  973. iconPrefix: String
  974. };
  975. function mapThemeVarsToCSSVars(themeVars) {
  976. const cssVars = {};
  977. Object.keys(themeVars).forEach((key) => {
  978. cssVars[`--van-${kebabCase(key)}`] = themeVars[key];
  979. });
  980. return cssVars;
  981. }
  982. var stdin_default$1A = vue.defineComponent({
  983. name: name$1t,
  984. props: configProviderProps,
  985. setup(props, {
  986. slots
  987. }) {
  988. const style = vue.computed(() => {
  989. if (props.themeVars) {
  990. return mapThemeVarsToCSSVars(props.themeVars);
  991. }
  992. });
  993. vue.provide(CONFIG_PROVIDER_KEY, props);
  994. vue.watchEffect(() => {
  995. if (props.zIndex !== void 0) {
  996. setGlobalZIndex(props.zIndex);
  997. }
  998. });
  999. return () => vue.createVNode(props.tag, {
  1000. "class": bem$1p(),
  1001. "style": style.value
  1002. }, {
  1003. default: () => {
  1004. var _a;
  1005. return [(_a = slots.default) == null ? void 0 : _a.call(slots)];
  1006. }
  1007. });
  1008. }
  1009. });
  1010. const [name$1s, bem$1o] = createNamespace("icon");
  1011. const isImage = (name2) => name2 == null ? void 0 : name2.includes("/");
  1012. const iconProps = {
  1013. dot: Boolean,
  1014. tag: makeStringProp("i"),
  1015. name: String,
  1016. size: numericProp,
  1017. badge: numericProp,
  1018. color: String,
  1019. badgeProps: Object,
  1020. classPrefix: String
  1021. };
  1022. var stdin_default$1z = vue.defineComponent({
  1023. name: name$1s,
  1024. props: iconProps,
  1025. setup(props, {
  1026. slots
  1027. }) {
  1028. const config = vue.inject(CONFIG_PROVIDER_KEY, null);
  1029. const classPrefix = vue.computed(() => props.classPrefix || (config == null ? void 0 : config.iconPrefix) || bem$1o());
  1030. return () => {
  1031. const {
  1032. tag,
  1033. dot,
  1034. name: name2,
  1035. size,
  1036. badge,
  1037. color
  1038. } = props;
  1039. const isImageIcon = isImage(name2);
  1040. return vue.createVNode(Badge, vue.mergeProps({
  1041. "dot": dot,
  1042. "tag": tag,
  1043. "class": [classPrefix.value, isImageIcon ? "" : `${classPrefix.value}-${name2}`],
  1044. "style": {
  1045. color,
  1046. fontSize: addUnit(size)
  1047. },
  1048. "content": badge
  1049. }, props.badgeProps), {
  1050. default: () => {
  1051. var _a;
  1052. return [(_a = slots.default) == null ? void 0 : _a.call(slots), isImageIcon && vue.createVNode("img", {
  1053. "class": bem$1o("image"),
  1054. "src": name2
  1055. }, null)];
  1056. }
  1057. });
  1058. };
  1059. }
  1060. });
  1061. const Icon = withInstall(stdin_default$1z);
  1062. const [name$1r, bem$1n] = createNamespace("loading");
  1063. const SpinIcon = Array(12).fill(null).map((_, index) => vue.createVNode("i", {
  1064. "class": bem$1n("line", String(index + 1))
  1065. }, null));
  1066. const CircularIcon = vue.createVNode("svg", {
  1067. "class": bem$1n("circular"),
  1068. "viewBox": "25 25 50 50"
  1069. }, [vue.createVNode("circle", {
  1070. "cx": "50",
  1071. "cy": "50",
  1072. "r": "20",
  1073. "fill": "none"
  1074. }, null)]);
  1075. const loadingProps = {
  1076. size: numericProp,
  1077. type: makeStringProp("circular"),
  1078. color: String,
  1079. vertical: Boolean,
  1080. textSize: numericProp,
  1081. textColor: String
  1082. };
  1083. var stdin_default$1y = vue.defineComponent({
  1084. name: name$1r,
  1085. props: loadingProps,
  1086. setup(props, {
  1087. slots
  1088. }) {
  1089. const spinnerStyle = vue.computed(() => extend({
  1090. color: props.color
  1091. }, getSizeStyle(props.size)));
  1092. const renderText = () => {
  1093. var _a;
  1094. if (slots.default) {
  1095. return vue.createVNode("span", {
  1096. "class": bem$1n("text"),
  1097. "style": {
  1098. fontSize: addUnit(props.textSize),
  1099. color: (_a = props.textColor) != null ? _a : props.color
  1100. }
  1101. }, [slots.default()]);
  1102. }
  1103. };
  1104. return () => {
  1105. const {
  1106. type,
  1107. vertical
  1108. } = props;
  1109. return vue.createVNode("div", {
  1110. "class": bem$1n([type, {
  1111. vertical
  1112. }]),
  1113. "aria-live": "polite",
  1114. "aria-busy": true
  1115. }, [vue.createVNode("span", {
  1116. "class": bem$1n("spinner", type),
  1117. "style": spinnerStyle.value
  1118. }, [type === "spinner" ? SpinIcon : CircularIcon]), renderText()]);
  1119. };
  1120. }
  1121. });
  1122. const Loading = withInstall(stdin_default$1y);
  1123. const [name$1q, bem$1m] = createNamespace("button");
  1124. const buttonProps = extend({}, routeProps, {
  1125. tag: makeStringProp("button"),
  1126. text: String,
  1127. icon: String,
  1128. type: makeStringProp("default"),
  1129. size: makeStringProp("normal"),
  1130. color: String,
  1131. block: Boolean,
  1132. plain: Boolean,
  1133. round: Boolean,
  1134. square: Boolean,
  1135. loading: Boolean,
  1136. hairline: Boolean,
  1137. disabled: Boolean,
  1138. iconPrefix: String,
  1139. nativeType: makeStringProp("button"),
  1140. loadingSize: numericProp,
  1141. loadingText: String,
  1142. loadingType: String,
  1143. iconPosition: makeStringProp("left")
  1144. });
  1145. var stdin_default$1x = vue.defineComponent({
  1146. name: name$1q,
  1147. props: buttonProps,
  1148. emits: ["click"],
  1149. setup(props, {
  1150. emit,
  1151. slots
  1152. }) {
  1153. const route2 = useRoute();
  1154. const renderLoadingIcon = () => {
  1155. if (slots.loading) {
  1156. return slots.loading();
  1157. }
  1158. return vue.createVNode(Loading, {
  1159. "size": props.loadingSize,
  1160. "type": props.loadingType,
  1161. "class": bem$1m("loading")
  1162. }, null);
  1163. };
  1164. const renderIcon = () => {
  1165. if (props.loading) {
  1166. return renderLoadingIcon();
  1167. }
  1168. if (slots.icon) {
  1169. return vue.createVNode("div", {
  1170. "class": bem$1m("icon")
  1171. }, [slots.icon()]);
  1172. }
  1173. if (props.icon) {
  1174. return vue.createVNode(Icon, {
  1175. "name": props.icon,
  1176. "class": bem$1m("icon"),
  1177. "classPrefix": props.iconPrefix
  1178. }, null);
  1179. }
  1180. };
  1181. const renderText = () => {
  1182. let text;
  1183. if (props.loading) {
  1184. text = props.loadingText;
  1185. } else {
  1186. text = slots.default ? slots.default() : props.text;
  1187. }
  1188. if (text) {
  1189. return vue.createVNode("span", {
  1190. "class": bem$1m("text")
  1191. }, [text]);
  1192. }
  1193. };
  1194. const getStyle = () => {
  1195. const {
  1196. color,
  1197. plain
  1198. } = props;
  1199. if (color) {
  1200. const style = {
  1201. color: plain ? color : "white"
  1202. };
  1203. if (!plain) {
  1204. style.background = color;
  1205. }
  1206. if (color.includes("gradient")) {
  1207. style.border = 0;
  1208. } else {
  1209. style.borderColor = color;
  1210. }
  1211. return style;
  1212. }
  1213. };
  1214. const onClick = (event) => {
  1215. if (props.loading) {
  1216. preventDefault(event);
  1217. } else if (!props.disabled) {
  1218. emit("click", event);
  1219. route2();
  1220. }
  1221. };
  1222. return () => {
  1223. const {
  1224. tag,
  1225. type,
  1226. size,
  1227. block,
  1228. round: round2,
  1229. plain,
  1230. square,
  1231. loading,
  1232. disabled,
  1233. hairline,
  1234. nativeType,
  1235. iconPosition
  1236. } = props;
  1237. const classes = [bem$1m([type, size, {
  1238. plain,
  1239. block,
  1240. round: round2,
  1241. square,
  1242. loading,
  1243. disabled,
  1244. hairline
  1245. }]), {
  1246. [BORDER_SURROUND]: hairline
  1247. }];
  1248. return vue.createVNode(tag, {
  1249. "type": nativeType,
  1250. "class": classes,
  1251. "style": getStyle(),
  1252. "disabled": disabled,
  1253. "onClick": onClick
  1254. }, {
  1255. default: () => [vue.createVNode("div", {
  1256. "class": bem$1m("content")
  1257. }, [iconPosition === "left" && renderIcon(), renderText(), iconPosition === "right" && renderIcon()])]
  1258. });
  1259. };
  1260. }
  1261. });
  1262. const Button = withInstall(stdin_default$1x);
  1263. const [name$1p, bem$1l] = createNamespace("action-bar-button");
  1264. const actionBarButtonProps = extend({}, routeProps, {
  1265. type: String,
  1266. text: String,
  1267. icon: String,
  1268. color: String,
  1269. loading: Boolean,
  1270. disabled: Boolean
  1271. });
  1272. var stdin_default$1w = vue.defineComponent({
  1273. name: name$1p,
  1274. props: actionBarButtonProps,
  1275. setup(props, {
  1276. slots
  1277. }) {
  1278. const route2 = useRoute();
  1279. const {
  1280. parent,
  1281. index
  1282. } = useParent(ACTION_BAR_KEY);
  1283. const isFirst = vue.computed(() => {
  1284. if (parent) {
  1285. const prev = parent.children[index.value - 1];
  1286. return !(prev && "isButton" in prev);
  1287. }
  1288. });
  1289. const isLast = vue.computed(() => {
  1290. if (parent) {
  1291. const next = parent.children[index.value + 1];
  1292. return !(next && "isButton" in next);
  1293. }
  1294. });
  1295. useExpose({
  1296. isButton: true
  1297. });
  1298. return () => {
  1299. const {
  1300. type,
  1301. icon,
  1302. text,
  1303. color,
  1304. loading,
  1305. disabled
  1306. } = props;
  1307. return vue.createVNode(Button, {
  1308. "class": bem$1l([type, {
  1309. last: isLast.value,
  1310. first: isFirst.value
  1311. }]),
  1312. "size": "large",
  1313. "type": type,
  1314. "icon": icon,
  1315. "color": color,
  1316. "loading": loading,
  1317. "disabled": disabled,
  1318. "onClick": route2
  1319. }, {
  1320. default: () => [slots.default ? slots.default() : text]
  1321. });
  1322. };
  1323. }
  1324. });
  1325. const ActionBarButton = withInstall(stdin_default$1w);
  1326. const [name$1o, bem$1k] = createNamespace("action-bar-icon");
  1327. const actionBarIconProps = extend({}, routeProps, {
  1328. dot: Boolean,
  1329. text: String,
  1330. icon: String,
  1331. color: String,
  1332. badge: numericProp,
  1333. iconClass: unknownProp,
  1334. badgeProps: Object,
  1335. iconPrefix: String
  1336. });
  1337. var stdin_default$1v = vue.defineComponent({
  1338. name: name$1o,
  1339. props: actionBarIconProps,
  1340. setup(props, {
  1341. slots
  1342. }) {
  1343. const route2 = useRoute();
  1344. useParent(ACTION_BAR_KEY);
  1345. const renderIcon = () => {
  1346. const {
  1347. dot,
  1348. badge,
  1349. icon,
  1350. color,
  1351. iconClass,
  1352. badgeProps: badgeProps2,
  1353. iconPrefix
  1354. } = props;
  1355. if (slots.icon) {
  1356. return vue.createVNode(Badge, vue.mergeProps({
  1357. "dot": dot,
  1358. "class": bem$1k("icon"),
  1359. "content": badge
  1360. }, badgeProps2), {
  1361. default: slots.icon
  1362. });
  1363. }
  1364. return vue.createVNode(Icon, {
  1365. "tag": "div",
  1366. "dot": dot,
  1367. "name": icon,
  1368. "badge": badge,
  1369. "color": color,
  1370. "class": [bem$1k("icon"), iconClass],
  1371. "badgeProps": badgeProps2,
  1372. "classPrefix": iconPrefix
  1373. }, null);
  1374. };
  1375. return () => vue.createVNode("div", {
  1376. "role": "button",
  1377. "class": bem$1k(),
  1378. "tabindex": 0,
  1379. "onClick": route2
  1380. }, [renderIcon(), slots.default ? slots.default() : props.text]);
  1381. }
  1382. });
  1383. const ActionBarIcon = withInstall(stdin_default$1v);
  1384. const popupSharedProps = {
  1385. show: Boolean,
  1386. zIndex: numericProp,
  1387. overlay: truthProp,
  1388. duration: numericProp,
  1389. teleport: [String, Object],
  1390. lockScroll: truthProp,
  1391. lazyRender: truthProp,
  1392. beforeClose: Function,
  1393. overlayStyle: Object,
  1394. overlayClass: unknownProp,
  1395. transitionAppear: Boolean,
  1396. closeOnClickOverlay: truthProp
  1397. };
  1398. const popupSharedPropKeys = Object.keys(
  1399. popupSharedProps
  1400. );
  1401. function getDirection(x, y) {
  1402. if (x > y) {
  1403. return "horizontal";
  1404. }
  1405. if (y > x) {
  1406. return "vertical";
  1407. }
  1408. return "";
  1409. }
  1410. function useTouch() {
  1411. const startX = vue.ref(0);
  1412. const startY = vue.ref(0);
  1413. const deltaX = vue.ref(0);
  1414. const deltaY = vue.ref(0);
  1415. const offsetX = vue.ref(0);
  1416. const offsetY = vue.ref(0);
  1417. const direction = vue.ref("");
  1418. const isVertical = () => direction.value === "vertical";
  1419. const isHorizontal = () => direction.value === "horizontal";
  1420. const reset = () => {
  1421. deltaX.value = 0;
  1422. deltaY.value = 0;
  1423. offsetX.value = 0;
  1424. offsetY.value = 0;
  1425. direction.value = "";
  1426. };
  1427. const start2 = (event) => {
  1428. reset();
  1429. startX.value = event.touches[0].clientX;
  1430. startY.value = event.touches[0].clientY;
  1431. };
  1432. const move = (event) => {
  1433. const touch = event.touches[0];
  1434. deltaX.value = (touch.clientX < 0 ? 0 : touch.clientX) - startX.value;
  1435. deltaY.value = touch.clientY - startY.value;
  1436. offsetX.value = Math.abs(deltaX.value);
  1437. offsetY.value = Math.abs(deltaY.value);
  1438. const LOCK_DIRECTION_DISTANCE = 10;
  1439. if (!direction.value || offsetX.value < LOCK_DIRECTION_DISTANCE && offsetY.value < LOCK_DIRECTION_DISTANCE) {
  1440. direction.value = getDirection(offsetX.value, offsetY.value);
  1441. }
  1442. };
  1443. return {
  1444. move,
  1445. start: start2,
  1446. reset,
  1447. startX,
  1448. startY,
  1449. deltaX,
  1450. deltaY,
  1451. offsetX,
  1452. offsetY,
  1453. direction,
  1454. isVertical,
  1455. isHorizontal
  1456. };
  1457. }
  1458. let totalLockCount = 0;
  1459. const BODY_LOCK_CLASS = "van-overflow-hidden";
  1460. function useLockScroll(rootRef, shouldLock) {
  1461. const touch = useTouch();
  1462. const DIRECTION_UP = "01";
  1463. const DIRECTION_DOWN = "10";
  1464. const onTouchMove = (event) => {
  1465. touch.move(event);
  1466. const direction = touch.deltaY.value > 0 ? DIRECTION_DOWN : DIRECTION_UP;
  1467. const el = getScrollParent$1(
  1468. event.target,
  1469. rootRef.value
  1470. );
  1471. const { scrollHeight, offsetHeight, scrollTop } = el;
  1472. let status = "11";
  1473. if (scrollTop === 0) {
  1474. status = offsetHeight >= scrollHeight ? "00" : "01";
  1475. } else if (scrollTop + offsetHeight >= scrollHeight) {
  1476. status = "10";
  1477. }
  1478. if (status !== "11" && touch.isVertical() && !(parseInt(status, 2) & parseInt(direction, 2))) {
  1479. preventDefault(event, true);
  1480. }
  1481. };
  1482. const lock = () => {
  1483. document.addEventListener("touchstart", touch.start);
  1484. document.addEventListener("touchmove", onTouchMove, { passive: false });
  1485. if (!totalLockCount) {
  1486. document.body.classList.add(BODY_LOCK_CLASS);
  1487. }
  1488. totalLockCount++;
  1489. };
  1490. const unlock = () => {
  1491. if (totalLockCount) {
  1492. document.removeEventListener("touchstart", touch.start);
  1493. document.removeEventListener("touchmove", onTouchMove);
  1494. totalLockCount--;
  1495. if (!totalLockCount) {
  1496. document.body.classList.remove(BODY_LOCK_CLASS);
  1497. }
  1498. }
  1499. };
  1500. const init = () => shouldLock() && lock();
  1501. const destroy = () => shouldLock() && unlock();
  1502. onMountedOrActivated(init);
  1503. vue.onDeactivated(destroy);
  1504. vue.onBeforeUnmount(destroy);
  1505. vue.watch(shouldLock, (value) => {
  1506. value ? lock() : unlock();
  1507. });
  1508. }
  1509. function useLazyRender(show) {
  1510. const inited = vue.ref(false);
  1511. vue.watch(
  1512. show,
  1513. (value) => {
  1514. if (value) {
  1515. inited.value = value;
  1516. }
  1517. },
  1518. { immediate: true }
  1519. );
  1520. return (render) => () => inited.value ? render() : null;
  1521. }
  1522. const [name$1n, bem$1j] = createNamespace("overlay");
  1523. const overlayProps = {
  1524. show: Boolean,
  1525. zIndex: numericProp,
  1526. duration: numericProp,
  1527. className: unknownProp,
  1528. lockScroll: truthProp,
  1529. lazyRender: truthProp,
  1530. customStyle: Object
  1531. };
  1532. var stdin_default$1u = vue.defineComponent({
  1533. name: name$1n,
  1534. props: overlayProps,
  1535. setup(props, {
  1536. slots
  1537. }) {
  1538. const root = vue.ref();
  1539. const lazyRender = useLazyRender(() => props.show || !props.lazyRender);
  1540. const onTouchMove = (event) => {
  1541. if (props.lockScroll) {
  1542. preventDefault(event, true);
  1543. }
  1544. };
  1545. const renderOverlay = lazyRender(() => {
  1546. var _a;
  1547. const style = extend(getZIndexStyle(props.zIndex), props.customStyle);
  1548. if (isDef(props.duration)) {
  1549. style.animationDuration = `${props.duration}s`;
  1550. }
  1551. return vue.withDirectives(vue.createVNode("div", {
  1552. "ref": root,
  1553. "style": style,
  1554. "class": [bem$1j(), props.className]
  1555. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]), [[vue.vShow, props.show]]);
  1556. });
  1557. useEventListener("touchmove", onTouchMove, {
  1558. target: root
  1559. });
  1560. return () => vue.createVNode(vue.Transition, {
  1561. "name": "van-fade",
  1562. "appear": true
  1563. }, {
  1564. default: renderOverlay
  1565. });
  1566. }
  1567. });
  1568. const Overlay = withInstall(stdin_default$1u);
  1569. const popupProps$2 = extend({}, popupSharedProps, {
  1570. round: Boolean,
  1571. position: makeStringProp("center"),
  1572. closeIcon: makeStringProp("cross"),
  1573. closeable: Boolean,
  1574. transition: String,
  1575. iconPrefix: String,
  1576. closeOnPopstate: Boolean,
  1577. closeIconPosition: makeStringProp("top-right"),
  1578. safeAreaInsetTop: Boolean,
  1579. safeAreaInsetBottom: Boolean
  1580. });
  1581. const [name$1m, bem$1i] = createNamespace("popup");
  1582. var stdin_default$1t = vue.defineComponent({
  1583. name: name$1m,
  1584. inheritAttrs: false,
  1585. props: popupProps$2,
  1586. emits: ["open", "close", "opened", "closed", "keydown", "update:show", "click-overlay", "click-close-icon"],
  1587. setup(props, {
  1588. emit,
  1589. attrs,
  1590. slots
  1591. }) {
  1592. let opened;
  1593. let shouldReopen;
  1594. const zIndex = vue.ref();
  1595. const popupRef = vue.ref();
  1596. const lazyRender = useLazyRender(() => props.show || !props.lazyRender);
  1597. const style = vue.computed(() => {
  1598. const style2 = {
  1599. zIndex: zIndex.value
  1600. };
  1601. if (isDef(props.duration)) {
  1602. const key = props.position === "center" ? "animationDuration" : "transitionDuration";
  1603. style2[key] = `${props.duration}s`;
  1604. }
  1605. return style2;
  1606. });
  1607. const open = () => {
  1608. if (!opened) {
  1609. opened = true;
  1610. zIndex.value = props.zIndex !== void 0 ? +props.zIndex : useGlobalZIndex();
  1611. emit("open");
  1612. }
  1613. };
  1614. const close = () => {
  1615. if (opened) {
  1616. callInterceptor(props.beforeClose, {
  1617. done() {
  1618. opened = false;
  1619. emit("close");
  1620. emit("update:show", false);
  1621. }
  1622. });
  1623. }
  1624. };
  1625. const onClickOverlay = (event) => {
  1626. emit("click-overlay", event);
  1627. if (props.closeOnClickOverlay) {
  1628. close();
  1629. }
  1630. };
  1631. const renderOverlay = () => {
  1632. if (props.overlay) {
  1633. return vue.createVNode(Overlay, {
  1634. "show": props.show,
  1635. "class": props.overlayClass,
  1636. "zIndex": zIndex.value,
  1637. "duration": props.duration,
  1638. "customStyle": props.overlayStyle,
  1639. "role": props.closeOnClickOverlay ? "button" : void 0,
  1640. "tabindex": props.closeOnClickOverlay ? 0 : void 0,
  1641. "onClick": onClickOverlay
  1642. }, {
  1643. default: slots["overlay-content"]
  1644. });
  1645. }
  1646. };
  1647. const onClickCloseIcon = (event) => {
  1648. emit("click-close-icon", event);
  1649. close();
  1650. };
  1651. const renderCloseIcon = () => {
  1652. if (props.closeable) {
  1653. return vue.createVNode(Icon, {
  1654. "role": "button",
  1655. "tabindex": 0,
  1656. "name": props.closeIcon,
  1657. "class": [bem$1i("close-icon", props.closeIconPosition), HAPTICS_FEEDBACK],
  1658. "classPrefix": props.iconPrefix,
  1659. "onClick": onClickCloseIcon
  1660. }, null);
  1661. }
  1662. };
  1663. const onOpened = () => emit("opened");
  1664. const onClosed = () => emit("closed");
  1665. const onKeydown = (event) => emit("keydown", event);
  1666. const renderPopup = lazyRender(() => {
  1667. var _a;
  1668. const {
  1669. round: round2,
  1670. position,
  1671. safeAreaInsetTop,
  1672. safeAreaInsetBottom
  1673. } = props;
  1674. return vue.withDirectives(vue.createVNode("div", vue.mergeProps({
  1675. "ref": popupRef,
  1676. "style": style.value,
  1677. "role": "dialog",
  1678. "tabindex": 0,
  1679. "class": [bem$1i({
  1680. round: round2,
  1681. [position]: position
  1682. }), {
  1683. "van-safe-area-top": safeAreaInsetTop,
  1684. "van-safe-area-bottom": safeAreaInsetBottom
  1685. }],
  1686. "onKeydown": onKeydown
  1687. }, attrs), [(_a = slots.default) == null ? void 0 : _a.call(slots), renderCloseIcon()]), [[vue.vShow, props.show]]);
  1688. });
  1689. const renderTransition = () => {
  1690. const {
  1691. position,
  1692. transition,
  1693. transitionAppear
  1694. } = props;
  1695. const name2 = position === "center" ? "van-fade" : `van-popup-slide-${position}`;
  1696. return vue.createVNode(vue.Transition, {
  1697. "name": transition || name2,
  1698. "appear": transitionAppear,
  1699. "onAfterEnter": onOpened,
  1700. "onAfterLeave": onClosed
  1701. }, {
  1702. default: renderPopup
  1703. });
  1704. };
  1705. vue.watch(() => props.show, (show) => {
  1706. if (show && !opened) {
  1707. open();
  1708. if (attrs.tabindex === 0) {
  1709. vue.nextTick(() => {
  1710. var _a;
  1711. (_a = popupRef.value) == null ? void 0 : _a.focus();
  1712. });
  1713. }
  1714. }
  1715. if (!show && opened) {
  1716. opened = false;
  1717. emit("close");
  1718. }
  1719. });
  1720. useExpose({
  1721. popupRef
  1722. });
  1723. useLockScroll(popupRef, () => props.show && props.lockScroll);
  1724. useEventListener("popstate", () => {
  1725. if (props.closeOnPopstate) {
  1726. close();
  1727. shouldReopen = false;
  1728. }
  1729. });
  1730. vue.onMounted(() => {
  1731. if (props.show) {
  1732. open();
  1733. }
  1734. });
  1735. vue.onActivated(() => {
  1736. if (shouldReopen) {
  1737. emit("update:show", true);
  1738. shouldReopen = false;
  1739. }
  1740. });
  1741. vue.onDeactivated(() => {
  1742. if (props.show && props.teleport) {
  1743. close();
  1744. shouldReopen = true;
  1745. }
  1746. });
  1747. vue.provide(POPUP_TOGGLE_KEY, () => props.show);
  1748. return () => {
  1749. if (props.teleport) {
  1750. return vue.createVNode(vue.Teleport, {
  1751. "to": props.teleport
  1752. }, {
  1753. default: () => [renderOverlay(), renderTransition()]
  1754. });
  1755. }
  1756. return vue.createVNode(vue.Fragment, null, [renderOverlay(), renderTransition()]);
  1757. };
  1758. }
  1759. });
  1760. const Popup = withInstall(stdin_default$1t);
  1761. const [name$1l, bem$1h] = createNamespace("action-sheet");
  1762. const actionSheetProps = extend({}, popupSharedProps, {
  1763. title: String,
  1764. round: truthProp,
  1765. actions: makeArrayProp(),
  1766. closeIcon: makeStringProp("cross"),
  1767. closeable: truthProp,
  1768. cancelText: String,
  1769. description: String,
  1770. closeOnPopstate: truthProp,
  1771. closeOnClickAction: Boolean,
  1772. safeAreaInsetBottom: truthProp
  1773. });
  1774. const popupInheritKeys$2 = [...popupSharedPropKeys, "round", "closeOnPopstate", "safeAreaInsetBottom"];
  1775. var stdin_default$1s = vue.defineComponent({
  1776. name: name$1l,
  1777. props: actionSheetProps,
  1778. emits: ["select", "cancel", "update:show"],
  1779. setup(props, {
  1780. slots,
  1781. emit
  1782. }) {
  1783. const updateShow = (show) => emit("update:show", show);
  1784. const onCancel = () => {
  1785. updateShow(false);
  1786. emit("cancel");
  1787. };
  1788. const renderHeader = () => {
  1789. if (props.title) {
  1790. return vue.createVNode("div", {
  1791. "class": bem$1h("header")
  1792. }, [props.title, props.closeable && vue.createVNode(Icon, {
  1793. "name": props.closeIcon,
  1794. "class": [bem$1h("close"), HAPTICS_FEEDBACK],
  1795. "onClick": onCancel
  1796. }, null)]);
  1797. }
  1798. };
  1799. const renderCancel = () => {
  1800. if (slots.cancel || props.cancelText) {
  1801. return [vue.createVNode("div", {
  1802. "class": bem$1h("gap")
  1803. }, null), vue.createVNode("button", {
  1804. "type": "button",
  1805. "class": bem$1h("cancel"),
  1806. "onClick": onCancel
  1807. }, [slots.cancel ? slots.cancel() : props.cancelText])];
  1808. }
  1809. };
  1810. const renderActionContent = (action, index) => {
  1811. if (action.loading) {
  1812. return vue.createVNode(Loading, {
  1813. "class": bem$1h("loading-icon")
  1814. }, null);
  1815. }
  1816. if (slots.action) {
  1817. return slots.action({
  1818. action,
  1819. index
  1820. });
  1821. }
  1822. return [vue.createVNode("span", {
  1823. "class": bem$1h("name")
  1824. }, [action.name]), action.subname && vue.createVNode("div", {
  1825. "class": bem$1h("subname")
  1826. }, [action.subname])];
  1827. };
  1828. const renderAction = (action, index) => {
  1829. const {
  1830. color,
  1831. loading,
  1832. callback,
  1833. disabled,
  1834. className
  1835. } = action;
  1836. const onClick = () => {
  1837. if (disabled || loading) {
  1838. return;
  1839. }
  1840. if (callback) {
  1841. callback(action);
  1842. }
  1843. if (props.closeOnClickAction) {
  1844. updateShow(false);
  1845. }
  1846. vue.nextTick(() => emit("select", action, index));
  1847. };
  1848. return vue.createVNode("button", {
  1849. "type": "button",
  1850. "style": {
  1851. color
  1852. },
  1853. "class": [bem$1h("item", {
  1854. loading,
  1855. disabled
  1856. }), className],
  1857. "onClick": onClick
  1858. }, [renderActionContent(action, index)]);
  1859. };
  1860. const renderDescription = () => {
  1861. if (props.description || slots.description) {
  1862. const content = slots.description ? slots.description() : props.description;
  1863. return vue.createVNode("div", {
  1864. "class": bem$1h("description")
  1865. }, [content]);
  1866. }
  1867. };
  1868. return () => vue.createVNode(Popup, vue.mergeProps({
  1869. "class": bem$1h(),
  1870. "position": "bottom",
  1871. "onUpdate:show": updateShow
  1872. }, pick(props, popupInheritKeys$2)), {
  1873. default: () => {
  1874. var _a;
  1875. return [renderHeader(), renderDescription(), vue.createVNode("div", {
  1876. "class": bem$1h("content")
  1877. }, [props.actions.map(renderAction), (_a = slots.default) == null ? void 0 : _a.call(slots)]), renderCancel()];
  1878. }
  1879. });
  1880. }
  1881. });
  1882. const ActionSheet = withInstall(stdin_default$1s);
  1883. function deepClone(obj) {
  1884. if (!isDef(obj)) {
  1885. return obj;
  1886. }
  1887. if (Array.isArray(obj)) {
  1888. return obj.map((item) => deepClone(item));
  1889. }
  1890. if (isObject(obj)) {
  1891. const to = {};
  1892. Object.keys(obj).forEach((key) => {
  1893. to[key] = deepClone(obj[key]);
  1894. });
  1895. return to;
  1896. }
  1897. return obj;
  1898. }
  1899. const DEFAULT_DURATION = 200;
  1900. const MOMENTUM_LIMIT_TIME = 300;
  1901. const MOMENTUM_LIMIT_DISTANCE = 15;
  1902. const [name$1k, bem$1g] = createNamespace("picker-column");
  1903. function getElementTranslateY(element) {
  1904. const {
  1905. transform
  1906. } = window.getComputedStyle(element);
  1907. const translateY = transform.slice(7, transform.length - 1).split(", ")[5];
  1908. return Number(translateY);
  1909. }
  1910. const PICKER_KEY = Symbol(name$1k);
  1911. const isOptionDisabled = (option) => isObject(option) && option.disabled;
  1912. var stdin_default$1r = vue.defineComponent({
  1913. name: name$1k,
  1914. props: {
  1915. textKey: makeRequiredProp(String),
  1916. readonly: Boolean,
  1917. allowHtml: Boolean,
  1918. className: unknownProp,
  1919. itemHeight: makeRequiredProp(Number),
  1920. defaultIndex: makeNumberProp(0),
  1921. swipeDuration: makeRequiredProp(numericProp),
  1922. initialOptions: makeArrayProp(),
  1923. visibleItemCount: makeRequiredProp(numericProp)
  1924. },
  1925. emits: ["change"],
  1926. setup(props, {
  1927. emit,
  1928. slots
  1929. }) {
  1930. let moving;
  1931. let startOffset;
  1932. let touchStartTime;
  1933. let momentumOffset;
  1934. let transitionEndTrigger;
  1935. const root = vue.ref();
  1936. const wrapper = vue.ref();
  1937. const state = vue.reactive({
  1938. index: props.defaultIndex,
  1939. offset: 0,
  1940. duration: 0,
  1941. options: deepClone(props.initialOptions)
  1942. });
  1943. const touch = useTouch();
  1944. const count = () => state.options.length;
  1945. const baseOffset = () => props.itemHeight * (+props.visibleItemCount - 1) / 2;
  1946. const adjustIndex = (index) => {
  1947. index = clamp(index, 0, count());
  1948. for (let i = index; i < count(); i++) {
  1949. if (!isOptionDisabled(state.options[i]))
  1950. return i;
  1951. }
  1952. for (let i = index - 1; i >= 0; i--) {
  1953. if (!isOptionDisabled(state.options[i]))
  1954. return i;
  1955. }
  1956. };
  1957. const setIndex = (index, emitChange) => {
  1958. index = adjustIndex(index) || 0;
  1959. const offset2 = -index * props.itemHeight;
  1960. const trigger = () => {
  1961. if (index !== state.index) {
  1962. state.index = index;
  1963. if (emitChange) {
  1964. emit("change", index);
  1965. }
  1966. }
  1967. };
  1968. if (moving && offset2 !== state.offset) {
  1969. transitionEndTrigger = trigger;
  1970. } else {
  1971. trigger();
  1972. }
  1973. state.offset = offset2;
  1974. };
  1975. const setOptions = (options) => {
  1976. if (JSON.stringify(options) !== JSON.stringify(state.options)) {
  1977. state.options = deepClone(options);
  1978. setIndex(props.defaultIndex);
  1979. }
  1980. };
  1981. const onClickItem = (index) => {
  1982. if (moving || props.readonly) {
  1983. return;
  1984. }
  1985. transitionEndTrigger = null;
  1986. state.duration = DEFAULT_DURATION;
  1987. setIndex(index, true);
  1988. };
  1989. const getOptionText = (option) => {
  1990. if (isObject(option) && props.textKey in option) {
  1991. return option[props.textKey];
  1992. }
  1993. return option;
  1994. };
  1995. const getIndexByOffset = (offset2) => clamp(Math.round(-offset2 / props.itemHeight), 0, count() - 1);
  1996. const momentum = (distance, duration) => {
  1997. const speed = Math.abs(distance / duration);
  1998. distance = state.offset + speed / 3e-3 * (distance < 0 ? -1 : 1);
  1999. const index = getIndexByOffset(distance);
  2000. state.duration = +props.swipeDuration;
  2001. setIndex(index, true);
  2002. };
  2003. const stopMomentum = () => {
  2004. moving = false;
  2005. state.duration = 0;
  2006. if (transitionEndTrigger) {
  2007. transitionEndTrigger();
  2008. transitionEndTrigger = null;
  2009. }
  2010. };
  2011. const onTouchStart = (event) => {
  2012. if (props.readonly) {
  2013. return;
  2014. }
  2015. touch.start(event);
  2016. if (moving) {
  2017. const translateY = getElementTranslateY(wrapper.value);
  2018. state.offset = Math.min(0, translateY - baseOffset());
  2019. startOffset = state.offset;
  2020. } else {
  2021. startOffset = state.offset;
  2022. }
  2023. state.duration = 0;
  2024. touchStartTime = Date.now();
  2025. momentumOffset = startOffset;
  2026. transitionEndTrigger = null;
  2027. };
  2028. const onTouchMove = (event) => {
  2029. if (props.readonly) {
  2030. return;
  2031. }
  2032. touch.move(event);
  2033. if (touch.isVertical()) {
  2034. moving = true;
  2035. preventDefault(event, true);
  2036. }
  2037. state.offset = clamp(startOffset + touch.deltaY.value, -(count() * props.itemHeight), props.itemHeight);
  2038. const now = Date.now();
  2039. if (now - touchStartTime > MOMENTUM_LIMIT_TIME) {
  2040. touchStartTime = now;
  2041. momentumOffset = state.offset;
  2042. }
  2043. };
  2044. const onTouchEnd = () => {
  2045. if (props.readonly) {
  2046. return;
  2047. }
  2048. const distance = state.offset - momentumOffset;
  2049. const duration = Date.now() - touchStartTime;
  2050. const allowMomentum = duration < MOMENTUM_LIMIT_TIME && Math.abs(distance) > MOMENTUM_LIMIT_DISTANCE;
  2051. if (allowMomentum) {
  2052. momentum(distance, duration);
  2053. return;
  2054. }
  2055. const index = getIndexByOffset(state.offset);
  2056. state.duration = DEFAULT_DURATION;
  2057. setIndex(index, true);
  2058. setTimeout(() => {
  2059. moving = false;
  2060. }, 0);
  2061. };
  2062. const renderOptions = () => {
  2063. const optionStyle = {
  2064. height: `${props.itemHeight}px`
  2065. };
  2066. return state.options.map((option, index) => {
  2067. const text = getOptionText(option);
  2068. const disabled = isOptionDisabled(option);
  2069. const data = {
  2070. role: "button",
  2071. style: optionStyle,
  2072. tabindex: disabled ? -1 : 0,
  2073. class: bem$1g("item", {
  2074. disabled,
  2075. selected: index === state.index
  2076. }),
  2077. onClick: () => onClickItem(index)
  2078. };
  2079. const childData = {
  2080. class: "van-ellipsis",
  2081. [props.allowHtml ? "innerHTML" : "textContent"]: text
  2082. };
  2083. return vue.createVNode("li", data, [slots.option ? slots.option(option) : vue.createVNode("div", childData, null)]);
  2084. });
  2085. };
  2086. const setValue = (value) => {
  2087. const {
  2088. options
  2089. } = state;
  2090. for (let i = 0; i < options.length; i++) {
  2091. if (getOptionText(options[i]) === value) {
  2092. return setIndex(i);
  2093. }
  2094. }
  2095. };
  2096. const getValue = () => state.options[state.index];
  2097. const hasOptions = () => state.options.length;
  2098. setIndex(state.index);
  2099. useParent(PICKER_KEY);
  2100. useExpose({
  2101. state,
  2102. setIndex,
  2103. getValue,
  2104. setValue,
  2105. setOptions,
  2106. hasOptions,
  2107. stopMomentum
  2108. });
  2109. vue.watch(() => props.initialOptions, setOptions);
  2110. vue.watch(() => props.defaultIndex, (value) => setIndex(value));
  2111. useEventListener("touchmove", onTouchMove, {
  2112. target: root
  2113. });
  2114. return () => vue.createVNode("div", {
  2115. "ref": root,
  2116. "class": [bem$1g(), props.className],
  2117. "onTouchstartPassive": onTouchStart,
  2118. "onTouchend": onTouchEnd,
  2119. "onTouchcancel": onTouchEnd
  2120. }, [vue.createVNode("ul", {
  2121. "ref": wrapper,
  2122. "style": {
  2123. transform: `translate3d(0, ${state.offset + baseOffset()}px, 0)`,
  2124. transitionDuration: `${state.duration}ms`,
  2125. transitionProperty: state.duration ? "all" : "none"
  2126. },
  2127. "class": bem$1g("wrapper"),
  2128. "onTransitionend": stopMomentum
  2129. }, [renderOptions()])]);
  2130. }
  2131. });
  2132. const [name$1j, bem$1f, t$j] = createNamespace("picker");
  2133. const pickerSharedProps = {
  2134. title: String,
  2135. loading: Boolean,
  2136. readonly: Boolean,
  2137. allowHtml: Boolean,
  2138. itemHeight: makeNumericProp(44),
  2139. showToolbar: truthProp,
  2140. swipeDuration: makeNumericProp(1e3),
  2141. visibleItemCount: makeNumericProp(6),
  2142. cancelButtonText: String,
  2143. confirmButtonText: String
  2144. };
  2145. const pickerProps = extend({}, pickerSharedProps, {
  2146. columns: makeArrayProp(),
  2147. valueKey: String,
  2148. defaultIndex: makeNumericProp(0),
  2149. toolbarPosition: makeStringProp("top"),
  2150. columnsFieldNames: Object
  2151. });
  2152. var stdin_default$1q = vue.defineComponent({
  2153. name: name$1j,
  2154. props: pickerProps,
  2155. emits: ["confirm", "cancel", "change"],
  2156. setup(props, {
  2157. emit,
  2158. slots
  2159. }) {
  2160. const hasOptions = vue.ref(false);
  2161. const columnsRef = vue.ref();
  2162. const formattedColumns = vue.ref([]);
  2163. const columnsFieldNames = vue.computed(() => {
  2164. const {
  2165. columnsFieldNames: columnsFieldNames2
  2166. } = props;
  2167. return {
  2168. text: (columnsFieldNames2 == null ? void 0 : columnsFieldNames2.text) || props.valueKey || "text",
  2169. values: (columnsFieldNames2 == null ? void 0 : columnsFieldNames2.values) || "values",
  2170. children: (columnsFieldNames2 == null ? void 0 : columnsFieldNames2.children) || "children"
  2171. };
  2172. });
  2173. const {
  2174. children,
  2175. linkChildren
  2176. } = useChildren(PICKER_KEY);
  2177. linkChildren();
  2178. const itemHeight = vue.computed(() => unitToPx(props.itemHeight));
  2179. const dataType = vue.computed(() => {
  2180. const firstColumn = props.columns[0];
  2181. if (typeof firstColumn === "object") {
  2182. if (columnsFieldNames.value.children in firstColumn) {
  2183. return "cascade";
  2184. }
  2185. if (columnsFieldNames.value.values in firstColumn) {
  2186. return "object";
  2187. }
  2188. }
  2189. return "plain";
  2190. });
  2191. const formatCascade = () => {
  2192. var _a;
  2193. const formatted = [];
  2194. let cursor = {
  2195. [columnsFieldNames.value.children]: props.columns
  2196. };
  2197. while (cursor && cursor[columnsFieldNames.value.children]) {
  2198. const children2 = cursor[columnsFieldNames.value.children];
  2199. let defaultIndex = (_a = cursor.defaultIndex) != null ? _a : +props.defaultIndex;
  2200. while (children2[defaultIndex] && children2[defaultIndex].disabled) {
  2201. if (defaultIndex < children2.length - 1) {
  2202. defaultIndex++;
  2203. } else {
  2204. defaultIndex = 0;
  2205. break;
  2206. }
  2207. }
  2208. formatted.push({
  2209. [columnsFieldNames.value.values]: cursor[columnsFieldNames.value.children],
  2210. className: cursor.className,
  2211. defaultIndex
  2212. });
  2213. cursor = children2[defaultIndex];
  2214. }
  2215. formattedColumns.value = formatted;
  2216. };
  2217. const format2 = () => {
  2218. const {
  2219. columns
  2220. } = props;
  2221. if (dataType.value === "plain") {
  2222. formattedColumns.value = [{
  2223. [columnsFieldNames.value.values]: columns
  2224. }];
  2225. } else if (dataType.value === "cascade") {
  2226. formatCascade();
  2227. } else {
  2228. formattedColumns.value = columns;
  2229. }
  2230. hasOptions.value = formattedColumns.value.some((item) => item[columnsFieldNames.value.values] && item[columnsFieldNames.value.values].length !== 0) || children.some((item) => item.hasOptions);
  2231. };
  2232. const getIndexes = () => children.map((child) => child.state.index);
  2233. const setColumnValues = (index, options) => {
  2234. const column = children[index];
  2235. if (column) {
  2236. column.setOptions(options);
  2237. hasOptions.value = true;
  2238. }
  2239. };
  2240. const onCascadeChange = (columnIndex) => {
  2241. let cursor = {
  2242. [columnsFieldNames.value.children]: props.columns
  2243. };
  2244. const indexes = getIndexes();
  2245. for (let i = 0; i <= columnIndex; i++) {
  2246. cursor = cursor[columnsFieldNames.value.children][indexes[i]];
  2247. }
  2248. while (cursor && cursor[columnsFieldNames.value.children]) {
  2249. columnIndex++;
  2250. setColumnValues(columnIndex, cursor[columnsFieldNames.value.children]);
  2251. cursor = cursor[columnsFieldNames.value.children][cursor.defaultIndex || 0];
  2252. }
  2253. };
  2254. const getChild = (index) => children[index];
  2255. const getColumnValue = (index) => {
  2256. const column = getChild(index);
  2257. if (column) {
  2258. return column.getValue();
  2259. }
  2260. };
  2261. const setColumnValue = (index, value) => {
  2262. const column = getChild(index);
  2263. if (column) {
  2264. column.setValue(value);
  2265. if (dataType.value === "cascade") {
  2266. onCascadeChange(index);
  2267. }
  2268. }
  2269. };
  2270. const getColumnIndex = (index) => {
  2271. const column = getChild(index);
  2272. if (column) {
  2273. return column.state.index;
  2274. }
  2275. };
  2276. const setColumnIndex = (columnIndex, optionIndex) => {
  2277. const column = getChild(columnIndex);
  2278. if (column) {
  2279. column.setIndex(optionIndex);
  2280. if (dataType.value === "cascade") {
  2281. onCascadeChange(columnIndex);
  2282. }
  2283. }
  2284. };
  2285. const getColumnValues = (index) => {
  2286. const column = getChild(index);
  2287. if (column) {
  2288. return column.state.options;
  2289. }
  2290. };
  2291. const getValues = () => children.map((child) => child.getValue());
  2292. const setValues = (values) => {
  2293. values.forEach((value, index) => {
  2294. setColumnValue(index, value);
  2295. });
  2296. };
  2297. const setIndexes = (indexes) => {
  2298. indexes.forEach((optionIndex, columnIndex) => {
  2299. setColumnIndex(columnIndex, optionIndex);
  2300. });
  2301. };
  2302. const emitAction = (event) => {
  2303. if (dataType.value === "plain") {
  2304. emit(event, getColumnValue(0), getColumnIndex(0));
  2305. } else {
  2306. emit(event, getValues(), getIndexes());
  2307. }
  2308. };
  2309. const onChange = (columnIndex) => {
  2310. if (dataType.value === "cascade") {
  2311. onCascadeChange(columnIndex);
  2312. }
  2313. if (dataType.value === "plain") {
  2314. emit("change", getColumnValue(0), getColumnIndex(0));
  2315. } else {
  2316. emit("change", getValues(), columnIndex);
  2317. }
  2318. };
  2319. const confirm = () => {
  2320. children.forEach((child) => child.stopMomentum());
  2321. emitAction("confirm");
  2322. };
  2323. const cancel = () => emitAction("cancel");
  2324. const renderTitle = () => {
  2325. if (slots.title) {
  2326. return slots.title();
  2327. }
  2328. if (props.title) {
  2329. return vue.createVNode("div", {
  2330. "class": [bem$1f("title"), "van-ellipsis"]
  2331. }, [props.title]);
  2332. }
  2333. };
  2334. const renderCancel = () => {
  2335. const text = props.cancelButtonText || t$j("cancel");
  2336. return vue.createVNode("button", {
  2337. "type": "button",
  2338. "class": [bem$1f("cancel"), HAPTICS_FEEDBACK],
  2339. "onClick": cancel
  2340. }, [slots.cancel ? slots.cancel() : text]);
  2341. };
  2342. const renderConfirm = () => {
  2343. const text = props.confirmButtonText || t$j("confirm");
  2344. return vue.createVNode("button", {
  2345. "type": "button",
  2346. "class": [bem$1f("confirm"), HAPTICS_FEEDBACK],
  2347. "onClick": confirm
  2348. }, [slots.confirm ? slots.confirm() : text]);
  2349. };
  2350. const renderToolbar = () => {
  2351. if (props.showToolbar) {
  2352. const slot = slots.toolbar || slots.default;
  2353. return vue.createVNode("div", {
  2354. "class": bem$1f("toolbar")
  2355. }, [slot ? slot() : [renderCancel(), renderTitle(), renderConfirm()]]);
  2356. }
  2357. };
  2358. const renderColumnItems = () => formattedColumns.value.map((item, columnIndex) => {
  2359. var _a;
  2360. return vue.createVNode(stdin_default$1r, {
  2361. "textKey": columnsFieldNames.value.text,
  2362. "readonly": props.readonly,
  2363. "allowHtml": props.allowHtml,
  2364. "className": item.className,
  2365. "itemHeight": itemHeight.value,
  2366. "defaultIndex": (_a = item.defaultIndex) != null ? _a : +props.defaultIndex,
  2367. "swipeDuration": props.swipeDuration,
  2368. "initialOptions": item[columnsFieldNames.value.values],
  2369. "visibleItemCount": props.visibleItemCount,
  2370. "onChange": () => onChange(columnIndex)
  2371. }, {
  2372. option: slots.option
  2373. });
  2374. });
  2375. const renderMask = (wrapHeight) => {
  2376. if (hasOptions.value) {
  2377. const frameStyle = {
  2378. height: `${itemHeight.value}px`
  2379. };
  2380. const maskStyle = {
  2381. backgroundSize: `100% ${(wrapHeight - itemHeight.value) / 2}px`
  2382. };
  2383. return [vue.createVNode("div", {
  2384. "class": bem$1f("mask"),
  2385. "style": maskStyle
  2386. }, null), vue.createVNode("div", {
  2387. "class": [BORDER_UNSET_TOP_BOTTOM, bem$1f("frame")],
  2388. "style": frameStyle
  2389. }, null)];
  2390. }
  2391. };
  2392. const renderColumns = () => {
  2393. const wrapHeight = itemHeight.value * +props.visibleItemCount;
  2394. const columnsStyle = {
  2395. height: `${wrapHeight}px`
  2396. };
  2397. return vue.createVNode("div", {
  2398. "ref": columnsRef,
  2399. "class": bem$1f("columns"),
  2400. "style": columnsStyle
  2401. }, [renderColumnItems(), renderMask(wrapHeight)]);
  2402. };
  2403. vue.watch(() => props.columns, format2, {
  2404. immediate: true
  2405. });
  2406. useEventListener("touchmove", preventDefault, {
  2407. target: columnsRef
  2408. });
  2409. useExpose({
  2410. confirm,
  2411. getValues,
  2412. setValues,
  2413. getIndexes,
  2414. setIndexes,
  2415. getColumnIndex,
  2416. setColumnIndex,
  2417. getColumnValue,
  2418. setColumnValue,
  2419. getColumnValues,
  2420. setColumnValues
  2421. });
  2422. return () => {
  2423. var _a, _b;
  2424. return vue.createVNode("div", {
  2425. "class": bem$1f()
  2426. }, [props.toolbarPosition === "top" ? renderToolbar() : null, props.loading ? vue.createVNode(Loading, {
  2427. "class": bem$1f("loading")
  2428. }, 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]);
  2429. };
  2430. }
  2431. });
  2432. const Picker = withInstall(stdin_default$1q);
  2433. const [name$1i, bem$1e] = createNamespace("area");
  2434. const EMPTY_CODE = "000000";
  2435. const INHERIT_SLOTS = ["title", "cancel", "confirm", "toolbar", "columns-top", "columns-bottom"];
  2436. const INHERIT_PROPS = ["title", "loading", "readonly", "itemHeight", "swipeDuration", "visibleItemCount", "cancelButtonText", "confirmButtonText"];
  2437. const isOverseaCode = (code) => code[0] === "9";
  2438. const areaProps = extend({}, pickerSharedProps, {
  2439. value: String,
  2440. columnsNum: makeNumericProp(3),
  2441. columnsPlaceholder: makeArrayProp(),
  2442. areaList: {
  2443. type: Object,
  2444. default: () => ({})
  2445. },
  2446. isOverseaCode: {
  2447. type: Function,
  2448. default: isOverseaCode
  2449. }
  2450. });
  2451. var stdin_default$1p = vue.defineComponent({
  2452. name: name$1i,
  2453. props: areaProps,
  2454. emits: ["change", "confirm", "cancel"],
  2455. setup(props, {
  2456. emit,
  2457. slots
  2458. }) {
  2459. const pickerRef = vue.ref();
  2460. const state = vue.reactive({
  2461. code: props.value,
  2462. columns: [{
  2463. values: []
  2464. }, {
  2465. values: []
  2466. }, {
  2467. values: []
  2468. }]
  2469. });
  2470. const areaList = vue.computed(() => {
  2471. const {
  2472. areaList: areaList2
  2473. } = props;
  2474. return {
  2475. province: areaList2.province_list || {},
  2476. city: areaList2.city_list || {},
  2477. county: areaList2.county_list || {}
  2478. };
  2479. });
  2480. const placeholderMap = vue.computed(() => {
  2481. const {
  2482. columnsPlaceholder
  2483. } = props;
  2484. return {
  2485. province: columnsPlaceholder[0] || "",
  2486. city: columnsPlaceholder[1] || "",
  2487. county: columnsPlaceholder[2] || ""
  2488. };
  2489. });
  2490. const getDefaultCode = () => {
  2491. if (props.columnsPlaceholder.length) {
  2492. return EMPTY_CODE;
  2493. }
  2494. const {
  2495. county,
  2496. city
  2497. } = areaList.value;
  2498. const countyCodes = Object.keys(county);
  2499. if (countyCodes[0]) {
  2500. return countyCodes[0];
  2501. }
  2502. const cityCodes = Object.keys(city);
  2503. if (cityCodes[0]) {
  2504. return cityCodes[0];
  2505. }
  2506. return "";
  2507. };
  2508. const getColumnValues = (type, code) => {
  2509. let column = [];
  2510. if (type !== "province" && !code) {
  2511. return column;
  2512. }
  2513. const list = areaList.value[type];
  2514. column = Object.keys(list).map((listCode) => ({
  2515. code: listCode,
  2516. name: list[listCode]
  2517. }));
  2518. if (code) {
  2519. if (type === "city" && props.isOverseaCode(code)) {
  2520. code = "9";
  2521. }
  2522. column = column.filter((item) => item.code.indexOf(code) === 0);
  2523. }
  2524. if (placeholderMap.value[type] && column.length) {
  2525. let codeFill = "";
  2526. if (type === "city") {
  2527. codeFill = EMPTY_CODE.slice(2, 4);
  2528. } else if (type === "county") {
  2529. codeFill = EMPTY_CODE.slice(4, 6);
  2530. }
  2531. column.unshift({
  2532. code: code + codeFill,
  2533. name: placeholderMap.value[type]
  2534. });
  2535. }
  2536. return column;
  2537. };
  2538. const getIndex = (type, code) => {
  2539. let compareNum = code.length;
  2540. if (type === "province") {
  2541. compareNum = props.isOverseaCode(code) ? 1 : 2;
  2542. }
  2543. if (type === "city") {
  2544. compareNum = 4;
  2545. }
  2546. code = code.slice(0, compareNum);
  2547. const list = getColumnValues(type, compareNum > 2 ? code.slice(0, compareNum - 2) : "");
  2548. for (let i = 0; i < list.length; i++) {
  2549. if (list[i].code.slice(0, compareNum) === code) {
  2550. return i;
  2551. }
  2552. }
  2553. return 0;
  2554. };
  2555. const setValues = () => {
  2556. const picker = pickerRef.value;
  2557. if (!picker) {
  2558. return;
  2559. }
  2560. let code = state.code || getDefaultCode();
  2561. const province = getColumnValues("province");
  2562. const city = getColumnValues("city", code.slice(0, 2));
  2563. picker.setColumnValues(0, province);
  2564. picker.setColumnValues(1, city);
  2565. if (city.length && code.slice(2, 4) === "00" && !props.isOverseaCode(code)) {
  2566. [{
  2567. code
  2568. }] = city;
  2569. }
  2570. picker.setColumnValues(2, getColumnValues("county", code.slice(0, 4)));
  2571. picker.setIndexes([getIndex("province", code), getIndex("city", code), getIndex("county", code)]);
  2572. };
  2573. const parseValues = (values) => values.map((value, index) => {
  2574. if (value) {
  2575. value = deepClone(value);
  2576. if (!value.code || value.name === props.columnsPlaceholder[index]) {
  2577. value.code = "";
  2578. value.name = "";
  2579. }
  2580. }
  2581. return value;
  2582. });
  2583. const getValues = () => {
  2584. if (pickerRef.value) {
  2585. const values = pickerRef.value.getValues().filter(Boolean);
  2586. return parseValues(values);
  2587. }
  2588. return [];
  2589. };
  2590. const getArea = () => {
  2591. const values = getValues();
  2592. const area = {
  2593. code: "",
  2594. country: "",
  2595. province: "",
  2596. city: "",
  2597. county: ""
  2598. };
  2599. if (!values.length) {
  2600. return area;
  2601. }
  2602. const names = values.map((item) => item.name);
  2603. const validValues = values.filter((value) => value.code);
  2604. area.code = validValues.length ? validValues[validValues.length - 1].code : "";
  2605. if (props.isOverseaCode(area.code)) {
  2606. area.country = names[1] || "";
  2607. area.province = names[2] || "";
  2608. } else {
  2609. area.province = names[0] || "";
  2610. area.city = names[1] || "";
  2611. area.county = names[2] || "";
  2612. }
  2613. return area;
  2614. };
  2615. const reset = (newCode = "") => {
  2616. state.code = newCode;
  2617. setValues();
  2618. };
  2619. const onChange = (values, index) => {
  2620. state.code = values[index].code;
  2621. setValues();
  2622. if (pickerRef.value) {
  2623. const parsedValues = parseValues(pickerRef.value.getValues());
  2624. emit("change", parsedValues, index);
  2625. }
  2626. };
  2627. const onConfirm = (values, index) => {
  2628. setValues();
  2629. emit("confirm", parseValues(values), index);
  2630. };
  2631. const onCancel = (...args) => emit("cancel", ...args);
  2632. vue.onMounted(setValues);
  2633. vue.watch(() => props.value, (value) => {
  2634. state.code = value;
  2635. setValues();
  2636. });
  2637. vue.watch(() => props.areaList, setValues, {
  2638. deep: true
  2639. });
  2640. vue.watch(() => props.columnsNum, () => {
  2641. vue.nextTick(setValues);
  2642. });
  2643. useExpose({
  2644. reset,
  2645. getArea,
  2646. getValues
  2647. });
  2648. return () => {
  2649. const columns = state.columns.slice(0, +props.columnsNum);
  2650. return vue.createVNode(Picker, vue.mergeProps({
  2651. "ref": pickerRef,
  2652. "class": bem$1e(),
  2653. "columns": columns,
  2654. "columnsFieldNames": {
  2655. text: "name"
  2656. },
  2657. "onChange": onChange,
  2658. "onCancel": onCancel,
  2659. "onConfirm": onConfirm
  2660. }, pick(props, INHERIT_PROPS)), pick(slots, INHERIT_SLOTS));
  2661. };
  2662. }
  2663. });
  2664. const Area = withInstall(stdin_default$1p);
  2665. const [name$1h, bem$1d] = createNamespace("cell");
  2666. const cellSharedProps = {
  2667. icon: String,
  2668. size: String,
  2669. title: numericProp,
  2670. value: numericProp,
  2671. label: numericProp,
  2672. center: Boolean,
  2673. isLink: Boolean,
  2674. border: truthProp,
  2675. required: Boolean,
  2676. iconPrefix: String,
  2677. valueClass: unknownProp,
  2678. labelClass: unknownProp,
  2679. titleClass: unknownProp,
  2680. titleStyle: null,
  2681. arrowDirection: String,
  2682. clickable: {
  2683. type: Boolean,
  2684. default: null
  2685. }
  2686. };
  2687. const cellProps = extend({}, cellSharedProps, routeProps);
  2688. var stdin_default$1o = vue.defineComponent({
  2689. name: name$1h,
  2690. props: cellProps,
  2691. setup(props, {
  2692. slots
  2693. }) {
  2694. const route2 = useRoute();
  2695. const renderLabel = () => {
  2696. const showLabel = slots.label || isDef(props.label);
  2697. if (showLabel) {
  2698. return vue.createVNode("div", {
  2699. "class": [bem$1d("label"), props.labelClass]
  2700. }, [slots.label ? slots.label() : props.label]);
  2701. }
  2702. };
  2703. const renderTitle = () => {
  2704. if (slots.title || isDef(props.title)) {
  2705. return vue.createVNode("div", {
  2706. "class": [bem$1d("title"), props.titleClass],
  2707. "style": props.titleStyle
  2708. }, [slots.title ? slots.title() : vue.createVNode("span", null, [props.title]), renderLabel()]);
  2709. }
  2710. };
  2711. const renderValue = () => {
  2712. const slot = slots.value || slots.default;
  2713. const hasValue = slot || isDef(props.value);
  2714. if (hasValue) {
  2715. const hasTitle = slots.title || isDef(props.title);
  2716. return vue.createVNode("div", {
  2717. "class": [bem$1d("value", {
  2718. alone: !hasTitle
  2719. }), props.valueClass]
  2720. }, [slot ? slot() : vue.createVNode("span", null, [props.value])]);
  2721. }
  2722. };
  2723. const renderLeftIcon = () => {
  2724. if (slots.icon) {
  2725. return slots.icon();
  2726. }
  2727. if (props.icon) {
  2728. return vue.createVNode(Icon, {
  2729. "name": props.icon,
  2730. "class": bem$1d("left-icon"),
  2731. "classPrefix": props.iconPrefix
  2732. }, null);
  2733. }
  2734. };
  2735. const renderRightIcon = () => {
  2736. if (slots["right-icon"]) {
  2737. return slots["right-icon"]();
  2738. }
  2739. if (props.isLink) {
  2740. const name2 = props.arrowDirection ? `arrow-${props.arrowDirection}` : "arrow";
  2741. return vue.createVNode(Icon, {
  2742. "name": name2,
  2743. "class": bem$1d("right-icon")
  2744. }, null);
  2745. }
  2746. };
  2747. return () => {
  2748. var _a, _b;
  2749. const {
  2750. size,
  2751. center,
  2752. border,
  2753. isLink,
  2754. required
  2755. } = props;
  2756. const clickable = (_a = props.clickable) != null ? _a : isLink;
  2757. const classes = {
  2758. center,
  2759. required,
  2760. clickable,
  2761. borderless: !border
  2762. };
  2763. if (size) {
  2764. classes[size] = !!size;
  2765. }
  2766. return vue.createVNode("div", {
  2767. "class": bem$1d(classes),
  2768. "role": clickable ? "button" : void 0,
  2769. "tabindex": clickable ? 0 : void 0,
  2770. "onClick": route2
  2771. }, [renderLeftIcon(), renderTitle(), renderValue(), renderRightIcon(), (_b = slots.extra) == null ? void 0 : _b.call(slots)]);
  2772. };
  2773. }
  2774. });
  2775. const Cell = withInstall(stdin_default$1o);
  2776. const [name$1g, bem$1c] = createNamespace("form");
  2777. const formProps = {
  2778. colon: Boolean,
  2779. disabled: Boolean,
  2780. readonly: Boolean,
  2781. showError: Boolean,
  2782. labelWidth: numericProp,
  2783. labelAlign: String,
  2784. inputAlign: String,
  2785. scrollToError: Boolean,
  2786. validateFirst: Boolean,
  2787. submitOnEnter: truthProp,
  2788. showErrorMessage: truthProp,
  2789. errorMessageAlign: String,
  2790. validateTrigger: {
  2791. type: [String, Array],
  2792. default: "onBlur"
  2793. }
  2794. };
  2795. var stdin_default$1n = vue.defineComponent({
  2796. name: name$1g,
  2797. props: formProps,
  2798. emits: ["submit", "failed"],
  2799. setup(props, {
  2800. emit,
  2801. slots
  2802. }) {
  2803. const {
  2804. children,
  2805. linkChildren
  2806. } = useChildren(FORM_KEY);
  2807. const getFieldsByNames = (names) => {
  2808. if (names) {
  2809. return children.filter((field) => names.includes(field.name));
  2810. }
  2811. return children;
  2812. };
  2813. const validateSeq = (names) => new Promise((resolve, reject) => {
  2814. const errors = [];
  2815. const fields = getFieldsByNames(names);
  2816. fields.reduce((promise, field) => promise.then(() => {
  2817. if (!errors.length) {
  2818. return field.validate().then((error) => {
  2819. if (error) {
  2820. errors.push(error);
  2821. }
  2822. });
  2823. }
  2824. }), Promise.resolve()).then(() => {
  2825. if (errors.length) {
  2826. reject(errors);
  2827. } else {
  2828. resolve();
  2829. }
  2830. });
  2831. });
  2832. const validateAll = (names) => new Promise((resolve, reject) => {
  2833. const fields = getFieldsByNames(names);
  2834. Promise.all(fields.map((item) => item.validate())).then((errors) => {
  2835. errors = errors.filter(Boolean);
  2836. if (errors.length) {
  2837. reject(errors);
  2838. } else {
  2839. resolve();
  2840. }
  2841. });
  2842. });
  2843. const validateField = (name2) => {
  2844. const matched = children.find((item) => item.name === name2);
  2845. if (matched) {
  2846. return new Promise((resolve, reject) => {
  2847. matched.validate().then((error) => {
  2848. if (error) {
  2849. reject(error);
  2850. } else {
  2851. resolve();
  2852. }
  2853. });
  2854. });
  2855. }
  2856. return Promise.reject();
  2857. };
  2858. const validate = (name2) => {
  2859. if (typeof name2 === "string") {
  2860. return validateField(name2);
  2861. }
  2862. return props.validateFirst ? validateSeq(name2) : validateAll(name2);
  2863. };
  2864. const resetValidation = (name2) => {
  2865. if (typeof name2 === "string") {
  2866. name2 = [name2];
  2867. }
  2868. const fields = getFieldsByNames(name2);
  2869. fields.forEach((item) => {
  2870. item.resetValidation();
  2871. });
  2872. };
  2873. const getValidationStatus = () => children.reduce((form, field) => {
  2874. form[field.name] = field.getValidationStatus();
  2875. return form;
  2876. }, {});
  2877. const scrollToField = (name2, options) => {
  2878. children.some((item) => {
  2879. if (item.name === name2) {
  2880. item.$el.scrollIntoView(options);
  2881. return true;
  2882. }
  2883. return false;
  2884. });
  2885. };
  2886. const getValues = () => children.reduce((form, field) => {
  2887. form[field.name] = field.formValue.value;
  2888. return form;
  2889. }, {});
  2890. const submit = () => {
  2891. const values = getValues();
  2892. validate().then(() => emit("submit", values)).catch((errors) => {
  2893. emit("failed", {
  2894. values,
  2895. errors
  2896. });
  2897. if (props.scrollToError && errors[0].name) {
  2898. scrollToField(errors[0].name);
  2899. }
  2900. });
  2901. };
  2902. const onSubmit = (event) => {
  2903. preventDefault(event);
  2904. submit();
  2905. };
  2906. linkChildren({
  2907. props
  2908. });
  2909. useExpose({
  2910. submit,
  2911. validate,
  2912. getValues,
  2913. scrollToField,
  2914. resetValidation,
  2915. getValidationStatus
  2916. });
  2917. return () => {
  2918. var _a;
  2919. return vue.createVNode("form", {
  2920. "class": bem$1c(),
  2921. "onSubmit": onSubmit
  2922. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  2923. };
  2924. }
  2925. });
  2926. const Form = withInstall(stdin_default$1n);
  2927. function isEmptyValue(value) {
  2928. if (Array.isArray(value)) {
  2929. return !value.length;
  2930. }
  2931. if (value === 0) {
  2932. return false;
  2933. }
  2934. return !value;
  2935. }
  2936. function runSyncRule(value, rule) {
  2937. if (isEmptyValue(value)) {
  2938. if (rule.required) {
  2939. return false;
  2940. }
  2941. if (rule.validateEmpty === false) {
  2942. return true;
  2943. }
  2944. }
  2945. if (rule.pattern && !rule.pattern.test(String(value))) {
  2946. return false;
  2947. }
  2948. return true;
  2949. }
  2950. function runRuleValidator(value, rule) {
  2951. return new Promise((resolve) => {
  2952. const returnVal = rule.validator(value, rule);
  2953. if (isPromise(returnVal)) {
  2954. returnVal.then(resolve);
  2955. return;
  2956. }
  2957. resolve(returnVal);
  2958. });
  2959. }
  2960. function getRuleMessage(value, rule) {
  2961. const { message } = rule;
  2962. if (isFunction(message)) {
  2963. return message(value, rule);
  2964. }
  2965. return message || "";
  2966. }
  2967. function startComposing({ target }) {
  2968. target.composing = true;
  2969. }
  2970. function endComposing({ target }) {
  2971. if (target.composing) {
  2972. target.composing = false;
  2973. target.dispatchEvent(new Event("input"));
  2974. }
  2975. }
  2976. function resizeTextarea(input, autosize) {
  2977. const scrollTop = getRootScrollTop();
  2978. input.style.height = "auto";
  2979. let height2 = input.scrollHeight;
  2980. if (isObject(autosize)) {
  2981. const { maxHeight, minHeight } = autosize;
  2982. if (maxHeight !== void 0) {
  2983. height2 = Math.min(height2, maxHeight);
  2984. }
  2985. if (minHeight !== void 0) {
  2986. height2 = Math.max(height2, minHeight);
  2987. }
  2988. }
  2989. if (height2) {
  2990. input.style.height = `${height2}px`;
  2991. setRootScrollTop(scrollTop);
  2992. }
  2993. }
  2994. function mapInputType(type) {
  2995. if (type === "number") {
  2996. return {
  2997. type: "text",
  2998. inputmode: "decimal"
  2999. };
  3000. }
  3001. if (type === "digit") {
  3002. return {
  3003. type: "tel",
  3004. inputmode: "numeric"
  3005. };
  3006. }
  3007. return { type };
  3008. }
  3009. function getStringLength(str) {
  3010. return [...str].length;
  3011. }
  3012. function cutString(str, maxlength) {
  3013. return [...str].slice(0, maxlength).join("");
  3014. }
  3015. let current = 0;
  3016. function useId() {
  3017. const vm = vue.getCurrentInstance();
  3018. const { name: name2 = "unknown" } = (vm == null ? void 0 : vm.type) || {};
  3019. return `${name2}-${++current}`;
  3020. }
  3021. const [name$1f, bem$1b] = createNamespace("field");
  3022. const fieldSharedProps = {
  3023. id: String,
  3024. name: String,
  3025. leftIcon: String,
  3026. rightIcon: String,
  3027. autofocus: Boolean,
  3028. clearable: Boolean,
  3029. maxlength: numericProp,
  3030. formatter: Function,
  3031. clearIcon: makeStringProp("clear"),
  3032. modelValue: makeNumericProp(""),
  3033. inputAlign: String,
  3034. placeholder: String,
  3035. autocomplete: String,
  3036. errorMessage: String,
  3037. enterkeyhint: String,
  3038. clearTrigger: makeStringProp("focus"),
  3039. formatTrigger: makeStringProp("onChange"),
  3040. error: {
  3041. type: Boolean,
  3042. default: null
  3043. },
  3044. disabled: {
  3045. type: Boolean,
  3046. default: null
  3047. },
  3048. readonly: {
  3049. type: Boolean,
  3050. default: null
  3051. }
  3052. };
  3053. const fieldProps = extend({}, cellSharedProps, fieldSharedProps, {
  3054. rows: numericProp,
  3055. type: makeStringProp("text"),
  3056. rules: Array,
  3057. autosize: [Boolean, Object],
  3058. labelWidth: numericProp,
  3059. labelClass: unknownProp,
  3060. labelAlign: String,
  3061. showWordLimit: Boolean,
  3062. errorMessageAlign: String,
  3063. colon: {
  3064. type: Boolean,
  3065. default: null
  3066. }
  3067. });
  3068. var stdin_default$1m = vue.defineComponent({
  3069. name: name$1f,
  3070. props: fieldProps,
  3071. emits: ["blur", "focus", "clear", "keypress", "click-input", "end-validate", "start-validate", "click-left-icon", "click-right-icon", "update:modelValue"],
  3072. setup(props, {
  3073. emit,
  3074. slots
  3075. }) {
  3076. const id = useId();
  3077. const state = vue.reactive({
  3078. status: "unvalidated",
  3079. focused: false,
  3080. validateMessage: ""
  3081. });
  3082. const inputRef = vue.ref();
  3083. const clearIconRef = vue.ref();
  3084. const customValue = vue.ref();
  3085. const {
  3086. parent: form
  3087. } = useParent(FORM_KEY);
  3088. const getModelValue = () => {
  3089. var _a;
  3090. return String((_a = props.modelValue) != null ? _a : "");
  3091. };
  3092. const getProp = (key) => {
  3093. if (isDef(props[key])) {
  3094. return props[key];
  3095. }
  3096. if (form && isDef(form.props[key])) {
  3097. return form.props[key];
  3098. }
  3099. };
  3100. const showClear = vue.computed(() => {
  3101. const readonly = getProp("readonly");
  3102. if (props.clearable && !readonly) {
  3103. const hasValue = getModelValue() !== "";
  3104. const trigger = props.clearTrigger === "always" || props.clearTrigger === "focus" && state.focused;
  3105. return hasValue && trigger;
  3106. }
  3107. return false;
  3108. });
  3109. const formValue = vue.computed(() => {
  3110. if (customValue.value && slots.input) {
  3111. return customValue.value();
  3112. }
  3113. return props.modelValue;
  3114. });
  3115. const runRules = (rules) => rules.reduce((promise, rule) => promise.then(() => {
  3116. if (state.status === "failed") {
  3117. return;
  3118. }
  3119. let {
  3120. value
  3121. } = formValue;
  3122. if (rule.formatter) {
  3123. value = rule.formatter(value, rule);
  3124. }
  3125. if (!runSyncRule(value, rule)) {
  3126. state.status = "failed";
  3127. state.validateMessage = getRuleMessage(value, rule);
  3128. return;
  3129. }
  3130. if (rule.validator) {
  3131. if (isEmptyValue(value) && rule.validateEmpty === false) {
  3132. return;
  3133. }
  3134. return runRuleValidator(value, rule).then((result) => {
  3135. if (result && typeof result === "string") {
  3136. state.status = "failed";
  3137. state.validateMessage = result;
  3138. } else if (result === false) {
  3139. state.status = "failed";
  3140. state.validateMessage = getRuleMessage(value, rule);
  3141. }
  3142. });
  3143. }
  3144. }), Promise.resolve());
  3145. const resetValidation = () => {
  3146. state.status = "unvalidated";
  3147. state.validateMessage = "";
  3148. };
  3149. const endValidate = () => emit("end-validate", {
  3150. status: state.status
  3151. });
  3152. const validate = (rules = props.rules) => new Promise((resolve) => {
  3153. resetValidation();
  3154. if (rules) {
  3155. emit("start-validate");
  3156. runRules(rules).then(() => {
  3157. if (state.status === "failed") {
  3158. resolve({
  3159. name: props.name,
  3160. message: state.validateMessage
  3161. });
  3162. endValidate();
  3163. } else {
  3164. state.status = "passed";
  3165. resolve();
  3166. endValidate();
  3167. }
  3168. });
  3169. } else {
  3170. resolve();
  3171. }
  3172. });
  3173. const validateWithTrigger = (trigger) => {
  3174. if (form && props.rules) {
  3175. const {
  3176. validateTrigger
  3177. } = form.props;
  3178. const defaultTrigger = toArray(validateTrigger).includes(trigger);
  3179. const rules = props.rules.filter((rule) => {
  3180. if (rule.trigger) {
  3181. return toArray(rule.trigger).includes(trigger);
  3182. }
  3183. return defaultTrigger;
  3184. });
  3185. if (rules.length) {
  3186. validate(rules);
  3187. }
  3188. }
  3189. };
  3190. const limitValueLength = (value) => {
  3191. const {
  3192. maxlength
  3193. } = props;
  3194. if (isDef(maxlength) && getStringLength(value) > maxlength) {
  3195. const modelValue = getModelValue();
  3196. if (modelValue && getStringLength(modelValue) === +maxlength) {
  3197. return modelValue;
  3198. }
  3199. return cutString(value, +maxlength);
  3200. }
  3201. return value;
  3202. };
  3203. const updateValue = (value, trigger = "onChange") => {
  3204. value = limitValueLength(value);
  3205. if (props.type === "number" || props.type === "digit") {
  3206. const isNumber = props.type === "number";
  3207. value = formatNumber(value, isNumber, isNumber);
  3208. }
  3209. if (props.formatter && trigger === props.formatTrigger) {
  3210. value = props.formatter(value);
  3211. }
  3212. if (inputRef.value && inputRef.value.value !== value) {
  3213. inputRef.value.value = value;
  3214. }
  3215. if (value !== props.modelValue) {
  3216. emit("update:modelValue", value);
  3217. }
  3218. };
  3219. const onInput = (event) => {
  3220. if (!event.target.composing) {
  3221. updateValue(event.target.value);
  3222. }
  3223. };
  3224. const blur = () => {
  3225. var _a;
  3226. return (_a = inputRef.value) == null ? void 0 : _a.blur();
  3227. };
  3228. const focus = () => {
  3229. var _a;
  3230. return (_a = inputRef.value) == null ? void 0 : _a.focus();
  3231. };
  3232. const adjustTextareaSize = () => {
  3233. const input = inputRef.value;
  3234. if (props.type === "textarea" && props.autosize && input) {
  3235. resizeTextarea(input, props.autosize);
  3236. }
  3237. };
  3238. const onFocus = (event) => {
  3239. state.focused = true;
  3240. emit("focus", event);
  3241. vue.nextTick(adjustTextareaSize);
  3242. if (getProp("readonly")) {
  3243. blur();
  3244. }
  3245. };
  3246. const onBlur = (event) => {
  3247. if (getProp("readonly")) {
  3248. return;
  3249. }
  3250. state.focused = false;
  3251. updateValue(getModelValue(), "onBlur");
  3252. emit("blur", event);
  3253. validateWithTrigger("onBlur");
  3254. vue.nextTick(adjustTextareaSize);
  3255. resetScroll();
  3256. };
  3257. const onClickInput = (event) => emit("click-input", event);
  3258. const onClickLeftIcon = (event) => emit("click-left-icon", event);
  3259. const onClickRightIcon = (event) => emit("click-right-icon", event);
  3260. const onClear = (event) => {
  3261. preventDefault(event);
  3262. emit("update:modelValue", "");
  3263. emit("clear", event);
  3264. };
  3265. const showError = vue.computed(() => {
  3266. if (typeof props.error === "boolean") {
  3267. return props.error;
  3268. }
  3269. if (form && form.props.showError && state.status === "failed") {
  3270. return true;
  3271. }
  3272. });
  3273. const labelStyle = vue.computed(() => {
  3274. const labelWidth = getProp("labelWidth");
  3275. if (labelWidth) {
  3276. return {
  3277. width: addUnit(labelWidth)
  3278. };
  3279. }
  3280. });
  3281. const onKeypress = (event) => {
  3282. const ENTER_CODE = 13;
  3283. if (event.keyCode === ENTER_CODE) {
  3284. const submitOnEnter = form && form.props.submitOnEnter;
  3285. if (!submitOnEnter && props.type !== "textarea") {
  3286. preventDefault(event);
  3287. }
  3288. if (props.type === "search") {
  3289. blur();
  3290. }
  3291. }
  3292. emit("keypress", event);
  3293. };
  3294. const getInputId = () => props.id || `${id}-input`;
  3295. const getValidationStatus = () => state.status;
  3296. const renderInput = () => {
  3297. const controlClass = bem$1b("control", [getProp("inputAlign"), {
  3298. error: showError.value,
  3299. custom: !!slots.input,
  3300. "min-height": props.type === "textarea" && !props.autosize
  3301. }]);
  3302. if (slots.input) {
  3303. return vue.createVNode("div", {
  3304. "class": controlClass,
  3305. "onClick": onClickInput
  3306. }, [slots.input()]);
  3307. }
  3308. const inputAttrs = {
  3309. id: getInputId(),
  3310. ref: inputRef,
  3311. name: props.name,
  3312. rows: props.rows !== void 0 ? +props.rows : void 0,
  3313. class: controlClass,
  3314. disabled: getProp("disabled"),
  3315. readonly: getProp("readonly"),
  3316. autofocus: props.autofocus,
  3317. placeholder: props.placeholder,
  3318. autocomplete: props.autocomplete,
  3319. enterkeyhint: props.enterkeyhint,
  3320. "aria-labelledby": props.label ? `${id}-label` : void 0,
  3321. onBlur,
  3322. onFocus,
  3323. onInput,
  3324. onClick: onClickInput,
  3325. onChange: endComposing,
  3326. onKeypress,
  3327. onCompositionend: endComposing,
  3328. onCompositionstart: startComposing
  3329. };
  3330. if (props.type === "textarea") {
  3331. return vue.createVNode("textarea", inputAttrs, null);
  3332. }
  3333. return vue.createVNode("input", vue.mergeProps(mapInputType(props.type), inputAttrs), null);
  3334. };
  3335. const renderLeftIcon = () => {
  3336. const leftIconSlot = slots["left-icon"];
  3337. if (props.leftIcon || leftIconSlot) {
  3338. return vue.createVNode("div", {
  3339. "class": bem$1b("left-icon"),
  3340. "onClick": onClickLeftIcon
  3341. }, [leftIconSlot ? leftIconSlot() : vue.createVNode(Icon, {
  3342. "name": props.leftIcon,
  3343. "classPrefix": props.iconPrefix
  3344. }, null)]);
  3345. }
  3346. };
  3347. const renderRightIcon = () => {
  3348. const rightIconSlot = slots["right-icon"];
  3349. if (props.rightIcon || rightIconSlot) {
  3350. return vue.createVNode("div", {
  3351. "class": bem$1b("right-icon"),
  3352. "onClick": onClickRightIcon
  3353. }, [rightIconSlot ? rightIconSlot() : vue.createVNode(Icon, {
  3354. "name": props.rightIcon,
  3355. "classPrefix": props.iconPrefix
  3356. }, null)]);
  3357. }
  3358. };
  3359. const renderWordLimit = () => {
  3360. if (props.showWordLimit && props.maxlength) {
  3361. const count = getStringLength(getModelValue());
  3362. return vue.createVNode("div", {
  3363. "class": bem$1b("word-limit")
  3364. }, [vue.createVNode("span", {
  3365. "class": bem$1b("word-num")
  3366. }, [count]), vue.createTextVNode("/"), props.maxlength]);
  3367. }
  3368. };
  3369. const renderMessage = () => {
  3370. if (form && form.props.showErrorMessage === false) {
  3371. return;
  3372. }
  3373. const message = props.errorMessage || state.validateMessage;
  3374. if (message) {
  3375. const slot = slots["error-message"];
  3376. const errorMessageAlign = getProp("errorMessageAlign");
  3377. return vue.createVNode("div", {
  3378. "class": bem$1b("error-message", errorMessageAlign)
  3379. }, [slot ? slot({
  3380. message
  3381. }) : message]);
  3382. }
  3383. };
  3384. const renderLabel = () => {
  3385. const colon = getProp("colon") ? ":" : "";
  3386. if (slots.label) {
  3387. return [slots.label(), colon];
  3388. }
  3389. if (props.label) {
  3390. return vue.createVNode("label", {
  3391. "id": `${id}-label`,
  3392. "for": getInputId()
  3393. }, [props.label + colon]);
  3394. }
  3395. };
  3396. const renderFieldBody = () => [vue.createVNode("div", {
  3397. "class": bem$1b("body")
  3398. }, [renderInput(), showClear.value && vue.createVNode(Icon, {
  3399. "ref": clearIconRef,
  3400. "name": props.clearIcon,
  3401. "class": bem$1b("clear")
  3402. }, null), renderRightIcon(), slots.button && vue.createVNode("div", {
  3403. "class": bem$1b("button")
  3404. }, [slots.button()])]), renderWordLimit(), renderMessage()];
  3405. useExpose({
  3406. blur,
  3407. focus,
  3408. validate,
  3409. formValue,
  3410. resetValidation,
  3411. getValidationStatus
  3412. });
  3413. vue.provide(CUSTOM_FIELD_INJECTION_KEY, {
  3414. customValue,
  3415. resetValidation,
  3416. validateWithTrigger
  3417. });
  3418. vue.watch(() => props.modelValue, () => {
  3419. updateValue(getModelValue());
  3420. resetValidation();
  3421. validateWithTrigger("onChange");
  3422. vue.nextTick(adjustTextareaSize);
  3423. });
  3424. vue.onMounted(() => {
  3425. updateValue(getModelValue(), props.formatTrigger);
  3426. vue.nextTick(adjustTextareaSize);
  3427. });
  3428. useEventListener("touchstart", onClear, {
  3429. target: vue.computed(() => {
  3430. var _a;
  3431. return (_a = clearIconRef.value) == null ? void 0 : _a.$el;
  3432. })
  3433. });
  3434. return () => {
  3435. const disabled = getProp("disabled");
  3436. const labelAlign = getProp("labelAlign");
  3437. const Label = renderLabel();
  3438. const LeftIcon = renderLeftIcon();
  3439. return vue.createVNode(Cell, {
  3440. "size": props.size,
  3441. "icon": props.leftIcon,
  3442. "class": bem$1b({
  3443. error: showError.value,
  3444. disabled,
  3445. [`label-${labelAlign}`]: labelAlign
  3446. }),
  3447. "center": props.center,
  3448. "border": props.border,
  3449. "isLink": props.isLink,
  3450. "clickable": props.clickable,
  3451. "titleStyle": labelStyle.value,
  3452. "valueClass": bem$1b("value"),
  3453. "titleClass": [bem$1b("label", [labelAlign, {
  3454. required: props.required
  3455. }]), props.labelClass],
  3456. "arrowDirection": props.arrowDirection
  3457. }, {
  3458. icon: LeftIcon ? () => LeftIcon : null,
  3459. title: Label ? () => Label : null,
  3460. value: renderFieldBody,
  3461. extra: slots.extra
  3462. });
  3463. };
  3464. }
  3465. });
  3466. const Field = withInstall(stdin_default$1m);
  3467. function usePopupState() {
  3468. const state = vue.reactive({
  3469. show: false
  3470. });
  3471. const toggle = (show) => {
  3472. state.show = show;
  3473. };
  3474. const open = (props) => {
  3475. extend(state, props, { transitionAppear: true });
  3476. toggle(true);
  3477. };
  3478. const close = () => toggle(false);
  3479. useExpose({ open, close, toggle });
  3480. return {
  3481. open,
  3482. close,
  3483. state,
  3484. toggle
  3485. };
  3486. }
  3487. function mountComponent(RootComponent) {
  3488. const app = vue.createApp(RootComponent);
  3489. const root = document.createElement("div");
  3490. document.body.appendChild(root);
  3491. return {
  3492. instance: app.mount(root),
  3493. unmount() {
  3494. app.unmount();
  3495. document.body.removeChild(root);
  3496. }
  3497. };
  3498. }
  3499. let lockCount = 0;
  3500. function lockClick(lock) {
  3501. if (lock) {
  3502. if (!lockCount) {
  3503. document.body.classList.add("van-toast--unclickable");
  3504. }
  3505. lockCount++;
  3506. } else if (lockCount) {
  3507. lockCount--;
  3508. if (!lockCount) {
  3509. document.body.classList.remove("van-toast--unclickable");
  3510. }
  3511. }
  3512. }
  3513. const [name$1e, bem$1a] = createNamespace("toast");
  3514. const popupInheritProps = ["show", "overlay", "teleport", "transition", "overlayClass", "overlayStyle", "closeOnClickOverlay"];
  3515. const toastProps = {
  3516. icon: String,
  3517. show: Boolean,
  3518. type: makeStringProp("text"),
  3519. overlay: Boolean,
  3520. message: numericProp,
  3521. iconSize: numericProp,
  3522. duration: makeNumberProp(2e3),
  3523. position: makeStringProp("middle"),
  3524. teleport: [String, Object],
  3525. className: unknownProp,
  3526. iconPrefix: String,
  3527. transition: makeStringProp("van-fade"),
  3528. loadingType: String,
  3529. forbidClick: Boolean,
  3530. overlayClass: unknownProp,
  3531. overlayStyle: Object,
  3532. closeOnClick: Boolean,
  3533. closeOnClickOverlay: Boolean
  3534. };
  3535. var stdin_default$1l = vue.defineComponent({
  3536. name: name$1e,
  3537. props: toastProps,
  3538. emits: ["update:show"],
  3539. setup(props, {
  3540. emit
  3541. }) {
  3542. let timer2;
  3543. let clickable = false;
  3544. const toggleClickable = () => {
  3545. const newValue = props.show && props.forbidClick;
  3546. if (clickable !== newValue) {
  3547. clickable = newValue;
  3548. lockClick(clickable);
  3549. }
  3550. };
  3551. const updateShow = (show) => emit("update:show", show);
  3552. const onClick = () => {
  3553. if (props.closeOnClick) {
  3554. updateShow(false);
  3555. }
  3556. };
  3557. const clearTimer = () => clearTimeout(timer2);
  3558. const renderIcon = () => {
  3559. const {
  3560. icon,
  3561. type,
  3562. iconSize,
  3563. iconPrefix,
  3564. loadingType
  3565. } = props;
  3566. const hasIcon = icon || type === "success" || type === "fail";
  3567. if (hasIcon) {
  3568. return vue.createVNode(Icon, {
  3569. "name": icon || type,
  3570. "size": iconSize,
  3571. "class": bem$1a("icon"),
  3572. "classPrefix": iconPrefix
  3573. }, null);
  3574. }
  3575. if (type === "loading") {
  3576. return vue.createVNode(Loading, {
  3577. "class": bem$1a("loading"),
  3578. "size": iconSize,
  3579. "type": loadingType
  3580. }, null);
  3581. }
  3582. };
  3583. const renderMessage = () => {
  3584. const {
  3585. type,
  3586. message
  3587. } = props;
  3588. if (isDef(message) && message !== "") {
  3589. return type === "html" ? vue.createVNode("div", {
  3590. "key": 0,
  3591. "class": bem$1a("text"),
  3592. "innerHTML": String(message)
  3593. }, null) : vue.createVNode("div", {
  3594. "class": bem$1a("text")
  3595. }, [message]);
  3596. }
  3597. };
  3598. vue.watch(() => [props.show, props.forbidClick], toggleClickable);
  3599. vue.watch(() => [props.show, props.type, props.message, props.duration], () => {
  3600. clearTimer();
  3601. if (props.show && props.duration > 0) {
  3602. timer2 = setTimeout(() => {
  3603. updateShow(false);
  3604. }, props.duration);
  3605. }
  3606. });
  3607. vue.onMounted(toggleClickable);
  3608. vue.onUnmounted(toggleClickable);
  3609. return () => vue.createVNode(Popup, vue.mergeProps({
  3610. "class": [bem$1a([props.position, {
  3611. [props.type]: !props.icon
  3612. }]), props.className],
  3613. "lockScroll": false,
  3614. "onClick": onClick,
  3615. "onClosed": clearTimer,
  3616. "onUpdate:show": updateShow
  3617. }, pick(props, popupInheritProps)), {
  3618. default: () => [renderIcon(), renderMessage()]
  3619. });
  3620. }
  3621. });
  3622. const defaultOptions$1 = {
  3623. icon: "",
  3624. type: "text",
  3625. message: "",
  3626. className: "",
  3627. overlay: false,
  3628. onClose: void 0,
  3629. onOpened: void 0,
  3630. duration: 2e3,
  3631. teleport: "body",
  3632. iconSize: void 0,
  3633. iconPrefix: void 0,
  3634. position: "middle",
  3635. transition: "van-fade",
  3636. forbidClick: false,
  3637. loadingType: void 0,
  3638. overlayClass: "",
  3639. overlayStyle: void 0,
  3640. closeOnClick: false,
  3641. closeOnClickOverlay: false
  3642. };
  3643. let queue = [];
  3644. let allowMultiple = false;
  3645. let currentOptions = extend({}, defaultOptions$1);
  3646. const defaultOptionsMap = /* @__PURE__ */ new Map();
  3647. function parseOptions$1(message) {
  3648. if (isObject(message)) {
  3649. return message;
  3650. }
  3651. return {
  3652. message
  3653. };
  3654. }
  3655. function createInstance() {
  3656. const {
  3657. instance: instance2,
  3658. unmount
  3659. } = mountComponent({
  3660. setup() {
  3661. const message = vue.ref("");
  3662. const {
  3663. open,
  3664. state,
  3665. close,
  3666. toggle
  3667. } = usePopupState();
  3668. const onClosed = () => {
  3669. if (allowMultiple) {
  3670. queue = queue.filter((item) => item !== instance2);
  3671. unmount();
  3672. }
  3673. };
  3674. const render = () => {
  3675. const attrs = {
  3676. onClosed,
  3677. "onUpdate:show": toggle
  3678. };
  3679. return vue.createVNode(stdin_default$1l, vue.mergeProps(state, attrs), null);
  3680. };
  3681. vue.watch(message, (val) => {
  3682. state.message = val;
  3683. });
  3684. vue.getCurrentInstance().render = render;
  3685. return {
  3686. open,
  3687. clear: close,
  3688. message
  3689. };
  3690. }
  3691. });
  3692. return instance2;
  3693. }
  3694. function getInstance() {
  3695. if (!queue.length || allowMultiple) {
  3696. const instance2 = createInstance();
  3697. queue.push(instance2);
  3698. }
  3699. return queue[queue.length - 1];
  3700. }
  3701. function Toast(options = {}) {
  3702. if (!inBrowser$1) {
  3703. return {};
  3704. }
  3705. const toast = getInstance();
  3706. const parsedOptions = parseOptions$1(options);
  3707. toast.open(extend({}, currentOptions, defaultOptionsMap.get(parsedOptions.type || currentOptions.type), parsedOptions));
  3708. return toast;
  3709. }
  3710. const createMethod = (type) => (options) => Toast(extend({
  3711. type
  3712. }, parseOptions$1(options)));
  3713. Toast.loading = createMethod("loading");
  3714. Toast.success = createMethod("success");
  3715. Toast.fail = createMethod("fail");
  3716. Toast.clear = (all) => {
  3717. var _a;
  3718. if (queue.length) {
  3719. if (all) {
  3720. queue.forEach((toast) => {
  3721. toast.clear();
  3722. });
  3723. queue = [];
  3724. } else if (!allowMultiple) {
  3725. queue[0].clear();
  3726. } else {
  3727. (_a = queue.shift()) == null ? void 0 : _a.clear();
  3728. }
  3729. }
  3730. };
  3731. function setDefaultOptions(type, options) {
  3732. if (typeof type === "string") {
  3733. defaultOptionsMap.set(type, options);
  3734. } else {
  3735. extend(currentOptions, type);
  3736. }
  3737. }
  3738. Toast.setDefaultOptions = setDefaultOptions;
  3739. Toast.resetDefaultOptions = (type) => {
  3740. if (typeof type === "string") {
  3741. defaultOptionsMap.delete(type);
  3742. } else {
  3743. currentOptions = extend({}, defaultOptions$1);
  3744. defaultOptionsMap.clear();
  3745. }
  3746. };
  3747. Toast.allowMultiple = (value = true) => {
  3748. allowMultiple = value;
  3749. };
  3750. Toast.install = (app) => {
  3751. app.use(withInstall(stdin_default$1l));
  3752. app.config.globalProperties.$toast = Toast;
  3753. };
  3754. const [name$1d, bem$19] = createNamespace("switch");
  3755. const switchProps = {
  3756. size: numericProp,
  3757. loading: Boolean,
  3758. disabled: Boolean,
  3759. modelValue: unknownProp,
  3760. activeColor: String,
  3761. inactiveColor: String,
  3762. activeValue: {
  3763. type: unknownProp,
  3764. default: true
  3765. },
  3766. inactiveValue: {
  3767. type: unknownProp,
  3768. default: false
  3769. }
  3770. };
  3771. var stdin_default$1k = vue.defineComponent({
  3772. name: name$1d,
  3773. props: switchProps,
  3774. emits: ["change", "update:modelValue"],
  3775. setup(props, {
  3776. emit,
  3777. slots
  3778. }) {
  3779. const isChecked = () => props.modelValue === props.activeValue;
  3780. const onClick = () => {
  3781. if (!props.disabled && !props.loading) {
  3782. const newValue = isChecked() ? props.inactiveValue : props.activeValue;
  3783. emit("update:modelValue", newValue);
  3784. emit("change", newValue);
  3785. }
  3786. };
  3787. const renderLoading = () => {
  3788. if (props.loading) {
  3789. const color = isChecked() ? props.activeColor : props.inactiveColor;
  3790. return vue.createVNode(Loading, {
  3791. "class": bem$19("loading"),
  3792. "color": color
  3793. }, null);
  3794. }
  3795. if (slots.node) {
  3796. return slots.node();
  3797. }
  3798. };
  3799. useCustomFieldValue(() => props.modelValue);
  3800. return () => {
  3801. var _a;
  3802. const {
  3803. size,
  3804. loading,
  3805. disabled,
  3806. activeColor,
  3807. inactiveColor
  3808. } = props;
  3809. const checked = isChecked();
  3810. const style = {
  3811. fontSize: addUnit(size),
  3812. backgroundColor: checked ? activeColor : inactiveColor
  3813. };
  3814. return vue.createVNode("div", {
  3815. "role": "switch",
  3816. "class": bem$19({
  3817. on: checked,
  3818. loading,
  3819. disabled
  3820. }),
  3821. "style": style,
  3822. "tabindex": disabled ? void 0 : 0,
  3823. "aria-checked": checked,
  3824. "onClick": onClick
  3825. }, [vue.createVNode("div", {
  3826. "class": bem$19("node")
  3827. }, [renderLoading()]), (_a = slots.background) == null ? void 0 : _a.call(slots)]);
  3828. };
  3829. }
  3830. });
  3831. const Switch = withInstall(stdin_default$1k);
  3832. const [name$1c, bem$18] = createNamespace("address-edit-detail");
  3833. const t$i = createNamespace("address-edit")[2];
  3834. var stdin_default$1j = vue.defineComponent({
  3835. name: name$1c,
  3836. props: {
  3837. show: Boolean,
  3838. rows: numericProp,
  3839. value: String,
  3840. rules: Array,
  3841. focused: Boolean,
  3842. maxlength: numericProp,
  3843. searchResult: Array,
  3844. showSearchResult: Boolean
  3845. },
  3846. emits: ["blur", "focus", "input", "select-search"],
  3847. setup(props, {
  3848. emit
  3849. }) {
  3850. const field = vue.ref();
  3851. const showSearchResult = () => props.focused && props.searchResult && props.showSearchResult;
  3852. const onSelect = (express) => {
  3853. emit("select-search", express);
  3854. emit("input", `${express.address || ""} ${express.name || ""}`.trim());
  3855. };
  3856. const renderSearchTitle = (express) => {
  3857. if (express.name) {
  3858. const text = express.name.replace(props.value, `<span class=${bem$18("keyword")}>${props.value}</span>`);
  3859. return vue.createVNode("div", {
  3860. "innerHTML": text
  3861. }, null);
  3862. }
  3863. };
  3864. const renderSearchResult = () => {
  3865. if (!showSearchResult()) {
  3866. return;
  3867. }
  3868. const {
  3869. searchResult
  3870. } = props;
  3871. return searchResult.map((express) => vue.createVNode(Cell, {
  3872. "clickable": true,
  3873. "key": express.name + express.address,
  3874. "icon": "location-o",
  3875. "label": express.address,
  3876. "class": bem$18("search-item"),
  3877. "border": false,
  3878. "onClick": () => onSelect(express)
  3879. }, {
  3880. title: () => renderSearchTitle(express)
  3881. }));
  3882. };
  3883. const onBlur = (event) => emit("blur", event);
  3884. const onFocus = (event) => emit("focus", event);
  3885. const onInput = (value) => emit("input", value);
  3886. return () => {
  3887. if (props.show) {
  3888. return vue.createVNode(vue.Fragment, null, [vue.createVNode(Field, {
  3889. "autosize": true,
  3890. "clearable": true,
  3891. "ref": field,
  3892. "class": bem$18(),
  3893. "rows": props.rows,
  3894. "type": "textarea",
  3895. "rules": props.rules,
  3896. "label": t$i("addressDetail"),
  3897. "border": !showSearchResult(),
  3898. "maxlength": props.maxlength,
  3899. "modelValue": props.value,
  3900. "placeholder": t$i("addressDetail"),
  3901. "onBlur": onBlur,
  3902. "onFocus": onFocus,
  3903. "onUpdate:modelValue": onInput
  3904. }, null), renderSearchResult()]);
  3905. }
  3906. };
  3907. }
  3908. });
  3909. const [name$1b, bem$17, t$h] = createNamespace("address-edit");
  3910. const DEFAULT_DATA = {
  3911. name: "",
  3912. tel: "",
  3913. city: "",
  3914. county: "",
  3915. country: "",
  3916. province: "",
  3917. areaCode: "",
  3918. isDefault: false,
  3919. postalCode: "",
  3920. addressDetail: ""
  3921. };
  3922. const isPostal = (value) => /^\d{6}$/.test(value);
  3923. const addressEditProps = {
  3924. areaList: Object,
  3925. isSaving: Boolean,
  3926. isDeleting: Boolean,
  3927. validator: Function,
  3928. showArea: truthProp,
  3929. showDetail: truthProp,
  3930. showDelete: Boolean,
  3931. showPostal: Boolean,
  3932. disableArea: Boolean,
  3933. searchResult: Array,
  3934. telMaxlength: numericProp,
  3935. showSetDefault: Boolean,
  3936. saveButtonText: String,
  3937. areaPlaceholder: String,
  3938. deleteButtonText: String,
  3939. showSearchResult: Boolean,
  3940. detailRows: makeNumericProp(1),
  3941. detailMaxlength: makeNumericProp(200),
  3942. areaColumnsPlaceholder: makeArrayProp(),
  3943. addressInfo: {
  3944. type: Object,
  3945. default: () => extend({}, DEFAULT_DATA)
  3946. },
  3947. telValidator: {
  3948. type: Function,
  3949. default: isMobile
  3950. },
  3951. postalValidator: {
  3952. type: Function,
  3953. default: isPostal
  3954. }
  3955. };
  3956. var stdin_default$1i = vue.defineComponent({
  3957. name: name$1b,
  3958. props: addressEditProps,
  3959. emits: ["save", "focus", "delete", "click-area", "change-area", "change-detail", "select-search", "change-default"],
  3960. setup(props, {
  3961. emit,
  3962. slots
  3963. }) {
  3964. const areaRef = vue.ref();
  3965. const data = vue.reactive({});
  3966. const showAreaPopup = vue.ref(false);
  3967. const detailFocused = vue.ref(false);
  3968. const areaListLoaded = vue.computed(() => isObject(props.areaList) && Object.keys(props.areaList).length);
  3969. const areaText = vue.computed(() => {
  3970. const {
  3971. country,
  3972. province,
  3973. city,
  3974. county,
  3975. areaCode
  3976. } = data;
  3977. if (areaCode) {
  3978. const arr = [country, province, city, county];
  3979. if (province && province === city) {
  3980. arr.splice(1, 1);
  3981. }
  3982. return arr.filter(Boolean).join("/");
  3983. }
  3984. return "";
  3985. });
  3986. const hideBottomFields = vue.computed(() => {
  3987. var _a;
  3988. return ((_a = props.searchResult) == null ? void 0 : _a.length) && detailFocused.value;
  3989. });
  3990. const assignAreaValues = () => {
  3991. if (areaRef.value) {
  3992. const detail = areaRef.value.getArea();
  3993. detail.areaCode = detail.code;
  3994. delete detail.code;
  3995. extend(data, detail);
  3996. }
  3997. };
  3998. const onFocus = (key) => {
  3999. detailFocused.value = key === "addressDetail";
  4000. emit("focus", key);
  4001. };
  4002. const rules = vue.computed(() => {
  4003. const {
  4004. validator,
  4005. telValidator,
  4006. postalValidator
  4007. } = props;
  4008. const makeRule = (name2, emptyMessage) => ({
  4009. validator: (value) => {
  4010. if (validator) {
  4011. const message = validator(name2, value);
  4012. if (message) {
  4013. return message;
  4014. }
  4015. }
  4016. if (!value) {
  4017. return emptyMessage;
  4018. }
  4019. return true;
  4020. }
  4021. });
  4022. return {
  4023. name: [makeRule("name", t$h("nameEmpty"))],
  4024. tel: [makeRule("tel", t$h("telInvalid")), {
  4025. validator: telValidator,
  4026. message: t$h("telInvalid")
  4027. }],
  4028. areaCode: [makeRule("areaCode", t$h("areaEmpty"))],
  4029. addressDetail: [makeRule("addressDetail", t$h("addressEmpty"))],
  4030. postalCode: [makeRule("addressDetail", t$h("postalEmpty")), {
  4031. validator: postalValidator,
  4032. message: t$h("postalEmpty")
  4033. }]
  4034. };
  4035. });
  4036. const onSave = () => emit("save", data);
  4037. const onChangeDetail = (val) => {
  4038. data.addressDetail = val;
  4039. emit("change-detail", val);
  4040. };
  4041. const onAreaConfirm = (values) => {
  4042. values = values.filter(Boolean);
  4043. if (values.some((value) => !value.code)) {
  4044. Toast(t$h("areaEmpty"));
  4045. } else {
  4046. showAreaPopup.value = false;
  4047. assignAreaValues();
  4048. emit("change-area", values);
  4049. }
  4050. };
  4051. const onDelete = () => emit("delete", data);
  4052. const getArea = () => {
  4053. var _a;
  4054. return ((_a = areaRef.value) == null ? void 0 : _a.getValues()) || [];
  4055. };
  4056. const setAreaCode = (code) => {
  4057. data.areaCode = code || "";
  4058. if (code) {
  4059. vue.nextTick(assignAreaValues);
  4060. }
  4061. };
  4062. const onDetailBlur = () => {
  4063. setTimeout(() => {
  4064. detailFocused.value = false;
  4065. });
  4066. };
  4067. const setAddressDetail = (value) => {
  4068. data.addressDetail = value;
  4069. };
  4070. const renderSetDefaultCell = () => {
  4071. if (props.showSetDefault) {
  4072. const slots2 = {
  4073. "right-icon": () => vue.createVNode(Switch, {
  4074. "modelValue": data.isDefault,
  4075. "onUpdate:modelValue": ($event) => data.isDefault = $event,
  4076. "size": "24",
  4077. "onChange": (event) => emit("change-default", event)
  4078. }, null)
  4079. };
  4080. return vue.withDirectives(vue.createVNode(Cell, {
  4081. "center": true,
  4082. "title": t$h("defaultAddress"),
  4083. "class": bem$17("default")
  4084. }, slots2), [[vue.vShow, !hideBottomFields.value]]);
  4085. }
  4086. };
  4087. useExpose({
  4088. getArea,
  4089. setAreaCode,
  4090. setAddressDetail
  4091. });
  4092. vue.watch(() => props.areaList, () => setAreaCode(data.areaCode));
  4093. vue.watch(() => props.addressInfo, (value) => {
  4094. extend(data, DEFAULT_DATA, value);
  4095. setAreaCode(value.areaCode);
  4096. }, {
  4097. deep: true,
  4098. immediate: true
  4099. });
  4100. return () => {
  4101. const {
  4102. disableArea
  4103. } = props;
  4104. return vue.createVNode(Form, {
  4105. "class": bem$17(),
  4106. "onSubmit": onSave
  4107. }, {
  4108. default: () => {
  4109. var _a;
  4110. return [vue.createVNode("div", {
  4111. "class": bem$17("fields")
  4112. }, [vue.createVNode(Field, {
  4113. "modelValue": data.name,
  4114. "onUpdate:modelValue": ($event) => data.name = $event,
  4115. "clearable": true,
  4116. "label": t$h("name"),
  4117. "rules": rules.value.name,
  4118. "placeholder": t$h("name"),
  4119. "onFocus": () => onFocus("name")
  4120. }, null), vue.createVNode(Field, {
  4121. "modelValue": data.tel,
  4122. "onUpdate:modelValue": ($event) => data.tel = $event,
  4123. "clearable": true,
  4124. "type": "tel",
  4125. "label": t$h("tel"),
  4126. "rules": rules.value.tel,
  4127. "maxlength": props.telMaxlength,
  4128. "placeholder": t$h("tel"),
  4129. "onFocus": () => onFocus("tel")
  4130. }, null), vue.withDirectives(vue.createVNode(Field, {
  4131. "readonly": true,
  4132. "label": t$h("area"),
  4133. "is-link": !disableArea,
  4134. "modelValue": areaText.value,
  4135. "rules": rules.value.areaCode,
  4136. "placeholder": props.areaPlaceholder || t$h("area"),
  4137. "onFocus": () => onFocus("areaCode"),
  4138. "onClick": () => {
  4139. emit("click-area");
  4140. showAreaPopup.value = !disableArea;
  4141. }
  4142. }, null), [[vue.vShow, props.showArea]]), vue.createVNode(stdin_default$1j, {
  4143. "show": props.showDetail,
  4144. "rows": props.detailRows,
  4145. "rules": rules.value.addressDetail,
  4146. "value": data.addressDetail,
  4147. "focused": detailFocused.value,
  4148. "maxlength": props.detailMaxlength,
  4149. "searchResult": props.searchResult,
  4150. "showSearchResult": props.showSearchResult,
  4151. "onBlur": onDetailBlur,
  4152. "onFocus": () => onFocus("addressDetail"),
  4153. "onInput": onChangeDetail,
  4154. "onSelect-search": (event) => emit("select-search", event)
  4155. }, null), props.showPostal && vue.withDirectives(vue.createVNode(Field, {
  4156. "modelValue": data.postalCode,
  4157. "onUpdate:modelValue": ($event) => data.postalCode = $event,
  4158. "type": "tel",
  4159. "rules": rules.value.postalCode,
  4160. "label": t$h("postal"),
  4161. "maxlength": "6",
  4162. "placeholder": t$h("postal"),
  4163. "onFocus": () => onFocus("postalCode")
  4164. }, null), [[vue.vShow, !hideBottomFields.value]]), (_a = slots.default) == null ? void 0 : _a.call(slots)]), renderSetDefaultCell(), vue.withDirectives(vue.createVNode("div", {
  4165. "class": bem$17("buttons")
  4166. }, [vue.createVNode(Button, {
  4167. "block": true,
  4168. "round": true,
  4169. "type": "danger",
  4170. "text": props.saveButtonText || t$h("save"),
  4171. "class": bem$17("button"),
  4172. "loading": props.isSaving,
  4173. "nativeType": "submit"
  4174. }, null), props.showDelete && vue.createVNode(Button, {
  4175. "block": true,
  4176. "round": true,
  4177. "class": bem$17("button"),
  4178. "loading": props.isDeleting,
  4179. "text": props.deleteButtonText || t$h("delete"),
  4180. "onClick": onDelete
  4181. }, null)]), [[vue.vShow, !hideBottomFields.value]]), vue.createVNode(Popup, {
  4182. "show": showAreaPopup.value,
  4183. "onUpdate:show": ($event) => showAreaPopup.value = $event,
  4184. "round": true,
  4185. "teleport": "body",
  4186. "position": "bottom",
  4187. "lazyRender": false
  4188. }, {
  4189. default: () => [vue.createVNode(Area, {
  4190. "ref": areaRef,
  4191. "value": data.areaCode,
  4192. "loading": !areaListLoaded.value,
  4193. "areaList": props.areaList,
  4194. "columnsPlaceholder": props.areaColumnsPlaceholder,
  4195. "onConfirm": onAreaConfirm,
  4196. "onCancel": () => {
  4197. showAreaPopup.value = false;
  4198. }
  4199. }, null)]
  4200. })];
  4201. }
  4202. });
  4203. };
  4204. }
  4205. });
  4206. const AddressEdit = withInstall(stdin_default$1i);
  4207. const [name$1a, bem$16] = createNamespace("radio-group");
  4208. const radioGroupProps = {
  4209. disabled: Boolean,
  4210. iconSize: numericProp,
  4211. direction: String,
  4212. modelValue: unknownProp,
  4213. checkedColor: String
  4214. };
  4215. const RADIO_KEY = Symbol(name$1a);
  4216. var stdin_default$1h = vue.defineComponent({
  4217. name: name$1a,
  4218. props: radioGroupProps,
  4219. emits: ["change", "update:modelValue"],
  4220. setup(props, {
  4221. emit,
  4222. slots
  4223. }) {
  4224. const {
  4225. linkChildren
  4226. } = useChildren(RADIO_KEY);
  4227. const updateValue = (value) => emit("update:modelValue", value);
  4228. vue.watch(() => props.modelValue, (value) => emit("change", value));
  4229. linkChildren({
  4230. props,
  4231. updateValue
  4232. });
  4233. useCustomFieldValue(() => props.modelValue);
  4234. return () => {
  4235. var _a;
  4236. return vue.createVNode("div", {
  4237. "class": bem$16([props.direction]),
  4238. "role": "radiogroup"
  4239. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  4240. };
  4241. }
  4242. });
  4243. const RadioGroup = withInstall(stdin_default$1h);
  4244. const [name$19, bem$15] = createNamespace("tag");
  4245. const tagProps = {
  4246. size: String,
  4247. mark: Boolean,
  4248. show: truthProp,
  4249. type: makeStringProp("default"),
  4250. color: String,
  4251. plain: Boolean,
  4252. round: Boolean,
  4253. textColor: String,
  4254. closeable: Boolean
  4255. };
  4256. var stdin_default$1g = vue.defineComponent({
  4257. name: name$19,
  4258. props: tagProps,
  4259. emits: ["close"],
  4260. setup(props, {
  4261. slots,
  4262. emit
  4263. }) {
  4264. const onClose = (event) => {
  4265. event.stopPropagation();
  4266. emit("close", event);
  4267. };
  4268. const getStyle = () => {
  4269. if (props.plain) {
  4270. return {
  4271. color: props.textColor || props.color,
  4272. borderColor: props.color
  4273. };
  4274. }
  4275. return {
  4276. color: props.textColor,
  4277. background: props.color
  4278. };
  4279. };
  4280. const renderTag = () => {
  4281. var _a;
  4282. const {
  4283. type,
  4284. mark,
  4285. plain,
  4286. round: round2,
  4287. size,
  4288. closeable
  4289. } = props;
  4290. const classes = {
  4291. mark,
  4292. plain,
  4293. round: round2
  4294. };
  4295. if (size) {
  4296. classes[size] = size;
  4297. }
  4298. const CloseIcon = closeable && vue.createVNode(Icon, {
  4299. "name": "cross",
  4300. "class": [bem$15("close"), HAPTICS_FEEDBACK],
  4301. "onClick": onClose
  4302. }, null);
  4303. return vue.createVNode("span", {
  4304. "style": getStyle(),
  4305. "class": bem$15([classes, type])
  4306. }, [(_a = slots.default) == null ? void 0 : _a.call(slots), CloseIcon]);
  4307. };
  4308. return () => vue.createVNode(vue.Transition, {
  4309. "name": props.closeable ? "van-fade" : void 0
  4310. }, {
  4311. default: () => [props.show ? renderTag() : null]
  4312. });
  4313. }
  4314. });
  4315. const Tag = withInstall(stdin_default$1g);
  4316. const checkerProps = {
  4317. name: unknownProp,
  4318. shape: makeStringProp("round"),
  4319. disabled: Boolean,
  4320. iconSize: numericProp,
  4321. modelValue: unknownProp,
  4322. checkedColor: String,
  4323. labelPosition: String,
  4324. labelDisabled: Boolean
  4325. };
  4326. var stdin_default$1f = vue.defineComponent({
  4327. props: extend({}, checkerProps, {
  4328. bem: makeRequiredProp(Function),
  4329. role: String,
  4330. parent: Object,
  4331. checked: Boolean,
  4332. bindGroup: truthProp
  4333. }),
  4334. emits: ["click", "toggle"],
  4335. setup(props, {
  4336. emit,
  4337. slots
  4338. }) {
  4339. const iconRef = vue.ref();
  4340. const getParentProp = (name2) => {
  4341. if (props.parent && props.bindGroup) {
  4342. return props.parent.props[name2];
  4343. }
  4344. };
  4345. const disabled = vue.computed(() => getParentProp("disabled") || props.disabled);
  4346. const direction = vue.computed(() => getParentProp("direction"));
  4347. const iconStyle = vue.computed(() => {
  4348. const checkedColor = props.checkedColor || getParentProp("checkedColor");
  4349. if (checkedColor && props.checked && !disabled.value) {
  4350. return {
  4351. borderColor: checkedColor,
  4352. backgroundColor: checkedColor
  4353. };
  4354. }
  4355. });
  4356. const onClick = (event) => {
  4357. const {
  4358. target
  4359. } = event;
  4360. const icon = iconRef.value;
  4361. const iconClicked = icon === target || (icon == null ? void 0 : icon.contains(target));
  4362. if (!disabled.value && (iconClicked || !props.labelDisabled)) {
  4363. emit("toggle");
  4364. }
  4365. emit("click", event);
  4366. };
  4367. const renderIcon = () => {
  4368. const {
  4369. bem: bem2,
  4370. shape,
  4371. checked
  4372. } = props;
  4373. const iconSize = props.iconSize || getParentProp("iconSize");
  4374. return vue.createVNode("div", {
  4375. "ref": iconRef,
  4376. "class": bem2("icon", [shape, {
  4377. disabled: disabled.value,
  4378. checked
  4379. }]),
  4380. "style": {
  4381. fontSize: addUnit(iconSize)
  4382. }
  4383. }, [slots.icon ? slots.icon({
  4384. checked,
  4385. disabled: disabled.value
  4386. }) : vue.createVNode(Icon, {
  4387. "name": "success",
  4388. "style": iconStyle.value
  4389. }, null)]);
  4390. };
  4391. const renderLabel = () => {
  4392. if (slots.default) {
  4393. return vue.createVNode("span", {
  4394. "class": props.bem("label", [props.labelPosition, {
  4395. disabled: disabled.value
  4396. }])
  4397. }, [slots.default()]);
  4398. }
  4399. };
  4400. return () => {
  4401. const nodes = props.labelPosition === "left" ? [renderLabel(), renderIcon()] : [renderIcon(), renderLabel()];
  4402. return vue.createVNode("div", {
  4403. "role": props.role,
  4404. "class": props.bem([{
  4405. disabled: disabled.value,
  4406. "label-disabled": props.labelDisabled
  4407. }, direction.value]),
  4408. "tabindex": disabled.value ? void 0 : 0,
  4409. "aria-checked": props.checked,
  4410. "onClick": onClick
  4411. }, [nodes]);
  4412. };
  4413. }
  4414. });
  4415. const [name$18, bem$14] = createNamespace("radio");
  4416. var stdin_default$1e = vue.defineComponent({
  4417. name: name$18,
  4418. props: checkerProps,
  4419. emits: ["update:modelValue"],
  4420. setup(props, {
  4421. emit,
  4422. slots
  4423. }) {
  4424. const {
  4425. parent
  4426. } = useParent(RADIO_KEY);
  4427. const checked = () => {
  4428. const value = parent ? parent.props.modelValue : props.modelValue;
  4429. return value === props.name;
  4430. };
  4431. const toggle = () => {
  4432. if (parent) {
  4433. parent.updateValue(props.name);
  4434. } else {
  4435. emit("update:modelValue", props.name);
  4436. }
  4437. };
  4438. return () => vue.createVNode(stdin_default$1f, vue.mergeProps({
  4439. "bem": bem$14,
  4440. "role": "radio",
  4441. "parent": parent,
  4442. "checked": checked(),
  4443. "onToggle": toggle
  4444. }, props), pick(slots, ["default", "icon"]));
  4445. }
  4446. });
  4447. const Radio = withInstall(stdin_default$1e);
  4448. const [name$17, bem$13] = createNamespace("address-item");
  4449. var stdin_default$1d = vue.defineComponent({
  4450. name: name$17,
  4451. props: {
  4452. address: makeRequiredProp(Object),
  4453. disabled: Boolean,
  4454. switchable: Boolean,
  4455. defaultTagText: String
  4456. },
  4457. emits: ["edit", "click", "select"],
  4458. setup(props, {
  4459. slots,
  4460. emit
  4461. }) {
  4462. const onClick = () => {
  4463. if (props.switchable) {
  4464. emit("select");
  4465. }
  4466. emit("click");
  4467. };
  4468. const renderRightIcon = () => vue.createVNode(Icon, {
  4469. "name": "edit",
  4470. "class": bem$13("edit"),
  4471. "onClick": (event) => {
  4472. event.stopPropagation();
  4473. emit("edit");
  4474. emit("click");
  4475. }
  4476. }, null);
  4477. const renderTag = () => {
  4478. if (slots.tag) {
  4479. return slots.tag(props.address);
  4480. }
  4481. if (props.address.isDefault && props.defaultTagText) {
  4482. return vue.createVNode(Tag, {
  4483. "type": "danger",
  4484. "round": true,
  4485. "class": bem$13("tag")
  4486. }, {
  4487. default: () => [props.defaultTagText]
  4488. });
  4489. }
  4490. };
  4491. const renderContent = () => {
  4492. const {
  4493. address,
  4494. disabled,
  4495. switchable
  4496. } = props;
  4497. const Info = [vue.createVNode("div", {
  4498. "class": bem$13("name")
  4499. }, [`${address.name} ${address.tel}`, renderTag()]), vue.createVNode("div", {
  4500. "class": bem$13("address")
  4501. }, [address.address])];
  4502. if (switchable && !disabled) {
  4503. return vue.createVNode(Radio, {
  4504. "name": address.id,
  4505. "iconSize": 18
  4506. }, {
  4507. default: () => [Info]
  4508. });
  4509. }
  4510. return Info;
  4511. };
  4512. return () => {
  4513. var _a;
  4514. const {
  4515. disabled
  4516. } = props;
  4517. return vue.createVNode("div", {
  4518. "class": bem$13({
  4519. disabled
  4520. }),
  4521. "onClick": onClick
  4522. }, [vue.createVNode(Cell, {
  4523. "border": false,
  4524. "valueClass": bem$13("value")
  4525. }, {
  4526. value: renderContent,
  4527. "right-icon": renderRightIcon
  4528. }), (_a = slots.bottom) == null ? void 0 : _a.call(slots, extend({}, props.address, {
  4529. disabled
  4530. }))]);
  4531. };
  4532. }
  4533. });
  4534. const [name$16, bem$12, t$g] = createNamespace("address-list");
  4535. const addressListProps = {
  4536. list: makeArrayProp(),
  4537. modelValue: numericProp,
  4538. switchable: truthProp,
  4539. disabledText: String,
  4540. disabledList: makeArrayProp(),
  4541. addButtonText: String,
  4542. defaultTagText: String
  4543. };
  4544. var stdin_default$1c = vue.defineComponent({
  4545. name: name$16,
  4546. props: addressListProps,
  4547. emits: ["add", "edit", "select", "click-item", "edit-disabled", "select-disabled", "update:modelValue"],
  4548. setup(props, {
  4549. slots,
  4550. emit
  4551. }) {
  4552. const renderItem = (item, index, disabled) => {
  4553. const onEdit = () => emit(disabled ? "edit-disabled" : "edit", item, index);
  4554. const onClick = () => emit("click-item", item, index);
  4555. const onSelect = () => {
  4556. emit(disabled ? "select-disabled" : "select", item, index);
  4557. if (!disabled) {
  4558. emit("update:modelValue", item.id);
  4559. }
  4560. };
  4561. return vue.createVNode(stdin_default$1d, {
  4562. "key": item.id,
  4563. "address": item,
  4564. "disabled": disabled,
  4565. "switchable": props.switchable,
  4566. "defaultTagText": props.defaultTagText,
  4567. "onEdit": onEdit,
  4568. "onClick": onClick,
  4569. "onSelect": onSelect
  4570. }, {
  4571. bottom: slots["item-bottom"],
  4572. tag: slots.tag
  4573. });
  4574. };
  4575. const renderList = (list, disabled) => {
  4576. if (list) {
  4577. return list.map((item, index) => renderItem(item, index, disabled));
  4578. }
  4579. };
  4580. const renderBottom = () => vue.createVNode("div", {
  4581. "class": [bem$12("bottom"), "van-safe-area-bottom"]
  4582. }, [vue.createVNode(Button, {
  4583. "round": true,
  4584. "block": true,
  4585. "type": "danger",
  4586. "text": props.addButtonText || t$g("add"),
  4587. "class": bem$12("add"),
  4588. "onClick": () => emit("add")
  4589. }, null)]);
  4590. return () => {
  4591. var _a, _b;
  4592. const List2 = renderList(props.list);
  4593. const DisabledList = renderList(props.disabledList, true);
  4594. const DisabledText = props.disabledText && vue.createVNode("div", {
  4595. "class": bem$12("disabled-text")
  4596. }, [props.disabledText]);
  4597. return vue.createVNode("div", {
  4598. "class": bem$12()
  4599. }, [(_a = slots.top) == null ? void 0 : _a.call(slots), vue.createVNode(RadioGroup, {
  4600. "modelValue": props.modelValue
  4601. }, {
  4602. default: () => [List2]
  4603. }), DisabledText, DisabledList, (_b = slots.default) == null ? void 0 : _b.call(slots), renderBottom()]);
  4604. };
  4605. }
  4606. });
  4607. const AddressList = withInstall(stdin_default$1c);
  4608. const [name$15, bem$11, t$f] = createNamespace("calendar");
  4609. const formatMonthTitle = (date) => t$f("monthTitle", date.getFullYear(), date.getMonth() + 1);
  4610. function compareMonth(date1, date2) {
  4611. const year1 = date1.getFullYear();
  4612. const year2 = date2.getFullYear();
  4613. if (year1 === year2) {
  4614. const month1 = date1.getMonth();
  4615. const month2 = date2.getMonth();
  4616. return month1 === month2 ? 0 : month1 > month2 ? 1 : -1;
  4617. }
  4618. return year1 > year2 ? 1 : -1;
  4619. }
  4620. function compareDay(day1, day2) {
  4621. const compareMonthResult = compareMonth(day1, day2);
  4622. if (compareMonthResult === 0) {
  4623. const date1 = day1.getDate();
  4624. const date2 = day2.getDate();
  4625. return date1 === date2 ? 0 : date1 > date2 ? 1 : -1;
  4626. }
  4627. return compareMonthResult;
  4628. }
  4629. const cloneDate = (date) => new Date(date);
  4630. const cloneDates = (dates) => Array.isArray(dates) ? dates.map(cloneDate) : cloneDate(dates);
  4631. function getDayByOffset(date, offset2) {
  4632. const cloned = cloneDate(date);
  4633. cloned.setDate(cloned.getDate() + offset2);
  4634. return cloned;
  4635. }
  4636. const getPrevDay = (date) => getDayByOffset(date, -1);
  4637. const getNextDay = (date) => getDayByOffset(date, 1);
  4638. const getToday = () => {
  4639. const today = new Date();
  4640. today.setHours(0, 0, 0, 0);
  4641. return today;
  4642. };
  4643. function calcDateNum(date) {
  4644. const day1 = date[0].getTime();
  4645. const day2 = date[1].getTime();
  4646. return (day2 - day1) / (1e3 * 60 * 60 * 24) + 1;
  4647. }
  4648. function useRefs() {
  4649. const refs = vue.ref([]);
  4650. const cache = [];
  4651. vue.onBeforeUpdate(() => {
  4652. refs.value = [];
  4653. });
  4654. const setRefs = (index) => {
  4655. if (!cache[index]) {
  4656. cache[index] = (el) => {
  4657. refs.value[index] = el;
  4658. };
  4659. }
  4660. return cache[index];
  4661. };
  4662. return [refs, setRefs];
  4663. }
  4664. const sharedProps = extend({}, pickerSharedProps, {
  4665. filter: Function,
  4666. columnsOrder: Array,
  4667. formatter: {
  4668. type: Function,
  4669. default: (type, value) => value
  4670. }
  4671. });
  4672. const pickerInheritKeys = Object.keys(pickerSharedProps);
  4673. function times(n, iteratee) {
  4674. if (n < 0) {
  4675. return [];
  4676. }
  4677. const result = Array(n);
  4678. let index = -1;
  4679. while (++index < n) {
  4680. result[index] = iteratee(index);
  4681. }
  4682. return result;
  4683. }
  4684. function getTrueValue(value) {
  4685. if (!value) {
  4686. return 0;
  4687. }
  4688. while (Number.isNaN(parseInt(value, 10))) {
  4689. if (value.length > 1) {
  4690. value = value.slice(1);
  4691. } else {
  4692. return 0;
  4693. }
  4694. }
  4695. return parseInt(value, 10);
  4696. }
  4697. const getMonthEndDay = (year, month) => 32 - new Date(year, month - 1, 32).getDate();
  4698. const proxyPickerMethods = (picker, callback) => {
  4699. const methods = [
  4700. "setValues",
  4701. "setIndexes",
  4702. "setColumnIndex",
  4703. "setColumnValue"
  4704. ];
  4705. return new Proxy(picker, {
  4706. get: (target, prop) => {
  4707. if (methods.includes(prop)) {
  4708. return (...args) => {
  4709. target[prop](...args);
  4710. callback();
  4711. };
  4712. }
  4713. return target[prop];
  4714. }
  4715. });
  4716. };
  4717. const [name$14] = createNamespace("calendar-day");
  4718. var stdin_default$1b = vue.defineComponent({
  4719. name: name$14,
  4720. props: {
  4721. item: makeRequiredProp(Object),
  4722. color: String,
  4723. index: Number,
  4724. offset: makeNumberProp(0),
  4725. rowHeight: String
  4726. },
  4727. emits: ["click"],
  4728. setup(props, {
  4729. emit,
  4730. slots
  4731. }) {
  4732. const style = vue.computed(() => {
  4733. var _a;
  4734. const {
  4735. item,
  4736. index,
  4737. color,
  4738. offset: offset2,
  4739. rowHeight
  4740. } = props;
  4741. const style2 = {
  4742. height: rowHeight
  4743. };
  4744. if (item.type === "placeholder") {
  4745. style2.width = "100%";
  4746. return style2;
  4747. }
  4748. if (index === 0) {
  4749. style2.marginLeft = `${100 * offset2 / 7}%`;
  4750. }
  4751. if (color) {
  4752. switch (item.type) {
  4753. case "end":
  4754. case "start":
  4755. case "start-end":
  4756. case "multiple-middle":
  4757. case "multiple-selected":
  4758. style2.background = color;
  4759. break;
  4760. case "middle":
  4761. style2.color = color;
  4762. break;
  4763. }
  4764. }
  4765. if (offset2 + (((_a = item.date) == null ? void 0 : _a.getDate()) || 1) > 28) {
  4766. style2.marginBottom = 0;
  4767. }
  4768. return style2;
  4769. });
  4770. const onClick = () => {
  4771. if (props.item.type !== "disabled") {
  4772. emit("click", props.item);
  4773. }
  4774. };
  4775. const renderTopInfo = () => {
  4776. const {
  4777. topInfo
  4778. } = props.item;
  4779. if (topInfo || slots["top-info"]) {
  4780. return vue.createVNode("div", {
  4781. "class": bem$11("top-info")
  4782. }, [slots["top-info"] ? slots["top-info"](props.item) : topInfo]);
  4783. }
  4784. };
  4785. const renderBottomInfo = () => {
  4786. const {
  4787. bottomInfo
  4788. } = props.item;
  4789. if (bottomInfo || slots["bottom-info"]) {
  4790. return vue.createVNode("div", {
  4791. "class": bem$11("bottom-info")
  4792. }, [slots["bottom-info"] ? slots["bottom-info"](props.item) : bottomInfo]);
  4793. }
  4794. };
  4795. const renderContent = () => {
  4796. const {
  4797. item,
  4798. color,
  4799. rowHeight
  4800. } = props;
  4801. const {
  4802. type,
  4803. text
  4804. } = item;
  4805. const Nodes = [renderTopInfo(), text, renderBottomInfo()];
  4806. if (type === "selected") {
  4807. return vue.createVNode("div", {
  4808. "class": bem$11("selected-day"),
  4809. "style": {
  4810. width: rowHeight,
  4811. height: rowHeight,
  4812. background: color
  4813. }
  4814. }, [Nodes]);
  4815. }
  4816. return Nodes;
  4817. };
  4818. return () => {
  4819. const {
  4820. type,
  4821. className
  4822. } = props.item;
  4823. if (type === "placeholder") {
  4824. return vue.createVNode("div", {
  4825. "class": bem$11("day"),
  4826. "style": style.value
  4827. }, null);
  4828. }
  4829. return vue.createVNode("div", {
  4830. "role": "gridcell",
  4831. "style": style.value,
  4832. "class": [bem$11("day", type), className],
  4833. "tabindex": type === "disabled" ? void 0 : -1,
  4834. "onClick": onClick
  4835. }, [renderContent()]);
  4836. };
  4837. }
  4838. });
  4839. const [name$13] = createNamespace("calendar-month");
  4840. const calendarMonthProps = {
  4841. date: makeRequiredProp(Date),
  4842. type: String,
  4843. color: String,
  4844. minDate: makeRequiredProp(Date),
  4845. maxDate: makeRequiredProp(Date),
  4846. showMark: Boolean,
  4847. rowHeight: numericProp,
  4848. formatter: Function,
  4849. lazyRender: Boolean,
  4850. currentDate: [Date, Array],
  4851. allowSameDay: Boolean,
  4852. showSubtitle: Boolean,
  4853. showMonthTitle: Boolean,
  4854. firstDayOfWeek: Number
  4855. };
  4856. var stdin_default$1a = vue.defineComponent({
  4857. name: name$13,
  4858. props: calendarMonthProps,
  4859. emits: ["click", "update-height"],
  4860. setup(props, {
  4861. emit,
  4862. slots
  4863. }) {
  4864. const [visible, setVisible] = useToggle();
  4865. const daysRef = vue.ref();
  4866. const monthRef = vue.ref();
  4867. const height2 = useHeight(monthRef);
  4868. const title = vue.computed(() => formatMonthTitle(props.date));
  4869. const rowHeight = vue.computed(() => addUnit(props.rowHeight));
  4870. const offset2 = vue.computed(() => {
  4871. const realDay = props.date.getDay();
  4872. if (props.firstDayOfWeek) {
  4873. return (realDay + 7 - props.firstDayOfWeek) % 7;
  4874. }
  4875. return realDay;
  4876. });
  4877. const totalDay = vue.computed(() => getMonthEndDay(props.date.getFullYear(), props.date.getMonth() + 1));
  4878. const shouldRender = vue.computed(() => visible.value || !props.lazyRender);
  4879. const getTitle = () => title.value;
  4880. const getMultipleDayType = (day) => {
  4881. const isSelected = (date) => props.currentDate.some((item) => compareDay(item, date) === 0);
  4882. if (isSelected(day)) {
  4883. const prevDay = getPrevDay(day);
  4884. const nextDay = getNextDay(day);
  4885. const prevSelected = isSelected(prevDay);
  4886. const nextSelected = isSelected(nextDay);
  4887. if (prevSelected && nextSelected) {
  4888. return "multiple-middle";
  4889. }
  4890. if (prevSelected) {
  4891. return "end";
  4892. }
  4893. if (nextSelected) {
  4894. return "start";
  4895. }
  4896. return "multiple-selected";
  4897. }
  4898. return "";
  4899. };
  4900. const getRangeDayType = (day) => {
  4901. const [startDay, endDay] = props.currentDate;
  4902. if (!startDay) {
  4903. return "";
  4904. }
  4905. const compareToStart = compareDay(day, startDay);
  4906. if (!endDay) {
  4907. return compareToStart === 0 ? "start" : "";
  4908. }
  4909. const compareToEnd = compareDay(day, endDay);
  4910. if (props.allowSameDay && compareToStart === 0 && compareToEnd === 0) {
  4911. return "start-end";
  4912. }
  4913. if (compareToStart === 0) {
  4914. return "start";
  4915. }
  4916. if (compareToEnd === 0) {
  4917. return "end";
  4918. }
  4919. if (compareToStart > 0 && compareToEnd < 0) {
  4920. return "middle";
  4921. }
  4922. return "";
  4923. };
  4924. const getDayType = (day) => {
  4925. const {
  4926. type,
  4927. minDate,
  4928. maxDate,
  4929. currentDate
  4930. } = props;
  4931. if (compareDay(day, minDate) < 0 || compareDay(day, maxDate) > 0) {
  4932. return "disabled";
  4933. }
  4934. if (currentDate === null) {
  4935. return "";
  4936. }
  4937. if (Array.isArray(currentDate)) {
  4938. if (type === "multiple") {
  4939. return getMultipleDayType(day);
  4940. }
  4941. if (type === "range") {
  4942. return getRangeDayType(day);
  4943. }
  4944. } else if (type === "single") {
  4945. return compareDay(day, currentDate) === 0 ? "selected" : "";
  4946. }
  4947. return "";
  4948. };
  4949. const getBottomInfo = (dayType) => {
  4950. if (props.type === "range") {
  4951. if (dayType === "start" || dayType === "end") {
  4952. return t$f(dayType);
  4953. }
  4954. if (dayType === "start-end") {
  4955. return `${t$f("start")}/${t$f("end")}`;
  4956. }
  4957. }
  4958. };
  4959. const renderTitle = () => {
  4960. if (props.showMonthTitle) {
  4961. return vue.createVNode("div", {
  4962. "class": bem$11("month-title")
  4963. }, [title.value]);
  4964. }
  4965. };
  4966. const renderMark = () => {
  4967. if (props.showMark && shouldRender.value) {
  4968. return vue.createVNode("div", {
  4969. "class": bem$11("month-mark")
  4970. }, [props.date.getMonth() + 1]);
  4971. }
  4972. };
  4973. const placeholders = vue.computed(() => {
  4974. const count = Math.ceil((totalDay.value + offset2.value) / 7);
  4975. return Array(count).fill({
  4976. type: "placeholder"
  4977. });
  4978. });
  4979. const days = vue.computed(() => {
  4980. const days2 = [];
  4981. const year = props.date.getFullYear();
  4982. const month = props.date.getMonth();
  4983. for (let day = 1; day <= totalDay.value; day++) {
  4984. const date = new Date(year, month, day);
  4985. const type = getDayType(date);
  4986. let config = {
  4987. date,
  4988. type,
  4989. text: day,
  4990. bottomInfo: getBottomInfo(type)
  4991. };
  4992. if (props.formatter) {
  4993. config = props.formatter(config);
  4994. }
  4995. days2.push(config);
  4996. }
  4997. return days2;
  4998. });
  4999. const disabledDays = vue.computed(() => days.value.filter((day) => day.type === "disabled"));
  5000. const scrollToDate = (body, targetDate) => {
  5001. if (daysRef.value) {
  5002. const daysRect = useRect(daysRef.value);
  5003. const totalRows = placeholders.value.length;
  5004. const currentRow = Math.ceil((targetDate.getDate() + offset2.value) / 7);
  5005. const rowOffset = (currentRow - 1) * daysRect.height / totalRows;
  5006. setScrollTop(body, daysRect.top + rowOffset + body.scrollTop - useRect(body).top);
  5007. }
  5008. };
  5009. const renderDay = (item, index) => vue.createVNode(stdin_default$1b, {
  5010. "item": item,
  5011. "index": index,
  5012. "color": props.color,
  5013. "offset": offset2.value,
  5014. "rowHeight": rowHeight.value,
  5015. "onClick": (item2) => emit("click", item2)
  5016. }, pick(slots, ["top-info", "bottom-info"]));
  5017. const renderDays = () => vue.createVNode("div", {
  5018. "ref": daysRef,
  5019. "role": "grid",
  5020. "class": bem$11("days")
  5021. }, [renderMark(), (shouldRender.value ? days : placeholders).value.map(renderDay)]);
  5022. useExpose({
  5023. getTitle,
  5024. getHeight: () => height2.value,
  5025. setVisible,
  5026. scrollToDate,
  5027. disabledDays
  5028. });
  5029. return () => vue.createVNode("div", {
  5030. "class": bem$11("month"),
  5031. "ref": monthRef
  5032. }, [renderTitle(), renderDays()]);
  5033. }
  5034. });
  5035. const [name$12] = createNamespace("calendar-header");
  5036. var stdin_default$19 = vue.defineComponent({
  5037. name: name$12,
  5038. props: {
  5039. title: String,
  5040. subtitle: String,
  5041. showTitle: Boolean,
  5042. showSubtitle: Boolean,
  5043. firstDayOfWeek: Number
  5044. },
  5045. emits: ["click-subtitle"],
  5046. setup(props, {
  5047. slots,
  5048. emit
  5049. }) {
  5050. const renderTitle = () => {
  5051. if (props.showTitle) {
  5052. const text = props.title || t$f("title");
  5053. const title = slots.title ? slots.title() : text;
  5054. return vue.createVNode("div", {
  5055. "class": bem$11("header-title")
  5056. }, [title]);
  5057. }
  5058. };
  5059. const onClickSubtitle = (event) => emit("click-subtitle", event);
  5060. const renderSubtitle = () => {
  5061. if (props.showSubtitle) {
  5062. const title = slots.subtitle ? slots.subtitle() : props.subtitle;
  5063. return vue.createVNode("div", {
  5064. "class": bem$11("header-subtitle"),
  5065. "onClick": onClickSubtitle
  5066. }, [title]);
  5067. }
  5068. };
  5069. const renderWeekDays = () => {
  5070. const {
  5071. firstDayOfWeek
  5072. } = props;
  5073. const weekdays = t$f("weekdays");
  5074. const renderWeekDays2 = [...weekdays.slice(firstDayOfWeek, 7), ...weekdays.slice(0, firstDayOfWeek)];
  5075. return vue.createVNode("div", {
  5076. "class": bem$11("weekdays")
  5077. }, [renderWeekDays2.map((text) => vue.createVNode("span", {
  5078. "class": bem$11("weekday")
  5079. }, [text]))]);
  5080. };
  5081. return () => vue.createVNode("div", {
  5082. "class": bem$11("header")
  5083. }, [renderTitle(), renderSubtitle(), renderWeekDays()]);
  5084. }
  5085. });
  5086. const calendarProps = {
  5087. show: Boolean,
  5088. type: makeStringProp("single"),
  5089. title: String,
  5090. color: String,
  5091. round: truthProp,
  5092. readonly: Boolean,
  5093. poppable: truthProp,
  5094. maxRange: makeNumericProp(null),
  5095. position: makeStringProp("bottom"),
  5096. teleport: [String, Object],
  5097. showMark: truthProp,
  5098. showTitle: truthProp,
  5099. formatter: Function,
  5100. rowHeight: numericProp,
  5101. confirmText: String,
  5102. rangePrompt: String,
  5103. lazyRender: truthProp,
  5104. showConfirm: truthProp,
  5105. defaultDate: [Date, Array],
  5106. allowSameDay: Boolean,
  5107. showSubtitle: truthProp,
  5108. closeOnPopstate: truthProp,
  5109. showRangePrompt: truthProp,
  5110. confirmDisabledText: String,
  5111. closeOnClickOverlay: truthProp,
  5112. safeAreaInsetTop: Boolean,
  5113. safeAreaInsetBottom: truthProp,
  5114. minDate: {
  5115. type: Date,
  5116. validator: isDate,
  5117. default: getToday
  5118. },
  5119. maxDate: {
  5120. type: Date,
  5121. validator: isDate,
  5122. default: () => {
  5123. const now = getToday();
  5124. return new Date(now.getFullYear(), now.getMonth() + 6, now.getDate());
  5125. }
  5126. },
  5127. firstDayOfWeek: {
  5128. type: numericProp,
  5129. default: 0,
  5130. validator: (val) => val >= 0 && val <= 6
  5131. }
  5132. };
  5133. var stdin_default$18 = vue.defineComponent({
  5134. name: name$15,
  5135. props: calendarProps,
  5136. emits: ["select", "confirm", "unselect", "month-show", "over-range", "update:show", "click-subtitle"],
  5137. setup(props, {
  5138. emit,
  5139. slots
  5140. }) {
  5141. const limitDateRange = (date, minDate = props.minDate, maxDate = props.maxDate) => {
  5142. if (compareDay(date, minDate) === -1) {
  5143. return minDate;
  5144. }
  5145. if (compareDay(date, maxDate) === 1) {
  5146. return maxDate;
  5147. }
  5148. return date;
  5149. };
  5150. const getInitialDate = (defaultDate = props.defaultDate) => {
  5151. const {
  5152. type,
  5153. minDate,
  5154. maxDate,
  5155. allowSameDay
  5156. } = props;
  5157. if (defaultDate === null) {
  5158. return defaultDate;
  5159. }
  5160. const now = getToday();
  5161. if (type === "range") {
  5162. if (!Array.isArray(defaultDate)) {
  5163. defaultDate = [];
  5164. }
  5165. const start2 = limitDateRange(defaultDate[0] || now, minDate, allowSameDay ? maxDate : getPrevDay(maxDate));
  5166. const end2 = limitDateRange(defaultDate[1] || now, allowSameDay ? minDate : getNextDay(minDate));
  5167. return [start2, end2];
  5168. }
  5169. if (type === "multiple") {
  5170. if (Array.isArray(defaultDate)) {
  5171. return defaultDate.map((date) => limitDateRange(date));
  5172. }
  5173. return [limitDateRange(now)];
  5174. }
  5175. if (!defaultDate || Array.isArray(defaultDate)) {
  5176. defaultDate = now;
  5177. }
  5178. return limitDateRange(defaultDate);
  5179. };
  5180. let bodyHeight;
  5181. const bodyRef = vue.ref();
  5182. const subtitle = vue.ref("");
  5183. const currentDate = vue.ref(getInitialDate());
  5184. const [monthRefs, setMonthRefs] = useRefs();
  5185. const dayOffset = vue.computed(() => props.firstDayOfWeek ? +props.firstDayOfWeek % 7 : 0);
  5186. const months = vue.computed(() => {
  5187. const months2 = [];
  5188. const cursor = new Date(props.minDate);
  5189. cursor.setDate(1);
  5190. do {
  5191. months2.push(new Date(cursor));
  5192. cursor.setMonth(cursor.getMonth() + 1);
  5193. } while (compareMonth(cursor, props.maxDate) !== 1);
  5194. return months2;
  5195. });
  5196. const buttonDisabled = vue.computed(() => {
  5197. if (currentDate.value) {
  5198. if (props.type === "range") {
  5199. return !currentDate.value[0] || !currentDate.value[1];
  5200. }
  5201. if (props.type === "multiple") {
  5202. return !currentDate.value.length;
  5203. }
  5204. }
  5205. return !currentDate.value;
  5206. });
  5207. const getSelectedDate = () => currentDate.value;
  5208. const onScroll = () => {
  5209. const top2 = getScrollTop(bodyRef.value);
  5210. const bottom2 = top2 + bodyHeight;
  5211. const heights = months.value.map((item, index) => monthRefs.value[index].getHeight());
  5212. const heightSum = heights.reduce((a, b) => a + b, 0);
  5213. if (bottom2 > heightSum && top2 > 0) {
  5214. return;
  5215. }
  5216. let height2 = 0;
  5217. let currentMonth;
  5218. const visibleRange = [-1, -1];
  5219. for (let i = 0; i < months.value.length; i++) {
  5220. const month = monthRefs.value[i];
  5221. const visible = height2 <= bottom2 && height2 + heights[i] >= top2;
  5222. if (visible) {
  5223. visibleRange[1] = i;
  5224. if (!currentMonth) {
  5225. currentMonth = month;
  5226. visibleRange[0] = i;
  5227. }
  5228. if (!monthRefs.value[i].showed) {
  5229. monthRefs.value[i].showed = true;
  5230. emit("month-show", {
  5231. date: month.date,
  5232. title: month.getTitle()
  5233. });
  5234. }
  5235. }
  5236. height2 += heights[i];
  5237. }
  5238. months.value.forEach((month, index) => {
  5239. const visible = index >= visibleRange[0] - 1 && index <= visibleRange[1] + 1;
  5240. monthRefs.value[index].setVisible(visible);
  5241. });
  5242. if (currentMonth) {
  5243. subtitle.value = currentMonth.getTitle();
  5244. }
  5245. };
  5246. const scrollToDate = (targetDate) => {
  5247. raf(() => {
  5248. months.value.some((month, index) => {
  5249. if (compareMonth(month, targetDate) === 0) {
  5250. if (bodyRef.value) {
  5251. monthRefs.value[index].scrollToDate(bodyRef.value, targetDate);
  5252. }
  5253. return true;
  5254. }
  5255. return false;
  5256. });
  5257. onScroll();
  5258. });
  5259. };
  5260. const scrollToCurrentDate = () => {
  5261. if (props.poppable && !props.show) {
  5262. return;
  5263. }
  5264. if (currentDate.value) {
  5265. const targetDate = props.type === "single" ? currentDate.value : currentDate.value[0];
  5266. if (isDate(targetDate)) {
  5267. scrollToDate(targetDate);
  5268. }
  5269. } else {
  5270. raf(onScroll);
  5271. }
  5272. };
  5273. const init = () => {
  5274. if (props.poppable && !props.show) {
  5275. return;
  5276. }
  5277. raf(() => {
  5278. bodyHeight = Math.floor(useRect(bodyRef).height);
  5279. });
  5280. scrollToCurrentDate();
  5281. };
  5282. const reset = (date = getInitialDate()) => {
  5283. currentDate.value = date;
  5284. scrollToCurrentDate();
  5285. };
  5286. const checkRange = (date) => {
  5287. const {
  5288. maxRange,
  5289. rangePrompt,
  5290. showRangePrompt
  5291. } = props;
  5292. if (maxRange && calcDateNum(date) > maxRange) {
  5293. if (showRangePrompt) {
  5294. Toast(rangePrompt || t$f("rangePrompt", maxRange));
  5295. }
  5296. emit("over-range");
  5297. return false;
  5298. }
  5299. return true;
  5300. };
  5301. const onConfirm = () => {
  5302. var _a;
  5303. return emit("confirm", (_a = currentDate.value) != null ? _a : cloneDates(currentDate.value));
  5304. };
  5305. const select = (date, complete) => {
  5306. const setCurrentDate = (date2) => {
  5307. currentDate.value = date2;
  5308. emit("select", cloneDates(date2));
  5309. };
  5310. if (complete && props.type === "range") {
  5311. const valid = checkRange(date);
  5312. if (!valid) {
  5313. setCurrentDate([date[0], getDayByOffset(date[0], +props.maxRange - 1)]);
  5314. return;
  5315. }
  5316. }
  5317. setCurrentDate(date);
  5318. if (complete && !props.showConfirm) {
  5319. onConfirm();
  5320. }
  5321. };
  5322. const getDisabledDate = (disabledDays2, startDay, date) => {
  5323. var _a;
  5324. return (_a = disabledDays2.find((day) => compareDay(startDay, day.date) === -1 && compareDay(day.date, date) === -1)) == null ? void 0 : _a.date;
  5325. };
  5326. const disabledDays = vue.computed(() => monthRefs.value.reduce((arr, ref2) => {
  5327. var _a, _b;
  5328. arr.push(...(_b = (_a = ref2.disabledDays) == null ? void 0 : _a.value) != null ? _b : []);
  5329. return arr;
  5330. }, []));
  5331. const onClickDay = (item) => {
  5332. if (props.readonly || !item.date) {
  5333. return;
  5334. }
  5335. const {
  5336. date
  5337. } = item;
  5338. const {
  5339. type
  5340. } = props;
  5341. if (type === "range") {
  5342. if (!currentDate.value) {
  5343. select([date]);
  5344. return;
  5345. }
  5346. const [startDay, endDay] = currentDate.value;
  5347. if (startDay && !endDay) {
  5348. const compareToStart = compareDay(date, startDay);
  5349. if (compareToStart === 1) {
  5350. const disabledDay = getDisabledDate(disabledDays.value, startDay, date);
  5351. if (disabledDay) {
  5352. const endDay2 = getPrevDay(disabledDay);
  5353. if (compareDay(startDay, endDay2) === -1) {
  5354. select([startDay, endDay2]);
  5355. } else {
  5356. select([date]);
  5357. }
  5358. } else {
  5359. select([startDay, date], true);
  5360. }
  5361. } else if (compareToStart === -1) {
  5362. select([date]);
  5363. } else if (props.allowSameDay) {
  5364. select([date, date], true);
  5365. }
  5366. } else {
  5367. select([date]);
  5368. }
  5369. } else if (type === "multiple") {
  5370. if (!currentDate.value) {
  5371. select([date]);
  5372. return;
  5373. }
  5374. const dates = currentDate.value;
  5375. const selectedIndex = dates.findIndex((dateItem) => compareDay(dateItem, date) === 0);
  5376. if (selectedIndex !== -1) {
  5377. const [unselectedDate] = dates.splice(selectedIndex, 1);
  5378. emit("unselect", cloneDate(unselectedDate));
  5379. } else if (props.maxRange && dates.length >= props.maxRange) {
  5380. Toast(props.rangePrompt || t$f("rangePrompt", props.maxRange));
  5381. } else {
  5382. select([...dates, date]);
  5383. }
  5384. } else {
  5385. select(date, true);
  5386. }
  5387. };
  5388. const updateShow = (value) => emit("update:show", value);
  5389. const renderMonth = (date, index) => {
  5390. const showMonthTitle = index !== 0 || !props.showSubtitle;
  5391. return vue.createVNode(stdin_default$1a, vue.mergeProps({
  5392. "ref": setMonthRefs(index),
  5393. "date": date,
  5394. "currentDate": currentDate.value,
  5395. "showMonthTitle": showMonthTitle,
  5396. "firstDayOfWeek": dayOffset.value
  5397. }, pick(props, ["type", "color", "minDate", "maxDate", "showMark", "formatter", "rowHeight", "lazyRender", "showSubtitle", "allowSameDay"]), {
  5398. "onClick": onClickDay
  5399. }), pick(slots, ["top-info", "bottom-info"]));
  5400. };
  5401. const renderFooterButton = () => {
  5402. if (slots.footer) {
  5403. return slots.footer();
  5404. }
  5405. if (props.showConfirm) {
  5406. const slot = slots["confirm-text"];
  5407. const disabled = buttonDisabled.value;
  5408. const text = disabled ? props.confirmDisabledText : props.confirmText;
  5409. return vue.createVNode(Button, {
  5410. "round": true,
  5411. "block": true,
  5412. "type": "danger",
  5413. "color": props.color,
  5414. "class": bem$11("confirm"),
  5415. "disabled": disabled,
  5416. "nativeType": "button",
  5417. "onClick": onConfirm
  5418. }, {
  5419. default: () => [slot ? slot({
  5420. disabled
  5421. }) : text || t$f("confirm")]
  5422. });
  5423. }
  5424. };
  5425. const renderFooter = () => vue.createVNode("div", {
  5426. "class": [bem$11("footer"), {
  5427. "van-safe-area-bottom": props.safeAreaInsetBottom
  5428. }]
  5429. }, [renderFooterButton()]);
  5430. const renderCalendar = () => vue.createVNode("div", {
  5431. "class": bem$11()
  5432. }, [vue.createVNode(stdin_default$19, {
  5433. "title": props.title,
  5434. "subtitle": subtitle.value,
  5435. "showTitle": props.showTitle,
  5436. "showSubtitle": props.showSubtitle,
  5437. "firstDayOfWeek": dayOffset.value,
  5438. "onClick-subtitle": (event) => emit("click-subtitle", event)
  5439. }, pick(slots, ["title", "subtitle"])), vue.createVNode("div", {
  5440. "ref": bodyRef,
  5441. "class": bem$11("body"),
  5442. "onScroll": onScroll
  5443. }, [months.value.map(renderMonth)]), renderFooter()]);
  5444. vue.watch(() => props.show, init);
  5445. vue.watch(() => [props.type, props.minDate, props.maxDate], () => reset(getInitialDate(currentDate.value)));
  5446. vue.watch(() => props.defaultDate, (value = null) => {
  5447. currentDate.value = value;
  5448. scrollToCurrentDate();
  5449. });
  5450. useExpose({
  5451. reset,
  5452. scrollToDate,
  5453. getSelectedDate
  5454. });
  5455. onMountedOrActivated(init);
  5456. return () => {
  5457. if (props.poppable) {
  5458. return vue.createVNode(Popup, {
  5459. "show": props.show,
  5460. "class": bem$11("popup"),
  5461. "round": props.round,
  5462. "position": props.position,
  5463. "closeable": props.showTitle || props.showSubtitle,
  5464. "teleport": props.teleport,
  5465. "closeOnPopstate": props.closeOnPopstate,
  5466. "safeAreaInsetTop": props.safeAreaInsetTop,
  5467. "closeOnClickOverlay": props.closeOnClickOverlay,
  5468. "onUpdate:show": updateShow
  5469. }, {
  5470. default: renderCalendar
  5471. });
  5472. }
  5473. return renderCalendar();
  5474. };
  5475. }
  5476. });
  5477. const Calendar = withInstall(stdin_default$18);
  5478. const [name$11, bem$10] = createNamespace("image");
  5479. const imageProps = {
  5480. src: String,
  5481. alt: String,
  5482. fit: String,
  5483. position: String,
  5484. round: Boolean,
  5485. block: Boolean,
  5486. width: numericProp,
  5487. height: numericProp,
  5488. radius: numericProp,
  5489. lazyLoad: Boolean,
  5490. iconSize: numericProp,
  5491. showError: truthProp,
  5492. errorIcon: makeStringProp("photo-fail"),
  5493. iconPrefix: String,
  5494. showLoading: truthProp,
  5495. loadingIcon: makeStringProp("photo")
  5496. };
  5497. var stdin_default$17 = vue.defineComponent({
  5498. name: name$11,
  5499. props: imageProps,
  5500. emits: ["load", "error"],
  5501. setup(props, {
  5502. emit,
  5503. slots
  5504. }) {
  5505. const error = vue.ref(false);
  5506. const loading = vue.ref(true);
  5507. const imageRef = vue.ref();
  5508. const {
  5509. $Lazyload
  5510. } = vue.getCurrentInstance().proxy;
  5511. const style = vue.computed(() => {
  5512. const style2 = {
  5513. width: addUnit(props.width),
  5514. height: addUnit(props.height)
  5515. };
  5516. if (isDef(props.radius)) {
  5517. style2.overflow = "hidden";
  5518. style2.borderRadius = addUnit(props.radius);
  5519. }
  5520. return style2;
  5521. });
  5522. vue.watch(() => props.src, () => {
  5523. error.value = false;
  5524. loading.value = true;
  5525. });
  5526. const onLoad = (event) => {
  5527. loading.value = false;
  5528. emit("load", event);
  5529. };
  5530. const onError = (event) => {
  5531. error.value = true;
  5532. loading.value = false;
  5533. emit("error", event);
  5534. };
  5535. const renderIcon = (name2, className, slot) => {
  5536. if (slot) {
  5537. return slot();
  5538. }
  5539. return vue.createVNode(Icon, {
  5540. "name": name2,
  5541. "size": props.iconSize,
  5542. "class": className,
  5543. "classPrefix": props.iconPrefix
  5544. }, null);
  5545. };
  5546. const renderPlaceholder = () => {
  5547. if (loading.value && props.showLoading) {
  5548. return vue.createVNode("div", {
  5549. "class": bem$10("loading")
  5550. }, [renderIcon(props.loadingIcon, bem$10("loading-icon"), slots.loading)]);
  5551. }
  5552. if (error.value && props.showError) {
  5553. return vue.createVNode("div", {
  5554. "class": bem$10("error")
  5555. }, [renderIcon(props.errorIcon, bem$10("error-icon"), slots.error)]);
  5556. }
  5557. };
  5558. const renderImage = () => {
  5559. if (error.value || !props.src) {
  5560. return;
  5561. }
  5562. const attrs = {
  5563. alt: props.alt,
  5564. class: bem$10("img"),
  5565. style: {
  5566. objectFit: props.fit,
  5567. objectPosition: props.position
  5568. }
  5569. };
  5570. if (props.lazyLoad) {
  5571. return vue.withDirectives(vue.createVNode("img", vue.mergeProps({
  5572. "ref": imageRef
  5573. }, attrs), null), [[vue.resolveDirective("lazy"), props.src]]);
  5574. }
  5575. return vue.createVNode("img", vue.mergeProps({
  5576. "src": props.src,
  5577. "onLoad": onLoad,
  5578. "onError": onError
  5579. }, attrs), null);
  5580. };
  5581. const onLazyLoaded = ({
  5582. el
  5583. }) => {
  5584. const check = () => {
  5585. if (el === imageRef.value && loading.value) {
  5586. onLoad();
  5587. }
  5588. };
  5589. if (imageRef.value) {
  5590. check();
  5591. } else {
  5592. vue.nextTick(check);
  5593. }
  5594. };
  5595. const onLazyLoadError = ({
  5596. el
  5597. }) => {
  5598. if (el === imageRef.value && !error.value) {
  5599. onError();
  5600. }
  5601. };
  5602. if ($Lazyload && inBrowser$1) {
  5603. $Lazyload.$on("loaded", onLazyLoaded);
  5604. $Lazyload.$on("error", onLazyLoadError);
  5605. vue.onBeforeUnmount(() => {
  5606. $Lazyload.$off("loaded", onLazyLoaded);
  5607. $Lazyload.$off("error", onLazyLoadError);
  5608. });
  5609. }
  5610. return () => {
  5611. var _a;
  5612. return vue.createVNode("div", {
  5613. "class": bem$10({
  5614. round: props.round,
  5615. block: props.block
  5616. }),
  5617. "style": style.value
  5618. }, [renderImage(), renderPlaceholder(), (_a = slots.default) == null ? void 0 : _a.call(slots)]);
  5619. };
  5620. }
  5621. });
  5622. const Image$1 = withInstall(stdin_default$17);
  5623. const [name$10, bem$$] = createNamespace("card");
  5624. const cardProps = {
  5625. tag: String,
  5626. num: numericProp,
  5627. desc: String,
  5628. thumb: String,
  5629. title: String,
  5630. price: numericProp,
  5631. centered: Boolean,
  5632. lazyLoad: Boolean,
  5633. currency: makeStringProp("\xA5"),
  5634. thumbLink: String,
  5635. originPrice: numericProp
  5636. };
  5637. var stdin_default$16 = vue.defineComponent({
  5638. name: name$10,
  5639. props: cardProps,
  5640. emits: ["click-thumb"],
  5641. setup(props, {
  5642. slots,
  5643. emit
  5644. }) {
  5645. const renderTitle = () => {
  5646. if (slots.title) {
  5647. return slots.title();
  5648. }
  5649. if (props.title) {
  5650. return vue.createVNode("div", {
  5651. "class": [bem$$("title"), "van-multi-ellipsis--l2"]
  5652. }, [props.title]);
  5653. }
  5654. };
  5655. const renderThumbTag = () => {
  5656. if (slots.tag || props.tag) {
  5657. return vue.createVNode("div", {
  5658. "class": bem$$("tag")
  5659. }, [slots.tag ? slots.tag() : vue.createVNode(Tag, {
  5660. "mark": true,
  5661. "type": "danger"
  5662. }, {
  5663. default: () => [props.tag]
  5664. })]);
  5665. }
  5666. };
  5667. const renderThumbImage = () => {
  5668. if (slots.thumb) {
  5669. return slots.thumb();
  5670. }
  5671. return vue.createVNode(Image$1, {
  5672. "src": props.thumb,
  5673. "fit": "cover",
  5674. "width": "100%",
  5675. "height": "100%",
  5676. "lazyLoad": props.lazyLoad
  5677. }, null);
  5678. };
  5679. const renderThumb = () => {
  5680. if (slots.thumb || props.thumb) {
  5681. return vue.createVNode("a", {
  5682. "href": props.thumbLink,
  5683. "class": bem$$("thumb"),
  5684. "onClick": (event) => emit("click-thumb", event)
  5685. }, [renderThumbImage(), renderThumbTag()]);
  5686. }
  5687. };
  5688. const renderDesc = () => {
  5689. if (slots.desc) {
  5690. return slots.desc();
  5691. }
  5692. if (props.desc) {
  5693. return vue.createVNode("div", {
  5694. "class": [bem$$("desc"), "van-ellipsis"]
  5695. }, [props.desc]);
  5696. }
  5697. };
  5698. const renderPriceText = () => {
  5699. const priceArr = props.price.toString().split(".");
  5700. return vue.createVNode("div", null, [vue.createVNode("span", {
  5701. "class": bem$$("price-currency")
  5702. }, [props.currency]), vue.createVNode("span", {
  5703. "class": bem$$("price-integer")
  5704. }, [priceArr[0]]), vue.createTextVNode("."), vue.createVNode("span", {
  5705. "class": bem$$("price-decimal")
  5706. }, [priceArr[1]])]);
  5707. };
  5708. return () => {
  5709. var _a, _b, _c;
  5710. const showNum = slots.num || isDef(props.num);
  5711. const showPrice = slots.price || isDef(props.price);
  5712. const showOriginPrice = slots["origin-price"] || isDef(props.originPrice);
  5713. const showBottom = showNum || showPrice || showOriginPrice || slots.bottom;
  5714. const Price = showPrice && vue.createVNode("div", {
  5715. "class": bem$$("price")
  5716. }, [slots.price ? slots.price() : renderPriceText()]);
  5717. const OriginPrice = showOriginPrice && vue.createVNode("div", {
  5718. "class": bem$$("origin-price")
  5719. }, [slots["origin-price"] ? slots["origin-price"]() : `${props.currency} ${props.originPrice}`]);
  5720. const Num = showNum && vue.createVNode("div", {
  5721. "class": bem$$("num")
  5722. }, [slots.num ? slots.num() : `x${props.num}`]);
  5723. const Footer = slots.footer && vue.createVNode("div", {
  5724. "class": bem$$("footer")
  5725. }, [slots.footer()]);
  5726. const Bottom = showBottom && vue.createVNode("div", {
  5727. "class": bem$$("bottom")
  5728. }, [(_a = slots["price-top"]) == null ? void 0 : _a.call(slots), Price, OriginPrice, Num, (_b = slots.bottom) == null ? void 0 : _b.call(slots)]);
  5729. return vue.createVNode("div", {
  5730. "class": bem$$()
  5731. }, [vue.createVNode("div", {
  5732. "class": bem$$("header")
  5733. }, [renderThumb(), vue.createVNode("div", {
  5734. "class": bem$$("content", {
  5735. centered: props.centered
  5736. })
  5737. }, [vue.createVNode("div", null, [renderTitle(), renderDesc(), (_c = slots.tags) == null ? void 0 : _c.call(slots)]), Bottom])]), Footer]);
  5738. };
  5739. }
  5740. });
  5741. const Card = withInstall(stdin_default$16);
  5742. function scrollLeftTo(scroller, to, duration) {
  5743. let count = 0;
  5744. const from = scroller.scrollLeft;
  5745. const frames = duration === 0 ? 1 : Math.round(duration * 1e3 / 16);
  5746. function animate() {
  5747. scroller.scrollLeft += (to - from) / frames;
  5748. if (++count < frames) {
  5749. raf(animate);
  5750. }
  5751. }
  5752. animate();
  5753. }
  5754. function scrollTopTo(scroller, to, duration, callback) {
  5755. let current2 = getScrollTop(scroller);
  5756. const isDown = current2 < to;
  5757. const frames = duration === 0 ? 1 : Math.round(duration * 1e3 / 16);
  5758. const step = (to - current2) / frames;
  5759. function animate() {
  5760. current2 += step;
  5761. if (isDown && current2 > to || !isDown && current2 < to) {
  5762. current2 = to;
  5763. }
  5764. setScrollTop(scroller, current2);
  5765. if (isDown && current2 < to || !isDown && current2 > to) {
  5766. raf(animate);
  5767. } else if (callback) {
  5768. raf(callback);
  5769. }
  5770. }
  5771. animate();
  5772. }
  5773. function useVisibilityChange(target, onChange) {
  5774. if (!inBrowser$1 || !window.IntersectionObserver) {
  5775. return;
  5776. }
  5777. const observer = new IntersectionObserver(
  5778. (entries) => {
  5779. onChange(entries[0].intersectionRatio > 0);
  5780. },
  5781. { root: document.body }
  5782. );
  5783. const observe = () => {
  5784. if (target.value) {
  5785. observer.observe(target.value);
  5786. }
  5787. };
  5788. const unobserve = () => {
  5789. if (target.value) {
  5790. observer.unobserve(target.value);
  5791. }
  5792. };
  5793. vue.onDeactivated(unobserve);
  5794. vue.onBeforeUnmount(unobserve);
  5795. onMountedOrActivated(observe);
  5796. }
  5797. const [name$$, bem$_] = createNamespace("sticky");
  5798. const stickyProps = {
  5799. zIndex: numericProp,
  5800. position: makeStringProp("top"),
  5801. container: Object,
  5802. offsetTop: makeNumericProp(0),
  5803. offsetBottom: makeNumericProp(0)
  5804. };
  5805. var stdin_default$15 = vue.defineComponent({
  5806. name: name$$,
  5807. props: stickyProps,
  5808. emits: ["scroll", "change"],
  5809. setup(props, {
  5810. emit,
  5811. slots
  5812. }) {
  5813. const root = vue.ref();
  5814. const scrollParent = useScrollParent(root);
  5815. const state = vue.reactive({
  5816. fixed: false,
  5817. width: 0,
  5818. height: 0,
  5819. transform: 0
  5820. });
  5821. const offset2 = vue.computed(() => unitToPx(props.position === "top" ? props.offsetTop : props.offsetBottom));
  5822. const rootStyle = vue.computed(() => {
  5823. const {
  5824. fixed,
  5825. height: height2,
  5826. width: width2
  5827. } = state;
  5828. if (fixed) {
  5829. return {
  5830. width: `${width2}px`,
  5831. height: `${height2}px`
  5832. };
  5833. }
  5834. });
  5835. const stickyStyle = vue.computed(() => {
  5836. if (!state.fixed) {
  5837. return;
  5838. }
  5839. const style = extend(getZIndexStyle(props.zIndex), {
  5840. width: `${state.width}px`,
  5841. height: `${state.height}px`,
  5842. [props.position]: `${offset2.value}px`
  5843. });
  5844. if (state.transform) {
  5845. style.transform = `translate3d(0, ${state.transform}px, 0)`;
  5846. }
  5847. return style;
  5848. });
  5849. const emitScroll = (scrollTop) => emit("scroll", {
  5850. scrollTop,
  5851. isFixed: state.fixed
  5852. });
  5853. const onScroll = () => {
  5854. if (!root.value || isHidden(root)) {
  5855. return;
  5856. }
  5857. const {
  5858. container,
  5859. position
  5860. } = props;
  5861. const rootRect = useRect(root);
  5862. const scrollTop = getScrollTop(window);
  5863. state.width = rootRect.width;
  5864. state.height = rootRect.height;
  5865. if (position === "top") {
  5866. if (container) {
  5867. const containerRect = useRect(container);
  5868. const difference = containerRect.bottom - offset2.value - state.height;
  5869. state.fixed = offset2.value > rootRect.top && containerRect.bottom > 0;
  5870. state.transform = difference < 0 ? difference : 0;
  5871. } else {
  5872. state.fixed = offset2.value > rootRect.top;
  5873. }
  5874. } else {
  5875. const {
  5876. clientHeight
  5877. } = document.documentElement;
  5878. if (container) {
  5879. const containerRect = useRect(container);
  5880. const difference = clientHeight - containerRect.top - offset2.value - state.height;
  5881. state.fixed = clientHeight - offset2.value < rootRect.bottom && clientHeight > containerRect.top;
  5882. state.transform = difference < 0 ? -difference : 0;
  5883. } else {
  5884. state.fixed = clientHeight - offset2.value < rootRect.bottom;
  5885. }
  5886. }
  5887. emitScroll(scrollTop);
  5888. };
  5889. vue.watch(() => state.fixed, (value) => emit("change", value));
  5890. useEventListener("scroll", onScroll, {
  5891. target: scrollParent,
  5892. passive: true
  5893. });
  5894. useVisibilityChange(root, onScroll);
  5895. return () => {
  5896. var _a;
  5897. return vue.createVNode("div", {
  5898. "ref": root,
  5899. "style": rootStyle.value
  5900. }, [vue.createVNode("div", {
  5901. "class": bem$_({
  5902. fixed: state.fixed
  5903. }),
  5904. "style": stickyStyle.value
  5905. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)])]);
  5906. };
  5907. }
  5908. });
  5909. const Sticky = withInstall(stdin_default$15);
  5910. const [name$_, bem$Z] = createNamespace("tab");
  5911. var stdin_default$14 = vue.defineComponent({
  5912. name: name$_,
  5913. props: {
  5914. id: String,
  5915. dot: Boolean,
  5916. type: String,
  5917. color: String,
  5918. title: String,
  5919. badge: numericProp,
  5920. shrink: Boolean,
  5921. isActive: Boolean,
  5922. disabled: Boolean,
  5923. controls: String,
  5924. scrollable: Boolean,
  5925. activeColor: String,
  5926. inactiveColor: String,
  5927. showZeroBadge: truthProp
  5928. },
  5929. setup(props, {
  5930. slots
  5931. }) {
  5932. const style = vue.computed(() => {
  5933. const style2 = {};
  5934. const {
  5935. type,
  5936. color,
  5937. disabled,
  5938. isActive,
  5939. activeColor,
  5940. inactiveColor
  5941. } = props;
  5942. const isCard = type === "card";
  5943. if (color && isCard) {
  5944. style2.borderColor = color;
  5945. if (!disabled) {
  5946. if (isActive) {
  5947. style2.backgroundColor = color;
  5948. } else {
  5949. style2.color = color;
  5950. }
  5951. }
  5952. }
  5953. const titleColor = isActive ? activeColor : inactiveColor;
  5954. if (titleColor) {
  5955. style2.color = titleColor;
  5956. }
  5957. return style2;
  5958. });
  5959. const renderText = () => {
  5960. const Text2 = vue.createVNode("span", {
  5961. "class": bem$Z("text", {
  5962. ellipsis: !props.scrollable
  5963. })
  5964. }, [slots.title ? slots.title() : props.title]);
  5965. if (props.dot || isDef(props.badge) && props.badge !== "") {
  5966. return vue.createVNode(Badge, {
  5967. "dot": props.dot,
  5968. "content": props.badge,
  5969. "showZero": props.showZeroBadge
  5970. }, {
  5971. default: () => [Text2]
  5972. });
  5973. }
  5974. return Text2;
  5975. };
  5976. return () => vue.createVNode("div", {
  5977. "id": props.id,
  5978. "role": "tab",
  5979. "class": [bem$Z([props.type, {
  5980. grow: props.scrollable && !props.shrink,
  5981. shrink: props.shrink,
  5982. active: props.isActive,
  5983. disabled: props.disabled
  5984. }])],
  5985. "style": style.value,
  5986. "tabindex": props.disabled ? void 0 : props.isActive ? 0 : -1,
  5987. "aria-selected": props.isActive,
  5988. "aria-disabled": props.disabled || void 0,
  5989. "aria-controls": props.controls
  5990. }, [renderText()]);
  5991. }
  5992. });
  5993. const [name$Z, bem$Y] = createNamespace("swipe");
  5994. const swipeProps = {
  5995. loop: truthProp,
  5996. width: numericProp,
  5997. height: numericProp,
  5998. vertical: Boolean,
  5999. autoplay: makeNumericProp(0),
  6000. duration: makeNumericProp(500),
  6001. touchable: truthProp,
  6002. lazyRender: Boolean,
  6003. initialSwipe: makeNumericProp(0),
  6004. indicatorColor: String,
  6005. showIndicators: truthProp,
  6006. stopPropagation: truthProp
  6007. };
  6008. const SWIPE_KEY = Symbol(name$Z);
  6009. var stdin_default$13 = vue.defineComponent({
  6010. name: name$Z,
  6011. props: swipeProps,
  6012. emits: ["change"],
  6013. setup(props, {
  6014. emit,
  6015. slots
  6016. }) {
  6017. const root = vue.ref();
  6018. const track = vue.ref();
  6019. const state = vue.reactive({
  6020. rect: null,
  6021. width: 0,
  6022. height: 0,
  6023. offset: 0,
  6024. active: 0,
  6025. swiping: false
  6026. });
  6027. const touch = useTouch();
  6028. const {
  6029. children,
  6030. linkChildren
  6031. } = useChildren(SWIPE_KEY);
  6032. const count = vue.computed(() => children.length);
  6033. const size = vue.computed(() => state[props.vertical ? "height" : "width"]);
  6034. const delta = vue.computed(() => props.vertical ? touch.deltaY.value : touch.deltaX.value);
  6035. const minOffset = vue.computed(() => {
  6036. if (state.rect) {
  6037. const base = props.vertical ? state.rect.height : state.rect.width;
  6038. return base - size.value * count.value;
  6039. }
  6040. return 0;
  6041. });
  6042. const maxCount = vue.computed(() => Math.ceil(Math.abs(minOffset.value) / size.value));
  6043. const trackSize = vue.computed(() => count.value * size.value);
  6044. const activeIndicator = vue.computed(() => (state.active + count.value) % count.value);
  6045. const isCorrectDirection = vue.computed(() => {
  6046. const expect = props.vertical ? "vertical" : "horizontal";
  6047. return touch.direction.value === expect;
  6048. });
  6049. const trackStyle = vue.computed(() => {
  6050. const style = {
  6051. transitionDuration: `${state.swiping ? 0 : props.duration}ms`,
  6052. transform: `translate${props.vertical ? "Y" : "X"}(${state.offset}px)`
  6053. };
  6054. if (size.value) {
  6055. const mainAxis = props.vertical ? "height" : "width";
  6056. const crossAxis = props.vertical ? "width" : "height";
  6057. style[mainAxis] = `${trackSize.value}px`;
  6058. style[crossAxis] = props[crossAxis] ? `${props[crossAxis]}px` : "";
  6059. }
  6060. return style;
  6061. });
  6062. const getTargetActive = (pace) => {
  6063. const {
  6064. active
  6065. } = state;
  6066. if (pace) {
  6067. if (props.loop) {
  6068. return clamp(active + pace, -1, count.value);
  6069. }
  6070. return clamp(active + pace, 0, maxCount.value);
  6071. }
  6072. return active;
  6073. };
  6074. const getTargetOffset = (targetActive, offset2 = 0) => {
  6075. let currentPosition = targetActive * size.value;
  6076. if (!props.loop) {
  6077. currentPosition = Math.min(currentPosition, -minOffset.value);
  6078. }
  6079. let targetOffset = offset2 - currentPosition;
  6080. if (!props.loop) {
  6081. targetOffset = clamp(targetOffset, minOffset.value, 0);
  6082. }
  6083. return targetOffset;
  6084. };
  6085. const move = ({
  6086. pace = 0,
  6087. offset: offset2 = 0,
  6088. emitChange
  6089. }) => {
  6090. if (count.value <= 1) {
  6091. return;
  6092. }
  6093. const {
  6094. active
  6095. } = state;
  6096. const targetActive = getTargetActive(pace);
  6097. const targetOffset = getTargetOffset(targetActive, offset2);
  6098. if (props.loop) {
  6099. if (children[0] && targetOffset !== minOffset.value) {
  6100. const outRightBound = targetOffset < minOffset.value;
  6101. children[0].setOffset(outRightBound ? trackSize.value : 0);
  6102. }
  6103. if (children[count.value - 1] && targetOffset !== 0) {
  6104. const outLeftBound = targetOffset > 0;
  6105. children[count.value - 1].setOffset(outLeftBound ? -trackSize.value : 0);
  6106. }
  6107. }
  6108. state.active = targetActive;
  6109. state.offset = targetOffset;
  6110. if (emitChange && targetActive !== active) {
  6111. emit("change", activeIndicator.value);
  6112. }
  6113. };
  6114. const correctPosition = () => {
  6115. state.swiping = true;
  6116. if (state.active <= -1) {
  6117. move({
  6118. pace: count.value
  6119. });
  6120. } else if (state.active >= count.value) {
  6121. move({
  6122. pace: -count.value
  6123. });
  6124. }
  6125. };
  6126. const prev = () => {
  6127. correctPosition();
  6128. touch.reset();
  6129. doubleRaf(() => {
  6130. state.swiping = false;
  6131. move({
  6132. pace: -1,
  6133. emitChange: true
  6134. });
  6135. });
  6136. };
  6137. const next = () => {
  6138. correctPosition();
  6139. touch.reset();
  6140. doubleRaf(() => {
  6141. state.swiping = false;
  6142. move({
  6143. pace: 1,
  6144. emitChange: true
  6145. });
  6146. });
  6147. };
  6148. let autoplayTimer;
  6149. const stopAutoplay = () => clearTimeout(autoplayTimer);
  6150. const autoplay = () => {
  6151. stopAutoplay();
  6152. if (props.autoplay > 0 && count.value > 1) {
  6153. autoplayTimer = setTimeout(() => {
  6154. next();
  6155. autoplay();
  6156. }, +props.autoplay);
  6157. }
  6158. };
  6159. const initialize = (active = +props.initialSwipe) => {
  6160. if (!root.value) {
  6161. return;
  6162. }
  6163. const cb = () => {
  6164. var _a, _b;
  6165. if (!isHidden(root)) {
  6166. const rect = {
  6167. width: root.value.offsetWidth,
  6168. height: root.value.offsetHeight
  6169. };
  6170. state.rect = rect;
  6171. state.width = +((_a = props.width) != null ? _a : rect.width);
  6172. state.height = +((_b = props.height) != null ? _b : rect.height);
  6173. }
  6174. if (count.value) {
  6175. active = Math.min(count.value - 1, active);
  6176. }
  6177. state.active = active;
  6178. state.swiping = true;
  6179. state.offset = getTargetOffset(active);
  6180. children.forEach((swipe) => {
  6181. swipe.setOffset(0);
  6182. });
  6183. autoplay();
  6184. };
  6185. if (isHidden(root)) {
  6186. vue.nextTick().then(cb);
  6187. } else {
  6188. cb();
  6189. }
  6190. };
  6191. const resize = () => initialize(state.active);
  6192. let touchStartTime;
  6193. const onTouchStart = (event) => {
  6194. if (!props.touchable)
  6195. return;
  6196. touch.start(event);
  6197. touchStartTime = Date.now();
  6198. stopAutoplay();
  6199. correctPosition();
  6200. };
  6201. const onTouchMove = (event) => {
  6202. if (props.touchable && state.swiping) {
  6203. touch.move(event);
  6204. if (isCorrectDirection.value) {
  6205. const isEdgeTouch = !props.loop && (state.active === 0 && delta.value > 0 || state.active === count.value - 1 && delta.value < 0);
  6206. if (!isEdgeTouch) {
  6207. preventDefault(event, props.stopPropagation);
  6208. move({
  6209. offset: delta.value
  6210. });
  6211. }
  6212. }
  6213. }
  6214. };
  6215. const onTouchEnd = () => {
  6216. if (!props.touchable || !state.swiping) {
  6217. return;
  6218. }
  6219. const duration = Date.now() - touchStartTime;
  6220. const speed = delta.value / duration;
  6221. const shouldSwipe = Math.abs(speed) > 0.25 || Math.abs(delta.value) > size.value / 2;
  6222. if (shouldSwipe && isCorrectDirection.value) {
  6223. const offset2 = props.vertical ? touch.offsetY.value : touch.offsetX.value;
  6224. let pace = 0;
  6225. if (props.loop) {
  6226. pace = offset2 > 0 ? delta.value > 0 ? -1 : 1 : 0;
  6227. } else {
  6228. pace = -Math[delta.value > 0 ? "ceil" : "floor"](delta.value / size.value);
  6229. }
  6230. move({
  6231. pace,
  6232. emitChange: true
  6233. });
  6234. } else if (delta.value) {
  6235. move({
  6236. pace: 0
  6237. });
  6238. }
  6239. state.swiping = false;
  6240. autoplay();
  6241. };
  6242. const swipeTo = (index, options = {}) => {
  6243. correctPosition();
  6244. touch.reset();
  6245. doubleRaf(() => {
  6246. let targetIndex;
  6247. if (props.loop && index === count.value) {
  6248. targetIndex = state.active === 0 ? 0 : index;
  6249. } else {
  6250. targetIndex = index % count.value;
  6251. }
  6252. if (options.immediate) {
  6253. doubleRaf(() => {
  6254. state.swiping = false;
  6255. });
  6256. } else {
  6257. state.swiping = false;
  6258. }
  6259. move({
  6260. pace: targetIndex - state.active,
  6261. emitChange: true
  6262. });
  6263. });
  6264. };
  6265. const renderDot = (_, index) => {
  6266. const active = index === activeIndicator.value;
  6267. const style = active ? {
  6268. backgroundColor: props.indicatorColor
  6269. } : void 0;
  6270. return vue.createVNode("i", {
  6271. "style": style,
  6272. "class": bem$Y("indicator", {
  6273. active
  6274. })
  6275. }, null);
  6276. };
  6277. const renderIndicator = () => {
  6278. if (slots.indicator) {
  6279. return slots.indicator({
  6280. active: activeIndicator.value,
  6281. total: count.value
  6282. });
  6283. }
  6284. if (props.showIndicators && count.value > 1) {
  6285. return vue.createVNode("div", {
  6286. "class": bem$Y("indicators", {
  6287. vertical: props.vertical
  6288. })
  6289. }, [Array(count.value).fill("").map(renderDot)]);
  6290. }
  6291. };
  6292. useExpose({
  6293. prev,
  6294. next,
  6295. state,
  6296. resize,
  6297. swipeTo
  6298. });
  6299. linkChildren({
  6300. size,
  6301. props,
  6302. count,
  6303. activeIndicator
  6304. });
  6305. vue.watch(() => props.initialSwipe, (value) => initialize(+value));
  6306. vue.watch(count, () => initialize(state.active));
  6307. vue.watch(() => props.autoplay, autoplay);
  6308. vue.watch([windowWidth, windowHeight], resize);
  6309. vue.watch(usePageVisibility(), (visible) => {
  6310. if (visible === "visible") {
  6311. autoplay();
  6312. } else {
  6313. stopAutoplay();
  6314. }
  6315. });
  6316. vue.onMounted(initialize);
  6317. vue.onActivated(() => initialize(state.active));
  6318. onPopupReopen(() => initialize(state.active));
  6319. vue.onDeactivated(stopAutoplay);
  6320. vue.onBeforeUnmount(stopAutoplay);
  6321. useEventListener("touchmove", onTouchMove, {
  6322. target: track
  6323. });
  6324. return () => {
  6325. var _a;
  6326. return vue.createVNode("div", {
  6327. "ref": root,
  6328. "class": bem$Y()
  6329. }, [vue.createVNode("div", {
  6330. "ref": track,
  6331. "style": trackStyle.value,
  6332. "class": bem$Y("track", {
  6333. vertical: props.vertical
  6334. }),
  6335. "onTouchstartPassive": onTouchStart,
  6336. "onTouchend": onTouchEnd,
  6337. "onTouchcancel": onTouchEnd
  6338. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]), renderIndicator()]);
  6339. };
  6340. }
  6341. });
  6342. const Swipe = withInstall(stdin_default$13);
  6343. const [name$Y, bem$X] = createNamespace("tabs");
  6344. var stdin_default$12 = vue.defineComponent({
  6345. name: name$Y,
  6346. props: {
  6347. count: makeRequiredProp(Number),
  6348. inited: Boolean,
  6349. animated: Boolean,
  6350. duration: makeRequiredProp(numericProp),
  6351. swipeable: Boolean,
  6352. lazyRender: Boolean,
  6353. currentIndex: makeRequiredProp(Number)
  6354. },
  6355. emits: ["change"],
  6356. setup(props, {
  6357. emit,
  6358. slots
  6359. }) {
  6360. const swipeRef = vue.ref();
  6361. const onChange = (index) => emit("change", index);
  6362. const renderChildren = () => {
  6363. var _a;
  6364. const Content = (_a = slots.default) == null ? void 0 : _a.call(slots);
  6365. if (props.animated || props.swipeable) {
  6366. return vue.createVNode(Swipe, {
  6367. "ref": swipeRef,
  6368. "loop": false,
  6369. "class": bem$X("track"),
  6370. "duration": +props.duration * 1e3,
  6371. "touchable": props.swipeable,
  6372. "lazyRender": props.lazyRender,
  6373. "showIndicators": false,
  6374. "onChange": onChange
  6375. }, {
  6376. default: () => [Content]
  6377. });
  6378. }
  6379. return Content;
  6380. };
  6381. const swipeToCurrentTab = (index) => {
  6382. const swipe = swipeRef.value;
  6383. if (swipe && swipe.state.active !== index) {
  6384. swipe.swipeTo(index, {
  6385. immediate: !props.inited
  6386. });
  6387. }
  6388. };
  6389. vue.watch(() => props.currentIndex, swipeToCurrentTab);
  6390. vue.onMounted(() => {
  6391. swipeToCurrentTab(props.currentIndex);
  6392. });
  6393. useExpose({
  6394. swipeRef
  6395. });
  6396. return () => vue.createVNode("div", {
  6397. "class": bem$X("content", {
  6398. animated: props.animated || props.swipeable
  6399. })
  6400. }, [renderChildren()]);
  6401. }
  6402. });
  6403. const [name$X, bem$W] = createNamespace("tabs");
  6404. const tabsProps = {
  6405. type: makeStringProp("line"),
  6406. color: String,
  6407. border: Boolean,
  6408. sticky: Boolean,
  6409. shrink: Boolean,
  6410. active: makeNumericProp(0),
  6411. duration: makeNumericProp(0.3),
  6412. animated: Boolean,
  6413. ellipsis: truthProp,
  6414. swipeable: Boolean,
  6415. scrollspy: Boolean,
  6416. offsetTop: makeNumericProp(0),
  6417. background: String,
  6418. lazyRender: truthProp,
  6419. lineWidth: numericProp,
  6420. lineHeight: numericProp,
  6421. beforeChange: Function,
  6422. swipeThreshold: makeNumericProp(5),
  6423. titleActiveColor: String,
  6424. titleInactiveColor: String
  6425. };
  6426. const TABS_KEY = Symbol(name$X);
  6427. var stdin_default$11 = vue.defineComponent({
  6428. name: name$X,
  6429. props: tabsProps,
  6430. emits: ["click", "change", "scroll", "disabled", "rendered", "click-tab", "update:active"],
  6431. setup(props, {
  6432. emit,
  6433. slots
  6434. }) {
  6435. let tabHeight;
  6436. let lockScroll;
  6437. let stickyFixed;
  6438. const root = vue.ref();
  6439. const navRef = vue.ref();
  6440. const wrapRef = vue.ref();
  6441. const contentRef = vue.ref();
  6442. const id = useId();
  6443. const scroller = useScrollParent(root);
  6444. const [titleRefs, setTitleRefs] = useRefs();
  6445. const {
  6446. children,
  6447. linkChildren
  6448. } = useChildren(TABS_KEY);
  6449. const state = vue.reactive({
  6450. inited: false,
  6451. position: "",
  6452. lineStyle: {},
  6453. currentIndex: -1
  6454. });
  6455. const scrollable = vue.computed(() => children.length > props.swipeThreshold || !props.ellipsis || props.shrink);
  6456. const navStyle = vue.computed(() => ({
  6457. borderColor: props.color,
  6458. background: props.background
  6459. }));
  6460. const getTabName = (tab, index) => {
  6461. var _a2;
  6462. return (_a2 = tab.name) != null ? _a2 : index;
  6463. };
  6464. const currentName = vue.computed(() => {
  6465. const activeTab = children[state.currentIndex];
  6466. if (activeTab) {
  6467. return getTabName(activeTab, state.currentIndex);
  6468. }
  6469. });
  6470. const offsetTopPx = vue.computed(() => unitToPx(props.offsetTop));
  6471. const scrollOffset = vue.computed(() => {
  6472. if (props.sticky) {
  6473. return offsetTopPx.value + tabHeight;
  6474. }
  6475. return 0;
  6476. });
  6477. const scrollIntoView = (immediate) => {
  6478. const nav = navRef.value;
  6479. const titles = titleRefs.value;
  6480. if (!scrollable.value || !nav || !titles || !titles[state.currentIndex]) {
  6481. return;
  6482. }
  6483. const title = titles[state.currentIndex].$el;
  6484. const to = title.offsetLeft - (nav.offsetWidth - title.offsetWidth) / 2;
  6485. scrollLeftTo(nav, to, immediate ? 0 : +props.duration);
  6486. };
  6487. const setLine = () => {
  6488. const shouldAnimate = state.inited;
  6489. vue.nextTick(() => {
  6490. const titles = titleRefs.value;
  6491. if (!titles || !titles[state.currentIndex] || props.type !== "line" || isHidden(root.value)) {
  6492. return;
  6493. }
  6494. const title = titles[state.currentIndex].$el;
  6495. const {
  6496. lineWidth,
  6497. lineHeight
  6498. } = props;
  6499. const left2 = title.offsetLeft + title.offsetWidth / 2;
  6500. const lineStyle = {
  6501. width: addUnit(lineWidth),
  6502. backgroundColor: props.color,
  6503. transform: `translateX(${left2}px) translateX(-50%)`
  6504. };
  6505. if (shouldAnimate) {
  6506. lineStyle.transitionDuration = `${props.duration}s`;
  6507. }
  6508. if (isDef(lineHeight)) {
  6509. const height2 = addUnit(lineHeight);
  6510. lineStyle.height = height2;
  6511. lineStyle.borderRadius = height2;
  6512. }
  6513. state.lineStyle = lineStyle;
  6514. });
  6515. };
  6516. const findAvailableTab = (index) => {
  6517. const diff = index < state.currentIndex ? -1 : 1;
  6518. while (index >= 0 && index < children.length) {
  6519. if (!children[index].disabled) {
  6520. return index;
  6521. }
  6522. index += diff;
  6523. }
  6524. };
  6525. const setCurrentIndex = (currentIndex, skipScrollIntoView) => {
  6526. const newIndex = findAvailableTab(currentIndex);
  6527. if (!isDef(newIndex)) {
  6528. return;
  6529. }
  6530. const newTab = children[newIndex];
  6531. const newName = getTabName(newTab, newIndex);
  6532. const shouldEmitChange = state.currentIndex !== null;
  6533. if (state.currentIndex !== newIndex) {
  6534. state.currentIndex = newIndex;
  6535. if (!skipScrollIntoView) {
  6536. scrollIntoView();
  6537. }
  6538. setLine();
  6539. }
  6540. if (newName !== props.active) {
  6541. emit("update:active", newName);
  6542. if (shouldEmitChange) {
  6543. emit("change", newName, newTab.title);
  6544. }
  6545. }
  6546. if (stickyFixed && !props.scrollspy) {
  6547. setRootScrollTop(Math.ceil(getElementTop(root.value) - offsetTopPx.value));
  6548. }
  6549. };
  6550. const setCurrentIndexByName = (name2, skipScrollIntoView) => {
  6551. const matched = children.find((tab, index2) => getTabName(tab, index2) === name2);
  6552. const index = matched ? children.indexOf(matched) : 0;
  6553. setCurrentIndex(index, skipScrollIntoView);
  6554. };
  6555. const scrollToCurrentContent = (immediate = false) => {
  6556. if (props.scrollspy) {
  6557. const target = children[state.currentIndex].$el;
  6558. if (target && scroller.value) {
  6559. const to = getElementTop(target, scroller.value) - scrollOffset.value;
  6560. lockScroll = true;
  6561. scrollTopTo(scroller.value, to, immediate ? 0 : +props.duration, () => {
  6562. lockScroll = false;
  6563. });
  6564. }
  6565. }
  6566. };
  6567. const onClickTab = (item, index, event) => {
  6568. const {
  6569. title,
  6570. disabled
  6571. } = children[index];
  6572. const name2 = getTabName(children[index], index);
  6573. if (disabled) {
  6574. emit("disabled", name2, title);
  6575. } else {
  6576. callInterceptor(props.beforeChange, {
  6577. args: [name2],
  6578. done: () => {
  6579. setCurrentIndex(index);
  6580. scrollToCurrentContent();
  6581. }
  6582. });
  6583. emit("click", name2, title);
  6584. route(item);
  6585. }
  6586. emit("click-tab", {
  6587. name: name2,
  6588. title,
  6589. event,
  6590. disabled
  6591. });
  6592. };
  6593. const onStickyScroll = (params) => {
  6594. stickyFixed = params.isFixed;
  6595. emit("scroll", params);
  6596. };
  6597. const scrollTo = (name2) => {
  6598. vue.nextTick(() => {
  6599. setCurrentIndexByName(name2);
  6600. scrollToCurrentContent(true);
  6601. });
  6602. };
  6603. const getCurrentIndexOnScroll = () => {
  6604. for (let index = 0; index < children.length; index++) {
  6605. const {
  6606. top: top2
  6607. } = useRect(children[index].$el);
  6608. if (top2 > scrollOffset.value) {
  6609. return index === 0 ? 0 : index - 1;
  6610. }
  6611. }
  6612. return children.length - 1;
  6613. };
  6614. const onScroll = () => {
  6615. if (props.scrollspy && !lockScroll) {
  6616. const index = getCurrentIndexOnScroll();
  6617. setCurrentIndex(index);
  6618. }
  6619. };
  6620. const renderNav = () => children.map((item, index) => vue.createVNode(stdin_default$14, vue.mergeProps({
  6621. "key": item.id,
  6622. "id": `${id}-${index}`,
  6623. "ref": setTitleRefs(index),
  6624. "type": props.type,
  6625. "color": props.color,
  6626. "style": item.titleStyle,
  6627. "class": item.titleClass,
  6628. "shrink": props.shrink,
  6629. "isActive": index === state.currentIndex,
  6630. "controls": item.id,
  6631. "scrollable": scrollable.value,
  6632. "activeColor": props.titleActiveColor,
  6633. "inactiveColor": props.titleInactiveColor,
  6634. "onClick": (event) => onClickTab(item, index, event)
  6635. }, pick(item, ["dot", "badge", "title", "disabled", "showZeroBadge"])), {
  6636. title: item.$slots.title
  6637. }));
  6638. const renderLine = () => {
  6639. if (props.type === "line" && children.length) {
  6640. return vue.createVNode("div", {
  6641. "class": bem$W("line"),
  6642. "style": state.lineStyle
  6643. }, null);
  6644. }
  6645. };
  6646. const renderHeader = () => {
  6647. var _a2, _b2, _c;
  6648. const {
  6649. type,
  6650. border,
  6651. sticky
  6652. } = props;
  6653. const Header = [vue.createVNode("div", {
  6654. "ref": sticky ? void 0 : wrapRef,
  6655. "class": [bem$W("wrap"), {
  6656. [BORDER_TOP_BOTTOM]: type === "line" && border
  6657. }]
  6658. }, [vue.createVNode("div", {
  6659. "ref": navRef,
  6660. "role": "tablist",
  6661. "class": bem$W("nav", [type, {
  6662. shrink: props.shrink,
  6663. complete: scrollable.value
  6664. }]),
  6665. "style": navStyle.value,
  6666. "aria-orientation": "horizontal"
  6667. }, [(_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)];
  6668. if (sticky) {
  6669. return vue.createVNode("div", {
  6670. "ref": wrapRef
  6671. }, [Header]);
  6672. }
  6673. return Header;
  6674. };
  6675. vue.watch([() => props.color, windowWidth], setLine);
  6676. vue.watch(() => props.active, (value) => {
  6677. if (value !== currentName.value) {
  6678. setCurrentIndexByName(value);
  6679. }
  6680. });
  6681. vue.watch(() => children.length, () => {
  6682. if (state.inited) {
  6683. setCurrentIndexByName(props.active);
  6684. setLine();
  6685. vue.nextTick(() => {
  6686. scrollIntoView(true);
  6687. });
  6688. }
  6689. });
  6690. const init = () => {
  6691. setCurrentIndexByName(props.active, true);
  6692. vue.nextTick(() => {
  6693. state.inited = true;
  6694. if (wrapRef.value) {
  6695. tabHeight = useRect(wrapRef.value).height;
  6696. }
  6697. scrollIntoView(true);
  6698. });
  6699. };
  6700. const onRendered = (name2, title) => emit("rendered", name2, title);
  6701. const resize = () => {
  6702. setLine();
  6703. vue.nextTick(() => {
  6704. var _a2, _b2;
  6705. return (_b2 = (_a2 = contentRef.value) == null ? void 0 : _a2.swipeRef.value) == null ? void 0 : _b2.resize();
  6706. });
  6707. };
  6708. useExpose({
  6709. resize,
  6710. scrollTo
  6711. });
  6712. vue.onActivated(setLine);
  6713. onPopupReopen(setLine);
  6714. onMountedOrActivated(init);
  6715. useEventListener("scroll", onScroll, {
  6716. target: scroller,
  6717. passive: true
  6718. });
  6719. linkChildren({
  6720. id,
  6721. props,
  6722. setLine,
  6723. onRendered,
  6724. currentName,
  6725. scrollIntoView
  6726. });
  6727. return () => vue.createVNode("div", {
  6728. "ref": root,
  6729. "class": bem$W([props.type])
  6730. }, [props.sticky ? vue.createVNode(Sticky, {
  6731. "container": root.value,
  6732. "offsetTop": offsetTopPx.value,
  6733. "onScroll": onStickyScroll
  6734. }, {
  6735. default: () => [renderHeader()]
  6736. }) : renderHeader(), vue.createVNode(stdin_default$12, {
  6737. "ref": contentRef,
  6738. "count": children.length,
  6739. "inited": state.inited,
  6740. "animated": props.animated,
  6741. "duration": props.duration,
  6742. "swipeable": props.swipeable,
  6743. "lazyRender": props.lazyRender,
  6744. "currentIndex": state.currentIndex,
  6745. "onChange": setCurrentIndex
  6746. }, {
  6747. default: () => {
  6748. var _a2;
  6749. return [(_a2 = slots.default) == null ? void 0 : _a2.call(slots)];
  6750. }
  6751. })]);
  6752. }
  6753. });
  6754. const TAB_STATUS_KEY = Symbol();
  6755. const useTabStatus = () => vue.inject(TAB_STATUS_KEY, null);
  6756. const [name$W, bem$V] = createNamespace("swipe-item");
  6757. var stdin_default$10 = vue.defineComponent({
  6758. name: name$W,
  6759. setup(props, {
  6760. slots
  6761. }) {
  6762. let rendered;
  6763. const state = vue.reactive({
  6764. offset: 0,
  6765. inited: false,
  6766. mounted: false
  6767. });
  6768. const {
  6769. parent,
  6770. index
  6771. } = useParent(SWIPE_KEY);
  6772. if (!parent) {
  6773. return;
  6774. }
  6775. const style = vue.computed(() => {
  6776. const style2 = {};
  6777. const {
  6778. vertical
  6779. } = parent.props;
  6780. if (parent.size.value) {
  6781. style2[vertical ? "height" : "width"] = `${parent.size.value}px`;
  6782. }
  6783. if (state.offset) {
  6784. style2.transform = `translate${vertical ? "Y" : "X"}(${state.offset}px)`;
  6785. }
  6786. return style2;
  6787. });
  6788. const shouldRender = vue.computed(() => {
  6789. const {
  6790. loop,
  6791. lazyRender
  6792. } = parent.props;
  6793. if (!lazyRender || rendered) {
  6794. return true;
  6795. }
  6796. if (!state.mounted) {
  6797. return false;
  6798. }
  6799. const active = parent.activeIndicator.value;
  6800. const maxActive = parent.count.value - 1;
  6801. const prevActive = active === 0 && loop ? maxActive : active - 1;
  6802. const nextActive = active === maxActive && loop ? 0 : active + 1;
  6803. rendered = index.value === active || index.value === prevActive || index.value === nextActive;
  6804. return rendered;
  6805. });
  6806. const setOffset = (offset2) => {
  6807. state.offset = offset2;
  6808. };
  6809. vue.onMounted(() => {
  6810. vue.nextTick(() => {
  6811. state.mounted = true;
  6812. });
  6813. });
  6814. useExpose({
  6815. setOffset
  6816. });
  6817. return () => {
  6818. var _a;
  6819. return vue.createVNode("div", {
  6820. "class": bem$V(),
  6821. "style": style.value
  6822. }, [shouldRender.value ? (_a = slots.default) == null ? void 0 : _a.call(slots) : null]);
  6823. };
  6824. }
  6825. });
  6826. const SwipeItem = withInstall(stdin_default$10);
  6827. const [name$V, bem$U] = createNamespace("tab");
  6828. const tabProps = extend({}, routeProps, {
  6829. dot: Boolean,
  6830. name: numericProp,
  6831. badge: numericProp,
  6832. title: String,
  6833. disabled: Boolean,
  6834. titleClass: unknownProp,
  6835. titleStyle: [String, Object],
  6836. showZeroBadge: truthProp
  6837. });
  6838. var stdin_default$$ = vue.defineComponent({
  6839. name: name$V,
  6840. props: tabProps,
  6841. setup(props, {
  6842. slots
  6843. }) {
  6844. const id = useId();
  6845. const inited = vue.ref(false);
  6846. const {
  6847. parent,
  6848. index
  6849. } = useParent(TABS_KEY);
  6850. if (!parent) {
  6851. return;
  6852. }
  6853. const getName = () => {
  6854. var _a;
  6855. return (_a = props.name) != null ? _a : index.value;
  6856. };
  6857. const init = () => {
  6858. inited.value = true;
  6859. if (parent.props.lazyRender) {
  6860. vue.nextTick(() => {
  6861. parent.onRendered(getName(), props.title);
  6862. });
  6863. }
  6864. };
  6865. const active = vue.computed(() => {
  6866. const isActive = getName() === parent.currentName.value;
  6867. if (isActive && !inited.value) {
  6868. init();
  6869. }
  6870. return isActive;
  6871. });
  6872. const hasInactiveClass = vue.ref(!active.value);
  6873. vue.watch(active, (val) => {
  6874. if (val) {
  6875. hasInactiveClass.value = false;
  6876. } else {
  6877. doubleRaf(() => {
  6878. hasInactiveClass.value = true;
  6879. });
  6880. }
  6881. });
  6882. vue.watch(() => props.title, () => {
  6883. parent.setLine();
  6884. parent.scrollIntoView();
  6885. });
  6886. vue.provide(TAB_STATUS_KEY, active);
  6887. return () => {
  6888. var _a;
  6889. const label = `${parent.id}-${index.value}`;
  6890. const {
  6891. animated,
  6892. swipeable,
  6893. scrollspy,
  6894. lazyRender
  6895. } = parent.props;
  6896. if (!slots.default && !animated) {
  6897. return;
  6898. }
  6899. const show = scrollspy || active.value;
  6900. if (animated || swipeable) {
  6901. return vue.createVNode(SwipeItem, {
  6902. "id": id,
  6903. "role": "tabpanel",
  6904. "class": bem$U("panel-wrapper", {
  6905. inactive: hasInactiveClass.value
  6906. }),
  6907. "tabindex": active.value ? 0 : -1,
  6908. "aria-hidden": !active.value,
  6909. "aria-labelledby": label
  6910. }, {
  6911. default: () => {
  6912. var _a2;
  6913. return [vue.createVNode("div", {
  6914. "class": bem$U("panel")
  6915. }, [(_a2 = slots.default) == null ? void 0 : _a2.call(slots)])];
  6916. }
  6917. });
  6918. }
  6919. const shouldRender = inited.value || scrollspy || !lazyRender;
  6920. const Content = shouldRender ? (_a = slots.default) == null ? void 0 : _a.call(slots) : null;
  6921. useExpose({
  6922. id
  6923. });
  6924. return vue.withDirectives(vue.createVNode("div", {
  6925. "id": id,
  6926. "role": "tabpanel",
  6927. "class": bem$U("panel"),
  6928. "tabindex": show ? 0 : -1,
  6929. "aria-labelledby": label
  6930. }, [Content]), [[vue.vShow, show]]);
  6931. };
  6932. }
  6933. });
  6934. const Tab = withInstall(stdin_default$$);
  6935. const Tabs = withInstall(stdin_default$11);
  6936. const [name$U, bem$T, t$e] = createNamespace("cascader");
  6937. const cascaderProps = {
  6938. title: String,
  6939. options: makeArrayProp(),
  6940. closeable: truthProp,
  6941. swipeable: truthProp,
  6942. closeIcon: makeStringProp("cross"),
  6943. showHeader: truthProp,
  6944. modelValue: numericProp,
  6945. fieldNames: Object,
  6946. placeholder: String,
  6947. activeColor: String
  6948. };
  6949. var stdin_default$_ = vue.defineComponent({
  6950. name: name$U,
  6951. props: cascaderProps,
  6952. emits: ["close", "change", "finish", "click-tab", "update:modelValue"],
  6953. setup(props, {
  6954. slots,
  6955. emit
  6956. }) {
  6957. const tabs = vue.ref([]);
  6958. const activeTab = vue.ref(0);
  6959. const {
  6960. text: textKey,
  6961. value: valueKey,
  6962. children: childrenKey
  6963. } = extend({
  6964. text: "text",
  6965. value: "value",
  6966. children: "children"
  6967. }, props.fieldNames);
  6968. const getSelectedOptionsByValue = (options, value) => {
  6969. for (const option of options) {
  6970. if (option[valueKey] === value) {
  6971. return [option];
  6972. }
  6973. if (option[childrenKey]) {
  6974. const selectedOptions = getSelectedOptionsByValue(option[childrenKey], value);
  6975. if (selectedOptions) {
  6976. return [option, ...selectedOptions];
  6977. }
  6978. }
  6979. }
  6980. };
  6981. const updateTabs = () => {
  6982. const {
  6983. options,
  6984. modelValue
  6985. } = props;
  6986. if (modelValue !== void 0) {
  6987. const selectedOptions = getSelectedOptionsByValue(options, modelValue);
  6988. if (selectedOptions) {
  6989. let optionsCursor = options;
  6990. tabs.value = selectedOptions.map((option) => {
  6991. const tab = {
  6992. options: optionsCursor,
  6993. selected: option
  6994. };
  6995. const next = optionsCursor.find((item) => item[valueKey] === option[valueKey]);
  6996. if (next) {
  6997. optionsCursor = next[childrenKey];
  6998. }
  6999. return tab;
  7000. });
  7001. if (optionsCursor) {
  7002. tabs.value.push({
  7003. options: optionsCursor,
  7004. selected: null
  7005. });
  7006. }
  7007. vue.nextTick(() => {
  7008. activeTab.value = tabs.value.length - 1;
  7009. });
  7010. return;
  7011. }
  7012. }
  7013. tabs.value = [{
  7014. options,
  7015. selected: null
  7016. }];
  7017. };
  7018. const onSelect = (option, tabIndex) => {
  7019. if (option.disabled) {
  7020. return;
  7021. }
  7022. tabs.value[tabIndex].selected = option;
  7023. if (tabs.value.length > tabIndex + 1) {
  7024. tabs.value = tabs.value.slice(0, tabIndex + 1);
  7025. }
  7026. if (option[childrenKey]) {
  7027. const nextTab = {
  7028. options: option[childrenKey],
  7029. selected: null
  7030. };
  7031. if (tabs.value[tabIndex + 1]) {
  7032. tabs.value[tabIndex + 1] = nextTab;
  7033. } else {
  7034. tabs.value.push(nextTab);
  7035. }
  7036. vue.nextTick(() => {
  7037. activeTab.value++;
  7038. });
  7039. }
  7040. const selectedOptions = tabs.value.map((tab) => tab.selected).filter(Boolean);
  7041. emit("update:modelValue", option[valueKey]);
  7042. const params = {
  7043. value: option[valueKey],
  7044. tabIndex,
  7045. selectedOptions
  7046. };
  7047. emit("change", params);
  7048. if (!option[childrenKey]) {
  7049. emit("finish", params);
  7050. }
  7051. };
  7052. const onClose = () => emit("close");
  7053. const onClickTab = ({
  7054. name: name2,
  7055. title
  7056. }) => emit("click-tab", name2, title);
  7057. const renderHeader = () => props.showHeader ? vue.createVNode("div", {
  7058. "class": bem$T("header")
  7059. }, [vue.createVNode("h2", {
  7060. "class": bem$T("title")
  7061. }, [slots.title ? slots.title() : props.title]), props.closeable ? vue.createVNode(Icon, {
  7062. "name": props.closeIcon,
  7063. "class": [bem$T("close-icon"), HAPTICS_FEEDBACK],
  7064. "onClick": onClose
  7065. }, null) : null]) : null;
  7066. const renderOption = (option, selectedOption, tabIndex) => {
  7067. const {
  7068. disabled
  7069. } = option;
  7070. const selected = !!(selectedOption && option[valueKey] === selectedOption[valueKey]);
  7071. const color = option.color || (selected ? props.activeColor : void 0);
  7072. const Text2 = slots.option ? slots.option({
  7073. option,
  7074. selected
  7075. }) : vue.createVNode("span", null, [option[textKey]]);
  7076. return vue.createVNode("li", {
  7077. "role": "menuitemradio",
  7078. "class": [bem$T("option", {
  7079. selected,
  7080. disabled
  7081. }), option.className],
  7082. "style": {
  7083. color
  7084. },
  7085. "tabindex": disabled ? void 0 : selected ? 0 : -1,
  7086. "aria-checked": selected,
  7087. "aria-disabled": disabled || void 0,
  7088. "onClick": () => onSelect(option, tabIndex)
  7089. }, [Text2, selected ? vue.createVNode(Icon, {
  7090. "name": "success",
  7091. "class": bem$T("selected-icon")
  7092. }, null) : null]);
  7093. };
  7094. const renderOptions = (options, selectedOption, tabIndex) => vue.createVNode("ul", {
  7095. "role": "menu",
  7096. "class": bem$T("options")
  7097. }, [options.map((option) => renderOption(option, selectedOption, tabIndex))]);
  7098. const renderTab = (tab, tabIndex) => {
  7099. const {
  7100. options,
  7101. selected
  7102. } = tab;
  7103. const placeholder = props.placeholder || t$e("select");
  7104. const title = selected ? selected[textKey] : placeholder;
  7105. return vue.createVNode(Tab, {
  7106. "title": title,
  7107. "titleClass": bem$T("tab", {
  7108. unselected: !selected
  7109. })
  7110. }, {
  7111. default: () => {
  7112. var _a, _b;
  7113. return [(_a = slots["options-top"]) == null ? void 0 : _a.call(slots, {
  7114. tabIndex
  7115. }), renderOptions(options, selected, tabIndex), (_b = slots["options-bottom"]) == null ? void 0 : _b.call(slots, {
  7116. tabIndex
  7117. })];
  7118. }
  7119. });
  7120. };
  7121. const renderTabs = () => vue.createVNode(Tabs, {
  7122. "active": activeTab.value,
  7123. "onUpdate:active": ($event) => activeTab.value = $event,
  7124. "shrink": true,
  7125. "animated": true,
  7126. "class": bem$T("tabs"),
  7127. "color": props.activeColor,
  7128. "swipeable": props.swipeable,
  7129. "onClick-tab": onClickTab
  7130. }, {
  7131. default: () => [tabs.value.map(renderTab)]
  7132. });
  7133. updateTabs();
  7134. vue.watch(() => props.options, updateTabs, {
  7135. deep: true
  7136. });
  7137. vue.watch(() => props.modelValue, (value) => {
  7138. if (value !== void 0) {
  7139. const values = tabs.value.map((tab) => {
  7140. var _a;
  7141. return (_a = tab.selected) == null ? void 0 : _a[valueKey];
  7142. });
  7143. if (values.includes(value)) {
  7144. return;
  7145. }
  7146. }
  7147. updateTabs();
  7148. });
  7149. return () => vue.createVNode("div", {
  7150. "class": bem$T()
  7151. }, [renderHeader(), renderTabs()]);
  7152. }
  7153. });
  7154. const Cascader = withInstall(stdin_default$_);
  7155. const [name$T, bem$S] = createNamespace("cell-group");
  7156. const cellGroupProps = {
  7157. title: String,
  7158. inset: Boolean,
  7159. border: truthProp
  7160. };
  7161. var stdin_default$Z = vue.defineComponent({
  7162. name: name$T,
  7163. inheritAttrs: false,
  7164. props: cellGroupProps,
  7165. setup(props, {
  7166. slots,
  7167. attrs
  7168. }) {
  7169. const renderGroup = () => {
  7170. var _a;
  7171. return vue.createVNode("div", vue.mergeProps({
  7172. "class": [bem$S({
  7173. inset: props.inset
  7174. }), {
  7175. [BORDER_TOP_BOTTOM]: props.border && !props.inset
  7176. }]
  7177. }, attrs), [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  7178. };
  7179. const renderTitle = () => vue.createVNode("div", {
  7180. "class": bem$S("title", {
  7181. inset: props.inset
  7182. })
  7183. }, [slots.title ? slots.title() : props.title]);
  7184. return () => {
  7185. if (props.title || slots.title) {
  7186. return vue.createVNode(vue.Fragment, null, [renderTitle(), renderGroup()]);
  7187. }
  7188. return renderGroup();
  7189. };
  7190. }
  7191. });
  7192. const CellGroup = withInstall(stdin_default$Z);
  7193. const [name$S, bem$R] = createNamespace("checkbox-group");
  7194. const checkboxGroupProps = {
  7195. max: numericProp,
  7196. disabled: Boolean,
  7197. iconSize: numericProp,
  7198. direction: String,
  7199. modelValue: makeArrayProp(),
  7200. checkedColor: String
  7201. };
  7202. const CHECKBOX_GROUP_KEY = Symbol(name$S);
  7203. var stdin_default$Y = vue.defineComponent({
  7204. name: name$S,
  7205. props: checkboxGroupProps,
  7206. emits: ["change", "update:modelValue"],
  7207. setup(props, {
  7208. emit,
  7209. slots
  7210. }) {
  7211. const {
  7212. children,
  7213. linkChildren
  7214. } = useChildren(CHECKBOX_GROUP_KEY);
  7215. const updateValue = (value) => emit("update:modelValue", value);
  7216. const toggleAll = (options = {}) => {
  7217. if (typeof options === "boolean") {
  7218. options = {
  7219. checked: options
  7220. };
  7221. }
  7222. const {
  7223. checked,
  7224. skipDisabled
  7225. } = options;
  7226. const checkedChildren = children.filter((item) => {
  7227. if (!item.props.bindGroup) {
  7228. return false;
  7229. }
  7230. if (item.props.disabled && skipDisabled) {
  7231. return item.checked.value;
  7232. }
  7233. return checked != null ? checked : !item.checked.value;
  7234. });
  7235. const names = checkedChildren.map((item) => item.name);
  7236. updateValue(names);
  7237. };
  7238. vue.watch(() => props.modelValue, (value) => emit("change", value));
  7239. useExpose({
  7240. toggleAll
  7241. });
  7242. useCustomFieldValue(() => props.modelValue);
  7243. linkChildren({
  7244. props,
  7245. updateValue
  7246. });
  7247. return () => {
  7248. var _a;
  7249. return vue.createVNode("div", {
  7250. "class": bem$R([props.direction])
  7251. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  7252. };
  7253. }
  7254. });
  7255. const [name$R, bem$Q] = createNamespace("checkbox");
  7256. const checkboxProps = extend({}, checkerProps, {
  7257. bindGroup: truthProp
  7258. });
  7259. var stdin_default$X = vue.defineComponent({
  7260. name: name$R,
  7261. props: checkboxProps,
  7262. emits: ["change", "update:modelValue"],
  7263. setup(props, {
  7264. emit,
  7265. slots
  7266. }) {
  7267. const {
  7268. parent
  7269. } = useParent(CHECKBOX_GROUP_KEY);
  7270. const setParentValue = (checked2) => {
  7271. const {
  7272. name: name2
  7273. } = props;
  7274. const {
  7275. max,
  7276. modelValue
  7277. } = parent.props;
  7278. const value = modelValue.slice();
  7279. if (checked2) {
  7280. const overlimit = max && value.length >= max;
  7281. if (!overlimit && !value.includes(name2)) {
  7282. value.push(name2);
  7283. if (props.bindGroup) {
  7284. parent.updateValue(value);
  7285. }
  7286. }
  7287. } else {
  7288. const index = value.indexOf(name2);
  7289. if (index !== -1) {
  7290. value.splice(index, 1);
  7291. if (props.bindGroup) {
  7292. parent.updateValue(value);
  7293. }
  7294. }
  7295. }
  7296. };
  7297. const checked = vue.computed(() => {
  7298. if (parent && props.bindGroup) {
  7299. return parent.props.modelValue.indexOf(props.name) !== -1;
  7300. }
  7301. return !!props.modelValue;
  7302. });
  7303. const toggle = (newValue = !checked.value) => {
  7304. if (parent && props.bindGroup) {
  7305. setParentValue(newValue);
  7306. } else {
  7307. emit("update:modelValue", newValue);
  7308. }
  7309. };
  7310. vue.watch(() => props.modelValue, (value) => emit("change", value));
  7311. useExpose({
  7312. toggle,
  7313. props,
  7314. checked
  7315. });
  7316. useCustomFieldValue(() => props.modelValue);
  7317. return () => vue.createVNode(stdin_default$1f, vue.mergeProps({
  7318. "bem": bem$Q,
  7319. "role": "checkbox",
  7320. "parent": parent,
  7321. "checked": checked.value,
  7322. "onToggle": toggle
  7323. }, props), pick(slots, ["default", "icon"]));
  7324. }
  7325. });
  7326. const Checkbox = withInstall(stdin_default$X);
  7327. const CheckboxGroup = withInstall(stdin_default$Y);
  7328. const [name$Q, bem$P] = createNamespace("circle");
  7329. let uid = 0;
  7330. const format$1 = (rate) => Math.min(Math.max(+rate, 0), 100);
  7331. function getPath(clockwise, viewBoxSize) {
  7332. const sweepFlag = clockwise ? 1 : 0;
  7333. 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`;
  7334. }
  7335. const circleProps = {
  7336. text: String,
  7337. size: numericProp,
  7338. fill: makeStringProp("none"),
  7339. rate: makeNumericProp(100),
  7340. speed: makeNumericProp(0),
  7341. color: [String, Object],
  7342. clockwise: truthProp,
  7343. layerColor: String,
  7344. currentRate: makeNumberProp(0),
  7345. strokeWidth: makeNumericProp(40),
  7346. strokeLinecap: String,
  7347. startPosition: makeStringProp("top")
  7348. };
  7349. var stdin_default$W = vue.defineComponent({
  7350. name: name$Q,
  7351. props: circleProps,
  7352. emits: ["update:currentRate"],
  7353. setup(props, {
  7354. emit,
  7355. slots
  7356. }) {
  7357. const id = `van-circle-${uid++}`;
  7358. const viewBoxSize = vue.computed(() => +props.strokeWidth + 1e3);
  7359. const path = vue.computed(() => getPath(props.clockwise, viewBoxSize.value));
  7360. const svgStyle = vue.computed(() => {
  7361. const ROTATE_ANGLE_MAP = {
  7362. top: 0,
  7363. right: 90,
  7364. bottom: 180,
  7365. left: 270
  7366. };
  7367. const angleValue = ROTATE_ANGLE_MAP[props.startPosition];
  7368. if (angleValue) {
  7369. return {
  7370. transform: `rotate(${angleValue}deg)`
  7371. };
  7372. }
  7373. });
  7374. vue.watch(() => props.rate, (rate) => {
  7375. let rafId;
  7376. const startTime = Date.now();
  7377. const startRate = props.currentRate;
  7378. const endRate = format$1(rate);
  7379. const duration = Math.abs((startRate - endRate) * 1e3 / +props.speed);
  7380. const animate = () => {
  7381. const now = Date.now();
  7382. const progress = Math.min((now - startTime) / duration, 1);
  7383. const rate2 = progress * (endRate - startRate) + startRate;
  7384. emit("update:currentRate", format$1(parseFloat(rate2.toFixed(1))));
  7385. if (endRate > startRate ? rate2 < endRate : rate2 > endRate) {
  7386. rafId = raf(animate);
  7387. }
  7388. };
  7389. if (props.speed) {
  7390. if (rafId) {
  7391. cancelRaf(rafId);
  7392. }
  7393. rafId = raf(animate);
  7394. } else {
  7395. emit("update:currentRate", endRate);
  7396. }
  7397. }, {
  7398. immediate: true
  7399. });
  7400. const renderHover = () => {
  7401. const PERIMETER = 3140;
  7402. const {
  7403. strokeWidth,
  7404. currentRate,
  7405. strokeLinecap
  7406. } = props;
  7407. const offset2 = PERIMETER * currentRate / 100;
  7408. const color = isObject(props.color) ? `url(#${id})` : props.color;
  7409. const style = {
  7410. stroke: color,
  7411. strokeWidth: `${+strokeWidth + 1}px`,
  7412. strokeLinecap,
  7413. strokeDasharray: `${offset2}px ${PERIMETER}px`
  7414. };
  7415. return vue.createVNode("path", {
  7416. "d": path.value,
  7417. "style": style,
  7418. "class": bem$P("hover"),
  7419. "stroke": color
  7420. }, null);
  7421. };
  7422. const renderLayer = () => {
  7423. const style = {
  7424. fill: props.fill,
  7425. stroke: props.layerColor,
  7426. strokeWidth: `${props.strokeWidth}px`
  7427. };
  7428. return vue.createVNode("path", {
  7429. "class": bem$P("layer"),
  7430. "style": style,
  7431. "d": path.value
  7432. }, null);
  7433. };
  7434. const renderGradient = () => {
  7435. const {
  7436. color
  7437. } = props;
  7438. if (!isObject(color)) {
  7439. return;
  7440. }
  7441. const Stops = Object.keys(color).sort((a, b) => parseFloat(a) - parseFloat(b)).map((key, index) => vue.createVNode("stop", {
  7442. "key": index,
  7443. "offset": key,
  7444. "stop-color": color[key]
  7445. }, null));
  7446. return vue.createVNode("defs", null, [vue.createVNode("linearGradient", {
  7447. "id": id,
  7448. "x1": "100%",
  7449. "y1": "0%",
  7450. "x2": "0%",
  7451. "y2": "0%"
  7452. }, [Stops])]);
  7453. };
  7454. const renderText = () => {
  7455. if (slots.default) {
  7456. return slots.default();
  7457. }
  7458. if (props.text) {
  7459. return vue.createVNode("div", {
  7460. "class": bem$P("text")
  7461. }, [props.text]);
  7462. }
  7463. };
  7464. return () => vue.createVNode("div", {
  7465. "class": bem$P(),
  7466. "style": getSizeStyle(props.size)
  7467. }, [vue.createVNode("svg", {
  7468. "viewBox": `0 0 ${viewBoxSize.value} ${viewBoxSize.value}`,
  7469. "style": svgStyle.value
  7470. }, [renderGradient(), renderLayer(), renderHover()]), renderText()]);
  7471. }
  7472. });
  7473. const Circle = withInstall(stdin_default$W);
  7474. const [name$P, bem$O] = createNamespace("row");
  7475. const ROW_KEY = Symbol(name$P);
  7476. const rowProps = {
  7477. tag: makeStringProp("div"),
  7478. wrap: truthProp,
  7479. align: String,
  7480. gutter: makeNumericProp(0),
  7481. justify: String
  7482. };
  7483. var stdin_default$V = vue.defineComponent({
  7484. name: name$P,
  7485. props: rowProps,
  7486. setup(props, {
  7487. slots
  7488. }) {
  7489. const {
  7490. children,
  7491. linkChildren
  7492. } = useChildren(ROW_KEY);
  7493. const groups = vue.computed(() => {
  7494. const groups2 = [[]];
  7495. let totalSpan = 0;
  7496. children.forEach((child, index) => {
  7497. totalSpan += Number(child.span);
  7498. if (totalSpan > 24) {
  7499. groups2.push([index]);
  7500. totalSpan -= 24;
  7501. } else {
  7502. groups2[groups2.length - 1].push(index);
  7503. }
  7504. });
  7505. return groups2;
  7506. });
  7507. const spaces = vue.computed(() => {
  7508. const gutter = Number(props.gutter);
  7509. const spaces2 = [];
  7510. if (!gutter) {
  7511. return spaces2;
  7512. }
  7513. groups.value.forEach((group) => {
  7514. const averagePadding = gutter * (group.length - 1) / group.length;
  7515. group.forEach((item, index) => {
  7516. if (index === 0) {
  7517. spaces2.push({
  7518. right: averagePadding
  7519. });
  7520. } else {
  7521. const left2 = gutter - spaces2[item - 1].right;
  7522. const right2 = averagePadding - left2;
  7523. spaces2.push({
  7524. left: left2,
  7525. right: right2
  7526. });
  7527. }
  7528. });
  7529. });
  7530. return spaces2;
  7531. });
  7532. linkChildren({
  7533. spaces
  7534. });
  7535. return () => {
  7536. const {
  7537. tag,
  7538. wrap,
  7539. align,
  7540. justify
  7541. } = props;
  7542. return vue.createVNode(tag, {
  7543. "class": bem$O({
  7544. [`align-${align}`]: align,
  7545. [`justify-${justify}`]: justify,
  7546. nowrap: !wrap
  7547. })
  7548. }, {
  7549. default: () => {
  7550. var _a;
  7551. return [(_a = slots.default) == null ? void 0 : _a.call(slots)];
  7552. }
  7553. });
  7554. };
  7555. }
  7556. });
  7557. const [name$O, bem$N] = createNamespace("col");
  7558. const colProps = {
  7559. tag: makeStringProp("div"),
  7560. span: makeNumericProp(0),
  7561. offset: numericProp
  7562. };
  7563. var stdin_default$U = vue.defineComponent({
  7564. name: name$O,
  7565. props: colProps,
  7566. setup(props, {
  7567. slots
  7568. }) {
  7569. const {
  7570. parent,
  7571. index
  7572. } = useParent(ROW_KEY);
  7573. const style = vue.computed(() => {
  7574. if (!parent) {
  7575. return;
  7576. }
  7577. const {
  7578. spaces
  7579. } = parent;
  7580. if (spaces && spaces.value && spaces.value[index.value]) {
  7581. const {
  7582. left: left2,
  7583. right: right2
  7584. } = spaces.value[index.value];
  7585. return {
  7586. paddingLeft: left2 ? `${left2}px` : null,
  7587. paddingRight: right2 ? `${right2}px` : null
  7588. };
  7589. }
  7590. });
  7591. return () => {
  7592. const {
  7593. tag,
  7594. span,
  7595. offset: offset2
  7596. } = props;
  7597. return vue.createVNode(tag, {
  7598. "style": style.value,
  7599. "class": bem$N({
  7600. [span]: span,
  7601. [`offset-${offset2}`]: offset2
  7602. })
  7603. }, {
  7604. default: () => {
  7605. var _a;
  7606. return [(_a = slots.default) == null ? void 0 : _a.call(slots)];
  7607. }
  7608. });
  7609. };
  7610. }
  7611. });
  7612. const Col = withInstall(stdin_default$U);
  7613. const [name$N, bem$M] = createNamespace("collapse");
  7614. const COLLAPSE_KEY = Symbol(name$N);
  7615. const collapseProps = {
  7616. border: truthProp,
  7617. accordion: Boolean,
  7618. modelValue: {
  7619. type: [String, Number, Array],
  7620. default: ""
  7621. }
  7622. };
  7623. var stdin_default$T = vue.defineComponent({
  7624. name: name$N,
  7625. props: collapseProps,
  7626. emits: ["change", "update:modelValue"],
  7627. setup(props, {
  7628. emit,
  7629. slots
  7630. }) {
  7631. const {
  7632. linkChildren,
  7633. children
  7634. } = useChildren(COLLAPSE_KEY);
  7635. const updateName = (name2) => {
  7636. emit("change", name2);
  7637. emit("update:modelValue", name2);
  7638. };
  7639. const toggle = (name2, expanded) => {
  7640. const {
  7641. accordion,
  7642. modelValue
  7643. } = props;
  7644. if (accordion) {
  7645. updateName(name2 === modelValue ? "" : name2);
  7646. } else if (expanded) {
  7647. updateName(modelValue.concat(name2));
  7648. } else {
  7649. updateName(modelValue.filter((activeName) => activeName !== name2));
  7650. }
  7651. };
  7652. const toggleAll = (options = {}) => {
  7653. if (props.accordion) {
  7654. return;
  7655. }
  7656. if (typeof options === "boolean") {
  7657. options = {
  7658. expanded: options
  7659. };
  7660. }
  7661. const {
  7662. expanded,
  7663. skipDisabled
  7664. } = options;
  7665. const expandedChildren = children.filter((item) => {
  7666. if (item.disabled && skipDisabled) {
  7667. return item.expanded.value;
  7668. }
  7669. return expanded != null ? expanded : !item.expanded.value;
  7670. });
  7671. const names = expandedChildren.map((item) => item.itemName.value);
  7672. updateName(names);
  7673. };
  7674. const isExpanded = (name2) => {
  7675. const {
  7676. accordion,
  7677. modelValue
  7678. } = props;
  7679. return accordion ? modelValue === name2 : modelValue.includes(name2);
  7680. };
  7681. useExpose({
  7682. toggleAll
  7683. });
  7684. linkChildren({
  7685. toggle,
  7686. isExpanded
  7687. });
  7688. return () => {
  7689. var _a;
  7690. return vue.createVNode("div", {
  7691. "class": [bem$M(), {
  7692. [BORDER_TOP_BOTTOM]: props.border
  7693. }]
  7694. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  7695. };
  7696. }
  7697. });
  7698. const Collapse = withInstall(stdin_default$T);
  7699. const [name$M, bem$L] = createNamespace("collapse-item");
  7700. const CELL_SLOTS = ["icon", "title", "value", "label", "right-icon"];
  7701. const collapseItemProps = extend({}, cellSharedProps, {
  7702. name: numericProp,
  7703. isLink: truthProp,
  7704. disabled: Boolean,
  7705. readonly: Boolean,
  7706. lazyRender: truthProp
  7707. });
  7708. var stdin_default$S = vue.defineComponent({
  7709. name: name$M,
  7710. props: collapseItemProps,
  7711. setup(props, {
  7712. slots
  7713. }) {
  7714. const wrapperRef = vue.ref();
  7715. const contentRef = vue.ref();
  7716. const {
  7717. parent,
  7718. index
  7719. } = useParent(COLLAPSE_KEY);
  7720. if (!parent) {
  7721. return;
  7722. }
  7723. const name2 = vue.computed(() => {
  7724. var _a;
  7725. return (_a = props.name) != null ? _a : index.value;
  7726. });
  7727. const expanded = vue.computed(() => parent.isExpanded(name2.value));
  7728. const show = vue.ref(expanded.value);
  7729. const lazyRender = useLazyRender(() => show.value || !props.lazyRender);
  7730. const onTransitionEnd = () => {
  7731. if (!expanded.value) {
  7732. show.value = false;
  7733. } else if (wrapperRef.value) {
  7734. wrapperRef.value.style.height = "";
  7735. }
  7736. };
  7737. vue.watch(expanded, (value, oldValue) => {
  7738. if (oldValue === null) {
  7739. return;
  7740. }
  7741. if (value) {
  7742. show.value = true;
  7743. }
  7744. const tick = value ? vue.nextTick : raf;
  7745. tick(() => {
  7746. if (!contentRef.value || !wrapperRef.value) {
  7747. return;
  7748. }
  7749. const {
  7750. offsetHeight
  7751. } = contentRef.value;
  7752. if (offsetHeight) {
  7753. const contentHeight = `${offsetHeight}px`;
  7754. wrapperRef.value.style.height = value ? "0" : contentHeight;
  7755. doubleRaf(() => {
  7756. if (wrapperRef.value) {
  7757. wrapperRef.value.style.height = value ? contentHeight : "0";
  7758. }
  7759. });
  7760. } else {
  7761. onTransitionEnd();
  7762. }
  7763. });
  7764. });
  7765. const toggle = (newValue = !expanded.value) => {
  7766. parent.toggle(name2.value, newValue);
  7767. };
  7768. const onClickTitle = () => {
  7769. if (!props.disabled && !props.readonly) {
  7770. toggle();
  7771. }
  7772. };
  7773. const renderTitle = () => {
  7774. const {
  7775. border,
  7776. disabled,
  7777. readonly
  7778. } = props;
  7779. const attrs = pick(props, Object.keys(cellSharedProps));
  7780. if (readonly) {
  7781. attrs.isLink = false;
  7782. }
  7783. if (disabled || readonly) {
  7784. attrs.clickable = false;
  7785. }
  7786. return vue.createVNode(Cell, vue.mergeProps({
  7787. "role": "button",
  7788. "class": bem$L("title", {
  7789. disabled,
  7790. expanded: expanded.value,
  7791. borderless: !border
  7792. }),
  7793. "aria-expanded": String(expanded.value),
  7794. "onClick": onClickTitle
  7795. }, attrs), pick(slots, CELL_SLOTS));
  7796. };
  7797. const renderContent = lazyRender(() => {
  7798. var _a;
  7799. return vue.withDirectives(vue.createVNode("div", {
  7800. "ref": wrapperRef,
  7801. "class": bem$L("wrapper"),
  7802. "onTransitionend": onTransitionEnd
  7803. }, [vue.createVNode("div", {
  7804. "ref": contentRef,
  7805. "class": bem$L("content")
  7806. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)])]), [[vue.vShow, show.value]]);
  7807. });
  7808. useExpose({
  7809. toggle,
  7810. expanded,
  7811. itemName: name2
  7812. });
  7813. return () => vue.createVNode("div", {
  7814. "class": [bem$L({
  7815. border: index.value && props.border
  7816. })]
  7817. }, [renderTitle(), renderContent()]);
  7818. }
  7819. });
  7820. const CollapseItem = withInstall(stdin_default$S);
  7821. const ConfigProvider = withInstall(stdin_default$1A);
  7822. const [name$L, bem$K, t$d] = createNamespace("contact-card");
  7823. const contactCardProps = {
  7824. tel: String,
  7825. name: String,
  7826. type: makeStringProp("add"),
  7827. addText: String,
  7828. editable: truthProp
  7829. };
  7830. var stdin_default$R = vue.defineComponent({
  7831. name: name$L,
  7832. props: contactCardProps,
  7833. emits: ["click"],
  7834. setup(props, {
  7835. emit
  7836. }) {
  7837. const onClick = (event) => {
  7838. if (props.editable) {
  7839. emit("click", event);
  7840. }
  7841. };
  7842. const renderContent = () => {
  7843. if (props.type === "add") {
  7844. return props.addText || t$d("addContact");
  7845. }
  7846. return [vue.createVNode("div", null, [`${t$d("name")}\uFF1A${props.name}`]), vue.createVNode("div", null, [`${t$d("tel")}\uFF1A${props.tel}`])];
  7847. };
  7848. return () => vue.createVNode(Cell, {
  7849. "center": true,
  7850. "icon": props.type === "edit" ? "contact" : "add-square",
  7851. "class": bem$K([props.type]),
  7852. "border": false,
  7853. "isLink": props.editable,
  7854. "valueClass": bem$K("value"),
  7855. "onClick": onClick
  7856. }, {
  7857. value: renderContent
  7858. });
  7859. }
  7860. });
  7861. const ContactCard = withInstall(stdin_default$R);
  7862. const [name$K, bem$J, t$c] = createNamespace("contact-edit");
  7863. const DEFAULT_CONTACT = {
  7864. tel: "",
  7865. name: ""
  7866. };
  7867. const contactEditProps = {
  7868. isEdit: Boolean,
  7869. isSaving: Boolean,
  7870. isDeleting: Boolean,
  7871. showSetDefault: Boolean,
  7872. setDefaultLabel: String,
  7873. contactInfo: {
  7874. type: Object,
  7875. default: () => extend({}, DEFAULT_CONTACT)
  7876. },
  7877. telValidator: {
  7878. type: Function,
  7879. default: isMobile
  7880. }
  7881. };
  7882. var stdin_default$Q = vue.defineComponent({
  7883. name: name$K,
  7884. props: contactEditProps,
  7885. emits: ["save", "delete", "change-default"],
  7886. setup(props, {
  7887. emit
  7888. }) {
  7889. const contact = vue.reactive(extend({}, DEFAULT_CONTACT, props.contactInfo));
  7890. const onSave = () => {
  7891. if (!props.isSaving) {
  7892. emit("save", contact);
  7893. }
  7894. };
  7895. const onDelete = () => emit("delete", contact);
  7896. const renderButtons = () => vue.createVNode("div", {
  7897. "class": bem$J("buttons")
  7898. }, [vue.createVNode(Button, {
  7899. "block": true,
  7900. "round": true,
  7901. "type": "danger",
  7902. "text": t$c("save"),
  7903. "class": bem$J("button"),
  7904. "loading": props.isSaving,
  7905. "nativeType": "submit"
  7906. }, null), props.isEdit && vue.createVNode(Button, {
  7907. "block": true,
  7908. "round": true,
  7909. "text": t$c("delete"),
  7910. "class": bem$J("button"),
  7911. "loading": props.isDeleting,
  7912. "onClick": onDelete
  7913. }, null)]);
  7914. const renderSwitch = () => vue.createVNode(Switch, {
  7915. "modelValue": contact.isDefault,
  7916. "onUpdate:modelValue": ($event) => contact.isDefault = $event,
  7917. "size": 24,
  7918. "onChange": (checked) => emit("change-default", checked)
  7919. }, null);
  7920. const renderSetDefault = () => {
  7921. if (props.showSetDefault) {
  7922. return vue.createVNode(Cell, {
  7923. "title": props.setDefaultLabel,
  7924. "class": bem$J("switch-cell"),
  7925. "border": false
  7926. }, {
  7927. "right-icon": renderSwitch
  7928. });
  7929. }
  7930. };
  7931. vue.watch(() => props.contactInfo, (value) => extend(contact, DEFAULT_CONTACT, value));
  7932. return () => vue.createVNode(Form, {
  7933. "class": bem$J(),
  7934. "onSubmit": onSave
  7935. }, {
  7936. default: () => [vue.createVNode("div", {
  7937. "class": bem$J("fields")
  7938. }, [vue.createVNode(Field, {
  7939. "modelValue": contact.name,
  7940. "onUpdate:modelValue": ($event) => contact.name = $event,
  7941. "clearable": true,
  7942. "label": t$c("name"),
  7943. "rules": [{
  7944. required: true,
  7945. message: t$c("nameEmpty")
  7946. }],
  7947. "maxlength": "30",
  7948. "placeholder": t$c("name")
  7949. }, null), vue.createVNode(Field, {
  7950. "modelValue": contact.tel,
  7951. "onUpdate:modelValue": ($event) => contact.tel = $event,
  7952. "clearable": true,
  7953. "type": "tel",
  7954. "label": t$c("tel"),
  7955. "rules": [{
  7956. validator: props.telValidator,
  7957. message: t$c("telInvalid")
  7958. }],
  7959. "placeholder": t$c("tel")
  7960. }, null)]), renderSetDefault(), renderButtons()]
  7961. });
  7962. }
  7963. });
  7964. const ContactEdit = withInstall(stdin_default$Q);
  7965. const [name$J, bem$I, t$b] = createNamespace("contact-list");
  7966. const contactListProps = {
  7967. list: Array,
  7968. addText: String,
  7969. modelValue: unknownProp,
  7970. defaultTagText: String
  7971. };
  7972. var stdin_default$P = vue.defineComponent({
  7973. name: name$J,
  7974. props: contactListProps,
  7975. emits: ["add", "edit", "select", "update:modelValue"],
  7976. setup(props, {
  7977. emit
  7978. }) {
  7979. const renderItem = (item, index) => {
  7980. const onClick = () => {
  7981. emit("update:modelValue", item.id);
  7982. emit("select", item, index);
  7983. };
  7984. const renderRightIcon = () => vue.createVNode(Radio, {
  7985. "class": bem$I("radio"),
  7986. "name": item.id,
  7987. "iconSize": 16
  7988. }, null);
  7989. const renderEditIcon = () => vue.createVNode(Icon, {
  7990. "name": "edit",
  7991. "class": bem$I("edit"),
  7992. "onClick": (event) => {
  7993. event.stopPropagation();
  7994. emit("edit", item, index);
  7995. }
  7996. }, null);
  7997. const renderContent = () => {
  7998. const nodes = [`${item.name}\uFF0C${item.tel}`];
  7999. if (item.isDefault && props.defaultTagText) {
  8000. nodes.push(vue.createVNode(Tag, {
  8001. "type": "danger",
  8002. "round": true,
  8003. "class": bem$I("item-tag")
  8004. }, {
  8005. default: () => [props.defaultTagText]
  8006. }));
  8007. }
  8008. return nodes;
  8009. };
  8010. return vue.createVNode(Cell, {
  8011. "key": item.id,
  8012. "isLink": true,
  8013. "center": true,
  8014. "class": bem$I("item"),
  8015. "valueClass": bem$I("item-value"),
  8016. "onClick": onClick
  8017. }, {
  8018. icon: renderEditIcon,
  8019. value: renderContent,
  8020. "right-icon": renderRightIcon
  8021. });
  8022. };
  8023. return () => vue.createVNode("div", {
  8024. "class": bem$I()
  8025. }, [vue.createVNode(RadioGroup, {
  8026. "modelValue": props.modelValue,
  8027. "class": bem$I("group")
  8028. }, {
  8029. default: () => [props.list && props.list.map(renderItem)]
  8030. }), vue.createVNode("div", {
  8031. "class": [bem$I("bottom"), "van-safe-area-bottom"]
  8032. }, [vue.createVNode(Button, {
  8033. "round": true,
  8034. "block": true,
  8035. "type": "danger",
  8036. "class": bem$I("add"),
  8037. "text": props.addText || t$b("addContact"),
  8038. "onClick": () => emit("add")
  8039. }, null)])]);
  8040. }
  8041. });
  8042. const ContactList = withInstall(stdin_default$P);
  8043. function parseFormat(format2, currentTime) {
  8044. const { days } = currentTime;
  8045. let { hours, minutes, seconds, milliseconds } = currentTime;
  8046. if (format2.includes("DD")) {
  8047. format2 = format2.replace("DD", padZero(days));
  8048. } else {
  8049. hours += days * 24;
  8050. }
  8051. if (format2.includes("HH")) {
  8052. format2 = format2.replace("HH", padZero(hours));
  8053. } else {
  8054. minutes += hours * 60;
  8055. }
  8056. if (format2.includes("mm")) {
  8057. format2 = format2.replace("mm", padZero(minutes));
  8058. } else {
  8059. seconds += minutes * 60;
  8060. }
  8061. if (format2.includes("ss")) {
  8062. format2 = format2.replace("ss", padZero(seconds));
  8063. } else {
  8064. milliseconds += seconds * 1e3;
  8065. }
  8066. if (format2.includes("S")) {
  8067. const ms = padZero(milliseconds, 3);
  8068. if (format2.includes("SSS")) {
  8069. format2 = format2.replace("SSS", ms);
  8070. } else if (format2.includes("SS")) {
  8071. format2 = format2.replace("SS", ms.slice(0, 2));
  8072. } else {
  8073. format2 = format2.replace("S", ms.charAt(0));
  8074. }
  8075. }
  8076. return format2;
  8077. }
  8078. const [name$I, bem$H] = createNamespace("count-down");
  8079. const countDownProps = {
  8080. time: makeNumericProp(0),
  8081. format: makeStringProp("HH:mm:ss"),
  8082. autoStart: truthProp,
  8083. millisecond: Boolean
  8084. };
  8085. var stdin_default$O = vue.defineComponent({
  8086. name: name$I,
  8087. props: countDownProps,
  8088. emits: ["change", "finish"],
  8089. setup(props, {
  8090. emit,
  8091. slots
  8092. }) {
  8093. const {
  8094. start: start2,
  8095. pause,
  8096. reset,
  8097. current: current2
  8098. } = useCountDown({
  8099. time: +props.time,
  8100. millisecond: props.millisecond,
  8101. onChange: (current22) => emit("change", current22),
  8102. onFinish: () => emit("finish")
  8103. });
  8104. const timeText = vue.computed(() => parseFormat(props.format, current2.value));
  8105. const resetTime = () => {
  8106. reset(+props.time);
  8107. if (props.autoStart) {
  8108. start2();
  8109. }
  8110. };
  8111. vue.watch(() => props.time, resetTime, {
  8112. immediate: true
  8113. });
  8114. useExpose({
  8115. start: start2,
  8116. pause,
  8117. reset: resetTime
  8118. });
  8119. return () => vue.createVNode("div", {
  8120. "role": "timer",
  8121. "class": bem$H()
  8122. }, [slots.default ? slots.default(current2.value) : timeText.value]);
  8123. }
  8124. });
  8125. const CountDown = withInstall(stdin_default$O);
  8126. function getDate(timeStamp) {
  8127. const date = new Date(timeStamp * 1e3);
  8128. return `${date.getFullYear()}.${padZero(date.getMonth() + 1)}.${padZero(
  8129. date.getDate()
  8130. )}`;
  8131. }
  8132. const formatDiscount = (discount) => (discount / 10).toFixed(discount % 10 === 0 ? 0 : 1);
  8133. const formatAmount = (amount) => (amount / 100).toFixed(amount % 100 === 0 ? 0 : amount % 10 === 0 ? 1 : 2);
  8134. const [name$H, bem$G, t$a] = createNamespace("coupon");
  8135. var stdin_default$N = vue.defineComponent({
  8136. name: name$H,
  8137. props: {
  8138. chosen: Boolean,
  8139. coupon: makeRequiredProp(Object),
  8140. disabled: Boolean,
  8141. currency: makeStringProp("\xA5")
  8142. },
  8143. setup(props) {
  8144. const validPeriod = vue.computed(() => {
  8145. const {
  8146. startAt,
  8147. endAt
  8148. } = props.coupon;
  8149. return `${getDate(startAt)} - ${getDate(endAt)}`;
  8150. });
  8151. const faceAmount = vue.computed(() => {
  8152. const {
  8153. coupon,
  8154. currency
  8155. } = props;
  8156. if (coupon.valueDesc) {
  8157. return [coupon.valueDesc, vue.createVNode("span", null, [coupon.unitDesc || ""])];
  8158. }
  8159. if (coupon.denominations) {
  8160. const denominations = formatAmount(coupon.denominations);
  8161. return [vue.createVNode("span", null, [currency]), ` ${denominations}`];
  8162. }
  8163. if (coupon.discount) {
  8164. return t$a("discount", formatDiscount(coupon.discount));
  8165. }
  8166. return "";
  8167. });
  8168. const conditionMessage = vue.computed(() => {
  8169. const condition = formatAmount(props.coupon.originCondition || 0);
  8170. return condition === "0" ? t$a("unlimited") : t$a("condition", condition);
  8171. });
  8172. return () => {
  8173. const {
  8174. chosen,
  8175. coupon,
  8176. disabled
  8177. } = props;
  8178. const description = disabled && coupon.reason || coupon.description;
  8179. return vue.createVNode("div", {
  8180. "class": bem$G({
  8181. disabled
  8182. })
  8183. }, [vue.createVNode("div", {
  8184. "class": bem$G("content")
  8185. }, [vue.createVNode("div", {
  8186. "class": bem$G("head")
  8187. }, [vue.createVNode("h2", {
  8188. "class": bem$G("amount")
  8189. }, [faceAmount.value]), vue.createVNode("p", {
  8190. "class": bem$G("condition")
  8191. }, [coupon.condition || conditionMessage.value])]), vue.createVNode("div", {
  8192. "class": bem$G("body")
  8193. }, [vue.createVNode("p", {
  8194. "class": bem$G("name")
  8195. }, [coupon.name]), vue.createVNode("p", {
  8196. "class": bem$G("valid")
  8197. }, [validPeriod.value]), !disabled && vue.createVNode(Checkbox, {
  8198. "class": bem$G("corner"),
  8199. "modelValue": chosen
  8200. }, null)])]), description && vue.createVNode("p", {
  8201. "class": bem$G("description")
  8202. }, [description])]);
  8203. };
  8204. }
  8205. });
  8206. const Coupon = withInstall(stdin_default$N);
  8207. const [name$G, bem$F, t$9] = createNamespace("coupon-cell");
  8208. const couponCellProps = {
  8209. title: String,
  8210. border: truthProp,
  8211. editable: truthProp,
  8212. coupons: makeArrayProp(),
  8213. currency: makeStringProp("\xA5"),
  8214. chosenCoupon: makeNumericProp(-1)
  8215. };
  8216. function formatValue({
  8217. coupons,
  8218. chosenCoupon,
  8219. currency
  8220. }) {
  8221. const coupon = coupons[+chosenCoupon];
  8222. if (coupon) {
  8223. let value = 0;
  8224. if (isDef(coupon.value)) {
  8225. ({
  8226. value
  8227. } = coupon);
  8228. } else if (isDef(coupon.denominations)) {
  8229. value = coupon.denominations;
  8230. }
  8231. return `-${currency} ${(value / 100).toFixed(2)}`;
  8232. }
  8233. return coupons.length === 0 ? t$9("noCoupon") : t$9("count", coupons.length);
  8234. }
  8235. var stdin_default$M = vue.defineComponent({
  8236. name: name$G,
  8237. props: couponCellProps,
  8238. setup(props) {
  8239. return () => {
  8240. const selected = props.coupons[+props.chosenCoupon];
  8241. return vue.createVNode(Cell, {
  8242. "class": bem$F(),
  8243. "value": formatValue(props),
  8244. "title": props.title || t$9("title"),
  8245. "border": props.border,
  8246. "isLink": props.editable,
  8247. "valueClass": bem$F("value", {
  8248. selected
  8249. })
  8250. }, null);
  8251. };
  8252. }
  8253. });
  8254. const CouponCell = withInstall(stdin_default$M);
  8255. const [name$F, bem$E] = createNamespace("empty");
  8256. const emptyProps = {
  8257. image: makeStringProp("default"),
  8258. imageSize: [Number, String, Array],
  8259. description: String
  8260. };
  8261. var stdin_default$L = vue.defineComponent({
  8262. name: name$F,
  8263. props: emptyProps,
  8264. setup(props, {
  8265. slots
  8266. }) {
  8267. const renderDescription = () => {
  8268. const description = slots.description ? slots.description() : props.description;
  8269. if (description) {
  8270. return vue.createVNode("p", {
  8271. "class": bem$E("description")
  8272. }, [description]);
  8273. }
  8274. };
  8275. const renderBottom = () => {
  8276. if (slots.default) {
  8277. return vue.createVNode("div", {
  8278. "class": bem$E("bottom")
  8279. }, [slots.default()]);
  8280. }
  8281. };
  8282. const baseId = useId();
  8283. const getId = (num) => `${baseId}-${num}`;
  8284. const getUrlById = (num) => `url(#${getId(num)})`;
  8285. const renderStop = (color, offset2, opacity) => vue.createVNode("stop", {
  8286. "stop-color": color,
  8287. "offset": `${offset2}%`,
  8288. "stop-opacity": opacity
  8289. }, null);
  8290. const renderStops = (fromColor, toColor) => [renderStop(fromColor, 0), renderStop(toColor, 100)];
  8291. const renderShadow = (id) => [vue.createVNode("defs", null, [vue.createVNode("radialGradient", {
  8292. "id": getId(id),
  8293. "cx": "50%",
  8294. "cy": "54%",
  8295. "fx": "50%",
  8296. "fy": "54%",
  8297. "r": "297%",
  8298. "gradientTransform": "matrix(-.16 0 0 -.33 .58 .72)"
  8299. }, [renderStop("#EBEDF0", 0), renderStop("#F2F3F5", 100, 0.3)])]), vue.createVNode("ellipse", {
  8300. "fill": getUrlById(id),
  8301. "opacity": ".8",
  8302. "cx": "80",
  8303. "cy": "140",
  8304. "rx": "46",
  8305. "ry": "8"
  8306. }, null)];
  8307. const renderBuilding = () => [vue.createVNode("defs", null, [vue.createVNode("linearGradient", {
  8308. "id": getId("a"),
  8309. "x1": "64%",
  8310. "y1": "100%",
  8311. "x2": "64%"
  8312. }, [renderStop("#FFF", 0, 0.5), renderStop("#F2F3F5", 100)])]), vue.createVNode("g", {
  8313. "opacity": ".8"
  8314. }, [vue.createVNode("path", {
  8315. "d": "M36 131V53H16v20H2v58h34z",
  8316. "fill": getUrlById("a")
  8317. }, null), vue.createVNode("path", {
  8318. "d": "M123 15h22v14h9v77h-31V15z",
  8319. "fill": getUrlById("a")
  8320. }, null)])];
  8321. const renderCloud = () => [vue.createVNode("defs", null, [vue.createVNode("linearGradient", {
  8322. "id": getId("b"),
  8323. "x1": "64%",
  8324. "y1": "97%",
  8325. "x2": "64%",
  8326. "y2": "0%"
  8327. }, [renderStop("#F2F3F5", 0, 0.3), renderStop("#F2F3F5", 100)])]), vue.createVNode("g", {
  8328. "opacity": ".8"
  8329. }, [vue.createVNode("path", {
  8330. "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",
  8331. "fill": getUrlById("b")
  8332. }, null), vue.createVNode("path", {
  8333. "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",
  8334. "fill": getUrlById("b")
  8335. }, null)])];
  8336. const renderNetwork = () => vue.createVNode("svg", {
  8337. "viewBox": "0 0 160 160"
  8338. }, [vue.createVNode("defs", null, [vue.createVNode("linearGradient", {
  8339. "id": getId(1),
  8340. "x1": "64%",
  8341. "y1": "100%",
  8342. "x2": "64%"
  8343. }, [renderStop("#FFF", 0, 0.5), renderStop("#F2F3F5", 100)]), vue.createVNode("linearGradient", {
  8344. "id": getId(2),
  8345. "x1": "50%",
  8346. "x2": "50%",
  8347. "y2": "84%"
  8348. }, [renderStop("#EBEDF0", 0), renderStop("#DCDEE0", 100, 0)]), vue.createVNode("linearGradient", {
  8349. "id": getId(3),
  8350. "x1": "100%",
  8351. "x2": "100%",
  8352. "y2": "100%"
  8353. }, [renderStops("#EAEDF0", "#DCDEE0")]), vue.createVNode("radialGradient", {
  8354. "id": getId(4),
  8355. "cx": "50%",
  8356. "cy": "0%",
  8357. "fx": "50%",
  8358. "fy": "0%",
  8359. "r": "100%",
  8360. "gradientTransform": "matrix(0 1 -.54 0 .5 -.5)"
  8361. }, [renderStop("#EBEDF0", 0), renderStop("#FFF", 100, 0)])]), vue.createVNode("g", {
  8362. "fill": "none"
  8363. }, [renderBuilding(), vue.createVNode("path", {
  8364. "fill": getUrlById(4),
  8365. "d": "M0 139h160v21H0z"
  8366. }, null), vue.createVNode("path", {
  8367. "d": "M80 54a7 7 0 0 1 3 13v27l-2 2h-2a2 2 0 0 1-2-2V67a7 7 0 0 1 3-13z",
  8368. "fill": getUrlById(2)
  8369. }, null), vue.createVNode("g", {
  8370. "opacity": ".6",
  8371. "stroke-linecap": "round",
  8372. "stroke-width": "7"
  8373. }, [vue.createVNode("path", {
  8374. "d": "M64 47a19 19 0 0 0-5 13c0 5 2 10 5 13",
  8375. "stroke": getUrlById(3)
  8376. }, null), vue.createVNode("path", {
  8377. "d": "M53 36a34 34 0 0 0 0 48",
  8378. "stroke": getUrlById(3)
  8379. }, null), vue.createVNode("path", {
  8380. "d": "M95 73a19 19 0 0 0 6-13c0-5-2-9-6-13",
  8381. "stroke": getUrlById(3)
  8382. }, null), vue.createVNode("path", {
  8383. "d": "M106 84a34 34 0 0 0 0-48",
  8384. "stroke": getUrlById(3)
  8385. }, null)]), vue.createVNode("g", {
  8386. "transform": "translate(31 105)"
  8387. }, [vue.createVNode("rect", {
  8388. "fill": "#EBEDF0",
  8389. "width": "98",
  8390. "height": "34",
  8391. "rx": "2"
  8392. }, null), vue.createVNode("rect", {
  8393. "fill": "#FFF",
  8394. "x": "9",
  8395. "y": "8",
  8396. "width": "80",
  8397. "height": "18",
  8398. "rx": "1.1"
  8399. }, null), vue.createVNode("rect", {
  8400. "fill": "#EBEDF0",
  8401. "x": "15",
  8402. "y": "12",
  8403. "width": "18",
  8404. "height": "6",
  8405. "rx": "1.1"
  8406. }, null)])])]);
  8407. const renderMaterial = () => vue.createVNode("svg", {
  8408. "viewBox": "0 0 160 160"
  8409. }, [vue.createVNode("defs", null, [vue.createVNode("linearGradient", {
  8410. "x1": "50%",
  8411. "x2": "50%",
  8412. "y2": "100%",
  8413. "id": getId(5)
  8414. }, [renderStops("#F2F3F5", "#DCDEE0")]), vue.createVNode("linearGradient", {
  8415. "x1": "95%",
  8416. "y1": "48%",
  8417. "x2": "5.5%",
  8418. "y2": "51%",
  8419. "id": getId(6)
  8420. }, [renderStops("#EAEDF1", "#DCDEE0")]), vue.createVNode("linearGradient", {
  8421. "y1": "45%",
  8422. "x2": "100%",
  8423. "y2": "54%",
  8424. "id": getId(7)
  8425. }, [renderStops("#EAEDF1", "#DCDEE0")])]), renderBuilding(), renderCloud(), vue.createVNode("g", {
  8426. "transform": "translate(36 50)",
  8427. "fill": "none"
  8428. }, [vue.createVNode("g", {
  8429. "transform": "translate(8)"
  8430. }, [vue.createVNode("rect", {
  8431. "fill": "#EBEDF0",
  8432. "opacity": ".6",
  8433. "x": "38",
  8434. "y": "13",
  8435. "width": "36",
  8436. "height": "53",
  8437. "rx": "2"
  8438. }, null), vue.createVNode("rect", {
  8439. "fill": getUrlById(5),
  8440. "width": "64",
  8441. "height": "66",
  8442. "rx": "2"
  8443. }, null), vue.createVNode("rect", {
  8444. "fill": "#FFF",
  8445. "x": "6",
  8446. "y": "6",
  8447. "width": "52",
  8448. "height": "55",
  8449. "rx": "1"
  8450. }, null), vue.createVNode("g", {
  8451. "transform": "translate(15 17)",
  8452. "fill": getUrlById(6)
  8453. }, [vue.createVNode("rect", {
  8454. "width": "34",
  8455. "height": "6",
  8456. "rx": "1"
  8457. }, null), vue.createVNode("path", {
  8458. "d": "M0 14h34v6H0z"
  8459. }, null), vue.createVNode("rect", {
  8460. "y": "28",
  8461. "width": "34",
  8462. "height": "6",
  8463. "rx": "1"
  8464. }, null)])]), vue.createVNode("rect", {
  8465. "fill": getUrlById(7),
  8466. "y": "61",
  8467. "width": "88",
  8468. "height": "28",
  8469. "rx": "1"
  8470. }, null), vue.createVNode("rect", {
  8471. "fill": "#F7F8FA",
  8472. "x": "29",
  8473. "y": "72",
  8474. "width": "30",
  8475. "height": "6",
  8476. "rx": "1"
  8477. }, null)])]);
  8478. const renderError = () => vue.createVNode("svg", {
  8479. "viewBox": "0 0 160 160"
  8480. }, [vue.createVNode("defs", null, [vue.createVNode("linearGradient", {
  8481. "x1": "50%",
  8482. "x2": "50%",
  8483. "y2": "100%",
  8484. "id": getId(8)
  8485. }, [renderStops("#EAEDF1", "#DCDEE0")])]), renderBuilding(), renderCloud(), renderShadow("c"), vue.createVNode("path", {
  8486. "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",
  8487. "fill": getUrlById(8)
  8488. }, null)]);
  8489. const renderSearch = () => vue.createVNode("svg", {
  8490. "viewBox": "0 0 160 160"
  8491. }, [vue.createVNode("defs", null, [vue.createVNode("linearGradient", {
  8492. "x1": "50%",
  8493. "y1": "100%",
  8494. "x2": "50%",
  8495. "id": getId(9)
  8496. }, [renderStops("#EEE", "#D8D8D8")]), vue.createVNode("linearGradient", {
  8497. "x1": "100%",
  8498. "y1": "50%",
  8499. "y2": "50%",
  8500. "id": getId(10)
  8501. }, [renderStops("#F2F3F5", "#DCDEE0")]), vue.createVNode("linearGradient", {
  8502. "x1": "50%",
  8503. "x2": "50%",
  8504. "y2": "100%",
  8505. "id": getId(11)
  8506. }, [renderStops("#F2F3F5", "#DCDEE0")]), vue.createVNode("linearGradient", {
  8507. "x1": "50%",
  8508. "x2": "50%",
  8509. "y2": "100%",
  8510. "id": getId(12)
  8511. }, [renderStops("#FFF", "#F7F8FA")])]), renderBuilding(), renderCloud(), renderShadow("d"), vue.createVNode("g", {
  8512. "transform": "rotate(-45 113 -4)",
  8513. "fill": "none"
  8514. }, [vue.createVNode("rect", {
  8515. "fill": getUrlById(9),
  8516. "x": "24",
  8517. "y": "52.8",
  8518. "width": "5.8",
  8519. "height": "19",
  8520. "rx": "1"
  8521. }, null), vue.createVNode("rect", {
  8522. "fill": getUrlById(10),
  8523. "x": "22.1",
  8524. "y": "67.3",
  8525. "width": "9.9",
  8526. "height": "28",
  8527. "rx": "1"
  8528. }, null), vue.createVNode("circle", {
  8529. "stroke": getUrlById(11),
  8530. "stroke-width": "8",
  8531. "cx": "27",
  8532. "cy": "27",
  8533. "r": "27"
  8534. }, null), vue.createVNode("circle", {
  8535. "fill": getUrlById(12),
  8536. "cx": "27",
  8537. "cy": "27",
  8538. "r": "16"
  8539. }, null), vue.createVNode("path", {
  8540. "d": "M37 7c-8 0-15 5-16 12",
  8541. "stroke": getUrlById(11),
  8542. "stroke-width": "3",
  8543. "opacity": ".5",
  8544. "stroke-linecap": "round",
  8545. "transform": "rotate(45 29 13)"
  8546. }, null)])]);
  8547. const renderImage = () => {
  8548. var _a;
  8549. if (slots.image) {
  8550. return slots.image();
  8551. }
  8552. const PRESET_IMAGES = {
  8553. error: renderError,
  8554. search: renderSearch,
  8555. network: renderNetwork,
  8556. default: renderMaterial
  8557. };
  8558. return ((_a = PRESET_IMAGES[props.image]) == null ? void 0 : _a.call(PRESET_IMAGES)) || vue.createVNode("img", {
  8559. "src": props.image
  8560. }, null);
  8561. };
  8562. return () => vue.createVNode("div", {
  8563. "class": bem$E()
  8564. }, [vue.createVNode("div", {
  8565. "class": bem$E("image"),
  8566. "style": getSizeStyle(props.imageSize)
  8567. }, [renderImage()]), renderDescription(), renderBottom()]);
  8568. }
  8569. });
  8570. const Empty = withInstall(stdin_default$L);
  8571. const [name$E, bem$D, t$8] = createNamespace("coupon-list");
  8572. const couponListProps = {
  8573. code: makeStringProp(""),
  8574. coupons: makeArrayProp(),
  8575. currency: makeStringProp("\xA5"),
  8576. showCount: truthProp,
  8577. emptyImage: String,
  8578. chosenCoupon: makeNumberProp(-1),
  8579. enabledTitle: String,
  8580. disabledTitle: String,
  8581. disabledCoupons: makeArrayProp(),
  8582. showExchangeBar: truthProp,
  8583. showCloseButton: truthProp,
  8584. closeButtonText: String,
  8585. inputPlaceholder: String,
  8586. exchangeMinLength: makeNumberProp(1),
  8587. exchangeButtonText: String,
  8588. displayedCouponIndex: makeNumberProp(-1),
  8589. exchangeButtonLoading: Boolean,
  8590. exchangeButtonDisabled: Boolean
  8591. };
  8592. var stdin_default$K = vue.defineComponent({
  8593. name: name$E,
  8594. props: couponListProps,
  8595. emits: ["change", "exchange", "update:code"],
  8596. setup(props, {
  8597. emit,
  8598. slots
  8599. }) {
  8600. const [couponRefs, setCouponRefs] = useRefs();
  8601. const root = vue.ref();
  8602. const barRef = vue.ref();
  8603. const activeTab = vue.ref(0);
  8604. const listHeight = vue.ref(0);
  8605. const currentCode = vue.ref(props.code);
  8606. const buttonDisabled = vue.computed(() => !props.exchangeButtonLoading && (props.exchangeButtonDisabled || !currentCode.value || currentCode.value.length < props.exchangeMinLength));
  8607. const updateListHeight = () => {
  8608. const TABS_HEIGHT = 44;
  8609. const rootHeight = useRect(root).height;
  8610. const headerHeight = useRect(barRef).height + TABS_HEIGHT;
  8611. listHeight.value = (rootHeight > headerHeight ? rootHeight : windowHeight.value) - headerHeight;
  8612. };
  8613. const onExchange = () => {
  8614. emit("exchange", currentCode.value);
  8615. if (!props.code) {
  8616. currentCode.value = "";
  8617. }
  8618. };
  8619. const scrollToCoupon = (index) => {
  8620. vue.nextTick(() => {
  8621. var _a;
  8622. return (_a = couponRefs.value[index]) == null ? void 0 : _a.scrollIntoView();
  8623. });
  8624. };
  8625. const renderEmpty = () => vue.createVNode(Empty, {
  8626. "image": props.emptyImage
  8627. }, {
  8628. default: () => [vue.createVNode("p", {
  8629. "class": bem$D("empty-tip")
  8630. }, [t$8("noCoupon")])]
  8631. });
  8632. const renderExchangeBar = () => {
  8633. if (props.showExchangeBar) {
  8634. return vue.createVNode("div", {
  8635. "ref": barRef,
  8636. "class": bem$D("exchange-bar")
  8637. }, [vue.createVNode(Field, {
  8638. "modelValue": currentCode.value,
  8639. "onUpdate:modelValue": ($event) => currentCode.value = $event,
  8640. "clearable": true,
  8641. "border": false,
  8642. "class": bem$D("field"),
  8643. "placeholder": props.inputPlaceholder || t$8("placeholder"),
  8644. "maxlength": "20"
  8645. }, null), vue.createVNode(Button, {
  8646. "plain": true,
  8647. "type": "danger",
  8648. "class": bem$D("exchange"),
  8649. "text": props.exchangeButtonText || t$8("exchange"),
  8650. "loading": props.exchangeButtonLoading,
  8651. "disabled": buttonDisabled.value,
  8652. "onClick": onExchange
  8653. }, null)]);
  8654. }
  8655. };
  8656. const renderCouponTab = () => {
  8657. const {
  8658. coupons
  8659. } = props;
  8660. const count = props.showCount ? ` (${coupons.length})` : "";
  8661. const title = (props.enabledTitle || t$8("enable")) + count;
  8662. return vue.createVNode(Tab, {
  8663. "title": title
  8664. }, {
  8665. default: () => {
  8666. var _a;
  8667. return [vue.createVNode("div", {
  8668. "class": bem$D("list", {
  8669. "with-bottom": props.showCloseButton
  8670. }),
  8671. "style": {
  8672. height: `${listHeight.value}px`
  8673. }
  8674. }, [coupons.map((coupon, index) => vue.createVNode(Coupon, {
  8675. "key": coupon.id,
  8676. "ref": setCouponRefs(index),
  8677. "coupon": coupon,
  8678. "chosen": index === props.chosenCoupon,
  8679. "currency": props.currency,
  8680. "onClick": () => emit("change", index)
  8681. }, null)), !coupons.length && renderEmpty(), (_a = slots["list-footer"]) == null ? void 0 : _a.call(slots)])];
  8682. }
  8683. });
  8684. };
  8685. const renderDisabledTab = () => {
  8686. const {
  8687. disabledCoupons
  8688. } = props;
  8689. const count = props.showCount ? ` (${disabledCoupons.length})` : "";
  8690. const title = (props.disabledTitle || t$8("disabled")) + count;
  8691. return vue.createVNode(Tab, {
  8692. "title": title
  8693. }, {
  8694. default: () => {
  8695. var _a;
  8696. return [vue.createVNode("div", {
  8697. "class": bem$D("list", {
  8698. "with-bottom": props.showCloseButton
  8699. }),
  8700. "style": {
  8701. height: `${listHeight.value}px`
  8702. }
  8703. }, [disabledCoupons.map((coupon) => vue.createVNode(Coupon, {
  8704. "disabled": true,
  8705. "key": coupon.id,
  8706. "coupon": coupon,
  8707. "currency": props.currency
  8708. }, null)), !disabledCoupons.length && renderEmpty(), (_a = slots["disabled-list-footer"]) == null ? void 0 : _a.call(slots)])];
  8709. }
  8710. });
  8711. };
  8712. vue.watch(() => props.code, (value) => {
  8713. currentCode.value = value;
  8714. });
  8715. vue.watch(windowHeight, updateListHeight);
  8716. vue.watch(currentCode, (value) => emit("update:code", value));
  8717. vue.watch(() => props.displayedCouponIndex, scrollToCoupon);
  8718. vue.onMounted(() => {
  8719. updateListHeight();
  8720. scrollToCoupon(props.displayedCouponIndex);
  8721. });
  8722. return () => vue.createVNode("div", {
  8723. "ref": root,
  8724. "class": bem$D()
  8725. }, [renderExchangeBar(), vue.createVNode(Tabs, {
  8726. "active": activeTab.value,
  8727. "onUpdate:active": ($event) => activeTab.value = $event,
  8728. "class": bem$D("tab")
  8729. }, {
  8730. default: () => [renderCouponTab(), renderDisabledTab()]
  8731. }), vue.createVNode("div", {
  8732. "class": bem$D("bottom")
  8733. }, [vue.withDirectives(vue.createVNode(Button, {
  8734. "round": true,
  8735. "block": true,
  8736. "type": "danger",
  8737. "class": bem$D("close"),
  8738. "text": props.closeButtonText || t$8("close"),
  8739. "onClick": () => emit("change", -1)
  8740. }, null), [[vue.vShow, props.showCloseButton]])])]);
  8741. }
  8742. });
  8743. const CouponList = withInstall(stdin_default$K);
  8744. const [name$D] = createNamespace("time-picker");
  8745. var stdin_default$J = vue.defineComponent({
  8746. name: name$D,
  8747. props: extend({}, sharedProps, {
  8748. minHour: makeNumericProp(0),
  8749. maxHour: makeNumericProp(23),
  8750. minMinute: makeNumericProp(0),
  8751. maxMinute: makeNumericProp(59),
  8752. modelValue: String
  8753. }),
  8754. emits: ["confirm", "cancel", "change", "update:modelValue"],
  8755. setup(props, {
  8756. emit,
  8757. slots
  8758. }) {
  8759. const formatValue2 = (value) => {
  8760. const {
  8761. minHour,
  8762. maxHour,
  8763. maxMinute,
  8764. minMinute
  8765. } = props;
  8766. if (!value) {
  8767. value = `${padZero(minHour)}:${padZero(minMinute)}`;
  8768. }
  8769. let [hour, minute] = value.split(":");
  8770. hour = padZero(clamp(+hour, +minHour, +maxHour));
  8771. minute = padZero(clamp(+minute, +minMinute, +maxMinute));
  8772. return `${hour}:${minute}`;
  8773. };
  8774. const picker = vue.ref();
  8775. const currentDate = vue.ref(formatValue2(props.modelValue));
  8776. const ranges = vue.computed(() => [{
  8777. type: "hour",
  8778. range: [+props.minHour, +props.maxHour]
  8779. }, {
  8780. type: "minute",
  8781. range: [+props.minMinute, +props.maxMinute]
  8782. }]);
  8783. const originColumns = vue.computed(() => ranges.value.map(({
  8784. type,
  8785. range: rangeArr
  8786. }) => {
  8787. let values = times(rangeArr[1] - rangeArr[0] + 1, (index) => padZero(rangeArr[0] + index));
  8788. if (props.filter) {
  8789. values = props.filter(type, values);
  8790. }
  8791. return {
  8792. type,
  8793. values
  8794. };
  8795. }));
  8796. const columns = vue.computed(() => originColumns.value.map((column) => ({
  8797. values: column.values.map((value) => props.formatter(column.type, value))
  8798. })));
  8799. const updateColumnValue = () => {
  8800. const pair = currentDate.value.split(":");
  8801. const values = [props.formatter("hour", pair[0]), props.formatter("minute", pair[1])];
  8802. vue.nextTick(() => {
  8803. var _a;
  8804. (_a = picker.value) == null ? void 0 : _a.setValues(values);
  8805. });
  8806. };
  8807. const updateInnerValue = () => {
  8808. const [hourIndex, minuteIndex] = picker.value.getIndexes();
  8809. const [hourColumn, minuteColumn] = originColumns.value;
  8810. const hour = hourColumn.values[hourIndex] || hourColumn.values[0];
  8811. const minute = minuteColumn.values[minuteIndex] || minuteColumn.values[0];
  8812. currentDate.value = formatValue2(`${hour}:${minute}`);
  8813. updateColumnValue();
  8814. };
  8815. const onConfirm = () => emit("confirm", currentDate.value);
  8816. const onCancel = () => emit("cancel");
  8817. const onChange = () => {
  8818. updateInnerValue();
  8819. vue.nextTick(() => {
  8820. vue.nextTick(() => emit("change", currentDate.value));
  8821. });
  8822. };
  8823. vue.onMounted(() => {
  8824. updateColumnValue();
  8825. vue.nextTick(updateInnerValue);
  8826. });
  8827. vue.watch(columns, updateColumnValue);
  8828. vue.watch(() => [props.filter, props.maxHour, props.minMinute, props.maxMinute], updateInnerValue);
  8829. vue.watch(() => props.minHour, () => {
  8830. vue.nextTick(updateInnerValue);
  8831. });
  8832. vue.watch(currentDate, (value) => emit("update:modelValue", value));
  8833. vue.watch(() => props.modelValue, (value) => {
  8834. value = formatValue2(value);
  8835. if (value !== currentDate.value) {
  8836. currentDate.value = value;
  8837. updateColumnValue();
  8838. }
  8839. });
  8840. useExpose({
  8841. getPicker: () => picker.value && proxyPickerMethods(picker.value, updateInnerValue)
  8842. });
  8843. return () => vue.createVNode(Picker, vue.mergeProps({
  8844. "ref": picker,
  8845. "columns": columns.value,
  8846. "onChange": onChange,
  8847. "onCancel": onCancel,
  8848. "onConfirm": onConfirm
  8849. }, pick(props, pickerInheritKeys)), slots);
  8850. }
  8851. });
  8852. const currentYear = new Date().getFullYear();
  8853. const [name$C] = createNamespace("date-picker");
  8854. var stdin_default$I = vue.defineComponent({
  8855. name: name$C,
  8856. props: extend({}, sharedProps, {
  8857. type: makeStringProp("datetime"),
  8858. modelValue: Date,
  8859. minDate: {
  8860. type: Date,
  8861. default: () => new Date(currentYear - 10, 0, 1),
  8862. validator: isDate
  8863. },
  8864. maxDate: {
  8865. type: Date,
  8866. default: () => new Date(currentYear + 10, 11, 31),
  8867. validator: isDate
  8868. }
  8869. }),
  8870. emits: ["confirm", "cancel", "change", "update:modelValue"],
  8871. setup(props, {
  8872. emit,
  8873. slots
  8874. }) {
  8875. const formatValue2 = (value) => {
  8876. if (isDate(value)) {
  8877. const timestamp = clamp(value.getTime(), props.minDate.getTime(), props.maxDate.getTime());
  8878. return new Date(timestamp);
  8879. }
  8880. return void 0;
  8881. };
  8882. const picker = vue.ref();
  8883. const currentDate = vue.ref(formatValue2(props.modelValue));
  8884. const getBoundary = (type, value) => {
  8885. const boundary = props[`${type}Date`];
  8886. const year = boundary.getFullYear();
  8887. let month = 1;
  8888. let date = 1;
  8889. let hour = 0;
  8890. let minute = 0;
  8891. if (type === "max") {
  8892. month = 12;
  8893. date = getMonthEndDay(value.getFullYear(), value.getMonth() + 1);
  8894. hour = 23;
  8895. minute = 59;
  8896. }
  8897. if (value.getFullYear() === year) {
  8898. month = boundary.getMonth() + 1;
  8899. if (value.getMonth() + 1 === month) {
  8900. date = boundary.getDate();
  8901. if (value.getDate() === date) {
  8902. hour = boundary.getHours();
  8903. if (value.getHours() === hour) {
  8904. minute = boundary.getMinutes();
  8905. }
  8906. }
  8907. }
  8908. }
  8909. return {
  8910. [`${type}Year`]: year,
  8911. [`${type}Month`]: month,
  8912. [`${type}Date`]: date,
  8913. [`${type}Hour`]: hour,
  8914. [`${type}Minute`]: minute
  8915. };
  8916. };
  8917. const ranges = vue.computed(() => {
  8918. const {
  8919. maxYear,
  8920. maxDate,
  8921. maxMonth,
  8922. maxHour,
  8923. maxMinute
  8924. } = getBoundary("max", currentDate.value || props.minDate);
  8925. const {
  8926. minYear,
  8927. minDate,
  8928. minMonth,
  8929. minHour,
  8930. minMinute
  8931. } = getBoundary("min", currentDate.value || props.minDate);
  8932. let result = [{
  8933. type: "year",
  8934. range: [minYear, maxYear]
  8935. }, {
  8936. type: "month",
  8937. range: [minMonth, maxMonth]
  8938. }, {
  8939. type: "day",
  8940. range: [minDate, maxDate]
  8941. }, {
  8942. type: "hour",
  8943. range: [minHour, maxHour]
  8944. }, {
  8945. type: "minute",
  8946. range: [minMinute, maxMinute]
  8947. }];
  8948. switch (props.type) {
  8949. case "date":
  8950. result = result.slice(0, 3);
  8951. break;
  8952. case "year-month":
  8953. result = result.slice(0, 2);
  8954. break;
  8955. case "month-day":
  8956. result = result.slice(1, 3);
  8957. break;
  8958. case "datehour":
  8959. result = result.slice(0, 4);
  8960. break;
  8961. }
  8962. if (props.columnsOrder) {
  8963. const columnsOrder = props.columnsOrder.concat(result.map((column) => column.type));
  8964. result.sort((a, b) => columnsOrder.indexOf(a.type) - columnsOrder.indexOf(b.type));
  8965. }
  8966. return result;
  8967. });
  8968. const originColumns = vue.computed(() => ranges.value.map(({
  8969. type,
  8970. range: rangeArr
  8971. }) => {
  8972. let values = times(rangeArr[1] - rangeArr[0] + 1, (index) => padZero(rangeArr[0] + index));
  8973. if (props.filter) {
  8974. values = props.filter(type, values);
  8975. }
  8976. return {
  8977. type,
  8978. values
  8979. };
  8980. }));
  8981. const columns = vue.computed(() => originColumns.value.map((column) => ({
  8982. values: column.values.map((value) => props.formatter(column.type, value))
  8983. })));
  8984. const updateColumnValue = () => {
  8985. const value = currentDate.value || props.minDate;
  8986. const {
  8987. formatter
  8988. } = props;
  8989. const values = originColumns.value.map((column) => {
  8990. switch (column.type) {
  8991. case "year":
  8992. return formatter("year", `${value.getFullYear()}`);
  8993. case "month":
  8994. return formatter("month", padZero(value.getMonth() + 1));
  8995. case "day":
  8996. return formatter("day", padZero(value.getDate()));
  8997. case "hour":
  8998. return formatter("hour", padZero(value.getHours()));
  8999. case "minute":
  9000. return formatter("minute", padZero(value.getMinutes()));
  9001. default:
  9002. return "";
  9003. }
  9004. });
  9005. vue.nextTick(() => {
  9006. var _a;
  9007. (_a = picker.value) == null ? void 0 : _a.setValues(values);
  9008. });
  9009. };
  9010. const updateInnerValue = () => {
  9011. const {
  9012. type
  9013. } = props;
  9014. const indexes = picker.value.getIndexes();
  9015. const getValue = (type2) => {
  9016. let index = 0;
  9017. originColumns.value.forEach((column, columnIndex) => {
  9018. if (type2 === column.type) {
  9019. index = columnIndex;
  9020. }
  9021. });
  9022. const {
  9023. values
  9024. } = originColumns.value[index];
  9025. return getTrueValue(values[indexes[index]]);
  9026. };
  9027. let year;
  9028. let month;
  9029. let day;
  9030. if (type === "month-day") {
  9031. year = (currentDate.value || props.minDate).getFullYear();
  9032. month = getValue("month");
  9033. day = getValue("day");
  9034. } else {
  9035. year = getValue("year");
  9036. month = getValue("month");
  9037. day = type === "year-month" ? 1 : getValue("day");
  9038. }
  9039. const maxDay = getMonthEndDay(year, month);
  9040. day = day > maxDay ? maxDay : day;
  9041. let hour = 0;
  9042. let minute = 0;
  9043. if (type === "datehour") {
  9044. hour = getValue("hour");
  9045. }
  9046. if (type === "datetime") {
  9047. hour = getValue("hour");
  9048. minute = getValue("minute");
  9049. }
  9050. const value = new Date(year, month - 1, day, hour, minute);
  9051. currentDate.value = formatValue2(value);
  9052. };
  9053. const onConfirm = () => {
  9054. emit("update:modelValue", currentDate.value);
  9055. emit("confirm", currentDate.value);
  9056. };
  9057. const onCancel = () => emit("cancel");
  9058. const onChange = () => {
  9059. updateInnerValue();
  9060. vue.nextTick(() => {
  9061. updateInnerValue();
  9062. vue.nextTick(() => emit("change", currentDate.value));
  9063. });
  9064. };
  9065. vue.onMounted(() => {
  9066. updateColumnValue();
  9067. vue.nextTick(updateInnerValue);
  9068. });
  9069. vue.watch(columns, updateColumnValue);
  9070. vue.watch(currentDate, (value, oldValue) => emit("update:modelValue", oldValue ? value : null));
  9071. vue.watch(() => [props.filter, props.minDate, props.maxDate], () => {
  9072. vue.nextTick(updateInnerValue);
  9073. });
  9074. vue.watch(() => props.modelValue, (value) => {
  9075. var _a;
  9076. value = formatValue2(value);
  9077. if (value && value.valueOf() !== ((_a = currentDate.value) == null ? void 0 : _a.valueOf())) {
  9078. currentDate.value = value;
  9079. }
  9080. });
  9081. useExpose({
  9082. getPicker: () => picker.value && proxyPickerMethods(picker.value, updateInnerValue)
  9083. });
  9084. return () => vue.createVNode(Picker, vue.mergeProps({
  9085. "ref": picker,
  9086. "columns": columns.value,
  9087. "onChange": onChange,
  9088. "onCancel": onCancel,
  9089. "onConfirm": onConfirm
  9090. }, pick(props, pickerInheritKeys)), slots);
  9091. }
  9092. });
  9093. const [name$B, bem$C] = createNamespace("datetime-picker");
  9094. const timePickerPropKeys = Object.keys(stdin_default$J.props);
  9095. const datePickerPropKeys = Object.keys(stdin_default$I.props);
  9096. const datetimePickerProps = extend({}, stdin_default$J.props, stdin_default$I.props, {
  9097. modelValue: [String, Date]
  9098. });
  9099. var stdin_default$H = vue.defineComponent({
  9100. name: name$B,
  9101. props: datetimePickerProps,
  9102. setup(props, {
  9103. attrs,
  9104. slots
  9105. }) {
  9106. const root = vue.ref();
  9107. useExpose({
  9108. getPicker: () => {
  9109. var _a;
  9110. return (_a = root.value) == null ? void 0 : _a.getPicker();
  9111. }
  9112. });
  9113. return () => {
  9114. const isTimePicker = props.type === "time";
  9115. const Component = isTimePicker ? stdin_default$J : stdin_default$I;
  9116. const inheritProps = pick(props, isTimePicker ? timePickerPropKeys : datePickerPropKeys);
  9117. return vue.createVNode(Component, vue.mergeProps({
  9118. "ref": root,
  9119. "class": bem$C()
  9120. }, inheritProps, attrs), slots);
  9121. };
  9122. }
  9123. });
  9124. const DatetimePicker = withInstall(stdin_default$H);
  9125. const [name$A, bem$B, t$7] = createNamespace("dialog");
  9126. const dialogProps = extend({}, popupSharedProps, {
  9127. title: String,
  9128. theme: String,
  9129. width: numericProp,
  9130. message: [String, Function],
  9131. callback: Function,
  9132. allowHtml: Boolean,
  9133. className: unknownProp,
  9134. transition: makeStringProp("van-dialog-bounce"),
  9135. messageAlign: String,
  9136. closeOnPopstate: truthProp,
  9137. showCancelButton: Boolean,
  9138. cancelButtonText: String,
  9139. cancelButtonColor: String,
  9140. cancelButtonDisabled: Boolean,
  9141. confirmButtonText: String,
  9142. confirmButtonColor: String,
  9143. confirmButtonDisabled: Boolean,
  9144. showConfirmButton: truthProp,
  9145. closeOnClickOverlay: Boolean
  9146. });
  9147. const popupInheritKeys$1 = [...popupSharedPropKeys, "transition", "closeOnPopstate"];
  9148. var stdin_default$G = vue.defineComponent({
  9149. name: name$A,
  9150. props: dialogProps,
  9151. emits: ["confirm", "cancel", "keydown", "update:show"],
  9152. setup(props, {
  9153. emit,
  9154. slots
  9155. }) {
  9156. const root = vue.ref();
  9157. const loading = vue.reactive({
  9158. confirm: false,
  9159. cancel: false
  9160. });
  9161. const updateShow = (value) => emit("update:show", value);
  9162. const close = (action) => {
  9163. var _a;
  9164. updateShow(false);
  9165. (_a = props.callback) == null ? void 0 : _a.call(props, action);
  9166. };
  9167. const getActionHandler = (action) => () => {
  9168. if (!props.show) {
  9169. return;
  9170. }
  9171. emit(action);
  9172. if (props.beforeClose) {
  9173. loading[action] = true;
  9174. callInterceptor(props.beforeClose, {
  9175. args: [action],
  9176. done() {
  9177. close(action);
  9178. loading[action] = false;
  9179. },
  9180. canceled() {
  9181. loading[action] = false;
  9182. }
  9183. });
  9184. } else {
  9185. close(action);
  9186. }
  9187. };
  9188. const onCancel = getActionHandler("cancel");
  9189. const onConfirm = getActionHandler("confirm");
  9190. const onKeydown = vue.withKeys((event) => {
  9191. var _a, _b;
  9192. if (event.target !== ((_b = (_a = root.value) == null ? void 0 : _a.popupRef) == null ? void 0 : _b.value)) {
  9193. return;
  9194. }
  9195. const onEventType = {
  9196. Enter: props.showConfirmButton ? onConfirm : noop,
  9197. Escape: props.showCancelButton ? onCancel : noop
  9198. };
  9199. onEventType[event.key]();
  9200. emit("keydown", event);
  9201. }, ["enter", "esc"]);
  9202. const renderTitle = () => {
  9203. const title = slots.title ? slots.title() : props.title;
  9204. if (title) {
  9205. return vue.createVNode("div", {
  9206. "class": bem$B("header", {
  9207. isolated: !props.message && !slots.default
  9208. })
  9209. }, [title]);
  9210. }
  9211. };
  9212. const renderMessage = (hasTitle) => {
  9213. const {
  9214. message,
  9215. allowHtml,
  9216. messageAlign
  9217. } = props;
  9218. const classNames = bem$B("message", {
  9219. "has-title": hasTitle,
  9220. [messageAlign]: messageAlign
  9221. });
  9222. const content = isFunction(message) ? message() : message;
  9223. if (allowHtml && typeof content === "string") {
  9224. return vue.createVNode("div", {
  9225. "class": classNames,
  9226. "innerHTML": content
  9227. }, null);
  9228. }
  9229. return vue.createVNode("div", {
  9230. "class": classNames
  9231. }, [content]);
  9232. };
  9233. const renderContent = () => {
  9234. if (slots.default) {
  9235. return vue.createVNode("div", {
  9236. "class": bem$B("content")
  9237. }, [slots.default()]);
  9238. }
  9239. const {
  9240. title,
  9241. message,
  9242. allowHtml
  9243. } = props;
  9244. if (message) {
  9245. const hasTitle = !!(title || slots.title);
  9246. return vue.createVNode("div", {
  9247. "key": allowHtml ? 1 : 0,
  9248. "class": bem$B("content", {
  9249. isolated: !hasTitle
  9250. })
  9251. }, [renderMessage(hasTitle)]);
  9252. }
  9253. };
  9254. const renderButtons = () => vue.createVNode("div", {
  9255. "class": [BORDER_TOP, bem$B("footer")]
  9256. }, [props.showCancelButton && vue.createVNode(Button, {
  9257. "size": "large",
  9258. "text": props.cancelButtonText || t$7("cancel"),
  9259. "class": bem$B("cancel"),
  9260. "style": {
  9261. color: props.cancelButtonColor
  9262. },
  9263. "loading": loading.cancel,
  9264. "disabled": props.cancelButtonDisabled,
  9265. "onClick": onCancel
  9266. }, null), props.showConfirmButton && vue.createVNode(Button, {
  9267. "size": "large",
  9268. "text": props.confirmButtonText || t$7("confirm"),
  9269. "class": [bem$B("confirm"), {
  9270. [BORDER_LEFT]: props.showCancelButton
  9271. }],
  9272. "style": {
  9273. color: props.confirmButtonColor
  9274. },
  9275. "loading": loading.confirm,
  9276. "disabled": props.confirmButtonDisabled,
  9277. "onClick": onConfirm
  9278. }, null)]);
  9279. const renderRoundButtons = () => vue.createVNode(ActionBar, {
  9280. "class": bem$B("footer")
  9281. }, {
  9282. default: () => [props.showCancelButton && vue.createVNode(ActionBarButton, {
  9283. "type": "warning",
  9284. "text": props.cancelButtonText || t$7("cancel"),
  9285. "class": bem$B("cancel"),
  9286. "color": props.cancelButtonColor,
  9287. "loading": loading.cancel,
  9288. "disabled": props.cancelButtonDisabled,
  9289. "onClick": onCancel
  9290. }, null), props.showConfirmButton && vue.createVNode(ActionBarButton, {
  9291. "type": "danger",
  9292. "text": props.confirmButtonText || t$7("confirm"),
  9293. "class": bem$B("confirm"),
  9294. "color": props.confirmButtonColor,
  9295. "loading": loading.confirm,
  9296. "disabled": props.confirmButtonDisabled,
  9297. "onClick": onConfirm
  9298. }, null)]
  9299. });
  9300. const renderFooter = () => {
  9301. if (slots.footer) {
  9302. return slots.footer();
  9303. }
  9304. return props.theme === "round-button" ? renderRoundButtons() : renderButtons();
  9305. };
  9306. return () => {
  9307. const {
  9308. width: width2,
  9309. title,
  9310. theme,
  9311. message,
  9312. className
  9313. } = props;
  9314. return vue.createVNode(Popup, vue.mergeProps({
  9315. "ref": root,
  9316. "role": "dialog",
  9317. "class": [bem$B([theme]), className],
  9318. "style": {
  9319. width: addUnit(width2)
  9320. },
  9321. "tabindex": 0,
  9322. "aria-labelledby": title || message,
  9323. "onKeydown": onKeydown,
  9324. "onUpdate:show": updateShow
  9325. }, pick(props, popupInheritKeys$1)), {
  9326. default: () => [renderTitle(), renderContent(), renderFooter()]
  9327. });
  9328. };
  9329. }
  9330. });
  9331. let instance$2;
  9332. function initInstance$2() {
  9333. const Wrapper = {
  9334. setup() {
  9335. const {
  9336. state,
  9337. toggle
  9338. } = usePopupState();
  9339. return () => vue.createVNode(stdin_default$G, vue.mergeProps(state, {
  9340. "onUpdate:show": toggle
  9341. }), null);
  9342. }
  9343. };
  9344. ({
  9345. instance: instance$2
  9346. } = mountComponent(Wrapper));
  9347. }
  9348. function Dialog(options) {
  9349. if (!inBrowser$1) {
  9350. return Promise.resolve();
  9351. }
  9352. return new Promise((resolve, reject) => {
  9353. if (!instance$2) {
  9354. initInstance$2();
  9355. }
  9356. instance$2.open(extend({}, Dialog.currentOptions, options, {
  9357. callback: (action) => {
  9358. (action === "confirm" ? resolve : reject)(action);
  9359. }
  9360. }));
  9361. });
  9362. }
  9363. Dialog.defaultOptions = {
  9364. title: "",
  9365. width: "",
  9366. theme: null,
  9367. message: "",
  9368. overlay: true,
  9369. callback: null,
  9370. teleport: "body",
  9371. className: "",
  9372. allowHtml: false,
  9373. lockScroll: true,
  9374. transition: void 0,
  9375. beforeClose: null,
  9376. overlayClass: "",
  9377. overlayStyle: void 0,
  9378. messageAlign: "",
  9379. cancelButtonText: "",
  9380. cancelButtonColor: null,
  9381. cancelButtonDisabled: false,
  9382. confirmButtonText: "",
  9383. confirmButtonColor: null,
  9384. confirmButtonDisabled: false,
  9385. showConfirmButton: true,
  9386. showCancelButton: false,
  9387. closeOnPopstate: true,
  9388. closeOnClickOverlay: false
  9389. };
  9390. Dialog.currentOptions = extend({}, Dialog.defaultOptions);
  9391. Dialog.alert = Dialog;
  9392. Dialog.confirm = (options) => Dialog(extend({
  9393. showCancelButton: true
  9394. }, options));
  9395. Dialog.close = () => {
  9396. if (instance$2) {
  9397. instance$2.toggle(false);
  9398. }
  9399. };
  9400. Dialog.setDefaultOptions = (options) => {
  9401. extend(Dialog.currentOptions, options);
  9402. };
  9403. Dialog.resetDefaultOptions = () => {
  9404. Dialog.currentOptions = extend({}, Dialog.defaultOptions);
  9405. };
  9406. Dialog.Component = withInstall(stdin_default$G);
  9407. Dialog.install = (app) => {
  9408. app.use(Dialog.Component);
  9409. app.config.globalProperties.$dialog = Dialog;
  9410. };
  9411. const [name$z, bem$A] = createNamespace("divider");
  9412. const dividerProps = {
  9413. dashed: Boolean,
  9414. hairline: truthProp,
  9415. contentPosition: makeStringProp("center")
  9416. };
  9417. var stdin_default$F = vue.defineComponent({
  9418. name: name$z,
  9419. props: dividerProps,
  9420. setup(props, {
  9421. slots
  9422. }) {
  9423. return () => {
  9424. var _a;
  9425. return vue.createVNode("div", {
  9426. "role": "separator",
  9427. "class": bem$A({
  9428. dashed: props.dashed,
  9429. hairline: props.hairline,
  9430. [`content-${props.contentPosition}`]: !!slots.default
  9431. })
  9432. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  9433. };
  9434. }
  9435. });
  9436. const Divider = withInstall(stdin_default$F);
  9437. const [name$y, bem$z] = createNamespace("dropdown-menu");
  9438. const dropdownMenuProps = {
  9439. overlay: truthProp,
  9440. zIndex: numericProp,
  9441. duration: makeNumericProp(0.2),
  9442. direction: makeStringProp("down"),
  9443. activeColor: String,
  9444. closeOnClickOutside: truthProp,
  9445. closeOnClickOverlay: truthProp
  9446. };
  9447. const DROPDOWN_KEY = Symbol(name$y);
  9448. var stdin_default$E = vue.defineComponent({
  9449. name: name$y,
  9450. props: dropdownMenuProps,
  9451. setup(props, {
  9452. slots
  9453. }) {
  9454. const id = useId();
  9455. const root = vue.ref();
  9456. const barRef = vue.ref();
  9457. const offset2 = vue.ref(0);
  9458. const {
  9459. children,
  9460. linkChildren
  9461. } = useChildren(DROPDOWN_KEY);
  9462. const scrollParent = useScrollParent(root);
  9463. const opened = vue.computed(() => children.some((item) => item.state.showWrapper));
  9464. const barStyle = vue.computed(() => {
  9465. if (opened.value && isDef(props.zIndex)) {
  9466. return {
  9467. zIndex: +props.zIndex + 1
  9468. };
  9469. }
  9470. });
  9471. const onClickAway = () => {
  9472. if (props.closeOnClickOutside) {
  9473. children.forEach((item) => {
  9474. item.toggle(false);
  9475. });
  9476. }
  9477. };
  9478. const updateOffset = () => {
  9479. if (barRef.value) {
  9480. const rect = useRect(barRef);
  9481. if (props.direction === "down") {
  9482. offset2.value = rect.bottom;
  9483. } else {
  9484. offset2.value = windowHeight.value - rect.top;
  9485. }
  9486. }
  9487. };
  9488. const onScroll = () => {
  9489. if (opened.value) {
  9490. updateOffset();
  9491. }
  9492. };
  9493. const toggleItem = (active) => {
  9494. children.forEach((item, index) => {
  9495. if (index === active) {
  9496. updateOffset();
  9497. item.toggle();
  9498. } else if (item.state.showPopup) {
  9499. item.toggle(false, {
  9500. immediate: true
  9501. });
  9502. }
  9503. });
  9504. };
  9505. const renderTitle = (item, index) => {
  9506. const {
  9507. showPopup
  9508. } = item.state;
  9509. const {
  9510. disabled,
  9511. titleClass
  9512. } = item;
  9513. return vue.createVNode("div", {
  9514. "id": `${id}-${index}`,
  9515. "role": "button",
  9516. "tabindex": disabled ? void 0 : 0,
  9517. "class": [bem$z("item", {
  9518. disabled
  9519. }), {
  9520. [HAPTICS_FEEDBACK]: !disabled
  9521. }],
  9522. "onClick": () => {
  9523. if (!disabled) {
  9524. toggleItem(index);
  9525. }
  9526. }
  9527. }, [vue.createVNode("span", {
  9528. "class": [bem$z("title", {
  9529. down: showPopup === (props.direction === "down"),
  9530. active: showPopup
  9531. }), titleClass],
  9532. "style": {
  9533. color: showPopup ? props.activeColor : ""
  9534. }
  9535. }, [vue.createVNode("div", {
  9536. "class": "van-ellipsis"
  9537. }, [item.renderTitle()])])]);
  9538. };
  9539. linkChildren({
  9540. id,
  9541. props,
  9542. offset: offset2
  9543. });
  9544. useClickAway(root, onClickAway);
  9545. useEventListener("scroll", onScroll, {
  9546. target: scrollParent,
  9547. passive: true
  9548. });
  9549. return () => {
  9550. var _a;
  9551. return vue.createVNode("div", {
  9552. "ref": root,
  9553. "class": bem$z()
  9554. }, [vue.createVNode("div", {
  9555. "ref": barRef,
  9556. "style": barStyle.value,
  9557. "class": bem$z("bar", {
  9558. opened: opened.value
  9559. })
  9560. }, [children.map(renderTitle)]), (_a = slots.default) == null ? void 0 : _a.call(slots)]);
  9561. };
  9562. }
  9563. });
  9564. const [name$x, bem$y] = createNamespace("dropdown-item");
  9565. const dropdownItemProps = {
  9566. title: String,
  9567. options: makeArrayProp(),
  9568. disabled: Boolean,
  9569. teleport: [String, Object],
  9570. lazyRender: truthProp,
  9571. modelValue: unknownProp,
  9572. titleClass: unknownProp
  9573. };
  9574. var stdin_default$D = vue.defineComponent({
  9575. name: name$x,
  9576. props: dropdownItemProps,
  9577. emits: ["open", "opened", "close", "closed", "change", "update:modelValue"],
  9578. setup(props, {
  9579. emit,
  9580. slots
  9581. }) {
  9582. const state = vue.reactive({
  9583. showPopup: false,
  9584. transition: true,
  9585. showWrapper: false
  9586. });
  9587. const {
  9588. parent,
  9589. index
  9590. } = useParent(DROPDOWN_KEY);
  9591. if (!parent) {
  9592. return;
  9593. }
  9594. const getEmitter = (name2) => () => emit(name2);
  9595. const onOpen = getEmitter("open");
  9596. const onClose = getEmitter("close");
  9597. const onOpened = getEmitter("opened");
  9598. const onClosed = () => {
  9599. state.showWrapper = false;
  9600. emit("closed");
  9601. };
  9602. const onClickWrapper = (event) => {
  9603. if (props.teleport) {
  9604. event.stopPropagation();
  9605. }
  9606. };
  9607. const toggle = (show = !state.showPopup, options = {}) => {
  9608. if (show === state.showPopup) {
  9609. return;
  9610. }
  9611. state.showPopup = show;
  9612. state.transition = !options.immediate;
  9613. if (show) {
  9614. state.showWrapper = true;
  9615. }
  9616. };
  9617. const renderTitle = () => {
  9618. if (slots.title) {
  9619. return slots.title();
  9620. }
  9621. if (props.title) {
  9622. return props.title;
  9623. }
  9624. const match = props.options.find((option) => option.value === props.modelValue);
  9625. return match ? match.text : "";
  9626. };
  9627. const renderOption = (option) => {
  9628. const {
  9629. activeColor
  9630. } = parent.props;
  9631. const active = option.value === props.modelValue;
  9632. const onClick = () => {
  9633. state.showPopup = false;
  9634. if (option.value !== props.modelValue) {
  9635. emit("update:modelValue", option.value);
  9636. emit("change", option.value);
  9637. }
  9638. };
  9639. const renderIcon = () => {
  9640. if (active) {
  9641. return vue.createVNode(Icon, {
  9642. "class": bem$y("icon"),
  9643. "color": activeColor,
  9644. "name": "success"
  9645. }, null);
  9646. }
  9647. };
  9648. return vue.createVNode(Cell, {
  9649. "role": "menuitem",
  9650. "key": option.value,
  9651. "icon": option.icon,
  9652. "title": option.text,
  9653. "class": bem$y("option", {
  9654. active
  9655. }),
  9656. "style": {
  9657. color: active ? activeColor : ""
  9658. },
  9659. "tabindex": active ? 0 : -1,
  9660. "clickable": true,
  9661. "onClick": onClick
  9662. }, {
  9663. value: renderIcon
  9664. });
  9665. };
  9666. const renderContent = () => {
  9667. const {
  9668. offset: offset2
  9669. } = parent;
  9670. const {
  9671. zIndex,
  9672. overlay,
  9673. duration,
  9674. direction,
  9675. closeOnClickOverlay
  9676. } = parent.props;
  9677. const style = getZIndexStyle(zIndex);
  9678. if (direction === "down") {
  9679. style.top = `${offset2.value}px`;
  9680. } else {
  9681. style.bottom = `${offset2.value}px`;
  9682. }
  9683. return vue.withDirectives(vue.createVNode("div", {
  9684. "style": style,
  9685. "class": bem$y([direction]),
  9686. "onClick": onClickWrapper
  9687. }, [vue.createVNode(Popup, {
  9688. "show": state.showPopup,
  9689. "onUpdate:show": ($event) => state.showPopup = $event,
  9690. "role": "menu",
  9691. "class": bem$y("content"),
  9692. "overlay": overlay,
  9693. "position": direction === "down" ? "top" : "bottom",
  9694. "duration": state.transition ? duration : 0,
  9695. "lazyRender": props.lazyRender,
  9696. "overlayStyle": {
  9697. position: "absolute"
  9698. },
  9699. "aria-labelledby": `${parent.id}-${index.value}`,
  9700. "closeOnClickOverlay": closeOnClickOverlay,
  9701. "onOpen": onOpen,
  9702. "onClose": onClose,
  9703. "onOpened": onOpened,
  9704. "onClosed": onClosed
  9705. }, {
  9706. default: () => {
  9707. var _a;
  9708. return [props.options.map(renderOption), (_a = slots.default) == null ? void 0 : _a.call(slots)];
  9709. }
  9710. })]), [[vue.vShow, state.showWrapper]]);
  9711. };
  9712. useExpose({
  9713. state,
  9714. toggle,
  9715. renderTitle
  9716. });
  9717. return () => {
  9718. if (props.teleport) {
  9719. return vue.createVNode(vue.Teleport, {
  9720. "to": props.teleport
  9721. }, {
  9722. default: () => [renderContent()]
  9723. });
  9724. }
  9725. return renderContent();
  9726. };
  9727. }
  9728. });
  9729. const DropdownItem = withInstall(stdin_default$D);
  9730. const DropdownMenu = withInstall(stdin_default$E);
  9731. const [name$w, bem$x] = createNamespace("grid");
  9732. const gridProps = {
  9733. square: Boolean,
  9734. center: truthProp,
  9735. border: truthProp,
  9736. gutter: numericProp,
  9737. reverse: Boolean,
  9738. iconSize: numericProp,
  9739. direction: String,
  9740. clickable: Boolean,
  9741. columnNum: makeNumericProp(4)
  9742. };
  9743. const GRID_KEY = Symbol(name$w);
  9744. var stdin_default$C = vue.defineComponent({
  9745. name: name$w,
  9746. props: gridProps,
  9747. setup(props, {
  9748. slots
  9749. }) {
  9750. const {
  9751. linkChildren
  9752. } = useChildren(GRID_KEY);
  9753. linkChildren({
  9754. props
  9755. });
  9756. return () => {
  9757. var _a;
  9758. return vue.createVNode("div", {
  9759. "style": {
  9760. paddingLeft: addUnit(props.gutter)
  9761. },
  9762. "class": [bem$x(), {
  9763. [BORDER_TOP]: props.border && !props.gutter
  9764. }]
  9765. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  9766. };
  9767. }
  9768. });
  9769. const Grid = withInstall(stdin_default$C);
  9770. const [name$v, bem$w] = createNamespace("grid-item");
  9771. const gridItemProps = extend({}, routeProps, {
  9772. dot: Boolean,
  9773. text: String,
  9774. icon: String,
  9775. badge: numericProp,
  9776. iconColor: String,
  9777. iconPrefix: String,
  9778. badgeProps: Object
  9779. });
  9780. var stdin_default$B = vue.defineComponent({
  9781. name: name$v,
  9782. props: gridItemProps,
  9783. setup(props, {
  9784. slots
  9785. }) {
  9786. const {
  9787. parent,
  9788. index
  9789. } = useParent(GRID_KEY);
  9790. const route2 = useRoute();
  9791. if (!parent) {
  9792. return;
  9793. }
  9794. const rootStyle = vue.computed(() => {
  9795. const {
  9796. square,
  9797. gutter,
  9798. columnNum
  9799. } = parent.props;
  9800. const percent = `${100 / +columnNum}%`;
  9801. const style = {
  9802. flexBasis: percent
  9803. };
  9804. if (square) {
  9805. style.paddingTop = percent;
  9806. } else if (gutter) {
  9807. const gutterValue = addUnit(gutter);
  9808. style.paddingRight = gutterValue;
  9809. if (index.value >= columnNum) {
  9810. style.marginTop = gutterValue;
  9811. }
  9812. }
  9813. return style;
  9814. });
  9815. const contentStyle = vue.computed(() => {
  9816. const {
  9817. square,
  9818. gutter
  9819. } = parent.props;
  9820. if (square && gutter) {
  9821. const gutterValue = addUnit(gutter);
  9822. return {
  9823. right: gutterValue,
  9824. bottom: gutterValue,
  9825. height: "auto"
  9826. };
  9827. }
  9828. });
  9829. const renderIcon = () => {
  9830. if (slots.icon) {
  9831. return vue.createVNode(Badge, vue.mergeProps({
  9832. "dot": props.dot,
  9833. "content": props.badge
  9834. }, props.badgeProps), {
  9835. default: slots.icon
  9836. });
  9837. }
  9838. if (props.icon) {
  9839. return vue.createVNode(Icon, {
  9840. "dot": props.dot,
  9841. "name": props.icon,
  9842. "size": parent.props.iconSize,
  9843. "badge": props.badge,
  9844. "class": bem$w("icon"),
  9845. "color": props.iconColor,
  9846. "badgeProps": props.badgeProps,
  9847. "classPrefix": props.iconPrefix
  9848. }, null);
  9849. }
  9850. };
  9851. const renderText = () => {
  9852. if (slots.text) {
  9853. return slots.text();
  9854. }
  9855. if (props.text) {
  9856. return vue.createVNode("span", {
  9857. "class": bem$w("text")
  9858. }, [props.text]);
  9859. }
  9860. };
  9861. const renderContent = () => {
  9862. if (slots.default) {
  9863. return slots.default();
  9864. }
  9865. return [renderIcon(), renderText()];
  9866. };
  9867. return () => {
  9868. const {
  9869. center,
  9870. border,
  9871. square,
  9872. gutter,
  9873. reverse,
  9874. direction,
  9875. clickable
  9876. } = parent.props;
  9877. const classes = [bem$w("content", [direction, {
  9878. center,
  9879. square,
  9880. reverse,
  9881. clickable,
  9882. surround: border && gutter
  9883. }]), {
  9884. [BORDER]: border
  9885. }];
  9886. return vue.createVNode("div", {
  9887. "class": [bem$w({
  9888. square
  9889. })],
  9890. "style": rootStyle.value
  9891. }, [vue.createVNode("div", {
  9892. "role": clickable ? "button" : void 0,
  9893. "class": classes,
  9894. "style": contentStyle.value,
  9895. "tabindex": clickable ? 0 : void 0,
  9896. "onClick": route2
  9897. }, [renderContent()])]);
  9898. };
  9899. }
  9900. });
  9901. const GridItem = withInstall(stdin_default$B);
  9902. const getDistance = (touches) => Math.sqrt((touches[0].clientX - touches[1].clientX) ** 2 + (touches[0].clientY - touches[1].clientY) ** 2);
  9903. const bem$v = createNamespace("image-preview")[1];
  9904. var stdin_default$A = vue.defineComponent({
  9905. props: {
  9906. src: String,
  9907. show: Boolean,
  9908. active: Number,
  9909. minZoom: makeRequiredProp(numericProp),
  9910. maxZoom: makeRequiredProp(numericProp),
  9911. rootWidth: makeRequiredProp(Number),
  9912. rootHeight: makeRequiredProp(Number)
  9913. },
  9914. emits: ["scale", "close"],
  9915. setup(props, {
  9916. emit
  9917. }) {
  9918. const state = vue.reactive({
  9919. scale: 1,
  9920. moveX: 0,
  9921. moveY: 0,
  9922. moving: false,
  9923. zooming: false,
  9924. imageRatio: 0,
  9925. displayWidth: 0,
  9926. displayHeight: 0
  9927. });
  9928. const touch = useTouch();
  9929. const swipeItem = vue.ref();
  9930. const vertical = vue.computed(() => {
  9931. const {
  9932. rootWidth,
  9933. rootHeight
  9934. } = props;
  9935. const rootRatio = rootHeight / rootWidth;
  9936. return state.imageRatio > rootRatio;
  9937. });
  9938. const imageStyle = vue.computed(() => {
  9939. const {
  9940. scale,
  9941. moveX,
  9942. moveY,
  9943. moving,
  9944. zooming
  9945. } = state;
  9946. const style = {
  9947. transitionDuration: zooming || moving ? "0s" : ".3s"
  9948. };
  9949. if (scale !== 1) {
  9950. const offsetX = moveX / scale;
  9951. const offsetY = moveY / scale;
  9952. style.transform = `scale(${scale}, ${scale}) translate(${offsetX}px, ${offsetY}px)`;
  9953. }
  9954. return style;
  9955. });
  9956. const maxMoveX = vue.computed(() => {
  9957. if (state.imageRatio) {
  9958. const {
  9959. rootWidth,
  9960. rootHeight
  9961. } = props;
  9962. const displayWidth = vertical.value ? rootHeight / state.imageRatio : rootWidth;
  9963. return Math.max(0, (state.scale * displayWidth - rootWidth) / 2);
  9964. }
  9965. return 0;
  9966. });
  9967. const maxMoveY = vue.computed(() => {
  9968. if (state.imageRatio) {
  9969. const {
  9970. rootWidth,
  9971. rootHeight
  9972. } = props;
  9973. const displayHeight = vertical.value ? rootHeight : rootWidth * state.imageRatio;
  9974. return Math.max(0, (state.scale * displayHeight - rootHeight) / 2);
  9975. }
  9976. return 0;
  9977. });
  9978. const setScale = (scale) => {
  9979. scale = clamp(scale, +props.minZoom, +props.maxZoom + 1);
  9980. if (scale !== state.scale) {
  9981. state.scale = scale;
  9982. emit("scale", {
  9983. scale,
  9984. index: props.active
  9985. });
  9986. }
  9987. };
  9988. const resetScale = () => {
  9989. setScale(1);
  9990. state.moveX = 0;
  9991. state.moveY = 0;
  9992. };
  9993. const toggleScale = () => {
  9994. const scale = state.scale > 1 ? 1 : 2;
  9995. setScale(scale);
  9996. state.moveX = 0;
  9997. state.moveY = 0;
  9998. };
  9999. let fingerNum;
  10000. let startMoveX;
  10001. let startMoveY;
  10002. let startScale;
  10003. let startDistance;
  10004. let doubleTapTimer;
  10005. let touchStartTime;
  10006. const onTouchStart = (event) => {
  10007. const {
  10008. touches
  10009. } = event;
  10010. const {
  10011. offsetX
  10012. } = touch;
  10013. touch.start(event);
  10014. fingerNum = touches.length;
  10015. startMoveX = state.moveX;
  10016. startMoveY = state.moveY;
  10017. touchStartTime = Date.now();
  10018. state.moving = fingerNum === 1 && state.scale !== 1;
  10019. state.zooming = fingerNum === 2 && !offsetX.value;
  10020. if (state.zooming) {
  10021. startScale = state.scale;
  10022. startDistance = getDistance(event.touches);
  10023. }
  10024. };
  10025. const onTouchMove = (event) => {
  10026. const {
  10027. touches
  10028. } = event;
  10029. touch.move(event);
  10030. if (state.moving || state.zooming) {
  10031. preventDefault(event, true);
  10032. }
  10033. if (state.moving) {
  10034. const {
  10035. deltaX,
  10036. deltaY
  10037. } = touch;
  10038. const moveX = deltaX.value + startMoveX;
  10039. const moveY = deltaY.value + startMoveY;
  10040. state.moveX = clamp(moveX, -maxMoveX.value, maxMoveX.value);
  10041. state.moveY = clamp(moveY, -maxMoveY.value, maxMoveY.value);
  10042. }
  10043. if (state.zooming && touches.length === 2) {
  10044. const distance = getDistance(touches);
  10045. const scale = startScale * distance / startDistance;
  10046. setScale(scale);
  10047. }
  10048. };
  10049. const checkTap = () => {
  10050. if (fingerNum > 1) {
  10051. return;
  10052. }
  10053. const {
  10054. offsetX,
  10055. offsetY
  10056. } = touch;
  10057. const deltaTime = Date.now() - touchStartTime;
  10058. const TAP_TIME = 250;
  10059. const TAP_OFFSET = 5;
  10060. if (offsetX.value < TAP_OFFSET && offsetY.value < TAP_OFFSET && deltaTime < TAP_TIME) {
  10061. if (doubleTapTimer) {
  10062. clearTimeout(doubleTapTimer);
  10063. doubleTapTimer = null;
  10064. toggleScale();
  10065. } else {
  10066. doubleTapTimer = setTimeout(() => {
  10067. emit("close");
  10068. doubleTapTimer = null;
  10069. }, TAP_TIME);
  10070. }
  10071. }
  10072. };
  10073. const onTouchEnd = (event) => {
  10074. let stopPropagation2 = false;
  10075. if (state.moving || state.zooming) {
  10076. stopPropagation2 = true;
  10077. if (state.moving && startMoveX === state.moveX && startMoveY === state.moveY) {
  10078. stopPropagation2 = false;
  10079. }
  10080. if (!event.touches.length) {
  10081. if (state.zooming) {
  10082. state.moveX = clamp(state.moveX, -maxMoveX.value, maxMoveX.value);
  10083. state.moveY = clamp(state.moveY, -maxMoveY.value, maxMoveY.value);
  10084. state.zooming = false;
  10085. }
  10086. state.moving = false;
  10087. startMoveX = 0;
  10088. startMoveY = 0;
  10089. startScale = 1;
  10090. if (state.scale < 1) {
  10091. resetScale();
  10092. }
  10093. if (state.scale > props.maxZoom) {
  10094. state.scale = +props.maxZoom;
  10095. }
  10096. }
  10097. }
  10098. preventDefault(event, stopPropagation2);
  10099. checkTap();
  10100. touch.reset();
  10101. };
  10102. const onLoad = (event) => {
  10103. const {
  10104. naturalWidth,
  10105. naturalHeight
  10106. } = event.target;
  10107. state.imageRatio = naturalHeight / naturalWidth;
  10108. };
  10109. vue.watch(() => props.active, resetScale);
  10110. vue.watch(() => props.show, (value) => {
  10111. if (!value) {
  10112. resetScale();
  10113. }
  10114. });
  10115. useEventListener("touchmove", onTouchMove, {
  10116. target: vue.computed(() => {
  10117. var _a;
  10118. return (_a = swipeItem.value) == null ? void 0 : _a.$el;
  10119. })
  10120. });
  10121. return () => {
  10122. const imageSlots = {
  10123. loading: () => vue.createVNode(Loading, {
  10124. "type": "spinner"
  10125. }, null)
  10126. };
  10127. return vue.createVNode(SwipeItem, {
  10128. "ref": swipeItem,
  10129. "class": bem$v("swipe-item"),
  10130. "onTouchstartPassive": onTouchStart,
  10131. "onTouchend": onTouchEnd,
  10132. "onTouchcancel": onTouchEnd
  10133. }, {
  10134. default: () => [vue.createVNode(Image$1, {
  10135. "src": props.src,
  10136. "fit": "contain",
  10137. "class": bem$v("image", {
  10138. vertical: vertical.value
  10139. }),
  10140. "style": imageStyle.value,
  10141. "onLoad": onLoad
  10142. }, imageSlots)]
  10143. });
  10144. };
  10145. }
  10146. });
  10147. const [name$u, bem$u] = createNamespace("image-preview");
  10148. const popupProps$1 = ["show", "transition", "overlayStyle", "closeOnPopstate"];
  10149. const imagePreviewProps = {
  10150. show: Boolean,
  10151. loop: truthProp,
  10152. images: makeArrayProp(),
  10153. minZoom: makeNumericProp(1 / 3),
  10154. maxZoom: makeNumericProp(3),
  10155. overlay: truthProp,
  10156. closeable: Boolean,
  10157. showIndex: truthProp,
  10158. className: unknownProp,
  10159. closeIcon: makeStringProp("clear"),
  10160. transition: String,
  10161. beforeClose: Function,
  10162. overlayClass: unknownProp,
  10163. overlayStyle: Object,
  10164. swipeDuration: makeNumericProp(300),
  10165. startPosition: makeNumericProp(0),
  10166. showIndicators: Boolean,
  10167. closeOnPopstate: truthProp,
  10168. closeIconPosition: makeStringProp("top-right")
  10169. };
  10170. var stdin_default$z = vue.defineComponent({
  10171. name: name$u,
  10172. props: imagePreviewProps,
  10173. emits: ["scale", "close", "closed", "change", "update:show"],
  10174. setup(props, {
  10175. emit,
  10176. slots
  10177. }) {
  10178. const swipeRef = vue.ref();
  10179. const state = vue.reactive({
  10180. active: 0,
  10181. rootWidth: 0,
  10182. rootHeight: 0
  10183. });
  10184. const resize = () => {
  10185. if (swipeRef.value) {
  10186. const rect = useRect(swipeRef.value.$el);
  10187. state.rootWidth = rect.width;
  10188. state.rootHeight = rect.height;
  10189. swipeRef.value.resize();
  10190. }
  10191. };
  10192. const emitScale = (args) => emit("scale", args);
  10193. const updateShow = (show) => emit("update:show", show);
  10194. const emitClose = () => {
  10195. callInterceptor(props.beforeClose, {
  10196. args: [state.active],
  10197. done: () => updateShow(false)
  10198. });
  10199. };
  10200. const setActive = (active) => {
  10201. if (active !== state.active) {
  10202. state.active = active;
  10203. emit("change", active);
  10204. }
  10205. };
  10206. const renderIndex = () => {
  10207. if (props.showIndex) {
  10208. return vue.createVNode("div", {
  10209. "class": bem$u("index")
  10210. }, [slots.index ? slots.index({
  10211. index: state.active
  10212. }) : `${state.active + 1} / ${props.images.length}`]);
  10213. }
  10214. };
  10215. const renderCover = () => {
  10216. if (slots.cover) {
  10217. return vue.createVNode("div", {
  10218. "class": bem$u("cover")
  10219. }, [slots.cover()]);
  10220. }
  10221. };
  10222. const renderImages = () => vue.createVNode(Swipe, {
  10223. "ref": swipeRef,
  10224. "lazyRender": true,
  10225. "loop": props.loop,
  10226. "class": bem$u("swipe"),
  10227. "duration": props.swipeDuration,
  10228. "initialSwipe": props.startPosition,
  10229. "showIndicators": props.showIndicators,
  10230. "indicatorColor": "white",
  10231. "onChange": setActive
  10232. }, {
  10233. default: () => [props.images.map((image) => vue.createVNode(stdin_default$A, {
  10234. "src": image,
  10235. "show": props.show,
  10236. "active": state.active,
  10237. "maxZoom": props.maxZoom,
  10238. "minZoom": props.minZoom,
  10239. "rootWidth": state.rootWidth,
  10240. "rootHeight": state.rootHeight,
  10241. "onScale": emitScale,
  10242. "onClose": emitClose
  10243. }, null))]
  10244. });
  10245. const renderClose = () => {
  10246. if (props.closeable) {
  10247. return vue.createVNode(Icon, {
  10248. "role": "button",
  10249. "name": props.closeIcon,
  10250. "class": [bem$u("close-icon", props.closeIconPosition), HAPTICS_FEEDBACK],
  10251. "onClick": emitClose
  10252. }, null);
  10253. }
  10254. };
  10255. const onClosed = () => emit("closed");
  10256. const swipeTo = (index, options) => {
  10257. var _a;
  10258. return (_a = swipeRef.value) == null ? void 0 : _a.swipeTo(index, options);
  10259. };
  10260. useExpose({
  10261. swipeTo
  10262. });
  10263. vue.onMounted(resize);
  10264. vue.watch([windowWidth, windowHeight], resize);
  10265. vue.watch(() => props.startPosition, (value) => setActive(+value));
  10266. vue.watch(() => props.show, (value) => {
  10267. const {
  10268. images,
  10269. startPosition
  10270. } = props;
  10271. if (value) {
  10272. setActive(+startPosition);
  10273. vue.nextTick(() => {
  10274. resize();
  10275. swipeTo(+startPosition, {
  10276. immediate: true
  10277. });
  10278. });
  10279. } else {
  10280. emit("close", {
  10281. index: state.active,
  10282. url: images[state.active]
  10283. });
  10284. }
  10285. });
  10286. return () => vue.createVNode(Popup, vue.mergeProps({
  10287. "class": [bem$u(), props.className],
  10288. "overlayClass": [bem$u("overlay"), props.overlayClass],
  10289. "onClosed": onClosed,
  10290. "onUpdate:show": updateShow
  10291. }, pick(props, popupProps$1)), {
  10292. default: () => [renderClose(), renderImages(), renderIndex(), renderCover()]
  10293. });
  10294. }
  10295. });
  10296. let instance$1;
  10297. const defaultConfig = {
  10298. loop: true,
  10299. images: [],
  10300. maxZoom: 3,
  10301. minZoom: 1 / 3,
  10302. onScale: void 0,
  10303. onClose: void 0,
  10304. onChange: void 0,
  10305. teleport: "body",
  10306. className: "",
  10307. showIndex: true,
  10308. closeable: false,
  10309. closeIcon: "clear",
  10310. transition: void 0,
  10311. beforeClose: void 0,
  10312. overlayStyle: void 0,
  10313. overlayClass: void 0,
  10314. startPosition: 0,
  10315. swipeDuration: 300,
  10316. showIndicators: false,
  10317. closeOnPopstate: true,
  10318. closeIconPosition: "top-right"
  10319. };
  10320. function initInstance$1() {
  10321. ({
  10322. instance: instance$1
  10323. } = mountComponent({
  10324. setup() {
  10325. const {
  10326. state,
  10327. toggle
  10328. } = usePopupState();
  10329. const onClosed = () => {
  10330. state.images = [];
  10331. };
  10332. return () => vue.createVNode(stdin_default$z, vue.mergeProps(state, {
  10333. "onClosed": onClosed,
  10334. "onUpdate:show": toggle
  10335. }), null);
  10336. }
  10337. }));
  10338. }
  10339. const ImagePreview = (options, startPosition = 0) => {
  10340. if (!inBrowser$1) {
  10341. return;
  10342. }
  10343. if (!instance$1) {
  10344. initInstance$1();
  10345. }
  10346. options = Array.isArray(options) ? {
  10347. images: options,
  10348. startPosition
  10349. } : options;
  10350. instance$1.open(extend({}, defaultConfig, options));
  10351. return instance$1;
  10352. };
  10353. ImagePreview.Component = withInstall(stdin_default$z);
  10354. ImagePreview.install = (app) => {
  10355. app.use(ImagePreview.Component);
  10356. };
  10357. function genAlphabet() {
  10358. const charCodeOfA = "A".charCodeAt(0);
  10359. const indexList = Array(26).fill("").map((_, i) => String.fromCharCode(charCodeOfA + i));
  10360. return indexList;
  10361. }
  10362. const [name$t, bem$t] = createNamespace("index-bar");
  10363. const indexBarProps = {
  10364. sticky: truthProp,
  10365. zIndex: numericProp,
  10366. teleport: [String, Object],
  10367. highlightColor: String,
  10368. stickyOffsetTop: makeNumberProp(0),
  10369. indexList: {
  10370. type: Array,
  10371. default: genAlphabet
  10372. }
  10373. };
  10374. const INDEX_BAR_KEY = Symbol(name$t);
  10375. var stdin_default$y = vue.defineComponent({
  10376. name: name$t,
  10377. props: indexBarProps,
  10378. emits: ["select", "change"],
  10379. setup(props, {
  10380. emit,
  10381. slots
  10382. }) {
  10383. const root = vue.ref();
  10384. const sidebar = vue.ref();
  10385. const activeAnchor = vue.ref("");
  10386. const touch = useTouch();
  10387. const scrollParent = useScrollParent(root);
  10388. const {
  10389. children,
  10390. linkChildren
  10391. } = useChildren(INDEX_BAR_KEY);
  10392. let selectActiveIndex;
  10393. linkChildren({
  10394. props
  10395. });
  10396. const sidebarStyle = vue.computed(() => {
  10397. if (isDef(props.zIndex)) {
  10398. return {
  10399. zIndex: +props.zIndex + 1
  10400. };
  10401. }
  10402. });
  10403. const highlightStyle = vue.computed(() => {
  10404. if (props.highlightColor) {
  10405. return {
  10406. color: props.highlightColor
  10407. };
  10408. }
  10409. });
  10410. const getActiveAnchor = (scrollTop, rects) => {
  10411. for (let i = children.length - 1; i >= 0; i--) {
  10412. const prevHeight = i > 0 ? rects[i - 1].height : 0;
  10413. const reachTop = props.sticky ? prevHeight + props.stickyOffsetTop : 0;
  10414. if (scrollTop + reachTop >= rects[i].top) {
  10415. return i;
  10416. }
  10417. }
  10418. return -1;
  10419. };
  10420. const getMatchAnchor = (index) => children.find((item) => String(item.index) === index);
  10421. const onScroll = () => {
  10422. if (isHidden(root)) {
  10423. return;
  10424. }
  10425. const {
  10426. sticky,
  10427. indexList
  10428. } = props;
  10429. const scrollTop = getScrollTop(scrollParent.value);
  10430. const scrollParentRect = useRect(scrollParent);
  10431. const rects = children.map((item) => item.getRect(scrollParent.value, scrollParentRect));
  10432. let active = -1;
  10433. if (selectActiveIndex) {
  10434. const match = getMatchAnchor(selectActiveIndex);
  10435. if (match) {
  10436. const rect = match.getRect(scrollParent.value, scrollParentRect);
  10437. active = getActiveAnchor(rect.top, rects);
  10438. }
  10439. } else {
  10440. active = getActiveAnchor(scrollTop, rects);
  10441. }
  10442. activeAnchor.value = indexList[active];
  10443. if (sticky) {
  10444. children.forEach((item, index) => {
  10445. const {
  10446. state,
  10447. $el
  10448. } = item;
  10449. if (index === active || index === active - 1) {
  10450. const rect = $el.getBoundingClientRect();
  10451. state.left = rect.left;
  10452. state.width = rect.width;
  10453. } else {
  10454. state.left = null;
  10455. state.width = null;
  10456. }
  10457. if (index === active) {
  10458. state.active = true;
  10459. state.top = Math.max(props.stickyOffsetTop, rects[index].top - scrollTop) + scrollParentRect.top;
  10460. } else if (index === active - 1 && selectActiveIndex === "") {
  10461. const activeItemTop = rects[active].top - scrollTop;
  10462. state.active = activeItemTop > 0;
  10463. state.top = activeItemTop + scrollParentRect.top - rects[index].height;
  10464. } else {
  10465. state.active = false;
  10466. }
  10467. });
  10468. }
  10469. selectActiveIndex = "";
  10470. };
  10471. const init = () => {
  10472. vue.nextTick(onScroll);
  10473. };
  10474. useEventListener("scroll", onScroll, {
  10475. target: scrollParent,
  10476. passive: true
  10477. });
  10478. vue.onMounted(init);
  10479. vue.watch(() => props.indexList, init);
  10480. vue.watch(activeAnchor, (value) => {
  10481. if (value) {
  10482. emit("change", value);
  10483. }
  10484. });
  10485. const renderIndexes = () => props.indexList.map((index) => {
  10486. const active = index === activeAnchor.value;
  10487. return vue.createVNode("span", {
  10488. "class": bem$t("index", {
  10489. active
  10490. }),
  10491. "style": active ? highlightStyle.value : void 0,
  10492. "data-index": index
  10493. }, [index]);
  10494. });
  10495. const scrollTo = (index) => {
  10496. selectActiveIndex = String(index);
  10497. const match = getMatchAnchor(selectActiveIndex);
  10498. if (match) {
  10499. const scrollTop = getScrollTop(scrollParent.value);
  10500. const scrollParentRect = useRect(scrollParent);
  10501. const {
  10502. offsetHeight
  10503. } = document.documentElement;
  10504. match.$el.scrollIntoView();
  10505. if (scrollTop === offsetHeight - scrollParentRect.height) {
  10506. onScroll();
  10507. return;
  10508. }
  10509. if (props.sticky && props.stickyOffsetTop) {
  10510. setRootScrollTop(getRootScrollTop() - props.stickyOffsetTop);
  10511. }
  10512. emit("select", match.index);
  10513. }
  10514. };
  10515. const scrollToElement = (element) => {
  10516. const {
  10517. index
  10518. } = element.dataset;
  10519. if (index) {
  10520. scrollTo(index);
  10521. }
  10522. };
  10523. const onClickSidebar = (event) => {
  10524. scrollToElement(event.target);
  10525. };
  10526. let touchActiveIndex;
  10527. const onTouchMove = (event) => {
  10528. touch.move(event);
  10529. if (touch.isVertical()) {
  10530. preventDefault(event);
  10531. const {
  10532. clientX,
  10533. clientY
  10534. } = event.touches[0];
  10535. const target = document.elementFromPoint(clientX, clientY);
  10536. if (target) {
  10537. const {
  10538. index
  10539. } = target.dataset;
  10540. if (index && touchActiveIndex !== index) {
  10541. touchActiveIndex = index;
  10542. scrollToElement(target);
  10543. }
  10544. }
  10545. }
  10546. };
  10547. const renderSidebar = () => vue.createVNode("div", {
  10548. "ref": sidebar,
  10549. "class": bem$t("sidebar"),
  10550. "style": sidebarStyle.value,
  10551. "onClick": onClickSidebar,
  10552. "onTouchstartPassive": touch.start
  10553. }, [renderIndexes()]);
  10554. useExpose({
  10555. scrollTo
  10556. });
  10557. useEventListener("touchmove", onTouchMove, {
  10558. target: sidebar
  10559. });
  10560. return () => {
  10561. var _a;
  10562. return vue.createVNode("div", {
  10563. "ref": root,
  10564. "class": bem$t()
  10565. }, [props.teleport ? vue.createVNode(vue.Teleport, {
  10566. "to": props.teleport
  10567. }, {
  10568. default: () => [renderSidebar()]
  10569. }) : renderSidebar(), (_a = slots.default) == null ? void 0 : _a.call(slots)]);
  10570. };
  10571. }
  10572. });
  10573. const [name$s, bem$s] = createNamespace("index-anchor");
  10574. const indexAnchorProps = {
  10575. index: numericProp
  10576. };
  10577. var stdin_default$x = vue.defineComponent({
  10578. name: name$s,
  10579. props: indexAnchorProps,
  10580. setup(props, {
  10581. slots
  10582. }) {
  10583. const state = vue.reactive({
  10584. top: 0,
  10585. left: null,
  10586. rect: {
  10587. top: 0,
  10588. height: 0
  10589. },
  10590. width: null,
  10591. active: false
  10592. });
  10593. const root = vue.ref();
  10594. const {
  10595. parent
  10596. } = useParent(INDEX_BAR_KEY);
  10597. if (!parent) {
  10598. return;
  10599. }
  10600. const isSticky = () => state.active && parent.props.sticky;
  10601. const anchorStyle = vue.computed(() => {
  10602. const {
  10603. zIndex,
  10604. highlightColor
  10605. } = parent.props;
  10606. if (isSticky()) {
  10607. return extend(getZIndexStyle(zIndex), {
  10608. left: state.left ? `${state.left}px` : void 0,
  10609. width: state.width ? `${state.width}px` : void 0,
  10610. transform: state.top ? `translate3d(0, ${state.top}px, 0)` : void 0,
  10611. color: highlightColor
  10612. });
  10613. }
  10614. });
  10615. const getRect = (scrollParent, scrollParentRect) => {
  10616. const rootRect = useRect(root);
  10617. state.rect.height = rootRect.height;
  10618. if (scrollParent === window || scrollParent === document.body) {
  10619. state.rect.top = rootRect.top + getRootScrollTop();
  10620. } else {
  10621. state.rect.top = rootRect.top + getScrollTop(scrollParent) - scrollParentRect.top;
  10622. }
  10623. return state.rect;
  10624. };
  10625. useExpose({
  10626. state,
  10627. getRect
  10628. });
  10629. return () => {
  10630. const sticky = isSticky();
  10631. return vue.createVNode("div", {
  10632. "ref": root,
  10633. "style": {
  10634. height: sticky ? `${state.rect.height}px` : void 0
  10635. }
  10636. }, [vue.createVNode("div", {
  10637. "style": anchorStyle.value,
  10638. "class": [bem$s({
  10639. sticky
  10640. }), {
  10641. [BORDER_BOTTOM]: sticky
  10642. }]
  10643. }, [slots.default ? slots.default() : props.index])]);
  10644. };
  10645. }
  10646. });
  10647. const IndexAnchor = withInstall(stdin_default$x);
  10648. const IndexBar = withInstall(stdin_default$y);
  10649. const [name$r, bem$r, t$6] = createNamespace("list");
  10650. const listProps = {
  10651. error: Boolean,
  10652. offset: makeNumericProp(300),
  10653. loading: Boolean,
  10654. finished: Boolean,
  10655. errorText: String,
  10656. direction: makeStringProp("down"),
  10657. loadingText: String,
  10658. finishedText: String,
  10659. immediateCheck: truthProp
  10660. };
  10661. var stdin_default$w = vue.defineComponent({
  10662. name: name$r,
  10663. props: listProps,
  10664. emits: ["load", "update:error", "update:loading"],
  10665. setup(props, {
  10666. emit,
  10667. slots
  10668. }) {
  10669. const loading = vue.ref(false);
  10670. const root = vue.ref();
  10671. const placeholder = vue.ref();
  10672. const tabStatus = useTabStatus();
  10673. const scrollParent = useScrollParent(root);
  10674. const check = () => {
  10675. vue.nextTick(() => {
  10676. if (loading.value || props.finished || props.error || (tabStatus == null ? void 0 : tabStatus.value) === false) {
  10677. return;
  10678. }
  10679. const {
  10680. offset: offset2,
  10681. direction
  10682. } = props;
  10683. const scrollParentRect = useRect(scrollParent);
  10684. if (!scrollParentRect.height || isHidden(root)) {
  10685. return;
  10686. }
  10687. let isReachEdge = false;
  10688. const placeholderRect = useRect(placeholder);
  10689. if (direction === "up") {
  10690. isReachEdge = scrollParentRect.top - placeholderRect.top <= offset2;
  10691. } else {
  10692. isReachEdge = placeholderRect.bottom - scrollParentRect.bottom <= offset2;
  10693. }
  10694. if (isReachEdge) {
  10695. loading.value = true;
  10696. emit("update:loading", true);
  10697. emit("load");
  10698. }
  10699. });
  10700. };
  10701. const renderFinishedText = () => {
  10702. if (props.finished) {
  10703. const text = slots.finished ? slots.finished() : props.finishedText;
  10704. if (text) {
  10705. return vue.createVNode("div", {
  10706. "class": bem$r("finished-text")
  10707. }, [text]);
  10708. }
  10709. }
  10710. };
  10711. const clickErrorText = () => {
  10712. emit("update:error", false);
  10713. check();
  10714. };
  10715. const renderErrorText = () => {
  10716. if (props.error) {
  10717. const text = slots.error ? slots.error() : props.errorText;
  10718. if (text) {
  10719. return vue.createVNode("div", {
  10720. "role": "button",
  10721. "class": bem$r("error-text"),
  10722. "tabindex": 0,
  10723. "onClick": clickErrorText
  10724. }, [text]);
  10725. }
  10726. }
  10727. };
  10728. const renderLoading = () => {
  10729. if (loading.value && !props.finished) {
  10730. return vue.createVNode("div", {
  10731. "class": bem$r("loading")
  10732. }, [slots.loading ? slots.loading() : vue.createVNode(Loading, {
  10733. "class": bem$r("loading-icon")
  10734. }, {
  10735. default: () => [props.loadingText || t$6("loading")]
  10736. })]);
  10737. }
  10738. };
  10739. vue.watch(() => [props.loading, props.finished, props.error], check);
  10740. if (tabStatus) {
  10741. vue.watch(tabStatus, (tabActive) => {
  10742. if (tabActive) {
  10743. check();
  10744. }
  10745. });
  10746. }
  10747. vue.onUpdated(() => {
  10748. loading.value = props.loading;
  10749. });
  10750. vue.onMounted(() => {
  10751. if (props.immediateCheck) {
  10752. check();
  10753. }
  10754. });
  10755. useExpose({
  10756. check
  10757. });
  10758. useEventListener("scroll", check, {
  10759. target: scrollParent,
  10760. passive: true
  10761. });
  10762. return () => {
  10763. var _a;
  10764. const Content = (_a = slots.default) == null ? void 0 : _a.call(slots);
  10765. const Placeholder = vue.createVNode("div", {
  10766. "ref": placeholder,
  10767. "class": bem$r("placeholder")
  10768. }, null);
  10769. return vue.createVNode("div", {
  10770. "ref": root,
  10771. "role": "feed",
  10772. "class": bem$r(),
  10773. "aria-busy": loading.value
  10774. }, [props.direction === "down" ? Content : Placeholder, renderLoading(), renderFinishedText(), renderErrorText(), props.direction === "up" ? Content : Placeholder]);
  10775. };
  10776. }
  10777. });
  10778. const List = withInstall(stdin_default$w);
  10779. const [name$q, bem$q] = createNamespace("nav-bar");
  10780. const navBarProps = {
  10781. title: String,
  10782. fixed: Boolean,
  10783. zIndex: numericProp,
  10784. border: truthProp,
  10785. leftText: String,
  10786. rightText: String,
  10787. leftArrow: Boolean,
  10788. placeholder: Boolean,
  10789. safeAreaInsetTop: Boolean
  10790. };
  10791. var stdin_default$v = vue.defineComponent({
  10792. name: name$q,
  10793. props: navBarProps,
  10794. emits: ["click-left", "click-right"],
  10795. setup(props, {
  10796. emit,
  10797. slots
  10798. }) {
  10799. const navBarRef = vue.ref();
  10800. const renderPlaceholder = usePlaceholder(navBarRef, bem$q);
  10801. const onClickLeft = (event) => emit("click-left", event);
  10802. const onClickRight = (event) => emit("click-right", event);
  10803. const renderLeft = () => {
  10804. if (slots.left) {
  10805. return slots.left();
  10806. }
  10807. return [props.leftArrow && vue.createVNode(Icon, {
  10808. "class": bem$q("arrow"),
  10809. "name": "arrow-left"
  10810. }, null), props.leftText && vue.createVNode("span", {
  10811. "class": bem$q("text")
  10812. }, [props.leftText])];
  10813. };
  10814. const renderRight = () => {
  10815. if (slots.right) {
  10816. return slots.right();
  10817. }
  10818. return vue.createVNode("span", {
  10819. "class": bem$q("text")
  10820. }, [props.rightText]);
  10821. };
  10822. const renderNavBar = () => {
  10823. const {
  10824. title,
  10825. fixed,
  10826. border,
  10827. zIndex
  10828. } = props;
  10829. const style = getZIndexStyle(zIndex);
  10830. const hasLeft = props.leftArrow || props.leftText || slots.left;
  10831. const hasRight = props.rightText || slots.right;
  10832. return vue.createVNode("div", {
  10833. "ref": navBarRef,
  10834. "style": style,
  10835. "class": [bem$q({
  10836. fixed
  10837. }), {
  10838. [BORDER_BOTTOM]: border,
  10839. "van-safe-area-top": props.safeAreaInsetTop
  10840. }]
  10841. }, [vue.createVNode("div", {
  10842. "class": bem$q("content")
  10843. }, [hasLeft && vue.createVNode("div", {
  10844. "class": [bem$q("left"), HAPTICS_FEEDBACK],
  10845. "onClick": onClickLeft
  10846. }, [renderLeft()]), vue.createVNode("div", {
  10847. "class": [bem$q("title"), "van-ellipsis"]
  10848. }, [slots.title ? slots.title() : title]), hasRight && vue.createVNode("div", {
  10849. "class": [bem$q("right"), HAPTICS_FEEDBACK],
  10850. "onClick": onClickRight
  10851. }, [renderRight()])])]);
  10852. };
  10853. return () => {
  10854. if (props.fixed && props.placeholder) {
  10855. return renderPlaceholder(renderNavBar);
  10856. }
  10857. return renderNavBar();
  10858. };
  10859. }
  10860. });
  10861. const NavBar = withInstall(stdin_default$v);
  10862. const [name$p, bem$p] = createNamespace("notice-bar");
  10863. const noticeBarProps = {
  10864. text: String,
  10865. mode: String,
  10866. color: String,
  10867. delay: makeNumericProp(1),
  10868. speed: makeNumericProp(60),
  10869. leftIcon: String,
  10870. wrapable: Boolean,
  10871. background: String,
  10872. scrollable: {
  10873. type: Boolean,
  10874. default: null
  10875. }
  10876. };
  10877. var stdin_default$u = vue.defineComponent({
  10878. name: name$p,
  10879. props: noticeBarProps,
  10880. emits: ["close", "replay"],
  10881. setup(props, {
  10882. emit,
  10883. slots
  10884. }) {
  10885. let wrapWidth = 0;
  10886. let contentWidth = 0;
  10887. let startTimer;
  10888. const wrapRef = vue.ref();
  10889. const contentRef = vue.ref();
  10890. const state = vue.reactive({
  10891. show: true,
  10892. offset: 0,
  10893. duration: 0
  10894. });
  10895. const renderLeftIcon = () => {
  10896. if (slots["left-icon"]) {
  10897. return slots["left-icon"]();
  10898. }
  10899. if (props.leftIcon) {
  10900. return vue.createVNode(Icon, {
  10901. "class": bem$p("left-icon"),
  10902. "name": props.leftIcon
  10903. }, null);
  10904. }
  10905. };
  10906. const getRightIconName = () => {
  10907. if (props.mode === "closeable") {
  10908. return "cross";
  10909. }
  10910. if (props.mode === "link") {
  10911. return "arrow";
  10912. }
  10913. };
  10914. const onClickRightIcon = (event) => {
  10915. if (props.mode === "closeable") {
  10916. state.show = false;
  10917. emit("close", event);
  10918. }
  10919. };
  10920. const renderRightIcon = () => {
  10921. if (slots["right-icon"]) {
  10922. return slots["right-icon"]();
  10923. }
  10924. const name2 = getRightIconName();
  10925. if (name2) {
  10926. return vue.createVNode(Icon, {
  10927. "name": name2,
  10928. "class": bem$p("right-icon"),
  10929. "onClick": onClickRightIcon
  10930. }, null);
  10931. }
  10932. };
  10933. const onTransitionEnd = () => {
  10934. state.offset = wrapWidth;
  10935. state.duration = 0;
  10936. raf(() => {
  10937. doubleRaf(() => {
  10938. state.offset = -contentWidth;
  10939. state.duration = (contentWidth + wrapWidth) / +props.speed;
  10940. emit("replay");
  10941. });
  10942. });
  10943. };
  10944. const renderMarquee = () => {
  10945. const ellipsis = props.scrollable === false && !props.wrapable;
  10946. const style = {
  10947. transform: state.offset ? `translateX(${state.offset}px)` : "",
  10948. transitionDuration: `${state.duration}s`
  10949. };
  10950. return vue.createVNode("div", {
  10951. "ref": wrapRef,
  10952. "role": "marquee",
  10953. "class": bem$p("wrap")
  10954. }, [vue.createVNode("div", {
  10955. "ref": contentRef,
  10956. "style": style,
  10957. "class": [bem$p("content"), {
  10958. "van-ellipsis": ellipsis
  10959. }],
  10960. "onTransitionend": onTransitionEnd
  10961. }, [slots.default ? slots.default() : props.text])]);
  10962. };
  10963. const reset = () => {
  10964. const {
  10965. delay,
  10966. speed,
  10967. scrollable
  10968. } = props;
  10969. const ms = isDef(delay) ? +delay * 1e3 : 0;
  10970. wrapWidth = 0;
  10971. contentWidth = 0;
  10972. state.offset = 0;
  10973. state.duration = 0;
  10974. clearTimeout(startTimer);
  10975. startTimer = setTimeout(() => {
  10976. if (!wrapRef.value || !contentRef.value || scrollable === false) {
  10977. return;
  10978. }
  10979. const wrapRefWidth = useRect(wrapRef).width;
  10980. const contentRefWidth = useRect(contentRef).width;
  10981. if (scrollable || contentRefWidth > wrapRefWidth) {
  10982. doubleRaf(() => {
  10983. wrapWidth = wrapRefWidth;
  10984. contentWidth = contentRefWidth;
  10985. state.offset = -contentWidth;
  10986. state.duration = contentWidth / +speed;
  10987. });
  10988. }
  10989. }, ms);
  10990. };
  10991. onPopupReopen(reset);
  10992. onMountedOrActivated(reset);
  10993. useEventListener("pageshow", reset);
  10994. useExpose({
  10995. reset
  10996. });
  10997. vue.watch(() => [props.text, props.scrollable], reset);
  10998. return () => {
  10999. const {
  11000. color,
  11001. wrapable,
  11002. background
  11003. } = props;
  11004. return vue.withDirectives(vue.createVNode("div", {
  11005. "role": "alert",
  11006. "class": bem$p({
  11007. wrapable
  11008. }),
  11009. "style": {
  11010. color,
  11011. background
  11012. }
  11013. }, [renderLeftIcon(), renderMarquee(), renderRightIcon()]), [[vue.vShow, state.show]]);
  11014. };
  11015. }
  11016. });
  11017. const NoticeBar = withInstall(stdin_default$u);
  11018. const [name$o, bem$o] = createNamespace("notify");
  11019. const notifyProps = extend({}, popupSharedProps, {
  11020. type: makeStringProp("danger"),
  11021. color: String,
  11022. message: numericProp,
  11023. position: makeStringProp("top"),
  11024. className: unknownProp,
  11025. background: String,
  11026. lockScroll: Boolean
  11027. });
  11028. var stdin_default$t = vue.defineComponent({
  11029. name: name$o,
  11030. props: notifyProps,
  11031. emits: ["update:show"],
  11032. setup(props, {
  11033. emit,
  11034. slots
  11035. }) {
  11036. const updateShow = (show) => emit("update:show", show);
  11037. return () => vue.createVNode(Popup, {
  11038. "show": props.show,
  11039. "class": [bem$o([props.type]), props.className],
  11040. "style": {
  11041. color: props.color,
  11042. background: props.background
  11043. },
  11044. "overlay": false,
  11045. "position": props.position,
  11046. "duration": 0.2,
  11047. "lockScroll": props.lockScroll,
  11048. "onUpdate:show": updateShow
  11049. }, {
  11050. default: () => [slots.default ? slots.default() : props.message]
  11051. });
  11052. }
  11053. });
  11054. let timer;
  11055. let instance;
  11056. const parseOptions = (message) => isObject(message) ? message : {
  11057. message
  11058. };
  11059. function initInstance() {
  11060. ({
  11061. instance
  11062. } = mountComponent({
  11063. setup() {
  11064. const {
  11065. state,
  11066. toggle
  11067. } = usePopupState();
  11068. return () => vue.createVNode(stdin_default$t, vue.mergeProps(state, {
  11069. "onUpdate:show": toggle
  11070. }), null);
  11071. }
  11072. }));
  11073. }
  11074. function Notify(options) {
  11075. if (!inBrowser$1) {
  11076. return;
  11077. }
  11078. if (!instance) {
  11079. initInstance();
  11080. }
  11081. options = extend({}, Notify.currentOptions, parseOptions(options));
  11082. instance.open(options);
  11083. clearTimeout(timer);
  11084. if (options.duration > 0) {
  11085. timer = window.setTimeout(Notify.clear, options.duration);
  11086. }
  11087. return instance;
  11088. }
  11089. const getDefaultOptions = () => ({
  11090. type: "danger",
  11091. color: void 0,
  11092. message: "",
  11093. onClose: void 0,
  11094. onClick: void 0,
  11095. onOpened: void 0,
  11096. duration: 3e3,
  11097. position: void 0,
  11098. className: "",
  11099. lockScroll: false,
  11100. background: void 0
  11101. });
  11102. Notify.clear = () => {
  11103. if (instance) {
  11104. instance.toggle(false);
  11105. }
  11106. };
  11107. Notify.currentOptions = getDefaultOptions();
  11108. Notify.setDefaultOptions = (options) => {
  11109. extend(Notify.currentOptions, options);
  11110. };
  11111. Notify.resetDefaultOptions = () => {
  11112. Notify.currentOptions = getDefaultOptions();
  11113. };
  11114. Notify.Component = withInstall(stdin_default$t);
  11115. Notify.install = (app) => {
  11116. app.use(Notify.Component);
  11117. app.config.globalProperties.$notify = Notify;
  11118. };
  11119. const [name$n, bem$n] = createNamespace("key");
  11120. const CollapseIcon = vue.createVNode("svg", {
  11121. "class": bem$n("collapse-icon"),
  11122. "viewBox": "0 0 30 24"
  11123. }, [vue.createVNode("path", {
  11124. "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",
  11125. "fill": "currentColor"
  11126. }, null)]);
  11127. const DeleteIcon = vue.createVNode("svg", {
  11128. "class": bem$n("delete-icon"),
  11129. "viewBox": "0 0 32 22"
  11130. }, [vue.createVNode("path", {
  11131. "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",
  11132. "fill": "currentColor"
  11133. }, null)]);
  11134. var stdin_default$s = vue.defineComponent({
  11135. name: name$n,
  11136. props: {
  11137. type: String,
  11138. text: numericProp,
  11139. color: String,
  11140. wider: Boolean,
  11141. large: Boolean,
  11142. loading: Boolean
  11143. },
  11144. emits: ["press"],
  11145. setup(props, {
  11146. emit,
  11147. slots
  11148. }) {
  11149. const active = vue.ref(false);
  11150. const touch = useTouch();
  11151. const onTouchStart = (event) => {
  11152. touch.start(event);
  11153. active.value = true;
  11154. };
  11155. const onTouchMove = (event) => {
  11156. touch.move(event);
  11157. if (touch.direction.value) {
  11158. active.value = false;
  11159. }
  11160. };
  11161. const onTouchEnd = (event) => {
  11162. if (active.value) {
  11163. if (!slots.default) {
  11164. preventDefault(event);
  11165. }
  11166. active.value = false;
  11167. emit("press", props.text, props.type);
  11168. }
  11169. };
  11170. const renderContent = () => {
  11171. if (props.loading) {
  11172. return vue.createVNode(Loading, {
  11173. "class": bem$n("loading-icon")
  11174. }, null);
  11175. }
  11176. const text = slots.default ? slots.default() : props.text;
  11177. switch (props.type) {
  11178. case "delete":
  11179. return text || DeleteIcon;
  11180. case "extra":
  11181. return text || CollapseIcon;
  11182. default:
  11183. return text;
  11184. }
  11185. };
  11186. return () => vue.createVNode("div", {
  11187. "class": bem$n("wrapper", {
  11188. wider: props.wider
  11189. }),
  11190. "onTouchstartPassive": onTouchStart,
  11191. "onTouchmovePassive": onTouchMove,
  11192. "onTouchend": onTouchEnd,
  11193. "onTouchcancel": onTouchEnd
  11194. }, [vue.createVNode("div", {
  11195. "role": "button",
  11196. "tabindex": 0,
  11197. "class": bem$n([props.color, {
  11198. large: props.large,
  11199. active: active.value,
  11200. delete: props.type === "delete"
  11201. }])
  11202. }, [renderContent()])]);
  11203. }
  11204. });
  11205. const [name$m, bem$m] = createNamespace("number-keyboard");
  11206. const numberKeyboardProps = {
  11207. show: Boolean,
  11208. title: String,
  11209. theme: makeStringProp("default"),
  11210. zIndex: numericProp,
  11211. teleport: [String, Object],
  11212. maxlength: makeNumericProp(Infinity),
  11213. modelValue: makeStringProp(""),
  11214. transition: truthProp,
  11215. blurOnClose: truthProp,
  11216. showDeleteKey: truthProp,
  11217. randomKeyOrder: Boolean,
  11218. closeButtonText: String,
  11219. deleteButtonText: String,
  11220. closeButtonLoading: Boolean,
  11221. hideOnClickOutside: truthProp,
  11222. safeAreaInsetBottom: truthProp,
  11223. extraKey: {
  11224. type: [String, Array],
  11225. default: ""
  11226. }
  11227. };
  11228. function shuffle(array) {
  11229. for (let i = array.length - 1; i > 0; i--) {
  11230. const j = Math.floor(Math.random() * (i + 1));
  11231. const temp = array[i];
  11232. array[i] = array[j];
  11233. array[j] = temp;
  11234. }
  11235. return array;
  11236. }
  11237. var stdin_default$r = vue.defineComponent({
  11238. name: name$m,
  11239. props: numberKeyboardProps,
  11240. emits: ["show", "hide", "blur", "input", "close", "delete", "update:modelValue"],
  11241. setup(props, {
  11242. emit,
  11243. slots
  11244. }) {
  11245. const root = vue.ref();
  11246. const genBasicKeys = () => {
  11247. const keys2 = Array(9).fill("").map((_, i) => ({
  11248. text: i + 1
  11249. }));
  11250. if (props.randomKeyOrder) {
  11251. shuffle(keys2);
  11252. }
  11253. return keys2;
  11254. };
  11255. const genDefaultKeys = () => [...genBasicKeys(), {
  11256. text: props.extraKey,
  11257. type: "extra"
  11258. }, {
  11259. text: 0
  11260. }, {
  11261. text: props.showDeleteKey ? props.deleteButtonText : "",
  11262. type: props.showDeleteKey ? "delete" : ""
  11263. }];
  11264. const genCustomKeys = () => {
  11265. const keys2 = genBasicKeys();
  11266. const {
  11267. extraKey
  11268. } = props;
  11269. const extraKeys = Array.isArray(extraKey) ? extraKey : [extraKey];
  11270. if (extraKeys.length === 1) {
  11271. keys2.push({
  11272. text: 0,
  11273. wider: true
  11274. }, {
  11275. text: extraKeys[0],
  11276. type: "extra"
  11277. });
  11278. } else if (extraKeys.length === 2) {
  11279. keys2.push({
  11280. text: extraKeys[0],
  11281. type: "extra"
  11282. }, {
  11283. text: 0
  11284. }, {
  11285. text: extraKeys[1],
  11286. type: "extra"
  11287. });
  11288. }
  11289. return keys2;
  11290. };
  11291. const keys = vue.computed(() => props.theme === "custom" ? genCustomKeys() : genDefaultKeys());
  11292. const onBlur = () => {
  11293. if (props.show) {
  11294. emit("blur");
  11295. }
  11296. };
  11297. const onClose = () => {
  11298. emit("close");
  11299. if (props.blurOnClose) {
  11300. onBlur();
  11301. }
  11302. };
  11303. const onAnimationEnd = () => emit(props.show ? "show" : "hide");
  11304. const onPress = (text, type) => {
  11305. if (text === "") {
  11306. if (type === "extra") {
  11307. onBlur();
  11308. }
  11309. return;
  11310. }
  11311. const value = props.modelValue;
  11312. if (type === "delete") {
  11313. emit("delete");
  11314. emit("update:modelValue", value.slice(0, value.length - 1));
  11315. } else if (type === "close") {
  11316. onClose();
  11317. } else if (value.length < props.maxlength) {
  11318. emit("input", text);
  11319. emit("update:modelValue", value + text);
  11320. }
  11321. };
  11322. const renderTitle = () => {
  11323. const {
  11324. title,
  11325. theme,
  11326. closeButtonText
  11327. } = props;
  11328. const leftSlot = slots["title-left"];
  11329. const showClose = closeButtonText && theme === "default";
  11330. const showTitle = title || showClose || leftSlot;
  11331. if (!showTitle) {
  11332. return;
  11333. }
  11334. return vue.createVNode("div", {
  11335. "class": bem$m("header")
  11336. }, [leftSlot && vue.createVNode("span", {
  11337. "class": bem$m("title-left")
  11338. }, [leftSlot()]), title && vue.createVNode("h2", {
  11339. "class": bem$m("title")
  11340. }, [title]), showClose && vue.createVNode("button", {
  11341. "type": "button",
  11342. "class": [bem$m("close"), HAPTICS_FEEDBACK],
  11343. "onClick": onClose
  11344. }, [closeButtonText])]);
  11345. };
  11346. const renderKeys = () => keys.value.map((key) => {
  11347. const keySlots = {};
  11348. if (key.type === "delete") {
  11349. keySlots.default = slots.delete;
  11350. }
  11351. if (key.type === "extra") {
  11352. keySlots.default = slots["extra-key"];
  11353. }
  11354. return vue.createVNode(stdin_default$s, {
  11355. "key": key.text,
  11356. "text": key.text,
  11357. "type": key.type,
  11358. "wider": key.wider,
  11359. "color": key.color,
  11360. "onPress": onPress
  11361. }, keySlots);
  11362. });
  11363. const renderSidebar = () => {
  11364. if (props.theme === "custom") {
  11365. return vue.createVNode("div", {
  11366. "class": bem$m("sidebar")
  11367. }, [props.showDeleteKey && vue.createVNode(stdin_default$s, {
  11368. "large": true,
  11369. "text": props.deleteButtonText,
  11370. "type": "delete",
  11371. "onPress": onPress
  11372. }, {
  11373. delete: slots.delete
  11374. }), vue.createVNode(stdin_default$s, {
  11375. "large": true,
  11376. "text": props.closeButtonText,
  11377. "type": "close",
  11378. "color": "blue",
  11379. "loading": props.closeButtonLoading,
  11380. "onPress": onPress
  11381. }, null)]);
  11382. }
  11383. };
  11384. vue.watch(() => props.show, (value) => {
  11385. if (!props.transition) {
  11386. emit(value ? "show" : "hide");
  11387. }
  11388. });
  11389. if (props.hideOnClickOutside) {
  11390. useClickAway(root, onBlur, {
  11391. eventName: "touchstart"
  11392. });
  11393. }
  11394. return () => {
  11395. const Title = renderTitle();
  11396. const Content = vue.createVNode(vue.Transition, {
  11397. "name": props.transition ? "van-slide-up" : ""
  11398. }, {
  11399. default: () => [vue.withDirectives(vue.createVNode("div", {
  11400. "ref": root,
  11401. "style": getZIndexStyle(props.zIndex),
  11402. "class": bem$m({
  11403. unfit: !props.safeAreaInsetBottom,
  11404. "with-title": !!Title
  11405. }),
  11406. "onAnimationend": onAnimationEnd,
  11407. "onTouchstartPassive": stopPropagation
  11408. }, [Title, vue.createVNode("div", {
  11409. "class": bem$m("body")
  11410. }, [vue.createVNode("div", {
  11411. "class": bem$m("keys")
  11412. }, [renderKeys()]), renderSidebar()])]), [[vue.vShow, props.show]])]
  11413. });
  11414. if (props.teleport) {
  11415. return vue.createVNode(vue.Teleport, {
  11416. "to": props.teleport
  11417. }, {
  11418. default: () => [Content]
  11419. });
  11420. }
  11421. return Content;
  11422. };
  11423. }
  11424. });
  11425. const NumberKeyboard = withInstall(stdin_default$r);
  11426. const [name$l, bem$l, t$5] = createNamespace("pagination");
  11427. const makePage = (number, text, active) => ({
  11428. number,
  11429. text,
  11430. active
  11431. });
  11432. const paginationProps = {
  11433. mode: makeStringProp("multi"),
  11434. prevText: String,
  11435. nextText: String,
  11436. pageCount: makeNumericProp(0),
  11437. modelValue: makeNumberProp(0),
  11438. totalItems: makeNumericProp(0),
  11439. showPageSize: makeNumericProp(5),
  11440. itemsPerPage: makeNumericProp(10),
  11441. forceEllipses: Boolean
  11442. };
  11443. var stdin_default$q = vue.defineComponent({
  11444. name: name$l,
  11445. props: paginationProps,
  11446. emits: ["change", "update:modelValue"],
  11447. setup(props, {
  11448. emit,
  11449. slots
  11450. }) {
  11451. const count = vue.computed(() => {
  11452. const {
  11453. pageCount,
  11454. totalItems,
  11455. itemsPerPage
  11456. } = props;
  11457. const count2 = +pageCount || Math.ceil(+totalItems / +itemsPerPage);
  11458. return Math.max(1, count2);
  11459. });
  11460. const pages = vue.computed(() => {
  11461. const items = [];
  11462. const pageCount = count.value;
  11463. const showPageSize = +props.showPageSize;
  11464. const {
  11465. modelValue,
  11466. forceEllipses
  11467. } = props;
  11468. let startPage = 1;
  11469. let endPage = pageCount;
  11470. const isMaxSized = showPageSize < pageCount;
  11471. if (isMaxSized) {
  11472. startPage = Math.max(modelValue - Math.floor(showPageSize / 2), 1);
  11473. endPage = startPage + showPageSize - 1;
  11474. if (endPage > pageCount) {
  11475. endPage = pageCount;
  11476. startPage = endPage - showPageSize + 1;
  11477. }
  11478. }
  11479. for (let number = startPage; number <= endPage; number++) {
  11480. const page = makePage(number, number, number === modelValue);
  11481. items.push(page);
  11482. }
  11483. if (isMaxSized && showPageSize > 0 && forceEllipses) {
  11484. if (startPage > 1) {
  11485. const prevPages = makePage(startPage - 1, "...");
  11486. items.unshift(prevPages);
  11487. }
  11488. if (endPage < pageCount) {
  11489. const nextPages = makePage(endPage + 1, "...");
  11490. items.push(nextPages);
  11491. }
  11492. }
  11493. return items;
  11494. });
  11495. const updateModelValue = (value, emitChange) => {
  11496. value = clamp(value, 1, count.value);
  11497. if (props.modelValue !== value) {
  11498. emit("update:modelValue", value);
  11499. if (emitChange) {
  11500. emit("change", value);
  11501. }
  11502. }
  11503. };
  11504. vue.watchEffect(() => updateModelValue(props.modelValue));
  11505. const renderDesc = () => vue.createVNode("li", {
  11506. "class": bem$l("page-desc")
  11507. }, [slots.pageDesc ? slots.pageDesc() : `${props.modelValue}/${count.value}`]);
  11508. const renderPrevButton = () => {
  11509. const {
  11510. mode,
  11511. modelValue
  11512. } = props;
  11513. const slot = slots["prev-text"];
  11514. const disabled = modelValue === 1;
  11515. return vue.createVNode("li", {
  11516. "class": [bem$l("item", {
  11517. disabled,
  11518. border: mode === "simple",
  11519. prev: true
  11520. }), BORDER_SURROUND]
  11521. }, [vue.createVNode("button", {
  11522. "type": "button",
  11523. "disabled": disabled,
  11524. "onClick": () => updateModelValue(modelValue - 1, true)
  11525. }, [slot ? slot() : props.prevText || t$5("prev")])]);
  11526. };
  11527. const renderNextButton = () => {
  11528. const {
  11529. mode,
  11530. modelValue
  11531. } = props;
  11532. const slot = slots["next-text"];
  11533. const disabled = modelValue === count.value;
  11534. return vue.createVNode("li", {
  11535. "class": [bem$l("item", {
  11536. disabled,
  11537. border: mode === "simple",
  11538. next: true
  11539. }), BORDER_SURROUND]
  11540. }, [vue.createVNode("button", {
  11541. "type": "button",
  11542. "disabled": disabled,
  11543. "onClick": () => updateModelValue(modelValue + 1, true)
  11544. }, [slot ? slot() : props.nextText || t$5("next")])]);
  11545. };
  11546. const renderPages = () => pages.value.map((page) => vue.createVNode("li", {
  11547. "class": [bem$l("item", {
  11548. active: page.active,
  11549. page: true
  11550. }), BORDER_SURROUND]
  11551. }, [vue.createVNode("button", {
  11552. "type": "button",
  11553. "aria-current": page.active || void 0,
  11554. "onClick": () => updateModelValue(page.number, true)
  11555. }, [slots.page ? slots.page(page) : page.text])]));
  11556. return () => vue.createVNode("nav", {
  11557. "role": "navigation",
  11558. "class": bem$l()
  11559. }, [vue.createVNode("ul", {
  11560. "class": bem$l("items")
  11561. }, [renderPrevButton(), props.mode === "simple" ? renderDesc() : renderPages(), renderNextButton()])]);
  11562. }
  11563. });
  11564. const Pagination = withInstall(stdin_default$q);
  11565. const [name$k, bem$k] = createNamespace("password-input");
  11566. const passwordInputProps = {
  11567. info: String,
  11568. mask: truthProp,
  11569. value: makeStringProp(""),
  11570. gutter: numericProp,
  11571. length: makeNumericProp(6),
  11572. focused: Boolean,
  11573. errorInfo: String
  11574. };
  11575. var stdin_default$p = vue.defineComponent({
  11576. name: name$k,
  11577. props: passwordInputProps,
  11578. emits: ["focus"],
  11579. setup(props, {
  11580. emit
  11581. }) {
  11582. const onTouchStart = (event) => {
  11583. event.stopPropagation();
  11584. emit("focus", event);
  11585. };
  11586. const renderPoints = () => {
  11587. const Points = [];
  11588. const {
  11589. mask,
  11590. value,
  11591. length,
  11592. gutter,
  11593. focused
  11594. } = props;
  11595. for (let i = 0; i < length; i++) {
  11596. const char = value[i];
  11597. const showBorder = i !== 0 && !gutter;
  11598. const showCursor = focused && i === value.length;
  11599. let style;
  11600. if (i !== 0 && gutter) {
  11601. style = {
  11602. marginLeft: addUnit(gutter)
  11603. };
  11604. }
  11605. Points.push(vue.createVNode("li", {
  11606. "class": [{
  11607. [BORDER_LEFT]: showBorder
  11608. }, bem$k("item", {
  11609. focus: showCursor
  11610. })],
  11611. "style": style
  11612. }, [mask ? vue.createVNode("i", {
  11613. "style": {
  11614. visibility: char ? "visible" : "hidden"
  11615. }
  11616. }, null) : char, showCursor && vue.createVNode("div", {
  11617. "class": bem$k("cursor")
  11618. }, null)]));
  11619. }
  11620. return Points;
  11621. };
  11622. return () => {
  11623. const info = props.errorInfo || props.info;
  11624. return vue.createVNode("div", {
  11625. "class": bem$k()
  11626. }, [vue.createVNode("ul", {
  11627. "class": [bem$k("security"), {
  11628. [BORDER_SURROUND]: !props.gutter
  11629. }],
  11630. "onTouchstartPassive": onTouchStart
  11631. }, [renderPoints()]), info && vue.createVNode("div", {
  11632. "class": bem$k(props.errorInfo ? "error-info" : "info")
  11633. }, [info])]);
  11634. };
  11635. }
  11636. });
  11637. const PasswordInput = withInstall(stdin_default$p);
  11638. function getWindow(node) {
  11639. if (node == null) {
  11640. return window;
  11641. }
  11642. if (node.toString() !== "[object Window]") {
  11643. var ownerDocument = node.ownerDocument;
  11644. return ownerDocument ? ownerDocument.defaultView || window : window;
  11645. }
  11646. return node;
  11647. }
  11648. function isElement(node) {
  11649. var OwnElement = getWindow(node).Element;
  11650. return node instanceof OwnElement || node instanceof Element;
  11651. }
  11652. function isHTMLElement(node) {
  11653. var OwnElement = getWindow(node).HTMLElement;
  11654. return node instanceof OwnElement || node instanceof HTMLElement;
  11655. }
  11656. function isShadowRoot(node) {
  11657. if (typeof ShadowRoot === "undefined") {
  11658. return false;
  11659. }
  11660. var OwnElement = getWindow(node).ShadowRoot;
  11661. return node instanceof OwnElement || node instanceof ShadowRoot;
  11662. }
  11663. var round = Math.round;
  11664. function getUAString() {
  11665. var uaData = navigator.userAgentData;
  11666. if (uaData != null && uaData.brands) {
  11667. return uaData.brands.map(function(item) {
  11668. return item.brand + "/" + item.version;
  11669. }).join(" ");
  11670. }
  11671. return navigator.userAgent;
  11672. }
  11673. function isLayoutViewport() {
  11674. return !/^((?!chrome|android).)*safari/i.test(getUAString());
  11675. }
  11676. function getBoundingClientRect(element, includeScale, isFixedStrategy) {
  11677. if (includeScale === void 0) {
  11678. includeScale = false;
  11679. }
  11680. if (isFixedStrategy === void 0) {
  11681. isFixedStrategy = false;
  11682. }
  11683. var clientRect = element.getBoundingClientRect();
  11684. var scaleX = 1;
  11685. var scaleY = 1;
  11686. if (includeScale && isHTMLElement(element)) {
  11687. scaleX = element.offsetWidth > 0 ? round(clientRect.width) / element.offsetWidth || 1 : 1;
  11688. scaleY = element.offsetHeight > 0 ? round(clientRect.height) / element.offsetHeight || 1 : 1;
  11689. }
  11690. var _ref = isElement(element) ? getWindow(element) : window, visualViewport = _ref.visualViewport;
  11691. var addVisualOffsets = !isLayoutViewport() && isFixedStrategy;
  11692. var x = (clientRect.left + (addVisualOffsets && visualViewport ? visualViewport.offsetLeft : 0)) / scaleX;
  11693. var y = (clientRect.top + (addVisualOffsets && visualViewport ? visualViewport.offsetTop : 0)) / scaleY;
  11694. var width2 = clientRect.width / scaleX;
  11695. var height2 = clientRect.height / scaleY;
  11696. return {
  11697. width: width2,
  11698. height: height2,
  11699. top: y,
  11700. right: x + width2,
  11701. bottom: y + height2,
  11702. left: x,
  11703. x,
  11704. y
  11705. };
  11706. }
  11707. function getWindowScroll(node) {
  11708. var win = getWindow(node);
  11709. var scrollLeft = win.pageXOffset;
  11710. var scrollTop = win.pageYOffset;
  11711. return {
  11712. scrollLeft,
  11713. scrollTop
  11714. };
  11715. }
  11716. function getHTMLElementScroll(element) {
  11717. return {
  11718. scrollLeft: element.scrollLeft,
  11719. scrollTop: element.scrollTop
  11720. };
  11721. }
  11722. function getNodeScroll(node) {
  11723. if (node === getWindow(node) || !isHTMLElement(node)) {
  11724. return getWindowScroll(node);
  11725. } else {
  11726. return getHTMLElementScroll(node);
  11727. }
  11728. }
  11729. function getNodeName(element) {
  11730. return element ? (element.nodeName || "").toLowerCase() : null;
  11731. }
  11732. function getDocumentElement(element) {
  11733. return ((isElement(element) ? element.ownerDocument : element.document) || window.document).documentElement;
  11734. }
  11735. function getWindowScrollBarX(element) {
  11736. return getBoundingClientRect(getDocumentElement(element)).left + getWindowScroll(element).scrollLeft;
  11737. }
  11738. function getComputedStyle(element) {
  11739. return getWindow(element).getComputedStyle(element);
  11740. }
  11741. function isScrollParent(element) {
  11742. var _getComputedStyle = getComputedStyle(element), overflow = _getComputedStyle.overflow, overflowX = _getComputedStyle.overflowX, overflowY = _getComputedStyle.overflowY;
  11743. return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);
  11744. }
  11745. function isElementScaled(element) {
  11746. var rect = element.getBoundingClientRect();
  11747. var scaleX = round(rect.width) / element.offsetWidth || 1;
  11748. var scaleY = round(rect.height) / element.offsetHeight || 1;
  11749. return scaleX !== 1 || scaleY !== 1;
  11750. }
  11751. function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) {
  11752. if (isFixed === void 0) {
  11753. isFixed = false;
  11754. }
  11755. var isOffsetParentAnElement = isHTMLElement(offsetParent);
  11756. var offsetParentIsScaled = isHTMLElement(offsetParent) && isElementScaled(offsetParent);
  11757. var documentElement = getDocumentElement(offsetParent);
  11758. var rect = getBoundingClientRect(elementOrVirtualElement, offsetParentIsScaled, isFixed);
  11759. var scroll = {
  11760. scrollLeft: 0,
  11761. scrollTop: 0
  11762. };
  11763. var offsets = {
  11764. x: 0,
  11765. y: 0
  11766. };
  11767. if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
  11768. if (getNodeName(offsetParent) !== "body" || isScrollParent(documentElement)) {
  11769. scroll = getNodeScroll(offsetParent);
  11770. }
  11771. if (isHTMLElement(offsetParent)) {
  11772. offsets = getBoundingClientRect(offsetParent, true);
  11773. offsets.x += offsetParent.clientLeft;
  11774. offsets.y += offsetParent.clientTop;
  11775. } else if (documentElement) {
  11776. offsets.x = getWindowScrollBarX(documentElement);
  11777. }
  11778. }
  11779. return {
  11780. x: rect.left + scroll.scrollLeft - offsets.x,
  11781. y: rect.top + scroll.scrollTop - offsets.y,
  11782. width: rect.width,
  11783. height: rect.height
  11784. };
  11785. }
  11786. function getLayoutRect(element) {
  11787. var clientRect = getBoundingClientRect(element);
  11788. var width2 = element.offsetWidth;
  11789. var height2 = element.offsetHeight;
  11790. if (Math.abs(clientRect.width - width2) <= 1) {
  11791. width2 = clientRect.width;
  11792. }
  11793. if (Math.abs(clientRect.height - height2) <= 1) {
  11794. height2 = clientRect.height;
  11795. }
  11796. return {
  11797. x: element.offsetLeft,
  11798. y: element.offsetTop,
  11799. width: width2,
  11800. height: height2
  11801. };
  11802. }
  11803. function getParentNode(element) {
  11804. if (getNodeName(element) === "html") {
  11805. return element;
  11806. }
  11807. return element.assignedSlot || element.parentNode || (isShadowRoot(element) ? element.host : null) || getDocumentElement(element);
  11808. }
  11809. function getScrollParent(node) {
  11810. if (["html", "body", "#document"].indexOf(getNodeName(node)) >= 0) {
  11811. return node.ownerDocument.body;
  11812. }
  11813. if (isHTMLElement(node) && isScrollParent(node)) {
  11814. return node;
  11815. }
  11816. return getScrollParent(getParentNode(node));
  11817. }
  11818. function listScrollParents(element, list) {
  11819. var _element$ownerDocumen;
  11820. if (list === void 0) {
  11821. list = [];
  11822. }
  11823. var scrollParent = getScrollParent(element);
  11824. var isBody = scrollParent === ((_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body);
  11825. var win = getWindow(scrollParent);
  11826. var target = isBody ? [win].concat(win.visualViewport || [], isScrollParent(scrollParent) ? scrollParent : []) : scrollParent;
  11827. var updatedList = list.concat(target);
  11828. return isBody ? updatedList : updatedList.concat(listScrollParents(getParentNode(target)));
  11829. }
  11830. function isTableElement(element) {
  11831. return ["table", "td", "th"].indexOf(getNodeName(element)) >= 0;
  11832. }
  11833. function getTrueOffsetParent(element) {
  11834. if (!isHTMLElement(element) || getComputedStyle(element).position === "fixed") {
  11835. return null;
  11836. }
  11837. return element.offsetParent;
  11838. }
  11839. function getContainingBlock(element) {
  11840. var isFirefox = /firefox/i.test(getUAString());
  11841. var isIE = /Trident/i.test(getUAString());
  11842. if (isIE && isHTMLElement(element)) {
  11843. var elementCss = getComputedStyle(element);
  11844. if (elementCss.position === "fixed") {
  11845. return null;
  11846. }
  11847. }
  11848. var currentNode = getParentNode(element);
  11849. if (isShadowRoot(currentNode)) {
  11850. currentNode = currentNode.host;
  11851. }
  11852. while (isHTMLElement(currentNode) && ["html", "body"].indexOf(getNodeName(currentNode)) < 0) {
  11853. var css = getComputedStyle(currentNode);
  11854. if (css.transform !== "none" || css.perspective !== "none" || css.contain === "paint" || ["transform", "perspective"].indexOf(css.willChange) !== -1 || isFirefox && css.willChange === "filter" || isFirefox && css.filter && css.filter !== "none") {
  11855. return currentNode;
  11856. } else {
  11857. currentNode = currentNode.parentNode;
  11858. }
  11859. }
  11860. return null;
  11861. }
  11862. function getOffsetParent(element) {
  11863. var window2 = getWindow(element);
  11864. var offsetParent = getTrueOffsetParent(element);
  11865. while (offsetParent && isTableElement(offsetParent) && getComputedStyle(offsetParent).position === "static") {
  11866. offsetParent = getTrueOffsetParent(offsetParent);
  11867. }
  11868. if (offsetParent && (getNodeName(offsetParent) === "html" || getNodeName(offsetParent) === "body" && getComputedStyle(offsetParent).position === "static")) {
  11869. return window2;
  11870. }
  11871. return offsetParent || getContainingBlock(element) || window2;
  11872. }
  11873. var top = "top";
  11874. var bottom = "bottom";
  11875. var right = "right";
  11876. var left = "left";
  11877. var auto = "auto";
  11878. var basePlacements = [top, bottom, right, left];
  11879. var start = "start";
  11880. var end = "end";
  11881. var placements = /* @__PURE__ */ [].concat(basePlacements, [auto]).reduce(function(acc, placement) {
  11882. return acc.concat([placement, placement + "-" + start, placement + "-" + end]);
  11883. }, []);
  11884. var beforeRead = "beforeRead";
  11885. var read = "read";
  11886. var afterRead = "afterRead";
  11887. var beforeMain = "beforeMain";
  11888. var main = "main";
  11889. var afterMain = "afterMain";
  11890. var beforeWrite = "beforeWrite";
  11891. var write = "write";
  11892. var afterWrite = "afterWrite";
  11893. var modifierPhases = [beforeRead, read, afterRead, beforeMain, main, afterMain, beforeWrite, write, afterWrite];
  11894. function order(modifiers) {
  11895. var map = /* @__PURE__ */ new Map();
  11896. var visited = /* @__PURE__ */ new Set();
  11897. var result = [];
  11898. modifiers.forEach(function(modifier) {
  11899. map.set(modifier.name, modifier);
  11900. });
  11901. function sort(modifier) {
  11902. visited.add(modifier.name);
  11903. var requires = [].concat(modifier.requires || [], modifier.requiresIfExists || []);
  11904. requires.forEach(function(dep) {
  11905. if (!visited.has(dep)) {
  11906. var depModifier = map.get(dep);
  11907. if (depModifier) {
  11908. sort(depModifier);
  11909. }
  11910. }
  11911. });
  11912. result.push(modifier);
  11913. }
  11914. modifiers.forEach(function(modifier) {
  11915. if (!visited.has(modifier.name)) {
  11916. sort(modifier);
  11917. }
  11918. });
  11919. return result;
  11920. }
  11921. function orderModifiers(modifiers) {
  11922. var orderedModifiers = order(modifiers);
  11923. return modifierPhases.reduce(function(acc, phase) {
  11924. return acc.concat(orderedModifiers.filter(function(modifier) {
  11925. return modifier.phase === phase;
  11926. }));
  11927. }, []);
  11928. }
  11929. function debounce(fn2) {
  11930. var pending;
  11931. return function() {
  11932. if (!pending) {
  11933. pending = new Promise(function(resolve) {
  11934. Promise.resolve().then(function() {
  11935. pending = void 0;
  11936. resolve(fn2());
  11937. });
  11938. });
  11939. }
  11940. return pending;
  11941. };
  11942. }
  11943. function format(str) {
  11944. for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  11945. args[_key - 1] = arguments[_key];
  11946. }
  11947. return [].concat(args).reduce(function(p, c) {
  11948. return p.replace(/%s/, c);
  11949. }, str);
  11950. }
  11951. var INVALID_MODIFIER_ERROR = 'Popper: modifier "%s" provided an invalid %s property, expected %s but got %s';
  11952. var MISSING_DEPENDENCY_ERROR = 'Popper: modifier "%s" requires "%s", but "%s" modifier is not available';
  11953. var VALID_PROPERTIES = ["name", "enabled", "phase", "fn", "effect", "requires", "options"];
  11954. function validateModifiers(modifiers) {
  11955. modifiers.forEach(function(modifier) {
  11956. [].concat(Object.keys(modifier), VALID_PROPERTIES).filter(function(value, index, self2) {
  11957. return self2.indexOf(value) === index;
  11958. }).forEach(function(key) {
  11959. switch (key) {
  11960. case "name":
  11961. if (typeof modifier.name !== "string") {
  11962. console.error(format(INVALID_MODIFIER_ERROR, String(modifier.name), '"name"', '"string"', '"' + String(modifier.name) + '"'));
  11963. }
  11964. break;
  11965. case "enabled":
  11966. if (typeof modifier.enabled !== "boolean") {
  11967. console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"enabled"', '"boolean"', '"' + String(modifier.enabled) + '"'));
  11968. }
  11969. break;
  11970. case "phase":
  11971. if (modifierPhases.indexOf(modifier.phase) < 0) {
  11972. console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"phase"', "either " + modifierPhases.join(", "), '"' + String(modifier.phase) + '"'));
  11973. }
  11974. break;
  11975. case "fn":
  11976. if (typeof modifier.fn !== "function") {
  11977. console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"fn"', '"function"', '"' + String(modifier.fn) + '"'));
  11978. }
  11979. break;
  11980. case "effect":
  11981. if (modifier.effect != null && typeof modifier.effect !== "function") {
  11982. console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"effect"', '"function"', '"' + String(modifier.fn) + '"'));
  11983. }
  11984. break;
  11985. case "requires":
  11986. if (modifier.requires != null && !Array.isArray(modifier.requires)) {
  11987. console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"requires"', '"array"', '"' + String(modifier.requires) + '"'));
  11988. }
  11989. break;
  11990. case "requiresIfExists":
  11991. if (!Array.isArray(modifier.requiresIfExists)) {
  11992. console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"requiresIfExists"', '"array"', '"' + String(modifier.requiresIfExists) + '"'));
  11993. }
  11994. break;
  11995. case "options":
  11996. case "data":
  11997. break;
  11998. default:
  11999. console.error('PopperJS: an invalid property has been provided to the "' + modifier.name + '" modifier, valid properties are ' + VALID_PROPERTIES.map(function(s) {
  12000. return '"' + s + '"';
  12001. }).join(", ") + '; but "' + key + '" was provided.');
  12002. }
  12003. modifier.requires && modifier.requires.forEach(function(requirement) {
  12004. if (modifiers.find(function(mod) {
  12005. return mod.name === requirement;
  12006. }) == null) {
  12007. console.error(format(MISSING_DEPENDENCY_ERROR, String(modifier.name), requirement, requirement));
  12008. }
  12009. });
  12010. });
  12011. });
  12012. }
  12013. function uniqueBy(arr, fn2) {
  12014. var identifiers = /* @__PURE__ */ new Set();
  12015. return arr.filter(function(item) {
  12016. var identifier = fn2(item);
  12017. if (!identifiers.has(identifier)) {
  12018. identifiers.add(identifier);
  12019. return true;
  12020. }
  12021. });
  12022. }
  12023. function getBasePlacement(placement) {
  12024. return placement.split("-")[0];
  12025. }
  12026. function mergeByName(modifiers) {
  12027. var merged = modifiers.reduce(function(merged2, current2) {
  12028. var existing = merged2[current2.name];
  12029. merged2[current2.name] = existing ? Object.assign({}, existing, current2, {
  12030. options: Object.assign({}, existing.options, current2.options),
  12031. data: Object.assign({}, existing.data, current2.data)
  12032. }) : current2;
  12033. return merged2;
  12034. }, {});
  12035. return Object.keys(merged).map(function(key) {
  12036. return merged[key];
  12037. });
  12038. }
  12039. function getVariation(placement) {
  12040. return placement.split("-")[1];
  12041. }
  12042. function getMainAxisFromPlacement(placement) {
  12043. return ["top", "bottom"].indexOf(placement) >= 0 ? "x" : "y";
  12044. }
  12045. function computeOffsets(_ref) {
  12046. var reference = _ref.reference, element = _ref.element, placement = _ref.placement;
  12047. var basePlacement = placement ? getBasePlacement(placement) : null;
  12048. var variation = placement ? getVariation(placement) : null;
  12049. var commonX = reference.x + reference.width / 2 - element.width / 2;
  12050. var commonY = reference.y + reference.height / 2 - element.height / 2;
  12051. var offsets;
  12052. switch (basePlacement) {
  12053. case top:
  12054. offsets = {
  12055. x: commonX,
  12056. y: reference.y - element.height
  12057. };
  12058. break;
  12059. case bottom:
  12060. offsets = {
  12061. x: commonX,
  12062. y: reference.y + reference.height
  12063. };
  12064. break;
  12065. case right:
  12066. offsets = {
  12067. x: reference.x + reference.width,
  12068. y: commonY
  12069. };
  12070. break;
  12071. case left:
  12072. offsets = {
  12073. x: reference.x - element.width,
  12074. y: commonY
  12075. };
  12076. break;
  12077. default:
  12078. offsets = {
  12079. x: reference.x,
  12080. y: reference.y
  12081. };
  12082. }
  12083. var mainAxis = basePlacement ? getMainAxisFromPlacement(basePlacement) : null;
  12084. if (mainAxis != null) {
  12085. var len = mainAxis === "y" ? "height" : "width";
  12086. switch (variation) {
  12087. case start:
  12088. offsets[mainAxis] = offsets[mainAxis] - (reference[len] / 2 - element[len] / 2);
  12089. break;
  12090. case end:
  12091. offsets[mainAxis] = offsets[mainAxis] + (reference[len] / 2 - element[len] / 2);
  12092. break;
  12093. }
  12094. }
  12095. return offsets;
  12096. }
  12097. var INVALID_ELEMENT_ERROR = "Popper: Invalid reference or popper argument provided. They must be either a DOM element or virtual element.";
  12098. var INFINITE_LOOP_ERROR = "Popper: An infinite loop in the modifiers cycle has been detected! The cycle has been interrupted to prevent a browser crash.";
  12099. var DEFAULT_OPTIONS = {
  12100. placement: "bottom",
  12101. modifiers: [],
  12102. strategy: "absolute"
  12103. };
  12104. function areValidElements() {
  12105. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  12106. args[_key] = arguments[_key];
  12107. }
  12108. return !args.some(function(element) {
  12109. return !(element && typeof element.getBoundingClientRect === "function");
  12110. });
  12111. }
  12112. function popperGenerator(generatorOptions) {
  12113. if (generatorOptions === void 0) {
  12114. generatorOptions = {};
  12115. }
  12116. var _generatorOptions = generatorOptions, _generatorOptions$def = _generatorOptions.defaultModifiers, defaultModifiers2 = _generatorOptions$def === void 0 ? [] : _generatorOptions$def, _generatorOptions$def2 = _generatorOptions.defaultOptions, defaultOptions2 = _generatorOptions$def2 === void 0 ? DEFAULT_OPTIONS : _generatorOptions$def2;
  12117. return function createPopper2(reference, popper, options) {
  12118. if (options === void 0) {
  12119. options = defaultOptions2;
  12120. }
  12121. var state = {
  12122. placement: "bottom",
  12123. orderedModifiers: [],
  12124. options: Object.assign({}, DEFAULT_OPTIONS, defaultOptions2),
  12125. modifiersData: {},
  12126. elements: {
  12127. reference,
  12128. popper
  12129. },
  12130. attributes: {},
  12131. styles: {}
  12132. };
  12133. var effectCleanupFns = [];
  12134. var isDestroyed = false;
  12135. var instance2 = {
  12136. state,
  12137. setOptions: function setOptions(setOptionsAction) {
  12138. var options2 = typeof setOptionsAction === "function" ? setOptionsAction(state.options) : setOptionsAction;
  12139. cleanupModifierEffects();
  12140. state.options = Object.assign({}, defaultOptions2, state.options, options2);
  12141. state.scrollParents = {
  12142. reference: isElement(reference) ? listScrollParents(reference) : reference.contextElement ? listScrollParents(reference.contextElement) : [],
  12143. popper: listScrollParents(popper)
  12144. };
  12145. var orderedModifiers = orderModifiers(mergeByName([].concat(defaultModifiers2, state.options.modifiers)));
  12146. state.orderedModifiers = orderedModifiers.filter(function(m) {
  12147. return m.enabled;
  12148. });
  12149. {
  12150. var modifiers = uniqueBy([].concat(orderedModifiers, state.options.modifiers), function(_ref) {
  12151. var name2 = _ref.name;
  12152. return name2;
  12153. });
  12154. validateModifiers(modifiers);
  12155. if (getBasePlacement(state.options.placement) === auto) {
  12156. var flipModifier = state.orderedModifiers.find(function(_ref2) {
  12157. var name2 = _ref2.name;
  12158. return name2 === "flip";
  12159. });
  12160. if (!flipModifier) {
  12161. console.error(['Popper: "auto" placements require the "flip" modifier be', "present and enabled to work."].join(" "));
  12162. }
  12163. }
  12164. var _getComputedStyle = getComputedStyle(popper), marginTop = _getComputedStyle.marginTop, marginRight = _getComputedStyle.marginRight, marginBottom = _getComputedStyle.marginBottom, marginLeft = _getComputedStyle.marginLeft;
  12165. if ([marginTop, marginRight, marginBottom, marginLeft].some(function(margin) {
  12166. return parseFloat(margin);
  12167. })) {
  12168. console.warn(['Popper: CSS "margin" styles cannot be used to apply padding', "between the popper and its reference element or boundary.", "To replicate margin, use the `offset` modifier, as well as", "the `padding` option in the `preventOverflow` and `flip`", "modifiers."].join(" "));
  12169. }
  12170. }
  12171. runModifierEffects();
  12172. return instance2.update();
  12173. },
  12174. forceUpdate: function forceUpdate() {
  12175. if (isDestroyed) {
  12176. return;
  12177. }
  12178. var _state$elements = state.elements, reference2 = _state$elements.reference, popper2 = _state$elements.popper;
  12179. if (!areValidElements(reference2, popper2)) {
  12180. {
  12181. console.error(INVALID_ELEMENT_ERROR);
  12182. }
  12183. return;
  12184. }
  12185. state.rects = {
  12186. reference: getCompositeRect(reference2, getOffsetParent(popper2), state.options.strategy === "fixed"),
  12187. popper: getLayoutRect(popper2)
  12188. };
  12189. state.reset = false;
  12190. state.placement = state.options.placement;
  12191. state.orderedModifiers.forEach(function(modifier) {
  12192. return state.modifiersData[modifier.name] = Object.assign({}, modifier.data);
  12193. });
  12194. var __debug_loops__ = 0;
  12195. for (var index = 0; index < state.orderedModifiers.length; index++) {
  12196. {
  12197. __debug_loops__ += 1;
  12198. if (__debug_loops__ > 100) {
  12199. console.error(INFINITE_LOOP_ERROR);
  12200. break;
  12201. }
  12202. }
  12203. if (state.reset === true) {
  12204. state.reset = false;
  12205. index = -1;
  12206. continue;
  12207. }
  12208. var _state$orderedModifie = state.orderedModifiers[index], fn2 = _state$orderedModifie.fn, _state$orderedModifie2 = _state$orderedModifie.options, _options = _state$orderedModifie2 === void 0 ? {} : _state$orderedModifie2, name2 = _state$orderedModifie.name;
  12209. if (typeof fn2 === "function") {
  12210. state = fn2({
  12211. state,
  12212. options: _options,
  12213. name: name2,
  12214. instance: instance2
  12215. }) || state;
  12216. }
  12217. }
  12218. },
  12219. update: debounce(function() {
  12220. return new Promise(function(resolve) {
  12221. instance2.forceUpdate();
  12222. resolve(state);
  12223. });
  12224. }),
  12225. destroy: function destroy() {
  12226. cleanupModifierEffects();
  12227. isDestroyed = true;
  12228. }
  12229. };
  12230. if (!areValidElements(reference, popper)) {
  12231. {
  12232. console.error(INVALID_ELEMENT_ERROR);
  12233. }
  12234. return instance2;
  12235. }
  12236. instance2.setOptions(options).then(function(state2) {
  12237. if (!isDestroyed && options.onFirstUpdate) {
  12238. options.onFirstUpdate(state2);
  12239. }
  12240. });
  12241. function runModifierEffects() {
  12242. state.orderedModifiers.forEach(function(_ref3) {
  12243. var name2 = _ref3.name, _ref3$options = _ref3.options, options2 = _ref3$options === void 0 ? {} : _ref3$options, effect3 = _ref3.effect;
  12244. if (typeof effect3 === "function") {
  12245. var cleanupFn = effect3({
  12246. state,
  12247. name: name2,
  12248. instance: instance2,
  12249. options: options2
  12250. });
  12251. var noopFn = function noopFn2() {
  12252. };
  12253. effectCleanupFns.push(cleanupFn || noopFn);
  12254. }
  12255. });
  12256. }
  12257. function cleanupModifierEffects() {
  12258. effectCleanupFns.forEach(function(fn2) {
  12259. return fn2();
  12260. });
  12261. effectCleanupFns = [];
  12262. }
  12263. return instance2;
  12264. };
  12265. }
  12266. var passive = {
  12267. passive: true
  12268. };
  12269. function effect(_ref) {
  12270. var state = _ref.state, instance2 = _ref.instance, options = _ref.options;
  12271. var _options$scroll = options.scroll, scroll = _options$scroll === void 0 ? true : _options$scroll, _options$resize = options.resize, resize = _options$resize === void 0 ? true : _options$resize;
  12272. var window2 = getWindow(state.elements.popper);
  12273. var scrollParents = [].concat(state.scrollParents.reference, state.scrollParents.popper);
  12274. if (scroll) {
  12275. scrollParents.forEach(function(scrollParent) {
  12276. scrollParent.addEventListener("scroll", instance2.update, passive);
  12277. });
  12278. }
  12279. if (resize) {
  12280. window2.addEventListener("resize", instance2.update, passive);
  12281. }
  12282. return function() {
  12283. if (scroll) {
  12284. scrollParents.forEach(function(scrollParent) {
  12285. scrollParent.removeEventListener("scroll", instance2.update, passive);
  12286. });
  12287. }
  12288. if (resize) {
  12289. window2.removeEventListener("resize", instance2.update, passive);
  12290. }
  12291. };
  12292. }
  12293. var eventListeners_default = {
  12294. name: "eventListeners",
  12295. enabled: true,
  12296. phase: "write",
  12297. fn: function fn() {
  12298. },
  12299. effect,
  12300. data: {}
  12301. };
  12302. function popperOffsets(_ref) {
  12303. var state = _ref.state, name2 = _ref.name;
  12304. state.modifiersData[name2] = computeOffsets({
  12305. reference: state.rects.reference,
  12306. element: state.rects.popper,
  12307. strategy: "absolute",
  12308. placement: state.placement
  12309. });
  12310. }
  12311. var popperOffsets_default = {
  12312. name: "popperOffsets",
  12313. enabled: true,
  12314. phase: "read",
  12315. fn: popperOffsets,
  12316. data: {}
  12317. };
  12318. var unsetSides = {
  12319. top: "auto",
  12320. right: "auto",
  12321. bottom: "auto",
  12322. left: "auto"
  12323. };
  12324. function roundOffsetsByDPR(_ref) {
  12325. var x = _ref.x, y = _ref.y;
  12326. var win = window;
  12327. var dpr = win.devicePixelRatio || 1;
  12328. return {
  12329. x: round(x * dpr) / dpr || 0,
  12330. y: round(y * dpr) / dpr || 0
  12331. };
  12332. }
  12333. function mapToStyles(_ref2) {
  12334. var _Object$assign2;
  12335. var popper = _ref2.popper, popperRect = _ref2.popperRect, placement = _ref2.placement, variation = _ref2.variation, offsets = _ref2.offsets, position = _ref2.position, gpuAcceleration = _ref2.gpuAcceleration, adaptive = _ref2.adaptive, roundOffsets = _ref2.roundOffsets, isFixed = _ref2.isFixed;
  12336. var _offsets$x = offsets.x, x = _offsets$x === void 0 ? 0 : _offsets$x, _offsets$y = offsets.y, y = _offsets$y === void 0 ? 0 : _offsets$y;
  12337. var _ref3 = typeof roundOffsets === "function" ? roundOffsets({
  12338. x,
  12339. y
  12340. }) : {
  12341. x,
  12342. y
  12343. };
  12344. x = _ref3.x;
  12345. y = _ref3.y;
  12346. var hasX = offsets.hasOwnProperty("x");
  12347. var hasY = offsets.hasOwnProperty("y");
  12348. var sideX = left;
  12349. var sideY = top;
  12350. var win = window;
  12351. if (adaptive) {
  12352. var offsetParent = getOffsetParent(popper);
  12353. var heightProp = "clientHeight";
  12354. var widthProp = "clientWidth";
  12355. if (offsetParent === getWindow(popper)) {
  12356. offsetParent = getDocumentElement(popper);
  12357. if (getComputedStyle(offsetParent).position !== "static" && position === "absolute") {
  12358. heightProp = "scrollHeight";
  12359. widthProp = "scrollWidth";
  12360. }
  12361. }
  12362. offsetParent = offsetParent;
  12363. if (placement === top || (placement === left || placement === right) && variation === end) {
  12364. sideY = bottom;
  12365. var offsetY = isFixed && offsetParent === win && win.visualViewport ? win.visualViewport.height : offsetParent[heightProp];
  12366. y -= offsetY - popperRect.height;
  12367. y *= gpuAcceleration ? 1 : -1;
  12368. }
  12369. if (placement === left || (placement === top || placement === bottom) && variation === end) {
  12370. sideX = right;
  12371. var offsetX = isFixed && offsetParent === win && win.visualViewport ? win.visualViewport.width : offsetParent[widthProp];
  12372. x -= offsetX - popperRect.width;
  12373. x *= gpuAcceleration ? 1 : -1;
  12374. }
  12375. }
  12376. var commonStyles = Object.assign({
  12377. position
  12378. }, adaptive && unsetSides);
  12379. var _ref4 = roundOffsets === true ? roundOffsetsByDPR({
  12380. x,
  12381. y
  12382. }) : {
  12383. x,
  12384. y
  12385. };
  12386. x = _ref4.x;
  12387. y = _ref4.y;
  12388. if (gpuAcceleration) {
  12389. var _Object$assign;
  12390. return Object.assign({}, commonStyles, (_Object$assign = {}, _Object$assign[sideY] = hasY ? "0" : "", _Object$assign[sideX] = hasX ? "0" : "", _Object$assign.transform = (win.devicePixelRatio || 1) <= 1 ? "translate(" + x + "px, " + y + "px)" : "translate3d(" + x + "px, " + y + "px, 0)", _Object$assign));
  12391. }
  12392. return Object.assign({}, commonStyles, (_Object$assign2 = {}, _Object$assign2[sideY] = hasY ? y + "px" : "", _Object$assign2[sideX] = hasX ? x + "px" : "", _Object$assign2.transform = "", _Object$assign2));
  12393. }
  12394. function computeStyles(_ref5) {
  12395. var state = _ref5.state, options = _ref5.options;
  12396. var _options$gpuAccelerat = options.gpuAcceleration, gpuAcceleration = _options$gpuAccelerat === void 0 ? true : _options$gpuAccelerat, _options$adaptive = options.adaptive, adaptive = _options$adaptive === void 0 ? true : _options$adaptive, _options$roundOffsets = options.roundOffsets, roundOffsets = _options$roundOffsets === void 0 ? true : _options$roundOffsets;
  12397. {
  12398. var transitionProperty = getComputedStyle(state.elements.popper).transitionProperty || "";
  12399. if (adaptive && ["transform", "top", "right", "bottom", "left"].some(function(property) {
  12400. return transitionProperty.indexOf(property) >= 0;
  12401. })) {
  12402. console.warn(["Popper: Detected CSS transitions on at least one of the following", 'CSS properties: "transform", "top", "right", "bottom", "left".', "\n\n", 'Disable the "computeStyles" modifier\'s `adaptive` option to allow', "for smooth transitions, or remove these properties from the CSS", "transition declaration on the popper element if only transitioning", "opacity or background-color for example.", "\n\n", "We recommend using the popper element as a wrapper around an inner", "element that can have any CSS property transitioned for animations."].join(" "));
  12403. }
  12404. }
  12405. var commonStyles = {
  12406. placement: getBasePlacement(state.placement),
  12407. variation: getVariation(state.placement),
  12408. popper: state.elements.popper,
  12409. popperRect: state.rects.popper,
  12410. gpuAcceleration,
  12411. isFixed: state.options.strategy === "fixed"
  12412. };
  12413. if (state.modifiersData.popperOffsets != null) {
  12414. state.styles.popper = Object.assign({}, state.styles.popper, mapToStyles(Object.assign({}, commonStyles, {
  12415. offsets: state.modifiersData.popperOffsets,
  12416. position: state.options.strategy,
  12417. adaptive,
  12418. roundOffsets
  12419. })));
  12420. }
  12421. if (state.modifiersData.arrow != null) {
  12422. state.styles.arrow = Object.assign({}, state.styles.arrow, mapToStyles(Object.assign({}, commonStyles, {
  12423. offsets: state.modifiersData.arrow,
  12424. position: "absolute",
  12425. adaptive: false,
  12426. roundOffsets
  12427. })));
  12428. }
  12429. state.attributes.popper = Object.assign({}, state.attributes.popper, {
  12430. "data-popper-placement": state.placement
  12431. });
  12432. }
  12433. var computeStyles_default = {
  12434. name: "computeStyles",
  12435. enabled: true,
  12436. phase: "beforeWrite",
  12437. fn: computeStyles,
  12438. data: {}
  12439. };
  12440. function applyStyles(_ref) {
  12441. var state = _ref.state;
  12442. Object.keys(state.elements).forEach(function(name2) {
  12443. var style = state.styles[name2] || {};
  12444. var attributes = state.attributes[name2] || {};
  12445. var element = state.elements[name2];
  12446. if (!isHTMLElement(element) || !getNodeName(element)) {
  12447. return;
  12448. }
  12449. Object.assign(element.style, style);
  12450. Object.keys(attributes).forEach(function(name22) {
  12451. var value = attributes[name22];
  12452. if (value === false) {
  12453. element.removeAttribute(name22);
  12454. } else {
  12455. element.setAttribute(name22, value === true ? "" : value);
  12456. }
  12457. });
  12458. });
  12459. }
  12460. function effect2(_ref2) {
  12461. var state = _ref2.state;
  12462. var initialStyles = {
  12463. popper: {
  12464. position: state.options.strategy,
  12465. left: "0",
  12466. top: "0",
  12467. margin: "0"
  12468. },
  12469. arrow: {
  12470. position: "absolute"
  12471. },
  12472. reference: {}
  12473. };
  12474. Object.assign(state.elements.popper.style, initialStyles.popper);
  12475. state.styles = initialStyles;
  12476. if (state.elements.arrow) {
  12477. Object.assign(state.elements.arrow.style, initialStyles.arrow);
  12478. }
  12479. return function() {
  12480. Object.keys(state.elements).forEach(function(name2) {
  12481. var element = state.elements[name2];
  12482. var attributes = state.attributes[name2] || {};
  12483. var styleProperties = Object.keys(state.styles.hasOwnProperty(name2) ? state.styles[name2] : initialStyles[name2]);
  12484. var style = styleProperties.reduce(function(style2, property) {
  12485. style2[property] = "";
  12486. return style2;
  12487. }, {});
  12488. if (!isHTMLElement(element) || !getNodeName(element)) {
  12489. return;
  12490. }
  12491. Object.assign(element.style, style);
  12492. Object.keys(attributes).forEach(function(attribute) {
  12493. element.removeAttribute(attribute);
  12494. });
  12495. });
  12496. };
  12497. }
  12498. var applyStyles_default = {
  12499. name: "applyStyles",
  12500. enabled: true,
  12501. phase: "write",
  12502. fn: applyStyles,
  12503. effect: effect2,
  12504. requires: ["computeStyles"]
  12505. };
  12506. var defaultModifiers = [eventListeners_default, popperOffsets_default, computeStyles_default, applyStyles_default];
  12507. var createPopper = /* @__PURE__ */ popperGenerator({
  12508. defaultModifiers
  12509. });
  12510. function distanceAndSkiddingToXY(placement, rects, offset2) {
  12511. var basePlacement = getBasePlacement(placement);
  12512. var invertDistance = [left, top].indexOf(basePlacement) >= 0 ? -1 : 1;
  12513. var _ref = typeof offset2 === "function" ? offset2(Object.assign({}, rects, {
  12514. placement
  12515. })) : offset2, skidding = _ref[0], distance = _ref[1];
  12516. skidding = skidding || 0;
  12517. distance = (distance || 0) * invertDistance;
  12518. return [left, right].indexOf(basePlacement) >= 0 ? {
  12519. x: distance,
  12520. y: skidding
  12521. } : {
  12522. x: skidding,
  12523. y: distance
  12524. };
  12525. }
  12526. function offset(_ref2) {
  12527. var state = _ref2.state, options = _ref2.options, name2 = _ref2.name;
  12528. var _options$offset = options.offset, offset2 = _options$offset === void 0 ? [0, 0] : _options$offset;
  12529. var data = placements.reduce(function(acc, placement) {
  12530. acc[placement] = distanceAndSkiddingToXY(placement, state.rects, offset2);
  12531. return acc;
  12532. }, {});
  12533. var _data$state$placement = data[state.placement], x = _data$state$placement.x, y = _data$state$placement.y;
  12534. if (state.modifiersData.popperOffsets != null) {
  12535. state.modifiersData.popperOffsets.x += x;
  12536. state.modifiersData.popperOffsets.y += y;
  12537. }
  12538. state.modifiersData[name2] = data;
  12539. }
  12540. var offset_default = {
  12541. name: "offset",
  12542. enabled: true,
  12543. phase: "main",
  12544. requires: ["popperOffsets"],
  12545. fn: offset
  12546. };
  12547. const [name$j, bem$j] = createNamespace("popover");
  12548. const popupProps = ["show", "overlay", "duration", "teleport", "overlayStyle", "overlayClass", "closeOnClickOverlay"];
  12549. const popoverProps = {
  12550. show: Boolean,
  12551. theme: makeStringProp("light"),
  12552. overlay: Boolean,
  12553. actions: makeArrayProp(),
  12554. trigger: makeStringProp("click"),
  12555. duration: numericProp,
  12556. showArrow: truthProp,
  12557. placement: makeStringProp("bottom"),
  12558. iconPrefix: String,
  12559. overlayClass: unknownProp,
  12560. overlayStyle: Object,
  12561. closeOnClickAction: truthProp,
  12562. closeOnClickOverlay: truthProp,
  12563. closeOnClickOutside: truthProp,
  12564. offset: {
  12565. type: Array,
  12566. default: () => [0, 8]
  12567. },
  12568. teleport: {
  12569. type: [String, Object],
  12570. default: "body"
  12571. }
  12572. };
  12573. var stdin_default$o = vue.defineComponent({
  12574. name: name$j,
  12575. props: popoverProps,
  12576. emits: ["select", "touchstart", "update:show"],
  12577. setup(props, {
  12578. emit,
  12579. slots,
  12580. attrs
  12581. }) {
  12582. let popper;
  12583. const popupRef = vue.ref();
  12584. const wrapperRef = vue.ref();
  12585. const popoverRef = vue.ref();
  12586. const getPopoverOptions = () => ({
  12587. placement: props.placement,
  12588. modifiers: [{
  12589. name: "computeStyles",
  12590. options: {
  12591. adaptive: false,
  12592. gpuAcceleration: false
  12593. }
  12594. }, extend({}, offset_default, {
  12595. options: {
  12596. offset: props.offset
  12597. }
  12598. })]
  12599. });
  12600. const createPopperInstance = () => {
  12601. if (wrapperRef.value && popoverRef.value) {
  12602. return createPopper(wrapperRef.value, popoverRef.value.popupRef.value, getPopoverOptions());
  12603. }
  12604. return null;
  12605. };
  12606. const updateLocation = () => {
  12607. vue.nextTick(() => {
  12608. if (!props.show) {
  12609. return;
  12610. }
  12611. if (!popper) {
  12612. popper = createPopperInstance();
  12613. } else {
  12614. popper.setOptions(getPopoverOptions());
  12615. }
  12616. });
  12617. };
  12618. const updateShow = (value) => emit("update:show", value);
  12619. const onClickWrapper = () => {
  12620. if (props.trigger === "click") {
  12621. updateShow(!props.show);
  12622. }
  12623. };
  12624. const onClickAction = (action, index) => {
  12625. if (action.disabled) {
  12626. return;
  12627. }
  12628. emit("select", action, index);
  12629. if (props.closeOnClickAction) {
  12630. updateShow(false);
  12631. }
  12632. };
  12633. const onClickAway = () => {
  12634. if (props.show && props.closeOnClickOutside && (!props.overlay || props.closeOnClickOverlay)) {
  12635. updateShow(false);
  12636. }
  12637. };
  12638. const renderActionContent = (action, index) => {
  12639. if (slots.action) {
  12640. return slots.action({
  12641. action,
  12642. index
  12643. });
  12644. }
  12645. return [action.icon && vue.createVNode(Icon, {
  12646. "name": action.icon,
  12647. "classPrefix": props.iconPrefix,
  12648. "class": bem$j("action-icon")
  12649. }, null), vue.createVNode("div", {
  12650. "class": [bem$j("action-text"), BORDER_BOTTOM]
  12651. }, [action.text])];
  12652. };
  12653. const renderAction = (action, index) => {
  12654. const {
  12655. icon,
  12656. color,
  12657. disabled,
  12658. className
  12659. } = action;
  12660. return vue.createVNode("div", {
  12661. "role": "menuitem",
  12662. "class": [bem$j("action", {
  12663. disabled,
  12664. "with-icon": icon
  12665. }), className],
  12666. "style": {
  12667. color
  12668. },
  12669. "tabindex": disabled ? void 0 : 0,
  12670. "aria-disabled": disabled || void 0,
  12671. "onClick": () => onClickAction(action, index)
  12672. }, [renderActionContent(action, index)]);
  12673. };
  12674. vue.onMounted(() => {
  12675. updateLocation();
  12676. vue.watchEffect(() => {
  12677. var _a;
  12678. popupRef.value = (_a = popoverRef.value) == null ? void 0 : _a.popupRef.value;
  12679. });
  12680. });
  12681. vue.onBeforeUnmount(() => {
  12682. if (popper) {
  12683. popper.destroy();
  12684. popper = null;
  12685. }
  12686. });
  12687. vue.watch(() => [props.show, props.offset, props.placement], updateLocation);
  12688. useClickAway([wrapperRef, popupRef], onClickAway, {
  12689. eventName: "touchstart"
  12690. });
  12691. return () => {
  12692. var _a;
  12693. return vue.createVNode(vue.Fragment, null, [vue.createVNode("span", {
  12694. "ref": wrapperRef,
  12695. "class": bem$j("wrapper"),
  12696. "onClick": onClickWrapper
  12697. }, [(_a = slots.reference) == null ? void 0 : _a.call(slots)]), vue.createVNode(Popup, vue.mergeProps({
  12698. "ref": popoverRef,
  12699. "class": bem$j([props.theme]),
  12700. "position": "",
  12701. "transition": "van-popover-zoom",
  12702. "lockScroll": false,
  12703. "onUpdate:show": updateShow
  12704. }, attrs, pick(props, popupProps)), {
  12705. default: () => [props.showArrow && vue.createVNode("div", {
  12706. "class": bem$j("arrow")
  12707. }, null), vue.createVNode("div", {
  12708. "role": "menu",
  12709. "class": bem$j("content")
  12710. }, [slots.default ? slots.default() : props.actions.map(renderAction)])]
  12711. })]);
  12712. };
  12713. }
  12714. });
  12715. const Popover = withInstall(stdin_default$o);
  12716. const [name$i, bem$i] = createNamespace("progress");
  12717. const progressProps = {
  12718. color: String,
  12719. inactive: Boolean,
  12720. pivotText: String,
  12721. textColor: String,
  12722. showPivot: truthProp,
  12723. pivotColor: String,
  12724. trackColor: String,
  12725. strokeWidth: numericProp,
  12726. percentage: {
  12727. type: numericProp,
  12728. default: 0,
  12729. validator: (value) => value >= 0 && value <= 100
  12730. }
  12731. };
  12732. var stdin_default$n = vue.defineComponent({
  12733. name: name$i,
  12734. props: progressProps,
  12735. setup(props) {
  12736. const background = vue.computed(() => props.inactive ? void 0 : props.color);
  12737. const renderPivot = () => {
  12738. const {
  12739. textColor,
  12740. pivotText,
  12741. pivotColor,
  12742. percentage
  12743. } = props;
  12744. const text = pivotText != null ? pivotText : `${percentage}%`;
  12745. if (props.showPivot && text) {
  12746. const style = {
  12747. color: textColor,
  12748. left: `${+percentage}%`,
  12749. transform: `translate(-${+percentage}%,-50%)`,
  12750. background: pivotColor || background.value
  12751. };
  12752. return vue.createVNode("span", {
  12753. "style": style,
  12754. "class": bem$i("pivot", {
  12755. inactive: props.inactive
  12756. })
  12757. }, [text]);
  12758. }
  12759. };
  12760. return () => {
  12761. const {
  12762. trackColor,
  12763. percentage,
  12764. strokeWidth
  12765. } = props;
  12766. const rootStyle = {
  12767. background: trackColor,
  12768. height: addUnit(strokeWidth)
  12769. };
  12770. const portionStyle = {
  12771. width: `${percentage}%`,
  12772. background: background.value
  12773. };
  12774. return vue.createVNode("div", {
  12775. "class": bem$i(),
  12776. "style": rootStyle
  12777. }, [vue.createVNode("span", {
  12778. "class": bem$i("portion", {
  12779. inactive: props.inactive
  12780. }),
  12781. "style": portionStyle
  12782. }, null), renderPivot()]);
  12783. };
  12784. }
  12785. });
  12786. const Progress = withInstall(stdin_default$n);
  12787. const [name$h, bem$h, t$4] = createNamespace("pull-refresh");
  12788. const DEFAULT_HEAD_HEIGHT = 50;
  12789. const TEXT_STATUS = ["pulling", "loosing", "success"];
  12790. const pullRefreshProps = {
  12791. disabled: Boolean,
  12792. modelValue: Boolean,
  12793. headHeight: makeNumericProp(DEFAULT_HEAD_HEIGHT),
  12794. successText: String,
  12795. pullingText: String,
  12796. loosingText: String,
  12797. loadingText: String,
  12798. pullDistance: numericProp,
  12799. successDuration: makeNumericProp(500),
  12800. animationDuration: makeNumericProp(300)
  12801. };
  12802. var stdin_default$m = vue.defineComponent({
  12803. name: name$h,
  12804. props: pullRefreshProps,
  12805. emits: ["change", "refresh", "update:modelValue"],
  12806. setup(props, {
  12807. emit,
  12808. slots
  12809. }) {
  12810. let reachTop;
  12811. const root = vue.ref();
  12812. const track = vue.ref();
  12813. const scrollParent = useScrollParent(root);
  12814. const state = vue.reactive({
  12815. status: "normal",
  12816. distance: 0,
  12817. duration: 0
  12818. });
  12819. const touch = useTouch();
  12820. const getHeadStyle = () => {
  12821. if (props.headHeight !== DEFAULT_HEAD_HEIGHT) {
  12822. return {
  12823. height: `${props.headHeight}px`
  12824. };
  12825. }
  12826. };
  12827. const isTouchable = () => state.status !== "loading" && state.status !== "success" && !props.disabled;
  12828. const ease = (distance) => {
  12829. const pullDistance = +(props.pullDistance || props.headHeight);
  12830. if (distance > pullDistance) {
  12831. if (distance < pullDistance * 2) {
  12832. distance = pullDistance + (distance - pullDistance) / 2;
  12833. } else {
  12834. distance = pullDistance * 1.5 + (distance - pullDistance * 2) / 4;
  12835. }
  12836. }
  12837. return Math.round(distance);
  12838. };
  12839. const setStatus = (distance, isLoading) => {
  12840. const pullDistance = +(props.pullDistance || props.headHeight);
  12841. state.distance = distance;
  12842. if (isLoading) {
  12843. state.status = "loading";
  12844. } else if (distance === 0) {
  12845. state.status = "normal";
  12846. } else if (distance < pullDistance) {
  12847. state.status = "pulling";
  12848. } else {
  12849. state.status = "loosing";
  12850. }
  12851. emit("change", {
  12852. status: state.status,
  12853. distance
  12854. });
  12855. };
  12856. const getStatusText = () => {
  12857. const {
  12858. status
  12859. } = state;
  12860. if (status === "normal") {
  12861. return "";
  12862. }
  12863. return props[`${status}Text`] || t$4(status);
  12864. };
  12865. const renderStatus = () => {
  12866. const {
  12867. status,
  12868. distance
  12869. } = state;
  12870. if (slots[status]) {
  12871. return slots[status]({
  12872. distance
  12873. });
  12874. }
  12875. const nodes = [];
  12876. if (TEXT_STATUS.includes(status)) {
  12877. nodes.push(vue.createVNode("div", {
  12878. "class": bem$h("text")
  12879. }, [getStatusText()]));
  12880. }
  12881. if (status === "loading") {
  12882. nodes.push(vue.createVNode(Loading, {
  12883. "class": bem$h("loading")
  12884. }, {
  12885. default: getStatusText
  12886. }));
  12887. }
  12888. return nodes;
  12889. };
  12890. const showSuccessTip = () => {
  12891. state.status = "success";
  12892. setTimeout(() => {
  12893. setStatus(0);
  12894. }, +props.successDuration);
  12895. };
  12896. const checkPosition = (event) => {
  12897. reachTop = getScrollTop(scrollParent.value) === 0;
  12898. if (reachTop) {
  12899. state.duration = 0;
  12900. touch.start(event);
  12901. }
  12902. };
  12903. const onTouchStart = (event) => {
  12904. if (isTouchable()) {
  12905. checkPosition(event);
  12906. }
  12907. };
  12908. const onTouchMove = (event) => {
  12909. if (isTouchable()) {
  12910. if (!reachTop) {
  12911. checkPosition(event);
  12912. }
  12913. const {
  12914. deltaY
  12915. } = touch;
  12916. touch.move(event);
  12917. if (reachTop && deltaY.value >= 0 && touch.isVertical()) {
  12918. preventDefault(event);
  12919. setStatus(ease(deltaY.value));
  12920. }
  12921. }
  12922. };
  12923. const onTouchEnd = () => {
  12924. if (reachTop && touch.deltaY.value && isTouchable()) {
  12925. state.duration = +props.animationDuration;
  12926. if (state.status === "loosing") {
  12927. setStatus(+props.headHeight, true);
  12928. emit("update:modelValue", true);
  12929. vue.nextTick(() => emit("refresh"));
  12930. } else {
  12931. setStatus(0);
  12932. }
  12933. }
  12934. };
  12935. vue.watch(() => props.modelValue, (value) => {
  12936. state.duration = +props.animationDuration;
  12937. if (value) {
  12938. setStatus(+props.headHeight, true);
  12939. } else if (slots.success || props.successText) {
  12940. showSuccessTip();
  12941. } else {
  12942. setStatus(0, false);
  12943. }
  12944. });
  12945. useEventListener("touchmove", onTouchMove, {
  12946. target: track
  12947. });
  12948. return () => {
  12949. var _a;
  12950. const trackStyle = {
  12951. transitionDuration: `${state.duration}ms`,
  12952. transform: state.distance ? `translate3d(0,${state.distance}px, 0)` : ""
  12953. };
  12954. return vue.createVNode("div", {
  12955. "ref": root,
  12956. "class": bem$h()
  12957. }, [vue.createVNode("div", {
  12958. "ref": track,
  12959. "class": bem$h("track"),
  12960. "style": trackStyle,
  12961. "onTouchstartPassive": onTouchStart,
  12962. "onTouchend": onTouchEnd,
  12963. "onTouchcancel": onTouchEnd
  12964. }, [vue.createVNode("div", {
  12965. "class": bem$h("head"),
  12966. "style": getHeadStyle()
  12967. }, [renderStatus()]), (_a = slots.default) == null ? void 0 : _a.call(slots)])]);
  12968. };
  12969. }
  12970. });
  12971. const PullRefresh = withInstall(stdin_default$m);
  12972. const [name$g, bem$g] = createNamespace("rate");
  12973. function getRateStatus(value, index, allowHalf, readonly) {
  12974. if (value >= index) {
  12975. return {
  12976. status: "full",
  12977. value: 1
  12978. };
  12979. }
  12980. if (value + 0.5 >= index && allowHalf && !readonly) {
  12981. return {
  12982. status: "half",
  12983. value: 0.5
  12984. };
  12985. }
  12986. if (value + 1 >= index && allowHalf && readonly) {
  12987. const cardinal = 10 ** 10;
  12988. return {
  12989. status: "half",
  12990. value: Math.round((value - index + 1) * cardinal) / cardinal
  12991. };
  12992. }
  12993. return {
  12994. status: "void",
  12995. value: 0
  12996. };
  12997. }
  12998. const rateProps = {
  12999. size: numericProp,
  13000. icon: makeStringProp("star"),
  13001. color: String,
  13002. count: makeNumericProp(5),
  13003. gutter: numericProp,
  13004. readonly: Boolean,
  13005. disabled: Boolean,
  13006. voidIcon: makeStringProp("star-o"),
  13007. allowHalf: Boolean,
  13008. voidColor: String,
  13009. touchable: truthProp,
  13010. iconPrefix: String,
  13011. modelValue: makeNumberProp(0),
  13012. disabledColor: String
  13013. };
  13014. var stdin_default$l = vue.defineComponent({
  13015. name: name$g,
  13016. props: rateProps,
  13017. emits: ["change", "update:modelValue"],
  13018. setup(props, {
  13019. emit
  13020. }) {
  13021. const touch = useTouch();
  13022. const [itemRefs, setItemRefs] = useRefs();
  13023. const groupRef = vue.ref();
  13024. const untouchable = () => props.readonly || props.disabled || !props.touchable;
  13025. const list = vue.computed(() => Array(+props.count).fill("").map((_, i) => getRateStatus(props.modelValue, i + 1, props.allowHalf, props.readonly)));
  13026. let ranges;
  13027. let groupRefRect;
  13028. let minRectTop = Number.MAX_SAFE_INTEGER;
  13029. let maxRectTop = Number.MIN_SAFE_INTEGER;
  13030. const updateRanges = () => {
  13031. groupRefRect = useRect(groupRef);
  13032. const rects = itemRefs.value.map(useRect);
  13033. ranges = [];
  13034. rects.forEach((rect, index) => {
  13035. minRectTop = Math.min(rect.top, minRectTop);
  13036. maxRectTop = Math.max(rect.top, maxRectTop);
  13037. if (props.allowHalf) {
  13038. ranges.push({
  13039. score: index + 0.5,
  13040. left: rect.left,
  13041. top: rect.top,
  13042. height: rect.height
  13043. }, {
  13044. score: index + 1,
  13045. left: rect.left + rect.width / 2,
  13046. top: rect.top,
  13047. height: rect.height
  13048. });
  13049. } else {
  13050. ranges.push({
  13051. score: index + 1,
  13052. left: rect.left,
  13053. top: rect.top,
  13054. height: rect.height
  13055. });
  13056. }
  13057. });
  13058. };
  13059. const getScoreByPosition = (x, y) => {
  13060. for (let i = ranges.length - 1; i > 0; i--) {
  13061. if (y >= groupRefRect.top && y <= groupRefRect.bottom) {
  13062. if (x > ranges[i].left && y >= ranges[i].top && y <= ranges[i].top + ranges[i].height) {
  13063. return ranges[i].score;
  13064. }
  13065. } else {
  13066. const curTop = y < groupRefRect.top ? minRectTop : maxRectTop;
  13067. if (x > ranges[i].left && ranges[i].top === curTop) {
  13068. return ranges[i].score;
  13069. }
  13070. }
  13071. }
  13072. return props.allowHalf ? 0.5 : 1;
  13073. };
  13074. const select = (index) => {
  13075. if (!props.disabled && !props.readonly && index !== props.modelValue) {
  13076. emit("update:modelValue", index);
  13077. emit("change", index);
  13078. }
  13079. };
  13080. const onTouchStart = (event) => {
  13081. if (untouchable()) {
  13082. return;
  13083. }
  13084. touch.start(event);
  13085. updateRanges();
  13086. };
  13087. const onTouchMove = (event) => {
  13088. if (untouchable()) {
  13089. return;
  13090. }
  13091. touch.move(event);
  13092. if (touch.isHorizontal()) {
  13093. const {
  13094. clientX,
  13095. clientY
  13096. } = event.touches[0];
  13097. preventDefault(event);
  13098. select(getScoreByPosition(clientX, clientY));
  13099. }
  13100. };
  13101. const renderStar = (item, index) => {
  13102. const {
  13103. icon,
  13104. size,
  13105. color,
  13106. count,
  13107. gutter,
  13108. voidIcon,
  13109. disabled,
  13110. voidColor,
  13111. allowHalf,
  13112. iconPrefix,
  13113. disabledColor
  13114. } = props;
  13115. const score = index + 1;
  13116. const isFull = item.status === "full";
  13117. const isVoid = item.status === "void";
  13118. const renderHalf = allowHalf && item.value > 0 && item.value < 1;
  13119. let style;
  13120. if (gutter && score !== +count) {
  13121. style = {
  13122. paddingRight: addUnit(gutter)
  13123. };
  13124. }
  13125. const onClickItem = (event) => {
  13126. updateRanges();
  13127. select(allowHalf ? getScoreByPosition(event.clientX, event.clientY) : score);
  13128. };
  13129. return vue.createVNode("div", {
  13130. "key": index,
  13131. "ref": setItemRefs(index),
  13132. "role": "radio",
  13133. "style": style,
  13134. "class": bem$g("item"),
  13135. "tabindex": disabled ? void 0 : 0,
  13136. "aria-setsize": count,
  13137. "aria-posinset": score,
  13138. "aria-checked": !isVoid,
  13139. "onClick": onClickItem
  13140. }, [vue.createVNode(Icon, {
  13141. "size": size,
  13142. "name": isFull ? icon : voidIcon,
  13143. "class": bem$g("icon", {
  13144. disabled,
  13145. full: isFull
  13146. }),
  13147. "color": disabled ? disabledColor : isFull ? color : voidColor,
  13148. "classPrefix": iconPrefix
  13149. }, null), renderHalf && vue.createVNode(Icon, {
  13150. "size": size,
  13151. "style": {
  13152. width: item.value + "em"
  13153. },
  13154. "name": isVoid ? voidIcon : icon,
  13155. "class": bem$g("icon", ["half", {
  13156. disabled,
  13157. full: !isVoid
  13158. }]),
  13159. "color": disabled ? disabledColor : isVoid ? voidColor : color,
  13160. "classPrefix": iconPrefix
  13161. }, null)]);
  13162. };
  13163. useCustomFieldValue(() => props.modelValue);
  13164. useEventListener("touchmove", onTouchMove, {
  13165. target: groupRef
  13166. });
  13167. return () => vue.createVNode("div", {
  13168. "ref": groupRef,
  13169. "role": "radiogroup",
  13170. "class": bem$g({
  13171. readonly: props.readonly,
  13172. disabled: props.disabled
  13173. }),
  13174. "tabindex": props.disabled ? void 0 : 0,
  13175. "aria-disabled": props.disabled,
  13176. "aria-readonly": props.readonly,
  13177. "onTouchstartPassive": onTouchStart
  13178. }, [list.value.map(renderStar)]);
  13179. }
  13180. });
  13181. const Rate = withInstall(stdin_default$l);
  13182. const Row = withInstall(stdin_default$V);
  13183. const [name$f, bem$f, t$3] = createNamespace("search");
  13184. const searchProps = extend({}, fieldSharedProps, {
  13185. label: String,
  13186. shape: makeStringProp("square"),
  13187. leftIcon: makeStringProp("search"),
  13188. clearable: truthProp,
  13189. actionText: String,
  13190. background: String,
  13191. showAction: Boolean
  13192. });
  13193. var stdin_default$k = vue.defineComponent({
  13194. name: name$f,
  13195. props: searchProps,
  13196. emits: ["blur", "focus", "clear", "search", "cancel", "click-input", "click-left-icon", "click-right-icon", "update:modelValue"],
  13197. setup(props, {
  13198. emit,
  13199. slots,
  13200. attrs
  13201. }) {
  13202. const id = useId();
  13203. const filedRef = vue.ref();
  13204. const onCancel = () => {
  13205. if (!slots.action) {
  13206. emit("update:modelValue", "");
  13207. emit("cancel");
  13208. }
  13209. };
  13210. const onKeypress = (event) => {
  13211. const ENTER_CODE = 13;
  13212. if (event.keyCode === ENTER_CODE) {
  13213. preventDefault(event);
  13214. emit("search", props.modelValue);
  13215. }
  13216. };
  13217. const getInputId = () => props.id || `${id}-input`;
  13218. const renderLabel = () => {
  13219. if (slots.label || props.label) {
  13220. return vue.createVNode("label", {
  13221. "class": bem$f("label"),
  13222. "for": getInputId()
  13223. }, [slots.label ? slots.label() : props.label]);
  13224. }
  13225. };
  13226. const renderAction = () => {
  13227. if (props.showAction) {
  13228. const text = props.actionText || t$3("cancel");
  13229. return vue.createVNode("div", {
  13230. "class": bem$f("action"),
  13231. "role": "button",
  13232. "tabindex": 0,
  13233. "onClick": onCancel
  13234. }, [slots.action ? slots.action() : text]);
  13235. }
  13236. };
  13237. const blur = () => {
  13238. var _a;
  13239. return (_a = filedRef.value) == null ? void 0 : _a.blur();
  13240. };
  13241. const focus = () => {
  13242. var _a;
  13243. return (_a = filedRef.value) == null ? void 0 : _a.focus();
  13244. };
  13245. const onBlur = (event) => emit("blur", event);
  13246. const onFocus = (event) => emit("focus", event);
  13247. const onClear = (event) => emit("clear", event);
  13248. const onClickInput = (event) => emit("click-input", event);
  13249. const onClickLeftIcon = (event) => emit("click-left-icon", event);
  13250. const onClickRightIcon = (event) => emit("click-right-icon", event);
  13251. const fieldPropNames = Object.keys(fieldSharedProps);
  13252. const renderField = () => {
  13253. const fieldAttrs = extend({}, attrs, pick(props, fieldPropNames), {
  13254. id: getInputId()
  13255. });
  13256. const onInput = (value) => emit("update:modelValue", value);
  13257. return vue.createVNode(Field, vue.mergeProps({
  13258. "ref": filedRef,
  13259. "type": "search",
  13260. "class": bem$f("field"),
  13261. "border": false,
  13262. "onBlur": onBlur,
  13263. "onFocus": onFocus,
  13264. "onClear": onClear,
  13265. "onKeypress": onKeypress,
  13266. "onClick-input": onClickInput,
  13267. "onClick-left-icon": onClickLeftIcon,
  13268. "onClick-right-icon": onClickRightIcon,
  13269. "onUpdate:modelValue": onInput
  13270. }, fieldAttrs), pick(slots, ["left-icon", "right-icon"]));
  13271. };
  13272. useExpose({
  13273. focus,
  13274. blur
  13275. });
  13276. return () => {
  13277. var _a;
  13278. return vue.createVNode("div", {
  13279. "class": bem$f({
  13280. "show-action": props.showAction
  13281. }),
  13282. "style": {
  13283. background: props.background
  13284. }
  13285. }, [(_a = slots.left) == null ? void 0 : _a.call(slots), vue.createVNode("div", {
  13286. "class": bem$f("content", props.shape)
  13287. }, [renderLabel(), renderField()]), renderAction()]);
  13288. };
  13289. }
  13290. });
  13291. const Search = withInstall(stdin_default$k);
  13292. const popupInheritKeys = [...popupSharedPropKeys, "round", "closeOnPopstate", "safeAreaInsetBottom"];
  13293. const iconMap = {
  13294. qq: "qq",
  13295. link: "link-o",
  13296. weibo: "weibo",
  13297. qrcode: "qr",
  13298. poster: "photo-o",
  13299. wechat: "wechat",
  13300. "weapp-qrcode": "miniprogram-o",
  13301. "wechat-moments": "wechat-moments"
  13302. };
  13303. const [name$e, bem$e, t$2] = createNamespace("share-sheet");
  13304. const shareSheetProps = extend({}, popupSharedProps, {
  13305. title: String,
  13306. round: truthProp,
  13307. options: makeArrayProp(),
  13308. cancelText: String,
  13309. description: String,
  13310. closeOnPopstate: truthProp,
  13311. safeAreaInsetBottom: truthProp
  13312. });
  13313. var stdin_default$j = vue.defineComponent({
  13314. name: name$e,
  13315. props: shareSheetProps,
  13316. emits: ["cancel", "select", "update:show"],
  13317. setup(props, {
  13318. emit,
  13319. slots
  13320. }) {
  13321. const updateShow = (value) => emit("update:show", value);
  13322. const onCancel = () => {
  13323. updateShow(false);
  13324. emit("cancel");
  13325. };
  13326. const onSelect = (option, index) => emit("select", option, index);
  13327. const renderHeader = () => {
  13328. const title = slots.title ? slots.title() : props.title;
  13329. const description = slots.description ? slots.description() : props.description;
  13330. if (title || description) {
  13331. return vue.createVNode("div", {
  13332. "class": bem$e("header")
  13333. }, [title && vue.createVNode("h2", {
  13334. "class": bem$e("title")
  13335. }, [title]), description && vue.createVNode("span", {
  13336. "class": bem$e("description")
  13337. }, [description])]);
  13338. }
  13339. };
  13340. const renderIcon = (icon) => {
  13341. if (iconMap[icon]) {
  13342. return vue.createVNode("div", {
  13343. "class": bem$e("icon", [icon])
  13344. }, [vue.createVNode(Icon, {
  13345. "name": iconMap[icon] || icon
  13346. }, null)]);
  13347. }
  13348. return vue.createVNode("img", {
  13349. "src": icon,
  13350. "class": bem$e("image-icon")
  13351. }, null);
  13352. };
  13353. const renderOption = (option, index) => {
  13354. const {
  13355. name: name2,
  13356. icon,
  13357. className,
  13358. description
  13359. } = option;
  13360. return vue.createVNode("div", {
  13361. "role": "button",
  13362. "tabindex": 0,
  13363. "class": [bem$e("option"), className, HAPTICS_FEEDBACK],
  13364. "onClick": () => onSelect(option, index)
  13365. }, [renderIcon(icon), name2 && vue.createVNode("span", {
  13366. "class": bem$e("name")
  13367. }, [name2]), description && vue.createVNode("span", {
  13368. "class": bem$e("option-description")
  13369. }, [description])]);
  13370. };
  13371. const renderOptions = (options, border) => vue.createVNode("div", {
  13372. "class": bem$e("options", {
  13373. border
  13374. })
  13375. }, [options.map(renderOption)]);
  13376. const renderRows = () => {
  13377. const {
  13378. options
  13379. } = props;
  13380. if (Array.isArray(options[0])) {
  13381. return options.map((item, index) => renderOptions(item, index !== 0));
  13382. }
  13383. return renderOptions(options);
  13384. };
  13385. const renderCancelButton = () => {
  13386. var _a;
  13387. const cancelText = (_a = props.cancelText) != null ? _a : t$2("cancel");
  13388. if (slots.cancel || cancelText) {
  13389. return vue.createVNode("button", {
  13390. "type": "button",
  13391. "class": bem$e("cancel"),
  13392. "onClick": onCancel
  13393. }, [slots.cancel ? slots.cancel() : cancelText]);
  13394. }
  13395. };
  13396. return () => vue.createVNode(Popup, vue.mergeProps({
  13397. "class": bem$e(),
  13398. "position": "bottom",
  13399. "onUpdate:show": updateShow
  13400. }, pick(props, popupInheritKeys)), {
  13401. default: () => [renderHeader(), renderRows(), renderCancelButton()]
  13402. });
  13403. }
  13404. });
  13405. const ShareSheet = withInstall(stdin_default$j);
  13406. const [name$d, bem$d] = createNamespace("sidebar");
  13407. const SIDEBAR_KEY = Symbol(name$d);
  13408. const sidebarProps = {
  13409. modelValue: makeNumericProp(0)
  13410. };
  13411. var stdin_default$i = vue.defineComponent({
  13412. name: name$d,
  13413. props: sidebarProps,
  13414. emits: ["change", "update:modelValue"],
  13415. setup(props, {
  13416. emit,
  13417. slots
  13418. }) {
  13419. const {
  13420. linkChildren
  13421. } = useChildren(SIDEBAR_KEY);
  13422. const getActive = () => +props.modelValue;
  13423. const setActive = (value) => {
  13424. if (value !== getActive()) {
  13425. emit("update:modelValue", value);
  13426. emit("change", value);
  13427. }
  13428. };
  13429. linkChildren({
  13430. getActive,
  13431. setActive
  13432. });
  13433. return () => {
  13434. var _a;
  13435. return vue.createVNode("div", {
  13436. "role": "tablist",
  13437. "class": bem$d()
  13438. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  13439. };
  13440. }
  13441. });
  13442. const Sidebar = withInstall(stdin_default$i);
  13443. const [name$c, bem$c] = createNamespace("sidebar-item");
  13444. const sidebarItemProps = extend({}, routeProps, {
  13445. dot: Boolean,
  13446. title: String,
  13447. badge: numericProp,
  13448. disabled: Boolean,
  13449. badgeProps: Object
  13450. });
  13451. var stdin_default$h = vue.defineComponent({
  13452. name: name$c,
  13453. props: sidebarItemProps,
  13454. emits: ["click"],
  13455. setup(props, {
  13456. emit,
  13457. slots
  13458. }) {
  13459. const route2 = useRoute();
  13460. const {
  13461. parent,
  13462. index
  13463. } = useParent(SIDEBAR_KEY);
  13464. if (!parent) {
  13465. return;
  13466. }
  13467. const onClick = () => {
  13468. if (props.disabled) {
  13469. return;
  13470. }
  13471. emit("click", index.value);
  13472. parent.setActive(index.value);
  13473. route2();
  13474. };
  13475. return () => {
  13476. const {
  13477. dot,
  13478. badge,
  13479. title,
  13480. disabled
  13481. } = props;
  13482. const selected = index.value === parent.getActive();
  13483. return vue.createVNode("div", {
  13484. "role": "tab",
  13485. "class": bem$c({
  13486. select: selected,
  13487. disabled
  13488. }),
  13489. "tabindex": disabled ? void 0 : 0,
  13490. "aria-selected": selected,
  13491. "onClick": onClick
  13492. }, [vue.createVNode(Badge, vue.mergeProps({
  13493. "dot": dot,
  13494. "class": bem$c("text"),
  13495. "content": badge
  13496. }, props.badgeProps), {
  13497. default: () => [slots.title ? slots.title() : title]
  13498. })]);
  13499. };
  13500. }
  13501. });
  13502. const SidebarItem = withInstall(stdin_default$h);
  13503. const [name$b, bem$b] = createNamespace("skeleton");
  13504. const DEFAULT_ROW_WIDTH = "100%";
  13505. const DEFAULT_LAST_ROW_WIDTH = "60%";
  13506. const skeletonProps = {
  13507. row: makeNumericProp(0),
  13508. title: Boolean,
  13509. round: Boolean,
  13510. avatar: Boolean,
  13511. loading: truthProp,
  13512. animate: truthProp,
  13513. avatarSize: numericProp,
  13514. titleWidth: numericProp,
  13515. avatarShape: makeStringProp("round"),
  13516. rowWidth: {
  13517. type: [Number, String, Array],
  13518. default: DEFAULT_ROW_WIDTH
  13519. }
  13520. };
  13521. var stdin_default$g = vue.defineComponent({
  13522. name: name$b,
  13523. inheritAttrs: false,
  13524. props: skeletonProps,
  13525. setup(props, {
  13526. slots,
  13527. attrs
  13528. }) {
  13529. const renderAvatar = () => {
  13530. if (props.avatar) {
  13531. return vue.createVNode("div", {
  13532. "class": bem$b("avatar", props.avatarShape),
  13533. "style": getSizeStyle(props.avatarSize)
  13534. }, null);
  13535. }
  13536. };
  13537. const renderTitle = () => {
  13538. if (props.title) {
  13539. return vue.createVNode("h3", {
  13540. "class": bem$b("title"),
  13541. "style": {
  13542. width: addUnit(props.titleWidth)
  13543. }
  13544. }, null);
  13545. }
  13546. };
  13547. const getRowWidth = (index) => {
  13548. const {
  13549. rowWidth
  13550. } = props;
  13551. if (rowWidth === DEFAULT_ROW_WIDTH && index === +props.row - 1) {
  13552. return DEFAULT_LAST_ROW_WIDTH;
  13553. }
  13554. if (Array.isArray(rowWidth)) {
  13555. return rowWidth[index];
  13556. }
  13557. return rowWidth;
  13558. };
  13559. const renderRows = () => Array(+props.row).fill("").map((_, i) => vue.createVNode("div", {
  13560. "class": bem$b("row"),
  13561. "style": {
  13562. width: addUnit(getRowWidth(i))
  13563. }
  13564. }, null));
  13565. return () => {
  13566. var _a;
  13567. if (!props.loading) {
  13568. return (_a = slots.default) == null ? void 0 : _a.call(slots);
  13569. }
  13570. return vue.createVNode("div", vue.mergeProps({
  13571. "class": bem$b({
  13572. animate: props.animate,
  13573. round: props.round
  13574. })
  13575. }, attrs), [renderAvatar(), vue.createVNode("div", {
  13576. "class": bem$b("content")
  13577. }, [renderTitle(), renderRows()])]);
  13578. };
  13579. }
  13580. });
  13581. const Skeleton = withInstall(stdin_default$g);
  13582. const [name$a, bem$a] = createNamespace("slider");
  13583. const sliderProps = {
  13584. min: makeNumericProp(0),
  13585. max: makeNumericProp(100),
  13586. step: makeNumericProp(1),
  13587. range: Boolean,
  13588. reverse: Boolean,
  13589. disabled: Boolean,
  13590. readonly: Boolean,
  13591. vertical: Boolean,
  13592. barHeight: numericProp,
  13593. buttonSize: numericProp,
  13594. activeColor: String,
  13595. inactiveColor: String,
  13596. modelValue: {
  13597. type: [Number, Array],
  13598. default: 0
  13599. }
  13600. };
  13601. var stdin_default$f = vue.defineComponent({
  13602. name: name$a,
  13603. props: sliderProps,
  13604. emits: ["change", "drag-end", "drag-start", "update:modelValue"],
  13605. setup(props, {
  13606. emit,
  13607. slots
  13608. }) {
  13609. let buttonIndex;
  13610. let current2;
  13611. let startValue;
  13612. const root = vue.ref();
  13613. const slider = vue.ref();
  13614. const dragStatus = vue.ref();
  13615. const touch = useTouch();
  13616. const scope = vue.computed(() => Number(props.max) - Number(props.min));
  13617. const wrapperStyle = vue.computed(() => {
  13618. const crossAxis = props.vertical ? "width" : "height";
  13619. return {
  13620. background: props.inactiveColor,
  13621. [crossAxis]: addUnit(props.barHeight)
  13622. };
  13623. });
  13624. const isRange = (val) => props.range && Array.isArray(val);
  13625. const calcMainAxis = () => {
  13626. const {
  13627. modelValue,
  13628. min
  13629. } = props;
  13630. if (isRange(modelValue)) {
  13631. return `${(modelValue[1] - modelValue[0]) * 100 / scope.value}%`;
  13632. }
  13633. return `${(modelValue - Number(min)) * 100 / scope.value}%`;
  13634. };
  13635. const calcOffset = () => {
  13636. const {
  13637. modelValue,
  13638. min
  13639. } = props;
  13640. if (isRange(modelValue)) {
  13641. return `${(modelValue[0] - Number(min)) * 100 / scope.value}%`;
  13642. }
  13643. return "0%";
  13644. };
  13645. const barStyle = vue.computed(() => {
  13646. const mainAxis = props.vertical ? "height" : "width";
  13647. const style = {
  13648. [mainAxis]: calcMainAxis(),
  13649. background: props.activeColor
  13650. };
  13651. if (dragStatus.value) {
  13652. style.transition = "none";
  13653. }
  13654. const getPositionKey = () => {
  13655. if (props.vertical) {
  13656. return props.reverse ? "bottom" : "top";
  13657. }
  13658. return props.reverse ? "right" : "left";
  13659. };
  13660. style[getPositionKey()] = calcOffset();
  13661. return style;
  13662. });
  13663. const format2 = (value) => {
  13664. const min = +props.min;
  13665. const max = +props.max;
  13666. const step = +props.step;
  13667. value = clamp(value, min, max);
  13668. const diff = Math.round((value - min) / step) * step;
  13669. return addNumber(min, diff);
  13670. };
  13671. const isSameValue = (newValue, oldValue) => JSON.stringify(newValue) === JSON.stringify(oldValue);
  13672. const handleRangeValue = (value) => {
  13673. var _a, _b;
  13674. const left2 = (_a = value[0]) != null ? _a : Number(props.min);
  13675. const right2 = (_b = value[1]) != null ? _b : Number(props.max);
  13676. return left2 > right2 ? [right2, left2] : [left2, right2];
  13677. };
  13678. const updateValue = (value, end2) => {
  13679. if (isRange(value)) {
  13680. value = handleRangeValue(value).map(format2);
  13681. } else {
  13682. value = format2(value);
  13683. }
  13684. if (!isSameValue(value, props.modelValue)) {
  13685. emit("update:modelValue", value);
  13686. }
  13687. if (end2 && !isSameValue(value, startValue)) {
  13688. emit("change", value);
  13689. }
  13690. };
  13691. const onClick = (event) => {
  13692. event.stopPropagation();
  13693. if (props.disabled || props.readonly) {
  13694. return;
  13695. }
  13696. const {
  13697. min,
  13698. reverse,
  13699. vertical,
  13700. modelValue
  13701. } = props;
  13702. const rect = useRect(root);
  13703. const getDelta = () => {
  13704. if (vertical) {
  13705. if (reverse) {
  13706. return rect.bottom - event.clientY;
  13707. }
  13708. return event.clientY - rect.top;
  13709. }
  13710. if (reverse) {
  13711. return rect.right - event.clientX;
  13712. }
  13713. return event.clientX - rect.left;
  13714. };
  13715. const total = vertical ? rect.height : rect.width;
  13716. const value = Number(min) + getDelta() / total * scope.value;
  13717. if (isRange(modelValue)) {
  13718. const [left2, right2] = modelValue;
  13719. const middle = (left2 + right2) / 2;
  13720. if (value <= middle) {
  13721. updateValue([value, right2], true);
  13722. } else {
  13723. updateValue([left2, value], true);
  13724. }
  13725. } else {
  13726. updateValue(value, true);
  13727. }
  13728. };
  13729. const onTouchStart = (event) => {
  13730. if (props.disabled || props.readonly) {
  13731. return;
  13732. }
  13733. touch.start(event);
  13734. current2 = props.modelValue;
  13735. if (isRange(current2)) {
  13736. startValue = current2.map(format2);
  13737. } else {
  13738. startValue = format2(current2);
  13739. }
  13740. dragStatus.value = "start";
  13741. };
  13742. const onTouchMove = (event) => {
  13743. if (props.disabled || props.readonly) {
  13744. return;
  13745. }
  13746. if (dragStatus.value === "start") {
  13747. emit("drag-start", event);
  13748. }
  13749. preventDefault(event, true);
  13750. touch.move(event);
  13751. dragStatus.value = "dragging";
  13752. const rect = useRect(root);
  13753. const delta = props.vertical ? touch.deltaY.value : touch.deltaX.value;
  13754. const total = props.vertical ? rect.height : rect.width;
  13755. let diff = delta / total * scope.value;
  13756. if (props.reverse) {
  13757. diff = -diff;
  13758. }
  13759. if (isRange(startValue)) {
  13760. const index = props.reverse ? 1 - buttonIndex : buttonIndex;
  13761. current2[index] = startValue[index] + diff;
  13762. } else {
  13763. current2 = startValue + diff;
  13764. }
  13765. updateValue(current2);
  13766. };
  13767. const onTouchEnd = (event) => {
  13768. if (props.disabled || props.readonly) {
  13769. return;
  13770. }
  13771. if (dragStatus.value === "dragging") {
  13772. updateValue(current2, true);
  13773. emit("drag-end", event);
  13774. }
  13775. dragStatus.value = "";
  13776. };
  13777. const getButtonClassName = (index) => {
  13778. if (typeof index === "number") {
  13779. const position = ["left", "right"];
  13780. return bem$a(`button-wrapper`, position[index]);
  13781. }
  13782. return bem$a("button-wrapper", props.reverse ? "left" : "right");
  13783. };
  13784. const renderButtonContent = (value, index) => {
  13785. if (typeof index === "number") {
  13786. const slot = slots[index === 0 ? "left-button" : "right-button"];
  13787. if (slot) {
  13788. return slot({
  13789. value
  13790. });
  13791. }
  13792. }
  13793. if (slots.button) {
  13794. return slots.button({
  13795. value
  13796. });
  13797. }
  13798. return vue.createVNode("div", {
  13799. "class": bem$a("button"),
  13800. "style": getSizeStyle(props.buttonSize)
  13801. }, null);
  13802. };
  13803. const renderButton = (index) => {
  13804. const current22 = typeof index === "number" ? props.modelValue[index] : props.modelValue;
  13805. return vue.createVNode("div", {
  13806. "ref": slider,
  13807. "role": "slider",
  13808. "class": getButtonClassName(index),
  13809. "tabindex": props.disabled ? void 0 : 0,
  13810. "aria-valuemin": props.min,
  13811. "aria-valuenow": current22,
  13812. "aria-valuemax": props.max,
  13813. "aria-disabled": props.disabled || void 0,
  13814. "aria-readonly": props.readonly || void 0,
  13815. "aria-orientation": props.vertical ? "vertical" : "horizontal",
  13816. "onTouchstartPassive": (event) => {
  13817. if (typeof index === "number") {
  13818. buttonIndex = index;
  13819. }
  13820. onTouchStart(event);
  13821. },
  13822. "onTouchend": onTouchEnd,
  13823. "onTouchcancel": onTouchEnd,
  13824. "onClick": stopPropagation
  13825. }, [renderButtonContent(current22, index)]);
  13826. };
  13827. updateValue(props.modelValue);
  13828. useCustomFieldValue(() => props.modelValue);
  13829. useEventListener("touchmove", onTouchMove, {
  13830. target: slider
  13831. });
  13832. return () => vue.createVNode("div", {
  13833. "ref": root,
  13834. "style": wrapperStyle.value,
  13835. "class": bem$a({
  13836. vertical: props.vertical,
  13837. disabled: props.disabled
  13838. }),
  13839. "onClick": onClick
  13840. }, [vue.createVNode("div", {
  13841. "class": bem$a("bar"),
  13842. "style": barStyle.value
  13843. }, [props.range ? [renderButton(0), renderButton(1)] : renderButton()])]);
  13844. }
  13845. });
  13846. const Slider = withInstall(stdin_default$f);
  13847. const [name$9, bem$9] = createNamespace("space");
  13848. const spaceProps = {
  13849. align: String,
  13850. direction: {
  13851. type: String,
  13852. default: "horizontal"
  13853. },
  13854. size: {
  13855. type: [Number, String, Array],
  13856. default: 8
  13857. },
  13858. wrap: Boolean,
  13859. fill: Boolean
  13860. };
  13861. function filterEmpty(children = []) {
  13862. const nodes = [];
  13863. children.forEach((child) => {
  13864. if (Array.isArray(child)) {
  13865. nodes.push(...child);
  13866. } else if (child.type === vue.Fragment) {
  13867. nodes.push(...filterEmpty(child.children));
  13868. } else {
  13869. nodes.push(child);
  13870. }
  13871. });
  13872. return nodes.filter((c) => {
  13873. var _a;
  13874. return !(c && (typeof Comment !== "undefined" && c.type === Comment || c.type === vue.Fragment && ((_a = c.children) == null ? void 0 : _a.length) === 0 || c.type === Text && c.children.trim() === ""));
  13875. });
  13876. }
  13877. var stdin_default$e = vue.defineComponent({
  13878. name: name$9,
  13879. props: spaceProps,
  13880. setup(props, {
  13881. slots
  13882. }) {
  13883. const mergedAlign = vue.computed(() => {
  13884. var _a;
  13885. return (_a = props.align) != null ? _a : props.direction === "horizontal" ? "center" : "";
  13886. });
  13887. const getMargin = (size) => {
  13888. if (typeof size === "number") {
  13889. return size + "px";
  13890. }
  13891. return size;
  13892. };
  13893. const getMarginStyle = (isLast) => {
  13894. const style = {};
  13895. const marginRight = `${getMargin(Array.isArray(props.size) ? props.size[0] : props.size)}`;
  13896. const marginBottom = `${getMargin(Array.isArray(props.size) ? props.size[1] : props.size)}`;
  13897. if (isLast) {
  13898. return props.wrap ? {
  13899. marginBottom
  13900. } : {};
  13901. }
  13902. if (props.direction === "horizontal") {
  13903. style.marginRight = marginRight;
  13904. }
  13905. if (props.direction === "vertical" || props.wrap) {
  13906. style.marginBottom = marginBottom;
  13907. }
  13908. return style;
  13909. };
  13910. return () => {
  13911. var _a;
  13912. const children = filterEmpty((_a = slots.default) == null ? void 0 : _a.call(slots));
  13913. return vue.createVNode("div", {
  13914. "class": [bem$9({
  13915. [props.direction]: props.direction,
  13916. [`align-${mergedAlign.value}`]: mergedAlign.value,
  13917. wrap: props.wrap,
  13918. fill: props.fill
  13919. })]
  13920. }, [children.map((c, i) => vue.createVNode("div", {
  13921. "key": `item-${i}`,
  13922. "class": `${name$9}-item`,
  13923. "style": getMarginStyle(i === children.length - 1)
  13924. }, [c]))]);
  13925. };
  13926. }
  13927. });
  13928. const Space = withInstall(stdin_default$e);
  13929. const [name$8, bem$8] = createNamespace("steps");
  13930. const stepsProps = {
  13931. active: makeNumericProp(0),
  13932. direction: makeStringProp("horizontal"),
  13933. activeIcon: makeStringProp("checked"),
  13934. iconPrefix: String,
  13935. finishIcon: String,
  13936. activeColor: String,
  13937. inactiveIcon: String,
  13938. inactiveColor: String
  13939. };
  13940. const STEPS_KEY = Symbol(name$8);
  13941. var stdin_default$d = vue.defineComponent({
  13942. name: name$8,
  13943. props: stepsProps,
  13944. emits: ["click-step"],
  13945. setup(props, {
  13946. emit,
  13947. slots
  13948. }) {
  13949. const {
  13950. linkChildren
  13951. } = useChildren(STEPS_KEY);
  13952. const onClickStep = (index) => emit("click-step", index);
  13953. linkChildren({
  13954. props,
  13955. onClickStep
  13956. });
  13957. return () => {
  13958. var _a;
  13959. return vue.createVNode("div", {
  13960. "class": bem$8([props.direction])
  13961. }, [vue.createVNode("div", {
  13962. "class": bem$8("items")
  13963. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)])]);
  13964. };
  13965. }
  13966. });
  13967. const [name$7, bem$7] = createNamespace("step");
  13968. var stdin_default$c = vue.defineComponent({
  13969. name: name$7,
  13970. setup(props, {
  13971. slots
  13972. }) {
  13973. const {
  13974. parent,
  13975. index
  13976. } = useParent(STEPS_KEY);
  13977. if (!parent) {
  13978. return;
  13979. }
  13980. const parentProps = parent.props;
  13981. const getStatus = () => {
  13982. const active = +parentProps.active;
  13983. if (index.value < active) {
  13984. return "finish";
  13985. }
  13986. return index.value === active ? "process" : "waiting";
  13987. };
  13988. const isActive = () => getStatus() === "process";
  13989. const lineStyle = vue.computed(() => ({
  13990. background: getStatus() === "finish" ? parentProps.activeColor : parentProps.inactiveColor
  13991. }));
  13992. const titleStyle = vue.computed(() => {
  13993. if (isActive()) {
  13994. return {
  13995. color: parentProps.activeColor
  13996. };
  13997. }
  13998. if (getStatus() === "waiting") {
  13999. return {
  14000. color: parentProps.inactiveColor
  14001. };
  14002. }
  14003. });
  14004. const onClickStep = () => parent.onClickStep(index.value);
  14005. const renderCircle = () => {
  14006. const {
  14007. iconPrefix,
  14008. finishIcon,
  14009. activeIcon,
  14010. activeColor,
  14011. inactiveIcon
  14012. } = parentProps;
  14013. if (isActive()) {
  14014. if (slots["active-icon"]) {
  14015. return slots["active-icon"]();
  14016. }
  14017. return vue.createVNode(Icon, {
  14018. "class": bem$7("icon", "active"),
  14019. "name": activeIcon,
  14020. "color": activeColor,
  14021. "classPrefix": iconPrefix
  14022. }, null);
  14023. }
  14024. if (getStatus() === "finish" && (finishIcon || slots["finish-icon"])) {
  14025. if (slots["finish-icon"]) {
  14026. return slots["finish-icon"]();
  14027. }
  14028. return vue.createVNode(Icon, {
  14029. "class": bem$7("icon", "finish"),
  14030. "name": finishIcon,
  14031. "color": activeColor,
  14032. "classPrefix": iconPrefix
  14033. }, null);
  14034. }
  14035. if (slots["inactive-icon"]) {
  14036. return slots["inactive-icon"]();
  14037. }
  14038. if (inactiveIcon) {
  14039. return vue.createVNode(Icon, {
  14040. "class": bem$7("icon"),
  14041. "name": inactiveIcon,
  14042. "classPrefix": iconPrefix
  14043. }, null);
  14044. }
  14045. return vue.createVNode("i", {
  14046. "class": bem$7("circle"),
  14047. "style": lineStyle.value
  14048. }, null);
  14049. };
  14050. return () => {
  14051. var _a;
  14052. const status = getStatus();
  14053. return vue.createVNode("div", {
  14054. "class": [BORDER, bem$7([parentProps.direction, {
  14055. [status]: status
  14056. }])]
  14057. }, [vue.createVNode("div", {
  14058. "class": bem$7("title", {
  14059. active: isActive()
  14060. }),
  14061. "style": titleStyle.value,
  14062. "onClick": onClickStep
  14063. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]), vue.createVNode("div", {
  14064. "class": bem$7("circle-container"),
  14065. "onClick": onClickStep
  14066. }, [renderCircle()]), vue.createVNode("div", {
  14067. "class": bem$7("line"),
  14068. "style": lineStyle.value
  14069. }, null)]);
  14070. };
  14071. }
  14072. });
  14073. const Step = withInstall(stdin_default$c);
  14074. const [name$6, bem$6] = createNamespace("stepper");
  14075. const LONG_PRESS_INTERVAL = 200;
  14076. const LONG_PRESS_START_TIME = 600;
  14077. const isEqual = (value1, value2) => String(value1) === String(value2);
  14078. const stepperProps = {
  14079. min: makeNumericProp(1),
  14080. max: makeNumericProp(Infinity),
  14081. name: makeNumericProp(""),
  14082. step: makeNumericProp(1),
  14083. theme: String,
  14084. integer: Boolean,
  14085. disabled: Boolean,
  14086. showPlus: truthProp,
  14087. showMinus: truthProp,
  14088. showInput: truthProp,
  14089. longPress: truthProp,
  14090. allowEmpty: Boolean,
  14091. modelValue: numericProp,
  14092. inputWidth: numericProp,
  14093. buttonSize: numericProp,
  14094. placeholder: String,
  14095. disablePlus: Boolean,
  14096. disableMinus: Boolean,
  14097. disableInput: Boolean,
  14098. beforeChange: Function,
  14099. defaultValue: makeNumericProp(1),
  14100. decimalLength: numericProp
  14101. };
  14102. var stdin_default$b = vue.defineComponent({
  14103. name: name$6,
  14104. props: stepperProps,
  14105. emits: ["plus", "blur", "minus", "focus", "change", "overlimit", "update:modelValue"],
  14106. setup(props, {
  14107. emit
  14108. }) {
  14109. const format2 = (value) => {
  14110. const {
  14111. min,
  14112. max,
  14113. allowEmpty,
  14114. decimalLength
  14115. } = props;
  14116. if (allowEmpty && value === "") {
  14117. return value;
  14118. }
  14119. value = formatNumber(String(value), !props.integer);
  14120. value = value === "" ? 0 : +value;
  14121. value = Number.isNaN(value) ? +min : value;
  14122. value = Math.max(Math.min(+max, value), +min);
  14123. if (isDef(decimalLength)) {
  14124. value = value.toFixed(+decimalLength);
  14125. }
  14126. return value;
  14127. };
  14128. const getInitialValue = () => {
  14129. var _a;
  14130. const defaultValue = (_a = props.modelValue) != null ? _a : props.defaultValue;
  14131. const value = format2(defaultValue);
  14132. if (!isEqual(value, props.modelValue)) {
  14133. emit("update:modelValue", value);
  14134. }
  14135. return value;
  14136. };
  14137. let actionType;
  14138. const inputRef = vue.ref();
  14139. const current2 = vue.ref(getInitialValue());
  14140. const minusDisabled = vue.computed(() => props.disabled || props.disableMinus || current2.value <= +props.min);
  14141. const plusDisabled = vue.computed(() => props.disabled || props.disablePlus || current2.value >= +props.max);
  14142. const inputStyle = vue.computed(() => ({
  14143. width: addUnit(props.inputWidth),
  14144. height: addUnit(props.buttonSize)
  14145. }));
  14146. const buttonStyle = vue.computed(() => getSizeStyle(props.buttonSize));
  14147. const check = () => {
  14148. const value = format2(current2.value);
  14149. if (!isEqual(value, current2.value)) {
  14150. current2.value = value;
  14151. }
  14152. };
  14153. const setValue = (value) => {
  14154. if (props.beforeChange) {
  14155. callInterceptor(props.beforeChange, {
  14156. args: [value],
  14157. done() {
  14158. current2.value = value;
  14159. }
  14160. });
  14161. } else {
  14162. current2.value = value;
  14163. }
  14164. };
  14165. const onChange = () => {
  14166. if (actionType === "plus" && plusDisabled.value || actionType === "minus" && minusDisabled.value) {
  14167. emit("overlimit", actionType);
  14168. return;
  14169. }
  14170. const diff = actionType === "minus" ? -props.step : +props.step;
  14171. const value = format2(addNumber(+current2.value, diff));
  14172. setValue(value);
  14173. emit(actionType);
  14174. };
  14175. const onInput = (event) => {
  14176. const input = event.target;
  14177. const {
  14178. value
  14179. } = input;
  14180. const {
  14181. decimalLength
  14182. } = props;
  14183. let formatted = formatNumber(String(value), !props.integer);
  14184. if (isDef(decimalLength) && formatted.includes(".")) {
  14185. const pair = formatted.split(".");
  14186. formatted = `${pair[0]}.${pair[1].slice(0, +decimalLength)}`;
  14187. }
  14188. if (props.beforeChange) {
  14189. input.value = String(current2.value);
  14190. } else if (!isEqual(value, formatted)) {
  14191. input.value = formatted;
  14192. }
  14193. const isNumeric2 = formatted === String(+formatted);
  14194. setValue(isNumeric2 ? +formatted : formatted);
  14195. };
  14196. const onFocus = (event) => {
  14197. var _a;
  14198. if (props.disableInput) {
  14199. (_a = inputRef.value) == null ? void 0 : _a.blur();
  14200. } else {
  14201. emit("focus", event);
  14202. }
  14203. };
  14204. const onBlur = (event) => {
  14205. const input = event.target;
  14206. const value = format2(input.value);
  14207. input.value = String(value);
  14208. current2.value = value;
  14209. vue.nextTick(() => {
  14210. emit("blur", event);
  14211. resetScroll();
  14212. });
  14213. };
  14214. let isLongPress;
  14215. let longPressTimer;
  14216. const longPressStep = () => {
  14217. longPressTimer = setTimeout(() => {
  14218. onChange();
  14219. longPressStep();
  14220. }, LONG_PRESS_INTERVAL);
  14221. };
  14222. const onTouchStart = () => {
  14223. if (props.longPress) {
  14224. isLongPress = false;
  14225. clearTimeout(longPressTimer);
  14226. longPressTimer = setTimeout(() => {
  14227. isLongPress = true;
  14228. onChange();
  14229. longPressStep();
  14230. }, LONG_PRESS_START_TIME);
  14231. }
  14232. };
  14233. const onTouchEnd = (event) => {
  14234. if (props.longPress) {
  14235. clearTimeout(longPressTimer);
  14236. if (isLongPress) {
  14237. preventDefault(event);
  14238. }
  14239. }
  14240. };
  14241. const onMousedown = (event) => {
  14242. if (props.disableInput) {
  14243. preventDefault(event);
  14244. }
  14245. };
  14246. const createListeners = (type) => ({
  14247. onClick: (event) => {
  14248. preventDefault(event);
  14249. actionType = type;
  14250. onChange();
  14251. },
  14252. onTouchstartPassive: () => {
  14253. actionType = type;
  14254. onTouchStart();
  14255. },
  14256. onTouchend: onTouchEnd,
  14257. onTouchcancel: onTouchEnd
  14258. });
  14259. vue.watch(() => [props.max, props.min, props.integer, props.decimalLength], check);
  14260. vue.watch(() => props.modelValue, (value) => {
  14261. if (!isEqual(value, current2.value)) {
  14262. current2.value = format2(value);
  14263. }
  14264. });
  14265. vue.watch(current2, (value) => {
  14266. emit("update:modelValue", value);
  14267. emit("change", value, {
  14268. name: props.name
  14269. });
  14270. });
  14271. useCustomFieldValue(() => props.modelValue);
  14272. return () => vue.createVNode("div", {
  14273. "role": "group",
  14274. "class": bem$6([props.theme])
  14275. }, [vue.withDirectives(vue.createVNode("button", vue.mergeProps({
  14276. "type": "button",
  14277. "style": buttonStyle.value,
  14278. "class": [bem$6("minus", {
  14279. disabled: minusDisabled.value
  14280. }), {
  14281. [HAPTICS_FEEDBACK]: !minusDisabled.value
  14282. }],
  14283. "aria-disabled": minusDisabled.value || void 0
  14284. }, createListeners("minus")), null), [[vue.vShow, props.showMinus]]), vue.withDirectives(vue.createVNode("input", {
  14285. "ref": inputRef,
  14286. "type": props.integer ? "tel" : "text",
  14287. "role": "spinbutton",
  14288. "class": bem$6("input"),
  14289. "value": current2.value,
  14290. "style": inputStyle.value,
  14291. "disabled": props.disabled,
  14292. "readonly": props.disableInput,
  14293. "inputmode": props.integer ? "numeric" : "decimal",
  14294. "placeholder": props.placeholder,
  14295. "aria-valuemax": props.max,
  14296. "aria-valuemin": props.min,
  14297. "aria-valuenow": current2.value,
  14298. "onBlur": onBlur,
  14299. "onInput": onInput,
  14300. "onFocus": onFocus,
  14301. "onMousedown": onMousedown
  14302. }, null), [[vue.vShow, props.showInput]]), vue.withDirectives(vue.createVNode("button", vue.mergeProps({
  14303. "type": "button",
  14304. "style": buttonStyle.value,
  14305. "class": [bem$6("plus", {
  14306. disabled: plusDisabled.value
  14307. }), {
  14308. [HAPTICS_FEEDBACK]: !plusDisabled.value
  14309. }],
  14310. "aria-disabled": plusDisabled.value || void 0
  14311. }, createListeners("plus")), null), [[vue.vShow, props.showPlus]])]);
  14312. }
  14313. });
  14314. const Stepper = withInstall(stdin_default$b);
  14315. const Steps = withInstall(stdin_default$d);
  14316. const [name$5, bem$5, t$1] = createNamespace("submit-bar");
  14317. const submitBarProps = {
  14318. tip: String,
  14319. label: String,
  14320. price: Number,
  14321. tipIcon: String,
  14322. loading: Boolean,
  14323. currency: makeStringProp("\xA5"),
  14324. disabled: Boolean,
  14325. textAlign: String,
  14326. buttonText: String,
  14327. buttonType: makeStringProp("danger"),
  14328. buttonColor: String,
  14329. suffixLabel: String,
  14330. placeholder: Boolean,
  14331. decimalLength: makeNumericProp(2),
  14332. safeAreaInsetBottom: truthProp
  14333. };
  14334. var stdin_default$a = vue.defineComponent({
  14335. name: name$5,
  14336. props: submitBarProps,
  14337. emits: ["submit"],
  14338. setup(props, {
  14339. emit,
  14340. slots
  14341. }) {
  14342. const root = vue.ref();
  14343. const renderPlaceholder = usePlaceholder(root, bem$5);
  14344. const renderText = () => {
  14345. const {
  14346. price,
  14347. label,
  14348. currency,
  14349. textAlign,
  14350. suffixLabel,
  14351. decimalLength
  14352. } = props;
  14353. if (typeof price === "number") {
  14354. const pricePair = (price / 100).toFixed(+decimalLength).split(".");
  14355. const decimal = decimalLength ? `.${pricePair[1]}` : "";
  14356. return vue.createVNode("div", {
  14357. "class": bem$5("text"),
  14358. "style": {
  14359. textAlign
  14360. }
  14361. }, [vue.createVNode("span", null, [label || t$1("label")]), vue.createVNode("span", {
  14362. "class": bem$5("price")
  14363. }, [currency, vue.createVNode("span", {
  14364. "class": bem$5("price-integer")
  14365. }, [pricePair[0]]), decimal]), suffixLabel && vue.createVNode("span", {
  14366. "class": bem$5("suffix-label")
  14367. }, [suffixLabel])]);
  14368. }
  14369. };
  14370. const renderTip = () => {
  14371. var _a;
  14372. const {
  14373. tip,
  14374. tipIcon
  14375. } = props;
  14376. if (slots.tip || tip) {
  14377. return vue.createVNode("div", {
  14378. "class": bem$5("tip")
  14379. }, [tipIcon && vue.createVNode(Icon, {
  14380. "class": bem$5("tip-icon"),
  14381. "name": tipIcon
  14382. }, null), tip && vue.createVNode("span", {
  14383. "class": bem$5("tip-text")
  14384. }, [tip]), (_a = slots.tip) == null ? void 0 : _a.call(slots)]);
  14385. }
  14386. };
  14387. const onClickButton = () => emit("submit");
  14388. const renderButton = () => {
  14389. if (slots.button) {
  14390. return slots.button();
  14391. }
  14392. return vue.createVNode(Button, {
  14393. "round": true,
  14394. "type": props.buttonType,
  14395. "text": props.buttonText,
  14396. "class": bem$5("button", props.buttonType),
  14397. "color": props.buttonColor,
  14398. "loading": props.loading,
  14399. "disabled": props.disabled,
  14400. "onClick": onClickButton
  14401. }, null);
  14402. };
  14403. const renderSubmitBar = () => {
  14404. var _a, _b;
  14405. return vue.createVNode("div", {
  14406. "ref": root,
  14407. "class": [bem$5(), {
  14408. "van-safe-area-bottom": props.safeAreaInsetBottom
  14409. }]
  14410. }, [(_a = slots.top) == null ? void 0 : _a.call(slots), renderTip(), vue.createVNode("div", {
  14411. "class": bem$5("bar")
  14412. }, [(_b = slots.default) == null ? void 0 : _b.call(slots), renderText(), renderButton()])]);
  14413. };
  14414. return () => {
  14415. if (props.placeholder) {
  14416. return renderPlaceholder(renderSubmitBar);
  14417. }
  14418. return renderSubmitBar();
  14419. };
  14420. }
  14421. });
  14422. const SubmitBar = withInstall(stdin_default$a);
  14423. const [name$4, bem$4] = createNamespace("swipe-cell");
  14424. const swipeCellProps = {
  14425. name: makeNumericProp(""),
  14426. disabled: Boolean,
  14427. leftWidth: numericProp,
  14428. rightWidth: numericProp,
  14429. beforeClose: Function,
  14430. stopPropagation: Boolean
  14431. };
  14432. var stdin_default$9 = vue.defineComponent({
  14433. name: name$4,
  14434. props: swipeCellProps,
  14435. emits: ["open", "close", "click"],
  14436. setup(props, {
  14437. emit,
  14438. slots
  14439. }) {
  14440. let opened;
  14441. let lockClick2;
  14442. let startOffset;
  14443. const root = vue.ref();
  14444. const leftRef = vue.ref();
  14445. const rightRef = vue.ref();
  14446. const state = vue.reactive({
  14447. offset: 0,
  14448. dragging: false
  14449. });
  14450. const touch = useTouch();
  14451. const getWidthByRef = (ref2) => ref2.value ? useRect(ref2).width : 0;
  14452. const leftWidth = vue.computed(() => isDef(props.leftWidth) ? +props.leftWidth : getWidthByRef(leftRef));
  14453. const rightWidth = vue.computed(() => isDef(props.rightWidth) ? +props.rightWidth : getWidthByRef(rightRef));
  14454. const open = (side) => {
  14455. state.offset = side === "left" ? leftWidth.value : -rightWidth.value;
  14456. if (!opened) {
  14457. opened = true;
  14458. emit("open", {
  14459. name: props.name,
  14460. position: side
  14461. });
  14462. }
  14463. };
  14464. const close = (position) => {
  14465. state.offset = 0;
  14466. if (opened) {
  14467. opened = false;
  14468. emit("close", {
  14469. name: props.name,
  14470. position
  14471. });
  14472. }
  14473. };
  14474. const toggle = (side) => {
  14475. const offset2 = Math.abs(state.offset);
  14476. const THRESHOLD = 0.15;
  14477. const threshold = opened ? 1 - THRESHOLD : THRESHOLD;
  14478. const width2 = side === "left" ? leftWidth.value : rightWidth.value;
  14479. if (width2 && offset2 > width2 * threshold) {
  14480. open(side);
  14481. } else {
  14482. close(side);
  14483. }
  14484. };
  14485. const onTouchStart = (event) => {
  14486. if (!props.disabled) {
  14487. startOffset = state.offset;
  14488. touch.start(event);
  14489. }
  14490. };
  14491. const onTouchMove = (event) => {
  14492. if (props.disabled) {
  14493. return;
  14494. }
  14495. const {
  14496. deltaX
  14497. } = touch;
  14498. touch.move(event);
  14499. if (touch.isHorizontal()) {
  14500. lockClick2 = true;
  14501. state.dragging = true;
  14502. const isEdge = !opened || deltaX.value * startOffset < 0;
  14503. if (isEdge) {
  14504. preventDefault(event, props.stopPropagation);
  14505. }
  14506. state.offset = clamp(deltaX.value + startOffset, -rightWidth.value, leftWidth.value);
  14507. }
  14508. };
  14509. const onTouchEnd = () => {
  14510. if (state.dragging) {
  14511. state.dragging = false;
  14512. toggle(state.offset > 0 ? "left" : "right");
  14513. setTimeout(() => {
  14514. lockClick2 = false;
  14515. }, 0);
  14516. }
  14517. };
  14518. const onClick = (position = "outside") => {
  14519. emit("click", position);
  14520. if (opened && !lockClick2) {
  14521. callInterceptor(props.beforeClose, {
  14522. args: [{
  14523. name: props.name,
  14524. position
  14525. }],
  14526. done: () => close(position)
  14527. });
  14528. }
  14529. };
  14530. const getClickHandler = (position, stop) => (event) => {
  14531. if (stop) {
  14532. event.stopPropagation();
  14533. }
  14534. onClick(position);
  14535. };
  14536. const renderSideContent = (side, ref2) => {
  14537. const contentSlot = slots[side];
  14538. if (contentSlot) {
  14539. return vue.createVNode("div", {
  14540. "ref": ref2,
  14541. "class": bem$4(side),
  14542. "onClick": getClickHandler(side, true)
  14543. }, [contentSlot()]);
  14544. }
  14545. };
  14546. useExpose({
  14547. open,
  14548. close
  14549. });
  14550. useClickAway(root, () => onClick("outside"), {
  14551. eventName: "touchstart"
  14552. });
  14553. useEventListener("touchmove", onTouchMove, {
  14554. target: root
  14555. });
  14556. return () => {
  14557. var _a;
  14558. const wrapperStyle = {
  14559. transform: `translate3d(${state.offset}px, 0, 0)`,
  14560. transitionDuration: state.dragging ? "0s" : ".6s"
  14561. };
  14562. return vue.createVNode("div", {
  14563. "ref": root,
  14564. "class": bem$4(),
  14565. "onClick": getClickHandler("cell", lockClick2),
  14566. "onTouchstartPassive": onTouchStart,
  14567. "onTouchend": onTouchEnd,
  14568. "onTouchcancel": onTouchEnd
  14569. }, [vue.createVNode("div", {
  14570. "class": bem$4("wrapper"),
  14571. "style": wrapperStyle
  14572. }, [renderSideContent("left", leftRef), (_a = slots.default) == null ? void 0 : _a.call(slots), renderSideContent("right", rightRef)])]);
  14573. };
  14574. }
  14575. });
  14576. const SwipeCell = withInstall(stdin_default$9);
  14577. const [name$3, bem$3] = createNamespace("tabbar");
  14578. const tabbarProps = {
  14579. route: Boolean,
  14580. fixed: truthProp,
  14581. border: truthProp,
  14582. zIndex: numericProp,
  14583. placeholder: Boolean,
  14584. activeColor: String,
  14585. beforeChange: Function,
  14586. inactiveColor: String,
  14587. modelValue: makeNumericProp(0),
  14588. safeAreaInsetBottom: {
  14589. type: Boolean,
  14590. default: null
  14591. }
  14592. };
  14593. const TABBAR_KEY = Symbol(name$3);
  14594. var stdin_default$8 = vue.defineComponent({
  14595. name: name$3,
  14596. props: tabbarProps,
  14597. emits: ["change", "update:modelValue"],
  14598. setup(props, {
  14599. emit,
  14600. slots
  14601. }) {
  14602. const root = vue.ref();
  14603. const {
  14604. linkChildren
  14605. } = useChildren(TABBAR_KEY);
  14606. const renderPlaceholder = usePlaceholder(root, bem$3);
  14607. const enableSafeArea = () => {
  14608. var _a;
  14609. return (_a = props.safeAreaInsetBottom) != null ? _a : props.fixed;
  14610. };
  14611. const renderTabbar = () => {
  14612. var _a;
  14613. const {
  14614. fixed,
  14615. zIndex,
  14616. border
  14617. } = props;
  14618. return vue.createVNode("div", {
  14619. "ref": root,
  14620. "role": "tablist",
  14621. "style": getZIndexStyle(zIndex),
  14622. "class": [bem$3({
  14623. fixed
  14624. }), {
  14625. [BORDER_TOP_BOTTOM]: border,
  14626. "van-safe-area-bottom": enableSafeArea()
  14627. }]
  14628. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  14629. };
  14630. const setActive = (active, afterChange) => {
  14631. callInterceptor(props.beforeChange, {
  14632. args: [active],
  14633. done() {
  14634. emit("update:modelValue", active);
  14635. emit("change", active);
  14636. afterChange();
  14637. }
  14638. });
  14639. };
  14640. linkChildren({
  14641. props,
  14642. setActive
  14643. });
  14644. return () => {
  14645. if (props.fixed && props.placeholder) {
  14646. return renderPlaceholder(renderTabbar);
  14647. }
  14648. return renderTabbar();
  14649. };
  14650. }
  14651. });
  14652. const Tabbar = withInstall(stdin_default$8);
  14653. const [name$2, bem$2] = createNamespace("tabbar-item");
  14654. const tabbarItemProps = extend({}, routeProps, {
  14655. dot: Boolean,
  14656. icon: String,
  14657. name: numericProp,
  14658. badge: numericProp,
  14659. badgeProps: Object,
  14660. iconPrefix: String
  14661. });
  14662. var stdin_default$7 = vue.defineComponent({
  14663. name: name$2,
  14664. props: tabbarItemProps,
  14665. emits: ["click"],
  14666. setup(props, {
  14667. emit,
  14668. slots
  14669. }) {
  14670. const route2 = useRoute();
  14671. const vm = vue.getCurrentInstance().proxy;
  14672. const {
  14673. parent,
  14674. index
  14675. } = useParent(TABBAR_KEY);
  14676. if (!parent) {
  14677. return;
  14678. }
  14679. const active = vue.computed(() => {
  14680. var _a;
  14681. const {
  14682. route: route22,
  14683. modelValue
  14684. } = parent.props;
  14685. if (route22 && "$route" in vm) {
  14686. const {
  14687. $route
  14688. } = vm;
  14689. const {
  14690. to
  14691. } = props;
  14692. const config = isObject(to) ? to : {
  14693. path: to
  14694. };
  14695. return !!$route.matched.find((val) => {
  14696. const pathMatched = "path" in config && config.path === val.path;
  14697. const nameMatched = "name" in config && config.name === val.name;
  14698. return pathMatched || nameMatched;
  14699. });
  14700. }
  14701. return ((_a = props.name) != null ? _a : index.value) === modelValue;
  14702. });
  14703. const onClick = (event) => {
  14704. var _a;
  14705. if (!active.value) {
  14706. parent.setActive((_a = props.name) != null ? _a : index.value, route2);
  14707. }
  14708. emit("click", event);
  14709. };
  14710. const renderIcon = () => {
  14711. if (slots.icon) {
  14712. return slots.icon({
  14713. active: active.value
  14714. });
  14715. }
  14716. if (props.icon) {
  14717. return vue.createVNode(Icon, {
  14718. "name": props.icon,
  14719. "classPrefix": props.iconPrefix
  14720. }, null);
  14721. }
  14722. };
  14723. return () => {
  14724. var _a;
  14725. const {
  14726. dot,
  14727. badge
  14728. } = props;
  14729. const {
  14730. activeColor,
  14731. inactiveColor
  14732. } = parent.props;
  14733. const color = active.value ? activeColor : inactiveColor;
  14734. return vue.createVNode("div", {
  14735. "role": "tab",
  14736. "class": bem$2({
  14737. active: active.value
  14738. }),
  14739. "style": {
  14740. color
  14741. },
  14742. "tabindex": 0,
  14743. "aria-selected": active.value,
  14744. "onClick": onClick
  14745. }, [vue.createVNode(Badge, vue.mergeProps({
  14746. "dot": dot,
  14747. "class": bem$2("icon"),
  14748. "content": badge
  14749. }, props.badgeProps), {
  14750. default: renderIcon
  14751. }), vue.createVNode("div", {
  14752. "class": bem$2("text")
  14753. }, [(_a = slots.default) == null ? void 0 : _a.call(slots, {
  14754. active: active.value
  14755. })])]);
  14756. };
  14757. }
  14758. });
  14759. const TabbarItem = withInstall(stdin_default$7);
  14760. const [name$1, bem$1] = createNamespace("tree-select");
  14761. const treeSelectProps = {
  14762. max: makeNumericProp(Infinity),
  14763. items: makeArrayProp(),
  14764. height: makeNumericProp(300),
  14765. selectedIcon: makeStringProp("success"),
  14766. mainActiveIndex: makeNumericProp(0),
  14767. activeId: {
  14768. type: [Number, String, Array],
  14769. default: 0
  14770. }
  14771. };
  14772. var stdin_default$6 = vue.defineComponent({
  14773. name: name$1,
  14774. props: treeSelectProps,
  14775. emits: ["click-nav", "click-item", "update:activeId", "update:mainActiveIndex"],
  14776. setup(props, {
  14777. emit,
  14778. slots
  14779. }) {
  14780. const isActiveItem = (id) => Array.isArray(props.activeId) ? props.activeId.includes(id) : props.activeId === id;
  14781. const renderSubItem = (item) => {
  14782. const onClick = () => {
  14783. if (item.disabled) {
  14784. return;
  14785. }
  14786. let activeId;
  14787. if (Array.isArray(props.activeId)) {
  14788. activeId = props.activeId.slice();
  14789. const index = activeId.indexOf(item.id);
  14790. if (index !== -1) {
  14791. activeId.splice(index, 1);
  14792. } else if (activeId.length < props.max) {
  14793. activeId.push(item.id);
  14794. }
  14795. } else {
  14796. activeId = item.id;
  14797. }
  14798. emit("update:activeId", activeId);
  14799. emit("click-item", item);
  14800. };
  14801. return vue.createVNode("div", {
  14802. "key": item.id,
  14803. "class": ["van-ellipsis", bem$1("item", {
  14804. active: isActiveItem(item.id),
  14805. disabled: item.disabled
  14806. })],
  14807. "onClick": onClick
  14808. }, [item.text, isActiveItem(item.id) && vue.createVNode(Icon, {
  14809. "name": props.selectedIcon,
  14810. "class": bem$1("selected")
  14811. }, null)]);
  14812. };
  14813. const onSidebarChange = (index) => {
  14814. emit("update:mainActiveIndex", index);
  14815. };
  14816. const onClickSidebarItem = (index) => emit("click-nav", index);
  14817. const renderSidebar = () => {
  14818. const Items = props.items.map((item) => vue.createVNode(SidebarItem, {
  14819. "dot": item.dot,
  14820. "title": item.text,
  14821. "badge": item.badge,
  14822. "class": [bem$1("nav-item"), item.className],
  14823. "disabled": item.disabled,
  14824. "onClick": onClickSidebarItem
  14825. }, null));
  14826. return vue.createVNode(Sidebar, {
  14827. "class": bem$1("nav"),
  14828. "modelValue": props.mainActiveIndex,
  14829. "onChange": onSidebarChange
  14830. }, {
  14831. default: () => [Items]
  14832. });
  14833. };
  14834. const renderContent = () => {
  14835. if (slots.content) {
  14836. return slots.content();
  14837. }
  14838. const selected = props.items[+props.mainActiveIndex] || {};
  14839. if (selected.children) {
  14840. return selected.children.map(renderSubItem);
  14841. }
  14842. };
  14843. return () => vue.createVNode("div", {
  14844. "class": bem$1(),
  14845. "style": {
  14846. height: addUnit(props.height)
  14847. }
  14848. }, [renderSidebar(), vue.createVNode("div", {
  14849. "class": bem$1("content")
  14850. }, [renderContent()])]);
  14851. }
  14852. });
  14853. const TreeSelect = withInstall(stdin_default$6);
  14854. const [name, bem, t] = createNamespace("uploader");
  14855. function readFileContent(file, resultType) {
  14856. return new Promise((resolve) => {
  14857. if (resultType === "file") {
  14858. resolve();
  14859. return;
  14860. }
  14861. const reader = new FileReader();
  14862. reader.onload = (event) => {
  14863. resolve(event.target.result);
  14864. };
  14865. if (resultType === "dataUrl") {
  14866. reader.readAsDataURL(file);
  14867. } else if (resultType === "text") {
  14868. reader.readAsText(file);
  14869. }
  14870. });
  14871. }
  14872. function isOversize(items, maxSize) {
  14873. return toArray(items).some((item) => {
  14874. if (item.file) {
  14875. if (isFunction(maxSize)) {
  14876. return maxSize(item.file);
  14877. }
  14878. return item.file.size > maxSize;
  14879. }
  14880. return false;
  14881. });
  14882. }
  14883. function filterFiles(items, maxSize) {
  14884. const valid = [];
  14885. const invalid = [];
  14886. items.forEach((item) => {
  14887. if (isOversize(item, maxSize)) {
  14888. invalid.push(item);
  14889. } else {
  14890. valid.push(item);
  14891. }
  14892. });
  14893. return { valid, invalid };
  14894. }
  14895. const IMAGE_REGEXP = /\.(jpeg|jpg|gif|png|svg|webp|jfif|bmp|dpg)/i;
  14896. const isImageUrl = (url) => IMAGE_REGEXP.test(url);
  14897. function isImageFile(item) {
  14898. if (item.isImage) {
  14899. return true;
  14900. }
  14901. if (item.file && item.file.type) {
  14902. return item.file.type.indexOf("image") === 0;
  14903. }
  14904. if (item.url) {
  14905. return isImageUrl(item.url);
  14906. }
  14907. if (typeof item.content === "string") {
  14908. return item.content.indexOf("data:image") === 0;
  14909. }
  14910. return false;
  14911. }
  14912. var stdin_default$5 = vue.defineComponent({
  14913. props: {
  14914. name: numericProp,
  14915. item: makeRequiredProp(Object),
  14916. index: Number,
  14917. imageFit: String,
  14918. lazyLoad: Boolean,
  14919. deletable: Boolean,
  14920. previewSize: [Number, String, Array],
  14921. beforeDelete: Function
  14922. },
  14923. emits: ["delete", "preview"],
  14924. setup(props, {
  14925. emit,
  14926. slots
  14927. }) {
  14928. const renderMask = () => {
  14929. const {
  14930. status,
  14931. message
  14932. } = props.item;
  14933. if (status === "uploading" || status === "failed") {
  14934. const MaskIcon = status === "failed" ? vue.createVNode(Icon, {
  14935. "name": "close",
  14936. "class": bem("mask-icon")
  14937. }, null) : vue.createVNode(Loading, {
  14938. "class": bem("loading")
  14939. }, null);
  14940. const showMessage = isDef(message) && message !== "";
  14941. return vue.createVNode("div", {
  14942. "class": bem("mask")
  14943. }, [MaskIcon, showMessage && vue.createVNode("div", {
  14944. "class": bem("mask-message")
  14945. }, [message])]);
  14946. }
  14947. };
  14948. const onDelete = (event) => {
  14949. const {
  14950. name: name2,
  14951. item,
  14952. index,
  14953. beforeDelete
  14954. } = props;
  14955. event.stopPropagation();
  14956. callInterceptor(beforeDelete, {
  14957. args: [item, {
  14958. name: name2,
  14959. index
  14960. }],
  14961. done: () => emit("delete")
  14962. });
  14963. };
  14964. const onPreview = () => emit("preview");
  14965. const renderDeleteIcon = () => {
  14966. if (props.deletable && props.item.status !== "uploading") {
  14967. const slot = slots["preview-delete"];
  14968. return vue.createVNode("div", {
  14969. "role": "button",
  14970. "class": bem("preview-delete", {
  14971. shadow: !slot
  14972. }),
  14973. "tabindex": 0,
  14974. "aria-label": t("delete"),
  14975. "onClick": onDelete
  14976. }, [slot ? slot() : vue.createVNode(Icon, {
  14977. "name": "cross",
  14978. "class": bem("preview-delete-icon")
  14979. }, null)]);
  14980. }
  14981. };
  14982. const renderCover = () => {
  14983. if (slots["preview-cover"]) {
  14984. const {
  14985. index,
  14986. item
  14987. } = props;
  14988. return vue.createVNode("div", {
  14989. "class": bem("preview-cover")
  14990. }, [slots["preview-cover"](extend({
  14991. index
  14992. }, item))]);
  14993. }
  14994. };
  14995. const renderPreview = () => {
  14996. const {
  14997. item,
  14998. lazyLoad,
  14999. imageFit,
  15000. previewSize
  15001. } = props;
  15002. if (isImageFile(item)) {
  15003. return vue.createVNode(Image$1, {
  15004. "fit": imageFit,
  15005. "src": item.content || item.url,
  15006. "class": bem("preview-image"),
  15007. "width": Array.isArray(previewSize) ? previewSize[0] : previewSize,
  15008. "height": Array.isArray(previewSize) ? previewSize[1] : previewSize,
  15009. "lazyLoad": lazyLoad,
  15010. "onClick": onPreview
  15011. }, {
  15012. default: renderCover
  15013. });
  15014. }
  15015. return vue.createVNode("div", {
  15016. "class": bem("file"),
  15017. "style": getSizeStyle(props.previewSize)
  15018. }, [vue.createVNode(Icon, {
  15019. "class": bem("file-icon"),
  15020. "name": "description"
  15021. }, null), vue.createVNode("div", {
  15022. "class": [bem("file-name"), "van-ellipsis"]
  15023. }, [item.file ? item.file.name : item.url]), renderCover()]);
  15024. };
  15025. return () => vue.createVNode("div", {
  15026. "class": bem("preview")
  15027. }, [renderPreview(), renderMask(), renderDeleteIcon()]);
  15028. }
  15029. });
  15030. const uploaderProps = {
  15031. name: makeNumericProp(""),
  15032. accept: makeStringProp("image/*"),
  15033. capture: String,
  15034. multiple: Boolean,
  15035. disabled: Boolean,
  15036. readonly: Boolean,
  15037. lazyLoad: Boolean,
  15038. maxCount: makeNumericProp(Infinity),
  15039. imageFit: makeStringProp("cover"),
  15040. resultType: makeStringProp("dataUrl"),
  15041. uploadIcon: makeStringProp("photograph"),
  15042. uploadText: String,
  15043. deletable: truthProp,
  15044. afterRead: Function,
  15045. showUpload: truthProp,
  15046. modelValue: makeArrayProp(),
  15047. beforeRead: Function,
  15048. beforeDelete: Function,
  15049. previewSize: [Number, String, Array],
  15050. previewImage: truthProp,
  15051. previewOptions: Object,
  15052. previewFullImage: truthProp,
  15053. maxSize: {
  15054. type: [Number, String, Function],
  15055. default: Infinity
  15056. }
  15057. };
  15058. var stdin_default$4 = vue.defineComponent({
  15059. name,
  15060. props: uploaderProps,
  15061. emits: ["delete", "oversize", "click-upload", "close-preview", "click-preview", "update:modelValue"],
  15062. setup(props, {
  15063. emit,
  15064. slots
  15065. }) {
  15066. const inputRef = vue.ref();
  15067. const urls = [];
  15068. const getDetail = (index = props.modelValue.length) => ({
  15069. name: props.name,
  15070. index
  15071. });
  15072. const resetInput = () => {
  15073. if (inputRef.value) {
  15074. inputRef.value.value = "";
  15075. }
  15076. };
  15077. const onAfterRead = (items) => {
  15078. resetInput();
  15079. if (isOversize(items, props.maxSize)) {
  15080. if (Array.isArray(items)) {
  15081. const result = filterFiles(items, props.maxSize);
  15082. items = result.valid;
  15083. emit("oversize", result.invalid, getDetail());
  15084. if (!items.length) {
  15085. return;
  15086. }
  15087. } else {
  15088. emit("oversize", items, getDetail());
  15089. return;
  15090. }
  15091. }
  15092. items = vue.reactive(items);
  15093. emit("update:modelValue", [...props.modelValue, ...toArray(items)]);
  15094. if (props.afterRead) {
  15095. props.afterRead(items, getDetail());
  15096. }
  15097. };
  15098. const readFile = (files) => {
  15099. const {
  15100. maxCount,
  15101. modelValue,
  15102. resultType
  15103. } = props;
  15104. if (Array.isArray(files)) {
  15105. const remainCount = +maxCount - modelValue.length;
  15106. if (files.length > remainCount) {
  15107. files = files.slice(0, remainCount);
  15108. }
  15109. Promise.all(files.map((file) => readFileContent(file, resultType))).then((contents) => {
  15110. const fileList = files.map((file, index) => {
  15111. const result = {
  15112. file,
  15113. status: "",
  15114. message: ""
  15115. };
  15116. if (contents[index]) {
  15117. result.content = contents[index];
  15118. }
  15119. return result;
  15120. });
  15121. onAfterRead(fileList);
  15122. });
  15123. } else {
  15124. readFileContent(files, resultType).then((content) => {
  15125. const result = {
  15126. file: files,
  15127. status: "",
  15128. message: ""
  15129. };
  15130. if (content) {
  15131. result.content = content;
  15132. }
  15133. onAfterRead(result);
  15134. });
  15135. }
  15136. };
  15137. const onChange = (event) => {
  15138. const {
  15139. files
  15140. } = event.target;
  15141. if (props.disabled || !files || !files.length) {
  15142. return;
  15143. }
  15144. const file = files.length === 1 ? files[0] : [].slice.call(files);
  15145. if (props.beforeRead) {
  15146. const response = props.beforeRead(file, getDetail());
  15147. if (!response) {
  15148. resetInput();
  15149. return;
  15150. }
  15151. if (isPromise(response)) {
  15152. response.then((data) => {
  15153. if (data) {
  15154. readFile(data);
  15155. } else {
  15156. readFile(file);
  15157. }
  15158. }).catch(resetInput);
  15159. return;
  15160. }
  15161. }
  15162. readFile(file);
  15163. };
  15164. let imagePreview;
  15165. const onClosePreview = () => emit("close-preview");
  15166. const previewImage = (item) => {
  15167. if (props.previewFullImage) {
  15168. const imageFiles = props.modelValue.filter(isImageFile);
  15169. const images = imageFiles.map((item2) => {
  15170. if (item2.file && !item2.url && item2.status !== "failed") {
  15171. item2.url = URL.createObjectURL(item2.file);
  15172. urls.push(item2.url);
  15173. }
  15174. return item2.url;
  15175. }).filter(Boolean);
  15176. imagePreview = ImagePreview(extend({
  15177. images,
  15178. startPosition: imageFiles.indexOf(item),
  15179. onClose: onClosePreview
  15180. }, props.previewOptions));
  15181. }
  15182. };
  15183. const closeImagePreview = () => {
  15184. if (imagePreview) {
  15185. imagePreview.close();
  15186. }
  15187. };
  15188. const deleteFile = (item, index) => {
  15189. const fileList = props.modelValue.slice(0);
  15190. fileList.splice(index, 1);
  15191. emit("update:modelValue", fileList);
  15192. emit("delete", item, getDetail(index));
  15193. };
  15194. const renderPreviewItem = (item, index) => {
  15195. const needPickData = ["imageFit", "deletable", "previewSize", "beforeDelete"];
  15196. const previewData = extend(pick(props, needPickData), pick(item, needPickData, true));
  15197. return vue.createVNode(stdin_default$5, vue.mergeProps({
  15198. "item": item,
  15199. "index": index,
  15200. "onClick": () => emit("click-preview", item, getDetail(index)),
  15201. "onDelete": () => deleteFile(item, index),
  15202. "onPreview": () => previewImage(item)
  15203. }, pick(props, ["name", "lazyLoad"]), previewData), pick(slots, ["preview-cover", "preview-delete"]));
  15204. };
  15205. const renderPreviewList = () => {
  15206. if (props.previewImage) {
  15207. return props.modelValue.map(renderPreviewItem);
  15208. }
  15209. };
  15210. const onClickUpload = (event) => emit("click-upload", event);
  15211. const renderUpload = () => {
  15212. if (props.modelValue.length >= props.maxCount || !props.showUpload) {
  15213. return;
  15214. }
  15215. const Input = props.readonly ? null : vue.createVNode("input", {
  15216. "ref": inputRef,
  15217. "type": "file",
  15218. "class": bem("input"),
  15219. "accept": props.accept,
  15220. "capture": props.capture,
  15221. "multiple": props.multiple,
  15222. "disabled": props.disabled,
  15223. "onChange": onChange
  15224. }, null);
  15225. if (slots.default) {
  15226. return vue.createVNode("div", {
  15227. "class": bem("input-wrapper"),
  15228. "onClick": onClickUpload
  15229. }, [slots.default(), Input]);
  15230. }
  15231. return vue.createVNode("div", {
  15232. "class": bem("upload", {
  15233. readonly: props.readonly
  15234. }),
  15235. "style": getSizeStyle(props.previewSize),
  15236. "onClick": onClickUpload
  15237. }, [vue.createVNode(Icon, {
  15238. "name": props.uploadIcon,
  15239. "class": bem("upload-icon")
  15240. }, null), props.uploadText && vue.createVNode("span", {
  15241. "class": bem("upload-text")
  15242. }, [props.uploadText]), Input]);
  15243. };
  15244. const chooseFile = () => {
  15245. if (inputRef.value && !props.disabled) {
  15246. inputRef.value.click();
  15247. }
  15248. };
  15249. vue.onBeforeUnmount(() => {
  15250. urls.forEach((url) => URL.revokeObjectURL(url));
  15251. });
  15252. useExpose({
  15253. chooseFile,
  15254. closeImagePreview
  15255. });
  15256. useCustomFieldValue(() => props.modelValue);
  15257. return () => vue.createVNode("div", {
  15258. "class": bem()
  15259. }, [vue.createVNode("div", {
  15260. "class": bem("wrapper", {
  15261. disabled: props.disabled
  15262. })
  15263. }, [renderPreviewList(), renderUpload()])]);
  15264. }
  15265. });
  15266. const Uploader = withInstall(stdin_default$4);
  15267. const hasIntersectionObserver = inBrowser && "IntersectionObserver" in window && "IntersectionObserverEntry" in window && "intersectionRatio" in window.IntersectionObserverEntry.prototype;
  15268. const modeType = {
  15269. event: "event",
  15270. observer: "observer"
  15271. };
  15272. function remove(arr, item) {
  15273. if (!arr.length)
  15274. return;
  15275. const index = arr.indexOf(item);
  15276. if (index > -1)
  15277. return arr.splice(index, 1);
  15278. }
  15279. function getBestSelectionFromSrcset(el, scale) {
  15280. if (el.tagName !== "IMG" || !el.getAttribute("data-srcset"))
  15281. return;
  15282. let options = el.getAttribute("data-srcset");
  15283. const container = el.parentNode;
  15284. const containerWidth = container.offsetWidth * scale;
  15285. let spaceIndex;
  15286. let tmpSrc;
  15287. let tmpWidth;
  15288. options = options.trim().split(",");
  15289. const result = options.map((item) => {
  15290. item = item.trim();
  15291. spaceIndex = item.lastIndexOf(" ");
  15292. if (spaceIndex === -1) {
  15293. tmpSrc = item;
  15294. tmpWidth = 999998;
  15295. } else {
  15296. tmpSrc = item.substr(0, spaceIndex);
  15297. tmpWidth = parseInt(
  15298. item.substr(spaceIndex + 1, item.length - spaceIndex - 2),
  15299. 10
  15300. );
  15301. }
  15302. return [tmpWidth, tmpSrc];
  15303. });
  15304. result.sort((a, b) => {
  15305. if (a[0] < b[0]) {
  15306. return 1;
  15307. }
  15308. if (a[0] > b[0]) {
  15309. return -1;
  15310. }
  15311. if (a[0] === b[0]) {
  15312. if (b[1].indexOf(".webp", b[1].length - 5) !== -1) {
  15313. return 1;
  15314. }
  15315. if (a[1].indexOf(".webp", a[1].length - 5) !== -1) {
  15316. return -1;
  15317. }
  15318. }
  15319. return 0;
  15320. });
  15321. let bestSelectedSrc = "";
  15322. let tmpOption;
  15323. for (let i = 0; i < result.length; i++) {
  15324. tmpOption = result[i];
  15325. bestSelectedSrc = tmpOption[1];
  15326. const next = result[i + 1];
  15327. if (next && next[0] < containerWidth) {
  15328. bestSelectedSrc = tmpOption[1];
  15329. break;
  15330. } else if (!next) {
  15331. bestSelectedSrc = tmpOption[1];
  15332. break;
  15333. }
  15334. }
  15335. return bestSelectedSrc;
  15336. }
  15337. const getDPR = (scale = 1) => inBrowser ? window.devicePixelRatio || scale : scale;
  15338. function supportWebp() {
  15339. if (!inBrowser)
  15340. return false;
  15341. let support = true;
  15342. try {
  15343. const elem = document.createElement("canvas");
  15344. if (elem.getContext && elem.getContext("2d")) {
  15345. support = elem.toDataURL("image/webp").indexOf("data:image/webp") === 0;
  15346. }
  15347. } catch (err) {
  15348. support = false;
  15349. }
  15350. return support;
  15351. }
  15352. function throttle(action, delay) {
  15353. let timeout = null;
  15354. let lastRun = 0;
  15355. return function(...args) {
  15356. if (timeout) {
  15357. return;
  15358. }
  15359. const elapsed = Date.now() - lastRun;
  15360. const runCallback = () => {
  15361. lastRun = Date.now();
  15362. timeout = false;
  15363. action.apply(this, args);
  15364. };
  15365. if (elapsed >= delay) {
  15366. runCallback();
  15367. } else {
  15368. timeout = setTimeout(runCallback, delay);
  15369. }
  15370. };
  15371. }
  15372. function on(el, type, func) {
  15373. el.addEventListener(type, func, {
  15374. capture: false,
  15375. passive: true
  15376. });
  15377. }
  15378. function off(el, type, func) {
  15379. el.removeEventListener(type, func, false);
  15380. }
  15381. const loadImageAsync = (item, resolve, reject) => {
  15382. const image = new Image();
  15383. if (!item || !item.src) {
  15384. return reject(new Error("image src is required"));
  15385. }
  15386. image.src = item.src;
  15387. if (item.cors) {
  15388. image.crossOrigin = item.cors;
  15389. }
  15390. image.onload = () => resolve({
  15391. naturalHeight: image.naturalHeight,
  15392. naturalWidth: image.naturalWidth,
  15393. src: image.src
  15394. });
  15395. image.onerror = (e) => reject(e);
  15396. };
  15397. class ImageCache {
  15398. constructor({ max }) {
  15399. this.options = {
  15400. max: max || 100
  15401. };
  15402. this.caches = [];
  15403. }
  15404. has(key) {
  15405. return this.caches.indexOf(key) > -1;
  15406. }
  15407. add(key) {
  15408. if (this.has(key))
  15409. return;
  15410. this.caches.push(key);
  15411. if (this.caches.length > this.options.max) {
  15412. this.free();
  15413. }
  15414. }
  15415. free() {
  15416. this.caches.shift();
  15417. }
  15418. }
  15419. class ReactiveListener {
  15420. constructor({
  15421. el,
  15422. src,
  15423. error,
  15424. loading,
  15425. bindType,
  15426. $parent,
  15427. options,
  15428. cors,
  15429. elRenderer,
  15430. imageCache
  15431. }) {
  15432. this.el = el;
  15433. this.src = src;
  15434. this.error = error;
  15435. this.loading = loading;
  15436. this.bindType = bindType;
  15437. this.attempt = 0;
  15438. this.cors = cors;
  15439. this.naturalHeight = 0;
  15440. this.naturalWidth = 0;
  15441. this.options = options;
  15442. this.$parent = $parent;
  15443. this.elRenderer = elRenderer;
  15444. this.imageCache = imageCache;
  15445. this.performanceData = {
  15446. loadStart: 0,
  15447. loadEnd: 0
  15448. };
  15449. this.filter();
  15450. this.initState();
  15451. this.render("loading", false);
  15452. }
  15453. initState() {
  15454. if ("dataset" in this.el) {
  15455. this.el.dataset.src = this.src;
  15456. } else {
  15457. this.el.setAttribute("data-src", this.src);
  15458. }
  15459. this.state = {
  15460. loading: false,
  15461. error: false,
  15462. loaded: false,
  15463. rendered: false
  15464. };
  15465. }
  15466. record(event) {
  15467. this.performanceData[event] = Date.now();
  15468. }
  15469. update({ src, loading, error }) {
  15470. const oldSrc = this.src;
  15471. this.src = src;
  15472. this.loading = loading;
  15473. this.error = error;
  15474. this.filter();
  15475. if (oldSrc !== this.src) {
  15476. this.attempt = 0;
  15477. this.initState();
  15478. }
  15479. }
  15480. checkInView() {
  15481. const rect = useRect(this.el);
  15482. return rect.top < window.innerHeight * this.options.preLoad && rect.bottom > this.options.preLoadTop && rect.left < window.innerWidth * this.options.preLoad && rect.right > 0;
  15483. }
  15484. filter() {
  15485. Object.keys(this.options.filter).forEach((key) => {
  15486. this.options.filter[key](this, this.options);
  15487. });
  15488. }
  15489. renderLoading(cb) {
  15490. this.state.loading = true;
  15491. loadImageAsync(
  15492. {
  15493. src: this.loading,
  15494. cors: this.cors
  15495. },
  15496. () => {
  15497. this.render("loading", false);
  15498. this.state.loading = false;
  15499. cb();
  15500. },
  15501. () => {
  15502. cb();
  15503. this.state.loading = false;
  15504. }
  15505. );
  15506. }
  15507. load(onFinish = noop) {
  15508. if (this.attempt > this.options.attempt - 1 && this.state.error) {
  15509. onFinish();
  15510. return;
  15511. }
  15512. if (this.state.rendered && this.state.loaded)
  15513. return;
  15514. if (this.imageCache.has(this.src)) {
  15515. this.state.loaded = true;
  15516. this.render("loaded", true);
  15517. this.state.rendered = true;
  15518. return onFinish();
  15519. }
  15520. this.renderLoading(() => {
  15521. var _a, _b;
  15522. this.attempt++;
  15523. (_b = (_a = this.options.adapter).beforeLoad) == null ? void 0 : _b.call(_a, this, this.options);
  15524. this.record("loadStart");
  15525. loadImageAsync(
  15526. {
  15527. src: this.src,
  15528. cors: this.cors
  15529. },
  15530. (data) => {
  15531. this.naturalHeight = data.naturalHeight;
  15532. this.naturalWidth = data.naturalWidth;
  15533. this.state.loaded = true;
  15534. this.state.error = false;
  15535. this.record("loadEnd");
  15536. this.render("loaded", false);
  15537. this.state.rendered = true;
  15538. this.imageCache.add(this.src);
  15539. onFinish();
  15540. },
  15541. (err) => {
  15542. !this.options.silent && console.error(err);
  15543. this.state.error = true;
  15544. this.state.loaded = false;
  15545. this.render("error", false);
  15546. }
  15547. );
  15548. });
  15549. }
  15550. render(state, cache) {
  15551. this.elRenderer(this, state, cache);
  15552. }
  15553. performance() {
  15554. let state = "loading";
  15555. let time = 0;
  15556. if (this.state.loaded) {
  15557. state = "loaded";
  15558. time = (this.performanceData.loadEnd - this.performanceData.loadStart) / 1e3;
  15559. }
  15560. if (this.state.error)
  15561. state = "error";
  15562. return {
  15563. src: this.src,
  15564. state,
  15565. time
  15566. };
  15567. }
  15568. $destroy() {
  15569. this.el = null;
  15570. this.src = null;
  15571. this.error = null;
  15572. this.loading = null;
  15573. this.bindType = null;
  15574. this.attempt = 0;
  15575. }
  15576. }
  15577. const DEFAULT_URL = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";
  15578. const DEFAULT_EVENTS = [
  15579. "scroll",
  15580. "wheel",
  15581. "mousewheel",
  15582. "resize",
  15583. "animationend",
  15584. "transitionend",
  15585. "touchmove"
  15586. ];
  15587. const DEFAULT_OBSERVER_OPTIONS = {
  15588. rootMargin: "0px",
  15589. threshold: 0
  15590. };
  15591. function stdin_default$3() {
  15592. return class Lazy {
  15593. constructor({
  15594. preLoad,
  15595. error,
  15596. throttleWait,
  15597. preLoadTop,
  15598. dispatchEvent,
  15599. loading,
  15600. attempt,
  15601. silent = true,
  15602. scale,
  15603. listenEvents,
  15604. filter,
  15605. adapter,
  15606. observer,
  15607. observerOptions
  15608. }) {
  15609. this.mode = modeType.event;
  15610. this.listeners = [];
  15611. this.targetIndex = 0;
  15612. this.targets = [];
  15613. this.options = {
  15614. silent,
  15615. dispatchEvent: !!dispatchEvent,
  15616. throttleWait: throttleWait || 200,
  15617. preLoad: preLoad || 1.3,
  15618. preLoadTop: preLoadTop || 0,
  15619. error: error || DEFAULT_URL,
  15620. loading: loading || DEFAULT_URL,
  15621. attempt: attempt || 3,
  15622. scale: scale || getDPR(scale),
  15623. ListenEvents: listenEvents || DEFAULT_EVENTS,
  15624. supportWebp: supportWebp(),
  15625. filter: filter || {},
  15626. adapter: adapter || {},
  15627. observer: !!observer,
  15628. observerOptions: observerOptions || DEFAULT_OBSERVER_OPTIONS
  15629. };
  15630. this.initEvent();
  15631. this.imageCache = new ImageCache({ max: 200 });
  15632. this.lazyLoadHandler = throttle(
  15633. this.lazyLoadHandler.bind(this),
  15634. this.options.throttleWait
  15635. );
  15636. this.setMode(this.options.observer ? modeType.observer : modeType.event);
  15637. }
  15638. config(options = {}) {
  15639. Object.assign(this.options, options);
  15640. }
  15641. performance() {
  15642. return this.listeners.map((item) => item.performance());
  15643. }
  15644. addLazyBox(vm) {
  15645. this.listeners.push(vm);
  15646. if (inBrowser) {
  15647. this.addListenerTarget(window);
  15648. this.observer && this.observer.observe(vm.el);
  15649. if (vm.$el && vm.$el.parentNode) {
  15650. this.addListenerTarget(vm.$el.parentNode);
  15651. }
  15652. }
  15653. }
  15654. add(el, binding, vnode) {
  15655. if (this.listeners.some((item) => item.el === el)) {
  15656. this.update(el, binding);
  15657. return vue.nextTick(this.lazyLoadHandler);
  15658. }
  15659. const value = this.valueFormatter(binding.value);
  15660. let { src } = value;
  15661. vue.nextTick(() => {
  15662. src = getBestSelectionFromSrcset(el, this.options.scale) || src;
  15663. this.observer && this.observer.observe(el);
  15664. const container = Object.keys(binding.modifiers)[0];
  15665. let $parent;
  15666. if (container) {
  15667. $parent = vnode.context.$refs[container];
  15668. $parent = $parent ? $parent.$el || $parent : document.getElementById(container);
  15669. }
  15670. if (!$parent) {
  15671. $parent = getScrollParent$1(el);
  15672. }
  15673. const newListener = new ReactiveListener({
  15674. bindType: binding.arg,
  15675. $parent,
  15676. el,
  15677. src,
  15678. loading: value.loading,
  15679. error: value.error,
  15680. cors: value.cors,
  15681. elRenderer: this.elRenderer.bind(this),
  15682. options: this.options,
  15683. imageCache: this.imageCache
  15684. });
  15685. this.listeners.push(newListener);
  15686. if (inBrowser) {
  15687. this.addListenerTarget(window);
  15688. this.addListenerTarget($parent);
  15689. }
  15690. this.lazyLoadHandler();
  15691. vue.nextTick(() => this.lazyLoadHandler());
  15692. });
  15693. }
  15694. update(el, binding, vnode) {
  15695. const value = this.valueFormatter(binding.value);
  15696. let { src } = value;
  15697. src = getBestSelectionFromSrcset(el, this.options.scale) || src;
  15698. const exist = this.listeners.find((item) => item.el === el);
  15699. if (!exist) {
  15700. this.add(el, binding, vnode);
  15701. } else {
  15702. exist.update({
  15703. src,
  15704. error: value.error,
  15705. loading: value.loading
  15706. });
  15707. }
  15708. if (this.observer) {
  15709. this.observer.unobserve(el);
  15710. this.observer.observe(el);
  15711. }
  15712. this.lazyLoadHandler();
  15713. vue.nextTick(() => this.lazyLoadHandler());
  15714. }
  15715. remove(el) {
  15716. if (!el)
  15717. return;
  15718. this.observer && this.observer.unobserve(el);
  15719. const existItem = this.listeners.find((item) => item.el === el);
  15720. if (existItem) {
  15721. this.removeListenerTarget(existItem.$parent);
  15722. this.removeListenerTarget(window);
  15723. remove(this.listeners, existItem);
  15724. existItem.$destroy();
  15725. }
  15726. }
  15727. removeComponent(vm) {
  15728. if (!vm)
  15729. return;
  15730. remove(this.listeners, vm);
  15731. this.observer && this.observer.unobserve(vm.el);
  15732. if (vm.$parent && vm.$el.parentNode) {
  15733. this.removeListenerTarget(vm.$el.parentNode);
  15734. }
  15735. this.removeListenerTarget(window);
  15736. }
  15737. setMode(mode) {
  15738. if (!hasIntersectionObserver && mode === modeType.observer) {
  15739. mode = modeType.event;
  15740. }
  15741. this.mode = mode;
  15742. if (mode === modeType.event) {
  15743. if (this.observer) {
  15744. this.listeners.forEach((listener) => {
  15745. this.observer.unobserve(listener.el);
  15746. });
  15747. this.observer = null;
  15748. }
  15749. this.targets.forEach((target) => {
  15750. this.initListen(target.el, true);
  15751. });
  15752. } else {
  15753. this.targets.forEach((target) => {
  15754. this.initListen(target.el, false);
  15755. });
  15756. this.initIntersectionObserver();
  15757. }
  15758. }
  15759. addListenerTarget(el) {
  15760. if (!el)
  15761. return;
  15762. let target = this.targets.find((target2) => target2.el === el);
  15763. if (!target) {
  15764. target = {
  15765. el,
  15766. id: ++this.targetIndex,
  15767. childrenCount: 1,
  15768. listened: true
  15769. };
  15770. this.mode === modeType.event && this.initListen(target.el, true);
  15771. this.targets.push(target);
  15772. } else {
  15773. target.childrenCount++;
  15774. }
  15775. return this.targetIndex;
  15776. }
  15777. removeListenerTarget(el) {
  15778. this.targets.forEach((target, index) => {
  15779. if (target.el === el) {
  15780. target.childrenCount--;
  15781. if (!target.childrenCount) {
  15782. this.initListen(target.el, false);
  15783. this.targets.splice(index, 1);
  15784. target = null;
  15785. }
  15786. }
  15787. });
  15788. }
  15789. initListen(el, start2) {
  15790. this.options.ListenEvents.forEach(
  15791. (evt) => (start2 ? on : off)(el, evt, this.lazyLoadHandler)
  15792. );
  15793. }
  15794. initEvent() {
  15795. this.Event = {
  15796. listeners: {
  15797. loading: [],
  15798. loaded: [],
  15799. error: []
  15800. }
  15801. };
  15802. this.$on = (event, func) => {
  15803. if (!this.Event.listeners[event])
  15804. this.Event.listeners[event] = [];
  15805. this.Event.listeners[event].push(func);
  15806. };
  15807. this.$once = (event, func) => {
  15808. const on2 = (...args) => {
  15809. this.$off(event, on2);
  15810. func.apply(this, args);
  15811. };
  15812. this.$on(event, on2);
  15813. };
  15814. this.$off = (event, func) => {
  15815. if (!func) {
  15816. if (!this.Event.listeners[event])
  15817. return;
  15818. this.Event.listeners[event].length = 0;
  15819. return;
  15820. }
  15821. remove(this.Event.listeners[event], func);
  15822. };
  15823. this.$emit = (event, context, inCache) => {
  15824. if (!this.Event.listeners[event])
  15825. return;
  15826. this.Event.listeners[event].forEach((func) => func(context, inCache));
  15827. };
  15828. }
  15829. lazyLoadHandler() {
  15830. const freeList = [];
  15831. this.listeners.forEach((listener) => {
  15832. if (!listener.el || !listener.el.parentNode) {
  15833. freeList.push(listener);
  15834. }
  15835. const catIn = listener.checkInView();
  15836. if (!catIn)
  15837. return;
  15838. listener.load();
  15839. });
  15840. freeList.forEach((item) => {
  15841. remove(this.listeners, item);
  15842. item.$destroy();
  15843. });
  15844. }
  15845. initIntersectionObserver() {
  15846. if (!hasIntersectionObserver) {
  15847. return;
  15848. }
  15849. this.observer = new IntersectionObserver(
  15850. this.observerHandler.bind(this),
  15851. this.options.observerOptions
  15852. );
  15853. if (this.listeners.length) {
  15854. this.listeners.forEach((listener) => {
  15855. this.observer.observe(listener.el);
  15856. });
  15857. }
  15858. }
  15859. observerHandler(entries) {
  15860. entries.forEach((entry) => {
  15861. if (entry.isIntersecting) {
  15862. this.listeners.forEach((listener) => {
  15863. if (listener.el === entry.target) {
  15864. if (listener.state.loaded)
  15865. return this.observer.unobserve(listener.el);
  15866. listener.load();
  15867. }
  15868. });
  15869. }
  15870. });
  15871. }
  15872. elRenderer(listener, state, cache) {
  15873. if (!listener.el)
  15874. return;
  15875. const { el, bindType } = listener;
  15876. let src;
  15877. switch (state) {
  15878. case "loading":
  15879. src = listener.loading;
  15880. break;
  15881. case "error":
  15882. src = listener.error;
  15883. break;
  15884. default:
  15885. ({ src } = listener);
  15886. break;
  15887. }
  15888. if (bindType) {
  15889. el.style[bindType] = 'url("' + src + '")';
  15890. } else if (el.getAttribute("src") !== src) {
  15891. el.setAttribute("src", src);
  15892. }
  15893. el.setAttribute("lazy", state);
  15894. this.$emit(state, listener, cache);
  15895. this.options.adapter[state] && this.options.adapter[state](listener, this.options);
  15896. if (this.options.dispatchEvent) {
  15897. const event = new CustomEvent(state, {
  15898. detail: listener
  15899. });
  15900. el.dispatchEvent(event);
  15901. }
  15902. }
  15903. valueFormatter(value) {
  15904. let src = value;
  15905. let { loading, error } = this.options;
  15906. if (isObject(value)) {
  15907. ({ src } = value);
  15908. loading = value.loading || this.options.loading;
  15909. error = value.error || this.options.error;
  15910. }
  15911. return {
  15912. src,
  15913. loading,
  15914. error
  15915. };
  15916. }
  15917. };
  15918. }
  15919. var stdin_default$2 = (lazy) => ({
  15920. props: {
  15921. tag: {
  15922. type: String,
  15923. default: "div"
  15924. }
  15925. },
  15926. emits: ["show"],
  15927. render() {
  15928. return vue.h(
  15929. this.tag,
  15930. this.show && this.$slots.default ? this.$slots.default() : null
  15931. );
  15932. },
  15933. data() {
  15934. return {
  15935. el: null,
  15936. state: {
  15937. loaded: false
  15938. },
  15939. show: false
  15940. };
  15941. },
  15942. mounted() {
  15943. this.el = this.$el;
  15944. lazy.addLazyBox(this);
  15945. lazy.lazyLoadHandler();
  15946. },
  15947. beforeUnmount() {
  15948. lazy.removeComponent(this);
  15949. },
  15950. methods: {
  15951. checkInView() {
  15952. const rect = useRect(this.$el);
  15953. return inBrowser && rect.top < window.innerHeight * lazy.options.preLoad && rect.bottom > 0 && rect.left < window.innerWidth * lazy.options.preLoad && rect.right > 0;
  15954. },
  15955. load() {
  15956. this.show = true;
  15957. this.state.loaded = true;
  15958. this.$emit("show", this);
  15959. },
  15960. destroy() {
  15961. return this.$destroy;
  15962. }
  15963. }
  15964. });
  15965. const defaultOptions = {
  15966. selector: "img"
  15967. };
  15968. class LazyContainer {
  15969. constructor({ el, binding, vnode, lazy }) {
  15970. this.el = null;
  15971. this.vnode = vnode;
  15972. this.binding = binding;
  15973. this.options = {};
  15974. this.lazy = lazy;
  15975. this.queue = [];
  15976. this.update({ el, binding });
  15977. }
  15978. update({ el, binding }) {
  15979. this.el = el;
  15980. this.options = Object.assign({}, defaultOptions, binding.value);
  15981. const imgs = this.getImgs();
  15982. imgs.forEach((el2) => {
  15983. this.lazy.add(
  15984. el2,
  15985. Object.assign({}, this.binding, {
  15986. value: {
  15987. src: "dataset" in el2 ? el2.dataset.src : el2.getAttribute("data-src"),
  15988. error: ("dataset" in el2 ? el2.dataset.error : el2.getAttribute("data-error")) || this.options.error,
  15989. loading: ("dataset" in el2 ? el2.dataset.loading : el2.getAttribute("data-loading")) || this.options.loading
  15990. }
  15991. }),
  15992. this.vnode
  15993. );
  15994. });
  15995. }
  15996. getImgs() {
  15997. return Array.from(this.el.querySelectorAll(this.options.selector));
  15998. }
  15999. clear() {
  16000. const imgs = this.getImgs();
  16001. imgs.forEach((el) => this.lazy.remove(el));
  16002. this.vnode = null;
  16003. this.binding = null;
  16004. this.lazy = null;
  16005. }
  16006. }
  16007. class LazyContainerManager {
  16008. constructor({ lazy }) {
  16009. this.lazy = lazy;
  16010. this.queue = [];
  16011. }
  16012. bind(el, binding, vnode) {
  16013. const container = new LazyContainer({
  16014. el,
  16015. binding,
  16016. vnode,
  16017. lazy: this.lazy
  16018. });
  16019. this.queue.push(container);
  16020. }
  16021. update(el, binding, vnode) {
  16022. const container = this.queue.find((item) => item.el === el);
  16023. if (!container)
  16024. return;
  16025. container.update({ el, binding, vnode });
  16026. }
  16027. unbind(el) {
  16028. const container = this.queue.find((item) => item.el === el);
  16029. if (!container)
  16030. return;
  16031. container.clear();
  16032. remove(this.queue, container);
  16033. }
  16034. }
  16035. var stdin_default$1 = (lazyManager) => ({
  16036. props: {
  16037. src: [String, Object],
  16038. tag: {
  16039. type: String,
  16040. default: "img"
  16041. }
  16042. },
  16043. render(h) {
  16044. return h(
  16045. this.tag,
  16046. {
  16047. attrs: {
  16048. src: this.renderSrc
  16049. }
  16050. },
  16051. this.$slots.default
  16052. );
  16053. },
  16054. data() {
  16055. return {
  16056. el: null,
  16057. options: {
  16058. src: "",
  16059. error: "",
  16060. loading: "",
  16061. attempt: lazyManager.options.attempt
  16062. },
  16063. state: {
  16064. loaded: false,
  16065. error: false,
  16066. attempt: 0
  16067. },
  16068. renderSrc: ""
  16069. };
  16070. },
  16071. watch: {
  16072. src() {
  16073. this.init();
  16074. lazyManager.addLazyBox(this);
  16075. lazyManager.lazyLoadHandler();
  16076. }
  16077. },
  16078. created() {
  16079. this.init();
  16080. this.renderSrc = this.options.loading;
  16081. },
  16082. mounted() {
  16083. this.el = this.$el;
  16084. lazyManager.addLazyBox(this);
  16085. lazyManager.lazyLoadHandler();
  16086. },
  16087. beforeUnmount() {
  16088. lazyManager.removeComponent(this);
  16089. },
  16090. methods: {
  16091. init() {
  16092. const { src, loading, error } = lazyManager.valueFormatter(this.src);
  16093. this.state.loaded = false;
  16094. this.options.src = src;
  16095. this.options.error = error;
  16096. this.options.loading = loading;
  16097. this.renderSrc = this.options.loading;
  16098. },
  16099. checkInView() {
  16100. const rect = useRect(this.$el);
  16101. return rect.top < window.innerHeight * lazyManager.options.preLoad && rect.bottom > 0 && rect.left < window.innerWidth * lazyManager.options.preLoad && rect.right > 0;
  16102. },
  16103. load(onFinish = noop) {
  16104. if (this.state.attempt > this.options.attempt - 1 && this.state.error) {
  16105. onFinish();
  16106. return;
  16107. }
  16108. const { src } = this.options;
  16109. loadImageAsync(
  16110. { src },
  16111. ({ src: src2 }) => {
  16112. this.renderSrc = src2;
  16113. this.state.loaded = true;
  16114. },
  16115. () => {
  16116. this.state.attempt++;
  16117. this.renderSrc = this.options.error;
  16118. this.state.error = true;
  16119. }
  16120. );
  16121. }
  16122. }
  16123. });
  16124. const Lazyload = {
  16125. install(app, options = {}) {
  16126. const LazyClass = stdin_default$3();
  16127. const lazy = new LazyClass(options);
  16128. const lazyContainer = new LazyContainerManager({ lazy });
  16129. app.config.globalProperties.$Lazyload = lazy;
  16130. if (options.lazyComponent) {
  16131. app.component("LazyComponent", stdin_default$2(lazy));
  16132. }
  16133. if (options.lazyImage) {
  16134. app.component("LazyImage", stdin_default$1(lazy));
  16135. }
  16136. app.directive("lazy", {
  16137. beforeMount: lazy.add.bind(lazy),
  16138. updated: lazy.update.bind(lazy),
  16139. unmounted: lazy.remove.bind(lazy)
  16140. });
  16141. app.directive("lazy-container", {
  16142. beforeMount: lazyContainer.bind.bind(lazyContainer),
  16143. updated: lazyContainer.update.bind(lazyContainer),
  16144. unmounted: lazyContainer.unbind.bind(lazyContainer)
  16145. });
  16146. }
  16147. };
  16148. const version = "3.6.4";
  16149. function install(app) {
  16150. const components = [
  16151. ActionBar,
  16152. ActionBarButton,
  16153. ActionBarIcon,
  16154. ActionSheet,
  16155. AddressEdit,
  16156. AddressList,
  16157. Area,
  16158. Badge,
  16159. Button,
  16160. Calendar,
  16161. Card,
  16162. Cascader,
  16163. Cell,
  16164. CellGroup,
  16165. Checkbox,
  16166. CheckboxGroup,
  16167. Circle,
  16168. Col,
  16169. Collapse,
  16170. CollapseItem,
  16171. ConfigProvider,
  16172. ContactCard,
  16173. ContactEdit,
  16174. ContactList,
  16175. CountDown,
  16176. Coupon,
  16177. CouponCell,
  16178. CouponList,
  16179. DatetimePicker,
  16180. Dialog,
  16181. Divider,
  16182. DropdownItem,
  16183. DropdownMenu,
  16184. Empty,
  16185. Field,
  16186. Form,
  16187. Grid,
  16188. GridItem,
  16189. Icon,
  16190. Image$1,
  16191. ImagePreview,
  16192. IndexAnchor,
  16193. IndexBar,
  16194. List,
  16195. Loading,
  16196. Locale,
  16197. NavBar,
  16198. NoticeBar,
  16199. Notify,
  16200. NumberKeyboard,
  16201. Overlay,
  16202. Pagination,
  16203. PasswordInput,
  16204. Picker,
  16205. Popover,
  16206. Popup,
  16207. Progress,
  16208. PullRefresh,
  16209. Radio,
  16210. RadioGroup,
  16211. Rate,
  16212. Row,
  16213. Search,
  16214. ShareSheet,
  16215. Sidebar,
  16216. SidebarItem,
  16217. Skeleton,
  16218. Slider,
  16219. Space,
  16220. Step,
  16221. Stepper,
  16222. Steps,
  16223. Sticky,
  16224. SubmitBar,
  16225. Swipe,
  16226. SwipeCell,
  16227. SwipeItem,
  16228. Switch,
  16229. Tab,
  16230. Tabbar,
  16231. TabbarItem,
  16232. Tabs,
  16233. Tag,
  16234. Toast,
  16235. TreeSelect,
  16236. Uploader
  16237. ];
  16238. components.forEach((item) => {
  16239. if (item.install) {
  16240. app.use(item);
  16241. } else if (item.name) {
  16242. app.component(item.name, item);
  16243. }
  16244. });
  16245. }
  16246. var stdin_default = {
  16247. install,
  16248. version
  16249. };
  16250. exports2.ActionBar = ActionBar;
  16251. exports2.ActionBarButton = ActionBarButton;
  16252. exports2.ActionBarIcon = ActionBarIcon;
  16253. exports2.ActionSheet = ActionSheet;
  16254. exports2.AddressEdit = AddressEdit;
  16255. exports2.AddressList = AddressList;
  16256. exports2.Area = Area;
  16257. exports2.Badge = Badge;
  16258. exports2.Button = Button;
  16259. exports2.Calendar = Calendar;
  16260. exports2.Card = Card;
  16261. exports2.Cascader = Cascader;
  16262. exports2.Cell = Cell;
  16263. exports2.CellGroup = CellGroup;
  16264. exports2.Checkbox = Checkbox;
  16265. exports2.CheckboxGroup = CheckboxGroup;
  16266. exports2.Circle = Circle;
  16267. exports2.Col = Col;
  16268. exports2.Collapse = Collapse;
  16269. exports2.CollapseItem = CollapseItem;
  16270. exports2.ConfigProvider = ConfigProvider;
  16271. exports2.ContactCard = ContactCard;
  16272. exports2.ContactEdit = ContactEdit;
  16273. exports2.ContactList = ContactList;
  16274. exports2.CountDown = CountDown;
  16275. exports2.Coupon = Coupon;
  16276. exports2.CouponCell = CouponCell;
  16277. exports2.CouponList = CouponList;
  16278. exports2.DatetimePicker = DatetimePicker;
  16279. exports2.Dialog = Dialog;
  16280. exports2.Divider = Divider;
  16281. exports2.DropdownItem = DropdownItem;
  16282. exports2.DropdownMenu = DropdownMenu;
  16283. exports2.Empty = Empty;
  16284. exports2.Field = Field;
  16285. exports2.Form = Form;
  16286. exports2.Grid = Grid;
  16287. exports2.GridItem = GridItem;
  16288. exports2.Icon = Icon;
  16289. exports2.Image = Image$1;
  16290. exports2.ImagePreview = ImagePreview;
  16291. exports2.IndexAnchor = IndexAnchor;
  16292. exports2.IndexBar = IndexBar;
  16293. exports2.Lazyload = Lazyload;
  16294. exports2.List = List;
  16295. exports2.Loading = Loading;
  16296. exports2.Locale = Locale;
  16297. exports2.NavBar = NavBar;
  16298. exports2.NoticeBar = NoticeBar;
  16299. exports2.Notify = Notify;
  16300. exports2.NumberKeyboard = NumberKeyboard;
  16301. exports2.Overlay = Overlay;
  16302. exports2.Pagination = Pagination;
  16303. exports2.PasswordInput = PasswordInput;
  16304. exports2.Picker = Picker;
  16305. exports2.Popover = Popover;
  16306. exports2.Popup = Popup;
  16307. exports2.Progress = Progress;
  16308. exports2.PullRefresh = PullRefresh;
  16309. exports2.Radio = Radio;
  16310. exports2.RadioGroup = RadioGroup;
  16311. exports2.Rate = Rate;
  16312. exports2.Row = Row;
  16313. exports2.Search = Search;
  16314. exports2.ShareSheet = ShareSheet;
  16315. exports2.Sidebar = Sidebar;
  16316. exports2.SidebarItem = SidebarItem;
  16317. exports2.Skeleton = Skeleton;
  16318. exports2.Slider = Slider;
  16319. exports2.Space = Space;
  16320. exports2.Step = Step;
  16321. exports2.Stepper = Stepper;
  16322. exports2.Steps = Steps;
  16323. exports2.Sticky = Sticky;
  16324. exports2.SubmitBar = SubmitBar;
  16325. exports2.Swipe = Swipe;
  16326. exports2.SwipeCell = SwipeCell;
  16327. exports2.SwipeItem = SwipeItem;
  16328. exports2.Switch = Switch;
  16329. exports2.Tab = Tab;
  16330. exports2.Tabbar = Tabbar;
  16331. exports2.TabbarItem = TabbarItem;
  16332. exports2.Tabs = Tabs;
  16333. exports2.Tag = Tag;
  16334. exports2.Toast = Toast;
  16335. exports2.TreeSelect = TreeSelect;
  16336. exports2.Uploader = Uploader;
  16337. exports2.default = stdin_default;
  16338. exports2.install = install;
  16339. exports2.version = version;
  16340. Object.defineProperties(exports2, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
  16341. });