"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),h=require("@aplus-frontend/antdv"),k=require("vuedraggable"),E=require("../../../context.js");require("../../../../config-provider/index.js");require("../sortable/index.vue.js");const z=require("./context.js"),D=require("../../../../config-provider/hooks/use-namespace.js"),M=require("../../../../config-provider/hooks/use-locale.js"),C=require("../sortable/index.vue2.js"),R={key:0},I={key:1},F={key:2},j=e.defineComponent({__name:"index",props:{value:{},onReset:{type:Function}},emits:["update:value"],setup(y,{emit:x}){const l=e.ref([]),r=e.ref([]),u=e.ref([]),{b:i}=D.useNamespace("ap-column-setting-sorter"),{t:f}=M.useLocale(),d=y,_=x,{columnsBackup:N}=E.useInjectApTable();z.useProvideSorterMethods({fixedToLeft:B,fixedToRight:w,unFixed:T});function V(t,n){const o=n[0].findIndex(a=>a.key===t.key);if(~o)n[0].splice(o,1);else{const a=n[1].findIndex(c=>c.key===t.key);n[1].splice(a,1)}}function m(t,n){const o=[...e.unref(l.value)],a=[...e.unref(u.value)],c=[...e.unref(r.value)],g={left:{target:o,search:[c,a]},right:{target:a,search:[c,o]},normal:{target:c,search:[o,a]}}[n];return n==="right"?g.target.unshift(t):g.target.push(t),V(t,g.search),[...o,...c,...a]}function B(t){const n=m(t,"left");s(n)}function w(t){const n=m(t,"right");s(n)}function T(t){const n=m(t,"normal");s(n)}function p(t){return N?.value.find(n=>t.key===n.key)?t.children?.length?t.children.some(n=>n.show):t.show:!1}function v(t,n){t.value?t.value.push(n):t.value=[n]}const L=e.computed(()=>{let t=0;function n(o){for(const a of o)a.children?.length?n(a.children):a.show&&(t+=1)}return n(d.value),t});function b(t){s([...t,...e.unref(r),...e.unref(u)])}function S(t){s([...e.unref(l),...t,...e.unref(u)])}function q(t){s([...e.unref(l),...e.unref(r),...t])}function s(t){_("update:value",t)}return e.watch(()=>d.value,t=>{if(t){l.value=[],r.value=[],u.value=[];for(const n of t)n.fixed==="left"?v(l,n):n.fixed==="right"?v(u,n):v(r,n)}},{immediate:!0}),(t,n)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(e.unref(i)())},[e.createVNode(e.unref(h.Flex),{class:e.normalizeClass(e.unref(i)("header")),align:"center",justify:"space-between"},{default:e.withCtx(()=>[e.createElementVNode("span",{class:e.normalizeClass(e.unref(i)("header-title")),style:{flex:"1"}},e.toDisplayString(e.unref(f)("ap.apTable.setting.selectCount",{count:L.value})),3),e.createVNode(e.unref(h.Typography).Link,{onClick:d.onReset},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(e.unref(f)("ap.apTable.setting.reset")),1)]),_:1},8,["onClick"])]),_:1},8,["class"]),e.createVNode(e.unref(h.Divider),{style:{margin:"0px"}}),e.createElementVNode("div",{class:e.normalizeClass(e.unref(i)("content"))},[l.value.length?(e.openBlock(),e.createElementBlock("div",R,[e.createElementVNode("span",{class:e.normalizeClass(e.unref(i)("section-title"))},e.toDisplayString(e.unref(f)("ap.apTable.setting.fixToLeft")),3),e.createVNode(e.unref(k),{"model-value":l.value,"item-key":"key","onUpdate:modelValue":b},{item:e.withCtx(({element:o})=>[p(o)?(e.openBlock(),e.createBlock(C.default,{key:0,value:o},null,8,["value"])):e.createCommentVNode("",!0)]),_:1},8,["model-value"])])):e.createCommentVNode("",!0),r.value.length?(e.openBlock(),e.createElementBlock("div",I,[e.createElementVNode("span",{class:e.normalizeClass(e.unref(i)("section-title"))},e.toDisplayString(e.unref(f)("ap.apTable.setting.unFixed")),3),e.createVNode(e.unref(k),{"model-value":r.value,"item-key":"key","onUpdate:modelValue":S},{item:e.withCtx(({element:o})=>[p(o)?(e.openBlock(),e.createBlock(C.default,{key:0,value:o},null,8,["value"])):e.createCommentVNode("",!0)]),_:1},8,["model-value"])])):e.createCommentVNode("",!0),u.value.length?(e.openBlock(),e.createElementBlock("div",F,[e.createElementVNode("span",{class:e.normalizeClass(e.unref(i)("section-title"))},e.toDisplayString(e.unref(f)("ap.apTable.setting.fixToRight")),3),e.createVNode(e.unref(k),{"model-value":u.value,"item-key":"key","onUpdate:modelValue":q},{item:e.withCtx(({element:o})=>[p(o)?(e.openBlock(),e.createBlock(C.default,{key:0,value:o},null,8,["value"])):e.createCommentVNode("",!0)]),_:1},8,["model-value"])])):e.createCommentVNode("",!0)],2)],2))}});exports.default=j;
