import{j as e,T as w,d as Qu,I as s6,an as G,B as m,aj as i6,ay as N6,az as V6,aA as q6,i as d6,ah as cu,aR as t0,aS as n0,aT as a0,aU as o0,aV as s0,aW as l0,bk as c0,ak as C0,al as l6,am as T6,aD as i0,a1 as d0,b3 as h0,N as A0,b as c6,a_ as p0}from"./mui-vendor-D_SVL-Dx.js";import{L as Y,j as O,h as D,A as au,a0 as M,C as iu,O as Cu,G as d,S as P,v as hu,ad as M6,$ as e6,dP as O6,u as h6,X as A6,r as p6,c as $6,b as Yu,V as C6,W as U6,go as g0,a3 as F0}from"./index-D80MdVQn.js";import{r as c,b as L6}from"./react-vendor-CmFgShSM.js";import{I as H6,f as z6}from"./toBase64-UDzdrM-n.js";import{a as ou,u as uu,f as H}from"./redux-vendor-CfkcHgWN.js";import{r as K6}from"./resizeImage-Csf2MO3w.js";import{S as u6}from"./ShowImage-DxnwAx1k.js";import{V as G6,v as y0}from"./VetFarmEditTrafficCode-C5Hod_My.js";import{R as Y6,a as g6}from"./index.esm-C1-dCPnj.js";import{R as r6}from"./ResponsiveTable-bUYl0qDM.js";import{d as f0}from"./AddCircleOutline-5cdNoXZy.js";import{i as Q6}from"./isValidIndexWeight-C_ik-uYa.js";import{c as du}from"./checkPathStartsWith-DedybDvj.js";import{V as x0}from"./SlaughterEnterNoneReciept-By4AAznT.js";import{g as E0}from"./getDocumentStates-X7qXjbQL.js";import{d as v0}from"./Tune-BBzxV8DK.js";import{d as R0}from"./Delete-CIwpNviU.js";import{S as j0}from"./SimpleTable-tm4uaKUf.js";import{N as Xu}from"./NumberFormatCustom-BXcOcGV4.js";import{F as S0}from"./FileUploader-DvFCJiD0.js";const W6=ou("KILL_HOUSE_ASSIGNMENT_INFORMATION_AGGREGATE_LOAD_SERVICE",async(u,{dispatch:r})=>{try{r(Y());const{data:o,status:n}=await O.put("kill_house_assignment_information_aggregate_load/0/",u);return r(D()),{data:o,status:n}}catch(o){return r(D()),{error:o.response.data.result}}}),P6=({isSingular:u,item:r,updateTable:o})=>{var p;const n=uu(),[i]=c.useContext(au),[y,F]=c.useState([]),[h,A]=c.useState(),{slaughterGetAggregateLoadInformation:R}=H(g=>g.slaughterSlice),C=(g,f)=>{var _;if(g[0]){const x=(_=g[0])==null?void 0:_.file;K6(x,B=>{const L=z6(B);A(L)})}F(g)};return c.useEffect(()=>{h&&(u?n(W6({image:h,bar_key:r.key,role:M()})).then(g=>{var f,_;A(null),F([]),n(iu()),g.payload.error?i({vertical:"top",horizontal:"center",msg:g.payload.error,severity:"error"}):(i({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}),(f=r==null?void 0:r.assingmentInformation)!=null&&f.realQuantity&&((_=r==null?void 0:r.assingmentInformation)!=null&&_.carWeightWithLoadImage)&&n(Cu({title:"بار به تب مدیریت بارها منتقل شد."})),o(1))}):n(W6({image:h,bar_keys:R==null?void 0:R.map(g=>g.key),role:M()})).then(g=>{var f,_;A(null),F([]),n(iu()),g.payload.error?i({vertical:"top",horizontal:"center",msg:g.payload.error,severity:"error"}):(i({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}),o(1),(f=r==null?void 0:r.assingmentInformation)!=null&&f.realQuantity&&((_=r==null?void 0:r.assingmentInformation)!=null&&_.carWeightWithLoadImage)&&n(Cu({title:"بار به تب مدیریت بارها منتقل شد."})))}))},[h,y]),e.jsxs(d,{width:"100%",children:[!u&&e.jsxs(d,{container:!0,gap:P.TINY,mb:P.SMALL,children:[e.jsx(w,{color:"error",children:"نکته:"}),e.jsx(w,{children:"این سند برای تمامی بارهایی که فاقد سند هستند ثبت خواهد شد."})]}),e.jsx(d,{mt:P.SMALL,children:e.jsx(H6,{onChange:C,images:y,maxNumber:1,showImages:!1,title:(p=r==null?void 0:r.assingmentInformation)!=null&&p.carWeightWithLoadImage?"ویرایش":"ثبت"})})]})},_0=ou("SALUGHTER_AGGREGATE_QUANTITY_SERVICE",async(u,{dispatch:r})=>{try{r(Y());const{data:o,status:n}=await O.post("kill_house_assignment_information_aggregate_load/",u);return r(D()),{data:o,status:n}}catch(o){return r(D()),{error:o.response.data.result}}}),I0=ou("PROVINCE_GET_LOAD_INFO_DASHBOARD",async(u,{dispatch:r})=>{try{r(Y());const{data:o,status:n}=await O.get("dashboard_enter_load_information",{params:{date1:u.selectedDate1,date2:u.selectedDate2,role:M(),filter:"search",value:u.text?u.text:"",role_key:u.role_key||""}});return r(D()),{data:o,status:n}}catch(o){return r(D()),{error:o.response.data}}}),ru={PROVINCE_OPERATOR:"ProvinceOperator",SUPER_ADMIN:"SuperAdmin",ADMIN_X:"AdminX",SUPPORTER:"Supporter",VET_SUPERVISOR:"VetSupervisor",VET_FARM:"VetFarm",CITY_VET:"CityVet"},t6={FREEZING:"انجماد",EXPORT:"صادرات",NORMAL:"عادی"},X6=10,Z=1,k0=u=>u?A6(new Date(u),"yyyy/MM/dd"):"-",n6=u=>u?`${u.toLocaleString()} ﷼`:"-",K=u=>u?u.toLocaleString():"-",Zu=(u,r)=>u&&r?`${u} (${r})`:"-",w0=u=>{var r,o;return(r=u==null?void 0:u.poultryRequest)!=null&&r.freezing?t6.FREEZING:(o=u==null?void 0:u.poultryRequest)!=null&&o.export?t6.EXPORT:t6.NORMAL},b0=u=>{const{textValue:r,role:o,date1:n,date2:i,page:y,perPage:F,roleKey:h}=u,A="kill_house_request_aggregate_load/",R=new URLSearchParams({check:"",search:"filter",value:r||"",role:o||"",date1:n||"",date2:i||"",page:y||Z,page_size:F||X6});return h&&R.append("role_key",h),`${A}?${R.toString()}`},D0=u=>{const{baseURL:r,date1:o,date2:n,role:i,roleKey:y,userKey:F,textValue:h}=u,A=new URLSearchParams({start:o||"",end:n||"",role:i||"",state:"bar_pending",key:F||"",search:"filter",value:h||""});return y&&A.append("role_key",y),`${r}bar_excel/?${A.toString()}`},B0=(u,r)=>{if([ru.PROVINCE_OPERATOR,ru.SUPER_ADMIN,ru.ADMIN_X,ru.SUPPORTER,ru.VET_SUPERVISOR].includes(u))return!0;const n=[ru.VET_FARM,ru.CITY_VET];return r.trash!==!0&&r.assignmentStateArchive==="pending"&&!(r!=null&&r.clearanceCode)&&n.includes(u)},Ie=()=>{const[,,u,r,o,n]=c.useContext(au),i=H(j=>j.userSlice.userProfile.key),y=H(j=>j.userSlice.selectedSubUser),F=uu(),[h,A]=c.useState([]),[R,C]=c.useState(0),[p,g]=c.useState(X6),[f,_]=c.useState(""),[x,B]=c.useState(Z),[L,l]=c.useState([]),[I,su]=c.useState([]),s=c.useMemo(()=>M(),[]),$=c.useMemo(()=>du("slaughter")&&(y==null?void 0:y.key)||"",[y==null?void 0:y.key]);c.useEffect(()=>{const j=hu(new Date).format("YYYY-MM-DD");r(j),n(j)},[r,n]);const k=c.useCallback(async(j=x)=>{F(Y());try{const t=b0({textValue:f,role:s,date1:u,date2:o,page:j,perPage:p,roleKey:$}),W=await O.get(t);A(W.data.results),C(W.data.count)}catch(t){console.error("Error fetching data:",t)}finally{F(D())}},[f,s,u,o,p,$,x,F]),b=c.useCallback(()=>{F(I0({selectedDate1:u,selectedDate2:o,text:f,role_key:$})).then(j=>{su(j.payload.data)})},[u,o,f,$,F]),E=j=>{k(j),B(j)},S=j=>{g(j),B(Z)},V=async j=>{j.preventDefault(),await k(Z),b(),B(Z)},z=j=>{_(j.target.value)},U=j=>{j&&r(hu(j).format("YYYY-MM-DD"))},q=j=>{j&&n(hu(j).format("YYYY-MM-DD"))},Q=c.useCallback(j=>{F(Cu({title:"ثبت اطلاعات بار",content:e.jsx(T0,{item:j,fetchApiData:k})}))},[F,k]);c.useEffect(()=>{k(Z),b()},[]),c.useEffect(()=>{k(Z),b(),B(Z)},[u,o,p,$]),c.useEffect(()=>{const j=h==null?void 0:h.map((t,W)=>{var a,T,nu,gu,Fu,yu,fu,xu,Eu,vu,Ru,ju,Su,_u,Iu,ku,wu,bu,Du,Bu,Tu,Lu,Wu,Pu,Nu,Vu,qu,Mu,Ou,$u,Uu,Hu,zu,Ku;const pu=x===Z?W+1:W+p*(x-1)+1,v=!!((a=t==null?void 0:t.assignmentInfo)!=null&&a.realQuantity);return[pu,v?e.jsxs(d,{container:!0,direction:"column",children:[e.jsxs(d,{children:[K((T=t==null?void 0:t.assignmentInfo)==null?void 0:T.realQuantity)," قطعه"]}),e.jsxs(d,{children:[K((nu=t==null?void 0:t.assignmentInfo)==null?void 0:nu.netWeight)," کیلوگرم"]}),e.jsx(Qu,{title:"ویرایش اطلاعات بار",placement:"top",children:e.jsx(s6,{color:"primary",onClick:()=>Q(t),size:"small",children:e.jsx(M6,{fontSize:"small"})})})]},t.key):e.jsx(Qu,{title:"ثبت اطلاعات بار",placement:"top",children:e.jsx(s6,{color:"primary",onClick:()=>Q(t),size:"small",children:e.jsx(f0,{fontSize:"small"})})},t.key),(gu=t==null?void 0:t.assingmentInformation)!=null&&gu.carWeightWithLoadImage?e.jsxs(d,{children:[e.jsx(u6,{src:(Fu=t==null?void 0:t.assingmentInformation)==null?void 0:Fu.carWeightWithLoadImage}),e.jsx(P6,{isSingular:!0,item:t,updateTable:k})]},t.key):e.jsx(P6,{isSingular:!0,item:t,updateTable:k},t.key),e.jsx(u6,{src:(yu=t==null?void 0:t.assignmentInfo)==null?void 0:yu.imageWithoutBar},`empty-${W}`),e.jsx(u6,{src:(fu=t==null?void 0:t.assignmentInfo)==null?void 0:fu.imageWithBar},`full-${W}`),e.jsx(w,{style:{fontSize:"13px",color:t!=null&&t.trash?"red":"black"},children:t.barCode},`barcode-${W}`),e.jsx(G6,{updateTable:k,killHouseRequestKey:t.key,trafficCode:t==null?void 0:t.trafficCode,isEditable:B0(s,t)},`traffic-${W}`),n6(t==null?void 0:t.amount),k0((xu=t==null?void 0:t.poultryRequest)==null?void 0:xu.sendDate),Zu((Eu=t.killhouseUser)==null?void 0:Eu.name,(ju=(Ru=(vu=t.killhouseUser)==null?void 0:vu.killHouseOperator)==null?void 0:Ru.user)==null?void 0:ju.mobile),t!=null&&t.killer?Zu((Su=t.killer)==null?void 0:Su.name,(ku=(Iu=(_u=t.killer)==null?void 0:_u.killHouseOperator)==null?void 0:Iu.user)==null?void 0:ku.mobile):"-",Zu((bu=(wu=t.poultryRequest)==null?void 0:wu.poultry)==null?void 0:bu.unitName,(Tu=(Bu=(Du=t.poultryRequest)==null?void 0:Du.poultry)==null?void 0:Bu.user)==null?void 0:Tu.mobile),((Lu=t==null?void 0:t.poultryRequest)==null?void 0:Lu.age)||"-",K(t.quantity),K((Wu=t==null?void 0:t.weightInfo)==null?void 0:Wu.weight),n6((Pu=t==null?void 0:t.poultryRequest)==null?void 0:Pu.amount),n6((Nu=t==null?void 0:t.weightInfo)==null?void 0:Nu.killHousePrice),`${((qu=(Vu=t.addCar)==null?void 0:Vu.driver)==null?void 0:qu.typeCar)||""} ${((Ou=(Mu=t.addCar)==null?void 0:Mu.driver)==null?void 0:Ou.pelak)||""}`.trim()||"-",Zu((Uu=($u=t.addCar)==null?void 0:$u.driver)==null?void 0:Uu.driverName,(zu=(Hu=t.addCar)==null?void 0:Hu.driver)==null?void 0:zu.driverMobile),K(t.vetAcceptedRealQuantity),K(t.vetAcceptedRealWeight),((Ku=t==null?void 0:t.poultryRequest)==null?void 0:Ku.orderCode)||"-",(t==null?void 0:t.finalBarState)||"-",w0(t)]});l(j||[])},[h,x,p,s,Q,k]);const N=["تعداد بار","مجموع تعداد اولیه","مجموع وزن اولیه (کیلوگرم)","مجموع تعداد تحویلی دامپزشک","مجموع وزن تحویلی دامپزشک (کیلوگرم)"],lu=["ردیف","تعداد/وزن خالص","سند","بارنامه خالی","بارنامه پر","کدبار","کد بهداشتی حمل و نقل","قیمت مرغ زنده‌ی بار","تاریخ کشتار","خریدار","کشتارکن اختصاصی","مرغدار","سن مرغ","تعداد اولیه","وزن اولیه بار (کیلوگرم)","قیمت مرغدار","قیمت کشتارگاه","ماشین","راننده","تحویلی دامپزشک (قطعه)","وزن تحویلی دامپزشک (کیلوگرم)","کدسفارش کشتار","وضعیت بار","نوع کشتار"],tu=[K(I==null?void 0:I.lenKillHouseRequest),K(I==null?void 0:I.firstQuantity),K(I==null?void 0:I.firstWeight),K(I==null?void 0:I.vetAcceptedRealQuantity),K(I==null?void 0:I.vetAcceptedRealWeight)],Au=D0({baseURL:O.defaults.baseURL,date1:u,date2:o,role:s,roleKey:$,userKey:i,textValue:f});return e.jsxs(d,{container:!0,justifyContent:"center",children:[e.jsx(d,{container:!0,alignItems:"start",justifyContent:"space-between",gap:2,paddingTop:2,mb:1,children:e.jsxs(d,{container:!0,alignItems:"center",gap:P.SMALL,children:[e.jsx(d,{children:e.jsx(e6,{label:"از تاریخ",renderInput:j=>e.jsx(G,{size:"small",style:{width:"160px"},...j}),value:u,onChange:U})}),e.jsx(d,{children:e.jsx(e6,{label:"تا تاریخ",renderInput:j=>e.jsx(G,{size:"small",style:{width:"160px"},...j}),value:o,onChange:q})}),e.jsxs("form",{onSubmit:V,children:[e.jsx(G,{size:"small",autoComplete:"off",label:"جستجو",variant:"outlined",style:{width:250},onChange:z,value:f}),e.jsx(m,{type:"submit",endIcon:e.jsx(Y6,{}),children:"جستجو"})]}),!!(h!=null&&h.length)&&e.jsx(d,{children:e.jsx(Qu,{title:"خروجی اکسل",children:e.jsx("a",{href:Au,rel:"noreferrer",children:e.jsx(m,{color:"success",children:e.jsx(g6,{size:32})})})})})]})}),e.jsx(d,{container:!0,mt:2,mb:4,isDashboard:!0,xs:12,children:e.jsx(r6,{noPagination:!0,isDashboard:!0,columns:N,data:[tu],title:"خلاصه اطلاعات"})}),e.jsx(r6,{data:L,columns:lu,handlePageChange:E,totalRows:R,page:x,perPage:p,handlePerRowsChange:S,title:"وارد کردن اطلاعات بار"})]})},T0=({item:u,fetchApiData:r})=>{const[o]=c.useContext(au),{weightRange:n}=H(p=>p.provinceSlice),i=uu(),y=H(p=>p.userSlice.selectedSubUser),F=c.useMemo(()=>M(),[]);c.useEffect(()=>{i(O6({role_key:du("slaughter")&&(y==null?void 0:y.key)||""}))},[y==null?void 0:y.key]);const h=p=>/^\d+$/.test(p),A=p=>{const{maximumLoadVolumeReduction:g,maximumLoadVolumeIncrease:f}=(u==null?void 0:u.killhouseUser)||{},_=(u==null?void 0:u.acceptedRealQuantity)||0;return g!==0&&p<_*(1-g/100)?{isValid:!1,message:"حجم وارد شده با مجوز حداکثر افزایش/کاهش ورود اطلاعات بار مطابقت ندارد!"}:f!==0&&p>_*(1+f/100)?{isValid:!1,message:"حجم وارد شده با مجوز حداکثر افزایش/کاهش ورود اطلاعات بار مطابقت ندارد!"}:{isValid:!0}},R=(p,g)=>{var x;if([ru.SUPER_ADMIN,ru.ADMIN_X].includes(F))return{isValid:!0};const _=parseInt(p)/parseInt(g);return Q6(n,(x=u==null?void 0:u.poultryRequest)==null?void 0:x.age,_)?{isValid:!0}:{isValid:!1,message:"میانگین وزنی با احراز سنی مطابقت ندارد. لطفا با اتحادیه تماس بگیرید."}},C=h6({initialValues:{quantity:"",weight:""},onSubmit:async p=>{const g=A(parseInt(p.quantity));if(!g.isValid){o({vertical:"top",horizontal:"center",msg:g.message,severity:"error"});return}const f=R(p.weight,p.quantity);if(!f.isValid){o({vertical:"top",horizontal:"center",msg:f.message,severity:"error"});return}const _=await i(_0({kill_house_request_key:u.key,role:F,net_weight:p.weight,exploited_carcass:0,real_quantity:p.quantity}));_.payload.error?o({vertical:"top",horizontal:"center",msg:_.payload.error,severity:"error"}):(o({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}),i(iu()),r(Z))},validate:p=>{const g={};return h(p.weight)||(g.weight="لطفا عدد وارد کنید"),h(p.quantity)||(g.quantity="لطفا عدد وارد کنید"),g}});return e.jsx("form",{onSubmit:C.handleSubmit,children:e.jsxs(d,{container:!0,gap:P.SMALL,alignItems:"center",justifyContent:"center",children:[e.jsx(G,{label:"وزن خالص (کیلوگرم)",variant:"outlined",fullWidth:!0,type:"text",name:"weight",id:"weight",onChange:C.handleChange,onBlur:C.handleBlur,value:C.values.weight,error:C.touched.weight&&!!C.errors.weight,helperText:C.touched.weight&&C.errors.weight}),e.jsx(G,{label:"تعداد واقعی (قطعه)",variant:"outlined",fullWidth:!0,type:"text",name:"quantity",id:"quantity",onChange:C.handleChange,onBlur:C.handleBlur,value:C.values.quantity,error:C.touched.quantity&&!!C.errors.quantity,helperText:C.touched.quantity&&C.errors.quantity}),e.jsx(m,{type:"submit",fullWidth:!0,variant:"contained",children:"ثبت"})]})})},L0=({item:u,updateTable:r})=>{var f,_;const[o,n]=c.useState((f=u==null?void 0:u.barDocumentStatus)!=null&&f.key?(_=u==null?void 0:u.barDocumentStatus)==null?void 0:_.key:""),[i,y]=c.useState(u!=null&&u.description?u==null?void 0:u.description:""),[F]=c.useContext(au),h=uu(),A=H(x=>x.userSlice.selectedSubUser),R=x=>{n(x.target.value)},C=x=>{y(x.target.value)},[p,g]=c.useState([]);return c.useEffect(()=>{h(E0({role_key:du("slaughter")&&(A==null?void 0:A.key)||""})).then(x=>{g(x.payload.data)})},[A==null?void 0:A.key]),e.jsxs(d,{container:!0,xs:12,gap:2,children:[e.jsxs(i6,{fullWidth:!0,children:[e.jsx(N6,{id:"document-state-label",children:"وضعیت سند"}),e.jsx(V6,{labelId:"document-state-label",id:"document-state-select",value:o,label:"وضعیت سند",onChange:R,children:p==null?void 0:p.map((x,B)=>e.jsx(q6,{value:x==null?void 0:x.key,children:x==null?void 0:x.title},B))})]}),e.jsx(G,{fullWidth:!0,label:"توضیحات",multiline:!0,rows:4,value:i,onChange:C,variant:"outlined"}),e.jsx(d,{xs:12,children:e.jsx(m,{fullWidth:!0,variant:"contained",color:"primary",onClick:()=>{h(y0({key:u==null?void 0:u.key,bar_document_status_key:o,bar_document_description:i,role:M()})).then(()=>{F({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}),r(1),h(iu())})},children:"ثبت"})})]})};var F6={},W0=d6;Object.defineProperty(F6,"__esModule",{value:!0});var Z6=F6.default=void 0,P0=W0(p6()),N0=e;Z6=F6.default=(0,P0.default)((0,N0.jsx)("path",{d:"M18 13v7H4V6h5.02c.05-.71.22-1.38.48-2H4c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2v-5zm-1.5 5h-11l2.75-3.53 1.96 2.36 2.75-3.54zm2.8-9.11c.44-.7.7-1.51.7-2.39C20 4.01 17.99 2 15.5 2S11 4.01 11 6.5s2.01 4.5 4.49 4.5c.88 0 1.7-.26 2.39-.7L21 13.42 22.42 12zM15.5 9C14.12 9 13 7.88 13 6.5S14.12 4 15.5 4 18 5.12 18 6.5 16.88 9 15.5 9"}),"ImageSearch");const V0=ou("SLAUGHTER_ENTER_BAR_WEIGHT",async(u,{dispatch:r})=>{try{r(Y());const{data:o,status:n}=await O.post("kill_house_assignment_information/",u);return r(D()),{data:o,status:n}}catch(o){return r(D()),{error:o.response.data.result}}}),q0=ou("SLAUGHTER_UPDATE_BAR_WEIGHT",async(u,{dispatch:r})=>{try{r(Y());const{data:o,status:n}=await O.put("kill_house_assignment_information/0/",u);return r(D()),{data:o,status:n}}catch(o){return r(D()),{error:o.response.data.result}}}),M0=ou("SLAUGHTER_GET_EXCLUSIVE_KILLERS",async(u,{dispatch:r})=>{r(Y());const{data:o,status:n}=await O.get("kill_house/?exclusive-killers=true",{params:u});return r(D()),{data:o,status:n}}),J6=({data:u,reqKey:r,isRejected:o,item:n,realNumber:i,updateTable:y})=>{const[F]=c.useContext(au),[h,A]=L6.useState([]),[R,C]=L6.useState(null),{weightRange:p}=H(E=>E.provinceSlice),g=H(E=>E.userSlice.selectedSubUser),f=E=>{var S;if(A(E),l.setFieldValue("weightWithBarImg",""),C(null),E[0]){const V=(S=E[0])==null?void 0:S.file;K6(V,z=>{const U=z6(z);C(U),l.setFieldValue("weightWithBarImg",U)})}else l.setFieldValue("weightWithBarImg","")},[_,x]=c.useState(0),B=uu();let L=0;const l=h6({initialValues:{weightWithoutBar:"",weightWithBar:"",weightWithBarImg:"",loadRealNumber:n.acceptedRealQuantity?n.acceptedRealQuantity:i,exploitedCarcass:0},validationSchema:$6({weightWithoutBar:Yu().min(0,"عدد منفی وارد نکنید!").required("این فیلد اجباری است!").typeError("لطفا عدد وارد کنید!"),weightWithBar:Yu().test("len","وزن با بار باید بیشتر از وزن بدون بار باشد!",(E,S)=>S.originalValue&&S.originalValue>L).required("این فیلد اجباری است!").typeError("لطفا وزن را وارد کنید!"),weightWithBarImg:C6().required("این فیلد اجباری است!"),loadRealNumber:Yu().required("این فیلد اجباری است!").typeError("لطفا عدد وارد کنید!"),exploitedCarcass:Yu().required("این فیلد اجباری است!").typeError("لطفا عدد وارد کنید!")})});L=Number(l.values.weightWithoutBar),c.useEffect(()=>{l.validateForm()},[]),c.useEffect(()=>{var E,S;(o||n)&&(l.setFieldValue("weightWithoutBar",(E=n.assignmentInfo)==null?void 0:E.carWeightWithoutLoad),l.setFieldValue("weightWithBar",(S=n.assignmentInfo)==null?void 0:S.carWeightWithLoad))},[]),c.useEffect(()=>{const E=Number(l.values.weightWithoutBar),S=Number(l.values.weightWithBar);S&&(E{B(M0({role_key:du("slaughter")&&(g==null?void 0:g.key)||""})).then(E=>{su(E.payload.data)})},[g==null?void 0:g.key]);const k=E=>{$(E==null?void 0:E.target.value)},b=M()!=="KillHouse"?"ثبت اطلاعات بجای کشتارگاه":"ثبت اطلاعات";return e.jsxs(d,{container:!0,direction:"column",children:[e.jsx(d,{children:e.jsx(j0,{columns:["کدبار","مرغداری","تعداد تخصیصی (قطعه)","تعداد تحویلی (قطعه)","وزن تحویلی (کیلوگرم)","میانگین وزن تحویلی هر قطعه (کیلوگرم)","سن","تاریخ کشتار","کشتارکن اختصاصی"],data:u})}),e.jsxs(d,{container:!0,direction:"column",alignItems:"start",my:P.SMALL,gap:P.SMALL,children:[e.jsxs(d,{container:!0,gap:P.TINY,children:[e.jsxs(w,{variant:"body2",color:"primary",fontWeight:"bold",children:["اطلاعات بار با کدبار ",u[0][0]," را وارد کنید."]}),(o||n.assignmentInfo)&&e.jsx(w,{variant:"body2",color:"error",fontWeight:"bold",children:"توجه: حتما باید اطلاعات جدید دوباره وارد گردد. (سند ماشین و وزن ماشین)"}),o&&e.jsx(e.Fragment,{children:e.jsxs(w,{variant:"body2",color:"error",fontWeight:"bold",children:["(","اطلاعات بار توسط واحد مالی استان رد شده است.",")"]})})]}),e.jsx(d,{container:!0,direction:"column",gap:P.SMALL,children:e.jsxs(d,{container:!0,gap:P.SMALL,alignItems:"normal",children:[e.jsxs(d,{container:!0,direction:"column",children:[e.jsx(Xu,{allowLeadingZeros:!0,thousandSeparator:",",id:"weightWithoutBar",label:"وزن ماشین بدون بار باسکول شده",variant:"outlined",value:l.values.weightWithoutBar,error:l.touched.weightWithoutBar?!!l.errors.weightWithoutBar:null,onChange:l.handleChange,onBlur:l.handleBlur,helperText:l.touched.weightWithoutBar&&l.errors.weightWithoutBar?l.errors.weightWithoutBar:null}),e.jsx(H6,{onChange:f,images:h,maxNumber:1,title:"بارگذاری سند"}),n.assignmentInfo.imageWithBar&&e.jsxs(d,{container:!0,direction:"column",alignItems:"center",mt:P.SMALL,children:[e.jsx("a",{href:n.assignmentInfo.imageWithBar,children:e.jsx("img",{src:n.assignmentInfo.imageWithBar,width:"100",height:"100",alt:"killHouseImageWithLoad"})}),e.jsx(w,{variant:"caption",children:"سند ماشین با بار بارگذاری شده"})]})]}),e.jsx(d,{container:!0,direction:"column",children:e.jsx(Xu,{allowLeadingZeros:!0,thousandSeparator:",",id:"weightWithBar",label:"وزن ماشین با بار باسکول شده",variant:"outlined",value:l.values.weightWithBar,error:l.touched.weightWithBar?!!l.errors.weightWithBar:null,onChange:l.handleChange,onBlur:l.handleBlur,helperText:l.touched.weightWithBar&&l.errors.weightWithBar?l.errors.weightWithBar:null})}),e.jsx(d,{container:!0,direction:"column",children:e.jsx(Xu,{allowLeadingZeros:!0,thousandSeparator:",",style:{width:130},id:"loadRealNumber",label:"تعداد واقعی بارگیری",variant:"outlined",value:l.values.loadRealNumber,error:l.touched.loadRealNumber?!!l.errors.loadRealNumber:null,onChange:l.handleChange,onBlur:l.handleBlur,helperText:l.touched.loadRealNumber&&l.errors.loadRealNumber?l.errors.loadRealNumber:null})}),e.jsx(d,{container:!0,direction:"column",children:e.jsx(Xu,{disabled:!0,allowLeadingZeros:!0,thousandSeparator:",",style:{width:150},id:"exploitedCarcass",label:"لاشه استحصالی",variant:"outlined",value:l.values.exploitedCarcass,error:l.touched.exploitedCarcass?!!l.errors.exploitedCarcass:null,onChange:l.handleChange,onBlur:l.handleBlur,helperText:l.touched.exploitedCarcass&&l.errors.exploitedCarcass?l.errors.exploitedCarcass:null})}),e.jsxs(d,{container:!0,direction:"column",children:[e.jsx(w,{color:E=>E.palette.grey.A700,variant:"caption",children:"وزن بار وارد شده"}),e.jsxs(w,{variant:"button",children:[_," کیلوگرم "]})]}),(I==null?void 0:I.length)>1&&e.jsxs(d,{container:!0,direction:"column",gap:1,alignItems:"center",children:[e.jsxs(i6,{children:[e.jsx(N6,{id:"demo-simple-select-label",children:"انتخاب کشتارکن"}),e.jsx(V6,{label:"کشتارکن",value:s,onChange:k,children:I==null?void 0:I.map((E,S)=>e.jsx(q6,{value:E==null?void 0:E.key,children:E==null?void 0:E.name},S))})]}),e.jsx(d,{children:e.jsx(w,{sx:{fontSize:"12px"},color:"red",children:"ویرایش کشتارکن اختصاصی (اختیاری)"})})]}),e.jsx(d,{container:!0,direction:"column",alignItems:"center",children:e.jsx(m,{variant:"contained",disabled:!l.isValid,onClick:()=>{var S,V,z,U,q,Q;const E=N=>{N.payload.error?F({vertical:"top",horizontal:"center",msg:N.payload.error,severity:"error"}):(l.setFieldValue("weightWithBar",""),l.setFieldValue("weightWithoutBar",""),C(null),A([]),F({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}),B(U6({right:!1,top:!1,bottom:!1,content:null,size:null})),y(1))};if(((S=n==null?void 0:n.killhouseUser)==null?void 0:S.maximumLoadVolumeReduction)!==0&&l.values.loadRealNumber<(n==null?void 0:n.acceptedRealQuantity)*(1-((V=n==null?void 0:n.killhouseUser)==null?void 0:V.maximumLoadVolumeReduction)/100)||((z=n==null?void 0:n.killhouseUser)==null?void 0:z.maximumLoadVolumeIncrease)!==0&&l.values.loadRealNumber>(n==null?void 0:n.acceptedRealQuantity)*(1+((U=n==null?void 0:n.killhouseUser)==null?void 0:U.maximumLoadVolumeIncrease)/100))F({vertical:"top",horizontal:"center",msg:"حجم وارد شده با مجوز حداکثر افزایش/کاهش ورود اطلاعات بار مطابقت ندارد!",severity:"error"});else if(M()!=="SuperAdmin"&&M()!=="AdminX"&&!Q6(p,(q=n==null?void 0:n.poultryRequest)==null?void 0:q.age,parseInt(_)/parseInt(l.values.loadRealNumber)))F({vertical:"top",horizontal:"center",msg:"میانگین وزنی با احراز سنی مطابقت ندارد. لطفا با اتحادیه تماس بگیرید.",severity:"error"});else if(o||((Q=n.assignmentInfo)==null?void 0:Q.assignmentState)===!0){const N={car_weight_with_load:l.values.weightWithBar,car_weight_without_load:l.values.weightWithoutBar,car_with_load_image:R,key:n.assignmentInfo.assignmentKey,real_quantity:l.values.loadRealNumber,exploited_carcass:l.values.exploitedCarcass,role:M(),killer_key:s||null};B(q0(N)).then(E)}else{const N={car_weight_with_load:l.values.weightWithBar,car_weight_without_load:l.values.weightWithoutBar,car_with_load_image:R,real_quantity:l.values.loadRealNumber,exploited_carcass:l.values.exploitedCarcass,kill_house_request_key:r,role:M(),killer_key:s||null};N.kill_house_check_key||delete N.kill_house_check_key,B(V0(N)).then(E)}},children:b})})]})})]})]})};J6.propTypes={data:cu.PropTypes.array,reqKey:cu.PropTypes.string,checkKey:cu.PropTypes.string,isRejected:cu.PropTypes.bool,item:cu.PropTypes.any,realNumber:cu.PropTypes.any};const m6=({item:u,updateTable:r})=>{var F,h,A,R,C,p,g,f,_;const o=uu(),n=H(x=>x.userSlice.selectedSubUser),i=(u==null?void 0:u.acceptedRealWeight)/(u==null?void 0:u.acceptedRealQuantity),y=[[u.barCode,`${(h=(F=u.poultryRequest)==null?void 0:F.poultry)==null?void 0:h.unitName} (${(R=(A=u.poultryRequest.poultry)==null?void 0:A.user)==null?void 0:R.mobile})`,u.quantity.toLocaleString(),u!=null&&u.acceptedRealQuantity?(C=u==null?void 0:u.acceptedRealQuantity)==null?void 0:C.toLocaleString():"وارد نشده",u!=null&&u.acceptedRealWeight?(p=u==null?void 0:u.acceptedRealWeight)==null?void 0:p.toLocaleString():"وارد نشده",i?i.toFixed(2):"وارد نشده",(g=u==null?void 0:u.poultryRequest)==null?void 0:g.age,A6(new Date((f=u==null?void 0:u.poultryRequest)==null?void 0:f.sendDate),"yyyy/MM/dd"),(_=u==null?void 0:u.killer)==null?void 0:_.name]];return c.useEffect(()=>{o(O6({role_key:du("slaughter")&&(n==null?void 0:n.key)||""}))},[n==null?void 0:n.key]),e.jsxs(t0,{sx:{alignSelf:"flex-start",width:"100%"},children:[e.jsxs(n0,{children:[e.jsx(a0,{color:"secondary"}),e.jsx(o0,{})]}),e.jsxs(d,{container:!0,direction:"column",flexWrap:"nowrap",flex:"1",children:[e.jsxs(d,{container:!0,children:[e.jsx(d,{children:e.jsx(s0,{variant:"body1",fontWeight:"bold",color:"secondary",children:"انجام عملیات"})}),e.jsx(d,{children:e.jsx(l0,{color:"textSecondary",children:e.jsx(w,{variant:"body2",children:"در این مرحله اطلاعات مربوط به وزن و سند باسکول را وارد نمایید."})})})]}),e.jsx(d,{container:!0,direction:"column",justifyContent:"space-between",children:e.jsx(d,{children:e.jsx(J6,{data:y,realNumber:u.quantity,reqKey:u.key,isRejected:u!=null&&u.assignmentInfo?(u==null?void 0:u.assignmentInfo.state)==="rejected":null,item:u,updateTable:r})})})]})]})};m6.propTypes={file:cu.PropTypes.object};var y6={},O0=d6;Object.defineProperty(y6,"__esModule",{value:!0});var u0=y6.default=void 0,$0=O0(p6()),U0=e;u0=y6.default=(0,$0.default)((0,U0.jsx)("path",{d:"M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6zm2.46-7.12 1.41-1.41L12 12.59l2.12-2.12 1.41 1.41L13.41 14l2.12 2.12-1.41 1.41L12 15.41l-2.12 2.12-1.41-1.41L10.59 14zM15.5 4l-1-1h-5l-1 1H5v2h14V4z"}),"DeleteForever");const H0=ou("VET_FARM_DELETE_BAR",async(u,{dispatch:r})=>{r(Y());try{const{data:o,status:n}=await O.delete("delete-bar/0/",{params:u});return r(D()),{data:o,status:n}}catch(o){return r(D()),{error:o.response.data.result}}}),z0=({updateTable:u,item:r})=>{const o=uu(),[n]=c.useContext(au);return e.jsxs(d,{container:!0,xs:12,justifyContent:"center",children:[e.jsx(w,{variant:"body2",color:"error",children:"پس از حذف امکان بازگشت تغییرات مقدور نیست!"}),e.jsxs(d,{container:!0,gap:P.SMALL,xs:12,mt:2,justifyContent:"center",children:[e.jsx(m,{color:"error",variant:"contained",onClick:()=>{if(!(r!=null&&r.barCode)){n({vertical:"top",horizontal:"center",msg:"کد بار یافت نشد!",severity:"error"});return}o(Y()),o(H0({bar_code:r.barCode})).then(i=>{var y,F,h,A,R;if(i!=null&&i.error||(y=i==null?void 0:i.payload)!=null&&y.error){const C=((F=i.payload)==null?void 0:F.error)||((h=i.error)==null?void 0:h.message)||"",p=C.includes("500")||((A=i.error)==null?void 0:A.status)===500||((R=i.error)==null?void 0:R.statusCode)===500;n(p?{vertical:"top",horizontal:"center",msg:"مشکلی در دریافت اطلاعات پیش آمده است!",severity:"error"}:{vertical:"top",horizontal:"center",msg:C||"مشکلی در حذف بار پیش آمده است!",severity:"error"})}else u&&typeof u=="function"&&u(),o(iu()),n({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"})}).catch(i=>{var A;console.error("Error deleting bar:",i);const y=(i==null?void 0:i.message)||"",F=(A=i==null?void 0:i.response)==null?void 0:A.status,h=y.includes("500")||F===500;n({vertical:"top",horizontal:"center",msg:h?"مشکلی در دریافت اطلاعات پیش آمده است!":"مشکلی در حذف بار پیش آمده است!",severity:"error"})}).finally(()=>{o(D())})},children:"بله"}),e.jsx(m,{variant:"outlined",onClick:()=>{o(iu())},children:"خیر"})]})]})};var f6={},K0=d6;Object.defineProperty(f6,"__esModule",{value:!0});var e0=f6.default=void 0,G0=K0(p6()),Y0=e;e0=f6.default=(0,G0.default)((0,Y0.jsx)("path",{d:"M4 6H2v14c0 1.1.9 2 2 2h14v-2H4zm16-4H8c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2m-1 9h-4v4h-2v-4H9V9h4V5h2v4h4z"}),"LibraryAdd");const Q0=ou("VET-FARM_SAVE_PRICE_SERVICE",async(u,{dispatch:r})=>{r(Y());try{const{data:o,status:n}=await O.put("kill_house_request_pricing/0/",u);return r(D()),{data:o,status:n}}catch(o){return r(D()),{error:o.response.data.result}}}),X0=({item:u,updateTable:r})=>{const[o]=c.useContext(au),[n,i]=c.useState([]),[y,F]=c.useState(!1),h=uu(),A=!!(u!=null&&u.priceRegisterDate),R=p=>{i(p)},C=h6({initialValues:{key:u.key||"",price:(u==null?void 0:u.price)||"",description:(u==null?void 0:u.description)||"",settlementType:(u==null?void 0:u.settlement_type)||"cash"},validationSchema:$6({price:Yu().required("لطفا قیمت را وارد کنید").typeError("لطفا یک عدد معتبر وارد کنید").min(0,"قیمت نمی‌تواند منفی باشد"),description:C6().required("این فیلد اجباری است!").min(10,"توضیحات باید حداقل ۱۰ کاراکتر باشد").max(500,"توضیحات نمی‌تواند بیشتر از ۵۰۰ کاراکتر باشد"),settlementType:C6().required("نوع تسویه الزامی است")}),onSubmit:p=>{F(!0);const g=new FormData;g.append("key",u==null?void 0:u.key),g.append("settlement_type",p.settlementType),g.append("price",p.price),g.append("description",p.description),n.forEach(f=>{g.append("file",f)}),h(Q0(g)).then(f=>{f.payload.error?o({vertical:"top",horizontal:"center",msg:f.payload.error,severity:"error"}):(F(!1),r(),h(iu()),o({vertical:"top",horizontal:"center",msg:A?"ویرایش با موفقیت انجام شد.":"ثبت با موفقیت انجام شد.",severity:"success"}))})}});return c.useEffect(()=>{A&&C.setValues({key:(u==null?void 0:u.key)||"",price:u.price||"",description:u.description||"",settlementType:u.settlement_type||"cash"}),C.validateForm()},[u]),e.jsx("form",{onSubmit:C.handleSubmit,children:e.jsxs(d,{container:!0,spacing:2,justifyContent:"center",alignItems:"center",children:[e.jsx(d,{item:!0,xs:12,children:e.jsxs(i6,{component:"fieldset",fullWidth:!0,children:[e.jsx(c0,{component:"legend",children:"نوع تسویه"}),e.jsxs(C0,{row:!0,"aria-label":"payment-type",name:"settlementType",value:C.values.settlementType,onChange:C.handleChange,children:[e.jsx(l6,{value:"cash",control:e.jsx(T6,{}),label:"نقدی"}),e.jsx(l6,{value:"term",control:e.jsx(T6,{}),label:"مدت دار"})]})]})}),e.jsx(d,{item:!0,xs:12,children:e.jsx(G,{fullWidth:!0,id:"price",name:"price",label:"قیمت (ریال)",variant:"outlined",type:"number",InputProps:{inputProps:{min:0,step:1e3}},value:C.values.price,error:C.touched.price&&!!C.errors.price,onChange:C.handleChange,onBlur:C.handleBlur,helperText:C.touched.price&&C.errors.price})}),e.jsx(d,{item:!0,xs:12,children:e.jsx(G,{multiline:!0,minRows:3,maxRows:6,fullWidth:!0,id:"description",name:"description",label:"توضیحات",variant:"outlined",value:C.values.description,error:C.touched.description&&!!C.errors.description,onChange:C.handleChange,onBlur:C.handleBlur,helperText:C.touched.description&&C.errors.description})}),e.jsxs(d,{item:!0,xs:12,children:[e.jsx(w,{color:"textSecondary",gutterBottom:!0,children:A?"فایل‌های موجود:":"لطفا فایل‌های مورد نیاز را آپلود کنید"}),e.jsx(w,{color:"error",gutterBottom:!0,children:A?"توجه: آپلود فایل جدید باعث جایگزینی فایل‌های قبلی می‌شود":"حداکثر حجم هر فایل: 5MB"}),e.jsx(S0,{onChange:R})]}),e.jsx(d,{item:!0,xs:12,children:e.jsx(m,{type:"submit",fullWidth:!0,variant:"contained",color:"primary",disabled:!C.isValid||y,startIcon:y?e.jsx(i0,{size:20}):null,children:y?"در حال ارسال...":A?"ویرایش قیمت ":"ثبت گزارش قیمت"})})]})})},Z0=({item:u,updateTable:r,isComplete:o})=>{var U;const n=uu(),i=H(q=>q.userSlice.selectedSubUser),[y,F]=c.useState(null),h=d0(),A=M(),R=A==="SuperAdmin",C=A==="Supporter",p=A==="ProvinceOperator",g=A==="CityVet",f=A==="VetFarm",_=A==="AdminX",x=R||C,B=_||R||C,L=u.assignmentStateArchive==="pending"&&u.trash!==!0&&!f,l=R||C||p||g,I=!f,su=o,s=!o&&B,$=!o,k=()=>e.jsx(c6,{component:"span",sx:{display:"flex",alignItems:"center"},children:e.jsx(g6,{size:20,color:h.palette.success.main})}),b=({title:q,IconComponent:Q,colorKey:N,onClick:lu,disabled:tu=!1,hidden:Au=!1,componentProps:j,placement:t="left"})=>{var T;if(Au)return null;const W=((T=h.palette[N])==null?void 0:T.main)??h.palette.primary.main,pu=A0(W,.1),v=()=>{tu||lu==null||lu()},a=nu=>{(nu.key==="Enter"||nu.key===" ")&&(nu.preventDefault(),v())};return e.jsx(d,{item:!0,children:e.jsx(Qu,{title:q,placement:t,children:e.jsx("span",{style:{width:"100%",display:"block"},children:e.jsxs(c6,{role:"button",tabIndex:0,onClick:v,onKeyDown:a,...j,sx:{display:"flex",alignItems:"center",gap:1.5,px:1.5,py:1,borderRadius:1,cursor:tu?"not-allowed":"pointer",opacity:tu?.4:1,transition:"background-color 0.2s ease",textDecoration:"none","&:hover":{backgroundColor:tu?"transparent":pu}},children:[e.jsx(Q,{sx:{color:W}}),e.jsx(w,{variant:"body2",sx:{color:W,fontWeight:500},children:q})]})})})})},E=q=>{F(q.currentTarget)},S=()=>{F(null)},V=!!y,z=V?"popover":void 0;return e.jsxs(d,{container:!0,children:[e.jsx(s6,{"aria-describedby":z,variant:"contained",color:"primary",onClick:E,children:e.jsx(v0,{})}),e.jsx(h0,{anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"left"},id:z,open:V,anchorEl:y,onClose:S,children:e.jsx(d,{style:{padding:"10px 6px"},children:e.jsxs(d,{container:!0,direction:"column",spacing:1,children:[b({title:"ثبت وضعیت سند",IconComponent:Z6,colorKey:"primary",hidden:!x,disabled:((U=u.assignmentInfo)==null?void 0:U.assignmentState)===!1,onClick:()=>{S(),n(Cu({title:"ثبت وضعیت سند",content:e.jsx(L0,{item:u,updateTable:r})}))}}),b({title:"ورود اطلاعات بار",IconComponent:M6,colorKey:"primary",hidden:!su,placement:"right",onClick:()=>{S(),n(U6({title:"انجام عملیات تخصیص",top:!(window.innerWidth<=600),bottom:window.innerWidth<=600,content:e.jsx(m6,{updateTable:r,item:u})}))}}),b({title:"لغو بار",IconComponent:R0,colorKey:"error",hidden:!L,disabled:l,onClick:()=>{S(),n(Cu({title:"لغو بار",content:e.jsx(x0,{updateTable:r,killHouseRequestKey:u.key})}))}}),b({title:"حذف کامل بار",IconComponent:u0,colorKey:"error",hidden:!s,disabled:u==null?void 0:u.trash,onClick:()=>{S(),n(Cu({title:"آیا از حذف بار اطمینان دارید؟",content:e.jsx(z0,{updateTable:r,item:u})}))}}),b({title:"خروجی اکسل",IconComponent:k,colorKey:"success",hidden:!$,placement:"left",onClick:()=>S(),componentProps:{component:"a",href:`${O.defaults.baseURL}bar_for_each_persion_excel/?code=${u.barCode}${du("slaughter")?`&role_key=${i==null?void 0:i.key}`:""}`,rel:"noreferrer",target:"_blank"}}),b({title:u!=null&&u.priceRegisterDate?"ویرایش گزارش قیمت":"ثبت گزارش قیمت",IconComponent:e0,colorKey:"primary",hidden:!I,placement:"left-start",onClick:()=>{S(),n(Cu({title:u!=null&&u.priceRegisterDate?"ویرایش گزارش قیمت":"ثبت گزارش قیمت",content:e.jsx(X0,{updateTable:r,item:u})}))}})]})})})]})},J={KILL_HOUSE:"KillHouse",ADMIN_X:"AdminX",VET_FARM:"VetFarm",PROVINCE_OPERATOR:"ProvinceOperator",KILL_HOUSE_VET:"KillHouseVet",SUPER_ADMIN:"SuperAdmin",SUPPORTER:"Supporter"},a6={FREEZING:"انجماد",EXPORT:"صادرات",NORMAL:"عادی"},Gu={WAREHOUSE:"ورود به انبار",REGISTERED:"ثبت اطلاعات بار",DELETED:"حذف شده",ACCEPTED:"تایید تخلیه",PENDING:"در انتظار تخلیه"},Ju={CONTRADICTION:"مغایرت کد رهگیری",NO_CLEARANCE:"فاقد کد رهگیری",MERGE:"ادغام",NOT_APPROVED:"عدم تایید راهداری"},r0=10,eu=1,J0=u=>u?A6(new Date(u),"yyyy/MM/dd"):"-",o6=u=>u?`${u.toLocaleString()} ﷼`:"-",X=u=>u?u.toLocaleString():"-",m0=(u,r=2)=>u?u.toFixed(r).toLocaleString():"-",mu=(u,r)=>u&&r?`${u} (${r})`:"-",ue=u=>{var r,o;return(r=u==null?void 0:u.poultryRequest)!=null&&r.freezing?a6.FREEZING:(o=u==null?void 0:u.poultryRequest)!=null&&o.export?a6.EXPORT:a6.NORMAL},ee=u=>u!=null&&u.wareHouseConfirmation?Gu.WAREHOUSE:(u==null?void 0:u.assignmentStateArchive)!=="pending"?Gu.REGISTERED:u.trash===!0?Gu.DELETED:u.vetState==="accepted"?Gu.ACCEPTED:u.vetState==="pending"?Gu.PENDING:"",re=u=>u!=null&&u.quarantineQuantity?u.quarantineQuantity:u!=null&&u.quarantineCodeState?{contradiction:Ju.CONTRADICTION,noclearance:Ju.NO_CLEARANCE,merge:Ju.MERGE}[u.quarantineCodeState]||Ju.NOT_APPROVED:"-",te=u=>{const{textValue:r,role:o,date1:n,date2:i,page:y,perPage:F,roleKey:h,withoutBarDocument:A}=u,R="kill_house_assignment_information/",C=new URLSearchParams({search:"filter",value:r||"",role:o||"",date1:n||"",date2:i||"",page:y,page_size:F||r0,without_bar_document:A?"true":"false"});return h&&C.append("role_key",h),`${R}?${C.toString()}`},ne=u=>{const{baseURL:r,date1:o,date2:n,role:i,roleKey:y,userKey:F,textValue:h}=u,A=new URLSearchParams({start:o||"",end:n||"",state:"completed",role:i||"",key:F||"",search:"filter",value:h||""});return y&&A.append("role_key",y),`${r}bar_excel/?${A.toString()}`},ae=(u,r)=>{var n;return(n=r==null?void 0:r.killer)!=null&&n.key?[J.KILL_HOUSE,J.ADMIN_X,J.VET_FARM,J.PROVINCE_OPERATOR,J.KILL_HOUSE_VET,J.SUPER_ADMIN,J.SUPPORTER].includes(u):!1},oe=u=>u===J.SUPER_ADMIN||u===J.SUPPORTER||u===J.ADMIN_X,ke=()=>{const[,,u,r,o,n]=c.useContext(au),i=H(v=>v.userSlice.selectedSubUser),y=H(v=>v.userSlice.userProfile.key),F=uu(),[h,A]=c.useState(!1),[R,C]=c.useState([]),[p,g]=c.useState(0),[f,_]=c.useState(r0),[x,B]=c.useState(""),[L,l]=c.useState(eu),[I,su]=c.useState([]),[s,$]=c.useState([]),k=c.useMemo(()=>M(),[]),b=c.useMemo(()=>du("slaughter")&&(i==null?void 0:i.key)||"",[i==null?void 0:i.key]),E=c.useMemo(()=>oe(k),[k]);c.useEffect(()=>{const v=hu(new Date).format("YYYY-MM-DD");r(v),n(v)},[r,n]);const S=c.useCallback(async(v=L)=>{F(Y());try{const a=te({textValue:x,role:k,date1:u,date2:o,page:v||eu,perPage:f,roleKey:b,withoutBarDocument:h}),T=await O.get(a);C(T.data.results),g(T.data.count)}catch(a){console.error("Error fetching data:",a)}finally{F(D())}},[x,k,u,o,f,b,h,L,F]),V=c.useCallback(()=>{F(g0({selectedDate1:u,selectedDate2:o,textValue:x,hasDocumentState:h,roleKey:b})).then(v=>{$(v.payload.data)})},[u,o,x,h,b,F]),z=v=>{S(v),l(v)},U=v=>{_(v),l(eu)},q=async v=>{v.preventDefault(),await S(eu),V(),l(eu)},Q=v=>{B(v.target.value)},N=v=>{v&&r(hu(v).format("YYYY-MM-DD"))},lu=v=>{v&&n(hu(v).format("YYYY-MM-DD"))},tu=()=>{A(!h)};c.useEffect(()=>{S(eu),V()},[]),c.useEffect(()=>{S(eu),V(),l(eu)},[u,o,h,f,b]),c.useEffect(()=>{const v=R==null?void 0:R.map((a,T)=>{var Fu,yu,fu,xu,Eu,vu,Ru,ju,Su,_u,Iu,ku,wu,bu,Du,Bu,Tu,Lu,Wu,Pu,Nu,Vu,qu,Mu,Ou,$u,Uu,Hu,zu,Ku,x6,E6,v6,R6,j6,S6,_6,I6,k6,w6,b6,D6,B6;const nu=L===eu?T+1:T+f*(L-1)+1,gu=a!=null&&a.trash?"red":"black";return[nu,e.jsx(Z0,{item:a,updateTable:S,isComplete:!0},`operation-${T}`),e.jsx(w,{style:{fontSize:"13px",color:gu},children:ee(a)},`state-${T}`),e.jsx(w,{style:{fontSize:"13px",color:gu},children:a.barCode},`barcode-${T}`),F0(a.createDate),ue(a),e.jsx(w,{variant:"body2",color:(Fu=a==null?void 0:a.barDocumentStatus)!=null&&Fu.isError?"error":"primary",children:((yu=a==null?void 0:a.barDocumentStatus)==null?void 0:yu.title)||"-"},`doc-status-${T}`),e.jsx(u6,{src:(fu=a==null?void 0:a.assignmentInfo)==null?void 0:fu.imageWithBar},`image-${T}`),X(a.acceptedRealQuantity),X(a==null?void 0:a.acceptedRealWeight),X((xu=a==null?void 0:a.weightInfo)==null?void 0:xu.finalIndexWeight),mu((Eu=a.killhouseUser)==null?void 0:Eu.name,(ju=(Ru=(vu=a.killhouseUser)==null?void 0:vu.killHouseOperator)==null?void 0:Ru.user)==null?void 0:ju.mobile),a!=null&&a.killer?mu((Su=a.killer)==null?void 0:Su.name,(ku=(Iu=(_u=a.killer)==null?void 0:_u.killHouseOperator)==null?void 0:Iu.user)==null?void 0:ku.mobile):"-",mu((Du=(bu=(wu=a.poultryRequest)==null?void 0:wu.poultry)==null?void 0:bu.user)==null?void 0:Du.fullname,(Lu=(Tu=(Bu=a.poultryRequest)==null?void 0:Bu.poultry)==null?void 0:Tu.user)==null?void 0:Lu.mobile),((Pu=(Wu=a.poultryRequest)==null?void 0:Wu.poultry)==null?void 0:Pu.unitName)||"-",((Nu=a==null?void 0:a.poultryRequest)==null?void 0:Nu.age)||"-",X(a.quantity),X((Vu=a==null?void 0:a.weightInfo)==null?void 0:Vu.weight),e.jsx(d,{children:e.jsx(G6,{updateTable:S,killHouseRequestKey:a.key,trafficCode:a==null?void 0:a.trafficCode,isEditable:ae(k,a)})},`traffic-${T}`),o6(a==null?void 0:a.amount),(a==null?void 0:a.clearanceCode)||"-",re(a),`${((Mu=(qu=a.addCar)==null?void 0:qu.driver)==null?void 0:Mu.typeCar)||""} ${(($u=(Ou=a.addCar)==null?void 0:Ou.driver)==null?void 0:$u.pelak)||""}`.trim()||"-",mu((Hu=(Uu=a.addCar)==null?void 0:Uu.driver)==null?void 0:Hu.driverName,(Ku=(zu=a.addCar)==null?void 0:zu.driver)==null?void 0:Ku.driverMobile),((x6=a.poultryRequest)==null?void 0:x6.chickenBreed)||"-",X((E6=a==null?void 0:a.weightInfo)==null?void 0:E6.indexWeight),o6((v6=a==null?void 0:a.poultryRequest)==null?void 0:v6.amount),o6((R6=a==null?void 0:a.weightInfo)==null?void 0:R6.killHousePrice),(_6=(S6=(j6=a==null?void 0:a.vetFarm)==null?void 0:j6.vet)==null?void 0:S6.user)!=null&&_6.fullname?`${a.vetFarm.vet.user.fullname}(${a.vetFarm.vet.user.mobile})`:"فاقد دامپزشک",a.killPlace||"-",((b6=(w6=(k6=(I6=a.poultryRequest)==null?void 0:I6.poultry)==null?void 0:k6.address)==null?void 0:w6.city)==null?void 0:b6.name)||"-",J0((D6=a==null?void 0:a.poultryRequest)==null?void 0:D6.sendDate),((B6=a==null?void 0:a.poultryRequest)==null?void 0:B6.orderCode)||"-",X(a==null?void 0:a.wareHouseAcceptedRealQuantity),X(a==null?void 0:a.wareHouseAcceptedRealWeight),X(a==null?void 0:a.weightLoss)]});su(v||[])},[R,L,f,k,S]);const Au=["تعداد بارها","حجم بارها","وزن بارها","میانگین وزن","کمترین سن ","بیشترین سن ","میانگین سنی","بارهای دارای کد قرنطینه","حجم بارهای دارای کد قرنطینه","بارهای احراز شده از قرنطینه","حجم بارهای احراز شده از قرنطینه","بارهای فاقد کد قرنطینه","حجم بارهای فاقد کد قرنطینه","بارهایی که در قرنطینه و رصدیار اختلاف دارند","بارهای تکمیل شده کشتارگاه","حجم نهایی در کشتارگاه","وزن نهایی در کشتارگاه","تعداد بار ورودی به انبار","حجم لاشه های انبار","وزن لاشه های انبار","درصد افت بار انبار"],j=["ردیف","عملیات","وضعیت","کدبار","تاریخ ثبت خودرو","نوع کشتار","وضعیت سند","سند (بارنامه)","تعداد نهایی","وزن نهایی بار (کیلوگرم)","میانگین وزن نهایی (کیلوگرم)","خریدار","کشتارکن اختصاصی","مشخصات مرغدار","نام فارم","سن مرغ","تعداد اولیه","وزن اولیه بار (کیلوگرم)","کد بهداشتی حمل و نقل","قیمت مرغ زنده‌ی بار","کدرهگیری سامانه قرنطینه","تعداد در قرنطینه","ماشین","راننده","نژاد","میانگین وزن اولیه (کیلوگرم)","قیمت مرغدار","قیمت کشتارگاه","دامپزشک فارم","محل کشتار","شهر","تاریخ کشتار","کدسفارش کشتار","حجم لاشه","وزن لاشه","درصد افت"],t=(v,a=!1)=>e.jsx(w,{variant:"caption",style:a?{color:"blue"}:{},children:X(v)}),W=[t(s==null?void 0:s.lenKillRequest,!0),t(s==null?void 0:s.killRequestQuantity),t(s==null?void 0:s.killRequestWeight,!0),e.jsx(w,{variant:"caption",children:(s==null?void 0:s.avgWeight)||"-"},"avg-weight"),t(s==null?void 0:s.minAge,!0),t(s==null?void 0:s.maxAge),t(s==null?void 0:s.avgAge,!0),t(s==null?void 0:s.lenKillRequestHasCode),t(s==null?void 0:s.quantityOfKillRequestHasCode,!0),t(s==null?void 0:s.lenKillRequestHasQuarantine),t(s==null?void 0:s.quantityOfKillRequestHasQuarantine,!0),t(s==null?void 0:s.lenKillRequestHasNotCode),t(s==null?void 0:s.quantityOfKillRequestHasNotCode,!0),t(s==null?void 0:s.differenceBar),t(s==null?void 0:s.lenCompleteWithKillHouse,!0),t(s==null?void 0:s.quantityFinalKillHouse),t(s==null?void 0:s.weightFinalKillHouse,!0),t(s==null?void 0:s.wareHouseBars),t(s==null?void 0:s.wareHouseBarsQuantity,!0),t(s==null?void 0:s.wareHouseBarsWeight),e.jsx(w,{variant:"caption",style:{color:"blue"},children:m0(s==null?void 0:s.wareHouseBarsWeightLose)},"weight-lose")],pu=ne({baseURL:O.defaults.baseURL,date1:u,date2:o,role:k,roleKey:b,userKey:y,textValue:x});return e.jsx(c6,{width:"100%",mt:2,children:e.jsx(d,{display:"flex",alignItems:"center",justifyContent:"center",direction:"row",gap:P.SMALL,children:e.jsxs(d,{container:!0,justifyContent:"center",gap:P.SMALL,xs:12,children:[e.jsxs(d,{container:!0,alignItems:"center",gap:P.SMALL,xs:12,children:[e.jsx(d,{style:{width:"150px"},children:e.jsx(e6,{label:"از تاریخ",renderInput:v=>e.jsx(G,{...v}),value:u,onChange:N})}),e.jsx(d,{style:{width:"150px"},children:e.jsx(e6,{label:"تا تاریخ",renderInput:v=>e.jsx(G,{...v}),value:o,onChange:lu})}),e.jsxs("form",{onSubmit:q,children:[e.jsx(G,{autoComplete:"off",size:"small",label:"جستجو",variant:"outlined",style:{width:250},onChange:Q,value:x}),e.jsx(m,{type:"submit",endIcon:e.jsx(Y6,{}),children:"جستجو"})]}),!!(R!=null&&R.length)&&e.jsx(d,{children:e.jsx(Qu,{title:"خروجی اکسل",children:e.jsx("a",{href:pu,rel:"noreferrer",children:e.jsx(m,{color:"success",children:e.jsx(g6,{size:32})})})})}),E&&e.jsx(l6,{control:e.jsx(p0,{checked:h,onChange:tu,name:"document-checkbox"}),label:"بدون وضعیت سند"})]}),e.jsx(d,{container:!0,mt:2,mb:4,isDashboard:!0,xs:12,children:e.jsx(r6,{title:"خلاصه اطلاعات",noPagination:!0,isDashboard:!0,columns:Au,data:[W]})}),e.jsx(r6,{data:I,columns:j,handlePageChange:z,totalRows:p,page:L,perPage:f,handlePerRowsChange:U,title:"بارهای تکمیل شده"})]})})})};export{Ie as E,ke as S,Z0 as V,m6 as a,I0 as b,M0 as s};