sevago-library 1.6.44 → 1.6.45

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # sevago-library
2
2
 
3
+ ## 1.6.45
4
+
5
+ ### Patch Changes
6
+
7
+ - enhance notification component system with module support and indentity
8
+
3
9
  ## 1.6.44
4
10
 
5
11
  ### Patch Changes
package/dist/index.cjs.js CHANGED
@@ -259,6 +259,6 @@ To suppress this warning, you need to explicitly provide the \`palette.${e}Chann
259
259
  background-size: 20px 20px;
260
260
  background-position: 0 0;
261
261
  }
262
- `,Os={wrapper:"transform-component-module_wrapper__SPB86",content:"transform-component-module_content__FBWxo",infiniteGrid:"transform-component-module_infiniteGrid__Z-aP3"};PB(MB);var RB=function(A){var e=A.children,t=A.wrapperClass,o=t===void 0?"":t,r=A.contentClass,i=r===void 0?"":r,s=A.wrapperStyle,a=A.contentStyle,l=A.wrapperProps,u=l===void 0?{}:l,d=A.contentProps,p=d===void 0?{}:d,g=A.infinite,h=g===void 0?!1:g,m=F.useContext(os),f=m.init,C=m.cleanupWindowEvents,b=F.useRef(null),q=F.useRef(null),x=F.useRef(null);return F.useEffect(function(){var y=b.current,w=q.current;return y!==null&&w!==null&&f&&(f==null||f(y,w)),function(){C==null||C()}},[]),F.useEffect(function(){if(h){var y=x.current;if(y){var w=function(){var E=m.state,T=E.positionX,P=E.positionY;y.style.backgroundPosition="".concat(T,"px ").concat(P,"px")};return w(),m.onChange(w)}}},[h,m]),c.jsxs("div",jt({},u,{ref:b,className:"".concat(ua.wrapperClass," ").concat(Os.wrapper," ").concat(o),style:s},{children:[h&&c.jsx("div",{ref:x,className:Os.infiniteGrid,"aria-hidden":!0}),c.jsx("div",jt({},p,{ref:q,className:"".concat(ua.contentClass," ").concat(Os.content," ").concat(i),style:jt(jt({},a),{transform:m4(m.state.positionX,m.state.positionY,m.state.scale)})},{children:e}))]}))};function NB(A,e){var t=Math.max(0,Math.min(A.x+A.width,e.x+e.width)-Math.max(A.x,e.x)),o=Math.max(0,Math.min(A.y+A.height,e.y+e.height)-Math.max(A.y,e.y));return t*o}function FB(A){var e=A.elementX,t=A.elementY,o=A.elementWidth,r=A.elementHeight,i=A.scale,s=A.positionX,a=A.positionY,l=A.viewportWidth,u=A.viewportHeight,d=A.margin,p=d===void 0?0:d,g=A.threshold,h=g===void 0?0:g,m={x:-p,y:-p,width:l+2*p,height:u+2*p},f={x:e*i+s,y:t*i+a,width:o*i,height:r*i};if(h<=0){var C=f.x<m.x+m.width&&f.x+f.width>m.x,b=f.y<m.y+m.height&&f.y+f.height>m.y;return C&&b}var q=f.width*f.height;if(q<=0)return!1;var x=NB(m,f);return x/q>=h}F.forwardRef(function(A,e){var t=A.x,o=A.y,r=A.width,i=A.height,s=A.margin,a=s===void 0?0:s,l=A.threshold,u=l===void 0?0:l,d=A.placeholder,p=d===void 0?null:d,g=A.onShow,h=A.onHide,m=A.children,f=A.className,C=A.style,b=F.useContext(os),q=F.useState(!1),x=q[0],y=q[1],w=F.useRef(!1),E=F.useRef(g),T=F.useRef(h);return E.current=g,T.current=h,F.useEffect(function(){var P=function(){var M,v,B=b.wrapperComponent;if(B){var O=FB({elementX:t,elementY:o,elementWidth:r,elementHeight:i,scale:b.state.scale,positionX:b.state.positionX,positionY:b.state.positionY,viewportWidth:B.offsetWidth,viewportHeight:B.offsetHeight,margin:a,threshold:u});O!==w.current&&(w.current=O,y(O),O?(M=E.current)===null||M===void 0||M.call(E):(v=T.current)===null||v===void 0||v.call(T))}};P();var D=b.onChange(P),k;return b.wrapperComponent||(k=b.onInit(function(){return P()})),function(){D(),k==null||k()}},[b,t,o,r,i,a,u]),x?c.jsx("div",jt({ref:e,className:f,style:C},{children:m})):p?c.jsx(c.Fragment,{children:p}):null});const t1=({open:A,selectedImage:e,selectedIndex:t,imageCount:o,hasMultipleImages:r,showViewerCounter:i,canGoPrevious:s,canGoNext:a,labels:l,viewerPaperSx:u,viewerImageSx:d,onImageError:p,onClose:g,onPrevious:h,onNext:m})=>c.jsx(I.Dialog,{open:A,onClose:g,maxWidth:!1,disableScrollLock:!0,PaperProps:{sx:Et({width:"min(1120px, calc(100vw - 32px))",maxWidth:"none",overflow:"visible",backgroundColor:"transparent",boxShadow:"none"},u)},children:c.jsx(I.DialogContent,{sx:{position:"relative",padding:0,overflow:"visible",display:"grid",placeItems:"center"},children:c.jsxs(I.Box,{sx:{position:"relative",width:"100%"},children:[c.jsx(kB,{centerOnInit:!0,centerZoomedOut:!0,limitToBounds:!0,panning:{allowLeftClickPan:!0,velocityDisabled:!0},doubleClick:{mode:"reset"},children:c.jsx(RB,{wrapperStyle:{width:"100%",maxHeight:"calc(100vh - 96px)",overflow:"hidden",borderRadius:be,cursor:"grab"},contentStyle:{width:"100%",display:"flex",justifyContent:"center"},children:c.jsx(I.Box,{component:"img",src:e.src,alt:e.alt,draggable:!1,onError:p,sx:Et({display:"block",width:"100%",maxHeight:"calc(100vh - 96px)",objectFit:"contain",borderRadius:be,backgroundColor:Ue[50]},d)})})},e.src),c.jsx(r0,{icon:"close",label:l.close,onClick:g,sx:{top:wA,right:wA}}),r&&c.jsxs(c.Fragment,{children:[c.jsx(r0,{icon:"chevron_left",label:l.previous,disabled:!s,onClick:h,sx:{left:Oe,top:"50%",transform:"translateY(-50%)"}}),c.jsx(r0,{icon:"chevron_right",label:l.next,disabled:!a,onClick:m,sx:{right:Oe,top:"50%",transform:"translateY(-50%)"}})]}),i&&r&&c.jsx(ze,{content:l.counter(t+1,o),sx:cT})]})})});var ti=(A=>(A.GALLERY="gallery",A.SUMMARY="summary",A))(ti||{});const S4=({images:A,variant:e=ti.GALLERY,activeIndex:t,initialIndex:o=0,mainAspectRatio:r="16 / 9",objectFit:i="cover",thumbnailObjectFit:s="cover",thumbnailSize:a=72,summaryMaxVisible:l=4,summaryThumbnailSize:u=ur.extra_large.width,showThumbnails:d=!0,showPreviewNavigation:p=!0,showViewerCounter:g=!0,openOnMainClick:h=!0,loop:m=!0,fallbackSrc:f,activeColor:C=xe[500],borderRadius:b=tn,emptyContent:q,labels:x,mainSx:y,mainImageSx:w,summarySx:E,summaryItemSx:T,summaryCountSx:P,thumbnailListSx:D,thumbnailSx:k,viewerPaperSx:M,viewerImageSx:v,onActiveIndexChange:B,onOpenViewer:O,onCloseViewer:R,sx:N,...L})=>{const[G,U]=F.useState(()=>Ar(o,A.length)),[H,j]=F.useState(!1),J=F.useMemo(()=>uT(x),[x]),eA=F.useMemo(()=>A.map((iA,Z)=>dT(iA,Z,J)),[J,A]),$=eA.length,X=Ar(t??G,$),_=eA[X],tA=$>1,cA=e===ti.SUMMARY,sA=!cA&&tA&&d;F.useEffect(()=>{U(iA=>Ar(iA,$))},[$]);const V=F.useCallback(iA=>{if(!f)return;const Z=iA.currentTarget;Z.dataset.galleryFallback!=="true"&&(Z.dataset.galleryFallback="true",Z.src=f)},[f]),Y=F.useCallback(iA=>{const Z=Ar(iA,$),aA=eA[Z];aA&&(t==null&&U(Z),B==null||B(Z,aA))},[t,$,eA,B]),W=tA&&(m||X>0),rA=tA&&(m||X<$-1),nA=F.useCallback(()=>{W&&Y(Yd(X,-1,$,m))},[W,Y,$,m,X]),oA=F.useCallback(()=>{rA&&Y(Yd(X,1,$,m))},[rA,Y,$,m,X]),AA=F.useCallback(()=>{!_||!h||(j(!0),O==null||O(X,_))},[O,h,_,X]),uA=F.useCallback(iA=>{if(!h)return;const Z=Ar(iA,$),aA=eA[Z];aA&&(Z!==X&&(t==null&&U(Z),B==null||B(Z,aA)),j(!0),O==null||O(Z,aA))},[t,$,eA,B,O,h,X]),K=F.useCallback(()=>{j(!1),R==null||R()},[R]);return F.useEffect(()=>{if(!H||!tA)return;const iA=Z=>{Z.key==="ArrowLeft"&&(Z.preventDefault(),nA()),Z.key==="ArrowRight"&&(Z.preventDefault(),oA())};return window.addEventListener("keydown",iA),()=>window.removeEventListener("keydown",iA)},[oA,nA,tA,H]),!$||!_?c.jsx(I.Box,{...L,sx:Et({width:"100%",minHeight:180,display:"grid",placeItems:"center",borderRadius:b,border:`1px solid ${ce[300]}`,backgroundColor:Sr[50]},N),children:q}):cA?c.jsxs(I.Box,{...L,sx:Et({width:"fit-content"},N),children:[c.jsx(yT,{images:eA,maxVisible:l,thumbnailSize:u,thumbnailObjectFit:s,labels:J,summarySx:E,summaryItemSx:T,summaryCountSx:P,onOpenIndex:uA,onImageError:V}),c.jsx(t1,{open:H,selectedImage:_,selectedIndex:X,imageCount:$,hasMultipleImages:tA,showViewerCounter:g,canGoPrevious:W,canGoNext:rA,labels:J,viewerPaperSx:M,viewerImageSx:v,onImageError:V,onClose:K,onPrevious:nA,onNext:oA})]}):c.jsxs(I.Box,{...L,sx:Et({width:"100%",overflow:"hidden",borderRadius:b,border:`1px solid ${ce[300]}`,backgroundColor:Ue[50]},N),children:[c.jsx(fT,{selectedImage:_,hasMultipleImages:tA,showPreviewNavigation:p,openOnMainClick:h,mainAspectRatio:r,objectFit:i,activeColor:C,canGoPrevious:W,canGoNext:rA,labels:J,mainSx:y,mainImageSx:w,onImageError:V,onOpenViewer:AA,onPrevious:nA,onNext:oA}),sA&&c.jsx(vT,{images:eA,selectedIndex:X,thumbnailSize:a,thumbnailObjectFit:s,activeColor:C,labels:J,thumbnailListSx:D,thumbnailSx:k,onSelectIndex:Y,onImageError:V}),c.jsx(t1,{open:H,selectedImage:_,selectedIndex:X,imageCount:$,hasMultipleImages:tA,showViewerCounter:g,canGoPrevious:W,canGoNext:rA,labels:J,viewerPaperSx:M,viewerImageSx:v,onImageError:V,onClose:K,onPrevious:nA,onNext:oA})]})},cc=(A,e,t)=>Math.min(Math.max(A,e),t),uc=A=>Math.max(T0,A-lr-Yr),n1=(A,e)=>A==="left"?Yr:Math.max(Yr,e-lr-Yr),jB=(A,e)=>({side:A.x<e.width/2?"left":"right",top:cc(A.y-lr/2,T0,uc(e.height))}),o1=A=>{const e=A.split("?")[0].split("#")[0].trim();return!e||e==="/"?"/":e.endsWith("/")?e.slice(0,-1):e},LB=(A,e=[])=>{const t=o1(A);return e.some(o=>{const r=o1(o);if(r.includes("*")){const i=r.replace(/[.+?^${}()|[\]\\]/g,"\\$&").replaceAll("\\*",".*");return new RegExp(`^${i}$`).test(t)}return t===r||t.startsWith(`${r}/`)})},QB=A=>!Array.isArray(A)&&"itemNoCode"in A,UB=A=>!Array.isArray(A)&&"list"in A,E4=A=>!A||Array.isArray(A)?[]:UB(A)?A.list:QB(A)?[A]:[],I4=A=>+!!A.imageUrl+ +!!A.renderImageUrl,HB=A=>A.renderImageUrl??A.imageUrl,zB=A=>A.reduce((e,t)=>e+I4(t),0),D4=A=>{const e=[];return A.imageUrl&&e.push({id:`${A.itemNoCode}-image`,src:A.imageUrl,alt:`${A.itemNoCode} 3D`,title:"3D"}),A.renderImageUrl&&e.push({id:`${A.itemNoCode}-render`,src:A.renderImageUrl,alt:`${A.itemNoCode} Render`,title:"Render"}),e},VB=A=>A?Array.isArray(A)?A:E4(A).flatMap(D4):[],WB=()=>{const[A,e]=F.useState("");return F.useEffect(()=>{if(typeof window>"u")return;const t=()=>e(window.location.pathname),o=()=>{window.setTimeout(()=>{window.dispatchEvent(new Event(y2))},0)},r=window.history.pushState,i=window.history.replaceState;return window.history.pushState=function(...a){const l=r.apply(this,a);return o(),l},window.history.replaceState=function(...a){const l=i.apply(this,a);return o(),l},t(),window.addEventListener("popstate",t),window.addEventListener(y2,t),()=>{window.history.pushState=r,window.history.replaceState=i,window.removeEventListener("popstate",t),window.removeEventListener(y2,t)}},[]),A},GB=()=>{const[A,e]=F.useState({width:0,height:0});return F.useEffect(()=>{if(typeof window>"u")return;const t=()=>e({width:window.innerWidth,height:window.innerHeight});return t(),window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)},[]),A},YB=A=>{const[e,t]=F.useState({side:"right",top:160});return F.useEffect(()=>{A.height&&t(o=>({...o,top:cc(o.top,T0,uc(A.height))}))},[A.height]),{launcherPosition:e,setLauncherPosition:t}},KB=({label:A,position:e,viewportSize:t,onPositionChange:o,onOpen:r})=>{const i=_e.useAnimationControls(),s=F.useRef(!1),a=uc(t.height),l=n1(e.side,t.width),u=cc(e.top,T0,a);return F.useEffect(()=>{t.width&&i.start({x:l,y:u,transition:Fs})},[i,u,l,t.width]),c.jsx(Ir,{preset:!1,drag:!0,dragMomentum:!1,dragElastic:F1,"aria-label":A,title:A,onDragStart:()=>{s.current=!0},onDragEnd:(d,p)=>{const g=jB(p.point,t);o(g),i.start({x:n1(g.side,t.width),y:g.top,transition:Fs}),window.setTimeout(()=>{s.current=!1},j1)},initial:{x:l,y:u},animate:i,whileHover:{scale:1.05},whileTap:{scale:.96},onClick:()=>{s.current||r()},sx:{position:"fixed",left:0,top:0,width:lr,height:lr,zIndex:P1,borderRadius:"50%",cursor:"grab",touchAction:"none",userSelect:"none",display:"grid",placeItems:"center",background:`linear-gradient(145deg, ${ar[600]}, ${ar[900]})`},children:c.jsx(I.Box,{sx:{width:Ns,height:Ns,borderRadius:"50%",display:"grid",placeItems:"center",backgroundColor:L1,border:Q1},children:c.jsx(vA,{icon:"image_search",fill:1,sx:{color:Ue[50],fontSize:k1}})})})},XB=({activeIndex:A,items:e,onChange:t})=>{if(e.length<=1)return null;const o=zB(e);return c.jsxs(I.Stack,{gap:Cn,sx:{padding:wA,borderRadius:be,border:`1px solid ${_A[300]}`,backgroundColor:Sr[50]},children:[c.jsxs(At,{sx:{gap:wA},children:[c.jsxs(I.Typography,{children:["Tìm thấy ",e.length," mã thành phẩm"]}),c.jsxs(I.Typography,{children:[o," hình ảnh"]})]}),c.jsx(Le,{sx:{display:"grid",gridTemplateColumns:" repeat(3, minmax(0, 1fr))"},children:e.map((r,i)=>{const s=i===A,a=HB(r),l=I4(r);return c.jsx(I.ButtonBase,{"aria-label":`Chọn mã thành phẩm ${r.itemNoCode}`,onClick:()=>t(i),sx:{padding:Je,borderRadius:be,border:`1px solid ${s?xe[500]:ce[300]}`,backgroundColor:s?xe[50]:Ue[50],textAlign:"left",transition:$e,"&:hover":{borderColor:xe[500],backgroundColor:xe[50]},"&:focus-visible":{outline:`2px solid ${xe[500]}`,outlineOffset:"2px"}},children:c.jsxs(se,{sx:{width:"100%",gap:wA},children:[a&&c.jsx(nn,{url:a,sizeType:"FULL_WIDTH",size:It.AVATAR_GROUP}),c.jsxs(I.Stack,{sx:{minWidth:0,flex:1,gap:Je},children:[c.jsx(I.Typography,{sx:{...OA.textXs.semiBold,color:ce[900],overflowWrap:"anywhere"},children:r.itemNoCode}),c.jsxs(I.Typography,{sx:{color:_A[500]},children:[l," ảnh"]})]})]})},r.itemNoCode)})})]})},JB=({activeOptionIndex:A,defaultEmptyContent:e,displayLoading:t,galleryImages:o,galleryProps:r,loadingContent:i,open:s,panelTitle:a,searchContent:l,searchDebounceMs:u,searchLabel:d,searchName:p,searchPlaceholder:g,searchText:h,resultItems:m,onClose:f,onOptionChange:C,onSearchTextChange:b})=>c.jsx(Ua,{open:s,onClose:f,label:a,maxWidth:!1,sx:{width:M1,maxWidth:R1},sxContent:{maxHeight:N1},nodeContent:c.jsxs(I.Stack,{gap:wA,children:[l,c.jsx(A4,{label:d,name:p,value:h,placeholder:g,disabled:t,debounceMs:u,onChange:q=>b(q.target.value??""),searchIcon:"search"}),c.jsx(XB,{items:m,activeIndex:A,onChange:C}),c.jsx(S4,{...r,images:t&&!o.length?[]:o,emptyContent:t&&!o.length?i??c.jsx(ct,{}):e})]})}),T4=({images:A,open:e,defaultOpen:t=!1,hideLauncher:o=!1,isLoading:r=!1,searchLabel:i="Mã sản phẩm",searchPlaceholder:s="Nhập hoặc quét mã sản phẩm...",searchName:a="finishGoodItemNoCode",searchContent:l,searchDebounceMs:u=300,emptyContent:d,loadingContent:p,axiosProductManagement:g,blacklist:h,launcherLabel:m="Tra cứu hình ảnh sản phẩm",panelTitle:f="Hình ảnh thành phẩm",onOpenChange:C,onSearch:b,textEmpty:q="Không có hình ảnh 3D/render",...x})=>{const y=d??c.jsx(Fn,{content:q}),[w,E]=F.useState(""),[T,P]=F.useState(),[D,k]=F.useState(!1),[M,v]=F.useState(0),[B,O]=F.useState(t),R=F.useRef(b),N=F.useRef(0),L=WB(),G=GB(),{launcherPosition:U,setLauncherPosition:H}=YB(G),j=g?T:A,J=r||D,eA=F.useMemo(()=>E4(j),[j]),$=F.useMemo(()=>eA.length?D4(eA[M]??eA[0]):VB(j),[M,j,eA]),X=L?LB(L,h):!1,_=e??B,tA=V=>{e===void 0&&O(V),C==null||C(V)};R.current=b,F.useEffect(()=>{X&&tA(!1)},[X]),F.useEffect(()=>{v(0)},[j]);const cA=async(V=w)=>{var rA;const Y=V.trim();if(k0(Y))return;if(!g){(rA=R.current)==null||rA.call(R,Y);return}const W=N.current+1;N.current=W;try{k(!0);const nA=await q1(g,Y);if(N.current!==W)return;P(nA)}catch(nA){if(N.current!==W)return;P(void 0),console.error(nA)}finally{N.current===W&&k(!1)}},sA=V=>{E(V),cA(V)};return X||!G.width?null:c.jsxs(c.Fragment,{children:[!o&&!_&&c.jsx(KB,{label:m,position:U,viewportSize:G,onPositionChange:H,onOpen:()=>tA(!0)}),c.jsx(JB,{activeOptionIndex:M,defaultEmptyContent:y,displayLoading:J,galleryImages:$,loadingContent:p,open:_,panelTitle:f,galleryProps:x,searchContent:l,searchDebounceMs:u,searchLabel:i,searchName:a,searchPlaceholder:s,searchText:w,resultItems:eA,onClose:()=>tA(!1),onOptionChange:v,onSearchTextChange:sA})]})},ZB=({url:A,content:e,caption:t,sizeType:o=It.MEDIUM,sx:r,sxContent:i,sxCaption:s,alt:a="",userTitleName:l})=>c.jsxs(Le,{alignItems:"center",sx:{...r,gap:wA},children:[c.jsx(dt,{alt:a,url:A,size:o}),c.jsx(r4,{userTitleName:l,content:e,caption:t,sxContent:i,sxCaption:s})]}),B4=({time:A,hasText:e})=>c.jsx(I.Typography,{variant:"caption",sx:{...Ge(1),color:"text.disabled"},children:(e?"Cập nhật lúc ":"")+n3(A)}),O4=({time:A,content:e,height:t=z1})=>c.jsxs(Ae.Stack,{sx:{height:t,gap:0,justifyContent:"space-between",alignItems:"flex-start"},children:[c.jsx(ze,{content:e}),c.jsx(B4,{time:A})]}),_B=({url:A,content:e,time:t,sizeType:o=It.MEDIUM})=>c.jsxs(Le,{alignItems:"center",children:[c.jsx(dt,{url:A,size:o}),c.jsx(O4,{content:e,time:t})]}),$B=({loading:A,content:e,startIcon:t,endIcon:o,sx:r,permission:i,...s})=>i===!1?null:c.jsx(I.Button,{...s,startIcon:t&&!A&&c.jsx(nn,{url:t,sx:{width:Jn.small,height:Jn.small,borderRadius:Ls,opacity:s.disabled?.6:1}}),endIcon:o&&!A&&c.jsx(nn,{url:o,sx:{width:Jn.medium,height:Jn.medium,borderRadius:Ls,opacity:s.disabled?.6:1}}),sx:{textTransform:"none",borderRadius:Re,minWidth:"unset","& > .MuiButton-endIcon":{margin:0},...r},children:A?c.jsx(ct,{size:"small",sx:{minHeight:"24.5px"}}):c.jsx(I.Typography,{sx:{transform:"translateY(0.5px)",whiteSpace:"nowrap"},children:e})}),dc=({multiple:A=!1,onChange:e,accept:t="image/*",permission:o,loading:r=!1,...i})=>{if(o===!1)return null;const[s,a]=F.useState([]),l=F.useRef(null),u=d=>{if(d.target.files){const g=Array.from(d.target.files).map(h=>Object.assign(h,{preview:URL.createObjectURL(h)}));a(g),e(g)}};return F.useEffect(()=>()=>s==null?void 0:s.forEach(d=>{URL.revokeObjectURL(d.preview)}),[s]),c.jsxs(F.Fragment,{children:[c.jsx(I.Stack,{sx:{width:"fit-content",height:"fit-content"},children:c.jsx(So,{...i,loading:r,icon:"attach_file",onClick:()=>l.current&&l.current.click()})}),c.jsx("input",{type:"file",accept:t,hidden:!0,multiple:A,ref:l,onChange:u})]})},AO=(...A)=>A.flatMap(e=>e?Array.isArray(e)?e:[e]:[]),eO={minWidth:100,textTransform:"none",borderRadius:Re,width:"fit-content"},tO={...OA.textSm.regular,whiteSpace:"nowrap"},Qe=({content:A,loading:e=!1,startIcon:t,endIcon:o,variant:r="contained",sx:i,disabled:s=!1,...a})=>{const{palette:l}=I.useTheme();return c.jsx(I.Button,{...a,variant:r,startIcon:!e&&t?typeof t=="string"?c.jsx(vA,{icon:t,sx:{cursor:"pointer"}}):t:void 0,endIcon:!e&&o?typeof o=="string"?c.jsx(vA,{icon:o,sx:{cursor:"pointer"}}):o:void 0,sx:AO(eO,i),disabled:s,children:e?c.jsx(ct,{color:r==="contained"?l.primary.contrastText:a.color,size:"small",sx:{minHeight:"24.5px"}}):c.jsx(I.Typography,{sx:tO,children:A})})},pa=({label:A,name:e,size:t="small",sx:o,...r})=>c.jsx(I.FormControlLabel,{sx:{marginRight:0},name:e,control:c.jsx(I.Checkbox,{size:t,...r,sx:{paddingTop:0,paddingBottom:0,paddingRight:wA,borderRadius:10,"&:hover":{backgroundColor:"unset"},...o}}),label:A}),nO=({open:A,anchorEl:e,title:t="Tùy chỉnh trường",items:o,onClose:r,onToggle:i})=>c.jsx(I.Popover,{open:A,anchorEl:e,onClose:r,disableScrollLock:!0,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},slotProps:{paper:{sx:{mt:"8px",minWidth:320,maxHeight:520,borderRadius:bn,border:`1px solid ${ce[200]}`,boxShadow:"0 1px 2px rgba(15, 23, 42, 0.08), 0 1px 3px rgba(15, 23, 42, 0.1)",overflow:"hidden"}}},children:c.jsxs(I.Box,{sx:{backgroundColor:Ue[50]},children:[c.jsxs(se,{sx:{justifyContent:"space-between",padding:"12px 12px 10px 12px",borderBottom:`1px solid ${ce[200]}`},children:[c.jsx(I.Typography,{sx:{...OA.textMd.semiBold},children:t}),c.jsx(I.IconButton,{onClick:r,sx:{padding:.5},children:c.jsx(vA,{icon:"close"})})]}),c.jsx(io,{sx:{alignItems:"stretch",gap:.5,padding:"10px 8px",maxHeight:460,overflowY:"auto"},children:o.map(s=>c.jsxs(se,{sx:{justifyContent:"space-between",gap:1,padding:"8px 8px",borderRadius:Re,opacity:s.disabled?.6:1},children:[c.jsxs(se,{sx:{gap:1,minWidth:0},children:[c.jsx(vA,{icon:"drag_indicator",sx:{color:ce[400]}}),c.jsx(I.Typography,{sx:{...OA.textSm.regular,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:s.label})]}),c.jsx(I.Checkbox,{checked:s.checked,disabled:s.disabled,onChange:a=>i(s.key,a.target.checked),sx:{padding:0}})]},s.key))})]})}),oO=({headerAction:A,children:e,isCollapsible:t=!0,title:o,description:r,defaultExpanded:i=!0,sx:s,titleSx:a})=>{const[l,u]=F.useState(i),d=!!o&&t;return c.jsxs(I.Stack,{sx:{bgcolor:Ue[50],borderRadius:Re,overflow:"hidden",gap:wA,boxShadow:2,p:Oe,...s},children:[o&&c.jsxs(At,{onClick:()=>u(p=>!p),sx:{"&:hover":{cursor:"pointer"}},children:[c.jsxs(Le,{gap:wA,children:[c.jsx(ze,{content:o,sx:{...OA.textMd.semiBold,color:xe[500],...a}}),r]}),c.jsxs(se,{gap:0,children:[A,d&&c.jsx(So,{icon:l?"expand_less":"expand_more"})]})]}),c.jsx(I.Collapse,{in:!d||l,unmountOnExit:d,children:c.jsx(I.Stack,{sx:{gap:wA},children:e})})]})},rO=({orientation:A="horizontal",color:e=re.gray2,thickness:t=1,length:o="100%",sx:r,dashed:i=!0})=>A==="vertical"?c.jsx(Ae.Box,{sx:{height:o,display:"flex",justifyContent:"center",alignSelf:"center","&::before":{content:'""',width:`${t}px`,height:"100%",borderLeft:`${t}px ${i?"dashed":"solid"} ${e}`,...r}}}):c.jsx(Ae.Box,{sx:{borderBottom:`${t}px ${i?"dashed":"solid"} ${e}`,width:typeof o=="number"?`${o}px`:o,alignSelf:"stretch",display:"block",...r}}),k4="180px",fa="140px",P4="250px";var ln=(A=>(A.Equals="Equals",A.NotEquals="NotEquals",A.Contains="Contains",A.NotContains="NotContains",A.IsNull="IsNull",A.IsNotNull="IsNotNull",A.GreaterThan="GreaterThan",A.LessThan="LessThan",A.GreaterThanOrEqual="GreaterThanOrEqual",A.LessThanOrEqual="LessThanOrEqual",A))(ln||{}),Ee=(A=>(A.EXACT="EXACT",A.DATE_RANGE="DATE_RANGE",A.TODAY="TODAY",A.TOMORROW="TOMORROW",A.YESTERDAY="YESTERDAY",A.THIS_WEEK="THIS_WEEK",A.LAST_WEEK="LAST_WEEK",A.THIS_MONTH="THIS_MONTH",A.LAST_MONTH="LAST_MONTH",A.LAST_7_DAYS="LAST_7_DAYS",A.NEXT_7_DAYS="NEXT_7_DAYS",A.LAST_30_DAYS="LAST_30_DAYS",A.NEXT_30_DAYS="NEXT_30_DAYS",A))(Ee||{});const M4=[{label:"Là",value:"Equals"},{label:"Không là",value:"NotEquals"},{label:"Chứa",value:"Contains"},{label:"Không chứa",value:"NotContains"},{label:"Lớn hơn",value:"GreaterThan"},{label:"Lớn hơn hoặc bằng",value:"GreaterThanOrEqual"},{label:"Nhỏ hơn",value:"LessThan"},{label:"Nhỏ hơn hoặc bằng",value:"LessThanOrEqual"},{label:"Trống",value:"IsNull"},{label:"Không trống",value:"IsNotNull"}],R4=[{label:"Là",value:"Equals"},{label:"Không là",value:"NotEquals"},{label:"Chứa",value:"Contains"},{label:"Không chứa",value:"NotContains"},{label:"Trống",value:"IsNull"},{label:"Không trống",value:"IsNotNull"}],N4=[{label:"Là",value:"Equals"},{label:"Trống",value:"IsNull"},{label:"Không trống",value:"IsNotNull"}],F4=[{label:"ngày chính xác",value:"EXACT"},{label:"khoảng ngày",value:"DATE_RANGE"},{label:"hôm nay",value:"TODAY"},{label:"ngày mai",value:"TOMORROW"},{label:"hôm qua",value:"YESTERDAY"},{label:"tuần này",value:"THIS_WEEK"},{label:"tuần trước",value:"LAST_WEEK"},{label:"tháng này",value:"THIS_MONTH"},{label:"tháng trước",value:"LAST_MONTH"},{label:"trong 7 ngày qua",value:"LAST_7_DAYS"},{label:"trong 7 ngày tiếp theo",value:"NEXT_7_DAYS"},{label:"trong 30 ngày qua",value:"LAST_30_DAYS"},{label:"trong 30 ngày tiếp theo",value:"NEXT_30_DAYS"}],Rn=()=>typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():Math.random().toString(36).substring(2,9),j4=A=>{if(!A)return{};const e=DA().startOf("day"),t=A.split("|"),o=t[0];let r=e,i=e;if(o===Ee.EXACT){const s=t[1];if(s){const a=DA(s).startOf("day"),l=DA(s).endOf("day");return{fromDate:a.unix(),toDate:l.unix()}}return{}}if(o===Ee.DATE_RANGE){const s=t[1],a=t[2],l=s?DA(s).startOf("day").unix():void 0,u=a?DA(a).endOf("day").unix():void 0;return{fromDate:l,toDate:u}}switch(o){case Ee.TODAY:r=e.startOf("day"),i=e.endOf("day");break;case Ee.TOMORROW:r=e.add(1,"day").startOf("day"),i=e.add(1,"day").endOf("day");break;case Ee.YESTERDAY:r=e.subtract(1,"day").startOf("day"),i=e.subtract(1,"day").endOf("day");break;case Ee.THIS_WEEK:{const s=(7+(e.day()-1))%7;r=e.subtract(s,"day"),i=r.add(6,"day").endOf("day");break}case Ee.LAST_WEEK:{const s=(7+(e.day()-1))%7;r=e.subtract(s,"day").subtract(7,"day"),i=r.add(6,"day").endOf("day");break}case Ee.THIS_MONTH:r=e.startOf("month"),i=e.endOf("month");break;case Ee.LAST_MONTH:r=e.subtract(1,"month").startOf("month"),i=e.subtract(1,"month").endOf("month");break;case Ee.LAST_7_DAYS:r=e.subtract(7,"day"),i=e.endOf("day");break;case Ee.NEXT_7_DAYS:r=e,i=e.add(7,"day").endOf("day");break;case Ee.LAST_30_DAYS:r=e.subtract(30,"day"),i=e.endOf("day");break;case Ee.NEXT_30_DAYS:r=e,i=e.add(30,"day").endOf("day");break;default:return{}}return{fromDate:r.unix(),toDate:i.unix()}},iO=A=>A.reduce((e,t)=>(e[t.key]=t.defaultValue,e),{}),r1=(A,e)=>{const t=A.filter(r=>((e==null?void 0:e[r.key])??r.defaultValue)!==r.defaultValue).map(r=>({id:Rn(),fieldKey:r.key,value:(e==null?void 0:e[r.key])??r.defaultValue}));if(t.length>0)return t;const o=A[0];return o?[{id:Rn(),fieldKey:o.key,value:(e==null?void 0:e[o.key])??o.defaultValue}]:[]},sO=({open:A,title:e="Tùy chỉnh bộ lọc",fields:t,value:o,anchorEl:r,offset:i,onClose:s,onApply:a})=>{const l=F.useMemo(()=>iO(t),[t]),u=F.useMemo(()=>t.map(y=>({label:y.label,value:y.key})),[t]),[d,p]=F.useState(()=>r1(t,o)),[g,h]=F.useState(null);F.useEffect(()=>{A&&(p(r1(t,o)),h(null))},[t,A,o]);const m=()=>{const y=t[0];if(!y){p([]);return}p([{id:Rn(),fieldKey:y.key,value:y.defaultValue}])},f=y=>{p(w=>{const E=w.filter((P,D)=>D!==y);if(E.length>0)return E;const T=t[0];return T?[{id:Rn(),fieldKey:T.key,value:T.defaultValue}]:[]})},C=()=>{p(y=>{const w=new Set(y.map(T=>T.fieldKey)),E=t.find(T=>!w.has(T.key));return E?[...y,{id:Rn(),fieldKey:E.key,value:E.defaultValue}]:y})},b=y=>{g===null||y===g||(p(w=>{const E=[...w],[T]=E.splice(g,1);return E.splice(y,0,T),E}),h(null))},q=()=>{const y={...l};d.forEach(w=>{w.fieldKey&&(y[w.fieldKey]=w.value)}),a(y),s()},x=d.length<t.length;return c.jsx(I.Popover,{open:A,anchorEl:r,onClose:s,disableScrollLock:!0,anchorOrigin:{vertical:"bottom",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"left"},slotProps:{paper:{sx:{mt:`${(i==null?void 0:i.y)??8}px`,ml:`${(i==null?void 0:i.x)??0}px`,minWidth:320,maxWidth:"calc(100vw - 48px)",borderRadius:bn,border:`1px solid ${ce[300]}`,boxShadow:"0 8px 24px rgba(15, 23, 42, 0.12)",overflow:"hidden"}}},children:c.jsx(I.Box,{sx:{backgroundColor:Ue[50],padding:2},children:c.jsxs(io,{sx:{alignItems:"stretch",gap:2},children:[c.jsxs(At,{sx:{gap:1},children:[c.jsx(I.Typography,{sx:{...OA.textMd.semiBold},children:e}),c.jsx(I.IconButton,{onClick:s,sx:{padding:Je},children:c.jsx(vA,{icon:"close"})})]}),c.jsx(io,{sx:{alignItems:"stretch",gap:1.25},children:d.map((y,w)=>{const E=t.find(D=>D.key===y.fieldKey);if(!E)return null;const T=new Set(d.map(D=>D.fieldKey)),P=u.filter(D=>D.value===y.fieldKey||!T.has(D.value));return c.jsxs(se,{onDragOver:D=>D.preventDefault(),onDrop:()=>b(w),sx:{gap:1,alignItems:"flex-end"},children:[c.jsx(I.Box,{draggable:!0,onDragStart:()=>h(w),onDragEnd:()=>h(null),sx:{paddingBottom:"10px",cursor:"grab"},children:c.jsx(vA,{icon:"drag_indicator",sx:{color:ce[500]}})}),c.jsx(I.Box,{sx:{flex:1,minWidth:220},children:c.jsx(Mn,{label:"",value:y.fieldKey,options:P,placeholder:"",onChange:D=>{const k=D.target.value,M=t.find(v=>v.key===k);M&&p(v=>v.map((B,O)=>O===w?{...B,fieldKey:k,value:M.defaultValue}:B))}})}),c.jsx(I.Box,{sx:{flex:1,minWidth:220},children:c.jsx(Mn,{label:"",value:y.value??E.defaultValue,options:E.options,placeholder:"Tất cả",onChange:D=>{const k=D.target.value;p(M=>M.map((v,B)=>B===w?{...v,value:k}:v))}})}),c.jsx(I.IconButton,{onClick:()=>f(w),children:c.jsx(vA,{icon:"delete_outline"})})]},y.id)})}),x&&c.jsx(Qe,{content:"Thêm điều kiện",onClick:C,startIcon:"add",variant:"text",sx:{color:xe[500],minWidth:0,paddingX:0}}),c.jsxs(At,{sx:{marginTop:1},children:[c.jsx(Qe,{content:"Mặc định",onClick:m,variant:"text",sx:{color:xe[500],minWidth:0,paddingX:0}}),c.jsxs(se,{sx:{gap:1},children:[c.jsx(Qe,{onClick:s,variant:"outlined",content:"Hủy"}),c.jsx(Qe,{onClick:q,variant:"contained",content:"Áp dụng"})]})]})]})})})},aO=({field:A,rowValue:e,onChange:t})=>{switch(A.type){case"select":return c.jsx(Mn,{label:"",value:e??A.defaultValue,options:A.options||[],placeholder:"Tất cả",onChange:o=>t(o.target.value)});case"date":{const o=e?e.split("|"):"",r=o[0],i=r===Ee.EXACT?o[1]:"",s=r===Ee.DATE_RANGE?o[1]:"",a=r===Ee.DATE_RANGE?o[2]:"",l=r===Ee.EXACT||r===Ee.DATE_RANGE;return c.jsxs(I.Box,{sx:{display:"flex",gap:wA,width:"100%"},children:[c.jsx(I.Box,{sx:{width:l?"140px":"100%",flexShrink:0},children:c.jsx(Mn,{label:"",value:r,options:F4,placeholder:"",onChange:u=>{const d=u.target.value;let p=d;d===Ee.EXACT&&(p=`${Ee.EXACT}|`),d===Ee.DATE_RANGE&&(p=`${Ee.DATE_RANGE}||`),t(p)}})}),r===Ee.EXACT&&c.jsx(I.Box,{sx:{flex:1},children:c.jsx($f,{name:`exact-date-${Rn()}`,label:"",value:i||null,onChange:u=>{const d=u.target.value,p=d?DA(d).format("YYYY-MM-DD"):"";t(`${Ee.EXACT}|${p}`)}})}),r===Ee.DATE_RANGE&&c.jsx(I.Box,{sx:{flex:1},children:c.jsx(jf,{format:"DD/MM/YYYY",placeholder:"Ngày bắt đầu — Ngày kết thúc",label:"",fromDate:s,toDate:a,onFromDateChange:u=>{const d=u?DA(u).format("YYYY-MM-DD"):"";t(`${Ee.DATE_RANGE}|${d}|${a}`)},onToDateChange:u=>{const d=u?DA(u).format("YYYY-MM-DD"):"";t(`${Ee.DATE_RANGE}|${s}|${d}`)}})})]})}}},lO=({open:A,title:e="Tùy chỉnh bộ lọc nâng cao",fields:t,value:o,operatorOptions:r=R4,fullOperator:i=!1,anchorEl:s,offset:a,onClose:l,onApply:u})=>{const[d,p]=F.useState([]),[g,h]=F.useState(null);F.useEffect(()=>{A&&(o&&o.length>0?p(o.map(E=>({id:Rn(),fieldKey:E.field,operator:E.operator,value:E.value}))):p([]),h(null))},[A,o]);const m=(E,T)=>{p(P=>P.map((D,k)=>k===E?{...D,...T}:D))},f=()=>p([]),C=E=>p(T=>T.filter((P,D)=>D!==E)),b=()=>{p(E=>{if(E.length>=t.length)return E;const T=new Set(E.map(D=>D.fieldKey)),P=t.find(D=>!T.has(D.key))||t[0];return P?[...E,{id:Rn(),fieldKey:P.key,operator:ln.Equals,value:P.defaultValue}]:E})},q=E=>{g===null||E===g||(p(T=>{const P=[...T],[D]=P.splice(g,1);return P.splice(E,0,D),P}),h(null))},x=()=>{const E=d.filter(T=>T.fieldKey).map(T=>{const P=t.find(v=>v.key===T.fieldKey);let D,k;if((P==null?void 0:P.type)==="date"&&T.operator!==ln.IsNull&&T.operator!==ln.IsNotNull){const v=j4(T.value);D=v.fromDate,k=v.toDate}return{field:T.fieldKey,operator:T.operator,value:T.operator===ln.IsNull||T.operator===ln.IsNotNull?"":T.value,fromDate:D,toDate:k}});u(E),l()},y=t.map(E=>({label:E.label,value:E.key})),w=d.map(E=>E.fieldKey);return c.jsx(I.Popover,{open:A,anchorEl:s,onClose:l,disableScrollLock:!0,anchorOrigin:{vertical:"bottom",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"left"},slotProps:{paper:{sx:{mt:`${(a==null?void 0:a.y)??8}px`,ml:`${(a==null?void 0:a.x)??0}px`,width:"max-content",minWidth:"800px",maxWidth:"calc(100vw - 48px)",boxShadow:4,overflow:"hidden"}}},children:c.jsx(Ae.Stack,{sx:{backgroundColor:ce[50],padding:V1},children:c.jsxs(Ae.Stack,{children:[c.jsxs(At,{children:[c.jsx(I.Typography,{sx:{...OA.textMd.semiBold},children:e}),c.jsx(I.IconButton,{onClick:l,sx:{padding:Je},children:c.jsx(vA,{icon:"close"})})]}),c.jsxs(Ae.Stack,{children:[d.length===0&&c.jsx(I.Typography,{sx:{color:ce[400],fontStyle:"italic"},children:"Chưa có điều kiện lọc nào được áp dụng."}),d.map((E,T)=>{const P=t.find(B=>B.key===E.fieldKey);if(!P)return null;const D=P.type==="date";i&&(r=M4);const k=D?N4:r,M=E.operator===ln.IsNull||E.operator===ln.IsNotNull,v=y.filter(B=>!w.includes(B.value)||B.value===E.fieldKey);return c.jsxs(se,{onDragOver:B=>B.preventDefault(),onDrop:()=>q(T),sx:{gap:wA},children:[c.jsx(Ae.Stack,{draggable:!0,onDragStart:()=>h(T),onDragEnd:()=>h(null),sx:{cursor:"grab"},children:c.jsx(vA,{icon:"drag_indicator",sx:{color:ce[400]}})}),c.jsx(Ae.Stack,{sx:{width:k4},children:c.jsx(Mn,{label:"",value:E.fieldKey,options:v,placeholder:"",onChange:B=>{const O=B.target.value,R=t.find(N=>N.key===O);R&&m(T,{fieldKey:O,value:R.defaultValue,operator:ln.Equals})}})}),c.jsx(Ae.Stack,{sx:{width:fa},children:c.jsx(Mn,{label:"",value:E.operator,options:k,placeholder:"",onChange:B=>{const O=B.target.value,R=E.value;m(T,{operator:O,value:R})},sx:{width:fa}})}),c.jsx(Ae.Stack,{sx:{flex:1,minWidth:P4},children:M?c.jsx(Mn,{label:"",value:"",options:[],placeholder:"---",disabled:!0}):c.jsx(aO,{field:P,rowValue:E.value,onChange:B=>m(T,{value:B})})}),c.jsx(I.IconButton,{onClick:()=>C(T),children:c.jsx(vA,{icon:"delete_outline"})})]},E.id)})]}),d.length<t.length&&c.jsx(Qe,{content:"Thêm điều kiện",onClick:b,startIcon:"add",variant:"text"}),c.jsxs(At,{sx:{marginTop:xa},children:[c.jsx(Ae.Stack,{onClick:f,sx:{cursor:"pointer",color:xe[500]},children:"Mặc định"}),c.jsxs(se,{sx:{gap:1},children:[c.jsx(Qe,{onClick:l,variant:"outlined",content:"Hủy",sx:{borderRadius:Re}}),c.jsx(Qe,{onClick:x,variant:"contained",content:"Áp dụng",sx:{borderRadius:Re}})]})]})]})})})},cO=({children:A,onApply:e,onReset:t,initialFilters:o={},sx:r={},ignoredKeysInCount:i=[]})=>{const[s,a]=F.useState(!1),[l,u]=F.useState(o),[d,p]=F.useState(o),g=Object.entries(l).filter(([C,b])=>i.includes(C)?!1:Array.isArray(b)?b.length>0:b!=null&&b!=="").length;F.useEffect(()=>{s&&p({...l})},[l,s]);const h=(C,b)=>{p(q=>({...q,[C]:b}))},m=()=>{u(d),e==null||e(d),a(!1)},f=()=>{p({}),u({}),t==null||t(),a(!1)};return c.jsxs(F.Fragment,{children:[c.jsx(Qe,{sx:{...r,color:(g>0,xe[500]),minWidth:"auto",p:Kr},startIcon:"filter_list_alt",variant:"outlined",onClick:()=>a(!0),content:`Bộ lọc${g>0?` (${g})`:""}`}),c.jsx(I.Drawer,{anchor:"right",open:s,onClose:()=>a(!1),sx:{"& .MuiDrawer-paper":{width:320,padding:Oe}},children:c.jsxs(Ae.Stack,{sx:{height:"100%"},children:[c.jsxs(At,{sx:{gap:0},children:[c.jsx(ze,{content:"Bộ lọc",sx:{...OA.textLg.semiBold}}),c.jsx(I.IconButton,{onClick:()=>a(!1),children:c.jsx(vA,{icon:"close"})})]}),c.jsx(Ae.Stack,{sx:{flex:1,gap:wA,overflowY:"auto",scrollbarWidth:"none","&::-webkit-scrollbar":{display:"none"}},children:A({filters:l,tempFilters:d,setFilter:h,setTempFilters:p})}),c.jsxs(E3,{sx:{gap:wA},children:[c.jsx(Qe,{variant:"outlined",onClick:f,content:"Đặt lại"}),c.jsx(Qe,{variant:"contained",onClick:m,content:"Cập nhật"})]})]})})]})},Nt=56,i1=42,s1=26,uO=12,k2=18,rs=76,dO=160,a1={type:"spring",stiffness:520,damping:34},pO=A=>(Nt+uO)*(A+1),pc=(A,e,t)=>Math.min(Math.max(A,e),t),ni=A=>Math.max(rs,A-Nt-k2),l1=(A,e)=>A==="left"?k2:Math.max(k2,e-Nt-k2),fO=(A,e)=>({side:A.x<e.width/2?"left":"right",top:pc(A.y-Nt/2,rs,ni(e.height))}),gO=(A,e,t)=>({position:"absolute",right:0,bottom:t?pO(e):0,width:Nt,height:Nt,borderRadius:"50%",opacity:t?1:0,pointerEvents:t?"auto":"none",transform:t?"scale(1)":"scale(0.82)",transition:`bottom ${$e}, opacity ${$e}, transform ${$e}`,backgroundColor:A.backgroundColor??Ue[50],border:`2px solid ${xe[200]}`,boxShadow:"0 10px 24px rgba(0, 0, 0, 0.2)","&:hover":{borderColor:xe[500],transform:t?"scale(1.04)":"scale(0.82)"},"&:focus-visible":{outline:`2px solid ${xe[300]}`,outlineOffset:"2px"}}),mO=()=>{const[A,e]=F.useState({width:0,height:0});return F.useEffect(()=>{if(typeof window>"u")return;const t=()=>e({width:window.innerWidth,height:window.innerHeight});return t(),window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)},[]),A},hO=A=>{const[e,t]=F.useState(null);return F.useEffect(()=>{!A.width||!A.height||t(o=>o?{...o,top:pc(o.top,rs,ni(A.height))}:{side:"right",top:ni(A.height)})},[A.width,A.height]),{position:e,setPosition:t}},L4=({closeOnActionClick:A=!0,items:e,launcherIcon:t="chat",launcherLabel:o="Công cụ",sx:r})=>{const[i,s]=F.useState(!1),a=_e.useAnimationControls(),l=F.useRef(!1),u=mO(),{position:d,setPosition:p}=hO(u),g=!!u.width&&!!u.height&&!!d,h=d?l1(d.side,u.width):0,m=d?pc(d.top,rs,ni(u.height)):0,f=r&&!Array.isArray(r)&&typeof r=="object"?r:void 0;F.useEffect(()=>{!d||!u.width||a.start({x:h,y:m,transition:a1})},[a,d,m,h,u.width]);const C=c.jsxs(I.Stack,{sx:{position:"relative",width:Nt,height:Nt},children:[e.map((b,q)=>c.jsx(I.ButtonBase,{"aria-label":b.label,title:b.label,disabled:b.disabled,onClick:()=>{A&&s(!1),b.onClick()},sx:gO(b,q,i),children:c.jsx(vA,{icon:b.icon,fill:1,sx:{color:b.color??xe[700],fontSize:s1}})},b.key)),c.jsx(I.ButtonBase,{"aria-label":o,title:o,onClick:()=>{l.current||s(b=>!b)},sx:{position:"absolute",right:0,bottom:0,width:Nt,height:Nt,borderRadius:"50%",backgroundColor:Ue[50],border:`2px solid ${xe[200]}`,boxShadow:"0 10px 24px rgba(0, 0, 0, 0.22)","&:hover":{borderColor:xe[500]},"&:focus-visible":{outline:`2px solid ${xe[300]}`,outlineOffset:"2px"}},children:c.jsx(I.Box,{sx:{width:i1,height:i1,borderRadius:"50%",display:"grid",placeItems:"center",backgroundColor:xe[700],transform:i?"scale(0.96)":"scale(1)",transition:$e},children:c.jsx(vA,{icon:i?"close":t,fill:1,sx:{color:Ue[50],fontSize:s1}})})})]});return!g||!d?null:c.jsx(Ir,{preset:!1,drag:!0,dragMomentum:!1,dragElastic:.08,onDragStart:()=>{l.current=!0},onDragEnd:(b,q)=>{const x=fO(q.point,u);p(x),a.start({x:l1(x.side,u.width),y:x.top,transition:a1}),window.setTimeout(()=>{l.current=!1},dO)},initial:{x:h,y:m},animate:a,whileHover:{scale:1.05},whileTap:{scale:.96},sx:{position:"fixed",left:0,top:0,width:Nt,height:Nt,zIndex:1400,cursor:"grab",touchAction:"none",userSelect:"none",...f},children:C})},fc=9600,Q4=20;var YA=(A=>(A.Idle="idle",A.Connecting="connecting",A.Connected="connected",A.Disconnecting="disconnecting",A.Error="error",A))(YA||{}),is=(A=>(A.None="none",A.Even="even",A.Odd="odd",A))(is||{}),U4=(A=>(A.None="none",A.Hardware="hardware",A))(U4||{});const c1="sevago:web-serial-scale-active-window",u1=300,CO=500,bO=20,ks=()=>{if(!(typeof navigator>"u"))return navigator.serial},d1=()=>typeof window>"u"?!1:window.isSecureContext,p1=A=>{const e=A instanceof DOMException?A.name:A instanceof Error?A.constructor.name:"Unknown",t=A instanceof Error?A.message:String(A);return`[${e}] ${t}`},yO=A=>A.map((e,t)=>({index:t,label:`Cân ${t+1}`})),vO=(A,e)=>{var o;const t=(o=A.getInfo)==null?void 0:o.call(A);return!(!t||e.usbVendorId!=null&&t.usbVendorId!==e.usbVendorId||e.usbProductId!=null&&t.usbProductId!==e.usbProductId)},xO=(A,e)=>{const t=e==null?void 0:e.filters;return t!=null&&t.length?A.filter(o=>t.some(r=>vO(o,r))):A},H4=A=>{const e=A.match(/[-+]?\d+(?:[.,]\d+)?/);if(!e)return;const t=e[0].replace(",","."),o=Number(t);return{rawLine:A,value:t,numericValue:Number.isFinite(o)?o:void 0,receivedAt:Date.now()}},gc=({serialOptions:A,requestOptions:e,lineLimit:t=Q4,autoConnectAuthorized:o=!1,autoSwitchActiveWindow:r=!1,parseReading:i=H4,onReading:s,onStatusChange:a,onError:l})=>{const[u,d]=F.useState(YA.Idle),[p,g]=F.useState("Chưa kiểm tra"),[h,m]=F.useState(""),[f,C]=F.useState([]),[b,q]=F.useState(),[x,y]=F.useState([]),[w,E]=F.useState(!1),[T,P]=F.useState(!1),D=F.useRef(void 0),k=F.useRef(void 0),M=F.useRef(void 0),v=F.useRef(void 0),B=F.useRef(!0),O=F.useRef(0),R=F.useRef(YA.Idle),N=F.useRef(!1),L=F.useRef(`web-serial-scale-${Date.now()}-${Math.random().toString(36).slice(2)}`),G=F.useRef(!1),U=F.useCallback(V=>{R.current=V,d(V),a==null||a(V)},[a]),H=F.useCallback(V=>{m(V),l==null||l(V)},[l]),j=F.useCallback(async()=>{if(G.current){G.current=!1;return}if(!r||typeof BroadcastChannel>"u")return;const V=new BroadcastChannel(c1);V.postMessage({senderId:L.current,type:"claim"}),await new Promise(Y=>{window.setTimeout(Y,u1)}),V.close()},[r]),J=F.useCallback(V=>{if(!V.trim())return;C(nA=>[...nA.slice(-(Math.max(t,1)-1)),V]);const Y=i(V);if(!(Y!=null&&Y.value))return;const W=Y.receivedAt??Date.now(),rA={...Y,rawLine:Y.rawLine??V,receivedAt:W};q(rA),s==null||s(rA)},[t,s,i]),eA=F.useCallback(async(V,Y)=>{if(!V.readable)return;const W=new TextDecoderStream;M.current=V.readable.pipeTo(W.writable).catch(()=>{});const rA=W.readable.getReader();k.current=rA;let nA="";try{for(;!B.current&&O.current===Y;){const{value:oA,done:AA}=await rA.read();if(AA)break;if(!oA)continue;nA+=oA;const uA=nA.split(/\r?\n/);nA=uA.pop()??"",uA.forEach(J)}}catch(oA){if(!B.current&&O.current===Y){const AA=p1(oA);H(AA),U(YA.Error)}}finally{try{rA.releaseLock()}catch{}k.current===rA&&(k.current=void 0)}},[J,H,U]),$=F.useCallback(async()=>{B.current=!0,O.current+=1;const V=k.current;if(V)try{await V.cancel()}catch{}if(v.current)try{await v.current}catch{}if(M.current)try{await M.current}catch{}const Y=D.current;if(Y)try{await Y.close()}catch{}k.current=void 0,M.current=void 0,v.current=void 0,D.current=void 0},[]),X=F.useCallback(async V=>{try{await V.open(A);return}catch(Y){if(!(Y instanceof DOMException)||Y.name!=="InvalidStateError")throw Y;D.current=V,await $(),await V.open(A)}},[$,A]),_=F.useCallback(async()=>{const V=ks();if(!V)return y([]),[];const Y=xO(await V.getPorts(),e);return y(yO(Y)),Y},[e]),tA=F.useCallback(async V=>{if(R.current===YA.Connecting||R.current===YA.Disconnecting)return;const Y=ks(),W=d1();if(E(!!Y),P(W),g(Y?"navigator.serial: có":"navigator.serial: không"),!W){H("Web Serial API cần HTTPS hoặc localhost để trình duyệt cho phép truy cập cổng COM."),U(YA.Error);return}if(!Y){H("Trình duyệt không hỗ trợ Web Serial API. Hãy dùng Chrome hoặc Edge."),U(YA.Error);return}q(void 0),U(YA.Connecting),m("");try{await j(),await $();const rA=V!=null&&V.useAuthorizedPort?await _():[],nA=rA[(V==null?void 0:V.authorizedPortIndex)??0]??rA[0];if(V!=null&&V.useAuthorizedPort&&rA.length===0){if(!V.silentNoAuthorizedPort){H("Chưa có cổng cân nào được trình duyệt cấp quyền. Hãy bấm Kết nối cân trước."),U(YA.Error);return}U(YA.Idle);return}const oA=nA??await Y.requestPort(e);nA||await _(),await X(oA),D.current=oA,B.current=!1,O.current+=1,U(YA.Connected),v.current=eA(oA,O.current)}catch(rA){await $(),H(p1(rA)),U(YA.Error)}},[$,X,eA,_,e,j,H,U]),cA=F.useCallback(async()=>{if(!D.current&&R.current!==YA.Error){U(YA.Idle);return}U(YA.Disconnecting),q(void 0),await $(),U(YA.Idle)},[$,U]),sA=F.useCallback(()=>{C([])},[]);return F.useEffect(()=>{const V=ks(),Y=d1();E(!!V),P(Y),g(V?"navigator.serial: có":"navigator.serial: không"),_()},[_]),F.useEffect(()=>{if(!o){N.current=!1;return}if(N.current)return;N.current=!0,(async()=>{(await _()).length===1&&tA({useAuthorizedPort:!0,authorizedPortIndex:0,silentNoAuthorizedPort:!0})})()},[o,tA,_]),F.useEffect(()=>{if(!r||typeof window>"u"||typeof document>"u")return;let V,Y=0;const W=typeof BroadcastChannel>"u"?void 0:new BroadcastChannel(c1),rA=()=>{V&&(window.clearTimeout(V),V=void 0)},nA=()=>document.visibilityState!=="hidden"&&document.hasFocus(),oA=async()=>(await _()).length!==1?!1:(G.current=!0,await tA({useAuthorizedPort:!0,authorizedPortIndex:0,silentNoAuthorizedPort:!0}),R.current===YA.Connected),AA=(aA=u1)=>{nA()&&(R.current===YA.Connected||R.current===YA.Connecting||R.current===YA.Disconnecting||(rA(),V=window.setTimeout(async()=>{if(await oA()||!nA()){Y=0;return}if(Y+=1,Y>bO){Y=0;return}AA(CO)},aA)))},uA=()=>{rA(),Y=0,!(R.current!==YA.Connected&&R.current!==YA.Connecting&&R.current!==YA.Error)&&cA()},K=()=>{nA()&&(W==null||W.postMessage({senderId:L.current,type:"claim"}),AA())},iA=()=>{if(document.visibilityState==="hidden"){uA();return}K()},Z=aA=>{aA.data.senderId!==L.current&&aA.data.type==="claim"&&uA()};return W==null||W.addEventListener("message",Z),window.addEventListener("focus",K),window.addEventListener("blur",uA),document.addEventListener("visibilitychange",iA),K(),()=>{rA(),W==null||W.removeEventListener("message",Z),W==null||W.close(),window.removeEventListener("focus",K),window.removeEventListener("blur",uA),document.removeEventListener("visibilitychange",iA)}},[r,tA,cA,_]),F.useEffect(()=>()=>{$()},[$]),{status:u,supportInfo:p,error:h,lines:f,reading:b,authorizedPorts:x,isSupported:w,isSecureContext:T,connect:tA,disconnect:cA,clearLines:sA}},qO=({targets:A=[],defaultTargetName:e,selectedTargetName:t,defaultBaudRate:o=fc,defaultAutoApply:r=!0,applyLatestOnTargetChange:i=!0,autoApplyIntervalMs:s=0,autoConnectAuthorized:a=!0,autoSwitchActiveWindow:l=!1,allowRequestPort:u=!0,lineLimit:d,requestOptions:p,onReading:g,onApply:h,sx:m})=>{const[f,C]=F.useState(e??""),b=F.useRef(void 0),q=F.useRef(void 0),x=F.useRef(void 0),y=F.useMemo(()=>Array.isArray(m)?m:m?[m]:[],[m]),w=t??f,E=F.useMemo(()=>A.find(L=>L.name===w),[w,A]),T=F.useMemo(()=>({baudRate:o,dataBits:8,stopBits:1,parity:is.None}),[o]),{status:P,reading:D,authorizedPorts:k,connect:M,disconnect:v}=gc({serialOptions:T,requestOptions:p,lineLimit:d,autoConnectAuthorized:a,autoSwitchActiveWindow:l,onReading:g}),B=P===YA.Connected,O=P===YA.Connecting||P===YA.Disconnecting,R=F.useCallback(L=>{t===void 0&&C(L)},[t]),N=F.useCallback(async()=>{var G;if(!B||!E||!(D!=null&&D.value)||E.disabled)return;const L=Date.now();if(q.current!==D.value&&!(b.current&&L-b.current<s))try{b.current=L,q.current=D.value,await((G=E.onApply)==null?void 0:G.call(E,D)),h==null||h(D,E)}catch{}},[E,s,B,h,D]);return F.useEffect(()=>{if(!A.length){R("");return}if(E||!e)return;const L=A.find(G=>G.name===e);L&&R(L.name)},[E,e,R,A]),F.useEffect(()=>{!r||!(D!=null&&D.receivedAt)||b.current===D.receivedAt||N()},[N,r,D==null?void 0:D.receivedAt]),F.useEffect(()=>{x.current!==w&&(x.current=w,!(!r||!i||!(D!=null&&D.value))&&N())},[w,i,N,r,D==null?void 0:D.value]),c.jsxs(se,{sx:[{gap:wA,flexWrap:"wrap"},...y],children:[B?c.jsx(Qe,{content:"Ngắt kết nối",startIcon:"link_off",variant:"outlined",color:"error",loading:O,disabled:O,onClick:()=>v()}):null,!B&&k.length===1?c.jsx(gn,{content:`Kết nối ${k[0].label} đã được trình duyệt cấp quyền.`,children:c.jsx(Qe,{content:k[0].label,startIcon:"scale",variant:"outlined",loading:O,disabled:O,onClick:()=>M({useAuthorizedPort:!0,authorizedPortIndex:k[0].index})})}):null,!B&&k.length>1?k.map(L=>c.jsx(gn,{content:`Kết nối ${L.label}`,children:c.jsx(Qe,{content:L.label,startIcon:"scale",variant:"outlined",loading:O,disabled:O,onClick:()=>M({useAuthorizedPort:!0,authorizedPortIndex:L.index})})},L.index)):null,!B&&u?c.jsx(gn,{content:"Kết nối cân mới trong danh sách cân đã được cấp quyền truy cập.",children:c.jsx(Qe,{content:P===YA.Connecting?"Đang kết nối...":k.length?"Kết nối cân khác":"Kết nối cân",startIcon:"usb",loading:O,disabled:O,onClick:()=>M()})}):null]})},z4=F.createContext(void 0),wO=A=>{const e=(A==null?void 0:A.targets)??[];if(e.length)return e.find(t=>t.name===(A==null?void 0:A.selectedTargetName))??e[0]},V4=({autoConnectAuthorized:A=!0,autoSwitchActiveWindow:e=!0,children:t,defaultBaudRate:o=fc,enabled:r=!0,lineLimit:i,onError:s,onReading:a,onStatusChange:l,parseReading:u,requestOptions:d,serialOptions:p})=>{const g=F.useRef(void 0),h=F.useRef(void 0),m=F.useMemo(()=>p??{baudRate:o,dataBits:8,stopBits:1,parity:is.None},[o,p]),f=gc({autoConnectAuthorized:r&&A,autoSwitchActiveWindow:r&&e,lineLimit:i,onError:s,onReading:a,onStatusChange:l,parseReading:u,requestOptions:d,serialOptions:m}),{disconnect:C,status:b}=f;F.useEffect(()=>{r||(g.current=void 0,h.current=void 0,(b===YA.Connected||b===YA.Connecting||b===YA.Error)&&C().catch(()=>{}))},[C,r,b]);const q=F.useCallback(w=>(g.current=w,h.current=void 0,()=>{g.current===w&&(g.current=void 0,h.current=void 0)}),[]),x=F.useCallback(async w=>{var D,k;if(!r)return;const E=g.current;if(!E||E.enabled===!1||E.defaultAutoApply===!1||!w.value)return;const T=wO(E);if(!T||T.disabled)return;const P=h.current;(P==null?void 0:P.targetName)===T.name&&P.value===w.value||(h.current={targetName:T.name,value:w.value},await((D=T.onApply)==null?void 0:D.call(T,w)),await((k=E.onApply)==null?void 0:k.call(E,w,T)))},[r]);F.useEffect(()=>{var w;(w=f.reading)!=null&&w.receivedAt&&x(f.reading).catch(()=>{})},[x,f.reading]);const y=F.useMemo(()=>({...f,registerTargets:q}),[q,f]);return c.jsx(z4.Provider,{value:y,children:t})},ss=()=>F.useContext(z4),SO=A=>{const e=ss();return F.useEffect(()=>{if(!(!e||A.enabled===!1))return e.registerTargets(A)},[e,A]),!!e},EO=({emptyContent:A="Chưa khởi tạo kết nối cân dùng chung.",sx:e})=>{const t=ss(),o=Array.isArray(e)?e:e?[e]:[];if(!t)return c.jsx(ze,{content:A,sx:{color:_A[600]}});const r=t.status===YA.Connected,i=t.status===YA.Connecting||t.status===YA.Disconnecting,s=r?"Đã kết nối cân":t.status===YA.Connecting?"Đang kết nối cân...":"Chưa kết nối cân";return c.jsxs(I.Stack,{sx:[{gap:wA},...o],children:[c.jsx(ze,{content:s,sx:{...OA.textSm.semiBold,color:r?to[700]:_A[700]}}),t.error?c.jsx(ze,{content:t.error,sx:{...OA.textXs.regular,color:Ft[700]}}):null,c.jsxs(se,{sx:{gap:wA,flexWrap:"wrap"},children:[r?c.jsx(Qe,{content:"Ngắt kết nối",startIcon:"link_off",variant:"outlined",color:"error",loading:i,disabled:i,onClick:()=>t.disconnect()}):null,!r&&t.authorizedPorts.length===1?c.jsx(gn,{content:`Kết nối ${t.authorizedPorts[0].label} đã được trình duyệt cấp quyền.`,children:c.jsx(Qe,{content:t.authorizedPorts[0].label,startIcon:"scale",variant:"outlined",loading:i,disabled:i,onClick:()=>t.connect({useAuthorizedPort:!0,authorizedPortIndex:t.authorizedPorts[0].index})})}):null,!r&&t.authorizedPorts.length>1?t.authorizedPorts.map(a=>c.jsx(gn,{content:`Kết nối ${a.label}`,children:c.jsx(Qe,{content:a.label,startIcon:"scale",variant:"outlined",loading:i,disabled:i,onClick:()=>t.connect({useAuthorizedPort:!0,authorizedPortIndex:a.index})})},a.index)):null,r?null:c.jsx(Qe,{content:t.status===YA.Connecting?"Đang kết nối...":"Kết nối cân",startIcon:"usb",loading:i,disabled:i,onClick:()=>t.connect()})]})]})},IO=({axiosProductManagement:A,enableFinishGoodGallery:e=!0,enableScale:t=!0,items:o=[],scaleAutoConnectAuthorized:r=!0})=>{const i=ss(),[s,a]=F.useState(!1),l=F.useRef(void 0),u=F.useRef(!1),d=(i==null?void 0:i.status)===YA.Connected,p=(i==null?void 0:i.status)===YA.Idle,g=(i==null?void 0:i.status)===YA.Connecting||(i==null?void 0:i.status)===YA.Disconnecting;F.useEffect(()=>{t||(l.current=void 0,u.current=!1)},[t]),F.useEffect(()=>{if(!t||!r||u.current||!i||!p||i.authorizedPorts.length!==1)return;const m=i.authorizedPorts[0],f=`${m.index}:${m.label}`;l.current!==f&&(l.current=f,i.connect({useAuthorizedPort:!0,authorizedPortIndex:m.index,silentNoAuthorizedPort:!0}))},[t,p,i,r]);const h=F.useMemo(()=>{const m=[];return t&&m.push({key:"scale",label:d?"Ngắt kết nối cân":"Kết nối cân",icon:"scale",disabled:!i||g,backgroundColor:d?to[50]:void 0,color:d?to[700]:void 0,onClick:()=>{if(!(!i||g)){if(d){u.current=!0,i.disconnect();return}if(u.current=!1,i.authorizedPorts.length){i.connect({useAuthorizedPort:!0,authorizedPortIndex:i.authorizedPorts[0].index});return}i.connect()}}}),e&&m.push({key:"finish-good-gallery",label:"Hình ảnh thành phẩm",icon:"image_search",onClick:()=>a(!0)}),m.push(...o),m},[e,t,g,d,o,i]);return h.length?c.jsxs(c.Fragment,{children:[c.jsx(L4,{items:h,launcherIcon:"support_agent",launcherLabel:"Công cụ"}),e?c.jsx(T4,{axiosProductManagement:A,hideLauncher:!0,open:s,onOpenChange:a}):null]}):null},W4=({titleNode:A,list:e,sxList:t={},sxListItem:o={},sxIconContent:r={},sxTitleNode:i={}})=>{const{palette:s}=I.useTheme();return c.jsxs(I.List,{sx:{display:"flex",flexDirection:"column",padding:0,...t},children:[A&&c.jsx(I.ListItem,{sx:{padding:wA,display:"flex",flexDirection:"column",alignItems:"flex-start",gap:"8px","&:hover":{cursor:"default",backgroundColor:"unset",color:"unset"},...i},children:A}),e.map(a=>c.jsx(I.ListItem,{onClick:a.onClick,sx:{borderRadius:be,padding:wA,transition:$e,"&:hover":{cursor:"pointer",backgroundColor:s.action.hover},...o},children:c.jsx(vn,{content:a.content,icon:a.icon,sx:r})},a.content))]})},G4=({total:A=0,page:e=js.page,take:t=js.take,openRowsPerPage:o=!0,onChange:r,sx:i={}})=>{const s=Math.ceil(A/t),a=[10,20,30,50],l=a.includes(Number(t))?Number(t):10,{palette:u}=I.useTheme(),d=g=>{const h=Number(g.target.value);r({page:1,take:h})},p=(g,h)=>{r({page:h,take:t})};return c.jsxs(se,{gap:.5,sx:{ml:"auto",...i},children:[c.jsx(I.Pagination,{count:s,page:e,showFirstButton:!0,showLastButton:!0,onChange:p,size:"medium",variant:"outlined",shape:"rounded",sx:{"& .MuiPagination-ul":{gap:.5},"& .MuiPaginationItem-root":{borderRadius:Re,m:0},"& .MuiPaginationItem-root.Mui-disabled":{opacity:.5,pointerEvents:"none"},"& .MuiPaginationItem-root.Mui-selected":{background:u.primary.main,color:"white"}}}),o&&c.jsx(se,{children:c.jsx(I.FormControl,{size:"small",children:c.jsx(Mn,{value:l,onChange:g=>d(g),options:a.map(g=>({value:g,label:`${g} / trang`})),sx:{"& .MuiOutlinedInput-root":{borderRadius:"0px !important"}}})})})]})},DO=({name:A,direction:e="row",label:t,disabled:o,iconLabel:r="event_list",defaultValue:i,value:s,onChange:a,children:l,required:u=!1,sx:d={}})=>{const p=g=>{a&&a({target:{name:A,value:g.target.value||void 0}})};return c.jsxs(I.FormControl,{disabled:o,sx:{gap:wA},onChange:p,children:[t&&c.jsx(I.InputLabel,{shrink:!0,required:u,sx:{transform:"translate(0px , -9px) scale(0.75)",zIndex:2,display:"flex"},children:c.jsxs(O3,{children:[c.jsx(vA,{icon:r,sx:{fontSize:Sa.FONT_SIZE_LABEL}}),t]})}),c.jsx(I.RadioGroup,{name:A,defaultValue:i,value:s,sx:{flexDirection:e,paddingTop:t?"calc(8.5px + 1.5px)":0,gap:Oe,...d},children:l})]})},TO=({name:A,label:e,...t})=>c.jsx(I.FormControlLabel,{name:A,label:e,sx:{alignItems:"center",mr:0},control:c.jsx(I.Radio,{...t,sx:{paddingTop:0,paddingBottom:0,paddingRight:wA,marginLeft:"2px","&:hover":{backgroundColor:"unset"},"& .MuiSvgIcon-root":{fontSize:"18px"}}})}),BO=({label:A,value:e,children:t,sx:o,textTransform:r="uppercase"})=>{const{palette:i}=I.useTheme();return c.jsxs(se,{sx:{gap:1,...o},children:[c.jsx(I.Typography,{variant:"subtitle2",sx:{...OA.textMd.semiBold,textTransform:r,color:i.primary.main},children:A||t}),e!==void 0&&c.jsx(I.Typography,{variant:"subtitle2",sx:{...OA.textMd.semiBold,textTransform:r,color:i.primary.main},children:e})]})},Y4=({name:A,value:e=!1,onChange:t})=>{const{palette:o}=I.useTheme(),r=()=>{t&&t({target:{name:A,value:!e}})};return c.jsx(_e.MotionConfig,{transition:{duration:.2,ease:"easeOut"},children:c.jsx(_e.motion.div,{className:"switch",initial:!1,animate:{backgroundColor:e?o.primary.main:o.text.disabled},onClick:r,style:{display:"flex",justifyContent:e?"flex-end":"flex-start",alignItems:"center",width:"30px",height:"14px",padding:"3px",borderRadius:"10px",boxSizing:"content-box",cursor:"pointer"},children:c.jsx(_e.motion.div,{layout:!0,className:"handle",style:{background:"#fdfdfd",aspectRatio:1,height:"100%",borderRadius:"50%"}})})})},OO=({name:A,content:e,value:t=!1,onChange:o,sx:r={}})=>c.jsxs(se,{sx:{gap:wA,...r},children:[c.jsx(I.Typography,{children:e}),c.jsx(Y4,{name:A,value:t,onChange:o})]});var mc=(A=>(A.DISABLED_GET_ROW_MENU="DISABLED_GET_ROW_MENU",A.HISTORY_GET_ROW_MENU="HISTORY_GET_ROW_MENU",A.INFO="INFO",A.COPY="COPY",A.DELETE="DELETE",A.UPDATE="UPDATE",A.SELECT="SELECT",A.COLLAPSE="COLLAPSE",A.DISABLED_ALL_ACTIONS="DISABLED_ALL_ACTIONS",A.DISABLED_ROW="DISABLED_ROW",A.DISABLED_CHECKBOX="DISABLED_CHECKBOX",A))(mc||{}),wr=(A=>(A.TOTAL="TOTAL",A.TOTAL_INCOME="TOTAL_INCOME",A))(wr||{});const Oo=`1px solid ${re.gray8}`,E0=Object.keys(mc).reduce((A,e)=>(A[e]=!1,A),{}),K4=A=>A?Array.isArray(A)?[...A]:[A]:[],Fo=(...A)=>A.flatMap(e=>K4(e)),X4=(A,e,t)=>Fo({width:`${A.width}px !important`,minWidth:`${A.width}px !important`,maxWidth:`${A.width}px !important`,padding:wA,borderRadius:"0 !important",color:t?e.divider:"none",...A.stickyCss?{position:"sticky",backgroundColor:e.background.default,...A.stickyCss}:{}},A.sx,A.cellSx),J4=(A,e,t,o,r)=>({cursor:A?"pointer":"default","&:hover .MuiTableCell-root":{backgroundColor:"inherit !important"},...o[t]?o[t]:{},...r===t?{background:`linear-gradient(270deg, ${e.primary.light+fn[90]}, ${e.action.hover}, ${e.background.paper})`,backgroundSize:"600% 600%",animation:"loading-gradient-row-table 1.5s ease infinite"}:{}});function kO({columns:A,row:e,indexRow:t,indexLoadingRow:o,rowSx:r={},getRowId:i,onClickRow:s,onDisabled:a,onClickSelectRow:l=!1,onSelectRowById:u,enableTree:d=!1,rowLevels:p={}}){const{palette:g}=I.useTheme(),h=i(e),m=a?a(e,t):{...E0},f=F.useCallback((q,x)=>{const y=x||"";return c.jsxs(At,{sx:{color:ar[950]},children:[q,c.jsx(vA,{icon:"content_copy",sx:{color:ar[950],fontSize:Jn.medium},onClick:w=>{w.stopPropagation(),y&&navigator.clipboard.writeText(y)}})]})},[]),C=!!(l&&u),b=!!(s||C);return c.jsx(I.Fade,{in:!0,timeout:t*120,children:c.jsx(I.TableRow,{hover:!0,tabIndex:-1,onClick:()=>{s==null||s(e,t),C&&(u==null||u(h))},sx:{...J4(b,g,t,r,o),...h===wr.TOTAL?{backgroundColor:re.green2,"& .MuiTableCell-root":{backgroundColor:re.green2},"& *":{fontWeight:"bold"}}:{},...h===wr.TOTAL_INCOME?{backgroundColor:re.gray7,"& .MuiTableCell-root":{backgroundColor:re.gray7},"& *":{fontWeight:"bold"}}:{}},children:A.map((q,x)=>{const y=d?p[h]??0:0,w=d?A.findIndex(T=>T.id!=="treeToggle"):-1,E=d&&x===w&&q.id!=="treeToggle";return c.jsx(I.TableCell,{align:q.align,sx:Fo(X4(q,g,m.DISABLED_ROW),{overflowWrap:"anywhere"},E?{pl:T=>`calc(${T.spacing(1)} + ${y*16}px)`}:void 0),onClick:q.id==="actions"||q.id==="selectCheckbox"?T=>{T.stopPropagation()}:void 0,children:(()=>{const T=e[q.id],P=no(q.render?q.render(e,t):T);if(!q.copyable)return P;const D=typeof q.copyable=="object"&&q.copyable.getValue?String(q.copyable.getValue(e,t)||""):String(T||"");return f(P,D)})()},q.id)})})})}const PO={visibleRows:[],rowLevels:{},hasChildrenById:{}},MO=({rows:A,enableTree:e,expandedRowIds:t,getRowId:o,getChildren:r})=>{if(!e)return{...PO,visibleRows:A};const i={},s={},a=[],l=(u,d)=>{u.forEach(p=>{const g=o(p),h=r(p);i[g]=d,s[g]=h.length>0,a.push(p),h.length>0&&t.has(g)&&l(h,d+1)})};return l(A,0),{visibleRows:a,rowLevels:i,hasChildrenById:s}},RO=({row:A,getRowId:e,rowLevels:t,hasChildrenById:o,expandedRowIds:r,onToggle:i,palette:s})=>{const a=e(A),l=t[a]??0,u=o[a],d=r.has(a),p=16,g=Math.max(l*p+14,14),h=l*p+7;return c.jsxs(I.Box,{sx:{display:"flex",alignItems:"stretch",cursor:u?"pointer":"default",minHeight:"100%"},onClick:m=>{u&&(m.stopPropagation(),i(a))},children:[c.jsx(I.Box,{sx:{position:"relative",width:g,flexShrink:0,alignSelf:"stretch",minHeight:"100%"},children:l>0&&c.jsxs(c.Fragment,{children:[c.jsx(I.Box,{sx:{position:"absolute",left:`${h}px`,top:"-1px",bottom:"50%",borderLeft:`1px solid ${s.divider}`}}),c.jsx(I.Box,{sx:{position:"absolute",left:`${h}px`,top:"50%",width:`${p/2}px`,borderBottom:`1px solid ${s.divider}`,transform:"translateY(-50%)"}})]})}),c.jsx(I.Box,{sx:{display:"flex",alignItems:"center",minHeight:"100%"},children:u?c.jsx(vA,{icon:d?"expand_more":"chevron_right"}):c.jsx(I.Box,{sx:{width:8,height:8,borderRadius:"50%",bgcolor:s.text.disabled}})})]})},NO=({children:A})=>c.jsx(I.Box,{sx:{overflowY:"auto",flex:1},children:c.jsx(I.TableContainer,{sx:{maxHeight:"100%",overflow:"auto"},children:A})}),f1=44,C2=(A,e)=>({id:A.id,label:A.label,width:A.width,align:A.align,alignHead:A.alignHead,sx:Fo(A.sx,A.headSx),stickyCss:A.stickyCss,rowSpan:e});function FO({columns:A,headerGroups:e}){const{palette:t}=I.useTheme(),o=F.useMemo(()=>{var u;if(!(e!=null&&e.length))return[A.map(d=>C2(d))];const i=new Map;e.forEach(d=>{d.columnIds.forEach(p=>{i.set(p,d)})});const s=[],a=[];let l=0;for(;l<A.length;){const d=A[l],p=i.get(d.id);if(!p){s.push(C2(d,2)),l+=1;continue}let g=1;for(;l+g<A.length&&((u=i.get(A[l+g].id))==null?void 0:u.id)===p.id;)g+=1;s.push({id:`${p.id}-${l}`,label:p.label,alignHead:p.align??"center",sx:p.sx,colSpan:g});for(let h=0;h<g;h+=1)a.push(C2(A[l+h]));l+=g}return a.length?[s,a]:[A.map(d=>C2(d))]},[A,e]),r=o.length>1;return c.jsx(I.TableHead,{children:o.map((i,s)=>c.jsx(I.TableRow,{children:i.map(a=>{var l;return c.jsx(I.TableCell,{align:a.align,colSpan:a.colSpan,rowSpan:a.rowSpan,sx:Fo({...a.width!=null?{width:`${a.width}px !important`,minWidth:`${a.width}px !important`,maxWidth:`${a.width}px !important`}:{},height:r?f1:void 0,fontWeight:550,padding:wA,borderRadius:"0 !important",backgroundColor:"#F9FAFB",verticalAlign:r&&a.rowSpan?"middle":"top",textAlign:a.alignHead?a.alignHead:"center",borderTop:s===0?Oo:"none",top:r?s*f1:0},a.stickyCss?{...a.stickyCss,position:"sticky",backgroundColor:t.background.paper,zIndex:4,borderRight:((l=a.stickyCss)==null?void 0:l.left)!=null?Oo:""}:{},a.sx),children:c.jsx(I.Typography,{variant:"subtitle1",children:a.label})},a.id)})},s))})}const jO=({columns:A,headerGroups:e,rows:t=[],loading:o=!1,stickyHeader:r=!0,tableSx:i,tableRef:s,renderRow:a,renderLoading:l,renderEmpty:u})=>c.jsx(NO,{children:c.jsxs(I.Table,{ref:s,stickyHeader:r,sx:[{height:o||t.length===0?"100%":"none",borderCollapse:"separate !important","& .MuiTableCell-root":{borderRight:Oo,borderBottom:Oo,"&:first-of-type":{borderLeft:Oo}}},...Array.isArray(i)?i:[i]],children:[c.jsx(FO,{columns:A,headerGroups:e}),c.jsx(I.TableBody,{children:o?c.jsx(I.TableRow,{children:c.jsx(I.TableCell,{colSpan:A.length,children:l()})}):t.length?t.map((d,p)=>c.jsx(F.Fragment,{children:a(d,p)},p)):c.jsx(I.TableRow,{children:c.jsx(I.TableCell,{colSpan:A.length,children:u()})})})]})}),LO=[];function hc({loading:A=!1,rows:e,columns:t,headerGroups:o,indexLoadingRow:r,isStickyActions:i=!1,rowSx:s={},rowKey:a,onClickSelectRow:l=!1,enableTree:u=!1,getChildren:d,onClickRow:p,onDisabled:g,selectedRows:h,onSelectRows:m,onSelectRow:f,onDeleteRow:C,onInfoRow:b,onCopyRow:q,onHistoryRow:x,onUpdateRow:y,getActionIcon:w,getRowMenu:E,extraActionCount:T=0,stickyHeader:P=!0,tableSx:D,tableRef:k,renderRow:M}){const v=F.useMemo(()=>e??LO,[e]),[B,O]=F.useState({}),[R,N]=F.useState(new Set),{palette:L}=I.useTheme(),U=[f,C,b,q,x,y,E].filter(Boolean).length+T,H=U>0?U*19+Math.max(U-1,0)*16:0,j=F.useCallback(oA=>a?a(oA):String(oA.id),[a]),J=F.useCallback(oA=>u?d?d(oA):oA&&oA.children||[]:[],[u,d]);F.useEffect(()=>{if(!u){N(new Set);return}const oA=new Set,AA=uA=>{uA.forEach(K=>{const iA=j(K),Z=J(K);Z&&Z.length>0&&(oA.add(iA),AA(Z))})};AA(v),N(oA)},[u,j,J,v]);const{visibleRows:eA,rowLevels:$,hasChildrenById:X}=F.useMemo(()=>MO({rows:v,enableTree:u,expandedRowIds:R,getRowId:j,getChildren:J}),[v,u,R,j,J]),_=F.useMemo(()=>eA.map(j),[eA,j]),tA=h?_.every(oA=>h.includes(oA)):!1,cA=h?h.length>0&&!tA:!1,sA=F.useCallback(()=>{tA?m==null||m([]):m==null||m(_)},[tA,m,_]),V=F.useCallback(oA=>{h&&(h.includes(oA)?m==null||m(h.filter(AA=>AA!==oA)):m==null||m([...h,oA]))},[h,m]),Y=F.useCallback(oA=>{N(AA=>{const uA=new Set(AA);return uA.has(oA)?uA.delete(oA):uA.add(oA),uA})},[]),W=F.useCallback((oA,AA)=>{const uA=j(oA);if(uA===wr.TOTAL||uA===wr.TOTAL_INCOME)return null;const K=g?g(oA,AA):{...E0},iA=K.DISABLED_ROW||K.DISABLED_ALL_ACTIONS,Z=String(a?a(oA):oA.id||AA),aA=()=>E?E(oA,AA).map(lA=>({...lA,onClick:()=>{lA.onClick(),O(BA=>({...BA,[Z]:!1}))}})):[];return c.jsxs(c.Fragment,{children:[f&&c.jsx(vA,{icon:"remove_red_eye",onClick:lA=>{lA.stopPropagation(),f(oA,AA)},disabled:iA||K.SELECT}),C&&c.jsx(vA,{icon:"delete",onClick:lA=>{lA.stopPropagation(),C(oA,AA)},color:"error",disabled:iA||K.DELETE}),b&&c.jsx(vA,{icon:"view_cozy",onClick:lA=>{lA.stopPropagation(),b(oA,AA)},disabled:iA||K.INFO}),q&&c.jsx(vA,{icon:w&&w(oA,AA,"COPY")||"content_copy",onClick:lA=>{lA.stopPropagation(),q(oA,AA),window.scrollTo({top:0,behavior:"smooth"})},disabled:iA||K.COPY}),x&&c.jsx(vA,{icon:"history",onClick:lA=>{lA.stopPropagation(),x(oA,AA)},disabled:iA||K.HISTORY_GET_ROW_MENU}),y&&c.jsx(vA,{icon:w&&w(oA,AA,"UPDATE")||"settings",onClick:lA=>{lA.stopPropagation(),y(oA,AA),window.scrollTo({top:0,behavior:"smooth"})},disabled:iA||K.UPDATE}),E&&(K.DISABLED_GET_ROW_MENU?c.jsx(vA,{icon:"open_in_browser",disabled:iA||K.DISABLED_GET_ROW_MENU,onClick:lA=>lA.stopPropagation()}):c.jsx(gn,{style:{cursor:"pointer",display:"flex",alignItems:"center"},placement:"bottom-end",open:!!B[Z],onOpen:()=>O(lA=>({...lA,[Z]:!0})),onClose:()=>O(lA=>({...lA,[Z]:!1})),content:c.jsx(W4,{list:aA()}),children:c.jsx(vA,{icon:"open_in_browser",onClick:lA=>lA.stopPropagation()})}))]})},[w,j,E,q,C,g,x,b,f,y,a,B]),rA=F.useMemo(()=>{const oA=[...t];if(u&&oA.unshift({id:"treeToggle",label:"",width:32,alignHead:"center",render:uA=>c.jsx(RO,{row:uA,getRowId:j,rowLevels:$,hasChildrenById:X,expandedRowIds:R,onToggle:Y,palette:L})}),m&&oA.unshift({id:"selectCheckbox",label:c.jsx(I.Box,{onClick:uA=>{uA.stopPropagation(),sA()},sx:{display:"flex",justifyContent:"center",cursor:"pointer"},children:c.jsx(pa,{checked:tA,indeterminate:cA})}),width:35,alignHead:"center",stickyCss:{left:0,zIndex:1.5},render:(uA,K)=>{const iA=g?g(uA,K):{...E0},Z=iA.DISABLED_ROW||iA.DISABLED_CHECKBOX;return c.jsx(I.Box,{children:c.jsx(pa,{checked:h==null?void 0:h.includes(j(uA)),disabled:Z,onClick:aA=>{aA.stopPropagation(),!Z&&V(j(uA))}})})}}),U>0&&oA.push({id:"actions",label:"Actions",width:H>70?H:70,align:"center",alignHead:"center",stickyCss:i?{right:0,borderLeft:Oo,zIndex:1.5}:void 0,render:(uA,K)=>c.jsx(jo,{gap:1,onClick:iA=>iA.stopPropagation(),children:W(uA,K)})}),!(o!=null&&o.length))return oA;const AA=new Map;return o.forEach(uA=>{uA.columnIds.forEach(K=>{AA.set(K,uA)})}),oA.map(uA=>{const K=AA.get(uA.id);return!K||!K.childrenHeadSx&&!K.childrenCellSx?uA:{...uA,...K.childrenHeadSx?{headSx:Fo(K.childrenHeadSx,uA.headSx)}:{},...K.childrenCellSx?{cellSx:Fo(K.childrenCellSx,uA.cellSx)}:{}}})},[t,o,u,m,U,j,$,X,R,Y,L,sA,tA,cA,g,h,V,H,i,W]),nA=F.useCallback((oA,AA,uA)=>c.jsx(kO,{columns:uA??rA,row:oA,indexRow:AA,indexLoadingRow:r,rowSx:s,getRowId:j,onClickRow:p,onDisabled:g,onClickSelectRow:l,onSelectRowById:V,enableTree:u,rowLevels:$}),[rA,u,j,V,r,p,l,g,$,s]);return c.jsx(jO,{columns:rA,headerGroups:o,rows:eA,loading:A,indexLoadingRow:r,stickyHeader:P,tableRef:k,tableSx:D,renderLoading:()=>c.jsx(ct,{}),renderEmpty:()=>c.jsx(Fn,{}),renderRow:(oA,AA)=>M?M({row:oA,index:AA,columns:rA,renderDefaultRow:uA=>nA(oA,AA,uA),renderActionsContent:W}):nA(oA,AA)})}const ga="collapseToggle",Z4=30,QO=20,ma=A=>A.some(e=>e.id===ga)?A:[{id:ga,label:"",width:Z4,align:"center",alignHead:"center",render:()=>null},...A],UO=(A,e,t)=>{if(e.onOpenCollapse)return t;if(e.property)return A[e.property]||[]},HO=(A,e)=>{const t=e.property?A==null?void 0:A[e.property]:A==null?void 0:A.children;return Array.isArray(t)?t:[]},zO=(A,e)=>HO(A,e).length>0,VO=(A,e)=>A?Math.max(A-parseInt(Oe,10)*2-e,Z4):"auto";function _4({columns:A,row:e,collapse:t,collapseTableWidth:o,collapseLevel:r=0,renderDefaultRow:i,onDisabled:s}){const{palette:a}=I.useTheme(),[l,u]=F.useState(!1),[d,p]=F.useState(),[g,h]=F.useState(!1),{iconTitle:m,title:f,children:C,indentSize:b,...q}=t,{columns:x,...y}=q,w=(b??QO)*r,E=F.useCallback(async(N,L)=>{const G=!l;if(u(G),!(!G||!t.onOpenCollapse||d!==void 0)){h(!0);try{const U=await t.onOpenCollapse(N,L),H=t.property?U==null?void 0:U[t.property]:U;p(H)}catch(U){console.error(U)}finally{h(!1)}}},[t,l,d]),T=F.useCallback((N,L)=>{const G=s?s(N,L):{...E0},U=G.DISABLED_ROW||G.DISABLED_ALL_ACTIONS;return c.jsx(jo,{onClick:H=>H.stopPropagation(),children:c.jsx(vA,{onClick:H=>{H.stopPropagation(),E(N,L)},icon:l?"keyboard_arrow_down":"keyboard_arrow_right",disabled:U||G.COLLAPSE})})},[s,l,E]),P=F.useMemo(()=>ma(A).map(N=>N.id!==ga?N:{...N,render:T}),[A,T]),D=UO(e,t,d),k=C==null?void 0:C[0],M=F.useMemo(()=>{if(!(k||!(D!=null&&D.some(N=>zO(N,t)))))return t},[t,D,k]),v=k??M,B=v?ma(x):x,O=VO(o,w);F.useEffect(()=>{u(!1),p(void 0),h(!1)},[e]);const R=F.useCallback(({row:N,index:L,columns:G,renderDefaultRow:U})=>v?c.jsx(_4,{...y,columns:G,row:N,indexRow:L,collapse:v,collapseTableWidth:o,collapseLevel:r+1,renderDefaultRow:U}):null,[r,o,y,v]);return c.jsxs(F.Fragment,{children:[i(P),c.jsx(I.TableRow,{children:c.jsx(I.TableCell,{style:{paddingBottom:0,paddingTop:0},colSpan:P.length,children:c.jsx(I.Stack,{sx:{display:"block",overflowX:"visible",maxWidth:"none",minWidth:O,width:"max-content",marginLeft:`${w}px`},children:c.jsx(I.Collapse,{in:l,timeout:"auto",unmountOnExit:!0,children:c.jsxs(I.Stack,{sx:{padding:Oe,borderRadius:be,backgroundColor:a.background.default,minWidth:O,width:"max-content"},children:[f&&c.jsx(vn,{icon:m||"filter_list",content:f,size:"medium"}),c.jsx(hc,{...y,columns:B,loading:g,rows:D,stickyHeader:!1,renderRow:v?R:void 0})]})})})})})]})}function WO({loading:A=!1,rows:e,columns:t,collapse:o,...r}){const i=F.useMemo(()=>e||[],[e]),s=F.useMemo(()=>ma(t),[t]),a=F.useRef(null),[l,u]=F.useState(0);return F.useEffect(()=>{a.current&&u(a.current.clientWidth)},[]),c.jsx(hc,{...r,columns:s,rows:i,loading:A,stickyHeader:!1,tableRef:a,tableSx:{height:A||i.length===0?"100%":"none"},renderRow:({row:d,index:p,columns:g,renderDefaultRow:h})=>c.jsx(_4,{...r,columns:g,row:d,indexRow:p,collapse:o,collapseTableWidth:l,renderDefaultRow:h})})}const GO={loading:{control:"boolean",table:{type:{summary:"boolean"},defaultValue:{summary:"false"}}},columns:{control:!1,table:{type:{summary:"Column<R>[]"}}},headerGroups:{control:!1,table:{type:{summary:"TableHeaderGroup[]"}}},rows:{control:!1,table:{type:{summary:"R[]"}}},indexLoadingRow:{control:"number",table:{type:{summary:"number | undefined"}}},isStickyActions:{control:"boolean",table:{type:{summary:"boolean"},defaultValue:{summary:"false"}}},onClickSelectRow:{control:"boolean",table:{type:{summary:"boolean"},defaultValue:{summary:"false"}}},selectedRows:{control:!1},rowSx:{control:!1},rowKey:{control:!1},requiredPermissions:{control:!1},onClickRow:{action:"rowClicked"},onSelectRows:{action:"rowsSelected"},onSelectRow:{action:"selectAction"},onDeleteRow:{action:"deleteAction"},onInfoRow:{action:"infoAction"},onCopyRow:{action:"copyAction"},onHistoryRow:{action:"historyAction"},onUpdateRow:{action:"updateAction"},getActionIcon:{control:!1},getRowMenu:{control:!1},onDisabled:{control:!1}};function YO(A){return c.jsx(hc,{...A})}const KO=({name:A="Hệ thống",department:e="Hệ thống",icon:t="person",sx:o})=>c.jsxs(I.Stack,{sx:o,children:[c.jsxs(I.Stack,{direction:"row",alignItems:"center",gap:1,children:[c.jsx(vA,{icon:t,sx:{fontSize:"16px",color:"#6B7280"}}),c.jsx(I.Typography,{variant:"body2",sx:{fontWeight:500},children:A})]}),e&&c.jsxs(I.Typography,{variant:"caption",sx:{color:"#6B7280",ml:2.5},children:["(",e,")"]})]}),XO=({name:A,loading:e,chart:t,sx:o})=>c.jsx(I.Fade,{in:!0,timeout:O0,children:c.jsxs(B3,{children:[c.jsx(I.Typography,{variant:"subtitle1",sx:{lineHeight:1,textAlign:"center"},children:A}),c.jsx(I.Stack,{sx:{height:`calc(100% - 14px - ${wA})`,...o},children:e?c.jsx(ct,{}):t})]})}),JO=({iconLabel:A,label:e,nodeLabel:t,labelSize:o="medium",flex:r=1,height:i="fit-content",width:s,direction:a="column",directionNodeLabel:l="column",sx:u={},loading:d=!1,children:p,sxChildren:g={}})=>c.jsx(I.Fade,{in:!0,timeout:O0,children:c.jsxs(I.Stack,{sx:{...s?{width:s}:{flex:r},overflow:"hidden",height:i,...u},children:[(e||t)&&c.jsxs(bi,{sx:{position:"sticky",alignItems:"stretch",top:0,zIndex:1,overflow:"hidden"},children:[e&&c.jsx(vn,{icon:A,content:e,size:o}),t&&c.jsx(I.Stack,{sx:{flexDirection:l},children:t})]}),c.jsx(I.Stack,{sx:{flex:1,flexDirection:a,paddingTop:e||t?0:Oe,...g},children:d?c.jsx(ct,{}):p})]})}),ZO=({iconLabel:A,label:e,nodeAction:t,nodeLabel:o,labelSize:r="large",flex:i=1,height:s="fit-content",width:a,direction:l="column",directionNodeLabel:u="column",sx:d={},loading:p=!1,children:g,sxChildren:h={overflowY:"auto"},sxLabel:m={},divider:f,labelId:C,isTopLabel:b=!1})=>{const q=!!(e||t),x={large:OA.textSm.semiBold,medium:OA.textXs.semiBold,small:OA.textSmall.semiBold}[r];return c.jsx(I.Fade,{in:!0,timeout:O0,children:c.jsx(I.Stack,{sx:{...a?{width:a}:{flex:i},overflowY:"auto",overflowX:"hidden",height:s,boxShadow:1,borderRadius:be,backgroundColor:Ue[50],...d},children:c.jsxs(I.Stack,{sx:{flex:1,minHeight:0,overflow:"hidden",gap:0},children:[q&&c.jsxs(bi,{sx:{position:"sticky",top:0,zIndex:1,gap:wA,minHeight:wt.large,padding:Kr,backgroundColor:Ue[50],...m},children:[e&&c.jsx(vn,{id:C,icon:A,content:e,size:r,isNowrap:!0,sx:{minWidth:0},sxText:{...x}}),t&&c.jsx(u0,{sx:{flexDirection:u,flexShrink:0,marginLeft:"auto"},children:t})]}),o&&c.jsx(S3,{sx:{minHeight:wt.large,overflowX:"auto",padding:Kr,borderTop:q?`1px solid ${_A[300]}`:"none"},children:o}),c.jsx(I.Stack,{sx:{flex:1,minHeight:0,flexDirection:l,padding:Kr,marginTop:b?Oe:0,borderTop:q||o?`1px solid ${_A[300]}`:"none",backgroundColor:Ue[50],...h},divider:f,children:p?c.jsx(jo,{height:100,width:"100%",children:c.jsx(ct,{})}):g})]})})})},_O=({isWrap:A=!1,children:e})=>A?c.jsx(jo,{children:e}):c.jsx(c.Fragment,{children:e}),Cc=({app:A,iconSize:e,iconRadius:t,titleColor:o,showNameApps:r=!0,showIconApps:i=!0,direction:s="column"})=>c.jsxs(D3,{sx:{flexDirection:s,gap:wA},children:[i&&c.jsx(nn,{sx:{width:e,height:e,borderRadius:t},url:A.icon,sizeType:"SQUARE"}),r&&c.jsx(I.Typography,{sx:{color:o,textAlign:"center",...OA.textMd.semiBold},children:A.content})]}),bc=({apps:A,columns:e=5,rows:t=3,iconSize:o=120,iconRadius:r=7,titleColor:i,showPagination:s=!0,onClickApp:a,isShowAppHidden:l=!1})=>{const u=zn(),d=Math.max(1,e*Math.max(1,t)),p=Math.max(1,Math.ceil(A.length/d)),[g,h]=F.useState(0);F.useEffect(()=>{h(x=>x>=p?p-1:x)},[p,e,t,A.length]);const m=g*d,f=m+d,C=p>1?A.slice(m,f):A,b=l?Math.max(0,d-C.length):0,q=l?o+36.5:0;return c.jsxs(io,{sx:{width:"100%",gap:3},children:[c.jsxs(se,{sx:{width:"100%",gap:3},children:[c.jsx(c.Fragment,{}),c.jsxs(I.Stack,{sx:{display:"grid",gridTemplateColumns:`repeat(${e}, 1fr)`,width:"100%"},children:[C.map((x,y)=>c.jsx(io,{component:Ir,preset:"staggerItem",index:y,hover:!0,sx:{cursor:"pointer",flex:1},onClick:()=>a(x),children:c.jsx(Cc,{app:x,titleColor:i??u.palette.common.white,iconSize:o,iconRadius:r})},y)),b>0&&Array.from({length:b}).map((x,y)=>c.jsx(I.Box,{sx:{visibility:"hidden",width:1,minHeight:q}},`placeholder-${y}`))]})]}),s&&p>1&&c.jsx(se,{sx:{px:Cn,py:Je,borderRadius:tn,backgroundColor:"rgba(255,255,255,0.15)",width:"fit-content"},children:Array.from({length:p}).map((x,y)=>c.jsx(I.Box,{onClick:()=>h(y),sx:{height:10,borderRadius:tn,cursor:"pointer",transition:"width 0.3s ease",width:y===g?"40px":"10px",backgroundColor:y===g?u.palette.common.white:"rgba(255,255,255,0.35)"}},y))})]})},$O=({children:A})=>c.jsx(I.Stack,{sx:{backgroundColor:"background.default",minHeight:"100vh",width:"100%",overflowY:"auto"},children:c.jsx(I.Stack,{sx:{flex:1,alignItems:"center",py:Oe,justifyContent:"center"},children:A})});var $4=(A=>(A.MAIN="logoMain",A.SUB1="logoSub1",A.SUB2="logoSub2",A.SUB3="logoSub3",A.SUB4="logoSub4",A.SUB5="logoSub5",A))($4||{});const Ak=({env:A,logoName:e="logoMain",height:t=H1,sx:o={},isLongSubDomain:r=!1})=>c.jsx(uo,{href:r?s0[A].replace("dev.","develop.").replace("sta.","staging."):s0[A],children:c.jsx(nn,{url:JA[e],sx:{height:t,borderRadius:"unset",width:"auto",...o}})}),ek=({content:A,contentHref:e,href:t,type:o="info"})=>{const{palette:r}=I.useTheme(),i={info:{icon:"error",title:"Info",color:r.success.dark},recommend:{icon:"gpp_maybe",title:"Recommend",color:r.info.dark},warning:{icon:"report",title:"Warning",color:r.warning.dark},error:{icon:"emergency_home",title:"Error",color:r.error.dark}};return c.jsxs(I.Stack,{sx:{gap:1,borderRadius:be,borderColor:i[o].color,borderStyle:"solid",borderWidth:"1px 1px 1px 3px",padding:1.5},children:[c.jsxs(se,{sx:{gap:Je},children:[c.jsx(vA,{icon:i[o].icon,sx:{color:i[o].color}}),c.jsx(I.Typography,{sx:{color:i[o].color},variant:"body2",children:i[o].title})]}),c.jsxs(I.Typography,{sx:{color:i[o].color},children:[A,t&&e&&c.jsxs(F.Fragment,{children:[" ",c.jsx(uo,{href:t,children:e})]})]})]})};var lo=(A=>(A.LOADING="loading",A.AUTHENTICATED="authenticated",A.UNAUTHENTICATED="unauthenticated",A))(lo||{}),en=(A=>(A.ALL="all",A.UNREAD="unread",A.READ="read",A))(en||{});const A5=A=>{if(!(A<=0))return A<=99?A:"99+"},yc=A=>!A||/^https?:\/\//i.test(A)||A.startsWith("//")?!1:A.startsWith("/"),vc=A=>{const e=Number(A);return e in me?e:me.INFO},i0=A=>String(A??"").trim(),e5=A=>i0(A.id??("Id"in A?A.Id:void 0)).toLowerCase(),t5=A=>{var r;const e=i0(A.title).toLowerCase(),t=i0(A.body).toLowerCase(),o=i0(A.createdAt??("data"in A?(r=A.data)==null?void 0:r.createdAt:void 0)).toLowerCase();return[e,t,o].join("|")},sr=A=>{const e=e5(A),t=t5(A),o=[];return e&&o.push(`id:${e}`),t!=="||"&&o.push(`fingerprint:${t}`),o},xc=A=>{var e;return i0(A.module??("data"in A?(e=A.data)==null?void 0:e.module:void 0)).toUpperCase()},n5=A=>{var t;const e=xc(A);return(t=ko[e])==null?void 0:t.icon},o5=A=>{var r,i,s,a,l;const e=A.title??"",t=A.body??"",o=A.createdAt??((r=A.data)==null?void 0:r.createdAt)??new Date().toISOString();return{id:A.id??A.Id??`${e}-${o}`,eventType:A.eventType??((i=A.data)==null?void 0:i.actionName)??"Realtime",priority:vc(A.priority??((s=A.data)==null?void 0:s.priority)),title:e,body:t,actionUrl:A.actionUrl??((a=A.data)==null?void 0:a.actionUrl),module:xc(A),status:hn.UNREAD,acknowledgementRequired:A.acknowledgementRequired??((l=A.data)==null?void 0:l.acknowledgementRequired)??!1,createdAt:o}},qc=A=>{const t=new Date(A).getTime();if(!Number.isFinite(t))return"vua xong";const o=Math.round((t-Date.now())/1e3),r=Math.abs(o),i=new Intl.RelativeTimeFormat("vi",{numeric:"auto"});if(r<60)return i.format(o,"second");const s=Math.round(o/60);if(Math.abs(s)<60)return i.format(s,"minute");const a=Math.round(s/60);if(Math.abs(a)<24)return i.format(a,"hour");const l=Math.round(a/24);if(Math.abs(l)<30)return i.format(l,"day");const u=Math.round(l/30);return Math.abs(u)<12?i.format(u,"month"):i.format(Math.round(u/12),"year")},tk="hub/notification-realtime",nk="NotificationReceived",ok="notification-be-list",r5="notification-be-unread-count",rk="notification-be-realtime",ik={axiosNotification:{},authStatus:lo.UNAUTHENTICATED,hasNewNotification:!1,unreadCount:0,markNotificationsSeen:()=>{},refreshNotifications:async()=>{}},i5=F.createContext(ik),sk={[me.CRITICAL]:mt.ERROR,[me.HIGH]:mt.WARNING,[me.NORMAL]:mt.INFO,[me.INFO]:mt.INFO},ak=A=>A.replace(/\/+$/,""),lk=A=>{const e=A.title??"",t=A.body;return t?`${e} - ${t}`:e},ck=(A,e)=>Array.isArray(A)&&A[0]===ok&&(!e||A[1]===e),s5=(A,e)=>Array.isArray(A)&&A[0]===r5&&(!e||A[1]===e),uk=(A,e)=>ck(A,e)||s5(A,e),dk=A=>A?[rk,A]:null;let Ps,g1="",P2="";const pk=(A,e)=>((!Ps||g1!==A)&&(Ps=new Rs.HubConnectionBuilder().withUrl(A,{accessTokenFactory:e,withCredentials:!1}).withAutomaticReconnect([0,2e3,5e3,1e4]).build(),g1=A,P2=""),Ps),fk=({axiosNotification:A,authStatus:e,userName:t,hubBaseUrl:o,hubPath:r=tk,realtimeEventName:i=nk,accessTokenFactory:s,showSnackbar:a,children:l})=>{const{mutate:u}=nr.useSWRConfig(),[d,p]=F.useState(!1),g=F.useRef(new Set),h=F.useRef(()=>{}),m=e===lo.AUTHENTICATED&&t?[r5,t]:null,{data:f=0}=nr(m,async()=>(await Ca(A)).count??0,{revalidateOnFocus:!1,shouldRetryOnError:!1}),C=F.useCallback(async()=>{await u(w=>uk(w,t),void 0,{revalidate:!0})},[u,t]),b=F.useCallback(()=>{p(!1)},[]),q=F.useCallback(async w=>{const E=o5(w),T=dk(t);T&&await u(T,(P=[])=>{const D=sr(E);return P.some(M=>{const v=sr(M);return D.some(B=>v.includes(B))})?P:[E,...P].slice(0,50)},{revalidate:!1}),await u(P=>s5(P,t),P=>(P??0)+1,{revalidate:!1})},[u,t]),x=F.useCallback(async w=>{const E=sr(w);E.some(T=>g.current.has(T))||(E.forEach(T=>g.current.add(T)),p(!0),a==null||a({type:sk[vc(w.priority)],message:lk(w)}),await q(w),await C(),setTimeout(()=>{E.forEach(T=>g.current.delete(T))},1e4))},[q,C,a]);F.useEffect(()=>{h.current=x},[x]),F.useEffect(()=>{if(e!==lo.AUTHENTICATED||!o||!t)return;const w=`${ak(o)}/${r.replace(/^\/+/,"")}`,E=pk(w,s),T=D=>{h.current(D)};return E.on(i,T),(async()=>{E.state===Rs.HubConnectionState.Connected&&P2&&P2!==t&&await E.stop(),E.state===Rs.HubConnectionState.Disconnected&&(P2=t,await E.start())})().catch(D=>{console.error("[NotificationReceived][global] connect error",D)}),()=>{E.off(i,T)}},[s,e,o,r,i,t]);const y=F.useMemo(()=>({axiosNotification:A,authStatus:e,userName:t,hasNewNotification:d,unreadCount:f,markNotificationsSeen:b,refreshNotifications:C,showSnackbar:a}),[e,A,d,b,C,a,f,t]);return c.jsx(i5.Provider,{value:y,children:l})},t2=()=>F.useContext(i5),a5=({notification:A,fallbackIcon:e,color:t})=>{const o=n5(A),r=A.priority??me.INFO;return c.jsx(u0,{sx:{height:36,width:36},children:o?c.jsx(nn,{alt:A.module||A.eventType||A.title,sizeType:"FULL_WIDTH",url:o,size:It.LARGE}):c.jsx(vA,{icon:e,sx:{color:t,fontSize:r===me.INFO?19:20}})})},wc="notification-be-list",Sc="notification-be-unread-count",l5="notification-be-realtime",m1=A=>{if(A===en.READ)return j2.READ;if(A===en.UNREAD)return j2.UNREAD},gk=(A,e)=>e===en.READ?A.status===hn.READ:e===en.UNREAD?A.status===hn.UNREAD:!0,mk=(A,e,t)=>{const o=e.filter(i=>gk(i,t)),r=new Set(A.flatMap(sr));return[...o.filter(i=>sr(i).every(s=>!r.has(s))),...A]},hk=(A,e)=>A.length!==e.length?!1:A.every((t,o)=>{const r=e[o];return t.id===r.id&&t.status===r.status&&t.title===r.title&&t.body===r.body&&t.createdAt===r.createdAt}),Ec=(A,e)=>Array.isArray(A)&&A[0]===wc&&(!e||A[1]===e),Ic=(A,e)=>Array.isArray(A)&&A[0]===Sc&&(!e||A[1]===e),Ck=(A,e)=>Ec(A,e)||Ic(A,e),c5=A=>A?[l5,A]:null,Dc=(A={},e=en.ALL)=>{const{axiosNotification:t,authStatus:o,userName:r}=t2(),{mutate:i}=nr.useSWRConfig(),[s,a]=F.useState({page:1,pageSize:10,status:m1(e),...A}),[l,u]=F.useState([]),[d,p]=F.useState(!1),g=F.useRef(!1),h=F.useMemo(()=>s,[s]),m=o===lo.AUTHENTICATED&&r?[wc,r,h]:null,f=o===lo.AUTHENTICATED&&r?c5(r):null;F.useEffect(()=>{a(D=>{const k=m1(e);return D.status===k&&D.page===1?D:{...D,status:k,page:1}}),g.current=!1,u(D=>D.length===0?D:[])},[e]);const{data:C,error:b,isLoading:q}=nr(m,async([,,D])=>{const k=await w1(t,D);return{notifications:k.items??[],totalCount:k.total??0}},{revalidateOnFocus:!1,revalidateIfStale:!0,shouldRetryOnError:!1}),{data:x=[]}=nr(f,null,{fallbackData:[],revalidateOnFocus:!1}),y=Math.max((C==null?void 0:C.totalCount)??0,l.length),w=F.useMemo(()=>l.filter(D=>D.status===hn.UNREAD).length,[l]);F.useEffect(()=>{if(h.page!==1){if(!C)return;if(g.current){u(k=>[...k,...C.notifications]),g.current=!1;return}u(C.notifications);return}if(!C&&x.length===0)return;const D=mk((C==null?void 0:C.notifications)??[],x,e);u(k=>hk(k,D)?k:D)},[C,h.page,e,x]);const E=F.useCallback(()=>{q||l.length>=y||(g.current=!0,a(D=>({...D,page:(D.page??1)+1})))},[q,l.length,y]),T=F.useCallback(D=>{g.current=!1,a(k=>({...k,page:D.page,pageSize:D.take}))},[]),P=F.useCallback(async()=>{p(!0),a(D=>({...D,page:1})),await i(D=>Ec(D,r),void 0,{revalidate:!0}),await i(D=>Ic(D,r),void 0,{revalidate:!0}),p(!1)},[i,r]);return{notifications:l,totalCount:y,unreadCount:w,isLoading:q,isRefreshing:d,error:(C==null?void 0:C.error)??(b instanceof Error?b.message:void 0),handlePaginationChange:T,loadMore:E,page:s.page??1,pageSize:s.pageSize??10,refresh:P}},bk=()=>{const{axiosNotification:A,authStatus:e,userName:t}=t2(),o=e===lo.AUTHENTICATED&&t?[Sc,t]:null,{data:r,isLoading:i,mutate:s}=nr(o,async()=>(await Ca(A)).count??0,{revalidateOnFocus:!1,shouldRetryOnError:!1});return{unreadCount:r??0,isLoadingUnreadCount:i,refreshUnreadCount:s}},yk={[me.CRITICAL]:"error",[me.HIGH]:"warning",[me.NORMAL]:"notifications",[me.INFO]:"info"},h1={[me.CRITICAL]:Ft[500],[me.HIGH]:qo[500],[me.NORMAL]:_A[500],[me.INFO]:_A[500]},vk={[me.CRITICAL]:"Khẩn cấp",[me.HIGH]:"Ưu tiên cao",[me.NORMAL]:"",[me.INFO]:""},xk=[{id:en.ALL,name:"Tất cả"},{id:en.UNREAD,name:"Chưa đọc"},{id:en.READ,name:"Đã đọc"}],qk=({notification:A,onRead:e,onNavigate:t})=>{const o=F.useMemo(()=>qc(A.createdAt),[A.createdAt]),r=A.status===hn.UNREAD,i=A.priority??me.INFO,s=yc(A.actionUrl),a=vk[i],l=async()=>{await e(),s&&A.actionUrl&&(t==null||t(A.actionUrl))};return c.jsx(I.Stack,{onClick:l,sx:{bgcolor:Ue[50],border:`1px solid ${_A[200]}`,borderRadius:be,boxShadow:r?`inset 3px 0 0 ${xe[500]}`:"none",cursor:"pointer",p:wA,transition:$e,"&:hover":{bgcolor:_A[50],borderColor:_A[300]}},children:c.jsxs(se,{sx:{alignItems:"flex-start",gap:wA,minWidth:0},children:[c.jsx(a5,{notification:A,fallbackIcon:yk[i],color:h1[i]}),c.jsxs(I.Stack,{sx:{flex:1,gap:0,minWidth:0},children:[c.jsxs(At,{sx:{alignItems:"flex-start",gap:wA},children:[c.jsx(ze,{content:no(A.title),sx:{...OA.textSm.semiBold,color:r?_A[900]:_A[700]}}),c.jsx(ze,{content:o,sx:{...OA.textXs.medium,color:_A[500],flexShrink:0}})]}),c.jsxs(At,{sx:{alignItems:"flex-start",gap:wA},children:[c.jsx(I.Typography,{sx:{...OA.textXs.regular,color:_A[700],width:"85%",display:"-webkit-box",WebkitBoxOrient:"vertical",WebkitLineClamp:5,overflow:"hidden"},children:no(A.body)}),c.jsx(ze,{content:r?"Chưa đọc":"Đã đọc",sx:{...OA.textXs.medium,color:r?xe[600]:_A[500]}})]}),c.jsxs(se,{sx:{gap:Je},children:[a?c.jsx(ze,{content:a,sx:{...OA.textXs.medium,color:h1[i]}}):null,s?c.jsx(ze,{content:"Xem chi tiết",sx:{...OA.textXs.medium,color:xe[600]}}):null]})]})]})})},u5=({onNavigate:A})=>{const{axiosNotification:e,showSnackbar:t}=t2(),[o,r]=F.useState(en.ALL),{notifications:i,totalCount:s,unreadCount:a,isLoading:l,isRefreshing:u,error:d,handlePaginationChange:p,page:g,pageSize:h,refresh:m}=Dc({page:1,pageSize:10},o),f=async b=>{if(b.status===hn.UNREAD)try{await ba(e,b.id),await m()}catch(q){t==null||t({type:mt.ERROR,message:a0(q)})}},C=async()=>{if(a)try{const b=await ya(e);await m(),t==null||t({type:mt.SUCCESS,message:b.success?"Đã đánh dấu tất cả thông báo là đã đọc":"Không có thông báo cần đánh dấu"})}catch(b){t==null||t({type:mt.ERROR,message:a0(b)})}};return c.jsxs(I.Stack,{sx:{flex:1,gap:0,minHeight:0,overflow:"hidden"},children:[c.jsx(I.Stack,{sx:{borderBottom:`1px solid ${_A[200]}`,gap:0,p:Je},children:c.jsx(w3,{children:c.jsx(Qa,{tabs:xk.map(b=>({id:b.id,name:b.name,onClick:()=>r(b.id)})),idSelect:o})})}),c.jsxs(I.Stack,{sx:{flex:1,gap:wA,minHeight:0,overflow:"auto",p:Oe},children:[c.jsxs(At,{sx:{flexWrap:"wrap",gap:wA},children:[c.jsxs(I.Stack,{sx:{gap:Je},children:[c.jsx(ze,{content:`Danh sách (${s})`,sx:{...OA.textSm.semiBold}}),c.jsx(ze,{content:a?`${a} thông báo chưa đọc`:"Tất cả thông báo đã được đọc",sx:{...OA.textXs.medium,color:a?xe[600]:_A[500]}})]}),a?c.jsx(Qe,{content:"Đánh dấu tất cả đã đọc",disabled:u,endIcon:"done_all",loading:u,onClick:C,variant:"text"}):null]}),i.map(b=>c.jsx(qk,{notification:b,onNavigate:A,onRead:()=>f(b)},b.id)),!d&&i.length===0&&!l?c.jsx(u0,{sx:{flex:1,gap:wA,minHeight:220},children:c.jsx(Fn,{content:"Bạn sẽ nhận được thông báo khi có hoạt động mới"})}):null,l&&i.length===0?c.jsx(u0,{sx:{flex:1,minHeight:220},children:c.jsx(ct,{})}):null,d?c.jsx(Fn,{content:`Lỗi khi tải thông báo: ${d}`}):null]}),s>h?c.jsx(G4,{total:s,page:g,take:h,onChange:p}):null]})},wk=10,Sk={[me.CRITICAL]:"error",[me.HIGH]:"warning",[me.NORMAL]:"notifications",[me.INFO]:"info"},Ek={[me.CRITICAL]:Ft[500],[me.HIGH]:qo[500],[me.NORMAL]:xe[500],[me.INFO]:_A[500]},Ik=({notification:A,onClick:e})=>{const t=F.useMemo(()=>qc(A.createdAt),[A.createdAt]),o=A.status===hn.UNREAD,r=A.priority??me.INFO;return c.jsx(I.ListItem,{onClick:()=>e(A),sx:{borderRadius:be,cursor:"pointer",p:wA,transition:$e,bgcolor:o?xe[50]:Ue[50],"&:hover":{bgcolor:o?xe[100]:_A[50]}},children:c.jsxs(se,{sx:{alignItems:"flex-start",gap:wA,width:"100%"},children:[c.jsx(a5,{notification:A,fallbackIcon:Sk[r],color:Ek[r]}),c.jsxs(I.Stack,{sx:{flex:1,gap:Je,minWidth:0},children:[c.jsxs(I3,{sx:{gap:wA},children:[c.jsx(ze,{content:no(A.title),sx:{...OA.textSm.semiBold}}),c.jsx(ze,{content:t,sx:{...OA.textXs.medium,flexShrink:0}})]}),c.jsx(ze,{content:no(A.body),sx:{...OA.textXs.regular}})]})]})})},Dk=({onNavigate:A,dropdownPageSize:e=wk})=>{const{axiosNotification:t,hasNewNotification:o,unreadCount:r,markNotificationsSeen:i,refreshNotifications:s,showSnackbar:a}=t2(),[l,u]=F.useState(!1),[d,p]=F.useState(!1),[g,h]=F.useState(!1),{notifications:m,isLoading:f,refresh:C}=Dc({page:1,pageSize:e}),b=()=>{u(y=>!y),i()},q=async y=>{if(u(!1),y.status===hn.UNREAD)try{await ba(t,y.id),await s(),await C()}catch(w){a==null||a({type:mt.ERROR,message:a0(w)})}yc(y.actionUrl)&&(A==null||A(y.actionUrl))},x=async()=>{h(!0);try{await ya(t),await s(),await C(),a==null||a({type:mt.SUCCESS,message:"Đã đánh dấu tất cả thông báo là đã đọc"})}catch(y){a==null||a({type:mt.ERROR,message:a0(y)})}finally{h(!1)}};return c.jsxs(c.Fragment,{children:[c.jsx(P3,{open:l,onClickAway:()=>u(!1),placement:"bottom-end",content:c.jsxs(I.List,{sx:{display:"flex",flexDirection:"column",maxHeight:500,overflowY:"auto",p:0,width:360},children:[c.jsxs(I.ListItem,{sx:{alignItems:"center",bgcolor:Ue[50],borderBottom:`1px solid ${_A[200]}`,display:"flex",justifyContent:"space-between",p:wA,position:"sticky",top:0,zIndex:1},children:[c.jsx(ze,{content:"Thông báo hệ thống",sx:{...OA.textMd.semiBold}}),c.jsxs(se,{sx:{gap:Je},children:[g?c.jsx(ct,{size:"small"}):null,c.jsx(So,{icon:"mark_email_read",onClick:x,sx:{minHeight:30,minWidth:30}}),c.jsx(So,{icon:"open_in_full",onClick:()=>{u(!1),p(!0)},sx:{minHeight:30,minWidth:30}})]})]}),f?c.jsx(ct,{}):null,!f&&m.length===0?c.jsx(Fn,{content:"Không có thông báo"}):null,f?null:m.map(y=>c.jsx(Ik,{notification:y,onClick:q},y.id))]}),children:c.jsx(I.Badge,{badgeContent:A5(r),color:"error",invisible:r===0,sx:{cursor:"pointer","& .MuiBadge-badge":{...OA.textXs.semiBold,minWidth:16,height:16}},children:c.jsx(So,{"aria-label":"Thông báo",icon:"notifications_none",onClick:b,sx:{bgcolor:o?qo[50]:"transparent",color:o?qo[700]:_A[600],minHeight:32,minWidth:32,"&:hover":{bgcolor:o?qo[100]:_A[100],color:o?qo[800]:_A[800]}}})})}),c.jsx(I.Drawer,{anchor:"right",open:d,onClose:()=>p(!1),children:c.jsxs(I.Stack,{sx:{height:"100vh",width:520,overflow:"hidden"},children:[c.jsxs(I.Stack,{sx:{borderBottom:`1px solid ${_A[200]}`,gap:Je,p:wA},children:[c.jsxs(At,{sx:{gap:wA},children:[c.jsx(ze,{content:"Thông báo hệ thống",sx:{...OA.textMd.semiBold}}),c.jsx(So,{icon:"close",onClick:()=>p(!1)})]}),c.jsx(ze,{content:"Xem và quản lý các thông báo của bạn",sx:{...OA.textXs.medium,color:_A[500]}})]}),c.jsx(u5,{onNavigate:A})]})})]})},Tk=({isLineHeight1:A,price:e,originalPrice:t,discountPercent:o,onClick:r,color:i,size:s="small",sameSize:a=!1,sx:l={}})=>{const{palette:u}=I.useTheme(),d={small:"subtitle1",medium:"h6",large:"h5"};return r&&(l={...l,cursor:"pointer"}),c.jsxs(I.Stack,{sx:l,children:[c.jsxs(se,{sx:{color:i||u.error.main,gap:wA},children:[c.jsx(vA,{icon:"attach_money",size:s,sx:{marginRight:"-5px",marginLeft:"-4px"}}),c.jsx(I.Typography,{lineHeight:A?1:void 0,variant:d[s],children:+e.toFixed(1)})]}),t&&e!==t&&c.jsxs(se,{sx:{gap:wA},children:[c.jsxs(se,{sx:{color:u.text.disabled,gap:wA,position:"relative","&:after":{position:"absolute",content:"''",borderTop:`1px solid ${u.text.disabled}`,width:"100%"}},children:[c.jsx(vA,{icon:"attach_money",size:a?s:"small",sx:{marginRight:"-5px",marginLeft:"-4px"}}),c.jsx(I.Typography,{lineHeight:A?1:void 0,variant:a?d[s]:"body1",children:t})]}),o&&c.jsx(I.Typography,{lineHeight:A?1:void 0,color:o<0?"success.main":"error",variant:a?d[s]:"body1",children:(o<0?"+":"-")+Math.abs(o)+"%"})]})]})};var M2={exports:{}},Bk=M2.exports,C1;function Ok(){return C1||(C1=1,(function(A,e){(function(t,o){A.exports=o()})(Bk,(function(){var t="week",o="year";return function(r,i,s){var a=i.prototype;a.week=function(l){if(l===void 0&&(l=null),l!==null)return this.add(7*(l-this.week()),"day");var u=this.$locale().yearStart||1;if(this.month()===11&&this.date()>25){var d=s(this).startOf(o).add(1,o).date(u),p=s(this).endOf(t);if(d.isBefore(p))return 1}var g=s(this).startOf(o).date(u).startOf(t).subtract(1,"millisecond"),h=this.diff(g,t,!0);return h<0?s(this).startOf("week").week():Math.ceil(h)},a.weeks=function(l){return l===void 0&&(l=null),this.week(l)}}}))})(M2)),M2.exports}var kk=Ok();const Pk=Hn(kk);var R2={exports:{}},Mk=R2.exports,b1;function Rk(){return b1||(b1=1,(function(A,e){(function(t,o){A.exports=o()})(Mk,(function(){return function(t,o,r){o.prototype.isBetween=function(i,s,a,l){var u=r(i),d=r(s),p=(l=l||"()")[0]==="(",g=l[1]===")";return(p?this.isAfter(u,a):!this.isBefore(u,a))&&(g?this.isBefore(d,a):!this.isAfter(d,a))||(p?this.isBefore(u,a):!this.isAfter(u,a))&&(g?this.isAfter(d,a):!this.isBefore(d,a))}}}))})(R2)),R2.exports}var Nk=Rk();const Fk=Hn(Nk);var N2={exports:{}},jk=N2.exports,y1;function Lk(){return y1||(y1=1,(function(A,e){(function(t,o){A.exports=o()})(jk,(function(){return function(t,o){var r=o.prototype,i=r.format;r.format=function(s){var a=this,l=this.$locale();if(!this.isValid())return i.bind(this)(s);var u=this.$utils(),d=(s||"YYYY-MM-DDTHH:mm:ssZ").replace(/\[([^\]]+)]|Q|wo|ww|w|WW|W|zzz|z|gggg|GGGG|Do|X|x|k{1,2}|S/g,(function(p){switch(p){case"Q":return Math.ceil((a.$M+1)/3);case"Do":return l.ordinal(a.$D);case"gggg":return a.weekYear();case"GGGG":return a.isoWeekYear();case"wo":return l.ordinal(a.week(),"W");case"w":case"ww":return u.s(a.week(),p==="w"?1:2,"0");case"W":case"WW":return u.s(a.isoWeek(),p==="W"?1:2,"0");case"k":case"kk":return u.s(String(a.$H===0?24:a.$H),p==="k"?1:2,"0");case"X":return Math.floor(a.$d.getTime()/1e3);case"x":return a.$d.getTime();case"z":return"["+a.offsetName()+"]";case"zzz":return"["+a.offsetName("long")+"]";default:return p}}));return i.bind(this)(d)}}}))})(N2)),N2.exports}var Qk=Lk();const Uk=Hn(Qk);DA.extend(t3);DA.extend(Pk);DA.extend(Fk);DA.extend(Uk);const Hk={YY:"year",YYYY:{sectionType:"year",contentType:"digit",maxLength:4},M:{sectionType:"month",contentType:"digit",maxLength:2},MM:"month",MMM:{sectionType:"month",contentType:"letter"},MMMM:{sectionType:"month",contentType:"letter"},D:{sectionType:"day",contentType:"digit",maxLength:2},DD:"day",Do:{sectionType:"day",contentType:"digit-with-letter"},d:{sectionType:"weekDay",contentType:"digit",maxLength:2},dd:{sectionType:"weekDay",contentType:"letter"},ddd:{sectionType:"weekDay",contentType:"letter"},dddd:{sectionType:"weekDay",contentType:"letter"},A:"meridiem",a:"meridiem",H:{sectionType:"hours",contentType:"digit",maxLength:2},HH:"hours",h:{sectionType:"hours",contentType:"digit",maxLength:2},hh:"hours",m:{sectionType:"minutes",contentType:"digit",maxLength:2},mm:"minutes",s:{sectionType:"seconds",contentType:"digit",maxLength:2},ss:"seconds"},zk={year:"YYYY",month:"MMMM",monthShort:"MMM",dayOfMonth:"D",dayOfMonthFull:"Do",weekday:"dddd",weekdayShort:"dd",hours24h:"HH",hours12h:"hh",meridiem:"A",minutes:"mm",seconds:"ss",fullDate:"ll",keyboardDate:"L",shortDate:"MMM D",normalDate:"D MMMM",normalDateWithWeekday:"ddd, MMM D",fullTime12h:"hh:mm A",fullTime24h:"HH:mm",keyboardDateTime12h:"L hh:mm A",keyboardDateTime24h:"L HH:mm"},Ms=["Missing UTC plugin","To be able to use UTC or timezones, you have to enable the `utc` plugin","Find more information on https://mui.com/x/react-date-pickers/timezone/#day-js-and-utc"].join(`
262
+ `,Os={wrapper:"transform-component-module_wrapper__SPB86",content:"transform-component-module_content__FBWxo",infiniteGrid:"transform-component-module_infiniteGrid__Z-aP3"};PB(MB);var RB=function(A){var e=A.children,t=A.wrapperClass,o=t===void 0?"":t,r=A.contentClass,i=r===void 0?"":r,s=A.wrapperStyle,a=A.contentStyle,l=A.wrapperProps,u=l===void 0?{}:l,d=A.contentProps,p=d===void 0?{}:d,g=A.infinite,h=g===void 0?!1:g,m=F.useContext(os),f=m.init,C=m.cleanupWindowEvents,b=F.useRef(null),q=F.useRef(null),x=F.useRef(null);return F.useEffect(function(){var y=b.current,w=q.current;return y!==null&&w!==null&&f&&(f==null||f(y,w)),function(){C==null||C()}},[]),F.useEffect(function(){if(h){var y=x.current;if(y){var w=function(){var E=m.state,T=E.positionX,P=E.positionY;y.style.backgroundPosition="".concat(T,"px ").concat(P,"px")};return w(),m.onChange(w)}}},[h,m]),c.jsxs("div",jt({},u,{ref:b,className:"".concat(ua.wrapperClass," ").concat(Os.wrapper," ").concat(o),style:s},{children:[h&&c.jsx("div",{ref:x,className:Os.infiniteGrid,"aria-hidden":!0}),c.jsx("div",jt({},p,{ref:q,className:"".concat(ua.contentClass," ").concat(Os.content," ").concat(i),style:jt(jt({},a),{transform:m4(m.state.positionX,m.state.positionY,m.state.scale)})},{children:e}))]}))};function NB(A,e){var t=Math.max(0,Math.min(A.x+A.width,e.x+e.width)-Math.max(A.x,e.x)),o=Math.max(0,Math.min(A.y+A.height,e.y+e.height)-Math.max(A.y,e.y));return t*o}function FB(A){var e=A.elementX,t=A.elementY,o=A.elementWidth,r=A.elementHeight,i=A.scale,s=A.positionX,a=A.positionY,l=A.viewportWidth,u=A.viewportHeight,d=A.margin,p=d===void 0?0:d,g=A.threshold,h=g===void 0?0:g,m={x:-p,y:-p,width:l+2*p,height:u+2*p},f={x:e*i+s,y:t*i+a,width:o*i,height:r*i};if(h<=0){var C=f.x<m.x+m.width&&f.x+f.width>m.x,b=f.y<m.y+m.height&&f.y+f.height>m.y;return C&&b}var q=f.width*f.height;if(q<=0)return!1;var x=NB(m,f);return x/q>=h}F.forwardRef(function(A,e){var t=A.x,o=A.y,r=A.width,i=A.height,s=A.margin,a=s===void 0?0:s,l=A.threshold,u=l===void 0?0:l,d=A.placeholder,p=d===void 0?null:d,g=A.onShow,h=A.onHide,m=A.children,f=A.className,C=A.style,b=F.useContext(os),q=F.useState(!1),x=q[0],y=q[1],w=F.useRef(!1),E=F.useRef(g),T=F.useRef(h);return E.current=g,T.current=h,F.useEffect(function(){var P=function(){var M,v,B=b.wrapperComponent;if(B){var O=FB({elementX:t,elementY:o,elementWidth:r,elementHeight:i,scale:b.state.scale,positionX:b.state.positionX,positionY:b.state.positionY,viewportWidth:B.offsetWidth,viewportHeight:B.offsetHeight,margin:a,threshold:u});O!==w.current&&(w.current=O,y(O),O?(M=E.current)===null||M===void 0||M.call(E):(v=T.current)===null||v===void 0||v.call(T))}};P();var D=b.onChange(P),k;return b.wrapperComponent||(k=b.onInit(function(){return P()})),function(){D(),k==null||k()}},[b,t,o,r,i,a,u]),x?c.jsx("div",jt({ref:e,className:f,style:C},{children:m})):p?c.jsx(c.Fragment,{children:p}):null});const t1=({open:A,selectedImage:e,selectedIndex:t,imageCount:o,hasMultipleImages:r,showViewerCounter:i,canGoPrevious:s,canGoNext:a,labels:l,viewerPaperSx:u,viewerImageSx:d,onImageError:p,onClose:g,onPrevious:h,onNext:m})=>c.jsx(I.Dialog,{open:A,onClose:g,maxWidth:!1,disableScrollLock:!0,PaperProps:{sx:Et({width:"min(1120px, calc(100vw - 32px))",maxWidth:"none",overflow:"visible",backgroundColor:"transparent",boxShadow:"none"},u)},children:c.jsx(I.DialogContent,{sx:{position:"relative",padding:0,overflow:"visible",display:"grid",placeItems:"center"},children:c.jsxs(I.Box,{sx:{position:"relative",width:"100%"},children:[c.jsx(kB,{centerOnInit:!0,centerZoomedOut:!0,limitToBounds:!0,panning:{allowLeftClickPan:!0,velocityDisabled:!0},doubleClick:{mode:"reset"},children:c.jsx(RB,{wrapperStyle:{width:"100%",maxHeight:"calc(100vh - 96px)",overflow:"hidden",borderRadius:be,cursor:"grab"},contentStyle:{width:"100%",display:"flex",justifyContent:"center"},children:c.jsx(I.Box,{component:"img",src:e.src,alt:e.alt,draggable:!1,onError:p,sx:Et({display:"block",width:"100%",maxHeight:"calc(100vh - 96px)",objectFit:"contain",borderRadius:be,backgroundColor:Ue[50]},d)})})},e.src),c.jsx(r0,{icon:"close",label:l.close,onClick:g,sx:{top:wA,right:wA}}),r&&c.jsxs(c.Fragment,{children:[c.jsx(r0,{icon:"chevron_left",label:l.previous,disabled:!s,onClick:h,sx:{left:Oe,top:"50%",transform:"translateY(-50%)"}}),c.jsx(r0,{icon:"chevron_right",label:l.next,disabled:!a,onClick:m,sx:{right:Oe,top:"50%",transform:"translateY(-50%)"}})]}),i&&r&&c.jsx(ze,{content:l.counter(t+1,o),sx:cT})]})})});var ti=(A=>(A.GALLERY="gallery",A.SUMMARY="summary",A))(ti||{});const S4=({images:A,variant:e=ti.GALLERY,activeIndex:t,initialIndex:o=0,mainAspectRatio:r="16 / 9",objectFit:i="cover",thumbnailObjectFit:s="cover",thumbnailSize:a=72,summaryMaxVisible:l=4,summaryThumbnailSize:u=ur.extra_large.width,showThumbnails:d=!0,showPreviewNavigation:p=!0,showViewerCounter:g=!0,openOnMainClick:h=!0,loop:m=!0,fallbackSrc:f,activeColor:C=xe[500],borderRadius:b=tn,emptyContent:q,labels:x,mainSx:y,mainImageSx:w,summarySx:E,summaryItemSx:T,summaryCountSx:P,thumbnailListSx:D,thumbnailSx:k,viewerPaperSx:M,viewerImageSx:v,onActiveIndexChange:B,onOpenViewer:O,onCloseViewer:R,sx:N,...L})=>{const[G,U]=F.useState(()=>Ar(o,A.length)),[H,j]=F.useState(!1),J=F.useMemo(()=>uT(x),[x]),eA=F.useMemo(()=>A.map((iA,Z)=>dT(iA,Z,J)),[J,A]),$=eA.length,X=Ar(t??G,$),_=eA[X],tA=$>1,cA=e===ti.SUMMARY,sA=!cA&&tA&&d;F.useEffect(()=>{U(iA=>Ar(iA,$))},[$]);const V=F.useCallback(iA=>{if(!f)return;const Z=iA.currentTarget;Z.dataset.galleryFallback!=="true"&&(Z.dataset.galleryFallback="true",Z.src=f)},[f]),Y=F.useCallback(iA=>{const Z=Ar(iA,$),aA=eA[Z];aA&&(t==null&&U(Z),B==null||B(Z,aA))},[t,$,eA,B]),W=tA&&(m||X>0),rA=tA&&(m||X<$-1),nA=F.useCallback(()=>{W&&Y(Yd(X,-1,$,m))},[W,Y,$,m,X]),oA=F.useCallback(()=>{rA&&Y(Yd(X,1,$,m))},[rA,Y,$,m,X]),AA=F.useCallback(()=>{!_||!h||(j(!0),O==null||O(X,_))},[O,h,_,X]),uA=F.useCallback(iA=>{if(!h)return;const Z=Ar(iA,$),aA=eA[Z];aA&&(Z!==X&&(t==null&&U(Z),B==null||B(Z,aA)),j(!0),O==null||O(Z,aA))},[t,$,eA,B,O,h,X]),K=F.useCallback(()=>{j(!1),R==null||R()},[R]);return F.useEffect(()=>{if(!H||!tA)return;const iA=Z=>{Z.key==="ArrowLeft"&&(Z.preventDefault(),nA()),Z.key==="ArrowRight"&&(Z.preventDefault(),oA())};return window.addEventListener("keydown",iA),()=>window.removeEventListener("keydown",iA)},[oA,nA,tA,H]),!$||!_?c.jsx(I.Box,{...L,sx:Et({width:"100%",minHeight:180,display:"grid",placeItems:"center",borderRadius:b,border:`1px solid ${ce[300]}`,backgroundColor:Sr[50]},N),children:q}):cA?c.jsxs(I.Box,{...L,sx:Et({width:"fit-content"},N),children:[c.jsx(yT,{images:eA,maxVisible:l,thumbnailSize:u,thumbnailObjectFit:s,labels:J,summarySx:E,summaryItemSx:T,summaryCountSx:P,onOpenIndex:uA,onImageError:V}),c.jsx(t1,{open:H,selectedImage:_,selectedIndex:X,imageCount:$,hasMultipleImages:tA,showViewerCounter:g,canGoPrevious:W,canGoNext:rA,labels:J,viewerPaperSx:M,viewerImageSx:v,onImageError:V,onClose:K,onPrevious:nA,onNext:oA})]}):c.jsxs(I.Box,{...L,sx:Et({width:"100%",overflow:"hidden",borderRadius:b,border:`1px solid ${ce[300]}`,backgroundColor:Ue[50]},N),children:[c.jsx(fT,{selectedImage:_,hasMultipleImages:tA,showPreviewNavigation:p,openOnMainClick:h,mainAspectRatio:r,objectFit:i,activeColor:C,canGoPrevious:W,canGoNext:rA,labels:J,mainSx:y,mainImageSx:w,onImageError:V,onOpenViewer:AA,onPrevious:nA,onNext:oA}),sA&&c.jsx(vT,{images:eA,selectedIndex:X,thumbnailSize:a,thumbnailObjectFit:s,activeColor:C,labels:J,thumbnailListSx:D,thumbnailSx:k,onSelectIndex:Y,onImageError:V}),c.jsx(t1,{open:H,selectedImage:_,selectedIndex:X,imageCount:$,hasMultipleImages:tA,showViewerCounter:g,canGoPrevious:W,canGoNext:rA,labels:J,viewerPaperSx:M,viewerImageSx:v,onImageError:V,onClose:K,onPrevious:nA,onNext:oA})]})},cc=(A,e,t)=>Math.min(Math.max(A,e),t),uc=A=>Math.max(T0,A-lr-Yr),n1=(A,e)=>A==="left"?Yr:Math.max(Yr,e-lr-Yr),jB=(A,e)=>({side:A.x<e.width/2?"left":"right",top:cc(A.y-lr/2,T0,uc(e.height))}),o1=A=>{const e=A.split("?")[0].split("#")[0].trim();return!e||e==="/"?"/":e.endsWith("/")?e.slice(0,-1):e},LB=(A,e=[])=>{const t=o1(A);return e.some(o=>{const r=o1(o);if(r.includes("*")){const i=r.replace(/[.+?^${}()|[\]\\]/g,"\\$&").replaceAll("\\*",".*");return new RegExp(`^${i}$`).test(t)}return t===r||t.startsWith(`${r}/`)})},QB=A=>!Array.isArray(A)&&"itemNoCode"in A,UB=A=>!Array.isArray(A)&&"list"in A,E4=A=>!A||Array.isArray(A)?[]:UB(A)?A.list:QB(A)?[A]:[],I4=A=>+!!A.imageUrl+ +!!A.renderImageUrl,HB=A=>A.renderImageUrl??A.imageUrl,zB=A=>A.reduce((e,t)=>e+I4(t),0),D4=A=>{const e=[];return A.imageUrl&&e.push({id:`${A.itemNoCode}-image`,src:A.imageUrl,alt:`${A.itemNoCode} 3D`,title:"3D"}),A.renderImageUrl&&e.push({id:`${A.itemNoCode}-render`,src:A.renderImageUrl,alt:`${A.itemNoCode} Render`,title:"Render"}),e},VB=A=>A?Array.isArray(A)?A:E4(A).flatMap(D4):[],WB=()=>{const[A,e]=F.useState("");return F.useEffect(()=>{if(typeof window>"u")return;const t=()=>e(window.location.pathname),o=()=>{window.setTimeout(()=>{window.dispatchEvent(new Event(y2))},0)},r=window.history.pushState,i=window.history.replaceState;return window.history.pushState=function(...a){const l=r.apply(this,a);return o(),l},window.history.replaceState=function(...a){const l=i.apply(this,a);return o(),l},t(),window.addEventListener("popstate",t),window.addEventListener(y2,t),()=>{window.history.pushState=r,window.history.replaceState=i,window.removeEventListener("popstate",t),window.removeEventListener(y2,t)}},[]),A},GB=()=>{const[A,e]=F.useState({width:0,height:0});return F.useEffect(()=>{if(typeof window>"u")return;const t=()=>e({width:window.innerWidth,height:window.innerHeight});return t(),window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)},[]),A},YB=A=>{const[e,t]=F.useState({side:"right",top:160});return F.useEffect(()=>{A.height&&t(o=>({...o,top:cc(o.top,T0,uc(A.height))}))},[A.height]),{launcherPosition:e,setLauncherPosition:t}},KB=({label:A,position:e,viewportSize:t,onPositionChange:o,onOpen:r})=>{const i=_e.useAnimationControls(),s=F.useRef(!1),a=uc(t.height),l=n1(e.side,t.width),u=cc(e.top,T0,a);return F.useEffect(()=>{t.width&&i.start({x:l,y:u,transition:Fs})},[i,u,l,t.width]),c.jsx(Ir,{preset:!1,drag:!0,dragMomentum:!1,dragElastic:F1,"aria-label":A,title:A,onDragStart:()=>{s.current=!0},onDragEnd:(d,p)=>{const g=jB(p.point,t);o(g),i.start({x:n1(g.side,t.width),y:g.top,transition:Fs}),window.setTimeout(()=>{s.current=!1},j1)},initial:{x:l,y:u},animate:i,whileHover:{scale:1.05},whileTap:{scale:.96},onClick:()=>{s.current||r()},sx:{position:"fixed",left:0,top:0,width:lr,height:lr,zIndex:P1,borderRadius:"50%",cursor:"grab",touchAction:"none",userSelect:"none",display:"grid",placeItems:"center",background:`linear-gradient(145deg, ${ar[600]}, ${ar[900]})`},children:c.jsx(I.Box,{sx:{width:Ns,height:Ns,borderRadius:"50%",display:"grid",placeItems:"center",backgroundColor:L1,border:Q1},children:c.jsx(vA,{icon:"image_search",fill:1,sx:{color:Ue[50],fontSize:k1}})})})},XB=({activeIndex:A,items:e,onChange:t})=>{if(e.length<=1)return null;const o=zB(e);return c.jsxs(I.Stack,{gap:Cn,sx:{padding:wA,borderRadius:be,border:`1px solid ${_A[300]}`,backgroundColor:Sr[50]},children:[c.jsxs(At,{sx:{gap:wA},children:[c.jsxs(I.Typography,{children:["Tìm thấy ",e.length," mã thành phẩm"]}),c.jsxs(I.Typography,{children:[o," hình ảnh"]})]}),c.jsx(Le,{sx:{display:"grid",gridTemplateColumns:" repeat(3, minmax(0, 1fr))"},children:e.map((r,i)=>{const s=i===A,a=HB(r),l=I4(r);return c.jsx(I.ButtonBase,{"aria-label":`Chọn mã thành phẩm ${r.itemNoCode}`,onClick:()=>t(i),sx:{padding:Je,borderRadius:be,border:`1px solid ${s?xe[500]:ce[300]}`,backgroundColor:s?xe[50]:Ue[50],textAlign:"left",transition:$e,"&:hover":{borderColor:xe[500],backgroundColor:xe[50]},"&:focus-visible":{outline:`2px solid ${xe[500]}`,outlineOffset:"2px"}},children:c.jsxs(se,{sx:{width:"100%",gap:wA},children:[a&&c.jsx(nn,{url:a,sizeType:"FULL_WIDTH",size:It.AVATAR_GROUP}),c.jsxs(I.Stack,{sx:{minWidth:0,flex:1,gap:Je},children:[c.jsx(I.Typography,{sx:{...OA.textXs.semiBold,color:ce[900],overflowWrap:"anywhere"},children:r.itemNoCode}),c.jsxs(I.Typography,{sx:{color:_A[500]},children:[l," ảnh"]})]})]})},r.itemNoCode)})})]})},JB=({activeOptionIndex:A,defaultEmptyContent:e,displayLoading:t,galleryImages:o,galleryProps:r,loadingContent:i,open:s,panelTitle:a,searchContent:l,searchDebounceMs:u,searchLabel:d,searchName:p,searchPlaceholder:g,searchText:h,resultItems:m,onClose:f,onOptionChange:C,onSearchTextChange:b})=>c.jsx(Ua,{open:s,onClose:f,label:a,maxWidth:!1,sx:{width:M1,maxWidth:R1},sxContent:{maxHeight:N1},nodeContent:c.jsxs(I.Stack,{gap:wA,children:[l,c.jsx(A4,{label:d,name:p,value:h,placeholder:g,disabled:t,debounceMs:u,onChange:q=>b(q.target.value??""),searchIcon:"search"}),c.jsx(XB,{items:m,activeIndex:A,onChange:C}),c.jsx(S4,{...r,images:t&&!o.length?[]:o,emptyContent:t&&!o.length?i??c.jsx(ct,{}):e})]})}),T4=({images:A,open:e,defaultOpen:t=!1,hideLauncher:o=!1,isLoading:r=!1,searchLabel:i="Mã sản phẩm",searchPlaceholder:s="Nhập hoặc quét mã sản phẩm...",searchName:a="finishGoodItemNoCode",searchContent:l,searchDebounceMs:u=300,emptyContent:d,loadingContent:p,axiosProductManagement:g,blacklist:h,launcherLabel:m="Tra cứu hình ảnh sản phẩm",panelTitle:f="Hình ảnh thành phẩm",onOpenChange:C,onSearch:b,textEmpty:q="Không có hình ảnh 3D/render",...x})=>{const y=d??c.jsx(Fn,{content:q}),[w,E]=F.useState(""),[T,P]=F.useState(),[D,k]=F.useState(!1),[M,v]=F.useState(0),[B,O]=F.useState(t),R=F.useRef(b),N=F.useRef(0),L=WB(),G=GB(),{launcherPosition:U,setLauncherPosition:H}=YB(G),j=g?T:A,J=r||D,eA=F.useMemo(()=>E4(j),[j]),$=F.useMemo(()=>eA.length?D4(eA[M]??eA[0]):VB(j),[M,j,eA]),X=L?LB(L,h):!1,_=e??B,tA=V=>{e===void 0&&O(V),C==null||C(V)};R.current=b,F.useEffect(()=>{X&&tA(!1)},[X]),F.useEffect(()=>{v(0)},[j]);const cA=async(V=w)=>{var rA;const Y=V.trim();if(k0(Y))return;if(!g){(rA=R.current)==null||rA.call(R,Y);return}const W=N.current+1;N.current=W;try{k(!0);const nA=await q1(g,Y);if(N.current!==W)return;P(nA)}catch(nA){if(N.current!==W)return;P(void 0),console.error(nA)}finally{N.current===W&&k(!1)}},sA=V=>{E(V),cA(V)};return X||!G.width?null:c.jsxs(c.Fragment,{children:[!o&&!_&&c.jsx(KB,{label:m,position:U,viewportSize:G,onPositionChange:H,onOpen:()=>tA(!0)}),c.jsx(JB,{activeOptionIndex:M,defaultEmptyContent:y,displayLoading:J,galleryImages:$,loadingContent:p,open:_,panelTitle:f,galleryProps:x,searchContent:l,searchDebounceMs:u,searchLabel:i,searchName:a,searchPlaceholder:s,searchText:w,resultItems:eA,onClose:()=>tA(!1),onOptionChange:v,onSearchTextChange:sA})]})},ZB=({url:A,content:e,caption:t,sizeType:o=It.MEDIUM,sx:r,sxContent:i,sxCaption:s,alt:a="",userTitleName:l})=>c.jsxs(Le,{alignItems:"center",sx:{...r,gap:wA},children:[c.jsx(dt,{alt:a,url:A,size:o}),c.jsx(r4,{userTitleName:l,content:e,caption:t,sxContent:i,sxCaption:s})]}),B4=({time:A,hasText:e})=>c.jsx(I.Typography,{variant:"caption",sx:{...Ge(1),color:"text.disabled"},children:(e?"Cập nhật lúc ":"")+n3(A)}),O4=({time:A,content:e,height:t=z1})=>c.jsxs(Ae.Stack,{sx:{height:t,gap:0,justifyContent:"space-between",alignItems:"flex-start"},children:[c.jsx(ze,{content:e}),c.jsx(B4,{time:A})]}),_B=({url:A,content:e,time:t,sizeType:o=It.MEDIUM})=>c.jsxs(Le,{alignItems:"center",children:[c.jsx(dt,{url:A,size:o}),c.jsx(O4,{content:e,time:t})]}),$B=({loading:A,content:e,startIcon:t,endIcon:o,sx:r,permission:i,...s})=>i===!1?null:c.jsx(I.Button,{...s,startIcon:t&&!A&&c.jsx(nn,{url:t,sx:{width:Jn.small,height:Jn.small,borderRadius:Ls,opacity:s.disabled?.6:1}}),endIcon:o&&!A&&c.jsx(nn,{url:o,sx:{width:Jn.medium,height:Jn.medium,borderRadius:Ls,opacity:s.disabled?.6:1}}),sx:{textTransform:"none",borderRadius:Re,minWidth:"unset","& > .MuiButton-endIcon":{margin:0},...r},children:A?c.jsx(ct,{size:"small",sx:{minHeight:"24.5px"}}):c.jsx(I.Typography,{sx:{transform:"translateY(0.5px)",whiteSpace:"nowrap"},children:e})}),dc=({multiple:A=!1,onChange:e,accept:t="image/*",permission:o,loading:r=!1,...i})=>{if(o===!1)return null;const[s,a]=F.useState([]),l=F.useRef(null),u=d=>{if(d.target.files){const g=Array.from(d.target.files).map(h=>Object.assign(h,{preview:URL.createObjectURL(h)}));a(g),e(g)}};return F.useEffect(()=>()=>s==null?void 0:s.forEach(d=>{URL.revokeObjectURL(d.preview)}),[s]),c.jsxs(F.Fragment,{children:[c.jsx(I.Stack,{sx:{width:"fit-content",height:"fit-content"},children:c.jsx(So,{...i,loading:r,icon:"attach_file",onClick:()=>l.current&&l.current.click()})}),c.jsx("input",{type:"file",accept:t,hidden:!0,multiple:A,ref:l,onChange:u})]})},AO=(...A)=>A.flatMap(e=>e?Array.isArray(e)?e:[e]:[]),eO={minWidth:100,textTransform:"none",borderRadius:Re,width:"fit-content"},tO={...OA.textSm.regular,whiteSpace:"nowrap"},Qe=({content:A,loading:e=!1,startIcon:t,endIcon:o,variant:r="contained",sx:i,disabled:s=!1,...a})=>{const{palette:l}=I.useTheme();return c.jsx(I.Button,{...a,variant:r,startIcon:!e&&t?typeof t=="string"?c.jsx(vA,{icon:t,sx:{cursor:"pointer"}}):t:void 0,endIcon:!e&&o?typeof o=="string"?c.jsx(vA,{icon:o,sx:{cursor:"pointer"}}):o:void 0,sx:AO(eO,i),disabled:s,children:e?c.jsx(ct,{color:r==="contained"?l.primary.contrastText:a.color,size:"small",sx:{minHeight:"24.5px"}}):c.jsx(I.Typography,{sx:tO,children:A})})},pa=({label:A,name:e,size:t="small",sx:o,...r})=>c.jsx(I.FormControlLabel,{sx:{marginRight:0},name:e,control:c.jsx(I.Checkbox,{size:t,...r,sx:{paddingTop:0,paddingBottom:0,paddingRight:wA,borderRadius:10,"&:hover":{backgroundColor:"unset"},...o}}),label:A}),nO=({open:A,anchorEl:e,title:t="Tùy chỉnh trường",items:o,onClose:r,onToggle:i})=>c.jsx(I.Popover,{open:A,anchorEl:e,onClose:r,disableScrollLock:!0,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},slotProps:{paper:{sx:{mt:"8px",minWidth:320,maxHeight:520,borderRadius:bn,border:`1px solid ${ce[200]}`,boxShadow:"0 1px 2px rgba(15, 23, 42, 0.08), 0 1px 3px rgba(15, 23, 42, 0.1)",overflow:"hidden"}}},children:c.jsxs(I.Box,{sx:{backgroundColor:Ue[50]},children:[c.jsxs(se,{sx:{justifyContent:"space-between",padding:"12px 12px 10px 12px",borderBottom:`1px solid ${ce[200]}`},children:[c.jsx(I.Typography,{sx:{...OA.textMd.semiBold},children:t}),c.jsx(I.IconButton,{onClick:r,sx:{padding:.5},children:c.jsx(vA,{icon:"close"})})]}),c.jsx(io,{sx:{alignItems:"stretch",gap:.5,padding:"10px 8px",maxHeight:460,overflowY:"auto"},children:o.map(s=>c.jsxs(se,{sx:{justifyContent:"space-between",gap:1,padding:"8px 8px",borderRadius:Re,opacity:s.disabled?.6:1},children:[c.jsxs(se,{sx:{gap:1,minWidth:0},children:[c.jsx(vA,{icon:"drag_indicator",sx:{color:ce[400]}}),c.jsx(I.Typography,{sx:{...OA.textSm.regular,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:s.label})]}),c.jsx(I.Checkbox,{checked:s.checked,disabled:s.disabled,onChange:a=>i(s.key,a.target.checked),sx:{padding:0}})]},s.key))})]})}),oO=({headerAction:A,children:e,isCollapsible:t=!0,title:o,description:r,defaultExpanded:i=!0,sx:s,titleSx:a})=>{const[l,u]=F.useState(i),d=!!o&&t;return c.jsxs(I.Stack,{sx:{bgcolor:Ue[50],borderRadius:Re,overflow:"hidden",gap:wA,boxShadow:2,p:Oe,...s},children:[o&&c.jsxs(At,{onClick:()=>u(p=>!p),sx:{"&:hover":{cursor:"pointer"}},children:[c.jsxs(Le,{gap:wA,children:[c.jsx(ze,{content:o,sx:{...OA.textMd.semiBold,color:xe[500],...a}}),r]}),c.jsxs(se,{gap:0,children:[A,d&&c.jsx(So,{icon:l?"expand_less":"expand_more"})]})]}),c.jsx(I.Collapse,{in:!d||l,unmountOnExit:d,children:c.jsx(I.Stack,{sx:{gap:wA},children:e})})]})},rO=({orientation:A="horizontal",color:e=re.gray2,thickness:t=1,length:o="100%",sx:r,dashed:i=!0})=>A==="vertical"?c.jsx(Ae.Box,{sx:{height:o,display:"flex",justifyContent:"center",alignSelf:"center","&::before":{content:'""',width:`${t}px`,height:"100%",borderLeft:`${t}px ${i?"dashed":"solid"} ${e}`,...r}}}):c.jsx(Ae.Box,{sx:{borderBottom:`${t}px ${i?"dashed":"solid"} ${e}`,width:typeof o=="number"?`${o}px`:o,alignSelf:"stretch",display:"block",...r}}),k4="180px",fa="140px",P4="250px";var ln=(A=>(A.Equals="Equals",A.NotEquals="NotEquals",A.Contains="Contains",A.NotContains="NotContains",A.IsNull="IsNull",A.IsNotNull="IsNotNull",A.GreaterThan="GreaterThan",A.LessThan="LessThan",A.GreaterThanOrEqual="GreaterThanOrEqual",A.LessThanOrEqual="LessThanOrEqual",A))(ln||{}),Ee=(A=>(A.EXACT="EXACT",A.DATE_RANGE="DATE_RANGE",A.TODAY="TODAY",A.TOMORROW="TOMORROW",A.YESTERDAY="YESTERDAY",A.THIS_WEEK="THIS_WEEK",A.LAST_WEEK="LAST_WEEK",A.THIS_MONTH="THIS_MONTH",A.LAST_MONTH="LAST_MONTH",A.LAST_7_DAYS="LAST_7_DAYS",A.NEXT_7_DAYS="NEXT_7_DAYS",A.LAST_30_DAYS="LAST_30_DAYS",A.NEXT_30_DAYS="NEXT_30_DAYS",A))(Ee||{});const M4=[{label:"Là",value:"Equals"},{label:"Không là",value:"NotEquals"},{label:"Chứa",value:"Contains"},{label:"Không chứa",value:"NotContains"},{label:"Lớn hơn",value:"GreaterThan"},{label:"Lớn hơn hoặc bằng",value:"GreaterThanOrEqual"},{label:"Nhỏ hơn",value:"LessThan"},{label:"Nhỏ hơn hoặc bằng",value:"LessThanOrEqual"},{label:"Trống",value:"IsNull"},{label:"Không trống",value:"IsNotNull"}],R4=[{label:"Là",value:"Equals"},{label:"Không là",value:"NotEquals"},{label:"Chứa",value:"Contains"},{label:"Không chứa",value:"NotContains"},{label:"Trống",value:"IsNull"},{label:"Không trống",value:"IsNotNull"}],N4=[{label:"Là",value:"Equals"},{label:"Trống",value:"IsNull"},{label:"Không trống",value:"IsNotNull"}],F4=[{label:"ngày chính xác",value:"EXACT"},{label:"khoảng ngày",value:"DATE_RANGE"},{label:"hôm nay",value:"TODAY"},{label:"ngày mai",value:"TOMORROW"},{label:"hôm qua",value:"YESTERDAY"},{label:"tuần này",value:"THIS_WEEK"},{label:"tuần trước",value:"LAST_WEEK"},{label:"tháng này",value:"THIS_MONTH"},{label:"tháng trước",value:"LAST_MONTH"},{label:"trong 7 ngày qua",value:"LAST_7_DAYS"},{label:"trong 7 ngày tiếp theo",value:"NEXT_7_DAYS"},{label:"trong 30 ngày qua",value:"LAST_30_DAYS"},{label:"trong 30 ngày tiếp theo",value:"NEXT_30_DAYS"}],Rn=()=>typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():Math.random().toString(36).substring(2,9),j4=A=>{if(!A)return{};const e=DA().startOf("day"),t=A.split("|"),o=t[0];let r=e,i=e;if(o===Ee.EXACT){const s=t[1];if(s){const a=DA(s).startOf("day"),l=DA(s).endOf("day");return{fromDate:a.unix(),toDate:l.unix()}}return{}}if(o===Ee.DATE_RANGE){const s=t[1],a=t[2],l=s?DA(s).startOf("day").unix():void 0,u=a?DA(a).endOf("day").unix():void 0;return{fromDate:l,toDate:u}}switch(o){case Ee.TODAY:r=e.startOf("day"),i=e.endOf("day");break;case Ee.TOMORROW:r=e.add(1,"day").startOf("day"),i=e.add(1,"day").endOf("day");break;case Ee.YESTERDAY:r=e.subtract(1,"day").startOf("day"),i=e.subtract(1,"day").endOf("day");break;case Ee.THIS_WEEK:{const s=(7+(e.day()-1))%7;r=e.subtract(s,"day"),i=r.add(6,"day").endOf("day");break}case Ee.LAST_WEEK:{const s=(7+(e.day()-1))%7;r=e.subtract(s,"day").subtract(7,"day"),i=r.add(6,"day").endOf("day");break}case Ee.THIS_MONTH:r=e.startOf("month"),i=e.endOf("month");break;case Ee.LAST_MONTH:r=e.subtract(1,"month").startOf("month"),i=e.subtract(1,"month").endOf("month");break;case Ee.LAST_7_DAYS:r=e.subtract(7,"day"),i=e.endOf("day");break;case Ee.NEXT_7_DAYS:r=e,i=e.add(7,"day").endOf("day");break;case Ee.LAST_30_DAYS:r=e.subtract(30,"day"),i=e.endOf("day");break;case Ee.NEXT_30_DAYS:r=e,i=e.add(30,"day").endOf("day");break;default:return{}}return{fromDate:r.unix(),toDate:i.unix()}},iO=A=>A.reduce((e,t)=>(e[t.key]=t.defaultValue,e),{}),r1=(A,e)=>{const t=A.filter(r=>((e==null?void 0:e[r.key])??r.defaultValue)!==r.defaultValue).map(r=>({id:Rn(),fieldKey:r.key,value:(e==null?void 0:e[r.key])??r.defaultValue}));if(t.length>0)return t;const o=A[0];return o?[{id:Rn(),fieldKey:o.key,value:(e==null?void 0:e[o.key])??o.defaultValue}]:[]},sO=({open:A,title:e="Tùy chỉnh bộ lọc",fields:t,value:o,anchorEl:r,offset:i,onClose:s,onApply:a})=>{const l=F.useMemo(()=>iO(t),[t]),u=F.useMemo(()=>t.map(y=>({label:y.label,value:y.key})),[t]),[d,p]=F.useState(()=>r1(t,o)),[g,h]=F.useState(null);F.useEffect(()=>{A&&(p(r1(t,o)),h(null))},[t,A,o]);const m=()=>{const y=t[0];if(!y){p([]);return}p([{id:Rn(),fieldKey:y.key,value:y.defaultValue}])},f=y=>{p(w=>{const E=w.filter((P,D)=>D!==y);if(E.length>0)return E;const T=t[0];return T?[{id:Rn(),fieldKey:T.key,value:T.defaultValue}]:[]})},C=()=>{p(y=>{const w=new Set(y.map(T=>T.fieldKey)),E=t.find(T=>!w.has(T.key));return E?[...y,{id:Rn(),fieldKey:E.key,value:E.defaultValue}]:y})},b=y=>{g===null||y===g||(p(w=>{const E=[...w],[T]=E.splice(g,1);return E.splice(y,0,T),E}),h(null))},q=()=>{const y={...l};d.forEach(w=>{w.fieldKey&&(y[w.fieldKey]=w.value)}),a(y),s()},x=d.length<t.length;return c.jsx(I.Popover,{open:A,anchorEl:r,onClose:s,disableScrollLock:!0,anchorOrigin:{vertical:"bottom",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"left"},slotProps:{paper:{sx:{mt:`${(i==null?void 0:i.y)??8}px`,ml:`${(i==null?void 0:i.x)??0}px`,minWidth:320,maxWidth:"calc(100vw - 48px)",borderRadius:bn,border:`1px solid ${ce[300]}`,boxShadow:"0 8px 24px rgba(15, 23, 42, 0.12)",overflow:"hidden"}}},children:c.jsx(I.Box,{sx:{backgroundColor:Ue[50],padding:2},children:c.jsxs(io,{sx:{alignItems:"stretch",gap:2},children:[c.jsxs(At,{sx:{gap:1},children:[c.jsx(I.Typography,{sx:{...OA.textMd.semiBold},children:e}),c.jsx(I.IconButton,{onClick:s,sx:{padding:Je},children:c.jsx(vA,{icon:"close"})})]}),c.jsx(io,{sx:{alignItems:"stretch",gap:1.25},children:d.map((y,w)=>{const E=t.find(D=>D.key===y.fieldKey);if(!E)return null;const T=new Set(d.map(D=>D.fieldKey)),P=u.filter(D=>D.value===y.fieldKey||!T.has(D.value));return c.jsxs(se,{onDragOver:D=>D.preventDefault(),onDrop:()=>b(w),sx:{gap:1,alignItems:"flex-end"},children:[c.jsx(I.Box,{draggable:!0,onDragStart:()=>h(w),onDragEnd:()=>h(null),sx:{paddingBottom:"10px",cursor:"grab"},children:c.jsx(vA,{icon:"drag_indicator",sx:{color:ce[500]}})}),c.jsx(I.Box,{sx:{flex:1,minWidth:220},children:c.jsx(Mn,{label:"",value:y.fieldKey,options:P,placeholder:"",onChange:D=>{const k=D.target.value,M=t.find(v=>v.key===k);M&&p(v=>v.map((B,O)=>O===w?{...B,fieldKey:k,value:M.defaultValue}:B))}})}),c.jsx(I.Box,{sx:{flex:1,minWidth:220},children:c.jsx(Mn,{label:"",value:y.value??E.defaultValue,options:E.options,placeholder:"Tất cả",onChange:D=>{const k=D.target.value;p(M=>M.map((v,B)=>B===w?{...v,value:k}:v))}})}),c.jsx(I.IconButton,{onClick:()=>f(w),children:c.jsx(vA,{icon:"delete_outline"})})]},y.id)})}),x&&c.jsx(Qe,{content:"Thêm điều kiện",onClick:C,startIcon:"add",variant:"text",sx:{color:xe[500],minWidth:0,paddingX:0}}),c.jsxs(At,{sx:{marginTop:1},children:[c.jsx(Qe,{content:"Mặc định",onClick:m,variant:"text",sx:{color:xe[500],minWidth:0,paddingX:0}}),c.jsxs(se,{sx:{gap:1},children:[c.jsx(Qe,{onClick:s,variant:"outlined",content:"Hủy"}),c.jsx(Qe,{onClick:q,variant:"contained",content:"Áp dụng"})]})]})]})})})},aO=({field:A,rowValue:e,onChange:t})=>{switch(A.type){case"select":return c.jsx(Mn,{label:"",value:e??A.defaultValue,options:A.options||[],placeholder:"Tất cả",onChange:o=>t(o.target.value)});case"date":{const o=e?e.split("|"):"",r=o[0],i=r===Ee.EXACT?o[1]:"",s=r===Ee.DATE_RANGE?o[1]:"",a=r===Ee.DATE_RANGE?o[2]:"",l=r===Ee.EXACT||r===Ee.DATE_RANGE;return c.jsxs(I.Box,{sx:{display:"flex",gap:wA,width:"100%"},children:[c.jsx(I.Box,{sx:{width:l?"140px":"100%",flexShrink:0},children:c.jsx(Mn,{label:"",value:r,options:F4,placeholder:"",onChange:u=>{const d=u.target.value;let p=d;d===Ee.EXACT&&(p=`${Ee.EXACT}|`),d===Ee.DATE_RANGE&&(p=`${Ee.DATE_RANGE}||`),t(p)}})}),r===Ee.EXACT&&c.jsx(I.Box,{sx:{flex:1},children:c.jsx($f,{name:`exact-date-${Rn()}`,label:"",value:i||null,onChange:u=>{const d=u.target.value,p=d?DA(d).format("YYYY-MM-DD"):"";t(`${Ee.EXACT}|${p}`)}})}),r===Ee.DATE_RANGE&&c.jsx(I.Box,{sx:{flex:1},children:c.jsx(jf,{format:"DD/MM/YYYY",placeholder:"Ngày bắt đầu — Ngày kết thúc",label:"",fromDate:s,toDate:a,onFromDateChange:u=>{const d=u?DA(u).format("YYYY-MM-DD"):"";t(`${Ee.DATE_RANGE}|${d}|${a}`)},onToDateChange:u=>{const d=u?DA(u).format("YYYY-MM-DD"):"";t(`${Ee.DATE_RANGE}|${s}|${d}`)}})})]})}}},lO=({open:A,title:e="Tùy chỉnh bộ lọc nâng cao",fields:t,value:o,operatorOptions:r=R4,fullOperator:i=!1,anchorEl:s,offset:a,onClose:l,onApply:u})=>{const[d,p]=F.useState([]),[g,h]=F.useState(null);F.useEffect(()=>{A&&(o&&o.length>0?p(o.map(E=>({id:Rn(),fieldKey:E.field,operator:E.operator,value:E.value}))):p([]),h(null))},[A,o]);const m=(E,T)=>{p(P=>P.map((D,k)=>k===E?{...D,...T}:D))},f=()=>p([]),C=E=>p(T=>T.filter((P,D)=>D!==E)),b=()=>{p(E=>{if(E.length>=t.length)return E;const T=new Set(E.map(D=>D.fieldKey)),P=t.find(D=>!T.has(D.key))||t[0];return P?[...E,{id:Rn(),fieldKey:P.key,operator:ln.Equals,value:P.defaultValue}]:E})},q=E=>{g===null||E===g||(p(T=>{const P=[...T],[D]=P.splice(g,1);return P.splice(E,0,D),P}),h(null))},x=()=>{const E=d.filter(T=>T.fieldKey).map(T=>{const P=t.find(v=>v.key===T.fieldKey);let D,k;if((P==null?void 0:P.type)==="date"&&T.operator!==ln.IsNull&&T.operator!==ln.IsNotNull){const v=j4(T.value);D=v.fromDate,k=v.toDate}return{field:T.fieldKey,operator:T.operator,value:T.operator===ln.IsNull||T.operator===ln.IsNotNull?"":T.value,fromDate:D,toDate:k}});u(E),l()},y=t.map(E=>({label:E.label,value:E.key})),w=d.map(E=>E.fieldKey);return c.jsx(I.Popover,{open:A,anchorEl:s,onClose:l,disableScrollLock:!0,anchorOrigin:{vertical:"bottom",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"left"},slotProps:{paper:{sx:{mt:`${(a==null?void 0:a.y)??8}px`,ml:`${(a==null?void 0:a.x)??0}px`,width:"max-content",minWidth:"800px",maxWidth:"calc(100vw - 48px)",boxShadow:4,overflow:"hidden"}}},children:c.jsx(Ae.Stack,{sx:{backgroundColor:ce[50],padding:V1},children:c.jsxs(Ae.Stack,{children:[c.jsxs(At,{children:[c.jsx(I.Typography,{sx:{...OA.textMd.semiBold},children:e}),c.jsx(I.IconButton,{onClick:l,sx:{padding:Je},children:c.jsx(vA,{icon:"close"})})]}),c.jsxs(Ae.Stack,{children:[d.length===0&&c.jsx(I.Typography,{sx:{color:ce[400],fontStyle:"italic"},children:"Chưa có điều kiện lọc nào được áp dụng."}),d.map((E,T)=>{const P=t.find(B=>B.key===E.fieldKey);if(!P)return null;const D=P.type==="date";i&&(r=M4);const k=D?N4:r,M=E.operator===ln.IsNull||E.operator===ln.IsNotNull,v=y.filter(B=>!w.includes(B.value)||B.value===E.fieldKey);return c.jsxs(se,{onDragOver:B=>B.preventDefault(),onDrop:()=>q(T),sx:{gap:wA},children:[c.jsx(Ae.Stack,{draggable:!0,onDragStart:()=>h(T),onDragEnd:()=>h(null),sx:{cursor:"grab"},children:c.jsx(vA,{icon:"drag_indicator",sx:{color:ce[400]}})}),c.jsx(Ae.Stack,{sx:{width:k4},children:c.jsx(Mn,{label:"",value:E.fieldKey,options:v,placeholder:"",onChange:B=>{const O=B.target.value,R=t.find(N=>N.key===O);R&&m(T,{fieldKey:O,value:R.defaultValue,operator:ln.Equals})}})}),c.jsx(Ae.Stack,{sx:{width:fa},children:c.jsx(Mn,{label:"",value:E.operator,options:k,placeholder:"",onChange:B=>{const O=B.target.value,R=E.value;m(T,{operator:O,value:R})},sx:{width:fa}})}),c.jsx(Ae.Stack,{sx:{flex:1,minWidth:P4},children:M?c.jsx(Mn,{label:"",value:"",options:[],placeholder:"---",disabled:!0}):c.jsx(aO,{field:P,rowValue:E.value,onChange:B=>m(T,{value:B})})}),c.jsx(I.IconButton,{onClick:()=>C(T),children:c.jsx(vA,{icon:"delete_outline"})})]},E.id)})]}),d.length<t.length&&c.jsx(Qe,{content:"Thêm điều kiện",onClick:b,startIcon:"add",variant:"text"}),c.jsxs(At,{sx:{marginTop:xa},children:[c.jsx(Ae.Stack,{onClick:f,sx:{cursor:"pointer",color:xe[500]},children:"Mặc định"}),c.jsxs(se,{sx:{gap:1},children:[c.jsx(Qe,{onClick:l,variant:"outlined",content:"Hủy",sx:{borderRadius:Re}}),c.jsx(Qe,{onClick:x,variant:"contained",content:"Áp dụng",sx:{borderRadius:Re}})]})]})]})})})},cO=({children:A,onApply:e,onReset:t,initialFilters:o={},sx:r={},ignoredKeysInCount:i=[]})=>{const[s,a]=F.useState(!1),[l,u]=F.useState(o),[d,p]=F.useState(o),g=Object.entries(l).filter(([C,b])=>i.includes(C)?!1:Array.isArray(b)?b.length>0:b!=null&&b!=="").length;F.useEffect(()=>{s&&p({...l})},[l,s]);const h=(C,b)=>{p(q=>({...q,[C]:b}))},m=()=>{u(d),e==null||e(d),a(!1)},f=()=>{p({}),u({}),t==null||t(),a(!1)};return c.jsxs(F.Fragment,{children:[c.jsx(Qe,{sx:{...r,color:(g>0,xe[500]),minWidth:"auto",p:Kr},startIcon:"filter_list_alt",variant:"outlined",onClick:()=>a(!0),content:`Bộ lọc${g>0?` (${g})`:""}`}),c.jsx(I.Drawer,{anchor:"right",open:s,onClose:()=>a(!1),sx:{"& .MuiDrawer-paper":{width:320,padding:Oe}},children:c.jsxs(Ae.Stack,{sx:{height:"100%"},children:[c.jsxs(At,{sx:{gap:0},children:[c.jsx(ze,{content:"Bộ lọc",sx:{...OA.textLg.semiBold}}),c.jsx(I.IconButton,{onClick:()=>a(!1),children:c.jsx(vA,{icon:"close"})})]}),c.jsx(Ae.Stack,{sx:{flex:1,gap:wA,overflowY:"auto",scrollbarWidth:"none","&::-webkit-scrollbar":{display:"none"}},children:A({filters:l,tempFilters:d,setFilter:h,setTempFilters:p})}),c.jsxs(E3,{sx:{gap:wA},children:[c.jsx(Qe,{variant:"outlined",onClick:f,content:"Đặt lại"}),c.jsx(Qe,{variant:"contained",onClick:m,content:"Cập nhật"})]})]})})]})},Nt=56,i1=42,s1=26,uO=12,k2=18,rs=76,dO=160,a1={type:"spring",stiffness:520,damping:34},pO=A=>(Nt+uO)*(A+1),pc=(A,e,t)=>Math.min(Math.max(A,e),t),ni=A=>Math.max(rs,A-Nt-k2),l1=(A,e)=>A==="left"?k2:Math.max(k2,e-Nt-k2),fO=(A,e)=>({side:A.x<e.width/2?"left":"right",top:pc(A.y-Nt/2,rs,ni(e.height))}),gO=(A,e,t)=>({position:"absolute",right:0,bottom:t?pO(e):0,width:Nt,height:Nt,borderRadius:"50%",opacity:t?1:0,pointerEvents:t?"auto":"none",transform:t?"scale(1)":"scale(0.82)",transition:`bottom ${$e}, opacity ${$e}, transform ${$e}`,backgroundColor:A.backgroundColor??Ue[50],border:`2px solid ${xe[200]}`,boxShadow:"0 10px 24px rgba(0, 0, 0, 0.2)","&:hover":{borderColor:xe[500],transform:t?"scale(1.04)":"scale(0.82)"},"&:focus-visible":{outline:`2px solid ${xe[300]}`,outlineOffset:"2px"}}),mO=()=>{const[A,e]=F.useState({width:0,height:0});return F.useEffect(()=>{if(typeof window>"u")return;const t=()=>e({width:window.innerWidth,height:window.innerHeight});return t(),window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)},[]),A},hO=A=>{const[e,t]=F.useState(null);return F.useEffect(()=>{!A.width||!A.height||t(o=>o?{...o,top:pc(o.top,rs,ni(A.height))}:{side:"right",top:ni(A.height)})},[A.width,A.height]),{position:e,setPosition:t}},L4=({closeOnActionClick:A=!0,items:e,launcherIcon:t="chat",launcherLabel:o="Công cụ",sx:r})=>{const[i,s]=F.useState(!1),a=_e.useAnimationControls(),l=F.useRef(!1),u=mO(),{position:d,setPosition:p}=hO(u),g=!!u.width&&!!u.height&&!!d,h=d?l1(d.side,u.width):0,m=d?pc(d.top,rs,ni(u.height)):0,f=r&&!Array.isArray(r)&&typeof r=="object"?r:void 0;F.useEffect(()=>{!d||!u.width||a.start({x:h,y:m,transition:a1})},[a,d,m,h,u.width]);const C=c.jsxs(I.Stack,{sx:{position:"relative",width:Nt,height:Nt},children:[e.map((b,q)=>c.jsx(I.ButtonBase,{"aria-label":b.label,title:b.label,disabled:b.disabled,onClick:()=>{A&&s(!1),b.onClick()},sx:gO(b,q,i),children:c.jsx(vA,{icon:b.icon,fill:1,sx:{color:b.color??xe[700],fontSize:s1}})},b.key)),c.jsx(I.ButtonBase,{"aria-label":o,title:o,onClick:()=>{l.current||s(b=>!b)},sx:{position:"absolute",right:0,bottom:0,width:Nt,height:Nt,borderRadius:"50%",backgroundColor:Ue[50],border:`2px solid ${xe[200]}`,boxShadow:"0 10px 24px rgba(0, 0, 0, 0.22)","&:hover":{borderColor:xe[500]},"&:focus-visible":{outline:`2px solid ${xe[300]}`,outlineOffset:"2px"}},children:c.jsx(I.Box,{sx:{width:i1,height:i1,borderRadius:"50%",display:"grid",placeItems:"center",backgroundColor:xe[700],transform:i?"scale(0.96)":"scale(1)",transition:$e},children:c.jsx(vA,{icon:i?"close":t,fill:1,sx:{color:Ue[50],fontSize:s1}})})})]});return!g||!d?null:c.jsx(Ir,{preset:!1,drag:!0,dragMomentum:!1,dragElastic:.08,onDragStart:()=>{l.current=!0},onDragEnd:(b,q)=>{const x=fO(q.point,u);p(x),a.start({x:l1(x.side,u.width),y:x.top,transition:a1}),window.setTimeout(()=>{l.current=!1},dO)},initial:{x:h,y:m},animate:a,whileHover:{scale:1.05},whileTap:{scale:.96},sx:{position:"fixed",left:0,top:0,width:Nt,height:Nt,zIndex:1400,cursor:"grab",touchAction:"none",userSelect:"none",...f},children:C})},fc=9600,Q4=20;var YA=(A=>(A.Idle="idle",A.Connecting="connecting",A.Connected="connected",A.Disconnecting="disconnecting",A.Error="error",A))(YA||{}),is=(A=>(A.None="none",A.Even="even",A.Odd="odd",A))(is||{}),U4=(A=>(A.None="none",A.Hardware="hardware",A))(U4||{});const c1="sevago:web-serial-scale-active-window",u1=300,CO=500,bO=20,ks=()=>{if(!(typeof navigator>"u"))return navigator.serial},d1=()=>typeof window>"u"?!1:window.isSecureContext,p1=A=>{const e=A instanceof DOMException?A.name:A instanceof Error?A.constructor.name:"Unknown",t=A instanceof Error?A.message:String(A);return`[${e}] ${t}`},yO=A=>A.map((e,t)=>({index:t,label:`Cân ${t+1}`})),vO=(A,e)=>{var o;const t=(o=A.getInfo)==null?void 0:o.call(A);return!(!t||e.usbVendorId!=null&&t.usbVendorId!==e.usbVendorId||e.usbProductId!=null&&t.usbProductId!==e.usbProductId)},xO=(A,e)=>{const t=e==null?void 0:e.filters;return t!=null&&t.length?A.filter(o=>t.some(r=>vO(o,r))):A},H4=A=>{const e=A.match(/[-+]?\d+(?:[.,]\d+)?/);if(!e)return;const t=e[0].replace(",","."),o=Number(t);return{rawLine:A,value:t,numericValue:Number.isFinite(o)?o:void 0,receivedAt:Date.now()}},gc=({serialOptions:A,requestOptions:e,lineLimit:t=Q4,autoConnectAuthorized:o=!1,autoSwitchActiveWindow:r=!1,parseReading:i=H4,onReading:s,onStatusChange:a,onError:l})=>{const[u,d]=F.useState(YA.Idle),[p,g]=F.useState("Chưa kiểm tra"),[h,m]=F.useState(""),[f,C]=F.useState([]),[b,q]=F.useState(),[x,y]=F.useState([]),[w,E]=F.useState(!1),[T,P]=F.useState(!1),D=F.useRef(void 0),k=F.useRef(void 0),M=F.useRef(void 0),v=F.useRef(void 0),B=F.useRef(!0),O=F.useRef(0),R=F.useRef(YA.Idle),N=F.useRef(!1),L=F.useRef(`web-serial-scale-${Date.now()}-${Math.random().toString(36).slice(2)}`),G=F.useRef(!1),U=F.useCallback(V=>{R.current=V,d(V),a==null||a(V)},[a]),H=F.useCallback(V=>{m(V),l==null||l(V)},[l]),j=F.useCallback(async()=>{if(G.current){G.current=!1;return}if(!r||typeof BroadcastChannel>"u")return;const V=new BroadcastChannel(c1);V.postMessage({senderId:L.current,type:"claim"}),await new Promise(Y=>{window.setTimeout(Y,u1)}),V.close()},[r]),J=F.useCallback(V=>{if(!V.trim())return;C(nA=>[...nA.slice(-(Math.max(t,1)-1)),V]);const Y=i(V);if(!(Y!=null&&Y.value))return;const W=Y.receivedAt??Date.now(),rA={...Y,rawLine:Y.rawLine??V,receivedAt:W};q(rA),s==null||s(rA)},[t,s,i]),eA=F.useCallback(async(V,Y)=>{if(!V.readable)return;const W=new TextDecoderStream;M.current=V.readable.pipeTo(W.writable).catch(()=>{});const rA=W.readable.getReader();k.current=rA;let nA="";try{for(;!B.current&&O.current===Y;){const{value:oA,done:AA}=await rA.read();if(AA)break;if(!oA)continue;nA+=oA;const uA=nA.split(/\r?\n/);nA=uA.pop()??"",uA.forEach(J)}}catch(oA){if(!B.current&&O.current===Y){const AA=p1(oA);H(AA),U(YA.Error)}}finally{try{rA.releaseLock()}catch{}k.current===rA&&(k.current=void 0)}},[J,H,U]),$=F.useCallback(async()=>{B.current=!0,O.current+=1;const V=k.current;if(V)try{await V.cancel()}catch{}if(v.current)try{await v.current}catch{}if(M.current)try{await M.current}catch{}const Y=D.current;if(Y)try{await Y.close()}catch{}k.current=void 0,M.current=void 0,v.current=void 0,D.current=void 0},[]),X=F.useCallback(async V=>{try{await V.open(A);return}catch(Y){if(!(Y instanceof DOMException)||Y.name!=="InvalidStateError")throw Y;D.current=V,await $(),await V.open(A)}},[$,A]),_=F.useCallback(async()=>{const V=ks();if(!V)return y([]),[];const Y=xO(await V.getPorts(),e);return y(yO(Y)),Y},[e]),tA=F.useCallback(async V=>{if(R.current===YA.Connecting||R.current===YA.Disconnecting)return;const Y=ks(),W=d1();if(E(!!Y),P(W),g(Y?"navigator.serial: có":"navigator.serial: không"),!W){H("Web Serial API cần HTTPS hoặc localhost để trình duyệt cho phép truy cập cổng COM."),U(YA.Error);return}if(!Y){H("Trình duyệt không hỗ trợ Web Serial API. Hãy dùng Chrome hoặc Edge."),U(YA.Error);return}q(void 0),U(YA.Connecting),m("");try{await j(),await $();const rA=V!=null&&V.useAuthorizedPort?await _():[],nA=rA[(V==null?void 0:V.authorizedPortIndex)??0]??rA[0];if(V!=null&&V.useAuthorizedPort&&rA.length===0){if(!V.silentNoAuthorizedPort){H("Chưa có cổng cân nào được trình duyệt cấp quyền. Hãy bấm Kết nối cân trước."),U(YA.Error);return}U(YA.Idle);return}const oA=nA??await Y.requestPort(e);nA||await _(),await X(oA),D.current=oA,B.current=!1,O.current+=1,U(YA.Connected),v.current=eA(oA,O.current)}catch(rA){await $(),H(p1(rA)),U(YA.Error)}},[$,X,eA,_,e,j,H,U]),cA=F.useCallback(async()=>{if(!D.current&&R.current!==YA.Error){U(YA.Idle);return}U(YA.Disconnecting),q(void 0),await $(),U(YA.Idle)},[$,U]),sA=F.useCallback(()=>{C([])},[]);return F.useEffect(()=>{const V=ks(),Y=d1();E(!!V),P(Y),g(V?"navigator.serial: có":"navigator.serial: không"),_()},[_]),F.useEffect(()=>{if(!o){N.current=!1;return}if(N.current)return;N.current=!0,(async()=>{(await _()).length===1&&tA({useAuthorizedPort:!0,authorizedPortIndex:0,silentNoAuthorizedPort:!0})})()},[o,tA,_]),F.useEffect(()=>{if(!r||typeof window>"u"||typeof document>"u")return;let V,Y=0;const W=typeof BroadcastChannel>"u"?void 0:new BroadcastChannel(c1),rA=()=>{V&&(window.clearTimeout(V),V=void 0)},nA=()=>document.visibilityState!=="hidden"&&document.hasFocus(),oA=async()=>(await _()).length!==1?!1:(G.current=!0,await tA({useAuthorizedPort:!0,authorizedPortIndex:0,silentNoAuthorizedPort:!0}),R.current===YA.Connected),AA=(aA=u1)=>{nA()&&(R.current===YA.Connected||R.current===YA.Connecting||R.current===YA.Disconnecting||(rA(),V=window.setTimeout(async()=>{if(await oA()||!nA()){Y=0;return}if(Y+=1,Y>bO){Y=0;return}AA(CO)},aA)))},uA=()=>{rA(),Y=0,!(R.current!==YA.Connected&&R.current!==YA.Connecting&&R.current!==YA.Error)&&cA()},K=()=>{nA()&&(W==null||W.postMessage({senderId:L.current,type:"claim"}),AA())},iA=()=>{if(document.visibilityState==="hidden"){uA();return}K()},Z=aA=>{aA.data.senderId!==L.current&&aA.data.type==="claim"&&uA()};return W==null||W.addEventListener("message",Z),window.addEventListener("focus",K),window.addEventListener("blur",uA),document.addEventListener("visibilitychange",iA),K(),()=>{rA(),W==null||W.removeEventListener("message",Z),W==null||W.close(),window.removeEventListener("focus",K),window.removeEventListener("blur",uA),document.removeEventListener("visibilitychange",iA)}},[r,tA,cA,_]),F.useEffect(()=>()=>{$()},[$]),{status:u,supportInfo:p,error:h,lines:f,reading:b,authorizedPorts:x,isSupported:w,isSecureContext:T,connect:tA,disconnect:cA,clearLines:sA}},qO=({targets:A=[],defaultTargetName:e,selectedTargetName:t,defaultBaudRate:o=fc,defaultAutoApply:r=!0,applyLatestOnTargetChange:i=!0,autoApplyIntervalMs:s=0,autoConnectAuthorized:a=!0,autoSwitchActiveWindow:l=!1,allowRequestPort:u=!0,lineLimit:d,requestOptions:p,onReading:g,onApply:h,sx:m})=>{const[f,C]=F.useState(e??""),b=F.useRef(void 0),q=F.useRef(void 0),x=F.useRef(void 0),y=F.useMemo(()=>Array.isArray(m)?m:m?[m]:[],[m]),w=t??f,E=F.useMemo(()=>A.find(L=>L.name===w),[w,A]),T=F.useMemo(()=>({baudRate:o,dataBits:8,stopBits:1,parity:is.None}),[o]),{status:P,reading:D,authorizedPorts:k,connect:M,disconnect:v}=gc({serialOptions:T,requestOptions:p,lineLimit:d,autoConnectAuthorized:a,autoSwitchActiveWindow:l,onReading:g}),B=P===YA.Connected,O=P===YA.Connecting||P===YA.Disconnecting,R=F.useCallback(L=>{t===void 0&&C(L)},[t]),N=F.useCallback(async()=>{var G;if(!B||!E||!(D!=null&&D.value)||E.disabled)return;const L=Date.now();if(q.current!==D.value&&!(b.current&&L-b.current<s))try{b.current=L,q.current=D.value,await((G=E.onApply)==null?void 0:G.call(E,D)),h==null||h(D,E)}catch{}},[E,s,B,h,D]);return F.useEffect(()=>{if(!A.length){R("");return}if(E||!e)return;const L=A.find(G=>G.name===e);L&&R(L.name)},[E,e,R,A]),F.useEffect(()=>{!r||!(D!=null&&D.receivedAt)||b.current===D.receivedAt||N()},[N,r,D==null?void 0:D.receivedAt]),F.useEffect(()=>{x.current!==w&&(x.current=w,!(!r||!i||!(D!=null&&D.value))&&N())},[w,i,N,r,D==null?void 0:D.value]),c.jsxs(se,{sx:[{gap:wA,flexWrap:"wrap"},...y],children:[B?c.jsx(Qe,{content:"Ngắt kết nối",startIcon:"link_off",variant:"outlined",color:"error",loading:O,disabled:O,onClick:()=>v()}):null,!B&&k.length===1?c.jsx(gn,{content:`Kết nối ${k[0].label} đã được trình duyệt cấp quyền.`,children:c.jsx(Qe,{content:k[0].label,startIcon:"scale",variant:"outlined",loading:O,disabled:O,onClick:()=>M({useAuthorizedPort:!0,authorizedPortIndex:k[0].index})})}):null,!B&&k.length>1?k.map(L=>c.jsx(gn,{content:`Kết nối ${L.label}`,children:c.jsx(Qe,{content:L.label,startIcon:"scale",variant:"outlined",loading:O,disabled:O,onClick:()=>M({useAuthorizedPort:!0,authorizedPortIndex:L.index})})},L.index)):null,!B&&u?c.jsx(gn,{content:"Kết nối cân mới trong danh sách cân đã được cấp quyền truy cập.",children:c.jsx(Qe,{content:P===YA.Connecting?"Đang kết nối...":k.length?"Kết nối cân khác":"Kết nối cân",startIcon:"usb",loading:O,disabled:O,onClick:()=>M()})}):null]})},z4=F.createContext(void 0),wO=A=>{const e=(A==null?void 0:A.targets)??[];if(e.length)return e.find(t=>t.name===(A==null?void 0:A.selectedTargetName))??e[0]},V4=({autoConnectAuthorized:A=!0,autoSwitchActiveWindow:e=!0,children:t,defaultBaudRate:o=fc,enabled:r=!0,lineLimit:i,onError:s,onReading:a,onStatusChange:l,parseReading:u,requestOptions:d,serialOptions:p})=>{const g=F.useRef(void 0),h=F.useRef(void 0),m=F.useMemo(()=>p??{baudRate:o,dataBits:8,stopBits:1,parity:is.None},[o,p]),f=gc({autoConnectAuthorized:r&&A,autoSwitchActiveWindow:r&&e,lineLimit:i,onError:s,onReading:a,onStatusChange:l,parseReading:u,requestOptions:d,serialOptions:m}),{disconnect:C,status:b}=f;F.useEffect(()=>{r||(g.current=void 0,h.current=void 0,(b===YA.Connected||b===YA.Connecting||b===YA.Error)&&C().catch(()=>{}))},[C,r,b]);const q=F.useCallback(w=>(g.current=w,h.current=void 0,()=>{g.current===w&&(g.current=void 0,h.current=void 0)}),[]),x=F.useCallback(async w=>{var D,k;if(!r)return;const E=g.current;if(!E||E.enabled===!1||E.defaultAutoApply===!1||!w.value)return;const T=wO(E);if(!T||T.disabled)return;const P=h.current;(P==null?void 0:P.targetName)===T.name&&P.value===w.value||(h.current={targetName:T.name,value:w.value},await((D=T.onApply)==null?void 0:D.call(T,w)),await((k=E.onApply)==null?void 0:k.call(E,w,T)))},[r]);F.useEffect(()=>{var w;(w=f.reading)!=null&&w.receivedAt&&x(f.reading).catch(()=>{})},[x,f.reading]);const y=F.useMemo(()=>({...f,registerTargets:q}),[q,f]);return c.jsx(z4.Provider,{value:y,children:t})},ss=()=>F.useContext(z4),SO=A=>{const e=ss();return F.useEffect(()=>{if(!(!e||A.enabled===!1))return e.registerTargets(A)},[e,A]),!!e},EO=({emptyContent:A="Chưa khởi tạo kết nối cân dùng chung.",sx:e})=>{const t=ss(),o=Array.isArray(e)?e:e?[e]:[];if(!t)return c.jsx(ze,{content:A,sx:{color:_A[600]}});const r=t.status===YA.Connected,i=t.status===YA.Connecting||t.status===YA.Disconnecting,s=r?"Đã kết nối cân":t.status===YA.Connecting?"Đang kết nối cân...":"Chưa kết nối cân";return c.jsxs(I.Stack,{sx:[{gap:wA},...o],children:[c.jsx(ze,{content:s,sx:{...OA.textSm.semiBold,color:r?to[700]:_A[700]}}),t.error?c.jsx(ze,{content:t.error,sx:{...OA.textXs.regular,color:Ft[700]}}):null,c.jsxs(se,{sx:{gap:wA,flexWrap:"wrap"},children:[r?c.jsx(Qe,{content:"Ngắt kết nối",startIcon:"link_off",variant:"outlined",color:"error",loading:i,disabled:i,onClick:()=>t.disconnect()}):null,!r&&t.authorizedPorts.length===1?c.jsx(gn,{content:`Kết nối ${t.authorizedPorts[0].label} đã được trình duyệt cấp quyền.`,children:c.jsx(Qe,{content:t.authorizedPorts[0].label,startIcon:"scale",variant:"outlined",loading:i,disabled:i,onClick:()=>t.connect({useAuthorizedPort:!0,authorizedPortIndex:t.authorizedPorts[0].index})})}):null,!r&&t.authorizedPorts.length>1?t.authorizedPorts.map(a=>c.jsx(gn,{content:`Kết nối ${a.label}`,children:c.jsx(Qe,{content:a.label,startIcon:"scale",variant:"outlined",loading:i,disabled:i,onClick:()=>t.connect({useAuthorizedPort:!0,authorizedPortIndex:a.index})})},a.index)):null,r?null:c.jsx(Qe,{content:t.status===YA.Connecting?"Đang kết nối...":"Kết nối cân",startIcon:"usb",loading:i,disabled:i,onClick:()=>t.connect()})]})]})},IO=({axiosProductManagement:A,enableFinishGoodGallery:e=!0,enableScale:t=!0,items:o=[],scaleAutoConnectAuthorized:r=!0})=>{const i=ss(),[s,a]=F.useState(!1),l=F.useRef(void 0),u=F.useRef(!1),d=(i==null?void 0:i.status)===YA.Connected,p=(i==null?void 0:i.status)===YA.Idle,g=(i==null?void 0:i.status)===YA.Connecting||(i==null?void 0:i.status)===YA.Disconnecting;F.useEffect(()=>{t||(l.current=void 0,u.current=!1)},[t]),F.useEffect(()=>{if(!t||!r||u.current||!i||!p||i.authorizedPorts.length!==1)return;const m=i.authorizedPorts[0],f=`${m.index}:${m.label}`;l.current!==f&&(l.current=f,i.connect({useAuthorizedPort:!0,authorizedPortIndex:m.index,silentNoAuthorizedPort:!0}))},[t,p,i,r]);const h=F.useMemo(()=>{const m=[];return t&&m.push({key:"scale",label:d?"Ngắt kết nối cân":"Kết nối cân",icon:"scale",disabled:!i||g,backgroundColor:d?to[50]:void 0,color:d?to[700]:void 0,onClick:()=>{if(!(!i||g)){if(d){u.current=!0,i.disconnect();return}if(u.current=!1,i.authorizedPorts.length){i.connect({useAuthorizedPort:!0,authorizedPortIndex:i.authorizedPorts[0].index});return}i.connect()}}}),e&&m.push({key:"finish-good-gallery",label:"Hình ảnh thành phẩm",icon:"image_search",onClick:()=>a(!0)}),m.push(...o),m},[e,t,g,d,o,i]);return h.length?c.jsxs(c.Fragment,{children:[c.jsx(L4,{items:h,launcherIcon:"support_agent",launcherLabel:"Công cụ"}),e?c.jsx(T4,{axiosProductManagement:A,hideLauncher:!0,open:s,onOpenChange:a}):null]}):null},W4=({titleNode:A,list:e,sxList:t={},sxListItem:o={},sxIconContent:r={},sxTitleNode:i={}})=>{const{palette:s}=I.useTheme();return c.jsxs(I.List,{sx:{display:"flex",flexDirection:"column",padding:0,...t},children:[A&&c.jsx(I.ListItem,{sx:{padding:wA,display:"flex",flexDirection:"column",alignItems:"flex-start",gap:"8px","&:hover":{cursor:"default",backgroundColor:"unset",color:"unset"},...i},children:A}),e.map(a=>c.jsx(I.ListItem,{onClick:a.onClick,sx:{borderRadius:be,padding:wA,transition:$e,"&:hover":{cursor:"pointer",backgroundColor:s.action.hover},...o},children:c.jsx(vn,{content:a.content,icon:a.icon,sx:r})},a.content))]})},G4=({total:A=0,page:e=js.page,take:t=js.take,openRowsPerPage:o=!0,onChange:r,sx:i={}})=>{const s=Math.ceil(A/t),a=[10,20,30,50],l=a.includes(Number(t))?Number(t):10,{palette:u}=I.useTheme(),d=g=>{const h=Number(g.target.value);r({page:1,take:h})},p=(g,h)=>{r({page:h,take:t})};return c.jsxs(se,{gap:.5,sx:{ml:"auto",...i},children:[c.jsx(I.Pagination,{count:s,page:e,showFirstButton:!0,showLastButton:!0,onChange:p,size:"medium",variant:"outlined",shape:"rounded",sx:{"& .MuiPagination-ul":{gap:.5},"& .MuiPaginationItem-root":{borderRadius:Re,m:0},"& .MuiPaginationItem-root.Mui-disabled":{opacity:.5,pointerEvents:"none"},"& .MuiPaginationItem-root.Mui-selected":{background:u.primary.main,color:"white"}}}),o&&c.jsx(se,{children:c.jsx(I.FormControl,{size:"small",children:c.jsx(Mn,{value:l,onChange:g=>d(g),options:a.map(g=>({value:g,label:`${g} / trang`})),sx:{"& .MuiOutlinedInput-root":{borderRadius:"0px !important"}}})})})]})},DO=({name:A,direction:e="row",label:t,disabled:o,iconLabel:r="event_list",defaultValue:i,value:s,onChange:a,children:l,required:u=!1,sx:d={}})=>{const p=g=>{a&&a({target:{name:A,value:g.target.value||void 0}})};return c.jsxs(I.FormControl,{disabled:o,sx:{gap:wA},onChange:p,children:[t&&c.jsx(I.InputLabel,{shrink:!0,required:u,sx:{transform:"translate(0px , -9px) scale(0.75)",zIndex:2,display:"flex"},children:c.jsxs(O3,{children:[c.jsx(vA,{icon:r,sx:{fontSize:Sa.FONT_SIZE_LABEL}}),t]})}),c.jsx(I.RadioGroup,{name:A,defaultValue:i,value:s,sx:{flexDirection:e,paddingTop:t?"calc(8.5px + 1.5px)":0,gap:Oe,...d},children:l})]})},TO=({name:A,label:e,...t})=>c.jsx(I.FormControlLabel,{name:A,label:e,sx:{alignItems:"center",mr:0},control:c.jsx(I.Radio,{...t,sx:{paddingTop:0,paddingBottom:0,paddingRight:wA,marginLeft:"2px","&:hover":{backgroundColor:"unset"},"& .MuiSvgIcon-root":{fontSize:"18px"}}})}),BO=({label:A,value:e,children:t,sx:o,textTransform:r="uppercase"})=>{const{palette:i}=I.useTheme();return c.jsxs(se,{sx:{gap:1,...o},children:[c.jsx(I.Typography,{variant:"subtitle2",sx:{...OA.textMd.semiBold,textTransform:r,color:i.primary.main},children:A||t}),e!==void 0&&c.jsx(I.Typography,{variant:"subtitle2",sx:{...OA.textMd.semiBold,textTransform:r,color:i.primary.main},children:e})]})},Y4=({name:A,value:e=!1,onChange:t})=>{const{palette:o}=I.useTheme(),r=()=>{t&&t({target:{name:A,value:!e}})};return c.jsx(_e.MotionConfig,{transition:{duration:.2,ease:"easeOut"},children:c.jsx(_e.motion.div,{className:"switch",initial:!1,animate:{backgroundColor:e?o.primary.main:o.text.disabled},onClick:r,style:{display:"flex",justifyContent:e?"flex-end":"flex-start",alignItems:"center",width:"30px",height:"14px",padding:"3px",borderRadius:"10px",boxSizing:"content-box",cursor:"pointer"},children:c.jsx(_e.motion.div,{layout:!0,className:"handle",style:{background:"#fdfdfd",aspectRatio:1,height:"100%",borderRadius:"50%"}})})})},OO=({name:A,content:e,value:t=!1,onChange:o,sx:r={}})=>c.jsxs(se,{sx:{gap:wA,...r},children:[c.jsx(I.Typography,{children:e}),c.jsx(Y4,{name:A,value:t,onChange:o})]});var mc=(A=>(A.DISABLED_GET_ROW_MENU="DISABLED_GET_ROW_MENU",A.HISTORY_GET_ROW_MENU="HISTORY_GET_ROW_MENU",A.INFO="INFO",A.COPY="COPY",A.DELETE="DELETE",A.UPDATE="UPDATE",A.SELECT="SELECT",A.COLLAPSE="COLLAPSE",A.DISABLED_ALL_ACTIONS="DISABLED_ALL_ACTIONS",A.DISABLED_ROW="DISABLED_ROW",A.DISABLED_CHECKBOX="DISABLED_CHECKBOX",A))(mc||{}),wr=(A=>(A.TOTAL="TOTAL",A.TOTAL_INCOME="TOTAL_INCOME",A))(wr||{});const Oo=`1px solid ${re.gray8}`,E0=Object.keys(mc).reduce((A,e)=>(A[e]=!1,A),{}),K4=A=>A?Array.isArray(A)?[...A]:[A]:[],Fo=(...A)=>A.flatMap(e=>K4(e)),X4=(A,e,t)=>Fo({width:`${A.width}px !important`,minWidth:`${A.width}px !important`,maxWidth:`${A.width}px !important`,padding:wA,borderRadius:"0 !important",color:t?e.divider:"none",...A.stickyCss?{position:"sticky",backgroundColor:e.background.default,...A.stickyCss}:{}},A.sx,A.cellSx),J4=(A,e,t,o,r)=>({cursor:A?"pointer":"default","&:hover .MuiTableCell-root":{backgroundColor:"inherit !important"},...o[t]?o[t]:{},...r===t?{background:`linear-gradient(270deg, ${e.primary.light+fn[90]}, ${e.action.hover}, ${e.background.paper})`,backgroundSize:"600% 600%",animation:"loading-gradient-row-table 1.5s ease infinite"}:{}});function kO({columns:A,row:e,indexRow:t,indexLoadingRow:o,rowSx:r={},getRowId:i,onClickRow:s,onDisabled:a,onClickSelectRow:l=!1,onSelectRowById:u,enableTree:d=!1,rowLevels:p={}}){const{palette:g}=I.useTheme(),h=i(e),m=a?a(e,t):{...E0},f=F.useCallback((q,x)=>{const y=x||"";return c.jsxs(At,{sx:{color:ar[950]},children:[q,c.jsx(vA,{icon:"content_copy",sx:{color:ar[950],fontSize:Jn.medium},onClick:w=>{w.stopPropagation(),y&&navigator.clipboard.writeText(y)}})]})},[]),C=!!(l&&u),b=!!(s||C);return c.jsx(I.Fade,{in:!0,timeout:t*120,children:c.jsx(I.TableRow,{hover:!0,tabIndex:-1,onClick:()=>{s==null||s(e,t),C&&(u==null||u(h))},sx:{...J4(b,g,t,r,o),...h===wr.TOTAL?{backgroundColor:re.green2,"& .MuiTableCell-root":{backgroundColor:re.green2},"& *":{fontWeight:"bold"}}:{},...h===wr.TOTAL_INCOME?{backgroundColor:re.gray7,"& .MuiTableCell-root":{backgroundColor:re.gray7},"& *":{fontWeight:"bold"}}:{}},children:A.map((q,x)=>{const y=d?p[h]??0:0,w=d?A.findIndex(T=>T.id!=="treeToggle"):-1,E=d&&x===w&&q.id!=="treeToggle";return c.jsx(I.TableCell,{align:q.align,sx:Fo(X4(q,g,m.DISABLED_ROW),{overflowWrap:"anywhere"},E?{pl:T=>`calc(${T.spacing(1)} + ${y*16}px)`}:void 0),onClick:q.id==="actions"||q.id==="selectCheckbox"?T=>{T.stopPropagation()}:void 0,children:(()=>{const T=e[q.id],P=no(q.render?q.render(e,t):T);if(!q.copyable)return P;const D=typeof q.copyable=="object"&&q.copyable.getValue?String(q.copyable.getValue(e,t)||""):String(T||"");return f(P,D)})()},q.id)})})})}const PO={visibleRows:[],rowLevels:{},hasChildrenById:{}},MO=({rows:A,enableTree:e,expandedRowIds:t,getRowId:o,getChildren:r})=>{if(!e)return{...PO,visibleRows:A};const i={},s={},a=[],l=(u,d)=>{u.forEach(p=>{const g=o(p),h=r(p);i[g]=d,s[g]=h.length>0,a.push(p),h.length>0&&t.has(g)&&l(h,d+1)})};return l(A,0),{visibleRows:a,rowLevels:i,hasChildrenById:s}},RO=({row:A,getRowId:e,rowLevels:t,hasChildrenById:o,expandedRowIds:r,onToggle:i,palette:s})=>{const a=e(A),l=t[a]??0,u=o[a],d=r.has(a),p=16,g=Math.max(l*p+14,14),h=l*p+7;return c.jsxs(I.Box,{sx:{display:"flex",alignItems:"stretch",cursor:u?"pointer":"default",minHeight:"100%"},onClick:m=>{u&&(m.stopPropagation(),i(a))},children:[c.jsx(I.Box,{sx:{position:"relative",width:g,flexShrink:0,alignSelf:"stretch",minHeight:"100%"},children:l>0&&c.jsxs(c.Fragment,{children:[c.jsx(I.Box,{sx:{position:"absolute",left:`${h}px`,top:"-1px",bottom:"50%",borderLeft:`1px solid ${s.divider}`}}),c.jsx(I.Box,{sx:{position:"absolute",left:`${h}px`,top:"50%",width:`${p/2}px`,borderBottom:`1px solid ${s.divider}`,transform:"translateY(-50%)"}})]})}),c.jsx(I.Box,{sx:{display:"flex",alignItems:"center",minHeight:"100%"},children:u?c.jsx(vA,{icon:d?"expand_more":"chevron_right"}):c.jsx(I.Box,{sx:{width:8,height:8,borderRadius:"50%",bgcolor:s.text.disabled}})})]})},NO=({children:A})=>c.jsx(I.Box,{sx:{overflowY:"auto",flex:1},children:c.jsx(I.TableContainer,{sx:{maxHeight:"100%",overflow:"auto"},children:A})}),f1=44,C2=(A,e)=>({id:A.id,label:A.label,width:A.width,align:A.align,alignHead:A.alignHead,sx:Fo(A.sx,A.headSx),stickyCss:A.stickyCss,rowSpan:e});function FO({columns:A,headerGroups:e}){const{palette:t}=I.useTheme(),o=F.useMemo(()=>{var u;if(!(e!=null&&e.length))return[A.map(d=>C2(d))];const i=new Map;e.forEach(d=>{d.columnIds.forEach(p=>{i.set(p,d)})});const s=[],a=[];let l=0;for(;l<A.length;){const d=A[l],p=i.get(d.id);if(!p){s.push(C2(d,2)),l+=1;continue}let g=1;for(;l+g<A.length&&((u=i.get(A[l+g].id))==null?void 0:u.id)===p.id;)g+=1;s.push({id:`${p.id}-${l}`,label:p.label,alignHead:p.align??"center",sx:p.sx,colSpan:g});for(let h=0;h<g;h+=1)a.push(C2(A[l+h]));l+=g}return a.length?[s,a]:[A.map(d=>C2(d))]},[A,e]),r=o.length>1;return c.jsx(I.TableHead,{children:o.map((i,s)=>c.jsx(I.TableRow,{children:i.map(a=>{var l;return c.jsx(I.TableCell,{align:a.align,colSpan:a.colSpan,rowSpan:a.rowSpan,sx:Fo({...a.width!=null?{width:`${a.width}px !important`,minWidth:`${a.width}px !important`,maxWidth:`${a.width}px !important`}:{},height:r?f1:void 0,fontWeight:550,padding:wA,borderRadius:"0 !important",backgroundColor:"#F9FAFB",verticalAlign:r&&a.rowSpan?"middle":"top",textAlign:a.alignHead?a.alignHead:"center",borderTop:s===0?Oo:"none",top:r?s*f1:0},a.stickyCss?{...a.stickyCss,position:"sticky",backgroundColor:t.background.paper,zIndex:4,borderRight:((l=a.stickyCss)==null?void 0:l.left)!=null?Oo:""}:{},a.sx),children:c.jsx(I.Typography,{variant:"subtitle1",children:a.label})},a.id)})},s))})}const jO=({columns:A,headerGroups:e,rows:t=[],loading:o=!1,stickyHeader:r=!0,tableSx:i,tableRef:s,renderRow:a,renderLoading:l,renderEmpty:u})=>c.jsx(NO,{children:c.jsxs(I.Table,{ref:s,stickyHeader:r,sx:[{height:o||t.length===0?"100%":"none",borderCollapse:"separate !important","& .MuiTableCell-root":{borderRight:Oo,borderBottom:Oo,"&:first-of-type":{borderLeft:Oo}}},...Array.isArray(i)?i:[i]],children:[c.jsx(FO,{columns:A,headerGroups:e}),c.jsx(I.TableBody,{children:o?c.jsx(I.TableRow,{children:c.jsx(I.TableCell,{colSpan:A.length,children:l()})}):t.length?t.map((d,p)=>c.jsx(F.Fragment,{children:a(d,p)},p)):c.jsx(I.TableRow,{children:c.jsx(I.TableCell,{colSpan:A.length,children:u()})})})]})}),LO=[];function hc({loading:A=!1,rows:e,columns:t,headerGroups:o,indexLoadingRow:r,isStickyActions:i=!1,rowSx:s={},rowKey:a,onClickSelectRow:l=!1,enableTree:u=!1,getChildren:d,onClickRow:p,onDisabled:g,selectedRows:h,onSelectRows:m,onSelectRow:f,onDeleteRow:C,onInfoRow:b,onCopyRow:q,onHistoryRow:x,onUpdateRow:y,getActionIcon:w,getRowMenu:E,extraActionCount:T=0,stickyHeader:P=!0,tableSx:D,tableRef:k,renderRow:M}){const v=F.useMemo(()=>e??LO,[e]),[B,O]=F.useState({}),[R,N]=F.useState(new Set),{palette:L}=I.useTheme(),U=[f,C,b,q,x,y,E].filter(Boolean).length+T,H=U>0?U*19+Math.max(U-1,0)*16:0,j=F.useCallback(oA=>a?a(oA):String(oA.id),[a]),J=F.useCallback(oA=>u?d?d(oA):oA&&oA.children||[]:[],[u,d]);F.useEffect(()=>{if(!u){N(new Set);return}const oA=new Set,AA=uA=>{uA.forEach(K=>{const iA=j(K),Z=J(K);Z&&Z.length>0&&(oA.add(iA),AA(Z))})};AA(v),N(oA)},[u,j,J,v]);const{visibleRows:eA,rowLevels:$,hasChildrenById:X}=F.useMemo(()=>MO({rows:v,enableTree:u,expandedRowIds:R,getRowId:j,getChildren:J}),[v,u,R,j,J]),_=F.useMemo(()=>eA.map(j),[eA,j]),tA=h?_.every(oA=>h.includes(oA)):!1,cA=h?h.length>0&&!tA:!1,sA=F.useCallback(()=>{tA?m==null||m([]):m==null||m(_)},[tA,m,_]),V=F.useCallback(oA=>{h&&(h.includes(oA)?m==null||m(h.filter(AA=>AA!==oA)):m==null||m([...h,oA]))},[h,m]),Y=F.useCallback(oA=>{N(AA=>{const uA=new Set(AA);return uA.has(oA)?uA.delete(oA):uA.add(oA),uA})},[]),W=F.useCallback((oA,AA)=>{const uA=j(oA);if(uA===wr.TOTAL||uA===wr.TOTAL_INCOME)return null;const K=g?g(oA,AA):{...E0},iA=K.DISABLED_ROW||K.DISABLED_ALL_ACTIONS,Z=String(a?a(oA):oA.id||AA),aA=()=>E?E(oA,AA).map(lA=>({...lA,onClick:()=>{lA.onClick(),O(BA=>({...BA,[Z]:!1}))}})):[];return c.jsxs(c.Fragment,{children:[f&&c.jsx(vA,{icon:"remove_red_eye",onClick:lA=>{lA.stopPropagation(),f(oA,AA)},disabled:iA||K.SELECT}),C&&c.jsx(vA,{icon:"delete",onClick:lA=>{lA.stopPropagation(),C(oA,AA)},color:"error",disabled:iA||K.DELETE}),b&&c.jsx(vA,{icon:"view_cozy",onClick:lA=>{lA.stopPropagation(),b(oA,AA)},disabled:iA||K.INFO}),q&&c.jsx(vA,{icon:w&&w(oA,AA,"COPY")||"content_copy",onClick:lA=>{lA.stopPropagation(),q(oA,AA),window.scrollTo({top:0,behavior:"smooth"})},disabled:iA||K.COPY}),x&&c.jsx(vA,{icon:"history",onClick:lA=>{lA.stopPropagation(),x(oA,AA)},disabled:iA||K.HISTORY_GET_ROW_MENU}),y&&c.jsx(vA,{icon:w&&w(oA,AA,"UPDATE")||"settings",onClick:lA=>{lA.stopPropagation(),y(oA,AA),window.scrollTo({top:0,behavior:"smooth"})},disabled:iA||K.UPDATE}),E&&(K.DISABLED_GET_ROW_MENU?c.jsx(vA,{icon:"open_in_browser",disabled:iA||K.DISABLED_GET_ROW_MENU,onClick:lA=>lA.stopPropagation()}):c.jsx(gn,{style:{cursor:"pointer",display:"flex",alignItems:"center"},placement:"bottom-end",open:!!B[Z],onOpen:()=>O(lA=>({...lA,[Z]:!0})),onClose:()=>O(lA=>({...lA,[Z]:!1})),content:c.jsx(W4,{list:aA()}),children:c.jsx(vA,{icon:"open_in_browser",onClick:lA=>lA.stopPropagation()})}))]})},[w,j,E,q,C,g,x,b,f,y,a,B]),rA=F.useMemo(()=>{const oA=[...t];if(u&&oA.unshift({id:"treeToggle",label:"",width:32,alignHead:"center",render:uA=>c.jsx(RO,{row:uA,getRowId:j,rowLevels:$,hasChildrenById:X,expandedRowIds:R,onToggle:Y,palette:L})}),m&&oA.unshift({id:"selectCheckbox",label:c.jsx(I.Box,{onClick:uA=>{uA.stopPropagation(),sA()},sx:{display:"flex",justifyContent:"center",cursor:"pointer"},children:c.jsx(pa,{checked:tA,indeterminate:cA})}),width:35,alignHead:"center",stickyCss:{left:0,zIndex:1.5},render:(uA,K)=>{const iA=g?g(uA,K):{...E0},Z=iA.DISABLED_ROW||iA.DISABLED_CHECKBOX;return c.jsx(I.Box,{children:c.jsx(pa,{checked:h==null?void 0:h.includes(j(uA)),disabled:Z,onClick:aA=>{aA.stopPropagation(),!Z&&V(j(uA))}})})}}),U>0&&oA.push({id:"actions",label:"Actions",width:H>70?H:70,align:"center",alignHead:"center",stickyCss:i?{right:0,borderLeft:Oo,zIndex:1.5}:void 0,render:(uA,K)=>c.jsx(jo,{gap:1,onClick:iA=>iA.stopPropagation(),children:W(uA,K)})}),!(o!=null&&o.length))return oA;const AA=new Map;return o.forEach(uA=>{uA.columnIds.forEach(K=>{AA.set(K,uA)})}),oA.map(uA=>{const K=AA.get(uA.id);return!K||!K.childrenHeadSx&&!K.childrenCellSx?uA:{...uA,...K.childrenHeadSx?{headSx:Fo(K.childrenHeadSx,uA.headSx)}:{},...K.childrenCellSx?{cellSx:Fo(K.childrenCellSx,uA.cellSx)}:{}}})},[t,o,u,m,U,j,$,X,R,Y,L,sA,tA,cA,g,h,V,H,i,W]),nA=F.useCallback((oA,AA,uA)=>c.jsx(kO,{columns:uA??rA,row:oA,indexRow:AA,indexLoadingRow:r,rowSx:s,getRowId:j,onClickRow:p,onDisabled:g,onClickSelectRow:l,onSelectRowById:V,enableTree:u,rowLevels:$}),[rA,u,j,V,r,p,l,g,$,s]);return c.jsx(jO,{columns:rA,headerGroups:o,rows:eA,loading:A,indexLoadingRow:r,stickyHeader:P,tableRef:k,tableSx:D,renderLoading:()=>c.jsx(ct,{}),renderEmpty:()=>c.jsx(Fn,{}),renderRow:(oA,AA)=>M?M({row:oA,index:AA,columns:rA,renderDefaultRow:uA=>nA(oA,AA,uA),renderActionsContent:W}):nA(oA,AA)})}const ga="collapseToggle",Z4=30,QO=20,ma=A=>A.some(e=>e.id===ga)?A:[{id:ga,label:"",width:Z4,align:"center",alignHead:"center",render:()=>null},...A],UO=(A,e,t)=>{if(e.onOpenCollapse)return t;if(e.property)return A[e.property]||[]},HO=(A,e)=>{const t=e.property?A==null?void 0:A[e.property]:A==null?void 0:A.children;return Array.isArray(t)?t:[]},zO=(A,e)=>HO(A,e).length>0,VO=(A,e)=>A?Math.max(A-parseInt(Oe,10)*2-e,Z4):"auto";function _4({columns:A,row:e,collapse:t,collapseTableWidth:o,collapseLevel:r=0,renderDefaultRow:i,onDisabled:s}){const{palette:a}=I.useTheme(),[l,u]=F.useState(!1),[d,p]=F.useState(),[g,h]=F.useState(!1),{iconTitle:m,title:f,children:C,indentSize:b,...q}=t,{columns:x,...y}=q,w=(b??QO)*r,E=F.useCallback(async(N,L)=>{const G=!l;if(u(G),!(!G||!t.onOpenCollapse||d!==void 0)){h(!0);try{const U=await t.onOpenCollapse(N,L),H=t.property?U==null?void 0:U[t.property]:U;p(H)}catch(U){console.error(U)}finally{h(!1)}}},[t,l,d]),T=F.useCallback((N,L)=>{const G=s?s(N,L):{...E0},U=G.DISABLED_ROW||G.DISABLED_ALL_ACTIONS;return c.jsx(jo,{onClick:H=>H.stopPropagation(),children:c.jsx(vA,{onClick:H=>{H.stopPropagation(),E(N,L)},icon:l?"keyboard_arrow_down":"keyboard_arrow_right",disabled:U||G.COLLAPSE})})},[s,l,E]),P=F.useMemo(()=>ma(A).map(N=>N.id!==ga?N:{...N,render:T}),[A,T]),D=UO(e,t,d),k=C==null?void 0:C[0],M=F.useMemo(()=>{if(!(k||!(D!=null&&D.some(N=>zO(N,t)))))return t},[t,D,k]),v=k??M,B=v?ma(x):x,O=VO(o,w);F.useEffect(()=>{u(!1),p(void 0),h(!1)},[e]);const R=F.useCallback(({row:N,index:L,columns:G,renderDefaultRow:U})=>v?c.jsx(_4,{...y,columns:G,row:N,indexRow:L,collapse:v,collapseTableWidth:o,collapseLevel:r+1,renderDefaultRow:U}):null,[r,o,y,v]);return c.jsxs(F.Fragment,{children:[i(P),c.jsx(I.TableRow,{children:c.jsx(I.TableCell,{style:{paddingBottom:0,paddingTop:0},colSpan:P.length,children:c.jsx(I.Stack,{sx:{display:"block",overflowX:"visible",maxWidth:"none",minWidth:O,width:"max-content",marginLeft:`${w}px`},children:c.jsx(I.Collapse,{in:l,timeout:"auto",unmountOnExit:!0,children:c.jsxs(I.Stack,{sx:{padding:Oe,borderRadius:be,backgroundColor:a.background.default,minWidth:O,width:"max-content"},children:[f&&c.jsx(vn,{icon:m||"filter_list",content:f,size:"medium"}),c.jsx(hc,{...y,columns:B,loading:g,rows:D,stickyHeader:!1,renderRow:v?R:void 0})]})})})})})]})}function WO({loading:A=!1,rows:e,columns:t,collapse:o,...r}){const i=F.useMemo(()=>e||[],[e]),s=F.useMemo(()=>ma(t),[t]),a=F.useRef(null),[l,u]=F.useState(0);return F.useEffect(()=>{a.current&&u(a.current.clientWidth)},[]),c.jsx(hc,{...r,columns:s,rows:i,loading:A,stickyHeader:!1,tableRef:a,tableSx:{height:A||i.length===0?"100%":"none"},renderRow:({row:d,index:p,columns:g,renderDefaultRow:h})=>c.jsx(_4,{...r,columns:g,row:d,indexRow:p,collapse:o,collapseTableWidth:l,renderDefaultRow:h})})}const GO={loading:{control:"boolean",table:{type:{summary:"boolean"},defaultValue:{summary:"false"}}},columns:{control:!1,table:{type:{summary:"Column<R>[]"}}},headerGroups:{control:!1,table:{type:{summary:"TableHeaderGroup[]"}}},rows:{control:!1,table:{type:{summary:"R[]"}}},indexLoadingRow:{control:"number",table:{type:{summary:"number | undefined"}}},isStickyActions:{control:"boolean",table:{type:{summary:"boolean"},defaultValue:{summary:"false"}}},onClickSelectRow:{control:"boolean",table:{type:{summary:"boolean"},defaultValue:{summary:"false"}}},selectedRows:{control:!1},rowSx:{control:!1},rowKey:{control:!1},requiredPermissions:{control:!1},onClickRow:{action:"rowClicked"},onSelectRows:{action:"rowsSelected"},onSelectRow:{action:"selectAction"},onDeleteRow:{action:"deleteAction"},onInfoRow:{action:"infoAction"},onCopyRow:{action:"copyAction"},onHistoryRow:{action:"historyAction"},onUpdateRow:{action:"updateAction"},getActionIcon:{control:!1},getRowMenu:{control:!1},onDisabled:{control:!1}};function YO(A){return c.jsx(hc,{...A})}const KO=({name:A="Hệ thống",department:e="Hệ thống",icon:t="person",sx:o})=>c.jsxs(I.Stack,{sx:o,children:[c.jsxs(I.Stack,{direction:"row",alignItems:"center",gap:1,children:[c.jsx(vA,{icon:t,sx:{fontSize:"16px",color:"#6B7280"}}),c.jsx(I.Typography,{variant:"body2",sx:{fontWeight:500},children:A})]}),e&&c.jsxs(I.Typography,{variant:"caption",sx:{color:"#6B7280",ml:2.5},children:["(",e,")"]})]}),XO=({name:A,loading:e,chart:t,sx:o})=>c.jsx(I.Fade,{in:!0,timeout:O0,children:c.jsxs(B3,{children:[c.jsx(I.Typography,{variant:"subtitle1",sx:{lineHeight:1,textAlign:"center"},children:A}),c.jsx(I.Stack,{sx:{height:`calc(100% - 14px - ${wA})`,...o},children:e?c.jsx(ct,{}):t})]})}),JO=({iconLabel:A,label:e,nodeLabel:t,labelSize:o="medium",flex:r=1,height:i="fit-content",width:s,direction:a="column",directionNodeLabel:l="column",sx:u={},loading:d=!1,children:p,sxChildren:g={}})=>c.jsx(I.Fade,{in:!0,timeout:O0,children:c.jsxs(I.Stack,{sx:{...s?{width:s}:{flex:r},overflow:"hidden",height:i,...u},children:[(e||t)&&c.jsxs(bi,{sx:{position:"sticky",alignItems:"stretch",top:0,zIndex:1,overflow:"hidden"},children:[e&&c.jsx(vn,{icon:A,content:e,size:o}),t&&c.jsx(I.Stack,{sx:{flexDirection:l},children:t})]}),c.jsx(I.Stack,{sx:{flex:1,flexDirection:a,paddingTop:e||t?0:Oe,...g},children:d?c.jsx(ct,{}):p})]})}),ZO=({iconLabel:A,label:e,nodeAction:t,nodeLabel:o,labelSize:r="large",flex:i=1,height:s="fit-content",width:a,direction:l="column",directionNodeLabel:u="column",sx:d={},loading:p=!1,children:g,sxChildren:h={overflowY:"auto"},sxLabel:m={},divider:f,labelId:C,isTopLabel:b=!1})=>{const q=!!(e||t),x={large:OA.textSm.semiBold,medium:OA.textXs.semiBold,small:OA.textSmall.semiBold}[r];return c.jsx(I.Fade,{in:!0,timeout:O0,children:c.jsx(I.Stack,{sx:{...a?{width:a}:{flex:i},overflowY:"auto",overflowX:"hidden",height:s,boxShadow:1,borderRadius:be,backgroundColor:Ue[50],...d},children:c.jsxs(I.Stack,{sx:{flex:1,minHeight:0,overflow:"hidden",gap:0},children:[q&&c.jsxs(bi,{sx:{position:"sticky",top:0,zIndex:1,gap:wA,minHeight:wt.large,padding:Kr,backgroundColor:Ue[50],...m},children:[e&&c.jsx(vn,{id:C,icon:A,content:e,size:r,isNowrap:!0,sx:{minWidth:0},sxText:{...x}}),t&&c.jsx(u0,{sx:{flexDirection:u,flexShrink:0,marginLeft:"auto"},children:t})]}),o&&c.jsx(S3,{sx:{minHeight:wt.large,overflowX:"auto",padding:Kr,borderTop:q?`1px solid ${_A[300]}`:"none"},children:o}),c.jsx(I.Stack,{sx:{flex:1,minHeight:0,flexDirection:l,padding:Kr,marginTop:b?Oe:0,borderTop:q||o?`1px solid ${_A[300]}`:"none",backgroundColor:Ue[50],...h},divider:f,children:p?c.jsx(jo,{height:100,width:"100%",children:c.jsx(ct,{})}):g})]})})})},_O=({isWrap:A=!1,children:e})=>A?c.jsx(jo,{children:e}):c.jsx(c.Fragment,{children:e}),Cc=({app:A,iconSize:e,iconRadius:t,titleColor:o,showNameApps:r=!0,showIconApps:i=!0,direction:s="column"})=>c.jsxs(D3,{sx:{flexDirection:s,gap:wA},children:[i&&c.jsx(nn,{sx:{width:e,height:e,borderRadius:t},url:A.icon,sizeType:"SQUARE"}),r&&c.jsx(I.Typography,{sx:{color:o,textAlign:"center",...OA.textMd.semiBold},children:A.content})]}),bc=({apps:A,columns:e=5,rows:t=3,iconSize:o=120,iconRadius:r=7,titleColor:i,showPagination:s=!0,onClickApp:a,isShowAppHidden:l=!1})=>{const u=zn(),d=Math.max(1,e*Math.max(1,t)),p=Math.max(1,Math.ceil(A.length/d)),[g,h]=F.useState(0);F.useEffect(()=>{h(x=>x>=p?p-1:x)},[p,e,t,A.length]);const m=g*d,f=m+d,C=p>1?A.slice(m,f):A,b=l?Math.max(0,d-C.length):0,q=l?o+36.5:0;return c.jsxs(io,{sx:{width:"100%",gap:3},children:[c.jsxs(se,{sx:{width:"100%",gap:3},children:[c.jsx(c.Fragment,{}),c.jsxs(I.Stack,{sx:{display:"grid",gridTemplateColumns:`repeat(${e}, 1fr)`,width:"100%"},children:[C.map((x,y)=>c.jsx(io,{component:Ir,preset:"staggerItem",index:y,hover:!0,sx:{cursor:"pointer",flex:1},onClick:()=>a(x),children:c.jsx(Cc,{app:x,titleColor:i??u.palette.common.white,iconSize:o,iconRadius:r})},y)),b>0&&Array.from({length:b}).map((x,y)=>c.jsx(I.Box,{sx:{visibility:"hidden",width:1,minHeight:q}},`placeholder-${y}`))]})]}),s&&p>1&&c.jsx(se,{sx:{px:Cn,py:Je,borderRadius:tn,backgroundColor:"rgba(255,255,255,0.15)",width:"fit-content"},children:Array.from({length:p}).map((x,y)=>c.jsx(I.Box,{onClick:()=>h(y),sx:{height:10,borderRadius:tn,cursor:"pointer",transition:"width 0.3s ease",width:y===g?"40px":"10px",backgroundColor:y===g?u.palette.common.white:"rgba(255,255,255,0.35)"}},y))})]})},$O=({children:A})=>c.jsx(I.Stack,{sx:{backgroundColor:"background.default",minHeight:"100vh",width:"100%",overflowY:"auto"},children:c.jsx(I.Stack,{sx:{flex:1,alignItems:"center",py:Oe,justifyContent:"center"},children:A})});var $4=(A=>(A.MAIN="logoMain",A.SUB1="logoSub1",A.SUB2="logoSub2",A.SUB3="logoSub3",A.SUB4="logoSub4",A.SUB5="logoSub5",A))($4||{});const Ak=({env:A,logoName:e="logoMain",height:t=H1,sx:o={},isLongSubDomain:r=!1})=>c.jsx(uo,{href:r?s0[A].replace("dev.","develop.").replace("sta.","staging."):s0[A],children:c.jsx(nn,{url:JA[e],sx:{height:t,borderRadius:"unset",width:"auto",...o}})}),ek=({content:A,contentHref:e,href:t,type:o="info"})=>{const{palette:r}=I.useTheme(),i={info:{icon:"error",title:"Info",color:r.success.dark},recommend:{icon:"gpp_maybe",title:"Recommend",color:r.info.dark},warning:{icon:"report",title:"Warning",color:r.warning.dark},error:{icon:"emergency_home",title:"Error",color:r.error.dark}};return c.jsxs(I.Stack,{sx:{gap:1,borderRadius:be,borderColor:i[o].color,borderStyle:"solid",borderWidth:"1px 1px 1px 3px",padding:1.5},children:[c.jsxs(se,{sx:{gap:Je},children:[c.jsx(vA,{icon:i[o].icon,sx:{color:i[o].color}}),c.jsx(I.Typography,{sx:{color:i[o].color},variant:"body2",children:i[o].title})]}),c.jsxs(I.Typography,{sx:{color:i[o].color},children:[A,t&&e&&c.jsxs(F.Fragment,{children:[" ",c.jsx(uo,{href:t,children:e})]})]})]})};var lo=(A=>(A.LOADING="loading",A.AUTHENTICATED="authenticated",A.UNAUTHENTICATED="unauthenticated",A))(lo||{}),en=(A=>(A.ALL="all",A.UNREAD="unread",A.READ="read",A))(en||{});const A5=A=>{if(!(A<=0))return A<=99?A:"99+"},yc=A=>!A||/^https?:\/\//i.test(A)||A.startsWith("//")?!1:A.startsWith("/"),vc=A=>{const e=Number(A);return e in me?e:me.INFO},i0=A=>String(A??"").trim(),e5=A=>i0(A.id??("Id"in A?A.Id:void 0)).toLowerCase(),t5=A=>{var r;const e=i0(A.title).toLowerCase(),t=i0(A.body).toLowerCase(),o=i0(A.createdAt??("data"in A?(r=A.data)==null?void 0:r.createdAt:void 0)).toLowerCase();return[e,t,o].join("|")},sr=A=>{const e=e5(A),t=t5(A),o=[];return e&&o.push(`id:${e}`),t!=="||"&&o.push(`fingerprint:${t}`),o},xc=A=>{var e;return i0(A.module??("data"in A?(e=A.data)==null?void 0:e.module:void 0)).toUpperCase()},n5=A=>{var t;const e=xc(A);return(t=ko[e])==null?void 0:t.icon},o5=A=>{var r,i,s,a,l;const e=A.title??"",t=A.body??"",o=A.createdAt??((r=A.data)==null?void 0:r.createdAt)??new Date().toISOString();return{id:A.id??A.Id??`${e}-${o}`,eventType:A.eventType??((i=A.data)==null?void 0:i.actionName)??"Realtime",priority:vc(A.priority??((s=A.data)==null?void 0:s.priority)),title:e,body:t,actionUrl:A.actionUrl??((a=A.data)==null?void 0:a.actionUrl),module:xc(A),status:hn.UNREAD,acknowledgementRequired:A.acknowledgementRequired??((l=A.data)==null?void 0:l.acknowledgementRequired)??!1,createdAt:o}},qc=A=>{const t=new Date(A).getTime();if(!Number.isFinite(t))return"vua xong";const o=Math.round((t-Date.now())/1e3),r=Math.abs(o),i=new Intl.RelativeTimeFormat("vi",{numeric:"auto"});if(r<60)return i.format(o,"second");const s=Math.round(o/60);if(Math.abs(s)<60)return i.format(s,"minute");const a=Math.round(s/60);if(Math.abs(a)<24)return i.format(a,"hour");const l=Math.round(a/24);if(Math.abs(l)<30)return i.format(l,"day");const u=Math.round(l/30);return Math.abs(u)<12?i.format(u,"month"):i.format(Math.round(u/12),"year")},tk="hub/notification-realtime",nk="NotificationReceived",ok="notification-be-list",r5="notification-be-unread-count",rk="notification-be-realtime",ik={axiosNotification:{},authStatus:lo.UNAUTHENTICATED,hasNewNotification:!1,unreadCount:0,markNotificationsSeen:()=>{},refreshNotifications:async()=>{}},i5=F.createContext(ik),sk={[me.CRITICAL]:mt.ERROR,[me.HIGH]:mt.WARNING,[me.NORMAL]:mt.INFO,[me.INFO]:mt.INFO},ak=A=>A.replace(/\/+$/,""),lk=A=>{const e=A.title??"",t=A.body;return t?`${e} - ${t}`:e},ck=(A,e)=>Array.isArray(A)&&A[0]===ok&&(!e||A[1]===e),s5=(A,e)=>Array.isArray(A)&&A[0]===r5&&(!e||A[1]===e),uk=(A,e)=>ck(A,e)||s5(A,e),dk=A=>A?[rk,A]:null;let Ps,g1="",P2="";const pk=(A,e)=>((!Ps||g1!==A)&&(Ps=new Rs.HubConnectionBuilder().withUrl(A,{accessTokenFactory:e,withCredentials:!1}).withAutomaticReconnect([0,2e3,5e3,1e4]).build(),g1=A,P2=""),Ps),fk=({axiosNotification:A,authStatus:e,userName:t,hubBaseUrl:o,hubPath:r=tk,realtimeEventName:i=nk,accessTokenFactory:s,showSnackbar:a,children:l})=>{const{mutate:u}=nr.useSWRConfig(),[d,p]=F.useState(!1),g=F.useRef(new Set),h=F.useRef(()=>{}),m=e===lo.AUTHENTICATED&&t?[r5,t]:null,{data:f=0}=nr(m,async()=>(await Ca(A)).count??0,{revalidateOnFocus:!1,shouldRetryOnError:!1}),C=F.useCallback(async()=>{await u(w=>uk(w,t),void 0,{revalidate:!0})},[u,t]),b=F.useCallback(()=>{p(!1)},[]),q=F.useCallback(async w=>{const E=o5(w),T=dk(t);T&&await u(T,(P=[])=>{const D=sr(E);return P.some(M=>{const v=sr(M);return D.some(B=>v.includes(B))})?P:[E,...P].slice(0,50)},{revalidate:!1}),await u(P=>s5(P,t),P=>(P??0)+1,{revalidate:!1})},[u,t]),x=F.useCallback(async w=>{const E=sr(w);E.some(T=>g.current.has(T))||(E.forEach(T=>g.current.add(T)),p(!0),a==null||a({type:sk[vc(w.priority)],message:lk(w)}),await q(w),await C(),setTimeout(()=>{E.forEach(T=>g.current.delete(T))},1e4))},[q,C,a]);F.useEffect(()=>{h.current=x},[x]),F.useEffect(()=>{if(e!==lo.AUTHENTICATED||!o||!t)return;const w=`${ak(o)}/${r.replace(/^\/+/,"")}`,E=pk(w,s),T=D=>{h.current(D)};return E.on(i,T),(async()=>{E.state===Rs.HubConnectionState.Connected&&P2&&P2!==t&&await E.stop(),E.state===Rs.HubConnectionState.Disconnected&&(P2=t,await E.start())})().catch(D=>{console.error("[NotificationReceived][global] connect error",D)}),()=>{E.off(i,T)}},[s,e,o,r,i,t]);const y=F.useMemo(()=>({axiosNotification:A,authStatus:e,userName:t,hasNewNotification:d,unreadCount:f,markNotificationsSeen:b,refreshNotifications:C,showSnackbar:a}),[e,A,d,b,C,a,f,t]);return c.jsx(i5.Provider,{value:y,children:l})},t2=()=>F.useContext(i5),a5=({notification:A,fallbackIcon:e,color:t})=>{const o=n5(A),r=A.priority??me.INFO;return c.jsx(u0,{sx:{height:36,width:36},children:o?c.jsx(nn,{alt:A.module||A.eventType||A.title,sizeType:"FULL_WIDTH",url:o,size:It.LARGE}):c.jsx(vA,{icon:e,sx:{color:t,fontSize:r===me.INFO?19:20}})})},wc="notification-be-list",Sc="notification-be-unread-count",l5="notification-be-realtime",m1=A=>{if(A===en.READ)return j2.READ;if(A===en.UNREAD)return j2.UNREAD},gk=(A,e)=>e===en.READ?A.status===hn.READ:e===en.UNREAD?A.status===hn.UNREAD:!0,mk=(A,e,t)=>{const o=e.filter(i=>gk(i,t)),r=new Set(A.flatMap(sr));return[...o.filter(i=>sr(i).every(s=>!r.has(s))),...A]},hk=(A,e)=>A.length!==e.length?!1:A.every((t,o)=>{const r=e[o];return t.id===r.id&&t.status===r.status&&t.title===r.title&&t.body===r.body&&t.createdAt===r.createdAt}),Ec=(A,e)=>Array.isArray(A)&&A[0]===wc&&(!e||A[1]===e),Ic=(A,e)=>Array.isArray(A)&&A[0]===Sc&&(!e||A[1]===e),Ck=(A,e)=>Ec(A,e)||Ic(A,e),c5=A=>A?[l5,A]:null,Dc=(A={},e=en.ALL)=>{const{axiosNotification:t,authStatus:o,userName:r}=t2(),{mutate:i}=nr.useSWRConfig(),[s,a]=F.useState({page:1,pageSize:10,status:m1(e),...A}),[l,u]=F.useState([]),[d,p]=F.useState(!1),g=F.useRef(!1),h=F.useMemo(()=>s,[s]),m=o===lo.AUTHENTICATED&&r?[wc,r,h]:null,f=o===lo.AUTHENTICATED&&r?c5(r):null;F.useEffect(()=>{a(D=>{const k=m1(e);return D.status===k&&D.page===1?D:{...D,status:k,page:1}}),g.current=!1,u(D=>D.length===0?D:[])},[e]);const{data:C,error:b,isLoading:q}=nr(m,async([,,D])=>{const k=await w1(t,D);return{notifications:k.items??[],totalCount:k.total??0}},{revalidateOnFocus:!1,revalidateIfStale:!0,shouldRetryOnError:!1}),{data:x=[]}=nr(f,null,{fallbackData:[],revalidateOnFocus:!1}),y=Math.max((C==null?void 0:C.totalCount)??0,l.length),w=F.useMemo(()=>l.filter(D=>D.status===hn.UNREAD).length,[l]);F.useEffect(()=>{if(h.page!==1){if(!C)return;if(g.current){u(k=>[...k,...C.notifications]),g.current=!1;return}u(C.notifications);return}if(!C&&x.length===0)return;const D=mk((C==null?void 0:C.notifications)??[],x,e);u(k=>hk(k,D)?k:D)},[C,h.page,e,x]);const E=F.useCallback(()=>{q||l.length>=y||(g.current=!0,a(D=>({...D,page:(D.page??1)+1})))},[q,l.length,y]),T=F.useCallback(D=>{g.current=!1,a(k=>({...k,page:D.page,pageSize:D.take}))},[]),P=F.useCallback(async()=>{p(!0),a(D=>({...D,page:1})),await i(D=>Ec(D,r),void 0,{revalidate:!0}),await i(D=>Ic(D,r),void 0,{revalidate:!0}),p(!1)},[i,r]);return{notifications:l,totalCount:y,unreadCount:w,isLoading:q,isRefreshing:d,error:(C==null?void 0:C.error)??(b instanceof Error?b.message:void 0),handlePaginationChange:T,loadMore:E,page:s.page??1,pageSize:s.pageSize??10,refresh:P}},bk=()=>{const{axiosNotification:A,authStatus:e,userName:t}=t2(),o=e===lo.AUTHENTICATED&&t?[Sc,t]:null,{data:r,isLoading:i,mutate:s}=nr(o,async()=>(await Ca(A)).count??0,{revalidateOnFocus:!1,shouldRetryOnError:!1});return{unreadCount:r??0,isLoadingUnreadCount:i,refreshUnreadCount:s}},yk={[me.CRITICAL]:"error",[me.HIGH]:"warning",[me.NORMAL]:"notifications",[me.INFO]:"info"},h1={[me.CRITICAL]:Ft[500],[me.HIGH]:qo[500],[me.NORMAL]:_A[500],[me.INFO]:_A[500]},vk={[me.CRITICAL]:"Khẩn cấp",[me.HIGH]:"Ưu tiên cao",[me.NORMAL]:"",[me.INFO]:""},xk=[{id:en.ALL,name:"Tất cả"},{id:en.UNREAD,name:"Chưa đọc"},{id:en.READ,name:"Đã đọc"}],qk=({notification:A,onRead:e,onNavigate:t})=>{const o=F.useMemo(()=>qc(A.createdAt),[A.createdAt]),r=A.status===hn.UNREAD,i=A.priority??me.INFO,s=yc(A.actionUrl),a=vk[i],l=async()=>{await e(),s&&A.actionUrl&&(t==null||t(A.actionUrl))};return c.jsx(I.Stack,{onClick:l,sx:{bgcolor:Ue[50],border:`1px solid ${_A[200]}`,borderRadius:be,boxShadow:r?`inset 3px 0 0 ${xe[500]}`:"none",cursor:"pointer",p:wA,transition:$e,"&:hover":{bgcolor:_A[50],borderColor:_A[300]}},children:c.jsxs(se,{sx:{alignItems:"flex-start",gap:wA,minWidth:0},children:[c.jsx(a5,{notification:A,fallbackIcon:yk[i],color:h1[i]}),c.jsxs(I.Stack,{sx:{flex:1,gap:0,minWidth:0},children:[c.jsxs(At,{sx:{alignItems:"flex-start",gap:wA},children:[c.jsx(ze,{content:no(A.title),sx:{...OA.textSm.semiBold,color:r?_A[900]:_A[700]}}),c.jsx(ze,{content:o,sx:{...OA.textXs.medium,color:_A[500],flexShrink:0}})]}),c.jsxs(At,{sx:{alignItems:"flex-start",gap:wA},children:[c.jsx(I.Typography,{sx:{...OA.textXs.regular,color:_A[700],width:"85%",display:"-webkit-box",WebkitBoxOrient:"vertical",WebkitLineClamp:5,overflow:"hidden"},children:no(A.body)}),c.jsx(ze,{content:r?"Chưa đọc":"Đã đọc",sx:{...OA.textXs.medium,color:r?xe[600]:_A[500]}})]}),c.jsxs(se,{sx:{gap:Je},children:[a?c.jsx(ze,{content:a,sx:{...OA.textXs.medium,color:h1[i]}}):null,s?c.jsx(ze,{content:"Xem chi tiết",sx:{...OA.textXs.medium,color:xe[600]}}):null]})]})]})})},u5=({onNavigate:A})=>{const{axiosNotification:e,showSnackbar:t}=t2(),[o,r]=F.useState(en.ALL),{notifications:i,totalCount:s,unreadCount:a,isLoading:l,isRefreshing:u,error:d,handlePaginationChange:p,page:g,pageSize:h,refresh:m}=Dc({page:1,pageSize:10},o),f=async b=>{if(b.status===hn.UNREAD)try{await ba(e,b.id),await m()}catch(q){t==null||t({type:mt.ERROR,message:a0(q)})}},C=async()=>{if(a)try{const b=await ya(e);await m(),t==null||t({type:mt.SUCCESS,message:b.success?"Đã đánh dấu tất cả thông báo là đã đọc":"Không có thông báo cần đánh dấu"})}catch(b){t==null||t({type:mt.ERROR,message:a0(b)})}};return c.jsxs(I.Stack,{sx:{flex:1,gap:0,minHeight:0,overflow:"hidden"},children:[c.jsx(I.Stack,{sx:{borderBottom:`1px solid ${_A[200]}`,gap:0,p:Je},children:c.jsx(w3,{children:c.jsx(Qa,{tabs:xk.map(b=>({id:b.id,name:b.name,onClick:()=>r(b.id)})),idSelect:o})})}),c.jsxs(I.Stack,{sx:{flex:1,gap:wA,minHeight:0,overflow:"auto",p:Oe},children:[c.jsxs(At,{sx:{flexWrap:"wrap",gap:wA},children:[c.jsxs(I.Stack,{sx:{gap:Je},children:[c.jsx(ze,{content:`Danh sách (${s})`,sx:{...OA.textSm.semiBold}}),c.jsx(ze,{content:a?`${a} thông báo chưa đọc`:"Tất cả thông báo đã được đọc",sx:{...OA.textXs.medium,color:a?xe[600]:_A[500]}})]}),a?c.jsx(Qe,{content:"Đánh dấu tất cả đã đọc",disabled:u,endIcon:"done_all",loading:u,onClick:C,variant:"text"}):null]}),i.map(b=>c.jsx(qk,{notification:b,onNavigate:A,onRead:()=>f(b)},b.id)),!d&&i.length===0&&!l?c.jsx(u0,{sx:{flex:1,gap:wA,minHeight:220},children:c.jsx(Fn,{content:"Bạn sẽ nhận được thông báo khi có hoạt động mới"})}):null,l&&i.length===0?c.jsx(u0,{sx:{flex:1,minHeight:220},children:c.jsx(ct,{})}):null,d?c.jsx(Fn,{content:`Lỗi khi tải thông báo: ${d}`}):null]}),s>h?c.jsx(G4,{total:s,page:g,take:h,onChange:p}):null]})},wk=10,Sk={[me.CRITICAL]:"error",[me.HIGH]:"warning",[me.NORMAL]:"notifications",[me.INFO]:"info"},Ek={[me.CRITICAL]:Ft[500],[me.HIGH]:qo[500],[me.NORMAL]:xe[500],[me.INFO]:_A[500]},Ik=({notification:A,onClick:e})=>{const t=F.useMemo(()=>qc(A.createdAt),[A.createdAt]),o=A.status===hn.UNREAD,r=A.priority??me.INFO;return c.jsx(I.ListItem,{onClick:()=>e(A),sx:{borderRadius:be,cursor:"pointer",p:wA,transition:$e,bgcolor:o?xe[50]:Ue[50],"&:hover":{bgcolor:o?xe[100]:_A[50]}},children:c.jsxs(se,{sx:{alignItems:"flex-start",gap:wA,width:"100%"},children:[c.jsx(a5,{notification:A,fallbackIcon:Sk[r],color:Ek[r]}),c.jsxs(I.Stack,{sx:{flex:1,gap:Je,minWidth:0},children:[c.jsxs(I3,{sx:{gap:wA},children:[c.jsx(ze,{content:no(A.title),sx:{...OA.textSm.semiBold}}),c.jsx(ze,{content:t,sx:{...OA.textXs.medium,flexShrink:0}})]}),c.jsx(ze,{content:no(A.body),sx:{...OA.textXs.regular}})]})]})})},Dk=({onNavigate:A,dropdownPageSize:e=wk})=>{const{axiosNotification:t,hasNewNotification:o,unreadCount:r,markNotificationsSeen:i,refreshNotifications:s,showSnackbar:a}=t2(),[l,u]=F.useState(!1),[d,p]=F.useState(!1),[g,h]=F.useState(!1),{notifications:m,isLoading:f,refresh:C}=Dc({page:1,pageSize:e}),b=()=>{u(y=>!y),i()},q=async y=>{if(u(!1),y.status===hn.UNREAD)try{await ba(t,y.id),await s(),await C()}catch(w){a==null||a({type:mt.ERROR,message:a0(w)})}yc(y.actionUrl)&&(A==null||A(y.actionUrl))},x=async()=>{h(!0);try{await ya(t),await s(),await C(),a==null||a({type:mt.SUCCESS,message:"Đã đánh dấu tất cả thông báo là đã đọc"})}catch(y){a==null||a({type:mt.ERROR,message:a0(y)})}finally{h(!1)}};return c.jsxs(c.Fragment,{children:[c.jsx(P3,{open:l,onClickAway:()=>u(!1),placement:"bottom-end",content:c.jsxs(I.List,{sx:{display:"flex",flexDirection:"column",maxHeight:500,overflowY:"auto",p:0,width:360},children:[c.jsxs(I.ListItem,{sx:{alignItems:"center",bgcolor:Ue[50],borderBottom:`1px solid ${_A[200]}`,display:"flex",justifyContent:"space-between",p:wA,position:"sticky",top:0,zIndex:1},children:[c.jsx(ze,{content:"Thông báo hệ thống",sx:{...OA.textMd.semiBold}}),c.jsxs(se,{sx:{gap:Je},children:[g?c.jsx(ct,{size:"small"}):null,c.jsx(So,{icon:"mark_email_read",onClick:x,sx:{minHeight:30,minWidth:30}}),c.jsx(So,{icon:"open_in_full",onClick:()=>{u(!1),p(!0)},sx:{minHeight:30,minWidth:30}})]})]}),f?c.jsx(ct,{}):null,!f&&m.length===0?c.jsx(Fn,{content:"Không có thông báo"}):null,f?null:m.map(y=>c.jsx(Ik,{notification:y,onClick:q},y.id))]}),children:c.jsx(I.Badge,{badgeContent:A5(r),color:"error",invisible:r===0,sx:{cursor:"pointer","& .MuiBadge-badge":{...OA.textXs.semiBold,minWidth:16,height:16}},children:c.jsx(So,{"aria-label":"Thông báo",icon:"notifications_none",onClick:b,sx:{bgcolor:o?qo[50]:"transparent",color:o?qo[700]:_A[600],minHeight:32,minWidth:32,"&:hover":{bgcolor:o?qo[100]:_A[100],color:o?qo[800]:_A[800]}}})})}),c.jsx(I.Drawer,{anchor:"right",open:d,onClose:()=>p(!1),children:c.jsxs(I.Stack,{sx:{height:"100vh",width:600,overflow:"hidden"},children:[c.jsxs(I.Stack,{sx:{borderBottom:`1px solid ${_A[200]}`,gap:Je,p:wA},children:[c.jsxs(At,{sx:{gap:wA},children:[c.jsx(ze,{content:"Thông báo hệ thống",sx:{...OA.textMd.semiBold}}),c.jsx(So,{icon:"close",onClick:()=>p(!1)})]}),c.jsx(ze,{content:"Xem và quản lý các thông báo của bạn",sx:{...OA.textXs.medium,color:_A[500]}})]}),c.jsx(u5,{onNavigate:A})]})})]})},Tk=({isLineHeight1:A,price:e,originalPrice:t,discountPercent:o,onClick:r,color:i,size:s="small",sameSize:a=!1,sx:l={}})=>{const{palette:u}=I.useTheme(),d={small:"subtitle1",medium:"h6",large:"h5"};return r&&(l={...l,cursor:"pointer"}),c.jsxs(I.Stack,{sx:l,children:[c.jsxs(se,{sx:{color:i||u.error.main,gap:wA},children:[c.jsx(vA,{icon:"attach_money",size:s,sx:{marginRight:"-5px",marginLeft:"-4px"}}),c.jsx(I.Typography,{lineHeight:A?1:void 0,variant:d[s],children:+e.toFixed(1)})]}),t&&e!==t&&c.jsxs(se,{sx:{gap:wA},children:[c.jsxs(se,{sx:{color:u.text.disabled,gap:wA,position:"relative","&:after":{position:"absolute",content:"''",borderTop:`1px solid ${u.text.disabled}`,width:"100%"}},children:[c.jsx(vA,{icon:"attach_money",size:a?s:"small",sx:{marginRight:"-5px",marginLeft:"-4px"}}),c.jsx(I.Typography,{lineHeight:A?1:void 0,variant:a?d[s]:"body1",children:t})]}),o&&c.jsx(I.Typography,{lineHeight:A?1:void 0,color:o<0?"success.main":"error",variant:a?d[s]:"body1",children:(o<0?"+":"-")+Math.abs(o)+"%"})]})]})};var M2={exports:{}},Bk=M2.exports,C1;function Ok(){return C1||(C1=1,(function(A,e){(function(t,o){A.exports=o()})(Bk,(function(){var t="week",o="year";return function(r,i,s){var a=i.prototype;a.week=function(l){if(l===void 0&&(l=null),l!==null)return this.add(7*(l-this.week()),"day");var u=this.$locale().yearStart||1;if(this.month()===11&&this.date()>25){var d=s(this).startOf(o).add(1,o).date(u),p=s(this).endOf(t);if(d.isBefore(p))return 1}var g=s(this).startOf(o).date(u).startOf(t).subtract(1,"millisecond"),h=this.diff(g,t,!0);return h<0?s(this).startOf("week").week():Math.ceil(h)},a.weeks=function(l){return l===void 0&&(l=null),this.week(l)}}}))})(M2)),M2.exports}var kk=Ok();const Pk=Hn(kk);var R2={exports:{}},Mk=R2.exports,b1;function Rk(){return b1||(b1=1,(function(A,e){(function(t,o){A.exports=o()})(Mk,(function(){return function(t,o,r){o.prototype.isBetween=function(i,s,a,l){var u=r(i),d=r(s),p=(l=l||"()")[0]==="(",g=l[1]===")";return(p?this.isAfter(u,a):!this.isBefore(u,a))&&(g?this.isBefore(d,a):!this.isAfter(d,a))||(p?this.isBefore(u,a):!this.isAfter(u,a))&&(g?this.isAfter(d,a):!this.isBefore(d,a))}}}))})(R2)),R2.exports}var Nk=Rk();const Fk=Hn(Nk);var N2={exports:{}},jk=N2.exports,y1;function Lk(){return y1||(y1=1,(function(A,e){(function(t,o){A.exports=o()})(jk,(function(){return function(t,o){var r=o.prototype,i=r.format;r.format=function(s){var a=this,l=this.$locale();if(!this.isValid())return i.bind(this)(s);var u=this.$utils(),d=(s||"YYYY-MM-DDTHH:mm:ssZ").replace(/\[([^\]]+)]|Q|wo|ww|w|WW|W|zzz|z|gggg|GGGG|Do|X|x|k{1,2}|S/g,(function(p){switch(p){case"Q":return Math.ceil((a.$M+1)/3);case"Do":return l.ordinal(a.$D);case"gggg":return a.weekYear();case"GGGG":return a.isoWeekYear();case"wo":return l.ordinal(a.week(),"W");case"w":case"ww":return u.s(a.week(),p==="w"?1:2,"0");case"W":case"WW":return u.s(a.isoWeek(),p==="W"?1:2,"0");case"k":case"kk":return u.s(String(a.$H===0?24:a.$H),p==="k"?1:2,"0");case"X":return Math.floor(a.$d.getTime()/1e3);case"x":return a.$d.getTime();case"z":return"["+a.offsetName()+"]";case"zzz":return"["+a.offsetName("long")+"]";default:return p}}));return i.bind(this)(d)}}}))})(N2)),N2.exports}var Qk=Lk();const Uk=Hn(Qk);DA.extend(t3);DA.extend(Pk);DA.extend(Fk);DA.extend(Uk);const Hk={YY:"year",YYYY:{sectionType:"year",contentType:"digit",maxLength:4},M:{sectionType:"month",contentType:"digit",maxLength:2},MM:"month",MMM:{sectionType:"month",contentType:"letter"},MMMM:{sectionType:"month",contentType:"letter"},D:{sectionType:"day",contentType:"digit",maxLength:2},DD:"day",Do:{sectionType:"day",contentType:"digit-with-letter"},d:{sectionType:"weekDay",contentType:"digit",maxLength:2},dd:{sectionType:"weekDay",contentType:"letter"},ddd:{sectionType:"weekDay",contentType:"letter"},dddd:{sectionType:"weekDay",contentType:"letter"},A:"meridiem",a:"meridiem",H:{sectionType:"hours",contentType:"digit",maxLength:2},HH:"hours",h:{sectionType:"hours",contentType:"digit",maxLength:2},hh:"hours",m:{sectionType:"minutes",contentType:"digit",maxLength:2},mm:"minutes",s:{sectionType:"seconds",contentType:"digit",maxLength:2},ss:"seconds"},zk={year:"YYYY",month:"MMMM",monthShort:"MMM",dayOfMonth:"D",dayOfMonthFull:"Do",weekday:"dddd",weekdayShort:"dd",hours24h:"HH",hours12h:"hh",meridiem:"A",minutes:"mm",seconds:"ss",fullDate:"ll",keyboardDate:"L",shortDate:"MMM D",normalDate:"D MMMM",normalDateWithWeekday:"ddd, MMM D",fullTime12h:"hh:mm A",fullTime24h:"HH:mm",keyboardDateTime12h:"L hh:mm A",keyboardDateTime24h:"L HH:mm"},Ms=["Missing UTC plugin","To be able to use UTC or timezones, you have to enable the `utc` plugin","Find more information on https://mui.com/x/react-date-pickers/timezone/#day-js-and-utc"].join(`
263
263
  `),v1=["Missing timezone plugin","To be able to use timezones, you have to enable both the `utc` and the `timezone` plugin","Find more information on https://mui.com/x/react-date-pickers/timezone/#day-js-and-timezone"].join(`
264
264
  `);class Vk{constructor({locale:e,formats:t}={}){yA(this,"isMUIAdapter",!0);yA(this,"isTimezoneCompatible",!0);yA(this,"lib","dayjs");yA(this,"escapedCharacters",{start:"[",end:"]"});yA(this,"formatTokenMap",Hk);yA(this,"setLocaleToValue",e=>{const t=this.getCurrentLocaleCode();return t===e.locale()?e:e.locale(t)});yA(this,"hasUTCPlugin",()=>typeof DA.utc<"u");yA(this,"hasTimezonePlugin",()=>typeof DA.tz<"u");yA(this,"isSame",(e,t,o)=>{const r=this.setTimezone(t,this.getTimezone(e));return e.format(o)===r.format(o)});yA(this,"cleanTimezone",e=>{switch(e){case"default":return;case"system":return DA.tz.guess();default:return e}});yA(this,"createSystemDate",e=>{let t;if(this.hasUTCPlugin()&&this.hasTimezonePlugin()){const o=DA.tz.guess();o==="UTC"?t=DA(e):t=DA.tz(e,o)}else t=DA(e);return this.setLocaleToValue(t)});yA(this,"createUTCDate",e=>{if(!this.hasUTCPlugin())throw new Error(Ms);return this.setLocaleToValue(DA.utc(e))});yA(this,"createTZDate",(e,t)=>{if(!this.hasUTCPlugin())throw new Error(Ms);if(!this.hasTimezonePlugin())throw new Error(v1);const o=e!==void 0&&!e.endsWith("Z");return this.setLocaleToValue(DA(e).tz(this.cleanTimezone(t),o))});yA(this,"getLocaleFormats",()=>{const e=DA.Ls,t=this.locale||"en";let o=e[t];return o===void 0&&(process.env.NODE_ENV!=="production"&&Op(["MUI X: Your locale has not been found.","Either the locale key is not a supported one. Locales supported by dayjs are available here: https://github.com/iamkun/dayjs/tree/dev/src/locale.","Or you forget to import the locale from 'dayjs/locale/{localeUsed}'","fallback on English locale."]),o=e.en),o.formats});yA(this,"adjustOffset",e=>{if(!this.hasTimezonePlugin())return e;const t=this.getTimezone(e);if(t!=="UTC"){const o=e.tz(this.cleanTimezone(t),!0);if(o.$offset===(e.$offset??0))return e;e.$offset=o.$offset}return e});yA(this,"date",(e,t="default")=>e===null?null:t==="UTC"?this.createUTCDate(e):t==="system"||t==="default"&&!this.hasTimezonePlugin()?this.createSystemDate(e):this.createTZDate(e,t));yA(this,"getInvalidDate",()=>DA(new Date("Invalid date")));yA(this,"getTimezone",e=>{var t;if(this.hasTimezonePlugin()){const o=(t=e.$x)==null?void 0:t.$timezone;if(o)return o}return this.hasUTCPlugin()&&e.isUTC()?"UTC":"system"});yA(this,"setTimezone",(e,t)=>{if(this.getTimezone(e)===t)return e;if(t==="UTC"){if(!this.hasUTCPlugin())throw new Error(Ms);return e.utc()}if(t==="system")return e.local();if(!this.hasTimezonePlugin()){if(t==="default")return e;throw new Error(v1)}return this.setLocaleToValue(DA.tz(e,this.cleanTimezone(t)))});yA(this,"toJsDate",e=>e.toDate());yA(this,"parse",(e,t)=>e===""?null:DA(e,t,this.locale,!0));yA(this,"getCurrentLocaleCode",()=>this.locale||"en");yA(this,"is12HourCycleInCurrentLocale",()=>/A|a/.test(this.getLocaleFormats().LT||""));yA(this,"expandFormat",e=>{const t=this.getLocaleFormats(),o=r=>r.replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,(i,s,a)=>s||a.slice(1));return e.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g,(r,i,s)=>{const a=s&&s.toUpperCase();return i||t[s]||o(t[a])})});yA(this,"isValid",e=>e==null?!1:e.isValid());yA(this,"format",(e,t)=>this.formatByString(e,this.formats[t]));yA(this,"formatByString",(e,t)=>this.setLocaleToValue(e).format(t));yA(this,"formatNumber",e=>e);yA(this,"isEqual",(e,t)=>e===null&&t===null?!0:e===null||t===null?!1:e.toDate().getTime()===t.toDate().getTime());yA(this,"isSameYear",(e,t)=>this.isSame(e,t,"YYYY"));yA(this,"isSameMonth",(e,t)=>this.isSame(e,t,"YYYY-MM"));yA(this,"isSameDay",(e,t)=>this.isSame(e,t,"YYYY-MM-DD"));yA(this,"isSameHour",(e,t)=>e.isSame(t,"hour"));yA(this,"isAfter",(e,t)=>e>t);yA(this,"isAfterYear",(e,t)=>this.hasUTCPlugin()?!this.isSameYear(e,t)&&e.utc()>t.utc():e.isAfter(t,"year"));yA(this,"isAfterDay",(e,t)=>this.hasUTCPlugin()?!this.isSameDay(e,t)&&e.utc()>t.utc():e.isAfter(t,"day"));yA(this,"isBefore",(e,t)=>e<t);yA(this,"isBeforeYear",(e,t)=>this.hasUTCPlugin()?!this.isSameYear(e,t)&&e.utc()<t.utc():e.isBefore(t,"year"));yA(this,"isBeforeDay",(e,t)=>this.hasUTCPlugin()?!this.isSameDay(e,t)&&e.utc()<t.utc():e.isBefore(t,"day"));yA(this,"isWithinRange",(e,[t,o])=>e>=t&&e<=o);yA(this,"startOfYear",e=>this.adjustOffset(e.startOf("year")));yA(this,"startOfMonth",e=>this.adjustOffset(e.startOf("month")));yA(this,"startOfWeek",e=>this.adjustOffset(this.setLocaleToValue(e).startOf("week")));yA(this,"startOfDay",e=>this.adjustOffset(e.startOf("day")));yA(this,"endOfYear",e=>this.adjustOffset(e.endOf("year")));yA(this,"endOfMonth",e=>this.adjustOffset(e.endOf("month")));yA(this,"endOfWeek",e=>this.adjustOffset(this.setLocaleToValue(e).endOf("week")));yA(this,"endOfDay",e=>this.adjustOffset(e.endOf("day")));yA(this,"addYears",(e,t)=>this.adjustOffset(e.add(t,"year")));yA(this,"addMonths",(e,t)=>this.adjustOffset(e.add(t,"month")));yA(this,"addWeeks",(e,t)=>this.adjustOffset(e.add(t,"week")));yA(this,"addDays",(e,t)=>this.adjustOffset(e.add(t,"day")));yA(this,"addHours",(e,t)=>this.adjustOffset(e.add(t,"hour")));yA(this,"addMinutes",(e,t)=>this.adjustOffset(e.add(t,"minute")));yA(this,"addSeconds",(e,t)=>this.adjustOffset(e.add(t,"second")));yA(this,"getYear",e=>e.year());yA(this,"getMonth",e=>e.month());yA(this,"getDate",e=>e.date());yA(this,"getHours",e=>e.hour());yA(this,"getMinutes",e=>e.minute());yA(this,"getSeconds",e=>e.second());yA(this,"getMilliseconds",e=>e.millisecond());yA(this,"setYear",(e,t)=>this.adjustOffset(e.set("year",t)));yA(this,"setMonth",(e,t)=>this.adjustOffset(e.set("month",t)));yA(this,"setDate",(e,t)=>this.adjustOffset(e.set("date",t)));yA(this,"setHours",(e,t)=>this.adjustOffset(e.set("hour",t)));yA(this,"setMinutes",(e,t)=>this.adjustOffset(e.set("minute",t)));yA(this,"setSeconds",(e,t)=>this.adjustOffset(e.set("second",t)));yA(this,"setMilliseconds",(e,t)=>this.adjustOffset(e.set("millisecond",t)));yA(this,"getDaysInMonth",e=>e.daysInMonth());yA(this,"getWeekArray",e=>{const t=this.startOfWeek(this.startOfMonth(e)),o=this.endOfWeek(this.endOfMonth(e));let r=0,i=t;const s=[];for(;i<o;){const a=Math.floor(r/7);s[a]=s[a]||[],s[a].push(i),i=this.addDays(i,1),r+=1}return s});yA(this,"getWeekNumber",e=>e.week());yA(this,"getYearRange",([e,t])=>{const o=this.startOfYear(e),r=this.endOfYear(t),i=[];let s=o;for(;this.isBefore(s,r);)i.push(s),s=this.addYears(s,1);return i});this.locale=e,this.formats=Q({},zk,t),DA.extend(n4)}getDayOfWeek(e){return e.day()+1}}function Wk({children:A,enableWebSerialScale:e=!0,webSerialScaleAutoConnectAuthorized:t,webSerialScaleAutoSwitchActiveWindow:o,webSerialScaleEnabledPathnames:r,webSerialScalePathname:i}){const s=!!(r!=null&&r.length),a=e&&Ta(i??Da(),r),l=t??s,u=o??s,d=c.jsx(xi,{dateAdapter:Vk,children:A});return e?c.jsx(V4,{autoConnectAuthorized:l,autoSwitchActiveWindow:u,enabled:a,children:d}):d}const Gk=({averageRating:A,reviewCount:e,onClick:t,sx:o={}})=>(t&&(o={...o,cursor:"pointer"}),c.jsxs(se,{sx:{gap:wA,cursor:"inherit",...o},onClick:t,children:[c.jsx(vA,{icon:"star",size:"large",fill:1,color:"warning",sx:{margin:"-5px"}}),c.jsxs(Le,{sx:{gap:wA},children:[c.jsx(I.Typography,{lineHeight:1,children:A}),c.jsx(I.Typography,{lineHeight:1,children:`(${e})`})]})]})),d5=({isOpen:A,onClose:e,position:t="left",blacklist:o=[],env:r,onClickApp:i,isLongSubDomain:s=!1})=>{if(!A)return null;const a=Object.keys(ko).reduce((l,u)=>{if(o.includes(u))return l;const d=ko[u];return s&&(d.path.develop=d.path.develop.replace("dev.","develop."),d.path.staging=d.path.staging.replace("sta.","staging.")),l[d.group]?l[d.group].push(d):l[d.group]=[d],l},{});return c.jsxs(c.Fragment,{children:[c.jsx(I.Stack,{onClick:e,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0, 0, 0, 0.5)",zIndex:100}}),c.jsxs(I.Stack,{preset:"fadeInLeft",component:Ir,sx:{position:"fixed",top:0,left:t==="left"?0:"auto",right:t==="right"?0:"auto",height:"100%",backgroundColor:Sr[50],zIndex:100,padding:Oe,overflowY:"auto"},children:[c.jsxs(At,{children:[c.jsx(vA,{icon:"close",onClick:e}),c.jsx(vA,{icon:"home",onClick:()=>window.location.href=s?s0[r].replace("dev.","develop.").replace("sta.","staging."):s0[r]})]}),Object.keys(a).map(l=>c.jsxs(I.Stack,{children:[c.jsx(I.Typography,{variant:"subtitle2",children:l===bA.PLATFORM_AND_INFO?"Platform & Info":l}),c.jsx(bc,{apps:a[l],iconSize:60,iconRadius:5.5,titleVariant:"body1",captionVariant:"caption",titleColor:_A[500],captionColor:_A[500],onClickApp:i,showPagination:!1})]},l))]})]})},Yk="Ẩn điều hướng",pn={background:ar[900],hoverBackground:"rgba(255, 255, 255, 0.08)",selectedBackground:"rgba(255, 255, 255, 0.16)",divider:"rgba(255, 255, 255, 0.18)",text:Ue[50],textMuted:Sr[50]},Kk=A=>({borderRight:0,width:A?Us:"max-content",minWidth:A?Us:K1,padding:wA,gap:wA,backgroundColor:pn.background,justifyContent:"space-between",transition:`width ${$e}, min-width ${$e}`}),Xk={overflowY:"auto",overflowX:"hidden",gap:0},Jk={borderColor:pn.divider},Zk={padding:wA,color:pn.text,borderRadius:bn,"&:hover":{backgroundColor:pn.hoverBackground}},_k=(A,e)=>({minHeight:A?34:36,gap:wA,padding:A?"6px 10px 6px 36px":"6px 10px",borderRadius:bn,color:pn.text,backgroundColor:e?pn.selectedBackground:"transparent",cursor:"pointer",transition:`background-color ${$e}`,"&:hover":{backgroundColor:e?pn.selectedBackground:pn.hoverBackground}}),$k={minWidth:0,flex:1,gap:wA},AP={},eP={},tP=A=>({color:pn.text,transform:A?"rotate(0deg)":"rotate(180deg)",transition:`transform ${$e}`}),nP=({tab:A,tabIdSelect:e,hiddenContent:t,isOpen:o,onClickTab:r,renderSubTabs:i})=>{var u;const s=A.id===e,a=!!((u=A.subs)!=null&&u.length),l=A.level>1;return c.jsxs(I.Stack,{gap:0,children:[c.jsx(gn,{placement:"right-end",content:A.name,disableHoverListener:!t,disableFocusListener:!t,disableTouchListener:!t,children:c.jsx(uo,{component:A.href?"a":"span",href:A.href,onClick:()=>r(A),children:c.jsxs(At,{sx:_k(l,s),children:[c.jsxs(se,{sx:$k,children:[!l&&A.icon&&c.jsx(vA,{icon:A.icon,sx:{color:pn.text}}),!t&&c.jsx(ze,{content:A.name,sx:l?eP:AP})]}),!t&&a&&c.jsx(vA,{icon:"arrow_drop_up",sx:tP(o)})]})})}),!t&&a&&o&&c.jsx(I.Stack,{gap:0,children:i(A.subs)})]},A.id)},p5=(A,e,t,o,r)=>{!A.children||!Object.keys(A.children).length||(Object.keys(A.children).forEach(i=>{const s=A.children[i],a=s.children&&Object.keys(s.children).length;let l=!1;(!s.isSidebar||!s.allowUserTypes.some(u=>e.includes(u))&&!e.includes(t))&&(delete A.children[i],l=!0),!l&&a&&p5(s,e,t,i,A)}),!Object.keys(A.children).length&&o&&r&&delete r.children[o])},f5=(A,e,t,o,r=1,i="/")=>A.children?Object.values(A.children).map(s=>{const l=`${i==="/"?"":i}/${s.path}`,u=s.children&&Object.keys(s.children).length,d={id:l,level:r,name:s.content,icon:s.icon,badgeCount:0,onClick:()=>{e(l),o(l),u||t(l)}};return u?d.subs=f5(s,e,t,o,r+1,l):d.href=l,d}):[],g5=(A,e,t="",o=[])=>{const r=decodeURIComponent(e.split("?")[0]),i=Object.values(A);if(i.length===0)return;const s=(u,d,p)=>{let g=u,h=d;const m=[...p];for(;g.children&&Object.keys(g.children).length>0;){const C=`${h}${g.path}`.replace(/\/+$/,"");C&&m.push(C);const b=Object.values(g.children);h=`${C}/`,g=b[0]}const f=`${h}${g.path}`.replace(/\/+$/,"");return{route:g,fullPath:f,parentPaths:m}};if(r==="/"||r==="")return s(i[0],t,o);const[a,l]=i.reduce((u,d)=>(u[d.path.includes(":")?1:0].push(d),u),[[],[]]);for(const u of[...a,...l]){const d=`${t}${u.path}`.replace(/\/+$/,"");if(!Oc.matchPath({path:d,end:!1},r))continue;const p=d?[...o,d]:[...o];if(u.children){const g=g5(u.children,r,`${d}/`,p);if(g)return g}if(Oc.matchPath({path:d,end:!0},r)){if(u.children){const g=Object.values(u.children)[0];return g?s(g,`${d}/`,p):void 0}return{route:u,fullPath:u.path.includes(":")?r:d,parentPaths:o}}}},F2=(A,e)=>e?[A,...Array.isArray(e)?e:[e]]:A,Tc=(A,e)=>{var t;return!!((t=A.subs)!=null&&t.some(o=>o.id===e||Tc(o,e)))},m5=({tabs:A,tabIdSelect:e,memoryOpen:t,hiddenContentDefault:o=!1,hiddenContentLabel:r=Yk,onEmptyTabs:i,onHiddenContentChange:s,mainSx:a,tabsSx:l,footerSx:u,toggleSx:d})=>{const[p,g]=F.useState(o),[h,m]=F.useState({});F.useEffect(()=>{A.length||i==null||i()},[i,A.length]);const f=()=>{g(x=>{const y=!x;return s==null||s(y),y})},C=x=>{var y,w;(y=x.subs)!=null&&y.length&&!t&&m(E=>({...E,[x.id]:!E[x.id]})),(w=x.onClick)==null||w.call(x)},b=x=>!!((t==null?void 0:t[x.id])??h[x.id]??Tc(x,e)),q=x=>x.map(y=>c.jsx(nP,{tab:y,tabIdSelect:e,hiddenContent:p,isOpen:b(y),onClickTab:C,renderSubTabs:q},y.id));return c.jsxs(I.Stack,{sx:F2(Kk(p),a),children:[A.length>0&&c.jsx(I.Stack,{sx:F2(Xk,l),children:q(A)}),c.jsxs(I.Stack,{gap:1,sx:u,children:[c.jsx(I.Divider,{orientation:"horizontal",flexItem:!0,sx:Jk}),c.jsx(vn,{onClick:f,icon:"menu_open",content:p?"":r,color:"inherit",hiddenContent:p,sx:F2(Zk,d)})]})]})},oP=m5,rP=({position:A,blacklist:e,env:t,onClickApp:o,showNameApps:r,showIconApps:i,showTitleApps:s,direction:a="row",isLongSubDomain:l=!1})=>{const[u,d]=F.useState(!1),p=Object.values(ko).find(g=>Object.values(g.path).some(h=>{const m=h==null?void 0:h.trim();return m&&window.location.href.startsWith(m)}))??ko.MASTER_DATA;return c.jsxs(se,{children:[c.jsx(nn,{url:JA.iconApps,onClick:()=>d(!0),sizeType:"SQUARE"}),c.jsx(Cc,{app:p,iconSize:45,iconRadius:3,showNameApps:r,showIconApps:i,showTitleApps:s,direction:a}),c.jsx(d5,{isOpen:u,onClose:()=>d(!1),position:A,blacklist:e,env:t,onClickApp:o,isLongSubDomain:l})]})},iP={[bA.ALL]:"TẤT CẢ"},sP=({blacklist:A,onClickApp:e,sx:t={},sxTabs:o={},sxApps:r={},sxNotification:i={},gridTemplateColumns:s={xs:"72px minmax(0, 1fr) 72px",sm:"180px minmax(0, 1fr) 180px",md:"240px minmax(0, 1fr) 240px"},isLongSubDomain:a=!1,searchText:l="",notificationSlot:u,iconSize:d=80})=>{const p=zn(),[g,h]=F.useState(bA.ALL),m=I.useMediaQuery(p.breakpoints.down("sm")),f=I.useMediaQuery(p.breakpoints.down("md")),C=I.useMediaQuery(p.breakpoints.down("lg")),b=m?2:f?3:C?4:5,q=F.useMemo(()=>Object.entries(ko).filter(([w])=>!(A!=null&&A.includes(w))).map(([,w])=>{const E=w;return a?{...E,path:{...E.path,develop:E.path.develop.replace("dev.","develop."),staging:E.path.staging.replace("sta.","staging.")}}:E}),[A,a]),x=F.useMemo(()=>q.filter(w=>g!==bA.ALL&&w.group!==g?!1:l?`${w.title??""} ${w.content}`.toLocaleLowerCase().includes(l.toLocaleLowerCase()):!0),[q,l,g]),y=F.useMemo(()=>Object.values(bA).filter(w=>w===bA.ALL||q.some(E=>E.group===w)),[q]);return c.jsxs(io,{component:Ir,preset:"fadeInUp",sx:[{display:"grid",gridTemplateColumns:s,columnGap:{xs:1,md:2},alignItems:"stretch",width:"100%",minHeight:"100%"},...Array.isArray(t)?t:[t]],children:[c.jsx(I.Stack,{sx:[{width:"100%",minWidth:0,gap:.5},...Array.isArray(o)?o:[o]],children:y.map(w=>{const E=g===w;return c.jsxs(se,{onClick:()=>h(w),"aria-pressed":E,sx:{minHeight:40,p:wA,justifyContent:{xs:"center",sm:"flex-start"},border:0,borderRadius:Re,color:E?p.palette.common.white:"rgba(255, 255, 255, 0.82)",backgroundColor:E?"rgba(255, 255, 255, 0.1)":"transparent",cursor:"pointer",transition:"background-color 160ms ease, color 160ms ease","&:hover":{color:p.palette.common.white,backgroundColor:E?"rgba(0, 138, 119, 0.3)":"rgba(255, 255, 255, 0.07)"}},children:[c.jsx(vA,{icon:D1[w]}),c.jsx(I.Typography,{sx:{display:{xs:"none",sm:"block"},...OA.textMd.regular},children:iP[w]??w})]},w)})}),c.jsx(I.Stack,{sx:[{flex:1,minWidth:0,gap:3},...Array.isArray(r)?r:[r]],children:x.length>0?c.jsx(bc,{apps:x,columns:b,rows:3,iconSize:d,iconRadius:7,onClickApp:e,isShowAppHidden:!0},`${g}-${l}`):c.jsx(Fn,{content:"Không tìm thấy ứng dụng phù hợp"})}),c.jsx(I.Stack,{sx:[{width:"100%",minWidth:0},...Array.isArray(i)?i:[i]],children:u})]})},aP=({label:A,count:e=0,color:t,icon:o,info:r,bgColor:i})=>c.jsxs(I.Card,{sx:{minHeight:116,borderRadius:tn},children:[c.jsx(I.CardHeader,{action:c.jsx(I.IconButton,{"aria-label":"settings",children:c.jsx(vA,{icon:"more_vert"})}),title:c.jsx(I.Typography,{variant:"h6",sx:{fontSize:"16px"},color:"#737373",children:A})}),c.jsx(I.CardContent,{sx:{paddingTop:0},children:c.jsxs(I.Stack,{gap:.5,children:[c.jsxs(At,{width:"100%",children:[c.jsx(I.Typography,{variant:"h2",sx:{color:t,fontSize:"32px"},children:e}),c.jsx(jo,{sx:{bgcolor:Do(i,.85),borderRadius:tn,width:48,height:48},children:c.jsx("img",{src:o})})]}),r]})})]}),lP=({label:A="",placeholder:e="Select option",value:t=null,disabled:o=!1,error:r=!1,success:i=!1,errorMessage:s,successMessage:a,borderRadius:l=6,onChange:u,helperText:d="",options:p=[],checkIconColor:g=an[900],required:h=!1,sx:m,labelSx:f})=>{const C=F.useMemo(()=>l==="max"?"100px":`${l}px`,[l]),b=F.useMemo(()=>p.find(E=>E.value===t),[p,t]),q=F.useCallback(()=>r&&s?s:i&&a?a:d||"",[r,s,i,a,d]),x=F.useCallback(()=>r?Ft[500]:i?to[500]:ce[400],[r,i]),y=F.useCallback(()=>r?Ft[500]:i?to[500]:ce[300],[r,i]),w=F.useMemo(()=>({"& .MuiOutlinedInput-root":{borderRadius:`${C} !important`,backgroundColor:o?ce[100]:"white",transition:"all 0.2s ease","& fieldset":{borderRadius:`${C} !important`,borderColor:y()},"&:hover fieldset":{borderColor:o?y():r?Ft[500]:ce[400]},"&.Mui-focused fieldset":{borderColor:r?Ft[500]:ce[400],borderWidth:"1px"}},"& .MuiOutlinedInput-input":{padding:"8px 10px",color:_A[900],"&::placeholder":{color:ce[400],opacity:1}}}),[C,o,r,y]);return c.jsxs(I.Box,{sx:{...m},children:[A&&c.jsxs(I.Box,{sx:{display:"flex",alignItems:"baseline",gap:"2px",marginBottom:"4px"},children:[c.jsx(I.Typography,{sx:{...OA.textMd,color:_A[800],...f},children:A}),h&&c.jsx(I.Typography,{sx:{color:Ft[500],...OA.textMd},children:"*"})]}),c.jsx(I.Select,{fullWidth:!0,value:t||"",onChange:E=>{const T=E.target.value,P=p.find(D=>String(D.value)===String(T));P&&(u==null||u(P.value))},disabled:o,displayEmpty:!0,MenuProps:{disableScrollLock:!0},slotProps:{root:{sx:{borderRadius:C}}},renderValue:()=>t?c.jsxs(I.Box,{sx:{display:"flex",alignItems:"center",gap:"8px"},children:[(b==null?void 0:b.statusIndicator)&&c.jsx(I.Box,{sx:{width:"8px",height:"8px",borderRadius:"50%",backgroundColor:"#4CAF50"}}),(b==null?void 0:b.avatar)&&c.jsx(I.Avatar,{src:b.avatar,sx:{width:"24px",height:"24px",fontSize:"12px"}}),(b==null?void 0:b.icon)&&c.jsx(vA,{icon:b.icon}),c.jsx(I.Typography,{sx:{color:_A[900],...OA.textMd,lineHeight:"1.4375em"},children:b==null?void 0:b.label})]}):c.jsx(I.Typography,{sx:{color:ce[400],...OA.textMd,lineHeight:"1.4375em"},children:e}),sx:w,children:p.map(E=>c.jsx(I.MenuItem,{value:E.value,children:c.jsxs(I.Box,{sx:{display:"flex",alignItems:"center",gap:"8px",width:"100%"},children:[E.statusIndicator&&c.jsx(I.Box,{sx:{width:"8px",height:"8px",borderRadius:"50%",backgroundColor:"#4CAF50"}}),E.avatar&&c.jsx(I.Avatar,{src:E.avatar,sx:{width:"24px",height:"24px",fontSize:"12px"}}),E.icon&&c.jsx(vA,{icon:E.icon}),c.jsx(I.Typography,{sx:{color:_A[900],...OA.textMd,lineHeight:"1.4375em"},children:E.label}),t===E.value&&c.jsx(I.Box,{sx:{marginLeft:"auto",display:"flex",alignItems:"center"},children:c.jsx(vA,{icon:"check",sx:{color:g}})})]})},E.value))}),q()&&c.jsx(I.Box,{sx:{color:x(),marginTop:"4px",...OA.textMd,lineHeight:"1.4375em"},children:q()})]})},cP=I.styled(I.Autocomplete)(()=>({"& .MuiOutlinedInput-root":{padding:"4px 10px !important",display:"flex",alignItems:"center",gap:"4px","& fieldset":{borderColor:ce[300]},"&:hover fieldset":{borderColor:ce[400]},"&.Mui-focused fieldset":{borderColor:ce[300]+" !important",borderWidth:"1.5px"},"&.Mui-disabled":{backgroundColor:ce[100],"& fieldset":{borderColor:ce[200]}},"&.Mui-error fieldset":{borderColor:Ft[500]},"&.Mui-success fieldset":{borderColor:to[500]}},"& .MuiInputBase-input":{padding:"4px 4px !important",fontSize:"14px",flex:1,minWidth:"60px","&::placeholder":{color:ce[400],opacity:1},"&.Mui-disabled":{color:ce[400],WebkitTextFillColor:ce[400]}},"& .MuiAutocomplete-endAdornment":{paddingRight:"4px"},"& .MuiAutocomplete-tag":{backgroundColor:an[50],border:`1px solid ${an[200]}`,color:an[900],fontSize:"12px",margin:"2px","& .MuiChip-deleteIcon":{color:an[400],"&:hover":{color:an[600]}}},"& .search-dropdown-limit-badge":{backgroundColor:an[50],border:`1px solid ${an[200]}`,color:an[700],...OA.textSmall.semiBold,margin:"2px"}})),uP=({value:A,onChange:e,onClear:t,onInputChange:o,onSearch:r,borderRadius:i=4,disabled:s=!1,multiple:a=!1,limitTags:l=2,label:u="",placeholder:d="Search...",error:p=!1,errorMessage:g,success:h=!1,successMessage:m,helperText:f="",options:C=[],loading:b=!1,iconBefore:q,required:x=!1,sx:y})=>{const[E,T]=F.useState(""),[P,D]=F.useState(C),[k,M]=F.useState(!1),v=F.useRef(null),B=F.useRef(r),O=F.useRef(o),R=F.useRef(C);F.useEffect(()=>{B.current=r,O.current=o,R.current=C},[r,o,C]);const N=F.useMemo(()=>A?(Array.isArray(A)?A:[A]).map(j=>typeof j=="object"?j:{label:String(j),value:j}):[],[A]);F.useEffect(()=>{if(v.current&&clearTimeout(v.current),!E.trim()){D(R.current);return}return v.current=setTimeout(async()=>{var j;const H=B.current;if(H){M(!0);try{const J=await H(E);D(J)}catch(J){console.error("Search error:",J),D([])}finally{M(!1)}}else{const J=R.current.filter(eA=>eA.label.toLowerCase().includes(E.toLowerCase()));D(J)}(j=O.current)==null||j.call(O,E)},500),()=>{v.current&&clearTimeout(v.current)}},[E]);const L=(H,j)=>{T(j)},G=(H,j)=>{if(a){const J=Array.isArray(j)?j:j?[j]:[];e==null||e(J.length>0?J:null),T("")}else e==null||e(j||null)},U=()=>{T(""),D(R.current),e==null||e(null),t==null||t()};return c.jsxs(I.Box,{sx:{width:"100%",...y},children:[u&&c.jsxs(I.Box,{sx:{display:"flex",alignItems:"baseline",gap:"2px",marginBottom:"6px"},children:[c.jsx(I.Typography,{sx:{...OA.textMd,color:_A[900],display:"block"},children:u}),x&&c.jsx(I.Typography,{sx:{color:Ft[500],...OA.textMd},children:"*"})]}),c.jsx(cP,{multiple:a,freeSolo:!1,options:P,getOptionLabel:H=>H?typeof H=="object"&&"label"in H?H.label:String(H):"",isOptionEqualToValue:(H,j)=>!H||!j?!1:typeof H=="object"&&typeof j=="object"&&"value"in H&&"value"in j?H.value===j.value:!1,value:a?N:N[0]||null,inputValue:E,onInputChange:L,onChange:G,disabled:s||b,loading:k||b,noOptionsText:E?"No results found":"Type to search",slotProps:{paper:{sx:{"& .MuiAutocomplete-listbox":{borderRadius:i==="max"?"0 0 100px 100px":`0 0 ${i}px ${i}px`}}}},renderInput:H=>c.jsx(I.TextField,{...H,placeholder:N&&(N==null?void 0:N.length)>0?"":d,variant:"outlined",size:"small",error:p,sx:{"& .MuiOutlinedInput-root":{borderRadius:i==="max"?"100px !important":`${i}px !important`,"& fieldset":{borderRadius:i==="max"?"100px !important":`${i}px !important`}}},InputProps:{...H.InputProps,startAdornment:c.jsxs(c.Fragment,{children:[c.jsx(I.InputAdornment,{position:"start",sx:{marginLeft:"4px",marginRight:"0px"},children:q||c.jsx(vA,{icon:"search",sx:{color:"#999",fontSize:"18px"}})}),H.InputProps.startAdornment]})}}),renderTags:(H,j)=>{const J=Array.isArray(H)?H:[],eA=a?J.slice(0,l):J,$=J.length-eA.length;return c.jsxs(c.Fragment,{children:[eA.map((X,_)=>{const tA=typeof X=="object"&&X&&"label"in X?X.label:String(X);return F.createElement(I.Chip,{...j({index:_}),key:_,label:tA,size:"small"})}),$>0&&c.jsx(I.Chip,{className:"search-dropdown-limit-badge",label:`+${$}`,size:"small"})]})},renderOption:(H,j)=>{const{key:J,...eA}=H,$=(j==null?void 0:j.label)||"";return c.jsx(I.Box,{...eA,component:"li",children:$},J)},componentsProps:{clearIndicator:{onClick:U}}}),p&&g&&c.jsx(I.Box,{sx:{fontSize:"12px",color:Ft[500],marginTop:"4px"},children:g}),h&&m&&c.jsx(I.Box,{sx:{fontSize:"12px",color:to[500],marginTop:"4px"},children:m}),f&&!p&&!h&&c.jsx(I.Box,{sx:{fontSize:"12px",color:ce[500],marginTop:"4px"},children:f})]})};exports.APPS=D6;exports.AdvancedFilterDialog=sO;exports.AdvancedOperatorFilterDialog=lO;exports.AppGrid=bc;exports.AppGridItem=Cc;exports.AppGroup=bA;exports.AppsSidebar=d5;exports.AvatarElement=dt;exports.AvatarGroupElement=H3;exports.AvatarOnlineStatusElement=lh;exports.AvatarUserInfo=dh;exports.AvatarUserInfoDetail=ch;exports.AvatarUserInfoUpdate=uh;exports.BORDER_TABLE=Oo;exports.BorderLinearProgress=Ah;exports.BreadcrumbElement=ph;exports.ButtonElement=Qe;exports.ButtonIconContentOpacityElement=fh;exports.ButtonIconElement=So;exports.ButtonImageElement=$B;exports.ButtonUploadFileElement=dc;exports.COLOR=F6;exports.CardStatisticsComponent=aP;exports.CheckboxElement=pa;exports.CollapsibleSection=oO;exports.ColumnSettingsPopover=nO;exports.DATE_OPERATOR_OPTIONS=N4;exports.DATE_OPTIONS=F4;exports.DISABLED_DEFAULT=E0;exports.DashedDividerElement=rO;exports.DateFilterMacro=Ee;exports.DefaultLayout=$O;exports.DialogConfirmActionElement=vh;exports.DialogElement=Ua;exports.DirectionProps=I0;exports.DropdownFieldComponent=lP;exports.EmptyComponent=Fn;exports.Environment=dn;exports.FIELD_WIDTH=k4;exports.FINISH_GOOD_IMAGE_GALLERY=j6;exports.FULL_OPERATOR_OPTIONS=M4;exports.FilterOperator=ln;exports.FilterSlider=cO;exports.FinishGoodImageGalleryElement=T4;exports.FloatingActionHubElement=L4;exports.FloatingToolsElement=IO;exports.FlowControlWebSerialScaleEvent=U4;exports.GROUP_ICONS=D1;exports.HttpStatusSpecial=E1;exports.ICONS=JA;exports.IconContentBadgeElement=Er;exports.IconContentBadgeSubsElement=U3;exports.IconContentBadgeSubsVerticalElement=R3;exports.IconContentElement=vn;exports.IconElement=vA;exports.ImageBorderDashboard=nh;exports.ImageBrand=th;exports.ImageContentCaptionComponent=ZB;exports.ImageContentTimeComponent=_B;exports.ImageElement=nn;exports.ImageEmpty=Na;exports.ImageGalleryElement=S4;exports.ImageGalleryVariant=ti;exports.InputLabelCustom=oh;exports.LinkElement=uo;exports.LinkWrapProductRow=rh;exports.ListIconContentElement=W4;exports.LoadingComponent=ct;exports.LogoComponent=Ak;exports.LogoName=$4;exports.MODE=On;exports.Mode=D0;exports.MotionBox=Ir;exports.NOTIFICATION_LIST_SWR_KEY=wc;exports.NOTIFICATION_REALTIME_SWR_KEY=l5;exports.NOTIFICATION_UNREAD_COUNT_SWR_KEY=Sc;exports.NoteComponent=ek;exports.NotificationAuthStatus=lo;exports.NotificationBeChannel=S1;exports.NotificationDropdown=Dk;exports.NotificationList=u5;exports.NotificationListStatus=en;exports.NotificationPriority=me;exports.NotificationProvider=fk;exports.NotificationRecipientStatus=hn;exports.NotificationRecipientStatusName=j2;exports.OPERATOR_OPTIONS=R4;exports.OPERATOR_WIDTH=fa;exports.OTHER=U6;exports.OnlineBadge=z3;exports.OrderType=I1;exports.PaginationElement=G4;exports.PaperSelect=Fa;exports.ParityWebSerialScaleSerial=is;exports.PriceComponent=Tk;exports.RadioElement=TO;exports.RadioGroupElement=DO;exports.ReviewComponent=Gk;exports.STYLE=e8;exports.SearchDropdownComponent=uP;exports.SectionTitle=BO;exports.SevagoProvider=Wk;exports.SidebarLeftComponent=oP;exports.SidebarLeftLibraryComponent=m5;exports.SizeProps=It;exports.SmallIcon=I2;exports.SnackbarType=mt;exports.StackAlignCenter=io;exports.StackAlignCenterJustAround=fm;exports.StackAlignCenterJustBetween=pm;exports.StackAlignCenterJustCenter=u0;exports.StackAlignCenterJustEnd=dm;exports.StackAlignCenterJustEvenly=gm;exports.StackAlignEnd=w3;exports.StackAlignEndJustAround=xm;exports.StackAlignEndJustBetween=vm;exports.StackAlignEndJustCenter=bm;exports.StackAlignEndJustEnd=ym;exports.StackAlignEndJustEvenly=qm;exports.StackAlignJustCenter=F0;exports.StackAlignStart=Yg;exports.StackAlignStartJustAround=im;exports.StackAlignStartJustBetween=rm;exports.StackAlignStartJustCenter=nm;exports.StackAlignStartJustEnd=om;exports.StackAlignStartJustEvenly=sm;exports.StackBgDefaultBorRadLayCol=B3;exports.StackBgPaperBorRadLayCol=_m;exports.StackJustAround=_g;exports.StackJustBetween=Zg;exports.StackJustCenter=S3;exports.StackJustEnd=Jg;exports.StackJustEvenly=$g;exports.StackLabel=O3;exports.StackRow=Le;exports.StackRowAlignCenter=se;exports.StackRowAlignCenterJustAround=hm;exports.StackRowAlignCenterJustBetween=At;exports.StackRowAlignCenterJustCenter=D3;exports.StackRowAlignCenterJustEnd=mm;exports.StackRowAlignCenterJustEvenly=Cm;exports.StackRowAlignEnd=Xg;exports.StackRowAlignEndJustAround=Im;exports.StackRowAlignEndJustBetween=Em;exports.StackRowAlignEndJustCenter=wm;exports.StackRowAlignEndJustEnd=Sm;exports.StackRowAlignEndJustEvenly=Dm;exports.StackRowAlignJustCenter=jo;exports.StackRowAlignStart=Kg;exports.StackRowAlignStartJustAround=cm;exports.StackRowAlignStartJustBetween=I3;exports.StackRowAlignStartJustCenter=am;exports.StackRowAlignStartJustEnd=lm;exports.StackRowAlignStartJustEvenly=um;exports.StackRowJustAround=em;exports.StackRowJustBetween=bi;exports.StackRowJustCenter=Am;exports.StackRowJustEnd=E3;exports.StackRowJustEvenly=tm;exports.StackRowWrap=Wg;exports.StackRowWrapAlignCenter=Bm;exports.StackRowWrapAlignCenterJustAround=Wm;exports.StackRowWrapAlignCenterJustBetween=Vm;exports.StackRowWrapAlignCenterJustCenter=Hm;exports.StackRowWrapAlignCenterJustEnd=zm;exports.StackRowWrapAlignCenterJustEvenly=Gm;exports.StackRowWrapAlignEnd=Om;exports.StackRowWrapAlignEndJustAround=Jm;exports.StackRowWrapAlignEndJustBetween=Xm;exports.StackRowWrapAlignEndJustCenter=Ym;exports.StackRowWrapAlignEndJustEnd=Km;exports.StackRowWrapAlignEndJustEvenly=Zm;exports.StackRowWrapAlignJustCenter=T3;exports.StackRowWrapAlignStart=Tm;exports.StackRowWrapAlignStartJustAround=Qm;exports.StackRowWrapAlignStartJustBetween=Lm;exports.StackRowWrapAlignStartJustCenter=Fm;exports.StackRowWrapAlignStartJustEnd=jm;exports.StackRowWrapAlignStartJustEvenly=Um;exports.StackRowWrapJustAround=Rm;exports.StackRowWrapJustBetween=Mm;exports.StackRowWrapJustCenter=km;exports.StackRowWrapJustEnd=Pm;exports.StackRowWrapJustEvenly=Nm;exports.StackTabs=k3;exports.StackWrap=Gg;exports.Status=B1;exports.StyledTab=F3;exports.StyledTableCell=$m;exports.StyledTabs=N3;exports.SwitchContentElement=OO;exports.SwitchElement=Y4;exports.SystemMonitorScreen=sP;exports.SystemMonitorSidebarPart=rP;exports.TAB_BACKGROUND_STYLES=La;exports.TAB_STYLES=ja;exports.TAB_WRAPPER_STYLES=j3;exports.TabSizeProps=T1;exports.TableActions=mc;exports.TableCollapseComponent=WO;exports.TableComponent=YO;exports.TableRowKey=wr;exports.TabsBadgeComponent=sh;exports.TabsBadgeSubsVerticalComponent=M3;exports.TabsComponent=Qa;exports.TabsMotionBase=Q3;exports.TagElement=i4;exports.TextFieldDateElement=$f;exports.TextFieldDateRangeElement=jf;exports.TextFieldDateTimeElement=aD;exports.TextFieldElement=iT;exports.TextFieldEmailAutocomplete=kD;exports.TextFieldHourMinuteElement=PD;exports.TextFieldLabelElement=ut;exports.TextFieldMonthYearElement=MD;exports.TextFieldNumberElement=RD;exports.TextFieldSearchCustomElement=ND;exports.TextFieldSearchElement=A4;exports.TextFieldSelectElement=Mn;exports.TextFieldSelectSearchObjectElement=FD;exports.TextFieldTimeElement=KD;exports.TextFieldTimeRangeElement=AT;exports.TextFieldUploadImageElement=eT;exports.TextFieldUploadImagesElement=tT;exports.TimeAgoComponent=B4;exports.TimeAgoContentComponent=O4;exports.TooltipOnClickElement=P3;exports.TooltipOnHoverElement=gn;exports.TypographyAnimatedIconImage=mT;exports.TypographyContentCaption=r4;exports.TypographyFilter=ih;exports.TypographyGridInfoRow=hT;exports.TypographyInfoRow=CT;exports.TypographyInfoUser=bT;exports.TypographyOneLine=ze;exports.UserInfo=KO;exports.VALUE_WIDTH=P4;exports.VariantProps=L2;exports.WEB_SERIAL_SCALE_DEFAULT_BAUD_RATE=fc;exports.WEB_SERIAL_SCALE_DEFAULT_LINE_LIMIT=Q4;exports.WebSerialScaleControllerElement=qO;exports.WebSerialScaleProviderElement=V4;exports.WebSerialScaleSharedControllerElement=EO;exports.WebSerialScaleStatus=YA;exports.WrapperCenterElement=_O;exports.WrapperChartElement=XO;exports.WrapperContentElement=JO;exports.WrapperElement=ZO;exports.animationPresets=V3;exports.arrayUtil=b8;exports.clearSidebarRouteByPermission=p5;exports.delayUtil=x8;exports.fileUtil=T8;exports.findSidebarRouteFromPathName=g5;exports.formatUnreadBadge=A5;exports.genSidebarTabsFromRoute=f5;exports.generateId=Rn;exports.getActionBarSx=Q0;exports.getNotificationFingerprint=t5;exports.getNotificationIdentityKeys=sr;exports.getNotificationModule=xc;exports.getNotificationModuleIcon=n5;exports.getNotificationNormalizedId=e5;exports.getNotificationRealtimeSWRKey=c5;exports.getPickerSx=j0;exports.getPopperProps=L0;exports.getRelativeTimeText=qc;exports.getStyleCell=X4;exports.getStyleRow=J4;exports.getSxArray=K4;exports.hasSelectedSidebarChild=Tc;exports.highlightText=sT;exports.highlightYellow=ca;exports.isInternalUrl=yc;exports.isNotificationCacheSWRKey=Ck;exports.isNotificationListSWRKey=Ec;exports.isNotificationUnreadCountSWRKey=Ic;exports.mapRealtimePayloadToNotification=o5;exports.mergeSidebarLeftSx=F2;exports.mergeSxProps=Fo;exports.normalizeNotificationPriority=vc;exports.notificationBeApi=Q5;exports.numberUtil=k8;exports.objectUtil=d8;exports.otherUtil=L8;exports.parseDateMacroToTimestamp=j4;exports.parseWebSerialScaleReading=H4;exports.productManagementApi=D5;exports.providerUntil=f7;exports.stringUtil=s8;exports.tableArgTypes=GO;exports.timeUtil=u7;exports.useNotificationContext=t2;exports.useNotificationUnreadCount=bk;exports.useNotifications=Dc;exports.useSharedWebSerialScale=ss;exports.useTabsSelected=L3;exports.useWebSerialScale=gc;exports.useWebSerialScaleTargetRegistration=SO;
package/dist/index.esm.js CHANGED
@@ -49875,7 +49875,7 @@ const dT = (A, e) => ((!ts || T1 !== A) && (ts = new is.HubConnectionBuilder().w
49875
49875
  )
49876
49876
  }
49877
49877
  ),
49878
- /* @__PURE__ */ u(G1, { anchor: "right", open: d, onClose: () => p(!1), children: /* @__PURE__ */ F(lA, { sx: { height: "100vh", width: 520, overflow: "hidden" }, children: [
49878
+ /* @__PURE__ */ u(G1, { anchor: "right", open: d, onClose: () => p(!1), children: /* @__PURE__ */ F(lA, { sx: { height: "100vh", width: 600, overflow: "hidden" }, children: [
49879
49879
  /* @__PURE__ */ F(
49880
49880
  lA,
49881
49881
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sevago-library",
3
- "version": "1.6.44",
3
+ "version": "1.6.45",
4
4
  "description": "Sevago SSO Frontend Library - A comprehensive SSO solution with React components",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",