import{bd as A,X as g,bQ as q,bR as x,af as k,ac as D,bI as Q,b3 as z}from"./index-00b4fcdc.js";import{u as G,b as N,f as j,c as H,d as L,e as O,h as T}from"./FileItem-40e08df3.js";let U=0;const W=()=>++U,X=(r,l,{dataUpdateStrategy:c="replace"}={})=>{const s=A([""]),u=g(!1),t=g(),a=g(!1);let f=g(-1);const v=new Set,b=e=>{var n;c==="replace"?t.value=e:c==="merge"&&(k((Array.isArray(t.value)||typeof t.value>"u")&&Array.isArray(e),"数据更新策略为合并时仅可用于值为数组的情况"),t.value=[...(n=t==null?void 0:t.value)!==null&&n!==void 0?n:[],...e])},d=e=>x(void 0,void 0,void 0,function*(){if(a.value||u.value&&typeof e>"u")return!1;a.value=!0;const n=W();f.value=n;try{let o;if(typeof e=="number"){if(o=s[e],typeof o!="string")return!1}else o=s[s.length-1];const m=yield r(o);if(v.has(n))return v.delete(n),!1;b(l(m));const i=m.cursor;if((e===s.length-1||typeof e!="number")&&(u.value=!i.has_next,i.has_next)){const p=i.next_cursor||i.next;k(typeof p=="string"),s.push(p)}}finally{f.value===n&&(a.value=!1)}return!0}),h=()=>{v.add(f.value),a.value=!1},w=(e=!1)=>x(void 0,void 0,void 0,function*(){const{refetch:n,force:o}=typeof e=="object"?e:{refetch:e};o&&h(),k(!a.value),s.splice(0,s.length,""),a.value=!1,t.value=void 0,u.value=!1,n&&(yield d())}),I=()=>({next:()=>x(void 0,void 0,void 0,function*(){if(a.value)throw new Error("不允许同时迭代");return{done:!(yield d()),value:t.value}})});return q({abort:h,load:u,next:d,res:t,loading:a,cursorStack:s,reset:w,[Symbol.asyncIterator]:I,iter:{[Symbol.asyncIterator]:I}})},K=r=>A(X(r,l=>l.files,{dataUpdateStrategy:"merge"})),V=r=>{const l=A(new Set),c=D(()=>(r.res??[]).filter(y=>!l.has(y.fullpath))),s=Q(),{stackViewEl:u,multiSelectedIdxs:t,stack:a,scroller:f}=G({images:c}).toRefs(),{itemSize:v,gridItems:b,cellWidth:d,onScroll:h}=N({fetchNext:()=>r.next()}),{showMenuIdx:w}=j(),{onFileDragStart:I,onFileDragEnd:e}=H(),{showGenInfo:n,imageGenInfo:o,q:m,onContextMenuClick:i,onFileItemClick:p}=L({openNext:z}),{previewIdx:C,previewing:F,onPreviewVisibleChange:_,previewImgMove:E,canPreview:M}=O(),R=async(y,S,P)=>{a.value=[{curr:"",files:c.value}],await i(y,S,P)};return T("removeFiles",async({paths:y})=>{y.forEach(S=>l.add(S))}),{images:c,scroller:f,queue:s,iter:r,onContextMenuClickU:R,stackViewEl:u,previewIdx:C,previewing:F,onPreviewVisibleChange:_,previewImgMove:E,canPreview:M,itemSize:v,gridItems:b,showGenInfo:n,imageGenInfo:o,q:m,onContextMenuClick:i,onFileItemClick:p,showMenuIdx:w,multiSelectedIdxs:t,onFileDragStart:I,onFileDragEnd:e,cellWidth:d,onScroll:h}};export{K as c,V as u};
