import{y as t,d as o,I as e,aY as n,ae as l,G as a,a as s,w as c,a5 as i,ao as r,aZ as u,aq as d,c as m,ac as f,B,a_ as g,A as b,ap as p,D as h,a$ as C,r as v,H as w,ay as y,z as x,P as k,b0 as S,b1 as D,b2 as T,b3 as O,b4 as A,al as H,$ as P,b5 as z,b6 as I}from"./index-4bd11d60.js";const[N,E]=t("action-bar"),F=Symbol(N),U=c(o({name:N,props:{placeholder:Boolean,safeAreaInsetBottom:a},setup(t,{slots:o}){const a=e(),c=n(a,E),{linkChildren:i}=l(F);i();const r=()=>{var e;return s("div",{ref:a,"class":[E(),{"van-safe-area-bottom":t.safeAreaInsetBottom}]},[null==(e=o["default"])?void 0:e.call(o)])};return()=>t.placeholder?c(r):r()}})),[$,j]=t("action-bar-button"),q=c(o({name:$,props:i({},r,{type:String,text:String,icon:String,color:String,loading:Boolean,disabled:Boolean}),setup(t,{slots:o}){const e=u(),{parent:n,index:l}=d(F),a=m((()=>{if(n){const t=n.children[l.value-1];return!(t&&"isButton"in t)}})),c=m((()=>{if(n){const t=n.children[l.value+1];return!(t&&"isButton"in t)}}));return f({isButton:!0}),()=>{const{type:n,icon:l,text:i,color:r,loading:u,disabled:d}=t;return s(B,{"class":j([n,{last:c.value,first:a.value}]),size:"large",type:n,icon:l,color:r,loading:u,disabled:d,onClick:e},{"default":()=>[o["default"]?o["default"]():i]})}}})),[G,K,L]=t("dialog"),M=i({},g,{title:String,theme:String,width:b,message:[String,Function],callback:Function,allowHtml:Boolean,className:p,transition:h("van-dialog-bounce"),messageAlign:String,closeOnPopstate:a,showCancelButton:Boolean,cancelButtonText:String,cancelButtonColor:String,cancelButtonDisabled:Boolean,confirmButtonText:String,confirmButtonColor:String,confirmButtonDisabled:Boolean,showConfirmButton:a,closeOnClickOverlay:Boolean}),R=[...C,"transition","closeOnPopstate"];var Y=o({name:G,props:M,emits:["confirm","cancel","keydown","update:show"],setup(t,{emit:o,slots:n}){const l=e(),a=v({confirm:!1,cancel:!1}),c=t=>o("update:show",t),i=o=>{var e;c(!1),null==(e=t.callback)||e.call(t,o)},r=e=>()=>{t.show&&(o(e),t.beforeClose?(a[e]=!0,H(t.beforeClose,{args:[e],done(){i(e),a[e]=!1},canceled(){a[e]=!1}})):i(e))},u=r("cancel"),d=r("confirm"),m=S((e=>{var n,a;e.target===(null==(a=null==(n=l.value)?void 0:n.popupRef)?void 0:a.value)&&({Enter:t.showConfirmButton?d:D,Escape:t.showCancelButton?u:D}[e.key](),o("keydown",e))}),["enter","esc"]),f=()=>{const o=n.title?n.title():t.title;if(o)return s("div",{"class":K("header",{isolated:!t.message&&!n["default"]})},[o])},g=o=>{const{message:e,allowHtml:n,messageAlign:l}=t,a=K("message",{"has-title":o,[l]:l}),c=T(e)?e():e;return n&&"string"==typeof c?s("div",{"class":a,innerHTML:c},null):s("div",{"class":a},[c])},b=()=>{if(n["default"])return s("div",{"class":K("content")},[n["default"]()]);const{title:o,message:e,allowHtml:l}=t;if(e){const t=!(!o&&!n.title);return s("div",{key:l?1:0,"class":K("content",{isolated:!t})},[g(t)])}};return()=>{const{width:o,title:e,theme:i,message:r,className:g}=t;return s(k,w({ref:l,role:"dialog","class":[K([i]),g],style:{width:x(o)},tabindex:0,"aria-labelledby":e||r,onKeydown:m,"onUpdate:show":c},y(t,R)),{"default":()=>[f(),b(),n.footer?n.footer():"round-button"===t.theme?s(U,{"class":K("footer")},{"default":()=>[t.showCancelButton&&s(q,{type:"warning",text:t.cancelButtonText||L("cancel"),"class":K("cancel"),color:t.cancelButtonColor,loading:a.cancel,disabled:t.cancelButtonDisabled,onClick:u},null),t.showConfirmButton&&s(q,{type:"danger",text:t.confirmButtonText||L("confirm"),"class":K("confirm"),color:t.confirmButtonColor,loading:a.confirm,disabled:t.confirmButtonDisabled,onClick:d},null)]}):s("div",{"class":[A,K("footer")]},[t.showCancelButton&&s(B,{size:"large",text:t.cancelButtonText||L("cancel"),"class":K("cancel"),style:{color:t.cancelButtonColor},loading:a.cancel,disabled:t.cancelButtonDisabled,onClick:u},null),t.showConfirmButton&&s(B,{size:"large",text:t.confirmButtonText||L("confirm"),"class":[K("confirm"),{[O]:t.showCancelButton}],style:{color:t.confirmButtonColor},loading:a.confirm,disabled:t.confirmButtonDisabled,onClick:d},null)])]})}}});let Z,_=i({},{title:"",width:"",theme:null,message:"",overlay:!0,callback:null,teleport:"body",className:"",allowHtml:!1,lockScroll:!0,transition:void 0,beforeClose:null,overlayClass:"",overlayStyle:void 0,messageAlign:"",cancelButtonText:"",cancelButtonColor:null,cancelButtonDisabled:!1,confirmButtonText:"",confirmButtonColor:null,confirmButtonDisabled:!1,showConfirmButton:!0,showCancelButton:!1,closeOnPopstate:!0,closeOnClickOverlay:!1});function J(t){return P?new Promise(((o,e)=>{Z||function(){const t={setup(){const{state:t,toggle:o}=I();return()=>s(Y,w(t,{"onUpdate:show":o}),null)}};({instance:Z}=z(t))}(),Z.open(i({},_,t,{callback:t=>{("confirm"===t?o:e)(t)}}))})):Promise.resolve(void 0)}const Q=t=>J(i({showCancelButton:!0},t));export{Q as a,J as b,Y as s};
