import{c as T,aS as L,E as z,D as S,w as E,J as h,K as M,N as W,M as V,d as Y,aU as j,n as J,a4 as Q,a2 as X,aV as q,a8 as G,F as Z,Y as ee,aW as D,aA as te,aX as ne,H as oe,j as ae,ar as le,aQ as se,aR as re}from"./index-ae60edf9.js";import{d as p,b as N,$ as o,k as O,l as ce,am as R,bm as ie}from"./@vue-cb50a1c4.js";import{B as k}from"./index-e4a7d928.js";const[F,A]=T("action-bar"),I=Symbol(F),ue={placeholder:Boolean,safeAreaInsetBottom:S};var de=p({name:F,props:ue,setup(e,{slots:a}){const n=N(),s=L(n,A),{linkChildren:r}=z(I);r();const f=()=>{var m;return o("div",{ref:n,class:[A(),{"van-safe-area-bottom":e.safeAreaInsetBottom}]},[(m=a.default)==null?void 0:m.call(a)])};return()=>e.placeholder?s(f):f()}});const fe=E(de),[me,Be]=T("action-bar-button"),ge=h({},M,{type:String,text:String,icon:String,color:String,loading:Boolean,disabled:Boolean});var he=p({name:me,props:ge,setup(e,{slots:a}){const n=W(),{parent:s,index:r}=V(I),f=O(()=>{if(s){const c=s.children[r.value-1];return!(c&&"isButton"in c)}}),m=O(()=>{if(s){const c=s.children[r.value+1];return!(c&&"isButton"in c)}});return Y({isButton:!0}),()=>{const{type:c,icon:B,text:g,color:w,loading:v,disabled:y}=e;return o(k,{class:Be([c,{last:m.value,first:f.value}]),size:"large",type:c,icon:B,color:w,loading:v,disabled:y,onClick:n},{default:()=>[a.default?a.default():g]})}}});const _=E(he),[Ce,i,b]=T("dialog"),be=h({},j,{title:String,theme:String,width:J,message:[String,Function],callback:Function,allowHtml:Boolean,className:Q,transition:X("van-dialog-bounce"),messageAlign:String,closeOnPopstate:S,showCancelButton:Boolean,cancelButtonText:String,cancelButtonColor:String,cancelButtonDisabled:Boolean,confirmButtonText:String,confirmButtonColor:String,confirmButtonDisabled:Boolean,showConfirmButton:S,closeOnClickOverlay:Boolean}),we=[...q,"transition","closeOnPopstate"];var ve=p({name:Ce,props:be,emits:["confirm","cancel","keydown","update:show"],setup(e,{emit:a,slots:n}){const s=N(),r=ce({confirm:!1,cancel:!1}),f=t=>a("update:show",t),m=t=>{var l;f(!1),(l=e.callback)==null||l.call(e,t)},c=t=>()=>{e.show&&(a(t),e.beforeClose?(r[t]=!0,ae(e.beforeClose,{args:[t],done(){m(t),r[t]=!1},canceled(){r[t]=!1}})):m(t))},B=c("cancel"),g=c("confirm"),w=ie(t=>{var l,u;if(t.target!==((u=(l=s.value)==null?void 0:l.popupRef)==null?void 0:u.value))return;({Enter:e.showConfirmButton?g:D,Escape:e.showCancelButton?B:D})[t.key](),a("keydown",t)},["enter","esc"]),v=()=>{const t=n.title?n.title():e.title;if(t)return o("div",{class:i("header",{isolated:!e.message&&!n.default})},[t])},y=t=>{const{message:l,allowHtml:u,messageAlign:d}=e,C=i("message",{"has-title":t,[d]:d}),P=te(l)?l():l;return u&&typeof P=="string"?o("div",{class:C,innerHTML:P},null):o("div",{class:C},[P])},H=()=>{if(n.default)return o("div",{class:i("content")},[n.default()]);const{title:t,message:l,allowHtml:u}=e;if(l){const d=!!(t||n.title);return o("div",{key:u?1:0,class:i("content",{isolated:!d})},[y(d)])}},K=()=>o("div",{class:[oe,i("footer")]},[e.showCancelButton&&o(k,{size:"large",text:e.cancelButtonText||b("cancel"),class:i("cancel"),style:{color:e.cancelButtonColor},loading:r.cancel,disabled:e.cancelButtonDisabled,onClick:B},null),e.showConfirmButton&&o(k,{size:"large",text:e.confirmButtonText||b("confirm"),class:[i("confirm"),{[ne]:e.showCancelButton}],style:{color:e.confirmButtonColor},loading:r.confirm,disabled:e.confirmButtonDisabled,onClick:g},null)]),$=()=>o(fe,{class:i("footer")},{default:()=>[e.showCancelButton&&o(_,{type:"warning",text:e.cancelButtonText||b("cancel"),class:i("cancel"),color:e.cancelButtonColor,loading:r.cancel,disabled:e.cancelButtonDisabled,onClick:B},null),e.showConfirmButton&&o(_,{type:"danger",text:e.confirmButtonText||b("confirm"),class:i("confirm"),color:e.confirmButtonColor,loading:r.confirm,disabled:e.confirmButtonDisabled,onClick:g},null)]}),U=()=>n.footer?n.footer():e.theme==="round-button"?$():K();return()=>{const{width:t,title:l,theme:u,message:d,className:C}=e;return o(ee,R({ref:s,role:"dialog",class:[i([u]),C],style:{width:Z(t)},tabindex:0,"aria-labelledby":l||d,onKeydown:w,"onUpdate:show":f},G(e,we)),{default:()=>[v(),H(),U()]})}}});let x;const ye={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};let Pe=h({},ye);function Se(){({instance:x}=se({setup(){const{state:a,toggle:n}=re();return()=>o(ve,R(a,{"onUpdate:show":n}),null)}}))}function ke(e){return le?new Promise((a,n)=>{x||Se(),x.open(h({},Pe,e,{callback:s=>{(s==="confirm"?a:n)(s)}}))}):Promise.resolve(void 0)}const De=e=>ke(h({showCancelButton:!0},e));export{ve as a,De as s};
