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