1import{_ as X,u as ee,A as te,B as se,C as ne,f as oe,c as p,b as V,a as e,t as o,e as r,d as w,n as y,g as ae,q as ie,v as re,F as $,m as S,z as le,h as B,l as v,D as de,o as h,p as ce}from"./index-DXXaIO4Q.js";import{a as ue,u as pe,D as ve,T as he}from"./TheNav-DGX4d0WG.js";import{u as fe}from"./useItemName-B_jGkcaH.js";import"./apiHouseholds-BnXH0EVw.js";const me={class:"inventory-view"},ye={class:"main"},ge={class:"page-head"},_e={class:"title"},we={class:"sub"},ke={class:"stat-grid"},xe={class:"head"},De={class:"big"},Ce={class:"delta"},be={class:"change"},Me={class:"head"},Ne={class:"big"},Be={class:"delta"},Te={class:"change"},Ie={class:"head"},Le={class:"big"},Fe={class:"delta"},Ve={class:"change"},$e={class:"cat-strip-wrap"},Se={class:"cat-strip-label"},Ee={class:"cat-strip"},je={class:"cat-pill-body"},Pe={class:"cat-pill-name"},He={class:"cat-pill-count"},Ae={class:"cat-pill-body"},ze={class:"cat-pill-name"},Oe={class:"cat-pill-count"},Re={class:"cat-pill-body"},qe={class:"cat-pill-name"},Ge={class:"cat-pill-count"},Qe={class:"cat-pill-body"},Ze={class:"cat-pill-name"},Ye={class:"cat-pill-count"},Ue={class:"cat-pill-body"},Je={class:"cat-pill-name"},Ke={class:"cat-pill-count"},We={class:"inv-toolbar"},Xe={class:"search-input"},et={width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round",style:{color:"var(--text-mute)","flex-shrink":"0"}},tt=["placeholder"],st={class:"inv-toolbar chips-row"},nt=["onClick"],ot={class:"chip-n"},at={class:"items-section"},it={class:"items-head"},rt={class:"items-head-title"},lt={class:"items-head-count"},dt={key:0,class:"no-items"},ct={key:1,class:"item-list"},ut=["onClick"],pt={class:"item-info"},vt={class:"item-name"},ht={class:"item-meta"},ft={class:"item-cat-badge"},mt={key:0},yt={key:1,style:{opacity:"0.5"}},gt=["disabled","onClick","title"],_t={__name:"Inventory",setup(wt){const{t:a}=ee(),{tName:E,tCat:j}=fe(),T=te(),{data:d}=se(v(()=>T.user?.householdId)),{mutate:P,isPending:H}=ne(),{data:A}=ue(),z=v(()=>A.value?.find(t=>t.id===T.user?.householdId)?.name??"â"),O=pe(),R=le(),b=de(),c=B("all"),k=B(""),M=["expiring","freshest","name","nameDesc"],f=B("expiring"),q=()=>{const s=M.indexOf(f.value);f.value=M[(s+1)%M.length]},G=v(()=>f.value==="freshest"?a("app.inventory.sortFreshest"):f.value==="name"?a("app.inventory.sortName"):f.value==="nameDesc"?a("app.inventory.sortNameDesc"):a("app.inventory.sortExpiring")),Q=s=>b.push({name:s}),g=s=>b.push({name:"app-category",params:{catId:s}}),Z=s=>b.push({name:"app-item",params:{id:s}}),m=s=>{if(!s)return null;const t=new Date(s);return Number.isNaN(t.getTime())?null:t},x=v(()=>{if(!d.value)return 0;const s=new Date;return d.value.filter(t=>{const n=m(t.expiryDate);return n!==null&&n<s}).length}),D=v(()=>{if(!d.value)return 0;const s=new Date,t=new Date(s.getTime()+4320*60*1e3);return d.value.filter(n=>{const i=m(n.expiryDate);return i!==null&&i>=s&&i<=t}).length}),I=v(()=>{if(!d.value)return 0;const s=new Date(new Date().getTime()+4320*60*1e3);return d.value.filter(t=>{const n=m(t.expiryDate);return n!==null&&n>s}).length}),Y=s=>{if(!s)return"ok";const t=new Date,n=new Date(t.getTime()+4320*60*1e3),i=new Date(s);return i<t?"danger":i<=n?"warn":"ok"},U=[{id:"fridge",name:"Fridge"},{id:"pantry",name:"Pantry"},{id:"leftovers",name:"Leftovers"},{id:"produce",name:"Fruits & Veggies"},{id:"dairy",name:"Dairy"}],J=(s,t,n="")=>{const i=(t||"").toLowerCase(),l=(n||"").toLowerCase(),u=C=>C.some(F=>i.includes(F)||l.includes(F));return s==="fridge"?u(["fridge","meat","fish","poultry","chicken","beef","ham","pork","turkey","salmon","tuna"]):s==="pantry"?u(["pantry","dry","bakery","bread","snack","cereal","grain","pasta","rice","penne","spaghetti","flour","oat","oil","noodle","granola","cracker","massa"]):s==="leftovers"?u(["leftover","sobras","cooked","restos"]):s==="produce"?u(["produce","fruit","vegeta","veggie","vegetable","apple","banana","spinach","tomato","carrot","lettuce","avocado","pepper","broccoli","grape","strawberry"]):s==="dairy"?u(["dairy","milk","cheese","yogurt","egg","butter","cream","mozzarella"]):!1},_=v(()=>U.map(s=>{const t=d.value?.filter(u=>J(s.id,u.category,u.name))||[],n=new Date,i=new Date(n.getTime()+4320*60*1e3),l=t.filter(u=>{const C=m(u.expiryDate);return C!==null&&C<=i}).length;return{...s,itemCount:t.length,expiring:l}})),L=v(()=>d.value?.length??0),K=v(()=>[{id:"all",label:a("app.inventory.filterAll"),n:L.value},{id:"expired",label:a("app.inventory.filterExpired"),n:x.value}
1,{id:"soon",label:a("app.inventory.filterSoon"),n:D.value},{id:"fresh",label:a("app.inventory.filterFresh"),n:I.value}]),N=v(()=>{if(!d.value)return[];let s=[...d.value];if(k.value.trim()){const i=k.value.trim().toLowerCase();s=s.filter(l=>(l.name||"").toLowerCase().includes(i)||(l.category||"").toLowerCase().includes(i))}const t=new Date,n=new Date(t.getTime()+4320*60*1e3);return c.value==="expired"?s=s.filter(i=>{const l=m(i.expiryDate);return l!==null&&l<t}):c.value==="soon"?s=s.filter(i=>{const l=m(i.expiryDate);return l!==null&&l>=t&&l<=n}):c.value==="fresh"&&(s=s.filter(i=>{const l=m(i.expiryDate);return l!==null&&l>n})),f.value==="name"?s.sort((i,l)=>(i.name||"").localeCompare(l.name||"")):f.value==="nameDesc"?s.sort((i,l)=>(l.name||"").localeCompare(i.name||"")):f.value==="freshest"?s.sort((i,l)=>i.expiryDate?l.expiryDate?new Date(l.expiryDate)-new Date(i.expiryDate):1:-1):s.sort((i,l)=>i.expiryDate?l.expiryDate?new Date(i.expiryDate)-new Date(l.expiryDate):-1:1),s}),W=s=>s?new Date(s).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"}):null;return oe(()=>{O.initTheme();const s=R.query.filter;(s==="expired"||s==="soon"||s==="fresh")&&(c.value=s)}),(s,t)=>(h(),p("div",me,[V(ve),e("main",ye,[e("div",ge,[e("div",null,[e("h1",_e,o(r(a)("app.inventory.title")),1),e("p",we,[w(o(r(a)("app.inventory.subtitlePart1")),1),e("b",null,o(z.value),1),w(o(r(a)("app.inventory.subtitlePart2")),1)])])]),e("div",ke,[e("div",{class:y(["stat expired",{active:c.value==="expired"}]),onClick:t[0]||(t[0]=n=>c.value="expired")},[e("div",xe,[t[10]||(t[10]=e("span",{class:"dot"},null,-1)),e("span",null,o(r(a)("app.inventory.expired")),1)]),e("div",De,o(x.value),1),e("div",Ce,[e("span",be,o(x.value>0?r(a)("app.inventory.expiredCount",{n:x.value}):r(a)("app.inventory.noneExpired")),1)])],2),e("div",{class:y(["stat soon",{active:c.value==="soon"}]),onClick:t[1]||(t[1]=n=>c.value="soon")},[e("div",Me,[t[11]||(t[11]=e("span",{class:"dot"},null,-1)),e("span",null,o(r(a)("app.inventory.soon")),1)]),e("div",Ne,o(D.value),1),e("div",Be,[e("span",Te,o(D.value>0?r(a)("app.inventory.soonCount",{n:D.value}):r(a)("app.inventory.allGood")),1)])],2),e("div",{class:y(["stat fresh",{active:c.value==="fresh"}]),onClick:t[2]||(t[2]=n=>c.value="fresh")},[e("div",Ie,[t[12]||(t[12]=e("span",{class:"dot"},null,-1)),e("span",null,o(r(a)("app.inventory.fresh")),1)]),e("div",Le,o(I.value),1),e("div",Fe,[e("span",Ve,o(r(a)("app.inventory.freshCount",{n:L.value})),1)])],2)]),e("div",$e,[e("div",Se,o(r(a)("app.inventory.browseByCategory")),1),e("div",Ee,[e("button",{class:"cat-pill",onClick:t[3]||(t[3]=n=>g("fridge"))},[t[13]||(t[13]=e("div",{class:"cat-pill-ico"},[e("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.6","stroke-linecap":"round","stroke-linejoin":"round"},[e("rect",{x:"6",y:"2.5",width:"12",height:"19",rx:"2"}),e("path",{d:"M6 10h12M9 6v1.5M9 13v2.5"})])],-1)),e("div",je,[e("div",Pe,o(r(a)("app.inventory.catFridge")),1),e("div",He,o(_.value[0].itemCount),1)])]),e("button",{class:"cat-pill",onClick:t[4]||(t[4]=n=>g("pantry"))},[t[14]||(t[14]=ae('<div class="cat-pill-ico" data-v-afd2f2da><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" data-v-afd2f2da><path d="M8 4h8l-1 4H9L8 4Z" data-v-afd2f2da></path><rect x="7" y="8" width="10" height="13" rx="1.5" data-v-afd2f2da></rect><path d="M10 13h4" data-v-afd2f2da></path></svg></div>',1)),e("div",Ae,[e("div",ze,o(r(a)("app.inventory.catPantry")),1),e("div",Oe,o(_.value[1].itemCount),1)])]),e("button",{class:"cat-pill",onClick:t[5]||(t[5]=n=>g("leftovers"))},[t[15]||(t[15]=e("div",{class:"cat-pill-ico"},[e("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.6","stroke-linecap":"round","stroke-linejoin":"round"},[e("path",{d:"M3 14a9 9 0 0 1 18 0M2 17h20M12 10v2"})])],-1)),e("div",Re,[e("div",qe,o(r(a)("app.inventory.catLeftovers")),1),e("div",Ge,o(_.value[2].itemCount),1)])]),e("button",{class:"cat-pill",onClick:t[6]||(t[6]=n=>g("produce"))},[t[16]||(t[16]=e("div",{class:"cat-pill-ico"},[e("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.6","stroke-linecap":"round","stroke-linejoin":"round"},[e("path",{d:"M12 7c-4 0-7 3-7 7 0 4 3 7 7 7s7-3 7-7c0-4-3-7-7-7Z"}),e("path",{d:"M12 7s.5-3 3-4M12 7c-1-1.5-2-2-3-2"})])],-1)),e("div",Qe,[e("div",Ze,o(r(a)("app.inventory.catProduce")),1),e("div",Ye,o(_.value[3].itemCount),1)])]),e("button",{class:"cat-pill",onClick:t[7]||(t[7]=n=>g("dairy"))},[t[17]||(t[17]=e("div",{class:"cat-pill-ico"},[e("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.6","stroke-linecap":"round","stroke-linejoin":"round"},[e("path",{d:"M9 3h6v3l2 4v10a1 1 0 0 1-1 1H8a1 1 0 0 1-1-1V10l2-4V3Z"}),e("path",{d:"M7 12h10"})])],-1)),e("div",Ue,[e("div",Je,o(r(a)("app.inventory.catDairy")),1),e("div",Ke,o(_.value[4].itemCount),1)])])])]),e("div",We,[e("div",Xe,[(h(),p("svg",et,[...t[18]||(t[18]=[e("circle",{cx:"11",cy:"11",r:"7"},null,-1),e("path",{d:"m20 20-3.5-3.5"},null,-1)])])),ie(e("input",{"onUpdate:modelValue":t[8]||(t[8]=n=>k.value=n),placeholder:r(a)("app.inventory.searchPlaceholder")},null,8,tt),[[re,k.value]])]),e("button",{class:"btn-secondary",onClick:t[9]||(t[9]=n=>Q("app-scan"))},[t[19]||(t[19]=e("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round"},[e("path",{d:"M4 7V5a1 1 0 0 1 1-1h2M20 7V5a1 1 0 0 0-1-1h-2M4 17v2a1 1 0 0 0 1 1h2M20 17v2a1 1 0 0 1-1 1h-2M4 12h16"})],-1)),w(" "+o(r(a)("app.inventory.scan")),1)])]),e("div",st,[(h(!0),p($,null,S(K.value,
1n=>(h(),p("button",{key:n.id,class:y(["filter-chip",{active:c.value===n.id}]),onClick:i=>c.value=n.id},[w(o(n.label)+" ",1),e("span",ot,o(n.n),1)],10,nt))),128)),t[21]||(t[21]=e("div",{style:{flex:"1"}},null,-1)),e("button",{class:y(["filter-chip sort-btn",{active:f.value!=="expiring"}]),onClick:q},[t[20]||(t[20]=e("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round"},[e("path",{d:"M3 5h18M6 12h12M10 19h4"})],-1)),w(" "+o(G.value),1)],2)]),e("div",at,[e("div",it,[e("div",rt,o(r(a)("app.inventory.allItemsSection")),1),e("div",lt,o(N.value.length)+" "+o(r(a)("app.inventory.filterAll").toLowerCase()),1)]),!r(d)||N.value.length===0?(h(),p("div",dt,o(r(d)?r(a)("app.inventory.noItemsYet"):r(a)("app.dashboard.loading")),1)):(h(),p("div",ct,[(h(!0),p($,null,S(N.value,n=>(h(),p("div",{key:n.id,class:"item-row",onClick:i=>Z(n.id)},[e("span",{class:y(["item-status-dot",Y(n.expiryDate)])},null,2),e("div",pt,[e("div",vt,o(r(E)(n.name)),1),e("div",ht,[e("span",ft,o(r(j)(n.category)),1),n.expiryDate?(h(),p("span",mt,o(W(n.expiryDate)),1)):(h(),p("span",yt,o(r(a)("app.scan.noExpiry")),1))])]),e("button",{class:"item-delete-btn",disabled:r(H),onClick:ce(i=>r(P)(n.id),["stop"]),title:r(a)("app.inventory.deleteItem")},[...t[22]||(t[22]=[e("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[e("path",{d:"M3 6h18M8 6V4h8v2M19 6l-1 14H6L5 6"})],-1)])],8,gt)],8,ut))),128))]))])]),V(he)]))}},bt=X(_t,[["__scopeId","data-v-afd2f2da"]]);export{bt as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.