import{r as m,R as U,O as le,w as p,d as _,c as u,M as F,i as H,v as X,a as ce,A as ie,o as V,s as re,U as ue,T as de,F as fe,m as A,J as ve,V as me,B as ye,g as he}from"./index-b63c6ed2.js";import{n as w,t as b,d as E,S as Ce,Q as ke,y as G,c as D,E as Z,e as T,g as Oe,v as N,w as q,f as S,I as J,p as ge,T as we,l as Ie,i as be}from"./index-f8f67ba0.js";import{u as Q}from"./use-expose-fbc3766e.js";import{T as M,H as Se}from"./constant-eba5e2d8.js";import{P as pe,c as Pe}from"./on-popup-reopen-965edd2a.js";import{u as $}from"./axios-04d59af7.js";import{L as xe}from"./index-5062ddcf.js";let Te=2e3;const ze=()=>++Te,W={show:Boolean,zIndex:w,overlay:b,duration:w,teleport:[String,Object],lockScroll:b,lazyRender:b,beforeClose:Function,overlayStyle:Object,overlayClass:E,transitionAppear:Boolean,closeOnClickOverlay:b},it=Object.keys(W);function Be(e,t){return e>t?"horizontal":t>e?"vertical":""}function Ae(){const e=m(0),t=m(0),o=m(0),l=m(0),n=m(0),s=m(0),a=m(""),c=m(!0),h=()=>a.value==="vertical",y=()=>a.value==="horizontal",f=()=>{o.value=0,l.value=0,n.value=0,s.value=0,a.value="",c.value=!0};return{move:v=>{const C=v.touches[0];o.value=(C.clientX<0?0:C.clientX)-e.value,l.value=C.clientY-t.value,n.value=Math.abs(o.value),s.value=Math.abs(l.value);const k=10;(!a.value||n.valueM||s.value>M)&&(c.value=!1)},start:v=>{f(),e.value=v.touches[0].clientX,t.value=v.touches[0].clientY},reset:f,startX:e,startY:t,deltaX:o,deltaY:l,offsetX:n,offsetY:s,direction:a,isVertical:h,isHorizontal:y,isTap:c}}let P=0;const Y="van-overflow-hidden";function Ee(e,t){const o=Ae(),l="01",n="10",s=f=>{o.move(f);const i=o.deltaY.value>0?n:l,d=ke(f.target,e.value),{scrollHeight:v,offsetHeight:C,scrollTop:k}=d;let O="11";k===0?O=C>=v?"00":"01":k+C>=v&&(O="10"),O!=="11"&&o.isVertical()&&!(parseInt(O,2)&parseInt(i,2))&&G(f,!0)},a=()=>{document.addEventListener("touchstart",o.start),document.addEventListener("touchmove",s,{passive:!1}),P||document.body.classList.add(Y),P++},c=()=>{P&&(document.removeEventListener("touchstart",o.start),document.removeEventListener("touchmove",s),P--,P||document.body.classList.remove(Y))},h=()=>t()&&a(),y=()=>t()&&c();Ce(h),U(y),le(y),p(t,f=>{f?a():c()})}function ee(e){const t=m(!1);return p(e,o=>{o&&(t.value=o)},{immediate:!0}),o=>()=>t.value?o():null}const[Le,_e]=D("overlay"),De={show:Boolean,zIndex:w,duration:w,className:E,lockScroll:b,lazyRender:b,customStyle:Object};var Ne=_({name:Le,props:De,setup(e,{slots:t}){const o=m(),l=ee(()=>e.show||!e.lazyRender),n=a=>{e.lockScroll&&G(a,!0)},s=l(()=>{var a;const c=T(Oe(e.zIndex),e.customStyle);return N(e.duration)&&(c.animationDuration=`${e.duration}s`),H(u("div",{ref:o,style:c,class:[_e(),e.className]},[(a=t.default)==null?void 0:a.call(t)]),[[X,e.show]])});return Z("touchmove",n,{target:o}),()=>u(F,{name:"van-fade",appear:!0},{default:s})}});const Re=q(Ne),Me=T({},W,{round:Boolean,position:S("center"),closeIcon:S("cross"),closeable:Boolean,transition:String,iconPrefix:String,closeOnPopstate:Boolean,closeIconPosition:S("top-right"),safeAreaInsetTop:Boolean,safeAreaInsetBottom:Boolean}),[$e,j]=D("popup");var Ye=_({name:$e,inheritAttrs:!1,props:Me,emits:["open","close","opened","closed","keydown","update:show","clickOverlay","clickCloseIcon"],setup(e,{emit:t,attrs:o,slots:l}){let n,s;const a=m(),c=m(),h=ee(()=>e.show||!e.lazyRender),y=ce(()=>{const r={zIndex:a.value};if(N(e.duration)){const g=e.position==="center"?"animationDuration":"transitionDuration";r[g]=`${e.duration}s`}return r}),f=()=>{n||(n=!0,a.value=e.zIndex!==void 0?+e.zIndex:ze(),t("open"))},i=()=>{n&&Pe(e.beforeClose,{done(){n=!1,t("close"),t("update:show",!1)}})},d=r=>{t("clickOverlay",r),e.closeOnClickOverlay&&i()},v=()=>{if(e.overlay)return u(Re,A({show:e.show,class:e.overlayClass,zIndex:a.value,duration:e.duration,customStyle:e.overlayStyle,role:e.closeOnClickOverlay?"button":void 0,tabindex:e.closeOnClickOverlay?0:void 0},$(),{onClick:d}),{default:l["overlay-content"]})},C=r=>{t("clickCloseIcon",r),i()},k=()=>{if(e.closeable)return u(J,{role:"button",tabindex:0,name:e.closeIcon,class:[j("close-icon",e.closeIconPosition),Se],classPrefix:e.iconPrefix,onClick:C},null)};let O;const te=()=>{O&&clearTimeout(O),O=setTimeout(()=>{t("opened")})},oe=()=>t("closed"),ne=r=>t("keydown",r),ae=h(()=>{var r;const{round:g,position:z,safeAreaInsetTop:L,safeAreaInsetBottom:se}=e;return H(u("div",A({ref:c,style:y.value,role:"dialog",tabindex:0,class:[j({round:g,[z]:z}),{"van-safe-area-top":L,"van-safe-area-bottom":se}],onKeydown:ne},o,$()),[(r=l.default)==null?void 0:r.call(l),k()]),[[X,e.show]])}),R=()=>{const{position:r,transition:g,transitionAppear:z}=e,L=r==="center"?"van-fade":`van-popup-slide-${r}`;return u(F,{name:g||L,appear:z,onAfterEnter:te,onAfterLeave:oe},{default:ae})};return p(()=>e.show,r=>{r&&!n&&(f(),o.tabindex===0&&ie(()=>{var g;(g=c.value)==null||g.focus()})),!r&&n&&(n=!1,t("close"))}),Q({popupRef:c}),Ee(c,()=>e.show&&e.lockScroll),Z("popstate",()=>{e.closeOnPopstate&&(i(),s=!1)}),V(()=>{e.show&&f()}),re(()=>{s&&(t("update:show",!0),s=!1)}),U(()=>{e.show&&e.teleport&&(i(),s=!0)}),ue(pe,()=>e.show),()=>e.teleport?u(de,{to:e.teleport},{default:()=>[v(),R()]}):u(fe,null,[v(),R()])}});const je=q(Ye);let x=0;function Ke(e){e?(x||document.body.classList.add("van-toast--unclickable"),x++):x&&(x--,x||document.body.classList.remove("van-toast--unclickable"))}const[Ue,I]=D("toast"),Fe=["show","overlay","teleport","transition","overlayClass","overlayStyle","closeOnClickOverlay","zIndex"],He={icon:String,show:Boolean,type:S("text"),overlay:Boolean,message:w,iconSize:w,duration:we(2e3),position:S("middle"),teleport:[String,Object],wordBreak:String,className:E,iconPrefix:String,transition:S("van-fade"),loadingType:String,forbidClick:Boolean,overlayClass:E,overlayStyle:Object,closeOnClick:Boolean,closeOnClickOverlay:Boolean,zIndex:w};var Xe=_({name:Ue,props:He,emits:["update:show"],setup(e,{emit:t,slots:o}){let l,n=!1;const s=()=>{const i=e.show&&e.forbidClick;n!==i&&(n=i,Ke(n))},a=i=>t("update:show",i),c=()=>{e.closeOnClick&&a(!1)},h=()=>clearTimeout(l),y=()=>{const{icon:i,type:d,iconSize:v,iconPrefix:C,loadingType:k}=e;if(i||d==="success"||d==="fail")return u(J,{name:i||d,size:v,class:I("icon"),classPrefix:C},null);if(d==="loading")return u(xe,{class:I("loading"),size:v,type:k},null)},f=()=>{const{type:i,message:d}=e;if(o.message)return u("div",{class:I("text")},[o.message()]);if(N(d)&&d!=="")return i==="html"?u("div",{key:0,class:I("text"),innerHTML:String(d)},null):u("div",{class:I("text")},[d])};return p(()=>[e.show,e.forbidClick],s),p(()=>[e.show,e.type,e.message,e.duration],()=>{h(),e.show&&e.duration>0&&(l=setTimeout(()=>{a(!1)},e.duration))}),V(s),ve(s),()=>u(je,A({class:[I([e.position,e.wordBreak==="normal"?"break-normal":e.wordBreak,{[e.type]:!e.icon}]),e.className],lockScroll:!1,onClick:c,onClosed:h,"onUpdate:show":a},ge(e,Fe)),{default:()=>[y(),f()]})}});function Ve(){const e=ye({show:!1}),t=n=>{e.show=n},o=n=>{T(e,n,{transitionAppear:!0}),t(!0)},l=()=>t(!1);return Q({open:o,close:l,toggle:t}),{open:o,close:l,state:e,toggle:t}}function Ge(e){const t=me(e),o=document.createElement("div");return document.body.appendChild(o),{instance:t.mount(o),unmount(){t.unmount(),document.body.removeChild(o)}}}const Ze={icon:"",type:"text",message:"",className:"",overlay:!1,onClose:void 0,onOpened:void 0,duration:2e3,teleport:"body",iconSize:void 0,iconPrefix:void 0,position:"middle",transition:"van-fade",forbidClick:!1,loadingType:void 0,overlayClass:"",overlayStyle:void 0,closeOnClick:!1,closeOnClickOverlay:!1};let B=[],qe=!1,K=T({},Ze);const Je=new Map;function Qe(e){return be(e)?e:{message:e}}function We(){const{instance:e,unmount:t}=Ge({setup(){const o=m(""),{open:l,state:n,close:s,toggle:a}=Ve(),c=()=>{},h=()=>u(Xe,A(n,{onClosed:c,"onUpdate:show":a}),null);return p(o,y=>{n.message=y}),he().render=h,{open:l,close:s,message:o}}});return e}function et(){if(!B.length||qe){const e=We();B.push(e)}return B[B.length-1]}function rt(e={}){if(!Ie)return{};const t=et(),o=Qe(e);return t.open(T({},K,Je.get(o.type||K.type),o)),t}export{Re as O,je as P,it as a,Ae as b,Ge as m,W as p,rt as s,Ve as u};