uni-h5.es.js 749 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917
  1. var __defProp = Object.defineProperty;
  2. var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  3. var __publicField = (obj, key, value) => {
  4. __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
  5. return value;
  6. };
  7. import { withModifiers, createVNode, getCurrentInstance, ref, defineComponent, openBlock, createElementBlock, onMounted, provide, computed, watch, onUnmounted, inject, onBeforeUnmount, mergeProps, injectHook, reactive, onActivated, nextTick, onBeforeMount, withDirectives, vModelDynamic, vShow, shallowRef, watchEffect, isVNode, Fragment, markRaw, Comment, h, createTextVNode, isReactive, Transition, createApp, createBlock, onBeforeActivate, onBeforeDeactivate, renderList, effectScope, withCtx, KeepAlive, resolveDynamicComponent, createElementVNode, normalizeStyle, renderSlot } from "vue";
  8. import { isArray, isString, extend, remove, stringifyStyle, parseStringStyle, isPlainObject, isFunction, capitalize, camelize, hasOwn, isObject, toRawType, makeMap as makeMap$1, isPromise, hyphenate, invokeArrayFns as invokeArrayFns$1 } from "@vue/shared";
  9. import { once, UNI_STORAGE_LOCALE, I18N_JSON_DELIMITERS, Emitter, passive, initCustomDatasetOnce, resolveComponentInstance, normalizeStyles, addLeadingSlash, invokeArrayFns, removeLeadingSlash, resolveOwnerVm, resolveOwnerEl, ON_WXS_INVOKE_CALL_METHOD, ON_RESIZE, ON_APP_ENTER_FOREGROUND, ON_APP_ENTER_BACKGROUND, ON_SHOW, ON_HIDE, ON_PAGE_SCROLL, ON_REACH_BOTTOM, EventChannel, SCHEME_RE, DATA_RE, getCustomDataset, LINEFEED, ON_ERROR, callOptions, ON_UNHANDLE_REJECTION, ON_PAGE_NOT_FOUND, PRIMARY_COLOR, getLen, debounce, isUniLifecycleHook, ON_LOAD, UniLifecycleHooks, invokeCreateErrorHandler, invokeCreateVueAppHook, parseQuery, NAVBAR_HEIGHT, ON_UNLOAD, ON_REACH_BOTTOM_DISTANCE, ON_THEME_CHANGE, decodedQuery, WEB_INVOKE_APPSERVICE, ON_WEB_INVOKE_APP_SERVICE, sortObject, OFF_THEME_CHANGE, updateElementStyle, ON_BACK_PRESS, parseUrl, addFont, ON_NAVIGATION_BAR_CHANGE, scrollTo, RESPONSIVE_MIN_WIDTH, onCreateVueApp, formatDateTime, ON_NAVIGATION_BAR_BUTTON_TAP, ON_NAVIGATION_BAR_SEARCH_INPUT_CLICKED, ON_NAVIGATION_BAR_SEARCH_INPUT_FOCUS_CHANGED, ON_NAVIGATION_BAR_SEARCH_INPUT_CHANGED, ON_NAVIGATION_BAR_SEARCH_INPUT_CONFIRMED, ON_PULL_DOWN_REFRESH } from "@dcloudio/uni-shared";
  10. import { onCreateVueApp as onCreateVueApp2 } from "@dcloudio/uni-shared";
  11. import { initVueI18n, isI18nStr, LOCALE_EN, LOCALE_ES, LOCALE_FR, LOCALE_ZH_HANS, LOCALE_ZH_HANT } from "@dcloudio/uni-i18n";
  12. import { useRoute, createRouter, createWebHistory, createWebHashHistory, useRouter, isNavigationFailure, RouterView } from "vue-router";
  13. const isEnableLocale = /* @__PURE__ */ once(
  14. () => typeof __uniConfig !== "undefined" && __uniConfig.locales && !!Object.keys(__uniConfig.locales).length
  15. );
  16. let i18n;
  17. function getLocaleMessage() {
  18. const locale = uni.getLocale();
  19. const locales = __uniConfig.locales;
  20. return locales[locale] || locales[__uniConfig.fallbackLocale] || locales.en || {};
  21. }
  22. function formatI18n(message) {
  23. if (isI18nStr(message, I18N_JSON_DELIMITERS)) {
  24. return useI18n().f(message, getLocaleMessage(), I18N_JSON_DELIMITERS);
  25. }
  26. return message;
  27. }
  28. function resolveJsonObj(jsonObj, names) {
  29. if (names.length === 1) {
  30. if (jsonObj) {
  31. const _isI18nStr = (value2) => isString(value2) && isI18nStr(value2, I18N_JSON_DELIMITERS);
  32. const _name = names[0];
  33. let filterJsonObj = [];
  34. if (isArray(jsonObj) && (filterJsonObj = jsonObj.filter((item) => _isI18nStr(item[_name]))).length) {
  35. return filterJsonObj;
  36. }
  37. const value = jsonObj[names[0]];
  38. if (_isI18nStr(value)) {
  39. return jsonObj;
  40. }
  41. }
  42. return;
  43. }
  44. const name = names.shift();
  45. return resolveJsonObj(jsonObj && jsonObj[name], names);
  46. }
  47. function defineI18nProperties(obj, names) {
  48. return names.map((name) => defineI18nProperty(obj, name));
  49. }
  50. function defineI18nProperty(obj, names) {
  51. const jsonObj = resolveJsonObj(obj, names);
  52. if (!jsonObj) {
  53. return false;
  54. }
  55. const prop = names[names.length - 1];
  56. if (isArray(jsonObj)) {
  57. jsonObj.forEach((item) => defineI18nProperty(item, [prop]));
  58. } else {
  59. let value = jsonObj[prop];
  60. Object.defineProperty(jsonObj, prop, {
  61. get() {
  62. return formatI18n(value);
  63. },
  64. set(v2) {
  65. value = v2;
  66. }
  67. });
  68. }
  69. return true;
  70. }
  71. function useI18n() {
  72. if (!i18n) {
  73. let locale;
  74. {
  75. {
  76. locale = navigator.cookieEnabled && window.localStorage && localStorage[UNI_STORAGE_LOCALE] || __uniConfig.locale || navigator.language;
  77. }
  78. }
  79. i18n = initVueI18n(locale);
  80. if (isEnableLocale()) {
  81. const localeKeys = Object.keys(__uniConfig.locales || {});
  82. if (localeKeys.length) {
  83. localeKeys.forEach(
  84. (locale2) => i18n.add(locale2, __uniConfig.locales[locale2])
  85. );
  86. }
  87. i18n.setLocale(locale);
  88. }
  89. }
  90. return i18n;
  91. }
  92. function normalizeMessages(module, keys, values) {
  93. return keys.reduce((res, name, index2) => {
  94. res[module + name] = values[index2];
  95. return res;
  96. }, {});
  97. }
  98. const initI18nAsyncMsgsOnce = /* @__PURE__ */ once(() => {
  99. const name = "uni.async.";
  100. const keys = ["error"];
  101. if (__UNI_FEATURE_I18N_EN__) {
  102. useI18n().add(
  103. LOCALE_EN,
  104. normalizeMessages(name, keys, [
  105. "The connection timed out, click the screen to try again."
  106. ]),
  107. false
  108. );
  109. }
  110. if (__UNI_FEATURE_I18N_ES__) {
  111. useI18n().add(
  112. LOCALE_ES,
  113. normalizeMessages(name, keys, [
  114. "Se agotó el tiempo de conexión, haga clic en la pantalla para volver a intentarlo."
  115. ]),
  116. false
  117. );
  118. }
  119. if (__UNI_FEATURE_I18N_FR__) {
  120. useI18n().add(
  121. LOCALE_FR,
  122. normalizeMessages(name, keys, [
  123. "La connexion a expiré, cliquez sur l'écran pour réessayer."
  124. ]),
  125. false
  126. );
  127. }
  128. if (__UNI_FEATURE_I18N_ZH_HANS__) {
  129. useI18n().add(
  130. LOCALE_ZH_HANS,
  131. normalizeMessages(name, keys, ["连接服务器超时,点击屏幕重试"]),
  132. false
  133. );
  134. }
  135. if (__UNI_FEATURE_I18N_ZH_HANT__) {
  136. useI18n().add(
  137. LOCALE_ZH_HANT,
  138. normalizeMessages(name, keys, ["連接服務器超時,點擊屏幕重試"]),
  139. false
  140. );
  141. }
  142. });
  143. const initI18nShowActionSheetMsgsOnce = /* @__PURE__ */ once(() => {
  144. const name = "uni.showActionSheet.";
  145. const keys = ["cancel"];
  146. if (__UNI_FEATURE_I18N_EN__) {
  147. useI18n().add(LOCALE_EN, normalizeMessages(name, keys, ["Cancel"]), false);
  148. }
  149. if (__UNI_FEATURE_I18N_ES__) {
  150. useI18n().add(LOCALE_ES, normalizeMessages(name, keys, ["Cancelar"]), false);
  151. }
  152. if (__UNI_FEATURE_I18N_FR__) {
  153. useI18n().add(LOCALE_FR, normalizeMessages(name, keys, ["Annuler"]), false);
  154. }
  155. if (__UNI_FEATURE_I18N_ZH_HANS__) {
  156. useI18n().add(
  157. LOCALE_ZH_HANS,
  158. normalizeMessages(name, keys, ["取消"]),
  159. false
  160. );
  161. }
  162. if (__UNI_FEATURE_I18N_ZH_HANT__) {
  163. useI18n().add(
  164. LOCALE_ZH_HANT,
  165. normalizeMessages(name, keys, ["取消"]),
  166. false
  167. );
  168. }
  169. });
  170. const initI18nShowToastMsgsOnce = /* @__PURE__ */ once(() => {
  171. const name = "uni.showToast.";
  172. const keys = ["unpaired"];
  173. if (__UNI_FEATURE_I18N_EN__) {
  174. useI18n().add(
  175. LOCALE_EN,
  176. normalizeMessages(name, keys, [
  177. "Please note showToast must be paired with hideToast"
  178. ]),
  179. false
  180. );
  181. }
  182. if (__UNI_FEATURE_I18N_ES__) {
  183. useI18n().add(
  184. LOCALE_ES,
  185. normalizeMessages(name, keys, [
  186. "Tenga en cuenta que showToast debe estar emparejado con hideToast"
  187. ]),
  188. false
  189. );
  190. }
  191. if (__UNI_FEATURE_I18N_FR__) {
  192. useI18n().add(
  193. LOCALE_FR,
  194. normalizeMessages(name, keys, [
  195. "Veuillez noter que showToast doit être associé à hideToast"
  196. ]),
  197. false
  198. );
  199. }
  200. if (__UNI_FEATURE_I18N_ZH_HANS__) {
  201. useI18n().add(
  202. LOCALE_ZH_HANS,
  203. normalizeMessages(name, keys, [
  204. "请注意 showToast 与 hideToast 必须配对使用"
  205. ]),
  206. false
  207. );
  208. }
  209. if (__UNI_FEATURE_I18N_ZH_HANT__) {
  210. useI18n().add(
  211. LOCALE_ZH_HANT,
  212. normalizeMessages(name, keys, [
  213. "請注意 showToast 與 hideToast 必須配對使用"
  214. ]),
  215. false
  216. );
  217. }
  218. });
  219. const initI18nShowLoadingMsgsOnce = /* @__PURE__ */ once(() => {
  220. const name = "uni.showLoading.";
  221. const keys = ["unpaired"];
  222. if (__UNI_FEATURE_I18N_EN__) {
  223. useI18n().add(
  224. LOCALE_EN,
  225. normalizeMessages(name, keys, [
  226. "Please note showLoading must be paired with hideLoading"
  227. ]),
  228. false
  229. );
  230. }
  231. if (__UNI_FEATURE_I18N_ES__) {
  232. useI18n().add(
  233. LOCALE_ES,
  234. normalizeMessages(name, keys, [
  235. "Tenga en cuenta que showLoading debe estar emparejado con hideLoading"
  236. ]),
  237. false
  238. );
  239. }
  240. if (__UNI_FEATURE_I18N_FR__) {
  241. useI18n().add(
  242. LOCALE_FR,
  243. normalizeMessages(name, keys, [
  244. "Veuillez noter que showLoading doit être associé à hideLoading"
  245. ]),
  246. false
  247. );
  248. }
  249. if (__UNI_FEATURE_I18N_ZH_HANS__) {
  250. useI18n().add(
  251. LOCALE_ZH_HANS,
  252. normalizeMessages(name, keys, [
  253. "请注意 showLoading 与 hideLoading 必须配对使用"
  254. ]),
  255. false
  256. );
  257. }
  258. if (__UNI_FEATURE_I18N_ZH_HANT__) {
  259. useI18n().add(
  260. LOCALE_ZH_HANT,
  261. normalizeMessages(name, keys, [
  262. "請注意 showLoading 與 hideLoading 必須配對使用"
  263. ]),
  264. false
  265. );
  266. }
  267. });
  268. const initI18nShowModalMsgsOnce = /* @__PURE__ */ once(() => {
  269. const name = "uni.showModal.";
  270. const keys = ["cancel", "confirm"];
  271. if (__UNI_FEATURE_I18N_EN__) {
  272. useI18n().add(
  273. LOCALE_EN,
  274. normalizeMessages(name, keys, ["Cancel", "OK"]),
  275. false
  276. );
  277. }
  278. if (__UNI_FEATURE_I18N_ES__) {
  279. useI18n().add(
  280. LOCALE_ES,
  281. normalizeMessages(name, keys, ["Cancelar", "OK"]),
  282. false
  283. );
  284. }
  285. if (__UNI_FEATURE_I18N_FR__) {
  286. useI18n().add(
  287. LOCALE_FR,
  288. normalizeMessages(name, keys, ["Annuler", "OK"]),
  289. false
  290. );
  291. }
  292. if (__UNI_FEATURE_I18N_ZH_HANS__) {
  293. useI18n().add(
  294. LOCALE_ZH_HANS,
  295. normalizeMessages(name, keys, ["取消", "确定"]),
  296. false
  297. );
  298. }
  299. if (__UNI_FEATURE_I18N_ZH_HANT__) {
  300. useI18n().add(
  301. LOCALE_ZH_HANT,
  302. normalizeMessages(name, keys, ["取消", "確定"]),
  303. false
  304. );
  305. }
  306. });
  307. const initI18nChooseFileMsgsOnce = /* @__PURE__ */ once(() => {
  308. const name = "uni.chooseFile.";
  309. const keys = ["notUserActivation"];
  310. if (__UNI_FEATURE_I18N_EN__) {
  311. useI18n().add(
  312. LOCALE_EN,
  313. normalizeMessages(name, keys, [
  314. "File chooser dialog can only be shown with a user activation"
  315. ]),
  316. false
  317. );
  318. }
  319. if (__UNI_FEATURE_I18N_ES__) {
  320. useI18n().add(
  321. LOCALE_ES,
  322. normalizeMessages(name, keys, [
  323. "El cuadro de diálogo del selector de archivos solo se puede mostrar con la activación del usuario"
  324. ]),
  325. false
  326. );
  327. }
  328. if (__UNI_FEATURE_I18N_FR__) {
  329. useI18n().add(
  330. LOCALE_FR,
  331. normalizeMessages(name, keys, [
  332. "La boîte de dialogue du sélecteur de fichier ne peut être affichée qu'avec une activation par l'utilisateur"
  333. ]),
  334. false
  335. );
  336. }
  337. if (__UNI_FEATURE_I18N_ZH_HANS__) {
  338. useI18n().add(
  339. LOCALE_ZH_HANS,
  340. normalizeMessages(name, keys, ["文件选择器对话框只能在由用户激活时显示"]),
  341. false
  342. );
  343. }
  344. if (__UNI_FEATURE_I18N_ZH_HANT__) {
  345. useI18n().add(
  346. LOCALE_ZH_HANT,
  347. normalizeMessages(name, keys, ["文件選擇器對話框只能在由用戶激活時顯示"]),
  348. false
  349. );
  350. }
  351. });
  352. const initI18nSetClipboardDataMsgsOnce = /* @__PURE__ */ once(() => {
  353. const name = "uni.setClipboardData.";
  354. const keys = ["success", "fail"];
  355. if (__UNI_FEATURE_I18N_EN__) {
  356. useI18n().add(
  357. LOCALE_EN,
  358. normalizeMessages(name, keys, [
  359. "Content copied",
  360. "Copy failed, please copy manually"
  361. ]),
  362. false
  363. );
  364. }
  365. if (__UNI_FEATURE_I18N_ES__) {
  366. useI18n().add(
  367. LOCALE_ES,
  368. normalizeMessages(name, keys, [
  369. "Contenido copiado",
  370. "Error al copiar, copie manualmente"
  371. ]),
  372. false
  373. );
  374. }
  375. if (__UNI_FEATURE_I18N_FR__) {
  376. useI18n().add(
  377. LOCALE_FR,
  378. normalizeMessages(name, keys, [
  379. "Contenu copié",
  380. "Échec de la copie, copiez manuellement"
  381. ]),
  382. false
  383. );
  384. }
  385. if (__UNI_FEATURE_I18N_ZH_HANS__) {
  386. useI18n().add(
  387. LOCALE_ZH_HANS,
  388. normalizeMessages(name, keys, ["内容已复制", "复制失败,请手动复制"]),
  389. false
  390. );
  391. }
  392. if (__UNI_FEATURE_I18N_ZH_HANT__) {
  393. useI18n().add(
  394. LOCALE_ZH_HANT,
  395. normalizeMessages(name, keys, ["內容已復制", "復制失敗,請手動復製"]),
  396. false
  397. );
  398. }
  399. });
  400. const initI18nGetClipboardDataMsgsOnce = /* @__PURE__ */ once(() => {
  401. const name = "uni.getClipboardData.";
  402. const keys = ["fail"];
  403. if (__UNI_FEATURE_I18N_EN__) {
  404. useI18n().add(
  405. LOCALE_EN,
  406. normalizeMessages(name, keys, ["Reading failed, please paste manually"]),
  407. false
  408. );
  409. }
  410. if (__UNI_FEATURE_I18N_ES__) {
  411. useI18n().add(
  412. LOCALE_ES,
  413. normalizeMessages(name, keys, ["Error de lectura, pegue manualmente"]),
  414. false
  415. );
  416. }
  417. if (__UNI_FEATURE_I18N_FR__) {
  418. useI18n().add(
  419. LOCALE_FR,
  420. normalizeMessages(name, keys, [
  421. "Échec de la lecture, veuillez coller manuellement"
  422. ]),
  423. false
  424. );
  425. }
  426. if (__UNI_FEATURE_I18N_ZH_HANS__) {
  427. useI18n().add(
  428. LOCALE_ZH_HANS,
  429. normalizeMessages(name, keys, ["读取失败,请手动粘贴"]),
  430. false
  431. );
  432. }
  433. if (__UNI_FEATURE_I18N_ZH_HANT__) {
  434. useI18n().add(
  435. LOCALE_ZH_HANT,
  436. normalizeMessages(name, keys, ["讀取失敗,請手動粘貼"]),
  437. false
  438. );
  439. }
  440. });
  441. const initI18nPickerMsgsOnce = /* @__PURE__ */ once(() => {
  442. const name = "uni.picker.";
  443. const keys = ["done", "cancel"];
  444. if (__UNI_FEATURE_I18N_EN__) {
  445. useI18n().add(
  446. LOCALE_EN,
  447. normalizeMessages(name, keys, ["Done", "Cancel"]),
  448. false
  449. );
  450. }
  451. if (__UNI_FEATURE_I18N_ES__) {
  452. useI18n().add(
  453. LOCALE_ES,
  454. normalizeMessages(name, keys, ["OK", "Cancelar"]),
  455. false
  456. );
  457. }
  458. if (__UNI_FEATURE_I18N_FR__) {
  459. useI18n().add(
  460. LOCALE_FR,
  461. normalizeMessages(name, keys, ["OK", "Annuler"]),
  462. false
  463. );
  464. }
  465. if (__UNI_FEATURE_I18N_ZH_HANS__) {
  466. useI18n().add(
  467. LOCALE_ZH_HANS,
  468. normalizeMessages(name, keys, ["完成", "取消"]),
  469. false
  470. );
  471. }
  472. if (__UNI_FEATURE_I18N_ZH_HANT__) {
  473. useI18n().add(
  474. LOCALE_ZH_HANT,
  475. normalizeMessages(name, keys, ["完成", "取消"]),
  476. false
  477. );
  478. }
  479. });
  480. const initI18nVideoMsgsOnce = /* @__PURE__ */ once(() => {
  481. const name = "uni.video.";
  482. const keys = ["danmu", "volume"];
  483. if (__UNI_FEATURE_I18N_EN__) {
  484. useI18n().add(
  485. LOCALE_EN,
  486. normalizeMessages(name, keys, ["Danmu", "Volume"]),
  487. false
  488. );
  489. }
  490. if (__UNI_FEATURE_I18N_ES__) {
  491. useI18n().add(
  492. LOCALE_ES,
  493. normalizeMessages(name, keys, ["Danmu", "Volumen"]),
  494. false
  495. );
  496. }
  497. if (__UNI_FEATURE_I18N_FR__) {
  498. useI18n().add(
  499. LOCALE_FR,
  500. normalizeMessages(name, keys, ["Danmu", "Le Volume"]),
  501. false
  502. );
  503. }
  504. if (__UNI_FEATURE_I18N_ZH_HANS__) {
  505. useI18n().add(
  506. LOCALE_ZH_HANS,
  507. normalizeMessages(name, keys, ["弹幕", "音量"]),
  508. false
  509. );
  510. }
  511. if (__UNI_FEATURE_I18N_ZH_HANT__) {
  512. useI18n().add(
  513. LOCALE_ZH_HANT,
  514. normalizeMessages(name, keys, ["彈幕", "音量"]),
  515. false
  516. );
  517. }
  518. });
  519. const initI18nChooseLocationMsgsOnce = /* @__PURE__ */ once(() => {
  520. const name = "uni.chooseLocation.";
  521. const keys = ["search", "cancel"];
  522. if (__UNI_FEATURE_I18N_EN__) {
  523. useI18n().add(
  524. LOCALE_EN,
  525. normalizeMessages(name, keys, ["Find Place", "Cancel"]),
  526. false
  527. );
  528. }
  529. if (__UNI_FEATURE_I18N_ES__) {
  530. useI18n().add(
  531. LOCALE_ES,
  532. normalizeMessages(name, keys, ["Encontrar", "Cancelar"]),
  533. false
  534. );
  535. }
  536. if (__UNI_FEATURE_I18N_FR__) {
  537. useI18n().add(
  538. LOCALE_FR,
  539. normalizeMessages(name, keys, ["Trouve", "Annuler"]),
  540. false
  541. );
  542. }
  543. if (__UNI_FEATURE_I18N_ZH_HANS__) {
  544. useI18n().add(
  545. LOCALE_ZH_HANS,
  546. normalizeMessages(name, keys, ["搜索地点", "取消"]),
  547. false
  548. );
  549. }
  550. if (__UNI_FEATURE_I18N_ZH_HANT__) {
  551. useI18n().add(
  552. LOCALE_ZH_HANT,
  553. normalizeMessages(name, keys, ["搜索地點", "取消"]),
  554. false
  555. );
  556. }
  557. });
  558. function initNavigationBarI18n(navigationBar) {
  559. if (isEnableLocale()) {
  560. return defineI18nProperties(navigationBar, [
  561. ["titleText"],
  562. ["searchInput", "placeholder"],
  563. ["buttons", "text"]
  564. ]);
  565. }
  566. }
  567. function initTabBarI18n(tabBar2) {
  568. if (isEnableLocale() && tabBar2.list) {
  569. tabBar2.list.forEach((item) => {
  570. defineI18nProperty(item, ["text"]);
  571. });
  572. }
  573. return tabBar2;
  574. }
  575. function initBridge(subscribeNamespace) {
  576. const emitter2 = new Emitter();
  577. return {
  578. on(event, callback) {
  579. return emitter2.on(event, callback);
  580. },
  581. once(event, callback) {
  582. return emitter2.once(event, callback);
  583. },
  584. off(event, callback) {
  585. return emitter2.off(event, callback);
  586. },
  587. emit(event, ...args) {
  588. return emitter2.emit(event, ...args);
  589. },
  590. subscribe(event, callback, once2 = false) {
  591. emitter2[once2 ? "once" : "on"](`${subscribeNamespace}.${event}`, callback);
  592. },
  593. unsubscribe(event, callback) {
  594. emitter2.off(`${subscribeNamespace}.${event}`, callback);
  595. },
  596. subscribeHandler(event, args, pageId) {
  597. emitter2.emit(`${subscribeNamespace}.${event}`, args, pageId);
  598. }
  599. };
  600. }
  601. const INVOKE_VIEW_API = "invokeViewApi";
  602. const INVOKE_SERVICE_API = "invokeServiceApi";
  603. let invokeServiceMethodId = 1;
  604. const invokeServiceMethod = (name, args, callback) => {
  605. const { subscribe, publishHandler } = UniViewJSBridge;
  606. const id2 = callback ? invokeServiceMethodId++ : 0;
  607. callback && subscribe(INVOKE_SERVICE_API + "." + id2, callback, true);
  608. publishHandler(INVOKE_SERVICE_API, { id: id2, name, args });
  609. };
  610. const viewMethods = /* @__PURE__ */ Object.create(null);
  611. function normalizeViewMethodName(pageId, name) {
  612. return pageId + "." + name;
  613. }
  614. function subscribeViewMethod(pageId, wrapper2) {
  615. UniViewJSBridge.subscribe(
  616. normalizeViewMethodName(pageId, INVOKE_VIEW_API),
  617. wrapper2 ? wrapper2(onInvokeViewMethod) : onInvokeViewMethod
  618. );
  619. }
  620. function unsubscribeViewMethod(pageId) {
  621. UniViewJSBridge.unsubscribe(normalizeViewMethodName(pageId, INVOKE_VIEW_API));
  622. Object.keys(viewMethods).forEach((name) => {
  623. if (name.indexOf(pageId + ".") === 0) {
  624. delete viewMethods[name];
  625. }
  626. });
  627. }
  628. function registerViewMethod(pageId, name, fn) {
  629. name = normalizeViewMethodName(pageId, name);
  630. if (!viewMethods[name]) {
  631. viewMethods[name] = fn;
  632. }
  633. }
  634. function unregisterViewMethod(pageId, name) {
  635. name = normalizeViewMethodName(pageId, name);
  636. delete viewMethods[name];
  637. }
  638. function onInvokeViewMethod({
  639. id: id2,
  640. name,
  641. args
  642. }, pageId) {
  643. name = normalizeViewMethodName(pageId, name);
  644. const publish = (res) => {
  645. id2 && UniViewJSBridge.publishHandler(INVOKE_VIEW_API + "." + id2, res);
  646. };
  647. const handler = viewMethods[name];
  648. if (handler) {
  649. handler(args, publish);
  650. } else {
  651. publish({});
  652. }
  653. }
  654. const ViewJSBridge = /* @__PURE__ */ extend(
  655. /* @__PURE__ */ initBridge("service"),
  656. {
  657. invokeServiceMethod
  658. }
  659. );
  660. const LONGPRESS_TIMEOUT = 350;
  661. const LONGPRESS_THRESHOLD = 10;
  662. const passiveOptions$2 = /* @__PURE__ */ passive(true);
  663. let longPressTimer;
  664. function clearLongPressTimer() {
  665. if (longPressTimer) {
  666. clearTimeout(longPressTimer);
  667. longPressTimer = null;
  668. }
  669. }
  670. let startPageX = 0;
  671. let startPageY = 0;
  672. function touchstart(evt) {
  673. clearLongPressTimer();
  674. if (evt.touches.length !== 1) {
  675. return;
  676. }
  677. const { pageX, pageY } = evt.touches[0];
  678. startPageX = pageX;
  679. startPageY = pageY;
  680. longPressTimer = setTimeout(function() {
  681. const customEvent = new CustomEvent("longpress", {
  682. bubbles: true,
  683. cancelable: true,
  684. // @ts-ignore
  685. target: evt.target,
  686. currentTarget: evt.currentTarget
  687. });
  688. customEvent.touches = evt.touches;
  689. customEvent.changedTouches = evt.changedTouches;
  690. evt.target.dispatchEvent(customEvent);
  691. }, LONGPRESS_TIMEOUT);
  692. }
  693. function touchmove(evt) {
  694. if (!longPressTimer) {
  695. return;
  696. }
  697. if (evt.touches.length !== 1) {
  698. return clearLongPressTimer();
  699. }
  700. const { pageX, pageY } = evt.touches[0];
  701. if (Math.abs(pageX - startPageX) > LONGPRESS_THRESHOLD || Math.abs(pageY - startPageY) > LONGPRESS_THRESHOLD) {
  702. return clearLongPressTimer();
  703. }
  704. }
  705. function initLongPress() {
  706. window.addEventListener("touchstart", touchstart, passiveOptions$2);
  707. window.addEventListener("touchmove", touchmove, passiveOptions$2);
  708. window.addEventListener("touchend", clearLongPressTimer, passiveOptions$2);
  709. window.addEventListener("touchcancel", clearLongPressTimer, passiveOptions$2);
  710. }
  711. function checkValue$1(value, defaultValue) {
  712. const newValue = Number(value);
  713. return isNaN(newValue) ? defaultValue : newValue;
  714. }
  715. function getWindowWidth$1() {
  716. const screenFix = /^Apple/.test(navigator.vendor) && typeof window.orientation === "number";
  717. const landscape = screenFix && Math.abs(window.orientation) === 90;
  718. var screenWidth = screenFix ? Math[landscape ? "max" : "min"](screen.width, screen.height) : screen.width;
  719. var windowWidth = Math.min(
  720. window.innerWidth,
  721. document.documentElement.clientWidth,
  722. screenWidth
  723. ) || screenWidth;
  724. return windowWidth;
  725. }
  726. function useRem() {
  727. const config = __uniConfig.globalStyle || {};
  728. const maxWidth2 = checkValue$1(config.rpxCalcMaxDeviceWidth, 960);
  729. const baseWidth2 = checkValue$1(config.rpxCalcBaseDeviceWidth, 375);
  730. function updateRem() {
  731. let width = getWindowWidth$1();
  732. width = width <= maxWidth2 ? width : baseWidth2;
  733. document.documentElement.style.fontSize = width / 23.4375 + "px";
  734. }
  735. updateRem();
  736. document.addEventListener("DOMContentLoaded", updateRem);
  737. window.addEventListener("load", updateRem);
  738. window.addEventListener("resize", updateRem);
  739. }
  740. function initView() {
  741. useRem();
  742. initCustomDatasetOnce();
  743. if (__UNI_FEATURE_LONGPRESS__) {
  744. initLongPress();
  745. }
  746. }
  747. function getDefaultExportFromCjs(x) {
  748. return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
  749. }
  750. var attrs = ["top", "left", "right", "bottom"];
  751. var inited$1;
  752. var elementComputedStyle = {};
  753. var support;
  754. function getSupport() {
  755. if (!("CSS" in window) || typeof CSS.supports != "function") {
  756. support = "";
  757. } else if (CSS.supports("top: env(safe-area-inset-top)")) {
  758. support = "env";
  759. } else if (CSS.supports("top: constant(safe-area-inset-top)")) {
  760. support = "constant";
  761. } else {
  762. support = "";
  763. }
  764. return support;
  765. }
  766. function init() {
  767. support = typeof support === "string" ? support : getSupport();
  768. if (!support) {
  769. attrs.forEach(function(attr2) {
  770. elementComputedStyle[attr2] = 0;
  771. });
  772. return;
  773. }
  774. function setStyle(el, style) {
  775. var elStyle = el.style;
  776. Object.keys(style).forEach(function(key) {
  777. var val = style[key];
  778. elStyle[key] = val;
  779. });
  780. }
  781. var cbs = [];
  782. function parentReady(callback) {
  783. if (callback) {
  784. cbs.push(callback);
  785. } else {
  786. cbs.forEach(function(cb) {
  787. cb();
  788. });
  789. }
  790. }
  791. var passiveEvents = false;
  792. try {
  793. var opts = Object.defineProperty({}, "passive", {
  794. get: function() {
  795. passiveEvents = { passive: true };
  796. }
  797. });
  798. window.addEventListener("test", null, opts);
  799. } catch (e2) {
  800. }
  801. function addChild(parent, attr2) {
  802. var a1 = document.createElement("div");
  803. var a2 = document.createElement("div");
  804. var a1Children = document.createElement("div");
  805. var a2Children = document.createElement("div");
  806. var W = 100;
  807. var MAX = 1e4;
  808. var aStyle = {
  809. position: "absolute",
  810. width: W + "px",
  811. height: "200px",
  812. boxSizing: "border-box",
  813. overflow: "hidden",
  814. paddingBottom: support + "(safe-area-inset-" + attr2 + ")"
  815. };
  816. setStyle(a1, aStyle);
  817. setStyle(a2, aStyle);
  818. setStyle(a1Children, {
  819. transition: "0s",
  820. animation: "none",
  821. width: "400px",
  822. height: "400px"
  823. });
  824. setStyle(a2Children, {
  825. transition: "0s",
  826. animation: "none",
  827. width: "250%",
  828. height: "250%"
  829. });
  830. a1.appendChild(a1Children);
  831. a2.appendChild(a2Children);
  832. parent.appendChild(a1);
  833. parent.appendChild(a2);
  834. parentReady(function() {
  835. a1.scrollTop = a2.scrollTop = MAX;
  836. var a1LastScrollTop = a1.scrollTop;
  837. var a2LastScrollTop = a2.scrollTop;
  838. function onScroll() {
  839. if (this.scrollTop === (this === a1 ? a1LastScrollTop : a2LastScrollTop)) {
  840. return;
  841. }
  842. a1.scrollTop = a2.scrollTop = MAX;
  843. a1LastScrollTop = a1.scrollTop;
  844. a2LastScrollTop = a2.scrollTop;
  845. attrChange(attr2);
  846. }
  847. a1.addEventListener("scroll", onScroll, passiveEvents);
  848. a2.addEventListener("scroll", onScroll, passiveEvents);
  849. });
  850. var computedStyle = getComputedStyle(a1);
  851. Object.defineProperty(elementComputedStyle, attr2, {
  852. configurable: true,
  853. get: function() {
  854. return parseFloat(computedStyle.paddingBottom);
  855. }
  856. });
  857. }
  858. var parentDiv = document.createElement("div");
  859. setStyle(parentDiv, {
  860. position: "absolute",
  861. left: "0",
  862. top: "0",
  863. width: "0",
  864. height: "0",
  865. zIndex: "-1",
  866. overflow: "hidden",
  867. visibility: "hidden"
  868. });
  869. attrs.forEach(function(key) {
  870. addChild(parentDiv, key);
  871. });
  872. document.body.appendChild(parentDiv);
  873. parentReady();
  874. inited$1 = true;
  875. }
  876. function getAttr(attr2) {
  877. if (!inited$1) {
  878. init();
  879. }
  880. return elementComputedStyle[attr2];
  881. }
  882. var changeAttrs = [];
  883. function attrChange(attr2) {
  884. if (!changeAttrs.length) {
  885. setTimeout(function() {
  886. var style = {};
  887. changeAttrs.forEach(function(attr3) {
  888. style[attr3] = elementComputedStyle[attr3];
  889. });
  890. changeAttrs.length = 0;
  891. callbacks.forEach(function(callback) {
  892. callback(style);
  893. });
  894. }, 0);
  895. }
  896. changeAttrs.push(attr2);
  897. }
  898. var callbacks = [];
  899. function onChange(callback) {
  900. if (!getSupport()) {
  901. return;
  902. }
  903. if (!inited$1) {
  904. init();
  905. }
  906. if (typeof callback === "function") {
  907. callbacks.push(callback);
  908. }
  909. }
  910. function offChange(callback) {
  911. var index2 = callbacks.indexOf(callback);
  912. if (index2 >= 0) {
  913. callbacks.splice(index2, 1);
  914. }
  915. }
  916. var safeAreaInsets = {
  917. get support() {
  918. return (typeof support === "string" ? support : getSupport()).length != 0;
  919. },
  920. get top() {
  921. return getAttr("top");
  922. },
  923. get left() {
  924. return getAttr("left");
  925. },
  926. get right() {
  927. return getAttr("right");
  928. },
  929. get bottom() {
  930. return getAttr("bottom");
  931. },
  932. onChange,
  933. offChange
  934. };
  935. var out = safeAreaInsets;
  936. const safeAreaInsets$1 = /* @__PURE__ */ getDefaultExportFromCjs(out);
  937. const onEventPrevent = /* @__PURE__ */ withModifiers(() => {
  938. }, ["prevent"]);
  939. const onEventStop = /* @__PURE__ */ withModifiers(
  940. (_event) => {
  941. },
  942. ["stop"]
  943. );
  944. function getWindowOffsetCssVar(style, name) {
  945. return parseInt((style.getPropertyValue(name).match(/\d+/) || ["0"])[0]);
  946. }
  947. function getWindowTop() {
  948. const style = document.documentElement.style;
  949. const top = getWindowOffsetCssVar(style, "--window-top");
  950. return top ? top + safeAreaInsets$1.top : 0;
  951. }
  952. function getWindowOffset() {
  953. const style = document.documentElement.style;
  954. const top = getWindowTop();
  955. const bottom = getWindowOffsetCssVar(style, "--window-bottom");
  956. const left = getWindowOffsetCssVar(style, "--window-left");
  957. const right = getWindowOffsetCssVar(style, "--window-right");
  958. const topWindowHeight = getWindowOffsetCssVar(style, "--top-window-height");
  959. return {
  960. top,
  961. bottom: bottom ? bottom + safeAreaInsets$1.bottom : 0,
  962. left: left ? left + safeAreaInsets$1.left : 0,
  963. right: right ? right + safeAreaInsets$1.right : 0,
  964. topWindowHeight: topWindowHeight || 0
  965. };
  966. }
  967. function updateCssVar(cssVars) {
  968. const style = document.documentElement.style;
  969. Object.keys(cssVars).forEach((name) => {
  970. style.setProperty(name, cssVars[name]);
  971. });
  972. }
  973. function updatePageCssVar(cssVars) {
  974. return updateCssVar(cssVars);
  975. }
  976. const sheetsMap = /* @__PURE__ */ new Map();
  977. function updateStyle(id2, content) {
  978. let style = sheetsMap.get(id2);
  979. if (style && !(style instanceof HTMLStyleElement)) {
  980. removeStyle(id2);
  981. style = void 0;
  982. }
  983. if (!style) {
  984. style = document.createElement("style");
  985. style.setAttribute("type", "text/css");
  986. style.innerHTML = content;
  987. document.head.appendChild(style);
  988. } else {
  989. style.innerHTML = content;
  990. }
  991. sheetsMap.set(id2, style);
  992. }
  993. function removeStyle(id2) {
  994. let style = sheetsMap.get(id2);
  995. if (style) {
  996. if (style instanceof CSSStyleSheet) {
  997. document.adoptedStyleSheets.indexOf(style);
  998. document.adoptedStyleSheets = document.adoptedStyleSheets.filter(
  999. (s) => s !== style
  1000. );
  1001. } else {
  1002. document.head.removeChild(style);
  1003. }
  1004. sheetsMap.delete(id2);
  1005. }
  1006. }
  1007. function PolySymbol(name) {
  1008. return Symbol(process.env.NODE_ENV !== "production" ? "[uni-app]: " + name : name);
  1009. }
  1010. function hasRpx(str) {
  1011. str = str + "";
  1012. return str.indexOf("rpx") !== -1 || str.indexOf("upx") !== -1;
  1013. }
  1014. function rpx2px(str, replace = false) {
  1015. if (replace) {
  1016. return rpx2pxWithReplace(str);
  1017. }
  1018. if (isString(str)) {
  1019. const res = parseInt(str) || 0;
  1020. if (hasRpx(str)) {
  1021. return uni.upx2px(res);
  1022. }
  1023. return res;
  1024. }
  1025. return str;
  1026. }
  1027. function rpx2pxWithReplace(str) {
  1028. if (!hasRpx(str)) {
  1029. return str;
  1030. }
  1031. return str.replace(/(\d+(\.\d+)?)[ru]px/g, (_a, b) => {
  1032. return uni.upx2px(parseFloat(b)) + "px";
  1033. });
  1034. }
  1035. const ICON_PATH_CANCEL = "M20.928 10.176l-4.928 4.928-4.928-4.928-0.896 0.896 4.928 4.928-4.928 4.928 0.896 0.896 4.928-4.928 4.928 4.928 0.896-0.896-4.928-4.928 4.928-4.928-0.896-0.896zM16 2.080q-3.776 0-7.040 1.888-3.136 1.856-4.992 4.992-1.888 3.264-1.888 7.040t1.888 7.040q1.856 3.136 4.992 4.992 3.264 1.888 7.040 1.888t7.040-1.888q3.136-1.856 4.992-4.992 1.888-3.264 1.888-7.040t-1.888-7.040q-1.856-3.136-4.992-4.992-3.264-1.888-7.040-1.888zM16 28.64q-3.424 0-6.4-1.728-2.848-1.664-4.512-4.512-1.728-2.976-1.728-6.4t1.728-6.4q1.664-2.848 4.512-4.512 2.976-1.728 6.4-1.728t6.4 1.728q2.848 1.664 4.512 4.512 1.728 2.976 1.728 6.4t-1.728 6.4q-1.664 2.848-4.512 4.512-2.976 1.728-6.4 1.728z";
  1036. const ICON_PATH_CLEAR = "M16 0q-4.352 0-8.064 2.176-3.616 2.144-5.76 5.76-2.176 3.712-2.176 8.064t2.176 8.064q2.144 3.616 5.76 5.76 3.712 2.176 8.064 2.176t8.064-2.176q3.616-2.144 5.76-5.76 2.176-3.712 2.176-8.064t-2.176-8.064q-2.144-3.616-5.76-5.76-3.712-2.176-8.064-2.176zM22.688 21.408q0.32 0.32 0.304 0.752t-0.336 0.736-0.752 0.304-0.752-0.32l-5.184-5.376-5.376 5.184q-0.32 0.32-0.752 0.304t-0.736-0.336-0.304-0.752 0.32-0.752l5.376-5.184-5.184-5.376q-0.32-0.32-0.304-0.752t0.336-0.752 0.752-0.304 0.752 0.336l5.184 5.376 5.376-5.184q0.32-0.32 0.752-0.304t0.752 0.336 0.304 0.752-0.336 0.752l-5.376 5.184 5.184 5.376z";
  1037. const ICON_PATH_DOWNLOAD = "M15.808 1.696q-3.776 0-7.072 1.984-3.2 1.888-5.088 5.152-1.952 3.392-1.952 7.36 0 3.776 1.952 7.072 1.888 3.2 5.088 5.088 3.296 1.952 7.072 1.952 3.968 0 7.36-1.952 3.264-1.888 5.152-5.088 1.984-3.296 1.984-7.072 0-4-1.984-7.36-1.888-3.264-5.152-5.152-3.36-1.984-7.36-1.984zM20.864 18.592l-3.776 4.928q-0.448 0.576-1.088 0.576t-1.088-0.576l-3.776-4.928q-0.448-0.576-0.24-0.992t0.944-0.416h2.976v-8.928q0-0.256 0.176-0.432t0.4-0.176h1.216q0.224 0 0.4 0.176t0.176 0.432v8.928h2.976q0.736 0 0.944 0.416t-0.24 0.992z";
  1038. const ICON_PATH_INFO = "M15.808 0.128q-4.224 0-7.872 2.176-3.552 2.112-5.632 5.728-2.176 3.776-2.176 8.16 0 4.224 2.176 7.872 2.080 3.552 5.632 5.632 3.648 2.176 7.872 2.176 4.384 0 8.16-2.176 3.616-2.080 5.728-5.632 2.176-3.648 2.176-7.872 0-4.416-2.176-8.16-2.112-3.616-5.728-5.728-3.744-2.176-8.16-2.176zM16.864 23.776q0 0.064-0.064 0.064h-1.568q-0.096 0-0.096-0.064l-0.256-11.328q0-0.064 0.064-0.064h2.112q0.096 0 0.064 0.064l-0.256 11.328zM16 10.88q-0.576 0-0.976-0.4t-0.4-0.96 0.4-0.96 0.976-0.4 0.976 0.4 0.4 0.96-0.4 0.96-0.976 0.4z";
  1039. const ICON_PATH_SEARCH = "M20.928 22.688q-1.696 1.376-3.744 2.112-2.112 0.768-4.384 0.768-3.488 0-6.464-1.728-2.88-1.696-4.576-4.608-1.76-2.976-1.76-6.464t1.76-6.464q1.696-2.88 4.576-4.576 2.976-1.76 6.464-1.76t6.464 1.76q2.912 1.696 4.608 4.576 1.728 2.976 1.728 6.464 0 2.272-0.768 4.384-0.736 2.048-2.112 3.744l9.312 9.28-1.824 1.824-9.28-9.312zM12.8 23.008q2.784 0 5.184-1.376 2.304-1.376 3.68-3.68 1.376-2.4 1.376-5.184t-1.376-5.152q-1.376-2.336-3.68-3.68-2.4-1.408-5.184-1.408t-5.152 1.408q-2.336 1.344-3.68 3.68-1.408 2.368-1.408 5.152t1.408 5.184q1.344 2.304 3.68 3.68 2.368 1.376 5.152 1.376zM12.8 23.008v0z";
  1040. const ICON_PATH_SUCCESS_NO_CIRCLE = "M1.952 18.080q-0.32-0.352-0.416-0.88t0.128-0.976l0.16-0.352q0.224-0.416 0.64-0.528t0.8 0.176l6.496 4.704q0.384 0.288 0.912 0.272t0.88-0.336l17.312-14.272q0.352-0.288 0.848-0.256t0.848 0.352l-0.416-0.416q0.32 0.352 0.32 0.816t-0.32 0.816l-18.656 18.912q-0.32 0.352-0.8 0.352t-0.8-0.32l-7.936-8.064z";
  1041. const ICON_PATH_SUCCESS = "M15.808 0.16q-4.224 0-7.872 2.176-3.552 2.112-5.632 5.728-2.144 3.744-2.144 8.128 0 4.192 2.144 7.872 2.112 3.52 5.632 5.632 3.68 2.144 7.872 2.144 4.384 0 8.128-2.144 3.616-2.080 5.728-5.632 2.176-3.648 2.176-7.872 0-4.384-2.176-8.128-2.112-3.616-5.728-5.728-3.744-2.176-8.128-2.176zM24.832 11.328l-11.264 11.104q-0.032 0.032-0.112 0.032t-0.112-0.032l-5.216-5.376q-0.096-0.128 0-0.288l0.704-0.96q0.032-0.064 0.112-0.064t0.112 0.032l4.256 3.264q0.064 0.032 0.144 0.032t0.112-0.032l10.336-8.608q0.064-0.064 0.144-0.064t0.112 0.064l0.672 0.672q0.128 0.128 0 0.224z";
  1042. const ICON_PATH_WAITING = "M15.84 0.096q-4.224 0-7.872 2.176-3.552 2.112-5.632 5.728-2.144 3.744-2.144 8.128 0 4.192 2.144 7.872 2.112 3.52 5.632 5.632 3.68 2.144 7.872 2.144 4.384 0 8.128-2.144 3.616-2.080 5.728-5.632 2.176-3.648 2.176-7.872 0-4.384-2.176-8.128-2.112-3.616-5.728-5.728-3.744-2.176-8.128-2.176zM23.008 21.92l-0.512 0.896q-0.096 0.128-0.224 0.064l-8-3.808q-0.096-0.064-0.16-0.128-0.128-0.096-0.128-0.288l0.512-12.096q0-0.064 0.048-0.112t0.112-0.048h1.376q0.064 0 0.112 0.048t0.048 0.112l0.448 10.848 6.304 4.256q0.064 0.064 0.080 0.128t-0.016 0.128z";
  1043. const ICON_PATH_WARN = "M15.808 0.16q-4.224 0-7.872 2.176-3.552 2.112-5.632 5.728-2.144 3.744-2.144 8.128 0 4.192 2.144 7.872 2.112 3.52 5.632 5.632 3.68 2.144 7.872 2.144 4.384 0 8.128-2.144 3.616-2.080 5.728-5.632 2.176-3.648 2.176-7.872 0-4.384-2.176-8.128-2.112-3.616-5.728-5.728-3.744-2.176-8.128-2.176zM15.136 8.672h1.728q0.128 0 0.224 0.096t0.096 0.256l-0.384 10.24q0 0.064-0.048 0.112t-0.112 0.048h-1.248q-0.096 0-0.144-0.048t-0.048-0.112l-0.384-10.24q0-0.16 0.096-0.256t0.224-0.096zM16 23.328q-0.48 0-0.832-0.352t-0.352-0.848 0.352-0.848 0.832-0.352 0.832 0.352 0.352 0.848-0.352 0.848-0.832 0.352z";
  1044. const ICON_PATH_BACK = "M21.781 7.844l-9.063 8.594 9.063 8.594q0.25 0.25 0.25 0.609t-0.25 0.578q-0.25 0.25-0.578 0.25t-0.578-0.25l-9.625-9.125q-0.156-0.125-0.203-0.297t-0.047-0.359q0-0.156 0.047-0.328t0.203-0.297l9.625-9.125q0.25-0.25 0.578-0.25t0.578 0.25q0.25 0.219 0.25 0.578t-0.25 0.578z";
  1045. const ICON_PATH_CLOSE = "M17.25 16.156l7.375-7.313q0.281-0.281 0.281-0.641t-0.281-0.641q-0.25-0.25-0.625-0.25t-0.625 0.25l-7.375 7.344-7.313-7.344q-0.25-0.25-0.625-0.25t-0.625 0.25q-0.281 0.25-0.281 0.625t0.281 0.625l7.313 7.344-7.375 7.344q-0.281 0.25-0.281 0.625t0.281 0.625q0.125 0.125 0.281 0.188t0.344 0.063q0.156 0 0.328-0.063t0.297-0.188l7.375-7.344 7.375 7.406q0.125 0.156 0.297 0.219t0.328 0.063q0.188 0 0.344-0.078t0.281-0.203q0.281-0.25 0.281-0.609t-0.281-0.641l-7.375-7.406z";
  1046. const ICON_PATH_CONFIRM = "M31.562 4.9966666659375q0.435 0.399 0.435 0.87 0.036 0.58-0.399 0.98l-18.61 19.917q-0.145 0.145-0.327 0.217-0.073 0.037-0.145 0.11-0.254 0.035-0.472 0.035-0.29 0-0.544-0.036l-0.145-0.072q-0.109-0.073-0.217-0.182l-0.11-0.072L0.363 16.2786666659375q-0.327-0.399-0.363-0.907 0-0.544 0.363-1.016 0.435-0.326 0.961-0.362 0.527-0.036 0.962 0.362l9.722 9.542L29.712 5.0326666659375q0.399-0.363 0.943-0.363 0.544-0.036 0.907 0.327z";
  1047. function createSvgIconVNode(path, color = "#000", size = 27) {
  1048. return createVNode(
  1049. "svg",
  1050. {
  1051. width: size,
  1052. height: size,
  1053. viewBox: "0 0 32 32"
  1054. },
  1055. [
  1056. createVNode(
  1057. "path",
  1058. {
  1059. d: path,
  1060. fill: color
  1061. },
  1062. null,
  1063. 8,
  1064. ["d", "fill"]
  1065. )
  1066. ],
  1067. 8,
  1068. ["width", "height"]
  1069. );
  1070. }
  1071. function useCurrentPageId() {
  1072. {
  1073. const { $pageInstance } = getCurrentInstance();
  1074. return $pageInstance && $pageInstance.proxy.$page.id;
  1075. }
  1076. }
  1077. function getPageIdByVm(instance2) {
  1078. const vm = resolveComponentInstance(instance2);
  1079. if (vm.$page) {
  1080. return vm.$page.id;
  1081. }
  1082. if (!vm.$) {
  1083. return;
  1084. }
  1085. {
  1086. const { $pageInstance } = vm.$;
  1087. return $pageInstance && $pageInstance.proxy.$page.id;
  1088. }
  1089. }
  1090. function getCurrentPage() {
  1091. const pages = getCurrentPages();
  1092. const len = pages.length;
  1093. if (len) {
  1094. return pages[len - 1];
  1095. }
  1096. }
  1097. function getCurrentPageMeta() {
  1098. const page = getCurrentPage();
  1099. if (page) {
  1100. return page.$page.meta;
  1101. }
  1102. }
  1103. function getCurrentPageId() {
  1104. const meta = getCurrentPageMeta();
  1105. if (meta) {
  1106. return meta.id;
  1107. }
  1108. return -1;
  1109. }
  1110. function getCurrentPageVm() {
  1111. const page = getCurrentPage();
  1112. if (page) {
  1113. return page.$vm;
  1114. }
  1115. }
  1116. const PAGE_META_KEYS = ["navigationBar", "pullToRefresh"];
  1117. function initGlobalStyle() {
  1118. return JSON.parse(JSON.stringify(__uniConfig.globalStyle || {}));
  1119. }
  1120. function initRouteMeta(pageMeta, id2) {
  1121. const globalStyle = initGlobalStyle();
  1122. const res = extend({ id: id2 }, globalStyle, pageMeta);
  1123. PAGE_META_KEYS.forEach((name) => {
  1124. res[name] = extend({}, globalStyle[name], pageMeta[name]);
  1125. });
  1126. const { navigationBar } = res;
  1127. navigationBar.titleText && navigationBar.titleImage && (navigationBar.titleText = "");
  1128. return res;
  1129. }
  1130. function normalizePullToRefreshRpx(pullToRefresh) {
  1131. if (pullToRefresh.offset) {
  1132. pullToRefresh.offset = rpx2px(pullToRefresh.offset);
  1133. }
  1134. if (pullToRefresh.height) {
  1135. pullToRefresh.height = rpx2px(pullToRefresh.height);
  1136. }
  1137. if (pullToRefresh.range) {
  1138. pullToRefresh.range = rpx2px(pullToRefresh.range);
  1139. }
  1140. return pullToRefresh;
  1141. }
  1142. function initPageInternalInstance(openType, url, pageQuery, meta, eventChannel, themeMode) {
  1143. const { id: id2, route } = meta;
  1144. const titleColor = normalizeStyles(
  1145. meta.navigationBar,
  1146. __uniConfig.themeConfig,
  1147. themeMode
  1148. ).titleColor;
  1149. return {
  1150. id: id2,
  1151. path: addLeadingSlash(route),
  1152. route,
  1153. fullPath: url,
  1154. options: pageQuery,
  1155. meta,
  1156. openType,
  1157. eventChannel,
  1158. statusBarStyle: titleColor === "#ffffff" ? "light" : "dark"
  1159. };
  1160. }
  1161. function removeHook(vm, name, hook) {
  1162. const hooks = vm.$[name];
  1163. if (!isArray(hooks)) {
  1164. return;
  1165. }
  1166. if (hook.__weh) {
  1167. remove(hooks, hook.__weh);
  1168. }
  1169. }
  1170. function invokeHook(vm, name, args) {
  1171. if (isString(vm)) {
  1172. args = name;
  1173. name = vm;
  1174. vm = getCurrentPageVm();
  1175. } else if (typeof vm === "number") {
  1176. const page = getCurrentPages().find((page2) => page2.$page.id === vm);
  1177. if (page) {
  1178. vm = page.$vm;
  1179. } else {
  1180. vm = getCurrentPageVm();
  1181. }
  1182. }
  1183. if (!vm) {
  1184. return;
  1185. }
  1186. const hooks = vm.$[name];
  1187. return hooks && invokeArrayFns(hooks, args);
  1188. }
  1189. function disableScrollListener(evt) {
  1190. evt.preventDefault();
  1191. }
  1192. let testReachBottomTimer;
  1193. let lastScrollHeight = 0;
  1194. function createScrollListener({
  1195. onPageScroll,
  1196. onReachBottom,
  1197. onReachBottomDistance
  1198. }) {
  1199. let ticking = false;
  1200. let hasReachBottom = false;
  1201. let reachBottomLocking = true;
  1202. const isReachBottom = () => {
  1203. const { scrollHeight } = document.documentElement;
  1204. const windowHeight = window.innerHeight;
  1205. const scrollY = window.scrollY;
  1206. const isBottom = scrollY > 0 && scrollHeight > windowHeight && scrollY + windowHeight + onReachBottomDistance >= scrollHeight;
  1207. const heightChanged = Math.abs(scrollHeight - lastScrollHeight) > onReachBottomDistance;
  1208. if (isBottom && (!hasReachBottom || heightChanged)) {
  1209. lastScrollHeight = scrollHeight;
  1210. hasReachBottom = true;
  1211. return true;
  1212. }
  1213. if (!isBottom && hasReachBottom) {
  1214. hasReachBottom = false;
  1215. }
  1216. return false;
  1217. };
  1218. const trigger = () => {
  1219. onPageScroll && onPageScroll(window.pageYOffset);
  1220. function testReachBottom() {
  1221. if (isReachBottom()) {
  1222. onReachBottom && onReachBottom();
  1223. reachBottomLocking = false;
  1224. setTimeout(function() {
  1225. reachBottomLocking = true;
  1226. }, 350);
  1227. return true;
  1228. }
  1229. }
  1230. if (onReachBottom && reachBottomLocking) {
  1231. if (testReachBottom())
  1232. ;
  1233. else {
  1234. testReachBottomTimer = setTimeout(testReachBottom, 300);
  1235. }
  1236. }
  1237. ticking = false;
  1238. };
  1239. return function onScroll() {
  1240. clearTimeout(testReachBottomTimer);
  1241. if (!ticking) {
  1242. requestAnimationFrame(trigger);
  1243. }
  1244. ticking = true;
  1245. };
  1246. }
  1247. function normalizeRoute(toRoute) {
  1248. if (toRoute.indexOf("/") === 0) {
  1249. return toRoute;
  1250. }
  1251. let fromRoute = "";
  1252. const pages = getCurrentPages();
  1253. if (pages.length) {
  1254. fromRoute = pages[pages.length - 1].$page.route;
  1255. }
  1256. return getRealRoute(fromRoute, toRoute);
  1257. }
  1258. function getRealRoute(fromRoute, toRoute) {
  1259. if (toRoute.indexOf("/") === 0) {
  1260. return toRoute;
  1261. }
  1262. if (toRoute.indexOf("./") === 0) {
  1263. return getRealRoute(fromRoute, toRoute.slice(2));
  1264. }
  1265. const toRouteArray = toRoute.split("/");
  1266. const toRouteLength = toRouteArray.length;
  1267. let i = 0;
  1268. for (; i < toRouteLength && toRouteArray[i] === ".."; i++) {
  1269. }
  1270. toRouteArray.splice(0, i);
  1271. toRoute = toRouteArray.join("/");
  1272. const fromRouteArray = fromRoute.length > 0 ? fromRoute.split("/") : [];
  1273. fromRouteArray.splice(fromRouteArray.length - i - 1, i + 1);
  1274. return addLeadingSlash(fromRouteArray.concat(toRouteArray).join("/"));
  1275. }
  1276. function getRouteOptions(path, alias = false) {
  1277. if (alias) {
  1278. return __uniRoutes.find(
  1279. (route) => route.path === path || route.alias === path
  1280. );
  1281. }
  1282. return __uniRoutes.find((route) => route.path === path);
  1283. }
  1284. function normalizeTabBarRoute(index2, oldPagePath, newPagePath) {
  1285. const oldTabBarRoute = getRouteOptions(addLeadingSlash(oldPagePath));
  1286. if (oldTabBarRoute) {
  1287. const { meta } = oldTabBarRoute;
  1288. delete meta.tabBarIndex;
  1289. meta.isQuit = meta.isTabBar = false;
  1290. }
  1291. const newTabBarRoute = getRouteOptions(addLeadingSlash(newPagePath));
  1292. if (newTabBarRoute) {
  1293. const { meta } = newTabBarRoute;
  1294. meta.tabBarIndex = index2;
  1295. meta.isQuit = meta.isTabBar = true;
  1296. const tabBar2 = __uniConfig.tabBar;
  1297. if (tabBar2 && tabBar2.list && tabBar2.list[index2]) {
  1298. tabBar2.list[index2].pagePath = removeLeadingSlash(newPagePath);
  1299. }
  1300. }
  1301. }
  1302. class ComponentDescriptor {
  1303. constructor(vm) {
  1304. this.$bindClass = false;
  1305. this.$bindStyle = false;
  1306. this.$vm = vm;
  1307. {
  1308. this.$el = resolveOwnerEl(vm.$);
  1309. }
  1310. if (this.$el.getAttribute) {
  1311. this.$bindClass = !!this.$el.getAttribute("class");
  1312. this.$bindStyle = !!this.$el.getAttribute("style");
  1313. }
  1314. }
  1315. selectComponent(selector) {
  1316. if (!this.$el || !selector) {
  1317. return;
  1318. }
  1319. const wxsVm = getWxsVm(this.$el.querySelector(selector));
  1320. if (!wxsVm) {
  1321. return;
  1322. }
  1323. return createComponentDescriptor(wxsVm, false);
  1324. }
  1325. selectAllComponents(selector) {
  1326. if (!this.$el || !selector) {
  1327. return [];
  1328. }
  1329. const descriptors = [];
  1330. const els = this.$el.querySelectorAll(selector);
  1331. for (let i = 0; i < els.length; i++) {
  1332. const wxsVm = getWxsVm(els[i]);
  1333. if (wxsVm) {
  1334. descriptors.push(createComponentDescriptor(wxsVm, false));
  1335. }
  1336. }
  1337. return descriptors;
  1338. }
  1339. forceUpdate(type) {
  1340. if (type === "class") {
  1341. if (this.$bindClass) {
  1342. this.$el.__wxsClassChanged = true;
  1343. this.$vm.$forceUpdate();
  1344. } else {
  1345. this.updateWxsClass();
  1346. }
  1347. } else if (type === "style") {
  1348. if (this.$bindStyle) {
  1349. this.$el.__wxsStyleChanged = true;
  1350. this.$vm.$forceUpdate();
  1351. } else {
  1352. this.updateWxsStyle();
  1353. }
  1354. }
  1355. }
  1356. updateWxsClass() {
  1357. const { __wxsAddClass } = this.$el;
  1358. if (__wxsAddClass.length) {
  1359. this.$el.className = __wxsAddClass.join(" ");
  1360. }
  1361. }
  1362. updateWxsStyle() {
  1363. const { __wxsStyle } = this.$el;
  1364. if (__wxsStyle) {
  1365. this.$el.setAttribute("style", stringifyStyle(__wxsStyle));
  1366. }
  1367. }
  1368. setStyle(style) {
  1369. if (!this.$el || !style) {
  1370. return this;
  1371. }
  1372. if (isString(style)) {
  1373. style = parseStringStyle(style);
  1374. }
  1375. if (isPlainObject(style)) {
  1376. this.$el.__wxsStyle = style;
  1377. this.forceUpdate("style");
  1378. }
  1379. return this;
  1380. }
  1381. addClass(clazz2) {
  1382. if (!this.$el || !clazz2) {
  1383. return this;
  1384. }
  1385. const __wxsAddClass = this.$el.__wxsAddClass || (this.$el.__wxsAddClass = []);
  1386. if (__wxsAddClass.indexOf(clazz2) === -1) {
  1387. __wxsAddClass.push(clazz2);
  1388. this.forceUpdate("class");
  1389. }
  1390. return this;
  1391. }
  1392. removeClass(clazz2) {
  1393. if (!this.$el || !clazz2) {
  1394. return this;
  1395. }
  1396. const { __wxsAddClass } = this.$el;
  1397. if (__wxsAddClass) {
  1398. const index2 = __wxsAddClass.indexOf(clazz2);
  1399. if (index2 > -1) {
  1400. __wxsAddClass.splice(index2, 1);
  1401. }
  1402. }
  1403. const __wxsRemoveClass = this.$el.__wxsRemoveClass || (this.$el.__wxsRemoveClass = []);
  1404. if (__wxsRemoveClass.indexOf(clazz2) === -1) {
  1405. __wxsRemoveClass.push(clazz2);
  1406. this.forceUpdate("class");
  1407. }
  1408. return this;
  1409. }
  1410. hasClass(cls) {
  1411. return this.$el && this.$el.classList.contains(cls);
  1412. }
  1413. getDataset() {
  1414. return this.$el && this.$el.dataset;
  1415. }
  1416. callMethod(funcName, args = {}) {
  1417. const func = this.$vm[funcName];
  1418. if (isFunction(func)) {
  1419. func(JSON.parse(JSON.stringify(args)));
  1420. } else if (this.$vm.ownerId) {
  1421. UniViewJSBridge.publishHandler(ON_WXS_INVOKE_CALL_METHOD, {
  1422. nodeId: this.$el.__id,
  1423. ownerId: this.$vm.ownerId,
  1424. method: funcName,
  1425. args
  1426. });
  1427. }
  1428. }
  1429. requestAnimationFrame(callback) {
  1430. return window.requestAnimationFrame(callback);
  1431. }
  1432. getState() {
  1433. return this.$el && (this.$el.__wxsState || (this.$el.__wxsState = {}));
  1434. }
  1435. triggerEvent(eventName, detail = {}) {
  1436. return this.$vm.$emit(eventName, detail), this;
  1437. }
  1438. getComputedStyle(names) {
  1439. if (this.$el) {
  1440. const styles = window.getComputedStyle(this.$el);
  1441. if (names && names.length) {
  1442. return names.reduce((res, n) => {
  1443. res[n] = styles[n];
  1444. return res;
  1445. }, {});
  1446. }
  1447. return styles;
  1448. }
  1449. return {};
  1450. }
  1451. setTimeout(handler, timeout) {
  1452. return window.setTimeout(handler, timeout);
  1453. }
  1454. clearTimeout(handle) {
  1455. return window.clearTimeout(handle);
  1456. }
  1457. getBoundingClientRect() {
  1458. return this.$el.getBoundingClientRect();
  1459. }
  1460. }
  1461. function createComponentDescriptor(vm, isOwnerInstance = true) {
  1462. {
  1463. if (isOwnerInstance && vm) {
  1464. vm = resolveOwnerVm(vm.$);
  1465. }
  1466. }
  1467. if (vm && vm.$el) {
  1468. if (!vm.$el.__wxsComponentDescriptor) {
  1469. vm.$el.__wxsComponentDescriptor = new ComponentDescriptor(vm);
  1470. }
  1471. return vm.$el.__wxsComponentDescriptor;
  1472. }
  1473. }
  1474. function getComponentDescriptor(instance2, isOwnerInstance) {
  1475. return createComponentDescriptor(instance2, isOwnerInstance);
  1476. }
  1477. function resolveOwnerComponentPublicInstance(eventValue, instance2, checkArgsLength = true) {
  1478. if (!instance2) {
  1479. return false;
  1480. }
  1481. if (checkArgsLength && eventValue.length < 2) {
  1482. return false;
  1483. }
  1484. const ownerVm = resolveOwnerVm(instance2);
  1485. if (!ownerVm) {
  1486. return false;
  1487. }
  1488. const type = ownerVm.$.type;
  1489. if (!type.$wxs && !type.$renderjs) {
  1490. return false;
  1491. }
  1492. return ownerVm;
  1493. }
  1494. function wrapperH5WxsEvent(event, eventValue, instance2, checkArgsLength = true) {
  1495. if (eventValue) {
  1496. if (!event.__instance) {
  1497. event.__instance = true;
  1498. Object.defineProperty(event, "instance", {
  1499. get() {
  1500. return getComponentDescriptor(instance2.proxy, false);
  1501. }
  1502. });
  1503. }
  1504. const ownerVm = resolveOwnerComponentPublicInstance(
  1505. eventValue,
  1506. instance2,
  1507. checkArgsLength
  1508. );
  1509. if (ownerVm) {
  1510. return [event, getComponentDescriptor(ownerVm, false)];
  1511. }
  1512. }
  1513. }
  1514. function getWxsVm(el) {
  1515. if (!el) {
  1516. return;
  1517. }
  1518. {
  1519. return el.__vueParentComponent && el.__vueParentComponent.proxy;
  1520. }
  1521. }
  1522. const isKeyboardEvent = (val) => !val.type.indexOf("key") && val instanceof KeyboardEvent;
  1523. const isClickEvent = (val) => val.type === "click";
  1524. const isMouseEvent = (val) => val.type.indexOf("mouse") === 0 || ["contextmenu"].includes(val.type);
  1525. const isTouchEvent = (val) => typeof TouchEvent !== "undefined" && val instanceof TouchEvent || val.type.indexOf("touch") === 0 || ["longpress"].indexOf(val.type) >= 0;
  1526. function $nne(evt, eventValue, instance2) {
  1527. const { currentTarget } = evt;
  1528. if (!(evt instanceof Event) || !(currentTarget instanceof HTMLElement)) {
  1529. return [evt];
  1530. }
  1531. const isHTMLTarget = currentTarget.tagName.indexOf("UNI-") !== 0;
  1532. {
  1533. if (isHTMLTarget) {
  1534. return wrapperH5WxsEvent(
  1535. evt,
  1536. eventValue,
  1537. instance2,
  1538. false
  1539. // 原生标签事件可能被cache,参数长度不准确,故默认不校验
  1540. ) || [evt];
  1541. }
  1542. }
  1543. const res = createNativeEvent(evt, isHTMLTarget);
  1544. if (isClickEvent(evt)) {
  1545. normalizeClickEvent(res, evt);
  1546. } else if (isMouseEvent(evt)) {
  1547. normalizeMouseEvent(res, evt);
  1548. } else if (isTouchEvent(evt)) {
  1549. const top = getWindowTop();
  1550. res.touches = normalizeTouchEvent(evt.touches, top);
  1551. res.changedTouches = normalizeTouchEvent(evt.changedTouches, top);
  1552. } else if (isKeyboardEvent(evt)) {
  1553. const proxyKeys = ["key", "code"];
  1554. proxyKeys.forEach((key) => {
  1555. Object.defineProperty(res, key, {
  1556. get() {
  1557. return evt[key];
  1558. }
  1559. });
  1560. });
  1561. }
  1562. {
  1563. return wrapperH5WxsEvent(
  1564. res,
  1565. eventValue,
  1566. instance2
  1567. ) || [res];
  1568. }
  1569. }
  1570. function findUniTarget(target) {
  1571. while (target && target.tagName.indexOf("UNI-") !== 0) {
  1572. target = target.parentElement;
  1573. }
  1574. return target;
  1575. }
  1576. function createNativeEvent(evt, htmlElement = false) {
  1577. const { type, timeStamp, target, currentTarget } = evt;
  1578. let realTarget, realCurrentTarget;
  1579. realTarget = htmlElement ? target : findUniTarget(target);
  1580. realCurrentTarget = currentTarget;
  1581. const event = {
  1582. type,
  1583. timeStamp,
  1584. target: realTarget,
  1585. detail: {},
  1586. currentTarget: realCurrentTarget
  1587. };
  1588. if (evt._stopped) {
  1589. event._stopped = true;
  1590. }
  1591. if (evt.type.startsWith("touch")) {
  1592. event.touches = evt.touches;
  1593. event.changedTouches = evt.changedTouches;
  1594. }
  1595. {
  1596. wrapperEvent(event, evt);
  1597. }
  1598. return event;
  1599. }
  1600. function wrapperEvent(event, evt) {
  1601. extend(event, {
  1602. preventDefault() {
  1603. return evt.preventDefault();
  1604. },
  1605. stopPropagation() {
  1606. return evt.stopPropagation();
  1607. }
  1608. });
  1609. }
  1610. function normalizeClickEvent(evt, mouseEvt) {
  1611. const { x, y } = mouseEvt;
  1612. const top = getWindowTop();
  1613. evt.detail = { x, y: y - top };
  1614. evt.x = x;
  1615. evt.y = y - top;
  1616. evt.touches = evt.changedTouches = [createTouchEvent(mouseEvt, top)];
  1617. }
  1618. function normalizeMouseEvent(evt, mouseEvt) {
  1619. const top = getWindowTop();
  1620. evt.pageX = mouseEvt.pageX;
  1621. evt.pageY = mouseEvt.pageY - top;
  1622. evt.clientX = mouseEvt.clientX;
  1623. evt.clientY = mouseEvt.clientY - top;
  1624. evt.touches = evt.changedTouches = [createTouchEvent(mouseEvt, top)];
  1625. }
  1626. function createTouchEvent(evt, top) {
  1627. return {
  1628. force: 1,
  1629. identifier: 0,
  1630. clientX: evt.clientX,
  1631. clientY: evt.clientY - top,
  1632. pageX: evt.pageX,
  1633. pageY: evt.pageY - top
  1634. };
  1635. }
  1636. function normalizeTouchEvent(touches, top) {
  1637. const res = [];
  1638. for (let i = 0; i < touches.length; i++) {
  1639. const {
  1640. identifier,
  1641. pageX,
  1642. pageY,
  1643. clientX,
  1644. clientY,
  1645. force,
  1646. screenX,
  1647. screenY
  1648. } = touches[i];
  1649. res.push({
  1650. identifier,
  1651. pageX,
  1652. pageY: pageY - top,
  1653. clientX,
  1654. clientY: clientY - top,
  1655. screenX,
  1656. screenY,
  1657. force: force || 0
  1658. });
  1659. }
  1660. return res;
  1661. }
  1662. const instance = /* @__PURE__ */ Object.defineProperty({
  1663. __proto__: null,
  1664. $nne,
  1665. createNativeEvent
  1666. }, Symbol.toStringTag, { value: "Module" });
  1667. function initAppConfig$1(appConfig) {
  1668. const globalProperties = appConfig.globalProperties;
  1669. extend(globalProperties, instance);
  1670. if (__UNI_FEATURE_WXS__) {
  1671. globalProperties.$gcd = getComponentDescriptor;
  1672. }
  1673. }
  1674. function initViewPlugin(app) {
  1675. initAppConfig$1(app._context.config);
  1676. }
  1677. const invokeOnCallback = (name, res) => UniServiceJSBridge.emit("api." + name, res);
  1678. let invokeViewMethodId = 1;
  1679. function publishViewMethodName(pageId) {
  1680. return (pageId || getCurrentPageId()) + "." + INVOKE_VIEW_API;
  1681. }
  1682. const invokeViewMethod = (name, args, pageId, callback) => {
  1683. const { subscribe, publishHandler } = UniServiceJSBridge;
  1684. const id2 = callback ? invokeViewMethodId++ : 0;
  1685. callback && subscribe(INVOKE_VIEW_API + "." + id2, callback, true);
  1686. publishHandler(publishViewMethodName(pageId), { id: id2, name, args }, pageId);
  1687. };
  1688. const invokeViewMethodKeepAlive = (name, args, callback, pageId) => {
  1689. const { subscribe, unsubscribe, publishHandler } = UniServiceJSBridge;
  1690. const id2 = invokeViewMethodId++;
  1691. const subscribeName = INVOKE_VIEW_API + "." + id2;
  1692. subscribe(subscribeName, callback);
  1693. publishHandler(publishViewMethodName(pageId), { id: id2, name, args }, pageId);
  1694. return () => {
  1695. unsubscribe(subscribeName);
  1696. };
  1697. };
  1698. const ServiceJSBridge = /* @__PURE__ */ extend(
  1699. /* @__PURE__ */ initBridge(
  1700. "view"
  1701. /* view 指的是 service 层订阅的是 view 层事件 */
  1702. ),
  1703. {
  1704. invokeOnCallback,
  1705. invokeViewMethod,
  1706. invokeViewMethodKeepAlive
  1707. }
  1708. );
  1709. function initOn() {
  1710. const { on: on2 } = UniServiceJSBridge;
  1711. on2(ON_RESIZE, onResize$1);
  1712. on2(ON_APP_ENTER_FOREGROUND, onAppEnterForeground);
  1713. on2(ON_APP_ENTER_BACKGROUND, onAppEnterBackground);
  1714. }
  1715. function onResize$1(res) {
  1716. invokeHook(getCurrentPage(), ON_RESIZE, res);
  1717. UniServiceJSBridge.invokeOnCallback("onWindowResize", res);
  1718. }
  1719. function onAppEnterForeground(enterOptions2) {
  1720. const page = getCurrentPage();
  1721. invokeHook(getApp(), ON_SHOW, enterOptions2);
  1722. invokeHook(page, ON_SHOW);
  1723. }
  1724. function onAppEnterBackground() {
  1725. invokeHook(getApp(), ON_HIDE);
  1726. invokeHook(getCurrentPage(), ON_HIDE);
  1727. }
  1728. const SUBSCRIBE_LIFECYCLE_HOOKS = [ON_PAGE_SCROLL, ON_REACH_BOTTOM];
  1729. function initSubscribe() {
  1730. SUBSCRIBE_LIFECYCLE_HOOKS.forEach(
  1731. (name) => UniServiceJSBridge.subscribe(name, createPageEvent(name))
  1732. );
  1733. }
  1734. function createPageEvent(name) {
  1735. return (args, pageId) => {
  1736. invokeHook(parseInt(pageId), name, args);
  1737. };
  1738. }
  1739. function initService() {
  1740. {
  1741. initOn();
  1742. initSubscribe();
  1743. }
  1744. }
  1745. function initAppVm(appVm2) {
  1746. appVm2.$vm = appVm2;
  1747. appVm2.$mpType = "app";
  1748. const locale = ref(useI18n().getLocale());
  1749. Object.defineProperty(appVm2, "$locale", {
  1750. get() {
  1751. return locale.value;
  1752. },
  1753. set(v2) {
  1754. locale.value = v2;
  1755. }
  1756. });
  1757. }
  1758. function initPageVm(pageVm, page) {
  1759. pageVm.route = page.route;
  1760. pageVm.$vm = pageVm;
  1761. pageVm.$page = page;
  1762. pageVm.$mpType = "page";
  1763. if (page.meta.isTabBar) {
  1764. pageVm.$.__isTabBar = true;
  1765. pageVm.$.__isActive = true;
  1766. }
  1767. }
  1768. function querySelector(vm, selector) {
  1769. const el = vm.$el.querySelector(selector);
  1770. return el && el.__vue__;
  1771. }
  1772. function querySelectorAll(vm, selector) {
  1773. const nodeList = vm.$el.querySelectorAll(selector);
  1774. if (nodeList) {
  1775. return [...nodeList].map((node) => node.__vue__).filter(Boolean);
  1776. }
  1777. return [];
  1778. }
  1779. function createSelectorQuery$1() {
  1780. return uni.createSelectorQuery().in(this);
  1781. }
  1782. function createMediaQueryObserver$1() {
  1783. return uni.createMediaQueryObserver(this);
  1784. }
  1785. function createIntersectionObserver$1(options) {
  1786. return uni.createIntersectionObserver(this, options);
  1787. }
  1788. function selectComponent(selector) {
  1789. return querySelector(this, selector);
  1790. }
  1791. function selectAllComponents(selector) {
  1792. return querySelectorAll(this, selector);
  1793. }
  1794. const wxInstance = /* @__PURE__ */ Object.defineProperty({
  1795. __proto__: null,
  1796. createIntersectionObserver: createIntersectionObserver$1,
  1797. createMediaQueryObserver: createMediaQueryObserver$1,
  1798. createSelectorQuery: createSelectorQuery$1,
  1799. selectAllComponents,
  1800. selectComponent
  1801. }, Symbol.toStringTag, { value: "Module" });
  1802. function getOpenerEventChannel() {
  1803. {
  1804. if (this.$route) {
  1805. const meta = this.$route.meta;
  1806. if (!meta.eventChannel) {
  1807. meta.eventChannel = new EventChannel(this.$page.id);
  1808. }
  1809. return meta.eventChannel;
  1810. }
  1811. }
  1812. }
  1813. function initAppConfig(appConfig) {
  1814. const globalProperties = appConfig.globalProperties;
  1815. globalProperties.getOpenerEventChannel = getOpenerEventChannel;
  1816. if (__UNI_FEATURE_WX__) {
  1817. extend(globalProperties, wxInstance);
  1818. }
  1819. }
  1820. function initServicePlugin(app) {
  1821. initAppConfig(app._context.config);
  1822. }
  1823. function createLaunchOptions() {
  1824. return {
  1825. path: "",
  1826. query: {},
  1827. scene: 1001,
  1828. referrerInfo: {
  1829. appId: "",
  1830. extraData: {}
  1831. }
  1832. };
  1833. }
  1834. function defineGlobalData(app, defaultGlobalData) {
  1835. const options = app.$options || {};
  1836. options.globalData = extend(options.globalData || {}, defaultGlobalData);
  1837. Object.defineProperty(app, "globalData", {
  1838. get() {
  1839. return options.globalData;
  1840. },
  1841. set(newGlobalData) {
  1842. options.globalData = newGlobalData;
  1843. }
  1844. });
  1845. }
  1846. function converPx(value) {
  1847. if (/^-?\d+[ur]px$/i.test(value)) {
  1848. return value.replace(/(^-?\d+)[ur]px$/i, (text2, num) => {
  1849. return `${uni.upx2px(parseFloat(num))}px`;
  1850. });
  1851. } else if (/^-?[\d\.]+$/.test(value)) {
  1852. return `${value}px`;
  1853. }
  1854. return value || "";
  1855. }
  1856. function converType(type) {
  1857. return type.replace(/[A-Z]/g, (text2) => {
  1858. return `-${text2.toLowerCase()}`;
  1859. }).replace("webkit", "-webkit");
  1860. }
  1861. function getStyle(action) {
  1862. const animateTypes1 = [
  1863. "matrix",
  1864. "matrix3d",
  1865. "scale",
  1866. "scale3d",
  1867. "rotate3d",
  1868. "skew",
  1869. "translate",
  1870. "translate3d"
  1871. ];
  1872. const animateTypes2 = [
  1873. "scaleX",
  1874. "scaleY",
  1875. "scaleZ",
  1876. "rotate",
  1877. "rotateX",
  1878. "rotateY",
  1879. "rotateZ",
  1880. "skewX",
  1881. "skewY",
  1882. "translateX",
  1883. "translateY",
  1884. "translateZ"
  1885. ];
  1886. const animateTypes3 = ["opacity", "background-color"];
  1887. const animateTypes4 = ["width", "height", "left", "right", "top", "bottom"];
  1888. const animates = action.animates;
  1889. const option = action.option;
  1890. const transition = option.transition;
  1891. const style = {};
  1892. const transform = [];
  1893. animates.forEach((animate) => {
  1894. let type = animate.type;
  1895. let args = [...animate.args];
  1896. if (animateTypes1.concat(animateTypes2).includes(type)) {
  1897. if (type.startsWith("rotate") || type.startsWith("skew")) {
  1898. args = args.map((value) => parseFloat(value) + "deg");
  1899. } else if (type.startsWith("translate")) {
  1900. args = args.map(converPx);
  1901. }
  1902. if (animateTypes2.indexOf(type) >= 0) {
  1903. args.length = 1;
  1904. }
  1905. transform.push(`${type}(${args.join(",")})`);
  1906. } else if (animateTypes3.concat(animateTypes4).includes(args[0])) {
  1907. type = args[0];
  1908. const value = args[1];
  1909. style[type] = animateTypes4.includes(type) ? converPx(value) : value;
  1910. }
  1911. });
  1912. style.transform = style.webkitTransform = transform.join(" ");
  1913. style.transition = style.webkitTransition = Object.keys(style).map(
  1914. (type) => `${converType(type)} ${transition.duration}ms ${transition.timingFunction} ${transition.delay}ms`
  1915. ).join(",");
  1916. style.transformOrigin = style.webkitTransformOrigin = option.transformOrigin;
  1917. return style;
  1918. }
  1919. function startAnimation(context) {
  1920. const animation2 = context.animation;
  1921. if (!animation2 || !animation2.actions || !animation2.actions.length) {
  1922. return;
  1923. }
  1924. let index2 = 0;
  1925. const actions = animation2.actions;
  1926. const length = animation2.actions.length;
  1927. function animate() {
  1928. const action = actions[index2];
  1929. const transition = action.option.transition;
  1930. const style = getStyle(action);
  1931. Object.keys(style).forEach((key) => {
  1932. context.$el.style[key] = style[key];
  1933. });
  1934. index2 += 1;
  1935. if (index2 < length) {
  1936. setTimeout(animate, transition.duration + transition.delay);
  1937. }
  1938. }
  1939. setTimeout(() => {
  1940. animate();
  1941. }, 0);
  1942. }
  1943. const animation = {
  1944. props: ["animation"],
  1945. watch: {
  1946. animation: {
  1947. deep: true,
  1948. handler() {
  1949. startAnimation(this);
  1950. }
  1951. }
  1952. },
  1953. mounted() {
  1954. startAnimation(this);
  1955. }
  1956. };
  1957. const defineBuiltInComponent = (options) => {
  1958. options.__reserved = true;
  1959. const { props: props2, mixins } = options;
  1960. if (!props2 || !props2.animation) {
  1961. (mixins || (options.mixins = [])).push(animation);
  1962. }
  1963. {
  1964. const rootElement = options.rootElement;
  1965. if (rootElement) {
  1966. customElements.define(
  1967. rootElement.name,
  1968. rootElement.class,
  1969. rootElement.options
  1970. );
  1971. }
  1972. }
  1973. return defineSystemComponent(options);
  1974. };
  1975. const defineSystemComponent = (options) => {
  1976. options.__reserved = true;
  1977. options.compatConfig = {
  1978. MODE: 3
  1979. // 标记为vue3
  1980. };
  1981. return defineComponent(options);
  1982. };
  1983. const defineUnsupportedComponent = (name) => {
  1984. return defineBuiltInComponent({
  1985. name: capitalize(camelize(name)),
  1986. setup() {
  1987. return () => (openBlock(), createElementBlock("uni-" + name, null, name + " is unsupported"));
  1988. }
  1989. });
  1990. };
  1991. function withWebEvent(fn) {
  1992. return fn.__wwe = true, fn;
  1993. }
  1994. function useCustomEvent(ref2, emit2) {
  1995. return (name, evt, detail) => {
  1996. if (ref2.value) {
  1997. emit2(name, normalizeCustomEvent(name, evt, ref2.value, detail || {}));
  1998. }
  1999. };
  2000. }
  2001. function useNativeEvent(emit2) {
  2002. return (name, evt) => {
  2003. emit2(name, createNativeEvent(evt));
  2004. };
  2005. }
  2006. function normalizeCustomEvent(name, domEvt, el, detail) {
  2007. let target;
  2008. target = el;
  2009. return {
  2010. type: detail.type || name,
  2011. timeStamp: domEvt.timeStamp || 0,
  2012. target,
  2013. currentTarget: target,
  2014. detail
  2015. };
  2016. }
  2017. const hoverProps = {
  2018. hoverClass: {
  2019. type: String,
  2020. default: "none"
  2021. },
  2022. hoverStopPropagation: {
  2023. type: Boolean,
  2024. default: false
  2025. },
  2026. hoverStartTime: {
  2027. type: [Number, String],
  2028. default: 50
  2029. },
  2030. hoverStayTime: {
  2031. type: [Number, String],
  2032. default: 400
  2033. }
  2034. };
  2035. function useHover(props2) {
  2036. const hovering = ref(false);
  2037. let hoverTouch = false;
  2038. let hoverStartTimer;
  2039. let hoverStayTimer;
  2040. function hoverReset() {
  2041. requestAnimationFrame(() => {
  2042. clearTimeout(hoverStayTimer);
  2043. hoverStayTimer = setTimeout(() => {
  2044. hovering.value = false;
  2045. }, parseInt(props2.hoverStayTime));
  2046. });
  2047. }
  2048. function onTouchstartPassive(evt) {
  2049. if (evt.touches.length > 1) {
  2050. return;
  2051. }
  2052. handleHoverStart(evt);
  2053. }
  2054. function onMousedown(evt) {
  2055. if (hoverTouch) {
  2056. return;
  2057. }
  2058. handleHoverStart(evt);
  2059. window.addEventListener("mouseup", handlePCHoverEnd);
  2060. }
  2061. function handleHoverStart(evt) {
  2062. if (evt._hoverPropagationStopped) {
  2063. return;
  2064. }
  2065. if (!props2.hoverClass || props2.hoverClass === "none" || props2.disabled) {
  2066. return;
  2067. }
  2068. if (props2.hoverStopPropagation) {
  2069. evt._hoverPropagationStopped = true;
  2070. }
  2071. hoverTouch = true;
  2072. hoverStartTimer = setTimeout(() => {
  2073. hovering.value = true;
  2074. if (!hoverTouch) {
  2075. hoverReset();
  2076. }
  2077. }, parseInt(props2.hoverStartTime));
  2078. }
  2079. function onTouchend() {
  2080. handleHoverEnd();
  2081. }
  2082. function onMouseup() {
  2083. if (!hoverTouch) {
  2084. return;
  2085. }
  2086. handlePCHoverEnd();
  2087. }
  2088. function handleHoverEnd() {
  2089. hoverTouch = false;
  2090. if (hovering.value) {
  2091. hoverReset();
  2092. }
  2093. }
  2094. function handlePCHoverEnd() {
  2095. handleHoverEnd();
  2096. window.removeEventListener("mouseup", handlePCHoverEnd);
  2097. }
  2098. function onTouchcancel() {
  2099. hoverTouch = false;
  2100. hovering.value = false;
  2101. clearTimeout(hoverStartTimer);
  2102. }
  2103. return {
  2104. hovering,
  2105. binding: {
  2106. onTouchstartPassive: withWebEvent(onTouchstartPassive),
  2107. onMousedown: withWebEvent(onMousedown),
  2108. onTouchend: withWebEvent(onTouchend),
  2109. onMouseup: withWebEvent(onMouseup),
  2110. onTouchcancel: withWebEvent(onTouchcancel)
  2111. }
  2112. };
  2113. }
  2114. function useBooleanAttr(props2, keys) {
  2115. if (isString(keys)) {
  2116. keys = [keys];
  2117. }
  2118. return keys.reduce((res, key) => {
  2119. if (props2[key]) {
  2120. res[key] = true;
  2121. }
  2122. return res;
  2123. }, /* @__PURE__ */ Object.create(null));
  2124. }
  2125. function transformRpx(value) {
  2126. if (/(-?(?:\d+\.)?\d+)[ur]px/gi.test(value)) {
  2127. return value.replace(/(-?(?:\d+\.)?\d+)[ur]px/gi, (text2, num) => {
  2128. return `${uni.upx2px(parseFloat(num))}px`;
  2129. });
  2130. }
  2131. return value;
  2132. }
  2133. class UniElement extends HTMLElement {
  2134. constructor() {
  2135. super();
  2136. this._props = {};
  2137. this.__isUniElement = true;
  2138. }
  2139. attachVmProps(props2) {
  2140. this._props = props2;
  2141. }
  2142. getAttribute(qualifiedName) {
  2143. const name = camelize(qualifiedName);
  2144. return name in this._props ? this._props[name] + "" : super.getAttribute(qualifiedName) || null;
  2145. }
  2146. get style() {
  2147. const originalStyle = super.style;
  2148. if (originalStyle.__patchRpx__) {
  2149. return originalStyle;
  2150. }
  2151. originalStyle.__patchRpx__ = true;
  2152. const originalSetProperty = originalStyle.setProperty.bind(originalStyle);
  2153. super.style.setProperty = function(property, value, priority) {
  2154. return originalSetProperty(
  2155. property,
  2156. value ? transformRpx(value + "") : value,
  2157. priority || void 0
  2158. );
  2159. };
  2160. return super.style;
  2161. }
  2162. get tagName() {
  2163. return super.tagName.replace(/^UNI-/, "");
  2164. }
  2165. get nodeName() {
  2166. return super.nodeName.replace(/^UNI-/, "");
  2167. }
  2168. }
  2169. const uniFormKey = PolySymbol(process.env.NODE_ENV !== "production" ? "uniForm" : "uf");
  2170. class UniFormElement extends UniElement {
  2171. }
  2172. const index$A = /* @__PURE__ */ defineBuiltInComponent({
  2173. name: "Form",
  2174. emits: ["submit", "reset"],
  2175. rootElement: {
  2176. name: "uni-form",
  2177. class: UniFormElement
  2178. },
  2179. setup(_props, {
  2180. slots,
  2181. emit: emit2
  2182. }) {
  2183. const rootRef = ref(null);
  2184. provideForm(useCustomEvent(rootRef, emit2));
  2185. onMounted(() => {
  2186. const rootElement = rootRef.value;
  2187. rootElement.attachVmProps(_props);
  2188. });
  2189. return () => createVNode("uni-form", {
  2190. "ref": rootRef
  2191. }, [createVNode("span", null, [slots.default && slots.default()])], 512);
  2192. }
  2193. });
  2194. function provideForm(trigger) {
  2195. const fields2 = [];
  2196. provide(uniFormKey, {
  2197. addField(field) {
  2198. fields2.push(field);
  2199. },
  2200. removeField(field) {
  2201. fields2.splice(fields2.indexOf(field), 1);
  2202. },
  2203. submit(evt) {
  2204. trigger("submit", evt, {
  2205. value: fields2.reduce((res, field) => {
  2206. if (field.submit) {
  2207. const [name, value] = field.submit();
  2208. name && (res[name] = value);
  2209. }
  2210. return res;
  2211. }, /* @__PURE__ */ Object.create(null))
  2212. });
  2213. },
  2214. reset(evt) {
  2215. fields2.forEach((field) => field.reset && field.reset());
  2216. trigger("reset", evt);
  2217. }
  2218. });
  2219. return fields2;
  2220. }
  2221. const labelProps = {
  2222. for: {
  2223. type: String,
  2224. default: ""
  2225. }
  2226. };
  2227. const uniLabelKey = PolySymbol(process.env.NODE_ENV !== "production" ? "uniLabel" : "ul");
  2228. function useProvideLabel() {
  2229. const handlers = [];
  2230. provide(uniLabelKey, {
  2231. addHandler(handler) {
  2232. handlers.push(handler);
  2233. },
  2234. removeHandler(handler) {
  2235. handlers.splice(handlers.indexOf(handler), 1);
  2236. }
  2237. });
  2238. return handlers;
  2239. }
  2240. class UniLabelElement extends UniElement {
  2241. }
  2242. const index$z = /* @__PURE__ */ defineBuiltInComponent({
  2243. name: "Label",
  2244. props: labelProps,
  2245. rootElement: {
  2246. name: "uni-label",
  2247. class: UniLabelElement
  2248. },
  2249. setup(props2, {
  2250. slots
  2251. }) {
  2252. const rootRef = ref(null);
  2253. const pageId = useCurrentPageId();
  2254. const handlers = useProvideLabel();
  2255. const pointer = computed(() => props2.for || slots.default && slots.default.length);
  2256. const _onClick = withWebEvent(($event) => {
  2257. const EventTarget = $event.target;
  2258. let stopPropagation = /^uni-(checkbox|radio|switch)-/.test(EventTarget.className);
  2259. if (!stopPropagation) {
  2260. stopPropagation = /^uni-(checkbox|radio|switch|button)$|^(svg|path)$/i.test(EventTarget.tagName);
  2261. }
  2262. if (stopPropagation) {
  2263. return;
  2264. }
  2265. if (props2.for) {
  2266. UniViewJSBridge.emit("uni-label-click-" + pageId + "-" + props2.for, $event, true);
  2267. } else {
  2268. handlers.length && handlers[0]($event, true);
  2269. }
  2270. });
  2271. onMounted(() => {
  2272. const rootElement = rootRef.value;
  2273. rootElement.attachVmProps(props2);
  2274. });
  2275. return () => createVNode("uni-label", {
  2276. "ref": rootRef,
  2277. "class": {
  2278. "uni-label-pointer": pointer
  2279. },
  2280. "onClick": _onClick
  2281. }, [slots.default && slots.default()], 10, ["onClick"]);
  2282. }
  2283. });
  2284. function useListeners$1(props2, listeners2) {
  2285. _addListeners(props2.id, listeners2);
  2286. watch(
  2287. () => props2.id,
  2288. (newId, oldId) => {
  2289. _removeListeners(oldId, listeners2, true);
  2290. _addListeners(newId, listeners2, true);
  2291. }
  2292. );
  2293. onUnmounted(() => {
  2294. _removeListeners(props2.id, listeners2);
  2295. });
  2296. }
  2297. function _addListeners(id2, listeners2, watch2) {
  2298. const pageId = useCurrentPageId();
  2299. if (watch2 && !id2) {
  2300. return;
  2301. }
  2302. if (!isPlainObject(listeners2)) {
  2303. return;
  2304. }
  2305. Object.keys(listeners2).forEach((name) => {
  2306. if (watch2) {
  2307. if (name.indexOf("@") !== 0 && name.indexOf("uni-") !== 0) {
  2308. UniViewJSBridge.on(`uni-${name}-${pageId}-${id2}`, listeners2[name]);
  2309. }
  2310. } else {
  2311. if (name.indexOf("uni-") === 0) {
  2312. UniViewJSBridge.on(name, listeners2[name]);
  2313. } else if (id2) {
  2314. UniViewJSBridge.on(`uni-${name}-${pageId}-${id2}`, listeners2[name]);
  2315. }
  2316. }
  2317. });
  2318. }
  2319. function _removeListeners(id2, listeners2, watch2) {
  2320. const pageId = useCurrentPageId();
  2321. if (watch2 && !id2) {
  2322. return;
  2323. }
  2324. if (!isPlainObject(listeners2)) {
  2325. return;
  2326. }
  2327. Object.keys(listeners2).forEach((name) => {
  2328. if (watch2) {
  2329. if (name.indexOf("@") !== 0 && name.indexOf("uni-") !== 0) {
  2330. UniViewJSBridge.off(`uni-${name}-${pageId}-${id2}`, listeners2[name]);
  2331. }
  2332. } else {
  2333. if (name.indexOf("uni-") === 0) {
  2334. UniViewJSBridge.off(name, listeners2[name]);
  2335. } else if (id2) {
  2336. UniViewJSBridge.off(`uni-${name}-${pageId}-${id2}`, listeners2[name]);
  2337. }
  2338. }
  2339. });
  2340. }
  2341. const buttonProps = {
  2342. id: {
  2343. type: String,
  2344. default: ""
  2345. },
  2346. hoverClass: {
  2347. type: String,
  2348. default: "button-hover"
  2349. },
  2350. hoverStartTime: {
  2351. type: [Number, String],
  2352. default: 20
  2353. },
  2354. hoverStayTime: {
  2355. type: [Number, String],
  2356. default: 70
  2357. },
  2358. hoverStopPropagation: {
  2359. type: Boolean,
  2360. default: false
  2361. },
  2362. disabled: {
  2363. type: [Boolean, String],
  2364. default: false
  2365. },
  2366. formType: {
  2367. type: String,
  2368. default: ""
  2369. },
  2370. openType: {
  2371. type: String,
  2372. default: ""
  2373. },
  2374. loading: {
  2375. type: [Boolean, String],
  2376. default: false
  2377. },
  2378. plain: {
  2379. type: [Boolean, String],
  2380. default: false
  2381. }
  2382. };
  2383. class UniButtonElement extends UniElement {
  2384. }
  2385. const index$y = /* @__PURE__ */ defineBuiltInComponent({
  2386. name: "Button",
  2387. props: buttonProps,
  2388. rootElement: {
  2389. name: "uni-button",
  2390. class: UniButtonElement
  2391. },
  2392. setup(props2, {
  2393. slots
  2394. }) {
  2395. const rootRef = ref(null);
  2396. const uniForm = inject(uniFormKey, false);
  2397. const {
  2398. hovering,
  2399. binding
  2400. } = useHover(props2);
  2401. useI18n();
  2402. const onClick = withWebEvent((e2, isLabelClick) => {
  2403. if (props2.disabled) {
  2404. return e2.stopImmediatePropagation();
  2405. }
  2406. if (isLabelClick) {
  2407. rootRef.value.click();
  2408. }
  2409. const formType = props2.formType;
  2410. if (formType) {
  2411. if (!uniForm) {
  2412. return;
  2413. }
  2414. if (formType === "submit") {
  2415. uniForm.submit(e2);
  2416. } else if (formType === "reset") {
  2417. uniForm.reset(e2);
  2418. }
  2419. return;
  2420. }
  2421. });
  2422. const uniLabel = inject(uniLabelKey, false);
  2423. if (uniLabel) {
  2424. uniLabel.addHandler(onClick);
  2425. onBeforeUnmount(() => {
  2426. uniLabel.removeHandler(onClick);
  2427. });
  2428. }
  2429. useListeners$1(props2, {
  2430. "label-click": onClick
  2431. });
  2432. onMounted(() => {
  2433. const rootElement = rootRef.value;
  2434. rootElement.attachVmProps(props2);
  2435. });
  2436. return () => {
  2437. const hoverClass = props2.hoverClass;
  2438. const booleanAttrs = useBooleanAttr(props2, "disabled");
  2439. const loadingAttrs = useBooleanAttr(props2, "loading");
  2440. const plainAttrs = useBooleanAttr(props2, "plain");
  2441. const hasHoverClass = hoverClass && hoverClass !== "none";
  2442. return createVNode("uni-button", mergeProps({
  2443. "ref": rootRef,
  2444. "onClick": onClick,
  2445. "id": props2.id,
  2446. "class": hasHoverClass && hovering.value ? hoverClass : ""
  2447. }, hasHoverClass && binding, booleanAttrs, loadingAttrs, plainAttrs), [slots.default && slots.default()], 16, ["onClick", "id"]);
  2448. };
  2449. }
  2450. });
  2451. function findElem(vm) {
  2452. return vm.$el;
  2453. }
  2454. function addBase(filePath) {
  2455. const { base: baseUrl } = __uniConfig.router;
  2456. if (addLeadingSlash(filePath).indexOf(baseUrl) === 0) {
  2457. return addLeadingSlash(filePath);
  2458. }
  2459. return baseUrl + filePath;
  2460. }
  2461. function getRealPath(filePath) {
  2462. const { base, assets } = __uniConfig.router;
  2463. if (base === "./") {
  2464. if (filePath.indexOf("./static/") === 0 || assets && filePath.indexOf("./" + assets + "/") === 0) {
  2465. filePath = filePath.slice(1);
  2466. }
  2467. }
  2468. if (filePath.indexOf("/") === 0) {
  2469. if (filePath.indexOf("//") === 0) {
  2470. filePath = "https:" + filePath;
  2471. } else {
  2472. return addBase(filePath.slice(1));
  2473. }
  2474. }
  2475. if (SCHEME_RE.test(filePath) || DATA_RE.test(filePath) || filePath.indexOf("blob:") === 0) {
  2476. return filePath;
  2477. }
  2478. {
  2479. if (process.env.NODE_ENV !== "production") {
  2480. if (!filePath.includes("/static/")) {
  2481. return filePath;
  2482. }
  2483. }
  2484. }
  2485. const pages = getCurrentPages();
  2486. if (pages.length) {
  2487. return addBase(
  2488. getRealRoute(pages[pages.length - 1].$page.route, filePath).slice(1)
  2489. );
  2490. }
  2491. return filePath;
  2492. }
  2493. const ua = navigator.userAgent;
  2494. const isAndroid = /* @__PURE__ */ /android/i.test(ua);
  2495. const isIOS$1 = /* @__PURE__ */ /iphone|ipad|ipod/i.test(ua);
  2496. const isWindows = /* @__PURE__ */ ua.match(/Windows NT ([\d|\d.\d]*)/i);
  2497. const isMac = /* @__PURE__ */ /Macintosh|Mac/i.test(ua);
  2498. const isLinux = /* @__PURE__ */ /Linux|X11/i.test(ua);
  2499. const isIPadOS = isMac && navigator.maxTouchPoints > 0;
  2500. function getScreenFix() {
  2501. return /^Apple/.test(navigator.vendor) && typeof window.orientation === "number";
  2502. }
  2503. function isLandscape(screenFix) {
  2504. return screenFix && Math.abs(window.orientation) === 90;
  2505. }
  2506. function getScreenWidth(screenFix, landscape) {
  2507. return screenFix ? Math[landscape ? "max" : "min"](screen.width, screen.height) : screen.width;
  2508. }
  2509. function getScreenHeight(screenFix, landscape) {
  2510. return screenFix ? Math[landscape ? "min" : "max"](screen.height, screen.width) : screen.height;
  2511. }
  2512. function getWindowWidth(screenWidth) {
  2513. return Math.min(
  2514. window.innerWidth,
  2515. document.documentElement.clientWidth,
  2516. screenWidth
  2517. ) || screenWidth;
  2518. }
  2519. function getBaseSystemInfo() {
  2520. const screenFix = getScreenFix();
  2521. const windowWidth = getWindowWidth(
  2522. getScreenWidth(screenFix, isLandscape(screenFix))
  2523. );
  2524. return {
  2525. platform: isIOS$1 ? "ios" : "other",
  2526. pixelRatio: window.devicePixelRatio,
  2527. windowWidth
  2528. };
  2529. }
  2530. function operateVideoPlayer(videoId, pageId, type, data) {
  2531. UniServiceJSBridge.invokeViewMethod(
  2532. "video." + videoId,
  2533. {
  2534. videoId,
  2535. type,
  2536. data
  2537. },
  2538. pageId
  2539. );
  2540. }
  2541. function operateMap(id2, pageId, type, data, operateMapCallback2) {
  2542. UniServiceJSBridge.invokeViewMethod(
  2543. "map." + id2,
  2544. {
  2545. type,
  2546. data
  2547. },
  2548. pageId,
  2549. operateMapCallback2
  2550. );
  2551. }
  2552. function getRootInfo(fields2) {
  2553. const info = {};
  2554. if (fields2.id) {
  2555. info.id = "";
  2556. }
  2557. if (fields2.dataset) {
  2558. info.dataset = {};
  2559. }
  2560. if (fields2.rect) {
  2561. info.left = 0;
  2562. info.right = 0;
  2563. info.top = 0;
  2564. info.bottom = 0;
  2565. }
  2566. if (fields2.size) {
  2567. info.width = document.documentElement.clientWidth;
  2568. info.height = document.documentElement.clientHeight;
  2569. }
  2570. if (fields2.scrollOffset) {
  2571. const documentElement2 = document.documentElement;
  2572. const body = document.body;
  2573. info.scrollLeft = documentElement2.scrollLeft || body.scrollLeft || 0;
  2574. info.scrollTop = documentElement2.scrollTop || body.scrollTop || 0;
  2575. info.scrollHeight = documentElement2.scrollHeight || body.scrollHeight || 0;
  2576. info.scrollWidth = documentElement2.scrollWidth || body.scrollWidth || 0;
  2577. }
  2578. return info;
  2579. }
  2580. function getNodeInfo(el, fields2) {
  2581. const info = {};
  2582. const { top, topWindowHeight } = getWindowOffset();
  2583. if (fields2.node) {
  2584. const tagName = el.tagName.split("-")[1];
  2585. if (tagName) {
  2586. info.node = el.querySelector(tagName);
  2587. }
  2588. }
  2589. if (fields2.id) {
  2590. info.id = el.id;
  2591. }
  2592. if (fields2.dataset) {
  2593. info.dataset = getCustomDataset(el);
  2594. }
  2595. if (fields2.rect || fields2.size) {
  2596. const rect = el.getBoundingClientRect();
  2597. if (fields2.rect) {
  2598. info.left = rect.left;
  2599. info.right = rect.right;
  2600. info.top = rect.top - top - topWindowHeight;
  2601. info.bottom = rect.bottom - top - topWindowHeight;
  2602. }
  2603. if (fields2.size) {
  2604. info.width = rect.width;
  2605. info.height = rect.height;
  2606. }
  2607. }
  2608. if (isArray(fields2.properties)) {
  2609. fields2.properties.forEach((prop) => {
  2610. prop = prop.replace(/-([a-z])/g, function(e2, t2) {
  2611. return t2.toUpperCase();
  2612. });
  2613. });
  2614. }
  2615. if (fields2.scrollOffset) {
  2616. if (el.tagName === "UNI-SCROLL-VIEW") {
  2617. const scroll = el.children[0].children[0];
  2618. info.scrollLeft = scroll.scrollLeft;
  2619. info.scrollTop = scroll.scrollTop;
  2620. info.scrollHeight = scroll.scrollHeight;
  2621. info.scrollWidth = scroll.scrollWidth;
  2622. } else {
  2623. info.scrollLeft = 0;
  2624. info.scrollTop = 0;
  2625. info.scrollHeight = 0;
  2626. info.scrollWidth = 0;
  2627. }
  2628. }
  2629. if (isArray(fields2.computedStyle)) {
  2630. const sytle = getComputedStyle(el);
  2631. fields2.computedStyle.forEach((name) => {
  2632. info[name] = sytle[name];
  2633. });
  2634. }
  2635. if (fields2.context) {
  2636. info.contextInfo = getContextInfo(el);
  2637. }
  2638. return info;
  2639. }
  2640. function findElm(component, pageVm) {
  2641. if (!component) {
  2642. return pageVm.$el;
  2643. }
  2644. return component.$el;
  2645. }
  2646. function matches(element, selectors) {
  2647. const matches2 = element.matches || element.matchesSelector || element.mozMatchesSelector || element.msMatchesSelector || element.oMatchesSelector || element.webkitMatchesSelector || function(selectors2) {
  2648. const matches3 = this.parentElement.querySelectorAll(
  2649. selectors2
  2650. );
  2651. let i = matches3.length;
  2652. while (--i >= 0 && matches3.item(i) !== this) {
  2653. }
  2654. return i > -1;
  2655. };
  2656. return matches2.call(element, selectors);
  2657. }
  2658. function getNodesInfo(pageVm, component, selector, single, fields2) {
  2659. const selfElement = findElm(component, pageVm);
  2660. const parentElement = selfElement.parentElement;
  2661. if (!parentElement) {
  2662. return single ? null : [];
  2663. }
  2664. const { nodeType } = selfElement;
  2665. const maybeFragment = nodeType === 3 || nodeType === 8;
  2666. if (single) {
  2667. const node = maybeFragment ? parentElement.querySelector(selector) : matches(selfElement, selector) ? selfElement : selfElement.querySelector(selector);
  2668. if (node) {
  2669. return getNodeInfo(node, fields2);
  2670. }
  2671. return null;
  2672. } else {
  2673. let infos = [];
  2674. const nodeList = (maybeFragment ? parentElement : selfElement).querySelectorAll(selector);
  2675. if (nodeList && nodeList.length) {
  2676. [].forEach.call(nodeList, (node) => {
  2677. infos.push(getNodeInfo(node, fields2));
  2678. });
  2679. }
  2680. if (!maybeFragment && matches(selfElement, selector)) {
  2681. infos.unshift(getNodeInfo(selfElement, fields2));
  2682. }
  2683. return infos;
  2684. }
  2685. }
  2686. function requestComponentInfo(page, reqs, callback) {
  2687. const result = [];
  2688. reqs.forEach(({ component, selector, single, fields: fields2 }) => {
  2689. if (component === null) {
  2690. result.push(getRootInfo(fields2));
  2691. } else {
  2692. result.push(getNodesInfo(page, component, selector, single, fields2));
  2693. }
  2694. });
  2695. callback(result);
  2696. }
  2697. function setCurrentPageMeta(_page, { pageStyle, rootFontSize }) {
  2698. if (pageStyle) {
  2699. const pageElm = document.querySelector("uni-page-body") || document.body;
  2700. pageElm.setAttribute("style", pageStyle);
  2701. }
  2702. if (rootFontSize && document.documentElement.style.fontSize !== rootFontSize) {
  2703. document.documentElement.style.fontSize = rootFontSize;
  2704. }
  2705. }
  2706. var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
  2707. var lookup = /* @__PURE__ */ function() {
  2708. const lookup2 = new Uint8Array(256);
  2709. for (var i = 0; i < chars.length; i++) {
  2710. lookup2[chars.charCodeAt(i)] = i;
  2711. }
  2712. return lookup2;
  2713. }();
  2714. function encode$1(arraybuffer) {
  2715. var bytes = new Uint8Array(arraybuffer), i, len = bytes.length, base64 = "";
  2716. for (i = 0; i < len; i += 3) {
  2717. base64 += chars[bytes[i] >> 2];
  2718. base64 += chars[(bytes[i] & 3) << 4 | bytes[i + 1] >> 4];
  2719. base64 += chars[(bytes[i + 1] & 15) << 2 | bytes[i + 2] >> 6];
  2720. base64 += chars[bytes[i + 2] & 63];
  2721. }
  2722. if (len % 3 === 2) {
  2723. base64 = base64.substring(0, base64.length - 1) + "=";
  2724. } else if (len % 3 === 1) {
  2725. base64 = base64.substring(0, base64.length - 2) + "==";
  2726. }
  2727. return base64;
  2728. }
  2729. function decode(base64) {
  2730. var bufferLength = base64.length * 0.75, len = base64.length, i, p2 = 0, encoded1, encoded2, encoded3, encoded4;
  2731. if (base64[base64.length - 1] === "=") {
  2732. bufferLength--;
  2733. if (base64[base64.length - 2] === "=") {
  2734. bufferLength--;
  2735. }
  2736. }
  2737. var arraybuffer = new ArrayBuffer(bufferLength), bytes = new Uint8Array(arraybuffer);
  2738. for (i = 0; i < len; i += 4) {
  2739. encoded1 = lookup[base64.charCodeAt(i)];
  2740. encoded2 = lookup[base64.charCodeAt(i + 1)];
  2741. encoded3 = lookup[base64.charCodeAt(i + 2)];
  2742. encoded4 = lookup[base64.charCodeAt(i + 3)];
  2743. bytes[p2++] = encoded1 << 2 | encoded2 >> 4;
  2744. bytes[p2++] = (encoded2 & 15) << 4 | encoded3 >> 2;
  2745. bytes[p2++] = (encoded3 & 3) << 6 | encoded4 & 63;
  2746. }
  2747. return arraybuffer;
  2748. }
  2749. const CHOOSE_SIZE_TYPES = ["original", "compressed"];
  2750. const CHOOSE_SOURCE_TYPES = ["album", "camera"];
  2751. const HTTP_METHODS = [
  2752. "GET",
  2753. "OPTIONS",
  2754. "HEAD",
  2755. "POST",
  2756. "PUT",
  2757. "DELETE",
  2758. "TRACE",
  2759. "CONNECT",
  2760. "PATCH"
  2761. ];
  2762. function elemInArray(str, arr) {
  2763. if (!str || arr.indexOf(str) === -1) {
  2764. return arr[0];
  2765. }
  2766. return str;
  2767. }
  2768. function elemsInArray(strArr, optionalVal) {
  2769. if (!isArray(strArr) || strArr.length === 0 || strArr.find((val) => optionalVal.indexOf(val) === -1)) {
  2770. return optionalVal;
  2771. }
  2772. return strArr;
  2773. }
  2774. function validateProtocolFail(name, msg) {
  2775. console.warn(`${name}: ${msg}`);
  2776. }
  2777. function validateProtocol(name, data, protocol, onFail) {
  2778. if (!onFail) {
  2779. onFail = validateProtocolFail;
  2780. }
  2781. for (const key in protocol) {
  2782. const errMsg = validateProp(
  2783. key,
  2784. data[key],
  2785. protocol[key],
  2786. !hasOwn(data, key)
  2787. );
  2788. if (isString(errMsg)) {
  2789. onFail(name, errMsg);
  2790. }
  2791. }
  2792. }
  2793. function validateProtocols(name, args, protocol, onFail) {
  2794. if (!protocol) {
  2795. return;
  2796. }
  2797. if (!isArray(protocol)) {
  2798. return validateProtocol(
  2799. name,
  2800. args[0] || /* @__PURE__ */ Object.create(null),
  2801. protocol,
  2802. onFail
  2803. );
  2804. }
  2805. const len = protocol.length;
  2806. const argsLen = args.length;
  2807. for (let i = 0; i < len; i++) {
  2808. const opts = protocol[i];
  2809. const data = /* @__PURE__ */ Object.create(null);
  2810. if (argsLen > i) {
  2811. data[opts.name] = args[i];
  2812. }
  2813. validateProtocol(name, data, { [opts.name]: opts }, onFail);
  2814. }
  2815. }
  2816. function validateProp(name, value, prop, isAbsent) {
  2817. if (!isPlainObject(prop)) {
  2818. prop = { type: prop };
  2819. }
  2820. const { type, required, validator: validator2 } = prop;
  2821. if (required && isAbsent) {
  2822. return 'Missing required args: "' + name + '"';
  2823. }
  2824. if (value == null && !required) {
  2825. return;
  2826. }
  2827. if (type != null) {
  2828. let isValid = false;
  2829. const types = isArray(type) ? type : [type];
  2830. const expectedTypes = [];
  2831. for (let i = 0; i < types.length && !isValid; i++) {
  2832. const { valid, expectedType } = assertType(value, types[i]);
  2833. expectedTypes.push(expectedType || "");
  2834. isValid = valid;
  2835. }
  2836. if (!isValid) {
  2837. return getInvalidTypeMessage(name, value, expectedTypes);
  2838. }
  2839. }
  2840. if (validator2) {
  2841. return validator2(value);
  2842. }
  2843. }
  2844. const isSimpleType = /* @__PURE__ */ makeMap$1(
  2845. "String,Number,Boolean,Function,Symbol"
  2846. );
  2847. function assertType(value, type) {
  2848. let valid;
  2849. const expectedType = getType(type);
  2850. if (isSimpleType(expectedType)) {
  2851. const t2 = typeof value;
  2852. valid = t2 === expectedType.toLowerCase();
  2853. if (!valid && t2 === "object") {
  2854. valid = value instanceof type;
  2855. }
  2856. } else if (expectedType === "Object") {
  2857. valid = isObject(value);
  2858. } else if (expectedType === "Array") {
  2859. valid = isArray(value);
  2860. } else {
  2861. {
  2862. valid = value instanceof type;
  2863. }
  2864. }
  2865. return {
  2866. valid,
  2867. expectedType
  2868. };
  2869. }
  2870. function getInvalidTypeMessage(name, value, expectedTypes) {
  2871. let message = `Invalid args: type check failed for args "${name}". Expected ${expectedTypes.map(capitalize).join(", ")}`;
  2872. const expectedType = expectedTypes[0];
  2873. const receivedType = toRawType(value);
  2874. const expectedValue = styleValue(value, expectedType);
  2875. const receivedValue = styleValue(value, receivedType);
  2876. if (expectedTypes.length === 1 && isExplicable(expectedType) && !isBoolean(expectedType, receivedType)) {
  2877. message += ` with value ${expectedValue}`;
  2878. }
  2879. message += `, got ${receivedType} `;
  2880. if (isExplicable(receivedType)) {
  2881. message += `with value ${receivedValue}.`;
  2882. }
  2883. return message;
  2884. }
  2885. function getType(ctor) {
  2886. const match = ctor && ctor.toString().match(/^\s*function (\w+)/);
  2887. return match ? match[1] : "";
  2888. }
  2889. function styleValue(value, type) {
  2890. if (type === "String") {
  2891. return `"${value}"`;
  2892. } else if (type === "Number") {
  2893. return `${Number(value)}`;
  2894. } else {
  2895. return `${value}`;
  2896. }
  2897. }
  2898. function isExplicable(type) {
  2899. const explicitTypes = ["string", "number", "boolean"];
  2900. return explicitTypes.some((elem) => type.toLowerCase() === elem);
  2901. }
  2902. function isBoolean(...args) {
  2903. return args.some((elem) => elem.toLowerCase() === "boolean");
  2904. }
  2905. function tryCatch(fn) {
  2906. return function() {
  2907. try {
  2908. return fn.apply(fn, arguments);
  2909. } catch (e2) {
  2910. console.error(e2);
  2911. }
  2912. };
  2913. }
  2914. let invokeCallbackId = 1;
  2915. const invokeCallbacks = {};
  2916. function addInvokeCallback(id2, name, callback, keepAlive = false) {
  2917. invokeCallbacks[id2] = {
  2918. name,
  2919. keepAlive,
  2920. callback
  2921. };
  2922. return id2;
  2923. }
  2924. function invokeCallback(id2, res, extras) {
  2925. if (typeof id2 === "number") {
  2926. const opts = invokeCallbacks[id2];
  2927. if (opts) {
  2928. if (!opts.keepAlive) {
  2929. delete invokeCallbacks[id2];
  2930. }
  2931. return opts.callback(res, extras);
  2932. }
  2933. }
  2934. return res;
  2935. }
  2936. function findInvokeCallbackByName(name) {
  2937. for (const key in invokeCallbacks) {
  2938. if (invokeCallbacks[key].name === name) {
  2939. return true;
  2940. }
  2941. }
  2942. return false;
  2943. }
  2944. function removeKeepAliveApiCallback(name, callback) {
  2945. for (const key in invokeCallbacks) {
  2946. const item = invokeCallbacks[key];
  2947. if (item.callback === callback && item.name === name) {
  2948. delete invokeCallbacks[key];
  2949. }
  2950. }
  2951. }
  2952. function offKeepAliveApiCallback(name) {
  2953. UniServiceJSBridge.off("api." + name);
  2954. }
  2955. function onKeepAliveApiCallback(name) {
  2956. UniServiceJSBridge.on("api." + name, (res) => {
  2957. for (const key in invokeCallbacks) {
  2958. const opts = invokeCallbacks[key];
  2959. if (opts.name === name) {
  2960. opts.callback(res);
  2961. }
  2962. }
  2963. });
  2964. }
  2965. function createKeepAliveApiCallback(name, callback) {
  2966. return addInvokeCallback(invokeCallbackId++, name, callback, true);
  2967. }
  2968. const API_SUCCESS = "success";
  2969. const API_FAIL = "fail";
  2970. const API_COMPLETE = "complete";
  2971. function getApiCallbacks(args) {
  2972. const apiCallbacks = {};
  2973. for (const name in args) {
  2974. const fn = args[name];
  2975. if (isFunction(fn)) {
  2976. apiCallbacks[name] = tryCatch(fn);
  2977. delete args[name];
  2978. }
  2979. }
  2980. return apiCallbacks;
  2981. }
  2982. function normalizeErrMsg$1(errMsg, name) {
  2983. if (!errMsg || errMsg.indexOf(":fail") === -1) {
  2984. return name + ":ok";
  2985. }
  2986. return name + errMsg.substring(errMsg.indexOf(":fail"));
  2987. }
  2988. function createAsyncApiCallback(name, args = {}, { beforeAll, beforeSuccess } = {}) {
  2989. if (!isPlainObject(args)) {
  2990. args = {};
  2991. }
  2992. const { success, fail, complete } = getApiCallbacks(args);
  2993. const hasSuccess = isFunction(success);
  2994. const hasFail = isFunction(fail);
  2995. const hasComplete = isFunction(complete);
  2996. const callbackId = invokeCallbackId++;
  2997. addInvokeCallback(callbackId, name, (res) => {
  2998. res = res || {};
  2999. res.errMsg = normalizeErrMsg$1(res.errMsg, name);
  3000. isFunction(beforeAll) && beforeAll(res);
  3001. if (res.errMsg === name + ":ok") {
  3002. isFunction(beforeSuccess) && beforeSuccess(res, args);
  3003. hasSuccess && success(res);
  3004. } else {
  3005. hasFail && fail(res);
  3006. }
  3007. hasComplete && complete(res);
  3008. });
  3009. return callbackId;
  3010. }
  3011. const HOOK_SUCCESS = "success";
  3012. const HOOK_FAIL = "fail";
  3013. const HOOK_COMPLETE = "complete";
  3014. const globalInterceptors = {};
  3015. const scopedInterceptors = {};
  3016. function wrapperHook(hook, params) {
  3017. return function(data) {
  3018. return hook(data, params) || data;
  3019. };
  3020. }
  3021. function queue(hooks, data, params) {
  3022. let promise = false;
  3023. for (let i = 0; i < hooks.length; i++) {
  3024. const hook = hooks[i];
  3025. if (promise) {
  3026. promise = Promise.resolve(wrapperHook(hook, params));
  3027. } else {
  3028. const res = hook(data, params);
  3029. if (isPromise(res)) {
  3030. promise = Promise.resolve(res);
  3031. }
  3032. if (res === false) {
  3033. return {
  3034. then() {
  3035. },
  3036. catch() {
  3037. }
  3038. };
  3039. }
  3040. }
  3041. }
  3042. return promise || {
  3043. then(callback) {
  3044. return callback(data);
  3045. },
  3046. catch() {
  3047. }
  3048. };
  3049. }
  3050. function wrapperOptions(interceptors2, options = {}) {
  3051. [HOOK_SUCCESS, HOOK_FAIL, HOOK_COMPLETE].forEach((name) => {
  3052. const hooks = interceptors2[name];
  3053. if (!isArray(hooks)) {
  3054. return;
  3055. }
  3056. const oldCallback = options[name];
  3057. options[name] = function callbackInterceptor(res) {
  3058. queue(hooks, res, options).then((res2) => {
  3059. return isFunction(oldCallback) && oldCallback(res2) || res2;
  3060. });
  3061. };
  3062. });
  3063. return options;
  3064. }
  3065. function wrapperReturnValue(method, returnValue) {
  3066. const returnValueHooks = [];
  3067. if (isArray(globalInterceptors.returnValue)) {
  3068. returnValueHooks.push(...globalInterceptors.returnValue);
  3069. }
  3070. const interceptor = scopedInterceptors[method];
  3071. if (interceptor && isArray(interceptor.returnValue)) {
  3072. returnValueHooks.push(...interceptor.returnValue);
  3073. }
  3074. returnValueHooks.forEach((hook) => {
  3075. returnValue = hook(returnValue) || returnValue;
  3076. });
  3077. return returnValue;
  3078. }
  3079. function getApiInterceptorHooks(method) {
  3080. const interceptor = /* @__PURE__ */ Object.create(null);
  3081. Object.keys(globalInterceptors).forEach((hook) => {
  3082. if (hook !== "returnValue") {
  3083. interceptor[hook] = globalInterceptors[hook].slice();
  3084. }
  3085. });
  3086. const scopedInterceptor = scopedInterceptors[method];
  3087. if (scopedInterceptor) {
  3088. Object.keys(scopedInterceptor).forEach((hook) => {
  3089. if (hook !== "returnValue") {
  3090. interceptor[hook] = (interceptor[hook] || []).concat(
  3091. scopedInterceptor[hook]
  3092. );
  3093. }
  3094. });
  3095. }
  3096. return interceptor;
  3097. }
  3098. function invokeApi(method, api2, options, params) {
  3099. const interceptor = getApiInterceptorHooks(method);
  3100. if (interceptor && Object.keys(interceptor).length) {
  3101. if (isArray(interceptor.invoke)) {
  3102. const res = queue(interceptor.invoke, options);
  3103. return res.then((options2) => {
  3104. return api2(
  3105. wrapperOptions(getApiInterceptorHooks(method), options2),
  3106. ...params
  3107. );
  3108. });
  3109. } else {
  3110. return api2(wrapperOptions(interceptor, options), ...params);
  3111. }
  3112. }
  3113. return api2(options, ...params);
  3114. }
  3115. function hasCallback(args) {
  3116. if (isPlainObject(args) && [API_SUCCESS, API_FAIL, API_COMPLETE].find(
  3117. (cb) => isFunction(args[cb])
  3118. )) {
  3119. return true;
  3120. }
  3121. return false;
  3122. }
  3123. function handlePromise(promise) {
  3124. return promise;
  3125. }
  3126. function promisify(name, fn) {
  3127. return (args = {}, ...rest) => {
  3128. if (hasCallback(args)) {
  3129. return wrapperReturnValue(name, invokeApi(name, fn, args, rest));
  3130. }
  3131. return wrapperReturnValue(
  3132. name,
  3133. handlePromise(
  3134. new Promise((resolve, reject) => {
  3135. invokeApi(
  3136. name,
  3137. fn,
  3138. extend(args, { success: resolve, fail: reject }),
  3139. rest
  3140. );
  3141. })
  3142. )
  3143. );
  3144. };
  3145. }
  3146. function formatApiArgs(args, options) {
  3147. const params = args[0];
  3148. if (!options || !isPlainObject(options.formatArgs) && isPlainObject(params)) {
  3149. return;
  3150. }
  3151. const formatArgs = options.formatArgs;
  3152. const keys = Object.keys(formatArgs);
  3153. for (let i = 0; i < keys.length; i++) {
  3154. const name = keys[i];
  3155. const formatterOrDefaultValue = formatArgs[name];
  3156. if (isFunction(formatterOrDefaultValue)) {
  3157. const errMsg = formatterOrDefaultValue(args[0][name], params);
  3158. if (isString(errMsg)) {
  3159. return errMsg;
  3160. }
  3161. } else {
  3162. if (!hasOwn(params, name)) {
  3163. params[name] = formatterOrDefaultValue;
  3164. }
  3165. }
  3166. }
  3167. }
  3168. function invokeSuccess(id2, name, res) {
  3169. const result = {
  3170. errMsg: name + ":ok"
  3171. };
  3172. result.errSubject = name;
  3173. return invokeCallback(id2, extend(res || {}, result));
  3174. }
  3175. function invokeFail(id2, name, errMsg, errRes = {}) {
  3176. const apiErrMsg = name + ":fail" + (errMsg ? " " + errMsg : "");
  3177. return invokeCallback(
  3178. id2,
  3179. typeof UniError !== "undefined" ? typeof errRes.errCode !== "undefined" ? new UniError(name, errRes.errCode, apiErrMsg) : new UniError(apiErrMsg, errRes) : extend({ errMsg: apiErrMsg }, errRes)
  3180. );
  3181. }
  3182. function beforeInvokeApi(name, args, protocol, options) {
  3183. if (process.env.NODE_ENV !== "production") {
  3184. validateProtocols(name, args, protocol);
  3185. }
  3186. if (options && options.beforeInvoke) {
  3187. const errMsg2 = options.beforeInvoke(args);
  3188. if (isString(errMsg2)) {
  3189. return errMsg2;
  3190. }
  3191. }
  3192. const errMsg = formatApiArgs(args, options);
  3193. if (errMsg) {
  3194. return errMsg;
  3195. }
  3196. }
  3197. function checkCallback(callback) {
  3198. if (!isFunction(callback)) {
  3199. throw new Error(
  3200. 'Invalid args: type check failed for args "callback". Expected Function'
  3201. );
  3202. }
  3203. }
  3204. function wrapperOnApi(name, fn, options) {
  3205. return (callback) => {
  3206. checkCallback(callback);
  3207. const errMsg = beforeInvokeApi(name, [callback], void 0, options);
  3208. if (errMsg) {
  3209. throw new Error(errMsg);
  3210. }
  3211. const isFirstInvokeOnApi = !findInvokeCallbackByName(name);
  3212. createKeepAliveApiCallback(name, callback);
  3213. if (isFirstInvokeOnApi) {
  3214. onKeepAliveApiCallback(name);
  3215. fn();
  3216. }
  3217. };
  3218. }
  3219. function wrapperOffApi(name, fn, options) {
  3220. return (callback) => {
  3221. checkCallback(callback);
  3222. const errMsg = beforeInvokeApi(name, [callback], void 0, options);
  3223. if (errMsg) {
  3224. throw new Error(errMsg);
  3225. }
  3226. name = name.replace("off", "on");
  3227. removeKeepAliveApiCallback(name, callback);
  3228. const hasInvokeOnApi = findInvokeCallbackByName(name);
  3229. if (!hasInvokeOnApi) {
  3230. offKeepAliveApiCallback(name);
  3231. fn();
  3232. }
  3233. };
  3234. }
  3235. function normalizeErrMsg(errMsg) {
  3236. if (!errMsg || isString(errMsg)) {
  3237. return errMsg;
  3238. }
  3239. if (errMsg.stack) {
  3240. console.error(errMsg.message + LINEFEED + errMsg.stack);
  3241. return errMsg.message;
  3242. }
  3243. return errMsg;
  3244. }
  3245. function wrapperTaskApi(name, fn, protocol, options) {
  3246. return (args) => {
  3247. const id2 = createAsyncApiCallback(name, args, options);
  3248. const errMsg = beforeInvokeApi(name, [args], protocol, options);
  3249. if (errMsg) {
  3250. return invokeFail(id2, name, errMsg);
  3251. }
  3252. return fn(args, {
  3253. resolve: (res) => invokeSuccess(id2, name, res),
  3254. reject: (errMsg2, errRes) => invokeFail(id2, name, normalizeErrMsg(errMsg2), errRes)
  3255. });
  3256. };
  3257. }
  3258. function wrapperSyncApi(name, fn, protocol, options) {
  3259. return (...args) => {
  3260. const errMsg = beforeInvokeApi(name, args, protocol, options);
  3261. if (errMsg) {
  3262. throw new Error(errMsg);
  3263. }
  3264. return fn.apply(null, args);
  3265. };
  3266. }
  3267. function wrapperAsyncApi(name, fn, protocol, options) {
  3268. return wrapperTaskApi(name, fn, protocol, options);
  3269. }
  3270. function defineOnApi(name, fn, options) {
  3271. return wrapperOnApi(name, fn, options);
  3272. }
  3273. function defineOffApi(name, fn, options) {
  3274. return wrapperOffApi(name, fn, options);
  3275. }
  3276. function defineTaskApi(name, fn, protocol, options) {
  3277. return promisify(
  3278. name,
  3279. wrapperTaskApi(name, fn, process.env.NODE_ENV !== "production" ? protocol : void 0, options)
  3280. );
  3281. }
  3282. function defineSyncApi(name, fn, protocol, options) {
  3283. return wrapperSyncApi(
  3284. name,
  3285. fn,
  3286. process.env.NODE_ENV !== "production" ? protocol : void 0,
  3287. options
  3288. );
  3289. }
  3290. function defineAsyncApi(name, fn, protocol, options) {
  3291. return promisify(
  3292. name,
  3293. wrapperAsyncApi(name, fn, process.env.NODE_ENV !== "production" ? protocol : void 0, options)
  3294. );
  3295. }
  3296. function createUnsupportedMsg(name) {
  3297. return `method 'uni.${name}' not supported`;
  3298. }
  3299. function createUnsupportedSyncApi(name) {
  3300. return () => {
  3301. console.error(createUnsupportedMsg(name));
  3302. };
  3303. }
  3304. const createUnsupportedOnApi = createUnsupportedSyncApi;
  3305. function createUnsupportedAsyncApi(name) {
  3306. return (_args, { reject }) => {
  3307. return reject(createUnsupportedMsg(name));
  3308. };
  3309. }
  3310. const API_BASE64_TO_ARRAY_BUFFER = "base64ToArrayBuffer";
  3311. const Base64ToArrayBufferProtocol = [
  3312. {
  3313. name: "base64",
  3314. type: String,
  3315. required: true
  3316. }
  3317. ];
  3318. const API_ARRAY_BUFFER_TO_BASE64 = "arrayBufferToBase64";
  3319. const ArrayBufferToBase64Protocol = [
  3320. {
  3321. name: "arrayBuffer",
  3322. type: [ArrayBuffer, Uint8Array],
  3323. required: true
  3324. }
  3325. ];
  3326. const base64ToArrayBuffer = /* @__PURE__ */ defineSyncApi(
  3327. API_BASE64_TO_ARRAY_BUFFER,
  3328. (base64) => {
  3329. return decode(base64);
  3330. },
  3331. Base64ToArrayBufferProtocol
  3332. );
  3333. const arrayBufferToBase64 = /* @__PURE__ */ defineSyncApi(
  3334. API_ARRAY_BUFFER_TO_BASE64,
  3335. (arrayBuffer) => {
  3336. return encode$1(arrayBuffer);
  3337. },
  3338. ArrayBufferToBase64Protocol
  3339. );
  3340. const API_UPX2PX = "upx2px";
  3341. const Upx2pxProtocol = [
  3342. {
  3343. name: "upx",
  3344. type: [Number, String],
  3345. required: true
  3346. }
  3347. ];
  3348. const EPS = 1e-4;
  3349. const BASE_DEVICE_WIDTH = 750;
  3350. let isIOS = false;
  3351. let deviceWidth = 0;
  3352. let deviceDPR = 0;
  3353. let maxWidth = 960;
  3354. let baseWidth = 375;
  3355. let includeWidth = 750;
  3356. function checkDeviceWidth() {
  3357. const { platform, pixelRatio: pixelRatio2, windowWidth } = getBaseSystemInfo();
  3358. deviceWidth = windowWidth;
  3359. deviceDPR = pixelRatio2;
  3360. isIOS = platform === "ios";
  3361. }
  3362. function checkValue(value, defaultValue) {
  3363. const newValue = Number(value);
  3364. return isNaN(newValue) ? defaultValue : newValue;
  3365. }
  3366. function checkMaxWidth() {
  3367. const config = __uniConfig.globalStyle || {};
  3368. maxWidth = checkValue(config.rpxCalcMaxDeviceWidth, 960);
  3369. baseWidth = checkValue(config.rpxCalcBaseDeviceWidth, 375);
  3370. includeWidth = checkValue(config.rpxCalcBaseDeviceWidth, 750);
  3371. }
  3372. const upx2px = /* @__PURE__ */ defineSyncApi(
  3373. API_UPX2PX,
  3374. (number, newDeviceWidth) => {
  3375. if (deviceWidth === 0) {
  3376. checkDeviceWidth();
  3377. {
  3378. checkMaxWidth();
  3379. }
  3380. }
  3381. number = Number(number);
  3382. if (number === 0) {
  3383. return 0;
  3384. }
  3385. let width = newDeviceWidth || deviceWidth;
  3386. {
  3387. width = number === includeWidth || width <= maxWidth ? width : baseWidth;
  3388. }
  3389. let result = number / BASE_DEVICE_WIDTH * width;
  3390. if (result < 0) {
  3391. result = -result;
  3392. }
  3393. result = Math.floor(result + EPS);
  3394. if (result === 0) {
  3395. if (deviceDPR === 1 || !isIOS) {
  3396. result = 1;
  3397. } else {
  3398. result = 0.5;
  3399. }
  3400. }
  3401. return number < 0 ? -result : result;
  3402. },
  3403. Upx2pxProtocol
  3404. );
  3405. const API_ADD_INTERCEPTOR = "addInterceptor";
  3406. const API_REMOVE_INTERCEPTOR = "removeInterceptor";
  3407. const AddInterceptorProtocol = [
  3408. {
  3409. name: "method",
  3410. type: [String, Object],
  3411. required: true
  3412. }
  3413. ];
  3414. const RemoveInterceptorProtocol = AddInterceptorProtocol;
  3415. function mergeInterceptorHook(interceptors2, interceptor) {
  3416. Object.keys(interceptor).forEach((hook) => {
  3417. if (isFunction(interceptor[hook])) {
  3418. interceptors2[hook] = mergeHook(
  3419. interceptors2[hook],
  3420. interceptor[hook]
  3421. );
  3422. }
  3423. });
  3424. }
  3425. function removeInterceptorHook(interceptors2, interceptor) {
  3426. if (!interceptors2 || !interceptor) {
  3427. return;
  3428. }
  3429. Object.keys(interceptor).forEach((name) => {
  3430. const hooks = interceptors2[name];
  3431. const hook = interceptor[name];
  3432. if (isArray(hooks) && isFunction(hook)) {
  3433. remove(hooks, hook);
  3434. }
  3435. });
  3436. }
  3437. function mergeHook(parentVal, childVal) {
  3438. const res = childVal ? parentVal ? parentVal.concat(childVal) : isArray(childVal) ? childVal : [childVal] : parentVal;
  3439. return res ? dedupeHooks(res) : res;
  3440. }
  3441. function dedupeHooks(hooks) {
  3442. const res = [];
  3443. for (let i = 0; i < hooks.length; i++) {
  3444. if (res.indexOf(hooks[i]) === -1) {
  3445. res.push(hooks[i]);
  3446. }
  3447. }
  3448. return res;
  3449. }
  3450. const addInterceptor = /* @__PURE__ */ defineSyncApi(
  3451. API_ADD_INTERCEPTOR,
  3452. (method, interceptor) => {
  3453. if (isString(method) && isPlainObject(interceptor)) {
  3454. mergeInterceptorHook(
  3455. scopedInterceptors[method] || (scopedInterceptors[method] = {}),
  3456. interceptor
  3457. );
  3458. } else if (isPlainObject(method)) {
  3459. mergeInterceptorHook(globalInterceptors, method);
  3460. }
  3461. },
  3462. AddInterceptorProtocol
  3463. );
  3464. const removeInterceptor = /* @__PURE__ */ defineSyncApi(
  3465. API_REMOVE_INTERCEPTOR,
  3466. (method, interceptor) => {
  3467. if (isString(method)) {
  3468. if (isPlainObject(interceptor)) {
  3469. removeInterceptorHook(scopedInterceptors[method], interceptor);
  3470. } else {
  3471. delete scopedInterceptors[method];
  3472. }
  3473. } else if (isPlainObject(method)) {
  3474. removeInterceptorHook(globalInterceptors, method);
  3475. }
  3476. },
  3477. RemoveInterceptorProtocol
  3478. );
  3479. const interceptors = {};
  3480. const API_ON = "$on";
  3481. const OnProtocol = [
  3482. {
  3483. name: "event",
  3484. type: String,
  3485. required: true
  3486. },
  3487. {
  3488. name: "callback",
  3489. type: Function,
  3490. required: true
  3491. }
  3492. ];
  3493. const API_ONCE = "$once";
  3494. const OnceProtocol = OnProtocol;
  3495. const API_OFF = "$off";
  3496. const OffProtocol = [
  3497. {
  3498. name: "event",
  3499. type: [String, Array]
  3500. },
  3501. {
  3502. name: "callback",
  3503. type: Function
  3504. }
  3505. ];
  3506. const API_EMIT = "$emit";
  3507. const EmitProtocol = [
  3508. {
  3509. name: "event",
  3510. type: String,
  3511. required: true
  3512. }
  3513. ];
  3514. const emitter = new Emitter();
  3515. const $on = /* @__PURE__ */ defineSyncApi(
  3516. API_ON,
  3517. (name, callback) => {
  3518. emitter.on(name, callback);
  3519. return () => emitter.off(name, callback);
  3520. },
  3521. OnProtocol
  3522. );
  3523. const $once = /* @__PURE__ */ defineSyncApi(
  3524. API_ONCE,
  3525. (name, callback) => {
  3526. emitter.once(name, callback);
  3527. return () => emitter.off(name, callback);
  3528. },
  3529. OnceProtocol
  3530. );
  3531. const $off = /* @__PURE__ */ defineSyncApi(
  3532. API_OFF,
  3533. (name, callback) => {
  3534. if (!name) {
  3535. emitter.e = {};
  3536. return;
  3537. }
  3538. if (!isArray(name))
  3539. name = [name];
  3540. name.forEach((n) => emitter.off(n, callback));
  3541. },
  3542. OffProtocol
  3543. );
  3544. const $emit = /* @__PURE__ */ defineSyncApi(
  3545. API_EMIT,
  3546. (name, ...args) => {
  3547. emitter.emit(name, ...args);
  3548. },
  3549. EmitProtocol
  3550. );
  3551. const validator = [
  3552. {
  3553. name: "id",
  3554. type: String,
  3555. required: true
  3556. }
  3557. ];
  3558. const API_CREATE_VIDEO_CONTEXT = "createVideoContext";
  3559. const API_CREATE_MAP_CONTEXT = "createMapContext";
  3560. const CreateMapContextProtocol = validator;
  3561. const API_CREATE_CANVAS_CONTEXT = "createCanvasContext";
  3562. const CreateCanvasContextProtocol = [
  3563. {
  3564. name: "canvasId",
  3565. type: String,
  3566. required: true
  3567. },
  3568. {
  3569. name: "componentInstance",
  3570. type: Object
  3571. }
  3572. ];
  3573. const API_CREATE_INNER_AUDIO_CONTEXT = "createInnerAudioContext";
  3574. validator.concat({
  3575. name: "componentInstance",
  3576. type: Object
  3577. });
  3578. const RATES = [0.5, 0.8, 1, 1.25, 1.5, 2];
  3579. class VideoContext {
  3580. constructor(id2, pageId) {
  3581. this.id = id2;
  3582. this.pageId = pageId;
  3583. }
  3584. play() {
  3585. operateVideoPlayer(this.id, this.pageId, "play");
  3586. }
  3587. pause() {
  3588. operateVideoPlayer(this.id, this.pageId, "pause");
  3589. }
  3590. stop() {
  3591. operateVideoPlayer(this.id, this.pageId, "stop");
  3592. }
  3593. seek(position) {
  3594. operateVideoPlayer(this.id, this.pageId, "seek", {
  3595. position
  3596. });
  3597. }
  3598. sendDanmu(args) {
  3599. operateVideoPlayer(this.id, this.pageId, "sendDanmu", args);
  3600. }
  3601. playbackRate(rate) {
  3602. if (!~RATES.indexOf(rate)) {
  3603. rate = 1;
  3604. }
  3605. operateVideoPlayer(this.id, this.pageId, "playbackRate", {
  3606. rate
  3607. });
  3608. }
  3609. requestFullScreen(args = {}) {
  3610. operateVideoPlayer(this.id, this.pageId, "requestFullScreen", args);
  3611. }
  3612. exitFullScreen() {
  3613. operateVideoPlayer(this.id, this.pageId, "exitFullScreen");
  3614. }
  3615. showStatusBar() {
  3616. operateVideoPlayer(this.id, this.pageId, "showStatusBar");
  3617. }
  3618. hideStatusBar() {
  3619. operateVideoPlayer(this.id, this.pageId, "hideStatusBar");
  3620. }
  3621. }
  3622. const createVideoContext = /* @__PURE__ */ defineSyncApi(
  3623. API_CREATE_VIDEO_CONTEXT,
  3624. (id2, context) => {
  3625. if (context) {
  3626. return new VideoContext(id2, getPageIdByVm(context));
  3627. }
  3628. return new VideoContext(id2, getPageIdByVm(getCurrentPageVm()));
  3629. }
  3630. );
  3631. const operateMapCallback = (options, res) => {
  3632. const errMsg = res.errMsg || "";
  3633. if (new RegExp("\\:\\s*fail").test(errMsg)) {
  3634. options.fail && options.fail(res);
  3635. } else {
  3636. options.success && options.success(res);
  3637. }
  3638. options.complete && options.complete(res);
  3639. };
  3640. const operateMapWrap = (id2, pageId, type, options) => {
  3641. operateMap(id2, pageId, type, options, (res) => {
  3642. options && operateMapCallback(options, res);
  3643. });
  3644. };
  3645. class MapContext {
  3646. constructor(id2, pageId) {
  3647. this.id = id2;
  3648. this.pageId = pageId;
  3649. }
  3650. getCenterLocation(options) {
  3651. operateMapWrap(this.id, this.pageId, "getCenterLocation", options);
  3652. }
  3653. moveToLocation(options) {
  3654. operateMapWrap(this.id, this.pageId, "moveToLocation", options);
  3655. }
  3656. getScale(options) {
  3657. operateMapWrap(this.id, this.pageId, "getScale", options);
  3658. }
  3659. getRegion(options) {
  3660. operateMapWrap(this.id, this.pageId, "getRegion", options);
  3661. }
  3662. includePoints(options) {
  3663. operateMapWrap(this.id, this.pageId, "includePoints", options);
  3664. }
  3665. translateMarker(options) {
  3666. operateMapWrap(this.id, this.pageId, "translateMarker", options);
  3667. }
  3668. $getAppMap() {
  3669. }
  3670. addCustomLayer(options) {
  3671. operateMapWrap(this.id, this.pageId, "addCustomLayer", options);
  3672. }
  3673. removeCustomLayer(options) {
  3674. operateMapWrap(this.id, this.pageId, "removeCustomLayer", options);
  3675. }
  3676. addGroundOverlay(options) {
  3677. operateMapWrap(this.id, this.pageId, "addGroundOverlay", options);
  3678. }
  3679. removeGroundOverlay(options) {
  3680. operateMapWrap(this.id, this.pageId, "removeGroundOverlay", options);
  3681. }
  3682. updateGroundOverlay(options) {
  3683. operateMapWrap(this.id, this.pageId, "updateGroundOverlay", options);
  3684. }
  3685. initMarkerCluster(options) {
  3686. operateMapWrap(this.id, this.pageId, "initMarkerCluster", options);
  3687. }
  3688. addMarkers(options) {
  3689. operateMapWrap(this.id, this.pageId, "addMarkers", options);
  3690. }
  3691. removeMarkers(options) {
  3692. operateMapWrap(this.id, this.pageId, "removeMarkers", options);
  3693. }
  3694. moveAlong(options) {
  3695. operateMapWrap(this.id, this.pageId, "moveAlong", options);
  3696. }
  3697. setLocMarkerIcon(options) {
  3698. operateMapWrap(this.id, this.pageId, "setLocMarkerIcon", options);
  3699. }
  3700. openMapApp(options) {
  3701. operateMapWrap(this.id, this.pageId, "openMapApp", options);
  3702. }
  3703. on(name, callback) {
  3704. operateMapWrap(this.id, this.pageId, "on", { name, callback });
  3705. }
  3706. }
  3707. const createMapContext = /* @__PURE__ */ defineSyncApi(
  3708. API_CREATE_MAP_CONTEXT,
  3709. (id2, context) => {
  3710. if (context) {
  3711. return new MapContext(id2, getPageIdByVm(context));
  3712. }
  3713. return new MapContext(id2, getPageIdByVm(getCurrentPageVm()));
  3714. },
  3715. CreateMapContextProtocol
  3716. );
  3717. function getInt(name, defaultValue) {
  3718. return function(value, params) {
  3719. if (value) {
  3720. params[name] = Math.round(value);
  3721. } else if (typeof defaultValue !== "undefined") {
  3722. params[name] = defaultValue;
  3723. }
  3724. };
  3725. }
  3726. const formatWidth = getInt("width");
  3727. const formatHeight = getInt("height");
  3728. const API_CANVAS_GET_IMAGE_DATA = "canvasGetImageData";
  3729. const CanvasGetImageDataOptions = {
  3730. formatArgs: {
  3731. x: getInt("x"),
  3732. y: getInt("y"),
  3733. width: formatWidth,
  3734. height: formatHeight
  3735. }
  3736. };
  3737. const CanvasGetImageDataProtocol = {
  3738. canvasId: {
  3739. type: String,
  3740. required: true
  3741. },
  3742. x: {
  3743. type: Number,
  3744. required: true
  3745. },
  3746. y: {
  3747. type: Number,
  3748. required: true
  3749. },
  3750. width: {
  3751. type: Number,
  3752. required: true
  3753. },
  3754. height: {
  3755. type: Number,
  3756. required: true
  3757. }
  3758. };
  3759. const API_CANVAS_PUT_IMAGE_DATA = "canvasPutImageData";
  3760. const CanvasPutImageDataOptions = CanvasGetImageDataOptions;
  3761. const CanvasPutImageDataProtocol = /* @__PURE__ */ extend(
  3762. {
  3763. data: {
  3764. type: Uint8ClampedArray,
  3765. required: true
  3766. }
  3767. },
  3768. CanvasGetImageDataProtocol,
  3769. {
  3770. height: {
  3771. type: Number
  3772. }
  3773. }
  3774. );
  3775. const fileTypes = {
  3776. PNG: "png",
  3777. JPG: "jpg",
  3778. JPEG: "jpg"
  3779. };
  3780. const API_CANVAS_TO_TEMP_FILE_PATH = "canvasToTempFilePath";
  3781. const CanvasToTempFilePathOptions = {
  3782. formatArgs: {
  3783. x: getInt("x", 0),
  3784. y: getInt("y", 0),
  3785. width: formatWidth,
  3786. height: formatHeight,
  3787. destWidth: getInt("destWidth"),
  3788. destHeight: getInt("destHeight"),
  3789. fileType(value, params) {
  3790. value = (value || "").toUpperCase();
  3791. let type = fileTypes[value];
  3792. if (!type) {
  3793. type = fileTypes.PNG;
  3794. }
  3795. params.fileType = type;
  3796. },
  3797. quality(value, params) {
  3798. params.quality = value && value > 0 && value < 1 ? value : 1;
  3799. }
  3800. }
  3801. };
  3802. const CanvasToTempFilePathProtocol = {
  3803. x: Number,
  3804. y: Number,
  3805. width: Number,
  3806. height: Number,
  3807. destWidth: Number,
  3808. destHeight: Number,
  3809. canvasId: {
  3810. type: String,
  3811. required: true
  3812. },
  3813. fileType: String,
  3814. quality: Number
  3815. };
  3816. function operateCanvas(canvasId, pageId, type, data, callback) {
  3817. UniServiceJSBridge.invokeViewMethod(
  3818. `canvas.${canvasId}`,
  3819. {
  3820. type,
  3821. data
  3822. },
  3823. pageId,
  3824. (data2) => {
  3825. if (callback)
  3826. callback(data2);
  3827. }
  3828. );
  3829. }
  3830. var methods1 = ["scale", "rotate", "translate", "setTransform", "transform"];
  3831. var methods2 = [
  3832. "drawImage",
  3833. "fillText",
  3834. "fill",
  3835. "stroke",
  3836. "fillRect",
  3837. "strokeRect",
  3838. "clearRect",
  3839. "strokeText"
  3840. ];
  3841. var methods3 = [
  3842. "setFillStyle",
  3843. "setTextAlign",
  3844. "setStrokeStyle",
  3845. "setGlobalAlpha",
  3846. "setShadow",
  3847. "setFontSize",
  3848. "setLineCap",
  3849. "setLineJoin",
  3850. "setLineWidth",
  3851. "setMiterLimit",
  3852. "setTextBaseline",
  3853. "setLineDash"
  3854. ];
  3855. function measureText(text2, font2) {
  3856. const canvas = document.createElement("canvas");
  3857. const c2d = canvas.getContext("2d");
  3858. c2d.font = font2;
  3859. return c2d.measureText(text2).width || 0;
  3860. }
  3861. const predefinedColor = {
  3862. aliceblue: "#f0f8ff",
  3863. antiquewhite: "#faebd7",
  3864. aqua: "#00ffff",
  3865. aquamarine: "#7fffd4",
  3866. azure: "#f0ffff",
  3867. beige: "#f5f5dc",
  3868. bisque: "#ffe4c4",
  3869. black: "#000000",
  3870. blanchedalmond: "#ffebcd",
  3871. blue: "#0000ff",
  3872. blueviolet: "#8a2be2",
  3873. brown: "#a52a2a",
  3874. burlywood: "#deb887",
  3875. cadetblue: "#5f9ea0",
  3876. chartreuse: "#7fff00",
  3877. chocolate: "#d2691e",
  3878. coral: "#ff7f50",
  3879. cornflowerblue: "#6495ed",
  3880. cornsilk: "#fff8dc",
  3881. crimson: "#dc143c",
  3882. cyan: "#00ffff",
  3883. darkblue: "#00008b",
  3884. darkcyan: "#008b8b",
  3885. darkgoldenrod: "#b8860b",
  3886. darkgray: "#a9a9a9",
  3887. darkgrey: "#a9a9a9",
  3888. darkgreen: "#006400",
  3889. darkkhaki: "#bdb76b",
  3890. darkmagenta: "#8b008b",
  3891. darkolivegreen: "#556b2f",
  3892. darkorange: "#ff8c00",
  3893. darkorchid: "#9932cc",
  3894. darkred: "#8b0000",
  3895. darksalmon: "#e9967a",
  3896. darkseagreen: "#8fbc8f",
  3897. darkslateblue: "#483d8b",
  3898. darkslategray: "#2f4f4f",
  3899. darkslategrey: "#2f4f4f",
  3900. darkturquoise: "#00ced1",
  3901. darkviolet: "#9400d3",
  3902. deeppink: "#ff1493",
  3903. deepskyblue: "#00bfff",
  3904. dimgray: "#696969",
  3905. dimgrey: "#696969",
  3906. dodgerblue: "#1e90ff",
  3907. firebrick: "#b22222",
  3908. floralwhite: "#fffaf0",
  3909. forestgreen: "#228b22",
  3910. fuchsia: "#ff00ff",
  3911. gainsboro: "#dcdcdc",
  3912. ghostwhite: "#f8f8ff",
  3913. gold: "#ffd700",
  3914. goldenrod: "#daa520",
  3915. gray: "#808080",
  3916. grey: "#808080",
  3917. green: "#008000",
  3918. greenyellow: "#adff2f",
  3919. honeydew: "#f0fff0",
  3920. hotpink: "#ff69b4",
  3921. indianred: "#cd5c5c",
  3922. indigo: "#4b0082",
  3923. ivory: "#fffff0",
  3924. khaki: "#f0e68c",
  3925. lavender: "#e6e6fa",
  3926. lavenderblush: "#fff0f5",
  3927. lawngreen: "#7cfc00",
  3928. lemonchiffon: "#fffacd",
  3929. lightblue: "#add8e6",
  3930. lightcoral: "#f08080",
  3931. lightcyan: "#e0ffff",
  3932. lightgoldenrodyellow: "#fafad2",
  3933. lightgray: "#d3d3d3",
  3934. lightgrey: "#d3d3d3",
  3935. lightgreen: "#90ee90",
  3936. lightpink: "#ffb6c1",
  3937. lightsalmon: "#ffa07a",
  3938. lightseagreen: "#20b2aa",
  3939. lightskyblue: "#87cefa",
  3940. lightslategray: "#778899",
  3941. lightslategrey: "#778899",
  3942. lightsteelblue: "#b0c4de",
  3943. lightyellow: "#ffffe0",
  3944. lime: "#00ff00",
  3945. limegreen: "#32cd32",
  3946. linen: "#faf0e6",
  3947. magenta: "#ff00ff",
  3948. maroon: "#800000",
  3949. mediumaquamarine: "#66cdaa",
  3950. mediumblue: "#0000cd",
  3951. mediumorchid: "#ba55d3",
  3952. mediumpurple: "#9370db",
  3953. mediumseagreen: "#3cb371",
  3954. mediumslateblue: "#7b68ee",
  3955. mediumspringgreen: "#00fa9a",
  3956. mediumturquoise: "#48d1cc",
  3957. mediumvioletred: "#c71585",
  3958. midnightblue: "#191970",
  3959. mintcream: "#f5fffa",
  3960. mistyrose: "#ffe4e1",
  3961. moccasin: "#ffe4b5",
  3962. navajowhite: "#ffdead",
  3963. navy: "#000080",
  3964. oldlace: "#fdf5e6",
  3965. olive: "#808000",
  3966. olivedrab: "#6b8e23",
  3967. orange: "#ffa500",
  3968. orangered: "#ff4500",
  3969. orchid: "#da70d6",
  3970. palegoldenrod: "#eee8aa",
  3971. palegreen: "#98fb98",
  3972. paleturquoise: "#afeeee",
  3973. palevioletred: "#db7093",
  3974. papayawhip: "#ffefd5",
  3975. peachpuff: "#ffdab9",
  3976. peru: "#cd853f",
  3977. pink: "#ffc0cb",
  3978. plum: "#dda0dd",
  3979. powderblue: "#b0e0e6",
  3980. purple: "#800080",
  3981. rebeccapurple: "#663399",
  3982. red: "#ff0000",
  3983. rosybrown: "#bc8f8f",
  3984. royalblue: "#4169e1",
  3985. saddlebrown: "#8b4513",
  3986. salmon: "#fa8072",
  3987. sandybrown: "#f4a460",
  3988. seagreen: "#2e8b57",
  3989. seashell: "#fff5ee",
  3990. sienna: "#a0522d",
  3991. silver: "#c0c0c0",
  3992. skyblue: "#87ceeb",
  3993. slateblue: "#6a5acd",
  3994. slategray: "#708090",
  3995. slategrey: "#708090",
  3996. snow: "#fffafa",
  3997. springgreen: "#00ff7f",
  3998. steelblue: "#4682b4",
  3999. tan: "#d2b48c",
  4000. teal: "#008080",
  4001. thistle: "#d8bfd8",
  4002. tomato: "#ff6347",
  4003. turquoise: "#40e0d0",
  4004. violet: "#ee82ee",
  4005. wheat: "#f5deb3",
  4006. white: "#ffffff",
  4007. whitesmoke: "#f5f5f5",
  4008. yellow: "#ffff00",
  4009. yellowgreen: "#9acd32",
  4010. transparent: "#00000000"
  4011. };
  4012. function checkColor(e2) {
  4013. e2 = e2 || "#000000";
  4014. var t2 = null;
  4015. if ((t2 = /^#([0-9|A-F|a-f]{6})$/.exec(e2)) != null) {
  4016. const n = parseInt(t2[1].slice(0, 2), 16);
  4017. const o2 = parseInt(t2[1].slice(2, 4), 16);
  4018. const r = parseInt(t2[1].slice(4), 16);
  4019. return [n, o2, r, 255];
  4020. }
  4021. if ((t2 = /^#([0-9|A-F|a-f]{3})$/.exec(e2)) != null) {
  4022. let n = t2[1].slice(0, 1);
  4023. let o2 = t2[1].slice(1, 2);
  4024. let r = t2[1].slice(2, 3);
  4025. n = parseInt(n + n, 16);
  4026. o2 = parseInt(o2 + o2, 16);
  4027. r = parseInt(r + r, 16);
  4028. return [n, o2, r, 255];
  4029. }
  4030. if ((t2 = /^rgb\((.+)\)$/.exec(e2)) != null) {
  4031. return t2[1].split(",").map(function(e22) {
  4032. return Math.min(255, parseInt(e22.trim()));
  4033. }).concat(255);
  4034. }
  4035. if ((t2 = /^rgba\((.+)\)$/.exec(e2)) != null) {
  4036. return t2[1].split(",").map(function(e22, t22) {
  4037. return t22 === 3 ? Math.floor(255 * parseFloat(e22.trim())) : Math.min(255, parseInt(e22.trim()));
  4038. });
  4039. }
  4040. var i = e2.toLowerCase();
  4041. if (hasOwn(predefinedColor, i)) {
  4042. t2 = /^#([0-9|A-F|a-f]{6,8})$/.exec(predefinedColor[i]);
  4043. const n = parseInt(t2[1].slice(0, 2), 16);
  4044. const o2 = parseInt(t2[1].slice(2, 4), 16);
  4045. const r = parseInt(t2[1].slice(4, 6), 16);
  4046. let a2 = parseInt(t2[1].slice(6, 8), 16);
  4047. a2 = a2 >= 0 ? a2 : 255;
  4048. return [n, o2, r, a2];
  4049. }
  4050. console.error("unsupported color:" + e2);
  4051. return [0, 0, 0, 255];
  4052. }
  4053. class CanvasGradient {
  4054. constructor(type, data) {
  4055. this.type = type;
  4056. this.data = data;
  4057. this.colorStop = [];
  4058. }
  4059. addColorStop(position, color) {
  4060. this.colorStop.push([position, checkColor(color)]);
  4061. }
  4062. }
  4063. class Pattern {
  4064. constructor(image2, repetition) {
  4065. this.type = "pattern";
  4066. this.data = image2;
  4067. this.colorStop = repetition;
  4068. }
  4069. }
  4070. class TextMetrics {
  4071. constructor(width) {
  4072. this.width = width;
  4073. }
  4074. }
  4075. class CanvasContext {
  4076. constructor(id2, pageId) {
  4077. this.id = id2;
  4078. this.pageId = pageId;
  4079. this.actions = [];
  4080. this.path = [];
  4081. this.subpath = [];
  4082. this.drawingState = [];
  4083. this.state = {
  4084. lineDash: [0, 0],
  4085. shadowOffsetX: 0,
  4086. shadowOffsetY: 0,
  4087. shadowBlur: 0,
  4088. shadowColor: [0, 0, 0, 0],
  4089. font: "10px sans-serif",
  4090. fontSize: 10,
  4091. fontWeight: "normal",
  4092. fontStyle: "normal",
  4093. fontFamily: "sans-serif"
  4094. };
  4095. }
  4096. draw(reserve = false, callback) {
  4097. var actions = [...this.actions];
  4098. this.actions = [];
  4099. this.path = [];
  4100. operateCanvas(
  4101. this.id,
  4102. this.pageId,
  4103. "actionsChanged",
  4104. {
  4105. actions,
  4106. reserve
  4107. },
  4108. callback
  4109. );
  4110. }
  4111. createLinearGradient(x0, y0, x1, y1) {
  4112. return new CanvasGradient("linear", [x0, y0, x1, y1]);
  4113. }
  4114. createCircularGradient(x, y, r) {
  4115. return new CanvasGradient("radial", [x, y, r]);
  4116. }
  4117. createPattern(image2, repetition) {
  4118. if (void 0 === repetition) {
  4119. console.error(
  4120. "Failed to execute 'createPattern' on 'CanvasContext': 2 arguments required, but only 1 present."
  4121. );
  4122. } else if (["repeat", "repeat-x", "repeat-y", "no-repeat"].indexOf(repetition) < 0) {
  4123. console.error(
  4124. "Failed to execute 'createPattern' on 'CanvasContext': The provided type ('" + repetition + "') is not one of 'repeat', 'no-repeat', 'repeat-x', or 'repeat-y'."
  4125. );
  4126. } else {
  4127. return new Pattern(image2, repetition);
  4128. }
  4129. }
  4130. measureText(text2) {
  4131. const font2 = this.state.font;
  4132. let width = 0;
  4133. {
  4134. width = measureText(text2, font2);
  4135. }
  4136. return new TextMetrics(width);
  4137. }
  4138. save() {
  4139. this.actions.push({
  4140. method: "save",
  4141. data: []
  4142. });
  4143. this.drawingState.push(this.state);
  4144. }
  4145. restore() {
  4146. this.actions.push({
  4147. method: "restore",
  4148. data: []
  4149. });
  4150. this.state = this.drawingState.pop() || {
  4151. lineDash: [0, 0],
  4152. shadowOffsetX: 0,
  4153. shadowOffsetY: 0,
  4154. shadowBlur: 0,
  4155. shadowColor: [0, 0, 0, 0],
  4156. font: "10px sans-serif",
  4157. fontSize: 10,
  4158. fontWeight: "normal",
  4159. fontStyle: "normal",
  4160. fontFamily: "sans-serif"
  4161. };
  4162. }
  4163. beginPath() {
  4164. this.path = [];
  4165. this.subpath = [];
  4166. this.path.push({
  4167. method: "beginPath",
  4168. data: []
  4169. });
  4170. }
  4171. moveTo(x, y) {
  4172. this.path.push({
  4173. method: "moveTo",
  4174. data: [x, y]
  4175. });
  4176. this.subpath = [[x, y]];
  4177. }
  4178. lineTo(x, y) {
  4179. if (this.path.length === 0 && this.subpath.length === 0) {
  4180. this.path.push({
  4181. method: "moveTo",
  4182. data: [x, y]
  4183. });
  4184. } else {
  4185. this.path.push({
  4186. method: "lineTo",
  4187. data: [x, y]
  4188. });
  4189. }
  4190. this.subpath.push([x, y]);
  4191. }
  4192. quadraticCurveTo(cpx, cpy, x, y) {
  4193. this.path.push({
  4194. method: "quadraticCurveTo",
  4195. data: [cpx, cpy, x, y]
  4196. });
  4197. this.subpath.push([x, y]);
  4198. }
  4199. bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y) {
  4200. this.path.push({
  4201. method: "bezierCurveTo",
  4202. data: [cp1x, cp1y, cp2x, cp2y, x, y]
  4203. });
  4204. this.subpath.push([x, y]);
  4205. }
  4206. arc(x, y, r, sAngle, eAngle, counterclockwise = false) {
  4207. this.path.push({
  4208. method: "arc",
  4209. data: [x, y, r, sAngle, eAngle, counterclockwise]
  4210. });
  4211. this.subpath.push([x, y]);
  4212. }
  4213. rect(x, y, width, height) {
  4214. this.path.push({
  4215. method: "rect",
  4216. data: [x, y, width, height]
  4217. });
  4218. this.subpath = [[x, y]];
  4219. }
  4220. arcTo(x1, y1, x2, y2, radius) {
  4221. this.path.push({
  4222. method: "arcTo",
  4223. data: [x1, y1, x2, y2, radius]
  4224. });
  4225. this.subpath.push([x2, y2]);
  4226. }
  4227. clip() {
  4228. this.actions.push({
  4229. method: "clip",
  4230. data: [...this.path]
  4231. });
  4232. }
  4233. closePath() {
  4234. this.path.push({
  4235. method: "closePath",
  4236. data: []
  4237. });
  4238. if (this.subpath.length) {
  4239. this.subpath = [this.subpath.shift()];
  4240. }
  4241. }
  4242. clearActions() {
  4243. this.actions = [];
  4244. this.path = [];
  4245. this.subpath = [];
  4246. }
  4247. getActions() {
  4248. var actions = [...this.actions];
  4249. this.clearActions();
  4250. return actions;
  4251. }
  4252. set lineDashOffset(value) {
  4253. this.actions.push({
  4254. method: "setLineDashOffset",
  4255. data: [value]
  4256. });
  4257. }
  4258. set globalCompositeOperation(type) {
  4259. this.actions.push({
  4260. method: "setGlobalCompositeOperation",
  4261. data: [type]
  4262. });
  4263. }
  4264. set shadowBlur(level) {
  4265. this.actions.push({
  4266. method: "setShadowBlur",
  4267. data: [level]
  4268. });
  4269. }
  4270. set shadowColor(color) {
  4271. this.actions.push({
  4272. method: "setShadowColor",
  4273. data: [color]
  4274. });
  4275. }
  4276. set shadowOffsetX(x) {
  4277. this.actions.push({
  4278. method: "setShadowOffsetX",
  4279. data: [x]
  4280. });
  4281. }
  4282. set shadowOffsetY(y) {
  4283. this.actions.push({
  4284. method: "setShadowOffsetY",
  4285. data: [y]
  4286. });
  4287. }
  4288. set font(value) {
  4289. var self = this;
  4290. this.state.font = value;
  4291. var fontFormat = value.match(
  4292. /^(([\w\-]+\s)*)(\d+r?px)(\/(\d+\.?\d*(r?px)?))?\s+(.*)/
  4293. );
  4294. if (fontFormat) {
  4295. var style = fontFormat[1].trim().split(/\s/);
  4296. var fontSize = parseFloat(fontFormat[3]);
  4297. var fontFamily = fontFormat[7];
  4298. var actions = [];
  4299. style.forEach(function(value2, index2) {
  4300. if (["italic", "oblique", "normal"].indexOf(value2) > -1) {
  4301. actions.push({
  4302. method: "setFontStyle",
  4303. data: [value2]
  4304. });
  4305. self.state.fontStyle = value2;
  4306. } else if (["bold", "normal"].indexOf(value2) > -1) {
  4307. actions.push({
  4308. method: "setFontWeight",
  4309. data: [value2]
  4310. });
  4311. self.state.fontWeight = value2;
  4312. } else if (index2 === 0) {
  4313. actions.push({
  4314. method: "setFontStyle",
  4315. data: ["normal"]
  4316. });
  4317. self.state.fontStyle = "normal";
  4318. } else if (index2 === 1) {
  4319. pushAction();
  4320. }
  4321. });
  4322. if (style.length === 1) {
  4323. pushAction();
  4324. }
  4325. style = actions.map(function(action) {
  4326. return action.data[0];
  4327. }).join(" ");
  4328. this.state.fontSize = fontSize;
  4329. this.state.fontFamily = fontFamily;
  4330. this.actions.push({
  4331. method: "setFont",
  4332. data: [`${style} ${fontSize}px ${fontFamily}`]
  4333. });
  4334. } else {
  4335. console.warn("Failed to set 'font' on 'CanvasContext': invalid format.");
  4336. }
  4337. function pushAction() {
  4338. actions.push({
  4339. method: "setFontWeight",
  4340. data: ["normal"]
  4341. });
  4342. self.state.fontWeight = "normal";
  4343. }
  4344. }
  4345. get font() {
  4346. return this.state.font;
  4347. }
  4348. set fillStyle(color) {
  4349. this.setFillStyle(color);
  4350. }
  4351. set strokeStyle(color) {
  4352. this.setStrokeStyle(color);
  4353. }
  4354. set globalAlpha(value) {
  4355. value = Math.floor(255 * parseFloat(value));
  4356. this.actions.push({
  4357. method: "setGlobalAlpha",
  4358. data: [value]
  4359. });
  4360. }
  4361. set textAlign(align2) {
  4362. this.actions.push({
  4363. method: "setTextAlign",
  4364. data: [align2]
  4365. });
  4366. }
  4367. set lineCap(type) {
  4368. this.actions.push({
  4369. method: "setLineCap",
  4370. data: [type]
  4371. });
  4372. }
  4373. set lineJoin(type) {
  4374. this.actions.push({
  4375. method: "setLineJoin",
  4376. data: [type]
  4377. });
  4378. }
  4379. set lineWidth(value) {
  4380. this.actions.push({
  4381. method: "setLineWidth",
  4382. data: [value]
  4383. });
  4384. }
  4385. set miterLimit(value) {
  4386. this.actions.push({
  4387. method: "setMiterLimit",
  4388. data: [value]
  4389. });
  4390. }
  4391. set textBaseline(type) {
  4392. this.actions.push({
  4393. method: "setTextBaseline",
  4394. data: [type]
  4395. });
  4396. }
  4397. }
  4398. const initCanvasContextProperty = /* @__PURE__ */ once(() => {
  4399. [...methods1, ...methods2].forEach(function(method) {
  4400. function get(method2) {
  4401. switch (method2) {
  4402. case "fill":
  4403. case "stroke":
  4404. return function() {
  4405. this.actions.push({
  4406. method: method2 + "Path",
  4407. // @ts-ignore
  4408. data: [...this.path]
  4409. });
  4410. };
  4411. case "fillRect":
  4412. return function(x, y, width, height) {
  4413. this.actions.push({
  4414. method: "fillPath",
  4415. data: [
  4416. {
  4417. method: "rect",
  4418. data: [x, y, width, height]
  4419. }
  4420. ]
  4421. });
  4422. };
  4423. case "strokeRect":
  4424. return function(x, y, width, height) {
  4425. this.actions.push({
  4426. method: "strokePath",
  4427. data: [
  4428. {
  4429. method: "rect",
  4430. data: [x, y, width, height]
  4431. }
  4432. ]
  4433. });
  4434. };
  4435. case "fillText":
  4436. case "strokeText":
  4437. return function(text2, x, y, maxWidth2) {
  4438. var data = [text2.toString(), x, y];
  4439. if (typeof maxWidth2 === "number") {
  4440. data.push(maxWidth2);
  4441. }
  4442. this.actions.push({
  4443. method: method2,
  4444. data
  4445. });
  4446. };
  4447. case "drawImage":
  4448. return function(imageResource, dx, dy, dWidth, dHeight, sx, sy, sWidth, sHeight) {
  4449. if (sHeight === void 0) {
  4450. sx = dx;
  4451. sy = dy;
  4452. sWidth = dWidth;
  4453. sHeight = dHeight;
  4454. dx = void 0;
  4455. dy = void 0;
  4456. dWidth = void 0;
  4457. dHeight = void 0;
  4458. }
  4459. var data;
  4460. function isNumber(e2) {
  4461. return typeof e2 === "number";
  4462. }
  4463. data = isNumber(dx) && isNumber(dy) && isNumber(dWidth) && isNumber(dHeight) ? [
  4464. imageResource,
  4465. sx,
  4466. sy,
  4467. sWidth,
  4468. sHeight,
  4469. dx,
  4470. dy,
  4471. dWidth,
  4472. dHeight
  4473. ] : isNumber(sWidth) && isNumber(sHeight) ? [imageResource, sx, sy, sWidth, sHeight] : [imageResource, sx, sy];
  4474. this.actions.push({
  4475. method: method2,
  4476. data
  4477. });
  4478. };
  4479. default:
  4480. return function(...data) {
  4481. this.actions.push({
  4482. method: method2,
  4483. data
  4484. });
  4485. };
  4486. }
  4487. }
  4488. CanvasContext.prototype[method] = get(method);
  4489. });
  4490. methods3.forEach(function(method) {
  4491. function get(method2) {
  4492. switch (method2) {
  4493. case "setFillStyle":
  4494. case "setStrokeStyle":
  4495. return function(color) {
  4496. if (typeof color !== "object") {
  4497. this.actions.push({
  4498. method: method2,
  4499. data: ["normal", checkColor(color)]
  4500. });
  4501. } else {
  4502. this.actions.push({
  4503. method: method2,
  4504. data: [color.type, color.data, color.colorStop]
  4505. });
  4506. }
  4507. };
  4508. case "setGlobalAlpha":
  4509. return function(alpha) {
  4510. alpha = Math.floor(255 * parseFloat(alpha));
  4511. this.actions.push({
  4512. method: method2,
  4513. data: [alpha]
  4514. });
  4515. };
  4516. case "setShadow":
  4517. return function(offsetX, offsetY, blur, color) {
  4518. color = checkColor(color);
  4519. this.actions.push({
  4520. method: method2,
  4521. data: [offsetX, offsetY, blur, color]
  4522. });
  4523. this.state.shadowBlur = blur;
  4524. this.state.shadowColor = color;
  4525. this.state.shadowOffsetX = offsetX;
  4526. this.state.shadowOffsetY = offsetY;
  4527. };
  4528. case "setLineDash":
  4529. return function(pattern, offset) {
  4530. pattern = pattern || [0, 0];
  4531. offset = offset || 0;
  4532. this.actions.push({
  4533. method: method2,
  4534. data: [pattern, offset]
  4535. });
  4536. this.state.lineDash = pattern;
  4537. };
  4538. case "setFontSize":
  4539. return function(fontSize) {
  4540. this.state.font = this.state.font.replace(
  4541. /\d+\.?\d*px/,
  4542. fontSize + "px"
  4543. );
  4544. this.state.fontSize = fontSize;
  4545. this.actions.push({
  4546. method: method2,
  4547. data: [fontSize]
  4548. });
  4549. };
  4550. default:
  4551. return function(...data) {
  4552. this.actions.push({
  4553. method: method2,
  4554. data
  4555. });
  4556. };
  4557. }
  4558. }
  4559. CanvasContext.prototype[method] = get(method);
  4560. });
  4561. });
  4562. const createCanvasContext = /* @__PURE__ */ defineSyncApi(
  4563. API_CREATE_CANVAS_CONTEXT,
  4564. (canvasId, componentInstance) => {
  4565. initCanvasContextProperty();
  4566. if (componentInstance) {
  4567. return new CanvasContext(canvasId, getPageIdByVm(componentInstance));
  4568. }
  4569. const pageId = getPageIdByVm(getCurrentPageVm());
  4570. if (pageId) {
  4571. return new CanvasContext(canvasId, pageId);
  4572. } else {
  4573. UniServiceJSBridge.emit(ON_ERROR, "createCanvasContext:fail");
  4574. }
  4575. },
  4576. CreateCanvasContextProtocol
  4577. );
  4578. const canvasGetImageData = /* @__PURE__ */ defineAsyncApi(
  4579. API_CANVAS_GET_IMAGE_DATA,
  4580. ({ canvasId, x, y, width, height }, { resolve, reject }) => {
  4581. const pageId = getPageIdByVm(getCurrentPageVm());
  4582. if (!pageId) {
  4583. reject();
  4584. return;
  4585. }
  4586. function callback(data) {
  4587. if (data.errMsg && data.errMsg.indexOf("fail") !== -1) {
  4588. reject("", data);
  4589. return;
  4590. }
  4591. let imgData = data.data;
  4592. if (imgData && imgData.length) {
  4593. data.data = new Uint8ClampedArray(imgData);
  4594. }
  4595. delete data.compressed;
  4596. resolve(data);
  4597. }
  4598. operateCanvas(
  4599. canvasId,
  4600. pageId,
  4601. "getImageData",
  4602. {
  4603. x,
  4604. y,
  4605. width,
  4606. height
  4607. },
  4608. callback
  4609. );
  4610. },
  4611. CanvasGetImageDataProtocol,
  4612. CanvasGetImageDataOptions
  4613. );
  4614. const canvasPutImageData = /* @__PURE__ */ defineAsyncApi(
  4615. API_CANVAS_PUT_IMAGE_DATA,
  4616. ({ canvasId, data, x, y, width, height }, { resolve, reject }) => {
  4617. var pageId = getPageIdByVm(getCurrentPageVm());
  4618. if (!pageId) {
  4619. reject();
  4620. return;
  4621. }
  4622. let compressed;
  4623. const operate = () => {
  4624. operateCanvas(
  4625. canvasId,
  4626. pageId,
  4627. "putImageData",
  4628. {
  4629. data,
  4630. x,
  4631. y,
  4632. width,
  4633. height,
  4634. compressed
  4635. },
  4636. (data2) => {
  4637. if (data2.errMsg && data2.errMsg.indexOf("fail") !== -1) {
  4638. reject();
  4639. return;
  4640. }
  4641. resolve(data2);
  4642. }
  4643. );
  4644. };
  4645. {
  4646. data = Array.prototype.slice.call(data);
  4647. }
  4648. operate();
  4649. },
  4650. CanvasPutImageDataProtocol,
  4651. CanvasPutImageDataOptions
  4652. );
  4653. const canvasToTempFilePath = /* @__PURE__ */ defineAsyncApi(
  4654. API_CANVAS_TO_TEMP_FILE_PATH,
  4655. ({
  4656. x = 0,
  4657. y = 0,
  4658. width,
  4659. height,
  4660. destWidth,
  4661. destHeight,
  4662. canvasId,
  4663. fileType,
  4664. quality
  4665. }, { resolve, reject }) => {
  4666. var pageId = getPageIdByVm(getCurrentPageVm());
  4667. if (!pageId) {
  4668. reject();
  4669. return;
  4670. }
  4671. const dirname = `${TEMP_PATH}/canvas`;
  4672. operateCanvas(
  4673. canvasId,
  4674. pageId,
  4675. "toTempFilePath",
  4676. {
  4677. x,
  4678. y,
  4679. width,
  4680. height,
  4681. destWidth,
  4682. destHeight,
  4683. fileType,
  4684. quality,
  4685. dirname
  4686. },
  4687. (res) => {
  4688. if (res.errMsg && res.errMsg.indexOf("fail") !== -1) {
  4689. reject("", res);
  4690. return;
  4691. }
  4692. resolve(res);
  4693. }
  4694. );
  4695. },
  4696. CanvasToTempFilePathProtocol,
  4697. CanvasToTempFilePathOptions
  4698. );
  4699. const innerAudioContextEventNames = [
  4700. "onCanplay",
  4701. "onPlay",
  4702. "onPause",
  4703. "onStop",
  4704. "onEnded",
  4705. "onTimeUpdate",
  4706. "onError",
  4707. "onWaiting",
  4708. "onSeeking",
  4709. "onSeeked"
  4710. ];
  4711. const innerAudioContextOffEventNames = [
  4712. "offCanplay",
  4713. "offPlay",
  4714. "offPause",
  4715. "offStop",
  4716. "offEnded",
  4717. "offTimeUpdate",
  4718. "offError",
  4719. "offWaiting",
  4720. "offSeeking",
  4721. "offSeeked"
  4722. ];
  4723. const defaultOptions = {
  4724. thresholds: [0],
  4725. initialRatio: 0,
  4726. observeAll: false
  4727. };
  4728. const MARGINS = ["top", "right", "bottom", "left"];
  4729. let reqComponentObserverId$1 = 1;
  4730. function normalizeRootMargin(margins = {}) {
  4731. return MARGINS.map(
  4732. (name) => `${Number(margins[name]) || 0}px`
  4733. ).join(" ");
  4734. }
  4735. class ServiceIntersectionObserver {
  4736. constructor(component, options) {
  4737. this._pageId = getPageIdByVm(component);
  4738. this._component = component;
  4739. this._options = extend({}, defaultOptions, options);
  4740. }
  4741. relativeTo(selector, margins) {
  4742. this._options.relativeToSelector = selector;
  4743. this._options.rootMargin = normalizeRootMargin(margins);
  4744. return this;
  4745. }
  4746. relativeToViewport(margins) {
  4747. this._options.relativeToSelector = void 0;
  4748. this._options.rootMargin = normalizeRootMargin(margins);
  4749. return this;
  4750. }
  4751. observe(selector, callback) {
  4752. if (!isFunction(callback)) {
  4753. return;
  4754. }
  4755. this._options.selector = selector;
  4756. this._reqId = reqComponentObserverId$1++;
  4757. addIntersectionObserver(
  4758. {
  4759. reqId: this._reqId,
  4760. component: this._component,
  4761. options: this._options,
  4762. callback
  4763. },
  4764. this._pageId
  4765. );
  4766. }
  4767. disconnect() {
  4768. this._reqId && removeIntersectionObserver(
  4769. { reqId: this._reqId, component: this._component },
  4770. this._pageId
  4771. );
  4772. }
  4773. }
  4774. const createIntersectionObserver = /* @__PURE__ */ defineSyncApi("createIntersectionObserver", (context, options) => {
  4775. context = resolveComponentInstance(context);
  4776. if (context && !getPageIdByVm(context)) {
  4777. options = context;
  4778. context = null;
  4779. }
  4780. if (context) {
  4781. return new ServiceIntersectionObserver(context, options);
  4782. }
  4783. return new ServiceIntersectionObserver(getCurrentPageVm(), options);
  4784. });
  4785. let reqComponentObserverId = 1;
  4786. class ServiceMediaQueryObserver {
  4787. constructor(component) {
  4788. this._pageId = component.$page && component.$page.id;
  4789. this._component = component;
  4790. }
  4791. observe(options, callback) {
  4792. if (!isFunction(callback)) {
  4793. return;
  4794. }
  4795. this._reqId = reqComponentObserverId++;
  4796. addMediaQueryObserver(
  4797. {
  4798. reqId: this._reqId,
  4799. component: this._component,
  4800. options,
  4801. callback
  4802. },
  4803. this._pageId
  4804. );
  4805. }
  4806. disconnect() {
  4807. this._reqId && removeMediaQueryObserver(
  4808. {
  4809. reqId: this._reqId,
  4810. component: this._component
  4811. },
  4812. this._pageId
  4813. );
  4814. }
  4815. }
  4816. const createMediaQueryObserver = /* @__PURE__ */ defineSyncApi("createMediaQueryObserver", (context) => {
  4817. context = resolveComponentInstance(context);
  4818. if (context && !getPageIdByVm(context)) {
  4819. context = null;
  4820. }
  4821. if (context) {
  4822. return new ServiceMediaQueryObserver(context);
  4823. }
  4824. return new ServiceMediaQueryObserver(getCurrentPageVm());
  4825. });
  4826. let index$x = 0;
  4827. let optionsCache = {};
  4828. function operateEditor(componentId, pageId, type, options) {
  4829. const data = { options };
  4830. const needCallOptions = options && ("success" in options || "fail" in options || "complete" in options);
  4831. if (needCallOptions) {
  4832. const callbackId = String(index$x++);
  4833. data.callbackId = callbackId;
  4834. optionsCache[callbackId] = options;
  4835. }
  4836. UniServiceJSBridge.invokeViewMethod(
  4837. `editor.${componentId}`,
  4838. {
  4839. type,
  4840. data
  4841. },
  4842. pageId,
  4843. ({ callbackId, data: data2 }) => {
  4844. if (needCallOptions) {
  4845. callOptions(optionsCache[callbackId], data2);
  4846. delete optionsCache[callbackId];
  4847. }
  4848. }
  4849. );
  4850. }
  4851. class EditorContext {
  4852. constructor(id2, pageId) {
  4853. this.id = id2;
  4854. this.pageId = pageId;
  4855. }
  4856. format(name, value) {
  4857. this._exec("format", {
  4858. name,
  4859. value
  4860. });
  4861. }
  4862. insertDivider() {
  4863. this._exec("insertDivider");
  4864. }
  4865. insertImage(options) {
  4866. this._exec("insertImage", options);
  4867. }
  4868. insertText(options) {
  4869. this._exec("insertText", options);
  4870. }
  4871. setContents(options) {
  4872. this._exec("setContents", options);
  4873. }
  4874. getContents(options) {
  4875. this._exec("getContents", options);
  4876. }
  4877. clear(options) {
  4878. this._exec("clear", options);
  4879. }
  4880. removeFormat(options) {
  4881. this._exec("removeFormat", options);
  4882. }
  4883. undo(options) {
  4884. this._exec("undo", options);
  4885. }
  4886. redo(options) {
  4887. this._exec("redo", options);
  4888. }
  4889. blur(options) {
  4890. this._exec("blur", options);
  4891. }
  4892. getSelectionText(options) {
  4893. this._exec("getSelectionText", options);
  4894. }
  4895. scrollIntoView(options) {
  4896. this._exec("scrollIntoView", options);
  4897. }
  4898. _exec(method, options) {
  4899. operateEditor(this.id, this.pageId, method, options);
  4900. }
  4901. }
  4902. const ContextClasss = {
  4903. canvas: CanvasContext,
  4904. map: MapContext,
  4905. video: VideoContext,
  4906. editor: EditorContext
  4907. };
  4908. function convertContext(result) {
  4909. if (result && result.contextInfo) {
  4910. const { id: id2, type, page } = result.contextInfo;
  4911. const ContextClass = ContextClasss[type];
  4912. result.context = new ContextClass(id2, page);
  4913. delete result.contextInfo;
  4914. }
  4915. }
  4916. class NodesRef {
  4917. constructor(selectorQuery, component, selector, single) {
  4918. this._selectorQuery = selectorQuery;
  4919. this._component = component;
  4920. this._selector = selector;
  4921. this._single = single;
  4922. }
  4923. boundingClientRect(callback) {
  4924. this._selectorQuery._push(
  4925. this._selector,
  4926. this._component,
  4927. this._single,
  4928. {
  4929. id: true,
  4930. dataset: true,
  4931. rect: true,
  4932. size: true
  4933. },
  4934. callback
  4935. );
  4936. return this._selectorQuery;
  4937. }
  4938. fields(fields2, callback) {
  4939. this._selectorQuery._push(
  4940. this._selector,
  4941. this._component,
  4942. this._single,
  4943. fields2,
  4944. callback
  4945. );
  4946. return this._selectorQuery;
  4947. }
  4948. scrollOffset(callback) {
  4949. this._selectorQuery._push(
  4950. this._selector,
  4951. this._component,
  4952. this._single,
  4953. {
  4954. id: true,
  4955. dataset: true,
  4956. scrollOffset: true
  4957. },
  4958. callback
  4959. );
  4960. return this._selectorQuery;
  4961. }
  4962. context(callback) {
  4963. this._selectorQuery._push(
  4964. this._selector,
  4965. this._component,
  4966. this._single,
  4967. {
  4968. context: true
  4969. },
  4970. callback
  4971. );
  4972. return this._selectorQuery;
  4973. }
  4974. node(callback) {
  4975. this._selectorQuery._push(
  4976. this._selector,
  4977. this._component,
  4978. this._single,
  4979. {
  4980. node: true
  4981. },
  4982. callback
  4983. );
  4984. return this._selectorQuery;
  4985. }
  4986. }
  4987. class SelectorQuery {
  4988. constructor(page) {
  4989. this._component = void 0;
  4990. this._page = page;
  4991. this._queue = [];
  4992. this._queueCb = [];
  4993. }
  4994. exec(callback) {
  4995. requestComponentInfo(
  4996. this._page,
  4997. this._queue,
  4998. (res) => {
  4999. const queueCbs = this._queueCb;
  5000. res.forEach((result, index2) => {
  5001. if (isArray(result)) {
  5002. result.forEach(convertContext);
  5003. } else {
  5004. convertContext(result);
  5005. }
  5006. const queueCb = queueCbs[index2];
  5007. if (isFunction(queueCb)) {
  5008. queueCb.call(this, result);
  5009. }
  5010. });
  5011. if (isFunction(callback)) {
  5012. callback.call(this, res);
  5013. }
  5014. }
  5015. );
  5016. return this._nodesRef;
  5017. }
  5018. in(component) {
  5019. this._component = resolveComponentInstance(component);
  5020. return this;
  5021. }
  5022. select(selector) {
  5023. return this._nodesRef = new NodesRef(
  5024. this,
  5025. this._component,
  5026. selector,
  5027. true
  5028. );
  5029. }
  5030. selectAll(selector) {
  5031. return this._nodesRef = new NodesRef(
  5032. this,
  5033. this._component,
  5034. selector,
  5035. false
  5036. );
  5037. }
  5038. selectViewport() {
  5039. return this._nodesRef = new NodesRef(this, null, "", true);
  5040. }
  5041. _push(selector, component, single, fields2, callback) {
  5042. this._queue.push({
  5043. component,
  5044. selector,
  5045. single,
  5046. fields: fields2
  5047. });
  5048. this._queueCb.push(callback);
  5049. }
  5050. }
  5051. const createSelectorQuery = /* @__PURE__ */ defineSyncApi("createSelectorQuery", (context) => {
  5052. context = resolveComponentInstance(context);
  5053. if (context && !getPageIdByVm(context)) {
  5054. context = null;
  5055. }
  5056. return new SelectorQuery(context || getCurrentPageVm());
  5057. });
  5058. const API_CREATE_ANIMATION = "createAnimation";
  5059. const CreateAnimationOptions = {
  5060. // 目前参数校验不支持此api校验
  5061. formatArgs: {
  5062. /* duration: 400,
  5063. timingFunction(timingFunction, params) {
  5064. params.timingFunction = elemInArray(timingFunction, timingFunctions)
  5065. },
  5066. delay: 0,
  5067. transformOrigin: '50% 50% 0', */
  5068. }
  5069. };
  5070. const CreateAnimationProtocol = {
  5071. duration: Number,
  5072. timingFunction: String,
  5073. delay: Number,
  5074. transformOrigin: String
  5075. };
  5076. const defaultOption = {
  5077. duration: 400,
  5078. timingFunction: "linear",
  5079. delay: 0,
  5080. transformOrigin: "50% 50% 0"
  5081. };
  5082. class MPAnimation {
  5083. constructor(option) {
  5084. this.actions = [];
  5085. this.currentTransform = {};
  5086. this.currentStepAnimates = [];
  5087. this.option = extend({}, defaultOption, option);
  5088. }
  5089. _getOption(option) {
  5090. const _option = {
  5091. transition: extend({}, this.option, option),
  5092. transformOrigin: ""
  5093. };
  5094. _option.transformOrigin = _option.transition.transformOrigin;
  5095. delete _option.transition.transformOrigin;
  5096. return _option;
  5097. }
  5098. _pushAnimates(type, args) {
  5099. this.currentStepAnimates.push({
  5100. type,
  5101. args
  5102. });
  5103. }
  5104. _converType(type) {
  5105. return type.replace(/[A-Z]/g, (text2) => {
  5106. return `-${text2.toLowerCase()}`;
  5107. });
  5108. }
  5109. _getValue(value) {
  5110. return typeof value === "number" ? `${value}px` : value;
  5111. }
  5112. export() {
  5113. const actions = this.actions;
  5114. this.actions = [];
  5115. return {
  5116. actions
  5117. };
  5118. }
  5119. step(option) {
  5120. this.currentStepAnimates.forEach((animate) => {
  5121. if (animate.type !== "style") {
  5122. this.currentTransform[animate.type] = animate;
  5123. } else {
  5124. this.currentTransform[`${animate.type}.${animate.args[0]}`] = animate;
  5125. }
  5126. });
  5127. this.actions.push({
  5128. animates: Object.values(
  5129. this.currentTransform
  5130. ),
  5131. option: this._getOption(option)
  5132. });
  5133. this.currentStepAnimates = [];
  5134. return this;
  5135. }
  5136. }
  5137. const initAnimationProperty = /* @__PURE__ */ once(() => {
  5138. const animateTypes1 = [
  5139. "matrix",
  5140. "matrix3d",
  5141. "rotate",
  5142. "rotate3d",
  5143. "rotateX",
  5144. "rotateY",
  5145. "rotateZ",
  5146. "scale",
  5147. "scale3d",
  5148. "scaleX",
  5149. "scaleY",
  5150. "scaleZ",
  5151. "skew",
  5152. "skewX",
  5153. "skewY",
  5154. "translate",
  5155. "translate3d",
  5156. "translateX",
  5157. "translateY",
  5158. "translateZ"
  5159. ];
  5160. const animateTypes2 = ["opacity", "backgroundColor"];
  5161. const animateTypes3 = ["width", "height", "left", "right", "top", "bottom"];
  5162. animateTypes1.concat(animateTypes2, animateTypes3).forEach((type) => {
  5163. MPAnimation.prototype[type] = function(...args) {
  5164. if (animateTypes2.concat(animateTypes3).includes(type)) {
  5165. this._pushAnimates("style", [
  5166. this._converType(type),
  5167. animateTypes3.includes(type) ? this._getValue(args[0]) : args[0]
  5168. ]);
  5169. } else {
  5170. this._pushAnimates(type, args);
  5171. }
  5172. return this;
  5173. };
  5174. });
  5175. });
  5176. const createAnimation$1 = /* @__PURE__ */ defineSyncApi(
  5177. API_CREATE_ANIMATION,
  5178. (option) => {
  5179. initAnimationProperty();
  5180. return new MPAnimation(option);
  5181. },
  5182. CreateAnimationProtocol,
  5183. CreateAnimationOptions
  5184. );
  5185. const API_ON_TAB_BAR_MID_BUTTON_TAP = "onTabBarMidButtonTap";
  5186. const onTabBarMidButtonTap = /* @__PURE__ */ defineOnApi(
  5187. API_ON_TAB_BAR_MID_BUTTON_TAP,
  5188. () => {
  5189. }
  5190. );
  5191. const API_ON_WINDOW_RESIZE = "onWindowResize";
  5192. const API_OFF_WINDOW_RESIZE = "offWindowResize";
  5193. const onWindowResize = /* @__PURE__ */ defineOnApi(
  5194. API_ON_WINDOW_RESIZE,
  5195. () => {
  5196. }
  5197. );
  5198. const offWindowResize = /* @__PURE__ */ defineOffApi(
  5199. API_OFF_WINDOW_RESIZE,
  5200. () => {
  5201. }
  5202. );
  5203. const API_SET_LOCALE = "setLocale";
  5204. const API_GET_LOCALE = "getLocale";
  5205. const API_ON_LOCALE_CHANGE = "onLocaleChange";
  5206. const getLocale = /* @__PURE__ */ defineSyncApi(
  5207. API_GET_LOCALE,
  5208. () => {
  5209. const app = getApp({ allowDefault: true });
  5210. if (app && app.$vm) {
  5211. return app.$vm.$locale;
  5212. }
  5213. return useI18n().getLocale();
  5214. }
  5215. );
  5216. const onLocaleChange = /* @__PURE__ */ defineOnApi(
  5217. API_ON_LOCALE_CHANGE,
  5218. () => {
  5219. }
  5220. );
  5221. const setLocale = /* @__PURE__ */ defineSyncApi(
  5222. API_SET_LOCALE,
  5223. (locale) => {
  5224. const app = getApp();
  5225. if (!app) {
  5226. return false;
  5227. }
  5228. const oldLocale = app.$vm.$locale;
  5229. if (oldLocale !== locale) {
  5230. app.$vm.$locale = locale;
  5231. {
  5232. navigator.cookieEnabled && window.localStorage && (localStorage[UNI_STORAGE_LOCALE] = locale);
  5233. }
  5234. UniServiceJSBridge.invokeOnCallback(API_ON_LOCALE_CHANGE, { locale });
  5235. return true;
  5236. }
  5237. return false;
  5238. }
  5239. );
  5240. const API_SET_PAGE_META = "setPageMeta";
  5241. const setPageMeta = /* @__PURE__ */ defineAsyncApi(
  5242. API_SET_PAGE_META,
  5243. (options, { resolve }) => {
  5244. resolve(setCurrentPageMeta(getCurrentPageVm(), options));
  5245. }
  5246. );
  5247. const API_GET_SELECTED_TEXT_RANGE = "getSelectedTextRange";
  5248. const getSelectedTextRange$1 = /* @__PURE__ */ defineAsyncApi(
  5249. API_GET_SELECTED_TEXT_RANGE,
  5250. (_, { resolve, reject }) => {
  5251. UniServiceJSBridge.invokeViewMethod(API_GET_SELECTED_TEXT_RANGE, {}, getCurrentPageId(), (res) => {
  5252. if (typeof res.end === "undefined" && typeof res.start === "undefined") {
  5253. reject("no focused");
  5254. } else {
  5255. resolve(res);
  5256. }
  5257. });
  5258. }
  5259. );
  5260. const appHooks = {
  5261. [ON_UNHANDLE_REJECTION]: [],
  5262. [ON_PAGE_NOT_FOUND]: [],
  5263. [ON_ERROR]: [],
  5264. [ON_SHOW]: [],
  5265. [ON_HIDE]: []
  5266. };
  5267. function onAppHook(type, hook) {
  5268. const app = getApp({ allowDefault: true });
  5269. if (app && app.$vm) {
  5270. return injectHook(type, hook, app.$vm.$);
  5271. }
  5272. appHooks[type].push(hook);
  5273. }
  5274. function injectAppHooks(appInstance) {
  5275. Object.keys(appHooks).forEach((type) => {
  5276. appHooks[type].forEach((hook) => {
  5277. injectHook(type, hook, appInstance);
  5278. });
  5279. });
  5280. }
  5281. function offAppHook(type, hook) {
  5282. const app = getApp({ allowDefault: true });
  5283. if (app && app.$vm) {
  5284. return removeHook(app.$vm, type, hook);
  5285. }
  5286. remove(appHooks[type], hook);
  5287. }
  5288. function onUnhandledRejection(hook) {
  5289. onAppHook(ON_UNHANDLE_REJECTION, hook);
  5290. }
  5291. function offUnhandledRejection(hook) {
  5292. offAppHook(ON_UNHANDLE_REJECTION, hook);
  5293. }
  5294. function onPageNotFound(hook) {
  5295. onAppHook(ON_PAGE_NOT_FOUND, hook);
  5296. }
  5297. function offPageNotFound(hook) {
  5298. offAppHook(ON_PAGE_NOT_FOUND, hook);
  5299. }
  5300. function onError(hook) {
  5301. onAppHook(ON_ERROR, hook);
  5302. }
  5303. function offError(hook) {
  5304. offAppHook(ON_ERROR, hook);
  5305. }
  5306. function onAppShow(hook) {
  5307. onAppHook(ON_SHOW, hook);
  5308. }
  5309. function offAppShow(hook) {
  5310. offAppHook(ON_SHOW, hook);
  5311. }
  5312. function onAppHide(hook) {
  5313. onAppHook(ON_HIDE, hook);
  5314. }
  5315. function offAppHide(hook) {
  5316. offAppHook(ON_HIDE, hook);
  5317. }
  5318. const API_GET_ENTER_OPTIONS_SYNC = "getEnterOptionsSync";
  5319. const getEnterOptionsSync = /* @__PURE__ */ defineSyncApi(
  5320. API_GET_ENTER_OPTIONS_SYNC,
  5321. () => {
  5322. return getEnterOptions();
  5323. }
  5324. );
  5325. const API_GET_LAUNCH_OPTIONS_SYNC = "getLaunchOptionsSync";
  5326. const getLaunchOptionsSync = /* @__PURE__ */ defineSyncApi(
  5327. API_GET_LAUNCH_OPTIONS_SYNC,
  5328. () => {
  5329. return getLaunchOptions();
  5330. }
  5331. );
  5332. let cid;
  5333. let cidErrMsg;
  5334. let enabled;
  5335. function normalizePushMessage(message) {
  5336. try {
  5337. return JSON.parse(message);
  5338. } catch (e2) {
  5339. }
  5340. return message;
  5341. }
  5342. function invokePushCallback(args) {
  5343. if (args.type === "enabled") {
  5344. enabled = true;
  5345. } else if (args.type === "clientId") {
  5346. cid = args.cid;
  5347. cidErrMsg = args.errMsg;
  5348. invokeGetPushCidCallbacks(cid, args.errMsg);
  5349. } else if (args.type === "pushMsg") {
  5350. const message = {
  5351. type: "receive",
  5352. data: normalizePushMessage(args.message)
  5353. };
  5354. for (let i = 0; i < onPushMessageCallbacks.length; i++) {
  5355. const callback = onPushMessageCallbacks[i];
  5356. callback(message);
  5357. if (message.stopped) {
  5358. break;
  5359. }
  5360. }
  5361. } else if (args.type === "click") {
  5362. onPushMessageCallbacks.forEach((callback) => {
  5363. callback({
  5364. type: "click",
  5365. data: normalizePushMessage(args.message)
  5366. });
  5367. });
  5368. }
  5369. }
  5370. const getPushCidCallbacks = [];
  5371. function invokeGetPushCidCallbacks(cid2, errMsg) {
  5372. getPushCidCallbacks.forEach((callback) => {
  5373. callback(cid2, errMsg);
  5374. });
  5375. getPushCidCallbacks.length = 0;
  5376. }
  5377. const API_GET_PUSH_CLIENT_ID = "getPushClientId";
  5378. const getPushClientId = /* @__PURE__ */ defineAsyncApi(
  5379. API_GET_PUSH_CLIENT_ID,
  5380. (_, { resolve, reject }) => {
  5381. Promise.resolve().then(() => {
  5382. if (typeof enabled === "undefined") {
  5383. enabled = false;
  5384. cid = "";
  5385. cidErrMsg = "uniPush is not enabled";
  5386. }
  5387. getPushCidCallbacks.push((cid2, errMsg) => {
  5388. if (cid2) {
  5389. resolve({ cid: cid2 });
  5390. } else {
  5391. reject(errMsg);
  5392. }
  5393. });
  5394. if (typeof cid !== "undefined") {
  5395. invokeGetPushCidCallbacks(cid, cidErrMsg);
  5396. }
  5397. });
  5398. }
  5399. );
  5400. const onPushMessageCallbacks = [];
  5401. const onPushMessage = (fn) => {
  5402. if (onPushMessageCallbacks.indexOf(fn) === -1) {
  5403. onPushMessageCallbacks.push(fn);
  5404. }
  5405. };
  5406. const offPushMessage = (fn) => {
  5407. if (!fn) {
  5408. onPushMessageCallbacks.length = 0;
  5409. } else {
  5410. const index2 = onPushMessageCallbacks.indexOf(fn);
  5411. if (index2 > -1) {
  5412. onPushMessageCallbacks.splice(index2, 1);
  5413. }
  5414. }
  5415. };
  5416. const API_CAN_I_USE = "canIUse";
  5417. const CanIUseProtocol = [
  5418. {
  5419. name: "schema",
  5420. type: String,
  5421. required: true
  5422. }
  5423. ];
  5424. const API_MAKE_PHONE_CALL = "makePhoneCall";
  5425. const MakePhoneCallProtocol = {
  5426. phoneNumber: String
  5427. };
  5428. const API_GET_CLIPBOARD_DATA = "getClipboardData";
  5429. const API_SET_CLIPBOARD_DATA = "setClipboardData";
  5430. const SetClipboardDataOptions = {
  5431. formatArgs: {
  5432. showToast: true
  5433. },
  5434. beforeInvoke() {
  5435. initI18nSetClipboardDataMsgsOnce();
  5436. },
  5437. beforeSuccess(res, params) {
  5438. if (!params.showToast)
  5439. return;
  5440. const { t: t2 } = useI18n();
  5441. const title = t2("uni.setClipboardData.success");
  5442. if (title) {
  5443. uni.showToast({
  5444. title,
  5445. icon: "success",
  5446. mask: false
  5447. });
  5448. }
  5449. }
  5450. };
  5451. const SetClipboardDataProtocol = {
  5452. data: {
  5453. type: String,
  5454. required: true
  5455. },
  5456. showToast: {
  5457. type: Boolean
  5458. }
  5459. };
  5460. const API_ON_ACCELEROMETER = "onAccelerometer";
  5461. const API_OFF_ACCELEROMETER = "offAccelerometer";
  5462. const API_START_ACCELEROMETER = "startAccelerometer";
  5463. const API_STOP_ACCELEROMETER = "stopAccelerometer";
  5464. const API_ON_COMPASS = "onCompass";
  5465. const API_OFF_COMPASS = "offCompass";
  5466. const API_START_COMPASS = "startCompass";
  5467. const API_STOP_COMPASS = "stopCompass";
  5468. const API_VIBRATE_SHORT = "vibrateShort";
  5469. const API_VIBRATE_LONG = "vibrateLong";
  5470. const API_GET_STORAGE = "getStorage";
  5471. const GetStorageProtocol = {
  5472. key: {
  5473. type: String,
  5474. required: true
  5475. }
  5476. };
  5477. const API_GET_STORAGE_SYNC = "getStorageSync";
  5478. const GetStorageSyncProtocol = [
  5479. {
  5480. name: "key",
  5481. type: String,
  5482. required: true
  5483. }
  5484. ];
  5485. const API_SET_STORAGE = "setStorage";
  5486. const SetStorageProtocol = {
  5487. key: {
  5488. type: String,
  5489. required: true
  5490. },
  5491. data: {
  5492. required: true
  5493. }
  5494. };
  5495. const API_SET_STORAGE_SYNC = "setStorageSync";
  5496. const SetStorageSyncProtocol = [
  5497. {
  5498. name: "key",
  5499. type: String,
  5500. required: true
  5501. },
  5502. {
  5503. name: "data",
  5504. required: true
  5505. }
  5506. ];
  5507. const API_REMOVE_STORAGE = "removeStorage";
  5508. const RemoveStorageProtocol = GetStorageProtocol;
  5509. const RemoveStorageSyncProtocol = GetStorageSyncProtocol;
  5510. const API_GET_FILE_INFO = "getFileInfo";
  5511. const GetFileInfoOptions = {
  5512. formatArgs: {
  5513. filePath(filePath, params) {
  5514. params.filePath = getRealPath(filePath);
  5515. }
  5516. }
  5517. };
  5518. const GetFileInfoProtocol = {
  5519. filePath: {
  5520. type: String,
  5521. required: true
  5522. }
  5523. };
  5524. const API_OPEN_DOCUMENT = "openDocument";
  5525. const OpenDocumentOptions = {
  5526. formatArgs: {
  5527. filePath(filePath, params) {
  5528. params.filePath = getRealPath(filePath);
  5529. }
  5530. }
  5531. };
  5532. const OpenDocumentProtocol = {
  5533. filePath: {
  5534. type: String,
  5535. required: true
  5536. },
  5537. fileType: String
  5538. };
  5539. const API_HIDE_KEYBOARD = "hideKeyboard";
  5540. const API_CHOOSE_LOCATION = "chooseLocation";
  5541. const ChooseLocationProtocol = {
  5542. keyword: String,
  5543. latitude: Number,
  5544. longitude: Number
  5545. };
  5546. const API_GET_LOCATION = "getLocation";
  5547. const coordTypes$1 = ["wgs84", "gcj02"];
  5548. const GetLocationOptions = {
  5549. formatArgs: {
  5550. type(value, params) {
  5551. value = (value || "").toLowerCase();
  5552. if (coordTypes$1.indexOf(value) === -1) {
  5553. params.type = coordTypes$1[0];
  5554. } else {
  5555. params.type = value;
  5556. }
  5557. },
  5558. altitude(value, params) {
  5559. params.altitude = value ? value : false;
  5560. }
  5561. }
  5562. };
  5563. const GetLocationProtocol = {
  5564. type: String,
  5565. altitude: Boolean
  5566. };
  5567. const API_OPEN_LOCATION = "openLocation";
  5568. const checkProps = (key, value) => {
  5569. if (value === void 0) {
  5570. return `${key} should not be empty.`;
  5571. }
  5572. if (typeof value !== "number") {
  5573. let receivedType = typeof value;
  5574. receivedType = receivedType[0].toUpperCase() + receivedType.substring(1);
  5575. return `Expected Number, got ${receivedType} with value ${JSON.stringify(
  5576. value
  5577. )}.`;
  5578. }
  5579. };
  5580. const OpenLocationOptions = {
  5581. formatArgs: {
  5582. latitude(value, params) {
  5583. const checkedInfo = checkProps("latitude", value);
  5584. if (checkedInfo) {
  5585. return checkedInfo;
  5586. }
  5587. params.latitude = value;
  5588. },
  5589. longitude(value, params) {
  5590. const checkedInfo = checkProps("longitude", value);
  5591. if (checkedInfo) {
  5592. return checkedInfo;
  5593. }
  5594. params.longitude = value;
  5595. },
  5596. scale(value, params) {
  5597. value = Math.floor(value);
  5598. params.scale = value >= 5 && value <= 18 ? value : 18;
  5599. }
  5600. }
  5601. };
  5602. const OpenLocationProtocol = {
  5603. latitude: Number,
  5604. longitude: Number,
  5605. scale: Number,
  5606. name: String,
  5607. address: String
  5608. };
  5609. const API_CHOOSE_IMAGE = "chooseImage";
  5610. const ChooseImageOptions = {
  5611. formatArgs: {
  5612. count(value, params) {
  5613. if (!value || value <= 0) {
  5614. params.count = 9;
  5615. }
  5616. },
  5617. sizeType(sizeType, params) {
  5618. params.sizeType = elemsInArray(sizeType, CHOOSE_SIZE_TYPES);
  5619. },
  5620. sourceType(sourceType, params) {
  5621. params.sourceType = elemsInArray(sourceType, CHOOSE_SOURCE_TYPES);
  5622. },
  5623. extension(extension, params) {
  5624. if (extension instanceof Array && extension.length === 0) {
  5625. return "param extension should not be empty.";
  5626. }
  5627. if (!extension)
  5628. params.extension = ["*"];
  5629. }
  5630. }
  5631. };
  5632. const ChooseImageProtocol = {
  5633. count: Number,
  5634. sizeType: [Array, String],
  5635. sourceType: Array,
  5636. extension: Array
  5637. };
  5638. const API_CHOOSE_VIDEO = "chooseVideo";
  5639. const ChooseVideoOptions = {
  5640. formatArgs: {
  5641. sourceType(sourceType, params) {
  5642. params.sourceType = elemsInArray(sourceType, CHOOSE_SOURCE_TYPES);
  5643. },
  5644. compressed: true,
  5645. maxDuration: 60,
  5646. camera: "back",
  5647. extension(extension, params) {
  5648. if (extension instanceof Array && extension.length === 0) {
  5649. return "param extension should not be empty.";
  5650. }
  5651. if (!extension)
  5652. params.extension = ["*"];
  5653. }
  5654. }
  5655. };
  5656. const ChooseVideoProtocol = {
  5657. sourceType: Array,
  5658. compressed: Boolean,
  5659. maxDuration: Number,
  5660. camera: String,
  5661. extension: Array
  5662. };
  5663. const API_CHOOSE_FILE = "chooseFile";
  5664. const CHOOSE_MEDIA_TYPE = [
  5665. "all",
  5666. "image",
  5667. "video"
  5668. ];
  5669. const ChooseFileOptions = {
  5670. formatArgs: {
  5671. count(count, params) {
  5672. if (!count || count <= 0) {
  5673. params.count = 100;
  5674. }
  5675. },
  5676. sourceType(sourceType, params) {
  5677. params.sourceType = elemsInArray(sourceType, CHOOSE_SOURCE_TYPES);
  5678. },
  5679. type(type, params) {
  5680. params.type = elemInArray(type, CHOOSE_MEDIA_TYPE);
  5681. },
  5682. extension(extension, params) {
  5683. if (extension instanceof Array && extension.length === 0) {
  5684. return "param extension should not be empty.";
  5685. }
  5686. if (!extension)
  5687. params.extension = [""];
  5688. }
  5689. }
  5690. };
  5691. const ChooseFileProtocol = {
  5692. count: Number,
  5693. sourceType: Array,
  5694. type: String,
  5695. extension: Array
  5696. };
  5697. const API_GET_IMAGE_INFO = "getImageInfo";
  5698. const GetImageInfoOptions = {
  5699. formatArgs: {
  5700. src(src, params) {
  5701. params.src = getRealPath(src);
  5702. }
  5703. }
  5704. };
  5705. const GetImageInfoProtocol = {
  5706. src: {
  5707. type: String,
  5708. required: true
  5709. }
  5710. };
  5711. const API_PREVIEW_IMAGE = "previewImage";
  5712. const PreviewImageOptions = {
  5713. formatArgs: {
  5714. urls(urls, params) {
  5715. params.urls = urls.map(
  5716. (url) => isString(url) && url ? getRealPath(url) : ""
  5717. );
  5718. },
  5719. current(current, params) {
  5720. if (typeof current === "number") {
  5721. params.current = current > 0 && current < params.urls.length ? current : 0;
  5722. } else if (isString(current) && current) {
  5723. params.current = getRealPath(current);
  5724. }
  5725. }
  5726. }
  5727. };
  5728. const PreviewImageProtocol = {
  5729. urls: {
  5730. type: Array,
  5731. required: true
  5732. },
  5733. current: {
  5734. type: [Number, String]
  5735. }
  5736. };
  5737. const API_CLOSE_PREVIEW_IMAGE = "closePreviewImage";
  5738. const API_GET_VIDEO_INFO = "getVideoInfo";
  5739. const GetVideoInfoOptions = {
  5740. formatArgs: {
  5741. src(src, params) {
  5742. params.src = getRealPath(src);
  5743. }
  5744. }
  5745. };
  5746. const GetVideoInfoProtocol = {
  5747. src: {
  5748. type: String,
  5749. required: true
  5750. }
  5751. };
  5752. const API_SAVE_IMAGE_TO_PHOTOS_ALBUM = "saveImageToPhotosAlbum";
  5753. const API_SAVE_VIDEO_TO_PHOTOS_ALBUM = "saveVideoToPhotosAlbum";
  5754. const API_REQUEST = "request";
  5755. const dataType = {
  5756. JSON: "json"
  5757. };
  5758. const RESPONSE_TYPE = ["text", "arraybuffer"];
  5759. const DEFAULT_RESPONSE_TYPE = "text";
  5760. const encode = encodeURIComponent;
  5761. function stringifyQuery(url, data) {
  5762. let str = url.split("#");
  5763. const hash = str[1] || "";
  5764. str = str[0].split("?");
  5765. let query = str[1] || "";
  5766. url = str[0];
  5767. const search = query.split("&").filter((item) => item);
  5768. const params = {};
  5769. search.forEach((item) => {
  5770. const part = item.split("=");
  5771. params[part[0]] = part[1];
  5772. });
  5773. for (const key in data) {
  5774. if (hasOwn(data, key)) {
  5775. let v2 = data[key];
  5776. if (typeof v2 === "undefined" || v2 === null) {
  5777. v2 = "";
  5778. } else if (isPlainObject(v2)) {
  5779. v2 = JSON.stringify(v2);
  5780. }
  5781. params[encode(key)] = encode(v2);
  5782. }
  5783. }
  5784. query = Object.keys(params).map((item) => `${item}=${params[item]}`).join("&");
  5785. return url + (query ? "?" + query : "") + (hash ? "#" + hash : "");
  5786. }
  5787. const RequestProtocol = {
  5788. method: String,
  5789. data: [Object, String, Array, ArrayBuffer],
  5790. url: {
  5791. type: String,
  5792. required: true
  5793. },
  5794. header: Object,
  5795. dataType: String,
  5796. responseType: String,
  5797. withCredentials: Boolean
  5798. };
  5799. const RequestOptions = {
  5800. formatArgs: {
  5801. method(value, params) {
  5802. params.method = elemInArray(
  5803. (value || "").toUpperCase(),
  5804. HTTP_METHODS
  5805. );
  5806. },
  5807. data(value, params) {
  5808. params.data = value || "";
  5809. },
  5810. url(value, params) {
  5811. if (params.method === HTTP_METHODS[0] && isPlainObject(params.data) && Object.keys(params.data).length) {
  5812. params.url = stringifyQuery(value, params.data);
  5813. }
  5814. },
  5815. header(value, params) {
  5816. const header = params.header = value || {};
  5817. if (params.method !== HTTP_METHODS[0]) {
  5818. if (!Object.keys(header).find(
  5819. (key) => key.toLowerCase() === "content-type"
  5820. )) {
  5821. header["Content-Type"] = "application/json";
  5822. }
  5823. }
  5824. },
  5825. dataType(value, params) {
  5826. params.dataType = (value || dataType.JSON).toLowerCase();
  5827. },
  5828. responseType(value, params) {
  5829. params.responseType = (value || "").toLowerCase();
  5830. if (RESPONSE_TYPE.indexOf(params.responseType) === -1) {
  5831. params.responseType = DEFAULT_RESPONSE_TYPE;
  5832. }
  5833. }
  5834. }
  5835. };
  5836. const API_DOWNLOAD_FILE = "downloadFile";
  5837. const DownloadFileOptions = {
  5838. formatArgs: {
  5839. header(value, params) {
  5840. params.header = value || {};
  5841. }
  5842. }
  5843. };
  5844. const DownloadFileProtocol = {
  5845. url: {
  5846. type: String,
  5847. required: true
  5848. },
  5849. header: Object,
  5850. timeout: Number
  5851. };
  5852. const API_UPLOAD_FILE = "uploadFile";
  5853. const UploadFileOptions = {
  5854. formatArgs: {
  5855. filePath(filePath, params) {
  5856. if (filePath) {
  5857. params.filePath = getRealPath(filePath);
  5858. }
  5859. },
  5860. header(value, params) {
  5861. params.header = value || {};
  5862. },
  5863. formData(value, params) {
  5864. params.formData = value || {};
  5865. }
  5866. }
  5867. };
  5868. const UploadFileProtocol = {
  5869. url: {
  5870. type: String,
  5871. required: true
  5872. },
  5873. files: Array,
  5874. filePath: String,
  5875. name: String,
  5876. header: Object,
  5877. formData: Object,
  5878. timeout: Number
  5879. };
  5880. const API_CONNECT_SOCKET = "connectSocket";
  5881. const ConnectSocketOptions = {
  5882. formatArgs: {
  5883. header(value, params) {
  5884. params.header = value || {};
  5885. },
  5886. method(value, params) {
  5887. params.method = elemInArray(
  5888. (value || "").toUpperCase(),
  5889. HTTP_METHODS
  5890. );
  5891. },
  5892. protocols(protocols, params) {
  5893. if (isString(protocols)) {
  5894. params.protocols = [protocols];
  5895. }
  5896. }
  5897. }
  5898. };
  5899. const ConnectSocketProtocol = {
  5900. url: {
  5901. type: String,
  5902. required: true
  5903. },
  5904. header: {
  5905. type: Object
  5906. },
  5907. method: String,
  5908. protocols: [Array, String]
  5909. };
  5910. const API_SEND_SOCKET_MESSAGE = "sendSocketMessage";
  5911. const SendSocketMessageProtocol = {
  5912. data: [String, ArrayBuffer]
  5913. };
  5914. const API_CLOSE_SOCKET = "closeSocket";
  5915. const CloseSocketProtocol = {
  5916. code: Number,
  5917. reason: String
  5918. };
  5919. const API_START_LOCATION_UPDATE = "startLocationUpdate";
  5920. const API_ON_LOCATION_CHANGE = "onLocationChange";
  5921. const API_STOP_LOCATION_UPDATE = "stopLocationUpdate";
  5922. const API_OFF_LOCATION_CHANGE = "offLocationChange";
  5923. const API_OFF_LOCATION_CHANGE_ERROR = "offLocationChangeError";
  5924. const API_ON_LOCATION_CHANGE_ERROR = "onLocationChangeError";
  5925. const coordTypes = ["wgs84", "gcj02"];
  5926. const StartLocationUpdateProtocol = {
  5927. type: String
  5928. };
  5929. const StartLocationUpdateOptions = {
  5930. formatArgs: {
  5931. type(value, params) {
  5932. value = (value || "").toLowerCase();
  5933. if (coordTypes.indexOf(value) === -1) {
  5934. params.type = coordTypes[1];
  5935. } else {
  5936. params.type = value;
  5937. }
  5938. }
  5939. }
  5940. };
  5941. function encodeQueryString(url) {
  5942. if (!isString(url)) {
  5943. return url;
  5944. }
  5945. const index2 = url.indexOf("?");
  5946. if (index2 === -1) {
  5947. return url;
  5948. }
  5949. const query = url.slice(index2 + 1).trim().replace(/^(\?|#|&)/, "");
  5950. if (!query) {
  5951. return url;
  5952. }
  5953. url = url.slice(0, index2);
  5954. const params = [];
  5955. query.split("&").forEach((param) => {
  5956. const parts = param.replace(/\+/g, " ").split("=");
  5957. const key = parts.shift();
  5958. const val = parts.length > 0 ? parts.join("=") : "";
  5959. params.push(key + "=" + encodeURIComponent(val));
  5960. });
  5961. return params.length ? url + "?" + params.join("&") : url;
  5962. }
  5963. const ANIMATION_IN$1 = [
  5964. "slide-in-right",
  5965. "slide-in-left",
  5966. "slide-in-top",
  5967. "slide-in-bottom",
  5968. "fade-in",
  5969. "zoom-out",
  5970. "zoom-fade-out",
  5971. "pop-in",
  5972. "none"
  5973. ];
  5974. const ANIMATION_OUT$1 = [
  5975. "slide-out-right",
  5976. "slide-out-left",
  5977. "slide-out-top",
  5978. "slide-out-bottom",
  5979. "fade-out",
  5980. "zoom-in",
  5981. "zoom-fade-in",
  5982. "pop-out",
  5983. "none"
  5984. ];
  5985. const BaseRouteProtocol = {
  5986. url: {
  5987. type: String,
  5988. required: true
  5989. }
  5990. };
  5991. const API_NAVIGATE_TO = "navigateTo";
  5992. const API_REDIRECT_TO = "redirectTo";
  5993. const API_RE_LAUNCH = "reLaunch";
  5994. const API_SWITCH_TAB = "switchTab";
  5995. const API_NAVIGATE_BACK = "navigateBack";
  5996. const API_PRELOAD_PAGE = "preloadPage";
  5997. const API_UN_PRELOAD_PAGE = "unPreloadPage";
  5998. const NavigateToProtocol = /* @__PURE__ */ extend(
  5999. {},
  6000. BaseRouteProtocol,
  6001. createAnimationProtocol(ANIMATION_IN$1)
  6002. );
  6003. const NavigateBackProtocol = /* @__PURE__ */ extend(
  6004. {
  6005. delta: {
  6006. type: Number
  6007. }
  6008. },
  6009. createAnimationProtocol(ANIMATION_OUT$1)
  6010. );
  6011. const RedirectToProtocol = BaseRouteProtocol;
  6012. const ReLaunchProtocol = BaseRouteProtocol;
  6013. const SwitchTabProtocol = BaseRouteProtocol;
  6014. const PreloadPageProtocol = BaseRouteProtocol;
  6015. const NavigateToOptions = /* @__PURE__ */ createRouteOptions(API_NAVIGATE_TO);
  6016. const RedirectToOptions = /* @__PURE__ */ createRouteOptions(API_REDIRECT_TO);
  6017. const ReLaunchOptions = /* @__PURE__ */ createRouteOptions(API_RE_LAUNCH);
  6018. const SwitchTabOptions = /* @__PURE__ */ createRouteOptions(API_SWITCH_TAB);
  6019. const NavigateBackOptions = {
  6020. formatArgs: {
  6021. delta(value, params) {
  6022. value = parseInt(value + "") || 1;
  6023. params.delta = Math.min(getCurrentPages().length - 1, value);
  6024. }
  6025. }
  6026. };
  6027. function createAnimationProtocol(animationTypes) {
  6028. return {
  6029. animationType: {
  6030. type: String,
  6031. validator(type) {
  6032. if (type && animationTypes.indexOf(type) === -1) {
  6033. return "`" + type + "` is not supported for `animationType` (supported values are: `" + animationTypes.join("`|`") + "`)";
  6034. }
  6035. }
  6036. },
  6037. animationDuration: {
  6038. type: Number
  6039. }
  6040. };
  6041. }
  6042. let navigatorLock;
  6043. function beforeRoute() {
  6044. navigatorLock = "";
  6045. }
  6046. function createRouteOptions(type) {
  6047. return {
  6048. formatArgs: {
  6049. url: createNormalizeUrl(type)
  6050. },
  6051. beforeAll: beforeRoute
  6052. };
  6053. }
  6054. function createNormalizeUrl(type) {
  6055. return function normalizeUrl(url, params) {
  6056. if (!url) {
  6057. return `Missing required args: "url"`;
  6058. }
  6059. url = normalizeRoute(url);
  6060. const pagePath = url.split("?")[0];
  6061. const routeOptions = getRouteOptions(pagePath, true);
  6062. if (!routeOptions) {
  6063. return "page `" + url + "` is not found";
  6064. }
  6065. if (type === API_NAVIGATE_TO || type === API_REDIRECT_TO) {
  6066. if (routeOptions.meta.isTabBar) {
  6067. return `can not ${type} a tabbar page`;
  6068. }
  6069. } else if (type === API_SWITCH_TAB) {
  6070. if (!routeOptions.meta.isTabBar) {
  6071. return "can not switch to no-tabBar page";
  6072. }
  6073. }
  6074. if ((type === API_SWITCH_TAB || type === API_PRELOAD_PAGE) && routeOptions.meta.isTabBar && params.openType !== "appLaunch") {
  6075. url = pagePath;
  6076. }
  6077. if (routeOptions.meta.isEntry) {
  6078. url = url.replace(routeOptions.alias, "/");
  6079. }
  6080. params.url = encodeQueryString(url);
  6081. if (type === API_UN_PRELOAD_PAGE) {
  6082. return;
  6083. } else if (type === API_PRELOAD_PAGE) {
  6084. if (routeOptions.meta.isTabBar) {
  6085. const pages = getCurrentPages();
  6086. const tabBarPagePath = routeOptions.path.slice(1);
  6087. if (pages.find((page) => page.route === tabBarPagePath)) {
  6088. return "tabBar page `" + tabBarPagePath + "` already exists";
  6089. }
  6090. }
  6091. return;
  6092. }
  6093. if (navigatorLock === url && params.openType !== "appLaunch") {
  6094. return `${navigatorLock} locked`;
  6095. }
  6096. if (__uniConfig.ready) {
  6097. navigatorLock = url;
  6098. }
  6099. };
  6100. }
  6101. const API_HIDE_LOADING = "hideLoading";
  6102. const API_HIDE_TOAST = "hideToast";
  6103. const API_LOAD_FONT_FACE = "loadFontFace";
  6104. const LoadFontFaceProtocol = {
  6105. family: {
  6106. type: String,
  6107. required: true
  6108. },
  6109. source: {
  6110. type: String,
  6111. required: true
  6112. },
  6113. desc: Object
  6114. };
  6115. const FRONT_COLORS = ["#ffffff", "#000000"];
  6116. const API_SET_NAVIGATION_BAR_COLOR = "setNavigationBarColor";
  6117. const SetNavigationBarColorOptions = {
  6118. formatArgs: {
  6119. animation(animation2, params) {
  6120. if (!animation2) {
  6121. animation2 = { duration: 0, timingFunc: "linear" };
  6122. }
  6123. params.animation = {
  6124. duration: animation2.duration || 0,
  6125. timingFunc: animation2.timingFunc || "linear"
  6126. };
  6127. }
  6128. }
  6129. };
  6130. const SetNavigationBarColorProtocol = {
  6131. frontColor: {
  6132. type: String,
  6133. required: true,
  6134. validator(frontColor) {
  6135. if (FRONT_COLORS.indexOf(frontColor) === -1) {
  6136. return `invalid frontColor "${frontColor}"`;
  6137. }
  6138. }
  6139. },
  6140. backgroundColor: {
  6141. type: String,
  6142. required: true
  6143. },
  6144. animation: Object
  6145. };
  6146. const API_SET_NAVIGATION_BAR_TITLE = "setNavigationBarTitle";
  6147. const SetNavigationBarTitleProtocol = {
  6148. title: {
  6149. type: String,
  6150. required: true
  6151. }
  6152. };
  6153. const API_SHOW_NAVIGATION_BAR_LOADING = "showNavigationBarLoading";
  6154. const API_HIDE_NAVIGATION_BAR_LOADING = "hideNavigationBarLoading";
  6155. const API_PAGE_SCROLL_TO = "pageScrollTo";
  6156. const PageScrollToProtocol = {
  6157. scrollTop: Number,
  6158. selector: String,
  6159. duration: Number
  6160. };
  6161. const PageScrollToOptions = {
  6162. formatArgs: {
  6163. duration: 300
  6164. }
  6165. };
  6166. const API_SHOW_ACTION_SHEET = "showActionSheet";
  6167. const ShowActionSheetProtocol = {
  6168. itemList: {
  6169. type: Array,
  6170. required: true
  6171. },
  6172. title: String,
  6173. itemColor: String,
  6174. popover: Object
  6175. };
  6176. const ShowActionSheetOptions = {
  6177. formatArgs: {
  6178. itemColor: "#000"
  6179. }
  6180. };
  6181. const API_SHOW_LOADING = "showLoading";
  6182. const ShowLoadingProtocol = {
  6183. title: String,
  6184. mask: Boolean
  6185. };
  6186. const ShowLoadingOptions = {
  6187. formatArgs: {
  6188. title: "",
  6189. mask: false
  6190. }
  6191. };
  6192. const API_SHOW_MODAL = "showModal";
  6193. const ShowModalProtocol = {
  6194. title: String,
  6195. content: String,
  6196. showCancel: Boolean,
  6197. cancelText: String,
  6198. cancelColor: String,
  6199. confirmText: String,
  6200. confirmColor: String
  6201. };
  6202. const ShowModalOptions = {
  6203. beforeInvoke() {
  6204. initI18nShowModalMsgsOnce();
  6205. },
  6206. formatArgs: {
  6207. title: "",
  6208. content: "",
  6209. placeholderText: "",
  6210. showCancel: true,
  6211. editable: false,
  6212. cancelText(_value, params) {
  6213. if (!hasOwn(params, "cancelText")) {
  6214. const { t: t2 } = useI18n();
  6215. params.cancelText = t2("uni.showModal.cancel");
  6216. }
  6217. },
  6218. cancelColor: "#000",
  6219. confirmText(_value, params) {
  6220. if (!hasOwn(params, "confirmText")) {
  6221. const { t: t2 } = useI18n();
  6222. params.confirmText = t2("uni.showModal.confirm");
  6223. }
  6224. },
  6225. confirmColor: PRIMARY_COLOR
  6226. }
  6227. };
  6228. const API_SHOW_TOAST = "showToast";
  6229. const SHOW_TOAST_ICON = [
  6230. "success",
  6231. "loading",
  6232. "none",
  6233. "error"
  6234. ];
  6235. const ShowToastProtocol = {
  6236. title: String,
  6237. icon: String,
  6238. image: String,
  6239. duration: Number,
  6240. mask: Boolean
  6241. };
  6242. const ShowToastOptions = {
  6243. formatArgs: {
  6244. title: "",
  6245. icon(type, params) {
  6246. params.icon = elemInArray(type, SHOW_TOAST_ICON);
  6247. },
  6248. image(value, params) {
  6249. if (value) {
  6250. params.image = getRealPath(value);
  6251. } else {
  6252. params.image = "";
  6253. }
  6254. },
  6255. duration: 1500,
  6256. mask: false
  6257. }
  6258. };
  6259. const API_START_PULL_DOWN_REFRESH = "startPullDownRefresh";
  6260. const API_STOP_PULL_DOWN_REFRESH = "stopPullDownRefresh";
  6261. const IndexProtocol = {
  6262. index: {
  6263. type: Number,
  6264. required: true
  6265. }
  6266. };
  6267. const IndexOptions = {
  6268. beforeInvoke() {
  6269. const pageMeta = getCurrentPageMeta();
  6270. if (pageMeta && !pageMeta.isTabBar) {
  6271. return "not TabBar page";
  6272. }
  6273. },
  6274. formatArgs: {
  6275. index(value) {
  6276. if (!__uniConfig.tabBar.list[value]) {
  6277. return "tabbar item not found";
  6278. }
  6279. }
  6280. }
  6281. };
  6282. const API_SET_TAB_BAR_ITEM = "setTabBarItem";
  6283. const SetTabBarItemProtocol = /* @__PURE__ */ extend(
  6284. {
  6285. text: String,
  6286. iconPath: String,
  6287. selectedIconPath: String,
  6288. pagePath: String
  6289. },
  6290. IndexProtocol
  6291. );
  6292. const SetTabBarItemOptions = {
  6293. beforeInvoke: IndexOptions.beforeInvoke,
  6294. formatArgs: /* @__PURE__ */ extend(
  6295. {
  6296. pagePath(value, params) {
  6297. if (value) {
  6298. params.pagePath = removeLeadingSlash(value);
  6299. }
  6300. }
  6301. },
  6302. IndexOptions.formatArgs
  6303. )
  6304. };
  6305. const API_SET_TAB_BAR_STYLE = "setTabBarStyle";
  6306. const SetTabBarStyleProtocol = {
  6307. color: String,
  6308. selectedColor: String,
  6309. backgroundColor: String,
  6310. backgroundImage: String,
  6311. backgroundRepeat: String,
  6312. borderStyle: String
  6313. };
  6314. const GRADIENT_RE = /^(linear|radial)-gradient\(.+?\);?$/;
  6315. const SetTabBarStyleOptions = {
  6316. beforeInvoke: IndexOptions.beforeInvoke,
  6317. formatArgs: {
  6318. backgroundImage(value, params) {
  6319. if (value && !GRADIENT_RE.test(value)) {
  6320. params.backgroundImage = getRealPath(value);
  6321. }
  6322. },
  6323. borderStyle(value, params) {
  6324. if (value) {
  6325. params.borderStyle = value === "white" ? "white" : "black";
  6326. }
  6327. }
  6328. }
  6329. };
  6330. const API_HIDE_TAB_BAR = "hideTabBar";
  6331. const HideTabBarProtocol = {
  6332. animation: Boolean
  6333. };
  6334. const API_SHOW_TAB_BAR = "showTabBar";
  6335. const ShowTabBarProtocol = HideTabBarProtocol;
  6336. const API_HIDE_TAB_BAR_RED_DOT = "hideTabBarRedDot";
  6337. const HideTabBarRedDotProtocol = IndexProtocol;
  6338. const HideTabBarRedDotOptions = IndexOptions;
  6339. const API_SHOW_TAB_BAR_RED_DOT = "showTabBarRedDot";
  6340. const ShowTabBarRedDotProtocol = IndexProtocol;
  6341. const ShowTabBarRedDotOptions = IndexOptions;
  6342. const API_REMOVE_TAB_BAR_BADGE = "removeTabBarBadge";
  6343. const RemoveTabBarBadgeProtocol = IndexProtocol;
  6344. const RemoveTabBarBadgeOptions = IndexOptions;
  6345. const API_SET_TAB_BAR_BADGE = "setTabBarBadge";
  6346. const SetTabBarBadgeProtocol = /* @__PURE__ */ extend(
  6347. {
  6348. text: {
  6349. type: String,
  6350. required: true
  6351. }
  6352. },
  6353. IndexProtocol
  6354. );
  6355. const SetTabBarBadgeOptions = {
  6356. beforeInvoke: IndexOptions.beforeInvoke,
  6357. formatArgs: /* @__PURE__ */ extend(
  6358. {
  6359. text(value, params) {
  6360. if (getLen(value) >= 4) {
  6361. params.text = "...";
  6362. }
  6363. }
  6364. },
  6365. IndexOptions.formatArgs
  6366. )
  6367. };
  6368. const initIntersectionObserverPolyfill = function() {
  6369. if (typeof window !== "object") {
  6370. return;
  6371. }
  6372. if ("IntersectionObserver" in window && "IntersectionObserverEntry" in window && "intersectionRatio" in window.IntersectionObserverEntry.prototype) {
  6373. if (!("isIntersecting" in window.IntersectionObserverEntry.prototype)) {
  6374. Object.defineProperty(
  6375. window.IntersectionObserverEntry.prototype,
  6376. "isIntersecting",
  6377. {
  6378. get: function() {
  6379. return this.intersectionRatio > 0;
  6380. }
  6381. }
  6382. );
  6383. }
  6384. return;
  6385. }
  6386. function getFrameElement(doc) {
  6387. try {
  6388. return doc.defaultView && doc.defaultView.frameElement || null;
  6389. } catch (e2) {
  6390. return null;
  6391. }
  6392. }
  6393. var document2 = function(startDoc) {
  6394. var doc = startDoc;
  6395. var frame = getFrameElement(doc);
  6396. while (frame) {
  6397. doc = frame.ownerDocument;
  6398. frame = getFrameElement(doc);
  6399. }
  6400. return doc;
  6401. }(window.document);
  6402. var registry = [];
  6403. var crossOriginUpdater = null;
  6404. var crossOriginRect = null;
  6405. function IntersectionObserverEntry(entry) {
  6406. this.time = entry.time;
  6407. this.target = entry.target;
  6408. this.rootBounds = ensureDOMRect(entry.rootBounds);
  6409. this.boundingClientRect = ensureDOMRect(entry.boundingClientRect);
  6410. this.intersectionRect = ensureDOMRect(
  6411. entry.intersectionRect || getEmptyRect()
  6412. );
  6413. this.isIntersecting = !!entry.intersectionRect;
  6414. var targetRect = this.boundingClientRect;
  6415. var targetArea = targetRect.width * targetRect.height;
  6416. var intersectionRect = this.intersectionRect;
  6417. var intersectionArea = intersectionRect.width * intersectionRect.height;
  6418. if (targetArea) {
  6419. this.intersectionRatio = Number(
  6420. (intersectionArea / targetArea).toFixed(4)
  6421. );
  6422. } else {
  6423. this.intersectionRatio = this.isIntersecting ? 1 : 0;
  6424. }
  6425. }
  6426. function IntersectionObserver2(callback, opt_options) {
  6427. var options = opt_options || {};
  6428. if (typeof callback != "function") {
  6429. throw new Error("callback must be a function");
  6430. }
  6431. if (options.root && options.root.nodeType != 1 && options.root.nodeType != 9) {
  6432. throw new Error("root must be a Document or Element");
  6433. }
  6434. this._checkForIntersections = throttle2(
  6435. this._checkForIntersections.bind(this),
  6436. this.THROTTLE_TIMEOUT
  6437. );
  6438. this._callback = callback;
  6439. this._observationTargets = [];
  6440. this._queuedEntries = [];
  6441. this._rootMarginValues = this._parseRootMargin(options.rootMargin);
  6442. this.thresholds = this._initThresholds(options.threshold);
  6443. this.root = options.root || null;
  6444. this.rootMargin = this._rootMarginValues.map(function(margin) {
  6445. return margin.value + margin.unit;
  6446. }).join(" ");
  6447. this._monitoringDocuments = [];
  6448. this._monitoringUnsubscribes = [];
  6449. }
  6450. IntersectionObserver2.prototype.THROTTLE_TIMEOUT = 100;
  6451. IntersectionObserver2.prototype.POLL_INTERVAL = null;
  6452. IntersectionObserver2.prototype.USE_MUTATION_OBSERVER = true;
  6453. IntersectionObserver2._setupCrossOriginUpdater = function() {
  6454. if (!crossOriginUpdater) {
  6455. crossOriginUpdater = function(boundingClientRect, intersectionRect) {
  6456. if (!boundingClientRect || !intersectionRect) {
  6457. crossOriginRect = getEmptyRect();
  6458. } else {
  6459. crossOriginRect = convertFromParentRect(
  6460. boundingClientRect,
  6461. intersectionRect
  6462. );
  6463. }
  6464. registry.forEach(function(observer) {
  6465. observer._checkForIntersections();
  6466. });
  6467. };
  6468. }
  6469. return crossOriginUpdater;
  6470. };
  6471. IntersectionObserver2._resetCrossOriginUpdater = function() {
  6472. crossOriginUpdater = null;
  6473. crossOriginRect = null;
  6474. };
  6475. IntersectionObserver2.prototype.observe = function(target) {
  6476. var isTargetAlreadyObserved = this._observationTargets.some(function(item) {
  6477. return item.element == target;
  6478. });
  6479. if (isTargetAlreadyObserved) {
  6480. return;
  6481. }
  6482. if (!(target && target.nodeType == 1)) {
  6483. throw new Error("target must be an Element");
  6484. }
  6485. this._registerInstance();
  6486. this._observationTargets.push({ element: target, entry: null });
  6487. this._monitorIntersections(target.ownerDocument);
  6488. this._checkForIntersections();
  6489. };
  6490. IntersectionObserver2.prototype.unobserve = function(target) {
  6491. this._observationTargets = this._observationTargets.filter(function(item) {
  6492. return item.element != target;
  6493. });
  6494. this._unmonitorIntersections(target.ownerDocument);
  6495. if (this._observationTargets.length == 0) {
  6496. this._unregisterInstance();
  6497. }
  6498. };
  6499. IntersectionObserver2.prototype.disconnect = function() {
  6500. this._observationTargets = [];
  6501. this._unmonitorAllIntersections();
  6502. this._unregisterInstance();
  6503. };
  6504. IntersectionObserver2.prototype.takeRecords = function() {
  6505. var records = this._queuedEntries.slice();
  6506. this._queuedEntries = [];
  6507. return records;
  6508. };
  6509. IntersectionObserver2.prototype._initThresholds = function(opt_threshold) {
  6510. var threshold = opt_threshold || [0];
  6511. if (!Array.isArray(threshold))
  6512. threshold = [threshold];
  6513. return threshold.sort().filter(function(t2, i, a2) {
  6514. if (typeof t2 != "number" || isNaN(t2) || t2 < 0 || t2 > 1) {
  6515. throw new Error(
  6516. "threshold must be a number between 0 and 1 inclusively"
  6517. );
  6518. }
  6519. return t2 !== a2[i - 1];
  6520. });
  6521. };
  6522. IntersectionObserver2.prototype._parseRootMargin = function(opt_rootMargin) {
  6523. var marginString = opt_rootMargin || "0px";
  6524. var margins = marginString.split(/\s+/).map(function(margin) {
  6525. var parts = /^(-?\d*\.?\d+)(px|%)$/.exec(margin);
  6526. if (!parts) {
  6527. throw new Error("rootMargin must be specified in pixels or percent");
  6528. }
  6529. return { value: parseFloat(parts[1]), unit: parts[2] };
  6530. });
  6531. margins[1] = margins[1] || margins[0];
  6532. margins[2] = margins[2] || margins[0];
  6533. margins[3] = margins[3] || margins[1];
  6534. return margins;
  6535. };
  6536. IntersectionObserver2.prototype._monitorIntersections = function(doc) {
  6537. var win = doc.defaultView;
  6538. if (!win) {
  6539. return;
  6540. }
  6541. if (this._monitoringDocuments.indexOf(doc) != -1) {
  6542. return;
  6543. }
  6544. var callback = this._checkForIntersections;
  6545. var monitoringInterval = null;
  6546. var domObserver = null;
  6547. if (this.POLL_INTERVAL) {
  6548. monitoringInterval = win.setInterval(callback, this.POLL_INTERVAL);
  6549. } else {
  6550. addEvent(win, "resize", callback, true);
  6551. addEvent(doc, "scroll", callback, true);
  6552. if (this.USE_MUTATION_OBSERVER && "MutationObserver" in win) {
  6553. domObserver = new win.MutationObserver(callback);
  6554. domObserver.observe(doc, {
  6555. attributes: true,
  6556. childList: true,
  6557. characterData: true,
  6558. subtree: true
  6559. });
  6560. }
  6561. }
  6562. this._monitoringDocuments.push(doc);
  6563. this._monitoringUnsubscribes.push(function() {
  6564. var win2 = doc.defaultView;
  6565. if (win2) {
  6566. if (monitoringInterval) {
  6567. win2.clearInterval(monitoringInterval);
  6568. }
  6569. removeEvent(win2, "resize", callback, true);
  6570. }
  6571. removeEvent(doc, "scroll", callback, true);
  6572. if (domObserver) {
  6573. domObserver.disconnect();
  6574. }
  6575. });
  6576. var rootDoc = this.root && (this.root.ownerDocument || this.root) || document2;
  6577. if (doc != rootDoc) {
  6578. var frame = getFrameElement(doc);
  6579. if (frame) {
  6580. this._monitorIntersections(frame.ownerDocument);
  6581. }
  6582. }
  6583. };
  6584. IntersectionObserver2.prototype._unmonitorIntersections = function(doc) {
  6585. var index2 = this._monitoringDocuments.indexOf(doc);
  6586. if (index2 == -1) {
  6587. return;
  6588. }
  6589. var rootDoc = this.root && (this.root.ownerDocument || this.root) || document2;
  6590. var hasDependentTargets = this._observationTargets.some(function(item) {
  6591. var itemDoc = item.element.ownerDocument;
  6592. if (itemDoc == doc) {
  6593. return true;
  6594. }
  6595. while (itemDoc && itemDoc != rootDoc) {
  6596. var frame2 = getFrameElement(itemDoc);
  6597. itemDoc = frame2 && frame2.ownerDocument;
  6598. if (itemDoc == doc) {
  6599. return true;
  6600. }
  6601. }
  6602. return false;
  6603. });
  6604. if (hasDependentTargets) {
  6605. return;
  6606. }
  6607. var unsubscribe = this._monitoringUnsubscribes[index2];
  6608. this._monitoringDocuments.splice(index2, 1);
  6609. this._monitoringUnsubscribes.splice(index2, 1);
  6610. unsubscribe();
  6611. if (doc != rootDoc) {
  6612. var frame = getFrameElement(doc);
  6613. if (frame) {
  6614. this._unmonitorIntersections(frame.ownerDocument);
  6615. }
  6616. }
  6617. };
  6618. IntersectionObserver2.prototype._unmonitorAllIntersections = function() {
  6619. var unsubscribes = this._monitoringUnsubscribes.slice(0);
  6620. this._monitoringDocuments.length = 0;
  6621. this._monitoringUnsubscribes.length = 0;
  6622. for (var i = 0; i < unsubscribes.length; i++) {
  6623. unsubscribes[i]();
  6624. }
  6625. };
  6626. IntersectionObserver2.prototype._checkForIntersections = function() {
  6627. if (!this.root && crossOriginUpdater && !crossOriginRect) {
  6628. return;
  6629. }
  6630. var rootIsInDom = this._rootIsInDom();
  6631. var rootRect = rootIsInDom ? this._getRootRect() : getEmptyRect();
  6632. this._observationTargets.forEach(function(item) {
  6633. var target = item.element;
  6634. var targetRect = getBoundingClientRect(target);
  6635. var rootContainsTarget = this._rootContainsTarget(target);
  6636. var oldEntry = item.entry;
  6637. var intersectionRect = rootIsInDom && rootContainsTarget && this._computeTargetAndRootIntersection(target, targetRect, rootRect);
  6638. var rootBounds = null;
  6639. if (!this._rootContainsTarget(target)) {
  6640. rootBounds = getEmptyRect();
  6641. } else if (!crossOriginUpdater || this.root) {
  6642. rootBounds = rootRect;
  6643. }
  6644. var newEntry = item.entry = new IntersectionObserverEntry({
  6645. time: now(),
  6646. target,
  6647. boundingClientRect: targetRect,
  6648. rootBounds,
  6649. intersectionRect
  6650. });
  6651. if (!oldEntry) {
  6652. this._queuedEntries.push(newEntry);
  6653. } else if (rootIsInDom && rootContainsTarget) {
  6654. if (this._hasCrossedThreshold(oldEntry, newEntry)) {
  6655. this._queuedEntries.push(newEntry);
  6656. }
  6657. } else {
  6658. if (oldEntry && oldEntry.isIntersecting) {
  6659. this._queuedEntries.push(newEntry);
  6660. }
  6661. }
  6662. }, this);
  6663. if (this._queuedEntries.length) {
  6664. this._callback(this.takeRecords(), this);
  6665. }
  6666. };
  6667. IntersectionObserver2.prototype._computeTargetAndRootIntersection = function(target, targetRect, rootRect) {
  6668. if (window.getComputedStyle(target).display == "none")
  6669. return;
  6670. var intersectionRect = targetRect;
  6671. var parent = getParentNode(target);
  6672. var atRoot = false;
  6673. while (!atRoot && parent) {
  6674. var parentRect = null;
  6675. var parentComputedStyle = parent.nodeType == 1 ? window.getComputedStyle(parent) : {};
  6676. if (parentComputedStyle.display == "none")
  6677. return null;
  6678. if (parent == this.root || parent.nodeType == /* DOCUMENT */
  6679. 9) {
  6680. atRoot = true;
  6681. if (parent == this.root || parent == document2) {
  6682. if (crossOriginUpdater && !this.root) {
  6683. if (!crossOriginRect || crossOriginRect.width == 0 && crossOriginRect.height == 0) {
  6684. parent = null;
  6685. parentRect = null;
  6686. intersectionRect = null;
  6687. } else {
  6688. parentRect = crossOriginRect;
  6689. }
  6690. } else {
  6691. parentRect = rootRect;
  6692. }
  6693. } else {
  6694. var frame = getParentNode(parent);
  6695. var frameRect = frame && getBoundingClientRect(frame);
  6696. var frameIntersect = frame && this._computeTargetAndRootIntersection(frame, frameRect, rootRect);
  6697. if (frameRect && frameIntersect) {
  6698. parent = frame;
  6699. parentRect = convertFromParentRect(frameRect, frameIntersect);
  6700. } else {
  6701. parent = null;
  6702. intersectionRect = null;
  6703. }
  6704. }
  6705. } else {
  6706. var doc = parent.ownerDocument;
  6707. if (parent != doc.body && parent != doc.documentElement && parentComputedStyle.overflow != "visible") {
  6708. parentRect = getBoundingClientRect(parent);
  6709. }
  6710. }
  6711. if (parentRect) {
  6712. intersectionRect = computeRectIntersection(parentRect, intersectionRect);
  6713. }
  6714. if (!intersectionRect)
  6715. break;
  6716. parent = parent && getParentNode(parent);
  6717. }
  6718. return intersectionRect;
  6719. };
  6720. IntersectionObserver2.prototype._getRootRect = function() {
  6721. var rootRect;
  6722. if (this.root && !isDoc(this.root)) {
  6723. rootRect = getBoundingClientRect(this.root);
  6724. } else {
  6725. var doc = isDoc(this.root) ? this.root : document2;
  6726. var html = doc.documentElement;
  6727. var body = doc.body;
  6728. rootRect = {
  6729. top: 0,
  6730. left: 0,
  6731. right: html.clientWidth || body.clientWidth,
  6732. width: html.clientWidth || body.clientWidth,
  6733. bottom: html.clientHeight || body.clientHeight,
  6734. height: html.clientHeight || body.clientHeight
  6735. };
  6736. }
  6737. return this._expandRectByRootMargin(rootRect);
  6738. };
  6739. IntersectionObserver2.prototype._expandRectByRootMargin = function(rect) {
  6740. var margins = this._rootMarginValues.map(function(margin, i) {
  6741. return margin.unit == "px" ? margin.value : margin.value * (i % 2 ? rect.width : rect.height) / 100;
  6742. });
  6743. var newRect = {
  6744. top: rect.top - margins[0],
  6745. right: rect.right + margins[1],
  6746. bottom: rect.bottom + margins[2],
  6747. left: rect.left - margins[3]
  6748. };
  6749. newRect.width = newRect.right - newRect.left;
  6750. newRect.height = newRect.bottom - newRect.top;
  6751. return newRect;
  6752. };
  6753. IntersectionObserver2.prototype._hasCrossedThreshold = function(oldEntry, newEntry) {
  6754. var oldRatio = oldEntry && oldEntry.isIntersecting ? oldEntry.intersectionRatio || 0 : -1;
  6755. var newRatio = newEntry.isIntersecting ? newEntry.intersectionRatio || 0 : -1;
  6756. if (oldRatio === newRatio)
  6757. return;
  6758. for (var i = 0; i < this.thresholds.length; i++) {
  6759. var threshold = this.thresholds[i];
  6760. if (threshold == oldRatio || threshold == newRatio || threshold < oldRatio !== threshold < newRatio) {
  6761. return true;
  6762. }
  6763. }
  6764. };
  6765. IntersectionObserver2.prototype._rootIsInDom = function() {
  6766. return !this.root || containsDeep(document2, this.root);
  6767. };
  6768. IntersectionObserver2.prototype._rootContainsTarget = function(target) {
  6769. var rootDoc = this.root && (this.root.ownerDocument || this.root) || document2;
  6770. return containsDeep(rootDoc, target) && (!this.root || rootDoc == target.ownerDocument);
  6771. };
  6772. IntersectionObserver2.prototype._registerInstance = function() {
  6773. if (registry.indexOf(this) < 0) {
  6774. registry.push(this);
  6775. }
  6776. };
  6777. IntersectionObserver2.prototype._unregisterInstance = function() {
  6778. var index2 = registry.indexOf(this);
  6779. if (index2 != -1)
  6780. registry.splice(index2, 1);
  6781. };
  6782. function now() {
  6783. return window.performance && performance.now && performance.now();
  6784. }
  6785. function throttle2(fn, timeout) {
  6786. var timer = null;
  6787. return function() {
  6788. if (!timer) {
  6789. timer = setTimeout(function() {
  6790. fn();
  6791. timer = null;
  6792. }, timeout);
  6793. }
  6794. };
  6795. }
  6796. function addEvent(node, event, fn, opt_useCapture) {
  6797. if (typeof node.addEventListener == "function") {
  6798. node.addEventListener(event, fn, opt_useCapture || false);
  6799. } else if (typeof node.attachEvent == "function") {
  6800. node.attachEvent("on" + event, fn);
  6801. }
  6802. }
  6803. function removeEvent(node, event, fn, opt_useCapture) {
  6804. if (typeof node.removeEventListener == "function") {
  6805. node.removeEventListener(event, fn, opt_useCapture || false);
  6806. } else if (typeof node.detatchEvent == "function") {
  6807. node.detatchEvent("on" + event, fn);
  6808. }
  6809. }
  6810. function computeRectIntersection(rect1, rect2) {
  6811. var top = Math.max(rect1.top, rect2.top);
  6812. var bottom = Math.min(rect1.bottom, rect2.bottom);
  6813. var left = Math.max(rect1.left, rect2.left);
  6814. var right = Math.min(rect1.right, rect2.right);
  6815. var width = right - left;
  6816. var height = bottom - top;
  6817. return width >= 0 && height >= 0 && {
  6818. top,
  6819. bottom,
  6820. left,
  6821. right,
  6822. width,
  6823. height
  6824. } || null;
  6825. }
  6826. function getBoundingClientRect(el) {
  6827. var rect;
  6828. try {
  6829. rect = el.getBoundingClientRect();
  6830. } catch (err) {
  6831. }
  6832. if (!rect)
  6833. return getEmptyRect();
  6834. if (!(rect.width && rect.height)) {
  6835. rect = {
  6836. top: rect.top,
  6837. right: rect.right,
  6838. bottom: rect.bottom,
  6839. left: rect.left,
  6840. width: rect.right - rect.left,
  6841. height: rect.bottom - rect.top
  6842. };
  6843. }
  6844. return rect;
  6845. }
  6846. function getEmptyRect() {
  6847. return {
  6848. top: 0,
  6849. bottom: 0,
  6850. left: 0,
  6851. right: 0,
  6852. width: 0,
  6853. height: 0
  6854. };
  6855. }
  6856. function ensureDOMRect(rect) {
  6857. if (!rect || "x" in rect) {
  6858. return rect;
  6859. }
  6860. return {
  6861. top: rect.top,
  6862. y: rect.top,
  6863. bottom: rect.bottom,
  6864. left: rect.left,
  6865. x: rect.left,
  6866. right: rect.right,
  6867. width: rect.width,
  6868. height: rect.height
  6869. };
  6870. }
  6871. function convertFromParentRect(parentBoundingRect, parentIntersectionRect) {
  6872. var top = parentIntersectionRect.top - parentBoundingRect.top;
  6873. var left = parentIntersectionRect.left - parentBoundingRect.left;
  6874. return {
  6875. top,
  6876. left,
  6877. height: parentIntersectionRect.height,
  6878. width: parentIntersectionRect.width,
  6879. bottom: top + parentIntersectionRect.height,
  6880. right: left + parentIntersectionRect.width
  6881. };
  6882. }
  6883. function containsDeep(parent, child) {
  6884. var node = child;
  6885. while (node) {
  6886. if (node == parent)
  6887. return true;
  6888. node = getParentNode(node);
  6889. }
  6890. return false;
  6891. }
  6892. function getParentNode(node) {
  6893. var parent = node.parentNode;
  6894. if (node.nodeType == /* DOCUMENT */
  6895. 9 && node != document2) {
  6896. return getFrameElement(node);
  6897. }
  6898. if (parent && parent.assignedSlot) {
  6899. parent = parent.assignedSlot.parentNode;
  6900. }
  6901. if (parent && parent.nodeType == 11 && parent.host) {
  6902. return parent.host;
  6903. }
  6904. return parent;
  6905. }
  6906. function isDoc(node) {
  6907. return node && node.nodeType === 9;
  6908. }
  6909. window.IntersectionObserver = IntersectionObserver2;
  6910. window.IntersectionObserverEntry = IntersectionObserverEntry;
  6911. };
  6912. function normalizeRect(rect) {
  6913. const { bottom, height, left, right, top, width } = rect || {};
  6914. return {
  6915. bottom,
  6916. height,
  6917. left,
  6918. right,
  6919. top,
  6920. width
  6921. };
  6922. }
  6923. function rectifyIntersectionRatio(entrie) {
  6924. const {
  6925. intersectionRatio,
  6926. boundingClientRect: { height: overAllHeight, width: overAllWidth },
  6927. intersectionRect: { height: intersectionHeight, width: intersectionWidth }
  6928. } = entrie;
  6929. if (intersectionRatio !== 0)
  6930. return intersectionRatio;
  6931. return intersectionHeight === overAllHeight ? intersectionWidth / overAllWidth : intersectionHeight / overAllHeight;
  6932. }
  6933. function requestComponentObserver($el, options, callback) {
  6934. initIntersectionObserverPolyfill();
  6935. const root = options.relativeToSelector ? $el.querySelector(options.relativeToSelector) : null;
  6936. const intersectionObserver = new IntersectionObserver(
  6937. (entries2) => {
  6938. entries2.forEach((entrie) => {
  6939. callback({
  6940. intersectionRatio: rectifyIntersectionRatio(entrie),
  6941. intersectionRect: normalizeRect(entrie.intersectionRect),
  6942. boundingClientRect: normalizeRect(entrie.boundingClientRect),
  6943. relativeRect: normalizeRect(entrie.rootBounds),
  6944. time: Date.now(),
  6945. dataset: getCustomDataset(entrie.target),
  6946. id: entrie.target.id
  6947. });
  6948. });
  6949. },
  6950. {
  6951. root,
  6952. rootMargin: options.rootMargin,
  6953. threshold: options.thresholds
  6954. }
  6955. );
  6956. if (options.observeAll) {
  6957. intersectionObserver.USE_MUTATION_OBSERVER = true;
  6958. const nodeList = $el.querySelectorAll(options.selector);
  6959. for (let i = 0; i < nodeList.length; i++) {
  6960. intersectionObserver.observe(nodeList[i]);
  6961. }
  6962. } else {
  6963. intersectionObserver.USE_MUTATION_OBSERVER = false;
  6964. const el = $el.querySelector(options.selector);
  6965. if (!el) {
  6966. console.warn(
  6967. `Node ${options.selector} is not found. Intersection observer will not trigger.`
  6968. );
  6969. } else {
  6970. intersectionObserver.observe(el);
  6971. }
  6972. }
  6973. return intersectionObserver;
  6974. }
  6975. function addIntersectionObserver({ reqId, component, options, callback }, _pageId) {
  6976. const $el = findElem(component);
  6977. ($el.__io || ($el.__io = {}))[reqId] = requestComponentObserver(
  6978. $el,
  6979. options,
  6980. callback
  6981. );
  6982. }
  6983. function removeIntersectionObserver({ reqId, component }, _pageId) {
  6984. const $el = findElem(component);
  6985. const intersectionObserver = $el.__io && $el.__io[reqId];
  6986. if (intersectionObserver) {
  6987. intersectionObserver.disconnect();
  6988. delete $el.__io[reqId];
  6989. }
  6990. }
  6991. let mediaQueryObservers = {};
  6992. let listeners = {};
  6993. function handleMediaQueryStr($props) {
  6994. const mediaQueryArr = [];
  6995. const propsMenu = [
  6996. "width",
  6997. "minWidth",
  6998. "maxWidth",
  6999. "height",
  7000. "minHeight",
  7001. "maxHeight",
  7002. "orientation"
  7003. ];
  7004. for (const item of propsMenu) {
  7005. if (item !== "orientation" && $props[item] && Number($props[item] >= 0)) {
  7006. mediaQueryArr.push(
  7007. `(${humpToLine(item)}: ${Number(
  7008. $props[item]
  7009. )}px)`
  7010. );
  7011. }
  7012. if (item === "orientation" && $props[item]) {
  7013. mediaQueryArr.push(`(${humpToLine(item)}: ${$props[item]})`);
  7014. }
  7015. }
  7016. const mediaQueryStr = mediaQueryArr.join(" and ");
  7017. return mediaQueryStr;
  7018. }
  7019. function humpToLine(name) {
  7020. return name.replace(/([A-Z])/g, "-$1").toLowerCase();
  7021. }
  7022. function addMediaQueryObserver({ reqId, component, options, callback }, _pageId) {
  7023. const mediaQueryObserver = mediaQueryObservers[reqId] = window.matchMedia(
  7024. handleMediaQueryStr(options)
  7025. );
  7026. const listener2 = listeners[reqId] = (observer) => callback(observer.matches);
  7027. listener2(mediaQueryObserver);
  7028. mediaQueryObserver.addListener(listener2);
  7029. }
  7030. function removeMediaQueryObserver({ reqId, component }, _pageId) {
  7031. const listener2 = listeners[reqId];
  7032. const mediaQueryObserver = mediaQueryObservers[reqId];
  7033. if (mediaQueryObserver) {
  7034. mediaQueryObserver.removeListener(listener2);
  7035. delete listeners[reqId];
  7036. delete mediaQueryObservers[reqId];
  7037. }
  7038. }
  7039. function saveImage(base64, dirname, callback) {
  7040. callback(null, base64);
  7041. }
  7042. const TEMP_PATH = "";
  7043. const files = {};
  7044. function urlToFile(url, local) {
  7045. const file = files[url];
  7046. if (file) {
  7047. return Promise.resolve(file);
  7048. }
  7049. if (/^data:[a-z-]+\/[a-z-]+;base64,/.test(url)) {
  7050. return Promise.resolve(base64ToFile(url));
  7051. }
  7052. if (local) {
  7053. return Promise.reject(new Error("not find"));
  7054. }
  7055. return new Promise((resolve, reject) => {
  7056. const xhr = new XMLHttpRequest();
  7057. xhr.open("GET", url, true);
  7058. xhr.responseType = "blob";
  7059. xhr.onload = function() {
  7060. resolve(this.response);
  7061. };
  7062. xhr.onerror = reject;
  7063. xhr.send();
  7064. });
  7065. }
  7066. function base64ToFile(base64) {
  7067. const base64Array = base64.split(",");
  7068. const res = base64Array[0].match(/:(.*?);/);
  7069. const type = res ? res[1] : "";
  7070. const str = atob(base64Array[1]);
  7071. let n = str.length;
  7072. const array = new Uint8Array(n);
  7073. while (n--) {
  7074. array[n] = str.charCodeAt(n);
  7075. }
  7076. return blobToFile(array, type);
  7077. }
  7078. function getExtname(type) {
  7079. const extname = type.split("/")[1];
  7080. return extname ? `.${extname}` : "";
  7081. }
  7082. function getFileName(url) {
  7083. url = url.split("#")[0].split("?")[0];
  7084. const array = url.split("/");
  7085. return array[array.length - 1];
  7086. }
  7087. function blobToFile(blob, type) {
  7088. let file;
  7089. if (blob instanceof File) {
  7090. file = blob;
  7091. } else {
  7092. type = type || blob.type || "";
  7093. const filename = `${Date.now()}${getExtname(type)}`;
  7094. try {
  7095. file = new File([blob], filename, { type });
  7096. } catch (error) {
  7097. blob = blob instanceof Blob ? blob : new Blob([blob], { type });
  7098. file = blob;
  7099. file.name = file.name || filename;
  7100. }
  7101. }
  7102. return file;
  7103. }
  7104. function fileToUrl(file) {
  7105. for (const key in files) {
  7106. if (hasOwn(files, key)) {
  7107. const oldFile = files[key];
  7108. if (oldFile === file) {
  7109. return key;
  7110. }
  7111. }
  7112. }
  7113. var url = (window.URL || window.webkitURL).createObjectURL(file);
  7114. files[url] = file;
  7115. return url;
  7116. }
  7117. function getSameOriginUrl(url) {
  7118. const a2 = document.createElement("a");
  7119. a2.href = url;
  7120. if (a2.origin === location.origin) {
  7121. return Promise.resolve(url);
  7122. }
  7123. return urlToFile(url).then(fileToUrl);
  7124. }
  7125. function revokeObjectURL(url) {
  7126. const URL = window.URL || window.webkitURL;
  7127. URL.revokeObjectURL(url);
  7128. delete files[url];
  7129. }
  7130. const launchOptions = /* @__PURE__ */ createLaunchOptions();
  7131. const enterOptions = /* @__PURE__ */ createLaunchOptions();
  7132. function getEnterOptions() {
  7133. return extend({}, enterOptions);
  7134. }
  7135. function getLaunchOptions() {
  7136. return extend({}, launchOptions);
  7137. }
  7138. function initLaunchOptions({
  7139. path,
  7140. query
  7141. }) {
  7142. extend(launchOptions, {
  7143. path,
  7144. query
  7145. });
  7146. extend(enterOptions, launchOptions);
  7147. return extend({}, launchOptions);
  7148. }
  7149. const inflateRaw = (...args) => {
  7150. };
  7151. const deflateRaw = (...args) => {
  7152. };
  7153. const ResizeSensor = /* @__PURE__ */ defineBuiltInComponent({
  7154. name: "ResizeSensor",
  7155. props: {
  7156. initial: {
  7157. type: Boolean,
  7158. default: false
  7159. }
  7160. },
  7161. emits: ["resize"],
  7162. setup(props2, {
  7163. emit: emit2
  7164. }) {
  7165. const rootRef = ref(null);
  7166. const reset = useResizeSensorReset(rootRef);
  7167. const update = useResizeSensorUpdate(rootRef, emit2, reset);
  7168. useResizeSensorLifecycle(rootRef, props2, update, reset);
  7169. return () => createVNode("uni-resize-sensor", {
  7170. "ref": rootRef,
  7171. "onAnimationstartOnce": update
  7172. }, [createVNode("div", {
  7173. "onScroll": update
  7174. }, [createVNode("div", null, null)], 40, ["onScroll"]), createVNode("div", {
  7175. "onScroll": update
  7176. }, [createVNode("div", null, null)], 40, ["onScroll"])], 40, ["onAnimationstartOnce"]);
  7177. }
  7178. });
  7179. function useResizeSensorUpdate(rootRef, emit2, reset) {
  7180. const size = reactive({
  7181. width: -1,
  7182. height: -1
  7183. });
  7184. watch(() => extend({}, size), (value) => emit2("resize", value));
  7185. return () => {
  7186. const rootEl = rootRef.value;
  7187. size.width = rootEl.offsetWidth;
  7188. size.height = rootEl.offsetHeight;
  7189. reset();
  7190. };
  7191. }
  7192. function useResizeSensorReset(rootRef) {
  7193. return () => {
  7194. const {
  7195. firstElementChild,
  7196. lastElementChild
  7197. } = rootRef.value;
  7198. firstElementChild.scrollLeft = 1e5;
  7199. firstElementChild.scrollTop = 1e5;
  7200. lastElementChild.scrollLeft = 1e5;
  7201. lastElementChild.scrollTop = 1e5;
  7202. };
  7203. }
  7204. function useResizeSensorLifecycle(rootRef, props2, update, reset) {
  7205. onActivated(reset);
  7206. onMounted(() => {
  7207. if (props2.initial) {
  7208. nextTick(update);
  7209. }
  7210. const rootEl = rootRef.value;
  7211. if (rootEl.offsetParent !== rootEl.parentElement) {
  7212. rootEl.parentElement.style.position = "relative";
  7213. }
  7214. if (!("AnimationEvent" in window)) {
  7215. reset();
  7216. }
  7217. });
  7218. }
  7219. const pixelRatio = /* @__PURE__ */ function() {
  7220. if (navigator.userAgent.includes("jsdom")) {
  7221. return 1;
  7222. }
  7223. const canvas = document.createElement("canvas");
  7224. canvas.height = canvas.width = 0;
  7225. const context = canvas.getContext("2d");
  7226. const backingStore = context.backingStorePixelRatio || context.webkitBackingStorePixelRatio || context.mozBackingStorePixelRatio || context.msBackingStorePixelRatio || context.oBackingStorePixelRatio || context.backingStorePixelRatio || 1;
  7227. return (window.devicePixelRatio || 1) / backingStore;
  7228. }();
  7229. function wrapper(canvas, hidpi = true) {
  7230. const pixel_ratio = hidpi ? pixelRatio : 1;
  7231. canvas.width = canvas.offsetWidth * pixel_ratio;
  7232. canvas.height = canvas.offsetHeight * pixel_ratio;
  7233. canvas.getContext("2d").__hidpi__ = hidpi;
  7234. canvas.getContext("2d").scale(pixel_ratio, pixel_ratio);
  7235. }
  7236. let isHidpi = false;
  7237. function initHidpi() {
  7238. if (isHidpi) {
  7239. return;
  7240. }
  7241. isHidpi = true;
  7242. return;
  7243. }
  7244. const initHidpiOnce = /* @__PURE__ */ once(() => {
  7245. return initHidpi();
  7246. });
  7247. function $getRealPath(src) {
  7248. return src ? getRealPath(src) : src;
  7249. }
  7250. function resolveColor(color) {
  7251. color = color.slice(0);
  7252. color[3] = color[3] / 255;
  7253. return "rgba(" + color.join(",") + ")";
  7254. }
  7255. function processTouches(rect, touches) {
  7256. Array.from(touches).forEach((touch) => {
  7257. touch.x = touch.clientX - rect.left;
  7258. touch.y = touch.clientY - rect.top;
  7259. });
  7260. }
  7261. let tempCanvas;
  7262. function getTempCanvas(width = 0, height = 0) {
  7263. if (!tempCanvas) {
  7264. tempCanvas = document.createElement("canvas");
  7265. }
  7266. tempCanvas.width = width;
  7267. tempCanvas.height = height;
  7268. return tempCanvas;
  7269. }
  7270. const props$x = {
  7271. canvasId: {
  7272. type: String,
  7273. default: ""
  7274. },
  7275. disableScroll: {
  7276. type: [Boolean, String],
  7277. default: false
  7278. },
  7279. hidpi: {
  7280. type: Boolean,
  7281. default: true
  7282. }
  7283. };
  7284. class UniCanvasElement extends UniElement {
  7285. }
  7286. const index$w = /* @__PURE__ */ defineBuiltInComponent({
  7287. inheritAttrs: false,
  7288. name: "Canvas",
  7289. compatConfig: {
  7290. MODE: 3
  7291. },
  7292. props: props$x,
  7293. computed: {
  7294. id() {
  7295. return this.canvasId;
  7296. }
  7297. },
  7298. rootElement: {
  7299. name: "uni-canvas",
  7300. class: UniCanvasElement
  7301. },
  7302. setup(props2, {
  7303. emit: emit2,
  7304. slots
  7305. }) {
  7306. initHidpiOnce();
  7307. const rootRef = ref(null);
  7308. const canvas = ref(null);
  7309. const sensor = ref(null);
  7310. const actionsWaiting = ref(false);
  7311. const trigger = useNativeEvent(emit2);
  7312. const {
  7313. $attrs,
  7314. $excludeAttrs,
  7315. $listeners
  7316. } = useAttrs({
  7317. excludeListeners: true
  7318. });
  7319. const {
  7320. _listeners
  7321. } = useListeners(props2, $listeners, trigger);
  7322. const {
  7323. _handleSubscribe,
  7324. _resize
  7325. } = useMethods(props2, canvas, actionsWaiting);
  7326. useSubscribe(_handleSubscribe, useContextInfo(props2.canvasId), true);
  7327. onMounted(() => {
  7328. _resize();
  7329. });
  7330. onMounted(() => {
  7331. const rootElement = rootRef.value;
  7332. rootElement.attachVmProps(props2);
  7333. });
  7334. return () => {
  7335. const {
  7336. canvasId,
  7337. disableScroll
  7338. } = props2;
  7339. return createVNode("uni-canvas", mergeProps({
  7340. "ref": rootRef,
  7341. "canvas-id": canvasId,
  7342. "disable-scroll": disableScroll
  7343. }, $attrs.value, $excludeAttrs.value, _listeners.value), [createVNode("canvas", {
  7344. "ref": canvas,
  7345. "class": "uni-canvas-canvas",
  7346. "width": "300",
  7347. "height": "150"
  7348. }, null, 512), createVNode("div", {
  7349. "style": "position: absolute;top: 0;left: 0;width: 100%;height: 100%;overflow: hidden;"
  7350. }, [slots.default && slots.default()]), createVNode(ResizeSensor, {
  7351. "ref": sensor,
  7352. "onResize": _resize
  7353. }, null, 8, ["onResize"])], 16, ["canvas-id", "disable-scroll"]);
  7354. };
  7355. }
  7356. });
  7357. function useListeners(props2, Listeners, trigger) {
  7358. const _listeners = computed(() => {
  7359. let events = ["onTouchstart", "onTouchmove", "onTouchend"];
  7360. let _$listeners = Listeners.value;
  7361. let $listeners = extend({}, (() => {
  7362. let obj = {};
  7363. for (const key in _$listeners) {
  7364. if (hasOwn(_$listeners, key)) {
  7365. const event = _$listeners[key];
  7366. obj[key] = event;
  7367. }
  7368. }
  7369. return obj;
  7370. })());
  7371. events.forEach((event) => {
  7372. let existing = $listeners[event];
  7373. let eventHandler = [];
  7374. if (existing) {
  7375. eventHandler.push(withWebEvent(($event) => {
  7376. const rect = $event.currentTarget.getBoundingClientRect();
  7377. processTouches(rect, $event.touches);
  7378. processTouches(rect, $event.changedTouches);
  7379. trigger(event.replace("on", "").toLocaleLowerCase(), $event);
  7380. }));
  7381. }
  7382. if (props2.disableScroll && event === "onTouchmove") {
  7383. eventHandler.push(onEventPrevent);
  7384. }
  7385. $listeners[event] = eventHandler;
  7386. });
  7387. return $listeners;
  7388. });
  7389. return {
  7390. _listeners
  7391. };
  7392. }
  7393. function useMethods(props2, canvasRef, actionsWaiting) {
  7394. let _actionsDefer = [];
  7395. let _images = {};
  7396. const _pixelRatio = computed(() => props2.hidpi ? pixelRatio : 1);
  7397. function _resize(size) {
  7398. let canvas = canvasRef.value;
  7399. var hasChanged = !size || canvas.width !== Math.floor(size.width * _pixelRatio.value) || canvas.height !== Math.floor(size.height * _pixelRatio.value);
  7400. if (!hasChanged)
  7401. return;
  7402. if (canvas.width > 0 && canvas.height > 0) {
  7403. let context = canvas.getContext("2d");
  7404. let imageData = context.getImageData(0, 0, canvas.width, canvas.height);
  7405. wrapper(canvas, props2.hidpi);
  7406. context.putImageData(imageData, 0, 0);
  7407. } else {
  7408. wrapper(canvas, props2.hidpi);
  7409. }
  7410. }
  7411. function actionsChanged({
  7412. actions,
  7413. reserve
  7414. }, resolve) {
  7415. if (!actions) {
  7416. return;
  7417. }
  7418. if (actionsWaiting.value) {
  7419. _actionsDefer.push([actions, reserve]);
  7420. return;
  7421. }
  7422. let canvas = canvasRef.value;
  7423. let c2d = canvas.getContext("2d");
  7424. if (!reserve) {
  7425. c2d.fillStyle = "#000000";
  7426. c2d.strokeStyle = "#000000";
  7427. c2d.shadowColor = "#000000";
  7428. c2d.shadowBlur = 0;
  7429. c2d.shadowOffsetX = 0;
  7430. c2d.shadowOffsetY = 0;
  7431. c2d.setTransform(1, 0, 0, 1, 0, 0);
  7432. c2d.clearRect(0, 0, canvas.width, canvas.height);
  7433. }
  7434. preloadImage(actions);
  7435. for (let index2 = 0; index2 < actions.length; index2++) {
  7436. const action = actions[index2];
  7437. let method = action.method;
  7438. const data = action.data;
  7439. const actionType = data[0];
  7440. if (/^set/.test(method) && method !== "setTransform") {
  7441. const method1 = method[3].toLowerCase() + method.slice(4);
  7442. let color;
  7443. if (method1 === "fillStyle" || method1 === "strokeStyle") {
  7444. if (actionType === "normal") {
  7445. color = resolveColor(data[1]);
  7446. } else if (actionType === "linear") {
  7447. const LinearGradient = c2d.createLinearGradient(...data[1]);
  7448. data[2].forEach(function(data2) {
  7449. const offset = data2[0];
  7450. const color2 = resolveColor(data2[1]);
  7451. LinearGradient.addColorStop(offset, color2);
  7452. });
  7453. color = LinearGradient;
  7454. } else if (actionType === "radial") {
  7455. let _data = data[1];
  7456. const x = _data[0];
  7457. const y = _data[1];
  7458. const r = _data[2];
  7459. const LinearGradient = c2d.createRadialGradient(x, y, 0, x, y, r);
  7460. data[2].forEach(function(data2) {
  7461. const offset = data2[0];
  7462. const color2 = resolveColor(data2[1]);
  7463. LinearGradient.addColorStop(offset, color2);
  7464. });
  7465. color = LinearGradient;
  7466. } else if (actionType === "pattern") {
  7467. const loaded = checkImageLoaded(data[1], actions.slice(index2 + 1), resolve, function(image2) {
  7468. if (image2) {
  7469. c2d[method1] = c2d.createPattern(image2, data[2]);
  7470. }
  7471. });
  7472. if (!loaded) {
  7473. break;
  7474. }
  7475. continue;
  7476. }
  7477. c2d[method1] = color;
  7478. } else if (method1 === "globalAlpha") {
  7479. c2d[method1] = Number(actionType) / 255;
  7480. } else if (method1 === "shadow") {
  7481. let shadowArray = ["shadowOffsetX", "shadowOffsetY", "shadowBlur", "shadowColor"];
  7482. data.forEach(function(color_, method_) {
  7483. c2d[shadowArray[method_]] = shadowArray[method_] === "shadowColor" ? resolveColor(color_) : color_;
  7484. });
  7485. } else if (method1 === "fontSize") {
  7486. const font2 = c2d.__font__ || c2d.font;
  7487. c2d.__font__ = c2d.font = font2.replace(/\d+\.?\d*px/, actionType + "px");
  7488. } else if (method1 === "lineDash") {
  7489. c2d.setLineDash(actionType);
  7490. c2d.lineDashOffset = data[1] || 0;
  7491. } else if (method1 === "textBaseline") {
  7492. if (actionType === "normal") {
  7493. data[0] = "alphabetic";
  7494. }
  7495. c2d[method1] = actionType;
  7496. } else if (method1 === "font") {
  7497. c2d.__font__ = c2d.font = actionType;
  7498. } else {
  7499. c2d[method1] = actionType;
  7500. }
  7501. } else if (method === "fillPath" || method === "strokePath") {
  7502. method = method.replace(/Path/, "");
  7503. c2d.beginPath();
  7504. data.forEach(function(data_) {
  7505. c2d[data_.method].apply(c2d, data_.data);
  7506. });
  7507. c2d[method]();
  7508. } else if (method === "fillText") {
  7509. c2d.fillText.apply(c2d, data);
  7510. } else if (method === "drawImage") {
  7511. let drawImage = function() {
  7512. let dataArray = [...data];
  7513. let url = dataArray[0];
  7514. let otherData = dataArray.slice(1);
  7515. _images = _images || {};
  7516. if (!checkImageLoaded(url, actions.slice(index2 + 1), resolve, function(image2) {
  7517. if (image2) {
  7518. c2d.drawImage.apply(
  7519. c2d,
  7520. // @ts-ignore
  7521. [image2].concat(
  7522. // @ts-ignore
  7523. [...otherData.slice(4, 8)],
  7524. [...otherData.slice(0, 4)]
  7525. )
  7526. );
  7527. }
  7528. }))
  7529. return "break";
  7530. }();
  7531. if (drawImage === "break") {
  7532. break;
  7533. }
  7534. } else {
  7535. if (method === "clip") {
  7536. data.forEach(function(data_) {
  7537. c2d[data_.method].apply(c2d, data_.data);
  7538. });
  7539. c2d.clip();
  7540. } else {
  7541. c2d[method].apply(c2d, data);
  7542. }
  7543. }
  7544. }
  7545. if (!actionsWaiting.value) {
  7546. resolve({
  7547. errMsg: "drawCanvas:ok"
  7548. });
  7549. }
  7550. }
  7551. function preloadImage(actions) {
  7552. actions.forEach(function(action) {
  7553. let method = action.method;
  7554. let data = action.data;
  7555. let src = "";
  7556. if (method === "drawImage") {
  7557. src = data[0];
  7558. src = $getRealPath(src);
  7559. data[0] = src;
  7560. } else if (method === "setFillStyle" && data[0] === "pattern") {
  7561. src = data[1];
  7562. src = $getRealPath(src);
  7563. data[1] = src;
  7564. }
  7565. if (src && !_images[src]) {
  7566. loadImage();
  7567. }
  7568. function loadImage() {
  7569. const image2 = _images[src] = new Image();
  7570. image2.onload = function() {
  7571. image2.ready = true;
  7572. };
  7573. getSameOriginUrl(src).then((src2) => {
  7574. image2.src = src2;
  7575. }).catch(() => {
  7576. image2.src = src;
  7577. });
  7578. }
  7579. });
  7580. }
  7581. function checkImageLoaded(src, actions, resolve, fn) {
  7582. let image2 = _images[src];
  7583. if (image2.ready) {
  7584. fn(image2);
  7585. return true;
  7586. } else {
  7587. _actionsDefer.unshift([actions, true]);
  7588. actionsWaiting.value = true;
  7589. image2.onload = function() {
  7590. image2.ready = true;
  7591. fn(image2);
  7592. actionsWaiting.value = false;
  7593. let actions2 = _actionsDefer.slice(0);
  7594. _actionsDefer = [];
  7595. for (let action = actions2.shift(); action; ) {
  7596. actionsChanged({
  7597. actions: action[0],
  7598. reserve: action[1]
  7599. }, resolve);
  7600. action = actions2.shift();
  7601. }
  7602. };
  7603. return false;
  7604. }
  7605. }
  7606. function getImageData({
  7607. x = 0,
  7608. y = 0,
  7609. width,
  7610. height,
  7611. destWidth,
  7612. destHeight,
  7613. hidpi = true,
  7614. dataType: dataType2,
  7615. quality = 1,
  7616. type = "png"
  7617. }, resolve) {
  7618. const canvas = canvasRef.value;
  7619. let data;
  7620. const maxWidth2 = canvas.offsetWidth - x;
  7621. width = width ? Math.min(width, maxWidth2) : maxWidth2;
  7622. const maxHeight = canvas.offsetHeight - y;
  7623. height = height ? Math.min(height, maxHeight) : maxHeight;
  7624. if (!hidpi) {
  7625. if (!destWidth && !destHeight) {
  7626. destWidth = Math.round(width * _pixelRatio.value);
  7627. destHeight = Math.round(height * _pixelRatio.value);
  7628. } else if (!destWidth) {
  7629. destWidth = Math.round(width / height * destHeight);
  7630. } else if (!destHeight) {
  7631. destHeight = Math.round(height / width * destWidth);
  7632. }
  7633. } else {
  7634. destWidth = width;
  7635. destHeight = height;
  7636. }
  7637. const newCanvas = getTempCanvas(destWidth, destHeight);
  7638. const context = newCanvas.getContext("2d");
  7639. if (type === "jpeg" || type === "jpg") {
  7640. type = "jpeg";
  7641. context.fillStyle = "#fff";
  7642. context.fillRect(0, 0, destWidth, destHeight);
  7643. }
  7644. context.__hidpi__ = true;
  7645. context.drawImageByCanvas(canvas, x, y, width, height, 0, 0, destWidth, destHeight, false);
  7646. let result;
  7647. try {
  7648. let compressed;
  7649. if (dataType2 === "base64") {
  7650. data = newCanvas.toDataURL(`image/${type}`, quality);
  7651. } else {
  7652. const imgData = context.getImageData(0, 0, destWidth, destHeight);
  7653. if (false)
  7654. ;
  7655. else {
  7656. data = Array.prototype.slice.call(imgData.data);
  7657. }
  7658. }
  7659. result = {
  7660. data,
  7661. compressed,
  7662. width: destWidth,
  7663. height: destHeight
  7664. };
  7665. } catch (error) {
  7666. result = {
  7667. errMsg: `canvasGetImageData:fail ${error}`
  7668. };
  7669. }
  7670. newCanvas.height = newCanvas.width = 0;
  7671. context.__hidpi__ = false;
  7672. if (!resolve) {
  7673. return result;
  7674. } else {
  7675. resolve(result);
  7676. }
  7677. }
  7678. function putImageData({
  7679. data,
  7680. x,
  7681. y,
  7682. width,
  7683. height,
  7684. compressed
  7685. }, resolve) {
  7686. try {
  7687. if (false)
  7688. ;
  7689. if (!height) {
  7690. height = Math.round(data.length / 4 / width);
  7691. }
  7692. const canvas = getTempCanvas(width, height);
  7693. const context = canvas.getContext("2d");
  7694. context.putImageData(new ImageData(new Uint8ClampedArray(data), width, height), 0, 0);
  7695. canvasRef.value.getContext("2d").drawImage(canvas, x, y, width, height);
  7696. canvas.height = canvas.width = 0;
  7697. } catch (error) {
  7698. resolve({
  7699. errMsg: "canvasPutImageData:fail"
  7700. });
  7701. return;
  7702. }
  7703. resolve({
  7704. errMsg: "canvasPutImageData:ok"
  7705. });
  7706. }
  7707. function toTempFilePath({
  7708. x = 0,
  7709. y = 0,
  7710. width,
  7711. height,
  7712. destWidth,
  7713. destHeight,
  7714. fileType,
  7715. quality,
  7716. dirname
  7717. }, resolve) {
  7718. const res = getImageData({
  7719. x,
  7720. y,
  7721. width,
  7722. height,
  7723. destWidth,
  7724. destHeight,
  7725. hidpi: false,
  7726. dataType: "base64",
  7727. type: fileType,
  7728. quality
  7729. });
  7730. if (!res.data || !res.data.length) {
  7731. resolve({
  7732. errMsg: res.errMsg.replace("canvasPutImageData", "toTempFilePath")
  7733. });
  7734. return;
  7735. }
  7736. saveImage(res.data, dirname, (error, tempFilePath) => {
  7737. let errMsg = `toTempFilePath:${error ? "fail" : "ok"}`;
  7738. if (error) {
  7739. errMsg += ` ${error.message}`;
  7740. }
  7741. resolve({
  7742. errMsg,
  7743. tempFilePath
  7744. });
  7745. });
  7746. }
  7747. const methods = {
  7748. actionsChanged,
  7749. getImageData,
  7750. putImageData,
  7751. toTempFilePath
  7752. };
  7753. function _handleSubscribe(type, data, resolve) {
  7754. let method = methods[type];
  7755. if (type.indexOf("_") !== 0 && isFunction(method)) {
  7756. method(data, resolve);
  7757. }
  7758. }
  7759. return extend(methods, {
  7760. _resize,
  7761. _handleSubscribe
  7762. });
  7763. }
  7764. const uniCheckGroupKey = PolySymbol(process.env.NODE_ENV !== "production" ? "uniCheckGroup" : "ucg");
  7765. const props$w = {
  7766. name: {
  7767. type: String,
  7768. default: ""
  7769. }
  7770. };
  7771. class UniCheckboxGroupElement extends UniElement {
  7772. }
  7773. const index$v = /* @__PURE__ */ defineBuiltInComponent({
  7774. name: "CheckboxGroup",
  7775. props: props$w,
  7776. emits: ["change"],
  7777. rootElement: {
  7778. name: "uni-checkbox-group",
  7779. class: UniCheckboxGroupElement
  7780. },
  7781. setup(props2, {
  7782. emit: emit2,
  7783. slots
  7784. }) {
  7785. const rootRef = ref(null);
  7786. const trigger = useCustomEvent(rootRef, emit2);
  7787. useProvideCheckGroup(props2, trigger);
  7788. onMounted(() => {
  7789. const rootElement = rootRef.value;
  7790. rootElement.attachVmProps(props2);
  7791. });
  7792. return () => {
  7793. return createVNode("uni-checkbox-group", {
  7794. "ref": rootRef
  7795. }, [slots.default && slots.default()], 512);
  7796. };
  7797. }
  7798. });
  7799. function useProvideCheckGroup(props2, trigger) {
  7800. const fields2 = [];
  7801. const getFieldsValue = () => fields2.reduce((res, field) => {
  7802. if (field.value.checkboxChecked) {
  7803. res.push(field.value.value + "");
  7804. }
  7805. return res;
  7806. }, new Array());
  7807. provide(uniCheckGroupKey, {
  7808. addField(field) {
  7809. fields2.push(field);
  7810. },
  7811. removeField(field) {
  7812. fields2.splice(fields2.indexOf(field), 1);
  7813. },
  7814. checkboxChange($event) {
  7815. trigger("change", $event, {
  7816. value: getFieldsValue()
  7817. });
  7818. }
  7819. });
  7820. const uniForm = inject(uniFormKey, false);
  7821. if (uniForm) {
  7822. uniForm.addField({
  7823. submit: () => {
  7824. let data = ["", null];
  7825. if (props2.name !== "") {
  7826. data[0] = props2.name;
  7827. data[1] = getFieldsValue();
  7828. }
  7829. return data;
  7830. }
  7831. });
  7832. }
  7833. return getFieldsValue;
  7834. }
  7835. const props$v = {
  7836. checked: {
  7837. type: [Boolean, String],
  7838. default: false
  7839. },
  7840. id: {
  7841. type: String,
  7842. default: ""
  7843. },
  7844. disabled: {
  7845. type: [Boolean, String],
  7846. default: false
  7847. },
  7848. value: {
  7849. type: String,
  7850. default: ""
  7851. },
  7852. color: {
  7853. type: String,
  7854. default: "#007aff"
  7855. },
  7856. backgroundColor: {
  7857. type: String,
  7858. default: ""
  7859. },
  7860. borderColor: {
  7861. type: String,
  7862. default: ""
  7863. },
  7864. activeBackgroundColor: {
  7865. type: String,
  7866. default: ""
  7867. },
  7868. activeBorderColor: {
  7869. type: String,
  7870. default: ""
  7871. },
  7872. iconColor: {
  7873. type: String,
  7874. default: ""
  7875. }
  7876. };
  7877. class UniCheckboxElement extends UniElement {
  7878. }
  7879. const index$u = /* @__PURE__ */ defineBuiltInComponent({
  7880. name: "Checkbox",
  7881. props: props$v,
  7882. rootElement: {
  7883. name: "uni-checkbox",
  7884. class: UniCheckboxElement
  7885. },
  7886. setup(props2, {
  7887. slots
  7888. }) {
  7889. const rootRef = ref(null);
  7890. const checkboxChecked = ref(props2.checked);
  7891. const checkboxCheckedBool = computed(() => {
  7892. return checkboxChecked.value === "true" || checkboxChecked.value === true;
  7893. });
  7894. const checkboxValue = ref(props2.value);
  7895. const initialCheckedValue = props2.checked;
  7896. function getCheckBoxStyle(checked) {
  7897. if (props2.disabled) {
  7898. return {
  7899. backgroundColor: "#E1E1E1",
  7900. borderColor: "#D1D1D1"
  7901. };
  7902. }
  7903. const style = {};
  7904. if (checked) {
  7905. if (props2.activeBorderColor)
  7906. style.borderColor = props2.activeBorderColor;
  7907. if (props2.activeBackgroundColor)
  7908. style.backgroundColor = props2.activeBackgroundColor;
  7909. } else {
  7910. if (props2.borderColor)
  7911. style.borderColor = props2.borderColor;
  7912. if (props2.backgroundColor)
  7913. style.backgroundColor = props2.backgroundColor;
  7914. }
  7915. return style;
  7916. }
  7917. const checkboxStyle = computed(() => {
  7918. return getCheckBoxStyle(checkboxCheckedBool.value);
  7919. });
  7920. watch([() => props2.checked, () => props2.value], ([newChecked, newModelValue]) => {
  7921. checkboxChecked.value = newChecked;
  7922. checkboxValue.value = newModelValue;
  7923. });
  7924. const reset = () => {
  7925. checkboxChecked.value = initialCheckedValue;
  7926. };
  7927. const {
  7928. uniCheckGroup,
  7929. uniLabel
  7930. } = useCheckboxInject(checkboxChecked, checkboxValue, reset);
  7931. const _onClick = ($event) => {
  7932. if (props2.disabled) {
  7933. return;
  7934. }
  7935. checkboxChecked.value = !checkboxChecked.value;
  7936. uniCheckGroup && uniCheckGroup.checkboxChange($event);
  7937. $event.stopPropagation();
  7938. };
  7939. if (!!uniLabel) {
  7940. uniLabel.addHandler(_onClick);
  7941. onBeforeUnmount(() => {
  7942. uniLabel.removeHandler(_onClick);
  7943. });
  7944. }
  7945. useListeners$1(props2, {
  7946. "label-click": _onClick
  7947. });
  7948. let checkedCache = ref(checkboxCheckedBool.value);
  7949. watch(() => checkboxCheckedBool.value, (newChecked) => {
  7950. checkedCache.value = newChecked;
  7951. });
  7952. onMounted(() => {
  7953. const rootElement = rootRef.value;
  7954. Object.defineProperty(rootElement, "checked", {
  7955. get() {
  7956. return checkedCache.value;
  7957. },
  7958. set(val) {
  7959. checkedCache.value = val;
  7960. const style = getCheckBoxStyle(val);
  7961. const checkboxInputElement = rootElement.querySelector(".uni-checkbox-input");
  7962. for (const key in style) {
  7963. const value = style[key];
  7964. value && checkboxInputElement.style.setProperty(key, value);
  7965. }
  7966. }
  7967. });
  7968. rootElement.attachVmProps(props2);
  7969. });
  7970. return () => {
  7971. const booleanAttrs = useBooleanAttr(props2, "disabled");
  7972. let realCheckValue;
  7973. realCheckValue = checkedCache.value;
  7974. return createVNode("uni-checkbox", mergeProps(booleanAttrs, {
  7975. "id": props2.id,
  7976. "onClick": _onClick,
  7977. "ref": rootRef
  7978. }), [createVNode("div", {
  7979. "class": "uni-checkbox-wrapper",
  7980. "style": {
  7981. "--HOVER-BD-COLOR": props2.activeBorderColor
  7982. }
  7983. }, [createVNode("div", {
  7984. "class": ["uni-checkbox-input", {
  7985. "uni-checkbox-input-disabled": props2.disabled
  7986. }],
  7987. "style": checkboxStyle.value
  7988. }, [realCheckValue ? createSvgIconVNode(ICON_PATH_SUCCESS_NO_CIRCLE, props2.disabled ? "#ADADAD" : props2.iconColor || props2.color, 22) : ""], 6), slots.default && slots.default()], 4)], 16, ["id", "onClick"]);
  7989. };
  7990. }
  7991. });
  7992. function useCheckboxInject(checkboxChecked, checkboxValue, reset) {
  7993. const field = computed(() => ({
  7994. checkboxChecked: Boolean(checkboxChecked.value),
  7995. value: checkboxValue.value
  7996. }));
  7997. const formField = {
  7998. reset
  7999. };
  8000. const uniCheckGroup = inject(uniCheckGroupKey, false);
  8001. if (!!uniCheckGroup) {
  8002. uniCheckGroup.addField(field);
  8003. }
  8004. const uniForm = inject(uniFormKey, false);
  8005. if (!!uniForm) {
  8006. uniForm.addField(formField);
  8007. }
  8008. const uniLabel = inject(uniLabelKey, false);
  8009. onBeforeUnmount(() => {
  8010. uniCheckGroup && uniCheckGroup.removeField(field);
  8011. uniForm && uniForm.removeField(formField);
  8012. });
  8013. return {
  8014. uniCheckGroup,
  8015. uniForm,
  8016. uniLabel
  8017. };
  8018. }
  8019. let resetTimer;
  8020. function iosHideKeyboard() {
  8021. }
  8022. const props$u = {
  8023. cursorSpacing: {
  8024. type: [Number, String],
  8025. default: 0
  8026. },
  8027. showConfirmBar: {
  8028. type: [Boolean, String],
  8029. default: "auto"
  8030. },
  8031. adjustPosition: {
  8032. type: [Boolean, String],
  8033. default: true
  8034. },
  8035. autoBlur: {
  8036. type: [Boolean, String],
  8037. default: false
  8038. }
  8039. };
  8040. const emit$1 = ["keyboardheightchange"];
  8041. function useKeyboard$1(props2, elRef, trigger) {
  8042. function initKeyboard(el) {
  8043. const isApple = computed(
  8044. () => String(navigator.vendor).indexOf("Apple") === 0
  8045. );
  8046. el.addEventListener("focus", () => {
  8047. clearTimeout(resetTimer);
  8048. document.addEventListener("click", iosHideKeyboard, false);
  8049. });
  8050. const onKeyboardHide = () => {
  8051. document.removeEventListener("click", iosHideKeyboard, false);
  8052. if (isApple.value) {
  8053. document.documentElement.scrollTo(
  8054. document.documentElement.scrollLeft,
  8055. document.documentElement.scrollTop
  8056. );
  8057. }
  8058. };
  8059. el.addEventListener("blur", () => {
  8060. if (isApple.value) {
  8061. el.blur();
  8062. }
  8063. onKeyboardHide();
  8064. });
  8065. }
  8066. watch(
  8067. () => elRef.value,
  8068. (el) => el && initKeyboard(el)
  8069. );
  8070. }
  8071. var startTag = /^<([-A-Za-z0-9_]+)((?:\s+[a-zA-Z_:][-a-zA-Z0-9_:.]*(?:\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|[^>\s]+))?)*)\s*(\/?)>/;
  8072. var endTag = /^<\/([-A-Za-z0-9_]+)[^>]*>/;
  8073. var attr = /([a-zA-Z_:][-a-zA-Z0-9_:.]*)(?:\s*=\s*(?:(?:"((?:\\.|[^"])*)")|(?:'((?:\\.|[^'])*)')|([^>\s]+)))?/g;
  8074. var empty = /* @__PURE__ */ makeMap(
  8075. "area,base,basefont,br,col,frame,hr,img,input,link,meta,param,embed,command,keygen,source,track,wbr"
  8076. );
  8077. var block = /* @__PURE__ */ makeMap(
  8078. "a,address,article,applet,aside,audio,blockquote,button,canvas,center,dd,del,dir,div,dl,dt,fieldset,figcaption,figure,footer,form,frameset,h1,h2,h3,h4,h5,h6,header,hgroup,hr,iframe,isindex,li,map,menu,noframes,noscript,object,ol,output,p,pre,section,script,table,tbody,td,tfoot,th,thead,tr,ul,video"
  8079. );
  8080. var inline = /* @__PURE__ */ makeMap(
  8081. "abbr,acronym,applet,b,basefont,bdo,big,br,button,cite,code,del,dfn,em,font,i,iframe,img,input,ins,kbd,label,map,object,q,s,samp,script,select,small,span,strike,strong,sub,sup,textarea,tt,u,var"
  8082. );
  8083. var closeSelf = /* @__PURE__ */ makeMap(
  8084. "colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr"
  8085. );
  8086. var fillAttrs = /* @__PURE__ */ makeMap(
  8087. "checked,compact,declare,defer,disabled,ismap,multiple,nohref,noresize,noshade,nowrap,readonly,selected"
  8088. );
  8089. var special = /* @__PURE__ */ makeMap("script,style");
  8090. function HTMLParser(html, handler) {
  8091. var index2;
  8092. var chars2;
  8093. var match;
  8094. var stack = [];
  8095. var last = html;
  8096. stack.last = function() {
  8097. return this[this.length - 1];
  8098. };
  8099. while (html) {
  8100. chars2 = true;
  8101. if (!stack.last() || !special[stack.last()]) {
  8102. if (html.indexOf("<!--") == 0) {
  8103. index2 = html.indexOf("-->");
  8104. if (index2 >= 0) {
  8105. if (handler.comment) {
  8106. handler.comment(html.substring(4, index2));
  8107. }
  8108. html = html.substring(index2 + 3);
  8109. chars2 = false;
  8110. }
  8111. } else if (html.indexOf("</") == 0) {
  8112. match = html.match(endTag);
  8113. if (match) {
  8114. html = html.substring(match[0].length);
  8115. match[0].replace(endTag, parseEndTag);
  8116. chars2 = false;
  8117. }
  8118. } else if (html.indexOf("<") == 0) {
  8119. match = html.match(startTag);
  8120. if (match) {
  8121. html = html.substring(match[0].length);
  8122. match[0].replace(startTag, parseStartTag);
  8123. chars2 = false;
  8124. }
  8125. }
  8126. if (chars2) {
  8127. index2 = html.indexOf("<");
  8128. var text2 = index2 < 0 ? html : html.substring(0, index2);
  8129. html = index2 < 0 ? "" : html.substring(index2);
  8130. if (handler.chars) {
  8131. handler.chars(text2);
  8132. }
  8133. }
  8134. } else {
  8135. html = html.replace(
  8136. new RegExp("([\\s\\S]*?)</" + stack.last() + "[^>]*>"),
  8137. function(all, text3) {
  8138. text3 = text3.replace(
  8139. /<!--([\s\S]*?)-->|<!\[CDATA\[([\s\S]*?)]]>/g,
  8140. "$1$2"
  8141. );
  8142. if (handler.chars) {
  8143. handler.chars(text3);
  8144. }
  8145. return "";
  8146. }
  8147. );
  8148. parseEndTag("", stack.last());
  8149. }
  8150. if (html == last) {
  8151. throw "Parse Error: " + html;
  8152. }
  8153. last = html;
  8154. }
  8155. parseEndTag();
  8156. function parseStartTag(tag, tagName, rest, unary) {
  8157. tagName = tagName.toLowerCase();
  8158. if (block[tagName]) {
  8159. while (stack.last() && inline[stack.last()]) {
  8160. parseEndTag("", stack.last());
  8161. }
  8162. }
  8163. if (closeSelf[tagName] && stack.last() == tagName) {
  8164. parseEndTag("", tagName);
  8165. }
  8166. unary = empty[tagName] || !!unary;
  8167. if (!unary) {
  8168. stack.push(tagName);
  8169. }
  8170. if (handler.start) {
  8171. var attrs2 = [];
  8172. rest.replace(attr, function(match2, name) {
  8173. var value = arguments[2] ? arguments[2] : arguments[3] ? arguments[3] : arguments[4] ? arguments[4] : fillAttrs[name] ? name : "";
  8174. attrs2.push({
  8175. name,
  8176. value,
  8177. escaped: value.replace(/(^|[^\\])"/g, '$1\\"')
  8178. // "
  8179. });
  8180. });
  8181. if (handler.start) {
  8182. handler.start(tagName, attrs2, unary);
  8183. }
  8184. }
  8185. }
  8186. function parseEndTag(tag, tagName) {
  8187. if (!tagName) {
  8188. var pos = 0;
  8189. } else {
  8190. for (var pos = stack.length - 1; pos >= 0; pos--) {
  8191. if (stack[pos] == tagName) {
  8192. break;
  8193. }
  8194. }
  8195. }
  8196. if (pos >= 0) {
  8197. for (var i = stack.length - 1; i >= pos; i--) {
  8198. if (handler.end) {
  8199. handler.end(stack[i]);
  8200. }
  8201. }
  8202. stack.length = pos;
  8203. }
  8204. }
  8205. }
  8206. function makeMap(str) {
  8207. var obj = {};
  8208. var items = str.split(",");
  8209. for (var i = 0; i < items.length; i++) {
  8210. obj[items[i]] = true;
  8211. }
  8212. return obj;
  8213. }
  8214. const scripts = {};
  8215. function loadScript(globalName, src, callback) {
  8216. const globalObject = isString(globalName) ? window[globalName] : globalName;
  8217. if (globalObject) {
  8218. callback();
  8219. return;
  8220. }
  8221. let callbacks2 = scripts[src];
  8222. if (!callbacks2) {
  8223. callbacks2 = scripts[src] = [];
  8224. const script = document.createElement("script");
  8225. script.src = src;
  8226. document.body.appendChild(script);
  8227. script.onload = function() {
  8228. callbacks2.forEach((callback2) => callback2());
  8229. delete scripts[src];
  8230. };
  8231. }
  8232. callbacks2.push(callback);
  8233. }
  8234. function divider(Quill) {
  8235. const BlockEmbed = Quill.import("blots/block/embed");
  8236. class Divider extends BlockEmbed {
  8237. }
  8238. Divider.blotName = "divider";
  8239. Divider.tagName = "HR";
  8240. return {
  8241. "formats/divider": Divider
  8242. };
  8243. }
  8244. function ins(Quill) {
  8245. const Inline = Quill.import("blots/inline");
  8246. class Ins extends Inline {
  8247. }
  8248. Ins.blotName = "ins";
  8249. Ins.tagName = "INS";
  8250. return {
  8251. "formats/ins": Ins
  8252. };
  8253. }
  8254. function align(Quill) {
  8255. const { Scope, Attributor } = Quill.import("parchment");
  8256. const config = {
  8257. scope: Scope.BLOCK,
  8258. whitelist: ["left", "right", "center", "justify"]
  8259. };
  8260. const AlignStyle = new Attributor.Style("align", "text-align", config);
  8261. return {
  8262. "formats/align": AlignStyle
  8263. };
  8264. }
  8265. function direction(Quill) {
  8266. const { Scope, Attributor } = Quill.import("parchment");
  8267. const config = {
  8268. scope: Scope.BLOCK,
  8269. whitelist: ["rtl"]
  8270. };
  8271. const DirectionStyle = new Attributor.Style("direction", "direction", config);
  8272. return {
  8273. "formats/direction": DirectionStyle
  8274. };
  8275. }
  8276. function list(Quill) {
  8277. const Parchment = Quill.import("parchment");
  8278. const Container = Quill.import("blots/container");
  8279. const ListItem = Quill.import("formats/list/item");
  8280. class List extends Container {
  8281. static create(value) {
  8282. const tagName = value === "ordered" ? "OL" : "UL";
  8283. const node = super.create(tagName);
  8284. if (value === "checked" || value === "unchecked") {
  8285. node.setAttribute("data-checked", value === "checked");
  8286. }
  8287. return node;
  8288. }
  8289. static formats(domNode) {
  8290. if (domNode.tagName === "OL")
  8291. return "ordered";
  8292. if (domNode.tagName === "UL") {
  8293. if (domNode.hasAttribute("data-checked")) {
  8294. return domNode.getAttribute("data-checked") === "true" ? "checked" : "unchecked";
  8295. } else {
  8296. return "bullet";
  8297. }
  8298. }
  8299. return void 0;
  8300. }
  8301. constructor(domNode) {
  8302. super(domNode);
  8303. const listEventHandler = (e2) => {
  8304. if (e2.target.parentNode !== domNode)
  8305. return;
  8306. const format = this.statics.formats(domNode);
  8307. const blot = Parchment.find(e2.target);
  8308. if (format === "checked") {
  8309. blot.format("list", "unchecked");
  8310. } else if (format === "unchecked") {
  8311. blot.format("list", "checked");
  8312. }
  8313. };
  8314. domNode.addEventListener("click", listEventHandler);
  8315. }
  8316. format(name, value) {
  8317. if (this.children.length > 0) {
  8318. this.children.tail.format(name, value);
  8319. }
  8320. }
  8321. formats() {
  8322. return { [this.statics.blotName]: this.statics.formats(this.domNode) };
  8323. }
  8324. insertBefore(blot, ref2) {
  8325. if (blot instanceof ListItem) {
  8326. super.insertBefore(blot, ref2);
  8327. } else {
  8328. const index2 = ref2 == null ? this.length() : ref2.offset(this);
  8329. const after = this.split(index2);
  8330. after.parent.insertBefore(blot, after);
  8331. }
  8332. }
  8333. optimize(context) {
  8334. super.optimize(context);
  8335. const next = this.next;
  8336. if (next != null && next.prev === this && next.statics.blotName === this.statics.blotName && next.domNode.tagName === this.domNode.tagName && next.domNode.getAttribute("data-checked") === this.domNode.getAttribute("data-checked")) {
  8337. next.moveChildren(this);
  8338. next.remove();
  8339. }
  8340. }
  8341. replace(target) {
  8342. if (target.statics.blotName !== this.statics.blotName) {
  8343. const item = Parchment.create(this.statics.defaultChild);
  8344. target.moveChildren(item);
  8345. this.appendChild(item);
  8346. }
  8347. super.replace(target);
  8348. }
  8349. }
  8350. List.blotName = "list";
  8351. List.scope = Parchment.Scope.BLOCK_BLOT;
  8352. List.tagName = ["OL", "UL"];
  8353. List.defaultChild = "list-item";
  8354. List.allowedChildren = [ListItem];
  8355. return {
  8356. "formats/list": List
  8357. };
  8358. }
  8359. function background(Quill) {
  8360. const { Scope } = Quill.import("parchment");
  8361. const BackgroundStyle = Quill.import("formats/background");
  8362. const BackgroundColorStyle = new BackgroundStyle.constructor(
  8363. "backgroundColor",
  8364. "background-color",
  8365. {
  8366. scope: Scope.INLINE
  8367. }
  8368. );
  8369. return {
  8370. "formats/backgroundColor": BackgroundColorStyle
  8371. };
  8372. }
  8373. function box(Quill) {
  8374. const { Scope, Attributor } = Quill.import("parchment");
  8375. const config = {
  8376. scope: Scope.BLOCK
  8377. };
  8378. const margin = [
  8379. "margin",
  8380. "marginTop",
  8381. "marginBottom",
  8382. "marginLeft",
  8383. "marginRight"
  8384. ];
  8385. const padding = [
  8386. "padding",
  8387. "paddingTop",
  8388. "paddingBottom",
  8389. "paddingLeft",
  8390. "paddingRight"
  8391. ];
  8392. const result = {};
  8393. margin.concat(padding).forEach((name) => {
  8394. result[`formats/${name}`] = new Attributor.Style(
  8395. name,
  8396. hyphenate(name),
  8397. config
  8398. );
  8399. });
  8400. return result;
  8401. }
  8402. function font(Quill) {
  8403. const { Scope, Attributor } = Quill.import("parchment");
  8404. const config = {
  8405. scope: Scope.INLINE
  8406. };
  8407. const font2 = [
  8408. "font",
  8409. "fontSize",
  8410. "fontStyle",
  8411. "fontVariant",
  8412. "fontWeight",
  8413. "fontFamily"
  8414. ];
  8415. const result = {};
  8416. font2.forEach((name) => {
  8417. result[`formats/${name}`] = new Attributor.Style(
  8418. name,
  8419. hyphenate(name),
  8420. config
  8421. );
  8422. });
  8423. return result;
  8424. }
  8425. function text(Quill) {
  8426. const { Scope, Attributor } = Quill.import("parchment");
  8427. const text2 = [
  8428. {
  8429. name: "lineHeight",
  8430. scope: Scope.BLOCK
  8431. },
  8432. {
  8433. name: "letterSpacing",
  8434. scope: Scope.INLINE
  8435. },
  8436. {
  8437. name: "textDecoration",
  8438. scope: Scope.INLINE
  8439. },
  8440. {
  8441. name: "textIndent",
  8442. scope: Scope.BLOCK
  8443. }
  8444. ];
  8445. const result = {};
  8446. text2.forEach(({ name, scope: scope2 }) => {
  8447. result[`formats/${name}`] = new Attributor.Style(name, hyphenate(name), {
  8448. scope: scope2
  8449. });
  8450. });
  8451. return result;
  8452. }
  8453. function image(Quill) {
  8454. const Image2 = Quill.import("formats/image");
  8455. const ATTRIBUTES = [
  8456. "alt",
  8457. "height",
  8458. "width",
  8459. "data-custom",
  8460. "class",
  8461. "data-local"
  8462. ];
  8463. Image2.sanitize = (url) => url ? getRealPath(url) : url;
  8464. Image2.formats = function formats(domNode) {
  8465. return ATTRIBUTES.reduce(
  8466. function(formats2, attribute) {
  8467. if (domNode.hasAttribute(attribute)) {
  8468. formats2[attribute] = domNode.getAttribute(attribute);
  8469. }
  8470. return formats2;
  8471. },
  8472. {}
  8473. );
  8474. };
  8475. const format = Image2.prototype.format;
  8476. Image2.prototype.format = function(name, value) {
  8477. if (ATTRIBUTES.indexOf(name) > -1) {
  8478. if (value) {
  8479. this.domNode.setAttribute(name, value);
  8480. } else {
  8481. this.domNode.removeAttribute(name);
  8482. }
  8483. } else {
  8484. format.call(this, name, value);
  8485. }
  8486. };
  8487. }
  8488. function link(Quill) {
  8489. const Link = Quill.import("formats/link");
  8490. Link.sanitize = (url) => {
  8491. const anchor = document.createElement("a");
  8492. anchor.href = url;
  8493. const protocol = anchor.href.slice(0, anchor.href.indexOf(":"));
  8494. return Link.PROTOCOL_WHITELIST.concat("file").indexOf(protocol) > -1 ? url : Link.SANITIZED_URL;
  8495. };
  8496. }
  8497. function register(Quill) {
  8498. const formats = {
  8499. divider,
  8500. ins,
  8501. align,
  8502. direction,
  8503. list,
  8504. background,
  8505. box,
  8506. font,
  8507. text,
  8508. image,
  8509. link
  8510. };
  8511. const options = {};
  8512. Object.values(formats).forEach((value) => extend(options, value(Quill)));
  8513. Quill.register(options, true);
  8514. }
  8515. function useQuill(props2, rootRef, trigger) {
  8516. let quillReady;
  8517. let skipMatcher;
  8518. let quill;
  8519. watch(
  8520. () => props2.readOnly,
  8521. (value) => {
  8522. if (quillReady) {
  8523. quill.enable(!value);
  8524. if (!value) {
  8525. quill.blur();
  8526. }
  8527. }
  8528. }
  8529. );
  8530. watch(
  8531. () => props2.placeholder,
  8532. (value) => {
  8533. if (quillReady) {
  8534. setPlaceHolder(value);
  8535. }
  8536. }
  8537. );
  8538. function html2delta(html) {
  8539. const tags = [
  8540. "span",
  8541. "strong",
  8542. "b",
  8543. "ins",
  8544. "em",
  8545. "i",
  8546. "u",
  8547. "a",
  8548. "del",
  8549. "s",
  8550. "sub",
  8551. "sup",
  8552. "img",
  8553. "div",
  8554. "p",
  8555. "h1",
  8556. "h2",
  8557. "h3",
  8558. "h4",
  8559. "h5",
  8560. "h6",
  8561. "hr",
  8562. "ol",
  8563. "ul",
  8564. "li",
  8565. "br"
  8566. ];
  8567. let content = "";
  8568. let disable;
  8569. HTMLParser(html, {
  8570. start: function(tag, attrs2, unary) {
  8571. if (!tags.includes(tag)) {
  8572. disable = !unary;
  8573. return;
  8574. }
  8575. disable = false;
  8576. const arrts = attrs2.map(({ name, value }) => `${name}="${value}"`).join(" ");
  8577. const start = `<${tag} ${arrts} ${unary ? "/" : ""}>`;
  8578. content += start;
  8579. },
  8580. end: function(tag) {
  8581. if (!disable) {
  8582. content += `</${tag}>`;
  8583. }
  8584. },
  8585. chars: function(text2) {
  8586. if (!disable) {
  8587. content += text2;
  8588. }
  8589. }
  8590. });
  8591. skipMatcher = true;
  8592. const delta = quill.clipboard.convert(content);
  8593. skipMatcher = false;
  8594. return delta;
  8595. }
  8596. function getContents() {
  8597. const html = quill.root.innerHTML;
  8598. const text2 = quill.getText();
  8599. const delta = quill.getContents();
  8600. return {
  8601. html,
  8602. text: text2,
  8603. delta
  8604. };
  8605. }
  8606. function setPlaceHolder(placeholder) {
  8607. const placeHolderAttrName = "data-placeholder";
  8608. const QuillRoot = quill.root;
  8609. QuillRoot.getAttribute(placeHolderAttrName) !== placeholder && QuillRoot.setAttribute(placeHolderAttrName, placeholder);
  8610. }
  8611. let oldStatus = {};
  8612. function updateStatus(range) {
  8613. const status = range ? quill.getFormat(range) : {};
  8614. const keys = Object.keys(status);
  8615. if (keys.length !== Object.keys(oldStatus).length || keys.find((key) => status[key] !== oldStatus[key])) {
  8616. oldStatus = status;
  8617. trigger("statuschange", {}, status);
  8618. }
  8619. }
  8620. function textChangeHandler() {
  8621. trigger("input", {}, getContents());
  8622. }
  8623. function initQuill(imageResizeModules) {
  8624. const Quill = window.Quill;
  8625. register(Quill);
  8626. const options = {
  8627. toolbar: false,
  8628. readOnly: props2.readOnly,
  8629. placeholder: props2.placeholder
  8630. };
  8631. if (imageResizeModules.length) {
  8632. Quill.register(
  8633. "modules/ImageResize",
  8634. window.ImageResize.default
  8635. );
  8636. options.modules = {
  8637. ImageResize: {
  8638. modules: imageResizeModules
  8639. }
  8640. };
  8641. }
  8642. const rootEl = rootRef.value;
  8643. quill = new Quill(rootEl, options);
  8644. const $el = quill.root;
  8645. const events = ["focus", "blur", "input"];
  8646. events.forEach((name) => {
  8647. $el.addEventListener(name, ($event) => {
  8648. const contents = getContents();
  8649. if (name === "input") {
  8650. if (getBaseSystemInfo().platform === "ios") {
  8651. const regExpContent = (contents.html.match(
  8652. /<span [\s\S]*>([\s\S]*)<\/span>/
  8653. ) || [])[1];
  8654. const placeholder = regExpContent && regExpContent.replace(/\s/g, "") ? "" : props2.placeholder;
  8655. setPlaceHolder(placeholder);
  8656. }
  8657. $event.stopPropagation();
  8658. } else {
  8659. trigger(name, $event, contents);
  8660. }
  8661. });
  8662. });
  8663. quill.on("text-change", textChangeHandler);
  8664. quill.on("selection-change", updateStatus);
  8665. quill.on("scroll-optimize", () => {
  8666. const range = quill.selection.getRange()[0];
  8667. updateStatus(range);
  8668. });
  8669. quill.clipboard.addMatcher(Node.ELEMENT_NODE, (node, delta) => {
  8670. if (skipMatcher) {
  8671. return delta;
  8672. }
  8673. if (delta.ops) {
  8674. delta.ops = delta.ops.filter(({ insert }) => isString(insert)).map(({ insert }) => ({ insert }));
  8675. }
  8676. return delta;
  8677. });
  8678. quillReady = true;
  8679. trigger("ready", {}, {});
  8680. }
  8681. const id2 = useContextInfo();
  8682. useSubscribe(
  8683. (type, data, resolve) => {
  8684. const { options, callbackId } = data;
  8685. let res;
  8686. let range;
  8687. let errMsg;
  8688. if (quillReady) {
  8689. const Quill = window.Quill;
  8690. switch (type) {
  8691. case "format":
  8692. {
  8693. let { name = "", value = false } = options;
  8694. range = quill.getSelection(true);
  8695. let format = quill.getFormat(range)[name] || false;
  8696. if (["bold", "italic", "underline", "strike", "ins"].includes(name)) {
  8697. value = !format;
  8698. } else if (name === "direction") {
  8699. value = value === "rtl" && format ? false : value;
  8700. const align2 = quill.getFormat(range).align;
  8701. if (value === "rtl" && !align2) {
  8702. quill.format("align", "right", "user");
  8703. } else if (!value && align2 === "right") {
  8704. quill.format("align", false, "user");
  8705. }
  8706. } else if (name === "indent") {
  8707. const rtl = quill.getFormat(range).direction === "rtl";
  8708. value = value === "+1";
  8709. if (rtl) {
  8710. value = !value;
  8711. }
  8712. value = value ? "+1" : "-1";
  8713. } else {
  8714. if (name === "list") {
  8715. value = value === "check" ? "unchecked" : value;
  8716. format = format === "checked" ? "unchecked" : format;
  8717. }
  8718. value = format && format !== (value || false) || !format && value ? value : !format;
  8719. }
  8720. quill.format(name, value, "user");
  8721. }
  8722. break;
  8723. case "insertDivider":
  8724. range = quill.getSelection(true);
  8725. quill.insertText(range.index, LINEFEED, "user");
  8726. quill.insertEmbed(range.index + 1, "divider", true, "user");
  8727. quill.setSelection(range.index + 2, 0, "silent");
  8728. break;
  8729. case "insertImage":
  8730. {
  8731. range = quill.getSelection(true);
  8732. const {
  8733. src = "",
  8734. alt = "",
  8735. width = "",
  8736. height = "",
  8737. extClass = "",
  8738. data: data2 = {}
  8739. } = options;
  8740. const path = getRealPath(src);
  8741. quill.insertEmbed(range.index, "image", path, "silent");
  8742. const local = /^(file|blob):/.test(path) ? path : false;
  8743. quill.formatText(range.index, 1, "data-local", local, "silent");
  8744. quill.formatText(range.index, 1, "alt", alt, "silent");
  8745. quill.formatText(range.index, 1, "width", width, "silent");
  8746. quill.formatText(range.index, 1, "height", height, "silent");
  8747. quill.formatText(range.index, 1, "class", extClass, "silent");
  8748. quill.formatText(
  8749. range.index,
  8750. 1,
  8751. "data-custom",
  8752. Object.keys(data2).map((key) => `${key}=${data2[key]}`).join("&"),
  8753. "silent"
  8754. );
  8755. quill.setSelection(range.index + 1, 0, "silent");
  8756. quill.scrollIntoView();
  8757. setTimeout(() => {
  8758. textChangeHandler();
  8759. }, 1e3);
  8760. }
  8761. break;
  8762. case "insertText":
  8763. {
  8764. range = quill.getSelection(true);
  8765. const { text: text2 = "" } = options;
  8766. quill.insertText(range.index, text2, "user");
  8767. quill.setSelection(range.index + text2.length, 0, "silent");
  8768. }
  8769. break;
  8770. case "setContents":
  8771. {
  8772. const { delta, html } = options;
  8773. if (typeof delta === "object") {
  8774. quill.setContents(delta, "silent");
  8775. } else if (isString(html)) {
  8776. quill.setContents(html2delta(html), "silent");
  8777. } else {
  8778. errMsg = "contents is missing";
  8779. }
  8780. }
  8781. break;
  8782. case "getContents":
  8783. res = getContents();
  8784. break;
  8785. case "clear":
  8786. quill.setText("");
  8787. break;
  8788. case "removeFormat":
  8789. {
  8790. range = quill.getSelection(true);
  8791. const parchment = Quill.import("parchment");
  8792. if (range.length) {
  8793. quill.removeFormat(range.index, range.length, "user");
  8794. } else {
  8795. Object.keys(quill.getFormat(range)).forEach((key) => {
  8796. if (parchment.query(key, parchment.Scope.INLINE)) {
  8797. quill.format(key, false);
  8798. }
  8799. });
  8800. }
  8801. }
  8802. break;
  8803. case "undo":
  8804. quill.history.undo();
  8805. break;
  8806. case "redo":
  8807. quill.history.redo();
  8808. break;
  8809. case "blur":
  8810. quill.blur();
  8811. break;
  8812. case "getSelectionText":
  8813. range = quill.selection.savedRange;
  8814. res = { text: "" };
  8815. if (range && range.length !== 0) {
  8816. res.text = quill.getText(range.index, range.length);
  8817. }
  8818. break;
  8819. case "scrollIntoView":
  8820. quill.scrollIntoView();
  8821. break;
  8822. }
  8823. updateStatus(range);
  8824. } else {
  8825. errMsg = "not ready";
  8826. }
  8827. if (callbackId) {
  8828. resolve({
  8829. callbackId,
  8830. data: extend({}, res, {
  8831. errMsg: `${type}:${errMsg ? "fail " + errMsg : "ok"}`
  8832. })
  8833. });
  8834. }
  8835. },
  8836. id2,
  8837. true
  8838. );
  8839. onMounted(() => {
  8840. const imageResizeModules = [];
  8841. if (props2.showImgSize) {
  8842. imageResizeModules.push("DisplaySize");
  8843. }
  8844. if (props2.showImgToolbar) {
  8845. imageResizeModules.push("Toolbar");
  8846. }
  8847. if (props2.showImgResize) {
  8848. imageResizeModules.push("Resize");
  8849. }
  8850. const quillSrc = "https://unpkg.com/quill@1.3.7/dist/quill.min.js";
  8851. loadScript(window.Quill, quillSrc, () => {
  8852. if (imageResizeModules.length) {
  8853. const imageResizeSrc = "https://unpkg.com/quill-image-resize-mp@3.0.1/image-resize.min.js";
  8854. loadScript(window.ImageResize, imageResizeSrc, () => {
  8855. initQuill(imageResizeModules);
  8856. });
  8857. } else {
  8858. initQuill(imageResizeModules);
  8859. }
  8860. });
  8861. });
  8862. }
  8863. const props$t = /* @__PURE__ */ extend({}, props$u, {
  8864. id: {
  8865. type: String,
  8866. default: ""
  8867. },
  8868. readOnly: {
  8869. type: [Boolean, String],
  8870. default: false
  8871. },
  8872. placeholder: {
  8873. type: String,
  8874. default: ""
  8875. },
  8876. showImgSize: {
  8877. type: [Boolean, String],
  8878. default: false
  8879. },
  8880. showImgToolbar: {
  8881. type: [Boolean, String],
  8882. default: false
  8883. },
  8884. showImgResize: {
  8885. type: [Boolean, String],
  8886. default: false
  8887. }
  8888. });
  8889. class UniEditorElement extends UniElement {
  8890. }
  8891. const index$t = /* @__PURE__ */ defineBuiltInComponent({
  8892. name: "Editor",
  8893. props: props$t,
  8894. emit: ["ready", "focus", "blur", "input", "statuschange", ...emit$1],
  8895. rootElement: {
  8896. name: "uni-editor",
  8897. class: UniEditorElement
  8898. },
  8899. setup(props2, {
  8900. emit: emit2
  8901. }) {
  8902. const rootRef = ref(null);
  8903. const trigger = useCustomEvent(rootRef, emit2);
  8904. useQuill(props2, rootRef, trigger);
  8905. useKeyboard$1(props2, rootRef);
  8906. onMounted(() => {
  8907. const rootElement = rootRef.value;
  8908. rootElement.attachVmProps(props2);
  8909. });
  8910. return () => {
  8911. return createVNode("uni-editor", {
  8912. "ref": rootRef,
  8913. "id": props2.id,
  8914. "class": "ql-container"
  8915. }, null, 8, ["id"]);
  8916. };
  8917. }
  8918. });
  8919. const INFO_COLOR = "#10aeff";
  8920. const WARN_COLOR = "#f76260";
  8921. const GREY_COLOR = "#b2b2b2";
  8922. const CANCEL_COLOR = "#f43530";
  8923. const ICONS = {
  8924. success: {
  8925. d: ICON_PATH_SUCCESS,
  8926. c: PRIMARY_COLOR
  8927. },
  8928. success_no_circle: {
  8929. d: ICON_PATH_SUCCESS_NO_CIRCLE,
  8930. c: PRIMARY_COLOR
  8931. },
  8932. info: {
  8933. d: ICON_PATH_INFO,
  8934. c: INFO_COLOR
  8935. },
  8936. warn: {
  8937. d: ICON_PATH_WARN,
  8938. c: WARN_COLOR
  8939. },
  8940. waiting: {
  8941. d: ICON_PATH_WAITING,
  8942. c: INFO_COLOR
  8943. },
  8944. cancel: {
  8945. d: ICON_PATH_CANCEL,
  8946. c: CANCEL_COLOR
  8947. },
  8948. download: {
  8949. d: ICON_PATH_DOWNLOAD,
  8950. c: PRIMARY_COLOR
  8951. },
  8952. search: {
  8953. d: ICON_PATH_SEARCH,
  8954. c: GREY_COLOR
  8955. },
  8956. clear: {
  8957. d: ICON_PATH_CLEAR,
  8958. c: GREY_COLOR
  8959. }
  8960. };
  8961. class UniIconElement extends UniElement {
  8962. }
  8963. const index$s = /* @__PURE__ */ defineBuiltInComponent({
  8964. name: "Icon",
  8965. props: {
  8966. type: {
  8967. type: String,
  8968. required: true,
  8969. default: ""
  8970. },
  8971. size: {
  8972. type: [String, Number],
  8973. default: 23
  8974. },
  8975. color: {
  8976. type: String,
  8977. default: ""
  8978. }
  8979. },
  8980. rootElement: {
  8981. name: "uni-icon",
  8982. class: UniIconElement
  8983. },
  8984. setup(props2) {
  8985. const rootRef = ref(null);
  8986. const path = computed(() => ICONS[props2.type]);
  8987. return () => {
  8988. const {
  8989. value
  8990. } = path;
  8991. onMounted(() => {
  8992. const rootElement = rootRef.value;
  8993. rootElement.attachVmProps(props2);
  8994. });
  8995. return createVNode("uni-icon", {
  8996. "ref": rootRef
  8997. }, [value && value.d && createSvgIconVNode(value.d, props2.color || value.c, rpx2px(props2.size))], 512);
  8998. };
  8999. }
  9000. });
  9001. const props$s = {
  9002. src: {
  9003. type: String,
  9004. default: ""
  9005. },
  9006. mode: {
  9007. type: String,
  9008. default: "scaleToFill"
  9009. },
  9010. lazyLoad: {
  9011. type: [Boolean, String],
  9012. default: false
  9013. },
  9014. draggable: {
  9015. type: Boolean,
  9016. default: false
  9017. }
  9018. };
  9019. const FIX_MODES = {
  9020. widthFix: ["offsetWidth", "height", (value, ratio) => value / ratio],
  9021. heightFix: ["offsetHeight", "width", (value, ratio) => value * ratio]
  9022. };
  9023. const IMAGE_MODES = {
  9024. aspectFit: ["center center", "contain"],
  9025. aspectFill: ["center center", "cover"],
  9026. widthFix: [, "100% 100%"],
  9027. heightFix: [, "100% 100%"],
  9028. top: ["center top"],
  9029. bottom: ["center bottom"],
  9030. center: ["center center"],
  9031. left: ["left center"],
  9032. right: ["right center"],
  9033. "top left": ["left top"],
  9034. "top right": ["right top"],
  9035. "bottom left": ["left bottom"],
  9036. "bottom right": ["right bottom"]
  9037. };
  9038. class UniImageElement extends UniElement {
  9039. }
  9040. const index$r = /* @__PURE__ */ defineBuiltInComponent({
  9041. name: "Image",
  9042. props: props$s,
  9043. rootElement: {
  9044. name: "uni-image",
  9045. class: UniImageElement
  9046. },
  9047. setup(props2, {
  9048. emit: emit2
  9049. }) {
  9050. const rootRef = ref(null);
  9051. const state2 = useImageState(rootRef, props2);
  9052. const trigger = useCustomEvent(rootRef, emit2);
  9053. const {
  9054. fixSize
  9055. } = useImageSize(rootRef, props2, state2);
  9056. useImageLoader(state2, props2, rootRef, fixSize, trigger);
  9057. onMounted(() => {
  9058. const rootElement = rootRef.value;
  9059. Object.defineProperty(rootElement, "src", {
  9060. get() {
  9061. return rootElement.querySelector("img").src;
  9062. },
  9063. set(value) {
  9064. rootElement.querySelector("div").style.backgroundImage = `url("${value}")`;
  9065. rootElement.querySelector("img").src = value;
  9066. }
  9067. });
  9068. rootElement.attachVmProps(props2);
  9069. });
  9070. return () => {
  9071. return createVNode("uni-image", {
  9072. "ref": rootRef
  9073. }, [createVNode("div", {
  9074. "style": state2.modeStyle
  9075. }, null, 4), FIX_MODES[props2.mode] ? (
  9076. // @ts-ignore
  9077. createVNode(ResizeSensor, {
  9078. "onResize": fixSize
  9079. }, null, 8, ["onResize"])
  9080. ) : createVNode("span", null, null)], 512);
  9081. };
  9082. }
  9083. });
  9084. function useImageState(rootRef, props2) {
  9085. const imgSrc = ref("");
  9086. const modeStyleRef = computed(() => {
  9087. let size = "auto";
  9088. let position = "";
  9089. const opts = IMAGE_MODES[props2.mode];
  9090. if (!opts) {
  9091. position = "0% 0%";
  9092. size = "100% 100%";
  9093. } else {
  9094. opts[0] && (position = opts[0]);
  9095. opts[1] && (size = opts[1]);
  9096. }
  9097. return `background-image:${imgSrc.value ? 'url("' + imgSrc.value + '")' : "none"};background-position:${position};background-size:${size};`;
  9098. });
  9099. const state2 = reactive({
  9100. rootEl: rootRef,
  9101. src: computed(() => props2.src ? getRealPath(props2.src) : ""),
  9102. origWidth: 0,
  9103. origHeight: 0,
  9104. origStyle: {
  9105. width: "",
  9106. height: ""
  9107. },
  9108. modeStyle: modeStyleRef,
  9109. imgSrc
  9110. });
  9111. onMounted(() => {
  9112. const rootEl = rootRef.value;
  9113. const style = rootEl.style;
  9114. state2.origWidth = Number(style.width) || 0;
  9115. state2.origHeight = Number(style.height) || 0;
  9116. });
  9117. return state2;
  9118. }
  9119. function useImageLoader(state2, props2, rootRef, fixSize, trigger) {
  9120. let img;
  9121. let draggableImg;
  9122. const setState = (width = 0, height = 0, imgSrc = "") => {
  9123. state2.origWidth = width;
  9124. state2.origHeight = height;
  9125. state2.imgSrc = imgSrc;
  9126. };
  9127. const loadImage = (src) => {
  9128. if (!src) {
  9129. resetImage();
  9130. setState();
  9131. return;
  9132. }
  9133. img = img || new Image();
  9134. img.onload = (evt) => {
  9135. const {
  9136. width,
  9137. height
  9138. } = img;
  9139. setState(width, height, src);
  9140. fixSize();
  9141. img.draggable = props2.draggable;
  9142. if (draggableImg) {
  9143. draggableImg.remove();
  9144. }
  9145. draggableImg = img;
  9146. rootRef.value.appendChild(img);
  9147. resetImage();
  9148. trigger("load", evt, {
  9149. width,
  9150. height
  9151. });
  9152. };
  9153. img.onerror = (evt) => {
  9154. setState();
  9155. resetImage();
  9156. trigger("error", evt, {
  9157. errMsg: `GET ${state2.src} 404 (Not Found)`
  9158. });
  9159. };
  9160. img.src = src;
  9161. };
  9162. const resetImage = () => {
  9163. if (img) {
  9164. img.onload = null;
  9165. img.onerror = null;
  9166. img = null;
  9167. }
  9168. };
  9169. watch(() => state2.src, (value) => loadImage(value));
  9170. watch(() => state2.imgSrc, (value) => {
  9171. if (!value && draggableImg) {
  9172. draggableImg.remove();
  9173. draggableImg = null;
  9174. }
  9175. });
  9176. onMounted(() => loadImage(state2.src));
  9177. onBeforeUnmount(() => resetImage());
  9178. }
  9179. const isChrome = navigator.vendor === "Google Inc.";
  9180. function fixNumber(num) {
  9181. if (isChrome && num > 10) {
  9182. num = Math.round(num / 2) * 2;
  9183. }
  9184. return num;
  9185. }
  9186. function useImageSize(rootRef, props2, state2) {
  9187. const fixSize = () => {
  9188. const {
  9189. mode: mode2
  9190. } = props2;
  9191. const names = FIX_MODES[mode2];
  9192. if (!names) {
  9193. return;
  9194. }
  9195. const {
  9196. origWidth,
  9197. origHeight
  9198. } = state2;
  9199. const ratio = origWidth && origHeight ? origWidth / origHeight : 0;
  9200. if (!ratio) {
  9201. return;
  9202. }
  9203. const rootEl = rootRef.value;
  9204. const value = rootEl[names[0]];
  9205. if (value) {
  9206. rootEl.style[names[1]] = fixNumber(names[2](value, ratio)) + "px";
  9207. }
  9208. };
  9209. const resetSize = () => {
  9210. const {
  9211. style
  9212. } = rootRef.value;
  9213. const {
  9214. origStyle: {
  9215. width,
  9216. height
  9217. }
  9218. } = state2;
  9219. style.width = width;
  9220. style.height = height;
  9221. };
  9222. watch(() => props2.mode, (value, oldValue) => {
  9223. if (FIX_MODES[oldValue]) {
  9224. resetSize();
  9225. }
  9226. if (FIX_MODES[value]) {
  9227. fixSize();
  9228. }
  9229. });
  9230. return {
  9231. fixSize,
  9232. resetSize
  9233. };
  9234. }
  9235. function throttle(fn, wait) {
  9236. let last = 0;
  9237. let timeout;
  9238. let waitCallback;
  9239. const newFn = function(...arg) {
  9240. const now = Date.now();
  9241. clearTimeout(timeout);
  9242. waitCallback = () => {
  9243. waitCallback = null;
  9244. last = now;
  9245. fn.apply(this, arg);
  9246. };
  9247. if (now - last < wait) {
  9248. timeout = setTimeout(waitCallback, wait - (now - last));
  9249. return;
  9250. }
  9251. waitCallback();
  9252. };
  9253. newFn.cancel = function() {
  9254. clearTimeout(timeout);
  9255. waitCallback = null;
  9256. };
  9257. newFn.flush = function() {
  9258. clearTimeout(timeout);
  9259. waitCallback && waitCallback();
  9260. };
  9261. return newFn;
  9262. }
  9263. const passiveOptions$1 = /* @__PURE__ */ passive(true);
  9264. const states = [];
  9265. let userInteract = 0;
  9266. let inited;
  9267. const setUserAction = (userAction) => states.forEach((vm) => vm.userAction = userAction);
  9268. function addInteractListener(vm = { userAction: false }) {
  9269. if (!inited) {
  9270. const eventNames = [
  9271. "touchstart",
  9272. "touchmove",
  9273. "touchend",
  9274. "mousedown",
  9275. "mouseup"
  9276. ];
  9277. eventNames.forEach((eventName) => {
  9278. document.addEventListener(
  9279. eventName,
  9280. function() {
  9281. !userInteract && setUserAction(true);
  9282. userInteract++;
  9283. setTimeout(() => {
  9284. !--userInteract && setUserAction(false);
  9285. }, 0);
  9286. },
  9287. passiveOptions$1
  9288. );
  9289. });
  9290. inited = true;
  9291. }
  9292. states.push(vm);
  9293. }
  9294. function removeInteractListener(vm) {
  9295. const index2 = states.indexOf(vm);
  9296. if (index2 >= 0) {
  9297. states.splice(index2, 1);
  9298. }
  9299. }
  9300. const getInteractStatus = () => !!userInteract;
  9301. function useUserAction() {
  9302. const state2 = reactive({
  9303. /**
  9304. * 是否用户激活
  9305. */
  9306. userAction: false
  9307. });
  9308. onMounted(() => {
  9309. addInteractListener(state2);
  9310. });
  9311. onBeforeUnmount(() => {
  9312. removeInteractListener(state2);
  9313. });
  9314. return {
  9315. state: state2
  9316. };
  9317. }
  9318. function useScopedAttrs() {
  9319. const state2 = reactive({
  9320. attrs: {}
  9321. });
  9322. onMounted(() => {
  9323. let instance2 = getCurrentInstance();
  9324. while (instance2) {
  9325. const scopeId = instance2.type.__scopeId;
  9326. if (scopeId) {
  9327. state2.attrs[scopeId] = "";
  9328. }
  9329. instance2 = instance2.proxy && instance2.proxy.$mpType === "page" ? null : instance2.parent;
  9330. }
  9331. });
  9332. return {
  9333. state: state2
  9334. };
  9335. }
  9336. function useFormField(nameKey, value) {
  9337. const uniForm = inject(
  9338. uniFormKey,
  9339. false
  9340. // remove warning
  9341. );
  9342. if (!uniForm) {
  9343. return;
  9344. }
  9345. const instance2 = getCurrentInstance();
  9346. const initialValue = isString(value) ? instance2.proxy[value] : value.value;
  9347. const ctx = {
  9348. submit() {
  9349. const proxy = instance2.proxy;
  9350. return [
  9351. proxy[nameKey],
  9352. isString(value) ? proxy[value] : value.value
  9353. ];
  9354. },
  9355. reset() {
  9356. if (isString(value)) {
  9357. instance2.proxy[value] = initialValue;
  9358. } else {
  9359. value.value = initialValue;
  9360. }
  9361. }
  9362. };
  9363. uniForm.addField(ctx);
  9364. onBeforeUnmount(() => {
  9365. uniForm.removeField(ctx);
  9366. });
  9367. }
  9368. function getSelectedTextRange(_, resolve) {
  9369. const activeElement = document.activeElement;
  9370. if (!activeElement) {
  9371. return resolve({});
  9372. }
  9373. const data = {};
  9374. if (["input", "textarea"].includes(activeElement.tagName.toLowerCase())) {
  9375. data.start = activeElement.selectionStart;
  9376. data.end = activeElement.selectionEnd;
  9377. }
  9378. resolve(data);
  9379. }
  9380. const UniViewJSBridgeSubscribe = function() {
  9381. registerViewMethod(
  9382. getCurrentPageId(),
  9383. "getSelectedTextRange",
  9384. getSelectedTextRange
  9385. );
  9386. };
  9387. function getValueString(value, type) {
  9388. if (type === "number" && isNaN(Number(value))) {
  9389. value = "";
  9390. }
  9391. return value === null ? "" : String(value);
  9392. }
  9393. const INPUT_MODES = [
  9394. "none",
  9395. "text",
  9396. "decimal",
  9397. "numeric",
  9398. "tel",
  9399. "search",
  9400. "email",
  9401. "url"
  9402. ];
  9403. const props$r = /* @__PURE__ */ extend(
  9404. {},
  9405. {
  9406. name: {
  9407. type: String,
  9408. default: ""
  9409. },
  9410. modelValue: {
  9411. type: [String, Number],
  9412. default: ""
  9413. },
  9414. value: {
  9415. type: [String, Number],
  9416. default: ""
  9417. },
  9418. disabled: {
  9419. type: [Boolean, String],
  9420. default: false
  9421. },
  9422. /**
  9423. * 已废弃属性,用于历史兼容
  9424. */
  9425. autoFocus: {
  9426. type: [Boolean, String],
  9427. default: false
  9428. },
  9429. focus: {
  9430. type: [Boolean, String],
  9431. default: false
  9432. },
  9433. cursor: {
  9434. type: [Number, String],
  9435. default: -1
  9436. },
  9437. selectionStart: {
  9438. type: [Number, String],
  9439. default: -1
  9440. },
  9441. selectionEnd: {
  9442. type: [Number, String],
  9443. default: -1
  9444. },
  9445. type: {
  9446. type: String,
  9447. default: "text"
  9448. },
  9449. password: {
  9450. type: [Boolean, String],
  9451. default: false
  9452. },
  9453. placeholder: {
  9454. type: String,
  9455. default: ""
  9456. },
  9457. placeholderStyle: {
  9458. type: String,
  9459. default: ""
  9460. },
  9461. placeholderClass: {
  9462. type: String,
  9463. default: ""
  9464. },
  9465. maxlength: {
  9466. type: [Number, String],
  9467. default: 140
  9468. },
  9469. confirmType: {
  9470. type: String,
  9471. default: "done"
  9472. },
  9473. confirmHold: {
  9474. type: Boolean,
  9475. default: false
  9476. },
  9477. ignoreCompositionEvent: {
  9478. type: Boolean,
  9479. default: true
  9480. },
  9481. step: {
  9482. type: String,
  9483. default: "0.000000000000000001"
  9484. },
  9485. inputmode: {
  9486. type: String,
  9487. default: void 0,
  9488. validator: (value) => !!~INPUT_MODES.indexOf(value)
  9489. },
  9490. cursorColor: {
  9491. type: String,
  9492. default: ""
  9493. }
  9494. },
  9495. props$u
  9496. );
  9497. const emit = [
  9498. "input",
  9499. "focus",
  9500. "blur",
  9501. "update:value",
  9502. "update:modelValue",
  9503. "update:focus",
  9504. "compositionstart",
  9505. "compositionupdate",
  9506. "compositionend",
  9507. ...emit$1
  9508. ];
  9509. function useBase(props2, rootRef, emit2) {
  9510. const fieldRef = ref(null);
  9511. const trigger = useCustomEvent(rootRef, emit2);
  9512. const selectionStart = computed(() => {
  9513. const selectionStart2 = Number(props2.selectionStart);
  9514. return isNaN(selectionStart2) ? -1 : selectionStart2;
  9515. });
  9516. const selectionEnd = computed(() => {
  9517. const selectionEnd2 = Number(props2.selectionEnd);
  9518. return isNaN(selectionEnd2) ? -1 : selectionEnd2;
  9519. });
  9520. const cursor = computed(() => {
  9521. const cursor2 = Number(props2.cursor);
  9522. return isNaN(cursor2) ? -1 : cursor2;
  9523. });
  9524. const maxlength = computed(() => {
  9525. var maxlength2 = Number(props2.maxlength);
  9526. return isNaN(maxlength2) ? 140 : maxlength2;
  9527. });
  9528. const value = getValueString(props2.modelValue, props2.type) || getValueString(props2.value, props2.type);
  9529. const state2 = reactive({
  9530. value,
  9531. valueOrigin: value,
  9532. maxlength,
  9533. focus: props2.focus,
  9534. composing: false,
  9535. selectionStart,
  9536. selectionEnd,
  9537. cursor
  9538. });
  9539. watch(
  9540. () => state2.focus,
  9541. (val) => emit2("update:focus", val)
  9542. );
  9543. watch(
  9544. () => state2.maxlength,
  9545. (val) => state2.value = state2.value.slice(0, val)
  9546. );
  9547. return {
  9548. fieldRef,
  9549. state: state2,
  9550. trigger
  9551. };
  9552. }
  9553. function useValueSync(props2, state2, emit2, trigger) {
  9554. const valueChangeFn = debounce(
  9555. (val) => {
  9556. state2.value = getValueString(val, props2.type);
  9557. },
  9558. 100,
  9559. { setTimeout, clearTimeout }
  9560. );
  9561. watch(() => props2.modelValue, valueChangeFn);
  9562. watch(() => props2.value, valueChangeFn);
  9563. const triggerInputFn = throttle((event, detail) => {
  9564. valueChangeFn.cancel();
  9565. emit2("update:modelValue", detail.value);
  9566. emit2("update:value", detail.value);
  9567. trigger("input", event, detail);
  9568. }, 100);
  9569. const triggerInput = (event, detail, force) => {
  9570. valueChangeFn.cancel();
  9571. triggerInputFn(event, detail);
  9572. if (force) {
  9573. triggerInputFn.flush();
  9574. }
  9575. };
  9576. onBeforeMount(() => {
  9577. valueChangeFn.cancel();
  9578. triggerInputFn.cancel();
  9579. });
  9580. return {
  9581. trigger,
  9582. triggerInput
  9583. };
  9584. }
  9585. function useAutoFocus(props2, fieldRef) {
  9586. useUserAction();
  9587. const needFocus = computed(() => props2.autoFocus || props2.focus);
  9588. function focus() {
  9589. if (!needFocus.value) {
  9590. return;
  9591. }
  9592. const field = fieldRef.value;
  9593. if (!field || false) {
  9594. setTimeout(focus, 100);
  9595. return;
  9596. }
  9597. {
  9598. field.focus();
  9599. }
  9600. }
  9601. function blur() {
  9602. const field = fieldRef.value;
  9603. if (field) {
  9604. field.blur();
  9605. }
  9606. }
  9607. watch(
  9608. () => props2.focus,
  9609. (value) => {
  9610. if (value) {
  9611. focus();
  9612. } else {
  9613. blur();
  9614. }
  9615. }
  9616. );
  9617. onMounted(() => {
  9618. if (needFocus.value) {
  9619. nextTick(focus);
  9620. }
  9621. });
  9622. }
  9623. function useEvent(fieldRef, state2, props2, trigger, triggerInput, beforeInput) {
  9624. function checkSelection() {
  9625. const field = fieldRef.value;
  9626. if (field && state2.focus && state2.selectionStart > -1 && state2.selectionEnd > -1 && field.type !== "number") {
  9627. field.selectionStart = state2.selectionStart;
  9628. field.selectionEnd = state2.selectionEnd;
  9629. }
  9630. }
  9631. function checkCursor() {
  9632. const field = fieldRef.value;
  9633. if (field && state2.focus && state2.selectionStart < 0 && state2.selectionEnd < 0 && state2.cursor > -1 && field.type !== "number") {
  9634. field.selectionEnd = field.selectionStart = state2.cursor;
  9635. }
  9636. }
  9637. function getFieldSelectionEnd(field) {
  9638. if (field.type === "number") {
  9639. return null;
  9640. } else {
  9641. return field.selectionEnd;
  9642. }
  9643. }
  9644. function initField() {
  9645. const field = fieldRef.value;
  9646. if (!field)
  9647. return;
  9648. const onFocus = function(event) {
  9649. state2.focus = true;
  9650. trigger("focus", event, {
  9651. value: state2.value
  9652. });
  9653. checkSelection();
  9654. checkCursor();
  9655. };
  9656. const onInput = function(event, force) {
  9657. event.stopPropagation();
  9658. if (isFunction(beforeInput) && beforeInput(event, state2) === false) {
  9659. return;
  9660. }
  9661. state2.value = field.value;
  9662. if (!state2.composing || !props2.ignoreCompositionEvent) {
  9663. triggerInput(
  9664. event,
  9665. {
  9666. value: field.value,
  9667. cursor: getFieldSelectionEnd(field)
  9668. },
  9669. force
  9670. );
  9671. }
  9672. };
  9673. const onBlur = function(event) {
  9674. if (state2.composing) {
  9675. state2.composing = false;
  9676. onInput(event, true);
  9677. }
  9678. state2.focus = false;
  9679. trigger("blur", event, {
  9680. value: state2.value,
  9681. cursor: getFieldSelectionEnd(event.target)
  9682. });
  9683. };
  9684. field.addEventListener("change", (event) => event.stopPropagation());
  9685. field.addEventListener("focus", onFocus);
  9686. field.addEventListener("blur", onBlur);
  9687. field.addEventListener("input", onInput);
  9688. field.addEventListener("compositionstart", (event) => {
  9689. event.stopPropagation();
  9690. state2.composing = true;
  9691. _onComposition(event);
  9692. });
  9693. field.addEventListener("compositionend", (event) => {
  9694. event.stopPropagation();
  9695. if (state2.composing) {
  9696. state2.composing = false;
  9697. onInput(event);
  9698. }
  9699. _onComposition(event);
  9700. });
  9701. field.addEventListener("compositionupdate", _onComposition);
  9702. function _onComposition(event) {
  9703. if (!props2.ignoreCompositionEvent) {
  9704. trigger(event.type, event, {
  9705. value: event.data
  9706. });
  9707. }
  9708. }
  9709. }
  9710. watch([() => state2.selectionStart, () => state2.selectionEnd], checkSelection);
  9711. watch(() => state2.cursor, checkCursor);
  9712. watch(() => fieldRef.value, initField);
  9713. }
  9714. function useField(props2, rootRef, emit2, beforeInput) {
  9715. UniViewJSBridgeSubscribe();
  9716. const { fieldRef, state: state2, trigger } = useBase(props2, rootRef, emit2);
  9717. const { triggerInput } = useValueSync(props2, state2, emit2, trigger);
  9718. useAutoFocus(props2, fieldRef);
  9719. useKeyboard$1(props2, fieldRef);
  9720. const { state: scopedAttrsState } = useScopedAttrs();
  9721. useFormField("name", state2);
  9722. useEvent(fieldRef, state2, props2, trigger, triggerInput, beforeInput);
  9723. const fixDisabledColor = String(navigator.vendor).indexOf("Apple") === 0 && CSS.supports("image-orientation:from-image");
  9724. return {
  9725. fieldRef,
  9726. state: state2,
  9727. scopedAttrsState,
  9728. fixDisabledColor,
  9729. trigger
  9730. };
  9731. }
  9732. const props$q = /* @__PURE__ */ extend({}, props$r, {
  9733. placeholderClass: {
  9734. type: String,
  9735. default: "input-placeholder"
  9736. },
  9737. textContentType: {
  9738. type: String,
  9739. default: ""
  9740. }
  9741. });
  9742. class UniInputElement extends UniElement {
  9743. focus(options) {
  9744. var _a;
  9745. (_a = this.querySelector("input")) == null ? void 0 : _a.focus(options);
  9746. }
  9747. }
  9748. const Input = /* @__PURE__ */ defineBuiltInComponent({
  9749. name: "Input",
  9750. props: props$q,
  9751. emits: ["confirm", ...emit],
  9752. rootElement: {
  9753. name: "uni-input",
  9754. class: UniInputElement
  9755. },
  9756. setup(props2, {
  9757. emit: emit2,
  9758. expose
  9759. }) {
  9760. const INPUT_TYPES = ["text", "number", "idcard", "digit", "password", "tel"];
  9761. const AUTOCOMPLETES = ["off", "one-time-code"];
  9762. const type = computed(() => {
  9763. let type2 = "";
  9764. switch (props2.type) {
  9765. case "text":
  9766. if (props2.confirmType === "search") {
  9767. type2 = "search";
  9768. }
  9769. break;
  9770. case "idcard":
  9771. type2 = "text";
  9772. break;
  9773. case "digit":
  9774. type2 = "number";
  9775. break;
  9776. default:
  9777. type2 = ~INPUT_TYPES.includes(props2.type) ? props2.type : "text";
  9778. break;
  9779. }
  9780. return props2.password ? "password" : type2;
  9781. });
  9782. const autocomplete = computed(() => {
  9783. const camelizeIndex = AUTOCOMPLETES.indexOf(props2.textContentType);
  9784. const kebabCaseIndex = AUTOCOMPLETES.indexOf(hyphenate(props2.textContentType));
  9785. const index2 = camelizeIndex !== -1 ? camelizeIndex : kebabCaseIndex !== -1 ? kebabCaseIndex : 0;
  9786. return AUTOCOMPLETES[index2];
  9787. });
  9788. let cache = ref("");
  9789. let resetCache;
  9790. const rootRef = ref(null);
  9791. const {
  9792. fieldRef,
  9793. state: state2,
  9794. scopedAttrsState,
  9795. fixDisabledColor,
  9796. trigger
  9797. } = useField(props2, rootRef, emit2, (event, state3) => {
  9798. const input = event.target;
  9799. if (type.value === "number") {
  9800. if (resetCache) {
  9801. input.removeEventListener("blur", resetCache);
  9802. resetCache = null;
  9803. }
  9804. if (input.validity && !input.validity.valid) {
  9805. if ((!cache.value || !input.value) && event.data === "-" || cache.value[0] === "-" && event.inputType === "deleteContentBackward") {
  9806. cache.value = "-";
  9807. state3.value = "";
  9808. resetCache = () => {
  9809. cache.value = input.value = "";
  9810. };
  9811. input.addEventListener("blur", resetCache);
  9812. return false;
  9813. }
  9814. if (cache.value) {
  9815. if (cache.value.indexOf(".") !== -1) {
  9816. if (event.data !== "." && event.inputType === "deleteContentBackward") {
  9817. const dotIndex = cache.value.indexOf(".");
  9818. cache.value = input.value = state3.value = cache.value.slice(0, dotIndex);
  9819. return true;
  9820. }
  9821. } else if (event.data === ".") {
  9822. cache.value += ".";
  9823. resetCache = () => {
  9824. cache.value = input.value = cache.value.slice(0, -1);
  9825. };
  9826. input.addEventListener("blur", resetCache);
  9827. return false;
  9828. }
  9829. }
  9830. cache.value = state3.value = input.value = cache.value === "-" ? "" : cache.value;
  9831. return false;
  9832. } else {
  9833. cache.value = input.value;
  9834. }
  9835. const maxlength = state3.maxlength;
  9836. if (maxlength > 0 && input.value.length > maxlength) {
  9837. input.value = input.value.slice(0, maxlength);
  9838. state3.value = input.value;
  9839. return false;
  9840. }
  9841. }
  9842. });
  9843. watch(() => state2.value, (value) => {
  9844. if (props2.type === "number" && !(cache.value === "-" && value === "")) {
  9845. cache.value = value;
  9846. }
  9847. });
  9848. const NUMBER_TYPES = ["number", "digit"];
  9849. const step = computed(() => NUMBER_TYPES.includes(props2.type) ? props2.step : "");
  9850. function onKeyUpEnter(event) {
  9851. if (event.key !== "Enter") {
  9852. return;
  9853. }
  9854. const input = event.target;
  9855. event.stopPropagation();
  9856. trigger("confirm", event, {
  9857. value: input.value
  9858. });
  9859. !props2.confirmHold && input.blur();
  9860. }
  9861. expose({
  9862. $triggerInput: (detail) => {
  9863. emit2("update:modelValue", detail.value);
  9864. emit2("update:value", detail.value);
  9865. state2.value = detail.value;
  9866. }
  9867. });
  9868. onMounted(() => {
  9869. const rootElement = rootRef.value;
  9870. Object.defineProperty(rootElement, "value", {
  9871. get() {
  9872. return rootElement.querySelector("input").value;
  9873. },
  9874. set(value) {
  9875. rootElement.querySelector("input").value = value;
  9876. }
  9877. });
  9878. rootElement.attachVmProps(props2);
  9879. });
  9880. return () => {
  9881. let inputNode = props2.disabled && fixDisabledColor ? createVNode("input", {
  9882. "key": "disabled-input",
  9883. "ref": fieldRef,
  9884. "value": state2.value,
  9885. "tabindex": "-1",
  9886. "readonly": !!props2.disabled,
  9887. "type": type.value,
  9888. "maxlength": state2.maxlength,
  9889. "step": step.value,
  9890. "class": "uni-input-input",
  9891. "style": props2.cursorColor ? {
  9892. caretColor: props2.cursorColor
  9893. } : {},
  9894. "onFocus": (event) => event.target.blur()
  9895. }, null, 44, ["value", "readonly", "type", "maxlength", "step", "onFocus"]) : withDirectives(createVNode("input", {
  9896. "key": "input",
  9897. "ref": fieldRef,
  9898. "onUpdate:modelValue": ($event) => state2.value = $event,
  9899. "disabled": !!props2.disabled,
  9900. "type": type.value,
  9901. "maxlength": state2.maxlength,
  9902. "step": step.value,
  9903. "enterkeyhint": props2.confirmType,
  9904. "pattern": props2.type === "number" ? "[0-9]*" : void 0,
  9905. "class": "uni-input-input",
  9906. "style": props2.cursorColor ? {
  9907. caretColor: props2.cursorColor
  9908. } : {},
  9909. "autocomplete": autocomplete.value,
  9910. "onKeyup": onKeyUpEnter,
  9911. "inputmode": props2.inputmode
  9912. }, null, 44, ["onUpdate:modelValue", "disabled", "type", "maxlength", "step", "enterkeyhint", "pattern", "autocomplete", "onKeyup", "inputmode"]), [[vModelDynamic, state2.value]]);
  9913. return createVNode("uni-input", {
  9914. "ref": rootRef
  9915. }, [createVNode("div", {
  9916. "class": "uni-input-wrapper"
  9917. }, [withDirectives(createVNode("div", mergeProps(scopedAttrsState.attrs, {
  9918. "style": props2.placeholderStyle,
  9919. "class": ["uni-input-placeholder", props2.placeholderClass]
  9920. }), [props2.placeholder], 16), [[vShow, !(state2.value.length || cache.value === "-")]]), props2.confirmType === "search" ? createVNode("form", {
  9921. "action": "",
  9922. "onSubmit": (event) => event.preventDefault(),
  9923. "class": "uni-input-form"
  9924. }, [inputNode], 40, ["onSubmit"]) : inputNode])], 512);
  9925. };
  9926. }
  9927. });
  9928. function entries(obj) {
  9929. return Object.keys(obj).map((key) => [key, obj[key]]);
  9930. }
  9931. const DEFAULT_EXCLUDE_KEYS = ["class", "style"];
  9932. const LISTENER_PREFIX = /^on[A-Z]+/;
  9933. const useAttrs = (params = {}) => {
  9934. const { excludeListeners = false, excludeKeys = [] } = params;
  9935. const instance2 = getCurrentInstance();
  9936. const attrs2 = shallowRef({});
  9937. const listeners2 = shallowRef({});
  9938. const excludeAttrs = shallowRef({});
  9939. const allExcludeKeys = excludeKeys.concat(DEFAULT_EXCLUDE_KEYS);
  9940. instance2.attrs = reactive(instance2.attrs);
  9941. watchEffect(() => {
  9942. const res = entries(instance2.attrs).reduce(
  9943. (acc, [key, val]) => {
  9944. if (allExcludeKeys.includes(key)) {
  9945. acc.exclude[key] = val;
  9946. } else if (LISTENER_PREFIX.test(key)) {
  9947. if (!excludeListeners) {
  9948. acc.attrs[key] = val;
  9949. }
  9950. acc.listeners[key] = val;
  9951. } else {
  9952. acc.attrs[key] = val;
  9953. }
  9954. return acc;
  9955. },
  9956. {
  9957. exclude: {},
  9958. attrs: {},
  9959. listeners: {}
  9960. }
  9961. );
  9962. attrs2.value = res.attrs;
  9963. listeners2.value = res.listeners;
  9964. excludeAttrs.value = res.exclude;
  9965. });
  9966. return { $attrs: attrs2, $listeners: listeners2, $excludeAttrs: excludeAttrs };
  9967. };
  9968. function flatVNode(nodes) {
  9969. const array = [];
  9970. if (isArray(nodes)) {
  9971. nodes.forEach((vnode) => {
  9972. if (isVNode(vnode)) {
  9973. if (vnode.type === Fragment) {
  9974. array.push(...flatVNode(vnode.children));
  9975. } else {
  9976. array.push(vnode);
  9977. }
  9978. } else if (isArray(vnode)) {
  9979. array.push(...flatVNode(vnode));
  9980. }
  9981. });
  9982. }
  9983. return array;
  9984. }
  9985. const movableAreaProps = {
  9986. scaleArea: {
  9987. type: Boolean,
  9988. default: false
  9989. }
  9990. };
  9991. class UniMovableAreaElement extends UniElement {
  9992. }
  9993. const MovableArea = /* @__PURE__ */ defineBuiltInComponent({
  9994. inheritAttrs: false,
  9995. name: "MovableArea",
  9996. props: movableAreaProps,
  9997. rootElement: {
  9998. name: "uni-movable-area",
  9999. class: UniMovableAreaElement
  10000. },
  10001. setup(props2, {
  10002. slots
  10003. }) {
  10004. const rootRef = ref(null);
  10005. const _isMounted = ref(false);
  10006. let {
  10007. setContexts,
  10008. events: movableAreaEvents
  10009. } = useMovableAreaState(props2, rootRef);
  10010. const {
  10011. $listeners,
  10012. $attrs,
  10013. $excludeAttrs
  10014. } = useAttrs();
  10015. const _listeners = $listeners.value;
  10016. let events = ["onTouchstart", "onTouchmove", "onTouchend"];
  10017. events.forEach((event) => {
  10018. let existing = _listeners[event];
  10019. let ours = movableAreaEvents[`_${event}`];
  10020. _listeners[event] = existing ? [].concat(existing, ours) : ours;
  10021. });
  10022. onMounted(() => {
  10023. movableAreaEvents._resize();
  10024. _isMounted.value = true;
  10025. });
  10026. let movableViewItems = [];
  10027. const originMovableViewContexts = [];
  10028. function updateMovableViewContexts() {
  10029. const contexts = [];
  10030. for (let index2 = 0; index2 < movableViewItems.length; index2++) {
  10031. let movableViewItem = movableViewItems[index2];
  10032. {
  10033. movableViewItem = movableViewItem.el;
  10034. }
  10035. const movableViewContext = originMovableViewContexts.find((context) => movableViewItem === context.rootRef.value);
  10036. if (movableViewContext) {
  10037. contexts.push(markRaw(movableViewContext));
  10038. }
  10039. }
  10040. setContexts(contexts);
  10041. }
  10042. const addMovableViewContext = (movableViewContext) => {
  10043. originMovableViewContexts.push(movableViewContext);
  10044. updateMovableViewContexts();
  10045. };
  10046. const removeMovableViewContext = (movableViewContext) => {
  10047. const index2 = originMovableViewContexts.indexOf(movableViewContext);
  10048. if (index2 >= 0) {
  10049. originMovableViewContexts.splice(index2, 1);
  10050. updateMovableViewContexts();
  10051. }
  10052. };
  10053. provide("_isMounted", _isMounted);
  10054. provide("movableAreaRootRef", rootRef);
  10055. provide("addMovableViewContext", addMovableViewContext);
  10056. provide("removeMovableViewContext", removeMovableViewContext);
  10057. onMounted(() => {
  10058. const rootElement = rootRef.value;
  10059. rootElement.attachVmProps(props2);
  10060. });
  10061. return () => {
  10062. const defaultSlots = slots.default && slots.default();
  10063. {
  10064. movableViewItems = flatVNode(defaultSlots);
  10065. }
  10066. return createVNode("uni-movable-area", mergeProps({
  10067. "ref": rootRef
  10068. }, $attrs.value, $excludeAttrs.value, _listeners), [createVNode(ResizeSensor, {
  10069. "onResize": movableAreaEvents._resize
  10070. }, null, 8, ["onResize"]), movableViewItems], 16);
  10071. };
  10072. }
  10073. });
  10074. function calc(e2) {
  10075. return Math.sqrt(e2.x * e2.x + e2.y * e2.y);
  10076. }
  10077. function useMovableAreaState(props2, rootRef) {
  10078. const width = ref(0);
  10079. const height = ref(0);
  10080. const gapV = reactive({
  10081. x: null,
  10082. y: null
  10083. });
  10084. const pinchStartLen = ref(null);
  10085. let _scaleMovableView = null;
  10086. let movableViewContexts = [];
  10087. function _updateScale(e2) {
  10088. if (e2 && e2 !== 1) {
  10089. if (props2.scaleArea) {
  10090. movableViewContexts.forEach(function(item) {
  10091. item._setScale(e2);
  10092. });
  10093. } else {
  10094. if (_scaleMovableView) {
  10095. _scaleMovableView._setScale(e2);
  10096. }
  10097. }
  10098. }
  10099. }
  10100. function _find(target, items = movableViewContexts) {
  10101. let root = rootRef.value;
  10102. function get(node) {
  10103. for (let i = 0; i < items.length; i++) {
  10104. const item = items[i];
  10105. if (node === item.rootRef.value) {
  10106. return item;
  10107. }
  10108. }
  10109. if (node === root || node === document.body || node === document) {
  10110. return null;
  10111. }
  10112. return get(node.parentNode);
  10113. }
  10114. return get(target);
  10115. }
  10116. const _onTouchstart = withWebEvent((t2) => {
  10117. let i = t2.touches;
  10118. if (i) {
  10119. if (i.length > 1) {
  10120. let r = {
  10121. x: i[1].pageX - i[0].pageX,
  10122. y: i[1].pageY - i[0].pageY
  10123. };
  10124. pinchStartLen.value = calc(r);
  10125. gapV.x = r.x;
  10126. gapV.y = r.y;
  10127. if (!props2.scaleArea) {
  10128. let touch0 = _find(i[0].target);
  10129. let touch1 = _find(i[1].target);
  10130. _scaleMovableView = touch0 && touch0 === touch1 ? touch0 : null;
  10131. }
  10132. }
  10133. }
  10134. });
  10135. const _onTouchmove = withWebEvent((t2) => {
  10136. let n = t2.touches;
  10137. if (n) {
  10138. if (n.length > 1) {
  10139. t2.preventDefault();
  10140. let i = {
  10141. x: n[1].pageX - n[0].pageX,
  10142. y: n[1].pageY - n[0].pageY
  10143. };
  10144. if (gapV.x !== null && pinchStartLen.value && pinchStartLen.value > 0) {
  10145. let r = calc(i) / pinchStartLen.value;
  10146. _updateScale(r);
  10147. }
  10148. gapV.x = i.x;
  10149. gapV.y = i.y;
  10150. }
  10151. }
  10152. });
  10153. const _onTouchend = withWebEvent((e2) => {
  10154. let t2 = e2.touches;
  10155. if (!(t2 && t2.length)) {
  10156. if (e2.changedTouches) {
  10157. gapV.x = 0;
  10158. gapV.y = 0;
  10159. pinchStartLen.value = null;
  10160. if (props2.scaleArea) {
  10161. movableViewContexts.forEach(function(item) {
  10162. item._endScale();
  10163. });
  10164. } else {
  10165. if (_scaleMovableView) {
  10166. _scaleMovableView._endScale();
  10167. }
  10168. }
  10169. }
  10170. }
  10171. });
  10172. function _resize() {
  10173. _getWH();
  10174. movableViewContexts.forEach(function(item, index2) {
  10175. item.setParent();
  10176. });
  10177. }
  10178. function _getWH() {
  10179. let style = window.getComputedStyle(rootRef.value);
  10180. let rect = rootRef.value.getBoundingClientRect();
  10181. width.value = rect.width - ["Left", "Right"].reduce(function(all, item) {
  10182. const LEFT = "border" + item + "Width";
  10183. const RIGHT = "padding" + item;
  10184. return all + parseFloat(style[LEFT]) + parseFloat(style[RIGHT]);
  10185. }, 0);
  10186. height.value = rect.height - ["Top", "Bottom"].reduce(function(all, item) {
  10187. const TOP = "border" + item + "Width";
  10188. const BOTTOM = "padding" + item;
  10189. return all + parseFloat(style[TOP]) + parseFloat(style[BOTTOM]);
  10190. }, 0);
  10191. }
  10192. provide("movableAreaWidth", width);
  10193. provide("movableAreaHeight", height);
  10194. return {
  10195. setContexts(contexts) {
  10196. movableViewContexts = contexts;
  10197. },
  10198. events: {
  10199. _onTouchstart,
  10200. _onTouchmove,
  10201. _onTouchend,
  10202. _resize
  10203. }
  10204. };
  10205. }
  10206. const addListenerToElement = function(element, type, callback, capture) {
  10207. element.addEventListener(
  10208. type,
  10209. ($event) => {
  10210. if (isFunction(callback)) {
  10211. if (callback($event) === false) {
  10212. if (typeof $event.cancelable !== "undefined" ? $event.cancelable : true) {
  10213. $event.preventDefault();
  10214. }
  10215. $event.stopPropagation();
  10216. }
  10217. }
  10218. },
  10219. {
  10220. passive: false
  10221. }
  10222. );
  10223. };
  10224. let __mouseMoveEventListener;
  10225. let __mouseUpEventListener;
  10226. function useTouchtrack(element, method, useCancel) {
  10227. onBeforeUnmount(() => {
  10228. document.removeEventListener("mousemove", __mouseMoveEventListener);
  10229. document.removeEventListener("mouseup", __mouseUpEventListener);
  10230. });
  10231. let x0 = 0;
  10232. let y0 = 0;
  10233. let x1 = 0;
  10234. let y1 = 0;
  10235. const fn = function($event, state2, x, y) {
  10236. if (method({
  10237. // @ts-expect-error
  10238. cancelable: $event.cancelable,
  10239. target: $event.target,
  10240. currentTarget: $event.currentTarget,
  10241. preventDefault: $event.preventDefault.bind($event),
  10242. stopPropagation: $event.stopPropagation.bind($event),
  10243. touches: $event.touches,
  10244. changedTouches: $event.changedTouches,
  10245. detail: {
  10246. state: state2,
  10247. x,
  10248. y,
  10249. dx: x - x0,
  10250. dy: y - y0,
  10251. ddx: x - x1,
  10252. ddy: y - y1,
  10253. timeStamp: $event.timeStamp
  10254. }
  10255. }) === false) {
  10256. return false;
  10257. }
  10258. };
  10259. let $eventOld = null;
  10260. let hasTouchStart;
  10261. let hasMouseDown;
  10262. addListenerToElement(element, "touchstart", function($event) {
  10263. hasTouchStart = true;
  10264. if ($event.touches.length === 1 && !$eventOld) {
  10265. $eventOld = $event;
  10266. x0 = x1 = $event.touches[0].pageX;
  10267. y0 = y1 = $event.touches[0].pageY;
  10268. return fn($event, "start", x0, y0);
  10269. }
  10270. });
  10271. addListenerToElement(element, "mousedown", function($event) {
  10272. hasMouseDown = true;
  10273. if (!hasTouchStart && !$eventOld) {
  10274. $eventOld = $event;
  10275. x0 = x1 = $event.pageX;
  10276. y0 = y1 = $event.pageY;
  10277. return fn($event, "start", x0, y0);
  10278. }
  10279. });
  10280. addListenerToElement(element, "touchmove", function($event) {
  10281. if ($event.touches.length === 1 && $eventOld) {
  10282. const res = fn(
  10283. $event,
  10284. "move",
  10285. $event.touches[0].pageX,
  10286. $event.touches[0].pageY
  10287. );
  10288. x1 = $event.touches[0].pageX;
  10289. y1 = $event.touches[0].pageY;
  10290. return res;
  10291. }
  10292. });
  10293. const mouseMoveEventListener = __mouseMoveEventListener = function($event) {
  10294. if (!hasTouchStart && hasMouseDown && $eventOld) {
  10295. const res = fn($event, "move", $event.pageX, $event.pageY);
  10296. x1 = $event.pageX;
  10297. y1 = $event.pageY;
  10298. return res;
  10299. }
  10300. };
  10301. document.addEventListener("mousemove", mouseMoveEventListener);
  10302. addListenerToElement(element, "touchend", function($event) {
  10303. if ($event.touches.length === 0 && $eventOld) {
  10304. hasTouchStart = false;
  10305. $eventOld = null;
  10306. return fn(
  10307. $event,
  10308. "end",
  10309. $event.changedTouches[0].pageX,
  10310. $event.changedTouches[0].pageY
  10311. );
  10312. }
  10313. });
  10314. const mouseUpEventListener = __mouseUpEventListener = function($event) {
  10315. hasMouseDown = false;
  10316. if (!hasTouchStart && $eventOld) {
  10317. $eventOld = null;
  10318. return fn($event, "end", $event.pageX, $event.pageY);
  10319. }
  10320. };
  10321. document.addEventListener("mouseup", mouseUpEventListener);
  10322. addListenerToElement(element, "touchcancel", function($event) {
  10323. if ($eventOld) {
  10324. hasTouchStart = false;
  10325. const $eventTemp = $eventOld;
  10326. $eventOld = null;
  10327. return fn(
  10328. $event,
  10329. useCancel ? "cancel" : "end",
  10330. $eventTemp.touches[0].pageX,
  10331. $eventTemp.touches[0].pageY
  10332. );
  10333. }
  10334. });
  10335. }
  10336. function e(e2, t2, n) {
  10337. return e2 > t2 - n && e2 < t2 + n;
  10338. }
  10339. function t(t2, n) {
  10340. return e(t2, 0, n);
  10341. }
  10342. function Decline() {
  10343. }
  10344. Decline.prototype.x = function(e2) {
  10345. return Math.sqrt(e2);
  10346. };
  10347. function Friction$1(e2, t2) {
  10348. this._m = e2;
  10349. this._f = 1e3 * t2;
  10350. this._startTime = 0;
  10351. this._v = 0;
  10352. }
  10353. Friction$1.prototype.setV = function(x, y) {
  10354. const n = Math.pow(Math.pow(x, 2) + Math.pow(y, 2), 0.5);
  10355. this._x_v = x;
  10356. this._y_v = y;
  10357. this._x_a = -this._f * this._x_v / n;
  10358. this._y_a = -this._f * this._y_v / n;
  10359. this._t = Math.abs(x / this._x_a) || Math.abs(y / this._y_a);
  10360. this._lastDt = null;
  10361. this._startTime = (/* @__PURE__ */ new Date()).getTime();
  10362. };
  10363. Friction$1.prototype.setS = function(x, y) {
  10364. this._x_s = x;
  10365. this._y_s = y;
  10366. };
  10367. Friction$1.prototype.s = function(t2) {
  10368. if (void 0 === t2) {
  10369. t2 = ((/* @__PURE__ */ new Date()).getTime() - this._startTime) / 1e3;
  10370. }
  10371. if (t2 > this._t) {
  10372. t2 = this._t;
  10373. this._lastDt = t2;
  10374. }
  10375. let x = this._x_v * t2 + 0.5 * this._x_a * Math.pow(t2, 2) + this._x_s;
  10376. let y = this._y_v * t2 + 0.5 * this._y_a * Math.pow(t2, 2) + this._y_s;
  10377. if (this._x_a > 0 && x < this._endPositionX || this._x_a < 0 && x > this._endPositionX) {
  10378. x = this._endPositionX;
  10379. }
  10380. if (this._y_a > 0 && y < this._endPositionY || this._y_a < 0 && y > this._endPositionY) {
  10381. y = this._endPositionY;
  10382. }
  10383. return {
  10384. x,
  10385. y
  10386. };
  10387. };
  10388. Friction$1.prototype.ds = function(t2) {
  10389. if (void 0 === t2) {
  10390. t2 = ((/* @__PURE__ */ new Date()).getTime() - this._startTime) / 1e3;
  10391. }
  10392. if (t2 > this._t) {
  10393. t2 = this._t;
  10394. }
  10395. return {
  10396. dx: this._x_v + this._x_a * t2,
  10397. dy: this._y_v + this._y_a * t2
  10398. };
  10399. };
  10400. Friction$1.prototype.delta = function() {
  10401. return {
  10402. x: -1.5 * Math.pow(this._x_v, 2) / this._x_a || 0,
  10403. y: -1.5 * Math.pow(this._y_v, 2) / this._y_a || 0
  10404. };
  10405. };
  10406. Friction$1.prototype.dt = function() {
  10407. return -this._x_v / this._x_a;
  10408. };
  10409. Friction$1.prototype.done = function() {
  10410. const t2 = e(this.s().x, this._endPositionX) || e(this.s().y, this._endPositionY) || this._lastDt === this._t;
  10411. this._lastDt = null;
  10412. return t2;
  10413. };
  10414. Friction$1.prototype.setEnd = function(x, y) {
  10415. this._endPositionX = x;
  10416. this._endPositionY = y;
  10417. };
  10418. Friction$1.prototype.reconfigure = function(m, f2) {
  10419. this._m = m;
  10420. this._f = 1e3 * f2;
  10421. };
  10422. function Spring$1(m, k, c) {
  10423. this._m = m;
  10424. this._k = k;
  10425. this._c = c;
  10426. this._solution = null;
  10427. this._endPosition = 0;
  10428. this._startTime = 0;
  10429. }
  10430. Spring$1.prototype._solve = function(e2, t2) {
  10431. const n = this._c;
  10432. const i = this._m;
  10433. const r = this._k;
  10434. const o2 = n * n - 4 * i * r;
  10435. if (o2 === 0) {
  10436. const a2 = -n / (2 * i);
  10437. const s = e2;
  10438. const l = t2 / (a2 * e2);
  10439. return {
  10440. x: function(e3) {
  10441. return (s + l * e3) * Math.pow(Math.E, a2 * e3);
  10442. },
  10443. dx: function(e3) {
  10444. const t3 = Math.pow(Math.E, a2 * e3);
  10445. return a2 * (s + l * e3) * t3 + l * t3;
  10446. }
  10447. };
  10448. }
  10449. if (o2 > 0) {
  10450. const c = (-n - Math.sqrt(o2)) / (2 * i);
  10451. const u = (-n + Math.sqrt(o2)) / (2 * i);
  10452. const d = (t2 - c * e2) / (u - c);
  10453. const h2 = e2 - d;
  10454. return {
  10455. x: function(e3) {
  10456. let t3;
  10457. let n2;
  10458. if (e3 === this._t) {
  10459. t3 = this._powER1T;
  10460. n2 = this._powER2T;
  10461. }
  10462. this._t = e3;
  10463. if (!t3) {
  10464. t3 = this._powER1T = Math.pow(Math.E, c * e3);
  10465. }
  10466. if (!n2) {
  10467. n2 = this._powER2T = Math.pow(Math.E, u * e3);
  10468. }
  10469. return h2 * t3 + d * n2;
  10470. },
  10471. dx: function(e3) {
  10472. let t3;
  10473. let n2;
  10474. if (e3 === this._t) {
  10475. t3 = this._powER1T;
  10476. n2 = this._powER2T;
  10477. }
  10478. this._t = e3;
  10479. if (!t3) {
  10480. t3 = this._powER1T = Math.pow(Math.E, c * e3);
  10481. }
  10482. if (!n2) {
  10483. n2 = this._powER2T = Math.pow(Math.E, u * e3);
  10484. }
  10485. return h2 * c * t3 + d * u * n2;
  10486. }
  10487. };
  10488. }
  10489. const p2 = Math.sqrt(4 * i * r - n * n) / (2 * i);
  10490. const f2 = -n / 2 * i;
  10491. const v2 = e2;
  10492. const g2 = (t2 - f2 * e2) / p2;
  10493. return {
  10494. x: function(e3) {
  10495. return Math.pow(Math.E, f2 * e3) * (v2 * Math.cos(p2 * e3) + g2 * Math.sin(p2 * e3));
  10496. },
  10497. dx: function(e3) {
  10498. const t3 = Math.pow(Math.E, f2 * e3);
  10499. const n2 = Math.cos(p2 * e3);
  10500. const i2 = Math.sin(p2 * e3);
  10501. return t3 * (g2 * p2 * n2 - v2 * p2 * i2) + f2 * t3 * (g2 * i2 + v2 * n2);
  10502. }
  10503. };
  10504. };
  10505. Spring$1.prototype.x = function(e2) {
  10506. if (void 0 === e2) {
  10507. e2 = ((/* @__PURE__ */ new Date()).getTime() - this._startTime) / 1e3;
  10508. }
  10509. return this._solution ? this._endPosition + this._solution.x(e2) : 0;
  10510. };
  10511. Spring$1.prototype.dx = function(e2) {
  10512. if (void 0 === e2) {
  10513. e2 = ((/* @__PURE__ */ new Date()).getTime() - this._startTime) / 1e3;
  10514. }
  10515. return this._solution ? this._solution.dx(e2) : 0;
  10516. };
  10517. Spring$1.prototype.setEnd = function(e2, n, i) {
  10518. if (!i) {
  10519. i = (/* @__PURE__ */ new Date()).getTime();
  10520. }
  10521. if (e2 !== this._endPosition || !t(n, 0.1)) {
  10522. n = n || 0;
  10523. let r = this._endPosition;
  10524. if (this._solution) {
  10525. if (t(n, 0.1)) {
  10526. n = this._solution.dx((i - this._startTime) / 1e3);
  10527. }
  10528. r = this._solution.x((i - this._startTime) / 1e3);
  10529. if (t(n, 0.1)) {
  10530. n = 0;
  10531. }
  10532. if (t(r, 0.1)) {
  10533. r = 0;
  10534. }
  10535. r += this._endPosition;
  10536. }
  10537. if (!(this._solution && t(r - e2, 0.1) && t(n, 0.1))) {
  10538. this._endPosition = e2;
  10539. this._solution = this._solve(r - this._endPosition, n);
  10540. this._startTime = i;
  10541. }
  10542. }
  10543. };
  10544. Spring$1.prototype.snap = function(e2) {
  10545. this._startTime = (/* @__PURE__ */ new Date()).getTime();
  10546. this._endPosition = e2;
  10547. this._solution = {
  10548. x: function() {
  10549. return 0;
  10550. },
  10551. dx: function() {
  10552. return 0;
  10553. }
  10554. };
  10555. };
  10556. Spring$1.prototype.done = function(n) {
  10557. if (!n) {
  10558. n = (/* @__PURE__ */ new Date()).getTime();
  10559. }
  10560. return e(this.x(), this._endPosition, 0.1) && t(this.dx(), 0.1);
  10561. };
  10562. Spring$1.prototype.reconfigure = function(m, t2, c) {
  10563. this._m = m;
  10564. this._k = t2;
  10565. this._c = c;
  10566. if (!this.done()) {
  10567. this._solution = this._solve(this.x() - this._endPosition, this.dx());
  10568. this._startTime = (/* @__PURE__ */ new Date()).getTime();
  10569. }
  10570. };
  10571. Spring$1.prototype.springConstant = function() {
  10572. return this._k;
  10573. };
  10574. Spring$1.prototype.damping = function() {
  10575. return this._c;
  10576. };
  10577. Spring$1.prototype.configuration = function() {
  10578. function e2(e3, t3) {
  10579. e3.reconfigure(1, t3, e3.damping());
  10580. }
  10581. function t2(e3, t3) {
  10582. e3.reconfigure(1, e3.springConstant(), t3);
  10583. }
  10584. return [
  10585. {
  10586. label: "Spring Constant",
  10587. read: this.springConstant.bind(this),
  10588. write: e2.bind(this, this),
  10589. min: 100,
  10590. max: 1e3
  10591. },
  10592. {
  10593. label: "Damping",
  10594. read: this.damping.bind(this),
  10595. write: t2.bind(this, this),
  10596. min: 1,
  10597. max: 500
  10598. }
  10599. ];
  10600. };
  10601. function STD(e2, t2, n) {
  10602. this._springX = new Spring$1(e2, t2, n);
  10603. this._springY = new Spring$1(e2, t2, n);
  10604. this._springScale = new Spring$1(e2, t2, n);
  10605. this._startTime = 0;
  10606. }
  10607. STD.prototype.setEnd = function(e2, t2, n, i) {
  10608. const r = (/* @__PURE__ */ new Date()).getTime();
  10609. this._springX.setEnd(e2, i, r);
  10610. this._springY.setEnd(t2, i, r);
  10611. this._springScale.setEnd(n, i, r);
  10612. this._startTime = r;
  10613. };
  10614. STD.prototype.x = function() {
  10615. const e2 = ((/* @__PURE__ */ new Date()).getTime() - this._startTime) / 1e3;
  10616. return {
  10617. x: this._springX.x(e2),
  10618. y: this._springY.x(e2),
  10619. scale: this._springScale.x(e2)
  10620. };
  10621. };
  10622. STD.prototype.done = function() {
  10623. const e2 = (/* @__PURE__ */ new Date()).getTime();
  10624. return this._springX.done(e2) && this._springY.done(e2) && this._springScale.done(e2);
  10625. };
  10626. STD.prototype.reconfigure = function(e2, t2, n) {
  10627. this._springX.reconfigure(e2, t2, n);
  10628. this._springY.reconfigure(e2, t2, n);
  10629. this._springScale.reconfigure(e2, t2, n);
  10630. };
  10631. const movableViewProps = {
  10632. direction: {
  10633. type: String,
  10634. default: "none"
  10635. },
  10636. inertia: {
  10637. type: [Boolean, String],
  10638. default: false
  10639. },
  10640. outOfBounds: {
  10641. type: [Boolean, String],
  10642. default: false
  10643. },
  10644. x: {
  10645. type: [Number, String],
  10646. default: 0
  10647. },
  10648. y: {
  10649. type: [Number, String],
  10650. default: 0
  10651. },
  10652. damping: {
  10653. type: [Number, String],
  10654. default: 20
  10655. },
  10656. friction: {
  10657. type: [Number, String],
  10658. default: 2
  10659. },
  10660. disabled: {
  10661. type: [Boolean, String],
  10662. default: false
  10663. },
  10664. scale: {
  10665. type: [Boolean, String],
  10666. default: false
  10667. },
  10668. scaleMin: {
  10669. type: [Number, String],
  10670. default: 0.5
  10671. },
  10672. scaleMax: {
  10673. type: [Number, String],
  10674. default: 10
  10675. },
  10676. scaleValue: {
  10677. type: [Number, String],
  10678. default: 1
  10679. },
  10680. animation: {
  10681. type: [Boolean, String],
  10682. default: true
  10683. }
  10684. };
  10685. function v(a2, b) {
  10686. return +((1e3 * a2 - 1e3 * b) / 1e3).toFixed(1);
  10687. }
  10688. class UniMovableViewElement extends UniElement {
  10689. }
  10690. const MovableView = /* @__PURE__ */ defineBuiltInComponent({
  10691. name: "MovableView",
  10692. props: movableViewProps,
  10693. emits: ["change", "scale"],
  10694. rootElement: {
  10695. name: "uni-movable-view",
  10696. class: UniMovableViewElement
  10697. },
  10698. setup(props2, {
  10699. slots,
  10700. emit: emit2
  10701. }) {
  10702. const rootRef = ref(null);
  10703. const trigger = useCustomEvent(rootRef, emit2);
  10704. const {
  10705. setParent
  10706. } = useMovableViewState(props2, trigger, rootRef);
  10707. onMounted(() => {
  10708. const rootElement = rootRef.value;
  10709. rootElement.attachVmProps(props2);
  10710. });
  10711. return () => {
  10712. return createVNode("uni-movable-view", {
  10713. "ref": rootRef
  10714. }, [createVNode(ResizeSensor, {
  10715. "onResize": setParent
  10716. }, null, 8, ["onResize"]), slots.default && slots.default()], 512);
  10717. };
  10718. }
  10719. });
  10720. let requesting = false;
  10721. function _requestAnimationFrame(e2) {
  10722. if (!requesting) {
  10723. requesting = true;
  10724. requestAnimationFrame(function() {
  10725. e2();
  10726. requesting = false;
  10727. });
  10728. }
  10729. }
  10730. function p(t2, n) {
  10731. if (t2 === n) {
  10732. return 0;
  10733. }
  10734. let i = t2.offsetLeft;
  10735. return t2.offsetParent ? i += p(t2.offsetParent, n) : 0;
  10736. }
  10737. function f(t2, n) {
  10738. if (t2 === n) {
  10739. return 0;
  10740. }
  10741. let i = t2.offsetTop;
  10742. return t2.offsetParent ? i += f(t2.offsetParent, n) : 0;
  10743. }
  10744. function g(friction, execute, endCallback) {
  10745. let record = {
  10746. id: 0,
  10747. cancelled: false
  10748. };
  10749. let cancel = function(record2) {
  10750. if (record2 && record2.id) {
  10751. cancelAnimationFrame(record2.id);
  10752. }
  10753. if (record2) {
  10754. record2.cancelled = true;
  10755. }
  10756. };
  10757. function fn(record2, friction2, execute2, endCallback2) {
  10758. if (!record2 || !record2.cancelled) {
  10759. execute2(friction2);
  10760. let isDone = friction2.done();
  10761. if (!isDone) {
  10762. if (!record2.cancelled) {
  10763. record2.id = requestAnimationFrame(fn.bind(null, record2, friction2, execute2, endCallback2));
  10764. }
  10765. }
  10766. if (isDone && endCallback2) {
  10767. endCallback2(friction2);
  10768. }
  10769. }
  10770. }
  10771. fn(record, friction, execute, endCallback);
  10772. return {
  10773. cancel: cancel.bind(null, record),
  10774. model: friction
  10775. };
  10776. }
  10777. function _getPx(val) {
  10778. if (/\d+[ur]px$/i.test(val)) {
  10779. return uni.upx2px(parseFloat(val));
  10780. }
  10781. return Number(val) || 0;
  10782. }
  10783. function useMovableViewLayout(rootRef, _scale, _adjustScale) {
  10784. const movableAreaWidth = inject("movableAreaWidth", ref(0));
  10785. const movableAreaHeight = inject("movableAreaHeight", ref(0));
  10786. const movableAreaRootRef = inject("movableAreaRootRef");
  10787. const _offset = {
  10788. x: 0,
  10789. y: 0
  10790. };
  10791. const _scaleOffset = {
  10792. x: 0,
  10793. y: 0
  10794. };
  10795. const width = ref(0);
  10796. const height = ref(0);
  10797. const minX = ref(0);
  10798. const minY = ref(0);
  10799. const maxX = ref(0);
  10800. const maxY = ref(0);
  10801. function _updateBoundary() {
  10802. let x = 0 - _offset.x + _scaleOffset.x;
  10803. let _width = movableAreaWidth.value - width.value - _offset.x - _scaleOffset.x;
  10804. minX.value = Math.min(x, _width);
  10805. maxX.value = Math.max(x, _width);
  10806. let y = 0 - _offset.y + _scaleOffset.y;
  10807. let _height = movableAreaHeight.value - height.value - _offset.y - _scaleOffset.y;
  10808. minY.value = Math.min(y, _height);
  10809. maxY.value = Math.max(y, _height);
  10810. }
  10811. function _updateOffset() {
  10812. _offset.x = p(rootRef.value, movableAreaRootRef.value);
  10813. _offset.y = f(rootRef.value, movableAreaRootRef.value);
  10814. }
  10815. function _updateWH(scale) {
  10816. scale = scale || _scale.value;
  10817. scale = _adjustScale(scale);
  10818. let rect = rootRef.value.getBoundingClientRect();
  10819. height.value = rect.height / _scale.value;
  10820. width.value = rect.width / _scale.value;
  10821. let _height = height.value * scale;
  10822. let _width = width.value * scale;
  10823. _scaleOffset.x = (_width - width.value) / 2;
  10824. _scaleOffset.y = (_height - height.value) / 2;
  10825. }
  10826. return {
  10827. _updateBoundary,
  10828. _updateOffset,
  10829. _updateWH,
  10830. _scaleOffset,
  10831. minX,
  10832. minY,
  10833. maxX,
  10834. maxY
  10835. };
  10836. }
  10837. function useMovableViewTransform(rootRef, props2, _scaleOffset, _scale, maxX, maxY, minX, minY, _translateX, _translateY, _SFA, _FA, _adjustScale, trigger) {
  10838. const dampingNumber = computed(() => {
  10839. let val = Number(props2.damping);
  10840. return isNaN(val) ? 20 : val;
  10841. });
  10842. const xMove = computed(() => props2.direction === "all" || props2.direction === "horizontal");
  10843. const yMove = computed(() => props2.direction === "all" || props2.direction === "vertical");
  10844. const xSync = ref(_getPx(props2.x));
  10845. const ySync = ref(_getPx(props2.y));
  10846. watch(() => props2.x, (val) => {
  10847. xSync.value = _getPx(val);
  10848. });
  10849. watch(() => props2.y, (val) => {
  10850. ySync.value = _getPx(val);
  10851. });
  10852. watch(xSync, (val) => {
  10853. _setX(val);
  10854. });
  10855. watch(ySync, (val) => {
  10856. _setY(val);
  10857. });
  10858. const _STD = new STD(1, 9 * Math.pow(dampingNumber.value, 2) / 40, dampingNumber.value);
  10859. function _getLimitXY(x, y) {
  10860. let outOfBounds = false;
  10861. if (x > maxX.value) {
  10862. x = maxX.value;
  10863. outOfBounds = true;
  10864. } else {
  10865. if (x < minX.value) {
  10866. x = minX.value;
  10867. outOfBounds = true;
  10868. }
  10869. }
  10870. if (y > maxY.value) {
  10871. y = maxY.value;
  10872. outOfBounds = true;
  10873. } else {
  10874. if (y < minY.value) {
  10875. y = minY.value;
  10876. outOfBounds = true;
  10877. }
  10878. }
  10879. return {
  10880. x,
  10881. y,
  10882. outOfBounds
  10883. };
  10884. }
  10885. function FAandSFACancel() {
  10886. if (_FA) {
  10887. _FA.cancel();
  10888. }
  10889. if (_SFA) {
  10890. _SFA.cancel();
  10891. }
  10892. }
  10893. function _animationTo(x, y, scale, source, r, o2) {
  10894. FAandSFACancel();
  10895. if (!xMove.value) {
  10896. x = _translateX.value;
  10897. }
  10898. if (!yMove.value) {
  10899. y = _translateY.value;
  10900. }
  10901. if (!props2.scale) {
  10902. scale = _scale.value;
  10903. }
  10904. let limitXY = _getLimitXY(x, y);
  10905. x = limitXY.x;
  10906. y = limitXY.y;
  10907. if (!props2.animation) {
  10908. _setTransform(x, y, scale, source, r, o2);
  10909. return;
  10910. }
  10911. _STD._springX._solution = null;
  10912. _STD._springY._solution = null;
  10913. _STD._springScale._solution = null;
  10914. _STD._springX._endPosition = _translateX.value;
  10915. _STD._springY._endPosition = _translateY.value;
  10916. _STD._springScale._endPosition = _scale.value;
  10917. _STD.setEnd(x, y, scale, 1);
  10918. _SFA = g(_STD, function() {
  10919. let data = _STD.x();
  10920. let x2 = data.x;
  10921. let y2 = data.y;
  10922. let scale2 = data.scale;
  10923. _setTransform(x2, y2, scale2, source, r, o2);
  10924. }, function() {
  10925. _SFA.cancel();
  10926. });
  10927. }
  10928. function _setTransform(x, y, scale, source = "", r, o2) {
  10929. if (!(x !== null && x.toString() !== "NaN" && typeof x === "number")) {
  10930. x = _translateX.value || 0;
  10931. }
  10932. if (!(y !== null && y.toString() !== "NaN" && typeof y === "number")) {
  10933. y = _translateY.value || 0;
  10934. }
  10935. x = Number(x.toFixed(1));
  10936. y = Number(y.toFixed(1));
  10937. scale = Number(scale.toFixed(1));
  10938. if (!(_translateX.value === x && _translateY.value === y)) {
  10939. if (!r) {
  10940. trigger("change", {}, {
  10941. x: v(x, _scaleOffset.x),
  10942. y: v(y, _scaleOffset.y),
  10943. source
  10944. });
  10945. }
  10946. }
  10947. if (!props2.scale) {
  10948. scale = _scale.value;
  10949. }
  10950. scale = _adjustScale(scale);
  10951. scale = +scale.toFixed(3);
  10952. if (o2 && scale !== _scale.value) {
  10953. trigger("scale", {}, {
  10954. x,
  10955. y,
  10956. scale
  10957. });
  10958. }
  10959. let transform = "translateX(" + x + "px) translateY(" + y + "px) translateZ(0px) scale(" + scale + ")";
  10960. if (rootRef.value) {
  10961. rootRef.value.style.transform = transform;
  10962. rootRef.value.style.webkitTransform = transform;
  10963. _translateX.value = x;
  10964. _translateY.value = y;
  10965. _scale.value = scale;
  10966. }
  10967. }
  10968. function _revise(source) {
  10969. let limitXY = _getLimitXY(_translateX.value, _translateY.value);
  10970. let x = limitXY.x;
  10971. let y = limitXY.y;
  10972. let outOfBounds = limitXY.outOfBounds;
  10973. if (outOfBounds) {
  10974. _animationTo(x, y, _scale.value, source);
  10975. }
  10976. return outOfBounds;
  10977. }
  10978. function _setX(val) {
  10979. if (xMove.value) {
  10980. if (val + _scaleOffset.x === _translateX.value) {
  10981. return _translateX;
  10982. } else {
  10983. if (_SFA) {
  10984. _SFA.cancel();
  10985. }
  10986. _animationTo(val + _scaleOffset.x, ySync.value + _scaleOffset.y, _scale.value);
  10987. }
  10988. }
  10989. return val;
  10990. }
  10991. function _setY(val) {
  10992. if (yMove.value) {
  10993. if (val + _scaleOffset.y === _translateY.value) {
  10994. return _translateY;
  10995. } else {
  10996. if (_SFA) {
  10997. _SFA.cancel();
  10998. }
  10999. _animationTo(xSync.value + _scaleOffset.x, val + _scaleOffset.y, _scale.value);
  11000. }
  11001. }
  11002. return val;
  11003. }
  11004. return {
  11005. FAandSFACancel,
  11006. _getLimitXY,
  11007. _animationTo,
  11008. _setTransform,
  11009. _revise,
  11010. dampingNumber,
  11011. xMove,
  11012. yMove,
  11013. xSync,
  11014. ySync,
  11015. _STD
  11016. };
  11017. }
  11018. function useMovableViewInit(props2, rootRef, trigger, _scale, _oldScale, _isScaling, _translateX, _translateY, _SFA, _FA) {
  11019. const scaleMinNumber = computed(() => {
  11020. let val = Number(props2.scaleMin);
  11021. return isNaN(val) ? 0.5 : val;
  11022. });
  11023. const scaleMaxNumber = computed(() => {
  11024. let val = Number(props2.scaleMax);
  11025. return isNaN(val) ? 10 : val;
  11026. });
  11027. const scaleValueSync = ref(Number(props2.scaleValue) || 1);
  11028. watch(scaleValueSync, (val) => {
  11029. _setScaleValue(val);
  11030. });
  11031. watch(scaleMinNumber, () => {
  11032. _setScaleMinOrMax();
  11033. });
  11034. watch(scaleMaxNumber, () => {
  11035. _setScaleMinOrMax();
  11036. });
  11037. watch(() => props2.scaleValue, (val) => {
  11038. scaleValueSync.value = Number(val) || 0;
  11039. });
  11040. const {
  11041. _updateBoundary,
  11042. _updateOffset,
  11043. _updateWH,
  11044. _scaleOffset,
  11045. minX,
  11046. minY,
  11047. maxX,
  11048. maxY
  11049. } = useMovableViewLayout(rootRef, _scale, _adjustScale);
  11050. const {
  11051. FAandSFACancel,
  11052. _getLimitXY,
  11053. _animationTo,
  11054. _setTransform,
  11055. _revise,
  11056. dampingNumber,
  11057. xMove,
  11058. yMove,
  11059. xSync,
  11060. ySync,
  11061. _STD
  11062. } = useMovableViewTransform(rootRef, props2, _scaleOffset, _scale, maxX, maxY, minX, minY, _translateX, _translateY, _SFA, _FA, _adjustScale, trigger);
  11063. function _updateScale(scale, animat) {
  11064. if (props2.scale) {
  11065. scale = _adjustScale(scale);
  11066. _updateWH(scale);
  11067. _updateBoundary();
  11068. const limitXY = _getLimitXY(_translateX.value, _translateY.value);
  11069. const x = limitXY.x;
  11070. const y = limitXY.y;
  11071. if (animat) {
  11072. _animationTo(x, y, scale, "", true, true);
  11073. } else {
  11074. _requestAnimationFrame(function() {
  11075. _setTransform(x, y, scale, "", true, true);
  11076. });
  11077. }
  11078. }
  11079. }
  11080. function _beginScale() {
  11081. _isScaling.value = true;
  11082. }
  11083. function _updateOldScale(scale) {
  11084. _oldScale.value = scale;
  11085. }
  11086. function _adjustScale(scale) {
  11087. scale = Math.max(0.5, scaleMinNumber.value, scale);
  11088. scale = Math.min(10, scaleMaxNumber.value, scale);
  11089. return scale;
  11090. }
  11091. function _setScaleMinOrMax() {
  11092. if (!props2.scale) {
  11093. return false;
  11094. }
  11095. _updateScale(_scale.value, true);
  11096. _updateOldScale(_scale.value);
  11097. }
  11098. function _setScaleValue(scale) {
  11099. if (!props2.scale) {
  11100. return false;
  11101. }
  11102. scale = _adjustScale(scale);
  11103. _updateScale(scale, true);
  11104. _updateOldScale(scale);
  11105. return scale;
  11106. }
  11107. function _endScale() {
  11108. _isScaling.value = false;
  11109. _updateOldScale(_scale.value);
  11110. }
  11111. function _setScale(scale) {
  11112. if (scale) {
  11113. scale = _oldScale.value * scale;
  11114. _beginScale();
  11115. _updateScale(scale);
  11116. }
  11117. }
  11118. return {
  11119. // scale
  11120. _updateOldScale,
  11121. _endScale,
  11122. _setScale,
  11123. scaleValueSync,
  11124. // layout
  11125. _updateBoundary,
  11126. _updateOffset,
  11127. _updateWH,
  11128. _scaleOffset,
  11129. minX,
  11130. minY,
  11131. maxX,
  11132. maxY,
  11133. // transform
  11134. FAandSFACancel,
  11135. _getLimitXY,
  11136. _animationTo,
  11137. _setTransform,
  11138. _revise,
  11139. dampingNumber,
  11140. xMove,
  11141. yMove,
  11142. xSync,
  11143. ySync,
  11144. _STD
  11145. };
  11146. }
  11147. function useMovableViewState(props2, trigger, rootRef) {
  11148. const _isMounted = inject("_isMounted", ref(false));
  11149. const addMovableViewContext = inject("addMovableViewContext", () => {
  11150. });
  11151. const removeMovableViewContext = inject("removeMovableViewContext", () => {
  11152. });
  11153. let _scale = ref(1);
  11154. let _oldScale = ref(1);
  11155. let _isScaling = ref(false);
  11156. let _translateX = ref(0);
  11157. let _translateY = ref(0);
  11158. let _SFA = null;
  11159. let _FA = null;
  11160. let _isTouching = false;
  11161. let __baseX;
  11162. let __baseY;
  11163. let _checkCanMove = null;
  11164. let _firstMoveDirection = null;
  11165. const _declineX = new Decline();
  11166. const _declineY = new Decline();
  11167. const __touchInfo = {
  11168. historyX: [0, 0],
  11169. historyY: [0, 0],
  11170. historyT: [0, 0]
  11171. };
  11172. const frictionNumber = computed(() => {
  11173. let val = Number(props2.friction);
  11174. return isNaN(val) || val <= 0 ? 2 : val;
  11175. });
  11176. const _friction = new Friction$1(1, frictionNumber.value);
  11177. watch(() => props2.disabled, () => {
  11178. __handleTouchStart();
  11179. });
  11180. const {
  11181. // scale
  11182. _updateOldScale,
  11183. _endScale,
  11184. _setScale,
  11185. scaleValueSync,
  11186. // layout
  11187. _updateBoundary,
  11188. _updateOffset,
  11189. _updateWH,
  11190. _scaleOffset,
  11191. minX,
  11192. minY,
  11193. maxX,
  11194. maxY,
  11195. // transform
  11196. FAandSFACancel,
  11197. _getLimitXY,
  11198. _setTransform,
  11199. _revise,
  11200. dampingNumber,
  11201. xMove,
  11202. yMove,
  11203. xSync,
  11204. ySync,
  11205. _STD
  11206. } = useMovableViewInit(props2, rootRef, trigger, _scale, _oldScale, _isScaling, _translateX, _translateY, _SFA, _FA);
  11207. function __handleTouchStart() {
  11208. if (!_isScaling.value) {
  11209. if (!props2.disabled) {
  11210. FAandSFACancel();
  11211. __touchInfo.historyX = [0, 0];
  11212. __touchInfo.historyY = [0, 0];
  11213. __touchInfo.historyT = [0, 0];
  11214. if (xMove.value) {
  11215. __baseX = _translateX.value;
  11216. }
  11217. if (yMove.value) {
  11218. __baseY = _translateY.value;
  11219. }
  11220. rootRef.value.style.willChange = "transform";
  11221. _checkCanMove = null;
  11222. _firstMoveDirection = null;
  11223. _isTouching = true;
  11224. }
  11225. }
  11226. }
  11227. function __handleTouchMove(event) {
  11228. if (!_isScaling.value && !props2.disabled && _isTouching) {
  11229. let x = _translateX.value;
  11230. let y = _translateY.value;
  11231. if (_firstMoveDirection === null) {
  11232. _firstMoveDirection = Math.abs(event.detail.dx / event.detail.dy) > 1 ? "htouchmove" : "vtouchmove";
  11233. }
  11234. if (xMove.value) {
  11235. x = event.detail.dx + __baseX;
  11236. __touchInfo.historyX.shift();
  11237. __touchInfo.historyX.push(x);
  11238. if (!yMove.value && _checkCanMove === null) {
  11239. _checkCanMove = Math.abs(event.detail.dx / event.detail.dy) < 1;
  11240. }
  11241. }
  11242. if (yMove.value) {
  11243. y = event.detail.dy + __baseY;
  11244. __touchInfo.historyY.shift();
  11245. __touchInfo.historyY.push(y);
  11246. if (!xMove.value && _checkCanMove === null) {
  11247. _checkCanMove = Math.abs(event.detail.dy / event.detail.dx) < 1;
  11248. }
  11249. }
  11250. __touchInfo.historyT.shift();
  11251. __touchInfo.historyT.push(event.detail.timeStamp);
  11252. if (!_checkCanMove) {
  11253. event.preventDefault();
  11254. let source = "touch";
  11255. if (x < minX.value) {
  11256. if (props2.outOfBounds) {
  11257. source = "touch-out-of-bounds";
  11258. x = minX.value - _declineX.x(minX.value - x);
  11259. } else {
  11260. x = minX.value;
  11261. }
  11262. } else if (x > maxX.value) {
  11263. if (props2.outOfBounds) {
  11264. source = "touch-out-of-bounds";
  11265. x = maxX.value + _declineX.x(x - maxX.value);
  11266. } else {
  11267. x = maxX.value;
  11268. }
  11269. }
  11270. if (y < minY.value) {
  11271. if (props2.outOfBounds) {
  11272. source = "touch-out-of-bounds";
  11273. y = minY.value - _declineY.x(minY.value - y);
  11274. } else {
  11275. y = minY.value;
  11276. }
  11277. } else {
  11278. if (y > maxY.value) {
  11279. if (props2.outOfBounds) {
  11280. source = "touch-out-of-bounds";
  11281. y = maxY.value + _declineY.x(y - maxY.value);
  11282. } else {
  11283. y = maxY.value;
  11284. }
  11285. }
  11286. }
  11287. _requestAnimationFrame(function() {
  11288. _setTransform(x, y, _scale.value, source);
  11289. });
  11290. }
  11291. }
  11292. }
  11293. function __handleTouchEnd() {
  11294. if (!_isScaling.value && !props2.disabled && _isTouching) {
  11295. rootRef.value.style.willChange = "auto";
  11296. _isTouching = false;
  11297. if (!_checkCanMove && !_revise("out-of-bounds") && props2.inertia) {
  11298. const xv = 1e3 * (__touchInfo.historyX[1] - __touchInfo.historyX[0]) / (__touchInfo.historyT[1] - __touchInfo.historyT[0]);
  11299. const yv = 1e3 * (__touchInfo.historyY[1] - __touchInfo.historyY[0]) / (__touchInfo.historyT[1] - __touchInfo.historyT[0]);
  11300. const __translateX = _translateX.value;
  11301. const __translateY = _translateY.value;
  11302. _friction.setV(xv, yv);
  11303. _friction.setS(__translateX, __translateY);
  11304. const x0 = _friction.delta().x;
  11305. const y0 = _friction.delta().y;
  11306. let x = x0 + __translateX;
  11307. let y = y0 + __translateY;
  11308. if (x < minX.value) {
  11309. x = minX.value;
  11310. y = __translateY + (minX.value - __translateX) * y0 / x0;
  11311. } else {
  11312. if (x > maxX.value) {
  11313. x = maxX.value;
  11314. y = __translateY + (maxX.value - __translateX) * y0 / x0;
  11315. }
  11316. }
  11317. if (y < minY.value) {
  11318. y = minY.value;
  11319. x = __translateX + (minY.value - __translateY) * x0 / y0;
  11320. } else {
  11321. if (y > maxY.value) {
  11322. y = maxY.value;
  11323. x = __translateX + (maxY.value - __translateY) * x0 / y0;
  11324. }
  11325. }
  11326. _friction.setEnd(x, y);
  11327. _FA = g(_friction, function() {
  11328. let t2 = _friction.s();
  11329. let x2 = t2.x;
  11330. let y2 = t2.y;
  11331. _setTransform(x2, y2, _scale.value, "friction");
  11332. }, function() {
  11333. _FA.cancel();
  11334. });
  11335. }
  11336. }
  11337. if (!props2.outOfBounds && !props2.inertia) {
  11338. FAandSFACancel();
  11339. }
  11340. }
  11341. function setParent() {
  11342. if (!_isMounted.value) {
  11343. return;
  11344. }
  11345. FAandSFACancel();
  11346. let scale = props2.scale ? scaleValueSync.value : 1;
  11347. _updateOffset();
  11348. _updateWH(scale);
  11349. _updateBoundary();
  11350. let limitXY = _getLimitXY(xSync.value + _scaleOffset.x, ySync.value + _scaleOffset.y);
  11351. let x = limitXY.x;
  11352. let y = limitXY.y;
  11353. _setTransform(x, y, scale, "", true);
  11354. _updateOldScale(scale);
  11355. }
  11356. onMounted(() => {
  11357. useTouchtrack(rootRef.value, (event) => {
  11358. switch (event.detail.state) {
  11359. case "start":
  11360. __handleTouchStart();
  11361. break;
  11362. case "move":
  11363. __handleTouchMove(event);
  11364. break;
  11365. case "end":
  11366. __handleTouchEnd();
  11367. }
  11368. });
  11369. setParent();
  11370. _friction.reconfigure(1, frictionNumber.value);
  11371. _STD.reconfigure(1, 9 * Math.pow(dampingNumber.value, 2) / 40, dampingNumber.value);
  11372. rootRef.value.style.transformOrigin = "center";
  11373. const context = {
  11374. rootRef,
  11375. setParent,
  11376. _endScale,
  11377. _setScale
  11378. };
  11379. addMovableViewContext(context);
  11380. onUnmounted(() => {
  11381. removeMovableViewContext(context);
  11382. });
  11383. });
  11384. onUnmounted(() => {
  11385. FAandSFACancel();
  11386. });
  11387. return {
  11388. setParent
  11389. };
  11390. }
  11391. const OPEN_TYPES = [
  11392. "navigate",
  11393. "redirect",
  11394. "switchTab",
  11395. "reLaunch",
  11396. "navigateBack"
  11397. ];
  11398. const ANIMATION_IN = [
  11399. "slide-in-right",
  11400. "slide-in-left",
  11401. "slide-in-top",
  11402. "slide-in-bottom",
  11403. "fade-in",
  11404. "zoom-out",
  11405. "zoom-fade-out",
  11406. "pop-in",
  11407. "none"
  11408. ];
  11409. const ANIMATION_OUT = [
  11410. "slide-out-right",
  11411. "slide-out-left",
  11412. "slide-out-top",
  11413. "slide-out-bottom",
  11414. "fade-out",
  11415. "zoom-in",
  11416. "zoom-fade-in",
  11417. "pop-out",
  11418. "none"
  11419. ];
  11420. const navigatorProps = {
  11421. hoverClass: {
  11422. type: String,
  11423. default: "navigator-hover"
  11424. },
  11425. url: {
  11426. type: String,
  11427. default: ""
  11428. },
  11429. openType: {
  11430. type: String,
  11431. default: "navigate",
  11432. validator(value) {
  11433. return Boolean(~OPEN_TYPES.indexOf(value));
  11434. }
  11435. },
  11436. delta: {
  11437. type: Number,
  11438. default: 1
  11439. },
  11440. hoverStartTime: {
  11441. type: [Number, String],
  11442. default: 50
  11443. },
  11444. hoverStayTime: {
  11445. type: [Number, String],
  11446. default: 600
  11447. },
  11448. exists: {
  11449. type: String,
  11450. default: ""
  11451. },
  11452. hoverStopPropagation: {
  11453. type: Boolean,
  11454. default: false
  11455. },
  11456. animationType: {
  11457. type: String,
  11458. default: "",
  11459. validator(value) {
  11460. return !value || ANIMATION_IN.concat(ANIMATION_OUT).includes(value);
  11461. }
  11462. },
  11463. animationDuration: {
  11464. type: [String, Number],
  11465. default: 300
  11466. }
  11467. };
  11468. function createNavigatorOnClick(props2) {
  11469. return () => {
  11470. if (props2.openType !== "navigateBack" && !props2.url) {
  11471. console.error(
  11472. "<navigator/> should have url attribute when using navigateTo, redirectTo, reLaunch or switchTab"
  11473. );
  11474. return;
  11475. }
  11476. const animationDuration = parseInt(props2.animationDuration);
  11477. switch (props2.openType) {
  11478. case "navigate":
  11479. uni.navigateTo({
  11480. url: props2.url,
  11481. animationType: props2.animationType || "pop-in",
  11482. animationDuration
  11483. });
  11484. break;
  11485. case "redirect":
  11486. uni.redirectTo({
  11487. url: props2.url,
  11488. // @ts-ignore
  11489. exists: props2.exists
  11490. });
  11491. break;
  11492. case "switchTab":
  11493. uni.switchTab({
  11494. url: props2.url
  11495. });
  11496. break;
  11497. case "reLaunch":
  11498. uni.reLaunch({
  11499. url: props2.url
  11500. });
  11501. break;
  11502. case "navigateBack":
  11503. uni.navigateBack({
  11504. delta: props2.delta,
  11505. animationType: props2.animationType || "pop-out",
  11506. animationDuration
  11507. });
  11508. break;
  11509. }
  11510. };
  11511. }
  11512. class UniNavigatorElement extends UniElement {
  11513. }
  11514. const index$q = /* @__PURE__ */ defineBuiltInComponent({
  11515. name: "Navigator",
  11516. inheritAttrs: false,
  11517. compatConfig: {
  11518. MODE: 3
  11519. },
  11520. props: extend({}, navigatorProps, {
  11521. renderLink: {
  11522. type: Boolean,
  11523. default: true
  11524. }
  11525. }),
  11526. rootElement: {
  11527. name: "uni-navigator",
  11528. class: UniNavigatorElement
  11529. },
  11530. setup(props2, {
  11531. slots
  11532. }) {
  11533. const rootRef = ref(null);
  11534. const vm = getCurrentInstance();
  11535. const __scopeId = vm && vm.vnode.scopeId || "";
  11536. const {
  11537. hovering,
  11538. binding
  11539. } = useHover(props2);
  11540. const onClick = createNavigatorOnClick(props2);
  11541. onMounted(() => {
  11542. const rootElement = rootRef.value;
  11543. rootElement.attachVmProps(props2);
  11544. });
  11545. return () => {
  11546. const {
  11547. hoverClass,
  11548. url
  11549. } = props2;
  11550. const hasHoverClass = props2.hoverClass && props2.hoverClass !== "none";
  11551. const innerNode = props2.renderLink ? createVNode("a", {
  11552. "class": "navigator-wrap",
  11553. "href": url,
  11554. "onClick": onEventPrevent,
  11555. "onMousedown": onEventPrevent
  11556. }, [slots.default && slots.default()], 40, ["href", "onClick", "onMousedown"]) : slots.default && slots.default();
  11557. return createVNode("uni-navigator", mergeProps({
  11558. "class": hasHoverClass && hovering.value ? hoverClass : "",
  11559. "ref": rootRef
  11560. }, hasHoverClass && binding, vm ? vm.attrs : {}, {
  11561. [__scopeId]: ""
  11562. }, {
  11563. "onClick": onClick
  11564. }), [innerNode], 16, ["onClick"]);
  11565. };
  11566. }
  11567. });
  11568. const pickerViewProps = {
  11569. value: {
  11570. type: Array,
  11571. default() {
  11572. return [];
  11573. },
  11574. validator: function(val) {
  11575. return isArray(val) && val.filter((val2) => typeof val2 === "number").length === val.length;
  11576. }
  11577. },
  11578. indicatorStyle: {
  11579. type: String,
  11580. default: ""
  11581. },
  11582. indicatorClass: {
  11583. type: String,
  11584. default: ""
  11585. },
  11586. maskStyle: {
  11587. type: String,
  11588. default: ""
  11589. },
  11590. maskClass: {
  11591. type: String,
  11592. default: ""
  11593. }
  11594. };
  11595. function useState$4(props2) {
  11596. const value = reactive([...props2.value]);
  11597. const state2 = reactive({
  11598. value,
  11599. height: 34
  11600. });
  11601. watch(() => props2.value, (val, oldVal) => {
  11602. {
  11603. state2.value.length = val.length;
  11604. val.forEach((val2, index2) => {
  11605. if (val2 !== state2.value[index2]) {
  11606. state2.value.splice(index2, 1, val2);
  11607. }
  11608. });
  11609. }
  11610. });
  11611. return state2;
  11612. }
  11613. class UniPickerViewElement extends UniElement {
  11614. }
  11615. const PickerView = /* @__PURE__ */ defineBuiltInComponent({
  11616. name: "PickerView",
  11617. props: pickerViewProps,
  11618. emits: ["change", "pickstart", "pickend", "update:value"],
  11619. rootElement: {
  11620. name: "uni-picker-view",
  11621. class: UniPickerViewElement
  11622. },
  11623. setup(props2, {
  11624. slots,
  11625. emit: emit2
  11626. }) {
  11627. const rootRef = ref(null);
  11628. const wrapperRef = ref(null);
  11629. const trigger = useCustomEvent(rootRef, emit2);
  11630. const state2 = useState$4(props2);
  11631. const resizeSensorRef = ref(null);
  11632. const onMountedCallback = () => {
  11633. const resizeSensor = resizeSensorRef.value;
  11634. resizeSensor && (state2.height = resizeSensor.offsetHeight);
  11635. };
  11636. {
  11637. onMounted(onMountedCallback);
  11638. }
  11639. let ColumnsPreRef = ref([]);
  11640. let columnsRef = ref([]);
  11641. function getItemIndex(vnode) {
  11642. let columnVNodes = columnsRef.value;
  11643. {
  11644. columnVNodes = columnVNodes.filter((vnode2) => vnode2.type !== Comment);
  11645. }
  11646. let index2 = columnVNodes.indexOf(vnode);
  11647. return index2 !== -1 ? index2 : ColumnsPreRef.value.indexOf(vnode);
  11648. }
  11649. const getPickerViewColumn = function(columnInstance) {
  11650. const ref2 = computed({
  11651. get() {
  11652. const index2 = getItemIndex(columnInstance.vnode);
  11653. return state2.value[index2] || 0;
  11654. },
  11655. set(current) {
  11656. const index2 = getItemIndex(columnInstance.vnode);
  11657. if (index2 < 0) {
  11658. return;
  11659. }
  11660. const oldCurrent = state2.value[index2];
  11661. if (oldCurrent !== current) {
  11662. state2.value[index2] = current;
  11663. const value = state2.value.map((val) => val);
  11664. emit2("update:value", value);
  11665. trigger("change", {}, {
  11666. value
  11667. });
  11668. }
  11669. }
  11670. });
  11671. return ref2;
  11672. };
  11673. provide("getPickerViewColumn", getPickerViewColumn);
  11674. provide("pickerViewProps", props2);
  11675. provide("pickerViewState", state2);
  11676. onMounted(() => {
  11677. const rootElement = rootRef.value;
  11678. Object.defineProperty(rootElement, "value", {
  11679. get() {
  11680. const columns = rootElement.querySelectorAll("uni-picker-view-column");
  11681. return Array.from(columns).map((item) => item.current);
  11682. },
  11683. set(value) {
  11684. const columns = rootElement.querySelectorAll("uni-picker-view-column");
  11685. Array.from(columns).forEach((item, index2) => {
  11686. item.current = value[index2] || 0;
  11687. });
  11688. }
  11689. });
  11690. rootElement.attachVmProps(props2);
  11691. });
  11692. return () => {
  11693. const defaultSlots = slots.default && slots.default();
  11694. {
  11695. const vnode = flatVNode(defaultSlots);
  11696. ColumnsPreRef.value = vnode;
  11697. nextTick(() => {
  11698. columnsRef.value = vnode;
  11699. });
  11700. }
  11701. return createVNode("uni-picker-view", {
  11702. "ref": rootRef
  11703. }, [createVNode(ResizeSensor, {
  11704. "ref": resizeSensorRef,
  11705. "onResize": ({
  11706. height
  11707. }) => state2.height = height
  11708. }, null, 8, ["onResize"]), createVNode("div", {
  11709. "ref": wrapperRef,
  11710. "class": "uni-picker-view-wrapper"
  11711. }, [defaultSlots], 512)], 512);
  11712. };
  11713. }
  11714. });
  11715. class Friction {
  11716. constructor(drag) {
  11717. this._drag = drag;
  11718. this._dragLog = Math.log(drag);
  11719. this._x = 0;
  11720. this._v = 0;
  11721. this._startTime = 0;
  11722. }
  11723. set(x, v2) {
  11724. this._x = x;
  11725. this._v = v2;
  11726. this._startTime = (/* @__PURE__ */ new Date()).getTime();
  11727. }
  11728. setVelocityByEnd(e2) {
  11729. this._v = (e2 - this._x) * this._dragLog / (Math.pow(this._drag, 100) - 1);
  11730. }
  11731. x(e2) {
  11732. if (e2 === void 0) {
  11733. e2 = ((/* @__PURE__ */ new Date()).getTime() - this._startTime) / 1e3;
  11734. }
  11735. const t2 = e2 === this._dt && this._powDragDt ? this._powDragDt : this._powDragDt = Math.pow(this._drag, e2);
  11736. this._dt = e2;
  11737. return this._x + this._v * t2 / this._dragLog - this._v / this._dragLog;
  11738. }
  11739. dx(e2) {
  11740. if (e2 === void 0) {
  11741. e2 = ((/* @__PURE__ */ new Date()).getTime() - this._startTime) / 1e3;
  11742. }
  11743. const t2 = e2 === this._dt && this._powDragDt ? this._powDragDt : this._powDragDt = Math.pow(this._drag, e2);
  11744. this._dt = e2;
  11745. return this._v * t2;
  11746. }
  11747. done() {
  11748. return Math.abs(this.dx()) < 3;
  11749. }
  11750. reconfigure(e2) {
  11751. const t2 = this.x();
  11752. const n = this.dx();
  11753. this._drag = e2;
  11754. this._dragLog = Math.log(e2);
  11755. this.set(t2, n);
  11756. }
  11757. configuration() {
  11758. const e2 = this;
  11759. return [
  11760. {
  11761. label: "Friction",
  11762. read: function() {
  11763. return e2._drag;
  11764. },
  11765. write: function(t2) {
  11766. e2.reconfigure(t2);
  11767. },
  11768. min: 1e-3,
  11769. max: 0.1,
  11770. step: 1e-3
  11771. }
  11772. ];
  11773. }
  11774. }
  11775. function o(e2, t2, n) {
  11776. return e2 > t2 - n && e2 < t2 + n;
  11777. }
  11778. function a(e2, t2) {
  11779. return o(e2, 0, t2);
  11780. }
  11781. class Spring {
  11782. constructor(m, k, c) {
  11783. this._m = m;
  11784. this._k = k;
  11785. this._c = c;
  11786. this._solution = null;
  11787. this._endPosition = 0;
  11788. this._startTime = 0;
  11789. }
  11790. _solve(e2, t2) {
  11791. const n = this._c;
  11792. const i = this._m;
  11793. const r = this._k;
  11794. const o2 = n * n - 4 * i * r;
  11795. if (o2 === 0) {
  11796. const a3 = -n / (2 * i);
  11797. const s2 = e2;
  11798. const l2 = t2 / (a3 * e2);
  11799. return {
  11800. x: function(e22) {
  11801. return (s2 + l2 * e22) * Math.pow(Math.E, a3 * e22);
  11802. },
  11803. dx: function(e22) {
  11804. const t22 = Math.pow(Math.E, a3 * e22);
  11805. return a3 * (s2 + l2 * e22) * t22 + l2 * t22;
  11806. }
  11807. };
  11808. }
  11809. if (o2 > 0) {
  11810. const c = (-n - Math.sqrt(o2)) / (2 * i);
  11811. const u = (-n + Math.sqrt(o2)) / (2 * i);
  11812. const l2 = (t2 - c * e2) / (u - c);
  11813. const s2 = e2 - l2;
  11814. return {
  11815. x: function(e22) {
  11816. let t22;
  11817. let n2;
  11818. if (e22 === this._t) {
  11819. t22 = this._powER1T;
  11820. n2 = this._powER2T;
  11821. }
  11822. this._t = e22;
  11823. if (!t22) {
  11824. t22 = this._powER1T = Math.pow(Math.E, c * e22);
  11825. }
  11826. if (!n2) {
  11827. n2 = this._powER2T = Math.pow(Math.E, u * e22);
  11828. }
  11829. return s2 * t22 + l2 * n2;
  11830. },
  11831. dx: function(e22) {
  11832. let t22;
  11833. let n2;
  11834. if (e22 === this._t) {
  11835. t22 = this._powER1T;
  11836. n2 = this._powER2T;
  11837. }
  11838. this._t = e22;
  11839. if (!t22) {
  11840. t22 = this._powER1T = Math.pow(Math.E, c * e22);
  11841. }
  11842. if (!n2) {
  11843. n2 = this._powER2T = Math.pow(Math.E, u * e22);
  11844. }
  11845. return s2 * c * t22 + l2 * u * n2;
  11846. }
  11847. };
  11848. }
  11849. const d = Math.sqrt(4 * i * r - n * n) / (2 * i);
  11850. const a2 = -n / 2 * i;
  11851. const s = e2;
  11852. const l = (t2 - a2 * e2) / d;
  11853. return {
  11854. x: function(e22) {
  11855. return Math.pow(Math.E, a2 * e22) * (s * Math.cos(d * e22) + l * Math.sin(d * e22));
  11856. },
  11857. dx: function(e22) {
  11858. const t22 = Math.pow(Math.E, a2 * e22);
  11859. const n2 = Math.cos(d * e22);
  11860. const i2 = Math.sin(d * e22);
  11861. return t22 * (l * d * n2 - s * d * i2) + a2 * t22 * (l * i2 + s * n2);
  11862. }
  11863. };
  11864. }
  11865. x(e2) {
  11866. if (e2 === void 0) {
  11867. e2 = ((/* @__PURE__ */ new Date()).getTime() - this._startTime) / 1e3;
  11868. }
  11869. return this._solution ? this._endPosition + this._solution.x(e2) : 0;
  11870. }
  11871. dx(e2) {
  11872. if (e2 === void 0) {
  11873. e2 = ((/* @__PURE__ */ new Date()).getTime() - this._startTime) / 1e3;
  11874. }
  11875. return this._solution ? this._solution.dx(e2) : 0;
  11876. }
  11877. setEnd(e2, t2, n) {
  11878. if (!n) {
  11879. n = (/* @__PURE__ */ new Date()).getTime();
  11880. }
  11881. if (e2 !== this._endPosition || !a(t2, 0.4)) {
  11882. t2 = t2 || 0;
  11883. let i = this._endPosition;
  11884. if (this._solution) {
  11885. if (a(t2, 0.4)) {
  11886. t2 = this._solution.dx((n - this._startTime) / 1e3);
  11887. }
  11888. i = this._solution.x((n - this._startTime) / 1e3);
  11889. if (a(t2, 0.4)) {
  11890. t2 = 0;
  11891. }
  11892. if (a(i, 0.4)) {
  11893. i = 0;
  11894. }
  11895. i += this._endPosition;
  11896. }
  11897. if (!(this._solution && a(i - e2, 0.4) && a(t2, 0.4))) {
  11898. this._endPosition = e2;
  11899. this._solution = this._solve(i - this._endPosition, t2);
  11900. this._startTime = n;
  11901. }
  11902. }
  11903. }
  11904. snap(e2) {
  11905. this._startTime = (/* @__PURE__ */ new Date()).getTime();
  11906. this._endPosition = e2;
  11907. this._solution = {
  11908. x: function() {
  11909. return 0;
  11910. },
  11911. dx: function() {
  11912. return 0;
  11913. }
  11914. };
  11915. }
  11916. done(e2) {
  11917. if (!e2) {
  11918. e2 = (/* @__PURE__ */ new Date()).getTime();
  11919. }
  11920. return o(this.x(), this._endPosition, 0.4) && a(this.dx(), 0.4);
  11921. }
  11922. reconfigure(e2, t2, n) {
  11923. this._m = e2;
  11924. this._k = t2;
  11925. this._c = n;
  11926. if (!this.done()) {
  11927. this._solution = this._solve(this.x() - this._endPosition, this.dx());
  11928. this._startTime = (/* @__PURE__ */ new Date()).getTime();
  11929. }
  11930. }
  11931. springConstant() {
  11932. return this._k;
  11933. }
  11934. damping() {
  11935. return this._c;
  11936. }
  11937. configuration() {
  11938. function e2(e22, t22) {
  11939. e22.reconfigure(1, t22, e22.damping());
  11940. }
  11941. function t2(e22, t22) {
  11942. e22.reconfigure(1, e22.springConstant(), t22);
  11943. }
  11944. return [
  11945. {
  11946. label: "Spring Constant",
  11947. read: this.springConstant.bind(this),
  11948. write: e2.bind(this, this),
  11949. min: 100,
  11950. max: 1e3
  11951. },
  11952. {
  11953. label: "Damping",
  11954. read: this.damping.bind(this),
  11955. write: t2.bind(this, this),
  11956. min: 1,
  11957. max: 500
  11958. }
  11959. ];
  11960. }
  11961. }
  11962. class Scroll {
  11963. constructor(extent, friction, spring) {
  11964. this._extent = extent;
  11965. this._friction = friction || new Friction(0.01);
  11966. this._spring = spring || new Spring(1, 90, 20);
  11967. this._startTime = 0;
  11968. this._springing = false;
  11969. this._springOffset = 0;
  11970. }
  11971. snap(e2, t2) {
  11972. this._springOffset = 0;
  11973. this._springing = true;
  11974. this._spring.snap(e2);
  11975. this._spring.setEnd(t2);
  11976. }
  11977. set(e2, t2) {
  11978. this._friction.set(e2, t2);
  11979. if (e2 > 0 && t2 >= 0) {
  11980. this._springOffset = 0;
  11981. this._springing = true;
  11982. this._spring.snap(e2);
  11983. this._spring.setEnd(0);
  11984. } else {
  11985. if (e2 < -this._extent && t2 <= 0) {
  11986. this._springOffset = 0;
  11987. this._springing = true;
  11988. this._spring.snap(e2);
  11989. this._spring.setEnd(-this._extent);
  11990. } else {
  11991. this._springing = false;
  11992. }
  11993. }
  11994. this._startTime = (/* @__PURE__ */ new Date()).getTime();
  11995. }
  11996. x(e2) {
  11997. if (!this._startTime) {
  11998. return 0;
  11999. }
  12000. if (!e2) {
  12001. e2 = ((/* @__PURE__ */ new Date()).getTime() - this._startTime) / 1e3;
  12002. }
  12003. if (this._springing) {
  12004. return this._spring.x() + this._springOffset;
  12005. }
  12006. let t2 = this._friction.x(e2);
  12007. let n = this.dx(e2);
  12008. if (t2 > 0 && n >= 0 || t2 < -this._extent && n <= 0) {
  12009. this._springing = true;
  12010. this._spring.setEnd(0, n);
  12011. if (t2 < -this._extent) {
  12012. this._springOffset = -this._extent;
  12013. } else {
  12014. this._springOffset = 0;
  12015. }
  12016. t2 = this._spring.x() + this._springOffset;
  12017. }
  12018. return t2;
  12019. }
  12020. dx(e2) {
  12021. let t2;
  12022. if (this._lastTime === e2) {
  12023. t2 = this._lastDx;
  12024. } else {
  12025. t2 = this._springing ? this._spring.dx(e2) : this._friction.dx(e2);
  12026. }
  12027. this._lastTime = e2;
  12028. this._lastDx = t2;
  12029. return t2;
  12030. }
  12031. done() {
  12032. return this._springing ? this._spring.done() : this._friction.done();
  12033. }
  12034. setVelocityByEnd(e2) {
  12035. this._friction.setVelocityByEnd(e2);
  12036. }
  12037. configuration() {
  12038. const e2 = this._friction.configuration();
  12039. e2.push.apply(e2, this._spring.configuration());
  12040. return e2;
  12041. }
  12042. }
  12043. function createAnimation(scroll, onScroll, onEnd) {
  12044. const state2 = {
  12045. id: 0,
  12046. cancelled: false
  12047. };
  12048. function startAnimation2(state22, scroll2, onScroll2, onEnd2) {
  12049. if (!state22 || !state22.cancelled) {
  12050. onScroll2(scroll2);
  12051. const isDone = scroll2.done();
  12052. if (!isDone) {
  12053. if (!state22.cancelled) {
  12054. state22.id = requestAnimationFrame(
  12055. startAnimation2.bind(null, state22, scroll2, onScroll2, onEnd2)
  12056. );
  12057. }
  12058. }
  12059. if (isDone && onEnd2) {
  12060. onEnd2(scroll2);
  12061. }
  12062. }
  12063. }
  12064. function cancel(state22) {
  12065. if (state22 && state22.id) {
  12066. cancelAnimationFrame(state22.id);
  12067. }
  12068. if (state22) {
  12069. state22.cancelled = true;
  12070. }
  12071. }
  12072. startAnimation2(state2, scroll, onScroll, onEnd);
  12073. return {
  12074. cancel: cancel.bind(null, state2),
  12075. model: scroll
  12076. };
  12077. }
  12078. class Scroller {
  12079. constructor(element, options) {
  12080. options = options || {};
  12081. this._element = element;
  12082. this._options = options;
  12083. this._enableSnap = options.enableSnap || false;
  12084. this._itemSize = options.itemSize || 0;
  12085. this._enableX = options.enableX || false;
  12086. this._enableY = options.enableY || false;
  12087. this._shouldDispatchScrollEvent = !!options.onScroll;
  12088. if (this._enableX) {
  12089. this._extent = (options.scrollWidth || this._element.offsetWidth) - this._element.parentElement.offsetWidth;
  12090. this._scrollWidth = options.scrollWidth;
  12091. } else {
  12092. this._extent = (options.scrollHeight || this._element.offsetHeight) - this._element.parentElement.offsetHeight;
  12093. this._scrollHeight = options.scrollHeight;
  12094. }
  12095. this._position = 0;
  12096. this._scroll = new Scroll(this._extent, options.friction, options.spring);
  12097. this._onTransitionEnd = this.onTransitionEnd.bind(this);
  12098. this.updatePosition();
  12099. }
  12100. onTouchStart() {
  12101. this._startPosition = this._position;
  12102. this._lastChangePos = this._startPosition;
  12103. if (this._startPosition > 0) {
  12104. this._startPosition /= 0.5;
  12105. } else {
  12106. if (this._startPosition < -this._extent) {
  12107. this._startPosition = (this._startPosition + this._extent) / 0.5 - this._extent;
  12108. }
  12109. }
  12110. if (this._animation) {
  12111. this._animation.cancel();
  12112. this._scrolling = false;
  12113. }
  12114. this.updatePosition();
  12115. }
  12116. onTouchMove(x, y) {
  12117. let startPosition = this._startPosition;
  12118. if (this._enableX) {
  12119. startPosition += x;
  12120. } else if (this._enableY) {
  12121. startPosition += y;
  12122. }
  12123. if (startPosition > 0) {
  12124. startPosition *= 0.5;
  12125. } else if (startPosition < -this._extent) {
  12126. startPosition = 0.5 * (startPosition + this._extent) - this._extent;
  12127. }
  12128. this._position = startPosition;
  12129. this.updatePosition();
  12130. this.dispatchScroll();
  12131. }
  12132. onTouchEnd(x, y, o2) {
  12133. if (this._enableSnap && this._position > -this._extent && this._position < 0) {
  12134. if (this._enableY && (Math.abs(y) < this._itemSize && Math.abs(o2.y) < 300 || Math.abs(o2.y) < 150)) {
  12135. this.snap();
  12136. return;
  12137. }
  12138. if (this._enableX && (Math.abs(x) < this._itemSize && Math.abs(o2.x) < 300 || Math.abs(o2.x) < 150)) {
  12139. this.snap();
  12140. return;
  12141. }
  12142. }
  12143. if (this._enableX) {
  12144. this._scroll.set(this._position, o2.x);
  12145. } else if (this._enableY) {
  12146. this._scroll.set(this._position, o2.y);
  12147. }
  12148. let c;
  12149. if (this._enableSnap) {
  12150. const s = this._scroll._friction.x(100);
  12151. const l = s % this._itemSize;
  12152. c = Math.abs(l) > this._itemSize / 2 ? s - (this._itemSize - Math.abs(l)) : s - l;
  12153. if (c <= 0 && c >= -this._extent) {
  12154. this._scroll.setVelocityByEnd(c);
  12155. }
  12156. }
  12157. this._lastTime = Date.now();
  12158. this._lastDelay = 0;
  12159. this._scrolling = true;
  12160. this._lastChangePos = this._position;
  12161. this._lastIdx = Math.floor(Math.abs(this._position / this._itemSize));
  12162. this._animation = createAnimation(
  12163. this._scroll,
  12164. () => {
  12165. const e2 = Date.now();
  12166. const i = (e2 - this._scroll._startTime) / 1e3;
  12167. const r = this._scroll.x(i);
  12168. this._position = r;
  12169. this.updatePosition();
  12170. const o22 = this._scroll.dx(i);
  12171. if (this._shouldDispatchScrollEvent && e2 - this._lastTime > this._lastDelay) {
  12172. this.dispatchScroll();
  12173. this._lastDelay = Math.abs(2e3 / o22);
  12174. this._lastTime = e2;
  12175. }
  12176. },
  12177. () => {
  12178. if (this._enableSnap) {
  12179. if (c <= 0 && c >= -this._extent) {
  12180. this._position = c;
  12181. this.updatePosition();
  12182. }
  12183. if (isFunction(this._options.onSnap)) {
  12184. this._options.onSnap(
  12185. Math.floor(Math.abs(this._position) / this._itemSize)
  12186. );
  12187. }
  12188. }
  12189. if (this._shouldDispatchScrollEvent) {
  12190. this.dispatchScroll();
  12191. }
  12192. this._scrolling = false;
  12193. }
  12194. );
  12195. }
  12196. onTransitionEnd() {
  12197. this._element.style.webkitTransition = "";
  12198. this._element.style.transition = "";
  12199. this._element.removeEventListener("transitionend", this._onTransitionEnd);
  12200. if (this._snapping) {
  12201. this._snapping = false;
  12202. }
  12203. this.dispatchScroll();
  12204. }
  12205. snap() {
  12206. const itemSize = this._itemSize;
  12207. const position = this._position % itemSize;
  12208. const i = Math.abs(position) > this._itemSize / 2 ? this._position - (itemSize - Math.abs(position)) : this._position - position;
  12209. if (this._position !== i) {
  12210. this._snapping = true;
  12211. this.scrollTo(-i);
  12212. if (isFunction(this._options.onSnap)) {
  12213. this._options.onSnap(
  12214. Math.floor(Math.abs(this._position) / this._itemSize)
  12215. );
  12216. }
  12217. }
  12218. }
  12219. scrollTo(position, time) {
  12220. if (this._animation) {
  12221. this._animation.cancel();
  12222. this._scrolling = false;
  12223. }
  12224. if (typeof position === "number") {
  12225. this._position = -position;
  12226. }
  12227. if (this._position < -this._extent) {
  12228. this._position = -this._extent;
  12229. } else {
  12230. if (this._position > 0) {
  12231. this._position = 0;
  12232. }
  12233. }
  12234. const transition = "transform " + (time || 0.2) + "s ease-out";
  12235. this._element.style.webkitTransition = "-webkit-" + transition;
  12236. this._element.style.transition = transition;
  12237. this.updatePosition();
  12238. this._element.addEventListener("transitionend", this._onTransitionEnd);
  12239. }
  12240. dispatchScroll() {
  12241. if (isFunction(this._options.onScroll) && Math.round(Number(this._lastPos)) !== Math.round(this._position)) {
  12242. this._lastPos = this._position;
  12243. const event = {
  12244. target: {
  12245. scrollLeft: this._enableX ? -this._position : 0,
  12246. scrollTop: this._enableY ? -this._position : 0,
  12247. scrollHeight: this._scrollHeight || this._element.offsetHeight,
  12248. scrollWidth: this._scrollWidth || this._element.offsetWidth,
  12249. offsetHeight: this._element.parentElement.offsetHeight,
  12250. offsetWidth: this._element.parentElement.offsetWidth
  12251. }
  12252. };
  12253. this._options.onScroll(event);
  12254. }
  12255. }
  12256. update(height, scrollHeight, itemSize) {
  12257. let extent = 0;
  12258. const position = this._position;
  12259. if (this._enableX) {
  12260. extent = this._element.childNodes.length ? (scrollHeight || this._element.offsetWidth) - this._element.parentElement.offsetWidth : 0;
  12261. this._scrollWidth = scrollHeight;
  12262. } else {
  12263. extent = this._element.childNodes.length ? (scrollHeight || this._element.offsetHeight) - this._element.parentElement.offsetHeight : 0;
  12264. this._scrollHeight = scrollHeight;
  12265. }
  12266. if (typeof height === "number") {
  12267. this._position = -height;
  12268. }
  12269. if (this._position < -extent) {
  12270. this._position = -extent;
  12271. } else {
  12272. if (this._position > 0) {
  12273. this._position = 0;
  12274. }
  12275. }
  12276. this._itemSize = itemSize || this._itemSize;
  12277. this.updatePosition();
  12278. if (position !== this._position) {
  12279. this.dispatchScroll();
  12280. if (isFunction(this._options.onSnap)) {
  12281. this._options.onSnap(
  12282. Math.floor(Math.abs(this._position) / this._itemSize)
  12283. );
  12284. }
  12285. }
  12286. this._extent = extent;
  12287. this._scroll._extent = extent;
  12288. }
  12289. updatePosition() {
  12290. let transform = "";
  12291. if (this._enableX) {
  12292. transform = "translateX(" + this._position + "px) translateZ(0)";
  12293. } else {
  12294. if (this._enableY) {
  12295. transform = "translateY(" + this._position + "px) translateZ(0)";
  12296. }
  12297. }
  12298. this._element.style.webkitTransform = transform;
  12299. this._element.style.transform = transform;
  12300. }
  12301. isScrolling() {
  12302. return this._scrolling || this._snapping;
  12303. }
  12304. }
  12305. function useScroller(element, options) {
  12306. const touchInfo = {
  12307. trackingID: -1,
  12308. maxDy: 0,
  12309. maxDx: 0
  12310. };
  12311. const scroller = new Scroller(element, options);
  12312. function findDelta(event) {
  12313. const touchtrackEvent = event;
  12314. const mouseEvent = event;
  12315. return touchtrackEvent.detail.state === "move" || touchtrackEvent.detail.state === "end" ? {
  12316. x: touchtrackEvent.detail.dx,
  12317. y: touchtrackEvent.detail.dy
  12318. } : {
  12319. x: mouseEvent.screenX - touchInfo.x,
  12320. y: mouseEvent.screenY - touchInfo.y
  12321. };
  12322. }
  12323. function handleTouchStart(event) {
  12324. const touchtrackEvent = event;
  12325. const mouseEvent = event;
  12326. if (touchtrackEvent.detail.state === "start") {
  12327. touchInfo.trackingID = "touch";
  12328. touchInfo.x = touchtrackEvent.detail.x;
  12329. touchInfo.y = touchtrackEvent.detail.y;
  12330. } else {
  12331. touchInfo.trackingID = "mouse";
  12332. touchInfo.x = mouseEvent.screenX;
  12333. touchInfo.y = mouseEvent.screenY;
  12334. }
  12335. touchInfo.maxDx = 0;
  12336. touchInfo.maxDy = 0;
  12337. touchInfo.historyX = [0];
  12338. touchInfo.historyY = [0];
  12339. touchInfo.historyTime = [
  12340. touchtrackEvent.detail.timeStamp || mouseEvent.timeStamp
  12341. ];
  12342. touchInfo.listener = scroller;
  12343. if (scroller.onTouchStart) {
  12344. scroller.onTouchStart();
  12345. }
  12346. if (typeof event.cancelable !== "boolean" || event.cancelable)
  12347. event.preventDefault();
  12348. }
  12349. function handleTouchMove(event) {
  12350. const touchtrackEvent = event;
  12351. const mouseEvent = event;
  12352. if (touchInfo.trackingID !== -1) {
  12353. if (typeof event.cancelable !== "boolean" || event.cancelable)
  12354. event.preventDefault();
  12355. const delta = findDelta(event);
  12356. if (delta) {
  12357. for (touchInfo.maxDy = Math.max(touchInfo.maxDy, Math.abs(delta.y)), touchInfo.maxDx = Math.max(touchInfo.maxDx, Math.abs(delta.x)), touchInfo.historyX.push(delta.x), touchInfo.historyY.push(delta.y), touchInfo.historyTime.push(
  12358. touchtrackEvent.detail.timeStamp || mouseEvent.timeStamp
  12359. ); touchInfo.historyTime.length > 10; ) {
  12360. touchInfo.historyTime.shift();
  12361. touchInfo.historyX.shift();
  12362. touchInfo.historyY.shift();
  12363. }
  12364. if (touchInfo.listener && touchInfo.listener.onTouchMove) {
  12365. touchInfo.listener.onTouchMove(delta.x, delta.y);
  12366. }
  12367. }
  12368. }
  12369. }
  12370. function handleTouchEnd(event) {
  12371. if (touchInfo.trackingID !== -1) {
  12372. event.preventDefault();
  12373. const delta = findDelta(event);
  12374. if (delta) {
  12375. const listener2 = touchInfo.listener;
  12376. touchInfo.trackingID = -1;
  12377. touchInfo.listener = null;
  12378. const length = touchInfo.historyTime.length;
  12379. const o2 = {
  12380. x: 0,
  12381. y: 0
  12382. };
  12383. if (length > 2) {
  12384. for (let i = touchInfo.historyTime.length - 1, time1 = touchInfo.historyTime[i], x = touchInfo.historyX[i], y = touchInfo.historyY[i]; i > 0; ) {
  12385. i--;
  12386. const time0 = touchInfo.historyTime[i];
  12387. const time = time1 - time0;
  12388. if (time > 30 && time < 50) {
  12389. o2.x = (x - touchInfo.historyX[i]) / (time / 1e3);
  12390. o2.y = (y - touchInfo.historyY[i]) / (time / 1e3);
  12391. break;
  12392. }
  12393. }
  12394. }
  12395. touchInfo.historyTime = [];
  12396. touchInfo.historyX = [];
  12397. touchInfo.historyY = [];
  12398. if (listener2 && listener2.onTouchEnd) {
  12399. listener2.onTouchEnd(delta.x, delta.y, o2);
  12400. }
  12401. }
  12402. }
  12403. }
  12404. return {
  12405. scroller,
  12406. handleTouchStart,
  12407. handleTouchMove,
  12408. handleTouchEnd
  12409. };
  12410. }
  12411. let scopedIndex = 0;
  12412. function useScopedClass(indicatorHeightRef) {
  12413. const className = `uni-picker-view-content-${scopedIndex++}`;
  12414. function updateStyle2() {
  12415. const style = document.createElement("style");
  12416. style.innerText = `.uni-picker-view-content.${className}>*{height: ${indicatorHeightRef.value}px;overflow: hidden;}`;
  12417. document.head.appendChild(style);
  12418. }
  12419. watch(() => indicatorHeightRef.value, updateStyle2);
  12420. return className;
  12421. }
  12422. function useCustomClick(dom) {
  12423. const MAX_MOVE = 20;
  12424. let x = 0;
  12425. let y = 0;
  12426. dom.addEventListener("touchstart", (event) => {
  12427. const info = event.changedTouches[0];
  12428. x = info.clientX;
  12429. y = info.clientY;
  12430. });
  12431. dom.addEventListener("touchend", (event) => {
  12432. const info = event.changedTouches[0];
  12433. if (Math.abs(info.clientX - x) < MAX_MOVE && Math.abs(info.clientY - y) < MAX_MOVE) {
  12434. const options = {
  12435. bubbles: true,
  12436. cancelable: true,
  12437. target: event.target,
  12438. currentTarget: event.currentTarget
  12439. };
  12440. const customClick = new CustomEvent("click", options);
  12441. const props2 = ["screenX", "screenY", "clientX", "clientY", "pageX", "pageY"];
  12442. props2.forEach((key) => {
  12443. customClick[key] = info[key];
  12444. });
  12445. event.target.dispatchEvent(customClick);
  12446. }
  12447. });
  12448. }
  12449. class UniPickerViewColumnElement extends UniElement {
  12450. }
  12451. const PickerViewColumn = /* @__PURE__ */ defineBuiltInComponent({
  12452. name: "PickerViewColumn",
  12453. rootElement: {
  12454. name: "uni-picker-view-column",
  12455. class: UniPickerViewColumnElement
  12456. },
  12457. setup(props2, {
  12458. slots,
  12459. emit: emit2
  12460. }) {
  12461. const rootRef = ref(null);
  12462. const contentRef = ref(null);
  12463. const getPickerViewColumn = inject("getPickerViewColumn");
  12464. const instance2 = getCurrentInstance();
  12465. const currentRef = getPickerViewColumn ? getPickerViewColumn(instance2) : ref(0);
  12466. const pickerViewProps2 = inject("pickerViewProps");
  12467. const pickerViewState = inject("pickerViewState");
  12468. const indicatorHeight = ref(34);
  12469. const resizeSensorRef = ref(null);
  12470. const initIndicatorHeight = () => {
  12471. const resizeSensor = resizeSensorRef.value;
  12472. indicatorHeight.value = resizeSensor.offsetHeight;
  12473. };
  12474. {
  12475. onMounted(initIndicatorHeight);
  12476. }
  12477. const maskSize = computed(() => (pickerViewState.height - indicatorHeight.value) / 2);
  12478. const {
  12479. state: scopedAttrsState
  12480. } = useScopedAttrs();
  12481. const className = useScopedClass(indicatorHeight);
  12482. let scroller;
  12483. const state2 = reactive({
  12484. current: currentRef.value,
  12485. length: 0
  12486. });
  12487. let updatesScrollerRequest;
  12488. function updatesScroller() {
  12489. if (scroller && !updatesScrollerRequest) {
  12490. updatesScrollerRequest = true;
  12491. nextTick(() => {
  12492. updatesScrollerRequest = false;
  12493. let current = Math.min(state2.current, state2.length - 1);
  12494. current = Math.max(current, 0);
  12495. scroller.update(current * indicatorHeight.value, void 0, indicatorHeight.value);
  12496. });
  12497. }
  12498. }
  12499. watch(() => currentRef.value, (current) => {
  12500. if (current !== state2.current) {
  12501. state2.current = current;
  12502. updatesScroller();
  12503. }
  12504. });
  12505. watch(() => state2.current, (current) => currentRef.value = current);
  12506. watch([() => indicatorHeight.value, () => state2.length, () => pickerViewState.height], updatesScroller);
  12507. let oldDeltaY = 0;
  12508. function handleWheel(event) {
  12509. const deltaY = oldDeltaY + event.deltaY;
  12510. if (Math.abs(deltaY) > 10) {
  12511. oldDeltaY = 0;
  12512. let current = Math.min(state2.current + (deltaY < 0 ? -1 : 1), state2.length - 1);
  12513. state2.current = current = Math.max(current, 0);
  12514. scroller.scrollTo(current * indicatorHeight.value);
  12515. } else {
  12516. oldDeltaY = deltaY;
  12517. }
  12518. event.preventDefault();
  12519. }
  12520. function handleTap({
  12521. clientY
  12522. }) {
  12523. const el = rootRef.value;
  12524. if (!scroller.isScrolling()) {
  12525. const rect = el.getBoundingClientRect();
  12526. const r = clientY - rect.top - pickerViewState.height / 2;
  12527. const o2 = indicatorHeight.value / 2;
  12528. if (!(Math.abs(r) <= o2)) {
  12529. const a2 = Math.ceil((Math.abs(r) - o2) / indicatorHeight.value);
  12530. const s = r < 0 ? -a2 : a2;
  12531. let current = Math.min(state2.current + s, state2.length - 1);
  12532. state2.current = current = Math.max(current, 0);
  12533. scroller.scrollTo(current * indicatorHeight.value);
  12534. }
  12535. }
  12536. }
  12537. const initScroller = () => {
  12538. const el = rootRef.value;
  12539. const content = contentRef.value;
  12540. const {
  12541. scroller: scrollerOrigin,
  12542. handleTouchStart,
  12543. handleTouchMove,
  12544. handleTouchEnd
  12545. } = useScroller(content, {
  12546. enableY: true,
  12547. enableX: false,
  12548. enableSnap: true,
  12549. itemSize: indicatorHeight.value,
  12550. friction: new Friction(1e-4),
  12551. spring: new Spring(2, 90, 20),
  12552. onSnap: (index2) => {
  12553. if (!isNaN(index2) && index2 !== state2.current) {
  12554. state2.current = index2;
  12555. }
  12556. }
  12557. });
  12558. scroller = scrollerOrigin;
  12559. useTouchtrack(el, (e2) => {
  12560. switch (e2.detail.state) {
  12561. case "start":
  12562. handleTouchStart(e2);
  12563. break;
  12564. case "move":
  12565. handleTouchMove(e2);
  12566. e2.stopPropagation();
  12567. break;
  12568. case "end":
  12569. case "cancel":
  12570. handleTouchEnd(e2);
  12571. }
  12572. }, true);
  12573. useCustomClick(el);
  12574. updatesScroller();
  12575. };
  12576. {
  12577. onMounted(initScroller);
  12578. }
  12579. let currentCache = state2.current;
  12580. watch(() => state2.current, (newCurrent) => {
  12581. currentCache = newCurrent;
  12582. });
  12583. onMounted(() => {
  12584. const rootElement = rootRef.value;
  12585. Object.defineProperty(rootElement, "current", {
  12586. get() {
  12587. return currentCache;
  12588. },
  12589. set(current) {
  12590. currentCache = current;
  12591. scroller.scrollTo(current * indicatorHeight.value);
  12592. }
  12593. });
  12594. rootElement.attachVmProps(props2);
  12595. });
  12596. return () => {
  12597. const defaultSlots = slots.default && slots.default();
  12598. {
  12599. state2.length = flatVNode(defaultSlots).length;
  12600. }
  12601. const padding = `${maskSize.value}px 0`;
  12602. return createVNode("uni-picker-view-column", {
  12603. "ref": rootRef
  12604. }, [createVNode("div", {
  12605. "onWheel": handleWheel,
  12606. "onClick": handleTap,
  12607. "class": "uni-picker-view-group"
  12608. }, [createVNode("div", mergeProps(scopedAttrsState.attrs, {
  12609. "class": ["uni-picker-view-mask", pickerViewProps2.maskClass],
  12610. "style": `background-size: 100% ${maskSize.value}px;${pickerViewProps2.maskStyle}`
  12611. }), null, 16), createVNode("div", mergeProps(scopedAttrsState.attrs, {
  12612. "class": ["uni-picker-view-indicator", pickerViewProps2.indicatorClass],
  12613. "style": pickerViewProps2.indicatorStyle
  12614. }), [createVNode(ResizeSensor, {
  12615. "ref": resizeSensorRef,
  12616. "onResize": ({
  12617. height
  12618. }) => indicatorHeight.value = height
  12619. }, null, 8, ["onResize"])], 16), createVNode("div", {
  12620. "ref": contentRef,
  12621. "class": ["uni-picker-view-content", className],
  12622. "style": {
  12623. padding
  12624. }
  12625. }, [defaultSlots], 6)], 40, ["onWheel", "onClick"])], 512);
  12626. };
  12627. }
  12628. });
  12629. const FONT_SIZE = 16;
  12630. const PROGRESS_VALUES = {
  12631. activeColor: PRIMARY_COLOR,
  12632. backgroundColor: "#EBEBEB",
  12633. activeMode: "backwards"
  12634. };
  12635. const progressProps = {
  12636. percent: {
  12637. type: [Number, String],
  12638. default: 0,
  12639. validator(value) {
  12640. return !isNaN(parseFloat(value));
  12641. }
  12642. },
  12643. fontSize: {
  12644. type: [String, Number],
  12645. default: FONT_SIZE
  12646. },
  12647. showInfo: {
  12648. type: [Boolean, String],
  12649. default: false
  12650. },
  12651. strokeWidth: {
  12652. type: [Number, String],
  12653. default: 6,
  12654. validator(value) {
  12655. return !isNaN(parseFloat(value));
  12656. }
  12657. },
  12658. color: {
  12659. type: String,
  12660. default: PROGRESS_VALUES.activeColor
  12661. },
  12662. activeColor: {
  12663. type: String,
  12664. default: PROGRESS_VALUES.activeColor
  12665. },
  12666. backgroundColor: {
  12667. type: String,
  12668. default: PROGRESS_VALUES.backgroundColor
  12669. },
  12670. active: {
  12671. type: [Boolean, String],
  12672. default: false
  12673. },
  12674. activeMode: {
  12675. type: String,
  12676. default: PROGRESS_VALUES.activeMode
  12677. },
  12678. duration: {
  12679. type: [Number, String],
  12680. default: 30,
  12681. validator(value) {
  12682. return !isNaN(parseFloat(value));
  12683. }
  12684. },
  12685. borderRadius: {
  12686. type: [Number, String],
  12687. default: 0
  12688. }
  12689. };
  12690. class UniProgressElement extends UniElement {
  12691. }
  12692. const index$p = /* @__PURE__ */ defineBuiltInComponent({
  12693. name: "Progress",
  12694. props: progressProps,
  12695. rootElement: {
  12696. name: "uni-progress",
  12697. class: UniProgressElement
  12698. },
  12699. setup(props2) {
  12700. const rootRef = ref(null);
  12701. const state2 = useProgressState(props2);
  12702. _activeAnimation(state2, props2);
  12703. watch(() => state2.realPercent, (newValue, oldValue) => {
  12704. state2.strokeTimer && clearInterval(state2.strokeTimer);
  12705. state2.lastPercent = oldValue || 0;
  12706. _activeAnimation(state2, props2);
  12707. });
  12708. let percentCache = state2.currentPercent;
  12709. watch(() => state2.currentPercent, (newPercent) => {
  12710. percentCache = newPercent;
  12711. });
  12712. onMounted(() => {
  12713. const rootElement = rootRef.value;
  12714. Object.defineProperty(rootElement, "percent", {
  12715. get() {
  12716. return percentCache;
  12717. },
  12718. set(value) {
  12719. percentCache = value;
  12720. rootElement.querySelector(".uni-progress-inner-bar").style.width = `${value}%`;
  12721. if (props2.showInfo) {
  12722. rootElement.querySelector(".uni-progress-info").innerText = `${value}%`;
  12723. }
  12724. }
  12725. });
  12726. rootElement.attachVmProps(props2);
  12727. });
  12728. return () => {
  12729. const {
  12730. showInfo
  12731. } = props2;
  12732. const {
  12733. outerBarStyle,
  12734. innerBarStyle,
  12735. currentPercent
  12736. } = state2;
  12737. return createVNode("uni-progress", {
  12738. "class": "uni-progress",
  12739. "ref": rootRef
  12740. }, [createVNode("div", {
  12741. "style": outerBarStyle,
  12742. "class": "uni-progress-bar"
  12743. }, [createVNode("div", {
  12744. "style": innerBarStyle,
  12745. "class": "uni-progress-inner-bar"
  12746. }, null, 4)], 4), showInfo ? (
  12747. // {currentPercent}% 的写法会影响 SSR Hydration (tsx插件的问题)
  12748. createVNode("p", {
  12749. "class": "uni-progress-info"
  12750. }, [currentPercent + "%"])
  12751. ) : ""], 512);
  12752. };
  12753. }
  12754. });
  12755. function useProgressState(props2) {
  12756. const currentPercent = ref(0);
  12757. const outerBarStyle = computed(() => `background-color: ${props2.backgroundColor}; height: ${props2.strokeWidth}px;`);
  12758. const innerBarStyle = computed(() => {
  12759. const backgroundColor = props2.color !== PROGRESS_VALUES.activeColor && props2.activeColor === PROGRESS_VALUES.activeColor ? props2.color : props2.activeColor;
  12760. return `width: ${currentPercent.value}%;background-color: ${backgroundColor}`;
  12761. });
  12762. const realPercent = computed(() => {
  12763. let realValue = parseFloat(props2.percent);
  12764. realValue < 0 && (realValue = 0);
  12765. realValue > 100 && (realValue = 100);
  12766. return realValue;
  12767. });
  12768. const state2 = reactive({
  12769. outerBarStyle,
  12770. innerBarStyle,
  12771. realPercent,
  12772. currentPercent,
  12773. strokeTimer: 0,
  12774. lastPercent: 0
  12775. });
  12776. return state2;
  12777. }
  12778. function _activeAnimation(state2, props2) {
  12779. if (props2.active) {
  12780. state2.currentPercent = props2.activeMode === PROGRESS_VALUES.activeMode ? 0 : state2.lastPercent;
  12781. state2.strokeTimer = setInterval(() => {
  12782. if (state2.currentPercent + 1 > state2.realPercent) {
  12783. state2.currentPercent = state2.realPercent;
  12784. state2.strokeTimer && clearInterval(state2.strokeTimer);
  12785. } else {
  12786. state2.currentPercent += 1;
  12787. }
  12788. }, parseFloat(props2.duration));
  12789. } else {
  12790. state2.currentPercent = state2.realPercent;
  12791. }
  12792. }
  12793. const uniRadioGroupKey = PolySymbol(process.env.NODE_ENV !== "production" ? "uniCheckGroup" : "ucg");
  12794. const props$p = {
  12795. name: {
  12796. type: String,
  12797. default: ""
  12798. }
  12799. };
  12800. class UniRadioGroupElement extends UniElement {
  12801. }
  12802. const index$o = /* @__PURE__ */ defineBuiltInComponent({
  12803. name: "RadioGroup",
  12804. props: props$p,
  12805. // emits: ['change'],
  12806. rootElement: {
  12807. name: "uni-radio-group",
  12808. class: UniRadioGroupElement
  12809. },
  12810. setup(props2, {
  12811. emit: emit2,
  12812. slots
  12813. }) {
  12814. const rootRef = ref(null);
  12815. const trigger = useCustomEvent(rootRef, emit2);
  12816. useProvideRadioGroup(props2, trigger);
  12817. onMounted(() => {
  12818. const rootElement = rootRef.value;
  12819. rootElement.attachVmProps(props2);
  12820. });
  12821. return () => {
  12822. return createVNode("uni-radio-group", {
  12823. "ref": rootRef
  12824. }, [slots.default && slots.default()], 512);
  12825. };
  12826. }
  12827. });
  12828. function useProvideRadioGroup(props2, trigger) {
  12829. const fields2 = [];
  12830. onMounted(() => {
  12831. _resetRadioGroupValue(fields2.length - 1);
  12832. });
  12833. const getFieldsValue = () => {
  12834. var _a;
  12835. return ((_a = fields2.find((field) => field.value.radioChecked)) == null ? void 0 : _a.value.value) + "";
  12836. };
  12837. provide(uniRadioGroupKey, {
  12838. addField(field) {
  12839. fields2.push(field);
  12840. },
  12841. removeField(field) {
  12842. fields2.splice(fields2.indexOf(field), 1);
  12843. },
  12844. radioChange($event, field) {
  12845. const index2 = fields2.indexOf(field);
  12846. _resetRadioGroupValue(index2, true);
  12847. trigger("change", $event, {
  12848. value: getFieldsValue()
  12849. });
  12850. }
  12851. });
  12852. const uniForm = inject(uniFormKey, false);
  12853. const formField = {
  12854. submit: () => {
  12855. let data = ["", null];
  12856. if (props2.name !== "") {
  12857. data[0] = props2.name;
  12858. data[1] = getFieldsValue();
  12859. }
  12860. return data;
  12861. }
  12862. };
  12863. if (uniForm) {
  12864. uniForm.addField(formField);
  12865. onBeforeUnmount(() => {
  12866. uniForm.removeField(formField);
  12867. });
  12868. }
  12869. function setFieldChecked(field, radioChecked) {
  12870. field.value = {
  12871. radioChecked,
  12872. value: field.value.value
  12873. };
  12874. }
  12875. function _resetRadioGroupValue(key, change) {
  12876. fields2.forEach((value, index2) => {
  12877. if (index2 === key) {
  12878. return;
  12879. }
  12880. if (change) {
  12881. setFieldChecked(fields2[index2], false);
  12882. } else {
  12883. fields2.forEach((v2, i) => {
  12884. if (index2 >= i) {
  12885. return;
  12886. }
  12887. if (fields2[i].value.radioChecked) {
  12888. setFieldChecked(fields2[index2], false);
  12889. }
  12890. });
  12891. }
  12892. });
  12893. }
  12894. return fields2;
  12895. }
  12896. const props$o = {
  12897. checked: {
  12898. type: [Boolean, String],
  12899. default: false
  12900. },
  12901. id: {
  12902. type: String,
  12903. default: ""
  12904. },
  12905. disabled: {
  12906. type: [Boolean, String],
  12907. default: false
  12908. },
  12909. value: {
  12910. type: String,
  12911. default: ""
  12912. },
  12913. color: {
  12914. type: String,
  12915. default: "#007aff"
  12916. },
  12917. backgroundColor: {
  12918. type: String,
  12919. default: ""
  12920. },
  12921. borderColor: {
  12922. type: String,
  12923. default: ""
  12924. },
  12925. activeBackgroundColor: {
  12926. type: String,
  12927. default: ""
  12928. },
  12929. activeBorderColor: {
  12930. type: String,
  12931. default: ""
  12932. },
  12933. iconColor: {
  12934. type: String,
  12935. default: "#ffffff"
  12936. }
  12937. };
  12938. class UniRadioElement extends UniElement {
  12939. }
  12940. const indexX$2 = /* @__PURE__ */ defineBuiltInComponent({
  12941. name: "Radio",
  12942. props: props$o,
  12943. rootElement: {
  12944. name: "uni-radio",
  12945. class: UniRadioElement
  12946. },
  12947. setup(props2, {
  12948. slots
  12949. }) {
  12950. const rootRef = ref(null);
  12951. const radioChecked = ref(props2.checked);
  12952. const radioValue = ref(props2.value);
  12953. const initialCheckedValue = props2.checked;
  12954. function getRadioStyle(checked) {
  12955. if (props2.disabled) {
  12956. return {
  12957. backgroundColor: "#E1E1E1",
  12958. borderColor: "#D1D1D1"
  12959. };
  12960. }
  12961. const style = {};
  12962. if (radioChecked.value) {
  12963. style.backgroundColor = props2.activeBackgroundColor || props2.color;
  12964. style.borderColor = props2.activeBorderColor || style.backgroundColor;
  12965. } else {
  12966. if (props2.borderColor)
  12967. style.borderColor = props2.borderColor;
  12968. if (props2.backgroundColor)
  12969. style.backgroundColor = props2.backgroundColor;
  12970. }
  12971. return style;
  12972. }
  12973. const radioStyle = computed(() => {
  12974. return getRadioStyle(radioChecked.value);
  12975. });
  12976. watch([() => props2.checked, () => props2.value], ([newChecked, newModelValue]) => {
  12977. radioChecked.value = newChecked;
  12978. radioValue.value = newModelValue;
  12979. });
  12980. const reset = () => {
  12981. radioChecked.value = initialCheckedValue;
  12982. };
  12983. const {
  12984. uniCheckGroup,
  12985. uniLabel,
  12986. field
  12987. } = useRadioInject(radioChecked, radioValue, reset);
  12988. const _onClick = ($event) => {
  12989. if (props2.disabled || radioChecked.value) {
  12990. return;
  12991. }
  12992. radioChecked.value = true;
  12993. uniCheckGroup && uniCheckGroup.radioChange($event, field);
  12994. $event.stopPropagation();
  12995. };
  12996. if (!!uniLabel) {
  12997. uniLabel.addHandler(_onClick);
  12998. onBeforeUnmount(() => {
  12999. uniLabel.removeHandler(_onClick);
  13000. });
  13001. }
  13002. useListeners$1(props2, {
  13003. "label-click": _onClick
  13004. });
  13005. const checkedCache = ref(radioChecked.value);
  13006. watch(() => radioChecked.value, (value) => {
  13007. checkedCache.value = value;
  13008. });
  13009. onMounted(() => {
  13010. const rootElement = rootRef.value;
  13011. Object.defineProperty(rootElement, "checked", {
  13012. get() {
  13013. return checkedCache.value;
  13014. },
  13015. set(value) {
  13016. checkedCache.value = value;
  13017. const style = getRadioStyle();
  13018. const checkboxInputElement = rootElement.querySelector(".uni-checkbox-input");
  13019. for (const key in style) {
  13020. const value2 = style[key];
  13021. value2 && checkboxInputElement.style.setProperty(key, value2);
  13022. }
  13023. }
  13024. });
  13025. rootElement.attachVmProps(props2);
  13026. });
  13027. return () => {
  13028. const booleanAttrs = useBooleanAttr(props2, "disabled");
  13029. let realCheckValue;
  13030. realCheckValue = checkedCache.value;
  13031. return createVNode("uni-radio", mergeProps(booleanAttrs, {
  13032. "onClick": _onClick,
  13033. "ref": rootRef,
  13034. "id": props2.id,
  13035. "class": "uni-radio-wrapper",
  13036. "style": {
  13037. "--HOVER-BD-COLOR": !radioChecked.value ? props2.activeBorderColor : radioStyle.value.borderColor
  13038. }
  13039. }), [createVNode("div", {
  13040. "class": ["uni-radio-input", {
  13041. "uni-radio-input-disabled": props2.disabled
  13042. }],
  13043. "style": radioStyle.value
  13044. }, [realCheckValue ? createSvgIconVNode(ICON_PATH_SUCCESS_NO_CIRCLE, props2.disabled ? "#ADADAD" : props2.iconColor, 18) : ""], 6), slots.default && slots.default()], 16, ["onClick", "id"]);
  13045. };
  13046. }
  13047. });
  13048. function useRadioInject(radioChecked, radioValue, reset) {
  13049. const field = computed({
  13050. get: () => ({
  13051. radioChecked: Boolean(radioChecked.value),
  13052. value: radioValue.value
  13053. }),
  13054. set: ({
  13055. radioChecked: checked
  13056. }) => {
  13057. radioChecked.value = checked;
  13058. }
  13059. });
  13060. const formField = {
  13061. reset
  13062. };
  13063. const uniCheckGroup = inject(uniRadioGroupKey, false);
  13064. if (!!uniCheckGroup) {
  13065. uniCheckGroup.addField(field);
  13066. }
  13067. const uniForm = inject(uniFormKey, false);
  13068. if (!!uniForm) {
  13069. uniForm.addField(formField);
  13070. }
  13071. const uniLabel = inject(uniLabelKey, false);
  13072. onBeforeUnmount(() => {
  13073. uniCheckGroup && uniCheckGroup.removeField(field);
  13074. uniForm && uniForm.removeField(formField);
  13075. });
  13076. return {
  13077. uniCheckGroup,
  13078. uniForm,
  13079. uniLabel,
  13080. field
  13081. };
  13082. }
  13083. const TAGS = {
  13084. a: "",
  13085. abbr: "",
  13086. address: "",
  13087. article: "",
  13088. aside: "",
  13089. b: "",
  13090. bdi: "",
  13091. bdo: ["dir"],
  13092. big: "",
  13093. blockquote: "",
  13094. br: "",
  13095. caption: "",
  13096. center: "",
  13097. cite: "",
  13098. code: "",
  13099. col: ["span", "width"],
  13100. colgroup: ["span", "width"],
  13101. dd: "",
  13102. del: "",
  13103. div: "",
  13104. dl: "",
  13105. dt: "",
  13106. em: "",
  13107. fieldset: "",
  13108. font: "",
  13109. footer: "",
  13110. h1: "",
  13111. h2: "",
  13112. h3: "",
  13113. h4: "",
  13114. h5: "",
  13115. h6: "",
  13116. header: "",
  13117. hr: "",
  13118. i: "",
  13119. img: ["alt", "src", "height", "width"],
  13120. ins: "",
  13121. label: "",
  13122. legend: "",
  13123. li: "",
  13124. mark: "",
  13125. nav: "",
  13126. ol: ["start", "type"],
  13127. p: "",
  13128. pre: "",
  13129. q: "",
  13130. rt: "",
  13131. ruby: "",
  13132. s: "",
  13133. section: "",
  13134. small: "",
  13135. span: "",
  13136. strong: "",
  13137. sub: "",
  13138. sup: "",
  13139. table: ["width"],
  13140. tbody: "",
  13141. td: ["colspan", "height", "rowspan", "width"],
  13142. tfoot: "",
  13143. th: ["colspan", "height", "rowspan", "width"],
  13144. thead: "",
  13145. tr: ["colspan", "height", "rowspan", "width"],
  13146. tt: "",
  13147. u: "",
  13148. ul: ""
  13149. };
  13150. const CHARS = {
  13151. amp: "&",
  13152. gt: ">",
  13153. lt: "<",
  13154. nbsp: " ",
  13155. quot: '"',
  13156. apos: "'",
  13157. ldquo: "“",
  13158. rdquo: "”",
  13159. yen: "¥",
  13160. radic: "√",
  13161. lceil: "⌈",
  13162. rceil: "⌉",
  13163. lfloor: "⌊",
  13164. rfloor: "⌋",
  13165. hellip: "…"
  13166. };
  13167. function decodeEntities(htmlString) {
  13168. return htmlString.replace(
  13169. /&(([a-zA-Z]+)|(#x{0,1}[\da-zA-Z]+));/gi,
  13170. function(match, stage) {
  13171. if (hasOwn(CHARS, stage) && CHARS[stage]) {
  13172. return CHARS[stage];
  13173. }
  13174. if (/^#[0-9]{1,4}$/.test(stage)) {
  13175. return String.fromCharCode(stage.slice(1));
  13176. }
  13177. if (/^#x[0-9a-f]{1,4}$/i.test(stage)) {
  13178. return String.fromCharCode(0 + stage.slice(1));
  13179. }
  13180. return match;
  13181. }
  13182. );
  13183. }
  13184. function processClickEvent(node, triggerItemClick) {
  13185. if (["a", "img"].includes(node.name) && triggerItemClick) {
  13186. return {
  13187. onClick: (e2) => {
  13188. triggerItemClick(e2, { node });
  13189. e2.stopPropagation();
  13190. e2.preventDefault();
  13191. e2.returnValue = false;
  13192. }
  13193. };
  13194. }
  13195. }
  13196. function normalizeAttrs(tagName, attrs2) {
  13197. if (!isPlainObject(attrs2))
  13198. return;
  13199. for (const key in attrs2) {
  13200. if (hasOwn(attrs2, key)) {
  13201. const value = attrs2[key];
  13202. if (tagName === "img" && key === "src")
  13203. attrs2[key] = getRealPath(value);
  13204. }
  13205. }
  13206. }
  13207. const nodeList2VNode = (scopeId, triggerItemClick, nodeList) => {
  13208. if (!nodeList || isArray(nodeList) && !nodeList.length)
  13209. return [];
  13210. return nodeList.map((node) => {
  13211. if (!isPlainObject(node)) {
  13212. return;
  13213. }
  13214. if (!hasOwn(node, "type") || node.type === "node") {
  13215. let nodeProps = { [scopeId]: "" };
  13216. const tagName = node.name.toLowerCase();
  13217. if (!hasOwn(TAGS, tagName)) {
  13218. return;
  13219. }
  13220. normalizeAttrs(tagName, node.attrs);
  13221. nodeProps = extend(
  13222. nodeProps,
  13223. processClickEvent(node, triggerItemClick),
  13224. node.attrs
  13225. );
  13226. return h(
  13227. node.name,
  13228. nodeProps,
  13229. nodeList2VNode(scopeId, triggerItemClick, node.children)
  13230. );
  13231. }
  13232. if (node.type === "text" && isString(node.text) && node.text !== "")
  13233. return createTextVNode(decodeEntities(node.text || ""));
  13234. });
  13235. };
  13236. function removeDOCTYPE(html) {
  13237. return html.replace(/<\?xml.*\?>\n/, "").replace(/<!doctype.*>\n/, "").replace(/<!DOCTYPE.*>\n/, "");
  13238. }
  13239. function parseAttrs(attrs2) {
  13240. return attrs2.reduce(function(pre, attr2) {
  13241. let value = attr2.value;
  13242. const name = attr2.name;
  13243. if (value.match(/ /) && ["style", "src"].indexOf(name) === -1) {
  13244. value = value.split(" ");
  13245. }
  13246. if (pre[name]) {
  13247. if (Array.isArray(pre[name])) {
  13248. pre[name].push(value);
  13249. } else {
  13250. pre[name] = [pre[name], value];
  13251. }
  13252. } else {
  13253. pre[name] = value;
  13254. }
  13255. return pre;
  13256. }, {});
  13257. }
  13258. function parseHtml(html) {
  13259. html = removeDOCTYPE(html);
  13260. const stacks = [];
  13261. const results = {
  13262. node: "root",
  13263. children: []
  13264. };
  13265. HTMLParser(html, {
  13266. start: function(tag, attrs2, unary) {
  13267. const node = {
  13268. name: tag
  13269. };
  13270. if (attrs2.length !== 0) {
  13271. node.attrs = parseAttrs(attrs2);
  13272. }
  13273. if (unary) {
  13274. const parent = stacks[0] || results;
  13275. if (!parent.children) {
  13276. parent.children = [];
  13277. }
  13278. parent.children.push(node);
  13279. } else {
  13280. stacks.unshift(node);
  13281. }
  13282. },
  13283. end: function(tag) {
  13284. const node = stacks.shift();
  13285. if (node.name !== tag)
  13286. console.error("invalid state: mismatch end tag");
  13287. if (stacks.length === 0) {
  13288. results.children.push(node);
  13289. } else {
  13290. const parent = stacks[0];
  13291. if (!parent.children) {
  13292. parent.children = [];
  13293. }
  13294. parent.children.push(node);
  13295. }
  13296. },
  13297. chars: function(text2) {
  13298. const node = {
  13299. type: "text",
  13300. text: text2
  13301. };
  13302. if (stacks.length === 0) {
  13303. results.children.push(node);
  13304. } else {
  13305. const parent = stacks[0];
  13306. if (!parent.children) {
  13307. parent.children = [];
  13308. }
  13309. parent.children.push(node);
  13310. }
  13311. },
  13312. comment: function(text2) {
  13313. const node = {
  13314. node: "comment",
  13315. text: text2
  13316. };
  13317. const parent = stacks[0];
  13318. if (!parent.children) {
  13319. parent.children = [];
  13320. }
  13321. parent.children.push(node);
  13322. }
  13323. });
  13324. return results.children;
  13325. }
  13326. const props$n = {
  13327. nodes: {
  13328. type: [Array, String],
  13329. default: function() {
  13330. return [];
  13331. }
  13332. }
  13333. };
  13334. class UniRichTextElement extends UniElement {
  13335. }
  13336. const index$n = /* @__PURE__ */ defineBuiltInComponent({
  13337. name: "RichText",
  13338. compatConfig: {
  13339. MODE: 3
  13340. },
  13341. props: props$n,
  13342. emits: ["click", "touchstart", "touchmove", "touchcancel", "touchend", "longpress", "itemclick"],
  13343. rootElement: {
  13344. name: "uni-rich-text",
  13345. class: UniRichTextElement
  13346. },
  13347. setup(props2, {
  13348. emit: emit2
  13349. }) {
  13350. const vm = getCurrentInstance();
  13351. const scopeId = vm && vm.vnode.scopeId || "";
  13352. const rootRef = ref(null);
  13353. const _vnode = ref([]);
  13354. const trigger = useCustomEvent(rootRef, emit2);
  13355. function triggerItemClick(e2, detail = {}) {
  13356. trigger("itemclick", e2, detail);
  13357. }
  13358. function renderVNode() {
  13359. let nodeList = props2.nodes;
  13360. if (isString(nodeList)) {
  13361. nodeList = parseHtml(props2.nodes);
  13362. }
  13363. _vnode.value = nodeList2VNode(scopeId, triggerItemClick, nodeList);
  13364. }
  13365. watch(() => props2.nodes, renderVNode, {
  13366. immediate: true
  13367. });
  13368. onMounted(() => {
  13369. const rootElement = rootRef.value;
  13370. rootElement.attachVmProps(props2);
  13371. });
  13372. return () => h("uni-rich-text", {
  13373. ref: rootRef
  13374. }, h("div", {}, _vnode.value));
  13375. }
  13376. });
  13377. const passiveOptions = /* @__PURE__ */ passive(true);
  13378. const props$m = {
  13379. direction: {
  13380. type: [String],
  13381. default: "vertical"
  13382. },
  13383. scrollX: {
  13384. type: [Boolean, String],
  13385. default: false
  13386. },
  13387. scrollY: {
  13388. type: [Boolean, String],
  13389. default: false
  13390. },
  13391. showScrollbar: {
  13392. type: [Boolean, String],
  13393. default: true
  13394. },
  13395. upperThreshold: {
  13396. type: [Number, String],
  13397. default: 50
  13398. },
  13399. lowerThreshold: {
  13400. type: [Number, String],
  13401. default: 50
  13402. },
  13403. scrollTop: {
  13404. type: [Number, String],
  13405. default: 0
  13406. },
  13407. scrollLeft: {
  13408. type: [Number, String],
  13409. default: 0
  13410. },
  13411. scrollIntoView: {
  13412. type: String,
  13413. default: ""
  13414. },
  13415. scrollWithAnimation: {
  13416. type: [Boolean, String],
  13417. default: false
  13418. },
  13419. enableBackToTop: {
  13420. type: [Boolean, String],
  13421. default: false
  13422. },
  13423. refresherEnabled: {
  13424. type: [Boolean, String],
  13425. default: false
  13426. },
  13427. refresherThreshold: {
  13428. type: Number,
  13429. default: 45
  13430. },
  13431. refresherDefaultStyle: {
  13432. type: String,
  13433. default: "back"
  13434. },
  13435. refresherBackground: {
  13436. type: String,
  13437. default: "#fff"
  13438. },
  13439. refresherTriggered: {
  13440. type: [Boolean, String],
  13441. default: false
  13442. }
  13443. };
  13444. class UniScrollViewElement extends UniElement {
  13445. }
  13446. const ScrollView = /* @__PURE__ */ defineBuiltInComponent({
  13447. name: "ScrollView",
  13448. compatConfig: {
  13449. MODE: 3
  13450. },
  13451. props: props$m,
  13452. emits: ["scroll", "scrolltoupper", "scrolltolower", "refresherrefresh", "refresherrestore", "refresherpulling", "refresherabort", "update:refresherTriggered"],
  13453. rootElement: {
  13454. name: "uni-scroll-view",
  13455. class: UniScrollViewElement
  13456. },
  13457. setup(props2, {
  13458. emit: emit2,
  13459. slots
  13460. }) {
  13461. const rootRef = ref(null);
  13462. const main = ref(null);
  13463. const wrap = ref(null);
  13464. const content = ref(null);
  13465. const refresherinner = ref(null);
  13466. const trigger = useCustomEvent(rootRef, emit2);
  13467. const {
  13468. state: state2,
  13469. scrollTopNumber,
  13470. scrollLeftNumber
  13471. } = useScrollViewState(props2);
  13472. const {
  13473. realScrollX,
  13474. realScrollY
  13475. } = useScrollViewLoader(props2, state2, scrollTopNumber, scrollLeftNumber, trigger, rootRef, main, content, emit2);
  13476. const mainStyle = computed(() => {
  13477. let style = "";
  13478. realScrollX.value ? style += "overflow-x:auto;" : style += "overflow-x:hidden;";
  13479. realScrollY.value ? style += "overflow-y:auto;" : style += "overflow-y:hidden;";
  13480. return style;
  13481. });
  13482. const scrollBarClassName = computed(() => {
  13483. let className = "uni-scroll-view";
  13484. if (props2.showScrollbar === false) {
  13485. className += " uni-scroll-view-scrollbar-hidden";
  13486. }
  13487. return className;
  13488. });
  13489. onMounted(() => {
  13490. const rootElement = rootRef.value;
  13491. Object.defineProperties(rootElement, {
  13492. scrollHeight: {
  13493. get() {
  13494. return main.value.scrollHeight;
  13495. }
  13496. },
  13497. scrollWidth: {
  13498. get() {
  13499. return main.value.scrollWidth;
  13500. }
  13501. },
  13502. scrollLeft: {
  13503. get() {
  13504. return main.value.scrollLeft;
  13505. },
  13506. set(val) {
  13507. main.value.scrollLeft = val;
  13508. }
  13509. },
  13510. scrollTop: {
  13511. get() {
  13512. return main.value.scrollTop;
  13513. },
  13514. set(val) {
  13515. main.value.scrollTop = val;
  13516. }
  13517. },
  13518. scrollBy: {
  13519. get() {
  13520. return main.value.scrollBy.bind(main.value);
  13521. }
  13522. }
  13523. });
  13524. rootElement.attachVmProps(props2);
  13525. });
  13526. return () => {
  13527. const {
  13528. refresherEnabled,
  13529. refresherBackground,
  13530. refresherDefaultStyle
  13531. } = props2;
  13532. const {
  13533. refresherHeight,
  13534. refreshState,
  13535. refreshRotate
  13536. } = state2;
  13537. return createVNode("uni-scroll-view", {
  13538. "ref": rootRef
  13539. }, [createVNode("div", {
  13540. "ref": wrap,
  13541. "class": "uni-scroll-view"
  13542. }, [createVNode("div", {
  13543. "ref": main,
  13544. "style": mainStyle.value,
  13545. "class": scrollBarClassName.value
  13546. }, [createVNode("div", {
  13547. "ref": content,
  13548. "class": "uni-scroll-view-content"
  13549. }, [refresherEnabled ? createVNode("div", {
  13550. "ref": refresherinner,
  13551. "style": {
  13552. backgroundColor: refresherBackground,
  13553. height: refresherHeight + "px"
  13554. },
  13555. "class": "uni-scroll-view-refresher"
  13556. }, [refresherDefaultStyle !== "none" ? createVNode("div", {
  13557. "class": "uni-scroll-view-refresh"
  13558. }, [createVNode("div", {
  13559. "class": "uni-scroll-view-refresh-inner"
  13560. }, [refreshState == "pulling" ? createVNode("svg", {
  13561. "key": "refresh__icon",
  13562. "style": {
  13563. transform: "rotate(" + refreshRotate + "deg)"
  13564. },
  13565. "fill": "#2BD009",
  13566. "class": "uni-scroll-view-refresh__icon",
  13567. "width": "24",
  13568. "height": "24",
  13569. "viewBox": "0 0 24 24"
  13570. }, [createVNode("path", {
  13571. "d": "M17.65 6.35C16.2 4.9 14.21 4 12 4c-4.42 0-7.99 3.58-7.99 8s3.57 8 7.99 8c3.73 0 6.84-2.55 7.73-6h-2.08c-.82 2.33-3.04 4-5.65 4-3.31 0-6-2.69-6-6s2.69-6 6-6c1.66 0 3.14.69 4.22 1.78L13 11h7V4l-2.35 2.35z"
  13572. }, null), createVNode("path", {
  13573. "d": "M0 0h24v24H0z",
  13574. "fill": "none"
  13575. }, null)], 4) : null, refreshState == "refreshing" ? createVNode("svg", {
  13576. "key": "refresh__spinner",
  13577. "class": "uni-scroll-view-refresh__spinner",
  13578. "width": "24",
  13579. "height": "24",
  13580. "viewBox": "25 25 50 50"
  13581. }, [createVNode("circle", {
  13582. "cx": "50",
  13583. "cy": "50",
  13584. "r": "20",
  13585. "fill": "none",
  13586. "style": "color: #2bd009",
  13587. "stroke-width": "3"
  13588. }, null)]) : null])]) : null, refresherDefaultStyle == "none" ? slots.refresher && slots.refresher() : null], 4) : null, slots.default && slots.default()], 512)], 6)], 512)], 512);
  13589. };
  13590. }
  13591. });
  13592. function useScrollViewState(props2) {
  13593. const scrollTopNumber = computed(() => {
  13594. return Number(props2.scrollTop) || 0;
  13595. });
  13596. const scrollLeftNumber = computed(() => {
  13597. return Number(props2.scrollLeft) || 0;
  13598. });
  13599. const state2 = reactive({
  13600. lastScrollTop: scrollTopNumber.value,
  13601. lastScrollLeft: scrollLeftNumber.value,
  13602. lastScrollToUpperTime: 0,
  13603. lastScrollToLowerTime: 0,
  13604. refresherHeight: 0,
  13605. refreshRotate: 0,
  13606. refreshState: ""
  13607. });
  13608. return {
  13609. state: state2,
  13610. scrollTopNumber,
  13611. scrollLeftNumber
  13612. };
  13613. }
  13614. function useScrollViewLoader(props2, state2, scrollTopNumber, scrollLeftNumber, trigger, rootRef, main, content, emit2) {
  13615. let beforeRefreshing = false;
  13616. let toUpperNumber = 0;
  13617. let triggerAbort = false;
  13618. let __transitionEnd = () => {
  13619. };
  13620. const realScrollX = computed(() => {
  13621. if (props2.direction === "horizontal" || props2.direction === "all") {
  13622. return true;
  13623. }
  13624. return false;
  13625. });
  13626. const realScrollY = computed(() => {
  13627. if (props2.direction === "vertical" || props2.direction === "all") {
  13628. return true;
  13629. }
  13630. return false;
  13631. });
  13632. const upperThresholdNumber = computed(() => {
  13633. let val = Number(props2.upperThreshold);
  13634. return isNaN(val) ? 50 : val;
  13635. });
  13636. const lowerThresholdNumber = computed(() => {
  13637. let val = Number(props2.lowerThreshold);
  13638. return isNaN(val) ? 50 : val;
  13639. });
  13640. function scrollTo2(scrollToValue, direction2) {
  13641. const container = main.value;
  13642. let transformValue = 0;
  13643. let transform = "";
  13644. scrollToValue < 0 ? scrollToValue = 0 : direction2 === "x" && scrollToValue > container.scrollWidth - container.offsetWidth ? scrollToValue = container.scrollWidth - container.offsetWidth : direction2 === "y" && scrollToValue > container.scrollHeight - container.offsetHeight && (scrollToValue = container.scrollHeight - container.offsetHeight);
  13645. direction2 === "x" ? transformValue = container.scrollLeft - scrollToValue : direction2 === "y" && (transformValue = container.scrollTop - scrollToValue);
  13646. if (transformValue === 0)
  13647. return;
  13648. let _content = content.value;
  13649. _content.style.transition = "transform .3s ease-out";
  13650. _content.style.webkitTransition = "-webkit-transform .3s ease-out";
  13651. if (direction2 === "x") {
  13652. transform = "translateX(" + transformValue + "px) translateZ(0)";
  13653. } else {
  13654. direction2 === "y" && (transform = "translateY(" + transformValue + "px) translateZ(0)");
  13655. }
  13656. _content.removeEventListener("transitionend", __transitionEnd);
  13657. _content.removeEventListener("webkitTransitionEnd", __transitionEnd);
  13658. __transitionEnd = () => _transitionEnd(scrollToValue, direction2);
  13659. _content.addEventListener("transitionend", __transitionEnd);
  13660. _content.addEventListener("webkitTransitionEnd", __transitionEnd);
  13661. if (direction2 === "x") {
  13662. container.style.overflowX = "hidden";
  13663. } else if (direction2 === "y") {
  13664. container.style.overflowY = "hidden";
  13665. }
  13666. _content.style.transform = transform;
  13667. _content.style.webkitTransform = transform;
  13668. }
  13669. function _handleScroll($event) {
  13670. const target = $event.target;
  13671. trigger("scroll", $event, {
  13672. scrollLeft: target.scrollLeft,
  13673. scrollTop: target.scrollTop,
  13674. scrollHeight: target.scrollHeight,
  13675. scrollWidth: target.scrollWidth,
  13676. deltaX: state2.lastScrollLeft - target.scrollLeft,
  13677. deltaY: state2.lastScrollTop - target.scrollTop
  13678. });
  13679. if (realScrollY.value) {
  13680. if (target.scrollTop <= upperThresholdNumber.value && state2.lastScrollTop - target.scrollTop > 0 && $event.timeStamp - state2.lastScrollToUpperTime > 200) {
  13681. trigger("scrolltoupper", $event, {
  13682. direction: "top"
  13683. });
  13684. state2.lastScrollToUpperTime = $event.timeStamp;
  13685. }
  13686. if (target.scrollTop + target.offsetHeight + lowerThresholdNumber.value >= target.scrollHeight && state2.lastScrollTop - target.scrollTop < 0 && $event.timeStamp - state2.lastScrollToLowerTime > 200) {
  13687. trigger("scrolltolower", $event, {
  13688. direction: "bottom"
  13689. });
  13690. state2.lastScrollToLowerTime = $event.timeStamp;
  13691. }
  13692. }
  13693. if (realScrollX.value) {
  13694. if (target.scrollLeft <= upperThresholdNumber.value && state2.lastScrollLeft - target.scrollLeft > 0 && $event.timeStamp - state2.lastScrollToUpperTime > 200) {
  13695. trigger("scrolltoupper", $event, {
  13696. direction: "left"
  13697. });
  13698. state2.lastScrollToUpperTime = $event.timeStamp;
  13699. }
  13700. if (target.scrollLeft + target.offsetWidth + lowerThresholdNumber.value >= target.scrollWidth && state2.lastScrollLeft - target.scrollLeft < 0 && $event.timeStamp - state2.lastScrollToLowerTime > 200) {
  13701. trigger("scrolltolower", $event, {
  13702. direction: "right"
  13703. });
  13704. state2.lastScrollToLowerTime = $event.timeStamp;
  13705. }
  13706. }
  13707. state2.lastScrollTop = target.scrollTop;
  13708. state2.lastScrollLeft = target.scrollLeft;
  13709. }
  13710. function _scrollTopChanged(val) {
  13711. if (realScrollY.value) {
  13712. {
  13713. if (props2.scrollWithAnimation) {
  13714. scrollTo2(val, "y");
  13715. } else {
  13716. main.value.scrollTop = val;
  13717. }
  13718. }
  13719. }
  13720. }
  13721. function _scrollLeftChanged(val) {
  13722. if (realScrollX.value) {
  13723. {
  13724. if (props2.scrollWithAnimation) {
  13725. scrollTo2(val, "x");
  13726. } else {
  13727. main.value.scrollLeft = val;
  13728. }
  13729. }
  13730. }
  13731. }
  13732. function _scrollIntoViewChanged(val) {
  13733. if (val) {
  13734. if (!/^[_a-zA-Z][-_a-zA-Z0-9:]*$/.test(val)) {
  13735. console.error(`id error: scroll-into-view=${val}`);
  13736. return;
  13737. }
  13738. let element = rootRef.value.querySelector("#" + val);
  13739. if (element) {
  13740. let mainRect = main.value.getBoundingClientRect();
  13741. let elRect = element.getBoundingClientRect();
  13742. if (realScrollX.value) {
  13743. let left = elRect.left - mainRect.left;
  13744. let scrollLeft = main.value.scrollLeft;
  13745. let x = scrollLeft + left;
  13746. if (props2.scrollWithAnimation) {
  13747. scrollTo2(x, "x");
  13748. } else {
  13749. main.value.scrollLeft = x;
  13750. }
  13751. }
  13752. if (realScrollY.value) {
  13753. let top = elRect.top - mainRect.top;
  13754. let scrollTop = main.value.scrollTop;
  13755. let y = scrollTop + top;
  13756. if (props2.scrollWithAnimation) {
  13757. scrollTo2(y, "y");
  13758. } else {
  13759. main.value.scrollTop = y;
  13760. }
  13761. }
  13762. }
  13763. }
  13764. }
  13765. function _transitionEnd(val, direction2) {
  13766. content.value.style.transition = "";
  13767. content.value.style.webkitTransition = "";
  13768. content.value.style.transform = "";
  13769. content.value.style.webkitTransform = "";
  13770. let _main = main.value;
  13771. if (direction2 === "x") {
  13772. _main.style.overflowX = realScrollX.value ? "auto" : "hidden";
  13773. _main.scrollLeft = val;
  13774. } else if (direction2 === "y") {
  13775. _main.style.overflowY = realScrollY.value ? "auto" : "hidden";
  13776. _main.scrollTop = val;
  13777. }
  13778. content.value.removeEventListener("transitionend", __transitionEnd);
  13779. content.value.removeEventListener("webkitTransitionEnd", __transitionEnd);
  13780. }
  13781. function _setRefreshState(_state) {
  13782. if (!props2.refresherEnabled)
  13783. return;
  13784. switch (_state) {
  13785. case "refreshing":
  13786. state2.refresherHeight = props2.refresherThreshold;
  13787. if (!beforeRefreshing) {
  13788. beforeRefreshing = true;
  13789. trigger("refresherrefresh", {}, {});
  13790. emit2("update:refresherTriggered", true);
  13791. }
  13792. break;
  13793. case "restore":
  13794. case "refresherabort":
  13795. beforeRefreshing = false;
  13796. state2.refresherHeight = toUpperNumber = 0;
  13797. if (_state === "restore") {
  13798. triggerAbort = false;
  13799. trigger("refresherrestore", {}, {});
  13800. }
  13801. if (_state === "refresherabort" && triggerAbort) {
  13802. triggerAbort = false;
  13803. trigger("refresherabort", {}, {});
  13804. }
  13805. break;
  13806. }
  13807. state2.refreshState = _state;
  13808. }
  13809. onMounted(() => {
  13810. nextTick(() => {
  13811. _scrollTopChanged(scrollTopNumber.value);
  13812. _scrollLeftChanged(scrollLeftNumber.value);
  13813. });
  13814. _scrollIntoViewChanged(props2.scrollIntoView);
  13815. let __handleScroll = function(event) {
  13816. event.preventDefault();
  13817. event.stopPropagation();
  13818. _handleScroll(event);
  13819. };
  13820. let touchStart = {
  13821. x: 0,
  13822. y: 0
  13823. };
  13824. let needStop = null;
  13825. let __handleTouchMove = function(event) {
  13826. if (touchStart === null)
  13827. return;
  13828. let x = event.touches[0].pageX;
  13829. let y = event.touches[0].pageY;
  13830. let _main = main.value;
  13831. if (Math.abs(x - touchStart.x) > Math.abs(y - touchStart.y)) {
  13832. if (realScrollX.value) {
  13833. if (_main.scrollLeft === 0 && x > touchStart.x) {
  13834. needStop = false;
  13835. return;
  13836. } else if (_main.scrollWidth === _main.offsetWidth + _main.scrollLeft && x < touchStart.x) {
  13837. needStop = false;
  13838. return;
  13839. }
  13840. needStop = true;
  13841. } else {
  13842. needStop = false;
  13843. }
  13844. } else {
  13845. if (realScrollY.value) {
  13846. if (_main.scrollTop === 0 && y > touchStart.y) {
  13847. needStop = false;
  13848. if (props2.refresherEnabled && event.cancelable !== false)
  13849. event.preventDefault();
  13850. } else if (_main.scrollHeight === _main.offsetHeight + _main.scrollTop && y < touchStart.y) {
  13851. needStop = false;
  13852. return;
  13853. } else {
  13854. needStop = true;
  13855. }
  13856. } else {
  13857. needStop = false;
  13858. }
  13859. }
  13860. if (needStop) {
  13861. event.stopPropagation();
  13862. }
  13863. if (_main.scrollTop === 0 && event.touches.length === 1) {
  13864. _setRefreshState("pulling");
  13865. }
  13866. if (props2.refresherEnabled && state2.refreshState === "pulling") {
  13867. const dy = y - touchStart.y;
  13868. if (toUpperNumber === 0) {
  13869. toUpperNumber = y;
  13870. }
  13871. if (!beforeRefreshing) {
  13872. state2.refresherHeight = y - toUpperNumber;
  13873. if (state2.refresherHeight > 0) {
  13874. triggerAbort = true;
  13875. trigger("refresherpulling", event, {
  13876. deltaY: dy
  13877. });
  13878. }
  13879. } else {
  13880. state2.refresherHeight = dy + props2.refresherThreshold;
  13881. triggerAbort = false;
  13882. }
  13883. const route = state2.refresherHeight / props2.refresherThreshold;
  13884. state2.refreshRotate = (route > 1 ? 1 : route) * 360;
  13885. }
  13886. };
  13887. let __handleTouchStart = function(event) {
  13888. if (event.touches.length === 1) {
  13889. touchStart = {
  13890. x: event.touches[0].pageX,
  13891. y: event.touches[0].pageY
  13892. };
  13893. }
  13894. };
  13895. let __handleTouchEnd = function(event) {
  13896. touchStart = null;
  13897. if (state2.refresherHeight >= props2.refresherThreshold) {
  13898. _setRefreshState("refreshing");
  13899. } else {
  13900. _setRefreshState("refresherabort");
  13901. }
  13902. };
  13903. main.value.addEventListener("touchstart", __handleTouchStart, passiveOptions);
  13904. main.value.addEventListener("touchmove", __handleTouchMove, passive(false));
  13905. main.value.addEventListener("scroll", __handleScroll, passive(false));
  13906. main.value.addEventListener("touchend", __handleTouchEnd, passiveOptions);
  13907. onBeforeUnmount(() => {
  13908. main.value.removeEventListener("touchstart", __handleTouchStart);
  13909. main.value.removeEventListener("touchmove", __handleTouchMove);
  13910. main.value.removeEventListener("scroll", __handleScroll);
  13911. main.value.removeEventListener("touchend", __handleTouchEnd);
  13912. });
  13913. });
  13914. onActivated(() => {
  13915. realScrollY.value && (main.value.scrollTop = state2.lastScrollTop);
  13916. realScrollX.value && (main.value.scrollLeft = state2.lastScrollLeft);
  13917. });
  13918. watch(scrollTopNumber, (val) => {
  13919. _scrollTopChanged(val);
  13920. });
  13921. watch(scrollLeftNumber, (val) => {
  13922. _scrollLeftChanged(val);
  13923. });
  13924. watch(() => props2.scrollIntoView, (val) => {
  13925. _scrollIntoViewChanged(val);
  13926. });
  13927. watch(() => props2.refresherTriggered, (val) => {
  13928. if (val === true) {
  13929. _setRefreshState("refreshing");
  13930. } else if (val === false) {
  13931. _setRefreshState("restore");
  13932. }
  13933. });
  13934. return {
  13935. realScrollX,
  13936. realScrollY
  13937. };
  13938. }
  13939. const SLIDER_BLOCK_SIZE_MIN_VALUE = 12;
  13940. const SLIDER_BLOCK_SIZE_MAX_VALUE = 28;
  13941. const props$l = {
  13942. name: {
  13943. type: String,
  13944. default: ""
  13945. },
  13946. min: {
  13947. type: [Number, String],
  13948. default: 0
  13949. },
  13950. max: {
  13951. type: [Number, String],
  13952. default: 100
  13953. },
  13954. value: {
  13955. type: [Number, String],
  13956. default: 0
  13957. },
  13958. step: {
  13959. type: [Number, String],
  13960. default: 1
  13961. },
  13962. disabled: {
  13963. type: [Boolean, String],
  13964. default: false
  13965. },
  13966. color: {
  13967. type: String,
  13968. default: "#e9e9e9"
  13969. },
  13970. backgroundColor: {
  13971. type: String,
  13972. default: "#e9e9e9"
  13973. },
  13974. activeColor: {
  13975. type: String,
  13976. default: "#007aff"
  13977. },
  13978. selectedColor: {
  13979. type: String,
  13980. default: "#007aff"
  13981. },
  13982. blockColor: {
  13983. type: String,
  13984. default: "#ffffff"
  13985. },
  13986. blockSize: {
  13987. type: [Number, String],
  13988. default: 28
  13989. },
  13990. showValue: {
  13991. type: [Boolean, String],
  13992. default: false
  13993. }
  13994. };
  13995. const getValuePercentage = (value, min, max) => {
  13996. return 100 * (value - min) / (max - min) + "%";
  13997. };
  13998. class UniSliderElement extends UniElement {
  13999. constructor() {
  14000. super(...arguments);
  14001. __publicField(this, "_initialValue", 0);
  14002. }
  14003. init() {
  14004. this.htmlSlider = this.querySelector(".uni-slider-browser-input-range");
  14005. this.trackValue = this.querySelector(".uni-slider-track-value");
  14006. this.thumbValue = this.querySelector(".uni-slider-thumb-value");
  14007. this.inputValue = this.querySelector(".uni-slider-value");
  14008. this.updateValue(this.value);
  14009. }
  14010. get value() {
  14011. return Number(this.htmlSlider.value);
  14012. }
  14013. set value(value) {
  14014. this.htmlSlider.value = value.toString();
  14015. this.updateValue(value);
  14016. }
  14017. reset() {
  14018. this.value = this._initialValue;
  14019. }
  14020. updateValue(value) {
  14021. const min = Number(this.htmlSlider.getAttribute("min"));
  14022. const max = Number(this.htmlSlider.getAttribute("max"));
  14023. if (value < min) {
  14024. value = min;
  14025. } else if (value > max) {
  14026. value = max;
  14027. }
  14028. const percentage = getValuePercentage(value, min, max);
  14029. this.trackValue.style.width = percentage;
  14030. this.thumbValue.style.left = percentage;
  14031. this.inputValue.innerText = value.toString();
  14032. }
  14033. }
  14034. const indexX$1 = /* @__PURE__ */ defineBuiltInComponent({
  14035. name: "Slider",
  14036. props: props$l,
  14037. emits: ["changing", "change"],
  14038. rootElement: {
  14039. name: "uni-slider",
  14040. class: UniSliderElement
  14041. },
  14042. setup(props2, {
  14043. emit: emit2
  14044. }) {
  14045. const sliderRef = ref(null);
  14046. const sliderValueRef = ref(null);
  14047. let uniSliderElement;
  14048. watch(() => props2.value, (val) => {
  14049. uniSliderElement.value = Number(val);
  14050. });
  14051. const trigger = useCustomEvent(sliderRef, emit2);
  14052. const state2 = useSliderState(props2);
  14053. const {
  14054. _onInput,
  14055. _onChange
  14056. } = useSliderLoader(props2, sliderRef, trigger);
  14057. onMounted(() => {
  14058. uniSliderElement = sliderRef.value;
  14059. uniSliderElement._initialValue = props2.value;
  14060. uniSliderElement.init();
  14061. uniSliderElement.attachVmProps(props2);
  14062. });
  14063. return () => {
  14064. const {
  14065. setTrackBgColor,
  14066. setActiveColor,
  14067. setThumbStyle,
  14068. thumbTrackStyle
  14069. } = state2;
  14070. return createVNode("uni-slider", {
  14071. "ref": sliderRef
  14072. }, [createVNode("div", {
  14073. "class": "uni-slider-wrapper"
  14074. }, [createVNode("div", {
  14075. "class": "uni-slider-input"
  14076. }, [createVNode("div", {
  14077. "style": setTrackBgColor.value,
  14078. "class": "uni-slider-track"
  14079. }, [createVNode("div", {
  14080. "style": setActiveColor.value,
  14081. "class": "uni-slider-track-value"
  14082. }, null, 4)], 4), createVNode("div", {
  14083. "style": thumbTrackStyle.value,
  14084. "class": "uni-slider-thumb-track"
  14085. }, [createVNode("div", {
  14086. "style": setThumbStyle.value,
  14087. "class": "uni-slider-thumb-value"
  14088. }, null, 4)], 4), createVNode("input", {
  14089. "class": "uni-slider-browser-input-range",
  14090. "type": "range",
  14091. "min": props2.min,
  14092. "max": props2.max,
  14093. "step": props2.step,
  14094. "value": props2.value,
  14095. "onInput": withWebEvent(_onInput),
  14096. "onChange": withWebEvent(_onChange)
  14097. }, null, 40, ["min", "max", "step", "value", "onInput", "onChange"])]), withDirectives(createVNode("span", {
  14098. "ref": sliderValueRef,
  14099. "class": "uni-slider-value"
  14100. }, null, 512), [[vShow, props2.showValue]])]), createVNode("slot", null, null)], 512);
  14101. };
  14102. }
  14103. });
  14104. function useSliderState(props2) {
  14105. const _getBgColor = () => {
  14106. return props2.backgroundColor !== "#e9e9e9" ? props2.backgroundColor : props2.color !== "#007aff" ? props2.color : "#007aff";
  14107. };
  14108. const _getActiveColor = () => {
  14109. return props2.activeColor !== "#007aff" ? props2.activeColor : props2.selectedColor !== "#e9e9e9" ? props2.selectedColor : "#e9e9e9";
  14110. };
  14111. const _getBlockSizeString = () => {
  14112. const blockSize = Math.min(Math.max(Number(props2.blockSize), SLIDER_BLOCK_SIZE_MIN_VALUE), SLIDER_BLOCK_SIZE_MAX_VALUE);
  14113. return blockSize + "px";
  14114. };
  14115. const state2 = {
  14116. setTrackBgColor: computed(() => ({
  14117. backgroundColor: _getBgColor()
  14118. })),
  14119. setActiveColor: computed(() => ({
  14120. backgroundColor: _getActiveColor()
  14121. })),
  14122. thumbTrackStyle: computed(() => ({
  14123. marginRight: _getBlockSizeString()
  14124. })),
  14125. setThumbStyle: computed(() => ({
  14126. width: _getBlockSizeString(),
  14127. height: _getBlockSizeString(),
  14128. backgroundColor: props2.blockColor
  14129. }))
  14130. };
  14131. return state2;
  14132. }
  14133. function useSliderLoader(props2, sliderRef, trigger) {
  14134. const _onInput = (event) => {
  14135. if (props2.disabled) {
  14136. return;
  14137. }
  14138. const valueNumber = Number(event.target.value);
  14139. sliderRef.value.updateValue(valueNumber);
  14140. trigger("changing", event, {
  14141. value: valueNumber
  14142. });
  14143. };
  14144. const _onChange = (event) => {
  14145. if (props2.disabled) {
  14146. return;
  14147. }
  14148. const valueNumber = Number(event.target.value);
  14149. sliderRef.value.updateValue(valueNumber);
  14150. trigger("change", event, {
  14151. value: valueNumber
  14152. });
  14153. };
  14154. const uniForm = inject(uniFormKey, false);
  14155. if (!!uniForm) {
  14156. const field = {
  14157. reset: () => {
  14158. sliderRef.value.reset();
  14159. },
  14160. submit: () => {
  14161. const data = ["", null];
  14162. const value = sliderRef.value.value;
  14163. if (props2.name !== "") {
  14164. data[0] = props2.name;
  14165. data[1] = value;
  14166. }
  14167. return data;
  14168. }
  14169. };
  14170. uniForm.addField(field);
  14171. onBeforeUnmount(() => {
  14172. uniForm.removeField(field);
  14173. });
  14174. }
  14175. return {
  14176. _onInput,
  14177. _onChange
  14178. };
  14179. }
  14180. const props$k = {
  14181. indicatorDots: {
  14182. type: [Boolean, String],
  14183. default: false
  14184. },
  14185. vertical: {
  14186. type: [Boolean, String],
  14187. default: false
  14188. },
  14189. autoplay: {
  14190. type: [Boolean, String],
  14191. default: false
  14192. },
  14193. circular: {
  14194. type: [Boolean, String],
  14195. default: false
  14196. },
  14197. interval: {
  14198. type: [Number, String],
  14199. default: 5e3
  14200. },
  14201. duration: {
  14202. type: [Number, String],
  14203. default: 500
  14204. },
  14205. current: {
  14206. type: [Number, String],
  14207. default: 0
  14208. },
  14209. indicatorColor: {
  14210. type: String,
  14211. default: ""
  14212. },
  14213. indicatorActiveColor: {
  14214. type: String,
  14215. default: ""
  14216. },
  14217. previousMargin: {
  14218. type: String,
  14219. default: ""
  14220. },
  14221. nextMargin: {
  14222. type: String,
  14223. default: ""
  14224. },
  14225. currentItemId: {
  14226. type: String,
  14227. default: ""
  14228. },
  14229. skipHiddenItemLayout: {
  14230. type: [Boolean, String],
  14231. default: false
  14232. },
  14233. displayMultipleItems: {
  14234. type: [Number, String],
  14235. default: 1
  14236. },
  14237. disableTouch: {
  14238. type: [Boolean, String],
  14239. default: false
  14240. },
  14241. navigation: {
  14242. type: [Boolean, String],
  14243. default: false
  14244. },
  14245. navigationColor: {
  14246. type: String,
  14247. default: "#fff"
  14248. },
  14249. navigationActiveColor: {
  14250. type: String,
  14251. default: "rgba(53, 53, 53, 0.6)"
  14252. }
  14253. };
  14254. function useState$3(props2) {
  14255. const interval = computed(() => {
  14256. const interval2 = Number(props2.interval);
  14257. return isNaN(interval2) ? 5e3 : interval2;
  14258. });
  14259. const duration = computed(() => {
  14260. const duration2 = Number(props2.duration);
  14261. return isNaN(duration2) ? 500 : duration2;
  14262. });
  14263. const displayMultipleItems = computed(() => {
  14264. const displayMultipleItems2 = Math.round(props2.displayMultipleItems);
  14265. return isNaN(displayMultipleItems2) ? 1 : displayMultipleItems2;
  14266. });
  14267. const state2 = reactive({
  14268. interval,
  14269. duration,
  14270. displayMultipleItems,
  14271. current: Math.round(props2.current) || 0,
  14272. currentItemId: props2.currentItemId,
  14273. userTracking: false
  14274. });
  14275. return state2;
  14276. }
  14277. function useLayout(props2, state2, swiperContexts, slideFrameRef, emit2, trigger) {
  14278. function cancelSchedule() {
  14279. if (timer) {
  14280. clearTimeout(timer);
  14281. timer = null;
  14282. }
  14283. }
  14284. let timer = null;
  14285. let invalid = true;
  14286. let viewportPosition = 0;
  14287. let viewportMoveRatio = 1;
  14288. let animating = null;
  14289. let requestedAnimation = false;
  14290. let contentTrackViewport = 0;
  14291. let transitionStart;
  14292. let currentChangeSource = "";
  14293. let animationFrame;
  14294. const swiperEnabled = computed(() => swiperContexts.value.length > state2.displayMultipleItems);
  14295. const circularEnabled = computed(() => props2.circular && swiperEnabled.value);
  14296. function checkCircularLayout(index2) {
  14297. if (!invalid) {
  14298. for (let items = swiperContexts.value, n = items.length, i = index2 + state2.displayMultipleItems, r = 0; r < n; r++) {
  14299. const item = items[r];
  14300. const s = Math.floor(index2 / n) * n + r;
  14301. const l = s + n;
  14302. const c = s - n;
  14303. const u = Math.max(index2 - (s + 1), s - i, 0);
  14304. const d = Math.max(index2 - (l + 1), l - i, 0);
  14305. const h2 = Math.max(index2 - (c + 1), c - i, 0);
  14306. const p2 = Math.min(u, d, h2);
  14307. const position = [s, l, c][[u, d, h2].indexOf(p2)];
  14308. item.updatePosition(position, props2.vertical);
  14309. }
  14310. }
  14311. }
  14312. function updateViewport(index2) {
  14313. if (!(Math.floor(2 * viewportPosition) === Math.floor(2 * index2) && Math.ceil(2 * viewportPosition) === Math.ceil(2 * index2))) {
  14314. if (circularEnabled.value) {
  14315. checkCircularLayout(index2);
  14316. }
  14317. }
  14318. const x = props2.vertical ? "0" : 100 * -index2 * viewportMoveRatio + "%";
  14319. const y = props2.vertical ? 100 * -index2 * viewportMoveRatio + "%" : "0";
  14320. const transform = "translate(" + x + ", " + y + ") translateZ(0)";
  14321. const slideFrame = slideFrameRef.value;
  14322. if (slideFrame) {
  14323. slideFrame.style.webkitTransform = transform;
  14324. slideFrame.style.transform = transform;
  14325. }
  14326. viewportPosition = index2;
  14327. if (!transitionStart) {
  14328. if (index2 % 1 === 0) {
  14329. return;
  14330. }
  14331. transitionStart = index2;
  14332. }
  14333. index2 -= Math.floor(transitionStart);
  14334. const items = swiperContexts.value;
  14335. if (index2 <= -(items.length - 1)) {
  14336. index2 += items.length;
  14337. } else if (index2 >= items.length) {
  14338. index2 -= items.length;
  14339. }
  14340. index2 = transitionStart % 1 > 0.5 || transitionStart < 0 ? index2 - 1 : index2;
  14341. trigger("transition", {}, {
  14342. dx: props2.vertical ? 0 : index2 * slideFrame.offsetWidth,
  14343. dy: props2.vertical ? index2 * slideFrame.offsetHeight : 0
  14344. });
  14345. }
  14346. function endViewportAnimation() {
  14347. if (animating) {
  14348. updateViewport(animating.toPos);
  14349. animating = null;
  14350. }
  14351. }
  14352. function normalizeCurrentValue(current) {
  14353. const length = swiperContexts.value.length;
  14354. if (!length) {
  14355. return -1;
  14356. }
  14357. const index2 = (Math.round(current) % length + length) % length;
  14358. if (circularEnabled.value) {
  14359. if (length <= state2.displayMultipleItems) {
  14360. return 0;
  14361. }
  14362. } else if (index2 > length - state2.displayMultipleItems) {
  14363. return length - state2.displayMultipleItems;
  14364. }
  14365. return index2;
  14366. }
  14367. function cancelViewportAnimation() {
  14368. animating = null;
  14369. }
  14370. function animateFrameFuncProto() {
  14371. if (!animating) {
  14372. requestedAnimation = false;
  14373. return;
  14374. }
  14375. const _animating = animating;
  14376. const toPos = _animating.toPos;
  14377. const acc = _animating.acc;
  14378. const endTime = _animating.endTime;
  14379. const source = _animating.source;
  14380. const time = endTime - Date.now();
  14381. if (time <= 0) {
  14382. updateViewport(toPos);
  14383. animating = null;
  14384. requestedAnimation = false;
  14385. transitionStart = null;
  14386. const item = swiperContexts.value[state2.current];
  14387. if (item) {
  14388. const currentItemId = item.getItemId();
  14389. trigger("animationfinish", {}, {
  14390. current: state2.current,
  14391. currentItemId,
  14392. source
  14393. });
  14394. }
  14395. return;
  14396. }
  14397. const s = acc * time * time / 2;
  14398. const l = toPos + s;
  14399. updateViewport(l);
  14400. animationFrame = requestAnimationFrame(animateFrameFuncProto);
  14401. }
  14402. function animateViewport(current, source, n) {
  14403. cancelViewportAnimation();
  14404. const duration = state2.duration;
  14405. const length = swiperContexts.value.length;
  14406. let position = viewportPosition;
  14407. if (circularEnabled.value) {
  14408. if (n < 0) {
  14409. for (; position < current; ) {
  14410. position += length;
  14411. }
  14412. for (; position - length > current; ) {
  14413. position -= length;
  14414. }
  14415. } else if (n > 0) {
  14416. for (; position > current; ) {
  14417. position -= length;
  14418. }
  14419. for (; position + length < current; ) {
  14420. position += length;
  14421. }
  14422. if (position + length - current < current - position) {
  14423. position += length;
  14424. }
  14425. } else {
  14426. for (; position + length < current; ) {
  14427. position += length;
  14428. }
  14429. for (; position - length > current; ) {
  14430. position -= length;
  14431. }
  14432. if (position + length - current < current - position) {
  14433. position += length;
  14434. }
  14435. }
  14436. } else if (source === "click") {
  14437. current = current + state2.displayMultipleItems - 1 < length ? current : 0;
  14438. }
  14439. animating = {
  14440. toPos: current,
  14441. acc: 2 * (position - current) / (duration * duration),
  14442. endTime: Date.now() + duration,
  14443. source
  14444. };
  14445. if (!requestedAnimation) {
  14446. requestedAnimation = true;
  14447. animationFrame = requestAnimationFrame(animateFrameFuncProto);
  14448. }
  14449. }
  14450. function scheduleAutoplay() {
  14451. cancelSchedule();
  14452. const items = swiperContexts.value;
  14453. const callback = function() {
  14454. timer = null;
  14455. currentChangeSource = "autoplay";
  14456. if (circularEnabled.value) {
  14457. state2.current = normalizeCurrentValue(state2.current + 1);
  14458. } else {
  14459. state2.current = state2.current + state2.displayMultipleItems < items.length ? state2.current + 1 : 0;
  14460. }
  14461. animateViewport(state2.current, "autoplay", circularEnabled.value ? 1 : 0);
  14462. timer = setTimeout(callback, state2.interval);
  14463. };
  14464. if (!(invalid || items.length <= state2.displayMultipleItems)) {
  14465. timer = setTimeout(callback, state2.interval);
  14466. }
  14467. }
  14468. function resetLayout() {
  14469. cancelSchedule();
  14470. endViewportAnimation();
  14471. const items = swiperContexts.value;
  14472. for (let i = 0; i < items.length; i++) {
  14473. items[i].updatePosition(i, props2.vertical);
  14474. }
  14475. viewportMoveRatio = 1;
  14476. const slideFrameEl = slideFrameRef.value;
  14477. if (state2.displayMultipleItems === 1 && items.length) {
  14478. const itemRect = items[0].getBoundingClientRect();
  14479. const slideFrameRect = slideFrameEl.getBoundingClientRect();
  14480. viewportMoveRatio = itemRect.width / slideFrameRect.width;
  14481. if (!(viewportMoveRatio > 0 && viewportMoveRatio < 1)) {
  14482. viewportMoveRatio = 1;
  14483. }
  14484. }
  14485. const position = viewportPosition;
  14486. viewportPosition = -2;
  14487. const current = state2.current;
  14488. if (current >= 0) {
  14489. invalid = false;
  14490. if (state2.userTracking) {
  14491. updateViewport(position + current - contentTrackViewport);
  14492. contentTrackViewport = current;
  14493. } else {
  14494. updateViewport(current);
  14495. if (props2.autoplay) {
  14496. scheduleAutoplay();
  14497. }
  14498. }
  14499. } else {
  14500. invalid = true;
  14501. updateViewport(-state2.displayMultipleItems - 1);
  14502. }
  14503. }
  14504. watch([() => props2.current, () => props2.currentItemId, () => [...swiperContexts.value]], () => {
  14505. let current = -1;
  14506. if (props2.currentItemId) {
  14507. for (let i = 0, items = swiperContexts.value; i < items.length; i++) {
  14508. const itemId = items[i].getItemId();
  14509. if (itemId === props2.currentItemId) {
  14510. current = i;
  14511. break;
  14512. }
  14513. }
  14514. }
  14515. if (current < 0) {
  14516. current = Math.round(props2.current) || 0;
  14517. }
  14518. current = current < 0 ? 0 : current;
  14519. if (state2.current !== current) {
  14520. currentChangeSource = "";
  14521. state2.current = current;
  14522. }
  14523. });
  14524. watch([() => props2.vertical, () => circularEnabled.value, () => state2.displayMultipleItems, () => [...swiperContexts.value]], resetLayout);
  14525. watch(() => state2.interval, () => {
  14526. if (timer) {
  14527. cancelSchedule();
  14528. scheduleAutoplay();
  14529. }
  14530. });
  14531. function currentChanged(current, history2) {
  14532. const source = currentChangeSource;
  14533. currentChangeSource = "";
  14534. const items = swiperContexts.value;
  14535. if (!source) {
  14536. const length = items.length;
  14537. animateViewport(current, "", circularEnabled.value && history2 + (length - current) % length > length / 2 ? 1 : 0);
  14538. }
  14539. const item = items[current];
  14540. if (item) {
  14541. const currentItemId = state2.currentItemId = item.getItemId();
  14542. trigger("change", {}, {
  14543. current: state2.current,
  14544. currentItemId,
  14545. source
  14546. });
  14547. }
  14548. }
  14549. watch(() => state2.current, (val, oldVal) => {
  14550. currentChanged(val, oldVal);
  14551. emit2("update:current", val);
  14552. });
  14553. watch(() => state2.currentItemId, (val) => {
  14554. emit2("update:currentItemId", val);
  14555. });
  14556. function inintAutoplay(enable) {
  14557. if (enable) {
  14558. scheduleAutoplay();
  14559. } else {
  14560. cancelSchedule();
  14561. }
  14562. }
  14563. watch(() => props2.autoplay && !state2.userTracking, inintAutoplay);
  14564. inintAutoplay(props2.autoplay && !state2.userTracking);
  14565. onMounted(() => {
  14566. let userDirectionChecked = false;
  14567. let contentTrackSpeed = 0;
  14568. let contentTrackT = 0;
  14569. function handleTrackStart() {
  14570. cancelSchedule();
  14571. contentTrackViewport = viewportPosition;
  14572. contentTrackSpeed = 0;
  14573. contentTrackT = Date.now();
  14574. cancelViewportAnimation();
  14575. }
  14576. function handleTrackMove(data) {
  14577. const oldContentTrackT = contentTrackT;
  14578. contentTrackT = Date.now();
  14579. const length = swiperContexts.value.length;
  14580. const other = length - state2.displayMultipleItems;
  14581. function calc2(val) {
  14582. return 0.5 - 0.25 / (val + 0.5);
  14583. }
  14584. function move(oldVal, newVal) {
  14585. let val = contentTrackViewport + oldVal;
  14586. contentTrackSpeed = 0.6 * contentTrackSpeed + 0.4 * newVal;
  14587. if (!circularEnabled.value) {
  14588. if (val < 0 || val > other) {
  14589. if (val < 0) {
  14590. val = -calc2(-val);
  14591. } else {
  14592. if (val > other) {
  14593. val = other + calc2(val - other);
  14594. }
  14595. }
  14596. contentTrackSpeed = 0;
  14597. }
  14598. }
  14599. updateViewport(val);
  14600. }
  14601. const time = contentTrackT - oldContentTrackT || 1;
  14602. const slideFrameEl = slideFrameRef.value;
  14603. if (props2.vertical) {
  14604. move(-data.dy / slideFrameEl.offsetHeight, -data.ddy / time);
  14605. } else {
  14606. move(-data.dx / slideFrameEl.offsetWidth, -data.ddx / time);
  14607. }
  14608. }
  14609. function handleTrackEnd(isCancel) {
  14610. state2.userTracking = false;
  14611. const t2 = contentTrackSpeed / Math.abs(contentTrackSpeed);
  14612. let n = 0;
  14613. if (!isCancel && Math.abs(contentTrackSpeed) > 0.2) {
  14614. n = 0.5 * t2;
  14615. }
  14616. const current = normalizeCurrentValue(viewportPosition + n);
  14617. if (isCancel) {
  14618. updateViewport(contentTrackViewport);
  14619. } else {
  14620. currentChangeSource = "touch";
  14621. state2.current = current;
  14622. animateViewport(current, "touch", n !== 0 ? n : current === 0 && circularEnabled.value && viewportPosition >= 1 ? 1 : 0);
  14623. }
  14624. }
  14625. useTouchtrack(slideFrameRef.value, (event) => {
  14626. if (props2.disableTouch) {
  14627. return;
  14628. }
  14629. if (!invalid) {
  14630. if (event.detail.state === "start") {
  14631. state2.userTracking = true;
  14632. userDirectionChecked = false;
  14633. return handleTrackStart();
  14634. }
  14635. if (event.detail.state === "end") {
  14636. return handleTrackEnd(false);
  14637. }
  14638. if (event.detail.state === "cancel") {
  14639. return handleTrackEnd(true);
  14640. }
  14641. if (state2.userTracking) {
  14642. if (!userDirectionChecked) {
  14643. userDirectionChecked = true;
  14644. const t2 = Math.abs(event.detail.dx);
  14645. const n = Math.abs(event.detail.dy);
  14646. if (t2 >= n && props2.vertical) {
  14647. state2.userTracking = false;
  14648. } else {
  14649. if (t2 <= n && !props2.vertical) {
  14650. state2.userTracking = false;
  14651. }
  14652. }
  14653. if (!state2.userTracking) {
  14654. if (props2.autoplay) {
  14655. scheduleAutoplay();
  14656. }
  14657. return;
  14658. }
  14659. }
  14660. handleTrackMove(event.detail);
  14661. return false;
  14662. }
  14663. }
  14664. });
  14665. });
  14666. onUnmounted(() => {
  14667. cancelSchedule();
  14668. cancelAnimationFrame(animationFrame);
  14669. });
  14670. function onSwiperDotClick(index2) {
  14671. animateViewport(state2.current = index2, currentChangeSource = "click", circularEnabled.value ? 1 : 0);
  14672. }
  14673. return {
  14674. onSwiperDotClick,
  14675. circularEnabled,
  14676. swiperEnabled
  14677. };
  14678. }
  14679. class UniSwiperElement extends UniElement {
  14680. }
  14681. const Swiper = /* @__PURE__ */ defineBuiltInComponent({
  14682. name: "Swiper",
  14683. props: props$k,
  14684. emits: ["change", "transition", "animationfinish", "update:current", "update:currentItemId"],
  14685. rootElement: {
  14686. name: "uni-swiper",
  14687. class: UniSwiperElement
  14688. },
  14689. setup(props2, {
  14690. slots,
  14691. emit: emit2
  14692. }) {
  14693. const rootRef = ref(null);
  14694. const trigger = useCustomEvent(rootRef, emit2);
  14695. const slidesWrapperRef = ref(null);
  14696. const slideFrameRef = ref(null);
  14697. const state2 = useState$3(props2);
  14698. const slidesStyle = computed(() => {
  14699. let style = {};
  14700. if (props2.nextMargin || props2.previousMargin) {
  14701. style = props2.vertical ? {
  14702. left: 0,
  14703. right: 0,
  14704. top: rpx2px(props2.previousMargin, true),
  14705. bottom: rpx2px(props2.nextMargin, true)
  14706. } : {
  14707. top: 0,
  14708. bottom: 0,
  14709. left: rpx2px(props2.previousMargin, true),
  14710. right: rpx2px(props2.nextMargin, true)
  14711. };
  14712. }
  14713. return style;
  14714. });
  14715. const slideFrameStyle = computed(() => {
  14716. const value = Math.abs(100 / state2.displayMultipleItems) + "%";
  14717. return {
  14718. width: props2.vertical ? "100%" : value,
  14719. height: !props2.vertical ? "100%" : value
  14720. };
  14721. });
  14722. let swiperItems = [];
  14723. const originSwiperContexts = [];
  14724. const swiperContexts = ref([]);
  14725. function updateSwiperContexts() {
  14726. const contexts = [];
  14727. for (let index2 = 0; index2 < swiperItems.length; index2++) {
  14728. let swiperItem = swiperItems[index2];
  14729. if (!(swiperItem instanceof Element)) {
  14730. swiperItem = swiperItem.el;
  14731. }
  14732. const swiperContext = originSwiperContexts.find((context) => swiperItem === context.rootRef.value);
  14733. if (swiperContext) {
  14734. contexts.push(markRaw(swiperContext));
  14735. }
  14736. }
  14737. swiperContexts.value = contexts;
  14738. }
  14739. const addSwiperContext = function(swiperContext) {
  14740. originSwiperContexts.push(swiperContext);
  14741. updateSwiperContexts();
  14742. };
  14743. provide("addSwiperContext", addSwiperContext);
  14744. const removeSwiperContext = function(swiperContext) {
  14745. const index2 = originSwiperContexts.indexOf(swiperContext);
  14746. if (index2 >= 0) {
  14747. originSwiperContexts.splice(index2, 1);
  14748. updateSwiperContexts();
  14749. }
  14750. };
  14751. provide("removeSwiperContext", removeSwiperContext);
  14752. const {
  14753. onSwiperDotClick,
  14754. circularEnabled,
  14755. swiperEnabled
  14756. } = useLayout(props2, state2, swiperContexts, slideFrameRef, emit2, trigger);
  14757. let createNavigationTsx = () => null;
  14758. {
  14759. createNavigationTsx = useSwiperNavigation(rootRef, props2, state2, onSwiperDotClick, swiperContexts, circularEnabled, swiperEnabled);
  14760. }
  14761. onMounted(() => {
  14762. const rootElement = rootRef.value;
  14763. rootElement.attachVmProps(props2);
  14764. });
  14765. return () => {
  14766. const defaultSlots = slots.default && slots.default();
  14767. swiperItems = flatVNode(defaultSlots);
  14768. return createVNode("uni-swiper", {
  14769. "ref": rootRef
  14770. }, [createVNode("div", {
  14771. "ref": slidesWrapperRef,
  14772. "class": "uni-swiper-wrapper"
  14773. }, [createVNode("div", {
  14774. "class": "uni-swiper-slides",
  14775. "style": slidesStyle.value
  14776. }, [createVNode("div", {
  14777. "ref": slideFrameRef,
  14778. "class": "uni-swiper-slide-frame",
  14779. "style": slideFrameStyle.value
  14780. }, [defaultSlots], 4)], 4), props2.indicatorDots && createVNode("div", {
  14781. "class": ["uni-swiper-dots", props2.vertical ? "uni-swiper-dots-vertical" : "uni-swiper-dots-horizontal"]
  14782. }, [swiperContexts.value.map((_, index2, array) => createVNode("div", {
  14783. "onClick": () => onSwiperDotClick(index2),
  14784. "class": {
  14785. "uni-swiper-dot": true,
  14786. "uni-swiper-dot-active": index2 < state2.current + state2.displayMultipleItems && index2 >= state2.current || index2 < state2.current + state2.displayMultipleItems - array.length
  14787. },
  14788. "style": {
  14789. background: index2 === state2.current ? props2.indicatorActiveColor : props2.indicatorColor
  14790. }
  14791. }, null, 14, ["onClick"]))], 2), createNavigationTsx()], 512)], 512);
  14792. };
  14793. }
  14794. });
  14795. const useSwiperNavigation = (rootRef, props2, state2, onSwiperDotClick, swiperContext, circularEnabled, swiperEnabled) => {
  14796. let isNavigationAuto = false;
  14797. let prevDisabled = false;
  14798. let nextDisabled = false;
  14799. let hideNavigation = ref(false);
  14800. watchEffect(() => {
  14801. isNavigationAuto = props2.navigation === "auto";
  14802. hideNavigation.value = props2.navigation !== true || isNavigationAuto;
  14803. swiperAddMouseEvent();
  14804. });
  14805. watchEffect(() => {
  14806. const swiperItemLength = swiperContext.value.length;
  14807. const notCircular = !circularEnabled.value;
  14808. prevDisabled = state2.current === 0 && notCircular;
  14809. nextDisabled = state2.current === swiperItemLength - 1 && notCircular || notCircular && state2.current + state2.displayMultipleItems >= swiperItemLength;
  14810. if (!swiperEnabled.value) {
  14811. prevDisabled = true;
  14812. nextDisabled = true;
  14813. isNavigationAuto && (hideNavigation.value = true);
  14814. }
  14815. });
  14816. function navigationHover(event, type) {
  14817. const target = event.currentTarget;
  14818. if (!target)
  14819. return;
  14820. target.style.backgroundColor = type === "over" ? props2.navigationActiveColor : "";
  14821. }
  14822. const navigationAttr = {
  14823. onMouseover: (event) => navigationHover(event, "over"),
  14824. onMouseout: (event) => navigationHover(event, "out")
  14825. };
  14826. function navigationClick($event, type, disabled) {
  14827. $event.stopPropagation();
  14828. if (disabled)
  14829. return;
  14830. const swiperItemLength = swiperContext.value.length;
  14831. let _current = state2.current;
  14832. switch (type) {
  14833. case "prev":
  14834. _current--;
  14835. if (_current < 0 && circularEnabled.value) {
  14836. _current = swiperItemLength - 1;
  14837. }
  14838. break;
  14839. case "next":
  14840. _current++;
  14841. if (_current >= swiperItemLength && circularEnabled.value) {
  14842. _current = 0;
  14843. }
  14844. break;
  14845. }
  14846. onSwiperDotClick(_current);
  14847. }
  14848. const createNavigationSVG = () => createSvgIconVNode(ICON_PATH_BACK, props2.navigationColor, 26);
  14849. let setHideNavigationTimer;
  14850. const _mousemove = (e2) => {
  14851. clearTimeout(setHideNavigationTimer);
  14852. const {
  14853. clientX,
  14854. clientY
  14855. } = e2;
  14856. const {
  14857. left,
  14858. right,
  14859. top,
  14860. bottom,
  14861. width,
  14862. height
  14863. } = rootRef.value.getBoundingClientRect();
  14864. let hide = false;
  14865. if (props2.vertical) {
  14866. hide = !(clientY - top < height / 3 || bottom - clientY < height / 3);
  14867. } else {
  14868. hide = !(clientX - left < width / 3 || right - clientX < width / 3);
  14869. }
  14870. if (hide) {
  14871. return setHideNavigationTimer = setTimeout(() => {
  14872. hideNavigation.value = hide;
  14873. }, 300);
  14874. }
  14875. hideNavigation.value = hide;
  14876. };
  14877. const _mouseleave = () => {
  14878. hideNavigation.value = true;
  14879. };
  14880. function swiperAddMouseEvent() {
  14881. if (rootRef.value) {
  14882. rootRef.value.removeEventListener("mousemove", _mousemove);
  14883. rootRef.value.removeEventListener("mouseleave", _mouseleave);
  14884. if (isNavigationAuto) {
  14885. rootRef.value.addEventListener("mousemove", _mousemove);
  14886. rootRef.value.addEventListener("mouseleave", _mouseleave);
  14887. }
  14888. }
  14889. }
  14890. onMounted(swiperAddMouseEvent);
  14891. function createNavigationTsx() {
  14892. const navigationClass = {
  14893. "uni-swiper-navigation-hide": hideNavigation.value,
  14894. "uni-swiper-navigation-vertical": props2.vertical
  14895. };
  14896. if (props2.navigation) {
  14897. return createVNode(Fragment, null, [createVNode("div", mergeProps({
  14898. "class": ["uni-swiper-navigation uni-swiper-navigation-prev", extend({
  14899. "uni-swiper-navigation-disabled": prevDisabled
  14900. }, navigationClass)],
  14901. "onClick": (e2) => navigationClick(e2, "prev", prevDisabled)
  14902. }, navigationAttr), [createNavigationSVG()], 16, ["onClick"]), createVNode("div", mergeProps({
  14903. "class": ["uni-swiper-navigation uni-swiper-navigation-next", extend({
  14904. "uni-swiper-navigation-disabled": nextDisabled
  14905. }, navigationClass)],
  14906. "onClick": (e2) => navigationClick(e2, "next", nextDisabled)
  14907. }, navigationAttr), [createNavigationSVG()], 16, ["onClick"])]);
  14908. }
  14909. return null;
  14910. }
  14911. return createNavigationTsx;
  14912. };
  14913. const props$j = {
  14914. itemId: {
  14915. type: String,
  14916. default: ""
  14917. }
  14918. };
  14919. class UniSwiperItemElement extends UniElement {
  14920. }
  14921. const SwiperItem = /* @__PURE__ */ defineBuiltInComponent({
  14922. name: "SwiperItem",
  14923. props: props$j,
  14924. rootElement: {
  14925. name: "uni-swiper-item",
  14926. class: UniSwiperItemElement
  14927. },
  14928. setup(props2, {
  14929. slots
  14930. }) {
  14931. const rootRef = ref(null);
  14932. const context = {
  14933. rootRef,
  14934. getItemId() {
  14935. return props2.itemId;
  14936. },
  14937. getBoundingClientRect() {
  14938. const el = rootRef.value;
  14939. return el.getBoundingClientRect();
  14940. },
  14941. updatePosition(position, vertical) {
  14942. const x = vertical ? "0" : 100 * position + "%";
  14943. const y = vertical ? 100 * position + "%" : "0";
  14944. const rootEl = rootRef.value;
  14945. const value = `translate(${x},${y}) translateZ(0)`;
  14946. if (rootEl) {
  14947. rootEl.style.webkitTransform = value;
  14948. rootEl.style.transform = value;
  14949. }
  14950. }
  14951. };
  14952. onMounted(() => {
  14953. const addSwiperContext = inject("addSwiperContext");
  14954. if (addSwiperContext) {
  14955. addSwiperContext(context);
  14956. }
  14957. });
  14958. onUnmounted(() => {
  14959. const removeSwiperContext = inject("removeSwiperContext");
  14960. if (removeSwiperContext) {
  14961. removeSwiperContext(context);
  14962. }
  14963. });
  14964. onMounted(() => {
  14965. const rootElement = rootRef.value;
  14966. rootElement.attachVmProps(props2);
  14967. });
  14968. return () => {
  14969. return createVNode("uni-swiper-item", {
  14970. "ref": rootRef,
  14971. "style": {
  14972. position: "absolute",
  14973. width: "100%",
  14974. height: "100%"
  14975. }
  14976. }, [slots.default && slots.default()], 512);
  14977. };
  14978. }
  14979. });
  14980. const props$i = {
  14981. name: {
  14982. type: String,
  14983. default: ""
  14984. },
  14985. checked: {
  14986. type: [Boolean, String],
  14987. default: false
  14988. },
  14989. type: {
  14990. type: String,
  14991. default: "switch"
  14992. },
  14993. id: {
  14994. type: String,
  14995. default: ""
  14996. },
  14997. disabled: {
  14998. type: [Boolean, String],
  14999. default: false
  15000. },
  15001. color: {
  15002. type: String,
  15003. default: ""
  15004. }
  15005. };
  15006. class UniSwitchElement extends UniElement {
  15007. }
  15008. const index$m = /* @__PURE__ */ defineBuiltInComponent({
  15009. name: "Switch",
  15010. props: props$i,
  15011. emits: ["change"],
  15012. rootElement: {
  15013. name: "uni-switch",
  15014. class: UniSwitchElement
  15015. },
  15016. setup(props2, {
  15017. emit: emit2
  15018. }) {
  15019. const rootRef = ref(null);
  15020. const switchChecked = ref(props2.checked);
  15021. const uniLabel = useSwitchInject(rootRef, props2, switchChecked);
  15022. const trigger = useCustomEvent(rootRef, emit2);
  15023. watch(() => props2.checked, (val) => {
  15024. switchChecked.value = val;
  15025. });
  15026. const _onClick = ($event) => {
  15027. if (props2.disabled) {
  15028. return;
  15029. }
  15030. switchChecked.value = !switchChecked.value;
  15031. trigger("change", $event, {
  15032. value: switchChecked.value
  15033. });
  15034. };
  15035. if (!!uniLabel) {
  15036. uniLabel.addHandler(_onClick);
  15037. onBeforeUnmount(() => {
  15038. uniLabel.removeHandler(_onClick);
  15039. });
  15040. }
  15041. useListeners$1(props2, {
  15042. "label-click": _onClick
  15043. });
  15044. let checkedCache = ref(switchChecked.value);
  15045. watch(() => switchChecked.value, (val) => {
  15046. checkedCache.value = val;
  15047. });
  15048. onMounted(() => {
  15049. const rootElement = rootRef.value;
  15050. Object.defineProperty(rootElement, "checked", {
  15051. get() {
  15052. return checkedCache.value;
  15053. },
  15054. set(val) {
  15055. checkedCache.value = val;
  15056. }
  15057. });
  15058. rootElement.attachVmProps(props2);
  15059. });
  15060. return () => {
  15061. const {
  15062. color,
  15063. type
  15064. } = props2;
  15065. const booleanAttrs = useBooleanAttr(props2, "disabled");
  15066. const switchInputStyle = {};
  15067. if (color && switchChecked.value) {
  15068. switchInputStyle["backgroundColor"] = color;
  15069. switchInputStyle["borderColor"] = color;
  15070. }
  15071. let realCheckValue;
  15072. realCheckValue = checkedCache.value;
  15073. return createVNode("uni-switch", mergeProps({
  15074. "id": props2.id,
  15075. "ref": rootRef
  15076. }, booleanAttrs, {
  15077. "onClick": _onClick
  15078. }), [createVNode("div", {
  15079. "class": "uni-switch-wrapper"
  15080. }, [withDirectives(createVNode("div", {
  15081. "class": ["uni-switch-input", [switchChecked.value ? "uni-switch-input-checked" : ""]],
  15082. "style": switchInputStyle
  15083. }, null, 6), [[vShow, type === "switch"]]), withDirectives(createVNode("div", {
  15084. "class": "uni-checkbox-input"
  15085. }, [realCheckValue ? createSvgIconVNode(ICON_PATH_SUCCESS_NO_CIRCLE, props2.color, 22) : ""], 512), [[vShow, type === "checkbox"]])])], 16, ["id", "onClick"]);
  15086. };
  15087. }
  15088. });
  15089. function useSwitchInject(rootRef, props2, switchChecked) {
  15090. const initialCheckedValue = props2.checked;
  15091. const uniForm = inject(uniFormKey, false);
  15092. const uniLabel = inject(uniLabelKey, false);
  15093. const formField = {
  15094. submit: () => {
  15095. const data = ["", null];
  15096. if (props2.name) {
  15097. data[0] = props2.name;
  15098. data[1] = rootRef.value.checked;
  15099. }
  15100. return data;
  15101. },
  15102. reset: () => {
  15103. switchChecked.value = initialCheckedValue;
  15104. }
  15105. };
  15106. if (!!uniForm) {
  15107. uniForm.addField(formField);
  15108. onUnmounted(() => {
  15109. uniForm.removeField(formField);
  15110. });
  15111. }
  15112. return uniLabel;
  15113. }
  15114. const SPACE_UNICODE = {
  15115. ensp: " ",
  15116. emsp: " ",
  15117. nbsp: " "
  15118. };
  15119. function normalizeText(text2, { space, decode: decode2 }) {
  15120. let result = "";
  15121. let isEscape = false;
  15122. for (let char of text2) {
  15123. if (space && SPACE_UNICODE[space] && char === " ") {
  15124. char = SPACE_UNICODE[space];
  15125. }
  15126. if (isEscape) {
  15127. if (char === "n") {
  15128. result += LINEFEED;
  15129. } else if (char === "\\") {
  15130. result += "\\";
  15131. } else {
  15132. result += "\\" + char;
  15133. }
  15134. isEscape = false;
  15135. } else {
  15136. if (char === "\\") {
  15137. isEscape = true;
  15138. } else {
  15139. result += char;
  15140. }
  15141. }
  15142. }
  15143. if (!decode2) {
  15144. return result;
  15145. }
  15146. return result.replace(/&nbsp;/g, SPACE_UNICODE.nbsp).replace(/&ensp;/g, SPACE_UNICODE.ensp).replace(/&emsp;/g, SPACE_UNICODE.emsp).replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&amp;/g, "&").replace(/&quot;/g, '"').replace(/&apos;/g, "'");
  15147. }
  15148. function parseText(text2, options) {
  15149. return normalizeText(text2, options).split(LINEFEED);
  15150. }
  15151. class UniTextElement extends UniElement {
  15152. }
  15153. const index$l = /* @__PURE__ */ defineBuiltInComponent({
  15154. name: "Text",
  15155. rootElement: {
  15156. name: "uni-text",
  15157. class: UniTextElement
  15158. },
  15159. props: {
  15160. selectable: {
  15161. type: [Boolean, String],
  15162. default: false
  15163. },
  15164. space: {
  15165. type: String,
  15166. default: ""
  15167. },
  15168. decode: {
  15169. type: [Boolean, String],
  15170. default: false
  15171. }
  15172. },
  15173. setup(props2, {
  15174. slots
  15175. }) {
  15176. const rootRef = ref(null);
  15177. onMounted(() => {
  15178. const rootElement = rootRef.value;
  15179. rootElement.attachVmProps(props2);
  15180. });
  15181. return () => {
  15182. const children = [];
  15183. if (slots.default) {
  15184. slots.default().forEach((vnode) => {
  15185. if (vnode.shapeFlag & 8 && vnode.type !== Comment) {
  15186. const lines = parseText(vnode.children, {
  15187. space: props2.space,
  15188. decode: props2.decode
  15189. });
  15190. const len = lines.length - 1;
  15191. lines.forEach((line, index2) => {
  15192. if (index2 === 0 && !line)
  15193. ;
  15194. else {
  15195. children.push(createTextVNode(line));
  15196. }
  15197. if (index2 !== len) {
  15198. children.push(createVNode("br"));
  15199. }
  15200. });
  15201. } else {
  15202. if (process.env.NODE_ENV !== "production" && vnode.shapeFlag & 6 && vnode.type.name !== "Text") {
  15203. console.warn("Do not nest other components in the text component, as there may be display differences on different platforms.");
  15204. }
  15205. children.push(vnode);
  15206. }
  15207. });
  15208. }
  15209. return createVNode("uni-text", {
  15210. "ref": rootRef,
  15211. "selectable": props2.selectable ? true : null
  15212. }, [createVNode("span", null, children)], 8, ["selectable"]);
  15213. };
  15214. }
  15215. });
  15216. const props$h = /* @__PURE__ */ extend({}, props$r, {
  15217. placeholderClass: {
  15218. type: String,
  15219. default: "input-placeholder"
  15220. },
  15221. autoHeight: {
  15222. type: [Boolean, String],
  15223. default: false
  15224. },
  15225. confirmType: {
  15226. type: String,
  15227. default: "return",
  15228. validator(val) {
  15229. return ConfirmTypes.concat("return").includes(val);
  15230. }
  15231. }
  15232. });
  15233. let fixMargin = false;
  15234. const ConfirmTypes = ["done", "go", "next", "search", "send"];
  15235. function setFixMargin() {
  15236. const DARK_TEST_STRING = "(prefers-color-scheme: dark)";
  15237. fixMargin = String(navigator.platform).indexOf("iP") === 0 && String(navigator.vendor).indexOf("Apple") === 0 && window.matchMedia(DARK_TEST_STRING).media !== DARK_TEST_STRING;
  15238. }
  15239. class UniTextareaElement extends UniElement {
  15240. focus(options) {
  15241. var _a;
  15242. (_a = this.querySelector("textarea")) == null ? void 0 : _a.focus(options);
  15243. }
  15244. }
  15245. const index$k = /* @__PURE__ */ defineBuiltInComponent({
  15246. name: "Textarea",
  15247. props: props$h,
  15248. emits: ["confirm", "linechange", ...emit],
  15249. rootElement: {
  15250. name: "uni-textarea",
  15251. class: UniTextareaElement
  15252. },
  15253. setup(props2, {
  15254. emit: emit2,
  15255. expose
  15256. }) {
  15257. const rootRef = ref(null);
  15258. const wrapperRef = ref(null);
  15259. const {
  15260. fieldRef,
  15261. state: state2,
  15262. scopedAttrsState,
  15263. fixDisabledColor,
  15264. trigger
  15265. } = useField(props2, rootRef, emit2);
  15266. const valueCompute = computed(() => state2.value.split(LINEFEED));
  15267. const isDone = computed(() => ConfirmTypes.includes(props2.confirmType));
  15268. const heightRef = ref(0);
  15269. const lineRef = ref(null);
  15270. watch(() => heightRef.value, (height) => {
  15271. const el = rootRef.value;
  15272. const lineEl = lineRef.value;
  15273. const wrapper2 = wrapperRef.value;
  15274. let lineHeight = parseFloat(getComputedStyle(el).lineHeight);
  15275. if (isNaN(lineHeight)) {
  15276. lineHeight = lineEl.offsetHeight;
  15277. }
  15278. var lineCount = Math.round(height / lineHeight);
  15279. trigger("linechange", {}, {
  15280. height,
  15281. heightRpx: 750 / window.innerWidth * height,
  15282. lineCount
  15283. });
  15284. if (props2.autoHeight) {
  15285. el.style.height = "auto";
  15286. wrapper2.style.height = height + "px";
  15287. }
  15288. });
  15289. function onResize2({
  15290. height
  15291. }) {
  15292. heightRef.value = height;
  15293. }
  15294. function confirm(event) {
  15295. trigger("confirm", event, {
  15296. value: state2.value
  15297. });
  15298. }
  15299. function onKeyDownEnter(event) {
  15300. if (event.key !== "Enter") {
  15301. return;
  15302. }
  15303. if (isDone.value) {
  15304. event.preventDefault();
  15305. }
  15306. }
  15307. function onKeyUpEnter(event) {
  15308. if (event.key !== "Enter") {
  15309. return;
  15310. }
  15311. if (isDone.value) {
  15312. confirm(event);
  15313. const textarea = event.target;
  15314. !props2.confirmHold && textarea.blur();
  15315. }
  15316. }
  15317. {
  15318. setFixMargin();
  15319. }
  15320. expose({
  15321. $triggerInput: (detail) => {
  15322. emit2("update:modelValue", detail.value);
  15323. emit2("update:value", detail.value);
  15324. state2.value = detail.value;
  15325. }
  15326. });
  15327. onMounted(() => {
  15328. const rootElement = rootRef.value;
  15329. Object.defineProperty(rootElement, "value", {
  15330. get() {
  15331. return state2.value;
  15332. },
  15333. set(value) {
  15334. rootElement.querySelector("textarea").value = value;
  15335. }
  15336. });
  15337. rootElement.attachVmProps(props2);
  15338. });
  15339. return () => {
  15340. let textareaNode = props2.disabled && fixDisabledColor ? createVNode("textarea", {
  15341. "key": "disabled-textarea",
  15342. "ref": fieldRef,
  15343. "value": state2.value,
  15344. "tabindex": "-1",
  15345. "readonly": !!props2.disabled,
  15346. "maxlength": state2.maxlength,
  15347. "class": {
  15348. "uni-textarea-textarea": true,
  15349. "uni-textarea-textarea-fix-margin": fixMargin
  15350. },
  15351. "style": {
  15352. overflowY: props2.autoHeight ? "hidden" : "auto",
  15353. /* eslint-disable no-restricted-syntax */
  15354. ...props2.cursorColor && {
  15355. caretColor: props2.cursorColor
  15356. }
  15357. },
  15358. "onFocus": (event) => event.target.blur()
  15359. }, null, 46, ["value", "readonly", "maxlength", "onFocus"]) : createVNode("textarea", {
  15360. "key": "textarea",
  15361. "ref": fieldRef,
  15362. "value": state2.value,
  15363. "disabled": !!props2.disabled,
  15364. "maxlength": state2.maxlength,
  15365. "enterkeyhint": props2.confirmType,
  15366. "inputmode": props2.inputmode,
  15367. "class": {
  15368. "uni-textarea-textarea": true,
  15369. "uni-textarea-textarea-fix-margin": fixMargin
  15370. },
  15371. "style": {
  15372. overflowY: props2.autoHeight ? "hidden" : "auto",
  15373. /* eslint-disable no-restricted-syntax */
  15374. ...props2.cursorColor && {
  15375. caretColor: props2.cursorColor
  15376. }
  15377. },
  15378. "onKeydown": onKeyDownEnter,
  15379. "onKeyup": onKeyUpEnter
  15380. }, null, 46, ["value", "disabled", "maxlength", "enterkeyhint", "inputmode", "onKeydown", "onKeyup"]);
  15381. return createVNode("uni-textarea", {
  15382. "ref": rootRef
  15383. }, [createVNode("div", {
  15384. "ref": wrapperRef,
  15385. "class": "uni-textarea-wrapper"
  15386. }, [withDirectives(createVNode("div", mergeProps(scopedAttrsState.attrs, {
  15387. "style": props2.placeholderStyle,
  15388. "class": ["uni-textarea-placeholder", props2.placeholderClass]
  15389. }), [props2.placeholder], 16), [[vShow, !state2.value.length]]), createVNode("div", {
  15390. "ref": lineRef,
  15391. "class": "uni-textarea-line"
  15392. }, [" "], 512), createVNode("div", {
  15393. "class": "uni-textarea-compute"
  15394. }, [valueCompute.value.map((item) => createVNode("div", null, [item.trim() ? item : "."])), createVNode(ResizeSensor, {
  15395. "initial": true,
  15396. "onResize": onResize2
  15397. }, null, 8, ["initial", "onResize"])]), props2.confirmType === "search" ? createVNode("form", {
  15398. "action": "",
  15399. "onSubmit": () => false,
  15400. "class": "uni-input-form"
  15401. }, [textareaNode], 40, ["onSubmit"]) : textareaNode], 512)], 512);
  15402. };
  15403. }
  15404. });
  15405. class UniViewElement extends UniElement {
  15406. }
  15407. const index$j = /* @__PURE__ */ defineBuiltInComponent({
  15408. name: "View",
  15409. props: extend({}, hoverProps),
  15410. rootElement: {
  15411. name: "uni-view",
  15412. class: UniViewElement
  15413. },
  15414. setup(props2, {
  15415. slots
  15416. }) {
  15417. const rootRef = ref(null);
  15418. const {
  15419. hovering,
  15420. binding
  15421. } = useHover(props2);
  15422. onMounted(() => {
  15423. const rootElement = rootRef.value;
  15424. rootElement.attachVmProps(props2);
  15425. });
  15426. return () => {
  15427. const hoverClass = props2.hoverClass;
  15428. if (hoverClass && hoverClass !== "none") {
  15429. return createVNode("uni-view", mergeProps({
  15430. "class": hovering.value ? hoverClass : "",
  15431. "ref": rootRef
  15432. }, binding), [slots.default && slots.default()], 16);
  15433. }
  15434. return createVNode("uni-view", {
  15435. "ref": rootRef
  15436. }, [slots.default && slots.default()], 512);
  15437. };
  15438. }
  15439. });
  15440. function isHTMlElement(node) {
  15441. return !!(node && node.nodeType === 1);
  15442. }
  15443. function getChildren(root) {
  15444. const children = [];
  15445. if (root) {
  15446. walk(root, children);
  15447. }
  15448. return children;
  15449. }
  15450. function walk(vnode, children) {
  15451. if (vnode.component) {
  15452. children.push(vnode);
  15453. } else if (vnode.shapeFlag & 16) {
  15454. const vnodes = vnode.children;
  15455. for (let i = 0; i < vnodes.length; i++) {
  15456. walk(vnodes[i], children);
  15457. }
  15458. }
  15459. }
  15460. function traverseListView(visibleVNode, callback) {
  15461. const children = getChildren(visibleVNode);
  15462. for (let i = 0; i < children.length; i++) {
  15463. const child = children[i];
  15464. callback(child);
  15465. }
  15466. }
  15467. function traverseStickySection(stickySectionVNode, callback) {
  15468. const children = getChildren(stickySectionVNode.component.subTree);
  15469. for (let i = 0; i < children.length; i++) {
  15470. const child = children[i];
  15471. callback(child);
  15472. }
  15473. }
  15474. class UniListViewElement extends UniElement {
  15475. }
  15476. const index$i = /* @__PURE__ */ defineBuiltInComponent({
  15477. name: "ListView",
  15478. props: {
  15479. direction: {
  15480. type: String,
  15481. default: "vertical",
  15482. validator: (val) => {
  15483. return ["none", "vertical", "horizontal"].includes(val);
  15484. }
  15485. },
  15486. showScrollbar: {
  15487. type: [Boolean, String],
  15488. default: true
  15489. },
  15490. upperThreshold: {
  15491. type: [Number, String],
  15492. default: 50
  15493. },
  15494. lowerThreshold: {
  15495. type: [Number, String],
  15496. default: 50
  15497. },
  15498. scrollTop: {
  15499. type: [Number, String],
  15500. default: 0
  15501. },
  15502. scrollLeft: {
  15503. type: [Number, String],
  15504. default: 0
  15505. },
  15506. // 暂不支持
  15507. // scrollIntoView: {
  15508. // type: String,
  15509. // default: '',
  15510. // },
  15511. scrollWithAnimation: {
  15512. type: [Boolean, String],
  15513. default: false
  15514. }
  15515. },
  15516. emits: [
  15517. "scroll",
  15518. "scrolltoupper",
  15519. "scrolltolower"
  15520. // 有触发时机,但是由于没有原生事件暂不支持
  15521. // 'scrollend',
  15522. ],
  15523. rootElement: {
  15524. name: "uni-list-view",
  15525. class: UniListViewElement
  15526. },
  15527. setup(props2, {
  15528. slots,
  15529. expose,
  15530. emit: emit2
  15531. }) {
  15532. const rootRef = ref(null);
  15533. const containerRef = ref(null);
  15534. const visibleRef = ref(null);
  15535. const placehoderSize = ref(0);
  15536. const visibleSize = ref(0);
  15537. const totalSize = ref(0);
  15538. const isVertical = computed(() => {
  15539. return props2.direction !== "horizontal";
  15540. });
  15541. const defaultItemSize = 40;
  15542. const cacheScreenCount = 5;
  15543. const loadScreenThreshold = 3;
  15544. let containerSize = 0;
  15545. provide("__listViewIsVertical", isVertical);
  15546. provide("__listViewDefaultItemSize", defaultItemSize);
  15547. const onItemChange = debounce(() => {
  15548. nextTick(() => {
  15549. rearrange();
  15550. });
  15551. }, 10, {
  15552. clearTimeout,
  15553. setTimeout
  15554. });
  15555. provide("__listViewRegisterItem", (status) => {
  15556. onItemChange();
  15557. });
  15558. provide("__listViewUnregisterItem", (status) => {
  15559. onItemChange();
  15560. });
  15561. const trigger = useCustomEvent(rootRef, emit2);
  15562. handleTouchEvent(isVertical, containerRef);
  15563. function getOffset() {
  15564. return isVertical.value ? containerRef.value.scrollTop : containerRef.value.scrollLeft;
  15565. }
  15566. function resetContainerSize() {
  15567. const containerEl = containerRef.value;
  15568. containerSize = isVertical.value ? containerEl.clientHeight : containerEl.clientWidth;
  15569. }
  15570. watch(isVertical, () => {
  15571. resetContainerSize();
  15572. });
  15573. function shouldRearrange() {
  15574. const offset = getOffset();
  15575. const loadScreenThresholdSize = containerSize * loadScreenThreshold;
  15576. const rearrangeOffsetMin = placehoderSize.value + loadScreenThresholdSize;
  15577. const rearrangeOffsetMax = placehoderSize.value + visibleSize.value - loadScreenThresholdSize;
  15578. return offset < rearrangeOffsetMin && placehoderSize.value > 0 || offset > rearrangeOffsetMax && placehoderSize.value + visibleSize.value < totalSize.value;
  15579. }
  15580. const upperThresholdNumber = computed(() => {
  15581. const val = Number(props2.upperThreshold);
  15582. return isNaN(val) ? 50 : val;
  15583. });
  15584. const lowerThresholdNumber = computed(() => {
  15585. const val = Number(props2.lowerThreshold);
  15586. return isNaN(val) ? 50 : val;
  15587. });
  15588. const scrollTopNumber = computed(() => {
  15589. return Number(props2.scrollTop) || 0;
  15590. });
  15591. const scrollLeftNumber = computed(() => {
  15592. return Number(props2.scrollLeft) || 0;
  15593. });
  15594. watch(scrollTopNumber, (val) => {
  15595. if (containerRef.value) {
  15596. containerRef.value.scrollTop = val;
  15597. }
  15598. });
  15599. watch(scrollLeftNumber, (val) => {
  15600. if (containerRef.value) {
  15601. containerRef.value.scrollLeft = val;
  15602. }
  15603. });
  15604. onMounted(() => {
  15605. resetContainerSize();
  15606. let lastScrollOffset = 0;
  15607. containerRef.value.addEventListener("scroll", function($event) {
  15608. const target = $event.target;
  15609. trigger("scroll", $event, {
  15610. scrollLeft: target.scrollLeft,
  15611. scrollTop: target.scrollTop,
  15612. scrollHeight: target.scrollHeight,
  15613. scrollWidth: target.scrollWidth,
  15614. deltaX: isVertical.value ? 0 : lastScrollOffset - target.scrollLeft,
  15615. deltaY: isVertical.value ? lastScrollOffset - target.scrollTop : 0
  15616. });
  15617. const currentOffset = getOffset();
  15618. const upperOffset = upperThresholdNumber.value;
  15619. if (currentOffset <= upperOffset && lastScrollOffset > upperOffset) {
  15620. trigger("scrolltoupper", $event, {
  15621. direction: isVertical.value ? "top" : "left"
  15622. });
  15623. }
  15624. const realTotalSize = isVertical.value ? target.scrollHeight : target.scrollWidth;
  15625. const realRootSize = isVertical.value ? target.clientHeight : target.clientWidth;
  15626. const lowerOffset = realTotalSize - realRootSize - lowerThresholdNumber.value;
  15627. if (currentOffset >= lowerOffset && lastScrollOffset < lowerOffset) {
  15628. trigger("scrolltolower", $event, {
  15629. direction: isVertical.value ? "bottom" : "right"
  15630. });
  15631. }
  15632. lastScrollOffset = currentOffset;
  15633. if (shouldRearrange()) {
  15634. rearrange();
  15635. }
  15636. });
  15637. const rootElement = rootRef.value;
  15638. const containerElement = containerRef.value;
  15639. Object.defineProperties(rootElement, {
  15640. scrollHeight: {
  15641. get() {
  15642. return containerElement.scrollHeight;
  15643. }
  15644. },
  15645. scrollWidth: {
  15646. get() {
  15647. return containerElement.scrollWidth;
  15648. }
  15649. },
  15650. scrollLeft: {
  15651. get() {
  15652. return containerElement.scrollLeft;
  15653. },
  15654. set(val) {
  15655. containerElement.scrollLeft = val;
  15656. }
  15657. },
  15658. scrollTop: {
  15659. get() {
  15660. return containerElement.scrollTop;
  15661. },
  15662. set(val) {
  15663. containerElement.scrollTop = val;
  15664. }
  15665. },
  15666. scrollBy: {
  15667. get() {
  15668. return containerElement.scrollBy.bind(containerElement);
  15669. }
  15670. }
  15671. });
  15672. rootElement.attachVmProps(props2);
  15673. });
  15674. function refresh() {
  15675. traverseAllItems((child) => {
  15676. const exposed = child.component.exposed;
  15677. if (exposed == null ? void 0 : exposed.__listViewChildStatus.seen.value) {
  15678. exposed.__listViewChildStatus.seen.value = false;
  15679. }
  15680. });
  15681. nextTick(() => {
  15682. nextTick(() => {
  15683. rearrange();
  15684. });
  15685. });
  15686. }
  15687. expose({
  15688. refresh
  15689. });
  15690. function onResize2() {
  15691. resetContainerSize();
  15692. refresh();
  15693. }
  15694. function traverseAllItems(callback) {
  15695. traverseListView(visibleVNode, (child) => {
  15696. var _a;
  15697. const childType = (_a = child.component) == null ? void 0 : _a.type.name;
  15698. if (childType === "StickySection") {
  15699. traverseStickySection(child, function() {
  15700. var _a2;
  15701. const childType2 = (_a2 = child.component) == null ? void 0 : _a2.type.name;
  15702. if (childType2 === "ListItem") {
  15703. callback(child);
  15704. }
  15705. });
  15706. } else if (childType === "ListItem") {
  15707. callback(child);
  15708. }
  15709. });
  15710. }
  15711. function rearrange() {
  15712. if (!visibleVNode) {
  15713. return;
  15714. }
  15715. const containerEl = containerRef.value;
  15716. if (!containerEl) {
  15717. return;
  15718. }
  15719. const offset = isVertical.value ? containerEl.scrollTop : containerEl.scrollLeft;
  15720. const offsetMin = Math.max(offset - containerSize * cacheScreenCount, 0);
  15721. const offsetMax = Math.max(offset + containerSize * (cacheScreenCount + 1), offsetMin + 1);
  15722. let tempTotalSize = 0;
  15723. let tempVisibleSize = 0;
  15724. let tempPlaceholderSize = 0;
  15725. let start = false, end = false;
  15726. function callback(child) {
  15727. var _a, _b, _c;
  15728. const childType = (_a = child.component) == null ? void 0 : _a.type.name;
  15729. const status = (_c = (_b = child.component) == null ? void 0 : _b.exposed) == null ? void 0 : _c.__listViewChildStatus;
  15730. if (childType === "StickySection") {
  15731. const {
  15732. headSize,
  15733. tailSize
  15734. } = status;
  15735. tempTotalSize += headSize.value;
  15736. traverseStickySection(child, callback);
  15737. tempTotalSize += tailSize.value;
  15738. } else if (childType === "ListItem") {
  15739. const {
  15740. cachedSize
  15741. } = status;
  15742. const itemSize = cachedSize;
  15743. tempTotalSize += itemSize;
  15744. if (!start && tempTotalSize > offsetMin) {
  15745. start = true;
  15746. }
  15747. if (!start) {
  15748. tempPlaceholderSize += itemSize;
  15749. }
  15750. if (start && !end) {
  15751. tempVisibleSize += itemSize;
  15752. status.visible.value = true;
  15753. } else {
  15754. status.visible.value = false;
  15755. }
  15756. if (!end && tempTotalSize >= offsetMax) {
  15757. end = true;
  15758. }
  15759. } else if (childType === "StickyHeader") {
  15760. const {
  15761. cachedSize
  15762. } = status;
  15763. tempTotalSize += cachedSize;
  15764. tempVisibleSize += cachedSize;
  15765. }
  15766. }
  15767. traverseListView(visibleVNode, callback);
  15768. totalSize.value = tempTotalSize;
  15769. visibleSize.value = tempVisibleSize;
  15770. placehoderSize.value = tempPlaceholderSize;
  15771. }
  15772. const containerStyle = computed(() => {
  15773. return `${props2.direction === "none" ? "overflow: hidden;" : isVertical.value ? "overflow-y: auto;" : "overflow-x: auto;"}scroll-behavior: ${props2.scrollWithAnimation ? "smooth" : "auto"};`;
  15774. });
  15775. const contentStyle = computed(() => {
  15776. return `position: relative; ${isVertical.value ? "height" : "width"}: ${totalSize.value}px;`;
  15777. });
  15778. const visibleStyle = computed(() => {
  15779. return `position: absolute; ${isVertical.value ? "width" : "height"}: 100%; ${isVertical.value ? "top" : "left"}: ${placehoderSize.value}px;`;
  15780. });
  15781. let visibleVNode = null;
  15782. return () => {
  15783. const defaultSlot = slots.default && slots.default();
  15784. visibleVNode = createVNode("div", {
  15785. "ref": visibleRef,
  15786. "class": "uni-list-view-visible",
  15787. "style": visibleStyle.value
  15788. }, [defaultSlot], 4);
  15789. return createVNode("uni-list-view", {
  15790. "ref": rootRef,
  15791. "class": "uni-list-view"
  15792. }, [createVNode("div", {
  15793. "ref": containerRef,
  15794. "class": `uni-list-view-container ${props2.showScrollbar === false ? "uni-list-view-scrollbar-hidden" : ""}`,
  15795. "style": containerStyle.value
  15796. }, [createVNode("div", {
  15797. "class": "uni-list-view-content",
  15798. "style": contentStyle.value
  15799. }, [visibleVNode], 4)], 4), createVNode(ResizeSensor, {
  15800. "onResize": onResize2
  15801. }, null, 8, ["onResize"])], 512);
  15802. };
  15803. }
  15804. });
  15805. function handleTouchEvent(isVertical, containerRef) {
  15806. let touchStart = {
  15807. x: 0,
  15808. y: 0
  15809. };
  15810. function __handleTouchStart(event) {
  15811. if (event.touches.length === 1) {
  15812. touchStart = {
  15813. x: event.touches[0].pageX,
  15814. y: event.touches[0].pageY
  15815. };
  15816. }
  15817. }
  15818. function __handleTouchMove(event) {
  15819. const containerEl = containerRef.value;
  15820. if (touchStart === null)
  15821. return;
  15822. let x = event.touches[0].pageX;
  15823. let y = event.touches[0].pageY;
  15824. if (!isVertical.value) {
  15825. return;
  15826. }
  15827. let needStop = false;
  15828. if (Math.abs(touchStart.y - y) < Math.abs(touchStart.x - x)) {
  15829. needStop = false;
  15830. } else if (containerEl.scrollTop === 0 && y > touchStart.y) {
  15831. needStop = false;
  15832. } else if (containerEl.scrollHeight === containerEl.offsetHeight + containerEl.scrollTop && y < touchStart.y) {
  15833. needStop = false;
  15834. } else {
  15835. needStop = true;
  15836. }
  15837. if (needStop) {
  15838. event.stopPropagation();
  15839. }
  15840. }
  15841. function __handleTouchEnd(event) {
  15842. touchStart = null;
  15843. }
  15844. onMounted(() => {
  15845. const containerEl = containerRef.value;
  15846. containerEl.addEventListener("touchstart", __handleTouchStart);
  15847. containerEl.addEventListener("touchmove", __handleTouchMove);
  15848. containerEl.addEventListener("touchend", __handleTouchEnd);
  15849. });
  15850. onBeforeUnmount(() => {
  15851. const containerEl = containerRef.value;
  15852. containerEl.removeEventListener("touchstart", __handleTouchStart);
  15853. containerEl.removeEventListener("touchmove", __handleTouchMove);
  15854. containerEl.removeEventListener("touchend", __handleTouchEnd);
  15855. });
  15856. }
  15857. function getSize(isVertical, el) {
  15858. var style = window.getComputedStyle(el);
  15859. if (isVertical) {
  15860. return parseFloat(style.marginTop) + el.getBoundingClientRect().height + parseFloat(style.marginBottom);
  15861. } else {
  15862. return parseFloat(style.marginLeft) + el.getBoundingClientRect().width + parseFloat(style.marginRight);
  15863. }
  15864. }
  15865. class UniListItemElement extends UniElement {
  15866. }
  15867. const index$h = /* @__PURE__ */ defineBuiltInComponent({
  15868. name: "ListItem",
  15869. props: {},
  15870. rootElement: {
  15871. name: "uni-list-item",
  15872. class: UniListItemElement
  15873. },
  15874. setup(props2, {
  15875. slots,
  15876. expose
  15877. }) {
  15878. const rootRef = ref(null);
  15879. const isVertical = inject("__listViewIsVertical");
  15880. const visible = ref(false);
  15881. const seen = ref(false);
  15882. const status = {
  15883. type: "ListItem",
  15884. visible,
  15885. cachedSize: 0,
  15886. seen
  15887. };
  15888. expose({
  15889. __listViewChildStatus: status
  15890. });
  15891. const registerItem = inject("__listViewRegisterItem");
  15892. const unregisterItem = inject("__listViewUnregisterItem");
  15893. onMounted(() => {
  15894. registerItem(status);
  15895. });
  15896. onBeforeUnmount(() => {
  15897. unregisterItem(status);
  15898. });
  15899. const realVisible = computed(() => {
  15900. return visible.value || !status.seen.value;
  15901. });
  15902. return () => {
  15903. nextTick(() => {
  15904. const rootNode = rootRef.value;
  15905. if (realVisible.value && isHTMlElement(rootNode)) {
  15906. status.cachedSize = getSize(isVertical.value, rootNode);
  15907. seen.value = true;
  15908. }
  15909. });
  15910. if (!realVisible.value) {
  15911. return null;
  15912. }
  15913. return createVNode("uni-list-item", {
  15914. "ref": rootRef
  15915. }, [slots.default && slots.default()], 512);
  15916. };
  15917. }
  15918. });
  15919. class UniStickySectionElement extends UniElement {
  15920. }
  15921. const index$g = /* @__PURE__ */ defineBuiltInComponent({
  15922. name: "StickySection",
  15923. props: {
  15924. padding: {
  15925. type: Array,
  15926. default: [0, 0, 0, 0]
  15927. }
  15928. },
  15929. rootElement: {
  15930. name: "uni-sticky-section",
  15931. class: UniStickySectionElement
  15932. },
  15933. setup(props2, {
  15934. slots,
  15935. expose
  15936. }) {
  15937. const rootRef = ref(null);
  15938. const isVertical = inject("__listViewIsVertical");
  15939. const style = computed(() => {
  15940. return {
  15941. paddingTop: props2.padding[0] + "px",
  15942. paddingRight: props2.padding[1] + "px",
  15943. paddingBottom: props2.padding[2] + "px",
  15944. paddingLeft: props2.padding[3] + "px"
  15945. };
  15946. });
  15947. const headSize = computed(() => {
  15948. return isVertical ? props2.padding[0] : props2.padding[3];
  15949. });
  15950. const tailSize = computed(() => {
  15951. return isVertical ? props2.padding[2] : props2.padding[1];
  15952. });
  15953. const status = {
  15954. type: "StickySection",
  15955. headSize,
  15956. tailSize
  15957. };
  15958. expose({
  15959. __listViewChildStatus: status
  15960. });
  15961. onMounted(() => {
  15962. const rootElement = rootRef.value;
  15963. rootElement.attachVmProps(props2);
  15964. });
  15965. return () => {
  15966. var _a;
  15967. return createVNode("uni-sticky-section", {
  15968. "ref": rootRef,
  15969. "style": style.value
  15970. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)], 4);
  15971. };
  15972. }
  15973. });
  15974. class UniStickyHeaderElement extends UniElement {
  15975. }
  15976. const index$f = /* @__PURE__ */ defineBuiltInComponent({
  15977. name: "StickyHeader",
  15978. props: {
  15979. padding: {
  15980. type: Array,
  15981. default: [0, 0, 0, 0]
  15982. }
  15983. },
  15984. rootElement: {
  15985. name: "uni-sticky-header",
  15986. class: UniStickyHeaderElement
  15987. },
  15988. setup(props2, {
  15989. slots,
  15990. expose
  15991. }) {
  15992. const rootRef = ref(null);
  15993. const isVertical = inject("__listViewIsVertical");
  15994. const style = computed(() => {
  15995. return {
  15996. paddingTop: props2.padding[0] + "px",
  15997. paddingRight: props2.padding[1] + "px",
  15998. paddingBottom: props2.padding[2] + "px",
  15999. paddingLeft: props2.padding[3] + "px",
  16000. top: 0 - props2.padding[0] + "px"
  16001. };
  16002. });
  16003. const status = {
  16004. type: "StickyHeader",
  16005. cachedSize: 0
  16006. };
  16007. expose({
  16008. __listViewChildStatus: status
  16009. });
  16010. onMounted(() => {
  16011. const rootElement = rootRef.value;
  16012. rootElement.attachVmProps(props2);
  16013. });
  16014. return () => {
  16015. var _a;
  16016. nextTick(() => {
  16017. const rootEl = rootRef.value;
  16018. const rect = rootEl.getBoundingClientRect();
  16019. status.cachedSize = isVertical ? rect.height : rect.width;
  16020. });
  16021. return createVNode("uni-sticky-header", {
  16022. "ref": rootRef,
  16023. "style": style.value
  16024. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)], 4);
  16025. };
  16026. }
  16027. });
  16028. function normalizeEvent(vm, id2) {
  16029. if (!id2) {
  16030. id2 = vm.id;
  16031. }
  16032. if (!id2) {
  16033. return;
  16034. }
  16035. return vm.$options.name.toLowerCase() + "." + id2;
  16036. }
  16037. function addSubscribe(name, callback, pageId) {
  16038. if (!name) {
  16039. return;
  16040. }
  16041. registerViewMethod(
  16042. pageId || getCurrentPageId(),
  16043. name,
  16044. ({ type, data }, resolve) => {
  16045. callback(type, data, resolve);
  16046. }
  16047. );
  16048. }
  16049. function removeSubscribe(name, pageId) {
  16050. if (!name) {
  16051. return;
  16052. }
  16053. unregisterViewMethod(pageId || getCurrentPageId(), name);
  16054. }
  16055. function useSubscribe(callback, name, multiple, pageId) {
  16056. const instance2 = getCurrentInstance();
  16057. const vm = instance2.proxy;
  16058. onMounted(() => {
  16059. addSubscribe(name || normalizeEvent(vm), callback, pageId);
  16060. if (multiple || !name) {
  16061. watch(
  16062. () => vm.id,
  16063. (value, oldValue) => {
  16064. addSubscribe(normalizeEvent(vm, value), callback, pageId);
  16065. removeSubscribe(oldValue && normalizeEvent(vm, oldValue));
  16066. }
  16067. );
  16068. }
  16069. });
  16070. onBeforeUnmount(() => {
  16071. removeSubscribe(name || normalizeEvent(vm), pageId);
  16072. });
  16073. }
  16074. function useOn(name, callback) {
  16075. onMounted(() => UniViewJSBridge.on(name, callback));
  16076. onBeforeUnmount(() => UniViewJSBridge.off(name));
  16077. }
  16078. let index$e = 0;
  16079. function useContextInfo(_id) {
  16080. const page = useCurrentPageId();
  16081. const instance2 = getCurrentInstance();
  16082. const vm = instance2.proxy;
  16083. const type = vm.$options.name.toLowerCase();
  16084. const id2 = _id || vm.id || `context${index$e++}`;
  16085. onMounted(() => {
  16086. const el = vm.$el;
  16087. el.__uniContextInfo = {
  16088. id: id2,
  16089. type,
  16090. page
  16091. };
  16092. });
  16093. return `${type}.${id2}`;
  16094. }
  16095. function getContextInfo(el) {
  16096. return el.__uniContextInfo;
  16097. }
  16098. function injectLifecycleHook(name, hook, publicThis, instance2) {
  16099. if (isFunction(hook)) {
  16100. injectHook(name, hook.bind(publicThis), instance2);
  16101. }
  16102. }
  16103. function initHooks(options, instance2, publicThis) {
  16104. var _a;
  16105. const mpType = options.mpType || publicThis.$mpType;
  16106. if (!mpType || mpType === "component") {
  16107. return;
  16108. }
  16109. Object.keys(options).forEach((name) => {
  16110. if (isUniLifecycleHook(name, options[name], false)) {
  16111. const hooks = options[name];
  16112. if (isArray(hooks)) {
  16113. hooks.forEach(
  16114. (hook) => injectLifecycleHook(name, hook, publicThis, instance2)
  16115. );
  16116. } else {
  16117. injectLifecycleHook(name, hooks, publicThis, instance2);
  16118. }
  16119. }
  16120. });
  16121. if (mpType === "page") {
  16122. instance2.__isVisible = true;
  16123. try {
  16124. invokeHook(publicThis, ON_LOAD, instance2.attrs.__pageQuery);
  16125. delete instance2.attrs.__pageQuery;
  16126. if (((_a = publicThis.$page) == null ? void 0 : _a.openType) !== "preloadPage") {
  16127. invokeHook(publicThis, ON_SHOW);
  16128. }
  16129. } catch (e2) {
  16130. console.error(e2.message + LINEFEED + e2.stack);
  16131. }
  16132. }
  16133. }
  16134. function applyOptions(options, instance2, publicThis) {
  16135. initHooks(options, instance2, publicThis);
  16136. }
  16137. function set(target, key, val) {
  16138. return target[key] = val;
  16139. }
  16140. function $callMethod(method, ...args) {
  16141. const fn = this[method];
  16142. if (fn) {
  16143. return fn(...args);
  16144. }
  16145. console.error(`method ${method} not found`);
  16146. return null;
  16147. }
  16148. function createErrorHandler(app) {
  16149. return function errorHandler(err, instance2, _info) {
  16150. if (!instance2) {
  16151. throw err;
  16152. }
  16153. const appInstance = app._instance;
  16154. if (!appInstance || !appInstance.proxy) {
  16155. throw err;
  16156. }
  16157. {
  16158. invokeHook(appInstance.proxy, ON_ERROR, err);
  16159. }
  16160. };
  16161. }
  16162. function mergeAsArray(to, from) {
  16163. return to ? [...new Set([].concat(to, from))] : from;
  16164. }
  16165. function initOptionMergeStrategies(optionMergeStrategies) {
  16166. UniLifecycleHooks.forEach((name) => {
  16167. optionMergeStrategies[name] = mergeAsArray;
  16168. });
  16169. }
  16170. let realAtob;
  16171. const b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
  16172. const b64re = /^(?:[A-Za-z\d+/]{4})*?(?:[A-Za-z\d+/]{2}(?:==)?|[A-Za-z\d+/]{3}=?)?$/;
  16173. if (typeof atob !== "function") {
  16174. realAtob = function(str) {
  16175. str = String(str).replace(/[\t\n\f\r ]+/g, "");
  16176. if (!b64re.test(str)) {
  16177. throw new Error(
  16178. "Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded."
  16179. );
  16180. }
  16181. str += "==".slice(2 - (str.length & 3));
  16182. var bitmap;
  16183. var result = "";
  16184. var r1;
  16185. var r2;
  16186. var i = 0;
  16187. for (; i < str.length; ) {
  16188. bitmap = b64.indexOf(str.charAt(i++)) << 18 | b64.indexOf(str.charAt(i++)) << 12 | (r1 = b64.indexOf(str.charAt(i++))) << 6 | (r2 = b64.indexOf(str.charAt(i++)));
  16189. result += r1 === 64 ? String.fromCharCode(bitmap >> 16 & 255) : r2 === 64 ? String.fromCharCode(bitmap >> 16 & 255, bitmap >> 8 & 255) : String.fromCharCode(
  16190. bitmap >> 16 & 255,
  16191. bitmap >> 8 & 255,
  16192. bitmap & 255
  16193. );
  16194. }
  16195. return result;
  16196. };
  16197. } else {
  16198. realAtob = atob;
  16199. }
  16200. function b64DecodeUnicode(str) {
  16201. return decodeURIComponent(
  16202. realAtob(str).split("").map(function(c) {
  16203. return "%" + ("00" + c.charCodeAt(0).toString(16)).slice(-2);
  16204. }).join("")
  16205. );
  16206. }
  16207. function getCurrentUserInfo() {
  16208. const token = uni.getStorageSync("uni_id_token") || "";
  16209. const tokenArr = token.split(".");
  16210. if (!token || tokenArr.length !== 3) {
  16211. return {
  16212. uid: null,
  16213. role: [],
  16214. permission: [],
  16215. tokenExpired: 0
  16216. };
  16217. }
  16218. let userInfo;
  16219. try {
  16220. userInfo = JSON.parse(b64DecodeUnicode(tokenArr[1]));
  16221. } catch (error) {
  16222. throw new Error("获取当前用户信息出错,详细错误信息为:" + error.message);
  16223. }
  16224. userInfo.tokenExpired = userInfo.exp * 1e3;
  16225. delete userInfo.exp;
  16226. delete userInfo.iat;
  16227. return userInfo;
  16228. }
  16229. function uniIdMixin(globalProperties) {
  16230. globalProperties.uniIDHasRole = function(roleId) {
  16231. const { role } = getCurrentUserInfo();
  16232. return role.indexOf(roleId) > -1;
  16233. };
  16234. globalProperties.uniIDHasPermission = function(permissionId) {
  16235. const { permission } = getCurrentUserInfo();
  16236. return this.uniIDHasRole("admin") || permission.indexOf(permissionId) > -1;
  16237. };
  16238. globalProperties.uniIDTokenValid = function() {
  16239. const { tokenExpired } = getCurrentUserInfo();
  16240. return tokenExpired > Date.now();
  16241. };
  16242. }
  16243. function initApp$1(app) {
  16244. const appConfig = app._context.config;
  16245. appConfig.errorHandler = invokeCreateErrorHandler(app, createErrorHandler);
  16246. initOptionMergeStrategies(appConfig.optionMergeStrategies);
  16247. const globalProperties = appConfig.globalProperties;
  16248. {
  16249. if (__UNI_FEATURE_UNI_CLOUD__) {
  16250. uniIdMixin(globalProperties);
  16251. }
  16252. }
  16253. {
  16254. globalProperties.$set = set;
  16255. globalProperties.$applyOptions = applyOptions;
  16256. globalProperties.$callMethod = $callMethod;
  16257. }
  16258. {
  16259. invokeCreateVueAppHook(app);
  16260. }
  16261. }
  16262. const pageMetaKey = PolySymbol(process.env.NODE_ENV !== "production" ? "UniPageMeta" : "upm");
  16263. function usePageMeta() {
  16264. return inject(pageMetaKey);
  16265. }
  16266. function providePageMeta(id2) {
  16267. const pageMeta = initPageMeta(id2);
  16268. provide(pageMetaKey, pageMeta);
  16269. return pageMeta;
  16270. }
  16271. function usePageRoute() {
  16272. if (__UNI_FEATURE_PAGES__) {
  16273. return useRoute();
  16274. }
  16275. const url = location.href;
  16276. const searchPos = url.indexOf("?");
  16277. const hashPos = url.indexOf("#", searchPos > -1 ? searchPos : 0);
  16278. let query = {};
  16279. if (searchPos > -1) {
  16280. query = parseQuery(
  16281. url.slice(searchPos + 1, hashPos > -1 ? hashPos : url.length)
  16282. );
  16283. }
  16284. const { meta } = __uniRoutes[0];
  16285. const path = addLeadingSlash(meta.route);
  16286. return {
  16287. meta,
  16288. query,
  16289. path,
  16290. matched: [{ path }]
  16291. };
  16292. }
  16293. function initPageMeta(id2) {
  16294. if (__UNI_FEATURE_PAGES__) {
  16295. return reactive(
  16296. normalizePageMeta(
  16297. JSON.parse(
  16298. JSON.stringify(
  16299. initRouteMeta(
  16300. useRoute().meta,
  16301. id2
  16302. )
  16303. )
  16304. )
  16305. )
  16306. );
  16307. }
  16308. return reactive(
  16309. normalizePageMeta(
  16310. JSON.parse(JSON.stringify(initRouteMeta(__uniRoutes[0].meta, id2)))
  16311. )
  16312. );
  16313. }
  16314. function normalizePageMeta(pageMeta) {
  16315. if (__UNI_FEATURE_PULL_DOWN_REFRESH__) {
  16316. const { enablePullDownRefresh, navigationBar } = pageMeta;
  16317. if (enablePullDownRefresh) {
  16318. const pullToRefresh = normalizePullToRefreshRpx(
  16319. extend(
  16320. {
  16321. support: true,
  16322. color: "#2BD009",
  16323. style: "circle",
  16324. height: 70,
  16325. range: 150,
  16326. offset: 0
  16327. },
  16328. pageMeta.pullToRefresh
  16329. )
  16330. );
  16331. const { type, style } = navigationBar;
  16332. if (style !== "custom" && type !== "transparent") {
  16333. pullToRefresh.offset += NAVBAR_HEIGHT + safeAreaInsets$1.top;
  16334. }
  16335. pageMeta.pullToRefresh = pullToRefresh;
  16336. }
  16337. }
  16338. if (__UNI_FEATURE_NAVIGATIONBAR__) {
  16339. const { navigationBar } = pageMeta;
  16340. const { titleSize, titleColor, backgroundColor } = navigationBar;
  16341. navigationBar.titleText = navigationBar.titleText || "";
  16342. navigationBar.type = navigationBar.type || "default";
  16343. navigationBar.titleSize = titleSize || "16px";
  16344. navigationBar.titleColor = titleColor || "#000000";
  16345. navigationBar.backgroundColor = backgroundColor || "#F8F8F8";
  16346. __UNI_FEATURE_I18N_LOCALE__ && initNavigationBarI18n(navigationBar);
  16347. }
  16348. if (__UNI_FEATURE_PAGES__ && history.state) {
  16349. const type = history.state.__type__;
  16350. if ((type === "redirectTo" || type === "reLaunch") && getCurrentPages().length === 0) {
  16351. pageMeta.isEntry = true;
  16352. pageMeta.isQuit = true;
  16353. }
  16354. }
  16355. return pageMeta;
  16356. }
  16357. const screen$1 = window.screen;
  16358. const documentElement = document.documentElement;
  16359. function checkMinWidth(minWidth) {
  16360. const sizes = [
  16361. window.outerWidth,
  16362. window.outerHeight,
  16363. screen$1.width,
  16364. screen$1.height,
  16365. documentElement.clientWidth,
  16366. documentElement.clientHeight
  16367. ];
  16368. return Math.max.apply(null, sizes) > minWidth;
  16369. }
  16370. function getStateId() {
  16371. return history.state && history.state.__id__ || 1;
  16372. }
  16373. let tabBar;
  16374. function useTabBar() {
  16375. if (!tabBar) {
  16376. tabBar = __uniConfig.tabBar && reactive(initTabBarI18n(__uniConfig.tabBar));
  16377. }
  16378. return tabBar;
  16379. }
  16380. const supports = window.CSS && window.CSS.supports;
  16381. function cssSupports(css) {
  16382. return supports && (supports(css) || supports.apply(window.CSS, css.split(":")));
  16383. }
  16384. const cssVar = /* @__PURE__ */ cssSupports("--a:0");
  16385. const cssEnv = /* @__PURE__ */ cssSupports("top:env(a)");
  16386. const cssConstant = /* @__PURE__ */ cssSupports("top:constant(a)");
  16387. const cssBackdropFilter = /* @__PURE__ */ cssSupports("backdrop-filter:blur(10px)");
  16388. const SCHEMA_CSS = {
  16389. "css.var": cssVar,
  16390. "css.env": cssEnv,
  16391. "css.constant": cssConstant,
  16392. "css.backdrop-filter": cssBackdropFilter
  16393. };
  16394. const canIUse = /* @__PURE__ */ defineSyncApi(
  16395. API_CAN_I_USE,
  16396. (schema) => {
  16397. if (hasOwn(SCHEMA_CSS, schema)) {
  16398. return SCHEMA_CSS[schema];
  16399. }
  16400. return true;
  16401. },
  16402. CanIUseProtocol
  16403. );
  16404. const envMethod = /* @__PURE__ */ (() => cssEnv ? "env" : cssConstant ? "constant" : "")();
  16405. function updateCurPageCssVar(pageMeta) {
  16406. let windowTopValue = 0;
  16407. let windowBottomValue = 0;
  16408. if (__UNI_FEATURE_NAVIGATIONBAR__ && pageMeta.navigationBar.style !== "custom" && ["default", "float"].indexOf(pageMeta.navigationBar.type) > -1) {
  16409. windowTopValue = NAVBAR_HEIGHT;
  16410. }
  16411. if (__UNI_FEATURE_TABBAR__ && pageMeta.isTabBar) {
  16412. const tabBar2 = useTabBar();
  16413. tabBar2.shown && (windowBottomValue = parseInt(tabBar2.height));
  16414. }
  16415. updatePageCssVar({
  16416. "--window-top": normalizeWindowTop(windowTopValue),
  16417. "--window-bottom": normalizeWindowBottom(windowBottomValue)
  16418. });
  16419. }
  16420. function normalizeWindowTop(windowTop) {
  16421. return envMethod ? `calc(${windowTop}px + ${envMethod}(safe-area-inset-top))` : `${windowTop}px`;
  16422. }
  16423. function normalizeWindowBottom(windowBottom) {
  16424. return envMethod ? `calc(${windowBottom}px + ${envMethod}(safe-area-inset-bottom))` : `${windowBottom}px`;
  16425. }
  16426. const SEP = "$$";
  16427. const currentPagesMap = /* @__PURE__ */ new Map();
  16428. function pruneCurrentPages() {
  16429. currentPagesMap.forEach((page, id2) => {
  16430. if (page.$.isUnmounted) {
  16431. currentPagesMap.delete(id2);
  16432. }
  16433. });
  16434. }
  16435. function getCurrentPagesMap() {
  16436. return currentPagesMap;
  16437. }
  16438. function getCurrentPages$1() {
  16439. const curPages = [];
  16440. const pages = currentPagesMap.values();
  16441. for (const page of pages) {
  16442. if (page.$.__isTabBar) {
  16443. if (page.$.__isActive) {
  16444. curPages.push(page);
  16445. }
  16446. } else {
  16447. curPages.push(page);
  16448. }
  16449. }
  16450. return curPages;
  16451. }
  16452. function removeRouteCache(routeKey) {
  16453. const vnode = pageCacheMap.get(routeKey);
  16454. if (vnode) {
  16455. pageCacheMap.delete(routeKey);
  16456. routeCache.pruneCacheEntry(vnode);
  16457. }
  16458. }
  16459. function removePage(routeKey, removeRouteCaches = true) {
  16460. const pageVm = currentPagesMap.get(routeKey);
  16461. pageVm.$.__isUnload = true;
  16462. invokeHook(pageVm, ON_UNLOAD);
  16463. currentPagesMap.delete(routeKey);
  16464. removeRouteCaches && removeRouteCache(routeKey);
  16465. }
  16466. let id = /* @__PURE__ */ getStateId();
  16467. function createPageState(type, __id__) {
  16468. return {
  16469. __id__: __id__ || ++id,
  16470. __type__: type
  16471. };
  16472. }
  16473. function initPublicPage(route) {
  16474. const meta = usePageMeta();
  16475. if (!__UNI_FEATURE_PAGES__) {
  16476. return initPageInternalInstance("navigateTo", __uniRoutes[0].path, {}, meta);
  16477. }
  16478. let fullPath = route.fullPath;
  16479. if (route.meta.isEntry && fullPath.indexOf(route.meta.route) === -1) {
  16480. fullPath = "/" + route.meta.route + fullPath.replace("/", "");
  16481. }
  16482. return initPageInternalInstance("navigateTo", fullPath, {}, meta);
  16483. }
  16484. function initPage(vm) {
  16485. const route = vm.$route;
  16486. const page = initPublicPage(route);
  16487. initPageVm(vm, page);
  16488. currentPagesMap.set(normalizeRouteKey(page.path, page.id), vm);
  16489. }
  16490. function normalizeRouteKey(path, id2) {
  16491. return path + SEP + id2;
  16492. }
  16493. function useKeepAliveRoute() {
  16494. const route = useRoute();
  16495. const routeKey = computed(
  16496. () => normalizeRouteKey("/" + route.meta.route, getStateId())
  16497. );
  16498. const isTabBar = computed(() => route.meta.isTabBar);
  16499. return {
  16500. routeKey,
  16501. isTabBar,
  16502. routeCache
  16503. };
  16504. }
  16505. const pageCacheMap = /* @__PURE__ */ new Map();
  16506. const routeCache = {
  16507. get(key) {
  16508. return pageCacheMap.get(key);
  16509. },
  16510. set(key, value) {
  16511. pruneRouteCache(key);
  16512. pageCacheMap.set(key, value);
  16513. },
  16514. delete(key) {
  16515. const vnode = pageCacheMap.get(key);
  16516. if (!vnode) {
  16517. return;
  16518. }
  16519. pageCacheMap.delete(key);
  16520. },
  16521. forEach(fn) {
  16522. pageCacheMap.forEach(fn);
  16523. }
  16524. };
  16525. function isTabBarVNode(vnode) {
  16526. return vnode.props.type === "tabBar";
  16527. }
  16528. function pruneRouteCache(key) {
  16529. const pageId = parseInt(key.split(SEP)[1]);
  16530. if (!pageId) {
  16531. return;
  16532. }
  16533. routeCache.forEach((vnode, key2) => {
  16534. const cPageId = parseInt(key2.split(SEP)[1]);
  16535. if (cPageId && cPageId > pageId) {
  16536. if (__UNI_FEATURE_TABBAR__ && isTabBarVNode(vnode)) {
  16537. return;
  16538. }
  16539. routeCache.delete(key2);
  16540. routeCache.pruneCacheEntry(vnode);
  16541. nextTick(() => pruneCurrentPages());
  16542. }
  16543. });
  16544. }
  16545. function updateCurPageAttrs(pageMeta) {
  16546. {
  16547. const uvueDirKey = "uvue-dir-" + __uniConfig.uvue["flex-direction"];
  16548. document.body.setAttribute("uvue", "");
  16549. document.body.setAttribute(uvueDirKey, "");
  16550. }
  16551. }
  16552. function onPageShow(instance2, pageMeta) {
  16553. updateBodyScopeId(instance2);
  16554. updateCurPageCssVar(pageMeta);
  16555. updateCurPageAttrs();
  16556. initPageScrollListener(instance2, pageMeta);
  16557. }
  16558. function onPageReady(instance2) {
  16559. const scopeId = getScopeId(instance2);
  16560. scopeId && updateCurPageBodyScopeId(scopeId);
  16561. }
  16562. function updateCurPageBodyScopeId(scopeId) {
  16563. const pageBodyEl = document.querySelector("uni-page-body");
  16564. if (pageBodyEl) {
  16565. pageBodyEl.setAttribute(scopeId, "");
  16566. } else if (process.env.NODE_ENV !== "production") {
  16567. console.warn("uni-page-body not found");
  16568. }
  16569. }
  16570. function getScopeId(instance2) {
  16571. return instance2.type.__scopeId;
  16572. }
  16573. let curScopeId;
  16574. function updateBodyScopeId(instance2) {
  16575. const scopeId = getScopeId(instance2);
  16576. const { body } = document;
  16577. curScopeId && body.removeAttribute(curScopeId);
  16578. scopeId && body.setAttribute(scopeId, "");
  16579. curScopeId = scopeId;
  16580. }
  16581. let curScrollListener;
  16582. function initPageScrollListener(instance2, pageMeta) {
  16583. document.removeEventListener("touchmove", disableScrollListener);
  16584. if (curScrollListener) {
  16585. document.removeEventListener("scroll", curScrollListener);
  16586. }
  16587. if (pageMeta.disableScroll) {
  16588. return document.addEventListener("touchmove", disableScrollListener);
  16589. }
  16590. const { onPageScroll, onReachBottom } = instance2;
  16591. const navigationBarTransparent = pageMeta.navigationBar.type === "transparent";
  16592. if (!onPageScroll && !onReachBottom && !navigationBarTransparent) {
  16593. return;
  16594. }
  16595. const opts = {};
  16596. const pageId = instance2.proxy.$page.id;
  16597. if (onPageScroll || navigationBarTransparent) {
  16598. opts.onPageScroll = createOnPageScroll(
  16599. pageId,
  16600. onPageScroll,
  16601. navigationBarTransparent
  16602. );
  16603. }
  16604. if (onReachBottom) {
  16605. opts.onReachBottomDistance = pageMeta.onReachBottomDistance || ON_REACH_BOTTOM_DISTANCE;
  16606. opts.onReachBottom = () => UniViewJSBridge.publishHandler(ON_REACH_BOTTOM, {}, pageId);
  16607. }
  16608. curScrollListener = createScrollListener(opts);
  16609. requestAnimationFrame(
  16610. () => document.addEventListener("scroll", curScrollListener)
  16611. );
  16612. }
  16613. function createOnPageScroll(pageId, onPageScroll, navigationBarTransparent) {
  16614. return (scrollTop) => {
  16615. if (onPageScroll) {
  16616. UniViewJSBridge.publishHandler(ON_PAGE_SCROLL, { scrollTop }, pageId);
  16617. }
  16618. if (navigationBarTransparent) {
  16619. UniViewJSBridge.emit(pageId + "." + ON_PAGE_SCROLL, {
  16620. scrollTop
  16621. });
  16622. }
  16623. };
  16624. }
  16625. function usePopupStyle(props2) {
  16626. const popupWidth = ref(0);
  16627. const popupHeight = ref(0);
  16628. const isDesktop = computed(
  16629. () => popupWidth.value >= 500 && popupHeight.value >= 500
  16630. );
  16631. const popupStyle = computed(() => {
  16632. const style = {
  16633. content: {
  16634. transform: "",
  16635. left: "",
  16636. top: "",
  16637. bottom: ""
  16638. },
  16639. triangle: {
  16640. left: "",
  16641. top: "",
  16642. bottom: "",
  16643. "border-width": "",
  16644. "border-color": ""
  16645. }
  16646. };
  16647. const contentStyle = style.content;
  16648. const triangleStyle = style.triangle;
  16649. const popover = props2.popover;
  16650. function getNumber(value) {
  16651. return Number(value) || 0;
  16652. }
  16653. if (isDesktop.value && popover) {
  16654. extend(triangleStyle, {
  16655. position: "absolute",
  16656. width: "0",
  16657. height: "0",
  16658. "margin-left": "-6px",
  16659. "border-style": "solid"
  16660. });
  16661. const popoverLeft = getNumber(popover.left);
  16662. const popoverWidth = getNumber(popover.width);
  16663. const popoverTop = getNumber(popover.top);
  16664. const popoverHeight = getNumber(popover.height);
  16665. const center = popoverLeft + popoverWidth / 2;
  16666. contentStyle.transform = "none !important";
  16667. const contentLeft = Math.max(0, center - 300 / 2);
  16668. contentStyle.left = `${contentLeft}px`;
  16669. let triangleLeft = Math.max(12, center - contentLeft);
  16670. triangleLeft = Math.min(300 - 12, triangleLeft);
  16671. triangleStyle.left = `${triangleLeft}px`;
  16672. const vcl = popupHeight.value / 2;
  16673. if (popoverTop + popoverHeight - vcl > vcl - popoverTop) {
  16674. contentStyle.top = "auto";
  16675. contentStyle.bottom = `${popupHeight.value - popoverTop + 6}px`;
  16676. triangleStyle.bottom = "-6px";
  16677. triangleStyle["border-width"] = "6px 6px 0 6px";
  16678. triangleStyle["border-color"] = "#fcfcfd transparent transparent transparent";
  16679. } else {
  16680. contentStyle.top = `${popoverTop + popoverHeight + 6}px`;
  16681. triangleStyle.top = "-6px";
  16682. triangleStyle["border-width"] = "0 6px 6px 6px";
  16683. triangleStyle["border-color"] = "transparent transparent #fcfcfd transparent";
  16684. }
  16685. }
  16686. return style;
  16687. });
  16688. onMounted(() => {
  16689. const fixSize = () => {
  16690. const { windowWidth, windowHeight, windowTop } = uni.getSystemInfoSync();
  16691. popupWidth.value = windowWidth;
  16692. popupHeight.value = windowHeight + (windowTop || 0);
  16693. };
  16694. window.addEventListener("resize", fixSize);
  16695. fixSize();
  16696. onUnmounted(() => {
  16697. window.removeEventListener("resize", fixSize);
  16698. });
  16699. });
  16700. return {
  16701. isDesktop,
  16702. popupStyle
  16703. };
  16704. }
  16705. const KEY_MAPS = {
  16706. esc: ["Esc", "Escape"],
  16707. // tab: ['Tab'],
  16708. enter: ["Enter"]
  16709. // space: [' ', 'Spacebar'],
  16710. // up: ['Up', 'ArrowUp'],
  16711. // left: ['Left', 'ArrowLeft'],
  16712. // right: ['Right', 'ArrowRight'],
  16713. // down: ['Down', 'ArrowDown'],
  16714. // delete: ['Backspace', 'Delete', 'Del'],
  16715. };
  16716. const KEYS = Object.keys(KEY_MAPS);
  16717. function useKeyboard() {
  16718. const key = ref("");
  16719. const disable = ref(false);
  16720. const onKeyup = (evt) => {
  16721. if (disable.value) {
  16722. return;
  16723. }
  16724. const res = KEYS.find(
  16725. (key2) => KEY_MAPS[key2].indexOf(evt.key) !== -1
  16726. );
  16727. if (res) {
  16728. key.value = res;
  16729. }
  16730. nextTick(() => key.value = "");
  16731. };
  16732. onMounted(() => {
  16733. document.addEventListener("keyup", onKeyup);
  16734. });
  16735. onBeforeUnmount(() => {
  16736. document.removeEventListener("keyup", onKeyup);
  16737. });
  16738. return {
  16739. key,
  16740. disable
  16741. };
  16742. }
  16743. function IEVersion() {
  16744. const userAgent = navigator.userAgent;
  16745. const isIE = userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1;
  16746. const isEdge = userAgent.indexOf("Edge") > -1 && !isIE;
  16747. const isIE11 = userAgent.indexOf("Trident") > -1 && userAgent.indexOf("rv:11.0") > -1;
  16748. if (isIE) {
  16749. const reIE = new RegExp("MSIE (\\d+\\.\\d+);");
  16750. reIE.test(userAgent);
  16751. const fIEVersion = parseFloat(RegExp.$1);
  16752. if (fIEVersion > 6) {
  16753. return fIEVersion;
  16754. } else {
  16755. return 6;
  16756. }
  16757. } else if (isEdge) {
  16758. return -1;
  16759. } else if (isIE11) {
  16760. return 11;
  16761. } else {
  16762. return -1;
  16763. }
  16764. }
  16765. function getTheme() {
  16766. if (__uniConfig.darkmode !== true)
  16767. return isString(__uniConfig.darkmode) ? __uniConfig.darkmode : "light";
  16768. try {
  16769. return window.matchMedia("(prefers-color-scheme: light)").matches ? "light" : "dark";
  16770. } catch (error) {
  16771. return "light";
  16772. }
  16773. }
  16774. function getBrowserInfo() {
  16775. let osname;
  16776. let osversion = "0";
  16777. let model = "";
  16778. let deviceType = "phone";
  16779. const language = navigator.language;
  16780. if (isIOS$1) {
  16781. osname = "iOS";
  16782. const osversionFind = ua.match(/OS\s([\w_]+)\slike/);
  16783. if (osversionFind) {
  16784. osversion = osversionFind[1].replace(/_/g, ".");
  16785. }
  16786. const modelFind = ua.match(/\(([a-zA-Z]+);/);
  16787. if (modelFind) {
  16788. model = modelFind[1];
  16789. }
  16790. } else if (isAndroid) {
  16791. osname = "Android";
  16792. const osversionFind = ua.match(/Android[\s/]([\w\.]+)[;\s]/);
  16793. if (osversionFind) {
  16794. osversion = osversionFind[1];
  16795. }
  16796. const infoFind = ua.match(/\((.+?)\)/);
  16797. const infos = infoFind ? infoFind[1].split(";") : ua.split(" ");
  16798. const otherInfo = [
  16799. /\bAndroid\b/i,
  16800. /\bLinux\b/i,
  16801. /\bU\b/i,
  16802. /^\s?[a-z][a-z]$/i,
  16803. /^\s?[a-z][a-z]-[a-z][a-z]$/i,
  16804. /\bwv\b/i,
  16805. /\/[\d\.,]+$/,
  16806. /^\s?[\d\.,]+$/,
  16807. /\bBrowser\b/i,
  16808. /\bMobile\b/i
  16809. ];
  16810. for (let i = 0; i < infos.length; i++) {
  16811. const info = infos[i];
  16812. if (info.indexOf("Build") > 0) {
  16813. model = info.split("Build")[0].trim();
  16814. break;
  16815. }
  16816. let other;
  16817. for (let o2 = 0; o2 < otherInfo.length; o2++) {
  16818. if (otherInfo[o2].test(info)) {
  16819. other = true;
  16820. break;
  16821. }
  16822. }
  16823. if (!other) {
  16824. model = info.trim();
  16825. break;
  16826. }
  16827. }
  16828. } else if (isIPadOS) {
  16829. model = "iPad";
  16830. osname = "iOS";
  16831. deviceType = "pad";
  16832. osversion = isFunction(window.BigInt) ? "14.0" : "13.0";
  16833. } else if (isWindows || isMac || isLinux) {
  16834. model = "PC";
  16835. osname = "PC";
  16836. deviceType = "pc";
  16837. osversion = "0";
  16838. let osversionFind = ua.match(/\((.+?)\)/)[1];
  16839. if (isWindows) {
  16840. osname = "Windows";
  16841. switch (isWindows[1]) {
  16842. case "5.1":
  16843. osversion = "XP";
  16844. break;
  16845. case "6.0":
  16846. osversion = "Vista";
  16847. break;
  16848. case "6.1":
  16849. osversion = "7";
  16850. break;
  16851. case "6.2":
  16852. osversion = "8";
  16853. break;
  16854. case "6.3":
  16855. osversion = "8.1";
  16856. break;
  16857. case "10.0":
  16858. osversion = "10";
  16859. break;
  16860. }
  16861. const framework = osversionFind && osversionFind.match(/[Win|WOW]([\d]+)/);
  16862. if (framework) {
  16863. osversion += ` x${framework[1]}`;
  16864. }
  16865. } else if (isMac) {
  16866. osname = "macOS";
  16867. const _osversion = osversionFind && osversionFind.match(/Mac OS X (.+)/) || "";
  16868. if (osversion) {
  16869. osversion = _osversion[1].replace(/_/g, ".");
  16870. if (osversion.indexOf(";") !== -1) {
  16871. osversion = osversion.split(";")[0];
  16872. }
  16873. }
  16874. } else if (isLinux) {
  16875. osname = "Linux";
  16876. const _osversion = osversionFind && osversionFind.match(/Linux (.*)/) || "";
  16877. if (_osversion) {
  16878. osversion = _osversion[1];
  16879. if (osversion.indexOf(";") !== -1) {
  16880. osversion = osversion.split(";")[0];
  16881. }
  16882. }
  16883. }
  16884. } else {
  16885. osname = "Other";
  16886. osversion = "0";
  16887. deviceType = "unknown";
  16888. }
  16889. const system = `${osname} ${osversion}`;
  16890. const platform = osname.toLocaleLowerCase();
  16891. let browserName = "";
  16892. let browserVersion = String(IEVersion());
  16893. if (browserVersion !== "-1") {
  16894. browserName = "IE";
  16895. } else {
  16896. const browseVendors = ["Version", "Firefox", "Chrome", "Edge{0,1}"];
  16897. const vendors = ["Safari", "Firefox", "Chrome", "Edge"];
  16898. for (let index2 = 0; index2 < browseVendors.length; index2++) {
  16899. const vendor = browseVendors[index2];
  16900. const reg = new RegExp(`(${vendor})/(\\S*)\\b`);
  16901. if (reg.test(ua)) {
  16902. browserName = vendors[index2];
  16903. browserVersion = ua.match(reg)[2];
  16904. }
  16905. }
  16906. }
  16907. let deviceOrientation = "portrait";
  16908. const orientation = typeof window.screen.orientation === "undefined" ? window.orientation : window.screen.orientation.angle;
  16909. deviceOrientation = Math.abs(orientation) === 90 ? "landscape" : "portrait";
  16910. return {
  16911. deviceBrand: void 0,
  16912. brand: void 0,
  16913. deviceModel: model,
  16914. deviceOrientation,
  16915. model,
  16916. system,
  16917. platform,
  16918. browserName: browserName.toLocaleLowerCase(),
  16919. browserVersion,
  16920. language,
  16921. deviceType,
  16922. ua,
  16923. osname,
  16924. osversion,
  16925. theme: getTheme()
  16926. };
  16927. }
  16928. function onThemeChange$2(callback) {
  16929. if (__uniConfig.darkmode) {
  16930. UniServiceJSBridge.on(ON_THEME_CHANGE, callback);
  16931. }
  16932. }
  16933. function offThemeChange$1(callback) {
  16934. UniServiceJSBridge.off(ON_THEME_CHANGE, callback);
  16935. }
  16936. function parseTheme(pageStyle) {
  16937. let parsedStyle = {};
  16938. if (__uniConfig.darkmode) {
  16939. parsedStyle = normalizeStyles(
  16940. pageStyle,
  16941. __uniConfig.themeConfig,
  16942. getTheme()
  16943. );
  16944. }
  16945. return __uniConfig.darkmode ? parsedStyle : pageStyle;
  16946. }
  16947. function useTheme(pageStyle, onThemeChangeCallback) {
  16948. const isReactived = isReactive(pageStyle);
  16949. const reactivePageStyle = isReactived ? reactive(parseTheme(pageStyle)) : parseTheme(pageStyle);
  16950. if (__uniConfig.darkmode && isReactived) {
  16951. watch(pageStyle, (value) => {
  16952. const _pageStyle = parseTheme(value);
  16953. for (const key in _pageStyle) {
  16954. reactivePageStyle[key] = _pageStyle[key];
  16955. }
  16956. });
  16957. }
  16958. onThemeChangeCallback && onThemeChange$2(onThemeChangeCallback);
  16959. return reactivePageStyle;
  16960. }
  16961. const ACTION_SHEET_THEME = {
  16962. light: {
  16963. listItemColor: "#000000",
  16964. cancelItemColor: "#000000"
  16965. },
  16966. dark: {
  16967. listItemColor: "rgba(255, 255, 255, 0.8)",
  16968. cancelItemColor: "rgba(255, 255, 255)"
  16969. }
  16970. };
  16971. function setActionSheetTheme(theme, actionSheetTheme) {
  16972. const ActionSheetThemeKey = ["listItemColor", "cancelItemColor"];
  16973. ActionSheetThemeKey.forEach((key) => {
  16974. actionSheetTheme[key] = ACTION_SHEET_THEME[theme][key];
  16975. });
  16976. }
  16977. const props$g = {
  16978. title: {
  16979. type: String,
  16980. default: ""
  16981. },
  16982. itemList: {
  16983. type: Array,
  16984. default() {
  16985. return [];
  16986. }
  16987. },
  16988. itemColor: {
  16989. type: String,
  16990. default: "#000000"
  16991. },
  16992. popover: {
  16993. type: Object,
  16994. default: null
  16995. },
  16996. visible: {
  16997. type: Boolean,
  16998. default: false
  16999. }
  17000. };
  17001. const actionSheet = /* @__PURE__ */ defineComponent({
  17002. name: "ActionSheet",
  17003. props: props$g,
  17004. emits: ["close"],
  17005. setup(props2, {
  17006. emit: emit2
  17007. }) {
  17008. initI18nShowActionSheetMsgsOnce();
  17009. const HEIGHT = ref(260);
  17010. const contentHeight = ref(0);
  17011. const titleHeight = ref(0);
  17012. const deltaY = ref(0);
  17013. const scrollTop = ref(0);
  17014. const content = ref(null);
  17015. const main = ref(null);
  17016. const {
  17017. t: t2
  17018. } = useI18n();
  17019. const {
  17020. _close
  17021. } = useActionSheetLoader(props2, emit2);
  17022. const {
  17023. popupStyle
  17024. } = usePopupStyle(props2);
  17025. let scroller;
  17026. onMounted(() => {
  17027. const {
  17028. scroller: _scroller,
  17029. handleTouchStart,
  17030. handleTouchMove,
  17031. handleTouchEnd
  17032. } = useScroller(content.value, {
  17033. enableY: true,
  17034. friction: new Friction(1e-4),
  17035. spring: new Spring(2, 90, 20),
  17036. onScroll: (e2) => {
  17037. scrollTop.value = e2.target.scrollTop;
  17038. }
  17039. });
  17040. scroller = _scroller;
  17041. useTouchtrack(content.value, (e2) => {
  17042. if (_scroller) {
  17043. switch (e2.detail.state) {
  17044. case "start":
  17045. handleTouchStart(e2);
  17046. break;
  17047. case "move":
  17048. handleTouchMove(e2);
  17049. break;
  17050. case "end":
  17051. case "cancel":
  17052. handleTouchEnd(e2);
  17053. }
  17054. }
  17055. }, true);
  17056. });
  17057. function _handleWheel($event) {
  17058. const _deltaY = deltaY.value + $event.deltaY;
  17059. if (Math.abs(_deltaY) > 10) {
  17060. scrollTop.value += _deltaY / 3;
  17061. scrollTop.value = scrollTop.value >= contentHeight.value ? contentHeight.value : scrollTop.value <= 0 ? 0 : scrollTop.value;
  17062. scroller.scrollTo(scrollTop.value);
  17063. } else {
  17064. deltaY.value = _deltaY;
  17065. }
  17066. $event.preventDefault();
  17067. }
  17068. watch(() => props2.visible, () => {
  17069. nextTick(() => {
  17070. if (props2.title) {
  17071. titleHeight.value = document.querySelector(".uni-actionsheet__title").offsetHeight;
  17072. }
  17073. scroller.update();
  17074. if (content.value)
  17075. contentHeight.value = content.value.clientHeight - HEIGHT.value;
  17076. document.querySelectorAll(".uni-actionsheet__cell").forEach((item) => {
  17077. initClick(item);
  17078. });
  17079. });
  17080. });
  17081. const actionSheetTheme = useOnThemeChange$1(props2);
  17082. return () => {
  17083. return createVNode("uni-actionsheet", {
  17084. "onTouchmove": onEventPrevent
  17085. }, [createVNode(Transition, {
  17086. "name": "uni-fade"
  17087. }, {
  17088. default: () => [withDirectives(createVNode("div", {
  17089. "class": "uni-mask uni-actionsheet__mask",
  17090. "onClick": () => _close(-1)
  17091. }, null, 8, ["onClick"]), [[vShow, props2.visible]])]
  17092. }), createVNode("div", {
  17093. "class": ["uni-actionsheet", {
  17094. "uni-actionsheet_toggle": props2.visible
  17095. }],
  17096. "style": popupStyle.value.content
  17097. }, [createVNode("div", {
  17098. "ref": main,
  17099. "class": "uni-actionsheet__menu",
  17100. "onWheel": _handleWheel
  17101. }, [props2.title ? createVNode(Fragment, null, [createVNode("div", {
  17102. "class": "uni-actionsheet__cell",
  17103. "style": {
  17104. height: `${titleHeight.value}px`
  17105. }
  17106. }, null), createVNode("div", {
  17107. "class": "uni-actionsheet__title"
  17108. }, [props2.title])]) : "", createVNode("div", {
  17109. "style": {
  17110. maxHeight: `${HEIGHT.value}px`,
  17111. overflow: "hidden"
  17112. }
  17113. }, [createVNode("div", {
  17114. "ref": content
  17115. }, [props2.itemList.map((itemTitle, index2) => createVNode("div", {
  17116. "key": index2,
  17117. "style": {
  17118. color: actionSheetTheme.listItemColor
  17119. },
  17120. "class": "uni-actionsheet__cell",
  17121. "onClick": () => _close(index2)
  17122. }, [itemTitle], 12, ["onClick"]))], 512)])], 40, ["onWheel"]), createVNode("div", {
  17123. "class": "uni-actionsheet__action"
  17124. }, [createVNode("div", {
  17125. "style": {
  17126. color: actionSheetTheme.cancelItemColor
  17127. },
  17128. "class": "uni-actionsheet__cell",
  17129. "onClick": () => _close(-1)
  17130. }, [t2("uni.showActionSheet.cancel")], 12, ["onClick"])]), createVNode("div", {
  17131. "style": popupStyle.value.triangle
  17132. }, null, 4)], 6)], 40, ["onTouchmove"]);
  17133. };
  17134. }
  17135. });
  17136. function useActionSheetLoader(props2, emit2) {
  17137. function _close(tapIndex) {
  17138. emit2("close", tapIndex);
  17139. }
  17140. const {
  17141. key,
  17142. disable
  17143. } = useKeyboard();
  17144. watch(() => props2.visible, (value) => disable.value = !value);
  17145. watchEffect(() => {
  17146. const {
  17147. value
  17148. } = key;
  17149. if (value === "esc") {
  17150. _close && _close(-1);
  17151. }
  17152. });
  17153. return {
  17154. _close
  17155. };
  17156. }
  17157. function initClick(dom) {
  17158. const MAX_MOVE = 20;
  17159. let x = 0;
  17160. let y = 0;
  17161. dom.addEventListener("touchstart", (event) => {
  17162. const info = event.changedTouches[0];
  17163. x = info.clientX;
  17164. y = info.clientY;
  17165. });
  17166. dom.addEventListener("touchend", (event) => {
  17167. const info = event.changedTouches[0];
  17168. if (Math.abs(info.clientX - x) < MAX_MOVE && Math.abs(info.clientY - y) < MAX_MOVE) {
  17169. const target = event.target;
  17170. const currentTarget = event.currentTarget;
  17171. const customEvent = new CustomEvent("click", {
  17172. bubbles: true,
  17173. cancelable: true,
  17174. target,
  17175. currentTarget
  17176. });
  17177. ["screenX", "screenY", "clientX", "clientY", "pageX", "pageY"].forEach((key) => {
  17178. customEvent[key] = info[key];
  17179. });
  17180. event.target.dispatchEvent(customEvent);
  17181. }
  17182. });
  17183. }
  17184. function useOnThemeChange$1(props2) {
  17185. const actionSheetTheme = reactive({
  17186. listItemColor: "#000",
  17187. cancelItemColor: "#000"
  17188. });
  17189. const _onThemeChange = ({
  17190. theme
  17191. }) => {
  17192. setActionSheetTheme(theme, actionSheetTheme);
  17193. };
  17194. watchEffect(() => {
  17195. if (props2.visible) {
  17196. actionSheetTheme.listItemColor = actionSheetTheme.cancelItemColor = props2.itemColor;
  17197. if (props2.itemColor === "#000") {
  17198. _onThemeChange({
  17199. theme: getTheme()
  17200. });
  17201. onThemeChange$2(_onThemeChange);
  17202. }
  17203. } else {
  17204. offThemeChange$1(_onThemeChange);
  17205. }
  17206. });
  17207. return actionSheetTheme;
  17208. }
  17209. const VNODE_MASK = /* @__PURE__ */ createVNode(
  17210. "div",
  17211. { class: "uni-mask" },
  17212. null,
  17213. -1
  17214. /* HOISTED */
  17215. );
  17216. function createRootApp(component, rootState, callback) {
  17217. rootState.onClose = (...args) => (rootState.visible = false, callback.apply(null, args));
  17218. return createApp(
  17219. defineComponent({
  17220. setup() {
  17221. return () => (openBlock(), createBlock(
  17222. component,
  17223. rootState,
  17224. null,
  17225. 16
  17226. /* FULL_PROPS */
  17227. ));
  17228. }
  17229. })
  17230. );
  17231. }
  17232. function ensureRoot(id2) {
  17233. let rootEl = document.getElementById(id2);
  17234. if (!rootEl) {
  17235. rootEl = document.createElement("div");
  17236. rootEl.id = id2;
  17237. document.body.append(rootEl);
  17238. }
  17239. return rootEl;
  17240. }
  17241. function usePopup(props2, {
  17242. onEsc,
  17243. onEnter
  17244. }) {
  17245. const visible = ref(props2.visible);
  17246. const { key, disable } = useKeyboard();
  17247. watch(
  17248. () => props2.visible,
  17249. (value) => visible.value = value
  17250. );
  17251. watch(
  17252. () => visible.value,
  17253. (value) => disable.value = !value
  17254. );
  17255. watchEffect(() => {
  17256. const { value } = key;
  17257. if (value === "esc") {
  17258. onEsc && onEsc();
  17259. } else if (value === "enter") {
  17260. onEnter && onEnter();
  17261. }
  17262. });
  17263. return visible;
  17264. }
  17265. let resolveAction;
  17266. let rejectAction;
  17267. let showActionSheetState;
  17268. const onHidePopupOnce$1 = /* @__PURE__ */ once(() => {
  17269. UniServiceJSBridge.on(
  17270. "onHidePopup",
  17271. () => showActionSheetState.visible = false
  17272. );
  17273. });
  17274. function onActionSheetClose(tapIndex) {
  17275. if (tapIndex === -1) {
  17276. rejectAction && rejectAction("cancel");
  17277. } else {
  17278. resolveAction && resolveAction({ tapIndex });
  17279. }
  17280. }
  17281. const hideActionSheet = () => {
  17282. if (showActionSheetState) {
  17283. showActionSheetState.visible = false;
  17284. }
  17285. };
  17286. const showActionSheet = /* @__PURE__ */ defineAsyncApi(
  17287. API_SHOW_ACTION_SHEET,
  17288. (args, { resolve, reject }) => {
  17289. onHidePopupOnce$1();
  17290. resolveAction = resolve;
  17291. rejectAction = reject;
  17292. if (!showActionSheetState) {
  17293. showActionSheetState = reactive(args);
  17294. nextTick(
  17295. () => (createRootApp(
  17296. actionSheet,
  17297. showActionSheetState,
  17298. onActionSheetClose
  17299. ).mount(ensureRoot("u-s-a-s")), //下一帧执行,确保首次显示时有动画效果
  17300. nextTick(() => showActionSheetState.visible = true))
  17301. );
  17302. } else {
  17303. extend(showActionSheetState, args);
  17304. showActionSheetState.visible = true;
  17305. }
  17306. },
  17307. ShowActionSheetProtocol,
  17308. ShowActionSheetOptions
  17309. );
  17310. const ModalTheme = {
  17311. light: {
  17312. cancelColor: "#000000"
  17313. },
  17314. dark: {
  17315. cancelColor: "rgb(170, 170, 170)"
  17316. }
  17317. };
  17318. const setCancelColor = (theme, cancelColor) => cancelColor.value = ModalTheme[theme].cancelColor;
  17319. const props$f = {
  17320. title: {
  17321. type: String,
  17322. default: ""
  17323. },
  17324. content: {
  17325. type: String,
  17326. default: ""
  17327. },
  17328. showCancel: {
  17329. type: Boolean,
  17330. default: true
  17331. },
  17332. cancelText: {
  17333. type: String,
  17334. default: "Cancel"
  17335. },
  17336. cancelColor: {
  17337. type: String,
  17338. default: "#000000"
  17339. },
  17340. confirmText: {
  17341. type: String,
  17342. default: "OK"
  17343. },
  17344. confirmColor: {
  17345. type: String,
  17346. default: "#007aff"
  17347. },
  17348. visible: {
  17349. type: Boolean
  17350. },
  17351. editable: {
  17352. type: Boolean,
  17353. default: false
  17354. },
  17355. placeholderText: {
  17356. type: String,
  17357. default: ""
  17358. }
  17359. };
  17360. const modal = /* @__PURE__ */ defineComponent({
  17361. props: props$f,
  17362. setup(props2, {
  17363. emit: emit2
  17364. }) {
  17365. const editContent = ref("");
  17366. const close = () => visible.value = false;
  17367. const cancel = () => (close(), emit2("close", "cancel"));
  17368. const confirm = () => (close(), emit2("close", "confirm", editContent.value));
  17369. const visible = usePopup(props2, {
  17370. onEsc: cancel,
  17371. onEnter: () => {
  17372. !props2.editable && confirm();
  17373. }
  17374. });
  17375. const cancelColor = useOnThemeChange(props2);
  17376. return () => {
  17377. const {
  17378. title,
  17379. content,
  17380. showCancel,
  17381. confirmText,
  17382. confirmColor,
  17383. editable,
  17384. placeholderText
  17385. } = props2;
  17386. editContent.value = content;
  17387. return createVNode(Transition, {
  17388. "name": "uni-fade"
  17389. }, {
  17390. default: () => [withDirectives(createVNode("uni-modal", {
  17391. "onTouchmove": onEventPrevent
  17392. }, [VNODE_MASK, createVNode("div", {
  17393. "class": "uni-modal"
  17394. }, [title && createVNode("div", {
  17395. "class": "uni-modal__hd"
  17396. }, [createVNode("strong", {
  17397. "class": "uni-modal__title",
  17398. "textContent": title
  17399. }, null, 8, ["textContent"])]), editable ? createVNode("textarea", {
  17400. "class": "uni-modal__textarea",
  17401. "rows": "1",
  17402. "placeholder": placeholderText,
  17403. "value": content,
  17404. "onInput": (e2) => editContent.value = e2.target.value
  17405. }, null, 40, ["placeholder", "value", "onInput"]) : createVNode("div", {
  17406. "class": "uni-modal__bd",
  17407. "onTouchmovePassive": onEventStop,
  17408. "textContent": content
  17409. }, null, 40, ["onTouchmovePassive", "textContent"]), createVNode("div", {
  17410. "class": "uni-modal__ft"
  17411. }, [showCancel && createVNode("div", {
  17412. "style": {
  17413. color: cancelColor.value
  17414. },
  17415. "class": "uni-modal__btn uni-modal__btn_default",
  17416. "onClick": cancel
  17417. }, [props2.cancelText], 12, ["onClick"]), createVNode("div", {
  17418. "style": {
  17419. color: confirmColor
  17420. },
  17421. "class": "uni-modal__btn uni-modal__btn_primary",
  17422. "onClick": confirm
  17423. }, [confirmText], 12, ["onClick"])])])], 40, ["onTouchmove"]), [[vShow, visible.value]])]
  17424. });
  17425. };
  17426. }
  17427. });
  17428. function useOnThemeChange(props2) {
  17429. const cancelColor = ref(props2.cancelColor);
  17430. const _onThemeChange = ({
  17431. theme
  17432. }) => {
  17433. setCancelColor(theme, cancelColor);
  17434. };
  17435. watchEffect(() => {
  17436. if (props2.visible) {
  17437. cancelColor.value = props2.cancelColor;
  17438. if (props2.cancelColor === "#000") {
  17439. if (getTheme() === "dark")
  17440. _onThemeChange({
  17441. theme: "dark"
  17442. });
  17443. onThemeChange$2(_onThemeChange);
  17444. }
  17445. } else {
  17446. offThemeChange$1(_onThemeChange);
  17447. }
  17448. });
  17449. return cancelColor;
  17450. }
  17451. let showModalState;
  17452. const onHidePopupOnce = /* @__PURE__ */ once(() => {
  17453. UniServiceJSBridge.on("onHidePopup", () => showModalState.visible = false);
  17454. });
  17455. let currentShowModalResolve;
  17456. function onModalClose(type, content) {
  17457. const isConfirm = type === "confirm";
  17458. const res = {
  17459. confirm: isConfirm,
  17460. cancel: type === "cancel"
  17461. };
  17462. isConfirm && showModalState.editable && (res.content = content);
  17463. currentShowModalResolve && currentShowModalResolve(res);
  17464. }
  17465. const hideModal = () => {
  17466. if (showModalState) {
  17467. showModalState.visible = false;
  17468. }
  17469. };
  17470. const showModal = /* @__PURE__ */ defineAsyncApi(
  17471. API_SHOW_MODAL,
  17472. (args, { resolve }) => {
  17473. onHidePopupOnce();
  17474. currentShowModalResolve = resolve;
  17475. if (!showModalState) {
  17476. showModalState = reactive(args);
  17477. nextTick(
  17478. () => (createRootApp(modal, showModalState, onModalClose).mount(
  17479. ensureRoot("u-a-m")
  17480. ), //下一帧执行,确保首次显示时有动画效果
  17481. nextTick(() => showModalState.visible = true))
  17482. );
  17483. } else {
  17484. extend(showModalState, args);
  17485. showModalState.visible = true;
  17486. }
  17487. },
  17488. ShowModalProtocol,
  17489. ShowModalOptions
  17490. );
  17491. function initRouter(app) {
  17492. const router = createRouter(createRouterOptions());
  17493. router.beforeEach((to, from) => {
  17494. hideActionSheet();
  17495. hideModal();
  17496. uni.hideToast();
  17497. uni.hideLoading();
  17498. });
  17499. app.router = router;
  17500. app.use(router);
  17501. }
  17502. const scrollBehavior = (_to, _from, savedPosition) => {
  17503. if (savedPosition) {
  17504. return savedPosition;
  17505. }
  17506. };
  17507. function createRouterOptions() {
  17508. return {
  17509. history: initHistory(),
  17510. strict: !!__uniConfig.router.strict,
  17511. routes: __uniRoutes,
  17512. scrollBehavior
  17513. };
  17514. }
  17515. function removeCurrentPages(delta = 1) {
  17516. const keys = getCurrentPages$1();
  17517. const start = keys.length - 1;
  17518. const end = start - delta;
  17519. for (let i = start; i > end; i--) {
  17520. const page = keys[i].$page;
  17521. removePage(normalizeRouteKey(page.path, page.id), false);
  17522. }
  17523. }
  17524. function initHistory() {
  17525. let { routerBase } = __uniConfig.router;
  17526. if (routerBase === "/") {
  17527. routerBase = "";
  17528. }
  17529. const history2 = __UNI_FEATURE_ROUTER_MODE__ === "history" ? createWebHistory(routerBase) : createWebHashHistory(routerBase);
  17530. history2.listen((_to, _from, info) => {
  17531. if (info.direction === "back") {
  17532. removeCurrentPages(Math.abs(info.delta));
  17533. }
  17534. });
  17535. return history2;
  17536. }
  17537. const index$d = {
  17538. install(app) {
  17539. initApp$1(app);
  17540. initViewPlugin(app);
  17541. initServicePlugin(app);
  17542. if (!app.config.warnHandler) {
  17543. app.config.warnHandler = warnHandler;
  17544. }
  17545. if (__UNI_FEATURE_PAGES__) {
  17546. initRouter(app);
  17547. }
  17548. }
  17549. };
  17550. function warnHandler(msg, instance2, trace) {
  17551. if (instance2) {
  17552. const name = instance2.$.type.name;
  17553. if ("PageMetaHead" === name) {
  17554. return;
  17555. }
  17556. const parent = instance2.$.parent;
  17557. if (parent && parent.type.name === "PageMeta") {
  17558. return;
  17559. }
  17560. }
  17561. const warnArgs = [`[Vue warn]: ${msg}`];
  17562. if (trace.length) {
  17563. warnArgs.push(`
  17564. `, trace);
  17565. }
  17566. console.warn(...warnArgs);
  17567. }
  17568. const clazz = { class: "uni-async-loading" };
  17569. const loadingVNode = /* @__PURE__ */ createVNode(
  17570. "i",
  17571. { class: "uni-loading" },
  17572. null,
  17573. -1
  17574. /* HOISTED */
  17575. );
  17576. const AsyncLoadingComponent = /* @__PURE__ */ defineSystemComponent({
  17577. name: "AsyncLoading",
  17578. render() {
  17579. return openBlock(), createBlock("div", clazz, [loadingVNode]);
  17580. }
  17581. });
  17582. function reload() {
  17583. window.location.reload();
  17584. }
  17585. const AsyncErrorComponent = /* @__PURE__ */ defineSystemComponent({
  17586. name: "AsyncError",
  17587. setup() {
  17588. initI18nAsyncMsgsOnce();
  17589. const {
  17590. t: t2
  17591. } = useI18n();
  17592. return () => createVNode("div", {
  17593. "class": "uni-async-error",
  17594. "onClick": reload
  17595. }, [t2("uni.async.error")], 8, ["onClick"]);
  17596. }
  17597. });
  17598. let appVm;
  17599. function getApp$1() {
  17600. return appVm;
  17601. }
  17602. function initApp(vm) {
  17603. appVm = vm;
  17604. Object.defineProperty(appVm.$.ctx, "$children", {
  17605. get() {
  17606. return getCurrentPages().map((page) => page.$vm);
  17607. }
  17608. });
  17609. const app = appVm.$.appContext.app;
  17610. if (!app.component(AsyncLoadingComponent.name)) {
  17611. app.component(AsyncLoadingComponent.name, AsyncLoadingComponent);
  17612. }
  17613. if (!app.component(AsyncErrorComponent.name)) {
  17614. app.component(AsyncErrorComponent.name, AsyncErrorComponent);
  17615. }
  17616. initAppVm(appVm);
  17617. defineGlobalData(appVm);
  17618. initService();
  17619. initView();
  17620. }
  17621. function wrapperComponentSetup(comp, { clone, init: init2, setup, before }) {
  17622. if (clone) {
  17623. comp = extend({}, comp);
  17624. }
  17625. before && before(comp);
  17626. const oldSetup = comp.setup;
  17627. comp.setup = (props2, ctx) => {
  17628. const instance2 = getCurrentInstance();
  17629. init2(instance2.proxy);
  17630. const query = setup(instance2);
  17631. if (oldSetup) {
  17632. return oldSetup(query || props2, ctx);
  17633. }
  17634. };
  17635. return comp;
  17636. }
  17637. function setupComponent(comp, options) {
  17638. if (comp && (comp.__esModule || comp[Symbol.toStringTag] === "Module")) {
  17639. return wrapperComponentSetup(comp.default, options);
  17640. }
  17641. return wrapperComponentSetup(comp, options);
  17642. }
  17643. function setupWindow(comp, id2) {
  17644. return setupComponent(comp, {
  17645. init: (vm) => {
  17646. vm.$page = {
  17647. id: id2
  17648. };
  17649. },
  17650. setup(instance2) {
  17651. instance2.$pageInstance = instance2;
  17652. }
  17653. });
  17654. }
  17655. function setupPage(comp) {
  17656. if (process.env.NODE_ENV !== "production") {
  17657. comp.__mpType = "page";
  17658. }
  17659. return setupComponent(comp, {
  17660. clone: true,
  17661. // 页面组件可能会被其他地方手动引用,比如 windows 等,需要 clone 一份新的作为页面组件
  17662. init: initPage,
  17663. setup(instance2) {
  17664. instance2.$pageInstance = instance2;
  17665. const route = usePageRoute();
  17666. const query = decodedQuery(route.query);
  17667. instance2.attrs.__pageQuery = query;
  17668. instance2.proxy.$page.options = query;
  17669. instance2.proxy.options = query;
  17670. const pageMeta = usePageMeta();
  17671. onBeforeMount(() => {
  17672. onPageShow(instance2, pageMeta);
  17673. });
  17674. onMounted(() => {
  17675. onPageReady(instance2);
  17676. const { onReady } = instance2;
  17677. onReady && invokeArrayFns$1(onReady);
  17678. invokeOnTabItemTap(route);
  17679. });
  17680. onBeforeActivate(() => {
  17681. if (!instance2.__isVisible) {
  17682. onPageShow(instance2, pageMeta);
  17683. instance2.__isVisible = true;
  17684. const { onShow } = instance2;
  17685. onShow && invokeArrayFns$1(onShow);
  17686. nextTick(() => {
  17687. invokeOnTabItemTap(route);
  17688. });
  17689. }
  17690. });
  17691. onBeforeDeactivate(() => {
  17692. if (instance2.__isVisible && !instance2.__isUnload) {
  17693. instance2.__isVisible = false;
  17694. const { onHide } = instance2;
  17695. onHide && invokeArrayFns$1(onHide);
  17696. }
  17697. });
  17698. subscribeViewMethod(pageMeta.id);
  17699. onBeforeUnmount(() => {
  17700. unsubscribeViewMethod(pageMeta.id);
  17701. });
  17702. return query;
  17703. }
  17704. });
  17705. }
  17706. function setupApp(comp) {
  17707. if (process.env.NODE_ENV !== "production") {
  17708. comp.__mpType = "app";
  17709. }
  17710. return setupComponent(comp, {
  17711. init: initApp,
  17712. setup(instance2) {
  17713. const route = usePageRoute();
  17714. const onLaunch = () => {
  17715. injectAppHooks(instance2);
  17716. const { onLaunch: onLaunch2, onShow, onPageNotFound: onPageNotFound2, onError: onError2 } = instance2;
  17717. const path = route.path.slice(1);
  17718. const launchOptions2 = initLaunchOptions({
  17719. path: path || __uniRoutes[0].meta.route,
  17720. query: decodedQuery(route.query)
  17721. });
  17722. onLaunch2 && invokeArrayFns$1(onLaunch2, launchOptions2);
  17723. onShow && invokeArrayFns$1(onShow, launchOptions2);
  17724. if (__UNI_FEATURE_PAGES__) {
  17725. if (!route.matched.length) {
  17726. const pageNotFoundOptions = {
  17727. notFound: true,
  17728. openType: "appLaunch",
  17729. path: route.path,
  17730. query: {},
  17731. scene: 1001
  17732. };
  17733. onPageNotFound2 && invokeArrayFns$1(onPageNotFound2, pageNotFoundOptions);
  17734. }
  17735. }
  17736. if (onError2) {
  17737. instance2.appContext.config.errorHandler = (err) => {
  17738. invokeArrayFns$1(onError2, err);
  17739. };
  17740. }
  17741. };
  17742. if (__UNI_FEATURE_PAGES__) {
  17743. useRouter().isReady().then(onLaunch);
  17744. } else {
  17745. onBeforeMount(onLaunch);
  17746. }
  17747. onMounted(() => {
  17748. window.addEventListener(
  17749. "resize",
  17750. debounce(onResize, 50, { setTimeout, clearTimeout })
  17751. );
  17752. window.addEventListener("message", onMessage);
  17753. document.addEventListener("visibilitychange", onVisibilityChange);
  17754. onThemeChange$1();
  17755. });
  17756. return route.query;
  17757. },
  17758. before(comp2) {
  17759. comp2.mpType = "app";
  17760. const { setup } = comp2;
  17761. const render = () => {
  17762. return openBlock(), createBlock(LayoutComponent);
  17763. };
  17764. comp2.setup = (props2, ctx) => {
  17765. const res = setup && setup(props2, ctx);
  17766. return isFunction(res) ? render : res;
  17767. };
  17768. comp2.render = render;
  17769. }
  17770. });
  17771. }
  17772. function onResize() {
  17773. const { windowWidth, windowHeight, screenWidth, screenHeight } = uni.getSystemInfoSync();
  17774. const landscape = Math.abs(Number(window.orientation)) === 90;
  17775. const deviceOrientation = landscape ? "landscape" : "portrait";
  17776. UniServiceJSBridge.emit(ON_RESIZE, {
  17777. deviceOrientation,
  17778. size: {
  17779. windowWidth,
  17780. windowHeight,
  17781. screenWidth,
  17782. screenHeight
  17783. }
  17784. });
  17785. }
  17786. function onMessage(evt) {
  17787. if (isPlainObject(evt.data) && evt.data.type === WEB_INVOKE_APPSERVICE) {
  17788. UniServiceJSBridge.emit(
  17789. ON_WEB_INVOKE_APP_SERVICE,
  17790. evt.data.data,
  17791. evt.data.pageId
  17792. );
  17793. }
  17794. }
  17795. function onVisibilityChange() {
  17796. const { emit: emit2 } = UniServiceJSBridge;
  17797. if (document.visibilityState === "visible") {
  17798. emit2(ON_APP_ENTER_FOREGROUND, getEnterOptions());
  17799. } else {
  17800. emit2(ON_APP_ENTER_BACKGROUND);
  17801. }
  17802. }
  17803. function onThemeChange$1() {
  17804. let mediaQueryList = null;
  17805. try {
  17806. mediaQueryList = window.matchMedia("(prefers-color-scheme: dark)");
  17807. } catch (error) {
  17808. }
  17809. if (mediaQueryList) {
  17810. let callback = (e2) => {
  17811. UniServiceJSBridge.emit(ON_THEME_CHANGE, {
  17812. theme: e2.matches ? "dark" : "light"
  17813. });
  17814. };
  17815. if (mediaQueryList.addEventListener) {
  17816. mediaQueryList.addEventListener("change", callback);
  17817. } else {
  17818. mediaQueryList.addListener(callback);
  17819. }
  17820. }
  17821. }
  17822. function invokeOnTabItemTap(route) {
  17823. const { tabBarText, tabBarIndex, route: pagePath } = route.meta;
  17824. if (tabBarText) {
  17825. invokeHook("onTabItemTap", {
  17826. index: tabBarIndex,
  17827. text: tabBarText,
  17828. pagePath
  17829. });
  17830. }
  17831. }
  17832. function formatTime(val) {
  17833. val = val > 0 && val < Infinity ? val : 0;
  17834. const h2 = Math.floor(val / 3600);
  17835. const m = Math.floor(val % 3600 / 60);
  17836. const s = Math.floor(val % 3600 % 60);
  17837. const hStr = (h2 < 10 ? "0" : "") + h2;
  17838. const mStr = (m < 10 ? "0" : "") + m;
  17839. const sStr = (s < 10 ? "0" : "") + s;
  17840. let str = mStr + ":" + sStr;
  17841. if (hStr !== "00") {
  17842. str = hStr + ":" + str;
  17843. }
  17844. return str;
  17845. }
  17846. function useGesture(props2, videoRef, fullscreenState) {
  17847. const state2 = reactive({
  17848. gestureType: "none",
  17849. volumeOld: 0,
  17850. volumeNew: 0,
  17851. currentTimeOld: 0,
  17852. currentTimeNew: 0
  17853. });
  17854. const touchStartOrigin = {
  17855. x: 0,
  17856. y: 0
  17857. };
  17858. function onTouchstart(event) {
  17859. const toucher = event.targetTouches[0];
  17860. touchStartOrigin.x = toucher.pageX;
  17861. touchStartOrigin.y = toucher.pageY;
  17862. state2.gestureType = "none";
  17863. state2.volumeOld = 0;
  17864. state2.currentTimeOld = state2.currentTimeNew = 0;
  17865. }
  17866. function onTouchmove(event) {
  17867. function stop() {
  17868. event.stopPropagation();
  17869. event.preventDefault();
  17870. }
  17871. if (fullscreenState.fullscreen) {
  17872. stop();
  17873. }
  17874. const gestureType = state2.gestureType;
  17875. if (gestureType === "stop") {
  17876. return;
  17877. }
  17878. const toucher = event.targetTouches[0];
  17879. const pageX = toucher.pageX;
  17880. const pageY = toucher.pageY;
  17881. const origin = touchStartOrigin;
  17882. const video = videoRef.value;
  17883. if (gestureType === "progress") {
  17884. changeProgress(pageX - origin.x);
  17885. } else if (gestureType === "volume") {
  17886. changeVolume(pageY - origin.y);
  17887. }
  17888. if (gestureType !== "none") {
  17889. return;
  17890. }
  17891. if (Math.abs(pageX - origin.x) > Math.abs(pageY - origin.y)) {
  17892. if (!props2.enableProgressGesture) {
  17893. state2.gestureType = "stop";
  17894. return;
  17895. }
  17896. state2.gestureType = "progress";
  17897. state2.currentTimeOld = state2.currentTimeNew = video.currentTime;
  17898. if (!fullscreenState.fullscreen) {
  17899. stop();
  17900. }
  17901. } else {
  17902. if (!props2.pageGesture) {
  17903. state2.gestureType = "stop";
  17904. return;
  17905. }
  17906. state2.gestureType = "volume";
  17907. state2.volumeOld = video.volume;
  17908. if (!fullscreenState.fullscreen) {
  17909. stop();
  17910. }
  17911. }
  17912. }
  17913. function onTouchend(event) {
  17914. const video = videoRef.value;
  17915. if (state2.gestureType !== "none" && state2.gestureType !== "stop") {
  17916. event.stopPropagation();
  17917. event.preventDefault();
  17918. }
  17919. if (state2.gestureType === "progress" && state2.currentTimeOld !== state2.currentTimeNew) {
  17920. video.currentTime = state2.currentTimeNew;
  17921. }
  17922. state2.gestureType = "none";
  17923. }
  17924. function changeProgress(x) {
  17925. const video = videoRef.value;
  17926. const duration = video.duration;
  17927. let currentTimeNew = x / 600 * duration + state2.currentTimeOld;
  17928. if (currentTimeNew < 0) {
  17929. currentTimeNew = 0;
  17930. } else if (currentTimeNew > duration) {
  17931. currentTimeNew = duration;
  17932. }
  17933. state2.currentTimeNew = currentTimeNew;
  17934. }
  17935. function changeVolume(y) {
  17936. const video = videoRef.value;
  17937. const valueOld = state2.volumeOld;
  17938. let value;
  17939. if (typeof valueOld === "number") {
  17940. value = valueOld - y / 200;
  17941. if (value < 0) {
  17942. value = 0;
  17943. } else if (value > 1) {
  17944. value = 1;
  17945. }
  17946. video.volume = value;
  17947. state2.volumeNew = value;
  17948. }
  17949. }
  17950. return {
  17951. state: state2,
  17952. onTouchstart,
  17953. onTouchmove,
  17954. onTouchend
  17955. };
  17956. }
  17957. function useFullscreen(trigger, containerRef, videoRef, userActionState, rootRef) {
  17958. const state2 = reactive({
  17959. fullscreen: false
  17960. });
  17961. const isSafari = /^Apple/.test(navigator.vendor);
  17962. function onFullscreenChange($event, webkit) {
  17963. if (webkit && document.fullscreenEnabled) {
  17964. return;
  17965. }
  17966. emitFullscreenChange(!!(document.fullscreenElement || document.webkitFullscreenElement));
  17967. }
  17968. function emitFullscreenChange(val) {
  17969. state2.fullscreen = val;
  17970. trigger("fullscreenchange", {}, {
  17971. fullScreen: val,
  17972. direction: "vertical"
  17973. });
  17974. }
  17975. function toggleFullscreen(val) {
  17976. const root = rootRef.value;
  17977. const container = containerRef.value;
  17978. const video = videoRef.value;
  17979. let mockFullScreen;
  17980. if (val) {
  17981. if ((document.fullscreenEnabled || document.webkitFullscreenEnabled) && (!isSafari || userActionState.userAction)) {
  17982. container[document.fullscreenEnabled ? "requestFullscreen" : "webkitRequestFullscreen"]();
  17983. } else if (video.webkitEnterFullScreen) {
  17984. video.webkitEnterFullScreen();
  17985. } else {
  17986. mockFullScreen = true;
  17987. container.remove();
  17988. container.classList.add("uni-video-type-fullscreen");
  17989. document.body.appendChild(container);
  17990. }
  17991. } else {
  17992. if (document.fullscreenEnabled || document.webkitFullscreenEnabled) {
  17993. if (document.fullscreenElement) {
  17994. document.exitFullscreen();
  17995. } else if (document.webkitFullscreenElement) {
  17996. document.webkitExitFullscreen();
  17997. }
  17998. } else if (video.webkitExitFullScreen) {
  17999. video.webkitExitFullScreen();
  18000. } else {
  18001. mockFullScreen = true;
  18002. container.remove();
  18003. container.classList.remove("uni-video-type-fullscreen");
  18004. root.appendChild(container);
  18005. }
  18006. }
  18007. if (mockFullScreen) {
  18008. emitFullscreenChange(val);
  18009. }
  18010. }
  18011. function requestFullScreen() {
  18012. toggleFullscreen(true);
  18013. }
  18014. function exitFullScreen() {
  18015. toggleFullscreen(false);
  18016. }
  18017. onBeforeUnmount(exitFullScreen);
  18018. return {
  18019. state: state2,
  18020. onFullscreenChange,
  18021. emitFullscreenChange,
  18022. toggleFullscreen,
  18023. requestFullScreen,
  18024. exitFullScreen
  18025. };
  18026. }
  18027. function useVideo(props2, attrs2, trigger) {
  18028. const videoRef = ref(null);
  18029. const src = computed(() => getRealPath(props2.src));
  18030. const muted = computed(() => props2.muted === "true" || props2.muted === true);
  18031. const state2 = reactive({
  18032. start: false,
  18033. src,
  18034. playing: false,
  18035. currentTime: 0,
  18036. duration: 0,
  18037. progress: 0,
  18038. buffered: 0,
  18039. muted
  18040. });
  18041. watch(() => src.value, () => {
  18042. state2.playing = false;
  18043. state2.currentTime = 0;
  18044. });
  18045. watch(() => state2.buffered, (buffered) => {
  18046. trigger("progress", {}, {
  18047. buffered
  18048. });
  18049. });
  18050. watch(() => muted.value, (muted2) => {
  18051. const video = videoRef.value;
  18052. video.muted = muted2;
  18053. });
  18054. function onDurationChange({
  18055. target
  18056. }) {
  18057. state2.duration = target.duration;
  18058. }
  18059. function onLoadedMetadata($event) {
  18060. const initialTime = Number(props2.initialTime) || 0;
  18061. const video = $event.target;
  18062. if (initialTime > 0) {
  18063. video.currentTime = initialTime;
  18064. }
  18065. trigger("loadedmetadata", $event, {
  18066. width: video.videoWidth,
  18067. height: video.videoHeight,
  18068. duration: video.duration
  18069. });
  18070. onProgress($event);
  18071. }
  18072. function onProgress($event) {
  18073. const video = $event.target;
  18074. const buffered = video.buffered;
  18075. if (buffered.length) {
  18076. state2.buffered = buffered.end(buffered.length - 1) / video.duration * 100;
  18077. }
  18078. }
  18079. function onWaiting($event) {
  18080. trigger("waiting", $event, {});
  18081. }
  18082. function onVideoError($event) {
  18083. state2.playing = false;
  18084. trigger("error", $event, {});
  18085. }
  18086. function onPlay($event) {
  18087. state2.start = true;
  18088. state2.playing = true;
  18089. trigger("play", $event, {});
  18090. }
  18091. function onPause($event) {
  18092. state2.playing = false;
  18093. trigger("pause", $event, {});
  18094. }
  18095. function onEnded($event) {
  18096. state2.playing = false;
  18097. trigger("ended", $event, {});
  18098. }
  18099. function onTimeUpdate($event) {
  18100. const video = $event.target;
  18101. const currentTime = state2.currentTime = video.currentTime;
  18102. trigger("timeupdate", $event, {
  18103. currentTime,
  18104. duration: video.duration
  18105. });
  18106. }
  18107. function toggle() {
  18108. const video = videoRef.value;
  18109. if (state2.playing) {
  18110. video.pause();
  18111. } else {
  18112. video.play();
  18113. }
  18114. }
  18115. function play() {
  18116. const video = videoRef.value;
  18117. state2.start = true;
  18118. video.play();
  18119. }
  18120. function pause() {
  18121. const video = videoRef.value;
  18122. video.pause();
  18123. }
  18124. function seek(position) {
  18125. const video = videoRef.value;
  18126. position = Number(position);
  18127. if (typeof position === "number" && !isNaN(position)) {
  18128. video.currentTime = position;
  18129. }
  18130. }
  18131. function stop() {
  18132. seek(0);
  18133. pause();
  18134. }
  18135. function playbackRate(rate) {
  18136. const video = videoRef.value;
  18137. video.playbackRate = rate;
  18138. }
  18139. return {
  18140. videoRef,
  18141. state: state2,
  18142. play,
  18143. pause,
  18144. stop,
  18145. seek,
  18146. playbackRate,
  18147. toggle,
  18148. onDurationChange,
  18149. onLoadedMetadata,
  18150. onProgress,
  18151. onWaiting,
  18152. onVideoError,
  18153. onPlay,
  18154. onPause,
  18155. onEnded,
  18156. onTimeUpdate
  18157. };
  18158. }
  18159. function useControls(props2, videoState, seek) {
  18160. const progressRef = ref(null);
  18161. const ballRef = ref(null);
  18162. const centerPlayBtnShow = computed(() => props2.showCenterPlayBtn && !videoState.start);
  18163. const controlsVisible = ref(true);
  18164. const controlsShow = computed(() => !centerPlayBtnShow.value && props2.controls && controlsVisible.value);
  18165. const state2 = reactive({
  18166. touching: false,
  18167. controlsTouching: false,
  18168. centerPlayBtnShow,
  18169. controlsShow,
  18170. controlsVisible
  18171. });
  18172. function clickProgress(event) {
  18173. const $progress = progressRef.value;
  18174. let element = event.target;
  18175. let x = event.offsetX;
  18176. while (element && element !== $progress) {
  18177. x += element.offsetLeft;
  18178. element = element.parentNode;
  18179. }
  18180. const w = $progress.offsetWidth;
  18181. let progress = 0;
  18182. if (x >= 0 && x <= w) {
  18183. progress = x / w;
  18184. seek(videoState.duration * progress);
  18185. }
  18186. }
  18187. function toggleControls() {
  18188. state2.controlsVisible = !state2.controlsVisible;
  18189. }
  18190. let hideTiming;
  18191. function autoHideStart() {
  18192. hideTiming = setTimeout(() => {
  18193. state2.controlsVisible = false;
  18194. }, 3e3);
  18195. }
  18196. function autoHideEnd() {
  18197. if (hideTiming) {
  18198. clearTimeout(hideTiming);
  18199. hideTiming = null;
  18200. }
  18201. }
  18202. onBeforeUnmount(() => {
  18203. if (hideTiming) {
  18204. clearTimeout(hideTiming);
  18205. }
  18206. });
  18207. watch(() => state2.controlsShow && videoState.playing && !state2.controlsTouching, (val) => {
  18208. if (val) {
  18209. autoHideStart();
  18210. } else {
  18211. autoHideEnd();
  18212. }
  18213. });
  18214. watch([() => videoState.currentTime, () => {
  18215. props2.duration;
  18216. }], function updateProgress() {
  18217. if (!state2.touching) {
  18218. videoState.progress = videoState.currentTime / videoState.duration * 100;
  18219. }
  18220. });
  18221. onMounted(() => {
  18222. const passiveOptions2 = passive(false);
  18223. let originX;
  18224. let originY;
  18225. let moveOnce = true;
  18226. let originProgress;
  18227. const ball = ballRef.value;
  18228. function touchmove2(event) {
  18229. const toucher = event.targetTouches[0];
  18230. const pageX = toucher.pageX;
  18231. const pageY = toucher.pageY;
  18232. if (moveOnce && Math.abs(pageX - originX) < Math.abs(pageY - originY)) {
  18233. touchend(event);
  18234. return;
  18235. }
  18236. moveOnce = false;
  18237. const progressEl = progressRef.value;
  18238. const w = progressEl.offsetWidth;
  18239. let progress = originProgress + (pageX - originX) / w * 100;
  18240. if (progress < 0) {
  18241. progress = 0;
  18242. } else if (progress > 100) {
  18243. progress = 100;
  18244. }
  18245. videoState.progress = progress;
  18246. event.preventDefault();
  18247. event.stopPropagation();
  18248. }
  18249. function touchend(event) {
  18250. state2.controlsTouching = false;
  18251. if (state2.touching) {
  18252. ball.removeEventListener("touchmove", touchmove2, passiveOptions2);
  18253. if (!moveOnce) {
  18254. event.preventDefault();
  18255. event.stopPropagation();
  18256. seek(videoState.duration * videoState.progress / 100);
  18257. }
  18258. state2.touching = false;
  18259. }
  18260. }
  18261. ball.addEventListener("touchstart", (event) => {
  18262. state2.controlsTouching = true;
  18263. const toucher = event.targetTouches[0];
  18264. originX = toucher.pageX;
  18265. originY = toucher.pageY;
  18266. originProgress = videoState.progress;
  18267. moveOnce = true;
  18268. state2.touching = true;
  18269. ball.addEventListener("touchmove", touchmove2, passiveOptions2);
  18270. });
  18271. ball.addEventListener("touchend", touchend);
  18272. ball.addEventListener("touchcancel", touchend);
  18273. });
  18274. return {
  18275. state: state2,
  18276. progressRef,
  18277. ballRef,
  18278. clickProgress,
  18279. toggleControls,
  18280. autoHideStart,
  18281. autoHideEnd
  18282. };
  18283. }
  18284. function useDanmu(props2, videoState) {
  18285. const danmuRef = ref(null);
  18286. const state2 = reactive({
  18287. enable: Boolean(props2.enableDanmu)
  18288. });
  18289. let danmuIndex = {
  18290. time: 0,
  18291. index: -1
  18292. };
  18293. const danmuList = isArray(props2.danmuList) ? JSON.parse(JSON.stringify(props2.danmuList)) : [];
  18294. danmuList.sort(function(a2, b) {
  18295. return (a2.time || 0) - (b.time || 0);
  18296. });
  18297. function toggleDanmu() {
  18298. state2.enable = !state2.enable;
  18299. }
  18300. function updateDanmu(event) {
  18301. const video = event.target;
  18302. const currentTime = video.currentTime;
  18303. const oldDanmuIndex = danmuIndex;
  18304. const newDanmuIndex = {
  18305. time: currentTime,
  18306. index: oldDanmuIndex.index
  18307. };
  18308. if (currentTime > oldDanmuIndex.time) {
  18309. for (let index2 = oldDanmuIndex.index + 1; index2 < danmuList.length; index2++) {
  18310. const element = danmuList[index2];
  18311. if (currentTime >= (element.time || 0)) {
  18312. newDanmuIndex.index = index2;
  18313. if (videoState.playing && state2.enable) {
  18314. playDanmu(element);
  18315. }
  18316. } else {
  18317. break;
  18318. }
  18319. }
  18320. } else if (currentTime < oldDanmuIndex.time) {
  18321. for (let index2 = oldDanmuIndex.index - 1; index2 > -1; index2--) {
  18322. const element = danmuList[index2];
  18323. if (currentTime <= (element.time || 0)) {
  18324. newDanmuIndex.index = index2 - 1;
  18325. } else {
  18326. break;
  18327. }
  18328. }
  18329. }
  18330. danmuIndex = newDanmuIndex;
  18331. }
  18332. function playDanmu(danmu) {
  18333. const p2 = document.createElement("p");
  18334. p2.className = "uni-video-danmu-item";
  18335. p2.innerText = danmu.text;
  18336. let style = `bottom: ${Math.random() * 100}%;color: ${danmu.color};`;
  18337. p2.setAttribute("style", style);
  18338. const danmuEl = danmuRef.value;
  18339. danmuEl.appendChild(p2);
  18340. setTimeout(function() {
  18341. style += "left: 0;-webkit-transform: translateX(-100%);transform: translateX(-100%);";
  18342. p2.setAttribute("style", style);
  18343. setTimeout(function() {
  18344. p2.remove();
  18345. }, 4e3);
  18346. }, 17);
  18347. }
  18348. function sendDanmu(danmu) {
  18349. danmuList.splice(danmuIndex.index + 1, 0, {
  18350. text: String(danmu.text),
  18351. color: danmu.color,
  18352. time: videoState.currentTime || 0
  18353. });
  18354. }
  18355. return {
  18356. state: state2,
  18357. danmuRef,
  18358. updateDanmu,
  18359. toggleDanmu,
  18360. sendDanmu
  18361. };
  18362. }
  18363. function useContext(play, pause, stop, seek, sendDanmu, playbackRate, requestFullScreen, exitFullScreen) {
  18364. const methods = {
  18365. play,
  18366. stop,
  18367. pause,
  18368. seek,
  18369. sendDanmu,
  18370. playbackRate,
  18371. requestFullScreen,
  18372. exitFullScreen
  18373. };
  18374. const id2 = useContextInfo();
  18375. useSubscribe((type, data) => {
  18376. let options;
  18377. switch (type) {
  18378. case "seek":
  18379. options = data.position;
  18380. break;
  18381. case "sendDanmu":
  18382. options = data;
  18383. break;
  18384. case "playbackRate":
  18385. options = data.rate;
  18386. break;
  18387. }
  18388. if (type in methods) {
  18389. methods[type](options);
  18390. }
  18391. }, id2, true);
  18392. }
  18393. const props$e = {
  18394. id: {
  18395. type: String,
  18396. default: ""
  18397. },
  18398. src: {
  18399. type: String,
  18400. default: ""
  18401. },
  18402. duration: {
  18403. type: [Number, String],
  18404. default: ""
  18405. },
  18406. controls: {
  18407. type: [Boolean, String],
  18408. default: true
  18409. },
  18410. danmuList: {
  18411. type: Array,
  18412. default() {
  18413. return [];
  18414. }
  18415. },
  18416. danmuBtn: {
  18417. type: [Boolean, String],
  18418. default: false
  18419. },
  18420. enableDanmu: {
  18421. type: [Boolean, String],
  18422. default: false
  18423. },
  18424. autoplay: {
  18425. type: [Boolean, String],
  18426. default: false
  18427. },
  18428. loop: {
  18429. type: [Boolean, String],
  18430. default: false
  18431. },
  18432. muted: {
  18433. type: [Boolean, String],
  18434. default: false
  18435. },
  18436. objectFit: {
  18437. type: String,
  18438. default: "contain"
  18439. },
  18440. poster: {
  18441. type: String,
  18442. default: ""
  18443. },
  18444. direction: {
  18445. type: [String, Number],
  18446. default: ""
  18447. },
  18448. showProgress: {
  18449. type: Boolean,
  18450. default: true
  18451. },
  18452. initialTime: {
  18453. type: [String, Number],
  18454. default: 0
  18455. },
  18456. showFullscreenBtn: {
  18457. type: [Boolean, String],
  18458. default: true
  18459. },
  18460. pageGesture: {
  18461. type: [Boolean, String],
  18462. default: false
  18463. },
  18464. enableProgressGesture: {
  18465. type: [Boolean, String],
  18466. default: true
  18467. },
  18468. showPlayBtn: {
  18469. type: [Boolean, String],
  18470. default: true
  18471. },
  18472. showCenterPlayBtn: {
  18473. type: [Boolean, String],
  18474. default: true
  18475. }
  18476. };
  18477. class UniVideoElement extends UniElement {
  18478. }
  18479. const index$c = /* @__PURE__ */ defineBuiltInComponent({
  18480. name: "Video",
  18481. props: props$e,
  18482. emits: ["fullscreenchange", "progress", "loadedmetadata", "waiting", "error", "play", "pause", "ended", "timeupdate"],
  18483. rootElement: {
  18484. name: "uni-video",
  18485. class: UniVideoElement
  18486. },
  18487. setup(props2, {
  18488. emit: emit2,
  18489. attrs: attrs2,
  18490. slots
  18491. }) {
  18492. const rootRef = ref(null);
  18493. const containerRef = ref(null);
  18494. const trigger = useCustomEvent(rootRef, emit2);
  18495. const {
  18496. state: userActionState
  18497. } = useUserAction();
  18498. const {
  18499. $attrs: videoAttrs
  18500. } = useAttrs({
  18501. excludeListeners: true
  18502. });
  18503. const {
  18504. t: t2
  18505. } = useI18n();
  18506. initI18nVideoMsgsOnce();
  18507. const {
  18508. videoRef,
  18509. state: videoState,
  18510. play,
  18511. pause,
  18512. stop,
  18513. seek,
  18514. playbackRate,
  18515. toggle,
  18516. onDurationChange,
  18517. onLoadedMetadata,
  18518. onProgress,
  18519. onWaiting,
  18520. onVideoError,
  18521. onPlay,
  18522. onPause,
  18523. onEnded,
  18524. onTimeUpdate
  18525. } = useVideo(props2, attrs2, trigger);
  18526. const {
  18527. state: danmuState,
  18528. danmuRef,
  18529. updateDanmu,
  18530. toggleDanmu,
  18531. sendDanmu
  18532. } = useDanmu(props2, videoState);
  18533. const {
  18534. state: fullscreenState,
  18535. onFullscreenChange,
  18536. emitFullscreenChange,
  18537. toggleFullscreen,
  18538. requestFullScreen,
  18539. exitFullScreen
  18540. } = useFullscreen(trigger, containerRef, videoRef, userActionState, rootRef);
  18541. const {
  18542. state: gestureState,
  18543. onTouchstart,
  18544. onTouchend,
  18545. onTouchmove
  18546. } = useGesture(props2, videoRef, fullscreenState);
  18547. const {
  18548. state: controlsState,
  18549. progressRef,
  18550. ballRef,
  18551. clickProgress,
  18552. toggleControls
  18553. } = useControls(props2, videoState, seek);
  18554. useContext(play, pause, stop, seek, sendDanmu, playbackRate, requestFullScreen, exitFullScreen);
  18555. onMounted(() => {
  18556. const rootElement = rootRef.value;
  18557. Object.assign(rootElement, {
  18558. play,
  18559. pause,
  18560. stop,
  18561. seek,
  18562. sendDanmu,
  18563. playbackRate,
  18564. requestFullScreen,
  18565. exitFullScreen
  18566. });
  18567. rootElement.attachVmProps(props2);
  18568. });
  18569. return () => {
  18570. return createVNode("uni-video", {
  18571. "ref": rootRef,
  18572. "id": props2.id,
  18573. "onClick": toggleControls
  18574. }, [createVNode("div", {
  18575. "ref": containerRef,
  18576. "class": "uni-video-container",
  18577. "onTouchstart": onTouchstart,
  18578. "onTouchend": onTouchend,
  18579. "onTouchmove": onTouchmove,
  18580. "onFullscreenchange": withModifiers(onFullscreenChange, ["stop"]),
  18581. "onWebkitfullscreenchange": withModifiers(($event) => onFullscreenChange($event, true), ["stop"])
  18582. }, [createVNode("video", mergeProps({
  18583. "ref": videoRef,
  18584. "style": {
  18585. "object-fit": props2.objectFit
  18586. },
  18587. "muted": !!props2.muted,
  18588. "loop": !!props2.loop,
  18589. "src": videoState.src,
  18590. "poster": props2.poster,
  18591. "autoplay": !!props2.autoplay
  18592. }, videoAttrs.value, {
  18593. "class": "uni-video-video",
  18594. "webkit-playsinline": true,
  18595. "playsinline": true,
  18596. "onDurationchange": onDurationChange,
  18597. "onLoadedmetadata": onLoadedMetadata,
  18598. "onProgress": onProgress,
  18599. "onWaiting": onWaiting,
  18600. "onError": onVideoError,
  18601. "onPlay": onPlay,
  18602. "onPause": onPause,
  18603. "onEnded": onEnded,
  18604. "onTimeupdate": (event) => {
  18605. onTimeUpdate(event);
  18606. updateDanmu(event);
  18607. },
  18608. "onWebkitbeginfullscreen": () => emitFullscreenChange(true),
  18609. "onX5videoenterfullscreen": () => emitFullscreenChange(true),
  18610. "onWebkitendfullscreen": () => emitFullscreenChange(false),
  18611. "onX5videoexitfullscreen": () => emitFullscreenChange(false)
  18612. }), null, 16, ["muted", "loop", "src", "poster", "autoplay", "webkit-playsinline", "playsinline", "onDurationchange", "onLoadedmetadata", "onProgress", "onWaiting", "onError", "onPlay", "onPause", "onEnded", "onTimeupdate", "onWebkitbeginfullscreen", "onX5videoenterfullscreen", "onWebkitendfullscreen", "onX5videoexitfullscreen"]), withDirectives(createVNode("div", {
  18613. "class": "uni-video-bar uni-video-bar-full",
  18614. "onClick": withModifiers(() => {
  18615. }, ["stop"])
  18616. }, [createVNode("div", {
  18617. "class": "uni-video-controls"
  18618. }, [withDirectives(createVNode("div", {
  18619. "class": {
  18620. "uni-video-control-button": true,
  18621. "uni-video-control-button-play": !videoState.playing,
  18622. "uni-video-control-button-pause": videoState.playing
  18623. },
  18624. "onClick": withModifiers(toggle, ["stop"])
  18625. }, null, 10, ["onClick"]), [[vShow, props2.showPlayBtn]]), withDirectives(createVNode("div", {
  18626. "class": "uni-video-current-time"
  18627. }, [formatTime(videoState.currentTime)], 512), [[vShow, props2.showProgress]]), withDirectives(createVNode("div", {
  18628. "ref": progressRef,
  18629. "class": "uni-video-progress-container",
  18630. "onClick": withModifiers(clickProgress, ["stop"])
  18631. }, [createVNode("div", {
  18632. "class": "uni-video-progress"
  18633. }, [createVNode("div", {
  18634. "style": {
  18635. width: videoState.buffered + "%"
  18636. },
  18637. "class": "uni-video-progress-buffered"
  18638. }, null, 4), createVNode("div", {
  18639. "ref": ballRef,
  18640. "style": {
  18641. left: videoState.progress + "%"
  18642. },
  18643. "class": "uni-video-ball"
  18644. }, [createVNode("div", {
  18645. "class": "uni-video-inner"
  18646. }, null)], 4)])], 8, ["onClick"]), [[vShow, props2.showProgress]]), withDirectives(createVNode("div", {
  18647. "class": "uni-video-duration"
  18648. }, [formatTime(Number(props2.duration) || videoState.duration)], 512), [[vShow, props2.showProgress]])]), withDirectives(createVNode("div", {
  18649. "class": {
  18650. "uni-video-danmu-button": true,
  18651. "uni-video-danmu-button-active": danmuState.enable
  18652. },
  18653. "onClick": withModifiers(toggleDanmu, ["stop"])
  18654. }, [t2("uni.video.danmu")], 10, ["onClick"]), [[vShow, props2.danmuBtn]]), withDirectives(createVNode("div", {
  18655. "class": {
  18656. "uni-video-fullscreen": true,
  18657. "uni-video-type-fullscreen": fullscreenState.fullscreen
  18658. },
  18659. "onClick": withModifiers(() => toggleFullscreen(!fullscreenState.fullscreen), ["stop"])
  18660. }, null, 10, ["onClick"]), [[vShow, props2.showFullscreenBtn]])], 8, ["onClick"]), [[vShow, controlsState.controlsShow]]), withDirectives(createVNode("div", {
  18661. "ref": danmuRef,
  18662. "style": "z-index: 0;",
  18663. "class": "uni-video-danmu"
  18664. }, null, 512), [[vShow, videoState.start && danmuState.enable]]), controlsState.centerPlayBtnShow && createVNode("div", {
  18665. "class": "uni-video-cover",
  18666. "onClick": withModifiers(() => {
  18667. }, ["stop"])
  18668. }, [createVNode("div", {
  18669. "class": "uni-video-cover-play-button",
  18670. "onClick": withModifiers(play, ["stop"])
  18671. }, null, 8, ["onClick"]), createVNode("p", {
  18672. "class": "uni-video-cover-duration"
  18673. }, [formatTime(Number(props2.duration) || videoState.duration)])], 8, ["onClick"]), createVNode("div", {
  18674. "class": {
  18675. "uni-video-toast": true,
  18676. "uni-video-toast-volume": gestureState.gestureType === "volume"
  18677. }
  18678. }, [createVNode("div", {
  18679. "class": "uni-video-toast-title"
  18680. }, [t2("uni.video.volume")]), createVNode("svg", {
  18681. "class": "uni-video-toast-icon",
  18682. "width": "200px",
  18683. "height": "200px",
  18684. "viewBox": "0 0 1024 1024",
  18685. "version": "1.1",
  18686. "xmlns": "http://www.w3.org/2000/svg"
  18687. }, [createVNode("path", {
  18688. "d": "M475.400704 201.19552l0 621.674496q0 14.856192-10.856448 25.71264t-25.71264 10.856448-25.71264-10.856448l-190.273536-190.273536-149.704704 0q-14.856192 0-25.71264-10.856448t-10.856448-25.71264l0-219.414528q0-14.856192 10.856448-25.71264t25.71264-10.856448l149.704704 0 190.273536-190.273536q10.856448-10.856448 25.71264-10.856448t25.71264 10.856448 10.856448 25.71264zm219.414528 310.837248q0 43.425792-24.28416 80.851968t-64.2816 53.425152q-5.71392 2.85696-14.2848 2.85696-14.856192 0-25.71264-10.570752t-10.856448-25.998336q0-11.999232 6.856704-20.284416t16.570368-14.2848 19.427328-13.142016 16.570368-20.284416 6.856704-32.569344-6.856704-32.569344-16.570368-20.284416-19.427328-13.142016-16.570368-14.2848-6.856704-20.284416q0-15.427584 10.856448-25.998336t25.71264-10.570752q8.57088 0 14.2848 2.85696 39.99744 15.427584 64.2816 53.139456t24.28416 81.137664zm146.276352 0q0 87.422976-48.56832 161.41824t-128.5632 107.707392q-7.428096 2.85696-14.2848 2.85696-15.427584 0-26.284032-10.856448t-10.856448-25.71264q0-22.284288 22.284288-33.712128 31.997952-16.570368 43.425792-25.141248 42.283008-30.855168 65.995776-77.423616t23.712768-99.136512-23.712768-99.136512-65.995776-77.423616q-11.42784-8.57088-43.425792-25.141248-22.284288-11.42784-22.284288-33.712128 0-14.856192 10.856448-25.71264t25.71264-10.856448q7.428096 0 14.856192 2.85696 79.99488 33.712128 128.5632 107.707392t48.56832 161.41824zm146.276352 0q0 131.42016-72.566784 241.41312t-193.130496 161.989632q-7.428096 2.85696-14.856192 2.85696-14.856192 0-25.71264-10.856448t-10.856448-25.71264q0-20.570112 22.284288-33.712128 3.999744-2.285568 12.85632-5.999616t12.85632-5.999616q26.284032-14.2848 46.854144-29.140992 70.281216-51.996672 109.707264-129.705984t39.426048-165.132288-39.426048-165.132288-109.707264-129.705984q-20.570112-14.856192-46.854144-29.140992-3.999744-2.285568-12.85632-5.999616t-12.85632-5.999616q-22.284288-13.142016-22.284288-33.712128 0-14.856192 10.856448-25.71264t25.71264-10.856448q7.428096 0 14.856192 2.85696 120.563712 51.996672 193.130496 161.989632t72.566784 241.41312z"
  18689. }, null)]), createVNode("div", {
  18690. "class": "uni-video-toast-value"
  18691. }, [createVNode("div", {
  18692. "style": {
  18693. width: gestureState.volumeNew * 100 + "%"
  18694. },
  18695. "class": "uni-video-toast-value-content"
  18696. }, [createVNode("div", {
  18697. "class": "uni-video-toast-volume-grids"
  18698. }, [renderList(10, () => createVNode("div", {
  18699. "class": "uni-video-toast-volume-grids-item"
  18700. }, null))])], 4)])], 2), createVNode("div", {
  18701. "class": {
  18702. "uni-video-toast": true,
  18703. "uni-video-toast-progress": gestureState.gestureType === "progress"
  18704. }
  18705. }, [createVNode("div", {
  18706. "class": "uni-video-toast-title"
  18707. }, [formatTime(gestureState.currentTimeNew), " / ", formatTime(videoState.duration)])], 2), createVNode("div", {
  18708. "class": "uni-video-slots"
  18709. }, [slots.default && slots.default()])], 40, ["onTouchstart", "onTouchend", "onTouchmove", "onFullscreenchange", "onWebkitfullscreenchange"])], 8, ["id", "onClick"]);
  18710. };
  18711. }
  18712. });
  18713. const onWebInvokeAppService = ({ name, arg }) => {
  18714. if (name === "postMessage")
  18715. ;
  18716. else {
  18717. uni[name](arg);
  18718. }
  18719. };
  18720. const Invoke = /* @__PURE__ */ once(() => UniServiceJSBridge.on(ON_WEB_INVOKE_APP_SERVICE, onWebInvokeAppService));
  18721. const props$d = {
  18722. src: {
  18723. type: String,
  18724. default: ""
  18725. }
  18726. };
  18727. class UniWebViewElement extends UniElement {
  18728. }
  18729. const indexX = /* @__PURE__ */ defineBuiltInComponent({
  18730. inheritAttrs: false,
  18731. name: "WebView",
  18732. props: props$d,
  18733. rootElement: {
  18734. name: "uni-web-view",
  18735. class: UniWebViewElement
  18736. },
  18737. setup(props2) {
  18738. Invoke();
  18739. const rootRef = ref(null);
  18740. const iframeRef = ref(null);
  18741. const {
  18742. $attrs,
  18743. $excludeAttrs,
  18744. $listeners
  18745. } = useAttrs({
  18746. excludeListeners: true
  18747. });
  18748. const renderIframe = () => {
  18749. const iframe = document.createElement("iframe");
  18750. watchEffect(() => {
  18751. for (const key in $attrs.value) {
  18752. if (hasOwn($attrs.value, key)) {
  18753. const attr2 = $attrs.value[key];
  18754. iframe[key] = attr2;
  18755. }
  18756. }
  18757. });
  18758. watchEffect(() => {
  18759. iframe.src = getRealPath(props2.src);
  18760. });
  18761. iframeRef.value = iframe;
  18762. };
  18763. renderIframe();
  18764. onMounted(() => {
  18765. var _a;
  18766. (_a = rootRef.value) == null ? void 0 : _a.appendChild(iframeRef.value);
  18767. });
  18768. onMounted(() => {
  18769. const rootElement = rootRef.value;
  18770. rootElement.attachVmProps(props2);
  18771. });
  18772. return () => {
  18773. return createVNode("uni-web-view", mergeProps({
  18774. "class": "uni-webview"
  18775. }, $listeners.value, $excludeAttrs.value, {
  18776. "ref": rootRef
  18777. }), null, 16);
  18778. };
  18779. }
  18780. });
  18781. let index$b = 0;
  18782. function getJSONP(url, options, success, error) {
  18783. var js = document.createElement("script");
  18784. var callbackKey = options.callback || "callback";
  18785. var callbackName = "__uni_jsonp_callback_" + index$b++;
  18786. var timeout = options.timeout || 3e4;
  18787. var timing;
  18788. function end() {
  18789. clearTimeout(timing);
  18790. delete window[callbackName];
  18791. js.remove();
  18792. }
  18793. window[callbackName] = (res) => {
  18794. if (isFunction(success)) {
  18795. success(res);
  18796. }
  18797. end();
  18798. };
  18799. js.onerror = () => {
  18800. if (isFunction(error)) {
  18801. error();
  18802. }
  18803. end();
  18804. };
  18805. timing = setTimeout(function() {
  18806. if (isFunction(error)) {
  18807. error();
  18808. }
  18809. end();
  18810. }, timeout);
  18811. js.src = url + (url.indexOf("?") >= 0 ? "&" : "?") + callbackKey + "=" + callbackName;
  18812. document.body.appendChild(js);
  18813. }
  18814. function createCallout(maps2) {
  18815. function onAdd() {
  18816. const div = this.div;
  18817. const panes = this.getPanes();
  18818. panes.floatPane.appendChild(div);
  18819. }
  18820. function onRemove() {
  18821. const parentNode = this.div.parentNode;
  18822. if (parentNode) {
  18823. parentNode.removeChild(this.div);
  18824. }
  18825. }
  18826. function createAMapText() {
  18827. const option = this.option;
  18828. this.Text = new maps2.Text({
  18829. text: option.content,
  18830. anchor: "bottom-center",
  18831. // 设置文本标记锚点
  18832. offset: new maps2.Pixel(0, option.offsetY - 16),
  18833. style: {
  18834. padding: (option.padding || 8) + "px",
  18835. "line-height": (option.fontSize || 14) + "px",
  18836. "border-radius": (option.borderRadius || 0) + "px",
  18837. "border-color": `${option.bgColor || "#fff"} transparent transparent`,
  18838. "background-color": option.bgColor || "#fff",
  18839. "box-shadow": "0 2px 6px 0 rgba(114, 124, 245, .5)",
  18840. "text-align": "center",
  18841. "font-size": (option.fontSize || 14) + "px",
  18842. color: option.color || "#000"
  18843. },
  18844. position: option.position
  18845. });
  18846. const event = maps2.event || maps2.Event;
  18847. event.addListener(this.Text, "click", () => {
  18848. this.callback();
  18849. });
  18850. this.Text.setMap(option.map);
  18851. }
  18852. function createBMapText() {
  18853. }
  18854. function removeAMapText() {
  18855. if (this.Text) {
  18856. this.option.map.remove(this.Text);
  18857. }
  18858. }
  18859. function removeBMapText() {
  18860. if (this.Text) {
  18861. this.option.map.remove(this.Text);
  18862. }
  18863. }
  18864. class Callout {
  18865. constructor(option = {}, callback) {
  18866. this.createAMapText = createAMapText;
  18867. this.removeAMapText = removeAMapText;
  18868. this.createBMapText = createBMapText;
  18869. this.removeBMapText = removeBMapText;
  18870. this.onAdd = onAdd;
  18871. this.construct = onAdd;
  18872. this.onRemove = onRemove;
  18873. this.destroy = onRemove;
  18874. this.option = option || {};
  18875. const visible = this.visible = this.alwaysVisible = option.display === "ALWAYS";
  18876. if (getIsAMap()) {
  18877. this.callback = callback;
  18878. if (this.visible) {
  18879. this.createAMapText();
  18880. }
  18881. } else if (getIsBMap()) {
  18882. if (this.visible) {
  18883. this.createBMapText();
  18884. }
  18885. } else {
  18886. const map = option.map;
  18887. this.position = option.position;
  18888. this.index = 1;
  18889. const div = this.div = document.createElement("div");
  18890. const divStyle = div.style;
  18891. divStyle.position = "absolute";
  18892. divStyle.whiteSpace = "nowrap";
  18893. divStyle.transform = "translateX(-50%) translateY(-100%)";
  18894. divStyle.zIndex = "1";
  18895. divStyle.boxShadow = option.boxShadow || "none";
  18896. divStyle.display = visible ? "block" : "none";
  18897. const triangle = this.triangle = document.createElement("div");
  18898. triangle.setAttribute(
  18899. "style",
  18900. "position: absolute;white-space: nowrap;border-width: 4px;border-style: solid;border-color: #fff transparent transparent;border-image: initial;font-size: 12px;padding: 0px;background-color: transparent;width: 0px;height: 0px;transform: translate(-50%, 100%);left: 50%;bottom: 0;"
  18901. );
  18902. this.setStyle(option);
  18903. div.appendChild(triangle);
  18904. if (map) {
  18905. this.setMap(map);
  18906. }
  18907. }
  18908. }
  18909. set onclick(callback) {
  18910. this.div.onclick = callback;
  18911. }
  18912. get onclick() {
  18913. return this.div.onclick;
  18914. }
  18915. setOption(option) {
  18916. this.option = option;
  18917. if (option.display === "ALWAYS") {
  18918. this.alwaysVisible = this.visible = true;
  18919. } else {
  18920. this.alwaysVisible = false;
  18921. }
  18922. if (getIsAMap()) {
  18923. if (this.visible) {
  18924. this.createAMapText();
  18925. }
  18926. } else if (getIsBMap()) {
  18927. if (this.visible) {
  18928. this.createBMapText();
  18929. }
  18930. } else {
  18931. this.setPosition(option.position);
  18932. this.setStyle(option);
  18933. }
  18934. }
  18935. setStyle(option) {
  18936. const div = this.div;
  18937. const divStyle = div.style;
  18938. div.innerText = option.content || "";
  18939. divStyle.lineHeight = (option.fontSize || 14) + "px";
  18940. divStyle.fontSize = (option.fontSize || 14) + "px";
  18941. divStyle.padding = (option.padding || 8) + "px";
  18942. divStyle.color = option.color || "#000";
  18943. divStyle.borderRadius = (option.borderRadius || 0) + "px";
  18944. divStyle.backgroundColor = option.bgColor || "#fff";
  18945. divStyle.marginTop = "-" + ((option.top || 0) + 5) + "px";
  18946. this.triangle.style.borderColor = `${option.bgColor || "#fff"} transparent transparent`;
  18947. }
  18948. setPosition(position) {
  18949. this.position = position;
  18950. this.draw();
  18951. }
  18952. draw() {
  18953. const overlayProjection = this.getProjection();
  18954. if (!this.position || !this.div || !overlayProjection) {
  18955. return;
  18956. }
  18957. const pixel = overlayProjection.fromLatLngToDivPixel(
  18958. this.position
  18959. );
  18960. const divStyle = this.div.style;
  18961. divStyle.left = pixel.x + "px";
  18962. divStyle.top = pixel.y + "px";
  18963. }
  18964. changed() {
  18965. const divStyle = this.div.style;
  18966. divStyle.display = this.visible ? "block" : "none";
  18967. }
  18968. }
  18969. if (!getIsAMap() && !getIsBMap()) {
  18970. const overlay = new (maps2.OverlayView || maps2.Overlay)();
  18971. Callout.prototype.setMap = overlay.setMap;
  18972. Callout.prototype.getMap = overlay.getMap;
  18973. Callout.prototype.getPanes = overlay.getPanes;
  18974. Callout.prototype.getProjection = overlay.getProjection;
  18975. Callout.prototype.map_changed = overlay.map_changed;
  18976. Callout.prototype.set = overlay.set;
  18977. Callout.prototype.get = overlay.get;
  18978. Callout.prototype.setOptions = overlay.setValues;
  18979. Callout.prototype.bindTo = overlay.bindTo;
  18980. Callout.prototype.bindsTo = overlay.bindsTo;
  18981. Callout.prototype.notify = overlay.notify;
  18982. Callout.prototype.setValues = overlay.setValues;
  18983. Callout.prototype.unbind = overlay.unbind;
  18984. Callout.prototype.unbindAll = overlay.unbindAll;
  18985. Callout.prototype.addListener = overlay.addListener;
  18986. }
  18987. return Callout;
  18988. }
  18989. let maps;
  18990. const callbacksMap = {};
  18991. const GOOGLE_MAP_CALLBACKNAME = "__map_callback__";
  18992. function loadMaps(libraries, callback) {
  18993. const mapInfo = getMapInfo();
  18994. if (!mapInfo.key) {
  18995. console.error("Map key not configured.");
  18996. return;
  18997. }
  18998. const callbacks2 = callbacksMap[mapInfo.type] = callbacksMap[mapInfo.type] || [];
  18999. if (maps) {
  19000. callback(maps);
  19001. } else if (window[mapInfo.type] && window[mapInfo.type].maps) {
  19002. maps = getIsAMap() || getIsBMap() ? window[mapInfo.type] : window[mapInfo.type].maps;
  19003. maps.Callout = maps.Callout || createCallout(maps);
  19004. callback(maps);
  19005. } else if (callbacks2.length) {
  19006. callbacks2.push(callback);
  19007. } else {
  19008. callbacks2.push(callback);
  19009. const globalExt = window;
  19010. const callbackName = GOOGLE_MAP_CALLBACKNAME + mapInfo.type;
  19011. globalExt[callbackName] = function() {
  19012. delete globalExt[callbackName];
  19013. maps = getIsAMap() || getIsBMap() ? window[mapInfo.type] : window[mapInfo.type].maps;
  19014. maps.Callout = createCallout(maps);
  19015. callbacks2.forEach((callback2) => callback2(maps));
  19016. callbacks2.length = 0;
  19017. };
  19018. if (getIsAMap()) {
  19019. handleAMapSecurityPolicy(mapInfo);
  19020. }
  19021. const script = document.createElement("script");
  19022. let src = getScriptBaseUrl(mapInfo.type);
  19023. if (mapInfo.type === MapType.QQ) {
  19024. libraries.push("geometry");
  19025. }
  19026. if (libraries.length) {
  19027. src += `libraries=${libraries.join("%2C")}&`;
  19028. }
  19029. if (mapInfo.type === MapType.BMAP) {
  19030. script.src = `${src}ak=${mapInfo.key}&callback=${callbackName}`;
  19031. } else {
  19032. script.src = `${src}key=${mapInfo.key}&callback=${callbackName}`;
  19033. }
  19034. script.onerror = function() {
  19035. console.error("Map load failed.");
  19036. };
  19037. document.body.appendChild(script);
  19038. }
  19039. }
  19040. const getScriptBaseUrl = (mapType) => {
  19041. const urlMap = {
  19042. qq: "https://map.qq.com/api/js?v=2.exp&",
  19043. google: "https://maps.googleapis.com/maps/api/js?",
  19044. AMap: "https://webapi.amap.com/maps?v=2.0&",
  19045. BMapGL: "https://api.map.baidu.com/api?type=webgl&v=1.0&"
  19046. };
  19047. return urlMap[mapType];
  19048. };
  19049. function handleAMapSecurityPolicy(mapInfo) {
  19050. window._AMapSecurityConfig = {
  19051. securityJsCode: mapInfo.securityJsCode || "",
  19052. serviceHost: mapInfo.serviceHost || ""
  19053. };
  19054. }
  19055. const ICON_PATH_LOCTAION = "M13.3334375 16 q0.033125 1.1334375 0.783125 1.8834375 q0.75 0.75 1.8834375 0.75 q1.1334375 0 1.8834375 -0.75 q0.75 -0.75 0.75 -1.8834375 q0 -1.1334375 -0.75 -1.8834375 q-0.75 -0.75 -1.8834375 -0.75 q-1.1334375 0 -1.8834375 0.75 q-0.75 0.75 -0.783125 1.8834375 ZM30.9334375 14.9334375 l-1.1334375 0 q-0.5 -5.2 -4.0165625 -8.716875 q-3.516875 -3.5165625 -8.716875 -4.0165625 l0 -1.1334375 q0 -0.4665625 -0.3 -0.7665625 q-0.3 -0.3 -0.7665625 -0.3 q-0.4665625 0 -0.7665625 0.3 q-0.3 0.3 -0.3 0.7665625 l0 1.1334375 q-5.2 0.5 -8.716875 4.0165625 q-3.5165625 3.516875 -4.0165625 8.716875 l-1.1334375 0 q-0.4665625 0 -0.7665625 0.3 q-0.3 0.3 -0.3 0.7665625 q0 0.4665625 0.3 0.7665625 q0.3 0.3 0.7665625 0.3 l1.1334375 0 q0.5 5.2 4.0165625 8.716875 q3.516875 3.5165625 8.716875 4.0165625 l0 1.1334375 q0 0.4665625 0.3 0.7665625 q0.3 0.3 0.7665625 0.3 q0.4665625 0 0.7665625 -0.3 q0.3 -0.3 0.3 -0.7665625 l0 -1.1334375 q5.2 -0.5 8.716875 -4.0165625 q3.5165625 -3.516875 4.0165625 -8.716875 l1.1334375 0 q0.4665625 0 0.7665625 -0.3 q0.3 -0.3 0.3 -0.7665625 q0 -0.4665625 -0.3 -0.7665625 q-0.3 -0.3 -0.7665625 -0.3 ZM17.0665625 27.6665625 l0 -2.0665625 q0 -0.4665625 -0.3 -0.7665625 q-0.3 -0.3 -0.7665625 -0.3 q-0.4665625 0 -0.7665625 0.3 q-0.3 0.3 -0.3 0.7665625 l0 2.0665625 q-4.3 -0.4665625 -7.216875 -3.383125 q-2.916875 -2.916875 -3.3834375 -7.216875 l2.0665625 0 q0.4665625 0 0.7665625 -0.3 q0.3 -0.3 0.3 -0.7665625 q0 -0.4665625 -0.3 -0.7665625 q-0.3 -0.3 -0.7665625 -0.3 l-2.0665625 0 q0.4665625 -4.3 3.3834375 -7.216875 q2.9165625 -2.916875 7.216875 -3.3834375 l0 2.0665625 q0 0.4665625 0.3 0.7665625 q0.3 0.3 0.7665625 0.3 q0.4665625 0 0.7665625 -0.3 q0.3 -0.3 0.3 -0.7665625 l0 -2.0665625 q4.3 0.4665625 7.216875 3.3834375 q2.9165625 2.9165625 3.383125 7.216875 l-2.0665625 0 q-0.4665625 0 -0.7665625 0.3 q-0.3 0.3 -0.3 0.7665625 q0 0.4665625 0.3 0.7665625 q0.3 0.3 0.7665625 0.3 l2.0665625 0 q-0.4665625 4.3 -3.383125 7.216875 q-2.916875 2.9165625 -7.216875 3.383125 Z";
  19056. const ICON_PATH_ORIGIN = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIQAAACECAMAAABmmnOVAAAC01BMVEUAAAAAef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef96quGStdqStdpbnujMzMzCyM7Gyc7Ky83MzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMwAef8GfP0yjfNWnOp0qOKKsdyYt9mju9aZt9mMstx1qeJYnekyjvIIfP0qivVmouaWttnMzMyat9lppOUujPQKffxhoOfNzc3Y2Njh4eHp6enu7u7y8vL19fXv7+/i4uLZ2dnOzs6auNgOf/sKff15quHR0dHx8fH9/f3////j4+N6quFdn+iywdPb29vw8PD+/v7c3NyywtLa2tr29vbS0tLd3d38/Pzf39/o6Ojc7f+q0v+HwP9rsf9dqv9Hnv9Vpv/q6urj8P+Vx/9Am/8Pgf8Iff/z8/OAvP95uf/n5+c5l//V6f+52v+y1//7+/vt7e0rkP/09PTQ0NDq9P8Whf+cy//W1tbe3t7A3v/m5ubs7OxOov/r6+vk5OQiaPjKAAAAknRSTlMACBZ9oB71/jiqywJBZATT6hBukRXv+zDCAVrkDIf4JbQsTb7eVeJLbwfa8Rh4G/OlPS/6/kxQ9/xdmZudoJxNVhng7B6wtWdzAtQOipcF1329wS44doK/BAkyP1pvgZOsrbnGXArAg34G2IsD1eMRe7bi7k5YnqFT9V0csyPedQyYD3p/Fje+hDpskq/MwpRBC6yKp2MAAAQdSURBVHja7Zn1exMxGIAPHbrhDsPdneHuNtzd3d3dIbjLh93o2o4i7TpgG1Jk0g0mMNwd/gTa5rq129reHnK5e/bk/TFNk/dJ7r5894XjGAwGg8GgTZasCpDIll1+hxw5vXLJLpEboTx5ZXbIhyzkl9fB28cqUaCgrBKFkI3CcjoUKYolihWXUSI7EihRUjaHXF52CVRKLoe8eZIdUOkyMknkRw6UlcehYAFHiXK+skgURk6Ul8OhQjFnCVRRBolKqRxQ5SzUHaqgNGSj7VCmalqJnDkoS5RF6ZCbroNvufQkUD6qEuXTdUA+3hQdqiEXVKfnUKOmK4latalJ1EEuoZZ6162HJ9x/4OChw0eOHj12/MTJU6dxG7XUu751tjNnz4ET5y9ctLZTSr0beKFLl89bpuUDrqgC1RqNWqsKuqqzNFw7e51S6u3tc+OmZUJ9kCHY6ECwOkRvab51iUrqXej2HYDQsHBjWgx3Ae7dppB6N2wEcF9jdMGDUIDGTaR2aNoM9FqjG7QmaN5CWgc/gIePjG559BigpZQOrYB/4jBfRGRUtDkmJjY6KjLCofkpD62lc2gDfMpWPIuLdwyV8XEpHgaddBZ+wBuSFcwJqSN2ovmZ/dfnOvCTxqGtwzq8SEjv4EhISn48eWgnhUP7DvDSvgzxrs6vV6+FLiro2EkCic4QKkzwJsH1KYreCp0eQhfyDl1B/w4P/xa5JVJ4U03QjbRD9x7wXlgH5IE3wmMBHXoSlugFAcI6f/AkkSi8q6HQm6xDn77wEQ8djTwSj3tqAMguRTe4ikeOQyJ4YV+KfkQl+oNW5GbY4gWOWgbwJ+kwAD6Fi90MK2ZsrIeBBCUGwRXbqJ+/iJMQliIEBhOU6AJhtlG/IpHE2bqrYQg5h6HA4yQiRqwEfkGCdTCMmMRw+IbPDCQaHCsCYAQxiZHw3TbmD/ESOHgHwShiEqPhp/gggYkSztIxxCRawy/bmEniJaJtfwiEscQkxkFgRqJESqQwwHhiEuMBp3Vm8RK/cZoHEzKXhCK2QxEPpiJe0YlKCFaKCNv/cYBNUsBRPlkJSc0U+dM7E9H0ThGJbgZT/iR7yj+VqMS06Qr4+OFm2JdCxIa8lugzkJs5K6MfxAaYPUcBpYG5khZJEkUUSb7DPCnKRfPBXj6M8FwuegoLpCgXcQszVjhbJFUJUee2hBhLoYTIcYtB57KY+opSMdVqwatSlZVj05aV//CwJLMX2DluaUcwhXm4ali2XOoLjxUrPV26zFtF4f5p0Gp310+z13BUWNvbehEXona6iAtX/zVZmtfN4WixfsNky4S6gCCVVq3RPLdfSfpv3MRRZfPoLc6Xs/5bt3EyMGzE9h07/Xft2t15z6i9+zgGg8FgMBgMBoPBYDAYDAYj8/APG67Rie8pUDsAAAAASUVORK5CYII=";
  19057. const ICON_PATH_TARGET = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGAAAACcCAMAAAC3Fl5oAAAB3VBMVEVMaXH/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/EhL/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/Dw//AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/GRn/NTX/Dw//Fhb/AAD/AAD/AAD/GRn/GRn/Y2P/AAD/AAD/ExP/Ghr/AAD/AAD/MzP/GRn/AAD/Hh7/AAD/RUX/AAD/AAD/AAD/AAD/AAD/AAD/Dg7/AAD/HR3/Dw//FRX/SUn/AAD/////kJD/DQ3/Zmb/+/v/wMD/mJj/6en/vb3/1NT//Pz/ODj/+fn/3Nz/nJz/j4//9/f/7e3/9vb/7Oz/2Nj/x8f/Ozv/+Pj/3d3/nZ3/2dn//f3/6Oj/2tr/v7//09P/vr7/mZn/l5cdSvP3AAAAe3RSTlMAAhLiZgTb/vztB/JMRhlp6lQW86g8mQ4KFPs3UCH5U8huwlesWtTYGI7RsdVeJGfTW5rxnutLsvXWF8vQNdo6qQbuz7D4hgVIx2xtw8GC1TtZaIw0i84P98tU0/fsj7PKaAgiZZxeVfo8Z52eg1P0nESrENnjXVPUgw/uuSmDAAADsUlEQVR42u3aZ3cTRxgF4GtbYleSLdnGcsENG2ODjbExEHrvhAQCIb1Bem+QdkeuuFMNBBJIfmuOckzZI8/srHYmH3Lm+QNXK632LTvQ03Tu/IWeU/tTGTKT2n+q58L5c00wpXJd47DHEt5w47pKxLbhdLdPKb/7dBYxVLxw1GcI/2h1BcpzKNFHLX2JQ4gumaiitqpEEhEdOMJI9h5AFC3feYzI+7IF2tpSLEOqDXpObPRYFm/jCWho/4Ble7MdoT7fzhhq9yHEz28wltU1UPrJZ0wd66HwicfYvEFIfePTAP8tSLTupBHvtGJFH9bSkNrNWEHzERrT34xSH9Ogr1CijkbVAUH1KRqVqkdQAw07iIAaGlcTqI+/0LjeJJ5J0IIEnkpXMdzs4sTtW9dnZq7fuj2xOMtwVWk88RHDjBYejYvnjD8qjOpfQsUqhvj7oSjxcJIhVj3pyKqpNjYvVjQ/RrXq5YABKi3MCYm5BSrtWO5v11DlmlC4RpU1WRS9SJU7QukOVbpQ9JLu549+Dd0AUOlTbkGEuk85vxLAK5QbuytC3R2j3HoAjZSbFxrmKTcCoJdSk0LLJKV6gSaPMqNTQsvUKGW8JrxKqUWhaZFSeWyh1LTQNE2pHF6mzOy40DQ+S5mLimJcENoKlOnBWsr8KbRNUGYt5LXgd6HtD3lNQIoyN4S2G5RJIUOZm0LbTcqsBqVmhLYZSlkPsP4VWf+Rrd+m1v9o9h8Vv5p42C1R5qL1x7WRglOgVN52yfwNOBu76P+lLPoYidu23KPciIHGa07ZeIW1jvcNtI7q5vexCPGYCmf+m/Y9a3sAwQ5bI9T7ukPgPcn9GToEao+xk1OixJT+GIsvNAbx6eAgPq0xiF+KtkpYKhRXCQ8eFFcJhSWGu3rZ8jJkCM8kz9K4TUnrC6mAgzTsB9tLwQ2W15qfosQ2GrQNpZr7aczbzVjBZsvLcaC1g0bsbIVEnU8DOr6H1KDH2LwtUBi0/JII6Dxm9zUXkH+XMWzfh1Dte1i2Pe3QkC77Zel7aehpO8wyHG6Dtt0NjKxhN6I4uSli/TqJiJJDUQ4NDCURXTrXRy1XcumyD24M+AzhD1RXIIZsl/LoyZmurJHDM7s8lvB2FQ/PmPJ6PseAXP5HGMYAAC7ABbgAF+ACXIALcAEuwAW4ABfgAlyAC3ABLsAFuID/d8Cx4NEt8/byOf0wLnis8zjMq9/Kp7bWw4JOj8u8TlhRl+G/Mp2wpOX48GffvvZ1CyL4B53LAS6zb08EAAAAAElFTkSuQmCC";
  19058. var MapType = /* @__PURE__ */ ((MapType2) => {
  19059. MapType2["QQ"] = "qq";
  19060. MapType2["GOOGLE"] = "google";
  19061. MapType2["AMAP"] = "AMap";
  19062. MapType2["BMAP"] = "BMapGL";
  19063. MapType2["UNKNOWN"] = "";
  19064. return MapType2;
  19065. })(MapType || {});
  19066. function getMapInfo() {
  19067. if (__uniConfig.bMapKey) {
  19068. return {
  19069. type: "BMapGL",
  19070. key: __uniConfig.bMapKey
  19071. };
  19072. }
  19073. if (__uniConfig.qqMapKey) {
  19074. return {
  19075. type: "qq",
  19076. key: __uniConfig.qqMapKey
  19077. };
  19078. }
  19079. if (__uniConfig.googleMapKey) {
  19080. return {
  19081. type: "google",
  19082. key: __uniConfig.googleMapKey
  19083. };
  19084. }
  19085. if (__uniConfig.aMapKey) {
  19086. return {
  19087. type: "AMap",
  19088. key: __uniConfig.aMapKey,
  19089. securityJsCode: __uniConfig.aMapSecurityJsCode,
  19090. serviceHost: __uniConfig.aMapServiceHost
  19091. };
  19092. }
  19093. return {
  19094. type: "",
  19095. key: ""
  19096. };
  19097. }
  19098. let IS_AMAP = false;
  19099. let hasGetIsAMap = false;
  19100. const getIsAMap = () => {
  19101. if (hasGetIsAMap) {
  19102. return IS_AMAP;
  19103. } else {
  19104. hasGetIsAMap = true;
  19105. return IS_AMAP = getMapInfo().type === "AMap";
  19106. }
  19107. };
  19108. const getIsBMap = () => {
  19109. return getMapInfo().type === "BMapGL";
  19110. };
  19111. function translateCoordinateSystem(type, coords, skip) {
  19112. const mapInfo = getMapInfo();
  19113. const wgs84Map = [
  19114. "google"
  19115. /* GOOGLE */
  19116. ];
  19117. if (type && type.toUpperCase() === "WGS84" || wgs84Map.includes(mapInfo.type) || skip) {
  19118. return Promise.resolve(coords);
  19119. }
  19120. if (mapInfo.type === "qq") {
  19121. return new Promise((resolve) => {
  19122. getJSONP(
  19123. `https://apis.map.qq.com/jsapi?qt=translate&type=1&points=${coords.longitude},${coords.latitude}&key=${mapInfo.key}&output=jsonp&pf=jsapi&ref=jsapi`,
  19124. {
  19125. callback: "cb"
  19126. },
  19127. (res) => {
  19128. if ("detail" in res && "points" in res.detail && res.detail.points.length) {
  19129. const { lng, lat } = res.detail.points[0];
  19130. resolve({
  19131. longitude: lng,
  19132. latitude: lat,
  19133. altitude: coords.altitude,
  19134. accuracy: coords.accuracy,
  19135. altitudeAccuracy: coords.altitudeAccuracy,
  19136. heading: coords.heading,
  19137. speed: coords.speed
  19138. });
  19139. } else {
  19140. resolve(coords);
  19141. }
  19142. },
  19143. () => resolve(coords)
  19144. );
  19145. });
  19146. }
  19147. if (mapInfo.type === "AMap") {
  19148. return new Promise((resolve) => {
  19149. loadMaps([], () => {
  19150. window.AMap.convertFrom(
  19151. [coords.longitude, coords.latitude],
  19152. "gps",
  19153. (_, res) => {
  19154. if (res.info === "ok" && res.locations.length) {
  19155. const { lat, lng } = res.locations[0];
  19156. resolve({
  19157. longitude: lng,
  19158. latitude: lat,
  19159. altitude: coords.altitude,
  19160. accuracy: coords.accuracy,
  19161. altitudeAccuracy: coords.altitudeAccuracy,
  19162. heading: coords.heading,
  19163. speed: coords.speed
  19164. });
  19165. } else {
  19166. resolve(coords);
  19167. }
  19168. }
  19169. );
  19170. });
  19171. });
  19172. }
  19173. return Promise.reject(new Error("translate coordinate system faild"));
  19174. }
  19175. const props$c = {
  19176. id: {
  19177. type: [Number, String],
  19178. default: ""
  19179. },
  19180. latitude: {
  19181. type: [Number, String],
  19182. require: true
  19183. },
  19184. longitude: {
  19185. type: [Number, String],
  19186. require: true
  19187. },
  19188. title: {
  19189. type: String,
  19190. default: ""
  19191. },
  19192. iconPath: {
  19193. type: String,
  19194. require: true
  19195. },
  19196. rotate: {
  19197. type: [Number, String],
  19198. default: 0
  19199. },
  19200. alpha: {
  19201. type: [Number, String],
  19202. default: 1
  19203. },
  19204. width: {
  19205. type: [Number, String],
  19206. default: ""
  19207. },
  19208. height: {
  19209. type: [Number, String],
  19210. default: ""
  19211. },
  19212. callout: {
  19213. type: Object,
  19214. default: null
  19215. },
  19216. label: {
  19217. type: Object,
  19218. default: null
  19219. },
  19220. anchor: {
  19221. type: Object,
  19222. default: null
  19223. },
  19224. clusterId: {
  19225. type: [Number, String],
  19226. default: ""
  19227. },
  19228. customCallout: {
  19229. type: Object,
  19230. default: null
  19231. },
  19232. ariaLabel: {
  19233. type: String,
  19234. default: ""
  19235. }
  19236. };
  19237. function useMarkerLabelStyle(id2) {
  19238. const className = "uni-map-marker-label-" + id2;
  19239. const styleEl = document.createElement("style");
  19240. styleEl.id = className;
  19241. document.head.appendChild(styleEl);
  19242. onUnmounted(() => {
  19243. styleEl.remove();
  19244. });
  19245. return function updateMarkerLabelStyle(style) {
  19246. const newStyle = Object.assign({}, style, {
  19247. position: "absolute",
  19248. top: "70px",
  19249. borderStyle: "solid"
  19250. });
  19251. const div = document.createElement("div");
  19252. Object.keys(newStyle).forEach((key) => {
  19253. div.style[key] = newStyle[key] || "";
  19254. });
  19255. styleEl.innerText = `.${className}{${div.getAttribute("style")}}`;
  19256. return className;
  19257. };
  19258. }
  19259. const MapMarker = /* @__PURE__ */ defineSystemComponent({
  19260. name: "MapMarker",
  19261. props: props$c,
  19262. setup(props2) {
  19263. const id2 = String(!isNaN(Number(props2.id)) ? props2.id : "");
  19264. const onMapReady = inject("onMapReady");
  19265. const updateMarkerLabelStyle = useMarkerLabelStyle(id2);
  19266. let marker;
  19267. function removeMarker() {
  19268. if (marker) {
  19269. if (marker.label && "setMap" in marker.label) {
  19270. marker.label.setMap(null);
  19271. }
  19272. if (marker.callout) {
  19273. removeMarkerCallout(marker.callout);
  19274. }
  19275. marker.setMap(null);
  19276. }
  19277. }
  19278. function removeMarkerCallout(callout) {
  19279. if (getIsAMap()) {
  19280. callout.removeAMapText();
  19281. } else {
  19282. callout.setMap(null);
  19283. }
  19284. }
  19285. onMapReady((map, maps2, trigger) => {
  19286. function updateMarker(option) {
  19287. const title = option.title;
  19288. let position;
  19289. if (getIsAMap()) {
  19290. position = new maps2.LngLat(option.longitude, option.latitude);
  19291. } else if (getIsBMap()) {
  19292. position = new maps2.Point(option.longitude, option.latitude);
  19293. } else {
  19294. position = new maps2.LatLng(option.latitude, option.longitude);
  19295. }
  19296. const img = new Image();
  19297. let imgHeight = 0;
  19298. img.onload = () => {
  19299. const anchor = option.anchor || {};
  19300. let icon;
  19301. let w;
  19302. let h2;
  19303. let top;
  19304. let x = typeof anchor.x === "number" ? anchor.x : 0.5;
  19305. let y = typeof anchor.y === "number" ? anchor.y : 1;
  19306. if (option.iconPath && (option.width || option.height)) {
  19307. w = option.width || img.width / img.height * option.height;
  19308. h2 = option.height || img.height / img.width * option.width;
  19309. } else {
  19310. w = img.width / 2;
  19311. h2 = img.height / 2;
  19312. }
  19313. imgHeight = h2;
  19314. top = h2 - (h2 - y * h2);
  19315. if ("MarkerImage" in maps2) {
  19316. icon = new maps2.MarkerImage(img.src, null, null, new maps2.Point(x * w, y * h2), new maps2.Size(w, h2));
  19317. } else if ("Icon" in maps2) {
  19318. icon = new maps2.Icon({
  19319. image: img.src,
  19320. size: new maps2.Size(w, h2),
  19321. imageSize: new maps2.Size(w, h2),
  19322. imageOffset: new maps2.Pixel(x * w, y * h2)
  19323. });
  19324. } else {
  19325. icon = {
  19326. url: img.src,
  19327. anchor: new maps2.Point(x, y),
  19328. size: new maps2.Size(w, h2)
  19329. };
  19330. }
  19331. if (getIsBMap()) {
  19332. marker = new maps2.Marker(new maps2.Point(position.lng, position.lat));
  19333. map.addOverlay(marker);
  19334. } else {
  19335. marker.setPosition(position);
  19336. marker.setIcon(icon);
  19337. }
  19338. if ("setRotation" in marker) {
  19339. marker.setRotation(option.rotate || 0);
  19340. }
  19341. const labelOpt = option.label || {};
  19342. if ("label" in marker) {
  19343. marker.label.setMap(null);
  19344. delete marker.label;
  19345. }
  19346. let label;
  19347. if (labelOpt.content) {
  19348. const labelStyle = {
  19349. borderColor: labelOpt.borderColor,
  19350. borderWidth: (Number(labelOpt.borderWidth) || 0) + "px",
  19351. padding: (Number(labelOpt.padding) || 0) + "px",
  19352. borderRadius: (Number(labelOpt.borderRadius) || 0) + "px",
  19353. backgroundColor: labelOpt.bgColor,
  19354. color: labelOpt.color,
  19355. fontSize: (labelOpt.fontSize || 14) + "px",
  19356. lineHeight: (labelOpt.fontSize || 14) + "px",
  19357. marginLeft: (Number(labelOpt.anchorX || labelOpt.x) || 0) + "px",
  19358. marginTop: (Number(labelOpt.anchorY || labelOpt.y) || 0) + "px"
  19359. };
  19360. if ("Label" in maps2) {
  19361. label = new maps2.Label({
  19362. position,
  19363. map,
  19364. clickable: false,
  19365. content: labelOpt.content,
  19366. style: labelStyle
  19367. });
  19368. marker.label = label;
  19369. } else if ("setLabel" in marker) {
  19370. if (getIsAMap()) {
  19371. const content = `<div style="
  19372. margin-left:${labelStyle.marginLeft};
  19373. margin-top:${labelStyle.marginTop};
  19374. padding:${labelStyle.padding};
  19375. background-color:${labelStyle.backgroundColor};
  19376. border-radius:${labelStyle.borderRadius};
  19377. line-height:${labelStyle.lineHeight};
  19378. color:${labelStyle.color};
  19379. font-size:${labelStyle.fontSize};
  19380. ">
  19381. ${labelOpt.content}
  19382. <div>`;
  19383. marker.setLabel({
  19384. content,
  19385. direction: "bottom-right"
  19386. });
  19387. } else {
  19388. const className = updateMarkerLabelStyle(labelStyle);
  19389. marker.setLabel({
  19390. text: labelOpt.content,
  19391. color: labelStyle.color,
  19392. fontSize: labelStyle.fontSize,
  19393. className
  19394. });
  19395. }
  19396. }
  19397. }
  19398. const calloutOpt = option.callout || {};
  19399. let callout = marker.callout;
  19400. let calloutStyle;
  19401. if (calloutOpt.content || title) {
  19402. if (getIsAMap() && calloutOpt.content) {
  19403. calloutOpt.content = calloutOpt.content.replaceAll("\n", "<br/>");
  19404. }
  19405. const boxShadow = "0px 0px 3px 1px rgba(0,0,0,0.5)";
  19406. let offsetY = -imgHeight / 2;
  19407. if (option.width || option.height) {
  19408. offsetY += 14 - imgHeight / 2;
  19409. }
  19410. calloutStyle = calloutOpt.content ? {
  19411. position,
  19412. map,
  19413. top,
  19414. // handle AMap callout offset
  19415. offsetY,
  19416. content: calloutOpt.content,
  19417. color: calloutOpt.color,
  19418. fontSize: calloutOpt.fontSize,
  19419. borderRadius: calloutOpt.borderRadius,
  19420. bgColor: calloutOpt.bgColor,
  19421. padding: calloutOpt.padding,
  19422. boxShadow: calloutOpt.boxShadow || boxShadow,
  19423. display: calloutOpt.display
  19424. } : {
  19425. position,
  19426. map,
  19427. top,
  19428. // handle AMap callout offset
  19429. offsetY,
  19430. content: title,
  19431. boxShadow
  19432. };
  19433. if (callout) {
  19434. callout.setOption(calloutStyle);
  19435. } else {
  19436. if (getIsAMap()) {
  19437. const callback = (id3) => {
  19438. if (id3 !== "") {
  19439. trigger("callouttap", {}, {
  19440. markerId: Number(id3)
  19441. });
  19442. }
  19443. };
  19444. callout = marker.callout = new maps2.Callout(calloutStyle, callback);
  19445. } else {
  19446. callout = marker.callout = new maps2.Callout(calloutStyle);
  19447. callout.div.onclick = function($event) {
  19448. if (id2 !== "") {
  19449. trigger("callouttap", $event, {
  19450. markerId: Number(id2)
  19451. });
  19452. }
  19453. $event.stopPropagation();
  19454. $event.preventDefault();
  19455. };
  19456. if (getMapInfo().type === MapType.GOOGLE) {
  19457. callout.div.ontouchstart = function($event) {
  19458. $event.stopPropagation();
  19459. };
  19460. callout.div.onpointerdown = function($event) {
  19461. $event.stopPropagation();
  19462. };
  19463. }
  19464. }
  19465. }
  19466. } else {
  19467. if (callout) {
  19468. removeMarkerCallout(callout);
  19469. delete marker.callout;
  19470. }
  19471. }
  19472. };
  19473. if (option.iconPath) {
  19474. img.src = getRealPath(option.iconPath);
  19475. } else {
  19476. console.error("Marker.iconPath is required.");
  19477. }
  19478. }
  19479. function addMarker(props3) {
  19480. if (!getIsBMap()) {
  19481. marker = new maps2.Marker({
  19482. map,
  19483. flat: true,
  19484. autoRotation: false
  19485. });
  19486. }
  19487. updateMarker(props3);
  19488. const MapsEvent = maps2.event || maps2.Event;
  19489. if (getIsBMap())
  19490. ;
  19491. else {
  19492. MapsEvent.addListener(marker, "click", () => {
  19493. const callout = marker.callout;
  19494. if (callout && !callout.alwaysVisible) {
  19495. if (getIsAMap()) {
  19496. callout.visible = !callout.visible;
  19497. if (callout.visible) {
  19498. marker.callout.createAMapText();
  19499. } else {
  19500. marker.callout.removeAMapText();
  19501. }
  19502. } else {
  19503. callout.set("visible", !callout.visible);
  19504. if (callout.visible) {
  19505. const div = callout.div;
  19506. const parent = div.parentNode;
  19507. parent.removeChild(div);
  19508. parent.appendChild(div);
  19509. }
  19510. }
  19511. }
  19512. if (id2) {
  19513. trigger("markertap", {}, {
  19514. markerId: Number(id2),
  19515. latitude: props3.latitude,
  19516. longitude: props3.longitude
  19517. });
  19518. }
  19519. });
  19520. }
  19521. }
  19522. addMarker(props2);
  19523. watch(props2, updateMarker);
  19524. });
  19525. if (id2) {
  19526. const addMapChidlContext = inject("addMapChidlContext");
  19527. const removeMapChidlContext = inject("removeMapChidlContext");
  19528. const context = {
  19529. id: id2,
  19530. translate(data) {
  19531. onMapReady((map, maps2, trigger) => {
  19532. const destination = data.destination;
  19533. const duration = data.duration;
  19534. const autoRotate = !!data.autoRotate;
  19535. let rotate = Number(data.rotate) || 0;
  19536. let rotation = 0;
  19537. if ("getRotation" in marker) {
  19538. rotation = marker.getRotation();
  19539. }
  19540. const a2 = marker.getPosition();
  19541. const b = new maps2.LatLng(destination.latitude, destination.longitude);
  19542. const distance2 = maps2.geometry.spherical.computeDistanceBetween(a2, b) / 1e3;
  19543. const time = (typeof duration === "number" ? duration : 1e3) / (1e3 * 60 * 60);
  19544. const speed = distance2 / time;
  19545. const MapsEvent = maps2.event || maps2.Event;
  19546. const movingEvent = MapsEvent.addListener(marker, "moving", (e2) => {
  19547. const latLng = e2.latLng;
  19548. const label = marker.label;
  19549. if (label) {
  19550. label.setPosition(latLng);
  19551. }
  19552. const callout = marker.callout;
  19553. if (callout) {
  19554. callout.setPosition(latLng);
  19555. }
  19556. });
  19557. const event = MapsEvent.addListener(marker, "moveend", () => {
  19558. event.remove();
  19559. movingEvent.remove();
  19560. marker.lastPosition = a2;
  19561. marker.setPosition(b);
  19562. const label = marker.label;
  19563. if (label) {
  19564. label.setPosition(b);
  19565. }
  19566. const callout = marker.callout;
  19567. if (callout) {
  19568. callout.setPosition(b);
  19569. }
  19570. const cb = data.animationEnd;
  19571. if (isFunction(cb)) {
  19572. cb();
  19573. }
  19574. });
  19575. let lastRtate = 0;
  19576. if (autoRotate) {
  19577. if (marker.lastPosition) {
  19578. lastRtate = maps2.geometry.spherical.computeHeading(marker.lastPosition, a2);
  19579. }
  19580. rotate = maps2.geometry.spherical.computeHeading(a2, b) - lastRtate;
  19581. }
  19582. if ("setRotation" in marker) {
  19583. marker.setRotation(rotation + rotate);
  19584. }
  19585. if ("moveTo" in marker) {
  19586. marker.moveTo(b, speed);
  19587. } else {
  19588. marker.setPosition(b);
  19589. MapsEvent.trigger(marker, "moveend", {});
  19590. }
  19591. });
  19592. }
  19593. };
  19594. addMapChidlContext(context);
  19595. onUnmounted(() => removeMapChidlContext(context));
  19596. }
  19597. onUnmounted(removeMarker);
  19598. return () => {
  19599. return null;
  19600. };
  19601. }
  19602. });
  19603. function hexToRgba(hex) {
  19604. if (!hex) {
  19605. return {
  19606. r: 0,
  19607. g: 0,
  19608. b: 0,
  19609. a: 0
  19610. };
  19611. }
  19612. let tmpHex = hex.slice(1);
  19613. const tmpHexLen = tmpHex.length;
  19614. if (![3, 4, 6, 8].includes(tmpHexLen)) {
  19615. return {
  19616. r: 0,
  19617. g: 0,
  19618. b: 0,
  19619. a: 0
  19620. };
  19621. }
  19622. if (tmpHexLen === 3 || tmpHexLen === 4) {
  19623. tmpHex = tmpHex.replace(/(\w{1})/g, "$1$1");
  19624. }
  19625. let [sr, sg, sb, sa] = tmpHex.match(/(\w{2})/g);
  19626. const r = parseInt(sr, 16), g2 = parseInt(sg, 16), b = parseInt(sb, 16);
  19627. if (!sa) {
  19628. return { r, g: g2, b, a: 1 };
  19629. }
  19630. return {
  19631. r,
  19632. g: g2,
  19633. b,
  19634. a: (`0x100${sa}` - 65536) / 255
  19635. };
  19636. }
  19637. const props$b = {
  19638. points: {
  19639. type: Array,
  19640. require: true
  19641. },
  19642. color: {
  19643. type: String,
  19644. default: "#000000"
  19645. },
  19646. width: {
  19647. type: [Number, String],
  19648. default: ""
  19649. },
  19650. dottedLine: {
  19651. type: [Boolean, String],
  19652. default: false
  19653. },
  19654. arrowLine: {
  19655. type: [Boolean, String],
  19656. default: false
  19657. },
  19658. arrowIconPath: {
  19659. type: String,
  19660. default: ""
  19661. },
  19662. borderColor: {
  19663. type: String,
  19664. default: "#000000"
  19665. },
  19666. borderWidth: {
  19667. type: [Number, String],
  19668. default: ""
  19669. },
  19670. colorList: {
  19671. type: Array,
  19672. default() {
  19673. return [];
  19674. }
  19675. },
  19676. level: {
  19677. type: String,
  19678. default: ""
  19679. }
  19680. };
  19681. const MapPolyline = /* @__PURE__ */ defineSystemComponent({
  19682. name: "MapPolyline",
  19683. props: props$b,
  19684. setup(props2) {
  19685. const onMapReady = inject("onMapReady");
  19686. let polyline;
  19687. let polylineBorder;
  19688. function removePolyline() {
  19689. if (polyline) {
  19690. polyline.setMap(null);
  19691. }
  19692. if (polylineBorder) {
  19693. polylineBorder.setMap(null);
  19694. }
  19695. }
  19696. onMapReady((map, maps2) => {
  19697. function updatePolyline(option) {
  19698. removePolyline();
  19699. addPolyline(option);
  19700. }
  19701. function addPolyline(option) {
  19702. const path = [];
  19703. option.points.forEach((point) => {
  19704. let pointPosition;
  19705. if (getIsAMap()) {
  19706. pointPosition = [point.longitude, point.latitude];
  19707. } else if (getIsBMap()) {
  19708. pointPosition = new maps2.Point(point.longitude, point.latitude);
  19709. } else {
  19710. pointPosition = new maps2.LatLng(point.latitude, point.longitude);
  19711. }
  19712. path.push(pointPosition);
  19713. });
  19714. const strokeWeight = Number(option.width) || 1;
  19715. const {
  19716. r: sr,
  19717. g: sg,
  19718. b: sb,
  19719. a: sa
  19720. } = hexToRgba(option.color);
  19721. const {
  19722. r: br,
  19723. g: bg,
  19724. b: bb,
  19725. a: ba
  19726. } = hexToRgba(option.borderColor);
  19727. const polylineOptions = {
  19728. map,
  19729. clickable: false,
  19730. path,
  19731. strokeWeight,
  19732. strokeColor: option.color || void 0,
  19733. strokeDashStyle: option.dottedLine ? "dash" : "solid"
  19734. };
  19735. const borderWidth = Number(option.borderWidth) || 0;
  19736. const polylineBorderOptions = {
  19737. map,
  19738. clickable: false,
  19739. path,
  19740. strokeWeight: strokeWeight + borderWidth * 2,
  19741. strokeColor: option.borderColor || void 0,
  19742. strokeDashStyle: option.dottedLine ? "dash" : "solid"
  19743. };
  19744. if ("Color" in maps2) {
  19745. polylineOptions.strokeColor = new maps2.Color(sr, sg, sb, sa);
  19746. polylineBorderOptions.strokeColor = new maps2.Color(br, bg, bb, ba);
  19747. } else {
  19748. polylineOptions.strokeColor = `rgb(${sr}, ${sg}, ${sb})`;
  19749. polylineOptions.strokeOpacity = sa;
  19750. polylineBorderOptions.strokeColor = `rgb(${br}, ${bg}, ${bb})`;
  19751. polylineBorderOptions.strokeOpacity = ba;
  19752. }
  19753. if (borderWidth) {
  19754. polylineBorder = new maps2.Polyline(polylineBorderOptions);
  19755. }
  19756. if (getIsBMap()) {
  19757. polyline = new maps2.Polyline(polylineOptions.path, polylineOptions);
  19758. map.addOverlay(polyline);
  19759. } else {
  19760. polyline = new maps2.Polyline(polylineOptions);
  19761. }
  19762. }
  19763. addPolyline(props2);
  19764. watch(props2, updatePolyline);
  19765. });
  19766. onUnmounted(removePolyline);
  19767. return () => {
  19768. return null;
  19769. };
  19770. }
  19771. });
  19772. const props$a = {
  19773. latitude: {
  19774. type: [Number, String],
  19775. require: true
  19776. },
  19777. longitude: {
  19778. type: [Number, String],
  19779. require: true
  19780. },
  19781. color: {
  19782. type: String,
  19783. default: "#000000"
  19784. },
  19785. fillColor: {
  19786. type: String,
  19787. default: "#00000000"
  19788. },
  19789. radius: {
  19790. type: [Number, String],
  19791. require: true
  19792. },
  19793. strokeWidth: {
  19794. type: [Number, String],
  19795. default: ""
  19796. },
  19797. level: {
  19798. type: String,
  19799. default: ""
  19800. }
  19801. };
  19802. const MapCircle = /* @__PURE__ */ defineSystemComponent({
  19803. name: "MapCircle",
  19804. props: props$a,
  19805. setup(props2) {
  19806. const onMapReady = inject("onMapReady");
  19807. let circle;
  19808. function removeCircle() {
  19809. if (circle) {
  19810. circle.setMap(null);
  19811. }
  19812. }
  19813. onMapReady((map, maps2) => {
  19814. function updateCircle(option) {
  19815. removeCircle();
  19816. addCircle(option);
  19817. }
  19818. function addCircle(option) {
  19819. const center = getIsAMap() || getIsBMap() ? [option.longitude, option.latitude] : new maps2.LatLng(option.latitude, option.longitude);
  19820. const circleOptions = {
  19821. map,
  19822. center,
  19823. clickable: false,
  19824. radius: option.radius,
  19825. strokeWeight: Number(option.strokeWidth) || 1,
  19826. strokeDashStyle: "solid"
  19827. };
  19828. if (getIsBMap()) {
  19829. circleOptions.strokeColor = option.color;
  19830. circleOptions.fillColor = option.fillColor || "#000";
  19831. circleOptions.fillOpacity = 1;
  19832. } else {
  19833. const {
  19834. r: fr,
  19835. g: fg,
  19836. b: fb,
  19837. a: fa
  19838. } = hexToRgba(option.fillColor);
  19839. const {
  19840. r: sr,
  19841. g: sg,
  19842. b: sb,
  19843. a: sa
  19844. } = hexToRgba(option.color);
  19845. if ("Color" in maps2) {
  19846. circleOptions.fillColor = new maps2.Color(fr, fg, fb, fa);
  19847. circleOptions.strokeColor = new maps2.Color(sr, sg, sb, sa);
  19848. } else {
  19849. circleOptions.fillColor = `rgb(${fr}, ${fg}, ${fb})`;
  19850. circleOptions.fillOpacity = fa;
  19851. circleOptions.strokeColor = `rgb(${sr}, ${sg}, ${sb})`;
  19852. circleOptions.strokeOpacity = sa;
  19853. }
  19854. }
  19855. if (getIsBMap()) {
  19856. let pt = new maps2.Point(
  19857. // @ts-ignore
  19858. circleOptions.center[0],
  19859. // @ts-ignore
  19860. circleOptions.center[1]
  19861. );
  19862. circle = new maps2.Circle(pt, circleOptions.radius, circleOptions);
  19863. map.addOverlay(circle);
  19864. } else {
  19865. circle = new maps2.Circle(circleOptions);
  19866. if (getIsAMap()) {
  19867. map.add(circle);
  19868. }
  19869. }
  19870. }
  19871. addCircle(props2);
  19872. watch(props2, updateCircle);
  19873. });
  19874. onUnmounted(removeCircle);
  19875. return () => {
  19876. return null;
  19877. };
  19878. }
  19879. });
  19880. const props$9 = {
  19881. id: {
  19882. type: [Number, String],
  19883. default: ""
  19884. },
  19885. position: {
  19886. type: Object,
  19887. required: true
  19888. },
  19889. iconPath: {
  19890. type: String,
  19891. required: true
  19892. },
  19893. clickable: {
  19894. type: [Boolean, String],
  19895. default: ""
  19896. },
  19897. trigger: {
  19898. type: Function,
  19899. required: true
  19900. }
  19901. };
  19902. const MapControl = /* @__PURE__ */ defineSystemComponent({
  19903. name: "MapControl",
  19904. props: props$9,
  19905. setup(props2) {
  19906. const imgPath = computed(() => getRealPath(props2.iconPath));
  19907. const positionStyle = computed(() => {
  19908. let positionStyle2 = `top:${props2.position.top || 0}px;left:${props2.position.left || 0}px;`;
  19909. if (props2.position.width) {
  19910. positionStyle2 += `width:${props2.position.width}px;`;
  19911. }
  19912. if (props2.position.height) {
  19913. positionStyle2 += `height:${props2.position.height}px;`;
  19914. }
  19915. return positionStyle2;
  19916. });
  19917. const handleClick = ($event) => {
  19918. if (props2.clickable) {
  19919. props2.trigger("controltap", $event, {
  19920. controlId: props2.id
  19921. });
  19922. }
  19923. };
  19924. return () => {
  19925. return createVNode("div", {
  19926. "class": "uni-map-control"
  19927. }, [createVNode("img", {
  19928. "src": imgPath.value,
  19929. "style": positionStyle.value,
  19930. "class": "uni-map-control-icon",
  19931. "onClick": handleClick
  19932. }, null, 12, ["src", "onClick"])]);
  19933. };
  19934. }
  19935. });
  19936. const initInnerAudioContextEventOnce = /* @__PURE__ */ once(() => {
  19937. innerAudioContextEventNames.forEach((eventName) => {
  19938. InnerAudioContext.prototype[eventName] = function(callback) {
  19939. if (isFunction(callback)) {
  19940. this._events[eventName].push(callback);
  19941. }
  19942. };
  19943. });
  19944. innerAudioContextOffEventNames.forEach((eventName) => {
  19945. InnerAudioContext.prototype[eventName] = function(callback) {
  19946. var handle = this._events[eventName.replace("off", "on")];
  19947. var index2 = handle.indexOf(callback);
  19948. if (index2 >= 0) {
  19949. handle.splice(index2, 1);
  19950. }
  19951. };
  19952. });
  19953. });
  19954. class InnerAudioContext {
  19955. /**
  19956. * 音频上下文初始化
  19957. */
  19958. constructor() {
  19959. this._src = "";
  19960. var audio = this._audio = new Audio();
  19961. this._stoping = false;
  19962. const propertys = [
  19963. "src",
  19964. "autoplay",
  19965. "loop",
  19966. "duration",
  19967. "currentTime",
  19968. "paused",
  19969. "volume"
  19970. ];
  19971. propertys.forEach((property) => {
  19972. Object.defineProperty(this, property, {
  19973. set: property === "src" ? (src) => {
  19974. audio.src = getRealPath(src);
  19975. this._src = src;
  19976. return src;
  19977. } : (val) => {
  19978. audio[property] = val;
  19979. return val;
  19980. },
  19981. get: property === "src" ? () => {
  19982. return this._src;
  19983. } : () => {
  19984. return audio[property];
  19985. }
  19986. });
  19987. });
  19988. this.startTime = 0;
  19989. Object.defineProperty(this, "obeyMuteSwitch", {
  19990. set: () => false,
  19991. get: () => false
  19992. });
  19993. Object.defineProperty(this, "buffered", {
  19994. get() {
  19995. var buffered = audio.buffered;
  19996. if (buffered.length) {
  19997. return buffered.end(buffered.length - 1);
  19998. } else {
  19999. return 0;
  20000. }
  20001. }
  20002. });
  20003. this._events = {};
  20004. innerAudioContextEventNames.forEach((eventName) => {
  20005. this._events[eventName] = [];
  20006. });
  20007. audio.addEventListener("loadedmetadata", () => {
  20008. var startTime = Number(this.startTime) || 0;
  20009. if (startTime > 0) {
  20010. audio.currentTime = startTime;
  20011. }
  20012. });
  20013. var stopEventNames = ["canplay", "pause", "seeking", "seeked", "timeUpdate"];
  20014. var eventNames = stopEventNames.concat([
  20015. "play",
  20016. "ended",
  20017. "error",
  20018. "waiting"
  20019. ]);
  20020. eventNames.forEach((eventName) => {
  20021. audio.addEventListener(
  20022. eventName.toLowerCase(),
  20023. () => {
  20024. if (this._stoping && stopEventNames.indexOf(eventName) >= 0) {
  20025. return;
  20026. }
  20027. const EventName = `on${eventName.slice(0, 1).toUpperCase()}${eventName.slice(1)}`;
  20028. this._events[EventName].forEach((callback) => {
  20029. callback();
  20030. });
  20031. },
  20032. false
  20033. );
  20034. });
  20035. initInnerAudioContextEventOnce();
  20036. }
  20037. /**
  20038. * 播放
  20039. */
  20040. play() {
  20041. this._stoping = false;
  20042. this._audio.play();
  20043. }
  20044. /**
  20045. * 暂停
  20046. */
  20047. pause() {
  20048. this._audio.pause();
  20049. }
  20050. /**
  20051. * 停止
  20052. */
  20053. stop() {
  20054. this._stoping = true;
  20055. this._audio.pause();
  20056. this._audio.currentTime = 0;
  20057. this._events.onStop.forEach((callback) => {
  20058. callback();
  20059. });
  20060. }
  20061. /**
  20062. * 跳转到
  20063. * @param {number} position
  20064. */
  20065. seek(position) {
  20066. this._stoping = false;
  20067. position = Number(position);
  20068. if (typeof position === "number" && !isNaN(position)) {
  20069. this._audio.currentTime = position;
  20070. }
  20071. }
  20072. /**
  20073. * 销毁
  20074. */
  20075. destroy() {
  20076. this.stop();
  20077. }
  20078. }
  20079. const createInnerAudioContext = /* @__PURE__ */ defineSyncApi(
  20080. API_CREATE_INNER_AUDIO_CONTEXT,
  20081. () => {
  20082. return new InnerAudioContext();
  20083. }
  20084. );
  20085. const makePhoneCall = /* @__PURE__ */ defineAsyncApi(
  20086. API_MAKE_PHONE_CALL,
  20087. ({ phoneNumber }, { resolve }) => {
  20088. window.location.href = `tel:${phoneNumber}`;
  20089. return resolve();
  20090. },
  20091. MakePhoneCallProtocol
  20092. );
  20093. const UUID_KEY = "__DC_STAT_UUID";
  20094. const storage = navigator.cookieEnabled && (window.localStorage || window.sessionStorage) || {};
  20095. let deviceId;
  20096. function deviceId$1() {
  20097. deviceId = deviceId || storage[UUID_KEY];
  20098. if (!deviceId) {
  20099. deviceId = Date.now() + "" + Math.floor(Math.random() * 1e7);
  20100. try {
  20101. storage[UUID_KEY] = deviceId;
  20102. } catch (error) {
  20103. }
  20104. }
  20105. return deviceId;
  20106. }
  20107. const getWindowInfo = /* @__PURE__ */ defineSyncApi(
  20108. "getWindowInfo",
  20109. () => {
  20110. const pixelRatio2 = window.devicePixelRatio;
  20111. const screenFix = getScreenFix();
  20112. const landscape = isLandscape(screenFix);
  20113. const screenWidth = getScreenWidth(screenFix, landscape);
  20114. const screenHeight = getScreenHeight(screenFix, landscape);
  20115. const windowWidth = getWindowWidth(screenWidth);
  20116. let windowHeight = window.innerHeight;
  20117. const statusBarHeight = safeAreaInsets$1.top;
  20118. const safeArea = {
  20119. left: safeAreaInsets$1.left,
  20120. right: windowWidth - safeAreaInsets$1.right,
  20121. top: safeAreaInsets$1.top,
  20122. bottom: windowHeight - safeAreaInsets$1.bottom,
  20123. width: windowWidth - safeAreaInsets$1.left - safeAreaInsets$1.right,
  20124. height: windowHeight - safeAreaInsets$1.top - safeAreaInsets$1.bottom
  20125. };
  20126. const { top: windowTop, bottom: windowBottom } = getWindowOffset();
  20127. windowHeight -= windowTop;
  20128. windowHeight -= windowBottom;
  20129. return {
  20130. windowTop,
  20131. windowBottom,
  20132. windowWidth,
  20133. windowHeight,
  20134. pixelRatio: pixelRatio2,
  20135. screenWidth,
  20136. screenHeight,
  20137. statusBarHeight,
  20138. safeArea,
  20139. safeAreaInsets: {
  20140. top: safeAreaInsets$1.top,
  20141. right: safeAreaInsets$1.right,
  20142. bottom: safeAreaInsets$1.bottom,
  20143. left: safeAreaInsets$1.left
  20144. },
  20145. screenTop: screenHeight - windowHeight
  20146. };
  20147. }
  20148. );
  20149. let browserInfo;
  20150. let _initBrowserInfo = true;
  20151. function initBrowserInfo() {
  20152. if (!_initBrowserInfo)
  20153. return;
  20154. browserInfo = getBrowserInfo();
  20155. }
  20156. const getDeviceInfo = /* @__PURE__ */ defineSyncApi(
  20157. "getDeviceInfo",
  20158. () => {
  20159. initBrowserInfo();
  20160. const {
  20161. deviceBrand,
  20162. deviceModel,
  20163. brand,
  20164. model,
  20165. platform,
  20166. system,
  20167. deviceOrientation,
  20168. deviceType
  20169. } = browserInfo;
  20170. return {
  20171. brand,
  20172. deviceBrand,
  20173. deviceModel,
  20174. devicePixelRatio: window.devicePixelRatio,
  20175. deviceId: deviceId$1(),
  20176. deviceOrientation,
  20177. deviceType,
  20178. model,
  20179. platform,
  20180. system
  20181. };
  20182. }
  20183. );
  20184. const getAppBaseInfo = /* @__PURE__ */ defineSyncApi(
  20185. "getAppBaseInfo",
  20186. () => {
  20187. initBrowserInfo();
  20188. const { theme, language, browserName, browserVersion } = browserInfo;
  20189. return {
  20190. appId: __uniConfig.appId,
  20191. appName: __uniConfig.appName,
  20192. appVersion: __uniConfig.appVersion,
  20193. appVersionCode: __uniConfig.appVersionCode,
  20194. appLanguage: getLocale ? getLocale() : language,
  20195. enableDebug: false,
  20196. hostSDKVersion: void 0,
  20197. hostPackageName: void 0,
  20198. hostFontSizeSetting: void 0,
  20199. hostName: browserName,
  20200. hostVersion: browserVersion,
  20201. hostTheme: theme,
  20202. hostLanguage: language,
  20203. language,
  20204. SDKVersion: "",
  20205. theme,
  20206. version: ""
  20207. };
  20208. }
  20209. );
  20210. const getSystemInfoSync = /* @__PURE__ */ defineSyncApi(
  20211. "getSystemInfoSync",
  20212. () => {
  20213. _initBrowserInfo = true;
  20214. initBrowserInfo();
  20215. _initBrowserInfo = false;
  20216. const windowInfo = getWindowInfo();
  20217. const deviceInfo = getDeviceInfo();
  20218. const appBaseInfo = getAppBaseInfo();
  20219. _initBrowserInfo = true;
  20220. const { ua: ua2, browserName, browserVersion, osname, osversion } = browserInfo;
  20221. const systemInfo = extend(
  20222. windowInfo,
  20223. deviceInfo,
  20224. appBaseInfo,
  20225. {
  20226. ua: ua2,
  20227. browserName,
  20228. browserVersion,
  20229. uniPlatform: "web",
  20230. uniCompileVersion: __uniConfig.compilerVersion,
  20231. uniRuntimeVersion: __uniConfig.compilerVersion,
  20232. fontSizeSetting: void 0,
  20233. osName: osname.toLocaleLowerCase(),
  20234. osVersion: osversion,
  20235. osLanguage: void 0,
  20236. osTheme: void 0
  20237. }
  20238. );
  20239. delete systemInfo.screenTop;
  20240. delete systemInfo.enableDebug;
  20241. if (!__uniConfig.darkmode)
  20242. delete systemInfo.theme;
  20243. return sortObject(systemInfo);
  20244. }
  20245. );
  20246. const getSystemInfo = /* @__PURE__ */ defineAsyncApi(
  20247. "getSystemInfo",
  20248. (_args, { resolve }) => {
  20249. return resolve(getSystemInfoSync());
  20250. }
  20251. );
  20252. const API_ON_NETWORK_STATUS_CHANGE = "onNetworkStatusChange";
  20253. function networkListener() {
  20254. getNetworkType().then(({ networkType }) => {
  20255. UniServiceJSBridge.invokeOnCallback(
  20256. API_ON_NETWORK_STATUS_CHANGE,
  20257. {
  20258. isConnected: networkType !== "none",
  20259. networkType
  20260. }
  20261. );
  20262. });
  20263. }
  20264. function getConnection() {
  20265. return navigator.connection || navigator.webkitConnection || navigator.mozConnection;
  20266. }
  20267. const onNetworkStatusChange = /* @__PURE__ */ defineOnApi(
  20268. API_ON_NETWORK_STATUS_CHANGE,
  20269. () => {
  20270. const connection = getConnection();
  20271. if (connection) {
  20272. connection.addEventListener("change", networkListener);
  20273. } else {
  20274. window.addEventListener("offline", networkListener);
  20275. window.addEventListener("online", networkListener);
  20276. }
  20277. }
  20278. );
  20279. const offNetworkStatusChange = /* @__PURE__ */ defineOffApi("offNetworkStatusChange", () => {
  20280. const connection = getConnection();
  20281. if (connection) {
  20282. connection.removeEventListener("change", networkListener);
  20283. } else {
  20284. window.removeEventListener("offline", networkListener);
  20285. window.removeEventListener("online", networkListener);
  20286. }
  20287. });
  20288. const getNetworkType = /* @__PURE__ */ defineAsyncApi(
  20289. "getNetworkType",
  20290. (_args, { resolve }) => {
  20291. const connection = getConnection();
  20292. let networkType = "unknown";
  20293. if (connection) {
  20294. networkType = connection.type;
  20295. if (networkType === "cellular" && connection.effectiveType) {
  20296. networkType = connection.effectiveType.replace("slow-", "");
  20297. } else if (!networkType && connection.effectiveType) {
  20298. networkType = connection.effectiveType;
  20299. } else if (!["none", "wifi"].includes(networkType)) {
  20300. networkType = "unknown";
  20301. }
  20302. } else if (navigator.onLine === false) {
  20303. networkType = "none";
  20304. }
  20305. return resolve({ networkType });
  20306. }
  20307. );
  20308. let listener$1 = null;
  20309. const onAccelerometerChange = /* @__PURE__ */ defineOnApi(API_ON_ACCELEROMETER, () => {
  20310. startAccelerometer();
  20311. });
  20312. const offAccelerometerChange = /* @__PURE__ */ defineOffApi(API_OFF_ACCELEROMETER, () => {
  20313. stopAccelerometer();
  20314. });
  20315. const startAccelerometer = /* @__PURE__ */ defineAsyncApi(
  20316. API_START_ACCELEROMETER,
  20317. (_, { resolve, reject }) => {
  20318. if (!window.DeviceMotionEvent) {
  20319. reject();
  20320. return;
  20321. }
  20322. function addEventListener() {
  20323. listener$1 = function(event) {
  20324. const acceleration = event.acceleration || event.accelerationIncludingGravity;
  20325. UniServiceJSBridge.invokeOnCallback(API_ON_ACCELEROMETER, {
  20326. x: acceleration && acceleration.x || 0,
  20327. y: acceleration && acceleration.y || 0,
  20328. z: acceleration && acceleration.z || 0
  20329. });
  20330. };
  20331. window.addEventListener("devicemotion", listener$1, false);
  20332. }
  20333. if (!listener$1) {
  20334. if (DeviceMotionEvent.requestPermission) {
  20335. DeviceMotionEvent.requestPermission().then((res) => {
  20336. if (res === "granted") {
  20337. addEventListener();
  20338. resolve();
  20339. } else {
  20340. reject(`${res}`);
  20341. }
  20342. }).catch((error) => {
  20343. reject(`${error}`);
  20344. });
  20345. return;
  20346. }
  20347. addEventListener();
  20348. }
  20349. resolve();
  20350. }
  20351. );
  20352. const stopAccelerometer = /* @__PURE__ */ defineAsyncApi(
  20353. API_STOP_ACCELEROMETER,
  20354. (_, { resolve }) => {
  20355. if (listener$1) {
  20356. window.removeEventListener("devicemotion", listener$1, false);
  20357. listener$1 = null;
  20358. }
  20359. resolve();
  20360. }
  20361. );
  20362. let listener = null;
  20363. const onCompassChange = /* @__PURE__ */ defineOnApi(
  20364. API_ON_COMPASS,
  20365. () => {
  20366. startCompass();
  20367. }
  20368. );
  20369. const offCompassChange = /* @__PURE__ */ defineOffApi(
  20370. API_OFF_COMPASS,
  20371. () => {
  20372. stopCompass();
  20373. }
  20374. );
  20375. const startCompass = /* @__PURE__ */ defineAsyncApi(
  20376. API_START_COMPASS,
  20377. (_, { resolve, reject }) => {
  20378. if (!window.DeviceOrientationEvent) {
  20379. reject();
  20380. return;
  20381. }
  20382. function addEventListener() {
  20383. listener = function(event) {
  20384. const direction2 = 360 - (event.alpha !== null ? event.alpha : 360);
  20385. UniServiceJSBridge.invokeOnCallback(API_ON_COMPASS, {
  20386. direction: direction2
  20387. });
  20388. };
  20389. window.addEventListener("deviceorientation", listener, false);
  20390. }
  20391. if (!listener) {
  20392. if (DeviceOrientationEvent.requestPermission) {
  20393. DeviceOrientationEvent.requestPermission().then((res) => {
  20394. if (res === "granted") {
  20395. addEventListener();
  20396. resolve();
  20397. } else {
  20398. reject(`${res}`);
  20399. }
  20400. }).catch((error) => {
  20401. reject(`${error}`);
  20402. });
  20403. return;
  20404. }
  20405. addEventListener();
  20406. }
  20407. resolve();
  20408. }
  20409. );
  20410. const stopCompass = /* @__PURE__ */ defineAsyncApi(
  20411. API_STOP_COMPASS,
  20412. (_, { resolve }) => {
  20413. if (listener) {
  20414. window.removeEventListener("deviceorientation", listener, false);
  20415. listener = null;
  20416. }
  20417. resolve();
  20418. }
  20419. );
  20420. const _isSupport = !!window.navigator.vibrate;
  20421. const vibrateShort = /* @__PURE__ */ defineAsyncApi(
  20422. API_VIBRATE_SHORT,
  20423. (args, { resolve, reject }) => {
  20424. if (_isSupport && window.navigator.vibrate(15)) {
  20425. resolve();
  20426. } else {
  20427. reject("vibrateLong:fail");
  20428. }
  20429. }
  20430. );
  20431. const vibrateLong = /* @__PURE__ */ defineAsyncApi(
  20432. API_VIBRATE_LONG,
  20433. (args, { resolve, reject }) => {
  20434. if (_isSupport && window.navigator.vibrate(400)) {
  20435. resolve();
  20436. } else {
  20437. reject("vibrateLong:fail");
  20438. }
  20439. }
  20440. );
  20441. var __async = (__this, __arguments, generator) => {
  20442. return new Promise((resolve, reject) => {
  20443. var fulfilled = (value) => {
  20444. try {
  20445. step(generator.next(value));
  20446. } catch (e2) {
  20447. reject(e2);
  20448. }
  20449. };
  20450. var rejected = (value) => {
  20451. try {
  20452. step(generator.throw(value));
  20453. } catch (e2) {
  20454. reject(e2);
  20455. }
  20456. };
  20457. var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
  20458. step((generator = generator.apply(__this, __arguments)).next());
  20459. });
  20460. };
  20461. const getClipboardData = /* @__PURE__ */ defineAsyncApi(
  20462. API_GET_CLIPBOARD_DATA,
  20463. (_0, _1) => __async(void 0, [_0, _1], function* (_, { resolve, reject }) {
  20464. initI18nGetClipboardDataMsgsOnce();
  20465. const { t: t2 } = useI18n();
  20466. try {
  20467. const data = yield navigator.clipboard.readText();
  20468. resolve({ data });
  20469. } catch (error) {
  20470. _getClipboardData(resolve, () => {
  20471. reject(`${error} ${t2("uni.getClipboardData.fail")}`);
  20472. });
  20473. }
  20474. })
  20475. );
  20476. const setClipboardData = /* @__PURE__ */ defineAsyncApi(
  20477. API_SET_CLIPBOARD_DATA,
  20478. (_0, _1) => __async(void 0, [_0, _1], function* ({ data }, { resolve, reject }) {
  20479. try {
  20480. yield navigator.clipboard.writeText(data);
  20481. resolve();
  20482. } catch (error) {
  20483. _setClipboardData(data, resolve, reject);
  20484. }
  20485. }),
  20486. SetClipboardDataProtocol,
  20487. SetClipboardDataOptions
  20488. );
  20489. function _getClipboardData(resolve, reject) {
  20490. const pasteText = document.getElementById("#clipboard");
  20491. const data = pasteText ? pasteText.value : void 0;
  20492. if (data) {
  20493. resolve({ data });
  20494. } else {
  20495. reject();
  20496. }
  20497. }
  20498. function _setClipboardData(data, resolve, reject) {
  20499. const pasteText = document.getElementById("#clipboard");
  20500. pasteText && pasteText.remove();
  20501. const textarea = document.createElement("textarea");
  20502. textarea.id = "#clipboard";
  20503. textarea.style.position = "fixed";
  20504. textarea.style.top = "-9999px";
  20505. textarea.style.zIndex = "-9999";
  20506. document.body.appendChild(textarea);
  20507. textarea.value = data;
  20508. textarea.select();
  20509. textarea.setSelectionRange(0, textarea.value.length);
  20510. const result = document.execCommand("Copy", false);
  20511. textarea.blur();
  20512. if (result) {
  20513. resolve();
  20514. } else {
  20515. reject();
  20516. }
  20517. }
  20518. const themeChangeCallBack = (res) => {
  20519. UniServiceJSBridge.invokeOnCallback(ON_THEME_CHANGE, res);
  20520. };
  20521. const onThemeChange = /* @__PURE__ */ defineOnApi(
  20522. ON_THEME_CHANGE,
  20523. () => {
  20524. UniServiceJSBridge.on(ON_THEME_CHANGE, themeChangeCallBack);
  20525. }
  20526. );
  20527. const offThemeChange = /* @__PURE__ */ defineOffApi(
  20528. OFF_THEME_CHANGE,
  20529. () => {
  20530. UniServiceJSBridge.off(ON_THEME_CHANGE, themeChangeCallBack);
  20531. }
  20532. );
  20533. const STORAGE_KEYS = "uni-storage-keys";
  20534. function parseValue(value) {
  20535. const types = ["object", "string", "number", "boolean", "undefined"];
  20536. try {
  20537. const object = isString(value) ? JSON.parse(value) : value;
  20538. const type = object.type;
  20539. if (types.indexOf(type) >= 0) {
  20540. const keys = Object.keys(object);
  20541. if (keys.length === 2 && "data" in object) {
  20542. if (typeof object.data === type) {
  20543. if (type === "object" && !Array.isArray(object.data)) {
  20544. return new globalThis.UTSJSONObject(object.data);
  20545. }
  20546. return object.data;
  20547. }
  20548. if (type === "object" && /^\d{4}-\d{2}-\d{2}T\d{2}\:\d{2}\:\d{2}\.\d{3}Z$/.test(object.data)) {
  20549. return new Date(object.data);
  20550. }
  20551. } else if (keys.length === 1) {
  20552. return "";
  20553. }
  20554. }
  20555. } catch (error) {
  20556. }
  20557. }
  20558. const setStorageSync = /* @__PURE__ */ defineSyncApi(
  20559. API_SET_STORAGE_SYNC,
  20560. (key, data) => {
  20561. const type = typeof data;
  20562. const value = type === "string" ? data : JSON.stringify({
  20563. type,
  20564. data
  20565. });
  20566. localStorage.setItem(key, value);
  20567. },
  20568. SetStorageSyncProtocol
  20569. );
  20570. const setStorage = /* @__PURE__ */ defineAsyncApi(
  20571. API_SET_STORAGE,
  20572. ({ key, data }, { resolve, reject }) => {
  20573. try {
  20574. setStorageSync(key, data);
  20575. resolve();
  20576. } catch (error) {
  20577. reject(error.message);
  20578. }
  20579. },
  20580. SetStorageProtocol
  20581. );
  20582. function getStorageOrigin(key) {
  20583. const value = localStorage && localStorage.getItem(key);
  20584. if (!isString(value)) {
  20585. throw new Error("data not found");
  20586. }
  20587. let data = value;
  20588. try {
  20589. const object = JSON.parse(value);
  20590. const result = parseValue(object);
  20591. if (result !== void 0) {
  20592. data = result;
  20593. }
  20594. } catch (error) {
  20595. }
  20596. return data;
  20597. }
  20598. const getStorageSync = /* @__PURE__ */ defineSyncApi(
  20599. API_GET_STORAGE_SYNC,
  20600. (key) => {
  20601. try {
  20602. return getStorageOrigin(key);
  20603. } catch (error) {
  20604. return "";
  20605. }
  20606. },
  20607. GetStorageSyncProtocol
  20608. );
  20609. const getStorage = /* @__PURE__ */ defineAsyncApi(
  20610. API_GET_STORAGE,
  20611. ({ key }, { resolve, reject }) => {
  20612. try {
  20613. const data = getStorageOrigin(key);
  20614. resolve({
  20615. data
  20616. });
  20617. } catch (error) {
  20618. reject(error.message);
  20619. }
  20620. },
  20621. GetStorageProtocol
  20622. );
  20623. const removeStorageSync = /* @__PURE__ */ defineSyncApi(
  20624. API_REMOVE_STORAGE,
  20625. (key) => {
  20626. if (localStorage) {
  20627. localStorage.removeItem(key);
  20628. }
  20629. },
  20630. RemoveStorageSyncProtocol
  20631. );
  20632. const removeStorage = /* @__PURE__ */ defineAsyncApi(
  20633. API_REMOVE_STORAGE,
  20634. ({ key }, { resolve }) => {
  20635. removeStorageSync(key);
  20636. resolve();
  20637. },
  20638. RemoveStorageProtocol
  20639. );
  20640. const clearStorageSync = /* @__PURE__ */ defineSyncApi(
  20641. "clearStorageSync",
  20642. () => {
  20643. if (localStorage) {
  20644. localStorage.clear();
  20645. }
  20646. }
  20647. );
  20648. const clearStorage = /* @__PURE__ */ defineAsyncApi(
  20649. "clearStorage",
  20650. (_, { resolve }) => {
  20651. clearStorageSync();
  20652. resolve();
  20653. }
  20654. );
  20655. const getStorageInfoSync = /* @__PURE__ */ defineSyncApi(
  20656. "getStorageInfoSync",
  20657. () => {
  20658. const length = localStorage && localStorage.length || 0;
  20659. const keys = [];
  20660. let currentSize = 0;
  20661. for (let index2 = 0; index2 < length; index2++) {
  20662. const key = localStorage.key(index2);
  20663. const value = localStorage.getItem(key) || "";
  20664. currentSize += key.length + value.length;
  20665. if (key !== STORAGE_KEYS) {
  20666. keys.push(key);
  20667. }
  20668. }
  20669. return {
  20670. keys,
  20671. currentSize: Math.ceil(currentSize * 2 / 1024),
  20672. limitSize: Number.MAX_VALUE
  20673. };
  20674. }
  20675. );
  20676. const getStorageInfo = /* @__PURE__ */ defineAsyncApi(
  20677. "getStorageInfo",
  20678. (_, { resolve }) => {
  20679. resolve(getStorageInfoSync());
  20680. }
  20681. );
  20682. const getFileInfo = /* @__PURE__ */ defineAsyncApi(
  20683. API_GET_FILE_INFO,
  20684. ({ filePath }, { resolve, reject }) => {
  20685. urlToFile(filePath).then((res) => {
  20686. resolve({
  20687. size: res.size
  20688. });
  20689. }).catch((err) => {
  20690. reject(String(err));
  20691. });
  20692. },
  20693. GetFileInfoProtocol,
  20694. GetFileInfoOptions
  20695. );
  20696. const openDocument = /* @__PURE__ */ defineAsyncApi(
  20697. API_OPEN_DOCUMENT,
  20698. ({ filePath }, { resolve }) => {
  20699. window.open(filePath);
  20700. return resolve();
  20701. },
  20702. OpenDocumentProtocol,
  20703. OpenDocumentOptions
  20704. );
  20705. const hideKeyboard = /* @__PURE__ */ defineAsyncApi(
  20706. API_HIDE_KEYBOARD,
  20707. (args, { resolve, reject }) => {
  20708. const activeElement = document.activeElement;
  20709. if (activeElement && (activeElement.tagName === "TEXTAREA" || activeElement.tagName === "INPUT")) {
  20710. activeElement.blur();
  20711. resolve();
  20712. }
  20713. }
  20714. );
  20715. function getServiceAddress() {
  20716. return window.location.protocol + "//" + window.location.host;
  20717. }
  20718. const getImageInfo = /* @__PURE__ */ defineAsyncApi(
  20719. API_GET_IMAGE_INFO,
  20720. ({ src }, { resolve, reject }) => {
  20721. const img = new Image();
  20722. img.onload = function() {
  20723. resolve({
  20724. width: img.naturalWidth,
  20725. height: img.naturalHeight,
  20726. path: src.indexOf("/") === 0 ? getServiceAddress() + src : src
  20727. });
  20728. };
  20729. img.onerror = function() {
  20730. reject();
  20731. };
  20732. img.src = src;
  20733. },
  20734. GetImageInfoProtocol,
  20735. GetImageInfoOptions
  20736. );
  20737. const getVideoInfo = /* @__PURE__ */ defineAsyncApi(
  20738. API_GET_VIDEO_INFO,
  20739. ({ src }, { resolve, reject }) => {
  20740. urlToFile(src, true).then((file) => {
  20741. return file;
  20742. }).catch(() => {
  20743. return null;
  20744. }).then((file) => {
  20745. const video = document.createElement("video");
  20746. if (video.onloadedmetadata !== void 0) {
  20747. const handle = setTimeout(
  20748. () => {
  20749. video.onloadedmetadata = null;
  20750. video.onerror = null;
  20751. reject();
  20752. },
  20753. src.startsWith("data:") || src.startsWith("blob:") ? 300 : 3e3
  20754. );
  20755. video.onloadedmetadata = function() {
  20756. clearTimeout(handle);
  20757. video.onerror = null;
  20758. resolve({
  20759. size: file ? file.size : 0,
  20760. duration: video.duration || 0,
  20761. width: video.videoWidth || 0,
  20762. height: video.videoHeight || 0
  20763. });
  20764. };
  20765. video.onerror = function() {
  20766. clearTimeout(handle);
  20767. video.onloadedmetadata = null;
  20768. reject();
  20769. };
  20770. video.src = src;
  20771. } else {
  20772. reject();
  20773. }
  20774. });
  20775. },
  20776. GetVideoInfoProtocol,
  20777. GetVideoInfoOptions
  20778. );
  20779. const MIMEType = {
  20780. /**
  20781. * 关于图片常见的MIME类型
  20782. */
  20783. image: {
  20784. jpg: "jpeg",
  20785. jpe: "jpeg",
  20786. pbm: "x-portable-bitmap",
  20787. pgm: "x-portable-graymap",
  20788. pnm: "x-portable-anymap",
  20789. ppm: "x-portable-pixmap",
  20790. psd: "vnd.adobe.photoshop",
  20791. pic: "x-pict",
  20792. rgb: "x-rgb",
  20793. svg: "svg+xml",
  20794. svgz: "svg+xml",
  20795. tif: "tiff",
  20796. xif: "vnd.xiff",
  20797. wbmp: "vnd.wap.wbmp",
  20798. wdp: "vnd.ms-photo",
  20799. xbm: "x-xbitmap",
  20800. ico: "x-icon"
  20801. },
  20802. /**
  20803. * 关于视频常见的MIME类型
  20804. */
  20805. video: {
  20806. "3g2": "3gpp2",
  20807. "3gp": "3gpp",
  20808. avi: "x-msvideo",
  20809. f4v: "x-f4v",
  20810. flv: "x-flv",
  20811. jpgm: "jpm",
  20812. jpgv: "jpeg",
  20813. m1v: "mpeg",
  20814. m2v: "mpeg",
  20815. mpe: "mpeg",
  20816. mpg: "mpeg",
  20817. mpg4: "mpeg",
  20818. m4v: "x-m4v",
  20819. mkv: "x-matroska",
  20820. mov: "quicktime",
  20821. qt: "quicktime",
  20822. movie: "x-sgi-movie",
  20823. mp4v: "mp4",
  20824. ogv: "ogg",
  20825. smv: "x-smv",
  20826. wm: "x-ms-wm",
  20827. wmv: "x-ms-wmv",
  20828. wmx: "x-ms-wmx",
  20829. wvx: "x-ms-wvx"
  20830. }
  20831. };
  20832. const MIMEType$1 = MIMEType;
  20833. const ALL = "all";
  20834. addInteractListener();
  20835. function isWXEnv() {
  20836. const ua2 = window.navigator.userAgent.toLowerCase();
  20837. const matchUA = ua2.match(/MicroMessenger/i);
  20838. return !!(matchUA && matchUA[0] === "micromessenger");
  20839. }
  20840. function _createInput({
  20841. count,
  20842. sourceType,
  20843. type,
  20844. extension
  20845. }) {
  20846. const inputEl = document.createElement("input");
  20847. inputEl.type = "file";
  20848. updateElementStyle(inputEl, {
  20849. position: "absolute",
  20850. visibility: "hidden",
  20851. zIndex: "-999",
  20852. width: "0",
  20853. height: "0",
  20854. top: "0",
  20855. left: "0"
  20856. });
  20857. inputEl.accept = extension.map((item) => {
  20858. if (type !== ALL) {
  20859. const MIMEKey = item.replace(".", "");
  20860. return `${type}/${MIMEType$1[type][MIMEKey] || MIMEKey}`;
  20861. } else {
  20862. if (isWXEnv()) {
  20863. return ".";
  20864. }
  20865. return item.indexOf(".") === 0 ? item : `.${item}`;
  20866. }
  20867. }).join(",");
  20868. if (count && count > 1) {
  20869. inputEl.multiple = true;
  20870. }
  20871. if (type !== ALL && sourceType instanceof Array && sourceType.length === 1 && sourceType[0] === "camera") {
  20872. inputEl.setAttribute("capture", "camera");
  20873. }
  20874. return inputEl;
  20875. }
  20876. let fileInput = null;
  20877. const chooseFile = /* @__PURE__ */ defineAsyncApi(
  20878. API_CHOOSE_FILE,
  20879. ({
  20880. // sizeType,
  20881. count,
  20882. sourceType,
  20883. type,
  20884. extension
  20885. }, { resolve, reject }) => {
  20886. initI18nChooseFileMsgsOnce();
  20887. const { t: t2 } = useI18n();
  20888. if (fileInput) {
  20889. document.body.removeChild(fileInput);
  20890. fileInput = null;
  20891. }
  20892. fileInput = _createInput({
  20893. count,
  20894. sourceType,
  20895. type,
  20896. extension
  20897. });
  20898. document.body.appendChild(fileInput);
  20899. fileInput.addEventListener("change", function(event) {
  20900. const eventTarget = event.target;
  20901. const tempFiles = [];
  20902. if (eventTarget && eventTarget.files) {
  20903. const fileCount = eventTarget.files.length;
  20904. for (let i = 0; i < fileCount; i++) {
  20905. const file = eventTarget.files[i];
  20906. let filePath;
  20907. Object.defineProperty(file, "path", {
  20908. get() {
  20909. filePath = filePath || fileToUrl(file);
  20910. return filePath;
  20911. }
  20912. });
  20913. if (i < count)
  20914. tempFiles.push(file);
  20915. }
  20916. }
  20917. const res = {
  20918. get tempFilePaths() {
  20919. return tempFiles.map(({ path }) => path);
  20920. },
  20921. tempFiles
  20922. };
  20923. resolve(res);
  20924. });
  20925. fileInput.click();
  20926. if (!getInteractStatus()) {
  20927. console.warn(t2("uni.chooseFile.notUserActivation"));
  20928. }
  20929. },
  20930. ChooseFileProtocol,
  20931. ChooseFileOptions
  20932. );
  20933. let imageInput = null;
  20934. const chooseImage = /* @__PURE__ */ defineAsyncApi(
  20935. API_CHOOSE_IMAGE,
  20936. ({
  20937. count,
  20938. // sizeType,
  20939. sourceType,
  20940. extension
  20941. }, { resolve, reject }) => {
  20942. initI18nChooseFileMsgsOnce();
  20943. const { t: t2 } = useI18n();
  20944. if (imageInput) {
  20945. document.body.removeChild(imageInput);
  20946. imageInput = null;
  20947. }
  20948. imageInput = _createInput({
  20949. count,
  20950. sourceType,
  20951. extension,
  20952. type: "image"
  20953. });
  20954. document.body.appendChild(imageInput);
  20955. imageInput.addEventListener("change", function(event) {
  20956. const eventTarget = event.target;
  20957. const tempFiles = [];
  20958. if (eventTarget && eventTarget.files) {
  20959. const fileCount = eventTarget.files.length;
  20960. for (let i = 0; i < fileCount; i++) {
  20961. const file = eventTarget.files[i];
  20962. let filePath;
  20963. Object.defineProperty(file, "path", {
  20964. get() {
  20965. filePath = filePath || fileToUrl(file);
  20966. return filePath;
  20967. }
  20968. });
  20969. if (i < count)
  20970. tempFiles.push(file);
  20971. }
  20972. }
  20973. const res = {
  20974. get tempFilePaths() {
  20975. return tempFiles.map(({ path }) => path);
  20976. },
  20977. tempFiles
  20978. };
  20979. resolve(res);
  20980. });
  20981. imageInput.click();
  20982. if (!getInteractStatus()) {
  20983. console.warn(t2("uni.chooseFile.notUserActivation"));
  20984. }
  20985. },
  20986. ChooseImageProtocol,
  20987. ChooseImageOptions
  20988. );
  20989. let index$a = 0;
  20990. let overflow = "";
  20991. function preventScroll(prevent) {
  20992. let before = index$a;
  20993. index$a += prevent ? 1 : -1;
  20994. index$a = Math.max(0, index$a);
  20995. if (index$a > 0) {
  20996. if (before === 0) {
  20997. overflow = document.body.style.overflow;
  20998. document.body.style.overflow = "hidden";
  20999. }
  21000. } else {
  21001. document.body.style.overflow = overflow;
  21002. overflow = "";
  21003. }
  21004. }
  21005. function usePreventScroll() {
  21006. onMounted(() => preventScroll(true));
  21007. onUnmounted(() => preventScroll(false));
  21008. }
  21009. const props$8 = {
  21010. src: {
  21011. type: String,
  21012. default: ""
  21013. }
  21014. };
  21015. const ImageView = /* @__PURE__ */ defineSystemComponent({
  21016. name: "ImageView",
  21017. props: props$8,
  21018. setup(props2) {
  21019. const state2 = reactive({
  21020. direction: "none"
  21021. });
  21022. let scale = 1;
  21023. let imgWidth = 0;
  21024. let imgHeight = 0;
  21025. let width = 0;
  21026. let height = 0;
  21027. function onScale({
  21028. detail
  21029. }) {
  21030. scale = detail.scale;
  21031. }
  21032. function onImgLoad(event) {
  21033. const target = event.target;
  21034. const rect = target.getBoundingClientRect();
  21035. imgWidth = rect.width;
  21036. imgHeight = rect.height;
  21037. }
  21038. function onTouchStart(event) {
  21039. const target = event.target;
  21040. const rect = target.getBoundingClientRect();
  21041. width = rect.width;
  21042. height = rect.height;
  21043. checkDirection(event);
  21044. }
  21045. function onTouchEnd(event) {
  21046. const horizontal = scale * imgWidth > width;
  21047. const vertical = scale * imgHeight > height;
  21048. if (horizontal && vertical) {
  21049. state2.direction = "all";
  21050. } else if (horizontal) {
  21051. state2.direction = "horizontal";
  21052. } else if (vertical) {
  21053. state2.direction = "vertical";
  21054. } else {
  21055. state2.direction = "none";
  21056. }
  21057. checkDirection(event);
  21058. }
  21059. function checkDirection(event) {
  21060. if (state2.direction === "all" || state2.direction === "horizontal") {
  21061. event.stopPropagation();
  21062. }
  21063. }
  21064. return () => {
  21065. const viewStyle = {
  21066. position: "absolute",
  21067. left: "0",
  21068. top: "0",
  21069. width: "100%",
  21070. height: "100%"
  21071. };
  21072. return createVNode(MovableArea, {
  21073. "style": viewStyle,
  21074. "onTouchstart": withWebEvent(onTouchStart),
  21075. "onTouchmove": withWebEvent(checkDirection),
  21076. "onTouchend": withWebEvent(onTouchEnd)
  21077. }, {
  21078. default: () => [createVNode(MovableView, {
  21079. "style": viewStyle,
  21080. "direction": state2.direction,
  21081. "inertia": true,
  21082. "scale": true,
  21083. "scale-min": "1",
  21084. "scale-max": "4",
  21085. "onScale": onScale
  21086. }, {
  21087. default: () => [createVNode("img", {
  21088. "src": props2.src,
  21089. "style": {
  21090. position: "absolute",
  21091. left: "50%",
  21092. top: "50%",
  21093. transform: "translate(-50%, -50%)",
  21094. maxHeight: "100%",
  21095. maxWidth: "100%"
  21096. },
  21097. "onLoad": onImgLoad
  21098. }, null, 40, ["src", "onLoad"])]
  21099. }, 8, ["style", "direction", "inertia", "scale", "onScale"])]
  21100. }, 8, ["style", "onTouchstart", "onTouchmove", "onTouchend"]);
  21101. };
  21102. }
  21103. });
  21104. function _isSlot$2(s) {
  21105. return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
  21106. }
  21107. const props$7 = {
  21108. urls: {
  21109. type: Array,
  21110. default() {
  21111. return [];
  21112. }
  21113. },
  21114. current: {
  21115. type: [Number, String],
  21116. default: 0
  21117. }
  21118. };
  21119. function getIndex(props2) {
  21120. let index2 = typeof props2.current === "number" ? props2.current : props2.urls.indexOf(props2.current);
  21121. index2 = index2 < 0 ? 0 : index2;
  21122. return index2;
  21123. }
  21124. const ImagePreview = /* @__PURE__ */ defineSystemComponent({
  21125. name: "ImagePreview",
  21126. props: props$7,
  21127. emits: ["close"],
  21128. setup(props2, {
  21129. emit: emit2
  21130. }) {
  21131. usePreventScroll();
  21132. const rootRef = ref(null);
  21133. const indexRef = ref(getIndex(props2));
  21134. watch(() => props2.current, () => indexRef.value = getIndex(props2));
  21135. let preventDefault;
  21136. onMounted(() => {
  21137. const el = rootRef.value;
  21138. const MAX_MOVE = 20;
  21139. let x = 0;
  21140. let y = 0;
  21141. el.addEventListener("mousedown", (event) => {
  21142. preventDefault = false;
  21143. x = event.clientX;
  21144. y = event.clientY;
  21145. });
  21146. el.addEventListener("mouseup", (event) => {
  21147. if (Math.abs(event.clientX - x) > MAX_MOVE || Math.abs(event.clientY - y) > MAX_MOVE) {
  21148. preventDefault = true;
  21149. }
  21150. });
  21151. });
  21152. function onClick() {
  21153. if (!preventDefault) {
  21154. nextTick(() => {
  21155. emit2("close");
  21156. });
  21157. }
  21158. }
  21159. function onChange2(event) {
  21160. indexRef.value = event.detail.current;
  21161. }
  21162. const closeBtnStyle = {
  21163. position: "absolute",
  21164. "box-sizing": "border-box",
  21165. top: "0",
  21166. right: "0",
  21167. width: "60px",
  21168. height: "44px",
  21169. padding: "6px",
  21170. "line-height": "32px",
  21171. "font-size": "26px",
  21172. color: "white",
  21173. "text-align": "center",
  21174. cursor: "pointer"
  21175. };
  21176. return () => {
  21177. let _slot;
  21178. return createVNode("div", {
  21179. "ref": rootRef,
  21180. "style": {
  21181. display: "block",
  21182. position: "fixed",
  21183. left: "0",
  21184. top: "0",
  21185. width: "100%",
  21186. height: "100%",
  21187. zIndex: 999,
  21188. background: "rgba(0,0,0,0.8)"
  21189. },
  21190. "onClick": onClick
  21191. }, [createVNode(Swiper, {
  21192. "navigation": "auto",
  21193. "current": indexRef.value,
  21194. "onChange": onChange2,
  21195. "indicator-dots": false,
  21196. "autoplay": false,
  21197. "style": {
  21198. position: "absolute",
  21199. left: "0",
  21200. top: "0",
  21201. width: "100%",
  21202. height: "100%"
  21203. }
  21204. }, _isSlot$2(_slot = props2.urls.map((src) => createVNode(SwiperItem, null, {
  21205. default: () => [createVNode(ImageView, {
  21206. "src": src
  21207. }, null, 8, ["src"])]
  21208. }))) ? _slot : {
  21209. default: () => [_slot],
  21210. _: 1
  21211. }, 8, ["current", "onChange"]), createVNode("div", {
  21212. "style": closeBtnStyle
  21213. }, [createSvgIconVNode(ICON_PATH_CLOSE, "#ffffff", 26)], 4)], 8, ["onClick"]);
  21214. };
  21215. }
  21216. });
  21217. let state$2 = null;
  21218. let imagePreviewInstance;
  21219. const closePreviewImageView = () => {
  21220. state$2 = null;
  21221. nextTick(() => {
  21222. imagePreviewInstance == null ? void 0 : imagePreviewInstance.unmount();
  21223. imagePreviewInstance = null;
  21224. });
  21225. };
  21226. const previewImage = /* @__PURE__ */ defineAsyncApi(
  21227. API_PREVIEW_IMAGE,
  21228. (args, { resolve }) => {
  21229. if (!state$2) {
  21230. state$2 = reactive(args);
  21231. nextTick(() => {
  21232. imagePreviewInstance = createRootApp(
  21233. ImagePreview,
  21234. state$2,
  21235. closePreviewImageView
  21236. );
  21237. imagePreviewInstance.mount(ensureRoot("u-a-p"));
  21238. });
  21239. } else {
  21240. extend(state$2, args);
  21241. }
  21242. resolve();
  21243. },
  21244. PreviewImageProtocol,
  21245. PreviewImageOptions
  21246. );
  21247. const closePreviewImage = /* @__PURE__ */ defineAsyncApi(
  21248. API_CLOSE_PREVIEW_IMAGE,
  21249. (_, { resolve, reject }) => {
  21250. if (imagePreviewInstance) {
  21251. closePreviewImageView();
  21252. resolve();
  21253. } else {
  21254. reject();
  21255. }
  21256. }
  21257. );
  21258. let videoInput = null;
  21259. const chooseVideo = /* @__PURE__ */ defineAsyncApi(
  21260. API_CHOOSE_VIDEO,
  21261. ({ sourceType, extension }, { resolve, reject }) => {
  21262. initI18nChooseFileMsgsOnce();
  21263. const { t: t2 } = useI18n();
  21264. if (videoInput) {
  21265. document.body.removeChild(videoInput);
  21266. videoInput = null;
  21267. }
  21268. videoInput = _createInput({
  21269. sourceType,
  21270. extension,
  21271. type: "video"
  21272. });
  21273. document.body.appendChild(videoInput);
  21274. videoInput.addEventListener("change", function(event) {
  21275. const eventTarget = event.target;
  21276. const file = eventTarget.files[0];
  21277. let filePath = "";
  21278. const callbackResult = {
  21279. tempFilePath: filePath,
  21280. tempFile: file,
  21281. size: file.size,
  21282. duration: 0,
  21283. width: 0,
  21284. height: 0,
  21285. name: file.name
  21286. };
  21287. Object.defineProperty(callbackResult, "tempFilePath", {
  21288. get() {
  21289. filePath = filePath || fileToUrl(this.tempFile);
  21290. return filePath;
  21291. }
  21292. });
  21293. const video = document.createElement("video");
  21294. if (video.onloadedmetadata !== void 0) {
  21295. const filePath2 = fileToUrl(file);
  21296. video.onloadedmetadata = function() {
  21297. revokeObjectURL(filePath2);
  21298. resolve(
  21299. extend(callbackResult, {
  21300. duration: video.duration || 0,
  21301. width: video.videoWidth || 0,
  21302. height: video.videoHeight || 0
  21303. })
  21304. );
  21305. };
  21306. setTimeout(() => {
  21307. video.onloadedmetadata = null;
  21308. revokeObjectURL(filePath2);
  21309. resolve(callbackResult);
  21310. }, 300);
  21311. video.src = filePath2;
  21312. } else {
  21313. resolve(callbackResult);
  21314. }
  21315. });
  21316. videoInput.click();
  21317. if (!getInteractStatus()) {
  21318. console.warn(t2("uni.chooseFile.notUserActivation"));
  21319. }
  21320. },
  21321. ChooseVideoProtocol,
  21322. ChooseVideoOptions
  21323. );
  21324. const request = /* @__PURE__ */ defineTaskApi(
  21325. API_REQUEST,
  21326. ({
  21327. url,
  21328. data,
  21329. header = {},
  21330. method,
  21331. dataType: dataType2,
  21332. responseType,
  21333. withCredentials,
  21334. timeout = __uniConfig.networkTimeout.request
  21335. }, { resolve, reject }) => {
  21336. {
  21337. timeout = timeout == null ? __uniConfig.networkTimeout.request : timeout;
  21338. }
  21339. let body = null;
  21340. const contentType = normalizeContentType(header);
  21341. if (method !== "GET") {
  21342. if (isString(data) || data instanceof ArrayBuffer) {
  21343. body = data;
  21344. } else {
  21345. if (contentType === "json") {
  21346. try {
  21347. body = JSON.stringify(data);
  21348. } catch (error) {
  21349. body = data.toString();
  21350. }
  21351. } else if (contentType === "urlencoded") {
  21352. const bodyArray = [];
  21353. for (const key in data) {
  21354. if (hasOwn(data, key)) {
  21355. bodyArray.push(
  21356. encodeURIComponent(key) + "=" + encodeURIComponent(data[key])
  21357. );
  21358. }
  21359. }
  21360. body = bodyArray.join("&");
  21361. } else {
  21362. body = data.toString();
  21363. }
  21364. }
  21365. }
  21366. const xhr = new XMLHttpRequest();
  21367. const requestTask = new RequestTask(xhr);
  21368. xhr.open(method, url);
  21369. for (const key in header) {
  21370. if (hasOwn(header, key)) {
  21371. xhr.setRequestHeader(key, header[key]);
  21372. }
  21373. }
  21374. const timer = setTimeout(function() {
  21375. xhr.onload = xhr.onabort = xhr.onerror = null;
  21376. requestTask.abort();
  21377. reject("timeout", { errCode: 5 });
  21378. }, timeout);
  21379. xhr.responseType = responseType;
  21380. xhr.onload = function() {
  21381. clearTimeout(timer);
  21382. const statusCode = xhr.status;
  21383. let res = responseType === "text" ? xhr.responseText : xhr.response;
  21384. if (responseType === "text" && dataType2 === "json") {
  21385. try {
  21386. res = new globalThis.UTSJSONObject(JSON.parse(res));
  21387. } catch (error) {
  21388. }
  21389. }
  21390. resolve({
  21391. data: res,
  21392. statusCode,
  21393. header: parseHeaders(xhr.getAllResponseHeaders()),
  21394. cookies: []
  21395. });
  21396. };
  21397. xhr.onabort = function() {
  21398. clearTimeout(timer);
  21399. reject("abort", { errCode: 600003 });
  21400. };
  21401. xhr.onerror = function() {
  21402. clearTimeout(timer);
  21403. reject(void 0, { errCode: 5 });
  21404. };
  21405. xhr.withCredentials = withCredentials;
  21406. xhr.send(body);
  21407. return requestTask;
  21408. },
  21409. RequestProtocol,
  21410. RequestOptions
  21411. );
  21412. function normalizeContentType(header) {
  21413. const name = Object.keys(header).find(
  21414. (name2) => name2.toLowerCase() === "content-type"
  21415. );
  21416. if (!name) {
  21417. return;
  21418. }
  21419. const contentType = header[name];
  21420. if (contentType.indexOf("application/json") === 0) {
  21421. return "json";
  21422. } else if (contentType.indexOf("application/x-www-form-urlencoded") === 0) {
  21423. return "urlencoded";
  21424. }
  21425. return "string";
  21426. }
  21427. class RequestTask {
  21428. constructor(xhr) {
  21429. this._xhr = xhr;
  21430. }
  21431. abort() {
  21432. if (this._xhr) {
  21433. this._xhr.abort();
  21434. delete this._xhr;
  21435. }
  21436. }
  21437. onHeadersReceived(callback) {
  21438. throw new Error("Method not implemented.");
  21439. }
  21440. offHeadersReceived(callback) {
  21441. throw new Error("Method not implemented.");
  21442. }
  21443. }
  21444. function parseHeaders(headers) {
  21445. const headersObject = {};
  21446. headers.split(LINEFEED).forEach((header) => {
  21447. const find = header.match(/(\S+\s*):\s*(.*)/);
  21448. if (!find || find.length !== 3) {
  21449. return;
  21450. }
  21451. headersObject[find[1]] = find[2];
  21452. });
  21453. return headersObject;
  21454. }
  21455. class DownloadTask {
  21456. constructor(xhr) {
  21457. this._callbacks = [];
  21458. this._xhr = xhr;
  21459. }
  21460. /**
  21461. * 监听下载进度
  21462. * @param {Function} callback 回调
  21463. */
  21464. onProgressUpdate(callback) {
  21465. if (!isFunction(callback)) {
  21466. return;
  21467. }
  21468. this._callbacks.push(callback);
  21469. }
  21470. offProgressUpdate(callback) {
  21471. const index2 = this._callbacks.indexOf(callback);
  21472. if (index2 >= 0) {
  21473. this._callbacks.splice(index2, 1);
  21474. }
  21475. }
  21476. /**
  21477. * 停止任务
  21478. */
  21479. abort() {
  21480. if (this._xhr) {
  21481. this._xhr.abort();
  21482. delete this._xhr;
  21483. }
  21484. }
  21485. onHeadersReceived(callback) {
  21486. throw new Error("Method not implemented.");
  21487. }
  21488. offHeadersReceived(callback) {
  21489. throw new Error("Method not implemented.");
  21490. }
  21491. }
  21492. const downloadFile = /* @__PURE__ */ defineTaskApi(
  21493. API_DOWNLOAD_FILE,
  21494. ({ url, header = {}, timeout = __uniConfig.networkTimeout.downloadFile }, { resolve, reject }) => {
  21495. {
  21496. timeout = timeout == null ? __uniConfig.networkTimeout.downloadFile : timeout;
  21497. }
  21498. var timer;
  21499. var xhr = new XMLHttpRequest();
  21500. var downloadTask = new DownloadTask(xhr);
  21501. xhr.open("GET", url, true);
  21502. Object.keys(header).forEach((key) => {
  21503. xhr.setRequestHeader(key, header[key]);
  21504. });
  21505. xhr.responseType = "blob";
  21506. xhr.onload = function() {
  21507. clearTimeout(timer);
  21508. const statusCode = xhr.status;
  21509. const blob = this.response;
  21510. let filename;
  21511. const contentDisposition = xhr.getResponseHeader("content-disposition");
  21512. if (contentDisposition) {
  21513. const res = contentDisposition.match(/filename="?(\S+)"?\b/);
  21514. if (res) {
  21515. filename = res[1];
  21516. }
  21517. }
  21518. blob.name = filename || getFileName(url);
  21519. resolve({
  21520. statusCode,
  21521. tempFilePath: fileToUrl(blob)
  21522. });
  21523. };
  21524. xhr.onabort = function() {
  21525. clearTimeout(timer);
  21526. reject("abort", { errCode: 600003 });
  21527. };
  21528. xhr.onerror = function() {
  21529. clearTimeout(timer);
  21530. reject("", { errCode: 602001 });
  21531. };
  21532. xhr.onprogress = function(event) {
  21533. downloadTask._callbacks.forEach((callback) => {
  21534. var totalBytesWritten = event.loaded;
  21535. var totalBytesExpectedToWrite = event.total;
  21536. var progress = Math.round(
  21537. totalBytesWritten / totalBytesExpectedToWrite * 100
  21538. );
  21539. callback({
  21540. progress,
  21541. totalBytesWritten,
  21542. totalBytesExpectedToWrite
  21543. });
  21544. });
  21545. };
  21546. xhr.send();
  21547. timer = setTimeout(function() {
  21548. xhr.onprogress = xhr.onload = xhr.onabort = xhr.onerror = null;
  21549. downloadTask.abort();
  21550. reject("timeout", { errCode: 5 });
  21551. }, timeout);
  21552. return downloadTask;
  21553. },
  21554. DownloadFileProtocol,
  21555. DownloadFileOptions
  21556. );
  21557. class UploadTask {
  21558. constructor(xhr) {
  21559. this._callbacks = [];
  21560. this._xhr = xhr;
  21561. }
  21562. /**
  21563. * 监听上传进度
  21564. * @param callback 回调
  21565. */
  21566. onProgressUpdate(callback) {
  21567. if (!isFunction(callback)) {
  21568. return;
  21569. }
  21570. this._callbacks.push(callback);
  21571. }
  21572. offProgressUpdate(callback) {
  21573. const index2 = this._callbacks.indexOf(callback);
  21574. if (index2 >= 0) {
  21575. this._callbacks.splice(index2, 1);
  21576. }
  21577. }
  21578. /**
  21579. * 中断上传任务
  21580. */
  21581. abort() {
  21582. this._isAbort = true;
  21583. if (this._xhr) {
  21584. this._xhr.abort();
  21585. delete this._xhr;
  21586. }
  21587. }
  21588. onHeadersReceived(callback) {
  21589. throw new Error("Method not implemented.");
  21590. }
  21591. offHeadersReceived(callback) {
  21592. throw new Error("Method not implemented.");
  21593. }
  21594. }
  21595. const uploadFile = /* @__PURE__ */ defineTaskApi(
  21596. API_UPLOAD_FILE,
  21597. ({
  21598. url,
  21599. file,
  21600. filePath,
  21601. name,
  21602. files: files2,
  21603. header = {},
  21604. formData = {},
  21605. timeout = __uniConfig.networkTimeout.uploadFile
  21606. }, { resolve, reject }) => {
  21607. {
  21608. timeout = timeout == null ? __uniConfig.networkTimeout.uploadFile : timeout;
  21609. }
  21610. var uploadTask = new UploadTask();
  21611. if (!isArray(files2) || !files2.length) {
  21612. files2 = [
  21613. {
  21614. name,
  21615. file,
  21616. uri: filePath
  21617. }
  21618. ];
  21619. }
  21620. function upload(realFiles) {
  21621. var xhr = new XMLHttpRequest();
  21622. var form = new FormData();
  21623. var timer;
  21624. Object.keys(formData).forEach((key) => {
  21625. form.append(key, formData[key]);
  21626. });
  21627. Object.values(files2).forEach(({ name: name2 }, index2) => {
  21628. const file2 = realFiles[index2];
  21629. form.append(name2 || "file", file2, file2.name || `file-${Date.now()}`);
  21630. });
  21631. xhr.open("POST", url);
  21632. Object.keys(header).forEach((key) => {
  21633. xhr.setRequestHeader(key, header[key]);
  21634. });
  21635. xhr.upload.onprogress = function(event) {
  21636. uploadTask._callbacks.forEach((callback) => {
  21637. var totalBytesSent = event.loaded;
  21638. var totalBytesExpectedToSend = event.total;
  21639. var progress = Math.round(
  21640. totalBytesSent / totalBytesExpectedToSend * 100
  21641. );
  21642. callback({
  21643. progress,
  21644. totalBytesSent,
  21645. totalBytesExpectedToSend
  21646. });
  21647. });
  21648. };
  21649. xhr.onerror = function() {
  21650. clearTimeout(timer);
  21651. reject("", { errCode: 602001 });
  21652. };
  21653. xhr.onabort = function() {
  21654. clearTimeout(timer);
  21655. reject("abort", { errCode: 600003 });
  21656. };
  21657. xhr.onload = function() {
  21658. clearTimeout(timer);
  21659. const statusCode = xhr.status;
  21660. resolve({
  21661. statusCode,
  21662. data: xhr.responseText || xhr.response
  21663. });
  21664. };
  21665. if (!uploadTask._isAbort) {
  21666. timer = setTimeout(function() {
  21667. xhr.upload.onprogress = xhr.onload = xhr.onabort = xhr.onerror = null;
  21668. uploadTask.abort();
  21669. reject("timeout", { errCode: 5 });
  21670. }, timeout);
  21671. xhr.send(form);
  21672. uploadTask._xhr = xhr;
  21673. } else {
  21674. reject("abort", { errCode: 600003 });
  21675. }
  21676. }
  21677. Promise.all(
  21678. files2.map(
  21679. ({ file: file2, uri }) => file2 instanceof Blob ? Promise.resolve(blobToFile(file2)) : urlToFile(uri)
  21680. )
  21681. ).then(upload).catch(() => {
  21682. setTimeout(() => {
  21683. reject("file error");
  21684. }, 0);
  21685. });
  21686. return uploadTask;
  21687. },
  21688. UploadFileProtocol,
  21689. UploadFileOptions
  21690. );
  21691. const socketTasks = [];
  21692. const globalEvent = {
  21693. open: "",
  21694. close: "",
  21695. error: "",
  21696. message: ""
  21697. };
  21698. class SocketTask {
  21699. /**
  21700. * 构造函数
  21701. * @param {string} url
  21702. * @param {Array} protocols
  21703. */
  21704. constructor(url, protocols, callback) {
  21705. this._callbacks = {
  21706. open: [],
  21707. close: [],
  21708. error: [],
  21709. message: []
  21710. };
  21711. let error;
  21712. try {
  21713. const webSocket = this._webSocket = new WebSocket(url, protocols);
  21714. webSocket.binaryType = "arraybuffer";
  21715. const eventNames = ["open", "close", "error", "message"];
  21716. eventNames.forEach((name) => {
  21717. this._callbacks[name] = [];
  21718. webSocket.addEventListener(name, (event) => {
  21719. const { data, code, reason } = event;
  21720. const res = name === "message" ? { data } : name === "close" ? { code, reason } : {};
  21721. this._callbacks[name].forEach((callback2) => {
  21722. try {
  21723. callback2(res);
  21724. } catch (e2) {
  21725. console.error(
  21726. `thirdScriptError
  21727. ${e2};at socketTask.on${capitalize(
  21728. name
  21729. )} callback function
  21730. `,
  21731. e2
  21732. );
  21733. }
  21734. });
  21735. if (this === socketTasks[0] && globalEvent[name]) {
  21736. UniServiceJSBridge.invokeOnCallback(globalEvent[name], res);
  21737. }
  21738. if (name === "error" || name === "close") {
  21739. const index2 = socketTasks.indexOf(this);
  21740. if (index2 >= 0) {
  21741. socketTasks.splice(index2, 1);
  21742. }
  21743. }
  21744. });
  21745. });
  21746. const propertys = [
  21747. "CLOSED",
  21748. "CLOSING",
  21749. "CONNECTING",
  21750. "OPEN",
  21751. "readyState"
  21752. ];
  21753. propertys.forEach((property) => {
  21754. Object.defineProperty(this, property, {
  21755. get() {
  21756. return webSocket[property];
  21757. }
  21758. });
  21759. });
  21760. } catch (e2) {
  21761. error = e2;
  21762. }
  21763. callback && callback(error, this);
  21764. }
  21765. /**
  21766. * 发送
  21767. * @param {any} data
  21768. */
  21769. send(options) {
  21770. const data = (options || {}).data;
  21771. const ws = this._webSocket;
  21772. try {
  21773. if (ws.readyState !== ws.OPEN) {
  21774. callOptions(options, {
  21775. errMsg: `sendSocketMessage:fail SocketTask.readyState is not OPEN`,
  21776. errCode: 10002
  21777. });
  21778. throw new Error("SocketTask.readyState is not OPEN");
  21779. }
  21780. ws.send(data);
  21781. callOptions(options, "sendSocketMessage:ok");
  21782. } catch (error) {
  21783. callOptions(options, {
  21784. errMsg: `sendSocketMessage:fail ${error}`,
  21785. errCode: 602001
  21786. });
  21787. }
  21788. }
  21789. /**
  21790. * 关闭
  21791. * @param {number} code
  21792. * @param {string} reason
  21793. */
  21794. close(options = {}) {
  21795. const ws = this._webSocket;
  21796. try {
  21797. const code = options.code || 1e3;
  21798. const reason = options.reason;
  21799. if (isString(reason)) {
  21800. ws.close(code, reason);
  21801. } else {
  21802. ws.close(code);
  21803. }
  21804. callOptions(options, "closeSocket:ok");
  21805. } catch (error) {
  21806. callOptions(options, `closeSocket:fail ${error}`);
  21807. }
  21808. }
  21809. onOpen(callback) {
  21810. this._callbacks.open.push(callback);
  21811. }
  21812. onMessage(callback) {
  21813. this._callbacks.message.push(callback);
  21814. }
  21815. onError(callback) {
  21816. this._callbacks.error.push(callback);
  21817. }
  21818. onClose(callback) {
  21819. this._callbacks.close.push(callback);
  21820. }
  21821. }
  21822. const connectSocket = /* @__PURE__ */ defineTaskApi(
  21823. API_CONNECT_SOCKET,
  21824. ({ url, protocols }, { resolve, reject }) => {
  21825. return new SocketTask(
  21826. url,
  21827. protocols,
  21828. (error, socketTask) => {
  21829. if (error) {
  21830. reject(error.toString(), {
  21831. errCode: 600009
  21832. });
  21833. return;
  21834. }
  21835. socketTasks.push(socketTask);
  21836. resolve();
  21837. }
  21838. );
  21839. },
  21840. ConnectSocketProtocol,
  21841. ConnectSocketOptions
  21842. );
  21843. function callSocketTask(socketTask, method, option, resolve, reject) {
  21844. const fn = socketTask[method];
  21845. if (isFunction(fn)) {
  21846. fn.call(
  21847. socketTask,
  21848. extend({}, option, {
  21849. success() {
  21850. resolve();
  21851. },
  21852. fail({ errMsg }) {
  21853. reject(errMsg.replace("sendSocketMessage:fail ", ""));
  21854. },
  21855. complete: void 0
  21856. })
  21857. );
  21858. }
  21859. }
  21860. const sendSocketMessage = /* @__PURE__ */ defineAsyncApi(
  21861. API_SEND_SOCKET_MESSAGE,
  21862. (options, { resolve, reject }) => {
  21863. const socketTask = socketTasks[0];
  21864. if (socketTask && socketTask.readyState === socketTask.OPEN) {
  21865. callSocketTask(socketTask, "send", options, resolve, reject);
  21866. } else {
  21867. reject("WebSocket is not connected");
  21868. }
  21869. },
  21870. SendSocketMessageProtocol
  21871. );
  21872. const closeSocket = /* @__PURE__ */ defineAsyncApi(
  21873. API_CLOSE_SOCKET,
  21874. (options, { resolve, reject }) => {
  21875. const socketTask = socketTasks[0];
  21876. if (socketTask) {
  21877. callSocketTask(socketTask, "close", options, resolve, reject);
  21878. } else {
  21879. reject("WebSocket is not connected");
  21880. }
  21881. },
  21882. CloseSocketProtocol
  21883. );
  21884. function on(event) {
  21885. const api2 = `onSocket${capitalize(event)}`;
  21886. return /* @__PURE__ */ defineOnApi(api2, () => {
  21887. globalEvent[event] = api2;
  21888. });
  21889. }
  21890. const onSocketOpen = /* @__PURE__ */ on("open");
  21891. const onSocketError = /* @__PURE__ */ on("error");
  21892. const onSocketMessage = /* @__PURE__ */ on("message");
  21893. const onSocketClose = /* @__PURE__ */ on("close");
  21894. const getLocation = /* @__PURE__ */ defineAsyncApi(
  21895. API_GET_LOCATION,
  21896. ({ type, altitude, highAccuracyExpireTime, isHighAccuracy }, { resolve, reject }) => {
  21897. const mapInfo = getMapInfo();
  21898. new Promise((resolve2, reject2) => {
  21899. if (navigator.geolocation) {
  21900. navigator.geolocation.getCurrentPosition(
  21901. (res) => resolve2({ coords: res.coords }),
  21902. reject2,
  21903. {
  21904. enableHighAccuracy: isHighAccuracy || altitude,
  21905. timeout: highAccuracyExpireTime || 1e3 * 100
  21906. }
  21907. );
  21908. } else {
  21909. reject2(new Error("device nonsupport geolocation"));
  21910. }
  21911. }).catch((error) => {
  21912. return new Promise(
  21913. (resolve2, reject2) => {
  21914. if (mapInfo.type === MapType.QQ) {
  21915. getJSONP(
  21916. `https://apis.map.qq.com/ws/location/v1/ip?output=jsonp&key=${mapInfo.key}`,
  21917. {
  21918. callback: "callback"
  21919. },
  21920. (res) => {
  21921. if ("result" in res && res.result.location) {
  21922. const location2 = res.result.location;
  21923. resolve2({
  21924. coords: {
  21925. latitude: location2.lat,
  21926. longitude: location2.lng
  21927. },
  21928. skip: true
  21929. });
  21930. } else {
  21931. reject2(new Error(res.message || JSON.stringify(res)));
  21932. }
  21933. },
  21934. () => reject2(new Error("network error"))
  21935. );
  21936. } else if (mapInfo.type === MapType.GOOGLE) {
  21937. request({
  21938. method: "POST",
  21939. url: `https://www.googleapis.com/geolocation/v1/geolocate?key=${mapInfo.key}`,
  21940. success(res) {
  21941. const data = res.data;
  21942. if ("location" in data) {
  21943. resolve2({
  21944. coords: {
  21945. latitude: data.location.lat,
  21946. longitude: data.location.lng,
  21947. accuracy: data.accuracy
  21948. },
  21949. skip: true
  21950. });
  21951. } else {
  21952. reject2(
  21953. new Error(
  21954. data.error && data.error.message || JSON.stringify(res)
  21955. )
  21956. );
  21957. }
  21958. },
  21959. fail() {
  21960. reject2(new Error("network error"));
  21961. }
  21962. });
  21963. } else if (mapInfo.type === MapType.AMAP) {
  21964. loadMaps([], () => {
  21965. window.AMap.plugin("AMap.Geolocation", () => {
  21966. const geolocation = new window.AMap.Geolocation({
  21967. enableHighAccuracy: true,
  21968. timeout: 1e4
  21969. });
  21970. geolocation.getCurrentPosition(
  21971. (status, data) => {
  21972. if (status === "complete") {
  21973. resolve2({
  21974. coords: {
  21975. latitude: data.position.lat,
  21976. longitude: data.position.lng,
  21977. accuracy: data.accuracy
  21978. },
  21979. skip: true
  21980. });
  21981. } else {
  21982. reject2(new Error(data.message));
  21983. }
  21984. }
  21985. );
  21986. });
  21987. });
  21988. } else {
  21989. reject2(error);
  21990. }
  21991. }
  21992. );
  21993. }).then(({ coords, skip }) => {
  21994. translateCoordinateSystem(type, coords, skip).then((coords2) => {
  21995. resolve({
  21996. latitude: coords2.latitude,
  21997. longitude: coords2.longitude,
  21998. accuracy: coords2.accuracy,
  21999. speed: coords2.altitude || 0,
  22000. altitude: coords2.altitude || 0,
  22001. verticalAccuracy: coords2.altitudeAccuracy || 0,
  22002. // 无专门水平精度,使用位置精度替代
  22003. horizontalAccuracy: coords2.accuracy || 0
  22004. });
  22005. }).catch((error) => {
  22006. reject(error.message);
  22007. });
  22008. }).catch((error) => {
  22009. reject(error.message || JSON.stringify(error));
  22010. });
  22011. },
  22012. GetLocationProtocol,
  22013. GetLocationOptions
  22014. );
  22015. const ICON_PATH_NAV = "M28 17c-6.49396875 0-12.13721875 2.57040625-15 6.34840625V5.4105l6.29859375 6.29859375c0.387875 0.387875 1.02259375 0.387875 1.4105 0 0.387875-0.387875 0.387875-1.02259375 0-1.4105L12.77853125 2.36803125a0.9978125 0.9978125 0 0 0-0.0694375-0.077125c-0.1944375-0.1944375-0.45090625-0.291375-0.70721875-0.290875l-0.00184375-0.0000625-0.00184375 0.0000625c-0.2563125-0.0005-0.51278125 0.09640625-0.70721875 0.290875a0.9978125 0.9978125 0 0 0-0.0694375 0.077125l-7.930625 7.9305625c-0.387875 0.387875-0.387875 1.02259375 0 1.4105 0.387875 0.387875 1.02259375 0.387875 1.4105 0L11 5.4105V29c0 0.55 0.45 1 1 1s1-0.45 1-1c0-5.52284375 6.71571875-10 15-10 0.55228125 0 1-0.44771875 1-1 0-0.55228125-0.44771875-1-1-1z";
  22016. const props$6 = {
  22017. latitude: {
  22018. type: Number
  22019. },
  22020. longitude: {
  22021. type: Number
  22022. },
  22023. scale: {
  22024. type: Number,
  22025. default: 18
  22026. },
  22027. name: {
  22028. type: String,
  22029. default: ""
  22030. },
  22031. address: {
  22032. type: String,
  22033. default: ""
  22034. }
  22035. };
  22036. function useState$2(props2) {
  22037. const state2 = reactive({
  22038. center: {
  22039. latitude: 0,
  22040. longitude: 0
  22041. },
  22042. marker: {
  22043. id: 1,
  22044. latitude: 0,
  22045. longitude: 0,
  22046. iconPath: ICON_PATH_TARGET,
  22047. width: 32,
  22048. height: 52
  22049. },
  22050. location: {
  22051. id: 2,
  22052. latitude: 0,
  22053. longitude: 0,
  22054. iconPath: ICON_PATH_ORIGIN,
  22055. width: 44,
  22056. height: 44
  22057. }
  22058. });
  22059. function updatePosition() {
  22060. if (props2.latitude && props2.longitude) {
  22061. state2.center.latitude = props2.latitude;
  22062. state2.center.longitude = props2.longitude;
  22063. state2.marker.latitude = props2.latitude;
  22064. state2.marker.longitude = props2.longitude;
  22065. }
  22066. }
  22067. watch([() => props2.latitude, () => props2.longitude], updatePosition);
  22068. updatePosition();
  22069. return state2;
  22070. }
  22071. const LocationView = /* @__PURE__ */ defineSystemComponent({
  22072. name: "LocationView",
  22073. props: props$6,
  22074. emits: ["close"],
  22075. setup(props2, {
  22076. emit: emit2
  22077. }) {
  22078. const state2 = useState$2(props2);
  22079. usePreventScroll();
  22080. getLocation({
  22081. type: "gcj02",
  22082. success: ({
  22083. latitude,
  22084. longitude
  22085. }) => {
  22086. state2.location.latitude = latitude;
  22087. state2.location.longitude = longitude;
  22088. }
  22089. });
  22090. function onRegionChange(event) {
  22091. const centerLocation = event.detail.centerLocation;
  22092. if (centerLocation) {
  22093. state2.center.latitude = centerLocation.latitude;
  22094. state2.center.longitude = centerLocation.longitude;
  22095. }
  22096. }
  22097. function nav() {
  22098. const mapInfo = getMapInfo();
  22099. let url = "";
  22100. if (mapInfo.type === MapType.GOOGLE) {
  22101. const origin = state2.location.latitude ? `&origin=${state2.location.latitude}%2C${state2.location.longitude}` : "";
  22102. url = `https://www.google.com/maps/dir/?api=1${origin}&destination=${props2.latitude}%2C${props2.longitude}`;
  22103. } else if (mapInfo.type === MapType.QQ) {
  22104. const fromcoord = state2.location.latitude ? `&fromcoord=${state2.location.latitude}%2C${state2.location.longitude}&from=${encodeURIComponent("我的位置")}` : "";
  22105. url = `https://apis.map.qq.com/uri/v1/routeplan?type=drive${fromcoord}&tocoord=${props2.latitude}%2C${props2.longitude}&to=${encodeURIComponent(props2.name || "目的地")}&ref=${mapInfo.key}`;
  22106. } else if (mapInfo.type === MapType.AMAP) {
  22107. const from = state2.location.latitude ? `from=${state2.location.longitude},${state2.location.latitude},${encodeURIComponent("我的位置")}&` : "";
  22108. url = `https://uri.amap.com/navigation?${from}to=${props2.longitude},${props2.latitude},${encodeURIComponent(props2.name || "目的地")}`;
  22109. }
  22110. window.open(url);
  22111. }
  22112. function back() {
  22113. emit2("close");
  22114. }
  22115. function setCenter({
  22116. latitude,
  22117. longitude
  22118. }) {
  22119. state2.center.latitude = latitude;
  22120. state2.center.longitude = longitude;
  22121. }
  22122. return () => {
  22123. return createVNode("div", {
  22124. "class": "uni-system-open-location"
  22125. }, [createVNode(Map$1, {
  22126. "latitude": state2.center.latitude,
  22127. "longitude": state2.center.longitude,
  22128. "class": "map",
  22129. "markers": [state2.marker, state2.location],
  22130. "onRegionchange": onRegionChange
  22131. }, {
  22132. default: () => [createVNode("div", {
  22133. "class": "map-move",
  22134. "onClick": () => setCenter(state2.location)
  22135. }, [createSvgIconVNode(ICON_PATH_LOCTAION, "#000000", 24)], 8, ["onClick"])]
  22136. }, 8, ["latitude", "longitude", "markers", "onRegionchange"]), createVNode("div", {
  22137. "class": "info"
  22138. }, [createVNode("div", {
  22139. "class": "name",
  22140. "onClick": () => setCenter(state2.marker)
  22141. }, [props2.name], 8, ["onClick"]), createVNode("div", {
  22142. "class": "address",
  22143. "onClick": () => setCenter(state2.marker)
  22144. }, [props2.address], 8, ["onClick"]), createVNode("div", {
  22145. "class": "nav",
  22146. "onClick": nav
  22147. }, [createSvgIconVNode(ICON_PATH_NAV, "#ffffff", 26)], 8, ["onClick"])]), createVNode("div", {
  22148. "class": "nav-btn-back",
  22149. "onClick": back
  22150. }, [createSvgIconVNode(ICON_PATH_BACK, "#ffffff", 26)], 8, ["onClick"])]);
  22151. };
  22152. }
  22153. });
  22154. let state$1 = null;
  22155. const openLocation = /* @__PURE__ */ defineAsyncApi(
  22156. API_OPEN_LOCATION,
  22157. (args, { resolve }) => {
  22158. if (!state$1) {
  22159. state$1 = reactive(args);
  22160. nextTick(() => {
  22161. const app = createRootApp(LocationView, state$1, () => {
  22162. state$1 = null;
  22163. nextTick(() => {
  22164. app.unmount();
  22165. });
  22166. });
  22167. app.mount(ensureRoot("u-a-o"));
  22168. });
  22169. } else {
  22170. extend(state$1, args);
  22171. }
  22172. resolve();
  22173. },
  22174. OpenLocationProtocol,
  22175. OpenLocationOptions
  22176. );
  22177. function _isSlot$1(s) {
  22178. return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
  22179. }
  22180. const props$5 = {
  22181. latitude: {
  22182. type: Number
  22183. },
  22184. longitude: {
  22185. type: Number
  22186. }
  22187. };
  22188. function distance(distance2) {
  22189. if (distance2 > 100) {
  22190. return `${distance2 > 1e3 ? (distance2 / 1e3).toFixed(1) + "k" : distance2.toFixed(0)}m | `;
  22191. } else if (distance2 > 0) {
  22192. return "<100m | ";
  22193. } else {
  22194. return "";
  22195. }
  22196. }
  22197. function useState$1(props2) {
  22198. const state2 = reactive({
  22199. latitude: 0,
  22200. longitude: 0,
  22201. keyword: "",
  22202. searching: false
  22203. });
  22204. function updatePosition() {
  22205. if (props2.latitude && props2.longitude) {
  22206. state2.latitude = props2.latitude;
  22207. state2.longitude = props2.longitude;
  22208. }
  22209. }
  22210. watch([() => props2.latitude, () => props2.longitude], updatePosition);
  22211. updatePosition();
  22212. return state2;
  22213. }
  22214. function useList(state2) {
  22215. const key = __uniConfig.qqMapKey;
  22216. const list2 = reactive([]);
  22217. const selectedIndexRef = ref(-1);
  22218. const selectedRef = computed(() => list2[selectedIndexRef.value]);
  22219. const listState = reactive({
  22220. loading: true,
  22221. // google map default
  22222. pageSize: 20,
  22223. pageIndex: 1,
  22224. hasNextPage: true,
  22225. nextPage: null,
  22226. selectedIndex: selectedIndexRef,
  22227. selected: selectedRef
  22228. });
  22229. const adcodeRef = ref("");
  22230. const boundaryRef = computed(() => adcodeRef.value ? `region(${adcodeRef.value},1,${state2.latitude},${state2.longitude})` : `nearby(${state2.latitude},${state2.longitude},5000)`);
  22231. function pushData(array) {
  22232. array.forEach((item) => {
  22233. list2.push({
  22234. name: item.title || item.name,
  22235. address: item.address,
  22236. distance: item._distance || item.distance,
  22237. latitude: item.location.lat,
  22238. longitude: item.location.lng
  22239. });
  22240. });
  22241. }
  22242. function getList() {
  22243. listState.loading = true;
  22244. const mapInfo = getMapInfo();
  22245. if (mapInfo.type === MapType.GOOGLE) {
  22246. if (listState.pageIndex > 1 && listState.nextPage) {
  22247. listState.nextPage();
  22248. return;
  22249. }
  22250. const service = new google.maps.places.PlacesService(document.createElement("div"));
  22251. service[state2.searching ? "textSearch" : "nearbySearch"]({
  22252. location: {
  22253. lat: state2.latitude,
  22254. lng: state2.longitude
  22255. },
  22256. query: state2.keyword,
  22257. radius: 5e3
  22258. }, (results, state3, page) => {
  22259. listState.loading = false;
  22260. if (results && results.length) {
  22261. results.forEach((item) => {
  22262. list2.push({
  22263. name: item.name || "",
  22264. address: item.vicinity || item.formatted_address || "",
  22265. distance: 0,
  22266. latitude: item.geometry.location.lat(),
  22267. longitude: item.geometry.location.lng()
  22268. });
  22269. });
  22270. }
  22271. if (page) {
  22272. if (!page.hasNextPage) {
  22273. listState.hasNextPage = false;
  22274. } else {
  22275. listState.nextPage = () => {
  22276. page.nextPage();
  22277. };
  22278. }
  22279. }
  22280. });
  22281. } else if (mapInfo.type === MapType.QQ) {
  22282. const url = state2.searching ? `https://apis.map.qq.com/ws/place/v1/search?output=jsonp&key=${key}&boundary=${boundaryRef.value}&keyword=${state2.keyword}&page_size=${listState.pageSize}&page_index=${listState.pageIndex}` : `https://apis.map.qq.com/ws/geocoder/v1/?output=jsonp&key=${key}&location=${state2.latitude},${state2.longitude}&get_poi=1&poi_options=page_size=${listState.pageSize};page_index=${listState.pageIndex}`;
  22283. getJSONP(url, {
  22284. callback: "callback"
  22285. }, (res) => {
  22286. listState.loading = false;
  22287. if (state2.searching && "data" in res && res.data.length) {
  22288. pushData(res.data);
  22289. } else if ("result" in res) {
  22290. const result = res.result;
  22291. adcodeRef.value = result.ad_info ? result.ad_info.adcode : "";
  22292. if (result.pois) {
  22293. pushData(result.pois);
  22294. }
  22295. }
  22296. if (list2.length === listState.pageSize * listState.pageIndex) {
  22297. listState.hasNextPage = false;
  22298. }
  22299. }, () => {
  22300. listState.loading = false;
  22301. });
  22302. } else if (mapInfo.type === MapType.AMAP) {
  22303. window.AMap.plugin("AMap.PlaceSearch", function() {
  22304. const placeSearch = new window.AMap.PlaceSearch({
  22305. city: "全国",
  22306. pageSize: 10,
  22307. pageIndex: listState.pageIndex
  22308. });
  22309. const keyword = state2.searching ? state2.keyword : "";
  22310. const radius = state2.searching ? 5e4 : 5e3;
  22311. placeSearch.searchNearBy(keyword, [state2.longitude, state2.latitude], radius, function(status, result) {
  22312. if (status === "error") {
  22313. console.error(result);
  22314. } else if (status === "no_data") {
  22315. listState.hasNextPage = false;
  22316. } else {
  22317. pushData(result.poiList.pois);
  22318. }
  22319. });
  22320. listState.loading = false;
  22321. });
  22322. }
  22323. }
  22324. function loadMore() {
  22325. if (!listState.loading && listState.hasNextPage) {
  22326. listState.pageIndex++;
  22327. getList();
  22328. }
  22329. }
  22330. function reset() {
  22331. listState.selectedIndex = -1;
  22332. listState.pageIndex = 1;
  22333. listState.hasNextPage = true;
  22334. listState.nextPage = null;
  22335. list2.splice(0, list2.length);
  22336. }
  22337. return {
  22338. listState,
  22339. list: list2,
  22340. loadMore,
  22341. reset,
  22342. getList
  22343. };
  22344. }
  22345. const LoctaionPicker = /* @__PURE__ */ defineSystemComponent({
  22346. name: "LoctaionPicker",
  22347. props: props$5,
  22348. emits: ["close"],
  22349. setup(props2, {
  22350. emit: emit2
  22351. }) {
  22352. usePreventScroll();
  22353. initI18nChooseLocationMsgsOnce();
  22354. const {
  22355. t: t2
  22356. } = useI18n();
  22357. const state2 = useState$1(props2);
  22358. const {
  22359. list: list2,
  22360. listState,
  22361. loadMore,
  22362. reset,
  22363. getList
  22364. } = useList(state2);
  22365. const search = debounce(() => {
  22366. reset();
  22367. if (state2.keyword) {
  22368. getList();
  22369. }
  22370. }, 1e3, {
  22371. setTimeout,
  22372. clearTimeout
  22373. });
  22374. watch(() => state2.searching, (val) => {
  22375. reset();
  22376. if (!val) {
  22377. getList();
  22378. }
  22379. });
  22380. function onInput(event) {
  22381. state2.keyword = event.detail.value;
  22382. search();
  22383. }
  22384. function onChoose() {
  22385. emit2("close", extend({}, listState.selected));
  22386. }
  22387. function onBack() {
  22388. emit2("close");
  22389. }
  22390. function onRegionChange(event) {
  22391. const centerLocation = event.detail.centerLocation;
  22392. if (centerLocation) {
  22393. move(centerLocation);
  22394. }
  22395. }
  22396. function moveToLocation() {
  22397. getLocation({
  22398. type: "gcj02",
  22399. success: move,
  22400. fail: () => {
  22401. }
  22402. });
  22403. }
  22404. function move({
  22405. latitude,
  22406. longitude
  22407. }) {
  22408. state2.latitude = latitude;
  22409. state2.longitude = longitude;
  22410. if (!state2.searching) {
  22411. reset();
  22412. getList();
  22413. }
  22414. }
  22415. if (!state2.latitude || !state2.longitude) {
  22416. moveToLocation();
  22417. }
  22418. return () => {
  22419. const content = list2.map((item, index2) => {
  22420. return createVNode("div", {
  22421. "key": index2,
  22422. "class": {
  22423. "list-item": true,
  22424. selected: listState.selectedIndex === index2
  22425. },
  22426. "onClick": () => {
  22427. listState.selectedIndex = index2;
  22428. state2.latitude = item.latitude;
  22429. state2.longitude = item.longitude;
  22430. }
  22431. }, [createSvgIconVNode(ICON_PATH_CONFIRM, "#007aff", 24), createVNode("div", {
  22432. "class": "list-item-title"
  22433. }, [item.name]), createVNode("div", {
  22434. "class": "list-item-detail"
  22435. }, [distance(item.distance), item.address])], 10, ["onClick"]);
  22436. });
  22437. if (listState.loading) {
  22438. content.unshift(createVNode("div", {
  22439. "class": "list-loading"
  22440. }, [createVNode("i", {
  22441. "class": "uni-loading"
  22442. }, null)]));
  22443. }
  22444. return createVNode("div", {
  22445. "class": "uni-system-choose-location"
  22446. }, [createVNode(Map$1, {
  22447. "latitude": state2.latitude,
  22448. "longitude": state2.longitude,
  22449. "class": "map",
  22450. "show-location": true,
  22451. "libraries": ["places"],
  22452. "onUpdated": getList,
  22453. "onRegionchange": onRegionChange
  22454. }, {
  22455. default: () => [createVNode("div", {
  22456. "class": "map-location",
  22457. "style": `background-image: url("${ICON_PATH_TARGET}")`
  22458. }, null), createVNode("div", {
  22459. "class": "map-move",
  22460. "onClick": moveToLocation
  22461. }, [createSvgIconVNode(ICON_PATH_LOCTAION, "#000000", 24)], 8, ["onClick"])],
  22462. _: 1
  22463. }, 8, ["latitude", "longitude", "show-location", "onUpdated", "onRegionchange"]), createVNode("div", {
  22464. "class": "nav"
  22465. }, [createVNode("div", {
  22466. "class": "nav-btn back",
  22467. "onClick": onBack
  22468. }, [createSvgIconVNode(ICON_PATH_CLOSE, "#ffffff", 26)], 8, ["onClick"]), createVNode("div", {
  22469. "class": {
  22470. "nav-btn": true,
  22471. confirm: true,
  22472. disable: !listState.selected
  22473. },
  22474. "onClick": onChoose
  22475. }, [createSvgIconVNode(ICON_PATH_CONFIRM, "#ffffff", 26)], 10, ["onClick"])]), createVNode("div", {
  22476. "class": "menu"
  22477. }, [createVNode("div", {
  22478. "class": "search"
  22479. }, [createVNode(Input, {
  22480. "value": state2.keyword,
  22481. "class": "search-input",
  22482. "placeholder": t2("uni.chooseLocation.search"),
  22483. "onFocus": () => state2.searching = true,
  22484. "onInput": onInput
  22485. }, null, 8, ["value", "placeholder", "onFocus", "onInput"]), state2.searching && createVNode("div", {
  22486. "class": "search-btn",
  22487. "onClick": () => {
  22488. state2.searching = false;
  22489. state2.keyword = "";
  22490. }
  22491. }, [t2("uni.chooseLocation.cancel")], 8, ["onClick"])]), createVNode(ScrollView, {
  22492. "scroll-y": true,
  22493. "class": "list",
  22494. "onScrolltolower": loadMore
  22495. }, _isSlot$1(content) ? content : {
  22496. default: () => [content],
  22497. _: 2
  22498. }, 8, ["scroll-y", "onScrolltolower"])])]);
  22499. };
  22500. }
  22501. });
  22502. let state = null;
  22503. const chooseLocation = /* @__PURE__ */ defineAsyncApi(
  22504. API_CHOOSE_LOCATION,
  22505. (args, { resolve, reject }) => {
  22506. if (!state) {
  22507. state = reactive(args);
  22508. nextTick(() => {
  22509. const app = createRootApp(
  22510. LoctaionPicker,
  22511. state,
  22512. (poi) => {
  22513. state = null;
  22514. nextTick(() => {
  22515. app.unmount();
  22516. });
  22517. poi ? resolve(poi) : reject("cancel");
  22518. }
  22519. );
  22520. app.mount(ensureRoot("u-a-c"));
  22521. });
  22522. } else {
  22523. reject("cancel");
  22524. }
  22525. },
  22526. ChooseLocationProtocol
  22527. );
  22528. let started = false;
  22529. let watchId = 0;
  22530. const startLocationUpdate = /* @__PURE__ */ defineAsyncApi(
  22531. API_START_LOCATION_UPDATE,
  22532. (options, { resolve, reject }) => {
  22533. if (!navigator.geolocation) {
  22534. reject();
  22535. return;
  22536. }
  22537. watchId = watchId || navigator.geolocation.watchPosition(
  22538. (res) => {
  22539. started = true;
  22540. translateCoordinateSystem(options == null ? void 0 : options.type, res.coords).then((coords) => {
  22541. UniServiceJSBridge.invokeOnCallback(
  22542. API_ON_LOCATION_CHANGE,
  22543. coords
  22544. );
  22545. resolve();
  22546. }).catch((error) => {
  22547. UniServiceJSBridge.invokeOnCallback(
  22548. API_ON_LOCATION_CHANGE_ERROR,
  22549. { errMsg: `onLocationChange:fail ${error.message}` }
  22550. );
  22551. });
  22552. },
  22553. (error) => {
  22554. if (!started) {
  22555. reject(error.message);
  22556. started = true;
  22557. }
  22558. UniServiceJSBridge.invokeOnCallback(API_ON_LOCATION_CHANGE_ERROR, {
  22559. errMsg: `onLocationChange:fail ${error.message}`
  22560. });
  22561. }
  22562. );
  22563. setTimeout(resolve, 100);
  22564. },
  22565. StartLocationUpdateProtocol,
  22566. StartLocationUpdateOptions
  22567. );
  22568. const stopLocationUpdate = /* @__PURE__ */ defineAsyncApi(
  22569. API_STOP_LOCATION_UPDATE,
  22570. (_, { resolve }) => {
  22571. if (watchId) {
  22572. navigator.geolocation.clearWatch(watchId);
  22573. started = false;
  22574. watchId = 0;
  22575. }
  22576. resolve();
  22577. }
  22578. );
  22579. const onLocationChange = /* @__PURE__ */ defineOnApi(
  22580. API_ON_LOCATION_CHANGE,
  22581. () => {
  22582. }
  22583. );
  22584. const offLocationChange = /* @__PURE__ */ defineOffApi(
  22585. API_OFF_LOCATION_CHANGE,
  22586. () => {
  22587. }
  22588. );
  22589. const onLocationChangeError = /* @__PURE__ */ defineOnApi(
  22590. API_ON_LOCATION_CHANGE_ERROR,
  22591. () => {
  22592. }
  22593. );
  22594. const offLocationChangeError = /* @__PURE__ */ defineOffApi(
  22595. API_OFF_LOCATION_CHANGE_ERROR,
  22596. () => {
  22597. }
  22598. );
  22599. const navigateBack = /* @__PURE__ */ defineAsyncApi(
  22600. API_NAVIGATE_BACK,
  22601. (args, { resolve, reject }) => {
  22602. let canBack = true;
  22603. if (invokeHook(ON_BACK_PRESS, {
  22604. from: args.from || "navigateBack"
  22605. }) === true) {
  22606. canBack = false;
  22607. }
  22608. if (!canBack) {
  22609. return reject(ON_BACK_PRESS);
  22610. }
  22611. getApp().$router.go(-args.delta);
  22612. return resolve();
  22613. },
  22614. NavigateBackProtocol,
  22615. NavigateBackOptions
  22616. );
  22617. function navigate({ type, url, tabBarText, events, isAutomatedTesting }, __id__) {
  22618. const router = getApp().$router;
  22619. const { path, query } = parseUrl(url);
  22620. return new Promise((resolve, reject) => {
  22621. const state2 = createPageState(type, __id__);
  22622. router[type === "navigateTo" ? "push" : "replace"]({
  22623. path,
  22624. query,
  22625. state: state2,
  22626. force: true
  22627. }).then((failure) => {
  22628. if (isNavigationFailure(failure)) {
  22629. return reject(failure.message);
  22630. }
  22631. if (type === "switchTab") {
  22632. router.currentRoute.value.meta.tabBarText = tabBarText;
  22633. }
  22634. if (type === "navigateTo") {
  22635. const meta = router.currentRoute.value.meta;
  22636. if (!meta.eventChannel) {
  22637. meta.eventChannel = new EventChannel(state2.__id__, events);
  22638. } else if (events) {
  22639. Object.keys(events).forEach((eventName) => {
  22640. meta.eventChannel._addListener(
  22641. eventName,
  22642. "on",
  22643. events[eventName]
  22644. );
  22645. });
  22646. meta.eventChannel._clearCache();
  22647. }
  22648. return isAutomatedTesting ? resolve({
  22649. __id__: state2.__id__
  22650. }) : resolve({
  22651. eventChannel: meta.eventChannel
  22652. });
  22653. }
  22654. return isAutomatedTesting ? resolve({ __id__: state2.__id__ }) : resolve();
  22655. });
  22656. });
  22657. }
  22658. const navigateTo = /* @__PURE__ */ defineAsyncApi(
  22659. API_NAVIGATE_TO,
  22660. // @ts-ignore
  22661. ({ url, events, isAutomatedTesting }, { resolve, reject }) => navigate({ type: API_NAVIGATE_TO, url, events, isAutomatedTesting }).then(resolve).catch(reject),
  22662. NavigateToProtocol,
  22663. NavigateToOptions
  22664. );
  22665. function removeLastPage() {
  22666. const page = getCurrentPage();
  22667. if (!page) {
  22668. return;
  22669. }
  22670. const $page = page.$page;
  22671. removePage(normalizeRouteKey($page.path, $page.id));
  22672. }
  22673. const redirectTo = /* @__PURE__ */ defineAsyncApi(
  22674. API_REDIRECT_TO,
  22675. // @ts-ignore
  22676. ({ url, isAutomatedTesting }, { resolve, reject }) => {
  22677. return (
  22678. // TODO exists 属性未实现
  22679. removeLastPage(), navigate({ type: API_REDIRECT_TO, url, isAutomatedTesting }).then(resolve).catch(reject)
  22680. );
  22681. },
  22682. RedirectToProtocol,
  22683. RedirectToOptions
  22684. );
  22685. function removeAllPages() {
  22686. const keys = getCurrentPagesMap().keys();
  22687. for (const routeKey of keys) {
  22688. removePage(routeKey);
  22689. }
  22690. }
  22691. const reLaunch = /* @__PURE__ */ defineAsyncApi(
  22692. API_RE_LAUNCH,
  22693. // @ts-ignore
  22694. ({ url, isAutomatedTesting }, { resolve, reject }) => {
  22695. return removeAllPages(), navigate({ type: API_RE_LAUNCH, url, isAutomatedTesting }).then(resolve).catch(reject);
  22696. },
  22697. ReLaunchProtocol,
  22698. ReLaunchOptions
  22699. );
  22700. function removeNonTabBarPages() {
  22701. const curTabBarPageVm = getCurrentPageVm();
  22702. if (!curTabBarPageVm) {
  22703. return;
  22704. }
  22705. const pagesMap = getCurrentPagesMap();
  22706. const keys = pagesMap.keys();
  22707. for (const routeKey of keys) {
  22708. const page = pagesMap.get(routeKey);
  22709. if (!page.$.__isTabBar) {
  22710. removePage(routeKey);
  22711. } else {
  22712. page.$.__isActive = false;
  22713. }
  22714. }
  22715. if (curTabBarPageVm.$.__isTabBar) {
  22716. curTabBarPageVm.$.__isVisible = false;
  22717. invokeHook(curTabBarPageVm, ON_HIDE);
  22718. }
  22719. }
  22720. function isSamePage(url, $page) {
  22721. return url === $page.fullPath || url === "/" && $page.meta.isEntry;
  22722. }
  22723. function getTabBarPageId(url) {
  22724. const pages = getCurrentPagesMap().values();
  22725. for (const page of pages) {
  22726. const $page = page.$page;
  22727. if (isSamePage(url, $page)) {
  22728. page.$.__isActive = true;
  22729. return $page.id;
  22730. }
  22731. }
  22732. }
  22733. const switchTab = /* @__PURE__ */ defineAsyncApi(
  22734. API_SWITCH_TAB,
  22735. // @ts-ignore
  22736. ({ url, tabBarText, isAutomatedTesting }, { resolve, reject }) => {
  22737. return removeNonTabBarPages(), navigate(
  22738. { type: API_SWITCH_TAB, url, tabBarText, isAutomatedTesting },
  22739. getTabBarPageId(url)
  22740. ).then(resolve).catch(reject);
  22741. },
  22742. SwitchTabProtocol,
  22743. SwitchTabOptions
  22744. );
  22745. const preloadPage = /* @__PURE__ */ defineAsyncApi(
  22746. API_PRELOAD_PAGE,
  22747. ({ url }, { resolve, reject }) => {
  22748. const path = url.split("?")[0];
  22749. const route = getRouteOptions(path);
  22750. if (!route) {
  22751. reject(`${url}}`);
  22752. return;
  22753. }
  22754. route.loader && route.loader().then(() => {
  22755. resolve({
  22756. url,
  22757. errMsg: "preloadPage:ok"
  22758. });
  22759. }).catch((err) => {
  22760. reject(`${url} ${String(err)}`);
  22761. });
  22762. },
  22763. PreloadPageProtocol
  22764. );
  22765. const props$4 = {
  22766. title: {
  22767. type: String,
  22768. default: ""
  22769. },
  22770. icon: {
  22771. default: "success",
  22772. validator(value) {
  22773. return SHOW_TOAST_ICON.indexOf(value) !== -1;
  22774. }
  22775. },
  22776. image: {
  22777. type: String,
  22778. default: ""
  22779. },
  22780. duration: {
  22781. type: Number,
  22782. default: 1500
  22783. },
  22784. mask: {
  22785. type: Boolean,
  22786. default: false
  22787. },
  22788. visible: {
  22789. type: Boolean
  22790. }
  22791. };
  22792. const ToastIconClassName = "uni-toast__icon";
  22793. const ICONCOLOR = {
  22794. light: "#fff",
  22795. dark: "rgba(255,255,255,0.9)"
  22796. };
  22797. const getIconColor = (theme) => ICONCOLOR[theme];
  22798. const Toast = /* @__PURE__ */ defineComponent({
  22799. name: "Toast",
  22800. props: props$4,
  22801. setup(props2) {
  22802. initI18nShowToastMsgsOnce();
  22803. initI18nShowLoadingMsgsOnce();
  22804. const {
  22805. Icon
  22806. } = useToastIcon(props2);
  22807. const visible = usePopup(props2, {});
  22808. return () => {
  22809. const {
  22810. mask,
  22811. duration,
  22812. title,
  22813. image: image2
  22814. } = props2;
  22815. return createVNode(Transition, {
  22816. "name": "uni-fade"
  22817. }, {
  22818. default: () => [withDirectives(createVNode("uni-toast", {
  22819. "data-duration": duration
  22820. }, [mask ? createVNode("div", {
  22821. "class": "uni-mask",
  22822. "style": "background: transparent;",
  22823. "onTouchmove": onEventPrevent
  22824. }, null, 40, ["onTouchmove"]) : "", !image2 && !Icon.value ? createVNode("div", {
  22825. "class": "uni-sample-toast"
  22826. }, [createVNode("p", {
  22827. "class": "uni-simple-toast__text"
  22828. }, [title])]) : createVNode("div", {
  22829. "class": "uni-toast"
  22830. }, [image2 ? createVNode("img", {
  22831. "src": image2,
  22832. "class": ToastIconClassName
  22833. }, null, 10, ["src"]) : Icon.value, createVNode("p", {
  22834. "class": "uni-toast__content"
  22835. }, [title])])], 8, ["data-duration"]), [[vShow, visible.value]])]
  22836. });
  22837. };
  22838. }
  22839. });
  22840. function useToastIcon(props2) {
  22841. const iconColor = ref(getIconColor(getTheme()));
  22842. const _onThemeChange = ({
  22843. theme
  22844. }) => iconColor.value = getIconColor(theme);
  22845. watchEffect(() => {
  22846. if (props2.visible) {
  22847. onThemeChange$2(_onThemeChange);
  22848. } else {
  22849. offThemeChange$1(_onThemeChange);
  22850. }
  22851. });
  22852. const Icon = computed(() => {
  22853. switch (props2.icon) {
  22854. case "success":
  22855. return createVNode(createSvgIconVNode(ICON_PATH_SUCCESS_NO_CIRCLE, iconColor.value, 38), {
  22856. class: ToastIconClassName
  22857. });
  22858. case "error":
  22859. return createVNode(createSvgIconVNode(ICON_PATH_WARN, iconColor.value, 38), {
  22860. class: ToastIconClassName
  22861. });
  22862. case "loading":
  22863. return createVNode("i", {
  22864. "class": [ToastIconClassName, "uni-loading"]
  22865. }, null, 2);
  22866. default:
  22867. return null;
  22868. }
  22869. });
  22870. return {
  22871. Icon
  22872. };
  22873. }
  22874. let showToastState;
  22875. let showType = "";
  22876. let timeoutId;
  22877. const scope = /* @__PURE__ */ effectScope();
  22878. function watchVisible() {
  22879. scope.run(() => {
  22880. watch(
  22881. [() => showToastState.visible, () => showToastState.duration],
  22882. ([visible, duration]) => {
  22883. if (visible) {
  22884. timeoutId && clearTimeout(timeoutId);
  22885. if (showType === "onShowLoading")
  22886. return;
  22887. timeoutId = setTimeout(() => {
  22888. hidePopup("onHideToast");
  22889. }, duration);
  22890. } else {
  22891. timeoutId && clearTimeout(timeoutId);
  22892. }
  22893. }
  22894. );
  22895. });
  22896. }
  22897. function createToast(args) {
  22898. if (!showToastState) {
  22899. showToastState = reactive(extend(args, { visible: false }));
  22900. nextTick(() => {
  22901. watchVisible();
  22902. UniServiceJSBridge.on("onHidePopup", () => hidePopup("onHidePopup"));
  22903. createRootApp(Toast, showToastState, () => {
  22904. }).mount(ensureRoot("u-a-t"));
  22905. });
  22906. } else {
  22907. extend(showToastState, args);
  22908. }
  22909. setTimeout(() => {
  22910. showToastState.visible = true;
  22911. }, 10);
  22912. }
  22913. const showToast = /* @__PURE__ */ defineAsyncApi(
  22914. API_SHOW_TOAST,
  22915. (args, { resolve, reject }) => {
  22916. createToast(args);
  22917. showType = "onShowToast";
  22918. resolve();
  22919. },
  22920. ShowToastProtocol,
  22921. ShowToastOptions
  22922. );
  22923. const showLoadingDefaultState = {
  22924. icon: "loading",
  22925. duration: 1e8,
  22926. image: ""
  22927. };
  22928. const showLoading = /* @__PURE__ */ defineAsyncApi(
  22929. API_SHOW_LOADING,
  22930. (args, { resolve, reject }) => {
  22931. extend(args, showLoadingDefaultState);
  22932. createToast(args);
  22933. showType = "onShowLoading";
  22934. resolve();
  22935. },
  22936. ShowLoadingProtocol,
  22937. ShowLoadingOptions
  22938. );
  22939. const hideToast = /* @__PURE__ */ defineAsyncApi(
  22940. API_HIDE_TOAST,
  22941. (args, { resolve, reject }) => {
  22942. hidePopup("onHideToast");
  22943. resolve();
  22944. }
  22945. );
  22946. const hideLoading = /* @__PURE__ */ defineAsyncApi(
  22947. API_HIDE_LOADING,
  22948. (args, { resolve, reject }) => {
  22949. hidePopup("onHideLoading");
  22950. resolve();
  22951. }
  22952. );
  22953. function hidePopup(type) {
  22954. const { t: t2 } = useI18n();
  22955. if (!showType) {
  22956. return;
  22957. }
  22958. let warnMsg = "";
  22959. if (type === "onHideToast" && showType !== "onShowToast") {
  22960. warnMsg = t2("uni.showToast.unpaired");
  22961. } else if (type === "onHideLoading" && showType !== "onShowLoading") {
  22962. warnMsg = t2("uni.showLoading.unpaired");
  22963. }
  22964. if (warnMsg) {
  22965. return console.warn(warnMsg);
  22966. }
  22967. showType = "";
  22968. setTimeout(() => {
  22969. showToastState.visible = false;
  22970. }, 10);
  22971. }
  22972. const loadFontFace = /* @__PURE__ */ defineAsyncApi(
  22973. API_LOAD_FONT_FACE,
  22974. ({ family, source, desc }, { resolve, reject }) => {
  22975. if (source.startsWith(`url("`) || source.startsWith(`url('`)) {
  22976. source = `url('${getRealPath(source.substring(5, source.length - 2))}')`;
  22977. } else if (source.startsWith("url(")) {
  22978. source = `url('${getRealPath(source.substring(4, source.length - 1))}')`;
  22979. } else {
  22980. source = getRealPath(source);
  22981. }
  22982. addFont(family, source, desc).then(() => {
  22983. resolve();
  22984. }).catch((err) => {
  22985. reject(`loadFontFace:fail ${err}`);
  22986. });
  22987. },
  22988. LoadFontFaceProtocol
  22989. );
  22990. function updateDocumentTitle(title) {
  22991. {
  22992. document.title = title;
  22993. }
  22994. UniServiceJSBridge.emit(ON_NAVIGATION_BAR_CHANGE, { titleText: title });
  22995. }
  22996. function useDocumentTitle(pageMeta) {
  22997. function update() {
  22998. updateDocumentTitle(pageMeta.navigationBar.titleText);
  22999. }
  23000. watchEffect(update);
  23001. onActivated(update);
  23002. }
  23003. function setNavigationBar(pageMeta, type, args, resolve, reject) {
  23004. if (!pageMeta) {
  23005. return reject("page not found");
  23006. }
  23007. const { navigationBar } = pageMeta;
  23008. switch (type) {
  23009. case API_SET_NAVIGATION_BAR_COLOR:
  23010. const { frontColor, backgroundColor, animation: animation2 } = args;
  23011. const { duration, timingFunc } = animation2;
  23012. if (frontColor) {
  23013. navigationBar.titleColor = frontColor === "#000000" ? "#000000" : "#ffffff";
  23014. }
  23015. if (backgroundColor) {
  23016. navigationBar.backgroundColor = backgroundColor;
  23017. }
  23018. navigationBar.duration = duration + "ms";
  23019. navigationBar.timingFunc = timingFunc;
  23020. break;
  23021. case API_SHOW_NAVIGATION_BAR_LOADING:
  23022. navigationBar.loading = true;
  23023. break;
  23024. case API_HIDE_NAVIGATION_BAR_LOADING:
  23025. navigationBar.loading = false;
  23026. break;
  23027. case API_SET_NAVIGATION_BAR_TITLE:
  23028. const { title } = args;
  23029. navigationBar.titleText = title;
  23030. break;
  23031. }
  23032. resolve();
  23033. }
  23034. const setNavigationBarColor = /* @__PURE__ */ defineAsyncApi(
  23035. API_SET_NAVIGATION_BAR_COLOR,
  23036. (args, { resolve, reject }) => {
  23037. setNavigationBar(
  23038. getCurrentPageMeta(),
  23039. API_SET_NAVIGATION_BAR_COLOR,
  23040. args,
  23041. resolve,
  23042. reject
  23043. );
  23044. },
  23045. SetNavigationBarColorProtocol,
  23046. SetNavigationBarColorOptions
  23047. );
  23048. const showNavigationBarLoading = /* @__PURE__ */ defineAsyncApi(
  23049. API_SHOW_NAVIGATION_BAR_LOADING,
  23050. (args, { resolve, reject }) => {
  23051. setNavigationBar(
  23052. getCurrentPageMeta(),
  23053. API_SHOW_NAVIGATION_BAR_LOADING,
  23054. args || {},
  23055. resolve,
  23056. reject
  23057. );
  23058. }
  23059. );
  23060. const hideNavigationBarLoading = /* @__PURE__ */ defineAsyncApi(
  23061. API_HIDE_NAVIGATION_BAR_LOADING,
  23062. (args, { resolve, reject }) => {
  23063. setNavigationBar(
  23064. getCurrentPageMeta(),
  23065. API_HIDE_NAVIGATION_BAR_LOADING,
  23066. args || {},
  23067. resolve,
  23068. reject
  23069. );
  23070. }
  23071. );
  23072. const setNavigationBarTitle = /* @__PURE__ */ defineAsyncApi(
  23073. API_SET_NAVIGATION_BAR_TITLE,
  23074. (args, { resolve, reject }) => {
  23075. setNavigationBar(
  23076. getCurrentPageMeta(),
  23077. API_SET_NAVIGATION_BAR_TITLE,
  23078. args,
  23079. resolve,
  23080. reject
  23081. );
  23082. },
  23083. SetNavigationBarTitleProtocol
  23084. );
  23085. const pageScrollTo = /* @__PURE__ */ defineAsyncApi(
  23086. API_PAGE_SCROLL_TO,
  23087. ({ scrollTop, selector, duration }, { resolve }) => {
  23088. scrollTo(selector || scrollTop || 0, duration, true);
  23089. resolve();
  23090. },
  23091. PageScrollToProtocol,
  23092. PageScrollToOptions
  23093. );
  23094. const startPullDownRefresh = /* @__PURE__ */ defineAsyncApi(
  23095. API_START_PULL_DOWN_REFRESH,
  23096. (_args, { resolve }) => {
  23097. UniServiceJSBridge.invokeViewMethod(
  23098. API_START_PULL_DOWN_REFRESH,
  23099. {},
  23100. getCurrentPageId()
  23101. );
  23102. resolve();
  23103. }
  23104. );
  23105. const stopPullDownRefresh = /* @__PURE__ */ defineAsyncApi(
  23106. API_STOP_PULL_DOWN_REFRESH,
  23107. (_args, { resolve }) => {
  23108. UniServiceJSBridge.invokeViewMethod(
  23109. API_STOP_PULL_DOWN_REFRESH,
  23110. {},
  23111. getCurrentPageId()
  23112. );
  23113. resolve();
  23114. }
  23115. );
  23116. const setTabBarItemProps = [
  23117. "text",
  23118. "iconPath",
  23119. "iconfont",
  23120. "selectedIconPath",
  23121. "visible"
  23122. ];
  23123. const setTabBarStyleProps = [
  23124. "color",
  23125. "selectedColor",
  23126. "backgroundColor",
  23127. "borderStyle",
  23128. "midButton"
  23129. ];
  23130. const setTabBarBadgeProps = ["badge", "redDot"];
  23131. function setProperties(item, props2, propsData) {
  23132. props2.forEach(function(name) {
  23133. if (hasOwn(propsData, name)) {
  23134. item[name] = propsData[name];
  23135. }
  23136. });
  23137. }
  23138. function setTabBar(type, args, resolve) {
  23139. const tabBar2 = useTabBar();
  23140. switch (type) {
  23141. case API_SHOW_TAB_BAR:
  23142. tabBar2.shown = true;
  23143. break;
  23144. case API_HIDE_TAB_BAR:
  23145. tabBar2.shown = false;
  23146. break;
  23147. case API_SET_TAB_BAR_ITEM:
  23148. const { index: index2 } = args;
  23149. const tabBarItem = tabBar2.list[index2];
  23150. const oldPagePath = tabBarItem.pagePath;
  23151. setProperties(tabBarItem, setTabBarItemProps, args);
  23152. const { pagePath } = args;
  23153. if (pagePath) {
  23154. const newPagePath = addLeadingSlash(pagePath);
  23155. if (newPagePath !== oldPagePath) {
  23156. normalizeTabBarRoute(index2, oldPagePath, newPagePath);
  23157. }
  23158. }
  23159. break;
  23160. case API_SET_TAB_BAR_STYLE:
  23161. setProperties(tabBar2, setTabBarStyleProps, args);
  23162. break;
  23163. case API_SHOW_TAB_BAR_RED_DOT:
  23164. setProperties(tabBar2.list[args.index], setTabBarBadgeProps, {
  23165. badge: "",
  23166. redDot: true
  23167. });
  23168. break;
  23169. case API_SET_TAB_BAR_BADGE:
  23170. setProperties(tabBar2.list[args.index], setTabBarBadgeProps, {
  23171. badge: args.text,
  23172. redDot: true
  23173. });
  23174. break;
  23175. case API_HIDE_TAB_BAR_RED_DOT:
  23176. case API_REMOVE_TAB_BAR_BADGE:
  23177. setProperties(tabBar2.list[args.index], setTabBarBadgeProps, {
  23178. badge: "",
  23179. redDot: false
  23180. });
  23181. break;
  23182. }
  23183. resolve();
  23184. }
  23185. const setTabBarItem = /* @__PURE__ */ defineAsyncApi(
  23186. API_SET_TAB_BAR_ITEM,
  23187. (args, { resolve }) => {
  23188. setTabBar(API_SET_TAB_BAR_ITEM, args, resolve);
  23189. },
  23190. SetTabBarItemProtocol,
  23191. SetTabBarItemOptions
  23192. );
  23193. const setTabBarStyle = /* @__PURE__ */ defineAsyncApi(
  23194. API_SET_TAB_BAR_STYLE,
  23195. (args, { resolve }) => {
  23196. setTabBar(API_SET_TAB_BAR_STYLE, args, resolve);
  23197. },
  23198. SetTabBarStyleProtocol,
  23199. SetTabBarStyleOptions
  23200. );
  23201. const hideTabBar = /* @__PURE__ */ defineAsyncApi(
  23202. API_HIDE_TAB_BAR,
  23203. (args, { resolve }) => {
  23204. setTabBar(API_HIDE_TAB_BAR, args ? args : {}, resolve);
  23205. },
  23206. HideTabBarProtocol
  23207. );
  23208. const showTabBar = /* @__PURE__ */ defineAsyncApi(
  23209. API_SHOW_TAB_BAR,
  23210. (args, { resolve }) => {
  23211. setTabBar(API_SHOW_TAB_BAR, args ? args : {}, resolve);
  23212. },
  23213. ShowTabBarProtocol
  23214. );
  23215. const hideTabBarRedDot = /* @__PURE__ */ defineAsyncApi(
  23216. API_HIDE_TAB_BAR_RED_DOT,
  23217. (args, { resolve }) => {
  23218. setTabBar(API_HIDE_TAB_BAR_RED_DOT, args, resolve);
  23219. },
  23220. HideTabBarRedDotProtocol,
  23221. HideTabBarRedDotOptions
  23222. );
  23223. const showTabBarRedDot = /* @__PURE__ */ defineAsyncApi(
  23224. API_SHOW_TAB_BAR_RED_DOT,
  23225. (args, { resolve }) => {
  23226. setTabBar(API_SHOW_TAB_BAR_RED_DOT, args, resolve);
  23227. },
  23228. ShowTabBarRedDotProtocol,
  23229. ShowTabBarRedDotOptions
  23230. );
  23231. const removeTabBarBadge = /* @__PURE__ */ defineAsyncApi(
  23232. API_REMOVE_TAB_BAR_BADGE,
  23233. (args, { resolve }) => {
  23234. setTabBar(API_REMOVE_TAB_BAR_BADGE, args, resolve);
  23235. },
  23236. RemoveTabBarBadgeProtocol,
  23237. RemoveTabBarBadgeOptions
  23238. );
  23239. const setTabBarBadge = /* @__PURE__ */ defineAsyncApi(
  23240. API_SET_TAB_BAR_BADGE,
  23241. (args, { resolve }) => {
  23242. setTabBar(API_SET_TAB_BAR_BADGE, args, resolve);
  23243. },
  23244. SetTabBarBadgeProtocol,
  23245. SetTabBarBadgeOptions
  23246. );
  23247. const UNI_TABBAR_ICON_FONT = "UniTabbarIconFont";
  23248. const _middleButton = {
  23249. width: "50px",
  23250. height: "50px",
  23251. iconWidth: "24px"
  23252. };
  23253. const TabBar = /* @__PURE__ */ defineSystemComponent({
  23254. name: "TabBar",
  23255. setup() {
  23256. const visibleList = ref([]);
  23257. const _tabBar = useTabBar();
  23258. const tabBar2 = useTheme(_tabBar, () => {
  23259. const tabBarStyle = parseTheme(_tabBar);
  23260. tabBar2.backgroundColor = tabBarStyle.backgroundColor;
  23261. tabBar2.borderStyle = tabBarStyle.borderStyle;
  23262. tabBar2.color = tabBarStyle.color;
  23263. tabBar2.selectedColor = tabBarStyle.selectedColor;
  23264. tabBar2.blurEffect = tabBarStyle.blurEffect;
  23265. if (tabBarStyle.list && tabBarStyle.list.length) {
  23266. tabBarStyle.list.forEach((item, index2) => {
  23267. tabBar2.list[index2].iconPath = item.iconPath;
  23268. tabBar2.list[index2].selectedIconPath = item.selectedIconPath;
  23269. });
  23270. }
  23271. });
  23272. useVisibleList(tabBar2, visibleList);
  23273. useTabBarCssVar(tabBar2);
  23274. const onSwitchTab = useSwitchTab(useRoute(), tabBar2, visibleList);
  23275. const {
  23276. style,
  23277. borderStyle,
  23278. placeholderStyle
  23279. } = useTabBarStyle(tabBar2);
  23280. onMounted(() => {
  23281. if (tabBar2.iconfontSrc) {
  23282. loadFontFace({
  23283. family: UNI_TABBAR_ICON_FONT,
  23284. source: `url("${tabBar2.iconfontSrc}")`
  23285. });
  23286. }
  23287. });
  23288. return () => {
  23289. const tabBarItemsTsx = createTabBarItemsTsx(tabBar2, onSwitchTab, visibleList);
  23290. return createVNode("uni-tabbar", {
  23291. "class": "uni-tabbar-" + tabBar2.position
  23292. }, [createVNode("div", {
  23293. "class": "uni-tabbar",
  23294. "style": style.value
  23295. }, [createVNode("div", {
  23296. "class": "uni-tabbar-border",
  23297. "style": borderStyle.value
  23298. }, null, 4), tabBarItemsTsx], 4), createVNode("div", {
  23299. "class": "uni-placeholder",
  23300. "style": placeholderStyle.value
  23301. }, null, 4)], 2);
  23302. };
  23303. }
  23304. });
  23305. function useTabBarCssVar(tabBar2) {
  23306. watch(() => tabBar2.shown, (value) => {
  23307. updatePageCssVar({
  23308. "--window-bottom": normalizeWindowBottom(value ? parseInt(tabBar2.height) : 0)
  23309. });
  23310. });
  23311. }
  23312. function useVisibleList(tabBar2, visibleList) {
  23313. const internalMidButton = ref(extend({
  23314. type: "midButton"
  23315. }, tabBar2.midButton));
  23316. function setVisibleList() {
  23317. let tempList = [];
  23318. tempList = tabBar2.list.filter((item) => item.visible !== false);
  23319. if (__UNI_FEATURE_TABBAR_MIDBUTTON__ && tabBar2.midButton) {
  23320. internalMidButton.value = extend({}, _middleButton, internalMidButton.value, tabBar2.midButton);
  23321. tempList = tempList.filter((item) => !isMidButton(item));
  23322. if (tempList.length % 2 === 0) {
  23323. tempList.splice(Math.floor(tempList.length / 2), 0, internalMidButton.value);
  23324. }
  23325. }
  23326. visibleList.value = tempList;
  23327. }
  23328. watchEffect(setVisibleList);
  23329. }
  23330. function useSwitchTab(route, tabBar2, visibleList) {
  23331. watchEffect(() => {
  23332. const meta = route.meta;
  23333. if (meta.isTabBar) {
  23334. const pagePath = meta.route;
  23335. const index2 = visibleList.value.findIndex((item) => item.pagePath === pagePath);
  23336. tabBar2.selectedIndex = index2;
  23337. }
  23338. });
  23339. return (tabBarItem, index2) => {
  23340. const {
  23341. type
  23342. } = tabBarItem;
  23343. return () => {
  23344. if (__UNI_FEATURE_TABBAR_MIDBUTTON__ && type === "midButton") {
  23345. return UniServiceJSBridge.invokeOnCallback(API_ON_TAB_BAR_MID_BUTTON_TAP);
  23346. }
  23347. const {
  23348. pagePath,
  23349. text: text2
  23350. } = tabBarItem;
  23351. let url = addLeadingSlash(pagePath);
  23352. if (url === __uniRoutes[0].alias) {
  23353. url = "/";
  23354. }
  23355. if (route.path !== url) {
  23356. uni.switchTab({
  23357. from: "tabBar",
  23358. url,
  23359. tabBarText: text2
  23360. });
  23361. } else {
  23362. invokeHook("onTabItemTap", {
  23363. index: index2,
  23364. text: text2,
  23365. pagePath
  23366. });
  23367. }
  23368. };
  23369. };
  23370. }
  23371. const DEFAULT_BG_COLOR = "#f7f7fa";
  23372. const BLUR_EFFECT_COLOR_DARK = "rgb(0, 0, 0, 0.8)";
  23373. const BLUR_EFFECT_COLOR_LIGHT = "rgb(250, 250, 250, 0.8)";
  23374. const BLUR_EFFECT_COLORS = {
  23375. dark: BLUR_EFFECT_COLOR_DARK,
  23376. light: BLUR_EFFECT_COLOR_LIGHT,
  23377. extralight: BLUR_EFFECT_COLOR_LIGHT
  23378. };
  23379. const BORDER_COLORS = {
  23380. white: "rgba(255, 255, 255, 0.33)",
  23381. black: "rgba(0, 0, 0, 0.33)"
  23382. };
  23383. function useTabBarStyle(tabBar2) {
  23384. const style = computed(() => {
  23385. let backgroundColor = tabBar2.backgroundColor;
  23386. const blurEffect = tabBar2.blurEffect;
  23387. if (!backgroundColor) {
  23388. if (cssBackdropFilter && blurEffect && blurEffect !== "none") {
  23389. backgroundColor = BLUR_EFFECT_COLORS[blurEffect];
  23390. }
  23391. }
  23392. return {
  23393. backgroundColor: backgroundColor || DEFAULT_BG_COLOR,
  23394. backdropFilter: blurEffect !== "none" ? "blur(10px)" : blurEffect
  23395. };
  23396. });
  23397. const borderStyle = computed(() => {
  23398. const {
  23399. borderStyle: borderStyle2
  23400. } = tabBar2;
  23401. return {
  23402. backgroundColor: BORDER_COLORS[borderStyle2] || borderStyle2
  23403. };
  23404. });
  23405. const placeholderStyle = computed(() => {
  23406. return {
  23407. height: tabBar2.height
  23408. };
  23409. });
  23410. return {
  23411. style,
  23412. borderStyle,
  23413. placeholderStyle
  23414. };
  23415. }
  23416. function isMidButton(item) {
  23417. return item.type === "midButton";
  23418. }
  23419. function createTabBarItemsTsx(tabBar2, onSwitchTab, visibleList) {
  23420. const {
  23421. selectedIndex,
  23422. selectedColor,
  23423. color
  23424. } = tabBar2;
  23425. return visibleList.value.map((item, index2) => {
  23426. const selected = selectedIndex === index2;
  23427. const textColor = selected ? selectedColor : color;
  23428. const iconPath = (selected ? item.selectedIconPath || item.iconPath : item.iconPath) || "";
  23429. const iconfontText = item.iconfont ? selected ? item.iconfont.selectedText || item.iconfont.text : item.iconfont.text : void 0;
  23430. const iconfontColor = item.iconfont ? selected ? item.iconfont.selectedColor || item.iconfont.color : item.iconfont.color : void 0;
  23431. if (!__UNI_FEATURE_TABBAR_MIDBUTTON__) {
  23432. return createTabBarItemTsx(textColor, iconPath, iconfontText, iconfontColor, item, tabBar2, index2, onSwitchTab);
  23433. }
  23434. return isMidButton(item) ? createTabBarMidButtonTsx(textColor, iconPath, iconfontText, iconfontColor, item, tabBar2, index2, onSwitchTab) : createTabBarItemTsx(textColor, iconPath, iconfontText, iconfontColor, item, tabBar2, index2, onSwitchTab);
  23435. });
  23436. }
  23437. function createTabBarItemTsx(color, iconPath, iconfontText, iconfontColor, tabBarItem, tabBar2, index2, onSwitchTab) {
  23438. return createVNode("div", {
  23439. "key": index2,
  23440. "class": "uni-tabbar__item",
  23441. "onClick": onSwitchTab(tabBarItem, index2)
  23442. }, [createTabBarItemBdTsx(color, iconPath || "", iconfontText, iconfontColor, tabBarItem, tabBar2)], 8, ["onClick"]);
  23443. }
  23444. function createTabBarItemBdTsx(color, iconPath, iconfontText, iconfontColor, tabBarItem, tabBar2) {
  23445. const {
  23446. height
  23447. } = tabBar2;
  23448. return createVNode("div", {
  23449. "class": "uni-tabbar__bd",
  23450. "style": {
  23451. height
  23452. }
  23453. }, [iconfontText ? createTabBarItemIconfontTsx(iconfontText, iconfontColor || BLUR_EFFECT_COLOR_DARK, tabBarItem, tabBar2) : iconPath && createTabBarItemIconTsx(iconPath, tabBarItem, tabBar2), tabBarItem.text && createTabBarItemTextTsx(color, tabBarItem, tabBar2), tabBarItem.redDot && createTabBarItemRedDotTsx(tabBarItem.badge)], 4);
  23454. }
  23455. function createTabBarItemIconTsx(iconPath, tabBarItem, tabBar2) {
  23456. const {
  23457. type,
  23458. text: text2
  23459. } = tabBarItem;
  23460. const {
  23461. iconWidth
  23462. } = tabBar2;
  23463. const clazz2 = "uni-tabbar__icon" + (text2 ? " uni-tabbar__icon__diff" : "");
  23464. const style = {
  23465. width: iconWidth,
  23466. height: iconWidth
  23467. };
  23468. return createVNode("div", {
  23469. "class": clazz2,
  23470. "style": style
  23471. }, [type !== "midButton" && createVNode("img", {
  23472. "src": getRealPath(iconPath)
  23473. }, null, 8, ["src"])], 6);
  23474. }
  23475. function createTabBarItemIconfontTsx(iconfontText, iconfontColor, tabBarItem, tabBar2) {
  23476. var _a;
  23477. const {
  23478. type,
  23479. text: text2
  23480. } = tabBarItem;
  23481. const {
  23482. iconWidth
  23483. } = tabBar2;
  23484. const clazz2 = "uni-tabbar__icon" + (text2 ? " uni-tabbar__icon__diff" : "");
  23485. const style = {
  23486. width: iconWidth,
  23487. height: iconWidth
  23488. };
  23489. const iconfontStyle = {
  23490. fontSize: ((_a = tabBarItem.iconfont) == null ? void 0 : _a.fontSize) || iconWidth,
  23491. color: iconfontColor
  23492. };
  23493. return createVNode("div", {
  23494. "class": clazz2,
  23495. "style": style
  23496. }, [type !== "midButton" && createVNode("div", {
  23497. "class": "uni-tabbar__iconfont",
  23498. "style": iconfontStyle
  23499. }, [iconfontText], 4)], 6);
  23500. }
  23501. function createTabBarItemTextTsx(color, tabBarItem, tabBar2) {
  23502. const {
  23503. iconPath,
  23504. text: text2
  23505. } = tabBarItem;
  23506. const {
  23507. fontSize,
  23508. spacing
  23509. } = tabBar2;
  23510. const style = {
  23511. color,
  23512. fontSize,
  23513. lineHeight: !iconPath ? 1.8 : "normal",
  23514. marginTop: !iconPath ? "inherit" : spacing
  23515. };
  23516. return createVNode("div", {
  23517. "class": "uni-tabbar__label",
  23518. "style": style
  23519. }, [text2], 4);
  23520. }
  23521. function createTabBarItemRedDotTsx(badge) {
  23522. const clazz2 = "uni-tabbar__reddot" + (badge ? " uni-tabbar__badge" : "");
  23523. return createVNode("div", {
  23524. "class": clazz2
  23525. }, [badge], 2);
  23526. }
  23527. function createTabBarMidButtonTsx(color, iconPath, iconfontText, iconfontColor, midButton, tabBar2, index2, onSwitchTab) {
  23528. const {
  23529. width,
  23530. height,
  23531. backgroundImage,
  23532. iconWidth
  23533. } = midButton;
  23534. return createVNode("div", {
  23535. "key": "midButton",
  23536. "class": "uni-tabbar__item",
  23537. "style": {
  23538. flex: "0 0 " + width,
  23539. position: "relative"
  23540. },
  23541. "onClick": onSwitchTab(midButton, index2)
  23542. }, [createVNode("div", {
  23543. "class": "uni-tabbar__mid",
  23544. "style": {
  23545. width,
  23546. height,
  23547. backgroundImage: backgroundImage ? "url('" + getRealPath(backgroundImage) + "')" : "none"
  23548. }
  23549. }, [iconPath && createVNode("img", {
  23550. "style": {
  23551. width: iconWidth,
  23552. height: iconWidth
  23553. },
  23554. "src": getRealPath(iconPath)
  23555. }, null, 12, ["src"])], 4), createTabBarItemBdTsx(color, iconPath, iconfontText, iconfontColor, midButton, tabBar2)], 12, ["onClick"]);
  23556. }
  23557. const DEFAULT_CSS_VAR_VALUE = "0px";
  23558. let globalLayoutState = void 0;
  23559. function getLayoutState() {
  23560. return globalLayoutState;
  23561. }
  23562. const LayoutComponent = /* @__PURE__ */ defineSystemComponent({
  23563. name: "Layout",
  23564. setup(_props, {
  23565. emit: emit2
  23566. }) {
  23567. const rootRef = ref(null);
  23568. initCssVar();
  23569. const keepAliveRoute = __UNI_FEATURE_PAGES__ && useKeepAliveRoute();
  23570. const {
  23571. layoutState,
  23572. windowState
  23573. } = useState();
  23574. useMaxWidth(layoutState, rootRef);
  23575. const topWindow = __UNI_FEATURE_TOPWINDOW__ && useTopWindow(layoutState);
  23576. const leftWindow = __UNI_FEATURE_LEFTWINDOW__ && useLeftWindow(layoutState);
  23577. const rightWindow = __UNI_FEATURE_RIGHTWINDOW__ && useRightWindow(layoutState);
  23578. const showTabBar2 = __UNI_FEATURE_TABBAR__ && useShowTabBar();
  23579. const clazz2 = useAppClass(showTabBar2);
  23580. globalLayoutState = layoutState;
  23581. return () => {
  23582. const layoutTsx = createLayoutTsx(keepAliveRoute, layoutState, windowState, topWindow, leftWindow, rightWindow);
  23583. const tabBarTsx = __UNI_FEATURE_TABBAR__ && createTabBarTsx(showTabBar2);
  23584. return createVNode("uni-app", {
  23585. "ref": rootRef,
  23586. "class": clazz2.value
  23587. }, [layoutTsx, tabBarTsx], 2);
  23588. };
  23589. }
  23590. });
  23591. function useAppClass(showTabBar2) {
  23592. const showMaxWidth = ref(false);
  23593. return computed(() => {
  23594. return {
  23595. "uni-app--showtabbar": showTabBar2 && showTabBar2.value,
  23596. "uni-app--maxwidth": showMaxWidth.value
  23597. };
  23598. });
  23599. }
  23600. function initCssVar() {
  23601. updateCssVar({
  23602. "--status-bar-height": DEFAULT_CSS_VAR_VALUE,
  23603. "--top-window-height": DEFAULT_CSS_VAR_VALUE,
  23604. "--window-left": DEFAULT_CSS_VAR_VALUE,
  23605. "--window-right": DEFAULT_CSS_VAR_VALUE,
  23606. "--window-margin": DEFAULT_CSS_VAR_VALUE,
  23607. "--tab-bar-height": DEFAULT_CSS_VAR_VALUE
  23608. });
  23609. }
  23610. function initMediaQuery(minWidth, callback) {
  23611. const mediaQueryList = window.matchMedia("(min-width: " + minWidth + "px)");
  23612. if (mediaQueryList.addEventListener) {
  23613. mediaQueryList.addEventListener("change", callback);
  23614. } else {
  23615. mediaQueryList.addListener(callback);
  23616. }
  23617. return mediaQueryList.matches;
  23618. }
  23619. function useMaxWidth(layoutState, rootRef) {
  23620. const route = usePageRoute();
  23621. function checkMaxWidth2() {
  23622. const windowWidth = document.body.clientWidth;
  23623. const pages = getCurrentPages();
  23624. let meta = {};
  23625. if (pages.length > 0) {
  23626. const curPage = pages[pages.length - 1];
  23627. meta = curPage.$page.meta;
  23628. } else {
  23629. const routeOptions = getRouteOptions(route.path, true);
  23630. if (routeOptions) {
  23631. meta = routeOptions.meta;
  23632. }
  23633. }
  23634. const maxWidth2 = parseInt(String((hasOwn(meta, "maxWidth") ? meta.maxWidth : __uniConfig.globalStyle.maxWidth) || Number.MAX_SAFE_INTEGER));
  23635. let showMaxWidth = false;
  23636. if (windowWidth > maxWidth2) {
  23637. showMaxWidth = true;
  23638. } else {
  23639. showMaxWidth = false;
  23640. }
  23641. if (showMaxWidth && maxWidth2) {
  23642. layoutState.marginWidth = (windowWidth - maxWidth2) / 2;
  23643. nextTick(() => {
  23644. const rootEl = rootRef.value;
  23645. if (rootEl) {
  23646. rootEl.setAttribute("style", "max-width:" + maxWidth2 + "px;margin:0 auto;");
  23647. }
  23648. });
  23649. } else {
  23650. layoutState.marginWidth = 0;
  23651. nextTick(() => {
  23652. const rootEl = rootRef.value;
  23653. if (rootEl) {
  23654. rootEl.removeAttribute("style");
  23655. }
  23656. });
  23657. }
  23658. }
  23659. watch([() => route.path], checkMaxWidth2);
  23660. onMounted(() => {
  23661. checkMaxWidth2();
  23662. window.addEventListener("resize", checkMaxWidth2);
  23663. });
  23664. }
  23665. function useState() {
  23666. const route = usePageRoute();
  23667. if (!__UNI_FEATURE_RESPONSIVE__) {
  23668. const layoutState2 = reactive({
  23669. marginWidth: 0,
  23670. leftWindowWidth: 0,
  23671. rightWindowWidth: 0
  23672. });
  23673. watch(() => layoutState2.marginWidth, (value) => updateCssVar({
  23674. "--window-margin": value + "px"
  23675. }));
  23676. watch(() => layoutState2.leftWindowWidth + layoutState2.marginWidth, (value) => {
  23677. updateCssVar({
  23678. "--window-left": value + "px"
  23679. });
  23680. });
  23681. watch(() => layoutState2.rightWindowWidth + layoutState2.marginWidth, (value) => {
  23682. updateCssVar({
  23683. "--window-right": value + "px"
  23684. });
  23685. });
  23686. return {
  23687. layoutState: layoutState2,
  23688. windowState: computed(() => ({}))
  23689. };
  23690. }
  23691. const topWindowMediaQuery = ref(false);
  23692. const leftWindowMediaQuery = ref(false);
  23693. const rightWindowMediaQuery = ref(false);
  23694. const showTopWindow2 = computed(() => __UNI_FEATURE_TOPWINDOW__ && route.meta.topWindow !== false && topWindowMediaQuery.value);
  23695. const showLeftWindow2 = computed(() => __UNI_FEATURE_LEFTWINDOW__ && route.meta.leftWindow !== false && leftWindowMediaQuery.value);
  23696. const showRightWindow2 = computed(() => __UNI_FEATURE_RIGHTWINDOW__ && route.meta.rightWindow !== false && rightWindowMediaQuery.value);
  23697. const layoutState = reactive({
  23698. topWindowMediaQuery,
  23699. showTopWindow: showTopWindow2,
  23700. apiShowTopWindow: false,
  23701. leftWindowMediaQuery,
  23702. showLeftWindow: showLeftWindow2,
  23703. apiShowLeftWindow: false,
  23704. rightWindowMediaQuery,
  23705. showRightWindow: showRightWindow2,
  23706. apiShowRightWindow: false,
  23707. topWindowHeight: 0,
  23708. marginWidth: 0,
  23709. leftWindowWidth: 0,
  23710. rightWindowWidth: 0,
  23711. navigationBarTitleText: "",
  23712. topWindowStyle: {},
  23713. leftWindowStyle: {},
  23714. rightWindowStyle: {}
  23715. });
  23716. const props2 = ["topWindow", "leftWindow", "rightWindow"];
  23717. props2.forEach((prop) => {
  23718. var _a;
  23719. const matchMedia = (_a = __uniConfig[prop]) == null ? void 0 : _a.matchMedia;
  23720. let topWindowMinWidth = RESPONSIVE_MIN_WIDTH;
  23721. if (matchMedia && hasOwn(matchMedia, "minWidth")) {
  23722. const minWidth = matchMedia.minWidth;
  23723. topWindowMinWidth = checkMinWidth(minWidth) ? minWidth : topWindowMinWidth;
  23724. }
  23725. const matches2 = initMediaQuery(topWindowMinWidth, (ev) => {
  23726. layoutState[`${prop}MediaQuery`] = ev.matches;
  23727. });
  23728. layoutState[`${prop}MediaQuery`] = matches2;
  23729. });
  23730. watch(() => layoutState.topWindowHeight, (value) => updateCssVar({
  23731. "--top-window-height": value + "px"
  23732. }));
  23733. watch(() => layoutState.marginWidth, (value) => updateCssVar({
  23734. "--window-margin": value + "px"
  23735. }));
  23736. watch(() => layoutState.leftWindowWidth + layoutState.marginWidth, (value) => {
  23737. updateCssVar({
  23738. "--window-left": value + "px"
  23739. });
  23740. });
  23741. watch(() => layoutState.rightWindowWidth + layoutState.marginWidth, (value) => {
  23742. updateCssVar({
  23743. "--window-right": value + "px"
  23744. });
  23745. });
  23746. UniServiceJSBridge.on(ON_NAVIGATION_BAR_CHANGE, (navigationBar) => {
  23747. layoutState.navigationBarTitleText = navigationBar.titleText;
  23748. });
  23749. const windowState = computed(() => ({
  23750. matchTopWindow: layoutState.topWindowMediaQuery,
  23751. showTopWindow: layoutState.showTopWindow || layoutState.apiShowTopWindow,
  23752. matchLeftWindow: layoutState.leftWindowMediaQuery,
  23753. showLeftWindow: layoutState.showLeftWindow || layoutState.apiShowLeftWindow,
  23754. matchRightWindow: layoutState.rightWindowMediaQuery,
  23755. showRightWindow: layoutState.showRightWindow || layoutState.apiShowRightWindow
  23756. }));
  23757. return {
  23758. layoutState,
  23759. windowState
  23760. };
  23761. }
  23762. function createLayoutTsx(keepAliveRoute, layoutState, windowState, topWindow, leftWindow, rightWindow) {
  23763. const routerVNode = __UNI_FEATURE_PAGES__ ? createRouterViewVNode(keepAliveRoute) : createPageVNode();
  23764. if (!__UNI_FEATURE_RESPONSIVE__) {
  23765. return routerVNode;
  23766. }
  23767. const topWindowTsx = __UNI_FEATURE_TOPWINDOW__ ? createTopWindowTsx(topWindow, layoutState, windowState.value) : null;
  23768. const leftWindowTsx = __UNI_FEATURE_LEFTWINDOW__ ? createLeftWindowTsx(leftWindow, layoutState, windowState.value) : null;
  23769. const rightWindowTsx = __UNI_FEATURE_RIGHTWINDOW__ ? createRightWindowTsx(rightWindow, layoutState, windowState.value) : null;
  23770. return createVNode("uni-layout", {
  23771. "class": {
  23772. "uni-app--showtopwindow": __UNI_FEATURE_TOPWINDOW__ && layoutState.showTopWindow,
  23773. "uni-app--showleftwindow": __UNI_FEATURE_LEFTWINDOW__ && layoutState.showLeftWindow,
  23774. "uni-app--showrightwindow": __UNI_FEATURE_RIGHTWINDOW__ && layoutState.showRightWindow
  23775. }
  23776. }, [topWindowTsx, createVNode("uni-content", null, [createVNode("uni-main", null, [routerVNode]), leftWindowTsx, rightWindowTsx])], 2);
  23777. }
  23778. function useShowTabBar(emit2) {
  23779. const route = usePageRoute();
  23780. const tabBar2 = useTabBar();
  23781. const showTabBar2 = computed(() => route.meta.isTabBar && tabBar2.shown);
  23782. updateCssVar({
  23783. "--tab-bar-height": tabBar2.height
  23784. });
  23785. return showTabBar2;
  23786. }
  23787. function createTabBarTsx(showTabBar2) {
  23788. return withDirectives(createVNode(TabBar, null, null, 512), [[vShow, showTabBar2.value]]);
  23789. }
  23790. function createPageVNode() {
  23791. return createVNode(__uniRoutes[0].component);
  23792. }
  23793. function createRouterViewVNode({
  23794. routeKey,
  23795. isTabBar,
  23796. routeCache: routeCache2
  23797. }) {
  23798. return createVNode(RouterView, null, {
  23799. default: withCtx(({
  23800. Component
  23801. }) => [(openBlock(), createBlock(KeepAlive, {
  23802. matchBy: "key",
  23803. cache: routeCache2
  23804. }, [(openBlock(), createBlock(resolveDynamicComponent(Component), {
  23805. type: isTabBar.value ? "tabBar" : "",
  23806. key: routeKey.value
  23807. }))], 1032, ["cache"]))]),
  23808. _: 1
  23809. /* STABLE */
  23810. });
  23811. }
  23812. function useTopWindow(layoutState) {
  23813. const {
  23814. component,
  23815. style
  23816. } = __uniConfig.topWindow;
  23817. const windowRef = ref(null);
  23818. function updateWindow() {
  23819. const instance2 = windowRef.value;
  23820. const el = resolveOwnerEl(instance2.$);
  23821. const height = el.getBoundingClientRect().height;
  23822. layoutState.topWindowHeight = height;
  23823. }
  23824. onMounted(updateWindow);
  23825. watch(() => layoutState.showTopWindow || layoutState.apiShowTopWindow, () => nextTick(updateWindow));
  23826. layoutState.topWindowStyle = style;
  23827. return {
  23828. component,
  23829. windowRef
  23830. };
  23831. }
  23832. function useLeftWindow(layoutState) {
  23833. const {
  23834. component,
  23835. style
  23836. } = __uniConfig.leftWindow;
  23837. const windowRef = ref(null);
  23838. function updateWindow() {
  23839. const instance2 = windowRef.value;
  23840. const el = resolveOwnerEl(instance2.$);
  23841. const width = el.getBoundingClientRect().width;
  23842. layoutState.leftWindowWidth = width;
  23843. }
  23844. onMounted(updateWindow);
  23845. watch(() => layoutState.showLeftWindow || layoutState.apiShowLeftWindow, () => nextTick(updateWindow));
  23846. layoutState.leftWindowStyle = style;
  23847. return {
  23848. component,
  23849. windowRef
  23850. };
  23851. }
  23852. function useRightWindow(layoutState) {
  23853. const {
  23854. component,
  23855. style
  23856. } = __uniConfig.rightWindow;
  23857. const windowRef = ref(null);
  23858. function updateWindow() {
  23859. const instance2 = windowRef.value;
  23860. const el = resolveOwnerEl(instance2.$);
  23861. const width = el.getBoundingClientRect().width;
  23862. layoutState.rightWindowWidth = width;
  23863. }
  23864. onMounted(updateWindow);
  23865. watch(() => layoutState.showRightWindow || layoutState.apiShowRightWindow, () => nextTick(updateWindow));
  23866. layoutState.rightWindowStyle = style;
  23867. return {
  23868. component,
  23869. windowRef
  23870. };
  23871. }
  23872. function createTopWindowTsx(topWindow, layoutState, windowState) {
  23873. if (topWindow) {
  23874. const {
  23875. component: TopWindow,
  23876. windowRef
  23877. } = topWindow;
  23878. return withDirectives(createVNode("uni-top-window", null, [createVNode("div", {
  23879. "class": "uni-top-window",
  23880. "style": layoutState.topWindowStyle
  23881. }, [createVNode(TopWindow, mergeProps({
  23882. "ref": windowRef,
  23883. "navigation-bar-title-text": layoutState.navigationBarTitleText
  23884. }, windowState), null, 16, ["navigation-bar-title-text"])], 4), createVNode("div", {
  23885. "class": "uni-top-window--placeholder",
  23886. "style": {
  23887. height: layoutState.topWindowHeight + "px"
  23888. }
  23889. }, null, 4)], 512), [[vShow, layoutState.showTopWindow || layoutState.apiShowTopWindow]]);
  23890. }
  23891. }
  23892. function createLeftWindowTsx(leftWindow, layoutState, windowState) {
  23893. if (leftWindow) {
  23894. const {
  23895. component: LeftWindow,
  23896. windowRef
  23897. } = leftWindow;
  23898. return withDirectives(createVNode("uni-left-window", {
  23899. "data-show": layoutState.apiShowLeftWindow || void 0,
  23900. "style": layoutState.leftWindowStyle
  23901. }, [layoutState.apiShowLeftWindow ? createVNode("div", {
  23902. "class": "uni-mask",
  23903. "onClick": () => layoutState.apiShowLeftWindow = false
  23904. }, null, 8, ["onClick"]) : null, createVNode("div", {
  23905. "class": "uni-left-window"
  23906. }, [createVNode(LeftWindow, mergeProps({
  23907. "ref": windowRef
  23908. }, windowState), null, 16)])], 12, ["data-show"]), [[vShow, layoutState.showLeftWindow || layoutState.apiShowLeftWindow]]);
  23909. }
  23910. }
  23911. function createRightWindowTsx(rightWindow, layoutState, windowState) {
  23912. if (rightWindow) {
  23913. const {
  23914. component: RightWindow,
  23915. windowRef
  23916. } = rightWindow;
  23917. return withDirectives(createVNode("uni-right-window", {
  23918. "data-show": layoutState.apiShowRightWindow || void 0,
  23919. "style": layoutState.rightWindowStyle
  23920. }, [layoutState.apiShowRightWindow ? createVNode("div", {
  23921. "class": "uni-mask",
  23922. "onClick": () => layoutState.apiShowRightWindow = false
  23923. }, null, 8, ["onClick"]) : null, createVNode("div", {
  23924. "class": "uni-right-window"
  23925. }, [createVNode(RightWindow, mergeProps({
  23926. "ref": windowRef
  23927. }, windowState), null, 16)])], 12, ["data-show"]), [[vShow, layoutState.showRightWindow || layoutState.apiShowRightWindow]]);
  23928. }
  23929. }
  23930. const showTopWindow = /* @__PURE__ */ defineAsyncApi(
  23931. "showTopWindow",
  23932. (_, { resolve, reject }) => {
  23933. const state2 = getLayoutState();
  23934. if (!state2) {
  23935. reject();
  23936. return;
  23937. }
  23938. state2.apiShowTopWindow = true;
  23939. nextTick(resolve);
  23940. }
  23941. );
  23942. const hideTopWindow = /* @__PURE__ */ defineAsyncApi(
  23943. "hideTopWindow",
  23944. (_, { resolve, reject }) => {
  23945. const state2 = getLayoutState();
  23946. if (!state2) {
  23947. reject();
  23948. return;
  23949. }
  23950. state2.apiShowTopWindow = false;
  23951. nextTick(resolve);
  23952. }
  23953. );
  23954. const showLeftWindow = /* @__PURE__ */ defineAsyncApi(
  23955. "showLeftWindow",
  23956. (_, { resolve, reject }) => {
  23957. const state2 = getLayoutState();
  23958. if (!state2) {
  23959. reject();
  23960. return;
  23961. }
  23962. state2.apiShowLeftWindow = true;
  23963. nextTick(resolve);
  23964. }
  23965. );
  23966. const hideLeftWindow = /* @__PURE__ */ defineAsyncApi(
  23967. "hideLeftWindow",
  23968. (_, { resolve, reject }) => {
  23969. const state2 = getLayoutState();
  23970. if (!state2) {
  23971. reject();
  23972. return;
  23973. }
  23974. state2.apiShowLeftWindow = false;
  23975. nextTick(resolve);
  23976. }
  23977. );
  23978. const showRightWindow = /* @__PURE__ */ defineAsyncApi(
  23979. "showRightWindow",
  23980. (_, { resolve, reject }) => {
  23981. const state2 = getLayoutState();
  23982. if (!state2) {
  23983. reject();
  23984. return;
  23985. }
  23986. state2.apiShowRightWindow = true;
  23987. nextTick(resolve);
  23988. }
  23989. );
  23990. const hideRightWindow = /* @__PURE__ */ defineAsyncApi(
  23991. "hideRightWindow",
  23992. (_, { resolve, reject }) => {
  23993. const state2 = getLayoutState();
  23994. if (!state2) {
  23995. reject();
  23996. return;
  23997. }
  23998. state2.apiShowRightWindow = false;
  23999. nextTick(resolve);
  24000. }
  24001. );
  24002. const getTopWindowStyle = /* @__PURE__ */ defineSyncApi(
  24003. "getTopWindowStyle",
  24004. () => {
  24005. const state2 = getLayoutState();
  24006. return extend({}, state2 && state2.topWindowStyle);
  24007. }
  24008. );
  24009. const setTopWindowStyle = /* @__PURE__ */ defineSyncApi(
  24010. "setTopWindowStyle",
  24011. (style) => {
  24012. const state2 = getLayoutState();
  24013. if (state2) {
  24014. state2.topWindowStyle = style;
  24015. }
  24016. }
  24017. );
  24018. const getLeftWindowStyle = /* @__PURE__ */ defineSyncApi(
  24019. "getLeftWindowStyle",
  24020. () => {
  24021. const state2 = getLayoutState();
  24022. return extend({}, state2 && state2.leftWindowStyle);
  24023. }
  24024. );
  24025. const setLeftWindowStyle = /* @__PURE__ */ defineSyncApi(
  24026. "setLeftWindowStyle",
  24027. (style) => {
  24028. const state2 = getLayoutState();
  24029. if (state2) {
  24030. state2.leftWindowStyle = style;
  24031. }
  24032. }
  24033. );
  24034. const getRightWindowStyle = /* @__PURE__ */ defineSyncApi("getRightWindowStyle", () => {
  24035. const state2 = getLayoutState();
  24036. return extend({}, state2 && state2.rightWindowStyle);
  24037. });
  24038. const setRightWindowStyle = /* @__PURE__ */ defineSyncApi("setRightWindowStyle", (style) => {
  24039. const state2 = getLayoutState();
  24040. if (state2) {
  24041. state2.rightWindowStyle = style;
  24042. }
  24043. });
  24044. const getElementById = /* @__PURE__ */ defineSyncApi(
  24045. "getElementById",
  24046. (id2) => {
  24047. const uniPageBody = document.querySelector("uni-page-body");
  24048. return uniPageBody ? uniPageBody.querySelector(`#${id2}`) : null;
  24049. }
  24050. );
  24051. const saveImageToPhotosAlbum = /* @__PURE__ */ defineAsyncApi(
  24052. API_SAVE_IMAGE_TO_PHOTOS_ALBUM,
  24053. createUnsupportedAsyncApi(API_SAVE_IMAGE_TO_PHOTOS_ALBUM)
  24054. );
  24055. const API_GET_RECORDER_MANAGER = "getRecorderManager";
  24056. const getRecorderManager = /* @__PURE__ */ defineSyncApi(
  24057. API_GET_RECORDER_MANAGER,
  24058. createUnsupportedSyncApi(API_GET_RECORDER_MANAGER)
  24059. );
  24060. const saveVideoToPhotosAlbum = /* @__PURE__ */ defineAsyncApi(
  24061. API_SAVE_VIDEO_TO_PHOTOS_ALBUM,
  24062. createUnsupportedAsyncApi(API_SAVE_VIDEO_TO_PHOTOS_ALBUM)
  24063. );
  24064. const API_CREATE_CAMERA_CONTEXT = "createCameraContext";
  24065. const createCameraContext = /* @__PURE__ */ defineSyncApi(
  24066. API_CREATE_CAMERA_CONTEXT,
  24067. createUnsupportedSyncApi(API_CREATE_CAMERA_CONTEXT)
  24068. );
  24069. const API_CREATE_LIVE_PLAYER_CONTEXT = "createLivePlayerContext";
  24070. const createLivePlayerContext = /* @__PURE__ */ defineSyncApi(
  24071. API_CREATE_LIVE_PLAYER_CONTEXT,
  24072. createUnsupportedSyncApi(API_CREATE_LIVE_PLAYER_CONTEXT)
  24073. );
  24074. const API_SAVE_FILE = "saveFile";
  24075. const saveFile = /* @__PURE__ */ defineAsyncApi(
  24076. API_SAVE_FILE,
  24077. createUnsupportedAsyncApi(API_SAVE_FILE)
  24078. );
  24079. const API_GET_SAVED_FILE_LIST = "getSavedFileList";
  24080. const getSavedFileList = /* @__PURE__ */ defineAsyncApi(
  24081. API_GET_SAVED_FILE_LIST,
  24082. createUnsupportedAsyncApi(API_GET_SAVED_FILE_LIST)
  24083. );
  24084. const API_GET_SAVED_FILE_INFO = "getSavedFileInfo";
  24085. const getSavedFileInfo = /* @__PURE__ */ defineAsyncApi(
  24086. API_GET_SAVED_FILE_INFO,
  24087. createUnsupportedAsyncApi(API_GET_SAVED_FILE_INFO)
  24088. );
  24089. const API_REMOVE_SAVED_FILE = "removeSavedFile";
  24090. const removeSavedFile = /* @__PURE__ */ defineAsyncApi(
  24091. API_REMOVE_SAVED_FILE,
  24092. createUnsupportedAsyncApi(API_REMOVE_SAVED_FILE)
  24093. );
  24094. const API_ON_MEMORY_WARNING = "onMemoryWarning";
  24095. const onMemoryWarning = /* @__PURE__ */ defineOnApi(
  24096. API_ON_MEMORY_WARNING,
  24097. createUnsupportedOnApi(API_ON_MEMORY_WARNING)
  24098. );
  24099. const API_ON_GYROSCOPE_CHANGE = "onGyroscopeChange";
  24100. const onGyroscopeChange = /* @__PURE__ */ defineOnApi(
  24101. API_ON_GYROSCOPE_CHANGE,
  24102. createUnsupportedOnApi(API_ON_GYROSCOPE_CHANGE)
  24103. );
  24104. const API_START_GYROSCOPE = "startGyroscope";
  24105. const startGyroscope = /* @__PURE__ */ defineAsyncApi(
  24106. API_START_GYROSCOPE,
  24107. createUnsupportedAsyncApi(API_START_GYROSCOPE)
  24108. );
  24109. const API_STOP_GYROSCOPE = "stopGyroscope";
  24110. const stopGyroscope = /* @__PURE__ */ defineAsyncApi(
  24111. API_STOP_GYROSCOPE,
  24112. createUnsupportedAsyncApi(API_STOP_GYROSCOPE)
  24113. );
  24114. const API_SCAN_CODE = "scanCode";
  24115. const scanCode = /* @__PURE__ */ defineAsyncApi(
  24116. API_SCAN_CODE,
  24117. createUnsupportedAsyncApi(API_SCAN_CODE)
  24118. );
  24119. const API_SET_SCREEN_BRIGHTNESS = "setScreenBrightness";
  24120. const setScreenBrightness = /* @__PURE__ */ defineAsyncApi(
  24121. API_SET_SCREEN_BRIGHTNESS,
  24122. createUnsupportedAsyncApi(API_SET_SCREEN_BRIGHTNESS)
  24123. );
  24124. const API_GET_SCREEN_BRIGHTNESS = "getScreenBrightness";
  24125. const getScreenBrightness = /* @__PURE__ */ defineAsyncApi(
  24126. API_GET_SCREEN_BRIGHTNESS,
  24127. createUnsupportedAsyncApi(API_GET_SCREEN_BRIGHTNESS)
  24128. );
  24129. const API_SET_KEEP_SCREEN_ON = "setKeepScreenOn";
  24130. const setKeepScreenOn = /* @__PURE__ */ defineAsyncApi(
  24131. API_SET_KEEP_SCREEN_ON,
  24132. createUnsupportedAsyncApi(API_SET_KEEP_SCREEN_ON)
  24133. );
  24134. const API_ON_USER_CAPTURE_SCREEN = "onUserCaptureScreen";
  24135. const onUserCaptureScreen = /* @__PURE__ */ defineOnApi(
  24136. API_ON_USER_CAPTURE_SCREEN,
  24137. createUnsupportedOnApi(API_ON_USER_CAPTURE_SCREEN)
  24138. );
  24139. const API_ADD_PHONE_CONTACT = "addPhoneContact";
  24140. const addPhoneContact = /* @__PURE__ */ defineAsyncApi(
  24141. API_ADD_PHONE_CONTACT,
  24142. createUnsupportedAsyncApi(API_ADD_PHONE_CONTACT)
  24143. );
  24144. const API_LOGIN = "login";
  24145. const login = /* @__PURE__ */ defineAsyncApi(
  24146. API_LOGIN,
  24147. createUnsupportedAsyncApi(API_LOGIN)
  24148. );
  24149. const API_GET_PROVIDER = "getProvider";
  24150. const getProvider = /* @__PURE__ */ defineAsyncApi(
  24151. API_GET_PROVIDER,
  24152. createUnsupportedAsyncApi(API_GET_PROVIDER)
  24153. );
  24154. const api = /* @__PURE__ */ Object.defineProperty({
  24155. __proto__: null,
  24156. $emit,
  24157. $off,
  24158. $on,
  24159. $once,
  24160. addInterceptor,
  24161. addPhoneContact,
  24162. arrayBufferToBase64,
  24163. base64ToArrayBuffer,
  24164. canIUse,
  24165. canvasGetImageData,
  24166. canvasPutImageData,
  24167. canvasToTempFilePath,
  24168. chooseFile,
  24169. chooseImage,
  24170. chooseLocation,
  24171. chooseVideo,
  24172. clearStorage,
  24173. clearStorageSync,
  24174. closePreviewImage,
  24175. closeSocket,
  24176. connectSocket,
  24177. createAnimation: createAnimation$1,
  24178. createCameraContext,
  24179. createCanvasContext,
  24180. createInnerAudioContext,
  24181. createIntersectionObserver,
  24182. createLivePlayerContext,
  24183. createMapContext,
  24184. createMediaQueryObserver,
  24185. createSelectorQuery,
  24186. createVideoContext,
  24187. cssBackdropFilter,
  24188. cssConstant,
  24189. cssEnv,
  24190. cssVar,
  24191. downloadFile,
  24192. getAppBaseInfo,
  24193. getClipboardData,
  24194. getDeviceInfo,
  24195. getElementById,
  24196. getEnterOptionsSync,
  24197. getFileInfo,
  24198. getImageInfo,
  24199. getLaunchOptionsSync,
  24200. getLeftWindowStyle,
  24201. getLocale,
  24202. getLocation,
  24203. getNetworkType,
  24204. getProvider,
  24205. getPushClientId,
  24206. getRecorderManager,
  24207. getRightWindowStyle,
  24208. getSavedFileInfo,
  24209. getSavedFileList,
  24210. getScreenBrightness,
  24211. getSelectedTextRange: getSelectedTextRange$1,
  24212. getStorage,
  24213. getStorageInfo,
  24214. getStorageInfoSync,
  24215. getStorageSync,
  24216. getSystemInfo,
  24217. getSystemInfoSync,
  24218. getTopWindowStyle,
  24219. getVideoInfo,
  24220. getWindowInfo,
  24221. hideActionSheet,
  24222. hideKeyboard,
  24223. hideLeftWindow,
  24224. hideLoading,
  24225. hideModal,
  24226. hideNavigationBarLoading,
  24227. hideRightWindow,
  24228. hideTabBar,
  24229. hideTabBarRedDot,
  24230. hideToast,
  24231. hideTopWindow,
  24232. interceptors,
  24233. invokePushCallback,
  24234. loadFontFace,
  24235. login,
  24236. makePhoneCall,
  24237. navigateBack,
  24238. navigateTo,
  24239. offAccelerometerChange,
  24240. offAppHide,
  24241. offAppShow,
  24242. offCompassChange,
  24243. offError,
  24244. offLocationChange,
  24245. offLocationChangeError,
  24246. offNetworkStatusChange,
  24247. offPageNotFound,
  24248. offPushMessage,
  24249. offThemeChange,
  24250. offUnhandledRejection,
  24251. offWindowResize,
  24252. onAccelerometerChange,
  24253. onAppHide,
  24254. onAppShow,
  24255. onCompassChange,
  24256. onCreateVueApp,
  24257. onError,
  24258. onGyroscopeChange,
  24259. onLocaleChange,
  24260. onLocationChange,
  24261. onLocationChangeError,
  24262. onMemoryWarning,
  24263. onNetworkStatusChange,
  24264. onPageNotFound,
  24265. onPushMessage,
  24266. onSocketClose,
  24267. onSocketError,
  24268. onSocketMessage,
  24269. onSocketOpen,
  24270. onTabBarMidButtonTap,
  24271. onThemeChange,
  24272. onUnhandledRejection,
  24273. onUserCaptureScreen,
  24274. onWindowResize,
  24275. openDocument,
  24276. openLocation,
  24277. pageScrollTo,
  24278. preloadPage,
  24279. previewImage,
  24280. reLaunch,
  24281. redirectTo,
  24282. removeInterceptor,
  24283. removeSavedFile,
  24284. removeStorage,
  24285. removeStorageSync,
  24286. removeTabBarBadge,
  24287. request,
  24288. rpx2px: upx2px,
  24289. saveFile,
  24290. saveImageToPhotosAlbum,
  24291. saveVideoToPhotosAlbum,
  24292. scanCode,
  24293. sendSocketMessage,
  24294. setClipboardData,
  24295. setKeepScreenOn,
  24296. setLeftWindowStyle,
  24297. setLocale,
  24298. setNavigationBarColor,
  24299. setNavigationBarTitle,
  24300. setPageMeta,
  24301. setRightWindowStyle,
  24302. setScreenBrightness,
  24303. setStorage,
  24304. setStorageSync,
  24305. setTabBarBadge,
  24306. setTabBarItem,
  24307. setTabBarStyle,
  24308. setTopWindowStyle,
  24309. showActionSheet,
  24310. showLeftWindow,
  24311. showLoading,
  24312. showModal,
  24313. showNavigationBarLoading,
  24314. showRightWindow,
  24315. showTabBar,
  24316. showTabBarRedDot,
  24317. showToast,
  24318. showTopWindow,
  24319. startAccelerometer,
  24320. startCompass,
  24321. startGyroscope,
  24322. startLocationUpdate,
  24323. startPullDownRefresh,
  24324. stopAccelerometer,
  24325. stopCompass,
  24326. stopGyroscope,
  24327. stopLocationUpdate,
  24328. stopPullDownRefresh,
  24329. switchTab,
  24330. uploadFile,
  24331. upx2px,
  24332. vibrateLong,
  24333. vibrateShort
  24334. }, Symbol.toStringTag, { value: "Module" });
  24335. const CONTEXT_ID = "MAP_LOCATION";
  24336. const MapLocation = /* @__PURE__ */ defineSystemComponent({
  24337. name: "MapLocation",
  24338. setup() {
  24339. const state2 = reactive({
  24340. latitude: 0,
  24341. longitude: 0,
  24342. rotate: 0
  24343. });
  24344. {
  24345. let compassChangeHandler = function(res) {
  24346. state2.rotate = res.direction;
  24347. }, updateLocation = function() {
  24348. getLocation({
  24349. type: "gcj02",
  24350. success: (res) => {
  24351. state2.latitude = res.latitude;
  24352. state2.longitude = res.longitude;
  24353. },
  24354. complete: () => {
  24355. timer = setTimeout(updateLocation, 3e4);
  24356. }
  24357. });
  24358. }, removeLocation = function() {
  24359. if (timer) {
  24360. clearTimeout(timer);
  24361. }
  24362. offCompassChange(compassChangeHandler);
  24363. };
  24364. const onMapReady = inject("onMapReady");
  24365. let timer;
  24366. onCompassChange(compassChangeHandler);
  24367. onMapReady(updateLocation);
  24368. onUnmounted(removeLocation);
  24369. const addMapChidlContext = inject("addMapChidlContext");
  24370. const removeMapChidlContext = inject("removeMapChidlContext");
  24371. const context = {
  24372. id: CONTEXT_ID,
  24373. state: state2
  24374. };
  24375. addMapChidlContext(context);
  24376. onUnmounted(() => removeMapChidlContext(context));
  24377. }
  24378. return () => {
  24379. return state2.latitude ? createVNode(MapMarker, mergeProps({
  24380. "anchor": {
  24381. x: 0.5,
  24382. y: 0.5
  24383. },
  24384. "width": "44",
  24385. "height": "44",
  24386. "iconPath": ICON_PATH_ORIGIN
  24387. }, state2), null, 16, ["iconPath"]) : null;
  24388. };
  24389. }
  24390. });
  24391. const props$3 = {
  24392. // 边框虚线,腾讯地图支持,google 高德 地图不支持,默认值为[0, 0] 为实线,非 [0, 0] 为虚线,H5 端无法像微信小程序一样控制虚线的间隔像素大小
  24393. dashArray: {
  24394. type: Array,
  24395. default: () => [0, 0]
  24396. },
  24397. // 经纬度数组,[{latitude: 0, longitude: 0}]
  24398. points: {
  24399. type: Array,
  24400. required: true
  24401. },
  24402. // 描边的宽度
  24403. strokeWidth: {
  24404. type: Number,
  24405. default: 1
  24406. },
  24407. // 描边的颜色,十六进制
  24408. strokeColor: {
  24409. type: String,
  24410. default: "#000000"
  24411. },
  24412. // 填充颜色,十六进制
  24413. fillColor: {
  24414. type: String,
  24415. default: "#00000000"
  24416. },
  24417. // 设置多边形 Z 轴数值
  24418. zIndex: {
  24419. type: Number,
  24420. default: 0
  24421. }
  24422. };
  24423. const MapPolygon = /* @__PURE__ */ defineSystemComponent({
  24424. name: "MapPolygon",
  24425. props: props$3,
  24426. setup(props2) {
  24427. let polygonIns;
  24428. const onMapReady = inject("onMapReady");
  24429. onMapReady((map, maps2, trigger) => {
  24430. function drawPolygon() {
  24431. const {
  24432. points,
  24433. strokeWidth,
  24434. strokeColor,
  24435. dashArray,
  24436. fillColor,
  24437. zIndex
  24438. } = props2;
  24439. const path = points.map((item) => {
  24440. const {
  24441. latitude,
  24442. longitude
  24443. } = item;
  24444. if (getIsAMap()) {
  24445. return [longitude, latitude];
  24446. } else if (getIsBMap()) {
  24447. return new maps2.Point(longitude, latitude);
  24448. } else {
  24449. return new maps2.LatLng(latitude, longitude);
  24450. }
  24451. });
  24452. const {
  24453. r: fcR,
  24454. g: fcG,
  24455. b: fcB,
  24456. a: fcA
  24457. } = hexToRgba(fillColor);
  24458. const {
  24459. r: scR,
  24460. g: scG,
  24461. b: scB,
  24462. a: scA
  24463. } = hexToRgba(strokeColor);
  24464. const polygonOptions = {
  24465. //多边形是否可点击。
  24466. clickable: true,
  24467. //鼠标在多边形内的光标样式。
  24468. cursor: "crosshair",
  24469. //多边形是否可编辑。
  24470. editable: false,
  24471. // 地图实例,即要显示多边形的地图
  24472. // @ts-ignore
  24473. map,
  24474. // 区域填充色
  24475. fillColor: "",
  24476. //多边形的路径,以经纬度坐标数组构成。
  24477. path,
  24478. // 区域边框
  24479. strokeColor: "",
  24480. //多边形的边框样式。实线是solid,虚线是dash。
  24481. strokeDashStyle: dashArray.some((item) => item > 0) ? "dash" : "solid",
  24482. //多边形的边框线宽。
  24483. strokeWeight: strokeWidth,
  24484. //多边形是否可见。
  24485. visible: true,
  24486. //多边形的zIndex值。
  24487. zIndex
  24488. };
  24489. if (maps2.Color) {
  24490. polygonOptions.fillColor = new maps2.Color(fcR, fcG, fcB, fcA);
  24491. polygonOptions.strokeColor = new maps2.Color(scR, scG, scB, scA);
  24492. } else {
  24493. polygonOptions.fillColor = `rgb(${fcR}, ${fcG}, ${fcB})`;
  24494. polygonOptions.fillOpacity = fcA;
  24495. polygonOptions.strokeColor = `rgb(${scR}, ${scG}, ${scB})`;
  24496. polygonOptions.strokeOpacity = scA;
  24497. }
  24498. if (polygonIns) {
  24499. polygonIns.setOptions(polygonOptions);
  24500. return;
  24501. }
  24502. if (getIsBMap()) {
  24503. polygonIns = new maps2.Polygon(polygonOptions.path, polygonOptions);
  24504. map.addOverlay(polygonIns);
  24505. } else {
  24506. polygonIns = new maps2.Polygon(polygonOptions);
  24507. }
  24508. }
  24509. drawPolygon();
  24510. watch(props2, drawPolygon);
  24511. });
  24512. onUnmounted(() => {
  24513. polygonIns.setMap(null);
  24514. });
  24515. return () => null;
  24516. }
  24517. });
  24518. const props$2 = {
  24519. id: {
  24520. type: String,
  24521. default: ""
  24522. },
  24523. latitude: {
  24524. type: [String, Number],
  24525. default: 0
  24526. },
  24527. longitude: {
  24528. type: [String, Number],
  24529. default: 0
  24530. },
  24531. scale: {
  24532. type: [String, Number],
  24533. default: 16
  24534. },
  24535. markers: {
  24536. type: Array,
  24537. default() {
  24538. return [];
  24539. }
  24540. },
  24541. includePoints: {
  24542. type: Array,
  24543. default() {
  24544. return [];
  24545. }
  24546. },
  24547. polyline: {
  24548. type: Array,
  24549. default() {
  24550. return [];
  24551. }
  24552. },
  24553. circles: {
  24554. type: Array,
  24555. default() {
  24556. return [];
  24557. }
  24558. },
  24559. controls: {
  24560. type: Array,
  24561. default() {
  24562. return [];
  24563. }
  24564. },
  24565. showLocation: {
  24566. type: [Boolean, String],
  24567. default: false
  24568. },
  24569. libraries: {
  24570. type: Array,
  24571. default() {
  24572. return [];
  24573. }
  24574. },
  24575. polygons: {
  24576. type: Array,
  24577. default: () => []
  24578. }
  24579. };
  24580. function getPoints(points) {
  24581. const newPoints = [];
  24582. if (isArray(points)) {
  24583. points.forEach((point) => {
  24584. if (point && point.latitude && point.longitude) {
  24585. newPoints.push({
  24586. latitude: point.latitude,
  24587. longitude: point.longitude
  24588. });
  24589. }
  24590. });
  24591. }
  24592. return newPoints;
  24593. }
  24594. function getAMapPosition(maps2, latitude, longitude) {
  24595. return new maps2.LngLat(longitude, latitude);
  24596. }
  24597. function getBMapPosition(maps2, latitude, longitude) {
  24598. return new maps2.Point(longitude, latitude);
  24599. }
  24600. function getGoogleOrQQMapPosition(maps2, latitude, longitude) {
  24601. return new maps2.LatLng(latitude, longitude);
  24602. }
  24603. function getMapPosition(maps2, latitude, longitude) {
  24604. if (getIsBMap()) {
  24605. return getBMapPosition(maps2, latitude, longitude);
  24606. } else if (getIsAMap()) {
  24607. return getAMapPosition(maps2, latitude, longitude);
  24608. } else {
  24609. return getGoogleOrQQMapPosition(maps2, latitude, longitude);
  24610. }
  24611. }
  24612. function getLat(latLng) {
  24613. if ("getLat" in latLng) {
  24614. return latLng.getLat();
  24615. } else {
  24616. if (getIsBMap()) {
  24617. return latLng.lat;
  24618. }
  24619. return latLng.lat();
  24620. }
  24621. }
  24622. function getLng(latLng) {
  24623. if ("getLng" in latLng) {
  24624. return latLng.getLng();
  24625. } else {
  24626. if (getIsBMap()) {
  24627. return latLng.lng;
  24628. }
  24629. return latLng.lng();
  24630. }
  24631. }
  24632. function useMap(props2, rootRef, emit2) {
  24633. const trigger = useCustomEvent(rootRef, emit2);
  24634. const mapRef = ref(null);
  24635. let maps2;
  24636. let map;
  24637. const state2 = reactive({
  24638. latitude: Number(props2.latitude),
  24639. longitude: Number(props2.longitude),
  24640. includePoints: getPoints(props2.includePoints)
  24641. });
  24642. const onMapReadyCallbacks = [];
  24643. let isMapReady;
  24644. function onMapReady(callback) {
  24645. if (isMapReady) {
  24646. callback(map, maps2, trigger);
  24647. } else {
  24648. onMapReadyCallbacks.push(callback);
  24649. }
  24650. }
  24651. function emitMapReady() {
  24652. isMapReady = true;
  24653. onMapReadyCallbacks.forEach((callback) => callback(map, maps2, trigger));
  24654. onMapReadyCallbacks.length = 0;
  24655. }
  24656. let isBoundsReady;
  24657. const onBoundsReadyCallbacks = [];
  24658. function onBoundsReady(callback) {
  24659. if (isBoundsReady) {
  24660. callback();
  24661. } else {
  24662. onMapReadyCallbacks.push(callback);
  24663. }
  24664. }
  24665. const contexts = {};
  24666. function addMapChidlContext(context) {
  24667. contexts[context.id] = context;
  24668. }
  24669. function removeMapChidlContext(context) {
  24670. delete contexts[context.id];
  24671. }
  24672. watch([() => props2.latitude, () => props2.longitude], ([latitudeVlaue, longitudeVlaue]) => {
  24673. const latitude = Number(latitudeVlaue);
  24674. const longitude = Number(longitudeVlaue);
  24675. if (latitude !== state2.latitude || longitude !== state2.longitude) {
  24676. state2.latitude = latitude;
  24677. state2.longitude = longitude;
  24678. if (map) {
  24679. const centerPosition = getMapPosition(maps2, state2.latitude, state2.longitude);
  24680. map.setCenter(centerPosition);
  24681. }
  24682. }
  24683. });
  24684. watch(() => props2.includePoints, (points) => {
  24685. state2.includePoints = getPoints(points);
  24686. if (isBoundsReady) {
  24687. updateBounds();
  24688. }
  24689. }, {
  24690. deep: true
  24691. });
  24692. function emitBoundsReady() {
  24693. isBoundsReady = true;
  24694. onBoundsReadyCallbacks.forEach((callback) => callback());
  24695. onBoundsReadyCallbacks.length = 0;
  24696. }
  24697. function getMapInfo2() {
  24698. const center = map.getCenter();
  24699. return {
  24700. scale: map.getZoom(),
  24701. centerLocation: {
  24702. latitude: getLat(center),
  24703. longitude: getLng(center)
  24704. }
  24705. };
  24706. }
  24707. function updateCenter() {
  24708. const centerPosition = getMapPosition(maps2, state2.latitude, state2.longitude);
  24709. map.setCenter(centerPosition);
  24710. }
  24711. function updateBounds() {
  24712. if (getIsAMap()) {
  24713. const points = [];
  24714. state2.includePoints.forEach((point) => {
  24715. points.push([point.longitude, point.latitude]);
  24716. });
  24717. const bounds = new maps2.Bounds(...points);
  24718. map.setBounds(bounds);
  24719. } else if (getIsBMap())
  24720. ;
  24721. else {
  24722. const bounds = new maps2.LatLngBounds();
  24723. state2.includePoints.forEach(({
  24724. latitude,
  24725. longitude
  24726. }) => {
  24727. const latLng = new maps2.LatLng(latitude, longitude);
  24728. bounds.extend(latLng);
  24729. });
  24730. map.fitBounds(bounds);
  24731. }
  24732. }
  24733. function initMap() {
  24734. const mapEl = mapRef.value;
  24735. const center = getMapPosition(maps2, state2.latitude, state2.longitude);
  24736. const event = maps2.event || maps2.Event;
  24737. const map2 = new maps2.Map(mapEl, {
  24738. center,
  24739. zoom: Number(props2.scale),
  24740. // scrollwheel: false,
  24741. disableDoubleClickZoom: true,
  24742. mapTypeControl: false,
  24743. zoomControl: false,
  24744. scaleControl: false,
  24745. panControl: false,
  24746. fullscreenControl: false,
  24747. streetViewControl: false,
  24748. keyboardShortcuts: false,
  24749. minZoom: 5,
  24750. maxZoom: 18,
  24751. draggable: true
  24752. });
  24753. if (getIsBMap()) {
  24754. map2.centerAndZoom(center, Number(props2.scale));
  24755. map2.enableScrollWheelZoom();
  24756. map2._printLog && map2._printLog("uniapp");
  24757. }
  24758. watch(() => props2.scale, (scale) => {
  24759. map2.setZoom(Number(scale) || 16);
  24760. });
  24761. onBoundsReady(() => {
  24762. if (state2.includePoints.length) {
  24763. updateBounds();
  24764. updateCenter();
  24765. }
  24766. });
  24767. if (getIsBMap()) {
  24768. map2.addEventListener("click", () => {
  24769. trigger("tap", {}, {});
  24770. trigger("click", {}, {});
  24771. });
  24772. map2.addEventListener("dragstart", () => {
  24773. trigger("regionchange", {}, {
  24774. type: "begin",
  24775. causedBy: "gesture"
  24776. });
  24777. });
  24778. map2.addEventListener("dragend", () => {
  24779. trigger("regionchange", {}, extend({
  24780. type: "end",
  24781. causedBy: "drag"
  24782. }, getMapInfo2()));
  24783. });
  24784. } else {
  24785. const boundsChangedEvent = event.addListener(map2, "bounds_changed", () => {
  24786. boundsChangedEvent.remove();
  24787. emitBoundsReady();
  24788. });
  24789. event.addListener(map2, "click", () => {
  24790. trigger("tap", {}, {});
  24791. trigger("click", {}, {});
  24792. });
  24793. event.addListener(map2, "dragstart", () => {
  24794. trigger("regionchange", {}, {
  24795. type: "begin",
  24796. causedBy: "gesture"
  24797. });
  24798. });
  24799. event.addListener(map2, "dragend", () => {
  24800. trigger("regionchange", {}, extend({
  24801. type: "end",
  24802. causedBy: "drag"
  24803. }, getMapInfo2()));
  24804. });
  24805. const zoomChangedCallback = () => {
  24806. emit2("update:scale", map2.getZoom());
  24807. trigger("regionchange", {}, extend({
  24808. type: "end",
  24809. causedBy: "scale"
  24810. }, getMapInfo2()));
  24811. };
  24812. event.addListener(map2, "zoom_changed", zoomChangedCallback);
  24813. event.addListener(map2, "zoomend", zoomChangedCallback);
  24814. event.addListener(map2, "center_changed", () => {
  24815. const center2 = map2.getCenter();
  24816. const latitude = getLat(center2);
  24817. const longitude = getLng(center2);
  24818. emit2("update:latitude", latitude);
  24819. emit2("update:longitude", longitude);
  24820. });
  24821. }
  24822. return map2;
  24823. }
  24824. try {
  24825. const id2 = useContextInfo();
  24826. useSubscribe((type, data = {}) => {
  24827. switch (type) {
  24828. case "getCenterLocation":
  24829. onMapReady(() => {
  24830. const center = map.getCenter();
  24831. callOptions(data, {
  24832. latitude: getLat(center),
  24833. longitude: getLng(center),
  24834. errMsg: `${type}:ok`
  24835. });
  24836. });
  24837. break;
  24838. case "moveToLocation":
  24839. {
  24840. let latitude = Number(data.latitude);
  24841. let longitude = Number(data.longitude);
  24842. if (!latitude || !longitude) {
  24843. const context = contexts[CONTEXT_ID];
  24844. if (context) {
  24845. latitude = context.state.latitude;
  24846. longitude = context.state.longitude;
  24847. }
  24848. }
  24849. if (latitude && longitude) {
  24850. state2.latitude = latitude;
  24851. state2.longitude = longitude;
  24852. if (map) {
  24853. const centerPosition = getMapPosition(maps2, latitude, longitude);
  24854. map.setCenter(centerPosition);
  24855. }
  24856. onMapReady(() => {
  24857. callOptions(data, `${type}:ok`);
  24858. });
  24859. } else {
  24860. callOptions(data, `${type}:fail`);
  24861. }
  24862. }
  24863. break;
  24864. case "translateMarker":
  24865. onMapReady(() => {
  24866. const context = contexts[data.markerId];
  24867. if (context) {
  24868. try {
  24869. context.translate(data);
  24870. } catch (error) {
  24871. callOptions(data, `${type}:fail ${error.message}`);
  24872. }
  24873. callOptions(data, `${type}:ok`);
  24874. } else {
  24875. callOptions(data, `${type}:fail not found`);
  24876. }
  24877. });
  24878. break;
  24879. case "includePoints":
  24880. state2.includePoints = getPoints(data.includePoints);
  24881. if (isBoundsReady || getIsAMap()) {
  24882. updateBounds();
  24883. }
  24884. onBoundsReady(() => {
  24885. callOptions(data, `${type}:ok`);
  24886. });
  24887. break;
  24888. case "getRegion":
  24889. onBoundsReady(() => {
  24890. const latLngBounds = map.getBounds();
  24891. const southwest = latLngBounds.getSouthWest();
  24892. const northeast = latLngBounds.getNorthEast();
  24893. callOptions(data, {
  24894. southwest: {
  24895. latitude: getLat(southwest),
  24896. longitude: getLng(southwest)
  24897. },
  24898. northeast: {
  24899. latitude: getLat(northeast),
  24900. longitude: getLng(northeast)
  24901. },
  24902. errMsg: `${type}:ok`
  24903. });
  24904. });
  24905. break;
  24906. case "getScale":
  24907. onMapReady(() => {
  24908. callOptions(data, {
  24909. scale: map.getZoom(),
  24910. errMsg: `${type}:ok`
  24911. });
  24912. });
  24913. break;
  24914. }
  24915. }, id2, true);
  24916. } catch (error) {
  24917. }
  24918. onMounted(() => {
  24919. loadMaps(props2.libraries, (result) => {
  24920. maps2 = result;
  24921. map = initMap();
  24922. emitMapReady();
  24923. trigger("updated", {}, {});
  24924. });
  24925. });
  24926. provide("onMapReady", onMapReady);
  24927. provide("addMapChidlContext", addMapChidlContext);
  24928. provide("removeMapChidlContext", removeMapChidlContext);
  24929. return {
  24930. state: state2,
  24931. mapRef,
  24932. trigger
  24933. };
  24934. }
  24935. class UniMapElement extends UniElement {
  24936. }
  24937. const Map$1 = /* @__PURE__ */ defineBuiltInComponent({
  24938. name: "Map",
  24939. props: props$2,
  24940. emits: ["markertap", "labeltap", "callouttap", "controltap", "regionchange", "tap", "click", "updated", "update:scale", "update:latitude", "update:longitude"],
  24941. rootElement: {
  24942. name: "uni-map",
  24943. class: UniMapElement
  24944. },
  24945. setup(props2, {
  24946. emit: emit2,
  24947. slots
  24948. }) {
  24949. const rootRef = ref(null);
  24950. const {
  24951. mapRef,
  24952. trigger
  24953. } = useMap(props2, rootRef, emit2);
  24954. onMounted(() => {
  24955. const rootElement = rootRef.value;
  24956. rootElement.attachVmProps(props2);
  24957. });
  24958. return () => {
  24959. return createVNode("uni-map", {
  24960. "ref": rootRef,
  24961. "id": props2.id
  24962. }, [createVNode("div", {
  24963. "ref": mapRef,
  24964. "style": "width: 100%; height: 100%; position: relative; overflow: hidden"
  24965. }, null, 512), props2.markers.map((item) => createVNode(MapMarker, mergeProps({
  24966. "key": item.id
  24967. }, item), null, 16)), props2.polyline.map((item) => createVNode(MapPolyline, item, null, 16)), props2.circles.map((item) => createVNode(MapCircle, item, null, 16)), props2.controls.map((item) => createVNode(MapControl, mergeProps(item, {
  24968. "trigger": trigger
  24969. }), null, 16, ["trigger"])), props2.showLocation && createVNode(MapLocation, null, null), props2.polygons.map((item) => createVNode(MapPolygon, item, null, 16)), createVNode("div", {
  24970. "style": "position: absolute;top: 0;width: 100%;height: 100%;overflow: hidden;pointer-events: none;"
  24971. }, [slots.default && slots.default()])], 8, ["id"]);
  24972. };
  24973. }
  24974. });
  24975. const props$1 = {
  24976. scrollTop: {
  24977. type: [String, Number],
  24978. default: 0
  24979. }
  24980. };
  24981. class UniCoverViewElement extends UniElement {
  24982. }
  24983. const index$9 = /* @__PURE__ */ defineBuiltInComponent({
  24984. name: "CoverView",
  24985. compatConfig: {
  24986. MODE: 3
  24987. },
  24988. props: props$1,
  24989. rootElement: {
  24990. name: "uni-cover-view",
  24991. class: UniCoverViewElement
  24992. },
  24993. setup(props2, {
  24994. slots
  24995. }) {
  24996. const root = ref(null);
  24997. const content = ref(null);
  24998. watch(() => props2.scrollTop, (val) => {
  24999. setScrollTop(val);
  25000. });
  25001. function setScrollTop(val) {
  25002. let _content = content.value;
  25003. if (getComputedStyle(_content).overflowY === "scroll") {
  25004. _content.scrollTop = _upx2pxNum(val);
  25005. }
  25006. }
  25007. function _upx2pxNum(val) {
  25008. let _val = String(val);
  25009. if (/\d+[ur]px$/i.test(_val)) {
  25010. _val.replace(/\d+[ur]px$/i, (text2) => {
  25011. return String(uni.upx2px(parseFloat(text2)));
  25012. });
  25013. }
  25014. return parseFloat(_val) || 0;
  25015. }
  25016. onMounted(() => {
  25017. setScrollTop(props2.scrollTop);
  25018. });
  25019. onMounted(() => {
  25020. const rootElement = root.value;
  25021. rootElement.attachVmProps(props2);
  25022. });
  25023. return () => {
  25024. return createVNode("uni-cover-view", {
  25025. "scroll-top": props2.scrollTop,
  25026. "ref": root
  25027. }, [createVNode("div", {
  25028. "ref": content,
  25029. "class": "uni-cover-view"
  25030. }, [slots.default && slots.default()], 512)], 8, ["scroll-top"]);
  25031. };
  25032. }
  25033. });
  25034. class UniCoverImageElement extends UniElement {
  25035. }
  25036. const index$8 = /* @__PURE__ */ defineBuiltInComponent({
  25037. name: "CoverImage",
  25038. compatConfig: {
  25039. MODE: 3
  25040. },
  25041. props: {
  25042. src: {
  25043. type: String,
  25044. default: ""
  25045. }
  25046. },
  25047. rootElement: {
  25048. name: "uni-cover-image",
  25049. class: UniCoverImageElement
  25050. },
  25051. emits: ["load", "error"],
  25052. setup(props2, {
  25053. emit: emit2
  25054. }) {
  25055. const root = ref(null);
  25056. const trigger = useCustomEvent(root, emit2);
  25057. function load($event) {
  25058. trigger("load", $event);
  25059. }
  25060. function error($event) {
  25061. trigger("error", $event);
  25062. }
  25063. onMounted(() => {
  25064. const rootElement = root.value;
  25065. rootElement.attachVmProps(props2);
  25066. });
  25067. return () => {
  25068. const {
  25069. src
  25070. } = props2;
  25071. return createVNode("uni-cover-image", {
  25072. "ref": root,
  25073. "src": src
  25074. }, [createVNode("div", {
  25075. "class": "uni-cover-image"
  25076. }, [src ? createVNode("img", {
  25077. "src": getRealPath(src),
  25078. "onLoad": load,
  25079. "onError": error
  25080. }, null, 40, ["src", "onLoad", "onError"]) : null])], 8, ["src"]);
  25081. };
  25082. }
  25083. });
  25084. function _isSlot(s) {
  25085. return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
  25086. }
  25087. function getDefaultStartValue(props2) {
  25088. if (props2.mode === mode.TIME) {
  25089. return "00:00";
  25090. }
  25091. if (props2.mode === mode.DATE) {
  25092. const year = (/* @__PURE__ */ new Date()).getFullYear() - 150;
  25093. switch (props2.fields) {
  25094. case fields.YEAR:
  25095. return year.toString();
  25096. case fields.MONTH:
  25097. return year + "-01";
  25098. default:
  25099. return year + "-01-01";
  25100. }
  25101. }
  25102. return "";
  25103. }
  25104. function getDefaultEndValue(props2) {
  25105. if (props2.mode === mode.TIME) {
  25106. return "23:59";
  25107. }
  25108. if (props2.mode === mode.DATE) {
  25109. const year = (/* @__PURE__ */ new Date()).getFullYear() + 150;
  25110. switch (props2.fields) {
  25111. case fields.YEAR:
  25112. return year.toString();
  25113. case fields.MONTH:
  25114. return year + "-12";
  25115. default:
  25116. return year + "-12-31";
  25117. }
  25118. }
  25119. return "";
  25120. }
  25121. function getDateValueArray(props2, state2, valueStr, defaultValue) {
  25122. const splitStr = props2.mode === mode.DATE ? "-" : ":";
  25123. const array = props2.mode === mode.DATE ? state2.dateArray : state2.timeArray;
  25124. let max;
  25125. if (props2.mode === mode.TIME) {
  25126. max = 2;
  25127. } else {
  25128. switch (props2.fields) {
  25129. case fields.YEAR:
  25130. max = 1;
  25131. break;
  25132. case fields.MONTH:
  25133. max = 2;
  25134. break;
  25135. default:
  25136. max = 3;
  25137. break;
  25138. }
  25139. }
  25140. const inputArray = String(valueStr).split(splitStr);
  25141. let value = [];
  25142. for (let i = 0; i < max; i++) {
  25143. const val = inputArray[i];
  25144. value.push(array[i].indexOf(val));
  25145. }
  25146. if (value.indexOf(-1) >= 0) {
  25147. value = defaultValue ? getDateValueArray(props2, state2, defaultValue) : value.map(() => 0);
  25148. }
  25149. return value;
  25150. }
  25151. const mode = {
  25152. SELECTOR: "selector",
  25153. MULTISELECTOR: "multiSelector",
  25154. TIME: "time",
  25155. DATE: "date"
  25156. // 暂不支持城市选择
  25157. // REGION: 'region'
  25158. };
  25159. const fields = {
  25160. YEAR: "year",
  25161. MONTH: "month",
  25162. DAY: "day"
  25163. };
  25164. const selectorType = {
  25165. PICKER: "picker",
  25166. SELECT: "select"
  25167. };
  25168. const props = {
  25169. name: {
  25170. type: String,
  25171. default: ""
  25172. },
  25173. range: {
  25174. type: Array,
  25175. default() {
  25176. return [];
  25177. }
  25178. },
  25179. rangeKey: {
  25180. type: String,
  25181. default: ""
  25182. },
  25183. value: {
  25184. type: [Number, String, Array],
  25185. default: 0
  25186. },
  25187. mode: {
  25188. type: String,
  25189. default: mode.SELECTOR,
  25190. validator(val) {
  25191. return Object.values(mode).includes(val);
  25192. }
  25193. },
  25194. fields: {
  25195. type: String,
  25196. default: ""
  25197. },
  25198. start: {
  25199. type: String,
  25200. default: (props2) => {
  25201. return getDefaultStartValue(props2);
  25202. }
  25203. },
  25204. end: {
  25205. type: String,
  25206. default: (props2) => {
  25207. return getDefaultEndValue(props2);
  25208. }
  25209. },
  25210. disabled: {
  25211. type: [Boolean, String],
  25212. default: false
  25213. },
  25214. selectorType: {
  25215. type: String,
  25216. default: ""
  25217. }
  25218. };
  25219. class UniPickerElement extends UniElement {
  25220. }
  25221. const index$7 = /* @__PURE__ */ defineBuiltInComponent({
  25222. name: "Picker",
  25223. compatConfig: {
  25224. MODE: 3
  25225. },
  25226. props,
  25227. emits: ["change", "cancel", "columnchange"],
  25228. rootElement: {
  25229. name: "uni-picker",
  25230. class: UniPickerElement
  25231. },
  25232. setup(props2, {
  25233. emit: emit2,
  25234. slots
  25235. }) {
  25236. initI18nPickerMsgsOnce();
  25237. const {
  25238. t: t2
  25239. } = useI18n();
  25240. const rootRef = ref(null);
  25241. const pickerRef = ref(null);
  25242. const selectRef = ref(null);
  25243. const inputRef = ref(null);
  25244. const pickerRender = ref(false);
  25245. const {
  25246. state: state2,
  25247. rangeArray
  25248. } = usePickerState(props2);
  25249. const trigger = useCustomEvent(rootRef, emit2);
  25250. const {
  25251. system,
  25252. selectorTypeComputed,
  25253. _show,
  25254. _l10nColumn,
  25255. _l10nItem,
  25256. _input,
  25257. _fixInputPosition,
  25258. _pickerViewChange,
  25259. _cancel,
  25260. _change,
  25261. _resetFormData,
  25262. _getFormData,
  25263. _createTime,
  25264. _createDate,
  25265. _setValueSync
  25266. } = usePickerMethods(props2, state2, trigger, rootRef, pickerRef, selectRef, inputRef);
  25267. usePickerWatch(state2, _cancel, _change);
  25268. usePickerForm(_resetFormData, _getFormData);
  25269. _createTime();
  25270. _createDate();
  25271. _setValueSync();
  25272. const popup = usePopupStyle(state2);
  25273. watchEffect(() => {
  25274. state2.isDesktop = popup.isDesktop.value;
  25275. state2.popupStyle = popup.popupStyle.value;
  25276. });
  25277. onBeforeUnmount(() => {
  25278. pickerRef.value && pickerRef.value.remove();
  25279. });
  25280. onMounted(() => {
  25281. pickerRender.value = true;
  25282. });
  25283. onMounted(() => {
  25284. const rootElement = rootRef.value;
  25285. rootElement.attachVmProps(props2);
  25286. });
  25287. return () => {
  25288. let _slot2;
  25289. const {
  25290. visible,
  25291. contentVisible,
  25292. valueArray,
  25293. popupStyle,
  25294. valueSync
  25295. } = state2;
  25296. const {
  25297. rangeKey,
  25298. mode: mode2,
  25299. start,
  25300. end
  25301. } = props2;
  25302. const booleanAttrs = useBooleanAttr(props2, "disabled");
  25303. return createVNode("uni-picker", mergeProps({
  25304. "ref": rootRef
  25305. }, booleanAttrs, {
  25306. "onClick": withWebEvent(_show)
  25307. }), [pickerRender.value ? createVNode("div", {
  25308. "ref": pickerRef,
  25309. "class": ["uni-picker-container", `uni-${mode2}-${selectorTypeComputed.value}`],
  25310. "onWheel": onEventPrevent,
  25311. "onTouchmove": onEventPrevent
  25312. }, [createVNode(Transition, {
  25313. "name": "uni-fade"
  25314. }, {
  25315. default: () => [withDirectives(createVNode("div", {
  25316. "class": "uni-mask uni-picker-mask",
  25317. "onClick": withWebEvent(_cancel),
  25318. "onMousemove": _fixInputPosition
  25319. }, null, 40, ["onClick", "onMousemove"]), [[vShow, visible]])]
  25320. }), !system.value ? createVNode("div", {
  25321. "class": [{
  25322. "uni-picker-toggle": visible
  25323. }, "uni-picker-custom"],
  25324. "style": popupStyle.content
  25325. }, [createVNode("div", {
  25326. "class": "uni-picker-header",
  25327. "onClick": onEventStop
  25328. }, [createVNode("div", {
  25329. "class": "uni-picker-action uni-picker-action-cancel",
  25330. "onClick": withWebEvent(_cancel)
  25331. }, [t2("uni.picker.cancel")], 8, ["onClick"]), createVNode("div", {
  25332. "class": "uni-picker-action uni-picker-action-confirm",
  25333. "onClick": _change
  25334. }, [t2("uni.picker.done")], 8, ["onClick"])], 8, ["onClick"]), contentVisible ? createVNode(PickerView, {
  25335. "value": _l10nColumn(valueArray),
  25336. "class": "uni-picker-content",
  25337. "onChange": _pickerViewChange
  25338. }, _isSlot(_slot2 = renderList(_l10nColumn(rangeArray.value), (rangeItem, index0) => {
  25339. let _slot;
  25340. return createVNode(PickerViewColumn, {
  25341. "key": index0
  25342. }, _isSlot(_slot = renderList(rangeItem, (item, index2) => createVNode("div", {
  25343. "key": index2,
  25344. "class": "uni-picker-item"
  25345. }, [typeof item === "object" ? item[rangeKey] || "" : _l10nItem(item, index0)]))) ? _slot : {
  25346. default: () => [_slot],
  25347. _: 1
  25348. });
  25349. })) ? _slot2 : {
  25350. default: () => [_slot2],
  25351. _: 1
  25352. }, 8, ["value", "onChange"]) : null, createVNode("div", {
  25353. "ref": selectRef,
  25354. "class": "uni-picker-select",
  25355. "onWheel": onEventStop,
  25356. "onTouchmove": onEventStop
  25357. }, [renderList(rangeArray.value[0], (item, index2) => createVNode("div", {
  25358. "key": index2,
  25359. "class": ["uni-picker-item", {
  25360. selected: valueArray[0] === index2
  25361. }],
  25362. "onClick": () => {
  25363. valueArray[0] = index2;
  25364. _change();
  25365. }
  25366. }, [typeof item === "object" ? item[rangeKey] || "" : item], 10, ["onClick"]))], 40, ["onWheel", "onTouchmove"]), createVNode("div", {
  25367. "style": popupStyle.triangle
  25368. }, null, 4)], 6) : null], 40, ["onWheel", "onTouchmove"]) : null, createVNode("div", null, [slots.default && slots.default()]), system.value ? createVNode("div", {
  25369. "class": "uni-picker-system",
  25370. "onMousemove": withWebEvent(_fixInputPosition)
  25371. }, [createVNode("input", {
  25372. "class": ["uni-picker-system_input", system.value],
  25373. "ref": inputRef,
  25374. "value": valueSync,
  25375. "type": mode2,
  25376. "tabindex": "-1",
  25377. "min": start,
  25378. "max": end,
  25379. "onChange": ($event) => {
  25380. _input($event);
  25381. onEventStop($event);
  25382. }
  25383. }, null, 42, ["value", "type", "min", "max", "onChange"])], 40, ["onMousemove"]) : null], 16, ["onClick"]);
  25384. };
  25385. }
  25386. });
  25387. function usePickerState(props2) {
  25388. const state2 = reactive({
  25389. valueSync: void 0,
  25390. visible: false,
  25391. contentVisible: false,
  25392. popover: null,
  25393. valueChangeSource: "",
  25394. timeArray: [],
  25395. dateArray: [],
  25396. valueArray: [],
  25397. oldValueArray: [],
  25398. isDesktop: false,
  25399. popupStyle: {
  25400. content: {},
  25401. triangle: {}
  25402. }
  25403. });
  25404. const rangeArray = computed(() => {
  25405. let val = props2.range;
  25406. switch (props2.mode) {
  25407. case mode.SELECTOR:
  25408. return [val];
  25409. case mode.MULTISELECTOR:
  25410. return val;
  25411. case mode.TIME:
  25412. return state2.timeArray;
  25413. case mode.DATE: {
  25414. const dateArray = state2.dateArray;
  25415. switch (props2.fields) {
  25416. case fields.YEAR:
  25417. return [dateArray[0]];
  25418. case fields.MONTH:
  25419. return [dateArray[0], dateArray[1]];
  25420. default:
  25421. return [dateArray[0], dateArray[1], dateArray[2]];
  25422. }
  25423. }
  25424. }
  25425. return [];
  25426. });
  25427. return {
  25428. state: state2,
  25429. rangeArray
  25430. };
  25431. }
  25432. const getiPadFlag = () => String(navigator.vendor).indexOf("Apple") === 0 && navigator.maxTouchPoints > 0;
  25433. function useIsiPad() {
  25434. const isiPad = ref(false);
  25435. {
  25436. isiPad.value = getiPadFlag();
  25437. }
  25438. return isiPad;
  25439. }
  25440. const getSystem = () => {
  25441. if (/win|mac/i.test(navigator.platform)) {
  25442. if (navigator.vendor === "Google Inc.") {
  25443. return "chrome";
  25444. } else if (/Firefox/.test(navigator.userAgent)) {
  25445. return "firefox";
  25446. }
  25447. }
  25448. return "";
  25449. };
  25450. function useSystem() {
  25451. const _system = ref("");
  25452. {
  25453. _system.value = getSystem();
  25454. }
  25455. return _system;
  25456. }
  25457. let __contentVisibleDelay;
  25458. function usePickerMethods(props2, state2, trigger, rootRef, pickerRef, selectRef, inputRef) {
  25459. const isiPad = useIsiPad();
  25460. const _system = useSystem();
  25461. const selectorTypeComputed = computed(() => {
  25462. const type = props2.selectorType;
  25463. if (Object.values(selectorType).includes(type)) {
  25464. return type;
  25465. }
  25466. return isiPad.value ? selectorType.PICKER : selectorType.SELECT;
  25467. });
  25468. const system = computed(() => {
  25469. if (props2.mode === mode.DATE && !Object.values(fields).includes(props2.fields) && state2.isDesktop) {
  25470. return _system.value;
  25471. }
  25472. return "";
  25473. });
  25474. const startArray = computed(() => {
  25475. return getDateValueArray(props2, state2, props2.start, getDefaultStartValue(props2));
  25476. });
  25477. const endArray = computed(() => {
  25478. return getDateValueArray(props2, state2, props2.end, getDefaultEndValue(props2));
  25479. });
  25480. function _show(event) {
  25481. if (props2.disabled) {
  25482. return;
  25483. }
  25484. state2.valueChangeSource = "";
  25485. let $picker = pickerRef.value;
  25486. let _currentTarget = event.currentTarget;
  25487. $picker.remove();
  25488. (document.querySelector("uni-app") || document.body).appendChild($picker);
  25489. $picker.style.display = "block";
  25490. const rect = _currentTarget.getBoundingClientRect();
  25491. state2.popover = {
  25492. top: rect.top,
  25493. left: rect.left,
  25494. width: rect.width,
  25495. height: rect.height
  25496. };
  25497. setTimeout(() => {
  25498. state2.visible = true;
  25499. }, 20);
  25500. }
  25501. function _getFormData() {
  25502. return {
  25503. value: state2.valueSync,
  25504. key: props2.name
  25505. };
  25506. }
  25507. function _resetFormData() {
  25508. switch (props2.mode) {
  25509. case mode.SELECTOR:
  25510. state2.valueSync = 0;
  25511. break;
  25512. case mode.MULTISELECTOR:
  25513. state2.valueSync = props2.value.map((val) => 0);
  25514. break;
  25515. case mode.DATE:
  25516. case mode.TIME:
  25517. state2.valueSync = "";
  25518. break;
  25519. }
  25520. }
  25521. function _createTime() {
  25522. let hours = [];
  25523. let minutes = [];
  25524. for (let i = 0; i < 24; i++) {
  25525. hours.push((i < 10 ? "0" : "") + i);
  25526. }
  25527. for (let i = 0; i < 60; i++) {
  25528. minutes.push((i < 10 ? "0" : "") + i);
  25529. }
  25530. state2.timeArray.push(hours, minutes);
  25531. }
  25532. function getYearStartEnd() {
  25533. let year = (/* @__PURE__ */ new Date()).getFullYear();
  25534. let start = year - 150;
  25535. let end = year + 150;
  25536. if (props2.start) {
  25537. const _year = new Date(props2.start).getFullYear();
  25538. if (!isNaN(_year) && _year < start) {
  25539. start = _year;
  25540. }
  25541. }
  25542. if (props2.end) {
  25543. const _year = new Date(props2.end).getFullYear();
  25544. if (!isNaN(_year) && _year > end) {
  25545. end = _year;
  25546. }
  25547. }
  25548. return {
  25549. start,
  25550. end
  25551. };
  25552. }
  25553. function _createDate() {
  25554. let years = [];
  25555. const year = getYearStartEnd();
  25556. for (let i = year.start, end = year.end; i <= end; i++) {
  25557. years.push(String(i));
  25558. }
  25559. let months = [];
  25560. for (let i = 1; i <= 12; i++) {
  25561. months.push((i < 10 ? "0" : "") + i);
  25562. }
  25563. let days = [];
  25564. for (let i = 1; i <= 31; i++) {
  25565. days.push((i < 10 ? "0" : "") + i);
  25566. }
  25567. state2.dateArray.push(years, months, days);
  25568. }
  25569. function _getTimeValue(val) {
  25570. return val[0] * 60 + val[1];
  25571. }
  25572. function _getDateValue(val) {
  25573. const DAY = 31;
  25574. return val[0] * DAY * 12 + (val[1] || 0) * DAY + (val[2] || 0);
  25575. }
  25576. function _cloneArray(val1, val2) {
  25577. for (let i = 0; i < val1.length && i < val2.length; i++) {
  25578. val1[i] = val2[i];
  25579. }
  25580. }
  25581. function _setValueSync() {
  25582. let val = props2.value;
  25583. switch (props2.mode) {
  25584. case mode.MULTISELECTOR:
  25585. {
  25586. if (!isArray(val)) {
  25587. val = state2.valueArray;
  25588. }
  25589. if (!isArray(state2.valueSync)) {
  25590. state2.valueSync = [];
  25591. }
  25592. const length = state2.valueSync.length = Math.max(val.length, props2.range.length);
  25593. for (let index2 = 0; index2 < length; index2++) {
  25594. const val0 = Number(val[index2]);
  25595. const val1 = Number(state2.valueSync[index2]);
  25596. const val2 = isNaN(val0) ? isNaN(val1) ? 0 : val1 : val0;
  25597. const maxVal = props2.range[index2] ? props2.range[index2].length - 1 : 0;
  25598. state2.valueSync.splice(index2, 1, val2 < 0 || val2 > maxVal ? 0 : val2);
  25599. }
  25600. }
  25601. break;
  25602. case mode.TIME:
  25603. case mode.DATE:
  25604. state2.valueSync = String(val);
  25605. break;
  25606. default: {
  25607. const valueSync = Number(val);
  25608. state2.valueSync = valueSync < 0 ? 0 : valueSync;
  25609. break;
  25610. }
  25611. }
  25612. }
  25613. function _setValueArray() {
  25614. let val = state2.valueSync;
  25615. let valueArray;
  25616. switch (props2.mode) {
  25617. case mode.MULTISELECTOR:
  25618. valueArray = [...val];
  25619. break;
  25620. case mode.TIME:
  25621. valueArray = getDateValueArray(props2, state2, val, formatDateTime({
  25622. mode: mode.TIME
  25623. }));
  25624. break;
  25625. case mode.DATE:
  25626. valueArray = getDateValueArray(props2, state2, val, formatDateTime({
  25627. mode: mode.DATE
  25628. }));
  25629. break;
  25630. default:
  25631. valueArray = [val];
  25632. break;
  25633. }
  25634. state2.oldValueArray = [...valueArray];
  25635. state2.valueArray = [...valueArray];
  25636. }
  25637. function _getValue() {
  25638. let val = state2.valueArray;
  25639. switch (props2.mode) {
  25640. case mode.SELECTOR:
  25641. return val[0];
  25642. case mode.MULTISELECTOR:
  25643. return val.map((val2) => val2);
  25644. case mode.TIME:
  25645. return state2.valueArray.map((val2, i) => state2.timeArray[i][val2]).join(":");
  25646. case mode.DATE:
  25647. return state2.valueArray.map((val2, i) => state2.dateArray[i][val2]).join("-");
  25648. }
  25649. }
  25650. function _change() {
  25651. _close();
  25652. state2.valueChangeSource = "click";
  25653. const value = _getValue();
  25654. state2.valueSync = isArray(value) ? value.map((val) => val) : value;
  25655. trigger("change", {}, {
  25656. value
  25657. });
  25658. }
  25659. function _cancel($event) {
  25660. if (system.value === "firefox" && $event) {
  25661. const {
  25662. top,
  25663. left,
  25664. width,
  25665. height
  25666. } = state2.popover;
  25667. const {
  25668. pageX,
  25669. pageY
  25670. } = $event;
  25671. if (pageX > left && pageX < left + width && pageY > top && pageY < top + height) {
  25672. return;
  25673. }
  25674. }
  25675. _close();
  25676. trigger("cancel", {}, {});
  25677. }
  25678. function _close() {
  25679. state2.visible = false;
  25680. setTimeout(() => {
  25681. let $picker = pickerRef.value;
  25682. $picker.remove();
  25683. rootRef.value.prepend($picker);
  25684. $picker.style.display = "none";
  25685. }, 260);
  25686. }
  25687. function _select() {
  25688. if (props2.mode === mode.SELECTOR && selectorTypeComputed.value === selectorType.SELECT) {
  25689. selectRef.value.scrollTop = state2.valueArray[0] * 34;
  25690. }
  25691. }
  25692. function _input($event) {
  25693. const EventTarget = $event.target;
  25694. state2.valueSync = EventTarget.value;
  25695. nextTick(() => {
  25696. _change();
  25697. });
  25698. }
  25699. function _fixInputPosition($event) {
  25700. if (system.value === "chrome") {
  25701. const rect = rootRef.value.getBoundingClientRect();
  25702. const fontSize = 32;
  25703. inputRef.value.style.left = `${$event.clientX - rect.left - fontSize * 1.5}px`;
  25704. inputRef.value.style.top = `${$event.clientY - rect.top - fontSize * 0.5}px`;
  25705. }
  25706. }
  25707. function _pickerViewChange(event) {
  25708. state2.valueArray = _l10nColumn(event.detail.value, true);
  25709. }
  25710. function _l10nColumn(array, normalize) {
  25711. const {
  25712. getLocale: getLocale2
  25713. } = useI18n();
  25714. if (props2.mode === mode.DATE) {
  25715. const locale = getLocale2();
  25716. if (!locale.startsWith("zh")) {
  25717. switch (props2.fields) {
  25718. case fields.YEAR:
  25719. return array;
  25720. case fields.MONTH:
  25721. return [array[1], array[0]];
  25722. default:
  25723. switch (locale) {
  25724. case "es":
  25725. case "fr":
  25726. return [array[2], array[1], array[0]];
  25727. default:
  25728. return normalize ? [array[2], array[0], array[1]] : [array[1], array[2], array[0]];
  25729. }
  25730. }
  25731. }
  25732. }
  25733. return array;
  25734. }
  25735. function _l10nItem(item, index2) {
  25736. const {
  25737. getLocale: getLocale2
  25738. } = useI18n();
  25739. if (props2.mode === mode.DATE) {
  25740. const locale = getLocale2();
  25741. if (locale.startsWith("zh")) {
  25742. const array = ["年", "月", "日"];
  25743. return item + array[index2];
  25744. } else if (props2.fields !== fields.YEAR && index2 === (props2.fields !== fields.MONTH && (locale === "es" || locale === "fr") ? 1 : 0)) {
  25745. let array;
  25746. switch (locale) {
  25747. case "es":
  25748. array = ["enero", "febrero", "marzo", "abril", "mayo", "junio", "​​julio", "agosto", "septiembre", "octubre", "noviembre", "diciembre"];
  25749. break;
  25750. case "fr":
  25751. array = ["janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre"];
  25752. break;
  25753. default:
  25754. array = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
  25755. break;
  25756. }
  25757. return array[Number(item) - 1];
  25758. }
  25759. }
  25760. return item;
  25761. }
  25762. watch(() => state2.visible, (val) => {
  25763. if (val) {
  25764. clearTimeout(__contentVisibleDelay);
  25765. state2.contentVisible = val;
  25766. _select();
  25767. } else {
  25768. __contentVisibleDelay = setTimeout(() => {
  25769. state2.contentVisible = val;
  25770. }, 300);
  25771. }
  25772. });
  25773. watch([() => props2.mode, () => props2.value, () => props2.range], _setValueSync, {
  25774. deep: true
  25775. });
  25776. watch(() => state2.valueSync, _setValueArray, {
  25777. deep: true
  25778. });
  25779. watch(() => state2.valueArray, (val) => {
  25780. if (props2.mode === mode.TIME || props2.mode === mode.DATE) {
  25781. const getValue = props2.mode === mode.TIME ? _getTimeValue : _getDateValue;
  25782. const valueArray = state2.valueArray;
  25783. const _startArray = startArray.value;
  25784. const _endArray = endArray.value;
  25785. if (props2.mode === mode.DATE) {
  25786. const dateArray = state2.dateArray;
  25787. const max = dateArray[2].length;
  25788. const day = Number(dateArray[2][valueArray[2]]) || 1;
  25789. const realDay = (/* @__PURE__ */ new Date(`${dateArray[0][valueArray[0]]}/${dateArray[1][valueArray[1]]}/${day}`)).getDate();
  25790. if (realDay < day) {
  25791. valueArray[2] -= realDay + max - day;
  25792. }
  25793. }
  25794. if (getValue(valueArray) < getValue(_startArray)) {
  25795. _cloneArray(valueArray, _startArray);
  25796. } else if (getValue(valueArray) > getValue(_endArray)) {
  25797. _cloneArray(valueArray, _endArray);
  25798. }
  25799. }
  25800. val.forEach((value, column) => {
  25801. if (value !== state2.oldValueArray[column]) {
  25802. state2.oldValueArray[column] = value;
  25803. if (props2.mode === mode.MULTISELECTOR) {
  25804. trigger("columnchange", {}, {
  25805. column,
  25806. value
  25807. });
  25808. }
  25809. }
  25810. });
  25811. });
  25812. return {
  25813. selectorTypeComputed,
  25814. system,
  25815. _show,
  25816. _cancel,
  25817. _change,
  25818. _l10nColumn,
  25819. _l10nItem,
  25820. _input,
  25821. _resetFormData,
  25822. _getFormData,
  25823. _createTime,
  25824. _createDate,
  25825. _setValueSync,
  25826. _fixInputPosition,
  25827. _pickerViewChange
  25828. };
  25829. }
  25830. function usePickerWatch(state2, _cancel, _change) {
  25831. const {
  25832. key,
  25833. disable
  25834. } = useKeyboard();
  25835. watchEffect(() => {
  25836. disable.value = !state2.visible;
  25837. });
  25838. watch(key, (value) => {
  25839. if (value === "esc") {
  25840. _cancel();
  25841. } else if (value === "enter") {
  25842. _change();
  25843. }
  25844. });
  25845. }
  25846. function usePickerForm(_resetFormData, _getFormData) {
  25847. const uniForm = inject(uniFormKey, false);
  25848. if (uniForm) {
  25849. const field = {
  25850. reset: _resetFormData,
  25851. submit: () => {
  25852. const data = ["", null];
  25853. const {
  25854. key,
  25855. value
  25856. } = _getFormData();
  25857. if (key !== "") {
  25858. data[0] = key;
  25859. data[1] = value;
  25860. }
  25861. return data;
  25862. }
  25863. };
  25864. uniForm.addField(field);
  25865. onBeforeUnmount(() => {
  25866. uniForm.removeField(field);
  25867. });
  25868. }
  25869. }
  25870. const index$6 = /* @__PURE__ */ defineUnsupportedComponent("ad");
  25871. const index$5 = /* @__PURE__ */ defineUnsupportedComponent("ad-content-page");
  25872. const index$4 = /* @__PURE__ */ defineUnsupportedComponent("ad-draw");
  25873. const index$3 = /* @__PURE__ */ defineUnsupportedComponent("camera");
  25874. const index$2 = /* @__PURE__ */ defineUnsupportedComponent("live-player");
  25875. const index$1 = /* @__PURE__ */ defineUnsupportedComponent("live-pusher");
  25876. const UniViewJSBridge$1 = /* @__PURE__ */ extend(ViewJSBridge, {
  25877. publishHandler(event, args, pageId) {
  25878. UniServiceJSBridge.subscribeHandler(event, args, pageId);
  25879. }
  25880. });
  25881. const uni$1 = api;
  25882. const UniServiceJSBridge$1 = /* @__PURE__ */ extend(ServiceJSBridge, {
  25883. publishHandler(event, args, pageId) {
  25884. UniViewJSBridge.subscribeHandler(event, args, pageId);
  25885. }
  25886. });
  25887. function usePageHeadTransparentBackgroundColor(backgroundColor) {
  25888. const { r, g: g2, b } = hexToRgba(backgroundColor);
  25889. return `rgba(${r},${g2},${b},0)`;
  25890. }
  25891. function usePageHeadTransparent(headRef, {
  25892. id: id2,
  25893. navigationBar: { titleColor, coverage, backgroundColor }
  25894. }) {
  25895. let A = 0;
  25896. const rgb = computed(() => hexToRgba(backgroundColor));
  25897. const offset = parseInt(coverage);
  25898. let titleElem;
  25899. let transparentElemStyle;
  25900. const iconElemsPaths = [];
  25901. const borderRadiusElemsStyles = [];
  25902. const oldColors = [];
  25903. onMounted(() => {
  25904. const $el = headRef.value;
  25905. transparentElemStyle = $el.style;
  25906. titleElem = $el.querySelector(".uni-page-head__title");
  25907. const borderRadiusElems = $el.querySelectorAll(
  25908. ".uni-page-head-btn"
  25909. );
  25910. const iconSvgElems = $el.querySelectorAll(
  25911. "svg path"
  25912. );
  25913. for (let i = 0; i < iconSvgElems.length; i++) {
  25914. iconElemsPaths.push(iconSvgElems[i]);
  25915. }
  25916. for (let i = 0; i < borderRadiusElems.length; i++) {
  25917. const borderRadiusElem = borderRadiusElems[i];
  25918. oldColors.push(getComputedStyle(borderRadiusElem).backgroundColor);
  25919. borderRadiusElemsStyles.push(borderRadiusElem.style);
  25920. }
  25921. });
  25922. useOn(id2 + ".onPageScroll", ({ scrollTop }) => {
  25923. const alpha = Math.min(scrollTop / offset, 1);
  25924. if (alpha === 1 && A === 1) {
  25925. return;
  25926. }
  25927. if (alpha > 0.5 && A <= 0.5) {
  25928. iconElemsPaths.forEach(function(iconElemPath) {
  25929. iconElemPath.setAttribute("fill", titleColor);
  25930. });
  25931. } else if (alpha <= 0.5 && A > 0.5) {
  25932. iconElemsPaths.forEach(function(iconElemPath) {
  25933. iconElemPath.setAttribute("fill", "#fff");
  25934. });
  25935. }
  25936. A = alpha;
  25937. if (titleElem) {
  25938. titleElem.style.opacity = alpha;
  25939. }
  25940. const bg = rgb.value;
  25941. transparentElemStyle.backgroundColor = `rgba(${bg.r},${bg.g},${bg.b},${alpha})`;
  25942. borderRadiusElemsStyles.forEach(function(borderRadiusElemStyle, index2) {
  25943. const oldColor = oldColors[index2];
  25944. const rgba = oldColor.match(/[\d+\.]+/g);
  25945. rgba[3] = (1 - alpha) * (rgba.length === 4 ? rgba[3] : 1);
  25946. borderRadiusElemStyle.backgroundColor = `rgba(${rgba})`;
  25947. });
  25948. });
  25949. }
  25950. const ICON_PATHS = {
  25951. none: "",
  25952. forward: "M11 7.844q-0.25-0.219-0.25-0.578t0.25-0.578q0.219-0.25 0.563-0.25t0.563 0.25l9.656 9.125q0.125 0.125 0.188 0.297t0.063 0.328q0 0.188-0.063 0.359t-0.188 0.297l-9.656 9.125q-0.219 0.25-0.563 0.25t-0.563-0.25q-0.25-0.219-0.25-0.578t0.25-0.609l9.063-8.594-9.063-8.594z",
  25953. back: ICON_PATH_BACK,
  25954. select: ICON_PATH_BACK,
  25955. share: "M26.563 24.844q0 0.125-0.109 0.234t-0.234 0.109h-17.938q-0.125 0-0.219-0.109t-0.094-0.234v-13.25q0-0.156 0.094-0.25t0.219-0.094h5.5v-1.531h-6q-0.531 0-0.906 0.391t-0.375 0.922v14.375q0 0.531 0.375 0.922t0.906 0.391h18.969q0.531 0 0.891-0.391t0.359-0.953v-5.156h-1.438v4.625zM29.813 10.969l-5.125-5.375-1.031 1.094 3.438 3.594-3.719 0.031q-2.313 0.188-4.344 1.125t-3.578 2.422-2.5 3.453-1.109 4.188l-0.031 0.25h1.469v-0.219q0.156-1.875 1-3.594t2.25-3.063 3.234-2.125 3.828-0.906l0.188-0.031 3.313-0.031-3.438 3.625 1.031 1.063 5.125-5.375-0.031-0.063 0.031-0.063z",
  25956. favorite: "M27.594 13.375q-0.063-0.188-0.219-0.313t-0.344-0.156l-7.094-0.969-3.219-6.406q-0.094-0.188-0.25-0.281t-0.375-0.094q-0.188 0-0.344 0.094t-0.25 0.281l-3.125 6.438-7.094 1.094q-0.188 0.031-0.344 0.156t-0.219 0.313q-0.031 0.188 0.016 0.375t0.172 0.313l5.156 4.969-1.156 7.063q-0.031 0.188 0.047 0.375t0.234 0.313q0.094 0.063 0.188 0.094t0.219 0.031q0.063 0 0.141-0.031t0.172-0.063l6.313-3.375 6.375 3.313q0.063 0.031 0.141 0.047t0.172 0.016q0.188 0 0.344-0.094t0.25-0.281q0.063-0.094 0.078-0.234t-0.016-0.234q0-0.031 0-0.063l-1.25-6.938 5.094-5.031q0.156-0.156 0.203-0.344t-0.016-0.375zM11.469 19.063q0.031-0.188-0.016-0.344t-0.172-0.281l-4.406-4.25 6.063-0.906q0.156-0.031 0.297-0.125t0.203-0.25l2.688-5.531 2.75 5.5q0.063 0.156 0.203 0.25t0.297 0.125l6.094 0.844-4.375 4.281q-0.125 0.125-0.172 0.297t-0.016 0.328l1.063 6.031-5.438-2.813q-0.156-0.094-0.328-0.078t-0.297 0.078l-5.438 2.875 1-6.031z",
  25957. home: "M23.719 16.5q-0.313 0-0.531 0.219t-0.219 0.5v7.063q0 0.219-0.172 0.391t-0.391 0.172h-12.344q-0.25 0-0.422-0.172t-0.172-0.391v-7.063q0-0.281-0.219-0.5t-0.531-0.219q-0.281 0-0.516 0.219t-0.234 0.5v7.063q0.031 0.844 0.625 1.453t1.438 0.609h12.375q0.844 0 1.453-0.609t0.609-1.453v-7.063q0-0.125-0.063-0.266t-0.156-0.234q-0.094-0.125-0.234-0.172t-0.297-0.047zM26.5 14.875l-8.813-8.813q-0.313-0.313-0.688-0.453t-0.781-0.141-0.781 0.141-0.656 0.422l-8.813 8.844q-0.188 0.219-0.188 0.516t0.219 0.484q0.094 0.125 0.234 0.172t0.297 0.047q0.125 0 0.25-0.047t0.25-0.141l8.781-8.781q0.156-0.156 0.406-0.156t0.406 0.156l8.813 8.781q0.219 0.188 0.516 0.188t0.516-0.219q0.188-0.188 0.203-0.484t-0.172-0.516z",
  25958. menu: "M8.938 18.313q0.875 0 1.484-0.609t0.609-1.453-0.609-1.453-1.484-0.609q-0.844 0-1.453 0.609t-0.609 1.453 0.609 1.453 1.453 0.609zM16.188 18.313q0.875 0 1.484-0.609t0.609-1.453-0.609-1.453-1.484-0.609q-0.844 0-1.453 0.609t-0.609 1.453 0.609 1.453 1.453 0.609zM23.469 18.313q0.844 0 1.453-0.609t0.609-1.453-0.609-1.453-1.453-0.609q-0.875 0-1.484 0.609t-0.609 1.453 0.609 1.453 1.484 0.609z",
  25959. close: ICON_PATH_CLOSE
  25960. };
  25961. const PageHead = /* @__PURE__ */ defineSystemComponent({
  25962. name: "PageHead",
  25963. setup() {
  25964. const headRef = ref(null);
  25965. const pageMeta = usePageMeta();
  25966. const navigationBar = useTheme(pageMeta.navigationBar, () => {
  25967. const _navigationBar = parseTheme(pageMeta.navigationBar);
  25968. navigationBar.backgroundColor = _navigationBar.backgroundColor;
  25969. navigationBar.titleColor = _navigationBar.titleColor;
  25970. });
  25971. const {
  25972. clazz: clazz2,
  25973. style
  25974. } = usePageHead(navigationBar);
  25975. const buttons = __UNI_FEATURE_NAVIGATIONBAR_BUTTONS__ && usePageHeadButtons(pageMeta);
  25976. const searchInput = __UNI_FEATURE_NAVIGATIONBAR_SEARCHINPUT__ && navigationBar.searchInput && usePageHeadSearchInput(pageMeta);
  25977. __UNI_FEATURE_NAVIGATIONBAR_TRANSPARENT__ && navigationBar.type === "transparent" && usePageHeadTransparent(headRef, pageMeta);
  25978. return () => {
  25979. const backButtonTsx = __UNI_FEATURE_PAGES__ ? createBackButtonTsx(navigationBar, pageMeta.isQuit) : null;
  25980. const leftButtonsTsx = __UNI_FEATURE_NAVIGATIONBAR_BUTTONS__ ? createButtonsTsx(buttons.left) : [];
  25981. const rightButtonsTsx = __UNI_FEATURE_NAVIGATIONBAR_BUTTONS__ ? createButtonsTsx(buttons.right) : [];
  25982. const type = navigationBar.type || "default";
  25983. const placeholderTsx = type !== "transparent" && type !== "float" && createVNode("div", {
  25984. "class": {
  25985. "uni-placeholder": true,
  25986. "uni-placeholder-titlePenetrate": navigationBar.titlePenetrate
  25987. }
  25988. }, null, 2);
  25989. return createVNode("uni-page-head", {
  25990. "uni-page-head-type": type
  25991. }, [createVNode("div", {
  25992. "ref": headRef,
  25993. "class": clazz2.value,
  25994. "style": style.value
  25995. }, [createVNode("div", {
  25996. "class": "uni-page-head-hd"
  25997. }, [backButtonTsx, ...leftButtonsTsx]), createPageHeadBdTsx(navigationBar, searchInput), createVNode("div", {
  25998. "class": "uni-page-head-ft"
  25999. }, [...rightButtonsTsx])], 6), placeholderTsx], 8, ["uni-page-head-type"]);
  26000. };
  26001. }
  26002. });
  26003. function createBackButtonTsx(navigationBar, isQuit) {
  26004. if (!isQuit) {
  26005. return createVNode("div", {
  26006. "class": "uni-page-head-btn",
  26007. "onClick": onPageHeadBackButton
  26008. }, [createSvgIconVNode(ICON_PATH_BACK, navigationBar.type === "transparent" ? "#fff" : navigationBar.titleColor, 26)], 8, ["onClick"]);
  26009. }
  26010. }
  26011. function createButtonsTsx(btns) {
  26012. return btns.map(({
  26013. onClick,
  26014. btnClass,
  26015. btnStyle,
  26016. btnText,
  26017. btnIconPath,
  26018. badgeText,
  26019. iconStyle,
  26020. btnSelect
  26021. }, index2) => {
  26022. return createVNode("div", {
  26023. "key": index2,
  26024. "class": btnClass,
  26025. "style": btnStyle,
  26026. "onClick": onClick,
  26027. "badge-text": badgeText
  26028. }, [btnIconPath ? createSvgIconVNode(btnIconPath, iconStyle.color, iconStyle.fontSize) : btnSelect ? createVNode("span", {
  26029. "style": iconStyle
  26030. }, [createVNode("i", {
  26031. "class": "uni-btn-icon",
  26032. "innerHTML": btnText
  26033. }, null, 8, ["innerHTML"]), createSvgIconVNode(ICON_PATHS["select"], "#000", 14)], 4) : createVNode("i", {
  26034. "class": "uni-btn-icon",
  26035. "style": iconStyle,
  26036. "innerHTML": btnText
  26037. }, null, 12, ["innerHTML"])], 14, ["onClick", "badge-text"]);
  26038. });
  26039. }
  26040. function createPageHeadBdTsx(navigationBar, searchInput) {
  26041. if (!__UNI_FEATURE_NAVIGATIONBAR_SEARCHINPUT__ || !navigationBar.searchInput) {
  26042. return createPageHeadTitleTextTsx(navigationBar);
  26043. }
  26044. return createPageHeadSearchInputTsx(navigationBar, searchInput);
  26045. }
  26046. function createPageHeadTitleTextTsx({
  26047. type,
  26048. loading,
  26049. titleSize,
  26050. titleText,
  26051. titleImage
  26052. }) {
  26053. return createVNode("div", {
  26054. "class": "uni-page-head-bd"
  26055. }, [createVNode("div", {
  26056. "style": {
  26057. fontSize: titleSize,
  26058. opacity: type === "transparent" ? 0 : 1
  26059. },
  26060. "class": "uni-page-head__title"
  26061. }, [loading ? createVNode("i", {
  26062. "class": "uni-loading"
  26063. }, null) : titleImage ? createVNode("img", {
  26064. "src": titleImage,
  26065. "class": "uni-page-head__title_image"
  26066. }, null, 8, ["src"]) : titleText], 4)]);
  26067. }
  26068. function createPageHeadSearchInputTsx(navigationBar, {
  26069. text: text2,
  26070. focus,
  26071. composing,
  26072. onBlur,
  26073. onFocus,
  26074. onInput,
  26075. onConfirm,
  26076. onClick
  26077. }) {
  26078. const {
  26079. color,
  26080. align: align2,
  26081. autoFocus,
  26082. disabled,
  26083. borderRadius,
  26084. backgroundColor,
  26085. placeholder,
  26086. placeholderColor
  26087. } = navigationBar.searchInput;
  26088. const searchStyle = {
  26089. borderRadius,
  26090. backgroundColor
  26091. };
  26092. const placeholderClass = ["uni-page-head-search-placeholder", `uni-page-head-search-placeholder-${focus.value || text2.value ? "left" : align2}`];
  26093. return createVNode("div", {
  26094. "class": "uni-page-head-search",
  26095. "style": searchStyle
  26096. }, [createVNode("div", {
  26097. "style": {
  26098. color: placeholderColor
  26099. },
  26100. "class": placeholderClass
  26101. }, [createVNode("div", {
  26102. "class": "uni-page-head-search-icon"
  26103. }, [createSvgIconVNode(ICON_PATH_SEARCH, placeholderColor, 20)]), text2.value || composing.value ? "" : placeholder], 6), disabled ? createVNode(Input, {
  26104. "disabled": true,
  26105. "style": {
  26106. color
  26107. },
  26108. "placeholder-style": "color: " + placeholderColor,
  26109. "class": "uni-page-head-search-input",
  26110. "confirm-type": "search",
  26111. "onClick": onClick
  26112. }, null, 8, ["style", "placeholder-style", "onClick"]) : createVNode(Input, {
  26113. "focus": autoFocus,
  26114. "style": {
  26115. color
  26116. },
  26117. "placeholder-style": "color: " + placeholderColor,
  26118. "class": "uni-page-head-search-input",
  26119. "confirm-type": "search",
  26120. "onFocus": onFocus,
  26121. "onBlur": onBlur,
  26122. "onInput": onInput,
  26123. "onConfirm": onConfirm
  26124. }, null, 8, ["focus", "style", "placeholder-style", "onFocus", "onBlur", "onInput", "onConfirm"])], 4);
  26125. }
  26126. function onPageHeadBackButton() {
  26127. if (getCurrentPages().length === 1) {
  26128. uni.reLaunch({
  26129. url: "/"
  26130. });
  26131. } else {
  26132. uni.navigateBack({
  26133. from: "backbutton",
  26134. success() {
  26135. }
  26136. // 传入空方法,避免返回Promise,因为onBackPress可能导致fail
  26137. });
  26138. }
  26139. }
  26140. function usePageHead(navigationBar) {
  26141. const clazz2 = computed(() => {
  26142. const {
  26143. type,
  26144. titlePenetrate,
  26145. shadowColorType
  26146. } = navigationBar;
  26147. const clazz3 = {
  26148. "uni-page-head": true,
  26149. "uni-page-head-transparent": type === "transparent",
  26150. "uni-page-head-titlePenetrate": titlePenetrate === "YES",
  26151. "uni-page-head-shadow": !!shadowColorType
  26152. };
  26153. if (shadowColorType) {
  26154. clazz3[`uni-page-head-shadow-${shadowColorType}`] = true;
  26155. }
  26156. return clazz3;
  26157. });
  26158. const style = computed(() => {
  26159. const backgroundColor = __UNI_FEATURE_NAVIGATIONBAR_TRANSPARENT__ && navigationBar.type === "transparent" ? usePageHeadTransparentBackgroundColor(navigationBar.backgroundColor) : navigationBar.backgroundColor;
  26160. return {
  26161. backgroundColor,
  26162. color: navigationBar.titleColor,
  26163. transitionDuration: navigationBar.duration,
  26164. transitionTimingFunction: navigationBar.timingFunc
  26165. };
  26166. });
  26167. return {
  26168. clazz: clazz2,
  26169. style
  26170. };
  26171. }
  26172. function usePageHeadButtons({
  26173. id: id2,
  26174. navigationBar
  26175. }) {
  26176. const left = [];
  26177. const right = [];
  26178. const {
  26179. buttons
  26180. } = navigationBar;
  26181. if (isArray(buttons)) {
  26182. const {
  26183. type
  26184. } = navigationBar;
  26185. const isTransparent = type === "transparent";
  26186. const fonts = /* @__PURE__ */ Object.create(null);
  26187. buttons.forEach((btn, index2) => {
  26188. if (btn.fontSrc && !btn.fontFamily) {
  26189. const fontSrc = getRealPath(btn.fontSrc);
  26190. let fontFamily = fonts[fontSrc];
  26191. if (!fontFamily) {
  26192. fontFamily = `font${Date.now()}`;
  26193. fonts[fontSrc] = fontFamily;
  26194. onBeforeMount(() => updateStyle("uni-btn-" + fontFamily, `@font-face{font-family: "${fontFamily}";src: url("${fontSrc}") format("truetype")}`));
  26195. }
  26196. btn.fontFamily = fontFamily;
  26197. }
  26198. const pageHeadBtn = usePageHeadButton(id2, index2, btn, isTransparent);
  26199. if (btn.float === "left") {
  26200. left.push(pageHeadBtn);
  26201. } else {
  26202. right.push(pageHeadBtn);
  26203. }
  26204. });
  26205. }
  26206. return {
  26207. left,
  26208. right
  26209. };
  26210. }
  26211. function usePageHeadButton(pageId, index2, btn, isTransparent) {
  26212. const iconStyle = {
  26213. color: btn.color,
  26214. fontSize: btn.fontSize,
  26215. fontWeight: btn.fontWeight
  26216. };
  26217. if (btn.fontFamily) {
  26218. iconStyle.fontFamily = btn.fontFamily;
  26219. }
  26220. return new Proxy({
  26221. btnClass: {
  26222. // 类似这样的大量重复的字符串,会在gzip时压缩大小,无需在代码层考虑优化相同字符串
  26223. "uni-page-head-btn": true,
  26224. "uni-page-head-btn-red-dot": !!(btn.redDot || btn.badgeText),
  26225. "uni-page-head-btn-select": !!btn.select
  26226. },
  26227. btnStyle: {
  26228. backgroundColor: isTransparent ? btn.background : "transparent",
  26229. width: btn.width
  26230. },
  26231. btnText: "",
  26232. btnIconPath: ICON_PATHS[btn.type],
  26233. badgeText: btn.badgeText,
  26234. iconStyle,
  26235. onClick() {
  26236. invokeHook(pageId, ON_NAVIGATION_BAR_BUTTON_TAP, extend({
  26237. index: index2
  26238. }, btn));
  26239. },
  26240. btnSelect: btn.select
  26241. }, {
  26242. get(target, key, receiver) {
  26243. if (["btnText"].includes(key)) {
  26244. return btn.fontSrc && btn.fontFamily ? btn.text.replace("\\u", "&#x") : btn.text;
  26245. } else {
  26246. return Reflect.get(target, key, receiver);
  26247. }
  26248. }
  26249. });
  26250. }
  26251. function usePageHeadSearchInput({
  26252. id: id2,
  26253. navigationBar: {
  26254. searchInput
  26255. }
  26256. }) {
  26257. const focus = ref(false);
  26258. const text2 = ref("");
  26259. const composing = ref(false);
  26260. const {
  26261. disabled
  26262. } = searchInput;
  26263. if (disabled) {
  26264. const onClick = () => {
  26265. invokeHook(id2, ON_NAVIGATION_BAR_SEARCH_INPUT_CLICKED);
  26266. };
  26267. return {
  26268. focus,
  26269. text: text2,
  26270. composing,
  26271. onClick
  26272. };
  26273. }
  26274. const onFocus = () => {
  26275. focus.value = true;
  26276. invokeHook(id2, ON_NAVIGATION_BAR_SEARCH_INPUT_FOCUS_CHANGED, {
  26277. focus: true
  26278. });
  26279. };
  26280. const onBlur = () => {
  26281. focus.value = false;
  26282. invokeHook(id2, ON_NAVIGATION_BAR_SEARCH_INPUT_FOCUS_CHANGED, {
  26283. focus: false
  26284. });
  26285. };
  26286. const onInput = (evt) => {
  26287. text2.value = evt.detail.value;
  26288. invokeHook(id2, ON_NAVIGATION_BAR_SEARCH_INPUT_CHANGED, {
  26289. text: text2.value
  26290. });
  26291. };
  26292. const onConfirm = (evt) => {
  26293. invokeHook(id2, ON_NAVIGATION_BAR_SEARCH_INPUT_CONFIRMED, {
  26294. text: text2.value
  26295. });
  26296. };
  26297. return {
  26298. focus,
  26299. text: text2,
  26300. composing,
  26301. onFocus,
  26302. onBlur,
  26303. onInput,
  26304. onConfirm
  26305. };
  26306. }
  26307. const _sfc_main = {
  26308. name: "PageRefresh",
  26309. setup() {
  26310. const { pullToRefresh } = usePageMeta();
  26311. return {
  26312. offset: pullToRefresh.offset,
  26313. color: pullToRefresh.color
  26314. };
  26315. }
  26316. };
  26317. const _export_sfc = (sfc, props2) => {
  26318. const target = sfc.__vccOpts || sfc;
  26319. for (const [key, val] of props2) {
  26320. target[key] = val;
  26321. }
  26322. return target;
  26323. };
  26324. const _hoisted_1 = { class: "uni-page-refresh-inner" };
  26325. const _hoisted_2 = ["fill"];
  26326. const _hoisted_3 = /* @__PURE__ */ createElementVNode("path", { d: "M17.65 6.35C16.2 4.9 14.21 4 12 4c-4.42 0-7.99 3.58-7.99 8s3.57 8 7.99 8c3.73 0 6.84-2.55 7.73-6h-2.08c-.82 2.33-3.04 4-5.65 4-3.31 0-6-2.69-6-6s2.69-6 6-6c1.66 0 3.14.69 4.22 1.78L13 11h7V4l-2.35 2.35z" }, null, -1);
  26327. const _hoisted_4 = /* @__PURE__ */ createElementVNode("path", {
  26328. d: "M0 0h24v24H0z",
  26329. fill: "none"
  26330. }, null, -1);
  26331. const _hoisted_5 = [
  26332. _hoisted_3,
  26333. _hoisted_4
  26334. ];
  26335. const _hoisted_6 = {
  26336. class: "uni-page-refresh__spinner",
  26337. width: "24",
  26338. height: "24",
  26339. viewBox: "25 25 50 50"
  26340. };
  26341. const _hoisted_7 = ["stroke"];
  26342. function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  26343. return openBlock(), createElementBlock("uni-page-refresh", null, [
  26344. createElementVNode("div", {
  26345. style: normalizeStyle({ "margin-top": $setup.offset + "px" }),
  26346. class: "uni-page-refresh"
  26347. }, [
  26348. createElementVNode("div", _hoisted_1, [
  26349. (openBlock(), createElementBlock("svg", {
  26350. fill: $setup.color,
  26351. class: "uni-page-refresh__icon",
  26352. width: "24",
  26353. height: "24",
  26354. viewBox: "0 0 24 24"
  26355. }, _hoisted_5, 8, _hoisted_2)),
  26356. (openBlock(), createElementBlock("svg", _hoisted_6, [
  26357. createElementVNode("circle", {
  26358. stroke: $setup.color,
  26359. class: "uni-page-refresh__path",
  26360. cx: "50",
  26361. cy: "50",
  26362. r: "20",
  26363. fill: "none",
  26364. "stroke-width": "4",
  26365. "stroke-miterlimit": "10"
  26366. }, null, 8, _hoisted_7)
  26367. ]))
  26368. ])
  26369. ], 4)
  26370. ]);
  26371. }
  26372. const PageRefresh = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
  26373. function processDeltaY(ev, identifier, startY) {
  26374. const touch = Array.prototype.slice.call(ev.changedTouches).filter((touch2) => touch2.identifier === identifier)[0];
  26375. if (!touch) {
  26376. return false;
  26377. }
  26378. ev.deltaY = touch.pageY - startY;
  26379. return true;
  26380. }
  26381. const PULLING = "pulling";
  26382. const REACHED = "reached";
  26383. const ABORTING = "aborting";
  26384. const REFRESHING = "refreshing";
  26385. const RESTORING = "restoring";
  26386. function usePageRefresh(refreshRef) {
  26387. const { id: id2, pullToRefresh } = usePageMeta();
  26388. const { range, height } = pullToRefresh;
  26389. let refreshContainerElem;
  26390. let refreshControllerElem;
  26391. let refreshControllerElemStyle;
  26392. let refreshInnerElemStyle;
  26393. useSubscribe(
  26394. () => {
  26395. if (!state2) {
  26396. state2 = REFRESHING;
  26397. addClass();
  26398. setTimeout(() => {
  26399. refreshing();
  26400. }, 50);
  26401. }
  26402. },
  26403. API_START_PULL_DOWN_REFRESH,
  26404. false,
  26405. id2
  26406. );
  26407. useSubscribe(
  26408. () => {
  26409. if (state2 === REFRESHING) {
  26410. removeClass();
  26411. state2 = RESTORING;
  26412. addClass();
  26413. restoring(() => {
  26414. removeClass();
  26415. state2 = distance2 = offset = null;
  26416. });
  26417. }
  26418. },
  26419. API_STOP_PULL_DOWN_REFRESH,
  26420. false,
  26421. id2
  26422. );
  26423. onMounted(() => {
  26424. refreshContainerElem = refreshRef.value.$el;
  26425. refreshControllerElem = refreshContainerElem.querySelector(".uni-page-refresh");
  26426. refreshControllerElemStyle = refreshControllerElem.style;
  26427. refreshInnerElemStyle = refreshControllerElem.querySelector(
  26428. ".uni-page-refresh-inner"
  26429. ).style;
  26430. });
  26431. let touchId;
  26432. let startY;
  26433. let canRefresh;
  26434. let state2;
  26435. let distance2 = null;
  26436. let offset = null;
  26437. function toggleClass(type) {
  26438. if (!state2) {
  26439. return;
  26440. }
  26441. if (refreshContainerElem) {
  26442. refreshContainerElem.classList[type]("uni-page-refresh--" + state2);
  26443. }
  26444. }
  26445. function addClass() {
  26446. toggleClass("add");
  26447. }
  26448. function removeClass() {
  26449. toggleClass("remove");
  26450. }
  26451. function pulling(deltaY) {
  26452. if (!refreshControllerElem) {
  26453. return;
  26454. }
  26455. let rotate = deltaY / range;
  26456. if (rotate > 1) {
  26457. rotate = 1;
  26458. } else {
  26459. rotate = rotate * rotate * rotate;
  26460. }
  26461. const y = Math.round(deltaY / (range / height)) || 0;
  26462. refreshInnerElemStyle.transform = "rotate(" + 360 * rotate + "deg)";
  26463. refreshControllerElemStyle.clip = "rect(" + (45 - y) + "px,45px,45px,-5px)";
  26464. refreshControllerElemStyle.transform = "translate3d(-50%, " + y + "px, 0)";
  26465. }
  26466. const onTouchstartPassive = withWebEvent((ev) => {
  26467. const touch = ev.changedTouches[0];
  26468. touchId = touch.identifier;
  26469. startY = touch.pageY;
  26470. if ([ABORTING, REFRESHING, RESTORING].indexOf(state2) >= 0) {
  26471. canRefresh = false;
  26472. } else {
  26473. canRefresh = true;
  26474. }
  26475. });
  26476. const onTouchmove = withWebEvent((ev) => {
  26477. if (!canRefresh) {
  26478. return;
  26479. }
  26480. if (!processDeltaY(ev, touchId, startY)) {
  26481. return;
  26482. }
  26483. let { deltaY } = ev;
  26484. if ((document.documentElement.scrollTop || document.body.scrollTop) !== 0) {
  26485. touchId = null;
  26486. return;
  26487. }
  26488. if (deltaY < 0 && !state2) {
  26489. return;
  26490. }
  26491. ev.preventDefault();
  26492. if (distance2 === null) {
  26493. offset = deltaY;
  26494. state2 = PULLING;
  26495. addClass();
  26496. }
  26497. deltaY = deltaY - offset;
  26498. if (deltaY < 0) {
  26499. deltaY = 0;
  26500. }
  26501. distance2 = deltaY;
  26502. const isReached = deltaY >= range && state2 !== REACHED;
  26503. const isPulling = deltaY < range && state2 !== PULLING;
  26504. if (isReached || isPulling) {
  26505. removeClass();
  26506. state2 = state2 === REACHED ? PULLING : REACHED;
  26507. addClass();
  26508. }
  26509. pulling(deltaY);
  26510. });
  26511. const onTouchend = withWebEvent((ev) => {
  26512. if (!processDeltaY(ev, touchId, startY)) {
  26513. return;
  26514. }
  26515. if (state2 === null) {
  26516. return;
  26517. }
  26518. if (state2 === PULLING) {
  26519. removeClass();
  26520. state2 = ABORTING;
  26521. addClass();
  26522. aborting(() => {
  26523. removeClass();
  26524. state2 = distance2 = offset = null;
  26525. });
  26526. } else if (state2 === REACHED) {
  26527. removeClass();
  26528. state2 = REFRESHING;
  26529. addClass();
  26530. refreshing();
  26531. }
  26532. });
  26533. function aborting(callback) {
  26534. if (!refreshControllerElem) {
  26535. return;
  26536. }
  26537. if (refreshControllerElemStyle.transform) {
  26538. refreshControllerElemStyle.transition = "-webkit-transform 0.3s";
  26539. refreshControllerElemStyle.transform = "translate3d(-50%, 0, 0)";
  26540. const abortTransitionEnd = function() {
  26541. timeout && clearTimeout(timeout);
  26542. refreshControllerElem.removeEventListener(
  26543. "webkitTransitionEnd",
  26544. abortTransitionEnd
  26545. );
  26546. refreshControllerElemStyle.transition = "";
  26547. callback();
  26548. };
  26549. refreshControllerElem.addEventListener(
  26550. "webkitTransitionEnd",
  26551. abortTransitionEnd
  26552. );
  26553. const timeout = setTimeout(abortTransitionEnd, 350);
  26554. } else {
  26555. callback();
  26556. }
  26557. }
  26558. function refreshing() {
  26559. if (!refreshControllerElem) {
  26560. return;
  26561. }
  26562. refreshControllerElemStyle.transition = "-webkit-transform 0.2s";
  26563. refreshControllerElemStyle.transform = "translate3d(-50%, " + height + "px, 0)";
  26564. invokeHook(id2, ON_PULL_DOWN_REFRESH);
  26565. }
  26566. function restoring(callback) {
  26567. if (!refreshControllerElem) {
  26568. return;
  26569. }
  26570. refreshControllerElemStyle.transition = "-webkit-transform 0.3s";
  26571. refreshControllerElemStyle.transform += " scale(0.01)";
  26572. const restoreTransitionEnd = function() {
  26573. timeout && clearTimeout(timeout);
  26574. refreshControllerElem.removeEventListener(
  26575. "webkitTransitionEnd",
  26576. restoreTransitionEnd
  26577. );
  26578. refreshControllerElemStyle.transition = "";
  26579. refreshControllerElemStyle.transform = "translate3d(-50%, 0, 0)";
  26580. callback();
  26581. };
  26582. refreshControllerElem.addEventListener(
  26583. "webkitTransitionEnd",
  26584. restoreTransitionEnd
  26585. );
  26586. const timeout = setTimeout(restoreTransitionEnd, 350);
  26587. }
  26588. return {
  26589. onTouchstartPassive,
  26590. onTouchmove,
  26591. onTouchend,
  26592. onTouchcancel: onTouchend
  26593. };
  26594. }
  26595. const PageBody = defineSystemComponent({
  26596. name: "PageBody",
  26597. setup(props2, ctx) {
  26598. const pageMeta = __UNI_FEATURE_PULL_DOWN_REFRESH__ && usePageMeta();
  26599. const refreshRef = __UNI_FEATURE_PULL_DOWN_REFRESH__ && ref(null);
  26600. const pageRefresh = __UNI_FEATURE_PULL_DOWN_REFRESH__ && pageMeta.enablePullDownRefresh ? usePageRefresh(refreshRef) : null;
  26601. return () => {
  26602. const pageRefreshTsx = __UNI_FEATURE_PULL_DOWN_REFRESH__ && createPageRefreshTsx(refreshRef, pageMeta);
  26603. return createVNode(Fragment, null, [pageRefreshTsx, createVNode("uni-page-wrapper", pageRefresh, [createVNode("uni-page-body", null, [renderSlot(ctx.slots, "default")])], 16)]);
  26604. };
  26605. }
  26606. });
  26607. function createPageRefreshTsx(refreshRef, pageMeta) {
  26608. if (!__UNI_FEATURE_PULL_DOWN_REFRESH__ || !pageMeta.enablePullDownRefresh) {
  26609. return null;
  26610. }
  26611. return createVNode(PageRefresh, {
  26612. "ref": refreshRef
  26613. }, null, 512);
  26614. }
  26615. const index = defineSystemComponent({
  26616. name: "Page",
  26617. setup(_props, ctx) {
  26618. const pageMeta = providePageMeta(getStateId());
  26619. const navigationBar = pageMeta.navigationBar;
  26620. useDocumentTitle(pageMeta);
  26621. return () => createVNode(
  26622. "uni-page",
  26623. { "data-page": pageMeta.route },
  26624. __UNI_FEATURE_NAVIGATIONBAR__ && navigationBar.style !== "custom" ? [createVNode(PageHead), createPageBodyVNode(ctx)] : [createPageBodyVNode(ctx)]
  26625. );
  26626. }
  26627. });
  26628. function createPageBodyVNode(ctx) {
  26629. return openBlock(), createBlock(
  26630. PageBody,
  26631. { key: 0 },
  26632. {
  26633. default: withCtx(() => [renderSlot(ctx.slots, "page")]),
  26634. _: 3
  26635. }
  26636. );
  26637. }
  26638. export {
  26639. $emit,
  26640. $off,
  26641. $on,
  26642. $once,
  26643. index$6 as Ad,
  26644. index$5 as AdContentPage,
  26645. index$4 as AdDraw,
  26646. AsyncErrorComponent,
  26647. AsyncLoadingComponent,
  26648. index$y as Button,
  26649. index$3 as Camera,
  26650. index$w as Canvas,
  26651. index$u as Checkbox,
  26652. index$v as CheckboxGroup,
  26653. index$8 as CoverImage,
  26654. index$9 as CoverView,
  26655. index$t as Editor,
  26656. index$A as Form,
  26657. index$s as Icon,
  26658. index$r as Image,
  26659. Input,
  26660. index$z as Label,
  26661. LayoutComponent,
  26662. index$h as ListItem,
  26663. index$i as ListView,
  26664. index$2 as LivePlayer,
  26665. index$1 as LivePusher,
  26666. Map$1 as Map,
  26667. MovableArea,
  26668. MovableView,
  26669. index$q as Navigator,
  26670. index as PageComponent,
  26671. index$7 as Picker,
  26672. PickerView,
  26673. PickerViewColumn,
  26674. index$p as Progress,
  26675. indexX$2 as Radio,
  26676. index$o as RadioGroup,
  26677. ResizeSensor,
  26678. index$n as RichText,
  26679. ScrollView,
  26680. indexX$1 as Slider,
  26681. index$f as StickyHeader,
  26682. index$g as StickySection,
  26683. Swiper,
  26684. SwiperItem,
  26685. index$m as Switch,
  26686. index$l as Text,
  26687. index$k as Textarea,
  26688. UniButtonElement,
  26689. UniCanvasElement,
  26690. UniCheckboxElement,
  26691. UniCheckboxGroupElement,
  26692. UniCoverImageElement,
  26693. UniCoverViewElement,
  26694. UniEditorElement,
  26695. UniElement,
  26696. UniElement as UniElementImpl,
  26697. UniFormElement,
  26698. UniIconElement,
  26699. UniImageElement,
  26700. UniInputElement,
  26701. UniLabelElement,
  26702. UniListItemElement,
  26703. UniListViewElement,
  26704. UniMapElement,
  26705. UniMovableAreaElement,
  26706. UniMovableViewElement,
  26707. UniNavigatorElement,
  26708. UniPickerElement,
  26709. UniPickerViewColumnElement,
  26710. UniPickerViewElement,
  26711. UniProgressElement,
  26712. UniRadioElement,
  26713. UniRadioGroupElement,
  26714. UniRichTextElement,
  26715. UniScrollViewElement,
  26716. UniServiceJSBridge$1 as UniServiceJSBridge,
  26717. UniSliderElement,
  26718. UniStickyHeaderElement,
  26719. UniStickySectionElement,
  26720. UniSwiperElement,
  26721. UniSwiperItemElement,
  26722. UniSwitchElement,
  26723. UniTextElement,
  26724. UniTextareaElement,
  26725. UniVideoElement,
  26726. UniViewElement,
  26727. UniViewJSBridge$1 as UniViewJSBridge,
  26728. UniWebViewElement,
  26729. index$c as Video,
  26730. index$j as View,
  26731. indexX as WebView,
  26732. addInterceptor,
  26733. addPhoneContact,
  26734. arrayBufferToBase64,
  26735. base64ToArrayBuffer,
  26736. canIUse,
  26737. canvasGetImageData,
  26738. canvasPutImageData,
  26739. canvasToTempFilePath,
  26740. chooseFile,
  26741. chooseImage,
  26742. chooseLocation,
  26743. chooseVideo,
  26744. clearStorage,
  26745. clearStorageSync,
  26746. closePreviewImage,
  26747. closeSocket,
  26748. connectSocket,
  26749. createAnimation$1 as createAnimation,
  26750. createCameraContext,
  26751. createCanvasContext,
  26752. createInnerAudioContext,
  26753. createIntersectionObserver,
  26754. createLivePlayerContext,
  26755. createMapContext,
  26756. createMediaQueryObserver,
  26757. createSelectorQuery,
  26758. createVideoContext,
  26759. cssBackdropFilter,
  26760. cssConstant,
  26761. cssEnv,
  26762. cssVar,
  26763. downloadFile,
  26764. getApp$1 as getApp,
  26765. getAppBaseInfo,
  26766. getClipboardData,
  26767. getCurrentPages$1 as getCurrentPages,
  26768. getDeviceInfo,
  26769. getElementById,
  26770. getEnterOptionsSync,
  26771. getFileInfo,
  26772. getImageInfo,
  26773. getLaunchOptionsSync,
  26774. getLeftWindowStyle,
  26775. getLocale,
  26776. getLocation,
  26777. getNetworkType,
  26778. getProvider,
  26779. getPushClientId,
  26780. getRealPath,
  26781. getRecorderManager,
  26782. getRightWindowStyle,
  26783. getSavedFileInfo,
  26784. getSavedFileList,
  26785. getScreenBrightness,
  26786. getSelectedTextRange$1 as getSelectedTextRange,
  26787. getStorage,
  26788. getStorageInfo,
  26789. getStorageInfoSync,
  26790. getStorageSync,
  26791. getSystemInfo,
  26792. getSystemInfoSync,
  26793. getTopWindowStyle,
  26794. getVideoInfo,
  26795. getWindowInfo,
  26796. hideActionSheet,
  26797. hideKeyboard,
  26798. hideLeftWindow,
  26799. hideLoading,
  26800. hideModal,
  26801. hideNavigationBarLoading,
  26802. hideRightWindow,
  26803. hideTabBar,
  26804. hideTabBarRedDot,
  26805. hideToast,
  26806. hideTopWindow,
  26807. interceptors,
  26808. invokePushCallback,
  26809. loadFontFace,
  26810. login,
  26811. makePhoneCall,
  26812. navigateBack,
  26813. navigateTo,
  26814. offAccelerometerChange,
  26815. offAppHide,
  26816. offAppShow,
  26817. offCompassChange,
  26818. offError,
  26819. offLocationChange,
  26820. offLocationChangeError,
  26821. offNetworkStatusChange,
  26822. offPageNotFound,
  26823. offPushMessage,
  26824. offThemeChange,
  26825. offUnhandledRejection,
  26826. offWindowResize,
  26827. onAccelerometerChange,
  26828. onAppHide,
  26829. onAppShow,
  26830. onCompassChange,
  26831. onCreateVueApp2 as onCreateVueApp,
  26832. onError,
  26833. onGyroscopeChange,
  26834. onLocaleChange,
  26835. onLocationChange,
  26836. onLocationChangeError,
  26837. onMemoryWarning,
  26838. onNetworkStatusChange,
  26839. onPageNotFound,
  26840. onPushMessage,
  26841. onSocketClose,
  26842. onSocketError,
  26843. onSocketMessage,
  26844. onSocketOpen,
  26845. onTabBarMidButtonTap,
  26846. onThemeChange,
  26847. onUnhandledRejection,
  26848. onUserCaptureScreen,
  26849. onWindowResize,
  26850. openDocument,
  26851. openLocation,
  26852. pageScrollTo,
  26853. index$d as plugin,
  26854. preloadPage,
  26855. previewImage,
  26856. reLaunch,
  26857. redirectTo,
  26858. removeInterceptor,
  26859. removeSavedFile,
  26860. removeStorage,
  26861. removeStorageSync,
  26862. removeTabBarBadge,
  26863. request,
  26864. upx2px as rpx2px,
  26865. saveFile,
  26866. saveImageToPhotosAlbum,
  26867. saveVideoToPhotosAlbum,
  26868. scanCode,
  26869. sendSocketMessage,
  26870. setClipboardData,
  26871. setKeepScreenOn,
  26872. setLeftWindowStyle,
  26873. setLocale,
  26874. setNavigationBarColor,
  26875. setNavigationBarTitle,
  26876. setPageMeta,
  26877. setRightWindowStyle,
  26878. setScreenBrightness,
  26879. setStorage,
  26880. setStorageSync,
  26881. setTabBarBadge,
  26882. setTabBarItem,
  26883. setTabBarStyle,
  26884. setTopWindowStyle,
  26885. setupApp,
  26886. setupPage,
  26887. setupWindow,
  26888. showActionSheet,
  26889. showLeftWindow,
  26890. showLoading,
  26891. showModal,
  26892. showNavigationBarLoading,
  26893. showRightWindow,
  26894. showTabBar,
  26895. showTabBarRedDot,
  26896. showToast,
  26897. showTopWindow,
  26898. startAccelerometer,
  26899. startCompass,
  26900. startGyroscope,
  26901. startLocationUpdate,
  26902. startPullDownRefresh,
  26903. stopAccelerometer,
  26904. stopCompass,
  26905. stopGyroscope,
  26906. stopLocationUpdate,
  26907. stopPullDownRefresh,
  26908. switchTab,
  26909. uni$1 as uni,
  26910. uploadFile,
  26911. upx2px,
  26912. useI18n,
  26913. useTabBar,
  26914. vibrateLong,
  26915. vibrateShort
  26916. };