@syncfusion/ej2-filemanager
Version:
Essential JS 2 FileManager Component
10 lines • 252 kB
JavaScript
/*!
* filename: ej2-filemanager.min.js
* version : 29.1.33
* Copyright Syncfusion Inc. 2001 - 2024. All rights reserved.
* Use of this code is subject to the terms of our license.
* A copy of the current license can be obtained at any time by e-mailing
* licensing@syncfusion.com. Any infringement will be prosecuted under
* applicable laws.
*/
this.ej=this.ej||{},this.ej.filemanager=function(e,t,i,n,a,s,r,o,l,h,d){"use strict";function p(e,t){var i=/\.\S+/.test(e),n=/\.\S+/.test(t);if(i&&!n)return 1;if(!i&&n)return-1;var a=[],s=[];for((e+"").replace(/(\d+)|(\D+)/g,function(e,t,i){return a.push([t||1/0,i||""]),""}),(t+"").replace(/(\d+)|(\D+)/g,function(e,t,i){return s.push([t||1/0,i||""]),""});a.length&&s.length;){var r=a.shift(),o=s.shift();if(r&&o){var l=r[0]-o[0]||r[1].localeCompare(o[1]);if(l)return l}}return a.length-s.length}function c(e,i,n){var a=t.getValue("name",i),s=e.getAttribute("data-id"),r=t.isNullOrUndefined(s)?a:s;n.setProperties({path:u(e,r,n.hasId)},!0),n.pathId=f(e),n.pathNames=g(e,a)}function u(e,t,i){for(var n=m(e,t,!1,i),a="/",s=n.length-2;s>=0;s--)a+=n[s]+"/";return a}function f(e){for(var t=m(e,e.getAttribute("data-uid"),!0),i=[],n=t.length-1;n>=0;n--)i.push(t[n]);return i}function g(e,t){for(var i=m(e,t,!1),n=[],a=i.length-1;a>=0;a--)n.push(i[a]);return n}function m(e,i,n,a){for(var s=[i],r=e.parentNode;!t.isNullOrUndefined(r);){if(t.matches(r,"."+Ai)){var o=n?r.getAttribute("data-uid"):a?r.getAttribute("data-id"):t.select("."+Fi,r).textContent;s.push(o)}if((r=r.parentNode).classList.contains(ln))break}return s}function b(e){var i=e.hasId?"id":"name",n="/",a=1;for(a;a<e.pathId.length;a++){var s=t.getValue(e.pathId[parseInt(a.toString(),10)],e.feParent);n+=t.getValue(i,s)+"/"}e.setProperties({path:n},!0)}function v(e){e.isCut&&(O(e),e.selectedNodes=[],e.actionRecords=[],e.enablePaste=!1,e.notify(Gn,{}))}function y(e,i){if(i.isSearchCut=!1,i.actionRecords=[],i.activeElements=[],i.notify(Jn,{}),0===i.activeElements.length)return!1;O(i);var n=i.activeElements;"navigationpane"!==i.activeModule?i.targetPath=i.path:i.targetPath=X(i.path);var a=0;if(n&&(w(i,n[0]),"cut"===e))for(;a<n.length;)I(n[a]),a++;for(a=0,i.selectedNodes=[],i.enablePaste=!0,i.notify(Yn,{});a<i.activeRecords.length;)i.actionRecords.push(i.activeRecords[a]),i.selectedNodes.push(t.getValue("name",i.activeRecords[a])),a++;if((""!==i.breadcrumbbarModule.searchObj.element.value||i.isFiltered)&&"navigationpane"!==i.activeModule){i.selectedNodes=[],i.isSearchCut=!0;for(var s=0;s<i.selectedItems.length;)i.selectedNodes.push(i.selectedItems[s]),s++}return!0}function I(e){e.classList.add(_i)}function O(e,t){for(var i=t?e.element.querySelectorAll("."+Bi):e.element.querySelectorAll("."+_i),n=0;n<i.length;)i[n].classList.remove(t?Bi:_i),n++}function w(e,i){i&&(i.classList.contains(Yi)?e.activeModule="detailsview":t.closest(i,"."+sn)?e.activeModule="largeiconsview":e.activeModule="navigationpane")}function D(e,t){var i=e.fileSystemData.filter(function(e){return String(e.parentId)===String(t)}),n=i.slice();return i.forEach(function(t){var i=t.id;n=n.concat(D(e,i))}),n}function S(e,i,n){var s;if(0!==i.length||e.isFiltered||e.notify(ea,{args:e}),Ae(e))if(""===i)e.itemData=e.fileSystemData,Ee(e,n?_n:Tn,e.path);else{e.searchSettings.filterType=t.isNullOrUndefined(e.searchSettings.filterType)?"contains":e.searchSettings.filterType;var r=t.getValue(e.pathId[e.pathId.length-1],e.feParent),o=D(e,t.getValue("id",r)),l=new a.DataManager(o).executeLocal((new a.Query).where("name",e.searchSettings.filterType,i,e.searchSettings.ignoreCase)),h=e.searchSettings.ignoreCase?i.toLowerCase():i;e.itemData=l,ht(e,n?_n:Tn,e.path,h,e.showHiddenItems,!e.searchSettings.ignoreCase)}else if(s="startsWith"===e.searchSettings.filterType?i+"*":"endsWith"===e.searchSettings.filterType?"*"+i:"*"+i+"*",e.searchWord=s,e.itemData=[E(e)],i.length>0){var d=e.searchSettings.ignoreCase,p=e.showHiddenItems;ht(e,n?_n:Tn,e.path,s,p,!d)}else e.isFiltered?Re(e,_n):e.isSortByClicked?(e.notify(_n,{files:"Details"===e.oldView?e.detailsviewModule.gridObj.dataSource:e.largeiconsviewModule.allItems}),e.isSortByClicked=!1):Ee(e,n?_n:Tn,e.path)}function C(e,t){e.oldView=e.view,e.setProperties({view:t},!0),(""!==e.breadcrumbbarModule.searchObj.element.value||e.isFiltered)&&(e.layoutSelectedItems=e.selectedItems);var i="";e.breadcrumbbarModule.searchObj.element.value&&(i=e.breadcrumbbarModule.searchObj.element.value),e.isLayoutChange=!0,S(e,i,!0)}function x(e,i){var n="";i&&(n=t.closest(i,"."+Pi+"."+Ri+" ."+pn)?"detailsview":t.closest(i,"."+Ti)?"largeiconsview":i.classList.contains("e-fullrow")||i.classList.contains("e-icon-expandable")?"navigationpane":t.closest(i,".e-address-list-item")?"breadcrumbbar":""),e.targetModule=n}function j(e){e.itemData=[E(e)],ye(e.itemData[0])?Ee(e,jn,e.path):be(e,e.itemData[0],oa)}function N(e){Ee(e,Fn,e.path)}function E(e){return t.getValue(e.pathId[e.pathId.length-1],e.feParent)}function P(e){y("copy",e)&&(e.fileAction="copy")}function R(e){y("cut",e)&&(e.isCut=!0,e.fileAction="move")}function M(e){if(!t.getValue("isFile",e))return en;var i=["bmp","dib","jpg","jpeg","jpe","jfif","gif","tif","tiff","png","ico"],n=["mp3","wav","aac","ogg","wma","aif","fla","m4a"],a=["webm","mkv","flv","vob","ogv","ogg","avi","wmv","mp4","3gp"],s=["css","exe","html","js","msi","pdf","pptx","ppt","rar","zip","txt","docx","doc","xlsx","xls","xml","rtf","php"],r=t.getValue("type",e);-1!==(r=r.toLowerCase()).indexOf(".")&&(r=r.split(".").join(""));return-1!==i.indexOf(r)?tn:-1!==n.indexOf(r)?nn:-1!==a.indexOf(r)?an:-1!==s.indexOf(r)?"e-fe-"+r:"e-fe-unknown e-fe-"+r}function k(e,i){var n=Ae(e)?t.getValue("imageUrl",i):"";if(Ae(e)){var a={fileDetails:[i],imageUrl:n};return e.trigger("beforeImageLoad",a),a.imageUrl}var s=e.ajaxSettings.getImageUrl?e.ajaxSettings.getImageUrl:e.ajaxSettings.url,r=-1!==s.indexOf("?")?"&path=":"?path=",o=encodeURIComponent(t.getValue("name",i)),l=t.getValue("filterPath",i);if(e.hasId){var h=t.getValue("id",i);n=s+r+e.path+"&id="+h}else n=t.isNullOrUndefined(l)?s+r+e.path+o:s+r+encodeURIComponent(l.replace(/\\/g,"/"))+o;var d={fileDetails:[i],imageUrl:n=n+"&time="+(new Date).getTime().toString()};return e.trigger("beforeImageLoad",d),d.imageUrl}function L(e,i,n){var a=t.getValue(e.hasId?"id":"name",i)+"/",s=t.getValue(e.hasId?"filterId":"filterPath",i);return t.isNullOrUndefined(s)?n+a:s.replace(/\\/g,"/").replace(/^.*?(?=\/)/,"")+a}function T(e,i){var n=t.getValue("name",i),a=t.getValue("filterPath",i);return""===e.breadcrumbbarModule.searchObj.element.value&&!e.isFiltered||t.isNullOrUndefined(a)||(n=(a=a.replace(/\\/g,"/")).replace(e.path,"")+n),n}function A(e,i){if(0===i.length)return i;var n;n="None"===e.sortOrder||t.isNullOrUndefined(e.sortOrder)?(new a.Query).group("isFile"):(new a.Query).sortBy(e.sortBy,e.sortOrder.toLowerCase(),!0).group("isFile");var s=new a.DataManager(i).executeLocal(n);return t.getValue("records",s)}function F(e,i,n){var a=t.getValue(e.pathId[e.pathId.length-1],e.feFiles).filter(function(e){return e[i].toString()===n});return a.length>0?a[0]:null}function U(e,i,n){var a,s=t.select("#"+e.element.id+Oi,e.element),r=t.select("#"+e.element.id+Ni,s).offsetHeight;if(a=s.offsetHeight-r,"Details"===e.view&&(a-=t.select("."+on,s).offsetHeight),t.isNullOrUndefined(i.querySelector("."+Gi))){var o=t.createElement("div",{className:Gi}),l=t.createElement("div",{className:rn}),h=t.createElement("div",{className:Ji}),d=t.createElement("div",{className:Qi});"Details"===e.view?i.querySelector("."+dn).appendChild(o):i.appendChild(o),o.appendChild(l),o.appendChild(h),o.appendChild(d)}i.querySelector("."+Gi)&&(t.isNullOrUndefined(n.error)?e.isFiltered?(i.querySelector("."+Ji).innerHTML=B(e,"Filter-Empty"),i.querySelector("."+Qi).innerHTML=B(e,"Filter-Key")):""!==e.breadcrumbbarModule.searchObj.element.value?(i.querySelector("."+Ji).innerHTML=B(e,"Search-Empty"),i.querySelector("."+Qi).innerHTML=B(e,"Search-Key")):(i.querySelector("."+Ji).innerHTML=B(e,"Folder-Empty"),i.querySelector("."+Qi).innerHTML=B(e,"File-Upload")):(i.querySelector("."+Ji).innerHTML=B(e,"Access-Denied"),i.querySelector("."+Qi).innerHTML=B(e,"Access-Details")));var p=t.select("."+Gi,i);a=(a-p.offsetHeight)/2,p.style.marginTop=a+"px"}function V(e){return new a.DataManager(e).executeLocal((new a.Query).where(yn,"equal",!1,!1))}function _(e,i){for(var n=V(e.files),a=0,s=n.length;a<s;a++)t.setValue("_fm_id",i+"_"+a,n[a])}function H(e){for(var i=0;i<e.length;i++){var n=new Date(t.getValue("dateCreated",e[i])),a=new Date(t.getValue("dateModified",e[i]));t.setValue("_fm_created",n,e[i]),t.setValue("_fm_modified",a,e[i])}}function B(e,t){var i=e.localeObj.getConstant(t);return""===i?t:i}function z(e,i){var n=e.cssClass;return n=t.isNullOrUndefined(n)||""===n?i:n+" "+i}function q(e,t){e.isSortByClicked=!0,-1!==t.item.id.indexOf("ascending")||-1!==t.item.id.indexOf("descending")||-1!==t.item.id.indexOf("none")?e.sortOrder=W(t.item.id):e.sortBy=W(t.item.id,e),e.itemData=[E(e)],"Details"===e.view&&(e.isMobile?C(e,"Details"):(e.notify(Zn,{module:"detailsview"}),e.isSortByClicked=!1)),"LargeIcons"===e.view&&C(e,"LargeIcons"),e.notify(Hn,{})}function W(e,t){var i,n=e.substring(e.lastIndexOf("_")+1),a=n;switch(t&&(i=t.detailsViewSettings.columns),n){case"date":for(var s=0,r=i.length;s<r;s++){if("dateModified"===i[s].field||"dateCreated"===i[s].field){a=i[s].field;break}a="_fm_modified"}break;case"ascending":a="Ascending";break;case"descending":a="Descending";break;case"none":a="None"}return a}function K(e,i){for(var n=i.split("/"),a=e.originalPath.split("/"),s=t.getValue(e.pathId[0],e.feParent),r=t.isNullOrUndefined(t.getValue("id",s))?"name":"id",o=n.length-1,l=a.length-1;o<l;o++){var h=""===a[o+1]?wn:On,d=""===a[o]?"/":e.path+a[o]+"/",p=F(e,r,a[parseInt(o.toString(),10)]);if(t.isNullOrUndefined(p))e.originalPath=d;else{var c=t.getValue("_fm_id",p);e.setProperties({path:d},!0),e.pathId.push(c),e.itemData=[p],e.pathNames.push(t.getValue("name",p))}Ee(e,h,e.path);break}}function Y(e,i){e.originalPath=L(e,i,e.path);var n=t.getValue(e.pathId[0],e.feParent),a=e.feParent[t.getValue("_fm_id",e.itemData[0])],s=t.isNullOrUndefined(a)||"fe_tree"===t.getValue("_fm_id",a),r=F(e,t.isNullOrUndefined(t.getValue("id",n))?"name":"id",Ae(e)?t.getValue("id",i):t.getValue("name",i));if(t.isNullOrUndefined(r)){if(s)return void K(e,e.path);e.notify(Vn,{selectedNode:e.pathId[e.pathId.length-1]})}else{var o=t.getValue("_fm_id",r);e.setProperties({path:e.originalPath},!0),e.pathId.push(o),e.itemData=[r],e.pathNames.push(t.getValue("name",r))}Ee(e,e.path!==e.originalPath?On:wn,e.path)}function G(e){if(e.isDragDrop=!1,0!==e.selectedNodes.length&&e.enablePaste){var t=""===e.folderPath?e.path:e.folderPath;"navigationpane"!==e.activeModule||e.selectedNodes[0].includes("/")||(e.targetPath=je(e,e.actionRecords[0])),J(e,e.actionRecords,t,e.path)||("move"===e.fileAction&&e.targetPath!==t||"copy"===e.fileAction?(e.notify(Qn,{}),ke(e,e.targetPath,e.selectedNodes,t,e.fileAction,[],e.actionRecords)):(e.enablePaste=!1,e.notify(Gn,{}),O(e),ut(e,"Error",{files:null,error:{code:"402",message:B(e,"Same-Folder-Error"),fileExists:null}})))}}function J(e,i,n,a){for(var s=!1,r=0;r<i.length;r++)if(t.getValue("isFile",i[r])){var o=e.dragData[r]?e.dragData[r].name:null,l=Ae(e)?o:e.dragNodes[r],h=0;l&&(h=l.lastIndexOf("/"));var d="";if(h>0&&(d=a+l.substring(0,h+1)),d===n){var p={files:null,error:{code:"402",message:B(e,"Same-Folder-Error"),fileExists:null}};ut(e,"Error",p),s=!0;break}}else{var c=L(e,i[r],a);if(0===n.indexOf(c)){ut(e,"Error",p={files:null,error:{code:"402",message:B(e,"Sub-Folder-Error"),fileExists:null}}),s=!0;break}}return s}function Q(e){e.isDragDrop=!0,0!==e.dragData.length&&(e.dragPath=e.dragPath.replace(/\\/g,"/"),e.dropPath=e.dropPath.replace(/\\/g,"/"),J(e,e.dragData,e.dropPath,e.dragPath)||e.dragPath===e.dropPath||(e.itemData=[e.dropData],ke(e,e.dragPath,e.dragNodes,e.dropPath,"move",[],e.dragData),e.notify(Qn,{})))}function X(e){for(var t=e.split("/"),i=t[0]+"/",n=1;n<t.length-2;n++)i+=t[n]+"/";return i}function $(e,i){var n=t.getValue(e.hasId?"id":"name",i.cwd)+"/",a=t.getValue(e.hasId&&!t.isNullOrUndefined(e.ajaxSettings.url)?"filterId":"filterPath",i.cwd);return t.isNullOrUndefined(a)?Ae(e)?n:e.path+n:""===a?"/":a.replace(/\\/g,"/").replace(/^.*?(?=\/)/,"")+n}function Z(e,t,i){"move"===t&&(e.isDragDrop?e.notify(na,i):(e.enablePaste=!1,e.notify(Gn,{}),e.notify($n,i))),0===e.duplicateItems.length&&(e.pasteNodes=[]);for(var n=0;n<i.files.length;n++)e.pasteNodes.push(i.files[n][e.hasId?"id":"name"]),e.isDragDrop&&e.droppedObjects.push(i.files[n]);e.duplicateItems=[],e.duplicateRecords=[],e.isDragDrop&&!e.isPasteError?e.isDropEnd=!0:e.isDropEnd=!1,e.trigger("success",{action:t,result:i}),!e.isDragDrop||e.path===e.dragPath||e.path===e.dropPath||e.isSearchDrag?(e.isPathDrag=!1,Ee(e,Xn,e.path)):ee(e)}function ee(e){var i=t.getValue("_fm_id",e.dropData);if(e.expandedId=i,e.itemData=[e.dropData],e.isPathDrag)e.notify(Sn,e.itemData);else{if(e.navigationpaneModule){var n=t.select('[data-uid="'+i+'"]',e.navigationpaneModule.treeObj.element);n||(i=document.querySelector('[data-id = "'+t.getValue("id",e.dropData)+'"]').getAttribute("data-uid"),n=t.select('[data-uid="'+i+'"]',e.navigationpaneModule.treeObj.element)),c(n,e.dropData,e)}Ee(e,aa,e.dropPath)}}function te(e,i){for(var n=null,a=e.isDragDrop?e.dragData:e.actionRecords,s=0;s<a.length;s++)if(t.getValue("name",a[s])===i){n=a[s];break}return n}function ie(e){if(e.isSearchDrag=!1,""!==e.breadcrumbbarModule.searchObj.element.value&&(e.isSearchDrag=!0),"navigationpane"!==e.activeModule){e.dragNodes=[];for(var t=0;t<e.selectedItems.length;)e.dragNodes.push(e.selectedItems[t]),t++;0===e.selectedItems.length&&e.dragData&&1===e.dragData.length&&e.dragNodes.push(pe(e,e.dragData[0]))}var i=e.createElement("div",{className:"e-fe-icon "+M(e.dragData[0])}),n=e.createElement("div",{className:"e-fe-name",innerHTML:e.dragData[0].name}),a=e.createElement("div",{className:"e-fe-content"});a.appendChild(i),a.appendChild(n);var s=e.createElement("div",{className:Xi});if(s.appendChild(a),e.dragNodes.length>1){var r=e.createElement("span",{className:"e-fe-count",innerHTML:e.dragNodes.length.toString(10)});s.appendChild(r)}e.virtualDragElement=s,e.element.appendChild(e.virtualDragElement)}function ne(e,i){var n=i;n.cancel=!1,null!=e.treeExpandTimer&&(window.clearTimeout(e.treeExpandTimer),e.treeExpandTimer=null),re(e),e.element.classList.remove("e-fe-drop","e-no-drop"),O(e),e.uploadObj.dropArea=t.select("#"+e.element.id+ji,e.element);var a=t.select("."+Xi,e.element);a&&t.detach(a),x(e,i.target),e.notify(ia,i),O(e,"hover"),n.fileDetails=e.dragData,e.trigger("fileDragStop",n,function(i){!i.cancel&&!t.isNullOrUndefined(e.targetModule)&&""!==e.targetModule&&e.dragCount>2&&Q(e),e.dragCount=0})}function ae(e,i,n){var a=i;if(a.cancel=!1,a.fileDetails=e.dragData,e.dragCount=0,e.droppedObjects=[],(!e.allowDragAndDrop||"navigationpane"===e.activeModule&&t.closest(i.element,"li").getAttribute("data-uid")===e.pathId[0])&&(a.cancel=!0),"navigationpane"===e.activeModule&&-1!==e.pathId.indexOf(t.closest(i.element,"li").getAttribute("data-uid"))?e.isPathDrag=!0:e.isPathDrag=!1,O(e),a.cancel)n.intDestroy(i.event),se(e);else if(!a.cancel){for(var s=0;s<e.activeElements.length;)I(e.activeElements[s]),s++;e.trigger("fileDragStart",a,function(t){t.cancel?(n.intDestroy(i.event),se(e)):e.uploadObj.dropArea=null})}}function se(e){O(e);var i=t.select("."+Xi,e.element);i&&t.detach(i)}function re(e){oe(e,$i),oe(e,Zi)}function oe(e,t){for(var i=e.element.querySelectorAll("."+t),n=0;n<i.length;n++)i[n].classList.remove(t)}function le(e,i,n,a){var s,r=e.getBoundingClientRect(),o=t.select("."+n,e);a>=r.top+e.clientHeight-30&&!t.isNullOrUndefined(o)&&(s="navigationpane"===i.targetModule||"detailsview"===i.targetModule?o.offsetHeight/2.5:o.offsetHeight/4.5,e.scrollBy(0,s)),!t.isNullOrUndefined(o)&&a<=r.top+30&&(s="navigationpane"===i.targetModule||"detailsview"===i.targetModule?o.offsetHeight/2.5:o.offsetHeight/4.5,e.scrollBy(0,-s))}function he(e,i){var n=i;n.fileDetails=e.dragData;var a=!1;x(e,i.target),re(e),null!=e.treeExpandTimer&&(window.clearTimeout(e.treeExpandTimer),e.treeExpandTimer=null),O(e,"hover");var s=null;"navigationpane"===e.targetModule?((s=t.closest(i.target,"li")).classList.add(Bi,$i),a=!0,e.treeExpandTimer=window.setTimeout(function(){e.notify(sa,i)},800),le(e.navigationpaneModule.treeObj.element.parentElement,e,"e-level-2",i.event.y)):"detailsview"===e.targetModule?((s=t.closest(i.target,"tr"))&&s.querySelector("."+en)&&!s.classList.contains(_i)?s.classList.add($i):!s||s.querySelector("."+en)||s.classList.contains(_i)||s.classList.add(Zi),a=!0,le(e.detailsviewModule.gridObj.element.querySelector(".e-content"),e,"e-row",i.event.y)):"largeiconsview"===e.targetModule?((s=t.closest(i.target,"li"))&&s.querySelector("."+en)&&!s.classList.contains(_i)&&s.classList.add(Bi,$i),a=!0,le(e.largeiconsviewModule.element.firstElementChild,e,"e-large-icon",i.event.y)):"breadcrumbbar"===e.targetModule&&(a=!0),e.element.classList.remove("e-fe-drop","e-no-drop"),e.element.classList.add(a?"e-fe-drop":"e-no-drop"),e.dragCount=e.dragCount+1,e.trigger("fileDragging",n)}function de(e){for(var i="",n=Object.keys(e),a=0;a<n.length;a++)"message"!==n[a]&&(i+=(0===a?"":", ")+n[a]+": "+t.getValue(n[a],e));return i}function pe(e,i){return e.hasId?t.getValue("id",i):T(e,i)}function ce(e,i){e.itemData=[i],e.currentItemText=t.getValue("name",i),e.isFile=t.getValue("isFile",i),e.filterPath=t.getValue("filterPath",i)}function ue(e){Ie(e.itemData[0])?ut(e,"Rename"):be(e,e.itemData[0],la)}function fe(e){for(var t=e.itemData,i=0;i<t.length;i++)if(!De(t[i]))return void be(e,t[i],pa);e.selectedItems.length>0&&pt(e,e.path,e.selectedItems)}function ge(e,t,i){for(var n=0;n<t.length;n++)if(!Ie(t[n]))return void be(e,t[n],la);e.itemData=t,Le(e,i,e.path,"delete")}function me(e,t,i){for(var n=0;n<t.length;n++)if(!De(t[n]))return void be(e,t[n],pa);e.itemData=t,i.length>0&&pt(e,e.path,i)}function be(e,i,n){var a=t.getValue("message",t.getValue("permission",i));""===a&&(a=B(e,"Access-Message").replace("{0}",t.getValue("name",i)).replace("{1}",n)),ut(e,"Error",{error:{code:"401",fileExists:null,message:a}})}function ve(e){return ye(e)?"e-fe-locked":"e-fe-locked e-fe-hidden"}function ye(e){var i=t.getValue("permission",e);return!(i&&!t.getValue("read",i))}function Ie(e){var i=t.getValue("permission",e);return!i||t.getValue("read",i)&&t.getValue("write",i)}function Oe(e){var i=t.getValue("permission",e);return!i||t.getValue("read",i)&&t.getValue("writeContents",i)}function we(e){var i=t.getValue("permission",e);return!i||t.getValue("read",i)&&t.getValue("upload",i)}function De(e){var i=t.getValue("permission",e);return!i||t.getValue("read",i)&&t.getValue("download",i)}function Se(e){var t=e.itemData[0];Oe(t)?ut(e,"NewFolder"):be(e,t,ha)}function Ce(e){var t=e.itemData[0];if(we(t)){var i="#"+e.element.id+Ei;document.querySelector(i).click()}else be(e,t,da)}function xe(e){t.isNullOrUndefined(e.dialogObj)||e.dialogObj.hide()}function je(e,i){return e.hasId&&!t.isNullOrUndefined(t.getValue("filterId",i))?t.getValue("filterId",i).replace(/\\/g,"/").replace(/^[^/]+\//,"/"):t.getValue("filterPath",i).replace(/\\/g,"/")}function Ne(e,i,n,a){for(var s="",r=0;r<i.length;r++){var o=t.getValue("permission",i[r]);if(null==o&&(o=void 0),a)!o||t.getValue("read",o)&&t.getValue("writeContents",o)||""===(s=t.getValue("message",t.getValue("permission",i[r])))&&(s=B(e,"Access-Message").replace("{0}",t.getValue("name",i[r])).replace("{1}","writeContents"));else{var l="copy"===n?t.getValue("copy",o):t.getValue("write",o);!o||t.getValue("read",o)&&l||""===(s=t.getValue("message",t.getValue("permission",i[r])))&&(s=B(e,"Access-Message").replace("{0}",t.getValue("name",i[r])).replace("{1}",n))}if(""!==s){e.responseData={cwd:null,details:null,error:{code:"401",message:s,fileExists:null},files:null};break}}return s}function Ee(e,i,n){for(var a=e.itemData,s=0;s<a.length;s++)t.isNullOrUndefined(t.getValue("hasChild",a[s]))&&t.setValue("hasChild",!1,a[s]);Qe(e,{action:"read",path:n,showHiddenItems:e.showHiddenItems,data:a},tt,i)}function Pe(e,t){Qe(e,{action:"create",path:e.path,name:t,data:e.itemData},nt,t)}function Re(e,i){var n={action:"filter",path:e.path,showHiddenItems:e.showHiddenItems,data:[E(e)]},a=e.filterData?t.extend(void 0,n,e.filterData):n;Qe(e,a,it,i,t.getValue("action",a))}function Me(e,t,i){var n,a;if(""!==e.breadcrumbbarModule.searchObj.element.value||e.isFiltered){var s=e.filterPath;e.hasId?(n=e.currentItemText,a=i):(n=(s=s.replace(/\\/g,"/")).replace(t,"")+e.currentItemText,a=s.replace(t,"")+i)}else n=e.currentItemText,a=i;Qe(e,{action:"rename",path:t,name:n,newName:a,data:e.itemData,showFileExtension:e.showFileExtension},at,t)}function ke(e,t,i,n,a,s,r){var o={action:a,path:t,targetData:e.itemData[0],targetPath:n,names:i,renameFiles:s,data:r};e.destinationPath=n,Qe(e,o,st,t,a,n)}function Le(e,t,i,n){Qe(e,{action:n,path:i,names:t,data:e.itemData},rt,i)}function Te(e,t,i,n){Qe(e,{action:n,path:i,names:t,data:e.itemData},ot,i,n)}function Ae(e){return e.fileSystemData.length>=0&&t.isNullOrUndefined(e.ajaxSettings.url)}function Fe(e,t){return e.some(function(e){return e.name===t})}function Ue(e,i){return e.fileSystemData.findIndex(function(e){return!t.isNullOrUndefined(e)&&String(e.id)===String(i)})}function Ve(e,t){return e.fileSystemData.filter(function(e){return String(e.id)===String(t)})[0]}function _e(e,t){return e.fileSystemData.filter(function(e){return String(e.parentId)===String(t)})}function He(e,i,n,a){var r={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(r[o]=null);var l=new Date,h=String(i.id)===String(0)||t.isNullOrUndefined(i.parentId)?"\\":i.filterPath+i.name+"\\";return Object.assign(r,{dateCreated:l,dateModified:l,filterPath:h,hasChild:!!a&&e.hasChild,id:s.getUid(null===n?e.name:n),isFile:!!a&&e.isFile,name:null===n?e.name:n,parentId:i.id,size:a?e.size:0,type:a?e.type:""}),r}function Be(e,t,i,n){e.responseData={cwd:null,details:null,error:{code:i,message:t,fileExists:null!=n?n:null},files:null}}function ze(e,i,n){var a={folderName:t.getValue("name",i),cancel:!1,path:t.getValue("path",i),parentFolder:t.getValue("data",i)};e.trigger("beforeFolderCreate",a,function(t){if(t.cancel)return void(n.cancel=!0);if(Ae(e))if(Fe(e.fileSystemData,t.folderName)){var i="A file or folder with the name "+t.folderName+" already exists.";Be(e,i,"400",null)}else{var a=t.parentFolder[0],s=He(a,a,t.folderName,!1);e.fileSystemData.push(s)}})}function qe(e,i,n){var a={cancel:!1,itemData:t.getValue("data",i),path:t.getValue("path",i)};e.trigger("beforeDelete",a,function(t){if(t.cancel)return void(n.cancel=!0);Ae(e)&&t.itemData.forEach(function(t){var i=Ue(e,t.id);-1!==i&&e.fileSystemData.splice(i,1),t.isFile||e.fileSystemData.filter(function(e){return e.filterPath.includes(t.name)}).forEach(function(t){var i=Ue(e,t.id);-1!==i&&e.fileSystemData.splice(i,1)})})})}function We(e,i,n){var a={cancel:!1,newName:t.getValue("newName",i),itemData:t.getValue("data",i),path:t.getValue("path",i)};e.trigger("beforeRename",a,function(t){if(t.cancel)return void(n.cancel=!0);if(Ae(e))if(Fe(e.fileSystemData,t.newName)){var i="Cannot rename"+t.itemData[0].name+"to"+t.newName+": destination already exists.";Be(e,i,"400",null)}else{var a=Ve(e,t.itemData[0].id),s=a.name;a.name=t.newName,Ke(e,a.id,s,t.newName)}})}function Ke(e,t,i,n){e.fileSystemData.forEach(function(a){if(String(a.parentId)===String(t)){var s=a.filterPath.replace(i+"\\",n+"\\");a.filterPath=s,Ke(e,a.id,i,n)}})}function Ye(e,i,n){var a={cancel:!1,itemData:t.getValue("data",i),isCopy:"copy"===t.getValue("action",i),path:t.getValue("path",i),targetData:t.getValue("targetData",i),targetPath:t.getValue("targetPath",i)};e.trigger("beforeMove",a,function(a){if(a.cancel)return void(n.cancel=!0);if(Ae(e)){var s=t.getValue("action",i),r=Ne(e,a.itemData,s,!1),o=Ne(e,[a.targetData],s,!0),l=[];if(e.pasteNodes=[],""===r&&""===o){if(a.isCopy){var h=_e(e,a.targetData.id);return a.itemData.forEach(function(n){if(!Fe(h,n.name)||t.getValue("renameFiles",i).length>0){if(t.getValue("renameFiles",i).length>0){var s=n.name.split("."),r=n.name.includes(".")?s[0]+"("+e.existingFileCount+")."+s[1]:s[0]+"("+e.existingFileCount+")";return Ze(e,n,a.targetData,r),e.responseData.error=null,void e.existingFileCount++}Ze(e,n,a.targetData,null)}else l.push(n.name)}),void(l.length>0&&Be(e,"File Already Exists","400",l))}for(var d=a.targetData,p=_e(e,d.id),c=0;c<a.itemData.length;c++){var u=a.itemData[c];if(!Fe(p,u.name)||t.getValue("renameFiles",i).length>0){if(!d.hasChild){d.hasChild=!u.isFile;var f=e.fileSystemData.filter(function(e){return String(e.id)===String(d.id)});f.length>0&&(f[0].hasChild=d.hasChild)}if(!u.isFile){var g=0!==u.parentId?_e(e,u.parentId):[];Ve(e,u.parentId).hasChild=g.length>1}var m=Ve(e,u.id);if(t.getValue("renameFiles",i).length>0){var b=u.name.split(".");u.name=u.name.includes(".")?b[0]+"("+e.existingFileCount+")."+b[1]:b[0]+"("+e.existingFileCount+")",m.name=u.name,e.responseData.error=null,e.existingFileCount++,e.dropData=d,e.dropPath=a.path;var v=a.targetPath.replace(/^\/|\/$/g,"").split("/");d=Ve(e,v[v.length-1])}m.parentId=d.id,m.filterPath=0===d.id?"\\":d.filterPath+d.name+"\\"}else l.push(u.name)}l.length>0&&Be(e,"File Already Exists","400",l)}}})}function Ge(e,i,n){var a={searchResults:t.getValue("data",i),cancel:!1,path:t.getValue("path",i),searchText:t.getValue("searchString",i),caseSensitive:t.getValue("caseSensitive",i),showHiddenItems:t.getValue("showHiddenItems",i)};e.trigger("search",a,function(e){t.setValue("data",e.searchResults,i),e.cancel&&(n.cancel=!0)})}function Je(e,i,n){switch(t.getValue("action",i)){case"create":ze(e,i,n);break;case"delete":qe(e,i,n);break;case"rename":We(e,i,n);break;case"move":case"copy":Ye(e,i,n);break;case"search":Ge(e,i,n)}}function Qe(e,i,n,a,s,r){var o={url:e.ajaxSettings.url,type:"POST",mode:!0,dataType:"json",contentType:"application/json",data:JSON.stringify(i),onSuccess:null,onFailure:null,beforeSend:null},l={action:t.getValue("action",i),ajaxSettings:o,cancel:!1};Je(e,i,l),e.trigger("beforeSend",l,function(o){if(!o.cancel){if(e.notify(Rn,{}),Ae(e)){var l=("node-expand"===a||"finalize-end"===a||"rename-end-parent"===a?t.getValue("path",i):e.path).replace(/^\/|\/$/g,"").split("/"),h="rename-end-parent"===a||"path-changed"===a&&0!==t.getValue("data",i).length&&t.isNullOrUndefined(e.renamedItem)?t.getValue("data",i)[0].id:l[l.length-1],d=t.getValue("action",i),p=("move"===d||"rename"===d||"copy"===d||"delete"===d||"search"===d)&&"rename-end"!==a;if("read"===d||"create"===d||"rename-end"===a){var c=e.fileSystemData.filter(function(e){return t.isNullOrUndefined(e.parentId)}).length>0?e.fileSystemData.filter(function(e){return t.isNullOrUndefined(e.parentId)})[0].id:0;if(e.responseData={cwd:Ve(e,"/"===e.path&&"node-expand"!==a&&"rename-end-parent"!==a?c:h),details:null,error:null,files:_e(e,"/"===e.path&&"node-expand"!==a&&"rename-end-parent"!==a?c:h)},t.isNullOrUndefined(e.responseData.cwd)){Be(e,"Cannot load empty data within the File Manager.","400",null)}}else if(p&&null===e.responseData.error)0===(u="search"===d||"delete"===d?t.getValue("data",i):[]).length&&(u="copy"===d?e.pasteNodes.map(function(t){return Ve(e,t)}):t.getValue("data",i).map(function(t){return Ve(e,t.id)})),e.responseData={cwd:null,details:null,error:null,files:u};else if("details"===t.getValue("action",i)){var u=t.getValue("data",i),f=u[0],g=u.length>1,m=u.map(function(e){return e.name}),b=Xe(g?u.reduce(function(e,t){return e+(t.size||0)},0):f.size),v=e.pathNames.includes(f.name)||g?e.pathNames.join("/"):e.pathNames.join("/")+"/"+f.name;e.responseData.details=Object.assign({location:v,multipleFiles:g,name:m.join(", "),size:b},g?{}:{created:f.dateCreated,isFile:f.isFile,modified:f.dateModified,permission:f.permission})}return void $e(e,e.responseData,n,i,a,s,r,o)}new t.Ajax({url:t.getValue("url",o.ajaxSettings),type:t.getValue("type",o.ajaxSettings),mode:t.getValue("mode",o.ajaxSettings),dataType:t.getValue("dataType",o.ajaxSettings),contentType:t.getValue("contentType",o.ajaxSettings),data:t.getValue("data",o.ajaxSettings),beforeSend:t.getValue("beforeSend",o.ajaxSettings),onSuccess:function(l){if(t.isNullOrUndefined(l)){var h={error:{fileExists:null,message:B(e,"Server-Error")+" "+e.ajaxSettings.url,code:"406"},files:null};return void et(e,o,n,h,a,s,r)}"string"==typeof l&&(l=JSON.parse(l)),$e(e,l,n,i,a,s,r,o)},onFailure:function(){var t={files:null,error:{code:"404",message:B(e,"Network-Error")+" "+e.ajaxSettings.url,fileExists:null}};et(e,o,n,t,a,s,r)}}).send()}})}function Xe(e){return e<1024?e+" B":e<1048576?(e/1024).toFixed(2)+" KB":e<1073741824?(e/1024/1024).toFixed(2)+" MB":(e/1024/1024/1024).toFixed(2)+" GB"}function $e(e,i,n,a,s,r,o,l){e.notify(kn,{action:"success"});var h=e.expandedId?e.expandedId:e.pathId[e.pathId.length-1];if(!t.isNullOrUndefined(i.cwd)&&"read"===t.getValue("action",a)&&(i.cwd.name=1===e.pathId.length?e.rootAliasName||i.cwd.name:i.cwd.name,t.setValue("_fm_id",h,i.cwd),t.setValue(h,i.cwd,e.feParent),!t.isNullOrUndefined(i.files)||"401"===i.error.code)){if(("finalize-end"===s||"initial-end"===s)&&0===e.pathNames.length){var d=t.getValue(e.pathId[0],e.feParent);e.pathNames[0]=t.getValue("name",d),e.hasId=!t.isNullOrUndefined(t.getValue("id",d))}"finalize-end"===s&&b(e)}if(!t.isNullOrUndefined(i.files)){H(i.files);for(var p=0,c=i.files.length;p<c;p++){var u=i.files[p];t.setValue("_fm_iconClass",M(u),u)}"read"===t.getValue("action",a)&&(_(i,h),t.setValue(h,i.files,e.feFiles))}if(!t.isNullOrUndefined(i.details)&&!t.isNullOrUndefined(e.rootAliasName)){var f=e.rootAliasName||t.getValue("name",i.details),g=t.getValue("location",i.details).replace(new RegExp("/","g"),"\\");"/"===t.getValue("path",a)||e.hasId&&1===t.getValue("path",a).match(/[/]/g).length?(0===t.getValue("names",a).length&&t.setValue("name",f,i.details),g=-1===g.indexOf("\\")?f:g.replace(g.substring(0,g.indexOf("\\")),f)):g=g.replace(g.substring(0,g.indexOf("\\")),f),t.setValue("location",g,i.details)}n(e,i,s,r,o),t.isNullOrUndefined(i.files)||"path-changed"!==s&&"finalize-end"!==s&&"open-end"!==s&&"drop-path"!==s||e.notify(ta,i),"function"==typeof t.getValue("onSuccess",l.ajaxSettings)&&t.getValue("onSuccess",l.ajaxSettings)()}function Ze(e,t,i,n){var a=He(t,i,n,!0);e.fileSystemData.push(a),e.pasteNodes.push(a.id);for(var s=_e(e,t.id),r=0;r<s.length;r++)Ze(e,s[r],a,null)}function et(e,i,n,a,s,r,o){e.notify(kn,{action:"failure"}),n(e,a,s,r,o),"function"==typeof t.getValue("onFailure",i.ajaxSettings)&&t.getValue("onFailure",i.ajaxSettings)()}function tt(e,i,n){try{if(t.isNullOrUndefined(i.files))t.isNullOrUndefined(i.error)||"401"!==i.error.code||(i.files=[],e.notify(n,i),e.notify(Un,{})),lt(e,i,"read"),e.setProperties({path:e.oldPath},!0),e.pathNames.pop();else{e.notify(n,i),e.notify(Un,{});a={action:"read",result:i};e.trigger("success",a)}}catch(t){ct(e,t,"read"),e.setProperties({path:e.oldPath},!0),e.pathNames.pop()}if(e.isDragDrop&&e.isDropEnd){if(0!==e.droppedObjects.length){var a={fileDetails:e.droppedObjects};e.trigger("fileDropped",a)}e.isDropEnd=e.isDragDrop=!1}}function it(e,i,n,a){try{if(t.isNullOrUndefined(i.files))lt(e,i,a);else{e.notify(n,i);var s={action:a,result:i};e.trigger("success",s)}}catch(t){ct(e,t,a)}}function nt(e,i,n){try{if(t.isNullOrUndefined(i.files))if("400"===i.error.code){if(e.dialogObj&&e.dialogObj.visible){var a=t.select("#newname",e.dialogObj.element),s=B(e,"Validation-NewFolder-Exists").replace("{0}",'"'+a.value+'"');a.parentElement.nextElementSibling.innerHTML=s}else ut(e,"Error",{files:null,error:{code:"400",message:B(e,"Validation-NewFolder-Exists").replace("{0}",'"'+n+'"'),fileExists:null}});o={action:"create",error:i.error};e.trigger("failure",o)}else e.dialogObj&&e.dialogObj.visible&&e.dialogObj.hide(),lt(e,i,"create");else{e.dialogObj&&e.dialogObj.visible&&e.dialogObj.hide(),e.createdItem=Ae(e)?i.files[i.files.length-1]:i.files[0],e.breadcrumbbarModule.searchObj.value="";var r={folderName:n,path:e.path,parentFolder:e.itemData};e.trigger("folderCreate",r);var o={action:"create",result:i};e.trigger("success",o),e.itemData=[E(e)],Ee(e,Dn,e.path)}}catch(s){e.dialogObj&&e.dialogObj.visible&&e.dialogObj.hide(),ct(e,s,"create")}}function at(e,i){try{if(t.isNullOrUndefined(i.files))if("400"===i.error.code&&e.dialogObj&&e.dialogObj.visible){var n=t.select("#rename",e.dialogObj.element),a=B(e,"Validation-Rename-Exists").replace("{0}",'"'+e.currentItemText+'"');a=a.replace("{1}",'"'+n.value+'"'),n.parentElement.nextElementSibling.innerHTML=a;s={action:"rename",error:i.error};e.trigger("failure",s)}else t.isNullOrUndefined(e.dialogObj)||e.dialogObj.hide(),lt(e,i,"rename");else{t.isNullOrUndefined(e.dialogObj)||e.dialogObj.hide();var s={action:"rename",result:i};e.trigger("success",s),e.renamedItem=Array.isArray(i.files)?i.files[0]:i.files;var r={newName:e.renamedItem.name,itemData:[e.renamedItem],path:e.path};if(e.trigger("rename",r),"navigationpane"===e.activeModule){var o=E(e),l=e.pathId[e.pathId.length-1].split("_").length-2;e.pathId.pop(),e.itemData=[t.getValue(e.pathId[e.pathId.length-1],e.feParent)];var h=je(e,e.renamedItem);Ee(e,Wn,h),!t.isNullOrUndefined(o)&&e.pathNames.length>1&&l<=e.pathNames.length-1&&(e.pathNames[l]=e.renameText,e.hasId||e.setProperties({path:"/"+e.pathNames.slice(1).join("/")+"/"},!0)),e.itemData=e.navigationpaneModule.previousSelected.length>0?e.navigationpaneModule.treeObj.getTreeData(e.navigationpaneModule.previousSelected[0]):e.itemData,Ee(e,En,e.path),e.itemData[0]=e.renamedItem,e.renamedItem=null}else e.itemData=[E(e)],""!==e.breadcrumbbarModule.searchObj.value?ht(e,Kn,e.path,e.searchWord,e.showHiddenItems,!e.searchSettings.ignoreCase):e.isFiltered?Re(e,Kn):Ee(e,Kn,e.path)}}catch(a){t.isNullOrUndefined(e.dialogObj)||e.dialogObj.hide(),ct(e,a,"rename")}}function st(e,i,n,a){try{var s={itemData:i.files,isCopy:"copy"===a,path:n,targetData:e.itemData[0],targetPath:e.path};e.trigger("move",s),i.error&&i.error.fileExists?(e.fileLength=0,t.isNullOrUndefined(i.files)||(e.isPasteError=!0,Z(e,a,i)),ft(e,"DuplicateItems",i.error.fileExists),"404"===i.error.code&&ut(e,"Error",i)):i.error||t.isNullOrUndefined(i.files)?i.error&&!t.isNullOrUndefined(i.files)?(e.isPasteError=!0,Z(e,a,i),ut(e,"Error",i)):lt(e,i,a):(e.isPasteError=!1,Z(e,a,i))}catch(t){ct(e,t,a)}}function rt(e,i,n){try{var a={itemData:i.files,path:n};if(e.trigger("delete",a),t.isNullOrUndefined(i.files))lt(e,i,"delete");else if(e.setProperties({path:n},!0),e.itemData=[E(e)],Ee(e,xn,e.path),i.error)lt(e,i,"delete");else{var s={action:"delete",result:i};e.trigger("success",s)}}catch(t){ct(e,t,"delete")}}function ot(e,i,n,a){try{if(t.isNullOrUndefined(i.details))lt(e,i,"details");else{ut(e,a,null,i.details);var s={action:"details",result:i};e.trigger("success",s)}}catch(t){ct(e,t,"details")}}function lt(e,t,i){ut(e,"Error",t);var n={action:i,error:t.error};e.trigger("failure",n)}function ht(e,t,i,n,a,s){Qe(e,{action:"search",path:i,searchString:n,showHiddenItems:a,caseSensitive:s,data:e.itemData},dt,t)}function dt(e,i,n){try{if(t.isNullOrUndefined(i.files))lt(e,i,"search");else{e.notify(n,i);var a={action:"search",result:i};e.trigger("success",a)}}catch(t){ct(e,t,"search")}}function pt(e,i,n){var a=e.ajaxSettings.downloadUrl?e.ajaxSettings.downloadUrl:e.ajaxSettings.url,s={action:"download",path:i,names:n,data:e.itemData},r={data:s,cancel:!1,useFormPost:!0,ajaxSettings:{url:a,type:"POST",contentType:"application/json",responseType:"blob",data:JSON.stringify(s),onSuccess:null,onFailure:null,beforeSend:null}};e.trigger("beforeDownload",r,function(i){if(!i.cancel)if(i.useFormPost){var n=t.createElement("form",{id:e.element.id+"_downloadForm",attrs:{action:a,method:"post",name:"downloadForm",download:""}}),s=t.createElement("input",{id:e.element.id+"_hiddenForm",attrs:{name:"downloadInput",value:JSON.stringify(i.data),type:"hidden"}});n.appendChild(s),e.element.appendChild(n),document.forms.namedItem("downloadForm").submit(),e.element.removeChild(n)}else try{var r,o;new t.Fetch({url:t.getValue("url",i.ajaxSettings),type:t.getValue("type",i.ajaxSettings),contentType:t.getValue("contentType",i.ajaxSettings),responseType:t.getValue("responseType",i.ajaxSettings),beforeSend:t.getValue("beforeSend",i.ajaxSettings),onLoad:function(i){if(r=i.headers.get("Content-Disposition")){var n=r.match(/filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/),a=n&&n[1];o=a?a.replace(/['"]/g,""):o}else o=e.itemData.length>1?"files.zip":t.getValue("isFile",e.itemData[0])?t.getValue("name",e.itemData[0]):t.getValue("name",e.itemData[0])+".zip"},onSuccess:function(t){e.trigger("success",i);var n=t,a=URL.createObjectURL(n),s=document.createElement("a");s.href=a,s.download=o,document.body.appendChild(s),s.click(),document.body.removeChild(s)},onFailure:function(t){var n={error:{code:t.status.toString(),message:B(e,"Network-Error")+" "+e.ajaxSettings.downloadUrl}};ut(e,"Error",n),e.trigger("failure",i)}}).send(JSON.stringify(i.data))}catch(t){ct(e,t,"download")}})}function ct(e,t,i){lt(e,{files:null,error:{message:t.message,fileExists:null}},i)}function ut(e,i,a,s){var r=Pt(e,i,a,s);t.isNullOrUndefined(e.dialogObj)?(e.dialogObj=new n.Dialog({beforeOpen:Rt.bind(this,e,r.dialogName),beforeClose:function(t){mt(e,e.dialogObj,t,r.dialogName)},header:r.header,content:r.content,buttons:r.buttons,animationSettings:{effect:"None"},showCloseIcon:!0,closeOnEscape:!0,visible:!0,allowDragging:!0,isModal:!0,target:e.popupTarget?e.popupTarget:"#"+e.element.id,cssClass:z(e,e.isMobile?ki:Mi),width:"350px",open:r.open,close:r.close,enableRtl:e.enableRtl,enableHtmlSanitizer:e.enableHtmlSanitizer,locale:e.locale}),e.dialogObj.isStringTemplate=!0,e.dialogObj.appendTo("#"+e.element.id+Si)):Lt(e,r)}function ft(e,i,a,s){var r=yt(e,i,a,s);e.isApplySame=!1,t.isNullOrUndefined(e.extDialogObj)?(e.extDialogObj=new n.Dialog({beforeOpen:Mt.bind(this,e,r.dialogName),beforeClose:function(t){mt(e,e.extDialogObj,t,r.dialogName)},content:r.content,header:r.header,closeOnEscape:!0,allowDragging:!0,animationSettings:{effect:"None"},target:e.popupTarget?e.popupTarget:"#"+e.element.id,cssClass:z(e,e.isMobile?ki:Mi),enableRtl:e.enableRtl,showCloseIcon:!0,isModal:!0,width:350,buttons:r.buttons,open:r.open,close:r.close,enableHtmlSanitizer:e.enableHtmlSanitizer,locale:e.locale}),e.extDialogObj.isStringTemplate=!0,e.extDialogObj.appendTo("#"+e.element.id+xi)):(e.extDialogObj.header=r.header,e.extDialogObj.close=r.close,e.extDialogObj.open=r.open,e.extDialogObj.close=r.close,e.extDialogObj.content=r.content,e.extDialogObj.buttons=r.buttons,e.extDialogObj.enableRtl=e.enableRtl,e.extDialogObj.locale=e.locale,e.extDialogObj.beforeOpen=Mt.bind(this,e,r.dialogName),e.extDialogObj.beforeClose=function(t){mt(e,e.extDialogObj,t,r.dialogName)},e.extDialogObj.dataBind(),e.extDialogObj.show())}function gt(e,t,i,n){var a={cancel:i.cancel,popupName:n,popupModule:t};e.trigger("beforePopupOpen",a,function(e){i.cancel=e.cancel})}function mt(e,t,i,n){var a={cancel:i.cancel,popupModule:t,popupName:n};e.trigger("beforePopupClose",a,function(t){i.cancel=t.cancel,i.cancel||!i.isInteracted||"Rename"!==n&&"Create Folder"!==n||e.trigger(Ln,{})})}function bt(e,t,i){var n={popupModule:t,element:t.element,popupName:i};e.trigger("popupOpen",n)}function vt(e,t,i){var n={popupModule:t,element:t.element,popupName:i};e.trigger("popupClose",n)}function yt(e,t,i,n){var a,s,r,o={header:"",content:"",buttons:[],dialogName:""};switch(o.open=function(){bt(e,e.extDialogObj,o.dialogName)},o.close=function(){vt(e,e.extDialogObj,o.dialogName)},t){case"Extension":o.header=B(e,"Header-Rename-Confirmation"),o.content="<div>"+B(e,"Content-Rename-Confirmation")+"</div>",o.buttons=[{buttonModel:{isPrimary:!0,content:B(e,"Button-Yes")},click:function(){e.extDialogObj.hide(),Me(e,n,e.renameText)}},{buttonModel:{content:B(e,"Button-No")},click:function(){e.extDialogObj.hide(),e.dialogObj.hide()}}],o.dialogName="Extension Change";break;case"DuplicateItems":o.dialogName="Duplicate Items",e.replaceItems=i,s=-1===(r=(s=e.replaceItems[e.fileLength]).lastIndexOf("/"))?s:s.substring(r),o.header=B(e,"Header-Duplicate"),a="<div>"+B(e,"Content-Duplicate")+"</div>",o.content=a.replace("{0}",s),o.close=function(){if(!e.isDropEnd&&0===e.duplicateItems.length){var t={fileDetails:e.droppedObjects};e.trigger("fileDropped",t),e.isDropEnd=e.isDragDrop=!1}vt(e,e.extDialogObj,o.dialogName)},o.buttons=[{buttonModel:{isPrimary:!0,content:B(e,"Button-Yes")},click:function(){if(e.duplicateItems.push(e.replaceItems[e.fileLength]),e.duplicateRecords.push(te(e,e.replaceItems[e.fileLength])),e.fileLength++,i[e.fileLength]){var t=e.replaceItems[e.fileLength],n=t.lastIndexOf("/");t=-1===n?t:t.substring(n),e.extDialogObj.content=a.replace("{0}",t),e.extDialogObj.show()}else{e.extDialogObj.hide();var s=e.isDragDrop?e.dragPath:e.targetPath,r=e.isDragDrop?e.dropPath:""===e.folderPath?e.path:e.folderPath,o=e.isDragDrop?"move":e.fileAction;ke(e,s,e.duplicateItems,r,o,e.duplicateItems,e.duplicateRecords)}}},{buttonModel:{content:B(e,"Button-No")},click:function(){if(e.fileLength++,i[e.fileLength]){var t=e.replaceItems[e.fileLength],n=t.lastIndexOf("/");t=-1===n?t:t.substring(n),e.extDialogObj.content=a.replace("{0}",t),e.extDialogObj.show()}else if(e.extDialogObj.hide(),0!==e.duplicateItems.length){var s=e.isDragDrop?"move":e.fileAction,r=e.isDragDrop?e.dragPath:e.targetPath,o=e.isDragDrop?e.dropPath:""===e.folderPath?e.path:e.folderPath;ke(e,r,e.duplicateItems,o,s,e.duplicateItems,e.duplicateRecords)}}}];break;case"UploadRetry":o.dialogName="Retry Upload",o.header=B(e,"Header-Retry"),o.content=e.retryFiles[0].name+'<div class="e-fe-retrycontent">'+B(e,"Content-Retry")+"</div>",o.open=wt.bind(this,e),o.close=function(){e.isRetryOpened=!1,Ot(e),vt(e,e.extDialogObj,o.dialogName)},o.buttons=[{buttonModel:{isPrimary:!0,content:B(e,"Button-Keep-Both")},click:function(){It(e,!0)}},{buttonModel:{isPrimary:!0,content:B(e,"Button-Replace")},click:function(){It(e,!1)}},{buttonModel:{isPrimary:!0,content:B(e,"Button-Skip")},click:function(){var t=0;e.isApplySame?(t=e.retryFiles.length,e.retryFiles=[],Ot(e)):(t=1,e.retryFiles.splice(0,1),0!==e.retryFiles.length?ft(e,"UploadRetry"):Ot(e)),e.notify(Mn,{count:t})}}]}return o}function It(e,t){e.isApplySame?(t?Dt(e):St(e),Ot(e)):(e.retryArgs.push({action:t?"keepboth":"replace",file:e.retryFiles[0]}),e.uploadObj.retry(e.retryFiles[0]),e.retryFiles.splice(0,1),0!==e.retryFiles.length?ft(e,"UploadRetry"):Ot(e))}function Ot(e){var i=!0;e.isRetryOpened?e.isRetryOpened=!1:i=!1;var n=t.select(".e-dlg-checkbox",e.extDialogObj.element);n&&t.remove(n),i?e.extDialogObj.hide():e.retryFiles=[]}function wt(e,i){e.isRetryOpened=!0;var n=t.getValue("element",i),a=t.select(".e-dlg-content",n),s=e.createElement("div",{className:"e-dlg-checkbox"}),r=e.createElement("input",{id:e.element.id+"_applyall"});s.appendChild(r),a.appendChild(s),new o.CheckBox({label:B(e,"ApplyAll-Label"),change:function(t){e.isApplySame=t.checked}}).appendTo("#"+e.element.id+"_applyall"),bt(e,e.extDialogObj,"Retry Upload")}function Dt(e){for(;0!==e.retryFiles.length;)e.retryArgs.push({action:"keepboth",file:e.retryFiles[0]}),e.uploadObj.retry(e.retryFiles[0]),e.retryFiles.splice(0,1)}function St(e){for(;0!==e.retryFiles.length;)e.retryArgs.push({action:"replace",file:e.retryFiles[0]}),e.uploadObj.retry(e.retryFiles[0]),e.retryFiles.splice(0,1)}function Ct(e){var i=t.select("#newname",e.dialogObj.element);i.focus(),i.value="";var n=i.value.length;i.setSelectionRange(0,n)}function xt(e){var i=t.select("#newname",e.dialogObj.element);i.parentElement.classList.contains("e-control-wrapper")||Et(i,B(e,"Content-NewFolder")),i.parentElement.nextElementSibling.innerHTML="",i.oninput=function(){Ut(e,i)},i.onkeyup=function(t){13===Ht(t)&&Tt(e)},Ct(e),bt(e,e.dialogObj,"Create Folder")}function jt(e){var i=t.select("#rename",e.dialogObj.element);i.parentElement.classList.contains("e-control-wrapper")||Et(i,B(e,"Content-Rename")),i.parentElement.nextElementSibling.innerHTML="",i.oninput=function(){Ut(e,i)},i.onkeyup=function(t){13===Ht(t)&&At(e)},Nt(e,i),bt(e,e.dialogObj,"Rename")}function Nt(e,t){t.focus();var i="";if(e.isFile&&!e.showFileExtension){var n=e.currentItemText.lastIndexOf(".");i=-1===n?e.currentItemText:e.currentItemText.substring(0,n)}else i=e.currentItemText;t.value=i,e.isFile&&e.showFileExtension&&-1!==t.value.indexOf(".")?t.setSelectionRange(0,t.value.lastIndexOf(".")):t.setSelectionRange(0,t.value.length)}function Et(e,t){r.Input.createInput({element:e,properties:{placeholder:t}})}function Pt(e,i,n,a){var s,r,o,l,h,d={header:"",content:"",buttons:[],dialogName:""};d.open=function(){bt(e,e.dialogObj,d.dialogName)},d.close=function(){vt(e,e.dialogObj,d.dialogName)};var p;switch(i=a&&!0===a.multipleFiles?"MultipleFileDetails":i){case"NewFolder":d.dialogName="Create Folder",d.header=B(e,"Header-NewFolder"),d.content='<input type="text" value="New folder" id="newname"><div class="e-fe-error"></div>',d.buttons=[{buttonModel:{isPrimary:!0,content:B(e,"Button-Create")},click:function(t){"keydown"!==t.type&&Tt(e)}}],d.open=xt.bind(this,e);break;case"Delete":d.dialogName="Delete",e.selectedItems.length>1?(d.content=("<div>"+B(e,"Content-Multiple-Delete")+"</div>").replace("{0}",e.selectedItems.length.toString()),d.header=B(e,"Header-Multiple-Delete")):(d.content="<div>"+B(e,e.isFile?"Content-Delete":"Content-Folder-Delete")+"</div>",d.header=B(e,e.isFile?"Header-Delete":"Header-Folder-Delete")),d.buttons=[{buttonModel:{isPrimary:!0,content:B(e,"Button-Yes")},click:function(){Ft(e)}},{buttonModel:{content:B(e,"Button-No")},click:function(){e.dialogObj.hide()}}];break;case"Rename":d.dialogName="Rename",d.header=B(e,"Header-Rename"),d.content='<input type="text" class="e-input" id="rename"><div class="e-fe-error"></div>',d.buttons=[{buttonModel:{isPrimary:!0,content:B(e,"Button-Save")},click:function(t){"keydown"!==t.type&&At(e)}}],d.open=jt.bind(this,e);break;case"details":d.dialogName="File Details",r=new t.Internationalization(e.locale).formatDate(new Date(a.modified),{format:"MMMM dd, yyyy HH:mm:ss"}),s="",t.isNullOrUndefined(a.permission)||(s="<tr><td>"+B(e,"Permission")+'</td><td class="'+vn+'" >'+de(a.permission)+"</td></tr>"),d.header=a.name,d.content="<table><tr><td>"+B(e,"Type")+'</td><td class="'+vn+'" title="'+(a.isFile?"File":"Folder")+'">'+(a.isFile?"File":"Folder")+"</td></tr><tr><td>"+B(e,"Size")+'</td><td><span class="'+vn+'" title ="'+a.size+'">'+a.size+"</span></td></tr><tr><td>"+B(e,"Location")+'</td><td class="'+vn+'" title="'+a.location+'">'+a.location+"</td></tr><tr><td>"+B(e,"Modified")+'</td><td class="'+vn+'" >'+r+"</td></tr>"+s+"</table>",d.buttons=[{buttonModel:{isPrimary:!0,content:B(e,"Button-Ok")},click:function(){e.dialogObj.hide()}}];break;case"MultipleFileDetails":d.dialogName="File Details",void 0===(o=e.itemData.map(function(e){return p=e.name.indexOf(".")+1,0!==p||e.isFile?0!==p?e.name.substr(p).replace(" ",""):"undetermined":"Folder"}))[0]&&(o=a.name.split(",").map(function(e){return p=e.indexOf(".")+1,0===p?"Folder":e.substr(p).replace(" ","")})),l=o.every(function(e,t,i){return e===i[0]})?"Folder"===o[0]?"Folder":o[0].toLocaleUpperCase()+" Type":"Multiple Types",h=a.location,d.header=a.name,d.content="<table><tr><td>"+B(e,"Type")+':</td><td class="'+vn+'">'+l+"</td></tr><tr><td>"+B(e,"Size")+":</td><td>"+a.size+'<span class="'+vn+'" title ="'+a.size+'"></span></td></tr><tr><td>'+B(e,"Location")+':</td><td class="'+vn+'" title="'+h+'">'+h+"</td></tr></table>",d.buttons=[{buttonModel:{isPrimary:!0,content:B(e,"Button-Ok")},click:function(t){"keydown"!==t.type&&e.dialogObj.hide()}}];break;case"Error":e.notify(Ln,{}),d.dialogName="Error","401"===n.error.code?d.header='<span class="e-fe-icon e-fe-access-error"></span><div class="e-fe-access-header">'+B(e,"Access-Denied")+"</div>":d.header=B(e,"Error"),d.content='<div class="'+gn+'">'+n.error.message+"</div>",d.buttons=[{buttonModel:{isPrimary:!0,content:B(e,"Button-Ok")},click:function(){e.dialogObj.hide()}}]}return d}function Rt(e,i,n){kt(t.selectAll(".e-btn",e.dialogObj.element)),gt(e,e.dialogObj,n,i)}function Mt(e,i,n){kt(t.selectAll(".e-btn",e.extDialogObj.element)),gt(e,e.extDialogObj,n,i)}function kt(e){for(var t=0;t<e.length;t++)!function(t){e[t].onkeydown=function(e){13===e.keyCode&&e.preventDefault()},e[t].onkeyup=function(i){13===i.keyCode&&e[t].click()}}(t)}function Lt(e,t){e.dialogObj.header=t.header,e.dialogObj.content=t.content,e.dialogObj.buttons=t.buttons,e.dialogObj.enableRtl=e.enableRtl,e.dialogObj.open=t.open,e.dialogObj.close=t.close,e.dialogObj.beforeOpen=Rt.bind(this,e,t.dialogName),e.dialogObj.beforeClose=function(i){mt(e,e.dialogObj,i,t.dialogName)},e.dialogObj.dataBind(),e.dialogObj.show()}function Tt(e){var i=t.select("#newname",e.dialogObj.element);Vt(e,i),""===i.parentElement.nextElementSibling.innerHTML&&Pe(e,i.value)}function At(e){var i=t.select("#rename",e.dialogObj.element);if(Vt(e,i),""===i.parentElement.nextElementSibling.innerHTML){var n=i.value,a=e.currentItemText.lastIndexOf(".");if(e.isFile&&!e.showFileExtension&&(n+=-1===a?"":e.currentItemText.substr(a)),e.renameText=n,e.currentItemText===n)return void e.dialogObj.hide();var s="";if(s="navigationpane"===e.activeModule?je(e,e.itemData[0]):e.path,e.renamedId=t.getValue("id",e.itemData[0]),e.isFile){var r=-1===a?"":e.currentItemText.substr(a),o=n.lastIndexOf("."),l=-1===o?"":n.substr(o);e.showFileExtension&&r!==l?ft(e,"Extension",null,s):Me(e,s,n)}else Me(e,s,n)}}function Ft(e){e.dialogObj.hide(),e.notify(Cn,{})}function Ut(e,t){/[/\\|*?"<>:]/.test(t.value)?_t(e,t):""===t.value?t.parentElement.nextElementSibling.innerHTML=B(e,"Validation-Empty"):t.parentElement.nextElementSibling.innerHTML=""}function Vt(e,t){Ut(e,t);var i=t.value.length-1;""===t.value||t.value.lastIndexOf(".")!==i&&t.value.lastIndexOf(" ")!==i||!e.showFileExtension&&-1!==t.value.lastIndexOf(".")&&0!==t.value.substring(t.value.indexOf(".")+1).length||_t(e,t)}function _t(e,t){var i