/**
 * Kendo UI v2023.3.1114 (http://www.telerik.com/kendo-ui)
 * Copyright 2023 Progress Software Corporation and/or one of its subsidiaries or affiliates. All rights reserved.
 *
 * Kendo UI commercial licenses may be obtained at
 * http://www.telerik.com/purchase/license-agreement/kendo-ui-complete
 * If you do not own a commercial license, this file shall be governed by the trial license terms.
 */
import"./kendo.data.js";import"./kendo.draganddrop.js";var __meta__={id:"treeview.draganddrop",name:"Hierarchical Drag & Drop",category:"framework",depends:["core","draganddrop"],advanced:!0};!function(t,e){var i=window.kendo,o=i.ui,s=t.extend,n="visibility",r="k-drag-status",a=`<span class="${r}"></span>`,d="k-hover";o.HierarchicalDragAndDrop=i.Class.extend({init:function(e,n){this.element=e,this.hovered=e,this.options=s({dragstart:t.noop,drag:t.noop,drop:t.noop,dragend:t.noop},n),this._draggable=new o.Draggable(e,{ignore:"input,a:not(.k-in),textarea,.k-multiselect-wrap,select,button,a.k-button>.k-icon,button.k-button>.k-icon,span.k-toggle-icon,a.k-button>.k-svg-icon,button.k-button>.k-svg-icon",filter:n.filter,autoScroll:n.autoScroll,cursorOffset:{left:10,top:i.support.mobileOS?-40/i.support.zoomLevel():10},hint:this._hint.bind(this),dragstart:this.dragstart.bind(this),dragcancel:this.dragcancel.bind(this),hintDestroyed:this.dragcancel.bind(this),drag:this.drag.bind(this),dragend:this.dragend.bind(this),holdToDrag:n.holdToDrag,clickMoveClick:n.clickMoveClick})},_hint:function(t){return"<div class='k-drag-clue'>"+a+this.options.hintText(t)+"</div>"},_removeTouchHover:function(){i.support.touch&&this.hovered&&(this.hovered.find("."+d).removeClass(d),this.hovered=!1)},_hintStatus:function(t){var e=this._draggable.hint.find(`.${r}`);t?(this.status=t,o.icon(e,{icon:t})):(this.status="",e.replaceWith(a))},dragstart:function(e){this.dropHint&&this.dropHint.remove(),this.source=e.currentTarget.closest(this.options.itemSelector),this.options.dragstart(this.source)&&e.preventDefault(),this.options.reorderable?this.dropHint=t("<div class='k-drop-hint k-drop-hint-h'><div class='k-drop-hint-start'></div><div class='k-drop-hint-line'></div></div>").css(n,"hidden").appendTo(this.element):this.dropHint=t()},drag:function(e){var o,s,r,a,l,h,c,p,g,v,u,k=this.options,m=this.source,f=this.dropTarget=t(i.eventTarget(e)),H=f.closest(k.allowedContainers);H.length?m[0]==f[0]||k.contains(m[0],f[0])||e.clickMoveClick&&e.currentTarget.hasClass("k-drag-cell")&&0===f.closest(".k-drag-cell").length||e.clickMoveClick&&e.currentTarget.hasClass("k-treeview-leaf")&&0===f.closest(".k-treeview-leaf").length?u="cancel":(u="insert-middle",(o=(g=k.itemFromTarget(f)).item).length?(this._removeTouchHover(),s=i._outerHeight(o),a=g.content,k.reorderable?(l=s/(a.length>0?4:2),r=i.getOffset(o).top,h=e.y.location<r+l,c=r+s-l<e.y.location,p=a.length&&!h&&!c):(p=!0,h=!1,c=!1),this.hovered=!!p&&H,this.dropHint.css(n,p?"hidden":"visible"),this._lastHover&&this._lastHover[0]!=a[0]&&this._lastHover.removeClass(d),this._lastHover=a.toggleClass(d,p),p?u="plus":((v=o.position()).top+=h?0:s,this.dropHint.css(v)[h?"prependTo":"appendTo"](k.dropHintContainer(o)),h&&g.first&&(u="insert-top"),c&&g.last&&(u="insert-bottom"))):f[0]!=this.dropHint[0]&&(this._lastHover&&this._lastHover.removeClass(d),u=t.contains(this.element[0],H[0])?"cancel":"plus")):(u="cancel",this._removeTouchHover()),this.options.drag({originalEvent:e.originalEvent,source:m,target:f,pageY:e.y.location,pageX:e.x.location,status:u,setStatus:function(t){u=t}}),0!==u.indexOf("insert")&&this.dropHint.css(n,"hidden"),this._hintStatus(u)},dragcancel:function(){this.dropHint&&this.dropHint.remove()},dragend:function(e){var o,s,r,a,l="over",h=this.source,c=this.dropHint,p=this.dropTarget||t(i.eventTarget(e));c&&"visible"==c.css(n)?(l=this.options.dropPositionFrom(c),o=c.closest(this.options.itemSelector),a=!0):p&&((o=p.closest(this.options.itemSelector)).length||(o=p.closest(this.options.allowedContainers))),!a||o.length?(s={originalEvent:e.originalEvent,source:h[0],destination:o[0],valid:"cancel"!=this.status,setValid:function(t){this.valid=t},dropTarget:p[0],position:l},r=this.options.drop(s),c.remove(),this._removeTouchHover(),this._lastHover&&this._lastHover.removeClass(d),s.valid&&!r?(this._draggable.dropped=!0,this.options.dragend({originalEvent:e.originalEvent,source:h,destination:o,position:l})):this._draggable.dropped=s.valid):this.dragcancel()},destroy:function(){this._lastHover=this.hovered=null,this._draggable.destroy()}})}(window.kendo.jQuery);var kendo$1=kendo;export{kendo$1 as default};
//# sourceMappingURL=kendo.treeview.draganddrop.js.map
