@simpoobusiness/sdk 2.0.23 → 2.0.25

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.
@@ -1,2 +1,4 @@
1
1
  import React from "react";
2
- export declare const InventoryTable: React.FC;
2
+ export declare const InventoryTable: React.FC<{
3
+ showStats?: boolean;
4
+ }>;
package/dist/embed.d.ts CHANGED
@@ -15,4 +15,4 @@ export declare function init(config: {
15
15
  * @example
16
16
  * SimpooSDK.renderWidget("inventory", "#inventory-widget");
17
17
  */
18
- export declare function renderWidget(widgetName: string, selector: string): void;
18
+ export declare function renderWidget(widgetName: string, selector: string, props?: Record<string, any>): void;
@@ -220,5 +220,5 @@ to {
220
220
  animation: ${wE} 2.5s cubic-bezier(0.35, 0.04, 0.63, 0.95) infinite;
221
221
  `,fE.svg`
222
222
  transform-origin: 50% 65%;
223
- `;var kE=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"});T.forwardRef((e,t)=>m.jsx(aa.span,{...e,ref:t,style:{...kE,...e.style}})).displayName="VisuallyHidden";var _E=[" ","Enter","ArrowUp","ArrowDown"],EE=[" ","Enter"],RE="Select",[NE,jE,PE]=sa(RE),[OE,ME]=qo(RE,[PE,js]),TE=js(),[DE,AE]=OE(RE),[FE,LE]=OE(RE),IE=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:a,value:i,defaultValue:s,onValueChange:l,dir:u,name:c,autoComplete:d,disabled:f,required:p,form:h}=e,g=TE(t),[y,v]=T.useState(null),[b,w]=T.useState(null),[x,C]=T.useState(!1),S=ua(u),[k,_]=Zo({prop:r,defaultProp:o??!1,onChange:a,caller:RE}),[E,R]=Zo({prop:i,defaultProp:s,onChange:l,caller:RE}),N=T.useRef(null),j=!y||(h||!!y.closest("form")),[P,O]=T.useState(new Set),M=Array.from(P).map(e=>e.props.value).join(";");return m.jsx(Ws,{...g,children:m.jsxs(DE,{required:p,scope:t,trigger:y,onTriggerChange:v,valueNode:b,onValueNodeChange:w,valueNodeHasChildren:x,onValueNodeHasChildrenChange:C,contentId:Aa(),value:E,onValueChange:R,open:k,onOpenChange:_,dir:S,triggerPointerDownPosRef:N,disabled:f,children:[m.jsx(NE.Provider,{scope:t,children:m.jsx(FE,{scope:e.__scopeSelect,onNativeOptionAdd:T.useCallback(e=>{O(t=>new Set(t).add(e))},[]),onNativeOptionRemove:T.useCallback(e=>{O(t=>{const n=new Set(t);return n.delete(e),n})},[]),children:n})}),j?m.jsxs(kR,{"aria-hidden":!0,required:p,tabIndex:-1,name:c,autoComplete:d,value:E,onChange:e=>R(e.target.value),disabled:f,form:h,children:[void 0===E?m.jsx("option",{value:""}):null,Array.from(P)]},M):null]})})};IE.displayName=RE;var zE="SelectTrigger",$E=T.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,a=TE(n),i=AE(zE,n),s=i.disabled||r,l=Yo(t,i.onTriggerChange),u=jE(n),c=T.useRef("touch"),[d,f,p]=ER(e=>{const t=u().filter(e=>!e.disabled),n=t.find(e=>e.value===i.value),r=RR(t,e,n);void 0!==r&&i.onValueChange(r.value)}),h=e=>{s||(i.onOpenChange(!0),p()),e&&(i.triggerPointerDownPosRef.current={x:Math.round(e.pageX),y:Math.round(e.pageY)})};return m.jsx(Ys,{asChild:!0,...a,children:m.jsx(aa.button,{type:"button",role:"combobox","aria-controls":i.contentId,"aria-expanded":i.open,"aria-required":i.required,"aria-autocomplete":"none",dir:i.dir,"data-state":i.open?"open":"closed",disabled:s,"data-disabled":s?"":void 0,"data-placeholder":_R(i.value)?"":void 0,...o,ref:l,onClick:Bo(o.onClick,e=>{e.currentTarget.focus(),"mouse"!==c.current&&h(e)}),onPointerDown:Bo(o.onPointerDown,e=>{c.current=e.pointerType;const t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),0===e.button&&!1===e.ctrlKey&&"mouse"===e.pointerType&&(h(e),e.preventDefault())}),onKeyDown:Bo(o.onKeyDown,e=>{const t=""!==d.current;e.ctrlKey||e.altKey||e.metaKey||1!==e.key.length||f(e.key),t&&" "===e.key||_E.includes(e.key)&&(h(),e.preventDefault())})})})});$E.displayName=zE;var HE="SelectValue",VE=T.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:a,placeholder:i="",...s}=e,l=AE(HE,n),{onValueNodeHasChildrenChange:u}=l,c=void 0!==a,d=Yo(t,l.onValueNodeChange);return Ko(()=>{u(c)},[u,c]),m.jsx(aa.span,{...s,ref:d,style:{pointerEvents:"none"},children:_R(l.value)?m.jsx(m.Fragment,{children:i}):a})});VE.displayName=HE;var BE=T.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return m.jsx(aa.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});BE.displayName="SelectIcon";var UE=e=>m.jsx(Ks,{asChild:!0,...e});UE.displayName="SelectPortal";var WE="SelectContent",YE=T.forwardRef((e,t)=>{const n=AE(WE,e.__scopeSelect),[r,o]=T.useState();if(Ko(()=>{o(new DocumentFragment)},[]),!n.open){const t=r;return t?Xo.createPortal(m.jsx(GE,{scope:e.__scopeSelect,children:m.jsx(NE.Slot,{scope:e.__scopeSelect,children:m.jsx("div",{children:e.children})})}),t):null}return m.jsx(ZE,{...e,ref:t})});YE.displayName=WE;var qE=10,[GE,KE]=OE(WE),QE=ea("SelectContent.RemoveScroll"),ZE=T.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:a,onPointerDownOutside:i,side:s,sideOffset:l,align:u,alignOffset:c,arrowPadding:d,collisionBoundary:f,collisionPadding:p,sticky:h,hideWhenDetached:g,avoidCollisions:y,...v}=e,b=AE(WE,n),[w,x]=T.useState(null),[C,S]=T.useState(null),k=Yo(t,e=>x(e)),[_,E]=T.useState(null),[R,N]=T.useState(null),j=jE(n),[P,O]=T.useState(!1),M=T.useRef(!1);T.useEffect(()=>{if(w)return Cl(w)},[w]),xa();const D=T.useCallback(e=>{const[t,...n]=j().map(e=>e.ref.current),[r]=n.slice(-1),o=document.activeElement;for(const n of e){if(n===o)return;if(n?.scrollIntoView({block:"nearest"}),n===t&&C&&(C.scrollTop=0),n===r&&C&&(C.scrollTop=C.scrollHeight),n?.focus(),document.activeElement!==o)return}},[j,C]),A=T.useCallback(()=>D([_,w]),[D,_,w]);T.useEffect(()=>{P&&A()},[P,A]);const{onOpenChange:F,triggerPointerDownPosRef:L}=b;T.useEffect(()=>{if(w){let e={x:0,y:0};const t=t=>{e={x:Math.abs(Math.round(t.pageX)-(L.current?.x??0)),y:Math.abs(Math.round(t.pageY)-(L.current?.y??0))}},n=n=>{e.x<=10&&e.y<=10?n.preventDefault():w.contains(n.target)||F(!1),document.removeEventListener("pointermove",t),L.current=null};return null!==L.current&&(document.addEventListener("pointermove",t),document.addEventListener("pointerup",n,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",t),document.removeEventListener("pointerup",n,{capture:!0})}}},[w,F,L]),T.useEffect(()=>{const e=()=>F(!1);return window.addEventListener("blur",e),window.addEventListener("resize",e),()=>{window.removeEventListener("blur",e),window.removeEventListener("resize",e)}},[F]);const[I,z]=ER(e=>{const t=j().filter(e=>!e.disabled),n=t.find(e=>e.ref.current===document.activeElement),r=RR(t,e,n);r&&setTimeout(()=>r.ref.current.focus())}),$=T.useCallback((e,t,n)=>{const r=!M.current&&!n;(void 0!==b.value&&b.value===t||r)&&(E(e),r&&(M.current=!0))},[b.value]),H=T.useCallback(()=>w?.focus(),[w]),V=T.useCallback((e,t,n)=>{const r=!M.current&&!n;(void 0!==b.value&&b.value===t||r)&&N(e)},[b.value]),B="popper"===r?JE:XE,U=B===JE?{side:s,sideOffset:l,align:u,alignOffset:c,arrowPadding:d,collisionBoundary:f,collisionPadding:p,sticky:h,hideWhenDetached:g,avoidCollisions:y}:{};return m.jsx(GE,{scope:n,content:w,viewport:C,onViewportChange:S,itemRefCallback:$,selectedItem:_,onItemLeave:H,itemTextRefCallback:V,focusSelectedItem:A,selectedItemText:R,position:r,isPositioned:P,searchRef:I,children:m.jsx(cu,{as:QE,allowPinchZoom:!0,children:m.jsx(Ea,{asChild:!0,trapped:b.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:Bo(o,e=>{b.trigger?.focus({preventScroll:!0}),e.preventDefault()}),children:m.jsx(ga,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:i,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>b.onOpenChange(!1),children:m.jsx(B,{role:"listbox",id:b.contentId,"data-state":b.open?"open":"closed",dir:b.dir,onContextMenu:e=>e.preventDefault(),...v,...U,onPlaced:()=>O(!0),ref:k,style:{display:"flex",flexDirection:"column",outline:"none",...v.style},onKeyDown:Bo(v.onKeyDown,e=>{const t=e.ctrlKey||e.altKey||e.metaKey;if("Tab"===e.key&&e.preventDefault(),t||1!==e.key.length||z(e.key),["ArrowUp","ArrowDown","Home","End"].includes(e.key)){let t=j().filter(e=>!e.disabled).map(e=>e.ref.current);if(["ArrowUp","End"].includes(e.key)&&(t=t.slice().reverse()),["ArrowUp","ArrowDown"].includes(e.key)){const n=e.target,r=t.indexOf(n);t=t.slice(r+1)}setTimeout(()=>D(t)),e.preventDefault()}})})})})})})});ZE.displayName="SelectContentImpl";var XE=T.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,a=AE(WE,n),i=KE(WE,n),[s,l]=T.useState(null),[u,c]=T.useState(null),d=Yo(t,e=>c(e)),f=jE(n),p=T.useRef(!1),h=T.useRef(!0),{viewport:g,selectedItem:y,selectedItemText:v,focusSelectedItem:b}=i,w=T.useCallback(()=>{if(a.trigger&&a.valueNode&&s&&u&&g&&y&&v){const e=a.trigger.getBoundingClientRect(),t=u.getBoundingClientRect(),n=a.valueNode.getBoundingClientRect(),o=v.getBoundingClientRect();if("rtl"!==a.dir){const r=o.left-t.left,a=n.left-r,i=e.left-a,l=e.width+i,u=Math.max(l,t.width),c=window.innerWidth-qE,d=SE(a,[qE,Math.max(qE,c-u)]);s.style.minWidth=l+"px",s.style.left=d+"px"}else{const r=t.right-o.right,a=window.innerWidth-n.right-r,i=window.innerWidth-e.right-a,l=e.width+i,u=Math.max(l,t.width),c=window.innerWidth-qE,d=SE(a,[qE,Math.max(qE,c-u)]);s.style.minWidth=l+"px",s.style.right=d+"px"}const i=f(),l=window.innerHeight-2*qE,c=g.scrollHeight,d=window.getComputedStyle(u),h=parseInt(d.borderTopWidth,10),m=parseInt(d.paddingTop,10),b=parseInt(d.borderBottomWidth,10),w=h+m+c+parseInt(d.paddingBottom,10)+b,x=Math.min(5*y.offsetHeight,w),C=window.getComputedStyle(g),S=parseInt(C.paddingTop,10),k=parseInt(C.paddingBottom,10),_=e.top+e.height/2-qE,E=l-_,R=y.offsetHeight/2,N=h+m+(y.offsetTop+R),j=w-N;if(N<=_){const e=i.length>0&&y===i[i.length-1].ref.current;s.style.bottom="0px";const t=u.clientHeight-g.offsetTop-g.offsetHeight,n=N+Math.max(E,R+(e?k:0)+t+b);s.style.height=n+"px"}else{const e=i.length>0&&y===i[0].ref.current;s.style.top="0px";const t=Math.max(_,h+g.offsetTop+(e?S:0)+R)+j;s.style.height=t+"px",g.scrollTop=N-_+g.offsetTop}s.style.margin=`${qE}px 0`,s.style.minHeight=x+"px",s.style.maxHeight=l+"px",r?.(),requestAnimationFrame(()=>p.current=!0)}},[f,a.trigger,a.valueNode,s,u,g,y,v,a.dir,r]);Ko(()=>w(),[w]);const[x,C]=T.useState();Ko(()=>{u&&C(window.getComputedStyle(u).zIndex)},[u]);const S=T.useCallback(e=>{e&&!0===h.current&&(w(),b?.(),h.current=!1)},[w,b]);return m.jsx(eR,{scope:n,contentWrapper:s,shouldExpandOnScrollRef:p,onScrollButtonChange:S,children:m.jsx("div",{ref:l,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:x},children:m.jsx(aa.div,{...o,ref:d,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});XE.displayName="SelectItemAlignedPosition";var JE=T.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=qE,...a}=e,i=TE(n);return m.jsx(qs,{...i,...a,ref:t,align:r,collisionPadding:o,style:{boxSizing:"border-box",...a.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});JE.displayName="SelectPopperPosition";var[eR,tR]=OE(WE,{}),nR="SelectViewport",rR=T.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,a=KE(nR,n),i=tR(nR,n),s=Yo(t,a.onViewportChange),l=T.useRef(0);return m.jsxs(m.Fragment,{children:[m.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:r}),m.jsx(NE.Slot,{scope:n,children:m.jsx(aa.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:s,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:Bo(o.onScroll,e=>{const t=e.currentTarget,{contentWrapper:n,shouldExpandOnScrollRef:r}=i;if(r?.current&&n){const e=Math.abs(l.current-t.scrollTop);if(e>0){const r=window.innerHeight-2*qE,o=parseFloat(n.style.minHeight),a=parseFloat(n.style.height),i=Math.max(o,a);if(i<r){const o=i+e,a=Math.min(r,o),s=o-a;n.style.height=a+"px","0px"===n.style.bottom&&(t.scrollTop=s>0?s:0,n.style.justifyContent="flex-end")}}}l.current=t.scrollTop})})})]})});rR.displayName=nR;var oR="SelectGroup",[aR,iR]=OE(oR);T.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Aa();return m.jsx(aR,{scope:n,id:o,children:m.jsx(aa.div,{role:"group","aria-labelledby":o,...r,ref:t})})}).displayName=oR;var sR="SelectLabel",lR=T.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=iR(sR,n);return m.jsx(aa.div,{id:o.id,...r,ref:t})});lR.displayName=sR;var uR="SelectItem",[cR,dR]=OE(uR),fR=T.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:a,...i}=e,s=AE(uR,n),l=KE(uR,n),u=s.value===r,[c,d]=T.useState(a??""),[f,p]=T.useState(!1),h=Yo(t,e=>l.itemRefCallback?.(e,r,o)),g=Aa(),y=T.useRef("touch"),v=()=>{o||(s.onValueChange(r),s.onOpenChange(!1))};if(""===r)throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return m.jsx(cR,{scope:n,value:r,disabled:o,textId:g,isSelected:u,onItemTextChange:T.useCallback(e=>{d(t=>t||(e?.textContent??"").trim())},[]),children:m.jsx(NE.ItemSlot,{scope:n,value:r,disabled:o,textValue:c,children:m.jsx(aa.div,{role:"option","aria-labelledby":g,"data-highlighted":f?"":void 0,"aria-selected":u&&f,"data-state":u?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...i,ref:h,onFocus:Bo(i.onFocus,()=>p(!0)),onBlur:Bo(i.onBlur,()=>p(!1)),onClick:Bo(i.onClick,()=>{"mouse"!==y.current&&v()}),onPointerUp:Bo(i.onPointerUp,()=>{"mouse"===y.current&&v()}),onPointerDown:Bo(i.onPointerDown,e=>{y.current=e.pointerType}),onPointerMove:Bo(i.onPointerMove,e=>{y.current=e.pointerType,o?l.onItemLeave?.():"mouse"===y.current&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Bo(i.onPointerLeave,e=>{e.currentTarget===document.activeElement&&l.onItemLeave?.()}),onKeyDown:Bo(i.onKeyDown,e=>{""!==l.searchRef?.current&&" "===e.key||(EE.includes(e.key)&&v()," "===e.key&&e.preventDefault())})})})})});fR.displayName=uR;var pR="SelectItemText",hR=T.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...a}=e,i=AE(pR,n),s=KE(pR,n),l=dR(pR,n),u=LE(pR,n),[c,d]=T.useState(null),f=Yo(t,e=>d(e),l.onItemTextChange,e=>s.itemTextRefCallback?.(e,l.value,l.disabled)),p=c?.textContent,h=T.useMemo(()=>m.jsx("option",{value:l.value,disabled:l.disabled,children:p},l.value),[l.disabled,l.value,p]),{onNativeOptionAdd:g,onNativeOptionRemove:y}=u;return Ko(()=>(g(h),()=>y(h)),[g,y,h]),m.jsxs(m.Fragment,{children:[m.jsx(aa.span,{id:l.textId,...a,ref:f}),l.isSelected&&i.valueNode&&!i.valueNodeHasChildren?Xo.createPortal(a.children,i.valueNode):null]})});hR.displayName=pR;var mR="SelectItemIndicator",gR=T.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return dR(mR,n).isSelected?m.jsx(aa.span,{"aria-hidden":!0,...r,ref:t}):null});gR.displayName=mR;var yR="SelectScrollUpButton",vR=T.forwardRef((e,t)=>{const n=KE(yR,e.__scopeSelect),r=tR(yR,e.__scopeSelect),[o,a]=T.useState(!1),i=Yo(t,r.onScrollButtonChange);return Ko(()=>{if(n.viewport&&n.isPositioned){let e=function(){const e=t.scrollTop>0;a(e)};const t=n.viewport;return e(),t.addEventListener("scroll",e),()=>t.removeEventListener("scroll",e)}},[n.viewport,n.isPositioned]),o?m.jsx(xR,{...e,ref:i,onAutoScroll:()=>{const{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop=e.scrollTop-t.offsetHeight)}}):null});vR.displayName=yR;var bR="SelectScrollDownButton",wR=T.forwardRef((e,t)=>{const n=KE(bR,e.__scopeSelect),r=tR(bR,e.__scopeSelect),[o,a]=T.useState(!1),i=Yo(t,r.onScrollButtonChange);return Ko(()=>{if(n.viewport&&n.isPositioned){let e=function(){const e=t.scrollHeight-t.clientHeight,n=Math.ceil(t.scrollTop)<e;a(n)};const t=n.viewport;return e(),t.addEventListener("scroll",e),()=>t.removeEventListener("scroll",e)}},[n.viewport,n.isPositioned]),o?m.jsx(xR,{...e,ref:i,onAutoScroll:()=>{const{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop=e.scrollTop+t.offsetHeight)}}):null});wR.displayName=bR;var xR=T.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,a=KE("SelectScrollButton",n),i=T.useRef(null),s=jE(n),l=T.useCallback(()=>{null!==i.current&&(window.clearInterval(i.current),i.current=null)},[]);return T.useEffect(()=>()=>l(),[l]),Ko(()=>{const e=s().find(e=>e.ref.current===document.activeElement);e?.ref.current?.scrollIntoView({block:"nearest"})},[s]),m.jsx(aa.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:Bo(o.onPointerDown,()=>{null===i.current&&(i.current=window.setInterval(r,50))}),onPointerMove:Bo(o.onPointerMove,()=>{a.onItemLeave?.(),null===i.current&&(i.current=window.setInterval(r,50))}),onPointerLeave:Bo(o.onPointerLeave,()=>{l()})})}),CR=T.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return m.jsx(aa.div,{"aria-hidden":!0,...r,ref:t})});CR.displayName="SelectSeparator";var SR="SelectArrow";T.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=TE(n),a=AE(SR,n),i=KE(SR,n);return a.open&&"popper"===i.position?m.jsx(Gs,{...o,...r,ref:t}):null}).displayName=SR;var kR=T.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=T.useRef(null),a=Yo(r,o),i=function(e){const t=T.useRef({value:e,previous:e});return T.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}(t);return T.useEffect(()=>{const e=o.current;if(!e)return;const n=window.HTMLSelectElement.prototype,r=Object.getOwnPropertyDescriptor(n,"value").set;if(i!==t&&r){const n=new Event("change",{bubbles:!0});r.call(e,t),e.dispatchEvent(n)}},[i,t]),m.jsx(aa.select,{...n,style:{...kE,...n.style},ref:a,defaultValue:t})});function _R(e){return""===e||void 0===e}function ER(e){const t=ca(e),n=T.useRef(""),r=T.useRef(0),o=T.useCallback(e=>{const o=n.current+e;t(o),function e(t){n.current=t,window.clearTimeout(r.current),""!==t&&(r.current=window.setTimeout(()=>e(""),1e3))}(o)},[t]),a=T.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return T.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,a]}function RR(e,t,n){const r=t.length>1&&Array.from(t).every(e=>e===t[0]),o=r?t[0]:t,a=n?e.indexOf(n):-1;let i=(s=e,l=Math.max(a,0),s.map((e,t)=>s[(l+t)%s.length]));var s,l;1===o.length&&(i=i.filter(e=>e!==n));const u=i.find(e=>e.textValue.toLowerCase().startsWith(o.toLowerCase()));return u!==n?u:void 0}kR.displayName="SelectBubbleInput";var NR=$E,jR=BE,PR=UE,OR=YE,MR=rR,TR=lR,DR=fR,AR=hR,FR=gR,LR=vR,IR=wR,zR=CR;const $R=IE,HR=VE,VR=T.forwardRef(({className:e,children:t,...n},r)=>m.jsxs(NR,{ref:r,className:Ao("flex h-10 w-full items-center hover:border-[#BFD7FE] justify-between rounded-md border focus:border-primary border-neutral-200 bg-white px-3 py-2 text-sm ring-offset-white placeholder:text-neutral-500 focus:outline-none disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1 ",e),...n,children:[t,m.jsx(jR,{asChild:!0,children:m.jsx(yd,{className:"h-4 w-4 opacity-50"})})]}));VR.displayName=NR.displayName;const BR=T.forwardRef(({className:e,...t},n)=>m.jsx(LR,{ref:n,className:Ao("flex cursor-default items-center justify-center py-1",e),...t,children:m.jsx(bd,{className:"h-4 w-4"})}));BR.displayName=LR.displayName;const UR=T.forwardRef(({className:e,...t},n)=>m.jsx(IR,{ref:n,className:Ao("flex cursor-default items-center justify-center py-1",e),...t,children:m.jsx(yd,{className:"h-4 w-4"})}));UR.displayName=IR.displayName;const WR=T.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>m.jsx(PR,{children:m.jsxs(OR,{ref:o,className:Ao("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border border-neutral-200 bg-white text-neutral-950 shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 dark:border-neutral-800 dark:bg-neutral-950 dark:text-neutral-50","popper"===n&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,...r,children:[m.jsx(BR,{}),m.jsx(MR,{className:Ao("p-1","popper"===n&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),m.jsx(UR,{})]})}));WR.displayName=OR.displayName;T.forwardRef(({className:e,...t},n)=>m.jsx(TR,{ref:n,className:Ao("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t})).displayName=TR.displayName;const YR=T.forwardRef(({className:e,children:t,...n},r)=>m.jsxs(DR,{ref:r,className:Ao("relative flex w-full select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-primary/20 cursor-pointer focus:text-neutral-900 data-[disabled]:pointer-events-none data-[disabled]:opacity-50 dark:focus:bg-neutral-800 dark:focus:text-neutral-50",e),...n,children:[m.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:m.jsx(FR,{children:m.jsx(gd,{className:"h-4 w-4"})})}),m.jsx(AR,{children:t})]}));YR.displayName=DR.displayName;function qR({label:e,addonLabel:t,type:n,placeholder:r,selectPlaceholder:o,error:a,success:i,value:s,defaultValue:l,name:u,id:c,formik:d,onChange:f,inputRef:p,onBlur:h,required:g,disabled:y,loading:v,showError:b,selectOptions:w,disableSearch:x,searchSelectPlaceholder:C,showSelectSearch:S,onSelectValueChange:k,selectValue:_,showOutline:E=!0,cols:R,rows:N,labelClass:j,addonLabelClass:P,optional:O,info:M,addonInfo:D,icon:A,actionIcon:F,actionLabel:L,actionLabelInfo:I,actionLabelAction:z,className:$,textAreaOnChange:H,addOn:V,infoAlignment:B,addonInfoAlignment:U,inputContainerClass:W,showNegative:Y,showPositive:q,...G}){const[K,Q]=T.useState(n),[Z,X]=T.useState(!1),[J,ee]=T.useState(""),te=((e,t)=>{const n=e?.filter(e=>"string"==typeof e.label?e.label?.toLowerCase().includes(t.toLowerCase()):e.value?.toLowerCase().includes(t.toLowerCase())||e?.searchId?.toLowerCase().includes(t.toLowerCase()));return t?n:e})(w??[],J);return m.jsx(m.Fragment,{children:v?m.jsx(Vo,{className:"w-full h-[48px]"}):m.jsx("div",{className:"w-full",children:m.jsxs("div",{className:`flex flex-col ${e&&"gap-2.5"} relative `,children:[m.jsxs("div",{className:"flex justify-between gap-2 flex-wrap",children:[t&&m.jsxs("label",{className:Ao("text-black flex items-center gap-1 first-letter:uppercase text-sm font-medium",P),children:[t," ",g?m.jsx("span",{className:"text-[#E12D39]",children:t&&"*"}):O?m.jsx("span",{className:"text-[#B5B5B5] font-normal",children:"(optional)"}):null,D&&m.jsx(fv,{fieldName:t,align:U,children:m.jsx("p",{className:"font-normal first-letter:uppercase",children:D})})]}),e&&m.jsxs("label",{className:Ao("text-black flex items-center gap-1 first-letter:uppercase text-sm font-medium",j),children:[e," ",g?m.jsx("span",{className:"text-[#E12D39]",children:e&&"*"}):O?m.jsx("span",{className:"text-[#B5B5B5] font-normal",children:"(optional)"}):null,M&&m.jsx(fv,{fieldName:e,align:B,children:m.jsx("p",{className:"font-normal first-letter:uppercase w-full whitespace-pre-wrap",children:M})})]}),L&&m.jsxs("button",{onClick:z,className:"text-primary flex items-center gap-1 first-letter:uppercase text-sm font-bold",children:[F,L,I&&m.jsx(fv,{fieldName:e,children:m.jsx("p",{className:"font-normal first-letter:uppercase",children:I})})]})]}),m.jsxs("div",{className:Ao(`border overflow-hidden rounded-md text-sm border-[#E1E3EA] hover:border-primary_light font-normal text-grey-950 flex gap-2 items-center bg-white px-3 ${"text-area"!==n&&"h-[48px]"} ${(a||b)&&"!border-danger"} ${i&&"!border-success"} ${Z&&E&&"!border-primary"}\n ${A&&"px-2"}\n ${V&&"px-0"}\n `,y?"cursor-not-allowed bg-gray-200":null,w?"px-0":null,W),children:[V&&m.jsx("span",{className:"bg-gray-200 text-[13px] font-semibold text-gray-700 h-full min-w-[38px] flex items-center justify-center shrink-0 rounded-l-[6px] px-2 ",children:V}),A,w&&m.jsxs($R,{onValueChange:k,defaultValue:_,value:_,children:[m.jsx(VR,{disabled:x,className:" min-w-max w-max h-full border-0 border-r rounded-none hover:border-neutral-200 focus:border-neutral-200 bg-[#F9F9F9] hover:border-b-neutral-200 disabled:opacity-100 ",children:m.jsx(HR,{className:" text-sm text-[#5E6278] placeholder:font-medium outline-none",placeholder:o})}),m.jsxs(WR,{className:"bg-white w-full relative",children:[S&&m.jsx("input",{value:J,onChange:e=>{ee(e.target.value.toString())},placeholder:C??"Search...",className:"h-10 border mb-2 text-sm px-4 outline-none w-full border-neutral-200 rounded bg-white sticky top-0 z-20"}),te?.map((e,t)=>m.jsx(YR,{className:"text-sm",value:e.value,children:e.label},e.value))]})]}),"text-area"===n?m.jsx("textarea",{cols:R,rows:N,onFocus:()=>X(!0),onBlur:e=>{X(!1)},placeholder:r,className:Ao(`placeholder:text-[#7E8299] hover:border-primary_light py-2 h-full placeholder:font-medium outline-none w-full rounded ${y?"bg-[#EEEFF2] cursor-not-allowed":null} ${Z&&E&&"!border-primary"} transition-all ease-in-out`,$),...G,value:s,name:u,onChange:H}):m.jsx("input",{onInput:e=>{const t=e.target;"number"===n&&(t.value=t.value.replace(/[^0-9.]/g,""),t.value=t.value.replace(/^\.|(\..*)\./g,"$1"),t.value.length>1&&t.value.startsWith("0")&&"."!==t.value[1]&&(t.value=t.value.replace(/^0+/,"")),""!==t.value&&"0"!==t.value||(t.value="0"))},type:"number"===K?"text":K,placeholder:r,className:Ao("placeholder:text-[#7E8299] h-full placeholder:font-medium outline-none w-full rounded disabled:cursor-not-allowed",w&&"number"===n?"pr-2":null,A||V?"pr-0":null,w&&"number"===n&&t&&"text-right pr-2",$,q&&"0"!==s?.toString().trim()?"text-green-600 font-semibold":"",Y&&s?.toString().trim().startsWith("-")?"text-red-600 font-semibold":""),onFocus:()=>X(!0),onBlur:e=>{d&&h&&d&&h(e),X(!1)},value:s||"",defaultValue:l,onChange:f,id:c,name:u,required:g,disabled:y,ref:p,...G}),"password"===n&&m.jsx("span",{className:"cursor-pointer",onClick:()=>{Q(e=>"password"===e?"text":"password")},children:"password"===K?$y.eyeslash:$y.eye})]}),a&&m.jsx("p",{className:"text-danger text-xs font-normal",children:a})]})})})}function GR({value:e,label:t,placeholder:n,uuid:r,name:o,displayValue:a,valueType:i,item_unit:s}){const{mutate:l,isPending:u}=Ww();J();const[c,d]=T.useState(!1),[f,p]=T.useState({item_uuid:r,[o]:e});wn();const[h,g]=T.useState("");return m.jsxs(ES,{open:c,onOpenChange:d,children:[m.jsx(RS,{className:"flex items-center",children:m.jsx("button",{className:"hover:text-primary duration-150 underline disabled:no-underline disabled:hover:text-inherit",children:h?"selling_price"===o?Uy(+h):Wy(+h)+s:a})}),m.jsxs(NS,{align:"center",className:"shadow-[0_1px_2px_0px_#E4E5E73D,_0_12px_24px_0_#868C981F] space-y-2 bg-white rounded-xl p-3 w-[280px] relative before:absolute before:w-3 before:h-1.5 before:bg-white before:left-1/2 before:-translate-x-1/2 before:rotate-45 data-[side=bottom]:before:top-0 data-[side=top]:before:bottom-0",children:[m.jsx(qR,{type:i,value:f[o],label:t,placeholder:n,onChange:e=>{p(t=>({...t,[o]:e.target.value}))}}),m.jsxs("div",{className:"flex justify-end gap-2.5",children:[m.jsx(CS,{children:m.jsx(xE,{label:"Dismiss",className:"bg-gray-300 text-dark text-sm hover:bg-gray-300/90 font-medium",disabled:u})}),m.jsx(xE,{label:"Update",className:"text-sm font-medium",onClick:()=>{l({url:"/items/update_basic",payload:f},{onSuccess:()=>{g(f[o]),d(!1)},onError:()=>{g("")}})},loading:u})]})]})]})}T.forwardRef(({className:e,...t},n)=>m.jsx(zR,{ref:n,className:Ao("-mx-1 my-1 h-px bg-neutral-100 dark:bg-neutral-800",e),...t})).displayName=zR.displayName;const KR=[{accessorKey:"item_description",header:"item description",cell:({row:e})=>{const t=e.original;return m.jsxs("div",{className:"flex items-center gap-5",children:[m.jsx("div",{className:"w-[50px] h-[50px] rounded-2xl relative bg-gray-100",children:m.jsx("img",{src:t.item_image,alt:"item image",className:"rounded-2xl object-cover w-full h-full",draggable:!1})}),m.jsxs("div",{className:"space-y-1 max-w-[265px]",children:[m.jsx(ZR,{title:t.item_description,item_uuid:t.uuid,item_type_id:t.item_type_id,data:t.fullData}),m.jsxs("p",{className:"text-dark text-xs font-normal flex items-center gap-1",children:[m.jsx("span",{className:"uppercase whitespace-nowrap",children:t.sku}),t.barcode?.length>0?m.jsxs(m.Fragment,{children:[m.jsx("span",{children:"|"}),t.barcode?.[0]?.barcode,t.barcode?.length>1?m.jsxs("span",{className:"rounded bg-[#9747FF1A] px-[5px] flex items-center text-[#7239EA] font-semibold text-[11px] h-[18px]",children:["+",t.barcode?.length-1]}):null]}):null,t.expired?m.jsxs(m.Fragment,{children:[m.jsx("span",{children:"|"}),"Expired",m.jsx("span",{className:"rounded bg-danger_light px-[5px] flex items-center text-danger font-semibold text-[11px] h-[18px]",children:t.expired})]}):null,t.expiring?m.jsxs(m.Fragment,{children:[m.jsx("span",{children:"|"}),"Expiring",m.jsx("span",{className:"rounded bg-warning-light px-[5px] flex items-center text-warning font-semibold text-[11px] h-[18px]",children:t.expiring})]}):null]})]})]})}},{accessorKey:"quantity",header:()=>m.jsx("p",{children:"quantity"}),cell:({row:e})=>{const t=e.original;return m.jsxs(m.Fragment,{children:[m.jsx("div",{className:Ao("flex items-center",t.quantity<=0?"text-danger":Number(t.reorder_level)==t.quantity?"text-orange":null),children:m.jsx(GR,{label:"Edit item quantity",placeholder:"Enter quantity",uuid:t.uuid,name:"item_quantity",displayValue:Wy(t.quantity)+t.unit,value:t.quantity,valueType:"number",item_unit:t.unit})}),t.all_quantity===t.quantity?null:m.jsx("p",{className:"text-gray-700",children:Intl.NumberFormat().format(t.all_quantity??0)+t.unit})]})}},{accessorKey:"type",cell:({row:e})=>{const t=e.original;return m.jsx("p",{className:"capitalize",children:t.type})}},{accessorKey:"selling_price",header:"Selling Price (₦)",cell:({row:e})=>{const t=e.original;return m.jsx(GR,{label:"Edit selling price (₦)",placeholder:"Enter selling price",uuid:t.uuid,name:"selling_price",displayValue:Uy(t.selling_price??0),value:t.selling_price??0,valueType:"number"})}},{accessorKey:"categories",header:"categories/Tags",cell:({row:e})=>{const t=e.original;return m.jsxs(m.Fragment,{children:[" ",m.jsxs("div",{className:"flex items-center gap-2 capitalize",children:[t.categories&&t.categories?.length>0?t.categories?.[0]?.name:"...",t.categories.length>1?m.jsx(fv,{align:"center",fieldName:"Categories",trigger:m.jsxs("button",{className:"rounded bg-[#9747FF1A] px-[5px] flex items-center text-[#7239EA] font-semibold text-[11px] h-[18px]",children:["+",t.categories.length-1]}),children:m.jsx("ul",{className:"list-disc pl-4",children:t.categories.map((e,t)=>m.jsx("li",{children:e.name},t))})}):null]}),m.jsxs("div",{className:"text-gray-700 flex items-center gap-2 capitalize",children:[t.tags?.[0],t.tags?.length>1?m.jsx(fv,{align:"center",fieldName:"Tags",trigger:m.jsxs("button",{className:"rounded bg-[#9747FF1A] px-[5px] flex items-center text-[#7239EA] font-semibold text-[11px] h-[18px] border-primary",children:["+",t.tags.length-1]}),children:m.jsx("ul",{className:"list-disc pl-4",children:t.tags.map((e,t)=>m.jsx("li",{children:e},t))})}):null]})]})}},{accessorKey:"status",cell:({row:e})=>{const t=e.getValue("status");return m.jsx(pv,{status:t})}},{id:"actions",header:"actions",cell:({row:e})=>{const t=e.original;return m.jsx(QR,{item_uuid:t.uuid,item_type_id:t.item_type_id,data:t.fullData})}}],QR=({item_uuid:e,item_type_id:t,data:n})=>{const[r,o]=T.useState(null),a=()=>{o(null)},[i,s]=T.useState(!1),[l,u]=T.useState(!1),[c,d]=T.useState(!1),[f,p]=T.useState(!1),[h,g]=T.useState(!1),[y,v]=T.useState(!1),[b,w]=T.useState(!1),x=[{label:"view",icon:$y.eye_outline,action:()=>s(!0)},{label:"delete",icon:$y.trash,action:()=>p(!0)}];return m.jsxs(m.Fragment,{children:[m.jsxs(kd,{children:[m.jsx(_d,{asChild:!0,children:m.jsxs("button",{className:"bg-gray-100 rounded-md h-[30px] w-[90px] flex items-center justify-between p-2.5 font-semibold text-[10px] text-gray-500 hover:border duration-200",children:["Action"," ",m.jsx("svg",{width:"11",height:"6",viewBox:"0 0 11 6",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:m.jsx("path",{d:"M5.50855 5.49304C5.42081 5.49355 5.33383 5.47673 5.25261 5.44356C5.17138 5.41038 5.09751 5.3615 5.03521 5.29971L1.03521 1.29971C0.972726 1.23773 0.92313 1.164 0.889284 1.08276C0.855438 1.00152 0.838013 0.914383 0.838013 0.826375C0.838013 0.738367 0.855438 0.65123 0.889284 0.56999C0.92313 0.488751 0.972726 0.415017 1.03521 0.353041C1.16012 0.228874 1.32909 0.15918 1.50521 0.15918C1.68134 0.15918 1.8503 0.228874 1.97521 0.353041L5.50855 3.88637L9.03521 0.353041C9.16012 0.228874 9.32909 0.15918 9.50521 0.15918C9.68134 0.15918 9.8503 0.228874 9.97521 0.353041C10.0377 0.415017 10.0873 0.488751 10.1211 0.56999C10.155 0.65123 10.1724 0.738367 10.1724 0.826375C10.1724 0.914383 10.155 1.00152 10.1211 1.08276C10.0873 1.164 10.0377 1.23773 9.97521 1.29971L5.97521 5.29971C5.85104 5.42287 5.68344 5.4923 5.50855 5.49304Z",fill:"#202125"})})]})}),m.jsx(Ed,{align:"end",className:"flex flex-col gap-2.5 rounded-xl border-gray-200",children:x.map((e,t)=>m.jsxs(Rd,{className:`capitalize focus:bg-primary_light rounded-md focus:text-primary font-semibold text-gray-700 text-sm cursor-pointer px-[15px] flex items-center gap-[5px] ${t===x.length-1&&"text-danger focus:text-danger"}`,onMouseOver:()=>(e=>{o(e)})(t),onMouseOut:a,onClick:e.action,children:[D.cloneElement(e.icon,{fill:r===t?"#1868DB":"#5E6278"})," ",e.label]},t))})]}),m.jsx(FS,{isOpen:i,onClose:()=>s(!1),itemUUID:e}),m.jsx(CE,{isOpen:f,onClose:()=>p(!1),uuids:[e],single:!0})]})},ZR=({title:e,item_uuid:t,item_type_id:n,data:r})=>{const[o,a]=T.useState(!1),[i,s]=T.useState(!1),[l,u]=T.useState(!1);return m.jsxs(m.Fragment,{children:[m.jsx("button",{className:Ao("text-primary font-bold text-sm first-letter:uppercase truncate max-w-[265px] cursor-pointer",r.expired?"text-danger":""),title:e,onClick:()=>a(!0),children:e}),m.jsx(FS,{isOpen:o,onClose:()=>a(!1),itemUUID:t})]})};var XR,JR={};function eN(){if(XR)return JR;function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e(t)}XR=1,Object.defineProperty(JR,"__esModule",{value:!0}),JR.Collapse=void 0;var t,n=(t=f())&&t.__esModule?t:{default:t};function r(e,t,n){return t&&function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(e.prototype,t),e}function o(e,t){return o=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},o(e,t)}function a(t){var n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}();return function(){var r,o=s(t);if(n){var a=s(this).constructor;r=Reflect.construct(o,arguments,a)}else r=o.apply(this,arguments);return function(t,n){if(n&&("object"===e(n)||"function"==typeof n))return n;if(void 0!==n)throw new TypeError("Derived constructors may only return object or undefined");return i(t)}(this,r)}}function i(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function s(e){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},s(e)}function l(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var u=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&o(e,t)}(s,e);var t=a(s);function s(e){var n;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,s),l(i(n=t.call(this,e)),"timeout",void 0),l(i(n),"container",void 0),l(i(n),"content",void 0),l(i(n),"onResize",function(){if(clearTimeout(n.timeout),n.container&&n.content){var e=n.props,t=e.isOpened,r=e.checkTimeout,o=Math.floor(n.container.clientHeight),a=Math.floor(n.content.clientHeight),i=t&&Math.abs(a-o)<=1,s=!t&&Math.abs(o)<=1;i||s?n.onRest({isFullyOpened:i,isFullyClosed:s,isOpened:t,containerHeight:o,contentHeight:a}):(n.onWork({isFullyOpened:i,isFullyClosed:s,isOpened:t,containerHeight:o,contentHeight:a}),n.timeout=setTimeout(function(){return n.onResize()},r))}}),l(i(n),"onRest",function(e){var t=e.isFullyOpened,r=e.isFullyClosed,o=e.isOpened,a=e.containerHeight,i=e.contentHeight;if(n.container&&n.content){var s=o&&n.container.style.height==="".concat(i,"px"),l=!o&&"0px"===n.container.style.height;if(s||l){n.container.style.overflow=o?"initial":"hidden",n.container.style.height=o?"auto":"0px";var u=n.props.onRest;u&&u({isFullyOpened:t,isFullyClosed:r,isOpened:o,containerHeight:a,contentHeight:i})}}}),l(i(n),"onWork",function(e){var t=e.isFullyOpened,r=e.isFullyClosed,o=e.isOpened,a=e.containerHeight,i=e.contentHeight;if(n.container&&n.content){var s=o&&n.container.style.height==="".concat(i,"px"),l=!o&&"0px"===n.container.style.height;if(!s&&!l){n.container.style.overflow="hidden",n.container.style.height=o?"".concat(i,"px"):"0px";var u=n.props.onWork;u&&u({isFullyOpened:t,isFullyClosed:r,isOpened:o,containerHeight:a,contentHeight:i})}}}),l(i(n),"onRefContainer",function(e){n.container=e}),l(i(n),"onRefContent",function(e){n.content=e}),e.initialStyle?n.initialStyle=e.initialStyle:n.initialStyle=e.isOpened?{height:"auto",overflow:"initial"}:{height:"0px",overflow:"hidden"},n}return r(s,[{key:"componentDidMount",value:function(){this.onResize()}},{key:"shouldComponentUpdate",value:function(e){var t=this.props,n=t.theme,r=t.isOpened;return t.children!==e.children||r!==e.isOpened||Object.keys(n).some(function(t){return n[t]!==e.theme[t]})}},{key:"getSnapshotBeforeUpdate",value:function(){if(!this.container||!this.content)return null;if("auto"===this.container.style.height){var e=this.content.clientHeight;this.container.style.height="".concat(e,"px")}return null}},{key:"componentDidUpdate",value:function(){this.onResize()}},{key:"componentWillUnmount",value:function(){clearTimeout(this.timeout)}},{key:"render",value:function(){var e=this.props,t=e.theme,r=e.children,o=e.isOpened;return n.default.createElement("div",{ref:this.onRefContainer,className:t.collapse,style:this.initialStyle,"aria-hidden":!o},n.default.createElement("div",{ref:this.onRefContent,className:t.content},r))}}]),s}(n.default.Component);return JR.Collapse=u,l(u,"defaultProps",{theme:{collapse:"ReactCollapse--collapse",content:"ReactCollapse--content"},initialStyle:void 0,onRest:void 0,onWork:void 0,checkTimeout:50}),JR}var tN,nN,rN,oN={};function aN(){if(tN)return oN;function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e(t)}tN=1,Object.defineProperty(oN,"__esModule",{value:!0}),oN.UnmountClosed=void 0;var t,n=(t=f())&&t.__esModule?t:{default:t},r=eN(),o=["isOpened"],a=["isOpened"];function i(){return i=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},i.apply(this,arguments)}function s(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function l(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?s(Object(n),!0).forEach(function(t){g(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):s(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function u(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}function c(e,t,n){return t&&function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(e.prototype,t),e}function d(e,t){return d=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},d(e,t)}function p(t){var n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}();return function(){var r,o=m(t);if(n){var a=m(this).constructor;r=Reflect.construct(o,arguments,a)}else r=o.apply(this,arguments);return function(t,n){if(n&&("object"===e(n)||"function"==typeof n))return n;if(void 0!==n)throw new TypeError("Derived constructors may only return object or undefined");return h(t)}(this,r)}}function h(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function m(e){return m=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},m(e)}function g(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var y=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&d(e,t)}(s,e);var t=p(s);function s(e){var n;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,s),g(h(n=t.call(this,e)),"onWork",function(e){var t=e.isOpened,r=u(e,o);n.setState({isResting:!1,isOpened:t});var a=n.props.onWork;a&&a(l({isOpened:t},r))}),g(h(n),"onRest",function(e){var t=e.isOpened,r=u(e,a);n.setState({isResting:!0,isOpened:t,isInitialRender:!1});var o=n.props.onRest;o&&o(l({isOpened:t},r))}),g(h(n),"getInitialStyle",function(){var e=n.state,t=e.isOpened;return e.isInitialRender&&t?{height:"auto",overflow:"initial"}:{height:"0px",overflow:"hidden"}}),n.state={isResting:!0,isOpened:e.isOpened,isInitialRender:!0},n}return c(s,[{key:"componentDidUpdate",value:function(e){var t=this.props.isOpened;e.isOpened!==t&&this.setState({isResting:!1,isOpened:t,isInitialRender:!1})}},{key:"render",value:function(){var e=this.state,t=e.isResting,o=e.isOpened;return t&&!o?null:n.default.createElement(r.Collapse,i({},this.props,{initialStyle:this.getInitialStyle(),onWork:this.onWork,onRest:this.onRest}))}}]),s}(n.default.PureComponent);return oN.UnmountClosed=y,g(y,"defaultProps",{onWork:void 0,onRest:void 0}),oN}var iN=function(){if(rN)return nN;rN=1;var e=eN().Collapse,t=aN().UnmountClosed;return nN=t,t.Collapse=e,t.UnmountClosed=t,nN}();function sN({loading:e,data:t,meta:n}){const r=t?.otherscount?.map(e=>{const n=e.name;return{type:n,value:t?.result_array?.[n]?.total_selling_price??0}}),o=[{type:t?.result_array?.Retail?.pricegroup??t?.default,value:t?.result_array?.Retail?.total_selling_price??0},...r||[]],a=t?.otherscount?.map(e=>{const n=e.name;return{type:n,value:t?.result_array?.[n]?.total_profit??0}}),i=[{type:t?.result_array?.Retail?.pricegroup??t?.default,value:t?.result_array?.Retail?.total_profit??0},...a||[]],[s,l]=T.useState({type:o?.[0].type,value:o?.[0].value}),[u,c]=T.useState({type:i?.[0].type,value:i?.[0].value});D.useEffect(()=>{l({type:o?.[0].type,value:o?.[0].value}),c({type:i?.[0].type,value:i?.[0].value})},[e]);const d=[{label:"Total No. of Unique Item",count:Intl.NumberFormat().format(n?.total??0),desc:`With ${t?.unit_count??0} unit(s)`,icon:m.jsx("div",{className:"shrink-0 rounded-lg bg-[#EFF5FF] w-12 h-12 flex items-center justify-center border border-[#EDEEF1]",children:$y.cube})},{label:"Total Cost Price",count:Uy(t?.result_array?.Retail?.total_cost??0),desc:"Takes into Account FIFO & LIFO ",icon:m.jsx("div",{className:"shrink-0 rounded-lg bg-[#F9DFDD] w-12 h-12 flex items-center justify-center border border-[#EDEEF1]",children:D.cloneElement($y.price_tag,{fill:"#ED7400"})})},{label:"Total Selling Price",count:Uy(s.value),desc:m.jsxs("p",{className:"flex gap-2 items-center flex-wrap",children:["Showing ",s.type," price"," ",m.jsxs(kd,{children:[m.jsx(_d,{asChild:!0,children:m.jsxs("button",{className:"rounded-lg h-8 flex items-center justify-between p-3 font-semibold text-xs text-gray-600 outline-none border border-gray-300 gap-2.5 capitalize bg-[#F9F9F9]",children:["change",m.jsx("span",{className:"rotate-90",children:$y.arrow})]})}),m.jsx(Ed,{align:"start",className:"flex flex-col gap-2.5 rounded-xl border-gray-200 py-2.5 w-[210px]",children:o.map((e,t)=>m.jsx(Rd,{className:Ao("capitalize focus:bg-primary_light rounded-md focus:text-primary font-semibold text-sm cursor-pointer px-[15px] flex items-center gap-[5px] \n \n ",e.type===s.type?"bg-primary_light text-primary":null),onClick:()=>l(t=>({...t,value:e.value,type:e.type})),children:e.type},t))})]})]}),icon:m.jsx("div",{className:"shrink-0 rounded-lg bg-[#D8CDF4] w-12 h-12 flex items-center justify-center border border-[#EDEEF1]",children:D.cloneElement($y.price_tag,{fill:"#9747FF"})})},{label:"Profit to be made",count:Uy(u.value),desc:m.jsxs("p",{className:"flex gap-2 items-center flex-wrap",children:["Showing ",u.type," price"," ",m.jsxs(kd,{children:[m.jsx(_d,{asChild:!0,children:m.jsxs("button",{className:"rounded-lg h-8 flex items-center justify-between p-3 font-semibold text-xs text-gray-600 outline-none border border-gray-300 gap-2.5 capitalize bg-[#F9F9F9]",children:["change",m.jsx("span",{className:"rotate-90",children:$y.arrow})]})}),m.jsx(Ed,{align:"start",className:"flex flex-col gap-2.5 rounded-xl border-gray-200 py-2.5 w-[210px]",children:i.map((e,t)=>m.jsx(Rd,{className:Ao("capitalize focus:bg-primary_light rounded-md focus:text-primary font-semibold text-sm cursor-pointer px-[15px] flex items-center gap-[5px] \n \n ",e.type===u.type?"bg-primary_light text-primary":null),onClick:()=>c(t=>({...t,value:e.value,type:e.type})),children:e.type},t))})]})]}),icon:m.jsx("div",{className:"shrink-0 rounded-lg bg-[#C6E3D2] w-12 h-12 flex items-center justify-center border border-[#EDEEF1]",children:D.cloneElement($y.price_tag,{fill:"#378C5A"})})}],[f,p]=T.useState(!1);return m.jsxs(qx,{className:"bg-[#F6F8FA] p-2.5 flex flex-col",children:[m.jsxs("div",{className:"flex justify-between",children:[m.jsx("h1",{className:"capitalize text-dark font-semibold text-lg",children:"Items overview"}),m.jsxs("button",{className:"rounded-lg h-8 flex items-center justify-between p-3 font-semibold text-xs text-gray-600 outline-none border border-gray-300 gap-2.5 capitalize bg-white",onClick:()=>p(!f),children:[f?"Close":"Open"," ",m.jsx("span",{className:"rotate-90",children:$y.arrow})]})]}),m.jsx(iN.Collapse,{isOpened:f,children:m.jsx("div",{className:"flex flex-wrap gap-2.5 mt-3",children:d.map((t,n)=>m.jsxs("div",{className:Ao("border rounded-xl border-[#E4E7EC] p-4 flex flex-col relative bg-right-bottom bg-no-repeat flex-auto",0===n?"bg-[#E4EEFA] bg-[url('/assets/images/ecstacy1.svg')]":1===n?"bg-[#FAEAE9] bg-[url('/assets/images/ecstacy2.svg')]":2===n?"bg-[#EEE9FA] bg-[url('/assets/images/ecstacy3.svg')]":3===n?"bg-[#EBF5EF] bg-[url('/assets/images/ecstacy4.svg')]":null),children:[m.jsxs("div",{className:"flex justify-between gap-1",children:[m.jsx("h1",{className:"text-dark text-sm font-medium",children:t.label}),m.jsx("div",{className:"shrink-0",children:t.icon})]}),m.jsxs("div",{className:"flex flex-col gap-1",children:[e?m.jsx(Vo,{className:"w-28 h-6 rounded"}):m.jsx("h1",{className:Ao("text-dark font-bold text-[29px] truncate",n===d.length-1&&u.value<0?"text-danger":null),title:t.count,children:t.count}),m.jsx("div",{className:"text-gray-700 text-sm font-medium ",children:t.desc})]})]},n))})})]})}function lN({placeholder:e,className:t,inputClass:n,...r}){return m.jsxs("div",{className:Ao("h-12 border border-gray-300 rounded-md w-[320px] flex",t),children:[m.jsx("span",{className:"bg-gray-200 w-[38px] flex items-center justify-center shrink-0 rounded-l-[6px] ",children:$y.magnifier}),m.jsx("input",{type:"search",placeholder:e,className:"w-full px-3 text-dark text-sm font-medium bg-transparent outline-none rounded-r-[6px]",...r})]})}function uN(e,t){return e===t}function cN(e,t,n){var r=uN,o=T.useRef(e),a=T.useState({})[1],i=function(e,t,n,r){var o=this,a=T.useRef(null),i=T.useRef(0),s=T.useRef(0),l=T.useRef(null),u=T.useRef([]),c=T.useRef(),d=T.useRef(),f=T.useRef(e),p=T.useRef(!0);f.current=e;var h="undefined"!=typeof window,m=!t&&0!==t&&h;if("function"!=typeof e)throw new TypeError("Expected a function");t=+t||0;var g=!!(n=n||{}).leading,y=!("trailing"in n)||!!n.trailing,v="maxWait"in n,b="debounceOnServer"in n&&!!n.debounceOnServer,w=v?Math.max(+n.maxWait||0,t):null;T.useEffect(function(){return p.current=!0,function(){p.current=!1}},[]);var x=T.useMemo(function(){var e=function(e){var t=u.current,n=c.current;return u.current=c.current=null,i.current=e,s.current=s.current||e,d.current=f.current.apply(n,t)},n=function(e,t){m&&cancelAnimationFrame(l.current),l.current=m?requestAnimationFrame(e):setTimeout(e,t)},x=function(e){if(!p.current)return!1;var n=e-a.current;return!a.current||n>=t||n<0||v&&e-i.current>=w},C=function(t){return l.current=null,y&&u.current?e(t):(u.current=c.current=null,d.current)},S=function e(){var r=Date.now();if(g&&s.current===i.current&&k(),x(r))return C(r);if(p.current){var o=t-(r-a.current),l=v?Math.min(o,w-(r-i.current)):o;n(e,l)}},k=function(){r&&r({})},_=function(){if(h||b){var r=Date.now(),s=x(r);if(u.current=[].slice.call(arguments),c.current=o,a.current=r,s){if(!l.current&&p.current)return i.current=a.current,n(S,t),g?e(a.current):d.current;if(v)return n(S,t),e(a.current)}return l.current||n(S,t),d.current}};return _.cancel=function(){l.current&&(m?cancelAnimationFrame(l.current):clearTimeout(l.current)),i.current=0,u.current=a.current=c.current=l.current=null},_.isPending=function(){return!!l.current},_.flush=function(){return l.current?C(Date.now()):d.current},_},[g,v,t,w,y,m,h,b,r]);return x}(T.useCallback(function(e){o.current=e,a({})},[a]),t,n,a),s=T.useRef(e);return r(s.current,e)||(i(e),s.current=e),[o.current,i]}function dN({placeholder:e,searchPlaceholder:t,options:n=[],showMultiSelectValues:r=!0,values:o,onChange:a,className:i,showCheckMark:s=!0,label:l,labelClass:u,required:c,info:d,optional:f,actionLabel:p,actionLabelAction:h,actionLabelInfo:g,removeSelectedValue:y,removeTag:v,loading:b,showCount:w,error:x}){const[C,S]=T.useState(!1),[k,_]=T.useState(0),E=T.useRef(null);T.useEffect(()=>{const e=()=>{E.current&&_(E?.current?.offsetWidth)};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[E]);const R=e=>{const t=o?.includes(e)?o?.filter(t=>t!==e):[...o||[],e];a&&a(t)};T.useEffect(()=>{y&&R(y)},[y]);const[N,j]=T.useState(null),P=e=>{j(t=>t===e?null:e)},O=e=>{for(let t of n){if(t.value===e)return t.label;if(t.subOptions){const n=t.subOptions.find(t=>t.value===e);if(n)return n.label}}return null};return m.jsx("div",{ref:E,children:b?m.jsx(Vo,{className:"w-full h-[48px]"}):m.jsxs("div",{className:Ao("flex flex-col gap-2.5",i),children:[m.jsxs("div",{className:"flex justify-between gap-2 flex-wrap",children:[l&&m.jsxs("label",{className:Ao("text-black flex items-center gap-1 first-letter:uppercase text-sm font-medium",u),children:[l," ",c?m.jsx("span",{className:"text-[#E12D39]",children:l&&"*"}):f?m.jsx("span",{className:"text-[#B5B5B5] font-normal",children:"(optional)"}):null,d&&m.jsx(fv,{fieldName:l,children:m.jsx("p",{className:"font-normal first-letter:uppercase",children:d})})]}),p&&m.jsxs("button",{onClick:h,className:"text-primary flex items-center gap-1 first-letter:uppercase text-sm font-medium",children:[p,g&&m.jsx(fv,{fieldName:l,children:m.jsx("p",{className:"font-normal first-letter:uppercase",children:g})})]})]}),m.jsxs(ES,{modal:!0,open:C,onOpenChange:S,children:[m.jsx(RS,{asChild:!0,children:m.jsxs(PS,{variant:"outline",role:"combobox","aria-expanded":C,className:Ao(`w-full h-[48px] justify-between border focus:border-primary border-neutral-200 bg-white hover:bg-white hover:border-[#BFD7FE] ${x&&"!border-danger"}`,r?"h-auto py-3":null,i),children:[m.jsx("div",{className:"flex gap-2 text-[#5E6278] justify-start first-letter:uppercase flex-wrap",children:o?.length&&r?o.map((e,t)=>m.jsxs("div",{onClick:()=>{v||R(e),P(e)},className:"px-2 py-1 text-black flex items-center justify-between rounded gap-2 border bg-slate-200 text-xs font-medium",children:[m.jsx("span",{className:"flex justify-start text-start flex-wrap gap-2 whitespace-normal",children:O(e)}),m.jsx("span",{className:"",children:m.jsx("svg",{width:"9",height:"9",viewBox:"0 0 9 9",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:m.jsx("path",{d:"M5.44001 4.49978L7.83334 2.12644C7.96064 1.99737 8.03146 1.82301 8.03021 1.64173C8.02896 1.46044 7.95575 1.28708 7.82667 1.15978C7.6976 1.03247 7.52324 0.961657 7.34196 0.962907C7.16067 0.964157 6.98731 1.03737 6.86001 1.16644L4.50001 3.55978L2.14001 1.21311C2.0151 1.08894 1.84613 1.01925 1.67001 1.01925C1.49388 1.01925 1.32492 1.08894 1.20001 1.21311C1.13752 1.27509 1.08793 1.34882 1.05408 1.43006C1.02023 1.5113 1.00281 1.59844 1.00281 1.68644C1.00281 1.77445 1.02023 1.86159 1.05408 1.94283C1.08793 2.02407 1.13752 2.0978 1.20001 2.15978L3.56001 4.49978L1.16667 6.87311C1.03937 7.00218 0.968554 7.17654 0.969804 7.35782C0.971054 7.53911 1.04427 7.71247 1.17334 7.83978C1.30241 7.96708 1.47677 8.0379 1.65805 8.03665C1.83934 8.0354 2.0127 7.96218 2.14001 7.83311L4.50001 5.43978L6.86001 7.78644C6.98492 7.91061 7.15388 7.98031 7.33001 7.98031C7.50613 7.98031 7.6751 7.91061 7.80001 7.78644C7.86249 7.72447 7.91209 7.65073 7.94594 7.56949C7.97978 7.48826 7.99721 7.40112 7.99721 7.31311C7.99721 7.2251 7.97978 7.13797 7.94594 7.05673C7.91209 6.97549 7.86249 6.90175 7.80001 6.83978L5.44001 4.49978Z",fill:"black"})})})]},t)):!r&&w&&o.length>0?`${o.length} ${l} selected`:e??"Select..."}),m.jsx(wd,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),m.jsx(NS,{align:"start",style:{width:k},className:"w-[480px] p-0 bg-white rounded-xl border-gray-200",children:m.jsxs(KC,{children:[m.jsx(QC,{className:"placeholder:text-xs",placeholder:t??"Search..."}),m.jsx(XC,{children:"No result found."}),m.jsx(JC,{children:m.jsx(ZC,{className:"",children:n?.map((e,t)=>m.jsxs("div",{children:[m.jsxs(eS,{value:"string"==typeof e.label?e.label:e.searchId,className:`first-letter:uppercase mb-1 focus:bg-primary_light w-full rounded-md focus:text-primary hover:text-primary font-semibold text-gray-700 text-sm cursor-pointer ${o?.includes(e.value)&&"bg-primary_light text-primary"}`,onSelect:()=>{R(e.value),e?.subOptions&&e?.subOptions?.length>0&&P(e.value)},children:[s&&m.jsx(gd,{className:Ao("mr-2 h-4 w-4",o?.includes(e.value)?"opacity-100":"opacity-0")}),m.jsxs("p",{className:"flex justify-between w-full",children:[e.label,e?.subOptions&&e?.subOptions?.length>0&&m.jsx(yd,{className:"ml-2 h-5 w-5 font-bold shrink-0 opacity-50"})]})]}),N===e.value&&e?.subOptions&&e?.subOptions?.map((e,t)=>m.jsxs(eS,{value:"string"==typeof e.label?e.label:e.searchId,className:`first-letter:uppercase mb-1 focus:bg-primary_light w-full rounded-md focus:text-primary hover:text-primary font-semibold text-gray-700 text-sm cursor-pointer pl-6 ${o?.includes(e.value)&&"bg-primary_light text-primary"}`,onSelect:()=>{R(e.value)},children:[s&&m.jsx(gd,{className:Ao("mr-2 h-4 w-4",o?.includes(e.value)?"opacity-100":"opacity-0")}),e.label]},t))]},t))})})]})})]}),x&&m.jsx("p",{className:"text-danger text-xs font-normal",children:x})]})})}var fN="ScrollArea",[pN,hN]=qo(fN),[mN,gN]=pN(fN),yN=T.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:o,scrollHideDelay:a=600,...i}=e,[s,l]=T.useState(null),[u,c]=T.useState(null),[d,f]=T.useState(null),[p,h]=T.useState(null),[g,y]=T.useState(null),[v,b]=T.useState(0),[w,x]=T.useState(0),[C,S]=T.useState(!1),[k,_]=T.useState(!1),E=Yo(t,e=>l(e)),R=ua(o);return m.jsx(mN,{scope:n,type:r,dir:R,scrollHideDelay:a,scrollArea:s,viewport:u,onViewportChange:c,content:d,onContentChange:f,scrollbarX:p,onScrollbarXChange:h,scrollbarXEnabled:C,onScrollbarXEnabledChange:S,scrollbarY:g,onScrollbarYChange:y,scrollbarYEnabled:k,onScrollbarYEnabledChange:_,onCornerWidthChange:b,onCornerHeightChange:x,children:m.jsx(aa.div,{dir:R,...i,ref:E,style:{position:"relative","--radix-scroll-area-corner-width":v+"px","--radix-scroll-area-corner-height":w+"px",...e.style}})})});yN.displayName=fN;var vN="ScrollAreaViewport",bN=T.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...a}=e,i=gN(vN,n),s=Yo(t,T.useRef(null),i.onViewportChange);return m.jsxs(m.Fragment,{children:[m.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:o}),m.jsx(aa.div,{"data-radix-scroll-area-viewport":"",...a,ref:s,style:{overflowX:i.scrollbarXEnabled?"scroll":"hidden",overflowY:i.scrollbarYEnabled?"scroll":"hidden",...e.style},children:m.jsx("div",{ref:i.onContentChange,style:{minWidth:"100%",display:"table"},children:r})})]})});bN.displayName=vN;var wN="ScrollAreaScrollbar",xN=T.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=gN(wN,e.__scopeScrollArea),{onScrollbarXEnabledChange:a,onScrollbarYEnabledChange:i}=o,s="horizontal"===e.orientation;return T.useEffect(()=>(s?a(!0):i(!0),()=>{s?a(!1):i(!1)}),[s,a,i]),"hover"===o.type?m.jsx(CN,{...r,ref:t,forceMount:n}):"scroll"===o.type?m.jsx(SN,{...r,ref:t,forceMount:n}):"auto"===o.type?m.jsx(kN,{...r,ref:t,forceMount:n}):"always"===o.type?m.jsx(_N,{...r,ref:t}):null});xN.displayName=wN;var CN=T.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=gN(wN,e.__scopeScrollArea),[a,i]=T.useState(!1);return T.useEffect(()=>{const e=o.scrollArea;let t=0;if(e){const n=()=>{window.clearTimeout(t),i(!0)},r=()=>{t=window.setTimeout(()=>i(!1),o.scrollHideDelay)};return e.addEventListener("pointerenter",n),e.addEventListener("pointerleave",r),()=>{window.clearTimeout(t),e.removeEventListener("pointerenter",n),e.removeEventListener("pointerleave",r)}}},[o.scrollArea,o.scrollHideDelay]),m.jsx(Qs,{present:n||a,children:m.jsx(kN,{"data-state":a?"visible":"hidden",...r,ref:t})})}),SN=T.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=gN(wN,e.__scopeScrollArea),a="horizontal"===e.orientation,i=UN(()=>l("SCROLL_END"),100),[s,l]=(u="hidden",c={hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}},T.useReducer((e,t)=>c[e][t]??e,u));var u,c;return T.useEffect(()=>{if("idle"===s){const e=window.setTimeout(()=>l("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(e)}},[s,o.scrollHideDelay,l]),T.useEffect(()=>{const e=o.viewport,t=a?"scrollLeft":"scrollTop";if(e){let n=e[t];const r=()=>{const r=e[t];n!==r&&(l("SCROLL"),i()),n=r};return e.addEventListener("scroll",r),()=>e.removeEventListener("scroll",r)}},[o.viewport,a,l,i]),m.jsx(Qs,{present:n||"hidden"!==s,children:m.jsx(_N,{"data-state":"hidden"===s?"hidden":"visible",...r,ref:t,onPointerEnter:Bo(e.onPointerEnter,()=>l("POINTER_ENTER")),onPointerLeave:Bo(e.onPointerLeave,()=>l("POINTER_LEAVE"))})})}),kN=T.forwardRef((e,t)=>{const n=gN(wN,e.__scopeScrollArea),{forceMount:r,...o}=e,[a,i]=T.useState(!1),s="horizontal"===e.orientation,l=UN(()=>{if(n.viewport){const e=n.viewport.offsetWidth<n.viewport.scrollWidth,t=n.viewport.offsetHeight<n.viewport.scrollHeight;i(s?e:t)}},10);return WN(n.viewport,l),WN(n.content,l),m.jsx(Qs,{present:r||a,children:m.jsx(_N,{"data-state":a?"visible":"hidden",...o,ref:t})})}),_N=T.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=gN(wN,e.__scopeScrollArea),a=T.useRef(null),i=T.useRef(0),[s,l]=T.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),u=IN(s.viewport,s.content),c={...r,sizes:s,onSizesChange:l,hasThumb:Boolean(u>0&&u<1),onThumbChange:e=>a.current=e,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:e=>i.current=e};function d(e,t){return function(e,t,n,r="ltr"){const o=zN(n),a=o/2,i=t||a,s=o-i,l=n.scrollbar.paddingStart+i,u=n.scrollbar.size-n.scrollbar.paddingEnd-s,c=n.content-n.viewport,d="ltr"===r?[0,c]:[-1*c,0];return HN([l,u],d)(e)}(e,i.current,s,t)}return"horizontal"===n?m.jsx(EN,{...c,ref:t,onThumbPositionChange:()=>{if(o.viewport&&a.current){const e=$N(o.viewport.scrollLeft,s,o.dir);a.current.style.transform=`translate3d(${e}px, 0, 0)`}},onWheelScroll:e=>{o.viewport&&(o.viewport.scrollLeft=e)},onDragScroll:e=>{o.viewport&&(o.viewport.scrollLeft=d(e,o.dir))}}):"vertical"===n?m.jsx(RN,{...c,ref:t,onThumbPositionChange:()=>{if(o.viewport&&a.current){const e=$N(o.viewport.scrollTop,s);a.current.style.transform=`translate3d(0, ${e}px, 0)`}},onWheelScroll:e=>{o.viewport&&(o.viewport.scrollTop=e)},onDragScroll:e=>{o.viewport&&(o.viewport.scrollTop=d(e))}}):null}),EN=T.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,a=gN(wN,e.__scopeScrollArea),[i,s]=T.useState(),l=T.useRef(null),u=Yo(t,l,a.onScrollbarXChange);return T.useEffect(()=>{l.current&&s(getComputedStyle(l.current))},[l]),m.jsx(PN,{"data-orientation":"horizontal",...o,ref:u,sizes:n,style:{bottom:0,left:"rtl"===a.dir?"var(--radix-scroll-area-corner-width)":0,right:"ltr"===a.dir?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":zN(n)+"px",...e.style},onThumbPointerDown:t=>e.onThumbPointerDown(t.x),onDragScroll:t=>e.onDragScroll(t.x),onWheelScroll:(t,n)=>{if(a.viewport){const r=a.viewport.scrollLeft+t.deltaX;e.onWheelScroll(r),VN(r,n)&&t.preventDefault()}},onResize:()=>{l.current&&a.viewport&&i&&r({content:a.viewport.scrollWidth,viewport:a.viewport.offsetWidth,scrollbar:{size:l.current.clientWidth,paddingStart:LN(i.paddingLeft),paddingEnd:LN(i.paddingRight)}})}})}),RN=T.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,a=gN(wN,e.__scopeScrollArea),[i,s]=T.useState(),l=T.useRef(null),u=Yo(t,l,a.onScrollbarYChange);return T.useEffect(()=>{l.current&&s(getComputedStyle(l.current))},[l]),m.jsx(PN,{"data-orientation":"vertical",...o,ref:u,sizes:n,style:{top:0,right:"ltr"===a.dir?0:void 0,left:"rtl"===a.dir?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":zN(n)+"px",...e.style},onThumbPointerDown:t=>e.onThumbPointerDown(t.y),onDragScroll:t=>e.onDragScroll(t.y),onWheelScroll:(t,n)=>{if(a.viewport){const r=a.viewport.scrollTop+t.deltaY;e.onWheelScroll(r),VN(r,n)&&t.preventDefault()}},onResize:()=>{l.current&&a.viewport&&i&&r({content:a.viewport.scrollHeight,viewport:a.viewport.offsetHeight,scrollbar:{size:l.current.clientHeight,paddingStart:LN(i.paddingTop),paddingEnd:LN(i.paddingBottom)}})}})}),[NN,jN]=pN(wN),PN=T.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:o,onThumbChange:a,onThumbPointerUp:i,onThumbPointerDown:s,onThumbPositionChange:l,onDragScroll:u,onWheelScroll:c,onResize:d,...f}=e,p=gN(wN,n),[h,g]=T.useState(null),y=Yo(t,e=>g(e)),v=T.useRef(null),b=T.useRef(""),w=p.viewport,x=r.content-r.viewport,C=ca(c),S=ca(l),k=UN(d,10);function _(e){if(v.current){const t=e.clientX-v.current.left,n=e.clientY-v.current.top;u({x:t,y:n})}}return T.useEffect(()=>{const e=e=>{const t=e.target,n=h?.contains(t);n&&C(e,x)};return document.addEventListener("wheel",e,{passive:!1}),()=>document.removeEventListener("wheel",e,{passive:!1})},[w,h,x,C]),T.useEffect(S,[r,S]),WN(h,k),WN(p.content,k),m.jsx(NN,{scope:n,scrollbar:h,hasThumb:o,onThumbChange:ca(a),onThumbPointerUp:ca(i),onThumbPositionChange:S,onThumbPointerDown:ca(s),children:m.jsx(aa.div,{...f,ref:y,style:{position:"absolute",...f.style},onPointerDown:Bo(e.onPointerDown,e=>{if(0===e.button){e.target.setPointerCapture(e.pointerId),v.current=h.getBoundingClientRect(),b.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",p.viewport&&(p.viewport.style.scrollBehavior="auto"),_(e)}}),onPointerMove:Bo(e.onPointerMove,_),onPointerUp:Bo(e.onPointerUp,e=>{const t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),document.body.style.webkitUserSelect=b.current,p.viewport&&(p.viewport.style.scrollBehavior=""),v.current=null})})})}),ON="ScrollAreaThumb",MN=T.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=jN(ON,e.__scopeScrollArea);return m.jsx(Qs,{present:n||o.hasThumb,children:m.jsx(TN,{ref:t,...r})})}),TN=T.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,a=gN(ON,n),i=jN(ON,n),{onThumbPositionChange:s}=i,l=Yo(t,e=>i.onThumbChange(e)),u=T.useRef(void 0),c=UN(()=>{u.current&&(u.current(),u.current=void 0)},100);return T.useEffect(()=>{const e=a.viewport;if(e){const t=()=>{if(c(),!u.current){const t=BN(e,s);u.current=t,s()}};return s(),e.addEventListener("scroll",t),()=>e.removeEventListener("scroll",t)}},[a.viewport,c,s]),m.jsx(aa.div,{"data-state":i.hasThumb?"visible":"hidden",...o,ref:l,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...r},onPointerDownCapture:Bo(e.onPointerDownCapture,e=>{const t=e.target.getBoundingClientRect(),n=e.clientX-t.left,r=e.clientY-t.top;i.onThumbPointerDown({x:n,y:r})}),onPointerUp:Bo(e.onPointerUp,i.onThumbPointerUp)})});MN.displayName=ON;var DN="ScrollAreaCorner",AN=T.forwardRef((e,t)=>{const n=gN(DN,e.__scopeScrollArea),r=Boolean(n.scrollbarX&&n.scrollbarY);return"scroll"!==n.type&&r?m.jsx(FN,{...e,ref:t}):null});AN.displayName=DN;var FN=T.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=gN(DN,n),[a,i]=T.useState(0),[s,l]=T.useState(0),u=Boolean(a&&s);return WN(o.scrollbarX,()=>{const e=o.scrollbarX?.offsetHeight||0;o.onCornerHeightChange(e),l(e)}),WN(o.scrollbarY,()=>{const e=o.scrollbarY?.offsetWidth||0;o.onCornerWidthChange(e),i(e)}),u?m.jsx(aa.div,{...r,ref:t,style:{width:a,height:s,position:"absolute",right:"ltr"===o.dir?0:void 0,left:"rtl"===o.dir?0:void 0,bottom:0,...e.style}}):null});function LN(e){return e?parseInt(e,10):0}function IN(e,t){const n=e/t;return isNaN(n)?0:n}function zN(e){const t=IN(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function $N(e,t,n="ltr"){const r=zN(t),o=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,a=t.scrollbar.size-o,i=t.content-t.viewport,s=a-r,l=SE(e,"ltr"===n?[0,i]:[-1*i,0]);return HN([0,i],[0,s])(l)}function HN(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function VN(e,t){return e>0&&e<t}var BN=(e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},r=0;return function o(){const a={left:e.scrollLeft,top:e.scrollTop},i=n.left!==a.left,s=n.top!==a.top;(i||s)&&t(),n=a,r=window.requestAnimationFrame(o)}(),()=>window.cancelAnimationFrame(r)};function UN(e,t){const n=ca(e),r=T.useRef(0);return T.useEffect(()=>()=>window.clearTimeout(r.current),[]),T.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function WN(e,t){const n=ca(t);Ko(()=>{let t=0;if(e){const r=new ResizeObserver(()=>{cancelAnimationFrame(t),t=window.requestAnimationFrame(n)});return r.observe(e),()=>{window.cancelAnimationFrame(t),r.unobserve(e)}}},[e,n])}var YN=yN,qN=bN,GN=AN;const KN=T.forwardRef(({className:e,children:t,...n},r)=>m.jsxs(YN,{ref:r,className:Ao("relative overflow-hidden",e),...n,children:[m.jsx(qN,{className:"h-full w-full rounded-[inherit]",children:t}),m.jsx(QN,{}),m.jsx(GN,{})]}));KN.displayName=YN.displayName;const QN=T.forwardRef(({className:e,orientation:t="vertical",...n},r)=>m.jsx(xN,{ref:r,orientation:t,className:Ao("flex touch-none select-none transition-colors","vertical"===t&&"h-full w-2.5 border-l border-l-transparent p-[1px]","horizontal"===t&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",e),...n,children:m.jsx(MN,{className:"relative flex-1 rounded-full bg-neutral-200 dark:bg-neutral-800"})}));function ZN({placeholder:e,searchPlaceholder:t,options:n=[],showMultiSelectValues:r=!0,values:o,onChange:a,className:i,showCheckMark:s=!0,label:l,labelClass:u,required:c,info:d,optional:f,actionLabel:p,actionLabelAction:h,actionLabelInfo:g,removeSelectedValue:y,removeTag:v,loading:b,showCount:w,error:x,showError:C,onChangeSearch:S,searching:k,contentStyle:_,disabled:E}){const[R,N]=T.useState(!1),[j,P]=T.useState(0),O=T.useRef(null);T.useEffect(()=>{const e=()=>{O.current&&P(O?.current?.offsetWidth)};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]);const M=o?.filter(e=>""!==e),D=e=>{const t=M?.includes(e)?M?.filter(t=>t!==e):[...M||[],e];a&&a(t)};return T.useEffect(()=>{y&&D(y)},[y]),m.jsx(m.Fragment,{children:b?m.jsx(Vo,{className:"w-full h-[48px]"}):m.jsxs("div",{className:Ao("flex flex-col gap-2.5",i),children:[m.jsxs("div",{className:"flex justify-between gap-2 flex-wrap",children:[l&&m.jsxs("label",{className:Ao("text-black flex items-center gap-1 first-letter:uppercase text-sm font-medium",u),children:[l," ",c?m.jsx("span",{className:"text-[#E12D39]",children:l&&"*"}):f?m.jsx("span",{className:"text-[#B5B5B5] font-normal",children:"(optional)"}):null,d&&m.jsx(fv,{fieldName:l,children:m.jsx("p",{className:"font-normal first-letter:uppercase",children:d})})]}),p&&m.jsxs("button",{onClick:h,className:"text-primary flex items-center gap-1 first-letter:uppercase text-sm font-medium",children:[p,g&&m.jsx(fv,{fieldName:p,children:m.jsx("p",{className:"font-normal first-letter:uppercase text-left",children:g})})]})]}),m.jsxs(ES,{modal:!0,open:R,onOpenChange:N,children:[m.jsx(RS,{disabled:E,asChild:!0,children:m.jsxs(PS,{ref:O,variant:"outline",role:"combobox","aria-expanded":R,className:Ao(`w-full h-[48px] justify-between border focus:border-primary border-neutral-200 bg-white hover:bg-white hover:border-[#BFD7FE] ${(x||C)&&"!border-danger"}`,r?"h-auto py-3":null,i),children:[m.jsx("div",{className:"flex gap-2 text-[#5E6278] justify-start first-letter:uppercase flex-wrap",children:M?.length>0&&r?M?.map((e,t)=>m.jsxs("div",{onClick:()=>{!v&&D(e)},className:"px-2 py-1 text-black flex items-center justify-between rounded gap-2 border bg-slate-200 text-xs font-medium",children:[n?.[0].searchId?n?.find(t=>t.value===e)?.searchId:n?.find(t=>t.value===e)?.label,m.jsx("span",{className:"",children:m.jsx("svg",{width:"9",height:"9",viewBox:"0 0 9 9",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:m.jsx("path",{d:"M5.44001 4.49978L7.83334 2.12644C7.96064 1.99737 8.03146 1.82301 8.03021 1.64173C8.02896 1.46044 7.95575 1.28708 7.82667 1.15978C7.6976 1.03247 7.52324 0.961657 7.34196 0.962907C7.16067 0.964157 6.98731 1.03737 6.86001 1.16644L4.50001 3.55978L2.14001 1.21311C2.0151 1.08894 1.84613 1.01925 1.67001 1.01925C1.49388 1.01925 1.32492 1.08894 1.20001 1.21311C1.13752 1.27509 1.08793 1.34882 1.05408 1.43006C1.02023 1.5113 1.00281 1.59844 1.00281 1.68644C1.00281 1.77445 1.02023 1.86159 1.05408 1.94283C1.08793 2.02407 1.13752 2.0978 1.20001 2.15978L3.56001 4.49978L1.16667 6.87311C1.03937 7.00218 0.968554 7.17654 0.969804 7.35782C0.971054 7.53911 1.04427 7.71247 1.17334 7.83978C1.30241 7.96708 1.47677 8.0379 1.65805 8.03665C1.83934 8.0354 2.0127 7.96218 2.14001 7.83311L4.50001 5.43978L6.86001 7.78644C6.98492 7.91061 7.15388 7.98031 7.33001 7.98031C7.50613 7.98031 7.6751 7.91061 7.80001 7.78644C7.86249 7.72447 7.91209 7.65073 7.94594 7.56949C7.97978 7.48826 7.99721 7.40112 7.99721 7.31311C7.99721 7.2251 7.97978 7.13797 7.94594 7.05673C7.91209 6.97549 7.86249 6.90175 7.80001 6.83978L5.44001 4.49978Z",fill:"black"})})})]},t)):!r&&w&&o.length>0?`${M.length} ${l} selected`:e??"Select..."}),m.jsx(wd,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),m.jsx(NS,{align:"start",style:{width:j},className:Ao("w-[480px] p-0 bg-white rounded-xl border-gray-200",_),children:m.jsx(KN,{children:m.jsxs(KC,{children:[m.jsx(QC,{onChangeCapture:S,className:"placeholder:text-xs",placeholder:t??"Search..."}),k?m.jsx("div",{className:"flex flex-col gap-2 p-2",children:[1,2,3].map((e,t)=>m.jsx(Vo,{className:"h-9 rounded-md"},t))}):m.jsx(XC,{children:"No result found."}),m.jsx(JC,{children:m.jsx(ZC,{className:"",children:n?.map(e=>m.jsxs(eS,{value:"string"==typeof e.label?e.label:e.searchId,className:`first-letter:uppercase mb-1 focus:bg-primary_light w-full rounded-md focus:text-primary hover:text-primary font-semibold text-gray-700 text-sm cursor-pointer ${o?.includes(e.value)&&"bg-primary_light text-primary"}`,onSelect:()=>{D(e.value)},children:[s&&m.jsx(gd,{className:Ao("mr-2 h-4 w-4",o?.includes(e.value)?"opacity-100":"opacity-0")}),e.label]},e.value))})})]})})})]})]})})}function XN({isOpen:e,onClose:t}){const{mutate:n,isPending:r}=Ww(),o=wn(),{apiKey:a}=Rn(),{data:i}=Uw(["categories",a],"/inventory_metas/categories",{enabled:!!a}),{data:s}=Uw(["itemunits",a],"/inventory_metas/units",{enabled:!!a}),{data:l}=Uw(["itemtags",a],"/inventory_metas/tags",{enabled:!!a}),{data:u}=Uw(["itemtypes",a],"/inventory_metas/types",{enabled:!!a}),c=i?.data?.data?.map(e=>({label:e.name,value:e.uuid,subOptions:e.subCategories.map(e=>({label:e.name,value:e.uuid}))}))||[],d=s?.data?.data?.map(e=>({label:e.name,value:e.uuid}))||[],f=l?.data?.data?.map(e=>({label:e.name,value:e.uuid})),p=u?.data?.data?.filter(e=>"products"===e.name||"services"===e.name).map(e=>({label:e.name,value:e.uuid}))||[],[h,g]=T.useState(""),[y,v]=D.useState([]),[b,w]=T.useState(p?.[0]?.value||"");T.useEffect(()=>{const e=p.find(e=>e?.value===b)?.label||"";g(e)},[b]);const[x,C]=T.useState([]),[S,k]=T.useState([{name:"",itemunit_id:d?.[0]?.value||"",quantity:"",cost_price:"",selling_price:"",barcode:""}]),_=(e,t,n)=>{const r=[...S];r[n]={...r[n],[e]:t},k(r)},E={itemtype_id:b,itemcategory_id:y,tags:x,items:S},R=["Item name","Item unit",..."services"!==h?["Quantity","Barcode"]:[],"Cost price (₦)","Selling price (₦)"];return m.jsxs(LS,{isOpen:e,onClose:t,title:"Quick create multiple items",className:"max-w-[1024px]",children:[m.jsxs("div",{className:"px-5 space-y-7 pb-5",children:[m.jsxs("div",{className:"grid grid-cols-3 gap-5 bg-gray-100 rounded-xl p-4",children:[m.jsx(OS,{label:"Item type",options:p,placeholder:"select item type",value:b,onValueChange:e=>w(e),required:!0,info:"Select the type of item you're creating (e.g., product, service, variations, kits ). This classification helps determine how the item is managed, displayed, or fulfilled."}),m.jsx(dN,{placeholder:"select categories",label:"Category",options:c,values:y,onChange:e=>v(e),showMultiSelectValues:!1,showCount:!0,info:"Select the category that best describes this item(s) (e.g., electronics, clothing, food). Categorizing items helps in organizing inventory and simplifies product management."}),m.jsx(ZN,{label:"Item tag",placeholder:"Select item tags",info:"Enter relevant keywords or labels for this item(s). Tags help in categorizing and making the item easier to find through search filters.",labelClass:"text-dark text-sm",options:f,values:x,onChange:C,showSearch:!0,showCount:!0,showMultiSelectValues:!1})]}),m.jsxs("div",{className:"space-y-2 overflow-auto",children:[m.jsxs("table",{className:"table-auto w-full border-separate border-spacing-4",children:[m.jsx("thead",{children:m.jsx("tr",{children:R.map((e,t)=>m.jsx("th",{className:"text-dark text-sm font-medium text-left",children:e},t))})}),m.jsx("tbody",{className:"text-dark text-[15px] ",children:S.map((e,t)=>m.jsxs("tr",{children:[m.jsx("td",{className:"",children:m.jsx(qR,{type:"text",placeholder:"Enter item name",value:e.name,onChange:e=>_("name",e.target.value,t)})}),m.jsx("td",{children:m.jsx(OS,{options:d,placeholder:"select item unit",value:e.itemunit_id,onValueChange:e=>_("itemunit_id",e,t)})}),"services"!==h?m.jsxs(m.Fragment,{children:[m.jsx("td",{className:"",children:m.jsx(qR,{type:"number",placeholder:"0",value:e.quantity,onChange:e=>_("quantity",e.target.value,t)})}),m.jsx("td",{className:"",children:m.jsx(qR,{type:"number",placeholder:"Enter barcode",value:e.barcode,onChange:e=>_("barcode",e.target.value,t)})})]}):null,m.jsx("td",{className:"",children:m.jsx(qR,{type:"number",placeholder:"0.00",value:e.cost_price,onChange:e=>_("cost_price",e.target.value,t)})}),m.jsx("td",{className:"",children:m.jsx(qR,{type:"number",placeholder:"0.00",value:e.selling_price,onChange:e=>_("selling_price",e.target.value,t)})}),m.jsx("td",{className:"",children:m.jsx("button",{onClick:()=>(e=>{const t=S.filter((t,n)=>n!==e);k(t)})(t),disabled:1===S.length,className:"disabled:cursor-not-allowed disabled:opacity-70",children:$y.trash2})})]},t))})]}),m.jsx(xE,{mode:"text",label:"Add more",left_addon:$y.plus_squared2,onClick:()=>{k(e=>[...e,{name:"",itemunit_id:d?.[0]?.value||"",quantity:"",cost_price:"",selling_price:"",barcode:""}])},className:"font-medium text-sm ml-4"})]})]}),m.jsxs("div",{className:"flex justify-between items-center px-5 sticky bottom-0 bg-white py-5 border-t ",children:[m.jsxs("button",{className:"text-primary text-sm font-medium flex items-center gap-1",children:[$y.question," Need help?"]}),m.jsxs("div",{className:"flex justify-end gap-2.5",children:[m.jsx(xE,{label:"Cancel",className:"bg-[#F1F1F2] text-[#181C32] hover:bg-[#F1F1F2]/90",onClick:t}),m.jsx(xE,{label:"Create Items",onClick:()=>{n({url:"/items/create_multiple",payload:E},{onSuccess:()=>{o.invalidateQueries({queryKey:["items"]}),t&&t()}})},loading:r})]})]})]})}QN.displayName=xN.displayName;const JN="https://unpkg.com/@simpoobusiness/sdk/dist/simpoo-sdk.css";let ej={};function tj(e){ej=e}const nj={inventory:()=>{const[e,t]=D.useState(),{currentPage:n,perview:r}=ne(e=>e.app),[o,a]=T.useState("all"),[i,s]=T.useState(!1),[l,u]=T.useState("all"),[c,d]=T.useState(""),[f]=cN(c,1e3),{apiKey:p}=Rn(),{data:h,isFetching:g}=Uw(["items",r.toString(),n?.toString(),o,f,p],f?`/items/search?page=${n}&paginate=${r}&param=${f}&for=${o}&filter=all`:`/items?page=${n}&paginate=${r}&status=${o}`,{enabled:!!p}),y=h?.data?.[0]||[],v=y?.data?.map(e=>({item_description:e?.name,all_quantity:+e?.all_quantity,quantity:+e?.quantity,type:e?.item_type?.name,selling_price:+e?.selling_price,categories:e?.category||[],tags:e?.item_tags?.map(e=>e.name)||[],status:e?.status?"published":"draft",sku:e?.sku,item_image:e.images?.length>0?e.images?.[0].image:Kx,barcode:e?.barcode,expired:e?.expired,expiring:e?.expiring,unit:e?.item_unit,uuid:e?.uuid,item_type_id:e?.item_type?.uuid,reorder_level:e?.reorder_level,fullData:e}))||[],{data:b,isFetching:w}=Uw(["items-tab"],"/items/count",{enabled:!!p}),x=b?.data,C=[{label:"all",count:x?.all||0,action:()=>a("all")},{label:"published",count:x?.published||0,action:()=>a("published")},{label:"out of stock",count:x?.out_of_stock||0,action:()=>a("out_of_stock")},{label:"draft",count:x?.draft||0,action:()=>a("draft")},{label:"expiring",count:x?.expiring||0,action:()=>a("expiring")},{label:"expired",count:x?.expired||0,action:()=>a("expired")}],[S,k]=T.useState(!1);return m.jsxs(qx,{className:"px-4 py-6 flex flex-col gap-8",children:[m.jsx(AS,{tabs:C,loading:g}),m.jsxs("div",{className:" flex items-center justify-between flex-wrap gap-4",children:[m.jsxs("div",{className:"flex items-center gap-2.5",children:[m.jsx(lN,{placeholder:"Search Item name, barcode or sku",value:c,onChange:e=>d(e.target.value)}),g?m.jsx(Vo,{className:"w-20 h-6"}):m.jsxs("p",{className:"text-dark text-sm font-medium",children:[y?.meta?.total??0," ",m.jsx("span",{className:"text-gray-700",children:"Items"})]})]}),m.jsx("div",{className:"flex gap-4",children:m.jsx(xE,{label:"Create New",left_addon:$y.plus_squared,className:"!font-medium !text-sm !h-12",onClick:()=>k(!0)})})]}),m.jsx(sN,{loading:g,data:h?.data?.[1],meta:y?.meta}),m.jsx(By,{loading:g,columns:KR,data:v,emptyData:0===v.length,emptyProps:{header:"No item yet",subText:"Add new item to start managing your inventory."},tHeadClass:"whitespace-nowrap",tbCellClass:"text-dark font-semibold",meta:y?.meta}),S?m.jsx(XN,{isOpen:S,onClose:()=>k(!1)}):null]})}};function rj(e,t){!function(){if(!document.querySelector(`link[href="${JN}"]`)){const e=document.createElement("link");e.rel="stylesheet",e.href=JN,document.head.appendChild(e)}}();const n=nj[e];if(!n)return void console.error(`SimpooSDK: Widget "${e}" not found.`);const r=document.querySelector(t);if(!r)throw new Error(`Container "${t}" not found!`);M.createRoot(r).render(m.jsx(Nn,{apiKey:ej.apiKey||"",children:m.jsx(n,{})}))}"undefined"!=typeof window&&(window.SimpooSDK={init:tj,renderWidget:rj}),e.init=tj,e.renderWidget=rj});
223
+ `;var kE=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"});T.forwardRef((e,t)=>m.jsx(aa.span,{...e,ref:t,style:{...kE,...e.style}})).displayName="VisuallyHidden";var _E=[" ","Enter","ArrowUp","ArrowDown"],EE=[" ","Enter"],RE="Select",[NE,jE,PE]=sa(RE),[OE,ME]=qo(RE,[PE,js]),TE=js(),[DE,AE]=OE(RE),[FE,LE]=OE(RE),IE=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:a,value:i,defaultValue:s,onValueChange:l,dir:u,name:c,autoComplete:d,disabled:f,required:p,form:h}=e,g=TE(t),[y,v]=T.useState(null),[b,w]=T.useState(null),[x,C]=T.useState(!1),S=ua(u),[k,_]=Zo({prop:r,defaultProp:o??!1,onChange:a,caller:RE}),[E,R]=Zo({prop:i,defaultProp:s,onChange:l,caller:RE}),N=T.useRef(null),j=!y||(h||!!y.closest("form")),[P,O]=T.useState(new Set),M=Array.from(P).map(e=>e.props.value).join(";");return m.jsx(Ws,{...g,children:m.jsxs(DE,{required:p,scope:t,trigger:y,onTriggerChange:v,valueNode:b,onValueNodeChange:w,valueNodeHasChildren:x,onValueNodeHasChildrenChange:C,contentId:Aa(),value:E,onValueChange:R,open:k,onOpenChange:_,dir:S,triggerPointerDownPosRef:N,disabled:f,children:[m.jsx(NE.Provider,{scope:t,children:m.jsx(FE,{scope:e.__scopeSelect,onNativeOptionAdd:T.useCallback(e=>{O(t=>new Set(t).add(e))},[]),onNativeOptionRemove:T.useCallback(e=>{O(t=>{const n=new Set(t);return n.delete(e),n})},[]),children:n})}),j?m.jsxs(kR,{"aria-hidden":!0,required:p,tabIndex:-1,name:c,autoComplete:d,value:E,onChange:e=>R(e.target.value),disabled:f,form:h,children:[void 0===E?m.jsx("option",{value:""}):null,Array.from(P)]},M):null]})})};IE.displayName=RE;var zE="SelectTrigger",$E=T.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,a=TE(n),i=AE(zE,n),s=i.disabled||r,l=Yo(t,i.onTriggerChange),u=jE(n),c=T.useRef("touch"),[d,f,p]=ER(e=>{const t=u().filter(e=>!e.disabled),n=t.find(e=>e.value===i.value),r=RR(t,e,n);void 0!==r&&i.onValueChange(r.value)}),h=e=>{s||(i.onOpenChange(!0),p()),e&&(i.triggerPointerDownPosRef.current={x:Math.round(e.pageX),y:Math.round(e.pageY)})};return m.jsx(Ys,{asChild:!0,...a,children:m.jsx(aa.button,{type:"button",role:"combobox","aria-controls":i.contentId,"aria-expanded":i.open,"aria-required":i.required,"aria-autocomplete":"none",dir:i.dir,"data-state":i.open?"open":"closed",disabled:s,"data-disabled":s?"":void 0,"data-placeholder":_R(i.value)?"":void 0,...o,ref:l,onClick:Bo(o.onClick,e=>{e.currentTarget.focus(),"mouse"!==c.current&&h(e)}),onPointerDown:Bo(o.onPointerDown,e=>{c.current=e.pointerType;const t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),0===e.button&&!1===e.ctrlKey&&"mouse"===e.pointerType&&(h(e),e.preventDefault())}),onKeyDown:Bo(o.onKeyDown,e=>{const t=""!==d.current;e.ctrlKey||e.altKey||e.metaKey||1!==e.key.length||f(e.key),t&&" "===e.key||_E.includes(e.key)&&(h(),e.preventDefault())})})})});$E.displayName=zE;var HE="SelectValue",VE=T.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:a,placeholder:i="",...s}=e,l=AE(HE,n),{onValueNodeHasChildrenChange:u}=l,c=void 0!==a,d=Yo(t,l.onValueNodeChange);return Ko(()=>{u(c)},[u,c]),m.jsx(aa.span,{...s,ref:d,style:{pointerEvents:"none"},children:_R(l.value)?m.jsx(m.Fragment,{children:i}):a})});VE.displayName=HE;var BE=T.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return m.jsx(aa.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});BE.displayName="SelectIcon";var UE=e=>m.jsx(Ks,{asChild:!0,...e});UE.displayName="SelectPortal";var WE="SelectContent",YE=T.forwardRef((e,t)=>{const n=AE(WE,e.__scopeSelect),[r,o]=T.useState();if(Ko(()=>{o(new DocumentFragment)},[]),!n.open){const t=r;return t?Xo.createPortal(m.jsx(GE,{scope:e.__scopeSelect,children:m.jsx(NE.Slot,{scope:e.__scopeSelect,children:m.jsx("div",{children:e.children})})}),t):null}return m.jsx(ZE,{...e,ref:t})});YE.displayName=WE;var qE=10,[GE,KE]=OE(WE),QE=ea("SelectContent.RemoveScroll"),ZE=T.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:a,onPointerDownOutside:i,side:s,sideOffset:l,align:u,alignOffset:c,arrowPadding:d,collisionBoundary:f,collisionPadding:p,sticky:h,hideWhenDetached:g,avoidCollisions:y,...v}=e,b=AE(WE,n),[w,x]=T.useState(null),[C,S]=T.useState(null),k=Yo(t,e=>x(e)),[_,E]=T.useState(null),[R,N]=T.useState(null),j=jE(n),[P,O]=T.useState(!1),M=T.useRef(!1);T.useEffect(()=>{if(w)return Cl(w)},[w]),xa();const D=T.useCallback(e=>{const[t,...n]=j().map(e=>e.ref.current),[r]=n.slice(-1),o=document.activeElement;for(const n of e){if(n===o)return;if(n?.scrollIntoView({block:"nearest"}),n===t&&C&&(C.scrollTop=0),n===r&&C&&(C.scrollTop=C.scrollHeight),n?.focus(),document.activeElement!==o)return}},[j,C]),A=T.useCallback(()=>D([_,w]),[D,_,w]);T.useEffect(()=>{P&&A()},[P,A]);const{onOpenChange:F,triggerPointerDownPosRef:L}=b;T.useEffect(()=>{if(w){let e={x:0,y:0};const t=t=>{e={x:Math.abs(Math.round(t.pageX)-(L.current?.x??0)),y:Math.abs(Math.round(t.pageY)-(L.current?.y??0))}},n=n=>{e.x<=10&&e.y<=10?n.preventDefault():w.contains(n.target)||F(!1),document.removeEventListener("pointermove",t),L.current=null};return null!==L.current&&(document.addEventListener("pointermove",t),document.addEventListener("pointerup",n,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",t),document.removeEventListener("pointerup",n,{capture:!0})}}},[w,F,L]),T.useEffect(()=>{const e=()=>F(!1);return window.addEventListener("blur",e),window.addEventListener("resize",e),()=>{window.removeEventListener("blur",e),window.removeEventListener("resize",e)}},[F]);const[I,z]=ER(e=>{const t=j().filter(e=>!e.disabled),n=t.find(e=>e.ref.current===document.activeElement),r=RR(t,e,n);r&&setTimeout(()=>r.ref.current.focus())}),$=T.useCallback((e,t,n)=>{const r=!M.current&&!n;(void 0!==b.value&&b.value===t||r)&&(E(e),r&&(M.current=!0))},[b.value]),H=T.useCallback(()=>w?.focus(),[w]),V=T.useCallback((e,t,n)=>{const r=!M.current&&!n;(void 0!==b.value&&b.value===t||r)&&N(e)},[b.value]),B="popper"===r?JE:XE,U=B===JE?{side:s,sideOffset:l,align:u,alignOffset:c,arrowPadding:d,collisionBoundary:f,collisionPadding:p,sticky:h,hideWhenDetached:g,avoidCollisions:y}:{};return m.jsx(GE,{scope:n,content:w,viewport:C,onViewportChange:S,itemRefCallback:$,selectedItem:_,onItemLeave:H,itemTextRefCallback:V,focusSelectedItem:A,selectedItemText:R,position:r,isPositioned:P,searchRef:I,children:m.jsx(cu,{as:QE,allowPinchZoom:!0,children:m.jsx(Ea,{asChild:!0,trapped:b.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:Bo(o,e=>{b.trigger?.focus({preventScroll:!0}),e.preventDefault()}),children:m.jsx(ga,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:i,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>b.onOpenChange(!1),children:m.jsx(B,{role:"listbox",id:b.contentId,"data-state":b.open?"open":"closed",dir:b.dir,onContextMenu:e=>e.preventDefault(),...v,...U,onPlaced:()=>O(!0),ref:k,style:{display:"flex",flexDirection:"column",outline:"none",...v.style},onKeyDown:Bo(v.onKeyDown,e=>{const t=e.ctrlKey||e.altKey||e.metaKey;if("Tab"===e.key&&e.preventDefault(),t||1!==e.key.length||z(e.key),["ArrowUp","ArrowDown","Home","End"].includes(e.key)){let t=j().filter(e=>!e.disabled).map(e=>e.ref.current);if(["ArrowUp","End"].includes(e.key)&&(t=t.slice().reverse()),["ArrowUp","ArrowDown"].includes(e.key)){const n=e.target,r=t.indexOf(n);t=t.slice(r+1)}setTimeout(()=>D(t)),e.preventDefault()}})})})})})})});ZE.displayName="SelectContentImpl";var XE=T.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,a=AE(WE,n),i=KE(WE,n),[s,l]=T.useState(null),[u,c]=T.useState(null),d=Yo(t,e=>c(e)),f=jE(n),p=T.useRef(!1),h=T.useRef(!0),{viewport:g,selectedItem:y,selectedItemText:v,focusSelectedItem:b}=i,w=T.useCallback(()=>{if(a.trigger&&a.valueNode&&s&&u&&g&&y&&v){const e=a.trigger.getBoundingClientRect(),t=u.getBoundingClientRect(),n=a.valueNode.getBoundingClientRect(),o=v.getBoundingClientRect();if("rtl"!==a.dir){const r=o.left-t.left,a=n.left-r,i=e.left-a,l=e.width+i,u=Math.max(l,t.width),c=window.innerWidth-qE,d=SE(a,[qE,Math.max(qE,c-u)]);s.style.minWidth=l+"px",s.style.left=d+"px"}else{const r=t.right-o.right,a=window.innerWidth-n.right-r,i=window.innerWidth-e.right-a,l=e.width+i,u=Math.max(l,t.width),c=window.innerWidth-qE,d=SE(a,[qE,Math.max(qE,c-u)]);s.style.minWidth=l+"px",s.style.right=d+"px"}const i=f(),l=window.innerHeight-2*qE,c=g.scrollHeight,d=window.getComputedStyle(u),h=parseInt(d.borderTopWidth,10),m=parseInt(d.paddingTop,10),b=parseInt(d.borderBottomWidth,10),w=h+m+c+parseInt(d.paddingBottom,10)+b,x=Math.min(5*y.offsetHeight,w),C=window.getComputedStyle(g),S=parseInt(C.paddingTop,10),k=parseInt(C.paddingBottom,10),_=e.top+e.height/2-qE,E=l-_,R=y.offsetHeight/2,N=h+m+(y.offsetTop+R),j=w-N;if(N<=_){const e=i.length>0&&y===i[i.length-1].ref.current;s.style.bottom="0px";const t=u.clientHeight-g.offsetTop-g.offsetHeight,n=N+Math.max(E,R+(e?k:0)+t+b);s.style.height=n+"px"}else{const e=i.length>0&&y===i[0].ref.current;s.style.top="0px";const t=Math.max(_,h+g.offsetTop+(e?S:0)+R)+j;s.style.height=t+"px",g.scrollTop=N-_+g.offsetTop}s.style.margin=`${qE}px 0`,s.style.minHeight=x+"px",s.style.maxHeight=l+"px",r?.(),requestAnimationFrame(()=>p.current=!0)}},[f,a.trigger,a.valueNode,s,u,g,y,v,a.dir,r]);Ko(()=>w(),[w]);const[x,C]=T.useState();Ko(()=>{u&&C(window.getComputedStyle(u).zIndex)},[u]);const S=T.useCallback(e=>{e&&!0===h.current&&(w(),b?.(),h.current=!1)},[w,b]);return m.jsx(eR,{scope:n,contentWrapper:s,shouldExpandOnScrollRef:p,onScrollButtonChange:S,children:m.jsx("div",{ref:l,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:x},children:m.jsx(aa.div,{...o,ref:d,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});XE.displayName="SelectItemAlignedPosition";var JE=T.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=qE,...a}=e,i=TE(n);return m.jsx(qs,{...i,...a,ref:t,align:r,collisionPadding:o,style:{boxSizing:"border-box",...a.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});JE.displayName="SelectPopperPosition";var[eR,tR]=OE(WE,{}),nR="SelectViewport",rR=T.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,a=KE(nR,n),i=tR(nR,n),s=Yo(t,a.onViewportChange),l=T.useRef(0);return m.jsxs(m.Fragment,{children:[m.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:r}),m.jsx(NE.Slot,{scope:n,children:m.jsx(aa.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:s,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:Bo(o.onScroll,e=>{const t=e.currentTarget,{contentWrapper:n,shouldExpandOnScrollRef:r}=i;if(r?.current&&n){const e=Math.abs(l.current-t.scrollTop);if(e>0){const r=window.innerHeight-2*qE,o=parseFloat(n.style.minHeight),a=parseFloat(n.style.height),i=Math.max(o,a);if(i<r){const o=i+e,a=Math.min(r,o),s=o-a;n.style.height=a+"px","0px"===n.style.bottom&&(t.scrollTop=s>0?s:0,n.style.justifyContent="flex-end")}}}l.current=t.scrollTop})})})]})});rR.displayName=nR;var oR="SelectGroup",[aR,iR]=OE(oR);T.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Aa();return m.jsx(aR,{scope:n,id:o,children:m.jsx(aa.div,{role:"group","aria-labelledby":o,...r,ref:t})})}).displayName=oR;var sR="SelectLabel",lR=T.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=iR(sR,n);return m.jsx(aa.div,{id:o.id,...r,ref:t})});lR.displayName=sR;var uR="SelectItem",[cR,dR]=OE(uR),fR=T.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:a,...i}=e,s=AE(uR,n),l=KE(uR,n),u=s.value===r,[c,d]=T.useState(a??""),[f,p]=T.useState(!1),h=Yo(t,e=>l.itemRefCallback?.(e,r,o)),g=Aa(),y=T.useRef("touch"),v=()=>{o||(s.onValueChange(r),s.onOpenChange(!1))};if(""===r)throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return m.jsx(cR,{scope:n,value:r,disabled:o,textId:g,isSelected:u,onItemTextChange:T.useCallback(e=>{d(t=>t||(e?.textContent??"").trim())},[]),children:m.jsx(NE.ItemSlot,{scope:n,value:r,disabled:o,textValue:c,children:m.jsx(aa.div,{role:"option","aria-labelledby":g,"data-highlighted":f?"":void 0,"aria-selected":u&&f,"data-state":u?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...i,ref:h,onFocus:Bo(i.onFocus,()=>p(!0)),onBlur:Bo(i.onBlur,()=>p(!1)),onClick:Bo(i.onClick,()=>{"mouse"!==y.current&&v()}),onPointerUp:Bo(i.onPointerUp,()=>{"mouse"===y.current&&v()}),onPointerDown:Bo(i.onPointerDown,e=>{y.current=e.pointerType}),onPointerMove:Bo(i.onPointerMove,e=>{y.current=e.pointerType,o?l.onItemLeave?.():"mouse"===y.current&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Bo(i.onPointerLeave,e=>{e.currentTarget===document.activeElement&&l.onItemLeave?.()}),onKeyDown:Bo(i.onKeyDown,e=>{""!==l.searchRef?.current&&" "===e.key||(EE.includes(e.key)&&v()," "===e.key&&e.preventDefault())})})})})});fR.displayName=uR;var pR="SelectItemText",hR=T.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...a}=e,i=AE(pR,n),s=KE(pR,n),l=dR(pR,n),u=LE(pR,n),[c,d]=T.useState(null),f=Yo(t,e=>d(e),l.onItemTextChange,e=>s.itemTextRefCallback?.(e,l.value,l.disabled)),p=c?.textContent,h=T.useMemo(()=>m.jsx("option",{value:l.value,disabled:l.disabled,children:p},l.value),[l.disabled,l.value,p]),{onNativeOptionAdd:g,onNativeOptionRemove:y}=u;return Ko(()=>(g(h),()=>y(h)),[g,y,h]),m.jsxs(m.Fragment,{children:[m.jsx(aa.span,{id:l.textId,...a,ref:f}),l.isSelected&&i.valueNode&&!i.valueNodeHasChildren?Xo.createPortal(a.children,i.valueNode):null]})});hR.displayName=pR;var mR="SelectItemIndicator",gR=T.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return dR(mR,n).isSelected?m.jsx(aa.span,{"aria-hidden":!0,...r,ref:t}):null});gR.displayName=mR;var yR="SelectScrollUpButton",vR=T.forwardRef((e,t)=>{const n=KE(yR,e.__scopeSelect),r=tR(yR,e.__scopeSelect),[o,a]=T.useState(!1),i=Yo(t,r.onScrollButtonChange);return Ko(()=>{if(n.viewport&&n.isPositioned){let e=function(){const e=t.scrollTop>0;a(e)};const t=n.viewport;return e(),t.addEventListener("scroll",e),()=>t.removeEventListener("scroll",e)}},[n.viewport,n.isPositioned]),o?m.jsx(xR,{...e,ref:i,onAutoScroll:()=>{const{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop=e.scrollTop-t.offsetHeight)}}):null});vR.displayName=yR;var bR="SelectScrollDownButton",wR=T.forwardRef((e,t)=>{const n=KE(bR,e.__scopeSelect),r=tR(bR,e.__scopeSelect),[o,a]=T.useState(!1),i=Yo(t,r.onScrollButtonChange);return Ko(()=>{if(n.viewport&&n.isPositioned){let e=function(){const e=t.scrollHeight-t.clientHeight,n=Math.ceil(t.scrollTop)<e;a(n)};const t=n.viewport;return e(),t.addEventListener("scroll",e),()=>t.removeEventListener("scroll",e)}},[n.viewport,n.isPositioned]),o?m.jsx(xR,{...e,ref:i,onAutoScroll:()=>{const{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop=e.scrollTop+t.offsetHeight)}}):null});wR.displayName=bR;var xR=T.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,a=KE("SelectScrollButton",n),i=T.useRef(null),s=jE(n),l=T.useCallback(()=>{null!==i.current&&(window.clearInterval(i.current),i.current=null)},[]);return T.useEffect(()=>()=>l(),[l]),Ko(()=>{const e=s().find(e=>e.ref.current===document.activeElement);e?.ref.current?.scrollIntoView({block:"nearest"})},[s]),m.jsx(aa.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:Bo(o.onPointerDown,()=>{null===i.current&&(i.current=window.setInterval(r,50))}),onPointerMove:Bo(o.onPointerMove,()=>{a.onItemLeave?.(),null===i.current&&(i.current=window.setInterval(r,50))}),onPointerLeave:Bo(o.onPointerLeave,()=>{l()})})}),CR=T.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return m.jsx(aa.div,{"aria-hidden":!0,...r,ref:t})});CR.displayName="SelectSeparator";var SR="SelectArrow";T.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=TE(n),a=AE(SR,n),i=KE(SR,n);return a.open&&"popper"===i.position?m.jsx(Gs,{...o,...r,ref:t}):null}).displayName=SR;var kR=T.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=T.useRef(null),a=Yo(r,o),i=function(e){const t=T.useRef({value:e,previous:e});return T.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}(t);return T.useEffect(()=>{const e=o.current;if(!e)return;const n=window.HTMLSelectElement.prototype,r=Object.getOwnPropertyDescriptor(n,"value").set;if(i!==t&&r){const n=new Event("change",{bubbles:!0});r.call(e,t),e.dispatchEvent(n)}},[i,t]),m.jsx(aa.select,{...n,style:{...kE,...n.style},ref:a,defaultValue:t})});function _R(e){return""===e||void 0===e}function ER(e){const t=ca(e),n=T.useRef(""),r=T.useRef(0),o=T.useCallback(e=>{const o=n.current+e;t(o),function e(t){n.current=t,window.clearTimeout(r.current),""!==t&&(r.current=window.setTimeout(()=>e(""),1e3))}(o)},[t]),a=T.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return T.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,a]}function RR(e,t,n){const r=t.length>1&&Array.from(t).every(e=>e===t[0]),o=r?t[0]:t,a=n?e.indexOf(n):-1;let i=(s=e,l=Math.max(a,0),s.map((e,t)=>s[(l+t)%s.length]));var s,l;1===o.length&&(i=i.filter(e=>e!==n));const u=i.find(e=>e.textValue.toLowerCase().startsWith(o.toLowerCase()));return u!==n?u:void 0}kR.displayName="SelectBubbleInput";var NR=$E,jR=BE,PR=UE,OR=YE,MR=rR,TR=lR,DR=fR,AR=hR,FR=gR,LR=vR,IR=wR,zR=CR;const $R=IE,HR=VE,VR=T.forwardRef(({className:e,children:t,...n},r)=>m.jsxs(NR,{ref:r,className:Ao("flex h-10 w-full items-center hover:border-[#BFD7FE] justify-between rounded-md border focus:border-primary border-neutral-200 bg-white px-3 py-2 text-sm ring-offset-white placeholder:text-neutral-500 focus:outline-none disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1 ",e),...n,children:[t,m.jsx(jR,{asChild:!0,children:m.jsx(yd,{className:"h-4 w-4 opacity-50"})})]}));VR.displayName=NR.displayName;const BR=T.forwardRef(({className:e,...t},n)=>m.jsx(LR,{ref:n,className:Ao("flex cursor-default items-center justify-center py-1",e),...t,children:m.jsx(bd,{className:"h-4 w-4"})}));BR.displayName=LR.displayName;const UR=T.forwardRef(({className:e,...t},n)=>m.jsx(IR,{ref:n,className:Ao("flex cursor-default items-center justify-center py-1",e),...t,children:m.jsx(yd,{className:"h-4 w-4"})}));UR.displayName=IR.displayName;const WR=T.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>m.jsx(PR,{children:m.jsxs(OR,{ref:o,className:Ao("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border border-neutral-200 bg-white text-neutral-950 shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 dark:border-neutral-800 dark:bg-neutral-950 dark:text-neutral-50","popper"===n&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,...r,children:[m.jsx(BR,{}),m.jsx(MR,{className:Ao("p-1","popper"===n&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),m.jsx(UR,{})]})}));WR.displayName=OR.displayName;T.forwardRef(({className:e,...t},n)=>m.jsx(TR,{ref:n,className:Ao("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t})).displayName=TR.displayName;const YR=T.forwardRef(({className:e,children:t,...n},r)=>m.jsxs(DR,{ref:r,className:Ao("relative flex w-full select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-primary/20 cursor-pointer focus:text-neutral-900 data-[disabled]:pointer-events-none data-[disabled]:opacity-50 dark:focus:bg-neutral-800 dark:focus:text-neutral-50",e),...n,children:[m.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:m.jsx(FR,{children:m.jsx(gd,{className:"h-4 w-4"})})}),m.jsx(AR,{children:t})]}));YR.displayName=DR.displayName;function qR({label:e,addonLabel:t,type:n,placeholder:r,selectPlaceholder:o,error:a,success:i,value:s,defaultValue:l,name:u,id:c,formik:d,onChange:f,inputRef:p,onBlur:h,required:g,disabled:y,loading:v,showError:b,selectOptions:w,disableSearch:x,searchSelectPlaceholder:C,showSelectSearch:S,onSelectValueChange:k,selectValue:_,showOutline:E=!0,cols:R,rows:N,labelClass:j,addonLabelClass:P,optional:O,info:M,addonInfo:D,icon:A,actionIcon:F,actionLabel:L,actionLabelInfo:I,actionLabelAction:z,className:$,textAreaOnChange:H,addOn:V,infoAlignment:B,addonInfoAlignment:U,inputContainerClass:W,showNegative:Y,showPositive:q,...G}){const[K,Q]=T.useState(n),[Z,X]=T.useState(!1),[J,ee]=T.useState(""),te=((e,t)=>{const n=e?.filter(e=>"string"==typeof e.label?e.label?.toLowerCase().includes(t.toLowerCase()):e.value?.toLowerCase().includes(t.toLowerCase())||e?.searchId?.toLowerCase().includes(t.toLowerCase()));return t?n:e})(w??[],J);return m.jsx(m.Fragment,{children:v?m.jsx(Vo,{className:"w-full h-[48px]"}):m.jsx("div",{className:"w-full",children:m.jsxs("div",{className:`flex flex-col ${e&&"gap-2.5"} relative `,children:[m.jsxs("div",{className:"flex justify-between gap-2 flex-wrap",children:[t&&m.jsxs("label",{className:Ao("text-black flex items-center gap-1 first-letter:uppercase text-sm font-medium",P),children:[t," ",g?m.jsx("span",{className:"text-[#E12D39]",children:t&&"*"}):O?m.jsx("span",{className:"text-[#B5B5B5] font-normal",children:"(optional)"}):null,D&&m.jsx(fv,{fieldName:t,align:U,children:m.jsx("p",{className:"font-normal first-letter:uppercase",children:D})})]}),e&&m.jsxs("label",{className:Ao("text-black flex items-center gap-1 first-letter:uppercase text-sm font-medium",j),children:[e," ",g?m.jsx("span",{className:"text-[#E12D39]",children:e&&"*"}):O?m.jsx("span",{className:"text-[#B5B5B5] font-normal",children:"(optional)"}):null,M&&m.jsx(fv,{fieldName:e,align:B,children:m.jsx("p",{className:"font-normal first-letter:uppercase w-full whitespace-pre-wrap",children:M})})]}),L&&m.jsxs("button",{onClick:z,className:"text-primary flex items-center gap-1 first-letter:uppercase text-sm font-bold",children:[F,L,I&&m.jsx(fv,{fieldName:e,children:m.jsx("p",{className:"font-normal first-letter:uppercase",children:I})})]})]}),m.jsxs("div",{className:Ao(`border overflow-hidden rounded-md text-sm border-[#E1E3EA] hover:border-primary_light font-normal text-grey-950 flex gap-2 items-center bg-white px-3 ${"text-area"!==n&&"h-[48px]"} ${(a||b)&&"!border-danger"} ${i&&"!border-success"} ${Z&&E&&"!border-primary"}\n ${A&&"px-2"}\n ${V&&"px-0"}\n `,y?"cursor-not-allowed bg-gray-200":null,w?"px-0":null,W),children:[V&&m.jsx("span",{className:"bg-gray-200 text-[13px] font-semibold text-gray-700 h-full min-w-[38px] flex items-center justify-center shrink-0 rounded-l-[6px] px-2 ",children:V}),A,w&&m.jsxs($R,{onValueChange:k,defaultValue:_,value:_,children:[m.jsx(VR,{disabled:x,className:" min-w-max w-max h-full border-0 border-r rounded-none hover:border-neutral-200 focus:border-neutral-200 bg-[#F9F9F9] hover:border-b-neutral-200 disabled:opacity-100 ",children:m.jsx(HR,{className:" text-sm text-[#5E6278] placeholder:font-medium outline-none",placeholder:o})}),m.jsxs(WR,{className:"bg-white w-full relative",children:[S&&m.jsx("input",{value:J,onChange:e=>{ee(e.target.value.toString())},placeholder:C??"Search...",className:"h-10 border mb-2 text-sm px-4 outline-none w-full border-neutral-200 rounded bg-white sticky top-0 z-20"}),te?.map((e,t)=>m.jsx(YR,{className:"text-sm",value:e.value,children:e.label},e.value))]})]}),"text-area"===n?m.jsx("textarea",{cols:R,rows:N,onFocus:()=>X(!0),onBlur:e=>{X(!1)},placeholder:r,className:Ao(`placeholder:text-[#7E8299] hover:border-primary_light py-2 h-full placeholder:font-medium outline-none w-full rounded ${y?"bg-[#EEEFF2] cursor-not-allowed":null} ${Z&&E&&"!border-primary"} transition-all ease-in-out`,$),...G,value:s,name:u,onChange:H}):m.jsx("input",{onInput:e=>{const t=e.target;"number"===n&&(t.value=t.value.replace(/[^0-9.]/g,""),t.value=t.value.replace(/^\.|(\..*)\./g,"$1"),t.value.length>1&&t.value.startsWith("0")&&"."!==t.value[1]&&(t.value=t.value.replace(/^0+/,"")),""!==t.value&&"0"!==t.value||(t.value="0"))},type:"number"===K?"text":K,placeholder:r,className:Ao("placeholder:text-[#7E8299] h-full placeholder:font-medium outline-none w-full rounded disabled:cursor-not-allowed",w&&"number"===n?"pr-2":null,A||V?"pr-0":null,w&&"number"===n&&t&&"text-right pr-2",$,q&&"0"!==s?.toString().trim()?"text-green-600 font-semibold":"",Y&&s?.toString().trim().startsWith("-")?"text-red-600 font-semibold":""),onFocus:()=>X(!0),onBlur:e=>{d&&h&&d&&h(e),X(!1)},value:s||"",defaultValue:l,onChange:f,id:c,name:u,required:g,disabled:y,ref:p,...G}),"password"===n&&m.jsx("span",{className:"cursor-pointer",onClick:()=>{Q(e=>"password"===e?"text":"password")},children:"password"===K?$y.eyeslash:$y.eye})]}),a&&m.jsx("p",{className:"text-danger text-xs font-normal",children:a})]})})})}function GR({value:e,label:t,placeholder:n,uuid:r,name:o,displayValue:a,valueType:i,item_unit:s}){const{mutate:l,isPending:u}=Ww();J();const[c,d]=T.useState(!1),[f,p]=T.useState({item_uuid:r,[o]:e});wn();const[h,g]=T.useState("");return m.jsxs(ES,{open:c,onOpenChange:d,children:[m.jsx(RS,{className:"flex items-center",children:m.jsx("button",{className:"hover:text-primary duration-150 underline disabled:no-underline disabled:hover:text-inherit",children:h?"selling_price"===o?Uy(+h):Wy(+h)+s:a})}),m.jsxs(NS,{align:"center",className:"shadow-[0_1px_2px_0px_#E4E5E73D,_0_12px_24px_0_#868C981F] space-y-2 bg-white rounded-xl p-3 w-[280px] relative before:absolute before:w-3 before:h-1.5 before:bg-white before:left-1/2 before:-translate-x-1/2 before:rotate-45 data-[side=bottom]:before:top-0 data-[side=top]:before:bottom-0",children:[m.jsx(qR,{type:i,value:f[o],label:t,placeholder:n,onChange:e=>{p(t=>({...t,[o]:e.target.value}))}}),m.jsxs("div",{className:"flex justify-end gap-2.5",children:[m.jsx(CS,{children:m.jsx(xE,{label:"Dismiss",className:"bg-gray-300 text-dark text-sm hover:bg-gray-300/90 font-medium",disabled:u})}),m.jsx(xE,{label:"Update",className:"text-sm font-medium",onClick:()=>{l({url:"/items/update_basic",payload:f},{onSuccess:()=>{g(f[o]),d(!1)},onError:()=>{g("")}})},loading:u})]})]})]})}T.forwardRef(({className:e,...t},n)=>m.jsx(zR,{ref:n,className:Ao("-mx-1 my-1 h-px bg-neutral-100 dark:bg-neutral-800",e),...t})).displayName=zR.displayName;const KR=[{accessorKey:"item_description",header:"item description",cell:({row:e})=>{const t=e.original;return m.jsxs("div",{className:"flex items-center gap-5",children:[m.jsx("div",{className:"w-[50px] h-[50px] rounded-2xl relative bg-gray-100",children:m.jsx("img",{src:t.item_image,alt:"item image",className:"rounded-2xl object-cover w-full h-full",draggable:!1})}),m.jsxs("div",{className:"space-y-1 max-w-[265px]",children:[m.jsx(ZR,{title:t.item_description,item_uuid:t.uuid,item_type_id:t.item_type_id,data:t.fullData}),m.jsxs("p",{className:"text-dark text-xs font-normal flex items-center gap-1",children:[m.jsx("span",{className:"uppercase whitespace-nowrap",children:t.sku}),t.barcode?.length>0?m.jsxs(m.Fragment,{children:[m.jsx("span",{children:"|"}),t.barcode?.[0]?.barcode,t.barcode?.length>1?m.jsxs("span",{className:"rounded bg-[#9747FF1A] px-[5px] flex items-center text-[#7239EA] font-semibold text-[11px] h-[18px]",children:["+",t.barcode?.length-1]}):null]}):null,t.expired?m.jsxs(m.Fragment,{children:[m.jsx("span",{children:"|"}),"Expired",m.jsx("span",{className:"rounded bg-danger_light px-[5px] flex items-center text-danger font-semibold text-[11px] h-[18px]",children:t.expired})]}):null,t.expiring?m.jsxs(m.Fragment,{children:[m.jsx("span",{children:"|"}),"Expiring",m.jsx("span",{className:"rounded bg-warning-light px-[5px] flex items-center text-warning font-semibold text-[11px] h-[18px]",children:t.expiring})]}):null]})]})]})}},{accessorKey:"quantity",header:()=>m.jsx("p",{children:"quantity"}),cell:({row:e})=>{const t=e.original;return m.jsxs(m.Fragment,{children:[m.jsx("div",{className:Ao("flex items-center",t.quantity<=0?"text-danger":Number(t.reorder_level)==t.quantity?"text-orange":null),children:m.jsx(GR,{label:"Edit item quantity",placeholder:"Enter quantity",uuid:t.uuid,name:"item_quantity",displayValue:Wy(t.quantity)+t.unit,value:t.quantity,valueType:"number",item_unit:t.unit})}),t.all_quantity===t.quantity?null:m.jsx("p",{className:"text-gray-700",children:Intl.NumberFormat().format(t.all_quantity??0)+t.unit})]})}},{accessorKey:"type",cell:({row:e})=>{const t=e.original;return m.jsx("p",{className:"capitalize",children:t.type})}},{accessorKey:"selling_price",header:"Selling Price (₦)",cell:({row:e})=>{const t=e.original;return m.jsx(GR,{label:"Edit selling price (₦)",placeholder:"Enter selling price",uuid:t.uuid,name:"selling_price",displayValue:Uy(t.selling_price??0),value:t.selling_price??0,valueType:"number"})}},{accessorKey:"categories",header:"categories/Tags",cell:({row:e})=>{const t=e.original;return m.jsxs(m.Fragment,{children:[" ",m.jsxs("div",{className:"flex items-center gap-2 capitalize",children:[t.categories&&t.categories?.length>0?t.categories?.[0]?.name:"...",t.categories.length>1?m.jsx(fv,{align:"center",fieldName:"Categories",trigger:m.jsxs("button",{className:"rounded bg-[#9747FF1A] px-[5px] flex items-center text-[#7239EA] font-semibold text-[11px] h-[18px]",children:["+",t.categories.length-1]}),children:m.jsx("ul",{className:"list-disc pl-4",children:t.categories.map((e,t)=>m.jsx("li",{children:e.name},t))})}):null]}),m.jsxs("div",{className:"text-gray-700 flex items-center gap-2 capitalize",children:[t.tags?.[0],t.tags?.length>1?m.jsx(fv,{align:"center",fieldName:"Tags",trigger:m.jsxs("button",{className:"rounded bg-[#9747FF1A] px-[5px] flex items-center text-[#7239EA] font-semibold text-[11px] h-[18px] border-primary",children:["+",t.tags.length-1]}),children:m.jsx("ul",{className:"list-disc pl-4",children:t.tags.map((e,t)=>m.jsx("li",{children:e},t))})}):null]})]})}},{accessorKey:"status",cell:({row:e})=>{const t=e.getValue("status");return m.jsx(pv,{status:t})}},{id:"actions",header:"actions",cell:({row:e})=>{const t=e.original;return m.jsx(QR,{item_uuid:t.uuid,item_type_id:t.item_type_id,data:t.fullData})}}],QR=({item_uuid:e,item_type_id:t,data:n})=>{const[r,o]=T.useState(null),a=()=>{o(null)},[i,s]=T.useState(!1),[l,u]=T.useState(!1),[c,d]=T.useState(!1),[f,p]=T.useState(!1),[h,g]=T.useState(!1),[y,v]=T.useState(!1),[b,w]=T.useState(!1),x=[{label:"view",icon:$y.eye_outline,action:()=>s(!0)},{label:"delete",icon:$y.trash,action:()=>p(!0)}];return m.jsxs(m.Fragment,{children:[m.jsxs(kd,{children:[m.jsx(_d,{asChild:!0,children:m.jsxs("button",{className:"bg-gray-100 rounded-md h-[30px] w-[90px] flex items-center justify-between p-2.5 font-semibold text-[10px] text-gray-500 hover:border duration-200",children:["Action"," ",m.jsx("svg",{width:"11",height:"6",viewBox:"0 0 11 6",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:m.jsx("path",{d:"M5.50855 5.49304C5.42081 5.49355 5.33383 5.47673 5.25261 5.44356C5.17138 5.41038 5.09751 5.3615 5.03521 5.29971L1.03521 1.29971C0.972726 1.23773 0.92313 1.164 0.889284 1.08276C0.855438 1.00152 0.838013 0.914383 0.838013 0.826375C0.838013 0.738367 0.855438 0.65123 0.889284 0.56999C0.92313 0.488751 0.972726 0.415017 1.03521 0.353041C1.16012 0.228874 1.32909 0.15918 1.50521 0.15918C1.68134 0.15918 1.8503 0.228874 1.97521 0.353041L5.50855 3.88637L9.03521 0.353041C9.16012 0.228874 9.32909 0.15918 9.50521 0.15918C9.68134 0.15918 9.8503 0.228874 9.97521 0.353041C10.0377 0.415017 10.0873 0.488751 10.1211 0.56999C10.155 0.65123 10.1724 0.738367 10.1724 0.826375C10.1724 0.914383 10.155 1.00152 10.1211 1.08276C10.0873 1.164 10.0377 1.23773 9.97521 1.29971L5.97521 5.29971C5.85104 5.42287 5.68344 5.4923 5.50855 5.49304Z",fill:"#202125"})})]})}),m.jsx(Ed,{align:"end",className:"flex flex-col gap-2.5 rounded-xl border-gray-200",children:x.map((e,t)=>m.jsxs(Rd,{className:`capitalize focus:bg-primary_light rounded-md focus:text-primary font-semibold text-gray-700 text-sm cursor-pointer px-[15px] flex items-center gap-[5px] ${t===x.length-1&&"text-danger focus:text-danger"}`,onMouseOver:()=>(e=>{o(e)})(t),onMouseOut:a,onClick:e.action,children:[D.cloneElement(e.icon,{fill:r===t?"#1868DB":"#5E6278"})," ",e.label]},t))})]}),m.jsx(FS,{isOpen:i,onClose:()=>s(!1),itemUUID:e}),m.jsx(CE,{isOpen:f,onClose:()=>p(!1),uuids:[e],single:!0})]})},ZR=({title:e,item_uuid:t,item_type_id:n,data:r})=>{const[o,a]=T.useState(!1),[i,s]=T.useState(!1),[l,u]=T.useState(!1);return m.jsxs(m.Fragment,{children:[m.jsx("button",{className:Ao("text-primary font-bold text-sm first-letter:uppercase truncate max-w-[265px] cursor-pointer",r.expired?"text-danger":""),title:e,onClick:()=>a(!0),children:e}),m.jsx(FS,{isOpen:o,onClose:()=>a(!1),itemUUID:t})]})};var XR,JR={};function eN(){if(XR)return JR;function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e(t)}XR=1,Object.defineProperty(JR,"__esModule",{value:!0}),JR.Collapse=void 0;var t,n=(t=f())&&t.__esModule?t:{default:t};function r(e,t,n){return t&&function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(e.prototype,t),e}function o(e,t){return o=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},o(e,t)}function a(t){var n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}();return function(){var r,o=s(t);if(n){var a=s(this).constructor;r=Reflect.construct(o,arguments,a)}else r=o.apply(this,arguments);return function(t,n){if(n&&("object"===e(n)||"function"==typeof n))return n;if(void 0!==n)throw new TypeError("Derived constructors may only return object or undefined");return i(t)}(this,r)}}function i(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function s(e){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},s(e)}function l(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var u=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&o(e,t)}(s,e);var t=a(s);function s(e){var n;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,s),l(i(n=t.call(this,e)),"timeout",void 0),l(i(n),"container",void 0),l(i(n),"content",void 0),l(i(n),"onResize",function(){if(clearTimeout(n.timeout),n.container&&n.content){var e=n.props,t=e.isOpened,r=e.checkTimeout,o=Math.floor(n.container.clientHeight),a=Math.floor(n.content.clientHeight),i=t&&Math.abs(a-o)<=1,s=!t&&Math.abs(o)<=1;i||s?n.onRest({isFullyOpened:i,isFullyClosed:s,isOpened:t,containerHeight:o,contentHeight:a}):(n.onWork({isFullyOpened:i,isFullyClosed:s,isOpened:t,containerHeight:o,contentHeight:a}),n.timeout=setTimeout(function(){return n.onResize()},r))}}),l(i(n),"onRest",function(e){var t=e.isFullyOpened,r=e.isFullyClosed,o=e.isOpened,a=e.containerHeight,i=e.contentHeight;if(n.container&&n.content){var s=o&&n.container.style.height==="".concat(i,"px"),l=!o&&"0px"===n.container.style.height;if(s||l){n.container.style.overflow=o?"initial":"hidden",n.container.style.height=o?"auto":"0px";var u=n.props.onRest;u&&u({isFullyOpened:t,isFullyClosed:r,isOpened:o,containerHeight:a,contentHeight:i})}}}),l(i(n),"onWork",function(e){var t=e.isFullyOpened,r=e.isFullyClosed,o=e.isOpened,a=e.containerHeight,i=e.contentHeight;if(n.container&&n.content){var s=o&&n.container.style.height==="".concat(i,"px"),l=!o&&"0px"===n.container.style.height;if(!s&&!l){n.container.style.overflow="hidden",n.container.style.height=o?"".concat(i,"px"):"0px";var u=n.props.onWork;u&&u({isFullyOpened:t,isFullyClosed:r,isOpened:o,containerHeight:a,contentHeight:i})}}}),l(i(n),"onRefContainer",function(e){n.container=e}),l(i(n),"onRefContent",function(e){n.content=e}),e.initialStyle?n.initialStyle=e.initialStyle:n.initialStyle=e.isOpened?{height:"auto",overflow:"initial"}:{height:"0px",overflow:"hidden"},n}return r(s,[{key:"componentDidMount",value:function(){this.onResize()}},{key:"shouldComponentUpdate",value:function(e){var t=this.props,n=t.theme,r=t.isOpened;return t.children!==e.children||r!==e.isOpened||Object.keys(n).some(function(t){return n[t]!==e.theme[t]})}},{key:"getSnapshotBeforeUpdate",value:function(){if(!this.container||!this.content)return null;if("auto"===this.container.style.height){var e=this.content.clientHeight;this.container.style.height="".concat(e,"px")}return null}},{key:"componentDidUpdate",value:function(){this.onResize()}},{key:"componentWillUnmount",value:function(){clearTimeout(this.timeout)}},{key:"render",value:function(){var e=this.props,t=e.theme,r=e.children,o=e.isOpened;return n.default.createElement("div",{ref:this.onRefContainer,className:t.collapse,style:this.initialStyle,"aria-hidden":!o},n.default.createElement("div",{ref:this.onRefContent,className:t.content},r))}}]),s}(n.default.Component);return JR.Collapse=u,l(u,"defaultProps",{theme:{collapse:"ReactCollapse--collapse",content:"ReactCollapse--content"},initialStyle:void 0,onRest:void 0,onWork:void 0,checkTimeout:50}),JR}var tN,nN,rN,oN={};function aN(){if(tN)return oN;function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e(t)}tN=1,Object.defineProperty(oN,"__esModule",{value:!0}),oN.UnmountClosed=void 0;var t,n=(t=f())&&t.__esModule?t:{default:t},r=eN(),o=["isOpened"],a=["isOpened"];function i(){return i=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},i.apply(this,arguments)}function s(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function l(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?s(Object(n),!0).forEach(function(t){g(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):s(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function u(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}function c(e,t,n){return t&&function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(e.prototype,t),e}function d(e,t){return d=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},d(e,t)}function p(t){var n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}();return function(){var r,o=m(t);if(n){var a=m(this).constructor;r=Reflect.construct(o,arguments,a)}else r=o.apply(this,arguments);return function(t,n){if(n&&("object"===e(n)||"function"==typeof n))return n;if(void 0!==n)throw new TypeError("Derived constructors may only return object or undefined");return h(t)}(this,r)}}function h(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function m(e){return m=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},m(e)}function g(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var y=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&d(e,t)}(s,e);var t=p(s);function s(e){var n;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,s),g(h(n=t.call(this,e)),"onWork",function(e){var t=e.isOpened,r=u(e,o);n.setState({isResting:!1,isOpened:t});var a=n.props.onWork;a&&a(l({isOpened:t},r))}),g(h(n),"onRest",function(e){var t=e.isOpened,r=u(e,a);n.setState({isResting:!0,isOpened:t,isInitialRender:!1});var o=n.props.onRest;o&&o(l({isOpened:t},r))}),g(h(n),"getInitialStyle",function(){var e=n.state,t=e.isOpened;return e.isInitialRender&&t?{height:"auto",overflow:"initial"}:{height:"0px",overflow:"hidden"}}),n.state={isResting:!0,isOpened:e.isOpened,isInitialRender:!0},n}return c(s,[{key:"componentDidUpdate",value:function(e){var t=this.props.isOpened;e.isOpened!==t&&this.setState({isResting:!1,isOpened:t,isInitialRender:!1})}},{key:"render",value:function(){var e=this.state,t=e.isResting,o=e.isOpened;return t&&!o?null:n.default.createElement(r.Collapse,i({},this.props,{initialStyle:this.getInitialStyle(),onWork:this.onWork,onRest:this.onRest}))}}]),s}(n.default.PureComponent);return oN.UnmountClosed=y,g(y,"defaultProps",{onWork:void 0,onRest:void 0}),oN}var iN=function(){if(rN)return nN;rN=1;var e=eN().Collapse,t=aN().UnmountClosed;return nN=t,t.Collapse=e,t.UnmountClosed=t,nN}();function sN({loading:e,data:t,meta:n}){const r=t?.otherscount?.map(e=>{const n=e.name;return{type:n,value:t?.result_array?.[n]?.total_selling_price??0}}),o=[{type:t?.result_array?.Retail?.pricegroup??t?.default,value:t?.result_array?.Retail?.total_selling_price??0},...r||[]],a=t?.otherscount?.map(e=>{const n=e.name;return{type:n,value:t?.result_array?.[n]?.total_profit??0}}),i=[{type:t?.result_array?.Retail?.pricegroup??t?.default,value:t?.result_array?.Retail?.total_profit??0},...a||[]],[s,l]=T.useState({type:o?.[0].type,value:o?.[0].value}),[u,c]=T.useState({type:i?.[0].type,value:i?.[0].value});D.useEffect(()=>{l({type:o?.[0].type,value:o?.[0].value}),c({type:i?.[0].type,value:i?.[0].value})},[e]);const d=[{label:"Total No. of Unique Item",count:Intl.NumberFormat().format(n?.total??0),desc:`With ${t?.unit_count??0} unit(s)`,icon:m.jsx("div",{className:"shrink-0 rounded-lg bg-[#EFF5FF] w-12 h-12 flex items-center justify-center border border-[#EDEEF1]",children:$y.cube})},{label:"Total Cost Price",count:Uy(t?.result_array?.Retail?.total_cost??0),desc:"Takes into Account FIFO & LIFO ",icon:m.jsx("div",{className:"shrink-0 rounded-lg bg-[#F9DFDD] w-12 h-12 flex items-center justify-center border border-[#EDEEF1]",children:D.cloneElement($y.price_tag,{fill:"#ED7400"})})},{label:"Total Selling Price",count:Uy(s.value),desc:m.jsxs("p",{className:"flex gap-2 items-center flex-wrap",children:["Showing ",s.type," price"," ",m.jsxs(kd,{children:[m.jsx(_d,{asChild:!0,children:m.jsxs("button",{className:"rounded-lg h-8 flex items-center justify-between p-3 font-semibold text-xs text-gray-600 outline-none border border-gray-300 gap-2.5 capitalize bg-[#F9F9F9]",children:["change",m.jsx("span",{className:"rotate-90",children:$y.arrow})]})}),m.jsx(Ed,{align:"start",className:"flex flex-col gap-2.5 rounded-xl border-gray-200 py-2.5 w-[210px]",children:o.map((e,t)=>m.jsx(Rd,{className:Ao("capitalize focus:bg-primary_light rounded-md focus:text-primary font-semibold text-sm cursor-pointer px-[15px] flex items-center gap-[5px] \n \n ",e.type===s.type?"bg-primary_light text-primary":null),onClick:()=>l(t=>({...t,value:e.value,type:e.type})),children:e.type},t))})]})]}),icon:m.jsx("div",{className:"shrink-0 rounded-lg bg-[#D8CDF4] w-12 h-12 flex items-center justify-center border border-[#EDEEF1]",children:D.cloneElement($y.price_tag,{fill:"#9747FF"})})},{label:"Profit to be made",count:Uy(u.value),desc:m.jsxs("p",{className:"flex gap-2 items-center flex-wrap",children:["Showing ",u.type," price"," ",m.jsxs(kd,{children:[m.jsx(_d,{asChild:!0,children:m.jsxs("button",{className:"rounded-lg h-8 flex items-center justify-between p-3 font-semibold text-xs text-gray-600 outline-none border border-gray-300 gap-2.5 capitalize bg-[#F9F9F9]",children:["change",m.jsx("span",{className:"rotate-90",children:$y.arrow})]})}),m.jsx(Ed,{align:"start",className:"flex flex-col gap-2.5 rounded-xl border-gray-200 py-2.5 w-[210px]",children:i.map((e,t)=>m.jsx(Rd,{className:Ao("capitalize focus:bg-primary_light rounded-md focus:text-primary font-semibold text-sm cursor-pointer px-[15px] flex items-center gap-[5px] \n \n ",e.type===u.type?"bg-primary_light text-primary":null),onClick:()=>c(t=>({...t,value:e.value,type:e.type})),children:e.type},t))})]})]}),icon:m.jsx("div",{className:"shrink-0 rounded-lg bg-[#C6E3D2] w-12 h-12 flex items-center justify-center border border-[#EDEEF1]",children:D.cloneElement($y.price_tag,{fill:"#378C5A"})})}],[f,p]=T.useState(!1);return m.jsxs(qx,{className:"bg-[#F6F8FA] p-2.5 flex flex-col",children:[m.jsxs("div",{className:"flex justify-between",children:[m.jsx("h1",{className:"capitalize text-dark font-semibold text-lg",children:"Items overview"}),m.jsxs("button",{className:"rounded-lg h-8 flex items-center justify-between p-3 font-semibold text-xs text-gray-600 outline-none border border-gray-300 gap-2.5 capitalize bg-white",onClick:()=>p(!f),children:[f?"Close":"Open"," ",m.jsx("span",{className:"rotate-90",children:$y.arrow})]})]}),m.jsx(iN.Collapse,{isOpened:f,children:m.jsx("div",{className:"flex flex-wrap gap-2.5 mt-3",children:d.map((t,n)=>m.jsxs("div",{className:Ao("border rounded-xl border-[#E4E7EC] p-4 flex flex-col relative bg-right-bottom bg-no-repeat flex-auto",0===n?"bg-[#E4EEFA] bg-[url('/assets/images/ecstacy1.svg')]":1===n?"bg-[#FAEAE9] bg-[url('/assets/images/ecstacy2.svg')]":2===n?"bg-[#EEE9FA] bg-[url('/assets/images/ecstacy3.svg')]":3===n?"bg-[#EBF5EF] bg-[url('/assets/images/ecstacy4.svg')]":null),children:[m.jsxs("div",{className:"flex justify-between gap-1",children:[m.jsx("h1",{className:"text-dark text-sm font-medium",children:t.label}),m.jsx("div",{className:"shrink-0",children:t.icon})]}),m.jsxs("div",{className:"flex flex-col gap-1",children:[e?m.jsx(Vo,{className:"w-28 h-6 rounded"}):m.jsx("h1",{className:Ao("text-dark font-bold text-[29px] truncate",n===d.length-1&&u.value<0?"text-danger":null),title:t.count,children:t.count}),m.jsx("div",{className:"text-gray-700 text-sm font-medium ",children:t.desc})]})]},n))})})]})}function lN({placeholder:e,className:t,inputClass:n,...r}){return m.jsxs("div",{className:Ao("h-12 border border-gray-300 rounded-md w-[320px] flex",t),children:[m.jsx("span",{className:"bg-gray-200 w-[38px] flex items-center justify-center shrink-0 rounded-l-[6px] ",children:$y.magnifier}),m.jsx("input",{type:"search",placeholder:e,className:"w-full px-3 text-dark text-sm font-medium bg-transparent outline-none rounded-r-[6px]",...r})]})}function uN(e,t){return e===t}function cN(e,t,n){var r=uN,o=T.useRef(e),a=T.useState({})[1],i=function(e,t,n,r){var o=this,a=T.useRef(null),i=T.useRef(0),s=T.useRef(0),l=T.useRef(null),u=T.useRef([]),c=T.useRef(),d=T.useRef(),f=T.useRef(e),p=T.useRef(!0);f.current=e;var h="undefined"!=typeof window,m=!t&&0!==t&&h;if("function"!=typeof e)throw new TypeError("Expected a function");t=+t||0;var g=!!(n=n||{}).leading,y=!("trailing"in n)||!!n.trailing,v="maxWait"in n,b="debounceOnServer"in n&&!!n.debounceOnServer,w=v?Math.max(+n.maxWait||0,t):null;T.useEffect(function(){return p.current=!0,function(){p.current=!1}},[]);var x=T.useMemo(function(){var e=function(e){var t=u.current,n=c.current;return u.current=c.current=null,i.current=e,s.current=s.current||e,d.current=f.current.apply(n,t)},n=function(e,t){m&&cancelAnimationFrame(l.current),l.current=m?requestAnimationFrame(e):setTimeout(e,t)},x=function(e){if(!p.current)return!1;var n=e-a.current;return!a.current||n>=t||n<0||v&&e-i.current>=w},C=function(t){return l.current=null,y&&u.current?e(t):(u.current=c.current=null,d.current)},S=function e(){var r=Date.now();if(g&&s.current===i.current&&k(),x(r))return C(r);if(p.current){var o=t-(r-a.current),l=v?Math.min(o,w-(r-i.current)):o;n(e,l)}},k=function(){r&&r({})},_=function(){if(h||b){var r=Date.now(),s=x(r);if(u.current=[].slice.call(arguments),c.current=o,a.current=r,s){if(!l.current&&p.current)return i.current=a.current,n(S,t),g?e(a.current):d.current;if(v)return n(S,t),e(a.current)}return l.current||n(S,t),d.current}};return _.cancel=function(){l.current&&(m?cancelAnimationFrame(l.current):clearTimeout(l.current)),i.current=0,u.current=a.current=c.current=l.current=null},_.isPending=function(){return!!l.current},_.flush=function(){return l.current?C(Date.now()):d.current},_},[g,v,t,w,y,m,h,b,r]);return x}(T.useCallback(function(e){o.current=e,a({})},[a]),t,n,a),s=T.useRef(e);return r(s.current,e)||(i(e),s.current=e),[o.current,i]}function dN({placeholder:e,searchPlaceholder:t,options:n=[],showMultiSelectValues:r=!0,values:o,onChange:a,className:i,showCheckMark:s=!0,label:l,labelClass:u,required:c,info:d,optional:f,actionLabel:p,actionLabelAction:h,actionLabelInfo:g,removeSelectedValue:y,removeTag:v,loading:b,showCount:w,error:x}){const[C,S]=T.useState(!1),[k,_]=T.useState(0),E=T.useRef(null);T.useEffect(()=>{const e=()=>{E.current&&_(E?.current?.offsetWidth)};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[E]);const R=e=>{const t=o?.includes(e)?o?.filter(t=>t!==e):[...o||[],e];a&&a(t)};T.useEffect(()=>{y&&R(y)},[y]);const[N,j]=T.useState(null),P=e=>{j(t=>t===e?null:e)},O=e=>{for(let t of n){if(t.value===e)return t.label;if(t.subOptions){const n=t.subOptions.find(t=>t.value===e);if(n)return n.label}}return null};return m.jsx("div",{ref:E,children:b?m.jsx(Vo,{className:"w-full h-[48px]"}):m.jsxs("div",{className:Ao("flex flex-col gap-2.5",i),children:[m.jsxs("div",{className:"flex justify-between gap-2 flex-wrap",children:[l&&m.jsxs("label",{className:Ao("text-black flex items-center gap-1 first-letter:uppercase text-sm font-medium",u),children:[l," ",c?m.jsx("span",{className:"text-[#E12D39]",children:l&&"*"}):f?m.jsx("span",{className:"text-[#B5B5B5] font-normal",children:"(optional)"}):null,d&&m.jsx(fv,{fieldName:l,children:m.jsx("p",{className:"font-normal first-letter:uppercase",children:d})})]}),p&&m.jsxs("button",{onClick:h,className:"text-primary flex items-center gap-1 first-letter:uppercase text-sm font-medium",children:[p,g&&m.jsx(fv,{fieldName:l,children:m.jsx("p",{className:"font-normal first-letter:uppercase",children:g})})]})]}),m.jsxs(ES,{modal:!0,open:C,onOpenChange:S,children:[m.jsx(RS,{asChild:!0,children:m.jsxs(PS,{variant:"outline",role:"combobox","aria-expanded":C,className:Ao(`w-full h-[48px] justify-between border focus:border-primary border-neutral-200 bg-white hover:bg-white hover:border-[#BFD7FE] ${x&&"!border-danger"}`,r?"h-auto py-3":null,i),children:[m.jsx("div",{className:"flex gap-2 text-[#5E6278] justify-start first-letter:uppercase flex-wrap",children:o?.length&&r?o.map((e,t)=>m.jsxs("div",{onClick:()=>{v||R(e),P(e)},className:"px-2 py-1 text-black flex items-center justify-between rounded gap-2 border bg-slate-200 text-xs font-medium",children:[m.jsx("span",{className:"flex justify-start text-start flex-wrap gap-2 whitespace-normal",children:O(e)}),m.jsx("span",{className:"",children:m.jsx("svg",{width:"9",height:"9",viewBox:"0 0 9 9",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:m.jsx("path",{d:"M5.44001 4.49978L7.83334 2.12644C7.96064 1.99737 8.03146 1.82301 8.03021 1.64173C8.02896 1.46044 7.95575 1.28708 7.82667 1.15978C7.6976 1.03247 7.52324 0.961657 7.34196 0.962907C7.16067 0.964157 6.98731 1.03737 6.86001 1.16644L4.50001 3.55978L2.14001 1.21311C2.0151 1.08894 1.84613 1.01925 1.67001 1.01925C1.49388 1.01925 1.32492 1.08894 1.20001 1.21311C1.13752 1.27509 1.08793 1.34882 1.05408 1.43006C1.02023 1.5113 1.00281 1.59844 1.00281 1.68644C1.00281 1.77445 1.02023 1.86159 1.05408 1.94283C1.08793 2.02407 1.13752 2.0978 1.20001 2.15978L3.56001 4.49978L1.16667 6.87311C1.03937 7.00218 0.968554 7.17654 0.969804 7.35782C0.971054 7.53911 1.04427 7.71247 1.17334 7.83978C1.30241 7.96708 1.47677 8.0379 1.65805 8.03665C1.83934 8.0354 2.0127 7.96218 2.14001 7.83311L4.50001 5.43978L6.86001 7.78644C6.98492 7.91061 7.15388 7.98031 7.33001 7.98031C7.50613 7.98031 7.6751 7.91061 7.80001 7.78644C7.86249 7.72447 7.91209 7.65073 7.94594 7.56949C7.97978 7.48826 7.99721 7.40112 7.99721 7.31311C7.99721 7.2251 7.97978 7.13797 7.94594 7.05673C7.91209 6.97549 7.86249 6.90175 7.80001 6.83978L5.44001 4.49978Z",fill:"black"})})})]},t)):!r&&w&&o.length>0?`${o.length} ${l} selected`:e??"Select..."}),m.jsx(wd,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),m.jsx(NS,{align:"start",style:{width:k},className:"w-[480px] p-0 bg-white rounded-xl border-gray-200",children:m.jsxs(KC,{children:[m.jsx(QC,{className:"placeholder:text-xs",placeholder:t??"Search..."}),m.jsx(XC,{children:"No result found."}),m.jsx(JC,{children:m.jsx(ZC,{className:"",children:n?.map((e,t)=>m.jsxs("div",{children:[m.jsxs(eS,{value:"string"==typeof e.label?e.label:e.searchId,className:`first-letter:uppercase mb-1 focus:bg-primary_light w-full rounded-md focus:text-primary hover:text-primary font-semibold text-gray-700 text-sm cursor-pointer ${o?.includes(e.value)&&"bg-primary_light text-primary"}`,onSelect:()=>{R(e.value),e?.subOptions&&e?.subOptions?.length>0&&P(e.value)},children:[s&&m.jsx(gd,{className:Ao("mr-2 h-4 w-4",o?.includes(e.value)?"opacity-100":"opacity-0")}),m.jsxs("p",{className:"flex justify-between w-full",children:[e.label,e?.subOptions&&e?.subOptions?.length>0&&m.jsx(yd,{className:"ml-2 h-5 w-5 font-bold shrink-0 opacity-50"})]})]}),N===e.value&&e?.subOptions&&e?.subOptions?.map((e,t)=>m.jsxs(eS,{value:"string"==typeof e.label?e.label:e.searchId,className:`first-letter:uppercase mb-1 focus:bg-primary_light w-full rounded-md focus:text-primary hover:text-primary font-semibold text-gray-700 text-sm cursor-pointer pl-6 ${o?.includes(e.value)&&"bg-primary_light text-primary"}`,onSelect:()=>{R(e.value)},children:[s&&m.jsx(gd,{className:Ao("mr-2 h-4 w-4",o?.includes(e.value)?"opacity-100":"opacity-0")}),e.label]},t))]},t))})})]})})]}),x&&m.jsx("p",{className:"text-danger text-xs font-normal",children:x})]})})}var fN="ScrollArea",[pN,hN]=qo(fN),[mN,gN]=pN(fN),yN=T.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:o,scrollHideDelay:a=600,...i}=e,[s,l]=T.useState(null),[u,c]=T.useState(null),[d,f]=T.useState(null),[p,h]=T.useState(null),[g,y]=T.useState(null),[v,b]=T.useState(0),[w,x]=T.useState(0),[C,S]=T.useState(!1),[k,_]=T.useState(!1),E=Yo(t,e=>l(e)),R=ua(o);return m.jsx(mN,{scope:n,type:r,dir:R,scrollHideDelay:a,scrollArea:s,viewport:u,onViewportChange:c,content:d,onContentChange:f,scrollbarX:p,onScrollbarXChange:h,scrollbarXEnabled:C,onScrollbarXEnabledChange:S,scrollbarY:g,onScrollbarYChange:y,scrollbarYEnabled:k,onScrollbarYEnabledChange:_,onCornerWidthChange:b,onCornerHeightChange:x,children:m.jsx(aa.div,{dir:R,...i,ref:E,style:{position:"relative","--radix-scroll-area-corner-width":v+"px","--radix-scroll-area-corner-height":w+"px",...e.style}})})});yN.displayName=fN;var vN="ScrollAreaViewport",bN=T.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...a}=e,i=gN(vN,n),s=Yo(t,T.useRef(null),i.onViewportChange);return m.jsxs(m.Fragment,{children:[m.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:o}),m.jsx(aa.div,{"data-radix-scroll-area-viewport":"",...a,ref:s,style:{overflowX:i.scrollbarXEnabled?"scroll":"hidden",overflowY:i.scrollbarYEnabled?"scroll":"hidden",...e.style},children:m.jsx("div",{ref:i.onContentChange,style:{minWidth:"100%",display:"table"},children:r})})]})});bN.displayName=vN;var wN="ScrollAreaScrollbar",xN=T.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=gN(wN,e.__scopeScrollArea),{onScrollbarXEnabledChange:a,onScrollbarYEnabledChange:i}=o,s="horizontal"===e.orientation;return T.useEffect(()=>(s?a(!0):i(!0),()=>{s?a(!1):i(!1)}),[s,a,i]),"hover"===o.type?m.jsx(CN,{...r,ref:t,forceMount:n}):"scroll"===o.type?m.jsx(SN,{...r,ref:t,forceMount:n}):"auto"===o.type?m.jsx(kN,{...r,ref:t,forceMount:n}):"always"===o.type?m.jsx(_N,{...r,ref:t}):null});xN.displayName=wN;var CN=T.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=gN(wN,e.__scopeScrollArea),[a,i]=T.useState(!1);return T.useEffect(()=>{const e=o.scrollArea;let t=0;if(e){const n=()=>{window.clearTimeout(t),i(!0)},r=()=>{t=window.setTimeout(()=>i(!1),o.scrollHideDelay)};return e.addEventListener("pointerenter",n),e.addEventListener("pointerleave",r),()=>{window.clearTimeout(t),e.removeEventListener("pointerenter",n),e.removeEventListener("pointerleave",r)}}},[o.scrollArea,o.scrollHideDelay]),m.jsx(Qs,{present:n||a,children:m.jsx(kN,{"data-state":a?"visible":"hidden",...r,ref:t})})}),SN=T.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=gN(wN,e.__scopeScrollArea),a="horizontal"===e.orientation,i=UN(()=>l("SCROLL_END"),100),[s,l]=(u="hidden",c={hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}},T.useReducer((e,t)=>c[e][t]??e,u));var u,c;return T.useEffect(()=>{if("idle"===s){const e=window.setTimeout(()=>l("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(e)}},[s,o.scrollHideDelay,l]),T.useEffect(()=>{const e=o.viewport,t=a?"scrollLeft":"scrollTop";if(e){let n=e[t];const r=()=>{const r=e[t];n!==r&&(l("SCROLL"),i()),n=r};return e.addEventListener("scroll",r),()=>e.removeEventListener("scroll",r)}},[o.viewport,a,l,i]),m.jsx(Qs,{present:n||"hidden"!==s,children:m.jsx(_N,{"data-state":"hidden"===s?"hidden":"visible",...r,ref:t,onPointerEnter:Bo(e.onPointerEnter,()=>l("POINTER_ENTER")),onPointerLeave:Bo(e.onPointerLeave,()=>l("POINTER_LEAVE"))})})}),kN=T.forwardRef((e,t)=>{const n=gN(wN,e.__scopeScrollArea),{forceMount:r,...o}=e,[a,i]=T.useState(!1),s="horizontal"===e.orientation,l=UN(()=>{if(n.viewport){const e=n.viewport.offsetWidth<n.viewport.scrollWidth,t=n.viewport.offsetHeight<n.viewport.scrollHeight;i(s?e:t)}},10);return WN(n.viewport,l),WN(n.content,l),m.jsx(Qs,{present:r||a,children:m.jsx(_N,{"data-state":a?"visible":"hidden",...o,ref:t})})}),_N=T.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=gN(wN,e.__scopeScrollArea),a=T.useRef(null),i=T.useRef(0),[s,l]=T.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),u=IN(s.viewport,s.content),c={...r,sizes:s,onSizesChange:l,hasThumb:Boolean(u>0&&u<1),onThumbChange:e=>a.current=e,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:e=>i.current=e};function d(e,t){return function(e,t,n,r="ltr"){const o=zN(n),a=o/2,i=t||a,s=o-i,l=n.scrollbar.paddingStart+i,u=n.scrollbar.size-n.scrollbar.paddingEnd-s,c=n.content-n.viewport,d="ltr"===r?[0,c]:[-1*c,0];return HN([l,u],d)(e)}(e,i.current,s,t)}return"horizontal"===n?m.jsx(EN,{...c,ref:t,onThumbPositionChange:()=>{if(o.viewport&&a.current){const e=$N(o.viewport.scrollLeft,s,o.dir);a.current.style.transform=`translate3d(${e}px, 0, 0)`}},onWheelScroll:e=>{o.viewport&&(o.viewport.scrollLeft=e)},onDragScroll:e=>{o.viewport&&(o.viewport.scrollLeft=d(e,o.dir))}}):"vertical"===n?m.jsx(RN,{...c,ref:t,onThumbPositionChange:()=>{if(o.viewport&&a.current){const e=$N(o.viewport.scrollTop,s);a.current.style.transform=`translate3d(0, ${e}px, 0)`}},onWheelScroll:e=>{o.viewport&&(o.viewport.scrollTop=e)},onDragScroll:e=>{o.viewport&&(o.viewport.scrollTop=d(e))}}):null}),EN=T.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,a=gN(wN,e.__scopeScrollArea),[i,s]=T.useState(),l=T.useRef(null),u=Yo(t,l,a.onScrollbarXChange);return T.useEffect(()=>{l.current&&s(getComputedStyle(l.current))},[l]),m.jsx(PN,{"data-orientation":"horizontal",...o,ref:u,sizes:n,style:{bottom:0,left:"rtl"===a.dir?"var(--radix-scroll-area-corner-width)":0,right:"ltr"===a.dir?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":zN(n)+"px",...e.style},onThumbPointerDown:t=>e.onThumbPointerDown(t.x),onDragScroll:t=>e.onDragScroll(t.x),onWheelScroll:(t,n)=>{if(a.viewport){const r=a.viewport.scrollLeft+t.deltaX;e.onWheelScroll(r),VN(r,n)&&t.preventDefault()}},onResize:()=>{l.current&&a.viewport&&i&&r({content:a.viewport.scrollWidth,viewport:a.viewport.offsetWidth,scrollbar:{size:l.current.clientWidth,paddingStart:LN(i.paddingLeft),paddingEnd:LN(i.paddingRight)}})}})}),RN=T.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,a=gN(wN,e.__scopeScrollArea),[i,s]=T.useState(),l=T.useRef(null),u=Yo(t,l,a.onScrollbarYChange);return T.useEffect(()=>{l.current&&s(getComputedStyle(l.current))},[l]),m.jsx(PN,{"data-orientation":"vertical",...o,ref:u,sizes:n,style:{top:0,right:"ltr"===a.dir?0:void 0,left:"rtl"===a.dir?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":zN(n)+"px",...e.style},onThumbPointerDown:t=>e.onThumbPointerDown(t.y),onDragScroll:t=>e.onDragScroll(t.y),onWheelScroll:(t,n)=>{if(a.viewport){const r=a.viewport.scrollTop+t.deltaY;e.onWheelScroll(r),VN(r,n)&&t.preventDefault()}},onResize:()=>{l.current&&a.viewport&&i&&r({content:a.viewport.scrollHeight,viewport:a.viewport.offsetHeight,scrollbar:{size:l.current.clientHeight,paddingStart:LN(i.paddingTop),paddingEnd:LN(i.paddingBottom)}})}})}),[NN,jN]=pN(wN),PN=T.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:o,onThumbChange:a,onThumbPointerUp:i,onThumbPointerDown:s,onThumbPositionChange:l,onDragScroll:u,onWheelScroll:c,onResize:d,...f}=e,p=gN(wN,n),[h,g]=T.useState(null),y=Yo(t,e=>g(e)),v=T.useRef(null),b=T.useRef(""),w=p.viewport,x=r.content-r.viewport,C=ca(c),S=ca(l),k=UN(d,10);function _(e){if(v.current){const t=e.clientX-v.current.left,n=e.clientY-v.current.top;u({x:t,y:n})}}return T.useEffect(()=>{const e=e=>{const t=e.target,n=h?.contains(t);n&&C(e,x)};return document.addEventListener("wheel",e,{passive:!1}),()=>document.removeEventListener("wheel",e,{passive:!1})},[w,h,x,C]),T.useEffect(S,[r,S]),WN(h,k),WN(p.content,k),m.jsx(NN,{scope:n,scrollbar:h,hasThumb:o,onThumbChange:ca(a),onThumbPointerUp:ca(i),onThumbPositionChange:S,onThumbPointerDown:ca(s),children:m.jsx(aa.div,{...f,ref:y,style:{position:"absolute",...f.style},onPointerDown:Bo(e.onPointerDown,e=>{if(0===e.button){e.target.setPointerCapture(e.pointerId),v.current=h.getBoundingClientRect(),b.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",p.viewport&&(p.viewport.style.scrollBehavior="auto"),_(e)}}),onPointerMove:Bo(e.onPointerMove,_),onPointerUp:Bo(e.onPointerUp,e=>{const t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),document.body.style.webkitUserSelect=b.current,p.viewport&&(p.viewport.style.scrollBehavior=""),v.current=null})})})}),ON="ScrollAreaThumb",MN=T.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=jN(ON,e.__scopeScrollArea);return m.jsx(Qs,{present:n||o.hasThumb,children:m.jsx(TN,{ref:t,...r})})}),TN=T.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,a=gN(ON,n),i=jN(ON,n),{onThumbPositionChange:s}=i,l=Yo(t,e=>i.onThumbChange(e)),u=T.useRef(void 0),c=UN(()=>{u.current&&(u.current(),u.current=void 0)},100);return T.useEffect(()=>{const e=a.viewport;if(e){const t=()=>{if(c(),!u.current){const t=BN(e,s);u.current=t,s()}};return s(),e.addEventListener("scroll",t),()=>e.removeEventListener("scroll",t)}},[a.viewport,c,s]),m.jsx(aa.div,{"data-state":i.hasThumb?"visible":"hidden",...o,ref:l,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...r},onPointerDownCapture:Bo(e.onPointerDownCapture,e=>{const t=e.target.getBoundingClientRect(),n=e.clientX-t.left,r=e.clientY-t.top;i.onThumbPointerDown({x:n,y:r})}),onPointerUp:Bo(e.onPointerUp,i.onThumbPointerUp)})});MN.displayName=ON;var DN="ScrollAreaCorner",AN=T.forwardRef((e,t)=>{const n=gN(DN,e.__scopeScrollArea),r=Boolean(n.scrollbarX&&n.scrollbarY);return"scroll"!==n.type&&r?m.jsx(FN,{...e,ref:t}):null});AN.displayName=DN;var FN=T.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=gN(DN,n),[a,i]=T.useState(0),[s,l]=T.useState(0),u=Boolean(a&&s);return WN(o.scrollbarX,()=>{const e=o.scrollbarX?.offsetHeight||0;o.onCornerHeightChange(e),l(e)}),WN(o.scrollbarY,()=>{const e=o.scrollbarY?.offsetWidth||0;o.onCornerWidthChange(e),i(e)}),u?m.jsx(aa.div,{...r,ref:t,style:{width:a,height:s,position:"absolute",right:"ltr"===o.dir?0:void 0,left:"rtl"===o.dir?0:void 0,bottom:0,...e.style}}):null});function LN(e){return e?parseInt(e,10):0}function IN(e,t){const n=e/t;return isNaN(n)?0:n}function zN(e){const t=IN(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function $N(e,t,n="ltr"){const r=zN(t),o=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,a=t.scrollbar.size-o,i=t.content-t.viewport,s=a-r,l=SE(e,"ltr"===n?[0,i]:[-1*i,0]);return HN([0,i],[0,s])(l)}function HN(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function VN(e,t){return e>0&&e<t}var BN=(e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},r=0;return function o(){const a={left:e.scrollLeft,top:e.scrollTop},i=n.left!==a.left,s=n.top!==a.top;(i||s)&&t(),n=a,r=window.requestAnimationFrame(o)}(),()=>window.cancelAnimationFrame(r)};function UN(e,t){const n=ca(e),r=T.useRef(0);return T.useEffect(()=>()=>window.clearTimeout(r.current),[]),T.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function WN(e,t){const n=ca(t);Ko(()=>{let t=0;if(e){const r=new ResizeObserver(()=>{cancelAnimationFrame(t),t=window.requestAnimationFrame(n)});return r.observe(e),()=>{window.cancelAnimationFrame(t),r.unobserve(e)}}},[e,n])}var YN=yN,qN=bN,GN=AN;const KN=T.forwardRef(({className:e,children:t,...n},r)=>m.jsxs(YN,{ref:r,className:Ao("relative overflow-hidden",e),...n,children:[m.jsx(qN,{className:"h-full w-full rounded-[inherit]",children:t}),m.jsx(QN,{}),m.jsx(GN,{})]}));KN.displayName=YN.displayName;const QN=T.forwardRef(({className:e,orientation:t="vertical",...n},r)=>m.jsx(xN,{ref:r,orientation:t,className:Ao("flex touch-none select-none transition-colors","vertical"===t&&"h-full w-2.5 border-l border-l-transparent p-[1px]","horizontal"===t&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",e),...n,children:m.jsx(MN,{className:"relative flex-1 rounded-full bg-neutral-200 dark:bg-neutral-800"})}));function ZN({placeholder:e,searchPlaceholder:t,options:n=[],showMultiSelectValues:r=!0,values:o,onChange:a,className:i,showCheckMark:s=!0,label:l,labelClass:u,required:c,info:d,optional:f,actionLabel:p,actionLabelAction:h,actionLabelInfo:g,removeSelectedValue:y,removeTag:v,loading:b,showCount:w,error:x,showError:C,onChangeSearch:S,searching:k,contentStyle:_,disabled:E}){const[R,N]=T.useState(!1),[j,P]=T.useState(0),O=T.useRef(null);T.useEffect(()=>{const e=()=>{O.current&&P(O?.current?.offsetWidth)};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]);const M=o?.filter(e=>""!==e),D=e=>{const t=M?.includes(e)?M?.filter(t=>t!==e):[...M||[],e];a&&a(t)};return T.useEffect(()=>{y&&D(y)},[y]),m.jsx(m.Fragment,{children:b?m.jsx(Vo,{className:"w-full h-[48px]"}):m.jsxs("div",{className:Ao("flex flex-col gap-2.5",i),children:[m.jsxs("div",{className:"flex justify-between gap-2 flex-wrap",children:[l&&m.jsxs("label",{className:Ao("text-black flex items-center gap-1 first-letter:uppercase text-sm font-medium",u),children:[l," ",c?m.jsx("span",{className:"text-[#E12D39]",children:l&&"*"}):f?m.jsx("span",{className:"text-[#B5B5B5] font-normal",children:"(optional)"}):null,d&&m.jsx(fv,{fieldName:l,children:m.jsx("p",{className:"font-normal first-letter:uppercase",children:d})})]}),p&&m.jsxs("button",{onClick:h,className:"text-primary flex items-center gap-1 first-letter:uppercase text-sm font-medium",children:[p,g&&m.jsx(fv,{fieldName:p,children:m.jsx("p",{className:"font-normal first-letter:uppercase text-left",children:g})})]})]}),m.jsxs(ES,{modal:!0,open:R,onOpenChange:N,children:[m.jsx(RS,{disabled:E,asChild:!0,children:m.jsxs(PS,{ref:O,variant:"outline",role:"combobox","aria-expanded":R,className:Ao(`w-full h-[48px] justify-between border focus:border-primary border-neutral-200 bg-white hover:bg-white hover:border-[#BFD7FE] ${(x||C)&&"!border-danger"}`,r?"h-auto py-3":null,i),children:[m.jsx("div",{className:"flex gap-2 text-[#5E6278] justify-start first-letter:uppercase flex-wrap",children:M?.length>0&&r?M?.map((e,t)=>m.jsxs("div",{onClick:()=>{!v&&D(e)},className:"px-2 py-1 text-black flex items-center justify-between rounded gap-2 border bg-slate-200 text-xs font-medium",children:[n?.[0].searchId?n?.find(t=>t.value===e)?.searchId:n?.find(t=>t.value===e)?.label,m.jsx("span",{className:"",children:m.jsx("svg",{width:"9",height:"9",viewBox:"0 0 9 9",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:m.jsx("path",{d:"M5.44001 4.49978L7.83334 2.12644C7.96064 1.99737 8.03146 1.82301 8.03021 1.64173C8.02896 1.46044 7.95575 1.28708 7.82667 1.15978C7.6976 1.03247 7.52324 0.961657 7.34196 0.962907C7.16067 0.964157 6.98731 1.03737 6.86001 1.16644L4.50001 3.55978L2.14001 1.21311C2.0151 1.08894 1.84613 1.01925 1.67001 1.01925C1.49388 1.01925 1.32492 1.08894 1.20001 1.21311C1.13752 1.27509 1.08793 1.34882 1.05408 1.43006C1.02023 1.5113 1.00281 1.59844 1.00281 1.68644C1.00281 1.77445 1.02023 1.86159 1.05408 1.94283C1.08793 2.02407 1.13752 2.0978 1.20001 2.15978L3.56001 4.49978L1.16667 6.87311C1.03937 7.00218 0.968554 7.17654 0.969804 7.35782C0.971054 7.53911 1.04427 7.71247 1.17334 7.83978C1.30241 7.96708 1.47677 8.0379 1.65805 8.03665C1.83934 8.0354 2.0127 7.96218 2.14001 7.83311L4.50001 5.43978L6.86001 7.78644C6.98492 7.91061 7.15388 7.98031 7.33001 7.98031C7.50613 7.98031 7.6751 7.91061 7.80001 7.78644C7.86249 7.72447 7.91209 7.65073 7.94594 7.56949C7.97978 7.48826 7.99721 7.40112 7.99721 7.31311C7.99721 7.2251 7.97978 7.13797 7.94594 7.05673C7.91209 6.97549 7.86249 6.90175 7.80001 6.83978L5.44001 4.49978Z",fill:"black"})})})]},t)):!r&&w&&o.length>0?`${M.length} ${l} selected`:e??"Select..."}),m.jsx(wd,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),m.jsx(NS,{align:"start",style:{width:j},className:Ao("w-[480px] p-0 bg-white rounded-xl border-gray-200",_),children:m.jsx(KN,{children:m.jsxs(KC,{children:[m.jsx(QC,{onChangeCapture:S,className:"placeholder:text-xs",placeholder:t??"Search..."}),k?m.jsx("div",{className:"flex flex-col gap-2 p-2",children:[1,2,3].map((e,t)=>m.jsx(Vo,{className:"h-9 rounded-md"},t))}):m.jsx(XC,{children:"No result found."}),m.jsx(JC,{children:m.jsx(ZC,{className:"",children:n?.map(e=>m.jsxs(eS,{value:"string"==typeof e.label?e.label:e.searchId,className:`first-letter:uppercase mb-1 focus:bg-primary_light w-full rounded-md focus:text-primary hover:text-primary font-semibold text-gray-700 text-sm cursor-pointer ${o?.includes(e.value)&&"bg-primary_light text-primary"}`,onSelect:()=>{D(e.value)},children:[s&&m.jsx(gd,{className:Ao("mr-2 h-4 w-4",o?.includes(e.value)?"opacity-100":"opacity-0")}),e.label]},e.value))})})]})})})]})]})})}function XN({isOpen:e,onClose:t}){const{mutate:n,isPending:r}=Ww(),[o,a]=T.useState({name:"",description:""}),i=(e,t)=>{a({...o,[e]:t})},s=wn();return m.jsx(LS,{isOpen:e,onClose:t,title:"New Tag",className:"w-[425px] pb-5",children:m.jsxs("form",{className:"space-y-5",onSubmit:e=>{e.preventDefault(),n({url:"/inventory_metas/tags/create",payload:o},{onSuccess:()=>{s.invalidateQueries({queryKey:["itemtags"]}),t&&t()}})},action:"",children:[m.jsxs("div",{className:"px-5 space-y-5",children:[m.jsx(qR,{type:"text",placeholder:"e.g Men Fashion",info:"Enter a name for the tag. Tags help categorize items and make them easier to search for.",label:"Tag name ",required:!0,labelClass:"text-dark",value:o.name,onChange:e=>i("name",e.target.value)}),m.jsx(qR,{type:"text-area",placeholder:"Text here",info:"Provide a description for the tag. This helps clarify its purpose and how it should be used for categorizing items.",label:"Description",labelClass:"text-dark",rows:3,required:!0,value:o.description,textAreaOnChange:e=>i("description",e.target.value)})]}),m.jsx(tC,{}),m.jsxs("div",{className:"flex justify-end gap-2.5 px-5",children:[m.jsx(xE,{label:"Dismiss",className:"px-4 bg-gray-300 text-gray-900 hover:bg-gray-400",onClick:t,disabled:r}),m.jsx(xE,{loading:r,label:"Create",className:"px-4",type:"submit"})]})]})})}function JN({isOpen:e,onClose:t}){const{mutate:n,isPending:r}=Ww(),o=wn(),{apiKey:a}=Rn(),{data:i}=Uw(["categories",a],"/inventory_metas/categories",{enabled:!!a}),{data:s}=Uw(["itemunits",a],"/inventory_metas/units",{enabled:!!a}),{data:l}=Uw(["itemtags",a],"/inventory_metas/tags",{enabled:!!a}),{data:u}=Uw(["itemtypes",a],"/inventory_metas/types",{enabled:!!a}),c=i?.data?.data?.map(e=>({label:e.name,value:e.uuid,subOptions:e.subCategories.map(e=>({label:e.name,value:e.uuid}))}))||[],d=s?.data?.data?.map(e=>({label:e.name,value:e.uuid}))||[],f=l?.data?.data?.map(e=>({label:e.name,value:e.uuid})),p=u?.data?.data?.filter(e=>"products"===e.name||"services"===e.name).map(e=>({label:e.name,value:e.uuid}))||[],[h,g]=T.useState(""),[y,v]=D.useState([]),[b,w]=T.useState(p?.[0]?.value||"");T.useEffect(()=>{const e=p.find(e=>e?.value===b)?.label||"";g(e)},[b]);const[x,C]=T.useState([]),[S,k]=T.useState([{name:"",itemunit_id:d?.[0]?.value||"",quantity:"",cost_price:"",selling_price:"",barcode:""}]),_=(e,t,n)=>{const r=[...S];r[n]={...r[n],[e]:t},k(r)},E={itemtype_id:b,itemcategory_id:y,tags:x,items:S},R=["Item name","Item unit",..."services"!==h?["Quantity","Barcode"]:[],"Cost price (₦)","Selling price (₦)"],[N,j]=T.useState(!1);return m.jsxs(LS,{isOpen:e,onClose:t,title:"Quick create multiple items",className:"max-w-[1024px]",children:[m.jsxs("div",{className:"px-5 space-y-7 pb-5",children:[m.jsxs("div",{className:"grid grid-cols-3 gap-5 bg-gray-100 rounded-xl p-4",children:[m.jsx(OS,{label:"Item type",options:p,placeholder:"select item type",value:b,onValueChange:e=>w(e),required:!0,info:"Select the type of item you're creating (e.g., product, service, variations, kits ). This classification helps determine how the item is managed, displayed, or fulfilled."}),m.jsx(dN,{placeholder:"select categories",label:"Category",options:c,values:y,onChange:e=>v(e),showMultiSelectValues:!1,showCount:!0,info:"Select the category that best describes this item(s) (e.g., electronics, clothing, food). Categorizing items helps in organizing inventory and simplifies product management."}),m.jsx(ZN,{label:"Item tag",placeholder:"Select item tags",info:"Enter relevant keywords or labels for this item(s). Tags help in categorizing and making the item easier to find through search filters.",labelClass:"text-dark text-sm",options:f,values:x,onChange:C,showSearch:!0,showCount:!0,showMultiSelectValues:!1,actionLabel:"Create a new tag",actionLabelInfo:"Enter a new tag to help categorize the item. Tags are useful for organizing and making items easily searchable by specific attributes or keywords.",actionLabelAction:()=>j(!0)})]}),m.jsxs("div",{className:"space-y-2 overflow-auto",children:[m.jsxs("table",{className:"table-auto w-full border-separate border-spacing-4",children:[m.jsx("thead",{children:m.jsx("tr",{children:R.map((e,t)=>m.jsx("th",{className:"text-dark text-sm font-medium text-left",children:e},t))})}),m.jsx("tbody",{className:"text-dark text-[15px] ",children:S.map((e,t)=>m.jsxs("tr",{children:[m.jsx("td",{className:"",children:m.jsx(qR,{type:"text",placeholder:"Enter item name",value:e.name,onChange:e=>_("name",e.target.value,t)})}),m.jsx("td",{children:m.jsx(OS,{options:d,placeholder:"select item unit",value:e.itemunit_id,onValueChange:e=>_("itemunit_id",e,t)})}),"services"!==h?m.jsxs(m.Fragment,{children:[m.jsx("td",{className:"",children:m.jsx(qR,{type:"number",placeholder:"0",value:e.quantity,onChange:e=>_("quantity",e.target.value,t)})}),m.jsx("td",{className:"",children:m.jsx(qR,{type:"number",placeholder:"Enter barcode",value:e.barcode,onChange:e=>_("barcode",e.target.value,t)})})]}):null,m.jsx("td",{className:"",children:m.jsx(qR,{type:"number",placeholder:"0.00",value:e.cost_price,onChange:e=>_("cost_price",e.target.value,t)})}),m.jsx("td",{className:"",children:m.jsx(qR,{type:"number",placeholder:"0.00",value:e.selling_price,onChange:e=>_("selling_price",e.target.value,t)})}),m.jsx("td",{className:"",children:m.jsx("button",{onClick:()=>(e=>{const t=S.filter((t,n)=>n!==e);k(t)})(t),disabled:1===S.length,className:"disabled:cursor-not-allowed disabled:opacity-70",children:$y.trash2})})]},t))})]}),m.jsx(xE,{mode:"text",label:"Add more",left_addon:$y.plus_squared2,onClick:()=>{k(e=>[...e,{name:"",itemunit_id:d?.[0]?.value||"",quantity:"",cost_price:"",selling_price:"",barcode:""}])},className:"font-medium text-sm ml-4"})]})]}),m.jsxs("div",{className:"flex justify-between items-center px-5 sticky bottom-0 bg-white py-5 border-t ",children:[m.jsxs("button",{className:"text-primary text-sm font-medium flex items-center gap-1",children:[$y.question," Need help?"]}),m.jsxs("div",{className:"flex justify-end gap-2.5",children:[m.jsx(xE,{label:"Cancel",className:"bg-[#F1F1F2] text-[#181C32] hover:bg-[#F1F1F2]/90",onClick:t}),m.jsx(xE,{label:"Create Items",onClick:()=>{n({url:"/items/create_multiple",payload:E},{onSuccess:()=>{o.invalidateQueries({queryKey:["items"]}),t&&t()}})},loading:r})]})]}),m.jsx(XN,{isOpen:N,onClose:()=>j(!1)})]})}QN.displayName=xN.displayName;const ej="https://unpkg.com/@simpoobusiness/sdk/dist/simpoo-sdk.css";let tj={};function nj(e){tj=e}const rj={inventory:({showStats:e=!0})=>{const[t,n]=D.useState(),{currentPage:r,perview:o}=ne(e=>e.app),[a,i]=T.useState("all"),[s,l]=T.useState(!1),[u,c]=T.useState("all"),[d,f]=T.useState(""),[p]=cN(d,1e3),{apiKey:h}=Rn(),{data:g,isFetching:y}=Uw(["items",o.toString(),r?.toString(),a,p,h],p?`/items/search?page=${r}&paginate=${o}&param=${p}&for=${a}&filter=all`:`/items?page=${r}&paginate=${o}&status=${a}`,{enabled:!!h}),v=g?.data?.[0]||[],b=v?.data?.map(e=>({item_description:e?.name,all_quantity:+e?.all_quantity,quantity:+e?.quantity,type:e?.item_type?.name,selling_price:+e?.selling_price,categories:e?.category||[],tags:e?.item_tags?.map(e=>e.name)||[],status:e?.status?"published":"draft",sku:e?.sku,item_image:e.images?.length>0?e.images?.[0].image:Kx,barcode:e?.barcode,expired:e?.expired,expiring:e?.expiring,unit:e?.item_unit,uuid:e?.uuid,item_type_id:e?.item_type?.uuid,reorder_level:e?.reorder_level,fullData:e}))||[],{data:w,isFetching:x}=Uw(["items-tab"],"/items/count",{enabled:!!h}),C=w?.data,S=[{label:"all",count:C?.all||0,action:()=>i("all")},{label:"published",count:C?.published||0,action:()=>i("published")},{label:"out of stock",count:C?.out_of_stock||0,action:()=>i("out_of_stock")},{label:"draft",count:C?.draft||0,action:()=>i("draft")},{label:"expiring",count:C?.expiring||0,action:()=>i("expiring")},{label:"expired",count:C?.expired||0,action:()=>i("expired")}],[k,_]=T.useState(!1);return m.jsxs(qx,{className:"px-4 py-6 flex flex-col gap-8",children:[m.jsx(AS,{tabs:S,loading:y}),m.jsxs("div",{className:" flex items-center justify-between flex-wrap gap-4",children:[m.jsxs("div",{className:"flex items-center gap-2.5",children:[m.jsx(lN,{placeholder:"Search Item name, barcode or sku",value:d,onChange:e=>f(e.target.value)}),y?m.jsx(Vo,{className:"w-20 h-6"}):m.jsxs("p",{className:"text-dark text-sm font-medium",children:[v?.meta?.total??0," ",m.jsx("span",{className:"text-gray-700",children:"Items"})]})]}),m.jsx("div",{className:"flex gap-4",children:m.jsx(xE,{label:"Create New",left_addon:$y.plus_squared,className:"!font-medium !text-sm !h-12",onClick:()=>_(!0)})})]}),e?m.jsx(sN,{loading:y,data:g?.data?.[1],meta:v?.meta}):null,m.jsx(By,{loading:y,columns:KR,data:b,emptyData:0===b.length,emptyProps:{header:"No item yet",subText:"Add new item to start managing your inventory."},tHeadClass:"whitespace-nowrap",tbCellClass:"text-dark font-semibold",meta:v?.meta}),k?m.jsx(JN,{isOpen:k,onClose:()=>_(!1)}):null]})}};function oj(e,t,n={}){!function(){if(!document.querySelector(`link[href="${ej}"]`)){const e=document.createElement("link");e.rel="stylesheet",e.href=ej,document.head.appendChild(e)}}();const r=rj[e];if(!r)return void console.error(`SimpooSDK: Widget "${e}" not found.`);const o=document.querySelector(t);if(!o)throw new Error(`Container "${t}" not found!`);M.createRoot(o).render(m.jsx(Nn,{apiKey:tj.apiKey||"",children:m.jsx(r,{...n})}))}"undefined"!=typeof window&&(window.SimpooSDK={init:nj,renderWidget:oj}),e.init=nj,e.renderWidget=oj});
224
224
  //# sourceMappingURL=simpoo-sdk.js.map