"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),a=require("@aplus-frontend/antdv"),V=require("@aplus-frontend/icon"),_=require("vuedraggable");require("../../../../config-provider/index.js");const b=require("../../../style/search-form-sorter.js");require("./sortable-item.vue.js");const d=require("../../../../config-provider/hooks/use-namespace.js"),x=require("../../../../config-provider/hooks/use-locale.js"),w=require("./sortable-item.vue2.js"),k=e.defineComponent({name:"ApFormSearchFormPopoverSorter",__name:"index",props:{items:{},onClickConfirm:{type:Function},sorted:{type:Boolean}},setup(v,{expose:C}){const o=v,n=e.ref(o.items);let p=[...o.items],f=[...o.items];e.watch(()=>o.items,r=>{n.value=r,p=r,o.sorted||(f=r)});const h=b.default("search-form-sorter"),{e:c,b:m}=d.useNamespace("ap-form-search-form"),{b:t}=d.useNamespace("search-form-sorter"),{t:s}=x.useLocale(),l=e.ref(!1);function g(r){return r.closest(".ant-form")||document.body}function N(){l.value=!1,p=[...e.unref(n)],o.onClickConfirm(e.unref(n))}function y(){n.value=[...f]}return e.watch(()=>l.value,r=>{r&&(n.value=[...p])}),C({getCachedList:()=>f}),(r,i)=>(e.openBlock(),e.createBlock(e.unref(a.Popover),{open:l.value,"onUpdate:open":i[1]||(i[1]=u=>l.value=u),"overlay-class-name":`${e.unref(t)()} ${e.unref(c)("popover")} ${e.unref(h)}`,trigger:"click",placement:"bottom",mask:"","mask-style":{backgroundColor:"transparent"},"get-popup-container":g},{content:e.withCtx(()=>[e.createElementVNode("div",{class:e.normalizeClass(e.unref(t)("header"))},[e.createElementVNode("span",{class:e.normalizeClass(e.unref(t)("header-title"))},e.toDisplayString(e.unref(s)("ap.apForm.search.sorterTitle")),3),e.createVNode(e.unref(a.Flex),{justify:"space-between",align:"center"},{default:e.withCtx(()=>[e.createElementVNode("span",{class:e.normalizeClass(e.unref(t)("header-desc"))},e.toDisplayString(e.unref(s)("ap.apForm.search.sorterDesc")),3),e.createElementVNode("div",{class:e.normalizeClass(e.unref(t)("header-action-wrapper")),onClick:y},[e.createElementVNode("span",{class:e.normalizeClass(e.unref(t)("header-reset-btn"))},e.toDisplayString(e.unref(s)("ap.apForm.search.sorterReset")),3)],2)]),_:1})],2),e.createElementVNode("div",{class:e.normalizeClass([e.unref(c)("popover-content"),e.unref(t)("content")])},[e.createVNode(e.unref(_),{list:n.value,class:e.normalizeClass(e.unref(t)("sorter-wrapper")),"item-key":"name"},{item:e.withCtx(({element:u})=>[e.createVNode(w.default,{item:u},null,8,["item"])]),_:1},8,["list","class"])],2),e.createVNode(e.unref(a.Divider),{style:{margin:"0"}}),e.createElementVNode("div",{class:e.normalizeClass(e.unref(c)("popover-footer"))},[e.createVNode(e.unref(a.Flex),{justify:"end",gap:8},{default:e.withCtx(()=>[e.createVNode(e.unref(a.Button),{onClick:i[0]||(i[0]=u=>l.value=!1)},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(e.unref(s)("ap.common.cancelText")),1)]),_:1}),e.createVNode(e.unref(a.Button),{class:e.normalizeClass(e.unref(c)("popover-footer-confirm-btn")),type:"primary",onClick:N},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(e.unref(s)("ap.apForm.search.sorterConfirmBtn")),1)]),_:1},8,["class"])]),_:1})],2)]),default:e.withCtx(()=>[e.createVNode(e.unref(a.Tooltip),{title:e.unref(s)("ap.apForm.search.sorterTitle"),placement:"top"},{default:e.withCtx(()=>[e.createVNode(e.unref(a.Button),{class:e.normalizeClass([e.unref(m)("trigger-btn"),{[e.unref(m)("trigger-btn-active")]:l.value}])},{icon:e.withCtx(()=>[e.createVNode(e.unref(V.IconApLayoutOutlined),{size:14})]),_:1},8,["class"])]),_:1},8,["title"])]),_:1},8,["open","overlay-class-name"]))}});exports.default=k;
