@he-tree/vue
Advanced tools
Comparing version 2.8.7 to 2.9.1
@@ -1,3 +0,3 @@ | ||
var heTreeVue=function(R,b){"use strict";/*! | ||
* @he-tree/vue v2.8.6 | ||
var heTreeVue=function(R,_){"use strict";/*! | ||
* @he-tree/vue v2.8.7 | ||
* Author: phphe <phphe@outlook.com> (https://github.com/phphe) | ||
@@ -11,3 +11,3 @@ * Homepage: https://hetree.phphe.com/ | ||
* Released under the MIT License. | ||
*/function ie(e){return Object.prototype.toString.call(e)==="[object Array]"}function De(e){return Object.prototype.toString.call(e)==="[object Object]"}function Xe(e){return typeof e=="function"}function Ye(e,t){return e<t?e:t}function Ee(e,t){let n,r=0;for(;(n=e.indexOf(t))>-1;)e.splice(n,1),r++;return r}function ke(e){return e[e.length-1]}function qe(e){return ie(e)?e:[e]}function Je(e,t){let n=new Set(t);const r={};return n.forEach(a=>{r[a]=e[a]}),r}function*Ze(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(t.reverse)if(e.length!=null)for(let n=e.length-1;n>=0;n--){const r={value:e[n],index:n};(!t.exclude||!t.exclude(r))&&(yield r)}else if(De(e)){const n=Object.keys(e);n.reverse();for(const r of n){const a={value:e[r],key:r};(!t.exclude||!t.exclude(a))&&(yield a)}}else throw"Unsupported type";else if(e.length!=null)for(let n=0;n<e.length;n++){const r={value:e[n],index:n};(!t.exclude||!t.exclude(r))&&(yield r)}else if(De(e))for(const n of Object.keys(e)){const r={value:e[n],key:n};(!t.exclude||!t.exclude(r))&&(yield r)}else throw"Unsupported type"}function Ge(e,t,n){e.hasOwnProperty(t)||(e[t]=n)}function Oe(e,t){return Object.keys(t).forEach(n=>{Ge(e,n,t[n])}),e}function Qe(e){const t={};return Object.keys(e).forEach(n=>{e[n]!==void 0&&(t[n]=e[n])}),t}function M(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};n=Oe({...n},{childrenKey:"children"});const{childrenKey:r}=n,a=ie(e)?e:[e];class i{}const l=(s,f,o)=>{n.reverse&&(s=s.slice(),s.reverse());const d=s.length;for(let u=0;u<d;u++){const c=s[u],h=n.reverse?d-u-1:u,g=o?[...o,h]:[];n.childFirst&&c[r]!=null&&l(c[r],c,g);const _=t(c,h,f,g);if(_===!1)throw new i;if(_==="skip children")continue;if(_==="skip siblings")break;n.childFirst||c[r]!=null&&l(c[r],c,g)}};try{l(a,null,ie(e)?[]:null)}catch(s){if(!(s instanceof i))throw s}}function et(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},r;return M(e,function(){if(t(...arguments))return r={node:arguments.length<=0?void 0:arguments[0],index:arguments.length<=1?void 0:arguments[1],parent:arguments.length<=2?void 0:arguments[2],path:arguments.length<=3?void 0:arguments[3]},!1},n),r}function tt(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const r=et(e,t,n);return r==null?void 0:r.node}function Ne(e,t){const n={childrenKey:"children"};t&&Object.assign(n,t);const{childrenKey:r,nodeHandler:a}=n,i=new pe;return i.childrenKey=r,M(e,(l,s,f,o)=>{let d=Object.assign({},l);d[r]&&(d[r]=[]),a&&(d=a(d,{oldNode:l,index:s,parent:f,path:o})),i.set(o,d)},{childrenKey:r}),i.data}class pe{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];ee(this,"data",void 0),ee(this,"childrenKey","children"),this.data=t}get rootChildren(){const{childrenKey:t}=this,{data:n}=this;return ie(n)?n:n[t]}*iteratePath(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const{childrenKey:r,rootChildren:a}=this;if(n.reverse){const i=[...this.iteratePath(t,{...n,reverse:!1})];i.reverse();for(const{path:l,node:s}of i)yield{path:l,node:s}}else{let i=[],l=a;for(const s of t){const f=[...i,s],o=l[s];yield{path:f,node:o},i=f,l=o[r]}}}getFamily(t){const n=[];for(const{node:r}of this.iteratePath(t))n.push(r);return n}get(t){return ke(this.getFamily(t))}getParentAndIndex(t){const n=t.slice(),r=n.pop();return{parent:this.get(n),index:r,parentPath:n}}getParent(t){return this.getParentAndIndex(t).parent}set(t,n){if(t==null||t.length===0)this.data=n;else{const{childrenKey:r}=this;let{rootChildren:a}=this;const{parent:i,index:l}=this.getParentAndIndex(t);let s;t.length===1?(a||(this.data?this.data[r]=[]:this.data=[]),s=a):(i[r]||(i[r]=[]),s=i[r]),s[l]=n}}delete(t){const{childrenKey:n,rootChildren:r}=this,{parent:a,index:i}=this.getParentAndIndex(t),l=t.length===1?r:a[n],s=l[i];return l.splice(i,1),s}walk(t,n){const{childrenKey:r,data:a}=this;return M(a,t,r,n)}clone(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return Ne(this.data),Qe({childrenKey:this.childrenKey,nodeHandler:t.nodeHandler||void 0})}}function Le(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];return Xe(e)?e(...t):e}function nt(e,t){return function(){let r,a;try{r=e(...arguments)}catch(i){a=i}finally{}if(a)throw a;return r}}function te(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const n=[];let r;const a={};let i=a;return{action:function(){for(var f=arguments.length,o=new Array(f),d=0;d<f;d++)o[d]=arguments[d];if(o.length===0)return i===a&&(i=e()),i;if(r||(r=new at),!r.has(o)&&(r.set(o,e(...o)),t.capacity!=null)){n.push(o);const u=n.splice(0,n.length-t.capacity);for(const c of u)r.delete(c)}return r.get(o)},clearCache:()=>{r=null,n.splice(0,n.length)}}}function rt(){let e,t;return{promise:new Promise((r,a)=>{e=r,t=a}),resolve:e,reject:t}}function it(e,t){for(;;){if(e.parentNode==null)return!1;if(e.parentNode===t)return!0;e=e.parentNode}}function ve(e){let t=e.getBoundingClientRect();if(document.documentElement.clientTop>0){const n=t.top-document.documentElement.clientTop,r=t.bottom,a=t.left-document.documentElement.clientLeft,i=t.right,l=t.width||i-a,s=t.height||r-n,d={top:n,right:i,bottom:r,left:a,width:l,height:s,x:a,y:n};t={...d,toJSON:()=>d}}return t}function Te(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},r=n&&n.withSelf?e:e.parentElement;for(;r;){const a=n.until&&r===n.until;if(a&&!n.withUntil)return;const i=t(r);if(i==="break")return;if(i)return r;if(a)return;r=r.parentElement}}function le(e,t){return e.classList?e.classList.contains(t):new RegExp("(^| )"+t+"( |$)","gi").test(e.className)}function Fe(e,t){for(const n of t)if(le(e,n))return!0;return!1}function z(e,t,n,r){e.addEventListener?e.addEventListener(t,n,r):e.attachEvent&&e.attachEvent("on".concat(t),n,r)}function H(e,t,n,r){e.removeEventListener?e.removeEventListener(t,n,r):e.detachEvent&&e.detachEvent("on".concat(t),n,r)}function lt(e){let t=[];const a={listening:!1,stop:()=>{if(a.listening){for(const i of t)i();t=[],a.listening=!1}},resume:()=>{if(!a.listening){for(const i of e){z.apply(this,i);const l=()=>H.apply(this,i);t.push(l)}a.listening=!0}}};return a}function ae(e,t){return getComputedStyle(e)[t]}function me(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};n={start:0,end:e.length-1,maxTimes:1e3,...n};let{start:r,end:a}=n;const{returnNearestIfNoHit:i,maxTimes:l}=n;let s,f;r==null&&(r=0,a=e.length-1);let o=0,d;for(;r>=0&&r<=a;){if(o>=l)throw Error("binarySearch: loop times is over ".concat(l,", you can increase the limit."));s=Math.floor((a-r)/2+r),f=e[s];const u=o+1;if(d=t(f,s,u),d>0)a=s-1;else if(d<0)r=s+1;else return{index:s,value:f,count:u,hit:!0};o++}return i?{index:s,value:f,count:o+1,hit:!1,greater:d>0}:null}class at{constructor(){ee(this,"_map",new Map),ee(this,"_values",{}),ee(this,"_objCount",0)}_keysToString(t){const{_map:n}=this;let r=[];for(const a of t){if(!n.has(a))return null;r.push(n.get(a)[0])}return r.toString()}has(t){return this._keysToString(t)!=null}get(t){const{_values:n}=this,r=this._keysToString(t);if(r==null)throw"Value not found by specified keys";return n[r][1]}set(t,n){const{_map:r,_values:a}=this;let i=[];for(const l of t){let s,f=1;r.has(l)?([s,f]=r.get(l),f++):(this._objCount++,s=this._objCount.toString()),r.set(l,[s,f]),i.push(s)}a[i.toString()]=[t.slice(),n]}delete(t){const{_values:n,_map:r}=this,a=this._keysToString(t);if(a==null)throw"Value not found by specified keys";delete n[a];for(const i of t){let[l,s]=r.get(i);s--,s===0?r.delete(i):r.set(i,[l,s])}}clear(){this._map.clear(),this._values={}}*entries(){const{_values:t}=this;for(const n in t){const[r,a]=t[n];yield[r,a]}}count(){return[...this.entries()].length}}/*! | ||
*/function ie(e){return Object.prototype.toString.call(e)==="[object Array]"}function Ee(e){return Object.prototype.toString.call(e)==="[object Object]"}function Ye(e){return typeof e=="function"}function qe(e,t){return e<t?e:t}function ke(e,t){let n,r=0;for(;(n=e.indexOf(t))>-1;)e.splice(n,1),r++;return r}function Oe(e){return e[e.length-1]}function Je(e){return ie(e)?e:[e]}function Ze(e,t){let n=new Set(t);const r={};return n.forEach(a=>{r[a]=e[a]}),r}function*Ge(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(t.reverse)if(e.length!=null)for(let n=e.length-1;n>=0;n--){const r={value:e[n],index:n};(!t.exclude||!t.exclude(r))&&(yield r)}else if(Ee(e)){const n=Object.keys(e);n.reverse();for(const r of n){const a={value:e[r],key:r};(!t.exclude||!t.exclude(a))&&(yield a)}}else throw"Unsupported type";else if(e.length!=null)for(let n=0;n<e.length;n++){const r={value:e[n],index:n};(!t.exclude||!t.exclude(r))&&(yield r)}else if(Ee(e))for(const n of Object.keys(e)){const r={value:e[n],key:n};(!t.exclude||!t.exclude(r))&&(yield r)}else throw"Unsupported type"}function Qe(e,t,n){e.hasOwnProperty(t)||(e[t]=n)}function Ne(e,t){return Object.keys(t).forEach(n=>{Qe(e,n,t[n])}),e}function et(e){const t={};return Object.keys(e).forEach(n=>{e[n]!==void 0&&(t[n]=e[n])}),t}function M(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};n=Ne({...n},{childrenKey:"children"});const{childrenKey:r}=n,a=ie(e)?e:[e];class i{}const l=(s,f,o)=>{n.reverse&&(s=s.slice(),s.reverse());const d=s.length;for(let u=0;u<d;u++){const c=s[u],h=n.reverse?d-u-1:u,g=o?[...o,h]:[];n.childFirst&&c[r]!=null&&l(c[r],c,g);const b=t(c,h,f,g);if(b===!1)throw new i;if(b==="skip children")continue;if(b==="skip siblings")break;n.childFirst||c[r]!=null&&l(c[r],c,g)}};try{l(a,null,ie(e)?[]:null)}catch(s){if(!(s instanceof i))throw s}}function tt(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},r;return M(e,function(){if(t(...arguments))return r={node:arguments.length<=0?void 0:arguments[0],index:arguments.length<=1?void 0:arguments[1],parent:arguments.length<=2?void 0:arguments[2],path:arguments.length<=3?void 0:arguments[3]},!1},n),r}function nt(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const r=tt(e,t,n);return r==null?void 0:r.node}function Le(e,t){const n={childrenKey:"children"};t&&Object.assign(n,t);const{childrenKey:r,nodeHandler:a}=n,i=new pe;return i.childrenKey=r,M(e,(l,s,f,o)=>{let d=Object.assign({},l);d[r]&&(d[r]=[]),a&&(d=a(d,{oldNode:l,index:s,parent:f,path:o})),i.set(o,d)},{childrenKey:r}),i.data}class pe{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];ee(this,"data",void 0),ee(this,"childrenKey","children"),this.data=t}get rootChildren(){const{childrenKey:t}=this,{data:n}=this;return ie(n)?n:n[t]}*iteratePath(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const{childrenKey:r,rootChildren:a}=this;if(n.reverse){const i=[...this.iteratePath(t,{...n,reverse:!1})];i.reverse();for(const{path:l,node:s}of i)yield{path:l,node:s}}else{let i=[],l=a;for(const s of t){const f=[...i,s],o=l[s];yield{path:f,node:o},i=f,l=o[r]}}}getFamily(t){const n=[];for(const{node:r}of this.iteratePath(t))n.push(r);return n}get(t){return Oe(this.getFamily(t))}getParentAndIndex(t){const n=t.slice(),r=n.pop();return{parent:this.get(n),index:r,parentPath:n}}getParent(t){return this.getParentAndIndex(t).parent}set(t,n){if(t==null||t.length===0)this.data=n;else{const{childrenKey:r}=this;let{rootChildren:a}=this;const{parent:i,index:l}=this.getParentAndIndex(t);let s;t.length===1?(a||(this.data?this.data[r]=[]:this.data=[]),s=a):(i[r]||(i[r]=[]),s=i[r]),s[l]=n}}delete(t){const{childrenKey:n,rootChildren:r}=this,{parent:a,index:i}=this.getParentAndIndex(t),l=t.length===1?r:a[n],s=l[i];return l.splice(i,1),s}walk(t,n){const{childrenKey:r,data:a}=this;return M(a,t,r,n)}clone(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return Le(this.data),et({childrenKey:this.childrenKey,nodeHandler:t.nodeHandler||void 0})}}function Te(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];return Ye(e)?e(...t):e}function rt(e,t){return function(){let r,a;try{r=e(...arguments)}catch(i){a=i}finally{}if(a)throw a;return r}}function te(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const n=[];let r;const a={};let i=a;return{action:function(){for(var f=arguments.length,o=new Array(f),d=0;d<f;d++)o[d]=arguments[d];if(o.length===0)return i===a&&(i=e()),i;if(r||(r=new st),!r.has(o)&&(r.set(o,e(...o)),t.capacity!=null)){n.push(o);const u=n.splice(0,n.length-t.capacity);for(const c of u)r.delete(c)}return r.get(o)},clearCache:()=>{r=null,n.splice(0,n.length)}}}function it(){let e,t;return{promise:new Promise((r,a)=>{e=r,t=a}),resolve:e,reject:t}}function lt(e,t){for(;;){if(e.parentNode==null)return!1;if(e.parentNode===t)return!0;e=e.parentNode}}function ve(e){let t=e.getBoundingClientRect();if(document.documentElement.clientTop>0){const n=t.top-document.documentElement.clientTop,r=t.bottom,a=t.left-document.documentElement.clientLeft,i=t.right,l=t.width||i-a,s=t.height||r-n,d={top:n,right:i,bottom:r,left:a,width:l,height:s,x:a,y:n};t={...d,toJSON:()=>d}}return t}function Fe(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},r=n&&n.withSelf?e:e.parentElement;for(;r;){const a=n.until&&r===n.until;if(a&&!n.withUntil)return;const i=t(r);if(i==="break")return;if(i)return r;if(a)return;r=r.parentElement}}function le(e,t){return e.classList?e.classList.contains(t):new RegExp("(^| )"+t+"( |$)","gi").test(e.className)}function $e(e,t){for(const n of t)if(le(e,n))return!0;return!1}function z(e,t,n,r){e.addEventListener?e.addEventListener(t,n,r):e.attachEvent&&e.attachEvent("on".concat(t),n,r)}function H(e,t,n,r){e.removeEventListener?e.removeEventListener(t,n,r):e.detachEvent&&e.detachEvent("on".concat(t),n,r)}function at(e){let t=[];const a={listening:!1,stop:()=>{if(a.listening){for(const i of t)i();t=[],a.listening=!1}},resume:()=>{if(!a.listening){for(const i of e){z.apply(this,i);const l=()=>H.apply(this,i);t.push(l)}a.listening=!0}}};return a}function ae(e,t){return getComputedStyle(e)[t]}function me(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};n={start:0,end:e.length-1,maxTimes:1e3,...n};let{start:r,end:a}=n;const{returnNearestIfNoHit:i,maxTimes:l}=n;let s,f;r==null&&(r=0,a=e.length-1);let o=0,d;for(;r>=0&&r<=a;){if(o>=l)throw Error("binarySearch: loop times is over ".concat(l,", you can increase the limit."));s=Math.floor((a-r)/2+r),f=e[s];const u=o+1;if(d=t(f,s,u),d>0)a=s-1;else if(d<0)r=s+1;else return{index:s,value:f,count:u,hit:!0};o++}return i?{index:s,value:f,count:o+1,hit:!1,greater:d>0}:null}class st{constructor(){ee(this,"_map",new Map),ee(this,"_values",{}),ee(this,"_objCount",0)}_keysToString(t){const{_map:n}=this;let r=[];for(const a of t){if(!n.has(a))return null;r.push(n.get(a)[0])}return r.toString()}has(t){return this._keysToString(t)!=null}get(t){const{_values:n}=this,r=this._keysToString(t);if(r==null)throw"Value not found by specified keys";return n[r][1]}set(t,n){const{_map:r,_values:a}=this;let i=[];for(const l of t){let s,f=1;r.has(l)?([s,f]=r.get(l),f++):(this._objCount++,s=this._objCount.toString()),r.set(l,[s,f]),i.push(s)}a[i.toString()]=[t.slice(),n]}delete(t){const{_values:n,_map:r}=this,a=this._keysToString(t);if(a==null)throw"Value not found by specified keys";delete n[a];for(const i of t){let[l,s]=r.get(i);s--,s===0?r.delete(i):r.set(i,[l,s])}}clear(){this._map.clear(),this._values={}}*entries(){const{_values:t}=this;for(const n in t){const[r,a]=t[n];yield[r,a]}}count(){return[...this.entries()].length}}/*! | ||
* @virtual-list/vue | ||
@@ -17,3 +17,3 @@ * Author: phphe <phphe@outlook.com> (https://github.com/phphe) | ||
* Released under the MIT License. | ||
*/var st=b.defineComponent({props:{table:Boolean}}),ot=function(){var e=this,t=e.$createElement,n=e._self._c||t;return e.table?n("table",[e._t("prepend"),n("tbody",[e._t("default")],2),e._t("append")],2):n("div",[e._t("prepend"),e._t("default"),e._t("append")],2)},ct=[];function $e(e,t,n,r,a,i,l,s){var f=typeof e=="function"?e.options:e;t&&(f.render=t,f.staticRenderFns=n,f._compiled=!0);var o;if(a&&(o=a),o)if(f.functional){f._injectStyles=o;var d=f.render;f.render=function(h,g){return o.call(g),d(h,g)}}else{var u=f.beforeCreate;f.beforeCreate=u?[].concat(u,o):[o]}return{exports:e,options:f}}const Pe={};var dt=$e(st,ot,ct,!1,ut);function ut(e){for(let t in Pe)this[t]=Pe[t]}var ft=function(){return dt.exports}();const ht=b.defineComponent({components:{VirtualListTable:ft},props:{items:Array,disabled:Boolean,horizontal:Boolean,firstRender:{type:Number,default:10},buffer:{type:Number,default:100},itemKey:{type:[String,Function]},itemSize:{type:Function},table:Boolean},setup(e){const t=b.ref(0),n=b.ref(e.firstRender-1),r=b.computed(()=>{var y;return Ye(n.value,(((y=e.items)==null?void 0:y.length)||1)-1)}),a=b.ref(0),i=b.computed(()=>c.value[t.value]?Q(t.value):0),l=b.computed(()=>c.value.length>0?Q(c.value.length-1)+ke(u.value):0),s=b.computed(()=>c.value[r.value]?l.value-Q(r.value)-u.value[r.value]:0),f=b.computed(()=>e.disabled?{}:{overflow:"auto"}),o=b.computed(()=>{const y={display:"flex"};return e.disabled||(e.horizontal?Object.assign(y,{"margin-left":i.value+"px","margin-right":s.value+"px",width:l.value-s.value-i.value+"px"}):Object.assign(y,{"margin-top":i.value+"px","margin-bottom":s.value+"px"})),y["flex-direction"]=e.horizontal?"row":"column",e.table&&(delete y.display,delete y["flex-direction"]),y}),d=b.computed(()=>b.reactive((e.items||[]).map(()=>null))),u=b.computed(()=>(e.items||[]).map((y,m)=>{var w;if(d[m]!=null)return d[m];let x=(w=e.itemSize)==null?void 0:w.call(e,y,m);return x==null&&(x=a.value),x})),c=b.computed(()=>{const y=[];return u.value.reduce((m,w)=>(y.push(m),m+w),0),y});b.watch(()=>e.items,D);const h=b.computed(()=>{if(!e.items||e.disabled)return;const y=[];for(let m=t.value;m<=r.value;m++){const w=e.items[m];if(!w)break;y.push({item:w,index:m})}return y}),g=b.ref(),_=b.ref();b.onMounted(async()=>{D();try{Ce()}catch{await b.nextTick(),D()}});let S;function N(){const y=g.value;if(!y)return;const m=W(y);S!=null&&e.buffer-Math.abs(m-S)>=10||(S=m,D())}let C=!1,K=!1;async function D(){var y;if(C){K=!0;return}if(!e.items||e.disabled)return;C=!0;const m=g.value,w=(y=_.value)==null?void 0:y.$el;if(!m||!w)return;a.value||(a.value=he()),t.value=q(),n.value=J(),await b.nextTick();let x,T=0;const B={},j=e.table?w.querySelector("tbody").children:w.children;for(let A=0;A<j.length;A++){const k=j[A],E=ae(k,"position");if(E&&["absolute","fixed"].includes(E))continue;const O=ae(k,"display")!=="none"?G(k):0,F=k.getAttribute("vt-index"),Z=F?parseInt(F):t.value+T;B[Z]=(B[Z]||0)+O,T++}for(const A of Object.keys(B)){const k=parseInt(A);d.value[k]!==B[k]&&(d.value[k]=B[k],x=!0)}x&&await b.nextTick(),C=!1,K&&(K=!1,D());function q(){const A=W(m)-I(m)-e.buffer;return me(c.value,E=>E-A,{returnNearestIfNoHit:!0}).index}function J(){const A=W(m)-I(m)+V(m)+e.buffer;return me(c.value,E=>E-A,{returnNearestIfNoHit:!0}).index}function he(){const k=[],E=e.table?w.querySelector("tbody").children:w.children;for(let O=0;O<E.length;O++){const F=E[O],Z=getComputedStyle(F);if(["absolute","fixed"].includes(Z.position))continue;const ge=G(F);if(k.push(ge),k.length>=10)break}return k.length===0?0:k.reduce((O,F)=>O+F,0)/k.length}}function V(y){const m=getComputedStyle(y);let w=parseFloat(e.horizontal?m.width:m.height);return m.boxSizing==="border-box"&&(e.horizontal?w=w-parseFloat(m.borderLeftWidth)-parseFloat(m.borderRightWidth):w=w-parseFloat(m.borderTopWidth)-parseFloat(m.borderBottomWidth)),w}function G(y){let m=V(y);const w=getComputedStyle(y);return e.horizontal?m+=parseFloat(w.borderLeftWidth)+parseFloat(w.borderRightWidth)+parseFloat(w.marginLeft)+parseFloat(w.marginRight):m+=parseFloat(w.borderTopWidth)+parseFloat(w.borderBottomWidth)+parseFloat(w.marginTop)+parseFloat(w.marginBottom),m=Number.isNaN(m)?0:m,m}function W(y){return e.horizontal?y.scrollLeft:y.scrollTop}function I(y){const m=getComputedStyle(y);return e.horizontal?parseFloat(m.paddingLeft):parseFloat(m.paddingTop)}function Q(y){return c.value[y]}function Ce(){const y=g.value;new ResizeObserver(w=>{for(let x of w)if(le(x.target,"vtlist")){D();break}}).observe(y)}function fe(y,m){if(e.itemKey){if(typeof e.itemKey=="string"&&e.itemKey==="index")return m;if(typeof e.itemKey=="function")return e.itemKey(y,m)}}return{listElRef:g,listInnerRef:_,onscroll:N,listStyle:f,listInnerStyle:o,visibleItemsInfo:h,getItemKey:fe,update:D,sizes:u,positions:c,runtimeSizes:d}}});var gt=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{ref:"listElRef",staticClass:"vtlist",style:e.listStyle,on:{"&scroll":function(r){return e.onscroll.apply(null,arguments)}}},[n("VirtualListTable",{ref:"listInnerRef",staticClass:"vtlist-inner",style:e.listInnerStyle,attrs:{table:e.table},scopedSlots:e._u([{key:"prepend",fn:function(){return[e._t("prepend")]},proxy:!0},{key:"append",fn:function(){return[e._t("append")]},proxy:!0}],null,!0)},[e.disabled?[e._l(e.items,function(r,a){return[e._t("default",null,{item:r,index:a})]})]:[e._l(e.visibleItemsInfo,function(r){var a=r.item,i=r.index;return[e._t("default",null,{item:a,index:i})]})]],2)],1)},pt=[];const Ie={};var vt=$e(ht,gt,pt,!1,mt);function mt(e){for(let t in Ie)this[t]=Ie[t]}var yt=function(){return vt.exports}();let se=!1;const bt=()=>{se=!0,setTimeout(()=>{se=!1},100)},_t=b.defineComponent({props:["stat","rtl","btt","indent","table","treeLine","treeLineOffset","processor"],emits:["open","close","check"],setup(e,{emit:t}){const n=b.computed(()=>({[e.rtl?"paddingRight":"paddingLeft"]:e.indent*(e.stat.level-1)+"px"}));b.watch(()=>e.stat.checked,i=>{se||e.processor.afterOneCheckChanged(e.stat)&&t("check",e.stat)}),b.watch(()=>e.stat.open,i=>{se||(t(i?"open":"close",e.stat),bt())});const r=b.computed(()=>{const i=[],l=d=>{var u;if(d.parent){let c=(u=d.parent)==null?void 0:u.children.indexOf(d);do{c++;let h=d.parent.children[c];if(h){if(!h.hidden)return!0}else break}while(!0)}return!1},s=e.rtl?"right":"left",f=e.btt?"top":"bottom";let o=e.stat;for(;o;){let d=(o.level-2)*e.indent+e.treeLineOffset;const u=l(o),c=()=>{i.push({style:{[s]:d+"px",[f]:u?0:"50%"}})};o===e.stat?o.level>1&&c():u&&c(),o=o.parent}return i}),a=b.computed(()=>{let i=(e.stat.level-2)*e.indent+e.treeLineOffset;return{[e.rtl?"right":"left"]:i+"px"}});return{indentStyle:n,vLines:r,hLineStyle:a}}});var xt=function(){var e=this,t=e.$createElement,n=e._self._c||t;return e.table?n("tr",{ref:"el",staticClass:"tree-node"},[e._t("default",null,{indentStyle:e.indentStyle})],2):n("div",{ref:"el",staticClass:"tree-node",class:{"tree-node--with-tree-line":e.treeLine},style:e.indentStyle},[e.treeLine?[e._l(e.vLines,function(r){return n("div",{staticClass:"tree-line tree-vline",style:r.style})}),e.stat.level>1?n("div",{staticClass:"tree-line tree-hline",style:e.hLineStyle}):e._e()]:e._e(),n("div",{staticClass:"tree-node-inner"},[e._t("default",null,{indentStyle:e.indentStyle})],2)],2)},St=[];function ye(e,t,n,r,a,i,l,s){var f=typeof e=="function"?e.options:e;t&&(f.render=t,f.staticRenderFns=n,f._compiled=!0);var o;if(a&&(o=a),o)if(f.functional){f._injectStyles=o;var d=f.render;f.render=function(h,g){return o.call(g),d(h,g)}}else{var u=f.beforeCreate;f.beforeCreate=u?[].concat(u,o):[o]}return{exports:e,options:f}}const Be={};var wt=ye(_t,xt,St,!1,Ct);function Ct(e){for(let t in Be)this[t]=Be[t]}const Ae=function(){return wt.exports}();/*! | ||
*/var ot=_.defineComponent({props:{table:Boolean}}),ct=function(){var e=this,t=e.$createElement,n=e._self._c||t;return e.table?n("table",[e._t("prepend"),n("tbody",[e._t("default")],2),e._t("append")],2):n("div",[e._t("prepend"),e._t("default"),e._t("append")],2)},dt=[];function Pe(e,t,n,r,a,i,l,s){var f=typeof e=="function"?e.options:e;t&&(f.render=t,f.staticRenderFns=n,f._compiled=!0);var o;if(a&&(o=a),o)if(f.functional){f._injectStyles=o;var d=f.render;f.render=function(h,g){return o.call(g),d(h,g)}}else{var u=f.beforeCreate;f.beforeCreate=u?[].concat(u,o):[o]}return{exports:e,options:f}}const Ie={};var ut=Pe(ot,ct,dt,!1,ft);function ft(e){for(let t in Ie)this[t]=Ie[t]}var ht=function(){return ut.exports}();const gt=_.defineComponent({components:{VirtualListTable:ht},props:{items:Array,disabled:Boolean,horizontal:Boolean,firstRender:{type:Number,default:10},buffer:{type:Number,default:100},itemKey:{type:[String,Function]},itemSize:{type:Function},table:Boolean},setup(e){const t=_.ref(0),n=_.ref(e.firstRender-1),r=_.computed(()=>{var y;return qe(n.value,(((y=e.items)==null?void 0:y.length)||1)-1)}),a=_.ref(0),i=_.computed(()=>c.value[t.value]?Q(t.value):0),l=_.computed(()=>c.value.length>0?Q(c.value.length-1)+Oe(u.value):0),s=_.computed(()=>c.value[r.value]?l.value-Q(r.value)-u.value[r.value]:0),f=_.computed(()=>e.disabled?{}:{overflow:"auto"}),o=_.computed(()=>{const y={display:"flex"};return e.disabled||(e.horizontal?Object.assign(y,{"margin-left":i.value+"px","margin-right":s.value+"px",width:l.value-s.value-i.value+"px"}):Object.assign(y,{"margin-top":i.value+"px","margin-bottom":s.value+"px"})),y["flex-direction"]=e.horizontal?"row":"column",e.table&&(delete y.display,delete y["flex-direction"]),y}),d=_.computed(()=>_.reactive((e.items||[]).map(()=>null))),u=_.computed(()=>(e.items||[]).map((y,m)=>{var w;if(d[m]!=null)return d[m];let x=(w=e.itemSize)==null?void 0:w.call(e,y,m);return x==null&&(x=a.value),x})),c=_.computed(()=>{const y=[];return u.value.reduce((m,w)=>(y.push(m),m+w),0),y});_.watch(()=>e.items,D);const h=_.computed(()=>{if(!e.items||e.disabled)return;const y=[];for(let m=t.value;m<=r.value;m++){const w=e.items[m];if(!w)break;y.push({item:w,index:m})}return y}),g=_.ref(),b=_.ref();_.onMounted(async()=>{D();try{De()}catch{await _.nextTick(),D()}});let S;function N(){const y=g.value;if(!y)return;const m=W(y);S!=null&&e.buffer-Math.abs(m-S)>=10||(S=m,D())}let C=!1,K=!1;async function D(){var y;if(C){K=!0;return}if(!e.items||e.disabled)return;C=!0;const m=g.value,w=(y=b.value)==null?void 0:y.$el;if(!m||!w)return;a.value||(a.value=he()),t.value=q(),n.value=J(),await _.nextTick();let x,T=0;const B={},j=e.table?w.querySelector("tbody").children:w.children;for(let A=0;A<j.length;A++){const k=j[A],E=ae(k,"position");if(E&&["absolute","fixed"].includes(E))continue;const O=ae(k,"display")!=="none"?G(k):0,F=k.getAttribute("vt-index"),Z=F?parseInt(F):t.value+T;B[Z]=(B[Z]||0)+O,T++}for(const A of Object.keys(B)){const k=parseInt(A);d.value[k]!==B[k]&&(d.value[k]=B[k],x=!0)}x&&await _.nextTick(),C=!1,K&&(K=!1,D());function q(){const A=W(m)-I(m)-e.buffer;return me(c.value,E=>E-A,{returnNearestIfNoHit:!0}).index}function J(){const A=W(m)-I(m)+V(m)+e.buffer;return me(c.value,E=>E-A,{returnNearestIfNoHit:!0}).index}function he(){const k=[],E=e.table?w.querySelector("tbody").children:w.children;for(let O=0;O<E.length;O++){const F=E[O],Z=getComputedStyle(F);if(["absolute","fixed"].includes(Z.position))continue;const ge=G(F);if(k.push(ge),k.length>=10)break}return k.length===0?0:k.reduce((O,F)=>O+F,0)/k.length}}function V(y){const m=getComputedStyle(y);let w=parseFloat(e.horizontal?m.width:m.height);return m.boxSizing==="border-box"&&(e.horizontal?w=w-parseFloat(m.borderLeftWidth)-parseFloat(m.borderRightWidth):w=w-parseFloat(m.borderTopWidth)-parseFloat(m.borderBottomWidth)),w}function G(y){let m=V(y);const w=getComputedStyle(y);return e.horizontal?m+=parseFloat(w.borderLeftWidth)+parseFloat(w.borderRightWidth)+parseFloat(w.marginLeft)+parseFloat(w.marginRight):m+=parseFloat(w.borderTopWidth)+parseFloat(w.borderBottomWidth)+parseFloat(w.marginTop)+parseFloat(w.marginBottom),m=Number.isNaN(m)?0:m,m}function W(y){return e.horizontal?y.scrollLeft:y.scrollTop}function I(y){const m=getComputedStyle(y);return e.horizontal?parseFloat(m.paddingLeft):parseFloat(m.paddingTop)}function Q(y){return c.value[y]}function De(){const y=g.value;new ResizeObserver(w=>{for(let x of w)if(le(x.target,"vtlist")){D();break}}).observe(y)}function fe(y,m){if(e.itemKey){if(typeof e.itemKey=="string"&&e.itemKey==="index")return m;if(typeof e.itemKey=="function")return e.itemKey(y,m)}}return{listElRef:g,listInnerRef:b,onscroll:N,listStyle:f,listInnerStyle:o,visibleItemsInfo:h,getItemKey:fe,update:D,sizes:u,positions:c,runtimeSizes:d}}});var pt=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{ref:"listElRef",staticClass:"vtlist",style:e.listStyle,on:{"&scroll":function(r){return e.onscroll.apply(null,arguments)}}},[n("VirtualListTable",{ref:"listInnerRef",staticClass:"vtlist-inner",style:e.listInnerStyle,attrs:{table:e.table},scopedSlots:e._u([{key:"prepend",fn:function(){return[e._t("prepend")]},proxy:!0},{key:"append",fn:function(){return[e._t("append")]},proxy:!0}],null,!0)},[e.disabled?[e._l(e.items,function(r,a){return[e._t("default",null,{item:r,index:a})]})]:[e._l(e.visibleItemsInfo,function(r){var a=r.item,i=r.index;return[e._t("default",null,{item:a,index:i})]})]],2)],1)},vt=[];const Be={};var mt=Pe(gt,pt,vt,!1,yt);function yt(e){for(let t in Be)this[t]=Be[t]}var bt=function(){return mt.exports}();let se=!1;const _t=()=>{se=!0,setTimeout(()=>{se=!1},100)},xt=_.defineComponent({props:["stat","rtl","btt","indent","table","treeLine","treeLineOffset","processor"],emits:["open","close","check"],setup(e,{emit:t}){const n=_.computed(()=>({[e.rtl?"paddingRight":"paddingLeft"]:e.indent*(e.stat.level-1)+"px"}));_.watch(()=>e.stat.checked,i=>{se||e.processor.afterOneCheckChanged(e.stat)&&t("check",e.stat)}),_.watch(()=>e.stat.open,i=>{se||(t(i?"open":"close",e.stat),_t())});const r=_.computed(()=>{const i=[],l=d=>{var u;if(d.parent){let c=(u=d.parent)==null?void 0:u.children.indexOf(d);do{c++;let h=d.parent.children[c];if(h){if(!h.hidden)return!0}else break}while(!0)}return!1},s=e.rtl?"right":"left",f=e.btt?"top":"bottom";let o=e.stat;for(;o;){let d=(o.level-2)*e.indent+e.treeLineOffset;const u=l(o),c=()=>{i.push({style:{[s]:d+"px",[f]:u?0:"50%"}})};o===e.stat?o.level>1&&c():u&&c(),o=o.parent}return i}),a=_.computed(()=>{let i=(e.stat.level-2)*e.indent+e.treeLineOffset;return{[e.rtl?"right":"left"]:i+"px"}});return{indentStyle:n,vLines:r,hLineStyle:a}}});var St=function(){var e=this,t=e.$createElement,n=e._self._c||t;return e.table?n("tr",{ref:"el",staticClass:"tree-node"},[e._t("default",null,{indentStyle:e.indentStyle})],2):n("div",{ref:"el",staticClass:"tree-node",class:{"tree-node--with-tree-line":e.treeLine},style:e.indentStyle},[e.treeLine?[e._l(e.vLines,function(r){return n("div",{staticClass:"tree-line tree-vline",style:r.style})}),e.stat.level>1?n("div",{staticClass:"tree-line tree-hline",style:e.hLineStyle}):e._e()]:e._e(),n("div",{staticClass:"tree-node-inner"},[e._t("default",null,{indentStyle:e.indentStyle})],2)],2)},wt=[];function ye(e,t,n,r,a,i,l,s){var f=typeof e=="function"?e.options:e;t&&(f.render=t,f.staticRenderFns=n,f._compiled=!0);var o;if(a&&(o=a),o)if(f.functional){f._injectStyles=o;var d=f.render;f.render=function(h,g){return o.call(g),d(h,g)}}else{var u=f.beforeCreate;f.beforeCreate=u?[].concat(u,o):[o]}return{exports:e,options:f}}const Ae={};var Ct=ye(xt,St,wt,!1,Dt);function Dt(e){for(let t in Ae)this[t]=Ae[t]}const Ke=function(){return Ct.exports}();/*! | ||
* @he-tree/tree-utils v0.1.0-alpha.5 | ||
@@ -23,3 +23,3 @@ * Author: phphe <phphe@outlook.com> (https://github.com/phphe) | ||
* Released under the MIT License. | ||
*/const X="children";function Dt(e){const n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r={...Et,...n,data:e,stats:null,statsFlat:null,_statsMap:null,initialized:!1,init(){const{data:i,childrenKey:l}=this,s=new pe([]);this._statsMap=new Map,M(i,(o,d,u,c)=>{const h=this.statHandler({...Ke(),data:o,open:!!this.defaultOpen,parent:s.getParent(c),children:[],level:c.length});this._statsMap.set(o,h),s.set(c,h)},{childrenKey:l});const f=[];s.walk(o=>{f.push(o)}),this.stats=this.statsHandler(s.rootChildren),this.statsFlat=this.statsFlatHandler(f),this.initialized=!0},getStat(i){let l=this._statsMap.get(i);if(!l)throw new Me("Stat not found");return l},has(i){if(i.isStat)return this.statsFlat.indexOf(i)>-1;try{return!!this.getStat(i)}catch(l){if(l instanceof Me)return!1;throw l}},_getPathByStat(i){if(i==null)return[];const s=this.getSiblings(i).indexOf(i);return[...i.parent?this._getPathByStat(i.parent):[],s]},afterOneCheckChanged(i){const{checked:l}=i;if(i._ignoreCheckedOnce)return delete i._ignoreCheckedOnce,!1;const s=f=>{const{parent:o}=f;if(o){let d,u,c;for(const g of o.children)g.checked?d=!0:g.checked===0?c=!0:u=!0;const h=c?0:u?d?0:!1:!0;o.checked!==h&&(this._ignoreCheckedOnce(o),o.checked=h),s(o)}};return s(i),M(i.children,f=>{f.checked!==l&&(this._ignoreCheckedOnce(f),f.checked=l)},{childrenKey:X}),!0},_ignoreCheckedOnce(i){i._ignoreCheckedOnce=!0,setTimeout(()=>{i._ignoreCheckedOnce&&(i._ignoreCheckedOnce=!1)},100)},isVisible(i){const l=i.isStat?i:this.getStat(i),s=f=>!f||!f.hidden&&f.open&&s(f.parent);return!!(!l.hidden&&s(l.parent))},updateCheck(){M(this.stats,i=>{if(i.children&&i.children.length>0){const l=i.children.every(s=>s.checked);i.checked!==l&&(this._ignoreCheckedOnce(i),i.checked=l)}},{childFirst:!0,childrenKey:X})},getChecked(){let i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1;return this.statsFlat.filter(l=>l.checked||i&&l.checked===0)},getUnchecked(){let i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;return this.statsFlat.filter(l=>i?!l.checked:l.checked===!1)},openAll(){for(const i of this.statsFlat)i.open=!0},closeAll(){for(const i of this.statsFlat)i.open=!1},openNodeAndParents(i){const l=i.isStat?i:this.getStat(i);for(const s of this.iterateParent(l,{withSelf:!0}))s.open=!0},_calcFlatIndex(i,l){let s=i?this.statsFlat.indexOf(i)+1:0;const f=i?i.children:this.stats;for(let o=0;o<l;o++)s+=this._count(f[o]);return s},add(i,l,s){if(this.has(i))throw"Can't add because data exists in tree";const f=l?l.children:this.stats;s==null&&(s=f.length);const o=this.statHandler({...Ke(),open:!!this.defaultOpen,data:i,parent:l||null,children:[],level:l?l.level+1:1});this._setPosition(o,l||null,s);const d=i[this.childrenKey];if(d){const u=d.slice();for(const c of u)this.add(c,o)}},remove(i){const l=this.getSiblings(i);if(l.includes(i)){Ee(l,i);const s=this._flat(i);this.statsFlat.splice(this.statsFlat.indexOf(i),s.length);for(const f of s)this._statsMap.delete(f.data);return this.afterRemoveStat(i),!0}return!1},getSiblings(i){const{parent:l}=i;return l?l.children:this.stats},_setPosition(i,l,s){(l?l.children:this.stats).splice(s,0,i),i.parent=l,i.level=l?l.level+1:1;const o=this._calcFlatIndex(l,s),d=this._flat(i);this.statsFlat.splice(o,0,...d);for(const u of d)this._statsMap.has(u.data)||this._statsMap.set(u.data,u);M(i,(u,c,h)=>{h&&(u.level=h.level+1)},{childrenKey:X}),this.afterSetStat(i,l,s)},*iterateParent(i,l){let s=l!=null&&l.withSelf?i:i.parent;for(;s;)yield s,s=s.parent},move(i,l,s){if(this.has(i)){if(i.parent===l&&this.getSiblings(i).indexOf(i)===s)return!1;if(i===l)throw new Error("Can't move node to it self");if(l&&i.level<l.level){let f;for(const o of this.iterateParent(l))if(o.level===i.level){f=o;break}if(i===f)throw new Error("Can't move node to its descendant")}this.remove(i)}return this._setPosition(i,l,s),!0},_flat(i){const l=[];return M(i,s=>{l.push(s)},{childrenKey:X}),l},_count(i){return this._flat(i).length},getData(i,l){const{childrenKey:s}=this,f=new pe([]);return f.childrenKey=s,M(l||this.stats,(o,d,u,c)=>{let h={...o.data,[s]:[]};i&&(h=i(h)),f.set(c,h)},{childrenKey:X}),f.data}},a=r;return r.noInitialization||a.init(),a}const Et={childrenKey:"children",defaultOpen:!1,statsHandler(e){return e},statsFlatHandler(e){return e},afterSetStat(e,t,n){},afterRemoveStat(e){},statHandler(e){return e}};function Ke(){return{isStat:!0,hidden:!1,checked:!1,style:null,class:null,draggable:null,droppable:null}}class Me extends Error{constructor(t){super(t),this.name="StatNotFoundError"}}function kt(e,t={}){const n={...t,statHandler(r){return this._statHandler2&&(r=this._statHandler2(r)),be(t.statHandler,b.reactive(r))},statsHandler(r){return be(t.statsHandler,b.reactive(r))},statsFlatHandler(r){return be(t.statsFlatHandler,b.reactive(r))}};return Dt(e,n)}function be(e,t){return e?e(t):t}const Ot=b.defineComponent({components:{VirtualList:yt,TreeNode:Ae},props:{value:{required:b.isVue2,type:Array},modelValue:{required:b.isVue3,type:Array},updateBehavior:{type:String,default:"modify"},processor:{type:Object,default:()=>kt([],{noInitialization:!0})},childrenKey:{type:String,default:"children"},textKey:{type:String,default:"text"},indent:{type:Number,default:20},virtualization:{type:Boolean,default:!1},virtualizationPrerenderCount:{type:Number,default:20},defaultOpen:{type:Boolean,default:!0},statHandler:{type:Function},rtl:{type:Boolean,default:!1},btt:{type:Boolean,default:!1},table:{type:Boolean,default:!1},watermark:{type:Boolean,default:!1},nodeKey:{type:[String,Function],default:"index"},treeLine:{type:Boolean,default:!1},treeLineOffset:{type:Number,default:8}},emits:["update:modelValue","click:node","open:node","close:node","check:node","beforeDragStart","before-drag-start","after-drop","change","enter","leave"],data(){return{stats:[],statsFlat:[],dragNode:null,dragOvering:!1,placeholderData:{},placeholderColspan:1,batchUpdateWaiting:!1,self:this,_ignoreValueChangeOnce:!1}},computed:{valueComputed(){return(b.isVue2?this.value:this.modelValue)||[]},visibleStats(){const{statsFlat:e,isVisible:t}=this;let n=e;return this.btt&&(n=n.slice(),n.reverse()),n.filter(r=>t(r))},rootChildren(){return this.stats}},methods:{_emitValue(e){this.$emit(b.isVue2?"input":"update:modelValue",e)},_updateValue(e){return this.updateBehavior==="disabled"?!1:(e!==this.valueComputed&&(this._ignoreValueChangeOnce=!0),this._emitValue(e),!0)},getStat:_e($("getStat")),has:_e($("has")),updateCheck:$("updateCheck"),getChecked:$("getChecked"),getUnchecked:$("getUnchecked"),openAll:$("openAll"),closeAll:$("closeAll"),openNodeAndParents:$("openNodeAndParents"),isVisible:$("isVisible"),move:Re("move"),add:_e(Re("add")),addMulti(e,t,n){this.batchUpdate(()=>{let r=n;for(const a of e)this.add(a,t,r),r!=null&&r++})},remove:$("remove"),removeMulti(e){let t=[...e];this.batchUpdate(()=>{for(const n of t)this.remove(n)})},iterateParent:$("iterateParent"),getSiblings:$("getSiblings"),getData:$("getData"),getRootEl(){return this.$refs.vtlist.listElRef},batchUpdate(e){const t=this.ignoreUpdate(e);return this.batchUpdateWaiting||this._updateValue(this.updateBehavior==="new"?this.getData():this.valueComputed),t},ignoreUpdate(e){const t=this.batchUpdateWaiting;this.batchUpdateWaiting=!0;const n=e();return this.batchUpdateWaiting=t,n}},watch:{processor:{immediate:!0,handler(e){if(e){const t=n=>{if(n){const{childrenKey:r}=this;return n[r]||(n[r]=[]),n[r]}else return this.valueComputed};e._statHandler2=this.statHandler?n=>n.data===this.placeholderData?n:this.statHandler(n):null,e.afterSetStat=(n,r,a)=>{const{childrenKey:i,updateBehavior:l}=this;let s=this.valueComputed;if(l==="new"){if(this.batchUpdateWaiting)return;s=this.getData()}else if(l==="modify"){const f=t(r==null?void 0:r.data);f.includes(n.data)||f.splice(a,0,n.data)}this.batchUpdateWaiting||this._updateValue(s)},e.afterRemoveStat=n=>{var l;const{childrenKey:r,updateBehavior:a}=this;let i=this.valueComputed;if(a==="new"){if(this.batchUpdateWaiting)return;i=this.getData()}else if(a==="modify"){const s=t((l=n.parent)==null?void 0:l.data);Ee(s,n.data)}this.batchUpdateWaiting||this._updateValue(i)}}e.initialized||(e.data=this.valueComputed,Object.assign(e,Je(this,["childrenKey","defaultOpen"])),e.init(),e.updateCheck()),this.stats=e.stats,this.statsFlat=e.statsFlat,e.data!==this.valueComputed&&this._updateValue(e.data)}},valueComputed:{handler(e){if(this.dragOvering||this.dragNode||this._ignoreValueChangeOnce)this._ignoreValueChangeOnce=!1;else{const{processor:n}=this;n.data=e,n.init(),this.stats=n.stats,this.statsFlat=n.statsFlat}}}},created(){},mounted(){this.watermark===!1&&(window._heTreeWatermarkDisabled=!0),this.watermark&&!window._heTreeWatermarkDisabled&&(window._heTreeWatermark||(window._heTreeWatermark=!0,console.log("%c[he-tree] Vue tree component: https://hetree.phphe.com","color:#0075ff; font-size:14px;")))}});function $(e){return function(...t){return this.processor[e](...t)}}function Re(e){return function(...t){return this.batchUpdate(()=>this.processor[e](...t))}}function _e(e){return function(t,...n){return t&&(t=b.reactive(t)),e.call(this,t,...n)}}var Nt=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("VirtualList",{ref:"vtlist",staticClass:"he-tree",class:{"he-tree--rtl rtl":e.rtl,"he-tree--drag-overing drag-overing":e.dragOvering},attrs:{items:e.visibleStats,disabled:!e.virtualization,table:e.table,itemKey:e.nodeKey},scopedSlots:e._u([{key:"prepend",fn:function(){return[e._t("prepend",null,{tree:e.self})]},proxy:!0},{key:"default",fn:function(r){var a=r.item,i=r.index;return[n("TreeNode",{class:[a.class,{"drag-placeholder-wrapper":a.data===e.placeholderData,"dragging-node":a===e.dragNode}],style:a.style,attrs:{"vt-index":i,stat:a,rtl:e.rtl,btt:e.btt,indent:e.indent,table:e.table,treeLine:e.treeLine,treeLineOffset:e.treeLineOffset,processor:e.processor},on:{click:function(l){return e.$emit("click:node",a)},open:function(l){return e.$emit("open:node",l)},close:function(l){return e.$emit("close:node",l)},check:function(l){return e.$emit("check:node",l)}},scopedSlots:e._u([{key:"default",fn:function(l){var s=l.indentStyle;return[a.data===e.placeholderData?[e.table?n("td",{style:s,attrs:{colspan:e.placeholderColspan}},[n("div",{staticClass:"drag-placeholder he-tree-drag-placeholder"},[e._t("placeholder",null,{tree:e.self})],2)]):n("div",{staticClass:"drag-placeholder he-tree-drag-placeholder"},[e._t("placeholder",null,{tree:e.self})],2)]:e._t("default",function(){return[e._v(e._s(a.data[e.textKey])+" ")]},{node:a.data,stat:a,indentStyle:s,tree:e.self})]}}],null,!0)})]}},{key:"append",fn:function(){return[e._t("append",null,{tree:e.self})]},proxy:!0}],null,!0)})},Lt=[];const ze={};var Tt=ye(Ot,Nt,Lt,!1,Ft);function Ft(e){for(let t in ze)this[t]=ze[t]}const He=function(){return Tt.exports}();/*! | ||
*/const X="children";function Et(e){const n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r={...kt,...n,data:e,stats:null,statsFlat:null,_statsMap:null,initialized:!1,init(){const{data:i,childrenKey:l}=this,s=new pe([]);this._statsMap=new Map,M(i,(o,d,u,c)=>{const h=this.statHandler({...Me(),data:o,open:!!this.defaultOpen,parent:s.getParent(c),children:[],level:c.length});this._statsMap.set(o,h),s.set(c,h)},{childrenKey:l});const f=[];s.walk(o=>{f.push(o)}),this.stats=this.statsHandler(s.rootChildren),this.statsFlat=this.statsFlatHandler(f),this.initialized=!0},getStat(i){let l=this._statsMap.get(i);if(!l)throw new Re("Stat not found");return l},has(i){if(i.isStat)return this.statsFlat.indexOf(i)>-1;try{return!!this.getStat(i)}catch(l){if(l instanceof Re)return!1;throw l}},_getPathByStat(i){if(i==null)return[];const s=this.getSiblings(i).indexOf(i);return[...i.parent?this._getPathByStat(i.parent):[],s]},afterOneCheckChanged(i){const{checked:l}=i;if(i._ignoreCheckedOnce)return delete i._ignoreCheckedOnce,!1;const s=f=>{const{parent:o}=f;if(o){let d,u,c;for(const g of o.children)g.checked?d=!0:g.checked===0?c=!0:u=!0;const h=c?0:u?d?0:!1:!0;o.checked!==h&&(this._ignoreCheckedOnce(o),o.checked=h),s(o)}};return s(i),M(i.children,f=>{f.checked!==l&&(this._ignoreCheckedOnce(f),f.checked=l)},{childrenKey:X}),!0},_ignoreCheckedOnce(i){i._ignoreCheckedOnce=!0,setTimeout(()=>{i._ignoreCheckedOnce&&(i._ignoreCheckedOnce=!1)},100)},isVisible(i){const l=i.isStat?i:this.getStat(i),s=f=>!f||!f.hidden&&f.open&&s(f.parent);return!!(!l.hidden&&s(l.parent))},updateCheck(){M(this.stats,i=>{if(i.children&&i.children.length>0){const l=i.children.every(s=>s.checked);i.checked!==l&&(this._ignoreCheckedOnce(i),i.checked=l)}},{childFirst:!0,childrenKey:X})},getChecked(){let i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1;return this.statsFlat.filter(l=>l.checked||i&&l.checked===0)},getUnchecked(){let i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;return this.statsFlat.filter(l=>i?!l.checked:l.checked===!1)},openAll(){for(const i of this.statsFlat)i.open=!0},closeAll(){for(const i of this.statsFlat)i.open=!1},openNodeAndParents(i){const l=i.isStat?i:this.getStat(i);for(const s of this.iterateParent(l,{withSelf:!0}))s.open=!0},_calcFlatIndex(i,l){let s=i?this.statsFlat.indexOf(i)+1:0;const f=i?i.children:this.stats;for(let o=0;o<l;o++)s+=this._count(f[o]);return s},add(i,l,s){if(this.has(i))throw"Can't add because data exists in tree";const f=l?l.children:this.stats;s==null&&(s=f.length);const o=this.statHandler({...Me(),open:!!this.defaultOpen,data:i,parent:l||null,children:[],level:l?l.level+1:1});this._setPosition(o,l||null,s);const d=i[this.childrenKey];if(d){const u=d.slice();for(const c of u)this.add(c,o)}},remove(i){const l=this.getSiblings(i);if(l.includes(i)){ke(l,i);const s=this._flat(i);this.statsFlat.splice(this.statsFlat.indexOf(i),s.length);for(const f of s)this._statsMap.delete(f.data);return this.afterRemoveStat(i),!0}return!1},getSiblings(i){const{parent:l}=i;return l?l.children:this.stats},_setPosition(i,l,s){(l?l.children:this.stats).splice(s,0,i),i.parent=l,i.level=l?l.level+1:1;const o=this._calcFlatIndex(l,s),d=this._flat(i);this.statsFlat.splice(o,0,...d);for(const u of d)this._statsMap.has(u.data)||this._statsMap.set(u.data,u);M(i,(u,c,h)=>{h&&(u.level=h.level+1)},{childrenKey:X}),this.afterSetStat(i,l,s)},*iterateParent(i,l){let s=l!=null&&l.withSelf?i:i.parent;for(;s;)yield s,s=s.parent},move(i,l,s){if(this.has(i)){if(i.parent===l&&this.getSiblings(i).indexOf(i)===s)return!1;if(i===l)throw new Error("Can't move node to it self");if(l&&i.level<l.level){let f;for(const o of this.iterateParent(l))if(o.level===i.level){f=o;break}if(i===f)throw new Error("Can't move node to its descendant")}this.remove(i)}return this._setPosition(i,l,s),!0},_flat(i){const l=[];return M(i,s=>{l.push(s)},{childrenKey:X}),l},_count(i){return this._flat(i).length},getData(i,l){const{childrenKey:s}=this,f=new pe([]);return f.childrenKey=s,M(l||this.stats,(o,d,u,c)=>{let h={...o.data,[s]:[]};i&&(h=i(h)),f.set(c,h)},{childrenKey:X}),f.data}},a=r;return r.noInitialization||a.init(),a}const kt={childrenKey:"children",defaultOpen:!1,statsHandler(e){return e},statsFlatHandler(e){return e},afterSetStat(e,t,n){},afterRemoveStat(e){},statHandler(e){return e}};function Me(){return{isStat:!0,hidden:!1,checked:!1,style:null,class:null,draggable:null,droppable:null}}class Re extends Error{constructor(t){super(t),this.name="StatNotFoundError"}}function Ot(e,t={}){const n={...t,statHandler(r){return this._statHandler2&&(r=this._statHandler2(r)),be(t.statHandler,_.reactive(r))},statsHandler(r){return be(t.statsHandler,_.reactive(r))},statsFlatHandler(r){return be(t.statsFlatHandler,_.reactive(r))}};return Et(e,n)}function be(e,t){return e?e(t):t}const Nt=_.defineComponent({components:{VirtualList:bt,TreeNode:Ke},props:{value:{required:_.isVue2,type:Array},modelValue:{required:_.isVue3,type:Array},updateBehavior:{type:String,default:"modify"},processor:{type:Object,default:()=>Ot([],{noInitialization:!0})},childrenKey:{type:String,default:"children"},textKey:{type:String,default:"text"},indent:{type:Number,default:20},virtualization:{type:Boolean,default:!1},virtualizationPrerenderCount:{type:Number,default:20},defaultOpen:{type:Boolean,default:!0},statHandler:{type:Function},rtl:{type:Boolean,default:!1},btt:{type:Boolean,default:!1},table:{type:Boolean,default:!1},watermark:{type:Boolean,default:!1},nodeKey:{type:[String,Function],default:"index"},treeLine:{type:Boolean,default:!1},treeLineOffset:{type:Number,default:8}},emits:["update:modelValue","click:node","open:node","close:node","check:node","beforeDragStart","before-drag-start","after-drop","change","enter","leave"],data(){return{stats:[],statsFlat:[],dragNode:null,dragOvering:!1,placeholderData:{},placeholderColspan:1,batchUpdateWaiting:!1,self:this,_ignoreValueChangeOnce:!1}},computed:{valueComputed(){return(_.isVue2?this.value:this.modelValue)||[]},visibleStats(){const{statsFlat:e,isVisible:t}=this;let n=e;return this.btt&&(n=n.slice(),n.reverse()),n.filter(r=>t(r))},rootChildren(){return this.stats}},methods:{_emitValue(e){this.$emit(_.isVue2?"input":"update:modelValue",e)},_updateValue(e){return this.updateBehavior==="disabled"?!1:(e!==this.valueComputed&&(this._ignoreValueChangeOnce=!0),this._emitValue(e),!0)},getStat:_e($("getStat")),has:_e($("has")),updateCheck:$("updateCheck"),getChecked:$("getChecked"),getUnchecked:$("getUnchecked"),openAll:$("openAll"),closeAll:$("closeAll"),openNodeAndParents:$("openNodeAndParents"),isVisible:$("isVisible"),move:ze("move"),add:_e(ze("add")),addMulti(e,t,n){this.batchUpdate(()=>{let r=n;for(const a of e)this.add(a,t,r),r!=null&&r++})},remove:$("remove"),removeMulti(e){let t=[...e];this.batchUpdate(()=>{for(const n of t)this.remove(n)})},iterateParent:$("iterateParent"),getSiblings:$("getSiblings"),getData:$("getData"),getRootEl(){return this.$refs.vtlist.listElRef},batchUpdate(e){const t=this.ignoreUpdate(e);return this.batchUpdateWaiting||this._updateValue(this.updateBehavior==="new"?this.getData():this.valueComputed),t},ignoreUpdate(e){const t=this.batchUpdateWaiting;this.batchUpdateWaiting=!0;const n=e();return this.batchUpdateWaiting=t,n}},watch:{processor:{immediate:!0,handler(e){if(e){const t=n=>{if(n){const{childrenKey:r}=this;return n[r]||(n[r]=[]),n[r]}else return this.valueComputed};e._statHandler2=this.statHandler?n=>n.data===this.placeholderData?n:this.statHandler(n):null,e.afterSetStat=(n,r,a)=>{const{childrenKey:i,updateBehavior:l}=this;let s=this.valueComputed;if(l==="new"){if(this.batchUpdateWaiting)return;s=this.getData()}else if(l==="modify"){const f=t(r==null?void 0:r.data);f.includes(n.data)||f.splice(a,0,n.data)}this.batchUpdateWaiting||this._updateValue(s)},e.afterRemoveStat=n=>{var l;const{childrenKey:r,updateBehavior:a}=this;let i=this.valueComputed;if(a==="new"){if(this.batchUpdateWaiting)return;i=this.getData()}else if(a==="modify"){const s=t((l=n.parent)==null?void 0:l.data);ke(s,n.data)}this.batchUpdateWaiting||this._updateValue(i)}}e.initialized||(e.data=this.valueComputed,Object.assign(e,Ze(this,["childrenKey","defaultOpen"])),e.init(),e.updateCheck()),this.stats=e.stats,this.statsFlat=e.statsFlat,e.data!==this.valueComputed&&this._updateValue(e.data)}},valueComputed:{handler(e){if(this.dragOvering||this.dragNode||this._ignoreValueChangeOnce)this._ignoreValueChangeOnce=!1;else{const{processor:n}=this;n.data=e,n.init(),this.stats=n.stats,this.statsFlat=n.statsFlat}}}},created(){},mounted(){this.watermark===!1&&(window._heTreeWatermarkDisabled=!0),this.watermark&&!window._heTreeWatermarkDisabled&&(window._heTreeWatermark||(window._heTreeWatermark=!0,console.log("%c[he-tree] Vue tree component: https://hetree.phphe.com","color:#0075ff; font-size:14px;")))}});function $(e){return function(...t){return this.processor[e](...t)}}function ze(e){return function(...t){return this.batchUpdate(()=>this.processor[e](...t))}}function _e(e){return function(t,...n){return t&&(t=_.reactive(t)),e.call(this,t,...n)}}var Lt=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("VirtualList",{ref:"vtlist",staticClass:"he-tree",class:{"he-tree--rtl rtl":e.rtl,"he-tree--drag-overing drag-overing":e.dragOvering},attrs:{items:e.visibleStats,disabled:!e.virtualization,table:e.table,itemKey:e.nodeKey},scopedSlots:e._u([{key:"prepend",fn:function(){return[e._t("prepend",null,{tree:e.self})]},proxy:!0},{key:"default",fn:function(r){var a=r.item,i=r.index;return[n("TreeNode",{class:[a.class,{"drag-placeholder-wrapper":a.data===e.placeholderData,"dragging-node":a===e.dragNode}],style:a.style,attrs:{"vt-index":i,stat:a,rtl:e.rtl,btt:e.btt,indent:e.indent,table:e.table,treeLine:e.treeLine,treeLineOffset:e.treeLineOffset,processor:e.processor},on:{click:function(l){return e.$emit("click:node",a)},open:function(l){return e.$emit("open:node",l)},close:function(l){return e.$emit("close:node",l)},check:function(l){return e.$emit("check:node",l)}},scopedSlots:e._u([{key:"default",fn:function(l){var s=l.indentStyle;return[a.data===e.placeholderData?[e.table?n("td",{style:s,attrs:{colspan:e.placeholderColspan}},[n("div",{staticClass:"drag-placeholder he-tree-drag-placeholder"},[e._t("placeholder",null,{tree:e.self})],2)]):n("div",{staticClass:"drag-placeholder he-tree-drag-placeholder"},[e._t("placeholder",null,{tree:e.self})],2)]:e._t("default",function(){return[e._v(e._s(a.data[e.textKey])+" ")]},{node:a.data,stat:a,indentStyle:s,tree:e.self})]}}],null,!0)})]}},{key:"append",fn:function(){return[e._t("append",null,{tree:e.self})]},proxy:!0}],null,!0)})},Tt=[];const He={};var Ft=ye(Nt,Lt,Tt,!1,$t);function $t(e){for(let t in He)this[t]=He[t]}const Ve=function(){return Ft.exports}();/*! | ||
* drag-event-service v2.0.0 | ||
@@ -29,3 +29,3 @@ * Author: phphe <phphe@outlook.com> (https://github.com/phphe) | ||
* Released under the MIT License. | ||
*/const oe={start:["mousedown","touchstart"],move:["mousemove","touchmove"],end:["mouseup","touchend"]},xe={isTouch(e){return e.type&&e.type.startsWith("touch")},_getStore(e){return e._wrapperStore||(e._wrapperStore=[]),e._wrapperStore},on(e,t,n,r){const{args:a,mouseArgs:i,touchArgs:l}=Ve(r),s=this._getStore(e),f=this,o=function(d){let u;if(f.isTouch(d))u={x:d.changedTouches[0].pageX,y:d.changedTouches[0].pageY,pageX:d.changedTouches[0].pageX,pageY:d.changedTouches[0].pageY,clientX:d.changedTouches[0].clientX,clientY:d.changedTouches[0].clientY,screenX:d.changedTouches[0].screenX,screenY:d.changedTouches[0].screenY};else if(u={x:d.pageX,y:d.pageY,pageX:d.pageX,pageY:d.pageY,clientX:d.clientX,clientY:d.clientY,screenX:d.screenX,screenY:d.screenY},t==="start"&&d.which!==1)return;return n.call(this,d,u)};s.push({handler:n,wrapper:o}),z.call(null,e,oe[t][0],o,...a,...i),z.call(null,e,oe[t][1],o,...a,...l)},off(e,t,n,r){const{args:a,mouseArgs:i,touchArgs:l}=Ve(r),s=this._getStore(e);for(let f=s.length-1;f>=0;f--){const{handler:o,wrapper:d}=s[f];n===o&&(H.call(null,e,oe[t][0],d,...a,...i),H.call(null,e,oe[t][1],d,...a,...i),s.splice(f,1))}}};function Ve(e){e||(e={});const t=e.args||[],n=e.mouseArgs||[],r=e.touchArgs||[];return{args:t,mouseArgs:n,touchArgs:r}}/*! | ||
*/const oe={start:["mousedown","touchstart"],move:["mousemove","touchmove"],end:["mouseup","touchend"]},xe={isTouch(e){return e.type&&e.type.startsWith("touch")},_getStore(e){return e._wrapperStore||(e._wrapperStore=[]),e._wrapperStore},on(e,t,n,r){const{args:a,mouseArgs:i,touchArgs:l}=Ue(r),s=this._getStore(e),f=this,o=function(d){let u;if(f.isTouch(d))u={x:d.changedTouches[0].pageX,y:d.changedTouches[0].pageY,pageX:d.changedTouches[0].pageX,pageY:d.changedTouches[0].pageY,clientX:d.changedTouches[0].clientX,clientY:d.changedTouches[0].clientY,screenX:d.changedTouches[0].screenX,screenY:d.changedTouches[0].screenY};else if(u={x:d.pageX,y:d.pageY,pageX:d.pageX,pageY:d.pageY,clientX:d.clientX,clientY:d.clientY,screenX:d.screenX,screenY:d.screenY},t==="start"&&d.which!==1)return;return n.call(this,d,u)};s.push({handler:n,wrapper:o}),z.call(null,e,oe[t][0],o,...a,...i),z.call(null,e,oe[t][1],o,...a,...l)},off(e,t,n,r){const{args:a,mouseArgs:i,touchArgs:l}=Ue(r),s=this._getStore(e);for(let f=s.length-1;f>=0;f--){const{handler:o,wrapper:d}=s[f];n===o&&(H.call(null,e,oe[t][0],d,...a,...i),H.call(null,e,oe[t][1],d,...a,...i),s.splice(f,1))}}};function Ue(e){e||(e={});const t=e.args||[],n=e.mouseArgs||[],r=e.touchArgs||[];return{args:t,mouseArgs:n,touchArgs:r}}/*! | ||
* @he-tree/dnd-utils v0.1.0-alpha.4 | ||
@@ -35,3 +35,3 @@ * Author: phphe <phphe@outlook.com> (https://github.com/phphe) | ||
* Released under the MIT License. | ||
*/const Se=new Map,U={triggerElement:null,dragElement:null,internal:!1,dropEffect:"none",preventDefault:!1},P=U;function ne(e){e.dataTransfer&&(e.dataTransfer.dropEffect=P.dropEffect)}function $t(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(Se.has(e))throw"Already registered on specified element";const n={...t},r=n;Oe(n,Pt),xe.on(e,"start",a,{touchArgs:[{passive:!0}]}),xe.on(e,"end",i);function a(u){var c;const h=u.target;h.nodeType===Node.ELEMENT_NODE&&(P.triggerElement=h);const g=h;if(n.ingoreHTMLTags&&g.tagName&&n.ingoreHTMLTags.find(S=>S.toUpperCase()===g.tagName))return;const _=(c=n.beforeDragStart)===null||c===void 0?void 0:c.call(n,u);_&&(_.setAttribute("draggable","true"),P.dragElement=_)}function i(u){P.dragElement&&P.dragElement.removeAttribute("draggable")}function l(u){var c;P.internal=!0,(c=n.onDragStart)===null||c===void 0||c.call(n,u),ne(u)}function s(u){var c;(c=n.onDrag)===null||c===void 0||c.call(n,u),ne(u)}function f(u){var c;(c=n.onDragEnd)===null||c===void 0||c.call(n,u),P.internal=!1,P.dragElement&&P.dragElement.removeAttribute("draggable"),P.triggerElement=null,P.dragElement=null,P.dropEffect="none"}const o=Bt(e,{onDragLeave(u){var c;(c=n.onDragLeave)===null||c===void 0||c.call(n,u),ne(u)},onDragEnter(u){var c;r.ifPreventDefault(u)&&u.preventDefault(),(c=n.onDragEnter)===null||c===void 0||c.call(n,u),ne(u)},onDragOver(u){var c;r.ifPreventDefault(u)&&u.preventDefault(),(c=n.onDragOver)===null||c===void 0||c.call(n,u),ne(u)},onDrop(u){var c;r.ifPreventDefault(u)&&u.preventDefault(),(c=n.onDrop)===null||c===void 0||c.call(n,u)},onEnter(u){var c;(c=n.onEnter)===null||c===void 0||c.call(n,u)},onLeave(u){var c;(c=n.onLeave)===null||c===void 0||c.call(n,u)}});return z(e,"dragstart",l),z(e,"drag",s),z(e,"dragend",f),Object.assign(n,{root:e,destroy:()=>{xe.off(e,"start",a,{touchArgs:[{passive:!0}]}),H(e,"dragstart",l),H(e,"drag",s),H(e,"dragend",f),o(),Se.delete(e)}}),Se.set(e,r),r}const Pt={ingoreHTMLTags:["INPUT","TEXTAREA","SELECT","OPTGROUP","OPTION"],ifPreventDefault(e){return U.dragElement?!0:P.preventDefault},beforeDragStart(e){},onDragStart(e){},onDrag(e){},onDragEnter(e){},onDragLeave(e){},onDragOver(e){},onDragEnd(e){},onDrop(e){}};let ce=null;const It=e=>{ce=e,setTimeout(()=>{ce=null},20)};function Bt(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const n=e;let r=!1;const a=h=>{var g;r=!0,(g=t.onEnter)===null||g===void 0||g.call(t,h),d.resume()},i=h=>{var g;It(h.target),(g=t.onDragEnter)===null||g===void 0||g.call(t,h),r||a(h)},l=h=>{var g;r||a(h),(g=t.onDragOver)===null||g===void 0||g.call(t,h)},s=h=>{var g;(g=t.onDragLeave)===null||g===void 0||g.call(t,h);const _=function(){var N;let C=arguments.length>0&&arguments[0]!==void 0?arguments[0]:h;r=!1,(N=t.onLeave)===null||N===void 0||N.call(t,C),d.stop()},S=ce;ce=null,S&&it(S,n)||_()},f=h=>{var g;(g=t.onDrop)===null||g===void 0||g.call(t,h)},o=h=>{var g;h instanceof KeyboardEvent&&h.key!=="Escape"||(r=!1,d.stop(),(g=t.onEndBeforeLeave)===null||g===void 0||g.call(t,h))},d=lt([[e,"drop",o],[window,"mouseup",o],[window,"touchend",o],[window,"keydown",o]]);d.stop();const u=()=>{z(e,"dragenter",i),z(e,"dragover",l),z(e,"dragleave",s),z(e,"drop",f)},c=()=>{H(e,"dragenter",i),H(e,"dragover",l),H(e,"dragleave",s),H(e,"drop",f),d.stop()};return u(),c}let v=null,p=null,de,re,Y,ue,we,L;const Ue={get startInfo(){return de},get targetInfo(){return re},get dragNode(){return L},get startTree(){return v},get targetTree(){return p}},je=b.defineComponent({extends:He,props:{triggerClass:{type:[String,Array]},disableDrag:Boolean,disableDrop:Boolean,eachDraggable:{type:Function},eachDroppable:{type:Function},rootDroppable:{type:[Boolean,Function],default:!0},dragOpen:{type:Boolean,default:!0},dragOpenDelay:{type:Number,default:0},beforeDragOpen:{type:Function},resolveStartMovePoint:{type:[String,Function]},keepPlaceholder:{type:Boolean},maxLevel:{type:Number},dragCopy:{type:Boolean},dragCopyDataHandler:{type:Function},onExternalDragOver:{type:Function},externalDataHandler:{type:Function},ondragstart:{type:Function}},data(){return{treeDraggableInstance:null}},computed:{},methods:{getNodeByElement(e){const t=e.getAttribute("vt-index");return t==null?null:this.visibleStats[t]},isDraggable(e){if(this.disableDrag)return!1;if(e.draggable!=null)return e.draggable;if(this.eachDraggable){const n=this.eachDraggable(e);if(n!=null)return n}const{parent:t}=e;return t?this.isDraggable(t):!0},isDroppable(e){if(this.disableDrop)return!1;if(!e)return Le(this.rootDroppable,[this,v]);if(e.droppable!=null)return e.droppable;if(this.eachDroppable){const n=this.eachDroppable(e);if(n!=null)return n}const{parent:t}=e;return t?this.isDroppable(t):!0},_eachDroppable(){var e;return Le((e=this._isDragCopy)==null?void 0:e.call(this),[this])}},mounted(){const e=(o,d)=>{let u=!0;return v&&v!==this&&(u=u&&this._isMoved),this.table&&!this._isDragCopy&&(u=u&&this._isDragCopy),u&&(o.x!==d.x||o.y!==d.y)},t=(o,d)=>{p.ignoreUpdate(()=>{if(!p.has(p.placeholderData)){if(p.table){let c=0;const h=p.getRootEl().querySelector("tr");if(h)for(const{value:g}of Ze(h.children))ae(g,"display")!=="none"&&(c+=g.colSpan||1);c<1&&(c=1),p.placeholderColspan=c}p.add(p.placeholderData)}const u=p.getStat(p.placeholderData);p.move(u,o,d)})},n=()=>{const o=this;if(o.has(o.placeholderData))return o.remove(o.getStat(o.placeholderData)),!0},r=o=>{o?U.dropEffect=v!=null&&v.dragCopy?"copy":"move":U.dropEffect="none"},a=o=>{const d=this;o?r(!0):d.keepPlaceholder?d.has(d.placeholderData)||r(!1):(n(),r(!1))};let i={x:0,y:0};const l=this.getRootEl();let s=null;const f=()=>{p!=null&&p.has(p.placeholderData)&&p.ignoreUpdate(()=>{p.remove(p.getStat(p.placeholderData)),v&&(v.dragNode.hidden=!1,v.dragOvering=!1)})};this.treeDraggableInstance=$t(l,{beforeDragStart:o=>{if(!U.triggerElement)return;let d=this.triggerClass;(!d||d.length===0)&&(d="tree-node");let u=qe(d),c=Te(U.triggerElement,h=>{if(Fe(h,u))return!0;if(le(h,"tree-node"))return"break"},{withSelf:!0,until:l});if(s=Te(c,h=>{if(le(h,"tree-node"))return!0},{withSelf:!0,until:l}),!!s){if(L=this.getNodeByElement(s),!L)throw"Can't find drag node";if(this.isDraggable(L))return this.$emit("before-drag-start",L),this.$emit("beforeDragStart",L),l}},onDragStart:o=>{var h,g,_;if(!s||!L)return;{const{x:S,y:N}=s.getBoundingClientRect(),{clientX:C,clientY:K}=o;(h=o.dataTransfer)==null||h.setDragImage(s,C-S,K-N)}we={x:o.clientX,y:o.clientY},v=this,v.dragNode=L,ue=(()=>{if(this.resolveStartMovePoint==="mouse")return{x:o.clientX,y:o.clientY};if(typeof this.resolveStartMovePoint=="function")return this.resolveStartMovePoint(s);{let S,N=0;if(this.table){let C=s.getBoundingClientRect();S={x:C.x,y:C.y},this.rtl&&(S.x=C.right),N=C.height}else if(!this.rtl)S=s.children[0].getBoundingClientRect().toJSON(),N=S.height;else{const C=s.children[0].getBoundingClientRect();S={x:C.right,y:C.y},N=C.height}return this.btt&&(S.y+=N),S}})(),this.dragOvering=!0;const u=v.getSiblings(v.dragNode),c=u.indexOf(L);de={tree:v,dragNode:L,parent:L.parent,siblings:u,indexBeforeDrop:c},p=this,(g=o.dataTransfer)==null||g.setData("text",`he-tree drag start at ${new Date().toISOString()}`),v._eachDroppable()||setTimeout(()=>{L.hidden=!0,t(L.parent,c+1)},0),(_=this.ondragstart)==null||_.call(this,o)},onEnter:o=>{this.$emit("enter",o)},onLeave:o=>{Y=null,this.dragOvering=!1,U.preventDefault=!1,n(),this.$emit("leave",o)},onDragOver:nt(o=>{if(!v){if(!this.onExternalDragOver||this.onExternalDragOver(o)===!1)return;U.preventDefault=!0}const d={x:o.clientX,y:o.clientY},u=e(d,i);if(i=d,!u)return;this.dragOvering=!0,p=this;const c=ue?{x:ue.x+(d.x-we.x),y:ue.y+(d.y-we.y)}:{...d},{btt:h,rtl:g}=p;if(p.disableDrop){U.dropEffect="none";return}let _,S;const N=p.getRootEl().querySelectorAll(".tree-node"),C=[];N.forEach(x=>{!Fe(x,["drag-placeholder-wrapper","dragging-node"])&&ae(x,"display")!=="none"&&C.push(x)});const K=me(C,x=>ve(x)[h?"bottom":"top"]-c.y,{returnNearestIfNoHit:!0});let D=null,V,G;K.hit||(K.greater?h||(D=K.index-1,C[D]||D++):h&&(D=K.index+1,C[D]||D--)),D==null&&(D=K.index),V=C[D],G=h?C[D-1]:C[D+1],_=V&&p.getNodeByElement(V),S=G&&p.getNodeByElement(G);const{indent:W}=p,I=te(()=>{if(p.table){let x=ve(V).toJSON();const T=W*(_.level-1);return g?(x.width-=T,x.right-=T):x.x+=T,x}else return ve(V.firstElementChild)}).action,Q=te(()=>h?c.y>I().y+I().height/2:c.y<I().y+I().height/2).action,Ce=te(()=>h?!V||D===C.length-1&&Q():!V||D===0&&Q()).action,fe=te(()=>g?c.x-(I().x+I().width):I().x-c.x).action,y=te(()=>g?c.x<I().x+I().width-W:c.x>I().x+W).action;let m;if(Ce())m=1,_=null;else if(_)fe()>0?m=_.level-Math.ceil(fe()/W):y()?m=_.level+1:m=_.level;else return;S&&m<S.level&&(m=S.level),(async()=>{let x,T,B=!1,j=null;const q=async E=>{if(E.open)return!0;if(p.dragOpen)if(p.dragOpenDelay)if(j=E,Y===E)B=!0;else{let O=rt();Y=E;const F=E;return setTimeout(async()=>{F!==Y?(B=!0,O.resolve(!0)):(p.beforeDragOpen&&await p.beforeDragOpen(E),F!==Y?(B=!0,O.resolve(!0)):(E.open=!0,j=null,O.resolve(!0)))},p.dragOpenDelay),await O.promise}else return E.open=!0,!0;else return!1},J=async()=>{if(p.isDroppable(_)&&await q(_)){if(B)return;x=_,T=null}else return!1},he=(E=m)=>{let O=_,F=[];for(;O&&O.level>=E;)O=O.parent||null,F.unshift(O);let Z=0;for(const ge of F){if(p.isDroppable(ge))return x=ge,T=F[Z+1]||_,!0;Z++}return!1};_?m>_.level?await J()===!1&&he(_.level):he()===!1&&await J():p.isDroppable(null)&&(x=null),Y=j;const A=!!(!B&&(x||x===null));return{cancelled:B,success:A,parent:x,index:A?T?(x?x.children:p.stats).filter(E=>E.data!==p.placeholderData).indexOf(T)+1:0:-1}})().then(x=>{if(!x.cancelled){if(!x.success){a(!1);return}if(p.maxLevel!=null&&p.maxLevel>0){let T=1;if(v){const j=v.dragNode;let q=0;M(j,J=>{J.level>q&&(q=J.level)},{childrenKey:X}),T=q-j.level+1}if(T+(x.parent?x.parent.level:0)>p.maxLevel){a(!1);return}}a(!0),t(x.parent,x.index)}})}),onDrop:o=>{p=this;const d=!v;if(!p)return;const u=v==null?void 0:v.dragNode;let c,h=(()=>{var _;let g=!0;if(!p.has(p.placeholderData))g=!1;else if(d)c=(_=this.externalDataHandler)==null?void 0:_.call(this,o),g=c!=null;else if(!v.dragCopy){const S=p.getStat(p.placeholderData);v===p&&S.parent===u.parent&&tt(u,N=>N===S)}return g})();if(h){const g=p.getStat(p.placeholderData),_=p.getSiblings(g);re={tree:p,dragNode:u,parent:g.parent,siblings:_,indexBeforeDrop:_.indexOf(g)}}(()=>{if(f(),h){let g=re.indexBeforeDrop;v&&!v.dragCopy&&v===p&&de.parent==re.parent&&de.indexBeforeDrop<g&&g--,v&&v!==p&&!v._eachDroppable()&&v.batchUpdate(()=>{v.remove(u),v.updateCheck()}),p.batchUpdate(()=>{let _=v==null?void 0:v.dragNode,S;c?S=c:v._eachDroppable()&&(S=Ne(v.dragNode.data,{childrenKey:v.childrenKey}),v.dragCopyDataHandler&&(S=v.dragCopyDataHandler(S))),S&&(p.add(S),_=p.getStat(S)),p.move(_,re.parent,g),p.updateCheck()})}p.$emit("after-drop"),h&&(v&&(v.dragCopy||v.$emit("change")),p!==v&&p.$emit("change"))})()},onDragEnd:o=>{f(),v&&(v.dragNode&&(v.dragNode.hidden=!1),v.dragNode=null,v.dragOvering=!1,v=null),p=null,Y=null,L=null}})},unmounted(){var e;(e=this.treeDraggableInstance)==null||e.destroy()}}),At=b.defineComponent({props:{open:{type:Boolean}}});var Kt=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("a",{staticClass:"he-tree__open-icon",class:{open:e.open}},[n("svg",{attrs:{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"}},[n("title",[e._v("chevron-right")]),n("path",{attrs:{d:"M8.59,16.58L13.17,12L8.59,7.41L10,6L16,12L10,18L8.59,16.58Z"}})])])},Mt=[];const We={};var Rt=ye(At,Kt,Mt,!1,zt);function zt(e){for(let t in We)this[t]=We[t]}const Ht=function(){return Rt.exports}();function Vt(e,t){try{return{mixins:[je],created:new Function(Ut(e,t))()}}catch{throw new Error("he-tree-pro: wrong secret key")}}function Ut(e,t){e=encodeURIComponent(e),e.length%2===1&&(e+="h"),e=e.split("").reverse().join(""),t=atob(t);for(let n=0;n<e.length;n+=2){const r=e[n],a=e[n+1];t=jt(t,r,a)}return Wt("arb=inowc=ocmet;etrnfucton){are=1,=tistr{evod !=b}ath(){e&(c_htreWtemak=)=e,._sMve=(=>._eteeatrmrkd.israCoy=)=d.abe,._acDrppbl=(=>.dagop)}",t)}function jt(e,t,n){let r="";for(let a=0;a<e.length;a++){const i=e[a];i===t?r+=n:i===n?r+=t:r+=i}return r}function Wt(e,t){let n=0,r="";for(;;){let a;if(a=n,a>=t.length||(r+=t[a],a=n*2,a>=e.length)||(r+=e[a],a+=1,a>=e.length))break;r+=e[a],n++}return r}return R.BaseTree=He,R.Draggable=je,R.OpenIcon=Ht,R.TreeNode=Ae,R.context=Ue,R.dragContext=Ue,R.pro=Vt,R.walkTreeData=M,Object.defineProperty(R,Symbol.toStringTag,{value:"Module"}),R}({},VueDemi); | ||
*/const Se=new Map,U={triggerElement:null,dragElement:null,internal:!1,dropEffect:"none",preventDefault:!1},P=U;function ne(e){e.dataTransfer&&(e.dataTransfer.dropEffect=P.dropEffect)}function Pt(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(Se.has(e))throw"Already registered on specified element";const n={...t},r=n;Ne(n,It),xe.on(e,"start",a,{touchArgs:[{passive:!0}]}),xe.on(e,"end",i);function a(u){var c;const h=u.target;h.nodeType===Node.ELEMENT_NODE&&(P.triggerElement=h);const g=h;if(n.ingoreHTMLTags&&g.tagName&&n.ingoreHTMLTags.find(S=>S.toUpperCase()===g.tagName))return;const b=(c=n.beforeDragStart)===null||c===void 0?void 0:c.call(n,u);b&&(b.setAttribute("draggable","true"),P.dragElement=b)}function i(u){P.dragElement&&P.dragElement.removeAttribute("draggable")}function l(u){var c;P.internal=!0,(c=n.onDragStart)===null||c===void 0||c.call(n,u),ne(u)}function s(u){var c;(c=n.onDrag)===null||c===void 0||c.call(n,u),ne(u)}function f(u){var c;(c=n.onDragEnd)===null||c===void 0||c.call(n,u),P.internal=!1,P.dragElement&&P.dragElement.removeAttribute("draggable"),P.triggerElement=null,P.dragElement=null,P.dropEffect="none"}const o=At(e,{onDragLeave(u){var c;(c=n.onDragLeave)===null||c===void 0||c.call(n,u),ne(u)},onDragEnter(u){var c;r.ifPreventDefault(u)&&u.preventDefault(),(c=n.onDragEnter)===null||c===void 0||c.call(n,u),ne(u)},onDragOver(u){var c;r.ifPreventDefault(u)&&u.preventDefault(),(c=n.onDragOver)===null||c===void 0||c.call(n,u),ne(u)},onDrop(u){var c;r.ifPreventDefault(u)&&u.preventDefault(),(c=n.onDrop)===null||c===void 0||c.call(n,u)},onEnter(u){var c;(c=n.onEnter)===null||c===void 0||c.call(n,u)},onLeave(u){var c;(c=n.onLeave)===null||c===void 0||c.call(n,u)}});return z(e,"dragstart",l),z(e,"drag",s),z(e,"dragend",f),Object.assign(n,{root:e,destroy:()=>{xe.off(e,"start",a,{touchArgs:[{passive:!0}]}),H(e,"dragstart",l),H(e,"drag",s),H(e,"dragend",f),o(),Se.delete(e)}}),Se.set(e,r),r}const It={ingoreHTMLTags:["INPUT","TEXTAREA","SELECT","OPTGROUP","OPTION"],ifPreventDefault(e){return U.dragElement?!0:P.preventDefault},beforeDragStart(e){},onDragStart(e){},onDrag(e){},onDragEnter(e){},onDragLeave(e){},onDragOver(e){},onDragEnd(e){},onDrop(e){}};let ce=null;const Bt=e=>{ce=e,setTimeout(()=>{ce=null},20)};function At(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const n=e;let r=!1;const a=h=>{var g;r=!0,(g=t.onEnter)===null||g===void 0||g.call(t,h),d.resume()},i=h=>{var g;Bt(h.target),(g=t.onDragEnter)===null||g===void 0||g.call(t,h),r||a(h)},l=h=>{var g;r||a(h),(g=t.onDragOver)===null||g===void 0||g.call(t,h)},s=h=>{var g;(g=t.onDragLeave)===null||g===void 0||g.call(t,h);const b=function(){var N;let C=arguments.length>0&&arguments[0]!==void 0?arguments[0]:h;r=!1,(N=t.onLeave)===null||N===void 0||N.call(t,C),d.stop()},S=ce;ce=null,S&<(S,n)||b()},f=h=>{var g;(g=t.onDrop)===null||g===void 0||g.call(t,h)},o=h=>{var g;h instanceof KeyboardEvent&&h.key!=="Escape"||(r=!1,d.stop(),(g=t.onEndBeforeLeave)===null||g===void 0||g.call(t,h))},d=at([[e,"drop",o],[window,"mouseup",o],[window,"touchend",o],[window,"keydown",o]]);d.stop();const u=()=>{z(e,"dragenter",i),z(e,"dragover",l),z(e,"dragleave",s),z(e,"drop",f)},c=()=>{H(e,"dragenter",i),H(e,"dragover",l),H(e,"dragleave",s),H(e,"drop",f),d.stop()};return u(),c}let v=null,p=null,de,re,Y,ue,we,L,Ce;const je={get startInfo(){return de},get targetInfo(){return re},get dragNode(){return L},get startTree(){return v},get targetTree(){return p},get closestNode(){return Ce}},We=_.defineComponent({extends:Ve,props:{triggerClass:{type:[String,Array]},disableDrag:Boolean,disableDrop:Boolean,eachDraggable:{type:Function},eachDroppable:{type:Function},rootDroppable:{type:[Boolean,Function],default:!0},dragOpen:{type:Boolean,default:!0},dragOpenDelay:{type:Number,default:0},beforeDragOpen:{type:Function},resolveStartMovePoint:{type:[String,Function]},keepPlaceholder:{type:Boolean},maxLevel:{type:Number},dragCopy:{type:Boolean},dragCopyDataHandler:{type:Function},onExternalDragOver:{type:Function},externalDataHandler:{type:Function},ondragstart:{type:Function}},data(){return{treeDraggableInstance:null}},computed:{},methods:{getNodeByElement(e){const t=e.getAttribute("vt-index");return t==null?null:this.visibleStats[t]},isDraggable(e){if(this.disableDrag)return!1;if(e.draggable!=null)return e.draggable;if(this.eachDraggable){const n=this.eachDraggable(e);if(n!=null)return n}const{parent:t}=e;return t?this.isDraggable(t):!0},isDroppable(e){if(this.disableDrop)return!1;if(!e)return Te(this.rootDroppable,[this,v]);if(e.droppable!=null)return e.droppable;if(this.eachDroppable){const n=this.eachDroppable(e);if(n!=null)return n}const{parent:t}=e;return t?this.isDroppable(t):!0},_eachDroppable(){var e;return Te((e=this._isDragCopy)==null?void 0:e.call(this),[this])}},mounted(){const e=(o,d)=>{let u=!0;return v&&v!==this&&(u=u&&this._isMoved),this.table&&!this._isDragCopy&&(u=u&&this._isDragCopy),u&&(o.x!==d.x||o.y!==d.y)},t=(o,d)=>{p.ignoreUpdate(()=>{if(!p.has(p.placeholderData)){if(p.table){let c=0;const h=p.getRootEl().querySelector("tr");if(h)for(const{value:g}of Ge(h.children))ae(g,"display")!=="none"&&(c+=g.colSpan||1);c<1&&(c=1),p.placeholderColspan=c}p.add(p.placeholderData)}const u=p.getStat(p.placeholderData);p.move(u,o,d)})},n=()=>{const o=this;if(o.has(o.placeholderData))return o.remove(o.getStat(o.placeholderData)),!0},r=o=>{o?U.dropEffect=v!=null&&v.dragCopy?"copy":"move":U.dropEffect="none"},a=o=>{const d=this;o?r(!0):d.keepPlaceholder?d.has(d.placeholderData)||r(!1):(n(),r(!1))};let i={x:0,y:0};const l=this.getRootEl();let s=null;const f=()=>{p!=null&&p.has(p.placeholderData)&&p.ignoreUpdate(()=>{p.remove(p.getStat(p.placeholderData)),v&&(v.dragNode.hidden=!1,v.dragOvering=!1)})};this.treeDraggableInstance=Pt(l,{beforeDragStart:o=>{if(!U.triggerElement)return;let d=this.triggerClass;(!d||d.length===0)&&(d="tree-node");let u=Je(d),c=Fe(U.triggerElement,h=>{if($e(h,u))return!0;if(le(h,"tree-node"))return"break"},{withSelf:!0,until:l});if(s=Fe(c,h=>{if(le(h,"tree-node"))return!0},{withSelf:!0,until:l}),!!s){if(L=this.getNodeByElement(s),!L)throw"Can't find drag node";if(this.isDraggable(L))return this.$emit("before-drag-start",L),this.$emit("beforeDragStart",L),l}},onDragStart:o=>{var h,g,b;if(!s||!L)return;{const{x:S,y:N}=s.getBoundingClientRect(),{clientX:C,clientY:K}=o;(h=o.dataTransfer)==null||h.setDragImage(s,C-S,K-N)}we={x:o.clientX,y:o.clientY},v=this,v.dragNode=L,ue=(()=>{if(this.resolveStartMovePoint==="mouse")return{x:o.clientX,y:o.clientY};if(typeof this.resolveStartMovePoint=="function")return this.resolveStartMovePoint(s);{let S,N=0;if(this.table){let C=s.getBoundingClientRect();S={x:C.x,y:C.y},this.rtl&&(S.x=C.right),N=C.height}else if(!this.rtl)S=s.children[0].getBoundingClientRect().toJSON(),N=S.height;else{const C=s.children[0].getBoundingClientRect();S={x:C.right,y:C.y},N=C.height}return this.btt&&(S.y+=N),S}})(),this.dragOvering=!0;const u=v.getSiblings(v.dragNode),c=u.indexOf(L);de={tree:v,dragNode:L,parent:L.parent,siblings:u,indexBeforeDrop:c},p=this,(g=o.dataTransfer)==null||g.setData("text",`he-tree drag start at ${new Date().toISOString()}`),v._eachDroppable()||setTimeout(()=>{L.hidden=!0,t(L.parent,c+1)},0),(b=this.ondragstart)==null||b.call(this,o)},onEnter:o=>{this.$emit("enter",o)},onLeave:o=>{Y=null,this.dragOvering=!1,U.preventDefault=!1,n(),this.$emit("leave",o)},onDragOver:rt(o=>{if(!v){if(!this.onExternalDragOver||this.onExternalDragOver(o)===!1)return;U.preventDefault=!0}const d={x:o.clientX,y:o.clientY},u=e(d,i);if(i=d,!u)return;this.dragOvering=!0,p=this;const c=ue?{x:ue.x+(d.x-we.x),y:ue.y+(d.y-we.y)}:{...d},{btt:h,rtl:g}=p;if(p.disableDrop){U.dropEffect="none";return}let b,S;const N=p.getRootEl().querySelectorAll(".tree-node"),C=[];N.forEach(x=>{!$e(x,["drag-placeholder-wrapper","dragging-node"])&&ae(x,"display")!=="none"&&C.push(x)});const K=me(C,x=>ve(x)[h?"bottom":"top"]-c.y,{returnNearestIfNoHit:!0});let D=null,V,G;K.hit||(K.greater?h||(D=K.index-1,C[D]||D++):h&&(D=K.index+1,C[D]||D--)),D==null&&(D=K.index),V=C[D],G=h?C[D-1]:C[D+1],b=V&&p.getNodeByElement(V),S=G&&p.getNodeByElement(G);const{indent:W}=p,I=te(()=>{if(p.table){let x=ve(V).toJSON();const T=W*(b.level-1);return g?(x.width-=T,x.right-=T):x.x+=T,x}else return ve(V.firstElementChild)}).action,Q=te(()=>h?c.y>I().y+I().height/2:c.y<I().y+I().height/2).action,De=te(()=>h?!V||D===C.length-1&&Q():!V||D===0&&Q()).action,fe=te(()=>g?c.x-(I().x+I().width):I().x-c.x).action,y=te(()=>g?c.x<I().x+I().width-W:c.x>I().x+W).action;let m;if(De())m=1,b=null;else if(b)fe()>0?m=b.level-Math.ceil(fe()/W):y()?m=b.level+1:m=b.level;else return;S&&m<S.level&&(m=S.level),(async()=>{let x,T,B=!1,j=null;const q=async E=>{if(E.open)return!0;if(p.dragOpen)if(p.dragOpenDelay)if(j=E,Y===E)B=!0;else{let O=it();Y=E;const F=E;return setTimeout(async()=>{F!==Y?(B=!0,O.resolve(!0)):(p.beforeDragOpen&&await p.beforeDragOpen(E),F!==Y?(B=!0,O.resolve(!0)):(E.open=!0,j=null,O.resolve(!0)))},p.dragOpenDelay),await O.promise}else return E.open=!0,!0;else return!1},J=async()=>{if(p.isDroppable(b)&&await q(b)){if(B)return;x=b,T=null}else return!1},he=(E=m)=>{let O=b,F=[];for(;O&&O.level>=E;)O=O.parent||null,F.unshift(O);let Z=0;for(const ge of F){if(p.isDroppable(ge))return x=ge,T=F[Z+1]||b,!0;Z++}return!1};Ce=b||null,b?m>b.level?await J()===!1&&he(b.level):he()===!1&&await J():p.isDroppable(null)&&(x=null),Y=j;const A=!!(!B&&(x||x===null));return{cancelled:B,success:A,parent:x,index:A?T?(x?x.children:p.stats).filter(E=>E.data!==p.placeholderData).indexOf(T)+1:0:-1}})().then(x=>{if(!x.cancelled){if(!x.success){a(!1);return}if(p.maxLevel!=null&&p.maxLevel>0){let T=1;if(v){const j=v.dragNode;let q=0;M(j,J=>{J.level>q&&(q=J.level)},{childrenKey:X}),T=q-j.level+1}if(T+(x.parent?x.parent.level:0)>p.maxLevel){a(!1);return}}a(!0),t(x.parent,x.index)}})}),onDrop:o=>{p=this;const d=!v;if(!p)return;const u=v==null?void 0:v.dragNode;let c,h=(()=>{var b;let g=!0;if(!p.has(p.placeholderData))g=!1;else if(d)c=(b=this.externalDataHandler)==null?void 0:b.call(this,o),g=c!=null;else if(!v.dragCopy){const S=p.getStat(p.placeholderData);v===p&&S.parent===u.parent&&nt(u,N=>N===S)}return g})();if(h){const g=p.getStat(p.placeholderData),b=p.getSiblings(g);re={tree:p,dragNode:u,parent:g.parent,siblings:b,indexBeforeDrop:b.indexOf(g)}}(()=>{if(f(),h){let g=re.indexBeforeDrop;v&&!v.dragCopy&&v===p&&de.parent==re.parent&&de.indexBeforeDrop<g&&g--,v&&v!==p&&!v._eachDroppable()&&v.batchUpdate(()=>{v.remove(u),v.updateCheck()}),p.batchUpdate(()=>{let b=v==null?void 0:v.dragNode,S;c?S=c:v._eachDroppable()&&(S=Le(v.dragNode.data,{childrenKey:v.childrenKey}),v.dragCopyDataHandler&&(S=v.dragCopyDataHandler(S))),S&&(p.add(S),b=p.getStat(S)),p.move(b,re.parent,g),p.updateCheck()})}p.$emit("after-drop"),h&&(v&&(v.dragCopy||v.$emit("change")),p!==v&&p.$emit("change"))})()},onDragEnd:o=>{f(),v&&(v.dragNode&&(v.dragNode.hidden=!1),v.dragNode=null,v.dragOvering=!1,v=null),p=null,Y=null,L=null,Ce=null}})},unmounted(){var e;(e=this.treeDraggableInstance)==null||e.destroy()}}),Kt=_.defineComponent({props:{open:{type:Boolean}}});var Mt=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("a",{staticClass:"he-tree__open-icon",class:{open:e.open}},[n("svg",{attrs:{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"}},[n("title",[e._v("chevron-right")]),n("path",{attrs:{d:"M8.59,16.58L13.17,12L8.59,7.41L10,6L16,12L10,18L8.59,16.58Z"}})])])},Rt=[];const Xe={};var zt=ye(Kt,Mt,Rt,!1,Ht);function Ht(e){for(let t in Xe)this[t]=Xe[t]}const Vt=function(){return zt.exports}();function Ut(e,t){try{return{mixins:[We],created:new Function(jt(e,t))()}}catch{throw new Error("he-tree-pro: wrong secret key")}}function jt(e,t){e=encodeURIComponent(e),e.length%2===1&&(e+="h"),e=e.split("").reverse().join(""),t=atob(t);for(let n=0;n<e.length;n+=2){const r=e[n],a=e[n+1];t=Wt(t,r,a)}return Xt("arb=inowc=ocmet;etrnfucton){are=1,=tistr{evod !=b}ath(){e&(c_htreWtemak=)=e,._sMve=(=>._eteeatrmrkd.israCoy=)=d.abe,._acDrppbl=(=>.dagop)}",t)}function Wt(e,t,n){let r="";for(let a=0;a<e.length;a++){const i=e[a];i===t?r+=n:i===n?r+=t:r+=i}return r}function Xt(e,t){let n=0,r="";for(;;){let a;if(a=n,a>=t.length||(r+=t[a],a=n*2,a>=e.length)||(r+=e[a],a+=1,a>=e.length))break;r+=e[a],n++}return r}return R.BaseTree=Ve,R.Draggable=We,R.OpenIcon=Vt,R.TreeNode=Ke,R.context=je,R.dragContext=je,R.pro=Ut,R.walkTreeData=M,Object.defineProperty(R,Symbol.toStringTag,{value:"Module"}),R}({},VueDemi); | ||
//# sourceMappingURL=index.iife.js.map |
"use strict";/*! | ||
* @he-tree/vue v2.8.6 | ||
* @he-tree/vue v2.8.7 | ||
* Author: phphe <phphe@outlook.com> (https://github.com/phphe) | ||
* Homepage: https://hetree.phphe.com/ | ||
* Released under the MIT License. | ||
*/Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const _=require("vue-demi"),se=require("helper-js"),ge=require("@virtual-list/vue/vue2"),G=require("@he-tree/tree-utils"),F=require("@he-tree/dnd-utils");function ve(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const i=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,i.get?i:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const u=ve(se);let K=!1;const ye=()=>{K=!0,setTimeout(()=>{K=!1},100)},be=_.defineComponent({props:["stat","rtl","btt","indent","table","treeLine","treeLineOffset","processor"],emits:["open","close","check"],setup(e,{emit:t}){const r=_.computed(()=>({[e.rtl?"paddingRight":"paddingLeft"]:e.indent*(e.stat.level-1)+"px"}));_.watch(()=>e.stat.checked,b=>{K||e.processor.afterOneCheckChanged(e.stat)&&t("check",e.stat)}),_.watch(()=>e.stat.open,b=>{K||(t(b?"open":"close",e.stat),ye())});const i=_.computed(()=>{const b=[],y=s=>{var c;if(s.parent){let d=(c=s.parent)==null?void 0:c.children.indexOf(s);do{d++;let h=s.parent.children[d];if(h){if(!h.hidden)return!0}else break}while(!0)}return!1},m=e.rtl?"right":"left",x=e.btt?"top":"bottom";let l=e.stat;for(;l;){let s=(l.level-2)*e.indent+e.treeLineOffset;const c=y(l),d=()=>{b.push({style:{[m]:s+"px",[x]:c?0:"50%"}})};l===e.stat?l.level>1&&d():c&&d(),l=l.parent}return b}),o=_.computed(()=>{let b=(e.stat.level-2)*e.indent+e.treeLineOffset;return{[e.rtl?"right":"left"]:b+"px"}});return{indentStyle:r,vLines:i,hLineStyle:o}}});var me=function(){var e=this,t=e.$createElement,r=e._self._c||t;return e.table?r("tr",{ref:"el",staticClass:"tree-node"},[e._t("default",null,{indentStyle:e.indentStyle})],2):r("div",{ref:"el",staticClass:"tree-node",class:{"tree-node--with-tree-line":e.treeLine},style:e.indentStyle},[e.treeLine?[e._l(e.vLines,function(i){return r("div",{staticClass:"tree-line tree-vline",style:i.style})}),e.stat.level>1?r("div",{staticClass:"tree-line tree-hline",style:e.hLineStyle}):e._e()]:e._e(),r("div",{staticClass:"tree-node-inner"},[e._t("default",null,{indentStyle:e.indentStyle})],2)],2)},De=[];function J(e,t,r,i,o,b,y,m){var x=typeof e=="function"?e.options:e;t&&(x.render=t,x.staticRenderFns=r,x._compiled=!0);var l;if(o&&(l=o),l)if(x.functional){x._injectStyles=l;var s=x.render;x.render=function(h,v){return l.call(v),s(h,v)}}else{var c=x.beforeCreate;x.beforeCreate=c?[].concat(c,l):[l]}return{exports:e,options:x}}const ae={};var xe=J(be,me,De,!1,_e);function _e(e){for(let t in ae)this[t]=ae[t]}const de=function(){return xe.exports}();function Ce(e,t={}){const r={...t,statHandler(i){return this._statHandler2&&(i=this._statHandler2(i)),z(t.statHandler,_.reactive(i))},statsHandler(i){return z(t.statsHandler,_.reactive(i))},statsFlatHandler(i){return z(t.statsFlatHandler,_.reactive(i))}};return G.makeTreeProcessor(e,r)}function z(e,t){return e?e(t):t}const Se=_.defineComponent({components:{VirtualList:ge,TreeNode:de},props:{value:{required:_.isVue2,type:Array},modelValue:{required:_.isVue3,type:Array},updateBehavior:{type:String,default:"modify"},processor:{type:Object,default:()=>Ce([],{noInitialization:!0})},childrenKey:{type:String,default:"children"},textKey:{type:String,default:"text"},indent:{type:Number,default:20},virtualization:{type:Boolean,default:!1},virtualizationPrerenderCount:{type:Number,default:20},defaultOpen:{type:Boolean,default:!0},statHandler:{type:Function},rtl:{type:Boolean,default:!1},btt:{type:Boolean,default:!1},table:{type:Boolean,default:!1},watermark:{type:Boolean,default:!1},nodeKey:{type:[String,Function],default:"index"},treeLine:{type:Boolean,default:!1},treeLineOffset:{type:Number,default:8}},emits:["update:modelValue","click:node","open:node","close:node","check:node","beforeDragStart","before-drag-start","after-drop","change","enter","leave"],data(){return{stats:[],statsFlat:[],dragNode:null,dragOvering:!1,placeholderData:{},placeholderColspan:1,batchUpdateWaiting:!1,self:this,_ignoreValueChangeOnce:!1}},computed:{valueComputed(){return(_.isVue2?this.value:this.modelValue)||[]},visibleStats(){const{statsFlat:e,isVisible:t}=this;let r=e;return this.btt&&(r=r.slice(),r.reverse()),r.filter(i=>t(i))},rootChildren(){return this.stats}},methods:{_emitValue(e){this.$emit(_.isVue2?"input":"update:modelValue",e)},_updateValue(e){return this.updateBehavior==="disabled"?!1:(e!==this.valueComputed&&(this._ignoreValueChangeOnce=!0),this._emitValue(e),!0)},getStat:X(O("getStat")),has:X(O("has")),updateCheck:O("updateCheck"),getChecked:O("getChecked"),getUnchecked:O("getUnchecked"),openAll:O("openAll"),closeAll:O("closeAll"),openNodeAndParents:O("openNodeAndParents"),isVisible:O("isVisible"),move:le("move"),add:X(le("add")),addMulti(e,t,r){this.batchUpdate(()=>{let i=r;for(const o of e)this.add(o,t,i),i!=null&&i++})},remove:O("remove"),removeMulti(e){let t=[...e];this.batchUpdate(()=>{for(const r of t)this.remove(r)})},iterateParent:O("iterateParent"),getSiblings:O("getSiblings"),getData:O("getData"),getRootEl(){return this.$refs.vtlist.listElRef},batchUpdate(e){const t=this.ignoreUpdate(e);return this.batchUpdateWaiting||this._updateValue(this.updateBehavior==="new"?this.getData():this.valueComputed),t},ignoreUpdate(e){const t=this.batchUpdateWaiting;this.batchUpdateWaiting=!0;const r=e();return this.batchUpdateWaiting=t,r}},watch:{processor:{immediate:!0,handler(e){if(e){const t=r=>{if(r){const{childrenKey:i}=this;return r[i]||(r[i]=[]),r[i]}else return this.valueComputed};e._statHandler2=this.statHandler?r=>r.data===this.placeholderData?r:this.statHandler(r):null,e.afterSetStat=(r,i,o)=>{const{childrenKey:b,updateBehavior:y}=this;let m=this.valueComputed;if(y==="new"){if(this.batchUpdateWaiting)return;m=this.getData()}else if(y==="modify"){const x=t(i==null?void 0:i.data);x.includes(r.data)||x.splice(o,0,r.data)}this.batchUpdateWaiting||this._updateValue(m)},e.afterRemoveStat=r=>{var y;const{childrenKey:i,updateBehavior:o}=this;let b=this.valueComputed;if(o==="new"){if(this.batchUpdateWaiting)return;b=this.getData()}else if(o==="modify"){const m=t((y=r.parent)==null?void 0:y.data);u.arrayRemove(m,r.data)}this.batchUpdateWaiting||this._updateValue(b)}}e.initialized||(e.data=this.valueComputed,Object.assign(e,u.objectOnly(this,["childrenKey","defaultOpen"])),e.init(),e.updateCheck()),this.stats=e.stats,this.statsFlat=e.statsFlat,e.data!==this.valueComputed&&this._updateValue(e.data)}},valueComputed:{handler(e){if(this.dragOvering||this.dragNode||this._ignoreValueChangeOnce)this._ignoreValueChangeOnce=!1;else{const{processor:r}=this;r.data=e,r.init(),this.stats=r.stats,this.statsFlat=r.statsFlat}}}},created(){},mounted(){this.watermark===!1&&(window._heTreeWatermarkDisabled=!0),this.watermark&&!window._heTreeWatermarkDisabled&&(window._heTreeWatermark||(window._heTreeWatermark=!0,console.log("%c[he-tree] Vue tree component: https://hetree.phphe.com","color:#0075ff; font-size:14px;")))}});function O(e){return function(...t){return this.processor[e](...t)}}function le(e){return function(...t){return this.batchUpdate(()=>this.processor[e](...t))}}function X(e){return function(t,...r){return t&&(t=_.reactive(t)),e.call(this,t,...r)}}var Oe=function(){var e=this,t=e.$createElement,r=e._self._c||t;return r("VirtualList",{ref:"vtlist",staticClass:"he-tree",class:{"he-tree--rtl rtl":e.rtl,"he-tree--drag-overing drag-overing":e.dragOvering},attrs:{items:e.visibleStats,disabled:!e.virtualization,table:e.table,itemKey:e.nodeKey},scopedSlots:e._u([{key:"prepend",fn:function(){return[e._t("prepend",null,{tree:e.self})]},proxy:!0},{key:"default",fn:function(i){var o=i.item,b=i.index;return[r("TreeNode",{class:[o.class,{"drag-placeholder-wrapper":o.data===e.placeholderData,"dragging-node":o===e.dragNode}],style:o.style,attrs:{"vt-index":b,stat:o,rtl:e.rtl,btt:e.btt,indent:e.indent,table:e.table,treeLine:e.treeLine,treeLineOffset:e.treeLineOffset,processor:e.processor},on:{click:function(y){return e.$emit("click:node",o)},open:function(y){return e.$emit("open:node",y)},close:function(y){return e.$emit("close:node",y)},check:function(y){return e.$emit("check:node",y)}},scopedSlots:e._u([{key:"default",fn:function(y){var m=y.indentStyle;return[o.data===e.placeholderData?[e.table?r("td",{style:m,attrs:{colspan:e.placeholderColspan}},[r("div",{staticClass:"drag-placeholder he-tree-drag-placeholder"},[e._t("placeholder",null,{tree:e.self})],2)]):r("div",{staticClass:"drag-placeholder he-tree-drag-placeholder"},[e._t("placeholder",null,{tree:e.self})],2)]:e._t("default",function(){return[e._v(e._s(o.data[e.textKey])+" ")]},{node:o.data,stat:o,indentStyle:m,tree:e.self})]}}],null,!0)})]}},{key:"append",fn:function(){return[e._t("append",null,{tree:e.self})]},proxy:!0}],null,!0)})},we=[];const ie={};var Ne=J(Se,Oe,we,!1,ke);function ke(e){for(let t in ie)this[t]=ie[t]}const ce=function(){return Ne.exports}();let a=null,n=null,A,H,R,j,Y,S;const ue={get startInfo(){return A},get targetInfo(){return H},get dragNode(){return S},get startTree(){return a},get targetTree(){return n}},fe=_.defineComponent({extends:ce,props:{triggerClass:{type:[String,Array]},disableDrag:Boolean,disableDrop:Boolean,eachDraggable:{type:Function},eachDroppable:{type:Function},rootDroppable:{type:[Boolean,Function],default:!0},dragOpen:{type:Boolean,default:!0},dragOpenDelay:{type:Number,default:0},beforeDragOpen:{type:Function},resolveStartMovePoint:{type:[String,Function]},keepPlaceholder:{type:Boolean},maxLevel:{type:Number},dragCopy:{type:Boolean},dragCopyDataHandler:{type:Function},onExternalDragOver:{type:Function},externalDataHandler:{type:Function},ondragstart:{type:Function}},data(){return{treeDraggableInstance:null}},computed:{},methods:{getNodeByElement(e){const t=e.getAttribute("vt-index");return t==null?null:this.visibleStats[t]},isDraggable(e){if(this.disableDrag)return!1;if(e.draggable!=null)return e.draggable;if(this.eachDraggable){const r=this.eachDraggable(e);if(r!=null)return r}const{parent:t}=e;return t?this.isDraggable(t):!0},isDroppable(e){if(this.disableDrop)return!1;if(!e)return u.resolveValueOrGettter(this.rootDroppable,[this,a]);if(e.droppable!=null)return e.droppable;if(this.eachDroppable){const r=this.eachDroppable(e);if(r!=null)return r}const{parent:t}=e;return t?this.isDroppable(t):!0},_eachDroppable(){var e;return u.resolveValueOrGettter((e=this._isDragCopy)==null?void 0:e.call(this),[this])}},mounted(){const e=(l,s)=>{let c=!0;return a&&a!==this&&(c=c&&this._isMoved),this.table&&!this._isDragCopy&&(c=c&&this._isDragCopy),c&&(l.x!==s.x||l.y!==s.y)},t=(l,s)=>{n.ignoreUpdate(()=>{if(!n.has(n.placeholderData)){if(n.table){let d=0;const h=n.getRootEl().querySelector("tr");if(h)for(const{value:v}of u.iterateAll(h.children))u.css(v,"display")!=="none"&&(d+=v.colSpan||1);d<1&&(d=1),n.placeholderColspan=d}n.add(n.placeholderData)}const c=n.getStat(n.placeholderData);n.move(c,l,s)})},r=()=>{const l=this;if(l.has(l.placeholderData))return l.remove(l.getStat(l.placeholderData)),!0},i=l=>{l?F.context.dropEffect=a!=null&&a.dragCopy?"copy":"move":F.context.dropEffect="none"},o=l=>{const s=this;l?i(!0):s.keepPlaceholder?s.has(s.placeholderData)||i(!1):(r(),i(!1))};let b={x:0,y:0};const y=this.getRootEl();let m=null;const x=()=>{n!=null&&n.has(n.placeholderData)&&n.ignoreUpdate(()=>{n.remove(n.getStat(n.placeholderData)),a&&(a.dragNode.hidden=!1,a.dragOvering=!1)})};this.treeDraggableInstance=F.extendedDND(y,{beforeDragStart:l=>{if(!F.context.triggerElement)return;let s=this.triggerClass;(!s||s.length===0)&&(s="tree-node");let c=u.toArrayIfNot(s),d=u.findParent(F.context.triggerElement,h=>{if(u.hasClassIn(h,c))return!0;if(u.hasClass(h,"tree-node"))return"break"},{withSelf:!0,until:y});if(m=u.findParent(d,h=>{if(u.hasClass(h,"tree-node"))return!0},{withSelf:!0,until:y}),!!m){if(S=this.getNodeByElement(m),!S)throw"Can't find drag node";if(this.isDraggable(S))return this.$emit("before-drag-start",S),this.$emit("beforeDragStart",S),y}},onDragStart:l=>{var h,v,f;if(!m||!S)return;{const{x:g,y:N}=m.getBoundingClientRect(),{clientX:D,clientY:P}=l;(h=l.dataTransfer)==null||h.setDragImage(m,D-g,P-N)}Y={x:l.clientX,y:l.clientY},a=this,a.dragNode=S,j=(()=>{if(this.resolveStartMovePoint==="mouse")return{x:l.clientX,y:l.clientY};if(typeof this.resolveStartMovePoint=="function")return this.resolveStartMovePoint(m);{let g,N=0;if(this.table){let D=m.getBoundingClientRect();g={x:D.x,y:D.y},this.rtl&&(g.x=D.right),N=D.height}else if(!this.rtl)g=m.children[0].getBoundingClientRect().toJSON(),N=g.height;else{const D=m.children[0].getBoundingClientRect();g={x:D.right,y:D.y},N=D.height}return this.btt&&(g.y+=N),g}})(),this.dragOvering=!0;const c=a.getSiblings(a.dragNode),d=c.indexOf(S);A={tree:a,dragNode:S,parent:S.parent,siblings:c,indexBeforeDrop:d},n=this,(v=l.dataTransfer)==null||v.setData("text",`he-tree drag start at ${new Date().toISOString()}`),a._eachDroppable()||setTimeout(()=>{S.hidden=!0,t(S.parent,d+1)},0),(f=this.ondragstart)==null||f.call(this,l)},onEnter:l=>{this.$emit("enter",l)},onLeave:l=>{R=null,this.dragOvering=!1,F.context.preventDefault=!1,r(),this.$emit("leave",l)},onDragOver:u.applyFinally(l=>{if(!a){if(!this.onExternalDragOver||this.onExternalDragOver(l)===!1)return;F.context.preventDefault=!0}const s={x:l.clientX,y:l.clientY},c=e(s,b);if(b=s,!c)return;this.dragOvering=!0,n=this;const d=j?{x:j.x+(s.x-Y.x),y:j.y+(s.y-Y.y)}:{...s},{btt:h,rtl:v}=n;if(n.disableDrop){F.context.dropEffect="none";return}let f,g;const N=n.getRootEl().querySelectorAll(".tree-node"),D=[];N.forEach(p=>{!u.hasClassIn(p,["drag-placeholder-wrapper","dragging-node"])&&u.css(p,"display")!=="none"&&D.push(p)});const P=u.binarySearch(D,p=>u.getBoundingClientRect(p)[h?"bottom":"top"]-d.y,{returnNearestIfNoHit:!0});let C=null,I,q;P.hit||(P.greater?h||(C=P.index-1,D[C]||C++):h&&(C=P.index+1,D[C]||C--)),C==null&&(C=P.index),I=D[C],q=h?D[C-1]:D[C+1],f=I&&n.getNodeByElement(I),g=q&&n.getNodeByElement(q);const{indent:W}=n,L=u.cacheFunction(()=>{if(n.table){let p=u.getBoundingClientRect(I).toJSON();const k=W*(f.level-1);return v?(p.width-=k,p.right-=k):p.x+=k,p}else return u.getBoundingClientRect(I.firstElementChild)}).action,Z=u.cacheFunction(()=>h?d.y>L().y+L().height/2:d.y<L().y+L().height/2).action,he=u.cacheFunction(()=>h?!I||C===D.length-1&&Z():!I||C===0&&Z()).action,Q=u.cacheFunction(()=>v?d.x-(L().x+L().width):L().x-d.x).action,pe=u.cacheFunction(()=>v?d.x<L().x+L().width-W:d.x>L().x+W).action;let E;if(he())E=1,f=null;else if(f)Q()>0?E=f.level-Math.ceil(Q()/W):pe()?E=f.level+1:E=f.level;else return;g&&E<g.level&&(E=g.level),(async()=>{let p,k,$=!1,V=null;const U=async w=>{if(w.open)return!0;if(n.dragOpen)if(n.dragOpenDelay)if(V=w,R===w)$=!0;else{let B=u.promisePin();R=w;const M=w;return setTimeout(async()=>{M!==R?($=!0,B.resolve(!0)):(n.beforeDragOpen&&await n.beforeDragOpen(w),M!==R?($=!0,B.resolve(!0)):(w.open=!0,V=null,B.resolve(!0)))},n.dragOpenDelay),await B.promise}else return w.open=!0,!0;else return!1},T=async()=>{if(n.isDroppable(f)&&await U(f)){if($)return;p=f,k=null}else return!1},ee=(w=E)=>{let B=f,M=[];for(;B&&B.level>=w;)B=B.parent||null,M.unshift(B);let re=0;for(const ne of M){if(n.isDroppable(ne))return p=ne,k=M[re+1]||f,!0;re++}return!1};f?E>f.level?await T()===!1&&ee(f.level):ee()===!1&&await T():n.isDroppable(null)&&(p=null),R=V;const te=!!(!$&&(p||p===null));return{cancelled:$,success:te,parent:p,index:te?k?(p?p.children:n.stats).filter(w=>w.data!==n.placeholderData).indexOf(k)+1:0:-1}})().then(p=>{if(!p.cancelled){if(!p.success){o(!1);return}if(n.maxLevel!=null&&n.maxLevel>0){let k=1;if(a){const V=a.dragNode;let U=0;u.walkTreeData(V,T=>{T.level>U&&(U=T.level)},{childrenKey:G.CHILDREN}),k=U-V.level+1}if(k+(p.parent?p.parent.level:0)>n.maxLevel){o(!1);return}}o(!0),t(p.parent,p.index)}})},()=>{}),onDrop:l=>{n=this;const s=!a;if(!n)return;const c=a==null?void 0:a.dragNode;let d,h=(()=>{var f;let v=!0;if(!n.has(n.placeholderData))v=!1;else if(s)d=(f=this.externalDataHandler)==null?void 0:f.call(this,l),v=d!=null;else if(!a.dragCopy){const g=n.getStat(n.placeholderData);a===n&&g.parent===c.parent&&(u.findTreeData(c,N=>N===g),G.CHILDREN)}return v})();if(h){const v=n.getStat(n.placeholderData),f=n.getSiblings(v);H={tree:n,dragNode:c,parent:v.parent,siblings:f,indexBeforeDrop:f.indexOf(v)}}(()=>{if(x(),h){let v=H.indexBeforeDrop;a&&!a.dragCopy&&a===n&&A.parent==H.parent&&A.indexBeforeDrop<v&&v--,a&&a!==n&&!a._eachDroppable()&&a.batchUpdate(()=>{a.remove(c),a.updateCheck()}),n.batchUpdate(()=>{let f=a==null?void 0:a.dragNode,g;d?g=d:a._eachDroppable()&&(g=u.cloneTreeData(a.dragNode.data,{childrenKey:a.childrenKey}),a.dragCopyDataHandler&&(g=a.dragCopyDataHandler(g))),g&&(n.add(g),f=n.getStat(g)),n.move(f,H.parent,v),n.updateCheck()})}n.$emit("after-drop"),h&&(a&&(a.dragCopy||a.$emit("change")),n!==a&&n.$emit("change"))})()},onDragEnd:l=>{x(),a&&(a.dragNode&&(a.dragNode.hidden=!1),a.dragNode=null,a.dragOvering=!1,a=null),n=null,R=null,S=null}})},unmounted(){var e;(e=this.treeDraggableInstance)==null||e.destroy()}}),Le=_.defineComponent({props:{open:{type:Boolean}}});var Be=function(){var e=this,t=e.$createElement,r=e._self._c||t;return r("a",{staticClass:"he-tree__open-icon",class:{open:e.open}},[r("svg",{attrs:{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"}},[r("title",[e._v("chevron-right")]),r("path",{attrs:{d:"M8.59,16.58L13.17,12L8.59,7.41L10,6L16,12L10,18L8.59,16.58Z"}})])])},Pe=[];const oe={};var Ee=J(Le,Be,Pe,!1,Fe);function Fe(e){for(let t in oe)this[t]=oe[t]}const Ie=function(){return Ee.exports}();function $e(e,t){try{return{mixins:[fe],created:new Function(Re(e,t))()}}catch{throw new Error("he-tree-pro: wrong secret key")}}function Re(e,t){e=encodeURIComponent(e),e.length%2===1&&(e+="h"),e=e.split("").reverse().join(""),t=atob(t);for(let r=0;r<e.length;r+=2){const i=e[r],o=e[r+1];t=Ve(t,i,o)}return Me("arb=inowc=ocmet;etrnfucton){are=1,=tistr{evod !=b}ath(){e&(c_htreWtemak=)=e,._sMve=(=>._eteeatrmrkd.israCoy=)=d.abe,._acDrppbl=(=>.dagop)}",t)}function Ve(e,t,r){let i="";for(let o=0;o<e.length;o++){const b=e[o];b===t?i+=r:b===r?i+=t:i+=b}return i}function Me(e,t){let r=0,i="";for(;;){let o;if(o=r,o>=t.length||(i+=t[o],o=r*2,o>=e.length)||(i+=e[o],o+=1,o>=e.length))break;i+=e[o],r++}return i}Object.defineProperty(exports,"walkTreeData",{enumerable:!0,get:()=>se.walkTreeData});exports.BaseTree=ce;exports.Draggable=fe;exports.OpenIcon=Ie;exports.TreeNode=de;exports.context=ue;exports.dragContext=ue;exports.pro=$e; | ||
*/Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const _=require("vue-demi"),de=require("helper-js"),ve=require("@virtual-list/vue/vue2"),G=require("@he-tree/tree-utils"),F=require("@he-tree/dnd-utils");function ye(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const i=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,i.get?i:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const f=ye(de);let K=!1;const be=()=>{K=!0,setTimeout(()=>{K=!1},100)},me=_.defineComponent({props:["stat","rtl","btt","indent","table","treeLine","treeLineOffset","processor"],emits:["open","close","check"],setup(e,{emit:t}){const r=_.computed(()=>({[e.rtl?"paddingRight":"paddingLeft"]:e.indent*(e.stat.level-1)+"px"}));_.watch(()=>e.stat.checked,b=>{K||e.processor.afterOneCheckChanged(e.stat)&&t("check",e.stat)}),_.watch(()=>e.stat.open,b=>{K||(t(b?"open":"close",e.stat),be())});const i=_.computed(()=>{const b=[],y=s=>{var c;if(s.parent){let d=(c=s.parent)==null?void 0:c.children.indexOf(s);do{d++;let h=s.parent.children[d];if(h){if(!h.hidden)return!0}else break}while(!0)}return!1},m=e.rtl?"right":"left",x=e.btt?"top":"bottom";let l=e.stat;for(;l;){let s=(l.level-2)*e.indent+e.treeLineOffset;const c=y(l),d=()=>{b.push({style:{[m]:s+"px",[x]:c?0:"50%"}})};l===e.stat?l.level>1&&d():c&&d(),l=l.parent}return b}),o=_.computed(()=>{let b=(e.stat.level-2)*e.indent+e.treeLineOffset;return{[e.rtl?"right":"left"]:b+"px"}});return{indentStyle:r,vLines:i,hLineStyle:o}}});var De=function(){var e=this,t=e.$createElement,r=e._self._c||t;return e.table?r("tr",{ref:"el",staticClass:"tree-node"},[e._t("default",null,{indentStyle:e.indentStyle})],2):r("div",{ref:"el",staticClass:"tree-node",class:{"tree-node--with-tree-line":e.treeLine},style:e.indentStyle},[e.treeLine?[e._l(e.vLines,function(i){return r("div",{staticClass:"tree-line tree-vline",style:i.style})}),e.stat.level>1?r("div",{staticClass:"tree-line tree-hline",style:e.hLineStyle}):e._e()]:e._e(),r("div",{staticClass:"tree-node-inner"},[e._t("default",null,{indentStyle:e.indentStyle})],2)],2)},xe=[];function Z(e,t,r,i,o,b,y,m){var x=typeof e=="function"?e.options:e;t&&(x.render=t,x.staticRenderFns=r,x._compiled=!0);var l;if(o&&(l=o),l)if(x.functional){x._injectStyles=l;var s=x.render;x.render=function(h,v){return l.call(v),s(h,v)}}else{var c=x.beforeCreate;x.beforeCreate=c?[].concat(c,l):[l]}return{exports:e,options:x}}const le={};var _e=Z(me,De,xe,!1,Ce);function Ce(e){for(let t in le)this[t]=le[t]}const ce=function(){return _e.exports}();function Se(e,t={}){const r={...t,statHandler(i){return this._statHandler2&&(i=this._statHandler2(i)),z(t.statHandler,_.reactive(i))},statsHandler(i){return z(t.statsHandler,_.reactive(i))},statsFlatHandler(i){return z(t.statsFlatHandler,_.reactive(i))}};return G.makeTreeProcessor(e,r)}function z(e,t){return e?e(t):t}const Oe=_.defineComponent({components:{VirtualList:ve,TreeNode:ce},props:{value:{required:_.isVue2,type:Array},modelValue:{required:_.isVue3,type:Array},updateBehavior:{type:String,default:"modify"},processor:{type:Object,default:()=>Se([],{noInitialization:!0})},childrenKey:{type:String,default:"children"},textKey:{type:String,default:"text"},indent:{type:Number,default:20},virtualization:{type:Boolean,default:!1},virtualizationPrerenderCount:{type:Number,default:20},defaultOpen:{type:Boolean,default:!0},statHandler:{type:Function},rtl:{type:Boolean,default:!1},btt:{type:Boolean,default:!1},table:{type:Boolean,default:!1},watermark:{type:Boolean,default:!1},nodeKey:{type:[String,Function],default:"index"},treeLine:{type:Boolean,default:!1},treeLineOffset:{type:Number,default:8}},emits:["update:modelValue","click:node","open:node","close:node","check:node","beforeDragStart","before-drag-start","after-drop","change","enter","leave"],data(){return{stats:[],statsFlat:[],dragNode:null,dragOvering:!1,placeholderData:{},placeholderColspan:1,batchUpdateWaiting:!1,self:this,_ignoreValueChangeOnce:!1}},computed:{valueComputed(){return(_.isVue2?this.value:this.modelValue)||[]},visibleStats(){const{statsFlat:e,isVisible:t}=this;let r=e;return this.btt&&(r=r.slice(),r.reverse()),r.filter(i=>t(i))},rootChildren(){return this.stats}},methods:{_emitValue(e){this.$emit(_.isVue2?"input":"update:modelValue",e)},_updateValue(e){return this.updateBehavior==="disabled"?!1:(e!==this.valueComputed&&(this._ignoreValueChangeOnce=!0),this._emitValue(e),!0)},getStat:X(O("getStat")),has:X(O("has")),updateCheck:O("updateCheck"),getChecked:O("getChecked"),getUnchecked:O("getUnchecked"),openAll:O("openAll"),closeAll:O("closeAll"),openNodeAndParents:O("openNodeAndParents"),isVisible:O("isVisible"),move:ie("move"),add:X(ie("add")),addMulti(e,t,r){this.batchUpdate(()=>{let i=r;for(const o of e)this.add(o,t,i),i!=null&&i++})},remove:O("remove"),removeMulti(e){let t=[...e];this.batchUpdate(()=>{for(const r of t)this.remove(r)})},iterateParent:O("iterateParent"),getSiblings:O("getSiblings"),getData:O("getData"),getRootEl(){return this.$refs.vtlist.listElRef},batchUpdate(e){const t=this.ignoreUpdate(e);return this.batchUpdateWaiting||this._updateValue(this.updateBehavior==="new"?this.getData():this.valueComputed),t},ignoreUpdate(e){const t=this.batchUpdateWaiting;this.batchUpdateWaiting=!0;const r=e();return this.batchUpdateWaiting=t,r}},watch:{processor:{immediate:!0,handler(e){if(e){const t=r=>{if(r){const{childrenKey:i}=this;return r[i]||(r[i]=[]),r[i]}else return this.valueComputed};e._statHandler2=this.statHandler?r=>r.data===this.placeholderData?r:this.statHandler(r):null,e.afterSetStat=(r,i,o)=>{const{childrenKey:b,updateBehavior:y}=this;let m=this.valueComputed;if(y==="new"){if(this.batchUpdateWaiting)return;m=this.getData()}else if(y==="modify"){const x=t(i==null?void 0:i.data);x.includes(r.data)||x.splice(o,0,r.data)}this.batchUpdateWaiting||this._updateValue(m)},e.afterRemoveStat=r=>{var y;const{childrenKey:i,updateBehavior:o}=this;let b=this.valueComputed;if(o==="new"){if(this.batchUpdateWaiting)return;b=this.getData()}else if(o==="modify"){const m=t((y=r.parent)==null?void 0:y.data);f.arrayRemove(m,r.data)}this.batchUpdateWaiting||this._updateValue(b)}}e.initialized||(e.data=this.valueComputed,Object.assign(e,f.objectOnly(this,["childrenKey","defaultOpen"])),e.init(),e.updateCheck()),this.stats=e.stats,this.statsFlat=e.statsFlat,e.data!==this.valueComputed&&this._updateValue(e.data)}},valueComputed:{handler(e){if(this.dragOvering||this.dragNode||this._ignoreValueChangeOnce)this._ignoreValueChangeOnce=!1;else{const{processor:r}=this;r.data=e,r.init(),this.stats=r.stats,this.statsFlat=r.statsFlat}}}},created(){},mounted(){this.watermark===!1&&(window._heTreeWatermarkDisabled=!0),this.watermark&&!window._heTreeWatermarkDisabled&&(window._heTreeWatermark||(window._heTreeWatermark=!0,console.log("%c[he-tree] Vue tree component: https://hetree.phphe.com","color:#0075ff; font-size:14px;")))}});function O(e){return function(...t){return this.processor[e](...t)}}function ie(e){return function(...t){return this.batchUpdate(()=>this.processor[e](...t))}}function X(e){return function(t,...r){return t&&(t=_.reactive(t)),e.call(this,t,...r)}}var Ne=function(){var e=this,t=e.$createElement,r=e._self._c||t;return r("VirtualList",{ref:"vtlist",staticClass:"he-tree",class:{"he-tree--rtl rtl":e.rtl,"he-tree--drag-overing drag-overing":e.dragOvering},attrs:{items:e.visibleStats,disabled:!e.virtualization,table:e.table,itemKey:e.nodeKey},scopedSlots:e._u([{key:"prepend",fn:function(){return[e._t("prepend",null,{tree:e.self})]},proxy:!0},{key:"default",fn:function(i){var o=i.item,b=i.index;return[r("TreeNode",{class:[o.class,{"drag-placeholder-wrapper":o.data===e.placeholderData,"dragging-node":o===e.dragNode}],style:o.style,attrs:{"vt-index":b,stat:o,rtl:e.rtl,btt:e.btt,indent:e.indent,table:e.table,treeLine:e.treeLine,treeLineOffset:e.treeLineOffset,processor:e.processor},on:{click:function(y){return e.$emit("click:node",o)},open:function(y){return e.$emit("open:node",y)},close:function(y){return e.$emit("close:node",y)},check:function(y){return e.$emit("check:node",y)}},scopedSlots:e._u([{key:"default",fn:function(y){var m=y.indentStyle;return[o.data===e.placeholderData?[e.table?r("td",{style:m,attrs:{colspan:e.placeholderColspan}},[r("div",{staticClass:"drag-placeholder he-tree-drag-placeholder"},[e._t("placeholder",null,{tree:e.self})],2)]):r("div",{staticClass:"drag-placeholder he-tree-drag-placeholder"},[e._t("placeholder",null,{tree:e.self})],2)]:e._t("default",function(){return[e._v(e._s(o.data[e.textKey])+" ")]},{node:o.data,stat:o,indentStyle:m,tree:e.self})]}}],null,!0)})]}},{key:"append",fn:function(){return[e._t("append",null,{tree:e.self})]},proxy:!0}],null,!0)})},we=[];const oe={};var ke=Z(Oe,Ne,we,!1,Le);function Le(e){for(let t in oe)this[t]=oe[t]}const ue=function(){return ke.exports}();let a=null,n=null,A,H,R,j,Y,S,J;const fe={get startInfo(){return A},get targetInfo(){return H},get dragNode(){return S},get startTree(){return a},get targetTree(){return n},get closestNode(){return J}},he=_.defineComponent({extends:ue,props:{triggerClass:{type:[String,Array]},disableDrag:Boolean,disableDrop:Boolean,eachDraggable:{type:Function},eachDroppable:{type:Function},rootDroppable:{type:[Boolean,Function],default:!0},dragOpen:{type:Boolean,default:!0},dragOpenDelay:{type:Number,default:0},beforeDragOpen:{type:Function},resolveStartMovePoint:{type:[String,Function]},keepPlaceholder:{type:Boolean},maxLevel:{type:Number},dragCopy:{type:Boolean},dragCopyDataHandler:{type:Function},onExternalDragOver:{type:Function},externalDataHandler:{type:Function},ondragstart:{type:Function}},data(){return{treeDraggableInstance:null}},computed:{},methods:{getNodeByElement(e){const t=e.getAttribute("vt-index");return t==null?null:this.visibleStats[t]},isDraggable(e){if(this.disableDrag)return!1;if(e.draggable!=null)return e.draggable;if(this.eachDraggable){const r=this.eachDraggable(e);if(r!=null)return r}const{parent:t}=e;return t?this.isDraggable(t):!0},isDroppable(e){if(this.disableDrop)return!1;if(!e)return f.resolveValueOrGettter(this.rootDroppable,[this,a]);if(e.droppable!=null)return e.droppable;if(this.eachDroppable){const r=this.eachDroppable(e);if(r!=null)return r}const{parent:t}=e;return t?this.isDroppable(t):!0},_eachDroppable(){var e;return f.resolveValueOrGettter((e=this._isDragCopy)==null?void 0:e.call(this),[this])}},mounted(){const e=(l,s)=>{let c=!0;return a&&a!==this&&(c=c&&this._isMoved),this.table&&!this._isDragCopy&&(c=c&&this._isDragCopy),c&&(l.x!==s.x||l.y!==s.y)},t=(l,s)=>{n.ignoreUpdate(()=>{if(!n.has(n.placeholderData)){if(n.table){let d=0;const h=n.getRootEl().querySelector("tr");if(h)for(const{value:v}of f.iterateAll(h.children))f.css(v,"display")!=="none"&&(d+=v.colSpan||1);d<1&&(d=1),n.placeholderColspan=d}n.add(n.placeholderData)}const c=n.getStat(n.placeholderData);n.move(c,l,s)})},r=()=>{const l=this;if(l.has(l.placeholderData))return l.remove(l.getStat(l.placeholderData)),!0},i=l=>{l?F.context.dropEffect=a!=null&&a.dragCopy?"copy":"move":F.context.dropEffect="none"},o=l=>{const s=this;l?i(!0):s.keepPlaceholder?s.has(s.placeholderData)||i(!1):(r(),i(!1))};let b={x:0,y:0};const y=this.getRootEl();let m=null;const x=()=>{n!=null&&n.has(n.placeholderData)&&n.ignoreUpdate(()=>{n.remove(n.getStat(n.placeholderData)),a&&(a.dragNode.hidden=!1,a.dragOvering=!1)})};this.treeDraggableInstance=F.extendedDND(y,{beforeDragStart:l=>{if(!F.context.triggerElement)return;let s=this.triggerClass;(!s||s.length===0)&&(s="tree-node");let c=f.toArrayIfNot(s),d=f.findParent(F.context.triggerElement,h=>{if(f.hasClassIn(h,c))return!0;if(f.hasClass(h,"tree-node"))return"break"},{withSelf:!0,until:y});if(m=f.findParent(d,h=>{if(f.hasClass(h,"tree-node"))return!0},{withSelf:!0,until:y}),!!m){if(S=this.getNodeByElement(m),!S)throw"Can't find drag node";if(this.isDraggable(S))return this.$emit("before-drag-start",S),this.$emit("beforeDragStart",S),y}},onDragStart:l=>{var h,v,u;if(!m||!S)return;{const{x:g,y:w}=m.getBoundingClientRect(),{clientX:D,clientY:P}=l;(h=l.dataTransfer)==null||h.setDragImage(m,D-g,P-w)}Y={x:l.clientX,y:l.clientY},a=this,a.dragNode=S,j=(()=>{if(this.resolveStartMovePoint==="mouse")return{x:l.clientX,y:l.clientY};if(typeof this.resolveStartMovePoint=="function")return this.resolveStartMovePoint(m);{let g,w=0;if(this.table){let D=m.getBoundingClientRect();g={x:D.x,y:D.y},this.rtl&&(g.x=D.right),w=D.height}else if(!this.rtl)g=m.children[0].getBoundingClientRect().toJSON(),w=g.height;else{const D=m.children[0].getBoundingClientRect();g={x:D.right,y:D.y},w=D.height}return this.btt&&(g.y+=w),g}})(),this.dragOvering=!0;const c=a.getSiblings(a.dragNode),d=c.indexOf(S);A={tree:a,dragNode:S,parent:S.parent,siblings:c,indexBeforeDrop:d},n=this,(v=l.dataTransfer)==null||v.setData("text",`he-tree drag start at ${new Date().toISOString()}`),a._eachDroppable()||setTimeout(()=>{S.hidden=!0,t(S.parent,d+1)},0),(u=this.ondragstart)==null||u.call(this,l)},onEnter:l=>{this.$emit("enter",l)},onLeave:l=>{R=null,this.dragOvering=!1,F.context.preventDefault=!1,r(),this.$emit("leave",l)},onDragOver:f.applyFinally(l=>{if(!a){if(!this.onExternalDragOver||this.onExternalDragOver(l)===!1)return;F.context.preventDefault=!0}const s={x:l.clientX,y:l.clientY},c=e(s,b);if(b=s,!c)return;this.dragOvering=!0,n=this;const d=j?{x:j.x+(s.x-Y.x),y:j.y+(s.y-Y.y)}:{...s},{btt:h,rtl:v}=n;if(n.disableDrop){F.context.dropEffect="none";return}let u,g;const w=n.getRootEl().querySelectorAll(".tree-node"),D=[];w.forEach(p=>{!f.hasClassIn(p,["drag-placeholder-wrapper","dragging-node"])&&f.css(p,"display")!=="none"&&D.push(p)});const P=f.binarySearch(D,p=>f.getBoundingClientRect(p)[h?"bottom":"top"]-d.y,{returnNearestIfNoHit:!0});let C=null,I,q;P.hit||(P.greater?h||(C=P.index-1,D[C]||C++):h&&(C=P.index+1,D[C]||C--)),C==null&&(C=P.index),I=D[C],q=h?D[C-1]:D[C+1],u=I&&n.getNodeByElement(I),g=q&&n.getNodeByElement(q);const{indent:W}=n,L=f.cacheFunction(()=>{if(n.table){let p=f.getBoundingClientRect(I).toJSON();const k=W*(u.level-1);return v?(p.width-=k,p.right-=k):p.x+=k,p}else return f.getBoundingClientRect(I.firstElementChild)}).action,Q=f.cacheFunction(()=>h?d.y>L().y+L().height/2:d.y<L().y+L().height/2).action,pe=f.cacheFunction(()=>h?!I||C===D.length-1&&Q():!I||C===0&&Q()).action,ee=f.cacheFunction(()=>v?d.x-(L().x+L().width):L().x-d.x).action,ge=f.cacheFunction(()=>v?d.x<L().x+L().width-W:d.x>L().x+W).action;let E;if(pe())E=1,u=null;else if(u)ee()>0?E=u.level-Math.ceil(ee()/W):ge()?E=u.level+1:E=u.level;else return;g&&E<g.level&&(E=g.level),(async()=>{let p,k,$=!1,V=null;const U=async N=>{if(N.open)return!0;if(n.dragOpen)if(n.dragOpenDelay)if(V=N,R===N)$=!0;else{let B=f.promisePin();R=N;const M=N;return setTimeout(async()=>{M!==R?($=!0,B.resolve(!0)):(n.beforeDragOpen&&await n.beforeDragOpen(N),M!==R?($=!0,B.resolve(!0)):(N.open=!0,V=null,B.resolve(!0)))},n.dragOpenDelay),await B.promise}else return N.open=!0,!0;else return!1},T=async()=>{if(n.isDroppable(u)&&await U(u)){if($)return;p=u,k=null}else return!1},te=(N=E)=>{let B=u,M=[];for(;B&&B.level>=N;)B=B.parent||null,M.unshift(B);let ne=0;for(const ae of M){if(n.isDroppable(ae))return p=ae,k=M[ne+1]||u,!0;ne++}return!1};J=u||null,u?E>u.level?await T()===!1&&te(u.level):te()===!1&&await T():n.isDroppable(null)&&(p=null),R=V;const re=!!(!$&&(p||p===null));return{cancelled:$,success:re,parent:p,index:re?k?(p?p.children:n.stats).filter(N=>N.data!==n.placeholderData).indexOf(k)+1:0:-1}})().then(p=>{if(!p.cancelled){if(!p.success){o(!1);return}if(n.maxLevel!=null&&n.maxLevel>0){let k=1;if(a){const V=a.dragNode;let U=0;f.walkTreeData(V,T=>{T.level>U&&(U=T.level)},{childrenKey:G.CHILDREN}),k=U-V.level+1}if(k+(p.parent?p.parent.level:0)>n.maxLevel){o(!1);return}}o(!0),t(p.parent,p.index)}})},()=>{}),onDrop:l=>{n=this;const s=!a;if(!n)return;const c=a==null?void 0:a.dragNode;let d,h=(()=>{var u;let v=!0;if(!n.has(n.placeholderData))v=!1;else if(s)d=(u=this.externalDataHandler)==null?void 0:u.call(this,l),v=d!=null;else if(!a.dragCopy){const g=n.getStat(n.placeholderData);a===n&&g.parent===c.parent&&(f.findTreeData(c,w=>w===g),G.CHILDREN)}return v})();if(h){const v=n.getStat(n.placeholderData),u=n.getSiblings(v);H={tree:n,dragNode:c,parent:v.parent,siblings:u,indexBeforeDrop:u.indexOf(v)}}(()=>{if(x(),h){let v=H.indexBeforeDrop;a&&!a.dragCopy&&a===n&&A.parent==H.parent&&A.indexBeforeDrop<v&&v--,a&&a!==n&&!a._eachDroppable()&&a.batchUpdate(()=>{a.remove(c),a.updateCheck()}),n.batchUpdate(()=>{let u=a==null?void 0:a.dragNode,g;d?g=d:a._eachDroppable()&&(g=f.cloneTreeData(a.dragNode.data,{childrenKey:a.childrenKey}),a.dragCopyDataHandler&&(g=a.dragCopyDataHandler(g))),g&&(n.add(g),u=n.getStat(g)),n.move(u,H.parent,v),n.updateCheck()})}n.$emit("after-drop"),h&&(a&&(a.dragCopy||a.$emit("change")),n!==a&&n.$emit("change"))})()},onDragEnd:l=>{x(),a&&(a.dragNode&&(a.dragNode.hidden=!1),a.dragNode=null,a.dragOvering=!1,a=null),n=null,R=null,S=null,J=null}})},unmounted(){var e;(e=this.treeDraggableInstance)==null||e.destroy()}}),Be=_.defineComponent({props:{open:{type:Boolean}}});var Pe=function(){var e=this,t=e.$createElement,r=e._self._c||t;return r("a",{staticClass:"he-tree__open-icon",class:{open:e.open}},[r("svg",{attrs:{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"}},[r("title",[e._v("chevron-right")]),r("path",{attrs:{d:"M8.59,16.58L13.17,12L8.59,7.41L10,6L16,12L10,18L8.59,16.58Z"}})])])},Ee=[];const se={};var Fe=Z(Be,Pe,Ee,!1,Ie);function Ie(e){for(let t in se)this[t]=se[t]}const $e=function(){return Fe.exports}();function Re(e,t){try{return{mixins:[he],created:new Function(Ve(e,t))()}}catch{throw new Error("he-tree-pro: wrong secret key")}}function Ve(e,t){e=encodeURIComponent(e),e.length%2===1&&(e+="h"),e=e.split("").reverse().join(""),t=atob(t);for(let r=0;r<e.length;r+=2){const i=e[r],o=e[r+1];t=Me(t,i,o)}return Ue("arb=inowc=ocmet;etrnfucton){are=1,=tistr{evod !=b}ath(){e&(c_htreWtemak=)=e,._sMve=(=>._eteeatrmrkd.israCoy=)=d.abe,._acDrppbl=(=>.dagop)}",t)}function Me(e,t,r){let i="";for(let o=0;o<e.length;o++){const b=e[o];b===t?i+=r:b===r?i+=t:i+=b}return i}function Ue(e,t){let r=0,i="";for(;;){let o;if(o=r,o>=t.length||(i+=t[o],o=r*2,o>=e.length)||(i+=e[o],o+=1,o>=e.length))break;i+=e[o],r++}return i}Object.defineProperty(exports,"walkTreeData",{enumerable:!0,get:()=>de.walkTreeData});exports.BaseTree=ue;exports.Draggable=he;exports.OpenIcon=$e;exports.TreeNode=ce;exports.context=fe;exports.dragContext=fe;exports.pro=Re; |
@@ -1,6 +0,6 @@ | ||
(function(D,b){typeof exports=="object"&&typeof module<"u"?b(exports,require("vue-demi"),require("helper-js"),require("@virtual-list/vue/vue2"),require("@he-tree/tree-utils"),require("@he-tree/dnd-utils")):typeof define=="function"&&define.amd?define(["exports","vue-demi","helper-js","@virtual-list/vue/vue2","@he-tree/tree-utils","@he-tree/dnd-utils"],b):(D=typeof globalThis<"u"?globalThis:D||self,b(D.heTreeVue={},D.VueDemi,D.hp,D.VirtualList,D.treeUtils,D.dndUtils))})(this,function(D,b,Q,pe,z,E){"use strict";/*! | ||
* @he-tree/vue v2.8.6 | ||
(function(D,b){typeof exports=="object"&&typeof module<"u"?b(exports,require("vue-demi"),require("helper-js"),require("@virtual-list/vue/vue2"),require("@he-tree/tree-utils"),require("@he-tree/dnd-utils")):typeof define=="function"&&define.amd?define(["exports","vue-demi","helper-js","@virtual-list/vue/vue2","@he-tree/tree-utils","@he-tree/dnd-utils"],b):(D=typeof globalThis<"u"?globalThis:D||self,b(D.heTreeVue={},D.VueDemi,D.hp,D.VirtualList,D.treeUtils,D.dndUtils))})(this,function(D,b,ee,ge,z,E){"use strict";/*! | ||
* @he-tree/vue v2.8.7 | ||
* Author: phphe <phphe@outlook.com> (https://github.com/phphe) | ||
* Homepage: https://hetree.phphe.com/ | ||
* Released under the MIT License. | ||
*/function ge(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const i=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,i.get?i:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const c=ge(Q);let U=!1;const ve=()=>{U=!0,setTimeout(()=>{U=!1},100)},ye=b.defineComponent({props:["stat","rtl","btt","indent","table","treeLine","treeLineOffset","processor"],emits:["open","close","check"],setup(e,{emit:t}){const r=b.computed(()=>({[e.rtl?"paddingRight":"paddingLeft"]:e.indent*(e.stat.level-1)+"px"}));b.watch(()=>e.stat.checked,m=>{U||e.processor.afterOneCheckChanged(e.stat)&&t("check",e.stat)}),b.watch(()=>e.stat.open,m=>{U||(t(m?"open":"close",e.stat),ve())});const i=b.computed(()=>{const m=[],y=s=>{var u;if(s.parent){let d=(u=s.parent)==null?void 0:u.children.indexOf(s);do{d++;let h=s.parent.children[d];if(h){if(!h.hidden)return!0}else break}while(!0)}return!1},_=e.rtl?"right":"left",C=e.btt?"top":"bottom";let l=e.stat;for(;l;){let s=(l.level-2)*e.indent+e.treeLineOffset;const u=y(l),d=()=>{m.push({style:{[_]:s+"px",[C]:u?0:"50%"}})};l===e.stat?l.level>1&&d():u&&d(),l=l.parent}return m}),o=b.computed(()=>{let m=(e.stat.level-2)*e.indent+e.treeLineOffset;return{[e.rtl?"right":"left"]:m+"px"}});return{indentStyle:r,vLines:i,hLineStyle:o}}});var be=function(){var e=this,t=e.$createElement,r=e._self._c||t;return e.table?r("tr",{ref:"el",staticClass:"tree-node"},[e._t("default",null,{indentStyle:e.indentStyle})],2):r("div",{ref:"el",staticClass:"tree-node",class:{"tree-node--with-tree-line":e.treeLine},style:e.indentStyle},[e.treeLine?[e._l(e.vLines,function(i){return r("div",{staticClass:"tree-line tree-vline",style:i.style})}),e.stat.level>1?r("div",{staticClass:"tree-line tree-hline",style:e.hLineStyle}):e._e()]:e._e(),r("div",{staticClass:"tree-node-inner"},[e._t("default",null,{indentStyle:e.indentStyle})],2)],2)},me=[];function X(e,t,r,i,o,m,y,_){var C=typeof e=="function"?e.options:e;t&&(C.render=t,C.staticRenderFns=r,C._compiled=!0);var l;if(o&&(l=o),l)if(C.functional){C._injectStyles=l;var s=C.render;C.render=function(h,v){return l.call(v),s(h,v)}}else{var u=C.beforeCreate;C.beforeCreate=u?[].concat(u,l):[l]}return{exports:e,options:C}}const ee={};var _e=X(ye,be,me,!1,xe);function xe(e){for(let t in ee)this[t]=ee[t]}const te=function(){return _e.exports}();function De(e,t={}){const r={...t,statHandler(i){return this._statHandler2&&(i=this._statHandler2(i)),Y(t.statHandler,b.reactive(i))},statsHandler(i){return Y(t.statsHandler,b.reactive(i))},statsFlatHandler(i){return Y(t.statsFlatHandler,b.reactive(i))}};return z.makeTreeProcessor(e,r)}function Y(e,t){return e?e(t):t}const Ce=b.defineComponent({components:{VirtualList:pe,TreeNode:te},props:{value:{required:b.isVue2,type:Array},modelValue:{required:b.isVue3,type:Array},updateBehavior:{type:String,default:"modify"},processor:{type:Object,default:()=>De([],{noInitialization:!0})},childrenKey:{type:String,default:"children"},textKey:{type:String,default:"text"},indent:{type:Number,default:20},virtualization:{type:Boolean,default:!1},virtualizationPrerenderCount:{type:Number,default:20},defaultOpen:{type:Boolean,default:!0},statHandler:{type:Function},rtl:{type:Boolean,default:!1},btt:{type:Boolean,default:!1},table:{type:Boolean,default:!1},watermark:{type:Boolean,default:!1},nodeKey:{type:[String,Function],default:"index"},treeLine:{type:Boolean,default:!1},treeLineOffset:{type:Number,default:8}},emits:["update:modelValue","click:node","open:node","close:node","check:node","beforeDragStart","before-drag-start","after-drop","change","enter","leave"],data(){return{stats:[],statsFlat:[],dragNode:null,dragOvering:!1,placeholderData:{},placeholderColspan:1,batchUpdateWaiting:!1,self:this,_ignoreValueChangeOnce:!1}},computed:{valueComputed(){return(b.isVue2?this.value:this.modelValue)||[]},visibleStats(){const{statsFlat:e,isVisible:t}=this;let r=e;return this.btt&&(r=r.slice(),r.reverse()),r.filter(i=>t(i))},rootChildren(){return this.stats}},methods:{_emitValue(e){this.$emit(b.isVue2?"input":"update:modelValue",e)},_updateValue(e){return this.updateBehavior==="disabled"?!1:(e!==this.valueComputed&&(this._ignoreValueChangeOnce=!0),this._emitValue(e),!0)},getStat:G(w("getStat")),has:G(w("has")),updateCheck:w("updateCheck"),getChecked:w("getChecked"),getUnchecked:w("getUnchecked"),openAll:w("openAll"),closeAll:w("closeAll"),openNodeAndParents:w("openNodeAndParents"),isVisible:w("isVisible"),move:re("move"),add:G(re("add")),addMulti(e,t,r){this.batchUpdate(()=>{let i=r;for(const o of e)this.add(o,t,i),i!=null&&i++})},remove:w("remove"),removeMulti(e){let t=[...e];this.batchUpdate(()=>{for(const r of t)this.remove(r)})},iterateParent:w("iterateParent"),getSiblings:w("getSiblings"),getData:w("getData"),getRootEl(){return this.$refs.vtlist.listElRef},batchUpdate(e){const t=this.ignoreUpdate(e);return this.batchUpdateWaiting||this._updateValue(this.updateBehavior==="new"?this.getData():this.valueComputed),t},ignoreUpdate(e){const t=this.batchUpdateWaiting;this.batchUpdateWaiting=!0;const r=e();return this.batchUpdateWaiting=t,r}},watch:{processor:{immediate:!0,handler(e){if(e){const t=r=>{if(r){const{childrenKey:i}=this;return r[i]||(r[i]=[]),r[i]}else return this.valueComputed};e._statHandler2=this.statHandler?r=>r.data===this.placeholderData?r:this.statHandler(r):null,e.afterSetStat=(r,i,o)=>{const{childrenKey:m,updateBehavior:y}=this;let _=this.valueComputed;if(y==="new"){if(this.batchUpdateWaiting)return;_=this.getData()}else if(y==="modify"){const C=t(i==null?void 0:i.data);C.includes(r.data)||C.splice(o,0,r.data)}this.batchUpdateWaiting||this._updateValue(_)},e.afterRemoveStat=r=>{var y;const{childrenKey:i,updateBehavior:o}=this;let m=this.valueComputed;if(o==="new"){if(this.batchUpdateWaiting)return;m=this.getData()}else if(o==="modify"){const _=t((y=r.parent)==null?void 0:y.data);c.arrayRemove(_,r.data)}this.batchUpdateWaiting||this._updateValue(m)}}e.initialized||(e.data=this.valueComputed,Object.assign(e,c.objectOnly(this,["childrenKey","defaultOpen"])),e.init(),e.updateCheck()),this.stats=e.stats,this.statsFlat=e.statsFlat,e.data!==this.valueComputed&&this._updateValue(e.data)}},valueComputed:{handler(e){if(this.dragOvering||this.dragNode||this._ignoreValueChangeOnce)this._ignoreValueChangeOnce=!1;else{const{processor:r}=this;r.data=e,r.init(),this.stats=r.stats,this.statsFlat=r.statsFlat}}}},created(){},mounted(){this.watermark===!1&&(window._heTreeWatermarkDisabled=!0),this.watermark&&!window._heTreeWatermarkDisabled&&(window._heTreeWatermark||(window._heTreeWatermark=!0,console.log("%c[he-tree] Vue tree component: https://hetree.phphe.com","color:#0075ff; font-size:14px;")))}});function w(e){return function(...t){return this.processor[e](...t)}}function re(e){return function(...t){return this.batchUpdate(()=>this.processor[e](...t))}}function G(e){return function(t,...r){return t&&(t=b.reactive(t)),e.call(this,t,...r)}}var Se=function(){var e=this,t=e.$createElement,r=e._self._c||t;return r("VirtualList",{ref:"vtlist",staticClass:"he-tree",class:{"he-tree--rtl rtl":e.rtl,"he-tree--drag-overing drag-overing":e.dragOvering},attrs:{items:e.visibleStats,disabled:!e.virtualization,table:e.table,itemKey:e.nodeKey},scopedSlots:e._u([{key:"prepend",fn:function(){return[e._t("prepend",null,{tree:e.self})]},proxy:!0},{key:"default",fn:function(i){var o=i.item,m=i.index;return[r("TreeNode",{class:[o.class,{"drag-placeholder-wrapper":o.data===e.placeholderData,"dragging-node":o===e.dragNode}],style:o.style,attrs:{"vt-index":m,stat:o,rtl:e.rtl,btt:e.btt,indent:e.indent,table:e.table,treeLine:e.treeLine,treeLineOffset:e.treeLineOffset,processor:e.processor},on:{click:function(y){return e.$emit("click:node",o)},open:function(y){return e.$emit("open:node",y)},close:function(y){return e.$emit("close:node",y)},check:function(y){return e.$emit("check:node",y)}},scopedSlots:e._u([{key:"default",fn:function(y){var _=y.indentStyle;return[o.data===e.placeholderData?[e.table?r("td",{style:_,attrs:{colspan:e.placeholderColspan}},[r("div",{staticClass:"drag-placeholder he-tree-drag-placeholder"},[e._t("placeholder",null,{tree:e.self})],2)]):r("div",{staticClass:"drag-placeholder he-tree-drag-placeholder"},[e._t("placeholder",null,{tree:e.self})],2)]:e._t("default",function(){return[e._v(e._s(o.data[e.textKey])+" ")]},{node:o.data,stat:o,indentStyle:_,tree:e.self})]}}],null,!0)})]}},{key:"append",fn:function(){return[e._t("append",null,{tree:e.self})]},proxy:!0}],null,!0)})},Oe=[];const ne={};var we=X(Ce,Se,Oe,!1,Ne);function Ne(e){for(let t in ne)this[t]=ne[t]}const ae=function(){return we.exports}();let a=null,n=null,A,H,V,K,J,S;const le={get startInfo(){return A},get targetInfo(){return H},get dragNode(){return S},get startTree(){return a},get targetTree(){return n}},ie=b.defineComponent({extends:ae,props:{triggerClass:{type:[String,Array]},disableDrag:Boolean,disableDrop:Boolean,eachDraggable:{type:Function},eachDroppable:{type:Function},rootDroppable:{type:[Boolean,Function],default:!0},dragOpen:{type:Boolean,default:!0},dragOpenDelay:{type:Number,default:0},beforeDragOpen:{type:Function},resolveStartMovePoint:{type:[String,Function]},keepPlaceholder:{type:Boolean},maxLevel:{type:Number},dragCopy:{type:Boolean},dragCopyDataHandler:{type:Function},onExternalDragOver:{type:Function},externalDataHandler:{type:Function},ondragstart:{type:Function}},data(){return{treeDraggableInstance:null}},computed:{},methods:{getNodeByElement(e){const t=e.getAttribute("vt-index");return t==null?null:this.visibleStats[t]},isDraggable(e){if(this.disableDrag)return!1;if(e.draggable!=null)return e.draggable;if(this.eachDraggable){const r=this.eachDraggable(e);if(r!=null)return r}const{parent:t}=e;return t?this.isDraggable(t):!0},isDroppable(e){if(this.disableDrop)return!1;if(!e)return c.resolveValueOrGettter(this.rootDroppable,[this,a]);if(e.droppable!=null)return e.droppable;if(this.eachDroppable){const r=this.eachDroppable(e);if(r!=null)return r}const{parent:t}=e;return t?this.isDroppable(t):!0},_eachDroppable(){var e;return c.resolveValueOrGettter((e=this._isDragCopy)==null?void 0:e.call(this),[this])}},mounted(){const e=(l,s)=>{let u=!0;return a&&a!==this&&(u=u&&this._isMoved),this.table&&!this._isDragCopy&&(u=u&&this._isDragCopy),u&&(l.x!==s.x||l.y!==s.y)},t=(l,s)=>{n.ignoreUpdate(()=>{if(!n.has(n.placeholderData)){if(n.table){let d=0;const h=n.getRootEl().querySelector("tr");if(h)for(const{value:v}of c.iterateAll(h.children))c.css(v,"display")!=="none"&&(d+=v.colSpan||1);d<1&&(d=1),n.placeholderColspan=d}n.add(n.placeholderData)}const u=n.getStat(n.placeholderData);n.move(u,l,s)})},r=()=>{const l=this;if(l.has(l.placeholderData))return l.remove(l.getStat(l.placeholderData)),!0},i=l=>{l?E.context.dropEffect=a!=null&&a.dragCopy?"copy":"move":E.context.dropEffect="none"},o=l=>{const s=this;l?i(!0):s.keepPlaceholder?s.has(s.placeholderData)||i(!1):(r(),i(!1))};let m={x:0,y:0};const y=this.getRootEl();let _=null;const C=()=>{n!=null&&n.has(n.placeholderData)&&n.ignoreUpdate(()=>{n.remove(n.getStat(n.placeholderData)),a&&(a.dragNode.hidden=!1,a.dragOvering=!1)})};this.treeDraggableInstance=E.extendedDND(y,{beforeDragStart:l=>{if(!E.context.triggerElement)return;let s=this.triggerClass;(!s||s.length===0)&&(s="tree-node");let u=c.toArrayIfNot(s),d=c.findParent(E.context.triggerElement,h=>{if(c.hasClassIn(h,u))return!0;if(c.hasClass(h,"tree-node"))return"break"},{withSelf:!0,until:y});if(_=c.findParent(d,h=>{if(c.hasClass(h,"tree-node"))return!0},{withSelf:!0,until:y}),!!_){if(S=this.getNodeByElement(_),!S)throw"Can't find drag node";if(this.isDraggable(S))return this.$emit("before-drag-start",S),this.$emit("beforeDragStart",S),y}},onDragStart:l=>{var h,v,f;if(!_||!S)return;{const{x:g,y:k}=_.getBoundingClientRect(),{clientX:x,clientY:F}=l;(h=l.dataTransfer)==null||h.setDragImage(_,x-g,F-k)}J={x:l.clientX,y:l.clientY},a=this,a.dragNode=S,K=(()=>{if(this.resolveStartMovePoint==="mouse")return{x:l.clientX,y:l.clientY};if(typeof this.resolveStartMovePoint=="function")return this.resolveStartMovePoint(_);{let g,k=0;if(this.table){let x=_.getBoundingClientRect();g={x:x.x,y:x.y},this.rtl&&(g.x=x.right),k=x.height}else if(!this.rtl)g=_.children[0].getBoundingClientRect().toJSON(),k=g.height;else{const x=_.children[0].getBoundingClientRect();g={x:x.right,y:x.y},k=x.height}return this.btt&&(g.y+=k),g}})(),this.dragOvering=!0;const u=a.getSiblings(a.dragNode),d=u.indexOf(S);A={tree:a,dragNode:S,parent:S.parent,siblings:u,indexBeforeDrop:d},n=this,(v=l.dataTransfer)==null||v.setData("text",`he-tree drag start at ${new Date().toISOString()}`),a._eachDroppable()||setTimeout(()=>{S.hidden=!0,t(S.parent,d+1)},0),(f=this.ondragstart)==null||f.call(this,l)},onEnter:l=>{this.$emit("enter",l)},onLeave:l=>{V=null,this.dragOvering=!1,E.context.preventDefault=!1,r(),this.$emit("leave",l)},onDragOver:c.applyFinally(l=>{if(!a){if(!this.onExternalDragOver||this.onExternalDragOver(l)===!1)return;E.context.preventDefault=!0}const s={x:l.clientX,y:l.clientY},u=e(s,m);if(m=s,!u)return;this.dragOvering=!0,n=this;const d=K?{x:K.x+(s.x-J.x),y:K.y+(s.y-J.y)}:{...s},{btt:h,rtl:v}=n;if(n.disableDrop){E.context.dropEffect="none";return}let f,g;const k=n.getRootEl().querySelectorAll(".tree-node"),x=[];k.forEach(p=>{!c.hasClassIn(p,["drag-placeholder-wrapper","dragging-node"])&&c.css(p,"display")!=="none"&&x.push(p)});const F=c.binarySearch(x,p=>c.getBoundingClientRect(p)[h?"bottom":"top"]-d.y,{returnNearestIfNoHit:!0});let O=null,$,Z;F.hit||(F.greater?h||(O=F.index-1,x[O]||O++):h&&(O=F.index+1,x[O]||O--)),O==null&&(O=F.index),$=x[O],Z=h?x[O-1]:x[O+1],f=$&&n.getNodeByElement($),g=Z&&n.getNodeByElement(Z);const{indent:q}=n,B=c.cacheFunction(()=>{if(n.table){let p=c.getBoundingClientRect($).toJSON();const L=q*(f.level-1);return v?(p.width-=L,p.right-=L):p.x+=L,p}else return c.getBoundingClientRect($.firstElementChild)}).action,se=c.cacheFunction(()=>h?d.y>B().y+B().height/2:d.y<B().y+B().height/2).action,Te=c.cacheFunction(()=>h?!$||O===x.length-1&&se():!$||O===0&&se()).action,de=c.cacheFunction(()=>v?d.x-(B().x+B().width):B().x-d.x).action,Me=c.cacheFunction(()=>v?d.x<B().x+B().width-q:d.x>B().x+q).action;let I;if(Te())I=1,f=null;else if(f)de()>0?I=f.level-Math.ceil(de()/q):Me()?I=f.level+1:I=f.level;else return;g&&I<g.level&&(I=g.level),(async()=>{let p,L,R=!1,T=null;const j=async N=>{if(N.open)return!0;if(n.dragOpen)if(n.dragOpenDelay)if(T=N,V===N)R=!0;else{let P=c.promisePin();V=N;const M=N;return setTimeout(async()=>{M!==V?(R=!0,P.resolve(!0)):(n.beforeDragOpen&&await n.beforeDragOpen(N),M!==V?(R=!0,P.resolve(!0)):(N.open=!0,T=null,P.resolve(!0)))},n.dragOpenDelay),await P.promise}else return N.open=!0,!0;else return!1},W=async()=>{if(n.isDroppable(f)&&await j(f)){if(R)return;p=f,L=null}else return!1},ce=(N=I)=>{let P=f,M=[];for(;P&&P.level>=N;)P=P.parent||null,M.unshift(P);let fe=0;for(const he of M){if(n.isDroppable(he))return p=he,L=M[fe+1]||f,!0;fe++}return!1};f?I>f.level?await W()===!1&&ce(f.level):ce()===!1&&await W():n.isDroppable(null)&&(p=null),V=T;const ue=!!(!R&&(p||p===null));return{cancelled:R,success:ue,parent:p,index:ue?L?(p?p.children:n.stats).filter(N=>N.data!==n.placeholderData).indexOf(L)+1:0:-1}})().then(p=>{if(!p.cancelled){if(!p.success){o(!1);return}if(n.maxLevel!=null&&n.maxLevel>0){let L=1;if(a){const T=a.dragNode;let j=0;c.walkTreeData(T,W=>{W.level>j&&(j=W.level)},{childrenKey:z.CHILDREN}),L=j-T.level+1}if(L+(p.parent?p.parent.level:0)>n.maxLevel){o(!1);return}}o(!0),t(p.parent,p.index)}})},()=>{}),onDrop:l=>{n=this;const s=!a;if(!n)return;const u=a==null?void 0:a.dragNode;let d,h=(()=>{var f;let v=!0;if(!n.has(n.placeholderData))v=!1;else if(s)d=(f=this.externalDataHandler)==null?void 0:f.call(this,l),v=d!=null;else if(!a.dragCopy){const g=n.getStat(n.placeholderData);a===n&&g.parent===u.parent&&(c.findTreeData(u,k=>k===g),z.CHILDREN)}return v})();if(h){const v=n.getStat(n.placeholderData),f=n.getSiblings(v);H={tree:n,dragNode:u,parent:v.parent,siblings:f,indexBeforeDrop:f.indexOf(v)}}(()=>{if(C(),h){let v=H.indexBeforeDrop;a&&!a.dragCopy&&a===n&&A.parent==H.parent&&A.indexBeforeDrop<v&&v--,a&&a!==n&&!a._eachDroppable()&&a.batchUpdate(()=>{a.remove(u),a.updateCheck()}),n.batchUpdate(()=>{let f=a==null?void 0:a.dragNode,g;d?g=d:a._eachDroppable()&&(g=c.cloneTreeData(a.dragNode.data,{childrenKey:a.childrenKey}),a.dragCopyDataHandler&&(g=a.dragCopyDataHandler(g))),g&&(n.add(g),f=n.getStat(g)),n.move(f,H.parent,v),n.updateCheck()})}n.$emit("after-drop"),h&&(a&&(a.dragCopy||a.$emit("change")),n!==a&&n.$emit("change"))})()},onDragEnd:l=>{C(),a&&(a.dragNode&&(a.dragNode.hidden=!1),a.dragNode=null,a.dragOvering=!1,a=null),n=null,V=null,S=null}})},unmounted(){var e;(e=this.treeDraggableInstance)==null||e.destroy()}}),ke=b.defineComponent({props:{open:{type:Boolean}}});var Le=function(){var e=this,t=e.$createElement,r=e._self._c||t;return r("a",{staticClass:"he-tree__open-icon",class:{open:e.open}},[r("svg",{attrs:{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"}},[r("title",[e._v("chevron-right")]),r("path",{attrs:{d:"M8.59,16.58L13.17,12L8.59,7.41L10,6L16,12L10,18L8.59,16.58Z"}})])])},Be=[];const oe={};var Pe=X(ke,Le,Be,!1,Ee);function Ee(e){for(let t in oe)this[t]=oe[t]}const Fe=function(){return Pe.exports}();function Ie(e,t){try{return{mixins:[ie],created:new Function(Ve(e,t))()}}catch{throw new Error("he-tree-pro: wrong secret key")}}function Ve(e,t){e=encodeURIComponent(e),e.length%2===1&&(e+="h"),e=e.split("").reverse().join(""),t=atob(t);for(let r=0;r<e.length;r+=2){const i=e[r],o=e[r+1];t=$e(t,i,o)}return Re("arb=inowc=ocmet;etrnfucton){are=1,=tistr{evod !=b}ath(){e&(c_htreWtemak=)=e,._sMve=(=>._eteeatrmrkd.israCoy=)=d.abe,._acDrppbl=(=>.dagop)}",t)}function $e(e,t,r){let i="";for(let o=0;o<e.length;o++){const m=e[o];m===t?i+=r:m===r?i+=t:i+=m}return i}function Re(e,t){let r=0,i="";for(;;){let o;if(o=r,o>=t.length||(i+=t[o],o=r*2,o>=e.length)||(i+=e[o],o+=1,o>=e.length))break;i+=e[o],r++}return i}Object.defineProperty(D,"walkTreeData",{enumerable:!0,get:()=>Q.walkTreeData}),D.BaseTree=ae,D.Draggable=ie,D.OpenIcon=Fe,D.TreeNode=te,D.context=le,D.dragContext=le,D.pro=Ie,Object.defineProperty(D,Symbol.toStringTag,{value:"Module"})}); | ||
*/function ve(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const i=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,i.get?i:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const c=ve(ee);let U=!1;const ye=()=>{U=!0,setTimeout(()=>{U=!1},100)},be=b.defineComponent({props:["stat","rtl","btt","indent","table","treeLine","treeLineOffset","processor"],emits:["open","close","check"],setup(e,{emit:t}){const r=b.computed(()=>({[e.rtl?"paddingRight":"paddingLeft"]:e.indent*(e.stat.level-1)+"px"}));b.watch(()=>e.stat.checked,m=>{U||e.processor.afterOneCheckChanged(e.stat)&&t("check",e.stat)}),b.watch(()=>e.stat.open,m=>{U||(t(m?"open":"close",e.stat),ye())});const i=b.computed(()=>{const m=[],y=s=>{var u;if(s.parent){let d=(u=s.parent)==null?void 0:u.children.indexOf(s);do{d++;let h=s.parent.children[d];if(h){if(!h.hidden)return!0}else break}while(!0)}return!1},_=e.rtl?"right":"left",C=e.btt?"top":"bottom";let l=e.stat;for(;l;){let s=(l.level-2)*e.indent+e.treeLineOffset;const u=y(l),d=()=>{m.push({style:{[_]:s+"px",[C]:u?0:"50%"}})};l===e.stat?l.level>1&&d():u&&d(),l=l.parent}return m}),o=b.computed(()=>{let m=(e.stat.level-2)*e.indent+e.treeLineOffset;return{[e.rtl?"right":"left"]:m+"px"}});return{indentStyle:r,vLines:i,hLineStyle:o}}});var me=function(){var e=this,t=e.$createElement,r=e._self._c||t;return e.table?r("tr",{ref:"el",staticClass:"tree-node"},[e._t("default",null,{indentStyle:e.indentStyle})],2):r("div",{ref:"el",staticClass:"tree-node",class:{"tree-node--with-tree-line":e.treeLine},style:e.indentStyle},[e.treeLine?[e._l(e.vLines,function(i){return r("div",{staticClass:"tree-line tree-vline",style:i.style})}),e.stat.level>1?r("div",{staticClass:"tree-line tree-hline",style:e.hLineStyle}):e._e()]:e._e(),r("div",{staticClass:"tree-node-inner"},[e._t("default",null,{indentStyle:e.indentStyle})],2)],2)},_e=[];function X(e,t,r,i,o,m,y,_){var C=typeof e=="function"?e.options:e;t&&(C.render=t,C.staticRenderFns=r,C._compiled=!0);var l;if(o&&(l=o),l)if(C.functional){C._injectStyles=l;var s=C.render;C.render=function(h,v){return l.call(v),s(h,v)}}else{var u=C.beforeCreate;C.beforeCreate=u?[].concat(u,l):[l]}return{exports:e,options:C}}const te={};var xe=X(be,me,_e,!1,De);function De(e){for(let t in te)this[t]=te[t]}const re=function(){return xe.exports}();function Ce(e,t={}){const r={...t,statHandler(i){return this._statHandler2&&(i=this._statHandler2(i)),Y(t.statHandler,b.reactive(i))},statsHandler(i){return Y(t.statsHandler,b.reactive(i))},statsFlatHandler(i){return Y(t.statsFlatHandler,b.reactive(i))}};return z.makeTreeProcessor(e,r)}function Y(e,t){return e?e(t):t}const Se=b.defineComponent({components:{VirtualList:ge,TreeNode:re},props:{value:{required:b.isVue2,type:Array},modelValue:{required:b.isVue3,type:Array},updateBehavior:{type:String,default:"modify"},processor:{type:Object,default:()=>Ce([],{noInitialization:!0})},childrenKey:{type:String,default:"children"},textKey:{type:String,default:"text"},indent:{type:Number,default:20},virtualization:{type:Boolean,default:!1},virtualizationPrerenderCount:{type:Number,default:20},defaultOpen:{type:Boolean,default:!0},statHandler:{type:Function},rtl:{type:Boolean,default:!1},btt:{type:Boolean,default:!1},table:{type:Boolean,default:!1},watermark:{type:Boolean,default:!1},nodeKey:{type:[String,Function],default:"index"},treeLine:{type:Boolean,default:!1},treeLineOffset:{type:Number,default:8}},emits:["update:modelValue","click:node","open:node","close:node","check:node","beforeDragStart","before-drag-start","after-drop","change","enter","leave"],data(){return{stats:[],statsFlat:[],dragNode:null,dragOvering:!1,placeholderData:{},placeholderColspan:1,batchUpdateWaiting:!1,self:this,_ignoreValueChangeOnce:!1}},computed:{valueComputed(){return(b.isVue2?this.value:this.modelValue)||[]},visibleStats(){const{statsFlat:e,isVisible:t}=this;let r=e;return this.btt&&(r=r.slice(),r.reverse()),r.filter(i=>t(i))},rootChildren(){return this.stats}},methods:{_emitValue(e){this.$emit(b.isVue2?"input":"update:modelValue",e)},_updateValue(e){return this.updateBehavior==="disabled"?!1:(e!==this.valueComputed&&(this._ignoreValueChangeOnce=!0),this._emitValue(e),!0)},getStat:G(N("getStat")),has:G(N("has")),updateCheck:N("updateCheck"),getChecked:N("getChecked"),getUnchecked:N("getUnchecked"),openAll:N("openAll"),closeAll:N("closeAll"),openNodeAndParents:N("openNodeAndParents"),isVisible:N("isVisible"),move:ne("move"),add:G(ne("add")),addMulti(e,t,r){this.batchUpdate(()=>{let i=r;for(const o of e)this.add(o,t,i),i!=null&&i++})},remove:N("remove"),removeMulti(e){let t=[...e];this.batchUpdate(()=>{for(const r of t)this.remove(r)})},iterateParent:N("iterateParent"),getSiblings:N("getSiblings"),getData:N("getData"),getRootEl(){return this.$refs.vtlist.listElRef},batchUpdate(e){const t=this.ignoreUpdate(e);return this.batchUpdateWaiting||this._updateValue(this.updateBehavior==="new"?this.getData():this.valueComputed),t},ignoreUpdate(e){const t=this.batchUpdateWaiting;this.batchUpdateWaiting=!0;const r=e();return this.batchUpdateWaiting=t,r}},watch:{processor:{immediate:!0,handler(e){if(e){const t=r=>{if(r){const{childrenKey:i}=this;return r[i]||(r[i]=[]),r[i]}else return this.valueComputed};e._statHandler2=this.statHandler?r=>r.data===this.placeholderData?r:this.statHandler(r):null,e.afterSetStat=(r,i,o)=>{const{childrenKey:m,updateBehavior:y}=this;let _=this.valueComputed;if(y==="new"){if(this.batchUpdateWaiting)return;_=this.getData()}else if(y==="modify"){const C=t(i==null?void 0:i.data);C.includes(r.data)||C.splice(o,0,r.data)}this.batchUpdateWaiting||this._updateValue(_)},e.afterRemoveStat=r=>{var y;const{childrenKey:i,updateBehavior:o}=this;let m=this.valueComputed;if(o==="new"){if(this.batchUpdateWaiting)return;m=this.getData()}else if(o==="modify"){const _=t((y=r.parent)==null?void 0:y.data);c.arrayRemove(_,r.data)}this.batchUpdateWaiting||this._updateValue(m)}}e.initialized||(e.data=this.valueComputed,Object.assign(e,c.objectOnly(this,["childrenKey","defaultOpen"])),e.init(),e.updateCheck()),this.stats=e.stats,this.statsFlat=e.statsFlat,e.data!==this.valueComputed&&this._updateValue(e.data)}},valueComputed:{handler(e){if(this.dragOvering||this.dragNode||this._ignoreValueChangeOnce)this._ignoreValueChangeOnce=!1;else{const{processor:r}=this;r.data=e,r.init(),this.stats=r.stats,this.statsFlat=r.statsFlat}}}},created(){},mounted(){this.watermark===!1&&(window._heTreeWatermarkDisabled=!0),this.watermark&&!window._heTreeWatermarkDisabled&&(window._heTreeWatermark||(window._heTreeWatermark=!0,console.log("%c[he-tree] Vue tree component: https://hetree.phphe.com","color:#0075ff; font-size:14px;")))}});function N(e){return function(...t){return this.processor[e](...t)}}function ne(e){return function(...t){return this.batchUpdate(()=>this.processor[e](...t))}}function G(e){return function(t,...r){return t&&(t=b.reactive(t)),e.call(this,t,...r)}}var Oe=function(){var e=this,t=e.$createElement,r=e._self._c||t;return r("VirtualList",{ref:"vtlist",staticClass:"he-tree",class:{"he-tree--rtl rtl":e.rtl,"he-tree--drag-overing drag-overing":e.dragOvering},attrs:{items:e.visibleStats,disabled:!e.virtualization,table:e.table,itemKey:e.nodeKey},scopedSlots:e._u([{key:"prepend",fn:function(){return[e._t("prepend",null,{tree:e.self})]},proxy:!0},{key:"default",fn:function(i){var o=i.item,m=i.index;return[r("TreeNode",{class:[o.class,{"drag-placeholder-wrapper":o.data===e.placeholderData,"dragging-node":o===e.dragNode}],style:o.style,attrs:{"vt-index":m,stat:o,rtl:e.rtl,btt:e.btt,indent:e.indent,table:e.table,treeLine:e.treeLine,treeLineOffset:e.treeLineOffset,processor:e.processor},on:{click:function(y){return e.$emit("click:node",o)},open:function(y){return e.$emit("open:node",y)},close:function(y){return e.$emit("close:node",y)},check:function(y){return e.$emit("check:node",y)}},scopedSlots:e._u([{key:"default",fn:function(y){var _=y.indentStyle;return[o.data===e.placeholderData?[e.table?r("td",{style:_,attrs:{colspan:e.placeholderColspan}},[r("div",{staticClass:"drag-placeholder he-tree-drag-placeholder"},[e._t("placeholder",null,{tree:e.self})],2)]):r("div",{staticClass:"drag-placeholder he-tree-drag-placeholder"},[e._t("placeholder",null,{tree:e.self})],2)]:e._t("default",function(){return[e._v(e._s(o.data[e.textKey])+" ")]},{node:o.data,stat:o,indentStyle:_,tree:e.self})]}}],null,!0)})]}},{key:"append",fn:function(){return[e._t("append",null,{tree:e.self})]},proxy:!0}],null,!0)})},Ne=[];const ae={};var we=X(Se,Oe,Ne,!1,ke);function ke(e){for(let t in ae)this[t]=ae[t]}const le=function(){return we.exports}();let a=null,n=null,A,H,V,K,J,S,Z;const ie={get startInfo(){return A},get targetInfo(){return H},get dragNode(){return S},get startTree(){return a},get targetTree(){return n},get closestNode(){return Z}},oe=b.defineComponent({extends:le,props:{triggerClass:{type:[String,Array]},disableDrag:Boolean,disableDrop:Boolean,eachDraggable:{type:Function},eachDroppable:{type:Function},rootDroppable:{type:[Boolean,Function],default:!0},dragOpen:{type:Boolean,default:!0},dragOpenDelay:{type:Number,default:0},beforeDragOpen:{type:Function},resolveStartMovePoint:{type:[String,Function]},keepPlaceholder:{type:Boolean},maxLevel:{type:Number},dragCopy:{type:Boolean},dragCopyDataHandler:{type:Function},onExternalDragOver:{type:Function},externalDataHandler:{type:Function},ondragstart:{type:Function}},data(){return{treeDraggableInstance:null}},computed:{},methods:{getNodeByElement(e){const t=e.getAttribute("vt-index");return t==null?null:this.visibleStats[t]},isDraggable(e){if(this.disableDrag)return!1;if(e.draggable!=null)return e.draggable;if(this.eachDraggable){const r=this.eachDraggable(e);if(r!=null)return r}const{parent:t}=e;return t?this.isDraggable(t):!0},isDroppable(e){if(this.disableDrop)return!1;if(!e)return c.resolveValueOrGettter(this.rootDroppable,[this,a]);if(e.droppable!=null)return e.droppable;if(this.eachDroppable){const r=this.eachDroppable(e);if(r!=null)return r}const{parent:t}=e;return t?this.isDroppable(t):!0},_eachDroppable(){var e;return c.resolveValueOrGettter((e=this._isDragCopy)==null?void 0:e.call(this),[this])}},mounted(){const e=(l,s)=>{let u=!0;return a&&a!==this&&(u=u&&this._isMoved),this.table&&!this._isDragCopy&&(u=u&&this._isDragCopy),u&&(l.x!==s.x||l.y!==s.y)},t=(l,s)=>{n.ignoreUpdate(()=>{if(!n.has(n.placeholderData)){if(n.table){let d=0;const h=n.getRootEl().querySelector("tr");if(h)for(const{value:v}of c.iterateAll(h.children))c.css(v,"display")!=="none"&&(d+=v.colSpan||1);d<1&&(d=1),n.placeholderColspan=d}n.add(n.placeholderData)}const u=n.getStat(n.placeholderData);n.move(u,l,s)})},r=()=>{const l=this;if(l.has(l.placeholderData))return l.remove(l.getStat(l.placeholderData)),!0},i=l=>{l?E.context.dropEffect=a!=null&&a.dragCopy?"copy":"move":E.context.dropEffect="none"},o=l=>{const s=this;l?i(!0):s.keepPlaceholder?s.has(s.placeholderData)||i(!1):(r(),i(!1))};let m={x:0,y:0};const y=this.getRootEl();let _=null;const C=()=>{n!=null&&n.has(n.placeholderData)&&n.ignoreUpdate(()=>{n.remove(n.getStat(n.placeholderData)),a&&(a.dragNode.hidden=!1,a.dragOvering=!1)})};this.treeDraggableInstance=E.extendedDND(y,{beforeDragStart:l=>{if(!E.context.triggerElement)return;let s=this.triggerClass;(!s||s.length===0)&&(s="tree-node");let u=c.toArrayIfNot(s),d=c.findParent(E.context.triggerElement,h=>{if(c.hasClassIn(h,u))return!0;if(c.hasClass(h,"tree-node"))return"break"},{withSelf:!0,until:y});if(_=c.findParent(d,h=>{if(c.hasClass(h,"tree-node"))return!0},{withSelf:!0,until:y}),!!_){if(S=this.getNodeByElement(_),!S)throw"Can't find drag node";if(this.isDraggable(S))return this.$emit("before-drag-start",S),this.$emit("beforeDragStart",S),y}},onDragStart:l=>{var h,v,f;if(!_||!S)return;{const{x:g,y:k}=_.getBoundingClientRect(),{clientX:x,clientY:F}=l;(h=l.dataTransfer)==null||h.setDragImage(_,x-g,F-k)}J={x:l.clientX,y:l.clientY},a=this,a.dragNode=S,K=(()=>{if(this.resolveStartMovePoint==="mouse")return{x:l.clientX,y:l.clientY};if(typeof this.resolveStartMovePoint=="function")return this.resolveStartMovePoint(_);{let g,k=0;if(this.table){let x=_.getBoundingClientRect();g={x:x.x,y:x.y},this.rtl&&(g.x=x.right),k=x.height}else if(!this.rtl)g=_.children[0].getBoundingClientRect().toJSON(),k=g.height;else{const x=_.children[0].getBoundingClientRect();g={x:x.right,y:x.y},k=x.height}return this.btt&&(g.y+=k),g}})(),this.dragOvering=!0;const u=a.getSiblings(a.dragNode),d=u.indexOf(S);A={tree:a,dragNode:S,parent:S.parent,siblings:u,indexBeforeDrop:d},n=this,(v=l.dataTransfer)==null||v.setData("text",`he-tree drag start at ${new Date().toISOString()}`),a._eachDroppable()||setTimeout(()=>{S.hidden=!0,t(S.parent,d+1)},0),(f=this.ondragstart)==null||f.call(this,l)},onEnter:l=>{this.$emit("enter",l)},onLeave:l=>{V=null,this.dragOvering=!1,E.context.preventDefault=!1,r(),this.$emit("leave",l)},onDragOver:c.applyFinally(l=>{if(!a){if(!this.onExternalDragOver||this.onExternalDragOver(l)===!1)return;E.context.preventDefault=!0}const s={x:l.clientX,y:l.clientY},u=e(s,m);if(m=s,!u)return;this.dragOvering=!0,n=this;const d=K?{x:K.x+(s.x-J.x),y:K.y+(s.y-J.y)}:{...s},{btt:h,rtl:v}=n;if(n.disableDrop){E.context.dropEffect="none";return}let f,g;const k=n.getRootEl().querySelectorAll(".tree-node"),x=[];k.forEach(p=>{!c.hasClassIn(p,["drag-placeholder-wrapper","dragging-node"])&&c.css(p,"display")!=="none"&&x.push(p)});const F=c.binarySearch(x,p=>c.getBoundingClientRect(p)[h?"bottom":"top"]-d.y,{returnNearestIfNoHit:!0});let O=null,$,Q;F.hit||(F.greater?h||(O=F.index-1,x[O]||O++):h&&(O=F.index+1,x[O]||O--)),O==null&&(O=F.index),$=x[O],Q=h?x[O-1]:x[O+1],f=$&&n.getNodeByElement($),g=Q&&n.getNodeByElement(Q);const{indent:q}=n,B=c.cacheFunction(()=>{if(n.table){let p=c.getBoundingClientRect($).toJSON();const L=q*(f.level-1);return v?(p.width-=L,p.right-=L):p.x+=L,p}else return c.getBoundingClientRect($.firstElementChild)}).action,de=c.cacheFunction(()=>h?d.y>B().y+B().height/2:d.y<B().y+B().height/2).action,Me=c.cacheFunction(()=>h?!$||O===x.length-1&&de():!$||O===0&&de()).action,ce=c.cacheFunction(()=>v?d.x-(B().x+B().width):B().x-d.x).action,He=c.cacheFunction(()=>v?d.x<B().x+B().width-q:d.x>B().x+q).action;let I;if(Me())I=1,f=null;else if(f)ce()>0?I=f.level-Math.ceil(ce()/q):He()?I=f.level+1:I=f.level;else return;g&&I<g.level&&(I=g.level),(async()=>{let p,L,R=!1,T=null;const j=async w=>{if(w.open)return!0;if(n.dragOpen)if(n.dragOpenDelay)if(T=w,V===w)R=!0;else{let P=c.promisePin();V=w;const M=w;return setTimeout(async()=>{M!==V?(R=!0,P.resolve(!0)):(n.beforeDragOpen&&await n.beforeDragOpen(w),M!==V?(R=!0,P.resolve(!0)):(w.open=!0,T=null,P.resolve(!0)))},n.dragOpenDelay),await P.promise}else return w.open=!0,!0;else return!1},W=async()=>{if(n.isDroppable(f)&&await j(f)){if(R)return;p=f,L=null}else return!1},ue=(w=I)=>{let P=f,M=[];for(;P&&P.level>=w;)P=P.parent||null,M.unshift(P);let he=0;for(const pe of M){if(n.isDroppable(pe))return p=pe,L=M[he+1]||f,!0;he++}return!1};Z=f||null,f?I>f.level?await W()===!1&&ue(f.level):ue()===!1&&await W():n.isDroppable(null)&&(p=null),V=T;const fe=!!(!R&&(p||p===null));return{cancelled:R,success:fe,parent:p,index:fe?L?(p?p.children:n.stats).filter(w=>w.data!==n.placeholderData).indexOf(L)+1:0:-1}})().then(p=>{if(!p.cancelled){if(!p.success){o(!1);return}if(n.maxLevel!=null&&n.maxLevel>0){let L=1;if(a){const T=a.dragNode;let j=0;c.walkTreeData(T,W=>{W.level>j&&(j=W.level)},{childrenKey:z.CHILDREN}),L=j-T.level+1}if(L+(p.parent?p.parent.level:0)>n.maxLevel){o(!1);return}}o(!0),t(p.parent,p.index)}})},()=>{}),onDrop:l=>{n=this;const s=!a;if(!n)return;const u=a==null?void 0:a.dragNode;let d,h=(()=>{var f;let v=!0;if(!n.has(n.placeholderData))v=!1;else if(s)d=(f=this.externalDataHandler)==null?void 0:f.call(this,l),v=d!=null;else if(!a.dragCopy){const g=n.getStat(n.placeholderData);a===n&&g.parent===u.parent&&(c.findTreeData(u,k=>k===g),z.CHILDREN)}return v})();if(h){const v=n.getStat(n.placeholderData),f=n.getSiblings(v);H={tree:n,dragNode:u,parent:v.parent,siblings:f,indexBeforeDrop:f.indexOf(v)}}(()=>{if(C(),h){let v=H.indexBeforeDrop;a&&!a.dragCopy&&a===n&&A.parent==H.parent&&A.indexBeforeDrop<v&&v--,a&&a!==n&&!a._eachDroppable()&&a.batchUpdate(()=>{a.remove(u),a.updateCheck()}),n.batchUpdate(()=>{let f=a==null?void 0:a.dragNode,g;d?g=d:a._eachDroppable()&&(g=c.cloneTreeData(a.dragNode.data,{childrenKey:a.childrenKey}),a.dragCopyDataHandler&&(g=a.dragCopyDataHandler(g))),g&&(n.add(g),f=n.getStat(g)),n.move(f,H.parent,v),n.updateCheck()})}n.$emit("after-drop"),h&&(a&&(a.dragCopy||a.$emit("change")),n!==a&&n.$emit("change"))})()},onDragEnd:l=>{C(),a&&(a.dragNode&&(a.dragNode.hidden=!1),a.dragNode=null,a.dragOvering=!1,a=null),n=null,V=null,S=null,Z=null}})},unmounted(){var e;(e=this.treeDraggableInstance)==null||e.destroy()}}),Le=b.defineComponent({props:{open:{type:Boolean}}});var Be=function(){var e=this,t=e.$createElement,r=e._self._c||t;return r("a",{staticClass:"he-tree__open-icon",class:{open:e.open}},[r("svg",{attrs:{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"}},[r("title",[e._v("chevron-right")]),r("path",{attrs:{d:"M8.59,16.58L13.17,12L8.59,7.41L10,6L16,12L10,18L8.59,16.58Z"}})])])},Pe=[];const se={};var Ee=X(Le,Be,Pe,!1,Fe);function Fe(e){for(let t in se)this[t]=se[t]}const Ie=function(){return Ee.exports}();function Ve(e,t){try{return{mixins:[oe],created:new Function($e(e,t))()}}catch{throw new Error("he-tree-pro: wrong secret key")}}function $e(e,t){e=encodeURIComponent(e),e.length%2===1&&(e+="h"),e=e.split("").reverse().join(""),t=atob(t);for(let r=0;r<e.length;r+=2){const i=e[r],o=e[r+1];t=Re(t,i,o)}return Te("arb=inowc=ocmet;etrnfucton){are=1,=tistr{evod !=b}ath(){e&(c_htreWtemak=)=e,._sMve=(=>._eteeatrmrkd.israCoy=)=d.abe,._acDrppbl=(=>.dagop)}",t)}function Re(e,t,r){let i="";for(let o=0;o<e.length;o++){const m=e[o];m===t?i+=r:m===r?i+=t:i+=m}return i}function Te(e,t){let r=0,i="";for(;;){let o;if(o=r,o>=t.length||(i+=t[o],o=r*2,o>=e.length)||(i+=e[o],o+=1,o>=e.length))break;i+=e[o],r++}return i}Object.defineProperty(D,"walkTreeData",{enumerable:!0,get:()=>ee.walkTreeData}),D.BaseTree=le,D.Draggable=oe,D.OpenIcon=Ie,D.TreeNode=re,D.context=ie,D.dragContext=ie,D.pro=Ve,Object.defineProperty(D,Symbol.toStringTag,{value:"Module"})}); |
@@ -1,3 +0,3 @@ | ||
var heTreeVue=function(M,S,f){"use strict";/*! | ||
* @he-tree/vue v2.8.6 | ||
var heTreeVue=function(M,k,f){"use strict";/*! | ||
* @he-tree/vue v2.8.7 | ||
* Author: phphe <phphe@outlook.com> (https://github.com/phphe) | ||
@@ -11,3 +11,3 @@ * Homepage: https://hetree.phphe.com/ | ||
* Released under the MIT License. | ||
*/function ie(e){return Object.prototype.toString.call(e)==="[object Array]"}function Oe(e){return Object.prototype.toString.call(e)==="[object Object]"}function He(e){return typeof e=="function"}function Ue(e,t){return e<t?e:t}function xe(e,t){let n,r=0;for(;(n=e.indexOf(t))>-1;)e.splice(n,1),r++;return r}function Ne(e){return e[e.length-1]}function We(e){return ie(e)?e:[e]}function je(e,t){let n=new Set(t);const r={};return n.forEach(o=>{r[o]=e[o]}),r}function*Xe(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(t.reverse)if(e.length!=null)for(let n=e.length-1;n>=0;n--){const r={value:e[n],index:n};(!t.exclude||!t.exclude(r))&&(yield r)}else if(Oe(e)){const n=Object.keys(e);n.reverse();for(const r of n){const o={value:e[r],key:r};(!t.exclude||!t.exclude(o))&&(yield o)}}else throw"Unsupported type";else if(e.length!=null)for(let n=0;n<e.length;n++){const r={value:e[n],index:n};(!t.exclude||!t.exclude(r))&&(yield r)}else if(Oe(e))for(const n of Object.keys(e)){const r={value:e[n],key:n};(!t.exclude||!t.exclude(r))&&(yield r)}else throw"Unsupported type"}function Ye(e,t,n){e.hasOwnProperty(t)||(e[t]=n)}function _e(e,t){return Object.keys(t).forEach(n=>{Ye(e,n,t[n])}),e}function qe(e){const t={};return Object.keys(e).forEach(n=>{e[n]!==void 0&&(t[n]=e[n])}),t}function V(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};n=_e({...n},{childrenKey:"children"});const{childrenKey:r}=n,o=ie(e)?e:[e];class l{}const a=(i,h,s)=>{n.reverse&&(i=i.slice(),i.reverse());const d=i.length;for(let u=0;u<d;u++){const c=i[u],p=n.reverse?d-u-1:u,m=s?[...s,p]:[];n.childFirst&&c[r]!=null&&a(c[r],c,m);const k=t(c,p,h,m);if(k===!1)throw new l;if(k==="skip children")continue;if(k==="skip siblings")break;n.childFirst||c[r]!=null&&a(c[r],c,m)}};try{a(o,null,ie(e)?[]:null)}catch(i){if(!(i instanceof l))throw i}}function Je(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},r;return V(e,function(){if(t(...arguments))return r={node:arguments.length<=0?void 0:arguments[0],index:arguments.length<=1?void 0:arguments[1],parent:arguments.length<=2?void 0:arguments[2],path:arguments.length<=3?void 0:arguments[3]},!1},n),r}function Ze(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const r=Je(e,t,n);return r==null?void 0:r.node}function $e(e,t){const n={childrenKey:"children"};t&&Object.assign(n,t);const{childrenKey:r,nodeHandler:o}=n,l=new me;return l.childrenKey=r,V(e,(a,i,h,s)=>{let d=Object.assign({},a);d[r]&&(d[r]=[]),o&&(d=o(d,{oldNode:a,index:i,parent:h,path:s})),l.set(s,d)},{childrenKey:r}),l.data}class me{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];te(this,"data",void 0),te(this,"childrenKey","children"),this.data=t}get rootChildren(){const{childrenKey:t}=this,{data:n}=this;return ie(n)?n:n[t]}*iteratePath(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const{childrenKey:r,rootChildren:o}=this;if(n.reverse){const l=[...this.iteratePath(t,{...n,reverse:!1})];l.reverse();for(const{path:a,node:i}of l)yield{path:a,node:i}}else{let l=[],a=o;for(const i of t){const h=[...l,i],s=a[i];yield{path:h,node:s},l=h,a=s[r]}}}getFamily(t){const n=[];for(const{node:r}of this.iteratePath(t))n.push(r);return n}get(t){return Ne(this.getFamily(t))}getParentAndIndex(t){const n=t.slice(),r=n.pop();return{parent:this.get(n),index:r,parentPath:n}}getParent(t){return this.getParentAndIndex(t).parent}set(t,n){if(t==null||t.length===0)this.data=n;else{const{childrenKey:r}=this;let{rootChildren:o}=this;const{parent:l,index:a}=this.getParentAndIndex(t);let i;t.length===1?(o||(this.data?this.data[r]=[]:this.data=[]),i=o):(l[r]||(l[r]=[]),i=l[r]),i[a]=n}}delete(t){const{childrenKey:n,rootChildren:r}=this,{parent:o,index:l}=this.getParentAndIndex(t),a=t.length===1?r:o[n],i=a[l];return a.splice(l,1),i}walk(t,n){const{childrenKey:r,data:o}=this;return V(o,t,r,n)}clone(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return $e(this.data),qe({childrenKey:this.childrenKey,nodeHandler:t.nodeHandler||void 0})}}function Be(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];return He(e)?e(...t):e}function Ge(e,t){return function(){let r,o;try{r=e(...arguments)}catch(l){o=l}finally{}if(o)throw o;return r}}function ne(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const n=[];let r;const o={};let l=o;return{action:function(){for(var h=arguments.length,s=new Array(h),d=0;d<h;d++)s[d]=arguments[d];if(s.length===0)return l===o&&(l=e()),l;if(r||(r=new nt),!r.has(s)&&(r.set(s,e(...s)),t.capacity!=null)){n.push(s);const u=n.splice(0,n.length-t.capacity);for(const c of u)r.delete(c)}return r.get(s)},clearCache:()=>{r=null,n.splice(0,n.length)}}}function Qe(){let e,t;return{promise:new Promise((r,o)=>{e=r,t=o}),resolve:e,reject:t}}function et(e,t){for(;;){if(e.parentNode==null)return!1;if(e.parentNode===t)return!0;e=e.parentNode}}function ye(e){let t=e.getBoundingClientRect();if(document.documentElement.clientTop>0){const n=t.top-document.documentElement.clientTop,r=t.bottom,o=t.left-document.documentElement.clientLeft,l=t.right,a=t.width||l-o,i=t.height||r-n,d={top:n,right:l,bottom:r,left:o,width:a,height:i,x:o,y:n};t={...d,toJSON:()=>d}}return t}function Le(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},r=n&&n.withSelf?e:e.parentElement;for(;r;){const o=n.until&&r===n.until;if(o&&!n.withUntil)return;const l=t(r);if(l==="break")return;if(l)return r;if(o)return;r=r.parentElement}}function ae(e,t){return e.classList?e.classList.contains(t):new RegExp("(^| )"+t+"( |$)","gi").test(e.className)}function Te(e,t){for(const n of t)if(ae(e,n))return!0;return!1}function R(e,t,n,r){e.addEventListener?e.addEventListener(t,n,r):e.attachEvent&&e.attachEvent("on".concat(t),n,r)}function H(e,t,n,r){e.removeEventListener?e.removeEventListener(t,n,r):e.detachEvent&&e.detachEvent("on".concat(t),n,r)}function tt(e){let t=[];const o={listening:!1,stop:()=>{if(o.listening){for(const l of t)l();t=[],o.listening=!1}},resume:()=>{if(!o.listening){for(const l of e){R.apply(this,l);const a=()=>H.apply(this,l);t.push(a)}o.listening=!0}}};return o}function oe(e,t){return getComputedStyle(e)[t]}function ve(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};n={start:0,end:e.length-1,maxTimes:1e3,...n};let{start:r,end:o}=n;const{returnNearestIfNoHit:l,maxTimes:a}=n;let i,h;r==null&&(r=0,o=e.length-1);let s=0,d;for(;r>=0&&r<=o;){if(s>=a)throw Error("binarySearch: loop times is over ".concat(a,", you can increase the limit."));i=Math.floor((o-r)/2+r),h=e[i];const u=s+1;if(d=t(h,i,u),d>0)o=i-1;else if(d<0)r=i+1;else return{index:i,value:h,count:u,hit:!0};s++}return l?{index:i,value:h,count:s+1,hit:!1,greater:d>0}:null}class nt{constructor(){te(this,"_map",new Map),te(this,"_values",{}),te(this,"_objCount",0)}_keysToString(t){const{_map:n}=this;let r=[];for(const o of t){if(!n.has(o))return null;r.push(n.get(o)[0])}return r.toString()}has(t){return this._keysToString(t)!=null}get(t){const{_values:n}=this,r=this._keysToString(t);if(r==null)throw"Value not found by specified keys";return n[r][1]}set(t,n){const{_map:r,_values:o}=this;let l=[];for(const a of t){let i,h=1;r.has(a)?([i,h]=r.get(a),h++):(this._objCount++,i=this._objCount.toString()),r.set(a,[i,h]),l.push(i)}o[l.toString()]=[t.slice(),n]}delete(t){const{_values:n,_map:r}=this,o=this._keysToString(t);if(o==null)throw"Value not found by specified keys";delete n[o];for(const l of t){let[a,i]=r.get(l);i--,i===0?r.delete(l):r.set(l,[a,i])}}clear(){this._map.clear(),this._values={}}*entries(){const{_values:t}=this;for(const n in t){const[r,o]=t[n];yield[r,o]}}count(){return[...this.entries()].length}}/*! | ||
*/function ie(e){return Object.prototype.toString.call(e)==="[object Array]"}function xe(e){return Object.prototype.toString.call(e)==="[object Object]"}function Ue(e){return typeof e=="function"}function We(e,t){return e<t?e:t}function Ne(e,t){let n,r=0;for(;(n=e.indexOf(t))>-1;)e.splice(n,1),r++;return r}function _e(e){return e[e.length-1]}function je(e){return ie(e)?e:[e]}function Xe(e,t){let n=new Set(t);const r={};return n.forEach(o=>{r[o]=e[o]}),r}function*Ye(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(t.reverse)if(e.length!=null)for(let n=e.length-1;n>=0;n--){const r={value:e[n],index:n};(!t.exclude||!t.exclude(r))&&(yield r)}else if(xe(e)){const n=Object.keys(e);n.reverse();for(const r of n){const o={value:e[r],key:r};(!t.exclude||!t.exclude(o))&&(yield o)}}else throw"Unsupported type";else if(e.length!=null)for(let n=0;n<e.length;n++){const r={value:e[n],index:n};(!t.exclude||!t.exclude(r))&&(yield r)}else if(xe(e))for(const n of Object.keys(e)){const r={value:e[n],key:n};(!t.exclude||!t.exclude(r))&&(yield r)}else throw"Unsupported type"}function qe(e,t,n){e.hasOwnProperty(t)||(e[t]=n)}function $e(e,t){return Object.keys(t).forEach(n=>{qe(e,n,t[n])}),e}function Je(e){const t={};return Object.keys(e).forEach(n=>{e[n]!==void 0&&(t[n]=e[n])}),t}function V(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};n=$e({...n},{childrenKey:"children"});const{childrenKey:r}=n,o=ie(e)?e:[e];class l{}const a=(i,h,s)=>{n.reverse&&(i=i.slice(),i.reverse());const d=i.length;for(let u=0;u<d;u++){const c=i[u],p=n.reverse?d-u-1:u,m=s?[...s,p]:[];n.childFirst&&c[r]!=null&&a(c[r],c,m);const S=t(c,p,h,m);if(S===!1)throw new l;if(S==="skip children")continue;if(S==="skip siblings")break;n.childFirst||c[r]!=null&&a(c[r],c,m)}};try{a(o,null,ie(e)?[]:null)}catch(i){if(!(i instanceof l))throw i}}function Ze(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},r;return V(e,function(){if(t(...arguments))return r={node:arguments.length<=0?void 0:arguments[0],index:arguments.length<=1?void 0:arguments[1],parent:arguments.length<=2?void 0:arguments[2],path:arguments.length<=3?void 0:arguments[3]},!1},n),r}function Ge(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const r=Ze(e,t,n);return r==null?void 0:r.node}function Be(e,t){const n={childrenKey:"children"};t&&Object.assign(n,t);const{childrenKey:r,nodeHandler:o}=n,l=new me;return l.childrenKey=r,V(e,(a,i,h,s)=>{let d=Object.assign({},a);d[r]&&(d[r]=[]),o&&(d=o(d,{oldNode:a,index:i,parent:h,path:s})),l.set(s,d)},{childrenKey:r}),l.data}class me{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];te(this,"data",void 0),te(this,"childrenKey","children"),this.data=t}get rootChildren(){const{childrenKey:t}=this,{data:n}=this;return ie(n)?n:n[t]}*iteratePath(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const{childrenKey:r,rootChildren:o}=this;if(n.reverse){const l=[...this.iteratePath(t,{...n,reverse:!1})];l.reverse();for(const{path:a,node:i}of l)yield{path:a,node:i}}else{let l=[],a=o;for(const i of t){const h=[...l,i],s=a[i];yield{path:h,node:s},l=h,a=s[r]}}}getFamily(t){const n=[];for(const{node:r}of this.iteratePath(t))n.push(r);return n}get(t){return _e(this.getFamily(t))}getParentAndIndex(t){const n=t.slice(),r=n.pop();return{parent:this.get(n),index:r,parentPath:n}}getParent(t){return this.getParentAndIndex(t).parent}set(t,n){if(t==null||t.length===0)this.data=n;else{const{childrenKey:r}=this;let{rootChildren:o}=this;const{parent:l,index:a}=this.getParentAndIndex(t);let i;t.length===1?(o||(this.data?this.data[r]=[]:this.data=[]),i=o):(l[r]||(l[r]=[]),i=l[r]),i[a]=n}}delete(t){const{childrenKey:n,rootChildren:r}=this,{parent:o,index:l}=this.getParentAndIndex(t),a=t.length===1?r:o[n],i=a[l];return a.splice(l,1),i}walk(t,n){const{childrenKey:r,data:o}=this;return V(o,t,r,n)}clone(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return Be(this.data),Je({childrenKey:this.childrenKey,nodeHandler:t.nodeHandler||void 0})}}function Le(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];return Ue(e)?e(...t):e}function Qe(e,t){return function(){let r,o;try{r=e(...arguments)}catch(l){o=l}finally{}if(o)throw o;return r}}function ne(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const n=[];let r;const o={};let l=o;return{action:function(){for(var h=arguments.length,s=new Array(h),d=0;d<h;d++)s[d]=arguments[d];if(s.length===0)return l===o&&(l=e()),l;if(r||(r=new rt),!r.has(s)&&(r.set(s,e(...s)),t.capacity!=null)){n.push(s);const u=n.splice(0,n.length-t.capacity);for(const c of u)r.delete(c)}return r.get(s)},clearCache:()=>{r=null,n.splice(0,n.length)}}}function et(){let e,t;return{promise:new Promise((r,o)=>{e=r,t=o}),resolve:e,reject:t}}function tt(e,t){for(;;){if(e.parentNode==null)return!1;if(e.parentNode===t)return!0;e=e.parentNode}}function ye(e){let t=e.getBoundingClientRect();if(document.documentElement.clientTop>0){const n=t.top-document.documentElement.clientTop,r=t.bottom,o=t.left-document.documentElement.clientLeft,l=t.right,a=t.width||l-o,i=t.height||r-n,d={top:n,right:l,bottom:r,left:o,width:a,height:i,x:o,y:n};t={...d,toJSON:()=>d}}return t}function Te(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},r=n&&n.withSelf?e:e.parentElement;for(;r;){const o=n.until&&r===n.until;if(o&&!n.withUntil)return;const l=t(r);if(l==="break")return;if(l)return r;if(o)return;r=r.parentElement}}function ae(e,t){return e.classList?e.classList.contains(t):new RegExp("(^| )"+t+"( |$)","gi").test(e.className)}function Fe(e,t){for(const n of t)if(ae(e,n))return!0;return!1}function R(e,t,n,r){e.addEventListener?e.addEventListener(t,n,r):e.attachEvent&&e.attachEvent("on".concat(t),n,r)}function H(e,t,n,r){e.removeEventListener?e.removeEventListener(t,n,r):e.detachEvent&&e.detachEvent("on".concat(t),n,r)}function nt(e){let t=[];const o={listening:!1,stop:()=>{if(o.listening){for(const l of t)l();t=[],o.listening=!1}},resume:()=>{if(!o.listening){for(const l of e){R.apply(this,l);const a=()=>H.apply(this,l);t.push(a)}o.listening=!0}}};return o}function oe(e,t){return getComputedStyle(e)[t]}function ve(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};n={start:0,end:e.length-1,maxTimes:1e3,...n};let{start:r,end:o}=n;const{returnNearestIfNoHit:l,maxTimes:a}=n;let i,h;r==null&&(r=0,o=e.length-1);let s=0,d;for(;r>=0&&r<=o;){if(s>=a)throw Error("binarySearch: loop times is over ".concat(a,", you can increase the limit."));i=Math.floor((o-r)/2+r),h=e[i];const u=s+1;if(d=t(h,i,u),d>0)o=i-1;else if(d<0)r=i+1;else return{index:i,value:h,count:u,hit:!0};s++}return l?{index:i,value:h,count:s+1,hit:!1,greater:d>0}:null}class rt{constructor(){te(this,"_map",new Map),te(this,"_values",{}),te(this,"_objCount",0)}_keysToString(t){const{_map:n}=this;let r=[];for(const o of t){if(!n.has(o))return null;r.push(n.get(o)[0])}return r.toString()}has(t){return this._keysToString(t)!=null}get(t){const{_values:n}=this,r=this._keysToString(t);if(r==null)throw"Value not found by specified keys";return n[r][1]}set(t,n){const{_map:r,_values:o}=this;let l=[];for(const a of t){let i,h=1;r.has(a)?([i,h]=r.get(a),h++):(this._objCount++,i=this._objCount.toString()),r.set(a,[i,h]),l.push(i)}o[l.toString()]=[t.slice(),n]}delete(t){const{_values:n,_map:r}=this,o=this._keysToString(t);if(o==null)throw"Value not found by specified keys";delete n[o];for(const l of t){let[a,i]=r.get(l);i--,i===0?r.delete(l):r.set(l,[a,i])}}clear(){this._map.clear(),this._values={}}*entries(){const{_values:t}=this;for(const n in t){const[r,o]=t[n];yield[r,o]}}count(){return[...this.entries()].length}}/*! | ||
* @virtual-list/vue | ||
@@ -17,3 +17,3 @@ * Author: phphe <phphe@outlook.com> (https://github.com/phphe) | ||
* Released under the MIT License. | ||
*/var Fe=(e,t)=>{const n=e.__vccOpts||e;for(const[r,o]of t)n[r]=o;return n};const rt=S.defineComponent({props:{table:Boolean}}),lt={key:0},it={key:1};function at(e,t,n,r,o,l){return e.table?(f.openBlock(),f.createElementBlock("table",lt,[f.renderSlot(e.$slots,"prepend"),f.createElementVNode("tbody",null,[f.renderSlot(e.$slots,"default")]),f.renderSlot(e.$slots,"append")])):(f.openBlock(),f.createElementBlock("div",it,[f.renderSlot(e.$slots,"prepend"),f.renderSlot(e.$slots,"default"),f.renderSlot(e.$slots,"append")]))}var ot=Fe(rt,[["render",at]]);const st=S.defineComponent({components:{VirtualListTable:ot},props:{items:Array,disabled:Boolean,horizontal:Boolean,firstRender:{type:Number,default:10},buffer:{type:Number,default:100},itemKey:{type:[String,Function]},itemSize:{type:Function},table:Boolean},setup(e){const t=S.ref(0),n=S.ref(e.firstRender-1),r=S.computed(()=>{var b;return Ue(n.value,(((b=e.items)==null?void 0:b.length)||1)-1)}),o=S.ref(0),l=S.computed(()=>c.value[t.value]?ee(t.value):0),a=S.computed(()=>c.value.length>0?ee(c.value.length-1)+Ne(u.value):0),i=S.computed(()=>c.value[r.value]?a.value-ee(r.value)-u.value[r.value]:0),h=S.computed(()=>e.disabled?{}:{overflow:"auto"}),s=S.computed(()=>{const b={display:"flex"};return e.disabled||(e.horizontal?Object.assign(b,{"margin-left":l.value+"px","margin-right":i.value+"px",width:a.value-i.value-l.value+"px"}):Object.assign(b,{"margin-top":l.value+"px","margin-bottom":i.value+"px"})),b["flex-direction"]=e.horizontal?"row":"column",e.table&&(delete b.display,delete b["flex-direction"]),b}),d=S.computed(()=>S.reactive((e.items||[]).map(()=>null))),u=S.computed(()=>(e.items||[]).map((b,v)=>{var C;if(d[v]!=null)return d[v];let w=(C=e.itemSize)==null?void 0:C.call(e,b,v);return w==null&&(w=o.value),w})),c=S.computed(()=>{const b=[];return u.value.reduce((v,C)=>(b.push(v),v+C),0),b});S.watch(()=>e.items,O);const p=S.computed(()=>{if(!e.items||e.disabled)return;const b=[];for(let v=t.value;v<=r.value;v++){const C=e.items[v];if(!C)break;b.push({item:C,index:v})}return b}),m=S.ref(),k=S.ref();S.onMounted(async()=>{O();try{De()}catch{await S.nextTick(),O()}});let E;function $(){const b=m.value;if(!b)return;const v=X(b);E!=null&&e.buffer-Math.abs(v-E)>=10||(E=v,O())}let D=!1,z=!1;async function O(){var b;if(D){z=!0;return}if(!e.items||e.disabled)return;D=!0;const v=m.value,C=(b=k.value)==null?void 0:b.$el;if(!v||!C)return;o.value||(o.value=ge()),t.value=J(),n.value=Z(),await S.nextTick();let w,L=0;const A={},j=e.table?C.querySelector("tbody").children:C.children;for(let K=0;K<j.length;K++){const N=j[K],x=oe(N,"position");if(x&&["absolute","fixed"].includes(x))continue;const _=oe(N,"display")!=="none"?Q(N):0,T=N.getAttribute("vt-index"),G=T?parseInt(T):t.value+L;A[G]=(A[G]||0)+_,L++}for(const K of Object.keys(A)){const N=parseInt(K);d.value[N]!==A[N]&&(d.value[N]=A[N],w=!0)}w&&await S.nextTick(),D=!1,z&&(z=!1,O());function J(){const K=X(v)-I(v)-e.buffer;return ve(c.value,x=>x-K,{returnNearestIfNoHit:!0}).index}function Z(){const K=X(v)-I(v)+U(v)+e.buffer;return ve(c.value,x=>x-K,{returnNearestIfNoHit:!0}).index}function ge(){const N=[],x=e.table?C.querySelector("tbody").children:C.children;for(let _=0;_<x.length;_++){const T=x[_],G=getComputedStyle(T);if(["absolute","fixed"].includes(G.position))continue;const pe=Q(T);if(N.push(pe),N.length>=10)break}return N.length===0?0:N.reduce((_,T)=>_+T,0)/N.length}}function U(b){const v=getComputedStyle(b);let C=parseFloat(e.horizontal?v.width:v.height);return v.boxSizing==="border-box"&&(e.horizontal?C=C-parseFloat(v.borderLeftWidth)-parseFloat(v.borderRightWidth):C=C-parseFloat(v.borderTopWidth)-parseFloat(v.borderBottomWidth)),C}function Q(b){let v=U(b);const C=getComputedStyle(b);return e.horizontal?v+=parseFloat(C.borderLeftWidth)+parseFloat(C.borderRightWidth)+parseFloat(C.marginLeft)+parseFloat(C.marginRight):v+=parseFloat(C.borderTopWidth)+parseFloat(C.borderBottomWidth)+parseFloat(C.marginTop)+parseFloat(C.marginBottom),v=Number.isNaN(v)?0:v,v}function X(b){return e.horizontal?b.scrollLeft:b.scrollTop}function I(b){const v=getComputedStyle(b);return e.horizontal?parseFloat(v.paddingLeft):parseFloat(v.paddingTop)}function ee(b){return c.value[b]}function De(){const b=m.value;new ResizeObserver(C=>{for(let w of C)if(ae(w.target,"vtlist")){O();break}}).observe(b)}function he(b,v){if(e.itemKey){if(typeof e.itemKey=="string"&&e.itemKey==="index")return v;if(typeof e.itemKey=="function")return e.itemKey(b,v)}}return{listElRef:m,listInnerRef:k,onscroll:$,listStyle:h,listInnerStyle:s,visibleItemsInfo:p,getItemKey:he,update:O,sizes:u,positions:c,runtimeSizes:d}}});function dt(e,t,n,r,o,l){const a=f.resolveComponent("VirtualListTable");return f.openBlock(),f.createElementBlock("div",{class:"vtlist",ref:"listElRef",style:f.normalizeStyle(e.listStyle),onScrollPassive:t[0]||(t[0]=(...i)=>e.onscroll&&e.onscroll(...i))},[f.createVNode(a,{class:"vtlist-inner",ref:"listInnerRef",style:f.normalizeStyle(e.listInnerStyle),table:e.table},{prepend:f.withCtx(()=>[f.renderSlot(e.$slots,"prepend")]),append:f.withCtx(()=>[f.renderSlot(e.$slots,"append")]),default:f.withCtx(()=>[e.disabled?(f.openBlock(!0),f.createElementBlock(f.Fragment,{key:0},f.renderList(e.items,(i,h)=>f.renderSlot(e.$slots,"default",{key:e.getItemKey(i,h),item:i,index:h})),128)):(f.openBlock(!0),f.createElementBlock(f.Fragment,{key:1},f.renderList(e.visibleItemsInfo,({item:i,index:h})=>f.renderSlot(e.$slots,"default",{key:e.getItemKey(i,h),item:i,index:h})),128))]),_:3},8,["style","table"])],36)}var ct=Fe(st,[["render",dt]]);let se=!1;const ut=()=>{se=!0,setTimeout(()=>{se=!1},100)},ft=S.defineComponent({props:["stat","rtl","btt","indent","table","treeLine","treeLineOffset","processor"],emits:["open","close","check"],setup(e,{emit:t}){const n=S.computed(()=>({[e.rtl?"paddingRight":"paddingLeft"]:e.indent*(e.stat.level-1)+"px"}));S.watch(()=>e.stat.checked,l=>{se||e.processor.afterOneCheckChanged(e.stat)&&t("check",e.stat)}),S.watch(()=>e.stat.open,l=>{se||(t(l?"open":"close",e.stat),ut())});const r=S.computed(()=>{const l=[],a=d=>{var u;if(d.parent){let c=(u=d.parent)==null?void 0:u.children.indexOf(d);do{c++;let p=d.parent.children[c];if(p){if(!p.hidden)return!0}else break}while(!0)}return!1},i=e.rtl?"right":"left",h=e.btt?"top":"bottom";let s=e.stat;for(;s;){let d=(s.level-2)*e.indent+e.treeLineOffset;const u=a(s),c=()=>{l.push({style:{[i]:d+"px",[h]:u?0:"50%"}})};s===e.stat?s.level>1&&c():u&&c(),s=s.parent}return l}),o=S.computed(()=>{let l=(e.stat.level-2)*e.indent+e.treeLineOffset;return{[e.rtl?"right":"left"]:l+"px"}});return{indentStyle:n,vLines:r,hLineStyle:o}}}),be=(e,t)=>{const n=e.__vccOpts||e;for(const[r,o]of t)n[r]=o;return n},ht={class:"tree-node-inner"},gt={key:1,class:"tree-node",ref:"el"};function pt(e,t,n,r,o,l){return e.table?(f.openBlock(),f.createElementBlock("tr",gt,[f.renderSlot(e.$slots,"default",{indentStyle:e.indentStyle})],512)):(f.openBlock(),f.createElementBlock("div",{key:0,class:f.normalizeClass(["tree-node",{"tree-node--with-tree-line":e.treeLine}]),style:f.normalizeStyle(e.indentStyle),ref:"el"},[e.treeLine?(f.openBlock(),f.createElementBlock(f.Fragment,{key:0},[(f.openBlock(!0),f.createElementBlock(f.Fragment,null,f.renderList(e.vLines,a=>(f.openBlock(),f.createElementBlock("div",{class:"tree-line tree-vline",style:f.normalizeStyle(a.style)},null,4))),256)),e.stat.level>1?(f.openBlock(),f.createElementBlock("div",{key:0,class:"tree-line tree-hline",style:f.normalizeStyle(e.hLineStyle)},null,4)):f.createCommentVNode("",!0)],64)):f.createCommentVNode("",!0),f.createElementVNode("div",ht,[f.renderSlot(e.$slots,"default",{indentStyle:e.indentStyle})])],6))}const Pe=be(ft,[["render",pt]]);/*! | ||
*/var Pe=(e,t)=>{const n=e.__vccOpts||e;for(const[r,o]of t)n[r]=o;return n};const lt=k.defineComponent({props:{table:Boolean}}),it={key:0},at={key:1};function ot(e,t,n,r,o,l){return e.table?(f.openBlock(),f.createElementBlock("table",it,[f.renderSlot(e.$slots,"prepend"),f.createElementVNode("tbody",null,[f.renderSlot(e.$slots,"default")]),f.renderSlot(e.$slots,"append")])):(f.openBlock(),f.createElementBlock("div",at,[f.renderSlot(e.$slots,"prepend"),f.renderSlot(e.$slots,"default"),f.renderSlot(e.$slots,"append")]))}var st=Pe(lt,[["render",ot]]);const dt=k.defineComponent({components:{VirtualListTable:st},props:{items:Array,disabled:Boolean,horizontal:Boolean,firstRender:{type:Number,default:10},buffer:{type:Number,default:100},itemKey:{type:[String,Function]},itemSize:{type:Function},table:Boolean},setup(e){const t=k.ref(0),n=k.ref(e.firstRender-1),r=k.computed(()=>{var b;return We(n.value,(((b=e.items)==null?void 0:b.length)||1)-1)}),o=k.ref(0),l=k.computed(()=>c.value[t.value]?ee(t.value):0),a=k.computed(()=>c.value.length>0?ee(c.value.length-1)+_e(u.value):0),i=k.computed(()=>c.value[r.value]?a.value-ee(r.value)-u.value[r.value]:0),h=k.computed(()=>e.disabled?{}:{overflow:"auto"}),s=k.computed(()=>{const b={display:"flex"};return e.disabled||(e.horizontal?Object.assign(b,{"margin-left":l.value+"px","margin-right":i.value+"px",width:a.value-i.value-l.value+"px"}):Object.assign(b,{"margin-top":l.value+"px","margin-bottom":i.value+"px"})),b["flex-direction"]=e.horizontal?"row":"column",e.table&&(delete b.display,delete b["flex-direction"]),b}),d=k.computed(()=>k.reactive((e.items||[]).map(()=>null))),u=k.computed(()=>(e.items||[]).map((b,v)=>{var C;if(d[v]!=null)return d[v];let w=(C=e.itemSize)==null?void 0:C.call(e,b,v);return w==null&&(w=o.value),w})),c=k.computed(()=>{const b=[];return u.value.reduce((v,C)=>(b.push(v),v+C),0),b});k.watch(()=>e.items,O);const p=k.computed(()=>{if(!e.items||e.disabled)return;const b=[];for(let v=t.value;v<=r.value;v++){const C=e.items[v];if(!C)break;b.push({item:C,index:v})}return b}),m=k.ref(),S=k.ref();k.onMounted(async()=>{O();try{Oe()}catch{await k.nextTick(),O()}});let E;function $(){const b=m.value;if(!b)return;const v=X(b);E!=null&&e.buffer-Math.abs(v-E)>=10||(E=v,O())}let D=!1,z=!1;async function O(){var b;if(D){z=!0;return}if(!e.items||e.disabled)return;D=!0;const v=m.value,C=(b=S.value)==null?void 0:b.$el;if(!v||!C)return;o.value||(o.value=ge()),t.value=J(),n.value=Z(),await k.nextTick();let w,L=0;const A={},j=e.table?C.querySelector("tbody").children:C.children;for(let K=0;K<j.length;K++){const N=j[K],x=oe(N,"position");if(x&&["absolute","fixed"].includes(x))continue;const _=oe(N,"display")!=="none"?Q(N):0,T=N.getAttribute("vt-index"),G=T?parseInt(T):t.value+L;A[G]=(A[G]||0)+_,L++}for(const K of Object.keys(A)){const N=parseInt(K);d.value[N]!==A[N]&&(d.value[N]=A[N],w=!0)}w&&await k.nextTick(),D=!1,z&&(z=!1,O());function J(){const K=X(v)-I(v)-e.buffer;return ve(c.value,x=>x-K,{returnNearestIfNoHit:!0}).index}function Z(){const K=X(v)-I(v)+U(v)+e.buffer;return ve(c.value,x=>x-K,{returnNearestIfNoHit:!0}).index}function ge(){const N=[],x=e.table?C.querySelector("tbody").children:C.children;for(let _=0;_<x.length;_++){const T=x[_],G=getComputedStyle(T);if(["absolute","fixed"].includes(G.position))continue;const pe=Q(T);if(N.push(pe),N.length>=10)break}return N.length===0?0:N.reduce((_,T)=>_+T,0)/N.length}}function U(b){const v=getComputedStyle(b);let C=parseFloat(e.horizontal?v.width:v.height);return v.boxSizing==="border-box"&&(e.horizontal?C=C-parseFloat(v.borderLeftWidth)-parseFloat(v.borderRightWidth):C=C-parseFloat(v.borderTopWidth)-parseFloat(v.borderBottomWidth)),C}function Q(b){let v=U(b);const C=getComputedStyle(b);return e.horizontal?v+=parseFloat(C.borderLeftWidth)+parseFloat(C.borderRightWidth)+parseFloat(C.marginLeft)+parseFloat(C.marginRight):v+=parseFloat(C.borderTopWidth)+parseFloat(C.borderBottomWidth)+parseFloat(C.marginTop)+parseFloat(C.marginBottom),v=Number.isNaN(v)?0:v,v}function X(b){return e.horizontal?b.scrollLeft:b.scrollTop}function I(b){const v=getComputedStyle(b);return e.horizontal?parseFloat(v.paddingLeft):parseFloat(v.paddingTop)}function ee(b){return c.value[b]}function Oe(){const b=m.value;new ResizeObserver(C=>{for(let w of C)if(ae(w.target,"vtlist")){O();break}}).observe(b)}function he(b,v){if(e.itemKey){if(typeof e.itemKey=="string"&&e.itemKey==="index")return v;if(typeof e.itemKey=="function")return e.itemKey(b,v)}}return{listElRef:m,listInnerRef:S,onscroll:$,listStyle:h,listInnerStyle:s,visibleItemsInfo:p,getItemKey:he,update:O,sizes:u,positions:c,runtimeSizes:d}}});function ct(e,t,n,r,o,l){const a=f.resolveComponent("VirtualListTable");return f.openBlock(),f.createElementBlock("div",{class:"vtlist",ref:"listElRef",style:f.normalizeStyle(e.listStyle),onScrollPassive:t[0]||(t[0]=(...i)=>e.onscroll&&e.onscroll(...i))},[f.createVNode(a,{class:"vtlist-inner",ref:"listInnerRef",style:f.normalizeStyle(e.listInnerStyle),table:e.table},{prepend:f.withCtx(()=>[f.renderSlot(e.$slots,"prepend")]),append:f.withCtx(()=>[f.renderSlot(e.$slots,"append")]),default:f.withCtx(()=>[e.disabled?(f.openBlock(!0),f.createElementBlock(f.Fragment,{key:0},f.renderList(e.items,(i,h)=>f.renderSlot(e.$slots,"default",{key:e.getItemKey(i,h),item:i,index:h})),128)):(f.openBlock(!0),f.createElementBlock(f.Fragment,{key:1},f.renderList(e.visibleItemsInfo,({item:i,index:h})=>f.renderSlot(e.$slots,"default",{key:e.getItemKey(i,h),item:i,index:h})),128))]),_:3},8,["style","table"])],36)}var ut=Pe(dt,[["render",ct]]);let se=!1;const ft=()=>{se=!0,setTimeout(()=>{se=!1},100)},ht=k.defineComponent({props:["stat","rtl","btt","indent","table","treeLine","treeLineOffset","processor"],emits:["open","close","check"],setup(e,{emit:t}){const n=k.computed(()=>({[e.rtl?"paddingRight":"paddingLeft"]:e.indent*(e.stat.level-1)+"px"}));k.watch(()=>e.stat.checked,l=>{se||e.processor.afterOneCheckChanged(e.stat)&&t("check",e.stat)}),k.watch(()=>e.stat.open,l=>{se||(t(l?"open":"close",e.stat),ft())});const r=k.computed(()=>{const l=[],a=d=>{var u;if(d.parent){let c=(u=d.parent)==null?void 0:u.children.indexOf(d);do{c++;let p=d.parent.children[c];if(p){if(!p.hidden)return!0}else break}while(!0)}return!1},i=e.rtl?"right":"left",h=e.btt?"top":"bottom";let s=e.stat;for(;s;){let d=(s.level-2)*e.indent+e.treeLineOffset;const u=a(s),c=()=>{l.push({style:{[i]:d+"px",[h]:u?0:"50%"}})};s===e.stat?s.level>1&&c():u&&c(),s=s.parent}return l}),o=k.computed(()=>{let l=(e.stat.level-2)*e.indent+e.treeLineOffset;return{[e.rtl?"right":"left"]:l+"px"}});return{indentStyle:n,vLines:r,hLineStyle:o}}}),be=(e,t)=>{const n=e.__vccOpts||e;for(const[r,o]of t)n[r]=o;return n},gt={class:"tree-node-inner"},pt={key:1,class:"tree-node",ref:"el"};function mt(e,t,n,r,o,l){return e.table?(f.openBlock(),f.createElementBlock("tr",pt,[f.renderSlot(e.$slots,"default",{indentStyle:e.indentStyle})],512)):(f.openBlock(),f.createElementBlock("div",{key:0,class:f.normalizeClass(["tree-node",{"tree-node--with-tree-line":e.treeLine}]),style:f.normalizeStyle(e.indentStyle),ref:"el"},[e.treeLine?(f.openBlock(),f.createElementBlock(f.Fragment,{key:0},[(f.openBlock(!0),f.createElementBlock(f.Fragment,null,f.renderList(e.vLines,a=>(f.openBlock(),f.createElementBlock("div",{class:"tree-line tree-vline",style:f.normalizeStyle(a.style)},null,4))),256)),e.stat.level>1?(f.openBlock(),f.createElementBlock("div",{key:0,class:"tree-line tree-hline",style:f.normalizeStyle(e.hLineStyle)},null,4)):f.createCommentVNode("",!0)],64)):f.createCommentVNode("",!0),f.createElementVNode("div",gt,[f.renderSlot(e.$slots,"default",{indentStyle:e.indentStyle})])],6))}const Ie=be(ht,[["render",mt]]);/*! | ||
* @he-tree/tree-utils v0.1.0-alpha.5 | ||
@@ -23,3 +23,3 @@ * Author: phphe <phphe@outlook.com> (https://github.com/phphe) | ||
* Released under the MIT License. | ||
*/const Y="children";function mt(e){const n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r={...yt,...n,data:e,stats:null,statsFlat:null,_statsMap:null,initialized:!1,init(){const{data:l,childrenKey:a}=this,i=new me([]);this._statsMap=new Map,V(l,(s,d,u,c)=>{const p=this.statHandler({...Ie(),data:s,open:!!this.defaultOpen,parent:i.getParent(c),children:[],level:c.length});this._statsMap.set(s,p),i.set(c,p)},{childrenKey:a});const h=[];i.walk(s=>{h.push(s)}),this.stats=this.statsHandler(i.rootChildren),this.statsFlat=this.statsFlatHandler(h),this.initialized=!0},getStat(l){let a=this._statsMap.get(l);if(!a)throw new Ae("Stat not found");return a},has(l){if(l.isStat)return this.statsFlat.indexOf(l)>-1;try{return!!this.getStat(l)}catch(a){if(a instanceof Ae)return!1;throw a}},_getPathByStat(l){if(l==null)return[];const i=this.getSiblings(l).indexOf(l);return[...l.parent?this._getPathByStat(l.parent):[],i]},afterOneCheckChanged(l){const{checked:a}=l;if(l._ignoreCheckedOnce)return delete l._ignoreCheckedOnce,!1;const i=h=>{const{parent:s}=h;if(s){let d,u,c;for(const m of s.children)m.checked?d=!0:m.checked===0?c=!0:u=!0;const p=c?0:u?d?0:!1:!0;s.checked!==p&&(this._ignoreCheckedOnce(s),s.checked=p),i(s)}};return i(l),V(l.children,h=>{h.checked!==a&&(this._ignoreCheckedOnce(h),h.checked=a)},{childrenKey:Y}),!0},_ignoreCheckedOnce(l){l._ignoreCheckedOnce=!0,setTimeout(()=>{l._ignoreCheckedOnce&&(l._ignoreCheckedOnce=!1)},100)},isVisible(l){const a=l.isStat?l:this.getStat(l),i=h=>!h||!h.hidden&&h.open&&i(h.parent);return!!(!a.hidden&&i(a.parent))},updateCheck(){V(this.stats,l=>{if(l.children&&l.children.length>0){const a=l.children.every(i=>i.checked);l.checked!==a&&(this._ignoreCheckedOnce(l),l.checked=a)}},{childFirst:!0,childrenKey:Y})},getChecked(){let l=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1;return this.statsFlat.filter(a=>a.checked||l&&a.checked===0)},getUnchecked(){let l=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;return this.statsFlat.filter(a=>l?!a.checked:a.checked===!1)},openAll(){for(const l of this.statsFlat)l.open=!0},closeAll(){for(const l of this.statsFlat)l.open=!1},openNodeAndParents(l){const a=l.isStat?l:this.getStat(l);for(const i of this.iterateParent(a,{withSelf:!0}))i.open=!0},_calcFlatIndex(l,a){let i=l?this.statsFlat.indexOf(l)+1:0;const h=l?l.children:this.stats;for(let s=0;s<a;s++)i+=this._count(h[s]);return i},add(l,a,i){if(this.has(l))throw"Can't add because data exists in tree";const h=a?a.children:this.stats;i==null&&(i=h.length);const s=this.statHandler({...Ie(),open:!!this.defaultOpen,data:l,parent:a||null,children:[],level:a?a.level+1:1});this._setPosition(s,a||null,i);const d=l[this.childrenKey];if(d){const u=d.slice();for(const c of u)this.add(c,s)}},remove(l){const a=this.getSiblings(l);if(a.includes(l)){xe(a,l);const i=this._flat(l);this.statsFlat.splice(this.statsFlat.indexOf(l),i.length);for(const h of i)this._statsMap.delete(h.data);return this.afterRemoveStat(l),!0}return!1},getSiblings(l){const{parent:a}=l;return a?a.children:this.stats},_setPosition(l,a,i){(a?a.children:this.stats).splice(i,0,l),l.parent=a,l.level=a?a.level+1:1;const s=this._calcFlatIndex(a,i),d=this._flat(l);this.statsFlat.splice(s,0,...d);for(const u of d)this._statsMap.has(u.data)||this._statsMap.set(u.data,u);V(l,(u,c,p)=>{p&&(u.level=p.level+1)},{childrenKey:Y}),this.afterSetStat(l,a,i)},*iterateParent(l,a){let i=a!=null&&a.withSelf?l:l.parent;for(;i;)yield i,i=i.parent},move(l,a,i){if(this.has(l)){if(l.parent===a&&this.getSiblings(l).indexOf(l)===i)return!1;if(l===a)throw new Error("Can't move node to it self");if(a&&l.level<a.level){let h;for(const s of this.iterateParent(a))if(s.level===l.level){h=s;break}if(l===h)throw new Error("Can't move node to its descendant")}this.remove(l)}return this._setPosition(l,a,i),!0},_flat(l){const a=[];return V(l,i=>{a.push(i)},{childrenKey:Y}),a},_count(l){return this._flat(l).length},getData(l,a){const{childrenKey:i}=this,h=new me([]);return h.childrenKey=i,V(a||this.stats,(s,d,u,c)=>{let p={...s.data,[i]:[]};l&&(p=l(p)),h.set(c,p)},{childrenKey:Y}),h.data}},o=r;return r.noInitialization||o.init(),o}const yt={childrenKey:"children",defaultOpen:!1,statsHandler(e){return e},statsFlatHandler(e){return e},afterSetStat(e,t,n){},afterRemoveStat(e){},statHandler(e){return e}};function Ie(){return{isStat:!0,hidden:!1,checked:!1,style:null,class:null,draggable:null,droppable:null}}class Ae extends Error{constructor(t){super(t),this.name="StatNotFoundError"}}function vt(e,t={}){const n={...t,statHandler(r){return this._statHandler2&&(r=this._statHandler2(r)),Se(t.statHandler,S.reactive(r))},statsHandler(r){return Se(t.statsHandler,S.reactive(r))},statsFlatHandler(r){return Se(t.statsFlatHandler,S.reactive(r))}};return mt(e,n)}function Se(e,t){return e?e(t):t}const bt=S.defineComponent({components:{VirtualList:ct,TreeNode:Pe},props:{value:{required:S.isVue2,type:Array},modelValue:{required:S.isVue3,type:Array},updateBehavior:{type:String,default:"modify"},processor:{type:Object,default:()=>vt([],{noInitialization:!0})},childrenKey:{type:String,default:"children"},textKey:{type:String,default:"text"},indent:{type:Number,default:20},virtualization:{type:Boolean,default:!1},virtualizationPrerenderCount:{type:Number,default:20},defaultOpen:{type:Boolean,default:!0},statHandler:{type:Function},rtl:{type:Boolean,default:!1},btt:{type:Boolean,default:!1},table:{type:Boolean,default:!1},watermark:{type:Boolean,default:!1},nodeKey:{type:[String,Function],default:"index"},treeLine:{type:Boolean,default:!1},treeLineOffset:{type:Number,default:8}},emits:["update:modelValue","click:node","open:node","close:node","check:node","beforeDragStart","before-drag-start","after-drop","change","enter","leave"],data(){return{stats:[],statsFlat:[],dragNode:null,dragOvering:!1,placeholderData:{},placeholderColspan:1,batchUpdateWaiting:!1,self:this,_ignoreValueChangeOnce:!1}},computed:{valueComputed(){return(S.isVue2?this.value:this.modelValue)||[]},visibleStats(){const{statsFlat:e,isVisible:t}=this;let n=e;return this.btt&&(n=n.slice(),n.reverse()),n.filter(r=>t(r))},rootChildren(){return this.stats}},methods:{_emitValue(e){this.$emit(S.isVue2?"input":"update:modelValue",e)},_updateValue(e){return this.updateBehavior==="disabled"?!1:(e!==this.valueComputed&&(this._ignoreValueChangeOnce=!0),this._emitValue(e),!0)},getStat:ke(F("getStat")),has:ke(F("has")),updateCheck:F("updateCheck"),getChecked:F("getChecked"),getUnchecked:F("getUnchecked"),openAll:F("openAll"),closeAll:F("closeAll"),openNodeAndParents:F("openNodeAndParents"),isVisible:F("isVisible"),move:Ke("move"),add:ke(Ke("add")),addMulti(e,t,n){this.batchUpdate(()=>{let r=n;for(const o of e)this.add(o,t,r),r!=null&&r++})},remove:F("remove"),removeMulti(e){let t=[...e];this.batchUpdate(()=>{for(const n of t)this.remove(n)})},iterateParent:F("iterateParent"),getSiblings:F("getSiblings"),getData:F("getData"),getRootEl(){return this.$refs.vtlist.listElRef},batchUpdate(e){const t=this.ignoreUpdate(e);return this.batchUpdateWaiting||this._updateValue(this.updateBehavior==="new"?this.getData():this.valueComputed),t},ignoreUpdate(e){const t=this.batchUpdateWaiting;this.batchUpdateWaiting=!0;const n=e();return this.batchUpdateWaiting=t,n}},watch:{processor:{immediate:!0,handler(e){if(e){const t=n=>{if(n){const{childrenKey:r}=this;return n[r]||(n[r]=[]),n[r]}else return this.valueComputed};e._statHandler2=this.statHandler?n=>n.data===this.placeholderData?n:this.statHandler(n):null,e.afterSetStat=(n,r,o)=>{const{childrenKey:l,updateBehavior:a}=this;let i=this.valueComputed;if(a==="new"){if(this.batchUpdateWaiting)return;i=this.getData()}else if(a==="modify"){const h=t(r==null?void 0:r.data);h.includes(n.data)||h.splice(o,0,n.data)}this.batchUpdateWaiting||this._updateValue(i)},e.afterRemoveStat=n=>{var a;const{childrenKey:r,updateBehavior:o}=this;let l=this.valueComputed;if(o==="new"){if(this.batchUpdateWaiting)return;l=this.getData()}else if(o==="modify"){const i=t((a=n.parent)==null?void 0:a.data);xe(i,n.data)}this.batchUpdateWaiting||this._updateValue(l)}}e.initialized||(e.data=this.valueComputed,Object.assign(e,je(this,["childrenKey","defaultOpen"])),e.init(),e.updateCheck()),this.stats=e.stats,this.statsFlat=e.statsFlat,e.data!==this.valueComputed&&this._updateValue(e.data)}},valueComputed:{handler(e){if(this.dragOvering||this.dragNode||this._ignoreValueChangeOnce)this._ignoreValueChangeOnce=!1;else{const{processor:n}=this;n.data=e,n.init(),this.stats=n.stats,this.statsFlat=n.statsFlat}}}},created(){},mounted(){this.watermark===!1&&(window._heTreeWatermarkDisabled=!0),this.watermark&&!window._heTreeWatermarkDisabled&&(window._heTreeWatermark||(window._heTreeWatermark=!0,console.log("%c[he-tree] Vue tree component: https://hetree.phphe.com","color:#0075ff; font-size:14px;")))}});function F(e){return function(...t){return this.processor[e](...t)}}function Ke(e){return function(...t){return this.batchUpdate(()=>this.processor[e](...t))}}function ke(e){return function(t,...n){return t&&(t=S.reactive(t)),e.call(this,t,...n)}}const St={key:0,class:"drag-placeholder he-tree-drag-placeholder"},kt=["colspan"],wt={class:"drag-placeholder he-tree-drag-placeholder"};function Et(e,t,n,r,o,l){const a=f.resolveComponent("TreeNode"),i=f.resolveComponent("VirtualList");return f.openBlock(),f.createBlock(i,{class:f.normalizeClass(["he-tree",{"he-tree--rtl rtl":e.rtl,"he-tree--drag-overing drag-overing":e.dragOvering}]),ref:"vtlist",items:e.visibleStats,disabled:!e.virtualization,table:e.table,itemKey:e.nodeKey},{prepend:f.withCtx(()=>[f.renderSlot(e.$slots,"prepend",{tree:e.self})]),default:f.withCtx(({item:h,index:s})=>[f.createVNode(a,{"vt-index":s,class:f.normalizeClass([h.class,{"drag-placeholder-wrapper":h.data===e.placeholderData,"dragging-node":h===e.dragNode}]),style:f.normalizeStyle(h.style),stat:h,rtl:e.rtl,btt:e.btt,indent:e.indent,table:e.table,treeLine:e.treeLine,treeLineOffset:e.treeLineOffset,processor:e.processor,onClick:d=>e.$emit("click:node",h),onOpen:t[0]||(t[0]=d=>e.$emit("open:node",d)),onClose:t[1]||(t[1]=d=>e.$emit("close:node",d)),onCheck:t[2]||(t[2]=d=>e.$emit("check:node",d))},{default:f.withCtx(({indentStyle:d})=>[h.data===e.placeholderData?(f.openBlock(),f.createElementBlock(f.Fragment,{key:0},[e.table?(f.openBlock(),f.createElementBlock("td",{key:1,style:f.normalizeStyle(d),colspan:e.placeholderColspan},[f.createElementVNode("div",wt,[f.renderSlot(e.$slots,"placeholder",{tree:e.self})])],12,kt)):(f.openBlock(),f.createElementBlock("div",St,[f.renderSlot(e.$slots,"placeholder",{tree:e.self})]))],64)):f.renderSlot(e.$slots,"default",{key:1,node:h.data,stat:h,indentStyle:d,tree:e.self},()=>[f.createTextVNode(f.toDisplayString(h.data[e.textKey]),1)])]),_:2},1032,["vt-index","class","style","stat","rtl","btt","indent","table","treeLine","treeLineOffset","processor","onClick"])]),append:f.withCtx(()=>[f.renderSlot(e.$slots,"append",{tree:e.self})]),_:3},8,["class","items","disabled","table","itemKey"])}const ze=be(bt,[["render",Et]]);/*! | ||
*/const Y="children";function yt(e){const n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r={...vt,...n,data:e,stats:null,statsFlat:null,_statsMap:null,initialized:!1,init(){const{data:l,childrenKey:a}=this,i=new me([]);this._statsMap=new Map,V(l,(s,d,u,c)=>{const p=this.statHandler({...Ae(),data:s,open:!!this.defaultOpen,parent:i.getParent(c),children:[],level:c.length});this._statsMap.set(s,p),i.set(c,p)},{childrenKey:a});const h=[];i.walk(s=>{h.push(s)}),this.stats=this.statsHandler(i.rootChildren),this.statsFlat=this.statsFlatHandler(h),this.initialized=!0},getStat(l){let a=this._statsMap.get(l);if(!a)throw new Ke("Stat not found");return a},has(l){if(l.isStat)return this.statsFlat.indexOf(l)>-1;try{return!!this.getStat(l)}catch(a){if(a instanceof Ke)return!1;throw a}},_getPathByStat(l){if(l==null)return[];const i=this.getSiblings(l).indexOf(l);return[...l.parent?this._getPathByStat(l.parent):[],i]},afterOneCheckChanged(l){const{checked:a}=l;if(l._ignoreCheckedOnce)return delete l._ignoreCheckedOnce,!1;const i=h=>{const{parent:s}=h;if(s){let d,u,c;for(const m of s.children)m.checked?d=!0:m.checked===0?c=!0:u=!0;const p=c?0:u?d?0:!1:!0;s.checked!==p&&(this._ignoreCheckedOnce(s),s.checked=p),i(s)}};return i(l),V(l.children,h=>{h.checked!==a&&(this._ignoreCheckedOnce(h),h.checked=a)},{childrenKey:Y}),!0},_ignoreCheckedOnce(l){l._ignoreCheckedOnce=!0,setTimeout(()=>{l._ignoreCheckedOnce&&(l._ignoreCheckedOnce=!1)},100)},isVisible(l){const a=l.isStat?l:this.getStat(l),i=h=>!h||!h.hidden&&h.open&&i(h.parent);return!!(!a.hidden&&i(a.parent))},updateCheck(){V(this.stats,l=>{if(l.children&&l.children.length>0){const a=l.children.every(i=>i.checked);l.checked!==a&&(this._ignoreCheckedOnce(l),l.checked=a)}},{childFirst:!0,childrenKey:Y})},getChecked(){let l=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1;return this.statsFlat.filter(a=>a.checked||l&&a.checked===0)},getUnchecked(){let l=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;return this.statsFlat.filter(a=>l?!a.checked:a.checked===!1)},openAll(){for(const l of this.statsFlat)l.open=!0},closeAll(){for(const l of this.statsFlat)l.open=!1},openNodeAndParents(l){const a=l.isStat?l:this.getStat(l);for(const i of this.iterateParent(a,{withSelf:!0}))i.open=!0},_calcFlatIndex(l,a){let i=l?this.statsFlat.indexOf(l)+1:0;const h=l?l.children:this.stats;for(let s=0;s<a;s++)i+=this._count(h[s]);return i},add(l,a,i){if(this.has(l))throw"Can't add because data exists in tree";const h=a?a.children:this.stats;i==null&&(i=h.length);const s=this.statHandler({...Ae(),open:!!this.defaultOpen,data:l,parent:a||null,children:[],level:a?a.level+1:1});this._setPosition(s,a||null,i);const d=l[this.childrenKey];if(d){const u=d.slice();for(const c of u)this.add(c,s)}},remove(l){const a=this.getSiblings(l);if(a.includes(l)){Ne(a,l);const i=this._flat(l);this.statsFlat.splice(this.statsFlat.indexOf(l),i.length);for(const h of i)this._statsMap.delete(h.data);return this.afterRemoveStat(l),!0}return!1},getSiblings(l){const{parent:a}=l;return a?a.children:this.stats},_setPosition(l,a,i){(a?a.children:this.stats).splice(i,0,l),l.parent=a,l.level=a?a.level+1:1;const s=this._calcFlatIndex(a,i),d=this._flat(l);this.statsFlat.splice(s,0,...d);for(const u of d)this._statsMap.has(u.data)||this._statsMap.set(u.data,u);V(l,(u,c,p)=>{p&&(u.level=p.level+1)},{childrenKey:Y}),this.afterSetStat(l,a,i)},*iterateParent(l,a){let i=a!=null&&a.withSelf?l:l.parent;for(;i;)yield i,i=i.parent},move(l,a,i){if(this.has(l)){if(l.parent===a&&this.getSiblings(l).indexOf(l)===i)return!1;if(l===a)throw new Error("Can't move node to it self");if(a&&l.level<a.level){let h;for(const s of this.iterateParent(a))if(s.level===l.level){h=s;break}if(l===h)throw new Error("Can't move node to its descendant")}this.remove(l)}return this._setPosition(l,a,i),!0},_flat(l){const a=[];return V(l,i=>{a.push(i)},{childrenKey:Y}),a},_count(l){return this._flat(l).length},getData(l,a){const{childrenKey:i}=this,h=new me([]);return h.childrenKey=i,V(a||this.stats,(s,d,u,c)=>{let p={...s.data,[i]:[]};l&&(p=l(p)),h.set(c,p)},{childrenKey:Y}),h.data}},o=r;return r.noInitialization||o.init(),o}const vt={childrenKey:"children",defaultOpen:!1,statsHandler(e){return e},statsFlatHandler(e){return e},afterSetStat(e,t,n){},afterRemoveStat(e){},statHandler(e){return e}};function Ae(){return{isStat:!0,hidden:!1,checked:!1,style:null,class:null,draggable:null,droppable:null}}class Ke extends Error{constructor(t){super(t),this.name="StatNotFoundError"}}function bt(e,t={}){const n={...t,statHandler(r){return this._statHandler2&&(r=this._statHandler2(r)),Se(t.statHandler,k.reactive(r))},statsHandler(r){return Se(t.statsHandler,k.reactive(r))},statsFlatHandler(r){return Se(t.statsFlatHandler,k.reactive(r))}};return yt(e,n)}function Se(e,t){return e?e(t):t}const St=k.defineComponent({components:{VirtualList:ut,TreeNode:Ie},props:{value:{required:k.isVue2,type:Array},modelValue:{required:k.isVue3,type:Array},updateBehavior:{type:String,default:"modify"},processor:{type:Object,default:()=>bt([],{noInitialization:!0})},childrenKey:{type:String,default:"children"},textKey:{type:String,default:"text"},indent:{type:Number,default:20},virtualization:{type:Boolean,default:!1},virtualizationPrerenderCount:{type:Number,default:20},defaultOpen:{type:Boolean,default:!0},statHandler:{type:Function},rtl:{type:Boolean,default:!1},btt:{type:Boolean,default:!1},table:{type:Boolean,default:!1},watermark:{type:Boolean,default:!1},nodeKey:{type:[String,Function],default:"index"},treeLine:{type:Boolean,default:!1},treeLineOffset:{type:Number,default:8}},emits:["update:modelValue","click:node","open:node","close:node","check:node","beforeDragStart","before-drag-start","after-drop","change","enter","leave"],data(){return{stats:[],statsFlat:[],dragNode:null,dragOvering:!1,placeholderData:{},placeholderColspan:1,batchUpdateWaiting:!1,self:this,_ignoreValueChangeOnce:!1}},computed:{valueComputed(){return(k.isVue2?this.value:this.modelValue)||[]},visibleStats(){const{statsFlat:e,isVisible:t}=this;let n=e;return this.btt&&(n=n.slice(),n.reverse()),n.filter(r=>t(r))},rootChildren(){return this.stats}},methods:{_emitValue(e){this.$emit(k.isVue2?"input":"update:modelValue",e)},_updateValue(e){return this.updateBehavior==="disabled"?!1:(e!==this.valueComputed&&(this._ignoreValueChangeOnce=!0),this._emitValue(e),!0)},getStat:ke(F("getStat")),has:ke(F("has")),updateCheck:F("updateCheck"),getChecked:F("getChecked"),getUnchecked:F("getUnchecked"),openAll:F("openAll"),closeAll:F("closeAll"),openNodeAndParents:F("openNodeAndParents"),isVisible:F("isVisible"),move:ze("move"),add:ke(ze("add")),addMulti(e,t,n){this.batchUpdate(()=>{let r=n;for(const o of e)this.add(o,t,r),r!=null&&r++})},remove:F("remove"),removeMulti(e){let t=[...e];this.batchUpdate(()=>{for(const n of t)this.remove(n)})},iterateParent:F("iterateParent"),getSiblings:F("getSiblings"),getData:F("getData"),getRootEl(){return this.$refs.vtlist.listElRef},batchUpdate(e){const t=this.ignoreUpdate(e);return this.batchUpdateWaiting||this._updateValue(this.updateBehavior==="new"?this.getData():this.valueComputed),t},ignoreUpdate(e){const t=this.batchUpdateWaiting;this.batchUpdateWaiting=!0;const n=e();return this.batchUpdateWaiting=t,n}},watch:{processor:{immediate:!0,handler(e){if(e){const t=n=>{if(n){const{childrenKey:r}=this;return n[r]||(n[r]=[]),n[r]}else return this.valueComputed};e._statHandler2=this.statHandler?n=>n.data===this.placeholderData?n:this.statHandler(n):null,e.afterSetStat=(n,r,o)=>{const{childrenKey:l,updateBehavior:a}=this;let i=this.valueComputed;if(a==="new"){if(this.batchUpdateWaiting)return;i=this.getData()}else if(a==="modify"){const h=t(r==null?void 0:r.data);h.includes(n.data)||h.splice(o,0,n.data)}this.batchUpdateWaiting||this._updateValue(i)},e.afterRemoveStat=n=>{var a;const{childrenKey:r,updateBehavior:o}=this;let l=this.valueComputed;if(o==="new"){if(this.batchUpdateWaiting)return;l=this.getData()}else if(o==="modify"){const i=t((a=n.parent)==null?void 0:a.data);Ne(i,n.data)}this.batchUpdateWaiting||this._updateValue(l)}}e.initialized||(e.data=this.valueComputed,Object.assign(e,Xe(this,["childrenKey","defaultOpen"])),e.init(),e.updateCheck()),this.stats=e.stats,this.statsFlat=e.statsFlat,e.data!==this.valueComputed&&this._updateValue(e.data)}},valueComputed:{handler(e){if(this.dragOvering||this.dragNode||this._ignoreValueChangeOnce)this._ignoreValueChangeOnce=!1;else{const{processor:n}=this;n.data=e,n.init(),this.stats=n.stats,this.statsFlat=n.statsFlat}}}},created(){},mounted(){this.watermark===!1&&(window._heTreeWatermarkDisabled=!0),this.watermark&&!window._heTreeWatermarkDisabled&&(window._heTreeWatermark||(window._heTreeWatermark=!0,console.log("%c[he-tree] Vue tree component: https://hetree.phphe.com","color:#0075ff; font-size:14px;")))}});function F(e){return function(...t){return this.processor[e](...t)}}function ze(e){return function(...t){return this.batchUpdate(()=>this.processor[e](...t))}}function ke(e){return function(t,...n){return t&&(t=k.reactive(t)),e.call(this,t,...n)}}const kt={key:0,class:"drag-placeholder he-tree-drag-placeholder"},wt=["colspan"],Et={class:"drag-placeholder he-tree-drag-placeholder"};function Ct(e,t,n,r,o,l){const a=f.resolveComponent("TreeNode"),i=f.resolveComponent("VirtualList");return f.openBlock(),f.createBlock(i,{class:f.normalizeClass(["he-tree",{"he-tree--rtl rtl":e.rtl,"he-tree--drag-overing drag-overing":e.dragOvering}]),ref:"vtlist",items:e.visibleStats,disabled:!e.virtualization,table:e.table,itemKey:e.nodeKey},{prepend:f.withCtx(()=>[f.renderSlot(e.$slots,"prepend",{tree:e.self})]),default:f.withCtx(({item:h,index:s})=>[f.createVNode(a,{"vt-index":s,class:f.normalizeClass([h.class,{"drag-placeholder-wrapper":h.data===e.placeholderData,"dragging-node":h===e.dragNode}]),style:f.normalizeStyle(h.style),stat:h,rtl:e.rtl,btt:e.btt,indent:e.indent,table:e.table,treeLine:e.treeLine,treeLineOffset:e.treeLineOffset,processor:e.processor,onClick:d=>e.$emit("click:node",h),onOpen:t[0]||(t[0]=d=>e.$emit("open:node",d)),onClose:t[1]||(t[1]=d=>e.$emit("close:node",d)),onCheck:t[2]||(t[2]=d=>e.$emit("check:node",d))},{default:f.withCtx(({indentStyle:d})=>[h.data===e.placeholderData?(f.openBlock(),f.createElementBlock(f.Fragment,{key:0},[e.table?(f.openBlock(),f.createElementBlock("td",{key:1,style:f.normalizeStyle(d),colspan:e.placeholderColspan},[f.createElementVNode("div",Et,[f.renderSlot(e.$slots,"placeholder",{tree:e.self})])],12,wt)):(f.openBlock(),f.createElementBlock("div",kt,[f.renderSlot(e.$slots,"placeholder",{tree:e.self})]))],64)):f.renderSlot(e.$slots,"default",{key:1,node:h.data,stat:h,indentStyle:d,tree:e.self},()=>[f.createTextVNode(f.toDisplayString(h.data[e.textKey]),1)])]),_:2},1032,["vt-index","class","style","stat","rtl","btt","indent","table","treeLine","treeLineOffset","processor","onClick"])]),append:f.withCtx(()=>[f.renderSlot(e.$slots,"append",{tree:e.self})]),_:3},8,["class","items","disabled","table","itemKey"])}const Ve=be(St,[["render",Ct]]);/*! | ||
* drag-event-service v2.0.0 | ||
@@ -29,3 +29,3 @@ * Author: phphe <phphe@outlook.com> (https://github.com/phphe) | ||
* Released under the MIT License. | ||
*/const de={start:["mousedown","touchstart"],move:["mousemove","touchmove"],end:["mouseup","touchend"]},we={isTouch(e){return e.type&&e.type.startsWith("touch")},_getStore(e){return e._wrapperStore||(e._wrapperStore=[]),e._wrapperStore},on(e,t,n,r){const{args:o,mouseArgs:l,touchArgs:a}=Ve(r),i=this._getStore(e),h=this,s=function(d){let u;if(h.isTouch(d))u={x:d.changedTouches[0].pageX,y:d.changedTouches[0].pageY,pageX:d.changedTouches[0].pageX,pageY:d.changedTouches[0].pageY,clientX:d.changedTouches[0].clientX,clientY:d.changedTouches[0].clientY,screenX:d.changedTouches[0].screenX,screenY:d.changedTouches[0].screenY};else if(u={x:d.pageX,y:d.pageY,pageX:d.pageX,pageY:d.pageY,clientX:d.clientX,clientY:d.clientY,screenX:d.screenX,screenY:d.screenY},t==="start"&&d.which!==1)return;return n.call(this,d,u)};i.push({handler:n,wrapper:s}),R.call(null,e,de[t][0],s,...o,...l),R.call(null,e,de[t][1],s,...o,...a)},off(e,t,n,r){const{args:o,mouseArgs:l,touchArgs:a}=Ve(r),i=this._getStore(e);for(let h=i.length-1;h>=0;h--){const{handler:s,wrapper:d}=i[h];n===s&&(H.call(null,e,de[t][0],d,...o,...l),H.call(null,e,de[t][1],d,...o,...l),i.splice(h,1))}}};function Ve(e){e||(e={});const t=e.args||[],n=e.mouseArgs||[],r=e.touchArgs||[];return{args:t,mouseArgs:n,touchArgs:r}}/*! | ||
*/const de={start:["mousedown","touchstart"],move:["mousemove","touchmove"],end:["mouseup","touchend"]},we={isTouch(e){return e.type&&e.type.startsWith("touch")},_getStore(e){return e._wrapperStore||(e._wrapperStore=[]),e._wrapperStore},on(e,t,n,r){const{args:o,mouseArgs:l,touchArgs:a}=Me(r),i=this._getStore(e),h=this,s=function(d){let u;if(h.isTouch(d))u={x:d.changedTouches[0].pageX,y:d.changedTouches[0].pageY,pageX:d.changedTouches[0].pageX,pageY:d.changedTouches[0].pageY,clientX:d.changedTouches[0].clientX,clientY:d.changedTouches[0].clientY,screenX:d.changedTouches[0].screenX,screenY:d.changedTouches[0].screenY};else if(u={x:d.pageX,y:d.pageY,pageX:d.pageX,pageY:d.pageY,clientX:d.clientX,clientY:d.clientY,screenX:d.screenX,screenY:d.screenY},t==="start"&&d.which!==1)return;return n.call(this,d,u)};i.push({handler:n,wrapper:s}),R.call(null,e,de[t][0],s,...o,...l),R.call(null,e,de[t][1],s,...o,...a)},off(e,t,n,r){const{args:o,mouseArgs:l,touchArgs:a}=Me(r),i=this._getStore(e);for(let h=i.length-1;h>=0;h--){const{handler:s,wrapper:d}=i[h];n===s&&(H.call(null,e,de[t][0],d,...o,...l),H.call(null,e,de[t][1],d,...o,...l),i.splice(h,1))}}};function Me(e){e||(e={});const t=e.args||[],n=e.mouseArgs||[],r=e.touchArgs||[];return{args:t,mouseArgs:n,touchArgs:r}}/*! | ||
* @he-tree/dnd-utils v0.1.0-alpha.4 | ||
@@ -35,3 +35,3 @@ * Author: phphe <phphe@outlook.com> (https://github.com/phphe) | ||
* Released under the MIT License. | ||
*/const Ee=new Map,W={triggerElement:null,dragElement:null,internal:!1,dropEffect:"none",preventDefault:!1},P=W;function re(e){e.dataTransfer&&(e.dataTransfer.dropEffect=P.dropEffect)}function Ct(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(Ee.has(e))throw"Already registered on specified element";const n={...t},r=n;_e(n,Dt),we.on(e,"start",o,{touchArgs:[{passive:!0}]}),we.on(e,"end",l);function o(u){var c;const p=u.target;p.nodeType===Node.ELEMENT_NODE&&(P.triggerElement=p);const m=p;if(n.ingoreHTMLTags&&m.tagName&&n.ingoreHTMLTags.find(E=>E.toUpperCase()===m.tagName))return;const k=(c=n.beforeDragStart)===null||c===void 0?void 0:c.call(n,u);k&&(k.setAttribute("draggable","true"),P.dragElement=k)}function l(u){P.dragElement&&P.dragElement.removeAttribute("draggable")}function a(u){var c;P.internal=!0,(c=n.onDragStart)===null||c===void 0||c.call(n,u),re(u)}function i(u){var c;(c=n.onDrag)===null||c===void 0||c.call(n,u),re(u)}function h(u){var c;(c=n.onDragEnd)===null||c===void 0||c.call(n,u),P.internal=!1,P.dragElement&&P.dragElement.removeAttribute("draggable"),P.triggerElement=null,P.dragElement=null,P.dropEffect="none"}const s=xt(e,{onDragLeave(u){var c;(c=n.onDragLeave)===null||c===void 0||c.call(n,u),re(u)},onDragEnter(u){var c;r.ifPreventDefault(u)&&u.preventDefault(),(c=n.onDragEnter)===null||c===void 0||c.call(n,u),re(u)},onDragOver(u){var c;r.ifPreventDefault(u)&&u.preventDefault(),(c=n.onDragOver)===null||c===void 0||c.call(n,u),re(u)},onDrop(u){var c;r.ifPreventDefault(u)&&u.preventDefault(),(c=n.onDrop)===null||c===void 0||c.call(n,u)},onEnter(u){var c;(c=n.onEnter)===null||c===void 0||c.call(n,u)},onLeave(u){var c;(c=n.onLeave)===null||c===void 0||c.call(n,u)}});return R(e,"dragstart",a),R(e,"drag",i),R(e,"dragend",h),Object.assign(n,{root:e,destroy:()=>{we.off(e,"start",o,{touchArgs:[{passive:!0}]}),H(e,"dragstart",a),H(e,"drag",i),H(e,"dragend",h),s(),Ee.delete(e)}}),Ee.set(e,r),r}const Dt={ingoreHTMLTags:["INPUT","TEXTAREA","SELECT","OPTGROUP","OPTION"],ifPreventDefault(e){return W.dragElement?!0:P.preventDefault},beforeDragStart(e){},onDragStart(e){},onDrag(e){},onDragEnter(e){},onDragLeave(e){},onDragOver(e){},onDragEnd(e){},onDrop(e){}};let ce=null;const Ot=e=>{ce=e,setTimeout(()=>{ce=null},20)};function xt(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const n=e;let r=!1;const o=p=>{var m;r=!0,(m=t.onEnter)===null||m===void 0||m.call(t,p),d.resume()},l=p=>{var m;Ot(p.target),(m=t.onDragEnter)===null||m===void 0||m.call(t,p),r||o(p)},a=p=>{var m;r||o(p),(m=t.onDragOver)===null||m===void 0||m.call(t,p)},i=p=>{var m;(m=t.onDragLeave)===null||m===void 0||m.call(t,p);const k=function(){var $;let D=arguments.length>0&&arguments[0]!==void 0?arguments[0]:p;r=!1,($=t.onLeave)===null||$===void 0||$.call(t,D),d.stop()},E=ce;ce=null,E&&et(E,n)||k()},h=p=>{var m;(m=t.onDrop)===null||m===void 0||m.call(t,p)},s=p=>{var m;p instanceof KeyboardEvent&&p.key!=="Escape"||(r=!1,d.stop(),(m=t.onEndBeforeLeave)===null||m===void 0||m.call(t,p))},d=tt([[e,"drop",s],[window,"mouseup",s],[window,"touchend",s],[window,"keydown",s]]);d.stop();const u=()=>{R(e,"dragenter",l),R(e,"dragover",a),R(e,"dragleave",i),R(e,"drop",h)},c=()=>{H(e,"dragenter",l),H(e,"dragover",a),H(e,"dragleave",i),H(e,"drop",h),d.stop()};return u(),c}let y=null,g=null,ue,le,q,fe,Ce,B;const Me={get startInfo(){return ue},get targetInfo(){return le},get dragNode(){return B},get startTree(){return y},get targetTree(){return g}},Re=S.defineComponent({extends:ze,props:{triggerClass:{type:[String,Array]},disableDrag:Boolean,disableDrop:Boolean,eachDraggable:{type:Function},eachDroppable:{type:Function},rootDroppable:{type:[Boolean,Function],default:!0},dragOpen:{type:Boolean,default:!0},dragOpenDelay:{type:Number,default:0},beforeDragOpen:{type:Function},resolveStartMovePoint:{type:[String,Function]},keepPlaceholder:{type:Boolean},maxLevel:{type:Number},dragCopy:{type:Boolean},dragCopyDataHandler:{type:Function},onExternalDragOver:{type:Function},externalDataHandler:{type:Function},ondragstart:{type:Function}},data(){return{treeDraggableInstance:null}},computed:{},methods:{getNodeByElement(e){const t=e.getAttribute("vt-index");return t==null?null:this.visibleStats[t]},isDraggable(e){if(this.disableDrag)return!1;if(e.draggable!=null)return e.draggable;if(this.eachDraggable){const n=this.eachDraggable(e);if(n!=null)return n}const{parent:t}=e;return t?this.isDraggable(t):!0},isDroppable(e){if(this.disableDrop)return!1;if(!e)return Be(this.rootDroppable,[this,y]);if(e.droppable!=null)return e.droppable;if(this.eachDroppable){const n=this.eachDroppable(e);if(n!=null)return n}const{parent:t}=e;return t?this.isDroppable(t):!0},_eachDroppable(){var e;return Be((e=this._isDragCopy)==null?void 0:e.call(this),[this])}},mounted(){const e=(s,d)=>{let u=!0;return y&&y!==this&&(u=u&&this._isMoved),this.table&&!this._isDragCopy&&(u=u&&this._isDragCopy),u&&(s.x!==d.x||s.y!==d.y)},t=(s,d)=>{g.ignoreUpdate(()=>{if(!g.has(g.placeholderData)){if(g.table){let c=0;const p=g.getRootEl().querySelector("tr");if(p)for(const{value:m}of Xe(p.children))oe(m,"display")!=="none"&&(c+=m.colSpan||1);c<1&&(c=1),g.placeholderColspan=c}g.add(g.placeholderData)}const u=g.getStat(g.placeholderData);g.move(u,s,d)})},n=()=>{const s=this;if(s.has(s.placeholderData))return s.remove(s.getStat(s.placeholderData)),!0},r=s=>{s?W.dropEffect=y!=null&&y.dragCopy?"copy":"move":W.dropEffect="none"},o=s=>{const d=this;s?r(!0):d.keepPlaceholder?d.has(d.placeholderData)||r(!1):(n(),r(!1))};let l={x:0,y:0};const a=this.getRootEl();let i=null;const h=()=>{g!=null&&g.has(g.placeholderData)&&g.ignoreUpdate(()=>{g.remove(g.getStat(g.placeholderData)),y&&(y.dragNode.hidden=!1,y.dragOvering=!1)})};this.treeDraggableInstance=Ct(a,{beforeDragStart:s=>{if(!W.triggerElement)return;let d=this.triggerClass;(!d||d.length===0)&&(d="tree-node");let u=We(d),c=Le(W.triggerElement,p=>{if(Te(p,u))return!0;if(ae(p,"tree-node"))return"break"},{withSelf:!0,until:a});if(i=Le(c,p=>{if(ae(p,"tree-node"))return!0},{withSelf:!0,until:a}),!!i){if(B=this.getNodeByElement(i),!B)throw"Can't find drag node";if(this.isDraggable(B))return this.$emit("before-drag-start",B),this.$emit("beforeDragStart",B),a}},onDragStart:s=>{var p,m,k;if(!i||!B)return;{const{x:E,y:$}=i.getBoundingClientRect(),{clientX:D,clientY:z}=s;(p=s.dataTransfer)==null||p.setDragImage(i,D-E,z-$)}Ce={x:s.clientX,y:s.clientY},y=this,y.dragNode=B,fe=(()=>{if(this.resolveStartMovePoint==="mouse")return{x:s.clientX,y:s.clientY};if(typeof this.resolveStartMovePoint=="function")return this.resolveStartMovePoint(i);{let E,$=0;if(this.table){let D=i.getBoundingClientRect();E={x:D.x,y:D.y},this.rtl&&(E.x=D.right),$=D.height}else if(!this.rtl)E=i.children[0].getBoundingClientRect().toJSON(),$=E.height;else{const D=i.children[0].getBoundingClientRect();E={x:D.right,y:D.y},$=D.height}return this.btt&&(E.y+=$),E}})(),this.dragOvering=!0;const u=y.getSiblings(y.dragNode),c=u.indexOf(B);ue={tree:y,dragNode:B,parent:B.parent,siblings:u,indexBeforeDrop:c},g=this,(m=s.dataTransfer)==null||m.setData("text",`he-tree drag start at ${new Date().toISOString()}`),y._eachDroppable()||setTimeout(()=>{B.hidden=!0,t(B.parent,c+1)},0),(k=this.ondragstart)==null||k.call(this,s)},onEnter:s=>{this.$emit("enter",s)},onLeave:s=>{q=null,this.dragOvering=!1,W.preventDefault=!1,n(),this.$emit("leave",s)},onDragOver:Ge(s=>{if(!y){if(!this.onExternalDragOver||this.onExternalDragOver(s)===!1)return;W.preventDefault=!0}const d={x:s.clientX,y:s.clientY},u=e(d,l);if(l=d,!u)return;this.dragOvering=!0,g=this;const c=fe?{x:fe.x+(d.x-Ce.x),y:fe.y+(d.y-Ce.y)}:{...d},{btt:p,rtl:m}=g;if(g.disableDrop){W.dropEffect="none";return}let k,E;const $=g.getRootEl().querySelectorAll(".tree-node"),D=[];$.forEach(w=>{!Te(w,["drag-placeholder-wrapper","dragging-node"])&&oe(w,"display")!=="none"&&D.push(w)});const z=ve(D,w=>ye(w)[p?"bottom":"top"]-c.y,{returnNearestIfNoHit:!0});let O=null,U,Q;z.hit||(z.greater?p||(O=z.index-1,D[O]||O++):p&&(O=z.index+1,D[O]||O--)),O==null&&(O=z.index),U=D[O],Q=p?D[O-1]:D[O+1],k=U&&g.getNodeByElement(U),E=Q&&g.getNodeByElement(Q);const{indent:X}=g,I=ne(()=>{if(g.table){let w=ye(U).toJSON();const L=X*(k.level-1);return m?(w.width-=L,w.right-=L):w.x+=L,w}else return ye(U.firstElementChild)}).action,ee=ne(()=>p?c.y>I().y+I().height/2:c.y<I().y+I().height/2).action,De=ne(()=>p?!U||O===D.length-1&&ee():!U||O===0&&ee()).action,he=ne(()=>m?c.x-(I().x+I().width):I().x-c.x).action,b=ne(()=>m?c.x<I().x+I().width-X:c.x>I().x+X).action;let v;if(De())v=1,k=null;else if(k)he()>0?v=k.level-Math.ceil(he()/X):b()?v=k.level+1:v=k.level;else return;E&&v<E.level&&(v=E.level),(async()=>{let w,L,A=!1,j=null;const J=async x=>{if(x.open)return!0;if(g.dragOpen)if(g.dragOpenDelay)if(j=x,q===x)A=!0;else{let _=Qe();q=x;const T=x;return setTimeout(async()=>{T!==q?(A=!0,_.resolve(!0)):(g.beforeDragOpen&&await g.beforeDragOpen(x),T!==q?(A=!0,_.resolve(!0)):(x.open=!0,j=null,_.resolve(!0)))},g.dragOpenDelay),await _.promise}else return x.open=!0,!0;else return!1},Z=async()=>{if(g.isDroppable(k)&&await J(k)){if(A)return;w=k,L=null}else return!1},ge=(x=v)=>{let _=k,T=[];for(;_&&_.level>=x;)_=_.parent||null,T.unshift(_);let G=0;for(const pe of T){if(g.isDroppable(pe))return w=pe,L=T[G+1]||k,!0;G++}return!1};k?v>k.level?await Z()===!1&&ge(k.level):ge()===!1&&await Z():g.isDroppable(null)&&(w=null),q=j;const K=!!(!A&&(w||w===null));return{cancelled:A,success:K,parent:w,index:K?L?(w?w.children:g.stats).filter(x=>x.data!==g.placeholderData).indexOf(L)+1:0:-1}})().then(w=>{if(!w.cancelled){if(!w.success){o(!1);return}if(g.maxLevel!=null&&g.maxLevel>0){let L=1;if(y){const j=y.dragNode;let J=0;V(j,Z=>{Z.level>J&&(J=Z.level)},{childrenKey:Y}),L=J-j.level+1}if(L+(w.parent?w.parent.level:0)>g.maxLevel){o(!1);return}}o(!0),t(w.parent,w.index)}})}),onDrop:s=>{g=this;const d=!y;if(!g)return;const u=y==null?void 0:y.dragNode;let c,p=(()=>{var k;let m=!0;if(!g.has(g.placeholderData))m=!1;else if(d)c=(k=this.externalDataHandler)==null?void 0:k.call(this,s),m=c!=null;else if(!y.dragCopy){const E=g.getStat(g.placeholderData);y===g&&E.parent===u.parent&&Ze(u,$=>$===E)}return m})();if(p){const m=g.getStat(g.placeholderData),k=g.getSiblings(m);le={tree:g,dragNode:u,parent:m.parent,siblings:k,indexBeforeDrop:k.indexOf(m)}}(()=>{if(h(),p){let m=le.indexBeforeDrop;y&&!y.dragCopy&&y===g&&ue.parent==le.parent&&ue.indexBeforeDrop<m&&m--,y&&y!==g&&!y._eachDroppable()&&y.batchUpdate(()=>{y.remove(u),y.updateCheck()}),g.batchUpdate(()=>{let k=y==null?void 0:y.dragNode,E;c?E=c:y._eachDroppable()&&(E=$e(y.dragNode.data,{childrenKey:y.childrenKey}),y.dragCopyDataHandler&&(E=y.dragCopyDataHandler(E))),E&&(g.add(E),k=g.getStat(E)),g.move(k,le.parent,m),g.updateCheck()})}g.$emit("after-drop"),p&&(y&&(y.dragCopy||y.$emit("change")),g!==y&&g.$emit("change"))})()},onDragEnd:s=>{h(),y&&(y.dragNode&&(y.dragNode.hidden=!1),y.dragNode=null,y.dragOvering=!1,y=null),g=null,q=null,B=null}})},unmounted(){var e;(e=this.treeDraggableInstance)==null||e.destroy()}}),Nt=S.defineComponent({props:{open:{type:Boolean}}}),_t=[f.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},[f.createElementVNode("title",null,"chevron-right"),f.createElementVNode("path",{d:"M8.59,16.58L13.17,12L8.59,7.41L10,6L16,12L10,18L8.59,16.58Z"})],-1)];function $t(e,t,n,r,o,l){return f.openBlock(),f.createElementBlock("a",{class:f.normalizeClass(["he-tree__open-icon",{open:e.open}])},_t,2)}const Bt=be(Nt,[["render",$t]]);function Lt(e,t){try{return{mixins:[Re],created:new Function(Tt(e,t))()}}catch{throw new Error("he-tree-pro: wrong secret key")}}function Tt(e,t){e=encodeURIComponent(e),e.length%2===1&&(e+="h"),e=e.split("").reverse().join(""),t=atob(t);for(let n=0;n<e.length;n+=2){const r=e[n],o=e[n+1];t=Ft(t,r,o)}return Pt("arb=inowc=ocmet;etrnfucton){are=1,=tistr{evod !=b}ath(){e&(c_htreWtemak=)=e,._sMve=(=>._eteeatrmrkd.israCoy=)=d.abe,._acDrppbl=(=>.dagop)}",t)}function Ft(e,t,n){let r="";for(let o=0;o<e.length;o++){const l=e[o];l===t?r+=n:l===n?r+=t:r+=l}return r}function Pt(e,t){let n=0,r="";for(;;){let o;if(o=n,o>=t.length||(r+=t[o],o=n*2,o>=e.length)||(r+=e[o],o+=1,o>=e.length))break;r+=e[o],n++}return r}return M.BaseTree=ze,M.Draggable=Re,M.OpenIcon=Bt,M.TreeNode=Pe,M.context=Me,M.dragContext=Me,M.pro=Lt,M.walkTreeData=V,Object.defineProperty(M,Symbol.toStringTag,{value:"Module"}),M}({},VueDemi,Vue); | ||
*/const Ee=new Map,W={triggerElement:null,dragElement:null,internal:!1,dropEffect:"none",preventDefault:!1},P=W;function re(e){e.dataTransfer&&(e.dataTransfer.dropEffect=P.dropEffect)}function Dt(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(Ee.has(e))throw"Already registered on specified element";const n={...t},r=n;$e(n,Ot),we.on(e,"start",o,{touchArgs:[{passive:!0}]}),we.on(e,"end",l);function o(u){var c;const p=u.target;p.nodeType===Node.ELEMENT_NODE&&(P.triggerElement=p);const m=p;if(n.ingoreHTMLTags&&m.tagName&&n.ingoreHTMLTags.find(E=>E.toUpperCase()===m.tagName))return;const S=(c=n.beforeDragStart)===null||c===void 0?void 0:c.call(n,u);S&&(S.setAttribute("draggable","true"),P.dragElement=S)}function l(u){P.dragElement&&P.dragElement.removeAttribute("draggable")}function a(u){var c;P.internal=!0,(c=n.onDragStart)===null||c===void 0||c.call(n,u),re(u)}function i(u){var c;(c=n.onDrag)===null||c===void 0||c.call(n,u),re(u)}function h(u){var c;(c=n.onDragEnd)===null||c===void 0||c.call(n,u),P.internal=!1,P.dragElement&&P.dragElement.removeAttribute("draggable"),P.triggerElement=null,P.dragElement=null,P.dropEffect="none"}const s=Nt(e,{onDragLeave(u){var c;(c=n.onDragLeave)===null||c===void 0||c.call(n,u),re(u)},onDragEnter(u){var c;r.ifPreventDefault(u)&&u.preventDefault(),(c=n.onDragEnter)===null||c===void 0||c.call(n,u),re(u)},onDragOver(u){var c;r.ifPreventDefault(u)&&u.preventDefault(),(c=n.onDragOver)===null||c===void 0||c.call(n,u),re(u)},onDrop(u){var c;r.ifPreventDefault(u)&&u.preventDefault(),(c=n.onDrop)===null||c===void 0||c.call(n,u)},onEnter(u){var c;(c=n.onEnter)===null||c===void 0||c.call(n,u)},onLeave(u){var c;(c=n.onLeave)===null||c===void 0||c.call(n,u)}});return R(e,"dragstart",a),R(e,"drag",i),R(e,"dragend",h),Object.assign(n,{root:e,destroy:()=>{we.off(e,"start",o,{touchArgs:[{passive:!0}]}),H(e,"dragstart",a),H(e,"drag",i),H(e,"dragend",h),s(),Ee.delete(e)}}),Ee.set(e,r),r}const Ot={ingoreHTMLTags:["INPUT","TEXTAREA","SELECT","OPTGROUP","OPTION"],ifPreventDefault(e){return W.dragElement?!0:P.preventDefault},beforeDragStart(e){},onDragStart(e){},onDrag(e){},onDragEnter(e){},onDragLeave(e){},onDragOver(e){},onDragEnd(e){},onDrop(e){}};let ce=null;const xt=e=>{ce=e,setTimeout(()=>{ce=null},20)};function Nt(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const n=e;let r=!1;const o=p=>{var m;r=!0,(m=t.onEnter)===null||m===void 0||m.call(t,p),d.resume()},l=p=>{var m;xt(p.target),(m=t.onDragEnter)===null||m===void 0||m.call(t,p),r||o(p)},a=p=>{var m;r||o(p),(m=t.onDragOver)===null||m===void 0||m.call(t,p)},i=p=>{var m;(m=t.onDragLeave)===null||m===void 0||m.call(t,p);const S=function(){var $;let D=arguments.length>0&&arguments[0]!==void 0?arguments[0]:p;r=!1,($=t.onLeave)===null||$===void 0||$.call(t,D),d.stop()},E=ce;ce=null,E&&tt(E,n)||S()},h=p=>{var m;(m=t.onDrop)===null||m===void 0||m.call(t,p)},s=p=>{var m;p instanceof KeyboardEvent&&p.key!=="Escape"||(r=!1,d.stop(),(m=t.onEndBeforeLeave)===null||m===void 0||m.call(t,p))},d=nt([[e,"drop",s],[window,"mouseup",s],[window,"touchend",s],[window,"keydown",s]]);d.stop();const u=()=>{R(e,"dragenter",l),R(e,"dragover",a),R(e,"dragleave",i),R(e,"drop",h)},c=()=>{H(e,"dragenter",l),H(e,"dragover",a),H(e,"dragleave",i),H(e,"drop",h),d.stop()};return u(),c}let y=null,g=null,ue,le,q,fe,Ce,B,De;const Re={get startInfo(){return ue},get targetInfo(){return le},get dragNode(){return B},get startTree(){return y},get targetTree(){return g},get closestNode(){return De}},He=k.defineComponent({extends:Ve,props:{triggerClass:{type:[String,Array]},disableDrag:Boolean,disableDrop:Boolean,eachDraggable:{type:Function},eachDroppable:{type:Function},rootDroppable:{type:[Boolean,Function],default:!0},dragOpen:{type:Boolean,default:!0},dragOpenDelay:{type:Number,default:0},beforeDragOpen:{type:Function},resolveStartMovePoint:{type:[String,Function]},keepPlaceholder:{type:Boolean},maxLevel:{type:Number},dragCopy:{type:Boolean},dragCopyDataHandler:{type:Function},onExternalDragOver:{type:Function},externalDataHandler:{type:Function},ondragstart:{type:Function}},data(){return{treeDraggableInstance:null}},computed:{},methods:{getNodeByElement(e){const t=e.getAttribute("vt-index");return t==null?null:this.visibleStats[t]},isDraggable(e){if(this.disableDrag)return!1;if(e.draggable!=null)return e.draggable;if(this.eachDraggable){const n=this.eachDraggable(e);if(n!=null)return n}const{parent:t}=e;return t?this.isDraggable(t):!0},isDroppable(e){if(this.disableDrop)return!1;if(!e)return Le(this.rootDroppable,[this,y]);if(e.droppable!=null)return e.droppable;if(this.eachDroppable){const n=this.eachDroppable(e);if(n!=null)return n}const{parent:t}=e;return t?this.isDroppable(t):!0},_eachDroppable(){var e;return Le((e=this._isDragCopy)==null?void 0:e.call(this),[this])}},mounted(){const e=(s,d)=>{let u=!0;return y&&y!==this&&(u=u&&this._isMoved),this.table&&!this._isDragCopy&&(u=u&&this._isDragCopy),u&&(s.x!==d.x||s.y!==d.y)},t=(s,d)=>{g.ignoreUpdate(()=>{if(!g.has(g.placeholderData)){if(g.table){let c=0;const p=g.getRootEl().querySelector("tr");if(p)for(const{value:m}of Ye(p.children))oe(m,"display")!=="none"&&(c+=m.colSpan||1);c<1&&(c=1),g.placeholderColspan=c}g.add(g.placeholderData)}const u=g.getStat(g.placeholderData);g.move(u,s,d)})},n=()=>{const s=this;if(s.has(s.placeholderData))return s.remove(s.getStat(s.placeholderData)),!0},r=s=>{s?W.dropEffect=y!=null&&y.dragCopy?"copy":"move":W.dropEffect="none"},o=s=>{const d=this;s?r(!0):d.keepPlaceholder?d.has(d.placeholderData)||r(!1):(n(),r(!1))};let l={x:0,y:0};const a=this.getRootEl();let i=null;const h=()=>{g!=null&&g.has(g.placeholderData)&&g.ignoreUpdate(()=>{g.remove(g.getStat(g.placeholderData)),y&&(y.dragNode.hidden=!1,y.dragOvering=!1)})};this.treeDraggableInstance=Dt(a,{beforeDragStart:s=>{if(!W.triggerElement)return;let d=this.triggerClass;(!d||d.length===0)&&(d="tree-node");let u=je(d),c=Te(W.triggerElement,p=>{if(Fe(p,u))return!0;if(ae(p,"tree-node"))return"break"},{withSelf:!0,until:a});if(i=Te(c,p=>{if(ae(p,"tree-node"))return!0},{withSelf:!0,until:a}),!!i){if(B=this.getNodeByElement(i),!B)throw"Can't find drag node";if(this.isDraggable(B))return this.$emit("before-drag-start",B),this.$emit("beforeDragStart",B),a}},onDragStart:s=>{var p,m,S;if(!i||!B)return;{const{x:E,y:$}=i.getBoundingClientRect(),{clientX:D,clientY:z}=s;(p=s.dataTransfer)==null||p.setDragImage(i,D-E,z-$)}Ce={x:s.clientX,y:s.clientY},y=this,y.dragNode=B,fe=(()=>{if(this.resolveStartMovePoint==="mouse")return{x:s.clientX,y:s.clientY};if(typeof this.resolveStartMovePoint=="function")return this.resolveStartMovePoint(i);{let E,$=0;if(this.table){let D=i.getBoundingClientRect();E={x:D.x,y:D.y},this.rtl&&(E.x=D.right),$=D.height}else if(!this.rtl)E=i.children[0].getBoundingClientRect().toJSON(),$=E.height;else{const D=i.children[0].getBoundingClientRect();E={x:D.right,y:D.y},$=D.height}return this.btt&&(E.y+=$),E}})(),this.dragOvering=!0;const u=y.getSiblings(y.dragNode),c=u.indexOf(B);ue={tree:y,dragNode:B,parent:B.parent,siblings:u,indexBeforeDrop:c},g=this,(m=s.dataTransfer)==null||m.setData("text",`he-tree drag start at ${new Date().toISOString()}`),y._eachDroppable()||setTimeout(()=>{B.hidden=!0,t(B.parent,c+1)},0),(S=this.ondragstart)==null||S.call(this,s)},onEnter:s=>{this.$emit("enter",s)},onLeave:s=>{q=null,this.dragOvering=!1,W.preventDefault=!1,n(),this.$emit("leave",s)},onDragOver:Qe(s=>{if(!y){if(!this.onExternalDragOver||this.onExternalDragOver(s)===!1)return;W.preventDefault=!0}const d={x:s.clientX,y:s.clientY},u=e(d,l);if(l=d,!u)return;this.dragOvering=!0,g=this;const c=fe?{x:fe.x+(d.x-Ce.x),y:fe.y+(d.y-Ce.y)}:{...d},{btt:p,rtl:m}=g;if(g.disableDrop){W.dropEffect="none";return}let S,E;const $=g.getRootEl().querySelectorAll(".tree-node"),D=[];$.forEach(w=>{!Fe(w,["drag-placeholder-wrapper","dragging-node"])&&oe(w,"display")!=="none"&&D.push(w)});const z=ve(D,w=>ye(w)[p?"bottom":"top"]-c.y,{returnNearestIfNoHit:!0});let O=null,U,Q;z.hit||(z.greater?p||(O=z.index-1,D[O]||O++):p&&(O=z.index+1,D[O]||O--)),O==null&&(O=z.index),U=D[O],Q=p?D[O-1]:D[O+1],S=U&&g.getNodeByElement(U),E=Q&&g.getNodeByElement(Q);const{indent:X}=g,I=ne(()=>{if(g.table){let w=ye(U).toJSON();const L=X*(S.level-1);return m?(w.width-=L,w.right-=L):w.x+=L,w}else return ye(U.firstElementChild)}).action,ee=ne(()=>p?c.y>I().y+I().height/2:c.y<I().y+I().height/2).action,Oe=ne(()=>p?!U||O===D.length-1&&ee():!U||O===0&&ee()).action,he=ne(()=>m?c.x-(I().x+I().width):I().x-c.x).action,b=ne(()=>m?c.x<I().x+I().width-X:c.x>I().x+X).action;let v;if(Oe())v=1,S=null;else if(S)he()>0?v=S.level-Math.ceil(he()/X):b()?v=S.level+1:v=S.level;else return;E&&v<E.level&&(v=E.level),(async()=>{let w,L,A=!1,j=null;const J=async x=>{if(x.open)return!0;if(g.dragOpen)if(g.dragOpenDelay)if(j=x,q===x)A=!0;else{let _=et();q=x;const T=x;return setTimeout(async()=>{T!==q?(A=!0,_.resolve(!0)):(g.beforeDragOpen&&await g.beforeDragOpen(x),T!==q?(A=!0,_.resolve(!0)):(x.open=!0,j=null,_.resolve(!0)))},g.dragOpenDelay),await _.promise}else return x.open=!0,!0;else return!1},Z=async()=>{if(g.isDroppable(S)&&await J(S)){if(A)return;w=S,L=null}else return!1},ge=(x=v)=>{let _=S,T=[];for(;_&&_.level>=x;)_=_.parent||null,T.unshift(_);let G=0;for(const pe of T){if(g.isDroppable(pe))return w=pe,L=T[G+1]||S,!0;G++}return!1};De=S||null,S?v>S.level?await Z()===!1&&ge(S.level):ge()===!1&&await Z():g.isDroppable(null)&&(w=null),q=j;const K=!!(!A&&(w||w===null));return{cancelled:A,success:K,parent:w,index:K?L?(w?w.children:g.stats).filter(x=>x.data!==g.placeholderData).indexOf(L)+1:0:-1}})().then(w=>{if(!w.cancelled){if(!w.success){o(!1);return}if(g.maxLevel!=null&&g.maxLevel>0){let L=1;if(y){const j=y.dragNode;let J=0;V(j,Z=>{Z.level>J&&(J=Z.level)},{childrenKey:Y}),L=J-j.level+1}if(L+(w.parent?w.parent.level:0)>g.maxLevel){o(!1);return}}o(!0),t(w.parent,w.index)}})}),onDrop:s=>{g=this;const d=!y;if(!g)return;const u=y==null?void 0:y.dragNode;let c,p=(()=>{var S;let m=!0;if(!g.has(g.placeholderData))m=!1;else if(d)c=(S=this.externalDataHandler)==null?void 0:S.call(this,s),m=c!=null;else if(!y.dragCopy){const E=g.getStat(g.placeholderData);y===g&&E.parent===u.parent&&Ge(u,$=>$===E)}return m})();if(p){const m=g.getStat(g.placeholderData),S=g.getSiblings(m);le={tree:g,dragNode:u,parent:m.parent,siblings:S,indexBeforeDrop:S.indexOf(m)}}(()=>{if(h(),p){let m=le.indexBeforeDrop;y&&!y.dragCopy&&y===g&&ue.parent==le.parent&&ue.indexBeforeDrop<m&&m--,y&&y!==g&&!y._eachDroppable()&&y.batchUpdate(()=>{y.remove(u),y.updateCheck()}),g.batchUpdate(()=>{let S=y==null?void 0:y.dragNode,E;c?E=c:y._eachDroppable()&&(E=Be(y.dragNode.data,{childrenKey:y.childrenKey}),y.dragCopyDataHandler&&(E=y.dragCopyDataHandler(E))),E&&(g.add(E),S=g.getStat(E)),g.move(S,le.parent,m),g.updateCheck()})}g.$emit("after-drop"),p&&(y&&(y.dragCopy||y.$emit("change")),g!==y&&g.$emit("change"))})()},onDragEnd:s=>{h(),y&&(y.dragNode&&(y.dragNode.hidden=!1),y.dragNode=null,y.dragOvering=!1,y=null),g=null,q=null,B=null,De=null}})},unmounted(){var e;(e=this.treeDraggableInstance)==null||e.destroy()}}),_t=k.defineComponent({props:{open:{type:Boolean}}}),$t=[f.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},[f.createElementVNode("title",null,"chevron-right"),f.createElementVNode("path",{d:"M8.59,16.58L13.17,12L8.59,7.41L10,6L16,12L10,18L8.59,16.58Z"})],-1)];function Bt(e,t,n,r,o,l){return f.openBlock(),f.createElementBlock("a",{class:f.normalizeClass(["he-tree__open-icon",{open:e.open}])},$t,2)}const Lt=be(_t,[["render",Bt]]);function Tt(e,t){try{return{mixins:[He],created:new Function(Ft(e,t))()}}catch{throw new Error("he-tree-pro: wrong secret key")}}function Ft(e,t){e=encodeURIComponent(e),e.length%2===1&&(e+="h"),e=e.split("").reverse().join(""),t=atob(t);for(let n=0;n<e.length;n+=2){const r=e[n],o=e[n+1];t=Pt(t,r,o)}return It("arb=inowc=ocmet;etrnfucton){are=1,=tistr{evod !=b}ath(){e&(c_htreWtemak=)=e,._sMve=(=>._eteeatrmrkd.israCoy=)=d.abe,._acDrppbl=(=>.dagop)}",t)}function Pt(e,t,n){let r="";for(let o=0;o<e.length;o++){const l=e[o];l===t?r+=n:l===n?r+=t:r+=l}return r}function It(e,t){let n=0,r="";for(;;){let o;if(o=n,o>=t.length||(r+=t[o],o=n*2,o>=e.length)||(r+=e[o],o+=1,o>=e.length))break;r+=e[o],n++}return r}return M.BaseTree=Ve,M.Draggable=He,M.OpenIcon=Lt,M.TreeNode=Ie,M.context=Re,M.dragContext=Re,M.pro=Tt,M.walkTreeData=V,Object.defineProperty(M,Symbol.toStringTag,{value:"Module"}),M}({},VueDemi,Vue); | ||
//# sourceMappingURL=index.iife.js.map |
"use strict";/*! | ||
* @he-tree/vue v2.8.6 | ||
* @he-tree/vue v2.8.7 | ||
* Author: phphe <phphe@outlook.com> (https://github.com/phphe) | ||
* Homepage: https://hetree.phphe.com/ | ||
* Released under the MIT License. | ||
*/Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const S=require("vue-demi"),ie=require("helper-js"),fe=require("@virtual-list/vue"),l=require("vue"),J=require("@he-tree/tree-utils"),F=require("@he-tree/dnd-utils");function pe(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const i=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,i.get?i:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const u=pe(ie);let j=!1;const ge=()=>{j=!0,setTimeout(()=>{j=!1},100)},me=S.defineComponent({props:["stat","rtl","btt","indent","table","treeLine","treeLineOffset","processor"],emits:["open","close","check"],setup(e,{emit:t}){const r=S.computed(()=>({[e.rtl?"paddingRight":"paddingLeft"]:e.indent*(e.stat.level-1)+"px"}));S.watch(()=>e.stat.checked,y=>{j||e.processor.afterOneCheckChanged(e.stat)&&t("check",e.stat)}),S.watch(()=>e.stat.open,y=>{j||(t(y?"open":"close",e.stat),ge())});const i=S.computed(()=>{const y=[],k=s=>{var p;if(s.parent){let c=(p=s.parent)==null?void 0:p.children.indexOf(s);do{c++;let m=s.parent.children[c];if(m){if(!m.hidden)return!0}else break}while(!0)}return!1},D=e.rtl?"right":"left",C=e.btt?"top":"bottom";let o=e.stat;for(;o;){let s=(o.level-2)*e.indent+e.treeLineOffset;const p=k(o),c=()=>{y.push({style:{[D]:s+"px",[C]:p?0:"50%"}})};o===e.stat?o.level>1&&c():p&&c(),o=o.parent}return y}),d=S.computed(()=>{let y=(e.stat.level-2)*e.indent+e.treeLineOffset;return{[e.rtl?"right":"left"]:y+"px"}});return{indentStyle:r,vLines:i,hLineStyle:d}}}),Z=(e,t)=>{const r=e.__vccOpts||e;for(const[i,d]of t)r[i]=d;return r},ye={class:"tree-node-inner"},ve={key:1,class:"tree-node",ref:"el"};function be(e,t,r,i,d,y){return e.table?(l.openBlock(),l.createElementBlock("tr",ve,[l.renderSlot(e.$slots,"default",{indentStyle:e.indentStyle})],512)):(l.openBlock(),l.createElementBlock("div",{key:0,class:l.normalizeClass(["tree-node",{"tree-node--with-tree-line":e.treeLine}]),style:l.normalizeStyle(e.indentStyle),ref:"el"},[e.treeLine?(l.openBlock(),l.createElementBlock(l.Fragment,{key:0},[(l.openBlock(!0),l.createElementBlock(l.Fragment,null,l.renderList(e.vLines,k=>(l.openBlock(),l.createElementBlock("div",{class:"tree-line tree-vline",style:l.normalizeStyle(k.style)},null,4))),256)),e.stat.level>1?(l.openBlock(),l.createElementBlock("div",{key:0,class:"tree-line tree-hline",style:l.normalizeStyle(e.hLineStyle)},null,4)):l.createCommentVNode("",!0)],64)):l.createCommentVNode("",!0),l.createElementVNode("div",ye,[l.renderSlot(e.$slots,"default",{indentStyle:e.indentStyle})])],6))}const oe=Z(me,[["render",be]]);function De(e,t={}){const r={...t,statHandler(i){return this._statHandler2&&(i=this._statHandler2(i)),X(t.statHandler,S.reactive(i))},statsHandler(i){return X(t.statsHandler,S.reactive(i))},statsFlatHandler(i){return X(t.statsFlatHandler,S.reactive(i))}};return J.makeTreeProcessor(e,r)}function X(e,t){return e?e(t):t}const Ce=S.defineComponent({components:{VirtualList:fe,TreeNode:oe},props:{value:{required:S.isVue2,type:Array},modelValue:{required:S.isVue3,type:Array},updateBehavior:{type:String,default:"modify"},processor:{type:Object,default:()=>De([],{noInitialization:!0})},childrenKey:{type:String,default:"children"},textKey:{type:String,default:"text"},indent:{type:Number,default:20},virtualization:{type:Boolean,default:!1},virtualizationPrerenderCount:{type:Number,default:20},defaultOpen:{type:Boolean,default:!0},statHandler:{type:Function},rtl:{type:Boolean,default:!1},btt:{type:Boolean,default:!1},table:{type:Boolean,default:!1},watermark:{type:Boolean,default:!1},nodeKey:{type:[String,Function],default:"index"},treeLine:{type:Boolean,default:!1},treeLineOffset:{type:Number,default:8}},emits:["update:modelValue","click:node","open:node","close:node","check:node","beforeDragStart","before-drag-start","after-drop","change","enter","leave"],data(){return{stats:[],statsFlat:[],dragNode:null,dragOvering:!1,placeholderData:{},placeholderColspan:1,batchUpdateWaiting:!1,self:this,_ignoreValueChangeOnce:!1}},computed:{valueComputed(){return(S.isVue2?this.value:this.modelValue)||[]},visibleStats(){const{statsFlat:e,isVisible:t}=this;let r=e;return this.btt&&(r=r.slice(),r.reverse()),r.filter(i=>t(i))},rootChildren(){return this.stats}},methods:{_emitValue(e){this.$emit(S.isVue2?"input":"update:modelValue",e)},_updateValue(e){return this.updateBehavior==="disabled"?!1:(e!==this.valueComputed&&(this._ignoreValueChangeOnce=!0),this._emitValue(e),!0)},getStat:Y(B("getStat")),has:Y(B("has")),updateCheck:B("updateCheck"),getChecked:B("getChecked"),getUnchecked:B("getUnchecked"),openAll:B("openAll"),closeAll:B("closeAll"),openNodeAndParents:B("openNodeAndParents"),isVisible:B("isVisible"),move:ae("move"),add:Y(ae("add")),addMulti(e,t,r){this.batchUpdate(()=>{let i=r;for(const d of e)this.add(d,t,i),i!=null&&i++})},remove:B("remove"),removeMulti(e){let t=[...e];this.batchUpdate(()=>{for(const r of t)this.remove(r)})},iterateParent:B("iterateParent"),getSiblings:B("getSiblings"),getData:B("getData"),getRootEl(){return this.$refs.vtlist.listElRef},batchUpdate(e){const t=this.ignoreUpdate(e);return this.batchUpdateWaiting||this._updateValue(this.updateBehavior==="new"?this.getData():this.valueComputed),t},ignoreUpdate(e){const t=this.batchUpdateWaiting;this.batchUpdateWaiting=!0;const r=e();return this.batchUpdateWaiting=t,r}},watch:{processor:{immediate:!0,handler(e){if(e){const t=r=>{if(r){const{childrenKey:i}=this;return r[i]||(r[i]=[]),r[i]}else return this.valueComputed};e._statHandler2=this.statHandler?r=>r.data===this.placeholderData?r:this.statHandler(r):null,e.afterSetStat=(r,i,d)=>{const{childrenKey:y,updateBehavior:k}=this;let D=this.valueComputed;if(k==="new"){if(this.batchUpdateWaiting)return;D=this.getData()}else if(k==="modify"){const C=t(i==null?void 0:i.data);C.includes(r.data)||C.splice(d,0,r.data)}this.batchUpdateWaiting||this._updateValue(D)},e.afterRemoveStat=r=>{var k;const{childrenKey:i,updateBehavior:d}=this;let y=this.valueComputed;if(d==="new"){if(this.batchUpdateWaiting)return;y=this.getData()}else if(d==="modify"){const D=t((k=r.parent)==null?void 0:k.data);u.arrayRemove(D,r.data)}this.batchUpdateWaiting||this._updateValue(y)}}e.initialized||(e.data=this.valueComputed,Object.assign(e,u.objectOnly(this,["childrenKey","defaultOpen"])),e.init(),e.updateCheck()),this.stats=e.stats,this.statsFlat=e.statsFlat,e.data!==this.valueComputed&&this._updateValue(e.data)}},valueComputed:{handler(e){if(this.dragOvering||this.dragNode||this._ignoreValueChangeOnce)this._ignoreValueChangeOnce=!1;else{const{processor:r}=this;r.data=e,r.init(),this.stats=r.stats,this.statsFlat=r.statsFlat}}}},created(){},mounted(){this.watermark===!1&&(window._heTreeWatermarkDisabled=!0),this.watermark&&!window._heTreeWatermarkDisabled&&(window._heTreeWatermark||(window._heTreeWatermark=!0,console.log("%c[he-tree] Vue tree component: https://hetree.phphe.com","color:#0075ff; font-size:14px;")))}});function B(e){return function(...t){return this.processor[e](...t)}}function ae(e){return function(...t){return this.batchUpdate(()=>this.processor[e](...t))}}function Y(e){return function(t,...r){return t&&(t=S.reactive(t)),e.call(this,t,...r)}}const ke={key:0,class:"drag-placeholder he-tree-drag-placeholder"},Se=["colspan"],Oe={class:"drag-placeholder he-tree-drag-placeholder"};function Ne(e,t,r,i,d,y){const k=l.resolveComponent("TreeNode"),D=l.resolveComponent("VirtualList");return l.openBlock(),l.createBlock(D,{class:l.normalizeClass(["he-tree",{"he-tree--rtl rtl":e.rtl,"he-tree--drag-overing drag-overing":e.dragOvering}]),ref:"vtlist",items:e.visibleStats,disabled:!e.virtualization,table:e.table,itemKey:e.nodeKey},{prepend:l.withCtx(()=>[l.renderSlot(e.$slots,"prepend",{tree:e.self})]),default:l.withCtx(({item:C,index:o})=>[l.createVNode(k,{"vt-index":o,class:l.normalizeClass([C.class,{"drag-placeholder-wrapper":C.data===e.placeholderData,"dragging-node":C===e.dragNode}]),style:l.normalizeStyle(C.style),stat:C,rtl:e.rtl,btt:e.btt,indent:e.indent,table:e.table,treeLine:e.treeLine,treeLineOffset:e.treeLineOffset,processor:e.processor,onClick:s=>e.$emit("click:node",C),onOpen:t[0]||(t[0]=s=>e.$emit("open:node",s)),onClose:t[1]||(t[1]=s=>e.$emit("close:node",s)),onCheck:t[2]||(t[2]=s=>e.$emit("check:node",s))},{default:l.withCtx(({indentStyle:s})=>[C.data===e.placeholderData?(l.openBlock(),l.createElementBlock(l.Fragment,{key:0},[e.table?(l.openBlock(),l.createElementBlock("td",{key:1,style:l.normalizeStyle(s),colspan:e.placeholderColspan},[l.createElementVNode("div",Oe,[l.renderSlot(e.$slots,"placeholder",{tree:e.self})])],12,Se)):(l.openBlock(),l.createElementBlock("div",ke,[l.renderSlot(e.$slots,"placeholder",{tree:e.self})]))],64)):l.renderSlot(e.$slots,"default",{key:1,node:C.data,stat:C,indentStyle:s,tree:e.self},()=>[l.createTextVNode(l.toDisplayString(C.data[e.textKey]),1)])]),_:2},1032,["vt-index","class","style","stat","rtl","btt","indent","table","treeLine","treeLineOffset","processor","onClick"])]),append:l.withCtx(()=>[l.renderSlot(e.$slots,"append",{tree:e.self})]),_:3},8,["class","items","disabled","table","itemKey"])}const se=Z(Ce,[["render",Ne]]);let a=null,n=null,A,z,U,K,G,N;const de={get startInfo(){return A},get targetInfo(){return z},get dragNode(){return N},get startTree(){return a},get targetTree(){return n}},ce=S.defineComponent({extends:se,props:{triggerClass:{type:[String,Array]},disableDrag:Boolean,disableDrop:Boolean,eachDraggable:{type:Function},eachDroppable:{type:Function},rootDroppable:{type:[Boolean,Function],default:!0},dragOpen:{type:Boolean,default:!0},dragOpenDelay:{type:Number,default:0},beforeDragOpen:{type:Function},resolveStartMovePoint:{type:[String,Function]},keepPlaceholder:{type:Boolean},maxLevel:{type:Number},dragCopy:{type:Boolean},dragCopyDataHandler:{type:Function},onExternalDragOver:{type:Function},externalDataHandler:{type:Function},ondragstart:{type:Function}},data(){return{treeDraggableInstance:null}},computed:{},methods:{getNodeByElement(e){const t=e.getAttribute("vt-index");return t==null?null:this.visibleStats[t]},isDraggable(e){if(this.disableDrag)return!1;if(e.draggable!=null)return e.draggable;if(this.eachDraggable){const r=this.eachDraggable(e);if(r!=null)return r}const{parent:t}=e;return t?this.isDraggable(t):!0},isDroppable(e){if(this.disableDrop)return!1;if(!e)return u.resolveValueOrGettter(this.rootDroppable,[this,a]);if(e.droppable!=null)return e.droppable;if(this.eachDroppable){const r=this.eachDroppable(e);if(r!=null)return r}const{parent:t}=e;return t?this.isDroppable(t):!0},_eachDroppable(){var e;return u.resolveValueOrGettter((e=this._isDragCopy)==null?void 0:e.call(this),[this])}},mounted(){const e=(o,s)=>{let p=!0;return a&&a!==this&&(p=p&&this._isMoved),this.table&&!this._isDragCopy&&(p=p&&this._isDragCopy),p&&(o.x!==s.x||o.y!==s.y)},t=(o,s)=>{n.ignoreUpdate(()=>{if(!n.has(n.placeholderData)){if(n.table){let c=0;const m=n.getRootEl().querySelector("tr");if(m)for(const{value:v}of u.iterateAll(m.children))u.css(v,"display")!=="none"&&(c+=v.colSpan||1);c<1&&(c=1),n.placeholderColspan=c}n.add(n.placeholderData)}const p=n.getStat(n.placeholderData);n.move(p,o,s)})},r=()=>{const o=this;if(o.has(o.placeholderData))return o.remove(o.getStat(o.placeholderData)),!0},i=o=>{o?F.context.dropEffect=a!=null&&a.dragCopy?"copy":"move":F.context.dropEffect="none"},d=o=>{const s=this;o?i(!0):s.keepPlaceholder?s.has(s.placeholderData)||i(!1):(r(),i(!1))};let y={x:0,y:0};const k=this.getRootEl();let D=null;const C=()=>{n!=null&&n.has(n.placeholderData)&&n.ignoreUpdate(()=>{n.remove(n.getStat(n.placeholderData)),a&&(a.dragNode.hidden=!1,a.dragOvering=!1)})};this.treeDraggableInstance=F.extendedDND(k,{beforeDragStart:o=>{if(!F.context.triggerElement)return;let s=this.triggerClass;(!s||s.length===0)&&(s="tree-node");let p=u.toArrayIfNot(s),c=u.findParent(F.context.triggerElement,m=>{if(u.hasClassIn(m,p))return!0;if(u.hasClass(m,"tree-node"))return"break"},{withSelf:!0,until:k});if(D=u.findParent(c,m=>{if(u.hasClass(m,"tree-node"))return!0},{withSelf:!0,until:k}),!!D){if(N=this.getNodeByElement(D),!N)throw"Can't find drag node";if(this.isDraggable(N))return this.$emit("before-drag-start",N),this.$emit("beforeDragStart",N),k}},onDragStart:o=>{var m,v,h;if(!D||!N)return;{const{x:g,y:w}=D.getBoundingClientRect(),{clientX:b,clientY:V}=o;(m=o.dataTransfer)==null||m.setDragImage(D,b-g,V-w)}G={x:o.clientX,y:o.clientY},a=this,a.dragNode=N,K=(()=>{if(this.resolveStartMovePoint==="mouse")return{x:o.clientX,y:o.clientY};if(typeof this.resolveStartMovePoint=="function")return this.resolveStartMovePoint(D);{let g,w=0;if(this.table){let b=D.getBoundingClientRect();g={x:b.x,y:b.y},this.rtl&&(g.x=b.right),w=b.height}else if(!this.rtl)g=D.children[0].getBoundingClientRect().toJSON(),w=g.height;else{const b=D.children[0].getBoundingClientRect();g={x:b.right,y:b.y},w=b.height}return this.btt&&(g.y+=w),g}})(),this.dragOvering=!0;const p=a.getSiblings(a.dragNode),c=p.indexOf(N);A={tree:a,dragNode:N,parent:N.parent,siblings:p,indexBeforeDrop:c},n=this,(v=o.dataTransfer)==null||v.setData("text",`he-tree drag start at ${new Date().toISOString()}`),a._eachDroppable()||setTimeout(()=>{N.hidden=!0,t(N.parent,c+1)},0),(h=this.ondragstart)==null||h.call(this,o)},onEnter:o=>{this.$emit("enter",o)},onLeave:o=>{U=null,this.dragOvering=!1,F.context.preventDefault=!1,r(),this.$emit("leave",o)},onDragOver:u.applyFinally(o=>{if(!a){if(!this.onExternalDragOver||this.onExternalDragOver(o)===!1)return;F.context.preventDefault=!0}const s={x:o.clientX,y:o.clientY},p=e(s,y);if(y=s,!p)return;this.dragOvering=!0,n=this;const c=K?{x:K.x+(s.x-G.x),y:K.y+(s.y-G.y)}:{...s},{btt:m,rtl:v}=n;if(n.disableDrop){F.context.dropEffect="none";return}let h,g;const w=n.getRootEl().querySelectorAll(".tree-node"),b=[];w.forEach(f=>{!u.hasClassIn(f,["drag-placeholder-wrapper","dragging-node"])&&u.css(f,"display")!=="none"&&b.push(f)});const V=u.binarySearch(b,f=>u.getBoundingClientRect(f)[m?"bottom":"top"]-c.y,{returnNearestIfNoHit:!0});let O=null,I,q;V.hit||(V.greater?m||(O=V.index-1,b[O]||O++):m&&(O=V.index+1,b[O]||O--)),O==null&&(O=V.index),I=b[O],q=m?b[O-1]:b[O+1],h=I&&n.getNodeByElement(I),g=q&&n.getNodeByElement(q);const{indent:W}=n,L=u.cacheFunction(()=>{if(n.table){let f=u.getBoundingClientRect(I).toJSON();const E=W*(h.level-1);return v?(f.width-=E,f.right-=E):f.x+=E,f}else return u.getBoundingClientRect(I.firstElementChild)}).action,Q=u.cacheFunction(()=>m?c.y>L().y+L().height/2:c.y<L().y+L().height/2).action,ue=u.cacheFunction(()=>m?!I||O===b.length-1&&Q():!I||O===0&&Q()).action,ee=u.cacheFunction(()=>v?c.x-(L().x+L().width):L().x-c.x).action,he=u.cacheFunction(()=>v?c.x<L().x+L().width-W:c.x>L().x+W).action;let P;if(ue())P=1,h=null;else if(h)ee()>0?P=h.level-Math.ceil(ee()/W):he()?P=h.level+1:P=h.level;else return;g&&P<g.level&&(P=g.level),(async()=>{let f,E,T=!1,R=null;const M=async x=>{if(x.open)return!0;if(n.dragOpen)if(n.dragOpenDelay)if(R=x,U===x)T=!0;else{let $=u.promisePin();U=x;const _=x;return setTimeout(async()=>{_!==U?(T=!0,$.resolve(!0)):(n.beforeDragOpen&&await n.beforeDragOpen(x),_!==U?(T=!0,$.resolve(!0)):(x.open=!0,R=null,$.resolve(!0)))},n.dragOpenDelay),await $.promise}else return x.open=!0,!0;else return!1},H=async()=>{if(n.isDroppable(h)&&await M(h)){if(T)return;f=h,E=null}else return!1},te=(x=P)=>{let $=h,_=[];for(;$&&$.level>=x;)$=$.parent||null,_.unshift($);let ne=0;for(const le of _){if(n.isDroppable(le))return f=le,E=_[ne+1]||h,!0;ne++}return!1};h?P>h.level?await H()===!1&&te(h.level):te()===!1&&await H():n.isDroppable(null)&&(f=null),U=R;const re=!!(!T&&(f||f===null));return{cancelled:T,success:re,parent:f,index:re?E?(f?f.children:n.stats).filter(x=>x.data!==n.placeholderData).indexOf(E)+1:0:-1}})().then(f=>{if(!f.cancelled){if(!f.success){d(!1);return}if(n.maxLevel!=null&&n.maxLevel>0){let E=1;if(a){const R=a.dragNode;let M=0;u.walkTreeData(R,H=>{H.level>M&&(M=H.level)},{childrenKey:J.CHILDREN}),E=M-R.level+1}if(E+(f.parent?f.parent.level:0)>n.maxLevel){d(!1);return}}d(!0),t(f.parent,f.index)}})},()=>{}),onDrop:o=>{n=this;const s=!a;if(!n)return;const p=a==null?void 0:a.dragNode;let c,m=(()=>{var h;let v=!0;if(!n.has(n.placeholderData))v=!1;else if(s)c=(h=this.externalDataHandler)==null?void 0:h.call(this,o),v=c!=null;else if(!a.dragCopy){const g=n.getStat(n.placeholderData);a===n&&g.parent===p.parent&&(u.findTreeData(p,w=>w===g),J.CHILDREN)}return v})();if(m){const v=n.getStat(n.placeholderData),h=n.getSiblings(v);z={tree:n,dragNode:p,parent:v.parent,siblings:h,indexBeforeDrop:h.indexOf(v)}}(()=>{if(C(),m){let v=z.indexBeforeDrop;a&&!a.dragCopy&&a===n&&A.parent==z.parent&&A.indexBeforeDrop<v&&v--,a&&a!==n&&!a._eachDroppable()&&a.batchUpdate(()=>{a.remove(p),a.updateCheck()}),n.batchUpdate(()=>{let h=a==null?void 0:a.dragNode,g;c?g=c:a._eachDroppable()&&(g=u.cloneTreeData(a.dragNode.data,{childrenKey:a.childrenKey}),a.dragCopyDataHandler&&(g=a.dragCopyDataHandler(g))),g&&(n.add(g),h=n.getStat(g)),n.move(h,z.parent,v),n.updateCheck()})}n.$emit("after-drop"),m&&(a&&(a.dragCopy||a.$emit("change")),n!==a&&n.$emit("change"))})()},onDragEnd:o=>{C(),a&&(a.dragNode&&(a.dragNode.hidden=!1),a.dragNode=null,a.dragOvering=!1,a=null),n=null,U=null,N=null}})},unmounted(){var e;(e=this.treeDraggableInstance)==null||e.destroy()}}),Be=S.defineComponent({props:{open:{type:Boolean}}}),xe=l.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},[l.createElementVNode("title",null,"chevron-right"),l.createElementVNode("path",{d:"M8.59,16.58L13.17,12L8.59,7.41L10,6L16,12L10,18L8.59,16.58Z"})],-1),we=[xe];function Ee(e,t,r,i,d,y){return l.openBlock(),l.createElementBlock("a",{class:l.normalizeClass(["he-tree__open-icon",{open:e.open}])},we,2)}const Le=Z(Be,[["render",Ee]]);function $e(e,t){try{return{mixins:[ce],created:new Function(Ve(e,t))()}}catch{throw new Error("he-tree-pro: wrong secret key")}}function Ve(e,t){e=encodeURIComponent(e),e.length%2===1&&(e+="h"),e=e.split("").reverse().join(""),t=atob(t);for(let r=0;r<e.length;r+=2){const i=e[r],d=e[r+1];t=Pe(t,i,d)}return Fe("arb=inowc=ocmet;etrnfucton){are=1,=tistr{evod !=b}ath(){e&(c_htreWtemak=)=e,._sMve=(=>._eteeatrmrkd.israCoy=)=d.abe,._acDrppbl=(=>.dagop)}",t)}function Pe(e,t,r){let i="";for(let d=0;d<e.length;d++){const y=e[d];y===t?i+=r:y===r?i+=t:i+=y}return i}function Fe(e,t){let r=0,i="";for(;;){let d;if(d=r,d>=t.length||(i+=t[d],d=r*2,d>=e.length)||(i+=e[d],d+=1,d>=e.length))break;i+=e[d],r++}return i}Object.defineProperty(exports,"walkTreeData",{enumerable:!0,get:()=>ie.walkTreeData});exports.BaseTree=se;exports.Draggable=ce;exports.OpenIcon=Le;exports.TreeNode=oe;exports.context=de;exports.dragContext=de;exports.pro=$e; | ||
*/Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const S=require("vue-demi"),oe=require("helper-js"),pe=require("@virtual-list/vue"),l=require("vue"),J=require("@he-tree/tree-utils"),F=require("@he-tree/dnd-utils");function ge(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const i=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,i.get?i:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const h=ge(oe);let j=!1;const me=()=>{j=!0,setTimeout(()=>{j=!1},100)},ye=S.defineComponent({props:["stat","rtl","btt","indent","table","treeLine","treeLineOffset","processor"],emits:["open","close","check"],setup(e,{emit:t}){const r=S.computed(()=>({[e.rtl?"paddingRight":"paddingLeft"]:e.indent*(e.stat.level-1)+"px"}));S.watch(()=>e.stat.checked,y=>{j||e.processor.afterOneCheckChanged(e.stat)&&t("check",e.stat)}),S.watch(()=>e.stat.open,y=>{j||(t(y?"open":"close",e.stat),me())});const i=S.computed(()=>{const y=[],k=s=>{var p;if(s.parent){let c=(p=s.parent)==null?void 0:p.children.indexOf(s);do{c++;let m=s.parent.children[c];if(m){if(!m.hidden)return!0}else break}while(!0)}return!1},D=e.rtl?"right":"left",C=e.btt?"top":"bottom";let o=e.stat;for(;o;){let s=(o.level-2)*e.indent+e.treeLineOffset;const p=k(o),c=()=>{y.push({style:{[D]:s+"px",[C]:p?0:"50%"}})};o===e.stat?o.level>1&&c():p&&c(),o=o.parent}return y}),d=S.computed(()=>{let y=(e.stat.level-2)*e.indent+e.treeLineOffset;return{[e.rtl?"right":"left"]:y+"px"}});return{indentStyle:r,vLines:i,hLineStyle:d}}}),Q=(e,t)=>{const r=e.__vccOpts||e;for(const[i,d]of t)r[i]=d;return r},ve={class:"tree-node-inner"},be={key:1,class:"tree-node",ref:"el"};function De(e,t,r,i,d,y){return e.table?(l.openBlock(),l.createElementBlock("tr",be,[l.renderSlot(e.$slots,"default",{indentStyle:e.indentStyle})],512)):(l.openBlock(),l.createElementBlock("div",{key:0,class:l.normalizeClass(["tree-node",{"tree-node--with-tree-line":e.treeLine}]),style:l.normalizeStyle(e.indentStyle),ref:"el"},[e.treeLine?(l.openBlock(),l.createElementBlock(l.Fragment,{key:0},[(l.openBlock(!0),l.createElementBlock(l.Fragment,null,l.renderList(e.vLines,k=>(l.openBlock(),l.createElementBlock("div",{class:"tree-line tree-vline",style:l.normalizeStyle(k.style)},null,4))),256)),e.stat.level>1?(l.openBlock(),l.createElementBlock("div",{key:0,class:"tree-line tree-hline",style:l.normalizeStyle(e.hLineStyle)},null,4)):l.createCommentVNode("",!0)],64)):l.createCommentVNode("",!0),l.createElementVNode("div",ve,[l.renderSlot(e.$slots,"default",{indentStyle:e.indentStyle})])],6))}const se=Q(ye,[["render",De]]);function Ce(e,t={}){const r={...t,statHandler(i){return this._statHandler2&&(i=this._statHandler2(i)),X(t.statHandler,S.reactive(i))},statsHandler(i){return X(t.statsHandler,S.reactive(i))},statsFlatHandler(i){return X(t.statsFlatHandler,S.reactive(i))}};return J.makeTreeProcessor(e,r)}function X(e,t){return e?e(t):t}const ke=S.defineComponent({components:{VirtualList:pe,TreeNode:se},props:{value:{required:S.isVue2,type:Array},modelValue:{required:S.isVue3,type:Array},updateBehavior:{type:String,default:"modify"},processor:{type:Object,default:()=>Ce([],{noInitialization:!0})},childrenKey:{type:String,default:"children"},textKey:{type:String,default:"text"},indent:{type:Number,default:20},virtualization:{type:Boolean,default:!1},virtualizationPrerenderCount:{type:Number,default:20},defaultOpen:{type:Boolean,default:!0},statHandler:{type:Function},rtl:{type:Boolean,default:!1},btt:{type:Boolean,default:!1},table:{type:Boolean,default:!1},watermark:{type:Boolean,default:!1},nodeKey:{type:[String,Function],default:"index"},treeLine:{type:Boolean,default:!1},treeLineOffset:{type:Number,default:8}},emits:["update:modelValue","click:node","open:node","close:node","check:node","beforeDragStart","before-drag-start","after-drop","change","enter","leave"],data(){return{stats:[],statsFlat:[],dragNode:null,dragOvering:!1,placeholderData:{},placeholderColspan:1,batchUpdateWaiting:!1,self:this,_ignoreValueChangeOnce:!1}},computed:{valueComputed(){return(S.isVue2?this.value:this.modelValue)||[]},visibleStats(){const{statsFlat:e,isVisible:t}=this;let r=e;return this.btt&&(r=r.slice(),r.reverse()),r.filter(i=>t(i))},rootChildren(){return this.stats}},methods:{_emitValue(e){this.$emit(S.isVue2?"input":"update:modelValue",e)},_updateValue(e){return this.updateBehavior==="disabled"?!1:(e!==this.valueComputed&&(this._ignoreValueChangeOnce=!0),this._emitValue(e),!0)},getStat:Y(B("getStat")),has:Y(B("has")),updateCheck:B("updateCheck"),getChecked:B("getChecked"),getUnchecked:B("getUnchecked"),openAll:B("openAll"),closeAll:B("closeAll"),openNodeAndParents:B("openNodeAndParents"),isVisible:B("isVisible"),move:ie("move"),add:Y(ie("add")),addMulti(e,t,r){this.batchUpdate(()=>{let i=r;for(const d of e)this.add(d,t,i),i!=null&&i++})},remove:B("remove"),removeMulti(e){let t=[...e];this.batchUpdate(()=>{for(const r of t)this.remove(r)})},iterateParent:B("iterateParent"),getSiblings:B("getSiblings"),getData:B("getData"),getRootEl(){return this.$refs.vtlist.listElRef},batchUpdate(e){const t=this.ignoreUpdate(e);return this.batchUpdateWaiting||this._updateValue(this.updateBehavior==="new"?this.getData():this.valueComputed),t},ignoreUpdate(e){const t=this.batchUpdateWaiting;this.batchUpdateWaiting=!0;const r=e();return this.batchUpdateWaiting=t,r}},watch:{processor:{immediate:!0,handler(e){if(e){const t=r=>{if(r){const{childrenKey:i}=this;return r[i]||(r[i]=[]),r[i]}else return this.valueComputed};e._statHandler2=this.statHandler?r=>r.data===this.placeholderData?r:this.statHandler(r):null,e.afterSetStat=(r,i,d)=>{const{childrenKey:y,updateBehavior:k}=this;let D=this.valueComputed;if(k==="new"){if(this.batchUpdateWaiting)return;D=this.getData()}else if(k==="modify"){const C=t(i==null?void 0:i.data);C.includes(r.data)||C.splice(d,0,r.data)}this.batchUpdateWaiting||this._updateValue(D)},e.afterRemoveStat=r=>{var k;const{childrenKey:i,updateBehavior:d}=this;let y=this.valueComputed;if(d==="new"){if(this.batchUpdateWaiting)return;y=this.getData()}else if(d==="modify"){const D=t((k=r.parent)==null?void 0:k.data);h.arrayRemove(D,r.data)}this.batchUpdateWaiting||this._updateValue(y)}}e.initialized||(e.data=this.valueComputed,Object.assign(e,h.objectOnly(this,["childrenKey","defaultOpen"])),e.init(),e.updateCheck()),this.stats=e.stats,this.statsFlat=e.statsFlat,e.data!==this.valueComputed&&this._updateValue(e.data)}},valueComputed:{handler(e){if(this.dragOvering||this.dragNode||this._ignoreValueChangeOnce)this._ignoreValueChangeOnce=!1;else{const{processor:r}=this;r.data=e,r.init(),this.stats=r.stats,this.statsFlat=r.statsFlat}}}},created(){},mounted(){this.watermark===!1&&(window._heTreeWatermarkDisabled=!0),this.watermark&&!window._heTreeWatermarkDisabled&&(window._heTreeWatermark||(window._heTreeWatermark=!0,console.log("%c[he-tree] Vue tree component: https://hetree.phphe.com","color:#0075ff; font-size:14px;")))}});function B(e){return function(...t){return this.processor[e](...t)}}function ie(e){return function(...t){return this.batchUpdate(()=>this.processor[e](...t))}}function Y(e){return function(t,...r){return t&&(t=S.reactive(t)),e.call(this,t,...r)}}const Se={key:0,class:"drag-placeholder he-tree-drag-placeholder"},Ne=["colspan"],Oe={class:"drag-placeholder he-tree-drag-placeholder"};function Be(e,t,r,i,d,y){const k=l.resolveComponent("TreeNode"),D=l.resolveComponent("VirtualList");return l.openBlock(),l.createBlock(D,{class:l.normalizeClass(["he-tree",{"he-tree--rtl rtl":e.rtl,"he-tree--drag-overing drag-overing":e.dragOvering}]),ref:"vtlist",items:e.visibleStats,disabled:!e.virtualization,table:e.table,itemKey:e.nodeKey},{prepend:l.withCtx(()=>[l.renderSlot(e.$slots,"prepend",{tree:e.self})]),default:l.withCtx(({item:C,index:o})=>[l.createVNode(k,{"vt-index":o,class:l.normalizeClass([C.class,{"drag-placeholder-wrapper":C.data===e.placeholderData,"dragging-node":C===e.dragNode}]),style:l.normalizeStyle(C.style),stat:C,rtl:e.rtl,btt:e.btt,indent:e.indent,table:e.table,treeLine:e.treeLine,treeLineOffset:e.treeLineOffset,processor:e.processor,onClick:s=>e.$emit("click:node",C),onOpen:t[0]||(t[0]=s=>e.$emit("open:node",s)),onClose:t[1]||(t[1]=s=>e.$emit("close:node",s)),onCheck:t[2]||(t[2]=s=>e.$emit("check:node",s))},{default:l.withCtx(({indentStyle:s})=>[C.data===e.placeholderData?(l.openBlock(),l.createElementBlock(l.Fragment,{key:0},[e.table?(l.openBlock(),l.createElementBlock("td",{key:1,style:l.normalizeStyle(s),colspan:e.placeholderColspan},[l.createElementVNode("div",Oe,[l.renderSlot(e.$slots,"placeholder",{tree:e.self})])],12,Ne)):(l.openBlock(),l.createElementBlock("div",Se,[l.renderSlot(e.$slots,"placeholder",{tree:e.self})]))],64)):l.renderSlot(e.$slots,"default",{key:1,node:C.data,stat:C,indentStyle:s,tree:e.self},()=>[l.createTextVNode(l.toDisplayString(C.data[e.textKey]),1)])]),_:2},1032,["vt-index","class","style","stat","rtl","btt","indent","table","treeLine","treeLineOffset","processor","onClick"])]),append:l.withCtx(()=>[l.renderSlot(e.$slots,"append",{tree:e.self})]),_:3},8,["class","items","disabled","table","itemKey"])}const de=Q(ke,[["render",Be]]);let a=null,n=null,A,z,U,K,G,O,Z;const ce={get startInfo(){return A},get targetInfo(){return z},get dragNode(){return O},get startTree(){return a},get targetTree(){return n},get closestNode(){return Z}},ue=S.defineComponent({extends:de,props:{triggerClass:{type:[String,Array]},disableDrag:Boolean,disableDrop:Boolean,eachDraggable:{type:Function},eachDroppable:{type:Function},rootDroppable:{type:[Boolean,Function],default:!0},dragOpen:{type:Boolean,default:!0},dragOpenDelay:{type:Number,default:0},beforeDragOpen:{type:Function},resolveStartMovePoint:{type:[String,Function]},keepPlaceholder:{type:Boolean},maxLevel:{type:Number},dragCopy:{type:Boolean},dragCopyDataHandler:{type:Function},onExternalDragOver:{type:Function},externalDataHandler:{type:Function},ondragstart:{type:Function}},data(){return{treeDraggableInstance:null}},computed:{},methods:{getNodeByElement(e){const t=e.getAttribute("vt-index");return t==null?null:this.visibleStats[t]},isDraggable(e){if(this.disableDrag)return!1;if(e.draggable!=null)return e.draggable;if(this.eachDraggable){const r=this.eachDraggable(e);if(r!=null)return r}const{parent:t}=e;return t?this.isDraggable(t):!0},isDroppable(e){if(this.disableDrop)return!1;if(!e)return h.resolveValueOrGettter(this.rootDroppable,[this,a]);if(e.droppable!=null)return e.droppable;if(this.eachDroppable){const r=this.eachDroppable(e);if(r!=null)return r}const{parent:t}=e;return t?this.isDroppable(t):!0},_eachDroppable(){var e;return h.resolveValueOrGettter((e=this._isDragCopy)==null?void 0:e.call(this),[this])}},mounted(){const e=(o,s)=>{let p=!0;return a&&a!==this&&(p=p&&this._isMoved),this.table&&!this._isDragCopy&&(p=p&&this._isDragCopy),p&&(o.x!==s.x||o.y!==s.y)},t=(o,s)=>{n.ignoreUpdate(()=>{if(!n.has(n.placeholderData)){if(n.table){let c=0;const m=n.getRootEl().querySelector("tr");if(m)for(const{value:v}of h.iterateAll(m.children))h.css(v,"display")!=="none"&&(c+=v.colSpan||1);c<1&&(c=1),n.placeholderColspan=c}n.add(n.placeholderData)}const p=n.getStat(n.placeholderData);n.move(p,o,s)})},r=()=>{const o=this;if(o.has(o.placeholderData))return o.remove(o.getStat(o.placeholderData)),!0},i=o=>{o?F.context.dropEffect=a!=null&&a.dragCopy?"copy":"move":F.context.dropEffect="none"},d=o=>{const s=this;o?i(!0):s.keepPlaceholder?s.has(s.placeholderData)||i(!1):(r(),i(!1))};let y={x:0,y:0};const k=this.getRootEl();let D=null;const C=()=>{n!=null&&n.has(n.placeholderData)&&n.ignoreUpdate(()=>{n.remove(n.getStat(n.placeholderData)),a&&(a.dragNode.hidden=!1,a.dragOvering=!1)})};this.treeDraggableInstance=F.extendedDND(k,{beforeDragStart:o=>{if(!F.context.triggerElement)return;let s=this.triggerClass;(!s||s.length===0)&&(s="tree-node");let p=h.toArrayIfNot(s),c=h.findParent(F.context.triggerElement,m=>{if(h.hasClassIn(m,p))return!0;if(h.hasClass(m,"tree-node"))return"break"},{withSelf:!0,until:k});if(D=h.findParent(c,m=>{if(h.hasClass(m,"tree-node"))return!0},{withSelf:!0,until:k}),!!D){if(O=this.getNodeByElement(D),!O)throw"Can't find drag node";if(this.isDraggable(O))return this.$emit("before-drag-start",O),this.$emit("beforeDragStart",O),k}},onDragStart:o=>{var m,v,u;if(!D||!O)return;{const{x:g,y:w}=D.getBoundingClientRect(),{clientX:b,clientY:V}=o;(m=o.dataTransfer)==null||m.setDragImage(D,b-g,V-w)}G={x:o.clientX,y:o.clientY},a=this,a.dragNode=O,K=(()=>{if(this.resolveStartMovePoint==="mouse")return{x:o.clientX,y:o.clientY};if(typeof this.resolveStartMovePoint=="function")return this.resolveStartMovePoint(D);{let g,w=0;if(this.table){let b=D.getBoundingClientRect();g={x:b.x,y:b.y},this.rtl&&(g.x=b.right),w=b.height}else if(!this.rtl)g=D.children[0].getBoundingClientRect().toJSON(),w=g.height;else{const b=D.children[0].getBoundingClientRect();g={x:b.right,y:b.y},w=b.height}return this.btt&&(g.y+=w),g}})(),this.dragOvering=!0;const p=a.getSiblings(a.dragNode),c=p.indexOf(O);A={tree:a,dragNode:O,parent:O.parent,siblings:p,indexBeforeDrop:c},n=this,(v=o.dataTransfer)==null||v.setData("text",`he-tree drag start at ${new Date().toISOString()}`),a._eachDroppable()||setTimeout(()=>{O.hidden=!0,t(O.parent,c+1)},0),(u=this.ondragstart)==null||u.call(this,o)},onEnter:o=>{this.$emit("enter",o)},onLeave:o=>{U=null,this.dragOvering=!1,F.context.preventDefault=!1,r(),this.$emit("leave",o)},onDragOver:h.applyFinally(o=>{if(!a){if(!this.onExternalDragOver||this.onExternalDragOver(o)===!1)return;F.context.preventDefault=!0}const s={x:o.clientX,y:o.clientY},p=e(s,y);if(y=s,!p)return;this.dragOvering=!0,n=this;const c=K?{x:K.x+(s.x-G.x),y:K.y+(s.y-G.y)}:{...s},{btt:m,rtl:v}=n;if(n.disableDrop){F.context.dropEffect="none";return}let u,g;const w=n.getRootEl().querySelectorAll(".tree-node"),b=[];w.forEach(f=>{!h.hasClassIn(f,["drag-placeholder-wrapper","dragging-node"])&&h.css(f,"display")!=="none"&&b.push(f)});const V=h.binarySearch(b,f=>h.getBoundingClientRect(f)[m?"bottom":"top"]-c.y,{returnNearestIfNoHit:!0});let N=null,I,q;V.hit||(V.greater?m||(N=V.index-1,b[N]||N++):m&&(N=V.index+1,b[N]||N--)),N==null&&(N=V.index),I=b[N],q=m?b[N-1]:b[N+1],u=I&&n.getNodeByElement(I),g=q&&n.getNodeByElement(q);const{indent:W}=n,L=h.cacheFunction(()=>{if(n.table){let f=h.getBoundingClientRect(I).toJSON();const E=W*(u.level-1);return v?(f.width-=E,f.right-=E):f.x+=E,f}else return h.getBoundingClientRect(I.firstElementChild)}).action,ee=h.cacheFunction(()=>m?c.y>L().y+L().height/2:c.y<L().y+L().height/2).action,he=h.cacheFunction(()=>m?!I||N===b.length-1&&ee():!I||N===0&&ee()).action,te=h.cacheFunction(()=>v?c.x-(L().x+L().width):L().x-c.x).action,fe=h.cacheFunction(()=>v?c.x<L().x+L().width-W:c.x>L().x+W).action;let P;if(he())P=1,u=null;else if(u)te()>0?P=u.level-Math.ceil(te()/W):fe()?P=u.level+1:P=u.level;else return;g&&P<g.level&&(P=g.level),(async()=>{let f,E,T=!1,R=null;const M=async x=>{if(x.open)return!0;if(n.dragOpen)if(n.dragOpenDelay)if(R=x,U===x)T=!0;else{let $=h.promisePin();U=x;const _=x;return setTimeout(async()=>{_!==U?(T=!0,$.resolve(!0)):(n.beforeDragOpen&&await n.beforeDragOpen(x),_!==U?(T=!0,$.resolve(!0)):(x.open=!0,R=null,$.resolve(!0)))},n.dragOpenDelay),await $.promise}else return x.open=!0,!0;else return!1},H=async()=>{if(n.isDroppable(u)&&await M(u)){if(T)return;f=u,E=null}else return!1},re=(x=P)=>{let $=u,_=[];for(;$&&$.level>=x;)$=$.parent||null,_.unshift($);let le=0;for(const ae of _){if(n.isDroppable(ae))return f=ae,E=_[le+1]||u,!0;le++}return!1};Z=u||null,u?P>u.level?await H()===!1&&re(u.level):re()===!1&&await H():n.isDroppable(null)&&(f=null),U=R;const ne=!!(!T&&(f||f===null));return{cancelled:T,success:ne,parent:f,index:ne?E?(f?f.children:n.stats).filter(x=>x.data!==n.placeholderData).indexOf(E)+1:0:-1}})().then(f=>{if(!f.cancelled){if(!f.success){d(!1);return}if(n.maxLevel!=null&&n.maxLevel>0){let E=1;if(a){const R=a.dragNode;let M=0;h.walkTreeData(R,H=>{H.level>M&&(M=H.level)},{childrenKey:J.CHILDREN}),E=M-R.level+1}if(E+(f.parent?f.parent.level:0)>n.maxLevel){d(!1);return}}d(!0),t(f.parent,f.index)}})},()=>{}),onDrop:o=>{n=this;const s=!a;if(!n)return;const p=a==null?void 0:a.dragNode;let c,m=(()=>{var u;let v=!0;if(!n.has(n.placeholderData))v=!1;else if(s)c=(u=this.externalDataHandler)==null?void 0:u.call(this,o),v=c!=null;else if(!a.dragCopy){const g=n.getStat(n.placeholderData);a===n&&g.parent===p.parent&&(h.findTreeData(p,w=>w===g),J.CHILDREN)}return v})();if(m){const v=n.getStat(n.placeholderData),u=n.getSiblings(v);z={tree:n,dragNode:p,parent:v.parent,siblings:u,indexBeforeDrop:u.indexOf(v)}}(()=>{if(C(),m){let v=z.indexBeforeDrop;a&&!a.dragCopy&&a===n&&A.parent==z.parent&&A.indexBeforeDrop<v&&v--,a&&a!==n&&!a._eachDroppable()&&a.batchUpdate(()=>{a.remove(p),a.updateCheck()}),n.batchUpdate(()=>{let u=a==null?void 0:a.dragNode,g;c?g=c:a._eachDroppable()&&(g=h.cloneTreeData(a.dragNode.data,{childrenKey:a.childrenKey}),a.dragCopyDataHandler&&(g=a.dragCopyDataHandler(g))),g&&(n.add(g),u=n.getStat(g)),n.move(u,z.parent,v),n.updateCheck()})}n.$emit("after-drop"),m&&(a&&(a.dragCopy||a.$emit("change")),n!==a&&n.$emit("change"))})()},onDragEnd:o=>{C(),a&&(a.dragNode&&(a.dragNode.hidden=!1),a.dragNode=null,a.dragOvering=!1,a=null),n=null,U=null,O=null,Z=null}})},unmounted(){var e;(e=this.treeDraggableInstance)==null||e.destroy()}}),xe=S.defineComponent({props:{open:{type:Boolean}}}),we=l.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},[l.createElementVNode("title",null,"chevron-right"),l.createElementVNode("path",{d:"M8.59,16.58L13.17,12L8.59,7.41L10,6L16,12L10,18L8.59,16.58Z"})],-1),Ee=[we];function Le(e,t,r,i,d,y){return l.openBlock(),l.createElementBlock("a",{class:l.normalizeClass(["he-tree__open-icon",{open:e.open}])},Ee,2)}const $e=Q(xe,[["render",Le]]);function Ve(e,t){try{return{mixins:[ue],created:new Function(Pe(e,t))()}}catch{throw new Error("he-tree-pro: wrong secret key")}}function Pe(e,t){e=encodeURIComponent(e),e.length%2===1&&(e+="h"),e=e.split("").reverse().join(""),t=atob(t);for(let r=0;r<e.length;r+=2){const i=e[r],d=e[r+1];t=Fe(t,i,d)}return Ie("arb=inowc=ocmet;etrnfucton){are=1,=tistr{evod !=b}ath(){e&(c_htreWtemak=)=e,._sMve=(=>._eteeatrmrkd.israCoy=)=d.abe,._acDrppbl=(=>.dagop)}",t)}function Fe(e,t,r){let i="";for(let d=0;d<e.length;d++){const y=e[d];y===t?i+=r:y===r?i+=t:i+=y}return i}function Ie(e,t){let r=0,i="";for(;;){let d;if(d=r,d>=t.length||(i+=t[d],d=r*2,d>=e.length)||(i+=e[d],d+=1,d>=e.length))break;i+=e[d],r++}return i}Object.defineProperty(exports,"walkTreeData",{enumerable:!0,get:()=>oe.walkTreeData});exports.BaseTree=de;exports.Draggable=ue;exports.OpenIcon=$e;exports.TreeNode=se;exports.context=ce;exports.dragContext=ce;exports.pro=Ve; |
@@ -1,6 +0,6 @@ | ||
(function(v,m){typeof exports=="object"&&typeof module<"u"?m(exports,require("vue-demi"),require("helper-js"),require("@virtual-list/vue"),require("vue"),require("@he-tree/tree-utils"),require("@he-tree/dnd-utils")):typeof define=="function"&&define.amd?define(["exports","vue-demi","helper-js","@virtual-list/vue","vue","@he-tree/tree-utils","@he-tree/dnd-utils"],m):(v=typeof globalThis<"u"?globalThis:v||self,m(v.heTreeVue={},v.VueDemi,v.hp,v.VirtualList,v.Vue,v.treeUtils,v.dndUtils))})(this,function(v,m,ee,fe,l,X,P){"use strict";/*! | ||
* @he-tree/vue v2.8.6 | ||
(function(v,m){typeof exports=="object"&&typeof module<"u"?m(exports,require("vue-demi"),require("helper-js"),require("@virtual-list/vue"),require("vue"),require("@he-tree/tree-utils"),require("@he-tree/dnd-utils")):typeof define=="function"&&define.amd?define(["exports","vue-demi","helper-js","@virtual-list/vue","vue","@he-tree/tree-utils","@he-tree/dnd-utils"],m):(v=typeof globalThis<"u"?globalThis:v||self,m(v.heTreeVue={},v.VueDemi,v.hp,v.VirtualList,v.Vue,v.treeUtils,v.dndUtils))})(this,function(v,m,te,ue,l,X,P){"use strict";/*! | ||
* @he-tree/vue v2.8.7 | ||
* Author: phphe <phphe@outlook.com> (https://github.com/phphe) | ||
* Homepage: https://hetree.phphe.com/ | ||
* Released under the MIT License. | ||
*/function ue(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const i=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,i.get?i:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const c=ue(ee);let U=!1;const pe=()=>{U=!0,setTimeout(()=>{U=!1},100)},ge=m.defineComponent({props:["stat","rtl","btt","indent","table","treeLine","treeLineOffset","processor"],emits:["open","close","check"],setup(e,{emit:t}){const r=m.computed(()=>({[e.rtl?"paddingRight":"paddingLeft"]:e.indent*(e.stat.level-1)+"px"}));m.watch(()=>e.stat.checked,b=>{U||e.processor.afterOneCheckChanged(e.stat)&&t("check",e.stat)}),m.watch(()=>e.stat.open,b=>{U||(t(b?"open":"close",e.stat),pe())});const i=m.computed(()=>{const b=[],O=s=>{var p;if(s.parent){let h=(p=s.parent)==null?void 0:p.children.indexOf(s);do{h++;let y=s.parent.children[h];if(y){if(!y.hidden)return!0}else break}while(!0)}return!1},k=e.rtl?"right":"left",S=e.btt?"top":"bottom";let o=e.stat;for(;o;){let s=(o.level-2)*e.indent+e.treeLineOffset;const p=O(o),h=()=>{b.push({style:{[k]:s+"px",[S]:p?0:"50%"}})};o===e.stat?o.level>1&&h():p&&h(),o=o.parent}return b}),d=m.computed(()=>{let b=(e.stat.level-2)*e.indent+e.treeLineOffset;return{[e.rtl?"right":"left"]:b+"px"}});return{indentStyle:r,vLines:i,hLineStyle:d}}}),Y=(e,t)=>{const r=e.__vccOpts||e;for(const[i,d]of t)r[i]=d;return r},ye={class:"tree-node-inner"},me={key:1,class:"tree-node",ref:"el"};function be(e,t,r,i,d,b){return e.table?(l.openBlock(),l.createElementBlock("tr",me,[l.renderSlot(e.$slots,"default",{indentStyle:e.indentStyle})],512)):(l.openBlock(),l.createElementBlock("div",{key:0,class:l.normalizeClass(["tree-node",{"tree-node--with-tree-line":e.treeLine}]),style:l.normalizeStyle(e.indentStyle),ref:"el"},[e.treeLine?(l.openBlock(),l.createElementBlock(l.Fragment,{key:0},[(l.openBlock(!0),l.createElementBlock(l.Fragment,null,l.renderList(e.vLines,O=>(l.openBlock(),l.createElementBlock("div",{class:"tree-line tree-vline",style:l.normalizeStyle(O.style)},null,4))),256)),e.stat.level>1?(l.openBlock(),l.createElementBlock("div",{key:0,class:"tree-line tree-hline",style:l.normalizeStyle(e.hLineStyle)},null,4)):l.createCommentVNode("",!0)],64)):l.createCommentVNode("",!0),l.createElementVNode("div",ye,[l.renderSlot(e.$slots,"default",{indentStyle:e.indentStyle})])],6))}const te=Y(ge,[["render",be]]);function De(e,t={}){const r={...t,statHandler(i){return this._statHandler2&&(i=this._statHandler2(i)),G(t.statHandler,m.reactive(i))},statsHandler(i){return G(t.statsHandler,m.reactive(i))},statsFlatHandler(i){return G(t.statsFlatHandler,m.reactive(i))}};return X.makeTreeProcessor(e,r)}function G(e,t){return e?e(t):t}const Ce=m.defineComponent({components:{VirtualList:fe,TreeNode:te},props:{value:{required:m.isVue2,type:Array},modelValue:{required:m.isVue3,type:Array},updateBehavior:{type:String,default:"modify"},processor:{type:Object,default:()=>De([],{noInitialization:!0})},childrenKey:{type:String,default:"children"},textKey:{type:String,default:"text"},indent:{type:Number,default:20},virtualization:{type:Boolean,default:!1},virtualizationPrerenderCount:{type:Number,default:20},defaultOpen:{type:Boolean,default:!0},statHandler:{type:Function},rtl:{type:Boolean,default:!1},btt:{type:Boolean,default:!1},table:{type:Boolean,default:!1},watermark:{type:Boolean,default:!1},nodeKey:{type:[String,Function],default:"index"},treeLine:{type:Boolean,default:!1},treeLineOffset:{type:Number,default:8}},emits:["update:modelValue","click:node","open:node","close:node","check:node","beforeDragStart","before-drag-start","after-drop","change","enter","leave"],data(){return{stats:[],statsFlat:[],dragNode:null,dragOvering:!1,placeholderData:{},placeholderColspan:1,batchUpdateWaiting:!1,self:this,_ignoreValueChangeOnce:!1}},computed:{valueComputed(){return(m.isVue2?this.value:this.modelValue)||[]},visibleStats(){const{statsFlat:e,isVisible:t}=this;let r=e;return this.btt&&(r=r.slice(),r.reverse()),r.filter(i=>t(i))},rootChildren(){return this.stats}},methods:{_emitValue(e){this.$emit(m.isVue2?"input":"update:modelValue",e)},_updateValue(e){return this.updateBehavior==="disabled"?!1:(e!==this.valueComputed&&(this._ignoreValueChangeOnce=!0),this._emitValue(e),!0)},getStat:J(w("getStat")),has:J(w("has")),updateCheck:w("updateCheck"),getChecked:w("getChecked"),getUnchecked:w("getUnchecked"),openAll:w("openAll"),closeAll:w("closeAll"),openNodeAndParents:w("openNodeAndParents"),isVisible:w("isVisible"),move:re("move"),add:J(re("add")),addMulti(e,t,r){this.batchUpdate(()=>{let i=r;for(const d of e)this.add(d,t,i),i!=null&&i++})},remove:w("remove"),removeMulti(e){let t=[...e];this.batchUpdate(()=>{for(const r of t)this.remove(r)})},iterateParent:w("iterateParent"),getSiblings:w("getSiblings"),getData:w("getData"),getRootEl(){return this.$refs.vtlist.listElRef},batchUpdate(e){const t=this.ignoreUpdate(e);return this.batchUpdateWaiting||this._updateValue(this.updateBehavior==="new"?this.getData():this.valueComputed),t},ignoreUpdate(e){const t=this.batchUpdateWaiting;this.batchUpdateWaiting=!0;const r=e();return this.batchUpdateWaiting=t,r}},watch:{processor:{immediate:!0,handler(e){if(e){const t=r=>{if(r){const{childrenKey:i}=this;return r[i]||(r[i]=[]),r[i]}else return this.valueComputed};e._statHandler2=this.statHandler?r=>r.data===this.placeholderData?r:this.statHandler(r):null,e.afterSetStat=(r,i,d)=>{const{childrenKey:b,updateBehavior:O}=this;let k=this.valueComputed;if(O==="new"){if(this.batchUpdateWaiting)return;k=this.getData()}else if(O==="modify"){const S=t(i==null?void 0:i.data);S.includes(r.data)||S.splice(d,0,r.data)}this.batchUpdateWaiting||this._updateValue(k)},e.afterRemoveStat=r=>{var O;const{childrenKey:i,updateBehavior:d}=this;let b=this.valueComputed;if(d==="new"){if(this.batchUpdateWaiting)return;b=this.getData()}else if(d==="modify"){const k=t((O=r.parent)==null?void 0:O.data);c.arrayRemove(k,r.data)}this.batchUpdateWaiting||this._updateValue(b)}}e.initialized||(e.data=this.valueComputed,Object.assign(e,c.objectOnly(this,["childrenKey","defaultOpen"])),e.init(),e.updateCheck()),this.stats=e.stats,this.statsFlat=e.statsFlat,e.data!==this.valueComputed&&this._updateValue(e.data)}},valueComputed:{handler(e){if(this.dragOvering||this.dragNode||this._ignoreValueChangeOnce)this._ignoreValueChangeOnce=!1;else{const{processor:r}=this;r.data=e,r.init(),this.stats=r.stats,this.statsFlat=r.statsFlat}}}},created(){},mounted(){this.watermark===!1&&(window._heTreeWatermarkDisabled=!0),this.watermark&&!window._heTreeWatermarkDisabled&&(window._heTreeWatermark||(window._heTreeWatermark=!0,console.log("%c[he-tree] Vue tree component: https://hetree.phphe.com","color:#0075ff; font-size:14px;")))}});function w(e){return function(...t){return this.processor[e](...t)}}function re(e){return function(...t){return this.batchUpdate(()=>this.processor[e](...t))}}function J(e){return function(t,...r){return t&&(t=m.reactive(t)),e.call(this,t,...r)}}const ve={key:0,class:"drag-placeholder he-tree-drag-placeholder"},ke=["colspan"],Se={class:"drag-placeholder he-tree-drag-placeholder"};function Oe(e,t,r,i,d,b){const O=l.resolveComponent("TreeNode"),k=l.resolveComponent("VirtualList");return l.openBlock(),l.createBlock(k,{class:l.normalizeClass(["he-tree",{"he-tree--rtl rtl":e.rtl,"he-tree--drag-overing drag-overing":e.dragOvering}]),ref:"vtlist",items:e.visibleStats,disabled:!e.virtualization,table:e.table,itemKey:e.nodeKey},{prepend:l.withCtx(()=>[l.renderSlot(e.$slots,"prepend",{tree:e.self})]),default:l.withCtx(({item:S,index:o})=>[l.createVNode(O,{"vt-index":o,class:l.normalizeClass([S.class,{"drag-placeholder-wrapper":S.data===e.placeholderData,"dragging-node":S===e.dragNode}]),style:l.normalizeStyle(S.style),stat:S,rtl:e.rtl,btt:e.btt,indent:e.indent,table:e.table,treeLine:e.treeLine,treeLineOffset:e.treeLineOffset,processor:e.processor,onClick:s=>e.$emit("click:node",S),onOpen:t[0]||(t[0]=s=>e.$emit("open:node",s)),onClose:t[1]||(t[1]=s=>e.$emit("close:node",s)),onCheck:t[2]||(t[2]=s=>e.$emit("check:node",s))},{default:l.withCtx(({indentStyle:s})=>[S.data===e.placeholderData?(l.openBlock(),l.createElementBlock(l.Fragment,{key:0},[e.table?(l.openBlock(),l.createElementBlock("td",{key:1,style:l.normalizeStyle(s),colspan:e.placeholderColspan},[l.createElementVNode("div",Se,[l.renderSlot(e.$slots,"placeholder",{tree:e.self})])],12,ke)):(l.openBlock(),l.createElementBlock("div",ve,[l.renderSlot(e.$slots,"placeholder",{tree:e.self})]))],64)):l.renderSlot(e.$slots,"default",{key:1,node:S.data,stat:S,indentStyle:s,tree:e.self},()=>[l.createTextVNode(l.toDisplayString(S.data[e.textKey]),1)])]),_:2},1032,["vt-index","class","style","stat","rtl","btt","indent","table","treeLine","treeLineOffset","processor","onClick"])]),append:l.withCtx(()=>[l.renderSlot(e.$slots,"append",{tree:e.self})]),_:3},8,["class","items","disabled","table","itemKey"])}const ne=Y(Ce,[["render",Oe]]);let a=null,n=null,j,z,I,A,Z,N;const le={get startInfo(){return j},get targetInfo(){return z},get dragNode(){return N},get startTree(){return a},get targetTree(){return n}},ae=m.defineComponent({extends:ne,props:{triggerClass:{type:[String,Array]},disableDrag:Boolean,disableDrop:Boolean,eachDraggable:{type:Function},eachDroppable:{type:Function},rootDroppable:{type:[Boolean,Function],default:!0},dragOpen:{type:Boolean,default:!0},dragOpenDelay:{type:Number,default:0},beforeDragOpen:{type:Function},resolveStartMovePoint:{type:[String,Function]},keepPlaceholder:{type:Boolean},maxLevel:{type:Number},dragCopy:{type:Boolean},dragCopyDataHandler:{type:Function},onExternalDragOver:{type:Function},externalDataHandler:{type:Function},ondragstart:{type:Function}},data(){return{treeDraggableInstance:null}},computed:{},methods:{getNodeByElement(e){const t=e.getAttribute("vt-index");return t==null?null:this.visibleStats[t]},isDraggable(e){if(this.disableDrag)return!1;if(e.draggable!=null)return e.draggable;if(this.eachDraggable){const r=this.eachDraggable(e);if(r!=null)return r}const{parent:t}=e;return t?this.isDraggable(t):!0},isDroppable(e){if(this.disableDrop)return!1;if(!e)return c.resolveValueOrGettter(this.rootDroppable,[this,a]);if(e.droppable!=null)return e.droppable;if(this.eachDroppable){const r=this.eachDroppable(e);if(r!=null)return r}const{parent:t}=e;return t?this.isDroppable(t):!0},_eachDroppable(){var e;return c.resolveValueOrGettter((e=this._isDragCopy)==null?void 0:e.call(this),[this])}},mounted(){const e=(o,s)=>{let p=!0;return a&&a!==this&&(p=p&&this._isMoved),this.table&&!this._isDragCopy&&(p=p&&this._isDragCopy),p&&(o.x!==s.x||o.y!==s.y)},t=(o,s)=>{n.ignoreUpdate(()=>{if(!n.has(n.placeholderData)){if(n.table){let h=0;const y=n.getRootEl().querySelector("tr");if(y)for(const{value:D}of c.iterateAll(y.children))c.css(D,"display")!=="none"&&(h+=D.colSpan||1);h<1&&(h=1),n.placeholderColspan=h}n.add(n.placeholderData)}const p=n.getStat(n.placeholderData);n.move(p,o,s)})},r=()=>{const o=this;if(o.has(o.placeholderData))return o.remove(o.getStat(o.placeholderData)),!0},i=o=>{o?P.context.dropEffect=a!=null&&a.dragCopy?"copy":"move":P.context.dropEffect="none"},d=o=>{const s=this;o?i(!0):s.keepPlaceholder?s.has(s.placeholderData)||i(!1):(r(),i(!1))};let b={x:0,y:0};const O=this.getRootEl();let k=null;const S=()=>{n!=null&&n.has(n.placeholderData)&&n.ignoreUpdate(()=>{n.remove(n.getStat(n.placeholderData)),a&&(a.dragNode.hidden=!1,a.dragOvering=!1)})};this.treeDraggableInstance=P.extendedDND(O,{beforeDragStart:o=>{if(!P.context.triggerElement)return;let s=this.triggerClass;(!s||s.length===0)&&(s="tree-node");let p=c.toArrayIfNot(s),h=c.findParent(P.context.triggerElement,y=>{if(c.hasClassIn(y,p))return!0;if(c.hasClass(y,"tree-node"))return"break"},{withSelf:!0,until:O});if(k=c.findParent(h,y=>{if(c.hasClass(y,"tree-node"))return!0},{withSelf:!0,until:O}),!!k){if(N=this.getNodeByElement(k),!N)throw"Can't find drag node";if(this.isDraggable(N))return this.$emit("before-drag-start",N),this.$emit("beforeDragStart",N),O}},onDragStart:o=>{var y,D,f;if(!k||!N)return;{const{x:g,y:E}=k.getBoundingClientRect(),{clientX:C,clientY:F}=o;(y=o.dataTransfer)==null||y.setDragImage(k,C-g,F-E)}Z={x:o.clientX,y:o.clientY},a=this,a.dragNode=N,A=(()=>{if(this.resolveStartMovePoint==="mouse")return{x:o.clientX,y:o.clientY};if(typeof this.resolveStartMovePoint=="function")return this.resolveStartMovePoint(k);{let g,E=0;if(this.table){let C=k.getBoundingClientRect();g={x:C.x,y:C.y},this.rtl&&(g.x=C.right),E=C.height}else if(!this.rtl)g=k.children[0].getBoundingClientRect().toJSON(),E=g.height;else{const C=k.children[0].getBoundingClientRect();g={x:C.right,y:C.y},E=C.height}return this.btt&&(g.y+=E),g}})(),this.dragOvering=!0;const p=a.getSiblings(a.dragNode),h=p.indexOf(N);j={tree:a,dragNode:N,parent:N.parent,siblings:p,indexBeforeDrop:h},n=this,(D=o.dataTransfer)==null||D.setData("text",`he-tree drag start at ${new Date().toISOString()}`),a._eachDroppable()||setTimeout(()=>{N.hidden=!0,t(N.parent,h+1)},0),(f=this.ondragstart)==null||f.call(this,o)},onEnter:o=>{this.$emit("enter",o)},onLeave:o=>{I=null,this.dragOvering=!1,P.context.preventDefault=!1,r(),this.$emit("leave",o)},onDragOver:c.applyFinally(o=>{if(!a){if(!this.onExternalDragOver||this.onExternalDragOver(o)===!1)return;P.context.preventDefault=!0}const s={x:o.clientX,y:o.clientY},p=e(s,b);if(b=s,!p)return;this.dragOvering=!0,n=this;const h=A?{x:A.x+(s.x-Z.x),y:A.y+(s.y-Z.y)}:{...s},{btt:y,rtl:D}=n;if(n.disableDrop){P.context.dropEffect="none";return}let f,g;const E=n.getRootEl().querySelectorAll(".tree-node"),C=[];E.forEach(u=>{!c.hasClassIn(u,["drag-placeholder-wrapper","dragging-node"])&&c.css(u,"display")!=="none"&&C.push(u)});const F=c.binarySearch(C,u=>c.getBoundingClientRect(u)[y?"bottom":"top"]-h.y,{returnNearestIfNoHit:!0});let B=null,_,Q;F.hit||(F.greater?y||(B=F.index-1,C[B]||B++):y&&(B=F.index+1,C[B]||B--)),B==null&&(B=F.index),_=C[B],Q=y?C[B-1]:C[B+1],f=_&&n.getNodeByElement(_),g=Q&&n.getNodeByElement(Q);const{indent:q}=n,$=c.cacheFunction(()=>{if(n.table){let u=c.getBoundingClientRect(_).toJSON();const L=q*(f.level-1);return D?(u.width-=L,u.right-=L):u.x+=L,u}else return c.getBoundingClientRect(_.firstElementChild)}).action,ie=c.cacheFunction(()=>y?h.y>$().y+$().height/2:h.y<$().y+$().height/2).action,Pe=c.cacheFunction(()=>y?!_||B===C.length-1&&ie():!_||B===0&&ie()).action,oe=c.cacheFunction(()=>D?h.x-($().x+$().width):$().x-h.x).action,Fe=c.cacheFunction(()=>D?h.x<$().x+$().width-q:h.x>$().x+q).action;let T;if(Pe())T=1,f=null;else if(f)oe()>0?T=f.level-Math.ceil(oe()/q):Fe()?T=f.level+1:T=f.level;else return;g&&T<g.level&&(T=g.level),(async()=>{let u,L,R=!1,M=null;const W=async x=>{if(x.open)return!0;if(n.dragOpen)if(n.dragOpenDelay)if(M=x,I===x)R=!0;else{let V=c.promisePin();I=x;const H=x;return setTimeout(async()=>{H!==I?(R=!0,V.resolve(!0)):(n.beforeDragOpen&&await n.beforeDragOpen(x),H!==I?(R=!0,V.resolve(!0)):(x.open=!0,M=null,V.resolve(!0)))},n.dragOpenDelay),await V.promise}else return x.open=!0,!0;else return!1},K=async()=>{if(n.isDroppable(f)&&await W(f)){if(R)return;u=f,L=null}else return!1},se=(x=T)=>{let V=f,H=[];for(;V&&V.level>=x;)V=V.parent||null,H.unshift(V);let ce=0;for(const he of H){if(n.isDroppable(he))return u=he,L=H[ce+1]||f,!0;ce++}return!1};f?T>f.level?await K()===!1&&se(f.level):se()===!1&&await K():n.isDroppable(null)&&(u=null),I=M;const de=!!(!R&&(u||u===null));return{cancelled:R,success:de,parent:u,index:de?L?(u?u.children:n.stats).filter(x=>x.data!==n.placeholderData).indexOf(L)+1:0:-1}})().then(u=>{if(!u.cancelled){if(!u.success){d(!1);return}if(n.maxLevel!=null&&n.maxLevel>0){let L=1;if(a){const M=a.dragNode;let W=0;c.walkTreeData(M,K=>{K.level>W&&(W=K.level)},{childrenKey:X.CHILDREN}),L=W-M.level+1}if(L+(u.parent?u.parent.level:0)>n.maxLevel){d(!1);return}}d(!0),t(u.parent,u.index)}})},()=>{}),onDrop:o=>{n=this;const s=!a;if(!n)return;const p=a==null?void 0:a.dragNode;let h,y=(()=>{var f;let D=!0;if(!n.has(n.placeholderData))D=!1;else if(s)h=(f=this.externalDataHandler)==null?void 0:f.call(this,o),D=h!=null;else if(!a.dragCopy){const g=n.getStat(n.placeholderData);a===n&&g.parent===p.parent&&(c.findTreeData(p,E=>E===g),X.CHILDREN)}return D})();if(y){const D=n.getStat(n.placeholderData),f=n.getSiblings(D);z={tree:n,dragNode:p,parent:D.parent,siblings:f,indexBeforeDrop:f.indexOf(D)}}(()=>{if(S(),y){let D=z.indexBeforeDrop;a&&!a.dragCopy&&a===n&&j.parent==z.parent&&j.indexBeforeDrop<D&&D--,a&&a!==n&&!a._eachDroppable()&&a.batchUpdate(()=>{a.remove(p),a.updateCheck()}),n.batchUpdate(()=>{let f=a==null?void 0:a.dragNode,g;h?g=h:a._eachDroppable()&&(g=c.cloneTreeData(a.dragNode.data,{childrenKey:a.childrenKey}),a.dragCopyDataHandler&&(g=a.dragCopyDataHandler(g))),g&&(n.add(g),f=n.getStat(g)),n.move(f,z.parent,D),n.updateCheck()})}n.$emit("after-drop"),y&&(a&&(a.dragCopy||a.$emit("change")),n!==a&&n.$emit("change"))})()},onDragEnd:o=>{S(),a&&(a.dragNode&&(a.dragNode.hidden=!1),a.dragNode=null,a.dragOvering=!1,a=null),n=null,I=null,N=null}})},unmounted(){var e;(e=this.treeDraggableInstance)==null||e.destroy()}}),Ne=m.defineComponent({props:{open:{type:Boolean}}}),Be=[l.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},[l.createElementVNode("title",null,"chevron-right"),l.createElementVNode("path",{d:"M8.59,16.58L13.17,12L8.59,7.41L10,6L16,12L10,18L8.59,16.58Z"})],-1)];function we(e,t,r,i,d,b){return l.openBlock(),l.createElementBlock("a",{class:l.normalizeClass(["he-tree__open-icon",{open:e.open}])},Be,2)}const xe=Y(Ne,[["render",we]]);function Ee(e,t){try{return{mixins:[ae],created:new Function(Le(e,t))()}}catch{throw new Error("he-tree-pro: wrong secret key")}}function Le(e,t){e=encodeURIComponent(e),e.length%2===1&&(e+="h"),e=e.split("").reverse().join(""),t=atob(t);for(let r=0;r<e.length;r+=2){const i=e[r],d=e[r+1];t=$e(t,i,d)}return Ve("arb=inowc=ocmet;etrnfucton){are=1,=tistr{evod !=b}ath(){e&(c_htreWtemak=)=e,._sMve=(=>._eteeatrmrkd.israCoy=)=d.abe,._acDrppbl=(=>.dagop)}",t)}function $e(e,t,r){let i="";for(let d=0;d<e.length;d++){const b=e[d];b===t?i+=r:b===r?i+=t:i+=b}return i}function Ve(e,t){let r=0,i="";for(;;){let d;if(d=r,d>=t.length||(i+=t[d],d=r*2,d>=e.length)||(i+=e[d],d+=1,d>=e.length))break;i+=e[d],r++}return i}Object.defineProperty(v,"walkTreeData",{enumerable:!0,get:()=>ee.walkTreeData}),v.BaseTree=ne,v.Draggable=ae,v.OpenIcon=xe,v.TreeNode=te,v.context=le,v.dragContext=le,v.pro=Ee,Object.defineProperty(v,Symbol.toStringTag,{value:"Module"})}); | ||
*/function pe(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const i=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,i.get?i:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const c=pe(te);let U=!1;const ge=()=>{U=!0,setTimeout(()=>{U=!1},100)},ye=m.defineComponent({props:["stat","rtl","btt","indent","table","treeLine","treeLineOffset","processor"],emits:["open","close","check"],setup(e,{emit:t}){const r=m.computed(()=>({[e.rtl?"paddingRight":"paddingLeft"]:e.indent*(e.stat.level-1)+"px"}));m.watch(()=>e.stat.checked,b=>{U||e.processor.afterOneCheckChanged(e.stat)&&t("check",e.stat)}),m.watch(()=>e.stat.open,b=>{U||(t(b?"open":"close",e.stat),ge())});const i=m.computed(()=>{const b=[],N=s=>{var p;if(s.parent){let h=(p=s.parent)==null?void 0:p.children.indexOf(s);do{h++;let y=s.parent.children[h];if(y){if(!y.hidden)return!0}else break}while(!0)}return!1},k=e.rtl?"right":"left",S=e.btt?"top":"bottom";let o=e.stat;for(;o;){let s=(o.level-2)*e.indent+e.treeLineOffset;const p=N(o),h=()=>{b.push({style:{[k]:s+"px",[S]:p?0:"50%"}})};o===e.stat?o.level>1&&h():p&&h(),o=o.parent}return b}),d=m.computed(()=>{let b=(e.stat.level-2)*e.indent+e.treeLineOffset;return{[e.rtl?"right":"left"]:b+"px"}});return{indentStyle:r,vLines:i,hLineStyle:d}}}),Y=(e,t)=>{const r=e.__vccOpts||e;for(const[i,d]of t)r[i]=d;return r},me={class:"tree-node-inner"},be={key:1,class:"tree-node",ref:"el"};function De(e,t,r,i,d,b){return e.table?(l.openBlock(),l.createElementBlock("tr",be,[l.renderSlot(e.$slots,"default",{indentStyle:e.indentStyle})],512)):(l.openBlock(),l.createElementBlock("div",{key:0,class:l.normalizeClass(["tree-node",{"tree-node--with-tree-line":e.treeLine}]),style:l.normalizeStyle(e.indentStyle),ref:"el"},[e.treeLine?(l.openBlock(),l.createElementBlock(l.Fragment,{key:0},[(l.openBlock(!0),l.createElementBlock(l.Fragment,null,l.renderList(e.vLines,N=>(l.openBlock(),l.createElementBlock("div",{class:"tree-line tree-vline",style:l.normalizeStyle(N.style)},null,4))),256)),e.stat.level>1?(l.openBlock(),l.createElementBlock("div",{key:0,class:"tree-line tree-hline",style:l.normalizeStyle(e.hLineStyle)},null,4)):l.createCommentVNode("",!0)],64)):l.createCommentVNode("",!0),l.createElementVNode("div",me,[l.renderSlot(e.$slots,"default",{indentStyle:e.indentStyle})])],6))}const re=Y(ye,[["render",De]]);function Ce(e,t={}){const r={...t,statHandler(i){return this._statHandler2&&(i=this._statHandler2(i)),G(t.statHandler,m.reactive(i))},statsHandler(i){return G(t.statsHandler,m.reactive(i))},statsFlatHandler(i){return G(t.statsFlatHandler,m.reactive(i))}};return X.makeTreeProcessor(e,r)}function G(e,t){return e?e(t):t}const ve=m.defineComponent({components:{VirtualList:ue,TreeNode:re},props:{value:{required:m.isVue2,type:Array},modelValue:{required:m.isVue3,type:Array},updateBehavior:{type:String,default:"modify"},processor:{type:Object,default:()=>Ce([],{noInitialization:!0})},childrenKey:{type:String,default:"children"},textKey:{type:String,default:"text"},indent:{type:Number,default:20},virtualization:{type:Boolean,default:!1},virtualizationPrerenderCount:{type:Number,default:20},defaultOpen:{type:Boolean,default:!0},statHandler:{type:Function},rtl:{type:Boolean,default:!1},btt:{type:Boolean,default:!1},table:{type:Boolean,default:!1},watermark:{type:Boolean,default:!1},nodeKey:{type:[String,Function],default:"index"},treeLine:{type:Boolean,default:!1},treeLineOffset:{type:Number,default:8}},emits:["update:modelValue","click:node","open:node","close:node","check:node","beforeDragStart","before-drag-start","after-drop","change","enter","leave"],data(){return{stats:[],statsFlat:[],dragNode:null,dragOvering:!1,placeholderData:{},placeholderColspan:1,batchUpdateWaiting:!1,self:this,_ignoreValueChangeOnce:!1}},computed:{valueComputed(){return(m.isVue2?this.value:this.modelValue)||[]},visibleStats(){const{statsFlat:e,isVisible:t}=this;let r=e;return this.btt&&(r=r.slice(),r.reverse()),r.filter(i=>t(i))},rootChildren(){return this.stats}},methods:{_emitValue(e){this.$emit(m.isVue2?"input":"update:modelValue",e)},_updateValue(e){return this.updateBehavior==="disabled"?!1:(e!==this.valueComputed&&(this._ignoreValueChangeOnce=!0),this._emitValue(e),!0)},getStat:J(w("getStat")),has:J(w("has")),updateCheck:w("updateCheck"),getChecked:w("getChecked"),getUnchecked:w("getUnchecked"),openAll:w("openAll"),closeAll:w("closeAll"),openNodeAndParents:w("openNodeAndParents"),isVisible:w("isVisible"),move:ne("move"),add:J(ne("add")),addMulti(e,t,r){this.batchUpdate(()=>{let i=r;for(const d of e)this.add(d,t,i),i!=null&&i++})},remove:w("remove"),removeMulti(e){let t=[...e];this.batchUpdate(()=>{for(const r of t)this.remove(r)})},iterateParent:w("iterateParent"),getSiblings:w("getSiblings"),getData:w("getData"),getRootEl(){return this.$refs.vtlist.listElRef},batchUpdate(e){const t=this.ignoreUpdate(e);return this.batchUpdateWaiting||this._updateValue(this.updateBehavior==="new"?this.getData():this.valueComputed),t},ignoreUpdate(e){const t=this.batchUpdateWaiting;this.batchUpdateWaiting=!0;const r=e();return this.batchUpdateWaiting=t,r}},watch:{processor:{immediate:!0,handler(e){if(e){const t=r=>{if(r){const{childrenKey:i}=this;return r[i]||(r[i]=[]),r[i]}else return this.valueComputed};e._statHandler2=this.statHandler?r=>r.data===this.placeholderData?r:this.statHandler(r):null,e.afterSetStat=(r,i,d)=>{const{childrenKey:b,updateBehavior:N}=this;let k=this.valueComputed;if(N==="new"){if(this.batchUpdateWaiting)return;k=this.getData()}else if(N==="modify"){const S=t(i==null?void 0:i.data);S.includes(r.data)||S.splice(d,0,r.data)}this.batchUpdateWaiting||this._updateValue(k)},e.afterRemoveStat=r=>{var N;const{childrenKey:i,updateBehavior:d}=this;let b=this.valueComputed;if(d==="new"){if(this.batchUpdateWaiting)return;b=this.getData()}else if(d==="modify"){const k=t((N=r.parent)==null?void 0:N.data);c.arrayRemove(k,r.data)}this.batchUpdateWaiting||this._updateValue(b)}}e.initialized||(e.data=this.valueComputed,Object.assign(e,c.objectOnly(this,["childrenKey","defaultOpen"])),e.init(),e.updateCheck()),this.stats=e.stats,this.statsFlat=e.statsFlat,e.data!==this.valueComputed&&this._updateValue(e.data)}},valueComputed:{handler(e){if(this.dragOvering||this.dragNode||this._ignoreValueChangeOnce)this._ignoreValueChangeOnce=!1;else{const{processor:r}=this;r.data=e,r.init(),this.stats=r.stats,this.statsFlat=r.statsFlat}}}},created(){},mounted(){this.watermark===!1&&(window._heTreeWatermarkDisabled=!0),this.watermark&&!window._heTreeWatermarkDisabled&&(window._heTreeWatermark||(window._heTreeWatermark=!0,console.log("%c[he-tree] Vue tree component: https://hetree.phphe.com","color:#0075ff; font-size:14px;")))}});function w(e){return function(...t){return this.processor[e](...t)}}function ne(e){return function(...t){return this.batchUpdate(()=>this.processor[e](...t))}}function J(e){return function(t,...r){return t&&(t=m.reactive(t)),e.call(this,t,...r)}}const ke={key:0,class:"drag-placeholder he-tree-drag-placeholder"},Se=["colspan"],Ne={class:"drag-placeholder he-tree-drag-placeholder"};function Oe(e,t,r,i,d,b){const N=l.resolveComponent("TreeNode"),k=l.resolveComponent("VirtualList");return l.openBlock(),l.createBlock(k,{class:l.normalizeClass(["he-tree",{"he-tree--rtl rtl":e.rtl,"he-tree--drag-overing drag-overing":e.dragOvering}]),ref:"vtlist",items:e.visibleStats,disabled:!e.virtualization,table:e.table,itemKey:e.nodeKey},{prepend:l.withCtx(()=>[l.renderSlot(e.$slots,"prepend",{tree:e.self})]),default:l.withCtx(({item:S,index:o})=>[l.createVNode(N,{"vt-index":o,class:l.normalizeClass([S.class,{"drag-placeholder-wrapper":S.data===e.placeholderData,"dragging-node":S===e.dragNode}]),style:l.normalizeStyle(S.style),stat:S,rtl:e.rtl,btt:e.btt,indent:e.indent,table:e.table,treeLine:e.treeLine,treeLineOffset:e.treeLineOffset,processor:e.processor,onClick:s=>e.$emit("click:node",S),onOpen:t[0]||(t[0]=s=>e.$emit("open:node",s)),onClose:t[1]||(t[1]=s=>e.$emit("close:node",s)),onCheck:t[2]||(t[2]=s=>e.$emit("check:node",s))},{default:l.withCtx(({indentStyle:s})=>[S.data===e.placeholderData?(l.openBlock(),l.createElementBlock(l.Fragment,{key:0},[e.table?(l.openBlock(),l.createElementBlock("td",{key:1,style:l.normalizeStyle(s),colspan:e.placeholderColspan},[l.createElementVNode("div",Ne,[l.renderSlot(e.$slots,"placeholder",{tree:e.self})])],12,Se)):(l.openBlock(),l.createElementBlock("div",ke,[l.renderSlot(e.$slots,"placeholder",{tree:e.self})]))],64)):l.renderSlot(e.$slots,"default",{key:1,node:S.data,stat:S,indentStyle:s,tree:e.self},()=>[l.createTextVNode(l.toDisplayString(S.data[e.textKey]),1)])]),_:2},1032,["vt-index","class","style","stat","rtl","btt","indent","table","treeLine","treeLineOffset","processor","onClick"])]),append:l.withCtx(()=>[l.renderSlot(e.$slots,"append",{tree:e.self})]),_:3},8,["class","items","disabled","table","itemKey"])}const le=Y(ve,[["render",Oe]]);let a=null,n=null,j,z,I,A,Z,O,Q;const ae={get startInfo(){return j},get targetInfo(){return z},get dragNode(){return O},get startTree(){return a},get targetTree(){return n},get closestNode(){return Q}},ie=m.defineComponent({extends:le,props:{triggerClass:{type:[String,Array]},disableDrag:Boolean,disableDrop:Boolean,eachDraggable:{type:Function},eachDroppable:{type:Function},rootDroppable:{type:[Boolean,Function],default:!0},dragOpen:{type:Boolean,default:!0},dragOpenDelay:{type:Number,default:0},beforeDragOpen:{type:Function},resolveStartMovePoint:{type:[String,Function]},keepPlaceholder:{type:Boolean},maxLevel:{type:Number},dragCopy:{type:Boolean},dragCopyDataHandler:{type:Function},onExternalDragOver:{type:Function},externalDataHandler:{type:Function},ondragstart:{type:Function}},data(){return{treeDraggableInstance:null}},computed:{},methods:{getNodeByElement(e){const t=e.getAttribute("vt-index");return t==null?null:this.visibleStats[t]},isDraggable(e){if(this.disableDrag)return!1;if(e.draggable!=null)return e.draggable;if(this.eachDraggable){const r=this.eachDraggable(e);if(r!=null)return r}const{parent:t}=e;return t?this.isDraggable(t):!0},isDroppable(e){if(this.disableDrop)return!1;if(!e)return c.resolveValueOrGettter(this.rootDroppable,[this,a]);if(e.droppable!=null)return e.droppable;if(this.eachDroppable){const r=this.eachDroppable(e);if(r!=null)return r}const{parent:t}=e;return t?this.isDroppable(t):!0},_eachDroppable(){var e;return c.resolveValueOrGettter((e=this._isDragCopy)==null?void 0:e.call(this),[this])}},mounted(){const e=(o,s)=>{let p=!0;return a&&a!==this&&(p=p&&this._isMoved),this.table&&!this._isDragCopy&&(p=p&&this._isDragCopy),p&&(o.x!==s.x||o.y!==s.y)},t=(o,s)=>{n.ignoreUpdate(()=>{if(!n.has(n.placeholderData)){if(n.table){let h=0;const y=n.getRootEl().querySelector("tr");if(y)for(const{value:D}of c.iterateAll(y.children))c.css(D,"display")!=="none"&&(h+=D.colSpan||1);h<1&&(h=1),n.placeholderColspan=h}n.add(n.placeholderData)}const p=n.getStat(n.placeholderData);n.move(p,o,s)})},r=()=>{const o=this;if(o.has(o.placeholderData))return o.remove(o.getStat(o.placeholderData)),!0},i=o=>{o?P.context.dropEffect=a!=null&&a.dragCopy?"copy":"move":P.context.dropEffect="none"},d=o=>{const s=this;o?i(!0):s.keepPlaceholder?s.has(s.placeholderData)||i(!1):(r(),i(!1))};let b={x:0,y:0};const N=this.getRootEl();let k=null;const S=()=>{n!=null&&n.has(n.placeholderData)&&n.ignoreUpdate(()=>{n.remove(n.getStat(n.placeholderData)),a&&(a.dragNode.hidden=!1,a.dragOvering=!1)})};this.treeDraggableInstance=P.extendedDND(N,{beforeDragStart:o=>{if(!P.context.triggerElement)return;let s=this.triggerClass;(!s||s.length===0)&&(s="tree-node");let p=c.toArrayIfNot(s),h=c.findParent(P.context.triggerElement,y=>{if(c.hasClassIn(y,p))return!0;if(c.hasClass(y,"tree-node"))return"break"},{withSelf:!0,until:N});if(k=c.findParent(h,y=>{if(c.hasClass(y,"tree-node"))return!0},{withSelf:!0,until:N}),!!k){if(O=this.getNodeByElement(k),!O)throw"Can't find drag node";if(this.isDraggable(O))return this.$emit("before-drag-start",O),this.$emit("beforeDragStart",O),N}},onDragStart:o=>{var y,D,f;if(!k||!O)return;{const{x:g,y:E}=k.getBoundingClientRect(),{clientX:C,clientY:F}=o;(y=o.dataTransfer)==null||y.setDragImage(k,C-g,F-E)}Z={x:o.clientX,y:o.clientY},a=this,a.dragNode=O,A=(()=>{if(this.resolveStartMovePoint==="mouse")return{x:o.clientX,y:o.clientY};if(typeof this.resolveStartMovePoint=="function")return this.resolveStartMovePoint(k);{let g,E=0;if(this.table){let C=k.getBoundingClientRect();g={x:C.x,y:C.y},this.rtl&&(g.x=C.right),E=C.height}else if(!this.rtl)g=k.children[0].getBoundingClientRect().toJSON(),E=g.height;else{const C=k.children[0].getBoundingClientRect();g={x:C.right,y:C.y},E=C.height}return this.btt&&(g.y+=E),g}})(),this.dragOvering=!0;const p=a.getSiblings(a.dragNode),h=p.indexOf(O);j={tree:a,dragNode:O,parent:O.parent,siblings:p,indexBeforeDrop:h},n=this,(D=o.dataTransfer)==null||D.setData("text",`he-tree drag start at ${new Date().toISOString()}`),a._eachDroppable()||setTimeout(()=>{O.hidden=!0,t(O.parent,h+1)},0),(f=this.ondragstart)==null||f.call(this,o)},onEnter:o=>{this.$emit("enter",o)},onLeave:o=>{I=null,this.dragOvering=!1,P.context.preventDefault=!1,r(),this.$emit("leave",o)},onDragOver:c.applyFinally(o=>{if(!a){if(!this.onExternalDragOver||this.onExternalDragOver(o)===!1)return;P.context.preventDefault=!0}const s={x:o.clientX,y:o.clientY},p=e(s,b);if(b=s,!p)return;this.dragOvering=!0,n=this;const h=A?{x:A.x+(s.x-Z.x),y:A.y+(s.y-Z.y)}:{...s},{btt:y,rtl:D}=n;if(n.disableDrop){P.context.dropEffect="none";return}let f,g;const E=n.getRootEl().querySelectorAll(".tree-node"),C=[];E.forEach(u=>{!c.hasClassIn(u,["drag-placeholder-wrapper","dragging-node"])&&c.css(u,"display")!=="none"&&C.push(u)});const F=c.binarySearch(C,u=>c.getBoundingClientRect(u)[y?"bottom":"top"]-h.y,{returnNearestIfNoHit:!0});let B=null,_,ee;F.hit||(F.greater?y||(B=F.index-1,C[B]||B++):y&&(B=F.index+1,C[B]||B--)),B==null&&(B=F.index),_=C[B],ee=y?C[B-1]:C[B+1],f=_&&n.getNodeByElement(_),g=ee&&n.getNodeByElement(ee);const{indent:q}=n,$=c.cacheFunction(()=>{if(n.table){let u=c.getBoundingClientRect(_).toJSON();const L=q*(f.level-1);return D?(u.width-=L,u.right-=L):u.x+=L,u}else return c.getBoundingClientRect(_.firstElementChild)}).action,oe=c.cacheFunction(()=>y?h.y>$().y+$().height/2:h.y<$().y+$().height/2).action,Fe=c.cacheFunction(()=>y?!_||B===C.length-1&&oe():!_||B===0&&oe()).action,se=c.cacheFunction(()=>D?h.x-($().x+$().width):$().x-h.x).action,Te=c.cacheFunction(()=>D?h.x<$().x+$().width-q:h.x>$().x+q).action;let T;if(Fe())T=1,f=null;else if(f)se()>0?T=f.level-Math.ceil(se()/q):Te()?T=f.level+1:T=f.level;else return;g&&T<g.level&&(T=g.level),(async()=>{let u,L,R=!1,M=null;const W=async x=>{if(x.open)return!0;if(n.dragOpen)if(n.dragOpenDelay)if(M=x,I===x)R=!0;else{let V=c.promisePin();I=x;const H=x;return setTimeout(async()=>{H!==I?(R=!0,V.resolve(!0)):(n.beforeDragOpen&&await n.beforeDragOpen(x),H!==I?(R=!0,V.resolve(!0)):(x.open=!0,M=null,V.resolve(!0)))},n.dragOpenDelay),await V.promise}else return x.open=!0,!0;else return!1},K=async()=>{if(n.isDroppable(f)&&await W(f)){if(R)return;u=f,L=null}else return!1},de=(x=T)=>{let V=f,H=[];for(;V&&V.level>=x;)V=V.parent||null,H.unshift(V);let he=0;for(const fe of H){if(n.isDroppable(fe))return u=fe,L=H[he+1]||f,!0;he++}return!1};Q=f||null,f?T>f.level?await K()===!1&&de(f.level):de()===!1&&await K():n.isDroppable(null)&&(u=null),I=M;const ce=!!(!R&&(u||u===null));return{cancelled:R,success:ce,parent:u,index:ce?L?(u?u.children:n.stats).filter(x=>x.data!==n.placeholderData).indexOf(L)+1:0:-1}})().then(u=>{if(!u.cancelled){if(!u.success){d(!1);return}if(n.maxLevel!=null&&n.maxLevel>0){let L=1;if(a){const M=a.dragNode;let W=0;c.walkTreeData(M,K=>{K.level>W&&(W=K.level)},{childrenKey:X.CHILDREN}),L=W-M.level+1}if(L+(u.parent?u.parent.level:0)>n.maxLevel){d(!1);return}}d(!0),t(u.parent,u.index)}})},()=>{}),onDrop:o=>{n=this;const s=!a;if(!n)return;const p=a==null?void 0:a.dragNode;let h,y=(()=>{var f;let D=!0;if(!n.has(n.placeholderData))D=!1;else if(s)h=(f=this.externalDataHandler)==null?void 0:f.call(this,o),D=h!=null;else if(!a.dragCopy){const g=n.getStat(n.placeholderData);a===n&&g.parent===p.parent&&(c.findTreeData(p,E=>E===g),X.CHILDREN)}return D})();if(y){const D=n.getStat(n.placeholderData),f=n.getSiblings(D);z={tree:n,dragNode:p,parent:D.parent,siblings:f,indexBeforeDrop:f.indexOf(D)}}(()=>{if(S(),y){let D=z.indexBeforeDrop;a&&!a.dragCopy&&a===n&&j.parent==z.parent&&j.indexBeforeDrop<D&&D--,a&&a!==n&&!a._eachDroppable()&&a.batchUpdate(()=>{a.remove(p),a.updateCheck()}),n.batchUpdate(()=>{let f=a==null?void 0:a.dragNode,g;h?g=h:a._eachDroppable()&&(g=c.cloneTreeData(a.dragNode.data,{childrenKey:a.childrenKey}),a.dragCopyDataHandler&&(g=a.dragCopyDataHandler(g))),g&&(n.add(g),f=n.getStat(g)),n.move(f,z.parent,D),n.updateCheck()})}n.$emit("after-drop"),y&&(a&&(a.dragCopy||a.$emit("change")),n!==a&&n.$emit("change"))})()},onDragEnd:o=>{S(),a&&(a.dragNode&&(a.dragNode.hidden=!1),a.dragNode=null,a.dragOvering=!1,a=null),n=null,I=null,O=null,Q=null}})},unmounted(){var e;(e=this.treeDraggableInstance)==null||e.destroy()}}),Be=m.defineComponent({props:{open:{type:Boolean}}}),we=[l.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},[l.createElementVNode("title",null,"chevron-right"),l.createElementVNode("path",{d:"M8.59,16.58L13.17,12L8.59,7.41L10,6L16,12L10,18L8.59,16.58Z"})],-1)];function xe(e,t,r,i,d,b){return l.openBlock(),l.createElementBlock("a",{class:l.normalizeClass(["he-tree__open-icon",{open:e.open}])},we,2)}const Ee=Y(Be,[["render",xe]]);function Le(e,t){try{return{mixins:[ie],created:new Function($e(e,t))()}}catch{throw new Error("he-tree-pro: wrong secret key")}}function $e(e,t){e=encodeURIComponent(e),e.length%2===1&&(e+="h"),e=e.split("").reverse().join(""),t=atob(t);for(let r=0;r<e.length;r+=2){const i=e[r],d=e[r+1];t=Ve(t,i,d)}return Pe("arb=inowc=ocmet;etrnfucton){are=1,=tistr{evod !=b}ath(){e&(c_htreWtemak=)=e,._sMve=(=>._eteeatrmrkd.israCoy=)=d.abe,._acDrppbl=(=>.dagop)}",t)}function Ve(e,t,r){let i="";for(let d=0;d<e.length;d++){const b=e[d];b===t?i+=r:b===r?i+=t:i+=b}return i}function Pe(e,t){let r=0,i="";for(;;){let d;if(d=r,d>=t.length||(i+=t[d],d=r*2,d>=e.length)||(i+=e[d],d+=1,d>=e.length))break;i+=e[d],r++}return i}Object.defineProperty(v,"walkTreeData",{enumerable:!0,get:()=>te.walkTreeData}),v.BaseTree=le,v.Draggable=ie,v.OpenIcon=Ee,v.TreeNode=re,v.context=ae,v.dragContext=ae,v.pro=Le,Object.defineProperty(v,Symbol.toStringTag,{value:"Module"})}); |
{ | ||
"name": "@he-tree/vue", | ||
"version": "2.8.7", | ||
"version": "2.9.1", | ||
"description": "Vue tree component. Features: Vue2 & 3, TypeScript, SSR, nested, virtual list, draggable, sortable, placeholder for drag, table tree, based on Drag and Drop API, deal with any other code based on Drag and Drop API.", | ||
@@ -76,3 +76,3 @@ "keywords": [ | ||
}, | ||
"gitHead": "69440d661a762f5ce41b2250f5db09a96d11b9ce" | ||
"gitHead": "15050501bc4fb7637f6de45df21a096c8191cea2" | ||
} |
@@ -8,10 +8,12 @@ # he-tree | ||
Vue tree component. Features: Vue2, Vue3, TypeScript, SSR, nested, virtual list, draggable, sortable, placeholder for drag, table tree, based on Drag and Drop API, deal with any other code based on Drag and Drop API. | ||
Vue tree component. [React click here](https://github.com/phphe/he-tree-react). Features: Vue2, Vue3, TypeScript, SSR, nested, virtual list, draggable, sortable, placeholder for drag, table tree, based on Drag and Drop API, deal with any other code based on Drag and Drop API. | ||
Vue 树组件. 特点: 支持 Vue2, Vue3, TypeScript, SSR, 嵌套, 虚拟列表, 可拖拽, 拖拽排序, 拖拽时使用占位节点表示可放置位置, 表格模式, 基于 Drag and Drop API, 可与其他基于 Drag and Drop API 的代码交互. | ||
Vue 树组件. [React 点这](https://github.com/phphe/he-tree-react). 特点: 支持 Vue2, Vue3, TypeScript, SSR, 嵌套, 虚拟列表, 可拖拽, 拖拽排序, 拖拽时使用占位节点表示可放置位置, 表格模式, 基于 Drag and Drop API, 可与其他基于 Drag and Drop API 的代码交互. | ||
[Docs & Demo](https://hetree.phphe.com) | [文档和示例](https://hetree.phphe.com/zh) | ||
[React Tree](https://github.com/phphe/he-tree-react) | [React 版树组件](https://github.com/phphe/he-tree-react) 👑👑👑 | ||
## License | ||
[MIT](http://opensource.org/licenses/MIT) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
19
872316
6320