import{j as l,B as n,b as e,s as u,H as S,bn as d,ac as z,R as T,aK as B,r as m,o as _,p as $,aq as H,T as j,d as R}from"./index-CYy8zBsj.js";import{d as W}from"./ArrowBack-DFpOyFDr.js";import{d as V}from"./Edit-YQ_1L3Tp.js";import{d as A,a as E}from"./Refresh-nkVHn998.js";const D=({title:i,subtitle:r,status:o,statusColor:s="default",extraChips:a,onBack:c,onEdit:p,showEdit:x=!0,onPrint:h,rightActions:f,sx:g})=>l(n,{sx:{px:3,pt:2.5,pb:1.5,display:"flex",alignItems:"flex-start",justifyContent:"space-between",...g},children:[l(n,{sx:{display:"flex",alignItems:"center",gap:1.5},children:[l(n,{children:[e(u,{variant:"h5",fontWeight:600,sx:{lineHeight:1.3},children:i}),r&&e(u,{variant:"caption",color:"text.secondary",component:"div",children:r})]}),o&&e(S,{label:o,color:s,size:"small"}),a]}),l(n,{sx:{display:"flex",gap:1,alignItems:"center",flexShrink:0,mt:.25},children:[c&&e(d,{variant:"outlined",size:"small",startIcon:e(W,{}),onClick:c,children:"Back"}),h&&e(d,{variant:"outlined",size:"small",startIcon:e(z,{}),onClick:h,children:"Print"}),p&&x&&e(d,{variant:"outlined",size:"small",startIcon:e(V,{}),onClick:p,children:"Edit"}),f]})]}),G=({stats:i,actions:r,sx:o})=>{const s=i.filter(a=>!a.hidden);return l(n,{sx:a=>({flexShrink:0,backgroundColor:a.palette.background.paper,borderTop:`1px solid ${a.palette.divider}`,px:3,py:1.5,display:"flex",alignItems:"center",justifyContent:"space-between",...o}),children:[e(n,{sx:{display:"flex",alignItems:"center",gap:3,flexWrap:"wrap"},children:s.map((a,c)=>l(T.Fragment,{children:[a.dividerBefore&&e(B,{orientation:"vertical",flexItem:!0,sx:{mx:.5}}),l(n,{children:[e(u,{variant:"caption",color:"text.secondary",sx:{display:"block",lineHeight:1.2},children:a.label}),a.highlight?typeof a.value=="string"||typeof a.value=="number"?e(u,{variant:"h6",color:"primary",fontWeight:700,sx:{fontVariantNumeric:"tabular-nums",lineHeight:1.3},children:a.value}):a.value:typeof a.value=="string"||typeof a.value=="number"?e(u,{variant:"body2",fontWeight:600,sx:{fontVariantNumeric:"tabular-nums"},children:a.value}):a.value]})]},c))}),r&&e(n,{sx:{display:"flex",gap:1,alignItems:"center",flexShrink:0},children:r})]})},M=({onSearch:i,onRefresh:r,onClear:o,onCreate:s,createLabel:a="Create",createButton:c,exportButton:p,extraActions:x,searchPlaceholder:h="Search by customer, number, status...",resetKey:f,debounceMs:g=400})=>{const[y,v]=m.useState(""),t=m.useRef(null);m.useEffect(()=>{f!==void 0&&v("")},[f]),m.useEffect(()=>()=>{t.current&&clearTimeout(t.current)},[]);const I=w=>{const C=w.target.value;v(C),t.current&&clearTimeout(t.current),t.current=setTimeout(()=>i(C),g)},k=()=>{t.current&&clearTimeout(t.current),v(""),i("")},b={height:36,whiteSpace:"nowrap",flexShrink:0};return l(n,{display:"flex",alignItems:"center",mb:2,gap:1.5,sx:{flexWrap:"nowrap"},children:[e(j,{size:"small",placeholder:h,value:y,onChange:I,InputProps:{endAdornment:y?e(_,{position:"end",children:e($,{size:"small","aria-label":"clear search",onClick:k,edge:"end",children:e(H,{fontSize:"small"})})}):void 0},sx:{width:320,flexShrink:0,"& .MuiOutlinedInput-root":{height:36}}}),e(n,{sx:{flexGrow:1}}),p,x,e(d,{variant:"outlined",size:"small",startIcon:e(A,{}),onClick:r,sx:b,children:"Refresh"}),e(d,{variant:"outlined",size:"small",color:"warning",startIcon:e(E,{}),onClick:o,sx:b,children:"Clear All"}),c??(s?e(d,{variant:"contained",size:"small",startIcon:e(R,{}),onClick:s,sx:b,children:a}):null)]})};export{D as C,G as a,M as b};
