var ln=Object.defineProperty;var sn=(i,e,t)=>e in i?ln(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var F=(i,e,t)=>(sn(i,typeof e!="symbol"?e+"":e,t),t);import{b as dn,i as We,P as st,a2 as un,a5 as fn,_ as Yt,v as cn,a6 as hn,Y as dt}from"./index-EwE51S_X.js";import{d as Tt,r as $e,j as V,aE as pn,a2 as gn,az as Xt,a as Ve,K as te,aq as jt,e as y,f as A,y as G,C,u as I,F as ee,B as Ue,L as j,t as ce,m as ut,i as It,n as mn,z as vn,am as Ke,ar as Se,x as bn,s as Ie,aA as yn,D as wn,aC as Nt,Z as En,a1 as Sn,w as _n}from"./vue-A59npLRR.js";const Dn=Tt({name:"Column",props:{attr:{type:Object,required:!0}},setup(i,{slots:e}){const t=$e(i.attr);return t["column-key"]=t["column-key"]?t["column-key"]:t.prop||dn(),()=>V(pn,t,e.default)}}),Tn=(i,e)=>{e.target=="_blank"?window.open(i):window.location.href=i},wi=(i=["weigh-sort","edit","delete"])=>{const e=new Map([["weigh-sort",{render:"moveButton",name:"weigh-sort",title:"Drag sort",text:"",type:"info",icon:"fa fa-arrows",class:"table-row-weigh-sort",disabledTip:!1}],["edit",{render:"tipButton",name:"edit",title:"Edit",text:"",type:"primary",icon:"fa fa-pencil",class:"table-row-edit",disabledTip:!1}],["delete",{render:"confirmButton",name:"delete",title:"Delete",text:"",type:"danger",icon:"fa fa-trash",class:"table-row-delete",popconfirm:{confirmButtonText:We.global.t("Delete"),cancelButtonText:We.global.t("Cancel"),confirmButtonType:"danger",title:We.global.t("Are you sure to delete the selected record?")},disabledTip:!1}]]),t=[];for(const n in i)e.has(i[n])&&t.push(e.get(i[n]));return t},wt=(i,e,t=-1)=>{for(const n in i){if(typeof t=="number"&&t++,t==e)return i[n];if(i[n].children&&(t=wt(i[n].children,e,t),typeof t!="number"))return t}return t},Cn={key:2,class:"ba-render-image"},An={key:3,class:"ba-render-image"},kn={key:4},On={key:5},In={key:6},Nn={key:7},Fn={key:8},Pn=["innerHTML"],Rn={key:11},Bn={key:0,class:"table-operate-text"},Mn={key:0,class:"table-operate-text"},xn={class:"ml-6"},zn={key:0,class:"table-operate-text"},Ln={key:0,class:"table-operate-text"},Hn=Tt({__name:"index",props:{row:{},field:{},column:{},index:{}},setup(i){const{t:e}=gn(),t=Xt("baTable"),n=i,o=Ve(n.field.prop),r=Ve(o.value?n.row[o.value]:"");if(o.value&&o.value.indexOf(".")>-1){let a=o.value.split("."),h=Ve(n.row[a[0]]);for(let c=1;c{t.onTableAction("field-change",{value:a,...n})},s=a=>{if(typeof a.click=="function"){a.click(n.row,n.field);return}t.onTableAction(a.name,n)},u=(a,h)=>h&&h[a]?h[a]:"";return(a,h)=>{const c=te("Icon"),b=te("el-switch"),_=te("el-image"),w=te("el-tag"),E=te("el-button"),z=te("el-input"),q=te("el-tooltip"),M=te("el-popconfirm"),p=jt("blur");return y(),A(ee,null,[a.field.render=="icon"?(y(),G(c,{key:0,class:"ba-icon-dark",name:r.value?r.value:a.field.default??""},null,8,["name"])):C("",!0),a.field.render=="switch"?(y(),G(b,{key:1,onChange:l,"model-value":r.value.toString(),loading:a.row.loading,"active-value":"1","inactive-value":"0"},null,8,["model-value","loading"])):C("",!0),a.field.render=="image"&&r.value?(y(),A("div",Cn,[V(_,{"hide-on-click-modal":!0,"preview-teleported":!0,"preview-src-list":[I(st)(r.value)],src:I(st)(r.value)},null,8,["preview-src-list","src"])])):C("",!0),a.field.render=="images"?(y(),A("div",An,[Array.isArray(r.value)&&r.value.length?(y(!0),A(ee,{key:0},Ue(r.value,(d,S)=>(y(),G(_,{key:S,"initial-index":S,"preview-teleported":!0,"preview-src-list":I(un)(r.value),class:"images-item",src:I(st)(d),"hide-on-click-modal":!0},null,8,["initial-index","preview-src-list","src"]))),128)):C("",!0)])):C("",!0),a.field.render=="tag"&&r.value!==""?(y(),A("div",kn,[V(w,{type:u(r.value,a.field.custom),effect:a.field.effect??"light",size:a.field.size??"default"},{default:j(()=>[ut(ce(a.field.replaceValue?a.field.replaceValue[r.value]:r.value),1)]),_:1},8,["type","effect","size"])])):C("",!0),a.field.render=="tags"?(y(),A("div",On,[Array.isArray(r.value)?(y(!0),A(ee,{key:0},Ue(r.value,(d,S)=>(y(),A(ee,{key:S},[d?(y(),G(w,{key:0,class:"m-10",type:u(d,a.field.custom),effect:a.field.effect??"light",size:a.field.size??"default"},{default:j(()=>[ut(ce(a.field.replaceValue?a.field.replaceValue[d]??d:d),1)]),_:2},1032,["type","effect","size"])):C("",!0)],64))),128)):(y(),A(ee,{key:1},[r.value!==""?(y(),G(w,{key:0,class:"m-10",type:u(r.value,a.field.custom),effect:a.field.effect??"light",size:a.field.size??"default"},{default:j(()=>[ut(ce(a.field.replaceValue?a.field.replaceValue[r.value]??r.value:r.value),1)]),_:1},8,["type","effect","size"])):C("",!0)],64))])):C("",!0),a.field.render=="url"&&r.value?(y(),A("div",In,[V(z,{"model-value":r.value,placeholder:I(e)("Link address")},{append:j(()=>[V(E,{onClick:h[0]||(h[0]=d=>typeof a.field.click=="function"?a.field.click(a.row,a.field,r.value,a.column,a.index):I(Tn)(r.value,a.field))},{default:j(()=>[V(c,{color:"#606266",name:"el-icon-Position"})]),_:1})]),_:1},8,["model-value","placeholder"])])):C("",!0),a.field.render=="datetime"?(y(),A("div",Nn,ce(r.value?I(fn)(r.value,a.field.timeFormat??void 0):"-"),1)):C("",!0),a.field.render=="color"?(y(),A("div",Fn,[It("div",{style:mn({background:r.value}),class:"ba-render-color"},null,4)])):C("",!0),a.field.render=="customTemplate"?(y(),A("div",{key:9,innerHTML:a.field.customTemplate?a.field.customTemplate(a.row,a.field,r.value,a.column,a.index):""},null,8,Pn)):C("",!0),a.field.render=="customRender"?(y(),G(vn(a.field.customRender),{key:10,renderRow:a.row,renderField:a.field,renderValue:r.value,renderColumn:a.column,renderIndex:a.index},null,8,["renderRow","renderField","renderValue","renderColumn","renderIndex"])):C("",!0),a.field.render=="buttons"&&a.field.buttons?(y(),A("div",Rn,[(y(!0),A(ee,null,Ue(a.field.buttons,(d,S)=>(y(),A(ee,{key:S},[!d.display||d.display(a.row,a.field)?(y(),A(ee,{key:0},[d.render=="basicButton"?Ke((y(),G(E,Se({key:0,onClick:B=>s(d),class:[d.class,"table-operate"],type:d.type,disabled:d.disabled&&d.disabled(a.row,a.field)},d.attr),{default:j(()=>[V(c,{name:d.icon},null,8,["name"]),d.text?(y(),A("div",Bn,ce(d.text),1)):C("",!0)]),_:2},1040,["onClick","class","type","disabled"])),[[p]]):C("",!0),d.render=="tipButton"&&(d.name=="edit"&&I(t).auth("edit")||d.name!="edit")?(y(),G(q,{key:1,disabled:!(d.title&&!d.disabledTip),content:d.title?I(e)(d.title):"",placement:"top"},{default:j(()=>[Ke((y(),G(E,Se({onClick:B=>s(d),class:[d.class,"table-operate"],type:d.type,disabled:d.disabled&&d.disabled(a.row,a.field)},d.attr),{default:j(()=>[V(c,{name:d.icon},null,8,["name"]),d.text?(y(),A("div",Mn,ce(d.text),1)):C("",!0)]),_:2},1040,["onClick","class","type","disabled"])),[[p]])]),_:2},1032,["disabled","content"])):C("",!0),d.render=="confirmButton"&&(d.name=="delete"&&I(t).auth("del")||d.name!="delete")?(y(),G(M,Se({key:2,disabled:d.disabled&&d.disabled(a.row,a.field)},d.popconfirm,{onConfirm:B=>s(d)}),{reference:j(()=>[It("div",xn,[V(q,{disabled:!d.title,content:d.title?I(e)(d.title):"",placement:"top"},{default:j(()=>[Ke((y(),G(E,Se({class:[d.class,"table-operate"],type:d.type,disabled:d.disabled&&d.disabled(a.row,a.field)},d.attr),{default:j(()=>[V(c,{name:d.icon},null,8,["name"]),d.text?(y(),A("div",zn,ce(d.text),1)):C("",!0)]),_:2},1040,["class","type","disabled"])),[[p]])]),_:2},1032,["disabled","content"])])]),_:2},1040,["disabled","onConfirm"])):C("",!0),d.render=="moveButton"&&(d.name=="weigh-sort"&&I(t).auth("sortable")||d.name!="weigh-sort")?(y(),G(q,{key:3,disabled:!(d.title&&!d.disabledTip),content:d.title?I(e)(d.title):"",placement:"top"},{default:j(()=>[V(E,Se({class:[d.class,"table-operate move-button"],type:d.type,disabled:d.disabled&&d.disabled(a.row,a.field)},d.attr),{default:j(()=>[V(c,{name:d.icon},null,8,["name"]),d.text?(y(),A("div",Ln,ce(d.text),1)):C("",!0)]),_:2},1040,["class","type","disabled"])]),_:2},1032,["disabled","content"])):C("",!0)],64)):C("",!0)],64))),128))])):C("",!0)],64)}}}),Yn=Yt(Hn,[["__scopeId","data-v-496267b7"]]),Xn={key:0,class:"table-pagination"},jn=Tt({__name:"index",props:{pagination:{type:Boolean,default:!0}},setup(i,{expose:e}){const t=cn(),n=Ve(),o=Xt("baTable"),r=i,l=p=>{o.onTableAction("page-size-change",{size:p})},s=p=>{o.onTableAction("current-page-change",{page:p})},u=({order:p,prop:d})=>{o.onTableAction("sort-change",{prop:d,order:p?p=="ascending"?"asc":"desc":""})},a=bn(()=>{let p=[10,20,50,100];return o.table.filter.limit&&(p.includes(o.table.filter.limit)||p.push(o.table.filter.limit)),p}),h=p=>{var d;c(p.map(S=>S[o.table.pk].toString()))?p.map(S=>{S.children&&b(S.children,!0)}):(d=n.value)==null||d.clearSelection()},c=p=>{let d=o.table.data;for(const S in d)return p.includes(d[S][o.table.pk].toString());return!1},b=(p,d)=>{p.map(S=>{_(S,d),S.children&&b(S.children,d)})},_=(p,d)=>{p&&wn(()=>{var S;(S=n.value)==null||S.toggleRowSelection(p,d)})},w=(p,d)=>{p.some(S=>d[o.table.pk]===S[o.table.pk])?d.children&&b(d.children,!0):d.children&&b(d.children,!1)},E=p=>{o.onTableAction("selection-change",p)},z=(p,d)=>{var S;for(const B in p)(S=n.value)==null||S.toggleRowExpansion(p[B],d),p[B].children&&z(p[B].children,d)};return e({unFoldAll:p=>{z(o.table.data,p)},getRef:()=>n.value}),(p,d)=>{const S=te("el-table"),B=te("el-pagination"),re=jt("loading");return y(),A("div",null,[Ie(p.$slots,"neck",{},void 0,!0),Ke((y(),G(S,Se({ref_key:"tableRef",ref:n,class:"ba-data-table w100","header-cell-class-name":"table-header-cell","default-expand-all":I(o).table.expandAll,data:I(o).table.data,"row-key":I(o).table.pk,border:!0,stripe:"",onSelectAll:h,onSelect:w,onSelectionChange:E,onSortChange:u,onRowDblclick:I(o).onTableDblclick},p.$attrs),{default:j(()=>[Ie(p.$slots,"columnPrepend",{},void 0,!0),(y(!0),A(ee,null,Ue(I(o).table.column,(L,H)=>(y(),A(ee,null,[L.show!==!1?(y(),A(ee,{key:0},[L.render=="slot"?Ie(p.$slots,L.slotName,{key:0},void 0,!0):(y(),G(Dn,{attr:L,key:H+"-column"},yn({_:2},[L.render?{name:"default",fn:j(Z=>[(y(),G(Yn,{field:L,row:Z.row,column:Z.column,index:Z.$index,key:H+"-"+Z.$index+"-"+L.render+"-"+(L.prop?"-"+L.prop+"-"+Z.row[L.prop]:"")},null,8,["field","row","column","index"]))]),key:"0"}:void 0]),1032,["attr"]))],64)):C("",!0)],64))),256)),Ie(p.$slots,"columnAppend",{},void 0,!0)]),_:3},16,["default-expand-all","data","row-key","onRowDblclick"])),[[re,I(o).table.loading]]),r.pagination?(y(),A("div",Xn,[V(B,{currentPage:I(o).table.filter.page,"page-size":I(o).table.filter.limit,"page-sizes":a.value,background:"",layout:I(t).layout.shrink?"prev, next, jumper":"sizes,total, ->, prev, pager, next, jumper",total:I(o).table.total,onSizeChange:l,onCurrentChange:s},null,8,["currentPage","page-size","page-sizes","layout","total"])])):C("",!0),Ie(p.$slots,"footer",{},void 0,!0)])}}}),Ei=Yt(jn,[["__scopeId","data-v-7f8222db"]]);/**! * Sortable 1.15.1 * @author RubaXa * @author owenm * @license MIT */function Ft(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(i);e&&(n=n.filter(function(o){return Object.getOwnPropertyDescriptor(i,o).enumerable})),t.push.apply(t,n)}return t}function oe(i){for(var e=1;e=0)&&(t[o]=i[o]);return t}function Wn(i,e){if(i==null)return{};var t=qn(i,e),n,o;if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(i);for(o=0;o=0)&&Object.prototype.propertyIsEnumerable.call(i,n)&&(t[n]=i[n])}return t}var $n="1.15.1";function le(i){if(typeof window<"u"&&window.navigator)return!!navigator.userAgent.match(i)}var de=le(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i),Le=le(/Edge/i),Pt=le(/firefox/i),Re=le(/safari/i)&&!le(/chrome/i)&&!le(/android/i),Gt=le(/iP(ad|od|hone)/i),qt=le(/chrome/i)&&le(/android/i),Wt={capture:!1,passive:!1};function T(i,e,t){i.addEventListener(e,t,!de&&Wt)}function D(i,e,t){i.removeEventListener(e,t,!de&&Wt)}function nt(i,e){if(e){if(e[0]===">"&&(e=e.substring(1)),i)try{if(i.matches)return i.matches(e);if(i.msMatchesSelector)return i.msMatchesSelector(e);if(i.webkitMatchesSelector)return i.webkitMatchesSelector(e)}catch{return!1}return!1}}function Vn(i){return i.host&&i!==document&&i.host.nodeType?i.host:i.parentNode}function ne(i,e,t,n){if(i){t=t||document;do{if(e!=null&&(e[0]===">"?i.parentNode===t&&nt(i,e):nt(i,e))||n&&i===t)return i;if(i===t)break}while(i=Vn(i))}return null}var Rt=/\s+/g;function $(i,e,t){if(i&&e)if(i.classList)i.classList[t?"add":"remove"](e);else{var n=(" "+i.className+" ").replace(Rt," ").replace(" "+e+" "," ");i.className=(n+(t?" "+e:"")).replace(Rt," ")}}function g(i,e,t){var n=i&&i.style;if(n){if(t===void 0)return document.defaultView&&document.defaultView.getComputedStyle?t=document.defaultView.getComputedStyle(i,""):i.currentStyle&&(t=i.currentStyle),e===void 0?t:t[e];!(e in n)&&e.indexOf("webkit")===-1&&(e="-webkit-"+e),n[e]=t+(typeof t=="string"?"":"px")}}function Te(i,e){var t="";if(typeof i=="string")t=i;else do{var n=g(i,"transform");n&&n!=="none"&&(t=n+" "+t)}while(!e&&(i=i.parentNode));var o=window.DOMMatrix||window.WebKitCSSMatrix||window.CSSMatrix||window.MSCSSMatrix;return o&&new o(t)}function $t(i,e,t){if(i){var n=i.getElementsByTagName(e),o=0,r=n.length;if(t)for(;o=r:l=o<=r,!l)return n;if(n===ie())break;n=ge(n,!1)}return!1}function Ce(i,e,t,n){for(var o=0,r=0,l=i.children;r2&&arguments[2]!==void 0?arguments[2]:{},o=n.evt,r=Wn(n,ni);He.pluginEvent.bind(m)(e,t,oe({dragEl:f,parentEl:N,ghostEl:v,rootEl:k,nextEl:ye,lastDownEl:Ze,cloneEl:O,cloneHidden:pe,dragStarted:Ne,putSortable:x,activeSortable:m.active,originalEvent:o,oldIndex:De,oldDraggableIndex:Me,newIndex:U,newDraggableIndex:he,hideGhostForTarget:tn,unhideGhostForTarget:nn,cloneNowHidden:function(){pe=!0},cloneNowShown:function(){pe=!1},dispatchSortableEvent:function(s){X({sortable:t,name:s,originalEvent:o})}},r))};function X(i){ti(oe({putSortable:x,cloneEl:O,targetEl:f,rootEl:k,oldIndex:De,oldDraggableIndex:Me,newIndex:U,newDraggableIndex:he},i))}var f,N,v,k,ye,Ze,O,pe,De,U,Me,he,Xe,x,_e=!1,it=!1,ot=[],ve,J,ht,pt,xt,zt,Ne,Ee,xe,ze=!1,je=!1,Je,Y,gt=[],Et=!1,rt=[],lt=typeof document<"u",Ge=Gt,Lt=Le||de?"cssFloat":"float",ii=lt&&!qt&&!Gt&&"draggable"in document.createElement("div"),Zt=function(){if(lt){if(de)return!1;var i=document.createElement("x");return i.style.cssText="pointer-events:auto",i.style.pointerEvents==="auto"}}(),Jt=function(e,t){var n=g(e),o=parseInt(n.width)-parseInt(n.paddingLeft)-parseInt(n.paddingRight)-parseInt(n.borderLeftWidth)-parseInt(n.borderRightWidth),r=Ce(e,0,t),l=Ce(e,1,t),s=r&&g(r),u=l&&g(l),a=s&&parseInt(s.marginLeft)+parseInt(s.marginRight)+R(r).width,h=u&&parseInt(u.marginLeft)+parseInt(u.marginRight)+R(l).width;if(n.display==="flex")return n.flexDirection==="column"||n.flexDirection==="column-reverse"?"vertical":"horizontal";if(n.display==="grid")return n.gridTemplateColumns.split(" ").length<=1?"vertical":"horizontal";if(r&&s.float&&s.float!=="none"){var c=s.float==="left"?"left":"right";return l&&(u.clear==="both"||u.clear===c)?"vertical":"horizontal"}return r&&(s.display==="block"||s.display==="flex"||s.display==="table"||s.display==="grid"||a>=o&&n[Lt]==="none"||l&&n[Lt]==="none"&&a+h>o)?"vertical":"horizontal"},oi=function(e,t,n){var o=n?e.left:e.top,r=n?e.right:e.bottom,l=n?e.width:e.height,s=n?t.left:t.top,u=n?t.right:t.bottom,a=n?t.width:t.height;return o===s||r===u||o+l/2===s+a/2},ri=function(e,t){var n;return ot.some(function(o){var r=o[K].options.emptyInsertThreshold;if(!(!r||Ct(o))){var l=R(o),s=e>=l.left-r&&e<=l.right+r,u=t>=l.top-r&&t<=l.bottom+r;if(s&&u)return n=o}}),n},en=function(e){function t(r,l){return function(s,u,a,h){var c=s.options.group.name&&u.options.group.name&&s.options.group.name===u.options.group.name;if(r==null&&(l||c))return!0;if(r==null||r===!1)return!1;if(l&&r==="clone")return r;if(typeof r=="function")return t(r(s,u,a,h),l)(s,u,a,h);var b=(l?s:u).options.group.name;return r===!0||typeof r=="string"&&r===b||r.join&&r.indexOf(b)>-1}}var n={},o=e.group;(!o||Qe(o)!="object")&&(o={name:o}),n.name=o.name,n.checkPull=t(o.pull,!0),n.checkPut=t(o.put),n.revertClone=o.revertClone,e.group=n},tn=function(){!Zt&&v&&g(v,"display","none")},nn=function(){!Zt&&v&&g(v,"display","")};lt&&!qt&&document.addEventListener("click",function(i){if(it)return i.preventDefault(),i.stopPropagation&&i.stopPropagation(),i.stopImmediatePropagation&&i.stopImmediatePropagation(),it=!1,!1},!0);var be=function(e){if(f){e=e.touches?e.touches[0]:e;var t=ri(e.clientX,e.clientY);if(t){var n={};for(var o in e)e.hasOwnProperty(o)&&(n[o]=e[o]);n.target=n.rootEl=t,n.preventDefault=void 0,n.stopPropagation=void 0,t[K]._onDragOver(n)}}},ai=function(e){f&&f.parentNode[K]._isOutsideThisEl(e.target)};function m(i,e){if(!(i&&i.nodeType&&i.nodeType===1))throw"Sortable: `el` must be an HTMLElement, not ".concat({}.toString.call(i));this.el=i,this.options=e=se({},e),i[K]=this;var t={group:null,sort:!0,disabled:!1,store:null,handle:null,draggable:/^[uo]l$/i.test(i.nodeName)?">li":">*",swapThreshold:1,invertSwap:!1,invertedSwapThreshold:null,removeCloneOnHide:!0,direction:function(){return Jt(i,this.options)},ghostClass:"sortable-ghost",chosenClass:"sortable-chosen",dragClass:"sortable-drag",ignore:"a, img",filter:null,preventOnFilter:!0,animation:0,easing:null,setData:function(l,s){l.setData("Text",s.textContent)},dropBubble:!1,dragoverBubble:!1,dataIdAttr:"data-id",delay:0,delayOnTouchOnly:!1,touchStartThreshold:(Number.parseInt?Number:window).parseInt(window.devicePixelRatio,10)||1,forceFallback:!1,fallbackClass:"sortable-fallback",fallbackOnBody:!1,fallbackTolerance:0,fallbackOffset:{x:0,y:0},supportPointer:m.supportPointer!==!1&&"PointerEvent"in window&&!Re,emptyInsertThreshold:5};He.initializePlugins(this,i,t);for(var n in t)!(n in e)&&(e[n]=t[n]);en(e);for(var o in this)o.charAt(0)==="_"&&typeof this[o]=="function"&&(this[o]=this[o].bind(this));this.nativeDraggable=e.forceFallback?!1:ii,this.nativeDraggable&&(this.options.touchStartThreshold=1),e.supportPointer?T(i,"pointerdown",this._onTapStart):(T(i,"mousedown",this._onTapStart),T(i,"touchstart",this._onTapStart)),this.nativeDraggable&&(T(i,"dragover",this),T(i,"dragenter",this)),ot.push(this.el),e.store&&e.store.get&&this.sort(e.store.get(this)||[]),se(this,Zn())}m.prototype={constructor:m,_isOutsideThisEl:function(e){!this.el.contains(e)&&e!==this.el&&(Ee=null)},_getDirection:function(e,t){return typeof this.options.direction=="function"?this.options.direction.call(this,e,t,f):this.options.direction},_onTapStart:function(e){if(e.cancelable){var t=this,n=this.el,o=this.options,r=o.preventOnFilter,l=e.type,s=e.touches&&e.touches[0]||e.pointerType&&e.pointerType==="touch"&&e,u=(s||e).target,a=e.target.shadowRoot&&(e.path&&e.path[0]||e.composedPath&&e.composedPath()[0])||u,h=o.filter;if(pi(n),!f&&!(/mousedown|pointerdown/.test(l)&&e.button!==0||o.disabled)&&!a.isContentEditable&&!(!this.nativeDraggable&&Re&&u&&u.tagName.toUpperCase()==="SELECT")&&(u=ne(u,o.draggable,n,!1),!(u&&u.animated)&&Ze!==u)){if(De=Q(u),Me=Q(u,o.draggable),typeof h=="function"){if(h.call(this,e,u,this)){X({sortable:t,rootEl:a,name:"filter",targetEl:u,toEl:n,fromEl:n}),W("filter",t,{evt:e}),r&&e.cancelable&&e.preventDefault();return}}else if(h&&(h=h.split(",").some(function(c){if(c=ne(a,c.trim(),n,!1),c)return X({sortable:t,rootEl:c,name:"filter",targetEl:u,fromEl:n,toEl:n}),W("filter",t,{evt:e}),!0}),h)){r&&e.cancelable&&e.preventDefault();return}o.handle&&!ne(a,o.handle,n,!1)||this._prepareDragStart(e,s,u)}}},_prepareDragStart:function(e,t,n){var o=this,r=o.el,l=o.options,s=r.ownerDocument,u;if(n&&!f&&n.parentNode===r){var a=R(n);if(k=r,f=n,N=f.parentNode,ye=f.nextSibling,Ze=n,Xe=l.group,m.dragged=f,ve={target:f,clientX:(t||e).clientX,clientY:(t||e).clientY},xt=ve.clientX-a.left,zt=ve.clientY-a.top,this._lastX=(t||e).clientX,this._lastY=(t||e).clientY,f.style["will-change"]="all",u=function(){if(W("delayEnded",o,{evt:e}),m.eventCanceled){o._onDrop();return}o._disableDelayedDragEvents(),!Pt&&o.nativeDraggable&&(f.draggable=!0),o._triggerDragStart(e,t),X({sortable:o,name:"choose",originalEvent:e}),$(f,l.chosenClass,!0)},l.ignore.split(",").forEach(function(h){$t(f,h.trim(),mt)}),T(s,"dragover",be),T(s,"mousemove",be),T(s,"touchmove",be),T(s,"mouseup",o._onDrop),T(s,"touchend",o._onDrop),T(s,"touchcancel",o._onDrop),Pt&&this.nativeDraggable&&(this.options.touchStartThreshold=4,f.draggable=!0),W("delayStart",this,{evt:e}),l.delay&&(!l.delayOnTouchOnly||t)&&(!this.nativeDraggable||!(Le||de))){if(m.eventCanceled){this._onDrop();return}T(s,"mouseup",o._disableDelayedDrag),T(s,"touchend",o._disableDelayedDrag),T(s,"touchcancel",o._disableDelayedDrag),T(s,"mousemove",o._delayedDragTouchMoveHandler),T(s,"touchmove",o._delayedDragTouchMoveHandler),l.supportPointer&&T(s,"pointermove",o._delayedDragTouchMoveHandler),o._dragStartTimer=setTimeout(u,l.delay)}else u()}},_delayedDragTouchMoveHandler:function(e){var t=e.touches?e.touches[0]:e;Math.max(Math.abs(t.clientX-this._lastX),Math.abs(t.clientY-this._lastY))>=Math.floor(this.options.touchStartThreshold/(this.nativeDraggable&&window.devicePixelRatio||1))&&this._disableDelayedDrag()},_disableDelayedDrag:function(){f&&mt(f),clearTimeout(this._dragStartTimer),this._disableDelayedDragEvents()},_disableDelayedDragEvents:function(){var e=this.el.ownerDocument;D(e,"mouseup",this._disableDelayedDrag),D(e,"touchend",this._disableDelayedDrag),D(e,"touchcancel",this._disableDelayedDrag),D(e,"mousemove",this._delayedDragTouchMoveHandler),D(e,"touchmove",this._delayedDragTouchMoveHandler),D(e,"pointermove",this._delayedDragTouchMoveHandler)},_triggerDragStart:function(e,t){t=t||e.pointerType=="touch"&&e,!this.nativeDraggable||t?this.options.supportPointer?T(document,"pointermove",this._onTouchMove):t?T(document,"touchmove",this._onTouchMove):T(document,"mousemove",this._onTouchMove):(T(f,"dragend",this),T(k,"dragstart",this._onDragStart));try{document.selection?et(function(){document.selection.empty()}):window.getSelection().removeAllRanges()}catch{}},_dragStarted:function(e,t){if(_e=!1,k&&f){W("dragStarted",this,{evt:t}),this.nativeDraggable&&T(document,"dragover",ai);var n=this.options;!e&&$(f,n.dragClass,!1),$(f,n.ghostClass,!0),m.active=this,e&&this._appendGhost(),X({sortable:this,name:"start",originalEvent:t})}else this._nulling()},_emulateDragOver:function(){if(J){this._lastX=J.clientX,this._lastY=J.clientY,tn();for(var e=document.elementFromPoint(J.clientX,J.clientY),t=e;e&&e.shadowRoot&&(e=e.shadowRoot.elementFromPoint(J.clientX,J.clientY),e!==t);)t=e;if(f.parentNode[K]._isOutsideThisEl(e),t)do{if(t[K]){var n=void 0;if(n=t[K]._onDragOver({clientX:J.clientX,clientY:J.clientY,target:e,rootEl:t}),n&&!this.options.dragoverBubble)break}e=t}while(t=t.parentNode);nn()}},_onTouchMove:function(e){if(ve){var t=this.options,n=t.fallbackTolerance,o=t.fallbackOffset,r=e.touches?e.touches[0]:e,l=v&&Te(v,!0),s=v&&l&&l.a,u=v&&l&&l.d,a=Ge&&Y&&Mt(Y),h=(r.clientX-ve.clientX+o.x)/(s||1)+(a?a[0]-gt[0]:0)/(s||1),c=(r.clientY-ve.clientY+o.y)/(u||1)+(a?a[1]-gt[1]:0)/(u||1);if(!m.active&&!_e){if(n&&Math.max(Math.abs(r.clientX-this._lastX),Math.abs(r.clientY-this._lastY))=0&&(X({rootEl:N,name:"add",toEl:N,fromEl:k,originalEvent:e}),X({sortable:this,name:"remove",toEl:N,originalEvent:e}),X({rootEl:N,name:"sort",toEl:N,fromEl:k,originalEvent:e}),X({sortable:this,name:"sort",toEl:N,originalEvent:e})),x&&x.save()):U!==De&&U>=0&&(X({sortable:this,name:"update",toEl:N,originalEvent:e}),X({sortable:this,name:"sort",toEl:N,originalEvent:e})),m.active&&((U==null||U===-1)&&(U=De,he=Me),X({sortable:this,name:"end",toEl:N,originalEvent:e}),this.save()))),this._nulling()},_nulling:function(){W("nulling",this),k=f=N=v=ye=O=Ze=pe=ve=J=Ne=U=he=De=Me=Ee=xe=x=Xe=m.dragged=m.ghost=m.clone=m.active=null,rt.forEach(function(e){e.checked=!0}),rt.length=ht=pt=0},handleEvent:function(e){switch(e.type){case"drop":case"dragend":this._onDrop(e);break;case"dragenter":case"dragover":f&&(this._onDragOver(e),li(e));break;case"selectstart":e.preventDefault();break}},toArray:function(){for(var e=[],t,n=this.el.children,o=0,r=n.length,l=this.options;oo.right+r||i.clientY>n.bottom&&i.clientX>n.left:i.clientY>o.bottom+r||i.clientX>n.right&&i.clientY>n.top}function fi(i,e,t,n,o,r,l,s){var u=n?i.clientY:i.clientX,a=n?t.height:t.width,h=n?t.top:t.left,c=n?t.bottom:t.right,b=!1;if(!l){if(s&&Jeh+a*r/2:uc-Je)return-xe}else if(u>h+a*(1-o)/2&&uc-a*r/2)?u>h+a/2?1:-1:0}function ci(i){return Q(f){if(this.runBefore("getIndex")!==!1)return this.table.loading=!0,this.api.index(this.table.filter).then(e=>{this.table.data=e.data.list,this.table.total=e.data.total,this.table.remark=e.data.remark,this.runAfter("getIndex",{res:e})}).finally(()=>{this.table.loading=!1})});F(this,"postDel",e=>{this.runBefore("postDel",{ids:e})!==!1&&this.api.del(e).then(t=>{this.onTableHeaderAction("refresh",{}),this.runAfter("postDel",{res:t})})});F(this,"requestEdit",e=>{if(this.runBefore("requestEdit",{id:e})!==!1)return this.form.loading=!0,this.form.items={},this.api.edit({[this.table.pk]:e}).then(t=>{this.form.items=t.data.row,this.runAfter("requestEdit",{res:t})}).catch(t=>{this.toggleForm(),this.runAfter("requestEdit",{err:t})}).finally(()=>{this.form.loading=!1})});F(this,"onTableDblclick",(e,t)=>{if(!this.table.dblClickNotEditColumn.includes("all")&&!this.table.dblClickNotEditColumn.includes(t.property)){if(this.runBefore("onTableDblclick",{row:e,column:t})===!1)return;this.toggleForm("Edit",[e[this.table.pk]]),this.runAfter("onTableDblclick",{row:e,column:t})}});F(this,"toggleForm",(e="",t=[])=>{if(this.runBefore("toggleForm",{operate:e,operateIds:t})!==!1){if(this.form.ref&&this.form.ref.resetFields(),e=="Edit"){if(!t.length)return!1;this.requestEdit(t[0])}else e=="Add"&&(this.form.items=Nt(this.form.defaultItems));this.form.operate=e,this.form.operateIds=t,this.runAfter("toggleForm",{operate:e,operateIds:t})}});F(this,"drawertoggleForm",(e="",t=[])=>{if(this.runBefore("toggleForm",{operate:e,operateIds:t})!==!1){if(this.form.ref&&this.form.ref.resetFields(),e=="Edit"){if(!t.length)return!1;this.requestEdit(t[0])}else e=="Add"&&(this.form.items=Nt(this.form.defaultItems));this.form.operate=e,this.form.operateIds=t,this.runAfter("toggleForm",{operate:e,operateIds:t})}});F(this,"onSubmit",(e=void 0)=>{const t=this.form.operate.replace(this.form.operate[0],this.form.operate[0].toLowerCase());if(this.runBefore("onSubmit",{formEl:e,operate:t,items:this.form.items})===!1)return;Object.keys(this.form.items).forEach(o=>{this.form.items[o]===null&&delete this.form.items[o]});const n=()=>{this.form.submitLoading=!0,this.api.postData(t,this.form.items).then(o=>{var r;this.onTableHeaderAction("refresh",{}),(r=this.form.operateIds)==null||r.shift(),this.form.operateIds.length>0?this.toggleForm("Edit",this.form.operateIds):this.toggleForm(),this.runAfter("onSubmit",{res:o})}).finally(()=>{this.form.submitLoading=!1})};e?(this.form.ref=e,e.validate(o=>{o&&n()})):n()});F(this,"onTableAction",(e,t)=>{if(this.runBefore("onTableAction",{event:e,data:t})===!1)return;const n=new Map([["selection-change",()=>{this.table.selection=t}],["page-size-change",()=>{this.table.filter.limit=t.size,this.onTableHeaderAction("refresh",{event:"page-size-change",...t})}],["current-page-change",()=>{this.table.filter.page=t.page,this.onTableHeaderAction("refresh",{event:"current-page-change",...t})}],["sort-change",()=>{let r;t.prop&&t.order&&(r=t.prop+","+t.order),r!=this.table.filter.order&&(this.table.filter.order=r,this.onTableHeaderAction("refresh",{event:"sort-change",...t}))}],["edit",()=>{this.toggleForm("Edit",[t.row[this.table.pk]])}],["delete",()=>{this.postDel([t.row[this.table.pk]])}],["field-change",()=>{if(t.field.render=="switch"){if(!t.field||!t.field.prop)return;t.row.loading=!0,this.api.postData("edit",{[this.table.pk]:t.row[this.table.pk],[t.field.prop]:t.value}).then(()=>{t.row.loading=!1,t.row[t.field.prop]=t.value}).catch(()=>{t.row.loading=!1})}}],["com-search",()=>{this.table.filter.search=t,this.onTableHeaderAction("refresh",{event:"com-search",data:t})}],["default",()=>{console.warn("No action defined")}]]);return(n.get(e)||n.get("default")).call(this),this.runAfter("onTableAction",{event:e,data:t})});F(this,"onTableHeaderAction",(e,t)=>{if(this.runBefore("onTableHeaderAction",{event:e,data:t})===!1)return;const n=new Map([["refresh",()=>{this.table.data=[],this.getIndex()}],["add",()=>{this.toggleForm("Add")}],["edit",()=>{this.toggleForm("Edit",this.getSelectionIds())}],["draweradd",()=>{this.drawertoggleForm("Add")}],["draweredit",()=>{this.drawertoggleForm("Edit",this.getSelectionIds())}],["delete",()=>{this.postDel(this.getSelectionIds())}],["unfold",()=>{if(!this.table.ref){console.warn("Collapse/expand failed because table ref is not defined. Please assign table ref when onMounted");return}this.table.expandAll=t.unfold,this.table.ref.unFoldAll(t.unfold)}],["quick-search",()=>{this.onTableHeaderAction("refresh",{event:"quick-search",...t})}],["change-show-column",()=>{const r=dt(this.table.column,"prop",t.field);this.table.column[r].show=t.value}],["default",()=>{console.warn("No action defined")}]]);return(n.get(e)||n.get("default")).call(this),this.runAfter("onTableHeaderAction",{event:e,data:t})});F(this,"initSort",()=>{var e;if(this.table.defaultOrder&&this.table.defaultOrder.prop){if(!this.table.ref){console.warn("Failed to initialize default sorting because table ref is not defined. Please assign table ref when onMounted");return}const t=this.table.defaultOrder.prop+","+this.table.defaultOrder.order;this.table.filter&&this.table.filter.order!=t&&(this.table.filter.order=t,(e=this.table.ref.getRef())==null||e.sort(this.table.defaultOrder.prop,this.table.defaultOrder.order=="desc"?"descending":"ascending"))}});F(this,"dragSort",()=>{var r;const e=dt(this.table.column,"render","buttons");if(e===!1)return;const t=dt((r=this.table.column[e])==null?void 0:r.buttons,"render","moveButton");if(t===!1)return;if(!this.table.ref){console.warn("Failed to initialize drag sort because table ref is not defined. Please assign table ref when onMounted");return}const n=this.table.ref.getRef().$el.querySelector(".el-table__body-wrapper .el-table__body tbody"),o=this.table.column[e].buttons[t].disabledTip;m.create(n,{animation:200,handle:".table-row-weigh-sort",ghostClass:"ba-table-row",onStart:()=>{this.table.column[e].buttons[t].disabledTip=!0},onEnd:l=>{this.table.column[e].buttons[t].disabledTip=o;const s=wt(this.table.data,l.oldIndex),u=wt(this.table.data,l.newIndex);if(this.table.dragSortLimitField&&s[this.table.dragSortLimitField]!=u[this.table.dragSortLimitField]){this.onTableHeaderAction("refresh",{}),En({type:"error",message:We.global.t("utils.The moving position is beyond the movable range!")});return}this.api.sortableApi(s[this.table.pk],u[this.table.pk]).finally(()=>{this.onTableHeaderAction("refresh",{})})}})});F(this,"mount",()=>{if(this.runBefore("mount")===!1)return;const e=Sn();this.table.routePath=e.path,this.initComSearch(e!=null&&e.query?e.query:{});let t=e.path+Object.entries(e.query).toString();_n(()=>e.query,()=>{const n=e.path+Object.entries(e.query).toString();e.path==this.table.routePath&&t!=n&&(this.initComSearch(e.query),this.onTableHeaderAction("refresh",{event:"route-query-change",query:e.query}),t=n)})});F(this,"initComSearch",(e={})=>{const t={},n=this.table.column;if(!(n.length<=0)){for(const o in n){if(n[o].operator===!1)continue;const r=n[o].prop;if(typeof n[o].operator>"u"&&(n[o].operator="eq"),r){if(n[o].operator=="RANGE"||n[o].operator=="NOT RANGE"?(t[r]="",t[r+"-start"]="",t[r+"-end"]=""):n[o].operator=="NULL"||n[o].operator=="NOT NULL"?t[r]=!1:t[r]="",this.table.acceptQuery&&typeof e[r]<"u"){const l=e[r]??"";if(n[o].operator=="RANGE"||n[o].operator=="NOT RANGE"){const s=l.split(",");n[o].render=="datetime"?s&&s.length>=2&&(t[r+"-default"]=[new Date(s[0]),new Date(s[1])]):(t[r+"-start"]=s[0]??"",t[r+"-end"]=s[1]??"")}else n[o].operator=="NULL"||n[o].operator=="NOT NULL"?t[r]=!!l:n[o].render=="datetime"?t[r+"-default"]=new Date(l):t[r]=l}this.comSearch.fieldData.set(r,{operator:n[o].operator,render:n[o].render,comSearchRender:n[o].comSearchRender})}}if(this.table.acceptQuery){const o=[];for(const r in e){const l=this.comSearch.fieldData.get(r);l&&o.push({field:r,val:e[r],operator:l.operator,render:l.render})}this.table.filter.search=o}this.comSearch.form=Object.assign(this.comSearch.form,t)}});this.api=e,this.form=Object.assign(this.form,n),this.table=Object.assign(this.table,t),this.before=o,this.after=r}auth(e){return hn(e)}runBefore(e,t={}){return this.before&&this.before[e]&&typeof this.before[e]=="function"?this.before[e]({...t})!==!1:!0}runAfter(e,t={}){return this.after&&this.after[e]&&typeof this.after[e]=="function"?this.after[e]({...t})!==!1:!0}getSelectionIds(){var t;const e=[];return(t=this.table.selection)==null||t.forEach(n=>{e.push(n[this.table.pk])}),e}}export{m as S,Ei as T,Si as b,wi as d};