import{m as e}from"./vendor-D8u7Kcdq.js";import{B as t}from"./semantic-ui-react-m4AAKEby.js";var n=`slskr.discoveryInbox.items`,r=[`Suggested`,`Approved`,`Downloading`,`Staged`,`Imported`,`Rejected`,`Snoozed`,`Failed`],i=`Suggested`,a=()=>new Date().toISOString(),o=e=>r.includes(e)?e:i,s=t=>{let n=a();return{acquisitionProfile:t.acquisitionProfile||`lossless-exact`,createdAt:t.createdAt||n,evidenceKey:t.evidenceKey||t.title||t.searchText||e(),id:t.id||e(),networkImpact:t.networkImpact||`Manual review; no network request until approved.`,reason:t.reason||`Manual discovery suggestion.`,searchText:t.searchText||t.title||``,source:t.source||`Manual`,sourceId:t.sourceId||``,state:o(t.state),snoozedUntil:t.snoozedUntil||``,title:t.title||t.searchText||`Untitled discovery`,updatedAt:t.updatedAt||n}},c=(e=t)=>{try{let t=JSON.parse(e(n,`[]`));return Array.isArray(t)?t.map(s):[]}catch{return[]}},l={approved:{color:`green`,label:`Approved`,summary:`Approved in Discovery Inbox for the next acquisition step.`},automatic:{color:`blue`,label:`Automatic`,summary:`Enabled and allowed to auto-download through Wishlist policy.`},disabled:{color:`grey`,label:`Disabled`,summary:`Saved but not eligible for scheduled wishlist processing.`},failed:{color:`red`,label:`Failed`,summary:`A previous acquisition/import attempt failed and needs review.`},imported:{color:`teal`,label:`Imported`,summary:`The request has been imported into the library.`},rejected:{color:`red`,label:`Rejected`,summary:`Rejected in Discovery Inbox and suppressed for the same evidence.`},review:{color:`yellow`,label:`Review`,summary:`Waiting in Discovery Inbox for approval or rejection.`},snoozed:{color:`grey`,label:`Snoozed`,summary:`Snoozed in Discovery Inbox until later review.`},staged:{color:`violet`,label:`Staged`,summary:`Downloaded or prepared for import review.`},wanted:{color:`purple`,label:`Wanted`,summary:`Enabled wishlist request with manual download approval.`}},u=e=>`${e||``}`.trim().toLowerCase(),d=e=>`wishlist:${e.id||u(e.searchText)}:${u(e.searchText)}:${u(e.filter)}`,f=e=>{switch(e){case`Approved`:return`approved`;case`Downloading`:return`automatic`;case`Failed`:return`failed`;case`Imported`:return`imported`;case`Rejected`:return`rejected`;case`Snoozed`:return`snoozed`;case`Staged`:return`staged`;default:return`review`}},p=(e,t=c())=>{let n=t.find(t=>t.evidenceKey===d(e));return n?l[f(n.state)]:e.enabled?e.autoDownload?l.automatic:l.wanted:l.disabled},m=({inboxItems:e=c(),items:t=[],quota:n=25}={})=>{let r=t.reduce((t,n)=>{let r=p(n,e).label;return t.byState[r]=(t.byState[r]||0)+1,n.enabled&&(t.enabled+=1),n.autoDownload&&(t.automatic+=1),t},{automatic:0,byState:{},enabled:0,total:t.length});return{...r,quota:n,quotaRemaining:Math.max(n-t.length,0),quotaStatus:t.length>n?`Over quota`:`Within quota`,reviewCount:(r.byState.Review||0)+(r.byState.Approved||0)+(r.byState.Snoozed||0)}},h=({inboxItems:e=c(),items:t=[],quota:n=25}={})=>{let r=m({inboxItems:e,items:t,quota:n}),i=t.map(t=>{let n=p(t,e);return{autoDownload:!!t.autoDownload,enabled:!!t.enabled,id:t.id,searchText:t.searchText,state:n.label}});return{generatedAt:new Date().toISOString(),rows:i,summary:r}},g=e=>{let t=[`slskr Wishlist request review`,`Generated: ${e.generatedAt}`,`Requests: ${e.summary.total}`,`Enabled: ${e.summary.enabled}`,`Automatic: ${e.summary.automatic}`,`Needs review: ${e.summary.reviewCount}`,`Quota: ${e.summary.quotaStatus} (${e.summary.quotaRemaining} remaining)`,``,`Requests:`];return e.rows.forEach(e=>{t.push(`- [${e.state}] ${e.searchText} (${e.enabled?`enabled`:`disabled`}, ${e.autoDownload?`automatic`:`manual`})`)}),t.join(`
`)},_=(e=[],{limit:t=3}={})=>e.filter(e=>e.enabled).filter(e=>e.id).slice(0,t);export{p as a,_ as i,m as n,g as r,h as t};