import{ar as E,as as M,a as w,c as O,bp as B,aV as x,bX as P,at as s,am as Q,z as y}from"./index-OSKNspXo.js";function f(e,o=new WeakMap){if(Object(e)!==e)return e;if(o.has(e))return o.get(e);const n=e instanceof Date?new Date(e):e instanceof RegExp?new RegExp(e.source,e.flags):e instanceof Set?new Set:e instanceof Map?new Map:typeof e.constructor!="function"?Object.create(null):e.prototype!==void 0&&typeof e.prototype.constructor=="function"?e:new e.constructor;if(typeof e.constructor=="function"&&typeof e.valueOf=="function"){const t=e.valueOf();if(Object(t)!==t){const c=new e.constructor(t);return o.set(e,c),c}}return o.set(e,n),e instanceof Set?e.forEach(t=>{n.add(f(t,o))}):e instanceof Map&&e.forEach((t,c)=>{n.set(c,f(t,o))}),Object.assign(n,...Object.keys(e).map(t=>({[t]:f(e[t],o)})))}const D=E({name:"QPopupEdit",props:{modelValue:{required:!0},title:String,buttons:Boolean,labelSet:String,labelCancel:String,color:{type:String,default:"primary"},validate:{type:Function,default:()=>!0},autoSave:Boolean,cover:{type:Boolean,default:!0},disable:Boolean},emits:["update:modelValue","save","cancel","beforeShow","show","beforeHide","hide"],setup(e,{slots:o,emit:n}){const{proxy:t}=M(),{$q:c}=t,i=w(null),a=w(""),l=w("");let b=!1;const m=O(()=>B({initialValue:a.value,validate:e.validate,set:d,cancel:v,updatePosition:g},"value",()=>l.value,u=>{l.value=u}));function d(){e.validate(l.value)!==!1&&(p()===!0&&(n("save",l.value,a.value),n("update:modelValue",l.value)),S())}function v(){p()===!0&&n("cancel",l.value,a.value),S()}function g(){x(()=>{i.value.updatePosition()})}function p(){return P(l.value,a.value)===!1}function S(){b=!0,i.value.hide()}function h(){b=!1,a.value=f(e.modelValue),l.value=f(e.modelValue),n("beforeShow")}function V(){n("show")}function j(){b===!1&&p()===!0&&(e.autoSave===!0&&e.validate(l.value)===!0?(n("save",l.value,a.value),n("update:modelValue",l.value)):n("cancel",l.value,a.value)),n("beforeHide")}function q(){n("hide")}function C(){const u=o.default!==void 0?[].concat(o.default(m.value)):[];return e.title&&u.unshift(s("div",{class:"q-dialog__title q-mt-sm q-mb-sm"},e.title)),e.buttons===!0&&u.push(s("div",{class:"q-popup-edit__buttons row justify-center no-wrap"},[s(y,{flat:!0,color:e.color,label:e.labelCancel||c.lang.label.cancel,onClick:v}),s(y,{flat:!0,color:e.color,label:e.labelSet||c.lang.label.set,onClick:d})])),u}return Object.assign(t,{set:d,cancel:v,show(u){var r;(r=i.value)==null||r.show(u)},hide(u){var r;(r=i.value)==null||r.hide(u)},updatePosition:g}),()=>{if(e.disable!==!0)return s(Q,{ref:i,class:"q-popup-edit",cover:e.cover,onBeforeShow:h,onShow:V,onBeforeHide:j,onHide:q,onEscapeKey:v},C)}}});export{D as Q};
//# sourceMappingURL=QPopupEdit-CrwLLqc3.js.map
