@emailmaker/emailmaker 1.0.111-alpha.1 → 1.0.111-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/asset-manifest.json +12 -12
- package/emailmaker-esm.js +1 -1
- package/emailmaker.js +1 -1
- package/iframe/429.js +1 -1
- package/iframe/766.js +1 -1
- package/iframe/iframe-eblock.dfbe43189ad0132f9332.html +1 -1
- package/iframe/iframe.dfbe43189ad0132f9332.html +1 -1
- package/iframe/js/174.99f4690d.js +1 -0
- package/iframe/js/525.91b8bafc.js +1 -0
- package/iframe/js/882.9de4b6f6.js +1 -0
- package/iframe/sandbox-eblock.js +1 -1
- package/package.json +1 -1
- package/static/js/3628.c9222f5e.js +3 -0
- package/static/js/5279.3b38adf9.js +2 -0
- package/static/js/{6310.4ce0a904.js → 6310.27dbb05e.js} +2 -2
- package/static/js/{emailmaker_core.a65d17bc.js → emailmaker_core.c7721058.js} +3 -3
- package/iframe/js/174.71dd26a1.js +0 -1
- package/iframe/js/525.79df1f3f.js +0 -1
- package/iframe/js/882.4be4f077.js +0 -1
- package/static/js/3628.ec1646ec.js +0 -3
- package/static/js/5279.434cda73.js +0 -2
- /package/iframe/js/{174.71dd26a1.js.LICENSE.txt → 174.99f4690d.js.LICENSE.txt} +0 -0
- /package/iframe/js/{525.79df1f3f.js.LICENSE.txt → 525.91b8bafc.js.LICENSE.txt} +0 -0
- /package/iframe/js/{882.4be4f077.js.LICENSE.txt → 882.9de4b6f6.js.LICENSE.txt} +0 -0
- /package/static/js/{3628.ec1646ec.js.LICENSE.txt → 3628.c9222f5e.js.LICENSE.txt} +0 -0
- /package/static/js/{emailmaker_core.a65d17bc.js.LICENSE.txt → emailmaker_core.c7721058.js.LICENSE.txt} +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";(globalThis.webpackChunkemail_maker=globalThis.webpackChunkemail_maker||[]).push([[6310],{21816:(e,t,i)=>{i.r(t),i.d(t,{default:()=>ae});var r=i(1936),o=i(71715),a=i(84075),s=i(18021),n=i(51114),l=i(6691),d=i(86331),h=i(60034),c=i(98173),u=i(78443),v=i(22817),f=i(81644),p=i(942),m=i(6403),w=i(65185);let g;var y;(y=g||(g={})).isEqual=function(e,t,i=(e,t)=>e===t){if(e===t)return!0;const r=e.length;if(r!==t.length)return!1;for(let o=0;o<r;o++)if(!i(e[o],t[o]))return!1;return!0},y.unique=function(e,t){t||(t=e=>e);const i=new Set;return e.filter(e=>{const r=t(e),o=!i.has(r);return i.add(r),o})};var I=i(47706),_=i(65893),F=i(93628),C=i(93506),P=(i(80708),i(10968)),b=i(2783);class A{constructor(e,t="",i="Trash",r="Trash",o=!0,a=I.nr){this._inner=e,this.rootPath=t,this.trashId=i,this.trashPath=r,this.ensureFolderTrailingSlash=o,this.i18n=a,this._pathToId=new Map,this._idToPath=new Map,this.getUrl=void 0,this.getThumbnailUrl=void 0,this.validateDuplicates=void 0,this.validateDuplicates=this._inner.validateDuplicates,"function"===typeof e.getUrl&&(this.getUrl=t=>e.getUrl({...t,id:this.pathForId(t.id,!1),folderId:t.folderId?this.pathForId(t.folderId,!0):this.rootPath})),"function"===typeof e.getThumbnailUrl&&(this.getThumbnailUrl=t=>e.getThumbnailUrl({...t,id:this.pathForId(t.id,!1),folderId:t.folderId?this.pathForId(t.folderId,!0):this.rootPath})),"function"!==typeof this._inner.deleteItems&&(this.deleteItems=void 0),"function"!==typeof this._inner.deleteItem&&(this.deleteItem=void 0),"function"!==typeof this._inner.moveItems?this.moveItems=void 0:this.moveItem=void 0,"function"!==typeof this._inner.copyItems?this.copyItems=void 0:this.copyItem=void 0,"function"!==typeof this._inner.uploadFiles?this.uploadFiles=void 0:this.uploadFile=void 0,"function"!==typeof this._inner.clearCache&&(this.clearCache=void 0),this._getOrGenerateId(this.rootPath)}setController(e){"function"===typeof this._inner.setController&&this._inner.setController({invalidateItemCache:t=>{const i=t.replace(/^\/+|\/+$/g,""),r=this._pathToId.get(i);r&&e.invalidateItemCache(r)},getCachedItem:t=>{const i=t.replace(/^\/+|\/+$/g,""),r=this._pathToId.get(i);if(r){const t=e.getCachedItem(r);if(t)return{...t,id:this.pathForId(t.id,t.isFolder),folderId:this.pathForId(t.folderId,t.isFolder)}}}})}clearCache(e){if("function"===typeof this._inner.clearCache)return this._inner.clearCache(e)}_getOrGenerateId(e){if(e===this.rootPath)return;const t=e.replaceAll(/^\/+|\/+$/g,"");if(t===this.trashPath.replaceAll(/^\/+|\/+$/g,""))return this.trashId;if(this._pathToId.has(t))return this._pathToId.get(t);const i=(0,P.A)();return this._pathToId.set(t,i),this._idToPath.set(i,t),i}pathForId(e,t,i){const{__:r}=this.i18n;if(""===e||void 0===e)return this.rootPath;if(e===this.trashId)return this.trashPath;let o=this._idToPath.get(e);if(!o){if(i)return`unknown folder ${e}`;{const t=r?r(`Path for id '${e}' not found in mapping`):`Path for id '${e}' not found in mapping`;throw new b.FileManagerApiError(t,"FileNotFound")}}let a=0;for(;a<this.rootPath.length&&"/"===this.rootPath[a];)a++;if(a){let e=0;for(;e<o.length&&"/"===o[e];)e++;const t=o.slice(e);o="/".repeat(a)+t}return t&&this.ensureFolderTrailingSlash&&!o.endsWith("/")&&(o+="/"),o}_updateIdMapping(e,t){const i=t.replace(/^\/+|\/+$/g,""),r=this._idToPath.get(e);r&&this._pathToId.delete(r),this._idToPath.set(e,i),this._pathToId.set(i,e)}async getItems(e){const t=e.folderId?this.pathForId(e.folderId,!0):this.rootPath,i=await this._inner.getItems({...e,folderId:t}),r=i.items.map(e=>{const t=this._getOrGenerateId(e.id),i=e.folderId?this._getOrGenerateId(e.folderId):this._getOrGenerateId(this.rootPath);return{...e,id:t,folderId:i}});return{...i,items:r}}async createFolder(e,t,i){const r=t?this.pathForId(t,!0):this.rootPath,o=await this._inner.createFolder(e,r,i),a=this._getOrGenerateId(o.id),s=o.folderId?this._getOrGenerateId(o.folderId):this._getOrGenerateId(this.rootPath);return{...o,id:a,folderId:s}}async renameItem(e,t){const{__:i}=this.i18n;if("function"!==typeof this._inner.renameItem){const e=i?i("Rename item is not supported by inner storage"):"Rename item is not supported by inner storage";throw new b.FileManagerApiError(e,"RenameNotAllowed")}const r=this.pathForId(e.id,e.isFolder),o=r;let{...a}=await this._inner.renameItem({...e,id:r,folderId:this.pathForId(e.folderId,!0)},t);return this._updateIdMapping(e.id,a.id),e.isFolder&&this.remapCachedFolderContents(e.id,o,a.id),a.folderId&&(a={...a,folderId:this._getOrGenerateId(a.folderId)}),{...a,id:this._getOrGenerateId(a.id)}}async deleteItem(e,t){const{__:i}=this.i18n;if("function"!==typeof this._inner.deleteItem){const e=i?i("Delete item is not supported by inner storage"):"Delete item is not supported by inner storage";throw new b.FileManagerApiError(e,"DeleteNotAllowed")}const r=this.pathForId(e.id,e.isFolder);await this._inner.deleteItem({...e,id:r,folderId:this.pathForId(e.folderId,!0)},t),this.recursivelyRemoveMappings(e.id,r)}async uploadFile(e){const{__:t}=this.i18n;if("function"!==typeof this._inner.uploadFile){const e=t?t("Upload file is not supported by inner storage"):"Upload file is not supported by inner storage";throw new b.FileManagerApiError(e,"UnsupportedOperation")}const i=e.folderId?this.pathForId(e.folderId,!0):this.rootPath,r=await this._inner.uploadFile({...e,folderId:i}),o=this._getOrGenerateId(r.id),a=r.folderId?this._getOrGenerateId(r.folderId):this._getOrGenerateId(this.rootPath);return{...r,id:o,folderId:a}}async uploadFiles(e){var t,i,r,o,a;const s=e.folderId,n=null!==(t=null===(i=e.items)||void 0===i?void 0:i.map(e=>e.folderId))&&void 0!==t?t:[],l=e.folderId?this.pathForId(e.folderId,!0):this.rootPath,d={...e,folderId:l,items:null!==(r=null===(o=e.items)||void 0===o?void 0:o.map(e=>({...e,folderId:e.folderId?this.pathForId(e.folderId,!0):l})))&&void 0!==r?r:[]},h=await this._inner.uploadFiles(d);return{...h,detailed:null===(a=h.detailed)||void 0===a?void 0:a.map((e,t)=>{var i,r;if(null===e||void 0===e||!e.data)return e;const o=e.data.id?this._getOrGenerateId(e.data.id):void 0,a=e.data.folderId?this._getOrGenerateId(e.data.folderId):null!==(i=null!==(r=n[t])&&void 0!==r?r:s)&&void 0!==i?i:this._getOrGenerateId(this.rootPath);return{...e,data:{...e.data,id:o,folderId:a}}})}}async findFileByUrl(e,t){const i=t?this.pathForId(t,!0):this.rootPath;if("function"===typeof this._inner.findFileByUrl){const t=await this._inner.findFileByUrl(e,i);if(!t)return;const r=this._getOrGenerateId(t.id),o=t.folderId?this._getOrGenerateId(t.folderId):this._getOrGenerateId(this.rootPath);return{...t,id:r,folderId:o}}}async uploadFileByUrl(e,t,i){const r=t?this.pathForId(t,!0):this.rootPath,o=await this._inner.uploadFileByUrl(e,r,i),a=this._getOrGenerateId(o.id),s=o.folderId?this._getOrGenerateId(o.folderId):this._getOrGenerateId(this.rootPath);return{...o,id:a,folderId:s}}async moveItem(e,t){const{__:i}=this.i18n;if("function"!==typeof this._inner.moveItem){const e=i?i("Move item is not supported by inner storage"):"Move item is not supported by inner storage";throw new b.FileManagerApiError(e,"MoveNotAllowed")}const r=this.pathForId(e.id,e.isFolder),o=this.pathForId(t,!0),a=await this._inner.moveItem({...e,id:r,folderId:this.pathForId(e.folderId,!0)},o);this._updateIdMapping(e.id,a.id),e.isFolder&&this.remapCachedFolderContents(e.id,r,a.id);const s=this._getOrGenerateId(a.id),n=a.folderId?this._getOrGenerateId(a.folderId):t;return{...a,id:s,folderId:n}}async moveItems(e,t){const{__:i}=this.i18n;if("function"!==typeof this._inner.moveItems){const e=i?i("Move items is not supported by inner storage"):"Move items is not supported by inner storage";throw new b.FileManagerApiError(e,"MoveNotAllowed")}const r=t?this.pathForId(t,!0):this.rootPath,o=e.map(e=>({...e,id:this.pathForId(e.id,e.isFolder),folderId:e.folderId?this.pathForId(e.folderId,!0):this.rootPath})),a=await this._inner.moveItems(o,r),s=[];if(a.detailed&&a.detailed.length>0){const r=new Map;for(let t=0;t<a.detailed.length;t++){const i=a.detailed[t],o=i.requestId||(t<e.length?e[t].id:void 0);o&&r.set(o,i)}for(const o of e){const n=r.get(o.id)||(a.detailed.length===e.length?a.detailed[e.indexOf(o)]:void 0);if(null!==n&&void 0!==n&&n.success&&n.data){if(this._updateIdMapping(o.id,n.data.id),o.isFolder){const e=this.pathForId(o.id,o.isFolder);this.remapCachedFolderContents(o.id,e,n.data.id)}s.push({requestId:o.id,success:!0,data:{...n.data,id:this._getOrGenerateId(n.data.id),folderId:n.data.folderId?this._getOrGenerateId(n.data.folderId):t||this._getOrGenerateId(this.rootPath)}})}else{const e=i?i("Move operation failed - no detailed result"):"Move operation failed - no detailed result";s.push({requestId:o.id,success:!1,error:(null===n||void 0===n?void 0:n.error)||{message:e,code:"MoveNotAllowed"}})}}}else for(const n of e){const e=i?i("Move operation failed - no detailed results"):"Move operation failed - no detailed results";s.push({requestId:n.id,success:!1,error:{message:e,code:"MoveNotAllowed"}})}return{success:a.success,detailed:s,error:a.error}}async copyItems(e,t){const{__:i}=this.i18n;if("function"!==typeof this._inner.copyItems){const e=i?i("Copy items is not supported by inner storage"):"Copy items is not supported by inner storage";throw new b.FileManagerApiError(e,"CopyNotAllowed")}const r=t?this.pathForId(t,!0):this.rootPath,o=e.map(e=>({...e,id:this.pathForId(e.id,e.isFolder),folderId:e.folderId?this.pathForId(e.folderId,!0):this.rootPath})),a=await this._inner.copyItems(o,r),s=[];if(a.detailed&&a.detailed.length>0){const r=new Map;for(let t=0;t<a.detailed.length;t++){const i=a.detailed[t],o=i.requestId||(t<e.length?e[t].id:void 0);o&&r.set(o,i)}for(const o of e){var n;const l=r.get(o.id)||(a.detailed.length===e.length?a.detailed[e.indexOf(o)]:void 0);if(null!==l&&void 0!==l&&l.success&&null!==(n=l.data)&&void 0!==n&&n.id){const e=this._getOrGenerateId(l.data.id);s.push({requestId:o.id,success:!0,data:{...l.data,id:e,folderId:l.data.folderId?this._getOrGenerateId(l.data.folderId):t||this._getOrGenerateId(this.rootPath)}})}else{const e=l?l.success?l.data?l.data.id?{message:i?i("Unknown copy error"):"Unknown copy error",code:"CopyNotAllowed"}:{message:i?i("No ID in copied item data"):"No ID in copied item data",code:"CopyNotAllowed"}:{message:i?i("No data returned from copy operation"):"No data returned from copy operation",code:"CopyNotAllowed"}:l.error||{message:i?i("Copy operation failed"):"Copy operation failed",code:"CopyNotAllowed"}:{message:i?i("No detailed result from copy operation"):"No detailed result from copy operation",code:"CopyNotAllowed"};s.push({requestId:o.id,success:!1,error:e})}}}else for(const h of e){const e=i?i("No detailed results from copy operation"):"No detailed results from copy operation";s.push({requestId:h.id,success:!1,error:{message:e,code:"CopyNotAllowed"}})}const l=s.every(e=>e.success),d=i?i("Copy operation completed with errors"):"Copy operation completed with errors";return{success:l,detailed:s,error:l?void 0:a.error||{message:d,code:"CopyNotAllowed"}}}async deleteItems(e,t){const{__:i}=this.i18n;if("function"!==typeof this._inner.deleteItems){const e=i?i("Delete items is not supported by inner storage"):"Delete items is not supported by inner storage";throw new b.FileManagerApiError(e,"DeleteNotAllowed")}const r=e.map(e=>({...e,id:this.pathForId(e.id,e.isFolder),folderId:e.folderId?this.pathForId(e.folderId,!0):this.rootPath})),o=await this._inner.deleteItems(r,t),a=[];if(o.detailed&&o.detailed.length>0){const r=new Map;for(let t=0;t<o.detailed.length;t++){const i=o.detailed[t],a=i.requestId||(t<e.length?e[t].id:void 0);a&&r.set(a,i)}for(const s of e){const n=r.get(s.id)||(o.detailed.length===e.length?o.detailed[e.indexOf(s)]:void 0);if(null!==n&&void 0!==n&&n.success){const e=this.pathForId(s.id,s.isFolder);if(t.permanent)this.recursivelyRemoveMappings(s.id,e);else if(this._updateIdMapping(s.id,this.trashPath+"/"+e+(s.isFolder?"/":"")),s.isFolder){const t=this.pathForId(s.id,s.isFolder);this.remapCachedFolderContents(s.id,t,this.trashPath+"/"+e+(s.isFolder?"/":""))}a.push({requestId:s.id,success:!0})}else{const e=i?i("Delete operation failed"):"Delete operation failed";a.push({requestId:s.id,success:!1,error:(null===n||void 0===n?void 0:n.error)||{message:e,code:"DeleteNotAllowed"}})}}}else for(const l of e)if(o.success){const e=this.pathForId(l.id,l.isFolder);if(t.permanent)this.recursivelyRemoveMappings(l.id,e);else if(this._updateIdMapping(l.id,this.trashPath+"/"+e+(l.isFolder?"/":"")),l.isFolder){const t=this.pathForId(l.id,l.isFolder);this.remapCachedFolderContents(l.id,t,this.trashPath+"/"+e+(l.isFolder?"/":""))}a.push({requestId:l.id,success:!0})}else{const e=i?i("Delete operation failed"):"Delete operation failed";a.push({requestId:l.id,success:!1,error:o.error||{message:e,code:"DeleteNotAllowed"}})}const s=a.every(e=>e.success),n=i?i("Some items failed to delete"):"Some items failed to delete";return{success:s,detailed:a,error:s?void 0:o.error||{message:n,code:"DeleteNotAllowed"}}}remapCachedFolderContents(e,t,i){const r=t.replace(/\/+$/,""),o=i.replace(/\/+$/,""),a=[];for(const[s,n]of this._idToPath.entries()){const e=n.replace(/\/+$/,"");e!==r&&e.startsWith(r+"/")&&a.push({id:s,oldPath:e})}for(const{id:s,oldPath:n}of a){const e=o+n.substring(r.length);this._updateIdMapping(s,e)}}recursivelyRemoveMappings(e,t){const i=t.replace(/\/+$/,""),r=[],o=[];for(const[a,s]of this._idToPath.entries()){const e=s.replace(/\/+$/,"");(e===i||e.startsWith(i+"/"))&&(r.push(a),o.push(e))}for(let a=0;a<r.length;a++)this._idToPath.delete(r[a]),this._pathToId.delete(o[a])}async copyItem(e,t){const{__:i}=this.i18n;if("function"!==typeof this._inner.copyItem){const e=i?i("Copy item is not supported by inner storage"):"Copy item is not supported by inner storage";throw new b.FileManagerApiError(e,"CopyNotAllowed")}const r=this.pathForId(e.id,e.isFolder),o=this.pathForId(t,!0),a=await this._inner.copyItem({...e,id:r,folderId:this.pathForId(e.folderId,!0)},o),s=this._getOrGenerateId(a.id),n=a.folderId?this._getOrGenerateId(a.folderId):t;return{...a,id:s,folderId:n}}async updateFile(e,t){const{__:i}=this.i18n;if("function"!==typeof this._inner.updateFile){const e=i?i("Update file is not supported by inner storage"):"Update file is not supported by inner storage";throw new b.FileManagerApiError(e,"UnsupportedOperation")}const r=this.pathForId(e.id,!1);let{...o}=await this._inner.updateFile({...e,id:r,folderId:this.pathForId(e.folderId,!0)},t);return this._updateIdMapping(e.id,o.id),o.folderId&&(o={...o,folderId:this._getOrGenerateId(o.folderId)}),{...o,id:this._getOrGenerateId(o.id)}}async getFileData(e,t){const{__:i}=this.i18n,r=this.pathForId(e.id,!1);if("function"===typeof this._inner.getFileData)return this._inner.getFileData({...e,id:r,folderId:this.pathForId(e.folderId,!0)},t);const o=e.url||("function"===typeof this.getUrl?await this.getUrl(e):void 0);if(!o){const e=i?i("Cannot get file data: no url and no inner.getFileData"):"Cannot get file data: no url and no inner.getFileData";throw new b.FileManagerApiError(e,"FileReadError")}return fetch(o,null!==t&&void 0!==t&&t.forceReload?{cache:"no-store"}:void 0).then(e=>e.blob())}async cleanTrash(){const{__:e}=this.i18n;if("function"!==typeof this._inner.cleanTrash){const t=e?e("Clean trash is not supported by inner storage"):"Clean trash is not supported by inner storage";throw new b.FileManagerApiError(t,"UnsupportedOperation")}return await this._inner.cleanTrash()}}const E="\x1e";class M{constructor(){this.map=new Map}static childrenViewKey(e,t){return`v${E}${e}${E}${t}`}static childrenCountKey(e){return`c${E}${e}`}getFreshError(e,t){const i=this.map.get(e);return i?t!==1/0&&Date.now()-i.updatedAt>t?(this.map.delete(e),null):i.error:null}setError(e,t){this.map.set(e,{error:t,updatedAt:Date.now()})}delete(e){this.map.delete(e)}clearChildrenViewErrorsForParent(e){const t=`v${E}${e}${E}`;for(const i of[...this.map.keys()])i.startsWith(t)&&this.map.delete(i)}clearAll(){this.map.clear()}}const S=18e5;function T(e){return null==e||""===e?"":e}function O(e){if(null==e)return 1/0;const t=Number(e);return Number.isFinite(t)&&t>=0?t:1/0}function N(e){if(!e)return null;const t=e.folderId;return null==t?null:String(t)}function D(e){return!!e&&e.isFolder}function U(){var e;if("function"===typeof(null===globalThis||void 0===globalThis||null===(e=globalThis.crypto)||void 0===e?void 0:e.randomUUID))return globalThis.crypto.randomUUID();try{const e=globalThis.crypto||globalThis.msCrypto;if(e&&"function"===typeof e.getRandomValues){const t=new Uint8Array(16);e.getRandomValues(t);let i="";for(let e=0;e<t.length;e++)i+=t[e].toString(16).padStart(2,"0");return`id_${i}`}}catch{}return`id_fallback_${Date.now().toString(36)}_${Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(36).slice(0,8)}`}function x(e){if(!e||"object"!==typeof e)return String(null!==e&&void 0!==e?e:"");const t=e,i=[],r={},o=["page","pageSize","sortBy","sortOrder","search","itemType","limit"];for(const l of Object.keys(t).sort()){const e=t[l];o.includes(l)?i.push(`${l}=${String(null!==e&&void 0!==e?e:"")}`):r[l]=e}const a=Object.keys(r).length?JSON.stringify(r):"",s=i.join("|"),n=a?function(e){let t=2166136261;for(let i=0;i<e.length;i++)t^=e.charCodeAt(i),t=t+((t<<1)+(t<<4)+(t<<7)+(t<<8)+(t<<24))>>>0;return t.toString(36)}(a):"";return`${s}${n?`|${n}`:""}`}class R{constructor(){this.entities=new Map,this.childrenByParent=new Map,this.maxCacheSize=1e4}now(){return Date.now()}checkCacheSize(){if(this.entities.size>this.maxCacheSize){const e=Array.from(this.entities.entries()).sort((e,t)=>e[1].updatedAt-t[1].updatedAt),t=Math.floor(.1*this.maxCacheSize);for(let i=0;i<t&&i<e.length;i++){const[t,r]=e[i];this.deleteEntityById(t)}}}getEntity(e){var t;return null===(t=this.entities.get(e))||void 0===t?void 0:t.value}getRecord(e){return this.entities.get(e)}getFileSystemItem(e){const t=this.getEntity(e);return t&&!D(t)?t:void 0}getFolder(e){const t=this.getEntity(e);return t&&D(t)?t:void 0}getChildrenIds(e,t={}){const i=T(e),r=this.childrenByParent.get(i);return r?t.onlyFileSystemItems?Array.from(r.files):t.onlyFolders?Array.from(r.folders):[...Array.from(r.folders),...Array.from(r.files)]:[]}searchByUrl(e){for(const t of this.entities.values())if(t.value.url===e)return t.value;return null}upsertEntity(e){var t;const i=null!==(t=this.entities.get(e.id))&&void 0!==t?t:null,r=i?i.value:null,o=r?N(r):null,a=N(e),s=!!r&&D(r),n=D(e);let l;if(r&&D(r)&&n){const t=r.childrenCount,i=e.childrenCount;void 0!==t&&void 0===i&&(l=t)}if(r&&(o!==a||s!==n)){const t=T(o),i=this.childrenByParent.get(t);i&&(s?i.folders.delete(e.id):i.files.delete(e.id),0===i.files.size&&0===i.folders.size&&this.childrenByParent.delete(t))}let d=e;void 0!==l&&(d={...e,childrenCount:l}),this.entities.set(e.id,{value:{...d},updatedAt:this.now()}),this.checkCacheSize();const h=T(a);let c=this.childrenByParent.get(h);c||(c={files:new Set,folders:new Set},this.childrenByParent.set(h,c)),n?c.folders.add(e.id):c.files.add(e.id)}updateServerChildrenCount(e,t){if(null==e||null==t||Number.isNaN(t))return;const i=this.entities.get(e);if(!i||!D(i.value))return;const r={...i.value,childrenCount:t};this.entities.set(e,{value:r,updatedAt:this.now()})}deleteEntityById(e){var t;const i=null!==(t=this.entities.get(e))&&void 0!==t?t:null;if(!i)return{entity:null,parentId:null};const r=i.value,o=N(r),a=T(o),s=this.childrenByParent.get(a);return s&&(D(r)?s.folders.delete(e):s.files.delete(e),0===s.files.size&&0===s.folders.size&&this.childrenByParent.delete(a)),this.entities.delete(e),{entity:{...r},parentId:o}}deleteFolderRecursive(e){const t=this.entities.get(e);if(!t||!D(t.value))return{deletedFolderRecords:[],deletedFileSystemItemRecords:[]};const i=[{id:e,parentId:N(t.value)}],r=[],o=[];for(;i.length;){const e=i.shift();r.push(e);const t=this.childrenByParent.get(T(e.id));if(t){for(const e of Array.from(t.folders)){const t=this.entities.get(e);t&&i.push({id:e,parentId:N(t.value)})}for(const e of Array.from(t.files))o.push(e)}}const a=[];for(const n of o){const e=this.entities.get(n);if(!e)continue;const t=e.value,i=T(N(t)),r=this.childrenByParent.get(i);r&&(r.files.delete(n),0===r.files.size&&0===r.folders.size&&this.childrenByParent.delete(i)),this.entities.delete(n),a.push({...t})}const s=[];for(let n=r.length-1;n>=0;n--){const{id:e,parentId:t}=r[n],i=this.entities.get(e);if(!i)continue;const o=i.value,a=T(o.id);this.childrenByParent.delete(a);const l=T(t),d=this.childrenByParent.get(l);d&&(d.folders.delete(e),0===d.files.size&&0===d.folders.size&&this.childrenByParent.delete(l)),this.entities.delete(e),s.push({...o})}return{deletedFolderRecords:s,deletedFileSystemItemRecords:a}}moveEntityById(e,t){var i;const r=null!==(i=this.entities.get(e))&&void 0!==i?i:null;if(!r)return null;const o=r.value,a=T(N(o)),s=this.childrenByParent.get(a);s&&(D(o)?s.folders.delete(e):s.files.delete(e),0===s.files.size&&0===s.folders.size&&this.childrenByParent.delete(a));const n={...o,folderId:t};if(D(o)&&D(n)){const e=o.childrenCount;void 0!==e&&(n.childrenCount=e)}this.entities.set(e,{value:n,updatedAt:this.now()});const l=T(t);let d=this.childrenByParent.get(l);return d||(d={files:new Set,folders:new Set},this.childrenByParent.set(l,d)),D(n)?d.folders.add(e):d.files.add(e),{...n}}copyFileSystemItem(e,t,i){var r;const o=null!==(r=this.entities.get(e))&&void 0!==r?r:null;if(!o||D(o.value))return null;const a={...o.value,id:t,folderId:i};return this.upsertEntity(a),{...a}}copyFolderShallow(e,t,i){var r;const o=null!==(r=this.entities.get(e))&&void 0!==r?r:null;if(!o||!D(o.value))return null;const a={...o.value,id:t,folderId:i};return this.upsertEntity(a),{...a}}isEntityStale(e,t){var i;const r=null!==(i=this.entities.get(e))&&void 0!==i?i:null;return!r||t!==1/0&&this.now()-r.updatedAt>t}touch(e,t){const i=this.entities.get(e);i&&(i.updatedAt=null!==t&&void 0!==t?t:this.now())}getEntitiesByIds(e){return e.map(e=>{var t,i;return null!==(t=null===(i=this.entities.get(e))||void 0===i?void 0:i.value)&&void 0!==t?t:null})}searchByName(e,t){var i,r,o,a;if(!e||""===e.trim())return[];const s=null===t||void 0===t?void 0:t.parentId,n=null!==(i=null===t||void 0===t?void 0:t.recursive)&&void 0!==i&&i,l=null!==(r=null===t||void 0===t?void 0:t.itemType)&&void 0!==r?r:"all",d=null!==(o=null===t||void 0===t?void 0:t.caseSensitive)&&void 0!==o&&o,h=null!==(a=null===t||void 0===t?void 0:t.limit)&&void 0!==a?a:1/0,c=d?e.trim():e.trim().toLowerCase(),u=[];let v=null;if(void 0!==s){v=new Set;const e=T(s);if(v.add(e),n){const t=[e],i=new Set;for(;t.length>0;){const e=t.shift();if(i.has(e))continue;i.add(e);const r=this.childrenByParent.get(e);if(r)for(const i of r.folders)v.add(i),t.push(i)}}}for(const[,p]of this.entities){var f;if(u.length>=h)break;const e=p.value;if(null!==v){const t=T(N(e));if(!v.has(t))continue}if("file"===l&&D(e))continue;if("folder"===l&&!D(e))continue;const t=null!==(f=e.name)&&void 0!==f?f:"";(d?t:t.toLowerCase()).includes(c)&&u.push({...e})}return u}toJSON(){return{entities:Array.from(this.entities.entries()),childrenByParent:Array.from(this.childrenByParent.entries()).map(([e,t])=>[e,{files:Array.from(t.files),folders:Array.from(t.folders)}])}}static fromJSON(e){const t=new R;for(const[o,a]of null!==(i=e.entities)&&void 0!==i?i:[]){var i;t.entities.set(o,{value:a.value,updatedAt:a.updatedAt})}for(const[o,a]of null!==(r=e.childrenByParent)&&void 0!==r?r:[]){var r;t.childrenByParent.set(o,{files:new Set(a.files),folders:new Set(a.folders)})}return t}}class B{constructor(e={},t=18e5,i,r,o=new M){var a,s,n,l,d;this.views=new Map,this.strategy=void 0,this.ttl=void 0,this.errorTtl=void 0,this.entityTtl=void 0,this.failedRequests=void 0,this.serverChildrenCountHandler=void 0,this.childrenCountInvalidator=void 0,this.maxViewsPerParent=50,this.strategy={allowSortedInsert:null===(a=e.allowSortedInsert)||void 0===a||a,allowSearchInsert:null===(s=e.allowSearchInsert)||void 0===s||s,invalidateOnPaginationFull:null===(n=e.invalidateOnPaginationFull)||void 0===n||n,preloadPagesBefore:null!==(l=e.preloadPagesBefore)&&void 0!==l?l:0,preloadPagesAfter:null!==(d=e.preloadPagesAfter)&&void 0!==d?d:1,comparator:e.comparator,filterMatch:e.filterMatch},this.ttl=t,this.errorTtl=null!==i&&void 0!==i?i:t,this.entityTtl=null!==r&&void 0!==r?r:t,this.failedRequests=o}setServerChildrenCountHandler(e){this.serverChildrenCountHandler=e}setChildrenCountInvalidator(e){this.childrenCountInvalidator=e}now(){return Date.now()}parentKey(e){return T(null!==e&&void 0!==e?e:null)}isExpired(e){return null==e||this.ttl!==1/0&&this.now()-e>this.ttl}areEntitiesStale(e,t){return!e||e.some(e=>!t.getEntity(e)||t.isEntityStale(e,this.entityTtl))}isEntityTypeCompatible(e,t){return!t||"all"===t||("file"===t&&!D(e)||!("folder"!==t||!D(e)))}cleanupOldViews(e){if(e.size<=this.maxViewsPerParent)return;const t=Array.from(e.entries()).sort((e,t)=>(t[1].view.updatedAt||0)-(e[1].view.updatedAt||0));for(;e.size>this.maxViewsPerParent&&t.length>0;){const[i]=t.pop();e.delete(i)}}async getOrCreateChildren(e,t,i,r){var o;const a=this.parentKey(e),s=x(null!==t&&void 0!==t?t:{});let n=this.views.get(a);n||(n=new Map,this.views.set(a,n));const l=M.childrenViewKey(a,s);let d=n.get(s);if(!d){d={params:t,view:{promise:null,value:void 0,meta:void 0,updatedAt:0,loadId:null}},n.set(s,d),this.cleanupOldViews(n)}const h=this.failedRequests.getFreshError(l,this.errorTtl);if(null!=h)throw h;if(d.view.value&&!this.isExpired(d.view.updatedAt)&&!this.areEntitiesStale(d.view.value,r)&&(null===(o=d.view.meta)||void 0===o||!o.stale)){var c,u;const e=d.view.value.map(e=>r.getEntity(e)).filter(Boolean),t=(null===(c=d.params)||void 0===c?void 0:c.itemType)||"all";return{items:e.filter(e=>this.isEntityTypeCompatible(e,t)),...null!==(u=d.view.meta)&&void 0!==u?u:{}}}if(d.view.promise)return d.view.promise;const v=U();d.view.loadId=v;const f=(async()=>{try{var o,s,n;const c=await i(e,t),u=function(e){return!!e&&"string"===typeof e.search&&e.search.trim().length>0}(t),f=u?{...c,total:void 0}:c,p=null===(o=this.views.get(a))||void 0===o?void 0:o.get(x(t));if(!p||p.view.loadId!==v){const e=new Error("StaleLoad");throw e.name="StaleLoad",e}for(const e of f.items)r.upsertEntity(e);d.view.value=f.items.map(e=>e.id);const{items:m,...w}=f,g={...w};d.view.meta=g,d.view.meta.stale=!1,this.failedRequests.delete(l),d.view.updatedAt=this.now(),u||"number"!==typeof g.total||(this.serverChildrenCountHandler?this.serverChildrenCountHandler(null!==e&&void 0!==e?e:null,g.total,r):r.updateServerChildrenCount(e,g.total));const y=null!==(s=this.strategy.preloadPagesAfter)&&void 0!==s?s:0,I=null!==(n=this.strategy.preloadPagesBefore)&&void 0!==n?n:0,_=O(null===t||void 0===t?void 0:t.pageSize),F=Number.isFinite(_);if((y>0||I>0)&&F){var h;const o=e,a={...t},s="number"===typeof g.totalPages?g.totalPages:1,n=null!==(h=null===t||void 0===t?void 0:t.page)&&void 0!==h?h:1,l=_,d=i,c=v;setTimeout(()=>{this.preloadPagesAsync(o,a,n,s,l,y,I,r,g,d,c)},0)}return f}catch(m){var c,u,f,p;if("StaleLoad"===(null===m||void 0===m?void 0:m.name))throw this.failedRequests.delete(l),d.view.value=void 0,d.view.updatedAt=this.now(),m;const e=m,t=null!==(c=null===e||void 0===e?void 0:e.status)&&void 0!==c?c:null===e||void 0===e||null===(u=e.data)||void 0===u?void 0:u.status,i=null!==(f=null===e||void 0===e?void 0:e.code)&&void 0!==f?f:null===e||void 0===e||null===(p=e.data)||void 0===p?void 0:p.code;if(404===t||"FileNotFound"===i||"FolderNotFound"===i||"path_folder_not_found"===i)return this.failedRequests.delete(l),d.view.value=[],d.view.meta={total:0,totalPages:0},d.view.updatedAt=this.now(),{items:[],total:0,totalPages:0};throw this.failedRequests.setError(l,m),d.view.value=void 0,d.view.updatedAt=this.now(),m}finally{d.view.promise=null}})();return d.view.promise=f,f}async preloadPagesAsync(e,t,i,r,o,a,s,n,l,d,h){try{const o=this.parentKey(e),l=this.views.get(o);if(!l)return;const c=l.get(x(t));if(!c)return;if(null!=h&&c.view.loadId!==h)return;const u=l.get(x(t));if(null===u||void 0===u||!u.view.meta)return;const v="number"===typeof u.view.meta.totalPages?u.view.meta.totalPages:1;if(v!==r)return;const f=async i=>{const r={...t,page:i};try{const a=await d(e,r),s=this.views.get(o);if(!s)return;const l=s.get(x(t));if(!l)return;if(null!=h&&l.view.loadId!==h)return;if(l.view.loadId!==h)return;for(const e of a.items)n.upsertEntity(e);const c=x(r);let u=s.get(c);if(!u){u={params:r,view:{promise:null,value:void 0,meta:void 0,updatedAt:0,loadId:l.view.loadId}},s.set(c,u),this.cleanupOldViews(s)}if(!u.view.value||this.isExpired(u.view.updatedAt)){u.view.value=a.items.map(e=>e.id);const{items:e,...t}=a;u.view.meta={...t,page:i,totalPages:v},u.view.updatedAt=this.now()}}catch(a){}};if(a>0&&i<v)for(let e=1;e<=Math.min(a,v-i);e++){const r=i+e,o=x({...t,page:r}),a=l.get(o);null!==a&&void 0!==a&&a.view.value&&!this.isExpired(a.view.updatedAt)||f(r)}if(s>0&&i>1)for(let e=1;e<=Math.min(s,i-1);e++){const r=i-e,o=x({...t,page:r}),a=l.get(o);null!==a&&void 0!==a&&a.view.value&&!this.isExpired(a.view.updatedAt)||f(r)}}catch(c){}}removeEmptyPageIfNeeded(e,t,i,r,o){if(t.view.value&&0===t.view.value.length&&i<r){const t=x({...o,page:i});e.delete(t)}}updateTotalPagesForAllViews(e,t){for(const[,i]of e)i.view.meta&&(i.view.meta.totalPages=t)}isParamsSame(e,t){const i=Object.keys(null!==e&&void 0!==e?e:{}).filter(e=>"page"!==e).sort(),r=Object.keys(null!==t&&void 0!==t?t:{}).filter(e=>"page"!==e).sort();if(i.length!==r.length)return!1;for(let o=0;o<i.length;o++){const a=i[o];if(a!==r[o])return!1;if(e[a]!==t[a])return!1}return!0}syncTotalsInSameViews(e,t){var i;const r=t.view.meta;if(!r||"number"!==typeof r.total)return;const o=Number(r.total),a=O(null===(i=t.params)||void 0===i?void 0:i.pageSize),s=Number.isFinite(a)&&a>0?Math.max(1,Math.ceil(o/a)):void 0;for(const[,d]of e){var n,l;this.isParamsSame(null!==(n=d.params)&&void 0!==n?n:{},null!==(l=t.params)&&void 0!==l?l:{})&&(d.view.meta||(d.view.meta={}),d.view.meta.total=o,void 0!==s&&(d.view.meta.totalPages=s))}}canSafelyModifySortedView(e){return!e.sortBy&&!e.sortOrder||!!this.strategy.comparator}cascadeShiftPages(e,t,i,r,o,a,s){let n=t,l=i,d=!1;let h=0;for(;n.view.value&&n.view.value.length<r&&l<o&&h<100;){h++;const t=x({...s,page:l+1}),i=e.get(t);if(null===i||void 0===i||!i.view.value||this.isExpired(i.view.updatedAt)){var c;n.view.meta={...null!==(c=n.view.meta)&&void 0!==c?c:{},stale:!0};break}const o=r-n.view.value.length,v=i.view.value.slice(0,o).filter(e=>a.getEntity(e));if(0===v.length){var u;n.view.meta={...null!==(u=n.view.meta)&&void 0!==u?u:{},stale:!0};break}if(n.view.value=[...n.view.value,...v],n.view.updatedAt=Date.now(),i.view.value=i.view.value.slice(v.length),i.view.updatedAt=Date.now(),0===i.view.value.length){const t=l+1,r=i.view.meta;if(t<(r&&"number"===typeof r.totalPages?r.totalPages:1)){const i=x({...s,page:t});e.delete(i),d=!0}break}n=i,l++}var v;(!n.view.value||n.view.value.length<r)&&l>=o&&(n.view.meta={...null!==(v=n.view.meta)&&void 0!==v?v:{},stale:!0});return d}cascadeShiftToNextPage(e,t,i,r,o,a,s){var n,l;if(!t.view.value||t.view.value.length<=r)return!1;var d;if(i-(s.page||1)>=10)return t.view.meta={...null!==(d=t.view.meta)&&void 0!==d?d:{},stale:!0},!1;const h={...s,page:i+1},c=x(h);let u=e.get(c),v=!1;if(null===(n=u)||void 0===n||!n.view.value||this.isExpired(u.view.updatedAt)){var f;if(!(i>=o))return t.view.meta={...null!==(f=t.view.meta)&&void 0!==f?f:{},stale:!0},!1;{u={params:h,view:{promise:null,value:void 0,meta:void 0,updatedAt:0,loadId:null}},e.set(c,u),this.cleanupOldViews(e);const r=t.view.meta;r&&(u.view.meta={...r,page:i+1}),v=!0}}const p=t.view.value.slice(r).filter(e=>a.getEntity(e));if(0===p.length)return v&&e.delete(c),!1;t.view.value=t.view.value.slice(0,r),t.view.updatedAt=Date.now(),u.view.value=[...p,...null!==(l=u.view.value)&&void 0!==l?l:[]],u.view.updatedAt=Date.now();const m=u.view.meta&&"number"===typeof u.view.meta.totalPages?u.view.meta.totalPages:o;if(!v){if(this.cascadeShiftToNextPage(e,u,i+1,r,m,a,s))return!0}if(!u.view.value||0===u.view.value.length){const t=i+1,r=u.view.meta,o=r&&"number"===typeof r.totalPages?r.totalPages:1;this.removeEmptyPageIfNeeded(e,u,t,o,s)}return v}tryInsertSorted(e,t,i){var r;const o=this.strategy.comparator;if(!o)return!1;if(!e.view.value)return!1;const a=(null===(r=e.params)||void 0===r?void 0:r.itemType)||"all";if(!this.isEntityTypeCompatible(t,a))return!1;const s=e.view.value.map(e=>i.getEntity(e));if(s.some(e=>!e))return!1;let n=0,l=s.length;for(;n<l;){const i=Math.floor((n+l)/2),r=o(t,s[i],e.params);if("number"!==typeof r||Number.isNaN(r))return!1;r>=0?n=i+1:l=i}return e.view.value.includes(t.id)?(e.view.updatedAt=this.now(),!0):(e.view.value=[...e.view.value.slice(0,n),t.id,...e.view.value.slice(n)],e.view.updatedAt=this.now(),e.view.meta&&"number"===typeof e.view.meta.total&&(e.view.meta.total=Number(e.view.meta.total)+1),!0)}updateChildrenCountForOperation(e,t,i,r){var o,a,s,n;const l=N(t);switch(e){case"delete":this.adjustChildrenCount(r,l,-1),null===(o=this.childrenCountInvalidator)||void 0===o||o.call(this,l);break;case"insert":case"copy":this.adjustChildrenCount(r,l,1),null===(a=this.childrenCountInvalidator)||void 0===a||a.call(this,l);break;case"move":this.adjustChildrenCount(r,i,-1),this.adjustChildrenCount(r,l,1),null===(s=this.childrenCountInvalidator)||void 0===s||s.call(this,i),null===(n=this.childrenCountInvalidator)||void 0===n||n.call(this,l)}}adjustChildrenCount(e,t,i){if(!t)return;const r=e.getFolder(t);if(r&&"number"===typeof r.childrenCount){const o=Math.max(0,r.childrenCount+i);e.updateServerChildrenCount(t,o)}}smartInvalidateChildrenViews(e,t,i,r,o,a){if(!t)return;this.updateChildrenCountForOperation(i,t,o,r);const s=this.parentKey(e),n=this.views.get(s);if(n)for(const[,u]of n){var l,d;const e=null!==(l=u.params)&&void 0!==l?l:{},a=null!==(d=null===e||void 0===e?void 0:e.page)&&void 0!==d?d:1,s=O(null===e||void 0===e?void 0:e.pageSize),v=Number.isFinite(s),f=!!(null!==e&&void 0!==e&&e.sortBy||null!==e&&void 0!==e&&e.sortOrder),p=!(null===e||void 0===e||!e.search),m=(null===e||void 0===e?void 0:e.itemType)||"all";if(!this.isEntityTypeCompatible(t,m))continue;if(p&&this.strategy.filterMatch&&!this.strategy.filterMatch(t,u.params)){var h;null!==(h=u.view.value)&&void 0!==h&&h.includes(t.id)&&(u.view.value=u.view.value.filter(e=>e!==t.id),u.view.meta&&"number"===typeof u.view.meta.total&&(u.view.meta.total=Math.max(0,u.view.meta.total-1)),u.view.updatedAt=Date.now());continue}if(!u.view.value){u.view.meta&&(u.view.meta.stale=!0),u.view.loadId=U(),u.view.abortController&&(u.view.abortController.abort(),u.view.abortController=void 0);continue}u.view.value.includes(t.id);var c;if(this.shouldInvalidateCompletely(u,i,t,f,v,a))u.view.meta={...null!==(c=u.view.meta)&&void 0!==c?c:{},stale:!0},u.view.loadId=U(),u.view.abortController&&(u.view.abortController.abort(),u.view.abortController=void 0);else switch(i){case"delete":this.handleDelete(n,u,a,s,v,t,r);break;case"insert":case"copy":this.handleInsert(n,u,a,s,v,f,t,r);break;case"update":this.handleUpdate(n,u,a,s,v,f,p,t,r);break;case"move":this.handleMove(n,u,a,s,v,f,t,o,r)}}}shouldInvalidateCompletely(e,t,i,r,o,a){return!(!(o&&a>1)||"insert"!==t&&"delete"!==t&&"move"!==t)||(!(!r||this.strategy.comparator||"insert"!==t&&"move"!==t)||!!this.isExpired(e.view.updatedAt))}tryReinsertEntity(e,t,i,r,o){var a,s;const n=(null===(a=e.params)||void 0===a?void 0:a.itemType)||"all";if(!this.isEntityTypeCompatible(t,n))return!1;if(this.strategy.comparator&&this.strategy.filterMatch){if(!this.strategy.filterMatch(t,e.params))return!1;if(this.tryInsertSorted(e,t,i))return!0}const l=null!==(s=e.params)&&void 0!==s?s:{};return!(!(!l.sortBy&&!l.sortOrder)&&!this.canSafelyModifySortedView(l))&&((!r||e.view.value.length<o)&&(e.view.value.push(t.id),!0))}handleDelete(e,t,i,r,o,a,s){const n=t.view.value.includes(a.id);if(n&&(t.view.value=t.view.value.filter(e=>e!==a.id)),t.view.meta&&"number"===typeof t.view.meta.total){if(t.view.meta.total=Math.max(0,t.view.meta.total-1),o&&Number.isFinite(r)&&"number"===typeof t.view.meta.total){const e=r;e>0&&(t.view.meta.totalPages=Math.max(1,Math.ceil(t.view.meta.total/e)))}this.syncTotalsInSameViews(e,t)}if(t.view.updatedAt=Date.now(),n&&o&&t.view.value.length<r&&s){var l;const o=t.view.meta,a=o&&"number"===typeof o.totalPages?o.totalPages:1;if(this.cascadeShiftPages(e,t,i,r,a,s,null!==(l=t.params)&&void 0!==l?l:{})&&t.view.meta&&"number"===typeof t.view.meta.totalPages){const i=Math.max(1,t.view.meta.totalPages-1);t.view.meta.totalPages=i,this.updateTotalPagesForAllViews(e,i)}}t.view.loadId=U(),t.view.abortController&&(t.view.abortController.abort(),t.view.abortController=void 0)}handleInsert(e,t,i,r,o,a,s,n){if(!t.view.value.includes(s.id)){if(a&&this.strategy.allowSortedInsert&&this.strategy.comparator&&n){if(this.tryInsertSorted(t,s,n)&&t.view.meta&&"number"===typeof t.view.meta.total){if(t.view.meta.total+=1,o&&Number.isFinite(r)){const e=r;e>0&&(t.view.meta.totalPages=Math.max(1,Math.ceil(t.view.meta.total/e)))}this.syncTotalsInSameViews(e,t)}if(o&&t.view.value.length>r&&n){var l;const o=t.view.meta,a=o&&"number"===typeof o.totalPages?o.totalPages:1;if(this.cascadeShiftToNextPage(e,t,i,r,a,n,null!==(l=t.params)&&void 0!==l?l:{})&&t.view.meta&&"number"===typeof t.view.meta.totalPages){const i=t.view.meta.totalPages+1;t.view.meta.totalPages=i,this.updateTotalPagesForAllViews(e,i)}}}else if(!o||t.view.value.length<r){if(t.view.value.push(s.id),t.view.meta&&"number"===typeof t.view.meta.total){if(t.view.meta.total+=1,o&&Number.isFinite(r)){const e=r;e>0&&(t.view.meta.totalPages=Math.max(1,Math.ceil(t.view.meta.total/e)))}this.syncTotalsInSameViews(e,t)}t.view.updatedAt=Date.now()}else{var d;t.view.meta={...null!==(d=t.view.meta)&&void 0!==d?d:{},stale:!0}}t.view.loadId=U(),t.view.abortController&&(t.view.abortController.abort(),t.view.abortController=void 0)}}handleUpdate(e,t,i,r,o,a,s,n,l){var d;const h=t.view.value.includes(n.id),c=this.isEntityTypeCompatible(n,(null===(d=t.params)||void 0===d?void 0:d.itemType)||"all");if(h&&!c){if(t.view.value=t.view.value.filter(e=>e!==n.id),t.view.meta&&"number"===typeof t.view.meta.total&&(t.view.meta.total=Math.max(0,t.view.meta.total-1),o&&Number.isFinite(r)&&"number"===typeof t.view.meta.total)){const e=r;e>0&&(t.view.meta.totalPages=Math.max(1,Math.ceil(t.view.meta.total/e)))}if(t.view.updatedAt=Date.now(),o&&t.view.value.length<r&&l){var u;const o=t.view.meta,a=o&&"number"===typeof o.totalPages?o.totalPages:1;if(this.cascadeShiftPages(e,t,i,r,a,l,null!==(u=t.params)&&void 0!==u?u:{})&&t.view.meta&&"number"===typeof t.view.meta.totalPages){const i=Math.max(1,t.view.meta.totalPages-1);t.view.meta.totalPages=i,this.updateTotalPagesForAllViews(e,i)}}return t.view.loadId=U(),void(t.view.abortController&&(t.view.abortController.abort(),t.view.abortController=void 0))}if(h&&(a||s)){t.view.value=t.view.value.filter(e=>e!==n.id);if(this.tryReinsertEntity(t,n,l,o,r)){if(t.view.meta&&"number"===typeof t.view.meta.total){if(t.view.meta.total+=1,o&&Number.isFinite(r)){const e=r;e>0&&(t.view.meta.totalPages=Math.max(1,Math.ceil(t.view.meta.total/e)))}this.syncTotalsInSameViews(e,t)}}else{if(t.view.meta&&"number"===typeof t.view.meta.total){if(t.view.meta.total=Math.max(0,t.view.meta.total-1),o&&Number.isFinite(r)&&"number"===typeof t.view.meta.total){const e=r;e>0&&(t.view.meta.totalPages=Math.max(1,Math.ceil(t.view.meta.total/e)))}this.syncTotalsInSameViews(e,t)}if(o&&t.view.value.length<r&&l){var v;const o=t.view.meta,a=o&&"number"===typeof o.totalPages?o.totalPages:1;if(this.cascadeShiftPages(e,t,i,r,a,l,null!==(v=t.params)&&void 0!==v?v:{})&&t.view.meta&&"number"===typeof t.view.meta.totalPages){const i=Math.max(1,t.view.meta.totalPages-1);t.view.meta.totalPages=i,this.updateTotalPagesForAllViews(e,i)}}}return t.view.updatedAt=Date.now(),t.view.loadId=U(),void(t.view.abortController&&(t.view.abortController.abort(),t.view.abortController=void 0))}if(h)return t.view.updatedAt=Date.now(),t.view.loadId=U(),void(t.view.abortController&&(t.view.abortController.abort(),t.view.abortController=void 0));if(c&&!s){if(a&&this.strategy.allowSortedInsert&&this.strategy.comparator&&l){if(this.tryInsertSorted(t,n,l)&&t.view.meta&&"number"===typeof t.view.meta.total){if(t.view.meta.total+=1,o&&Number.isFinite(r)){const e=r;e>0&&(t.view.meta.totalPages=Math.max(1,Math.ceil(t.view.meta.total/e)))}this.syncTotalsInSameViews(e,t)}}else if(!o||t.view.value.length<r){if(t.view.value.push(n.id),t.view.meta&&"number"===typeof t.view.meta.total){if(t.view.meta.total+=1,o&&Number.isFinite(r)){const e=r;e>0&&(t.view.meta.totalPages=Math.max(1,Math.ceil(t.view.meta.total/e)))}this.syncTotalsInSameViews(e,t)}t.view.updatedAt=Date.now()}else{var f;t.view.meta={...null!==(f=t.view.meta)&&void 0!==f?f:{},stale:!0}}t.view.loadId=U(),t.view.abortController&&(t.view.abortController.abort(),t.view.abortController=void 0)}}handleMove(e,t,i,r,o,a,s,n,l){if(t.view.value.includes(s.id)){if(t.view.value=t.view.value.filter(e=>e!==s.id),t.view.meta&&"number"===typeof t.view.meta.total&&(t.view.meta.total=Math.max(0,t.view.meta.total-1),o&&Number.isFinite(r)&&"number"===typeof t.view.meta.total)){const e=r;e>0&&(t.view.meta.totalPages=Math.max(1,Math.ceil(t.view.meta.total/e)))}if(t.view.updatedAt=Date.now(),o&&t.view.value.length<r&&l){var d;const o=t.view.meta,a=o&&"number"===typeof o.totalPages?o.totalPages:1;if(this.cascadeShiftPages(e,t,i,r,a,l,null!==(d=t.params)&&void 0!==d?d:{})&&t.view.meta&&"number"===typeof t.view.meta.totalPages){const i=Math.max(1,t.view.meta.totalPages-1);t.view.meta.totalPages=i,this.updateTotalPagesForAllViews(e,i)}}this.syncTotalsInSameViews(e,t)}t.view.loadId=U(),t.view.abortController&&(t.view.abortController.abort(),t.view.abortController=void 0)}forceInvalidateChildrenViews(e){const t=this.parentKey(null!==e&&void 0!==e?e:null);this.failedRequests.clearChildrenViewErrorsForParent(t);const i=this.views.get(t);if(i)for(const[,r]of i)r.view.value=void 0,r.view.meta=void 0,r.view.promise=null,r.view.updatedAt=0,r.view.loadId=U(),r.view.abortController&&(r.view.abortController.abort(),r.view.abortController=void 0)}getKnownTotal(e){const t=this.parentKey(null!==e&&void 0!==e?e:null),i=this.views.get(t);if(!i)return;let r=null;for(const[,s]of i){const e=s.view.meta;var o,a;if(e&&"number"===typeof e.total)if(!r||(null!==(o=s.view.updatedAt)&&void 0!==o?o:0)>r.updatedAt)r={total:Number(e.total),updatedAt:null!==(a=s.view.updatedAt)&&void 0!==a?a:0}}return r?r.total:void 0}toJSON(){return{views:Array.from(this.views.entries()).map(([e,t])=>[e,Array.from(t.entries())]),ttl:this.ttl,errorTtl:this.errorTtl,entityTtl:this.entityTtl,strategy:{allowSortedInsert:this.strategy.allowSortedInsert,allowSearchInsert:this.strategy.allowSearchInsert,invalidateOnPaginationFull:this.strategy.invalidateOnPaginationFull,preloadPagesBefore:this.strategy.preloadPagesBefore,preloadPagesAfter:this.strategy.preloadPagesAfter}}}static fromJSON(e,t){var i,r,o,a,s;const n=null!==(i=null!==(r=null===t||void 0===t?void 0:t.ttl)&&void 0!==r?r:null===e||void 0===e?void 0:e.ttl)&&void 0!==i?i:S,l=null!==(o=null!==(a=null===t||void 0===t?void 0:t.errorTtl)&&void 0!==a?a:null===e||void 0===e?void 0:e.errorTtl)&&void 0!==o?o:n,d=null!==(s=null===t||void 0===t?void 0:t.failedRequests)&&void 0!==s?s:new M,h=new B({},n,l,void 0,d);for(const[u,v]of null!==(c=e.views)&&void 0!==c?c:[]){var c;const e=new Map;for(const[t,i]of v){const r=i;null!==r&&void 0!==r&&r.view&&"error"in r.view&&delete r.view.error,e.set(t,r)}h.views.set(u,e)}return h}}class z{invalidateChildrenCountCache(e){const t=T(null!==e&&void 0!==e?e:"");this.childrenCountPromises.delete(t),this.failedRequests.delete(M.childrenCountKey(t))}constructor(e={},t=18e5,i){this.entities=void 0,this.views=void 0,this.ttl=void 0,this.errorTtl=void 0,this.failedRequests=void 0,this.childrenCountPromises=new Map,this.failedRequests=new M,this.ttl=t,this.errorTtl=null!==i&&void 0!==i?i:t,this.entities=new R,this.views=new B(e,t,this.errorTtl,void 0,this.failedRequests),this.views.setServerChildrenCountHandler((e,t,i)=>{this.handleServerReportedChildrenCount(e,t,null!==i&&void 0!==i?i:this.entities)}),this.views.setChildrenCountInvalidator(e=>{this.invalidateChildrenCountCache(e)})}getEntity(e){var t;return null!==(t=this.entities.getEntity(e))&&void 0!==t?t:null}getFileSystemItem(e){var t;return null!==(t=this.entities.getFileSystemItem(e))&&void 0!==t?t:null}getFolder(e){var t;return null!==(t=this.entities.getFolder(e))&&void 0!==t?t:null}async getOrCreateChildren(e,t,i){return this.views.getOrCreateChildren(e,t,i,this.entities)}upsertEntity(e){const t=this.entities.getEntity(e.id),i=t?N(t):null,r=N(e),o=!!t&&D(t),a=D(e);if(this.entities.upsertEntity(e),t){if(i!==r||o!==a)return this.views.smartInvalidateChildrenViews(i,t,"delete",this.entities),void this.views.smartInvalidateChildrenViews(r,e,"insert",this.entities);this.views.smartInvalidateChildrenViews(r,e,"update",this.entities,void 0,t)}else this.views.smartInvalidateChildrenViews(r,e,"insert",this.entities)}isAncestor(e,t){let i=t;const r=new Set;for(;i&&!r.has(i);){r.add(i);if(T(i)===T(e))return!0;const t=this.entities.getEntity(i);if(!t)break;i=N(t),null===i&&(i="")}return!1}moveEntity(e,t){const i=this.entities.getEntity(e);if(!i)return null;if(D(i)&&null!==t&&this.isAncestor(e,t))return null;const r=N(i),o=this.entities.moveEntityById(e,t);return o?(this.views.smartInvalidateChildrenViews(r,i,"delete",this.entities),this.views.smartInvalidateChildrenViews(t,o,"insert",this.entities),o):null}copyEntity(e,t,i,r){const o=this.entities.getEntity(e);if(!o)return null;let a=null;if(D(o)){var s;const i=[e],o=[];for(;i.length;){const e=i.shift();o.push(e);const t=this.entities.getChildrenIds(e,{onlyFolders:!0});for(const r of t)i.push(r)}const d=new Map;for(const e of o)d.set(e,U());for(const a of o){var n,l;const i=this.entities.getFolder(a),o=d.get(a),s=N(i),h=null===s?t:null!==(n=d.get(s))&&void 0!==n?n:null,c={...i,...a===e?r:void 0,id:o,folderId:null!==(l=a===e?null===r||void 0===r?void 0:r.folderId:void 0)&&void 0!==l?l:h};this.entities.upsertEntity(c)}for(const e of o){const t=d.get(e),i=this.entities.getChildrenIds(e,{onlyFileSystemItems:!0});for(const e of i){const i=this.entities.getFileSystemItem(e);if(!i)continue;const r=U(),o={...i,id:r,folderId:t};this.entities.upsertEntity(o)}}a=null!==(s=this.entities.getEntity(d.get(e)))&&void 0!==s?s:null}else{const o=null!==i&&void 0!==i?i:U();if(a=this.entities.copyFileSystemItem(e,o,null!==t&&void 0!==t?t:null),a&&r){var d,h;const e={...a,...r,id:o,folderId:null!==(d=null!==(h=r.folderId)&&void 0!==h?h:t)&&void 0!==d?d:null};this.entities.upsertEntity(e),a=e}}return a&&this.views.smartInvalidateChildrenViews(t,a,"copy",this.entities),a}searchByUrl(e){var t;return null!==(t=this.entities.searchByUrl(e))&&void 0!==t?t:null}deleteEntity(e){const t=this.entities.getEntity(e);if(!t)return null;if(D(t)){const{deletedFolderRecords:i,deletedFileSystemItemRecords:r}=this.entities.deleteFolderRecursive(e);for(const e of r)this.views.smartInvalidateChildrenViews(e.folderId,e,"delete",this.entities);for(const e of i)this.views.smartInvalidateChildrenViews(e.folderId,e,"delete",this.entities);for(const e of i)this.views.forceInvalidateChildrenViews(e.id);return t}{const{entity:t,parentId:i}=this.entities.deleteEntityById(e);return t&&this.views.smartInvalidateChildrenViews(i,t,"delete",this.entities),t}}deleteFolderRecursive(e){const{deletedFolderRecords:t,deletedFileSystemItemRecords:i}=this.entities.deleteFolderRecursive(e);for(const r of i)this.views.smartInvalidateChildrenViews(r.folderId,r,"delete",this.entities);for(const r of t)this.views.smartInvalidateChildrenViews(r.folderId,r,"delete",this.entities);for(const r of t)this.views.forceInvalidateChildrenViews(r.id);return{deletedFileSystemItemIds:i.map(e=>e.id),deletedFolderIds:t.map(e=>e.id)}}forceInvalidate(e){const t=this.entities.getEntity(e);if(!t)return;const i=new Set;if(D(t)){const t=[e];for(;t.length;){const e=t.pop();if(i.has(e))continue;i.add(e),this.views.forceInvalidateChildrenViews(e),this.invalidateChildrenCountCache(e);const r=this.entities.getChildrenIds(e,{onlyFolders:!0});for(const i of r)t.push(i)}}else{var r;const e=null!==(r=t.folderId)&&void 0!==r?r:null;this.views.forceInvalidateChildrenViews(e),this.invalidateChildrenCountCache(e)}}getChildrenIds(e){return this.entities.getChildrenIds(e)}searchByName(e,t){return this.entities.searchByName(e,t)}async getChildrenCount(e="",t){const i=T(e),r=M.childrenCountKey(i),o=this.failedRequests.getFreshError(r,this.errorTtl);if(null!=o)return Promise.reject(o);const a=this.childrenCountPromises.get(i);if(a)return a;const s=(async()=>{try{const i=this.entities.getFolder(e);if(i&&"number"===typeof i.childrenCount)return this.failedRequests.delete(r),i.childrenCount;const o=this.views.getKnownTotal(e);if("number"===typeof o)return i&&this.handleServerReportedChildrenCount(e,o,this.entities),this.failedRequests.delete(r),o;if(t){const i=await t(e);return this.entities.getFolder(e)&&this.handleServerReportedChildrenCount(e,i,this.entities),this.failedRequests.delete(r),i}return this.failedRequests.delete(r),this.entities.getChildrenIds(e).length}catch(o){if(this.childrenCountPromises.delete(i),function(e){var t,i,r;if(!e||"object"!==typeof e)return!1;const o=e;return"path_folder_not_found"===o.code||"path_folder_not_found"===(null===(t=o.data)||void 0===t?void 0:t.code)||404===o.status||404===(null===(i=o.data)||void 0===i||null===(r=i.data)||void 0===r?void 0:r.status)}(o))return this.failedRequests.delete(r),0;throw this.failedRequests.setError(r,o),o}finally{this.childrenCountPromises.delete(i)}})();return this.childrenCountPromises.set(i,s),s}toJSON(){return{entities:this.entities.toJSON(),views:this.views.toJSON(),ttl:this.ttl,errorTtl:this.errorTtl}}static fromJSON(e,t){var i,r,o,a;const s=null!==(i=null===e||void 0===e?void 0:e.ttl)&&void 0!==i?i:S,n=null!==(r=null===e||void 0===e?void 0:e.errorTtl)&&void 0!==r?r:s,l=new z(null!==t&&void 0!==t?t:{},s,n),d=R.fromJSON(null!==(o=null===e||void 0===e?void 0:e.entities)&&void 0!==o?o:{}),h=B.fromJSON(null!==(a=null===e||void 0===e?void 0:e.views)&&void 0!==a?a:{},{failedRequests:l.failedRequests,ttl:s,errorTtl:n});var c,u,v,f,p;t&&(h.strategy={allowSortedInsert:null===(c=t.allowSortedInsert)||void 0===c||c,allowSearchInsert:null===(u=t.allowSearchInsert)||void 0===u||u,invalidateOnPaginationFull:null===(v=t.invalidateOnPaginationFull)||void 0===v||v,preloadPagesBefore:null!==(f=t.preloadPagesBefore)&&void 0!==f?f:0,preloadPagesAfter:null!==(p=t.preloadPagesAfter)&&void 0!==p?p:1,comparator:t.comparator,filterMatch:t.filterMatch});return l.entities=d,l.views=h,h.setServerChildrenCountHandler((e,t,i)=>{l.handleServerReportedChildrenCount(e,t,null!==i&&void 0!==i?i:d)}),h.setChildrenCountInvalidator(e=>{l.invalidateChildrenCountCache(e)}),l}handleServerReportedChildrenCount(e,t,i){this.checkAndResolveChildrenCountConflict(e,t,i),this.invalidateChildrenCountCache(e)}checkAndResolveChildrenCountConflict(e,t,i){if(!i||void 0===t)return;const r=null!==e&&void 0!==e?e:null;if(!r)return void i.updateServerChildrenCount(r,t);const o=i.getFolder(r),a=null===o||void 0===o?void 0:o.childrenCount;void 0!==a&&a!==t&&this.views.forceInvalidateChildrenViews(r),i.updateServerChildrenCount(r,t)}}class k{constructor(){this.deletingIds=new Set}beginDeleting(e){for(const t of e)t&&this.deletingIds.add(t)}endDeleting(e){for(const t of e)t&&this.deletingIds.delete(t)}isDeleting(e){return!!e&&this.deletingIds.has(e)}}var q;function G(e,t){const i=null!==e&&void 0!==e?e:{},r=Array.isArray(i.detailed)?i.detailed.map(e=>{var i;return{requestId:null!==(i=e.requestId)&&void 0!==i?i:e.id,success:!!e.success,data:t(e.data),error:e.error}}):void 0;return{success:!!i.success,error:i.error,detailed:r}}let L=(V=q=class{async _findOrCreateFolderByPath(e){const{__:t}=this.i18n,i=(r=e)?r.replaceAll("\\","/").split("/").filter(Boolean):[];var r;if(i.length>10){const e=t("Path depth exceeds maximum limit of %s").replace("%s",String(10));throw new b.FileManagerApiError(e,"ValidationError")}let o;for(const n of i){var a;const{files:i}=await this.getFiles({folderId:(null===(a=o)||void 0===a?void 0:a.id)||"",itemType:"folder"}),r=i.find(e=>e.name===n);if(r){if(!r.isFolder){const i=t("Path component '%s' in '%s' is not a folder").replace("%s",n).replace("%s",e);throw new b.FileManagerApiError(i,"ValidationError")}o={id:r.id,name:r.name,parentId:r.folderId}}else{var s;if("function"!==typeof this._dataProvider.createFolder)throw new b.FileManagerApiError(t("Create folder operation is not supported by data provider"),"UnsupportedOperation");o=await this.createFolder({name:n,parentId:null===(s=o)||void 0===s?void 0:s.id})}}return o}getTrashFolder(){return this._findOrCreateFolderByPath(this._pathOptions.trashPath||"Trash")}getTempFolder(){return this._findOrCreateFolderByPath(this._pathOptions.tempPath||"Edited")}constructor(e,t={},i,r=I.nr){var o,a;this._dataProvider=e,this._options=t,this._pathOptions=i,this.i18n=r,this._cache=void 0,this._rootId=void 0,this._useSoftDelete=void 0,this._enableTrash=void 0,this._validateDuplicates=void 0,this._blobFetchForceReloadOnceIds=new Set,this._mutationRegistry=new k,this._mapItem=async({childrenCount:e,...t})=>{if(t.isFolder)return{...t,childCount:e,url:"",thumbnailUrl:""};const[i,r]=await Promise.all([this._getUrl(t),this._getThumbnailUrl(t)]);return{...t,childCount:0,url:i,thumbnailUrl:r}},this._useSoftDelete=this._pathOptions.useSoftDelete,this._rootId=this._pathOptions.rootId||"",this._enableTrash=void 0===this._options.enableTrash||this._options.enableTrash,this._validateDuplicates=this._dataProvider.validateDuplicates,this._cache=new z(t.cacheStrategy||{},null===(o=t.cacheStrategy)||void 0===o?void 0:o.ttl,null===(a=t.cacheStrategy)||void 0===a?void 0:a.errorTtl),this.setController({invalidateItemCache:e=>{this._cache.forceInvalidate(e)},getCachedItem:e=>this._cache.getEntity(e)}),"function"!==typeof this._dataProvider.clearCache&&(this.clearCache=void 0)}setController(e){"function"===typeof this._dataProvider.setController&&this._dataProvider.setController(e)}async clearCache(e){if("function"!==typeof this._dataProvider.clearCache){const{__:e}=this.i18n;throw new b.FileManagerApiError(e("Clear cache is not supported by data provider"),"UnsupportedOperation")}this._cache.forceInvalidate(this._rootId),await this._dataProvider.clearCache(e)}markNextFileBlobFetchBypassHttpCache(e){this._blobFetchForceReloadOnceIds.add(this.normalizeId(e))}normalizeId(e){return e?"root"===e||"folders"===e?this._rootId:e:this._rootId}_isDeletingId(e){return this._mutationRegistry.isDeleting(this.normalizeId(e))}_collectDeletingIds(e){const t=this.normalizeId(e),i=new Set([t]),r=this._cache.getEntity(t);if(null===r||void 0===r||!r.isFolder)return Array.from(i);const o=[t];for(;o.length>0;){const e=o.pop(),t=this._cache.getChildrenIds(e);for(const r of t){if(i.has(r))continue;i.add(r);const e=this._cache.getEntity(r);null!==e&&void 0!==e&&e.isFolder&&o.push(r)}}return Array.from(i)}_emptyFilesResult(e,t){return{files:[],pagination:{..."number"===typeof e?{page:e}:{},..."number"===typeof t?{limit:t}:{},total:0,totalPages:1,hasNext:!1,hasPrev:!1}}}_validateName(e,t=!1){if(!e||0===e.trim().length){const e=t?"FolderInvalidName":"FileInvalidName",{__:i}=this.i18n,r=i(t?"Folder name cannot be empty":"File name cannot be empty");throw new b.FileManagerApiError(r,e)}if(/[\/\\:*?"<>|]/.test(e)){const{__:i}=this.i18n,r=t?"FolderInvalidName":"FileInvalidName",o=t?i("Folder name contains invalid characters: %s").replace("%s",e):i("File name contains invalid characters: %s").replace("%s",e);throw new b.FileManagerApiError(o,r)}}_validateTargetFolderType(e){const t=this.normalizeId(e);if(t===this._rootId)return;const i=this._cache.getEntity(t);if(i&&!i.isFolder){const{__:t}=this.i18n,i=t("Target item with id '%s' is not a folder").replace("%s",e);throw new b.FileManagerApiError(i,"ValidationError")}}_checkNameExistsInCache(e,t,i,r){const o=this.normalizeId(e),a=this._cache.getChildrenIds(o);for(const s of a){const e=this._cache.getEntity(s);if(e&&e.name===t&&!!e.isFolder===i&&(!r||e.id!==r))return!0}return!1}async _getUrl(e){if(e.url)return e.url;try{var t;return"function"===typeof(null===(t=this._dataProvider)||void 0===t?void 0:t.getUrl)&&this._dataProvider.getUrl(e)||""}catch(i){}return""}async _getThumbnailUrl(e){if(e.thumbnailUrl)return e.thumbnailUrl;try{var t;return"function"===typeof(null===(t=this._dataProvider)||void 0===t?void 0:t.getThumbnailUrl)&&this._dataProvider.getThumbnailUrl(e)||""}catch(i){}return""}_isAncestor(e,t){if(!t)return!1;const i=this.normalizeId(t),r=this.normalizeId(e);if(i===r)return!0;let o=this._cache.getEntity(i);const a=new Set;for(;o&&o.folderId&&!a.has(o.id);){a.add(o.id);const e=this.normalizeId(o.folderId);if(e===r)return!0;if(o=this._cache.getEntity(e),!o||!o.isFolder)break}return!1}async getFile(e,t){return this._isDeletingId(e)?null:this._cache.searchByName(t,{parentId:this.normalizeId(e),caseSensitive:!0,recursive:!1,itemType:"file"})[0]||(await this.getFiles({folderId:e,itemType:"file",search:t})).files[0]}async getFileById(e){const t=this.normalizeId(e);if(this._isDeletingId(t))return null;const i=this._cache.getFileSystemItem(t);if(i&&!i.isFolder)return await this._mapItem(i);if(!this._dataProvider.pathMode)return null;const r=await this._getFileByPathStyleId(t);return r&&!r.isFolder?(this._cache.upsertEntity(r),await this._mapItem(r)):null}async _getFileByPathStyleId(e){const t=e.replace(/\\/g,"/").replace(/^\/+/,""),i=t.lastIndexOf("/"),r=i<0?"":t.slice(0,i),o=i<0?t:t.slice(i+1);return o?this.getFile(r,o):null}async getFileUrl(e,t){const i=await this.getFile(e,t);return await this._getUrl(i)||await this._getThumbnailUrl(i)||i.thumbnail}async getFiles({folderId:e,search:t,sortBy:i,sortOrder:r,page:o,limit:a,itemType:s="all",noFolder:n=!1}){var l,d;n&&(e=null===(d=await this.getTempFolder())||void 0===d?void 0:d.id);const h=this.normalizeId(null!==(l=e)&&void 0!==l?l:this._rootId),c=!1===this._options.enablePagination,u=c?1:o,v=c?1e4:a,f=this._options.clientSideFilter,p=this._options.clientSideSorting,m=this._options.clientSidePaging,w=m?Math.max(1,null!==o&&void 0!==o?o:1):void 0,g=m?"number"===typeof a&&Number.isFinite(a)&&a>0?a:25:void 0,y=this._emptyFilesResult(m?w:u,m?g:v);if(this._isDeletingId(h))return y;const I=!1!==this._options.unifiedCatalogFetch&&c&&("folder"===s||"file"===s),_=I?"all":s,F={folderId:h,itemType:_};f||(F.search=t),p||(F.sortBy=null!==i&&void 0!==i?i:"folder"!==_?"date":void 0,F.sortOrder=null!==r&&void 0!==r?r:"folder"!==_?"desc":void 0),m||(F.page=u,F.limit=I?1e4:v);const C=I?1e4:m?void 0:v,P={folderId:h,itemType:_,search:f?void 0:t,sortBy:p?void 0:F.sortBy,sortOrder:p?void 0:F.sortOrder,page:m?void 0:u,pageSize:C};let b;try{b=await this._cache.getOrCreateChildren(h,P,async(e,t)=>{const i=t.pageSize,r=null!=i&&Number.isFinite(Number(i))?Number(i):1e4,o=await this._dataProvider.getItems({...t,folderId:e,limit:r});var a;return m?{items:o.items,total:"number"===typeof(null===(a=o.pagination)||void 0===a?void 0:a.total)?o.pagination.total:o.items.length}:{items:o.items,...o.pagination}})}catch(O){if(this._isDeletingId(h))return y;throw O}let A,E=b.items;if(I&&("folder"===s?E=E.filter(e=>e.isFolder):"file"===s&&(E=E.filter(e=>!e.isFolder))),f)if("function"===typeof this._options.clientSideFilter)E=this._options.clientSideFilter(E,t);else if(t){const e=t.toLowerCase();E=E.filter(t=>{var i;return null===(i=t.name)||void 0===i?void 0:i.toLowerCase().includes(e)})}var M;p&&(E="function"===typeof this._options.clientSideSorting?this._options.clientSideSorting(E,i,r):this._defaultClientSideSort(E,i,r)),A=m||f||I?E.length:null!==(M=b.total)&&void 0!==M?M:E.length;let S=E;if(m)if("function"===typeof this._options.clientSidePaging)S=this._options.clientSidePaging(E,w,g);else{const e=(w-1)*g,t=e+g;S=E.slice(e,t)}if("function"===typeof this._dataProvider.getUrl||"function"===typeof this._dataProvider.getThumbnailUrl){const e=S.map(async e=>{if(e.isFolder)return e;const[t,i]=await Promise.all([e.url?Promise.resolve(e.url):"function"===typeof this._dataProvider.getUrl?this._dataProvider.getUrl(e):Promise.resolve(void 0),e.thumbnailUrl?Promise.resolve(e.thumbnailUrl):"function"===typeof this._dataProvider.getThumbnailUrl?this._dataProvider.getThumbnailUrl(e):Promise.resolve(void 0)]);return{...e,url:t,thumbnailUrl:i}});S=await Promise.all(e)}const T=m?{page:w,limit:g,total:A,totalPages:Math.max(1,Math.ceil(A/g)),hasNext:w*g<A,hasPrev:w>1}:{page:u,limit:v,total:A,...!m&&b.totalPages&&{totalPages:b.totalPages},...!m&&b.hasNextPage&&{hasNextPage:b.hasNextPage}};return{files:await Promise.all(S.map(this._mapItem)),pagination:T}}_defaultClientSideSort(e,t,i){return e.sort((e,r)=>{let o=0;switch(t){case"name":default:o=(e.name||"").localeCompare(r.name||"");break;case"date":o=new Date(e.date||0).getTime()-new Date(r.date||0).getTime();break;case"size":o=(Number(e.size)||0)-(Number(r.size)||0)}return"desc"===i?-o:o})}async getFileData(e,t){const i=this.normalizeId("string"===typeof e?e:e.id);let r=t;this._blobFetchForceReloadOnceIds.delete(i)&&(r={...t,forceReload:!0});const o=this._cache.getEntity(i)||("string"===typeof e?{id:i,name:"",folderId:this._rootId,isFolder:!1}:{...e,childrenCount:e.childCount});if("function"===typeof this._dataProvider.getFileData)return await this._dataProvider.getFileData(o,r);const{__:a}=this.i18n;if(!o.url&&"function"!==typeof this._dataProvider.getUrl)throw new b.FileManagerApiError(a("Cannot read file"),"FileReadError");const s=o.url||("function"===typeof this._dataProvider.getUrl?await this._dataProvider.getUrl(o):"");var n;if(s)return(await fetch(s,null!==(n=r)&&void 0!==n&&n.forceReload?{cache:"no-store"}:void 0)).blob();throw new b.FileManagerApiError(a("Unable to get file data"),"FileReadError")}async findFileByUrl(e){const t=this._cache.searchByUrl(e);if(t)return t;if("function"===typeof this._dataProvider.findFileByUrl)try{const t=await this._dataProvider.findFileByUrl(e);if(t)return this._cache.upsertEntity(t),t}catch(i){}return null}async getChildrenCount(e){if(!e)return 0;const t=this.normalizeId(null!==e&&void 0!==e?e:this._rootId);return this._isDeletingId(t)?0:this._cache.getChildrenCount(t,async()=>{try{if(this._options.clientSidePaging){var e;const i=await this.getFiles({folderId:t,itemType:"all",page:1,limit:25});return null!==(e=i.pagination.total)&&void 0!==e?e:i.files.length}const i=await this._dataProvider.getItems({folderId:t,limit:0,itemType:"all"});return"undefined"!==typeof i.pagination?i.pagination.total||0:!1===this._options.enablePagination?i.items.length:0}catch(i){if(this._isDeletingId(t))return 0;if(this._isPathFolderNotFoundError(i))return 0;throw i}})}_isPathFolderNotFoundError(e){var t,i,r;if(!e||"object"!==typeof e)return!1;const o=e;return"path_folder_not_found"===o.code||"path_folder_not_found"===(null===(t=o.data)||void 0===t?void 0:t.code)||404===o.status||404===(null===(i=o.data)||void 0===i||null===(r=i.data)||void 0===r?void 0:r.status)}async _uploadFile(e){var t;const i=this.normalizeId(null!==(t=e.folderId)&&void 0!==t?t:this._rootId),{__:r}=this.i18n;if("function"!==typeof this._dataProvider.uploadFile)throw new b.FileManagerApiError(r("Upload file operation is not supported by data provider"),"UnsupportedOperation");if(this._validateName(e.name,!1),this._validateDuplicates&&this._checkNameExistsInCache(i,e.name,!1)){const t=r("File '%s' already exists in target folder").replace("%s",e.name);throw new b.FileManagerApiError(t,"FileAlreadyExists")}const o=await this._dataProvider.uploadFile({...e,folderId:i}),a={name:e.name,size:e.size,...o,folderId:i};return this._cache.upsertEntity(a),a}async uploadFiles(e){var t,i;const r=e.items.some(e=>e.noFolder)?await this.getTempFolder():null;e={...e,items:null===(t=e.items)||void 0===t?void 0:t.map(e=>({...e,folderId:e.noFolder?null===r||void 0===r?void 0:r.id:e.folderId}))};for(const v of e.items)v.folderId&&(e.folderId=v.folderId);const o=e.items||[],a=null!==(i=e.folderId)&&void 0!==i?i:this._rootId,s=this.normalizeId(a);if(this._validateDuplicates)for(const v of o)if(v.name){var n;this._validateName(v.name,!1);const e=this.normalizeId(null!==(n=v.folderId)&&void 0!==n?n:s);if(this._checkNameExistsInCache(e,v.name,!1)){const{__:e}=this.i18n,t=e("File '%s' already exists in target folder").replace("%s",v.name);throw new b.FileManagerApiError(t,"FileAlreadyExists")}}const l=this._cache.getEntity(s);let d={detailed:new Array(o.length),success:!0};if("function"===typeof this._dataProvider.uploadFiles){const e=o.map(e=>{var t;return{...e,folderId:this.normalizeId(null!==(t=e.folderId)&&void 0!==t?t:s)}});if(d=G(await this._dataProvider.uploadFiles({folderId:s,items:e}),e=>{if(e)return{id:e.id,name:e.name,folderId:e.folderId}}),d.detailed&&d.detailed.length){for(let e=0;e<d.detailed.length;e++){const t=d.detailed[e];if(t&&t.success){var h,c;const e=t.data,i=null!==(h=null===e||void 0===e?void 0:e.id)&&void 0!==h?h:t.requestId,r={...l,...e,folderId:null!==(c=null===e||void 0===e?void 0:e.folderId)&&void 0!==c?c:s};this._cache.upsertEntity(r),t.requestId=i}}void 0===d.success&&(d.success=!d.detailed.some(e=>!e.success))}else d.success=!d.error&&!!d.success}else{if("function"!==typeof this._dataProvider.uploadFile)throw new b.FileManagerApiError("Upload files is not supported by data provider","UnsupportedOperation");d.detailed=await Promise.all(o.map(async e=>{var t;const i=this.normalizeId(null!==(t=e.folderId)&&void 0!==t?t:s);try{const t=await this._uploadFile({...e,folderId:i});return{requestId:t.id,data:t,success:!0}}catch(r){return{requestId:null===e||void 0===e?void 0:e.id,success:!1,error:r}}})),d.success=!d.detailed.some(e=>!e.success)}if(d.success&&this._enableTrash)try{this._cache.forceInvalidate(s)}catch(u){}return d}async deleteFile(e){const t=this.normalizeId(e),i=[t];this._mutationRegistry.beginDeleting(i);try{if(this._useSoftDelete&&this._enableTrash){const e=await this.getTrashFolder();return await this.moveItem({itemId:t,targetFolderId:e.id,isFolder:!1})}return await this.hardDeleteItem(t)}finally{this._mutationRegistry.endDeleting(i)}}async deleteItems(e,t){const i=Array.from(new Set(e.flatMap(e=>this._collectDeletingIds(this.normalizeId(e)))));this._mutationRegistry.beginDeleting(i);try{if(this._useSoftDelete&&this._enableTrash&&!0!==t.permanent){const t=await this.getTrashFolder();return await this.moveItems(t.id,e)}return await this.hardDeleteItems(e,t)}finally{this._mutationRegistry.endDeleting(i)}}async hardDeleteItems(e,t){let i={success:!0,detailed:[]};const r=t.permanent?null:await this.getTrashFolder();if("function"===typeof this._dataProvider.deleteItems){if(i=G(await this._dataProvider.deleteItems(e.map(e=>this._cache.getEntity(e)),t),e=>e),i.success){const t=i.detailed||e.map(e=>({requestId:e,success:!0,error:void 0}));for(const e of t)e.success&&(r?this._cache.moveEntity(e.requestId,r.id):this._cache.deleteEntity(e.requestId))}}else"function"===typeof this._dataProvider.deleteItem&&(i.detailed=await Promise.all(e.map(async e=>{const i=this._cache.getEntity(e);if(!i){const t="FileNotFound",{__:i}=this.i18n,r=i("Item with id '%s' not found").replace("%s",e);return{requestId:e,success:!1,error:new b.FileManagerApiError(r,t)}}try{return await this._dataProvider.deleteItem(i,t),r?this._cache.moveEntity(e,r.id):this._cache.deleteEntity(e),{requestId:e,success:!0}}catch(o){return{requestId:e,error:o,success:!1}}})),i.success=!i.detailed.some(e=>!e.success));if(i.success&&r)try{this._cache.forceInvalidate(r.id)}catch(o){}return i}async hardDeleteItem(e){const t=this._cache.getEntity(e);if(!t){const{__:t}=this.i18n,i=t("Item with id '%s' not found in cache").replace("%s",e);throw new b.FileManagerApiError(i,"FileNotFound")}if("function"!==typeof this._dataProvider.deleteItem){const{__:e}=this.i18n;throw new b.FileManagerApiError(e("Delete item operation is not supported by data provider"),"DeleteNotAllowed")}if(await this._dataProvider.deleteItem(t,{permanent:!0}),this._cache.deleteEntity(e),this._enableTrash)try{const e=await this.getTrashFolder();e&&this._cache.forceInvalidate(e.id)}catch(i){}return!0}async cleanTrash(){const{__:e}=this.i18n;if(!this._enableTrash)throw new b.FileManagerApiError(e("Trash is not enabled"),"UnsupportedOperation");if("function"===typeof this._dataProvider.cleanTrash){const e=await this._dataProvider.cleanTrash();try{const e=await this.getTrashFolder();e&&this._cache.forceInvalidate(e.id)}catch(t){}return e}throw new b.FileManagerApiError(e("Clean trash is not supported by data provider"),"UnsupportedOperation")}async createFolder({name:e,parentId:t,is_force_create:i}){const r=this.normalizeId(null!==t&&void 0!==t?t:this._rootId);if(this._validateName(e,!0),this._validateDuplicates&&this._checkNameExistsInCache(r,e,!0)){const{__:t}=this.i18n,i=t("Folder '%s' already exists in parent folder").replace("%s",e);throw new b.FileManagerApiError(i,"FolderAlreadyExists")}const o=await this._dataProvider.createFolder(e,r,i);return this._cache.upsertEntity({id:o.id,folderId:r,name:o.name,isFolder:!0,childrenCount:o.childrenCount}),o}async deleteFolder(e){const t=this.normalizeId(e),i=this._collectDeletingIds(t);this._mutationRegistry.beginDeleting(i);try{if(this._useSoftDelete&&this._enableTrash)try{const e=await this.getTrashFolder();return!!await this.moveItem({itemId:t,targetFolderId:e.id,isFolder:!0})&&(this._cache.deleteFolderRecursive(t),!0)}catch(r){return await this.hardDeleteItem(t)}return await this.hardDeleteItem(t)}finally{this._mutationRegistry.endDeleting(i)}}async renameFolder(e,t){const{__:i}=this.i18n;if("function"!==typeof this._dataProvider.renameItem)throw new b.FileManagerApiError(i("Rename folder is not supported"),"RenameNotAllowed");const r=this.normalizeId(e),o=this._cache.getEntity(r);if(!o){const t=i("Folder with id '%s' not found in cache").replace("%s",e);throw new b.FileManagerApiError(t,"FolderNotFound")}if(this._validateName(t,!0),this._validateDuplicates){const e=this.normalizeId(o.folderId);if(this._checkNameExistsInCache(e,t,!0,r)){const e=i("Folder '%s' already exists in parent folder").replace("%s",t);throw new b.FileManagerApiError(e,"FolderAlreadyExists")}}const a=await this._dataProvider.renameItem(o,t);return this._cache.upsertEntity({...this._cache.getEntity(a.id),...a}),this._cache.getEntity(a.id)}async renameFile(e,t){const{__:i}=this.i18n;if("function"!==typeof this._dataProvider.renameItem)throw new b.FileManagerApiError(i("Rename file is not supported"),"RenameNotAllowed");const r=this._cache.getEntity(e);if(!r){const t=i("File with id '%s' not found in cache").replace("%s",e);throw new b.FileManagerApiError(t,"FileNotFound")}const o=this.normalizeId(e);if(this._validateName(t,!1),this._validateDuplicates){const e=this.normalizeId(r.folderId);if(this._checkNameExistsInCache(e,t,!1,o)){const e=i("File '%s' already exists in parent folder").replace("%s",t);throw new b.FileManagerApiError(e,"FileAlreadyExists")}}const a=await this._dataProvider.renameItem(r,t);return a&&this._cache.upsertEntity({...this._cache.getEntity(o),...a}),this._cache.getEntity(o)}async moveItem({itemId:e,targetFolderId:t,isFolder:i}){if("function"!==typeof this._dataProvider.moveItem){const{__:e}=this.i18n;throw new b.FileManagerApiError(e("Move item operation is not supported by data provider"),"MoveNotAllowed")}const r=this.normalizeId(t);this._validateTargetFolderType(t);const o=this._cache.getEntity(e);if(!o){const t=await this._dataProvider.moveItem({id:e,folderId:r,isFolder:i},r);if(t.id===e)this._cache.upsertEntity({...t,folderId:r});else{try{this._cache.deleteEntity(e)}catch(n){}this._cache.upsertEntity({...t,folderId:r})}return!0}const{__:a}=this.i18n;if(o.isFolder){if(e===r)throw new b.FileManagerApiError(a("Cannot move folder into itself"),"MoveIntoSelf");if(this._isAncestor(e,r))throw new b.FileManagerApiError(a("Cannot move folder into its descendant"),"MoveIntoDescendant")}if(this._validateDuplicates&&r!==this.normalizeId(o.folderId)&&o.name&&this._checkNameExistsInCache(r,o.name,!!o.isFolder,e)){const e=o.isFolder?"FolderAlreadyExists":"FileAlreadyExists";throw new b.FileManagerApiError(`${o.isFolder?"Folder":"File"} '${o.name}' already exists in target folder`,e)}const s=await this._dataProvider.moveItem(o,r);if(s.id===e){const t=this._cache.moveEntity(e,r);return this._cache.upsertEntity({...t,...s}),!0}{const t=this._cache.deleteEntity(e);return this._cache.upsertEntity({...t,...s,folderId:r}),!0}}async moveItems(e,t){const i=this.normalizeId(e);this._validateTargetFolderType(e);const r=t.map(e=>this._cache.getEntity(e));for(const a of r)if(a){if(a.isFolder){const{__:e}=this.i18n;if(a.id===i){const t=e("Cannot move folder '%s' into itself").replace("%s",a.name);throw new b.FileManagerApiError(t,"MoveIntoSelf")}if(this._isAncestor(a.id,i)){const t=e("Cannot move folder '%s' into its descendant").replace("%s",a.name);throw new b.FileManagerApiError(t,"MoveIntoDescendant")}}if(this._validateDuplicates){const e=this.normalizeId(a.folderId);if(i!==e&&a.name&&this._checkNameExistsInCache(i,a.name,!!a.isFolder,a.id)){const e=a.isFolder?"FolderAlreadyExists":"FileAlreadyExists";throw new b.FileManagerApiError(`${a.isFolder?"Folder":"File"} '${a.name}' already exists in target folder`,e)}}}let o={detailed:new Array(r.length),success:!0};if("function"===typeof this._dataProvider.moveItems)o=G(await this._dataProvider.moveItems(r,i),e=>e);else{if("function"!==typeof this._dataProvider.moveItem)throw new b.FileManagerApiError("Move items is not supported","MoveNotAllowed");o.detailed=await Promise.all(t.map(async(e,t)=>{const o=r[t]||{id:e,folderId:null,isFolder:!1,name:e};try{return{requestId:e,data:await this._dataProvider.moveItem(o,i),success:!0}}catch(a){return{requestId:e,success:!1,error:a}}}))}if(o.success){const e=o.detailed||t.map(e=>({requestId:e,success:!0,data:void 0}));for(const t of e)if(t.success)if(t.data&&t.data.id!==t.requestId){const e=this._cache.deleteEntity(t.requestId);this._cache.upsertEntity({...e,...t.data,folderId:i})}else this._cache.moveEntity(t.requestId,i),t.data&&this._cache.upsertEntity({...this._cache.getEntity(t.requestId),...t.data,folderId:i});return o}{const{__:e}=this.i18n;return{success:!1,error:o.error||new b.FileManagerApiError(e("Move items failed"),"MoveNotAllowed")}}}async copyItem({itemId:e,targetFolderId:t}){if("function"!==typeof this._dataProvider.copyItem){const{__:e}=this.i18n;throw new b.FileManagerApiError(e("Copy item is not supported"),"CopyNotAllowed")}const i=this.normalizeId(t);this._validateTargetFolderType(t);const r=this._cache.getEntity(e);if(!r){const t=await this._dataProvider.copyItem({id:e,folderId:i},i);return this._cache.copyEntity(e,i,t.id),this._cache.upsertEntity({...t,folderId:i}),!0}if(this._validateDuplicates&&r.name){const t=i===this.normalizeId(r.folderId)?e:void 0;if(this._checkNameExistsInCache(i,r.name,!!r.isFolder,t)){const e=r.isFolder?"FolderAlreadyExists":"FileAlreadyExists";throw new b.FileManagerApiError(`${r.isFolder?"Folder":"File"} '${r.name}' already exists in target folder`,e)}}const o=await this._dataProvider.copyItem(r,i);return this._cache.copyEntity(e,i,o.id,{...o,folderId:i})||this._cache.upsertEntity({...o,folderId:i}),!0}async copyItems(e,t){const i=this.normalizeId(e);this._validateTargetFolderType(e);const r=t.map(e=>"string"===typeof e?{id:e}:e),o=r.map(e=>e.id),a=o.map((e,t)=>{var i;const o=this._cache.getEntity(e),a=null===(i=r[t])||void 0===i?void 0:i.newName;return o?a?{...o,name:a}:o:void 0});if(this._validateDuplicates)for(let l=0;l<a.length;l++){const e=a[l];if(e&&e.name){const t=this.normalizeId(e.folderId),r=i===t?o[l]:void 0;if(this._checkNameExistsInCache(i,e.name,!!e.isFolder,r)){const t=e.isFolder?"FolderAlreadyExists":"FileAlreadyExists";throw new b.FileManagerApiError(`${e.isFolder?"Folder":"File"} '${e.name}' already exists in target folder`,t)}}}let s={detailed:new Array(a.length),success:!0};if("function"===typeof this._dataProvider.copyItems)s=G(await this._dataProvider.copyItems(a,i),e=>e);else{if("function"!==typeof this._dataProvider.copyItem){const{__:e}=this.i18n;throw new b.FileManagerApiError(e("Copy items is not supported"),"CopyNotAllowed")}s.detailed=await Promise.all(o.map(async(e,t)=>{const r=a[t]||{id:e,folderId:null,isFolder:!1};try{return{requestId:e,data:await this._dataProvider.copyItem(r,i),success:!0}}catch(o){return{requestId:e,success:!1,error:o}}}))}if(s.success&&s.detailed)for(let l=0,d=s.detailed.length;l<d;l++){const e=s.detailed[l];var n;if(e.success&&null!==(n=e.data)&&void 0!==n&&n.id){const t=e.data.folderId||i;!this._cache.copyEntity(e.requestId,t,e.data.id,{...e.data,folderId:t})&&e.data&&this._cache.upsertEntity({...e.data,folderId:t})}}else if(!s.detailed)throw new b.FileManagerApiError("batchResult in copy method must have detailed results","ValidationError");return s}async uploadFileByUrl(e){var t;if(e.noFolder){const t=await this.getTempFolder();e={...e,folderId:t.id}}const i=this.normalizeId(null!==(t=e.folderId)&&void 0!==t?t:this._rootId);try{const t=await this._dataProvider.uploadFileByUrl(e.url,i,{eventSource:e.eventSource});return this._cache.upsertEntity({...t,folderId:i}),t}catch(r){throw r}}async updateFile(e,t){const{__:i}=this.i18n;if("function"!==typeof this._dataProvider.updateFile)throw new b.FileManagerApiError(i("Update file is not supported"),"UnsupportedOperation");const r=this.normalizeId(e),o=this._cache.getEntity(r);if(!o){const t=i("File with id '%s' not found in cache").replace("%s",e);throw new b.FileManagerApiError(t,"FileNotFound")}if(t.name&&t.name!==o.name&&this._validateName(t.name,!1),this._validateDuplicates&&t.name&&t.name!==o.name){const e=this.normalizeId(o.folderId);if(this._checkNameExistsInCache(e,t.name,!1,r)){const e=i("File '%s' already exists in parent folder").replace("%s",t.name);throw new b.FileManagerApiError(e,"FileAlreadyExists")}}const a=await this._dataProvider.updateFile(o,{...t});return this._cache.upsertEntity({...this._cache.getEntity(r),...a,...t}),this._cache.getEntity(r)}},class extends V{constructor(...e){super(...e);const t=Object.getOwnPropertyNames(V.prototype);for(const i of t){const e=Object.getOwnPropertyDescriptor(V.prototype,i);"constructor"!==i&&"function"===typeof(null===e||void 0===e?void 0:e.value)&&this[i]&&(this[i]=this[i].bind(this))}}}||q);var V,$=i(25516),j=i(20263),K=i(70529);const H="a_T7zSNUXtMfhVWQbIOMpXIPqzLQ8hm5Wfclm2nU98PtlSVxcft8FSn5InbD04056fYCpKXP20jJSySRLu",J={ru:"ru_RU",en:"en_GB",uk:"uk_UA",de:"de_DE",fr:"fr_FR",es:"es_ES",it:"it_IT",pt:"pt_PT",pl:"pl_PL",zh:"zh-Hans_CN",ja:"ja_JP"};async function W(e,t={}){const i=e.trim();if(!i)return i;const r=(e=>{if(!e)return"en_GB";const t=e.toLowerCase().split(/[-_]/)[0];return J[t]||"auto"})(t.locale);if(t.locale&&"en_GB"===r)return i;try{const e={from:t.locale?r:"auto",to:"en_GB",data:i,platform:"api"},o=await fetch("https://api-b2b.backenster.com/b1/api/v3/translate",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${H}`},body:JSON.stringify(e)});if(!o.ok)return i;const a=await o.json();if(a.err)return i;const s=a.result;return"string"===typeof s&&s.trim()?s.trim():i}catch(o){return i}}function Y(){const e=(0,o.Pj)(),t=(0,o.d4)(c.B),i=(0,w.ml)(_.AZ.ON_TRANSLATE_ID);return(0,r.useCallback)(async(r,o={})=>{var a;const s=r.trim();if(!s)return s;const n=null!==(a=o.locale)&&void 0!==a?a:"string"===typeof t?t:void 0,l=void 0!==j.di.getInstance(e,K.Ef);try{const e=await i.fire({input:s,locale:n}),t=function(e){for(const t of e)if("string"===typeof t&&t.trim().length>0)return t.trim();return null}(Array.isArray(e)?e:[e]);if(t)return t}catch(d){}return l?s:W(s,{locale:n}).catch(()=>s)},[t,e,i])}var Z=i(2527),X=i(74397);const Q=(0,r.memo)(F.KG),ee=(0,r.memo)(F.BC),{useToken:te}=s.A,ie="static/media/image-editor",re="js/browser-image-compression.js",oe=({storageProvider:e})=>{var t,i;const s=(0,p.rD)(),{projectId:y,emailId:F,blockId:P}=(0,a.g)(),b=(0,I.s9)(),{__:E}=b,{token:M}=te(),{error:T,notify:O}=(0,m.hN)(),N=(0,o.wA)(),D=(0,o.d4)(c.B$),U=(0,o.d4)(c.C1),x=(0,o.d4)(u.cL),R=(0,o.d4)(v.yN),B=Y(),{request:z,resolveImagePicker:k}=(0,X.p)(),q=(0,r.useMemo)(()=>{const e=s.fileManager;if(e)return{...e,enablePagination:!1===e.enablePagination?Boolean(e.clientSidePaging):e.enablePagination}},[s.fileManager]),[G,V]=(0,r.useState)(""),[j,K]=(0,r.useState)("my_files"),[H,J]=(0,r.useState)(!1),[W,oe]=(0,r.useState)(0),[ae,se]=(0,r.useState)(""),[ne,le]=(0,r.useState)(()=>[]),de=(0,r.useCallback)(()=>{N((0,u.Oo)()),setTimeout(()=>V(""),600)},[N]),he=!(D||(null===(t=U.id)||void 0===t?void 0:t.toString())!==(null===R||void 0===R||null===(i=R.members)||void 0===i?void 0:i.owner.ID));(0,r.useEffect)(()=>{null!==z&&void 0!==z&&z.kind&&(V(z.kind),se(z.currentUrl||"")),x===C.lx.UPLOAD_IMAGE_MODAL||x===C.lx.UPLOAD_BACKGROUND_MODAL?K("editor"):x===C.lx.UPLOAD_IMAGE_MODAL_AI||x===C.lx.UPLOAD_BACKGROUND_MODAL_AI?he?(J(!0),oe(2)):K("ai"):x===C.lx.UPLOAD_IMAGE_MODAL_UPLOAD||x===C.lx.UPLOAD_BACKGROUND_MODAL_UPLOAD?K("my_files"):x===C.lx.UPLOAD_IMAGE_MODAL_STOCK||x===C.lx.UPLOAD_BACKGROUND_MODAL_STOCK?he?(J(!0),oe(3)):K("stock_images"):x===C.lx.UPLOAD_IMAGE_MODAL_GIF||x===C.lx.UPLOAD_BACKGROUND_MODAL_GIF?he?(J(!0),oe(3)):K("gif"):x===C.lx.UPLOAD_IMAGE_MODAL_EDIT||x===C.lx.UPLOAD_BACKGROUND_MODAL_EDIT?(he?(J(!0),oe(5)):K("editor"),N((0,u.Wz)(C.lx.IMAGE_EDITOR_MODAL))):K("my_files")},[x,N,he,z]);const ce=!he&&!!j&&(x.includes("UPLOAD_IMAGE_")||x.includes("UPLOAD_BACKGROUND_"));(0,r.useEffect)(()=>{const e=document.querySelector("#carrotquest-messenger-collapsed-container");e&&(e.style.display=ce?"none":"")},[ce]);const ue=(0,r.useMemo)(()=>e?e.pathMode?new A(e,e.rootId,"Trash",e.trashPath,!0,b):null:(T(E("Error when initializing file manager")),null),[e,T,b]),ve=(0,r.useMemo)(()=>new L(null!==ue&&void 0!==ue?ue:e,q,{...e,trashPath:e.pathMode?"trash":e.trashPath,rootId:e.pathMode?"":e.rootId},b),[e,ue,q,b]),fe=(0,r.useCallback)(e=>{const t=(0,$.e0)(e,ve,ue);return O(t,!0)},[ve,ue,O]),pe=(0,w.ml)(_.AZ.FILE_PROXY_EVENT_ID),me=(0,Z.p)(),we=(0,o.Pj)(),ge=(0,r.useCallback)(async e=>{const t=await pe.fire({url:e,project:y});let i=await t.find(e=>e);if(!i)try{e=(0,$.i_)(e);const t=await fetch(e);i=await t.blob()}catch(r){return null}return i},[pe,y,me,we]),ye=r.createElement(d.A,{style:{fontSize:32,margin:-16},spin:!0}),Ie=(0,r.useCallback)(e=>{g.isEqual(e,ne)||le(e)},[ne]),[_e]=(0,h.Mv)(),Fe=(0,r.useCallback)(async()=>{if(ve){const e=ne[0];if(e){const t=e.url||e.thumbnailUrl||e.thumbnail;t&&k({url:t,file:e,meta:{mode:"select"}})}}de()},[ve,de,ne,k]),Ce=(0,r.useCallback)(async(e,t)=>{let i=e.url;!i&&ve&&(i=await ve.getFileUrl(e.folderId,e.name)),i&&("save"===(null===t||void 0===t?void 0:t.mode)&&ve.markNextFileBlobFetchBypassHttpCache(e.id),k({url:i,file:e,meta:t})),de()},[ve,de,k]),Pe=(0,r.useCallback)(async()=>{de()},[de]),[be,{data:Ae=[]}]=(0,h.gg)(),Ee=(null===s||void 0===s?void 0:s.handleLimitUsageEmitter)||(0,w.ml)(_.AZ.ON_LIMIT_ID),Me=(0,r.useCallback)(async function(e){try{await be(e).unwrap()}catch(t){}},[be]),Se=(0,r.useMemo)(()=>{const e=(null===s||void 0===s?void 0:s.icons)||{};if(e&&0!==Object.keys(e).length)return(0,$.Rt)(e)},[null===s||void 0===s?void 0:s.icons]),Te=(0,r.useCallback)(async(e,t={})=>await B(e,t),[B]),Oe=(0,w.ml)(_.AZ.PROXY_URL_EVENT_ID),Ne=(0,r.useCallback)(async e=>(await Oe.fire({url:e,project:y})).findLast(t=>t&&t!==e)||(0,$.W5)(e),[Oe,y]),De=(0,r.useMemo)(()=>{var e,t;const i=null===q||void 0===q?void 0:q.cacheStrategy;return null!==(e=null!==(t=null===i||void 0===i?void 0:i.errorTtl)&&void 0!==t?t:null===i||void 0===i?void 0:i.ttl)&&void 0!==e?e:S},[null===q||void 0===q?void 0:q.cacheStrategy]),Ue=(0,r.useMemo)(()=>({assetsUrl:(0,$.Zq)("",ie),compessorUrl:(0,$.Zq)("",re),compressMaxSize:null===q||void 0===q?void 0:q.compressMaxSize,compressMaxWidthOrHeight:null===q||void 0===q?void 0:q.compressMaxWidthOrHeight,onClose:de,handleProxyUrl:Ne,handleFileProxy:ge,expandRootFolderOnInit:!1!==(null===q||void 0===q?void 0:q.expandRootFolderOnInit),activeLibraryItem:j,REACT_APP_GIPHY_KEY:"Nh77eBlPeMn1ed9MBAvL542NUGeNO26F",UNSPLASH_KEY:"S5iNcLqYgRBIOLQdluHdTsCJnjCvahzhG7JfYQOrV7o",APP_NAME_UNSPLASH:"Nh77eBlPeMn1ed9MBAvL542NUGeNO26F",UNSLASH_PROXY_URL:"https://api.emailmaker.ru/services/agent",STREAMLINE_API_KEY:{}.REACT_APP_STREAMLINE_API_KEY,fileForEdit:ae,projectId:y,elementId:F||P,pushToGTM:null===s||void 0===s?void 0:s.pushToGTM,handleLimitUsageEmitter:Ee,sseQuery:Me,messages:Ae,sendAIImageRequest:(null===s||void 0===s?void 0:s.sendAIImageRequest)||_e,locale:U.locale.split("-")[0].split("_")[0],theme:U.theme,customTheme:M,enableTrashFolder:null===q||void 0===q?void 0:q.enableTrash,showNotifications:null===q||void 0===q?void 0:q.showNotifications,notificationDedupeTtlMs:De,previewFallbackToFileUrl:null===q||void 0===q?void 0:q.previewFallbackToFileUrl,dedupeUploadNamesOnClient:null===q||void 0===q?void 0:q.dedupeUploadNamesOnClient,saveCopyToCurrentFolder:null===q||void 0===q?void 0:q.saveCopyToCurrentFolder,handleTranslate:Te,features:{enableStockImages:!1!==s.imageCenterStockEnabled,enableGif:!1!==s.imageCenterGifEnabled,enableIconStock:!1!==s.imageCenterIconStockEnabled,enableRenameFile:!1!==(null===q||void 0===q?void 0:q.enableRenameFile),enableRenameFolder:!1!==(null===q||void 0===q?void 0:q.enableRenameFolder),enableUpdateFile:!1!==(null===q||void 0===q?void 0:q.enableUpdateFile),enableCopyItem:!1!==(null===q||void 0===q?void 0:q.enableCopyFile),enableCopyFolder:!1!==(null===q||void 0===q?void 0:q.enableCopyFolder),enableDelete:!1!==(null===q||void 0===q?void 0:q.enableDelete),enableEdit:!1!==(null===q||void 0===q?void 0:q.enableEdit),enableMoveItem:!1!==(null===q||void 0===q?void 0:q.enableMoveFile),enableMoveFolder:!1!==(null===q||void 0===q?void 0:q.enableMoveFolder)},disablePagination:!1===(null===q||void 0===q?void 0:q.enablePagination),multiSelect:!1!==(null===q||void 0===q?void 0:q.multiSelect),sortOptions:null===q||void 0===q?void 0:q.sortOptions,defaultFolderName:null===q||void 0===q?void 0:q.defaultFolderName,availableImageExtensions:null===q||void 0===q?void 0:q.availableImageExtensions}),[q,De,de,Ne,ge,j,ae,y,F,P,s,Ee,Me,Ae,_e,U.locale,U.theme,M,Te]);return z&&G&&ve?r.createElement(r.Fragment,null,!he&&r.createElement(n.A,{className:"file-manager",closable:!0,footer:null,open:ce,width:"100vw",onOk:Fe,onCancel:de},r.createElement(l.A,{spinning:!ve,indicator:ye},ve&&("editor"===j?r.createElement(ee,{onSave:Ce,onClose:Pe,compessorUrl:(0,$.Zq)("",re),compressMaxSize:null===q||void 0===q?void 0:q.compressMaxSize,compressMaxWidthOrHeight:null===q||void 0===q?void 0:q.compressMaxWidthOrHeight,dedupeUploadNamesOnClient:null===q||void 0===q?void 0:q.dedupeUploadNamesOnClient,saveCopyToCurrentFolder:null===q||void 0===q?void 0:q.saveCopyToCurrentFolder,dataProviders:ve,handleFileProxy:ge,theme:U.theme,file:ae,handleNotify:fe,assetsUrl:(0,$.Zq)("",ie),locale:U.locale.split("-")[0].split("_")[0]}):r.createElement(Q,{dataProviders:ve,onChangeSelection:Ie,onEditorOk:Ce,handleNotify:fe,customIcons:Se,config:Ue})))),r.createElement(f.A,{open:H,onCancel:()=>J(!1),initialSlide:W,sideOnOk:void 0})):null},ae=(0,r.memo)(oe)}}]);
|
|
2
|
-
//# sourceMappingURL=6310.
|
|
1
|
+
"use strict";(globalThis.webpackChunkemail_maker=globalThis.webpackChunkemail_maker||[]).push([[6310],{21816:(e,t,i)=>{i.r(t),i.d(t,{default:()=>ae});var r=i(1936),o=i(71715),a=i(84075),s=i(18021),n=i(51114),l=i(6691),d=i(86331),h=i(60034),c=i(98173),u=i(78443),v=i(22817),f=i(81644),p=i(942),m=i(6403),w=i(65185);let g;var y;(y=g||(g={})).isEqual=function(e,t,i=(e,t)=>e===t){if(e===t)return!0;const r=e.length;if(r!==t.length)return!1;for(let o=0;o<r;o++)if(!i(e[o],t[o]))return!1;return!0},y.unique=function(e,t){t||(t=e=>e);const i=new Set;return e.filter(e=>{const r=t(e),o=!i.has(r);return i.add(r),o})};var I=i(47706),_=i(65893),F=i(93628),C=i(93506),P=(i(80708),i(10968)),b=i(2783);class A{constructor(e,t="",i="Trash",r="Trash",o=!0,a=I.nr){this._inner=e,this.rootPath=t,this.trashId=i,this.trashPath=r,this.ensureFolderTrailingSlash=o,this.i18n=a,this._pathToId=new Map,this._idToPath=new Map,this.getUrl=void 0,this.getThumbnailUrl=void 0,this.validateDuplicates=void 0,this.validateDuplicates=this._inner.validateDuplicates,"function"===typeof e.getUrl&&(this.getUrl=t=>e.getUrl({...t,id:this.pathForId(t.id,!1),folderId:t.folderId?this.pathForId(t.folderId,!0):this.rootPath})),"function"===typeof e.getThumbnailUrl&&(this.getThumbnailUrl=t=>e.getThumbnailUrl({...t,id:this.pathForId(t.id,!1),folderId:t.folderId?this.pathForId(t.folderId,!0):this.rootPath})),"function"!==typeof this._inner.deleteItems&&(this.deleteItems=void 0),"function"!==typeof this._inner.deleteItem&&(this.deleteItem=void 0),"function"!==typeof this._inner.moveItems?this.moveItems=void 0:this.moveItem=void 0,"function"!==typeof this._inner.copyItems?this.copyItems=void 0:this.copyItem=void 0,"function"!==typeof this._inner.uploadFiles?this.uploadFiles=void 0:this.uploadFile=void 0,"function"!==typeof this._inner.clearCache&&(this.clearCache=void 0),this._getOrGenerateId(this.rootPath)}setController(e){"function"===typeof this._inner.setController&&this._inner.setController({invalidateItemCache:t=>{const i=t.replace(/^\/+|\/+$/g,""),r=this._pathToId.get(i);r&&e.invalidateItemCache(r)},getCachedItem:t=>{const i=t.replace(/^\/+|\/+$/g,""),r=this._pathToId.get(i);if(r){const t=e.getCachedItem(r);if(t)return{...t,id:this.pathForId(t.id,t.isFolder),folderId:this.pathForId(t.folderId,t.isFolder)}}}})}clearCache(e){if("function"===typeof this._inner.clearCache)return this._inner.clearCache(e)}_getOrGenerateId(e){if(e===this.rootPath)return;const t=e.replaceAll(/^\/+|\/+$/g,"");if(t===this.trashPath.replaceAll(/^\/+|\/+$/g,""))return this.trashId;if(this._pathToId.has(t))return this._pathToId.get(t);const i=(0,P.A)();return this._pathToId.set(t,i),this._idToPath.set(i,t),i}pathForId(e,t,i){const{__:r}=this.i18n;if(""===e||void 0===e)return this.rootPath;if(e===this.trashId)return this.trashPath;let o=this._idToPath.get(e);if(!o){if(i)return`unknown folder ${e}`;{const t=r?r(`Path for id '${e}' not found in mapping`):`Path for id '${e}' not found in mapping`;throw new b.FileManagerApiError(t,"FileNotFound")}}let a=0;for(;a<this.rootPath.length&&"/"===this.rootPath[a];)a++;if(a){let e=0;for(;e<o.length&&"/"===o[e];)e++;const t=o.slice(e);o="/".repeat(a)+t}return t&&this.ensureFolderTrailingSlash&&!o.endsWith("/")&&(o+="/"),o}_updateIdMapping(e,t){const i=t.replace(/^\/+|\/+$/g,""),r=this._idToPath.get(e);r&&this._pathToId.delete(r),this._idToPath.set(e,i),this._pathToId.set(i,e)}async getItems(e){const t=e.folderId?this.pathForId(e.folderId,!0):this.rootPath,i=await this._inner.getItems({...e,folderId:t}),r=i.items.map(e=>{const t=this._getOrGenerateId(e.id),i=e.folderId?this._getOrGenerateId(e.folderId):this._getOrGenerateId(this.rootPath);return{...e,id:t,folderId:i}});return{...i,items:r}}async createFolder(e,t,i){const r=t?this.pathForId(t,!0):this.rootPath,o=await this._inner.createFolder(e,r,i),a=this._getOrGenerateId(o.id),s=o.folderId?this._getOrGenerateId(o.folderId):this._getOrGenerateId(this.rootPath);return{...o,id:a,folderId:s}}async renameItem(e,t){const{__:i}=this.i18n;if("function"!==typeof this._inner.renameItem){const e=i?i("Rename item is not supported by inner storage"):"Rename item is not supported by inner storage";throw new b.FileManagerApiError(e,"RenameNotAllowed")}const r=this.pathForId(e.id,e.isFolder),o=r;let{...a}=await this._inner.renameItem({...e,id:r,folderId:this.pathForId(e.folderId,!0)},t);return this._updateIdMapping(e.id,a.id),e.isFolder&&this.remapCachedFolderContents(e.id,o,a.id),a.folderId&&(a={...a,folderId:this._getOrGenerateId(a.folderId)}),{...a,id:this._getOrGenerateId(a.id)}}async deleteItem(e,t){const{__:i}=this.i18n;if("function"!==typeof this._inner.deleteItem){const e=i?i("Delete item is not supported by inner storage"):"Delete item is not supported by inner storage";throw new b.FileManagerApiError(e,"DeleteNotAllowed")}const r=this.pathForId(e.id,e.isFolder);await this._inner.deleteItem({...e,id:r,folderId:this.pathForId(e.folderId,!0)},t),this.recursivelyRemoveMappings(e.id,r)}async uploadFile(e){const{__:t}=this.i18n;if("function"!==typeof this._inner.uploadFile){const e=t?t("Upload file is not supported by inner storage"):"Upload file is not supported by inner storage";throw new b.FileManagerApiError(e,"UnsupportedOperation")}const i=e.folderId?this.pathForId(e.folderId,!0):this.rootPath,r=await this._inner.uploadFile({...e,folderId:i}),o=this._getOrGenerateId(r.id),a=r.folderId?this._getOrGenerateId(r.folderId):this._getOrGenerateId(this.rootPath);return{...r,id:o,folderId:a}}async uploadFiles(e){var t,i,r,o,a;const s=e.folderId,n=null!==(t=null===(i=e.items)||void 0===i?void 0:i.map(e=>e.folderId))&&void 0!==t?t:[],l=e.folderId?this.pathForId(e.folderId,!0):this.rootPath,d={...e,folderId:l,items:null!==(r=null===(o=e.items)||void 0===o?void 0:o.map(e=>({...e,folderId:e.folderId?this.pathForId(e.folderId,!0):l})))&&void 0!==r?r:[]},h=await this._inner.uploadFiles(d);return{...h,detailed:null===(a=h.detailed)||void 0===a?void 0:a.map((e,t)=>{var i,r;if(null===e||void 0===e||!e.data)return e;const o=e.data.id?this._getOrGenerateId(e.data.id):void 0,a=e.data.folderId?this._getOrGenerateId(e.data.folderId):null!==(i=null!==(r=n[t])&&void 0!==r?r:s)&&void 0!==i?i:this._getOrGenerateId(this.rootPath);return{...e,data:{...e.data,id:o,folderId:a}}})}}async findFileByUrl(e,t){const i=t?this.pathForId(t,!0):this.rootPath;if("function"===typeof this._inner.findFileByUrl){const t=await this._inner.findFileByUrl(e,i);if(!t)return;const r=this._getOrGenerateId(t.id),o=t.folderId?this._getOrGenerateId(t.folderId):this._getOrGenerateId(this.rootPath);return{...t,id:r,folderId:o}}}async uploadFileByUrl(e,t,i){const r=t?this.pathForId(t,!0):this.rootPath,o=await this._inner.uploadFileByUrl(e,r,i),a=this._getOrGenerateId(o.id),s=o.folderId?this._getOrGenerateId(o.folderId):this._getOrGenerateId(this.rootPath);return{...o,id:a,folderId:s}}async moveItem(e,t){const{__:i}=this.i18n;if("function"!==typeof this._inner.moveItem){const e=i?i("Move item is not supported by inner storage"):"Move item is not supported by inner storage";throw new b.FileManagerApiError(e,"MoveNotAllowed")}const r=this.pathForId(e.id,e.isFolder),o=this.pathForId(t,!0),a=await this._inner.moveItem({...e,id:r,folderId:this.pathForId(e.folderId,!0)},o);this._updateIdMapping(e.id,a.id),e.isFolder&&this.remapCachedFolderContents(e.id,r,a.id);const s=this._getOrGenerateId(a.id),n=a.folderId?this._getOrGenerateId(a.folderId):t;return{...a,id:s,folderId:n}}async moveItems(e,t){const{__:i}=this.i18n;if("function"!==typeof this._inner.moveItems){const e=i?i("Move items is not supported by inner storage"):"Move items is not supported by inner storage";throw new b.FileManagerApiError(e,"MoveNotAllowed")}const r=t?this.pathForId(t,!0):this.rootPath,o=e.map(e=>({...e,id:this.pathForId(e.id,e.isFolder),folderId:e.folderId?this.pathForId(e.folderId,!0):this.rootPath})),a=await this._inner.moveItems(o,r),s=[];if(a.detailed&&a.detailed.length>0){const r=new Map;for(let t=0;t<a.detailed.length;t++){const i=a.detailed[t],o=i.requestId||(t<e.length?e[t].id:void 0);o&&r.set(o,i)}for(const o of e){const n=r.get(o.id)||(a.detailed.length===e.length?a.detailed[e.indexOf(o)]:void 0);if(null!==n&&void 0!==n&&n.success&&n.data){if(this._updateIdMapping(o.id,n.data.id),o.isFolder){const e=this.pathForId(o.id,o.isFolder);this.remapCachedFolderContents(o.id,e,n.data.id)}s.push({requestId:o.id,success:!0,data:{...n.data,id:this._getOrGenerateId(n.data.id),folderId:n.data.folderId?this._getOrGenerateId(n.data.folderId):t||this._getOrGenerateId(this.rootPath)}})}else{const e=i?i("Move operation failed - no detailed result"):"Move operation failed - no detailed result";s.push({requestId:o.id,success:!1,error:(null===n||void 0===n?void 0:n.error)||{message:e,code:"MoveNotAllowed"}})}}}else for(const n of e){const e=i?i("Move operation failed - no detailed results"):"Move operation failed - no detailed results";s.push({requestId:n.id,success:!1,error:{message:e,code:"MoveNotAllowed"}})}return{success:a.success,detailed:s,error:a.error}}async copyItems(e,t){const{__:i}=this.i18n;if("function"!==typeof this._inner.copyItems){const e=i?i("Copy items is not supported by inner storage"):"Copy items is not supported by inner storage";throw new b.FileManagerApiError(e,"CopyNotAllowed")}const r=t?this.pathForId(t,!0):this.rootPath,o=e.map(e=>({...e,id:this.pathForId(e.id,e.isFolder),folderId:e.folderId?this.pathForId(e.folderId,!0):this.rootPath})),a=await this._inner.copyItems(o,r),s=[];if(a.detailed&&a.detailed.length>0){const r=new Map;for(let t=0;t<a.detailed.length;t++){const i=a.detailed[t],o=i.requestId||(t<e.length?e[t].id:void 0);o&&r.set(o,i)}for(const o of e){var n;const l=r.get(o.id)||(a.detailed.length===e.length?a.detailed[e.indexOf(o)]:void 0);if(null!==l&&void 0!==l&&l.success&&null!==(n=l.data)&&void 0!==n&&n.id){const e=this._getOrGenerateId(l.data.id);s.push({requestId:o.id,success:!0,data:{...l.data,id:e,folderId:l.data.folderId?this._getOrGenerateId(l.data.folderId):t||this._getOrGenerateId(this.rootPath)}})}else{const e=l?l.success?l.data?l.data.id?{message:i?i("Unknown copy error"):"Unknown copy error",code:"CopyNotAllowed"}:{message:i?i("No ID in copied item data"):"No ID in copied item data",code:"CopyNotAllowed"}:{message:i?i("No data returned from copy operation"):"No data returned from copy operation",code:"CopyNotAllowed"}:l.error||{message:i?i("Copy operation failed"):"Copy operation failed",code:"CopyNotAllowed"}:{message:i?i("No detailed result from copy operation"):"No detailed result from copy operation",code:"CopyNotAllowed"};s.push({requestId:o.id,success:!1,error:e})}}}else for(const h of e){const e=i?i("No detailed results from copy operation"):"No detailed results from copy operation";s.push({requestId:h.id,success:!1,error:{message:e,code:"CopyNotAllowed"}})}const l=s.every(e=>e.success),d=i?i("Copy operation completed with errors"):"Copy operation completed with errors";return{success:l,detailed:s,error:l?void 0:a.error||{message:d,code:"CopyNotAllowed"}}}async deleteItems(e,t){const{__:i}=this.i18n;if("function"!==typeof this._inner.deleteItems){const e=i?i("Delete items is not supported by inner storage"):"Delete items is not supported by inner storage";throw new b.FileManagerApiError(e,"DeleteNotAllowed")}const r=e.map(e=>({...e,id:this.pathForId(e.id,e.isFolder),folderId:e.folderId?this.pathForId(e.folderId,!0):this.rootPath})),o=await this._inner.deleteItems(r,t),a=[];if(o.detailed&&o.detailed.length>0){const r=new Map;for(let t=0;t<o.detailed.length;t++){const i=o.detailed[t],a=i.requestId||(t<e.length?e[t].id:void 0);a&&r.set(a,i)}for(const s of e){const n=r.get(s.id)||(o.detailed.length===e.length?o.detailed[e.indexOf(s)]:void 0);if(null!==n&&void 0!==n&&n.success){const e=this.pathForId(s.id,s.isFolder);if(t.permanent)this.recursivelyRemoveMappings(s.id,e);else if(this._updateIdMapping(s.id,this.trashPath+"/"+e+(s.isFolder?"/":"")),s.isFolder){const t=this.pathForId(s.id,s.isFolder);this.remapCachedFolderContents(s.id,t,this.trashPath+"/"+e+(s.isFolder?"/":""))}a.push({requestId:s.id,success:!0})}else{const e=i?i("Delete operation failed"):"Delete operation failed";a.push({requestId:s.id,success:!1,error:(null===n||void 0===n?void 0:n.error)||{message:e,code:"DeleteNotAllowed"}})}}}else for(const l of e)if(o.success){const e=this.pathForId(l.id,l.isFolder);if(t.permanent)this.recursivelyRemoveMappings(l.id,e);else if(this._updateIdMapping(l.id,this.trashPath+"/"+e+(l.isFolder?"/":"")),l.isFolder){const t=this.pathForId(l.id,l.isFolder);this.remapCachedFolderContents(l.id,t,this.trashPath+"/"+e+(l.isFolder?"/":""))}a.push({requestId:l.id,success:!0})}else{const e=i?i("Delete operation failed"):"Delete operation failed";a.push({requestId:l.id,success:!1,error:o.error||{message:e,code:"DeleteNotAllowed"}})}const s=a.every(e=>e.success),n=i?i("Some items failed to delete"):"Some items failed to delete";return{success:s,detailed:a,error:s?void 0:o.error||{message:n,code:"DeleteNotAllowed"}}}remapCachedFolderContents(e,t,i){const r=t.replace(/\/+$/,""),o=i.replace(/\/+$/,""),a=[];for(const[s,n]of this._idToPath.entries()){const e=n.replace(/\/+$/,"");e!==r&&e.startsWith(r+"/")&&a.push({id:s,oldPath:e})}for(const{id:s,oldPath:n}of a){const e=o+n.substring(r.length);this._updateIdMapping(s,e)}}recursivelyRemoveMappings(e,t){const i=t.replace(/\/+$/,""),r=[],o=[];for(const[a,s]of this._idToPath.entries()){const e=s.replace(/\/+$/,"");(e===i||e.startsWith(i+"/"))&&(r.push(a),o.push(e))}for(let a=0;a<r.length;a++)this._idToPath.delete(r[a]),this._pathToId.delete(o[a])}async copyItem(e,t){const{__:i}=this.i18n;if("function"!==typeof this._inner.copyItem){const e=i?i("Copy item is not supported by inner storage"):"Copy item is not supported by inner storage";throw new b.FileManagerApiError(e,"CopyNotAllowed")}const r=this.pathForId(e.id,e.isFolder),o=this.pathForId(t,!0),a=await this._inner.copyItem({...e,id:r,folderId:this.pathForId(e.folderId,!0)},o),s=this._getOrGenerateId(a.id),n=a.folderId?this._getOrGenerateId(a.folderId):t;return{...a,id:s,folderId:n}}async updateFile(e,t){const{__:i}=this.i18n;if("function"!==typeof this._inner.updateFile){const e=i?i("Update file is not supported by inner storage"):"Update file is not supported by inner storage";throw new b.FileManagerApiError(e,"UnsupportedOperation")}const r=this.pathForId(e.id,!1);let{...o}=await this._inner.updateFile({...e,id:r,folderId:this.pathForId(e.folderId,!0)},t);return this._updateIdMapping(e.id,o.id),o.folderId&&(o={...o,folderId:this._getOrGenerateId(o.folderId)}),{...o,id:this._getOrGenerateId(o.id)}}async getFileData(e,t){const{__:i}=this.i18n,r=this.pathForId(e.id,!1);if("function"===typeof this._inner.getFileData)return this._inner.getFileData({...e,id:r,folderId:this.pathForId(e.folderId,!0)},t);const o=e.url||("function"===typeof this.getUrl?await this.getUrl(e):void 0);if(!o){const e=i?i("Cannot get file data: no url and no inner.getFileData"):"Cannot get file data: no url and no inner.getFileData";throw new b.FileManagerApiError(e,"FileReadError")}return fetch(o,null!==t&&void 0!==t&&t.forceReload?{cache:"no-store"}:void 0).then(e=>e.blob())}async cleanTrash(){const{__:e}=this.i18n;if("function"!==typeof this._inner.cleanTrash){const t=e?e("Clean trash is not supported by inner storage"):"Clean trash is not supported by inner storage";throw new b.FileManagerApiError(t,"UnsupportedOperation")}return await this._inner.cleanTrash()}}const E="\x1e";class M{constructor(){this.map=new Map}static childrenViewKey(e,t){return`v${E}${e}${E}${t}`}static childrenCountKey(e){return`c${E}${e}`}getFreshError(e,t){const i=this.map.get(e);return i?t!==1/0&&Date.now()-i.updatedAt>t?(this.map.delete(e),null):i.error:null}setError(e,t){this.map.set(e,{error:t,updatedAt:Date.now()})}delete(e){this.map.delete(e)}clearChildrenViewErrorsForParent(e){const t=`v${E}${e}${E}`;for(const i of[...this.map.keys()])i.startsWith(t)&&this.map.delete(i)}clearAll(){this.map.clear()}}const S=18e5;function T(e){return null==e||""===e?"":e}function O(e){if(null==e)return 1/0;const t=Number(e);return Number.isFinite(t)&&t>=0?t:1/0}function N(e){if(!e)return null;const t=e.folderId;return null==t?null:String(t)}function D(e){return!!e&&e.isFolder}function U(){var e;if("function"===typeof(null===globalThis||void 0===globalThis||null===(e=globalThis.crypto)||void 0===e?void 0:e.randomUUID))return globalThis.crypto.randomUUID();try{const e=globalThis.crypto||globalThis.msCrypto;if(e&&"function"===typeof e.getRandomValues){const t=new Uint8Array(16);e.getRandomValues(t);let i="";for(let e=0;e<t.length;e++)i+=t[e].toString(16).padStart(2,"0");return`id_${i}`}}catch{}return`id_fallback_${Date.now().toString(36)}_${Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(36).slice(0,8)}`}function x(e){if(!e||"object"!==typeof e)return String(null!==e&&void 0!==e?e:"");const t=e,i=[],r={},o=["page","pageSize","sortBy","sortOrder","search","itemType","limit"];for(const l of Object.keys(t).sort()){const e=t[l];o.includes(l)?i.push(`${l}=${String(null!==e&&void 0!==e?e:"")}`):r[l]=e}const a=Object.keys(r).length?JSON.stringify(r):"",s=i.join("|"),n=a?function(e){let t=2166136261;for(let i=0;i<e.length;i++)t^=e.charCodeAt(i),t=t+((t<<1)+(t<<4)+(t<<7)+(t<<8)+(t<<24))>>>0;return t.toString(36)}(a):"";return`${s}${n?`|${n}`:""}`}class R{constructor(){this.entities=new Map,this.childrenByParent=new Map,this.maxCacheSize=1e4}now(){return Date.now()}checkCacheSize(){if(this.entities.size>this.maxCacheSize){const e=Array.from(this.entities.entries()).sort((e,t)=>e[1].updatedAt-t[1].updatedAt),t=Math.floor(.1*this.maxCacheSize);for(let i=0;i<t&&i<e.length;i++){const[t,r]=e[i];this.deleteEntityById(t)}}}getEntity(e){var t;return null===(t=this.entities.get(e))||void 0===t?void 0:t.value}getRecord(e){return this.entities.get(e)}getFileSystemItem(e){const t=this.getEntity(e);return t&&!D(t)?t:void 0}getFolder(e){const t=this.getEntity(e);return t&&D(t)?t:void 0}getChildrenIds(e,t={}){const i=T(e),r=this.childrenByParent.get(i);return r?t.onlyFileSystemItems?Array.from(r.files):t.onlyFolders?Array.from(r.folders):[...Array.from(r.folders),...Array.from(r.files)]:[]}searchByUrl(e){for(const t of this.entities.values())if(t.value.url===e)return t.value;return null}upsertEntity(e){var t;const i=null!==(t=this.entities.get(e.id))&&void 0!==t?t:null,r=i?i.value:null,o=r?N(r):null,a=N(e),s=!!r&&D(r),n=D(e);let l;if(r&&D(r)&&n){const t=r.childrenCount,i=e.childrenCount;void 0!==t&&void 0===i&&(l=t)}if(r&&(o!==a||s!==n)){const t=T(o),i=this.childrenByParent.get(t);i&&(s?i.folders.delete(e.id):i.files.delete(e.id),0===i.files.size&&0===i.folders.size&&this.childrenByParent.delete(t))}let d=e;void 0!==l&&(d={...e,childrenCount:l}),this.entities.set(e.id,{value:{...d},updatedAt:this.now()}),this.checkCacheSize();const h=T(a);let c=this.childrenByParent.get(h);c||(c={files:new Set,folders:new Set},this.childrenByParent.set(h,c)),n?c.folders.add(e.id):c.files.add(e.id)}updateServerChildrenCount(e,t){if(null==e||null==t||Number.isNaN(t))return;const i=this.entities.get(e);if(!i||!D(i.value))return;const r={...i.value,childrenCount:t};this.entities.set(e,{value:r,updatedAt:this.now()})}deleteEntityById(e){var t;const i=null!==(t=this.entities.get(e))&&void 0!==t?t:null;if(!i)return{entity:null,parentId:null};const r=i.value,o=N(r),a=T(o),s=this.childrenByParent.get(a);return s&&(D(r)?s.folders.delete(e):s.files.delete(e),0===s.files.size&&0===s.folders.size&&this.childrenByParent.delete(a)),this.entities.delete(e),{entity:{...r},parentId:o}}deleteFolderRecursive(e){const t=this.entities.get(e);if(!t||!D(t.value))return{deletedFolderRecords:[],deletedFileSystemItemRecords:[]};const i=[{id:e,parentId:N(t.value)}],r=[],o=[];for(;i.length;){const e=i.shift();r.push(e);const t=this.childrenByParent.get(T(e.id));if(t){for(const e of Array.from(t.folders)){const t=this.entities.get(e);t&&i.push({id:e,parentId:N(t.value)})}for(const e of Array.from(t.files))o.push(e)}}const a=[];for(const n of o){const e=this.entities.get(n);if(!e)continue;const t=e.value,i=T(N(t)),r=this.childrenByParent.get(i);r&&(r.files.delete(n),0===r.files.size&&0===r.folders.size&&this.childrenByParent.delete(i)),this.entities.delete(n),a.push({...t})}const s=[];for(let n=r.length-1;n>=0;n--){const{id:e,parentId:t}=r[n],i=this.entities.get(e);if(!i)continue;const o=i.value,a=T(o.id);this.childrenByParent.delete(a);const l=T(t),d=this.childrenByParent.get(l);d&&(d.folders.delete(e),0===d.files.size&&0===d.folders.size&&this.childrenByParent.delete(l)),this.entities.delete(e),s.push({...o})}return{deletedFolderRecords:s,deletedFileSystemItemRecords:a}}moveEntityById(e,t){var i;const r=null!==(i=this.entities.get(e))&&void 0!==i?i:null;if(!r)return null;const o=r.value,a=T(N(o)),s=this.childrenByParent.get(a);s&&(D(o)?s.folders.delete(e):s.files.delete(e),0===s.files.size&&0===s.folders.size&&this.childrenByParent.delete(a));const n={...o,folderId:t};if(D(o)&&D(n)){const e=o.childrenCount;void 0!==e&&(n.childrenCount=e)}this.entities.set(e,{value:n,updatedAt:this.now()});const l=T(t);let d=this.childrenByParent.get(l);return d||(d={files:new Set,folders:new Set},this.childrenByParent.set(l,d)),D(n)?d.folders.add(e):d.files.add(e),{...n}}copyFileSystemItem(e,t,i){var r;const o=null!==(r=this.entities.get(e))&&void 0!==r?r:null;if(!o||D(o.value))return null;const a={...o.value,id:t,folderId:i};return this.upsertEntity(a),{...a}}copyFolderShallow(e,t,i){var r;const o=null!==(r=this.entities.get(e))&&void 0!==r?r:null;if(!o||!D(o.value))return null;const a={...o.value,id:t,folderId:i};return this.upsertEntity(a),{...a}}isEntityStale(e,t){var i;const r=null!==(i=this.entities.get(e))&&void 0!==i?i:null;return!r||t!==1/0&&this.now()-r.updatedAt>t}touch(e,t){const i=this.entities.get(e);i&&(i.updatedAt=null!==t&&void 0!==t?t:this.now())}getEntitiesByIds(e){return e.map(e=>{var t,i;return null!==(t=null===(i=this.entities.get(e))||void 0===i?void 0:i.value)&&void 0!==t?t:null})}searchByName(e,t){var i,r,o,a;if(!e||""===e.trim())return[];const s=null===t||void 0===t?void 0:t.parentId,n=null!==(i=null===t||void 0===t?void 0:t.recursive)&&void 0!==i&&i,l=null!==(r=null===t||void 0===t?void 0:t.itemType)&&void 0!==r?r:"all",d=null!==(o=null===t||void 0===t?void 0:t.caseSensitive)&&void 0!==o&&o,h=null!==(a=null===t||void 0===t?void 0:t.limit)&&void 0!==a?a:1/0,c=d?e.trim():e.trim().toLowerCase(),u=[];let v=null;if(void 0!==s){v=new Set;const e=T(s);if(v.add(e),n){const t=[e],i=new Set;for(;t.length>0;){const e=t.shift();if(i.has(e))continue;i.add(e);const r=this.childrenByParent.get(e);if(r)for(const i of r.folders)v.add(i),t.push(i)}}}for(const[,p]of this.entities){var f;if(u.length>=h)break;const e=p.value;if(null!==v){const t=T(N(e));if(!v.has(t))continue}if("file"===l&&D(e))continue;if("folder"===l&&!D(e))continue;const t=null!==(f=e.name)&&void 0!==f?f:"";(d?t:t.toLowerCase()).includes(c)&&u.push({...e})}return u}toJSON(){return{entities:Array.from(this.entities.entries()),childrenByParent:Array.from(this.childrenByParent.entries()).map(([e,t])=>[e,{files:Array.from(t.files),folders:Array.from(t.folders)}])}}static fromJSON(e){const t=new R;for(const[o,a]of null!==(i=e.entities)&&void 0!==i?i:[]){var i;t.entities.set(o,{value:a.value,updatedAt:a.updatedAt})}for(const[o,a]of null!==(r=e.childrenByParent)&&void 0!==r?r:[]){var r;t.childrenByParent.set(o,{files:new Set(a.files),folders:new Set(a.folders)})}return t}}class B{constructor(e={},t=18e5,i,r,o=new M){var a,s,n,l,d;this.views=new Map,this.strategy=void 0,this.ttl=void 0,this.errorTtl=void 0,this.entityTtl=void 0,this.failedRequests=void 0,this.serverChildrenCountHandler=void 0,this.childrenCountInvalidator=void 0,this.maxViewsPerParent=50,this.strategy={allowSortedInsert:null===(a=e.allowSortedInsert)||void 0===a||a,allowSearchInsert:null===(s=e.allowSearchInsert)||void 0===s||s,invalidateOnPaginationFull:null===(n=e.invalidateOnPaginationFull)||void 0===n||n,preloadPagesBefore:null!==(l=e.preloadPagesBefore)&&void 0!==l?l:0,preloadPagesAfter:null!==(d=e.preloadPagesAfter)&&void 0!==d?d:1,comparator:e.comparator,filterMatch:e.filterMatch},this.ttl=t,this.errorTtl=null!==i&&void 0!==i?i:t,this.entityTtl=null!==r&&void 0!==r?r:t,this.failedRequests=o}setServerChildrenCountHandler(e){this.serverChildrenCountHandler=e}setChildrenCountInvalidator(e){this.childrenCountInvalidator=e}now(){return Date.now()}parentKey(e){return T(null!==e&&void 0!==e?e:null)}isExpired(e){return null==e||this.ttl!==1/0&&this.now()-e>this.ttl}areEntitiesStale(e,t){return!e||e.some(e=>!t.getEntity(e)||t.isEntityStale(e,this.entityTtl))}isEntityTypeCompatible(e,t){return!t||"all"===t||("file"===t&&!D(e)||!("folder"!==t||!D(e)))}cleanupOldViews(e){if(e.size<=this.maxViewsPerParent)return;const t=Array.from(e.entries()).sort((e,t)=>(t[1].view.updatedAt||0)-(e[1].view.updatedAt||0));for(;e.size>this.maxViewsPerParent&&t.length>0;){const[i]=t.pop();e.delete(i)}}async getOrCreateChildren(e,t,i,r){var o;const a=this.parentKey(e),s=x(null!==t&&void 0!==t?t:{});let n=this.views.get(a);n||(n=new Map,this.views.set(a,n));const l=M.childrenViewKey(a,s);let d=n.get(s);if(!d){d={params:t,view:{promise:null,value:void 0,meta:void 0,updatedAt:0,loadId:null}},n.set(s,d),this.cleanupOldViews(n)}const h=this.failedRequests.getFreshError(l,this.errorTtl);if(null!=h)throw h;if(d.view.value&&!this.isExpired(d.view.updatedAt)&&!this.areEntitiesStale(d.view.value,r)&&(null===(o=d.view.meta)||void 0===o||!o.stale)){var c,u;const e=d.view.value.map(e=>r.getEntity(e)).filter(Boolean),t=(null===(c=d.params)||void 0===c?void 0:c.itemType)||"all";return{items:e.filter(e=>this.isEntityTypeCompatible(e,t)),...null!==(u=d.view.meta)&&void 0!==u?u:{}}}if(d.view.promise)return d.view.promise;const v=U();d.view.loadId=v;const f=(async()=>{try{var o,s,n;const c=await i(e,t),u=function(e){return!!e&&"string"===typeof e.search&&e.search.trim().length>0}(t),f=u?{...c,total:void 0}:c,p=null===(o=this.views.get(a))||void 0===o?void 0:o.get(x(t));if(!p||p.view.loadId!==v){const e=new Error("StaleLoad");throw e.name="StaleLoad",e}for(const e of f.items)r.upsertEntity(e);d.view.value=f.items.map(e=>e.id);const{items:m,...w}=f,g={...w};d.view.meta=g,d.view.meta.stale=!1,this.failedRequests.delete(l),d.view.updatedAt=this.now(),u||"number"!==typeof g.total||(this.serverChildrenCountHandler?this.serverChildrenCountHandler(null!==e&&void 0!==e?e:null,g.total,r):r.updateServerChildrenCount(e,g.total));const y=null!==(s=this.strategy.preloadPagesAfter)&&void 0!==s?s:0,I=null!==(n=this.strategy.preloadPagesBefore)&&void 0!==n?n:0,_=O(null===t||void 0===t?void 0:t.pageSize),F=Number.isFinite(_);if((y>0||I>0)&&F){var h;const o=e,a={...t},s="number"===typeof g.totalPages?g.totalPages:1,n=null!==(h=null===t||void 0===t?void 0:t.page)&&void 0!==h?h:1,l=_,d=i,c=v;setTimeout(()=>{this.preloadPagesAsync(o,a,n,s,l,y,I,r,g,d,c)},0)}return f}catch(m){var c,u,f,p;if("StaleLoad"===(null===m||void 0===m?void 0:m.name))throw this.failedRequests.delete(l),d.view.value=void 0,d.view.updatedAt=this.now(),m;const e=m,t=null!==(c=null===e||void 0===e?void 0:e.status)&&void 0!==c?c:null===e||void 0===e||null===(u=e.data)||void 0===u?void 0:u.status,i=null!==(f=null===e||void 0===e?void 0:e.code)&&void 0!==f?f:null===e||void 0===e||null===(p=e.data)||void 0===p?void 0:p.code;if(404===t||"FileNotFound"===i||"FolderNotFound"===i||"path_folder_not_found"===i)return this.failedRequests.delete(l),d.view.value=[],d.view.meta={total:0,totalPages:0},d.view.updatedAt=this.now(),{items:[],total:0,totalPages:0};throw this.failedRequests.setError(l,m),d.view.value=void 0,d.view.updatedAt=this.now(),m}finally{d.view.promise=null}})();return d.view.promise=f,f}async preloadPagesAsync(e,t,i,r,o,a,s,n,l,d,h){try{const o=this.parentKey(e),l=this.views.get(o);if(!l)return;const c=l.get(x(t));if(!c)return;if(null!=h&&c.view.loadId!==h)return;const u=l.get(x(t));if(null===u||void 0===u||!u.view.meta)return;const v="number"===typeof u.view.meta.totalPages?u.view.meta.totalPages:1;if(v!==r)return;const f=async i=>{const r={...t,page:i};try{const a=await d(e,r),s=this.views.get(o);if(!s)return;const l=s.get(x(t));if(!l)return;if(null!=h&&l.view.loadId!==h)return;if(l.view.loadId!==h)return;for(const e of a.items)n.upsertEntity(e);const c=x(r);let u=s.get(c);if(!u){u={params:r,view:{promise:null,value:void 0,meta:void 0,updatedAt:0,loadId:l.view.loadId}},s.set(c,u),this.cleanupOldViews(s)}if(!u.view.value||this.isExpired(u.view.updatedAt)){u.view.value=a.items.map(e=>e.id);const{items:e,...t}=a;u.view.meta={...t,page:i,totalPages:v},u.view.updatedAt=this.now()}}catch(a){}};if(a>0&&i<v)for(let e=1;e<=Math.min(a,v-i);e++){const r=i+e,o=x({...t,page:r}),a=l.get(o);null!==a&&void 0!==a&&a.view.value&&!this.isExpired(a.view.updatedAt)||f(r)}if(s>0&&i>1)for(let e=1;e<=Math.min(s,i-1);e++){const r=i-e,o=x({...t,page:r}),a=l.get(o);null!==a&&void 0!==a&&a.view.value&&!this.isExpired(a.view.updatedAt)||f(r)}}catch(c){}}removeEmptyPageIfNeeded(e,t,i,r,o){if(t.view.value&&0===t.view.value.length&&i<r){const t=x({...o,page:i});e.delete(t)}}updateTotalPagesForAllViews(e,t){for(const[,i]of e)i.view.meta&&(i.view.meta.totalPages=t)}isParamsSame(e,t){const i=Object.keys(null!==e&&void 0!==e?e:{}).filter(e=>"page"!==e).sort(),r=Object.keys(null!==t&&void 0!==t?t:{}).filter(e=>"page"!==e).sort();if(i.length!==r.length)return!1;for(let o=0;o<i.length;o++){const a=i[o];if(a!==r[o])return!1;if(e[a]!==t[a])return!1}return!0}syncTotalsInSameViews(e,t){var i;const r=t.view.meta;if(!r||"number"!==typeof r.total)return;const o=Number(r.total),a=O(null===(i=t.params)||void 0===i?void 0:i.pageSize),s=Number.isFinite(a)&&a>0?Math.max(1,Math.ceil(o/a)):void 0;for(const[,d]of e){var n,l;this.isParamsSame(null!==(n=d.params)&&void 0!==n?n:{},null!==(l=t.params)&&void 0!==l?l:{})&&(d.view.meta||(d.view.meta={}),d.view.meta.total=o,void 0!==s&&(d.view.meta.totalPages=s))}}canSafelyModifySortedView(e){return!e.sortBy&&!e.sortOrder||!!this.strategy.comparator}cascadeShiftPages(e,t,i,r,o,a,s){let n=t,l=i,d=!1;let h=0;for(;n.view.value&&n.view.value.length<r&&l<o&&h<100;){h++;const t=x({...s,page:l+1}),i=e.get(t);if(null===i||void 0===i||!i.view.value||this.isExpired(i.view.updatedAt)){var c;n.view.meta={...null!==(c=n.view.meta)&&void 0!==c?c:{},stale:!0};break}const o=r-n.view.value.length,v=i.view.value.slice(0,o).filter(e=>a.getEntity(e));if(0===v.length){var u;n.view.meta={...null!==(u=n.view.meta)&&void 0!==u?u:{},stale:!0};break}if(n.view.value=[...n.view.value,...v],n.view.updatedAt=Date.now(),i.view.value=i.view.value.slice(v.length),i.view.updatedAt=Date.now(),0===i.view.value.length){const t=l+1,r=i.view.meta;if(t<(r&&"number"===typeof r.totalPages?r.totalPages:1)){const i=x({...s,page:t});e.delete(i),d=!0}break}n=i,l++}var v;(!n.view.value||n.view.value.length<r)&&l>=o&&(n.view.meta={...null!==(v=n.view.meta)&&void 0!==v?v:{},stale:!0});return d}cascadeShiftToNextPage(e,t,i,r,o,a,s){var n,l;if(!t.view.value||t.view.value.length<=r)return!1;var d;if(i-(s.page||1)>=10)return t.view.meta={...null!==(d=t.view.meta)&&void 0!==d?d:{},stale:!0},!1;const h={...s,page:i+1},c=x(h);let u=e.get(c),v=!1;if(null===(n=u)||void 0===n||!n.view.value||this.isExpired(u.view.updatedAt)){var f;if(!(i>=o))return t.view.meta={...null!==(f=t.view.meta)&&void 0!==f?f:{},stale:!0},!1;{u={params:h,view:{promise:null,value:void 0,meta:void 0,updatedAt:0,loadId:null}},e.set(c,u),this.cleanupOldViews(e);const r=t.view.meta;r&&(u.view.meta={...r,page:i+1}),v=!0}}const p=t.view.value.slice(r).filter(e=>a.getEntity(e));if(0===p.length)return v&&e.delete(c),!1;t.view.value=t.view.value.slice(0,r),t.view.updatedAt=Date.now(),u.view.value=[...p,...null!==(l=u.view.value)&&void 0!==l?l:[]],u.view.updatedAt=Date.now();const m=u.view.meta&&"number"===typeof u.view.meta.totalPages?u.view.meta.totalPages:o;if(!v){if(this.cascadeShiftToNextPage(e,u,i+1,r,m,a,s))return!0}if(!u.view.value||0===u.view.value.length){const t=i+1,r=u.view.meta,o=r&&"number"===typeof r.totalPages?r.totalPages:1;this.removeEmptyPageIfNeeded(e,u,t,o,s)}return v}tryInsertSorted(e,t,i){var r;const o=this.strategy.comparator;if(!o)return!1;if(!e.view.value)return!1;const a=(null===(r=e.params)||void 0===r?void 0:r.itemType)||"all";if(!this.isEntityTypeCompatible(t,a))return!1;const s=e.view.value.map(e=>i.getEntity(e));if(s.some(e=>!e))return!1;let n=0,l=s.length;for(;n<l;){const i=Math.floor((n+l)/2),r=o(t,s[i],e.params);if("number"!==typeof r||Number.isNaN(r))return!1;r>=0?n=i+1:l=i}return e.view.value.includes(t.id)?(e.view.updatedAt=this.now(),!0):(e.view.value=[...e.view.value.slice(0,n),t.id,...e.view.value.slice(n)],e.view.updatedAt=this.now(),e.view.meta&&"number"===typeof e.view.meta.total&&(e.view.meta.total=Number(e.view.meta.total)+1),!0)}updateChildrenCountForOperation(e,t,i,r){var o,a,s,n;const l=N(t);switch(e){case"delete":this.adjustChildrenCount(r,l,-1),null===(o=this.childrenCountInvalidator)||void 0===o||o.call(this,l);break;case"insert":case"copy":this.adjustChildrenCount(r,l,1),null===(a=this.childrenCountInvalidator)||void 0===a||a.call(this,l);break;case"move":this.adjustChildrenCount(r,i,-1),this.adjustChildrenCount(r,l,1),null===(s=this.childrenCountInvalidator)||void 0===s||s.call(this,i),null===(n=this.childrenCountInvalidator)||void 0===n||n.call(this,l)}}adjustChildrenCount(e,t,i){if(!t)return;const r=e.getFolder(t);if(r&&"number"===typeof r.childrenCount){const o=Math.max(0,r.childrenCount+i);e.updateServerChildrenCount(t,o)}}smartInvalidateChildrenViews(e,t,i,r,o,a){if(!t)return;this.updateChildrenCountForOperation(i,t,o,r);const s=this.parentKey(e),n=this.views.get(s);if(n)for(const[,u]of n){var l,d;const e=null!==(l=u.params)&&void 0!==l?l:{},a=null!==(d=null===e||void 0===e?void 0:e.page)&&void 0!==d?d:1,s=O(null===e||void 0===e?void 0:e.pageSize),v=Number.isFinite(s),f=!!(null!==e&&void 0!==e&&e.sortBy||null!==e&&void 0!==e&&e.sortOrder),p=!(null===e||void 0===e||!e.search),m=(null===e||void 0===e?void 0:e.itemType)||"all";if(!this.isEntityTypeCompatible(t,m))continue;if(p&&this.strategy.filterMatch&&!this.strategy.filterMatch(t,u.params)){var h;null!==(h=u.view.value)&&void 0!==h&&h.includes(t.id)&&(u.view.value=u.view.value.filter(e=>e!==t.id),u.view.meta&&"number"===typeof u.view.meta.total&&(u.view.meta.total=Math.max(0,u.view.meta.total-1)),u.view.updatedAt=Date.now());continue}if(!u.view.value){u.view.meta&&(u.view.meta.stale=!0),u.view.loadId=U(),u.view.abortController&&(u.view.abortController.abort(),u.view.abortController=void 0);continue}u.view.value.includes(t.id);var c;if(this.shouldInvalidateCompletely(u,i,t,f,v,a))u.view.meta={...null!==(c=u.view.meta)&&void 0!==c?c:{},stale:!0},u.view.loadId=U(),u.view.abortController&&(u.view.abortController.abort(),u.view.abortController=void 0);else switch(i){case"delete":this.handleDelete(n,u,a,s,v,t,r);break;case"insert":case"copy":this.handleInsert(n,u,a,s,v,f,t,r);break;case"update":this.handleUpdate(n,u,a,s,v,f,p,t,r);break;case"move":this.handleMove(n,u,a,s,v,f,t,o,r)}}}shouldInvalidateCompletely(e,t,i,r,o,a){return!(!(o&&a>1)||"insert"!==t&&"delete"!==t&&"move"!==t)||(!(!r||this.strategy.comparator||"insert"!==t&&"move"!==t)||!!this.isExpired(e.view.updatedAt))}tryReinsertEntity(e,t,i,r,o){var a,s;const n=(null===(a=e.params)||void 0===a?void 0:a.itemType)||"all";if(!this.isEntityTypeCompatible(t,n))return!1;if(this.strategy.comparator&&this.strategy.filterMatch){if(!this.strategy.filterMatch(t,e.params))return!1;if(this.tryInsertSorted(e,t,i))return!0}const l=null!==(s=e.params)&&void 0!==s?s:{};return!(!(!l.sortBy&&!l.sortOrder)&&!this.canSafelyModifySortedView(l))&&((!r||e.view.value.length<o)&&(e.view.value.push(t.id),!0))}handleDelete(e,t,i,r,o,a,s){const n=t.view.value.includes(a.id);if(n&&(t.view.value=t.view.value.filter(e=>e!==a.id)),t.view.meta&&"number"===typeof t.view.meta.total){if(t.view.meta.total=Math.max(0,t.view.meta.total-1),o&&Number.isFinite(r)&&"number"===typeof t.view.meta.total){const e=r;e>0&&(t.view.meta.totalPages=Math.max(1,Math.ceil(t.view.meta.total/e)))}this.syncTotalsInSameViews(e,t)}if(t.view.updatedAt=Date.now(),n&&o&&t.view.value.length<r&&s){var l;const o=t.view.meta,a=o&&"number"===typeof o.totalPages?o.totalPages:1;if(this.cascadeShiftPages(e,t,i,r,a,s,null!==(l=t.params)&&void 0!==l?l:{})&&t.view.meta&&"number"===typeof t.view.meta.totalPages){const i=Math.max(1,t.view.meta.totalPages-1);t.view.meta.totalPages=i,this.updateTotalPagesForAllViews(e,i)}}t.view.loadId=U(),t.view.abortController&&(t.view.abortController.abort(),t.view.abortController=void 0)}handleInsert(e,t,i,r,o,a,s,n){if(!t.view.value.includes(s.id)){if(a&&this.strategy.allowSortedInsert&&this.strategy.comparator&&n){if(this.tryInsertSorted(t,s,n)&&t.view.meta&&"number"===typeof t.view.meta.total){if(t.view.meta.total+=1,o&&Number.isFinite(r)){const e=r;e>0&&(t.view.meta.totalPages=Math.max(1,Math.ceil(t.view.meta.total/e)))}this.syncTotalsInSameViews(e,t)}if(o&&t.view.value.length>r&&n){var l;const o=t.view.meta,a=o&&"number"===typeof o.totalPages?o.totalPages:1;if(this.cascadeShiftToNextPage(e,t,i,r,a,n,null!==(l=t.params)&&void 0!==l?l:{})&&t.view.meta&&"number"===typeof t.view.meta.totalPages){const i=t.view.meta.totalPages+1;t.view.meta.totalPages=i,this.updateTotalPagesForAllViews(e,i)}}}else if(!o||t.view.value.length<r){if(t.view.value.push(s.id),t.view.meta&&"number"===typeof t.view.meta.total){if(t.view.meta.total+=1,o&&Number.isFinite(r)){const e=r;e>0&&(t.view.meta.totalPages=Math.max(1,Math.ceil(t.view.meta.total/e)))}this.syncTotalsInSameViews(e,t)}t.view.updatedAt=Date.now()}else{var d;t.view.meta={...null!==(d=t.view.meta)&&void 0!==d?d:{},stale:!0}}t.view.loadId=U(),t.view.abortController&&(t.view.abortController.abort(),t.view.abortController=void 0)}}handleUpdate(e,t,i,r,o,a,s,n,l){var d;const h=t.view.value.includes(n.id),c=this.isEntityTypeCompatible(n,(null===(d=t.params)||void 0===d?void 0:d.itemType)||"all");if(h&&!c){if(t.view.value=t.view.value.filter(e=>e!==n.id),t.view.meta&&"number"===typeof t.view.meta.total&&(t.view.meta.total=Math.max(0,t.view.meta.total-1),o&&Number.isFinite(r)&&"number"===typeof t.view.meta.total)){const e=r;e>0&&(t.view.meta.totalPages=Math.max(1,Math.ceil(t.view.meta.total/e)))}if(t.view.updatedAt=Date.now(),o&&t.view.value.length<r&&l){var u;const o=t.view.meta,a=o&&"number"===typeof o.totalPages?o.totalPages:1;if(this.cascadeShiftPages(e,t,i,r,a,l,null!==(u=t.params)&&void 0!==u?u:{})&&t.view.meta&&"number"===typeof t.view.meta.totalPages){const i=Math.max(1,t.view.meta.totalPages-1);t.view.meta.totalPages=i,this.updateTotalPagesForAllViews(e,i)}}return t.view.loadId=U(),void(t.view.abortController&&(t.view.abortController.abort(),t.view.abortController=void 0))}if(h&&(a||s)){t.view.value=t.view.value.filter(e=>e!==n.id);if(this.tryReinsertEntity(t,n,l,o,r)){if(t.view.meta&&"number"===typeof t.view.meta.total){if(t.view.meta.total+=1,o&&Number.isFinite(r)){const e=r;e>0&&(t.view.meta.totalPages=Math.max(1,Math.ceil(t.view.meta.total/e)))}this.syncTotalsInSameViews(e,t)}}else{if(t.view.meta&&"number"===typeof t.view.meta.total){if(t.view.meta.total=Math.max(0,t.view.meta.total-1),o&&Number.isFinite(r)&&"number"===typeof t.view.meta.total){const e=r;e>0&&(t.view.meta.totalPages=Math.max(1,Math.ceil(t.view.meta.total/e)))}this.syncTotalsInSameViews(e,t)}if(o&&t.view.value.length<r&&l){var v;const o=t.view.meta,a=o&&"number"===typeof o.totalPages?o.totalPages:1;if(this.cascadeShiftPages(e,t,i,r,a,l,null!==(v=t.params)&&void 0!==v?v:{})&&t.view.meta&&"number"===typeof t.view.meta.totalPages){const i=Math.max(1,t.view.meta.totalPages-1);t.view.meta.totalPages=i,this.updateTotalPagesForAllViews(e,i)}}}return t.view.updatedAt=Date.now(),t.view.loadId=U(),void(t.view.abortController&&(t.view.abortController.abort(),t.view.abortController=void 0))}if(h)return t.view.updatedAt=Date.now(),t.view.loadId=U(),void(t.view.abortController&&(t.view.abortController.abort(),t.view.abortController=void 0));if(c&&!s){if(a&&this.strategy.allowSortedInsert&&this.strategy.comparator&&l){if(this.tryInsertSorted(t,n,l)&&t.view.meta&&"number"===typeof t.view.meta.total){if(t.view.meta.total+=1,o&&Number.isFinite(r)){const e=r;e>0&&(t.view.meta.totalPages=Math.max(1,Math.ceil(t.view.meta.total/e)))}this.syncTotalsInSameViews(e,t)}}else if(!o||t.view.value.length<r){if(t.view.value.push(n.id),t.view.meta&&"number"===typeof t.view.meta.total){if(t.view.meta.total+=1,o&&Number.isFinite(r)){const e=r;e>0&&(t.view.meta.totalPages=Math.max(1,Math.ceil(t.view.meta.total/e)))}this.syncTotalsInSameViews(e,t)}t.view.updatedAt=Date.now()}else{var f;t.view.meta={...null!==(f=t.view.meta)&&void 0!==f?f:{},stale:!0}}t.view.loadId=U(),t.view.abortController&&(t.view.abortController.abort(),t.view.abortController=void 0)}}handleMove(e,t,i,r,o,a,s,n,l){if(t.view.value.includes(s.id)){if(t.view.value=t.view.value.filter(e=>e!==s.id),t.view.meta&&"number"===typeof t.view.meta.total&&(t.view.meta.total=Math.max(0,t.view.meta.total-1),o&&Number.isFinite(r)&&"number"===typeof t.view.meta.total)){const e=r;e>0&&(t.view.meta.totalPages=Math.max(1,Math.ceil(t.view.meta.total/e)))}if(t.view.updatedAt=Date.now(),o&&t.view.value.length<r&&l){var d;const o=t.view.meta,a=o&&"number"===typeof o.totalPages?o.totalPages:1;if(this.cascadeShiftPages(e,t,i,r,a,l,null!==(d=t.params)&&void 0!==d?d:{})&&t.view.meta&&"number"===typeof t.view.meta.totalPages){const i=Math.max(1,t.view.meta.totalPages-1);t.view.meta.totalPages=i,this.updateTotalPagesForAllViews(e,i)}}this.syncTotalsInSameViews(e,t)}t.view.loadId=U(),t.view.abortController&&(t.view.abortController.abort(),t.view.abortController=void 0)}forceInvalidateChildrenViews(e){const t=this.parentKey(null!==e&&void 0!==e?e:null);this.failedRequests.clearChildrenViewErrorsForParent(t);const i=this.views.get(t);if(i)for(const[,r]of i)r.view.value=void 0,r.view.meta=void 0,r.view.promise=null,r.view.updatedAt=0,r.view.loadId=U(),r.view.abortController&&(r.view.abortController.abort(),r.view.abortController=void 0)}getKnownTotal(e){const t=this.parentKey(null!==e&&void 0!==e?e:null),i=this.views.get(t);if(!i)return;let r=null;for(const[,s]of i){const e=s.view.meta;var o,a;if(e&&"number"===typeof e.total)if(!r||(null!==(o=s.view.updatedAt)&&void 0!==o?o:0)>r.updatedAt)r={total:Number(e.total),updatedAt:null!==(a=s.view.updatedAt)&&void 0!==a?a:0}}return r?r.total:void 0}toJSON(){return{views:Array.from(this.views.entries()).map(([e,t])=>[e,Array.from(t.entries())]),ttl:this.ttl,errorTtl:this.errorTtl,entityTtl:this.entityTtl,strategy:{allowSortedInsert:this.strategy.allowSortedInsert,allowSearchInsert:this.strategy.allowSearchInsert,invalidateOnPaginationFull:this.strategy.invalidateOnPaginationFull,preloadPagesBefore:this.strategy.preloadPagesBefore,preloadPagesAfter:this.strategy.preloadPagesAfter}}}static fromJSON(e,t){var i,r,o,a,s;const n=null!==(i=null!==(r=null===t||void 0===t?void 0:t.ttl)&&void 0!==r?r:null===e||void 0===e?void 0:e.ttl)&&void 0!==i?i:S,l=null!==(o=null!==(a=null===t||void 0===t?void 0:t.errorTtl)&&void 0!==a?a:null===e||void 0===e?void 0:e.errorTtl)&&void 0!==o?o:n,d=null!==(s=null===t||void 0===t?void 0:t.failedRequests)&&void 0!==s?s:new M,h=new B({},n,l,void 0,d);for(const[u,v]of null!==(c=e.views)&&void 0!==c?c:[]){var c;const e=new Map;for(const[t,i]of v){const r=i;null!==r&&void 0!==r&&r.view&&"error"in r.view&&delete r.view.error,e.set(t,r)}h.views.set(u,e)}return h}}class z{invalidateChildrenCountCache(e){const t=T(null!==e&&void 0!==e?e:"");this.childrenCountPromises.delete(t),this.failedRequests.delete(M.childrenCountKey(t))}constructor(e={},t=18e5,i){this.entities=void 0,this.views=void 0,this.ttl=void 0,this.errorTtl=void 0,this.failedRequests=void 0,this.childrenCountPromises=new Map,this.failedRequests=new M,this.ttl=t,this.errorTtl=null!==i&&void 0!==i?i:t,this.entities=new R,this.views=new B(e,t,this.errorTtl,void 0,this.failedRequests),this.views.setServerChildrenCountHandler((e,t,i)=>{this.handleServerReportedChildrenCount(e,t,null!==i&&void 0!==i?i:this.entities)}),this.views.setChildrenCountInvalidator(e=>{this.invalidateChildrenCountCache(e)})}getEntity(e){var t;return null!==(t=this.entities.getEntity(e))&&void 0!==t?t:null}getFileSystemItem(e){var t;return null!==(t=this.entities.getFileSystemItem(e))&&void 0!==t?t:null}getFolder(e){var t;return null!==(t=this.entities.getFolder(e))&&void 0!==t?t:null}async getOrCreateChildren(e,t,i){return this.views.getOrCreateChildren(e,t,i,this.entities)}upsertEntity(e){const t=this.entities.getEntity(e.id),i=t?N(t):null,r=N(e),o=!!t&&D(t),a=D(e);if(this.entities.upsertEntity(e),t){if(i!==r||o!==a)return this.views.smartInvalidateChildrenViews(i,t,"delete",this.entities),void this.views.smartInvalidateChildrenViews(r,e,"insert",this.entities);this.views.smartInvalidateChildrenViews(r,e,"update",this.entities,void 0,t)}else this.views.smartInvalidateChildrenViews(r,e,"insert",this.entities)}isAncestor(e,t){let i=t;const r=new Set;for(;i&&!r.has(i);){r.add(i);if(T(i)===T(e))return!0;const t=this.entities.getEntity(i);if(!t)break;i=N(t),null===i&&(i="")}return!1}moveEntity(e,t){const i=this.entities.getEntity(e);if(!i)return null;if(D(i)&&null!==t&&this.isAncestor(e,t))return null;const r=N(i),o=this.entities.moveEntityById(e,t);return o?(this.views.smartInvalidateChildrenViews(r,i,"delete",this.entities),this.views.smartInvalidateChildrenViews(t,o,"insert",this.entities),o):null}copyEntity(e,t,i,r){const o=this.entities.getEntity(e);if(!o)return null;let a=null;if(D(o)){var s;const i=[e],o=[];for(;i.length;){const e=i.shift();o.push(e);const t=this.entities.getChildrenIds(e,{onlyFolders:!0});for(const r of t)i.push(r)}const d=new Map;for(const e of o)d.set(e,U());for(const a of o){var n,l;const i=this.entities.getFolder(a),o=d.get(a),s=N(i),h=null===s?t:null!==(n=d.get(s))&&void 0!==n?n:null,c={...i,...a===e?r:void 0,id:o,folderId:null!==(l=a===e?null===r||void 0===r?void 0:r.folderId:void 0)&&void 0!==l?l:h};this.entities.upsertEntity(c)}for(const e of o){const t=d.get(e),i=this.entities.getChildrenIds(e,{onlyFileSystemItems:!0});for(const e of i){const i=this.entities.getFileSystemItem(e);if(!i)continue;const r=U(),o={...i,id:r,folderId:t};this.entities.upsertEntity(o)}}a=null!==(s=this.entities.getEntity(d.get(e)))&&void 0!==s?s:null}else{const o=null!==i&&void 0!==i?i:U();if(a=this.entities.copyFileSystemItem(e,o,null!==t&&void 0!==t?t:null),a&&r){var d,h;const e={...a,...r,id:o,folderId:null!==(d=null!==(h=r.folderId)&&void 0!==h?h:t)&&void 0!==d?d:null};this.entities.upsertEntity(e),a=e}}return a&&this.views.smartInvalidateChildrenViews(t,a,"copy",this.entities),a}searchByUrl(e){var t;return null!==(t=this.entities.searchByUrl(e))&&void 0!==t?t:null}deleteEntity(e){const t=this.entities.getEntity(e);if(!t)return null;if(D(t)){const{deletedFolderRecords:i,deletedFileSystemItemRecords:r}=this.entities.deleteFolderRecursive(e);for(const e of r)this.views.smartInvalidateChildrenViews(e.folderId,e,"delete",this.entities);for(const e of i)this.views.smartInvalidateChildrenViews(e.folderId,e,"delete",this.entities);for(const e of i)this.views.forceInvalidateChildrenViews(e.id);return t}{const{entity:t,parentId:i}=this.entities.deleteEntityById(e);return t&&this.views.smartInvalidateChildrenViews(i,t,"delete",this.entities),t}}deleteFolderRecursive(e){const{deletedFolderRecords:t,deletedFileSystemItemRecords:i}=this.entities.deleteFolderRecursive(e);for(const r of i)this.views.smartInvalidateChildrenViews(r.folderId,r,"delete",this.entities);for(const r of t)this.views.smartInvalidateChildrenViews(r.folderId,r,"delete",this.entities);for(const r of t)this.views.forceInvalidateChildrenViews(r.id);return{deletedFileSystemItemIds:i.map(e=>e.id),deletedFolderIds:t.map(e=>e.id)}}forceInvalidate(e){const t=this.entities.getEntity(e);if(!t)return;const i=new Set;if(D(t)){const t=[e];for(;t.length;){const e=t.pop();if(i.has(e))continue;i.add(e),this.views.forceInvalidateChildrenViews(e),this.invalidateChildrenCountCache(e);const r=this.entities.getChildrenIds(e,{onlyFolders:!0});for(const i of r)t.push(i)}}else{var r;const e=null!==(r=t.folderId)&&void 0!==r?r:null;this.views.forceInvalidateChildrenViews(e),this.invalidateChildrenCountCache(e)}}getChildrenIds(e){return this.entities.getChildrenIds(e)}searchByName(e,t){return this.entities.searchByName(e,t)}async getChildrenCount(e="",t){const i=T(e),r=M.childrenCountKey(i),o=this.failedRequests.getFreshError(r,this.errorTtl);if(null!=o)return Promise.reject(o);const a=this.childrenCountPromises.get(i);if(a)return a;const s=(async()=>{try{const i=this.entities.getFolder(e);if(i&&"number"===typeof i.childrenCount)return this.failedRequests.delete(r),i.childrenCount;const o=this.views.getKnownTotal(e);if("number"===typeof o)return i&&this.handleServerReportedChildrenCount(e,o,this.entities),this.failedRequests.delete(r),o;if(t){const i=await t(e);return this.entities.getFolder(e)&&this.handleServerReportedChildrenCount(e,i,this.entities),this.failedRequests.delete(r),i}return this.failedRequests.delete(r),this.entities.getChildrenIds(e).length}catch(o){if(this.childrenCountPromises.delete(i),function(e){var t,i,r;if(!e||"object"!==typeof e)return!1;const o=e;return"path_folder_not_found"===o.code||"path_folder_not_found"===(null===(t=o.data)||void 0===t?void 0:t.code)||404===o.status||404===(null===(i=o.data)||void 0===i||null===(r=i.data)||void 0===r?void 0:r.status)}(o))return this.failedRequests.delete(r),0;throw this.failedRequests.setError(r,o),o}finally{this.childrenCountPromises.delete(i)}})();return this.childrenCountPromises.set(i,s),s}toJSON(){return{entities:this.entities.toJSON(),views:this.views.toJSON(),ttl:this.ttl,errorTtl:this.errorTtl}}static fromJSON(e,t){var i,r,o,a;const s=null!==(i=null===e||void 0===e?void 0:e.ttl)&&void 0!==i?i:S,n=null!==(r=null===e||void 0===e?void 0:e.errorTtl)&&void 0!==r?r:s,l=new z(null!==t&&void 0!==t?t:{},s,n),d=R.fromJSON(null!==(o=null===e||void 0===e?void 0:e.entities)&&void 0!==o?o:{}),h=B.fromJSON(null!==(a=null===e||void 0===e?void 0:e.views)&&void 0!==a?a:{},{failedRequests:l.failedRequests,ttl:s,errorTtl:n});var c,u,v,f,p;t&&(h.strategy={allowSortedInsert:null===(c=t.allowSortedInsert)||void 0===c||c,allowSearchInsert:null===(u=t.allowSearchInsert)||void 0===u||u,invalidateOnPaginationFull:null===(v=t.invalidateOnPaginationFull)||void 0===v||v,preloadPagesBefore:null!==(f=t.preloadPagesBefore)&&void 0!==f?f:0,preloadPagesAfter:null!==(p=t.preloadPagesAfter)&&void 0!==p?p:1,comparator:t.comparator,filterMatch:t.filterMatch});return l.entities=d,l.views=h,h.setServerChildrenCountHandler((e,t,i)=>{l.handleServerReportedChildrenCount(e,t,null!==i&&void 0!==i?i:d)}),h.setChildrenCountInvalidator(e=>{l.invalidateChildrenCountCache(e)}),l}handleServerReportedChildrenCount(e,t,i){this.checkAndResolveChildrenCountConflict(e,t,i),this.invalidateChildrenCountCache(e)}checkAndResolveChildrenCountConflict(e,t,i){if(!i||void 0===t)return;const r=null!==e&&void 0!==e?e:null;if(!r)return void i.updateServerChildrenCount(r,t);const o=i.getFolder(r),a=null===o||void 0===o?void 0:o.childrenCount;void 0!==a&&a!==t&&this.views.forceInvalidateChildrenViews(r),i.updateServerChildrenCount(r,t)}}class k{constructor(){this.deletingIds=new Set}beginDeleting(e){for(const t of e)t&&this.deletingIds.add(t)}endDeleting(e){for(const t of e)t&&this.deletingIds.delete(t)}isDeleting(e){return!!e&&this.deletingIds.has(e)}}var q;function G(e,t){const i=null!==e&&void 0!==e?e:{},r=Array.isArray(i.detailed)?i.detailed.map(e=>{var i;return{requestId:null!==(i=e.requestId)&&void 0!==i?i:e.id,success:!!e.success,data:t(e.data),error:e.error}}):void 0;return{success:!!i.success,error:i.error,detailed:r}}let L=(V=q=class{async _findOrCreateFolderByPath(e){const{__:t}=this.i18n,i=(r=e)?r.replaceAll("\\","/").split("/").filter(Boolean):[];var r;if(i.length>10){const e=t("Path depth exceeds maximum limit of %s").replace("%s",String(10));throw new b.FileManagerApiError(e,"ValidationError")}let o;for(const n of i){var a;const{files:i}=await this.getFiles({folderId:(null===(a=o)||void 0===a?void 0:a.id)||"",itemType:"folder"}),r=i.find(e=>e.name===n);if(r){if(!r.isFolder){const i=t("Path component '%s' in '%s' is not a folder").replace("%s",n).replace("%s",e);throw new b.FileManagerApiError(i,"ValidationError")}o={id:r.id,name:r.name,parentId:r.folderId}}else{var s;if("function"!==typeof this._dataProvider.createFolder)throw new b.FileManagerApiError(t("Create folder operation is not supported by data provider"),"UnsupportedOperation");o=await this.createFolder({name:n,parentId:null===(s=o)||void 0===s?void 0:s.id})}}return o}getTrashFolder(){return this._findOrCreateFolderByPath(this._pathOptions.trashPath||"Trash")}getTempFolder(){return this._findOrCreateFolderByPath(this._pathOptions.tempPath||"Edited")}constructor(e,t={},i,r=I.nr){var o,a;this._dataProvider=e,this._options=t,this._pathOptions=i,this.i18n=r,this._cache=void 0,this._rootId=void 0,this._useSoftDelete=void 0,this._enableTrash=void 0,this._validateDuplicates=void 0,this._blobFetchForceReloadOnceIds=new Set,this._mutationRegistry=new k,this._mapItem=async({childrenCount:e,...t})=>{if(t.isFolder)return{...t,childCount:e,url:"",thumbnailUrl:""};const[i,r]=await Promise.all([this._getUrl(t),this._getThumbnailUrl(t)]);return{...t,childCount:0,url:i,thumbnailUrl:r}},this._useSoftDelete=this._pathOptions.useSoftDelete,this._rootId=this._pathOptions.rootId||"",this._enableTrash=void 0===this._options.enableTrash||this._options.enableTrash,this._validateDuplicates=this._dataProvider.validateDuplicates,this._cache=new z(t.cacheStrategy||{},null===(o=t.cacheStrategy)||void 0===o?void 0:o.ttl,null===(a=t.cacheStrategy)||void 0===a?void 0:a.errorTtl),this.setController({invalidateItemCache:e=>{this._cache.forceInvalidate(e)},getCachedItem:e=>this._cache.getEntity(e)}),"function"!==typeof this._dataProvider.clearCache&&(this.clearCache=void 0)}setController(e){"function"===typeof this._dataProvider.setController&&this._dataProvider.setController(e)}async clearCache(e){if("function"!==typeof this._dataProvider.clearCache){const{__:e}=this.i18n;throw new b.FileManagerApiError(e("Clear cache is not supported by data provider"),"UnsupportedOperation")}this._cache.forceInvalidate(this._rootId),await this._dataProvider.clearCache(e)}markNextFileBlobFetchBypassHttpCache(e){this._blobFetchForceReloadOnceIds.add(this.normalizeId(e))}normalizeId(e){return e?"root"===e||"folders"===e?this._rootId:e:this._rootId}_isDeletingId(e){return this._mutationRegistry.isDeleting(this.normalizeId(e))}_collectDeletingIds(e){const t=this.normalizeId(e),i=new Set([t]),r=this._cache.getEntity(t);if(null===r||void 0===r||!r.isFolder)return Array.from(i);const o=[t];for(;o.length>0;){const e=o.pop(),t=this._cache.getChildrenIds(e);for(const r of t){if(i.has(r))continue;i.add(r);const e=this._cache.getEntity(r);null!==e&&void 0!==e&&e.isFolder&&o.push(r)}}return Array.from(i)}_emptyFilesResult(e,t){return{files:[],pagination:{..."number"===typeof e?{page:e}:{},..."number"===typeof t?{limit:t}:{},total:0,totalPages:1,hasNext:!1,hasPrev:!1}}}_validateName(e,t=!1){if(!e||0===e.trim().length){const e=t?"FolderInvalidName":"FileInvalidName",{__:i}=this.i18n,r=i(t?"Folder name cannot be empty":"File name cannot be empty");throw new b.FileManagerApiError(r,e)}if(/[\/\\:*?"<>|]/.test(e)){const{__:i}=this.i18n,r=t?"FolderInvalidName":"FileInvalidName",o=t?i("Folder name contains invalid characters: %s").replace("%s",e):i("File name contains invalid characters: %s").replace("%s",e);throw new b.FileManagerApiError(o,r)}}_validateTargetFolderType(e){const t=this.normalizeId(e);if(t===this._rootId)return;const i=this._cache.getEntity(t);if(i&&!i.isFolder){const{__:t}=this.i18n,i=t("Target item with id '%s' is not a folder").replace("%s",e);throw new b.FileManagerApiError(i,"ValidationError")}}_checkNameExistsInCache(e,t,i,r){const o=this.normalizeId(e),a=this._cache.getChildrenIds(o);for(const s of a){const e=this._cache.getEntity(s);if(e&&e.name===t&&!!e.isFolder===i&&(!r||e.id!==r))return!0}return!1}async _getUrl(e){if(e.url)return e.url;try{var t;return"function"===typeof(null===(t=this._dataProvider)||void 0===t?void 0:t.getUrl)&&this._dataProvider.getUrl(e)||""}catch(i){}return""}async _getThumbnailUrl(e){if(e.thumbnailUrl)return e.thumbnailUrl;try{var t;return"function"===typeof(null===(t=this._dataProvider)||void 0===t?void 0:t.getThumbnailUrl)&&this._dataProvider.getThumbnailUrl(e)||""}catch(i){}return""}_isAncestor(e,t){if(!t)return!1;const i=this.normalizeId(t),r=this.normalizeId(e);if(i===r)return!0;let o=this._cache.getEntity(i);const a=new Set;for(;o&&o.folderId&&!a.has(o.id);){a.add(o.id);const e=this.normalizeId(o.folderId);if(e===r)return!0;if(o=this._cache.getEntity(e),!o||!o.isFolder)break}return!1}async getFile(e,t){return this._isDeletingId(e)?null:this._cache.searchByName(t,{parentId:this.normalizeId(e),caseSensitive:!0,recursive:!1,itemType:"file"})[0]||(await this.getFiles({folderId:e,itemType:"file",search:t})).files[0]}async getFileById(e){const t=this.normalizeId(e);if(this._isDeletingId(t))return null;const i=this._cache.getFileSystemItem(t);if(i&&!i.isFolder)return await this._mapItem(i);if(!this._dataProvider.pathMode)return null;const r=await this._getFileByPathStyleId(t);return r&&!r.isFolder?(this._cache.upsertEntity(r),await this._mapItem(r)):null}async _getFileByPathStyleId(e){const t=e.replace(/\\/g,"/").replace(/^\/+/,""),i=t.lastIndexOf("/"),r=i<0?"":t.slice(0,i),o=i<0?t:t.slice(i+1);return o?this.getFile(r,o):null}async getFileUrl(e,t){const i=await this.getFile(e,t);return await this._getUrl(i)||await this._getThumbnailUrl(i)||i.thumbnail}async getFiles({folderId:e,search:t,sortBy:i,sortOrder:r,page:o,limit:a,itemType:s="all",noFolder:n=!1}){var l,d;n&&(e=null===(d=await this.getTempFolder())||void 0===d?void 0:d.id);const h=this.normalizeId(null!==(l=e)&&void 0!==l?l:this._rootId),c=!1===this._options.enablePagination,u=c?1:o,v=c?1e4:a,f=this._options.clientSideFilter,p=this._options.clientSideSorting,m=this._options.clientSidePaging,w=m?Math.max(1,null!==o&&void 0!==o?o:1):void 0,g=m?"number"===typeof a&&Number.isFinite(a)&&a>0?a:25:void 0,y=this._emptyFilesResult(m?w:u,m?g:v);if(this._isDeletingId(h))return y;const I=!1!==this._options.unifiedCatalogFetch&&c&&("folder"===s||"file"===s),_=I?"all":s,F={folderId:h,itemType:_};f||(F.search=t),p||(F.sortBy=null!==i&&void 0!==i?i:"folder"!==_?"date":void 0,F.sortOrder=null!==r&&void 0!==r?r:"folder"!==_?"desc":void 0),m||(F.page=u,F.limit=I?1e4:v);const C=I?1e4:m?void 0:v,P={folderId:h,itemType:_,search:f?void 0:t,sortBy:p?void 0:F.sortBy,sortOrder:p?void 0:F.sortOrder,page:m?void 0:u,pageSize:C};let b;try{b=await this._cache.getOrCreateChildren(h,P,async(e,t)=>{const i=t.pageSize,r=null!=i&&Number.isFinite(Number(i))?Number(i):1e4,o=await this._dataProvider.getItems({...t,folderId:e,limit:r});var a;return m?{items:o.items,total:"number"===typeof(null===(a=o.pagination)||void 0===a?void 0:a.total)?o.pagination.total:o.items.length}:{items:o.items,...o.pagination}})}catch(O){if(this._isDeletingId(h))return y;throw O}let A,E=b.items;if(I&&("folder"===s?E=E.filter(e=>e.isFolder):"file"===s&&(E=E.filter(e=>!e.isFolder))),f)if("function"===typeof this._options.clientSideFilter)E=this._options.clientSideFilter(E,t);else if(t){const e=t.toLowerCase();E=E.filter(t=>{var i;return null===(i=t.name)||void 0===i?void 0:i.toLowerCase().includes(e)})}var M;p&&(E="function"===typeof this._options.clientSideSorting?this._options.clientSideSorting(E,i,r):this._defaultClientSideSort(E,i,r)),A=m||f||I?E.length:null!==(M=b.total)&&void 0!==M?M:E.length;let S=E;if(m)if("function"===typeof this._options.clientSidePaging)S=this._options.clientSidePaging(E,w,g);else{const e=(w-1)*g,t=e+g;S=E.slice(e,t)}if("function"===typeof this._dataProvider.getUrl||"function"===typeof this._dataProvider.getThumbnailUrl){const e=S.map(async e=>{if(e.isFolder)return e;const[t,i]=await Promise.all([e.url?Promise.resolve(e.url):"function"===typeof this._dataProvider.getUrl?this._dataProvider.getUrl(e):Promise.resolve(void 0),e.thumbnailUrl?Promise.resolve(e.thumbnailUrl):"function"===typeof this._dataProvider.getThumbnailUrl?this._dataProvider.getThumbnailUrl(e):Promise.resolve(void 0)]);return{...e,url:t,thumbnailUrl:i}});S=await Promise.all(e)}const T=m?{page:w,limit:g,total:A,totalPages:Math.max(1,Math.ceil(A/g)),hasNext:w*g<A,hasPrev:w>1}:{page:u,limit:v,total:A,...!m&&b.totalPages&&{totalPages:b.totalPages},...!m&&b.hasNextPage&&{hasNextPage:b.hasNextPage}};return{files:await Promise.all(S.map(this._mapItem)),pagination:T}}_defaultClientSideSort(e,t,i){return e.sort((e,r)=>{let o=0;switch(t){case"name":default:o=(e.name||"").localeCompare(r.name||"");break;case"date":o=new Date(e.date||0).getTime()-new Date(r.date||0).getTime();break;case"size":o=(Number(e.size)||0)-(Number(r.size)||0)}return"desc"===i?-o:o})}async getFileData(e,t){const i=this.normalizeId("string"===typeof e?e:e.id);let r=t;this._blobFetchForceReloadOnceIds.delete(i)&&(r={...t,forceReload:!0});const o=this._cache.getEntity(i)||("string"===typeof e?{id:i,name:"",folderId:this._rootId,isFolder:!1}:{...e,childrenCount:e.childCount});if("function"===typeof this._dataProvider.getFileData)return await this._dataProvider.getFileData(o,r);const{__:a}=this.i18n;if(!o.url&&"function"!==typeof this._dataProvider.getUrl)throw new b.FileManagerApiError(a("Cannot read file"),"FileReadError");const s=o.url||("function"===typeof this._dataProvider.getUrl?await this._dataProvider.getUrl(o):"");var n;if(s)return(await fetch(s,null!==(n=r)&&void 0!==n&&n.forceReload?{cache:"no-store"}:void 0)).blob();throw new b.FileManagerApiError(a("Unable to get file data"),"FileReadError")}async findFileByUrl(e){const t=this._cache.searchByUrl(e);if(t)return t;if("function"===typeof this._dataProvider.findFileByUrl)try{const t=await this._dataProvider.findFileByUrl(e);if(t)return this._cache.upsertEntity(t),t}catch(i){}return null}async getChildrenCount(e){if(!e)return 0;const t=this.normalizeId(null!==e&&void 0!==e?e:this._rootId);return this._isDeletingId(t)?0:this._cache.getChildrenCount(t,async()=>{try{if(this._options.clientSidePaging){var e;const i=await this.getFiles({folderId:t,itemType:"all",page:1,limit:25});return null!==(e=i.pagination.total)&&void 0!==e?e:i.files.length}const i=await this._dataProvider.getItems({folderId:t,limit:0,itemType:"all"});return"undefined"!==typeof i.pagination?i.pagination.total||0:!1===this._options.enablePagination?i.items.length:0}catch(i){if(this._isDeletingId(t))return 0;if(this._isPathFolderNotFoundError(i))return 0;throw i}})}_isPathFolderNotFoundError(e){var t,i,r;if(!e||"object"!==typeof e)return!1;const o=e;return"path_folder_not_found"===o.code||"path_folder_not_found"===(null===(t=o.data)||void 0===t?void 0:t.code)||404===o.status||404===(null===(i=o.data)||void 0===i||null===(r=i.data)||void 0===r?void 0:r.status)}async _uploadFile(e){var t;const i=this.normalizeId(null!==(t=e.folderId)&&void 0!==t?t:this._rootId),{__:r}=this.i18n;if("function"!==typeof this._dataProvider.uploadFile)throw new b.FileManagerApiError(r("Upload file operation is not supported by data provider"),"UnsupportedOperation");if(this._validateName(e.name,!1),this._validateDuplicates&&this._checkNameExistsInCache(i,e.name,!1)){const t=r("File '%s' already exists in target folder").replace("%s",e.name);throw new b.FileManagerApiError(t,"FileAlreadyExists")}const o=await this._dataProvider.uploadFile({...e,folderId:i}),a={name:e.name,size:e.size,...o,folderId:i};return this._cache.upsertEntity(a),a}async uploadFiles(e){var t,i;const r=e.items.some(e=>e.noFolder)?await this.getTempFolder():null;e={...e,items:null===(t=e.items)||void 0===t?void 0:t.map(e=>({...e,folderId:e.noFolder?null===r||void 0===r?void 0:r.id:e.folderId}))};for(const v of e.items)v.folderId&&(e.folderId=v.folderId);const o=e.items||[],a=null!==(i=e.folderId)&&void 0!==i?i:this._rootId,s=this.normalizeId(a);if(this._validateDuplicates)for(const v of o)if(v.name){var n;this._validateName(v.name,!1);const e=this.normalizeId(null!==(n=v.folderId)&&void 0!==n?n:s);if(this._checkNameExistsInCache(e,v.name,!1)){const{__:e}=this.i18n,t=e("File '%s' already exists in target folder").replace("%s",v.name);throw new b.FileManagerApiError(t,"FileAlreadyExists")}}const l=this._cache.getEntity(s);let d={detailed:new Array(o.length),success:!0};if("function"===typeof this._dataProvider.uploadFiles){const e=o.map(e=>{var t;return{...e,folderId:this.normalizeId(null!==(t=e.folderId)&&void 0!==t?t:s)}});if(d=G(await this._dataProvider.uploadFiles({folderId:s,items:e}),e=>{if(e)return{id:e.id,name:e.name,folderId:e.folderId}}),d.detailed&&d.detailed.length){for(let e=0;e<d.detailed.length;e++){const t=d.detailed[e];if(t&&t.success){var h,c;const e=t.data,i=null!==(h=null===e||void 0===e?void 0:e.id)&&void 0!==h?h:t.requestId,r={...l,...e,folderId:null!==(c=null===e||void 0===e?void 0:e.folderId)&&void 0!==c?c:s};this._cache.upsertEntity(r),t.requestId=i}}void 0===d.success&&(d.success=!d.detailed.some(e=>!e.success))}else d.success=!d.error&&!!d.success}else{if("function"!==typeof this._dataProvider.uploadFile)throw new b.FileManagerApiError("Upload files is not supported by data provider","UnsupportedOperation");d.detailed=await Promise.all(o.map(async e=>{var t;const i=this.normalizeId(null!==(t=e.folderId)&&void 0!==t?t:s);try{const t=await this._uploadFile({...e,folderId:i});return{requestId:t.id,data:t,success:!0}}catch(r){return{requestId:null===e||void 0===e?void 0:e.id,success:!1,error:r}}})),d.success=!d.detailed.some(e=>!e.success)}if(d.success&&this._enableTrash)try{this._cache.forceInvalidate(s)}catch(u){}return d}async deleteFile(e){const t=this.normalizeId(e),i=[t];this._mutationRegistry.beginDeleting(i);try{if(this._useSoftDelete&&this._enableTrash){const e=await this.getTrashFolder();return await this.moveItem({itemId:t,targetFolderId:e.id,isFolder:!1})}return await this.hardDeleteItem(t)}finally{this._mutationRegistry.endDeleting(i)}}async deleteItems(e,t){const i=Array.from(new Set(e.flatMap(e=>this._collectDeletingIds(this.normalizeId(e)))));this._mutationRegistry.beginDeleting(i);try{if(this._useSoftDelete&&this._enableTrash&&!0!==t.permanent){const t=await this.getTrashFolder();return await this.moveItems(t.id,e)}return await this.hardDeleteItems(e,t)}finally{this._mutationRegistry.endDeleting(i)}}async hardDeleteItems(e,t){let i={success:!0,detailed:[]};const r=t.permanent?null:await this.getTrashFolder();if("function"===typeof this._dataProvider.deleteItems){if(i=G(await this._dataProvider.deleteItems(e.map(e=>this._cache.getEntity(e)),t),e=>e),i.success){const t=i.detailed||e.map(e=>({requestId:e,success:!0,error:void 0}));for(const e of t)e.success&&(r?this._cache.moveEntity(e.requestId,r.id):this._cache.deleteEntity(e.requestId))}}else"function"===typeof this._dataProvider.deleteItem&&(i.detailed=await Promise.all(e.map(async e=>{const i=this._cache.getEntity(e);if(!i){const t="FileNotFound",{__:i}=this.i18n,r=i("Item with id '%s' not found").replace("%s",e);return{requestId:e,success:!1,error:new b.FileManagerApiError(r,t)}}try{return await this._dataProvider.deleteItem(i,t),r?this._cache.moveEntity(e,r.id):this._cache.deleteEntity(e),{requestId:e,success:!0}}catch(o){return{requestId:e,error:o,success:!1}}})),i.success=!i.detailed.some(e=>!e.success));if(i.success&&r)try{this._cache.forceInvalidate(r.id)}catch(o){}return i}async hardDeleteItem(e){const t=this._cache.getEntity(e);if(!t){const{__:t}=this.i18n,i=t("Item with id '%s' not found in cache").replace("%s",e);throw new b.FileManagerApiError(i,"FileNotFound")}if("function"!==typeof this._dataProvider.deleteItem){const{__:e}=this.i18n;throw new b.FileManagerApiError(e("Delete item operation is not supported by data provider"),"DeleteNotAllowed")}if(await this._dataProvider.deleteItem(t,{permanent:!0}),this._cache.deleteEntity(e),this._enableTrash)try{const e=await this.getTrashFolder();e&&this._cache.forceInvalidate(e.id)}catch(i){}return!0}async cleanTrash(){const{__:e}=this.i18n;if(!this._enableTrash)throw new b.FileManagerApiError(e("Trash is not enabled"),"UnsupportedOperation");if("function"===typeof this._dataProvider.cleanTrash){const e=await this._dataProvider.cleanTrash();try{const e=await this.getTrashFolder();e&&this._cache.forceInvalidate(e.id)}catch(t){}return e}throw new b.FileManagerApiError(e("Clean trash is not supported by data provider"),"UnsupportedOperation")}async createFolder({name:e,parentId:t,is_force_create:i}){const r=this.normalizeId(null!==t&&void 0!==t?t:this._rootId);if(this._validateName(e,!0),this._validateDuplicates&&this._checkNameExistsInCache(r,e,!0)){const{__:t}=this.i18n,i=t("Folder '%s' already exists in parent folder").replace("%s",e);throw new b.FileManagerApiError(i,"FolderAlreadyExists")}const o=await this._dataProvider.createFolder(e,r,i);return this._cache.upsertEntity({id:o.id,folderId:r,name:o.name,isFolder:!0,childrenCount:o.childrenCount}),o}async deleteFolder(e){const t=this.normalizeId(e),i=this._collectDeletingIds(t);this._mutationRegistry.beginDeleting(i);try{if(this._useSoftDelete&&this._enableTrash)try{const e=await this.getTrashFolder();return!!await this.moveItem({itemId:t,targetFolderId:e.id,isFolder:!0})&&(this._cache.deleteFolderRecursive(t),!0)}catch(r){return await this.hardDeleteItem(t)}return await this.hardDeleteItem(t)}finally{this._mutationRegistry.endDeleting(i)}}async renameFolder(e,t){const{__:i}=this.i18n;if("function"!==typeof this._dataProvider.renameItem)throw new b.FileManagerApiError(i("Rename folder is not supported"),"RenameNotAllowed");const r=this.normalizeId(e),o=this._cache.getEntity(r);if(!o){const t=i("Folder with id '%s' not found in cache").replace("%s",e);throw new b.FileManagerApiError(t,"FolderNotFound")}if(this._validateName(t,!0),this._validateDuplicates){const e=this.normalizeId(o.folderId);if(this._checkNameExistsInCache(e,t,!0,r)){const e=i("Folder '%s' already exists in parent folder").replace("%s",t);throw new b.FileManagerApiError(e,"FolderAlreadyExists")}}const a=await this._dataProvider.renameItem(o,t);return this._cache.upsertEntity({...this._cache.getEntity(a.id),...a}),this._cache.getEntity(a.id)}async renameFile(e,t){const{__:i}=this.i18n;if("function"!==typeof this._dataProvider.renameItem)throw new b.FileManagerApiError(i("Rename file is not supported"),"RenameNotAllowed");const r=this._cache.getEntity(e);if(!r){const t=i("File with id '%s' not found in cache").replace("%s",e);throw new b.FileManagerApiError(t,"FileNotFound")}const o=this.normalizeId(e);if(this._validateName(t,!1),this._validateDuplicates){const e=this.normalizeId(r.folderId);if(this._checkNameExistsInCache(e,t,!1,o)){const e=i("File '%s' already exists in parent folder").replace("%s",t);throw new b.FileManagerApiError(e,"FileAlreadyExists")}}const a=await this._dataProvider.renameItem(r,t);return a&&this._cache.upsertEntity({...this._cache.getEntity(o),...a}),this._cache.getEntity(o)}async moveItem({itemId:e,targetFolderId:t,isFolder:i}){if("function"!==typeof this._dataProvider.moveItem){const{__:e}=this.i18n;throw new b.FileManagerApiError(e("Move item operation is not supported by data provider"),"MoveNotAllowed")}const r=this.normalizeId(t);this._validateTargetFolderType(t);const o=this._cache.getEntity(e);if(!o){const t=await this._dataProvider.moveItem({id:e,folderId:r,isFolder:i},r);if(t.id===e)this._cache.upsertEntity({...t,folderId:r});else{try{this._cache.deleteEntity(e)}catch(n){}this._cache.upsertEntity({...t,folderId:r})}return!0}const{__:a}=this.i18n;if(o.isFolder){if(e===r)throw new b.FileManagerApiError(a("Cannot move folder into itself"),"MoveIntoSelf");if(this._isAncestor(e,r))throw new b.FileManagerApiError(a("Cannot move folder into its descendant"),"MoveIntoDescendant")}if(this._validateDuplicates&&r!==this.normalizeId(o.folderId)&&o.name&&this._checkNameExistsInCache(r,o.name,!!o.isFolder,e)){const e=o.isFolder?"FolderAlreadyExists":"FileAlreadyExists";throw new b.FileManagerApiError(`${o.isFolder?"Folder":"File"} '${o.name}' already exists in target folder`,e)}const s=await this._dataProvider.moveItem(o,r);if(s.id===e){const t=this._cache.moveEntity(e,r);return this._cache.upsertEntity({...t,...s}),!0}{const t=this._cache.deleteEntity(e);return this._cache.upsertEntity({...t,...s,folderId:r}),!0}}async moveItems(e,t){const i=this.normalizeId(e);this._validateTargetFolderType(e);const r=t.map(e=>this._cache.getEntity(e));for(const a of r)if(a){if(a.isFolder){const{__:e}=this.i18n;if(a.id===i){const t=e("Cannot move folder '%s' into itself").replace("%s",a.name);throw new b.FileManagerApiError(t,"MoveIntoSelf")}if(this._isAncestor(a.id,i)){const t=e("Cannot move folder '%s' into its descendant").replace("%s",a.name);throw new b.FileManagerApiError(t,"MoveIntoDescendant")}}if(this._validateDuplicates){const e=this.normalizeId(a.folderId);if(i!==e&&a.name&&this._checkNameExistsInCache(i,a.name,!!a.isFolder,a.id)){const e=a.isFolder?"FolderAlreadyExists":"FileAlreadyExists";throw new b.FileManagerApiError(`${a.isFolder?"Folder":"File"} '${a.name}' already exists in target folder`,e)}}}let o={detailed:new Array(r.length),success:!0};if("function"===typeof this._dataProvider.moveItems)o=G(await this._dataProvider.moveItems(r,i),e=>e);else{if("function"!==typeof this._dataProvider.moveItem)throw new b.FileManagerApiError("Move items is not supported","MoveNotAllowed");o.detailed=await Promise.all(t.map(async(e,t)=>{const o=r[t]||{id:e,folderId:null,isFolder:!1,name:e};try{return{requestId:e,data:await this._dataProvider.moveItem(o,i),success:!0}}catch(a){return{requestId:e,success:!1,error:a}}}))}if(o.success){const e=o.detailed||t.map(e=>({requestId:e,success:!0,data:void 0}));for(const t of e)if(t.success)if(t.data&&t.data.id!==t.requestId){const e=this._cache.deleteEntity(t.requestId);this._cache.upsertEntity({...e,...t.data,folderId:i})}else this._cache.moveEntity(t.requestId,i),t.data&&this._cache.upsertEntity({...this._cache.getEntity(t.requestId),...t.data,folderId:i});return o}{const{__:e}=this.i18n;return{success:!1,error:o.error||new b.FileManagerApiError(e("Move items failed"),"MoveNotAllowed")}}}async copyItem({itemId:e,targetFolderId:t}){if("function"!==typeof this._dataProvider.copyItem){const{__:e}=this.i18n;throw new b.FileManagerApiError(e("Copy item is not supported"),"CopyNotAllowed")}const i=this.normalizeId(t);this._validateTargetFolderType(t);const r=this._cache.getEntity(e);if(!r){const t=await this._dataProvider.copyItem({id:e,folderId:i},i);return this._cache.copyEntity(e,i,t.id),this._cache.upsertEntity({...t,folderId:i}),!0}if(this._validateDuplicates&&r.name){const t=i===this.normalizeId(r.folderId)?e:void 0;if(this._checkNameExistsInCache(i,r.name,!!r.isFolder,t)){const e=r.isFolder?"FolderAlreadyExists":"FileAlreadyExists";throw new b.FileManagerApiError(`${r.isFolder?"Folder":"File"} '${r.name}' already exists in target folder`,e)}}const o=await this._dataProvider.copyItem(r,i);return this._cache.copyEntity(e,i,o.id,{...o,folderId:i})||this._cache.upsertEntity({...o,folderId:i}),!0}async copyItems(e,t){const i=this.normalizeId(e);this._validateTargetFolderType(e);const r=t.map(e=>"string"===typeof e?{id:e}:e),o=r.map(e=>e.id),a=o.map((e,t)=>{var i;const o=this._cache.getEntity(e),a=null===(i=r[t])||void 0===i?void 0:i.newName;return o?a?{...o,name:a}:o:void 0});if(this._validateDuplicates)for(let l=0;l<a.length;l++){const e=a[l];if(e&&e.name){const t=this.normalizeId(e.folderId),r=i===t?o[l]:void 0;if(this._checkNameExistsInCache(i,e.name,!!e.isFolder,r)){const t=e.isFolder?"FolderAlreadyExists":"FileAlreadyExists";throw new b.FileManagerApiError(`${e.isFolder?"Folder":"File"} '${e.name}' already exists in target folder`,t)}}}let s={detailed:new Array(a.length),success:!0};if("function"===typeof this._dataProvider.copyItems)s=G(await this._dataProvider.copyItems(a,i),e=>e);else{if("function"!==typeof this._dataProvider.copyItem){const{__:e}=this.i18n;throw new b.FileManagerApiError(e("Copy items is not supported"),"CopyNotAllowed")}s.detailed=await Promise.all(o.map(async(e,t)=>{const r=a[t]||{id:e,folderId:null,isFolder:!1};try{return{requestId:e,data:await this._dataProvider.copyItem(r,i),success:!0}}catch(o){return{requestId:e,success:!1,error:o}}}))}if(s.success&&s.detailed)for(let l=0,d=s.detailed.length;l<d;l++){const e=s.detailed[l];var n;if(e.success&&null!==(n=e.data)&&void 0!==n&&n.id){const t=e.data.folderId||i;!this._cache.copyEntity(e.requestId,t,e.data.id,{...e.data,folderId:t})&&e.data&&this._cache.upsertEntity({...e.data,folderId:t})}}else if(!s.detailed)throw new b.FileManagerApiError("batchResult in copy method must have detailed results","ValidationError");return s}async uploadFileByUrl(e){var t;if(e.noFolder){const t=await this.getTempFolder();e={...e,folderId:t.id}}const i=this.normalizeId(null!==(t=e.folderId)&&void 0!==t?t:this._rootId);try{const t=await this._dataProvider.uploadFileByUrl(e.url,i,{eventSource:e.eventSource});return this._cache.upsertEntity({...t,folderId:i}),t}catch(r){throw r}}async updateFile(e,t){const{__:i}=this.i18n;if("function"!==typeof this._dataProvider.updateFile)throw new b.FileManagerApiError(i("Update file is not supported"),"UnsupportedOperation");const r=this.normalizeId(e),o=this._cache.getEntity(r);if(!o){const t=i("File with id '%s' not found in cache").replace("%s",e);throw new b.FileManagerApiError(t,"FileNotFound")}if(t.name&&t.name!==o.name&&this._validateName(t.name,!1),this._validateDuplicates&&t.name&&t.name!==o.name){const e=this.normalizeId(o.folderId);if(this._checkNameExistsInCache(e,t.name,!1,r)){const e=i("File '%s' already exists in parent folder").replace("%s",t.name);throw new b.FileManagerApiError(e,"FileAlreadyExists")}}const a=await this._dataProvider.updateFile(o,{...t});return this._cache.upsertEntity({...this._cache.getEntity(r),...a,...t}),this._cache.getEntity(r)}},class extends V{constructor(...e){super(...e);const t=Object.getOwnPropertyNames(V.prototype);for(const i of t){const e=Object.getOwnPropertyDescriptor(V.prototype,i);"constructor"!==i&&"function"===typeof(null===e||void 0===e?void 0:e.value)&&this[i]&&(this[i]=this[i].bind(this))}}}||q);var V,$=i(25516),j=i(20263),K=i(70529);const H="a_T7zSNUXtMfhVWQbIOMpXIPqzLQ8hm5Wfclm2nU98PtlSVxcft8FSn5InbD04056fYCpKXP20jJSySRLu",J={ru:"ru_RU",en:"en_GB",uk:"uk_UA",de:"de_DE",fr:"fr_FR",es:"es_ES",it:"it_IT",pt:"pt_PT",pl:"pl_PL",zh:"zh-Hans_CN",ja:"ja_JP"};async function W(e,t={}){const i=e.trim();if(!i)return i;const r=(e=>{if(!e)return"en_GB";const t=e.toLowerCase().split(/[-_]/)[0];return J[t]||"auto"})(t.locale);if(t.locale&&"en_GB"===r)return i;try{const e={from:t.locale?r:"auto",to:"en_GB",data:i,platform:"api"},o=await fetch("https://api-b2b.backenster.com/b1/api/v3/translate",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${H}`},body:JSON.stringify(e)});if(!o.ok)return i;const a=await o.json();if(a.err)return i;const s=a.result;return"string"===typeof s&&s.trim()?s.trim():i}catch(o){return i}}function Y(){const e=(0,o.Pj)(),t=(0,o.d4)(c.B),i=(0,w.ml)(_.AZ.ON_TRANSLATE_ID);return(0,r.useCallback)(async(r,o={})=>{var a;const s=r.trim();if(!s)return s;const n=null!==(a=o.locale)&&void 0!==a?a:"string"===typeof t?t:void 0,l=void 0!==j.di.getInstance(e,K.Ef);try{const e=await i.fire({input:s,locale:n}),t=function(e){for(const t of e)if("string"===typeof t&&t.trim().length>0)return t.trim();return null}(Array.isArray(e)?e:[e]);if(t)return t}catch(d){}return l?s:W(s,{locale:n}).catch(()=>s)},[t,e,i])}var Z=i(2527),X=i(74397);const Q=(0,r.memo)(F.KG),ee=(0,r.memo)(F.BC),{useToken:te}=s.A,ie="static/media/image-editor",re="js/browser-image-compression.js",oe=({storageProvider:e})=>{var t,i;const s=(0,p.rD)(),{projectId:y,emailId:F,blockId:P}=(0,a.g)(),b=(0,I.s9)(),{__:E}=b,{token:M}=te(),{error:T,notify:O}=(0,m.hN)(),N=(0,o.wA)(),D=(0,o.d4)(c.B$),U=(0,o.d4)(c.C1),x=(0,o.d4)(u.cL),R=(0,o.d4)(v.yN),B=Y(),{request:z,resolveImagePicker:k}=(0,X.p)(),q=(0,r.useMemo)(()=>{const e=s.fileManager;if(e)return{...e,enablePagination:!1===e.enablePagination?Boolean(e.clientSidePaging):e.enablePagination}},[s.fileManager]),[G,V]=(0,r.useState)(""),[j,K]=(0,r.useState)("my_files"),[H,J]=(0,r.useState)(!1),[W,oe]=(0,r.useState)(0),[ae,se]=(0,r.useState)(""),[ne,le]=(0,r.useState)(()=>[]),de=(0,r.useCallback)(()=>{N((0,u.Oo)()),setTimeout(()=>V(""),600)},[N]),he=!(D||(null===(t=U.id)||void 0===t?void 0:t.toString())!==(null===R||void 0===R||null===(i=R.members)||void 0===i?void 0:i.owner.ID));(0,r.useEffect)(()=>{null!==z&&void 0!==z&&z.kind&&(V(z.kind),se(z.currentUrl||"")),x===C.lx.UPLOAD_IMAGE_MODAL||x===C.lx.UPLOAD_BACKGROUND_MODAL?K("editor"):x===C.lx.UPLOAD_IMAGE_MODAL_AI||x===C.lx.UPLOAD_BACKGROUND_MODAL_AI?he?(J(!0),oe(2)):K("ai"):x===C.lx.UPLOAD_IMAGE_MODAL_UPLOAD||x===C.lx.UPLOAD_BACKGROUND_MODAL_UPLOAD?K("my_files"):x===C.lx.UPLOAD_IMAGE_MODAL_STOCK||x===C.lx.UPLOAD_BACKGROUND_MODAL_STOCK?he?(J(!0),oe(3)):K("stock_images"):x===C.lx.UPLOAD_IMAGE_MODAL_GIF||x===C.lx.UPLOAD_BACKGROUND_MODAL_GIF?he?(J(!0),oe(3)):K("gif"):x===C.lx.UPLOAD_IMAGE_MODAL_EDIT||x===C.lx.UPLOAD_BACKGROUND_MODAL_EDIT?(he?(J(!0),oe(5)):K("editor"),N((0,u.Wz)(C.lx.IMAGE_EDITOR_MODAL))):K("my_files")},[x,N,he,z]);const ce=!he&&!!j&&(x.includes("UPLOAD_IMAGE_")||x.includes("UPLOAD_BACKGROUND_"));(0,r.useEffect)(()=>{const e=document.querySelector("#carrotquest-messenger-collapsed-container");e&&(e.style.display=ce?"none":"")},[ce]);const ue=(0,r.useMemo)(()=>e?e.pathMode?new A(e,e.rootId,"Trash",e.trashPath,!0,b):null:(T(E("Error when initializing file manager")),null),[e,T,b]),ve=(0,r.useMemo)(()=>new L(null!==ue&&void 0!==ue?ue:e,q,{...e,trashPath:e.pathMode?"trash":e.trashPath,rootId:e.pathMode?"":e.rootId},b),[e,ue,q,b]),fe=(0,r.useCallback)(e=>{const t=(0,$.e0)(e,ve,ue);return O(t,!0)},[ve,ue,O]),pe=(0,w.ml)(_.AZ.FILE_PROXY_EVENT_ID),me=(0,Z.p)(),we=(0,o.Pj)(),ge=(0,r.useCallback)(async e=>{const t=await pe.fire({url:e,project:y});let i=await t.find(e=>e);if(!i)try{e=(0,$.i_)(e);const t=await fetch(e);i=await t.blob()}catch(r){return null}return i},[pe,y,me,we]),ye=r.createElement(d.A,{style:{fontSize:32,margin:-16},spin:!0}),Ie=(0,r.useCallback)(e=>{g.isEqual(e,ne)||le(e)},[ne]),[_e]=(0,h.Mv)(),Fe=(0,r.useCallback)(async()=>{if(ve){const e=ne[0];if(e){const t=e.url||e.thumbnailUrl||e.thumbnail;t&&k({url:t,file:e,meta:{mode:"select"}})}}de()},[ve,de,ne,k]),Ce=(0,r.useCallback)(async(e,t)=>{let i=e.url;!i&&ve&&(i=await ve.getFileUrl(e.folderId,e.name)),i&&("save"===(null===t||void 0===t?void 0:t.mode)&&ve.markNextFileBlobFetchBypassHttpCache(e.id),k({url:i,file:e,meta:t})),de()},[ve,de,k]),Pe=(0,r.useCallback)(async()=>{de()},[de]),[be,{data:Ae=[]}]=(0,h.gg)(),Ee=(null===s||void 0===s?void 0:s.handleLimitUsageEmitter)||(0,w.ml)(_.AZ.ON_LIMIT_ID),Me=(0,r.useCallback)(async function(e){try{await be(e).unwrap()}catch(t){}},[be]),Se=(0,r.useMemo)(()=>{const e=(null===s||void 0===s?void 0:s.icons)||{};if(e&&0!==Object.keys(e).length)return(0,$.Rt)(e)},[null===s||void 0===s?void 0:s.icons]),Te=(0,r.useCallback)(async(e,t={})=>await B(e,t),[B]),Oe=(0,w.ml)(_.AZ.PROXY_URL_EVENT_ID),Ne=(0,r.useCallback)(async e=>(await Oe.fire({url:e,project:y})).findLast(t=>t&&t!==e)||(0,$.W5)(e),[Oe,y]),De=(0,r.useMemo)(()=>{var e,t;const i=null===q||void 0===q?void 0:q.cacheStrategy;return null!==(e=null!==(t=null===i||void 0===i?void 0:i.errorTtl)&&void 0!==t?t:null===i||void 0===i?void 0:i.ttl)&&void 0!==e?e:S},[null===q||void 0===q?void 0:q.cacheStrategy]),Ue=(0,r.useMemo)(()=>({assetsUrl:(0,$.Zq)("",ie),compessorUrl:(0,$.Zq)("",re),compressMaxSize:null===q||void 0===q?void 0:q.compressMaxSize,compressMaxWidthOrHeight:null===q||void 0===q?void 0:q.compressMaxWidthOrHeight,onClose:de,handleProxyUrl:Ne,handleFileProxy:ge,expandRootFolderOnInit:!1!==(null===q||void 0===q?void 0:q.expandRootFolderOnInit),activeLibraryItem:j,REACT_APP_GIPHY_KEY:"Nh77eBlPeMn1ed9MBAvL542NUGeNO26F",UNSPLASH_KEY:"S5iNcLqYgRBIOLQdluHdTsCJnjCvahzhG7JfYQOrV7o",APP_NAME_UNSPLASH:"Nh77eBlPeMn1ed9MBAvL542NUGeNO26F",UNSLASH_PROXY_URL:"https://px0.racs.rest/",STREAMLINE_API_KEY:{}.REACT_APP_STREAMLINE_API_KEY,fileForEdit:ae,projectId:y,elementId:F||P,pushToGTM:null===s||void 0===s?void 0:s.pushToGTM,handleLimitUsageEmitter:Ee,sseQuery:Me,messages:Ae,sendAIImageRequest:(null===s||void 0===s?void 0:s.sendAIImageRequest)||_e,locale:U.locale.split("-")[0].split("_")[0],theme:U.theme,customTheme:M,enableTrashFolder:null===q||void 0===q?void 0:q.enableTrash,showNotifications:null===q||void 0===q?void 0:q.showNotifications,notificationDedupeTtlMs:De,previewFallbackToFileUrl:null===q||void 0===q?void 0:q.previewFallbackToFileUrl,dedupeUploadNamesOnClient:null===q||void 0===q?void 0:q.dedupeUploadNamesOnClient,saveCopyToCurrentFolder:null===q||void 0===q?void 0:q.saveCopyToCurrentFolder,handleTranslate:Te,features:{enableStockImages:!1!==s.imageCenterStockEnabled,enableGif:!1!==s.imageCenterGifEnabled,enableIconStock:!1!==s.imageCenterIconStockEnabled,enableRenameFile:!1!==(null===q||void 0===q?void 0:q.enableRenameFile),enableRenameFolder:!1!==(null===q||void 0===q?void 0:q.enableRenameFolder),enableUpdateFile:!1!==(null===q||void 0===q?void 0:q.enableUpdateFile),enableCopyItem:!1!==(null===q||void 0===q?void 0:q.enableCopyFile),enableCopyFolder:!1!==(null===q||void 0===q?void 0:q.enableCopyFolder),enableDelete:!1!==(null===q||void 0===q?void 0:q.enableDelete),enableEdit:!1!==(null===q||void 0===q?void 0:q.enableEdit),enableMoveItem:!1!==(null===q||void 0===q?void 0:q.enableMoveFile),enableMoveFolder:!1!==(null===q||void 0===q?void 0:q.enableMoveFolder)},disablePagination:!1===(null===q||void 0===q?void 0:q.enablePagination),multiSelect:!1!==(null===q||void 0===q?void 0:q.multiSelect),sortOptions:null===q||void 0===q?void 0:q.sortOptions,defaultFolderName:null===q||void 0===q?void 0:q.defaultFolderName,availableImageExtensions:null===q||void 0===q?void 0:q.availableImageExtensions}),[q,De,de,Ne,ge,j,ae,y,F,P,s,Ee,Me,Ae,_e,U.locale,U.theme,M,Te]);return z&&G&&ve?r.createElement(r.Fragment,null,!he&&r.createElement(n.A,{className:"file-manager",closable:!0,footer:null,open:ce,width:"100vw",onOk:Fe,onCancel:de},r.createElement(l.A,{spinning:!ve,indicator:ye},ve&&("editor"===j?r.createElement(ee,{onSave:Ce,onClose:Pe,compessorUrl:(0,$.Zq)("",re),compressMaxSize:null===q||void 0===q?void 0:q.compressMaxSize,compressMaxWidthOrHeight:null===q||void 0===q?void 0:q.compressMaxWidthOrHeight,dedupeUploadNamesOnClient:null===q||void 0===q?void 0:q.dedupeUploadNamesOnClient,saveCopyToCurrentFolder:null===q||void 0===q?void 0:q.saveCopyToCurrentFolder,dataProviders:ve,handleFileProxy:ge,theme:U.theme,file:ae,handleNotify:fe,assetsUrl:(0,$.Zq)("",ie),locale:U.locale.split("-")[0].split("_")[0]}):r.createElement(Q,{dataProviders:ve,onChangeSelection:Ie,onEditorOk:Ce,handleNotify:fe,customIcons:Se,config:Ue})))),r.createElement(f.A,{open:H,onCancel:()=>J(!1),initialSlide:W,sideOnOk:void 0})):null},ae=(0,r.memo)(oe)}}]);
|
|
2
|
+
//# sourceMappingURL=6310.27dbb05e.js.map
|