sd-webui-infinite-image-bro.../vue/dist/assets/index-dea9fb8b.js

4 lines
34 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

var st=Object.defineProperty;var ot=(l,a,e)=>a in l?st(l,a,{enumerable:!0,configurable:!0,writable:!0,value:e}):l[a]=e;var fe=(l,a,e)=>(ot(l,typeof a!="symbol"?a+"":a,e),e);import{dy as xe,cm as Ie,cl as rt,ba as ze,ax as Pe,Z as De,cP as lt,bT as it,c as H,A as ct,dz as ut,$ as N,cJ as dt,bw as Ne,dA as ft,dB as ie,dC as je,bs as pt,dg as Be,dD as vt,ao as ht,v as le,aD as he,bl as ne,ap as te,at as mt,dE as Se,af as X,dF as gt,dG as He,ay as Ge,ag as K,ae as E,c6 as qe,c5 as yt,Y as Q,dH as ee,a0 as wt,aH as kt,aI as bt,E as me,dI as Ce,aw as se,dJ as xt,U as re,cU as Te,dl as q,dK as It,dL as St,aK as _t,dM as Re,cH as $e,c3 as Ke,dN as Qe,W as _e,d6 as Ft,dO as Je,dP as Ee,s as Pt,dm as Ae,dp as Le,dQ as Ct,dR as Tt,O as ae,cT as Et,dS as Mt,cX as Dt,dT as At,m as We,L as Lt,cS as Ue,dU as Ot,dV as Nt,dW as Rt,dX as $t,cn as Wt,dY as Ut,dZ as Vt,d_ as zt,d$ as jt,e0 as Bt,cR as Ht,r as Gt,c0 as qt,ar as Kt,e1 as Xe,e2 as Qt}from"./index-12313f08.js";import{_ as Jt,C as Ye,g as Xt}from"./shortcut-bbb69994.js";import{i as Yt}from"./_isIterateeCall-daf707d9.js";function Zt(l){return l&&l.length?l[0]:void 0}var ea=Math.ceil,ta=Math.max;function aa(l,a,e,t){for(var i=-1,s=ta(ea((a-l)/(e||1)),0),F=Array(s);s--;)F[t?s:++i]=l,l+=e;return F}function na(l){return function(a,e,t){return t&&typeof t!="number"&&Yt(a,e,t)&&(e=t=void 0),a=xe(a),e===void 0?(e=a,a=0):e=xe(e),t=t===void 0?a<e?1:-1:xe(t),aa(a,e,t,l)}}var sa=na();const Ze=sa;class ke{static run(a){const e=Object.assign({immediately:!0,id:-1,isFinished:!1,errorHandleMethod:"ignore"},a);let t,i;const s=new Promise((v,I)=>{i=v,t=I}),F=()=>{e.isFinished=!0,clearTimeout(e.id)},L=()=>Ie(this,void 0,void 0,function*(){try{e.res=yield e.action(),e.validator&&e.validator(e.res)&&(i(e.res),F())}catch(v){ke.silent||console.error(v),e.errorHandleMethod==="stop"&&(F(),t(v))}}),P=()=>{e.isFinished||(e.id=setTimeout(()=>Ie(this,void 0,void 0,function*(){yield L(),P()}),e.pollInterval))};return setTimeout(()=>Ie(this,void 0,void 0,function*(){e.immediately&&(yield L()),P()}),0),rt({task:e,clearTask:F,completedTask:s})}}ke.silent=!1;const de=(...l)=>{document.addEventListener(...l),ze(()=>document.removeEventListener(...l))},pe=new WeakMap;function oa(l,a){return{useHookShareState:t=>{const i=it();Pe(i),pe.has(i)||(pe.set(i,De(l(i,t??(a==null?void 0:a())))),ze(()=>{pe.delete(i)}));const s=pe.get(i);return Pe(s),{state:s,toRefs(){return lt(s)}}}}}var ra={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M832 64H192c-17.7 0-32 14.3-32 32v832c0 17.7 14.3 32 32 32h640c17.7 0 32-14.3 32-32V96c0-17.7-14.3-32-32-32zm-600 72h560v208H232V136zm560 480H232V408h560v208zm0 272H232V680h560v208zM304 240a40 40 0 1080 0 40 40 0 10-80 0zm0 272a40 40 0 1080 0 40 40 0 10-80 0zm0 272a40 40 0 1080 0 40 40 0 10-80 0z"}}]},name:"database",theme:"outlined"};const la=ra;function Ve(l){for(var a=1;a<arguments.length;a++){var e=arguments[a]!=null?Object(arguments[a]):{},t=Object.keys(e);typeof Object.getOwnPropertySymbols=="function"&&(t=t.concat(Object.getOwnPropertySymbols(e).filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable}))),t.forEach(function(i){ia(l,i,e[i])})}return l}function ia(l,a,e){return a in l?Object.defineProperty(l,a,{value:e,enumerable:!0,configurable:!0,writable:!0}):l[a]=e,l}var Oe=function(a,e){var t=Ve({},a,e.attrs);return H(ct,Ve({},t,{icon:la}),null)};Oe.displayName="DatabaseOutlined";Oe.inheritAttrs=!1;const ca=Oe,ua=ut("useBatchDownloadStore",()=>{const l=N([]);return{selectdFiles:l,addFiles:e=>{l.value=dt([...l.value,...e])}}});class ge{constructor(a,e=ft.CREATED_TIME_DESC){fe(this,"root");fe(this,"execQueue",[]);fe(this,"walkerInitPromsie");this.entryPath=a,this.sortMethod=e,this.root={children:[],info:{name:this.entryPath,size:"-",bytes:0,created_time:"",is_under_scanned_path:!0,date:"",type:"dir",fullpath:this.entryPath}},this.walkerInitPromsie=new Promise(t=>{Ne([this.entryPath]).then(async i=>{this.root.info=i[this.entryPath],await this.fetchChildren(this.root),t()})})}reset(){return this.root.children=[],this.fetchChildren(this.root)}get images(){const a=e=>e.children.map(t=>{if(t.info.type==="dir")return a(t);if(Be(t.info.name))return t.info}).filter(t=>t).flat(1);return a(this.root)}get isCompleted(){return this.execQueue.length===0}async fetchChildren(a){const{files:e}=await ie(a.info.fullpath);return a.children=je(e,this.sortMethod).map(t=>({info:t,children:[]})),this.execQueue.shift(),this.execQueue.unshift(...a.children.filter(t=>t.info.type==="dir").map(t=>({fn:()=>this.fetchChildren(t),...t}))),a}async next(){await this.walkerInitPromsie;const a=Zt(this.execQueue);if(!a)return null;const e=await a.fn();return this.execQueue=this.execQueue.slice(),this.root={...this.root},e}async isExpired(){const a=[this.root.info],e=i=>{for(const s of i.children)s.info.type==="dir"&&(a.push(s.info),e(s))};e(this.root);const t=await Ne(a.map(i=>i.fullpath));for(const i of a)if(!pt(i,t[i.fullpath]))return!0;return!1}async seamlessRefresh(a,e=N(!1)){const t=performance.now(),i=new ge(this.entryPath,this.sortMethod);for(await i.walkerInitPromsie;!i.isCompleted&&i.images.length<a;){if(e.value)throw new Error("canceled");await i.next()}const s=performance.now();return console.log("seamlessRefresh currPos:",a,"Time taken:",(s-t).toFixed(0),"ms"),i}}var et={exports:{}};/* NProgress, (c) 2013, 2014 Rico Sta. Cruz - http://ricostacruz.com/nprogress
* @license MIT */(function(l,a){(function(e,t){l.exports=t})(vt,function(){var e={};e.version="0.3.5";var t=e.settings={minimum:.08,easing:"linear",positionUsing:"",speed:200,trickle:!0,trickleSpeed:200,showSpinner:!0,barSelector:'[role="bar"]',spinnerSelector:'[role="spinner"]',parent:"body",template:'<div class="bar" role="bar"><div class="peg"></div></div><div class="spinner" role="spinner"><div class="spinner-icon"></div></div>'};e.configure=function(n){var o,r;for(o in n)r=n[o],r!==void 0&&n.hasOwnProperty(o)&&(t[o]=r);return this},e.status=null,e.set=function(n){var o=e.isStarted();n=i(n,t.minimum,1),e.status=n===1?null:n;var r=e.render(!o),c=r.querySelector(t.barSelector),p=t.speed,y=t.easing;return r.offsetWidth,L(function(d){t.positionUsing===""&&(t.positionUsing=e.getPositioningCSS()),P(c,F(n,p,y)),n===1?(P(r,{transition:"none",opacity:1}),r.offsetWidth,setTimeout(function(){P(r,{transition:"all "+p+"ms linear",opacity:0}),setTimeout(function(){e.remove(),d()},p)},p)):setTimeout(d,p)}),this},e.isStarted=function(){return typeof e.status=="number"},e.start=function(){e.status||e.set(0);var n=function(){setTimeout(function(){e.status&&(e.trickle(),n())},t.trickleSpeed)};return t.trickle&&n(),this},e.done=function(n){return!n&&!e.status?this:e.inc(.3+.5*Math.random()).set(1)},e.inc=function(n){var o=e.status;return o?o>1?void 0:(typeof n!="number"&&(o>=0&&o<.2?n=.1:o>=.2&&o<.5?n=.04:o>=.5&&o<.8?n=.02:o>=.8&&o<.99?n=.005:n=0),o=i(o+n,0,.994),e.set(o)):e.start()},e.trickle=function(){return e.inc()},function(){var n=0,o=0;e.promise=function(r){return!r||r.state()==="resolved"?this:(o===0&&e.start(),n++,o++,r.always(function(){o--,o===0?(n=0,e.done()):e.set((n-o)/n)}),this)}}(),e.getElement=function(){var n=e.getParent();if(n){var o=Array.prototype.slice.call(n.querySelectorAll(".nprogress")).filter(function(r){return r.parentElement===n});if(o.length>0)return o[0]}return null},e.getParent=function(){if(t.parent instanceof HTMLElement)return t.parent;if(typeof t.parent=="string")return document.querySelector(t.parent)},e.render=function(n){if(e.isRendered())return e.getElement();I(document.documentElement,"nprogress-busy");var o=document.createElement("div");o.id="nprogress",o.className="nprogress",o.innerHTML=t.template;var r=o.querySelector(t.barSelector),c=n?"-100":s(e.status||0),p=e.getParent(),y;return P(r,{transition:"all 0 linear",transform:"translate3d("+c+"%,0,0)"}),t.showSpinner||(y=o.querySelector(t.spinnerSelector),y&&S(y)),p!=document.body&&I(p,"nprogress-custom-parent"),p.appendChild(o),o},e.remove=function(){e.status=null,M(document.documentElement,"nprogress-busy"),M(e.getParent(),"nprogress-custom-parent");var n=e.getElement();n&&S(n)},e.isRendered=function(){return!!e.getElement()},e.getPositioningCSS=function(){var n=document.body.style,o="WebkitTransform"in n?"Webkit":"MozTransform"in n?"Moz":"msTransform"in n?"ms":"OTransform"in n?"O":"";return o+"Perspective"in n?"translate3d":o+"Transform"in n?"translate":"margin"};function i(n,o,r){return n<o?o:n>r?r:n}function s(n){return(-1+n)*100}function F(n,o,r){var c;return t.positionUsing==="translate3d"?c={transform:"translate3d("+s(n)+"%,0,0)"}:t.positionUsing==="translate"?c={transform:"translate("+s(n)+"%,0)"}:c={"margin-left":s(n)+"%"},c.transition="all "+o+"ms "+r,c}var L=function(){var n=[];function o(){var r=n.shift();r&&r(o)}return function(r){n.push(r),n.length==1&&o()}}(),P=function(){var n=["Webkit","O","Moz","ms"],o={};function r(d){return d.replace(/^-ms-/,"ms-").replace(/-([\da-z])/gi,function(u,m){return m.toUpperCase()})}function c(d){var u=document.body.style;if(d in u)return d;for(var m=n.length,D=d.charAt(0).toUpperCase()+d.slice(1),O;m--;)if(O=n[m]+D,O in u)return O;return d}function p(d){return d=r(d),o[d]||(o[d]=c(d))}function y(d,u,m){u=p(u),d.style[u]=m}return function(d,u){var m=arguments,D,O;if(m.length==2)for(D in u)O=u[D],O!==void 0&&u.hasOwnProperty(D)&&y(d,D,O);else y(d,m[1],m[2])}}();function v(n,o){var r=typeof n=="string"?n:w(n);return r.indexOf(" "+o+" ")>=0}function I(n,o){var r=w(n),c=r+o;v(r,o)||(n.className=c.substring(1))}function M(n,o){var r=w(n),c;v(n,o)&&(c=r.replace(" "+o+" "," "),n.className=c.substring(1,c.length-1))}function w(n){return(" "+(n&&n.className||"")+" ").replace(/\s+/gi," ")}function S(n){n&&n.parentNode&&n.parentNode.removeChild(n)}return e})})(et);var da=et.exports;const fa=ht(da);function pa(){const l=N(),{scroller:a,stackViewEl:e,stack:t,currPage:i,currLocation:s,useEventListen:F,eventEmitter:L,getPane:P,props:v,deletedFiles:I,walker:M,sortedFiles:w,previewing:S}=J().toRefs();le(()=>t.value.length,he((f,x)=>{var j,U;if(f===x)return;if(f>x){(j=a.value)==null||j.scrollToItem(0);return}const C=((U=ne(t.value))==null?void 0:U.scrollIndex)??0;te(0).then(()=>{var B;return(B=a.value)==null?void 0:B.scrollToItem(C)})},300)),mt(async()=>{var f;if(!t.value.length)if(v.value.mode==="scanned-fixed"||v.value.mode==="walk")t.value=[{files:[],curr:v.value.path??""}];else{const x=await ie("/");t.value.push({files:x.files,curr:"/"})}l.value=new fa,l.value.configure({parent:e.value}),v.value.path&&v.value.path!=="/"?await y(v.value.path):(f=k.conf)!=null&&f.home&&y(k.conf.home)}),le(s,he(f=>{const x=P.value();if(!x)return;x.path=f;const C=Se(f).pop()??"",U=(()=>{const B={walk:"Walk","scanned-fixed":"Fixed",scanned:null}[v.value.mode??"scanned"],G=oe=>B?`${B}: ${oe}`:oe,Y=k.getShortPath(f);return G(Y.length>24&&C?C:Y)})();x.name=X("div",{style:"display:flex;align-items:center"},[X(ca),X("span",{class:"line-clamp-1",style:"max-width: 256px"},U)]),x.nameFallbackStr=U,k.recent=k.recent.filter(B=>B.key!==x.key),k.recent.unshift({path:f,key:x.key,mode:v.value.mode}),k.recent.length>20&&(k.recent=k.recent.slice(0,20))},300));const n=()=>me(s.value),o=async f=>{var x,C;if(f.type==="dir")try{(x=l.value)==null||x.start();const{files:j}=await ie(f.fullpath);v.value.mode=="scanned-fixed"?t.value=[{files:j,curr:f.fullpath}]:t.value.push({files:j,curr:f.name})}finally{(C=l.value)==null||C.done()}},r=f=>{if(v.value.mode!="walk")for(;f<t.value.length-1;)t.value.pop()},c=()=>{y(Ce(s.value))},p=(f,x)=>(Pe(k.conf,"global.conf load failed"),k.conf.is_win?f.toLowerCase()==x.toLowerCase():f==x),y=async f=>{v.value.mode==="walk"?P.value().path=f:v.value.mode==="scanned-fixed"?await o({fullpath:f,name:f,type:"dir"}):await d(f),te(500).then(()=>L.value.emit("viewableAreaFilesChange"))},d=async f=>{var C,j;const x=t.value.slice();try{gt(f)||(f=He(((C=k.conf)==null?void 0:C.sd_cwd)??"/",f));const U=Se(f),B=t.value.map(G=>G.curr);for(B.shift();B[0]&&U[0]&&p(B[0],U[0]);)B.shift(),U.shift();for(let G=0;G<B.length;G++)t.value.pop();if(!U.length)return u();for(const G of U){const Y=(j=i.value)==null?void 0:j.files.find(oe=>p(oe.name,G));if(!Y)throw console.error({frags:U,frag:G,stack:Ge(t.value)}),new Error(`${G} not found`);await o(Y)}}catch(U){throw K.error(E("moveFailedCheckPath")+(U instanceof Error?U.message:"")),console.error(f,Se(f),i.value),t.value=x,U}},u=qe(async()=>{var f,x,C;try{if((f=l.value)==null||f.start(),M.value)await M.value.reset(),L.value.emit("loadNextDir");else{const{files:j}=await ie(s.value);ne(t.value).files=j}I.value.clear(),(x=a.value)==null||x.scrollToItem(0),K.success(E("refreshCompleted"))}finally{(C=l.value)==null||C.done()}}),m=async(f=!1)=>{var x,C,j;if(!(f===!0&&S.value)){if(v.value.mode==="walk"&&M.value){const U=((x=a.value)==null?void 0:x.$_endIndex)??64;if(k.autoRefreshWalkMode&&U<k.autoRefreshWalkModePosLimit&&await M.value.isExpired()){const B=N(!1),G=()=>{B.value=!0,k.autoRefreshWalkMode=!1,Y(),K.success(E("walkModeAutoRefreshDisabled"))},Y=K.loading(X("span",{},[E("autoUpdate"),X("span",{onClick:G,style:{paddingLeft:"16px",cursor:"pointer",color:"var(--primary-color)"}},E("disable"))]),0);try{const oe=new Promise(at=>{M.value.seamlessRefresh(U,B).then(nt=>{B.value||(M.value=nt,L.value.emit("loadNextDir"),at())})});await Promise.all([oe,te(1500)])}finally{Y()}}return}try{if(!k.autoRefreshNormalFixedMode)return;(C=l.value)==null||C.start();const{files:U}=await ie(s.value);ne(t.value).files.map(G=>G.date).join()!==U.map(G=>G.date).join()&&(ne(t.value).files=U,K.success(E("autoUpdate")))}finally{(j=l.value)==null||j.done()}}};yt("returnToIIB",m),F.value("refresh",u),F.value("navigateUp",c);const D=f=>{y(f)},O=Q(()=>k.quickMovePaths.map(f=>({...f,path:ee(f.dir)}))),V=Q(()=>{const f=ee(s.value);return O.value.find(C=>C.path===f)}),h=async()=>{const f=k.tabList[v.value.tabIdx],x={type:"empty",name:E("emptyStartPage"),key:Date.now()+se(),popAddPathModal:{path:s.value,type:"scanned-fixed"}};f.panes.push(x),f.key=x.key},b=N(!1),T=N(s.value),A=()=>{b.value=!0,T.value=s.value},R=async()=>{await y(T.value),b.value=!1};de("click",f=>{var x,C,j;(j=(C=(x=f.target)==null?void 0:x.className)==null?void 0:C.includes)!=null&&j.call(C,"ant-input")||(b.value=!1)});const z=()=>{const f=parent.location,x=f.href.substring(0,f.href.length-f.search.length),C=new URLSearchParams(f.search);C.set("action","open"),C.set("path",s.value),C.set("mode",v.value.mode??"scanned");const j=`${x}?${C.toString()}`;me(j,E("copyLocationUrlSuccessMsg"))},g=(f="tag-search")=>{const x=k.tabList[v.value.tabIdx],C={type:f,key:se(),searchScope:s.value,name:E(f==="tag-search"?"imgSearch":"fuzzy-search")};x.panes.push(C),x.key=C.key},_=()=>L.value.emit("selectAll"),W=async()=>{await xt(s.value),await u()},$=()=>{const f=s.value;ye.set(f,t.value);const x=k.tabList[v.value.tabIdx],C={type:"local",key:se(),path:f,name:E("local"),stackKey:f,mode:"walk"};x.panes.push(C),x.key=C.key},be=Q(()=>!M.value&&w.value.some(f=>f.type==="dir"));return{locInputValue:T,isLocationEditing:b,onLocEditEnter:R,onEditBtnClick:A,addToSearchScanPathAndQuickMove:h,searchPathInfo:V,refresh:u,copyLocation:n,back:r,openNext:o,currPage:i,currLocation:s,stack:t,scroller:a,share:z,selectAll:_,quickMoveTo:D,onCreateFloderBtnClick:W,onWalkBtnClick:$,showWalkButton:be,searchInCurrentDir:g,backToLastUseTo:c,...va(()=>m(!0))}}const va=l=>{const a=N([]),e=Q(()=>a.value.length>0);wt(()=>{a.value.forEach(s=>s())});const t=kt(bt+"poll-interval",3);return{onPollRefreshClick:()=>{if(a.value.length){a.value.forEach(s=>s()),a.value=[];return}re.confirm({title:E("pollRefresh"),width:640,content:()=>X("div",{},[X("p",{class:"uni-desc primary-bg"},E("pollRefreshTip")),X("div",{style:{display:"flex",alignItems:"center",gap:"4px"}},[X("span",{},E("pollInterval")+"(s): "),X(Jt,{min:1,max:60*10,modelValue:t.value,"onUpdate:modelValue":s=>{t.value=s}})])]),onOk:()=>{const{clearTask:s}=ke.run({pollInterval:t.value*1e3,action:l});a.value.push(s)}})},polling:e}};function ha(l){const{previewIdx:a,eventEmitter:e,canLoadNext:t,previewing:i,sortedFiles:s,scroller:F,props:L}=J().toRefs(),{state:P}=J();let v=null;const I=(r,c)=>{var p;i.value=r,v!=null&&!r&&c&&((p=F.value)==null||p.scrollToItem(v),v=null)},M=r=>{const c=F.value;!c||r<0||(r>=c.$_startIndex&&r<=c.$_endIndex?console.log("scrollToIndex already in view",r,"s",c):c.scrollToItem(r))},w=r=>{if(!r)return;const c=s.value.findIndex(p=>p.fullpath===r);console.log("idx",{idx:c,files:s}),c>=0&&M(c)},S=()=>{if(!o("next")){if(l!=null&&l.loadNext)return l.loadNext();L.value.mode==="walk"&&t.value&&(K.info(E("loadingNextFolder")),e.value.emit("loadNextDir",!0))}};de("keydown",r=>{var c;if(i.value){let p=a.value;if(["ArrowDown","ArrowRight"].includes(r.key))for(p++;s.value[p]&&!q(s.value[p].name);)p++;else if(["ArrowUp","ArrowLeft"].includes(r.key))for(p--;s.value[p]&&!q(s.value[p].name);)p--;if(q((c=s.value[p])==null?void 0:c.name)??""){a.value=p;const y=F.value;y&&!(p>=y.$_startIndex&&p<=y.$_endIndex)&&(v=p)}S()}});const n=r=>{var p;let c=a.value;if(r==="next")for(c++;s.value[c]&&!q(s.value[c].name);)c++;else if(r==="prev")for(c--;s.value[c]&&!q(s.value[c].name);)c--;if(q((p=s.value[c])==null?void 0:p.name)??""){a.value=c;const y=F.value;y&&!(c>=y.$_startIndex&&c<=y.$_endIndex)&&(v=c)}S()},o=r=>{var p;let c=a.value;if(r==="next")for(c++;s.value[c]&&!q(s.value[c].name);)c++;else if(r==="prev")for(c--;s.value[c]&&!q(s.value[c].name);)c--;return q((p=s.value[c])==null?void 0:p.name)};return we("removeFiles",async()=>{i.value&&!P.sortedFiles[a.value]&&Te()}),{previewIdx:a,onPreviewVisibleChange:I,previewing:i,previewImgMove:n,canPreview:o,scrollToIndex:M,scrollToFileId:w}}function ma({fetchNext:l}={}){const{scroller:a,sortedFiles:e,sortMethod:t,currLocation:i,currPage:s,stackViewEl:F,canLoadNext:L,previewIdx:P,props:v,walker:I,getViewableAreaFiles:M}=J().toRefs(),{state:w}=J(),S=N(!1),n=N(k.defaultGridCellWidth),o=Q(()=>n.value+16),r=44,{width:c}=It(F),p=Q(()=>~~(c.value/o.value)),y=De(new Map),d=Q(()=>{const h=o.value;return{first:h+(n.value<=160?0:r),second:h}}),u=N(!1),m=async()=>{var h;if(!(u.value||v.value.mode!=="walk"||!L.value))try{u.value=!0,await((h=I.value)==null?void 0:h.next())}finally{u.value=!1}},D=async(h=!1)=>{const b=a.value,T=()=>h?P.value:(b==null?void 0:b.$_endIndex)??0,A=()=>{const R=e.value.length,z=50;return R?l?T()>R-z:T()>R-z&&L.value:!0};for(;A();){await te(30);const R=await(l??m)();if(typeof R=="boolean"&&!R)return}};w.useEventListen("loadNextDir",qe(async(h=!1)=>{await D(h),v.value.mode==="walk"&&O()})),w.useEventListen("viewableAreaFilesChange",()=>{const h=M.value(),b=h.filter(A=>A.is_under_scanned_path&&Be(A.name)).map(A=>A.fullpath);ue.fetchImageTags(b);const T=h.filter(A=>A.is_under_scanned_path&&A.type==="dir"&&!y.has(A.fullpath)).map(A=>A.fullpath);T.length&&St(T).then(A=>{for(const R in A)if(Object.prototype.hasOwnProperty.call(A,R)){const z=A[R];y.set(R,z)}})}),w.useEventListen("refresh",async()=>{w.eventEmitter.emit("viewableAreaFilesChange")});const O=he(()=>w.eventEmitter.emit("viewableAreaFilesChange"),300);le(i,O);const V=he(async()=>{const h=a.value;h&&s.value&&(s.value.scrollIndex=h.$_startIndex),await D(),O()},150);return{gridItems:p,sortedFiles:e,sortMethodConv:_t,moreActionsDropdownShow:S,gridSize:o,sortMethod:t,onScroll:V,loadNextDir:m,loadNextDirLoading:u,canLoadNext:L,itemSize:d,cellWidth:n,dirCoverCache:y}}function ve(l){return typeof l=="function"||Object.prototype.toString.call(l)==="[object Object]"&&!Ft(l)}function ga(){const{currLocation:l,sortedFiles:a,currPage:e,multiSelectedIdxs:t,eventEmitter:i,walker:s}=J().toRefs(),F=()=>{t.value=[]};de("click",()=>{k.keepMultiSelect||F()}),de("blur",()=>{k.keepMultiSelect||F()}),le(e,F);const L=(w,S)=>{const n=Ge(a.value[S]);Me.fileDragging=!0,console.log("onFileDragStart set drag file ",w,S,n);const o=[n];let r=n.type==="dir";if(t.value.includes(S)){const p=t.value.map(y=>a.value[y]);o.push(...p),r=p.some(y=>y.type==="dir")}const c={includeDir:r,loc:l.value||"search-result",path:Re(o,"fullpath").map(p=>p.fullpath),nodes:Re(o,"fullpath"),__id:"FileTransferData"};w.dataTransfer.setData("text/plain",JSON.stringify(c))},P=()=>{Me.fileDragging=!1},v=async w=>{if(s.value)return;const S=$e(w);if(!S)return;const n=l.value;S.loc!==n&&M(S,n)},I=async(w,S)=>{if(s.value||S.type!=="dir")return!1;const n=$e(w);if(!n)return!1;const o=ee(n.loc),r=ee(l.value||"");if(o!==r)return!1;const c=ee(S.fullpath),p=n.path.map(ee).filter(y=>y!==c&&!c.startsWith(y+"/"));return p.length?(w.preventDefault(),M({...n,path:p},c),!0):!1},M=(w,S)=>{const n=Ke(),o=N(!1),r=async()=>n.pushAction(async()=>{await Je(w.path,S,!1,o.value),i.value.emit("refresh"),re.destroyAll()}),c=()=>n.pushAction(async()=>{await Ee(w.path,S,!1,o.value),Z.emit("removeFiles",{paths:w.path,loc:w.loc}),i.value.emit("refresh"),re.destroyAll()});re.confirm({title:E("confirm")+"?",width:"60vw",content:()=>{let p,y,d,u;return H("div",null,[H("div",null,[`${E("moveSelectedFilesTo")} ${S}`,H("ol",{style:{maxHeight:"50vh",overflow:"auto"}},[w.path.map(m=>H("li",null,[m.split(/[/\\]/).pop()]))])]),H(Qe,null,null),H("div",{style:{marginTop:"8px"}},[H(Ye,{checked:o.value,"onUpdate:checked":m=>o.value=m},ve(p=E("continueOnError"))?p:{default:()=>[p]}),H("div",{style:{color:"#888",fontSize:"12px",marginTop:"4px"}},[E("continueOnErrorDesc")])]),H("div",{style:{display:"flex",alignItems:"center",justifyContent:"flex-end"},class:"actions"},[H(_e,{onClick:re.destroyAll},ve(y=E("cancel"))?y:{default:()=>[y]}),H(_e,{type:"primary",loading:!n.isIdle,onClick:r},ve(d=E("copy"))?d:{default:()=>[d]}),H(_e,{type:"primary",loading:!n.isIdle,onClick:c},ve(u=E("move"))?u:{default:()=>[u]})])])},maskClosable:!0,wrapClassName:"hidden-antd-btns-modal"})};return{onFileDragStart:L,onDrop:v,multiSelectedIdxs:t,onFileDragEnd:P,onFileDropToFolder:I}}const ya=l=>{const a=Ae(l.name),e=Le(l.name);let t,i;return a?(t=Ct(l),i="video"):e?(t=Tt(l),i="audio"):(t=ae(l),i="image"),{id:l.fullpath,url:t,type:i,originalFile:l,name:l.name,fullpath:l.fullpath}},wa=l=>l.filter(a=>a.type==="file"&&(q(a.name)||Ae(a.name)||Le(a.name))).map(ya),ka=(l,a=0)=>{a=Math.min(a,l.length-1),a=Math.max(a,0);const e=Pt(),t=wa(l);if(t.length===0){console.warn("没有找到可以显示的媒体文件");return}let i=0;if(a<l.length){const s=l[a];i=t.findIndex(F=>F.id===s.fullpath),i===-1&&(i=0)}e.openTiktokView(t,i)};function ba({openNext:l}){const a=N(!1),e=N(""),{sortedFiles:t,previewIdx:i,multiSelectedIdxs:s,stack:F,currLocation:L,spinning:P,previewing:v,scroller:I,stackViewEl:M,eventEmitter:w,props:S,deletedFiles:n}=J().toRefs(),o=ee;we("removeFiles",({paths:d,loc:u})=>{o(u)!==o(L.value)||!ne(F.value)||(d.forEach(D=>n.value.add(D)),d.filter(q).forEach(D=>n.value.add(D.replace(/\.\w+$/,".txt"))))}),we("addFiles",({files:d,loc:u})=>{if(o(u)!==o(L.value))return;const m=ne(F.value);m&&m.files.unshift(...d)});const r=Ke(),c=async(d,u,m)=>{i.value=m,k.fullscreenPreviewInitialUrl=ae(u);const D=s.value.indexOf(m);if(d.shiftKey){if(D!==-1)s.value.splice(D,1);else{s.value.push(m),s.value.sort((h,b)=>h-b);const O=s.value[0],V=s.value[s.value.length-1];s.value=Ze(O,V+1)}d.stopPropagation()}else d.ctrlKey||d.metaKey?(D!==-1?s.value.splice(D,1):s.value.push(m),d.stopPropagation()):await l(u)},p=async(d,u,m)=>{var A,R,z;const D=ae(u),O=L.value,V={IIB_container_id:parent.IIB_container_id},h=()=>{let g=[];return s.value.includes(m)?g=s.value.map(_=>t.value[_]):g.push(u),g},b=async g=>{if(!P.value)try{P.value=!0,await Ut(u.fullpath),ce.postMessage({...V,event:"click_hidden_button",btnEleId:"iib_hidden_img_update_trigger"}),await Vt(),ce.postMessage({...V,event:"click_hidden_button",btnEleId:`iib_hidden_tab_${g}`})}catch(_){console.error(_),K.error("发送图像失败请携带console的错误消息找开发者")}finally{P.value=!1}},T=`${d.key}`;if(T.startsWith("toggle-tag-")){const g=+T.split("toggle-tag-")[1],{is_remove:_}=await Mt({tag_id:g,img_path:u.fullpath}),W=(R=(A=k.conf)==null?void 0:A.all_custom_tags.find($=>$.id===g))==null?void 0:R.name;await ue.refreshTags([u.fullpath]),K.success(E(_?"removedTagFromImage":"addedTagToImage",{tag:W}));return}else if(T==="add-custom-tag")Dt();else if(T.startsWith("batch-add-tag-")||T.startsWith("batch-remove-tag-")){const g=+T.split("-tag-")[1],_=T.includes("add")?"add":"remove",W=h().map($=>$.fullpath);await At({tag_id:g,img_paths:W,action:_}),await ue.refreshTags(W),K.success(E(_==="add"?"addCompleted":"removeCompleted"));return}else if(T.startsWith("copy-to-")){const g=T.split("copy-to-")[1],_=h(),W=_.map($=>$.fullpath);await Je(W,g,!0),Z.emit("addFiles",{files:_,loc:g}),K.success(E("copySuccess"));return}else if(T.startsWith("move-to-")){const g=T.split("move-to-")[1],_=h(),W=_.map($=>$.fullpath);await Ee(W,g,!0),Z.emit("removeFiles",{paths:W,loc:L.value}),Z.emit("addFiles",{files:_,loc:g}),K.success(E("moveSuccess"));return}switch(d.key){case"previewInNewWindow":return window.open(D);case"copyFilePath":return me(u.fullpath);case"saveSelectedAsJson":return Wt(h());case"openWithDefaultApp":return $t(u.fullpath);case"download":{const g=h();Rt(g.map(_=>ae(_,!0)));break}case"copyPreviewUrl":return me(parent.document.location.origin+D);case"rename":{let g=await Nt(u.fullpath);g=ee(g);const _=ue.tagMap;_.set(g,_.get(u.fullpath)??[]),_.delete(u.fullpath),u.fullpath=g,u.name=g.split(/[\\/]/).pop()??"";return}case"send2txt2img":return b("txt2img");case"send2img2img":return b("img2img");case"send2inpaint":return b("inpaint");case"send2extras":return b("extras");case"send2savedDir":{const g=k.quickMovePaths.find($=>$.key==="outdir_save");if(!g)return K.error(E("unknownSavedDir"));const _=Ot(g.dir,(z=k.conf)==null?void 0:z.sd_cwd),W=h();await Ee(W.map($=>$.fullpath),_,!0),Z.emit("removeFiles",{paths:W.map($=>$.fullpath),loc:L.value}),Z.emit("addFiles",{files:W,loc:_});break}case"send2controlnet-img2img":case"send2controlnet-txt2img":{const g=d.key.split("-")[1];ce.postMessage({...V,event:"send_to_control_net",type:g,url:ae(u)});break}case"send2outpaint":{e.value=await r.pushAction(()=>Ue(u.fullpath)).res;const[g,_]=(e.value||"").split(`
`);ce.postMessage({...V,event:"send_to_outpaint",url:ae(u),prompt:g,negPrompt:_.slice(17)});break}case"openWithWalkMode":{ye.set(O,F.value);const g=k.tabList[S.value.tabIdx],_={type:"local",key:se(),path:u.fullpath,name:E("local"),stackKey:O,mode:"walk"};g.panes.push(_),g.key=_.key;break}case"openFileLocationInNewTab":case"openInNewTab":{const g=k.tabList[S.value.tabIdx],_={type:"local",key:se(),path:d.key==="openInNewTab"?u.fullpath:Ce(u.fullpath),name:E("local"),mode:"scanned-fixed"};g.panes.push(_),g.key=_.key;break}case"openOnTheRight":{ye.set(O,F.value);let g=k.tabList[S.value.tabIdx+1];g||(g={panes:[],key:"",id:se()},k.tabList[S.value.tabIdx+1]=g);const _=u.type==="dir"?u.fullpath:Ce(u.fullpath),W={type:"local",key:se(),path:_,name:E("local"),stackKey:O,mode:S.value.mode??"scanned"};g.panes.push(W),g.key=W.key;break}case"send2BatchDownload":{tt.addFiles(h());break}case"viewGenInfo":{a.value=!0,e.value=await r.pushAction(()=>Ue(u.fullpath)).res;break}case"tiktokView":{ka(t.value,m);break}case"openWithLocalFileBrowser":{await Lt(u.fullpath);break}case"deleteFiles":{const g=h(),_=async()=>{const W=g.map($=>$.fullpath);if(await zt(W),K.success(E("deleteSuccess")),v.value){const $=ae(u)===k.fullscreenPreviewInitialUrl,be=i.value===t.value.length-1;if(($||be)&&(Te(),await te(100),$&&t.value.length>1)){const f=i.value;te(0).then(()=>jt(f,M.value))}}Z.emit("removeFiles",{paths:W,loc:L.value})};if(g.length===1&&k.ignoredConfirmActions.deleteOneOnly)return _();await new Promise(W=>{re.confirm({title:E("confirmDelete"),maskClosable:!0,width:"60vw",content:()=>H("div",null,[H("ol",{style:{maxHeight:"50vh",overflow:"auto"}},[g.map($=>H("li",null,[$.fullpath.split(/[/\\]/).pop()]))]),H(Qe,null,null),H(Ye,{checked:k.ignoredConfirmActions.deleteOneOnly,"onUpdate:checked":$=>k.ignoredConfirmActions.deleteOneOnly=$},{default:()=>[E("deleteOneOnlySkipConfirm"),We(" ("),E("resetOnGlobalSettingsPage"),We(")")]})]),async onOk(){await _(),W()}})});break}}return{}},{isOutside:y}=Et(M);return de("keydown",d=>{var D,O,V;const u=h=>{var A;const b=h;if(!b)return!1;const T=(A=b.tagName)==null?void 0:A.toLowerCase();return T==="input"||T==="textarea"||b.isContentEditable},m=Xt(d);if(v.value){m==="Esc"&&Te();const h=(D=Object.entries(k.shortcut).find(b=>b[1]===m&&b[1]))==null?void 0:D[0];if(h){d.stopPropagation(),d.preventDefault();const b=i.value,T=t.value[b];switch(h){case"delete":return p({key:"deleteFiles"},T,b);case"download":return p({key:"download"},T,b);default:{const A=(O=/^toggle_tag_(.*)$/.exec(h))==null?void 0:O[1],R=(V=k.conf)==null?void 0:V.all_custom_tags.find(z=>z.name===A);if(R)return p({key:`toggle-tag-${R.id}`},T,b);if(h.startsWith("copy_to_")){const z=h.split("copy_to_")[1];return p({key:`copy-to-${z}`},T,b)}if(h.startsWith("move_to_")){const z=h.split("move_to_")[1];return p({key:`move-to-${z}`},T,b)}}}}}else if(!y.value&&!u(d.target)){if(!d.altKey&&!d.ctrlKey&&!d.metaKey){const h=I.value,b=t.value.length,T=Math.max(b-1,0),A=R=>{if(!h||b===0)return;const z=Math.min(Math.max(R,0),T);h.scrollToItem(z)};switch(d.key){case"PageUp":{d.preventDefault(),d.stopPropagation();const R=h?Math.max(h.$_endIndex-h.$_startIndex,1):1,z=(h==null?void 0:h.$_startIndex)??0;return A(z-R)}case"PageDown":{d.preventDefault(),d.stopPropagation();const R=h?Math.max(h.$_endIndex-h.$_startIndex,1):1,z=(h==null?void 0:h.$_startIndex)??0;return A(z+R)}case"Home":return d.preventDefault(),d.stopPropagation(),A(0);case"End":return d.preventDefault(),d.stopPropagation(),A(T);case"Backspace":return d.preventDefault(),d.stopPropagation(),w.value.emit("navigateUp")}}["Ctrl + KeyA","Cmd + KeyA"].includes(m)&&(d.preventDefault(),d.stopPropagation(),w.value.emit("selectAll"))}}),{onFileItemClick:c,onContextMenuClick:p,showGenInfo:a,imageGenInfo:e,q:r}}const Fe=new Map,xa=()=>{const{useEventListen:l,sortedFiles:a,getViewableAreaFiles:e}=J().toRefs(),t=N(k.defaultChangeIndchecked),i=N(k.defaultSeedChangeChecked),s=async()=>{if(await te(100),!t.value)return;const P=e.value().filter(I=>q(I.fullpath)&&!I.gen_info_obj);if(!P.length)return;const v=await Bt(P.map(I=>I.fullpath).filter(I=>!Fe.has(I)));P.forEach(I=>{const M=v[I.fullpath]||Fe.get(I.fullpath)||"";Fe.set(I.fullpath,M),I.gen_info_obj=Ht(M),I.gen_info_raw=M})};l.value("viewableAreaFilesChange",s);const F=P=>{const v=a.value;return[P,i.value,v[P-1],v[P],v[P+1]]};function L(P,v,I,M){const w={diff:{},empty:!0,ownFile:"",otherFile:""};if(v+I<0||v+I>=a.value.length||a.value[v]==null||!("gen_info_obj"in a.value[v])||!("gen_info_obj"in a.value[v+I]))return w;const S=P,n=a.value[v+I].gen_info_obj;if(n==null)return w;const o=["hashes","resources"];w.diff={},w.ownFile=M.name,w.otherFile=a.value[v+I].name,w.empty=!1,i.value||o.push("seed");for(const r in S)if(!o.includes(r)){if(!(r in n)){w.diff[r]="+";continue}if(S[r]!=n[r])if(r.includes("rompt")&&S[r]!=""&&n[r]!=""){const c=S[r].split(","),p=n[r].split(",");let y=0;for(const d in c)c[d]!=p[d]&&y++;w.diff[r]=y}else w.diff[r]=[S[r],n[r]]}return w}return{getGenDiff:L,changeIndchecked:t,seedChangeChecked:i,getRawGenParams:()=>s(),getGenDiffWatchDep:F}},ye=new Map,k=Gt(),tt=ua(),ue=qt(),Me=Kt(),ce=new BroadcastChannel("iib-image-transfer-bus"),{eventEmitter:Z,useEventListen:we}=Xe(),{useHookShareState:J}=oa((l,{images:a})=>{const e=N({tabIdx:-1,paneIdx:-1}),t=Q(()=>ne(i.value)),i=N([]),s=Q(()=>{var u;return i.value.map(m=>m.curr).slice((u=k.conf)!=null&&u.is_win&&e.value.mode!=="scanned-fixed"?1:0)}),F=Q(()=>He(...s.value)),L=Q(()=>{var u,m;return e.value.mode==="scanned-fixed"?((m=(u=i.value)==null?void 0:u[0])==null?void 0:m.curr)??"":e.value.mode==="walk"?e.value.path??"":i.value.length===1?"/":F.value}),P=N(k.defaultSortingMethod),v=N(e.value.mode=="walk"?new ge(e.value.path,P.value):void 0);le([()=>e.value.mode,()=>e.value.path,P],async([u,m,D])=>{var O;u==="walk"?(v.value=new ge(m,D),i.value=[{files:[],curr:m}],await te(),await((O=v.value)==null?void 0:O.reset()),y.eventEmitter.emit("loadNextDir")):v.value=void 0});const I=De(new Set);le(t,()=>I.clear());const M=Q(()=>{var O;if(a.value)return a.value;if(v.value)return v.value.images.filter(V=>!I.has(V.fullpath));if(!t.value)return[];const u=((O=t.value)==null?void 0:O.files)??[],m=P.value;return je((V=>{const h=k.fileTypeFilter;return h.includes("all")||h.length===0?V:V.filter(b=>!!(b.type==="dir"||h.includes("image")&&q(b.name)||h.includes("video")&&Ae(b.name)||h.includes("audio")&&Le(b.name)))})(u),m).filter(V=>!I.has(V.fullpath))}),w=N([]),S=N(-1),n=Q(()=>v.value?!v.value.isCompleted:!1),o=N(!1),r=N(!1),c=N(),p=()=>{var u,m,D;return(D=(m=(u=k.tabList)==null?void 0:u[e.value.tabIdx])==null?void 0:m.panes)==null?void 0:D[e.value.paneIdx]},y=Xe();y.useEventListen("selectAll",()=>{console.log(`select all 0 -> ${M.value.length}`),w.value=Ze(0,M.value.length)});const d=()=>{const u=c.value;if(u){const m=Math.max(u.$_startIndex-10,0);return M.value.slice(m,u.$_endIndex+10)}return[]};return{previewing:r,spinning:o,canLoadNext:n,multiSelectedIdxs:w,previewIdx:S,basePath:s,currLocation:L,currPage:t,stack:i,sortMethod:P,sortedFiles:M,scroller:c,stackViewEl:N(),props:e,getPane:p,walker:v,deletedFiles:I,getViewableAreaFiles:d,...y}},()=>({images:N()}));function Ia(){const{eventEmitter:l,multiSelectedIdxs:a,sortedFiles:e}=J().toRefs();return{onSelectAll:()=>l.value.emit("selectAll"),onReverseSelect:()=>{a.value=e.value.map((F,L)=>L).filter(F=>!a.value.includes(F))},onClearAllSelected:()=>{a.value=[]}}}const Sa=()=>{const{stackViewEl:l}=J().toRefs(),a=N(-1);return Qt(l,e=>{var i;let t=e.target;for(;t.parentElement;)if(t=t.parentElement,t.tagName.toLowerCase()==="li"&&t.classList.contains("file-item-trigger")){const s=(i=t.dataset)==null?void 0:i.idx;s&&Number.isSafeInteger(+s)&&(a.value=+s);return}}),{showMenuIdx:a}},Ta=Object.freeze(Object.defineProperty({__proto__:null,batchDownload:tt,events:Z,global:k,imgTransferBus:ce,sli:Me,stackCache:ye,tagStore:ue,useEventListen:we,useFileItemActions:ba,useFileTransfer:ga,useFilesDisplay:ma,useGenInfoDiff:xa,useHookShareState:J,useKeepMultiSelect:Ia,useLocation:pa,useMobileOptimization:Sa,usePreview:ha},Symbol.toStringTag,{value:"Module"}));export{pa as a,ma as b,ga as c,ba as d,ha as e,Sa as f,Ia as g,xa as h,we as i,ua as j,de as k,Ta as l,ka as o,ye as s,J as u};