import{n as e}from"./vue-vendor-DMUmTARL.js";import{H as t,J as n,K as r,Y as i,q as a,yt as o}from"./index-BcZTP2Ia.js";var s=2e3,c=400,l=(e,t)=>{if(e<=0)return 0;let n=Number(t),r=Number.isNaN(n)||n<=0?e:n;return e<=s?Math.min(r,e):Math.min(r,c,e)},u=e=>{if(e.type===`BACK`||e.type===`FOLDER`||e.type===`ROOT`)return String(e.type).toLowerCase();let t=e.displayName||e.name,n=r(t),o=i.getFileIconName(n);if(o)return o;let s=e.fileType,c=s?i.getFileIconName(s):null;if(c)return c;let l=a(t);return(l?i.getFileIconName(l):null)||`file`},d=(e,r)=>{if(e.type===`FILE`&&e.preview!==null){let a=n(t(e.displayName||e.name),r);e.availablePreviewers=a;let o=a[0];o?(e.fileType=o.key,e.preview=i.previewFileType.indexOf(o.key)!==-1):e.preview=!1}return e.icon||=u(e),e},f=e=>{let t=JSON.parse(e),n=Object.entries(t).reduce((e,[t,n])=>(typeof n==`number`&&Number.isFinite(n)&&(e[t]=n),e),{});return Object.keys(n).length>0?n:null},p=e(`fileDataStore`,{state:()=>({currentClickRow:{},currentRightClickRow:{},currentStorageSource:{id:null,type:{description:``,key:``}},imgMode:!1,newImgMode:!1,oldStorageKey:null,searchParam:``,fileListSource:[],loadFileSize:-1,audioArray:[]}),getters:{filterFileByType:e=>t=>e.fileListSource.filter(function(e){if(e.type===`BACK`)return!1;let n=e.displayName||e.name,r=n.substring(n.lastIndexOf(`.`)+1).toLowerCase();return i.fileTypeMap[t].indexOf(r)!==-1}),fileList:e=>{if(e.loadFileSize===-1)return[];let t=e.fileListSource[0]?.type===`BACK`?e.loadFileSize+1:e.loadFileSize;return t=t>e.fileListSource.length?e.fileListSource.length:t,e.fileListSource.slice(0,t)},getFileUrlByName:e=>t=>{let n=e.fileListSource.find(e=>e.name===t);return n&&n.url||``}},actions:{updateCurrentStorageSource(e){this.currentStorageSource=e},updateAudioList(e){this.audioArray=e},updateCurrentClickRow(e){this.currentClickRow=e},updateCurrentRightClickRow(e){this.currentRightClickRow=e},updateFileList(e){let t=o(),n=null;try{let e=t.globalConfig?.previewerPriority;e&&(n=f(e))}catch{}this.fileListSource=e.map(e=>d(e,n));let r=l(this.fileListSource.length,t.globalConfig.maxShowSize);this.loadFileSize=r,this.fileListSource.length>s&&r<this.fileListSource.length&&console.info(`[file-list] large-directory-degrade`,{total:this.fileListSource.length,initialLoadSize:r,threshold:s})},updateOldStorageKey(e){this.oldStorageKey=e},updateLoadFileSize(e){this.loadFileSize=e}}});export{p as n,u as t};