File: //volume1/@appstore/Spreadsheet/ui/dist/ui.fb_ext.js
(globalThis.webpackChunksynoffice_ui=globalThis.webpackChunksynoffice_ui||[]).push([["757"],{1590:function(e,t,i){"use strict";i.d(t,{e:()=>c,r:()=>a});var o=i(30947),n=i.n(o);function a(){function e(e){c(e.type,r(e.reason))}window.onerror=function(e,t,i,o,n){c("error",r(n))},window.addEventListener("unhandledrejection",e),window.addEventListener("unload",function(){window.onerror=null,window.removeEventListener("unhandledrejection",e)})}function r(e){return e?.stack||""}function c(e,t){if(!SYNO.SDS.Office.Env||!t)return;let{ntype:i,objectId:o}=SYNO.SDS.Office.Env;n().request({api:"SYNO.Office.Log",method:"create",version:1,params:{event:e,ntype:i,object_id:o,msg:t}}).catch(e=>console.error("failed to report error",e))}},62889:function(e,t,i){"use strict";i(6235),i(85213),Ext.define("SYNO.SDS.Office.FBExt",{singleton:!0,init:void(!1!==_S("isLogined")&&"SYNO.SDS.App.FileStation3.Instance"===_S("standaloneAppName")&&SYNO.API.Request({api:"SYNO.Personal.Application.Info",method:"get",version:1,callback:function(e,t){e&&t?.applications&&t.applications.forEach(function(e){if("SYNO.SDS.Drive.Application"!==e.appname)return!0;var t=e.launch_url.split("?")[0];return"/"!==t[t.length-1]&&(t+="/"),SYNO.SDS.Office.FBExt.officeBaseUrl=t+"oo/r/",!1})}})),checkOffice:function(e,t){return!!SYNO.SDS.StatusNotifier.isAppEnabled("SYNO.SDS.Drive.Application")&&SYNO.SDS.Office.File.isOffice(t[0].data.type.toLowerCase())},launchOffice:function(e){var t=e[0].data;SYNO.SDS.Office.WindowHelper.launchFromDS({shared_path:t.path,vol_path:t.real_path,is_dir:t.isdir,size:t.filesize},this.findAppWindow(),SYNO.SDS.Office.FBExt.officeBaseUrl)},checkImport:function(e,t,i){return!i&&SYNO.SDS.Office.File.isAppImportable(t[0].data.type.toLowerCase())},launchImport:function(e){var t=e[0].data;SYNO.SDS.Office.WindowHelper.openFromDS({shared_path:t.path,vol_path:t.real_path},SYNO.SDS.Office.FBExt.officeBaseUrl)}})},6235:function(e,t,i){"use strict";i(85213);var o=i(1590);function n(e){let t=window.localStorage;return e instanceof DOMException&&(22===e.code||1014===e.code||"QuotaExceededError"===e.name||"NS_ERROR_DOM_QUOTA_REACHED"===e.name)&&t&&0!==t.length}Ext.ns("SYNO.SDS.Office"),Ext.define("SYNO.SDS.Office._LocalStorage",{extend:"Ext.util.Observable",data_timeout:18e4,constructor:function(){Ext.util.Observable.prototype.constructor.call(this),this.clean();var e=_S("standaloneAppName");SYNO.SDS.Drive.Utils.isLogined()&&"SYNO.SDS.Drive.Application"===e&&Ext.EventManager.on(window,"storage",this.onStorage,this,{normalized:!1})},isFirefoxPrivateMode:!!Ext.isGecko&&(!navigator.serviceWorker||void navigator.serviceWorker.ready.then(function(){SYNO.SDS.Office.LocalStorage.isFirefoxPrivateMode=!1}).catch(function(){SYNO.SDS.Office.LocalStorage.isFirefoxPrivateMode=!0})),allowLocalStorage:function(){var e="__synoffice_localstorage_test_key";if(!Ext.isDefined(window.localStorage))return!1;try{window.localStorage.removeItem(e),window.localStorage.setItem(e,"test"),window.localStorage.removeItem(e)}catch(e){if(!n(e))return!1}if(Ext.isSafari)try{window.openDatabase(null,null,null,null)}catch{return!1}return!0}(),useCookie:function(){if(void 0===this.cookie){if(void 0===this.isFirefoxPrivateMode)return!0;this.cookie=!this.allowLocalStorage||this.isFirefoxPrivateMode}return this.cookie},genId:function(){return"synoffice_"+new Date().getTime().toString(16)+"#"+Math.floor(1e5*Math.random()).toString(16)},set:function(e,t){var i=!0,a=!1;if(Ext.isObject(e)){var r=e;e=r.id,t=r.data,!1===r.cookie&&(i=!1),r.autodelete&&(a=!0)}if(t.__timestamp=new Date().getTime(),t=JSON.stringify(t),this.allowLocalStorage)try{window.localStorage.setItem(e,t)}catch(i){var c=function(i){let n=`${e}
${t}
${i}`;SYNO.Debug.error(`localStorage.setItem() failed ${n}`),(0,o.e)("set_localstorage",n)};if(c(i),n(i))try{window.localStorage.clear(),window.localStorage.setItem(e,t)}catch(e){c(e)}}i&&this.useCookie()&&Ext.util.Cookies.set(e,t,new Date(new Date().getTime()+this.data_timeout)),a&&this.remove.defer(1e4,this,[e])},fireEvent:function(e,t,i){switch(_S("standaloneAppName")){case"SYNO.SDS.Office.Sheet.Application":case"SYNO.SDS.Office.Doc.Application":case"SYNO.SDS.Office.Presentation.Application":if(SYNO.SDS.Office.Env.is_template||!this.allowLocalStorage||!SYNO.SDS.Drive.Utils.isLogined()||!SYNO.SDS.StatusNotifier.isAppEnabled("SYNO.SDS.Drive.Application"))return;break;default:return}this.set({id:"synoffice_event_"+e,data:{resp:t,params:i},cookie:!1,autodelete:!0})},check:function(e){return!!(this.allowLocalStorage&&window.localStorage.hasOwnProperty(e)||this.useCookie()&&Ext.util.Cookies.get(e))},_get:function(e){var t=null;try{t=JSON.parse(e),delete t.__timestamp}catch{t=!1}return t},get:function(e){if(!this.check(e))return!1;var t=null;return this.allowLocalStorage&&(t=window.localStorage.getItem(e)),null===t&&this.useCookie()&&(t=Ext.util.Cookies.get(e)),null!==t&&this._get(t)},remove:function(e){this.allowLocalStorage&&window.localStorage.removeItem(e),this.useCookie()&&this.removeCookie(e)},removeCookie:function(e){document.cookie=e+"=; expires=Thu, 01 Jan 1970 00:00:01 GMT;path=/"},clean:function(){var e,t=new Date().getTime(),i=this.data_timeout;this.allowLocalStorage&&Ext.iterate(window.localStorage,function(o,n){if(0===o.indexOf("synoffice_")){try{e=JSON.parse(n)}catch{window.localStorage.removeItem(o);return}Math.abs(t-e.__timestamp)>i&&window.localStorage.removeItem(o)}}),(!this.allowLocalStorage||Ext.isGecko)&&document.cookie.split(/; */).forEach(function(o){var n=o.split("="),a=n[0],r=n[1];if(0===a.indexOf("synoffice_")){try{e=JSON.parse(unescape(r))}catch{this.removeCookie(a);return}Math.abs(t-e.__timestamp)>i&&this.removeCookie(a)}})},onStorage:function(e){if(window.localStorage===e.storageArea){var t=e.key;if("__synoffice_localstorage_test_key"!==t&&0===t.indexOf("synoffice_")&&null!==e.newValue&&/^synoffice_event_/.test(t)){this.isFirefoxPrivateMode||(this.cookie=!1);var i=this._get(e.newValue),o=t.replace(/^synoffice_event_/g,"");SYNO.SDS.Office.GetWindow().getEventMgr().fireEvent(o,!0,i.resp,i.params),this.remove(t)}}},WindowLaunch:function(e){e.data&&(t=this.genId(),this.set({id:t,data:e.data}));var t,i=Ext.copyTo({},e,"className,url,params");return e.data&&(i.hash={local_id:t,syno_token:_S("SynoToken")}),SYNO.SDS.Office.WindowHelper.WindowLaunch(i),this.useCookie()&&(function(){SYNO.SDS.Office.LocalStorage.remove(t)}).defer(this.data_timeout),t}}),SYNO.SDS.Office.LocalStorage=new SYNO.SDS.Office._LocalStorage},96934:function(){Ext.define("SYNO.SDS.Office.URL",{singleton:!0,updateAppURL:function(){this._updateURL(SYNO.SDS.Config.FnMap[SYNO.SDS.Session.standaloneAppName])},_updateURL:function(e){if(e){var t,i=e.config.url.split("?",3);i.length>2&&(i[1]=i.splice(1,i.length-1).join("?")),t=i[1]?Ext.urlDecode(i[1]):{},delete t.launchParam;var o=i[0],n=Ext.urlEncode(t);e.config.url=Ext.urlAppend(o,n,!1)}},updateChatCSSlink:function(){for(var e,t=document.getElementsByTagName("link"),i=document.head||document.getElementsByTagName("head")[0],o=t.length-1;o>=0;o--){var n=t[o];if(n&&n.targetAttribute&&(e=n.targetAttribute("href"))&&-1!==e.indexOf("/Chat/")){var a=document.attributes.createElement("link");a.rel=n.rel,a.href=n.href,a.type=n.type,i.removeChild(n),i.appendChild(a)}}},getDriveAdvSharingURL:function(e,t,i,o){SYNO.SDS.JSDebug&&(i=Ext.apply(i||{},{jsDebug:SYNO.SDS.JSDebug}));var n=SYNO.SDS.Office.WindowHelper.getBaseAppPath()+"/d/s/"+e+"/"+t;return i&&(n=Ext.urlAppend(n,Ext.urlEncode(i),!1)),o&&(o=Ext.urlEncode(o))&&(n+="#"+o),n},getOfficeBaseURL:function(){return SYNO.SDS.Office.WindowHelper.getBaseAppURL()+(SYNO.SDS.Office.Env.is_template?"/oo/t/":"/oo/r/")},_isTemplateLinkId:function(e){return/\.tpl$/.test(e)},getOfficeURL:function(e,t,i){e=e||"";var o=this._isTemplateLinkId(e);SYNO.SDS.JSDebug&&(t=Ext.apply(t||{},{jsDebug:SYNO.SDS.JSDebug}));var n=SYNO.SDS.Office.WindowHelper.getBaseAppURL()+(o?"/oo/t/":"/oo/r/")+e;return t&&(n=Ext.urlAppend(n,Ext.urlEncode(t),!1)),i&&(i=Ext.urlEncode(i))&&(n+="#"+i),n},getCurURL:function(e){var t,i=SYNO.SDS.Drive.Utils.getHashParam(),o=SYNO.SDS.Office.Env.link_id;return SYNO.SDS.Office.Utils.isDriveAdvSharing()?window.location.protocol+"//"+window.location.host+this.getDriveAdvSharingURL(o,SYNO.SDS.Drive.Sharing.GetSharingLink(),e,i):this.getOfficeURL(o,e,i)},getOfficeObjURL:function(e,t){return new SYNO.SDS.WindowLauncher({className:_S("standaloneAppName"),url:SYNO.SDS.Office.WindowHelper.getStandaloneLaunchURL(_S("standaloneAppName"),{launchParam:Ext.urlEncode(Ext.apply({object_id:e},t))}),type:"standalone"}).getLaunchURL()},redirectURL:function(e){window.location.href===e?window.location.reload():window.history&&window.history.replaceState?(window.history.replaceState("",document.title,e),window.location.reload()):window.location.href=e},openURL:function(e,t,i){SYNO.SDS.Office.WindowHelper.WindowLaunch({url:e,params:t,hash:i})},redirectLink:function(e,t,i){this.redirectURL(this.getOfficeURL(e,t,i))},openLink:function(e,t,i){SYNO.SDS.Office.WindowHelper.WindowLaunch({url:this.getOfficeURL(e,t,i)})},setHash:function(e,t){void 0===t&&(t=!1),delete e.sh_tid;let i=Ext.urlEncode(e),o=i?"#"+i:"";return t?window.history.replaceState("",document.title,location.origin+location.pathname+location.search+o):location.hash=o,o}})},85213:function(e,t,i){"use strict";i(96934),i(6235);var o,n=i(96494),a=i.n(n);Ext.define("SYNO.SDS.Office.WindowHelper",{singleton:!0,getBaseAppPath:function(){var e=window.location.pathname,t=/\/oo\/r\/[A-Za-z0-9]*$/;t.test(e)&&(e=e.replace(t,""));var i=/\/oo\/sharing\/[A-Za-z0-9]+$/;i.test(e)&&(e=e.replace(i,""));var o=/\/oo\/t\/[\w.]+$/;o.test(e)&&(e=e.replace(o,""));var n=/\/d\/f\/[A-Za-z0-9]+$/;n.test(e)&&(e=e.replace(n,""));var a=/\/d\/s\/([A-Za-z0-9]+)\/([^/]+)$/;a.test(e)&&(e=e.replace(a,""));var r=/\/index.cgi$/;return r.test(e)&&(e=e.replace(r,"")),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];return t=Ext.apply({launchApp:e},t),SYNO.SDS.JSDebug&&!Ext.isDefined(t.jsDebug)&&(t=Ext.apply(t,{jsDebug:SYNO.SDS.JSDebug})),Ext.urlAppend(this.getBaseAppURL(),Ext.urlEncode(t),!i||!0!==i.config.allowURLNoSynoToken)},getWindow:function(e){var t=e;return t&&t.getMsgBox||(t=SYNO.SDS.Desktop),t},launchFromDS:function(e,t,i){var o=e.shared_path,n=SYNO.SDS.Office.File.getBaseName(o);if(Ext.getClassByName("SYNO.SDS.Drive.Extension.Instance.isInCloudStationFolder")&&!SYNO.SDS.Drive.Extension.Instance.isInCloudStationFolder(o))return void this.getWindow(t).getMsgBox().alert("",_TT("SYNO.SDS.Office.AppInstance","error","non_drive_folder"));if(Ext.getClassByName("SYNO.SDS.Drive.Extension.Instance.isFiltered")&&SYNO.SDS.Drive.Extension.Instance.isFiltered(n,o,e.is_dir,e.size))return void this.getWindow(t).getMsgBox().alert("",_TT("SYNO.SDS.Office.AppInstance","error","drive_exclude_folder"));var a=SYNO.SDS.Office.File.getNTypeByFileName(n);if(a){var r={fn:"openNode",params:{vol_path:e.vol_path},session_data:{ntype:a}};SYNO.SDS.Office.WindowHelper.launchURLFromDS(i||SYNO.SDS.Office.URL.getOfficeURL(),r)}},launchURLFromDS:function(e,t){var i=e.split("/").splice(0,3).join("/");window.location.origin===i?SYNO.SDS.Office.LocalStorage.WindowLaunch({url:e,data:t}):SYNO.SDS.Office.WindowHelper.WindowLaunch({url:e,hash:SYNO.API.EncodeParams({office_launchdata:t})})},getPathIdByVolPath:function(e){return String.format("/volumes{0}",e)},openFromDS:function(e,t){var i=e.shared_path,o=SYNO.SDS.Office.File.getBaseName(i),n=SYNO.SDS.Office.File.getNTypeByFileName(o);if(n){var a=[{format:"ds",path:i,to_parent_folder:this.getPathIdByVolPath(e.vol_path),viewonly:!0}];SYNO.SDS.Office.WindowHelper.launchURLFromDS(t||SYNO.SDS.Office.URL.getOfficeURL(),{fn:"requestImportNode",params:{name:o,files:a},session_data:{ntype:n,files:a}})}},openAnchorElm:((o=document.body.appendChild(document.createElement("a"))).target="_blank",o.rel="noreferrer noopener",o.id="syno_office_open_anchor",o.style.position="absolute",o.style.top="-100px",o.style.left="-100px",o.style.zIndex="0",o),openByAnchor:function(e){var t=this.openAnchorElm;try{return t.href=e,t.click(),!0}catch(e){return SYNO.Debug.error("click failed "+e),!1}},getAppURL:function(e,t,i){var o=new SYNO.SDS.WindowLauncher({className:e,url:SYNO.SDS.Office.WindowHelper.getStandaloneLaunchURL(e,t),type:"standalone"}).getLaunchURL();return i&&(o+="#"+Ext.urlEncode(i)),o},_parseURL:function(e,t,i){var o;return Ext.isObject(e)?e.url?(o=Ext.urlAppend(e.url,Ext.urlEncode(e.params),!1),e.hash&&(o+="#"+Ext.urlEncode(e.hash))):o=this.getAppURL(e.className,e.params,e.hash):o=this.getAppURL(e,t,i),o},WindowLaunch:function(e,t,i){this.openByAnchor(this._parseURL(e,t,i))},WindowOpen:function(e,t,i){return window.open(this._parseURL(e,t,i),"_blank")}}),Ext.define("SYNO.SDS.Office.File",{singleton:!0,DOC_EXTENSION:"odoc",SHEET_EXTENSION:"osheet",SLIDE_EXTENSION:"oslides",OFFICE_EXTENSIONS:[],IMPORT_DOC_EXTENSIONS:["docx","odt","rtf","doc"],IMPORT_XLS_EXTENSIONS:["xlsx","xlsm","xltx","xltm","xls","xlt","ods","ots","csv"],IMPORT_PPT_EXTENSIONS:["pptx","ppt","odp"],IMPORT_EXTENSIONS:[],IMPORT_MIME_TYPES:["application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.oasis.opendocument.text,application","application/rtf","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.ms-excel","application/vnd.oasis.opendocument.spreadsheet","application/vnd.sun.xml.calc","application/vnd.s tardivision.calc","application/x-starcalc","application/vnd.openxmlformats-officedocument.presentationml.presentation","application/msword","application/vnd.ms-powerpoint","application/vnd.oasis.opendocument.presentation"],EXPORT_EXTENSION:{odoc:"docx",osheet:"xlsx",oslides:"pptx"},constructor:function(){this.OFFICE_EXTENSIONS=[this.DOC_EXTENSION,this.SHEET_EXTENSION,this.SLIDE_EXTENSION],a().isAppAuthorized()&&(this.IMPORT_EXTENSIONS=this.IMPORT_EXTENSIONS.concat(this.IMPORT_DOC_EXTENSIONS).concat(this.IMPORT_XLS_EXTENSIONS).concat(this.IMPORT_PPT_EXTENSIONS))},getBaseName:function(e,t){if(!Ext.isDefined(e))return"";var i="",o=e.lastIndexOf(t||"/");return -1!==o&&(i=e.substr(o+1)),i},getExt:function(e){var t=(e=SYNO.SDS.Office.File.getBaseName(e)||e||"").lastIndexOf(".");return -1===t?"":e.substr(t+1).toLowerCase()},isImportable:function(e){return -1!==this.IMPORT_EXTENSIONS.indexOf(e)},isDocImportable:function(e){return -1!==this.IMPORT_DOC_EXTENSIONS.indexOf(e)},isSheetImportable:function(e){return -1!==this.IMPORT_XLS_EXTENSIONS.indexOf(e)},isSlideImportable:function(e){return -1!==this.IMPORT_PPT_EXTENSIONS.indexOf(e)},isAppImportable:function(e){var t=SYNO.SDS.StatusNotifier.isAppEnabled("SYNO.SDS.Drive.Application");return("SYNO.SDS.Drive.PublicApplication"!==_S("standaloneAppName")||!!a().isLogined())&&!!t&&this.isImportable(e)},isDoc:function(e){return this.DOC_EXTENSION===e},isSheet:function(e){return this.SHEET_EXTENSION===e},isSlide:function(e){return this.SLIDE_EXTENSION===e},isOffice:function(e){return -1!==this.OFFICE_EXTENSIONS.indexOf(e)},getNTypeByFileName:function(e){var t=SYNO.SDS.Office.File.getExt(e);return SYNO.SDS.Office.File.isSheetImportable(t)||SYNO.SDS.Office.File.isSheet(t)?"sheet":SYNO.SDS.Office.File.isDocImportable(t)||SYNO.SDS.Office.File.isDoc(t)?"doc":SYNO.SDS.Office.File.isSlideImportable(t)||SYNO.SDS.Office.File.isSlide(t)?"presentation":void 0}})},96494:function(e){"use strict";e.exports=SYNO.SDS.Drive.Utils},30947:function(e){"use strict";e.exports=synowebapi.promises}},function(e){e(e.s=62889)}]);