403Webshell
Server IP : 193.86.120.172  /  Your IP : 216.73.216.67
Web Server : Apache/2.4.63 (Unix)
System : Linux JServices 3.10.108 #86003 SMP Wed Oct 22 13:20:46 CST 2025 x86_64
User : kubec ( 1026)
PHP Version : 8.2.28
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /volume1/@appstore/SynologyDrive/drive/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /volume1/@appstore/SynologyDrive/drive/synodrive_common.js
/* Copyright (c) 2026 Synology Inc. All rights reserved. */

function showPasswordDialog(e,t,i){new SYNO.SDS.Drive.PasswordDialog({files:e,listeners:{scope:i,apply:function(){t&&Ext.isFunction(t)&&t.apply(i,arguments)}}}).show()}function showSinglePasswordDialog(e,t,i){var n=SYNO.SDS.Drive.Utils.getPathId(e[0].file_id);new SYNO.SDS.Office.PasswordWindow({path:n,listeners:{success:function(e,o){t&&Ext.isFunction(t)&&t(i,n,o)}}}).show()}Ext.define("SYNO.SDS.Drive.Store",{extend:"SYNO.API.Store",constructor:function(){SYNO.SDS.Drive.Store.superclass.constructor.apply(this,arguments)},sort:function(){this.sorting=!0,SYNO.SDS.Drive.Store.superclass.sort.apply(this,arguments)},loadRecords:function(e,t,i){var n,o,s=this.sorting;if(this.sorting&&(this.sorting=!1),!0!==this.isDestroyed){if(!e||!1===i)return!1!==i&&this.fireEvent("load",this,[],t),void(t.callback&&t.callback.call(t.scope||this,[],t,!1,e));var r,a=e.records,l=e.totalRecords||a.length,d=!1,c=!1;if(t.add||s||l!==this.totalLength)d=!0;else{for(n=0,o=a.length;n<o;++n){r=a[n];var h=this.data.items[n];if(!h){d=!0;break}var u,p,S,f=h.data;if(h.id!==r.id){d=!0;break}c=!1;for(S in f)f.hasOwnProperty(S)&&(p=h.data[S],u=r.data[S],SYNO.ux.Utils.checkObjectConsistency(u,p)||(c=!0,h.data[S]=u));c&&h.commit()}t.callback&&t.callback.call(t.scope||this,a,t,!0)}var g=SYNO.SDS.Drive.GetWindow().getEventMgr();d?(t.add||g.fireEvent("enableviewmask"),SYNO.SDS.Drive.Store.superclass.loadRecords.apply(this,arguments)):(g.fireEvent("disableviewmask"),this.fireEvent("load",this,a,t))}}}),Ext.define("SYNO.SDS.Drive.ViewStore.Base",{extend:"SYNO.SDS.Drive.Store",pageSize:1e3,constructor:function(e){this.appWindow=e.appWindow;var t=this.getAPIInfo(),i={autoLoad:!1,proxy:new SYNO.API.Proxy({api:t.api,method:t.method,version:t.version,timeout:3e5,listeners:{scope:this,beforeload:function(e,t){e.activeRequest.read&&Ext.Ajax.abort(e.activeRequest.read)}}}),remoteSort:!0,reader:this.getReader(),sortInfo:this.getSortInfo(),baseParams:this.getBaseParams(),listeners:{scope:this,beforeload:this.onBeforeNodeLoad,load:this.onLoadStore,exception:this.onExceptionStore}};Ext.apply(i,e||{}),this.callParent([i])},convertOwner:function(e,t){var i=Ext.isObject(t.owner)?t.owner.display_name:"";return"#"===i.charAt(0)&&(i=SYNO.SDS.Drive._T("common","deleted_user")),i},convertExt:function(e,t){return SYNO.SDS.Drive.Utils.getNtype(t.name,t.type)},convertLabels:function(e,t){var i=[];return Ext.each(t.labels,function(e){e.color=e.color.substr(1),i.push(e)}),i},onBeforeNodeLoad:function(e,t){if(SYNO.SDS.Drive.WindowHelper.isPublicShare()&&window.getDriveFile&&!window.getDriveFile())return!1;var i=this.getLoadParam(t);if(!1===i)return e.removeAll(),this.appWindow.getEventMgr().fireEvent("storeloaddone",e,[]),!1;SYNO.SDS.Drive.Utils.apply(t.params,i),this.parseSortInfo(t),this.getFilter&&this.getFilter()?t.params.filter=this.getFilter():delete t.params.filter;var n=this.appWindow.getEventMgr().fireEvent("storebeforeload",e,t);return this.parseSortInfo(t),n&&(this.loading=!0),n},parseSortInfo:function(e){if(e&&e.params&&e.params.sort_direction&&(e.params.sort_direction=e.params.sort_direction.toLowerCase()),e&&e.params&&e.params.sort_by)switch(e.params.sort_by){case"mtime":e.params.sort_by="modified_time";break;case"owner_name":e.params.sort_by="owner"}},onLoadStore:function(e,t,i){this.sorting=!1,this.loading=!1,i&&i.add||this.appWindow.getEventMgr().fireEvent("storeloaddone",e,t,i)},onExceptionStore:function(e,t,i,n,o,s){this.sorting=!1,this.loading=!1,n&&n.add||this.appWindow.getEventMgr().fireEvent("storeloadfail",o)},setExtraOptions:function(e){this.extraOptions=e},getExtraOptions:function(){return this.extraOptions||{}},clearExtraOptions:function(){this.extraOptions=null},getAPIInfo:Ext.emptyFn,getReader:Ext.emptyFn,getSortInfo:Ext.emptyFn,getBaseParams:function(){return{}},getLoadParam:function(e){return{}}}),Ext.define("SYNO.SDS.Drive.ViewStore.Node",{extend:"SYNO.SDS.Drive.ViewStore.Base",getAPIInfo:function(){return SYNO.SDS.Drive.WebAPIDesc.list_files},getReaderFields:function(){return[{name:"file_id"},{name:"parent_id"},{name:"sync_id"},{name:"name"},{name:"path"},{name:"display_path"},{name:"mtime",mapping:"modified_time"},{name:"ctime",mapping:"created_time"},{name:"atime",mapping:"access_time"},{name:"owner"},{name:"labels",convert:this.convertLabels},{name:"starred"},{name:"hash"},{name:"type"},{name:"removed"},{name:"starred"},{name:"shared"},{name:"permanent_link"},{name:"size"},{name:"hash"},{name:"capabilities"},{name:"shared_with"},{name:"adv_shared"},{name:"version_id"},{name:"ntype",mapping:"name",convert:this.convertExt},{name:"owner_name",convert:this.convertOwner},{name:"encrypted"},{name:"revisions"},{name:"original_path"},{name:"support_remote"},{name:"transient"},{name:"disable_download"},{name:"enable_watermark"},{name:"force_watermark_download"},{name:"node_locking"},{name:"in_disconnected_cold_tier"}]},getReader:function(){return new Ext.data.JsonReader({root:"items",id:"file_id",fields:this.getReaderFields()})},getBaseParams:function(){return Ext.apply({path:SYNO.SDS.Drive.WindowHelper.isPublicShare()&&window.getDriveFile?SYNO.SDS.Drive.Utils.getPathId(window.getDriveFile().file_id):"/mydrive",offset:0,limit:this.pageSize},{filter:this.getFilter()||{}})},getLoadParam:function(e){var t,i=this.getExtraOptions(),n=this.appWindow.getNavigation(),o={};return t=n.isRootPath()&&SYNO.SDS.Drive.WindowHelper.isPublicShare()&&window.getDriveFile?window.getDriveFile().file_id:n.getLastPathId(),n.isRootPath()||SYNO.SDS.Drive.Utils.apply(o,{path:SYNO.SDS.Drive.Utils.getPathId(t)}),Ext.apply(o,i)},setFilter:function(e){this.filterParam=e},getFilter:function(){return Ext.applyIf(this.filterParam||{},{include_transient:!0})}}),Ext.define("SYNO.SDS.Drive.ViewStore.Recycle",{extend:"SYNO.SDS.Drive.ViewStore.Node",getAPIInfo:function(){return SYNO.SDS.Drive.WebAPIDesc.list_trash},getBaseParams:function(){return{}},getSortInfo:function(){return{field:"recycled_time",direction:"ASC"}},getReaderFields:function(){var e=SYNO.SDS.Drive.ViewStore.Recycle.superclass.getReaderFields.call(this);return e.push({name:"recycled_time"}),e},getLoadParam:function(e){var t="node",i={},n=this.appWindow.getNavigation();if(_S("is_admin")){var o=n.getLastPath(),s=this.appWindow.getDrivePanel().getRecycleBtn();if(!s)return!1;if(!(t=s.getCheckedId())&&!o.display_path)return!1;if(o.display_path){var r=o.display_path.split("/");"mydrive"!==r[2]&&s.setCheckedName(r[3])}}if(!n.isRootPath())return SYNO.SDS.Drive.Utils.apply(i,{path:SYNO.SDS.Drive.Utils.getPathId(n.getLastPathId())}),i;switch(t){case"node":SYNO.SDS.Drive.Utils.apply(i,{path:"/mydrive"});break;default:SYNO.SDS.Drive.Utils.apply(i,{path:SYNO.SDS.Drive.Utils.getPathId(t)})}return i}}),Ext.define("SYNO.SDS.Drive.ViewStore.Starred",{extend:"SYNO.SDS.Drive.ViewStore.Node",getAPIInfo:function(){return SYNO.SDS.Drive.WebAPIDesc.list_star_files},getBaseParams:function(){var e={offset:0,limit:this.pageSize};return this.getFilter()&&(e=Ext.apply({filter:this.getFilter()})),e}}),Ext.define("SYNO.SDS.Drive.ViewStore.Recent",{extend:"SYNO.SDS.Drive.ViewStore.Node",getAPIInfo:function(){return SYNO.SDS.Drive.WebAPIDesc.list_recent},getBaseParams:function(){return this.getFilter()?{filter:this.getFilter()}:{}},getSortInfo:function(){return{field:"atime",direction:"ASC"}}}),Ext.define("SYNO.SDS.Drive.ViewStore.Tag",{extend:"SYNO.SDS.Drive.ViewStore.Node",getAPIInfo:function(){return SYNO.SDS.Drive.WebAPIDesc.list_label_files},getBaseParams:function(){var e={offset:0,limit:this.pageSize};return this.getFilter()&&(e=Ext.apply({filter:this.getFilter()})),e},getLoadParam:function(e){var t=this.appWindow.getNavigation(),i={};return SYNO.SDS.Drive.Utils.apply(i,{label_id:t.getCategory()}),i}}),Ext.define("SYNO.SDS.Drive.ViewStore.TeamFolder",{extend:"SYNO.SDS.Drive.ViewStore.Node",getAPIInfo:function(){return SYNO.SDS.Drive.WebAPIDesc.list_team_folders},getReaderFields:function(){var e=this.callParent(arguments);return e.push({name:"team_id"}),e},getBaseParams:function(){return this.getFilter()?{filter:this.getFilter()}:{}}}),Ext.define("SYNO.SDS.Drive.ViewStore.Search",{extend:"SYNO.SDS.Drive.ViewStore.Node",infinite:!0,first_limit:25,onBeforeNodeLoad:function(){this.resetLoadMore(),this.callParent(arguments),this.on("load",function(e,t,i){i.params.content_snippet||this.loadSnippet(i.params)},this,{single:!0})},getLimit:function(){return"tile"===SYNO.SDS.Drive.GetWindow().getViewModeMgr().getViewMode()?300:this.first_limit},getAPIInfo:function(){return SYNO.SDS.Drive.WebAPIDesc.search_files},getSortInfo:function(){return{field:"score",direction:"asc"}},getBaseParams:function(){return{content_snippet:!1}},getReaderFields:function(){var e=this.callParent(arguments);return e.push({name:"score"},{name:"content_snippet"}),e},getLoadParam:function(e){if(this.prevParams)return this.prevParams=SYNO.SDS.Drive.Utils.copyTo(this.prevParams,e.params,"sort_by,sort_direction"),e.params=this.prevParams,e.params.content_snippet=!1,e.params.limit=Math.max(this.getLimit(),this.getCount()),void(e.params.offset=0);var t={},i=e.params;this.fillSearchKeyword(i,t),this.fillSearchLabels(i,t),this.fillSearchDate(i,t),this.fillSearchType(i,t),this.fillSearchLocation(i,t),this.fillSearchOwner(i,t),this.fillSearchSize(i,t),this.fillSortField(i,t),this.fillEnableContentSearch(i,t),t.limit=this.first_limit,t.offset=0,t.content_snippet=!1,e.params=t,this.prevParams=t},cleanParams:function(){this.prevParams=null,this.resetLoadMore()},resetLoadMore:function(){this.reachEnd=!1,this.loadingMore=!1,this.loadMoreAjax&&this.loadMoreAjax.conn&&(this.loadMoreAjax.conn.abort(),this.loadMoreAjax=null),this.loadSnippetAjax&&this.loadSnippetAjax.conn&&(this.loadSnippetAjax.conn.abort(),this.loadSnippetAjax=null)},removeLeadingWildCard:function(e){var t=[];return Ext.each(e.split(" "),function(e){(e=e.replace(/^\*+/,""))&&t.push(e)}),t.join(" ")},removeColon:function(e){return e.replace(":"," ")},fillSearchKeyword:function(e,t){e.query&&Ext.isString(e.query)&&(t.keyword=this.removeLeadingWildCard(this.removeColon(e.query)))},fillSearchLabels:function(e,t){e.tag&&Ext.isArray(e.tag)&&0!==e.tag.length&&(t.labels=e.tag.map(function(e){return e.label_id}))},fillSearchDate:function(e,t){var i=e.datetype,n=e.searchdatefrom,o=e.searchdateto,s=e.searchdatefromformat,r=e.searchdatetoformat;"any"!==i&&(n||o)&&(n=n?Date.parseDate(n+" 00:00:00",s+" H:i:s").getTime()/1e3:0,o=o?Date.parseDate(o+" 23:59:59",r+" H:i:s").getTime()/1e3:2147483647,t.start_date=n,t.end_date=o,t.time=i)},fillSearchType:function(e,t){if(e.ntype&&"any"!==e.ntype)switch(e.ntype){case"extension":e.custom_file_type&&(t.file_type="custom",t.custom_file_type=e.custom_file_type);break;default:t.file_type=e.ntype}},fillSearchLocation:function(e,t){if(e.parent_id){var i=e.parent_id.split(":")[1];return t.location="custom",void(t.custom_location=SYNO.SDS.Drive.Utils.getPathId(i))}if(e.location&&"any"!==e.location)return void(t.location=e.location)},fillSearchOwner:function(e,t){e.owner&&"any"!==e.owner&&(t.owner=e.owner,"custom"===e.owner&&(t.custom_owner={type:"user",name:e.custom_owner}))},fillSearchSize:function(e,t){if(e.size&&e.custom_size&&!(e.custom_size<0||1024*e.custom_size*1024>SYNO.SDS.Drive.Define.MAX_INT_VALUE)){var i=1024*e.custom_size*1024;switch(e.size){case"greater":t.min_size=i;break;case"equal":0===i?(t.min_size=0,t.max_size=1):(t.min_size=Math.max(parseInt(.95*i),0),t.max_size=Math.min(parseInt(1.05*i),SYNO.SDS.Drive.Define.MAX_INT_VALUE));break;case"less":t.max_size=i}}},fillSortField:function(e,t){t.sort_by=this.sortInfo.field,t.sort_direction=this.sortInfo.direction.toLowerCase()},fillEnableContentSearch:function(e,t){t.enable_content_search=!0===e.enable_content_search},isloadMore:function(){return!(this.reachEnd||this.loadingMore||!this.prevParams||this.first_limit>this.getCount())},loadMore:function(e,t,i){if(this.isloadMore()){var n=this.prevParams;n.offset=this.getCount(),n.limit=this.getLimit(),n.content_snippet=!1,this.loadingMore=!0;var o=SYNO.SDS.Drive.GetWindow();this.loadMoreAjax=o.sendWebAPI(Ext.apply({params:n,timeout:3e5,callback:function(s,r,a){if(this.loadingMore=!1,!this.isDestroyed&&"search"===o.getNavigation().getCategory()){if(!s)return void(this.reachEnd=!0);if(this.prevParams){var l=a.content_snippet,d=SYNO.Util.copy(this.prevParams);if(delete d.content_snippet,delete a.content_snippet,d.toString()===a.toString()){var c=this.reader.readRecords(r);e&&e.call(i),this.loadRecords(c,{add:!0},!0),a.limit>c.totalRecords&&(this.reachEnd=!0),t&&t.call(i),l||this.loadSnippet(n)}}}},scope:this},this.getAPIInfo()))}},loadSnippet:function(e){if(e.enable_content_search){var t=SYNO.SDS.Drive.GetWindow();this.isDestroyed||"search"!==t.getNavigation().getCategory()||0===this.getCount()||(this.loadSnippetAjax=t.sendWebAPI(Ext.apply({params:Ext.apply(e,{content_snippet:!0}),timeout:3e5,callback:function(e,i,n){if(!this.isDestroyed&&"search"===t.getNavigation().getCategory()&&e){var o=this.reader.readRecords(i),s=SYNO.SDS.Drive.GetWindow().getViewModeMgr().getViewMode(),r="snippet"===s;Ext.each(o.records,function(e){var t=this.getById(e.id);t&&(r?t.set("content_snippet",e.data.content_snippet):t.data.content_snippet=e.data.content_snippet)},this)}},scope:this},this.getAPIInfo())))}}}),Ext.define("SYNO.SDS.Drive.ViewStore.SharedWithMe",{extend:"SYNO.SDS.Drive.ViewStore.Node",getAPIInfo:function(){return SYNO.SDS.Drive.WebAPIDesc.list_shared_with_me},getBaseParams:function(){return this.getFilter()?{filter:this.getFilter()}:{}},getReaderFields:function(){var e=SYNO.SDS.Drive.ViewStore.SharedWithMe.superclass.getReaderFields.call(this);return e.push({name:"sync_to_device"}),e}}),Ext.define("SYNO.SDS.Drive.ViewStore.SharingToOther",{extend:"SYNO.SDS.Drive.ViewStore.Node",getAPIInfo:function(){return SYNO.SDS.Drive.WebAPIDesc.list_shared_with_others},getBaseParams:function(){return this.getFilter()?{filter:this.getFilter()}:{}}}),Ext.define("SYNO.SDS.Drive.ViewStore.Backup",{extend:"SYNO.SDS.Drive.ViewStore.Node",getAPIInfo:function(){return SYNO.SDS.Drive.WebAPIDesc.list_backup_tasks},getBaseParams:function(){return this.getFilter()?{filter:this.getFilter()}:{}},getSortInfo:function(){return{field:"atime",direction:"ASC"}}}),Ext.define("SYNO.SDS.Drive.ViewStore.FileRequest",{extend:"SYNO.SDS.Drive.ViewStore.Node",getAPIInfo:function(){return SYNO.SDS.Drive.WebAPIDesc.list_file_request},getReaderFields:function(){return[{name:"file_id"},{name:"description"},{name:"name"},{name:"display_path"},{name:"destination_folder"},{name:"due_date"},{name:"has_due_date_hour"},{name:"expire_time"},{name:"file_request_status"},{name:"is_expired"},{name:"identifier"},{name:"permanent_link"},{name:"protect_password"},{name:"sharing_link"},{name:"title"},{name:"uid"},{name:"sync_id"},{name:"mtime",mapping:"modified_time"},{name:"created_time"},{name:"url"},{name:"atime",mapping:"access_time"},{name:"ntype",mapping:"name",convert:this.convertExt}]},filterStatus:"any",getFilterStatus:function(){return this.filterStatus},setFilterStatus:function(e){this.filterStatus=e},getBaseParams:function(){var e={};return""!==this.getFilterStatus()&&(e=Ext.apply(e,{status:this.getFilterStatus()})),e},getLoadParam:function(e){if(""!==this.getFilterStatus()){var t={};t.status=this.getFilterStatus(),e.params=Ext.apply(e.params,t)}},getSortInfo:function(){return{field:"created_time",direction:"DESC"}},parseSortInfo:function(e){if(e&&e.params&&e.params.sort_direction&&(e.params.sort_direction=e.params.sort_direction.toLowerCase()),e&&e.params&&e.params.sort_by)switch(e.params.sort_by){case"expire_time":e.params.sort_by="due_date";break;case"destination_folder":e.params.sort_by="display_path"}},onLoadStore:function(){this.appWindow.getViewModeMgr().setViewMode("list"),this.callParent(arguments)},getReader:function(){return new Ext.data.JsonReader({root:"items",id:"file_request_id",fields:this.getReaderFields()})},getFilter:function(){}}),Ext.define("SYNO.SDS.Drive.StoreMgr",{extend:"Ext.Component",publicEventMap:{createnodedone:"onCreateNodeDone",convertofficedone:"onConvertOfficeDone",setnodepermdone:"onSetNodePermDone",deletenodepermdone:"onDeleteNodepermDone",deletetagdone:"onUpdateNodeStoreReload",hidetagdone:"onUpdateNodeStoreReload",settagdone:"onUpdateNodeStoreReload",copynodedone:"onCopyNodeDone",encryptnodedone:"onEncryptNodeDone",setnodedone:"onSetNodeDone",movenodedone:"onMoveNodeDone",setnodetitledone:"onSetNodeTitleDone",deletenodedone:"onDeleteNodeDone",restorenodedone:"onRestoreNodeDone",categorychange:"onCategoryChange",pathchange:"onPathChange",updatenode:"onUpdateNodeStoreReloadByObject",uploadcomplete:"onUploadComplete",syncdevicedone:"onSyncDeviceDone",cleannodedone:"onCleanNodeDone"},privateEventMap:{setnodetagdone:"onSetNodeTagDone",setshortcutdone:"onSetShortcutDone",deleteshortcutdone:"onDeleteShortcutDone",setnodelockdone:"onSetNodeLockDone",updateteamfolderdone:"onUpdateNodeStoreReload"},constructor:function(e){this.appWindow=e.appWindow,this.callParent(arguments),this.createStores(),this.onRegEvent()},onRegEvent:function(){var e=this.appWindow.getEventMgr();this.blRegEvent||(Ext.iterate(this.publicEventMap,function(t){var i=this.publicEventMap[t];this.mon(e,t,this[i],this)},this),SYNO.SDS.Drive.WindowHelper.isPublicShare()||Ext.iterate(this.privateEventMap,function(t){var i=this.privateEventMap[t];this.mon(e,t,this[i],this)},this))},createStores:function(){this.stores={node:new SYNO.SDS.Drive.ViewStore.Node({appWindow:this.appWindow}),shared_with_me:new SYNO.SDS.Drive.ViewStore.SharedWithMe({appWindow:this.appWindow}),sharing_to_others:new SYNO.SDS.Drive.ViewStore.SharingToOther({appWindow:this.appWindow}),file_request:new SYNO.SDS.Drive.ViewStore.FileRequest({appWindow:this.appWindow}),backup:new SYNO.SDS.Drive.ViewStore.Backup({appWindow:this.appWindow}),team_folder:new SYNO.SDS.Drive.ViewStore.TeamFolder({appWindow:this.appWindow}),recycle:new SYNO.SDS.Drive.ViewStore.Recycle({appWindow:this.appWindow}),recent:new SYNO.SDS.Drive.ViewStore.Recent({appWindow:this.appWindow}),starred:new SYNO.SDS.Drive.ViewStore.Starred({appWindow:this.appWindow}),search:new SYNO.SDS.Drive.ViewStore.Search({appWindow:this.appWindow}),tag:new SYNO.SDS.Drive.ViewStore.Tag({appWindow:this.appWindow})},this.activeStore=this.stores.node},getStore:function(e){return this.stores[e]},getActiveStore:function(){return this.activeStore},onCategoryChange:function(e,t,i){if("search"===e||e!==i){this.stores.hasOwnProperty(e)?this.activeStore=this.stores[e]:this.activeStore=this.stores.tag,"search"===e&&this.activeStore.cleanParams();var n=this.appWindow.getNavigation(),o={};SYNO.SDS.Drive.Utils.isEnterFromSharing()&&n.getSelection()&&(o.loadItemFileId=n.getSelection()),this.onStoreReload(!0,SYNO.SDS.Drive.Utils.apply(t||{},Object.assign({params:{offset:0,limit:1e3}},o))),this.appWindow.getEventMgr().fireEvent("viewstorechange",e,t,this.activeStore)}},onPathChange:function(e,t,i,n){if(n){var o,s=this.appWindow.getNavigation();o=s.isRootPath()?this.stores.hasOwnProperty(i)?this.stores[i]:this.stores.tag:"recycle"!==i?this.stores.node:this.activeStore,o!==this.activeStore&&(this.activeStore=o,this.appWindow.getEventMgr().fireEvent("viewstorechange",i,null,this.activeStore));var r={};SYNO.SDS.Drive.Utils.isEnterFromSharing()&&s.getSelection()&&(r.loadItemFileId=s.getSelection()),"search"!==i&&this.onStoreReload(!0,Object.assign({params:{offset:0,limit:1e3}},r),!0)}},getObjectByFileId:function(e){var t,i=this.getActiveStore();if(Ext.isArray(e)){for(var n=0;n<e.length;n++)if(t=i.getById(e[n]))return t;return!1}return(t=i.getById(e))||!1},getObject:function(e){var t,i=this.getActiveStore();Ext.isArray(e)||(e=[e]);for(var n=0;n<e.length;n++){var o=e[n].split(":");if((o.length<2||"link"!==o[0])&&(t=this.getObjectByFileId(o[1])))return t;var s=i.findExact("permanent_link",o[1]);if(-1!==s&&(t=i.getAt(s)))return t}return!1},getObjectByDisplayPath:function(e){var t,i=this.getActiveStore();Ext.isArray(e)||(e=[e]);for(var n=0;n<e.length;n++){var o=i.findExact("display_path",e[n]);if(-1!==o&&(t=i.getAt(o)))return t}return!1},findNextFocusIdx:function(){var e=this.appWindow.getPanel();if(!e.getSelectionModel)return-1;var t=e.getSelectionModel().getSelections();if(Ext.isEmpty(t))return-1;var i=e.getStore().getTotalCount()-(t.length-1)-1;return Ext.each(t,function(t){i=Math.min(i,e.getStore().indexOf(t))}),i},onCreateNodeDone:function(e,t,i,n){var o=this.appWindow.getNavigation();if("recycle"!==o.getCategory()){var s,r=o.getLastPathId();t&&(t.parent_id?s=t.parent_id:t.result&&t.result.params&&t.result.params.to_parent_folder&&(s=SYNO.SDS.Drive.Utils.getFileIdFromPathId(t.result.params.to_parent_folder))),r===s&&this.onStoreReload(!1,void 0,!1,n,void 0,!0)}},onConvertOfficeDone:function(e,t,i){if(e&&t){var n=this.appWindow,o=n.getNavigation();if("recycle"!==o.getCategory()){var s=o.getLastPathId();Ext.each(t.result.params.files,function(e){if(s===e.parent_id)return this.onStoreReload(),!1},this)}}},onSetNodePermDone:function(e,t,i){e&&this.onUpdateNodeStoreReloadByObject(i.file_id)},onDeleteNodepermDone:function(e,t,i){e&&this.onUpdateNodeStoreReloadByObject(i.file_id)},onCopyNodeDone:function(e,t,i){if(e&&"recycle"!==this.appWindow.getNavigation().getCategory()){var n=this.appWindow.getNavigation().getLastPathId();SYNO.SDS.Drive.Utils.getFileIdFromPathId(i.to_parent_folder)===n&&this.onStoreReload()}},onEncryptNodeDone:function(e,t,i){if(e&&t){var n=this.appWindow.getNavigation();"recycle"!==n.getCategory()&&(t.parent_id===n.getLastPathId()||this.getObjectByDisplayPath(t.display_path))&&this.onStoreReload()}},onSetNodeDone:function(e,t,i){e&&"recycle"!==this.appWindow.getNavigation().getCategory()&&this.getObjectByFileId(t.file_id)&&this.onStoreReload()},onMoveNodeDone:function(e,t,i){if(i&&"recycle"!==this.appWindow.getNavigation().getCategory()){var n=this.appWindow.getNavigation().getLastPathId();if(SYNO.SDS.Drive.Utils.getFileIdFromPathId(i.to_parent_folder)===n)return void this.onStoreReload();var o;Ext.each(i.files,function(e){if(o=this.getObject(e))return this.onStoreReload(),!1},this)}},onSetNodeTitleDone:function(e,t,i){e&&"recycle"!==this.appWindow.getNavigation().getCategory()&&this.onStoreReloadWithAfterFocus("file_id",t.file_id)},onDeleteNodeDone:function(e,t,i){if(e)switch(this.appWindow.getNavigation().getCategory()){case"recycle":this.onStoreReload(void 0,void 0,void 0,void 0,!0);break;default:Ext.each(i.files,function(e){if(this.getObject(e))return this.onStoreReload(void 0,void 0,void 0,void 0,!0),!1},this)}},onCleanNodeDone:function(e,t,i){if(e){var n=this.appWindow.getNavigation();"recycle"===n.getCategory()&&(n.isRootPath()?this.onStoreReload():n.setCategoryAndPath("recycle"))}},onRestoreNodeDone:function(e,t,i){if(e){switch(this.appWindow.getNavigation().getCategory()){case"recycle":Ext.each(i.files,function(e){if(this.getObject(e.path))return this.onStoreReload(),!1},this);break;default:this.onStoreReload()}}},onUpdateNodeStoreReloadByObject:function(e){e&&!this.getObjectByFileId(e)||this.onUpdateNodeStoreReload()},onUpdateNodeStoreReload:function(){switch(this.appWindow.getNavigation().getCategory()){case"recycle":break;default:this.onStoreReload()}},onSetNodeTagDone:function(e,t,i){this.onStoreReload()},onSetNodeLockDone:function(e,t,i){this.onStoreReload()},onSetShortcutDone:function(e,t,i){if(!e)return void this.onStoreReload();Ext.each(i.files,function(e){var t=this.getObject(e);t&&!0!==t.data.starred&&(t.data.starred=!0,t.commit())},this)},onDeleteShortcutDone:function(e,t,i){e||this.onStoreReload(),Ext.each(i.files,function(e){var t=this.getObject(e);t&&!1!==t.data.starred&&(t.data.starred=!1,t.commit())},this)},onUploadComplete:function(e){if(e&&Ext.isArray(e)){var t=this.appWindow.getNavigation();Ext.each(e,function(e){if(SYNO.SDS.Drive.Utils.getFileIdFromPathId(e.path)===t.getLastPathId())return this.onStoreReload(),!1},this)}},onStoreReloadWithAfterFocus:function(e,t){this.onStoreReload(void 0,void 0,!0,void 0,void 0,!0,function(){var i=this.getActiveStore(),n=i.findExact(e,t),o=this.appWindow.getPanel();o.getSelectionModel&&o.getSelectionModel().selectRow(n),o.focusItem&&o.focusItem(n)}.bind(this))},onStoreReload:function(e,t,i,n,o,s,r){var a,l=function(){this.getActiveStore().reload(Ext.apply({scope:this,callback:function(e,t,i){if(void 0!==this.load_options.focusIdx){var n=this.appWindow.getPanel();-1!==this.load_options.focusIdx&&n.getStore&&(this.load_options.focusIdx=Math.min(this.load_options.focusIdx,n.getStore().getTotalCount()-1),n.getSelectionModel&&n.getSelectionModel().selectRow(this.load_options.focusIdx),n.focusItem&&n.focusItem(this.load_options.focusIdx),n.getView&&(n.getView().preserveScroll=!1)),d.fireEvent("enableviewmask"),Ext.isFunction(this.load_options.cb)&&this.load_options.cb()}}},this.load_options.options))}.bind(this);t&&t.loadItemFileId&&(a=t.loadItemFileId,delete t.loadItemFileId),this.load_options={blMask:e||!1,focusNext:o||!1,skipFocus:s||!1,options:t||{},cb:r,loadItemFileId:a};var d=this.appWindow.getEventMgr();this.delayStoreReloadTask||(this.delayStoreReloadTask=new Ext.util.DelayedTask(function(){if(!0!==this.load_options.blMask?d.fireEvent("disableviewmask"):(this.getActiveStore().removeAll(),d.fireEvent("enableviewmask")),this.appWindow.getPanel().getView&&(this.appWindow.getPanel().getView().preserveScroll=this.load_options.focusNext),this.load_options.focusIdx=this.load_options.skipFocus?-1:this.findNextFocusIdx(),this.load_options.loadItemFileId){var e=this.getActiveStore();e.setExtraOptions({include_item_file_id:this.load_options.loadItemFileId});var t=this.getStoreSortInfo(e);SYNO.API.Request({api:e.getAPIInfo().api,version:e.getAPIInfo().version,method:e.getAPIInfo().method,params:Ext.apply(e.getBaseParams(),e.getLoadParam(),t,this.load_options.options.params),callback:function(t,i,n){if(e.clearExtraOptions(),!t||!i||!i.include_item_idx||i.include_item_idx<1){var o=SYNO.SDS.Drive.Utils.getErrorStr(i);return SYNO.Debug.error(o),this.load_options.options.params.offset=0,void l()}var s=i.include_item_idx,r=Math.ceil(s/e.pageSize);this.load_options.options.params.offset=(r-1)*e.pageSize,l()}.bind(this)})}else l()},this),this.mon(this,"beforedestroy",function(){this.delayStoreReloadTask.cancel(),this.delayStoreReloadTask=null},this)),this.delayStoreReloadTask.cancel(),this.delayStoreReloadTask.delay(i?0:n||80)},getStoreSortInfo:function(e){var t=this.appWindow.getNavigation(),i=this.appWindow.getPanel(),n={sort_by:"name",sort_direction:"desc"};if(e.sortInfo){var o=e.sortInfo;n.sort_by=o.field,n.sort_direction=o.direction}if(!e.sorting){var s=i.getSortInfo(t.getCategoryText());s&&(n.sort_by=s.field,n.sort_direction=s.direction)}return n},onSyncDeviceDone:function(e,t,i){e&&"shared_with_me"===this.appWindow.getNavigation().getCategory()&&this.onStoreReload()},destroy:function(){Ext.iterate(this.stores,function(e){this.stores[e].destroy()},this),this.callParent(arguments)}}),Ext.define("SYNO.SDS.Drive.EventMgr",{extend:"Ext.util.Observable",constructor:function(e){this.appWindow=e.appWindow,this.listeners=e.listeners,this.callParent([e])}}),Ext.define("SYNO.SDS.Drive.ViewModeMgr",{extend:"Ext.Component",constructor:function(e){this.appWindow=e.appWindow,this.viewMode=e.viewMode||this.getViewMode(),this.callParent(arguments)},isCheckUserSetting:function(){return!!(!SYNO.SDS.Drive.WindowHelper.isPublicShare()&&Ext.getClassByName("SYNO.SDS.Drive.MainWindow")&&this.appWindow instanceof SYNO.SDS.Drive.MainWindow)},setViewMode:function(e){this.viewMode=e,this.appWindow.getEventMgr().fireEvent("viewmodechange",e),this.isCheckUserSetting()&&"snippet"!==e&&"empty"!==e&&SYNO.SDS.UserSettings.setProperty("SYNO.SDS.Drive.Application","viewmode",e)},getUserViewMode:function(){if(this.isCheckUserSetting())return SYNO.SDS.UserSettings.getProperty("SYNO.SDS.Drive.Application","viewmode")},getViewMode:function(){return this.viewMode||this.getUserViewMode()||"list"}}),Ext.define("SYNO.SDS.Drive.Task.Base",{extend:"Ext.Component",type:"base",constructor:function(e){this.appWindow=e.appWindow;var t={action:e.action,taskid:Ext.id(void 0,this.type+"_"),starttime:(new Date).getTime(),title:"",name:"",prevProgress:0,hasProgress:!1,showProgress:!1,delayProgress:1e3,showToast:!0,showStartToast:!0,total:-1,status:"wait",statusText:SYNO.SDS.Drive._T("task","task_waiting")};Ext.apply(t,e||{}),Ext.apply(this,t),this.callParent(arguments)},start:function(){return this.starttime=(new Date).getTime(),this.status="processing",this.statusText=SYNO.SDS.Drive._T("task","task_processing"),this._showToast("start"),this._showProgress.defer(this.delayProgress,this),this._onChange(),new Promise(function(e,t){this.resolve=e,this.reject=t,this._start()}.bind(this))},stop:function(){this.status="stopped",this._stop(),this.reject&&this.reject("stop"),this._cleanup()},clone:function(){return null},_start:function(e,t){},_stop:function(){},_cleanup:function(){this.resolve=null,this.reject=null,this.progressbox&&this.progressbox.hide()},_onFinished:function(e,t){e?this._onSuccess(t):this._onError(t),this.fireEvent("onfinish",this,e,t),this._cleanup()},_onChange:function(){this.fireEvent("onchange",this)},_onProgress:function(e){this.prevProgress=e,this.hasProgress&&(!0===this.showProgress&&this._onUpdateProgress(e),this.fireEvent("onprogress",this,e))},_onError:function(e){"error"!==this.status&&"partial_error"!==this.status&&(this.status="error",this.statusText=SYNO.SDS.Drive.Utils.getErrorStr(e)),this._showToast("error",e),this._onUpdateProgress(0,!0,!1,e),this.fireEvent("onerror",this,e);try{this.reject&&this.reject(e)}catch(e){SYNO.Debug.error(e)}},_onSuccess:function(e){this.status="success",this.statusText=SYNO.SDS.Drive._T("task","task_completed"),this._showToast("success",e),this._onUpdateProgress(100,!0,!0,e),this.fireEvent("onsuccess",this,e);try{this.resolve(e)}catch(e){SYNO.Debug.error(e)}},_showToast:function(e,t){if(this.showToast&&this.appWindow&&(this.showStartToast||"start"!==e)){var i=this._getToastMessage(e,t),n=i.action;SYNO.SDS.Drive.Utils.showToastMsg(this.appWindow,i.text,n?5e3:3e3,!!n,n)}},_getToastMessage:function(e,t){var i=SYNO.SDS.Drive._T;if("success"!==e&&"error"!==e)return{text:this._getTitleText(e)};if(!t||!t.result)return{text:this._getTitleText(e)};var n=t.result,o=this.title,s="",r=n&&!Ext.isEmpty(n.skips),a=r&&1===n.skips.length,l=n&&!Ext.isEmpty(n.errors),d=l&&1===n.errors.length;if(r&&!l&&a)return s=SYNO.SDS.Drive.Utils.parseDisplayName(n.skips[0].context.name),{text:String.format(i("task","success_skip"),Ext.util.Format.htmlEncode(s))};if(l&&!r&&d)return o=String.format("{0}_error",o),s=SYNO.SDS.Drive.Utils.parseDisplayName(n.errors[0].context.name),{text:String.format(i("task",o),Ext.util.Format.htmlEncode(s))};if(!r&&!l){var c,h=SYNO.SDS.Drive.GetWindow();if(n)if("restore"===n.action&&n.names&&n.params&&!n.params.to_parent_folder&&1===n.names.length&&0===h.modalWin.length&&n.targets&&1===n.targets.length)c={text:i("action","goto_folder"),fn:function(){h.getAction().onGotoPath({path:SYNO.SDS.Drive.Utils.getPathIdByLink(n.targets[0].permanent_link)},void 0,void 0,!1)}};else if("convert_office"===n.action&&this._isConvertFolder(n))return{text:this._getConvertFolderText(e,n.names)};return{action:c,text:this._getTitleText(e)}}var u=[];return u.push(SYNO.SDS.Drive._T("task","task_completed")),r&&u.push(String.format(i("task","skipped_items"),n.skips.length)),l&&u.push(String.format(i("task","error_items"),n.errors.length)),{text:u.join(", ")}},_isConvertFolder:function(e){var t=e.names;if(Ext.isEmpty(t))return!0;var i=Ext.isString(this.name)?[this.name]:this.name,n=!1;return Ext.each(t,function(e){if(-1===i.indexOf(e))return n=!0,!1}),n},_getConvertFolderText:function(e,t){var i,n,o,s=this.name;return o=t?1===t.length?1:t.length:0,Ext.isArray(s)&&s.length>1?(i=0===o?"convert_multi_folder_none_success":1===o?"convert_multi_folder_one_success":"convert_multi_folder_multi_success",
n=String.format(SYNO.SDS.Drive._T("task",i),s.length,o)):(i=0===o?"convert_folder_none_success":1===o?"convert_folder_one_success":"convert_folder_multi_success",n=String.format(SYNO.SDS.Drive._T("task",i),s.toString(),o)),Ext.util.Format.htmlEncode(n)},_getTitleText:function(e,t){var i,n,o=e?String.format("_{0}",e):"";return t=t||this._getTitleSourceText(),Ext.isArray(t)&&t.length>1?(i=String.format("{0}_multi{1}",this.title,o),n=String.format(SYNO.SDS.Drive._T("task",i),t.length,this._getDestinationName())):(i=String.format("{0}{1}",this.title,o),n=SYNO.SDS.Drive._T("task",i),n=String.format(n,SYNO.SDS.Drive.Utils.parseDisplayName(t.toString()),this._getDestinationName())),Ext.util.Format.htmlEncode(n)},_showProgress:function(){if(this.showProgress&&this.appWindow&&!this.progressbox&&("processing"===this.status||"task_error"===this.status)){var e={ok:_T("common","hide"),cancel:_T("common","cancel")},t={title:"",cls:"syno-d-bgtask-message-progress",width:340,progress:this.hasProgress,progressText:this.hasProgress?"<center>0&#37;</center>":"",closable:!1,buttons:e,fn:function(e){switch(e){case"ok":this.hideProgress=!0;break;case"cancel":this.taskmgr.removeTask(this.taskid)}},hideDlg:!0,scope:this};this.progressbox=this.appWindow.getMsgBox(),this.progressbox.show(t),this.progressbox.updateText(this._getProgressTitle()),0<this.prevProgress&&this._onUpdateProgress(this.prevProgress)}},_onUpdateProgress:function(e,t,i,n){this.progressbox&&this.progressbox.isVisible()&&!this.hideProgress&&(!0===t?i?(this.progressbox.updateProgress(1,this._getProgressText(100),this._getProgressTitle()),this.progressbox.hide.defer(2e3,this)):SYNO.SDS.Drive.Utils.showAlertMsg(this.appWindow,this._getToastMessage("error",n).text):this.progressbox.updateProgress(e/100,this._getProgressText(e),this._getProgressTitle()))},_getProgressTitle:function(){var e=Ext.isArray(this.name)?this.name:[this.name];e=e.map(function(e){return SYNO.SDS.Drive.Utils.parseDisplayName(e)}).join(", "),e=Ext.util.Format.htmlEncode(e);var t=String.format('<span style="font-weight: bold;">{0}: </span><span class="syno-d-bgtask-progress-title" ext:qtip="{1}">{2}</span>',this._getTitleText(),Ext.util.Format.htmlEncode(e),e),i=String.format('<span style="float:right; color:#7E8082">{0}</span>',this.statusText);return this.hasProgress?t:t+i},_getProgressText:function(e){if(!this.hasProgress)return"";if(0>=e||0>=this.total)return String.format("<center>{0}&#37;</center>",0<e?e:0);var t,i,n=["<div>",'<div class="syno-d-bgtask-progress-info">','<span style="float:left;">{0}% ({1}/{2})</span>','<span style="float:right;">{3}/'+SYNO.SDS.Drive._T("task","time_s")+"</span>","</div>",'<div class="syno-d-bgtask-progress-info">',"{4}: {5}","</div>","</div>"].join(""),o=this._getTimeSpeedInfo(e),s=String.format("1 {0}",SYNO.SDS.Drive._T("task","time_sec")),r=Math.round(100*o.speed)/100;return"delete"===this.action||"convert_office"===this.action?(r+=" "+SYNO.SDS.Drive._T("task","file_number"),t=this.total+" "+SYNO.SDS.Drive._T("task","file_number"),i=o.processed.toFixed(0)):(r=Ext.util.Format.fileSize(r),t=Ext.util.Format.fileSize(this.total),i=Ext.util.Format.fileSize(o.processed.toFixed(0))),String.format(n,Math.round(100*e)/100,i,t,r,SYNO.SDS.Drive._T("task","left_time"),SYNO.SDS.Drive.Date.fancyDuration(o.leftTime)||s)},_getTimeSpeedInfo:function(e){var t=this.total*(e/100),i=((new Date).getTime()-this.starttime)/1e3;return{processed:t,speed:t/i,leftTime:i*((100-e)/e)}},getTrayTitle:function(){if(Ext.isArray(this.name)&&this.name.length>1){var e=String.format("{0}_multi",this.title);return String.format(SYNO.SDS.Drive._T("task",e),this.name.length,Ext.util.Format.htmlEncode(this._getDestinationName()))}return String.format(SYNO.SDS.Drive._T("task",this.title),Ext.util.Format.htmlEncode(this.name),Ext.util.Format.htmlEncode(this._getDestinationName()))},getTrayTitleTooltip:function(){return this.getTrayTitle()},_getDestinationName:function(){return""},getTrayNames:function(){var e;return e=Ext.isArray(this.name)&&this.name.length>1?this.name:[this.name],e=e.map(function(e){return SYNO.SDS.Drive.Utils.parseDisplayName(e)}).join(", ")},_getTitleSourceText:function(){return this.name},onClickAction:function(){}}),Ext.define("SYNO.SDS.Drive.Task.Upload",{extend:"SYNO.SDS.Drive.Task.Base",type:"upload",buffer:1e3,lastTime:0,uploadedSize:0,startUploading:!1,isOutermost:!0,constructor:function(e){this.callParent(arguments),this._init()},initFiles:function(){return Promise.resolve(this)},updateParentPath:function(e){this.path=e,this.uploadPath=String.format("{0}/{1}",this.path,this.name)},clone:function(){return new SYNO.SDS.Drive.Task.Upload({appWindow:this.appWindow,path:this.path,file:this.file,isOutermost:this.isOutermost,showToast:!1})},_genTempFile:function(){var e="0123456789abcdef",t="",i=new Uint8Array(32);window.crypto.getRandomValues(i);for(var n=0;n<32;n++){var o=i[n]%e.length;t+=e.charAt(o)}return t},_upload:function(){var e={path:this.uploadPath,type:this.uploadType,modified_time:this.uploadMtime,conflict_action:"version",file:new Blob([])};SYNO.SDS.Drive.WebAPICore.sendPromise("upload_files",e,void 0,{headers:{"X-TMP-FILE":this.tmpFile,"X-TYPE-NAME":"SLICEUPLOAD","X-FILE-CHUNK-END":"false"}}).then(function(t){var i=t.tmp_newly_created;if(this.uploadedSize=t.uploaded_size,!0===this.startUploading&&0===this.uploadedSize&&!0===i)return void this._expectFinished();this.startUploading=!0,e={path:this.uploadPath,type:this.uploadType,modified_time:this.uploadMtime,conflict_action:"version",mute:this._needMute(),file:this.file.slice(this.uploadedSize)},this.apiId=SYNO.SDS.Drive.WebAPICore.send("upload_files",e,{callback:this._onFinished.createDelegate(this),progress:this._onProgress.createDelegate(this)},this,void 0,{headers:{"X-TMP-FILE":this.tmpFile,"X-TYPE-NAME":"SLICEUPLOAD","X-FILE-CHUNK-END":"true"}})}.bind(this)).catch(function(e){this._isResumeUploadError(e)&&(setTimeout(function(){this._upload()}.bind(this),500),this.fireEvent("onnetworkerror",this,e))}.bind(this))},_expectFinished:function(){SYNO.SDS.Drive.WebAPICore.send("get_file",{path:this.uploadPath},{callback:function(e,t){if(!e&&this._isResumeUploadError(t))return void this._expectFinished();this._onFinished(e,t)}.bind(this)})},_start:function(){this.tmpFile=this._genTempFile(),this._upload()},_stop:function(){if(this.apiId)try{this.apiId.abortController.abort()}catch(e){SYNO.Debug.error(e)}},_init:function(){this.uploadPath=String.format("{0}/{1}",this.path,this.file.name),this.uploadType="file",this.uploadMtime=this.file.lastModifiedDate?this.file.lastModifiedDate.getTime():this.file.lastModified,this.uploadMtime/=1e3,this.uploadSize=this.file.size,this.name=this._getFileName(this.file.name),this.total=this.uploadSize,this.title=this.type,this.hasProgress=!0},_cleanup:function(){this.callParent(arguments),this.apiId=null,this.lastTime=0},_onProgress:function(e,t){if(!(e.timeStamp-this.lastTime<this.buffer)){var i=0===e.total?1:(this.uploadedSize+e.loaded)/(this.uploadedSize+e.total);i=(100*i).toFixed(0),this.lastTime=e.timeStamp,this.callParent([i])}},_onFinished:function(e,t){if(!e&&t&&0===t.status){var i=1e4;switch(t.statusText){case"communication failure":i=10001}return void this.callParent([!1,{code:i}])}if(!e&&this._isResumeUploadError(t))return setTimeout(function(){this._upload()}.bind(this),500),void this.fireEvent("onnetworkerror",this,t);this.callParent(arguments)},_onSuccess:function(e){e&&this.appWindow&&this.appWindow.getEventMgr().fireEvent("createnodedone",!0,e,{},1500),this.callParent(arguments)},_onError:function(e){e&&e.code&&(this.status="error",this.statusText=SYNO.SDS.Drive.Utils.getErrorStr(e),this.errors=e.errors=[this._getErrObject(e.code)]),this.callParent(arguments)},_getErrObject:function(e){return{code:e,context:{name:this.name,file_type:"file"}}},_getFileName:function(e){if(Ext.isWindows)return e.substr(e.lastIndexOf("\\")+1);var t=/fakepath\\(.+)$/.exec(e);return null!==t&&(e=t[1]),e},_isResumeUploadError:function(e){return 1054===e.code||"network error"===e.message},_needMute:function(){return!1===this.isOutermost}}),Ext.define("SYNO.SDS.Drive.Task.UploadDir",{extend:"SYNO.SDS.Drive.Task.Upload",blInit:!1,blUploadDir:!0,initFiles:function(){return this.blInit?Promise.resolve(this):this._createSubTasks()},clone:function(){return new SYNO.SDS.Drive.Task.UploadDir({appWindow:this.appWindow,path:this.path,directory:this.directory,isOutermost:this.isOutermost,showToast:!1})},_createSubTasks:function(){return new Promise(function(e,t){this.blInit=!0,this.reader=this.directory.createReader(),this._readEntries(e,t)}.bind(this))},_readEntries:function(e,t){this.reader.readEntries(this._readEntriesCb.createDelegate(this,[e,t],!0),this._readEntriesErrCb.createDelegate(this,[e,t],!0))},_readEntriesCb:function(e,t,i){var n=[],o=this.path+"/"+this.name;if(!e.length)return void t(this);Ext.each(e,function(e){n.push(SYNO.SDS.Drive.TaskFactory.createUploadTaskByEntry(e,{appWindow:this.appWindow,path:o,isOutermost:!1,showToast:!1,showProgress:!1}).then(function(e){return e.initFiles()}))},this),Promise.all(n).then(function(e){this.total+=e.reduce(function(e,t){return e+t.total},0),this.subTasks=this.subTasks.concat(e),this._readEntries(t,i)}.bind(this)).catch(function(e){SYNO.Debug.error("Failed to initFiles: "+e),i(e)})},_readEntriesErrCb:function(e,t,i){SYNO.Debug.error(String.format("Failed to read entries: {0}, reason: {1}",this.name,e)),t(SYNO.SDS.Drive.TaskFactory.createErrTask({name:this.name,file_type:"dir"}))},_start:function(e,t){Promise.resolve().then(this.initFiles.bind(this)).then(this._startUpload.bind(this)).catch(this._onError.bind(this))},_stop:function(){this.curTask&&this.curTask.stop()},_init:function(){this.title=this.type,this.name=this._getFolderName(),this.hasProgress=!0,this.total=0,this.loaded=0,this.subTasks=[],this.errors=[]},_cleanup:function(){this.curTask=null,this.subTasks=null,this.loaded=0,this.subTasks=[]},_startUpload:function(){return Promise.resolve().then(this._createFolder.bind(this)).then(this._updateSubTask.bind(this)).then(this._uploadSubTasks.bind(this))},_createFolder:function(){return SYNO.SDS.Drive.WebAPICore.sendPromise("create_files",{type:"folder",path:this.path+"/"+this.name,conflict_action:"autorename",mute:this._needMute()}).then(function(e){return this.appWindow.getEventMgr().fireEvent("createnodedone",!0,e,{},1500),Promise.resolve(e)}.bind(this)).catch(function(e){return this.errors.push({context:{name:this.name,file_type:"dir"},code:e.code}),Promise.reject(e)}.bind(this))},_updateSubTask:function(e){return Ext.each(this.subTasks,function(t){t.updateParentPath(SYNO.SDS.Drive.Utils.getPathId(e.file_id))}),Promise.resolve()},_uploadSubTasks:function(){return this.curTask=this.subTasks.shift(),this.curTask?this.curTask.blErrTask?(this.errors=this.errors.concat(this.curTask.errors),this._uploadSubTasks()):(this.mon(this.curTask,"onprogress",this._onProgress,this),this.mon(this.curTask,"onsuccess",this._onTaskSuccess,this),this.mon(this.curTask,"onnetworkerror",this._onNetworkError,this),Promise.resolve().then(this.curTask.start.bind(this.curTask)).then(this._uploadSubTasks.bind(this)).catch(this._onSubTaskErr.bind(this))):(this._onFinished(),Promise.resolve())},_onSubTaskErr:function(e){return"stop"===e?Promise.reject("stop"):e.errors?(this.errors=this.errors.concat(e.errors),this._uploadSubTasks()):Promise.reject(e)},_onTaskSuccess:function(e,t){this.loaded+=e.total},_onProgress:function(e,t){var i=this.loaded+e.total*(t/100),n=(100*i/this.total).toFixed(0);0<this.errors.length&&(this.status="task_error",this.statusText=SYNO.SDS.Drive._T("task",this.status)),this.fireEvent("onprogress",this,n)},_onSetSuccess:function(){},_onFinished:function(){0===this.errors.length?this._onSuccess():this._onError(),this._cleanup()},_onError:function(e){"stop"!==e&&(this.status="partial_error",this.statusText=SYNO.SDS.Drive._T("task",this.status),this.callParent([{errors:this.errors}]))},_onNetworkError:function(e,t){this.fireEvent("onnetworkerror",this,t)},_getFolderName:function(){return this._getFileName(this.directory.name)}}),Ext.define("SYNO.SDS.Drive.Task.UploadToDir",{extend:"SYNO.SDS.Drive.Task.UploadDir",clone:function(){return new SYNO.SDS.Drive.Task.UploadToDir({appWindow:this.appWindow,path:this.path,files:this.files,folderName:this.folderName,isOutermost:this.isOutermost,showToast:!1})},_createSubTasks:function(){var e=[],t=this.path+"/"+this.name;return this.files.length&&0!==this.files.length?new Promise(function(i,n){Ext.each(this.files,function(i){e.push(SYNO.SDS.Drive.TaskFactory.createUploadTask(i,null,{appWindow:this.appWindow,path:t,showToast:!1,showProgress:!1,isOutermost:!1}).then(function(e){return e.initFiles()}))},this),Promise.all(e).then(function(e){this.total+=e.reduce(function(e,t){return e+t.total},0),this.subTasks=this.subTasks.concat(e),i(this)}.bind(this)).catch(function(e){SYNO.Debug.error("Failed to initFiles: "+e),n(e)})}.bind(this)):Promise.resolve(this)},_updateSubTask:function(e){var t=SYNO.SDS.Drive.Utils.getPathId(e.file_id);return Ext.each(this.subTasks,function(e){var i=e.file.webkitRelativePath,n=i.substr(0,i.length-e.name.length),o=String.format("{0}/{1}",t,n.substr(n.indexOf("/")+1));e.updateParentPath(o)}.bind(this)),Promise.resolve()},_getFolderName:function(){return this.folderName}}),Ext.define("SYNO.SDS.Drive.Task.Background.Base",{extend:"SYNO.SDS.Drive.Task.Base",type:"background",immediate:!0,interval:[{time:0,interval:1},{time:3,interval:3}],pollingOnly:!1,constructor:function(e){this.callParent(arguments),this._init(e)},_start:function(){var e=Promise.resolve();this.pollingOnly||(e=SYNO.SDS.Drive.WebAPICore.sendPromise(this.webapi,this.params,void 0,this.opt)),e.then(this._startPolling.bind(this)).catch(this._onError.bind(this))},_stop:function(){this.pollId&&SYNO.SDS.Drive.WebAPICore.send("delete_task",{task_id:this.async_task_id})},_init:function(e){this.webapi=e.webapi,this.params=e.params,this.title=e.title,this.name=e.name,this.progress=e.progress||0,this.total=e.total||-1,this.async_task_id=e.async_task_id},_cleanup:function(){this.callParent(arguments),this.pollId&&this.pollUnreg(this.pollId),this.pollId=null},_startPolling:function(e){this.pollingOnly||(this.async_task_id=e.async_task_id);var t=SYNO.SDS.Drive.WebAPIDesc.get_task;this.pollId=this.pollReg({webapi:Ext.apply({params:{task_id:this.async_task_id}},t),interval:this.interval,immediate:!!this.immediate,status_callback:this._onStatusCb.bind(this),scope:this})},_onStatusCb:function(e,t,i,n){if("finished"===t.status||!e)return t.result&&Ext.isArray(t.result.errors)&&0<t.result.errors.length&&(e=!1),void this._onFinished(e,t);this._onProgress(t)},_onError:function(e){e&&e.result&&Ext.isArray(e.result.errors)&&0<e.result.errors.length?("download"===e.result.action&&0<e.result.processed_size?(this.status="partial_error",this.statusText=SYNO.SDS.Drive._T("task",this.status)):e.result.names&&1===e.result.names.length||!e.result.names&&e.result.context&&1===e.result.errors.length?(this.status="error",this.statusText=SYNO.SDS.Drive.Utils.getErrorStr(e.result.errors[0])):(this.status="partial_error",this.statusText=SYNO.SDS.Drive._T("task",this.status)),this.errors=e.result.errors):(this.status="error",this.statusText=SYNO.SDS.Drive.Utils.getErrorStr(e.result)),this.callParent(arguments)},_onProgress:function(e){if(!(0>e.progress)){e.result&&Ext.isArray(e.result.errors)&&0<e.result.errors.length&&(this.status="task_error",this.statusText=SYNO.SDS.Drive._T("task",this.status),this.errors=e.result.errors),e.result&&(this.total=e.result.total_size||-1);var t=e.progress;if(0<e.progress&&!this.progressbox){var i=this._getTimeSpeedInfo(e.progress/100);this.delayProgress<i.leftTime/1e3&&this._showProgress()}this.callParent([t.toFixed(0)])}}}),Ext.define("SYNO.SDS.Drive.Task.Background.MVCP",{extend:"SYNO.SDS.Drive.Task.Background.Base",constructor:function(e){this.callParent([e]),this.to_parent_folder_name=e.params.to_parent_folder_name,this.title=String.format("task_{0}",this.title),this.finishedResult=void 0},_getToastMessage:function(e,t){if("success"!==e||!t||!t.result)return this.callParent(arguments);var i=t.result,n=i&&!Ext.isEmpty(i.skips),o=i&&!Ext.isEmpty(i.errors);if(!n&&!o){var s=Ext.id();return{action:{text:Ext.util.Format.htmlEncode(this._getDestinationName()),fn:this.onClickAction.bind(this),textActionId:s},text:this._getSuccussToastText()}}return this.callParent(arguments)},_onSuccess:function(e){return e&&e.result?(this.finishedResult=e.result,this.callParent(arguments)):this.callParent(arguments)},getTrayTitle:function(){return this._getTrayTitle()},getTrayTitleTooltip:function(){return this._getTrayTitle(!0)},_getTrayTitle:function(e){var t;if("processing"===this.status||"wait"===this.status)return Ext.isArray(this.name)&&this.name.length>1?(t=String.format("action_{0}_multi_start",this.title),String.format(SYNO.SDS.Drive._T("task",t),this.name.length,Ext.util.Format.htmlEncode(this._getDestinationName()))):(t=String.format("action_{0}_start",this.title),String.format(SYNO.SDS.Drive._T("task",t),Ext.util.Format.htmlEncode(this.name),Ext.util.Format.htmlEncode(this._getDestinationName())));if(!e&&"success"===this.status){var i='<a class="syno-d-bgtask-action">';return Ext.isArray(this.name)&&this.name.length>1?(t=String.format("action_{0}_multi_success",this.title),String.format(SYNO.SDS.Drive._T("task",t),this.name.length,Ext.util.Format.htmlEncode(this._getDestinationName()),i,"</a>")):(t=String.format("action_{0}_success",this.title),String.format(SYNO.SDS.Drive._T("task",t),Ext.util.Format.htmlEncode(this.name),Ext.util.Format.htmlEncode(this._getDestinationName()),i,"</a>"))}return Ext.isArray(this.name)&&this.name.length>1?(t=String.format("action_{0}_multi_done",this.title),String.format(SYNO.SDS.Drive._T("task",t),this.name.length,Ext.util.Format.htmlEncode(this._getDestinationName()))):(t=String.format("action_{0}_done",this.title),String.format(SYNO.SDS.Drive._T("task",t),Ext.util.Format.htmlEncode(this.name),Ext.util.Format.htmlEncode(this._getDestinationName())))},onClickAction:function(){var e=SYNO.SDS.Drive.GetWindow(),t=this.finishedResult.targets;t&&1===t.length?e.getAction().onGotoPath({path:SYNO.SDS.Drive.Utils.getPathIdByLink(t[0].permanent_link)},void 0,void 0,!1):e.getAction().onGotoPath({path:this.finishedResult.params.to_parent_folder})},_getParentFolderName:function(){return this.to_parent_folder_name?this.to_parent_folder_name:SYNO.SDS.Drive._T("category","node")},_getDestinationName:function(){return this._getParentFolderName()},_getSuccussToastText:function(){var e,t,i=this._getTitleSourceText();return Ext.isArray(i)&&i.length>1?(e=String.format("{0}_multi_success_toast",this.title),t=String.format(SYNO.SDS.Drive._T("task",e),i.length,"","","")):(e=String.format("{0}_success_toast",this.title),t=SYNO.SDS.Drive._T("task",e),t=String.format(t,Ext.util.Format.htmlEncode(SYNO.SDS.Drive.Utils.parseDisplayName(i.toString())),"","","")),t}}),Ext.define("SYNO.SDS.Drive.Task.Background.ConvertOffice",{extend:"SYNO.SDS.Drive.Task.Background.Base",constructor:function(e){e.opt=e.opt||{},Ext.applyIf(e.opt,{encryption:["additional_passwords"]}),this.callParent([e])},_getToastMessage:function(e,t){if("error"!==e||!t||!t.result)return this.callParent(arguments);var i=this.callParent(arguments),n={action:{text:SYNO.SDS.Drive._T("task","check_detail"),fn:function(){SYNO.SDS.Drive.GetWindow().getLeftPanel().getBackgroundTray().onViewDetail()}}};return Ext.applyIf(i,n)}}),Ext.define("SYNO.SDS.Drive.Define",{singleton:!0,TIME_FORMAT:"H:i",TIME_SEC_FORMAT:"H:i:s",DATE_FORMAT:"Y-m-d",TITLE_MAX_LENGTH:256,TAG_MAX_LENGTH:100,MAX_INT_VALUE:0x7ffffffffffffc00,TagColor:["DCE1E6","FFCCCC","FFD9B2","FFEC8C","DDF29D","C4F5D4","C2F2F2","C8EDFA","CCE6FF","E2D9FF","FFD9F2","FFC0D2","A0A5AA","FA8282","FA9C3E","F2CA00","94BF13","4DBF73","1DBFBF","24BFF2","499DF2","A18AE6","E67EC3","F56496","64696E","E04343","E67300","CCAA00","739900","009933","009999","008FBF","1470CC","7052CC","CC3D9C","C81466"],TagTextColor:{DCE1E6:"50555A",FFCCCC:"C73232",FFD9B2:"BF6000",FFEC8C:"997F00",DDF29D:"567300",C4F5D4:"007326",C2F2F2:"007373",C8EDFA:"007399",CCE6FF:"0059B3",E2D9FF:"5536B3",FFD9F2:"B32483",FFC0D2:"A12A62",A0A5AA:"FFF",FA8282:"FFF",FA9C3E:"FFF",F2CA00:"FFF","94BF13":"FFF","4DBF73":"FFF","1DBFBF":"FFF","24BFF2":"FFF","499DF2":"FFF",A18AE6:"FFF",E67EC3:"FFF",F56496:"FFF","64696E":"FFF",E04343:"FFF",E67300:"FFF",CCAA00:"FFF",739900:"FFF","009933":"FFF","009999":"FFF","008FBF":"FFF","1470CC":"FFF","7052CC":"FFF",CC3D9C:"FFF",C81466:"FFF"},ColorSelf:"#499DF2",AnonymousUID:4294967295,LockOverlayDynamicIcon:{name:"dynamic_thumbnail",width:22,height:25}}),SYNO.SDS.Drive.Define.Info={drive_id:"/mydrive"},Ext.define("SYNO.SDS.Drive.ToastBox",{extend:"SYNO.SDS.ToastBox",constructor:function(e){this.callParent(arguments),this.textActionId=e.textActionId},bindEvents:function(){this.callParent(arguments),this.textActionEl=Ext.get(this.textActionId),this.textActionEl&&(this.textActionEl.on("click",this.actionHandler.createSequence(this.destroyBox,this),this.actionHandlerScope||this),this.textActionEl.addKeyListener(Ext.EventObject.ENTER,this.actionHandler.createSequence(this.destroyBox,this),this.actionHandlerScope||this),this.textActionEl.addKeyListener(Ext.EventObject.SPACE,this.actionHandler.createSequence(this.destroyBox,this),this.actionHandlerScope||this))},unbindEvents:function(){this.callParent(arguments),this.textActionEl&&this.textActionEl.un("click",this.actionHandler.createSequence(this.destroyBox),this.actionHandlerScope||this)}}),function(){var e=["3fr","arw","bmp","cr2","crw","dcr","dng","erf","gif","jpe","jpeg","jpg","k25","kdc","mef","mos","mrw","nef","orf","pef","png","ptx","raf","raw","rw2","sr2","srf","tif","tiff","x3f","heic","heif","svg","webp","jfif"],t={acc:["acc","accdb","accde","accdr","accdt","ade","adn","adp","mam","maf","maq","mar","mat","mda","mdb","mde","mdf","mdn","mdt","mdw"],image:e.concat(["ufo","ico"]),audio:["aac","ac3","aif","ape","cda","dts","flac","m4a","m4b","mid","mka","mp2","mp3","mpc","ogg","pcm","ra","wav","wma","mp1","mpa","ram","m4p","aiff","dsf","dff","m3u","wpl"],video:["3g2","3gp","amr","asf","avi","dat","divx","dvr-ms","ifo","m1v","m2t","m2ts","m2v","m4v","mkv","mov","mpe","mpeg","mpeg1","mpeg2","mpeg4","mpg","mp4","mts","ogv","qt","rm","rmvb","tp","trp","ts","vob","webm","wmv","xvid","vdr"],doc:["doc","docx","rtf","wri","odt"],ppt:["ppt","pps","ppsx","pptx","odp"],xls:["xls","xla","xlam","xlb","xlc","xld","xlk","xll","xlm","xlsb","xlsm","xlsx","xlt","xltm","xlv","xlw","xltx","ods","ots","csv"],ai:["ai"],psd:["psd"],fla:["fla"],pdf:["pdf"],swf:["swf","f4v","flv"],idn:["idn","indd"],txt:["diff","erl","json","lst","markdown","md","mdown","mkdn","out","patch","sml","txt"],htm:["htm","html"],code:["actproj","ad","akp","applescript","as","asax","asc","ascx","asm","asmx","asp","aspx","asr","as3","bat","c","cc","cmake","coffee","cpp","cs","css","cxx","erb","groovy","gvy","h","haml","hh","hpp","hxx","java","js","jsx","less","m","make","mhtml","ml","mm","php","pl","plist","properties","py","rb","sass","scala","scm","script","scss","sh","sql","swift","tsx","vb","vi","vim","xhtml","xml","xsd","xsl","yaml","yml"],bkpi:["bkpi"],ttf:["ttf","otf","ttc"],iso:["iso","bin","daa","img","mds","nrg"],zip:["zip","7z","bz2","gz","rar","tar","tbz","tgz","txz","jar","lzh","rpm","xz","zipx"],exe:["exe"],key:["key"],numbers:["numbers"],pages:["pages"],folder:["folder","dir"],folder_photo:["folder_photo"],synodoc:["odoc"],synosheet:["osheet"],synoslide:["oslides"]},i={image:e,video:t.video.concat(t.swf).concat(["iso"])},n=Object.keys(t).reduce(function(e,i){return t[i].forEach(function(t){e[t]=i}),e},{}),o={acc:"A9dJREFUaEPtmt9LU2EYx7/P2XRbVuqN/cKMLCij3MGpzW6CIgjKRQRdaFSQdaMEFtQf0EVGeFEQFIFFdtOF1aqLbrrMqIsJUVpOp1PR6Vpz/tiWujfehcv9SM85bPOM9sJgO+d9n30/z/d93rN35xAyvFGG60ccgM1mKwjM010wVsuA9akEJKIZAG9zKLfRZCobVfJdcQCdn7qeMMbqlQRTOoZADkFHh6rLyx1yY8QDfLRN8swb9+6GQa+TG09W/7m5eXyzOzA1PQMCjeQIwmGTaV+PnCBxAO8/2hgPYK40yomjuG8oFEJPrwOTvimAMKHV4kiVKHZJDbjqAFxoiDF8tzvw0+sDiLyCQEf3V5R/kAKhCgAulDGgt38APzxeDjGtEchSXVH+biUI1QAsCu1zODHu9gCggEZgp6pN4pvlIFQHwMU6nCMYc02ACHMQqN5cYXz2LwhVAnCxzuFRjIy6+NsFAdSwv8rYlghCtQBcLAfgIETEQLhsNhnvxkKoGoCLHXO5MTA0AsYYSIN6c4X4dCmE6gG4WNe4G/2Dw7wm7OZKcWfGAXDBnZ/+XNtqqsSopGeEA1mAla6GseeHLl2C/8uXqMOGPXtQfP++3FCR/mmbQr/6+jBw9mxCodseP0ZuaakiiLQBjLe2wtvRkVBkwcmTKGpuVi8ACwbRX1uLhRm+0Ypvmrw8bLdaQTr5+4y0OOB7/RpjN29GlOt37cK82x1+LbaN169j/bFjsl1IC8DQxYvwf/0aEbfhyhXMuVzwtLdHjhnKylD84IH6AIJ2OwbPnYsIo5wclFqtmPd4MFBXFyW45NEj6HbskAWRcgfGb9+G98WLiKh1Bw9i040b4c/OhgYEursj5wpOnEDR1avqAWCBAPotlqji3dLSgrwDB8IiJzs64GptjQgOF/PLlyC9XjJESh2ILV5hzRoU37sH0mjCAhempjDc2AgWCiku5pQCOC9cQKBH1r8h4CvU1ocPV9+BYG8vBs+flyxkaceStjbodkb9Ov5nnJQ5EFu8mvx85JaUJBTCV6rQ7KyiYk4JAPP70WexRIkqampCwenTCQEm7tzBz2d/9+e8Vkp5MRsMKzqYEoDJV6/gamn5u/Zrtdj+/Dk0hYWJHUgw3TZcu4b848dXByC2eNfW1GDzrVvLiuEXOz6VFpvUYk6JAyumLYkdsgBJTKaiUFkHFKUtiYOyDiQxmYpCZR1QlLYkDvp/HOhM421WqQb5A0F0fe7md+V95ioxf+k4VdzolgpCRO3mSuOZZQHS+aiBZOGAD0RWvZY1iaLoXRZAalC19Mv4p1V+A99xL0/8q/utAAAAAElFTkSuQmCC",ai:"A3lJREFUaEPtmltIFFEYx/9nZ2cv7oZKIqWShUgXoht2MaJ8sTI0oowou6DSRVHppctTSVQYSkGaZVakZGgU1EtkllJUkFSUPeVDJJIblanl7rq77kys5kyzs7qz1xnBeZsz35zz/33ff789wwzBJD/IJNcPEQBbCs1AL06xwF6wmBlqQM2yHVcNeU0H/V1HBNBfjDKWxTF/J/T1Ps3qA8DQgN8QIoC+YvSEI/NjoCMArsNPCDFAEVhfsxhIPAfgJ4SyAPyAUB6AjxDKBPABQrkAEiGUDSABQnYAevluEDpi4kY2QYuVHYBKXAkqfrH3TjwOhOwAIBSoWSlQxSb7VQn5AbznXhARXSXcv00B+JjAgMOnKhBwCgOcIPgVUNEwFD0G0U4TSLM1n4aj436AcsW3Bx2ASloL/dbzopWcXe2w3imcEMB45I3g+mB5ilfgoAPoMs9APX+DeGGWgbk6A6yld1xR8gOodTAWPQFonUeRtqflcLxrUi6Aet566LLO8gIdVoDWc+fOrx9gvZ2vXADdlgqok9M4gba2C9CuKwFUFDdmvpIJ9s83r96WGhC834DGCGNRC0DRo2szTgxeSod+cxmoxBU81LOLcLTXe9RH9FGCcdba75UjaADqhVnQZZzk7fKv69BLsqFNP86NM98/wVKX41GYrD9i/fYqULNX8ZluKYPj/V0QQwwMhY8Egs3XtoHt6xJByAbgKr2hsFno9eqNYM0/R0Tqc26AilvECba/rIH9Va1yANxt4uzpgLUhjxPoesrSph3mbfTrCyzXs5UDoN9ZCyphKS+IGQYcQ/y5Si36b7Dc3AXmR6cAQhYLEWMsDAUPvXYL9wD76zrYn1fKD+BuD7AMmL5uERCh1CCR8dw4+9sEc02W/AARe+qhmrGAb5+fX8B6j/c7d0FFw1jSJrCS5VYuGNNHLiTsFiJRCTDsF26Rhx4cxXBnq0dL6bMrQc1J5a453jbC1lohH4AmNR+aNQW8Laz9IztOMA6PAO52c7VZ8+VNcNnOdYS9AhG5TVDFJI2bUXcKVexcROxrEAxbGw/B2T36HBB2AJ9bTwhuCNpeKATaJE05BSApTSEMmqpACJMraWrvFQjza1ZJqseCCEzRlYj7/x7ZX3T7AkAIzkVVgn/cA+T/1EASAIGJAPWR03GClMI+YQUkTaigoEn/tcpf0TKqQHQCyvMAAAAASUVORK5CYII=",audio:"AtNJREFUaEPtWs9rE0EYfWOS2qRmtzEJlapQQSP1UKttFAWFhOpFEEREkEp68ubBmyfP4sWDf4ANFkGKCIIXLQki6KGplh6U1iIFaRWSkOxWU9LErOxqlmQ3mx/bTTILuzCn7My89773fTOzEwKTP8Tk+GER6HYEVREYir/o58A/goDLAgSm2wDF+QkID4KXLJjba6Er2UpMKgKeePSJIAiTNABXYiCEzGRCkZv1CcSiHC3KqwiA8JlwhK1LoD82LdCofhlTNjxV5RqVhSwCbQ6fFYE2C9xweOoiwNp7wBW3GwKnIolFsGOMD+NS80utz2bHwNsZ+gjYCMGxPg+CjF8CHWT9OOxkQIh6++WJR7tPYKDHiVPsP1XFNur2wmWzVwHLFvJY4FNISC2J2eMT0u9UEPhxfhK9NpsMuFgq4fPvDOb5pAR6nktidYuvIpQJReghUAZzbzUhqbu4mcZW6Y/KGoecbjkHbh0Ypo9ApR0YuwMn3b7/eeBHkPVhr6NXRYoKC5UjcGf5g5y4ARerStpvOV7OgQeB0/RFoFJerrCNj5spKQ8SXFICninm5VeozIHH68ty4q7kuLrlkUoCrfjZIiAdNxWP3vOAHjX19GnbZk4PGD19ukpgFwgmvIM44mLxNcfh2QhFW4lGaoqL2vORCxhn/XQvZFpV6OHRM5gaDNQsq61ULsMsdNG7H3eHRmU7nGB8dVfVL2evYd9uFx0ERPBl/yoRaampReBnPofh97OdPQ/Exi6hrHizBLQsNL2xAnH/1OxjiIW+n7uBPXaHas5fxQIOvntaE0utJBb3R1eX3oAvFprFD0MIaEXgE59CeOGVJhhlGZ1Lb6CE1j4EGkJAKweuL83hdXq9aTX1vGgIAXFiZRW6v7bYdvDivIYR0KOeEX0sAkaouJMxrAjsRD0j+jaMgMfsV0ymv+Qz/TWrET7t5BjWXw06qXatuUwfgb+qb6dAwJ2cZwAAAABJRU5ErkJggg==",bkpi:"A75JREFUaEPtmltoXFUUhr91Jk1TabTYKggqpdp6wTZzyGSSo/ailkrBG1oVNIG+RKnXB19EH8SHii++WFBsSy3ECl4KUhRRRLxUJ6TIBPpgzG1i2pBMM6nTSWKmTTJbNmNopjOd7JmeTM+BnqeBWXvt/1t7r3XWZh/B54/4XD95ANFodEV6Rvag1CMKrl5MQBGZBL5bItUvhUJ3DpczVx5A5Fhnm1KquRxn5Y4RJGYtlQca6+pipfrIB+iIntGRD66/g2U1S0v1V5L99PQMf/XGGJ+YRJChJZa1NRTa0FWKkzyA3zuiSjtwGoKl+CnbNpPJ0NUT40xqHITRqiq2hW2709ThZQfQQjNK0d0b459kCkSSliXbm+rr2k0gPAGghSoFPf0DjJ1OaoiJgCWPNtbX/bgQhGcA5oT2xQY5lTgNSDpgqR2NIfubYhCeA9BiY4NDjMRHEWEaS5qd+uDnF4PwJIAWO3hymKHhuP45ayGtTeHgx4UgPAugxWoADSIiCuFVJxTccyGEpwG02JF4goETQyilkADNTr19aD6E5wG02PipBP1/n9Q50es02Gt9B6AFR45l3213h+2coLu6AuNpONoDv3bDwBgkxrOxWlULq1fCxnVw71qorVmouuf/v6gA52bhsw441A4T6eLiltfAs03wdBiqA+YgiwaQmIDXv4SuEpvh22+Ad3fAquVmEIsCoMW3HoTR/7eKmZTzVtfVwr6dZhCuA+ht80Jb6ZG/EFKvxActC28n1wHaIvDRT6XGvLD981ugxSnuy1UAXW2e/HDhhDXF04n9xa7i1clVgG+Pw+6vTeWZ2b35EGxff3FbVwHeOAy/dJsJM7XatA7eeaJCAM/shcGx3MksgQfvgu4R6BstLOTW6+HF+0FXH129pqbP2928Ej59rkIA296Df8/lTrbhxmw1ySg40gn7f4bkVNZmxTJo3QwPB0GDxlPQvA+m5vm4qhq+f+0yAuieZNd98FQDVAWyCX7wt6ygnfeATtSZWTj8Bxw4CpNnc8VWFKDQFpqTc9O18MpWcG7JFRjpg/d/gBP6tFjgqegWMknipjXw9mNZpW99Be39xdN5822w+/EKbSHfl1Hfv8j0Qvu6ldAAvm/mNISv2+m5euHrA80chK+PlPMrt28P9aYd56XYudpOX4qQcsdeASg3cm6Nu7ICbkWyXD/GKxCp4DWrKcxU+iydx//Ut/IpJ2xfM3+cJy66TUFE5BOnIdhSFKCSnxoYC4cUIkdqqtTLtm0niwKYOvWKne+/VvkPuEwvT0k8bZAAAAAASUVORK5CYII=",code:"AqFJREFUaEPtmtFLU1Ecx79HnWwzt4VEFiOZUCRpOYgoK2KL6k17qSDqKXrsIfs7sof+hHzJCjR6CAoX1QQp3MRYNMiKTLJJbNNqtumRO9lad7s7287v6i7c+3p/53e+n9/39zuwnctg8IcZXD9MgK12sMiBO4GAiydxF+D9nMOx1QKV/RlDEmCPmQM3bvp88UJNRQBDY4F7nPMr9SBcrYExNjw44LsqABhP1EvliwGQHBzwO8sC3B4d5/VY/ZymW+f9/3VNUQuZADrbZzqgc4GF6U0HhCXSOcB0QOcCC9Pr4oDDZsWx/R6kMxm8jHxEZnWtrJDjXR5sb7FjMvoZseQvoejCAHIAp92Kiye8aLVZs/s8nYog8nVBU5S7zZWNV55UOo1HE9NYiC9VDEEKoBbPOcfwi7eIJZc1BdmaLbh+tg9NjQ01QZABlBL/fDqKmS/zwmp6drah/0g3Ghs2IFbSGTycCFfkBAmAjPgcXa0Q0gAU4mUgpACU0+bSyX8Dq/R8pW2j1VelnHgQDONHovRgSwGc83bhwJ72vJZn4Q8V9bxoKNQQc4txjARDJZdJAfh79qK3051PrJzjwfefRPqE7w927MbpQ/vA2MbPk9nvixidnKEHsDZbcKGvFzuc28gg1OKX/qQw8jqExO8UPYCSkRKiWvHK/lItlCsJBUQt4skAZJ2oVTwpgBbE/VdT+PYzoTm4ylF87czR/MCKel6diKSFCpOq2+nJm3eIzsc0Adpdrbh86nD2fbXiyR3Iz4SlCd5ON/5mVhGancMaL//XUk/HLrha7NnY5dSK8JgtDCB3oKrdCYJNAIIiSqUwHZAqH8Fi0wGCIkqlMB2QKh/BYqEDQ2MGv2Iy/CWf4a9ZCdp0U1OYnxpsarlLbGZ4B9YB3ZK3QL0Ey2EAAAAASUVORK5CYII=",doc:"BU5JREFUaEPtmntMW1Ucx7/nUh6jjveAxOhIptGpG20ojw7RhM3FOceikrlN9lBG1GRGxlwEGcyNoSSLZhl7mS3OOCcDF2NYNlCXJQYHCCxgNBlzZUUcgba8WsooLfSacwv3tuVVSC+UhPPXPef++ju/z+98f/fcRwkWeCMLPH6MA2hsbAwyDZNisGwKCwSICUgIGQDwszfx2atQPNMxm7nGAdTUN11kWTZtNs5m+xsComZ8ydr46Gj1TH2MB6hr1NPMy1atxBI/35n6m5G9xTKMuyo1+o0DICDt3gyzTqFY3TwTJ+MAqusaWepAGSubiZ9Z21qtVjTfU0Nv6AcIdBIJ1sfJ5U2uOpx3ABqolWXxj0qN3j4DQEgfw5ANCTHRta5AeAQADZRlgXv3W9Hd00chjF4M2RwfE31zOgiPARgLtEXdBm1XDwBi8mLY1HiF/NpUEB4HQINVt7WjU6MDIbCAIWnKGFnZZBAeCUCDbXvQgfYODT0cYUAyEuJkFyaC8FgAGiwFoCCEEBYEHyoVsmJnCI8GoMF2arrQ+l87WJYF8UKaMkZ+yR7C4wFosBptF+7/+4DWhEoZK39ywQHQgGvqbXvbmji5Q9IXxAosAjhX/ktHdGjvHuaHr+eGIyrci+9bRoC4jzsxZOFuq7h283AEIoMYvt8/yCIhR8MVJ22Phkrwa/6ySfcst0roYIkeP9Y+5Ccr2hGEFMUSvl+vMmNXcbdDMMd2BmNjjB8/dqvZjIwzgs3rCf44ui1wbgDKGwaRfbGPn+ytF6TIfUN49jlVacSpin6HYN5MlOLQFsHmdKURJ+1snJPgTOLWFejssyL5ELdLci06ygcl+0L5/q7iHtSrhhxieCLSG+U5YfzYu2d7UXXHNKnERAWgzl8u0KGty1YHPhKChmORkDCAedimf/OwoH9qQwhB9WcRCPS3XfiUORroH1q548fDJKjMm1z/1MatK0Ad5l/W40qNUAc/fBSGZx/zRp3KjN2j+vfzIRyQ1WqDOZkRguTnfKHWjmBjoZZPcqrSH0e2Tq5/UQCu3TbhwLe9fBD5WwKxNdEfJyuMOF1p0/+ap3xhGGTxd5uZ67+d/AgObF6Kn+oG8ckloYacC9xZPqIA6AxWvJgn1MFr8f4o3B4Ie/1nvhoAo8mK8zeMXEyrlvugNCsUn5bqUVYtrN5vBRFYFiBcYucEgE7ySqEOrVpbHdAipTKKzxb0//2+MAyYWP5yKfEi+KMoAtuPd+Nuu4X7XVS4BNdzp9a/KCtAnR4uM6D0Fn21AzAMwYn0YOw9R5+mAH9fBrVFEbAMs0jI1sAyYquD4vQQZF7oxchoXThfXifKvmgAFY0m7P9GqIOYFT643WLTe+LTvjj3fgh3vPNENxpGx+1t6Lkvdgdjg1zY4OYUoLvfiqSDQh3YT561KQB71km5oYk2tjHbqqMRCF06tf5FWwHqeNPnXWjptOnZvl3OCsPq5d7cEM0+XQXntiLSG1ftNrfJsi8qQMEVA0qqbHUw1qSj+vcaTSy9uUvI7sSg2XFz25YkRV6qa69f3b6RjQX7y58mZH4t1AEdT1rph6/eC3aA2nOmB9XNjrcXx98Jxvro6fUv6gr0DljxfK6Wvy2mk+1PCUD6Wpv+x9r5GwP48qqB79Nbi98LwxEsnV7/ogJMpVt3nhNNQu4Mcl6KeBHAxQwsSsjFRIlmtrgCoqXWRceLK+BiokQzc3kFaubwM6urtIOmITT9dYd+lTco4+QOT/8e8aHbVRBCyHfKWNkOe/t5/auBy4EDBhBS7idhP5DL5cLrDPq+yVUnnmq34AH+B0uqsk/AWW5PAAAAAElFTkSuQmCC",exe:"ASlJREFUaEPtmkEOwVAQhme2EiUuY90eQB2AxAUs1DnUwgUkHEAdoF27jFCJ7RNtJGiiRob2xd/1m//NfN/bTZks/9jy/gkDVG2wYGCeJG2T0oLI9Iwhp+oGr/czU0rEW3ZoPHHdw31PhQHCKFkZYwZ1aPy5B2ZeB747LBkgPtaFfHEASgPfa70cYLaJTR3p33qa9r2HV1N4Qhjgy/pg4MuAS+P/x0Dgu6U0fnkgjJLsurcNYABlPTCgDFQcBwNiZMoFMKAMVBwHA2JkygUwoAxUHAcDYmTKBTCgDFQcBwNiZMoFMKAMVBwHA2JkygUwoAxUHAcDYmTKBf9jIIzyFdPI61Kn2VDm+Fnc/nSmZbzLln2lKybrl3zWr1k/k1xdFX41qI59frP1Bi4u/hhAcOVzEgAAAABJRU5ErkJggg==",
fla:"AeFJREFUaEPtms9LAkEUx99zbS2tzKNeIsR7nYu6RIfokJSHCLp2rgQjSig6JPQXdJRuJfbH1L+QxwqsVMSJtVbcNteZ0d2ZtdnLwvLmzft83w+W3UHw+YU+jx9sACST0d9I84IQ2AMgcbcB9cWlm8hhdp93HxvA63b6ihCS43XIuk5fXQP4/OCGsAG8bKWfvVDeBG0DGBcnxB8Am4RVxUHsOwCcEHIBcEDIB8AIIScAA4S8AJQQcgNQQAgHGFteAdRDzoPMYcQKB9BSKdBm5/pP4h4QwgEgEAAtmYRAPMGVCfEA/bW3WMRKD5aYFQCjgAObqwwMLCEiGI0LmvZ9r9WYXA4tA5OFa6aNq7ls2/73OvM5rTMFYCo1chl4vzwH0mj0roR6Xe4Sqp6dADgB/KBJ2wMKgHIMCZlC3aNS2hJyElABdKnjWgmpJhbdxP82A7XbIjSfHgFaLaocCO+ByGkecGraFiztW6lwgPGdXQjOL/gXAKNRCB8cAU6ELRC+yYARtQERWt9of04xy8lzAKqOc8FoaD3gQmxULhUAlUwuGqkMuCgulWuKDHj7m5Uq6o4RVmKlcqJ7jfAf3SwAiFiYuS8fOwJ4fdSADgAriFCMYjCPd3eWbzejd9iDThF5rL4A39Z5QOOYNXsAAAAASUVORK5CYII=",folder:"AYFJREFUaEPtmbFKw1AUhs9/c8HJBxD0CaQQd4PSuPQBHNRR6EN11w4+gIud1CmCAeng4tKgk1PXNlciVtRK0tt7D/bi6ZqTP+f/voRCAgr8h8D3Jynw1wbFwMoZMIOdTkmmZwxtuiwH0KOCPkX77tYlp+ncuVtoOohHrsvPLgrQWEWUYj/PmhZZ9vhcgclVbJYN++08EF6V0ntoZ0OfuZ+Qfob6LlDlg/Cs1nSCJHvyXYLdgK+FASoUoYv0/vJrZjAF3k2CiijNt4ItUC2uD/Jv0IMyIAV8PZAuOc230PWuUesbhEi7XMf7uWY6oXL8Qjq5qX8GyvzQrNryMxpVCRVf1BcwD0de/4l9q0CrLwV8Q7XKEwNWuBiGxQADVKtIMWCFi2FYDDBAtYoUA1a4GIbFAANUq0gxYIWLYVgMMEC1ihQDVrgYhv+DgeMRkXH6OsMA/iMSBVrn9S93zfCkQ6XprV4JFKTQxfZZ/et1Pno8yfKZlYfr4qliYHFWPJPBG3gDgn2xMeAd79wAAAAASUVORK5CYII=",htm:"BRVJREFUaEPtmnlsVFUUh787bWmLVCugARWRGMpipDN2ugwIVaA1mBS0NiQgKiqlcSWixBgVBCXign9AAMW1gpQQxAWXIKaFEBkpxlY0Umjp1NJaujK0pS20zDPXZ9Nl5s2baWae0+j9azLv3HN/3z3n3HvfIhjkTQxy/bgBFBUVxXZ0iY0oylwFLg8moBDiPLAvQgx53GqdXDOQsdwA7EeLtymKsmggzgbaRyAcpkgxKzk+3uGvD3eAwqJzcubNN08iOirSX39+2Xd2dnGizEFL63kEojrCZJpttU4p8ceJG8DhwiJFOrAlmv3xM2Bbl8tFSamDc80tIKgPDyc9yWIp9tXhvw4ghboUhZNlDs46m0EIp8kk5qQkxP/oC0RIAEihigKl5RU0NjklRGuYScxLTojP14MIGYBuoaccldQ1NAGiI8ykZCVbLV97gwg5ACnWUVnNmdp6hKATk1hkSzDv0oIISQAptrKqhuqaWvnzkgmRnZJk/tATRMgCSLESQIIIIRQEy2xW88b+ECENIMWeqW2g4nQ1iqIgwlhkS7B80hsi5AGk2Nq6Bsr/qJI1UWZLtIwPGkBJDXxsh2NV0NoBXZfUocLDYFgUmMfAstlwVYze4uh+3X5U3dumJln6THpAIlBaCy9+BlVn9YWFmeDOKbBkOowYpm/fbRE0gC35sKNQ3Yj0Wkw0tF9UIzM0ElZlwLQ+CaHtISgAL+yBAyf0ZPdcnzUZclJhUz4cPAEmAU/Ohiyrvo+AA7x9ALbb9QfubfHANMieof6TdwS2FKi/X71HPxIBBTh5Bh76SB5g/ANYORfSb+rpIyFkNGQ65S31XhMBBVjwDpyWxxU/27ZsGDeyb6fn96jplGGGZ+cYUAN/z77HTd07zfUjYMdSd5s/nbBwq7oI7H5Ue4kNWARe3gv7foOoCIgdqgpytkFHpzZARBi8Ph8Sb/Bss/JzyD8Oy++AzFs82wQMYMUusJ+CVfMgbbI62MUueGon/HLafXC50qy5G26boA24/3dY/QXYboQ35gcZQIa7shHycmDM8J7BKpvgwQ/gQr9I3Doe1mV5Ty9ZT7KutNJM9g5YBNLXQ9tF2P8MREf0FSaFHK2AguNQVKlee+R2uDfFO0B7J6S9CUOHwHdPBzkC3gC6h77kgsxN0NgKqRPglUx5v67d5O6ctt4gAK0U6i9v+U4o/Ocpz9gRMHG0mnLXXgnxY+DqXgc6Q1PIUxF7mtvcw/DuQc+zLgQkjoOVGepKZmgR7/kZ3toHMyfBmru008KlwOYC2HlE2+a64ZD7MKz9ysBltL4FsjbLJx/qxnRNrPcClbVQ16xtc/9U2HHEwI1MSnntW9hbrBbo2kzvAIvfh7I6bZvhl0HTeQOPElKKXF0WbIW2C/DYTFiQrC1QD0D2NPwwJwf9oRSe+7RnrdeC0AOQqbjO6ON093zv/gk2fC+fbarpJKPRvyb0AOaZYYWXU2j3WAHbifsni4zE6r1qOsmb9xlxMD0OJo6CkTGQkwvl9Z5TbPFUWJLqvYaCDtBdE+8dgm+OgdyF9Zo887w0F+JG6Vn2XA9aBHpLkEvsoVKwl0G1ExpaoKNLvfeNiQTzWFiYDJNG+y7ckAj4L8f/HoZEwH9Zvvf4H8D3uQqO5X8nAnYDX7P6Gqv2jgsU/3pc3hQ125IsV/TuFxIvun0FEUJstyWa7/MKYOSnBj4Lh2aE+DIqXHnCYrE4vQL46jRU7Ab91yp/ASCmiE8lpkUFAAAAAElFTkSuQmCC",idn:"AqFJREFUaEPtmk1oE0EYht+ZTbJJdiWxqbYNBhUsOYgXkVp78KAHKRTxr/UmxYJ6MTfRYpWiB/UkBE9CFQQPFi+CHgUPvQnqSfCgPfjT+gMxmjZt8zOyiVm7Lqaz2yQ7W3eOyzeT93m/b7+Z7C6BywdxuX6YANj4ZCD7fvYKAU4whq5mA8o93bdDZ/pP2/0dE8D3kfR1MJy3u6DVeYG920EWlmxDmACyI+lPrXC+BqoBaMMuhDkDJ9PMqouria8B2IUQCsAOhHAAViGEBLACISwAL4TQADwQjgP4e5MgAV/dRlavxToOIG3tgJRoX7ET/wvCcQAQAmnLRtCOqK1MOA+wovfGgOidlEGzB2DRwFWHexmoWaheOm5wM3ftIVAscTusjA2BkD8VnLv6gGtuwzLgAXgZqFac7Tb6f5QQJfDvTkLa1gmpqw2sUET56w8UX7yFfGSP2DcxiSoIHu2DFG/j6i7CdaHQ8D5IiQ1c4rUgoQB8OzYjeKhXF88YQ2HqNQqvpsF+5kFj6xA6dUDcEvrb/cLLd1h8/NyQDeXiIAil+jWhMqCMHgPxSbq4+btPUf7wzSUAPgp1dNAgdu7mI7DcgksACKCOGc9Jc7eegGVyLgEAEE4NgEYUXXB+cgqlNx/dAyD374R/V7cuuDSTQf7+MyC/VLlGN8UQGt4vbhciahDhswOGG7myC3/JgoRl0PWqaX8Qqgtp6rS9QD7YY2iVNdVsfrECsnwIB1AtlXYE+pKg8Ri0pw/l2QxK05+h7QvKucPOlhD3GaHBgQ37R9ZgXdzLeQDcVjUp0MtAk4zlXnbtZ6DVr1m5rdeeQBDMRCZS8eVzHH/RbQUABDeiE6kLdQFa/akBD4DmPAPuRRKdl8n4UPVE+HusvY89eBwRKeYX8tzFQGW8wDsAAAAASUVORK5CYII=",image:"AwJJREFUaEPtmj9IG2EYxp/vDLlIU/8rGSqIYLXSpqY2QR3qIg5tKYiDS+oiOkQqCgm4CIoIYgYhDoJrXV2KdnLq0IhRL7GiouJU2lKoMYliksa7koDSePnLfWdykJsC97zfPb/3eb9A7guBwi+icP8oAOQ6QVECHMeVBSNkAYLwTgBKcm0w+nwC+EHIJ41K+GAwGM7/9yQCcLrcHwVBMOeD8bseCCHL7caW96kBNjlftPMtz56gWMPmBcdVMAT3t4NYEu0mQ2lKgK+bnBAVtBtb8sL8jQmnyx372GEyxE2NaIQKADLlVkhApsZmvGwhgYxbJZMwLxLgf68hcjgJ4eIQRNsEVdMkmJo3GSHnHCBqPrzxVmRW3baaEUTOAcJfjODPt0QATNlLqF+50qaQc4DQ54cQIhcio0SlBfs6kP8Aik9A8XsgOiOK/hZKO+RpBDnfxHkPcC1co4gUSfWZtF7WBE4vTzHGjaFcXQ77czuq2WrqILICDG8PY8+3FzNd96AOC60LKFHRfR8gG8DazzXMHczFdby5tBnzhnloGA21JGQB8Ef8MDvN8P31iYyaKk2Y1c9S2xeyANgP7Vj9sZq0y126Lkw0TyS8H+bD2PJuQV+qh1alTZsUdYB9/z4s2xYIQuwlRtKrt7YXIw0jcfeDfBA2tw2757vQFeuw2LqICnVFynWoAvDgMeQawnHgOG3nooKB+gH01/XHtCE+BJvHBo/Xc1vbWNIIxwtHyj1DFWDl+wocR46MzN+IrE1WdOu6Me4Zx453R1TbUdWBGf0MGDAJ16UGcBY+g3nDjMvIZVYADGFQr63HSeAkaV3Pox6MPh6VF2B6fxrrv9azMp+N2NJgQV9tn6iESgKcl8Mol7hD2ZhMpSWEYOrpFDqrO+NkVAAGXYM4ChzR8pp0HbaIxXLbMmrYmlsNFQCrxwrXn/S/X6USVrKVWDIuoUpdRRdAqjEp9VQSkGJAam0BQGoHpdZnnIBT6UdMij/kU/wxq9RZve/6wl8N7rvjd5+n+AT+AZm/3UDFmhoAAAAAAElFTkSuQmCC",iso:"B+5JREFUaEPtWV1sXEcVPjP3Z+/aa3vtZO31JrihcWhQo0amQFncBopUyY5ror4gUSkSvPAAkUjWaZWWl77QRPVPQALEG5UigcQDVXB+LPrQ1om7DVUJgZAm1LSu699s7Gy8u9n1vfODzo29WXt/7r0bJ1KljmQ/7J2Zc7453zlzzhkCn/NBPuf6wxcAVi04+Ob5g8RSfgYEwgDgk1KqhNw5HyklEEIYACyDhDmp8d/2PfPkrzbC+vdkAVtprrwkJYRASm97ESIJgYRU+NF7AeNN6MqR/frN9/dxk50ACgHpVfF1x04IkSAgrejq/p8/842TXq3iCcAfLl4M0gy5vJjORoTweOIOmtlAAGYaw8auH3d0JN0CcQ3g92f/ESWGGE1nTRU3VygBLlDmBg9CmI/59hzo/Vrczc6uAPzmbxdiQMjAssUIJQTaW5qgub4W3hufAiaEGzle50hKyOFD3dEhp4WOAFB5LuUA44JoigKPtTVDY63f3ncumYbLU9edZFT1HSlFABxBVASAtGEqG8OTr/Fp0PFQGPy6tkahf03Ow/WlTFVKulgkfdzorESnsgDQYc0kTyDn8eS/uT1SpDwqYDEO8fEpMBl3oU8VUwhhTWEjVM6xywJ4ffSf0wvp2xHkfMe2cJ42pVRILGXg0uR8Fdq5W0IImY51R7eWml0SAMZ5wdkbGCq/Et4EbZsbHCVdmUrATDLlOK+aCegPiqo+V+qeKAlg6HR8SRJZh6Ey2v4lMHQ7clYcnAubSjkLM4aNH0SSVKwnWr9+5yIAdnrAlKHVG1alFHZGNkM4GHDU6mY6Cx9MzDrOq2YCWkGqPLY+7SgCMDQSn5dCNq8XgnH/q5HNoKlKRfmXJmbgk9kEMNMCLu44tkIVUHUN/H4/KKqzNcsJIJRcj3VFWwq/F1vgbFyUS8x0VbFBhOpri2QIIeHiR5/C+PQclLufUZjhr4GaQABWElVvxiBE9nVHaVkAx8/GY0LKQaddI8E6eKR1EyjKnb1Q+XcuXYX5m7ecltrfNV2H+oZgVSAoIX2FN/QaCwyeiY8DyO1utDA0FR7dEoLGgB8+uDYBH03PuVmWn+P310BtnbNfFW9K/te3N9q++vsaAENn4ykppaddQwEDrn48uZY2BKaopC9KRX8bBRFuflcQ8RpIyMdyFBxsavLsE4SQdKw7WlcOgCmlXJsrOJxrOpWCXDZ7dxaBKZ/f2P3KD7oWC5e+8ueRpuVs7lIhCMPvh0BdXhdXFiSEWLHuqF4SwOCZdzG1dEzwCiUlFxaB8buxnwJ9/pc/+v6fSmnzi9f/+kMB4o+r31RFheCmJleKF0ySfXu/nXfk9RQSXiushUTCrnnzJ6IYkVf3d5W8DF4+MdIqeW4mP5cQ2BQKeQKA90GsIBKtc2LvFniQAFaaA+UtMHhmTGADAUlk/3MxHhSFJIYJCRh6Zd/eztIUGjg9ZjsxtkNWWyJOGB6UE+Pp4x8lxOrr6SztxAOnxlICZACVxzTazeCMQXJxsaowuvPhNkikc27EgBDClkGBpA8/21k6jPafGhsXUmxH1RWlcs5TKDWTSkM2e9uVIquTdmwJw+OPbANMAP8znXDMYjlndoajEDp+uLdzR8kw2j9y/qAw5XH8qKiKSy/AzhvA0q0kWKbpCkRLYwN8Z/dOoPSOlTEVvzp7A2aT6ZLr8eQ544B+oOn0UF/X3a5eEU+ODZ8TUgiiUhWo4o5GKBVB3E6nIZe9XTGZa98Sho4dD+WVL9QYK7sPZ24UlaeCS2CCAaFUHul9qnwyh5u9Nnx+nnHejH6ga95TX/SJbDZbMp3+cmsIdm+LVLQS1tgIorBRYDGkj0RWXH+x58nK6XT/yOhBtiztgkZTVaB0DWBXFKk06fFtrXYC6DSwZXPVtgYDBABApGaQ2Atde9Y0hUty5NjJc0uMszpU3meXk+6p5KQYZrHR9q35VLzS/JxpwdtXPgHGBSiUpo7s2+NcUuKGQyPv7ctmc2/YVtBUUD1EJCcA+L01GIBHtxYVfUVLP55fhMufzSELpN8wnot1fauo+Vv2aI+eHJ1mnEWQe36fb8OptLutpWRlt4piIZWB+LVJwNSgpbF++iff+7r7tgpugo2tmYlbCS64/VBhIAiXl5sbK2B5ilQqVWNnlk0YvTIBpmVBQ8DP6lv83htbqMTx4QvRtJUZE0IQSigYxsaCwEbBY21rggqg8vFrn0I6Z2InUNZovs4D3U+U7VQ7emf/8LlYdtkaEBJBEBuEsoGRadfW5nzL5kYqA3//72d25FEURdb69MOHejordqgdAaAljg2fi5mmOcC5sHM8pJNq39SulldkFPadnmjfAjMLS/DvyVk73vt9utRV1VF53Ni1Bsf/ciGakplRzrl9u9mU8uk2kHsZjHGwLMs+dTydhlqD6ULfc6C3PG0K5bkGYPvEWxeDmZvJy8uWFcGSAU8LAeiqBqqmunZyjCyWhReUBQgAh6oosjkYmMmpvl2Hnr4PT0yFqPtPj+3L5ZZPmBYLANx9K8M+Eda56CuEknzotVNhIe2QiPUzJm+rA0tETVXThuHb/0JP5/195FtPlVdPvXWQm/Ilk/GQ5LyyNdF5MONbCcWYmOmaklA0cvTlZ5+u+s3YE4UqcR0d3bLYT6WULVIIHxPoK2TlkRtApQqSfJlSOq9p6u+O9D7l+P7lxrc2DIAbYfdjzhcA7sepetnz/5JVcV4hOdOnAAAAAElFTkSuQmCC",pdf:"BWJJREFUaEPtmntsFFUUxr97Z7ozs7RAVeoTFRMJArodu30sKaBIQNKIj0giCSQ+QqKtWCgYJIAYUUSDChQbMBANtDFCTBAlCpIiiBRLpEURKSALC6UPWti+9tGdmWvu1CaULWV3u122kflrN3vPme93zrmPM7ME/fwi/Vw/ggAqKioG+zRSCMamMmBgXwISQtoA7Ewgltft9pE1kdwrCKDsUOVmxtiMSJxFakNAnFQiT2TabM5wfQQDlFc08cinPvwQFFkK119Y4wMBDVWnnGhpbQMBqU6gdKLd/sjxcJwEARwor2DcgSM9NRw/EY81DAPHTzrR1NwCEFwURUzKUNXKUB3ecAAu1GAMJ045cdndDBDippRMyUqzHQwFIi4AuFDGgJOnz6DxkptDtAqUPJ2ZZiu9HkTcAHQK/cfpQn3DJQDEJ1D2fKZd3dETRNwBcLFOVzVq6y6CEARAyQxHWuqWa0HEJQAX6zpfg+qaOv5RpyCzsjJSv+gOIm4BuFgOwEEIIQwE+Q57auHVEHENwMXW1jXgzLlqMMZABMxwpKklV0L0GQBzX4R++GeAUohpE4Ck5OstKNf8va6+AafPnudz4pQjXX2wzwGMo2XwLX8ZzOcx70UGDIS8ZBPocDViiLJDHXvbmAy1S9CjngHWWANv3mNg7T6Ijz4OpgWg/7HfhLBuPARY5IggYgag7SyGf/0iiOkTIS3caIr1vf0C9KNlkBesh5D5ZJwDlG6Bf+2bEEZmQH5vawfAgqnQTx6BXFAIIXtqfAPA0wxP7niw5kuQclcAum5mhCanQPlsLyBb4xyA7zwHdsC3MheQB5gdE/O19ap8OHHM5kBneP0f50H79XvzqzgmB9L8oogi32kUcwB2rgqeOZPNY6aytBjUNrZ/AVyZAeGB0ZA/+s7c1CK9YpoB41g5vIungUgKSFIyjIYLkF55B2LOS5Hqj+EcYAy++TnQnX/BMn0e6LBR5q5MrElQCktBklMigohZBrTdX8Ff9BZoyj1Q1pQCFgn+FbOgle+CmP0UpIK1cQzgaYEnbzxYUyPk+UUQxuSYYlnDBXhnTwDze6EsLQG1ZYcNEZMMtH+5DIHtGyCMyoK87OsuIgPb1qF90wegdw2DsmoXIFrCguhzAHbhNLxzJgGGDnnlDtD7R3YVqGvwzpsCw3UClukFSJiWfwMBWt3Qyn8C2poAKpjLY2BXCYyzVR3HZzGhe3G6ZjYmEBJgee41kMTBvMAAaxKEtAkgg4dcEypqGWC1Z+Fd+KxZ59G8iJII+f2twZn77yZRA+g8WQoj7B0NCjOg/b4HvIRE21hISzb1yOVfmQvt4A+gKUMhZE0GCIVx5hj0I/tB77gXStEv3dpHB6DlMjwvqmZ7aN1QDvBSaXXD82o2mKcFyvJvQEfYewRgrip45042J7FStBfk1jvN44Y3bxyMWhes6/aDpAwN8hEVANZYC8+sTPB0K2v3mJtS++eLEfhxs9n3Sou6ffIRJMa/Kh/avm0Qxz0Dac5qgAcmfyKYuwHW1btBhnZpe037qABwR/53Z0Kr3NdxTBh0G4z6cyAWGcqH34LcNyKkacHqXPAWTAHztoLecruZPd4/C8NVyCu29WEJcdftPvgL50H/bafZ7/JGRZq7BnS0IyTxnYOME4fh/zQfRp3LXLX4KiS98QmgJPYxQKf7dp+5EpEhd4cl/OrB7HI9SOIgIKHndxFRK6Feqe2F8U2AXgQvKqY3MxCVMPbCyf8nA2UxfM0aakK8Pj8q//ybP2NqdmSog660i4sX3aGCEEKKHempM3sEiOVfDUIWDjSDkO2yyGarquruESBUp/Eyrt//W+Vf3kLTT0Tqf/gAAAAASUVORK5CYII=",ppt:"AzNJREFUaEPtml9IU1Ecx7+/s81t5sy07KUXg6CC3K6b0/UHgv6Q/bOHICJ9CSKC/lEU9Oe93noQIiKRqF6CCIKCCOwtQ6EJBWlaU3PN6TKdzj9s7sRRWurcn3uZ8w7uebrc+zvf+/38fufcc+BcQo43ynH/iANwu91FUxFqAOdHOVC4nIBEFALw1kB55x2OrT4l74oDaGlrf8I5r1MiprQPgTzMSHuqrFaPXI14gFb3qMi8bdsWmE1GuXqy4sPhCDq7PRgbD4FAXgNjex2O8g45InEAH1rdXAi4Km1ydBTHRqNRdHR5MBocAwhDej32OyWpPV3BFQcQRqOc41u3B39GggDRCGNUU223fkwHQhUAwijnQNePHvweHhEQ4zpGtVV2a3MqCNUA/DP63dOHwcAwAJrSMX68yiG9TgahOgBh1tPnxYB/CEQIg1Gdy257nghClQDCbF+/D16fX1zOMNCZaqetaSkI1QIIswJAgBARB+GSy2FrWAyhagBhdsAfQM9PLzjnIB3qXHbp2XwI1QMIs/7BAH709os50e2qlDblHIAw3NI2t7Ztd0oLkp4TFdAAUq2Gvrq8hCHEdCCzBbrSjTBJB5G/+zRY8YZUknHPl3UIJQOI++wxHSwn72BVzWVZEFkFIMZmNzfi05eoFV95AWPFkbQhsgpQdLYR5l31sxAz/m5MvG9E6M29BUB5m3ei5HbKvVoMcGUA5uV3+O4BTH/5b5jlF2L9w4DKKzDPXvDxRYTePYjd0RWuQ+l9b44AhKcxdMuByK/OmGFj+T4UX0+6U14Al9UhZDl2E0ZbDfhkEJFALyaaHyHs+bTAUNG5Jph3nFJnBVK5MkmHsObqy1RhK1eBRM4oz4SC2hsoOHwN0OnVC6AvLQOzrJ0zaDCCFZTAUFYBs+vE7IqspGV1DsTWASVOE/TRAJIlc/FeSKvAEtnShlAG56MiqWWtgCJHMjtpADITlvFwrQIZT6lMQa0CMhOW8XCtAhlPqUzBtCvQksVj1nQZJqem0f75qziVD7qc0ur5/VRx0J0uCBE9dVXa6pMCZPNXg7SNA0EQvTLp+QVJkkaSAqQrqpa4nP9b5S/Nb+pARqUjEQAAAABJRU5ErkJggg==",psd:"A7xJREFUaEPtmllIVFEYx//3zuZMLndK3JqKXIIMUsiiRaUXod2eLAntpYyIgpDQpyLxQV8DiRYIA0mKSMqCCntKK8tMM8vKXGdGK8dcZnNm7o173WZcZu7s1/I8nvude77f953z/85dCCzxRixx/zEPIPnuJ+nXLlsJzSAfYGL9DZizkbpenb3ulKfzzAMQl7eW0QxT5OkN3R13MmUlRiZojyHmAZBlrZpARH4alAVgm6cQCwC0MO5G0Rv7aQBPIQQF4AmE4ADchRAkgDsQggXgCyFoAD4QQQc4lkxBISGdCpkziQ06wLZYOVKi5C6VeDGIoAOQBJAWI0eSUuZRJoIO4DL0cwzo4hQHn5cB3I2gt/bLGfA2gt6O9zoDjccTF/XBYmPwx0yj/bcJNd9G0NBvgK+Ptn4FmEvWoDagsE4Dmw8pfA7weciMCRsDuZhAAiWDaE5Rrf0+hpL6QW9Xzsx4nwMcqelF18gEN0GolETZ7liw1dW+HbjXjZ8Gq08g/ArAephASXEne62Ds+eea/BaY+D6ImQkjm6kkKCUIS5UjGGTDeoxC+r7DWhQ610uN78DiEmgIc9xo59+qkbTgBHpqhUoyYjmMrVQu9U6jKvNQ04z5XeAJKUUVYccM5BV/YM751QdXOvgPMMAhN1ZoPLjMCreBxEgSiFGaWYMUqNDZqL4VmvEmWdq5G2icDYtkuvXGW0ofKHBlyEzYkIl3GGuIHUVnnSOBh6g7ZeJUyFliAhrwqVgl9B0Y/tzH/aib9SCS+nR2J8Qxl0a1FuRU9MDo3VWXxUSAmvCpOjQmQO7hBabTW+hceGFFu8GjJzJ+a2RyE2mZswNFhqNWiM+DBpR369Hz6iFl0r5fA/Yz2qjwcnlG40BN1t0DtKZEhWCG3tVizr5uHMMpfWDgVehvEd96J6qA2YXJbcgdSVOTL2JE6wKuVoHiUopDidFYEuMHPGU1EGFtONWZN/vDuwesK/EzmbepVLgldoA2u5cRMlEuJwRjR2rFdxQk5VBZlWnMAGuZMVxSnWtWcdV3GkQtrDtiZ9UJ1ZW82v7hAuwPW420gN6K0IlJCIVohmHK5qGUNk2LHyAhTx82a9HYZ3W5fODz2WU7x4Il5HYFx+OnSoFVGESsFVbZ7Khd9SCBx0jqOsZd7X/ueteA/CaxY9GywB+DC6vWy9ngFeY/Gj0P2QgsJ9Z3UsWoaWLN8fZjwn6h253AEiCKLcWbS52ChDoXw34ARBaksDtDetFF9tzNk2+w5lq/97PHvwiIhyrv7BOOE995O/qAAAAAElFTkSuQmCC",swf:"BAVJREFUaEPtmmtsU2UYx//P29u6jcEkYswSs0QxApH1sK6jqImJeBkaiAmBEKeEMDCRoX7hEsVLFI2XL8apHxQ1KoRkiTGSAJIQAkGZ2RLbQAhzF1onzeiuXS/r1st5zXsqCWyjnNbT09PI+6lJn/P093ue95y35z2HUOKDSpwfswQ8Hs+CqRS1gfO1HKgqpCARxQCcsJC11elcOpjPb80S6Ojy/sA5b84nWb7HEMjHbPRYY12dL9ccswU6PROi8o4Hl8BeZss1X07xyWQKf/b5EInGQKCAhbHVTufy7lySzBI41+nhIoG7wZFLnrxjZVlGd68PE+EIQBg2m/GES5K8ahMWXUCAypyjp8+H8VAYIAoxRk0r6+t+VyNhCAEByjnQe9mP0bGQkIiaGK1rrK87dSsJwwhcA+33DWBoZAwATZkYX9/olI5mkzCcgID1DQRwNTgMIiTBqNld72i/mYQhBQTswJVBBAaD4mOagbatdDm+nUvCsAICVggIESLiILzidjraZkoYWkDAXg2OwP93AJxzkAnN7nrp0PUShhcQsMGhEVz+64o4J/rcDdLiogqku71IB/yQR4fA7rgT1tXP3upKqXzf0ZVZ21a5pBuKrk8HkgnED32O6WOHIQ/d+J+tct+nqiSKJiAH/Ii8vhVpf8+clTa0AJ8YR/iltcqUuTbYwrtgWfEQ2MJFMN23VFX1izaFoq9tQeLcSYWdyitQsfMdWJs2qJrzM4N0n0IpbwfCr2ZgiTFUfvAdLK5H84IvSgeib2xH4uxxBdj29CZU7Poob3j9BeKTGF+3HDwxrUAv+P402D33lo5A8tcTiOxrUYDNi5eh6qtf/hO87h2YbHsLUz9+o0Dbm1thb9lTWgLh7WuQ6rlwU2iyWFG28UXYW3arFtPvKhSPYfyZZeDpdFY4cVmtPqb+/l03gWTXGUR2/bsrQ5S5V5wxDN2B+IEPET/4mYJctn4rylvfVj1NsgXq1oHwtqeQ6r2osMzbfwCWh58sHQF5oB+hFzKrLVltqP75PGAvLx2B2Me7MX30sAJsfaQJle9+qQm8LutAsvM0ons3g8uyAl31STvMDndpCCSOtyPW9ib4pNhsBqyrHkfl+5mFTKuh6UmcOPkT0v2XII8EkfzjN8ijyvaHMkw1taj64ghofrVW7EoezQQEfHT/y3PCmWrvx7z3vgarqdUUvuACbNHdsK3ZBPtzOwCLVXN4TQVEMtEFeWw4c1tYUwvTA4XfitdsChWkvCqS3hZQUaSChtzuQEHLqyL5/6cDHTo+ZlVReCUkPjUN74VL4ql82O2S5l9/nCEedKsVIaKD7gbH81kF9HzVQDU4EAbRkTIz3ylJUiirgNqkRokr+bdV/gHi4zRPUedPZQAAAABJRU5ErkJggg==",synodoc:"BEtJREFUaEPtmm1MU1cYx//nXlrAvowXi7YomxpRcEQJcxjdss0wh2QhqBuJLyFxmuiyGf1AoN0LU5bonMliTPwkWybxk/ODiYVONo0STQwYhouisjmDEKqsA8tLLa1wTQ9Qi723vT3c6hrpt+ac5/88v+fltKe3BDH+IjEeP/wA2XtvqPvb7NUEo2UCYGQBI4BdAFerzzZWte1d4mHRiNTGDzCn9PfvgNHKSAXE93MHu04WmJXRCq3iB5hb2tDNmvlnXahUKix+PS9s/ATEBSJcVHPqXacrEu6ENRDZEFCBBkFMYN1bs1GQZ0BWhhZz0hLR0zeMf+wu/Fh/Dxev/SfpMyd3hex4CCEODqTAatZek200vjEkwPc7srFxdbqk5rG6DlTXtouuRwJABQh6eY5/31qhaYkEQhIgL/MVnP72Tap1s2OAZrzH6cHCdA0+L3kNyTo1Xduyv0W0EhED+BgIHvJx/Joz5ZpmuRCSAJ8Wv4ovNmdSnXVVTbh62+nXfC93JmrNufT9id+6YKm5GeSPBWC8Es44Eld4pnLGFTkQkgC+3j+yK4dqNFztwb7j7bjX88iv+c7SVLjcI3D0e3DX7lIOYKwSAxxQZDXrL4WDkARI0alw/oeVSNWPtYrvdbtzkLbLhVYHLl/vxajo2I/tZa7AhDOCIV4gH1otuguhIEIO8YqsZBzdk4O0pPggjW6HG7uPXseVtj5R/SkD0LkmLo4jxdZK7TkpiLDHqDaRR8kqI4ry05CfnQx1HOfXcntGsO1QKxr/7FW0hSaLETdHSEmdWXtWDCIsQKBRgoqjENuLMvDuspl06Y+/nSj+simKAHQohjlwG+rMmrpnHUkCHP5sCeabNHA89OCTQ61BATYeXol5Rg0eDY8gs+x8dAHG2skj8MJqW4X+cqAzSYCa8qX4YHkaBEFAydfNaPnr6TE6I57HpSOrYEiKx4O+YbyxszHqAD4HhKCp3qzPlwVQuNyAY+XL6F7nkBc//9pJTyHfqbSpIB1ZGTq6dvxsJ7766dZzAQAhXpt5/BN03GPIGajeughbCzMkT7H2rkGsr2qGc+jx8wEAYLPoJ91hwg7x2zkpdGjnmTQwpSbQnr9734WG5n9RU98Bt2c0aseomLAkwIv4Oh3qA0pqLUQFlLvQGGaZMNsk3XosgU/YSAJMXClVKr7S6/Uy+fBdZJJSDJhlnAtConPdlgSYiHjtgf4Q33CYuBQ1mgZQNJ0MYi9vBb75KJEhX+wm+049vTwFqjBXIOYB2HOprCVzBZQNg11tGoA9d8pYMlcg5oc45gGUaYCpqzC30NRdK6MwDaBMHtlVmCsQ80Mc8wDsRVfWkrmFlA2DXe1lABjoBgSmB93seZVrSew2i84UuDvot4+1BwYVfOAtNzC5+7iDNot20gP0IICPTwrqwTtD1YBQ9v+pBLEDpFa7QFP1SymZ9BeG6Pz6JDehCuyLeYAnUmemQPAymwUAAAAASUVORK5CYII=",synosheet:"BHZJREFUaEPtmX9sU1UUx7/3tStjYzC2ldhmAVGGrIpuUaBRJIhgGIN2xS1GBIIkGDWOkPhjk2yjthi3xPgHM2aCIA74R0wkxEYxMW7JlqEL0nW6wBYgsLhmo8FOGNs6s2v6amu3vrv3+voeOuj7rz3nfO/53HPPfe++RzDNLzLN80cEwGQv0/lHqAME2ymFQQ4YIfCCojEzldR02U8G5GjEGxMBMFaW1lKgIl4BIX8C1PXVflWphJaYxr8A75b2yZ35yYNwOi2yCvPExgYh5DYomlNmpJSf21B9STRAwCECYKgspUICmwuexrolj8NkWIDcuXoM3PTj8vU+HGp1oamngzlmzop8yfkQQnwajXbt+U01bEGG2pQAH25+FVuWPctM5GDLN7C7vhC0xwMQEiA3iIZb57HYf5FMHowKO0+uwBPzF+P0a+/z5i7vVXzW6sLALT/y9LkoX21DVnoGb9tyZL9gJeIHQHBJ+TmOPue2ONulQjABXl9lRVXRVl7H2lCF9qsXI5prHirE8R17+d/HfvoeFacOxYwnB4CvAzAIjWa9x2I/KwWCCRBc+x+/sJvXONPVjn2uo7h2YyCiuTrvMdwOjMI3NIjLPq9iAKHVhJscx23osLzXIgbBBMhKn43mPR8he9aciMbF/l40dbvxY7cbLZd+xTgdV6SJhUQIwRBHNRvdNnvTVBBTNrF5oQkNL+7BvIy5MRq/+33Y/WU92q50KdTEsTL/bLMWj83xAwtCdBudNWMmbAUrUfyIGeb786HTpkS0RsYCePlYHZp7PMouoWg1QkY4oKSjxHFGsFLhP1n3geigVK0O5oX52LVyI55ZXMCbzvf2oPiTUENHX3KbWHCmCUY1hDzvtjpck+3MChwoewMP6o24fmsQOxrrYnRb3jyAB3IMfCMv2hfarVQD4IVJQMPRNW6rs3VCgVgVOLLtHaw3LQOlFJaGKpy71h2JS9Olou2teugzMtH/5x8o/OCVOwAQ3JzIzx6bY4UkgCLTchze9jbvOzg8hM/bvsWF/l5kp8/G1uVrkX/fAt52tO077D19+A4BYMxjc+okAQSd9m/aiZ1PFgkuy+Cf3f29sH5azQOqv4RCI3TanBPOMKK70KpFj2LXU8X8ejdm5mB4bBRXfF7+5hZ8oBseE37sV7SJo2aHCWD8Dx6nmaWdwsAGUPBAk2bIRtr8eXLyE41hAoSPlESnrRgP/CUqJOQQPMikZs/BzFw9CKfOcZsJEE5o6dfVggcbWUQqBCUBVJjUuCTv3QrUm1+Ka6YSdS4/e0JQQnYF7hoA1syEAVl2qRUR00m4AkkAkVIkK8C6E981TSy1GRP1U20bTTZxsokZR0qxx2mx7U3MLrUnxHQSvpFJTSRRP9WaONHEpMYrDiB1YLX9ZC8htROTqn9PAPQB8j50S53FBPy8nTanMTo+5t3H0lM1taBUkQ/eCSQqHEpIXWeJY8IH9BiAst/sugs94w5Quv1/VAkvCGlcksfVnHzYPuFdpjpvnxSferbgtAf4GzoR8kAQ+tysAAAAAElFTkSuQmCC",synoslide:"BPxJREFUaEPtml1sVEUUx3/TbrelSwv0g1LaYtG2UKKAD2C0pn5EaoN8SBBCYLsxIZJGJQomIjyQhgdTntRgEKLGpH0xkhipQiyJXwQES6JChEpblNLapVhatGy73W17zd3tbrfszt67y71UjPepzcz8z/nNmTlz5t4V3OWPuMv9Jwig1GC96GGPAg5FITceMCFwCqibZ2W3qMETj0asY4IAv+6idlRhR6wCkfonCPbOf5M3jNDS0ggCNO+iK96Zv9VIkgWKirVM+9oHEHxHElvFBi7pGnFLpyDAhZ0o4QKC9MWbSJu/guRZC0maUchwvxNPTwu9J9/G1dootVlaGoM7gh7gKVHF2RhG+bpGBchd8wHTl2yWal4/8RbXjm6P2B4TgF+hF8EyUcWPsUBIAabMeYTC6pM+LbfzHL3fv8Nw/1WSZ5aS+fhOLKmZvrYrH1VGjEQcAKrcDRKoEHbO6IWQAmSUv05O5V6fzuWDjzLY7odRH1vJcuY8f8T3d98PB7l6uDrMXpwA6pr4C0GlsHNaD4QUIH2xnbz19T6N/uYGur/YhrfvtzFNga24glGPi5Gb1/BcbzEOwK/Uj4XlYiMntCCkAIm2bO595TyWqdlBjaHu89xsbcTV8iWuS1+DMiLVjzsCAUWBC1ghqvg2GkTUTZw69zHyNnyMJW1WmIb3RgddhxwM/B5Z/7YB/BYHSGCVsPOVDEIjjUJCcjrpizaSfv9aUgvLERZrUGvU66azfjWutmNGL6FQPTeJPCs2ETFnawKEKgnLFFLnlpNRto2pJU/7mgY7mrj83kNmAqjaQwjWiir8mSPkkQLMXleHNWsewze76axfFebgfdtbsGYVM+oZ4GKNzWwANTt5EDwp7Iynw2gHWb79M9IWrEZRFNoPlDHYcSropLBOpei1NixpOXj/dtJWO9t8AL+FJuFgQrilEUhbsIZ8+6e+USODN+g79S7u7l+w2LKZvnQLKbMe8LX1nt5Pd8NLdwrAKxyMb0KtUiJn5T4yHn5ZmsWGui/4DrlRd9+dAkA4xssf1ajmJrYVLSOj7FWsWSVYphWgeAfw9LTS33zYV9Cp/0d6DEqjYdJSgEkqp6XRlTVIAYy80GRlQvbMmH3TNUAKELhSJiaywzusSyusk3qRmTYNstXqw6TbthQg4I1SF+liEx+QGaP+B4h7VssPgftP6PsZuhrB1R6X1ORF4InPxx1WFPjjKLR9CIo3JhDzAWz3QG4FZCyGlBw4/pzfwVCAgMt95+BsTUwQ5gGIJCjaDHnLQYSkoG9WygHUls4j0HpAdxTMAVCdX1QDMxaGO6IFoC6nM1t17wlzAIqrIf+ZyLOoBaCO6miAtvd1RcF4AHXNL9k3cdmEuqIHwHUFmsIr2khExgMUb4H8sXUeyaIegJGh8c2uEQfjAZbuB1uB3GwAQNcC0e5kPIB6QCWm/IcBok3qiBuOr9Oe9pAexkdAawlFc8/VAU0vTjJA0QtQEP7WQpdXMaTPgJ7xEdBKozKSGA8w8wBU5WgHmQwgxhLCXIBopUQkgDiKOHMBVHVZMRcKcBtltPkAAQvBcvpBSBl7Na9eZHp/Aucx3UWbbOUZv4l1pRvjOmkD1NNFnB+6jXNToqR+SK9iwovYsJcfSj21GPTB23AgwV5RNfEDejjAJ1gZYg/g+NdEQuAE6khmt1g/8ScMJr1+MnzupYJ3PcA/M3/KQPEWTXcAAAAASUVORK5CYII=",ttf:"BKdJREFUaEPtml9MW1Ucx7/ntpQh6BjZQraxDdhGQa20tkC7hy3GjagzOth0WezEMLdkZsbEJzXxyeiDb8sS3TTI1JEYWOZcnGyJW4xuQ8GkZVNpKaWlo+kKCKWUlELpNecUIx2j996uLSXuPp32nvP7fT/nd/78zmkJlvlDlrl+LAAwmUz5U2FyAjz/Ag88kkpAQsgkgMtZRHFMp3vUk4ivBQAdXeaveZ43JmIs0TYExMFlk6drKisdUm0sBOg0jdOeV6sqkLMiW6o9SfVnZsKw9jkwEZgEAXFncdxOne4JixQjCwBudJp4asBQpZZiJ+G6kUgEFpsD4/4JgGBYLkdttUZjFmtwyQGo0AjPo7fPgTGfHyDEx3HkWb228lcxEBkBQIXyPGDrd+LvUR+FCMg48mKNtvKqEETGAPwr1O5wYWhkFACZknH8vhqd5mI8iIwDoGIdLjfueIdBCGbAEaNBq25dDCIjAahY16AHbo+XFmc5kMP6anXzvSAyFoCKpQAUhBDCg+Atg0594m6IjAagYu94R+C87QbP8yAyGA1aTct8iJQCtFnGEeGB/RUrhRaTuO+9QyPoHxikc6LPUKXZmhaA07fGcOiH28zXyWeKcLiy4L4gOrqie9u2ak1Mp6ckAnQrr/jcCttoiDktyVeg90g5uPvIfdMK8J3Nj/pzzpgeb92zCXuViQ+ltALsaLHj2iDNlP979Otzcd24OeFhlDaALk8Q+q9sTKhCxtGJh1A4wj5fM26BYf1DCUGkDeDABRdae3xMZIOqAHIOaOqmqQFQr1yJtj2bMhdgwD+DracsmKVrJ4DuxjLIOAJVUy9bxzlCYD2iRGm+QjJEWiLw9hUPjv8+zMTVljyM9pdLWPn5s0602/2sfEy7Gsd3rss8gPFQBBs/6UFgepaJu7S/FLuK81j56kAAu77pZ+VcBQfXGxXIz5ZJgkh5BD7+bRjv/hQ9l6vW5MDcGLNhQnvaBrM3yN5/uGMt3tGvyRwAusiUnuyBe2KGiWrevQGvPr4qRuCZP31o+N7FvlublwXH0XJkSdjZUhoBMeLEQMYLSUoBnmy2oXtIeHgIDbMlAbgyEECtyAkab6ILTYiURaDslAV237SQ/3u+f2pjHn48UCqqbUoA/hoJQdVkFSVgsUo3Dynx2GrhC7SUALzePojmm9E0IdHnNVUBmp4rEmyedADvZBjFn1owPRtN1G4c3IKadeIStU5PEIZ5CZ/zaDkKc+VxIZIO8P7PXnzUwW4NsK0oF7+8Ii1V3t5ix/W5lPs9QyE+2F6YPoBgmGdpw2gwzJyerStGXZm0m/jzNj/2zh16CnLkLL3IkS9+ZEtqBL78YwyNF6Pn3c2rslmGKfW0SPNV5WdW2Meix84vdm9Aw1279/yQJBXgXK8fL30bPTIKOY43LuZ3RFtdMerjRDGpAGzYWMdZfh/PqeDSAoB2Br2d3idwXk46gBhxyazzACCZvZmIrQcRSKTXktnm/xOBjjT+zCo2QsGpEMy3euhm6TdUa2LuJzPih26xIISQM4Yq9cH59Zf0rwaihQN+EHJhhZx/U6PRRK/95h6pKYxYn2mrt+wB/gFq1IJPLiilxAAAAABJRU5ErkJggg==",txt:"AlJJREFUaEPtmk9PE0EYxp93WgQv6pfgIAl2J922rCcTjYGLXDzWozeNH4YP4EG9cMPERC/GkyVw2CYe5E9lsdKUQsVSINYUO2ZiSNDCdnbZrbNx9rTJvvPs83ufmcwms4SEX5Rw/+gDcF33WueY5iDEPQFciROQiI4AvBmhS49se6Ie5l19AKXl8jMhRDGMWNgxBPLYKN0uZDJeUI1+gCV3X3bemryOy2OjQfUC1Xe7x1iteDg4PAKBaiOM3bHtGytBRPoA3i+5Qgo4OSuITujaXq+HlXUP++0DgLCbTuNunvOyquA/B5BGe0JgreLhW6sNELUYo5mpbGZRBUILAGlUCGB9YxNf91oS4jDFaLaQzbwdBKENwInRT14VO809ANRJMXG/YPNXfhDaAUizXrWG7cYuiNAFo6KTtebPg9ASQJqtbtVRqzfk7U8GejiVt56eBaEtgDQrASQIEQkQnji2Nfc3hNYA0ux2o4nNLzUIIUApFJ0sf3EaQnsAabax08TG5y25JipOjo8nDkAaLi3/3ttu5vkfTU9EAgZg0G44jOdmCg2jy37vMAmcdGfh9btYw5idvnWmfmQJJB4g1vb7iEeWgAEI2YHIEkj8Gkg8QMgZcOFhkU2hCzsJKWAAzE6sOHVi/5RQ9BF5mVkDkbc0oGBkCYTdyM6b26ocBkC1U3HVRZZAXAYH6RqAQR2K+/n/k0BpiMesqql97/xA+cNHeSrfdvL86ulxWhx0q4IQ0XMnZz3wBRjmrwbKxoE2iF6OpcVjznnLF0BVVJe6xP+t8gu3vJ9AOdbOIQAAAABJRU5ErkJggg==",video:"A6BJREFUaEPtmltIFFEYx/9n3aur7holCvbgQ/mQPhn0UhSFQRRG9BBKhikRFaVpWGkXulgYaFpU+OCFkpXAKBcjSxKtXoSEYJXQgogMxSLdbW+zu+6JM7Jgq87suhcd2PP8zcz3+/7nu5yZIZD4IhL3HzGAlVZwgQJlRVRPOct9EJoHiqSVdpB/PoEFlBiJKul0QxuZme/TAoDSfPMTgB5eFY4vcIK0N3boCoUBCmbMqyby/gAElkaDXieiwAxdndGf86qxQ//frllkC8UAIipgTAGh8K5LlSF7sxyZ2QokryXQJct4c/O0F9O/KUZNbpg+evBr0rtslSKiQHpGHPIK1Ni4SR6QY2MjHhgNTox/mw3Ifr5RWAFkMuDAETW25ipBCIHdSmEacmN4yI3JcS8febaYEqnpMmTlKJCdo0B8AgGlFB96XXj+2AlvEIKEDUCjJSgui8eGTXK4XRT9rzi8NXJwOoSDqtYAu/JU2LFHBYWS4MuIBy0NdjhsgVXvsACwyJ+4qOWdn/njRXOdHT+C3A7rM+JQUhEP/RoZD/Hoti0gJcICcLBIjW27Vbzzdy9bYZ4OLHr+2uiSCc7eSOAh3r/h8KzNKZoTIQOwhK24qYXHDdy7Zgs68v4eMiXOXNVCrgDqLtlEEztkgJPVWr7a9HY58fIpJxqxQAz2HlIhd78arDo9rLEJXhISQEqaDFV1iXy1uV5qEUzYY+fiMdDjwtiwR5SBJfaVxiS+OtWU/xXsEyEB7NynRF6BBoMDLnQ0CZebBsPc0DjY78KLdgccdmGO/OMabNmuhNHgQF+3a0njkABY5cnMlqO53sZ3VKHlA/B14s5Wh+A1rIOXlGsxapqrSEutkACq6hKQkhYnKjN7+HwAnzOfBt1gIFbLwqrFxpDq+kRMTcziVoU1MgC1LUlQqQkqj5rhEsnfxQCYVzarF7WVVlj8pnalCrjTqgPnpDhfbFmdAF4vRW8Xh55ODtRPBJUaqG3RwemguFASIYBQthBreu0P7Pj6efEBLipbaLlJzIY7Q5ODL79LragkcbBl1OOm/Nj87vXSZdEHFJUyGkwjKzylQV83h5/fxWflqDUyFi1JjxIMQPLDHIOQ9DjNACR/oGEQkj5S+kqfpA/18xuSZF+r+HdV1ieycoRfbA0PeTA1Id4bIjJOix6tomAQ0nkgCv6JPiIGIBqiCBuIKyD9T0wS/8gn+c+sEd7CYb997FeDsIc0yBtKXoF/vDuJT96PcI8AAAAASUVORK5CYII=",xls:"BF1JREFUaEPtmn9sE2UYx7/vtds6F8aCoIGJEhXFJbM917XrRNQJExSGTPiLqSFoQgaiI/5h8BdGNIpo0KKY+IdTQMXEoEsGAotm4ceAKS2g4cfKOsaarVu3dW0n3br1NW9htUe33d3Cbdek71/Ne8899/m8T/vek7sSJPggCc6POAGbzZYVHCBWUFpCgUwlBQkhvQAOpJDUdUZjTutYrhUnUFdv30kpLRtLsrGeQ0CcXBp5wqzXO+XmiBc4aethK2/IfQDpujS5+WTFh0IDuOBwwh/oBQFxpXDcfKPxwfNyksQJHDtpoyyBJd8gJ8+YY8PhMM43ONHj8wMEHVotik08b5eacMIFGGiYUlx0ONHt9QGEeDmOLCrI0x+XIqEKAQZKKdDQ2ITOLi+TCGg4stScp/9dTEI1AkOgl5zNaPd0ASBBDUeXm4189WgSqhNgsM5mF9rcHSAEIXCkzJJn+GkkCVUKMNjmlla4Wt3s4yAH8lKByfDNcBKqFWCwTICJEEIoCF6xGA3WGyVULcBg29weNF1xgVIKokGZJY/fHSuhegEG6273oPFyC/tNOCz5/OyEE2DAdfXX7m2FJl6w6AlRgaTASHvwljM/YtNflYLD86brsX/hh6w5iztt06lvseX0D4L5jYaVeJN/TuyGq9xX6Nmad7D/ygkBAANiYLHjoOtPLDv0VmQ3GRqLZprx8/x3ReEV/Qp5+wMorFqHJn9bFETDaSJVmHt7bmTO1etBQVU5OoO+aMw9mTNwZIkVk1MzJlaAXd3e6UDRvg0IDvRHYbIzpuL40i8jgAv2vYYT7eeixzJSdKhd/Blysu6SBK9oBYYIKi/+hvKj2wRAC2eacG9mNrb/s1cwv+vxjSidNU8y/LgIsIusOfIpvms4OCpYRe4KvG9cLQt+3AT6BkN4rPpVnO68NCxg0YyHUFW8GRzh1CnAqJoCbbD8uhY9/eyBw//jtvQsnFr2NaakTZINP24VGOkHzeYJIdi74D0UZxvVK9B9fUu9HLOlxtLeqstEXckXuCNjmmwJxXshCorSQ2/jQEu9YLu8OtCPMA1H50zT5qDm6U+gJRpZEooLfGDfjc22nQKoykdfx9/dTmw9s0cwvzbnGXxsXqMeAdYmsNWPXekX7nsSOx6uwCANo6i6AvUdF264F7yB0lmPSJZQrALNAXeklejq80dh5mTdiaMlVqRrrj3ZYzuT+Zdy+EP/RmMmpdyCYyXbwVoKKUMRAbbvsxbC5mmIMqRr03B4yedxbcKexj+wqvYjAWvulLtRu3gbdJpUUQdFBFjrwFqI2GEtXI/V9z81LNCLh7fie0eN4Njzs4vx1dwNEyMgetWbGKBIBW4in2iqpIDoEikckKyAwgssmj5ZAdElUjggWQGFF1g0veQK1I3ja1ZR6usBV4N9sJ89x571+SwmfnLseap40S1VhBCyy5JvEDyHnNC/GkgGB3wgpEqnpS/zPO8dtQJSk6olLuH/rfIfRy5PT3h4uJwAAAAASUVORK5CYII=",xxx:"AitJREFUaEPtmjFv01AUhc99SWlZgD/BAFKJn+IkNSuoEku7dAwjG4gf0x/AACwdkRhYGAlqB0dioLRp3aaN0rShpGkrgtLmoieEBARcO1ektvQyWcq7x+c7x5YlPxNS/qOU+8cQgO/7N3pntAjmOQau/U9AIjoF8GaCrjx23dvNUc41BFBZqT5n5vIoYqPOEChQk3SvlMsFcTWGAZb9I5O8M30LV6cm4+rFWt/vn+FTLcDxySkI1JhQ6r7r3lmNIzIE8G7ZZyPgFZw4OiOvHQwGWF0PcNQ9BggH2Sxmi1pXowpeOoAxOmDGWi3Al04XIOooRQ9m8rn3USASAWCMMgPrm1v4fNgxECcZRfOlfO7tRRCJAfhpdCOoY799CIB6GcULJVe/DoNIHIAxG9Qb2GsdgAh9KCp7eWfpXxCJBDBm67tNNJotc3iuQI9mis6zv0EkFsCYNQAGhIgYhKee6yz+CZFoAGN2r9XG1k4DzAzKoOzl9ctfIRIPYMy29tvY3N4190TNK+ibqQMwhisrP55td4v6t9BT0YAFuOhpOI7/7SU0jpTDzmEbsA0IE7CXkDBA8bhtQByhUMA2IAxQPG4bEEcoFLANCAMUj9sGxBEKBWwDwgDF47YBcYRCAduAMEDxuG1AHKFQIHIDlTFus0Zl+tr7huqHj2ZXvusV9fXQt9OXsdEdFYSIXngF52EowDg/NYhsHOiC6NVUlp9orTuhAFFFk7Iu9V+rfAfNzYdAB6N0dAAAAABJRU5ErkJggg==",zip:"AodJREFUaEPtmrFu01AUhv/jpLQsgISEeIEOIJXYxElqJqQiBAtdGMPIBuJh+gAMwMIGEhIsiIlUrZAjdaDQUJfQKHWTljRtRVBKLrqlKa6TONchdmzhrDn33PPd/z8njq4JIf9QyOtHB4Cu6+caBzQHxu4w4IyXgES0D+DNGJ16oKqXy4Ps1QGQW8w/YYxlB0k26BoCGdI4zWQSCcNtjk6ABX2Hn7w8dQmnJ8bd5juMf/H63fG62VvXe+ZoNg/wqWBgd28fBCqNSdINVb2y7GbTDoD3CzrjCbSU7CbPiVhRAL6o1WphecXATn0XIFTicdxMK0pedPORAxxCMIbPBQPfa3WAqCZJdHs6mZgXgfAEwLqxqBqMASura9jarnGIvZhEs5lk4m0/iMAAtAv9YhSxWd0GQI2YxO5mVOWVE0TgAHixRrGEDbMCIjQhUVZLys97QXgCIGobp5MtrpdRKps85JcEuj+dlh93iw8sAC+WA3AQImIgPNJUec4OEWgAXuyGWcXatxIYY6AYslpSeWaF8ARgkCnkZCdzs4rVr+u8JwpaSpkMHQAvOLf457ftWlo5ceihUMB3gGFMIbulfFUgAujS0b4qMOwp5HsPRACjtND8hyWYla3jEpz+kfV7VLZ+71sPWCcQLyACOJJhZApYbfAvakQAog1n74FIgagHRL1zFBdZqMeB+T6FrCOzrUqoxmgEYLOS7xbqZuVQWMj+NNoGuXjhPDJXp1zOtL/hvikwcIV9FkYAXp2saN5IAdGT8iru/1EgN4Rr1mGr8KPxE/mlj/xWvq6llbPW/IG46BYFJqKnWkq+5wjg56sGwoUDdRC9nIizh4qi1BwBRJMGJS70b6v8Bpsw+UC6csnIAAAAAElFTkSuQmCC"};Ext.define("SYNO.SDS.Drive.FileType",{statics:{SYNODOC:"odoc",SYNOSHEET:"osheet",SYNOSLIDE:"oslides",iconPlugins:[],browser_display_image:["image/gif","image/jpeg","image/pjpeg","image/png","image/bmp","image/x-windows-bmp","image/x-icon"],getMappingTypeCss:function(e,t){return String.format("syno-d-start-ntype {0}-s{1}",SYNO.SDS.Drive.FileType.getMappingType(e),t)},getMappingType:function(e){var t=n[e],i=SYNO.SDS.Drive.GetWindow().getNavigation&&SYNO.SDS.Drive.GetWindow().getNavigation();return i&&"folder"===t&&"backup"===i.getCategory()&&1===i.getPath().length&&(t="computer"),t||"xxx"},getIcon:function(e){return String.format("{0}.png",SYNO.SDS.Drive.FileType.getMappingType(e))},getBaseURL:function(e){var t=SYNO.SDS.UIFeatures.test("isRetina");return e=e||16,String.format("webman/3rdparty/SynologyDrive-Drive/images/_Asset/FileType/{0}",t?2*e:e)},getLockIconBaseURL:function(e){var t=SYNO.SDS.UIFeatures.test("isRetina"),i="1x";return t&&e!==SYNO.SDS.Drive.Define.LockOverlayDynamicIcon.name&&(i="2x",e*=2),String.format("webman/3rdparty/SynologyDrive-Drive/images/_Asset/{0}/_Drive/lock_overlay_{1}.png",i,e)},hasThumbnail:function(e){return-1!==i.image.indexOf(e)||-1!==i.video.indexOf(e)},getLockOverlayIcon:function(e){var t=SYNO.SDS.Drive.FileType.getLockIconBaseURL(e),i=SYNO.SDS.Drive.Utils.getPackageVersion();return String.format("url({0}?version={2})",t,i)},getFileTypeIcon:function(e,t){var i=SYNO.SDS.Drive.FileType.getBaseURL(t),n=SYNO.SDS.Drive.FileType.getIcon(e),o=SYNO.SDS.Drive.Utils.getPackageVersion(),s=SYNO.SDS.UIFeatures.test("isRetina"),r="";return Ext.each(SYNO.SDS.Drive.FileType.iconPlugins,function(i){if("string"==typeof i.getIconFn){var n,o=Ext.getClassByName(i.getIconFn);if(o)return n=o(e,s,t),n&&(r=i.baseURL+"/"+n),!1}}),r||String.format("{0}/{1}?version={2}",i,n,o)},getFileTypeIconStyle:function(e,t){return String.format("background:url({0});width:{1}px;height:{1}px;background-size:{1}px;background-repeat:no-repeat;",SYNO.SDS.Drive.FileType.getFileTypeIcon(e,t),t)},getTransientFileIconStyle:function(e,t){return SYNO.SDS.JSDebug?String.format("background:url({0});width:{1}px;height:{1}px;background-size:{1}px;background-repeat:no-repeat;","webman/3rdparty/SynologyDrive-Drive/images/loading.gif",t):SYNO.SDS.Drive.FileType.getFileTypeIconStyle(e,t)},getDefaultIcon:function(){return"scripts/ext-3/resources/images/default/s.gif"},isImageMime:function(e){return-1!==SYNO.SDS.Drive.FileType.browser_display_image.indexOf(e)},getBase64Img:function(e,t){return"iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAA"+("dir"===e?o.folder:o[SYNO.SDS.Drive.FileType.getMappingType(SYNO.SDS.Drive.Utils.getExt(t))])}}})}(),Array.prototype.fill||Object.defineProperty(Array.prototype,"fill",{value:function(e){if(null==this)throw new TypeError("this is null or not defined");for(var t=Object(this),i=t.length>>>0,n=arguments[1],o=n>>0,s=o<0?Math.max(i+o,0):Math.min(o,i),r=arguments[2],a=void 0===r?i:r>>0,l=a<0?Math.max(i+a,0):Math.min(a,i);s<l;)t[s]=e,s++;return t}}),Ext.ns("SYNO.SDS.Drive"),window.SYNO.SDS.Drive._T=function(e,t){try{return _TT("SYNO.SDS.Drive.Application",e,t)||_T(e,t)||e+":"+t}catch(i){return _T(e,t)||e+":"+t}},Ext.define("SYNO.SDS.Drive.Date",{statics:{DURATIONS:{days:86400,hours:3600,minutes:60,seconds:1},DURATION_ABBR:{days:SYNO.SDS.Drive._T("task","time_day"),hours:SYNO.SDS.Drive._T("task","time_hour"),minutes:SYNO.SDS.Drive._T("task","time_min"),seconds:SYNO.SDS.Drive._T("task","time_sec")},parseDuration:function(e){var t,i={},n=SYNO.SDS.Drive.Date.DURATIONS;for(var o in n)if(n.hasOwnProperty(o)&&(t=Math.floor(e/n[o]))&&(i[o]=Ext.isNumber(t)&&t<Number.MAX_VALUE?t:Number.MAX_VALUE,0>=(e-=t*n[o])))break;return i},fancyDuration:function(e){var t=[],i=SYNO.SDS.Drive.Date.parseDuration(e);for(var n in i)if(i.hasOwnProperty(n)){var o=i[n]>9999?9999:i[n];t.push(o+" "+SYNO.SDS.Drive.Date.DURATION_ABBR[n])}return t.join(", ")}}}),Ext.define("SYNO.SDS.Drive.Utils",{statics:{ENTER_FROM_SHARING:null,CHARACTERS:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",ALL_NAMING_CATEGORY:["search","node","team_folder","backup","shared_with_me","sharing_to_others","file_request","recent","starred","recycle"],initErrorStr:function(){var e=SYNO.SDS.Drive._T;SYNO.SDS.Drive.ErrorString={};var t=SYNO.SDS.Drive.ErrorString;t[401]=e("warning","err_sys"),t[402]=e("warning","err_admin_only"),t[403]=e("warning","error_privilege_not_enough"),t[404]=e("warning","err_get_download_link_fail"),t[405]=e("warning","download_single_task"),t[406]=e("warning","restore_single_task"),t[407]=e("warning","delete_single_task"),t[408]=e("warning","restore_conflict"),t[409]=e("warning","restore_err_no_space"),t[500]=e("warning","err_drive_disabled"),t[501]=e("warning","err_drive_disabled"),t[502]=e("cstn","drive_diskfull_desc"),t[503]=e("warning","error_drive_repomove"),t[600]=e("warning","not_enough_space"),t[601]=e("warning","error_volume_not_found"),t[602]=e("warning","error_volume_readonly"),t[603]=e("warning","error_not_mounted"),t[604]=e("warning","invalid_repo_path"),t[701]=e("warning","user_key_conflict"),t[702]=e("warning","invalid_user_key"),t[703]=e("warning","no_such_user"),t[801]=e("warning","disable_popup_blocker")
;var i=[e("error","error_error_system"),e("error","perm_op_fail"),e("error","permission_not_enough"),e("error","node_not_exist"),e("error","not_in_recycle"),e("error","dir_not_exist"),e("error","tag_not_exist"),e("error","tag_already_exist"),e("error","dir_not_exist"),e("error","move_to_child"),e("error","copy_to_child"),e("error","not_support"),e("error","chat_no_such_user"),e("error","chat_error"),e("error","no_enough_space"),e("error","space_not_enough"),e("error","volume_quota_full"),e("error","share_quota_full"),_S("is_admin")?e("error","volume_moving"):e("error","maintenance"),_S("is_admin")?e("error","backuping"):e("error","maintenance"),_S("is_admin")?e("error","backuping"):e("error","maintenance"),e("error","moving_data"),e("error","filename_exist"),e("error","autorename_max_limit"),e("error","parent_path_conflict"),e("error","file_type_conflict"),e("error","office_install"),e("warning","err_enable_homes"),e("warning","no_such_user"),e("error","no_such_group"),e("error","chat_service_not_found"),e("error","access_token_invalid"),e("error","reserved_name"),e("error","file_too_big"),e("error","error_long_path"),e("error","name_too_long"),e("error","protection_shared_error"),e("error","adv_share_password_error"),e("error","adv_share_expired"),e("error","view_user_disabled"),e("error","public_sharing_disable"),e("error","internal_sharing_disable"),e("error","invite_sharing_disable"),e("error","adv_sharing_need_password"),e("error","adv_sharing_need_expire"),e("error","request_access_disabled"),_T("error","error_error"),e("error","index_home_migrating"),e("error","error_error_system"),"","",e("error","error_watermark_operation"),e("error","error_watermark_path_not_found"),e("error","error_watermark_file_too_large"),"",e("error","protection_shared_error"),e("error","file_request_password_error"),e("error","file_request_expired"),e("error","file_request_need_password"),e("error","file_request_need_expire"),e("error","error_shared_label_readonly"),e("error","file_request_setting_expired_error"),e("error","file_request_setting_expired_too_far_error"),e("error","error_node_locking_lock_denied"),e("error","error_node_locking_unlock_denied"),e("error","error_node_locking_already_unlocked"),e("warning","err_sys"),"",e("warning","error_privilege_not_enough"),e("warning","error_node_locking_locked"),e("warning","error_privilege_not_enough"),e("error","error_password_too_long"),e("error","file_request_exceeded_max_upload_size"),e("error","error_mount_point_detected"),e("error","error_shared_label_copy_failed"),e("request","ask_access"),e("error","file_request_disabled"),e("error","error_shared_label_no_manage_permission"),e("warning","err_transforming_homes"),e("error","error_file_in_disconnected_cold_tier"),e("error","error_version_in_disconnected_cold_tier")],n=[_T("common","commfail"),e("error","source_no_file"),e("error","source_read_error")],o=0;for(o=0;o<i.length;++o)SYNO.SDS.Drive.ErrorString[1e3+o]=i[o];for(o=0;o<n.length;++o)SYNO.SDS.Drive.ErrorString[1e4+o]=n[o]},getErrorCode:function(e){return Ext.isObject(e)?e.code:e},getErrorStr:function(e){var t=SYNO.SDS.Drive.Utils.getErrorCode(e);if(!Ext.isNumber(t))return Ext.isString(t)?t:_T("error","error_unknown");if(102===t)return SYNO.SDS.Drive._T("error","drive_server_install");if(t<400)return SYNO.API.Errors.common[t]||_T("error","error_error");if(t in SYNO.SDS.Drive.ErrorString)return SYNO.SDS.Drive.ErrorString[t];if(SYNO.SDS.Office&&t in SYNO.SDS.Office.ErrorString)return SYNO.SDS.Office.ErrorString[t];if(t>=57344&&t<61439)return SYNO.SDS.Drive._T("error","office_install");var i=SYNO.API.getErrorString(t);return i||_T("error","error_error")},showErrorMsg:function(e,t,i,n){var o=SYNO.SDS.Drive.Utils.getErrorStr(t);if(t&&(1079===t.code||1080===t.code)){o+=String.format('<a class="syno-d-text-btn" target="_blank" href="{0}">{1}</a>',"https://sy.to/tiered_files_inaccessible",_T("common","learn_more"))}SYNO.SDS.Drive.Utils.showAlertMsg(e,o,i,n)},showAlertMsg:function(e,t,i,n){var o=e.getMsgBox();Ext.isEmpty(o)||o.alert("",t,i,n)},showToastMsg:function(e,t,i,n,o){this.getToastBox(t,n||!1,o,{offsetX:0,offsetY:10,delay:i||1500},e).show()},getToastBox:function(e,t,i,n,o){this.toastBox&&!this.toastBox.isDestroyed&&this.toastBox.destroy();var s={text:e,closable:t,owner:o};return Ext.isObject(i)&&(Ext.isString(i.text)&&(s.actionText=i.text),Ext.isFunction(i.fn)&&(s.actionHandler=i.fn),Ext.isObject(i.scope)&&(s.actionHandlerScope=i.scope),Ext.isString(i.textActionId)&&(s.textActionId=i.textActionId)),Ext.isObject(n)&&(Ext.isNumber(n.delay)&&(s.delay=n.delay),Ext.isNumber(n.offsetY)&&(s.offsetY=n.offsetY),Ext.isNumber(n.offsetX)&&(s.offsetX=n.offsetX),Ext.isDefined(n.alignEl)&&(s.alignEl=n.alignEl),s.alignBottom=!0===n.alignBottom),this.toastBox=new SYNO.SDS.Drive.ToastBox(s),this.toastBox},getFormatDate:function(e){return SYNO.SDS.DateTimeFormatter?SYNO.SDS.DateTimeFormatter(e,{type:"date"}):e.format(SYNO.SDS.Drive.Define.DATE_FORMAT)},getFormatDateTime:function(e,t){return SYNO.SDS.DateTimeFormatter?t?SYNO.SDS.DateTimeFormatter(e,{type:""}):SYNO.SDS.DateTimeFormatter(e,{type:"datetimesec"}):t?e.format(SYNO.SDS.Drive.Define.DATE_FORMAT+" "+SYNO.SDS.Drive.Define.TIME_FORMAT):e.format(SYNO.SDS.Drive.Define.DATE_FORMAT+" "+SYNO.SDS.Drive.Define.TIME_SEC_FORMAT)},getFormatTime:function(e){return SYNO.SDS.DateTimeFormatter?SYNO.SDS.DateTimeFormatter(e,{type:"time"}):e.format(SYNO.SDS.Drive.Define.TIME_FORMAT)},getDateFormat:function(){return SYNO.SDS.DateTimeUtils?SYNO.SDS.DateTimeUtils.GetDateFormat():SYNO.SDS.Drive.Define.DATE_FORMAT},getFormatTimeSec:function(e){return SYNO.SDS.DateTimeFormatter?SYNO.SDS.DateTimeFormatter(e,{type:"timesec"}):e.format(SYNO.SDS.Drive.Define.TIME_SEC_FORMAT)},getPathId:function(e){return Ext.isEmpty(e)&&(e=SYNO.SDS.Drive.Define.Info.drive_id),"/"===e.charAt(0)?e:String.format("id:{0}",e)},getPathIdByLink:function(e){return String.format("link:{0}",e)},getAppURL:function(){var e,t=SYNO.SDS.Drive.WindowHelper.getBaseAppPath()+"/",i=SYNO.SDS.Session.standaloneAppName;if(SYNO.SDS.Drive.WindowHelper.isPublicShare()){var n={link:window.getDriveLink()},o=SYNO.SDS.Drive.Sharing.GetSharingLink();o&&(n.sharing_link=o),e={launchApp:i,launchParam:Ext.urlEncode(n)}}else-1!==window.location.href.indexOf("launchApp")&&(e={launchApp:i});return SYNO.SDS.JSDebug&&(e=Ext.apply(e,{jsDebug:SYNO.SDS.JSDebug})),Ext.urlAppend(t,Ext.urlEncode(e),!1)+window.location.hash||""},openFileLink:function(e,t,i,n){if(SYNO.SDS.Drive.Utils.isOfficeFile(e))this.openOfficeLink(t,i,n);else{var o=SYNO.SDS.Drive.Utils.getDriveLink(t);SYNO.SDS.Drive.Utils.openURL(o,i,n)}},openOfficeLink:function(e,t,i,n,o){var s;if(s=SYNO.SDS.Drive.WindowHelper.isAdvShare()?SYNO.SDS.Drive.Sharing.GetURL(e,SYNO.SDS.Drive.Sharing.GetSharingLink()):SYNO.SDS.Drive.Utils.getOfficeLink(e),!0===n)return SYNO.SDS.Drive.Utils.openURLWithReferer(s,t,i);SYNO.SDS.Drive.Utils.openURL(s,t,i,o)},openDriveLink:function(e,t,i){var n=SYNO.SDS.Drive.Utils.getDriveLink(e);SYNO.SDS.Drive.Utils.openURL(n,t,i)},openByAnchor:function(e,t){var i=document.createElement("a");i.target="_blank",i.rel="noopener noreferrer",i.style.position="absolute",i.style.top="-9999px",i.style.left="-9999px",i.href=e,document.body.appendChild(i);var n=function(){i.click(),document.body.removeChild(i)};return void 0!==t?(setTimeout(n.bind(this),t),!0):(n(),!0)},openURL:function(e,t,i,n){t&&(e+="#"+t),!1===i?window.location.href=e:!0!==SYNO.SDS.Drive.Utils.openByAnchor(e,n)&&window.open(e,"_blank")},openURLWithReferer:function(e,t,i){if(t&&(e+="#"+t),!1===i)return window.location.href=e,window;var n=window.open(e,"_blank");return n&&!n.closed&&void 0!==n.closed?n:void 0},getDriveLink:function(e){var t=window.location.pathname.substr(0,window.location.pathname.lastIndexOf("/"));return t=t.replace("/d/f",""),window.location.protocol+"//"+window.location.host+t+"/d/f/"+e},getOfficeLink:function(e){var t=window.location.pathname.substr(0,window.location.pathname.lastIndexOf("/"));return t=t.replace("/d/f",""),t=t.replace("/oo/r",""),t=t.replace("/oo/sharing",""),window.location.protocol+"//"+window.location.host+t+"/oo/r/"+e},isAppAuthorized:function(){return!1!==_S("isLogined")&&SYNO.SDS.StatusNotifier.isAppEnabled("SYNO.SDS.Drive.Application")},isLogined:function(){return!1!==_S("isLogined")},isAdvSharingPage:function(){return SYNO.SDS.Drive.Sharing&&SYNO.SDS.Drive.Sharing.GetSharingLink()},getBaseName:function(e,t){var i=t||"/";if(!Ext.isDefined(e))return"";var n="",o=e.lastIndexOf(i);return-1!==o&&(n=e.substr(o+1)),n},getExt:function(e){var t=SYNO.SDS.Drive.Utils.getBaseName(e);e=t||e;var i=e.lastIndexOf(".");return-1===i?"":e.substr(i+1).toLowerCase()},getNtype:function(e,t){return"dir"!==t&&t?this.getExt(e):"dir"},getFileTypeMapping:function(e){switch(e){case"dir":return"dir";case SYNO.SDS.Drive.FileType.SYNODOC:case SYNO.SDS.Drive.FileType.SYNOSHEET:case SYNO.SDS.Drive.FileType.SYNOSLIDE:return"office";default:return"regular"}},getHashParam:function(){var e=location.hash.substr(1);return Ext.urlDecode(e)},isShared:function(e){return!Ext.isEmpty(e)},hasUserShared:function(e,t){var i=!1;return Ext.each(e,function(e){if("user"===e.type&&e.name.toLowerCase()===t.toLowerCase())return i=!0,!1}),i},apply:function(e,t,i,n){if(n=!1!==n,i&&Ext.apply(e,i),e&&t&&"object"==typeof t)for(var o in t)t.hasOwnProperty(o)&&(e[o]=n&&Ext.isObject(e[o])&&Ext.isObject(t[o])?SYNO.SDS.Drive.Utils.apply(e[o],t[o]):t[o]);return e},copyTo:function(e,t,i){return"string"==typeof i&&(i=i.split(/[,;\s]/)),Ext.each(i,function(i){t.hasOwnProperty(i)&&Ext.isDefined(t[i])&&(e[i]&&"object"==typeof t[i]?SYNO.SDS.Drive.Utils.apply(e[i],t[i]):e[i]=t[i])}),e},getAccount1stName:function(e){e=e||"";var t=e.split("\\");return 1<t.length?this.matchEmoji(t[1])||t[1].charAt(0).toUpperCase():this.matchEmoji(e)||e.charAt(0).toUpperCase()},matchEmoji:function(e){try{var t=e.match(/^(?<icon>\p{Extended_Pictographic})/u);if(t&&t.groups)return t.groups.icon}catch(e){}return null},updateAccountIcon:function(e,t,i){var n=function(e){var n=!0;2>e.width&&2>e.height&&(n=!1),!0===n?(this.el.setStyle("background","#FFF"),this.el.dom.lastChild.setAttribute("style",String.format("background-color: #FFF;background-image:url({0});",t))):i?(this.el.setStyle("background",i),this.el.dom.lastChild.removeAttribute("style")):(this.el.dom.removeAttribute("style"),this.el.dom.lastChild.removeAttribute("style"))};SYNO.SDS.Drive.Utils.getImageLoader().load(t,{load:function(t){this.rendered&&this.el&&this.el.dom?n.call(e,t):this.mon(this,"afterrender",function(){n.call(e,t)},this,{single:!0})}.bind(e)})},getImageLoader:function(){return SYNO.SDS.Drive.Utils.imageloader||(SYNO.SDS.Drive.Utils.imageloader=new SYNO.SDS.Drive.Utils.ImageLoad)},isEmpty:function(e){if(!e)return!0;if(Ext.isObject(e)){for(var t in e)if(e.hasOwnProperty(t))return!1;return!0}return Ext.isEmpty(e)},getParentIdFromResp:function(e){var t;if(Ext.isArray(e.data)){t=[];for(var i=e.data,n=0;n<i.length;n++)t.push(i[n].parent_id)}else t=[e.parent_id];return t},getFileIdFromPathId:function(e){if(!e)return"";var t=e.indexOf(":");return-1===t?e:e.substr(t+1)},isCurrentPath:function(e,t){for(var i="root"===t,n=0;n<e.length;n++)if(i){if("#00000000"===e[n].split("_",2)[1])return!0}else if(e[n]===t)return!0;return!1},openOffice:function(e,t){var i=SYNO.SDS.Drive.GetWindow();if(SYNO.SDS.Drive.Utils.hasOffice())return SYNO.SDS.Drive.Utils.openOfficeLink(e,void 0,void 0,void 0,t);SYNO.SDS.Drive.Define.Info.office_migration?SYNO.SDS.Drive.Utils.showAlertMsg(i,SYNO.SDS.Drive._T("app","migration_office")):SYNO.SDS.Drive.Utils.showAlertMsg(i,SYNO.SDS.Drive._T("app","install_office_alert"))},hasOffice:function(){return SYNO.SDS.StatusNotifier.isAppEnabled("SYNO.SDS.Office.AppInstance")&&Ext.isDefined("SYNO.SDS.Office.Drive")},doubleHtmlEncode:function(e){return Ext.util.Format.htmlEncode(Ext.util.Format.htmlEncode(e))},getPackageVersion:function(){return SYNO.SDS.Config.FnMap["SYNO.SDS.Drive.Application"].config.version},getChannelName:function(e,t){return 1===e?_TT("SYNO.SDS.Chat.Application","channel","name_general")||t:2===e?_TT("SYNO.SDS.Chat.Application","channel","name_random")||t:t},stripExt:function(e){var t=e.lastIndexOf(".");return-1===t?e:e.substr(0,t)},isOfficeFile:function(e){return"office"===SYNO.SDS.Drive.Utils.getFileTypeMapping(SYNO.SDS.Drive.Utils.getExt(e))},isMsOfficeFile:function(e){return["doc","ppt","xls"].indexOf(SYNO.SDS.Drive.FileType.getMappingType(SYNO.SDS.Drive.Utils.getExt(e)))>=0},isImageFile:function(e){return"image"===SYNO.SDS.Drive.FileType.getMappingType(SYNO.SDS.Drive.Utils.getExt(e))},isMP4:function(e){return"mp4"===SYNO.SDS.Drive.Utils.getExt(e)},isPDF:function(e){return"pdf"===SYNO.SDS.Drive.Utils.getExt(e)},isPreviewable:function(e){return this.isOfficeFile(e)||this.isImageFile(e)||SYNO.SDS.Drive.Utils.isAppAuthorized()&&"pdf"===SYNO.SDS.Drive.FileType.getMappingType(SYNO.SDS.Drive.Utils.getExt(e))},parseDisplayName:function(e){return SYNO.SDS.Drive.Utils.isOfficeFile(e)?SYNO.SDS.Drive.Utils.stripExt(e):e},isDisplayPathUnderMyDrive:function(e){var t=e.split("/");return 1<t.length&&"mydrive"===t[1]},parseDisplayPath:function(e,t){var i=e,n=e.split("/");if(1<n.length){switch(n[1]){case"mydrive":n[1]=SYNO.SDS.Drive._T("category","node");break;case"team-folders":n[1]=SYNO.SDS.Drive._T("category","team_folder");break;case"shared-with-me":n[1]=SYNO.SDS.Drive._T("category","shared_with_me");break;case"recycle-bin":switch(n[1]=SYNO.SDS.Drive._T("category","recycle"),n[2]){case"mydrive":n[2]=SYNO.SDS.Drive._T("category","node");break;case"team-folders":n[2]=SYNO.SDS.Drive._T("category","team_folder")}t&&n.splice(1,1)}var o=n[n.length-1];n[n.length-1]=this.parseDisplayName(o),i=n.join("/")}else i=this.parseDisplayName(i);return i},isVisibleInDrive:function(e){return"/"===e.charAt(0)},checkSharePrivilge:function(e,t){if(!0!==t)return!1;var i=SYNO.SDS.Drive.Define.Info||{},n=SYNO.SDS.Drive.Utils.isDisplayPathUnderMyDrive(e.display_path||"");return!1===i.disabled_all_sharing||(!(!e.adv_shared||!n)||!!(e.shared_with&&e.shared_with.length>0))},checkFileName:function(e){switch(e){case".":case"..":return!1;default:if(/[\/\\]/.test(e))return!1}switch(e.toLowerCase()){case"@eaDir":case"#recycle":case"#snapshot":return!1;default:return!0}},onOpenMgr:function(e,t){var i=new SYNO.SDS.WindowLauncher({className:"SYNO.SDS.Drive.Application",url:SYNO.SDS.Drive.WindowHelper.getStandaloneLaunchURL("SYNO.SDS.Drive.Application",e),type:"standalone",isOpenNewWindow:!0}),n=i.getLaunchURL();t&&(n+="#"+Ext.urlEncode(t));var o=i.appConfig,s=o.windowParam||"";return window.open(n,"SYNOSDSDriveApplication",s)},convertEpochTime:function(e,t){var i,n,o="";return Ext.isNumber(e)?(i=new Date(e),n=new Date,i.format("Y-m-d")===n.format("Y-m-d")?o+=SYNO.SDS.Drive._T("date","today"):i.getYear()===n.getYear()?o+=String.format(SYNO.SDS.Drive._T("date","date_format"),SYNO.SDS.Drive._T("date","mon_"+(i.getMonth()+1)),i.getDate(),SYNO.SDS.Drive._T("date","weekday_"+i.getDay())):o+=SYNO.SDS.Drive.Utils.getFormatDate(i),o+=!1!==t?" "+SYNO.SDS.Drive.Utils.getFormatTimeSec(i):" "+SYNO.SDS.Drive.Utils.getFormatTime(i)):o},is1stSharedWithMe:function(e){if(!e)return!1;var t=e.split("/",4);return 3===t.length&&"shared-with-me"===t[1]},jsLoad:function(){SYNO.SDS.JSLoad("SYNO.SDS.Profile.Panel"),SYNO.SDS.JSLoad("SYNO.Personal.Mail.MailForm",function(){Ext.getClassByName("SYNO.Personal.Mail.Config")&&(SYNO.Personal.Mail.Config.btnStyle="grey",SYNO.Personal.Mail.Config.emailWizardStyle={})});var e=this;SYNO.SDS.JSLoad("SYNO.Personal.Mail.EmailAccountWizard",function(){Ext.getClassByName("SYNO.Personal.Mail.EmailAccountWizard")&&(SYNO.Personal.Mail.EmailAccountWizard.prototype.WIZRAD_HEIGHT=480,e.setEmailAccountWizard())})},setEmailAccountWizard:function(){var e=function(e){var t,i;if((t=SYNO.SDS.Config.FnMap[e])&&t.config&&Ext.isString(t.config.version)&&(i=t.config.version.match(/(.*)-(.*)/),Ext.isArray(i)&&i.length>2))return parseInt(i[2],10)}("SYNO.Application.Service.Instance");"7"===_S("majorversion")&&Ext.isNumber(e)&&e<=10544&&(SYNO.Personal.Mail.EmailAccountWizard.prototype.setHeadline=SYNO.Personal.Mail.EmailAccountWizard.prototype.setHeader,SYNO.Personal.Mail.EmailAccountWizard.SyncContactStep.prototype.activate=function(){var e=this.getComponent("sync_displayfield"),t=this.getEmailConfig(this.owner.saveData.email_type);e.setValue(t.desc),this.syncBtn.setText(t.btn_text),this.msgField.setValue(""),"gmail"===this.owner.saveData.email_type?this.getComponent("sync_note").hide():this.getComponent("sync_note").show()})},getSupportedCodepage:function(){var e=SYNO.SDS.Utils.getSupportedLanguageCodepage();return e.push(["unicode",SYNO.SDS.Drive._T("common","unicode")]),e},isConflictPath:function(e,t,i){var n="";if(t.length<e.length){var o=e.lastIndexOf("/");return n=e.substring(o),t+n===e}if(t.length===e.length)return t===e;if(i){var s=t.substring(0,e.length);return n=t.substring(e.length),s===e&&"/"===n.charAt(0)}return!1},getDragItem:function(e,t,i){if(t){if(e.length===t.length)return t[i];var n,o=-1;for(n=0;n<t.length;++n)if("file"===t[n].kind&&(++o,i===o))return t[n];return t[i]}},getSharedLabelTooltipContent:function(e){var t=SYNO.SDS.Drive.Utils.parseDisplayName(Ext.util.Format.htmlEncode(e.name)),i=""===e.owner?SYNO.SDS.Drive._T("shared_label","no_owner"):String.format(SYNO.SDS.Drive._T("shared_label","owned_by"),Ext.util.Format.htmlEncode(e.owner)),n=SYNO.SDS.Drive.SharedLabel.LabelConfig.roleOptions.find(function(t){return t.value===e.apply_permission}).label;return String.format("{0}<br>{1}<br>{2}",t,i,n)},getSharedLabelDragText:function(e){return"<span class='syno-d-tag-shared-label-info'><span class='syno-d-drag-text'>"+SYNO.SDS.Drive.Utils.getSharedLabelTooltipContent(e)+"</span></span>"},isDriveAppWindow:function(e){return Ext.getClassByName("SYNO.SDS.Drive.MainWindow")&&e instanceof SYNO.SDS.Drive.MainWindow},isDrivePage:function(){var e=_S("standaloneAppName");return"SYNO.SDS.Drive.Application"===e||"SYNO.SDS.Drive.PublicApplication"===e},getHelpURL:function(e){return SYNO.SDS.Drive.WindowHelper.getStandaloneLaunchURL("SYNO.SDS.HelpBrowser.Application",e?{launchParam:"topic="+e}:null)},getAlignToXY:function(e,t,i,n){if(!(t=Ext.get(t))||!t.dom)throw"Element.alignToXY with an element that doesn't exist";n=n||[0,0],i=(i&&"?"!==i?/-/.test(i)||""===i?i||"tl-bl":"tl-"+i:"tl-bl?").toLowerCase();var o,s,r,a,l,d,c,h,u,p,S,f,g,m=Ext.lib.Dom.getViewWidth()-10,v=Ext.lib.Dom.getViewHeight()-10,D=document,y=D.documentElement,_=D.body,w=(y.scrollLeft||_.scrollLeft||0)+5,b=(y.scrollTop||_.scrollTop||0)+5,x=!1,N="",O="",E=i.match(/^([a-z]+)-([a-z]+)(\?)?$/);if(!E)throw"Element.alignTo with an invalid alignment "+i;N=E[1],O=E[2],x=!!E[3],o=e.getAnchorXY(N,!0),s=t.getAnchorXY(O,!1),r=s[0]-o[0]+n[0],a=s[1]-o[1]+n[1];var T={left:!1,right:!1,top:!1,bottom:!1};return x&&(l=e.getWidth(),d=e.getHeight(),c=t.getRegion(),h=N.charAt(0),u=N.charAt(N.length-1),p=O.charAt(0),S=O.charAt(O.length-1),f="t"===h&&"b"===p||"b"===h&&"t"===p,g="r"===u&&"l"===S||"l"===u&&"r"===S,r+l>m+w&&(r=g?c.left-l:m+w-l,T.right=!0),r<w&&(r=g?c.right:w,T.left=!0),a+d>v+b&&(a=f?c.top-d-n[1]:v+b-d-n[1],T.bottom=!0),a<b&&(a=f?c.bottom:b,T.top=!0)),{xy:[r,a],viewportReachBoundry:T}},prepareRequestParams:function(e){return e.path||e.files?e:(e.permanent_link?(Ext.isArray(e.permanent_link)?(e.files=[],Ext.each(e.permanent_link,function(t){e.files.push(SYNO.SDS.Drive.Utils.getPathIdByLink(t))})):e.path=SYNO.SDS.Drive.Utils.getPathIdByLink(e.permanent_link),delete e.permanent_link):e.file_id&&(Ext.isArray(e.file_id)?(e.files=[],Ext.each(e.file_id,function(t){e.files.push(SYNO.SDS.Drive.Utils.getPathId(t))})):e.path=SYNO.SDS.Drive.Utils.getPathId(e.file_id),delete e.file_id),e)},isiOS:function(){return Ext.isBoolean(this.isiOS_)?this.isiOS_:this.isiOS_=/(iPad|iPhone|iPod)/.test(navigator.platform)||"MacIntel"===navigator.platform&&navigator.maxTouchPoints>1},isAndroid:function(){return Ext.isBoolean(this.isAndroid_)?this.isAndroid_:this.isAndroid_=/Android/i.test(navigator.userAgent)},isMobile:function(){return Ext.isBoolean(this.isMobile_)?this.isMobile_:this.isMobile_=SYNO.SDS.Drive.Utils.isiOS()||SYNO.SDS.Drive.Utils.isAndroid()||/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|ipad|iris|kindle|Android|Silk|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(navigator.userAgent)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g|nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(navigator.userAgent.substr(0,4))},checkFileCanUpload:function(e,t){if(0===e.length)return Promise.reject(SYNO.SDS.Drive._T("error","upload_folder"));for(var i=[],n=0;n<e.length;++n)i.push(SYNO.SDS.Drive.Utils.checkCanUpload(e[n],t?t[n]:void 0));return Promise.all(i).then(function(){return Promise.resolve()}).catch(function(e){return Promise.reject(SYNO.SDS.Drive._T("error",e))})},checkCanUpload:function(e,t){return Ext.isModernIE&&e.size>this.MAX_UPLOAD_SIZE?Promise.reject("upload_4G_limit"):t||!Ext.isSafari&&4096!==e.size?Promise.resolve():new Promise(function(t,i){var n=new FileReader;n.onerror=function(e){i("upload_folder")},n.onload=function(){t()};var o=Math.min(e.size,1024);n.readAsArrayBuffer(e.slice(0,o))})},genRandomStr:function(e){var t="",i=this.CHARACTERS,n=i.length;e=e||10;for(var o=0;o<e;o++)t+=i.charAt(Math.floor(Math.random()*n));return t},isSmallScreenSize:function(){return void 0!==this.SMALLSCREENSIZE?this.SMALLSCREENSIZE:this.SMALLSCREENSIZE=window.matchMedia("(max-device-width:479px)").matches||window.matchMedia("(max-device-height:479px)").matches},getPermissionText:function(e){var t=SYNO.SDS.Drive._T("perm","limit"),i=SYNO.SDS.Drive._T("perm","limit_desc");return SYNO.SDS.Drive.Define.Info.sharing_permission.invite_sharing||(i=SYNO.SDS.Drive._T("perm","limit_you_desc")),e.forEach(function(e){switch(e.type){case"public":t=SYNO.SDS.Drive._T("perm","public"),i={previewer:SYNO.SDS.Drive._T("perm","public_previewer_desc"),viewer:SYNO.SDS.Drive._T("perm","public_ro_desc"),commenter:SYNO.SDS.Drive._T("perm","public_commenter_desc"),editor:SYNO.SDS.Drive._T("perm","public_rw_desc"),preview_commenter:SYNO.SDS.Drive._T("perm","public_preview_commenter_desc")}[e.role];break;case"internal":t=SYNO.SDS.Drive._T("perm","app"),i={previewer:SYNO.SDS.Drive._T("perm","app_previewer_desc"),viewer:SYNO.SDS.Drive._T("perm","app_ro_desc"),commenter:SYNO.SDS.Drive._T("perm","app_commenter_desc"),editor:SYNO.SDS.Drive._T("perm","app_rw_desc"),preview_commenter:SYNO.SDS.Drive._T("perm","app_preview_commenter_desc")}[e.role]}}),SYNO.SDS.formatString("<b>{0}</b> - {1}",t,i)},getAdvPermissionText:function(e){var t=SYNO.SDS.Drive._T("perm","public"),i={accesser:SYNO.SDS.Drive._T("perm","public_access_desc"),previewer:SYNO.SDS.Drive._T("perm","public_previewer_desc"),viewer:SYNO.SDS.Drive._T("perm","public_ro_desc"),commenter:SYNO.SDS.Drive._T("perm","public_commenter_desc"),editor:SYNO.SDS.Drive._T("perm","public_rw_desc"),preview_commenter:SYNO.SDS.Drive._T("perm","public_preview_commenter_desc")}[e.role];return SYNO.SDS.formatString("<b>{0}</b> - {1}",t,i)},copyToClipboard:function(e,t){var i=document.querySelector("body"),n=document.createElement("textarea");i.appendChild(n),n.value=t,n.select();var o=document.execCommand("copy"),s="";i.removeChild(n),s=o?SYNO.SDS.Drive._T("share","copy_url_done"):SYNO.SDS.Drive._T("error","copy_share_link"),SYNO.SDS.Drive.Utils.showToastMsg(e,s,3e3)},openDriveVueWindow:function(e,t,i,n){var o=e||this.findAppWindow(),s=n||{};return Ext.apply(s,{ownerWindow:o,createWindow:function(e,t,i){var n=SYNO.SDS.Drive._Vue;return n.config.globalProperties.$windowManager.createWindow(e,t,Ext.apply(i,{parentApp:n}))}}),o.manager.openModalWindow(t,i,s)},GetNoSearchResultHtml:function(e){return['<div class="syno-d-empty-view">','<div class="empty-text-wrap">','<div class="empty-text-inner-wrap">','<div class="empty-text">',e||SYNO.SDS.Drive._T("common","search_no_result"),"</div>","</div>","</div>","</div>"].join("")},registerEmptyTextEvents:function(){this.initEmptyText=SYNO.SDS.Drive._T("common","no_data"),this.searchEmptyText=SYNO.SDS.Drive._T("empty","search_no_result"),this.store.on("beforeload",function(e,t){var i=this.searchFields.some(function(e){return e.isDirty()}),n=i?this.searchEmptyText:this.initEmptyText;this.emptyText=SYNO.SDS.Drive.Utils.GetNoSearchResultHtml(n)},this)},showPrompt:function(e){var t=SYNO.SDS.Drive.GetWindow(),i=t.manager,n=e.buttons||{},o=e.showDontAskAgainOption||!1;return i.getMsgBox(SYNO.SDS.Drive.Vue.MsgBox,{buttons:n,showDontAskAgainOption:o})},shouldShowFileLockOverlay:function(e){var t=SYNO.SDS.Drive.GetWindow();if(t.getNavigation){var i=t.getNavigation(),n=["recycle","file_request"],o=i.getCategoryText();if(n.includes(o))return!1}return e.node_locking&&e.node_locking.is_locked},checkFileLockOverlay:function(e,t,i){if(!SYNO.SDS.Drive.Utils.shouldShowFileLockOverlay(e))return t;var n=t.match(/background:\s?(url\(.*\))/);return n&&(t=t.replace(n[0],String.format("background:{0}, {1}",SYNO.SDS.Drive.FileType.getLockOverlayIcon(i),n[1]))),t},getFileLockingTooltip:function(e){var t=e.node_locking.lock_user,i=t.name,n=t.display_name;return i===_S("user")?SYNO.SDS.Drive._T("file_locking","locked_by_you"):String.format(SYNO.SDS.Drive._T("file_locking","locked_by_other"),SYNO.SDS.Drive.Utils.doubleHtmlEncode(n))},isLabelCategory:function(e){return!SYNO.SDS.Drive.Utils.ALL_NAMING_CATEGORY.includes(e)},isEnterFromSharing:function(){if(null!==SYNO.SDS.Drive.Utils.ENTER_FROM_SHARING)return SYNO.SDS.Drive.Utils.ENTER_FROM_SHARING;var e=Ext.urlDecode(window.location.search.substring(1));return SYNO.SDS.Drive.Utils.ENTER_FROM_SHARING=e.sharing,SYNO.SDS.Drive.Utils.ENTER_FROM_SHARING}}}),Ext.define("SYNO.SDS.Drive.Utils.base64ForHtmlId",{statics:{keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",encode:function(e){var t,i,n,o,s,r,a,l="",d=0;for(e=function(e){e=e.replace(/\r\n/g,"\n");for(var t="",i=0;i<e.length;i++){var n=e.charCodeAt(i);n<128?t+=String.fromCharCode(n):n>127&&n<2048?(t+=String.fromCharCode(n>>6|192),t+=String.fromCharCode(63&n|128)):(t+=String.fromCharCode(n>>12|224),t+=String.fromCharCode(n>>6&63|128),t+=String.fromCharCode(63&n|128))}return t}(e);d<e.length;)t=e.charCodeAt(d++),i=e.charCodeAt(d++),n=e.charCodeAt(d++),o=t>>2,s=(3&t)<<4|i>>4,r=(15&i)<<2|n>>6,a=63&n,isNaN(i)?r=a=64:isNaN(n)&&(a=64),l=l+this.keyStr.charAt(o)+this.keyStr.charAt(s)+this.keyStr.charAt(r)+this.keyStr.charAt(a);return l},decode:function(e){var t,i,n,o,s,r,a,l="",d=0;for(e=e.replace(/[^A-Za-z0-9]/g,"");d<e.length;)o=this.keyStr.indexOf(e.charAt(d++)),s=this.keyStr.indexOf(e.charAt(d++)),r=this.keyStr.indexOf(e.charAt(d++)),a=this.keyStr.indexOf(e.charAt(d++)),t=o<<2|s>>4,i=(15&s)<<4|r>>2,n=(3&r)<<6|a,l+=String.fromCharCode(t),64!==r&&(l+=String.fromCharCode(i)),64!==a&&(l+=String.fromCharCode(n));return l=function(e){for(var t,i="",n=0,o=0,s=o;n<e.length;)o=e.charCodeAt(n),o<128?(i+=String.fromCharCode(o),n++):o>191&&o<224?(s=e.charCodeAt(n+1),i+=String.fromCharCode((31&o)<<6|63&s),n+=2):(s=e.charCodeAt(n+1),t=e.charCodeAt(n+2),i+=String.fromCharCode((15&o)<<12|(63&s)<<6|63&t),n+=3);return i}(l)}}}),SYNO.SDS.Drive.Utils.ImageLoad=Ext.extend(Object,{list:[],intervalId:null,tick:function(){for(var e=0;e<this.list.length;e++)this.list[e].end?this.list.splice(e--,1):this.list[e]();this.list.length||this.stop()},stop:function(){clearInterval(this.intervalId),this.intervalId=null,this.clean()},clean:function(){for(var e=0;e<this.list.length;e++)this.list[e].img&&(this.list[e].img.onload=this.list[e].img.onerror=null);this.list=[]},load:function(e,t){var i=new Image;i.src=e,this.loadImg(i,t,!0)},loadImg:function(e,t){this.loadfn(e,t,!1)},loadfn:function(e,t,i){t=t||{};var n,o,s,r,a,l=t.beforeload,d=t.ready,c=t.load,h=t.error;if(e.complete)return Ext.isFunction(d)&&d(e),void(Ext.isFunction(c)&&c(e));o=e.width,s=e.height,e.onerror=function(){Ext.isFunction(h)&&h(e),n.end=!0,e.onload=e.onerror=null,!1!==i&&(e=null)},n=function(){r=e.width,a=e.height,(r!==o||a!==s||r*a>1024)&&(Ext.isFunction(d)&&d(e),n.end=!0)},n(),e.onload=function(){n.end||n(),Ext.isFunction(c)&&c(e),e.onload=e.onerror=null,!1!==i&&(e=null)},n.img=e,n.end||(this.list.push(n),null===this.intervalId&&(this.intervalId=setInterval(this.tick.createDelegate(this),100))),Ext.isFunction(l)&&l(e)}}),SYNO.SDS.Drive.Utils.initErrorStr(),SYNO.SDS.Drive.GetWindow=function(){return SYNO.SDS.Drive.Window||(SYNO.SDS.Drive.Window=SYNO.SDS.AppMgr.getByAppName(_S("standaloneAppName"))[0].window),SYNO.SDS.Drive.Window},Ext.ns("SYNO.SDS.Drive.HybridShare.Status"),SYNO.SDS.Drive.HybridShare.Status.PROGESSING=1,SYNO.SDS.Drive.HybridShare.Status.DONE=2,SYNO.SDS.Drive.HybridShare.Status.ERROR=3,Ext.define("SYNO.SDS.Drive.HybridShare.DownloadTask",{statics:{FILE_SYSTEM:1,MEMORY:2},constructor:function(e){this.appWindow=e.appWindow,this.fileInfo=e.fileInfo,this.observers=[],this.isAbort=!1,this.placeholder=void 0,this.persistentDownloadProgress=!1},start:function(){this.isAbort||(this.fileInfo.updateProgress(SYNO.SDS.Drive.HybridShare.FileInfo.STATUS_NEW,this.persistentDownloadProgress),this.placeholder=this._createPlaceholder(this._callback.bind(this)),this.placeholder.fill())},suspend:function(){this.isAbort=!0,this.placeholder&&this.placeholder.abort(),this.fileInfo.updateProgress(SYNO.SDS.Drive.HybridShare.FileInfo.STATUS_PAUSE,this.persistentDownloadProgress)},abort:function(){this.isAbort=!0,this.placeholder&&this.placeholder.abort(),this.fileInfo.updateProgress(SYNO.SDS.Drive.HybridShare.FileInfo.STATUS_DELETE,this.persistentDownloadProgress)},addObserver:function(e){this.observers.push(e)},getProgress:function(){return this.placeholder.getProgress()},_createPlaceholder:function(){},_refreshChunkInfo:function(){var e=this.fileInfo;return new Promise(function(t,i){SYNO.SDS.Drive.WebAPICore.sendPromise("download_files",{files:[SYNO.SDS.Drive.Utils.getPathId(e.file.file_id)],json_error:!0,c2_offload:"force",download_type:"download"}).then(function(n){return n&&n.file&&n.chunks&&0!==n.chunks.length&&n.file.hash===e.file.hash&&SYNO.SDS.Drive.HybridShare.ChunkInfo.updateChunkInfosByWebapiResponse(e.chunkInfos,n.chunks)?void t():void i()}).catch(i)})},_callback:function(e,t){
this.isAbort||(e===SYNO.SDS.Drive.HybridShare.Status.PROGESSING?(this.fileInfo.updateProgress(SYNO.SDS.Drive.HybridShare.FileInfo.STATUS_DOWNLOADING,this.persistentDownloadProgress,this.placeholder.downloadChunkCount),this._notifyDownLoadProgress()):e===SYNO.SDS.Drive.HybridShare.Status.DONE?(this.fileInfo.updateProgress(SYNO.SDS.Drive.HybridShare.FileInfo.STATUS_DOWNLOADED,this.persistentDownloadProgress),this.placeholder.triggerDownload().then(this._notifyDownLoadDone.bind(this)).catch(this._notifyDownLoadError.bind(this,!1))):e===SYNO.SDS.Drive.HybridShare.Status.ERROR&&this._notifyDownLoadError(t))},_notify:function(e){this.observers.forEach(function(t){t(this,e)})},_notifyDownLoadProgress:function(){this.isAbort||this._notify(SYNO.SDS.Drive.HybridShare.Status.PROGESSING)},_notifyDownLoadDone:function(){this.isAbort||this._notify(SYNO.SDS.Drive.HybridShare.Status.DONE)},_notifyDownLoadError:function(e){if(!this.isAbort)return e?void this._refreshChunkInfo().then(this.placeholder.resume.bind(this.placeholder)).catch(this._notify.bind(this,SYNO.SDS.Drive.HybridShare.Status.ERROR)):void this._notify(SYNO.SDS.Drive.HybridShare.Status.ERROR)}}),Ext.define("SYNO.SDS.Drive.Task.HybridShareDownload",{extend:"SYNO.SDS.Drive.Task.Base",type:"background",constructor:function(e){this.appWindow=e.appWindow,this.task=e.downloadTask,this.downloadDispatcher=e.downloadDispatcher,this.task.addObserver(this._taskCallback.bind(this)),this.callParent(arguments)},_start:function(){this.downloadDispatcher.startTask(this.task)},_stop:function(){this.downloadDispatcher.stopTask(this.task)},_onFinished:function(e){e?this.downloadDispatcher.finishTask(this.task):this.downloadDispatcher.fallBackTask(this.task),this.callParent([!0])},_taskCallback:function(e,t){t===SYNO.SDS.Drive.HybridShare.Status.PROGESSING?this._updateProgress():t===SYNO.SDS.Drive.HybridShare.Status.DONE?this._onFinished(!0):t===SYNO.SDS.Drive.HybridShare.Status.ERROR&&this._onFinished(!1)},_updateProgress:function(){var e=this.task.getProgress();this.total=e.remainTotal,this.process=e.remainProcessed,this.totalSize=e.total,this.totalProcessed=e.totalProcessed;var t=e.progress,i=((new Date).getTime()-this.starttime)/1e3;this.speed=this.process/i,this.leftTime=(this.total-this.process)/this.speed,this._onProgress(t.toFixed(1))},_getProgressText:function(e){if(!this.hasProgress)return"";if(0>=e||0>=this.total)return String.format("<center>{0}&#37;</center>",0<e?e:0);var t=["<div>",'<div class="syno-d-bgtask-progress-info">','<span style="float:left;">{0}% ({1}/{2})</span>','<span style="float:right;">{3}/'+SYNO.SDS.Drive._T("task","time_s")+"</span>","</div>",'<div class="syno-d-bgtask-progress-info">',"{4}: {5}","</div>","</div>"].join(""),i=String.format("1 {0}",SYNO.SDS.Drive._T("task","time_sec")),n=Ext.util.Format.fileSize(this.speed),o=Ext.util.Format.fileSize(this.totalSize),s=Ext.util.Format.fileSize(this.totalProcessed.toFixed(0));return String.format(t,Math.round(100*e)/100,s,o,n,SYNO.SDS.Drive._T("task","left_time"),SYNO.SDS.Drive.Date.fancyDuration(this.leftTime)||i)}}),Ext.define("SYNO.SDS.Drive.TaskFactory",{statics:{createErrTask:function(e){return{blErrTask:!0,total:0,stop:Ext.emptyFn,start:Ext.emptyFn,initFiles:function(){return Promise.resolve(this)},updateParentPath:Ext.emptyFn,errors:[{code:10002,context:e}]}},createHybridShareDownloadTask:function(e,t,i,n){return new SYNO.SDS.Drive.Task.HybridShareDownload({title:"download_from_remote",name:t,appWindow:e,downloadTask:i,downloadDispatcher:n,showProgress:!0,hasProgress:!0,delayProgress:500})},createUploadTask:function(e,t,i){if(t){if(t.isFile||t.isDirectory)return SYNO.SDS.Drive.TaskFactory.createUploadTaskByEntry(t,i);var n=t.webkitGetAsEntry();return n?SYNO.SDS.Drive.TaskFactory.createUploadTaskByEntry(n,i):Promise.resolve(new SYNO.SDS.Drive.Task.Upload(Ext.apply({showToast:!1,file:e},i||{})))}return Promise.resolve(new SYNO.SDS.Drive.Task.Upload(Ext.apply({showToast:!1,file:e},i||{})))},createUploadTaskByEntry:function(e,t){return new Promise(function(i,n){var o=null;e.isDirectory?(o=new SYNO.SDS.Drive.Task.UploadDir(Ext.apply({action:"upload",showToast:!1,directory:e},t||{})),i(o)):e.file(function(e){o=new SYNO.SDS.Drive.Task.Upload(Ext.apply({action:"upload",showToast:!1,file:e},t||{})),i(o)},function(t){SYNO.Debug.error(t);var n={name:e.name,file_type:"file"};i(SYNO.SDS.Drive.TaskFactory.createErrTask(n))})})},addUploadTasks:function(e,t,i,n){for(var o=[],s=0;s<i.length;++s)o.push(this.createUploadTask(i[s],SYNO.SDS.Drive.Utils.getDragItem(i,n,s),{appWindow:e,path:t}));Promise.all(o).then(function(t){var i;if(1<t.length)i=String.format(SYNO.SDS.Drive._T("task","upload_multi_start"),t.length);else{var n=Ext.util.Format.htmlEncode(SYNO.SDS.Drive.Utils.parseDisplayName(t[0].name).toString());i=String.format(SYNO.SDS.Drive._T("task","upload_start"),String.format('"{0}"',n))}SYNO.SDS.Drive.Utils.showToastMsg(e,i),e.getTaskMgr().addTasks(t)}).catch(function(t){SYNO.Debug.error(t),SYNO.SDS.Drive.Utils.showAlertMsg(e,_T("error","error_error"))})},addUploadFolderTask:function(e,t,i,n,o){var s=new SYNO.SDS.Drive.Task.UploadToDir(Ext.apply({action:"upload",appWindow:e,showToast:!1,path:t,folderName:i,files:n},o||{}));e.getTaskMgr().addTasks(s)},createUploadFromNasTask:function(e,t,i){var n=this.creatBackgroundTaskInstance({action:"upload_from_dsm",title:"upload",appWindow:SYNO.SDS.Drive.GetWindow(),webapi:"upload_files_from_nas",showProgress:!0,hasProgress:!0,delayProgress:3e3,params:{path:e,dsm_paths:t,conflict_action:"version"},name:i}),o=function(e,t,i){n.appWindow.getEventMgr().fireEvent("createnodedone",t,i,e.params),n.un("onfinish",o)};return n.on("onfinish",o),n},createEmptyRecycleTask:function(e,t){var i=this.creatBackgroundTaskInstance({action:"empty_recycle_bin",title:"empty_recycle_bin",appWindow:SYNO.SDS.Drive.GetWindow(),webapi:"empty_recycle_bin",showProgress:!0,hasProgress:!1,delayProgress:3e3,params:{path:e},name:t}),n=function(e,t){i.appWindow.getEventMgr().fireEvent("cleannodedone",!0,t,e.params),i.un("onsuccess",n)};return i.on("onsuccess",n),i},createBgTask:function(e,t){var i=String.format("{0}_files",e.title),n=String.format("{0}nodedone",e.title);"move"===e.title&&e.params&&e.params.change_name&&(e.title="rename");var o=Ext.apply({action:e.title,appWindow:SYNO.SDS.Drive.GetWindow(),webapi:i,showProgress:!0,hasProgress:!0,delayProgress:3e3},e||{}),s=this.creatBackgroundTaskInstance(o),r=function(e,i,o){s.appWindow.getEventMgr().fireEvent(n,i,o,e.params,t),s.un("onfinish",r)};return s.on("onfinish",r),s},creatBackgroundTaskInstance:function(e){return"move"===e.action||"copy"===e.action?new SYNO.SDS.Drive.Task.Background.MVCP(e):"convert_office"===e.action?new SYNO.SDS.Drive.Task.Background.ConvertOffice(e):new SYNO.SDS.Drive.Task.Background.Base(e)},createDownloadBgTask:function(e,t,i){var n=this.creatBackgroundTaskInstance(Ext.apply({action:e.title,appWindow:SYNO.SDS.Drive.GetWindow(),webapi:t,showProgress:!0,hasProgress:!0,delayProgress:3e3},e||{})),o=function(e,t){t&&t.task_id&&t.result&&(SYNO.SDS.Drive.WebAPICore.download("download_files",{task_id:t.task_id},t.result.archive_name),n.un("onsuccess",o),n.un("onerror",o))};return n.on("onsuccess",o),n.on("onerror",o),n},createConvertBgTask:function(e){var t=this.creatBackgroundTaskInstance(Ext.apply({action:"convert_office",title:"convert_office",appWindow:SYNO.SDS.Drive.GetWindow(),webapi:"convert_office",showProgress:!0,hasProgress:!0,delayProgress:3e3},e)),i=function(e,n){t.appWindow.getEventMgr().fireEvent("convertofficedone",!0,n,e.params,e.name[0]),t.un("onsuccess",i)};return t.on("onsuccess",i),t},createRestoreBgTask:function(e){var t=this.creatBackgroundTaskInstance(Ext.apply({action:"restore",title:e.params.action,appWindow:SYNO.SDS.Drive.GetWindow(),webapi:"restore_revisions",showProgress:!0,hasProgress:!0,delayProgress:3e3},e)),i=function(e,n){t.appWindow.getEventMgr().fireEvent("restorenodedone",!0,n,e.params,e.name[0]),t.un("onsuccess",i)};return t.on("onsuccess",i),t}}}),Ext.define("SYNO.SDS.Drive.TaskMgr",{extend:"Ext.Component",constructor:function(e){this.appWindow=e.appWindow,this.queue={upload:new SYNO.SDS.Drive.UploadTaskQueue({idx:0,appWindow:this.appWindow,maxConcurrency:1}),background:new SYNO.SDS.Drive.TaskQueue({idx:1,appWindow:this.appWindow})},this.statusBitset=0,this.callParent(arguments),this.onRegEvent()},onRegEvent:function(){Ext.iterate(this.queue,function(e,t){this.mon(t,{scope:this,oncomplete:this.onAllComplete})},this),this.mon(this.appWindow.getEventMgr(),"envready",this.initBgTask,this)},initBgTask:function(){SYNO.SDS.Drive.WindowHelper.isPublicShare()&&!SYNO.SDS.Drive.Utils.isLogined()||SYNO.SDS.Drive.WebAPICore.sendPromise("list_tasks").then(this._addExistTasks.bind(this)).catch(Ext.emptyFn)},_addExistTasks:function(e){Ext.each(e.items,function(e){if("finished"===e.status||!e.result||"download"===e.result.action)return void(e.result&&"download"===e.result.action&&SYNO.SDS.Drive.WebAPICore.send("delete_task",{task_id:e.result.task_id}));this.addTask(SYNO.SDS.Drive.TaskFactory.createBgTask({title:e.result.action,name:e.result.names,params:e.result.params,total:e.result.total_size,progress:e.progress,async_task_id:e.task_id,showProgress:!1,showStartToast:!1,pollingOnly:!0}))},this)},getTask:function(e){var t=this._getTaskType(e);return this.queue[t]?this.queue[t].get(e):null},addTask:function(e){e&&e.type&&this.queue[e.type]&&-1===this.queue[e.type].find(e.taskid)&&(e.taskmgr=this,this.queue[e.type].push(e),this.fireEvent("ontaskadd",e),this.statusBitset|=1<<this.queue[e.type].idx,this.appWindow.getEventMgr().fireEvent("bgtask_update",!0,!0))},addTasks:function(e){Ext.each(e,function(e){this.addTask(e)},this)},removeTask:function(e){var t=this._getTaskType(e);this.queue[t].remove(e),this.fireEvent("ontaskremove",e)},removeTasks:function(e){Ext.each(e,function(e){this.removeTask(e)},this)},restartTask:function(e){var t=this.getTask(e),i=t.clone();this.removeTask(e),this.addTask(i)},restartTasks:function(e){Ext.each(e,function(e){this.restartTask(e)},this)},onAllComplete:function(e){this.statusBitset&=~(1<<e.idx),0===this.statusBitset&&this.appWindow.getEventMgr().fireEvent("bgtask_update",void 0,!1)},_getTaskType:function(e){var t=e.indexOf("_");return-1===t?e:e.substr(0,t)}}),Ext.define("SYNO.SDS.Drive.TaskQueue",{extend:"Ext.util.Observable",autoStart:!0,maxConcurrency:-1,currentProcessing:0,queue:[],constructor:function(e){Ext.apply(this,e||{}),this.callParent(arguments)},push:function(e){if(-1!==this.find(e.taskid))return void SYNO.Debug.error("Task is already exist");this.queue.push(e),this.process(e)},get:function(e){var t=this.find(e);return this.queue[t]},remove:function(e){var t=this.find(e);if(-1!==t){var i=this.queue[t];this.queue.splice(t,1),i.stop(),i.destroy()}},clear:function(){this.queue=[]},find:function(e){var t=0;for(t=0;t<this.queue.length;++t)if(this.queue[t].taskid===e)return t;return-1},pause:function(){this.autoStart=!1},resume:function(){this.autoStart=!0},process:function(e){!this.autoStart||0===this.queue.length||-1!==this.maxConcurrency&&this.currentProcessing>=this.maxConcurrency||e&&(this.currentProcessing++,e.start().then(this._processNext.createDelegate(this,[e]),this._processNext.createDelegate(this,[e])))},_processNext:function(e){var t=null;return this.currentProcessing--,Ext.each(this.queue,function(e){if("wait"===e.status)return t=e,!1}),t?this.process(t):this.fireEvent("oncomplete",this),t}}),Ext.define("SYNO.SDS.Drive.UploadTaskQueue",{extend:"SYNO.SDS.Drive.TaskQueue",toastSuccTasks:[],toastErrTasks:[],notificationTasks:[],_processNext:function(e){var t=!0;"stopped"!==e.status&&("success"!==e.status?(this.toastErrTasks.push(e),this.notificationTasks.push(e)):this.toastSuccTasks.push(e)),null===this.callParent(arguments)&&(t=!1),this._showToast(t),this._sendNotification(t)},_showToast:function(e){if(this.delayToastTask&&(window.clearTimeout(this.delayToastTask),this.delayToastTask=null),e)return void(this.delayToastTask=this._showToast.defer(1500,this));Ext.isEmpty(this.toastSuccTasks)&&Ext.isEmpty(this.toastErrTasks)||(this.appWindow.getEventMgr().fireEvent("uploadcomplete",this.toastSuccTasks),SYNO.SDS.Drive.Utils.showToastMsg(this.appWindow,this.getToastMessage(),3e3),this.toastSuccTasks=[],this.toastErrTasks=[])},_sendNotification:function(e){if(this.delayNotifyTask&&(window.clearTimeout(this.delayNotifyTask),this.delayNotifyTask=null),e)return void(this.delayNotifyTask=this._sendNotification.defer(1e4,this));if(!Ext.isEmpty(this.notificationTasks)){var t=this.getNotificationData(this.notificationTasks);SYNO.SDS.Drive.WebAPICore.send("create_notification",{content:t,type:"drive#upload_task"}),this.notificationTasks=[]}},getToastMessage:function(){var e,t,i="",n="";return Ext.isEmpty(this.toastSuccTasks)||(t=1<this.toastSuccTasks.length,e=String.format("upload{0}_{1}",t?"_multi":"","success"),t||Ext.each(this.toastSuccTasks[0].name,function(e){""!==n&&(n+=", "),n+=SYNO.SDS.Drive.Utils.parseDisplayName(e)}),n=Ext.util.Format.htmlEncode(n),i=String.format(SYNO.SDS.Drive._T("task",e),t?this.toastSuccTasks.length:String.format('"{0}"',n))),Ext.isEmpty(this.toastErrTasks)||(Ext.isEmpty(i)||(i+="<br>"),t=1<this.toastErrTasks.length,e=String.format("upload{0}_{1}",t?"_multi":"","error"),t||Ext.each(this.toastErrTasks[0].name,function(e){""!==n&&(n+=", "),n+=SYNO.SDS.Drive.Utils.parseDisplayName(e)}),n=Ext.util.Format.htmlEncode(n),i+=String.format(SYNO.SDS.Drive._T("task",e),t?this.toastErrTasks.length:String.format('"{0}"',n))),i},getNotificationData:function(e){if(!Ext.isEmpty(e)){var t=e.map(function(e){return{context:{name:e.name,file_type:e.blUploadDir?"dir":"file"},code:e.errors[0].code}});return{action:"upload",names:t.map(function(e){return e.context.name}),errors:t,success:!1}}}}),Ext.define("SYNO.SDS.Drive.ImageLoaderQueue",{extend:"Ext.Component",maxImageRequest:24,constructor:function(e){this.queue=[],this.appWindow=e.appWindow,this.callParent(arguments),this.imageloader=SYNO.SDS.Drive.Utils.getImageLoader()},getTask:function(){return this.actionTask=this.actionTask||this.addTask({id:"drive_task_load_image",interval:17,run:this.loadImage,scope:this}),this.actionTask},findIndexOf:function(e){var t=0;for(t=0;t<this.queue.length;t++)if(this.queue[t].id===e)return t;return-1},addImage:function(e){var t=this.getTask();-1===this.findIndexOf(e)&&(this.queue.push(e),!1===t.running&&t.restart(!0))},removeImage:function(e){if(0!==this.queue.length){var t=this.findIndexOf(e);-1!==t&&(this.queue.splice(t,1),0===this.queue.length&&this.getTask().stop())}},removeAll:function(){this.queue=[],this.getTask().stop()},loadImage:function(){var e,t=0,i=Math.min(this.maxImageRequest,this.queue.length);for(t=0;t<i;t++)try{e=this.queue[t];var n=Ext.fly(e.id);n&&n.dom&&(n.dom.src=e.url,this.imageloader.loadImg(n.dom,e.listeners))}catch(e){SYNO.Debug.error(e)}this.queue.splice(0,i),0===this.queue.length&&this.getTask().stop()},stop:function(){this.getTask().stop()},destroy:function(){this.queue=null,this.actionTask&&(this.actionTask=null),this.callParent(arguments)}}),Ext.define("SYNO.SDS.Drive.VueModalWindow",{extend:"SYNO.SDS.ModalWindow",constructor:function(e){this.callParent([e])}}),Ext.define("SYNO.SDS.Drive.ModalWindow",{extend:"SYNO.SDS.Drive.VueModalWindow",constructor:function(e){var t=Ext.isString(e.cls)?e.cls+" syno-d-modal-window":"syno-d-modal-window";e.cls=t;var i=[{key:Ext.EventObject.ENTER,scope:this,fn:this.onEnter}];e.keys?Ext.isArray(e.keys)?e.keys=e.keys.concat(i):Ext.isObject(e.keys)&&(e.keys=i.push(e.keys)):e.keys=i,this.callParent([Ext.apply(this.fillWindowPadding({owner:SYNO.SDS.Drive.GetWindow(),closable:!0,closeAction:"onCancel",bodyBorder:!1,border:!1,width:560}),e)]),this.mon(this,"show",this.onWinShow,this)},checkEnterTarget:function(e){return"TEXTAREA"===e.getTarget().tagName},onEnter:function(e,t){this.maskCnt||this.checkEnterTarget(t)||(t.stopEvent(),this.onApply())},setStatus:function(e){e.duration&&window.setTimeout(function(){this.clearStatus()}.bind(this),e.duration),this.callParent(arguments)},onApply:Ext.emptyFn,onCancel:function(){this.close()},onWinShow:function(){}}),Ext.ns("SYNO.SDS.Drive"),Ext.define("SYNO.SDS.Drive.PasswordDialog",{extend:"SYNO.SDS.Drive.ModalWindow",constructor:function(e){this.pendingValidateCallback={},this.callParent([this.fillConfig(e)])},fillConfig:function(e){var t=new SYNO.SDS.Drive.PasswordDialog.Store({autoDestroy:!0,data:e.files,idProperty:"file_id",fields:[{name:"file_id"},{name:"name"},{name:"display_path"},{name:"file_type"},{name:"ntype",mapping:"name",convert:function(e,t){return SYNO.SDS.Drive.Utils.getNtype(e,t.file_type)}}]}),i={title:_T("common","enter_password_to_continue"),width:638,height:161+45*Math.min(8,Math.max(3,t.getCount())),buttons:[{xtype:"syno_button",text:SYNO.SDS.Drive._T("common","close"),scope:this,handler:this.close},{xtype:"syno_button",btnStyle:"default",text:_T("common","ok"),scope:this,handler:this.onApply}],layout:"fit",defaults:{border:!1},items:[{xtype:"syno_editorgrid",itemId:"grid",cls:"syno-d-mgr-export-password-grid",store:t,enableHdMenu:!1,clicksToEdit:1,colModel:new Ext.grid.ColumnModel({defaults:{menuDisabled:!0,resizable:!1},columns:[{width:300,header:_T("common","file_name"),dataIndex:"name",renderer:this.renderFileNameColumn},{width:198,header:_T("common","password"),renderer:this.renderPasswordColumn},{header:_T("common","action"),renderer:this.renderActionColumn,align:"center",listeners:{scope:this,click:this.skip}}]}),sm:new Ext.grid.RowSelectionModel({singleSelect:!0,handleMouseDown:Ext.emptyFn}),listeners:{scope:this,viewready:this.onViewReady},viewConfig:{forceFit:!0,listeners:{scope:this,refresh:function(e){var t=e.el.dom;Array.prototype.forEach.call(t.querySelectorAll("input[data-syno-file-id]"),this.addPasswordListener,this)},rowremoved:function(){this.setHeight(161+45*Math.min(8,Math.max(3,t.getCount())))}}}}]};return Ext.apply(i,e)},renderFileNameColumn:function(e,t,i,n,o,s){var r="";switch(i.data.ntype){case"odoc":r="syno-d-doc-menu-icon";break;case"osheet":r="syno-d-sheet-menu-icon";break;case"oslides":r="syno-d-slide-menu-icon"}return t.attr+='ext:qtip="'+Ext.util.Format.htmlEncode(Ext.util.Format.htmlEncode(SYNO.SDS.Drive.Utils.parseDisplayName(i.data.display_path)))+'"',"<span class="+r+">"+Ext.util.Format.htmlEncode(SYNO.SDS.Drive.Utils.parseDisplayName(e))+"</span>"},renderPasswordColumn:function(e,t,i,n,o,s){return'<input type="password" placeholder="'+_T("common","password")+'" size="20" data-syno-file-id="'+i.id+'" data-syno-state="idle">'},renderActionColumn:function(e,t,i,n,o,s){return'<a data-syno-file-id="'+i.id+'">'+_T("common","skip")+"</a>"},onViewReady:function(e){e.view.refresh(),e.view.scroller.dom.fleXcroll.formUpdate()},addPasswordListener:function(e){var t=this,i=!1;e.addEventListener("focus",function(){e.classList.add("syno-d-mgr-export-password-grid-input-focus")}),e.addEventListener("blur",function(){e.classList.remove("syno-d-mgr-export-password-grid-input-focus")}),e.addEventListener("keypress",function(e){i=!0}),e.addEventListener("keyup",function(n){(i||8===n.keyCode||46===n.keyCode)&&(i=!1,t.validatePassword(e,function(e,t){var i=t.parentElement;e?(t.itip="",i.classList.add("syno-d-mgr-export-password-valid"),i.classList.remove("syno-d-mgr-export-password-invalid")):(t.itip=_T("common","err_pass"),i.classList.remove("syno-d-mgr-export-password-valid"),i.classList.add("syno-d-mgr-export-password-invalid"))}))})},validatePassword:function(e,t){var i=e.getAttribute("data-syno-file-id");switch(e.getAttribute("data-syno-state")){case"idle":case"pending":e.setAttribute("data-syno-state","validating");break;case"validating":return e.setAttribute("data-syno-state","pending"),void(this.pendingValidateCallback[i]=t);default:return}SYNO.SDS.Office.GetAction().checkNodePassword({file_id:i,password:e.value},function(n,o){var s=this;switch(e.getAttribute("data-syno-state")){case"validating":e.setAttribute("data-syno-state","idle");break;case"pending":return void setTimeout(function(){t=s.pendingValidateCallback[i],delete s.pendingValidateCallback[i],s.validatePassword(e,t)},0)}t&&t(n,e)},this)},addNotDownloadFiles:function(e){this.other_files||(this.other_files=[]),this.other_files.push(e)},onApply:function(){var e={},t=!1;Ext.each(this.getComponent("grid").view.el.dom.querySelectorAll("input[data-syno-file-id]"),function(i){i.parentElement.classList.contains("syno-d-mgr-export-password-valid")||(t=!0);var n=i.value;n&&!i.parentElement.classList.contains("syno-d-mgr-export-password-invalid")?e[SYNO.SDS.Drive.Utils.getPathId(i.getAttribute("data-syno-file-id"))]=n:this.addNotDownloadFiles(i.getAttribute("data-syno-file-id"))},this),this.requestDownload(e,this.other_files,t)},skip:function(e,t,i,n){var o=n.getTarget();if(!o)return!1;var s=Ext.get(o);if(!s)return!1;if(!s.is("a"))return!1;var r,a,l=t.view.getRow(i),d=l.offsetHeight,c=[];l.addEventListener("transitionend",function(e){"opacity"===e.propertyName&&(t.store.removeAt(i),t.view.refresh(),c.forEach(function(e,i){var n=t.view.getRow(i).querySelector('input[type="password"]');n.value=e[0],e.length>1&&n.parentElement.classList.add(e[1])}))}),l.style.left="360px",l.style.opacity=0,r=l.querySelector('input[type="password"]'),this.addNotDownloadFiles(r.getAttribute("data-syno-file-id"));for(var h=0,u=t.store.getCount();h<u;++h)h!==i&&(l=t.view.getRow(h),r=l.querySelector('input[type="password"]'),a=[r.value],r.parentElement.classList.contains("syno-d-mgr-export-password-valid")?a.push("syno-d-mgr-export-password-valid"):r.parentElement.classList.contains("syno-d-mgr-export-password-invalid")&&a.push("syno-d-mgr-export-password-invalid"),c.push(a),h>i&&(l.style.top=-d+"px"))},requestDownload:function(e,t,i){this.fireEvent("apply",this,e,t||[],i)}}),Ext.define("SYNO.SDS.Drive.PasswordDialog.Store",{extend:"Ext.data.JsonStore",sortInfo:{field:"display_path",direction:"ASC"},createSortFunction:function(e,t){t=t||"ASC";var i="DESC"===t.toUpperCase()?-1:1,n=this.fields.get(e).sortType;return function(t,o){var s,r,a;return"display_path"!==e?(s=n(t.data[e]),r=n(o.data[e]),a=s>r?1:s<r?-1:0,i*a):(s=String(t.data[e]),r=String(o.data[e]),a=s.localeCompare(r),i*a)}}}),Ext.ns("SYNO.SDS.Drive.Crypto"),Ext.define("SYNO.SDS.Drive.Crypto.Utils",{statics:{isCryptoSupport:function(){var e=window.crypto||window.msCrypto;return!!e&&!!e.subtle},incrementNonce:function(e,t){for(var i=new Uint8Array(e.slice(0)),n=i.length-1;t>0&&n>=i.length-2;n--){var o=t+i[n];i[n]=o%256,t=Math.floor(o/256)}return i.buffer},importAes256GcmKey:function(e){return window.msCrypto?new Promise(function(t,i){try{var n=window.msCrypto.subtle.importKey("raw",e,{name:"AES-GCM",length:256},!1,["decrypt"]);n.oncomplete=function(e){t(e.target.result)},n.onerror=function(e){i()}}catch(e){i()}}):window.crypto.subtle.importKey("raw",e,{name:"AES-GCM",length:256},!1,["decrypt"])},_decryptAes256Gcm:function(e,t,i){var n={name:"AES-GCM",iv:i,tagLength:128};return window.msCrypto?new Promise(function(i,o){try{var s=e.subarray(e.length-16);n=Ext.apply(n,{tag:s});var r=window.msCrypto.subtle.decrypt(n,t,e.subarray(0,e.length-16));r.oncomplete=function(e){i(e.target.result)},r.onerror=function(e){o()}}catch(e){o()}}):window.crypto.subtle.decrypt(n,t,e)},decryptAes256Gcm:function(e,t,i){return new Promise(function(n,o){SYNO.SDS.Drive.Crypto.Utils._decryptAes256Gcm(e,t,i).then(function(e){n(e)}).catch(function(){o()})})}}}),Ext.define("SYNO.SDS.Drive.Crypto.HybridShareChunk",{DECRYPTED_MINI_CHUNK_MAX_LEN:8192,ENCRYPTED_MINI_CHUNK_MAX_LEN:8208,ABYTES:16,constructor:function(e,t,i){this.ciphertext=e,this.key=t,this.nonce=i,this.miniChunkCount=Math.ceil(e.length/parseFloat(this.ENCRYPTED_MINI_CHUNK_MAX_LEN)),this.processedCount=0},getExpectDecryptedChunkSize:function(){if(this.ciphertext.length%this.ENCRYPTED_MINI_CHUNK_MAX_LEN==0)return this.DECRYPTED_MINI_CHUNK_MAX_LEN*this.miniChunkCount;var e=this.ciphertext.length%this.ENCRYPTED_MINI_CHUNK_MAX_LEN-this.ABYTES;return e<0?-1:this.DECRYPTED_MINI_CHUNK_MAX_LEN*this.miniChunkCount+e},hasDecryptNext:function(){return this.processedCount<this.miniChunkCount},decryptNext:function(){if(!this.hasDecryptNext())return Promise.reject();var e=this.processedCount,t=e*this.ENCRYPTED_MINI_CHUNK_MAX_LEN,i=e*this.DECRYPTED_MINI_CHUNK_MAX_LEN,n=this.ciphertext.subarray(t,t+this.ENCRYPTED_MINI_CHUNK_MAX_LEN),o=this.key,s=SYNO.SDS.Drive.Crypto.Utils.incrementNonce(this.nonce,e);return this.processedCount++,SYNO.SDS.Drive.Crypto.Utils.decryptAes256Gcm(n,o,s).then(function(e){return{data:e,offset:i}})}}),Ext.define("SYNO.SDS.Drive.HybridShare.ChunkDownloader",{constructor:function(e,t){this.chunkInfo=e,this.file=t,this.processedSize=0},download:function(e){var t=this._base64ToArrayBuffer(this.chunkInfo.chunkKey),i=this._base64ToArrayBuffer(this.chunkInfo.chunkNonce),n=this.chunkInfo.chunkUrl,o=this.file,s=this.chunkInfo.fileOffset;return this.processedSize=0,this._downloadEncryptedChunk(n,e).then(function(e){return this._decryptChunk(e,t,i,o,s)}.bind(this))},_downloadEncryptedChunk:function(e,t){return new Promise(function(i,n){var o=new XMLHttpRequest;o.open("GET",e,!0),o.responseType="blob",o.onload=function(e){if(200!==e.target.status)return void n(!0);if(e.target.response.arrayBuffer)e.target.response.arrayBuffer().then(function(e){i(e)}).catch(function(){n(!1)});else{var t=new FileReader;t.onload=function(e){var t=e.target.result;i(t)},t.onerror=function(){n(!1)},t.readAsArrayBuffer(e.target.response)}};var s=0;o.onprogress=function(e){this.processedSize=.9*e.loaded;var i=(new Date).getTime();i-s>500&&(s=i,t())}.bind(this),o.onerror=function(){n(!0)};try{o.send()}catch(e){n(!0)}}.bind(this))},_decryptChunk:function(e,t,i,n,o){return new Promise(function(s,r){SYNO.SDS.Drive.Crypto.Utils.importAes256GcmKey(t).then(function(t){var a=new SYNO.SDS.Drive.Crypto.HybridShareChunk(new Uint8Array(e),t,i),l=a.getExpectDecryptedChunkSize(),d=function(e){if(e&&e.data){n.write(e.offset+o,new Uint8Array(e.data)).catch(r)}a.hasDecryptNext()?a.decryptNext().then(d).catch(r):n.fsync().then(function(){s(l)}).catch(r)};d()}).catch(r)})},_base64ToArrayBuffer:function(e){for(var t=window.atob(e),i=t.length,n=new Uint8Array(i),o=0;o<i;o++)n[o]=t.charCodeAt(o);return n.buffer}}),Ext.define("SYNO.SDS.Drive.HybridShare.Placeholder",{constructor:function(e,t){this.fileInfo=e,this.observer=t,this.chunkInfos=e.chunkInfos,this.downloadChunkCount=0,this.currentChunkDownloader=void 0,this.remainTotal=e.file.size,this.remainProcessed=0,this.isAbort=!1,this.file=void 0,this.fileInfo.finishedChunkCount&&(this.downloadChunkCount=this.fileInfo.finishedChunkCount,this.remainTotal=e.file.size-this.fileInfo.chunkInfos[this.downloadChunkCount].fileOffset)},fill:function(){this.isAbort||this._createFile().then(function(e){this.isAbort||(this.file=e,this._dispatchDownload())}.bind(this)).catch(function(){this.observer(SYNO.SDS.Drive.HybridShare.Status.ERROR)}.bind(this))},resume:function(){this._dispatchDownload()},getProgress:function(){var e=this.remainProcessed+this._getDownloadingChunkProgress(),t=this.fileInfo.file.size||1,i=t-this.remainTotal+e,n=100*i/t;return{progress:n<0?0:n,remainTotal:this.remainTotal,remainProcessed:e>this.remainTotal?this.remainTotal:e,total:t,totalProcessed:i>t?t:i}},abort:function(){this.isAbort=!0,this.file&&this.file.abort()},triggerDownload:function(){return Promise.reject()},_dispatchDownload:function(){if(!this.isAbort){if(this.downloadChunkCount<this.chunkInfos.length){var e=this.chunkInfos[this.downloadChunkCount];this.currentChunkDownloader=new SYNO.SDS.Drive.HybridShare.ChunkDownloader(e,this.file),this.currentChunkDownloader.download(function(){this.observer(SYNO.SDS.Drive.HybridShare.Status.PROGESSING)}.bind(this)).then(function(e){this.downloadChunkCount++,this.remainProcessed=this.remainProcessed+e,this.currentChunkDownloader=void 0,this.observer(SYNO.SDS.Drive.HybridShare.Status.PROGESSING),this._dispatchDownload()}.bind(this)).catch(function(t){if(this.currentChunkDownloader=void 0,e.errorCount++,!0===t&&e.errorCount<3)return void this.observer(SYNO.SDS.Drive.HybridShare.Status.ERROR,!0);this.observer(SYNO.SDS.Drive.HybridShare.Status.ERROR,!1)}.bind(this))}this.downloadChunkCount===this.chunkInfos.length&&this.observer(SYNO.SDS.Drive.HybridShare.Status.DONE)}},_getDownloadingChunkProgress:function(){return this.currentChunkDownloader&&this.currentChunkDownloader.processedSize>0?this.currentChunkDownloader.processedSize:0},_createFile:function(){}}),Ext.define("SYNO.SDS.Drive.FileSystem.File",{constructor:function(){this.abortFlag=!1},abort:function(){this.abortFlag=!0},isAbort:function(){return this.abortFlag},write:function(e,t){return Promise.reject()},fsync:function(){return Promise.reject()},toURL:function(){return""},toBlob:function(){}}),Ext.define("SYNO.SDS.Drive.FileSystem.Utils",{singleton:!0,getEmptyBuffer:function(){return this.emptyBuffer?this.emptyBuffer:(this.emptyBuffer=new Uint8Array(this.getEmptyBufferSize()),this.emptyBuffer)},getEmptyBufferSize:function(){return 1048576}}),Ext.define("SYNO.SDS.Drive.FileSystem.WriteEvent",{constructor:function(e,t,i,n,o){this.offset=e,this.data=t,this.length=i,this.successCallbacks=n,this.failCallbacks=o,this.retryQuota=3},notify:function(e){var t=e?this.successCallbacks:this.failCallbacks;Ext.each(t,function(e){e()})}}),Ext.define("SYNO.SDS.Drive.FileSystem.PersistentFile",{extend:"SYNO.SDS.Drive.FileSystem.File",constructor:function(e){this.callParent(arguments),this.file=e,this.writeEvents=[],this.isFlushing=!1,this.flushingObservers=[]},write:function(e,t){return this.isAbort()?Promise.reject():new Promise(function(i,n){this.writeEvents.push(new SYNO.SDS.Drive.FileSystem.WriteEvent(e,[t],t.length,[i],[n]))}.bind(this))},fsync:function(){return this.isAbort()?Promise.reject():this.isFlushing?new Promise(function(e,t){this.flushingObservers.push({resolve:e,reject:t})}.bind(this)):(this.isFlushing=!0,new Promise(function(e,t){this.flushingObservers.push({resolve:e,reject:t}),this._flushToDisk()}.bind(this)))},toURL:function(){return this.isAbort()?"":this.file.fileEntry.toURL()},_fillEmpty:function(e,t,i,n){for(var o=SYNO.SDS.Drive.FileSystem.Utils,s=t-e,r=o.getEmptyBuffer(),a=[];s>=r.length;)a.push(new SYNO.SDS.Drive.FileSystem.WriteEvent(t-s,[r],r.length,[i],[n])),s-=r.length;s>0&&a.push(new SYNO.SDS.Drive.FileSystem.WriteEvent(t-s,[new Uint8Array(s)],s,[i],[n])),this.writeEvents=a.concat(this.writeEvents)},_flushToDisk:function(){if(!this.isAbort())try{if(0===this.writeEvents.length)return this.isFlushing=!1,void this._notifyAll(!0);var e=this.writeEvents[0];if(this.file.fileWriter.seek(e.offset),this.file.fileWriter.position<e.offset)return this._fillEmpty(this.file.fileWriter.position,e.offset,Ext.emptyFn,Ext.emptyFn),void this._flushToDisk();e=this._mergeWriteEvent(),this.file.fileWriter.write(new Blob(e.data)),this.file.fileWriter.onwriteend=function(t){this.writeEvents.shift(),e.notify(!0),this._flushToDisk()}.bind(this),this.file.fileWriter.onerror=function(t){e.retryQuota>0?e.retryQuota=e.retryQuota-1:(this.isFlushing=!1,e.notify(!1),this._notifyAll(!1)),this._flushToDisk()}.bind(this)}catch(e){this._notifyAll(!1)}},_mergeWriteEvent:function(){for(var e=this.writeEvents[0],t=1,i=e.length,n=e.offset+e.length;t<this.writeEvents.length&&t<1024&&!(this.writeEvents[t].offset!==n||i+this.writeEvents[t].length>10485760);t++)n+=this.writeEvents[t].length,i+=this.writeEvents[t].length;if(1===t)return e;for(var o=e.offset,s=[],r=[],a=[],l=0,d=0;d<t;d++)s=s.concat(this.writeEvents[0].data),l+=this.writeEvents[0].length,r=r.concat(this.writeEvents[0].successCallbacks),a=a.concat(this.writeEvents[0].failCallbacks),this.writeEvents.shift();var c=new SYNO.SDS.Drive.FileSystem.WriteEvent(o,s,l,r,a);return this.writeEvents.unshift(c),c},_notifyAll:function(e){if(!this.isAbort()){var t=this.flushingObservers.slice();this.flushingObservers=[],t.forEach(function(t){e?t.resolve():t.reject()})}}}),
Ext.define("SYNO.SDS.Drive.FileSystem.FileManger",{singleton:!0,constructor:function(){this.fileSystem=void 0,this.driveFolder=void 0,this.askQuota=107374182400,this.realQuota=0,this.dirName="drive"},isSupportFileSystemAPI:function(){return Ext.isFunction(window.webkitRequestFileSystem)},openFile:function(e,t,i){var n=this;return new Promise(function(o,s){n._initialize().then(function(){return n._getQuotaInfo()}).then(function(e){if(e.grantedBytes-e.usedBytes<=t)return void s()}).then(function(){var t=n.driveFolder.name+"/"+e;return new Promise(function(e,o){n.fileSystem.root.getFile(t,{create:i},function(t){e(t)},o)})}).then(function(e){e.createWriter(function(t){var i={fileEntry:e,fileWriter:t},n=new SYNO.SDS.Drive.FileSystem.PersistentFile(i);o(n)})}).catch(s)})},checkFileExist:function(e){return new Promise(function(t,i){this._initialize().then(function(){var i=this.driveFolder.name+"/"+e;this.fileSystem.root.getFile(i,{create:!1},function(e){t(!0)},function(){t(!1)})}.bind(this)).catch(i)}.bind(this))},cleanupFileSystem:function(e){return this._initialize().then(function(){this.driveFolder.createReader().readEntries(function(t){for(var i=0;i<t.length;i++){var n=t[i];n.isDirectory||e&&-1!==e.indexOf(n.name)||n.remove(Ext.emptyFn)}})}.bind(this))},_initialize:function(){return void 0!==this.fileSystem&&void 0!==this.driveFolder?Promise.resolve():this._initializeFileSystem().then(function(){return this._initializeDriveFolder()}.bind(this))},_initializeFileSystem:function(){return new Promise(function(e,t){navigator.webkitPersistentStorage.requestQuota(this.askQuota,function(i){if(!i||0===i)return void t();this.realQuota=i,window.webkitRequestFileSystem(window.PERSISTENT,this.realQuota,function(t){this.fileSystem=t,e(this.fileSystem)}.bind(this),t)}.bind(this),t)}.bind(this))},_initializeDriveFolder:function(){return new Promise(function(e,t){this.fileSystem.root.getDirectory(this.dirName,{create:!0},function(t){this.driveFolder=t,e(this.driveFolder)}.bind(this),function(e){t(e)})}.bind(this))},_getQuotaInfo:function(){return new Promise(function(e,t){navigator.webkitPersistentStorage.queryUsageAndQuota(function(t,i){e({usedBytes:t,grantedBytes:i})},t)})},_deleteDriveFolder:function(){this._initialize().then(function(){this.driveFolder.removeRecursively(function(){this.driveFolder=void 0}.bind(this),Ext.emptyFn)})}}),Ext.define("SYNO.SDS.Drive.HybridShare.FileSystem.Placeholder",{extend:"SYNO.SDS.Drive.HybridShare.Placeholder",constructor:function(e,t){return this.callParent(arguments)},_createFile:function(){if(!this.isAbort){var e=this.fileInfo.finishedChunkCount>0;return SYNO.SDS.Drive.FileSystem.FileManger.openFile(this.fileInfo.tmpFileName,this.fileInfo.file.size,!e)}},triggerDownload:function(){var e=document.createElement("a");return e.href=this.file.toURL(),e.download=this.fileInfo.file.name,document.getElementsByTagName("BODY")[0].appendChild(e),e.click(),Promise.resolve()}}),Ext.define("SYNO.SDS.Drive.HybridShare.ChunkInfo",{statics:{convertToChunkInfos:function(e){for(var t=[],i=0;i<e.length;i++)t.push(new SYNO.SDS.Drive.HybridShare.ChunkInfo(i,e[i]));return t},updateChunkInfosByWebapiResponse:function(e,t){if(e.length!==t.length)return!1;for(var i=0;i<e.length;i++){if(e[i].chunkId!==t[i].chunk_id)return!1;e[i].chunkUrl=t[i].chunk_url}return!0}},constructor:function(e,t){this.index=e,this.chunkId=t.chunk_id,this.chunkKey=t.chunk_key,this.chunkNonce=t.chunk_nonce,this.chunkUrl=t.chunk_url,this.dependentIdxs=t.dependent_idxs,this.fileOffset=t.file_offset,this.errorCount=0},toString:function(){var e={index:this.index,chunkId:this.chunkId,chunkKey:this.chunkKey,chunkNonce:this.chunkNonce,chunkUrl:this.chunkUrl,dependentIdxs:this.dependentIdxs,fileOffset:this.fileOffset,errorCount:this.errorCount};return JSON.stringify(e)}}),Ext.define("SYNO.SDS.Drive.HybridShare.FileInfo",{statics:{FORMAT_VERSION:1,PREFIX:"drive-",STATUS_NEW:1,STATUS_DOWNLOADING:2,STATUS_DOWNLOADED:3,STATUS_PAUSE:4,STATUS_DELETE:5,get:function(e){var t=new SYNO.SDS.Drive.HybridShare.FileInfo;if(t.parse(window.localStorage.getItem(e)))return t.key=e,t},getByFileName:function(e){return SYNO.SDS.Drive.HybridShare.FileInfo.get(SYNO.SDS.Drive.HybridShare.FileInfo.PREFIX+e)},isFileInfo:function(e){var t=SYNO.SDS.Drive.HybridShare.FileInfo.PREFIX;return e.substring(0,t.length)===t},remove:function(e){return window.localStorage.removeItem(e)},fetchFileInfos:function(){for(var e=[],t=[],i=[],n=(new Date).getTime(),o=0;o<window.localStorage.length;o++){var s=window.localStorage.key(o);if(SYNO.SDS.Drive.HybridShare.FileInfo.isFileInfo(s)){var r=SYNO.SDS.Drive.HybridShare.FileInfo.get(s);if(!r)continue;var a=n-r.lastUpdateTime;r.status===SYNO.SDS.Drive.HybridShare.FileInfo.STATUS_PAUSE&&r.finishedChunkCount>2?t.push(r):a<5e3?e.push(r):r.status===SYNO.SDS.Drive.HybridShare.FileInfo.STATUS_DOWNLOADED&&a<6e4?e.push(r):r.status===SYNO.SDS.Drive.HybridShare.FileInfo.STATUS_DOWNLOADING&&a<3e5?e.push(r):i.push(r)}}return{skippedList:e,resumableList:t,needRemoveList:i}}},constructor:function(e,t,i,n,o,s){this.formatVersion=SYNO.SDS.Drive.HybridShare.FileInfo.FORMAT_VERSION,this.key=SYNO.SDS.Drive.HybridShare.FileInfo.PREFIX+e,this.tmpFileName=e,this.file=t,this.lastUpdateTime=o||(new Date).getTime(),this.finishedChunkCount=n||0,this.status=s||SYNO.SDS.Drive.HybridShare.FileInfo.STATUS_NEW,this.chunkCount=i?i.length:0,this.chunkInfos=i,this.lastPersistTime=0,this.skipPersistentCount=0},persistent:function(){this.lastPersistTime=(new Date).getTime(),this.skipPersistentCount=0;var e=!0;try{window.localStorage.setItem(this.key,this.serialize())}catch(t){e=!1}return e},lazyPersistent:function(){return this.lastUpdateTime-this.lastPersistTime>1e3||this.skipPersistentCount>10?this.persistent():(this.skipPersistentCount=this.skipPersistentCount+1,!0)},serialize:function(){return JSON.stringify([this.formatVersion,this.tmpFileName,this.file,this.chunkCount,this.status,this.finishedChunkCount,this.lastUpdateTime])},parse:function(e){try{var t=JSON.parse(e);if(t[0]===SYNO.SDS.Drive.HybridShare.FileInfo.FORMAT_VERSION)return this.formatVersion=t[0],this.tmpFileName=t[1],this.file=t[2],this.chunkCount=t[3],this.status=t[4],this.finishedChunkCount=t[5],this.lastUpdateTime=t[6],!0}catch(e){}return!1},delete:function(){return SYNO.SDS.Drive.HybridShare.FileInfo.remove(this.key)},updateProgress:function(e,t,i){var n=!0;this.status=e,this.lastUpdateTime=(new Date).getTime();var o=e===SYNO.SDS.Drive.HybridShare.FileInfo.STATUS_DOWNLOADING;return o&&(this.finishedChunkCount=i),t&&(n=o?this.lazyPersistent():this.persistent()),n}}),Ext.define("SYNO.SDS.Drive.HybridShare.FileSystem.DownloadTask",{extend:"SYNO.SDS.Drive.HybridShare.DownloadTask",constructor:function(e){this.callParent([e]),this.type=SYNO.SDS.Drive.HybridShare.DownloadTask.FILE_SYSTEM,this.persistentDownloadProgress=!0},_createPlaceholder:function(e){return new SYNO.SDS.Drive.HybridShare.FileSystem.Placeholder(this.fileInfo,e)}}),Ext.define("SYNO.SDS.Drive.FileSystem.BlobHelper",{singleton:!0,constructor:function(){this.worker=void 0,this.requestMap={},this.requestId=1},_getWorker:function(){return this.worker?this.worker:(this.worker=new Worker("webman/3rdparty/SynologyDrive-Drive/blob_worker.js"),this.worker.onmessage=this.onmessage.bind(this),this.worker)},onmessage:function(e){var t=e.data.requestId;t&&t in this.requestMap&&(e.data.success?this.requestMap[t].resolve(new Blob([e.data.buffer])):this.requestMap[t].reject(),delete this.requestMap[t])},concatBlob:function(e){var t=this.requestId++;return new Promise(function(i,n){for(var o=[],s=0;s<e.length;s++)o.push(e[s].buffer);this.requestMap[t]={resolve:i,reject:n},this._getWorker().postMessage({requestId:t,graduallyConcat:Ext.isIE||Ext.isIE11||Ext.isIE12,blobArray:e},o)}.bind(this))}}),Ext.define("SYNO.SDS.Drive.FileSystem.MemoryFile",{extend:"SYNO.SDS.Drive.FileSystem.File",constructor:function(){this.callParent(arguments),this.fileChunks=[],this.wholeFile=void 0,this.currentLen=0},write:function(e,t){if(this.isAbort())return Promise.reject();try{if(e===this.currentLen)this.fileChunks.push(t),this.currentLen=e+t.length;else if(e>this.currentLen)this.fileChunks.push(new Uint8Array(e-this.currentLen)),this.fileChunks.push(t),this.currentLen=e+t.length;else{for(var i=0,n=0,o=0;o<this.fileChunks.length;o++){var s=this.fileChunks[o];if(s.length+n>e)if(0===i&&t.length===s.length)this.fileChunks[o]=t,i=t.length;else for(var r=n>e?0:e-n,a=i,l=0;a+l<t.length&&r+l<s.length;l++)s[r+l]=t[a+l],i++;if(n+=s.length,i>=t.length)break}if(i<t.length){for(var d=new Uint8Array(t.length-i),c=i;c<t.length;c++)d[c]=t[t.length-i+c];this.fileChunks.push(d),this.currentLen=this.currentLen+t.length-i}}}catch(e){return Promise.reject()}return Promise.resolve()},fsync:function(){return Promise.resolve()},toBlob:function(){if(!this.isAbort())return SYNO.SDS.Drive.FileSystem.BlobHelper.concatBlob(this.fileChunks)}}),Ext.define("SYNO.SDS.Drive.HybridShare.Memory.Placeholder",{extend:"SYNO.SDS.Drive.HybridShare.Placeholder",constructor:function(e,t){return this.callParent(arguments)},_createFile:function(){if(!this.isAbort){var e=new SYNO.SDS.Drive.FileSystem.MemoryFile(this.chunkInfos.length);return Promise.resolve(e)}},triggerDownload:function(){var e=this.fileInfo.file.name,t=this.file;return new Promise(function(i,n){t.toBlob().then(function(t){if(navigator.msSaveBlob)return navigator.msSaveBlob(t,e),void i();var n=document.createElement("a");n.href=window.URL.createObjectURL(t),n.download=e,document.getElementsByTagName("BODY")[0].appendChild(n),n.click(),i()}).catch(n)})}}),Ext.define("SYNO.SDS.Drive.HybridShare.Memory.DownloadTask",{extend:"SYNO.SDS.Drive.HybridShare.DownloadTask",constructor:function(e){this.callParent([e]),this.type=SYNO.SDS.Drive.HybridShare.DownloadTask.MEMORY},_createPlaceholder:function(e){return new SYNO.SDS.Drive.HybridShare.Memory.Placeholder(this.fileInfo,e)}}),Ext.define("SYNO.SDS.Drive.HybridShare.TaskDispatcher",{constructor:function(e){this.appWindow=e.appWindow,this.offloadDownloader=e.offloadDownloader,this.currentRunningTask=void 0,this.waitingQueue=[],SYNO.SDS.Drive.FileSystem.FileManger.isSupportFileSystemAPI()&&window.addEventListener("unload",this._suspendTask.bind(this)),SYNO.SDS.StatusNotifier.on("beforeunload",function(){return!this.currentRunningTask}.bind(this))},startTask:function(e){this.currentRunningTask&&SYNO.SDS.Drive.Utils.showToastMsg(this.appWindow,SYNO.SDS.Drive._T("task","download_from_remote_queue"),3e3),this.waitingQueue.push({task:e}),this._dispatchTask()},stopTask:function(e){if(e.abort(),this.currentRunningTask===e)this.currentRunningTask=void 0,this._dispatchTask();else for(var t=0;t<this.waitingQueue.length;t++)if(this.waitingQueue[t].task===e){this.waitingQueue.splice(t,1);break}},fallBackTask:function(e){window.setTimeout(function(){this.offloadDownloader.download({data:e.fileInfo.file},!0)}.bind(this),1e3),this.stopTask(e)},finishTask:function(e){this.stopTask(e)},_dispatchTask:function(){if(!this.currentRunningTask&&0!==this.waitingQueue.length){var e=this.waitingQueue.shift().task;this.currentRunningTask=e,e.type===SYNO.SDS.Drive.HybridShare.DownloadTask.FILE_SYSTEM?this._cleanFileSystem().then(e.start.bind(e)).catch(e.start.bind(e)):e.start()}},_cleanFileSystem:function(){if(SYNO.SDS.Drive.FileSystem.FileManger.isSupportFileSystemAPI()){for(var e=SYNO.SDS.Drive.HybridShare.FileInfo.fetchFileInfos(),t=0;t<e.needRemoveList.length;t++){e.needRemoveList[t].delete()}for(var i=e.skippedList.concat(e.resumableList),n=[],o=0;o<i.length;o++)n.push(i[o].tmpFileName);return SYNO.SDS.Drive.FileSystem.FileManger.cleanupFileSystem(n)}return Promise.resolve()},_suspendTask:function(){this.currentRunningTask&&this.currentRunningTask.suspend()}}),Ext.define("SYNO.SDS.Drive.HybridShare.OffloadDownloader",{statics:{FILE_SIZE_HARD_LIMIT:5368709120,FILE_SIZE_DEFAULT_LIMIT:1073741824,FILE_SIZE_DEFAULT_LIMIT_FOR_IE:104857600,FILE_SIZE_THRESHOLD_FOR_USING_FILE_SYSTEM:1073741824,TYPE_NONE:0,TYPE_MEM:1,TYPE_FS:2},constructor:function(e){this.appWindow=e.appWindow,this.dispatcher=new SYNO.SDS.Drive.HybridShare.TaskDispatcher(Ext.apply(e,{offloadDownloader:this})),this._checkResumableTask()},download:function(e,t){var i={};i.files=[SYNO.SDS.Drive.Utils.getPathId(e.data.file_id)],i.force_download=!0,i.json_error=!0,i.download_type="download",t||(i.c2_offload=Ext.isIE||Ext.isIE11?"force":"allow");var n=function(){this.download(e,!0)}.bind(this);if(SYNO.SDS.Drive.Utils.showToastMsg(this.appWindow,SYNO.SDS.Drive._T("common","preparing_download"),3e3),t||!Ext.isIE&&!Ext.isIE11)return void SYNO.SDS.Drive.WebAPICore.download("download_files",i,e.data.name,function(e){if(!e||!e.file||!e.chunks||0===e.chunks.length)return void(t?SYNO.SDS.Drive.Utils.showErrorMsg(this.appWindow,e):n());this._startDownloadTask(e.file,e.chunks)||n()}.bind(this));SYNO.SDS.Drive.WebAPICore.sendPromise("download_files",i).then(function(e){if(!e||!e.file||!e.chunks||0===e.chunks.length)return void n();this._startDownloadTask(e.file,e.chunks)||n()}.bind(this)).catch(n)},isOffloadSupport:function(e){if(SYNO.SDS.Drive.Utils.isMobile())return!1;if(navigator.hardwareConcurrency&&navigator.hardwareConcurrency<=2)return!1;if(Ext.isIE||Ext.isIE11)return!1;if(!SYNO.SDS.Drive.Crypto.Utils.isCryptoSupport())return!1;if(1!==e.length)return!1;var t=!1,i=!1,n=!1;return Ext.each(e,function(e){return"dir"===e.data.type?(t=!0,!1):SYNO.SDS.Drive.Utils.isOfficeFile(e.data.name)?(i=!0,!1):e.data.removed?(n=!0,!1):void 0}),!(t||i||n)&&this._checkDownloadType(e[0].data.size)!==SYNO.SDS.Drive.HybridShare.OffloadDownloader.TYPE_NONE},_checkResumableTask:function(){setTimeout(function(){if(!SYNO.SDS.Drive.WindowHelper.isPublicShare()&&this._isSupportFileSystemAPI()){var e=SYNO.SDS.Drive.HybridShare.FileInfo.fetchFileInfos();if(e.resumableList.length>0){var t=e.resumableList[0];this._resumeDownload(t)}}}.bind(this),1500)},_resumeDownload:function(e){var t=function(){e.updateProgress(SYNO.SDS.Drive.HybridShare.FileInfo.STATUS_DELETE,!0)},i=this._startResumeDownloadTask.bind(this),n=this.appWindow;SYNO.SDS.Drive.FileSystem.FileManger.checkFileExist(e.tmpFileName).then(function(i){if(!i)return void t();var n={};return n.files=[SYNO.SDS.Drive.Utils.getPathId(e.file.file_id)],n.force_download=!0,n.json_error=!0,n.c2_offload="force",SYNO.SDS.Drive.WebAPICore.sendPromise("download_files",n)}).then(function(o){return o&&o.file&&o.chunks&&0!==o.chunks.length?e.file.hash!==o.file.hash||e.file.name!==o.file.name?void t():void n.getMsgBox({preventDelay:!0}).confirm("",String.format(SYNO.SDS.Drive._T("task","download_from_remote_resume"),Ext.util.Format.htmlEncode(e.file.name)),function(n){"yes"===n?(e.file=o.file,e.chunkInfos=SYNO.SDS.Drive.HybridShare.ChunkInfo.convertToChunkInfos(o.chunks),i(e)):t()}):void t()}).catch(t)},_startResumeDownloadTask:function(e){var t=this._requestDownloadTask(e,SYNO.SDS.Drive.HybridShare.OffloadDownloader.TYPE_FS),i=SYNO.SDS.Drive.TaskFactory.createHybridShareDownloadTask(this.appWindow,e.file.name,t,this.dispatcher);this.appWindow.getTaskMgr().addTask(i)},_isSupportFileSystemAPI:function(){return SYNO.SDS.Drive.FileSystem.FileManger.isSupportFileSystemAPI()},_startDownloadTask:function(e,t){var i=SYNO.SDS.Drive.Utils.genRandomStr(),n=SYNO.SDS.Drive.HybridShare.ChunkInfo.convertToChunkInfos(t),o=new SYNO.SDS.Drive.HybridShare.FileInfo(i,e,n),s=this._requestDownloadTask(o);if(!s)return!1;var r=SYNO.SDS.Drive.TaskFactory.createHybridShareDownloadTask(this.appWindow,e.name,s,this.dispatcher);return this.appWindow.getTaskMgr().addTask(r),!0},_requestDownloadTask:function(e,t){var i=t||this._checkDownloadType(e.file.size);return i===SYNO.SDS.Drive.HybridShare.OffloadDownloader.TYPE_MEM?new SYNO.SDS.Drive.HybridShare.Memory.DownloadTask({appWindow:this.appWindow,fileInfo:e}):i===SYNO.SDS.Drive.HybridShare.OffloadDownloader.TYPE_FS?new SYNO.SDS.Drive.HybridShare.FileSystem.DownloadTask({appWindow:this.appWindow,fileInfo:e}):void 0},_checkDownloadType:function(e){var t=this.appWindow.appInstance.getUserSettings("offload_setting");if(t&&-1!==["disable","file_system","memory"].indexOf(t))return"disable"===t?SYNO.SDS.Drive.HybridShare.OffloadDownloader.TYPE_NONE:"file_system"===t&&this._isSupportFileSystemAPI()?SYNO.SDS.Drive.HybridShare.OffloadDownloader.TYPE_FS:SYNO.SDS.Drive.HybridShare.OffloadDownloader.TYPE_MEM;if(e>=SYNO.SDS.Drive.HybridShare.OffloadDownloader.FILE_SIZE_HARD_LIMIT)return SYNO.SDS.Drive.HybridShare.OffloadDownloader.TYPE_NONE;var i=Ext.isIE||Ext.isIE11?SYNO.SDS.Drive.HybridShare.OffloadDownloader.FILE_SIZE_DEFAULT_LIMIT_FOR_IE:SYNO.SDS.Drive.HybridShare.OffloadDownloader.FILE_SIZE_DEFAULT_LIMIT,n=navigator.deviceMemory;return n&&n>0&&(i=1024*n*1024*1024*.25),e>i&&!this._isSupportFileSystemAPI()?SYNO.SDS.Drive.HybridShare.OffloadDownloader.TYPE_NONE:e>SYNO.SDS.Drive.HybridShare.OffloadDownloader.FILE_SIZE_THRESHOLD_FOR_USING_FILE_SYSTEM&&this._isSupportFileSystemAPI()?SYNO.SDS.Drive.HybridShare.OffloadDownloader.TYPE_FS:SYNO.SDS.Drive.HybridShare.OffloadDownloader.TYPE_MEM}}),Ext.define("SYNO.SDS.Drive.ActionHandler.Download",{constructor:function(e){this.appWindow=e.appWindow,this.officeDownloader=e.officeDownloader,SYNO.SDS.Drive.Utils.isDrivePage()&&(this.offloadDownloader=this.appWindow.getDownloadMgr()||new SYNO.SDS.Drive.HybridShare.OffloadDownloader(e))},findAppWindow:function(){return this.appWindow||SYNO.SDS.Drive.GetWindow()},setTarget:function(e){this.target=e},resetTarget:function(){this.target=null},getTargets:function(){return this.target?this.target:this.findAppWindow().getPanel().getSelections()},getTargetFileIds:function(){return this.getTargets().map(function(e){return e.get("file_id")})},downloadFileVersion:function(e,t,i,n){e=Ext.apply(e,{json_error:!0,download_type:"download"}),SYNO.SDS.Drive.Utils.showToastMsg(this.findAppWindow(),SYNO.SDS.Drive._T("common","preparing_download"),3e3),SYNO.SDS.Drive.WebAPICore.download("download_revisions",e,t,i,n)},downloadNodes:function(e){var t=!1;if(Ext.each(e,function(e){if(SYNO.SDS.Drive.Utils.isOfficeFile(e.data.name))return t=!0,!1}),t&&!SYNO.SDS.Drive.Utils.hasOffice()){var i=SYNO.SDS.Drive._T("app","install_office_alert");return SYNO.SDS.Drive.Define.Info.office_migration&&(i=SYNO.SDS.Drive._T("app","migration_office")),void SYNO.SDS.Drive.Utils.showAlertMsg(this.findAppWindow(),i)}if(1===e.length)return this.downloadNode(e[0]);var n=this.findAppWindow().getNavigation(),o=n.getLastPath().text,s=[],r=[];return Ext.each(e,function(e){var t=e.data.file_id;s.push(t),r.push({file_id:t,name:e.data.name})}),this.downloadAsZip(o,r,{file_id:s},"recycle"===n.getCategory())},downloadAsZip:function(e,t,i,n){i=Ext.apply({dry_run:!0,archive_name:e,download_type:"download"},SYNO.SDS.Drive.Utils.prepareRequestParams(i)),i.force_download=!0,i.json_error=!0;var o,s,r=e+".zip";n?(s=i.files,i.files=[],Ext.each(s,function(e){i.files.push({path:e,version_id:0})}),o="download_revisions"):o="download_files";var a=[];SYNO.SDS.Drive.WebAPICore.send(o,i,function(e,n){if(!e)return void SYNO.SDS.Drive.Utils.showErrorMsg(this.findAppWindow(),n);if(delete i.dry_run,n.result&&0<n.result.length){if(!SYNO.SDS.Drive.Utils.hasOffice())return void(SYNO.SDS.Drive.Define.Info.office_migration?SYNO.SDS.Drive.Utils.showAlertMsg(this.findAppWindow(),SYNO.SDS.Drive._T("app","migration_office")):SYNO.SDS.Drive.Utils.showAlertMsg(this.findAppWindow(),SYNO.SDS.Drive._T("app","install_office_alert")));showPasswordDialog(n.result,function(e,n,s,l){if(Ext.each(t,function(e){-1===s.indexOf(e.file_id)&&a.push(e.name)}),Ext.isEmpty(a))return void e.setStatusError({text:_T("common","err_pass"),clear:!0});if(i.decrypt=n,l){var d=function(t){"yes"===t&&(e.close(),this._postDownloadNodes(o,i,a,r))};e.getMsgBox().confirm("",SYNO.SDS.Drive._T("confirm","no_password"),d,this)}else e.close(),this._postDownloadNodes(o,i,a,r)},this)}else a=t.map(function(e){return e.name}),this._postDownloadNodes(o,i,a,r)},this)},downloadNode:function(e){var t=SYNO.SDS.Drive.Utils.getNtype(e.data.name,e.data.type);switch(SYNO.SDS.Drive.Utils.getFileTypeMapping(t)){case"dir":var i=this.findAppWindow().getNavigation(),n=e.data.name;return void this.downloadAsZip(n,[{file_id:e.data.file_id,name:n}],{file_id:this.getTargetFileIds()||[e.data.file_id]},"recycle"===i.getCategory());case"office":return SYNO.SDS.Drive.Utils.hasOffice()?this.officeDownloader.downloadOffice(e):void(SYNO.SDS.Drive.Define.Info.office_migration?SYNO.SDS.Drive.Utils.showAlertMsg(this.findAppWindow(),SYNO.SDS.Drive._T("app","migration_office")):SYNO.SDS.Drive.Utils.showAlertMsg(this.findAppWindow(),SYNO.SDS.Drive._T("app","install_office_alert")));case"regular":return SYNO.SDS.Drive.Utils.isDrivePage()&&this._allowOffload([e])?this.offloadDownloader.download(e):this._downloadFile(SYNO.SDS.Drive.Utils.getPathId(e.data.file_id),e.data.name,e.data.removed)}},_downloadFile:function(e,t,i){var n={download_type:"download"};i?(n.files=[{path:e,version_id:0}],this.downloadFileVersion(n,t)):(n.files=[e],n.force_download=!0,n.json_error=!0,SYNO.SDS.Drive.Utils.showToastMsg(this.findAppWindow(),SYNO.SDS.Drive._T("common","preparing_download"),3e3),SYNO.SDS.Drive.WebAPICore.download("download_files",n,t))},_postDownloadNodes:function(e,t,i,n){i=Ext.isArray(i)?i:[i],this.findAppWindow().getTaskMgr().addTask(SYNO.SDS.Drive.TaskFactory.createDownloadBgTask({title:"download",params:t,name:i},e,n))},_allowOffload:function(e){return!!this.offloadDownloader.isOffloadSupport(e)&&"disallow"!==this.findAppWindow().appInstance.getUserSettings("offload_setting")}}),Ext.define("SYNO.SDS.Drive.ActionHandler.C2Transfer",{constructor:function(e){this.appWindow=e.appWindow},findAppWindow:function(){return this.appWindow||SYNO.SDS.Drive.GetWindow()},_checkSelections:function(e){var t=!1,i=!1,n=[],o=[],s=!1;return Ext.each(e,function(e){var s=e.data.file_id;n.push(s),o.push({file_id:s,name:e.data.name}),!t&&SYNO.SDS.Drive.Utils.isOfficeFile(e.data.name)&&(t=!0),i||!e.get("enable_watermark")||e.get("capabilities").can_write&&!e.get("force_watermark_download")||(i=!0)}),e&&1===e.length&&"file"===e[0].get("type")&&(s=!0),{hasOfficeFile:t,param:{file_id:n},fileInfos:o,isSingleFile:s,enableWatermark:i}},sendCopy:function(e){if(0!==e.length){var t=this._checkSelections(e);if(t.hasOfficeFile&&!SYNO.SDS.Drive.Utils.hasOffice()){var i=SYNO.SDS.Drive._T("app","install_office_alert");return SYNO.SDS.Drive.Define.Info.office_migration&&(i=SYNO.SDS.Drive._T("app","migration_office")),void SYNO.SDS.Drive.Utils.showAlertMsg(this.findAppWindow(),i)}if(t.isSingleFile)return void this.transferNodes(t,showSinglePasswordDialog.bind(this),this.handleSingleEncryptFile.bind(this));this.transferNodes(t,showPasswordDialog.bind(this),this.handleEncryptFiles.bind(this,t.fileInfos))}},_requestTransfer:function(e,t,i){t||(t={}),t.c2_transfer=!0,t.convert_office_file=!0,t.json_error=!0,SYNO.SDS.Drive.Utils.showToastMsg(this.findAppWindow(),SYNO.SDS.Drive._T("common","preparing_transfer"),3e3);var n=document.querySelector(".syno-d-c2-transfer-btn");n&&n.classList.add("active"),this.remainingTransferCount||(this.remainingTransferCount=0),this.remainingTransferCount++;var o=this;this.openC2webWindow("/drive/create-task","?c2_kwdmga_uhid="+(o.appWindow.send_copy_enc_syno_uid||"")).then(function(i){return o.event=i,new Promise(function(i,n){SYNO.SDS.Drive.WebAPICore.send(e,t,function(e,t){if(!e)return SYNO.Debug("C2 Transfer response:",t),void n(t);if(t&&t.async_task_id){var s=function(e,o){return e&&o&&o.result?o.result.errors?(SYNO.Debug("taskID["+t.async_task_id+"]:",o),void n(o.result.errors[0])):void i(t):void n({code:1e3})};o.getTaskResult(t.async_task_id,s)}else i(t)})})}).then(function(e){o.output_dir_path=e.output_dir_path}).catch(function(e){n&&n.classList.remove("active"),o.event.source.closed||o.event.source.close(),SYNO.SDS.Drive.Utils.showErrorMsg(SYNO.SDS.Drive.GetWindow(),e)})},handleSingleEncryptFile:function(e,t,i,n,o,s){t.decrypt={},t.decrypt[o]=s,n._requestTransfer(e,t,i)},handleEncryptFiles:function(e,t,i,n,o,s,r,a){var l=[];if(Ext.each(e,function(e){-1===r.indexOf(e.file_id)&&l.push(e.name)}),Ext.isEmpty(l))return void o.setStatusError({text:_T("common","err_pass"),clear:!0});if(i.decrypt=s,a){var d=function(e){"yes"===e&&(o.close(),this._requestTransfer(t,i,n))};o.getMsgBox().confirm("",SYNO.SDS.Drive._T("confirm","no_password_send"),d,this)}else o.close(),this._requestTransfer(t,i,n)},transferNodes:function(e,t,i){var n="download_files",o=this.findAppWindow().getNavigation().getLastPath().text,s=Ext.apply({dry_run:!0,archive_name:o,download_type:"download"},SYNO.SDS.Drive.Utils.prepareRequestParams(e.param)),r=function(e){SYNO.SDS.Drive.Utils.showErrorMsg(this.findAppWindow(),e)}.bind(this),a=function(t,i,o){if(delete s.dry_run,o.result&&0<o.result.length){if(!SYNO.SDS.Drive.Utils.hasOffice())return void(SYNO.SDS.Drive.Define.Info.office_migration?SYNO.SDS.Drive.Utils.showAlertMsg(this.findAppWindow(),SYNO.SDS.Drive._T("app","migration_office")):SYNO.SDS.Drive.Utils.showAlertMsg(this.findAppWindow(),SYNO.SDS.Drive._T("app","install_office_alert")));t(o.result,i.bind(this,n,s,e),this)}else this._requestTransfer(n,s,e)}.bind(this,t,i);SYNO.SDS.Drive.WebAPICore.sendPromise(n,s).then(a).catch(r)},openC2webWindow:function(e,t){var i=this;return new Promise(function(n,o){if(!i.appWindow.send_copy_url)return void o("Please login to C2");var s=new URL(i.appWindow.send_copy_url+e+(t||""));if(null===window.open(s.toString(),"_blank"))return void o("Failed to open window");var r=function(e){if(e.origin!==s.origin)return void o("Message received from an unexpected origin");n(e),window.removeEventListener("message",r)};window.addEventListener("message",r)})},getTaskResult:function(e,t){this.appWindow.sendWebAPI({webapi:Ext.apply({params:{task_id:e}},SYNO.SDS.Drive.WebAPIDesc.get_task),callback:t,scope:this})},relayResponse:function(e,t,i){var n=document.querySelector(".syno-d-c2-transfer-btn");return this.remainingTransferCount--,0===this.remainingTransferCount&&n&&n.classList.remove("active"),0===e.length?void SYNO.Debug("Cannot get postmessage from C2 web"):i?(t||SYNO.Debug("error code: "+i.code),SYNO.Debug("remainingTransferCount:",this.remainingTransferCount),void e.forEach(function(e){e instanceof MessagePort&&e.postMessage(i)})):void SYNO.Debug("Cannot get response from C2 package")}}),Ext.define("SYNO.SDS.Drive.WindowHelper",{singleton:!0,SHAREMODE:Ext.isFunction(window.getDriveShareMode)?window.getDriveShareMode():"",getBaseAppPath:function(){var e=window.location.pathname,t=/\/oo\/r\/[A-Za-z0-9]+$/,i=/\/oo\/t\/[A-Za-z0-9_.]+$/,n=/\/d\/f\/[A-Za-z0-9]+$/,o=/\/d\/s\/([A-Za-z0-9]+)\/([^/]+)$/;return t.test(e)?e=e.replace(t,""):i.test(e)?e=e.replace(i,""):n.test(e)?e=e.replace(n,""):o.test(e)&&(e=e.replace(o,"")),e.lastIndexOf("/")===e.length-1&&(e=e.slice(0,-1)),e},getBaseAppURL:function(){return window.location.protocol+"//"+window.location.host+this.getBaseAppPath()},getStandaloneLaunchURL:function(e,t){var i=SYNO.SDS.Config.FnMap[e];if(i){t=Ext.apply({launchApp:e},t),SYNO.SDS.JSDebug&&!Ext.isDefined(t.jsDebug)&&(t=Ext.apply(t,{jsDebug:SYNO.SDS.JSDebug}));return Ext.urlAppend(this.getBaseAppURL(),Ext.urlEncode(t),!0!==i.config.allowURLNoSynoToken)}},isPublicFileShare:function(){return this.isPublicShare()&&window.getDriveFile&&"file"===window.getDriveFile().type},isPublicShare:function(){return"public"===SYNO.SDS.Drive.WindowHelper.SHAREMODE},isAdvShare:function(){return window.getDriveSharingLink&&!Ext.isEmpty(window.getDriveSharingLink())}}),Ext.define("SYNO.SDS.Drive.Comp.TreeNodeUI",{extend:"Ext.tree.TreeNodeUI",getDDHandles:function(){return this.anchor.id=Ext.id(),[this.iconNode,this.textNode,this.elNode,this.anchor]},renderElements:function(e,t,i,n){this.callParent(arguments),"Photos"===e.text&&"node"===e.parentNode.id&&SYNO.SDS.StatusNotifier.isAppEnabled("SYNO.Foto.AppInstance")&&this.elNode.classList.add("syno-photo-folder"),this.afterRenderElement(t)},setText:function(e){this.node.setText(Ext.util.Format.htmlEncode(e)),this.node.attributes.name=e,this.node.setTooltip(e)},afterRenderElement:function(e){this.elNode.classList.add("syno-d-tree-node"),this.ecNode.setAttribute("draggable",!1),!1!==e.removeIconNode&&this.elNode.removeChild(this.iconNode),!1!==e.removeEcNode&&this.elNode.removeChild(this.ecNode),!0===e.removeIndentNode&&this.elNode.removeChild(this.indentNode)}}),Ext.define("SYNO.SDS.Drive.Comp.TreeRootNodeUI",{extend:"SYNO.SDS.Drive.Comp.TreeNodeUI",renderElements:function(e,t,i,n){this.callParent(arguments);var o="syno-d-add-category";if("tag_shared_label"===e.id){o="syno-d-setting-category syno-d-non-delegated-category";SYNO.SDS.Drive.GetWindow().getEventMgr().on("envready",function(){if(SYNO.SDS.Drive.Define.Info.is_delegated){Ext.get("syno-d-gear-tag_shared_label").replaceClass("syno-d-non-delegated-category","syno-d-delegated-category")}})}switch(e.id){case"tag_label":case"tag_shared_label":var s="tag_label"===e.id?"syno-d-gear-tag_label":"syno-d-gear-tag_shared_label",r=String.format('<span class="syno-d-chevron syno-d-chevron-collapsed" id="syno-d-chevron-{0}" />',e.id),a=String.format('<div class="{0}" id="{1}" />',o,s);Ext.DomHelper.insertBefore(this.elNode.childNodes[1],r),Ext.DomHelper.append(e.ui.elNode,a),this.elNode.classList.add("syno-d-tree-root-node"),this.elNode.classList.add("syno-d-tree-tag-label","syno-d-tree-tag-node");break;case"category_label":this.elNode.classList.add("syno-d-tree-root-node")}},onDblClick:function(e){e.preventDefault()}}),Ext.define("SYNO.SDS.Drive.Comp.TreeSubNodeUI",{extend:"SYNO.SDS.Drive.Comp.TreeNodeUI",renderElements:function(e,t,i,n){this.callParent(arguments),this.elNode.classList.add("syno-d-tree-sub-node")}}),Ext.define("SYNO.SDS.Drive.Comp.LabelTreeNodeUI",{extend:"SYNO.SDS.Drive.Comp.TreeNodeUI",getDDHandles:function(){var e=this.callParent(arguments);return e.push(this.colorNode),e},renderElements:function(e,t,i,n){this.callParent(arguments),this.elNode.classList.add("syno-d-tree-tag-node"),t.is_new_label&&this.elNode.classList.add("syno-d-new-shared-label");var o=String.format('<div id="{0}" class="syno-d-color" style="background-color:#{1}; color:#FFF;"></div>',Ext.id(),t.color);Ext.DomHelper.insertBefore(this.elNode.childNodes[1],o),this.colorNode=this.elNode.childNodes[1]},setColor:function(e){Ext.fly(this.colorNode).setStyle("background-color","#"+e);var t=this.node.attributes.color;this.node.attributes.color=e,this.node.fireEvent("colorchange",this.node,e,t)},setIsNewLabel:function(e){this.elNode.classList[e?"add":"remove"]("syno-d-new-shared-label");var t=this.node.attributes.is_new_label;this.node.attributes.is_new_label=e,this.node.fireEvent("isnewlabelchange",this.node,e,t)}}),Ext.define("SYNO.SDS.Drive.Comp.SharedLabelTreeNodeUI",{extend:"SYNO.SDS.Drive.Comp.LabelTreeNodeUI",renderElements:function(e,t,i,n){this.callParent(arguments),this.elNode.setAttribute("ext:qtip",t.qtip)},onTipChange:function(e,t,i){if(this.rendered){var n=Ext.isDefined(i);this.textNode.setAttribute("ext:qtip",t),n&&this.textNode.setAttribute("ext:qtitle",i)}}}),Ext.define("SYNO.SDS.Drive.Comp.TreeLoader",{extend:"SYNO.API.TreeLoader",constructor:function(e){var t={listeners:{scope:this,beforeload:this.onBeforeLoad,load:this.onLoad,loadexception:this.onLoadException}};this.category=e.category,SYNO.SDS.Drive.Utils.apply(t,e||{}),this.callParent([t])},createNode:function(e,t){if(!1!==this.parseNodeAttr(e,t))return this.callParent(arguments)},getNodeId:function(e,t){return String.format("{0}:{1}",e,t)},parseNodeAttr:function(e,t){if(e.removeIconNode=t.attributes.removeIconNode,e.removeEcNode=t.attributes.removeEcNode,e.qtip=e.name,e.listRO=t.attributes.listRO,e.listNA=t.attributes.listNA,!1===e.listRO&&e.capabilities&&!e.capabilities.can_write||!1===e.listNA&&e.capabilities&&!e.capabilities.can_write&&!e.capabilities.can_preview)return!1},onBeforeLoad:function(e,t){e.nodeParameter=""},onLoad:function(e,t,i){},onLoadException:function(e,t,i){var n=i.responseData;try{
if(n=Ext.decode(n),n.success)return;i=n.error}catch(e){}SYNO.SDS.Drive.GetWindow().getMsgBox().alert("",SYNO.SDS.Drive.Utils.getErrorStr(i))}}),Ext.define("SYNO.SDS.Drive.Comp.DriveTreeLoader",{extend:"SYNO.SDS.Drive.Comp.TreeLoader",constructor:function(e){var t={dataroot:["data","items"],uiProviders:{render:SYNO.SDS.Drive.Comp.TreeSubNodeUI},baseParams:{path:"/mydrive",sort_by:"name",sort_direction:"asc",filter:{type:["dir"]}}};Ext.apply(t,SYNO.SDS.Drive.WebAPIDesc.list_files),Ext.apply(t,e||{}),this.callParent([t])},parseNodeAttr:function(e,t){return!1!==this.callParent(arguments)&&("dir"===e.type&&(e.text=e.name,e.uiProvider="render",e.id=this.getNodeId(this.category,e.file_id),void(e.removeEcNode=!1)))},onBeforeLoad:function(e,t){this.callParent(arguments),"node"===t.id?e.baseParams.path="/mydrive":e.baseParams.path=SYNO.SDS.Drive.Utils.getPathId(t.attributes.file_id)}}),Ext.define("SYNO.SDS.Drive.Comp.FolderTreeLoader",{extend:"SYNO.SDS.Drive.Comp.TreeLoader",constructor:function(e){var t={dataroot:["data","items"],uiProviders:{render:SYNO.SDS.Drive.Comp.TreeSubNodeUI},baseParams:{sort_by:"name",sort_direction:"asc"}};Ext.apply(t,SYNO.SDS.Drive.WebAPIDesc.list_team_folders),Ext.apply(t,e||{}),this.callParent([t]),this.subNodeLoader=new SYNO.SDS.Drive.Comp.DriveTreeLoader({category:this.category})},parseNodeAttr:function(e,t){if(!1===this.callParent(arguments))return!1;e.text=e.name,e.uiProvider="render",e.id=this.getNodeId(this.category,e.file_id),e.removeEcNode=!1,e.loader=this.subNodeLoader}}),Ext.define("SYNO.SDS.Drive.Comp.SharedTreeLoader",{extend:"SYNO.SDS.Drive.Comp.TreeLoader",constructor:function(e){var t={dataroot:["data","items"],uiProviders:{render:SYNO.SDS.Drive.Comp.TreeSubNodeUI},baseParams:{sort_by:"name",sort_direction:"asc",filter:{type:["dir"]}}};Ext.apply(t,e||{}),Ext.apply(t,SYNO.SDS.Drive.WebAPIDesc[e.method]),this.callParent([t]),this.subNodeLoader=new SYNO.SDS.Drive.Comp.DriveTreeLoader({category:this.category})},parseNodeAttr:function(e,t){if(!1===this.callParent(arguments))return!1;e.text=e.name,e.uiProvider="render",e.id=this.getNodeId(this.category,e.file_id),e.removeEcNode=!1,e.loader=this.subNodeLoader}}),Ext.define("SYNO.SDS.Drive.Comp.LabelTreeLoader",{extend:"SYNO.SDS.Drive.Comp.TreeLoader",constructor:function(e){var t={dataroot:["data","items"],uiProviders:{render:SYNO.SDS.Drive.Comp.LabelTreeNodeUI}};"shared_label"===e.category&&Ext.apply(t,{uiProviders:{render:SYNO.SDS.Drive.Comp.SharedLabelTreeNodeUI},baseParams:{type:"shared_label"}}),Ext.apply(t,SYNO.SDS.Drive.WebAPIDesc.list_labels),Ext.apply(t,e||{}),this.callParent([t])},parseNodeAttr:function(e,t){this.callParent(arguments),e.draggable=!0,e.leaf=!0,e.uiProvider="render",e.id=this.getNodeId(this.category,e.label_id),e.text=e.name,e.category=this.category,e.color=e.color.substr(1),"shared_label"===this.category&&(e.qtip=SYNO.SDS.Drive.Utils.getSharedLabelTooltipContent(e)),!1===e.display&&(e.hidden=!0)}}),Ext.define("SYNO.SDS.Drive.TreeWindow",{extend:"SYNO.SDS.Drive.ModalWindow",constructor:function(e){var t={width:480,height:446,cls:"syno-d-tree-dlg",layout:"fit",items:[this.getPanel(e)],buttonAlign:"left",useStatusBar:!1,buttons:[{xtype:"syno_button",btnStyle:"grey",cls:"syno-d-icon-btn syno-d-create-folder-btn",iconCls:"syno-d-create-folder-icon",hidden:e.hideCreate,scope:this,handler:this.onCreateFolder},"->"]},i=[{xtype:"syno_button",btnStyle:"grey",text:_T("common","cancel"),scope:this,handler:this.onCancel},this.ok_btn=new SYNO.ux.Button({xtype:"syno_button",text:_T("common","ok"),btnStyle:"default",disabled:!0,scope:this,handler:this.onApply})];t.buttons.push.apply(t.buttons,i);var n=Ext.apply(t,e);this.callParent([n]),this.mon(this,"afterlayout",this.onAfterLayout,this,{single:!0})},onApply:function(){var e;this.namefield&&this.namefield.isDirty()&&(e=this.namefield.getValue()),this.fireEvent("choose",this,this.getTree().getSelectionModel().getSelectedNode(),e)},onCancel:function(){this.close()},onAfterLayout:function(){this.center()},getPanel:function(e){return{autoFlexcroll:!1,border:!1,layout:{type:"vbox",align:"stretch",defaultMargins:{top:0,right:0,bottom:0,left:0}},items:[{xtype:"syno_formpanel",autoFlexcroll:!1,labelAlign:"top",border:!1,hidden:e.hideForm,items:[this.namefield=new SYNO.ux.TextField({xtype:"syno_textfield",fieldLabel:SYNO.SDS.Drive._T("action","enter_name"),name:"name",width:424,value:e.formText})]},this.getTree(e)]}},getTree:function(e){return this.tree||(this.tree=new SYNO.SDS.Drive.TreePanel(e))},onCreateFolder:function(){var e=this.getTree().getSelectionModel(),t=e.getSelectedNode();if(t){this.findAppWindow().getAction().createNode({file_id:t.attributes.file_id,ntype:"dir"},function(i,n){if(!i)return void this.getMsgBox().alert("",SYNO.SDS.Drive.Utils.getErrorStr(n));var o=t.id.split(":")[0];t.reload(function(){(t=this.getTree().getNodeByFileId(n.file_id,o))&&(e.select(t),t.ensureVisible())},this)},this)}},onGoToPath:function(e){this.getTree().onGoToPath(e)}}),Ext.define("SYNO.SDS.Drive.TreePanel",{extend:"SYNO.ux.TreePanel",constructor:function(e){this.action=e.action;var t=[{id:"node",text:SYNO.SDS.Drive._T("category","node"),draggable:!1,expanded:!0,allowDrop:!1,removeIconNode:!1,listNA:!1,loader:this.getDriveLoader()},{id:"team_folder",text:SYNO.SDS.Drive._T("category","team_folder"),draggable:!1,expanded:!0,allowDrop:!1,hidden:!0,removeIconNode:!1,listNA:!1,loader:this.getFolderLoader()},{id:"shared_with_me",text:SYNO.SDS.Drive._T("category","shared_with_me"),draggable:!1,expanded:!0,allowDrop:!1,hidden:!0,removeIconNode:!1,listNA:!1,loader:this.getSharedLoader()}];SYNO.SDS.Drive.Define.Info.is_home||t.shift();var i={clearOnLoad:!0,flex:1,bodyStyle:"padding: 8px 11px 8px 8px;",margins:{top:0,left:8,right:8,bottom:8},useGradient:!1,border:!0,rootVisible:!1,useArrows:!0,root:new Ext.tree.AsyncTreeNode({id:"root",allowDrag:!1,allowDrop:!1,children:t}),selModel:new Ext.tree.DefaultSelectionModel({listeners:{scope:this,beforeselect:this.onBeforeSelect,selectionchange:this.onSelectionChange}}),listeners:{scope:this,beforeclick:this.onBeforeTreeNodeClick}};this.callParent([i])},onBeforeTreeNodeClick:function(e,t,i){return!this.action||!("team_folder"===e.id||"shared_with_me"===e.id)},onBeforeSelect:function(e,t,i){if(!this.action)return!0;if("team_folder"===t.id||"shared_with_me"===t.id){var n,o=this.getSelectionModel();if(window.event){var s=new Ext.EventObjectImpl(window.event);switch(s.getKey()){case s.DOWN:n=o.selectNext;break;case s.UP:n=o.selectPrevious}}else{var r=o.getSelectedNode();r&&(r===t.previousSibling?n=o.selectNext:r.parentNode!==t&&r!==t.nextSibling||(n=o.selectPrevious))}return n&&n.defer(80,o,[t]),!1}return this.onBeforeTreeNodeClick(t)},onSelectionChange:function(){this.ownerCt.ownerCt.ok_btn&&this.ownerCt.ownerCt.ok_btn.enable()},getDriveLoader:function(){return this.driveLoader?this.driveLoader:(this.driveLoader=new SYNO.SDS.Drive.Comp.DriveTreeLoader({category:"node"}),this.driveLoader)},getFolderLoader:function(){return this.folderLoader?this.folderLoader:(this.folderLoader=new SYNO.SDS.Drive.Comp.FolderTreeLoader({category:"team_folder",listeners:{load:function(e,t,i){Ext.isEmpty(t.childNodes)||t.ui.show()}}}),this.folderLoader)},getSharedLoader:function(){return this.sharedLoader?this.sharedLoader:(this.sharedLoader=new SYNO.SDS.Drive.Comp.SharedTreeLoader({category:"shared_with_me",method:"list_shared_with_me",listeners:{load:function(e,t,i){Ext.isEmpty(t.childNodes)||t.ui.show()}}}),this.sharedLoader)},getNodeIdFromFileId:function(e,t){return String.format("{0}:{1}",e,t)},getNodeByFileId:function(e,t){return this.root.findChild("id",this.getNodeIdFromFileId(t,e),!0)},onGotoDefaultPath:function(){var e=this.root.getPath();this.getNodeById("node")&&(e+="/node",this.selectPath(e))},onGoToPath:function(e){if(!this.isDestroyed){if(!e||0===e.length)return void this.onGotoDefaultPath();var t=e[0].id,i=0,n=this.root.getPath()+"/"+t;if(("shared_with_me"===t||"team_folder"===t)&&1===e.length)return void this.onGotoDefaultPath();for(i=1;i<e.length;++i)n+="/"+this.getNodeIdFromFileId(t,e[i].id);this.selectPath(n,"id",function(e){e||this.onGotoDefaultPath()}.bind(this))}}}),Ext.define("SYNO.SDS.Drive.CopyToWindow",{extend:"SYNO.SDS.Drive.TreeWindow",constructor:function(e){if(!e.hideForm){var t=SYNO.SDS.Drive.Utils.parseDisplayName(e.formText);t!==e.formText&&(this.ext=SYNO.SDS.Drive.Utils.getExt(e.formText),e.formText=t)}this.callParent([e])},onApply:function(){var e;this.namefield&&this.namefield.isDirty()&&(e=this.namefield.getValue().trim(),this.ext&&(e+="."+this.ext)),this.fireEvent("choose",this,this.getTree().getSelectionModel().getSelectedNode(),e)}}),Ext.define("SYNO.SDS.Drive.AddEditWindow",{extend:"SYNO.SDS.Drive.ModalWindow",nameItemId:"title",maxNameLength:SYNO.SDS.Drive.Define.TAG_MAX_LENGTH,constructor:function(e){e.mode&&(this.mode=e.mode||"edit");var t={title:"add"===this.mode?_T("common","create"):_T("common","alt_edit"),items:this.getFormPanel(),buttons:[{itemId:"cancel",text:_T("common","cancel"),scope:this,handler:this.onCancel},{itemId:"ok",text:_T("common","ok"),btnStyle:"default",scope:this,disabled:_S("demo_mode"),tooltip:_S("demo_mode")?_JSLIBSTR("uicommon","error_demo"):"",handler:this.onApply}]},i=Ext.apply(t,e);this.callParent([i]),this.mon(this,"afterlayout",this.onAfterLayout,this,{single:!0}),this.mon(this,"show",this.onDelayShow,this,{single:!0,buffer:300})},onAfterLayout:function(){this.center()},onDelayShow:function(){var e=this.getForm().findField(this.nameItemId);e&&(e.focus(),e.selectText(0,e.getValue().length))},getForm:function(){return this.getFormPanel().getForm()},getFormPanel:Ext.emptyFn,getParams:function(){return this.getForm().getFieldValues(!0)},onApplyDone:Ext.emptyFn,isValid:function(){return this.getForm().isValid()},onApply:function(){if(!this.isValid()){var e=this.getForm().findField(this.nameItemId);if(!e)return;var t=e.getActiveError();return void(Ext.isEmpty(t)||this.getMsgBox().alert("",t))}if("edit"===this.mode||!this.isDirty())return void this.close();var i=this.getParams();i&&(this.setStatusBusy({text:_T("common","loading")}),this.onAction(i))},onAction:Ext.emptyFn,onApplyCb:function(e,t,i,n){if(this.clearStatusBusy(),e)return this.onApplyDone(t,i,n),void this.close();this.setStatusError({text:SYNO.SDS.Drive.Utils.getErrorStr(t)}),this.getMsgBox().alert("",SYNO.SDS.Drive.Utils.getErrorStr(t),this.onErrorCb.createDelegate(this,[t]),this)},onErrorCb:Ext.emptyFn,onCancel:function(){if("edit"!==this.mode||!this.isDirty())return void this.close();var e=function(e){"yes"===e&&this.close()};this.getMsgBox().confirm(this.title,_T("common","confirm_lostchange"),e,this)},isDirty:function(){return!!this.getForm()&&this.getForm().isDirty()},nameValidator:function(e){var t=e.trim();return 0===t.length?this.getForm().findField(this.nameItemId).blankText:t.length>0&&t.length<this.maxNameLength}}),Ext.define("SYNO.SDS.Drive.SearchList",{extend:"SYNO.ux.Menu",enableScrolling:!1,minChars:0,lastQuery:null,assetHeight:0,maxHeight:423,width:300,selectedClass:"x-combo-selected",listEmptyText:"",constructor:function(e){this.callParent([this.fillConfig(e)]),this.mon(this,"afterlayout",function(){this.focusEl=this.getSearchField().getEl(),this.bindStore(this.store,!0)},this,{single:!0})},fillConfig:function(e){Ext.apply(this,e);var t="x-combo-list",i=Ext.apply({autoRender:!0,cls:t+" syno-ux-combobox-list x-layer",items:[this.getSearchField(e),{xtype:"container",height:4},this.getView(t)]},e);return this.store=e.store,i},onDestroy:function(){this.bindStore(null),Ext.destroy(this.view,this.getSearchField(),this.store),SYNO.SDS.Drive.SearchList.superclass.onDestroy.call(this)},initComponent:function(){SYNO.SDS.Drive.SearchList.superclass.initComponent.call(this),this.addEvents("expand","collapse","beforeselect","select","beforequery"),this.selectedIndex=-1},getView:function(e){return this.view?this.view:(this.tpl||(!0===this.tplHtmlEncode?this.tpl='<tpl for="."><div class="'+e+'-item {[values.cls || ""]}" role="option" aria-label="{[Ext.util.Format.htmlEncode(Ext.util.Format.stripTags(values.'+this.displayField+'))]}" id="{[Ext.id()]}">{[Ext.util.Format.htmlEncode(values.'+this.displayField+")]}</div></tpl>":this.tpl='<tpl for="."><div class="'+e+'-item {[values.cls || ""]}" role="option" aria-label="{'+this.displayField+'}" id="{[Ext.id()]}">{'+this.displayField+"}</div></tpl>"),this.view=new SYNO.ux.FleXcroll.DataView({tpl:this.tpl,singleSelect:!0,useDefaultKeyNav:!0,overClass:this.selectedClass,selectedClass:this.selectedClass,itemSelector:this.itemSelector||"."+e+"-item",emptyText:this.listEmptyText,deferEmptyText:!1,listeners:{containerclick:this.onViewClick,click:this.onViewClick,scope:this}}),this.view)},getSearchField:function(e){return this.searchfield||(this.searchfield=new SYNO.TextFilter({width:(e.width||this.width)-16,itemId:"searchfield",listeners:{scope:this,keyup:{fn:function(e){this.doQuery(e.getValue())},buffer:300},afterrender:{scope:this,single:!0,fn:function(e){e.mon(e.trigger,"click",function(){this.doQuery(e.getValue())},this)}}}}))},getStore:function(){return this.store},bindStore:function(e,t){this.store&&!t&&(this.store!==e&&this.store.autoDestroy?this.store.destroy():(this.store.un("beforeload",this.onBeforeLoad,this),this.store.un("load",this.onLoad,this),this.store.un("exception",this.collapse,this)),e||(this.store=null,this.view&&this.view.bindStore(null))),e&&(t||(this.lastQuery=null),this.store=Ext.StoreMgr.lookup(e),this.store.on({scope:this,beforeload:this.onBeforeLoad,load:this.onLoad,exception:this.onLoadException}),this.view&&this.view.bindStore(e))},doQuery:function(e,t){e=Ext.isEmpty(e)?"":e.trim();var i={query:e,forceAll:t,combo:this,cancel:!1};if(!1===this.fireEvent("beforequery",i)||i.cancel)return!1;e=i.query,(!0===(t=i.forceAll)||e.length>=this.minChars)&&(this.lastQuery!==e?(this.lastQuery=e,"local"===this.mode?(this.selectedIndex=-1,t?this.store.clearFilter():this.store.filter(this.displayField,e),this.onLoad()):0!==this.store.getTotalCount()&&this.blQueryEmpty&&!1!==this.onBeforeQuery(e)?this.restrictHeight():(this.store.baseParams[this.queryParam]=e,this.store.load({params:this.getParams(e),callback:function(){this.lastQuery||this.blQueryEmpty||(this.blQueryEmpty=!0)},scope:this}))):(this.selectedIndex=-1,this.onLoad()))},onBeforeQuery:function(e){return this.store.filter(this.displayField,e,!0,!1,!1),!0},getParams:function(e){return{}},isExpanded:function(){return this.isVisible()},collapse:function(){this.isExpanded()&&this.hide()},expand:function(e,t){this.isExpanded()||(this.parentEl=e||this.parentEl,this.show(e,t),this.assetHeight||this.items.each(function(e){e!==this.getView()&&(this.assetHeight+=e.getHeight())},this),null===this.lastQuery?this.doQuery("",!0):this.restrictHeight())},onBeforeLoad:function(){this.selectedIndex=-1},onLoad:function(){this.restrictHeight()},onLoadException:function(){},onViewClick:function(){var e=this.view.getSelectedIndexes()[0],t=this.store,i=t.getAt(e);i?this.onSelect(i,e):this.collapse()},onSelect:function(e,t){if(!1!==this.fireEvent("beforeselect",this,e,t)){var i=this.getValue(),n=this.getStore();this.setValue(e.data[this.valueField||this.displayField]),this.collapse(),this.fireEvent("select",this,e,t);var o=n.findExact("name",i);-1!==o?n.getAt(o).commit():n.getAt(0).commit(),e.commit()}},setValue:function(e){this.value=e},getValue:function(){return this.value||""},restrictHeight:function(){var e=this.view.getTemplateTarget().dom,t=this.el.getFrameWidth("tb")+this.assetHeight,i=Math.max(e.clientHeight,e.offsetHeight,e.scrollHeight),n=this.owner.getPosition()[1]-Ext.getBody().getScroll().top,o=Ext.lib.Dom.getViewHeight(!0)-n-this.owner.getHeight(),s=Math.max(n,o,this.minHeight||0)-t-5;i=Math.min(i,s,this.maxHeight),this.setHeight(i+t),this.ul.setHeight(i+this.assetHeight),this.view.setHeight(i+1),this.view.updateFleXcroll(),this.show(this.parentEl)},select:function(e,t){var i=this;if(i.callParent(arguments),!1!==t){var n=i.view.getNode(e);n&&i.view.fleXcrollTo(n)}}}),Ext.define("SYNO.SDS.Drive.Info.Panel",{extend:"SYNO.ux.FormPanel",constructor:function(e){this.owner=e.owner,this.module=e.module;var t=this.fillConfig(e);this.callParent([t])},fillConfig:function(e){var t=this,i={trackResetOnLoad:!0,autoHeight:!0,font:"13px Arial",items:[{xtype:"syno_textfield",cls:"syno-d-info-title-textfield",fieldLabel:SYNO.SDS.Drive._T("file","title"),name:"name",validator:function(e){var i=e.trim();return 0===i.length?this.blankText:i.length>0&&unescape(encodeURIComponent(i)).length>=SYNO.SDS.Drive.Define.TITLE_MAX_LENGTH-(t.ext?t.ext.length+1:0)?SYNO.SDS.Drive._T("error","name_too_long"):!!SYNO.SDS.Drive.Utils.checkFileName(e)||SYNO.SDS.Drive._T("error","reserved_name")},allowBlank:!1},{xtype:"syno_displayfield",itemCls:SYNO.SDS.Utils.SelectableCLS,fieldLabel:SYNO.SDS.Drive._T("file","title"),name:"name_readonly",hidden:!0},{xtype:"syno_displayfield",itemCls:SYNO.SDS.Utils.SelectableCLS,fieldLabel:SYNO.SDS.Drive._T("file","type"),name:"ntype"},{xtype:"syno_displayfield",itemCls:SYNO.SDS.Utils.SelectableCLS,fieldLabel:SYNO.SDS.Drive._T("info","created"),name:"ctime_readonly"},{xtype:"syno_displayfield",itemCls:SYNO.SDS.Utils.SelectableCLS,fieldLabel:SYNO.SDS.Drive._T("info","modified"),name:"mtime"},{xtype:"syno_displayfield",itemCls:SYNO.SDS.Utils.SelectableCLS,fieldLabel:SYNO.SDS.Drive._T("file","owner"),name:"owner"},{xtype:"syno_displayfield",itemCls:SYNO.SDS.Utils.SelectableCLS,fieldLabel:SYNO.SDS.Drive._T("file","size"),name:"size"},{xtype:"syno_displayfield",itemCls:SYNO.SDS.Utils.SelectableCLS,fieldLabel:SYNO.SDS.Drive._T("file","location"),name:"location",cls:"syno-d-info-location",htmlEncode:!1,listeners:{scope:this,single:!0,render:function(e){this.mon(e.getEl(),"click",this.onClick,this)}}}]};return Ext.apply(i,e)},onClick:function(e,t,i){if(!SYNO.SDS.Drive.Utils.isAdvSharingPage()){var n=Ext.fly(t),o=n.is("a"),s=n.is("span.syno-d-info-path");if(o||s){if(!s)return o?void this.copyToClipBoard("span.syno-d-info-path"):void 0;if("SYNO.SDS.Drive.PublicApplication"===_S("standaloneAppName")||"SYNO.SDS.Drive.Application"===_S("standaloneAppName")){var r=this.findAppWindow().getNavigation().getCategory();if("node"===r||"team_folder"===r)return void this.owner.close();this.findAppWindow().getAction().onGotoPath(this.data.file_id),this.owner.close()}else SYNO.SDS.Drive.Utils.onOpenMgr({},{file_id:this.data.file_id})}}},copyToClipBoard:function(e){var t=document.querySelector(e).dataset.path,i=document.querySelector("body"),n=document.createElement("textarea");i.appendChild(n),n.value=t,n.select();var o=document.execCommand("copy"),s="";i.removeChild(n),s=o?SYNO.SDS.Drive._T("share","copy_url_done"):SYNO.SDS.Drive._T("error","copy_share_link"),SYNO.SDS.Drive.Utils.showToastMsg(this.findAppWindow(),s,3e3)},updateData:function(e){var t,i=this.getForm();this.data=e,e=SYNO.Util.copy(e);var n=e.ctime||e.created_time,o=e.mtime||e.modified_time;if(Ext.isNumber(n)&&(e.ctime_readonly=SYNO.SDS.Drive.Utils.getFormatDateTime(new Date(1e3*n))),"dir"===e.type?e.ntype=SYNO.SDS.Drive._T("file","dir"):e.ntype&&"office"===SYNO.SDS.Drive.Utils.getFileTypeMapping(e.ntype)?(t=e.ntype,"oslides"===t&&(t="oslide"),e.ntype=SYNO.SDS.Drive._T("file",t)):SYNO.SDS.Drive.Utils.isOfficeFile(e.name)&&(t=SYNO.SDS.Drive.Utils.getExt(e.name),"oslides"===t&&(t="oslide"),e.ntype=SYNO.SDS.Drive._T("file",t)),"dir"===e.type)e.size="-";else{var s=Ext.util.Format.number(e.size,"0,000");e.size=String.format("{0} ({1} Bytes)",Ext.util.Format.fileSize(e.size),s)}var r=SYNO.SDS.Drive.Utils.parseDisplayName(e.name);if(r!==e.name&&(this.ext=SYNO.SDS.Drive.Utils.getExt(e.name)),e.name=r,e.name_readonly=r,Ext.isNumber(o)&&(e.mtime=SYNO.SDS.Drive.Utils.getFormatDateTime(new Date(1e3*o))),Ext.isObject(e.owner)){var a=e.owner.display_name,l=e.owner.name,d=e.owner.nickname;Ext.isString(a)&&(e.owner=a),Ext.isString(l)&&(e.owner_name=l),Ext.isString(d)&&(e.owner_nickname=d)}if(e.location=this.getDisplayPathString(e),this.updatePermUI(e),i.setValues(e),SYNO.SDS.Drive.Define.Info.use_nickname){var c=e.owner_name;e.owner_nickname&&(c+=" ("+e.owner_nickname+")"),new Ext.ToolTip({target:i.findField("owner").getEl(),html:Ext.util.Format.htmlEncode(c)})}},getDisplayPathString:function(e){var t="",i=SYNO.SDS.Drive.Utils.parseDisplayPath(e.display_path),n='<span class="syno-d-info-path {4}" data-path="{0}" ext:qtip="{1}">{2}</span>';SYNO.SDS.Drive.Utils.isAdvSharingPage()?(i=e.name,t="syno-adv-info-path"):SYNO.SDS.Drive.Utils.isVisibleInDrive(e.display_path)&&(n+='<span class="syno-d-info-copy-path"> (<a>{3}</a>)</span>');var o=this.getTrimString(i,344),s=Ext.util.Format.htmlEncode(i),r=Ext.util.Format.htmlEncode(s);return String.format(n,s,r,o,SYNO.SDS.Drive._T("info","copy_path"),t)},getTrimString:function(e,t){this.canvas||(this.canvas=document.createElement("canvas"));var i=this.canvas.getContext("2d");i.font=this.font;var n,o,s=" ("+SYNO.SDS.Drive._T("info","copy_path")+")",r=Math.ceil(i.measureText(s).width),a=Math.ceil(i.measureText(e).width),l=a+r,d="";if(l<t)n=e;else if(l<2*t)n=e,a<t&&(d="<br>");else{var c,h,u;for(c=1;c<e.length;++c)if(h=e.substr(0,c),Math.ceil(i.measureText(h).width)>t){h=e.substr(0,c-1);break}for(o=1;o<e.length;++o)if(u=e.substr(c-1,o)+"...",Math.ceil(i.measureText(u).width)+8+r>t){u=e.substr(c-1,o-1)+"...";break}n=h+u}return Ext.util.Format.htmlEncode(n)+d},updatePermUI:function(e){if(!e.capabilities.can_delete||SYNO.SDS.Drive.Utils.is1stSharedWithMe(e.display_path)){var t=this.getForm();t.findField("name_readonly").show(),t.findField("name").hide();var i=this.owner.getFooterToolbar().items;i.get("ok").hide(),i.get("cancel").hide(),i.get("close")||this.owner.addButton({itemId:"close",text:_T("common","close"),scope:this.owner,handler:this.owner.close}),this.owner.doLayout()}},updateForm:function(e){this.updateData(e.data)},updateFormByNode:function(e){this.updateData(e)},isDirty:function(){return this.getForm().isDirty()}}),Ext.define("SYNO.SDS.Drive.Info.Window",{extend:"SYNO.SDS.Drive.AddEditWindow",mode:"edit",maxNameLength:SYNO.SDS.Drive.Define.TITLE_MAX_LENGTH,nameItemId:"name",constructor:function(e){this.owner=e.owner,e.path?this.path=e.path:this.rec=e.rec,this.callParent([this.fillConfig(e)])},fillConfig:function(e){var t={title:SYNO.SDS.Drive._T("file","info"),resizable:!1,autoHeight:!0,listeners:{single:!0,beforeshow:function(){if(this.path)this.onLoadData(e);else{var t=this.getFormPanel();t.updateForm(this.rec),t.getForm().clearInvalid()}},scope:this}};return Ext.apply(t,e)},getFormPanel:function(){return Ext.isEmpty(this.infoFormPanel)&&(this.infoFormPanel=new SYNO.SDS.Drive.Info.Panel({owner:this,module:this})),this.infoFormPanel},isDirty:function(){return this.getFormPanel().isDirty()},getParams:function(){var e=this.getForm().getFieldValues(!0)||{};return this.rec?e.path=SYNO.SDS.Drive.Utils.getPathId(this.rec.id):e.path=this.path,e.ctime&&Ext.isDate(e.ctime)&&(e.created_time=e.ctime.valueOf()/1e3,delete e.ctime),e},onAction:function(e){if(e.name){var t=this.getFormPanel().ext;t&&(e.name+="."+t)}this.findAppWindow().getAction().setNodeTitle(e,this.onApplyCb,this)},onLoadData:function(e){if(e){this.getFormPanel().updatePermUI(e)}this.setStatusBusy(),this.findAppWindow().getWebAPI().getNode({params:{path:this.path},callback:this.onLoadDataDone,scope:this})},onLoadDataDone:function(e,t,i,n){if(!this.isDestroyed){if(this.clearStatusBusy(),!e){var o=SYNO.API.Util.GetFirstError(t);return void this.getMsgBox().alert("",SYNO.SDS.Drive.Utils.getErrorStr(o),function(){this.close()},this)}var s=SYNO.SDS.Drive.WebAPIDesc.get_file,r=SYNO.API.Util.GetValByAPI(t,s.api,s.method);this.getFormPanel().updateFormByNode(r)}}}),Ext.define("SYNO.SDS.Drive.RenameWindow",{extend:"SYNO.SDS.Drive.AddEditWindow",mode:"edit",maxNameLength:SYNO.SDS.Drive.Define.TITLE_MAX_LENGTH,constructor:function(e){this.initName=e.initName,this.blDir=e.blDir,this.callParent([Ext.apply({title:e.title||SYNO.SDS.Drive._T("action","rename"),width:456,height:190},e)])},getFormPanel:function(){return this.formPanel=this.formPanel||new SYNO.ux.FormPanel({cls:"syno-d-add-edit-form",autoHeight:!0,border:!1,fieldWidth:400,labelAlign:"top",items:[{xtype:"syno_textfield",fieldLabel:SYNO.SDS.Drive._T("file","new_name"),itemId:this.nameItemId,name:this.nameItemId,value:this.initName,validator:this.nameValidator.createDelegate(this)}]}),this.formPanel},onDelayShow:function(){var e=this.getForm().findField(this.nameItemId);if(e){var t=e.getValue().lastIndexOf(".");e.focus(),e.selectText(0,this.ext||-1===t||this.blDir?e.getValue().length:t)}},onAction:function(e){e[this.nameItemId]=e[this.nameItemId].trim(),this.fireEvent("apply",this,this.getForm(),e)}}),Ext.define("SYNO.SDS.Drive.NodeEditWindow",{extend:"SYNO.SDS.Drive.RenameWindow",onErrorCb:function(e){var t=SYNO.SDS.Drive.Utils.getErrorCode(e);1022!==t&&1032!==t&&1034!==t&&1035!==t&&this.close()},nameValidator:function(e){var t=e.trim();return 0===t.length?this.getForm().findField(this.nameItemId).blankText:t.length>0&&unescape(encodeURIComponent(t)).length>=this.maxNameLength-(this.ext?this.ext.length+1:0)?SYNO.SDS.Drive._T("error","name_too_long"):!!SYNO.SDS.Drive.Utils.checkFileName(t)||SYNO.SDS.Drive._T("error","reserved_name")}}),Ext.define("SYNO.SDS.Drive.RenameNodeWindow",{extend:"SYNO.SDS.Drive.NodeEditWindow",constructor:function(e){var t=SYNO.SDS.Drive.Utils.parseDisplayName(e.initName);t!==e.initName&&(this.ext=SYNO.SDS.Drive.Utils.getExt(e.initName),e.initName=t),this.callParent([e])},onAction:function(e){var t=e[this.nameItemId].trim();this.ext&&(t+="."+this.ext),e[this.nameItemId]=t,this.callParent([e])}}),Ext.define("SYNO.SDS.Drive.CreateWindow",{extend:"SYNO.SDS.Drive.NodeEditWindow",mode:"add",constructor:function(e){this.callParent([Ext.apply({title:e.title||_T("common","create"),allowBlank:!1},e)])},getFormPanel:function(){return this.formPanel=this.formPanel||new SYNO.ux.FormPanel({cls:"syno-d-add-edit-form",autoHeight:!0,border:!1,fieldWidth:400,labelAlign:"top",items:[{xtype:"syno_textfield",fieldLabel:SYNO.SDS.Drive._T("common","name"),itemId:this.nameItemId,name:this.nameItemId,value:this.initName,validator:this.nameValidator.createDelegate(this)}]}),this.formPanel}}),Ext.define("SYNO.SDS.Drive.WebAPIDesc",{statics:{get_file:{api:"SYNO.SynologyDrive.Files",method:"get",version:3},update_file:{api:"SYNO.SynologyDrive.Files",method:"update",version:2},star_file:{api:"SYNO.SynologyDrive.Files",method:"star",version:2},delete_files:{api:"SYNO.SynologyDrive.Files",method:"delete",version:2},share_file:{api:"SYNO.SynologyDrive.Sharing",method:"update",version:1},request_access:{api:"SYNO.SynologyDrive.Files",method:"request_access",version:2},copy_files:{api:"SYNO.SynologyDrive.Files",method:"copy",version:2},move_files:{api:"SYNO.SynologyDrive.Files",method:"move",version:2},get_file_link:{api:"SYNO.SynologyDrive.Sharing",method:"create_link",version:1},get_base_url:{api:"SYNO.SynologyDrive.Sharing",method:"get_base_url",version:2},list_files:{api:"SYNO.SynologyDrive.Files",method:"list",version:2},list_shared_with_me:{api:"SYNO.SynologyDrive.Files",method:"shared_with_me",version:2},list_shared_with_others:{api:"SYNO.SynologyDrive.Files",method:"shared_with_others",version:2},list_recent:{api:"SYNO.SynologyDrive.Files",method:"recent",version:2},list_label_files:{api:"SYNO.SynologyDrive.Files",method:"list_labelled",version:2},list_star_files:{api:"SYNO.SynologyDrive.Files",method:"list_starred",version:2},list_team_folders:{api:"SYNO.SynologyDrive.TeamFolders",method:"list",version:1},list_team_folders_members:{api:"SYNO.SynologyDrive.TeamFolders",version:1,method:"list_members"},list_labels:{api:"SYNO.SynologyDrive.Labels",method:"list",version:1},list_trash:{api:"SYNO.SynologyDrive.Trash",method:"list",version:1},list_trash_ancestor:{api:"SYNO.SynologyDrive.Trash",method:"list_ancestor",version:1},list_node_ancestor:{api:"SYNO.SynologyDrive.Files",method:"list_ancestor",version:2},create_files:{api:"SYNO.SynologyDrive.Files",method:"create",version:2},list_revisions:{api:"SYNO.SynologyDrive.Revisions",method:"list",version:1},restore_revisions:{api:"SYNO.SynologyDrive.Revisions",method:"restore",version:1},list_office_revisions:{api:"SYNO.Office.Node.Version",method:"list",version:1},restore_office_revisions:{api:"SYNO.Office.Node.Version",method:"restore",version:1},download_revisions:{api:"SYNO.SynologyDrive.Revisions",method:"download",version:1},upload_files:{api:"SYNO.SynologyDrive.Files",method:"upload",version:2,uploadAttr:"file"},upload_files_from_nas:{api:"SYNO.SynologyDrive.Files",method:"upload_from_dsm",version:2},download_files:{api:"SYNO.SynologyDrive.Files",method:"download",version:2},search_files:{api:"SYNO.SynologyDrive.Files",version:2,method:"search"},list_app_priv:{api:"SYNO.SynologyDrive.Share.Priv",method:"list",version:1},list_tasks:{api:"SYNO.SynologyDrive.Tasks",method:"list",version:1},get_task:{api:"SYNO.SynologyDrive.Tasks",method:"get",version:1},delete_task:{api:"SYNO.SynologyDrive.Tasks",method:"delete",version:1},info:{api:"SYNO.SynologyDrive.Info",version:2,method:"get"},get_quota:{api:"SYNO.SynologyDrive.Info",version:2,method:"quota"},get_setting:{api:"SYNO.SynologyDrive.Settings",version:2,method:"list"},update_setting:{api:"SYNO.SynologyDrive.Settings",version:2,method:"update"},get_user_setting:{api:"SYNO.SynologyDrive.Users",version:1,method:"get"},update_user_setting:{api:"SYNO.SynologyDrive.Users",version:1,method:"update"},get_dsm_setting:{api:"SYNO.SynologyDrive.DSM",version:1,method:"get"},list_notifications:{api:"SYNO.SynologyDrive.Notifications",method:"list",version:1},create_notification:{api:"SYNO.SynologyDrive.Notifications",method:"create",version:1},delete_notifications:{api:"SYNO.SynologyDrive.Notifications",method:"delete",version:1},set_labels:{api:"SYNO.SynologyDrive.Files",version:2,method:"label"},create_labels:{api:"SYNO.SynologyDrive.Labels",version:1,method:"create"},update_labels:{api:"SYNO.SynologyDrive.Labels",version:1,method:"update"},delete_labels:{api:"SYNO.SynologyDrive.Labels",version:1,method:"delete"},list_chat_channels:{api:"SYNO.SynologyDrive.Services.SynologyChat",version:1,method:"list"},bind_chat_channels:{api:"SYNO.SynologyDrive.Services.SynologyChat",version:1,method:"bind"},convert_office:{api:"SYNO.SynologyDrive.Files",version:6,method:"convert_office"},get_thumbnail:{api:"SYNO.SynologyDrive.Files",version:2,method:"get_thumbnail"},get_dsm_thumbnail:{api:"SYNO.Core.File.Thumbnail",version:1,method:"get"},get_metadata:{api:"SYNO.SynologyDrive.Photos",version:1,method:"get_metadata"},create_vs_link:{api:"SYNO.SynologyDrive.Services.VideoStation",version:1,method:"create"},doc_convert:{api:"SYNO.SynologyDrive.Services.DocumentViewer",version:1,method:"create"},sync_to_device:{api:"SYNO.SynologyDrive.Sharing",method:"sync_to_device",version:1},office_status:{api:"SYNO.SynologyDrive.Office",method:"status",version:1},plugin_string:{api:"SYNO.SynologyDrive.String",method:"get",version:1},empty_recycle_bin:{api:"SYNO.SynologyDrive.Trash",method:"empty",version:1},auth_adv_sharing:{api:"SYNO.SynologyDrive.AdvanceSharing.Public",method:"auth",version:1},get_adv_sharing:{api:"SYNO.SynologyDrive.AdvanceSharing",method:"get",version:1},create_adv_sharing:{api:"SYNO.SynologyDrive.AdvanceSharing",method:"create",version:1},update_adv_sharing:{api:"SYNO.SynologyDrive.AdvanceSharing",method:"update",version:1},remove_adv_sharing:{api:"SYNO.SynologyDrive.AdvanceSharing",method:"delete",version:1},list_backup_tasks:{api:"SYNO.SynologyDrive.Files",method:"list_backup_tasks",version:3},get_migrate_index_home_config:{api:"SYNO.SynologyDrive.Share",method:"get_migrate_index_home_config",version:1},list_package:{api:"SYNO.Core.Package.Server",method:"list",version:2},get_package_info:{api:"SYNO.Core.Package.Info",method:"get",version:1},check_delegated:{api:"SYNO.SynologyDrive.Labels",method:"check_delegated",version:1},list_file_request:{
api:"SYNO.SynologyDrive.FileRequest",method:"list",version:1},create_file_request:{api:"SYNO.SynologyDrive.FileRequest",method:"create",version:1},delete_file_request:{api:"SYNO.SynologyDrive.FileRequest",method:"delete",version:1},update_file_request:{api:"SYNO.SynologyDrive.FileRequest",method:"update",version:1},lock_node:{api:"SYNO.SynologyDrive.Files",method:"lock",version:2},request_unlock:{api:"SYNO.SynologyDrive.Files",method:"request_unlock",version:2},access_file:{api:"SYNO.SynologyDrive.Files",method:"access",version:10},list_share:{api:"SYNO.SynologyDrive.Share",method:"list",version:1},enable_team_folder:{api:"SYNO.SynologyDrive.Share",method:"set",version:2},update_team_folder:{api:"SYNO.SynologyDrive.Share",method:"set",version:2},get_db_config:{api:"SYNO.SynologyDrive.Config",method:"get",version:1},create_share:{api:"SYNO.Core.Share",method:"create",version:1},list_c2_share:{api:"SYNO.C2FS.Share",method:"list",version:1},list_volume:{api:"SYNO.Core.Storage.Volume",method:"list",version:1}}}),Ext.define("SYNO.SDS.Drive.Sharing",{singleton:!0,GetURL:function(e,t){var i,n=window.location.pathname;n=n.replace(/\/d\/s\/([A-Za-z0-9]+)\/([^/]+)/,""),SYNO.SDS.JSDebug&&(i=Ext.apply(i||{},{jsDebug:SYNO.SDS.JSDebug})),n&&"/"===n.charAt(n.length-1)||(n+="/");var o=n+"d/s/"+e+"/"+t;return i&&(o=Ext.urlAppend(o,Ext.urlEncode(i),!1)),o},GetSharingLink:function(){if(this.sharing_link)return this.sharing_link;var e=/\/d\/s\/([A-Za-z0-9]+)\/([^/]+)$/g.exec(location.pathname);if(e&&3===e.length)this.sharing_link=e[2];else{var t=Ext.urlDecode(window.location.search.substr(1));t&&t.sharing_link&&(this.sharing_link=JSON.parse(t.sharing_link))}return this.sharing_link},GetSharingToken:function(){if(this.sharing_token)return this.sharing_token;var e=this.GetSharingLink();if(e){var t=Ext.util.Cookies.get("drive-sharing-"+e);t&&(this.sharing_token=t)}return this.sharing_token},AddSharingToken:function(e,t,i){if(e){var n=this.GetSharingToken();if(n){var o=e.api||t;if(/^SYNO\.SynologyDrive\.|^SYNO\.Office\./.test(o))e.sharing_token=i?Ext.encode(n):n;else if("SYNO.Entry.Request"===o&&e.compound){var s,r=e.compound,a=!1;Ext.isString(r)?(a=!0,s=Ext.decode(r)||[]):s=r.params||r||[];for(var l=0;l<s.length;++l)this.AddSharingToken(s[l]);a&&(e.compound=Ext.encode(s))}}}},Override:function(){Ext.Ajax.on("beforerequest",function(e,t){this.AddSharingToken(t.params,void 0,!0)},this),synowebapi&&synowebapi.hooks&&synowebapi.hooks.beforeRequest.use(function(e){this.AddSharingToken(e.params,e.api)}.bind(this)),Ext.ori_urlAppend=Ext.urlAppend,Ext.urlAppend=function(e,t,i){if(i=void 0===i||i){var n,o=Ext.urlDecode(t);if(Ext.isObject(o)&&!o.sharing_token&&o.api&&(n=SYNO.SDS.Drive.Sharing.GetSharingToken())&&/^SYNO\.SynologyDrive\.|^SYNO\.Office\./.test(o.api))return o.sharing_token=n,Ext.ori_urlAppend(e,Ext.urlEncode(o),i)}return Ext.ori_urlAppend(e,t,i)},SYNO.API.currentManager.getBaseURL&&(SYNO.API.currentManager.ori_getBaseURL=SYNO.API.currentManager.getBaseURL,SYNO.API.currentManager.getBaseURL=function(e,t,i,n,o){if(Ext.isObject(e))return SYNO.SDS.Drive.Sharing.GetSharingToken()&&(e.params||(e.params={}),SYNO.SDS.Drive.Sharing.AddSharingToken(e.params,e.api)),SYNO.API.currentManager.ori_getBaseURL(e,t,i,n,o);var s={api:e,method:t,version:i};return SYNO.SDS.Drive.Sharing.GetSharingToken()&&(s.params={},SYNO.SDS.Drive.Sharing.AddSharingToken(s.params,s.api)),SYNO.API.currentManager.ori_getBaseURL(s,n,o)})}}),Ext.override(SYNO.SDS.Utils.IFrame,{createIFrame:function(e,t){var i=Ext.id(),n=e.createElement("iframe");return n.setAttribute("src",""),n.setAttribute("id",i),n.setAttribute("name",i),t&&n.setAttribute("src",t),n.setAttribute("frameBorder","0"),n.setAttribute("style","border:0px none;width:0;height:0;position:absolute;top:-100000px"),e.body.appendChild(n),n}}),Ext.ns("SYNO.SDS.Drive"),SYNO.SDS.Drive.Override=function(){SYNO.SDS.Drive.isRunOverride||(SYNO.SDS.Drive.isRunOverride=!0,SYNO.SDS.Utils.Logout.redirect=function(e){var t=SYNO.SDS.Drive.WindowHelper.getBaseAppPath()+"/",i=SYNO.SDS.Drive.Utils.getAppURL();this.logoutTriggered=!0;var n=function(){window.location.href===window.location.origin+i?window.location.reload():window.location.href=i};!1===e?n():function(){var e=t+"webman/logout.cgi";Ext.Ajax.request({method:"POST",url:e,callback:function(){n()}})}()},SYNO.SDS.Strings["SYNO.SDS.Drive.MainWindow"]=SYNO.SDS.Strings["SYNO.SDS.Drive.PublicApplication"]=SYNO.SDS.Strings["SYNO.SDS.Drive.BasicInstance"]=SYNO.SDS.Strings["SYNO.SDS.Drive.BasicApp"]=SYNO.SDS.Strings["SYNO.SDS.Drive.Application"],SYNO.SDS.Strings["SYNO.SDS.CSTN.Instance"]||(SYNO.SDS.Strings["SYNO.SDS.CSTN.Instance"]=SYNO.SDS.Strings["SYNO.SDS.Drive.Application"]),"SYNO.SDS.Drive.PublicApplication"===_S("standaloneAppName")&&SYNO.SDS.Drive.Sharing.Override())},SYNO.SDS.Drive.updatePrototype=function(e){for(var t,i=document.getElementsByTagName("script"),n=0;n<i.length;++n){var o=i[n].src;if(-1!==o.indexOf("prototype.js"))return void(e&&e());-1!==o.indexOf("ext-base.js")&&(t=o.replace(/ext-3\/adapter\/ext\/ext-base.js/,"prototype-1.7.2/prototype.js"))}if(t){var s=document.createElement("script");s.type="text/javascript",s.src=t,e&&(s.onload=e),document.head.appendChild(s)}},"SYNO.SDS.Drive.Application"!==_S("standaloneAppName")&&"SYNO.SDS.Drive.PublicApplication"!==_S("standaloneAppName")&&"SYNO.SDS.Drive.BasicInstance"!==_S("standaloneAppName")||SYNO.SDS.Drive.Override(),Ext.define("SYNO.SDS.Drive.WebAPICore",{statics:{getApiConfig:function(e,t){var i=Object.create(SYNO.SDS.Drive.WebAPIDesc[e]);return i.params=Ext.apply(i.baseParams||{},t),i},formatApiObj:function(e,t,i,n,o,s){var r=this.getApiConfig(e,t);return i&&(r.callback=i),s&&s.encryption&&(r.encryption=s.encryption),n&&(r.progress=n),o&&(r.scope=o),r.uploadAttr&&(s=Ext.apply(s||{},{timeout:864e5}),Ext.apply(r,s),r.processApiObj=function(e,t){return function(t){return t.html5upload=!1,t.params[t.uploadAttr]&&(t.html5upload=!0,t.uploadData=new FormData,Ext.iterate(t.params,function(e,i){(e===t.uploadAttr||Ext.isString(i))&&(!(i instanceof File)&&i instanceof Blob?t.uploadData.append(e,i,i.name):t.uploadData.append(e,i),delete t.params[e])})),Ext.isFunction(e)?e(t):t}}(r.processApiObj,r.uploadAttr)),r.processApiObj&&(r=r.processApiObj(r)),r},send:function(e,t,i,n,o,s){var r={};Ext.isFunction(i)?r.callback=i:Ext.isObject(i)&&(r=i);var a=SYNO.SDS.Drive.GetWindow()||n,l=this;if(Ext.isArray(e)){t=t||[];var d,c=[];for(d=0;d<e.length;d++)c.push(l.formatApiObj(e[d],t[d]));return a.sendWebAPI({compound:Ext.apply({mode:"parallel",params:c,stopwhenerror:!0},o),scope:n||window,callback:r.callback})}return a.sendWebAPI(l.formatApiObj(e,t,r.callback,r.progress,n,s))},sendPromise:function(e,t,i,n){return new Promise(function(o,s){this.send(e,t,function(e,t,i,n){e&&!t.has_fail?o(t):(this._handleCompoundLogout(t),s(t))}.bind(this),null,i,n)}.bind(this))},_handleCompoundLogout:function(e){e.result&&Ext.isArray(e.result)&&Ext.each(e.result,function(e){var t,i;if(e.error&&e.error.code&&(t=e.error.code)>=105&&t<=107)return i=SYNO.API.Errors.common[t],SYNO.SDS.Utils.Logout.action(!0,i,!0),!1})},download:function(e,t,i,n,o){var s=SYNO.SDS.Drive.GetWindow()||o;t=Ext.apply(t,{_dc:(new Date).getTime()});var r=function(e){Ext.isGecko&&!Ext.isObject(e)||(Ext.isFunction(n)?Ext.callback(n,o,[e],1):SYNO.SDS.Drive.Utils.showErrorMsg(s,e))},a=this.getApiConfig(e,t);synowebapi.download({api:a.api,method:a.method,version:a.version,params:a.params,filename:i,onLoad:r,onError:r})}}}),Ext.define("SYNO.SDS.Drive.Action",{constructor:function(e){this.appWindow=e.appWindow,this.target=e.target,this.c2TransferHandler=new SYNO.SDS.Drive.ActionHandler.C2Transfer(e),this.downloadHandler=new SYNO.SDS.Drive.ActionHandler.Download(Ext.applyIf(e,{officeDownloader:this}))},clone:function(){return new SYNO.SDS.Drive.Action(this)},setTarget:function(e){this.target=e,this.downloadHandler.setTarget(e)},resetTarget:function(){this.target=null,this.downloadHandler.resetTarget()},getTargets:function(){return this.target?this.target:this.findAppWindow().getPanel().getSelections()},getTarget:function(){return this.getTargets().length>0?this.getTargets()[0]:null},getTargetFileIds:function(){return this.getTargets().map(function(e){return e.get("file_id")})},findAppWindow:function(){return this.appWindow||SYNO.SDS.Drive.GetWindow()},initInfoData:function(e){Ext.apply(SYNO.SDS.Drive.Define.Info,e),SYNO.SDS.Drive.Define.Info.ready=!0},initMigrateIndexHomeData:function(e){Ext.apply(SYNO.SDS.Drive.Define.Info,{index_home_config:e.config}),Ext.apply(SYNO.SDS.Drive.Define.Info,{migrated_to_index_home:e.migrated_to_index_home}),SYNO.SDS.Drive.Define.Info.migrateIndexHomeReady=!0},initSettingData:function(e){Ext.apply(SYNO.SDS.Drive.Define.Info,e);var t=SYNO.SDS.Drive.Define.Info.sharing_permission;SYNO.SDS.Drive.Define.Info.disabled_all_sharing=!(t.internal_link_sharing||t.invite_sharing||t.public_sharing),SYNO.SDS.Drive.Define.Info.use_nickname="nickname"===(SYNO.SDS.Drive.Define.Info.displayname_result||SYNO.SDS.Drive.Define.Info.default_displayname),SYNO.SDS.Drive.Define.Info.settingready=!0},initDelegatedInfo:function(e){SYNO.SDS.Drive.Define.Info.is_delegated=e.is_delegated},initEnv:function(){var e=this.findAppWindow(),t=this;e.getWebAPI().initial({callback:function(i,n){var o=function(){var o,s;if(i&&!n.has_fail?(o=SYNO.API.Util.GetValByAPI(n,SYNO.SDS.Drive.WebAPIDesc.info.api,SYNO.SDS.Drive.WebAPIDesc.info.method),t.initInfoData(o),o=SYNO.API.Util.GetValByAPI(n,SYNO.SDS.Drive.WebAPIDesc.get_setting.api,SYNO.SDS.Drive.WebAPIDesc.get_setting.method),t.initSettingData(o),o=SYNO.API.Util.GetValByAPI(n,SYNO.SDS.Drive.WebAPIDesc.get_migrate_index_home_config.api,SYNO.SDS.Drive.WebAPIDesc.get_migrate_index_home_config.method),t.initMigrateIndexHomeData(o),o=SYNO.API.Util.GetValByAPI(n,SYNO.SDS.Drive.WebAPIDesc.check_delegated.api,SYNO.SDS.Drive.WebAPIDesc.check_delegated.method),t.initDelegatedInfo(o),e.getEventMgr().fireEvent("envready",this),e.getEventMgr().fireEvent("settingready",this)):s=SYNO.SDS.Drive.Utils.getErrorStr(SYNO.API.Util.GetFirstError(n)),s)return void e.getEl().mask(s,"syno-ux-mask-info")};e.rendered?o.call(e):e.mon(e,"afterlayout",o,this,{single:!0,buffer:80})},scope:e}),e.sendWebAPI({compound:{stopwhenerror:!1,params:[SYNO.SDS.Drive.WebAPIDesc.office_status]},callback:function(t,i){if(t&&!i.has_fail){var n=SYNO.SDS.Drive.WebAPIDesc.office_status;if(SYNO.API.Util.GetValByAPI(i,n.api,n.method).migration){SYNO.SDS.Drive.Define.Info.office_migration=!0;var o=e.addWebAPITask(Ext.apply({interval:5e3,scope:this,callback:function(e,t){e&&!t.has_fail&&!t.migration&&t.start&&(o.stop(),function(){SYNO.API.Request({api:"SYNO.Core.Desktop.Initdata",method:"get",version:1,params:{action:"jsconfig"},callback:function(e,t,i,n){e&&(SYNO.SDS.Config.JSConfig=t.JSConfig,SYNO.SDS.Strings=t.Strings,SYNO.SDS.ServiceStatus=t.ServiceStatus,SYNO.SDS.AppPrivilege=t.AppPrivilege,SYNO.SDS.UrlTag=t.UrlTag,SYNO.SDS.JSLoad.init(),SYNO.SDS.appendMissingCSSFiles(t.CSSFiles),SYNO.SDS.JSLoad("SYNO.SDS.Office.Drive",function(){SYNO.SDS.Drive.Define.Info.office_migration=!1}))}})}.defer(1e3))}},SYNO.SDS.Drive.WebAPIDesc.office_status));o.start(!1)}}},scope:e})},waitSettingReady:function(){if(this.waitSettingReadyPromise)return this.waitSettingReadyPromise;var e;return e=SYNO.SDS.Drive.Define.Info.settingready?Promise.resolve():new Promise(function(e){this.findAppWindow().getEventMgr().on("settingready",e,null,{single:!0})}.bind(this)),this.waitSettingReadyPromise=e},prepareParam:function(e){return SYNO.SDS.Drive.Utils.prepareRequestParams(e)},onCreateCallBack:function(e,t,i,n){var o=this.findAppWindow();return!1!==n&&o.setStatusBusy(),function(s,r,a,l,d){!1!==n&&(o.clearStatusBusy(),o.setMaskOpacity(0)),Ext.isFunction(t)&&t.call(i||window,s,r||{},a,l,d),(s||!1===n)&&o.getEventMgr().fireEvent(e,s,r,a||{},l,e,d)}},createNode:function(e,t,i){var n=this.findAppWindow(),o=this,s=this.openDriveVueWindow(SYNO.SDS.Drive.Vue.DialogCreate,{cb:function(r){n.getWebAPI().createNode({params:{type:"folder",conflict_action:"autorename",path:String.format("{0}/{1}",SYNO.SDS.Drive.Utils.getPathId(e.file_id),r)},scope:o,callback:o.onCreateCallBack("createnodedone",Ext.createSequence(t||Ext.emptyFn,function(){s.onApplyCb.apply(s,arguments)}.createDelegate(n),i||window),i||window)})}}).component},lockNode:function(){function e(){i.getWebAPI().lockNodePromise({files:[SYNO.SDS.Drive.Utils.getPathId(n.get("file_id"))],perform_lock:!0}).then(function(e){SYNO.SDS.Drive.Utils.showToastMsg(i,SYNO.SDS.Drive._T("file_locking","lock_success"))}).catch(function(e){t._handleLockNodeError(e)}).finally(function(){i.getEventMgr().fireEvent("setnodelockdone")})}var t=this,i=this.findAppWindow(),n=this.getTarget(),o=this.getFileLockingCookieName();if("true"===localStorage.getItem(o))return void e();var s=SYNO.SDS.Drive._T("file_locking","lock_confirm_title"),r=String.format('<a class="syno-d-text-btn" target="_blank" href="{0}">{1}</a>',"https://kb.synology.com/DSM/help/SynologyDrive/drive_file_management?version=7#locking",SYNO.SDS.Drive._T("common","learn_more")),a=String.format(SYNO.SDS.Drive._T("file_locking","lock_confirm_msg"),r),l=SYNO.SDS.Drive.Utils.showPrompt({showDontAskAgainOption:!0,buttons:{confirm:{text:SYNO.SDS.Drive._T("common","lock")}}});l.confirm(s,a,void 0,{useHtml:!0}).then(function(t){l.close();var i=t.dontAskAgain;"confirm"===t.btn&&(i&&localStorage.setItem(o,"true"),e())})},unlockNode:function(){function e(){i.getWebAPI().requestUnlockPromise({path:SYNO.SDS.Drive.Utils.getPathId(n.get("file_id"))}).then(function(e){SYNO.SDS.Drive.Utils.showToastMsg(i,SYNO.SDS.Drive._T("file_locking","request_to_unlock_success"))}).catch(function(e){t._handleLockNodeError(e)})}var t=this,i=this.findAppWindow(),n=this.getTarget(),o=n.get("node_locking"),s=o.lock_user.name;(function(){return i.getWebAPI().lockNodePromise({files:[SYNO.SDS.Drive.Utils.getPathId(n.get("file_id"))],perform_lock:!1})})().then(function(e){SYNO.SDS.Drive.Utils.showToastMsg(i,SYNO.SDS.Drive._T("file_locking","unlock_success"))}).catch(function(i){if(1068===i.code){var n=SYNO.SDS.Drive._T("file_locking","request_unlock_title"),o=String.format(SYNO.SDS.Drive._T("file_locking","request_unlock_msg"),s);return void SYNO.SDS.Drive.Utils.showPrompt({buttons:{cancel:{text:SYNO.SDS.Drive._T("file_locking","request_to_unlock")}}}).confirm(n,o).then(function(t){"confirm"!==t&&e()})}t._handleLockNodeError(i)}).finally(function(){i.getEventMgr().fireEvent("setnodelockdone")})},_handleLockNodeError:function(e){var t=this.findAppWindow(),i=this.getTarget(),n=Ext.util.Format.htmlEncode(i.get("name")),o=String.format(SYNO.SDS.Drive.Utils.getErrorStr(e),n),s=SYNO.SDS.Drive.Utils.getErrorCode(e);if(Ext.isNumber(s)&&[1063,1064,1065].includes(s))return void SYNO.SDS.Drive.Utils.showToastMsg(t,o);t.getMsgBox().alert("",o)},getFileLockingCookieName:function(){return"synologydrive-file-locking-dont-ask-again"},ctxMenuCreateNode:function(e){this.createNode(e)},renameNode:function(e,t,i,n){var o=this,s=o.findAppWindow(),r=this.openDriveVueWindow(SYNO.SDS.Drive.Vue.DialogRename,{initName:e.name,selectAllText:e.selectAllText,validator:n,cb:function(n){var a={name:n};e.file_id&&(a=Ext.apply(a,{file_id:e.file_id})),s.getAction().setNodeTitle(a,Ext.createSequence(t||Ext.emptyFn,function(){r.onApplyCb.apply(r,arguments)}.createDelegate(o.findAppWindow()),i||window),i||window)}}).component},getChannelMap:function(e,t,i){this.findAppWindow().getWebAPI().getChannelMap({params:e,scope:i,callback:this.onCreateCallBack("getchannelmapdone",t,i,!1)})},getGroupMap:function(e,t,i){this.findAppWindow().getWebAPI().getGroupMap({params:e,scope:i,callback:this.onCreateCallBack("getgroupmapdone",t,i,!1)})},getMyDrive:function(e,t){var i=SYNO.SDS.Drive.Define.Info,n={path:"/mydrive"};this.findAppWindow().getWebAPI().getNode({params:n,callback:Ext.createSequence(function(e,t){e&&(i.mydrive_node=t,i.drive_id=t.file_id)},e||Ext.emptyFn,t||window)})},getNode:function(e,t,i){this.findAppWindow().getWebAPI().getNode({params:this.prepareParam(e),scope:i,callback:this.onCreateCallBack("getnodedone",t||Ext.emptyFn,i||window,!1)})},copyNode:function(e,t,i){i&&i.close(),this.mvcpNode("copy",e,t)},copyNodeTo:function(e,t,i,n,o,s){var r=this,a=this.openDriveVueWindow(SYNO.SDS.Drive.Vue.DialogTree,{title:SYNO.SDS.Drive._T("action","copy_to"),findAppWindow:this.findAppWindow.bind(this),cb:function(t,i){r.copyNode(Ext.apply({to_parent_folder:SYNO.SDS.Drive.Utils.getPathId(t),to_parent_folder_name:i},e||{}),void 0,a)},params:e,selections:s,createFolderCb:function(e,t){r.createFolderCB(a,e,t)}}).component},createFolderCB:function(e,t,i){var n=this.findAppWindow(),o=this;n.getWebAPI().createNode({params:{type:"folder",conflict_action:"autorename",path:String.format("{0}/{1}",SYNO.SDS.Drive.Utils.getPathId(t),i)},scope:o,callback:o.onCreateCallBack("createnodedone",e.afterCreateFolder,window)})},moveNode:function(e,t,i){i&&i.close(),this.mvcpNode("move",e,t)},moveNodeTo:function(e,t,i,n){var o=this,s=this.openDriveVueWindow(SYNO.SDS.Drive.Vue.DialogTree,{title:SYNO.SDS.Drive._T("action","move_to"),findAppWindow:this.findAppWindow.bind(this),cb:function(t,i){o.moveNode(Ext.apply({to_parent_folder:SYNO.SDS.Drive.Utils.getPathId(t),to_parent_folder_name:i},e||{}),void 0,s)},params:e,selections:n,createFolderCb:function(e,t){o.createFolderCB(s,e,t)}}).component},onTreeDlgGotoPath:function(e,t){if(!t)return void e.onGoToPath([]);e.setStatusBusy(),this.findAppWindow().getWebAPI().getNode({params:this.prepareParam(t),scope:this,callback:function(t,i){if(e.clearStatusBusy(),t&&!i.removed){var n,o,s=i.display_path,r=s.split("/"),a=[],l="file"===i.type;if("/"===s.charAt(0)&&r.splice(0,1),Ext.each(r,function(e,t){if(!l||r.length-1!==t)if(0!==t)a.push(o+r.slice(1,t+1).join("/"));else switch(e){case"mydrive":o="/mydrive/",n="node";break;case"team-folders":o="/team-folders/",n="team_folder";break;default:return!1}}),e.onGoToPath([{id:n}]),0!==a.length){var d,c=e.getTree().getSelectionModel().getSelectedNode();c&&(d=c.id),this.findAppWindow().getWebAPI().getNodes({params:{path:a},scope:this,callback:function(t,i){if(t&&!i.has_fail&&!e.getTree().isDestroyed){var o=e.getTree().getSelectionModel().getSelectedNode();if(!o||d===o.id){var s=[{id:n}];Ext.each(i.result,function(e){var t=e.data;if("dir"!==t.type)return!1;var i=t.name;i||(i=SYNO.SDS.Drive.Utils.getBaseName(t.display_path)),s.push({id:t.file_id,text:i,perm:t.capabilities,display_path:t.display_path})}),e.onGoToPath(s)}}}})}}}})},mvcpNode:function(e,t,i,n){var o=String.format("{0}_files",e),s=Ext.applyIf(t||{},{dry_run:!0});if(s.conflict_action||!1===s.dry_run)return delete s.dry_run,void this.doMvcpNode(e,s,i,n);SYNO.SDS.Drive.WebAPICore.sendPromise(o,s).then(function(t){delete s.dry_run,t.result&&this.needToShowConflictDialog(t.result)?this.showConflictDialog(e,t.result,function(t){this.doMvcpNode(e,s,i,n,t)},this):this.doMvcpNode(e,s,i,n)}.bind(this)).catch(function(e){SYNO.SDS.Drive.Utils.showErrorMsg(this.findAppWindow(),e)}.bind(this))},needToShowConflictDialog:function(e){if(Ext.isArray(e)&&0!==e.length){return e.filter(function(e){return!e.dst_locked_by_others}).length>0}},doMvcpNode:function(e,t,i,n,o){t.conflict_action||(t.conflict_action=o||"autorename"),this.postMvcpNode(e,t,i,n)},postMvcpNode:Ext.emptyFn,cleanNode:function(e,t,i){var n=this.findAppWindow(),o=SYNO.SDS.Drive._T("recycle","clean_all_confirm");n.getMsgBox().confirmDelete("",o,function(t){"yes"===t&&n.getTaskMgr().addTask(SYNO.SDS.Drive.TaskFactory.createEmptyRecycleTask(e.path,e.name))},this)},postDeleteNode:function(e,t,i){this.findAppWindow().getWebAPI().deleteNode({params:e,scope:this,callback:this.onCreateCallBack("deletenodedone",t,i)})},deleteNode:function(e,t,i){var n,o=this.findAppWindow(),s=SYNO.SDS.Drive._T;e=this.prepareParam(e);var r=1===e.files.length,a=this;n=!e.permanent&&e.revisions>0?r?s("file","recycle_confirm_one"):s("file","recycle_confirm"):r?s("file","delete_confim_one"):s("file","delete_confim"),r||(n=String.format(n,e.files.length)),o.getMsgBox().confirmDelete("",n,function(n){"yes"===n&&a.postDeleteNode(e,t,i)})},restoreNode:function(e,t,i){this.findAppWindow().getWebAPI().restoreNode({params:this.prepareParam(e),scope:this,callback:this.onCreateCallBack("restorenodedone",t,i)})},restoreFileVersion:function(e,t){var i=e||{};SYNO.SDS.Drive.WebAPICore.sendPromise("restore_revisions",i).then(function(e){delete i.dry_run,e.result&&this.needToShowConflictDialog(e.result)?this.showConflictDialog("restore",e.result,function(e){this.doRestoreFileVersion(i,t,e)},this):this.doRestoreFileVersion(i,t)}.bind(this)).catch(function(e){SYNO.SDS.Drive.Utils.showErrorMsg(this.findAppWindow(),e)}.bind(this))},doRestoreFileVersion:function(e,t,i,n,o){e.conflict_action||(e.conflict_action=i||"autorename"),this.postRestoreNode(e,t)},postRestoreNode:Ext.emptyFn,setNode:function(e,t,i){this.findAppWindow().getWebAPI().setNode({params:this.prepareParam(e),scope:this,callback:this.onCreateCallBack("setnodedone",t,i)})},setNodeTitle:function(e,t,i){this.findAppWindow().getWebAPI().setNode({params:this.prepareParam(e),scope:this,callback:this.onCreateCallBack("setnodetitledone",t,i)})},setNodeTag:function(e,t,i,n){this.findAppWindow().getWebAPI().setNodeTag({params:this.prepareParam(e),scope:this,callback:this.onCreateCallBack("setnodetagdone",t,i,!1)})},openFileRequestDialog:function(e){this.openDriveVueWindow(SYNO.SDS.Drive.Vue.DialogFileRequest,Ext.apply({findAppWindow:this.findAppWindow.bind(this)},e))},postDeleteFileRequest:function(e,t,i){var n=e.link_infos.map(function(e){return{sharing_link:e.sharing_link}});this.findAppWindow().getWebAPI().deleteFileRequest({params:{delete_infos:n},scope:this,callback:function(t,i){if(!t)return void SYNO.SDS.Drive.Utils.showErrorMsg(this.findAppWindow(),i);this.findAppWindow().getStoreMgr().getActiveStore().reload();var n,o=SYNO.SDS.Drive._T;if(1===e.link_infos.length){var s=Ext.util.Format.htmlEncode(e.link_infos[0].title);n=String.format(o("info_tip","file_request_deleted_one"),s)}else n=String.format(o("info_tip","file_request_deleted"),e.link_infos.length);SYNO.SDS.Drive.Utils.showToastMsg(this.findAppWindow(),n)}})},deleteFileRequest:function(e,t,i){var n,o=this.findAppWindow(),s=SYNO.SDS.Drive._T;e=this.prepareParam(e);var r=this;n=1===e.link_infos.length?s("file_request","delete_confirm_one"):String.format(s("file_request","delete_confirm"),e.link_infos.length),o.getMsgBox().confirmDelete("",n,function(n){"yes"===n&&r.postDeleteFileRequest(e,t,i)})},closeFileRequest:function(e,t,i){var n=this.findAppWindow(),o=SYNO.SDS.Drive._T,s=o("file_request","close_confirm");n.getMsgBox().confirm("",s,function(t){"yes"===t&&n.getWebAPI().updateFileRequestStatus({params:e,scope:this,callback:function(){this.findAppWindow().getStoreMgr().getActiveStore().reload();var e=SYNO.SDS.Drive._T("info_tip","close_file_request_done");SYNO.SDS.Drive.Utils.showToastMsg(this.findAppWindow(),e)}})}.bind(this))},openDriveVueWindow:function(e,t,i){var n=this.findAppWindow();return SYNO.SDS.Drive.Utils.openDriveVueWindow(n,e,t,i)},shareNode:function(e){e=this.prepareParam(e);var t=this,i=this.findAppWindow();this.openDriveVueWindow(SYNO.SDS.Drive.Vue.DialogShare,{findAppWindow:this.findAppWindow.bind(this),advShared:e.adv_shared,capabilities:e.capabilities,displayPath:e.display_path,name:e.name,path:e.path,type:e.type,setRoleAPI:function(e,n){i.getAction().setNodePerm(e,n,t)},advSharingLinkCB:function(e){i.getEventMgr().fireEvent("setnodepermdone",!0,void 0,{file_id:e})},closeHook:e.closeHook,shareUser:e.share_user,listeners:e.listeners})},setNodePerm:function(e,t,i){this.findAppWindow().getWebAPI().setNodePerm({params:this.prepareParam(e),scope:this,callback:this.onCreateCallBack("setnodepermdone",t,i)})},deleteNodePerm:function(e,t,i){if(e=this.prepareParam(e),e.files){var n=[],o=[];Ext.each(e.files,function(t){n.push("share_file"),o.push({path:t,permissions:[{action:"delete",member:{type:"user",name:e.username}}]})}),SYNO.SDS.Drive.WebAPICore.send(n,o,this.onCreateCallBack("deletenodepermdone",t,i))}else this.findAppWindow().getWebAPI().deleteNodePerm({params:e,scope:this,callback:this.onCreateCallBack("deletenodepermdone",t,i)})},infoNode:function(e){var t=this.findAppWindow();this.openDriveVueWindow(SYNO.SDS.Drive.Vue.DialogInfo,{findAppWindow:this.findAppWindow.bind(this),params:this.prepareParam(e),cb:function(e){t.getWebAPI().getNode({params:{path:e},callback:this.onLoadDataDone,scope:this})}})},createTag:function(e,t,i){this.findAppWindow().getWebAPI().createTag({params:e,scope:this,callback:this.onCreateCallBack("createtagdone",t,i)})},setTag:function(e,t,i,n,o){this.findAppWindow().getWebAPI().setTag({params:e,scope:this,callback:!1===o?t:this.onCreateCallBack("settagdone",t,i,!1)})},deleteTag:function(e,t,i){this.findAppWindow().getWebAPI().deleteTag({params:e,scope:this,callback:this.onCreateCallBack("deletetagdone",t,i)})},editSharedLabel:function(e){var t=SYNO.SDS.Drive.Vue.Utils.labelHelper.APIResponseToFormValues([e]),i=this.findAppWindow(),n=i.getCategoryPanel(),o=n.getSharedLabelStore(),s=o.data.items.filter(function(t){return t.get("owner")===e.owner}).map(function(e){return e.get("name")});this.openDriveVueWindow(SYNO.SDS.Drive.Vue.DialogSharedLabelEdit,{labelInfo:t[0],ownerLabelsNames:s,listeners:{apply:function(){var e=this.findAppWindow();e.getCategoryPanel().onReloadSharedLabel();var t=SYNO.SDS.Drive._T("shared_label","edit_label_success_msg");SYNO.SDS.Drive.Utils.showToastMsg(e,t)}.bind(this)}})},hideTag:function(e,t,i){this.findAppWindow().getWebAPI().hideTag({params:e,scope:this,callback:this.onCreateCallBack("hidetagdone",t,i)})},setShortcut:function(e,t,i){this.findAppWindow().getWebAPI().setShortcut({params:this.prepareParam(e),scope:this,callback:this.onCreateCallBack("setshortcutdone",t,i,!1)})},deleteShortcut:function(e,t,i){this.findAppWindow().getWebAPI().deleteShortcut({params:this.prepareParam(e),scope:this,callback:this.onCreateCallBack("deleteshortcutdone",t,i,!1)})},openFile:function(e,t,i){var n={},o=SYNO.SDS.Drive.Utils.getPathId(e.get("file_id")),s=e.get("name");n="recycle"===this.findAppWindow().getNavigation().getCategory()?Ext.apply({params:{files:[{path:o,version_id:0}],force_download:!1,download_type:"download"}},SYNO.SDS.Drive.WebAPIDesc.download_revisions):Ext.apply({params:{files:[o],force_download:!1,download_type:"download"}},SYNO.SDS.Drive.WebAPIDesc.download_files);var r=Ext.urlAppend(SYNO.API.GetBaseURL(n,!0,s),"_dc="+(new Date).getTime());if(!0===t)return SYNO.SDS.Drive.Utils.openURLWithReferer(r);SYNO.SDS.Drive.Utils.openURL(r,void 0,void 0,i)},openShareGetLinkMenu:function(e,t,i){var n=Ext.get(e);this.findAppWindow().getLeftPanel().getShareVuePanel().getVueInstance().open({findAppWindow:this.findAppWindow,panelType:i,anchor:n.dom,fileInfo:t})},openRequestGetLinkMenu:function(e,t,i){var n=Ext.get(e);this.findAppWindow().getLeftPanel().getRequestVuePanel().getVueInstance().open({findAppWindow:this.findAppWindow,panelType:i,anchor:n.dom,requestInfo:t})},listRecent:function(e,t,i){this.findAppWindow().getWebAPI().listRecent({params:e,callback:t,scope:i})},setChatChannel:function(e,t,i){this.findAppWindow().getWebAPI().setChatChannel({params:e,callback:t,scope:i})},requestAccess:function(e,t,i){this.findAppWindow().getWebAPI().requestAccess({params:this.prepareParam(e),callback:t,scope:i})},convertOffice:function(e,t,i){var n=this.prepareParam(e)||{};n.conflict_action||(n.conflict_action="autorename"),this.postConvertOffice(e,t,i)},postConvertOffice:function(e,t,i){t=Ext.isArray(t)?t:[t];var n=[];Ext.each(e.files,function(e){Ext.isObject(e)?n.push(e):n.push({path:e})}),e.files=n;var o=SYNO.SDS.Drive.TaskFactory.createConvertBgTask(Ext.apply({params:e,name:t},i));this.findAppWindow().getTaskMgr().addTask(o)},showConflictDialog:function(e,t,i,n){var o=[];Ext.each(t,function(e){e.dst_locked_by_others||o.push({src:{file_id:e.src_info.file_id,name:e.src_info.name,path:SYNO.SDS.Drive.Utils.parseDisplayPath(e.src_info.display_path),size:e.src_info.size,mtime:e.src_info.modified_time,file_type:e.src_info.file_type,renamed:SYNO.SDS.Drive.Utils.parseDisplayName(e.renamed)},dest:{file_id:e.dst_info.file_id,name:e.dst_info.name,path:SYNO.SDS.Drive.Utils.parseDisplayPath(e.dst_info.display_path),size:e.dst_info.size,mtime:e.dst_info.modified_time,file_type:e.dst_info.file_type}})}),new SYNO.SDS.Drive.Conflict.Dialog({action:e,conflicts:o,listeners:{scope:this,doaction:function(e){i&&Ext.isFunction(i)&&i.call(n,e)}}}).show()},syncDevice:function(e,t,i){var n=[];Ext.isEmpty(e.enable)||n.push(Ext.apply({params:this.prepareParam({file_id:e.enable,enable_sync:!0})},SYNO.SDS.Drive.WebAPIDesc.sync_to_device)),Ext.isEmpty(e.disable)||n.push(Ext.apply({params:this.prepareParam({file_id:e.disable,enable_sync:!1})},SYNO.SDS.Drive.WebAPIDesc.sync_to_device)),this.findAppWindow().getWebAPI().syncDevice({params:n,callback:this.onCreateCallBack("syncdevicedone",t,i)})},updateRecently:function(e,t,i){this.findAppWindow().getWebAPI().setNode({params:{path:SYNO.SDS.Drive.Utils.getPathId(e)},callback:t,scope:i})},syncPluginString:function(e){this.findAppWindow().getWebAPI().syncPluginString({params:{app:e},callback:function(e,t){if(e)for(var i in t)t.hasOwnProperty(i)&&(SYNO.SDS.Strings[i]=t[i])}})},getUserSetting:function(e,t){this.findAppWindow().getWebAPI().getUserSetting({callback:e,scope:t})},downloadOffice:Ext.emptyFn,downloadFileVersion:function(e,t,i,n){return this.downloadHandler.downloadFileVersion(e,t,i,n)},downloadAsZip:function(e,t,i,n){return this.downloadHandler.downloadAsZip(e,t,i,n)},downloadNode:function(e){return this.downloadNodes([e])},downloadNodes:function(e){return this.downloadHandler.downloadNodes(e)},downloadSelectedNodes:function(){this.downloadNodes(this.getTargets())},uploadFiles:function(){var e={tag:"input",type:"file",multiple:"multiple"};this.fileInput=Ext.getBody().createChild(e),this.fileInput.setStyle({position:"absolute",top:"-10000px",left:"-10000px"});var t=function(e,t){var i=t.files,n=this.findAppWindow(),o=n.getNavigation();SYNO.SDS.Drive.Utils.checkFileCanUpload(i).then(function(){var e=SYNO.SDS.Drive.Utils.getPathId(o.getLastPathId()),t=[];SYNO.SDS.Drive.TaskFactory.addUploadTasks(n,e,i,t)}).catch(function(e){SYNO.SDS.Drive.Utils.showAlertMsg(n,e)})};this.fileInput.on("change",t,this),this.fileInput.dom.click()},uploadFolder:function(){var e={tag:"input",type:"file",webkitdirectory:"webkitdirectory"};this.folderInput=Ext.getBody().createChild(e),this.folderInput.setStyle({position:"absolute",top:"-10000px",left:"-10000px"});var t=function(e,t){var i=t.files;if(!(i.length<=0)){var n=function(e){if(!Ext.isDefined(e))return"";var t="",i=e.indexOf("/");return-1!==i&&(t=e.substr(0,i)),t}(i[0].webkitRelativePath),o=this.findAppWindow(),s=o.getNavigation();SYNO.SDS.Drive.Utils.checkFileCanUpload(i).then(function(){var e=SYNO.SDS.Drive.Utils.getPathId(s.getLastPathId());SYNO.SDS.Drive.TaskFactory.addUploadFolderTask(o,e,n,i)}).catch(function(e){SYNO.SDS.Drive.Utils.showAlertMsg(o,e)})}};this.folderInput.on("change",t,this),this.folderInput.dom.click()},uploadFromNAS:function(){var e=function(e,t){if(0!==t.length){var i=this.findAppWindow(),n=i.getNavigation(),o=SYNO.SDS.Drive.Utils.getPathId(n.getLastPathId());if("from_nas"===t[0].source){var s=[],r=[];Ext.each(t,function(e){s.push(e.real_path),r.push(e.name)},this),i.getTaskMgr().addTask(SYNO.SDS.Drive.TaskFactory.createUploadFromNasTask(o,s,r))}else if("from_pc"===t[0].source){var a=[],l=[];Ext.each(t,function(e){a.push(e.fileObj),l.push(e.fileEntry||void 0)}),SYNO.SDS.Drive.TaskFactory.addUploadTasks(i,o,a,0===l.length?void 0:l)}}};SYNO.SDS.AppLaunch("SYNO.SDS.Drive.Upload.Application",{enableSelectDir:!0,from_upload:!1,from_drive:!1,from_url:!1,activeItem:"from_nas",onApply:e.createDelegate(this)})},transferNodes2C2:function(){return this.c2TransferHandler.sendCopy(this.getTargets())},editTeamFolder:function(e,t,i){
this.teamFolderEditor=this.openDriveVueWindow(SYNO.SDS.Drive.Vue.TeamFolderEditor,{findAppWindow:this.findAppWindow.bind(this),jumpToAdminConsole:this.jumpToAdminConsole.bind(this),jumpToControlPanelShareTab:this.jumpToControlPanelShareTab.bind(this),jumpToUserHomeSettings:this.jumpToUserHomeSettings.bind(this)}).component},goToDsmFunction:function(e,t,i){var n=new SYNO.SDS.WindowLauncher(SYNO.SDS.WindowLauncher.Util.parseOptions(e,Ext.apply({fn:t,tab:i},this.findAppWindow().openConfig))),o=Ext.urlDecode(window.location.search.substr(1))||{};return n.url=Ext.urlAppend(window.location.protocol+"//"+window.location.host,Ext.urlEncode(Ext.apply(o,{launchApp:e})),!0),n.openNewWindow(void 0,n.getLaunchURL())},jumpToUserHomeSettings:function(){return this.goToDsmFunction("SYNO.SDS.AdminCenter.Application","SYNO.SDS.AdminCenter.User.Main","option_tab")},jumpToAdminConsole:function(){return this.goToDsmFunction("SYNO.SDS.CSTN.Instance","SYNO.SDS.CSTN.PanelSharing")},jumpToControlPanelShareTab:function(){return this.goToDsmFunction("SYNO.SDS.AdminCenter.Application","SYNO.SDS.AdminCenter.Share.Main")}}),Ext.define("SYNO.SDS.Drive.Share.GetLink.FieldSet.Base",{extend:"SYNO.ux.FieldSet",constructor:function(e){SYNO.Assert(e.file_info,"need file_info"),this.callParent([Ext.apply({collapsible:!1,items:[this.getShareLinkComposite(),this.getPermissionInfo()]},e)]),this.addEvents("copy_url_done","copy_url_failed")},getShareLinkComposite:function(){return this.shareLinkComposite||(this.shareLinkComposite=new SYNO.SDS.Utils.ClipBoardComposite({cls:"syno-d-link-composite-field",disableWhenEmpty:!1,hideLabel:!0,defaultMargins:"0 8 0 0",textFieldCfg:{cls:"syno-d-share-link-text selectabletext allowDefCtxMenu",readOnly:!0,selectOnFocus:!0,width:312},btnCfg:{tooltip:SYNO.SDS.Drive._T("info","copy_url"),cls:"syno-d-copy-btn",iconCls:"syno-d-copy-btn-icon",btnStyle:"grey",width:40},listeners:{clipsucceed:function(e){this.fireEvent("copy_url_done")},clipfailed:function(e){this.fireEvent("copy_url_failed")},scope:this}}))},copyToClipBoard:function(){this.getShareLinkComposite().btn.btnEl.dom.click()},getLinkField:function(){return this.shareLinkComposite.textField},getPermissionInfo:function(){return{cls:"syno-d-getlink-permission-info",itemId:"permission_info",xtype:"box",html:""}},updatePermissionInfo:function(e){var t=this.getComponent("permission_info");t.rendered?t.update(e):t.html=e}}),Ext.define("SYNO.SDS.Drive.Share.GetLink.FieldSet.ShareLink",{extend:"SYNO.SDS.Drive.Share.GetLink.FieldSet.Base",statics:{getPermissionText:function(e){var t=SYNO.SDS.Drive._T,i=t("perm","limit"),n=t("perm","limit_desc");return SYNO.SDS.Drive.Define.Info.sharing_permission.invite_sharing||(n=t("perm","limit_you_desc")),Ext.each(e.shared_with,function(e){switch(e.type){case"public":i=t("perm","public"),n={previewer:t("perm","public_previewer_desc"),viewer:t("perm","public_ro_desc"),commenter:t("perm","public_commenter_desc"),editor:t("perm","public_rw_desc"),preview_commenter:t("perm","public_preview_commenter_desc")}[e.role];break;case"internal":i=t("perm","app"),n={previewer:t("perm","app_previewer_desc"),viewer:t("perm","app_ro_desc"),commenter:t("perm","app_commenter_desc"),editor:t("perm","app_rw_desc"),preview_commenter:t("perm","app_preview_commenter_desc")}[e.role]}},this),String.format("<b>{0}</b> - {1}",i,n)}},constructor:function(e){var t=SYNO.SDS.Drive._T,i=SYNO.SDS.Drive.Utils.isAdvSharingPage();this.callParent([Ext.apply({title:"dir"===e.file_info.file_type?t("share","directory_link"):t("share","file_link"),hidden:i},e)]),i?this.readyPromise=Promise.resolve():(this.readyPromise=this.initQuerySharing(),this.updatePermissionInfo(SYNO.SDS.Drive.Share.GetLink.FieldSet.ShareLink.getPermissionText(e.file_info)))},getReadyPromise:function(){return this.readyPromise},initQuerySharing:function(){var e=this;return SYNO.SDS.Drive.WebAPICore.sendPromise("get_file_link",{path:this.file_info.path}).then(function(t){e.updateSharingResult(t)}).catch(function(e){SYNO.Debug.error(e,e.stack)})},updateSharingResult:function(e){this.getLinkField().setValue(e.url)}}),Ext.define("SYNO.SDS.Drive.Share.GetLink.FieldSet.AdvanceSharingLink",{extend:"SYNO.SDS.Drive.Share.GetLink.FieldSet.Base",statics:{getPermissionText:function(e){var t=SYNO.SDS.Drive._T,i=t("perm","public"),n={accesser:t("perm","public_access_desc"),previewer:t("perm","public_previewer_desc"),viewer:t("perm","public_ro_desc"),commenter:t("perm","public_commenter_desc"),editor:t("perm","public_rw_desc"),preview_commenter:t("perm","public_preview_commenter_desc")}[e.role];return String.format("<b>{0}</b> - {1}",i,n)}},constructor:function(e){this.fileInfo=e.file_info;var t=SYNO.SDS.Drive._T,i=!this.fileInfo.capabilities.can_share&&!SYNO.SDS.Drive.Utils.isAdvSharingPage();this.callParent([Ext.apply({title:t("share","public_protection_link"),hidden:i},e)]),this.readyPromise=i?Promise.resolve():this.initQueryAdvSharing()},getReadyPromise:function(){return this.readyPromise},initQueryAdvSharing:function(){var e=this;return this.fileInfo.capabilities.can_share?SYNO.SDS.Drive.WebAPICore.sendPromise("get_adv_sharing",{path:this.file_info.path}).then(function(t){e.updateAdvSharingResult(t)}).catch(function(t){t.code&&1036===t.code||SYNO.Debug.error(t),e.hide()}):SYNO.SDS.Drive.Utils.isAdvSharingPage()?SYNO.SDS.Drive.WebAPICore.sendPromise("get_base_url",{}).then(function(t){var i=t.base_url+window.location.pathname,n={url:i,role:"accesser"};e.updateAdvSharingResult(n)}).catch(function(){e.hide()}):(e.hide(),Promise.resolve())},updateAdvSharingResult:function(e){this.getLinkField().setValue(e.url),this.updatePermissionInfo(SYNO.SDS.Drive.Share.GetLink.FieldSet.AdvanceSharingLink.getPermissionText(e))}}),Ext.define("SYNO.SDS.Drive.Share.GetLink.Panel",{extend:"SYNO.ux.FormPanel",constructor:function(e){SYNO.Assert(e.file_info,"need file info"),SYNO.Assert(e.file_info.path,"need path"),SYNO.Assert(e.file_info.capabilities,"need capabilities"),SYNO.Assert(e.file_info.shared_with,"need shared_with"),SYNO.Assert(void 0!==e.file_info.file_type,"need file_type"),this.callParent([{title:SYNO.SDS.Drive._T("share","get_link"),cls:"syno-d-share-getlink-formpanel",layout:"anchor",autoFlexcroll:!1,items:[this.share_link=new SYNO.SDS.Drive.Share.GetLink.FieldSet.ShareLink({file_info:e.file_info}),this.adv_share_link=new SYNO.SDS.Drive.Share.GetLink.FieldSet.AdvanceSharingLink({file_info:e.file_info}),this.getShareSettingButton(e.file_info)]}]),this.addEvents("open_share_setting","copy_url_done","copy_url_failed"),this.relayEvents(this.share_link,["copy_url_done","copy_url_failed"]),this.relayEvents(this.adv_share_link,["copy_url_done","copy_url_failed"])},isAdvanceSharingLinkShown:function(){return!this.adv_share_link.hidden},copySharedLink:function(){(this.share_link.hidden||this.adv_share_link.hidden)&&(this.share_link.hidden?this.adv_share_link.hidden||this.adv_share_link.copyToClipBoard():this.share_link.copyToClipBoard())},getReadyPromise:function(){return this.readyPromise||(this.readyPromise=Promise.all([this.share_link.getReadyPromise(),this.adv_share_link.getReadyPromise()]))},getShareSettingButton:function(e){var t=SYNO.SDS.Drive._T,i=!SYNO.SDS.Drive.Utils.checkSharePrivilge(e,e.capabilities.can_share);return{xtype:"button",text:t("share","sharing_settings"),handler:this.onOpenShareSetting,scope:this,hidden:i,buttonSelector:"div:first-child",iconCls:"syno-d-text-btn",template:new Ext.Template('<div id="{4}">',"<div></div>","</div>")}},onOpenShareSetting:function(){this.fireEvent("open_share_setting")}}),Ext.define("SYNO.SDS.Drive.ArrowMenu",{extend:"SYNO.ux.Menu",constructor:function(e){this.callParent([Ext.apply({cls:"syno-d-arrow-menu "+(e.cls||""),resizable:!1,autoHeight:!0,enableScrolling:!1},e)]),this.mon(this,"hide",this.destroy,this),this.mon(this,"beforedestroy",this.destroyArrow,this)},open:function(e){if(!this.isDestroyed&&!this.destroying){this.el||(this.render(),this.doLayout(!1,!0));var t=Ext.get(e),i=this.getDefaultLayout(),n=SYNO.SDS.Drive.Utils.getAlignToXY(this.el,t,i.position,i.offset),o=n.viewportReachBoundry;i=this.getLayout(o),n=SYNO.SDS.Drive.Utils.getAlignToXY(this.el,t,i.position,i.offset),this.showAt(n.xy),i=this.getArrowLayout(o),this.showArrow(e,i)}},showArrow:function(e,t){this.arrows=[],this.arrows.push(Ext.DomHelper.append(Ext.getBody(),'<div class="syno-d-arrow syno-d-arrow-white"></div>',!0)),this.arrows.push(Ext.DomHelper.append(Ext.getBody(),'<div class="syno-d-arrow syno-d-arrow-black"></div>',!0)),Ext.each(this.arrows,function(i){i.alignTo(e,t.position,t.offset)})},destroyArrow:function(){this.arrows&&Ext.each(this.arrows,function(e){e.remove()})},getDefaultLayout:function(){return{position:"tl-bl?",offset:[0,10]}},getLayout:function(e){return this.getDefaultLayout()},getArrowLayout:function(e){return{position:e.bottom?"b-t":"t-b",offset:[0,0]}}}),Ext.define("SYNO.SDS.Drive.Share.GetLink.Menu",{extend:"SYNO.SDS.Drive.ArrowMenu",constructor:function(e){SYNO.Assert(e.file_info,"need file info"),SYNO.Assert(e.file_info.path,"need path"),SYNO.Assert(e.file_info.capabilities,"need capabilities"),SYNO.Assert(e.file_info.shared_with,"need shared_with"),SYNO.Assert(void 0!==e.file_info.file_type,"need file_type");var t=e.file_info;delete e.file_info,this.callParent([Ext.apply({cls:"syno-d-getlink-menu",title:SYNO.SDS.Drive._T("share","get_link"),items:this.panel=new SYNO.SDS.Drive.Share.GetLink.Panel({owner:this,file_info:t})},e)]),this.mon(this.panel,"open_share_setting",this.onOpenShareSetting,this),this.mon(this.panel,"copy_url_done",this.onCopyUrlDone,this)},onCopyUrlDone:function(){SYNO.SDS.Drive.Utils.showToastMsg(this.findAppWindow(),SYNO.SDS.Drive._T("share","url_copied"))},onOpenShareSetting:function(){this.hide(),this.getAction().shareNode()},setAction:function(e){this.action=e},getAction:function(){return this.action||SYNO.SDS.Drive.GetWindow().getAction()},open:function(e,t){this.panelType=e,this.panel.getReadyPromise().then(function(){SYNO.SDS.Drive.ArrowMenu.prototype.open.call(this,t),this.panel.copySharedLink()}.bind(this))},getDefaultLayout:function(){return this.getLayout()},getLayout:function(e){var t,i,n,o={position:"tl-bl?",offset:[0,0]};switch(this.panelType){case"toolbar":o.offset=[-20,16];break;case"menu_pathbar":o.offset=[-50,10],o.position="tl-b?";break;case"thumbnail":o.offset=[-1,10],e&&(t="{0}{1}-{2}{1}?",i="l",n="tb".split(""),e.right&&(i="r",o.offset[0]=1),e.bottom&&(n="bt".split(""),o.offset[1]=-18),o.position=String.format(t,n[0],i,n[1]));break;case"detail":case"compact":case"list":o.offset=[12,6];break;case"tile":o.offset=[-10,8],e&&(t="{0}{1}-{2}{1}?",i="l",n="tb".split(""),e.right&&(i="r",o.offset[0]=0),e.bottom&&(n="bt".split(""),o.offset[1]=-8),o.position=String.format(t,n[0],i,n[1]));break;case"snippet":o.offset=[5,4],e&&e.bottom&&(o.offset=[5,7])}return o},getArrowLayout:function(e){var t={position:e.bottom?"bl-tl":"tl-bl",offset:[0,0]};switch(this.panelType){case"toolbar":t.offset=[6,6];break;case"menu_pathbar":t.offset=[-24,0],t.position="tl-b?";break;case"thumbnail":t.position=e.bottom?"b-t":"t-b",t.offset=e.bottom?[-3,-10]:[-3,0];break;case"detail":t.offset=e.bottom?[45,3]:[45,-4];break;case"list":case"compact":t.offset=e.bottom?[38,3]:[38,-4];break;case"tile":t.offset=e.bottom?[7,0]:[7,-2];break;case"snippet":t.offset=e.bottom?[30,2]:[30,-6]}return e.bottom&&(t.offset[1]-=5),t}}),Ext.ns("SYNO.SDS.Drive"),Ext.define("SYNO.SDS.Drive.PasswordPanel",{extend:"Ext.Container",constructor:function(e){var t=e.title,i=e.prompt;this.errMsgBox=new Ext.BoxComponent({hidden:!0,cls:"syno-d-passwd-error"});var n=SYNO.SDS.Drive.Utils.isSmallScreenSize(),o={cls:"syno-d-passwd-background",xtype:"container",boxMinHeight:this.getBoxMinHeight(),layout:{type:"vbox",align:"center",pack:"center"},items:[{xtype:"container",cls:"syno-d-passwd-container",items:[{xtype:"box",cls:"syno-d-passwd-title",hidden:n,html:t},{xtype:"container",layout:"border",cls:"syno-d-passwd-container-panel",items:[{region:"north",border:!1,cls:"syno-d-passwd-north-box",autoHeight:!0,layout:{type:"vbox",align:"center",pack:"center"},items:[{xtype:"box",cls:"syno-d-passwd-icon"},{xtype:"box",cls:"syno-d-passwd-title",hidden:!n,html:t},{xtype:"syno_displayfield",cls:"syno-d-passwd-desc",value:i}]},this.form=new Ext.form.FormPanel({region:"center",xtype:"form",cls:"syno-d-passwd-form",border:!1,autoHeight:!0,layout:{type:"vbox",align:"center",pack:"center"},items:[this.getPassField()].concat(n?[this.errMsgBox]:[]).concat([{xtype:"box",cls:"syno-d-passwd-margin-box"},this.getSubmitBtn()])})].concat(n?[]:this.errMsgBox)}]}]};Ext.apply(o,e),this.callParent([o]),this.mon(this,"afterlayout",this.afterApplyLayout,this,{single:!0}),n&&(this.mon(this,"afterlayout",function(){var e=this.items.items[0],t=0;e.items.items[1].items.items.forEach(function(e){t+=e.getOuterSize().height});t+=50,e.getEl().setStyle("top","calc(((100% - "+t+"px) * 0.4) + 50px)"),this.mon(this.getPassField(),"focus",this.doFocus,this,{buffer:80}),this.mon(this.getPassField(),"blur",this.doBlur,this),this.mon(this.findAppWindow(),"resize",this.doResize,this,{buffer:80})},this,{buffer:80,single:!0}),this.mon(this,"activate",this.onActivate,this),this.mon(this,"deactivate",this.onDeActivate,this)),this.owner&&this.mon(this.owner,"show",this.afterShow,this,{single:!0})},getBoxMinHeight:function(){if(SYNO.SDS.Drive.Utils.isSmallScreenSize()){var e=Ext.getBody().getHeight();return e<400?400:e}},onActivate:function(){this.originalAutoScroll=this.owner.autoScroll||!1,this.owner.setAutoScroll(!0)},onDeActivate:function(){this.owner.setAutoScroll(this.originalAutoScroll)},getPassField:function(){return this.passField?this.passField:(this.passField=new SYNO.ux.TextField({cls:"syno-d-passwd-pass",emptyText:_T("common","password"),textType:"password",enableKeyEvents:!0,hideLabel:!0,listeners:{scope:this,keydown:this.onKeyDown}}),this.passField)},doResize:function(){this.getPassField().getEl().dom===document.activeElement&&this.scrollToPassField()},doFocus:function(){this.scrollToPassField()},scrollToPassField:function(){this.getPassField().getEl().scrollIntoView(this.owner.body)},doBlur:function(){var e=this.findAppWindow();e.maximize(),e.doLayout()},onKeyDown:function(e,t){Ext.EventObject.ENTER===t.getKey()&&this.onSubmit()},afterApplyLayout:function(){this.items.items[0].addClass("syno-d-passwd-container-anim")},afterShow:function(){this.passField.focus(!1,300)},validateAsync:function(){return Promise.resolve()},getSubmitBtn:function(e){return this.submitBtn||(this.submitBtn=new SYNO.ux.Button({cls:"syno-d-passwd-btn",xtype:"syno_button",btnStyle:"default",text:_T("common","enter"),scope:this,disabled:e,handler:this.onSubmit}))},setFormDisabled:function(e){this.passField.setDisabled(e),this.submitBtn.setDisabled(e)},setError:function(e){this.errMsgBox.show(),this.errMsgBox.update(e),this.doLayout();var t=this.passField;t.markInvalid(),t.addClass("syno-d-passwd-invalid"),t.focus(),t.selectText(0,t.getValue().length)},setPassword:function(e){this.passField.setRawValue(e)},onValidateError:Ext.emptyFn,onValidateSuccess:Ext.emptyFn,onSubmit:function(){SYNO.SDS.Drive.Utils.isSmallScreenSize()||(this.errMsgBox.hide(),this.passField.clearInvalid()),this.setFormDisabled(!0),this.validateAsync().then(this.onValidateSuccess.bind(this)).catch(this.onValidateError.bind(this))}}),Ext.define("SYNO.SDS.Drive.Share.AdvancedPasswordPanel",{extend:"SYNO.SDS.Drive.PasswordPanel",constructor:function(e){this.callParent([Ext.apply({title:SYNO.SDS.Drive._T("share","protected_title"),prompt:SYNO.SDS.Drive._T("share","protected_prompt")},e)])},validateAsync:function(){return new Promise(function(e,t){this.findAppWindow().getWebAPI().checkAdvSharingPassword({params:{sharing_link:window.getDriveSharingLink(),password:this.passField.getValue()},callback:function(i,n){(i?e:t)(n)},scope:this})}.bind(this))},onValidateError:function(e){this.setFormDisabled(!1),this.setError(SYNO.SDS.Drive.Utils.getErrorStr(e))},onValidateSuccess:function(e){location.reload(!0)}}),Ext.ns("SYNO.SDS.Drive.Mail"),Ext.define("SYNO.SDS.Drive.Mail.Template",{statics:{get:function(e,t,i,n,o,s){var r="",a=i;return s||(s=""),r="<html><head><style>.syno-o-file:hover{color:#0B8BE5;}.syno-o-file:active{color:#007ED9;}.syno-o-btn:hover{border-color:#13ACBA;background-color:#2AC6D4;}.syno-o-btn:active{border-color:#0093A1;background-color:#13ACBA;}</style></head><body>",r+="<div style='width:95%;width:calc(100% - 64px);min-width:704px;padding:24px 32px 16px 32px;background-color:#ECEEF0;text-align:center;'><div style='display:inline-block;max-width:720px;min-width:640px;text-align:left;font-family:Arial,Verdana,Helvetica,sans-serif;box-shadow:0 1px 4px rgba(0,0,0,0.1);'>\r\n<div style='padding:28px;background:#fff;'><div style='font-size:13px;line-height:20px;color:#2E3032;'><b>",r+=e,r+="</b>&nbsp;"+t,r+="</div><div style='height:12px;'></div><div style='font-size:18px;display:table;'><div style='display:table-row;height:30px;'><span style='display:table-cell;vertical-align:middle;'>\r\n<img src='data:image/png;base64,",n&&(r+=n),r+="' style='vertical-align:middle;height:24px;width:24px;'/></span>\r\n<span style='display:table-cell;padding-left:8px;vertical-align:middle;'><a class='syno-o-file' href='",r+=i,r+="' style='color:#30A1F2;vertical-align:middle;text-decoration:none;'>",r+="{0}",r+="</a></span></div></div>\r\n",s?(r+="<div style='height:24px;'></div><div style='border-left:3px solid #CED0D2;' dir='ltr'><span style='display:inline-block;padding-left:8px;'>",r+="{1}",r+="</span></div>\r\n"):r+="{1}",r+="\r\n<div style='height:32px;'></div><div><a class='syno-o-btn' href='",r+=a,r+="' target='_blank' style='background-color:#1EB9C7;border:1px solid #09A0AD;border-radius:3px;color:white;display:inline-block;font-family:Arial,Verdana,Helvetica,sans-serif;font-size:13px;height:28px;line-height:28px;min-width:50px;outline:0px;padding:0 14px;text-align:center;text-decoration:none'>",r+="{2}",r+="</a>\r\n</div></div></div><div style='padding:16px 8px 0 8px;width:100%;text-align:center;font-size:13px;color:#7E8082;line-height:24px;'>",r+="{3}",r+="</div></div></body></html>",String.format(r,Ext.util.Format.htmlEncode(SYNO.SDS.Drive.Utils.parseDisplayName(o)),Ext.util.Format.htmlEncode(s),SYNO.SDS.Drive._T("action","open"),SYNO.SDS.Drive._T("drive","displayname"))}}}),Ext.define("SYNO.SDS.Drive.MailDialog",{extend:"SYNO.SDS.Drive.ModalWindow",constructor:function(e){this.contactCacheData={};var t=this.fillConfig(e);this.callParent([t]),this.mon(this,"afterlayout",this.onLoadData,this,{single:!0})},fillConfig:function(e){var t={width:600,height:412,title:_T("mail","application_title"),cls:"syno-d-mail-dlg",buttons:[{text:_T("common","cancel"),handler:this.onClose,scope:this},{btnStyle:"default",itemId:"submit_button",text:_T("common","send"),handler:this.onBeforeConfirm,scope:this}],items:this.initPanel(),listeners:{beforeclose:this.onClose,scope:this}};return Ext.apply(t,e)},initPanel:function(){this.store=new Ext.data.JsonStore({fields:["name","address"],data:[],sortInfo:{field:"address",direction:"ASC"}}),this.addManagedComponent(this.store);var e=new Ext.XTemplate('<tpl for="."><div class="x-combo-list-item" style="height: 53px"><div style="margin-left:10px"><tpl if="name!=address;"><div style="height:20px;margin-top:4px;font-weight:bold;">{name:htmlEncode}</div></tpl><div class="syno-mail-contactaccount">{address:htmlEncode}</div></div></div></tpl>'),t=new Ext.XTemplate('<tpl if"name!=null && name!=&quot;&quot;";>{name:htmlEncode}</tpl><tpl if="name==null || name==&quot;&quot;">{address:htmlEncode}</tpl>'),i=function(e){var t=new RegExp("^"+e.query+"|\\s+"+e.query,"gi");return this.store.filterBy(function(e){return!(!e.data.name||null===e.data.name.match(t))||!(!e.data.address||null===e.data.address.match(t))}),e.combo.onLoad(),!1},n=function(e,t){""!==t&&e.validateValue(t)&&e.addNewItem({name:t,address:t},!0)},o=[{xtype:"syno_superboxselect",fieldLabel:_T("mail","mail_to_desc"),expandBtnCls:"syno-d-mail-dlg-superboxselect-expand",itemId:"mail_to_field",hideTrigger:!0,typeAhead:!1,allowBlank:!1,displayField:"name",displayFieldTpl:t,valueField:"address",allowAddNewData:!0,addNewDataOnBlur:!0,mode:"local",tpl:e,vtype:"email",blankText:_JSLIBSTR("extlang","emailText"),listeners:{newitem:n,beforequery:i,scope:this},store:this.store},{xtype:"syno_superboxselect",fieldLabel:_T("mail","mail_cc_desc"),itemId:"mail_cc_field",expandBtnCls:"syno-d-mail-dlg-superboxselect-expand",hideTrigger:!0,typeAhead:!0,displayField:"name",displayFieldTpl:t,valueField:"address",allowAddNewData:!0,addNewDataOnBlur:!0,mode:"local",tpl:e,vtype:"email",blankText:_JSLIBSTR("extlang","emailText"),listeners:{newitem:n,beforequery:i,scope:this},store:this.store},{xtype:"syno_textfield",fieldLabel:_T("mail","mail_subject"),itemId:"mail_subject"},{xtype:"syno_displayfield",cls:"syno-d-mail-dlg-shared-file",fieldLabel:SYNO.SDS.Drive._T("mail","shared_file"),htmlEncode:!1,itemId:"shared_file",listeners:{scope:this,single:!0,render:function(e){var t=e.getEl();this.mon(e.getEl(),"click",function(e){t.hasClass("x-item-disabled")||window.open(this.url,"_blank")},this)}}},{xtype:"syno_textarea",fieldLabel:SYNO.SDS.Drive._T("mail","additional_msg"),itemId:"texteditor",height:130,grow:!0,growMin:130,growMax:130}],s={trackResetOnLoad:!0,autoHeight:!0,defaults:{anchor:"100%"},items:o},r=new SYNO.ux.FormPanel(s);return this.panel=r,r},onSetData:function(e,t){this.data=e,this.url=t;var i=e.name,n=String.format('<span class="syno-d-start-ntype" style="{0}"></span>',SYNO.SDS.Drive.FileType.getFileTypeIconStyle("dir"===e.type?"folder":SYNO.SDS.Drive.Utils.getExt(i),16));i=SYNO.SDS.Drive.Utils.parseDisplayName(e.name);var o=Ext.util.Format.htmlEncode(i),s=Ext.util.Format.htmlEncode(o);this.panel.getForm().setValues({shared_file:n+'<span class="syno-d-file-name" ext:qtip="'+s+'">'+o+"</span>",mail_subject:String.format(SYNO.SDS.Drive._T("mail","subject"),i)})},onBeforeConfirm:function(){return""===this.panel.getComponent("mail_to_field").getValue()?void this.getMsgBox().alert("",_T("mail","mailto_alert")):""===this.panel.getComponent("mail_subject").getValue()?void this.getMsgBox().confirm("",_T("mail","mail_subject_alert"),function(e){"yes"===e&&this.onConfirm()},this):void this.onConfirm()},onConfirm:function(){var e=this.panel.getComponent("mail_to_field").getValue().split(","),t=this.panel.getComponent("mail_cc_field").getValue(),i=this.panel.getComponent("mail_subject").getValue(),n=this.panel.getComponent("texteditor").getValue(),o=this.getTemplate(this.url,this.data,n),s={to:Ext.encode(e),subject:i,body:o};Ext.isEmpty(t)||(s.cc=Ext.encode(t.split(","))),this.onSendMail(s)},onSendMail:function(e){this.setStatusBusy(),this.sendWebAPI({api:"SYNO.Personal.MailAccount.Mail",method:"send",version:1,params:Ext.apply(e,{background:!1}),callback:function(e,t,i){if(this.clearStatusBusy(),e)this.doClose();else{var n=SYNO.SDS.Drive.MailDialog.Utils.APIErrorGet(t.code);this.getMsgBox().alert("",n)}},scope:this})},onLoadData:function(){var e=[];e.push({api:"SYNO.Personal.MailAccount",method:"get",version:1}),e.push({api:"SYNO.Personal.MailAccount.Contacts",method:"list",version:1}),this.setStatusBusy(),this.sendWebAPI({params:{},compound:{params:e},scope:this,callback:function(e,t,i,n){if(this.clearStatusBusy(),!e)return void this.getMsgBox().alert("",SYNO.SDS.Drive.MailDialog.Utils.APIErrorGet(SYNO.API.Util.GetFirstError(t)),function(){this.doClose()},this);this.setAccountData(t.result)}})},setAccountData:function(e){var t,i;if(e[0].error){var n=SYNO.SDS.Drive.MailDialog.Utils.APIErrorGet(e[0].error.code);return void this.getMsgBox().alert("",n,function(){this.doClose()},this)}if(t=e[0].data.data,0===t.length)return void this.getMsgBox().alert("",SYNO.SDS.Drive._T("mail","setup_up"),function(e){this.doClose()},this);e[1].error||(i=e[1].data.result,this.contactCacheData[this.alias]=i,this.store.loadData(i,!0))},onClose:function(){return this.panel.getForm().isDirty()?(this.getMsgBox().confirm("",_T("mail","mail_leave_desc"),function(e){"yes"===e&&this.doClose()},this),!1):void this.doClose()},getTemplate:function(e,t,i){var n,o=t.name,s=t.type,r=SYNO.SDS.Drive._T;if("dir"===s)n=r("mail","share_dir");else if(SYNO.SDS.Drive.Utils.isOfficeFile(o))switch(SYNO.SDS.Drive.Utils.getExt(o)){case SYNO.SDS.Drive.FileType.SYNODOC:n=r("mail","share_doc");break;case SYNO.SDS.Drive.FileType.SYNOSHEET:n=r("mail","share_sheet");break;case SYNO.SDS.Drive.FileType.SYNOSLIDE:n=r("mail","share_slide");break;default:n=r("mail","share_file")}else n=r("mail","share_file");return SYNO.SDS.Drive.Mail.Template.get(_S("user"),n,e,SYNO.SDS.Drive.FileType.getBase64Img(s,o),o,i)}}),Ext.ns("SYNO.SDS.Drive.MailDialog.Utils"),Ext.apply(SYNO.SDS.Drive.MailDialog.Utils,{APIErrorGet:function(e){switch(e){case 116:return _JSLIBSTR("uicommon","error_demo");case 8001:case 8002:case 8003:case 8004:return _T("error","error_error_system");case 8005:return _T("error","error_privilege_not_enough");case 8006:case 8007:case 8008:case 8009:case 8010:case 8011:return _T("error","error_error_system");case 8012:return _T("mail","sync_expire");case 8013:default:return _T("error","error_error_system")}}}),Ext.define("SYNO.SDS.Drive.FancyPasswordField",{extend:"Ext.form.TriggerField",constructor:function(e){var t={cls:"syno-ux-textfield syno-d-fancy-password-field",inputType:"password",triggerClass:"syno-d-fancy-password-trigger syno-d-fancy-password-invalid",inputVisible:!1,msgTarget:"itip"};Ext.apply(t,e||{}),this.callParent([t])},onTriggerClick:function(e){this.inputVisible?(this.el.dom.setAttribute("type","password"),this.trigger.addClass("syno-d-fancy-password-invalid")):(this.el.dom.setAttribute("type","text"),this.trigger.removeClass("syno-d-fancy-password-invalid")),this.inputVisible=!this.inputVisible},markInvalid:function(e){this.trigger&&this.trigger.addClass("syno-ux-trigger-invalid"),this.callParent(arguments)},clearInvalid:function(){this.trigger&&this.trigger.removeClass("syno-ux-trigger-invalid"),this.callParent(arguments)}}),function(){var e=function(e){var t=this.activeTarget;if(t){if(this.rendered||(this.render(Ext.getBody()),this.activeTarget=t),t.width?(this.setWidth(t.width),this.measureWidth=!1):(this.setWidth("auto"),this.body.setWidth("auto")),this.setTitle(t.title||""),Ext.isString(t.tipContents))t.width&&this.body.setWidth(this.adjustBodyWidth(t.width)),this.body.setStyle("max-width",this.maxWidth+"px"),this.body.hasClass("text-only")||this.body.addClass("text-only"),this.body.update(t.tipContents),this.mon(this,"beforehide",this.removeStyle,this,{single:!0});else if(Ext.isArray(t.tipContents))this.body.update(""),Ext.each(t.tipContents,function(e){e.rendered?this.body.appendChild(e.el):e.render(this.body),e.show(),this.mon(this,"beforehide",this.moveItemToBody.bind(this,e),this,{single:!0})},this);else if(Ext.isObject(t.tipContents)){this.body.update("");var i=t.tipContents;i.rendered?this.body.appendChild(i.el):i.render(this.body),i.show(),this.mon(this,"beforehide",this.moveItemToBody.bind(this,i),this,{single:!0})}this.autoHide=t.autoHide,this.dismissDelay=t.dismissDelay||this.dismissDelay,this.lastCls&&(this.el.removeClass(this.lastCls),delete this.lastCls),t.cls&&(this.el.addClass(t.cls),this.lastCls=t.cls),this.anchor?this.constrainPosition=!1:t.align?(this.el.show(),e=this.el.getAlignToXY(t.el,t.align),this.constrainPosition=!1):this.constrainPosition=!0}Ext.QuickTip.superclass.showAt.call(this,e)};Ext.isDefined(SYNO.ux.WhiteQuickTip)?SYNO.ux.WhiteQuickTip.prototype.showAt=e:(Ext.define("SYNO.ux.WhiteQuickTip",{extend:"Ext.QuickTip",xtype:"syno_whitequicktip",floating:{shadow:!1,shim:!0,useDisplay:!0,constrain:!1},tagConfig:{namespace:"ext",attribute:"wtip",width:"wwidth",target:"target",title:"qtitle",hide:"hide",cls:"iclass",align:"qalign",anchor:"anchor"},dismissDelay:0,initComponent:function(){this.callParent(arguments),this.addEvents("click")},onRender:function(){this.callParent(arguments),this.mon(this.el,"mouseover",this.onSelfMouseOver,this),this.mon(this.el,"mouseout",this.onSelfMouseOut,this),this.mon(this.el,"mousemove",this.onSelfMouseMove,this),this.mon(this.el,"click",this.fireClickEvent,this);var e=this.field;e instanceof SYNO.ux.DisplayField&&e.initValue()},fireClickEvent:function(){this.fireEvent("click",[this].concat(arguments))},onSelfMouseOver:function(e){this.clearTimer("hide")},onSelfMouseOut:function(){this.clearTimer("show"),!1!==this.autoHide&&this.delayHide(1)},onSelfMouseMove:function(){this.clearTimer("hide")},delayHide:function(e){this.hidden||this.hideTimer||(this.hideTimer=this.hide.defer(e||this.hideDelay,this))},getTipCfg:function(e){var t,i,n=e.getTarget();if(this.interceptTitles&&n.title&&Ext.isString(n.title))t=n.title,n.wtip=t,n.removeAttribute("title"),e.preventDefault();else if(i=this.tagConfig,t=n.wtip||Ext.fly(n).getAttribute(i.attribute,i.namespace),Ext.isEmpty(t)&&n.wtip_items||Ext.fly(n).getAttribute("wtip_items",i.namespace)){var o=n.id,s=Ext.getCmp(o);t=s?s.tipItems:void 0}return t},doAutoWidth:Ext.emptyFn,onTargetOver:function(e){if(!this.disabled){this.targetXY=e.getXY();var t=e.getTarget();if(t&&1===t.nodeType&&t!=document&&t!=document.body){if(this.activeTarget&&(t==this.activeTarget.el||Ext.fly(this.activeTarget.el).contains(t)))return this.clearTimer("hide"),void this.show();if(t&&this.targets[t.id])return this.activeTarget=this.targets[t.id],this.activeTarget.el=t,this.anchor=this.activeTarget.anchor,this.anchor&&(this.anchorTarget=t),void this.delayShow();var i=this.getTipCfg(e),n=Ext.fly(t),o=this.tagConfig,s=o.namespace;if(i){var r=n.getAttribute(o.hide,s);this.activeTarget={el:t,tipContents:i,width:n.getAttribute(o.width,s),autoHide:"user"!=r&&"false"!==r,title:n.getAttribute(o.title,s),cls:n.getAttribute(o.cls,s),align:n.getAttribute(o.align,s)},this.anchor=n.getAttribute(o.anchor,s),this.anchor&&(this.anchorTarget=t),this.delayShow()}}}},showAt:e,removeStyle:function(){this.body.setStyle("max-width","none"),this.body.removeClass("text-only")},moveItemToBody:function(e){e.el.appendTo(Ext.getBody()),e.hide()}}),SYNO.ux.WhiteQuickTips=function(){var e,t=!1;return{init:function(i){if(!e){if(!Ext.isReady)return void Ext.onReady(function(){SYNO.ux.WhiteQuickTips.init(i)});e=new SYNO.ux.WhiteQuickTip({baseCls:"x-tip-white",elements:"header,body",disabled:t}),!1!==i&&e.render(Ext.getBody())}},ddDisable:function(){e&&!t&&e.disable()},ddEnable:function(){e&&!t&&e.enable()},enable:function(){e&&e.enable(),t=!1},disable:function(){e&&e.disable(),t=!0},isEnabled:function(){return void 0!==e&&!e.disabled},getQuickTip:function(){return e},register:function(){e.register.apply(e,arguments)},unregister:function(){e.unregister.apply(e,arguments)},tips:function(){e.register.apply(e,arguments)}}}(),SYNO.ux.WhiteQuickTips.init(!0),Ext.define("SYNO.ux.WhiteTipIcon",{extend:"Ext.BoxComponent",constructor:function(e){var t,i;if(e=e||{},!(t=e.field))throw"need field as render target!";var n={renderTo:Ext.getBody()};this.callParent([Ext.apply(n,e)]),this.addClass("syno-ux-whitetip-icon"),this.relayEvents(this.getTip(),["click"]),i=t.rendered,i?this.renderToField():this.mon(t,"afterrender",this.renderToField,this)},renderToField:function(){var e=this.field,t=this.getRenderTargetByField(e);t.isInsertBefore?t.parent.insertBefore(this.el.dom,t.dom):t.parent.appendChild(this.el.dom)},lookupComponent:function(e){return Ext.isString(e)?Ext.ComponentMgr.get(e):e.events?e:this.createComponent(e)},createComponent:function(e,t){if(e.render)return e;var i=Ext.create(Ext.apply({ownerCt:this},e),t||this.defaultType);return delete i.initialConfig.ownerCt,delete i.ownerCt,i},getRenderTargetByField:function(e){var t={isInsertBefore:!1,dom:null,parent:null};return e instanceof SYNO.ux.DisplayField?t.parent=e.el:e instanceof SYNO.ux.Button&&Ext.getDom(e.el).nextSibling?(t.isInsertBefore=!0,t.parent=e.el.parent().dom,
t.dom=e.el.dom.nextSibling):e instanceof SYNO.ux.TextArea?t.parent=e.el.dom.parentNode.parentNode:t.parent=e.el.dom.parentNode,t},adjustStyleForButton:function(){var e=this.field,t=e.el.getStyle("margin-right");e.el.dom.nextSibling&&"0px"!==t&&(e.el.dom.style+=" margin-right: 0px !important;",this.el.dom.style+=" margin-right: 6px !important;")},addAriaAttr:function(){var e=this.field;e.el.set({"aria-describedby":e.el.dom.getAttribute("aria-describedby")+" "+this.id})},onRender:function(){this.callParent(arguments),this.el.set({"ext:wtip":this.message||"",draggable:!1,"ext:wwidth":this.tipWidth||""}),Ext.isEmpty(this.tipItems)||(Ext.isArray(this.tipItems)?this.tipItems=this.tipItems.map(function(e){return this.lookupComponent(e)}.bind(this)):this.tipItems=this.lookupComponent(this.tipItems),this.el.set({"ext:wtip_items":!0})),this.field instanceof SYNO.ux.Button&&this.adjustStyleForButton(),this.addAriaAttr()},getTip:function(){return SYNO.ux.WhiteQuickTips.getQuickTip()},beforeDestroy:function(){Ext.isArray(this.tipItems)?Ext.each(this.tipItems,function(e){e.destroy&&e.destroy()}):this.tipItems&&this.tipItems.destroy&&this.tipItems.destroy(),this.tipItems=null,this.field=null}}),SYNO.ux.AddWhiteTipWithMsg=function(e,t,i){return new SYNO.ux.WhiteTipIcon({field:e,message:t,tipWidth:i})},SYNO.ux.AddWhiteTipWithItem=function(e,t,i){return new SYNO.ux.WhiteTipIcon({field:e,tipItems:t,tipWidth:i})},SYNO.ux.AddTip=function(e,t,i){var n=Ext.getCmp(e.id);return SYNO.ux.AddWhiteTipWithMsg(n,t,i||480).el.dom})}(),Ext.define("SYNO.SDS.Drive.WhiteQuickTip",{extend:"Ext.BoxComponent",constructor:function(e){var t={cls:"syno-d-info-icon"+(e.lightIcon?" syno-d-info-icon-light":"")+(e.warningIcon?" syno-d-info-icon-warning":""),tipItems:e.tipItems,width:24};Ext.apply(t,e),this.callParent([t])},onRender:function(){this.callParent(arguments);var e={draggable:!1,"ext:wtip_items":!0};this.tipWidth&&(e["ext:wwidth"]=this.tipWidth),this.attrs&&Ext.apply(e,this.attrs),this.el.set(e)}}),Ext.define("SYNO.SDS.Drive.Share.AdvancedPanel",{extend:"SYNO.ux.FormPanel",constructor:function(e){SYNO.Assert(e.path,"need path"),this.path=e.path,this.name=e.name||"";var t={title:SYNO.SDS.Drive._T("share","protection_share_title"),cls:"syno-d-advance-share",items:[this.getAdvSharingCheckbox(),this.getPrivacySettingFieldSet(),this.getPasswordFieldSet(),this.getLinkExpireFieldSet(),this.getProtectLinkFieldSet()]};Ext.apply(t,e||{}),this.callParent([t]),this.mon(this,"afterlayout",this._onAfterLayout,this,{single:!0})},getAdvSharingCheckbox:function(){return this.advSharingCheckbox?this.advSharingCheckbox:(this.advSharingCheckbox=new SYNO.ux.Checkbox({name:"adv_sharing_checkbox",itemId:"adv_sharing_checkbox",boxLabel:SYNO.SDS.Drive._T("share","enable_protection_sharing"),checked:!1,listeners:{scope:this,check:this._onAdvSharingCheckboxClick}}),this.advSharingCheckbox)},getPrivacySettingFieldSet:function(){if(this.privacySettingFieldSet)return this.privacySettingFieldSet;var e="https://www.synology.com/knowledgebase/DSM/help/SynologyDrive/drive_file_management?version="+_S("majorversion"),t=SYNO.SDS.Drive._T;return this.privacySettingFieldSet=new SYNO.ux.FieldSet({title:SYNO.SDS.Drive._T("share","privacy_setting"),name:"privacy_setting",itemId:"privacy_setting",collapsible:!1,items:[{xtype:"syno_compositefield",hideLabel:!0,items:[this.getLinkRoleBtn(),new SYNO.SDS.Drive.WhiteQuickTip({style:{marginTop:"3px",marginLeft:"-1px"},tipWidth:320,tipItems:new Ext.BoxComponent({html:String.format("<p>{0}<br /> {2}{1}{3}.</p>",t("info_tip","adv_sharing_content"),t("info_tip","adv_sharing_learn_more"),'<a target="_blank" rel="noreferrer" href="'+e+'">',"</a>")})})]},this._getPreviewCheckbox()]}),this.privacySettingFieldSet},getPasswordFieldSet:function(){return this.passwordFieldSet?this.passwordFieldSet:(this.passwordFieldSet=new SYNO.ux.FieldSet({title:SYNO.SDS.Drive._T("share","password_field_title"),name:"passwd_fieldset",itemId:"passwd_fieldset",items:[this.getPasswordComposite()]}),this.passwordFieldSet)},getLinkExpireFieldSet:function(){return this.expireFieldSet?this.expireFieldSet:(this.expireFieldSet=new SYNO.ux.FieldSet({title:SYNO.SDS.Drive._T("share","expire_field_title"),name:"expiration_fieldset",itemId:"expiration_fieldset",items:[this.getExpirationComposite()]}),this.expireFieldSet)},getProtectLinkFieldSet:function(){return this.protectLinkFieldSet?this.protectLinkFieldSet:(this.protectLinkFieldSet=new SYNO.ux.FieldSet({name:"link_fieldset",itemId:"link_fieldset",cls:"syno-d-no-bottom-margin",collapsible:!1,title:SYNO.SDS.Drive._T("share","protect_link_title"),margins:{top:0,bottom:8,left:0,right:0},items:[this.getShareLinkComposite(),this.getShareMailBox()]}),this.protectLinkFieldSet)},getShareLinkComposite:function(){return this.shareLinkComposite?this.shareLinkComposite:(this.shareLinkComposite=new SYNO.SDS.Utils.ClipBoardComposite({itemId:"share_link_composite",disableWhenEmpty:!1,hideLabel:!0,textFieldCfg:{name:"url",itemId:"url",cls:"syno-d-share-link-text selectabletext allowDefCtxMenu",readOnly:!0,selectOnFocus:!0,width:456},btnCfg:{tooltip:SYNO.SDS.Drive._T("info","copy_url"),width:40,cls:"syno-d-copy-btn",iconCls:"syno-d-copy-btn-icon",btnStyle:"grey"},listeners:{clipsucceed:function(e){this.findWindow().setStatusOK({text:SYNO.SDS.Drive._T("share","copy_url_done")})},clipfailed:function(e){this.findWindow().setStatusError({text:SYNO.SDS.Drive._T("error","copy_share_link")})},scope:this}}),this.shareLinkComposite)},getLinkRoleBtn:function(){if(this.linkRoleBtn)return this.linkRoleBtn;var e=this,t=SYNO.SDS.Drive._T,i=[{itemId:"viewer",text:t("perm","public_ro_desc")},{itemId:"commenter",text:t("perm","public_commenter_desc")},{itemId:"editor",text:t("perm","public_rw_desc")}];return this.linkRoleBtnId=Ext.id(),this.linkRoleBtn=new SYNO.ux.Button({id:this.linkRoleBtnId,htmlEncode:!1,height:30,width:472,hideLabel:!0,btnStyle:"grey",cls:"syno-d-combo-btn",text:i[0].text,menu:this.getRoleMenu(i),setValue:function(t,i){this.menu.items.each(function(e){if(e.itemId===t)return this.value=t,this.setText(e.text),!1},this),i&&(this.ori_value=t,e.getLinkField().focus(!1,2)),-1!==["viewer","commenter"].indexOf(t)?e._getPreviewCheckbox().show():(e._getPreviewCheckbox().setValue(!0),e._getPreviewCheckbox().hide())},getOriValue:function(){return this.ori_value},getValue:function(){return this.value||"viewer"},isDirty:function(){return this.value!==this.ori_value}})},getRoleMenu:function(e){return this.roleMenu?this.roleMenu:(this.roleMenu=new SYNO.ux.Menu({minWidth:504,defaults:{htmlEncode:!1,checked:!1},items:e,listeners:{scope:this,itemclick:function(e){var t=e.itemId,i=this.getLinkRoleBtn();i.getValue()!==t&&i.setValue(t)},beforeshow:function(e){var t=this.getLinkRoleBtn().getValue(),i=e.items;i.each(function(e){e.setChecked&&e.setChecked(e.itemId===t)}),SYNO.SDS.Drive.Utils.isOfficeFile(this.name)||i.get("commenter").hide()},show:function(e){var t=e.layout.container,i=t.getEl();t.getLayoutTarget().getWidth()+i.getFrameWidth("lr")<e.minWidth&&t.setWidth(e.minWidth)}}}),this.roleMenu)},getLinkField:function(){return this.getShareLinkComposite().textField},getShareMailBox:function(){return this.shareMailBox?this.shareMailBox:(this.shareMailBox=new SYNO.ux.DisplayField({itemId:"share_mailbox",htmlEncode:!1,hideLabel:!0,value:'<span class="syno-d-text-btn syno-d-share-email-text">'+SYNO.SDS.Drive._T("share","mail_protection_link")+"</span>",scope:this,cls:"syno-d-share-email",listeners:{scope:this,single:!0,render:function(e){var t=e.getEl();this.mon(t,"click",function(e){if(!t.hasClass("x-item-disabled")&&e.within(t.dom.firstChild)){var i=new SYNO.SDS.Drive.MailDialog({owner:this.findWindow()});i.onSetData(this,this.getLinkField().getValue()),i.show()}},this)}}}),this.shareMailBox)},getPasswordComposite:function(){return this.passwordComposite?this.passwordComposite:(this.passwordCheckbox=new SYNO.SDS.Drive.Share.CustomizedCheckBox({name:"enable_passwd_checkbox",itemId:"enable_passwd_checkbox",width:230,boxLabel:SYNO.SDS.Drive._T("share","enable_password"),checked:!1}),this.passwordTextField=new SYNO.SDS.Drive.FancyPasswordField({name:"passwd_text_field",itemId:"passwd_text_field",width:180,allowBlank:!1,maxLength:32,selectWhenFocus:!1,listeners:{focus:function(){!0===this.selectWhenFocus&&this.el.dom.select(),this.selectWhenFocus=!1}}}),this.passwordComposite=new SYNO.ux.CompositeField({itemId:"passwd_composite_field",hideLabel:!0,items:[this.passwordCheckbox,this.passwordTextField]}),this.passwordComposite)},getExpirationComposite:function(){if(this.expirationComposite)return this.expirationComposite;var e=SYNO.SDS.Drive._T,t=new Date((new Date).getTime()+864e5);this.expirationCheckbox=new SYNO.SDS.Drive.Share.CustomizedCheckBox({name:"enable_expiration_checkbox",itemId:"enable_expiration_checkbox",width:230,boxLabel:e("share","enable_expiration"),checked:!1,handler:function(e,i){!0===i&&this.expirationDateField.setValue(t)}.bind(this)});var i=SYNO.SDS.Drive.Define.Info.sharing_permission.public_force_expiration_days,n=null;return i>0&&(n=new Date((new Date).getTime()+864e5*i)),this.expirationDateField=new SYNO.SDS.Drive.DateTimeField({name:"expiration_datefield",itemId:"expiration_datefield",width:180,editable:!0,showToday:!1,format:SYNO.SDS.Drive.Utils.getDateFormat(),minValue:t,maxValue:n,invalidText:e("share","invalid_time"),validator:function(i){if(this.disabled)return!0;var n=this.parseDate(i);if(!this.formatDate(n))return this.invalidText;var o=new Date,s=new Date(n);return!(s.getYear()<o.getYear()||o.getYear()===s.getYear()&&s.getDayOfYear()-o.getDayOfYear()<1)||String.format(e("share","date_period_error"),SYNO.SDS.Drive.Utils.getFormatDate(t))}}),this.expirationComposite=new SYNO.ux.CompositeField({name:"expiration_composite_field",itemId:"expiration_composite_field",hideLabel:!0,items:[this.expirationCheckbox,this.expirationDateField]}),this.expirationComposite},isDirty:function(){return this.form.isDirty()||this.getLinkRoleBtn().isDirty()||this._getPreviewCheckbox().isDirty()},isValid:function(){return!this.rendered||!this.isDirty()||this.form.isValid()},onBeforeApply:function(){return Promise.resolve()},onApply:function(){return this.isDirty()?this._onSaveLink():Promise.resolve()},_onClearDirty:function(){this.form.trackResetOnLoad=!0,this.form.setValues(this.form.getValues()),this.form.trackResetOnLoad=!1},_onAfterLayout:function(){new SYNO.ux.Utils.EnableCheckGroup(this.getForm(),"enable_passwd_checkbox",["passwd_text_field"]),new SYNO.ux.Utils.EnableCheckGroup(this.getForm(),"enable_expiration_checkbox",["expiration_datefield"]),new SYNO.ux.Utils.EnableCheckGroup(this.getForm(),"adv_sharing_checkbox",["share_link_composite",this.linkRoleBtnId,"share_mailbox","enable_passwd_checkbox","passwd_composite_field","enable_expiration_checkbox","expiration_composite_field"]),this._onInit()},_onInit:function(){this._doAction(this._onGetLink())},_doAction:function(e){return Promise.resolve().then(function(){this.findWindow().setStatusBusy()}.bind(this)).then(function(){return e.promise}).then(function(){this._onClearDirty(),this.findWindow().clearStatusBusy(),e.statusAction&&e.statusAction(this.findWindow())}.bind(this)).catch(function(e){SYNO.Debug.error(e),this.findWindow().setStatusError(SYNO.SDS.Drive.Utils.getErrorStr(e))}.bind(this))},_showRemoveMsgBox:function(){var e=SYNO.SDS.Drive._T,t=['<div class="syno-d-advance-share-remove-title"> {0} </div>',"<div> {1} </div>"].join(""),i="";i=SYNO.SDS.Drive.Define.Info.sharing_permission.public_sharing?String.format(t,e("share","remove_link_title"),e("share","remove_link_desc")):String.format(t,e("share","remove_link_title"),e("share","remove_link_warn_desc"));var n={title:"",msg:i,width:340,closable:!1,buttons:{ok:_T("common","remove"),cancel:_T("common","cancel")},fn:function(e){switch(e){case"ok":this._doAction(this._onRemoveLink()),SYNO.SDS.Drive.Define.Info.sharing_permission.public_sharing||this.setDisabled(!0);break;case"cancel":this._onAdvSharingCheckboxSetValue(!0)}},scope:this};this.findWindow().getMsgBox().show(n)},_onAdvSharingCheckboxClick:function(e,t){this.skipAdvSharingCheck||(t?this._doAction(this._onCreateLink()):this._showRemoveMsgBox())},_onAdvSharingCheckboxSetValue:function(e){this.skipAdvSharingCheck=!0,this.advSharingCheckbox.setValue(e),this.skipAdvSharingCheck=!1},_onSetDisabledEdit:function(e){this._onAdvSharingCheckboxSetValue(!e),this.privacySettingFieldSet.setDisabled(e),this.passwordFieldSet.setDisabled(e),this.expireFieldSet.setDisabled(e),this.protectLinkFieldSet.setDisabled(e),this.previewCheckbox.setDisabled(e),e&&(this.passwordCheckbox.setValue(!1),this.expirationCheckbox.setValue(!1),this.form.findField("url").setValue(""),this.previewCheckbox.setValue(!1))},_getPreviewCheckbox:function(){return this.previewCheckbox||(this.previewCheckbox=new SYNO.ux.Checkbox({name:"preview_checkbox",itemId:"preview_checkbox",boxLabel:SYNO.SDS.Drive._T("share","allow_download"),checked:!1,hidden:!0})),this.previewCheckbox},_onSetLinkInfo:function(e){this.sharingLinkInfo=e;var t=!1,i=e.role;i.match(/preview/)&&(i={previewer:"viewer",preview_commenter:"commenter"}[i],t=!0),this.linkRoleBtn.setValue(i,!0),this._getPreviewCheckbox().setValue(!t),this._getPreviewCheckbox().originalValue=!t,this.form.findField("url").setValue(e.url),this._isForcePassword()&&(this.passwordCheckbox.setValue(!0),this.passwordCheckbox.setReadOnly(!0)),this._isForceExpire()&&(this.expirationCheckbox.setValue(!0),this.expirationCheckbox.setReadOnly(!0),this.expirationDateField.setValue(null)),Ext.isEmpty(e.protect_password)||(this.passwordCheckbox.setValue(!0),this.passwordTextField.setValue(e.protect_password)),e.due_date>0&&(this.expirationCheckbox.setValue(!0),this.expirationDateField.setValue(new Date(1e3*e.due_date)))},_onGetLink:function(){var e=this.findAppWindow(),t={path:this.path};return{promise:e.getWebAPI().getAdvSharingLinkPromise(t).then(function(e){this._onSetDisabledEdit(!1),this._onSetLinkInfo(e)}.bind(this)).catch(function(e){if(this._onSetDisabledEdit(!0),!e.code||1036!==e.code)return SYNO.Debug.error(e),Promise.reject(e)}.bind(this))}},_onCreateLink:function(){var e=this.findAppWindow(),t={path:this.path},i={promise:e.getWebAPI().createAdvSharingLinkPromise(t).then(function(e){var t=SYNO.SDS.Drive.Utils.getFileIdFromPathId(this.path);this.findAppWindow().getEventMgr().fireEvent("setnodepermdone",!0,void 0,{file_id:t}),this._onSetDisabledEdit(!1),this._onSetLinkInfo(e),this.passwordTextField.inputVisible||this.passwordTextField.onTriggerClick(),this.passwordTextField.selectWhenFocus=!0,i.statusAction=function(e){e.setStatusOK({text:SYNO.SDS.Drive._T("share","protection_sharing_activated")})}}.bind(this)).catch(function(e){SYNO.Debug.error(e),this._onSetDisabledEdit(!0)}.bind(this))};return i},_onRemoveLink:function(){var e=this.findAppWindow(),t={path:this.path,sharing_link:this.sharingLinkInfo.sharing_link},i={promise:e.getWebAPI().removeAdvSharingLinkPromise(t).then(function(e){var t=SYNO.SDS.Drive.Utils.getFileIdFromPathId(this.path);this.findAppWindow().getEventMgr().fireEvent("setnodepermdone",!0,void 0,{file_id:t}),this._onSetDisabledEdit(!0),i.statusAction=function(e){e.setStatusOK({text:SYNO.SDS.Drive._T("share","protection_sharing_deactivated")})}}.bind(this)).catch(function(e){SYNO.Debug.error(e),this._onAdvSharingCheckboxSetValue(!0)}.bind(this))};return i},_onSaveLink:function(){var e=this.findAppWindow(),t={path:this.path,sharing_link:this.sharingLinkInfo.sharing_link,role:this._getRole()};return this.passwordCheckbox.getValue()?t.protect_password=this.passwordTextField.getValue():t.protect_password="",this.expirationCheckbox.getValue()?t.due_date=this.expirationDateField.getValue().getTime()/1e3:t.due_date=0,e.getWebAPI().updateAdvSharingLinkPromise(t)},_getRole:function(){var e=this.linkRoleBtn.getValue();return this._getPreviewCheckbox().getValue()?e:{viewer:"previewer",commenter:"preview_commenter"}[e]},_isForceExpire:function(){return SYNO.SDS.Drive.Define.Info.sharing_permission.public_force_expiration_days>0},_isForcePassword:function(){return!0===SYNO.SDS.Drive.Define.Info.sharing_permission.public_force_password}}),Ext.define("SYNO.SDS.Drive.Share.CustomizedCheckBox",{extend:"SYNO.ux.Checkbox",constructor:function(e){this.callParent([e])},setCheckedDisabledClass:function(){this.checkIcon&&(this.checked?this.checkIcon.addClass("syno-ux-cb-checked"):this.checkIcon.removeClass("syno-ux-cb-checked")),this.disabled?(this.checkIcon&&this.checkIcon.addClass("syno-ux-cb-disabled"),this.boxlabelEl&&this.boxlabelEl.addClass("syno-ux-cb-disabled")):this.readOnly?(this.checkIcon&&this.checkIcon.addClass("syno-ux-cb-disabled"),this.boxlabelEl&&this.boxlabelEl.removeClass("syno-ux-cb-disabled")):(this.checkIcon&&this.checkIcon.removeClass("syno-ux-cb-disabled"),this.boxlabelEl&&this.boxlabelEl.removeClass("syno-ux-cb-disabled"))}}),Ext.define("SYNO.SDS.Drive.Share.SharingInfo",{extend:"SYNO.ux.Panel",constructor:function(e){e=e||{};var t={cls:"syno-d-share-sharing-info",items:[{xtype:"box",html:String.format("<h2>{0}</h2>",SYNO.SDS.Drive._T("share","role_permission_title"))},new SYNO.SDS.Drive.Share.SharingInfoGrid]};Ext.apply(t,e),this.callParent([t])}}),Ext.define("SYNO.SDS.Drive.Share.SharingInfoGrid",{extend:"SYNO.ux.GridPanel",constructor:function(e){var t=this,i="preview,comment,download,upload,edit,delete,share".split(","),n={autoHeight:!0,cls:"syno-d-share-sharing-info-grid",enableHdMenu:!1,store:new Ext.data.ArrayStore({autoDestroy:!0,fields:["role"].concat(i),data:[["previewer",!0],["preview_commenter",!0,!0],["viewer",!0,!1,!0],["commenter"].concat(new Array(3).fill(!0)),["editor"].concat(new Array(5).fill(!0)),["manager"].concat(new Array(7).fill(!0))]}),view:new Ext.grid.GridView({autoFill:!0,disableTextSelect:!0}),cm:new Ext.grid.ColumnModel({defaults:{align:"center",width:85,menuDisabled:!0,sortable:!1,resizable:!1},columns:[{align:"left",width:180,dataIndex:"role",header:SYNO.SDS.Drive._T("share","role"),renderer:t._roleRenderer}].concat(i.map(function(e){return{dataIndex:e,header:SYNO.SDS.Drive._T("perm",e),tooltip:SYNO.SDS.Drive._T("perm",e),renderer:t._checkRenderer}}))})};Ext.apply(n,e),this.callParent([n])},_roleRenderer:function(e,t,i,n,o,s){var r=SYNO.SDS.Drive._T("perm",e);return t.attr='ext:qtip="'+r+'"',r},_checkRenderer:function(e,t,i,n,o,s){return e?'<div class="syno-d-icon-check"></div>':""}}),Ext.define("SYNO.SDS.Drive.Share.FormPanel",{extend:"SYNO.ux.FormPanel",constructor:function(e){this.path=e.path,this.share_user=e.share_user,this.capabilities=e.capabilities,this.name=e.name,this.type=e.type,this.callParent([this.fillConfig(e)]),this.mon(this,"afterlayout",this.onLoadData,this,{single:!0})},fillConfig:function(e){var t={title:SYNO.SDS.Drive._T("share","permission"),cls:"syno-d-share-formpanel",layout:"border",hideMode:"offsets",items:[this.getLinkFieldSet(),this.getShareToDsmUserCfg()],objectRole:{}};return Ext.apply(t,e)},getLinkRoleBtn:function(){if(this.linkRoleBtn)return this.linkRoleBtn;var e=this,t=SYNO.SDS.Drive._T,i=t("perm","limit_desc");SYNO.SDS.Drive.Define.Info.sharing_permission.invite_sharing||(i=t("perm","limit_you_desc"));var n=[{itemId:"na",text:"<b>"+t("perm","limit")+"</b> - "+i},"-",{itemId:"internal_viewer",text:"<b>"+t("perm","app")+"</b> - "+t("perm","app_ro_desc")},{itemId:"internal_commenter",text:"<b>"+t("perm","app")+"</b> - "+t("perm","app_commenter_desc")},{itemId:"internal_editor",text:"<b>"+t("perm","app")+"</b> - "+t("perm","app_rw_desc")}];return n.push({itemId:"public_viewer",text:"<b>"+t("perm","public")+"</b> - "+t("perm","public_ro_desc"),hidden:!0},{itemId:"public_commenter",text:"<b>"+t("perm","public")+"</b> - "+t("perm","public_commenter_desc"),hidden:!0},{itemId:"public_editor",text:"<b>"+t("perm","public")+"</b> - "+t("perm","public_rw_desc"),hidden:!0}),this.linkRoleBtn=new SYNO.ux.Button({ori_value:{type:null,role:null},displayRole:"na",htmlEncode:!1,height:30,width:504,hideLabel:!0,btnStyle:"grey",cls:"syno-d-combo-btn syno-d-link-role",text:n[0].text,menu:new SYNO.ux.Menu({minWidth:504,defaults:{htmlEncode:!1,checked:!1},items:n,listeners:{scope:this,itemclick:function(e){this.getLinkRoleBtn().setDisplayRole(e.itemId)},beforeshow:function(e){var t=this.getLinkRoleBtn().displayRole,i=e.items;i.each(function(e){e.setChecked&&e.setChecked(e.itemId===t)}),SYNO.SDS.Drive.Define.Info.sharing_permission.internal_link_sharing||(i.get("internal_editor").hide(),i.get("internal_viewer").hide(),i.get("internal_commenter").hide(),i.items[e.items.length-7].hide())},show:function(e){var t=e.layout.container,i=t.getEl();t.getLayoutTarget().getWidth()+i.getFrameWidth("lr")<e.minWidth&&t.setWidth(e.minWidth)}}}),initValue:function(t){var i=!1,n=t.role;t.role.match(/preview/)&&(i=!0,n={previewer:"viewer",preview_commenter:"commenter"}[t.role]),this.ori_value=t,e.getLinkField().focus(!1,2),this.setDisplayRole(("public"===t.type?"public_":"internal_")+n),e.getPreviewCheckbox().setValue(!i),e.getPreviewCheckbox().originalValue=!i},setDisplayRole:function(t){this.displayRole=t,this.menu.items.each(function(e){if(e.itemId===t)return this.setText(e.text),!1},this),e.doLayout(!1),t.match(/(viewer)|(commenter)/)?e.getPreviewCheckbox().show():(e.getPreviewCheckbox().setValue(!0),e.getPreviewCheckbox().hide()),e.doLayout(!1)},getOriValue:function(){return this.ori_value},getValue:function(){var t=this.displayRole;if("na"===t)return{type:null,role:null};var i=t.replace(/(public_)|(internal_)/,"");return e.getPreviewCheckbox().getValue()||("commenter"===i?i="preview_commenter":"viewer"===i&&(i="previewer")),{type:t.match(/public_/)?"public":"internal",role:i}},isDirty:function(){var e=this.getValue();return e.type!==this.ori_value.type||e.role!==this.ori_value.role},hideForOffice:function(){this.menu&&(this.menu.items.get("internal_commenter").hide(),this.menu.items.get("public_commenter").hide())}})},getShareLinkComposite:function(){return this.shareLinkComposite||(this.shareLinkComposite=new SYNO.SDS.Utils.ClipBoardComposite({cls:"syno-d-link-composite-field",disableWhenEmpty:!1,hideLabel:!0,textFieldCfg:{cls:"syno-d-share-link-text selectabletext allowDefCtxMenu",readOnly:!0,selectOnFocus:!0,width:456},btnCfg:{tooltip:SYNO.SDS.Drive._T("info","copy_url"),width:40,cls:"syno-d-copy-btn",iconCls:"syno-d-copy-btn-icon",btnStyle:"grey"},listeners:{clipsucceed:function(e){this.findWindow().setStatusOK({text:SYNO.SDS.Drive._T("share","copy_url_done")})},clipfailed:function(e){this.findWindow().setStatusError({text:SYNO.SDS.Drive._T("error","copy_share_link")})},scope:this}}))},getShareMailBox:function(){var e=SYNO.SDS.Drive._T,t="dir"===this.type?e("share","mail_directory_link"):e("share","mail_file_link");return this.shareMailBox||(this.shareMailBox=new SYNO.ux.DisplayField({htmlEncode:!1,hideLabel:!0,value:'<span class="syno-d-text-btn syno-d-share-email-text">'+t+"</span>",scope:this,cls:"syno-d-share-email",listeners:{scope:this,single:!0,render:function(e){var t=e.getEl();this.mon(t,"click",function(e){if(!t.hasClass("x-item-disabled")&&e.within(t.dom.firstChild)){var i=new SYNO.SDS.Drive.MailDialog({owner:this.findWindow()});i.onSetData(this.data,this.getLinkField().getValue()),i.show()}},this)}}}))},getUserGroupCombo:function(){if(this.share_name)return this.share_name;var e=new SYNO.SDS.Drive.Share.QueryStore({autoLoad:!1,listeners:{scope:this,load:function(){this.isDestroyed||this.fireEvent("sharestoreloaddone")}}});return this.share_name=new SYNO.ux.SuperBoxSelect({supportPlaceHolder:!1,itemMaxWidth:65,ctCls:"syno-d-share-user-group",labelAlign:"top",typeAhead:!1,addNewDataOnBlur:!0,allowAddNewData:!0,allowDeleteData:!0,allowQueryAll:!1,removeValuesFromStore:!0,lazyInit:!1,emptyText:SYNO.SDS.Drive._T("share","user_group"),listEmptyText:SYNO.SDS.Drive._T("common","no_data"),editable:!0,width:290,store:e,minChars:1,valueField:"id",displayField:"displayname",queryParam:"query",mode:"remote",enableKeyEvents:!0,tpl:new Ext.XTemplate('<tpl for=".">{[this.insertBefore(values, xindex, parent)]}<div class="x-combo-list-item {[values.cls || ""]}" role="option" aria-label="{[Ext.util.Format.htmlEncode(Ext.util.Format.stripTags(values.displayname))]}" id="{[Ext.id()]}" ext:qtip="{[Ext.util.Format.htmlEncode(Ext.util.Format.htmlEncode(values.displayname))]}">{[Ext.util.Format.htmlEncode(values.displayname)]}</div></tpl></tpl>',{insertBefore:function(e,t,i){return t>1&&i[t-2].type!==e.type?'<div class="syno-d-menu-sep">&nbsp;</div>':""}}),validator:function(e){var t=e.split("@");t.shift();var i=t.join("@");return Ext.isEmpty(i)||-1!==this.findIndexUserGroup(i)||this.share_name.hasValue(e)}.bind(this),initScrollbarEvent:Ext.emptyFn,onBlur:function(){this.onBlurCall=!0,this.beforeBlur(),this.outerWrapEl.removeClass(this.focusClass),this.autoSize(),this.clearCurrentFocus(),SYNO.ux.SuperBoxSelect.superclass.onBlur.call(this)},onStoreLoad:function(e,t,i){var n=0;Ext.each(t,function(e){var t=e.get(this.displayField),i=Ext.util.TextMetrics.measure(this.el,t);n=Math.max(n,i.width+100)}.bind(this));var o=n>this.width?n:this.width;o=o>456?456:o,this.doResize(o),SYNO.ux.SuperBoxSelect.prototype.onStoreLoad.bind(this)(e,t,i)},listeners:{scope:this,beforeselect:function(e,t){var i=t.data.name;e.hasValue(i)&&e.collapse()},beforeadditem:function(e,t,i){return!Ext.isEmpty(t)&&-1!==this.findIndexUserGroup(i.data.name)},additem:function(e){if(window.event){var t=new Ext.EventObjectImpl(window.event);e.itemDelimiterKey===t.getKey()&&(this.blViewAddUser=!0,function(){this.blViewAddUser=!1}.defer(80,this))}},newitem:function(e,t){var i=this.findUserGroup(t);if(i){e.getStore().clearFilter();var n=i.data;e.addItem(n)}},autosize:function(e,t){""===e.el.dom.value&&e.items.getCount()>0&&e.el.setWidth(5)},keydown:function(e,t,i){if(e.itemDelimiterKey===t.getKey()&&!this.blViewAddUser){""!==e.el.dom.value||e.isExpanded()||this.onAddSharePriv()}},beforequery:function(e){if(e&&this.getUserGroupCombo().isVisible()){var t=this.getUserGroupCombo().outerWrapEl.dom;t.scrollTop=t.scrollHeight}}}}),e.setCombo(this.share_name),this.share_name},getSharePrivCombo:function(){var e=[{role:"previewer",display:SYNO.SDS.Drive._T("perm","previewer"),tip:SYNO.SDS.Drive._T("perm","previewer_description")},{role:"preview_commenter",display:SYNO.SDS.Drive._T("perm","preview_commenter"),tip:SYNO.SDS.Drive._T("perm","preview_commenter_description")},{role:"viewer",display:SYNO.SDS.Drive._T("perm","viewer"),tip:SYNO.SDS.Drive._T("perm","viewer_description")},{role:"commenter",display:SYNO.SDS.Drive._T("perm","commenter"),tip:SYNO.SDS.Drive._T("perm","commenter_description")},{role:"editor",display:SYNO.SDS.Drive._T("perm","editor"),tip:SYNO.SDS.Drive._T("perm","editor_description")},{role:"organizer",display:SYNO.SDS.Drive._T("perm","manager"),tip:SYNO.SDS.Drive._T("perm","organizer_description")}];return new SYNO.ux.ComboBox({store:this.sharePrivComboStore=new Ext.data.JsonStore({idProperty:"role",autoDestroy:!0,fields:["role","display","tip"],data:e}),displayField:"display",valueField:"role",width:158,value:"viewer",cls:"syno-d-share-user-group-combobox",tpl:'<tpl for="."><div ext:qtip="{[Ext.util.Format.htmlEncode(SYNO.SDS.Drive.Utils.doubleHtmlEncode(values.tip))]}" class="x-combo-list-item" role="option" aria-label="{[Ext.util.Format.htmlEncode(values.display)]}">{[Ext.util.Format.htmlEncode(values.display)]}</div></tpl>',initList:function(){var e=0;this.getStore().each(function(t){var i=t.get(this.displayField),n=Ext.util.TextMetrics.measure(this.el,i);e=Math.max(e,n.width+60)}.bind(this)),this.listWidth=e>this.width?e:this.width,SYNO.ux.ComboBox.prototype.initList.bind(this)()},listeners:{afterrender:function(e){Ext.QuickTips.register({target:e.getEl(),text:e.rawValue})},select:function(e){Ext.QuickTips.register({target:e.getEl(),text:e.rawValue})}}})},getAddBtn:function(){return this.add_btn||(this.add_btn=new SYNO.ux.Button({btnStyle:"grey",cls:"syno-d-share-add",width:40,listeners:{click:function(){this.onAddSharePriv()},scope:this}}))},onAddSharePriv:function(){var e=this.getUserGroupUnAdded();if(e){var t=this.share_priv.getValue(),i=this.getShareStore(),n=0,o=null;Ext.each(e,function(e){if(e){var s=e.data.name,r=s.toLowerCase(),a=e.data.type,l=e.data.nickname;n=i.findBy(function(e){return e.data.name.toLowerCase()===r&&e.data.type===a},this),-1===n?i.insert(0,new Ext.data.Record({name:s,type:a,role:t,nickname:l})):(o=i.getAt(n),t!==o.data.role&&(o.beginEdit(),o.set("name",s),o.set("type",a),o.set("role",t),o.set("nickname",l),o.endEdit()))}},this),this.share_name.clearValue()}},findIndexUserGroup:function(e){var t=this.share_name.getStore(),i=t.createFilterFn("name",e,!1,!1,!0);return(t.snapshot||t.data).findIndexBy(i)},findUserGroup:function(e){var t=this.share_name.getStore(),i=t.createFilterFn("name",e,!1,!1,!0);return(t.snapshot||t.data).find(i)},isUserGroupVaild:function(){return this.share_name.validate()},isUserGroupUnAdded:function(){var e=this.getUserGroupUnAdded();if(!e)return!1;var t,i=this.share_priv.getValue(),n=!1;return Ext.each(e,function(e){if(e)return-1===(t=this.getShareStore().findBy(function(t){var i=t.data.name.toLowerCase()===e.data.name.toLowerCase(),n=t.data.type===e.data.type;return i&&n},this))||i!==this.getShareStore().getAt(t).data.role?(n=!0,!1):void 0},this),n},getUserGroupUnAdded:function(){return this.share_name.getStore().clearFilter(),this.share_name.getSelectedRecords()},getLinkFieldSet:function(){var e=SYNO.SDS.Drive._T;return this.linkFieldset||(this.linkFieldset=new SYNO.ux.FieldSet({itemId:"link_fieldset",cls:"syno-d-no-bottom-margin",collapsible:!1,region:"north",title:"dir"===this.type?e("share","directory_link"):e("share","file_link"),items:[this.getShareLinkComposite(),this.getShareMailBox()]}))},getLinkField:function(){return this.getShareLinkComposite().textField},getShareToDsmUserCfg:function(){this.share_priv=this.getSharePrivCombo(),this.shareCompositeField=new SYNO.ux.CompositeField({xtype:"syno_compositefield",hideLabel:!0,region:"north",hidden:!SYNO.SDS.Drive.Define.Info.sharing_permission.invite_sharing,defaults:{margins:"0 8 0 0"},items:[this.getUserGroupCombo(),this.share_priv,this.getAddBtn()]}),this.shareEditorGrid=new SYNO.ux.EditorGridPanel({itemId:"sharegrid",cls:"syno-d-share-gridpanel",clicksToEdit:1,hideHeaders:!0,region:"center",margins:{top:8,bottom:8,left:0,right:9},viewConfig:{markDirty:!1,autoFill:!0,deferEmptyText:!1,emptyText:SYNO.SDS.Drive._T("empty","share"),scrollOffset:0},sm:new Ext.grid.RowSelectionModel({listeners:{beforerowselect:function(){return!1}}}),listeners:{viewready:function(e){e.getView().updateScroller()}},colModel:new Ext.grid.ColumnModel({defaults:{menuDisabled:!0,fixed:!0,align:"left"},columns:[{dataIndex:"name",width:293,renderer:this.displaynameRenderer.createDelegate(this)},{dataIndex:"role",width:159,renderer:this.roleRenderer.createDelegate(this)},{xtype:"actioncolumn",css:"syno-d-actioncolumn",width:50,items:[{iconCls:"syno-d-share-delete-icon",handler:function(e,t,i){e.getStore().removeAt(t)}}]}]}),store:this.getShareStore()});var e=String.format("<p>{0}</p>",SYNO.SDS.Drive._T("info_tip","public_sharing_warning_disabled_content"));if(SYNO.SDS.Drive.Define.Info.sharing_permission.public_sharing){var t="https://www.synology.com/knowledgebase/DSM/help/SynologyDrive/drive_file_management?version="+_S("majorversion");e=String.format("<p>{0}<br /> {2}{1}{3}.</p>",SYNO.SDS.Drive._T("info_tip","public_sharing_warning_content"),SYNO.SDS.Drive._T("info_tip","adv_sharing_learn_more"),'<a target="_blank" rel="noreferrer" href="'+t+'">',"</a>")}return this.publicDeprecatedWarning=new SYNO.SDS.Drive.WhiteQuickTip({style:{marginTop:"3px",marginLeft:"-1px"},tipWidth:320,tipItems:new Ext.BoxComponent({html:e}),warningIcon:!0,hidden:!0}),{xtype:"container",region:"center",layout:"border",cls:"syno-d-share-perm-fieldset syno-ux-fieldset",items:[{xtype:"syno_compositefield",region:"north",cls:"x-fieldset-header",height:30,items:[{xtype:"container",
html:SYNO.SDS.Drive._T("share","privacy_setting"),cls:"x-fieldset-header-text"},this.publicDeprecatedWarning]},{xtype:"syno_fieldset",collapsible:!1,itemId:"sharefieldset",cls:"syno-d-user-cfg-fieldset",region:"center",layout:"border",items:[{xtype:"container",region:"north",layout:"form",labelAlign:"top",defautls:{height:30},items:[this.getLinkRoleBtn(),this.getPreviewCheckbox(),{xtype:"syno_compositefield",items:[{xtype:"syno_displayfield",value:SYNO.SDS.Drive._T("share","invite")+":"},new SYNO.SDS.Drive.WhiteQuickTip({style:{marginTop:"3px",marginLeft:"-1px"},tipWidth:778,tipItems:new SYNO.SDS.Drive.Share.SharingInfo})]},this.shareCompositeField],doLayout:function(){this.setHeight(""),Ext.Container.prototype.doLayout.apply(this,arguments)}},this.shareEditorGrid]}]}},getPreviewCheckbox:function(){return this.previewCheckbox||(this.previewCheckbox=new SYNO.ux.Checkbox({name:"preview_checkbox",itemId:"preview_checkbox",boxLabel:SYNO.SDS.Drive._T("share","allow_download"),checked:!0,hidden:!0})),this.previewCheckbox},onLoadData:function(){if(this.findWindow().setStatusBusy(),this.findAppWindow().getWebAPI().getShardLinkAndInfo({params:{path:this.path},callback:this.onLoadDataDone,scope:this}),this.capabilities&&!this.capabilities.can_share){var e=[this.linkRoleBtn,this.share_name,this.share_priv,this.add_btn,this.shareEditorGrid,this.getPreviewCheckbox()];Ext.each(e,function(e){e.setDisabled(!0)})}this.share_user&&_S("user")!==this.share_user&&(this.findWindow().setStatusBusy(),this.share_name.addValue(this.share_user),this.mon(this,"sharestoreloaddone",function(){if(!this.isDestroyed&&(this.findWindow().clearStatusBusy(),!this.share_name.getRawValue())){var e=this.findUserGroup(this.share_user);e&&this.share_name.setValueEx(e.data),this.share_priv.collapse(),this.share_name.collapse(),this.share_name.getRawValue()?this.share_priv.focus():this.share_name.focus()}},this,{buffer:80,single:!0}))},onLoadDataDone:function(e,t,i,n){if(!this.isDestroyed){if(this.findWindow().clearStatusBusy(),!e||t.has_fail){var o=SYNO.API.Util.GetFirstError(t);return void this.findWindow().getMsgBox().alert("",SYNO.SDS.Drive.Utils.getErrorStr(o),function(){this.findWindow().close()},this)}var s=SYNO.SDS.Drive.WebAPIDesc.get_file_link,r=SYNO.API.Util.GetValByAPI(t,s.api,s.method,"url");this.getLinkField().setValue(r),s=SYNO.SDS.Drive.WebAPIDesc.get_file;var a=SYNO.API.Util.GetValByAPI(t,s.api,s.method);this.data=a;var l=[];if(this.objectRole={user:{},group:{}},!Ext.isEmpty(this.data)&&Ext.isArray(this.data.shared_with)){if(a.removed)return void this.findWindow().getMsgBox().alert("",SYNO.SDS.Drive._T("file","in_recycle"),function(){this.findWindow().close()},this);this.findWindow().fireEvent("load",a),Ext.each(this.data.shared_with,function(e){switch(e.type){case"public":this.getLinkRoleBtn().initValue(e),this.publicDeprecatedWarning.setVisible(!0),this.doLayout();break;case"internal":this.getLinkRoleBtn().initValue(e);break;case"user":this.objectRole.user[e.name]=e.role,l.push(e);break;case"group":this.objectRole.group[e.name]=e.role,l.push(e)}},this),Ext.isEmpty(l)||this.getShareStore().loadData(l),SYNO.SDS.Drive.Utils.isOfficeFile(this.data.name)||(this.sharePrivComboStore.remove(this.sharePrivComboStore.getById("commenter")),this.sharePrivComboStore.remove(this.sharePrivComboStore.getById("preview_commenter")),this.getLinkRoleBtn().hideForOffice());var d=SYNO.SDS.Drive.Define.Info.sharing_permission.invite_sharing;d!==this.shareCompositeField.isVisible()&&(this.shareCompositeField.ownerCt.setHeight("auto"),this.shareCompositeField.setVisible(d),this.doLayout())}}},getShareStore:function(){return this.shareStore?this.shareStore:(this.shareStore=new Ext.data.JsonStore({autoDestroy:!0,fields:[{name:"id"},{name:"name",sortType:function(e){return e?e.toLowerCase():""}},"role","type","nickname",{name:"order",convert:function(e,t){switch(t.type){case"user":return 1;case"group":return 2;default:return 100}}}],hasMultiSort:!0,multiSortInfo:{sorters:[{field:"order",direction:"asc"},{field:"type",direction:"asc"},{field:"name",direction:"asc"},{field:"nickname",direction:"asc"}],direction:"asc"}}),this.shareStore)},displaynameRenderer:function(e,t,i){var n,o=e;return n="group"===i.data.type?"syno-d-share-group":"syno-d-share-user",i.data.nickname&&(o+=" ("+i.data.nickname+")"),String.format('<div ext:qtip="{0}"><span class="{1}"></span>{2}</div>',Ext.util.Format.htmlEncode(Ext.util.Format.htmlEncode(o)),n,Ext.util.Format.htmlEncode(o))},roleRenderer:function(e,t,i){var n=Ext.id();return Ext.defer(this.createStatusButton,25,this,[e,n,i]),'<div id="'+n+'";</div>'},changeRoleStatus:function(e,t,i){e.setText(t.text),e.setTooltip(t.text),i.data.role=t.value},createStatusButton:function(e,t,i){if(!Ext.isEmpty(Ext.get(t))){var n=[{text:SYNO.SDS.Drive._T("perm","previewer"),value:"previewer",tip:SYNO.SDS.Drive._T("perm","previewer_description")},{itemId:"preview_commenter",text:SYNO.SDS.Drive._T("perm","preview_commenter"),value:"preview_commenter",tip:SYNO.SDS.Drive._T("perm","preview_commenter_description")},{text:SYNO.SDS.Drive._T("perm","viewer"),value:"viewer",tip:SYNO.SDS.Drive._T("perm","viewer_description")},{itemId:"commenter",text:SYNO.SDS.Drive._T("perm","commenter"),value:"commenter",tip:SYNO.SDS.Drive._T("perm","commenter_description")},{text:SYNO.SDS.Drive._T("perm","editor"),value:"editor",tip:SYNO.SDS.Drive._T("perm","editor_description")},{text:SYNO.SDS.Drive._T("perm","manager"),value:"organizer",tip:SYNO.SDS.Drive._T("perm","organizer_description")}],o=SYNO.SDS.Drive._T("perm","organizer"===e?"manager":e),s=new SYNO.ux.Button({disabled:!SYNO.SDS.Drive.Define.Info.sharing_permission.invite_sharing,btnStyle:"default",text:o,tooltip:o,renderTo:t,cls:"syno-d-share-status-btn",menu:new SYNO.ux.Menu({items:n,listeners:{scope:this,beforeshow:function(e){e.items.items.forEach(function(e){e.tip&&(new Ext.ToolTip({target:e.getEl(),html:Ext.util.Format.htmlEncode(e.tip)}),e.tip=void 0)}),SYNO.SDS.Drive.Utils.isOfficeFile(this.data.name)||(e.items.get("preview_commenter").hide(),e.items.get("commenter").hide())}}})});s.menu.items.each(function(e,t,n){e.setHandler(this.changeRoleStatus.createDelegate(this,[s,e,i]))},this),this.addManagedComponent(s),this.statusBtn=s}},isShareLinkRoleDirty:function(){return this.getLinkRoleBtn().isDirty()||this.getPreviewCheckbox().isDirty()},calculateRole:function(e,t,i,n){var o={},s=!1,r=Ext.apply({},t);return Ext.iterate(e,function(e,t){if(r.hasOwnProperty(e)){if(r[e]===t)return void delete r[e];i.push({action:"update",member:{type:n?"group":"user",name:e},role:t}),delete r[e],s=!0}else i.push({action:"update",member:{type:n?"group":"user",name:e},role:t}),s=!0},this),Ext.iterate(r,function(e,t){i.push({action:"delete",member:{type:n?"group":"user",name:e}}),s=!0},this),!0===s&&o},hasModifiedRole:function(){if(this.isShareLinkRoleDirty())return!0;var e,t,i=function(e){for(var t in e)if(e.hasOwnProperty(t))return!1;return!0};return e=Ext.apply({},this.objectRole.user),t=Ext.apply({},this.objectRole.group),this.getShareStore().each(function(i,n,o){var s=i.data.role;"group"===i.data.type?t[i.data.name]===s?delete t[i.data.name]:t[i.data.name]=s:"user"===i.data.type&&(e[i.data.name]===s?delete e[i.data.name]:e[i.data.name]=s)},this),!i(e)||!i(t)},onBeforeApply:function(){return this.isDirty()&&this.isUserGroupUnAdded()?new Promise(function(e,t){var i,n=this.getUserGroupUnAdded(),o=!0,s=[];Ext.each(n,function(e){e&&("group"!==e.data.type&&(o=!1),s.push(e.data.name))},this),i=s.join(", ");var r=SYNO.SDS.Drive._T,a=String.format(o?r("share","prompt_addedit_group"):r("share","prompt_addedit_user"),i);this.findWindow().getMsgBox().confirm("",a,function(i){"yes"===i?(this.onAddSharePriv(),e()):t()},this)}.bind(this)):Promise.resolve()},onApply:function(){return this.hasModifiedRole()?this.onSetRole(this.getParams()):Promise.resolve()},onSetRole:function(e){return new Promise(function(t,i){this.findAppWindow().getAction().setNodePerm(e,function(e,n){e?t(n):i(n)},this)}.bind(this))},isDirty:function(){return this.hasModifiedRole()||this.isUserGroupUnAdded()},isValid:function(){return this.form.isValid()},getParams:function(){var e,t={path:this.path};return e=this.getModifiedRole(),Ext.isObject(e)&&Ext.apply(t,e),t},getModifiedRole:function(){var e=[],t={},i={};if(this.isShareLinkRoleDirty()){var n=this.getLinkRoleBtn().getOriValue(),o=this.getLinkRoleBtn().getValue();n.type&&n.type!==o.type&&e.push({action:"delete",member:{type:n.type}}),o.role&&e.push({action:"update",member:{type:o.type},role:o.role})}return this.getShareStore().each(function(e,n,o){"group"===e.data.type?i[e.data.name]=e.data.role:"user"===e.data.type&&(t[e.data.name]=e.data.role)},this),this.calculateRole(t,this.objectRole.user,e,!1),this.calculateRole(i,this.objectRole.group,e,!0),!Ext.isEmpty(e)&&{path:this.path,permissions:e}}}),Ext.define("SYNO.SDS.Drive.Share.QueryStore",{extend:"SYNO.API.Store",constructor:function(e){this.callParent([this.fillConfig(e)])},setCombo:function(e){this.combo=e,this.combo.on("beforequery",this.onBeforeQuery,this)},fillConfig:function(e){var t={appWindow:this,autoDestroy:!0,pruneModifiedRecords:!0,baseParams:{query:"",limit:500,additional:["nickname"]},proxy:this.getProxy(),reader:this.getJsonReader()};return Ext.apply(t,e)},getProxy:function(){return new SYNO.API.Proxy(Ext.apply({listeners:{scope:this,beforeload:this.onProxyBeforeLoad}},SYNO.SDS.Drive.WebAPIDesc.list_app_priv))},onProxyBeforeLoad:function(e,t){var i=e.activeRequest.read;i&&Ext.Ajax.abort(i)},onBeforeQuery:function(e){if(this.isDestroyed)return!1;var t=e.query.toLowerCase();return this.query_str=t,""!==t&&void 0},add:function(e){this.suspendEvents(!1),SYNO.API.Store.prototype.add.call(this,e),this.resumeEvents()},doUpdate:function(e){this.suspendEvents(!1),SYNO.API.Store.prototype.doUpdate.call(this,e),this.resumeEvents()},load:function(e){SYNO.API.Store.prototype.load.call(this,Ext.apply(e||{},{add:!1,callback:function(e){this.isDestroyed||(this.sort([{field:"type",direction:"ASC"}]),this.filterStore(this.query_str))}}))},getJsonReader:function(){return new Ext.data.JsonReader({root:"list",idProperty:function(e){return e.type+"@"+e.name},fields:[{name:"id",convert:function(e,t){return t.type+"@"+t.name}},{name:"name",sortType:function(e){return e?e.toLowerCase():""}},{name:"nickname",sortType:function(e){return e?e.toLowerCase():""}},{name:"displayname",convert:function(e,t){return t.nickname?t.name+" ("+t.nickname+")":t.name}},{name:"type",sortType:function(e){return"user"===e?0:1}},"role",{name:"cls",convert:function(e,t){return"group"===t.type?"syno-d-combo-share-group":"syno-d-combo-share-user"}}]})},filterStore:function(e){if(this.combo){this.clearFilter();var t=this.combo,i=[];Ext.isEmpty(e)||i.push({fn:function(t){return this.createFilterFn("name",e,!0,!1,!1)(t)||this.createFilterFn("nickname",e,!0,!1,!1)(t)}.bind(this)}),i.push({fn:function(e){var i=!1;return Ext.each(t.getSelectedRecords(),function(t){if(t&&t.get("name").toLowerCase()===e.get("name").toLowerCase()&&t.get("type")===e.get("type"))return i=!0,!1}),!i}}),this.filter(i),t.selectedIndex=-1,t.onLoad()}}}),Ext.define("SYNO.SDS.Drive.Share.Window",{extend:"SYNO.SDS.Drive.AddEditWindow",constructor:function(e){var t=e.display_path||"",i=SYNO.SDS.Drive.Utils.isDisplayPathUnderMyDrive(t);this.enable_public_sharing=e.adv_shared&&i||SYNO.SDS.Drive.Define.Info.sharing_permission.public_sharing;var n=this.fillConfig(e);this.callParent([n]),this.mon(this,"beforeclose",this.onBeforeClose,this)},fillConfig:function(e){this.owner=e.owner,this.path=e.path,this.closeCheck=!0;var t={title:SYNO.SDS.Drive._T("common","share"),width:560,height:601,layout:"fit",resizeHandles:"n s",items:this.getTabPanel(e),buttons:[{itemId:"ok",text:SYNO.SDS.Drive._T("btn","save"),btnStyle:"default",scope:this,disabled:_S("demo_mode"),tooltip:_S("demo_mode")?_JSLIBSTR("uicommon","error_demo"):"",handler:this.onApply}]};return Ext.apply(t,e)},getTabPanel:function(e){if(this.tabPanel)return this.tabPanel;var t=[this.getFormPanel(e)];return this.enable_public_sharing&&t.push(this.getAdvancedPanel(e)),this.tabPanel=new SYNO.ux.TabPanel({activeTab:0,items:t}),this.tabPanel},getFormPanel:function(e){return this.shareFormPanel||(this.shareFormPanel=new SYNO.SDS.Drive.Share.FormPanel(e))},getAdvancedPanel:function(e){return this.shareAdvancedPanel||(this.shareAdvancedPanel=new SYNO.SDS.Drive.Share.AdvancedPanel(e))},isValid:function(){return this.shareFormPanel.isValid()&&(!this.shareAdvancedPanel||this.shareAdvancedPanel.isValid())},isDirty:function(){return this.shareFormPanel.isDirty()||this.shareAdvancedPanel&&this.shareAdvancedPanel.isDirty()},onBeforeApply:function(){var e=[this.shareFormPanel.onBeforeApply()];return this.enable_public_sharing&&e.push(this.shareAdvancedPanel.onBeforeApply()),Promise.all(e)},onApply:function(){return this.isDirty()?this.isValid()?void Promise.resolve().then(function(){return this.onBeforeApply()}.bind(this)).catch(function(){return Promise.reject()}).then(function(){this.setStatusBusy();var e=[this.shareFormPanel.onApply()];return this.enable_public_sharing&&e.push(this.shareAdvancedPanel.onApply()),Promise.all(e)}.bind(this)).then(function(){this._close()}.bind(this)).catch(function(e){Ext.isEmpty(e)||(SYNO.Debug.error(e),this.clearStatusBusy(),this.setStatusError({text:SYNO.SDS.Drive.Utils.getErrorStr(e)}))}.bind(this)):void this.setStatusError({text:_T("common","forminvalid"),duration:3e3}):void this._close()},onCancel:function(){if(!this.isDirty())return void this._close();var e=function(e){"yes"===e&&this._close()};this.getMsgBox().confirm(this.title,_T("common","confirm_lostchange"),e,this)},onBeforeClose:function(){if(this.closeCheck)return this.onCancel(),!1},_close:function(){this.closeCheck=!1,this.close()}}),Ext.define("SYNO.SDS.Drive.Client.Panel",{extend:"SYNO.ux.GridPanel",constructor:function(e){this.owner=e.owner||e.appWin,this.module=e.module||e.appWin;var t=this.fillConfig(e);this.callParent([t]),this.getSelectionModel().on("rowselect",function(e){0===e.getCount()||this._S("demo_mode")||this.getTopToolbar().getComponent("btnUnlink").enable()},this),this.getSelectionModel().on("rowdeselect",function(e){0===e.getCount()&&this.getTopToolbar().getComponent("btnUnlink").disable()},this),this.getStore().on("beforeload",function(){this.getTopToolbar().getComponent("btnUnlink").disable()},this)},fillConfig:function(e){var t;this.pageSize=50,t=!this._S("is_admin");var i=[{id:"client_id",header:SYNO.SDS.Drive._T("clientinfo","title_id"),tooltip:SYNO.SDS.Drive._T("clientinfo","title_id"),dataIndex:"client_id",align:"left",width:150,sortable:!0},{id:"client_name",header:SYNO.SDS.Drive._T("common","usrname"),tooltip:SYNO.SDS.Drive._T("common","usrname"),dataIndex:"client_name",align:"left",hidden:t,width:120,sortable:!0},{id:"client_type",header:SYNO.SDS.Drive._T("clientinfo","client_type"),tooltip:SYNO.SDS.Drive._T("clientinfo","client_type"),dataIndex:"client_type",align:"left",sortable:!0,width:130,renderer:function(e){return{drive:SYNO.SDS.Drive._T("clientinfo","client_drive"),drive_mobile:SYNO.SDS.Drive._T("clientinfo","client_drive_mobile"),drive_backup:SYNO.SDS.Drive._T("clientinfo","client_drive"),backup:SYNO.SDS.Drive._T("clientinfo","client_backup"),ds_cloud:SYNO.SDS.Drive._T("clientinfo","client_ds_cloud"),cloudstation:SYNO.SDS.Drive._T("clientinfo","client_cloudstation"),sharesync:SYNO.SDS.Drive._T("clientinfo","client_sharesync"),serversync:SYNO.SDS.Drive._T("clientinfo","client_serversync"),unknown:"--"}[e]}},{id:"client_version",header:SYNO.SDS.Drive._T("clientinfo","client_version"),tooltip:SYNO.SDS.Drive._T("clientinfo","client_version"),dataIndex:"client_version",align:"left",width:120,sortable:!0},{id:"last_auth_time",header:SYNO.SDS.Drive._T("clientinfo","title_lastconnectedtime"),tooltip:SYNO.SDS.Drive._T("clientinfo","title_lastconnectedtime"),dataIndex:"last_auth_time",align:"left",renderer:function(e,t,i){var n=i.get("client_status");return"off_line"===n||"incompatible"===n?0===e?"":SYNO.SDS.CSTN.RenderTime(e,t):SYNO.SDS.Drive._T("clientinfo","lastconnectedtime_online")},width:130,sortable:!0},{id:"client_status",header:SYNO.SDS.Drive._T("clientinfo","syncing_status"),tooltip:SYNO.SDS.Drive._T("clientinfo","syncing_status"),dataIndex:"client_status",align:"left",renderer:function(e){return{off_line:SYNO.SDS.Drive._T("clientinfo","disconnected"),on_line:'<span class="green-status">'+SYNO.SDS.Drive._T("clientinfo","connected")+"</span>",syncing:'<span class="blue-status">'+SYNO.SDS.Drive._T("clientinfo","syncing")+"</span>",wipe:'<span class="red-status">'+SYNO.SDS.Drive._T("clientinfo","wiped")+"</span>",incompatible:String.format('<span class="red-status" ext:qtip="{0}">{1}</span>',SYNO.SDS.Drive._T("clientinfo","incompatible_tip"),SYNO.SDS.Drive._T("clientinfo","incompatible"))}[e]},width:130,sortable:!0},{id:"client_ip",header:SYNO.SDS.Drive._T("clientinfo","last_ip"),tooltip:SYNO.SDS.Drive._T("clientinfo","last_ip"),align:"left",dataIndex:"client_ip",width:130,sortable:!0},{id:"client_location",header:SYNO.SDS.Drive._T("clientinfo","client_location"),tooltip:SYNO.SDS.Drive._T("clientinfo","client_location"),align:"left",dataIndex:"client_location",width:130,sortable:!0},{id:"client_session_id",dataIndex:"client_session_id",hidden:!0,sortable:!0},{id:"client_is_relay",dataIndex:"client_is_relay",hidden:!0,sortable:!0}],n=new Ext.grid.ColumnModel({columns:i}),o=this.createStore(),s=new Ext.Toolbar({defaults:{btnStyle:"grey"},items:[{xtype:"syno_button",disabled:this._S("demo_mode"),tooltip:this._S("demo_mode")?_JSLIBSTR("uicommon","error_demo"):"",itemId:"btnUnlink",text:SYNO.SDS.Drive._T("clientinfo","action_unlink"),handler:this.onDisconnect,scope:this},{xtype:"syno_button",disabled:this._S("demo_mode"),tooltip:this._S("demo_mode")?_JSLIBSTR("uicommon","error_demo"):"",itemId:"btnRefres",text:SYNO.SDS.Drive._T("btn","refresh"),handler:this.onRefresh,scope:this}]}),r=new SYNO.ux.PagingToolbar({store:o,pageSize:this.pageSize,displayInfo:!0,emptyMsg:"",owner:this}),a={itemId:"client",tbar:s,view:new SYNO.ux.FleXcroll.grid.GridView,stripeRows:!0,enableColLock:!1,enableHdMenu:!1,enableColumnMove:!1,colModel:n,ds:o,sm:new Ext.grid.RowSelectionModel({singleSelect:!1}),autoExpandColumn:"last_auth_time",loadMask:!0,bbar:r};return SYNO.LayoutConfig.fill(a),Ext.apply(a,e),a},createStore:function(){var e=["client_id","client_name","last_auth_time","client_status","client_session_id","client_ip","client_is_relay","client_type","client_version","client_can_wipe","client_location","device_uuid"],t=new SYNO.API.Store({pruneModifiedRecords:!0,autoDestroy:!0,autoLoad:!0,proxy:new SYNO.API.Proxy({api:SYNO.SDS.CSTN.WebAPI.Connection.api,version:1,method:"list",appWindow:this.owner}),reader:new Ext.data.JsonReader({root:"items",totalProperty:"total",idProperty:"id"},e),sortInfo:{field:"last_auth_time",direction:"DESC"},paramNames:{start:"offset",limit:"limit",sort:"sort_by",dir:"sort_direction"},baseParams:{offset:0,limit:this.pageSize,sort_by:"last_auth_time",sort_direction:"DESC",view_role:_S("user")},listeners:{scope:this,exception:function(e,t,i,n,o){o&&o.code&&this.owner.getMsgBox().alert(SYNO.SDS.Drive._T("app","app_name"),SYNO.SDS.CSTN.getErrorString(o))}},remoteSort:!0});return this.addManagedComponent(t),t},applyDisconnect:function(e){this.owner.setStatusBusy();var t=this.getSelectionModel().getSelections(),i=[];Ext.each(t,function(e){i.push(e.get("client_session_id"))}),SYNO.SDS.CSTN.WebAPI.Connection.delete.call(this.owner,i,e,this.ajaxCheckSrvStatusCB,this)},ajaxCheckSrvStatusCB:function(e,t,i,n){SYNO.SDS.CSTN.webapiHdl.call(this,e,t,i,n,{success:SYNO.SDS.CSTN.cbLoad,failure:SYNO.SDS.CSTN.webapiErrHdlMain})},checkSrvStatus:function(){this.owner.setStatusBusy(),SYNO.SDS.CSTN.WebAPI.checkUser.call(this.owner,this.ajaxCheckSrvStatusCB,this)},onPageActivate:function(){this.checkSrvStatus()},onActivate:function(){this.onPageActivate()},onDisconnect:function(){this.owner.getMsgBox().confirm(SYNO.SDS.Drive._T("app","app_name"),SYNO.SDS.Drive._T("warning","msg_confirmunlink"),function(e){"yes"===e&&this.applyDisconnect(!1)},this)},onRefresh:function(){this.checkSrvStatus()}}),Ext.define("SYNO.SDS.Drive.Client.Dialog",{extend:"SYNO.SDS.Drive.ModalWindow",constructor:function(e){var t=this.fillConfig(e);this.callParent([t])},fillConfig:function(e){var t={title:SYNO.SDS.Drive._T("func","mgr_clientinfo"),width:840,height:600,layout:"fit",items:this.getPanel(e),buttons:[{xtype:"syno_button",text:_T("common","close"),scope:this,handler:this.close}]};return Ext.apply(t,e)},getPanel:function(e){return this.panel||(this.panel=new SYNO.SDS.Drive.Client.Panel(e))}}),Ext.ns("SYNO.SDS.Drive.Setting"),Ext.define("SYNO.SDS.Drive.Setting.GeneralPanel",{extend:"SYNO.ux.FormPanel",constructor:function(e){this.owner=e.owner,this.module=e.module,this.callParent([this.fillConfig(e)])},createForm:function(){var e=Ext.applyIf({appWindow:this,listeners:{}},this.initialConfig);return new SYNO.API.Form.BasicForm(null,e)},fillConfig:function(e){var t;return this.appPortalDesc=new SYNO.ux.DisplayField({ctCls:"syno-d-setting-portal-desc",value:""}),this.appPortalLink=new SYNO.ux.DisplayField({htmlEncode:!1,hidden:!0}),this.appPortalBtn=new SYNO.ux.Button({btnStyle:"grey",text:SYNO.SDS.Drive._T("setting","launch_app_portal"),hidden:!0,handler:function(){var e=new SYNO.SDS.WindowLauncher(SYNO.SDS.WindowLauncher.Util.parseOptions("SYNO.SDS.AdminCenter.Application",Ext.apply({fn:"SYNO.SDS.AdminCenter.Login.Main"},this.findAppWindow().openConfig))),t=Ext.urlDecode(window.location.search.substr(1))||{};return e.url=Ext.urlAppend(window.location.protocol+"//"+window.location.host,Ext.urlEncode(Ext.apply(t,{launchApp:"SYNO.SDS.AdminCenter.Application"})),!0),e.openNewWindow(void 0,e.getLaunchURL())},scope:this}),t={cls:"syno-d-setting-general",trackResetOnLoad:!0,border:!1,frame:!1,autoScroll:!0,header:!1,useDefaultBtn:!1,title:SYNO.SDS.Drive._T("setting","general"),items:[{xtype:"syno_fieldset",title:SYNO.SDS.Drive._T("setting","notification"),items:[{xtype:"checkboxgroup",fieldLabel:SYNO.SDS.Drive._T("setting","notification_by"),columns:1,defaultType:"syno_checkbox",items:[{name:"enable_email_notification",boxLabel:_T("notification","notification_email")},{name:"enable_chat_notification",boxLabel:SYNO.SDS.Drive._T("notification","notification_chat"),hidden:!SYNO.SDS.StatusNotifier.isAppEnabled("SYNO.SDS.Chat.Application")}]}]},{xtype:"syno_fieldset",title:SYNO.SDS.Drive._T("setting","login_portal"),items:[this.appPortalDesc,this.appPortalLink,this.appPortalBtn]},{xtype:"syno_fieldset",title:SYNO.SDS.Drive._T("setting","lang_codepage"),items:[this.getCodepageTitle(),this.getCodepageCombo()]}]},Ext.apply(t,e)},getCodepageTitle:function(){return this.codepageTitle?this.codepageTitle:(this.codepageTitle=new SYNO.ux.DisplayField({value:SYNO.SDS.Drive._T("setting","download_codepage_desc")}),this.codepageTitle)},getCodepageCombo:function(){return this.codepageCombo?this.codepageCombo:(this.codepageStore=new Ext.data.SimpleStore({fields:["value","display"],data:SYNO.SDS.Drive.Utils.getSupportedCodepage()}),this.codepageCombo=new SYNO.ux.ComboBox({name:"archive_codepage",fieldLabel:SYNO.SDS.Drive._T("setting","lang_codepage"),store:this.codepageStore,displayField:"display",valueField:"value",triggerAction:"all",editable:!1,value:"unicode",mode:"local"}),this.codepageCombo)},loadData:function(){return SYNO.SDS.Drive.WebAPICore.sendPromise(["get_user_setting","get_dsm_setting"]).then(function(e){this.handleSetting(e.result[0].success,e.result[0].data||e.result[0].error),this.handleAppPortal(e.result[1].success,e.result[1].data||e.result[1].error)}.bind(this))},handleSetting:function(e,t){if(this.rendered)this.getForm().setValues(t);else{var i=function(){this.getForm().setValues(t)}.bind(this);this.mun(this,"activate",i,this),this.mon(this,"activate",i,this,{single:!0})}},handleAppPortal:function(e,t){var i;return e?(t&&(i=this.makeAppPortalURL(t.app_portal)),i?(this.appPortalDesc.setValue(SYNO.SDS.Drive._T("setting","app_portal_link_desc")),this.appPortalLink.setValue(i),this.appPortalLink.show(),void this.appPortalLink.setHeight("auto")):void(this._S("is_admin")?this.showAppPortalBtn():this.hideAppPortalBtn())):(this.appPortalLink.hide(),void this.showAppPortalBtn())},showAppPortalBtn:function(){this.appPortalDesc.setValue(SYNO.SDS.Drive._T("setting","app_portal_enable_desc")),this.appPortalBtn.show(),this.appPortalBtn.setText(SYNO.SDS.Drive._T("setting","launch_login_portal"))},hideAppPortalBtn:function(){this.appPortalDesc.setValue(SYNO.SDS.Drive._T("setting","login_portal_admin_desc")),this.appPortalBtn.hide()},makeAppPortalURL:function(e){var t,i,n,o=[],s=!1,r='<a href="{0}" rel="noreferrer" target="_blank"> {0} </a>';return Ext.isObject(e)?e.fqdn&&window.location.hostname.toLowerCase()===e.fqdn.toLowerCase()?(t=Ext.form.VTypes.netbiosName(e.fqdn)?"http":"https",n=String.format("{0}://{1}",t,e.fqdn),String.format(r,n)):(t=window.location.protocol,i=this.getDsmHost()||window.location.hostname,this.getDsmHttpPort()||parseInt(window.location.port,10),[".quickconnect.to",".quickconnect.cn"].forEach(function(e){i.toLowerCase().substr(-1*e.length)===e&&(s=!0)}),"alias"in e&&(n=t+"//"+i+"/"+e.alias+"/",o.push(String.format(r,n))),s||("http_port"in e&&(n="http://"+i+":"+e.http_port,o.push(String.format(r,n))),"https_port"in e&&(n="https://"+i+":"+e.https_port,o.push(String.format(r,n)))),e.fqdn&&(t=Ext.form.VTypes.netbiosName(e.fqdn)?"http":"https",n=String.format("{0}://{1}",t,e.fqdn),o.push(String.format(r,n))),o.join("<br>")):""},applyForm:function(e,t){return this.getForm().isDirty()?(this.sendWebAPI({compound:{stopwhenerror:!1,params:[Ext.apply({params:this.getForm().getValues()},SYNO.SDS.Drive.WebAPIDesc.update_user_setting)]},callback:function(i,n){if(!i||n.has_fail)return void t(n);e()},scope:this}),!0):(e(),!1)}}),Ext.ns("SYNO.SDS.Drive.Setting"),Ext.define("SYNO.SDS.Drive.Setting.DateTimePanel",{extend:"SYNO.ux.FormPanel",constructor:function(e){this.owner=e.owner,this.module=e.module,this.callParent([this.fillConfig(e)])},createForm:function(){var e=Ext.applyIf({appWindow:this,listeners:{}},this.initialConfig);return new SYNO.API.Form.BasicForm(null,e)},fillConfig:function(e){var t;return t={trackResetOnLoad:!0,border:!1,frame:!1,autoScroll:!0,header:!1,useDefaultBtn:!1,title:SYNO.SDS.Drive._T("setting","display"),items:[{xtype:"syno_fieldset",title:SYNO.SDS.Drive._T("common","language"),items:[this.getLangTitle(),this.getLangCombo()]},{xtype:"syno_fieldset",title:SYNO.SDS.Drive._T("common","time"),items:[this.getTimeTitle(),this.getDateCombo(),this.getTimeCombo()]},{xtype:"syno_fieldset",title:SYNO.SDS.Drive._T("setting","displayname"),items:[this.getDisplayNameTitle(),this.getDisplayNameCombo()]}]},Ext.apply(t,e)},getLangTitle:function(){return this.langTitle?this.langTitle:(this.langTitle=new SYNO.ux.DisplayField({value:SYNO.SDS.Drive._T("setting","language_desc")}),this.langTitle)},getTimeTitle:function(){return this.timeTitle?this.timeTitle:(this.timeTitle=new SYNO.ux.DisplayField({value:SYNO.SDS.Drive._T("setting","time_desc")}),this.timeTitle)},getDisplayNameTitle:function(){return this.displayNameTitle?this.displayNameTitle:(this.displayNameTitle=new SYNO.ux.DisplayField({value:SYNO.SDS.Drive._T("setting","displayname_des")}),this.displayNameTitle)},getDisplayNameCombo:function(){if(this.displayNameCombo)return this.displayNameCombo;var e=SYNO.SDS.Drive._T("common","sys_default_setting")||SYNO.SDS.Drive._T("common","lang_dsm")||SYNO.SDS.Drive._STR("common","lang_dsm"),t=new Ext.data.JsonStore({fields:["display","value"],data:[{display:e,value:"default"},{display:SYNO.SDS.Drive._T("common","usrname"),value:"username"},{display:SYNO.SDS.Drive._T("common","nickname"),value:"nickname"}]});return this.displayNameCombo=new SYNO.ux.ComboBox({name:"displayname_setting",fieldLabel:SYNO.SDS.Drive._T("setting","displayname_field"),store:t,displayField:"display",valueField:"value",triggerAction:"all",editable:!1,mode:"local",value:"system"}),this.displayNameCombo},getLangCombo:function(){return this.langCombo?this.langCombo:(this.langStore=this.createLangStore(),this.langCombo=new SYNO.ux.ComboBox({name:"lang_combo",fieldLabel:SYNO.SDS.Drive._T("common","language"),store:this.langStore,displayField:"display",valueField:"value",triggerAction:"all",editable:!1,mode:"local"}),this.langCombo)},getDateCombo:function(){return this.dateCombo?this.dateCombo:(this.dateStore=this.createDateFormatStore(),this.dateCombo=new SYNO.ux.ComboBox({name:"date_combo",fieldLabel:_STR("personal_settings","date_format"),store:this.dateStore,displayField:"display",valueField:"value",triggerAction:"all",editable:!1,mode:"local"}),this.dateCombo)},getTimeCombo:function(){return this.timeCombo?this.timeCombo:(this.timeStore=this.createTimeFormatStore(),this.timeCombo=new SYNO.ux.ComboBox({name:"time_combo",fieldLabel:_STR("personal_settings","time_format"),store:this.timeStore,displayField:"display",valueField:"value",triggerAction:"all",editable:!1,mode:"local"}),this.timeCombo)},loadData:function(){if(this.langCombo.setValue(SYNO.SDS.UserSettings.getProperty("Personal","lang")||"def"),SYNO.SDS.DateTimeUtils.GetTimeFormat)this.timeCombo.setValue(SYNO.SDS.DateTimeUtils.GetTimeFormat()),this.dateCombo.setValue(SYNO.SDS.DateTimeUtils.GetDateFormat());else{var e=SYNO.SDS.UserSettings.getProperty("Personal","timeFormat");e&&e.length>0&&this.timeCombo.setValue(e);var t=SYNO.SDS.UserSettings.getProperty("Personal","dateFormat");t&&t.length>0&&this.dateCombo.setValue(t)}return SYNO.SDS.Drive.WebAPICore.sendPromise("get_user_setting").then(function(e){this.displayNameCombo.setValue(e.displayname_setting)}.bind(this))},applyForm:function(e,t){return this.getForm().isDirty()?(SYNO.SDS.UserSettings.setProperty("Personal","lang",this.langCombo.value),SYNO.SDS.DateTimeUtils.SetUserFormat?(SYNO.SDS.DateTimeUtils.SetUserFormat("date",this.dateCombo.value),SYNO.SDS.DateTimeUtils.SetUserFormat("time",this.timeCombo.value)):(this.timeCombo.value&&this.timeCombo.value.length>0&&SYNO.SDS.UserSettings.setProperty("Personal","timeFormat",this.timeCombo.value),this.dateCombo.value&&this.dateCombo.value.length>0&&SYNO.SDS.UserSettings.setProperty("Personal","dateFormat",this.dateCombo.value)),this.sendWebAPI({compound:{stopwhenerror:!1,params:[Ext.apply({params:this.getForm().getValues()},SYNO.SDS.Drive.WebAPIDesc.update_user_setting)]},callback:function(i,n){if(!i||n.has_fail)return void t(n);e()},scope:this}),!0):(e(),!1)},createLangStore:function(){var e=SYNO.SDS.Utils.getSupportedLanguage(),t=_T("common","sys_default_setting")||_T("common","lang_dsm")||_STR("common","lang_dsm");return e.unshift(["def",t]),new Ext.data.SimpleStore({fields:["value","display"],data:e})},createDateTimeStore:function(e){var t=e.map(function(e,t){return[e,(new Date).format(e)]});return new Ext.data.ArrayStore({fields:["value","display"],data:t})},createTimeFormatStore:function(){if(SYNO.SDS.DateTimeUtils.CreateTimeFormatStore)return SYNO.SDS.DateTimeUtils.CreateTimeFormatStore(!0);var e=SYNO.SDS.DateTimeUtils.SupportedTimeFormats;return this.createDateTimeStore(e)},createDateFormatStore:function(){if(SYNO.SDS.DateTimeUtils.CreateDateFormatStore)return SYNO.SDS.DateTimeUtils.CreateDateFormatStore(!0);var e=SYNO.SDS.DateTimeUtils.SupportedDateFormats;return this.createDateTimeStore(e)},onSave:function(){this.getForm().isDirty()&&(SYNO.SDS.UserSettings.save(),setTimeout(function(){SYNO.SDS.Drive.GetWindow().getMsgBox({preventDelay:!0}).confirm("",SYNO.SDS.Drive._T("personal_settings","refresh_confirm"),function(e){"yes"===e&&location.reload(!0)})},500))}}),Ext.ns("SYNO.SDS.Drive.Setting"),Ext.define("SYNO.SDS.Drive.Setting.Window",{extend:"SYNO.SDS.Drive.ModalWindow",constructor:function(e){this.owner=e.owner,this.module=e.module,this.drive_setting=e.drive_setting,
this.sharing_link_by_email=void 0!==this.drive_setting.sharing_link_by_email&&this.drive_setting.sharing_link_by_email,this.file_request_link_by_email=void 0!==this.drive_setting.file_request_link_by_email&&this.drive_setting.file_request_link_by_email,this.initial_active_tab=e.active_tab||"profile";var t=this.fillConfig(e);this.callParent([t]),this.onLoadData(),this.mon(this.settingPanel,"tabchange",this.onTabChange,this)},fillConfig:function(e){var t={title:SYNO.SDS.Drive._T("common","setting"),width:640,height:572,layout:"fit",cls:"syno-d-setting-win",items:this.getSettingPanel(),buttons:[{xtype:"syno_button",text:SYNO.SDS.Drive._T("common","cancel"),scope:this,handler:this.onClickCancel},{xtype:"syno_button",btnStyle:"default",text:SYNO.SDS.Drive._T("common","ok"),handler:this.onClickOk,scope:this}]};return Ext.apply(t,e)},getTabPanel:function(e){var t=null;switch(e){case"profile":t=this.profile_panel;break;case"general":t=this.general_panel;break;case"datetime":t=this.datatime_panel;break;case"office":t=this.office_panel;break;case"mail":t=this.mail_panel}return t||0},getGeneralSettingPanel:function(){return new SYNO.SDS.Drive.Setting.GeneralPanel({owner:this.owner,module:this})},getDateTimeSettingPanel:function(){return new SYNO.SDS.Drive.Setting.DateTimePanel({owner:this.owner,module:this})},getOfficeSettingPanel:function(){return new SYNO.SDS.Office.Setting.Panel({owner:this.owner,module:this})},getSettingPanel:function(){if(this.settingPanel)return this.settingPanel;var e=[];Ext.getClassByName("SYNO.SDS.Profile.Panel")&&(SYNO.SDS.Avatar.Dialog.prototype.EDITOR_WIDTH=420,SYNO.SDS.Avatar.Dialog.prototype.EDITOR_HEIGHT=420,SYNO.SDS.Avatar.Editor.prototype.blConstraintMask=!0,this.profile_panel=new SYNO.SDS.Profile.Panel({title:SYNO.SDS.Drive._T("common","title_profile"),useDefaultBtn:!1,avatarCtCfg:{width:200},profileCfg:{tzHidden:!0,padding:void 0,descHeight:50},avatarDlgCfg:{closable:!0,width:476,height:588,padding:"12px 27px 0 27px"},processProfileGetSuccess:function(e){this.onProfileGetSuccess.apply(this,arguments)}.bind(this),processProfileGetFailed:function(){this.onProfileGetFailed.apply(this,arguments)}.bind(this),listeners:{scope:this,applysucceed:function(e,t){this.module.updateAccountIcon(!0,t?SYNO.API.Util.GetValByAPI(t,"SYNO.Personal.Profile","set"):null),this.onProfileSetSuccess.apply(this,arguments)},applyfailed:function(){this.onProfileSetFailed.apply(this,arguments)},deletesucceed:function(){this.module.updateAccountIcon(!0)}}}),this.profile_panel.profileForm.getLangField().hide(),e.push(this.profile_panel)),this.general_panel=this.getGeneralSettingPanel(),e.push(this.general_panel),this.datatime_panel=this.getDateTimeSettingPanel(),e.push(this.datatime_panel);try{window.SYNO_WebManager_Strings.mail.mail_account=SYNO.SDS.Drive._T("mail","mail_account")}catch(e){}return(_S("is_admin")||this.sharing_link_by_email||this.file_request_link_by_email)&&Ext.getClassByName("SYNO.Personal.Mail.MailForm")&&(this.mail_panel=new SYNO.Personal.Mail.MailForm({module:this,dialogButtonCfg:{confirm:{btnStyle:"default"}}}),e.push(this.mail_panel)),SYNO.SDS.Drive.Utils.hasOffice()&&(this.office_panel=this.getOfficeSettingPanel(),e.push(this.office_panel)),this.settingPanel=new SYNO.ux.TabPanel({activeTab:this.getTabPanel(this.initial_active_tab),items:e}),this.settingPanel},onLoadData:function(){var e=[];this.profile_panel&&this.profile_panel.rendered&&e.push(new Promise(function(e,t){this.onProfileGetSuccess=e,this.onProfileGetFailed=t}.bind(this)).then(function(){this.profile_panel_loaded=!0}.bind(this))),e.push(this.general_panel.loadData()),this.datatime_panel.loadData(),this.office_panel&&e.push(new Promise(function(e,t){this.office_panel.onLoadData(e,t)}.bind(this))),this.setStatusBusy(),Promise.all(e).then(function(){this.clearStatusBusy()}.bind(this),function(e){this.clearStatusBusy();var t=function(){this.close()};SYNO.SDS.Drive.Utils.showErrorMsg(this,e,t,this)}.bind(this))},onClickCancel:function(){this.close()},onClickOk:function(){this.applySetting()},applySetting:function(){var e=[];if(this.profile_panel){if(!this.profile_panel.isValid())return this.settingPanel.setActiveTab(this.profile_panel),!1;e.push(new Promise(function(e,t){this.onProfileSetSuccess=e,this.onProfileSetFailed=t}.bind(this)))}e.push(new Promise(function(e,t){this.general_panel.applyForm(e,t)}.bind(this))),e.push(new Promise(function(e,t){this.datatime_panel.applyForm(e,t)}.bind(this))),this.office_panel&&e.push(new Promise(function(e,t){this.office_panel.applyForm(e,t)}.bind(this))),this.setStatusBusy(),Promise.all(e).then(function(){this.notClose||this.close()}.bind(this),function(){this.clearStatusBusy(),this.setStatusError({text:SYNO.SDS.Drive._T("error","save"),clear:!0})}.bind(this)),this.profile_panel&&this.profile_panel.onSave(),this.datatime_panel.onSave()},onTabChange:function(e,t){if(t===this.profile_panel&&!this.profile_panel_loaded){var i=new Promise(function(e,t){this.onProfileGetSuccess=e,this.onProfileGetFailed=t}.bind(this));this.setStatusBusy(),i.then(function(){this.profile_panel_loaded=!0}.bind(this)).finally(this.clearStatusBusy.bind(this))}}}),Ext.ns("SYNO.SDS.Drive"),Ext.define("SYNO.SDS.Drive.WebAPI",{constructor:function(e){this.appWindow=e.appWindow,this.callParent([e])},copyTo:function(e,t,i){return SYNO.SDS.Drive.Utils.copyTo(e,t,i)},initial:function(e){this.appWindow.sendWebAPI({compound:{stopwhenerror:!1,params:[SYNO.SDS.Drive.WebAPIDesc.info,SYNO.SDS.Drive.WebAPIDesc.get_setting,SYNO.SDS.Drive.WebAPIDesc.get_migrate_index_home_config,Ext.apply(SYNO.SDS.Drive.WebAPIDesc.check_delegated,{params:{user:_S("user")}})]},callback:e.callback,scope:e.scope||window})},listRecent:function(e){this.appWindow.sendWebAPI(Ext.apply({params:this.copyTo({},e.params,"offset,limit,filter"),callback:e.callback,scope:e.scope||window},SYNO.SDS.Drive.WebAPIDesc.list_recent))},createNode:function(e){this.appWindow.sendWebAPI(Ext.apply({params:this.copyTo({},e.params,"path,type,conflict_action"),callback:e.callback,scope:e.scope||window},SYNO.SDS.Drive.WebAPIDesc.create_files))},createNodePromise:function(e){return new Promise(function(t,i){this.createNode({params:e,callback:function(e,n){e?t(n):i(n)}})}.bind(this))},lockNode:function(e){this.appWindow.sendWebAPI(Ext.apply({params:this.copyTo({},e.params,"files,perform_lock"),callback:e.callback,scope:e.scope||window},SYNO.SDS.Drive.WebAPIDesc.lock_node))},lockNodePromise:function(e){return new Promise(function(t,i){this.lockNode({params:e,callback:function(e,n){e?t(n):i(n)}})}.bind(this))},requestUnlock:function(e){this.appWindow.sendWebAPI(Ext.apply({params:this.copyTo({},e.params,"path"),callback:e.callback,scope:e.scope||window},SYNO.SDS.Drive.WebAPIDesc.request_unlock))},requestUnlockPromise:function(e){return new Promise(function(t,i){this.requestUnlock({params:e,callback:function(e,n){e?t(n):i(n)}})}.bind(this))},getChannelMap:function(e){if(!SYNO.SDS.StatusNotifier.isAppEnabled("SYNO.SDS.Chat.Application"))return void e.callback.call(e.scope||window,!1);this.appWindow.sendWebAPI({api:"SYNO.Chat.Channel",version:1,method:"list",params:{type:"channel",attributes:["channel_id","name"]},callback:e.callback,scope:e.scope||window})},getGroupMap:function(e){this.appWindow.sendWebAPI({api:"SYNO.SynologyDrive.Share.Priv",version:1,method:"list",params:{type:"group",query:"",offset:0,limit:65536},callback:e.callback,scope:e.scope||window})},getUsers:function(e){this.appWindow.sendWebAPI({api:"SYNO.SynologyDrive.SCIM.User",version:1,method:"get",params:this.copyTo({},e.params||{},"user,uid"),callback:e.callback,scope:e.scope||window})},getNode:function(e){this.appWindow.sendWebAPI(Ext.apply({params:this.copyTo({},e.params,"path"),callback:e.callback,scope:e.scope||window},SYNO.SDS.Drive.WebAPIDesc.get_file))},getTrashAncestor:function(e){this.appWindow.sendWebAPI(Ext.apply({params:this.copyTo({},e.params,"path"),callback:e.callback,scope:e.scope||window},SYNO.SDS.Drive.WebAPIDesc.list_trash_ancestor))},getNodes:function(e){var t=[];Ext.each(e.params.path,function(e){t.push(Ext.apply({params:{path:e}},SYNO.SDS.Drive.WebAPIDesc.get_file))}),this.appWindow.sendWebAPI({compound:{stopwhenerror:!0,params:t},callback:e.callback,scope:e.scope||window})},getNodeAncestors:function(e){var t={path:e.params.path};this.appWindow.sendWebAPI(Ext.apply({params:t,callback:e.callback,scope:e.scope||window},SYNO.SDS.Drive.WebAPIDesc.list_node_ancestor))},setNode:function(e){this.appWindow.sendWebAPI(Ext.apply({params:this.copyTo({},e.params,"path,name,created_time,modified_time,labels,starred,properties,app_properties"),callback:e.callback,scope:e.scope||window},SYNO.SDS.Drive.WebAPIDesc.update_file))},setNodeTag:function(e){var t=e.params||{};this.appWindow.sendWebAPI(Ext.apply({params:this.copyTo({},t,"files,labels"),callback:e.callback,scope:e.scope||window},SYNO.SDS.Drive.WebAPIDesc.set_labels))},deleteNode:function(e){this.appWindow.sendWebAPI(Ext.apply({params:this.copyTo({},e.params||{},"files,permanent"),callback:e.callback,scope:e.scope||window},SYNO.SDS.Drive.WebAPIDesc.delete_files))},cleanNode:function(e){this.appWindow.sendWebAPI(Ext.apply({params:this.copyTo({},e.params,"path"),callback:e.callback,scope:e.scope||window},SYNO.SDS.Drive.WebAPIDesc.empty_recycle_bin))},restoreNode:function(e){this.appWindow.sendWebAPI(Ext.apply({params:this.copyTo({},e.params||{},"files,conflict_action,to_parent_folder"),callback:e.callback,scope:e.scope||window},SYNO.SDS.Drive.WebAPIDesc.restore_revisions))},copyNode:function(e){this.appWindow.sendWebAPI(Ext.apply({params:this.copyTo({},e.params||{},"files,to_parent_folder,conflict_action,dry_run"),callback:e.callback,scope:e.scope||window},SYNO.SDS.Drive.WebAPIDesc.copy_files))},moveNode:function(e){this.appWindow.sendWebAPI(Ext.apply({params:this.copyTo({},e.params||{},"files,to_parent_folder,conflict_action,dry_run,change_name"),callback:e.callback,scope:e.scope||window},SYNO.SDS.Drive.WebAPIDesc.move_files))},listTag:function(e){this.appWindow.sendWebAPI(Ext.apply({params:this.copyTo({},e.params||{},"filter,field,offset,limit,sort_by,sort_direction"),callback:e.callback,scope:e.scope||window},SYNO.SDS.Drive.WebAPIDesc.list_labels))},createTag:function(e){this.appWindow.sendWebAPI(Ext.apply({params:this.copyTo({},e.params||{},"file_id,name,color"),callback:e.callback,scope:e.scope||window},SYNO.SDS.Drive.WebAPIDesc.create_labels))},setTag:function(e){this.appWindow.sendWebAPI(Ext.apply({params:this.copyTo({},e.params||{},"label_id,name,color,position,display,is_new_label,update_is_new_label"),callback:e.callback,scope:e.scope||window},SYNO.SDS.Drive.WebAPIDesc.update_labels))},deleteTag:function(e){this.appWindow.sendWebAPI(Ext.apply({params:this.copyTo({},e.params||{},"label_id"),callback:e.callback,scope:e.scope||window},SYNO.SDS.Drive.WebAPIDesc.delete_labels))},hideTag:function(e){this.appWindow.sendWebAPI(Ext.apply({params:this.copyTo({display:!1,is_new_label:!1,update_is_new_label:!0},e.params||{},"label_id"),callback:e.callback,scope:e.scope||window},SYNO.SDS.Drive.WebAPIDesc.update_labels))},setShortcut:function(e){this.appWindow.sendWebAPI(Ext.apply({params:this.copyTo({starred:!0},e.params,"files"),callback:e.callback,scope:e.scope||window},SYNO.SDS.Drive.WebAPIDesc.star_file))},deleteShortcut:function(e){this.appWindow.sendWebAPI(Ext.apply({params:this.copyTo({starred:!1},e.params,"files"),callback:e.callback,scope:e.scope||window},SYNO.SDS.Drive.WebAPIDesc.star_file))},getShardLink:function(e){this.appWindow.sendWebAPI(Ext.apply({params:this.copyTo({},e.params,"path"),callback:e.callback,scope:e.scope||window},SYNO.SDS.Drive.WebAPIDesc.get_file_link))},getShardLinkPromise:function(e){return new Promise(function(t,i){this.getShardLink({params:e,callback:function(e,n){e?t(n):i(n)}})}.bind(this))},getShardLinkAndInfo:function(e){var t=[Ext.apply({params:this.copyTo({},e.params,"path")},SYNO.SDS.Drive.WebAPIDesc.get_file_link),Ext.apply({params:this.copyTo({},e.params,"path")},SYNO.SDS.Drive.WebAPIDesc.get_file),SYNO.SDS.Drive.WebAPIDesc.get_setting];this.appWindow.sendWebAPI({compound:{params:t,stopwhenerror:!1},callback:e.callback,scope:e.scope})},getShardLinkAndInfoPromise:function(e){return new Promise(function(t,i){this.getShardLinkAndInfo({params:e,callback:function(e,n){e&&!1===n.has_fail?t(n):i(n)}})}.bind(this))},setNodePerm:function(e){this.appWindow.sendWebAPI(Ext.apply({params:this.copyTo({},e.params,"path,permissions"),callback:e.callback,scope:e.scope||window},SYNO.SDS.Drive.WebAPIDesc.share_file))},deleteNodePerm:function(e){this.appWindow.sendWebAPI(Ext.apply({params:{path:e.params.path,permissions:[{action:"delete",member:{type:"user",name:e.params.username}}]},callback:e.callback,scope:e.scope||window},SYNO.SDS.Drive.WebAPIDesc.share_file))},requestAccess:function(e){this.appWindow.sendWebAPI(Ext.apply({params:this.copyTo({},e.params||{},"path"),callback:e.callback,scope:e.scope||window},SYNO.SDS.Drive.WebAPIDesc.request_access))},setChatChannel:function(e){this.appWindow.sendWebAPI(Ext.apply({params:this.copyTo({},e.params,"path, channel_ids"),callback:e.callback,scope:e.scope||window},SYNO.SDS.Drive.WebAPIDesc.bind_chat_channels))},convertOffice:function(e){this.appWindow.sendWebAPI(Ext.apply({params:this.copyTo({},e.params,"files,conflict_action,to_parent_folder,dry_run"),callback:e.callback,scope:e.scope||window},SYNO.SDS.Drive.WebAPIDesc.convert_office))},syncDevice:function(e){this.appWindow.sendWebAPI({compound:{params:e.params,stopwhenerror:!1},callback:e.callback,scope:e.scope})},syncPluginString:function(e){this.appWindow.sendWebAPI(Ext.apply({params:this.copyTo({},e.params,"app"),callback:e.callback,scope:e.scope||window},SYNO.SDS.Drive.WebAPIDesc.plugin_string))},checkAdvSharingPassword:function(e){this.appWindow.sendWebAPI(Ext.apply({params:e.params,encryption:["password"],callback:e.callback,scope:e.scope||window},SYNO.SDS.Drive.WebAPIDesc.auth_adv_sharing))},getAdvSharingLink:function(e){this.appWindow.sendWebAPI(Ext.apply({params:e.params,callback:e.callback,scope:e.scope||window},SYNO.SDS.Drive.WebAPIDesc.get_adv_sharing))},getAdvSharingLinkPromise:function(e){return new Promise(function(t,i){this.getAdvSharingLink({params:e,callback:function(e,n){e?t(n):i(n)}})}.bind(this))},updateAdvSharingLink:function(e){this.appWindow.sendWebAPI(Ext.apply({params:e.params,encryption:["protect_password"],callback:e.callback,scope:e.scope||window},SYNO.SDS.Drive.WebAPIDesc.update_adv_sharing))},updateAdvSharingLinkPromise:function(e){return new Promise(function(t,i){this.updateAdvSharingLink({params:e,callback:function(e,n){e?t(n):i(n)},scope:this})}.bind(this))},removeAdvSharingLink:function(e){this.appWindow.sendWebAPI(Ext.apply({params:e.params,callback:e.callback,scope:e.scope||window},SYNO.SDS.Drive.WebAPIDesc.remove_adv_sharing))},removeAdvSharingLinkPromise:function(e){return new Promise(function(t,i){this.removeAdvSharingLink({params:e,callback:function(e,n){e?t(n):i(n)},scope:this})}.bind(this))},createAdvSharingLink:function(e){this.appWindow.sendWebAPI(Ext.apply({params:e.params,callback:e.callback,scope:e.scope||window},SYNO.SDS.Drive.WebAPIDesc.create_adv_sharing))},createAdvSharingLinkPromise:function(e){return new Promise(function(t,i){this.createAdvSharingLink({params:e,callback:function(e,n){e?t(n):i(n)},scope:this})}.bind(this))},getQuotaInfo:function(e){this.appWindow.sendWebAPI(Ext.apply({callback:e.callback,scope:e.scope||window},SYNO.SDS.Drive.WebAPIDesc.get_quota))},getUserSetting:function(e){this.appWindow.sendWebAPI(Ext.apply({callback:e.callback,scope:e.scope||window},SYNO.SDS.Drive.WebAPIDesc.get_user_setting))},getUserSettingPromise:function(e){return new Promise(function(t,i){this.getUserSetting({params:e,callback:function(e,n){e?t(n):i(n)},scope:this})}.bind(this))},notifyDownloadEvent:function(e){this.appWindow.sendWebAPI(Ext.apply({params:Ext.apply({notify_download_event:!0},e.params),callback:e.callback,scope:e.scope||window},SYNO.SDS.Drive.WebAPIDesc.download_files))},clearNotifications:function(e){this.appWindow.sendWebAPI(Ext.apply({params:e.params,callback:e.callback,scope:e.scope||window},SYNO.SDS.Drive.WebAPIDesc.delete_notifications))},createFileRequest:function(e){this.appWindow.sendWebAPI(Ext.apply({params:e.params,callback:e.callback,scope:e.scope||window},SYNO.SDS.Drive.WebAPIDesc.create_file_request))},createFileRequestPromise:function(e){return new Promise(function(t,i){this.createFileRequest({params:e,callback:function(e,n){e?t(n):i(n)},scope:this})}.bind(this))},updateFileRequest:function(e){this.appWindow.sendWebAPI(Ext.apply({params:e.params,callback:e.callback,scope:e.scope||window},SYNO.SDS.Drive.WebAPIDesc.update_file_request))},updateFileRequestPromise:function(e){return new Promise(function(t,i){this.updateFileRequest({params:e,callback:function(e,n){e?t(n):i(n)},scope:this})}.bind(this))},deleteFileRequest:function(e){var t=this;Ext.each(e.params.delete_infos,function(i,n){t.appWindow.sendWebAPI(Ext.apply({params:{sharing_link:i.sharing_link},callback:e.callback,scope:e.scope||window},SYNO.SDS.Drive.WebAPIDesc.delete_file_request))})},updateFileRequestStatus:function(e){var t=this;Ext.each(e.params.sharing_links,function(i,n){var o=e.params.paths[n];t.appWindow.sendWebAPI(Ext.apply({params:{sharing_link:i,path:o,file_request_status:e.params.file_request_status},callback:e.callback,scope:e.scope||window},SYNO.SDS.Drive.WebAPIDesc.update_file_request))})},accessFile:function(e){this.appWindow.sendWebAPI(Ext.apply({params:e.params,callback:e.callback,scope:e.scope||window},SYNO.SDS.Drive.WebAPIDesc.access_file))},listShare:function(e){this.appWindow.sendWebAPI(Ext.apply({params:e.params,callback:e.callback,scope:e.scope||window},SYNO.SDS.Drive.WebAPIDesc.list_share))},listSharePromise:function(e){return new Promise(function(t,i){this.listShare({params:e,callback:function(e,n){e?t(n):i(n)}})}.bind(this))},enableTeamFolder:function(e){this.appWindow.sendWebAPI(Ext.apply({params:e.params,callback:e.callback,scope:e.scope||window},SYNO.SDS.Drive.WebAPIDesc.enable_team_folder))},enableTeamFolderPromise:function(e){return new Promise(function(t,i){this.enableTeamFolder({params:e,callback:function(e,n){e?t(n):i(n)}})}.bind(this))},updateTeamFolderSettings:function(e){this.appWindow.sendWebAPI(Ext.apply({params:e.params,callback:e.callback,scope:e.scope||window},SYNO.SDS.Drive.WebAPIDesc.update_team_folder))},updateTeamFolderSettingsPromise:function(e){return new Promise(function(t,i){this.updateTeamFolderSettings({params:e,callback:function(e,n){e?t(n):i(n)}})}.bind(this))},getDbConfig:function(e){this.appWindow.sendWebAPI(Ext.apply({params:e.params,callback:e.callback,scope:e.scope||window},SYNO.SDS.Drive.WebAPIDesc.get_db_config))},getDbConfigPromise:function(e){return new Promise(function(t,i){this.getDbConfig({params:e,callback:function(e,n){e?t(n):i(n)}})}.bind(this))},createShare:function(e){this.appWindow.sendWebAPI(Ext.apply({params:e.params,callback:e.callback,scope:e.scope||window,encryption:["shareinfo"]},SYNO.SDS.Drive.WebAPIDesc.create_share))},createSharePromise:function(e){return new Promise(function(t,i){this.createShare({params:e,callback:function(e,n){e?t(n):i(n)}})}.bind(this))},listC2Share:function(e){this.appWindow.sendWebAPI(Ext.apply({params:e.params,callback:e.callback,scope:e.scope||window},SYNO.SDS.Drive.WebAPIDesc.list_c2_share))},getC2ShareAccountsPromise:function(e){return new Promise(function(t,i){this.listC2Share({params:e,callback:function(e,n){e?t(n):i(n)}})}.bind(this))},listVolume:function(e){this.appWindow.sendWebAPI(Ext.apply({params:e.params,callback:e.callback,scope:e.scope||window},SYNO.SDS.Drive.WebAPIDesc.list_volume))},listVolumePromise:function(e){return new Promise(function(t,i){this.listVolume({params:e,callback:function(e,n){e?t(n):i(n)}})}.bind(this))}}),Ext.define("SYNO.SDS.Drive.ColorPalette",{extend:"Ext.Container",xtype:"syno_drive_colorpalette",rowLength:12,selected:[],defaultColor:null,colors:[],constructor:function(e){this.colors=SYNO.SDS.Drive.Define.TagColor;var t,i=[];for(t=0;t<this.colors.length;t++)i.push({xtype:"container",cls:"color-item",color:this.colors[t],items:[{xtype:"container",cls:t<this.rowLength?"light":"dark",style:"background-color: #"+this.colors[t]+";"}]});var n={defaults:{select:function(){return this.addClass("color-selected"),this},deselect:function(){return this.removeClass("color-selected"),this},listeners:{scope:this,single:!0,afterrender:function(e){this.mon(e.el,"click",function(t,i,n){this.select(e)},this)}}},items:i};this.callParent([Ext.apply(n,e)]),this.addEvents("select"),this.addClass("syno-d-colorpalette"),null!==this.defaultColor&&this.select(this.items.get(this.defaultColor))},select:function(e){var t;for(t=0;t<this.selected.length;++t)this.selected[t].deselect();this.selected=[e.select()],this.fireEvent("select",e.color)},getSelectedNode:function(){if(this.selected.length)return{color:this.selected[0].color}}}),Ext.define("SYNO.SDS.Drive.ColorMenu",{extend:"SYNO.ux.Menu",constructor:function(e){this.callParent([this.fillConfig(e)])},fillConfig:function(e){var t={cls:"syno-d-color-menu",items:[{xtype:"menutextitem",text:SYNO.SDS.Drive._T("tag","select_color")},this.colorPalette=new SYNO.SDS.Drive.ColorPalette({itemId:"ctn",listeners:{scope:this,select:function(e){this.color!==e&&(this.rec.set("color",e),this.fireEvent("colorchange",this.rec.id,e,this.rec)),this.hide()}}})]};return Ext.apply(t,e)},show:function(e,t,i,n){if(n){this.el||this.render(),this.showAt(this.el.getAlignToXY(e,t||this.defaultAlign,this.defaultOffsets),i);var o=n.get("color");this.rec=n,this.getComponent("ctn").items.each(function(e){e.color===o?(this.color=o,e.select()):e.deselect()},this);this.el.getBottom()>=Ext.getBody().getBottom()&&this.el.setTop(this.el.getTop()-25)}}}),Ext.define("SYNO.SDS.Drive.MenuCheckItem",{extend:"Ext.menu.CheckItem",xtype:"syno_drive_menucheckitem",selectPartialCls:"select-partial",constructor:function(e){this.itemTpl=this.getTpl(),this.callParent([e]),this.mon(this,"checkchange",function(e,t){e.removeClass(e.selectPartialCls),e.parentMenu&&(Ext.fly(e.getId()).removeClass(e.parentMenu.selectPartialCls||e.selectPartialCls),e.parentMenu.fireEvent("checkchange",e,t))})},getTpl:function(){return new Ext.XTemplate('<a class="x-menu-list-item" hidefocus="true" unselectable="on" href="{href}"','<tpl if="hrefTarget">',' target="{hrefTarget}"',"</tpl>",">",'<div id="{id}" class="{cls} x-unselectable">','<img alt="{altText}" src="{icon}" class="x-menu-item-icon {iconCls}"/>','<tpl if="color">','<div class="syno-d-color" style="background-color:#{color}; color:#FFF;"></div>',"</tpl>",'<span class="x-menu-item-text" ext:qtip="{qtip}">{text}</span>','<tpl if="readonlyIcon">','<div class="syno-d-readonly-icon"></div>',"</tpl>","</div>","</a>")},getTemplateArgs:function(){return{id:this.id,cls:this.itemCls+(this.menu?" x-menu-item-arrow":"")+(this.cls?" "+this.cls:""),href:this.href||"#",hrefTarget:this.hrefTarget,icon:this.icon||Ext.BLANK_IMAGE_URL,iconCls:this.iconCls||"",text:this.itemText||this.text||"&#160;",altText:this.altText||"",color:this.color||"",readonlyIcon:this.readonlyIcon||!1,qtip:this.qtip||""}}}),Ext.define("SYNO.SDS.Drive.AddTag",{extend:"SYNO.SDS.Drive.AddEditWindow",mode:"add",maxNameLength:SYNO.SDS.Drive.Define.TAG_MAX_LENGTH,constructor:function(e){this.initName=e.initName,this.callParent([Ext.apply({width:547,height:254},e)])},getFormPanel:function(){return this.formPanel=this.formPanel||new SYNO.ux.FormPanel({cls:"syno-d-add-edit-form",border:!1,autoHeight:!0,items:[{itemCls:"tag-title",xtype:"syno_textfield",fieldLabel:_T("common","name"),itemId:this.nameItemId,name:this.nameItemId,width:330,validator:this.nameValidator.createDelegate(this),value:this.initName?this.initName:void 0},{itemCls:"tag-color",xtype:"syno_drive_colorpalette",fieldLabel:SYNO.SDS.Drive._T("tag","color"),itemId:"color",defaultColor:0,width:336}]}),this.formPanel},isDirty:function(){return!0},getParams:function(){var e,t=this.getForm(),i={},n=t.getFieldValues();n.title&&(e=n.title.trim())&&(i.name=e);var o=this.formPanel.getComponent("color").getSelectedNode();return i.color="#"+o.color,i.name?i:(t.markInvalid({title:_JSLIBSTR("extlang","fieldblank")}),!1)},nameValidator:function(e){var t=e.trim();return 0===t.length?this.getForm().findField(this.nameItemId).blankText:!(t.length>0&&t.length>this.maxNameLength)||SYNO.SDS.Drive._T("error","label_name_too_long")},onAction:function(e){this.findAppWindow().getAction().createTag(e,this.onApplyCb,this)},onApplyDone:function(e,t,i){this.fireEvent("apply","add",e.label_id,t.name,t.color,t.type)}}),Ext.define("SYNO.SDS.Drive.EditTag",{extend:"SYNO.SDS.Drive.AddEditWindow",mode:"edit",maxNameLength:SYNO.SDS.Drive.Define.TAG_MAX_LENGTH,constructor:function(e){this.callParent([this.fillConfig(e)])},fillConfig:function(e){var t=e.targetRec;if(!t)throw"no target";this.rec=t,delete e.targetRec;var i={width:547,height:254};return Ext.apply(i,e)},getFormPanel:function(){return this.formPanel=this.formPanel||new SYNO.ux.FormPanel({cls:"syno-d-add-edit-form",autoHeight:!0,border:!1,items:[{itemCls:"tag-title",xtype:"syno_textfield",fieldLabel:_T("common","name"),itemId:this.nameItemId,name:this.nameItemId,value:this.rec.get("name"),width:330,validator:this.nameValidator.createDelegate(this)},{itemCls:"tag-color",xtype:"syno_drive_colorpalette",fieldLabel:SYNO.SDS.Drive._T("tag","color"),itemId:"color",defaultColor:this.getColorIndex(this.rec.get("color")),width:336}]}),this.formPanel},isDirty:function(){var e=this.formPanel.getComponent("color").getSelectedNode();return this.getForm().isDirty()||this.rec.get("color")!==e.color},getParams:function(){var e=this.getForm(),t={},i=e.getFieldValues(),n=i.title.trim(),o=this.formPanel.getComponent("color").getSelectedNode();return!!this.rec.get("label_id")&&(n===this.rec.get("title")&&this.rec.get("color")===o.color?void this.onCancel():(t.label_id=this.rec.get("label_id"),i.title&&n!==this.rec.get("title")&&(t.name=n),o.color!==this.rec.get("color")&&(t.color="#"+o.color),t))},nameValidator:function(e){var t=e.trim();return 0===t.length?this.getForm().findField(this.nameItemId).blankText:!(t.length>0&&t.length>this.maxNameLength)||SYNO.SDS.Drive._T("error","label_name_too_long")},onAction:function(e){this.findAppWindow().getAction().setTag(e,this.onApplyCb,this)},onApplyDone:function(e,t,i){this.fireEvent("apply","edit",t.label_id,t.title,t.color)},getColorIndex:function(e){var t=SYNO.SDS.Drive.Define.TagColor.indexOf(e);return-1!==t&&t}}),Ext.define("SYNO.SDS.Drive.TagButton",{extend:"SYNO.ux.Button",selectedTags:[],originalValue:[],constructor:function(e){var t={};e.hasOwnProperty("menuCfg")&&(t=e.menuCfg,delete e.menuCfg),e.hasOwnProperty("text")?this.defaultText=e.text:this.defaultText=SYNO.SDS.Drive._T("search","all_tags");var i={cls:"syno-d-combo-btn",text:this.defaultText,btnStyle:"grey",menu:new SYNO.SDS.Drive.SearchTagMenu(Ext.apply({ownerBtn:this,handleViewOnlyLabel:!1},t))};Ext.apply(i,e),this.callParent([i]),this.addEvents("change"),this.mon(this.menu,"apply",this.selectTags,this)},selectTags:function(e,t,i){this.setValue(i),this.fireEvent("change",this.selectedTags)},setValue:function(e){this.selectedTags=e||[],this.setTagText(this.selectedTags),this.menu.setItem([{data:{labels:this.selectedTags}}])},setTagText:function(e){var t=[];e.forEach(function(e,i,n){t.push(e.name)},this),this.setText(t.length>0?t.join(", "):this.defaultText)},getTagIds:function(){var e=[];return this.selectedTags.forEach(function(t,i,n){e.push(t.file_id)},this),e},isTagSelected:function(e){var t;for(t=0;t<this.selectedTags.length;++t)if(e===this.selectedTags[t].id)return!0;return!1},reset:function(){this.setText(this.defaultText),this.selectedTags=[],this.menu.setItem([{data:{labels:this.selectedTags}}]),this.fireEvent("change",this.selectedTags)},getValue:function(){return this.getTagIds()},getRawValue:function(){return this.selectedTags},setOriginalValue:function(e){var t,i=[];for(t=0;t<e.length;++t)i.push(e[t].id);this.originalValue=i},isDirty:function(){if(this.originalValue.length!==this.selectedTags.length)return!0;var e;for(e=0;e<this.selectedTags.length;++e)if(-1===this.originalValue.indexOf(this.selectedTags[e].id))return!0;return!1}}),Ext.define("SYNO.SDS.Drive.SearchListMenu",{extend:"SYNO.ux.Menu",contentMaxHeight:224,constructor:function(e){e.selector&&(this.selector=e.selector,delete e.selector);var t=284;e.width&&(t=e.width-16);var i={width:300,autoFlexcroll:!1,maxHeight:void 0,items:[]};Ext.apply(i,e),i.items.unshift(this.selector),e.disableSearch||(this.searchfield=new SYNO.TextFilter({width:t,itemId:"searchfield",listeners:{scope:this,keyup:{fn:this.onKeyUp,buffer:300},afterrender:{scope:this,single:!0,fn:function(e){e.mon(e.trigger,"click",function(){this.onKeyUp(e)},this),e.wrap.addClass("syno-d-searchlist-searchfield")}}}}),i.items.unshift(this.searchfield)),this.callParent([i]),this.addClass("syno-d-search-menu syno-d-checkbox-menu"),this.mon(this,"beforegetalign",this.loadList,this),this.mon(this,{scope:this,show:function(){this.setFocus(50)},hide:function(e,t){e.reset()}})},show:function(e,t,i){return this.floating&&(this.parentMenu=i,this.el||(this.render(),this.doLayout(!1,!0)),this.fireEvent("beforegetalign")),this.callParent(arguments)},setFocus:function(e){this.searchfield&&this.searchfield.focus(!1,e||0)},focus:function(e,t){return t?(this.focusTask=new Ext.util.DelayedTask(this.focus,this,[e,!1]),this.focusTask.delay(Ext.isNumber(t)?t:10),this):(this.rendered&&!this.isDestroyed&&this.setFocus(),this)},reset:function(){this.searchText="",this.searchfield&&this.searchfield.reset(),this.match([],!1)},onKeyUp:function(e,t){var i=e.getValue().trim();if(this.searchText=i,!this.searchText)return void this.match([],!1);var n=-1<this.filter_store.findExact("name",i)||-1<this.filter_shared_store.findExact("name",i);this.filter_store.filter("name",i,!0),this.filter_shared_store.filter("name",i,!0);var o=this.filter_store.getRange(),s=this.filter_shared_store.getRange();this.filter_store.clearFilter(),this.filter_shared_store.clearFilter(),this.match(o.concat(s),n)},match:Ext.emptyFn}),Ext.define("SYNO.SDS.Drive.SearchCheckItemMenu",{extend:"SYNO.SDS.Drive.SearchListMenu",selectPartialCls:"select-partial",constructor:function(e){this.hideCreate=!0===e.hideCreate;var t={selector:new SYNO.ux.Menu({cls:"syno-d-menu syno-d-scrollbar-fix",floating:!1,maxHeight:250,autoFlexcroll:!0,listeners:{scope:this,checkchange:this.onCheckChange}}),cls:"syno-d-tag-searchlist",items:[{itemId:"no-label",text:SYNO.SDS.Drive._T("common","no_label"),cls:"syno-d-tag-btn-ct",hidden:!0,disabled:!0},{itemId:"sep",xtype:"menuseparator",hidden:this.hideCreate},{itemId:"create",text:SYNO.SDS.Drive._T("common","create_personal_label"),cls:"syno-d-tag-btn-ct",hidden:this.hideCreate,scope:this,handler:function(){var e=this.findAppWindow(),t=this;SYNO.SDS.Drive.Utils.openDriveVueWindow(e,SYNO.SDS.Drive.Vue.DialogTag,{mode:"add",findAppWindow:this.findAppWindow.bind(this),name:this.searchText,listeners:{apply:function(e){t.onCreate(void 0,e.label_id,e.name,e.color)}}})}},{itemId:"apply",text:SYNO.SDS.Drive._T("common","commit"),scope:this,cls:"syno-d-tag-btn-ct",hidden:!0,handler:this.onApply}]};this.callParent([Ext.apply(t,e)]),this.filter_store||(this.filter_store=new Ext.data.JsonStore({idProperty:"label_id",autoDestroy:!0,fields:["label_id","name","color"]})),this.filter_shared_store||(this.filter_shared_store=new Ext.data.JsonStore({idProperty:"label_id",autoDestroy:!0,fields:["label_id","name","color"]})),this.addEvents("apply"),this.itemTags={},this.itemRecords=[],this.mon(this,"show",function(){this.firstChecked=!1},this)},adjustContentHeight:function(){var e,t=this.selector.el.query(".contentwrapper"),i=this.contentMaxHeight;e=t.length?Ext.fly(t[0]).getHeight():this.selector.getHeight(),i=e>i?i:e,this.selector.setHeight(i||1),this.doLayout(!0),this.selector.ul.setHeight(i?i+1:2),
this.selector.updateScroller()},getCheckedResult:function(){var e={};this.selector.items.each(function(t,i,n){t.checked&&(e[t.data.label_id]=t)},this);var t={add:[],remove:[],checkedList:[]};return Ext.iterate(this.itemTags,function(i,n,o){e.hasOwnProperty(i)||t.remove.push({label_id:i})},this),Ext.iterate(e,function(e,i,n){t.checkedList.push(i.data),this.itemTags.hasOwnProperty(e)&&(i.el.hasClass(this.selectPartialCls)||this.itemTags[e]===this.itemRecords.length)||t.add.push(i.data)},this),this.checkResult=t,t},match:function(e,t){var i,n=[],o=!this.searchText,s=o,r=o;for(i=0;i<e.length;++i){var a=e[i].id;n.push(a),"shared_label"===e[i].json.category?r=!0:s=!0}this.selector.items.each(function(e,t,i){!0===e.isRootNode||e.isXType("menuseparator")||(o||-1<n.indexOf(e.data.label_id)?e.show():e.hide())},this),this.setRootNodeShow("label",s),this.setRootNodeShow("shared_label",r);var l=this.findFromSelectorById("sepSharedLabel");l&&l.setVisible(s&&r),this.completeMatch=t;var d=!this.hideCreate&&!t;this.getComponent("create").setVisible(d).setText(this.searchText?String.format(SYNO.SDS.Drive._T("common","create_sth"),this.searchText):SYNO.SDS.Drive._T("common","create_personal_label")),this.getComponent("sep").setVisible(d||this.getComponent("apply").isVisible()),this.adjustContentHeight()},onCheckChange:function(e,t){this.firstChecked=!0;var i=this.getCheckedResult(),n=i.add.length||i.remove.length;this.getComponent("apply").setVisible(n);var o=!this.hideCreate&&!this.completeMatch;this.getComponent("create").setVisible(o&&!n),this.getComponent("sep").setVisible(o||n),this.adjustContentHeight()},reset:function(){this.getComponent("apply").setVisible(!1),SYNO.SDS.Drive.SearchCheckItemMenu.superclass.reset.apply(this,arguments)},onApply:function(){(this.checkResult.add.length||this.checkResult.remove.length)&&this.fireEvent("apply",this.checkResult.add,this.checkResult.remove,this.checkResult.checkedList),this.hide(!0)},onCreate:Ext.emptyFn,findFromSelectorById:function(e){return this.selector.items.get(e)},setRootNodeShow:function(e,t){var i=this.findFromSelectorById(e);i&&(t?i.show():i.hide())}}),Ext.define("SYNO.SDS.Drive.SearchTagMenu",{extend:"SYNO.SDS.Drive.SearchCheckItemMenu",constructor:function(e){e.store&&(this.store=e.store,delete e.store),e.sharedLabelStore&&(this.sharedLabelStore=e.sharedLabelStore,delete e.sharedLabelStore),this.handleViewOnlyLabel=e.handleViewOnlyLabel||!0,this.callParent([e]),this.store&&this.mon(this.store,"load",function(){this.isVisible()&&this.loadList()},this),this.sharedLabelStore&&this.mon(this.sharedLabelStore,"load",function(){this.isVisible()&&this.loadList()},this)},onCreate:function(e,t,i,n){this.getCheckedResult();var o={label_id:t,name:i,color:n,type:"personal_label"};this.checkResult.add.push(o),this.checkResult.checkedList.push(o),this.onApply()},setItem:function(e){var t={};Ext.each(e,function(e,i,n){Ext.each(e.labels||e.data.labels,function(e,i,n){t.hasOwnProperty(e.label_id)||(t[e.label_id]=0),t[e.label_id]++})},this),this.itemRecords=e,this.itemTags=t},loadList:function(){this.filter_store.clearData(),this.checkResult={add:[],remove:[],checkedList:[]},this.getComponent("apply").setVisible(!1),this.getComponent("sep").setVisible(!this.hideCreate),this.selector.ul.dom&&this.selector.ul.dom.fleXcroll&&this.selector.ul.dom.fleXcroll.setScrollPos(!1,0),this.GetSeletions&&this.setItem(this.GetSeletions());var e=this.store?this.loadPersonalLabel():{},t=this.sharedLabelStore?this.loadSharedLabel():{},i=e.data&&e.data.length>0,n=t.data&&t.data.length>0;this.selector.suspendEvents(),this.selector.removeAll(),i&&this.selector.add([this.getRootItemConfig("label",SYNO.SDS.Drive._T("common","personal_label")),e.checked,e.unchecked]),i&&n&&this.selector.add([{itemId:"sepSharedLabel",xtype:"menuseparator",hidden:!1}]),n&&this.selector.add([this.getRootItemConfig("shared_label",SYNO.SDS.Drive._T("common","shared_labels")),t.checked,t.unchecked]),this.getComponent("no-label").setVisible(0===this.selector.items.length),this.searchfield&&this.searchfield.setVisible(0!==this.selector.items.length),this.selector.resumeEvents(),this.selector.doLayout(),e&&this.filter_store.loadData(e.data),t&&this.filter_shared_store.loadData(t.data),this.adjustContentHeight()},loadPersonalLabel:function(){var e,t=[],i={},n=[],o=[];return this.store.each(function(s){e=s.data,"label"===e.category&&(i=this.getItemConfig(e),i.checked?n.push(i):t.push(i),o.push(s.data))},this),{checked:n,unchecked:t,data:o}},loadSharedLabel:function(){var e,t=[],i={},n=[],o=[];return this.sharedLabelStore.each(function(s){e=s.data,"shared_label"===e.category&&!1!==e.display&&(i=this.getItemConfig(e),!i.checked&&i.disabled||(i.checked?n.push(i):t.push(i),o.push(s.data)))},this),{checked:n,unchecked:t,data:o}},getRootItemConfig:function(e,t){return{xtype:"menuitem",id:e,cls:"tag-menu-root",canActivate:!1,isRootNode:!0,text:t}},getItemConfig:function(e){var t=Ext.util.Format.htmlEncode(e.name),i=Ext.util.Format.htmlEncode(t),n=!1;if("shared_label"===e.category){var o=SYNO.SDS.Drive.SharedLabel.LabelConfig.roleOptions.find(function(t){return t.value===e.apply_permission});n=o.value===SYNO.SDS.Drive.SharedLabel.LabelConst.PERMISSION_READONLY,o&&o.label&&(i+="<br><b>"+o.label+"</b>")}var s={xtype:"syno_drive_menucheckitem",hideOnClick:!1,data:e,color:e.color,disabled:!0===this.handleViewOnlyLabel&&n,readonlyIcon:!0===this.handleViewOnlyLabel&&n,qtip:i,text:Ext.util.Format.htmlEncode(e.name),listeners:{scope:this,click:function(e,t){Ext.fly(t.getTarget()).hasClass("x-menu-item-text")&&!this.firstChecked&&(!0===e.checked?e.checked=!1:e.checked=!0,this.onCheckChange(),this.onApply())}}};return this.itemTags.hasOwnProperty(e.label_id)&&(s.checked=!0,s.cls=this.itemTags[e.label_id]!==this.itemRecords.length?this.selectPartialCls:""),s}}),Ext.define("SYNO.SDS.Drive.Conflict.Dialog",{extend:"SYNO.SDS.Drive.ModalWindow",constructor:function(e){Ext.apply(this,e||{});var t={owner:e.owner,title:this.getTitle(),cls:"syno-d-conflict-dialog",width:540,autoHeight:!0,resizable:!1,layout:"fit",items:[this.getPanel()],buttons:[{xtype:"syno_button",text:SYNO.SDS.Drive._T("common","cancel"),btnStyle:"grey",handler:this.onCancelClick,scope:this}],listeners:this.listeners||{}};this.currIndex=0,this.conflictAction={},this.callParent([t]),this.mon(this,"afterlayout",this.onAfterLayout,this,{single:!0})},onAfterLayout:function(){this.replaceContainer&&this.mon(this.replaceContainer,"containerclick",this.onContainerClick,this),this.skipContainer&&this.mon(this.skipContainer,"containerclick",this.onContainerClick,this),this.keepContainer&&this.mon(this.keepContainer,"containerclick",this.onContainerClick,this),this.updateCheckbox()},getTitle:function(){var e=SYNO.SDS.Drive._T;return String.format(e("action","mvcp_replace"),e("action",this.action))},getPanel:function(){if(this.panel)return this.panel;var e=[{xtype:"syno_displayfield",cls:"syno-d-conflict-desc",value:SYNO.SDS.Drive._T("action","mvcp_conflict_desc")}];"restore"!==this.action&&e.push(this.getReplaceContainer()),e.push(this.getSkipContainer()),e.push(this.getKeepContainer()),e.push(this.getCheckbox());var t={cls:"syno-d-conflict-panel",autoFlexcroll:!0,defaults:{style:{marginBottom:"8px"}},items:e};return this.panel=new SYNO.ux.Panel(t),this.panel},getReplaceContainer:function(){if(this.replaceContainer)return this.replaceContainer;var e=SYNO.SDS.Drive._T;return this.replaceContainer=new SYNO.SDS.Drive.Conflict.FileInfoContainer({action:"replace",actionKey:"overwrite",title:this.getTitle(),desc:e("action",String.format("replace_{0}_desc",this.action)),fileInfo:this.conflicts[0].src}),this.replaceContainer},getSkipContainer:function(){if(this.skipContainer)return this.skipContainer;var e=SYNO.SDS.Drive._T;return this.skipContainer=new SYNO.SDS.Drive.Conflict.FileInfoContainer({action:"skip",title:e("action","skip"),desc:e("action","skip_desc"),fileInfo:this.conflicts[0].dest}),this.skipContainer},getKeepContainer:function(){if(this.keepContainer)return this.keepContainer;var e=SYNO.SDS.Drive._T;return this.keepContainer=new SYNO.SDS.Drive.Conflict.KeepContainer({action:"keep",actionKey:"autorename",title:String.format(e("action","keep_both_file"),e("action",this.action)),desc:e("action",String.format("rename_{0}_desc",this.action)),fileInfo:this.conflicts[0].src}),this.keepContainer},getCheckbox:function(){return this.checkbox?this.checkbox:(this.checkbox=new SYNO.ux.Checkbox({cls:"syno-d-conflict-checkbox",boxLabel:SYNO.SDS.Drive._T("action","mvcp_apply_all_label"),itemId:"apply_all",hidden:1===this.conflicts.length}),this.checkbox)},updatePanel:function(){if(++this.currIndex===this.conflicts.length)return this.doConflictAction();this.replaceContainer&&this.replaceContainer.updateContent(this.conflicts[this.currIndex].src),this.skipContainer&&this.skipContainer.updateContent(this.conflicts[this.currIndex].dest),this.keepContainer&&this.keepContainer.updateContent(this.conflicts[this.currIndex].src),this.updateCheckbox(),this.doLayout()},onContainerClick:function(e){var t=SYNO.SDS.Drive.Utils.getPathId(this.conflicts[this.currIndex].src.file_id);if(this.conflictAction[t]=e,this.checkbox.getValue()){for(var i=this.currIndex+1;i<this.conflicts.length;++i)t=SYNO.SDS.Drive.Utils.getPathId(this.conflicts[i].src.file_id),this.conflictAction[t]=e;return this.doConflictAction()}this.updatePanel()},updateCheckbox:function(){var e=SYNO.SDS.Drive._T,t=this.conflicts.length-this.currIndex-1;0===t?this.checkbox.boxlabelEl.update(e("action","mvcp_apply_all_label")):this.checkbox.boxlabelEl.update(String.format(e("action","mvcp_apply_label"),t))},doConflictAction:function(){!1!==this.fireEvent("doaction",this.conflictAction)&&this.close()},onCancelClick:function(){this.close()}}),Ext.define("SYNO.SDS.Drive.Conflict.Container",{extend:"Ext.Container",constructor:function(e){var t=[{xtype:"syno_displayfield",cls:"syno-d-conflict-c-title",value:e.title}];t=t.concat(this.getItems(e));var i={cls:"syno-d-conflict-container",items:t,listeners:{scope:this,afterlayout:{single:!0,fn:this.onAfterLayout}}};this.action=e.action,this.actionKey=e.actionKey||this.action,this.callParent([i])},onAfterLayout:function(){this.mon(this.el,{scope:this,click:this.onElClick})},onElClick:function(){this.fireEvent("containerclick",this.actionKey)},updateContent:function(e){this.getComponent("info-template").update(e)},getItems:function(e){}}),Ext.define("SYNO.SDS.Drive.Conflict.FileInfoContainer",{extend:"SYNO.SDS.Drive.Conflict.Container",getItems:function(e){return[{xtype:"syno_displayfield",cls:"syno-d-conflict-c-desc",value:e.desc},{itemId:"info-template",border:!1,data:e.fileInfo,tpl:this.getTemplate()}]},getTemplate:function(){return this.infoTpl?this.infoTpl:(this.infoTpl=new Ext.XTemplate('<div class="syno-d-conflict-c-icon syno-d-start-ntype" style="{[this.getFileTypeStyle(values)]}"></div>','<div class="syno-d-conflict-c-fileinfo">','<div class="filename" ext:qtip="{[SYNO.SDS.Drive.Utils.doubleHtmlEncode(values.name)]}">{[this.getName(values.name)]}</div>','<div class="path" ext:qtip="{[SYNO.SDS.Drive.Utils.doubleHtmlEncode(values.path)]}">{[this.getPath(values.path)]}</div>','<div class="size">{[this.getSize(values.size)]}</div>','<div class="mtime">{[this.getMtime(values.mtime)]}</div>',"</div>",{getFileTypeStyle:function(e){var t="dir"===e.file_type?"dir":SYNO.SDS.Drive.Utils.getExt(e.name);return SYNO.SDS.Drive.FileType.getFileTypeIconStyle(t,64)},getName:function(e){return Ext.util.Format.htmlEncode(SYNO.SDS.Drive.Utils.parseDisplayName(e))},getPath:function(e){return String.format("{0}: {1}",SYNO.SDS.Drive._T("common","path"),Ext.util.Format.htmlEncode(e))},getSize:function(e){return String.format("{0}: {1}",SYNO.SDS.Drive._T("file","size"),Ext.util.Format.fileSize(e))},getMtime:function(e){var t=SYNO.SDS.Drive.Utils.getFormatDateTime(new Date(1e3*e));return String.format("{0}: {1}",SYNO.SDS.Drive._T("file","mtime"),t)}}),this.infoTpl)}}),Ext.define("SYNO.SDS.Drive.Conflict.KeepContainer",{extend:"SYNO.SDS.Drive.Conflict.Container",getItems:function(e){return this.desc=e.desc,[{itemId:"info-template",border:!1,data:e.fileInfo,tpl:this.getTemplate()}]},getTemplate:function(){if(this.infoTpl)return this.infoTpl;var e=this.desc;return this.infoTpl=new Ext.XTemplate('<div class="syno-d-conflict-c-desc">{[this.getDesc()]}','<span class="syno-d-conflict-k-name">','<span class="syno-d-conflict-k-name-head" ext:qtip="{[this.getKeepFileNameQtip(values.renamed)]}">',"{[this.getHeadFileName(values.renamed)]}","</span>",'<span class="syno-d-conflict-k-name-tail" ext:qtip="{[this.getKeepFileNameQtip(values.renamed)]}">',"{[this.getTailFileName(values.renamed)]}","</span>","</span>","</div>",{getDesc:function(){return String.format(e," ")},getKeepFileNameQtip:function(e){return Ext.util.Format.htmlEncode(this.getKeepFileName(e))},getKeepFileName:function(e){var t=this.getHeadFileName(e),i=this.getTailFileName(e),n=t+i;return n=n.substr(1,n.length-2)},getHeadFileName:function(e){var t=e.lastIndexOf("("),i=-1===t?e:e.substr(0,t-1);return String.format('"{0}',Ext.util.Format.htmlEncode(i))},getTailFileName:function(e){var t=e.lastIndexOf("("),i=Ext.util.Format.htmlEncode(e.substr(t));return String.format('&nbsp;{0}"',i)}}),this.infoTpl}}),Ext.define("SYNO.SDS.Drive.RoundButton",{extend:"Ext.Button",template:new Ext.Template('<em class="{2} {3} syno-d-round-button" style="{5}" unselectable="on"><button type="{0}"></button><div class="syno-d-round-img"></div></em>').compile(),getMenuClass:function(){return""},getTemplateArgs:function(){var e=[this.type,"x-btn-"+this.scale+" x-btn-icon-"+this.scale+"-"+this.iconAlign,this.getMenuClass(),this.cls,this.id];return this.color?e.push("background-color:"+this.color+";"):e.push(""),this.updateAccountIcon(),e},updateAccountIcon:function(){this.rendered&&this.el&&this.el.dom&&this.color&&this.el.setStyle("background",this.color)}}),Ext.reg("synodrive_round_button",SYNO.SDS.Drive.RoundButton),Ext.define("SYNO.SDS.Drive.TextButton",{extend:"Ext.Button",template:new Ext.Template('<em class="{2} {3} syno-d-text-button " ext:qtip="{6}" style="{7}" unselectable="on"><button type="{0}"></button><div class="display-text">{5}</div><div class="syno-d-round-img"></div></em>').compile(),getMenuClass:function(){return""},getTemplateArgs:function(){var e=[this.type,"x-btn-"+this.scale+" x-btn-icon-"+this.scale+"-"+this.iconAlign,this.getMenuClass(),this.cls,this.id,Ext.util.Format.htmlEncode(this.displayText),SYNO.SDS.Drive.Utils.doubleHtmlEncode(this.tooltip)];return this.color?e.push("background-color:"+this.color+";"):e.push(""),this.updateAccountIcon(),e},updateAccountIcon:function(){this.rendered&&this.el&&this.el.dom&&this.color&&this.el.setStyle("background",this.color)}}),Ext.reg("synodrive_text_button",SYNO.SDS.Drive.TextButton),Ext.define("SYNO.SDS.Drive.SimpleButton",{extend:"Ext.Button",template:new Ext.Template('<em class="{2} syno-d-simple-button" unselectable="on"><button type="{0}"></button></em>').compile(),getMenuClass:function(){return""}}),Ext.reg("synodrive_simple_button",SYNO.SDS.Drive.SimpleButton),Ext.define("SYNO.SDS.Drive.DownloadClient.Window",{extend:"SYNO.SDS.Drive.ModalWindow",constructor:function(e){var t={width:680,height:509,cls:"syno-d-prompt-window syno-d-download-client-window",layout:"fit",header:!1,elements:"body",useStatusBar:!1,resizable:!1,closable:!1,draggable:!1,padding:void 0,items:this.getContent()};Ext.apply(t,e||{}),this.callParent([t])},getContent:function(){var e=SYNO.SDS.Drive._T;return{xtype:"container",layout:"vbox",layoutConfig:{align:"center"},items:[{xtype:"spacer",height:20},{xtype:"container",cls:"syno-d-download-client-image"},{xtype:"spacer",height:20},{xtype:"syno_displayfield",cls:"syno-d-prompt-window-title",value:e("common","prompt_tip")},{xtype:"spacer",height:12},{xtype:"syno_displayfield",cls:"syno-d-prompt-window-desc",value:e("common","prompt_desc")},{xtype:"spacer",flex:1},{xtype:"container",layout:"hbox",layougConfig:{pack:"center"},items:[{xtype:"syno_button",width:200,cls:"syno-d-prompt-window-btn",text:e("common","for_desktop"),scope:this,handler:this.onPCClientClick},{xtype:"spacer",width:16},{xtype:"syno_button",width:200,cls:"syno-d-prompt-window-btn",text:e("common","mobile_app"),scope:this,handler:this.onMobileAppClick}]},{xtype:"spacer",height:36}],listeners:{scope:this,afterrender:{single:!0,fn:this.onAfterRender},close:this.onWinClose}}},onAfterRender:function(){this.closeBtn=new SYNO.ux.Panel({renderTo:this.el,floating:!0,shadow:!1,items:{xtype:"box",autoEl:{tag:"img",src:SYNO.SDS.Drive.FileType.getDefaultIcon()},cls:"syno-d-prompt-window-close"}}),this.mon(this.closeBtn.el,"click",this.onCloseBtnClick,this),this.closeBtn.el.alignTo(this.el,"tr-tr",[14,-14]),this.addManagedComponent(this.closeBtn)},onCloseBtnClick:function(){this.close()},getOS:function(){return Ext.isMac?"Mac":Ext.isWindows?"Windows":Ext.isLinux?"Linux":"default"},onPCClientClick:function(){SYNO.SDS.CSTN.WebAPI.getClientLink.call(this,this.getOS(),window.navigator.platform,"drive",function(e,t,i,n){var o=SYNO.SDS.Drive._T("warning","err_get_download_link_fail");e?SYNO.SDS.Utils.IFrame.request(t.download_link,function(e,t,i,n){"timeout"===e||Ext.isGecko&&!Ext.isObject(n)||this.getMsgBox().alert("",o)},this,null,null,!0):this.getMsgBox().alert("",o)},this)},onMobileAppClick:function(){new SYNO.SDS.Drive.DownloadClient.QrcodeWindow({owner:this,module:this}).show()},afterShow:function(){this.callParent(arguments);var e=this.owner.el.query(".sds-window-mask")[0];Ext.fly(e).addClass("syno-d-prompt-window-mask")},onWinClose:function(){var e=this.owner.el.query(".sds-window-mask")[0];Ext.fly(e).removeClass("syno-d-prompt-window-mask")}}),Ext.define("SYNO.SDS.Drive.DownloadClient.Qrcode",{extend:"Ext.Container",xtype:"synodrive_qrcode",constructor:function(e){var t={xtype:"container",items:{xtype:"container",cls:"syno-d-download-qrcode-content",layout:"vbox",layoutConfig:{pack:"center",align:"center"},items:[{xtype:"container",cls:e.qrcodeCls},{xtype:"syno_displayfield",cls:"syno-d-download-qrcode-content-text",value:e.text}],listeners:{scope:this,afterrender:{single:!0,fn:function(t){this.mon(t.getEl(),"click",function(){window.open(e.storeURL,"_blank")},this)}}}}};this.callParent([t])}}),Ext.define("SYNO.SDS.Drive.DownloadClient.QrcodeWindow",{extend:"SYNO.SDS.Drive.ModalWindow",constructor:function(e){var t={width:600,height:421,cls:"syno-d-prompt-window syno-d-download-qrcode-window",layout:"fit",header:!1,elements:"body",useStatusBar:!1,resizable:!1,closable:!1,draggable:!1,padding:void 0,items:this.getContent()};Ext.apply(t,e||{}),this.callParent([t])},getContent:function(){var e=SYNO.SDS.Drive._T;return[{xtype:"container",layout:"vbox",layoutConfig:{align:"stretch"},items:[{xtype:"spacer",height:32},{xtype:"syno_displayfield",cls:"syno-d-download-qrcode-title",value:e("common","mobile_tip")},{xtype:"spacer",height:8},{xtype:"syno_displayfield",cls:"syno-d-download-qrcode-desc",value:e("common","mobile_desc")},{xtype:"container",flex:1,layout:"hbox",layoutConfig:{pack:"center",align:"middle"},items:[{xtype:"synodrive_qrcode",text:_T("common","ios"),qrcodeCls:"syno-d-download-qrcode-content-ios",storeURL:"https://itunes.apple.com/us/app/synology-drive/id1267275421?ls=1&mt=8"},{xtype:"spacer",width:60},{xtype:"synodrive_qrcode",text:_T("common","android"),qrcodeCls:"syno-d-download-qrcode-content-android",storeURL:"https://play.google.com/store/apps/details?id=com.synology.dsdrive"}]},{xtype:"spacer",height:30}],listeners:{scope:this,afterrender:{single:!0,fn:this.onAfterRender},close:this.onWinClose}}]},onAfterRender:function(){this.closeBtn=new SYNO.ux.Panel({renderTo:this.el,floating:!0,shadow:!1,items:{xtype:"box",autoEl:{tag:"img",src:SYNO.SDS.Drive.FileType.getDefaultIcon()},cls:"syno-d-prompt-window-close"}}),this.mon(this.closeBtn.el,"click",this.onCloseBtnClick,this),this.closeBtn.el.alignTo(this.el,"tr-tr",[14,-14]),this.addManagedComponent(this.closeBtn)},onCloseBtnClick:function(){this.close()},afterShow:function(){this.callParent(arguments);var e=this.owner.el.query(".sds-window-mask")[0],t=Ext.fly(e);t.addClass("syno-d-qrcode-mask"),t.setStyle("position","fixed")},onWinClose:function(){var e=this.owner.el.query(".sds-window-mask")[0];Ext.fly(e).removeClass("syno-d-qrcode-mask")}}),Ext.define("SYNO.SDS.Drive.DownloadClient.PromptToast",{extend:"SYNO.ux.Panel",WIDTH:340,constructor:function(e){this.progressIndicator=new Ext.Container({cls:"progress-indicator",width:24,margins:"0 12 0 10"});var t={cls:"syno-d-prompt-toast",width:this.WIDTH,floating:!0,shadow:!1,layout:"auto",items:[{border:!1,data:{},tpl:this.createContentTemplate()},{xtype:"container",layout:"hbox",height:34,layoutConfig:{align:"stretch"},items:[{xtype:"syno_checkbox",cls:"syno-d-prompt-checkbox",boxLabel:SYNO.SDS.Drive._T("common","prompt_dont_show_again"),flex:1,scope:this,checked:!1,handler:this.onCheck},this.progressIndicator]}],listeners:{scope:this,afterrender:{single:this,fn:this.onAfterRender}}};Ext.apply(t,e||{}),this.appWindow=e.appWindow,this.callParent([t])},onAfterRender:function(){var e=0,t=this.el.child("span.syno-d-prompt-tip"),i=t.getTextWidth();i>228&&(e=this.WIDTH+(i-228));var n=this.el.child("span.syno-d-prompt-link"),o=Ext.fly(n.dom.firstChild).getTextWidth();o>228&&(e=Math.max(e,this.WIDTH+(o-228))),e&&this.setWidth(e),n.on("click",this.onShowDownloadClient,this),this.closeBtn=new SYNO.ux.Panel({renderTo:this.el,floating:!0,shadow:!1,width:32,height:32,items:{xtype:"box",autoEl:{tag:"img",src:SYNO.SDS.Drive.FileType.getDefaultIcon()},cls:"syno-d-prompt-close"}}),this.mon(this.closeBtn.el,"click",this.onCloseBtnClick,this),this.closeBtn.el.alignTo(this.el,"tr-tr",[14,-14]),this.addManagedComponent(this.closeBtn)},onCheck:function(e,t){this.appWindow.appInstance.setUserSettings("hide_prompt_toast",t)},onCloseBtnClick:function(){this.hidePanel()},onShowDownloadClient:function(){new SYNO.SDS.Drive.DownloadClient.Window({owner:this.appWindow,module:this.appWindow}).show()},alignPanel:function(){this.el.alignTo(this.alignTargetEl,"bl-br",[-14,-20])},createContentTemplate:function(){var e=SYNO.SDS.Drive._T;return new Ext.XTemplate('<div class="syno-d-prompt-wrapper">','<div class="syno-d-prompt-icon"></div>','<span class="syno-d-prompt-tip">'+e("common","prompt_tip")+"</span><br>",'<span class="syno-d-prompt-link"><a>'+e("common","prompt_tip_link_new")+"</a></span>","</div>")},slideIn:function(){var e={opacity:{to:1,from:0},left:{by:-12-this.getWidth(),unit:"px"}},t=this.el;t.animate(e,.5,function(){var e=t.getRight(),i=t.getBottom();t.setStyle({top:"",left:"",right:Ext.lib.Dom.getViewWidth(!0)-e-1+"px",bottom:Ext.lib.Dom.getViewHeight(!0)-i-1+"px"})},"easeOut")},showPanel:function(){this.alignPanel(),this.slideIn()},hidePanel:function(e){if(!1===e)return void this.hide();var t={left:{by:12+this.getWidth(),unit:"px"},opacity:{from:1,to:0}};this&&this.el&&this.el.animate(t,.5,null,"easeOut")}}),Ext.define("SYNO.SDS.Drive.PermPanel",{extend:"Ext.Container",constructor:function(e){var t,i=e.mode||"request";t=SYNO.SDS.Drive.Utils.isSmallScreenSize()?this.fillModibleConfig(e,i):this.fillConfig(e,i),this.callParent([t]),this.mon(this,"activate",this.onActivate,this,{buffer:80})},fillConfig:function(e,t){var i={cls:"syno-d-perm-panel-background",xtype:"container",layout:{type:"vbox",align:"center",pack:"center"},items:[{xtype:"container",height:288,width:640,cls:"syno-d-perm-panel-container",defaults:{width:640},items:[this.title=new Ext.BoxComponent({height:42,cls:"syno-d-perm-panel-title",html:this.getTitle(t)}),{xtype:"container",layout:"border",height:220,cls:"syno-d-perm-panel-container-panel",defaults:{border:!1},items:[{region:"west",margins:{top:0,bottom:0,left:32,right:0},width:128,items:[this.iconBox=new Ext.BoxComponent({xtype:"box",ctCls:"syno-d-perm-panel-icon-ct",cls:"syno-d-perm-panel-icon"})]},{region:"center",xtype:"container",ctCls:"syno-d-perm-panel-center-ct",cls:"syno-d-perm-panel-center",layout:{type:"table",columns:1},defaults:{columnWidth:1},margins:{top:32,bottom:32,left:32,right:32},items:[this.permDesc=new Ext.BoxComponent({cls:"syno-d-perm-panel-desc",html:this.getDesc(t)}),{xtype:"container",cls:"syno-d-perm-panel-desc-ct",defaults:{width:"auto"},items:this.getButtons()}]}]}]}]};return Ext.apply(i,e),i},fillModibleConfig:function(e,t){var i={cls:"syno-d-perm-panel-background",xtype:"container",layout:{type:"vbox",align:"center",pack:"center"},items:[{xtype:"container",cls:"syno-d-perm-panel-container",autoHeight:!0,layout:{type:"vbox",align:"center",pack:"center"},items:[this.iconBox=new Ext.BoxComponent({cls:"syno-d-perm-panel-icon"}),this.title=new Ext.BoxComponent({cls:"syno-d-perm-panel-title",html:this.getTitle(t)}),this.permDesc=new Ext.BoxComponent({cls:"syno-d-perm-panel-desc",html:this.getDesc(t)})].concat(this.getButtons())}]};return Ext.apply(i,e),i},getButtons:function(){var e=SYNO.SDS.Drive._T,t=SYNO.SDS.Drive.Utils.isSmallScreenSize()?"0 0 16 0":0;return[this.accessBtn=new SYNO.ux.Button({cls:"syno-d-perm-panel-btn",xtype:"syno_button",btnStyle:"green",text:e("request","access"),margins:t,scope:this,handler:this.onRequestAccess}),this.switchBtn=new SYNO.ux.Button({cls:"syno-d-perm-panel-btn",xtype:"syno_button",btnStyle:"grey",text:e("request","switch_account"),margins:t,scope:this,handler:this.onLogout}),this.loginBtn=new SYNO.ux.Button({cls:"syno-d-perm-panel-btn",xtype:"syno_button",btnStyle:"green",text:_T("common","login"),margins:t,scope:this,handler:this.onLogin})]},onActivate:function(){var e=this.findAppWindow();e.onHidePromptToast&&e.onHidePromptToast(),this.doLayout(),this.onUpdatePosition()},getTitle:function(e,t){var i=SYNO.SDS.Drive._T;switch(e){case"SENT":return i("request","title");case"SERVICE_UNAVAILABLE":case"NON_EXIST":case"VIEW_OWNER_DISABLED":return t||i("request","not_exist_title");case"EXPIRED":return t||i("share","expired_title");case"NO_PERM":return i("request","no_perm_title");default:return i("request","title")}},getDesc:function(e,t){var i=SYNO.SDS.Drive._T,n=SYNO.SDS.Drive.Utils.isSmallScreenSize();switch(e){case"SENT":return n?i("request","sent").replace(/<br><br>/g,"&nbsp;"):i("request","sent");case"SERVICE_UNAVAILABLE":return t||i("error","service_unavailable");case"NON_EXIST":return t||i("error","item_not_exist");case"VIEW_OWNER_DISABLED":return t||i("error","view_user_disabled");case"EXPIRED":return t||i("share","expired_link_desc");default:return SYNO.SDS.Drive.Utils.isLogined()?i("request","desc")+(n?"&nbsp;":"<br><br>")+String.format(i("request","user"),'<span class="syno-d-perm-panel-account">'+_S("user")+"</span>"):i("request","no_perm")}},getMode:function(){return this.mode||"request"},getIconClasses:function(e){var t;switch(e){case"SENT":t="syno-d-perm-panel-icon-mail";break;case"SERVICE_UNAVAILABLE":case"NON_EXIST":case"VIEW_OWNER_DISABLED":t="syno-d-perm-panel-icon-no-exist";break;case"EXPIRED":t="syno-d-perm-panel-icon-expired-link";break;default:t="syno-d-perm-panel-icon-noperm"}return t},onUpdateByErrCode:function(e,t){switch(e){case 1002:this.onUpdate("NO_PERM",void 0,void 0,t);break;case 1003:case 1036:this.onUpdate("NON_EXIST");break;case 1038:this.onUpdate("EXPIRED");break;case 1039:this.onUpdate("VIEW_OWNER_DISABLED");break;default:this.onUpdate("SERVICE_UNAVAILABLE")}},onUpdate:function(e,t,i,n){var o=this.mode;switch(this.mode=e,this.iconBox.removeClass(this.getIconClasses(o)).addClass(this.getIconClasses(e)),this.title.el?this.title.update(this.getTitle(e,t)):this.mon(this.title,"afterrender",function(){this.title.update(this.getTitle(e,t))},this,{single:!0}),this.permDesc.el?this.permDesc.update(this.getDesc(e,i)):this.mon(this.permDesc,"afterrender",function(){this.permDesc.update(this.getDesc(e,i))},this,{single:!0}),e){case"SERVICE_UNAVAILABLE":this.accessBtn.hide(),this.switchBtn.hide(),SYNO.SDS.Drive.Utils.isLogined()?this.loginBtn.hide():this.loginBtn.show();break;case"NON_EXIST":case"SENT":case"VIEW_OWNER_DISABLED":case"EXPIRED":this.accessBtn.hide(),this.switchBtn.hide(),this.loginBtn.hide();break;default:if(SYNO.SDS.Drive.Utils.isLogined()){var s=!1;s=n?"disallow"!==n.sharing_level:!window.getDriveAllowToShare||!1!==window.getDriveAllowToShare(),SYNO.SDS.Drive.Utils.isAppAuthorized()&&s?this.accessBtn.show():this.accessBtn.hide(),this.switchBtn.show(),this.loginBtn.hide()}else this.accessBtn.hide(),this.switchBtn.hide(),this.loginBtn.show()}this.onUpdatePosition()},onUpdatePosition:function(){if(SYNO.SDS.Drive.Utils.isSmallScreenSize()){var e=this.items.items[0],t=0,i=e.items.items;i.forEach(function(e,n){e.hidden||(n===i.length-1?t+=e.getHeight():t+=e.getOuterSize().height)});t+=50,e.getEl().setStyle("top","calc(((100% - "+t+"px) * 0.4) + 50px)")}},onRequestAccess:function(){var e=this.findAppWindow();e.setStatusBusy();var t;if(SYNO.SDS.Drive.WindowHelper.isPublicShare())t={permanent_link:window.getDriveLink()};else{var i=SYNO.SDS.Drive.Utils.getHashParam()||{};if(!i.file_id)return;t={file_id:i.file_id}}e.getAction().requestAccess(t,function(t,i){if(e.clearStatusBusy(),!t)return void e.getMsgBox().alert("",SYNO.SDS.Drive.Utils.getErrorStr(i));this.onUpdate("SENT")},this)},onLogin:function(){SYNO.SDS.Utils.Logout.redirect(!1)},onLogout:function(){SYNO.SDS.Utils.Logout.action()}}),Ext.define("SYNO.SDS.Drive.Upload.Store.Label",{extend:"SYNO.SDS.Drive.ViewStore.Base",getAPIInfo:function(){return SYNO.SDS.Drive.WebAPIDesc.list_labels},getReader:function(){return new Ext.data.JsonReader({root:"items",id:"label_id"},[{name:"label_id"},{name:"name"},{name:"color",convert:function(e,t){return e.substr(1)}},{name:"position"},{name:"category",defaultValue:"label"},{name:"type",defaultValue:"personal_label"}])},onBeforeNodeLoad:function(e,t){return this.appWindow.getEventMgr().fireEvent("storebeforeload",e,t)}}),Ext.define("SYNO.SDS.Drive.Upload.Store.ShareFolder",{extend:"SYNO.SDS.Drive.ViewStore.Base",getAPIInfo:function(){return{api:"SYNO.Core.File",method:"list",version:2}},getReader:function(){return new Ext.data.JsonReader({root:"files",id:"path"},[{name:"file_id",mapping:"path"},{name:"name"},{name:"size",mapping:"additional.size"},{name:"mtime",mapping:"additional.time.mtime"},{name:"atime",mapping:"additional.time.atime"},{name:"real_path",mapping:"additional.real_path"},{name:"owner_name",mapping:"additional.owner.user"},{name:"is_recycle_bin",mapping:"additional.is_recycle_bin"},{name:"is_snapshot"},{name:"ntype",convert:function(e,t){return t.isdir?"dir":SYNO.SDS.Drive.Utils.getExt(t.name)}},{name:"type",convert:function(e,t){return t.isdir?"dir":"file"}},{name:"thumbnail",convert:function(e,t){var i=Ext.apply({params:{path:t.path,size:"medium"}},SYNO.SDS.Drive.WebAPIDesc.get_dsm_thumbnail);return SYNO.API.GetBaseURL(i)}}])},parseSortInfo:function(e){if(e&&e.params&&e.params.sort_direction&&(e.params.sort_direction=e.params.sort_direction.toLowerCase()),e&&e.params&&e.params.sort_by)switch(e.params.sort_by){case"owner_name":e.params.sort_by="user"}},getBaseParams:function(){return{needrw:!0,status_filter:"valid",superuser:!1,support_enum_cold_storage:!0,additional:["real_path","size","owner","time","type","mount_point_type","is_recycle_bin"]}},getLoadParam:function(e){var t=this.appWindow.getNavigation(),i={};return t.isRootPath()?i={folder_path:"/"}:(i={folder_path:t.getLastPathId()},this.pattern&&(i.pattern=this.pattern)),i},onLoadStore:function(e,t){e.each(function(t){(t.data.is_recycle_bin||t.data.is_snapshot)&&(e.remove(t),e.totalLength--)}),this.local_filter&&e.filter(this.local_filter),this.callParent(arguments)},onExceptionStore:function(e,t,i,n,o,s){var r=SYNO.API.getErrorString(o);o&&117===o.code&&(r=SYNO.API.getErrorString(5613)),SYNO.SDS.Drive.Upload.Store.ShareFolder.superclass.onExceptionStore.call(this,e,t,i,n,r,s)},setPattern:function(e){this.pattern=e},setLocalFilter:function(e){this.local_filter=e}}),Ext.define("SYNO.SDS.Drive.Upload.Store.Tag",{extend:"SYNO.SDS.Drive.ViewStore.Node",getAPIInfo:function(){
return SYNO.SDS.Drive.WebAPIDesc.list_label_files},getBaseParams:function(){var e={offset:0,limit:this.pageSize};return this.getFilter()&&(e=Ext.apply({filter:this.getFilter()})),e},getLoadParam:function(e){var t=this.appWindow.getNavigation(),i=t.getPath(),n={};return SYNO.SDS.Drive.Utils.apply(n,{label_id:i[1].id}),n}}),Ext.define("SYNO.SDS.Drive.Comp.SelectionModel",{getSelections:function(){return[]},selectRecords:function(){},selectRow:function(){},clearSelections:function(){}}),Ext.define("SYNO.SDS.Drive.Comp.PanelEventHandler",{publicEventMap:{viewstorechange:"onViewStoreChange",storeloaddone:"onLoadStore",storebeforeload:"onBeforeNodeLoad",storeloadfail:"onExceptionStore",enableviewmask:"onEnableMask",disableviewmask:"onDisableMask",pathchange:"onPathChange"},onRegEvent:function(){var e=this.appWin,t=e.getEventMgr();this.blRegEvent||(Ext.iterate(this.publicEventMap,function(e){var i=this.publicEventMap[e];this.mon(t,e,this[i],this)},this),e.hasClipboard&&this.mon(SYNO.SDS.Drive.Mgr.FileClipboard,{scope:this,set:this.updateCutIcon,beforeset:this.removeCutIcons,beforeclean:this.removeCutIcons}),this.mon(e.el,"mousedown",this.onHandleMouseDown,this),this.mon(e.el,"click",this.onHandleMouseClick,this,{buffer:50}),this.blRegEvent=!0,this.mon(this,"beforedestroy",this.unRegEvent,this))},unRegEvent:function(){var e=this.appWin,t=e.getEventMgr(),i=this.appWin.getViewModeMgr().getViewMode();this.blRegEvent&&"empty"!==i&&(Ext.iterate(this.publicEventMap,function(e){var i=this.publicEventMap[e];this.mun(t,e,this[i],this)},this),e.hasClipboard&&(this.mun(SYNO.SDS.Drive.Mgr.FileClipboard,"set",this.updateCutIcon,this),this.mun(SYNO.SDS.Drive.Mgr.FileClipboard,"beforeset",this.removeCutIcons,this),this.mun(SYNO.SDS.Drive.Mgr.FileClipboard,"beforeclean",this.removeCutIcons,this)),this.mun(e.el,"mousedown",this.onHandleMouseDown,this),this.mun(e.el,"click",this.onHandleMouseClick,this),this.blRegEvent=!1)},onEnableMask:function(){this.loadMask.enable(),this.getView().trackResetOnLoad=!0},onDisableMask:function(){this.loadMask.disable(),this.getView().trackResetOnLoad=!1},onLoadStore:function(e,t){var i=this.findAppWindow(),n=i.getEventMgr();this.loadMask.hide(),this.unmaskView(),this.onFocusRow.defer(80,this),this.updateCutIcon();var o=i.getNavigation();if(SYNO.SDS.Drive.Utils.isEnterFromSharing()&&this.onLaunchNode(),t&&0===t.length){if("search"===o.getCategory()){var s=SYNO.SDS.Drive._T("empty","search");this.findAppWindow().getDrivePanel().setEmptyText(s)}e.removeAll()}if(n.fireEvent("viewpanelload",t,this.itemId),!SYNO.SDS.Drive.WindowHelper.isPublicShare()&&(o.isRootPath()&&"node"===o.getLastPath().id||!o.isRootPath())&&o.getLastPath()&&!o.getLastPath().skip_load&&(!o.getLastPath().perm||!o.getLastPath().display_path)){var r=o.getLastPath().id,a="node"===r?"/mydrive":SYNO.SDS.Drive.Utils.getPathId(r);if("/mydrive"===a)return void this.findAppWindow().getAction().getMyDrive(this.onGetNodeDone,this);i.getWebAPI().getNode({params:{path:a},scope:this,callback:this.onGetNodeDone})}},onGetNodeDone:function(e,t,i){if(e){var n=this.findAppWindow();if(!n.isDestroyed){var o=n.getNavigation();if(i&&"/mydrive"===i.path){if("node"!==o.getLastPath().id)return}else if(t.file_id!==o.getLastPath().id)return;o.applyLastPath({perm:t.capabilities,display_path:t.display_path}),n.getDrivePanel().onCheckToolbar()}}},onBeforeNodeLoad:function(e,t){this.findAppWindow().getEventMgr().fireEvent("beforeviewpanelload",this.itemId);var i=this.findAppWindow().getNavigation(),n=i.getCategory();if(this.isViewMasked()&&this.unmaskView(),this.loadMask.show(),"recent"!==n&&"search"!==n&&"label"!==n&&"shared_label"!==n&&"file_request"!==n){if(!e.sorting){var o=this.getSortInfo(i.getCategoryText());o&&(t.params.sort_by=o.field,t.params.sort_direction=o.direction)}"recycle"===n?t.params.sort_by||(t.params.sort_by="recycled_time",t.params.sort_direction="DESC"):t.params.sort_by&&"recycled_time"!==t.params.sort_by||(t.params.sort_by="name",t.params.sort_direction="ASC"),this.updateSortState(e,t.params)}var s;s="search"===n?"":SYNO.SDS.Drive._T("common","no_data"),this.findAppWindow().getDrivePanel().setEmptyText(s)},onExceptionStore:function(e){this.loadMask.hide(),this.findAppWindow().getEventMgr().fireEvent("viewpanelfail",e),this.isViewMasked()&&this.unmaskView(),this.maskView(SYNO.SDS.Drive.Utils.getErrorStr(e))},getActiveStore:function(){return this.activeStore},switchStore:function(e,t){var i=!1;return this.activeStore!==t&&(i=!0),this.activeStore=t,i},onShowContextMenu:function(e){e.preventDefault();var t=this.findAppWindow().getMenu();t.setType("menu_context"),t.setOrigin(e.target),t.showAt(e.getXY())},onDoubleClick:function(e,t,i,n){this.findAppWindow().getAction().openNode()},getSortInfo:function(e){if(!SYNO.SDS.Drive.WindowHelper.isPublicShare()){var t=this.findAppWindow();if(Ext.getClassByName("SYNO.SDS.Drive.MainWindow")&&t instanceof SYNO.SDS.Drive.MainWindow){var i="recycle"===e?"gridsortstates_recycle":"gridsortstates";return t.appInstance.getUserSettings(i)||{}}}},isViewMasked:function(){return this.getEl().isMasked()},maskView:function(e,t){this.getEl().mask(e,t)},unmaskView:function(){this.getEl().unmask()},setEmptyText:function(e){this.getView().emptyText=e},updateCutIcon:function(e,t){"recycle"!==this.findAppWindow().getNavigation().getCategory()&&this.findAppWindow().hasClipboard&&(t=t||SYNO.SDS.Drive.Mgr.FileClipboard.get())&&"cut"===t.action&&Ext.each(t.recs,function(e){this.addRemoveCutClass(e,!0)},this)},removeCutIcons:function(){if("recycle"!==this.findAppWindow().getNavigation().getCategory()&&this.findAppWindow().hasClipboard){var e=SYNO.SDS.Drive.Mgr.FileClipboard.get();Ext.each(e.recs,function(e){this.addRemoveCutClass(e,!1)},this)}},getMouseElement:function(e){if(!this.findAppWindow().maskCnt&&!this.isViewMasked()&&this.getActiveStore().getTotalCount()){var t=e.getTarget();if(t)return Ext.fly(t)}},onHandleMouseDown:function(e){if(this.blClickScrollBar=!1,e.within(this.el)){var t=this.getMouseElement(e);t&&(this.blClickScrollBar=!!t.is(":any(div.vscrollerbar|div.hscrollerbar)"))}},onHandleMouseClick:function(e){if(!this.blClickScrollBar){var t=this.getMouseElement(e);if(t&&!t.findParent(":any(span.action-text|td.x-grid3-hd|div.x-grid3-row|td.x-grid3-cell|.syno-ux-textfilter|.x-form-trigger|button|input|img|a|div.x-combo-list-item|div.x-menu|td.x-date-active|div.vscrollerbar|div.hscrollerbar|em.syno-d-round-button|div.thumbnail-entry|div.file-wrap|div.snippet-entry)",15)){this.getSelectionModel().clearSelections()}}},onPathChange:function(e,t,i,n){n||this.onFocusRow()},onFocusRow:function(){var e=this.findAppWindow();if(!e.isDestroyed){var t,i=e.getNavigation();if(t=i.getSelection()){var n=this.getActiveStore();if(n.loading)return;var o=n.indexOfId(t);-1!==o&&(this.focusItem(o),i.setSelection(void 0))}}},onLaunchNode:function(){var e=this.findAppWindow();if(!e.isDestroyed){var t;if(t=e.getNavigation().getSelection()){var i=this.getActiveStore();if(i.loading)return;var n=i.indexOfId(t),o=i.getAt(n);o&&!1!==e.getEventMgr().fireEvent("beforelaunchnode",o)&&e.getAction().openUniversalViewer(i.getAt(n))}}},getView:function(){},addRemoveCutClass:function(){},onViewStoreChange:function(){},onViewModeChage:function(){},updateSortState:function(){}}),Ext.define("SYNO.SDS.Drive.Comp.ScrollEventHandler",{INFINITE_LOAD_THRESHOLD:200,onAfterBindStore:function(e){this.mun(this,"flexcroll",this.onScroll,this,{buffer:100}),this.removeLoading(!1),e&&e.infinite&&(this.mon(this,"flexcroll",this.onScroll,this,{buffer:100}),this.addLoading(),this.onCheckLoadMore(),this.mon(e,"load",this.addLoading,this),this.mon(this,"deactivate",this.removeLoading,this,{single:!0}))},onScroll:function(){this.onCheckLoadMore()},onCheckLoadMore:function(){if(this.isVisible()){var e=this.getStore();if(e&&e.infinite){var t,i;if(this instanceof SYNO.SDS.Drive.Comp.GridPanel){if(!this.view||!this.view.scroller||!this.view.scroller.dom)return;i=this.view.scroller.dom,t=i.fleXdata}else if(this instanceof SYNO.SDS.Drive.Comp.DataView){if(!this.el||!this.el.dom)return;i=this.el.dom}if(i&&(t=i.fleXdata,i.fleXcroll,t)){var n=SYNO.SDS.Drive.GetWindow().getViewModeMgr().getViewMode();if("tile"===n&&t.getContentWidth()-(this.getWidth()+t.scrollPosition[0][0])<=this.INFINITE_LOAD_THRESHOLD||"tile"!==n&&t.getContentHeight()-(this.getHeight()+t.scrollPosition[1][0])<=this.INFINITE_LOAD_THRESHOLD){if(!e.isloadMore())return void(e.loadingMore||this.removeLoading(!1));var o=this;e.loadMore(function(){this.view&&(this.view.trackResetOnLoad=!1)},function(){this.updateFleXcroll(),this.view&&(this.view.syncFocusEl(0),this.view.trackResetOnLoad=!0)},o)}}}}},addLoading:function(){var e=this.getStore();e&&e.infinite&&e.isloadMore()&&this.rendered&&this.el&&this.el.dom&&(this.el.hasClass("syno-d-search-loading")||(this.addClass("syno-d-search-loading"),this.updateFleXcroll()))},removeLoading:function(e){if(this.rendered&&this.el&&this.el.dom&&(this.el.hasClass("syno-d-search-loading")&&(this.removeClass("syno-d-search-loading"),this.updateFleXcroll()),!1!==e)){var t=this.getStore();if(!t||!t.infinite)return;this.mun(t,"load",this.addLoading,this)}}}),Ext.define("SYNO.SDS.Drive.Comp.KeyEventHandler",{delayKeyTime:50,delayClearTime:720,initKeyEvent:function(e){var t=this;t.search_key="",t.mon(t,"afterlayout",function(){this.mon(this.el,"keyup",this.onDetectKeyUp,this),this.mon(this.el,"keydown",this.onDetectKeyDown,this),this.mon(this.el,"keypress",this.onDetectKeyPress,this)},t,{single:!0}),t.mon(t,"beforedestroy",t.unRegKeyEvent,t)},runKeySearchTask:function(){var e=this;e.runTask("searchKeyTask",e.searchKey,Ext.isNumber(e.delayKeyTime)?e.delayKeyTime:50)},runClearKeywordTask:function(){var e=this;e.runTask("clearKeyTask",e.clearKeyword,Ext.isNumber(e.delayClearTime)?e.delayClearTime:720)},clearKeyword:function(){this.search_key=""},setKeyword:function(e){this.search_key=e},searchKey:function(){var e=this,t=e.search_key;!1===e.searchKeyAndFocus(t,t.length>1)&&e.setKeyword(t.charAt(t.length-1))},searchKeyAndFocus:function(e,t){var i=this.getStore(),n=this.getSelectionModel(),o=n.getSelected(),s=0,r=-1;return s=t?i.indexOf(o):0,s>i.getCount()-1&&(s=0),!((r=i.find("name",e,s,!1,!1))<0&&(0!==s&&(r=i.find("name",e,0,!1,!1)),r<0))&&(this.focusItem(r),!0)},hasKeyModifiers:function(e){for(var t,i=["shift","ctrl","alt"],n=0,o=i.length;n<o;++n)if(t=i[n],e[t+"Key"])return!0;return!1},onDetectKeyUp:function(e){this.blPressEnter&&(this.blPressEnter=!1)},onDetectKeyDown:function(e){if(e.getKey()===Ext.EventObject.ENTER&&!this.blPressEnter)return this.blPressEnter=!0,this.clearKeyword(),void this.findAppWindow().getAction().openNode()},onDetectKeyPress:function(e){var t=this;if(!t.isVisible()||t.hasKeyModifiers(e))return void t.clearKeyword();t.search_key=Ext.isString(t.search_key)?t.search_key:"",t.search_key+=String.fromCharCode(e.getCharCode()),t.runKeySearchTask(),t.runClearKeywordTask()},unRegKeyEvent:function(){var e=this,t=["searchKeyTask","clearKeyTask"];Ext.each(t,function(e,t,i){this.removeDelayedTask(e)},e)}}),Ext.define("SYNO.SDS.Drive.Comp.DragDropHandler",{MAX_UPLOAD_SIZE:4294963200,initDragDrop:function(){this.enterCount=0,this.mask=this.createMask(),this.mon(this.getMaskTargetEl(),"dragover",this.onDragOverHandler,this),this.mon(this.getMaskTargetEl(),"drop",this.onDropHandler,this),this.mon(Ext.getDoc(),"dragover",this.onDragOverHandler,this),this.mon(Ext.getDoc(),"dragenter",this.onDragEnter,this),this.mon(Ext.getDoc(),"dragleave",this.onDragLeave,this)},isDragFile:function(e){try{if(Ext.isWebKit){return e.dataTransfer.types&&-1!==e.dataTransfer.types.indexOf("Files")}if(Ext.isGecko)return e.dataTransfer.types.contains&&e.dataTransfer.types.contains("application/x-moz-file")||0<=e.dataTransfer.types.indexOf("application/x-moz-file");if(Ext.isIE10||Ext.isModernIE){var t=!1;return t=Array.isArray(e.dataTransfer.types)?e.dataTransfer.types&&-1!==e.dataTransfer.types.indexOf("Files"):e.dataTransfer.types&&e.dataTransfer.types.contains("Files"),e.dataTransfer.files&&t}}catch(e){}return!1},isAllowDrop:function(e){if(!this.isDragFile(e.browserEvent))return!1;if(!e.within(this.getMaskTargetEl())||!e.browserEvent.dataTransfer)return!1;var t=this.findAppWindow();if(t.allowDrop)return!0;var i=t.getNavigation(),n=i.getLastPath();return!!("node"===i.getCategory()||"recycle"!==i.getCategory()&&n&&n.perm&&n.perm.can_write)},onDragOverHandler:function(e){e.stopPropagation(),e.preventDefault(),this.isAllowDrop(e)?(e.browserEvent.dataTransfer.dropEffect="copy",this.onMask()):(e.browserEvent.dataTransfer.dropEffect="none",this.unMask())},onDropHandler:function(e){if(e.stopPropagation(),e.preventDefault(),!this.isAllowDrop(e))return e.browserEvent.dataTransfer.dropEffect="none",void this.unMask();var t=e.browserEvent.dataTransfer.files,i=e.browserEvent.dataTransfer.items;this.enterCount=0,this.onFileChange(t,i),this.unMask()},onDragEnter:function(e){this.enterCount++},onDragLeave:function(e){0===--this.enterCount&&this.unMask()},createMask:function(){var e='<div class="drag-drop-hint-wrap"><div class="drag-drop-top-hint"></div><div class="drag-drop-bottom-hint">'+SYNO.SDS.Drive._T("upload","drop_here")+"</div></div>",t=this.getMaskTargetEl().createChild({cls:"drag-drop-mask",tag:"div",html:e});return this.maskCls&&t.addClass(this.maskCls),t.setVisibilityMode(Ext.Element.DISPLAY),t.hide(),t},getMaskTargetEl:function(){return this.el},onMask:function(){this.mask.show()},unMask:function(){this.mask.hide()},onFileChange:function(e,t){var i=this.findAppWindow(),n=i.getNavigation();SYNO.SDS.Drive.Utils.checkFileCanUpload(e,t).then(function(){var o=SYNO.SDS.Drive.Utils.getPathId(n.getLastPathId());SYNO.SDS.Drive.TaskFactory.addUploadTasks(i,o,e,t)}).catch(function(e){SYNO.SDS.Drive.Utils.showAlertMsg(i,e)})}}),Ext.define("SYNO.SDS.Drive.Comp.PagingToolBar",{getPagingToolBar:function(e){if(this.paging)return this.paging;var t=e?e.pageSize:1e3;return this.paging=new SYNO.ux.PagingToolbar({store:e,pageSize:t,displayInfo:!0,emptyMsg:"",showRefreshBtn:!0,updateInfo:function(){var e=this.store,t=e.getCount(),i=e.getTotalCount();if(e.snapshot&&(i-=e.snapshot.getCount()-e.data.getCount()),this.setButtonsVisible(i>t),this.displayItem){var n=0===t?this.emptyMsg:String.format(this.displayMsg,this.cursor+1,this.cursor+t,i);this.displayItem.setText(n)}}}),this.paging},updatePaginToolBar:function(e){e.infinite?(this.paging.hide(),this.paging.bindStore(null)):(this.paging.show(),this.paging.bindStore(e))}}),Ext.define("SYNO.SDS.Drive.FrameworkImpl",{singleton:!0,evalName:function(e){return e.split(".").reduce(function(e,t){return e[t]},window)},applyMixin:function(){function e(e,t){function i(e){return-1!==["override","self","superclass","supr"].indexOf(e)}var o=n(e),s=o.$isClass?o.prototype:Object.getPrototypeOf(o);Ext.iterate(s,function(e,n){i(e)||(t[e]?t[e].prototype=n:t[e]=n)},this)}var t,i=SYNO.SDS.Drive.FrameworkImpl,n=i.evalName;t=this.$isClass?this.prototype:this,t.mixins&&t.mixins.forEach(function(i){e.call(this,i,t)},this)}}),Ext.define("SYNO.SDS.Drive.Framework",{singleton:!0,postDefine:function(){SYNO.SDS.Drive.FrameworkImpl.applyMixin.apply(this,arguments)}}),Ext.define("SYNO.SDS.Drive.Comp.GridPanel",{extend:"SYNO.ux.GridPanel",mixins:["SYNO.SDS.Drive.Comp.SelectionModel","SYNO.SDS.Drive.Comp.PagingToolBar","SYNO.SDS.Drive.Comp.PanelEventHandler","SYNO.SDS.Drive.Comp.ScrollEventHandler","SYNO.SDS.Drive.Comp.DragDropHandler","SYNO.SDS.Drive.Comp.KeyEventHandler"],cm_lists:{full:["name","mtime","owner_name","size","labels"],nameonly:["name"],nosize:["name","mtime","owner_name"],nolabel:["name","mtime","owner_name","size","display_path"],recentAtime:["name","atime","owner_name","size","labels"],recentMtime:["name","mtime","owner_name","size","labels"],search:["name","mtime","owner_name","size","labels","display_path"],backup:["name","mtime","labels"],shared:["name","mtime","owner_name","size","permissions","labels"],recycle:["name","recycled_time","mtime","owner_name","size","display_path"],file_request:["title","destination_folder","created_time","expire_time","file_request_status"]},cm_mapping:{recycle:"recycle",recent:"recentAtime",backup:"nameonly",team_folder:"nameonly",share_folder:"nosize",search:"search",sharing_to_others:"shared",file_request:"file_request"},constructor:function(e){this.module=e.module,this.owner=e.owner,this.mode=e.mode||"grid",this.appWin=this.findAppWindow();var t="syno-d-mgr-grid";"detail"===this.mode?t+=" syno-d-mgr-detail":"compact"===this.mode&&(t+=" syno-d-mgr-compact");var i={cls:t,colModel:this.getGridCM(),stateful:!0,stateEvents:["columnresize"],selModel:this.getSelModel(),minColumnWidth:50,store:this.getActiveStore(),enableColumnMove:!1,enableColumnResize:!0,loadMask:!0,monitorWindowResize:!0,columnLines:!1,stripeRows:!1,hideMode:"offsets",autoExpandColumn:"name",autoExpandMin:180,view:this.getGridView(),bbar:this.getPagingToolBar(this.getActiveStore()),forceFitWidth:700};Ext.apply(i,e||{}),this.callParent([i]),this.initKeyEvent()},updateSortState:function(e,t){var i;switch(t.sort_by){case"modified_time":i="mtime";break;case"owner":case"user":i="owner_name";break;case"due_date":i="expire_time";break;default:i=t.sort_by}var n={field:i,direction:t.sort_direction||"DESC"};e.sortInfo=n,this.getView().updateSortIcon(this.getGridCM().findColumnIndex(n.field),e.sortInfo.direction.toUpperCase())},switchCM:function(e){var t,i=this.getGridCM(),n=i.columns,o=!1;if(SYNO.SDS.Drive.WindowHelper.isPublicShare())t=SYNO.SDS.Drive.Utils.isAppAuthorized()?["name","mtime","owner_name"]:["name","mtime"];else{var s=this.getColumnMapping(),r=this.findAppWindow().getNavigation();if(!r.isRootPath())switch(e){case"team_folder":s="full";break;case"share_folder":s="nolabel";break;case"backup":s="backup";break;case"recent":s="recentMtime"}t=this.cm_lists[s]}return this.headerBtn&&this.enableHdMenu&&this.headerBtn.setVisible(1<t.length),Ext.each(n,function(i){var n=!1,s=!0;-1===t.indexOf(i.dataIndex)&&(n=!0,s=!1),"search"===e&&"labels"===i.dataIndex&&(n=!0),"name"===i.dataIndex&&(s=!1),n!==i.hidden&&(o=!0,i.hidden=n),i.hideable=s,["labels","display_path","destination_folder"].includes(i.dataIndex)||("recycle"===e&&"mtime"===i.dataIndex&&(i.hidden=!0),"recent"===e&&r.isRootPath()?!1!==i.sortable&&(i.sortable=!1,o=!0):!0!==i.sortable&&(i.sortable=!0,o=!0))},this),o&&this.updateColumn(),o},getColumnMapping:function(){var e=this.findAppWindow().getNavigation().getCategory();return this.cm_mapping[e]||"full"},updateColumn:function(){if(this.rendered&&!1!==this.applyColumnState&&this.isVisible()){var e=this.getGridCM(),t=e.columns,i=this.getColumnState(),n=0;Ext.each(t,function(e,t){e.hidden||(i&&t<i.length?e.width=i[t].width:"display_path"===e.dataIndex?e.width=250:"name"===e.dataIndex||"labels"===e.dataIndex?e.width=200:"permissions"===e.dataIndex?e.width=230:e.width=100,n+=e.width)});var o=this.getView(),s=o.cm.getTotalWidth(!1);n>s&&Ext.each(t,function(e,t){e.hidden||("display_path"===e.dataIndex?e.width=250:"name"===e.dataIndex||"labels"===e.dataIndex?e.width=200:e.width=100)}),e.setConfig(t,!0),e.totalWidth=null,this.updateColumnWidth(!1),i&&!1!==this.applyColumnState&&this.saveState()}},updateForceFit:function(){var e=this.getView(),t=this.getGridEl().getWidth();e.forceFit=this.forceFitWidth<t},updateColumnWidth:function(e){var t=this.getView();this.updateForceFit(),t.forceFit?t.fitColumns(e):t.autoExpand(e)},getSelectedElements:function(){return this.getSelections().reduce(function(e,t){var i=this.store.indexOfId(t.id);return e.push(this.view.getRow(i)),e}.bind(this),[])},getSelections:function(){return this.getSelectionModel().getSelections()},selectRecords:function(e,t){this.getSelectionModel().selectRecords(e,t)},getActiveAjaxId:function(){return this.getActiveStore().proxy.activeRequest.read},onViewStoreChange:function(e,t,i){var n=!1,o=!1;n=this.switchCM(e),o=this.switchStore(e,i),(n||o)&&(this.reconfigure(this.getActiveStore(),this.getGridCM()),this.updatePaginToolBar(this.getActiveStore()))},onShowPanel:function(){var e=this.findAppWindow().getNavigation();this.switchCM(e.getCategory()),this.reconfigure(this.getActiveStore(),this.getGridCM()),this.updatePaginToolBar(this.getActiveStore())},onActivate:function(){this.onRegEvent(),this.updateColumn(),this.updateCutIcon(),this.getActiveStore().getCount()&&this.removeClass("syno-d-mgr-empty-grid"),this.updateScrollbar(this.getView().scroller.dom),this.body.focus(100)},onDeActivate:function(){this.unRegEvent()},getTitleColumn:function(e){return new Ext.grid.Column(Ext.apply({width:150,header:SYNO.SDS.Drive._T("file_request","name_header"),dataIndex:"title",renderer:function(e,t,i,n,o,s){var r=Ext.util.Format.htmlEncode(e);return t.attr='ext:qtip="'+Ext.util.Format.htmlEncode(r)+'"',r}},e||{}))},getDestFolderColumn:function(e){return new Ext.grid.Column(Ext.apply({width:250,sortable:!0,header:SYNO.SDS.Drive._T("file_request","destination_folder_header"),dataIndex:"destination_folder",renderer:function(e,t,i,n,o,s){var r=SYNO.SDS.Drive.Utils.parseDisplayPath(i.data.display_path);if("-"===r)return SYNO.SDS.Drive._T("file_request","cannot_access_folder");var a=Ext.util.Format.htmlEncode(r);return t.css="syno-d-location-colume",t.attr='ext:qtip="'+Ext.util.Format.htmlEncode(a)+'"',a}},e||{}))},getExpireTimeColumn:function(e){return new Ext.grid.Column(Ext.apply({width:150,header:SYNO.SDS.Drive._T("file_request","expire_on_header"),dataIndex:"expire_time",renderer:function(e,t,i,n,o,s){var r=i.data.due_date;return 0===r?"-":i.data.is_expired?SYNO.SDS.Drive.Utils.getFormatDateTime(new Date(1e3*r))+" ("+SYNO.SDS.Drive._T("common","expired")+")":SYNO.SDS.Drive.Utils.getFormatDateTime(new Date(1e3*r))}},e||{}))},getStatusColumn:function(e){return new Ext.grid.Column(Ext.apply({width:150,header:SYNO.SDS.Drive._T("file_request","status_header"),dataIndex:"file_request_status",renderer:function(e,t,i,n,o,s){var r,a,l;return"error"===e||"readonly"===e?(r=SYNO.SDS.Drive._T("error","file_request_error_status"),a="#e85454"):i.data.is_expired||"inactive"===e?(r=SYNO.SDS.Drive._T("common","inactive"),a="#aeaeb2"):(r=SYNO.SDS.Drive._T("common","active"),a="#2bae2f"),r=Ext.util.Format.htmlEncode(r),l=Ext.util.Format.htmlEncode(r),t.attr=String.format('ext:qtip="{0}"',l),String.format('<font color="{0}">{1}</font>',a,r)}},e||{}))},getOwnerColumn:function(e){return new Ext.grid.Column(Ext.apply({width:100,header:SYNO.SDS.Drive._T("file","owner"),dataIndex:"owner_name",renderer:function(e,t,i,n,o,s){if(SYNO.SDS.Drive.Define.Info.use_nickname&&i.data.owner){var r=i.data.owner.name,a=i.data.owner.nickname;return a&&(r+=" ("+a+")"),String.format('<span ext:qtip="{0}">{1}</span>',Ext.util.Format.htmlEncode(Ext.util.Format.htmlEncode(r)),Ext.util.Format.htmlEncode(e))}return Ext.util.Format.htmlEncode(e)}},e||{}))},getSizeColumn:function(e){return new Ext.grid.Column(Ext.apply({width:100,header:SYNO.SDS.Drive._T("file","size"),dataIndex:"size",renderer:function(e,t,i,n,o,s){t.css="syno-d-size-colume";return"dir"===i.get("ntype")?"":Ext.util.Format.fileSize(e)}},e||{}))},getTimeColumn:function(e){return new Ext.grid.Column(Ext.apply({width:100,renderer:function(e,t,i,n,o,s){return SYNO.SDS.Drive.Utils.getFormatDateTime(new Date(1e3*e))}},e||{}))},getRecycledTimeColumn:function(e){return new Ext.grid.Column(Ext.apply({width:150,header:SYNO.SDS.Drive._T("file","recycled_time"),dataIndex:"recycled_time",renderer:function(e,t,i,n,o,s){return 0===e?"-":SYNO.SDS.Drive.Utils.getFormatDateTime(new Date(1e3*e))}},e||{}))},getLabelsColumn:function(e){return new Ext.grid.Column(Ext.apply({width:200,header:SYNO.SDS.Drive._T("category","tag"),sortable:!1,dataIndex:"labels",renderer:function(e,t,i,n,o,s){var r,a=SYNO.SDS.Drive.GetWindow().getNavigation(),l=a.getCategoryText();"label"!==l&&"shared_label"!==l||(r=a.getCategory()),t.css="syno-d-tag-colume syno-d-label-column";var d="";return Ext.isArray(e)&&Ext.each(e,function(e){if(r!==e.label_id&&(!e.type||["personal_label","shared_label"].includes(e.type))){var t=Ext.util.Format.htmlEncode(e.name),i=Ext.util.Format.htmlEncode(t);if("personal_label"===e.type)d+=String.format('<span id="{0}" class="syno-d-tag syno-d-label-tag" tip="{1}" style="background-color:#{2};color:#{3};{4}">{5}</span>',Ext.id(),i,e.color,SYNO.SDS.Drive.Define.TagTextColor[e.color],Ext.isChrome||1!==t.length?"":"min-width:13px",t);else{var n=String.format('<svg class="syno-d-shared-label-icon" width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">\t\t\t\t\t\t\t\t<path d="M6 4C7.10467 4 8 4.89533 8 6C8 7.10467 7.10467 8 6 8C4.89533 8 4 7.10467 4 6C4 4.89533 4.89533 4 6 4Z" fill="#{0}"/>\t\t\t\t\t\t\t\t<path d="M11.0002 5.00012C11.8282 5.00012 12.5002 5.67137 12.5002 6.50012C12.5002 7.32812 11.8282 8.00011 11.0002 8.00011C10.1722 8.00011 9.50022 7.32812 9.50022 6.50012C9.50022 5.67137 10.1722 5.00012 11.0002 5.00012Z" fill="#{0}"/>\t\t\t\t\t\t\t\t<path d="M3.921 9.27963L3.88348 9.29398C2.74896 9.73585 2 10.7793 2 12V13L10 13V12C10 10.7793 9.25104 9.73585 8.11652 9.29398L8.079 9.27963C6.73857 8.77697 5.26143 8.77697 3.921 9.27963Z" fill="#{0}"/>\t\t\t\t\t\t\t\t<path d="M14 12H10.9997C10.9862 10.9619 10.5681 9.99554 9.87108 9.28244C10.6272 9.10063 11.4163 9.10408 12.1712 9.2928C13.246 9.5615 14 10.5272 14 11.6351V12Z" fill="#{0}"/>\t\t\t\t\t\t\t\t</svg>',SYNO.SDS.Drive.Define.TagTextColor[e.color]);d+=String.format('<span id="{0}" class="syno-d-shared-label-tag syno-d-label-tag" tip="{1}" style="background-color:#{2};{3}">{4}<span class="syno-d-shared-label-name" style="color:#{5};">{6}</span></span>',Ext.id(),i,e.color,Ext.isChrome||1!==t.length?"":"min-width:13px",n,SYNO.SDS.Drive.Define.TagTextColor[e.color],t)}}}),""===d?"-":d}},e||{}))},needShowFileListLabelTooltip:function(e){var t=this.getView();if(t){var i=t.findRow(e),n=i?i.rowIndex:-1;if(!e||!e.classList.contains("syno-d-label-column"))return!1;if(!this.isEllipsis(e.childNodes[0]))return!1;return this.store.getAt(n).data.labels.length>0}},isEllipsis:function(e){return e.offsetWidth<e.scrollWidth},updateScrollbar:function(e,t){if(e&&e.fleXcroll){var i=String.format("#{0} > .scrollwrapper",e.id),n=Ext.query(i);if(n.length>0){var o=n[0];0===o.getSize[0]()&&o.setSize[0]("1px"),0===o.getSize[1]()&&o.setSize[1]("1px")}}this.callParent(arguments)},getPermissionsColumn:function(e){return new Ext.grid.Column(Ext.apply({width:230,header:SYNO.SDS.Drive._T("share","permission"),sortable:!1,dataIndex:"permissions",renderer:function(e,t,i){t.css="syno-d-tag-colume";var n=[],o=i.data.shared_with;Ext.each(o,function(e){if("user"===e.type||"group"===e.type)return n.push(SYNO.SDS.Drive._T("share","Invitee")),!1}),Ext.each(o,function(e){if("internal"===e.type)return n.push(SYNO.SDS.Drive._T("share","app_share")),!1});var s=!1;Ext.each(o,function(e){if("public"===e.type)return n.push(SYNO.SDS.Drive._T("share","public_share")),s=!0,!1}),i.data.adv_shared&&!s&&n.push(SYNO.SDS.Drive._T("share","advanced_share_type"));var r=n.join(SYNO.SDS.Drive._T("common","comma"));return r=String.format('<span class="syno-d-tag syno-d-tag-shared" ext:qtip="{0}">{1}</span>',r,r),""===r?"-":r}},e||{}))},reconfigure:function(e,t){e.reconfiguring=!0,this.updateColumn(),this.callParent(arguments),this.onAfterBindStore(e),e.reconfiguring=!1},focusItem:function(e){this.getSelectionModel().selectRow(e);var t=this.getView();this.findAppWindow().modalWin.length?t.syncFocusEl(t.ensureVisible(e,0,!1)):t.focusRow(e)},onUpdateScrollbar:function(e){this.getView().updateScroller(e)},onAfterBindStore:Ext.empytFn,updatePaginToolBar:Ext.empytFn,getActiveStore:function(){},getGridView:function(){},getGridCM:function(){},getNameColumn:function(){},getSelModel:function(){return new Ext.grid.RowSelectionModel({})},getColumnState:Ext.emptyFn,saveState:function(e){}},SYNO.SDS.Drive.Framework.postDefine),Ext.define("SYNO.SDS.Drive.Comp.NameColumn",{extend:"Ext.grid.Column",id:"name",constructor:function(e){this.appWindow=e.appWindow,this.iconSize=e.iconSize||16,this.lockIconSize=e.lockIconSize||16,this.showStar=e.showStar,this.callParent(arguments)},renderer:function(e,t,i,n,o,s){var r="",a=this.appWindow.getNavigation().getCategory(),l=Ext.util.Format.htmlEncode(SYNO.SDS.Drive.Utils.parseDisplayName(e)),d="",c=!1,h=0;return SYNO.SDS.Drive.WindowHelper.isPublicShare()||(d=this.getSharingNames(a,i.data.shared_with,i.data.adv_shared)),d&&(c=!0),!1===this.showStar||SYNO.SDS.Drive.WindowHelper.isPublicShare()||(r+=this.getStarIcon(a,i)),r+=this.getFileTypeIcon(i),c&&h++,i.data.encrypted&&h++,r+=this.getTitle(l,h),c&&(r+=this.getSharingIndicator(d)),i.data.encrypted&&(r+=this.getEncryptIndicator()),r},getSharingNames:function(e,t,i){var n=[];return Ext.each(t,function(e){switch(e.type){case"internal":n.push(SYNO.SDS.Drive._T("share","app_share"));break;case"public":n.push(SYNO.SDS.Drive._T("share","public_share"));break;default:n.push(e.display_name)}}),i&&n.push(SYNO.SDS.Drive._T("share","protection_share")),n.join(", ")},getTitle:function(e,t){return String.format('<span ext:qtip="{0}" class="syno-d-start-title" style="max-width:calc(100% - {1}px);">{2}</span>',Ext.util.Format.htmlEncode(e),72+24*t,e)},getFileTypeIcon:function(e){var t=e.data,i=t.ntype;"/mydrive/Photos"===t.display_path&&SYNO.SDS.StatusNotifier.isAppEnabled("SYNO.Foto.AppInstance")&&(i="folder_photo");var n=t.transient?SYNO.SDS.Drive.FileType.getTransientFileIconStyle(i,this.iconSize):SYNO.SDS.Drive.FileType.getFileTypeIconStyle(i,this.iconSize);if(!SYNO.SDS.Drive.Utils.shouldShowFileLockOverlay(t))return String.format('<span class="syno-d-start-ntype" style="{0}"></span>',n);var o=SYNO.SDS.Drive.Utils.getFileLockingTooltip(t);return n=SYNO.SDS.Drive.Utils.checkFileLockOverlay(t,n,this.lockIconSize),String.format('<span class="syno-d-start-ntype" style="{0}" ext:qtip="{1}"></span>',n,o)},getStarIcon:function(e,t){var i=this.appWindow.getNavigation();return"search"===e&&!t.get("recycle")||"recycle"!==e&&"search"!==e&&("team_folder"!==e||!i.isRootPath())?String.format('<span class="{0}"></span>',t.get("starred")?"syno-d-start-icon syno-d-start-icon-check":"syno-d-start-icon"):""},getSharingIndicator:function(e){return String.format('<span ext:qtip="{0}" class="syno-d-shard-icon"></span>',SYNO.SDS.Drive.Utils.doubleHtmlEncode(e))},getEncryptIndicator:function(){return String.format('<span class="syno-d-encrypt-icon"></span>')},processEvent:function(e,t,i,n,o){var s=Ext.fly(t.getTarget());if("click"===e&&s.is("span.syno-d-start-icon")){var r=i.store.getAt(n),a=r.get("starred");r.data.starred=!a,r.commit(),this.fireEvent("change",this,i,r,a,n,o,t)}this.callParent(arguments)}}),Ext.define("SYNO.SDS.Drive.Comp.DetailNameColumn",{extend:"SYNO.SDS.Drive.Comp.NameColumn",constructor:function(e){var t={iconSize:24,lockIconSize:24};Ext.apply(t,e||{}),this.callParent([t])},getTitle:function(e,t){return String.format('<span ext:qtip="{0}" class="syno-d-start-title" style="max-width:calc(100% - {1}px);">{2}</span>',Ext.util.Format.htmlEncode(e),72+24*(t+1),e)},getFileTypeIcon:function(e){if(e.data.removed||!SYNO.SDS.Drive.FileType.hasThumbnail(e.data.ntype))return this.callParent(arguments);var t=this.appWindow.getViewModeMgr().getViewMode();if("empty"!==t&&"detail"!==t)return"";var i=String.format("detail_{0}",SYNO.SDS.Drive.Utils.base64ForHtmlId.encode(e.data.file_id.toString())),n=this.getThumbImg(e.data),o=this.getImgHtml(e.data,i,n);return this.appWindow.getImageQueue().addImage({id:i,url:n,listeners:{load:this.onImageLoad.createDelegate(this)}}),o},getImgHtml:function(e,t,i){var n=SYNO.SDS.Drive.FileType.getMappingTypeCss(e.ntype,this.iconSize),o=String.format('<div class="syno-d-img-container {0}"><img id="{1}" class="syno-d-start-ntype syno-d-hidden syno-d-def-icon" data-type="{2}" data-thumb="{3}" src="" draggable="false"></div>',n,t,Ext.util.Format.htmlEncode(e.ntype),i);if(!SYNO.SDS.Drive.Utils.shouldShowFileLockOverlay(e))return o;var s=this.getLockImgHtml(e,t),r=SYNO.SDS.Drive.Utils.getFileLockingTooltip(e)
;return o=String.format('<div class="syno-d-img-container {0}"><img id="{1}" class="syno-d-start-ntype syno-d-hidden syno-d-def-icon" data-type="{2}" data-thumb="{3}" src="" draggable="false" ext:qtip="{4}">{5}</div>',n,t,Ext.util.Format.htmlEncode(e.ntype),i,r,s)},getLockImgId:function(e){return String.format("{0}-lock-overlay",e)},getLockImgHtml:function(e,t){var i=this.getLockImgId(t),n=this.lockIconSize/2,o=SYNO.SDS.Drive.FileType.getLockIconBaseURL(this.lockIconSize),s=SYNO.SDS.Drive.Utils.getFileLockingTooltip(e);return String.format('<img id="{0}" src="{1}" class="syno-d-lock-overlay-icon" style="position: absolute; left: calc(50% - {2}px); top: calc(50% - {3}px)" ext:qtip="{4}"></img>',i,o,n,n,s)},getThumbImg:function(e){if(!SYNO.SDS.Drive.FileType.hasThumbnail(e.ntype))return"";if(e.thumbnail)return e.thumbnail;var t=Ext.apply({params:{path:SYNO.SDS.Drive.Utils.getPathId(e.file_id),size:"small",version_id:e.version_id}},SYNO.SDS.Drive.WebAPIDesc.get_thumbnail);return SYNO.API.GetBaseURL(t)},onImageLoad:function(e){e.naturalWidth>=32&&e.naturalHeight>=32&&e.classList.remove("syno-d-def-icon"),e.classList.remove("syno-d-hidden"),e.parentNode.className="syno-d-img-container";var t=document.getElementById(this.getLockImgId(e.id));if(t){var i=this.lockIconSize,n=this.lockIconSize;t.style.left=String.format("calc(100% - {0}px)",i),t.style.top=String.format("calc(100% - {0}px)",n)}}}),Ext.ns("SYNO.SDS.Drive.FleXcroll"),Ext.define("SYNO.SDS.Drive.FleXcroll.BufferView",{extend:"SYNO.ux.FleXcroll.grid.BufferView",constructor:function(e){this.store=e.store,this.searchFields=e.searchFields,this.callParent([e]),SYNO.SDS.Drive.Utils.registerEmptyTextEvents.apply(this)}}),Ext.define("SYNO.SDS.Drive.FleXcroll.GridView",{extend:"SYNO.ux.FleXcroll.grid.GridView",constructor:function(e){this.store=e.store,this.searchFields=e.searchFields,this.callParent([e]),SYNO.SDS.Drive.Utils.registerEmptyTextEvents.apply(this)}}),Ext.define("SYNO.SDS.Drive.Comp.GridView",{extend:"SYNO.ux.FleXcroll.grid.BufferView",afterRenderUI:function(){this.callParent(arguments),this.autoFlexcroll&&this.grid.mon(this,"flexcroll",function(){this.fireEvent.apply(this,["flexcroll"].concat(Array.prototype.slice.call(arguments,0)))},this.grid)}}),Ext.define("SYNO.SDS.Drive.Comp.RowSelectionModel",{extend:"Ext.grid.RowSelectionModel",onKeyRight:function(e){this.selections.items[0]||this.grid.focusItem(0)},onKeyLeft:function(e){this.selections.items[0]||this.grid.focusItem(0)}}),Ext.define("SYNO.SDS.Drive.Upload.GridPanel",{extend:"SYNO.SDS.Drive.Comp.GridPanel",applyColumnState:!1,constructor:function(e){var t={enableDragDrop:!1,enableHdMenu:!1,minColumnWidth:50,listeners:{scope:this,rowclick:function(e,t,i){i&&t>=0&&!i.hasModifier()&&e.getSelectionModel().selectRow(t)},show:this.onShowPanel,activate:this.onActivate,deactivate:this.onDeActivate,rowdblclick:this.onDoubleClick}};Ext.apply(t,e||{}),this.callParent([t])},getGridView:function(e){var t=36;return"detail"===this.mode?t=48:"compact"===this.mode&&(t=30),new SYNO.ux.FleXcroll.grid.BufferView({rowHeight:t,borderHeight:2,cacheSize:30,scrollDelay:!1,forceFit:!0,disableTextSelect:!0,updateSortIcon:function(e,t){var i=this.sortClasses,n=i["DESC"===t.toUpperCase()?1:0],o=this.mainHd.select("td").removeClass(i),s=o.item(e);s&&s.addClass(n)}})},getActiveStore:function(){return this.activeStore=this.findAppWindow().getStoreMgr().getActiveStore(),this.activeStore},getNameColumn:function(){return new("detail"===this.mode?SYNO.SDS.Drive.Comp.DetailNameColumn:SYNO.SDS.Drive.Comp.NameColumn)({appWindow:this.findAppWindow(),width:200,showStar:!1,dataIndex:"name",header:SYNO.SDS.Drive._T("file","title")})},getGridCM:function(){return this.gridcm?this.gridcm:(this.gridcm=new Ext.grid.ColumnModel({defaults:{menuDisabled:!0,sortable:!0,hidden:!1},columns:[this.getNameColumn(),this.getOwnerColumn(),this.getSizeColumn(),this.getTimeColumn({dataIndex:"mtime",header:SYNO.SDS.Drive._T("file","mtime")})]}),this.gridcm)},getSelModel:function(){return new Ext.grid.RowSelectionModel({listeners:{scope:this,selectionchange:this.onSelectionChange}})},onSelectionChange:function(){this.findAppWindow().getEventMgr().fireEvent("nodeselectchange")}},SYNO.SDS.Drive.Framework.postDefine),Ext.define("SYNO.SDS.Drive.FileButton",{extend:"SYNO.ux.FileButton",mulitSelect:!0,acceptType:"",constructor:function(e){this.callParent(arguments)},getFileName:function(e){if(Ext.isWindows)return e.substr(e.lastIndexOf("\\")+1);var t=/fakepath\\(.+)$/.exec(e);return null!==t&&(e=t[1]),e},onRender:function(){this.callParent(arguments),this.el.set({multiple:this.mulitSelect,accept:this.acceptType},!0)},onFileChange:function(e,t,i){var n=[],o=e.target.files;Ext.each(o,function(e){n.push(this.getFileName(e.name))},this),this.fileTextField.setValue(n.join(",")),this.fireEvent("change",e.target.files)},setAttributes:function(e){this.el.set({accept:e.accept},!0),!1===e.multiple&&this.el.dom.removeAttribute("multiple")}}),Ext.reg("synodrive_filebutton",SYNO.SDS.Drive.FileButton),Ext.define("SYNO.SDS.Drive.Upload.FromPCPanel",{extend:"SYNO.SDS.Utils.FormPanel",mixins:["SYNO.SDS.Drive.Comp.DragDropHandler"],constructor:function(e){this.owner=e.owner,this.appWin=this.findAppWindow(),this.callParent([this.fillConfig(e||{})])},fillConfig:function(e){var t={cls:"syno-d-upload-from-pc-panel",layout:"fit",padding:0,fieldWidth:250,fileUpload:!0,items:[this.getGridPanel()],tbar:this.getToolbar(),listeners:{scope:this,afterlayout:{single:!0,fn:this.initDragDrop}}};return Ext.apply(t,e)},getGridPanel:function(){if(this.grid)return this.grid;var e=SYNO.SDS.Drive._T;return this.grid=new SYNO.ux.GridPanel({itemId:"upload_file_grid",hideHeaders:!0,view:new SYNO.ux.FleXcroll.grid.BufferView({rowHeight:48,borderHeight:1,cacheSize:30,scrollDelay:!1,forceFit:!0,disableTextSelect:!0}),flex:1,sm:new Ext.grid.RowSelectionModel({singleSelect:!0,listeners:{scope:this,beforerowselect:function(){return!!this.owner.singleSelect}}}),colModel:new Ext.grid.ColumnModel({defaults:{menuDisabled:!0},columns:[{dataIndex:"filename",header:e("file","title"),renderer:function(e,t,i,n,o,s){var r,a,l,d=i.get("fileObj"),c=i.get("fileEntry");return SYNO.SDS.Drive.FileType.isImageMime(d.type)?(r=URL.createObjectURL(d),l=32,Ext.defer(function(){URL.revokeObjectURL(r)},1e3)):(l=24,r=c&&c.isDirectory?SYNO.SDS.Drive.FileType.getFileTypeIcon("dir",l):SYNO.SDS.Drive.FileType.getFileTypeIcon(SYNO.SDS.Drive.Utils.getExt(e),l)),a=String.format('<div class="syno-d-upload-preview" style="background-image: url({0}); background-size:{1}px"></div>',r,l),a+=String.format('<span class="syno-d-upload-text">{0}</span>',Ext.util.Format.htmlEncode(SYNO.SDS.Drive.Utils.parseDisplayName(e))),a+='<span class="syno-d-upload-remove"></span>'}}]}),store:this.getFileStore(),listeners:{scope:this,rowclick:this.onRowClick}}),this.grid},getFileStore:function(){return this.fileStore?this.fileStore:(this.fileStore=new Ext.data.JsonStore({autoDestroy:!0,fields:["filename","filesize"]}),this.fileStore)},getToolbar:function(){if(this.toolbar)return this.toolbar;var e=SYNO.SDS.Drive._T;return this.toolbar=new SYNO.ux.Toolbar({items:[{xtype:"synodrive_filebutton",itemId:"upload",buttonConfig:{btnStyle:"default"},buttonOnly:!0,buttonText:e("upload","upload_from_pc"),listeners:{scope:this,change:this.addFiles}}]}),this.toolbar},onRowClick:function(e,t,i,n){Ext.fly(i.getTarget()).is("span.syno-d-upload-remove")&&(this.fileStore.removeAt(t),this.setStatusText())},getFileName:function(e){if(Ext.isWindows)return e.substr(e.lastIndexOf("\\")+1);var t=/fakepath\\(.+)$/.exec(e);return null!==t&&(e=t[1]),e},addFiles:function(e,t){if(!1===this.findAppWindow().fireEvent("beforefileselect",e,t))return!1;for(var i=0;i<e.length;++i){var n=SYNO.SDS.Drive.Utils.getDragItem(e,t,i);this.fileStore.add(new Ext.data.Record({name:Ext.id(void 0,"file_upload_"),filename:this.getFileName(e[i].name),filesize:Ext.util.Format.fileSize(e[i].size),fileObj:e[i],fileEntry:n?n.webkitGetAsEntry():void 0,source:"from_pc"}))}if(this.setStatusText(),this.owner.singleSelect){var o=this.getGridPanel().getSelectionModel();o.hasSelection()||o.selectRow(0),t||this.findAppWindow().onApply()}},setFileBtnAttributes:function(e){this.toolbar.get("upload").setAttributes(e)},setStatusText:function(){var e=this.fileStore.getCount();this.findAppWindow().setApplyBtnDisabled(0===e),this.findAppWindow().setStatus(String.format(SYNO.SDS.Drive._T("upload","items"),e))},onFileChange:function(e,t){var i=this.findAppWindow();SYNO.SDS.Drive.Utils.checkFileCanUpload(e,t).then(function(){this.addFiles(e,t)}.bind(this)).catch(function(e){SYNO.SDS.Drive.Utils.showAlertMsg(i,e)})},getMaskTargetEl:function(){return this.grid.getEl()},getResults:function(){var e=[];if(this.owner.singleSelect){var t=this.getGridPanel().getSelectionModel();if(t.hasSelection()){var i=t.getSelected();e.push(i.data)}return e}return this.fileStore.each(function(t){e.push(t.data)}),e},cleanAll:function(){this.fileStore.removeAll()},isDirty:function(){return 0<this.getResults().length}},SYNO.SDS.Drive.Framework.postDefine),Ext.define("SYNO.SDS.Drive.Comp.DropTarget",{extend:"Ext.dd.DropTarget",constructor:function(e,t){this.callParent(arguments)},isDropCategory:function(e){switch(e){case"label":case"shared_label":return!0;default:return!1}},notifyOut:function(e,t,i){this.updateDDText(e,t,i)},notifyOver:function(e,t,i){this.updateDDText(e,t,i);var n=this.getDDIndex(t);return this.notifyOverAndDrop(n,e,t,i)?this.dropAllowed:this.dropNotAllowed},updateDDText:function(e,t,i){e.getProxy().getGhost().update(this.getDragDropText(i.selections))},getDragDropText:function(e){var t=e.length;if(0!==t){var i=SYNO.SDS.Drive.Utils.parseDisplayName(Ext.util.Format.htmlEncode(e[0].data.name));return 1===e.length&&"shared_label"===e[0].data.type?SYNO.SDS.Drive.Utils.getSharedLabelDragText(e[0].data):"<span class='syno-d-drag-text'>"+i+"</span>"+(1<t?"<span class='syno-d-drag-num'>"+(t>99?"99+":t)+"</span>":"")}},getDDTarget:function(){return this.ddTarget},getDDIndex:function(e){return!1},notifyOverAndDrop:function(e,t,i){return!1},notifyDrop:function(e,t,i){return!1}}),Ext.define("SYNO.SDS.Drive.Comp.DataView",{extend:"SYNO.SDS.Utils.DataView.LazyDataView",mixins:["SYNO.SDS.Drive.Comp.ScrollEventHandler"],constructor:function(e){var t={autoScroll:!0,trackResetOnLoad:!1,disableTextSelect:!0,multiSelect:!0,enableDragDrop:!1,trackOver:!0,emptyText:""};Ext.apply(t,e||{}),this.callParent([t])},getTemplateTarget:function(){var e=this;if(e.el.dom)return e.scrollBar=e.scrollBar||e.el.createChild({tag:"div",class:"syno-d-dataview-ct",style:"display:inline-block;width:100%;"}),e.scrollBar},afterRender:function(e){this.callParent(arguments),this.mun(this.getTemplateTarget(),"click",this.onClick,this),this.on("flexcrollInitDone",function(){this.mon(this.el.child(".mcontentwrapper"),"click",this.onClick,this)},this,{single:!0}),this.getEl().on("click",function(e){this.getEl().focus()},this),this.keys&&(this.keymap=new Ext.KeyMap(this.getEl(),this.keys)),this.enableDragDrop&&!this.dragZone&&(this.dragZone=new SYNO.SDS.Drive.Comp.DataViewDragZone(e,this.dragConfig)),this.enableDragDrop&&!this.dropTarget&&(this.dropTarget=new SYNO.SDS.Drive.Comp.DataViewDropTarget(e,this.dropConfig))},onBeforeLoad:function(){this.selectedRecIds=this.getSelectedRecords().map(function(e){return e.id}),this.callParent(arguments)},onStoreLoad:function(e,t,i){if(!i||!i.add){if(!Ext.isEmpty(this.selectedRecIds)&&this.store){for(var n=0,o=this.selectedRecIds.length;n<o;n++){var s=this.store.indexOfId(this.selectedRecIds[n]);-1!==s&&this.select(this.all.elements[s],!0,!0)}this.selectedRecIds=null}this.updateScrollbar(this.trackResetOnLoad),this.trackResetOnLoad=!0,this.fireEvent("afterUpdateScrollbar",this)}},onMouseOver:function(e){this.callParent(arguments);var t,i=!1,n=!1;Ext.dd.DragDropMgr.dragCurrent&&Ext.dd.DragDropMgr.dragCurrent.getProxy&&(t=Ext.dd.DragDropMgr.dragCurrent.getProxy()),t&&t.getGhost()&&t.getGhost().isVisible()&&(n=!0,Ext.dd.DragDropMgr.dragCurrent.dragData.dataview instanceof SYNO.SDS.Drive.ViewPanel.DataViewPanel&&(i=!0));var o=e.getTarget(this.itemSelector,this.getTemplateTarget());if(o&&n){var s=this.indexOf(o);if(!this.isSelected(s)){var r=this.store.getAt(s);!r||i&&"dir"!==r.data.ntype||Ext.fly(o).addClass("dragover")}}},bindStore:function(e){this.callParent(arguments),this.onAfterBindStore(e)},onAfterBindStore:Ext.empytFn,onMouseOut:function(e){this.callParent(arguments);var t=e.getTarget(this.itemSelector,this.getTemplateTarget());t&&Ext.fly(t).removeClass("dragover")},clearAllSelections:function(){this.clearSelections()},createTemplate:Ext.emptyFn,onLoadItem:function(e){},onUnLoadItem:function(e){}},SYNO.SDS.Drive.Framework.postDefine),Ext.define("SYNO.SDS.Drive.Comp.DataViewDragZone",{extend:"Ext.dd.DragZone",ddGroup:"DataViewDD",proxy:new Ext.dd.StatusProxy({animRepair:!1}),constructor:function(e,t){this.callParent(arguments),this.ddTarget=t.owner,this.scroll=!1,this.ddel=document.createElement("div"),this.ddel.className="x-grid-dd-wrap"},onBeforeDrag:function(e,t){var i=SYNO.SDS.Drive.GetWindow().getNavigation(),n=i.getCategory();return!("recycle"===n||"team_folder"===n&&i.isRootPath())},getDragData:function(e){var t=this.ddTarget.dataview,i=e.getTarget(t.itemSelector,t.getTemplateTarget()),n=-1;if(i&&(n=this.ddTarget.dataview.indexOf(i),-1===n||t.isSelected(n)||e.hasModifier()||t.select(n,!1),-1!==n&&t.isSelected(n)&&!e.hasModifier()))return{dataview:this.ddTarget,ddel:this.ddel,index:n,selections:this.ddTarget.getSelections()}}}),Ext.define("SYNO.SDS.Drive.Comp.DataViewDropTarget",{extend:"SYNO.SDS.Drive.Comp.DropTarget",constructor:function(e,t){this.callParent(arguments),this.ddTarget=t.owner},notifyOverAndDrop:function(e,t,i,n){if(-1===e)return!1;var o=this.ddTarget.dataview.getStore().getAt(e);if(!o)return!1;var s=this.ddTarget.findAppWindow().getNavigation(),r=s.getCategory();if("recycle"===r||"shared_with_me"===r&&s.isRootPath()||"team_folder"===r&&s.isRootPath())return!1;if(n.dataview instanceof SYNO.SDS.Drive.Comp.DataViewPanel){if("dir"!==o.data.ntype)return!1}else if(Ext.isEmpty(n.selections)||!this.isDropCategory(n.selections[0].data.category))return!1;return!0},notifyDrop:function(e,t,i){var n=this.ddTarget.dataview,o=t.getTarget(n.itemSelector,n.getTemplateTarget());o&&Ext.fly(o).removeClass("dragover");var s=this.getDDIndex(t);if(!this.notifyOverAndDrop(s,e,t,i)||i.selections[0]===n.getStore().getAt(s))return!1;var r=n.getStore().getAt(s);if(!r)return!1;var a=this.ddTarget.findAppWindow();return i.dataview instanceof SYNO.SDS.Drive.ViewPanel.DataViewPanel?a.getAction().moveNode({to_parent_folder:SYNO.SDS.Drive.Utils.getPathId(r.id),to_parent_folder_name:r.get("name")}):a.getAction().changeTagByRec([i.selections[0].data],[],[r]),!0},getDDIndex:function(e){var t=this.ddTarget.dataview,i=e.getTarget(t.itemSelector,t.getTemplateTarget());return i?t.indexOf(i):-1}}),Ext.define("SYNO.SDS.Drive.Comp.ThumbnailView",{extend:"SYNO.SDS.Drive.Comp.DataView",defaultIconSize:48,defaultLockIconSize:48,constructor:function(e){var t={store:e.store,itemSelector:"div.thumbnail-entry",tpl:this.createTemplate()};Ext.apply(t,e||{}),this.callParent([t]),this.onRegEvent()},onRegEvent:function(){this.mon(this,{scope:this,resize:this.onViewResize})},createTemplate:function(){var e=this.defaultIconSize,t=this.defaultLockIconSize,i=t;return new Ext.XTemplate('<tpl for=".">','<div class="thumbnail-entry">','<div class="thumbnail-wrapper {[this.getLoadingClass(values)]}">','<div class="image-container syno-d-ori-icon" ext:qtip="{[this.getFileLockingTooltip(values)]}">',"{[this.getImgHtml(values)]}",'<tpl if="this.shouldShowFileLockOverlay(values)">',"{[this.getLockImgHtml(values)]}","</tpl>","</div>","</div>","<div ext:qtip=\"{[SYNO.SDS.Drive.Utils.doubleHtmlEncode(this.getFileName(values.name || '-'))]}\" class=\"title\">{[Ext.util.Format.htmlEncode(this.getFileName(values.name || '-'))]}</div>","</div>","</tpl>",{getId:function(e){return String.format("thumbnail_{0}",e.file_id?SYNO.SDS.Drive.Utils.base64ForHtmlId.encode(e.file_id.toString()):"")},getLockImgId:this.getLockImgId.bind(this),getDataType:function(e){return e.ntype},getLoadingClass:function(e){return this.hasThumbnail(e)?"thumbnail-loading":""}.bind(this),getThumbImg:this.getThumbImg.bind(this),getThumbDefaultSrc:function(t){if(!this.hasThumbnail(t)){var i=t.ntype;return"/mydrive/Photos"===t.display_path&&SYNO.SDS.StatusNotifier.isAppEnabled("SYNO.Foto.AppInstance")&&(i="folder_photo"),SYNO.SDS.Drive.FileType.getFileTypeIcon(i,e)}return SYNO.SDS.Drive.FileType.getDefaultIcon()}.bind(this),getFileName:function(e){return SYNO.SDS.Drive.Utils.parseDisplayName(e)},shouldShowFileLockOverlay:function(e){return SYNO.SDS.Drive.Utils.shouldShowFileLockOverlay(e)},getFileLockingTooltip:function(e){if(this.shouldShowFileLockOverlay(e))return SYNO.SDS.Drive.Utils.getFileLockingTooltip(e)},getImgHtml:function(e){var t=this.getId(e),i=Ext.util.Format.htmlEncode(this.getDataType(e)),n=this.getThumbImg(e),o=this.getThumbDefaultSrc(e);if(!SYNO.SDS.Drive.Utils.shouldShowFileLockOverlay(e))return String.format('<img id="{0}" data-failed="0" draggable="false" data-type="{1}" data-thumb="{2}" src="{3}">',t,i,n,o);var s=SYNO.SDS.Drive.Utils.getFileLockingTooltip(e);return String.format('<img id="{0}" data-failed="0" draggable="false" data-type="{1}" data-thumb="{2}" src="{3}" ext:qtip="{4}">',t,i,n,o,s)},getLockImgHtml:function(e){var n=this.getId(e),o=this.getLockImgId(n),s=i/2,r=i/2,a=SYNO.SDS.Drive.FileType.getLockIconBaseURL(t),l=SYNO.SDS.Drive.Utils.getFileLockingTooltip(e);return String.format('<img id="{0}" src="{1}" class="syno-d-lock-overlay-icon" style="position: absolute; left: calc(50% - {2}px); top: calc(50% - {3}px)" ext:qtip="{4}"></img>',o,a,s,r,l)},scope:this})},hasThumbnail:function(e){return!e.removed&&SYNO.SDS.Drive.FileType.hasThumbnail(e.ntype)},onViewResize:function(){this.updateWidthStyle()},updateWidthStyle:function(){var e=this.getViewSize(),t=this.getWidth()-24,i=Math.floor((t+16)/(e+16)),n=(t+16)/i-16-2,o=String.format(".thumbnail-wrapper { width: {0}px; height: {1}px; } .thumbnail-entry .title {width: {2}px}",n,n,n),s=document.head||document.getElementsByTagName("head")[0];this.style&&s.removeChild(this.style),this.style=document.createElement("style"),this.style.type="text/css",this.style.styleSheet?this.style.styleSheet.cssText=o:this.style.appendChild(document.createTextNode(o)),s.appendChild(this.style)},getThumbImg:function(e){if(!this.hasThumbnail(e))return"";if(e.thumbnail)return e.thumbnail;var t=Ext.apply({params:{path:SYNO.SDS.Drive.Utils.getPathId(e.file_id),size:"medium",version_id:e.version_id}},SYNO.SDS.Drive.WebAPIDesc.get_thumbnail);return SYNO.API.GetBaseURL(t)},onLoadItem:function(e){var t=e.query("img")[0],i=t.getAttribute("data-type");if(SYNO.SDS.Drive.FileType.hasThumbnail(i)){var n=t.getAttribute("data-thumb"),o=SYNO.SDS.Drive.FileType.getFileTypeIcon(i,this.defaultIconSize),s=n||o,r=!1;if(n){var a=this.store.getAt(this.indexOf(e));if(a&&a.data){var l=a.data,d=Ext.urlDecode(t.src)||{};(!d.path||SYNO.SDS.Drive.Utils.getPathId(l.file_id)!==Ext.decode(d.path)||d.version_id&&l.version_id!==Ext.decode(d.version_id))&&(r=!0,s=this.getThumbImg(l))}}(r||-1!==t.src.indexOf(SYNO.SDS.Drive.FileType.getDefaultIcon()))&&this.findAppWindow().getImageQueue().addImage({id:t.id,url:s,listeners:{load:this.onImageLoad.createDelegate(this),error:this.onImageError.createDelegate(this)}})}},onUnLoadItem:function(e){var t=e.query("img")[0],i=t.getAttribute("data-type");SYNO.SDS.Drive.FileType.hasThumbnail(i)&&this.findAppWindow().getImageQueue().removeImage(t.id)},onImageLoad:function(e){e.parentNode.parentNode.classList.remove("thumbnail-loading"),e.parentNode.classList.remove("syno-d-ori-icon");var t=this.getViewSize();e.naturalWidth>=t&&e.naturalHeight>=t||e.parentNode.classList.add("syno-d-not-fit-icon");var i=document.getElementById(this.getLockImgId(e.id));if(i){var n=SYNO.SDS.Drive.Define.LockOverlayDynamicIcon,o=SYNO.SDS.Drive.FileType.getLockIconBaseURL(n.name),s=n.width+8,r=n.height+8;i.src=o,i.style.left=String.format("calc(100% - {0}px)",s),i.style.top=String.format("calc(100% - {0}px)",r)}},onImageError:function(e){e.parentNode.parentNode.classList.remove("thumbnail-loading"),e.parentNode.classList.add("syno-d-ori-icon"),e.parentNode.classList.remove("syno-d-not-fit-icon"),e.src=SYNO.SDS.Drive.FileType.getFileTypeIcon(e.getAttribute("data-type"),this.defaultIconSize)},onUpdate:function(e,t){var i=this.store.indexOf(t);if(i>-1){var n=this.isSelected(i),o=this.all.elements[i],s=this.bufferRender([t],i)[0],r=Ext.DomQuery.selectNode("img",s);if(o&&r&&r.complete){var a=!1,l=Ext.fly(o).child("img",!0),d=t.data,c=Ext.urlDecode(l.src)||{};c.path&&SYNO.SDS.Drive.Utils.getPathId(d.file_id)===Ext.decode(c.path)&&d.version_id===Ext.decode(c.version_id)||(a=!0);var h=null!==o.querySelector("#"+this.getLockImgId(l.id));if(t.get("node_locking")&&h!==t.get("node_locking").is_locked&&(a=!0),!a)return o.replaceChild(s.lastChild,o.lastChild),void Ext.removeNode(s)}this.all.replaceElement(i,s,!0),n&&(this.selected.replaceElement(o,s),this.all.item(i).addClass(this.selectedClass)),this.updateIndexes(i,i)}},setViewSize:function(e,t){this.view_size=e,t&&this.updateWidthStyle()},getViewSize:function(){return this.view_size||140},getLockImgId:function(e){return String.format("{0}-lock-overlay",e)}}),Ext.define("SYNO.SDS.Drive.Comp.TileView",{extend:"SYNO.SDS.Drive.Comp.DataView",iconSize:16,lockIconSize:16,constructor:function(e){var t={store:e.store,itemSelector:"div.file-wrap",tpl:this.createTemplate()};Ext.apply(t,e||{}),this.callParent([t])},createTemplate:function(){var e=this.iconSize,t=this.lockIconSize;return new Ext.XTemplate('<tpl for=".">','<div class="file-wrap" role="option" aria-haspopup="true">',"{[this.getHtml(values)]}","</div>","</tpl>",{compiled:!0,disableFormats:!0,getFileName:function(e){return Ext.util.Format.htmlEncode(SYNO.SDS.Drive.Utils.parseDisplayName(e))},getFileNameQtip:function(e){return SYNO.SDS.Drive.Utils.doubleHtmlEncode(SYNO.SDS.Drive.Utils.parseDisplayName(e))},getStyle:function(t){var i=t.ntype;return"/mydrive/Photos"===t.display_path&&SYNO.SDS.StatusNotifier.isAppEnabled("SYNO.Foto.AppInstance")&&(i="folder_photo"),String.format("background:url({0});background-size:16px;background-repeat:no-repeat;background-position:8px 7px;",SYNO.SDS.Drive.FileType.getFileTypeIcon(i,e))},getHtml:function(e){var i=this.getStyle(e),n=this.getFileNameQtip(e.name||"-"),o=this.getFileName(e.name||"-");if(!SYNO.SDS.Drive.Utils.shouldShowFileLockOverlay(e))return String.format('<div class="syno-d-start-ntype" style="{0}" ext:qtip="{1}">{2}</div>',i,n,o);var s=SYNO.SDS.Drive.Utils.getFileLockingTooltip(e),r=String.format("{0}<br/>{1}",n,s);return i=SYNO.SDS.Drive.Utils.checkFileLockOverlay(e,i,t),String.format('<div class="syno-d-start-ntype" style="{0}" ext:qtip="{1}">{2}</div>',i,r,o)}})},getTemplateTarget:function(){if(this.el.dom)return this.scrollBar=this.scrollBar||this.el.createChild({tag:"div",class:"syno-d-dataview-ct",style:"display: inline-flex; flex-wrap: wrap; flex-direction: column; height: calc(100% - 12px); margin-top: 8px;"}),this.scrollBar},updateScrollbar:function(){this.scrollBar&&(this.scrollBar.removeClass("ellipsis"),this.scrollBar.setWidth("auto"),this.scrollBar.setWidth(this.scrollBar.dom.scrollWidth),this.scrollBar.addClass("ellipsis")),this.callParent(arguments)},onUpdateScrollbar:function(e){var t=this;if(t.isVisible()){var i=t.el.dom;i&&i.fleXcroll?(e&&i.fleXcroll.setScrollPos(0,0),i.fleXcroll.updateScrollBars(),e||i.fleXcroll.setScrollPos(0,0,!0)):i&&(fleXenv.fleXcrollMain(i,this.disableTextSelect),i.onfleXcroll=function(){t.isVisible()&&t.onUpdateView&&t.onUpdateView(),this.fireEvent("flexcroll",this,this.getFleXcrollInfo(t.el.dom))}.createDelegate(this),i.fleXcroll&&this.fireEvent("flexcrollInitDone")),i=null}},getThumbnailRowNum:function(e){var t=e.getTemplateTarget(),i=e.selected.elements[0].clientHeight;return Math.floor(t.getHeight()/i)},onKeyUp:function(e){if(!0!==this.isNeedToShift())return void this.selectItem(0);var t=this;e.shiftKey?t.selectPreItemIn():t.selectPreItem()},onKeyDown:function(e){if(!0!==this.isNeedToShift())return void this.selectItem(0);var t=this;e.shiftKey?t.selectNextItemIn():t.selectNextItem()},onKeyRight:function(e){if(!0!==this.isNeedToShift())return void this.selectItem(0);var t=this,i=t.getThumbnailRowNum(t);e.shiftKey?t.selectNextRowItemIn(i):t.selectNextRowItem(i)},onKeyLeft:function(e){if(!0!==this.isNeedToShift())return void this.selectItem(0);var t=this,i=t.getThumbnailRowNum(t);e.shiftKey?t.selectPreRowItemIn(i):t.selectPreRowItem(i)}}),Ext.define("SYNO.SDS.Drive.Comp.SnippetView",{extend:"SYNO.SDS.Drive.Comp.DataView",iconSize:16,lockIconSize:16,constructor:function(e){var t={store:e.store,itemSelector:"div.snippet-entry",tpl:this.createTemplate()};Ext.apply(t,e||{}),Ext.apply(t.listeners,{click:this.onViewItemClick}),this.callParent([t])},createTemplate:function(){return new Ext.XTemplate('<tpl for=".">','<div class="snippet-entry {[this.getEntryClass(values)]}">','<span class="{[this.getStarClass(values)]}"></span>',"{[this.getFileTypeStyle(values)]}",'<div class="info-wrapper">','<div class="info">','<div class="title"><span ext:qtip="{[this.getFileNameQtip(values)]}">{[this.getFileName(values.name || \'-\')]}</span></div>','<div class="timestamp"> {[this.getMtime(values.mtime)]} </div>',"</div>",'<div class="info">','<div class="path"><span class="path-text" ext:qtip="{[this.getFileNameQtip(values)]}">{[this.getFilePath(values)]}</span></div>','<div ext:qtip="{[this.getFileOwnerQtip(values)]}" class="owner-name"> {[this.getFileOwner(values)]} </div>',"</div>",'<tpl if="this.displayHighlight(values) == true">','<div class="info">','<div ext:qtip="{[Ext.util.Format.htmlEncode(this.getHighlight(values))]}" class="snippet">{[this.getHighlight(values)]}</div>',"</div>","</tpl>","</div>","</div>","</tpl>",{getEntryClass:function(e){var t="";return 0===this.owner.store.indexOfId(e.file_id)&&(t+=" first-item"),this.displayHighlight(e)&&(t+=" highlight-content"),t},getStarClass:function(e){return e.starred?"syno-d-start-icon syno-d-start-icon-check":"syno-d-start-icon"},getFileTypeStyle:function(e){var t=e.ntype;"/mydrive/Photos"===e.display_path&&SYNO.SDS.StatusNotifier.isAppEnabled("SYNO.Foto.AppInstance")&&(t="folder_photo");var i=SYNO.SDS.Drive.FileType.getFileTypeIconStyle(t,this.owner.iconSize);if(!SYNO.SDS.Drive.Utils.shouldShowFileLockOverlay(e))return String.format('<span class="syno-d-start-ntype" style="{0}"></span>',i);var n=SYNO.SDS.Drive.Utils.getFileLockingTooltip(e);return i=SYNO.SDS.Drive.Utils.checkFileLockOverlay(e,i,this.owner.lockIconSize),String.format('<span class="syno-d-start-ntype" style="{0}" ext:qtip="{1}"></span>',i,n)},getHighlight:function(e){return this.escapeHighlight(e.content_snippet||"-")},displayHighlight:function(e){var t=this.getHighlight(e);return!(!t||"-"===t)},escapeHighlight:function(e){return Ext.util.Format.htmlEncode(e||"").replace(/(3dd2fc93591338387e3f9e8f06fe0e34)|(92e78cb96015fb30b3d910376e32825d)/g,function(e,t,i){return t?'<span class="highlight">':"</span>"})},getFileOwner:function(e){var t="";return e.owner&&(t=e.owner.display_name),Ext.util.Format.htmlEncode(t)},getFileOwnerQtip:function(e){if(SYNO.SDS.Drive.Define.Info.use_nickname&&e.owner){var t=e.owner.name,i=e.owner.nickname;return i&&(t+=" ("+i+")"),SYNO.SDS.Drive.Utils.doubleHtmlEncode(t)}return e.owner?Ext.util.Format.htmlEncode(e.owner.display_name):""},getFileName:function(e){return Ext.util.Format.htmlEncode(SYNO.SDS.Drive.Utils.parseDisplayName(e))},getFilePath:function(e){return Ext.util.Format.htmlEncode(SYNO.SDS.Drive.Utils.parseDisplayPath(e.display_path))},getFileNameQtip:function(e){return SYNO.SDS.Drive.Utils.doubleHtmlEncode(SYNO.SDS.Drive.Utils.parseDisplayPath(e.display_path))},getMtime:function(e){return SYNO.SDS.Drive.Utils.getFormatDateTime(new Date(1e3*e))},owner:this})},onViewItemClick:function(e,t,i,n){var o=Ext.fly(n.getTarget());if(o)if(o.is("span.syno-d-start-icon")){var s=this.getStore().getAt(t),r=s.get("starred");r?this.findAppWindow().getAction().deleteShortcut({file_id:[s.id]}):this.findAppWindow().getAction().setShortcut({file_id:[s.id]}),s.data.starred=!r,s.commit()}else o.is("span.path-text")&&this.findAppWindow().getAction().onGotoPath(this.getStore().getAt(t).data.file_id)}}),Ext.define("SYNO.SDS.Drive.Comp.DataViewPanel",{extend:"SYNO.ux.Panel",mixins:["SYNO.SDS.Drive.Comp.SelectionModel","SYNO.SDS.Drive.Comp.PagingToolBar","SYNO.SDS.Drive.Comp.PanelEventHandler","SYNO.SDS.Drive.Comp.DragDropHandler","SYNO.SDS.Drive.Comp.KeyEventHandler"],constructor:function(e){this.module=e.module,this.owner=e.owner,this.appWin=this.findAppWindow(),this.activeStore=this.appWin.getStoreMgr().getActiveStore(),this.dataview=this.createDataView(e.Dataview);var t={loadMask:!0,items:this.dataview,layout:"fit",bbar:this.getPagingToolBar(this.activeStore),listeners:{scope:this,activate:this.onActivate,deactivate:this.onDeActivate,afterlayout:{single:!0,fn:function(){e.allowDragFile&&this.initDragDrop()}}}};Ext.apply(t,e||{}),this.callParent([t]),this.initKeyEvent()},initEvents:function(){this.loadMask&&(this.loadMask=new Ext.LoadMask(this.bwrap,Ext.apply({store:this.store},this.loadMask))),this.callParent(arguments)},onActivate:function(){this.onRegEvent(),this.activeStore=this.appWin.getStoreMgr().getActiveStore(),this.dataview.bindStore(this.activeStore),this.updatePaginToolBar(this.activeStore),this.updateCutIcon(),this.refreshEmptyText(),this.getView().el.focus(100)},onDeActivate:function(){this.loadMask&&!Ext.isBoolean(this.loadMask)&&this.loadMask.hide(),this.unRegEvent(),this.dataview.bindStore(null)},getView:function(){return this.dataview},getSelectedElements:function(){return this.dataview.selected.elements},getSelections:function(){return this.dataview.getSelectedRecords()},selectRecords:function(e,t){this.getSelectionModel().selectRecords(e,t)},onDataSelectionChange:function(){this.findAppWindow().getEventMgr().fireEvent("nodeselectchange")},getStore:function(){return this.dataview.getStore()},onViewStoreChange:function(e,t,i){this.switchStore(e,i)&&(this.dataview.bindStore(this.activeStore),this.updatePaginToolBar(this.activeStore))},createDataView:function(e){return new e({store:null,enableDragDrop:!1,deferEmptyText:!1,listeners:{scope:this,dblclick:this.onDoubleClick,selectionchange:this.onDataSelectionChange}})},setEmptyText:function(e){var t=this.dataview.getWidth(),i=this.dataview.getHeight()-3;this.emptyText=e,this.dataview.emptyText=String.format('<div class="syno-d-dataview-empty" style="width: {0}px; height: {1}px"> {2} </div>',t,i,e)},refreshEmptyText:function(){0===this.activeStore.getTotalCount()&&(this.setEmptyText(this.emptyText||""),this.dataview.refresh())},getSelectionModel:function(){return this.selectionModel||(this.selectionModel=new SYNO.SDS.Drive.Comp.DataViewSelectionModel(this.dataview))},focusItem:function(e){this.getSelectionModel().selectRow(e),this.dataview.focusNode(e)},onUpdateScrollbar:function(e){this.dataview.onUpdateScrollbar(e)},updatePaginToolBar:Ext.empytFn},SYNO.SDS.Drive.Framework.postDefine),SYNO.SDS.Drive.Comp.DataViewSelectionModel=function(e){var t=e,i=function(){return t.getSelectionCount()>0},n=function(){return t.getSelectedRecords()};return{dataView:t,getSelected:function(){return n()[0]},getCount:function(){return t.getSelectionCount()},hasSelection:i,getSelections:n,selectAll:function(e){t.selectRange(0,e-1)},clearAllSelections:function(e){t.clearAllSelections(e)},clearSelections:function(e){t.clearSelections(e)},selectRow:function(e,i){t.select(e,i)},selectRecords:function(e,i){var n=0;if(!Ext.isEmpty(e))for(i||this.clearAllSelections(),n=0;n<e.length;n++)this.selectRow(t.store.indexOf(e[n]),!0)}}},Ext.define("SYNO.SDS.Drive.Comp.EmptyPanel",{extend:"SYNO.ux.Panel",
mixins:["SYNO.SDS.Drive.Comp.SelectionModel","SYNO.SDS.Drive.Comp.DragDropHandler"],constructor:function(e){this.error=!1,this.owner=e.owner,this.appWin=this.findAppWindow(),this.callParent([this.fillConfig(e||{})]),this.mon(this,"afterlayout",this.initDragDrop,this,{single:!0}),this.mon(this,"afterlayout",function(e){this.mon(e.getEl(),"contextmenu",this.onShowContextMenu,this)},this,{single:!0})},fillConfig:function(e){var t={bodyCfg:{tabindex:"0"},cls:"syno-d-empty-panel",html:'<div class="syno-d-empty-panel-arrow"></div><div class="syno-d-empty-panel-container"><div class="syno-d-empty-panel-img"></div><div class="syno-d-empty-panel-text"></div></div>'};return Ext.apply(e,t)},onUpdateText:function(e,t){if(this.getText().update(t),"file_request_empty"===e)return this.error=!1,this.getImg().removeClass("syno-d-empty-panel-err-img"),void this.getImg().addClass("syno-d-empty-panel-file-request-img");this.getImg().removeClass("syno-d-empty-panel-file-request-img"),"empty"!==e?(this.error=!0,this.getArrow().hide(),this.getImg().addClass("syno-d-empty-panel-err-img")):(this.error=!1,this.getImg().removeClass("syno-d-empty-panel-err-img"))},getError:function(){return this.error},getText:function(){return this.emptytext||(this.emptytext=this.el.child("div.syno-d-empty-panel-text"))},getArrow:function(){return this.arrow||(this.arrow=this.el.child("div.syno-d-empty-panel-arrow"))},getImg:function(){return this.img||(this.img=this.el.child("div.syno-d-empty-panel-img"))},onUpdate:function(){var e,t=this.findAppWindow().getNavigation(),i=t.getCategory(),n="empty";switch(i){case"node":case"recent":case"starred":case"recycle":case"shared_with_me":case"sharing_to_others":case"backup":e=i;break;case"file_request":e=0===this.findAppWindow().getStoreMgr().getActiveStore().totalLength?"file_request":"file_request_filter",n="file_request_empty";break;case"team_folder":e=_S("is_admin")?"team_folder_empty_admin":"team_folder_empty";break;default:e="tag"}this.onUpdateText(n,SYNO.SDS.Drive._T("empty",e)),this.getArrow()["node"===i?"show":"hide"]()},onShowContextMenu:function(e){e.preventDefault();var t=this.findAppWindow().getMenu();t.setType("menu_context"),t.setOrigin(e.target),t.showAt(e.getXY())}},SYNO.SDS.Drive.Framework.postDefine),Ext.define("SYNO.SDS.Drive.Comp.PathBar",{extend:"Ext.BoxComponent",cls:"syno-d-pathtoolbar",activeButton:null,scrollRepeatInterval:400,scrollDuration:.35,buttonWidthSet:!1,allowDomMove:!1,autoScroll:!1,lastPathBtn:null,minLastPathBtnWidth:60,items:[],onUpdatePath:function(e,t){this.clearAllBtns(),"search"===e?this.addSearchPathBtns(t):"file_request"===e?this.addFileRequestBtn(t):this.addPathBtns(t)},clearAllBtns:function(){this.removeButtons(0,this.items.length)},addFileRequestBtn:function(e){this.addWhiteTipButton({itemId:0,text:e[0].text,tooltip:e[0].tooltip})},addPathBtns:function(e){for(var t=e.length-1,i=0;i<e.length;i++)this.addButton({itemId:i,text:e[i].text,tooltip:e[i].tooltip},0===i,i===t);this.setActiveButton(this.items[this.items.length-1]),!1===this.fireEvent("beforeshowarrow")?this.activeButton.removeClass(this.activeButton.arrowCls):this.activeButton.addClass(this.activeButton.arrowCls)},addSearchPathBtns:function(e){e.length<=0||this.addSearchButton({itemId:0,text:e[0].text||SYNO.SDS.Drive._T("drive","all_location")})},onRender:function(){this.callParent(arguments),this.mon(this,"resize",this.delegateUpdates,this),this.items=[];var e=Ext.get(this.el);this.stripWrap=e.createChild({cls:"syno-d-pathbuttons-strip-wrap",cn:{tag:"ul",cls:"syno-d-pathbuttons-strip"}}),this.stripSpacer=e.createChild({cls:"syno-d-pathbuttons-strip-spacer"}),this.strip=new Ext.Element(this.stripWrap.dom.firstChild),this.edge=this.strip.createChild({tag:"li",cls:"syno-d-pathbuttons-edge"}),this.strip.createChild({cls:"x-clear"})},addButton:function(e,t,i){var n=this.strip.createChild({tag:"li"},this.edge),o=new SYNO.SDS.Drive.Comp.PathButton(this,n,e,t,i);return this.items.push(o),this.buttonWidthSet||(this.lastButtonWidth=o.container.getWidth()),this.addManagedComponent(o),i&&(this.lastPathBtn=o,this.updateLastPathBtnWidth()),o},addWhiteTipButton:function(e){var t=this.strip.createChild({tag:"title-li"},this.edge),i=new SYNO.SDS.Drive.Comp.PathButton(this,t,e,!0,!0),n=String.format('href="{0}" target="_blank"',"https://kb.synology.com/DSM/help/SynologyDrive/drive_file_management?version=7#filerequest"),o=String.format(SYNO.SDS.Drive._T("file_request","title_tooltip_learn_more"),n);return SYNO.SDS.Utils.AddTip(i,o),this.items.push(i),this.buttonWidthSet||(this.lastButtonWidth=i.container.getWidth()),this.addManagedComponent(i),i},addSearchButton:function(e){var t=this.strip.createChild({tag:"li"},this.edge),i=new SYNO.SDS.Drive.Comp.SearchPathButton(this,t,e);return this.items.push(i),this.addManagedComponent(i),i},removeButtons:function(e,t){for(var i,n,o=e;o<t;o++)n=this.items[o],i=document.getElementById(n.container.id),this.removeManagedComponent(n),n.purgeListeners(),n.destroy(),i.parentNode.removeChild(i);var s=[];for(o=0;o<e;o++)s.push(this.items[o]);this.items=s,this.delegateUpdates()},setActiveButton:function(e){this.activeButton=e,this.delegateUpdates()},delegateUpdates:function(){this.rendered&&this.onAutoScroll()},onAutoScroll:function(){var e=this.items.length,t=this.el.dom.clientWidth,i=this.stripWrap,n=i.dom.offsetWidth,o=this.getScrollPos(),s=this.edge.getOffsetsTo(this.stripWrap)[0]+o;e<1||n<40||(i.setWidth(t),s<=t||1===this.items.length?(i.dom.scrollLeft=0,this.el.removeClass("syno-d-pathbuttons-selection-btn-displayed"),this.getMenuBtn().hide()):(this.el.addClass("syno-d-pathbuttons-selection-btn-displayed"),t-=i.getMargins("lr"),i.setWidth(t>40?t:40),this.getMenuBtn().show(),this.updateScrollandSelMenu(),this.updateLastPathBtnWidth(!0)))},getMenu:function(){return this.selMenu?this.selMenu:this.selMenu=new SYNO.ux.Menu({items:[],listeners:{scope:this,click:function(e,t){this.fireEvent("pathbarclick",this,t.itemId,!1,null)}}})},getMenuBtn:function(){if(this.menuBtn)return this.menuBtn;var e=this.el.dom.offsetHeight;return this.menuBtn=new Ext.Button({template:new Ext.Template('<em class="{2}" unselectable="on"><button type="{0}"></button><span class="syno-d-pathbutton-right"></span></em>').compile(),cls:"syno-d-pathbuttons-selection-btn",renderTo:this.el,height:e,text:"...",menu:this.getMenu()})},getLastBtn:function(){return this.lastPathBtn},destory:function(){this.menuBtn&&(this.menuBtn.purgeListeners(),this.menuBtn.destroy(),this.menuBtn=null),this.callParent(arguments)},getScrollPos:function(){return parseInt(this.stripWrap.dom.scrollLeft,10)||0},updateScrollandSelMenu:function(){var e=this.getStripIndex();this.selMenu.removeAll();for(var t=0;t<=e;t++)this.selMenu.addItem({itemId:String.format("{0}",t),htmlEncode:!1,text:this.items[t].text});var i=this.items[e+1],n=this.stripWrap.dom.scrollLeft,o=i.el.getOffsetsTo(this.stripWrap)[0]+n;this.stripWrap.scrollTo("left",o)},getStripIndex:function(){for(var e=this.items.length,t=e-1,i=0,n=this.stripWrap.getWidth(),o=t;o>=0&&!((i+=this.items[o].el.getWidth())+87>n);o--);return o===t&&(o-=1),o},getMinLastPathBtnWidth:function(){return this.minLastPathBtnWidth},updateLastPathBtnWidth:function(e){if(this.lastPathBtn&&this.lastPathBtn.rendered&&this.lastPathBtn.btnEl){for(var t=this.items.length,i=0,n=0,o=0;o<t-1;o++)i+=this.items[o].getOuterSize().width;if(e){i=this.getMenuBtn().getOuterSize().width;var s=this.getStripIndex();for(o=s+1;o<t-1;o++)i+=this.items[o].getOuterSize().width}if(n=this.getWidth()-i-24,this.lastPathBtn.btnEl.setWidth("auto"),this.getWidth()>0&&n<this.lastPathBtn.getWidth()){var r=Math.max(n,this.minLastPathBtnWidth);this.lastPathBtn.btnEl.setWidth(r)}}}}),Ext.define("SYNO.SDS.Drive.Comp.PathButton",{extend:"Ext.Button",firstBtnCls:"syno-d-pathbutton-first-btn",lastBtnCls:"syno-d-pathbutton-last-btn",arrowCls:"syno-d-pathbutton-arrow",constructor:function(e,t,i,n,o){this.panel=e;var s=n?this.firstBtnCls:"",r=o?this.lastBtnCls:"",a=Ext.apply({renderTo:t,clickEvent:"mousedown",tabIndex:-1,listeners:{click:{fn:this._onClickButton,scope:this},afterrender:{fn:function(){this.setTooltip(this.getText())},scope:this}},template:new Ext.Template('<table cellspacing="0" class="x-btn '+s+" "+r+' {3}"><tbody><tr>','<td class="syno-d-pathbutton-left"></td>','<td class="syno-d-pathbutton-center"><em class="{5}" unselectable="on">','<button class="x-btn-text {2}" type="{1}" style="height:18px;">{0}</button>',"</em></td>",'<td class="syno-d-pathbutton-right"></td>',"</tr></tbody></table>")},i);a.text&&(a.text=Ext.util.Format.htmlEncode(a.text)),a.tooltip&&(a.tooltip=Ext.util.Format.htmlEncode(Ext.util.Format.htmlEncode(a.tooltip))),this.callParent([a])},_onClickButton:function(){this.panel.fireEvent("pathbarclick",this.panel,this.itemId,this.el.hasClass(this.lastBtnCls),this)}}),Ext.define("SYNO.SDS.Drive.Comp.SearchPathButton",{extend:"Ext.Container",constructor:function(e,t,i){var n=String.format(SYNO.SDS.Drive._T("drive","search_in_location"),Ext.util.Format.htmlEncode(i.text));this.callParent([{cls:"syno-d-pathbutton-search",renderTo:t,html:n}])},_onClickButton:function(){}}),Ext.define("SYNO.SDS.Drive.Comp.Path",{extend:"SYNO.SDS.Drive.Comp.PathBar",constructor:function(e){this.appWin=e.appWin,this.callParent(arguments),this.onRegEvent()},onRegEvent:function(){var e=this.findAppWindow().getEventMgr();this.mon(e,{scope:this,search:this.onSearch,categorychange:this.onChange,pathchange:this.onChange,currentpathrename:this.onChange})},onChange:function(){var e=this.findAppWindow().getNavigation().getPath();this.onUpdatePath(this.findAppWindow().getNavigation().getCategory(),e)},findAppWindow:function(){return this.appWin}});SYNO.SDS.Drive.SelMenu=Ext.extend(SYNO.ux.Menu,{constructor:function(e){this.owner=e.owner,SYNO.SDS.Drive.SelMenu.superclass.constructor.call(this,Ext.apply({cls:"syno-ux-menu syno-d-select-menu"},e))},render:function(e,t){e||(e=this.findAppWindow().getEl()),SYNO.SDS.Drive.SelMenu.superclass.render.call(this,e,t)}}),Ext.define("SYNO.SDS.Drive.Comp.SortButton",{extend:"SYNO.SDS.Drive.SimpleButton",itemId:"sort",constructor:function(e){var t=SYNO.SDS.Drive._T,i={tabIndex:-1,itemId:"sort",tooltip:t("common","sort"),cls:"syno-d-sort-btn",menu:new SYNO.SDS.Drive.SelMenu({owner:e.appWindow,defaults:{checked:!1},items:[{itemId:"recycled_time",text:t("file","recycled_time")},{itemId:"score",text:t("file","relativity"),hidden:!0},{itemId:"name",text:t("file","title")},{itemId:"mtime",text:t("file","mtime"),checked:!0},{itemId:"type",text:t("file","type")},{itemId:"owner_name",text:t("file","owner")},{itemId:"size",text:t("file","size")}],listeners:{scope:this,itemclick:this.onItemClick,beforeshow:this.onBeforeShow}})};Ext.apply(i,e||{}),this.callParent([i])},getMenuClass:function(){return""},onItemClick:function(e,t){if(this.getSortType()!==e.itemId){var i="ASC";"mtime"!==e.itemId&&"recycled_time"!==e.itemId||(i="DESC"),this.findAppWindow().getStoreMgr().getActiveStore().sort(e.itemId,i)}},getSortType:function(){return(this.findAppWindow().getStoreMgr().getActiveStore().getSortState()||{}).field||"mtime"},onBeforeShow:function(e){var t=this.findAppWindow().getNavigation().getCategory();"list"!==this.findAppWindow().getViewModeMgr().getViewMode()&&this.parentPanel.getGrid().switchCM(t),this.parentPanel.getGrid().getGridCM().columns.forEach(function(t){var i=e.get(t.dataIndex);void 0!==i&&(!0!==t.sortable||!1!==t.hidden&&!0!==t.hideable?i.setVisible(!1):i.setVisible(!0))},this),e.get("score").setVisible("search"===t),e.items.each(function(e){e.setChecked&&e.setChecked(e.itemId===this.getSortType())},this)}}),Ext.define("SYNO.SDS.Drive.Comp.ViewModeButton",{extend:"SYNO.SDS.Drive.SimpleButton",defaultMode:"list",constructor:function(e){var t=SYNO.SDS.Drive._T,i={tabIndex:-1,itemId:"view_mode",cls:"syno-d-viewmode-btn viewmode-list",disabled:!1,tooltip:t("view","list_mode"),menu:{items:[{itemId:"list",text:t("view","list_mode"),tooltip:t("view","list_mode"),iconCls:"syno-d-viewmode-menu menu-list"},{itemId:"compact",text:t("view","compact_mode"),tooltip:t("view","compact_mode"),iconCls:"syno-d-viewmode-menu menu-compact"},"-",{itemId:"detail",text:t("view","detail_mode"),tooltip:t("view","detail_mode"),iconCls:"syno-d-viewmode-menu menu-detail"},{itemId:"thumbnail",text:t("view","thumb_mode"),tooltip:t("view","thumb_mode"),iconCls:"syno-d-viewmode-menu menu-thumbnail"},{itemId:"tile",text:t("view","tile_mode"),tooltip:t("view","tile_mode"),iconCls:"syno-d-viewmode-menu menu-tile"},{itemId:"snippet",text:t("view","snippet_mode"),tooltip:t("view","snippet_mode"),iconCls:"syno-d-viewmode-menu menu-snippet",hidden:!0}],listeners:{scope:this,itemclick:this.onItemClick,show:this.onMenuShow}},listeners:{scope:this,single:!0,beforeshow:this.onBeforeShow}};Ext.apply(i,e||{}),this.appWin=e.appWindow,this.callParent([i]),this.onRegEvent()},onRegEvent:function(){var e=this.appWin.getEventMgr();this.mon(e,{scope:this,viewmodechange:this.onViewModeChage})},onMenuShow:function(){SYNO.SDS.Drive.Utils.isDriveAppWindow(this.findAppWindow())&&"search"===SYNO.SDS.Drive.GetWindow().getNavigation().getCategory()?this.menu.get("snippet").show():this.menu.get("snippet").hide(),this.menu.doLayout()},onBeforeShow:function(){this.onViewModeChage(this.appWin.getViewModeMgr().getViewMode())},onItemClick:function(e){this.appWin.getViewModeMgr().setViewMode(e.itemId),this.setTooltip(e.tooltip)},onViewModeChage:function(e){if("empty"!==e){var t=String.format("viewmode-{0}",this.currentMode),i=String.format("viewmode-{0}",e);this.el.removeClass(t),this.el.addClass(i),"snippet"!==this.currentMode&&"label"!==this.currentMode&&(this.previousMode=this.currentMode),this.currentMode=e;var n=this.menu.get(e);n&&this.setTooltip(n.tooltip)}},setViewMode:function(e){var t=this.menu.get(e);t&&this.onItemClick(t)},setPrevViewMode:function(){this.setViewMode(this.getPreviousMode())},getPreviousMode:function(){return this.previousMode||this.defaultMode},getCurrentMode:function(){return this.currentMode||this.defaultMode}}),Ext.define("SYNO.SDS.Drive.Comp.FilterButton",{extend:"SYNO.SDS.Drive.SimpleButton",itemId:"filter",constructor:function(e){var t=SYNO.SDS.Drive._T,i=e.items||[{itemId:"any",text:t("share","share_permission_any")}],n={tabIndex:-1,itemId:"filter",tooltip:t("common","filter"),cls:"syno-d-filter-btn",menu:new SYNO.SDS.Drive.SelMenu({owner:e.appWindow,defaults:{checked:!1},items:i,listeners:{scope:this,itemclick:this.onItemClick,beforeshow:this.onBeforeShow}})};Ext.apply(n,e||{}),this.callParent([n])},getMenuClass:function(){return""},onItemClick:function(e,t){this.getFilterType()!==e.itemId&&(this.findAppWindow().getStoreMgr().getActiveStore().setFilterStatus(e.itemId),this.findAppWindow().getStoreMgr().onStoreReload(),this.changeCls(e.itemId))},changeCls:function(e){"any"===e?(this.el.removeClass("syno-d-filter-on-btn"),this.el.addClass("syno-d-filter-btn")):(this.el.removeClass("syno-d-filter-btn"),this.el.addClass("syno-d-filter-on-btn"))},getFilterType:function(){return this.findAppWindow().getStoreMgr().getActiveStore().getFilterStatus()||"any"},onBeforeShow:function(e){e.items.each(function(e){e.setChecked&&e.setChecked(e.itemId===this.getFilterType())},this)}}),Ext.define("SYNO.SDS.Drive.Comp.SimpleSplitButton",{extend:"SYNO.SDS.Drive.SimpleButton",constructor:function(e){var t={tabIndex:-1,cls:"syno-d-simple-split-btn",margins:"0 0 0 6",menu:this.getMenu(e)};Ext.apply(t,e||{}),this.appWindow=e.appWindow,this.callParent([t])},onClickItem:function(e,t,i){this.setText(e.text);var n=this.menu.items.items;Ext.each(n,function(e){e.setChecked(!1)},this),e.setChecked(!0),this.menu.hide()},getCheckedId:function(){var e,t=this.menu.items.items;return Ext.each(t,function(t){if(t.checked)return e=t.itemId,!1},this),e},getItemText:function(e){if(!e)return"";var t=this.menu.get(e);return t?t.text:""},setCheckedId:function(e){var t=this.menu.get(e);t&&this.onClickItem(t)},getMenu:Ext.emptyFn}),Ext.define("SYNO.SDS.Drive.Comp.SharedItemButton",{extend:"SYNO.SDS.Drive.Comp.SimpleSplitButton",constructor:function(e){var t={itemId:"shared_items",text:SYNO.SDS.Drive._T("category","shared_with_me"),hidden:!0};Ext.apply(t,e||{}),this.callParent([t])},getMenu:function(e){return this.menu?this.menu:(this.menu=new SYNO.SDS.Drive.SelMenu({owner:e.appWindow,defaults:{checked:!1},items:[{itemId:"shared_with_me",text:SYNO.SDS.Drive._T("category","shared_with_me"),checked:!0},{itemId:"sharing_to_others",text:SYNO.SDS.Drive._T("category","sharing_to_others")}],listeners:{scope:this,itemclick:this.onClickItem}}),this.menu)},onClickItem:function(e,t){return this.callParent(arguments),this.appWindow.getNavigation().setCategory(e.itemId,void 0,void 0,!0),!1}}),Ext.define("SYNO.SDS.Drive.Comp.RecycleButton",{extend:"SYNO.SDS.Drive.Comp.SimpleSplitButton",lastTime:0,cacheTime:3e3,constructor:function(e){this.recycleBinFolderTips=e.recycleBinFolderTips;var t={itemId:"recycle",listeners:{scope:this,afterrender:this.onAfterRender,hide:this.onHide,show:this.onShow}};Ext.apply(t,e||{}),this.callParent([t]),this.onRegEvent()},onRegEvent:function(){var e=this.appWindow.getEventMgr();this.mon(e,"envready",this.onBeforeShow,this)},getMenu:function(e){return this.menu?this.menu:(this.menu=new SYNO.SDS.Drive.SelMenu({owner:e.appWindow,defaults:{checked:!1},items:[],listeners:{scope:this,itemclick:this.onClickItem,beforeshow:this.onBeforeShow}}),this.menu)},onClickItem:function(e,t){return this.callParent(arguments),this.appWindow.getNavigation().setCategoryAndPath("recycle",void 0,void 0,void 0,void 0,!0),!1},onBeforeShow:function(){var e=(new Date).getTime();e-this.lastTime<this.cacheTime||(this.lastTime=e,SYNO.SDS.Drive.WebAPICore.sendPromise("list_team_folders",{}).then(this.onAddTeamFolders.bind(this)).catch(Ext.emptyFn))},onAddTeamFolders:function(e){this.init=!0;var t=this.getCheckedId();this.menu.removeAll(),SYNO.SDS.Drive.Define.Info.is_home&&this.menu.add({itemId:"node",text:SYNO.SDS.Drive._T("category","node")}),Ext.each(e.items,function(e){this.menu.add({itemId:e.file_id,text:e.name}),this.initName&&(this.initName===e.name&&(t=e.file_id),this.initName=null)},this);var i;if(!(i=Ext.isEmpty(t)?this.menu.items.items[0]:this.menu.get(t)))return this.hide(),void this.appWindow.getEventMgr().fireEvent("recycle_ready",this);this.setText(i.text),i.setChecked(!0),this.appWindow.getEventMgr().fireEvent("recycle_ready",this)},setCheckedName:function(e){if(this.init){var t=this.getCheckedId(),i=this.menu.items.items;Ext.each(i,function(i){if(e===i.text)return t!==i.itemId&&this.setCheckedId(i.itemId),!1},this)}else this.initName=e},onAfterRender:function(){if(!1!==_S("is_admin")){void 0===this.findAppWindow().appInstance.getUserSettings("display_recycle_bin_folder_tips")&&this.findAppWindow().appInstance.setUserSettings("display_recycle_bin_folder_tips",!0),this.recycleBinFolderTips._$vueInst.init(Ext.getCmp(this.id)),0===this.menu.items.length&&this.recycleBinFolderTips._$vueInst.hide()}},onHide:function(){this.recycleBinFolderTips._$vueInst.hide(),this.callParent(arguments)},onShow:function(){0!==this.menu.items.length&&(_S("is_admin")&&!1!==this.findAppWindow().appInstance.getUserSettings("display_recycle_bin_folder_tips")&&this.recycleBinFolderTips._$vueInst.show(),this.callParent(arguments))}}),Ext.define("SYNO.SDS.Drive.Comp.MainPanel",{extend:"Ext.Panel",constructor:function(e){this.module=e.module,this.owner=e.owner,this.appWin=this.findAppWindow();var t={cls:"syno-d-mgr-right",border:!1,itemId:"main",region:"center",layout:"card",activeItem:this.appWin.getViewModeMgr().getViewMode(),boxMaxWidth:SYNO.SDS.Drive.WindowHelper.isPublicShare()?1e3:void 0,defaults:{border:!1},tbar:this.getToolbar(),items:this.getPanelItems()};Ext.apply(t,e||{}),this.callParent([t])},onRegEvent:function(){var e=this.appWin.getEventMgr();this.mon(e,{scope:this,beforeviewpanelload:this.onBeforePanelLoad,viewpanelload:this.onPanelLoadDone,viewpanelfail:this.onPanelLoadFail,viewmodechange:this.onViewModeChage})},getPanelItems:function(){return[this.getGrid(),this.getCompactPanel(),this.getDetailPanel(),this.getThumbnailPanel(),this.getTilePanel(),this.getEmptyPanel()]},getEmptyPanel:function(){return this.emptypanel?this.emptypanel:this.emptypanel=new SYNO.SDS.Drive.Comp.EmptyPanel({itemId:"empty",hideMode:"offsets",owner:this})},getPathBar:function(){return this.pathbar?this.pathbar:(this.pathbar=new SYNO.SDS.Drive.Comp.Path({appWin:this.findAppWindow(),listeners:{beforeshowarrow:this.onBeforeShowArrow,pathbarclick:this.onPathbarClick,resize:this.onPathResize,scope:this}}),this.pathbar)},onBeforeShowArrow:function(){return!1},onPathbarClick:function(e,t,i,n){var o=this.findAppWindow().getNavigation(),s=o.getPath();o.setCategoryAndPath(o.getCategory(),s.slice(0,parseInt(t)+1),void 0,void 0,void 0,!0)},onPathResize:function(){var e=this.getPathBar();e.getLastBtn()&&e.updateLastPathBtnWidth()},getSharedItemBtn:function(){return this.sharedItemBtn?this.sharedItemBtn:(this.sharedItemBtn=new SYNO.SDS.Drive.Comp.SharedItemButton({appWindow:this.appWin}),this.sharedItemBtn)},getRecycleBtn:function(){return this.recycleBtn?this.recycleBtn:(this.recycleBtn=new SYNO.SDS.Drive.Comp.RecycleButton({appWindow:this.appWin,recycleBinFolderTips:this.recycleBinFolderTips}),this.recycleBtn)},getRecycleBinFolderTips:function(){return this.recycleBinFolderTips?this.recycleBinFolderTips:(this.recycleBinFolderTips=new SYNO.SDS.Drive.VuePanel({vueClass:SYNO.SDS.Drive.Vue.RecycleBinFolderTips,mountId:"recycleBinFolderTips",layout:"fit",cls:"RecycleBinFolderTips"}),this.recycleBinFolderTips)},getViewModeBtn:function(){return this.viewModeBtn?this.viewModeBtn:(this.viewModeBtn=new SYNO.SDS.Drive.Comp.ViewModeButton({appWindow:this.appWin}),this.viewModeBtn)},getSortBtn:function(){return this.sortBtn?this.sortBtn:(this.sortBtn=new SYNO.SDS.Drive.Comp.SortButton({appWindow:this.appWin,parentPanel:this}),this.sortBtn)},getFilterBtn:function(){if(this.filterBtn)return this.filterBtn;var e=SYNO.SDS.Drive._T;return this.filterBtn=new SYNO.SDS.Drive.Comp.FilterButton({appWindow:this.appWin,items:[{itemId:"any",text:e("share","share_permission_any")},{itemId:"active",text:e("common","active")},{itemId:"inactive",text:e("common","inactive")},{itemId:"error",text:e("common","error")}]}),this.filterBtn},onBeforePanelLoad:function(e){this.removeClass("syno-d-mgr-empty-grid"),this.setActivePanel(e)},onPanelLoadDone:function(e,t){var i=this.findAppWindow(),n=i.getNavigation(),o=n.getCategory();if(!SYNO.SDS.Drive.WindowHelper.isPublicShare()&&Ext.getClassByName("SYNO.SDS.Drive.MainWindow")&&i instanceof SYNO.SDS.Drive.MainWindow&&"search"!==o&&1>=n.getPath().length&&0===e.length?(this.setActivePanel("empty"),this.getEmptyPanel().onUpdate()):("search"===o&&0===e.length?this.addClass("syno-d-mgr-empty-grid"):this.removeClass("syno-d-mgr-empty-grid"),this.setActivePanel(t)),!this.blLoadInit&&n.isRootPath()&&SYNO.SDS.Drive.WindowHelper.isPublicShare()){var s=!1;Ext.each(e,function(e){if("dir"===e.data.ntype)return s=!0,!1}),s&&this.getTopToolbar().setHeight(83),this.blLoadInit=!0}this.onCheckToolbar(),this.onCheckSharedLabel()},onPanelLoadFail:function(e){this.setActivePanel("empty"),this.getEmptyPanel().onUpdateText("error",SYNO.SDS.Drive.Utils.getErrorStr(e)),this.sharedLabelPanelFailed(e)},onViewModeChage:function(e){var t=this.getActivePanel().getSelections(),i=this.layout;i.activeItem!==i.container.getComponent(e)&&i.setActiveItem(e);var n=this.getActivePanel();n.selectRecords(t),n.onUpdateScrollbar&&n.onUpdateScrollbar(!0)},onCheckSharedLabel:function(){var e=this.findAppWindow(),t=e.getNavigation().getCategory();if(SYNO.SDS.Drive.Utils.isLabelCategory(t)){if(!e.getCategoryPanel)return;var i=t,n=e.getCategoryPanel(),o=n.getSharedLabelStore(),s=o.getById("shared_label:"+i);if(void 0===s||!s.get("is_new_label"))return;e.getWebAPI().setTag({params:{label_id:t,is_new_label:!1,update_is_new_label:!0},scope:this,callback:function(e,t){e&&n.updateTreeNode("shared_label",i,void 0,void 0,!1)}})}},sharedLabelPanelFailed:function(e){var t=this.findAppWindow();1075===e.code&&t.getMsgBox().alert("",SYNO.SDS.Drive.Utils.getErrorStr(e))},setActivePanel:function(e){var t=this.findAppWindow().getViewModeMgr();e!==t.getViewMode()&&t.setViewMode(e)},setEmptyText:function(e){Ext.each(this.items.items,function(t){Ext.isFunction(t.setEmptyText)&&t.setEmptyText(e)})},getActivePanel:function(){return this.layout.activeItem},getGrid:function(){},getCompactPanel:function(){},getDetailPanel:function(){},getThumbnailPanel:function(){},getTilePanel:function(){},getToolbar:function(){}}),Ext.define("SYNO.SDS.Drive.Upload.LabelPanel",{extend:"SYNO.ux.GridPanel",mixins:["SYNO.SDS.Drive.Comp.SelectionModel","SYNO.SDS.Drive.Comp.PanelEventHandler","SYNO.SDS.Drive.Comp.KeyEventHandler"],constructor:function(e){this.module=e.module,this.owner=e.owner,this.appWin=this.findAppWindow();var t={enableHdMenu:!1,hideHeaders:!0,loadMask:!0,colModel:this.getGridCM(),selModel:this.getSelModel(),store:this.getActiveStore(),view:this.getGridView(),listeners:{scope:this,activate:function(){this.onRegEvent(),this.getView().focusEl.focus(100)},deactivate:function(){this.unRegEvent()},rowdblclick:this.onRowDbClick}};Ext.apply(t,e||{}),this.callParent([t]),this.initKeyEvent()},getGridView:function(){return new SYNO.ux.FleXcroll.grid.BufferView({rowHeight:36,borderHeight:1,forceFit:!0,disableTextSelect:!0})},getGridCM:function(){return new Ext.grid.ColumnModel({defaults:{menuDisabled:!0},columns:[{dataIndex:"name",renderer:function(e,t,i,n,o,s){var r=String.format('<div id="{0}" class="syno-d-color" style="background-color:#{1}; color:#FFF;"></div>',Ext.id(),i.get("color"));return r+=String.format("<span>{0}<span>",Ext.util.Format.htmlEncode(e))}}]})},getSelModel:function(){return new Ext.grid.RowSelectionModel({singleSelect:!0})},getActiveStore:function(){return this.activeStore=this.findAppWindow().getStoreMgr().getActiveStore(),this.activeStore},isViewMasked:function(){return this.getGridEl().isMasked()},maskView:function(e,t){this.getGridEl().mask(e,t)},unmaskView:function(){this.getGridEl().unmask()},onViewStoreChange:function(e,t,i){this.reconfigure(this.getActiveStore(),this.getGridCM())},onRowDbClick:function(e,t,i,n){var o=this.getActiveStore().getAt(t);this.findAppWindow().getNavigation().appendPath({id:o.id,text:o.data.name,skip_load:!0})},focusItem:function(e){this.getView().focusRow(e)}},SYNO.SDS.Drive.Framework.postDefine),Ext.define("SYNO.SDS.Drive.Upload.DriveMainPanel",{extend:"SYNO.SDS.Drive.Comp.MainPanel",enableSelectDir:!1,constructor:function(e){this.callParent(arguments),this.onRegEvent()},onRegEvent:function(){this.callParent(arguments);var e=this.appWin.getEventMgr();this.mon(e,{scope:this,beforecategorychange:this.onBeforeSetCategory,nodeselectchange:this.onSelectionChange})},getPanelItems:function(){var e=this.callParent(arguments);return e.push(this.getLabelPanel()),e},getGrid:function(){return this.grid?this.grid:this.grid=new SYNO.SDS.Drive.Upload.GridPanel({itemId:"list",hideMode:"offsets",mode:"grid",owner:this})},getCompactPanel:function(){return this.compactpanel?this.compactpanel:this.compactpanel=new SYNO.SDS.Drive.Upload.GridPanel({itemId:"compact",hideMode:"offsets",mode:"compact",owner:this})},getDetailPanel:function(){return this.detailpanel?this.detailpanel:this.detailpanel=new SYNO.SDS.Drive.Upload.GridPanel({itemId:"detail",hideMode:"offsets",mode:"detail",owner:this})},getThumbnailPanel:function(){return this.thumbnailpanel?this.thumbnailpanel:this.thumbnailpanel=new SYNO.SDS.Drive.Comp.DataViewPanel({itemId:"thumbnail",cls:"syno-d-thumbnail-view",Dataview:SYNO.SDS.Drive.Comp.ThumbnailView,hideMode:"offsets",owner:this})},getTilePanel:function(){return this.tilepanel?this.tilepanel:this.tilepanel=new SYNO.SDS.Drive.Comp.DataViewPanel({itemId:"tile",cls:"syno-d-tile-view",Dataview:SYNO.SDS.Drive.Comp.TileView,hideMode:"offsets",owner:this})},getLabelPanel:function(){return this.labelpanel?this.labelpanel:this.labelpanel=new SYNO.SDS.Drive.Upload.LabelPanel({itemId:"label",cls:"syno-d-upload-label-panel",hideMode:"offsets",owner:this})},getToolbar:function(){return this.navitbar?this.navitbar:this.navitbar=new Ext.Toolbar({height:36,items:[this.getPathBar(),"->",this.getSharedItemBtn(),this.getViewModeBtn(),this.getSortBtn()],listeners:{single:!0,afterlayout:function(e){this.mon(e,"resize",this.onUpdatePathbar,this)},scope:this}})},onCheckToolbar:function(){var e=this.findAppWindow(),t=e.getNavigation(),i=t.getCategory();this.navitbar.get("shared_items").setVisible("shared_items"===e.getActiveCategory());var n=this.navitbar.get("sort"),o=this.navitbar.get("view_mode");"label"===i||"shared_label"===i?(n.setDisabled(t.isRootPath()),o.setDisabled(t.isRootPath())):(n.setDisabled(!1),o.setDisabled(!1),this.navitbar.get("sort").setVisible(!("recent"===i||"backup"===i||"team_folder"===i&&t.isRootPath()))),this.onUpdatePathbar()},onUpdatePathbar:function(){if(this.rendered){var e=0,t=this.navitbar;t.items.each(function(t){!0!==t.hidden&&t.rendered&&(e+=t.getOuterSize().width)}),e-=this.getPathBar().getWidth();var i=t.getWidth()-t.getResizeEl().getPadding("lr"),n=i-e+1-50;n>0&&this.getPathBar().setWidth(n)}},setEnableSelectDir:function(e){this.enableSelectDir=e||!1},onSelectionChange:function(){var e=this.getActivePanel().getSelections();0===e.length||!this.enableSelectDir&&this.hasDir(e)||this.beforeselectfn&&!this.beforeselectfn(e)?(this.findAppWindow().clearStatus(),this.findAppWindow().setApplyBtnDisabled(!0)):(this.findAppWindow().setStatus(String.format(SYNO.SDS.Drive._T("upload","items_selected"),e.length)),this.findAppWindow().setApplyBtnDisabled(!1))},hasDir:function(e){var t=!1;return Ext.each(e,function(e){if("dir"===e.data.ntype)return t=!0,!1}),t},onBeforeSetCategory:function(e,t){var i=this.findAppWindow().getNavigation();"label"!==e&&"shared_label"!==e||e===t&&!i.isRootPath()?"label"!==t&&"shared_label"!==t||this.viewModeBtn.setPrevViewMode():this.setActivePanel(e)},setBeforeSelection:function(e){this.beforeselectfn=e},getResults:function(){var e=[],t=this.findAppWindow().getNavigation(),i=this.getActivePanel();return Ext.isFunction(i.getSelections)?(Ext.each(i.getSelections(),function(i){var n=i.data;n.source="share_folder"===t.getCategory()?"from_nas":"from_drive",e.push(n)}),e):[]},isValid:function(){return!0},getError:function(){return""},isDirty:function(){return 0<this.getResults().length},setSingleSelect:function(e){this.items.each(function(t){this.getLabelPanel()!==t&&"empty"!==t.itemId&&(t.dataview?(t.dataview.multiSelect=!e,t.dataview.singleSelect=e):t.getSelectionModel&&(t.getSelectionModel().singleSelect=e))},this)},setViewSize:function(e){var t=this.getActivePanel();this.items.each(function(i){this.getLabelPanel()!==i&&this.getEmptyPanel()!==i&&i.dataview&&i.dataview.setViewSize&&i.dataview.setViewSize(e,i===t)},this)}}),Ext.define("SYNO.SDS.Drive.Upload.URLPanel",{extend:"SYNO.ux.FormPanel",constructor:function(e){var t=SYNO.SDS.Drive._T,i={cls:"syno-d-upload-url-panel",labelAlign:"top",items:[{xtype:"syno_textfield",name:"url_field",itemId:"url_field",fieldLabel:t("upload","paste_url"),cls:"syno-d-upload-url-field",allowBlank:!1,enableKeyEvents:!0,validator:function(e){var t=this.isValidURL(e);return this.findAppWindow().setApplyBtnDisabled(!t),t}.bind(this),listeners:{scope:this,buffer:100,keyup:function(e){var t=this.isValidURL(e.getValue());this.findAppWindow().setApplyBtnDisabled(!t)}}}]};Ext.apply(i,e||{}),this.callParent([i])},isValidURL:function(e){return!!/^(?:https?|ftps?|sftp):\/\/[^\s\$.?#].[^\s]*$/i.exec(e)},getResults:function(){return[{source:"from_url",url:this.form.findField("url_field").getValue()}]},isValid:function(){return this.form.isValid()},getError:function(){return""},isDirty:function(){return this.form.isDirty()}}),Ext.define("SYNO.SDS.Drive.Upload.YouTubeURLPanel",{extend:"SYNO.ux.FormPanel",constructor:function(e){var t=SYNO.SDS.Drive._T,i={cls:"syno-d-upload-url-panel",labelAlign:"top",
items:[{xtype:"syno_compositefield",fieldLabel:t("upload","paste_youtube_url"),style:{"padding-top":"8px"},items:[{xtype:"syno_displayfield",cls:"syno-d-upload-youtube-icon"},{xtype:"syno_textfield",name:"youtube_url_field",itemId:"youtube_url_field",cls:"syno-d-upload-url-field",style:{"margin-left":"3px"},allowBlank:!1,enableKeyEvents:!0,validator:function(e){var t=this.isValidURL(e);return this.findAppWindow().setApplyBtnDisabled(!t),t}.bind(this),listeners:{scope:this,buffer:100,keyup:function(e){var t=this.isValidURL(e.getValue());this.findAppWindow().setApplyBtnDisabled(!t)}}}]}]};Ext.apply(i,e||{}),this.callParent([i])},isValidURL:function(e){return!!/^https?:\/\/(?:[^/]*\.)?(youtu\.be\/|youtube\.com\/watch\?(?:.*&)?v=)[\w\-]+/.exec(e)},getResults:function(){return[{source:"from_youtube_url",url:this.form.findField("youtube_url_field").getValue()}]},isValid:function(){return this.form.isValid()},getError:function(){return""},isDirty:function(){return this.form.isDirty()}}),Ext.define("SYNO.SDS.Drive.Upload.DnDPanel",{extend:"SYNO.ux.FormPanel",mixins:["SYNO.SDS.Drive.Comp.DragDropHandler"],constructor:function(e){var t=SYNO.SDS.Drive._T,i={type:"vbox",pack:"center",align:"center"},n={cls:"syno-d-upload-dnd-panel",layout:i,items:[{xtype:"container",cls:"syno-d-upload-container",layout:i,items:[{xtype:"syno_displayfield",cls:"syno-d-upload-drag-here",value:t("upload","drag_here")},{xtype:"syno_displayfield",cls:"syno-d-upload-or",value:t("upload","or_you_can")},{xtype:"synodrive_filebutton",itemId:"upload",buttonConfig:{btnStyle:"default"},buttonText:t("upload","upload_from_pc"),buttonOnly:!0,listeners:{scope:this,change:this.onFileChange}}]}],listeners:{scope:this,afterlayout:{single:!0,fn:this.initDragDrop}}};Ext.apply(n,e||{}),this.callParent([n])},onMask:function(){this.el.addClass("syno-d-upload-dragover")},unMask:function(){this.el.removeClass("syno-d-upload-dragover")},onFileChange:function(e,t){var i=this.findAppWindow();SYNO.SDS.Drive.Utils.checkFileCanUpload(e,t).then(function(){i.getEventMgr().fireEvent("uploadfilechange",e,t)}.bind(this)).catch(function(e){SYNO.SDS.Drive.Utils.showAlertMsg(i,e)})},setFileBtnAttributes:function(e){this.form.findField("upload").setAttributes(e)}},SYNO.SDS.Drive.Framework.postDefine),Ext.define("SYNO.SDS.Drive.Upload.UploadPanel",{extend:"SYNO.ux.Panel",constructor:function(e){var t={cls:"syno-d-upload-main-panel",layout:"card",activeItem:0,items:[this.getDnDPanel(),this.getFromPCPanel()]};Ext.apply(t,e||{}),this.callParent([t]),this.onRegEvent()},onRegEvent:function(){var e=this.findAppWindow().getEventMgr();this.mon(e,{scope:this,uploadfilechange:this.onFileChange})},getDnDPanel:function(){return this.dndPanel?this.dndPanel:(this.dndPanel=new SYNO.SDS.Drive.Upload.DnDPanel({itemId:"dnd_panel",owner:this}),this.dndPanel)},getFromPCPanel:function(){return this.fromPCPanel?this.fromPCPanel:(this.fromPCPanel=new SYNO.SDS.Drive.Upload.FromPCPanel({itemId:"from_pc_panel",owner:this}),this.fromPCPanel)},onFileChange:function(e,t){0<e.length&&(this.fromPCPanel.addFiles(e,t),this.layout.setActiveItem("from_pc_panel"))},setFileBtnAttributes:function(e){this.fromPCPanel.setFileBtnAttributes(e),this.dndPanel.setFileBtnAttributes(e)},getResults:function(){return this.fromPCPanel.getResults()},cleanAll:function(){this.fromPCPanel.cleanAll(),this.layout.setActiveItem("dnd_panel")},isValid:function(){return!(this.singleSelect&&!this.getFromPCPanel().getGridPanel().getSelectionModel().hasSelection())},getError:function(){return this.singleSelect?SYNO.SDS.Drive._T("upload","select_one"):""},isDirty:function(){return this.fromPCPanel.isDirty()},setSingleSelect:function(e){this.singleSelect=e}}),Ext.define("SYNO.SDS.Drive.Upload.StoreMgr",{extend:"SYNO.SDS.Drive.StoreMgr",createStores:function(){this.callParent(arguments),this.stores.share_folder=new SYNO.SDS.Drive.Upload.Store.ShareFolder({appWindow:this.appWindow}),this.stores.tag&&this.stores.tag.destroy(),this.stores.tag=new SYNO.SDS.Drive.Upload.Store.Tag({appWindow:this.appWindow}),this.stores.label&&this.stores.label.destroy(),this.stores.label=new SYNO.SDS.Drive.Upload.Store.Label({appWindow:this.appWindow})},onPathChange:function(e,t,i,n){var o=this.appWindow.getNavigation(),s=this.appWindow.getViewModeMgr(),r=!1;if(n){var a;switch(i){case"starred":case"team_folder":case"shared_with_me":case"sharing_to_others":case"backup":a=this.activeStore,o.isRootPath()?this.activeStore=this.stores[i]:this.activeStore=this.stores.node,a!==this.activeStore&&(r=!0);break;case"label":if(a=this.activeStore,o.isRootPath())this.activeStore=this.stores.label,s.setViewMode(i);else{t.length<=2?this.activeStore=this.stores.tag:this.activeStore=this.stores.node;this.appWindow.getDrivePanel().getViewModeBtn().setPrevViewMode()}a!==this.activeStore&&(r=!0);break;case"share_folder":r=!0}r&&this.appWindow.getEventMgr().fireEvent("viewstorechange",i,null,this.activeStore),"search"!==i&&this.onStoreReload(!0,{params:{offset:0,limit:1e3}},!0)}}}),Ext.ns("SYNO.SDS.Drive"),SYNO.SDS.Drive.Layout=function(){SYNO.SDS.Drive.isRunLayout||(SYNO.SDS.Drive.isRunLayout=!0,SYNO.ux.FormPanel.prototype.labelWidth=150,SYNO.ux.FormPanel.prototype.labelPad=10,SYNO.ux.FormPanel.prototype.fieldWidth=344,SYNO.SDS.Utils.FormPanel.prototype.labelWidth=150,SYNO.SDS.Utils.FormPanel.prototype.labelPad=10,SYNO.SDS.Utils.FormPanel.prototype.fieldWidth=344,Ext.grid.GridView.prototype.emptyText=_TT("SYNO.SDS.Drive.Application","common","no_data"),Ext.grid.GridView.prototype.applyEmptyText=function(){this.emptyText&&(this.hasRows()?this.grid.el.removeClass("syno-d-mgr-empty-grid"):(this.grid.el.addClass("syno-d-mgr-empty-grid"),this.mainBody.update('<div class="x-grid-empty">'+this.emptyText+"</div>")))},SYNO.ux.GridPanel.prototype.useNewStyle=!0,SYNO.ux.GridPanel.prototype.ori_initEvents=SYNO.ux.GridPanel.prototype.initEvents,SYNO.ux.GridPanel.prototype.initEvents=function(e,t){SYNO.ux.GridPanel.prototype.ori_initEvents.apply(this,arguments);var i=this.findWindow()||this.findAppWindow();i&&this.mon(i,"show",function(){var e=this.bwrap;e&&e.isMasked()&&this.loadMask.show()},this,{single:!0})},SYNO.ux.ComboBox.prototype.listAlign=["tl-bl?",[0,2]],SYNO.ux.SuperBoxSelect.prototype.listAlign=["tl-bl?",[0,2]],SYNO.SDS.BaseWindow.prototype.getMsgBox=function(e){if(!this.msgBox||this.msgBox.isDestroyed){var t=e&&e.owner||this;t=t.isDestroyed?null:t,this.isV5Style()?this.msgBox=new SYNO.SDS.MessageBoxV5({owner:t,preventDelay:!!e&&(e.preventDelay||!1),draggable:!!e&&(e.draggable||!1)}):this.msgBox=new SYNO.SDS.MessageBox({owner:t})}return this.msgBox.getWrapper(Ext.apply(e||{},{btnStyle:"default"}))},SYNO.SDS.MessageBoxV5.prototype.old_getButtons=SYNO.SDS.MessageBoxV5.prototype.getButtons,SYNO.SDS.MessageBoxV5.prototype.getButtons=function(e){var t=SYNO.SDS.MessageBoxV5.prototype.old_getButtons.apply(this,arguments);return Ext.each(t,function(e){e.transitionFocus=Ext.emptyFn}),t},SYNO.ux.DateTimePicker.prototype.old_onRender=SYNO.ux.DateTimePicker.prototype.onRender,SYNO.ux.DateTimePicker.prototype.onRender=function(){SYNO.ux.DateTimePicker.prototype.old_onRender.apply(this,arguments),this.todayBtn&&this.todayBtn.removeClass("syno-ux-button-default").addClass("syno-ux-button-grey"),this.clearBtn&&this.clearBtn.removeClass("syno-ux-button-default").addClass("syno-ux-button-grey")},SYNO.ux.FileButton.prototype.buttonConfig={btnStyle:"grey"},Ext.Button.prototype.ori_initComponent=Ext.Button.prototype.initComponent,Ext.Button.prototype.initComponent=function(){Ext.Button.prototype.ori_initComponent.apply(this,arguments),this.menu&&!this.menu.defaultOffsets&&(this.menu.defaultOffsets=[0,2])},SYNO.ux.Button.prototype.updateButtonStyle&&(SYNO.ux.Button.prototype.updateButtonStyle=function(e){this.addClass("syno-ux-button"),"blue"===this.btnStyle?this.addClass("syno-ux-button-blue"):"grey"===this.btnStyle?this.addClass("syno-ux-button-grey"):"red"===this.btnStyle?this.addClass("syno-ux-button-red"):"green"===this.btnStyle?this.addClass("syno-ux-button-green"):"orange"===this.btnStyle?this.addClass("syno-ux-button-orange"):"none"===this.btnStyle||this.addClass("syno-ux-button-default")}),SYNO.ux.SplitButton.prototype.updateButtonStyle&&(SYNO.ux.SplitButton.prototype.updateButtonStyle=function(e){this.addClass("syno-ux-button"),this.addClass("syno-ux-button-split"),"blue"===this.btnStyle?this.addClass("syno-ux-button-blue"):"grey"===this.btnStyle?this.addClass("syno-ux-button-grey"):"red"===this.btnStyle?this.addClass("syno-ux-button-red"):"green"===this.btnStyle?this.addClass("syno-ux-button-green"):"orange"===this.btnStyle?this.addClass("syno-ux-button-orange"):"none"===this.btnStyle||this.addClass("syno-ux-button-default")}),SYNO.ux.SearchField.prototype.ori_initComponent=SYNO.ux.SearchField.prototype.initComponent,SYNO.ux.SearchField.prototype.initComponent=function(){SYNO.ux.SearchField.prototype.ori_initComponent.apply(this,arguments),this.menu&&!this.menu.defaultOffsets&&(this.menu.defaultOffsets=[0,2])},SYNO.SDS.ModalWindow.prototype.fillWindowPadding=function(e){return Ext.applyIf(e,{padding:"12px 19px 0 19px"})},SYNO.SDS.ModalWindow.prototype.centerTitle=Ext.emptyFn,Ext.menu.Menu.prototype.shadow=!1,Ext.Panel.prototype.shadow=!1,SYNO.ux.SuperBoxSelect.prototype.shadow=!1,SYNO.SDS.Wizard.ModalWindow.prototype.ori_configButtons=SYNO.SDS.Wizard.ModalWindow.prototype.configButtons,SYNO.SDS.Wizard.ModalWindow.prototype.configButtons=function(e){var t=SYNO.SDS.Wizard.ModalWindow.prototype.ori_configButtons.apply(this,arguments).items[0].items,i=t.length-1;return"blue"!==t[i].btnStyle&&(i=t.length-1),t[i].btnStyle="default",t},SYNO.SDS.Wizard.ModalWindow.prototype.ori_configWizard=SYNO.SDS.Wizard.ModalWindow.prototype.configWizard,SYNO.SDS.Wizard.ModalWindow.prototype.configWizard=function(e){return arguments[0].width=640,SYNO.SDS.Wizard.ModalWindow.prototype.ori_configWizard.apply(this,arguments)},SYNO.ux.SuperBoxSelectItem.prototype.preDestroy=function(e){if((!0===this.owner.allowDeleteData||!this.owner.readOnly)&&!1!==this.fireEvent("remove",this)){var t=function(){this.owner.navigateItemsWithTab&&this.moveFocus("right"),this.hiddenEl.remove(),this.hidden=null,this.destroy()};return e?t.call(this):this.getEl().hide({duration:.2,callback:t,scope:this}),this}},Ext.QuickTip.prototype.ori_show=Ext.QuickTip.prototype.show,Ext.QuickTip.prototype.show=function(){Ext.QuickTip.prototype.ori_show.apply(this,arguments),this.setWidth("auto")},Ext.slider.SingleSlider.prototype.ori_moveThumb=Ext.slider.SingleSlider.prototype.moveThumb,Ext.slider.SingleSlider.prototype.moveThumb=function(e,t,i){-5>t&&(t=-5),Ext.slider.SingleSlider.prototype.ori_moveThumb.call(this,e,t,i)})},"SYNO.SDS.Drive.Application"!==_S("standaloneAppName")&&"SYNO.SDS.Drive.PublicApplication"!==_S("standaloneAppName")||SYNO.SDS.Drive.Layout(),Ext.define("SYNO.SDS.Drive.Env",{singleton:!0,constructor:function(){this.isPulicMode=SYNO.SDS.Drive.WindowHelper.isPublicShare(),this.supported=["file_id","isPulicMode","permanent_link","shared_with","labels"]},init:function(e){e.file_id?this.file_id=e.file_id:this.isPulicMode&&Ext.isFunction(window.getDriveFile)&&window.getDriveFile()&&SYNO.SDS.Drive.Env.set(window.getDriveFile())},set:function(e,t){Ext.isObject(e)?Ext.copyTo(this,e,this.supported):-1<this.supported.indexOf(e)&&(this[e]=t)},get:function(e,t){return this.hasOwnProperty(e)?this[e]:t}}),Ext.define("SYNO.SDS.Drive.AppInstance",{extend:"SYNO.SDS.AppInstance",skipRecord:!SYNO.SDS.Drive.Utils.isAppAuthorized(),constructor:function(){SYNO.SDS.Drive.AppInstance.superclass.constructor.apply(this,arguments);var e=["syno-d-theme"];SYNO.SDS.Drive.WindowHelper.isPublicShare()&&e.push("syno-d-public"),SYNO.SDS.Drive.Utils.isSmallScreenSize()&&e.push("syno-d-small-theme"),Ext.getBody().addClass(e)},setUserSettings:function(){SYNO.SDS.Drive.Utils.isAppAuthorized()&&SYNO.SDS.Drive.AppInstance.superclass.setUserSettings.apply(this,arguments)},beforeOpen:function(){if(this.isOldIE=Ext.isIE6||Ext.isIE7||Ext.isIE8||Ext.isIEQuirks||Ext.isIE9,this.isOldIE){return new SYNO.SDS.MessageBoxV5({modal:!0,draggable:!1,renderTo:document.body}).getWrapper().alert("",SYNO.SDS.Drive._T("error","not_support_ie8"),function(){try{window.close()}catch(e){}window.location.assign("/")}),!1}return!this.onCheckRedirect()},onCheckRedirect:function(){var e=Ext.urlDecode(window.location.search.substr(1));if(e.launchParam){var t=Ext.urlDecode(e.launchParam);if(t.link){var i,n=t.link,o=t.sharing_link;return i=o?SYNO.SDS.Drive.Sharing.GetURL(n,o):SYNO.SDS.Drive.Utils.getDriveLink(n),window.location.hash&&(i+=window.location.hash),window.location.href=i,!0}}return!1}}),Ext.define("SYNO.SDS.Drive.BasicVueApp",{extend:"SYNO.SDS.AppWindow",constructor:function(e){this.callParent([e])}}),Ext.define("SYNO.SDS.Drive.PrototypeWindow",{extend:"SYNO.SDS.Drive.BasicVueApp",aboutTitleColor:"#1EB9C7",constructor:function(e){SYNO.SDS.Drive.Utils.isAppAuthorized()&&!SYNO.SDS.Drive.Define.Info.ready&&this.getAction().initEnv(),this.callParent([this.fillConfig(e)]),SYNO.SDS.Drive.Utils.isAppAuthorized()&&!SYNO.SDS.System&&(SYNO.SDS.System=new SYNO.SDS._System)},isAlwaysOnBottom:function(){return!0},onOpen:function(e){return SYNO.SDS.Drive.Env.init(e),SYNO.SDS.Drive.PrototypeWindow.superclass.onOpen.apply(this,arguments)},onRequest:function(e){return SYNO.SDS.Drive.Env.init(e),SYNO.SDS.Drive.PrototypeWindow.superclass.onRequest.apply(this,arguments)},getWebAPI:function(){return this.webapimgr||(this.webapimgr=new SYNO.SDS.Drive.WebAPI({appWindow:this}))},getAction:function(){return this.actionmgr||(this.actionmgr=new SYNO.SDS.Drive.Action({}))},getStatusMgr:function(){return this.statusmgr},getEventMgr:function(){return this.eventmgr},getStoreMgr:function(){return this.storemgr},getViewModeMgr:function(){return this.viewmodemgr},getImageQueue:function(){return this.imagequeue},getTaskMgr:function(){return this.taskmgr},getDownloadMgr:function(){return this.downloadmgr},fillConfig:function(e){var t=this.getWinPanel(),i=[];i.push([this.getWinPanel(),this.getPermPanel()]);var n={renderTo:Ext.getBody(),height:Ext.lib.Dom.getViewHeight(!0),layout:"card",deferredRender:!0,activeItem:t,items:i};return n.useDefualtKey=!1,Ext.apply(n,e),n},getWinPanel:function(e){return this.winpanel||(this.winpanel=new Ext.Container({anchor:"100%, 100%",layout:"border",hideMode:"offsets",items:[this.getLeftPanel(),this.getMainPanel()]}))},getLeftPanel:function(){return this.toolbar||(this.toolbar=new SYNO.SDS.Drive.Toolbar({region:"west",owner:this}))},fillWindowPadding:function(){},getPermPanel:function(){return this.permPanel||(this.permPanel=new SYNO.SDS.Drive.PermPanel({})),this.permPanel},getImageLoader:function(){return SYNO.SDS.Drive.Utils.getImageLoader()},onBeforeDestroy:function(){this.getImageLoader().stop(),SYNO.SDS.Drive.PrototypeWindow.superclass.onBeforeDestroy.apply(this,arguments)},showAboutWindow:function(){var e=this.getJsConfig();if(this.showAboutWindowV2){var t=SYNO.SDS.Config.FnMap["SYNO.SDS.Drive.Application"].config.version,i=SYNO.SDS.Packages.getPkgId(e.jsID);this.manager.openModalWindow(SYNO.SDS.Drive.Vue.AboutWindowV2,{synoId:"drive-about-windowV2",title:SYNO.SDS.UIString.GetLocalizedString(e.title,e.jsID),tagline:SYNO.SDS.Drive._T("common","about_tagline"),icon:e.jsBaseURL.concat("/",e.icon,"/../","SynologyDrive_256_about.png"),copyrightYear:e.buildTime?e.buildTime.split("-")[0]:_S&&_S("builddate")?_S("builddate").split("/")[0]:"",beta:SYNO.SDS.Drive.Define.Info.beta,maskContainer:!0,version:t,releaseNotesUrl:"https://www.synology.com/releaseNote/SynologyDrive",fetchVersion:function(){return SYNO.SDS.Drive.WebAPICore.sendPromise(["list_package","get_package_info"],[{filter_ids:[i]},{}]).then(function(e){var t=SYNO.SDS.Drive.WebAPIDesc.list_package,i=SYNO.SDS.Drive.WebAPIDesc.get_package_info,n=SYNO.API.Util.GetValByAPI(e,t.api,t.method),o=SYNO.API.Util.GetValByAPI(e,i.api,i.method),s=n.packages||[],r=n.beta_packages||[],a=o.config;return{newVersion:s.length>0?s[0].version:null,betaVersion:a.blBetaChannel&&r.length>0?r[0].version:null}}).catch(function(e){return SYNO.Debug.error(e),{newVersion:null,betaVersion:null}})}.bind(this)})}else this.manager.openModalWindow(SYNO.SDS.Drive._Vue.prototype.$aboutWindow,{synoId:"drive-about-window",name:SYNO.SDS.UIString.GetLocalizedString(e.title,e.jsID),desc:"",icon:SYNO.SDS.UIFeatures.IconSizeManager.getIconPath(e.jsBaseURL.concat("/",e.icon),"desktop"),copyrightYear:e.buildTime?e.buildTime.split("-")[0]:_S&&_S("builddate")?_S("builddate").split("/")[0]:"",isBeta:SYNO.SDS.Drive.Define.Info.beta,swapNameAndDesc:!1,theme:{},customCls:""})}}),Ext.define("SYNO.SDS.Drive.BasicInstance",{extend:"SYNO.SDS.Drive.AppInstance",appWindowName:"SYNO.SDS.Drive.BasicApp"}),Ext.define("SYNO.SDS.Drive.BasicApp",{extend:"SYNO.SDS.Drive.BasicVueApp",constructor:function(e){var t=["syno-drive-theme"];SYNO.SDS.Drive.Utils.isSmallScreenSize()&&t.push("syno-d-small-theme"),Ext.getBody().addClass(t),this.addEvents({beforedestroy:!0}),this.callParent([this.fillConfig(e)])},fillConfig:function(e){var t,i=[],n=window.getDriveErrCode();1037===n?t=this.getPasswordPanel():(t=this.getPermPanel(),t.onUpdateByErrCode(n)),i.push([t]);var o={layout:"card",deferredRender:!0,activeItem:t,items:i};return o.useDefualtKey=!1,Ext.apply(o,e),o},getWebAPI:function(){return this.webapimgr||(this.webapimgr=new SYNO.SDS.Drive.WebAPI({appWindow:this}))},getAction:function(){return this.actionmgr||(this.actionmgr=new SYNO.SDS.Drive.Action({}))},getPermPanel:function(){return this.permPanel||(this.permPanel=new SYNO.SDS.Drive.PermPanel({})),this.permPanel},getPasswordPanel:function(){return this.passwdPanel||(this.passwdPanel=new SYNO.SDS.Drive.Share.AdvancedPasswordPanel({owner:this})),this.passwdPanel}}),Ext.define("SYNO.SDS.Drive.Comp.Navigation",{extend:"Ext.Component",category:"",defaultCategory:["node","team_folder","share_folder","backup","shared_with_me","sharing_to_others","file_request","recent","starred","recycle","search","label","shared_label"],paths:{node:[{id:"node",text:SYNO.SDS.Drive._T("category","node")}],team_folder:[{id:"team_folder",text:SYNO.SDS.Drive._T("category","team_folder")}],share_folder:[{id:"share_folder",text:SYNO.SDS.Drive._T("category","share_folder")}],shared_with_me:[{id:"shared_with_me",text:SYNO.SDS.Drive._T("category","shared_with_me")}],sharing_to_others:[{id:"sharing_to_others",text:SYNO.SDS.Drive._T("category","sharing_to_others")}],file_request:[{id:"file_request",text:SYNO.SDS.Drive._T("category","file_request")}],backup:[{id:"backup",text:SYNO.SDS.Drive._T("category","backup")}],recent:[{id:"recent",text:SYNO.SDS.Drive._T("category","recent")}],starred:[{id:"starred",text:SYNO.SDS.Drive._T("category","starred")}],recycle:[{id:"recycle",text:SYNO.SDS.Drive._T("category","recycle")}],search:[{id:"search",text:SYNO.SDS.Drive._T("category","search")}],label:[{id:"label",text:SYNO.SDS.Drive._T("category","label")}],shared_label:[{id:"shared_label",text:SYNO.SDS.Drive._T("category","shared_label")}]},routeNameMapping:{node:"MyDrive",team_folder:"TeamFolder",shared_with_me:"SharedWithMe",sharing_to_others:"SharedWithOthers",file_request:"FileRequest",backup:"ComputerBackup",recent:"Recent",starred:"Starred",recycle:"RecycleBin"},constructor:function(e){this.appWindow=e.appWindow,this.callParent(arguments);var t=this.findAppWindow().getEventMgr();this.mon(t,{scope:this,setnodetitledone:this.onSetNodeTitleDone,deletenodedone:this.onDeleteNodeDone,mvcpstart:this.onMVCPStart,restorestart:this.onRestoreStart,deleteshortcutdone:this.onRemoveStar,setnodetagdone:this.onSetTag,deletenodepermdone:this.onDeleteNodePerm})},getRouteName:function(e){return this.routeNameMapping[e]},getRouteKey:function(e){for(var t=Object.keys(this.routeNameMapping),i=0;i<t.length;++i)if(this.routeNameMapping[t[i]]===e)return t[i];return null},onSetNodeTitleDone:function(e,t,i){e&&t&&"dir"===t.type&&t.file_id===this.getLastPath().id&&(this.getLastPath().text=t.name,this.findAppWindow().getEventMgr().fireEvent("currentpathrename",t.name))},onDeleteNodeDone:function(e,t,i){if(e){var n=this.getLastPath().id;i.files.some(function(e){return n===SYNO.SDS.Drive.Utils.getFileIdFromPathId(e)})&&this.popPath()}},onMVCPStart:function(e,t,i){if("move"===e){var n=this.getLastPath().id;t.files.some(function(e){return n===SYNO.SDS.Drive.Utils.getFileIdFromPathId(e)})&&this.findAppWindow().getAction().onGotoPath({path:t.to_parent_folder})}},onRestoreStart:function(e,t){var i=this.getLastPath().id;e.files.some(function(e){return i===SYNO.SDS.Drive.Utils.getFileIdFromPathId(e.path)})&&this.popPath()},onRemoveStar:function(e,t,i){if(e){var n=this.getLastPath().id;i.files.some(function(e){return n===SYNO.SDS.Drive.Utils.getFileIdFromPathId(e)})&&"starred"===this.category&&this.popPath()}},onSetTag:function(e,t,i){if(e){var n=this.getLastPath().id;if(i.files.some(function(e){return n===SYNO.SDS.Drive.Utils.getFileIdFromPathId(e)})){var o=this.category;i.labels.some(function(e){return"delete"===e.action&&e.label_id===o})&&this.popPath()}}},onDeleteNodePerm:function(e,t,i){if(e&&"shared_with_me"===this.category){var n=this.getLastPath().id;i.compound.some(function(e){return n===SYNO.SDS.Drive.Utils.getFileIdFromPathId(e.path)})&&this.popPath()}},initPath:function(e,t){if(-1!==this.defaultCategory.indexOf(e)&&(t=SYNO.SDS.Drive._T("category",e)),SYNO.SDS.Drive.WindowHelper.isPublicShare()&&window.getDriveFile){var i=window.getDriveFile()||{};this.paths[e]=[{id:"node",text:i.name}]}else this.paths[e]=[{id:e,text:t}]},setDefaultCategory:function(){this.setCategoryAndPath(SYNO.SDS.Drive.Define.Info.is_home?"node":"team_folder")},setCategoryDragZone:function(e){var t=this.findAppWindow();t.getPanel&&t.getPanel()&&t.getPanel().getView&&t.getPanel().getView()&&t.getPanel().getView().dragZone&&("file_request"===e?this.findAppWindow().getPanel().getView().dragZone.lock():this.findAppWindow().getPanel().getView().dragZone.unlock())},setCategory:function(e,t,i,n){if(n||this.category!==e||Ext.isEmpty(this.category)||"search"===this.category){var o=this.findAppWindow(),s=this.category;this.setCategoryDragZone(e),o.getEventMgr().fireEvent("beforecategorychange",e,s),this.initPath(e,t),this.category=e,o.getEventMgr().fireEvent("categorychange",e,SYNO.Util.copy(i),s)}},getCategory:function(){return this.category},getCategoryText:function(){return this.isDefaultCategoryExist(this.getCategory())?this.getCategory():"label"},isDefaultCategoryExist:function(e){return-1!==this.defaultCategory.indexOf(e)},isCategoryExist:function(e){return this.paths.hasOwnProperty(e)},removeCategory:function(e){this.isCategoryExist(e)&&(this.paths[e]=null,delete this.paths[e])},eachCategory:function(e){for(var t in this.paths)this.paths.hasOwnProperty(t)&&e(t)},getPath:function(e){return e=e||this.getCategory(),this.paths[e]||[]},getLastPath:function(){var e=this.getPath();return e[e.length-1]||{}},getLastPathId:function(){return this.isRootPath()&&"node"===this.category?SYNO.SDS.Drive.Define.Info.drive_id:this.getLastPath().id},popPath:function(){this.getPath().pop(),this.setPath(this.getPath(),!0)},applyLastPath:function(e){Ext.apply(this.getLastPath(),e)},appendPath:function(e){this.getPath().push(e),this.setPath(this.getPath(),!0)},isPathChanged:function(e){var t=this.getPath();if(Ext.isNumber(e)&&(!t||t.length!==e+1))return!0;if(!t||!e||t.length!==e.length)return!0;for(var i=0;i<e.length;i++)if(t[i].id!==e[i].id)return!0;return!1},setPath:function(e,t,i){var n=this.getCategory();t=t||this.isPathChanged(e),Ext.isNumber(e)?this.paths[n]=this.paths[this.getCategory()].slice(0,e+1):this.paths[n]=e,this.findAppWindow().getEventMgr().fireEvent("pathchange",e,this.paths[n],n,t,i)},updatePath:function(e,t,i){this.paths&&this.paths[e]&&this.paths[e][t]&&(this.paths[e][t].text=i,this.findAppWindow().getEventMgr().fireEvent("pathchange",null,this.paths[e],e,!1))},setCategoryAndPath:function(e,t,i,n,o,s){var r=this.findAppWindow().getEventMgr();if(Ext.isEmpty(t)||!t[0]){var a=this.getPath(e);a||(this.initPath(e,o),a=this.getPath(e)),t=[a[0]]}else t[0].id!==e&&t.splice(0,0,this.getPath(e)[0]);r.suspendEvents(!0);var l=this.isPathChanged(t)||s;this.setSelection(n),this.setCategory(e,o,i,s),this.setPath(t,l,i),r.resumeEvents()},setSelection:function(e){this.selection_id=e},getSelection:function(){return this.selection_id},isRootPath:function(){var e=this.getPath();return e&&e.length<=1},findAppWindow:function(){return this.appWindow},goBack:function(){if(!window.history)return void this.setDefaultCategory();window.history.back()}}),Ext.define("SYNO.SDS.Drive.Upload.ActionMgr",{extend:"SYNO.SDS.Drive.Action",openNode:function(){var e=this.findAppWindow(),t=e.GetOneSeleted();if(t)if("dir"===t.data.ntype){var i=t.data;e.getNavigation().appendPath({id:t.id,text:i.name,perm:i.capabilities,display_path:i.display_path})}else e.getAllowDblClick()&&!e.getApplyBtnDisabled()&&e.onApply()}}),Ext.define("SYNO.SDS.Drive.Utils.DocumentVisibility",{extend:Ext.util.Observable,singleton:!0,supportVisibilityChange:!1,documentHiddenKey:void 0,constructor:function(){this.addEvents("onPageVisible","onPageInvisible");var e;void 0!==document.hidden?(this.documentHiddenKey="hidden",e="visibilitychange"):void 0!==document.msHidden?(this.documentHiddenKey="msHidden",e="msvisibilitychange"):void 0!==document.webkitHidden&&(this.documentHiddenKey="webkitHidden",e="webkitvisibilitychange"),void 0===document.addEventListener||void 0===this.documentHiddenKey?this.supportVisibilityChange=!1:(this.supportVisibilityChange=!0,document.addEventListener(e,function(){document[this.documentHiddenKey]?this.fireEvent("onPageInvisible"):this.fireEvent("onPageVisible")}.bind(this),!1))},doesSupport:function(){return this.supportVisibilityChange},isVisible:function(){return!this.supportVisibilityChange||!document[this.documentHiddenKey]}}),Ext.ns("SYNO.SDS.Drive.Notification"),Ext.define("SYNO.SDS.Drive.Notification.Menu",{extend:"SYNO.ux.Menu",lastRead:0,userObj:{},DEFAULT_POLL_INTERVAL:3e4,BGTASK_POLL_INTERVAL:3e3,DELAY_TASK_MAX_COUNT:5,statics:{OneWeekSeconds:604800},autoFlexcroll:!1,enableScrolling:!1,constructor:function(e){this.currentData=[],this.callParent([this.fillConfig(e)]),this.onInitPollingTask(),this.onRegEvent()},fillConfig:function(e){return Ext.apply({cls:"syno-d-notification-menu",width:400,items:[this.getGrid()],listeners:{scope:this,show:this.onShowMenu,hide:this.onHideMenu}},e)},lastUpdateTime:0,pendingStart:!1,onRegEvent:function(){var e=this.findAppWindow().getEventMgr();this.mon(e,{scope:this,buffer:100,bgtask_update:this.onBgTaskUpdate}),SYNO.SDS.Drive.Utils.DocumentVisibility.on("onPageVisible",this.onPageVisible.bind(this,!0)),SYNO.SDS.Drive.Utils.DocumentVisibility.on("onPageInvisible",this.onPageVisible.bind(this,!1))},onPageVisible:function(e){void 0===this.pollTask||this.pollTask.removed||(e&&this.pendingStart?this.resuemPolling():!e&&this.pollTask.running&&this.pausePolling())},onBgTaskUpdate:function(e){var t=this.getPollingTask();e&&t.interval!==this.BGTASK_POLL_INTERVAL&&(this.removePollingTask(),this.getPollingTask(this.BGTASK_POLL_INTERVAL),this.startPolling(!0)),e||t.interval===this.DEFAULT_POLL_INTERVAL||(this.removePollingTask(),this.getPollingTask(this.DEFAULT_POLL_INTERVAL),this.startPolling(!0))},onMsgRender:function(e,t,i,n,o,s){var r=i.data,a="";i.id===this.readItemId&&(a='<h1 class="syno-d-notification-read"><span class="syno-d-notification-read-text">'+SYNO.SDS.Drive._T("notification","old")+"</span></h1>");var l=this.getMsgContent(r);return this._isSharedLabelNotificationType(r.type)?a+'<table class="syno-d-notification-ct '+this.getCursorCss(r)+'" border="0" cellspacing="0" cellpadding="0"><tr><td class="syno-d-account-icon-ct" rowspan="3">'+this.getNotificationIcon(r,n)+'</td><td class="syno-d-notification-msg" ext:qtip="'+Ext.util.Format.htmlEncode(l)+'">'+l+'</td></tr><tr><td ext:qtip="'+this.getMsgDate(r,!0)+'" class="syno-d-notification-time">'+this.getMsgDate(r,!1)+'</td></tr><tr><td class="syno-d-notification-tag">'+this.getLabel(r)+"</td></tr></table>":a+'<table class="syno-d-notification-ct '+this.getCursorCss(r)+'" border="0" cellspacing="0" cellpadding="0"><tr><td class="syno-d-account-icon-ct" rowspan="3">'+this.getNotificationIcon(r,n)+'</td><td class="syno-d-notification-msg" ext:qtip="'+Ext.util.Format.htmlEncode(l)+'">'+l+'</td></tr><tr><td ext:qtip="'+this.getMsgDate(r,!0)+'" class="syno-d-notification-time">'+this.getMsgDate(r,!1)+'</td></tr><tr><td class="syno-d-notification-file">'+this.getFile(r)+"</td></tr></table>"},getCursorCss:function(e){return!this.isFileAction(e.type)||!e.content.success&&e.content.names&&this._needToShowPartialError(e.content)?"cursor":""},getNotificationIcon:function(e,t){return this.isFileAction(e.type)?this.getSystemInfoIcon():this.getAccount(e,t)},getSystemInfoIcon:function(){return'<div class="system-info-icon"></div>'},getAccount:function(e,t){var i=e.sender;if(!i)return"";var n,o,s=i.uid,r=this.userObj[s];r?(n=i.display_name,o=s===SYNO.SDS.Drive.Define.Info.uid?SYNO.SDS.Drive.Define.ColorSelf:r.color):(n=i.display_name,o=SYNO.SDS.Drive.Define.ColorSelf);var a='<em class="syno-d-account-icon-l syno-d-round-button" style="background-color:'+o+';" unselectable="on"><button class="x-btn-text" ext:qtip="'+Ext.util.Format.htmlEncode(Ext.util.Format.htmlEncode(n))+'" type="button">'+SYNO.SDS.Drive.Utils.getAccount1stName(n)+"</button>",l="";return e.use_image&&(l=String.format('style="background-color: #FFF;background-image:url({0})"',this.getAccountURL(s))),a+=String.format('<div class="syno-d-round-img" {0}>',l)+"</div></em>"},getAccountURL:function(e){return this.getBaseURL({api:"SYNO.SynologyDrive.SCIM.Photo",version:1,method:"get",params:{size:"S",retina:SYNO.SDS.UIFeatures.test("isRetina"),type:"other",uid:e}},!0,e+".png")},updateAccountIcon:function(e,t,i,n){var o=this.getStore(),s=this.getGrid().getView(),r=function(r){var a=o.getAt(e),l=a.data;if(l.sender.uid===t){var d=s.getRow(e);if(this.isRowRendered(d)){l.rendered=!0;var c=Ext.fly(d).child("em.syno-d-round-button"),h=!0;2>r.width&&2>r.height&&(h=!1),l.use_image=h,!0===h?(c.setStyle("background","#FFF"),c.dom.lastChild.setAttribute("style",String.format("background-color: #FFF;background-image:url({0});",i))):n?(c.setStyle("background",n),c.dom.lastChild.removeAttribute("style")):(c.dom.removeAttribute("style"),c.dom.lastChild.removeAttribute("style"))}}}.bind(this);SYNO.SDS.Drive.GetWindow().getImageLoader().load(i,{load:function(e){r(e)}})},isRowRendered:function(e){return e&&e.childNodes.length>0},isFileAction:function(e){switch(e){case"drive#upload_task":case"drive#background_task":return!0;default:return!1}},onUpdateUserIcon:function(){for(var e,t,i=this.getStore(),n=i.getCount(),o=this.getGrid().getView(),s=0;s<n;++s)if(e=i.getAt(s),t=e.data,!t.rendered&&!this.isFileAction(t.type)){var r=o.getRow(s);if(this.isRowRendered(r)&&t.sender){var a,l,d=t.sender.uid;(a=this.userObj[d])&&(l=d===SYNO.SDS.Drive.Define.Info.uid?SYNO.SDS.Drive.Define.ColorSelf:a.color,this.updateAccountIcon(s,d,this.getAccountURL(d),l))}}},getMsgByFileType:function(e,t,i){var n={};if(n[SYNO.SDS.Drive.FileType.SYNODOC]="doc",n[SYNO.SDS.Drive.FileType.SYNOSHEET]="sheet",n[SYNO.SDS.Drive.FileType.SYNOSLIDE]="slide","file"===e&&SYNO.SDS.Drive.Utils.isOfficeFile(t)){var o=SYNO.SDS.Drive.Utils.getExt(t);return String.format("notification:{0}_{1}",i,n[o])}return String.format("notification:{0}_{1}",i,"dir"===e?"dir":"file")},getBackgroundTaskMsg:function(e){if(!e.names)return"";var t=e.names.length>1,i=e.success,n=String.format("{0}{1}_{2}",e.action,t?"_multi":"",i?"success":"error"),o=Ext.util.Format.htmlEncode(e.names[0].toString()),s=Ext.util.Format.htmlEncode(o);return String.format(SYNO.SDS.Drive._T("task",n),t?e.names.length:String.format('<b ext:qtip="{0}">{1}</b>',s,o))},getMsgFromNotificationType:function(e){var t;switch(e.type){case"drive#create":t="create";break;case"drive#share_with_me":t="share";break;case"drive#request":t="request";break
;case"drive#change_owner":t="owner";break;case"drive#comment":return"notification:comment_add_doc";case"drive#comment_reply":return"notification:comment_reply";case"drive#mention":return"notification:comment_mention_doc";case"drive#upload_task":case"drive#background_task":return this.getBackgroundTaskMsg(e.content);case"drive#request_office_template":return"notification:request_office_template";case"drive#request_unlock":return"notification:request_unlock";case"drive#shared_label":return"notification:shared_label";case"drive#shared_label_owner_transfer":return"notification:shared_label_transfer";default:return""}return this.getMsgByFileType(e.content.file_type,e.content.name,t)},getMsgContent:function(e){if(!e.content)return"";var t=this.getMsgFromNotificationType(e),i=SYNO.SDS.Drive.Define.AnonymousUID===e.sender.uid?String.format(SYNO.SDS.Drive._T("common","guest"),""):Ext.util.Format.htmlEncode(e.sender.display_name);return 1===e.extra_info.group.length&&e.extra_info.multiple_comment?t+="_multiple":2===e.extra_info.group.length?(i=String.format(SYNO.SDS.Drive._T("notification","comment_grouping_another_person"),i),t+="_plural"):2<e.extra_info.group.length&&(i=String.format(SYNO.SDS.Drive._T("notification","comment_grouping"),i,e.extra_info.group.length-1),t+="_plural"),String.format(SYNO.SDS.Utils.GetLocalizedString(t,"SYNO.SDS.Drive.Application"),"<b>"+i+"</b>")},getLabel:function(e){if(!e.content||!e.content.label_info||0===e.content.label_info.length)return"";var t=e.content.label_info.map(function(e){return e.label_name}),i=Ext.util.Format.htmlEncode(t.join(SYNO.SDS.Drive._T("common","comma"))),n=Ext.util.Format.htmlEncode(i);return String.format('<div class="icon syno-d-notification-icon-tag"></div><div class="shared-label-name" ext:qtip="{0}">{1}</div>',n,i)},getFile:function(e){return e.content?this.isFileAction(e.type)?this.getTaskFileTemplate(e.content):this.getDefaultFileTemplate(e):""},_needToShowPartialError:function(e){var t=e.errors;if(!e.names||e.names.length>1)return!0;if(Ext.isArray(t)&&t.length>1)return!0;var i=e.names[0],n=t[0];return!!n.context.path&&n.context.path.includes(i+"/")},getTaskFileTemplate:function(e){var t,i;if(e.success)return e.names&&1!==e.names.length?(t=Ext.util.Format.htmlEncode(e.names.toString()),i=Ext.util.Format.htmlEncode(t),String.format('<div class="bgtask-filename" ext:qtip="{0}">{1}</div>',i,t)):"";if(Ext.isArray(e.errors)){if(this._needToShowPartialError(e))return String.format('<div class="error underline">{0}</div>',SYNO.SDS.Drive._T("task","partial_error"));var n=SYNO.SDS.Drive.Utils.getErrorStr(e.errors[0].code);return t=Ext.util.Format.htmlEncode(n),i=Ext.util.Format.htmlEncode(t),String.format('<div class="error" ext:qtip="{0}">{1}</div>',i,t)}return""},getDefaultFileTemplate:function(e){var t,i;if("drive#request_office_template"===e.type)return t=Ext.util.Format.htmlEncode(e.content.name),i=Ext.util.Format.htmlEncode(t),String.format('<div class="icon {0}"></div><div class="filename" ext:qtip="{1}">{2}</div>',SYNO.SDS.Drive.FileType.getMappingTypeCss(e.content.file_extension,16),i,t);var n=SYNO.SDS.Drive.Utils.getNtype(e.content.name,e.content.file_type);return t=Ext.util.Format.htmlEncode(SYNO.SDS.Drive.Utils.parseDisplayName(e.content.name)),i=Ext.util.Format.htmlEncode(t),String.format('<div class="icon syno-d-start-ntype" style="{0}"></div><div class="filename" ext:qtip="{1}">{2}</div>',SYNO.SDS.Drive.FileType.getFileTypeIconStyle(n,16),i,t)},getGrid:function(){return this.grid||(this.grid=new SYNO.ux.GridPanel({title:SYNO.SDS.Drive._T("notification","title"),header:!0,id:"syno-d-notification-grid",cls:"syno-d-notification-grid",border:!1,boxMaxHeight:480,store:this.getStore(),hideHeaders:!0,disableSelection:!0,useNewStyle:!1,colModel:new Ext.grid.ColumnModel({defaults:{menuDisabled:!0,fixed:!0,align:"left"},columns:[{width:376,dataIndex:"message",renderer:this.onMsgRender.createDelegate(this)}]}),view:new SYNO.SDS.Drive.Notification.GridView({forceFit:!0,disableTextSelect:!0,deferEmptyText:!1,rowOverCls:"",emptyText:'<div class="syno-d-empty-panel-container"><div class="syno-d-empty-panel-img"></div><div class="syno-d-empty-panel-text">'+SYNO.SDS.Drive._T("notification","empty")+"</div></div></div>",scrollOffset:0,rowSelectorDepth:11}),listeners:{scope:this,viewready:this.onUpdateGridView,rowclick:this.onRowClick,afterrender:{single:!0,fn:this.onUpdateGridView}}}))},updateTitle:function(){if(Ext.isEmpty(this.currentData))Ext.getCmp("syno-d-notification-grid").setTitle(SYNO.SDS.Drive._T("notification","title"));else{var e=String.format('<span class="syno-d-notification-grid-title">{0}</span><span class="syno-d-notification-clean" ext:qtip="{1}"></span>',SYNO.SDS.Drive._T("notification","title"),SYNO.SDS.Drive._T("common","clear_all_notifications"));Ext.getCmp("syno-d-notification-grid").setTitle(e);var t=this.grid.header.down(".x-panel-header-text > .syno-d-notification-clean");this.mon(t,"click",this.clearNotifications,this)}},onUpdateGridView:function(){this.updateTitle();var e=this.grid;if(e.getView().hasRows()){var t=this.grid.getView().mainBody.getHeight();this.grid.getHeight()+36!==t&&this.grid.setHeight(t+36)}else e.setHeight(302);e.ownerCt.doLayout(),this.onUpdateUserIcon()},clearNotifications:function(){this.findAppWindow().getWebAPI().clearNotifications({params:{},scope:this,callback:function(e,t){!0===e&&(this.currentData=[],this.currentGroupData=[],this.onUpdateData(),this.onUpdateGridView())}})},getStore:function(){return this.store||(this.store=new Ext.data.JsonStore({autoDestroy:!0,totalProperty:"total",idProperty:"notification_id",fields:["notification_id","type","time","content","sender","recipient","extra_info",{name:"rendered",convert:function(){return!1}}]}))},onShowMenu:function(){Ext.isEmpty(this.currentGroupData)||(this.stopPolling(),this.currentGroupData.length!==this.getStore().getTotalCount()||this.currentGroupData[0].notification_id!==this.getStore().getAt(0).id?(this.onUpdateData(),this.currentGroupData.length&&SYNO.SDS.UserSettings.setProperty("SYNO.SDS.Drive.Application","lastRead",this.currentGroupData[0].time+1)):this.readItemId&&(this.readItemId=void 0,this.grid.getView().refresh(),this.onUpdateGridView(),this.grid.getView().updateScroller()))},onUpdateData:function(){this.getStore().loadData(this.currentGroupData),this.updateTitle(),this.grid.ownerCt.doLayout(),this.onUpdateUserIcon()},onHideMenu:function(){var e=this.getPollingTask();e.reqId||e.restart(!1),Ext.isArray(this.currentGroupData)&&(this.findAppWindow().getEventMgr().fireEvent("notification_update",0,this.currentGroupData.length),this.groupingData())},onStoreLoad:function(e,t){this.findAppWindow().getEventMgr().fireEvent("notification_update",t.length)},onExceptionStore:function(){},onInitPollingTask:function(){this.getPollingTask().start(!0)},getPollingTask:function(e){return this.pollTask||(this.pollTask=this.findAppWindow().addWebAPITask(Ext.apply({interval:e||this.DEFAULT_POLL_INTERVAL,params:{limit:100},scope:this,callback:this.onUpdatePolling},SYNO.SDS.Drive.WebAPIDesc.list_notifications)))},removePollingTask:function(){this.pollTask&&(this.pollTask.remove(),this.pollTask=null,this.lastUpdateTime=0)},groupingData:function(){if(!Ext.isEmpty(this.currentData)){var e;this.lastRead=SYNO.SDS.UserSettings.getProperty("SYNO.SDS.Drive.Application","lastRead")||SYNO.SDS.UserSettings.getProperty("SYNO.SDS.Office.Application","lastRead")||0,this.currentGroupData=[];for(var t=0;t<this.currentData.length;++t)if(e=this.currentData[t],e.content){var i=!1;if("drive#comment"===e.type||"drive#mention"===e.type||"drive#comment_reply"===e.type)for(var n=0;n<this.currentGroupData.length;++n){var o=this.currentGroupData[n];if((o.time>this.lastRead&&e.time>this.lastRead||o.time<=this.lastRead&&e.time<=this.lastRead)&&o.content.link_id===e.content.link_id&&o.type===e.type&&o.time-e.time<=600){o.extra_info.multiple_comment=!0,-1===o.extra_info.group.indexOf(e.sender.uid)&&o.extra_info.group.push(e.sender.uid),i=!0;break}}if(!i){this.currentGroupData.push(this.currentData[t]);var s=this.currentGroupData[this.currentGroupData.length-1];s.extra_info={group:[]},s.extra_info.multiple_comment=!1,s.extra_info.group.push(s.sender.uid)}}}},onUpdatePolling:function(e,t,i){if(this.lastUpdateTime=(new Date).getTime(),this.findAppWindow().isDestroyed)return void this.stopPolling();if(t&&t.items&&0!==t.items.length&&(this.previousData=this.currentData,this.currentData=t.items,this.currentData.length!==this.previousData.length||this.currentData[0].notification_id!==this.previousData[0].notification_id)){this.lastRead=SYNO.SDS.UserSettings.getProperty("SYNO.SDS.Drive.Application","lastRead")||SYNO.SDS.UserSettings.getProperty("SYNO.SDS.Office.Application","lastRead")||0;var n,o=0;this.groupingData();for(var s=0;s<this.currentGroupData.length;++s){if(n=this.currentGroupData[s],n.time<=this.lastRead){this.readItemId=n.notification_id;break}++o}0===o&&(this.readItemId=void 0),this.onUpdateUser(),this.findAppWindow().getEventMgr().fireEvent("notification_update",o,this.currentGroupData.length),this.isVisible()&&this.onUpdateData()}},resuemPolling:function(){var e=(new Date).getTime();this.pendingStart=!1,this.lastUpdateTime&&e-this.lastUpdateTime>=this.pollTask.interval?this.startPolling(!0):this.startPolling(!1)},pausePolling:function(){this.pollTask&&(this.pendingStart=!0,this.pollTask.stop())},stopPolling:function(){this.pollTask&&this.pollTask.stop(),this.pendingStart=!1},startPolling:function(e){if(this.pollTask&&!this.pollTask.removed)return SYNO.SDS.Drive.Utils.DocumentVisibility.isVisible()?void(this.pollTask.running||this.getPollingTask().start(e)):void(this.pendingStart=!0)},shareNode:function(e){var t=e.content.link_id;this.findAppWindow().getAction().getNode({permanent_link:t},function(i,n){i&&(this.findAppWindow().getAction().onGotoPath(n.file_id,function(){return!0}),this.findAppWindow().getAction().shareNodeByParam({permanent_link:t,share_user:e.sender.name,capabilities:n.capabilities,name:n.name}))},this)},onRowClick:function(e,t,i){var n=this.findAppWindow(),o=this.grid.store.getAt(t),s=o.data;if(this.isFileAction(s.type)){if(s.content.success||!s.content.names||!this._needToShowPartialError(s.content))return;return new SYNO.SDS.Drive.Task.ViewErrorDialog({owner:this.findAppWindow(),appWindow:this.findAppWindow(),errors:s.content.errors}).show(),void this.hide()}if("drive#request_office_template"===s.type){if(!SYNO.SDS.Drive.Utils.hasOffice()||!SYNO.SDS.Office.GetAction().shareTemplate){var r=SYNO.SDS.Drive._T("app","install_office_alert");return SYNO.SDS.Drive.Define.Info.office_migration&&(r=SYNO.SDS.Drive._T("app","migration_office")),void SYNO.SDS.Drive.Utils.showAlertMsg(this.findAppWindow(),r)}return SYNO.SDS.Office.GetAction().shareTemplate(s),void this.hide()}if("drive#request"===s.type)return this.shareNode(s),void this.hide();if("drive#request_unlock"===s.type){var a=s.content.file_id;return location.hash=String.format("#action=unlock&file_id={0}",a),void this.hide()}if(this._isSharedLabelNotificationType(s.type)){var l=function(e){d.delay(50,void 0,this,[e])},d=new Ext.util.DelayedTask(function(e){var t=c.body.dom.fleXcroll.scrollContent(),i=t[1][1];if(e&&p===i&&this.delayTaskCounter<this.DELAY_TASK_MAX_COUNT)return d.delay(50),void(this.delayTaskCounter+=1);c.toggleLabelTreeNode(!0,h);var o=s.content.label_info;if(1===o.length){var r=o[0],a=c.getNodeById(String.format("shared_label:{0}",r.label_id));return a?(a.select(),a.ensureVisible(),void this.hide()):void c.getSharedLabelRootNode().reload(function(){var e=c.getNodeById(String.format("shared_label:{0}",r.label_id));if(!e)return n.getMsgBox().alert("",SYNO.SDS.Drive._T("request","ask_access")),void this.hide();e.select(),e.ensureVisible(),this.hide()}.bind(this))}!1!==i&&c.body.dom.fleXcroll.setScrollPos(0,i),h.ensureVisible(),this.hide()}.bind(this)),c=n.getCategoryPanel(),h=c.getSharedLabelRootNode();if(!h.ui)return n.getMsgBox().alert("",SYNO.SDS.Drive._T("warning","ask_refresh"),function(){location.reload()}),void this.hide();this.delayTaskCounter=0;var u=c.body.dom.fleXcroll.scrollContent(),p=u[1][1];return h.isExpanded()?void l.call(this,!1):(h.on("expand",l.bind(this,!0),this,{single:!0}),void h.expand(!1,!1))}if("file"===s.content.file_type&&SYNO.SDS.Drive.Utils.isOfficeFile(s.content.name))return SYNO.SDS.Drive.Utils.openOfficeLink(s.content.link_id,s.content.hash,!0),void this.hide();n.getAction().onGotoPath({permanent_link:s.content.link_id},function(e,t){var i;if(e)return!0;if(1002!==t.code)return void n.getMsgBox().alert("",SYNO.SDS.Drive.Utils.getErrorStr(t));i=SYNO.SDS.Drive._T("request","ask_access");var o=n.getMsgBox().confirm("",i,function(e){"yes"===e&&n.getAction().requestAccess({permanent_link:s.content.link_id},function(e,t){var o=SYNO.SDS.Drive._T("request","sent");i=e?o.replace("<br>",""):SYNO.SDS.Drive.Utils.getErrorStr(t),SYNO.SDS.Drive.Utils.showToastMsg(n,i,3500)})});o.fbButtons.yes.setText(SYNO.SDS.Drive._T("request","access")),o.fbButtons.no.setText(_T("common","cancel"))}),this.hide()},getMsgDate:function(e,t){var i,n,o=!1,s=e.time;return i=this.getCurrentTime()-s,n=i<0,o=i>SYNO.SDS.Drive.Notification.Menu.OneWeekSeconds,o||t||n?SYNO.SDS.Drive.Utils.getFormatDateTime(new Date(1e3*s)):Ext.util.Format.relativeTime(1e3*s)},getCurrentTime:function(){return Ext.isNumber(this.nowSec)?this.nowSec:this.nowSec=(new Date).getTime()/1e3},onUpdateUser:function(){if(this.currentData){for(var e,t,i=[],n=0;n<this.currentData.length;++n)t=this.currentData[n],(e=t.sender.uid)&&!this.userObj[e]&&i.push(e);0!==i.length&&this.findAppWindow().getWebAPI().getUsers({params:{uid:Ext.unique(i)},scope:this,callback:function(e,t){if(e){for(var i=0,n=t.users.length;i<n;i++){var o=t.users[i];this.userObj[o.uid]=Ext.copyTo({},o,["name","nick","color"]);var s=this.getAccountURL(o.uid);SYNO.SDS.Drive.GetWindow().getImageLoader().load(s)}this.onUpdateUserIcon()}}})}},_isSharedLabelNotificationType:function(e){return["drive#shared_label","drive#shared_label_owner_transfer"].includes(e)}}),Ext.define("SYNO.SDS.Drive.Notification.GridView",{extend:"SYNO.ux.FleXcroll.grid.GridView",constructor:function(e){this.callParent([e])},onLayout:function(){var e=this,t=e.scroller.dom;e.autoFlexcroll&&(e.fitColumns(!1),e.updateScrollbar(t))}}),Ext.define("SYNO.SDS.Drive.Task.ViewErrorDialog",{extend:"SYNO.SDS.Drive.ModalWindow",constructor:function(e){this.appWindow=e.appWindow;var t={title:SYNO.SDS.Drive._T("task","view_error"),width:800,height:520,resizable:!1,cls:"syno-d-bgtask-view-error",layout:"fit",items:[this.getGridPanel(e)],buttons:[{xtype:"syno_button",text:SYNO.SDS.Drive._T("common","close"),btnStyle:"grey",handler:this.onCloseClick,scope:this}]};Ext.apply(t,e||{}),this.callParent([t])},getGridPanel:function(e){if(this.grid)return this.grid;var t={cls:"syno-d-bgtask-view-error-grid",enableHdMenu:!1,view:this.createGridView(),store:this.createGridStore(e.errors),cm:this.createGridCM(),listeners:{viewready:function(e){this.view.updateScroller()}}};return this.grid=new SYNO.ux.GridPanel(t),this.grid},createGridView:function(){var e={rowHeight:29,forceFit:!0,disableTextSelect:!0,deferEmptyText:!1};return new SYNO.ux.FleXcroll.grid.BufferView(e)},createGridStore:function(e){var t=e.map(function(e){return{name:e.context.name,path:e.context.path,file_type:e.context.file_type,reason:SYNO.SDS.Drive.Utils.getErrorStr(e.code)}});return new Ext.data.JsonStore({autoDestroy:!0,fields:["name","path","file_type","reason"],data:t})},createGridCM:function(){var e=SYNO.SDS.Drive._T;return new Ext.grid.ColumnModel({defaults:{menuDisabled:!0,sortable:!1,scope:this},columns:[{dataIndex:"name",width:240,header:e("common","file_name"),renderer:function(e,t,i,n,o,s){var r="dir"===i.data.file_type?"dir":SYNO.SDS.Drive.Utils.getExt(e);return String.format('<span class="syno-d-start-ntype" style="{0}"></span>',SYNO.SDS.Drive.FileType.getFileTypeIconStyle(r,16))+this.defaultRender(e)}},{dataIndex:"path",width:280,header:e("common","path"),renderer:this.defaultRender.createDelegate(this)},{dataIndex:"reason",width:223,header:e("task","reason"),renderer:this.defaultRender.createDelegate(this)}]})},defaultRender:function(e,t,i,n,o,s){var r=Ext.util.Format.htmlEncode(e)||"-",a=Ext.util.Format.htmlEncode(r);return String.format('<span ext:qtip="{0}">{1}</span>',a,r)},onCloseClick:function(){this.close()}}),Ext.define("SYNO.SDS.Drive.Task.MonitorDialog",{extend:"SYNO.SDS.Drive.ModalWindow",constructor:function(e){var t={title:SYNO.SDS.Drive._T("task","task_monitor"),width:920,height:559,resizable:!1,cls:"syno-d-bgtask-monitor",layout:"fit",items:[this.getGridPanel(e)],buttons:[{xtype:"syno_button",text:SYNO.SDS.Drive._T("common","close"),btnStyle:"grey",handler:this.onCloseClick,scope:this}]};Ext.apply(t,e||{}),this.appWindow=e.appWindow,e.store.suspendEvents(),this.callParent([t])},getGridPanel:function(e){if(this.grid)return this.grid;var t=SYNO.SDS.Drive._T,i={cls:"syno-d-bgtask-monitor-grid",enableHdMenu:!1,view:this.createGridView(),store:e.store,cm:this.createGridCM(),sm:this.createSelModel(),tbar:[{xtype:"syno_button",itemId:"clear",text:t("common","clear_complete"),btnStyle:"grey",handler:this.onClearClick,scope:this},{xtype:"syno_button",itemId:"remove",text:t("common","remove"),btnStyle:"grey",handler:this.onRemoveClick,scope:this},{xtype:"syno_button",itemId:"restart",text:t("common","restart"),btnStyle:"grey",disabled:!0,handler:this.onRestartClick,scope:this}],listeners:{scope:this,viewready:function(){e.store.resumeEvents(),this.getGridPanel().getView().updateScroller()}}};return this.grid=new SYNO.ux.GridPanel(i),this.grid},createGridView:function(){var e={rowHeight:29,forceFit:!0,disableTextSelect:!0,deferEmptyText:!1};return new SYNO.ux.FleXcroll.grid.BufferView(e)},createSelModel:function(){return new Ext.grid.RowSelectionModel({listeners:{scope:this,buffer:80,selectionchange:this.onSelectionChange}})},createGridCM:function(){var e=SYNO.SDS.Drive._T;return new Ext.grid.ColumnModel({defaults:{menuDisabled:!0,sortable:!1,scope:this},columns:[{dataIndex:"title",width:120,header:e("task","task_title"),renderer:this.titleRender.createDelegate(this),listeners:{scope:this,click:this.onTitleClick}},{dataIndex:"name",width:250,header:e("file","file"),renderer:this.defaultRender.createDelegate(this)},{dataIndex:"time",width:100,header:e("task","left_time"),renderer:function(e,t,i,n,o,s){var r=i.get("progress");if(0>=r||"processing"!==i.get("status"))return"-";if(!0===i.get("networkError"))return"-";var a;if(i.get("leftTime")>=0)a=SYNO.SDS.Drive.Date.fancyDuration(i.get("leftTime").toFixed(0));else{var l=i.get("starttime"),d=(new Date).getTime(),c=(100-r)/r*(d-l);a=SYNO.SDS.Drive.Date.fancyDuration((c/1e3).toFixed(0))}return String.format('<span css="syno-d-bgtask-lefttime" ext:qtip="{0}"> {1} <span>',a,a)}},{dataIndex:"speed",width:100,header:e("task","speed"),renderer:function(e,t,i,n,o,s){var r='<span css="syno-d-bgtask-speed"  ext:qtip="{0}"> {1}/'+SYNO.SDS.Drive._T("task","time_s")+" <span>",a=i.get("progress"),l=i.get("total");if(0>=a||0>=l||"processing"!==i.get("status"))return"-";if(!0===i.get("networkError"))return String.format(r,0,0);var d=0;if(i.get("speed")>=0)d=i.get("speed");else{var c=i.get("starttime");d=l*(a/100)/(((new Date).getTime()-c)/1e3),d=Math.round(100*d)/100}return"delete"===i.get("action")||"convert_office"===i.get("action")?d+=" "+SYNO.SDS.Drive._T("task","file_number"):d=Ext.util.Format.fileSize(d),String.format(r,d,d)}},{dataIndex:"progress",width:172,header:e("task","progress"),renderer:function(e,t,i,n,o,s){var r=this.getProgressTpl();return e=parseFloat(e),e=Math.round(100*e)/100,0<e?r.fill(e,"",100===e):""}},{dataIndex:"status",width:121,header:e("common","status"),renderer:function(e,t,i,n,o,s){var r,a;switch(e){case"task_error":r="error-occurred underline";break;case"partial_error":r="error underline";break;default:r=e}return a=Ext.util.Format.htmlEncode(i.get("statusText")),String.format('<span class="syno-d-bgtask-status {0}" ext:qtip="{1}"> {2} </span>',r,Ext.util.Format.htmlEncode(a),a)},listeners:{scope:this,click:this.onShowError}}]})},defaultRender:function(e,t,i,n,o,s){var r=Ext.util.Format.htmlEncode(e),a=Ext.util.Format.htmlEncode(r);return String.format('<span ext:qtip="{0}">{1}</span>',a,r)},titleRender:function(e,t,i,n,o,s){var r=i.get("titleTooltip");return String.format('<span ext:qtip="{0}">{1}</span>',Ext.util.Format.htmlEncode(r),e)},getProgressTpl:function(){return this.progressTpl?this.progressTpl:(this.progressTpl=new SYNO.SDS.Utils.ProgressBar({barWidth:100,barHeight:8,showValueText:!0}),this.progressTpl)},onShowError:function(e,t,i,n,o){if(Ext.fly(n.getTarget()).hasClass("underline")){var s=this.grid.getStore().getAt(i).get("taskid"),r=this.appWindow.getTaskMgr().getTask(s);new SYNO.SDS.Drive.Task.ViewErrorDialog({owner:this,appWindow:this.appWindow,errors:r.errors}).show()}},onSelectionChange:function(){var e=this.grid.getSelectionModel().getSelections(),t=0<e.length;Ext.each(e,function(e){if("upload_"!==e.get("taskid").substr(0,7)||!e.data.status||-1===e.get("status").indexOf("error"))return t=!1,!1},this),this.grid.getTopToolbar().get("restart").setDisabled(!t),this.grid.getTopToolbar().get("remove").setDisabled(0===e.length)},onClearClick:function(){for(var e=this.grid.getStore().data.items,t=0;t<e.length;t++)"success"===e[t].data.status&&(this.appWindow.getTaskMgr().removeTask(e[t].get("taskid")),e=this.grid.getStore().data.items,t--)},onRemoveClick:function(){var e=this.grid.getSelectionModel().getSelections();Ext.each(e,function(e){this.appWindow.getTaskMgr().removeTask(e.get("taskid"))},this)},onRestartClick:function(){var e=this.grid.getSelectionModel().getSelections();Ext.each(e,function(e){this.appWindow.getTaskMgr().restartTask(e.get("taskid"))},this)},onCloseClick:function(){this.close()},onTitleClick:function(e,t,i,n,o){if(Ext.fly(n.getTarget()).hasClass("syno-d-bgtask-action")){var s=this.grid.getStore().getAt(i).get("taskid");this.appWindow.getTaskMgr().getTask(s).onClickAction(),this.hide()}}}),Ext.define("SYNO.SDS.Drive.Task.TrayPanel",{extend:"SYNO.ux.Menu",constructor:function(e){var t={cls:"syno-d-bgtask-menu",width:400,items:[this.createGridPanel(),this.createViewDetailBtn()],listeners:{scope:this,show:this.onShowMenu}};Ext.apply(t,e||{}),this.appWindow=e.appWindow,this.callParent([t]),this.onRegEvent()},onRegEvent:function(){var e=this.appWindow.getTaskMgr();this.mon(e,{scope:this,ontaskadd:this.onTaskAdd,ontaskremove:this.onTaskRemove})},createViewDetailBtn:function(){var e={text:SYNO.SDS.Drive._T("task","view_detail"),cls:"syno-d-bgtask-view-detail",handler:this.onViewDetail,scope:this};return this.viewDetailBtn=new SYNO.SDS.Drive.SimpleButton(e),this.viewDetailBtn},createGridPanel:function(){var e=['<div class="syno-d-empty-panel-container">','<div class="syno-d-empty-panel-img"></div>','<div class="syno-d-empty-panel-text">',SYNO.SDS.Drive._T("notification","empty"),"</div>","</div>"].join(""),t={title:this.getTitle(),header:!0,cls:"syno-d-bgtask-grid",width:376,boxMaxHeight:435,store:this.getStore(),hideHeaders:!0,disableSelection:!0,useNewStyle:!1,colModel:new Ext.grid.ColumnModel({defaults:{menuDisabled:!0,fixed:!0,align:"left"},columns:[{width:376,dataIndex:"taskid",renderer:this.onTaskInfoRender.createDelegate(this),listeners:{scope:this,click:this.onClickTask}}]}),view:new SYNO.ux.FleXcroll.grid.BufferView({rowHeight:57,forceFit:!0,disableTextSelect:!0,deferEmptyText:!1,emptyText:e,scrollOffset:0,rowSelectorDepth:11,listeners:{scope:this,rowsinserted:this.onUpdateGridView}}),listeners:{scope:this,viewready:this.onUpdateGridView,rowclick:this.onRowClick,afterrender:{single:!0,fn:this.onGridRender}}};return this.grid=new SYNO.ux.GridPanel(t),this.grid},getStore:function(){return this.dataStore?this.dataStore:(this.dataStore=new Ext.data.JsonStore({autoDestroy:!1,fields:["action","title","titleTooltip","name","progress","status","starttime","speed","leftTime","total","statusText","taskid","networkError","statusValue"],listeners:{scope:this,remove:function(e,t,i,n){0===e.getCount()&&this.findAppWindow().getEventMgr().fireEvent("hide_bgtask_tray")},update:function(e,t,i,n){e.sort("statusValue","ASC")}}}),this.dataStore)},getProgressTpl:function(){return this.progressTpl?this.progressTpl:(this.progressTpl=new SYNO.SDS.Utils.ProgressBar({barWidth:150,barHeight:8,showValueText:!0}),this.progressTpl)},getTaskInfoTpl:function(){return this.taskInfoTpl?this.taskInfoTpl:(this.taskInfoTpl=new Ext.XTemplate('<div class="syno-d-bgtask-info-wrapper {[this.getCursorClass(values.status, values.actionTitle)]}">','<div class="syno-d-bgtask-info-wrapper-top">','<span class="syno-d-bgtask-title">{[values.title]}: </span>','<span class="syno-d-bgtask-name" ext:qtip="{[SYNO.SDS.Drive.Utils.doubleHtmlEncode(values.name)]}">',"{[Ext.util.Format.htmlEncode(values.name)]}","</span>","</div>",'<div class="syno-d-bgtask-info-wrapper-bottom">',"{progress}","{[this.getSplitDiv(values)]}",'<div class="syno-d-bgtask-status {[this.getStatusClass(values.status)]}"','ext:qtip="{[SYNO.SDS.Drive.Utils.doubleHtmlEncode(values.statusText)]}">',"{[Ext.util.Format.htmlEncode(values.statusText)]}","</div>","</div>","</div>",'<div class="{[this.getActionClass(values.status)]} {[this.getCursorClass(values.status, values.actionTitle)]}"></div>',{getSplitDiv:function(e){var t=e.statusText;return Ext.isEmpty(t)||Ext.isEmpty(e.progress)?"":'<div class="syno-d-bgtask-split"></div>'},getStatusClass:function(e){var t;switch(e){case"task_error":t="error-occurred underline";break;case"partial_error":t="error underline";break;default:t=e}return t},getActionClass:function(e){switch(e){case"success":return"syno-d-bgtask-success";default:return"syno-d-bgtask-remove"}},getCursorClass:function(e,t){var i=["upload"];if("success"===e&&-1===i.indexOf(t))return"syno-d-bgtask-not-pointor"}}),this.taskInfoTpl)},getTitle:function(){return String.format('<span class="syno-d-bgtask-grid-title">{0}</span><span class="syno-d-bgtask-clean" ext:qtip="{1}"></span>',SYNO.SDS.Drive._T("task","bgtask_title"),SYNO.SDS.Drive._T("common","clear_complete"))},onGridRender:function(){var e=this.grid.header.down(".x-panel-header-text > .syno-d-bgtask-clean");this.mon(e,"click",this.onCleanTask,this)},onUpdateGridView:function(){if(this.isVisible()){var e=this.grid;if(e.getView().hasRows()){var t=this.grid.getView().mainBody.getHeight();this.grid.getHeight()+36!==t&&this.grid.setHeight(t+36),this.viewDetailBtn.show()}else e.setHeight(302),this.viewDetailBtn.hide();e.ownerCt.doLayout()}},onClickTask:function(e,t,i,n,o){var s=this.grid.getStore().getAt(i).get("taskid"),r=this.appWindow.getTaskMgr().getTask(s);if(Ext.fly(n.getTarget()).hasClass("underline"))new SYNO.SDS.Drive.Task.ViewErrorDialog({owner:this.appWindow,appWindow:this.appWindow,errors:r.errors}).show(),this.hide();else if("success"===r.status&&"upload"===r.title){var a=r.uploadPath||r.path+"/"+r.name;this.findAppWindow().getAction().onGotoPath(a.substring(3,a.length),void 0,void 0,!1),this.hide()}},onShowMenu:function(){this.grid.getView().refresh(),this.onUpdateGridView()},onViewDetail:function(){new SYNO.SDS.Drive.Task.MonitorDialog({owner:this.appWindow,appWindow:this.appWindow,store:this.getStore()}).show(),this.hide()},onTaskInfoRender:function(e,t,i,n,o,s){var r=this.getProgressTpl(),a=this.getTaskInfoTpl(),l=parseFloat(i.get("progress"));l=Math.round(100*l)/100;var d=i.get("status"),c=i.get("statusText");return a.apply({title:i.get("title"),name:i.get("name"),titleTooltip:i.get("titleTooltip"),actionTitle:i.get("actionTitle"),status:d,statusText:0<l&&"processing"===d?"":c,progress:"success"!==d&&0<l?r.fill(l,"",100===l):""})},onTaskAdd:function(e){"upload"===e.type&&this.findAppWindow().getEventMgr().fireEvent("show_bgtask_tray"),this.getStore().loadData([{action:e.action,title:e.getTrayTitle(),titleTooltip:e.getTrayTitleTooltip(),name:e.getTrayNames(),status:e.status,statusText:e.statusText,progress:e.hasProgress?0:-1,starttime:e.starttime,speed:e.speed,leftTime:e.leftTime,total:e.total,taskid:e.taskid,statusValue:this._getStatusValue(e)}],!0);var t=this.getStore().getAt(this.getStore().getCount()-1);this.mon(e,{scope:this,onsuccess:this.onTaskSuccess.createDelegate(this,[t],!0),onerror:this.onTaskError.createDelegate(this,[t],!0),onprogress:this.onTaskProgress.createDelegate(this,[t],!0),onchange:this.onTaskChange.createDelegate(this,[t],!0),onnetworkerror:this.onNetworkError.createDelegate(this,[t],!0)}),this.getStore().sort("statusValue","ASC")},_getStatusValue:function(e){var t=e.status;return"processing"===t?0:"wait"===t?1:"error"===t||"partial_error"===t?2:3},onRowClick:function(e,t,i){var n=Ext.fly(i.getTarget());if(n.is("div.syno-d-bgtask-remove")){var o=e.getStore().getAt(t);this.onTaskRemove(o.get("taskid"),!0,!1)}else if(n.hasClass("syno-d-bgtask-action")){var s=this.grid.getStore().getAt(t).get("taskid"),r=this.appWindow.getTaskMgr().getTask(s);r.onClickAction(),this.hide()}},onTaskRemove:function(e,t,i){if(i){var n=this.dataStore.findExact("taskid",e),o=Ext.get(this.grid.view.getRow(n));o&&o.slideOut("r",{duration:.5,remove:!1,callback:this.removeTask.createDelegate(this,[e,t])})}else this.removeTask(e,t)},onTaskProgress:function(e,t,i){i.beginEdit(),this._setNetworkError(i,!1),i.set("status",e.status),i.set("statusText",e.statusText),i.set("progress",t),i.set("statusValue",this._getStatusValue(e)),i.set("actionTitle",e.title),i.set("speed",e.speed),i.set("leftTime",e.leftTime),i.set("total",e.total),i.commit()},onTaskChange:function(e,t){t.beginEdit(),this._setNetworkError(t,!1),t.set("starttime",e.starttime),t.set("status",e.status),t.set("statusValue",this._getStatusValue(e)),t.set("statusText",e.statusText),t.commit()},onTaskSuccess:function(e,t,i){i.beginEdit(),this._setNetworkError(i,!1),i.set("status","success"),i.set("title",e.getTrayTitle()),i.set("titleTooltip",e.getTrayTitleTooltip()),i.set("statusText",e.statusText),i.set("progress",100),i.set("statusValue",this._getStatusValue(e)),i.set("actionTitle",e.title),i.commit()},onTaskError:function(e,t,i){i.beginEdit(),this._setNetworkError(i,!1),i.set("status",e.status),i.set("title",e.getTrayTitle()),i.set("titleTooltip",e.getTrayTitleTooltip()),i.set("statusText",e.statusText),i.set("progress",-1),i.set("statusValue",this._getStatusValue(e)),i.set("actionTitle",e.title),i.commit()},onNetworkError:function(e,t,i){i.beginEdit(),this._setNetworkError(i,!0),i.commit()},_setNetworkError:function(e,t){e.set("networkError",t)},onCleanTask:function(){for(var e=this.grid.getStore().data.items,t=0;t<e.length;t++)"success"===e[t].data.status&&(this.removeTask(e[t].get("taskid"),!0),e=this.grid.getStore().data.items,t--)},removeTask:function(e,t){var i=this.dataStore.findExact("taskid",e);-1!==i&&(this.dataStore.removeAt(i),t&&this.appWindow.getTaskMgr().removeTask(e),this.onUpdateGridView())},onDestroy:function(){this.dataStore.destroy(),this.callParent(arguments)}}),Ext.ns("SYNO.SDS.Drive.Log"),SYNO.SDS.Drive.Log.STATUS_COL_WIDTH=150,SYNO.SDS.Drive.Log.LOG_PAGE_LIMIT=1e3,SYNO.SDS.Drive.Log.LOG_COL_WIDTH=250,Ext.define("SYNO.SDS.Drive.Log.Panel",{extend:"SYNO.ux.EditorGridPanel",constructor:function(e){this.owner=e.owner||e.appWin;var t=this.fillConfig(e);this.callParent([t])},initEvents:function(){this.callParent(),this.mon(this.searchPanel,"search",this.onSearch,this,{buffer:this.searchBuffer})},fillConfig:function(e){this.pageSize=SYNO.SDS.Drive.Log.LOG_PAGE_LIMIT;var t=[{id:"log",header:SYNO.SDS.Drive._T("func","mgr_log"),dataIndex:"log",align:"left",renderer:function(e,t,i,n){return i.ridx=n,SYNO.SDS.CSTN.RenderLog(i)},width:SYNO.SDS.Drive.Log.LOG_COL_WIDTH},{id:"time",header:SYNO.SDS.Drive._T("common","time"),dataIndex:"time",align:"left",renderer:function(e,t){return SYNO.SDS.CSTN.RenderTime(e,t)},width:SYNO.SDS.Drive.Log.STATUS_COL_WIDTH}],i=new Ext.grid.ColumnModel({columns:t}),n=this.createStore();this.ds_share=new Ext.data.JsonStore({autoDestroy:!0,
fields:["share_name","share_type"],data:[{share_name:SYNO.SDS.Drive._T("log","log_title_all"),share_type:"all"}]}),this.searchPanel=new SYNO.SDS.Drive.Log.SearchPanel({itemId:"search"}),this.findField=new SYNO.SDS.Drive.Log.AdvancedSearchField({searchPanel:this.searchPanel,iconStyle:"filter",owner:this}),this.selected_index=0,this.combo_share=new SYNO.ux.ComboBox({name:"combo_share",mode:"local",hideLabel:!1,editable:!1,store:this.ds_share,displayField:"share_name",valueField:"share_name",triggerAction:"all",value:"all",hidden:!1,listeners:{scope:this,select:function(e,t,i){this.selected_index=i,this.getStore().load()}}});var o=new Ext.Toolbar;o.add(this.combo_share),o.add("->"),o.add(this.findField);var s=new SYNO.ux.PagingToolbar({store:n,pageSize:this.pageSize,displayInfo:!0,displayMsg:"",emptyMsg:"",moveLast:function(){this.store.setBaseParam("get_all",!0),this.store.load()},listeners:{change:function(){var e=Math.floor(this.store.totalLength/this.pageSize);this.store.totalLength%this.pageSize!=0&&e++;var t=this.getPageData().pages;!0===this.store.baseParams.get_all&&(this.setFocusPage(e),this.cursor=(e-1)*this.pageSize,this.first.setDisabled(1===e),this.prev.setDisabled(1===e),this.next.setDisabled(e===t),this.last.setDisabled(e===t),this.store.setBaseParam("get_all",!1))}}}),r={itemId:"log",cls:"syno-d-log-panel",tbar:o,view:new SYNO.SDS.Drive.FleXcroll.GridView({listeners:{refresh:{scope:this,fn:function(){}}},store:n,searchFields:[this.findField]}),stripeRows:!0,enableColLock:!1,enableHdMenu:!1,enableColumnMove:!1,colModel:i,ds:n,autoExpandColumn:"log",loadMask:!0,bbar:s,sm:new Ext.grid.RowSelectionModel({singleSelect:!1}),listeners:{rowdblclick:{fn:this.rowDoubleClick,scope:this},afterlayout:{single:!0,fn:this.onActivate,scope:this}}};return SYNO.LayoutConfig.fill(r),Ext.apply(r,e),r},canShowVer:function(e){var t=String(e.get("type")),i=SYNO.SDS.CSTN.LogType;return(t===i.restore_node||t===i.add_event||t===i.remove_event||t===i.modify_event||t===i.version_rotate||t===i.rename_event)&&""!==e.get("p1")},rowDoubleClick:function(e,t){var i=this.getStore().getAt(t);this.canShowVer(i)&&this.showDialogVersion(i.get("target"),i.get("s1"),i.get("p1"))},showDialogVersion:function(e,t,i){this.findAppWindow().getAction().showVersion({name:t.substring(t.lastIndexOf("/")+1),file_id:i},this.findWindow())},createStore:function(){var e=["type","username","target","share_name","share_type","time","accessable","filestation_link_prefix","s1","s2","s3","s4","s5","p1","p2","p3","p4","p5","target_share_name","target_share_type","target_accessable","target_link_prefix"],t=new SYNO.API.Store({pruneModifiedRecords:!0,autoDestroy:!0,autoLoad:!1,proxy:new SYNO.API.Proxy({api:SYNO.SDS.CSTN.WebAPI.Log.api,version:1,method:"list"}),reader:new Ext.data.JsonReader({root:"items",totalProperty:"total",idProperty:"id"},e),paramNames:{start:"offset",limit:"limit",sort:"sort_by",dir:"sort_direction"},baseParams:{share_type:"all",offset:0,limit:this.pageSize,view_role:_S("user"),get_all:!1},listeners:{scope:this,beforeload:function(){var e=this.combo_share.getStore().getAt(this.selected_index);this.getStore().setBaseParam("share_type",e.get("share_type")),"share"===e.get("share_type")?this.getStore().setBaseParam("target","@"+e.get("share_name")):this.getStore().setBaseParam("target","user")}}});return this.addManagedComponent(t),t},getShareCombo:function(){SYNO.SDS.CSTN.WebAPI.Share.listActive.call(this.owner,{},function(e,t,i,n){if(e){for(var o=[{share_name:SYNO.SDS.Drive._T("log","log_title_all"),share_type:"all"}],s=0;s<t.total;s++)o="home"===t.items[s].type?o.concat([{share_name:SYNO.SDS.Drive._T("category","node"),share_type:t.items[s].type}]):o.concat([{share_name:t.items[s].name,share_type:t.items[s].type}]);this.ds_share.loadData(o)}SYNO.SDS.CSTN.webapiHdl.call(this,e,t,i,n,{success:SYNO.SDS.CSTN.cbLoad,failure:SYNO.SDS.CSTN.webapiErrHdlMain})},this)},clearSearchParam:function(){var e={keyword:"",datefrom:0,dateto:0,log_type:[]};Ext.apply(this.getStore().baseParams,e),this.combo_share.setValue(SYNO.SDS.Drive._T("log","log_title_all")),this.selected_index=0,this.searchPanel.rendered&&this.searchPanel.onReset(),this.findField.setValue("")},onSearch:function(e,t){Ext.apply(this.getStore().baseParams,t),this.getStore().load()},onPageActivate:function(){this.clearSearchParam(),this.owner.setStatusBusy(),this.getShareCombo()},onActivate:function(){this.onPageActivate()}}),Ext.define("SYNO.SDS.Drive.Log.AdvancedSearchField",{extend:"SYNO.ux.SearchField",constructor:function(e){this.searchPanel=e.searchPanel,this.callParent(arguments)},initEvents:function(){this.callParent(arguments),this.mon(Ext.getDoc(),"mousedown",this.onMouseDown,this),this.mon(this,"keydown",function(e,t){t.getKey()===Ext.EventObject.ENTER&&(this.searchPanel.setKeyWord(this.getValue()),this.searchPanel.onSearch())},this)},checkInnerComponent:function(e,t){var i=!1;return t.items.each(function(t){if(t instanceof Ext.form.ComboBox){if(t.view){if(e.within(t.view.getEl()))return i=!0,!1;!e.within(t.getEl())&&t.view.isVisible()&&t.view.hide()}}else if(t instanceof Ext.ux.form.DateTimeField){if(t.menu){if(e.within(t.menu.getEl())||t.menu.activeChild&&e.within(t.menu.activeChild.getEl()))return i=!0,!1;!e.within(t.wrap)&&t.menu.isVisible()&&t.menu.hide()}}else if(t instanceof Ext.form.CompositeField&&this.checkInnerComponent(e,t))return i=!0,!1},this),i},checkHideMenu:function(e){var t=this.getMenu(),i=this.searchPanel;return!(!i||!t.isVisible()||t.isDestroyed||e.within(t.getEl())||i.attriWin&&i.attriWin.isVisible()||this.checkInnerComponent(e,this.searchPanel.getForm()))},onMouseDown:function(e){e.within(this.searchtrigger)||(this.checkHideMenu(e)?this.hideMenu():window.event||(this.tmp_mouse_event=e))},onTriggerClick:function(){this.callParent(),this.searchPanel.onReset(),this.searchPanel.onSearch()},getMenu:function(){return this.menu||(this.menu=new SYNO.ux.Menu({cls:"syno-d-log-search-menu",owner:this,enableScrolling:!1,defaultOffsets:[0,2],items:[this.searchPanel],listeners:{scope:this,afterlayout:{single:!0,fn:function(e){this.mon(e.getEl(),"click",function(e){this.checkInnerComponent(e,this.searchPanel.getForm())},this)},scope:this},beforehide:function(){var e=window.event||this.tmp_mouse_event;return this.tmp_mouse_event&&delete this.tmp_mouse_event,!e||"click"!==e.type&&"mousedown"!==e.type||this.checkHideMenu(new Ext.EventObjectImpl(e))}}}),this.searchPanel.owner=this.menu,this.owner.addManagedComponent(this.menu)),this.menu},showMenu:function(){return this.rendered&&this.getMenu()&&(this.getMenu().isVisible()&&this.hideMenu(),this.getMenu().ownerCt=this,this.getMenu().show(this.wrap,"tr-br?")),this.searchPanel.setKeyWord(this.getValue()),this},hideMenu:function(){this.getMenu().hide()}}),Ext.define("SYNO.SDS.Drive.DateTimeField",{extend:"SYNO.ux.DateTimeField",constructor:function(){this.callParent(arguments)},onTriggerClick:function(){if(Ext.isEmpty(this.menu)&&(this.menu=new SYNO.ux.DateTimeMenu({hideOnClick:!1,focusOnSelect:!1,allowOtherMenus:!0,defaultOffsets:[0,2],ownerField:this,pickerCfg:this.getPickerCfg()}),this.el.setARIAOwns(this.menu.id),this.mon(this.menu,"hide",this.onDateMenuHide,this)),this.menu.isVisible())return void this.menuEvents("hide");SYNO.SDS.Drive.DateTimeField.superclass.onTriggerClick.apply(this,arguments)}}),Ext.ns("SYNO.SDS.Drive.Log"),Ext.define("SYNO.SDS.Drive.Log.SearchPanel",{extend:"SYNO.ux.FormPanel",constructor:function(e){this.dateType={custom:1,today:2,yesterday:4,lastweek:8,lastmonth:16},this.dataRange=[[this.dateType.custom,SYNO.SDS.Drive._T("log","date_custom")],[this.dateType.today,SYNO.SDS.Drive._T("log","date_today")],[this.dateType.yesterday,SYNO.SDS.Drive._T("log","date_yesterday")],[this.dateType.lastweek,SYNO.SDS.Drive._T("log","date_lastweek")],[this.dateType.lastmonth,SYNO.SDS.Drive._T("log","date_lastmonth")]],this.logType=SYNO.SDS.CSTN.LogType,this.logDescAdmin=[[this.logType.share_save,SYNO.SDS.Drive._T("log","log_type_share_save")],[this.logType.client_unlink,SYNO.SDS.Drive._T("log","log_type_client_unlink")],[this.logType.restore_node,SYNO.SDS.Drive._T("log","log_type_restore_node")],[this.logType.delfile_forever,SYNO.SDS.Drive._T("log","log_type_delfile_forever")],[this.logType.rotate_set,SYNO.SDS.Drive._T("log","log_type_rotate_set")],[this.logType.volume_set,SYNO.SDS.Drive._T("log","log_type_volume_set")],[this.logType.log_rotate_cnt_set,SYNO.SDS.Drive._T("log","log_type_log_rotate_cnt_set")],[this.logType.log_rotate_span_set,SYNO.SDS.Drive._T("log","log_type_log_rotate_span_set")],[this.logType.log_delete,SYNO.SDS.Drive._T("log","log_type_log_delete")],[this.logType.client_link,SYNO.SDS.Drive._T("log","log_type_client_link")],[this.logType.add_event,SYNO.SDS.Drive._T("log","log_type_add_event")],[this.logType.remove_event,SYNO.SDS.Drive._T("log","log_type_remove_event")],[this.logType.modify_event,SYNO.SDS.Drive._T("log","log_type_modify_event")],[this.logType.rename_event,SYNO.SDS.Drive._T("log","log_type_rename_event")],[this.logType.version_rotate,SYNO.SDS.Drive._T("log","log_type_version_rotate")]],this.logDesc=[[this.logType.client_unlink,SYNO.SDS.Drive._T("log","log_type_client_unlink")],[this.logType.restore_node,SYNO.SDS.Drive._T("log","log_type_restore_node")],[this.logType.delfile_forever,SYNO.SDS.Drive._T("log","log_type_delfile_forever")],[this.logType.client_link,SYNO.SDS.Drive._T("log","log_type_client_link")],[this.logType.add_event,SYNO.SDS.Drive._T("log","log_type_add_event")],[this.logType.remove_event,SYNO.SDS.Drive._T("log","log_type_remove_event")],[this.logType.modify_event,SYNO.SDS.Drive._T("log","log_type_modify_event")],[this.logType.rename_event,SYNO.SDS.Drive._T("log","log_type_rename_event")],[this.logType.version_rotate,SYNO.SDS.Drive._T("log","log_type_version_rotate")]],this.defaultAnimation=["#000",1,{duration:.35}],Ext.apply(this,e||{});var t=this.fillConfig(e);this.callParent([t])},fillConfig:function(){var e,t,i,n,o=[];e=this.createKeyword(),t=this.createFriendlyDate(),i=this.createCustDate(),n=this.createType(),o.push(e),o.push(t),o.push(i),o.push(n);var s={xtype:"toolbar",border:!1,itemId:"btns",items:[{xtype:"tbfill"}]},r=[{xtype:"syno_button",btnStyle:"grey",style:{"border-radius":"15px","box-sizing":"border-box"},minWidth:80,text:_T("common","reset"),handler:this.onReset,scope:this},{xtype:"syno_button",style:{"border-radius":"15px","box-sizing":"border-box"},text:_T("log","search"),itemId:"btn_search",handler:this.onSearch,scope:this}];return s.items.push.apply(s.items,r),o.push(s),{width:368,heigh:480,labelAlign:"top",trackResetOnLoad:!0,border:!1,cls:"syno-d-log-search-panel",autoFlexcroll:!1,defaults:{anchor:"100%"},items:o,keys:[{key:[Ext.EventObject.ENTER],scope:this,fn:function(){this.owner.isVisible()&&this.onSearch()}}]}},setComboBoxValue:function(e,t){this.frameAnimation(e.el,this.defaultAnimation),e.setMultiValue&&e.setMultiValue(t)},getComboBoxValue:function(e){var t=this.getForm().findField(e);return t.getMultiValue?t.getMultiValue():[t.getValue()]},multiSelect:function(e,t,i,n,o){if("more"===t.get("value"))return this.attriWin=new SYNO.SDS.Drive.Log.MultiSelectedDialog({title:n,combo:e,emptyValue:o,anim:this.defaultAnimation,owner:this.owner.findWindow()}),this.attriWin.showUp(),e.collapse(),!1},logSelect:function(e){this.setComboBoxValue(e,e.getValue())},createKeyword:function(){return[{fieldLabel:SYNO.SDS.Drive._T("log","attr_keyword"),xtype:"syno_textfield",name:"keyword",vaule:""}]},setDate:function(e,t,i){!0===i&&(this.frameAnimation(this.form.findField("searchdatefrom").el,this.defaultAnimation),this.frameAnimation(this.form.findField("searchdateto").el,this.defaultAnimation)),this.form.findField("searchdatefrom").setMaxValue(t),this.form.findField("searchdateto").setMinValue(e),this.form.findField("searchdatefrom").setValue(e),this.form.findField("searchdateto").setValue(t)},getFromToDate:function(e){var t,i,n=new Date;if(e===this.dateType.today)t=n,i=n;else if(e===this.dateType.yesterday)t=n.add(Date.DAY,-1),i=t;else if(e===this.dateType.lastweek){var o=n.getDay();t=n.add(Date.DAY,-7-o),i=t.add(Date.DAY,6)}else e===this.dateType.lastmonth&&(n=n.add(Date.MONTH,-1),t=n.getFirstDateOfMonth(),i=n.getLastDateOfMonth());return{from:t,to:i}},friendlyDateSelect:function(e,t){var i=t.get("id"),n=this.getFromToDate(i);this.setDate(n.from,n.to,!0)},getFriendlyDateStore:function(){var e=this.dataRange;return new Ext.data.ArrayStore({autoDestroy:!0,fields:["id","displayText"],data:e})},createFriendlyDate:function(){return this.FriendlyDate=new SYNO.ux.ComboBox({fieldLabel:SYNO.SDS.Drive._T("log","date_range"),mode:"local",editable:!1,name:"dateRange",store:this.getFriendlyDateStore(),displayField:"displayText",valueField:"id",triggerAction:"all",value:this.dateType.custom,listeners:{scope:this,beforeselect:this.friendlyDateSelect}}),[this.FriendlyDate]},createCustDate:function(){return this.DateFrom=new SYNO.SDS.Drive.DateTimeField({name:"searchdatefrom",editable:!1,format:SYNO.SDS.Drive.Utils.getDateFormat(),emptyText:_T("log","date_from"),value:"",listeners:{scope:this,select:function(e,t){this.form.findField("searchdateto").setMinValue(t)}}}),this.DateTo=new SYNO.SDS.Drive.DateTimeField({name:"searchdateto",editable:!1,format:SYNO.SDS.Drive.Utils.getDateFormat(),emptyText:_T("log","date_to"),value:"",listeners:{scope:this,select:function(e,t){this.form.findField("searchdatefrom").setMaxValue(t)}}}),[{xtype:"syno_compositefield",fieldLabel:SYNO.SDS.Drive._T("time","time_date"),defaults:{flex:1},defaultMargins:"0 8 0 0",items:[this.DateFrom,this.DateTo]}]},getLogTypeStore:function(){var e;return e=_S("is_admin")?this.logDescAdmin.slice(0,this.logDescAdmin.length):this.logDesc.slice(0,this.logDesc.length),e.length>1&&e.splice(0,0,["all",SYNO.SDS.Drive._T("log","log_title_all")],["more",SYNO.SDS.Drive._T("log","more_item")+"..."]),new Ext.data.ArrayStore({autoDestroy:!0,multiValue:[],fields:["value","displayText"],data:e})},multiLogTypeSelect:function(e,t,i){this.multiSelect(e,t,i,SYNO.SDS.Drive._T("log","log_type"),"all")},createType:function(){return this.logTypeCombo=new SYNO.ux.ComboBox({xtype:"syno_combobox",fieldLabel:SYNO.SDS.Drive._T("log","log_type"),mode:"local",editable:!1,name:"logType",store:this.getLogTypeStore(),displayField:"displayText",valueField:"value",triggerAction:"all",value:"all",listeners:{scope:this,beforeselect:this.multiLogTypeSelect,select:this.logSelect,expand:{fn:function(){this.inEl=!0},scope:this},collapse:{fn:function(){this.inEl=!1},scope:this}},getMultiValue:function(){return this.multiValue},setMultiValue:function(e){Ext.isArray(e)?this.multiValue=e:"all"===e?this.multiValue=[]:"more"!==e&&(this.multiValue=[e])}}),[this.logTypeCombo]},frameAnimation:function(e,t){e&&e.isVisible()&&Ext.Element.prototype.frame.apply(e,t)},setKeyWord:function(e){var t=this.form.findField("keyword");t&&Ext.isString(e)&&t.setValue(e),t.focus("",1)},onSearch:function(){var e,t,i,n,o,s;e=this.getForm(),t=e.findField("keyword").getValue(),i=e.findField("searchdatefrom"),n=e.findField("searchdateto"),o=this.getComboBoxValue("logType"),s={keyword:t,datefrom:i.getRawValue()?Date.parseDate(i.getRawValue()+" 00:00:00",i.format+" H:i:s").getTime()/1e3:0,dateto:n.getRawValue()?Date.parseDate(n.getRawValue()+" 23:59:59",n.format+" H:i:s").getTime()/1e3:0,log_type:o},this.fireEvent("search",this,s),this.owner.hide()},onReset:function(){this.form.items.each(function(e){e.isDirty()&&this.frameAnimation(e.el,this.defaultAnimation)},this),this.form.reset(),this.form.findField("searchdatefrom").setMaxValue(null),this.form.findField("searchdateto").setMinValue(null),this.form.findField("logType").setMultiValue("all")}}),Ext.define("SYNO.SDS.Drive.Log.MultiSelectedDialog",{extend:"SYNO.SDS.Drive.VueModalWindow",constructor:function(e){Ext.apply(this,e),this.orginalValue=this.combo.getMultiValue?this.combo.getMultiValue():this.combo.getValue(),this.orginalDisplayValue=this.combo.getRawValue(),this.attriFormPanel=this.createAttriFormPanel();var t={width:450,height:500,resizable:!1,title:e.title,layout:"fit",closable:!0,owner:e.owner,items:[this.attriFormPanel],buttons:[{text:_T("common","cancel"),itemId:"cancel",handler:this.onCancel,scope:this},{text:_T("common","apply"),btnStyle:"default",itemId:"apply",handler:this.onOk,scope:this}],listeners:{scope:this,show:function(e){var t=this.combo.ownerCt.owner,i=parseInt(e.getEl().getStyle("z-index"),10);t.el.setZIndex(i-3);var n=t.getEl().mask();n.setOpacity(0),n.setStyle("z-index",i-1)},beforehide:function(){this.combo.ownerCt.owner.el.unmask()}}};SYNO.SDS.Drive.Log.MultiSelectedDialog.superclass.constructor.call(this,t),this.initEvent()},initEvent:function(){this.mon(this,"close",this.onClose,this)},createAttriFormPanel:function(){var e,t,i=this.combo.getStore(),n=[],o=this.combo.displayField,s=this.combo.valueField;n.push({xtype:"syno_displayfield",indent:0,value:_T("log","title_select_desc")}),i.each(function(r){if(e=r.get(s),t=r.get(o),0===i.indexOf(r)||"more"===e)return!0;var a={xtype:"syno_checkbox",indent:1,name:""+r.get(s),boxLabel:r.get(o)};n.push(a)},this);var r={labelWidth:190,labelAlign:"left",border:!1,autoScroll:!0,trackResetOnLoad:!0,items:n};return new SYNO.ux.FormPanel(r)},setCheckBox:function(){var e=this.attriFormPanel.getForm(),t=this.combo,i=t.getStore(),n=t.getMultiValue()||[],o=t.valueField;n=n.length>0?n:[t.getValue()],i.each(function(t){var i=t.get(o);-1!==n.indexOf(i)&&e.findField(""+i)&&e.findField(""+i).setValue(!0)},this)},showUp:function(){this.setCheckBox(),this.open()},onOk:function(){var e=this.attriFormPanel.getForm(),t=this.combo,i=t.getStore(),n=[],o=[],s=t.displayField,r=t.valueField;i.each(function(t){var i=t.get(r),a=t.get(s),l=e.findField(""+i);l&&l.getValue()&&(n.push(a),o.push(i))},this),n.length===i.getCount()-2?t.setValue(this.emptyValue):0<n.length?t.setRawValue(n.toString()):t.setValue(this.emptyValue),t.setMultiValue(o),this.isOK=!0,Ext.Element.prototype.frame.apply(t.el,this.anim),this.close()},onCancel:function(){this.close()},onClose:function(){var e=this.combo;this.isOK||(e.setMultiValue(this.orginalValue),e.setRawValue(this.orginalDisplayValue))}}),Ext.ns("SYNO.SDS.Drive.Log"),Ext.define("SYNO.SDS.Drive.Log.Dialog",{extend:"SYNO.SDS.Drive.ModalWindow",constructor:function(e){var t=this.fillConfig(e);this.callParent([t])},fillConfig:function(e){var t={title:SYNO.SDS.Drive._T("func","mgr_log"),width:800,height:600,layout:"fit",items:this.getPanel(e),buttons:[{xtype:"syno_button",text:_T("common","close"),scope:this,handler:this.close}]};return Ext.apply(t,e)},getPanel:function(e){return this.panel||(this.panel=new SYNO.SDS.Drive.Log.Panel(e))}}),Ext.define("SYNO.SDS.Drive.QuotaInfo.Grid",{extend:"SYNO.ux.GridPanel",constructor:function(){this.callParent([this.fillConfig()])},fillConfig:function(){return{cls:"syno-d-quota-grid-panel",hideHeaders:!0,disableSelection:!0,store:new SYNO.API.JsonStore({autoDestroy:!1,root:"share_list",proxy:new SYNO.API.Proxy(SYNO.SDS.Drive.WebAPIDesc.get_quota),fields:[{name:"name",convert:function(e,t){return"homes"===e?SYNO.SDS.Drive._T("category","node"):e}},{name:"quota"},{name:"used"},{name:"share_quota"},{name:"share_used"},{name:"is_home"},{name:"support_per_share_quota"}],listeners:{scope:this,beforeload:this.onStoreBeforeLoad,load:this.onStoreLoad,exception:this.onStoreException}}),view:new SYNO.ux.FleXcroll.grid.BufferView({rowHeight:54,disableTextSelect:!0,deferEmptyText:!1}),height:375,colModel:new Ext.grid.ColumnModel({defaults:{menuDisabled:!0,editable:!1,fixed:!0,align:"left"},columns:[{width:46,renderer:{fn:this.renderIcon,scope:this}},{width:226,dataIndex:"name"},{width:216,renderer:{fn:this.renderQuotaInfo,scope:this}}]})}},onStoreBeforeLoad:function(){this.findWindow().setStatusBusy()},onStoreLoad:function(){this.findWindow().clearStatusBusy(),this.store.filter("support_per_share_quota",!0)},onStoreException:function(e,t,i,n,o,s){this.findWindow().clearStatusBusy(),this.findWindow().getMsgBox().alert("",SYNO.SDS.Drive.Utils.getErrorStr(o),function(){this.findWindow().close()},this)},renderIcon:function(e,t,i){var n=i.get("is_home");t.css+=!0===n?"syno-quota-home-folder ":"syno-quota-team-folder "},renderQuotaInfo:function(e,t,i){var n=i.get("quota"),o=i.get("used"),s=i.get("share_quota"),r=i.get("share_used");return this.showProgressBar(n,o,s,r)},loadData:function(){this.store.load()},showProgressBar:function(e,t,i,n){var o=this.getProgressTpl(),s=this.getTaskInfoTpl(),r='<span class="syno-d-quota-used-bold">'+Ext.util.Format.fileSize(1024*t*1024)+"</span>",a='<span class="syno-d-quota-used-bold">'+Ext.util.Format.fileSize(1024*e*1024)+"</span>",l=-1,d=-1,c=0;0<e&&(l=100*t/e),0<i&&(d=100*n/i);var h=t/1024,u=e/1024,p=n/1024,S=i/1024,f=99<l&&2>u-h,g=99<d&&2>S-p;if(!0===f)return String.format('<div class="syno-d-quota-used-limit"> {0} </div>',SYNO.SDS.Drive._T("quota","reach_personal_quota_limit"));if(!0===g)return String.format('<div class="syno-d-quota-used-limit"> {0} </div>',SYNO.SDS.Drive._T("quota","reach_share_quota_limit"));if(!(0<e)){var m=String.format(SYNO.SDS.Drive._T("quota","used"),r);return String.format('<div class="syno-d-quota-used"> {0} </div>',m)}return c=Math.round(l),s.apply({showText:String.format(SYNO.SDS.Drive._T("quota","used_of_quota"),r,a),progress:o.fill(c,"",100===c)})},getProgressTpl:function(){return this.progressBar?this.progressBar:(this.progressBar=new SYNO.SDS.Utils.ProgressBar({barWidth:200,barHeight:4,showValueText:!1}),this.progressBar)},getTaskInfoTpl:function(){return this.taskInfoTpl?this.taskInfoTpl:(this.taskInfoTpl=new Ext.XTemplate('<div class="syno-d-bgtask-info-wrapper">','<div class="syno-d-bgtask-info-wrapper-top">','<span class="syno-d-quota-used"> {showText} </span>',"</div>",'<div class="syno-d-bgtask-info-wrapper-bottom">',"{progress}","</div>","</div>"),this.taskInfoTpl)},onWindowShow:function(){this.loadData()}}),Ext.define("SYNO.SDS.Drive.QuotaInfo.Window",{extend:"SYNO.SDS.Drive.ModalWindow",constructor:function(e){this.callParent([this.fillConfig(e)])},fillConfig:function(e){var t,i={owner:e.owner,title:SYNO.SDS.Drive._T("quota","storage_usage"),cls:"syno-d-quota-window",height:545,width:580,resizable:!1,items:[],buttons:[{text:_T("common","close"),scope:this,handler:this.close}],listeners:{}};return 0===e.data.length?t={layout:{type:"vbox",align:"center",pack:"center"},cls:"syno-d-quota-empty-panel",items:[{cls:"syno-d-quota-empty-icon"},{xtype:"syno_displayfield",cls:"syno-d-quota-empty-desc",value:SYNO.SDS.Drive._T("quota","quota_not_support"),width:360}]}:(this.gridPanel=new SYNO.SDS.Drive.QuotaInfo.Grid,t={layout:"vbox",layoutConfig:{align:"stretch"},items:[{xtype:"syno_displayfield",html:SYNO.SDS.Drive._T("quota","description")+'<div class="quota-spacer"></div><div id="quota-quick-tip"></div>',listeners:{scope:this,afterrender:function(e){var t=SYNO.SDS.Drive._T("quota","description_c2_quicktip");new SYNO.SDS.Drive.WhiteQuickTip({tipWidth:320,tipItems:new Ext.BoxComponent({html:t}),renderTo:"quota-quick-tip"})}}},this.gridPanel],listeners:{scope:this.gridPanel,show:this.gridPanel.onWindowShow}}),Ext.apply(i,t)}}),Ext.define("SYNO.SDS.Drive.Toolbar",{extend:"Ext.Container",constructor:function(e){this.owner=e.owner,this.callParent([Ext.apply({layout:"border",width:60,cls:"syno-d-main-toolbar",items:[this.getTopPanel(),this.getBottomPanel(),this.getShareVuePanel(),this.getRequestVuePanel(),this.getFileLabelTipPanel()],listeners:{scope:this,beforeshow:this.onBeforeShow}},e)]),this.onRegEvent()},onRegEvent:function(){var e=this.findAppWindow().getEventMgr();this.mon(e,{scope:this,notification_update:this.onUpdateNotification,hide_bgtask_tray:this.onHideBgTask,envready:this.onUpdateUserIcon}),this.mon(e,"envready",this.onUpdateClientDownloadMenu,this),this.mon(e,"bgtask_update",this.onUpdateBgTask,this,{buffer:100}),this.mon(e,"show_bgtask_tray",this.onShowBgTask,this,{buffer:300})},onBeforeShow:Ext.emptyFn,getShareVuePanel:function(){return this.shareVuePanel?this.shareVuePanel:(this.shareVuePanel=new SYNO.SDS.Drive.VuePanel({vueClass:SYNO.SDS.Drive.Vue.ShareGetLinkMenu,mountId:"shareGetLinkMenu",layout:"fit",cls:"ShareGetLinkMenu",owner:this}),this.shareVuePanel)},getRequestVuePanel:function(){return this.requestVuePanel?this.requestVuePanel:(this.requestVuePanel=new SYNO.SDS.Drive.VuePanel({vueClass:SYNO.SDS.Drive.Vue.RequestGetLinkMenu,mountId:"requestGetLinkMenu",layout:"fit",cls:"RequestGetLinkMenu",owner:this}),this.requestVuePanel)},getFileLabelTipPanel:function(){return this.fileLabelTipPanel?this.fileLabelTipPanel:(this.fileLabelTipPanel=new SYNO.SDS.Drive.VuePanel({vueClass:SYNO.SDS.Drive.Vue.FileListLabelTooltip,mountId:"fileListLabelTooltip",layout:"fit",cls:"FileListLabelTooltip",owner:this}),this.fileLabelTipPanel)},getTopPanel:function(){var e="SYNO.SDS.Drive.Application"===_S("standaloneAppName");SYNO.SDS.Drive.Utils.isLogined()&&SYNO.SDS.JSLoad("SYNO.SDS.AppLauncher.Panel",function(){this.appLauncherPanel=new SYNO.SDS.AppLauncher.Panel({width:380,height:216,padding:"15px",defaultOffsets:[54,16],animate:!1}),e&&SYNO.SDS.Drive.Utils.isLogined()&&this.appLauncherPanel.mon(this.appLauncherPanel.launcherView.getStore(),"load",function(){this.hasOtherApp()||(this.items.get("top").get("home").hide(),this.items.get("top").get("home-sep").removeClass("syno-d-toolbar-sep-first"),this.items.get("top").get("home-sep").addClass("syno-d-toolbar-sep-first-hide"))},this,{single:!0}),this.appLauncherPanel.hide()},this);var t=[{xtype:"synodrive_simple_button",itemId:"home",ctCls:"syno-d-home-icon-ct",cls:e?"syno-d-launcher-icon":"syno-d-home-icon",tooltip:e?void 0:SYNO.SDS.Drive._T("drive","home"),handler:function(){if(!SYNO.SDS.Drive.Utils.isLogined()||!e)return void this.onOpenMgr();this.appLauncherPanel&&this.hasOtherApp()&&(this.appLauncherPanel.isVisible()?this.appLauncherPanel.hide():this.appLauncherPanel.show())},scope:this},{itemId:"home-sep",xtype:"container",ctCls:"syno-d-toolbar-sep-ct",cls:"syno-d-toolbar-sep-first"}];return this.onAddTopItems(t),{itemId:"top",xtype:"container",region:"center",width:40,layout:new SYNO.SDS.Drive.Toolbar.TableLayout,margins:{left:10,right:10,top:0,bottom:0},defaults:{xtype:"synodrive_round_button",hideParent:!0},cls:"syno-d-main-top-toolbar",items:t}},hasOtherApp:function(){var e=this.appLauncherPanel.launcherView.getStore(),t=e.getTotalCount(),i=!1;return 1<t?i=!0:1===t&&e.each(function(e){if("SYNO.SDS.Office.Application"!==e.get("appname")&&"SYNO.SDS.Drive.Application"!==e.get("appname"))return i=!0,!1}),i},onAddTopItems:function(e){SYNO.SDS.Drive.Utils.isAppAuthorized()&&"SYNO.SDS.Drive.PublicApplication"!==_S("standaloneAppName")&&e.push([this.btn_notification=new SYNO.SDS.Drive.SimpleButton({cls:"syno-d-notification-btn",itemId:"notification",scope:this,menuAlign:"tl-tr",menu:this.getNotificationMenu()}),this.btn_notification_count=new SYNO.SDS.Drive.SimpleButton({hidden:!0,cls:"syno-d-notification-count",itemId:"notification-count",scope:this,menuAlign:"tl-tr",menu:this.getNotificationMenu()})]),e.push(this.btn_bgtask_tray=new SYNO.SDS.Drive.SimpleButton({hidden:!0,cls:"syno-d-bgtask-tray-btn",itemId:"bgtask-tray",scope:this,menuAlign:"tl-tr",menu:this.getBackgroundTray()}))},onOpenMgr:function(){var e;if(this.appLauncherPanel){this.appLauncherPanel.launcherView.getStore().each(function(t){if("SYNO.SDS.Drive.Application"===t.get("appname"))return e=t.get("launch_url"),!1})}e||window.location.port&&!SYNO.SDS.Drive.WindowHelper.getBaseAppPath()||(e=SYNO.SDS.Drive.WindowHelper.getBaseAppURL()),e?window.open(e,"_blank"):SYNO.SDS.Drive.Utils.onOpenMgr()},updateAccountIcon:function(e,t){var i={retina:SYNO.SDS.UIFeatures.test("isRetina"),size:"S"};e&&(i._dc=Ext.id(void 0,"photo_"));var n=this.getBaseURL({api:"SYNO.SynologyDrive.SCIM.Photo",version:1,method:"get",params:i},!0,this._S("user")+".png");SYNO.SDS.Drive.Utils.updateAccountIcon(this.icon_btn,n),t&&(t.nickName||t.userName)&&(this.oriDisplayName=t.userName,this.displayName=Ext.util.Format.htmlEncode(t.userName),SYNO.SDS.Drive.Define.Info.use_nickname&&t.nickName&&(this.oriDisplayName=t.nickName,this.displayName=Ext.util.Format.htmlEncode(t.nickName)),this.icon_btn.setText(SYNO.SDS.Drive.Utils.getAccount1stName(this.oriDisplayName)))},onUpdateUserIcon:function(){SYNO.SDS.Drive.Utils.isLogined()&&(this.findAppWindow().getWebAPI().getUsers({params:{user:[_S("user")]},scope:this,callback:function(e,t){if(e&&t&&t.users){var i=t.users[0];this.oriDisplayName=i.name,this.displayName=Ext.util.Format.htmlEncode(i.name),SYNO.SDS.Drive.Define.Info.use_nickname&&i.nick&&(this.oriDisplayName=i.nick,this.displayName=Ext.util.Format.htmlEncode(i.nick)),this.icon_btn.setText(SYNO.SDS.Drive.Utils.getAccount1stName(this.oriDisplayName))}}}),this.findAppWindow().getWebAPI().getQuotaInfo({scope:this,callback:function(e,t){if(e&&t){var i=this;this.quotaInfoList=[],Ext.each(t.share_list,function(e){!0===e.support_per_share_quota&&(i.quotaInfoList.push(e),i.isShowMyDrive=i.isShowMyDrive||e.is_home)})}}}))},onUpdateClientDownloadMenu:function(){_S("is_admin")||SYNO.SDS.Drive.Define.Info.enable_non_admin_user_sync||Ext.getCmp(this.clientDownloadMenuId).setVisible(!1)},onUpdateC2TransferBtn:function(){this.findAppWindow().send_copy_enabled&&!0===this.findAppWindow().send_copy_enabled?this.c2TransferBtn.setVisible(!0):this.c2TransferBtn.setVisible(!1)},getBottomPanel:function(){var e=[];return e.push({xtype:"container",height:0,ctCls:"syno-d-toolbar-sep-ct syno-d-account-sep-ct",cls:"syno-d-toolbar-sep"}),this.onAddBottomItems(e),{itemId:"bottom",xtype:"container",region:"south",height:100,width:40,cls:"syno-d-main-bottom-toolbar",layout:new SYNO.SDS.Drive.Toolbar.TableLayout,margins:{left:10,right:10,top:0,bottom:0},defaults:{hideParent:!0},items:e,listeners:{scope:this,single:!0,afterlayout:this.onBottomAfterLayout}}},onAddBottomItems:function(e){e.push(this.onCreateAccountBtn())},getC2TransferBtn:function(){return this.c2TransferBtn?this.c2TransferBtn:(this.c2TransferBtn=new SYNO.SDS.Drive.Comp.C2TransferButton({appWindow:this.findAppWindow(),itemId:"C2TransferBtn"}),this.c2TransferBtn)},onCreateAccountBtn:function(){var e=SYNO.SDS.Drive._T,t=SYNO.SDS.Drive.Utils.isLogined(),i=SYNO.SDS.Drive.Utils.isAppAuthorized(),n=[],o=this;t&&(i&&(this.quotaFieldSet=new SYNO.ux.FieldSet({xtype:"syno_fieldset",cls:"syno-d-quota-fieldset",headerCfg:{style:"padding-top: 8px",cls:"x-fieldset-header",html:"name"},items:[{xtype:"syno_displayfield",cls:"syno-d-drive-text",itemId:"my-drive",value:e("category","node"),listeners:{afterrender:function(e){this.mon(e.getEl(),"click",function(){this.icon_btn.menu.get("storage_usage_win").fireEvent("click"),this.icon_btn.menu.hide()},this)},scope:this}},{xtype:"syno_displayfield",cls:"syno-d-quota-used-text",itemId:"quota-used-info",html:"used",listeners:{afterrender:function(e){this.mon(e.getEl(),"click",function(){this.icon_btn.menu.get("storage_usage_win").fireEvent("click"),this.icon_btn.menu.hide()},this)},scope:this}},{xtype:"syno_displayfield",itemId:"quota-progress-bar",html:this.onQuotaInfoRender(),listeners:{afterrender:function(e){this.mon(e.getEl(),"click",function(){this.icon_btn.menu.get("storage_usage_win").fireEvent("click"),this.icon_btn.menu.hide()},this)},scope:this}}],scope:this.findAppWindow()}),n.push(this.quotaFieldSet,"-",{text:e("common","setting"),scope:this.findAppWindow(),handler:function(){var e={};SYNO.SDS.Drive.WebAPICore.sendPromise("get_setting").then(function(t){e=t}.bind(this)).catch(function(e){SYNO.Debug.error(e)}.bind(this)).finally(function(){new SYNO.SDS.Drive.Setting.Window({owner:this,module:o,drive_setting:e}).show()}.bind(this))}},{text:e("quota","storage_usage_account"),itemId:"storage_usage_win",scope:this.findAppWindow(),handler:this.onClickStorage},{text:e("func","mgr_log"),scope:this.findAppWindow(),handler:this.onClickLog},{text:e("func","mgr_clientinfo_account"),scope:this.findAppWindow(),handler:function(){new SYNO.SDS.Drive.Client.Dialog({owner:this,module:o}).show()}},{
id:this.clientDownloadMenuId=Ext.id(),text:e("common","get_desktop_and_mobile_apps"),scope:this.findAppWindow(),handler:function(){new SYNO.SDS.Drive.DownloadClient.Window({owner:this,module:o}).show()}},"-")),n.push({text:_T("common","alt_help"),scope:this.findAppWindow(),handler:this.onClickHelp},{text:_T("personal_settings","about"),handler:function(){SYNO.SDS.Drive.GetWindow().showAboutWindow()}},"-",{text:e("common","sign_out_account"),handler:function(){if(SYNO.SDS.Utils.Logout.setConfig({reserveQueryString:!0}),SYNO.SDS.System)SYNO.SDS.System.Logout();else try{SYNO.SDS.Utils.Logout.action()}catch(e){}}}));var s=new SYNO.SDS.Drive.RoundButton({itemId:"account",cls:"syno-d-account-icon-m",tooltip:_S("user"),menuAlign:"bl-br",text:SYNO.SDS.Drive.Utils.getAccount1stName(_S("user")),menu:t?new SYNO.ux.Menu({cls:"syno-d-account-menu",ignoreParentClicks:!0,width:"auto",defaultOffsets:[8,0],items:n}):void 0,scope:this,handler:t?this.onClickIcon:this.onLogin});return this.icon_btn=s,this.updateAccountIcon(),s},onBottomAfterLayout:function(e){},getTagStore:function(){return this.tagStore?this.tagStore:(this.tagStore=new SYNO.API.Store({autoLoad:SYNO.SDS.Drive.Utils.isAppAuthorized(),remoteSort:!1,proxy:new SYNO.API.Proxy({api:"SYNO.SynologyDrive.Labels",version:1,method:"list",listeners:{scope:this,beforeload:function(e,t){var i=e.activeRequest.read;i&&Ext.Ajax.abort(i)}}}),reader:new Ext.data.JsonReader({root:"items",id:"label_id"},[{name:"label_id"},{name:"name"},{name:"color",convert:function(e,t){return e.substr(1)}},{name:"position"},{name:"category",defaultValue:"label"}])}),this.findAppWindow().addManagedComponent(this.tagStore),this.tagStore)},getNotificationMenu:function(){return this.notification_menu||(this.notification_menu=new SYNO.SDS.Drive.Notification.Menu({defaultOffsets:[8,0],owner:this}))},getBackgroundTray:function(){return this.background_tray||(this.background_tray=new SYNO.SDS.Drive.Task.TrayPanel({owner:this,defaultOffsets:[8,0],appWindow:this.findAppWindow()}))},onClickIcon:function(){this.findAppWindow().getWebAPI().getQuotaInfo({scope:this,callback:function(e,t){if(e&&t){var i=this;this.quotaInfoList=[],Ext.each(t.share_list,function(e){!0===e.support_per_share_quota&&(i.quotaInfoList.push(e),i.isShowMyDrive=i.isShowMyDrive||e.is_home)}),this.updateQuotaInfo()}}}),this.updateQuotaInfo()},onClickStorage:function(){new SYNO.SDS.Drive.QuotaInfo.Window({owner:this.findAppWindow(),data:this.getLeftPanel().quotaInfoList}).show()},onClickLog:function(){new SYNO.SDS.Drive.Log.Dialog({owner:this}).show()},onClickHelp:function(){var e="SYNO.SDS.Drive.Application",t=this.getHelpParam();Ext.isString(t)&&t.length>0&&(e+=":"+t),SYNO.SDS.Drive.Utils.openURL(SYNO.SDS.Drive.Utils.getHelpURL(e),null,!0)},onUpdateNotification:function(e){this.btn_notification.setVisible(0===e),this.btn_notification_count.setVisible(0!==e),0!==e&&this.btn_notification_count.setText(e>99?"<span class='syno-d-notification-count-over'>99+</span>":e)},onUpdateBgTask:function(e,t,i){if(this.btn_bgtask_tray.el.removeClass("syno-d-bgtask-tray-btn"),this.btn_bgtask_tray.el.removeClass("syno-d-bgtask-tray-gif-btn"),this.blAnimate=t,t?this.btn_bgtask_tray.el.addClass("syno-d-bgtask-tray-gif-btn"):this.btn_bgtask_tray.el.addClass("syno-d-bgtask-tray-btn"),void 0!==e&&this.btn_bgtask_tray.setVisible(e),!1===e&&this.btn_bgtask_tray.menu.hide(),!0===i){this.btn_bgtask_tray.setVisible(!0);var n=this.btn_bgtask_tray.getEl().getXY();n[0]+=32,this.btn_bgtask_tray.menu.showAt(n)}},onShowBgTask:function(){this.onUpdateBgTask(!0,this.blAnimate,!0)},onHideBgTask:function(){this.onUpdateBgTask(!1,!1,!1)},onLogin:function(){window.location=SYNO.SDS.Drive.Utils.getAppURL()},onQuotaInfoRender:function(){var e=this.getProgressTpl(),t=this.getTaskInfoTpl(),i=25;if(!this.isShowMyDrive)return"";var n=this.quotaInfoList[0].quota,o=this.quotaInfoList[0].used;return 0!==n&&(i=Math.round(100*o/n)),t.apply({progress:e.fill(i,"",100===i)})},getQuotaInfoText:function(e){var t="<b>"+Ext.util.Format.fileSize(1024*e.used*1024)+"</b>",i="<b>"+Ext.util.Format.fileSize(1024*e.quota*1024)+"</b>",n=String.format(SYNO.SDS.Drive._T("quota","used_of_quota"),t,i);return 0===e.quota&&(n=String.format(SYNO.SDS.Drive._T("quota","used"),t)),n},getProgressTpl:function(){return this.progressBar?this.progressBar:(this.progressBar=new SYNO.SDS.Utils.ProgressBar({barWidth:220,barHeight:4,showValueText:!1}),this.progressBar)},getTaskInfoTpl:function(){return this.taskInfoTpl?this.taskInfoTpl:(this.taskInfoTpl=new Ext.XTemplate('<div class="syno-d-bgtask-info-wrapper">','<div class="syno-d-bgtask-info-wrapper-bottom">',"{progress}","</div>","</div>"),this.taskInfoTpl)},updateQuotaInfo:function(){if(this.quotaFieldSet.setTitle(this.displayName),this.isShowMyDrive){var e=this.quotaInfoList[0],t=this.getQuotaInfoText(e),i=this.onQuotaInfoRender(),n=e.quota;this.quotaFieldSet.get("quota-used-info").update(t),0===n?this.quotaFieldSet.get("quota-progress-bar").doHide():this.quotaFieldSet.get("quota-progress-bar").update(i)}else this.quotaFieldSet.get("my-drive").doHide(),this.quotaFieldSet.get("quota-used-info").doHide(),this.quotaFieldSet.get("quota-progress-bar").doHide();this.icon_btn.menu.doLayout()}}),Ext.define("SYNO.SDS.Drive.Toolbar.TableLayout",{extend:"Ext.layout.TableLayout",columns:1,getNextCell:function(e){var t=Ext.layout.TableLayout.prototype.getNextCell.call(this,e);return t.align="center",t}}),Ext.define("SYNO.SDS.Drive.Upload.Application",{extend:"SYNO.SDS.Drive.AppInstance",appWindowName:"SYNO.SDS.Drive.Upload.MainWindow",constructor:function(e){this.callParent(arguments)}}),Ext.define("SYNO.SDS.Drive.Upload.MainWindow",{extend:"SYNO.SDS.Drive.PrototypeWindow",driveToolbarList:["node","shared_items","starred","recent","team_folder","label"],mainToolbarList:["from_upload","from_drive","from_nas","from_url","from_youtube_url"],allowDrop:!0,constructor:function(e){Ext.isWebKit?window.name||(window.name="SYNOSDSDriveUploadApplication"):window.name&&(window.name=""),this.driveFirstItemId=this.driveToolbarList[0],this.eventmgr=new SYNO.SDS.Drive.EventMgr({appWindow:this}),this.storemgr=new SYNO.SDS.Drive.Upload.StoreMgr({appWindow:this}),this.addManagedComponent(this.storemgr),this.viewmodemgr=new SYNO.SDS.Drive.ViewModeMgr({appWindow:this}),this.addManagedComponent(this.viewmodemgr),this.imagequeue=new SYNO.SDS.Drive.ImageLoaderQueue({appWindow:this}),this.addManagedComponent(this.imagequeue),this.callParent(arguments),this.mon(this.eventmgr,"envready",function(){if(!SYNO.SDS.Drive.Define.Info.is_home){this.driveToolbarList.shift();this.wintoolbar.get("node").setVisible(!1)}this.driveFirstItemId=this.driveToolbarList[0]},this),this.mon(this,"show",this.focus,this)},fillConfig:function(e){var t={layout:"card",height:this.getHeight(),width:this.getWidth(),maximizable:!1,autoDestroy:!0,cls:"syno-drive-win syno-d-upload-window",deferredRender:!0,activeItem:0,items:[this.getUploadPanel(),this.getDrivePanel(),this.getURLPanel(),this.getYouTubeURLPanel()],tbar:this.getWinToolbar(),buttons:[{itemId:"cancel",text:_T("common","cancel"),scope:this,handler:this.onCancel},{itemId:"ok",text:_T("common","ok"),btnStyle:"default",disabled:!0,scope:this,handler:this.onApply}],listeners:{scope:this,afterlayout:{single:!0,fn:this.onAfterLayout}}};return Ext.apply(t,e||{}),t},getHeight:function(){var e=.8*Ext.getBody().getViewSize().height;return e>680?e=680:e<440&&(e=440),e},getWidth:function(){var e=Math.floor(.75*Ext.getBody().getViewSize().width);return e>1120?e=1120:e<680&&(e=680),e},onAfterLayout:function(){this.maskEl&&this.maskEl.addClass("syno-d-upload-window-mask")},onOpen:function(e){this.callParent(arguments);var t=this.openParams=e||{};if(e)for(var i in e)if(e.hasOwnProperty(i))switch(e[i]){case"true":e[i]=!0;break;case"false":e[i]=!1}if(!1===t.from_upload&&this.wintoolbar.remove("from_upload"),SYNO.SDS.Drive.Utils.isAppAuthorized()&&!1!==t.from_drive||this.wintoolbar.remove("from_drive"),SYNO.SDS.Drive.Utils.isLogined()&&!1!==t.from_nas||this.wintoolbar.remove("from_nas"),!1===t.from_url&&this.wintoolbar.remove("from_url"),!0!==t.from_youtube_url&&this.wintoolbar.remove("from_youtube_url"),t.activeItem){var n=this.wintoolbar.get(t.activeItem);this.onChangeUploadCategory(n)}var o=t.fromPCParams;if(t.filter){if(t.filter.extensions){var s=t.filter.extensions,r="";r=s.reduce(function(e,t){switch(e&&(e+=","),t){case"bmp":return e+"image/bmp,image/x-windows-bmp";case"tif":return-1!==s.indexOf("tiff")?e.substring(0,e.length-1):e+"image/tiff";case"svg":return e+"image/svg+xml";default:return e+"image/"+t}},r),o=Ext.applyIf(o||{},{multiple:!0,accept:r}),t.fromNasParams=Ext.applyIf(t.fromNasParams||{},{pattern:s.join(",")})}t.fromDriveParams=Ext.applyIf(t.fromDriveParams||{},{filter:t.filter})}if(t.fromNasParams){var a=this.getStoreMgr().getStore("share_folder");a.setPattern(t.fromNasParams.pattern),t.fromNasParams.local_filter&&a.setLocalFilter(t.fromNasParams.local_filter)}if(t.fromDriveParams){var l=t.fromDriveParams.filter;Ext.iterate(this.getStoreMgr().stores,function(e,t){"share_folder"!==e&&"label"!==e&&t.setFilter(l)})}if(this.drivePanel.setEnableSelectDir(t.enableSelectDir),t.beforeSelection){var d=t.beforeSelection;Ext.isString(d)&&(d=new Function(d)),this.drivePanel.setBeforeSelection(d)}if(Ext.isBoolean(t.singleSelect)){var c=t.singleSelect;this.drivePanel.setSingleSelect(c),this.uploadPanel.setSingleSelect(c),o=Ext.apply(o||{},{multiple:!c})}o&&this.uploadPanel.setFileBtnAttributes(o),t.viewMode&&this.getViewModeMgr().setViewMode(t.viewMode),"small"===t.viewSize&&(this.addClass("syno-d-small-upload-window"),this.getDrivePanel().setViewSize(100)),(t.width||t.height)&&(this.setSize(t.width,t.height),this.center()),t.hidden&&this.setVisible(!1)},onApply:function(){if(!this.layout.activeItem.isValid())return void this.getMsgBox().alert("",this.layout.activeItem.getError()||_T("common","forminvalid"));Ext.isFunction(this.openParams.onApply)&&!1===this.openParams.onApply(this,this.getResult())||this[this.closeAction]()},onCancel:function(){this.layout.activeItem.isDirty()?this.getMsgBox().confirm("",SYNO.SDS.Drive._T("upload","cancel_confirm"),function(e){"yes"===e&&this[this.closeAction]()},this):this[this.closeAction]()},getResult:function(){return this.layout.activeItem.getResults()},getUploadPanel:function(){return this.uploadPanel?this.uploadPanel:(this.uploadPanel=new SYNO.SDS.Drive.Upload.UploadPanel({itemId:"from_upload",owner:this}),this.uploadPanel)},getURLPanel:function(){return this.urlPanel?this.urlPanel:(this.urlPanel=new SYNO.SDS.Drive.Upload.URLPanel({itemId:"from_url",owner:this}),this.urlPanel)},getYouTubeURLPanel:function(){return this.youtubeUrlPanel?this.youtubeUrlPanel:(this.youtubeUrlPanel=new SYNO.SDS.Drive.Upload.YouTubeURLPanel({itemId:"from_youtube_url",owner:this}),this.youtubeUrlPanel)},getDrivePanel:function(){return this.drivePanel||(this.drivePanel=new SYNO.SDS.Drive.Upload.DriveMainPanel({itemId:"from_drive",owner:this})),this.drivePanel},getDriveToolbarItemCfg:function(e){var t={itemId:e,text:SYNO.SDS.Drive._T("category",e),handler:this.onChangeDriveCategory,scope:this};return e===this.driveFirstItemId&&(t.cls="syno-d-upload-toolbar-first"),t},getMainToolbarItemCfg:function(e){var t={itemId:e,text:SYNO.SDS.Drive._T("upload",e),handler:this.onChangeUploadCategory,scope:this};return"from_upload"===e&&(t.cls="syno-d-upload-toolbar-first"),t},getWinToolbar:function(){if(this.wintoolbar)return this.wintoolbar;var e=[],t=SYNO.SDS.Drive._T;return Ext.each(this.mainToolbarList,function(t){e.push(this.getMainToolbarItemCfg(t))},this),e.push({itemId:"back",cls:"syno-d-upload-back-btn",hidden:!0,handler:this.onChangeUploadCategory,scope:this}),Ext.each(this.driveToolbarList,function(t){e.push(Ext.apply(this.getDriveToolbarItemCfg(t),{hidden:!0}))},this),e.push({itemId:"more",cls:"syno-d-upload-more-btn",text:t("category","more"),hidden:!0,menu:new SYNO.ux.Menu({ignoreParentClicks:!0,items:[]})}),e.push("->"),e.push({cls:"syno-d-upload-close-btn",handler:this.onCancel,scope:this}),this.wintoolbar=new SYNO.ux.Toolbar({height:40,cls:"syno-d-upload-toolbar",defaults:{xtype:"syno_button"},items:e}),this.wintoolbar.get("from_upload").addClass("syno-d-button-selected"),this.wintoolbar},onChangeUploadCategory:function(e,t,i){var n=e.itemId,o=this.layout.activeItem,s=this.getNavigation();if(!i&&"from_upload"===o.itemId&&o.isDirty())return void this.getMsgBox().confirm("",SYNO.SDS.Drive._T("upload","switch_confirm"),function(t){"yes"===t&&(o.cleanAll(),this.onChangeUploadCategory(e,null,!0))},this);switch(this.clearButtonSelected(),e.itemId){case"from_drive":this.setActiveCategory(this.driveFirstItemId);var r=this.driveFirstItemId;"shared_items"===r&&(r=this.getDrivePanel().getSharedItemBtn().getCheckedId()),s.setCategory(r),this.showHideMainToolbar(!1),this.showHideDriveToolbar(!0),this.wintoolbar.get(this.driveFirstItemId).addClass("syno-d-button-selected");break;case"back":this.showHideDriveToolbar(!1),this.showHideMainToolbar(!0);for(var a=0;a<this.mainToolbarList.length;++a){var l=this.mainToolbarList[a];if("from_drive"!==l){var d=this.wintoolbar.get(l);if(d){n=l,d.addClass("syno-d-button-selected");break}}}break;case"from_nas":n="from_drive",this.setActiveCategory("share_folder"),s.setCategory("share_folder"),e.addClass("syno-d-button-selected");break;default:e.addClass("syno-d-button-selected")}this.clearStatus(),this.setApplyBtnDisabled(!0),this.layout.setActiveItem(n)},onChangeDriveCategory:function(e){this.clearButtonSelected(),e.addClass("syno-d-button-selected"),this.setApplyBtnDisabled(!0);var t=e.itemId;"shared_items"===t&&(t=this.getDrivePanel().getSharedItemBtn().getCheckedId()),this.setActiveCategory(e.itemId),this.navigation.setCategory(t)},setActiveCategory:function(e){this.active_category=e},getActiveCategory:function(e){return this.active_category},onMoreItemClick:function(e){var t=this.wintoolbar.get("more");this.clearButtonSelected(),t.addClass("syno-d-button-selected"),t.setText(e.text),this.setActiveCategory(e.itemId),this.navigation.setCategory(e.itemId)},clearButtonSelected:function(){var e=this.wintoolbar.items.items;Ext.each(e,function(e){e.removeClass("syno-d-button-selected")})},showHideDriveToolbar:function(e){var t=0,i=this.wintoolbar.getWidth()-60;Ext.each(this.driveToolbarList,function(i){var n=this.wintoolbar.get(i);n.setVisible(e),t+=n.getWidth()},this);var n=this.wintoolbar.get("back");if(!1===this.openParams.from_upload&&!1===this.openParams.from_nas&&!1===this.openParams.from_url&&!0!==this.openParams.from_youtube_url?n.setVisible(!1):(n.setVisible(e),t+=n.getWidth()),t<=i)return void this.wintoolbar.get("more").hide();var o=this.wintoolbar.get("more");o.setVisible(!0),t+=o.getWidth();var s=this.driveToolbarList.length-1;for(o.menu.removeAll();t>i&&s>0;){var r=this.driveToolbarList[s--],a=this.wintoolbar.get(r),l=this.getDriveToolbarItemCfg(r);Ext.apply(l,{handler:this.onMoreItemClick}),o.menu.addItem(l),t-=a.getWidth(),a.hide()}o.show()},setApplyBtnDisabled:function(e){Ext.each(this.buttons,function(t){if("ok"===t.itemId)return t.setDisabled(e),!1})},getApplyBtnDisabled:function(){var e=!0;return Ext.each(this.buttons,function(t){if("ok"===t.itemId)return e=t.disabled,!1}),e},showHideMainToolbar:function(e){Ext.each(this.mainToolbarList,function(t){var i=this.wintoolbar.get(t);i&&i.setVisible(e)},this)},getPanel:function(){return this.getDrivePanel().getActivePanel()},getAction:function(){return this.actionmgr?this.actionmgr:(this.actionmgr=new SYNO.SDS.Drive.Upload.ActionMgr({appWindow:this}),this.actionmgr)},getNavigation:function(){return this.navigation?this.navigation:(this.navigation=new SYNO.SDS.Drive.Comp.Navigation({appWindow:this}),this.addManagedComponent(this.navigation),this.navigation)},GetOneSeleted:function(){return this.getPanel().getSelections()[0]},GetSeletions:function(){return this.getPanel().getSelections()},GetSeletionIds:function(){var e=this.getPanel().getSelections(),t=[];return Ext.each(e,function(e){t.push(e.id)}),t},getAllowDblClick:function(){return this.openParams&&this.openParams.allowDblClick},destroy:function(){this.callParent(arguments),this.navigation=null,this.actionmgr=null,this.eventmgr=null},toFront:function(){this.manager.bringToFront(this)}}),Ext.define("SYNO.SDS.Drive.Upload.IFrameApplication",{extend:"SYNO.SDS.Drive.Upload.Application",appWindowName:"SYNO.SDS.Drive.Upload.IFrameMainWindow",constructor:function(e){this.callParent(arguments)}}),Ext.define("SYNO.SDS.Drive.Upload.IFrameMainWindow",{extend:"SYNO.SDS.Drive.Upload.MainWindow",constructor:function(e){this.origin=window.location.protocol+"//"+window.location.host,this.callParent(arguments),Ext.getBody().addClass(["syno-d-theme","syno-drive-theme"])},getHeight:function(){return Ext.getBody().getViewSize().height},getWidth:function(){return Ext.getBody().getViewSize().width},onAfterLayout:function(){window.parent.postMessage({action:"afterlayout"},this.origin)},onApply:function(){if(!this.layout.activeItem.isValid())return void this.getMsgBox().alert("",this.layout.activeItem.getError()||_T("common","forminvalid"));var e=this.getResult();window.parent.postMessage({action:"apply",result:e},this.origin)},close:function(){window.parent.postMessage({action:"close"},this.origin)}}),Ext.define("SYNO.SDS.Drive.MemberDialog",{extend:"SYNO.SDS.Drive.ModalWindow",mixins:["SYNO.SDS.Drive.Comp.PagingToolBar"],constructor:function(e){this.rec=e.rec;var t={title:SYNO.SDS.Drive._T("common","members"),width:500,height:462,resizable:!1,items:[this.getGridPanel()],buttons:[{xtype:"syno_button",text:SYNO.SDS.Drive._T("common","close"),btnStyle:"grey",handler:this.onCloseClick,scope:this}]};Ext.apply(t,e||{}),this.callParent([t])},getGridPanel:function(){if(this.grid)return this.grid;var e={autoHeight:!1,height:342,cls:"syno-d-share-formpanel",enableHdMenu:!1,view:this.createGridView(),store:this.getGridStore(),cm:this.createGridCM(),bbar:this.getPagingToolBar(this.getGridStore()),listeners:{viewready:function(e){this.view.updateScroller()}}};return this.grid=new SYNO.ux.GridPanel(e),this.grid},createGridView:function(){var e={rowHeight:29,forceFit:!0,disableTextSelect:!0,deferEmptyText:!1};return new SYNO.ux.FleXcroll.grid.BufferView(e)},getGridStore:function(){return this.gridStore?this.gridStore:(this.pageSize=100,this.gridStore=new SYNO.API.Store({autoDestroy:!0,autoLoad:!0,pageSize:this.pageSize,proxy:new SYNO.API.Proxy(SYNO.SDS.Drive.WebAPIDesc.list_team_folders_members),baseParams:{team_id:this.rec.get("team_id"),offset:0,limit:this.pageSize},reader:new Ext.data.JsonReader({root:"items",fields:[{name:"display_name"},{name:"name"},{name:"uid"},{name:"role"}]}),listeners:{scope:this,beforeload:this.onBeforeLoad,load:this.onLoad,loadexception:this.onLoadException}}),this.gridStore)},createGridCM:function(){return new Ext.grid.ColumnModel({defaults:{menuDisabled:!0,sortable:!1,scope:this},columns:[{dataIndex:"display_name",width:240,header:_T("common","user"),renderer:function(e,t,i,n,o,s){return'<span class="syno-d-share-user"></span>'+this.defaultRender(e)}},{dataIndex:"role",width:100,header:_T("share","permission"),renderer:this.permRender.createDelegate(this)}]})},defaultRender:function(e,t,i,n,o,s){var r=Ext.util.Format.htmlEncode(e),a=Ext.util.Format.htmlEncode(r);return String.format('<span ext:qtip="{0}">{1}</span>',a,r)},permRender:function(e,t,i,n,o,s){var r;switch(e){case"viewer":r="ro";break;case"editor":r="rw";break;default:r=e}return e=SYNO.SDS.Drive._T("perm",r),this.defaultRender(e)},onBeforeLoad:function(){this.setStatusBusy()},onLoad:function(){this.clearStatusBusy()},onLoadException:function(e,t,i){this.clearStatusBusy(),SYNO.SDS.Drive.Utils.showErrorMsg(this,i,function(){this.close()},this)},onCloseClick:function(){this.close()}},SYNO.SDS.Drive.Framework.postDefine),Ext.define("SYNO.SDS.Drive.Comp.C2TransferButton",{extend:"SYNO.SDS.Drive.SimpleButton",itemId:"c2transfer",constructor:function(e){this.c2TransferHandler=new SYNO.SDS.Drive.ActionHandler.C2Transfer(e);var t={id:"syno-d-c2-transfer-btn",cls:"syno-d-c2-transfer-btn",scope:this,tooltip:SYNO.SDS.Drive._T("info","c2transfer_btn"),menuAlign:"bl-br",listeners:{scope:this,afterrender:this.onAfterRender},handler:this.onClickItem};Ext.apply(t,e||{}),this.appWindow=e.appWindow,this.callParent([t]),this.hoverTimeout=null},onAfterRender:function(){this.setVisible(!1)},onClickItem:function(e,t){var i=this;this.c2TransferHandler.openC2webWindow("/drive/task-management","?c2_kwdmga_uhid="+(i.appWindow.send_copy_enc_syno_uid||"")).then(function(e){i.event=e,i.appWindow.sendWebAPI({webapi:e.data,callback:function(e,t,n){if(!e||!t||!i.event)return void SYNO.Debug("Cannot get response from C2 package",n);i.event.ports.forEach(function(e){e.postMessage(t)})}})}).catch(function(e){SYNO.Debug("Error opening C2 web for /drive/task-management",e)})},setVisible:function(e){e?this.el.dom.classList.add("visible"):this.el.dom.classList.remove("visible")},getMenu:Ext.emptyFn}),Ext.define("SYNO.SDS.Drive.Comp.HotkeyHandler",{createHotkeyMap:function(){if(!this.keyMap){this.fillKeyConfig();var e=this.findAppWindow().getAction(),t=this;this.keyMap=new Ext.KeyMap(this.el,[{key:Ext.EventObject.C,alt:!1,ctrl:!0,shift:!1,scope:e,fn:function(){t.hasPermission("copy")&&!0===t.config.copy&&(e.onCopyAction(),t.config.paste=!0)}},{key:Ext.EventObject.X,alt:!1,ctrl:!0,shift:!1,scope:e,fn:function(){t.hasPermission("cut")&&!0===t.config.cut&&(e.onCutAction(),t.config.paste=!0)}},{key:Ext.EventObject.V,alt:!1,ctrl:!0,shift:!1,scope:e,fn:function(){t.hasPermission("paste")&&!0===t.config.paste&&e.onPasteAction(Ext.EventObject.V)}},{key:Ext.EventObject.A,alt:!1,ctrl:!0,shift:!1,scope:t,fn:function(){!0===t.config.select_all&&t.selectAll()}},{alt:!1,ctrl:!1,shift:!1,key:Ext.EventObject.ESC,scope:t,fn:function(){!0===t.config.unselect&&t.unSelect()}},{alt:!1,ctrl:!1,shift:!1,key:Ext.EventObject.DELETE,scope:e,fn:function(){t.hasPermission("remove")&&!0===t.config.remove&&e.deleteNode()}},{alt:!1,ctrl:!1,shift:!1,key:Ext.EventObject.F2,scope:e,fn:function(){t.hasPermission("rename")&&!0===t.config.rename&&e.renameNode()}}]),this.findAppWindow().addManagedComponent(this.keyMap)}},fillKeyConfig:function(){this.config={copy:!0,cut:!0,paste:!0,select_all:!0,unselect:!0,remove:!0,rename:!0}},getConfig:function(){return this.config},hasPermission:function(e){var t;t="paste"===e?[]:this.findAppWindow().getAction().getTargets();var i=this.findAppWindow().getAction().ActionPrivChecker.check(e,t,"hotkey");return i.display&&i.enable}}),Ext.define("SYNO.SDS.Drive.MigrateIndexHomeIntro.Window",{extend:"SYNO.SDS.Drive.ModalWindow",constructor:function(e){var t={width:680,height:509,cls:"syno-d-prompt-window syno-d-office-intro-window",layout:"fit",header:!1,elements:"body",useStatusBar:!1,resizable:!1,closable:!1,draggable:!1,padding:void 0,items:this.getContent()};Ext.apply(t,e||{}),this.callParent([t])},getContent:function(){var e=SYNO.SDS.Drive._T;return{xtype:"container",layout:"vbox",layoutConfig:{align:"center"},items:[{xtype:"spacer",height:20},{xtype:"container",cls:_S("is_admin")?"syno-d-index-home-admin-image":"syno-d-index-home-normal-user-image"},{xtype:"spacer",height:20},{xtype:"syno_displayfield",cls:"syno-d-prompt-window-title",value:_S("is_admin")?e("migrate_index_home","web_intro_title_admin"):e("migrate_index_home","web_intro_title_normal_user")},{xtype:"spacer",height:12},{xtype:"syno_displayfield",cls:"syno-d-prompt-window-desc",html:_S("is_admin")?e("migrate_index_home","web_intro_desc_admin"):e("migrate_index_home","web_intro_desc_normal_user")},{xtype:"spacer",flex:1},{xtype:"syno_button",width:200,cls:"syno-d-prompt-window-btn",text:e("common","got_it"),scope:this,handler:this.onWinClose},{xtype:"spacer",height:36}]}},afterShow:function(){this.callParent(arguments);var e=this.owner.el.query(".sds-window-mask")[0];Ext.fly(e).addClass("syno-d-prompt-window-mask")},onWinClose:function(){var e=this.owner.el.query(".sds-window-mask")[0];Ext.fly(e).removeClass("syno-d-prompt-window-mask"),_S("is_admin")?this.owner.appInstance.setUserSettings("welcome_window_index_home_ds_id",SYNO.SDS.Drive.Define.Info.ds_id):this.owner.appInstance.setUserSettings("hide_migrate_index_home_intro_prompt",!0),this.close()}}),Ext.define("SYNO.SDS.Drive.OfficeIntro.Window",{extend:"SYNO.SDS.Drive.ModalWindow",constructor:function(e){var t={width:680,height:509,cls:"syno-d-prompt-window syno-d-office-intro-window",layout:"fit",header:!1,elements:"body",useStatusBar:!1,resizable:!1,closable:!1,draggable:!1,padding:void 0,items:this.getContent()};Ext.apply(t,e||{}),this.callParent([t])},getContent:function(){var e=SYNO.SDS.Drive._T;return{xtype:"container",layout:"vbox",layoutConfig:{align:"center"},items:[{xtype:"spacer",height:20},{xtype:"container",cls:"syno-d-office-intro-image"},{xtype:"spacer",height:20},{xtype:"syno_displayfield",cls:"syno-d-prompt-window-title",value:e("cstn","welcome_title_office")},{xtype:"spacer",height:12},{xtype:"syno_displayfield",cls:"syno-d-prompt-window-desc",html:String.format(e("common","prompt_intro_office_desc"),e("cstn","package_center"))},{xtype:"spacer",flex:1},{xtype:"syno_button",width:200,cls:"syno-d-prompt-window-btn",text:e("common","got_it"),scope:this,handler:this.onWinClose},{xtype:"spacer",height:36}]}},afterShow:function(){this.callParent(arguments);var e=this.owner.el.query(".sds-window-mask")[0];Ext.fly(e).addClass("syno-d-prompt-window-mask")},onWinClose:function(){var e=this.owner.el.query(".sds-window-mask")[0];Ext.fly(e).removeClass("syno-d-prompt-window-mask"),this.owner.appInstance.setUserSettings("hide_office_intro_prompt",!0),this.close()}}),Ext.define("SYNO.SDS.Drive.DateField",{extend:"SYNO.ux.DateField",constructor:function(){this.callParent(arguments)},onTriggerClick:function(){if(Ext.isEmpty(this.menu)&&(this.menu=new SYNO.ux.DateMenu({hideOnClick:!1,focusOnSelect:!1,allowOtherMenus:!0})),this.menu.isVisible())return void this.menuEvents("hide");SYNO.SDS.Drive.DateField.superclass.onTriggerClick.apply(this,arguments)}}),Ext.define("SYNO.SDS.Drive.MenuUtils",{statics:{onShowHideMenu:function(e){var t,i,n=!1,o=null,s=0;for(e instanceof Ext.util.MixedCollection&&(e=e.items),Ext.each(e,function(e){e instanceof Ext.menu.Separator&&e.show()}),t=0,i=e.length;t>=0&&t<i;t++){var r=e.get?e.get(t):e[t];r instanceof Ext.menu.Separator&&!r.hidden?(n||0===t||0===s?r.hide():o=r,n=!0):r.hidden||(s++,n=!1,o=null)}o&&o.hide()}}});

Youez - 2016 - github.com/yon3zu
LinuXploit