"use strict";(globalThis.webpackChunk_kenyaemr_esm_stock_management_app=globalThis.webpackChunk_kenyaemr_esm_stock_management_app||[]).push([[41,422],{23041:(e,t,a)=>{a.r(t),a.d(t,{default:()=>z,infinite:()=>h,unstable_serialize:()=>m});var r=a(16072),n=a(92177),l=a(27804),s=a(35430),i=a(14993),o=a(19888);const c=()=>{},u=c(),f=Object,p=e=>e===u,_=new WeakMap,g=(e,t)=>f.prototype.toString.call(e)===`[object ${t}]`;let y=0;const d=e=>{const t=typeof e,a=g(e,"Date"),r=g(e,"RegExp"),n=g(e,"Object");let l,s;if(f(e)!==e||a||r)l=a?e.toJSON():"symbol"==t?e.toString():"string"==t?JSON.stringify(e):""+e;else{if(l=_.get(e),l)return l;if(l=++y+"~",_.set(e,l),Array.isArray(e)){for(l="@",s=0;s<e.length;s++)l+=d(e[s])+",";_.set(e,l)}if(n){l="#";const t=f.keys(e).sort();for(;!p(s=t.pop());)p(e[s])||(l+=s+":"+d(e[s])+",");_.set(e,l)}}return l},b=e=>(e=>{if("function"==typeof e)try{e=e()}catch(t){e=""}const t=e;return[e="string"==typeof e?e:(Array.isArray(e)?e.length:e)?d(e):"",t]})(e?e(0,null):null)[0],m=e=>s.q+b(e),k=Promise.resolve(),h=e=>(t,a,n)=>{const i=(0,r.useRef)(!1),{cache:c,initialSize:u=1,revalidateAll:f=!1,persistSize:p=!1,revalidateFirstPage:_=!0,revalidateOnMount:g=!1,parallel:y=!1}=n,[,,,d]=l.b.get(l.c);let m;try{m=b(t),m&&(m=s.q+m)}catch(e){}const[h,z,v]=(0,l.z)(c,m),S=(0,r.useCallback)(()=>(0,l.e)(h()._l)?u:h()._l,[c,m,u]);(0,o.useSyncExternalStore)((0,r.useCallback)(e=>m?v(m,()=>{e()}):()=>{},[c,m]),S,S);const w=(0,r.useCallback)(()=>{const e=h()._l;return(0,l.e)(e)?u:e},[m,u]),C=(0,r.useRef)(w());(0,l.u)(()=>{i.current?m&&z({_l:p?C.current:w()}):i.current=!0},[m,c]);const A=g&&!i.current,O=e(m,async e=>{const r=h()._i,s=h()._r;z({_r:l.U});const i=[],o=w(),[u]=(0,l.z)(c,e),p=u().data,g=[];let b=null;for(let e=0;e<o;++e){const[o,u]=(0,l.s)(t(e,y?null:b));if(!o)break;const[m,k]=(0,l.z)(c,o);let h=m().data;const z=f||r||(0,l.e)(h)||_&&!e&&!(0,l.e)(p)||A||p&&!(0,l.e)(p[e])&&!n.compare(p[e],h);if(a&&("function"==typeof s?s(h,u):z)){const t=async()=>{if(o in d){const e=d[o];delete d[o],h=await e}else h=await a(u);k({data:h,_k:u}),i[e]=h};y?g.push(t):await t()}else i[e]=h;y||(b=h)}return y&&await Promise.all(g.map(e=>e())),z({_i:l.U}),i},n),j=(0,r.useCallback)(function(e,t){const a="boolean"==typeof t?{revalidate:t}:t||{},r=!1!==a.revalidate;return m?(r&&((0,l.e)(e)?z({_i:!0,_r:a.revalidate}):z({_i:!1,_r:a.revalidate})),arguments.length?O.mutate(e,{...a,revalidate:r}):O.mutate()):k},[m,c]),P=(0,r.useCallback)(e=>{if(!m)return k;const[,a]=(0,l.z)(c,m);let r;if((0,l.a)(e)?r=e(w()):"number"==typeof e&&(r=e),"number"!=typeof r)return k;a({_l:r}),C.current=r;const n=[],[s]=(0,l.z)(c,m);let i=null;for(let e=0;e<r;++e){const[a]=(0,l.s)(t(e,i)),[r]=(0,l.z)(c,a),o=a?r().data:l.U;if((0,l.e)(o))return j(s().data);n.push(o),i=o}return j(n)},[m,c,j,w]);return{size:w(),setSize:P,mutate:j,get data(){return O.data},get error(){return O.error},get isValidating(){return O.isValidating},get isLoading(){return O.isLoading}}},z=(0,i.Ht)(n.Ay,h)}}]);