PageSourceSearch

https://redgo.in/assets/js/Inventory-yfjm6lZD.js

js redgo.in collected 2026-10-02 02:00:37 UTC 56,039 bytes, 9 lines download raw bytes

1import{b as _t,r as a,j as e,L as $e,t as F}from"./index-CAG7YFZd.js";import{R as Bt}from"./RestaurantNavbar-C9gkpr66.js";import{B as Et}from"./BottomNavOrders-BXBgAO3q.js";import{S as Le}from"./switch-BtXVerbm.js";import{r as q,c as Ot}from"./index-BTR0BB7t.js";import{a as Pt}from"./imageUploadUtils-BAHBaIfb.js";import{d as at}from"./dish_fallback-D6DhqKcF.js";import{m as C}from"./proxy-CEtNvAea.js";import{S as Ft}from"./search-B8wRtotC.js";import{X as nt}from"./x-BCVCJpKG.js";import{S as $t}from"./sliders-horizontal-3zDoaqnE.js";import{U as Lt}from"./upload-DvwnbQFr.js";import{C as Ht}from"./chevron-up-D7bhTQRx.js";import{C as He}from"./chevron-down-C3dIF40-.js";import{A as te}from"./index-Vzwk4whn.js";import{P as Ut}from"./pencil-DiMFwcbU.js";import{M as zt}from"./minus-3naGWe-y.js";import{P as Vt}from"./plus-pJ7MQMBn.js";import{U as Yt}from"./utensils-B53frYQ8.js";import{C as Xt}from"./chevron-left-DosUpr3J.js";import{C as Jt}from"./chevron-right-DFSfj0ll.js";import"./restaurantLocation-Du8Hbwol.js";import"./businessSettings-cyKlMK6I.js";import"./useNotificationInbox-D1Wuue8I.js";import"./useRestaurantNotifications-fEhoav24.js";import"./index-BkL6vOXg.js";import"./routes-BHmLUkwU.js";import"./trash-2-Qyy0Wnny.js";import"./circle-check-CVZUOHZZ.js";import"./bell-BZL1M968.js";import"./index.esm-BzR8oUpF.js";import"./restaurantOrderPricing-mzi3IFXw.js";import"./map-pin-DAIQP7vC.js";import"./file-text-7Q36_7-K.js";import"./package-DNWl5qPR.js";import"./message-square-CvM1eZ_A.js";import"./index-QHXycSr2.js";import"./index-CBAjRXir.js";import"./index-CSgpTPiN.js";import"./index-Dc0kaaFU.js";const ot="restaurant_inventory_state",Wt="restaurant_inventory_recommended_map",it="restaurant_inventory_active_tab",Ue="restaurant_inventory_addon_form",lt="restaurant_inventory_stock_rules_v1",ze=[{value:"all",label:"All"},{value:"in-stock",label:"In stock"},{value:"out-of-stock",label:"Out of stock"},{value:"recommended",label:"Recommended"},{value:"veg",label:"Veg"},{value:"non-veg",label:"Non-veg"}],ct=[{value:"all",label:"All"},{value:"available",label:"Available"},{value:"unavailable",label:"Unavailable"},{value:"approved",label:"Approved"},{value:"pending",label:"Pending"},{value:"rejected",label:"Rejected"}],Kt=m=>{const i=String(m||"approved").toLowerCase();return i==="rejected"?{label:"Rejected",className:"bg-red-50 text-red-700 border border-red-200"}:i==="pending"?{label:"Pending",className:"bg-amber-50 text-amber-700 border border-amber-200"}:{label:"Approved",className:"bg-emerald-50 text-emerald-700 border border-emerald-200"}},dt=m=>String(m||"").trim().toLowerCase().replace(/\./g,""),Gt=m=>{const i=String(m).trim();if(!i)return{hours:9,minutes:0};const x=i.match(/^(\d{1,2}):(\d{2})$/);if(x)return{hours:Math.max(0,Math.min(23,Number(x[1]))),minutes:Math.max(0,Math.min(59,Number(x[2])))};const p=i.match(/^(\d{1,2})(?::(\d{2}))?\s*(am|pm)$/i);if(p){let f=Number(p[1]);const k=Number(p[2]||0),v=p[3].toLowerCase();return v==="pm"&&f!==12&&(f+=12),v==="am"&&f===12&&(f=0),{hours:Math.max(0,Math.min(23,f)),minutes:Math.max(0,Math.min(59,k))}}return{hours:9,minutes:0}},Qt=m=>{const i=Math.max(1,Number(m)||1),x=new Date;return x.setHours(x.getHours()+i),x.toISOString()},qt=(m,i)=>{if(!m||!i)return null;const x=new Date(m);if(Number.isNaN(x.getTime()))return null;let p=Number(i.hour||0);const f=Number(i.minute||0),k=String(i.period||"am").toLowerCase();return k==="pm"&&p!==12&&(p+=12),k==="am"&&p===12&&(p=0),x.setHours(p,f,0,0),x.toISOString()},Zt=m=>{const i=new Date,x=Array.isArray(m?.openDays)?m.openDays.map(dt).filter(Boolean):[],p=Gt(m?.openingTime||"09:00");for(let k=1;k<=7;k+=1){const v=new Date(i);v.setDate(i.getDate()+k);const y=dt(v.toLocaleDateString("en-US",{weekday:"long"}));if(!(x.length>0&&!x.includes(y)))return v.setHours(p.hours,p.minutes,0,0),v.toISOString()}const f=new Date(i);return f.setDate(i.getDate()+1),f.setHours(p.hours,p.minutes,0,0),f.toISOString()},es=({selectedOption:m,hours:i,selectedDate:x,selectedTime:p,restaurantProfile:f})=>{const k=new Date().toISOString();if(m==="manual")return{mode:"manual",createdAt:k,resumeAt:null};if(m==="next-business-day")return{mode:"next-business-day",createdAt:k,resumeAt:Zt(f)};if(m==="custom-date-time"){const v=qt(x,p);return{mode:"custom-date-time",createdAt:k,resumeAt:v}}return{mode:"specific-time",createdAt:k,durationHours:Math.max(1,Number(i)||1),resumeAt:Qt(i)}},ts=m=>{if(!m)return"No time set. Turn item in stock manually.";if(m.mode==="manual")return"Manual off. Turn item in stock manually.";const i=new Date(m.resumeAt||"");if(Number.isNaN(i.getTime()))return"Out of stock";
1const x=i.toLocaleString("en-IN",{day:"2-digit",month:"short",hour:"numeric",minute:"2-digit",hour12:!0});return m.mode==="specific-time"?`Out of stock until ${x}`:m.mode==="next-business-day"?`Back next business day at ${x}`:m.mode==="custom-date-time"?`Out of stock until ${x}`:"Out of stock"};function ss({isOpen:m,onClose:i,initialHour:x,initialMinute:p,initialPeriod:f,onConfirm:k}){const v=Math.max(1,Math.min(12,parseInt(x)||1)),y=Math.max(0,Math.min(59,parseInt(p)||0)),M=f==="am"||f==="pm"?f:"am",[J,U]=a.useState(v),[Z,z]=a.useState(y),[d,T]=a.useState(M),_=a.useRef(null),N=a.useRef(null),R=a.useRef(null),E=a.useRef(null),B=a.useRef(!1),X=Array.from({length:12},(u,D)=>D+1),V=Array.from({length:60},(u,D)=>D),Y=["am","pm"];a.useEffect(()=>{m&&(U(v),z(y),T(M))},[m,x,p,f,v,y,M]),a.useEffect(()=>{if(m){document.body.style.overflow="hidden";const u=setTimeout(()=>{const w=80+(v-1)*40;_.current&&(_.current.scrollTop=w,U(v),setTimeout(()=>{_.current?.scrollTo({top:w,behavior:"smooth"})},50));const I=Math.max(0,Math.min(59,y)),L=80+I*40;N.current&&(N.current.scrollTop=L,z(I),setTimeout(()=>{N.current?.scrollTo({top:L,behavior:"smooth"})},50));const K=80+Y.indexOf(M)*40;R.current&&(R.current.scrollTop=K,T(M),setTimeout(()=>{R.current?.scrollTo({top:K,behavior:"smooth"})},50))},150);return()=>{clearTimeout(u),E.current&&clearTimeout(E.current),document.body.style.overflow="unset"}}},[m,v,y,M]);const W=(u,D,A,O)=>{if(!u||B.current)return;const w=80,I=u.scrollTop,L=Math.round((I-w)/O),re=Math.max(0,Math.min(L,A.length-1)),K=A[re];K!==void 0&&D(K),E.current&&clearTimeout(E.current),B.current=!0,E.current=setTimeout(()=>{const ae=Math.round((u.scrollTop-w)/O),ne=Math.max(0,Math.min(ae,A.length-1)),G=w+ne*O;u.scrollTop=G,A[ne]!==void 0&&D(A[ne]),setTimeout(()=>{u.scrollTo({top:G,behavior:"smooth"})},50),setTimeout(()=>{B.current=!1},300)},150)},se=()=>{const u=J.toString(),D=Z.toString().padStart(2,"0");k(u,D,d),i()};return m?e.jsx(te,{children:e.jsx(C.div,{initial:{opacity:0}
1,animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 bg-black/50 z-[9999] flex items-center justify-center p-4",onClick:i,children:e.jsxs(C.div,{initial:{scale:.9,opacity:0},animate:{scale:1,opacity:1},exit:{scale:.9,opacity:0},transition:{type:"spring",damping:25,stiffness:300},className:"bg-white rounded-lg shadow-2xl w-full max-w-xs overflow-hidden",onClick:u=>u.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-center py-8 px-4 relative",children:[e.jsx("style",{children:`
2              .time-picker-scroll::-webkit-scrollbar {
3                display: none;
4              }
5              .time-picker-scroll {
6                -ms-overflow-style: none;
7                scrollbar-width: none;
8              }
9            `}),e.jsx("div",{className:"flex-1 flex flex-col items-center",children:e.jsxs("div",{ref:_,className:"w-full h-48 overflow-y-scroll time-picker-scroll snap-y snap-mandatory",style:{scrollSnapType:"y mandatory",scrollBehavior:"smooth",WebkitOverflowScrolling:"touch"},onScroll:()=>W(_.current,U,X,40),onTouchEnd:()=>{setTimeout(()=>{if(_.current){const A=_.current.scrollTop,O=Math.round((A-80)/40),w=Math.max(0,Math.min(O,X.length-1)),I=80+w*40;_.current.scrollTop=I,X[w]!==void 0&&U(X[w]),setTimeout(()=>{_.current?.scrollTo({top:I,behavior:"smooth"})},50)}},100)},children:[e.jsx("div",{className:"h-20"}),X.map(u=>e.jsx("div",{className:"h-10 flex items-center justify-center snap-center",style:{minHeight:"40px"},children:e.jsx("span",{className:`text-lg transition-all duration-200 ${J===u?"font-bold text-gray-900 text-xl":"font-normal text-gray-400 text-base"}`,children:u})},u)),e.jsx("div",{className:"h-20"})]})}),e.jsx("div",{className:"px-2",children:e.jsx("span",{className:"text-2xl font-bold text-gray-900",children:":"})}),e.jsx("div",{className:"flex-1 flex flex-col items-center",children:e.jsxs("div",{ref:N,className:"w-full h-48 overflow-y-scroll time-picker-scroll snap-y snap-mandatory",style:{scrollSnapType:"y mandatory",scrollBehavior:"smooth",WebkitOverflowScrolling:"touch"},onScroll:()=>W(N.current,z,V,40),onTouchEnd:()=>{setTimeout(()=>{if(N.current){const A=N.current.scrollTop,O=Math.round((A-80)/40),w=Math.max(0,Math.min(O,V.length-1)),I=80+w*40;N.current.scrollTop=I,V[w]!==void 0&&z(V[w]),setTimeout(()=>{N.current?.scrollTo({top:I,behavior:"smooth"})},50)}},100)},children:[e.jsx("div",{className:"h-20"}),V.map(u=>e.jsx("div",{className:"h-10 flex items-center justify-center snap-center",style:{minHeight:"40px"},children:e.jsx("span",{className:`text-lg transition-all duration-200 ${Z===u?"font-bold text-gray-900 text-xl":"font-normal text-gray-400 text-base"}`,children:u.toString().padStart(2,"0")})},u)),e.jsx("div",{className:"h-20"})]})}),e.jsx("div",{className:"flex-1 flex flex-col items-center",children:e.jsxs("div",{ref:R,className:"w-full h-48 overflow-y-scroll time-picker-scroll snap-y snap-mandatory",style:{scrollSnapType:"y mandatory",scrollBehavior:"smooth",WebkitOverflowScrolling:"touch"},onScroll:()=>W(R.current,T,Y,40),onTouchEnd:()=>{setTimeout(()=>{if(R.current){const A=R.current.scrollTop,O=Math.round((A-80)/40),w=Math.max(0,Math.min(O,Y.length-1)),I=80+w*40;R.current.scrollTop=I,Y[w]!==void 0&&T(Y[w]),setTimeout(()=>{R.current?.scrollTo({top:I,behavior:"smooth"})},50)}},100)},children:[e.jsx("div",{className:"h-20"}),Y.map(u=>e.jsx("div",{className:"h-10 flex items-center justify-center snap-center",style:{minHeight:"40px"},children:e.jsx("span",{className:`text-lg transition-all duration-200 ${d===u?"font-bold text-gray-900 text-xl":"font-normal text-gray-400 text-base"}`,children:u})},u)),e.jsx("div",{className:"h-20"})]})}),e.jsxs("div",{className:"absolute left-0 right-0 top-1/2 -translate-y-1/2 pointer-events-none",children:[e.jsx("div",{className:"border-t border-gray-300 mx-4"}),e.jsx("div",{className:"border-b border-gray-300 mx-4 mt-10"})]})]}),e.jsx("div",{className:"border-t border-gray-200 px-4 py-4 flex justify-center",children:e.jsx("button",{onClick:se,className:"text-[#B80B3D] hover:text-blue-700 font-medium text-base transition-colors",children:"Okay"})})]})})}):null}function rs({selectedDate:m,onDateSelect:i,isOpen:x,onClose:p}){const[f,k]=a.useState(()=>m?new Date(m):new Date),v=a.useRef(null);a.useEffect(()=>{m&&k(new Date(m))},[m]),a.useEffect(()=>{const d=T=>{v.current&&!v.current.contains(T.target)&&p()};return x&&document.addEventListener("mousedown",d),()=>{document.removeEventListener("mousedown",d)}},[x,p]);const y=a.useMemo(()=>{const d=f.getFullYear(),T=f.getMonth(),_=new Date(d,T,1),N=new Date(_);N.setDate(N.getDate()-N.getDay()+(N.getDay()===0?-6:1));const R=[],E=new Date(N);for(let B=0;B<42;B++)R.push(new Date(E)),E.setDate(E.getDate()+1);return R},[f]),M=d=>d.getMonth()===f.getMonth(),J=d=>m?d.toDateString()===new Date(m).toDateString():!1,U=d=>d.toDateString()===new Date().toDateString(),Z=["January","February","March","April","May","June","July","August","September","October","November","December"],z=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"];return x?e.jsx(te,{children:e.jsx(C.div,{initial:{opacity:0}
9,animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 bg-black/50 z-[9998] flex items-center justify-center p-4",onClick:p,children:e.jsx(C.div,{initial:{scale:.9,opacity:0},animate:{scale:1,opacity:1},exit:{scale:.9,opacity:0},transition:{type:"spring",damping:25,stiffness:300},className:"bg-white rounded-lg shadow-2xl w-full max-w-sm overflow-hidden",onClick:d=>d.stopPropagation(),ref:v,children:e.jsxs("div",{className:"p-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("button",{onClick:()=>{const d=new Date(f);d.setMonth(d.getMonth()-1),k(d)},className:"p-1 hover:bg-gray-100 rounded",children:e.jsx(Xt,{className:"w-5 h-5"})}),e.jsxs("h3",{className:"text-lg font-semibold",children:[Z[f.getMonth()]," ",f.getFullYear()]}),e.jsx("button",{onClick:()=>{const d=new Date(f);d.setMonth(d.getMonth()+1),k(d)},className:"p-1 hover:bg-gray-100 rounded",children:e.jsx(Jt,{className:"w-5 h-5"})})]}),e.jsx("div",{className:"grid grid-cols-7 gap-1 mb-2",children:z.map(d=>e.jsx("div",{className:"text-center text-xs font-medium text-gray-500 py-2",children:d},d))}),e.jsx("div",{className:"grid grid-cols-7 gap-1",children:y.map((d,T)=>{const _=M(d),N=J(d),R=U(d);return e.jsx("button",{onClick:()=>{i(new Date(d)),p()},className:`h-10 text-sm rounded transition-colors ${_?N?"bg-gradient-to-br from-[#B80B3D] to-[#66001D] text-white":R?"bg-[#f9f0f7] text-[#B80B3D] font-semibold":"text-gray-700 hover:bg-gray-100":"text-gray-300"}`,children:d.getDate()},T)})})]})})})}):null}function Ys(){const m=_t(),[i,x]=a.useState(()=>{try{return typeof window>"u"?"all-items":localStorage.getItem(it)||"all-items"}catch{return"all-items"}}),[p,f]=a.useState(""),[k,v]=a.useState(!1),[y,M]=a.useState("all"),[J,U]=a.useState(!1),[Z,z]=a.useState(!1),[d,T]=a.useState(()=>{try{if(typeof window>"u")return[];const t=localStorage.getItem(ot);if(t){const s=JSON.parse(t);if(Array.isArray(s))return s}}catch{}return[]}),[_,N]=a.useState([]),[R,E]=a.useState(!1),[B,X]=a.useState(null),[V,Y]=a.useState(!1),[W,se]=a.useState(!1),[u,D]=a.use
9State("specific-time"),[A,O]=a.useState(3),[w,I]=a.useState(null),[L,re]=a.useState({hour:"2",minute:"30",period:"pm"}),[K,ae]=a.useState(!1),[ne,G]=a.useState(!1),[oe,mt]=a.useState(null),[Q,Ce]=a.useState(()=>{try{if(typeof window>"u")return{};const t=localStorage.getItem(lt),s=t?JSON.parse(t):{};return s&&typeof s=="object"?s:{}}catch{return{}}}),Ve=a.useRef({}),fe=a.useRef(null),ie=a.useRef(0),le=a.useRef(0),De=a.useRef(0),P=a.useRef(!1),he=a.useRef(0),ge=a.useRef(0),ce=a.useRef(!1),[Ye,be]=a.useState(!1),[de,Ae]=a.useState([]),[ut,Xe]=a.useState(!1),[ye,me]=a.useState(!1),[ue,Te]=a.useState(""),[ve,Re]=a.useState(""),[je,Ie]=a.useState(""),[we,Je]=a.useState(null),[H,Me]=a.useState(""),[_e,We]=a.useState(!1),[Be,as]=a.useState(()=>{try{if(typeof window>"u")return{};const t=localStorage.getItem(Wt),s=t?JSON.parse(t):{};return s&&typeof s=="object"?s:{}}catch{return{}}}),ee=["all-items","add-ons"],Ee=a.useRef(null),pt=a.useRef(null);a.useEffect(()=>{(async()=>{try{const s=await q.getCurrentRestaurant(),r=s?.data?.data?.restaurant||s?.data?.restaurant||s?.data?.data||null;mt(r)}catch{}})()},[]),a.useEffect(()=>{(async()=>{try{z(!0);const s=await q.getMenu();if(s.data&&s.data.success&&s.data.data&&s.data.data.menu){const l=(s.data.data.menu.sections||[]).map((o,g)=>{const S=[];Array.isArray(o.items)&&o.items.forEach(h=>{S.push({id:String(h.id||Date.now()+Math.random()),name:h.name||"Unnamed Item",description:h.description||"",image:h.image||"",images:h.image?[h.image]:[],price:h.price??"",variants:Array.isArray(h.variants)?h.variants:Array.isArray(h.variations)?h.variations:[],category:o.name||"",categoryId:o.categoryId||o.id||"",inStock:h.isAvailable!==void 0?h.isAvailable:!0,isAvailable:h.isAvailable!==void 0?h.isAvailable:!0,isVeg:h.foodType==="Veg",foodType:h.foodType||"Non-Veg",approvalStatus:String(h.approvalStatus||"approved").toLowerCase(),rejectionReason:h.rejectionReason||"",isRecommended:!!(h.recommended===!0||h.isRecommended===!0||h.is_recommended===!0||Be?.[String(h.id)]),stockQuantity:h.stock||"Unlimited",unit:h.itemSizeUnit||"piece",expiryDate:null,lastRestocked:null})}),Array.isArray(o.subsections)&&o.subsections.forEach(h=>{Array.isArray(h.items)&&h.items.forEach(j=>{S.push({id:String(j.id||Date.now()+Math.random()),name:j.name||"Unnamed Item",description:j.description||"",image:j.image||"",images:j.image?[j.image]:[],price:j.price??"",variants:Array.isArray(j.variants)?j.variants:Array.isArray(j.variations)?j.variations:[],category:o.name||h.name||"",categoryId:o.categoryId||o.id||"",inStock:j.isAvailable!==void 0?j.isAvailable:!0,isAvailable:j.isAvailable!==void 0?j.isAvailable:!0,isVeg:j.foodType==="Veg",foodType:j.foodType||"Non-Veg",approvalStatus:String(j.approvalStatus||"approved").toLowerCase(),rejectionReason:j.rejectionReason||"",isRecommended:!!(j.recommended===!0||j.isRecommended===!0||j.is_recommended===!0||Be?.[String(j.id)]),stockQuantity:j.stock||"Unlimited",unit:j.itemSizeUnit||"piece",expiryDate:null,lastRestocked:null})})});const b=S.length>0?S.every(h=>h.inStock):!0,$=S.length;return{id:o.id||`category-${g}`,name:o.name||"Unnamed Category",description:o.description||"",itemCount:$,inStock:b,items:S,order:o.order!==void 0?o.order:g}}),n=Date.now(),c=l.map(o=>{const g=(o.items||[]).map(S=>{const b=Q?.[String(S.id)]||null;return b&&(b.mode==="manual"||b.resumeAt&&new Date(b.resumeAt).getTime()>n)?{...S,inStock:!1,isAvailable:!1,stockRule:b}:S});return{...o,items:g,itemCount:g.length,inStock:g.length>0?g.every(S=>S.inStock):!0}});T(c),N(c.map(o=>o.id))}else T([]),N([])}catch(s){s.code!=="ERR_NETWORK"&&s.code!=="ECONNABORTED"&&!s.message?.includes("timeout")?F.error("Failed to load menu data"):s.code==="ERR_NETWORK"||s.message,T([]),N([])}finally{z(!1)}})()},[Be]);const Ke=async(t=!0)=>{try{t&&Xe(!0);
9const s=await q.getAddons(),r=s?.data?.data?.addons||s?.data?.addons||[],l=(c={})=>{const o=[c.requestedAt,c.createdAt,c.updatedAt].map($=>new Date($).getTime()).find($=>Number.isFinite($)&&$>0);if(o)return o;const S=String(c.id||"").match(/\d{10,}/);if(!S)return 0;const b=Number(S[0]);return Number.isFinite(b)?b:0},n=[...r].sort((c,o)=>l(o)-l(c));Ae(n)}catch{F.error("Failed to load add-ons"),Ae([])}finally{t&&Xe(!1)}};a.useEffect(()=>{i==="add-ons"&&Ke(!0)},[i]),a.useEffect(()=>{try{if(typeof window>"u")return;localStorage.setItem(it,i)}catch{}},[i]),a.useEffect(()=>{try{if(typeof window>"u")return;const t=localStorage.getItem(Ue);if(t){const s=JSON.parse(t);Te(s?.name||""),Re(s?.description||""),Ie(s?.price||""),s?.isOpen&&me(!0),s?.preview&&Me(s.preview)}}catch{}},[]),a.useEffect(()=>{try{if(typeof window>"u")return;const t={name:ue,description:ve,price:je,preview:H,isOpen:ye};localStorage.setItem(Ue,JSON.stringify(t))}catch{}},[ue,ve,je,H,ye]);const Ge=()=>{H&&H.startsWith("blob:")&&URL.revokeObjectURL(H),Te(""),Re(""),Ie(""),Je(null),Me(""),fe.current&&(fe.current.value=""),me(!1),localStorage.removeItem(Ue)},Qe=t=>{if(!t)return;if(!["image/png","image/jpeg","image/jpg","image/webp","image/heic","image/heif"].includes(t.type)){F.error("Invalid image type. Please use PNG, JPG, JPEG, WEBP, HEIC, or HEIF.");return}if(t.size>5*1024*1024){F.error("Image must be under 5MB.");return}H&&H.startsWith("blob:")&&URL.revokeObjectURL(H);const r=URL.createObjectURL(t);Je(t),Me(r)},xt=t=>{Qe(t.target.files?.[0]),t.target.value=""},ft=()=>{Pt({onSelectFile:Qe,fileNamePrefix:"addon-image",fallbackInputRef:fe})},ht=async()=>{if(!ue.trim()){F.error("Please enter add-on name");return}const t=parseFloat(je);if(Number.isNaN(t)||t<0){F.error("Please enter a valid price");return}We(!0);try{let s="";if(we){const l=await Ot.uploadMedia(we,{folder:"appzeto/restaurant/addons"});s=l?.data?.data?.url||l?.data?.url||""}const r={name:ue.trim(),description:ve.trim(),price:t,image:s,images:s?[s]:[]};await q.addAddon(r),F.success("Add-on submitted to admin for approval"),Ge(),me(!1),Ke(!0)}catch(s){F.error(s?.response?.data?.message||"Failed to save add-on")}finally{We(!1)}},gt=async(t,s)=>{try{await q.updateAddon(t,{isAvailable:s}),Ae(r=>r.map(l=>l.id===t?{...l,isAvailable:s}:l)),F.success(`Add-on ${s?"enabled":"disabled"} successfully`)}catch{F.error("Failed to update add-on availability")}},bt=t=>{const s=t.target;Ee.current?.contains(s)||(ie.current=t.touches[0].clientX,De.current=t.touches[0].clientY,le.current=t.touches[0].clientX,P.current=!1)},yt=t=>{if(!P.current){const s=Math.abs(t.touches[0].clientX-ie.current),r=Math.abs(t.touches[0].clientY-De.current);s>r&&s>10&&(P.current=!0)}P.current&&(le.current=t.touches[0].clientX)},vt=()=>{if(!P.current){ie.current=0,le.current=0;return}const t=ie.current-le.current;if(Math.abs(t)>50&&!Ye){const l=ee.findIndex(c=>c===i);let n=l;t>0&&l<ee.length-1?n=l+1:t<0&&l>0&&(n=l-1),n!==l&&(be(!0),setTimeout(()=>{x(ee[n]),setTimeout(()=>{be(!1)},300)},50))}ie.current=0,le.current=0,De.current=0,P.current=!1};a.useEffect(()=>{try{if(typeof window>"u")return;localStorage.setItem(ot,JSON.stringify(d))}catch{}},[d]),a.useEffect(()=>{try{if(typeof window>"u")return;localStorage.setItem(lt,JSON.stringify(Q))}catch{}},[Q]),a.useEffect(()=>{if(!Q||Object.keys(Q).length===0)return;const t=async()=>{const r=Date.now(),l=Object.entries(Q).filter(([,c])=>c?.mode!=="manual").filter(([,c])=>{const o=new Date(c?.resumeAt||"").getTime();return Number.isFinite(o)&&o<=r}).map(([c])=>c);if(l.length===0)return;const n=new Map;T(c=>c.map(o=>{let g=!1;const S=(o.items||[]).map(b=>l.includes(String(b.id))?(g=!0,n.set(String(b.id),o.id),{...b,inStock:!0,isAvailable:!0,stockRule:null}):b);return g?{...o,items:S,inStock:S.every(b=>b.inStock)}:o})),Ce(c=>{const o={...c};return l.forEach(g=>{delete o[g]}),o}),await Promise.all(l.map(async c=>{try{const o=n.get(String(c));await xe(o,c,!0)}catch{}}))};t();const s=setInterval(t,15e3);return()=>clearInterval(s)},[Q]);const jt=a.useMemo(()=>d.reduce((t,s)=>t+(s.itemCount||s.items?.length||0),0),[d]),Ne=a.useMemo(()=>i==="add-ons"?ct:oe?.pureVegRestaurant===!0?ze.filter(s=>s.value!=="veg"&&s.value!=="non-veg"):ze,[i,oe?.pureVegRestaurant]);a.useEffect(()=>{Ne.some(t=>t.value===y)||M("all")},[Ne,y]),a.useEffect(()=>{oe?.pureVegRestaurant===!0&&(y==="non-veg"||y==="veg")&&M("all")},[oe?.pureVegRestaurant,y]);const qe=(t=[],s="all")=>s==="all"?t:s==="in-stock"?t.filter(r=>r.inStock):s==="out-of-stock"?t.filter(r=>!r.inStock):s==="recommended"?t.filter(r=>r.isRecommended):s==="veg"?t.filter(r=>r.isVeg):s==="non-veg"?t.filter(r=>!r.isVeg):t,Ze=(t=[],s="all")=>s==="all"?t:s==="available"?t.filter(r=>r.isAvailable!==!1):s==="unavailable"?t.filter(r=>r.isAvailable===!1):s==="approved"?t.filter(r=>r.approvalStatus==="approved"):s==="pending"?t.filter(r=>r.approvalStatus==="pending"):s==="rejected"?t.filter(r=>r.approvalStatus==="rejected"):t,Oe=a.useMemo(()=>ze.reduce((t,s)=>(t[s.value]=d.reduce((r,l)=>r+qe(l.items||[],s.value).length,0),t),{}),[d]),Pe=a.useMemo(()=>ct.reduce((t,s)=>(t[s.value]=Ze(de,s.value).length,t),{}),[de]),Fe=a.useMemo(()=>d.map(t=>{const s=qe(t.items||[],y);return s.length===0?null:{...t,items:s,itemCount:s.length,inStock:s.every(r=>r.inStock)}}
9).filter(Boolean),[d,y]),wt=a.useMemo(()=>{const t=p.trim().toLowerCase();return t?Fe.map(s=>{const r=s.items||[],l=s.name?.toLowerCase().includes(t)||(s.description||"").toLowerCase().includes(t),n=r.filter(c=>c.name?.toLowerCase().includes(t));return!l&&n.length===0?null:{...s,items:n.length>0?n:r,itemCount:n.length>0?n.length:r.length,inStock:(n.length>0?n:r).every(c=>c.inStock)}}).filter(Boolean):Fe},[Fe,p]),Se=a.useMemo(()=>{const t=Ze(de,y),s=p.trim().toLowerCase();return s?t.filter(r=>{const l=String(r?.approvalStatus||"").toLowerCase();return String(r?.name||"").toLowerCase().includes(s)||String(r?.description||"").toLowerCase().includes(s)||l.includes(s)}):t},[de,p,y]),ke=i==="add-ons"?[]:wt,et=i==="add-ons"?Pe[y]||0:Oe[y]||0,pe=p.trim().length>0||y!=="all",Nt=t=>t.items.filter(s=>!s.inStock).length,St=()=>{U(!0),v(!1),setTimeout(()=>{U(!1)},1500)},kt=()=>{M("all"),v(!1)},xe=async(t,s,r)=>{try{if(!t)return;if(s){await q.updateFood(s,{isAvailable:!!r});return}const n=d.find(c=>c.id===t)?.items||[];await Promise.all(n.map(c=>q.updateFood(c.id,{isAvailable:!!r})))}catch(l){F.error(l?.response?.data?.message||"Failed to update availability")}},tt=(t,s,r)=>{const l=d.find(c=>c.id===s),n=Array.isArray(l?.items)?l.items:[];return t==="category"?n.map(c=>String(c.id)).filter(Boolean):r?[String(r)]:[]},st=async(t,s,r,l)=>{if(l){const n=tt(t,s,r);T(c=>c.map(o=>{if(o.id!==s)return o;const g=o.items||[];if(t==="category"){const b=g.map($=>({...$,inStock:!0,isAvailable:!0,stockRule:null}));return{...o,inStock:!0,items:b}}const S=g.map(b=>b.id===r?{...b,inStock:!0,isAvailable:!0,stockRule:null}:b);return{...o,items:S}})),Ce(c=>{const o={...c};return n.forEach(g=>{delete o[g]}),o}),t==="category"?await xe(s,null,!0):await xe(s,r,!0);return}X({type:t,categoryId:s,itemId:r}),D("specific-time"),O(3),I(null),re({hour:"2",minute:"30",period:"pm"}),ae(!1),G(!1),E(!0)},Ct=async()=>{if(!B||V)return;const{type:t,categoryId:s,itemId:r}=B,l=tt(t,s,r),n=es({selectedOption:u,hours:A,selectedDate:w,selectedTime:L,restaurantProfile:oe});if(u==="custom-date-time"){if(!n.resumeAt){F.error("Please select a valid custom date and time");return}if(new Date(n.resumeAt).getTime()<=Date.now()){F.error("Custom date & time must be in the future");return}}E(!1),X(null),Y(!0),T(c=>c.map(o=>{if(o.id!==s)return o;const g=o.items||[];if(t==="category"){const b=g.map($=>({...$,inStock:!1,isAvailable:!1,stockRule:n}));return{...o,inStock:!1,items:b}}const S=g.map(b=>b.id===r?{...b,inStock:!1,isAvailable:!1,stockRule:n}:b);return{...o,items:S}})),Ce(c=>{const o={...c};return l.forEach(g=>{o[g]=n}),o});try{t==="category"?await xe(s,null,!1):await xe(s,r,!1)}finally{Y(!1)}},Dt=()=>!B||B.type!=="category"?null:d.find(t=>t.id===B.categoryId),At=t=>
9{if(!t)return"";const s=t.getDate(),r=t.toLocaleString("en-US",{month:"short"}),l=t.getFullYear();return`${s} ${r} ${l}`},Tt=t=>{if(!t)return"";const s=t.minute.padStart(2,"0"),r=t.period.toUpperCase();return`${t.hour}:${s} ${r}`},Rt=(t,s,r)=>{re({hour:t,minute:s,period:r}),G(!1)},rt=t=>{N(s=>s.includes(t)?s.filter(r=>r!==t):[...s,t])},It=t=>{const s=Ve.current[t];s&&s.scrollIntoView&&s.scrollIntoView({behavior:"smooth",block:"start"}),window.scrollTo({top:s.offsetTop-100,behavior:"smooth"})},Mt=(t,s)=>{s?.id&&m(`/food/restaurant/hub-menu/item/${s.id}`,{state:{backTo:"/food/restaurant/inventory",item:{...s,category:t?.name||"",categoryId:t?.id||t?.categoryId||"",isAvailable:s.inStock},category:t?.name||"",categoryId:t?.id||t?.categoryId||"",groupId:t?.id||t?.categoryId||""}})};return e.jsxs("div",{className:"min-h-screen bg-[#f3f5f8] flex flex-col",children:[e.jsx("div",{className:"sticky top-0 z-50 bg-white",children:e.jsx(Bt,{showSearch:!1,showOfflineOnlineTag:!1,showNotifications:!1})}),e.jsx("div",{className:"bg-[#f3f5f8] px-4 pt-4 pb-4",children:e.jsxs("div",{ref:Ee,className:"grid grid-cols-2 gap-3",children:[e.jsxs(C.button,{onClick:()=>x("all-items"),className:`relative overflow-hidden rounded-[24px] border px-4 py-3 text-sm font-semibold ${i==="all-items"?"border-[#B80B3D] text-white shadow-[0_18px_32px_-24px_rgba(126,56,102,0.6)]":"border-[#ead6e3] bg-white/90 text-[#6d6470] shadow-[0_16px_40px_-34px_rgba(109,100,112,0.35)]"}`,animate:{scale:i==="all-items"?1.02:1},transition:{duration:.2},children:[i==="all-items"&&e.jsx(C.div,{layoutId:"activeTabBackgroun
9d",className:"absolute inset-0 rounded-[24px] bg-gradient-to-br from-[#B80B3D] to-[#66001D] -z-10",initial:!1,transition:{type:"spring",stiffness:500,damping:30}}),e.jsxs("span",{className:"relative z-10 flex min-h-7 items-center justify-center gap-2 leading-none",children:[e.jsx("span",{className:"whitespace-nowrap",children:"All items"}),e.jsx("span",{className:`inline-flex min-h-5 min-w-[24px] items-center justify-center rounded-full px-2 py-0.5 text-xs font-semibold ${i==="all-items"?"bg-white text-[#B80B3D]":"bg-[#f6ecf3] text-[#6d6470]"}`,children:jt})]})]}),e.jsxs(C.button,{onClick:()=>x("add-ons"),className:`relative overflow-hidden rounded-[24px] border px-4 py-3 text-sm font-semibold ${i==="add-ons"?"border-[#B80B3D] text-white shadow-[0_18px_32px_-24px_rgba(126,56,102,0.6)]":"border-[#ead6e3] bg-white/90 text-[#6d6470] shadow-[0_16px_40px_-34px_rgba(109,100,112,0.35)]"}`,animate:{scale:i==="add-ons"?1.02:1},transition:{duration:.2},children:[i==="add-ons"&&e.jsx(C.div,{layoutId:"activeTabBackground",className:"absolute inset-0 rounded-[24px] bg-gradient-to-br from-[#B80B3D] to-[#66001D] -z-10",initial:!1,transition:{type:"spring",stiffness:500,damping:30}}),e.jsxs("span",{className:"relative z-10 flex min-h-7 items-center justify-center gap-2 leading-none",children:[e.jsx("span",{className:"whitespace-nowrap",children:"Add ons"}),e.jsx("span",{className:`inline-flex min-h-5 min-w-[24px] items-center justify-center rounded-full px-2 py-0.5 text-xs font-semibold ${i==="add-ons"?"bg-white text-[#B80B3D]":"bg-[#f6ecf3] text-[#6d6470]"}`,children:de.length})]})]})]})}),e.jsxs("div",{ref:pt,className:"flex-1 overflow-y-auto px-4 pb-32",onTouchStart:bt,onTouchMove:yt,onTouchEnd:vt,onMouseDown:t=>{const s=t.target;Ee.current?.contains(s)||(he.current=t.clientX,ge.current=t.clientX,ce.current=!0,P.current=!1)},onMouseMove:t=>{ce.current&&(P.current||Math.abs(t.clientX-he.current)>10&&(P.current=!0),P.current&&(ge.current=t.clientX))},onMouseUp:()=>{if(ce.current&&P.current){const t=he.current-ge.current;if(Math.abs(t)>50&&!Ye){const r=ee.findIndex(n=>n===i);let l=r;t>0&&r<ee.length-1?l=r+1:t<0&&r>0&&(l=r-1),l!==r&&(be(!0),setTimeout(()=>{x(ee[l]),setTimeout(()=>be(!1),300)},50))}}ce.current=!1,P.current=!1,he.current=0,ge.current=0},onMouseLeave:()=>{ce.current=!1,P.current=!1},children:[e.jsx("div",{className:"sticky top-0 z-30 -mx-4 px-4 pb-4 bg-[#f3f5f8]/95 backdrop-blur supports-[backdrop-filter]:bg-[#f3f5f8]/80",children:e.jsxs("div",{className:"overflow-hidden rounded-[28px] border border-white/80 bg-white/90 p-4 shadow-[0_20px_48px_-34px_rgba(15,23,42,0.45)] backdrop-blur",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold text-slate-950",children:i==="add-ons"?"Search and review add-ons":"Search and manage menu inventory"}),e.jsx("p",{className:"mt-1 text-xs text-slate-500",children:i==="add-ons"?`${Se.length} add-on${Se.length!==1?"s":""} in this view`:`${ke.length} categor${ke.length!==1?"ies":"y"} and ${et} item${et!==1?"s":""} in focus`})]}),pe?e.jsx("button",{type:"button",onClick:()=>{f(""),M("all")},className:"rounded-full border border-[#e7d5e0] px-3 py-1.5 text-xs font-semibold text-[#6b4d62] transition-colors hover:border-[#d5bdd0] hover:bg-[#f9f0f7]",children:"Clear all"}):null]}),e.jsxs("div",{className:"mt-4 flex gap-2 flex-wrap",children:[e.jsxs("div",{className:"flex-1 min-w-[220px] relative",children:[e.jsx(Ft,{className:"absolute left-4 top-1/2 -translate-y-1/2 w-4 h-4 text-slate-400"}),e.jsx("input",{type:"text",value:p,onChange:t=>f(t.target.value),placeholder:i==="add-ons"?"Search add-ons by name or status":"Search categories or menu items",className:"h-12 w-full rounded-[20px] border border-[#e7d5e0] bg-[#fcf7fb] pl-11 pr-10 text-sm text-slate-900 placeholder:text-slate-400 focus:border-[#c796b8] focus:bg-white focus:outline-none"}),p?e.jsx("button",{type:"button",onClick:()=>f(""),className:"absolute right-3 top-1/2 -translate-y-1/2 rounded-full p-1 text-slate-400 transition-colors hover:bg-slate-100 hover:text-slate-700","aria-label":"Clear search",children:e.jsx(nt,{className:"w-4 h-4"})}):null]}),e.jsxs("button",{onClick:()=>v(!0),className:"relative flex h-12 items-center justify-center gap-2 rounded-[20px] border border-[#e7d5e0] bg-white px-4 text-sm font-semibold text-[#66001D] transition-colors hover:border-[#d5bdd0] hover:bg-[#f9f0f7]",children:[e.jsx($t,{className:"w-4 h-4 text-[#B80B3D]"}),e.jsx("span",{children:"Filters"}),y!=="all"&&e.jsx("span",{className:"absolute right-1.5 top-1.5 h-2.5 w-2.5 rounded-full bg-gradient-to-br from-[#B80B3D] to-[#66001D] ring-2 ring-white"})]}),i==="add-ons"&&e.jsx("button",{onClick:()=>me(t=>!t),className:"h-12 rounded-[20px] bg-gradient-to-br from-[#B80B3D] to-[#66001D] px-4 text-sm font-semibold text-white shadow-[0_18px_32px_-24px_rgba(126,56,
9102,0.7)] transition-colors hover:bg-[#66001D]",style:{minWidth:"128px"},children:ye?"Close":"Add Add-on"})]}),e.jsx("div",{className:"mt-4 flex gap-2 overflow-x-auto scrollbar-hide pb-1",children:Ne.map(t=>{const s=i==="add-ons"?Pe[t.value]||0:Oe[t.value]||0,r=y===t.value;return e.jsxs("button",{type:"button",onClick:()=>M(t.value),className:`shrink-0 rounded-full border px-3.5 py-2 text-xs font-semibold transition-colors ${r?"border-[#B80B3D] bg-gradient-to-br from-[#B80B3D] to-[#66001D] text-white shadow-[0_14px_28px_-24px_rgba(126,56,102,0.8)]":"border-[#e7d5e0] bg-[#fcf7fb] text-[#6d6470] hover:border-[#d5bdd0] hover:bg-white"}`,children:[e.jsx("span",{children:t.label}),e.jsx("span",{className:`ml-2 inline-flex min-w-[20px] items-center justify-center rounded-full px-1.5 py-0.5 text-[11px] ${r?"bg-white/20 text-white":"bg-white text-[#8a7a89]"}`,children:s})]},t.value)})})]})}),e.jsxs("div",{className:"space-y-4 mb-6",children:[i==="add-ons"&&e.jsxs(e.Fragment,{children:[ye&&e.jsx("div",{className:"bg-white border border-gray-200 rounded-lg p-4 mb-4 shadow-sm",children:e.jsxs("div",{className:"grid grid-cols-1 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Add-on Name *"}),e.jsx("input",{type:"text",value:ue,onChange:t=>Te(t.target.value),className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:ring-2 focus:ring-[#B80B3D] focus:outline-none",placeholder:"e.g., Coke, Chips"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Description"}),e.jsx("textarea",{value:ve,onChange:t=>Re(t.target.value),className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:ring-2 focus:ring-[#B80B3D] focus:outline-none resize-none",rows:3,placeholder:"Describe the add-on..."})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Price (₹) *"}),e.jsx("input",{type:"number",value:je,onChange:t=>Ie(t.target.value),className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:ring-2 focus:ring-[#B80B3D] focus:outline-none",min:"0",step:"0.01",placeholder:"0.00"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Image (1 only)"}),H&&e.jsx("div",{className:"mb-2",children:e.jsx("img",{src:H,alt:"Preview",className:"w-24 h-24 object-cover rounded border",onError:t=>t.target.style.display="none"})}),e.jsx("input",{ref:fe,type:"file",accept:"image/*",onChange:xt,className:"hidden"}),e.jsxs("button",{type:"button",onClick:ft,className:"w-full rounded-md border border-gray-300 bg-gray-50 px-3 py-3 text-left transition-colors hover:bg-gray-100",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm font-medium text-gray-900",children:[e.jsx(Lt,{className:"h-4 w-4 text-gray-500"}),we?.name||"Upload image"]}),e.jsx("span",{className:"mt-1 block text-xs text-gray-500",children:we?"Image selected successfully":"Tap to choose 1 image from your device"})]}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"PNG, JPG, WEBP, HEIC up to 5MB."})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{type:"button",onClick:()=>{Ge(),me(!1)},className:"px-4 py-2 border border-gray-300 rounded-md text-sm font-medium text-gray-700 hover:bg-gray-50",children:"Cancel"}),e.jsxs("button",{type:"button",onClick:ht,disabled:_e,className:"px-4 py-2 bg-gradient-to-br from-[#B80B3D] to-[#66001D] text-white rounded-md text-sm font-medium hover:bg-[#66001D] disabled:opacity-50 disabled:cursor-not-allowed flex items-center gap-2",children:[_e&&e.jsx($e,{className:"h-4 w-4 animate-spin"}),e.jsx("span",{children:_e?"Saving...":"Submit for approval"})]})]})]})}),ut?e.jsx("div",{className:"flex items-center justify-center py-20",children:e.jsx($e,{className:"h-8 w-8 animate-spin text-slate-400"})}):Se.length===0?e.jsx("div",{className:"rounded-[28px] border border-dashed border-slate-200 bg-white/70 px-4 py-20 text-center shadow-[0_18px_40px_-34px_rgba(15,23,42,0.35)]",children:e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-lg font-semibold text-slate-700",children:pe?"No matching add-ons foun
9d":"No add-ons available"}),e.jsx("p",{className:"mt-2 text-sm text-slate-500",children:pe?"Try changing your search or filters":"All add-ons will appear here"})]})}):e.jsx("div",{className:"space-y-4",children:Se.map(t=>e.jsx("div",{className:"rounded-[28px] border border-white/80 bg-white p-4 shadow-[0_20px_48px_-34px_rgba(15,23,42,0.45)]",children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"mb-2 flex items-center gap-2 flex-wrap",children:[e.jsx("h3",{className:"text-base font-semibold text-slate-950",children:t.name}),e.jsx("span",{className:`rounded-full px-2.5 py-1 text-[11px] font-semibold ${t.isAvailable!==!1?"bg-emerald-50 text-emerald-700":"bg-slate-100 text-slate-600"}`,children:t.isAvailable!==!1?"Live":"Paused"}),t.approvalStatus==="approved"&&e.jsx("span",{className:"rounded-full bg-green-100 px-2.5 py-1 text-[11px] font-semibold text-green-800",children:"Approved"}),t.approvalStatus==="pending"&&e.jsx("span",{className:"rounded-full bg-yellow-100 px-2.5 py-1 text-[11px] font-semibold text-yellow-800",children:"Pending"}),t.approvalStatus==="rejected"&&e.jsx("span",{className:"rounded-full bg-red-100 px-2.5 py-1 text-[11px] font-semibold text-red-800",children:"Rejected"})]}),t.description&&e.jsx("p",{className:"mb-2 text-sm leading-6 text-slate-600",children:t.description}),e.jsxs("p",{className:"text-base font-bold text-slate-950",children:["Rs. ",t.price]}),t.approvalStatus==="rejected"&&t.rejectionReason&&e.jsxs("p",{className:"mt-2 text-xs font-medium text-[#B80B3D]",children:["Reason: ",t.rejectionReason]})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[t.images&&t.images.length>0&&t.images[0]&&e.jsx("img",{src:t.images[0],alt:t.name,className:"h-20 w-20 rounded-2xl object-cover ring-1 ring-slate-200",onError:s=>{s.target.style.display="none"}}),e.jsx("div",{className:"flex items-center rounded-full bg-slate-100 px-2 py-1",children:e.jsx(Le,{checked:t.isAvailable!==!1,onCheckedChange:s=>gt(t.id,s),className:"data-[state=checked]:bg-green-600"})})]})]})},t.id))})]}),i!=="add-ons"&&!Z&&ke.length===0&&e.jsxs("div",{className:"rounded-[28px] border border-dashed border-slate-200 bg-white/70 px-6 py-16 text-center shadow-[0_18px_40px_-34px_rgba(15,23,42,0.35)]",children:[e.jsx("p",{className:"text-lg font-semibold text-slate-700",children:pe?"No matching categories or items found":"No menu categories available"}),e.jsx("p",{className:"mt-2 text-sm text-slate-500",children:pe?"Try adjusting your search or filters.":"Your menu categories will appear here once items are added."})]}),ke.map((t,s)=>{const r=_.includes(t.id),l=t.items||[];return e.jsxs(C.div,{initial:{opacity:0,y:8},animate:{opacity:J?.6:1,y:0},transition:{delay:s*.05},className:"relative overflow-hidden rounded-[30px] border border-white/80 bg-white shadow-[0_22px_52px_-36px_rgba(15,23,42,0.45)]",ref:n=>{n&&(Ve.current[t.id]=n)},children:[J&&e.jsx(C.div,{initial:{opacity:0}
9,animate:{opacity:1},className:"absolute inset-0 z-10 flex items-center justify-center rounded-[30px] bg-white/80",children:e.jsx($e,{className:"h-5 w-5 animate-spin text-slate-400"})}),e.jsx("div",{className:"cursor-pointer bg-white dark:bg-gradient-to-br from-[#B80B3D] to-[#66001D] px-6 py-5 hover:bg-slate-50/50 transition-colors",onClick:()=>rt(t.id),children:e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2 flex-wrap",children:[e.jsx("h3",{className:"text-xl font-black tracking-tight text-slate-950 dark:text-white",children:t.name}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"rounded-full bg-slate-100 dark:bg-gray-800 px-3 py-1 text-[10px] font-black uppercase tracking-wider text-slate-500",children:[t.items?.length||t.itemCount||0," items"]}),e.jsx("span",{className:`rounded-full px-3 py-1 text-[10px] font-black uppercase tracking-wider ${t.inStock?"bg-green-50 text-green-700 border border-green-100":"bg-amber-50 text-amber-700 border border-amber-100"}`,children:t.inStock?"Healthy":"Needs attention"})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3 mt-4",children:[t.inStock?e.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-1.5 bg-green-50/50 rounded-xl border border-green-100/50",children:[e.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-green-500 animate-pulse"}),e.jsx("p",{className:"text-[10px] font-bold text-green-700",children:"All items live"})]}):e.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-1.5 bg-rose-50/50 rounded-xl border border-rose-100/50",children:[e.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-rose-500"}),e.jsxs("p",{className:"text-[10px] font-bold text-rose-700",children:[Nt(t)," Items paused"]})]}),e.jsx("div",{className:"flex items-center gap-1.5 px-3 py-1.5 bg-blue-50/50 rounded-xl border border-blue-100/50",children:e.jsxs("p",{className:"text-[10px] font-bold text-blue-700",children:[l.filter(n=>n.isRecommended).length," Recommended"]})})]})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{onClick:n=>n.stopPropagation(),className:"scale-110",children:e.jsx(Le,{checked:t.inStock,onCheckedChange:n=>st("category",t.id,null,n),className:"data-[state=checked]:bg-green-500"})}),e.jsx("button",{onClick:n=>{n.stopPropagation(),rt(t.id)},className:`w-10 h-10 flex items-center justify-center rounded-xl border transition-all ${r?"bg-gradient-to-br from-[#B80B3D] to-[#66001D] border-slate-900 text-white":"bg-white border-slate-200 text-slate-600 hover:bg-slate-50"}`,children:r?e.jsx(Ht,{className:"h-5 w-5"}):e.jsx(He,{className:"h-5 w-5"})})]})]})}),e.jsx(te,{children:r&&e.jsx(C.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.3,ease:"circOut"},className:"overflow-hidden bg-slate-50/30",children:e.jsx("div",{className:"space-y-4 px-6 pb-6 pt-2",children:l.map(n=>{const c=Kt(n.approvalStatus),o=n.approvalStatus==="rejected";return e.jsx("div",{className:"group px-1",children:e.jsxs("div",{className:"flex items-center justify-between gap-3 sm:gap-4 rounded-[28px] border border-slate-100/80 bg-white p-3 sm:p-4 shadow-[0_8px_20px_-12px_rgba(0,0,0,0.08)] hover:shadow-[0_20px_40px_-20px_rgba(0,0,0,0.12)] hover:border-slate-200 transition-all duration-500",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3 sm:gap-5",children:[e.jsx("div",{className:"w-16 h-16 sm:w-20 sm:h-20 md:w-24 md:h-24 flex-shrink-0 rounded-[20px] overflow-hidden shadow-md border-2 border-white ring-1 ring-slate-100/50 bg-slate-100",children:e.jsx("img",{src:n.image||at,alt:n.name,className:"w-full h-full object-cover transform group-hover:scale-110 transition-transform duration-700",onError:g=>{g.target.src=at}})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h4",{className:"line-clamp-1 text-sm sm:text-base md:text-lg font-black text-slate-950 tracking-tight leading-tight mb-1.5",children:n.name}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 mb-2.5",children:[e.jsxs("span",{className:`inline-flex items-center gap-1 rounded-full px-2 py-0.5 
9sm:px-2.5 sm:py-1 text-[9px] sm:text-[10px] font-black uppercase tracking-wider shadow-sm transition-all ${n.isVeg?"bg-white text-green-600 border border-green-100":"bg-white text-[#B80B3D] border border-red-100"}`,children:[e.jsx("div",{className:`h-2.5 w-2.5 sm:h-3 sm:w-3 shrink-0 rounded-[2px] border flex items-center justify-center ${n.isVeg?"border-green-600":"border-red-600"}`,children:e.jsx("div",{className:`h-1 w-1 sm:h-1.5 sm:w-1.5 rounded-full ${n.isVeg?"bg-green-600":"bg-gradient-to-br from-[#B80B3D] to-[#66001D]"}`})}),n.isVeg?"Veg":"Non-veg"]}),e.jsx("span",{className:`rounded-full px-2 py-0.5 sm:px-2.5 sm:py-1 text-[9px] sm:text-[10px] font-black uppercase tracking-wider border shadow-sm ${c.className.replace("text-","text-").replace("bg-","bg-white border-")}`,children:c.label})]}),e.jsxs("div",{className:"flex items-center gap-3 sm:gap-4 mt-1",children:[e.jsx("p",{className:`text-[9px] sm:text-[10px] font-black uppercase tracking-widest ${n.inStock?"text-green-500":"text-rose-500"}`,children:n.inStock?"● Live":`● ${ts(n.stockRule)}`}),e.jsxs("button",{type:"button",onClick:()=>Mt(t,n),className:`inline-flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 sm:px-3 sm:py-2 text-[9px] sm:text-[10px] font-black uppercase tracking-widest transition-all shadow-sm ${o?"bg-gradient-to-br from-[#B80B3D] to-[#66001D] text-white hover:bg-red-700":"bg-slate-100 text-slate-800 hover:bg-gradient-to-br from-[#B80B3D] to-[#66001D] hover:text-white"}`,children:[e.jsx(Ut,{className:"h-3 w-3 sm:h-3.5 sm:w-3.5"}),o?"Fix":"Edit"]})]}),n.isRecommended&&e.jsx("div",{className:"mt-2.5",children:e.jsx("span",{className:"inline-flex items-center gap-1 rounded-full px-2.5 py-1 text-[9px] sm:text-[10px] font-black uppercase tracking-wider bg-blue-50 text-blue-600 border border-blue-100 shadow-sm",children:"★ Recommended"})}),n.approvalStatus==="rejected"&&n.rejectionReason&&e.jsx("p",{className:"mt-2 text-[9px] sm:text-[10px] font-bold text-[#B80B3D] bg-red-50/50 border border-red-100/50 px-2.5 py-1 rounded-lg italic",children:n.rejectionReason})]})]}),e.jsx("div",{className:"flex shrink-0 flex-col items-center justify-center gap-3 sm:gap-4",children:e.jsx("div",{onClick:g=>g.stopPropagation(),className:"scale-100 sm:scale-125 origin-right",children:e.jsx(Le,{checked:n.inStock,onCheckedChange:g=>st("item",t.id,n.id,g),className:"data-[state=checked]:bg-green-500 scale-90 sm:scale-100"})})})]})},n.id)})})})})]},t.id)})]})]}),e.jsx(te,{children:k&&e.jsxs(e.Fragment,{children:[e.jsx(C.div,{initial:{opacity:0}
9,animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 bg-black/50 z-50",onClick:()=>v(!1)}),e.jsx(C.div,{initial:{y:"100%"},animate:{y:0},exit:{y:"100%"},transition:{type:"spring",damping:30,stiffness:300},className:"fixed bottom-0 left-0 right-0 bg-white rounded-t-2xl shadow-2xl z-50",onClick:t=>t.stopPropagation(),children:e.jsxs("div",{className:"p-6",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4 mb-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-bold text-gray-900",children:"Filters"}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:i==="add-ons"?"Refine the add-ons list by availability or approval status.":"Refine your inventory by stock state, recommendation, or food type."})]}),y!=="all"?e.jsx("span",{className:"rounded-full bg-gray-100 px-3 py-1 text-xs font-medium text-gray-700",children:"Active"}):null]}),e.jsx("div",{className:"space-y-4 mb-6",children:Ne.map(t=>{const s=i==="add-ons"?Pe[t.value]||0:Oe[t.value]||0;return e.jsxs("label",{className:"flex items-center justify-between gap-3 cursor-pointer rounded-xl border border-gray-200 px-4 py-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("input",{type:"radio",name:"filter",checked:y===t.value,onChange:()=>M(t.value),style:{accentColor:"#B80B3D"},className:"w-5 h-5 border-gray-300"}),e.jsx("span",{className:"text-base text-gray-900",children:t.label})]}),e.jsx("span",{className:"min-w-[28px] h-7 rounded-full bg-gray-100 flex items-center justify-center text-xs font-medium text-gray-700",children:s})]},t.value)})}),e.jsxs("div",{className:"flex gap-3",children:[y!=="all"&&e.jsx("button",{onClick:kt,className:"flex-1 border border-gray-300 text-gray-900 py-3 rounded-lg font-medium hover:bg-gray-50 transition-colors",children:"Clear"}),e.jsx("button",{onClick:St,className:`${y!=="all"?"flex-1":"w-full"} bg-gradient-to-br from-[#B80B3D] to-[#66001D] text-white py-3 rounded-lg font-medium hover:bg-[#66001D] transition-colors`,children:"Apply"})]})]})})]})}),e.jsx(te,{children:R&&B&&e.jsxs(e.Fragment,{children:[e.jsx(C.div,{initial:{opacity:0}
9,animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 bg-black/50 z-50",onClick:()=>E(!1)}),e.jsx(C.div,{initial:{y:"100%"},animate:{y:0},exit:{y:"100%"},transition:{type:"spring",damping:30,stiffness:300},className:"fixed bottom-0 left-0 right-0 bg-white rounded-t-2xl shadow-2xl z-50 max-h-[90vh] overflow-y-auto pb-[calc(1rem+env(safe-area-inset-bottom)+6rem)]",onClick:t=>t.stopPropagation(),children:e.jsxs("div",{className:"p-6",children:[e.jsx("h2",{className:"text-lg font-bold text-gray-900 text-center mb-6",children:B.type==="category"?"Mark sub category out of stock":"Mark item out of stock"}),B.type==="category"&&(()=>{const t=Dt();return t?e.jsxs("div",{className:"",children:[e.jsx("h3",{className:"text-base font-bold text-gray-900 mb-3",children:t.name}),e.jsxs("ul",{className:"space-y-1 text-sm text-gray-600",children:[e.jsxs("li",{children:["• ",t.name]}),e.jsxs("li",{children:["• Includes ",t.itemCount," item",t.itemCount!==1?"s":""]})]}),e.jsx("div",{className:"border-t border-gray-200 mt-4"})]}):null})(),e.jsxs("div",{className:"space-y-0 mb-6",children:[e.jsx("label",{className:"flex items-center justify-between py-4 cursor-pointer border-b border-gray-200",children:e.jsxs("div",{className:"flex items-center gap-3 flex-1",children:[e.jsx("span",{className:"text-base text-gray-900",children:"For specific time"}),u==="specific-time"&&e.jsxs("div",{className:"ml-auto py-3 flex items-center justify-center gap-4",children:[e.jsx("button",{onClick:()=>O(Math.max(1,A-1)),className:"w-8 h-8 rounded-full bg-gray-200 flex items-center justify-center hover:bg-gray-300 transition-colors",children:e.jsx(zt,{className:"w-4 h-4 text-gray-700"})}),e.jsxs("span",{className:"text-base font-medium text-gray-900 min-w-[60px] text-center",children:[A," hour",A!==1?"s":""]}),e.jsx("button",{onClick:()=>O(A+1),className:"w-8 h-8 rounded-full bg-gray-200 flex items-center justify-center hover:bg-gray-300 transition-colors",children:e.jsx(Vt,{className:"w-4 h-4 text-gray-700"})})]}),e.jsx("input",{type:"radio",name:"outOfStockOption",checked:u==="specific-time",onChange:()=>D("specific-time"),style:{accentColor:"#B80B3D"},className:"ml-auto w-5 h-5 border-gray-300"})]})}),e.jsx("label",{className:"flex items-center justify-between py-4 cursor-pointer border-b border-gray-200",children:e.jsxs("div",{className:"flex items-center gap-3 flex-1",children:[e.jsx("span",{className:"text-base text-gray-900",children:"Next business day - Opening time"}),e.jsx("input",{type:"radio",name:"outOfStockOption",checked:u==="next-business-day",onChange:()=>D("next-business-day"),style:{accentColor:"#B80B3D"},className:"ml-auto w-5 h-5 border-gray-300"})]})}),e.jsx("label",{className:"flex items-center justify-between py-4 cursor-pointer border-b border-gray-200",children:e.jsxs("div",{className:"flex items-center gap-3 flex-1",children:[e.jsx("span",{className:"text-base text-gray-900",children:"Custom date & time"}),e.jsx("input",{type:"radio",name:"outOfStockOption",checked:u==="custom-date-time",onChange:()=>D("custom-date-time"),style:{accentColor:"#B80B3D"},className:"ml-auto w-5 h-5 border-gray-300"})]})}),u==="custom-date-time"&&e.jsxs("div",{className:"ml-auto py-3 flex items-center justify-center gap-4",children:[e.jsxs("button",{onClick:()=>ae(!0),className:"flex-1 px-4 py-2.5 border border-gray-300 rounded-lg text-sm text-gray-900 bg-white hover:bg-gray-50 transition-colors flex items-center justify-between",children:[e.jsx("span",{children:w?At(w):"15 Dec 2025"}),e.jsx(He,{className:"w-4 h-4 text-gray-500"})]}),e.jsxs("button",{onClick:()=>G(!0),className:"flex-1 px-4 py-2.5 border border-gray-300 rounded-lg text-sm text-gray-900 bg-white hover:bg-gray-50 transition-colors flex items-center justify-between",children:[e.jsx("span",{children:Tt(L)}),e.jsx(He,{className:"w-4 h-4 text-gray-500"})]})]}),e.jsx("label",{className:"flex items-center justify-between py-4 cursor-pointer",children:e.jsxs("div",{className:"flex flex-col gap-1 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-base text-gray-900",children:"I will turn it on manually"}),e.jsx("input",{type:"radio",name:"outOfStockOption",checked:u==="manual",onChange:()=>D("manual"),style:{accentColor:"#B80B3D"},className:"ml-auto w-5 h-5 border-gray-300"})]}),e.jsx("p",{className:"text-sm text-gray-500",children:"Item won't be visible to customers on app till you mark it back in stock"})]})})]}),e.jsxs("div",{className:"flex gap-3 mt-6",children:[e.jsx("button",{onClick:()=>E(!1),className:"flex-1 border border-gray-300 text-gray-900 py-3 rounded-lg font-medium hover:bg-gray-50 transition-colors",children:"Back"}),e.jsx("button",{onClick:Ct,disabled:V,className:"flex-1 bg-gradient-to-br from-[#B80B3D] to-[#66001D] text-white py-3 rounded-lg font-medium hover:bg-[#66001D] transition-colors disabled:opacity-60 disabled:cursor-not-allowed",children:V?"Confirming...":"Confirm"})]})]})})]})}),e.jsx(rs,{selectedDate:w,onDateSelect:I,isOpen:K,onClose:()=>ae(!1)}),e.jsx(ss,{isOpen:ne,onClose:()=>G(!1),initialHour:L.hour,initialMinute:L.minute,initialPeriod:L.period,onConfirm:Rt}),i!=="add-ons"&&e.jsxs("div",{className:"fixed right-4 bottom-24 z-30 flex flex-col items-end gap-2",children:[e.jsx(C.button,{whileTap:{scale:.96},onClick:()=>m("/food/restaurant/hub-menu/item/new",{state:{backTo:"/food/restaurant/inventory"}}),className:"rounded-full bg-gradient-to-br from-[#B80B3D] to-[#66001D] px-5 py-3 text-sm font-semibold text-white shadow-[0_22px_40px_-24px_rgba(126,56,
9102,0.72)]",children:"+ Add item"}),e.jsxs(C.button,{type:"button",whileTap:{scale:.96},onClick:()=>se(t=>!t),className:"flex items-center gap-2 rounded-full border border-[#ead6e3] bg-white/95 px-4 py-3 text-sm font-semibold text-[#66001D] shadow-[0_18px_36px_-28px_rgba(126,56,102,0.45)]",children:[e.jsx("span",{className:"w-5 h-5 flex items-center justify-center",children:W?e.jsx(nt,{className:"w-4 h-4 text-[#66001D]"}):e.jsx(Yt,{className:"w-4 h-4 text-[#B80B3D]"})}),e.jsx("span",{children:W?"Close":"Menu"})]}),e.jsx(te,{children:W&&e.jsxs(e.Fragment,{children:[e.jsx(C.div,{className:"fixed inset-0 bg-black/50/40 z-30",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},onClick:()=>se(!1)}),e.jsx(C.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:20},transition:{duration:.2},className:"fixed right-4 bottom-36 z-30 h-[45vh] w-[60vw] max-w-sm overflow-hidden rounded-[28px] border border-[#ead6e3] bg-white shadow-[0_24px_60px_-30px_rgba(126,56,102,0.45)]",children:e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsx("div",{className:"bg-[linear-gradient(135deg,#fcf4f9_0%,#f6e8f1_100%)] px-4 pt-4 pb-3",children:e.jsx("p",{className:"text-sm font-semibold text-[#66001D]",children:"Jump to category"})}),e.jsx("div",{className:"mx-4 h-px bg-slate-200"}),e.jsx("div",{className:"flex-1 overflow-y-auto px-4 py-2 space-y-1",children:d.map((t,s)=>{const r=t.itemCount||t.items?.length||0,l=s===d.length-1;return e.jsxs("button",{type:"button",onClick:()=>{se(!1),setTimeout(()=>It(t.id),200)},className:"w-full text-left py-3 focus:outline-none",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm font-medium text-slate-900",children:t.name}),e.jsx("span",{className:"flex h-7 min-w-[28px] items-center justify-center rounded-full border border-slate-200 bg-slate-50 text-xs font-semibold text-slate-700",children:r})]}),!l&&e.jsx("div",{className:"mt-3 border-t border-dashed border-slate-200"})]},t.id)})})]})})]})})]}),e.jsx(Et,{})]})}export{Ys 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.