(this["webpackJsonpgonzo-test-client"]=this["webpackJsonpgonzo-test-client"]||[]).push([[80],{"+5lq":function(e,t,a){"use strict";var n=a("44Ds"),i=a.n(n),s=a("J2iB"),r=a.n(s),o=a("Y+p1"),c=a.n(o),l=a("q1tI"),d=a.n(l),m=a("3Z9Z"),h=a("JI6e"),u=a("/kok"),p=a("VyNe"),g=a("17x9"),f=a.n(g),v=a("/MKj"),b=(a("58CA"),a("3xDe")),D=a("A5yn"),E=a("q17X"),w=a("mwIZ"),y=a.n(w),O=a("mr+a"),C=a("kG49"),S=a("9D2Z"),I=a("uSQv"),T=a("LCzB");class j extends d.a.Component{constructor(e){super(e),this.setEvent=e=>{this.setState({event:e})},this.getItems=()=>[{name:this.props.chamber.IndividualFeeding?this.props.t("deviceRows.feeding.dispenserRow.standingName"):this.props.t("rfid"),value:O.a.BY_DEFAULT_ASC},{name:this.props.t("animalNumber"),value:O.a.BY_ANIMAL_NUMBER_ASC},{name:this.props.t("deviceRows.feeding.dispenserRow.foodAmount"),value:O.a.BY_USAGE_ASC},{name:this.props.chamber.IndividualFeeding?this.props.t("deviceRows.feeding.dispenserRow.lastFed"):this.props.t("deviceRows.feeding.dispenserRow.lastSeen"),value:O.a.BY_ACTIVITY_ASC},{name:this.props.t("deviceRows.feeding.dispenserRow.percentage"),value:O.a.BY_PERCENTAGE_ASC}].filter(e=>e),this.handleSort=e=>{const{feedingSort:t,chamber:a,dispatch:n}=this.props;this.chopEnd(e)===this.chopEnd(t)?n(Object(D.g)(a,"".concat(this.chopEnd(e)).concat(t.endsWith("_ASC")?"_DESC":"_ASC"))):n(Object(D.g)(a,e))},this.chopEnd=e=>e.split("_").slice(0,-1).join("_"),this.state={event:null}}render(){const{feedingSort:e,t:t}=this.props,{event:a}=this.state;let n=this.getItems();const i=y()(n.find(t=>this.chopEnd(t.value)===this.chopEnd(e)),"name",t("deviceRows.feeding.dispenserRow.sort"));return d.a.createElement(d.a.Fragment,null,d.a.createElement(I.a,{title:i,type:"button",className:"w-100",onClick:this.setEvent},d.a.createElement("i",{className:"fas fa-flip-vertical fa-sort-amount-".concat(e.endsWith("_ASC")?"up":"down")}),d.a.createElement("span",{className:"d-none d-lg-inline ml-1"},i)),d.a.createElement(S.a,{event:a},n.map(t=>d.a.createElement(C.a,{stopPropagation:!0,onClick:()=>this.handleSort(t.value),icon:this.chopEnd(t.value)===this.chopEnd(e)?e.endsWith("_ASC")?d.a.createElement("i",{className:"fas fa-sort-amount-up fa-flip-vertical"}):d.a.createElement("i",{className:"fas fa-sort-amount-down fa-flip-vertical"}):null},t.name))))}}j.propTypes={chamber:f.a.object.isRequired},j=Object(v.connect)((e,t)=>({feedingSort:(e.feeding.feeding[t.chamber.CID]||{feedingSort:O.a.BY_USAGE_ASC}).feedingSort}))(j);var x=Object(T.a)()(j),M=a("2dKy");class k extends d.a.Component{constructor(e){super(e),this.setText=e=>{const{dispatch:t,chamber:a}=this.props;this.setState({text:e||""},()=>{this.timer&&(clearTimeout(this.timer),this.timer=null),this.timer=setTimeout(()=>{t(Object(D.c)(a,e)),this.timer=null},200)})},this.state={text:""},this.timer=null}render(){const{text:e}=this.state,{t:t}=this.props;return d.a.createElement("div",null,d.a.createElement(M.a,{placeholder:t("filter"),onChange:this.setText,value:e}))}}k=Object(T.a)()(k);var N=Object(v.connect)()(k),R=a("wQVC"),F=a("UZWR"),A=a("op23"),P=a("IOn/"),L=a("ANjH"),U=a("f0zD"),Y=a("bST7"),V=a("msTn");class W extends l.Component{constructor(...e){super(...e),this.handleOpenSettlement=()=>{this.openModal(A.a)},this.handleOpenSeparation=()=>{this.openModal(P.a)},this.handleOpenTransfer=()=>{this.openModal(Y.a)},this.openModal=e=>{const{show:t,chamber:a}=this.props;t(e,{chamberId:a.CID})}}render(){const{settlement:{state:e},chamber:t,t:a,sectorType:n}=this.props;return d.a.createElement(d.a.Fragment,null,d.a.createElement(d.a.Fragment,null,(e===F.a.SHOW_SETTLEMENT||e===F.a.NO_SHOW)&&d.a.createElement(I.a,{onClick:this.handleOpenSettlement,disabled:e===F.a.NO_SHOW,type:"button",className:"w-100"},a("settlement")),e===F.a.SHOW_SEPARATION&&[V.a.DELIVERY].includes(n)&&d.a.createElement(I.a,{onClick:this.handleOpenSeparation,type:"button",className:"w-100"},a("separation")),e===F.a.SHOW_SEPARATION&&![V.a.DELIVERY].includes(n)&&d.a.createElement(I.a,{onClick:this.handleOpenTransfer,type:"button",className:"w-100"},a("transfer"))),d.a.createElement(A.b,{chamberId:t.CID}),d.a.createElement(P.b,{chamberId:t.CID}),d.a.createElement(Y.b,{chamberId:t.CID}))}}W=Object(v.connect)((e,t)=>({settlement:Object(F.c)(e,{CID:t.chamber.CID})}))(W),W=Object(v.connect)(null,e=>Object(L.b)({show:U.d},e))(W);Object(T.a)()(W);var B=a("v9qu");const q=d.a.memo(({t:e,chamber:t,sectorType:a,selectAll:n,unselectAll:i})=>d.a.createElement(m.a,null,d.a.createElement(h.a,{xs:12,lg:8,xl:6},d.a.createElement(N,{chamber:t})),!1,d.a.createElement(h.a,{xs:4,lg:4,xl:2},d.a.createElement(x,{chamber:t})),d.a.createElement(h.a,{xs:4,lg:6,xl:2},d.a.createElement(I.a,{title:e("deviceRows.feeding.dispenserChamber.select"),type:"button",className:"w-100",onClick:n},d.a.createElement("i",{className:"far fa-check-square d-lg-none"}),d.a.createElement("span",{className:"d-none d-lg-inline"},e("deviceRows.feeding.dispenserChamber.select")))),d.a.createElement(h.a,{xs:4,lg:6,xl:2},d.a.createElement(I.a,{title:e("deviceRows.feeding.dispenserChamber.unselect"),type:"button",className:"w-100",onClick:i},d.a.createElement("i",{className:"far fa-square d-lg-none"}),d.a.createElement("span",{className:"d-none d-lg-inline"},e("deviceRows.feeding.dispenserChamber.unselect"))))));class K extends d.a.Component{constructor(...e){super(...e),this.selectAll=()=>{const{dispatch:e,chamber:t}=this.props;e(Object(D.f)(t))},this.unselectAll=()=>{const{dispatch:e,chamber:t}=this.props;e(Object(D.h)(t))}}render(){const{chamber:e,sectorType:t,t:a,isOpen:n,toggleOpen:i}=this.props,s=Object(R.e)(),r=Object(B.a)();return d.a.createElement(h.a,{className:"pt-1rem ".concat(r?"":"sticky-item"),style:{top:s,zIndex:2},md:12},d.a.createElement(m.a,{onClick:i,className:"pointer justify-content-center"},d.a.createElement("h5",{className:"chamber-menu justify-content-between",id:"chamber_".concat(e.CID)},d.a.createElement("span",null,!!n&&r&&e.CName,r&&d.a.createElement("i",{className:"ml-1 mr-1 fas fa-arrow-".concat(n?"up":"down")})))),d.a.createElement(q,{sectorType:t,t:a,chamber:e,setEvent:this.setEvent,unselectAll:this.unselectAll,selectAll:this.selectAll}))}}K=Object(T.a)()(K);var H=K=Object(v.connect)()(K),_=a("n7pt"),z=a("6/k7"),G=a("mxqY"),X=a("qzmO"),Z=a("IXwn"),J=a("Z0cm"),Q=a.n(J),$=a("CuyV"),ee=a("EP7i"),te=a("wd/R"),ae=a.n(te),ne=a("ZRKa"),ie=a("Zayz"),se=a("LKKa"),re=a("XzT5");function oe(){return(oe=Object.assign||function(e){for(var t=1;td.a.createElement($.a,{tooltipContent:d.a.createElement("div",null,d.a.createElement("div",null,e),!!s&&d.a.createElement("div",null,d.a.createElement("i",{className:"fas fa-sync mr-1"}),d.a.createElement("b",null,s)),!!t&&d.a.createElement("div",{className:"opacity-75"},d.a.createElement("small",null,d.a.createElement("b",null,t))),Q()(i)&&i.map(e=>d.a.createElement("div",null,d.a.createElement("small",null,e))),!Q()(i)&&d.a.createElement("div",null,d.a.createElement("small",null,i))),placement:"auto",type:a},d.a.createElement("div",{className:"override-inactive device-main-working ".concat(a)},d.a.createElement("i",{className:n}))));class le extends d.a.Component{constructor(e){super(e),this.state={checkTime:+new Date}}shouldComponentUpdate(e,t,a){return e.dateTime!==this.props.dateTime||t.checkTime!==this.state.checkTime||e.loading!==this.props.loading}componentDidMount(){this.interval=setInterval(()=>{this.setState({checkTime:+new Date})},ee.a.DEVICE_OUTDATED_DATA_CHECK)}componentWillUnmount(){clearInterval(this.interval)}getStyle({extended:e,curveMap:t,curveId:a,day:n,animal:i,locked:s,loading:r,alert:o,feeding:c,connected:l,t:m,receiver:h,workType:u,feedingType:p,dateTime:g=0,scheduleMap:f=[],skipDoses:v=[],scheduleId:b}){const D=p===z.f.INDIVIDUAL?[z.g.SCHEDULE,z.g.TRIGGER]:[z.g.RFID],E=!!e&&Object(se.a)({curveMap:t,curveId:a,day:n,animal:i}),w=!(!h||!l)&&Math.abs(g-+new Date)>ee.a.DEVICE_OUTDATED_DATA;if(r)return{icon:"fas fa-fw fa-circle-notch fa-spin",color:"warning",header:d.a.createElement("b",null,m("deviceRows.feeding.dispenserRow.loading"))};if(l){if(w)return{icon:"fas fa-fw fa-sync",color:"warning",header:d.a.createElement("b",null,m("outOfSync"))};if(!D.includes(u))return{icon:"fas fa-fw fa-wrench",color:"error",header:d.a.createElement("b",null,m("deviceRows.feeding.dispenserRow.wrongWorkType")),extraInfo:re.a.t("deviceRows.feeding.dispenserRow.isXshouldBeY",{type1:m("deviceRows.feeding.dispenserRow.workType.".concat(u)),type2:D.map(e=>m("deviceRows.feeding.dispenserRow.workType.".concat(e))).join("/")})};if(!c)return{icon:"fas fa-fw fa-stop",color:"error",header:d.a.createElement("b",null,m("deviceRows.feeding.dispenserRow.stop"))};if(s)return{icon:"fas fa-fw fa-pause",color:E?"info":"",header:E?d.a.createElement("b",null,m("deviceRows.feeding.dispenserRow.pause"),d.a.createElement("br",null),m("deviceRows.feeding.dispenserRow.condition")):d.a.createElement("b",null,m("deviceRows.feeding.dispenserRow.pause"))};if(o)return{icon:"fas fa-fw fa-exclamation",color:"error",header:d.a.createElement("b",null,m("alertedDevice"))};if(b&&v.reduce((e,t)=>e+t,0)){const e=f.get(b)||ne.a.getSettingByID(b);if(e)for(let t=0;t<6;t++)if(v[t]){const a=y()(e,"SetData.Doses",[]);if(a[t]){const e=Object(ie.b)(y()(a[t],"Start",0)),n=Object(ie.b)(y()(a[t],"Stop",0)),i=Object(ie.b)(+new Date);if(i>=e&&i<=n)return{icon:"fas fa-fw fas fa-step-forward",color:E?"info":"",header:E?d.a.createElement("b",null,m("deviceRows.feeding.dispenserRow.skippingTime"),d.a.createElement("br",null),m("deviceRows.feeding.dispenserRow.condition")):d.a.createElement("b",null,m("deviceRows.feeding.dispenserRow.skippingTime"))}}}}const e=p===z.f.GROUP?m("deviceRows.iconStatus.pigConfigured"):m("deviceRows.feeding.dispenserRow.active");return{icon:"fas fa-fw fa-cog fa-spin",color:E?"info":"success",header:E?d.a.createElement("b",null,e,d.a.createElement("br",null),m("deviceRows.feeding.dispenserRow.condition")):d.a.createElement("b",null,e)}}return p===z.f.INDIVIDUAL||h?{icon:h?"fas fa-fw fa-wifi-slash":p===z.f.INDIVIDUAL?"fas fa-fw fa-plug":"fas fa-fw fa-wifi-slash",color:"warning",header:h?d.a.createElement("b",null,m("notConnectedDevice")):d.a.createElement("b",null,m("deviceRows.feeding.dispenserRow.notAssigned"))}:p===z.f.GROUP?{icon:"fas fa-fw fa-question",color:"warning",header:d.a.createElement("b",null,m("deviceRows.feeding.dispenserRow.notYetFeed"))}:void 0}render(){const e=this.getStyle(this.props),{errors:t=[],loading:a,dateTime:n,receiver:i,t:s}=this.props,r=!a&&i?n?ae()(n).format("DD.MM.YY HH:mm:ss"):s("noConnection"):void 0;return d.a.createElement(d.a.Fragment,null,d.a.createElement(ce,oe({},e,{error:t,dateTime:r})))}}var de=Object(T.a)()(le),me=a("T34T"),he=a("+V8T"),ue=a("pxzG"),pe=a("eASP"),ge=a("PjVZ");function fe(){return(fe=Object.assign||function(e){for(var t=1;t{clearTimeout(this.timeout),this.setState({loading:!0}),this.timeout=setTimeout(()=>{this.setState({loading:!1})},7500)},this.stopLoading=()=>{clearTimeout(this.timeout),this.setState({loading:!1})},this.openConfirmModal=(e,t={})=>{const{show:a,t:n}=this.props,{data:i,data:{receiver:s}}=this.props,r=new Map;r.set(s.gatewayId,{individualNRF:{devices:[s.deviceId],animals:[]},individualDTM:[],groupNRF:[]}),e(be({show:a,feedingType:z.f.INDIVIDUAL,t:n,content:n("deviceRows.feeding.dispenserButtons"),receivers:r,selectedNodes:[i],onConfirmed:()=>{}},t))},this.openModal=e=>{const{show:t}=this.props,{chamberId:a,data:n,data:{receiver:i}}=this.props,s=new Map;s.set(i.gatewayId,{individualNRF:{devices:[i.deviceId],animals:[]},individualDTM:[],groupNRF:[]}),t(e,{type:z.f.INDIVIDUAL,selectedNodes:[n],receivers:s,size:1,locationID:a,sectorType:_.a.getSectorTypeByChamberID(a),clearSelection:()=>{}})},this.callFunc=(e,t={},a={})=>{const{chamberId:n,data:i,data:{receiver:s}}=this.props,r=new Map;return r.set(s.gatewayId,{individualNRF:{devices:[s.deviceId],animals:[]},individualDTM:[],groupNRF:[]}),e(t,null,be({},{feedingType:z.f.INDIVIDUAL,selectedNodes:[i],receivers:r,size:1,chamberID:n,sectorType:_.a.getSectorTypeByChamberID(n)},{},a))},this.handleScrollToRFID=e=>{const{standings:t,chamberId:a}=this.props;Object(R.l)(document.getElementById("list_".concat(a)),t.findIndex(t=>t.id===e),t.length),Object(R.b)("rfid_".concat(e))},this.handleWorkType=()=>{this.callFunc(G.d,{workType:z.g.RFID})},this.reconnect=()=>{const{startSendingDeviceState:e,chamberId:t,data:{receiver:a}}=this.props;this.startLoading(),e(a.deviceId,a.gatewayId,{CID:t},{onSuccess:this.stopLoading,onFailure:this.stopLoading})},this.handleUnpause=()=>{this.openConfirmModal(G.b,{status:!1})},this.handlePause=()=>{this.openConfirmModal(G.b,{status:!0})},this.handleAlert=()=>{this.openModal(he.a)},this.clearAlert=()=>{this.callFunc((e,t,a)=>{const{receivers:n}=a;for(let i of n.values())i.individualNRF.devices.length>0&&Object(X.k)(i.individualNRF.devices,!1)})},this.handleExtraFeeding=()=>{this.openModal(me.a)},this.state={loading:!e.data.connected}}componentDidMount(){this.props.data.connected||this.startLoading()}UNSAFE_componentWillReceiveProps(e,t){this.state.loading&&e.data.connected&&this.stopLoading()}render(){const{device:{Address:e,Name:t}={},data:{efficiency:a=0,dateTime:n,connected:i,locked:s,workType:r,alert:o,receiver:c,errors:l=[],lastRFID:u=""},t:g}=this.props,{loading:f}=this.state,v=["device-rfid mb-0",Object(B.a)()?"mobile":""].filter(e=>e).join(" "),b=(l||[]).map(e=>{switch(e){case 5101:return g(["notificationsCenter.errorCodes.S".concat(e),"notificationsCenter.errorCodes.".concat(e)],{number:u||"-"});default:return g(["notificationsCenter.errorCodes.S".concat(e),"notificationsCenter.errorCodes.".concat(e)])}}),D=d.a.createElement("small",{className:"mr-1"},d.a.createElement(ge.a,{highlightColor:a?"info":"warning"},g("deviceRows.feeding.dispenserRow.efficiencyTime",{efficiency:Object(ue.j)(a,{showUnit:!0,unit:pe.a.SMALL,fixed:0})})));return d.a.createElement(h.a,{md:12,sm:12,xs:12,lg:6,xl:4,className:"mb-2"},d.a.createElement(p.a,{className:v},d.a.createElement(de,{dateTime:n,loading:f,workType:r,feedingType:z.f.GROUP,receiver:c,locked:s,alert:o,feeding:!0,connected:i,errors:b}),d.a.createElement(m.a,null,d.a.createElement(h.a,{ms:12},d.a.createElement("small",null,d.a.createElement("span",{className:"opacity-75 mr-1"},t),d.a.createElement("b",{className:"opacity-50 mr-1"},"0x",(e||0).toString(16).toUpperCase())))),d.a.createElement(m.a,null,d.a.createElement(h.a,{xs:12},u&&d.a.createElement("div",{className:"pointer align-items-baseline",title:g("deviceRows.feeding.deviceItem.clickToScrollToPig"),onClick:()=>this.handleScrollToRFID(u)},D,u,d.a.createElement("i",{className:"fas fa-arrow-from-top ml-1"})),!u&&d.a.createElement("div",{className:"align-items-baseline "},"R"===r&&!s||f?d.a.createElement("span",{className:"loading-animation"},f?g("deviceRows.feeding.dispenserRow.loading"):d.a.createElement(d.a.Fragment,null,D,g("deviceRows.feeding.deviceItem.waitingForPig"))):d.a.createElement("span",null,g(i?"deviceRows.feeding.dispenserRow.pause":"noConnection"))," "))),d.a.createElement(m.a,{className:"button-actions"},d.a.createElement(h.a,{md:12},d.a.createElement(Z.a,{className:"m-0"},d.a.createElement(I.a,fe({},Ee,{onClick:this.reconnect,icon:d.a.createElement("i",{className:"fas fa-sync fa-fw ".concat(f?"fa-spin":"")}),title:g("deviceRows.feeding.deviceItem.retryConnection")})),!f&&!!i&&d.a.createElement(d.a.Fragment,null,r!==z.g.RFID&&d.a.createElement(I.a,fe({},Ee,{onClick:this.handleWorkType,icon:d.a.createElement("i",{className:"fas fa-wrench fa-fw"}),title:g("deviceRows.feeding.deviceItem.setWorkTypeAsRFID")})),!!s&&d.a.createElement(I.a,fe({},Ee,{onClick:this.handleUnpause,icon:d.a.createElement("i",{className:"fas fa-play fa-fw"}),title:g("unlockFeeding")})),!s&&d.a.createElement(I.a,fe({},Ee,{onClick:this.handlePause,icon:d.a.createElement("i",{className:"fas fa-pause fa-fw"}),title:g("lockFeeding")})),d.a.createElement(I.a,fe({},Ee,{onClick:this.handleAlert,icon:d.a.createElement("i",{className:o?"fas fa-bell-slash fa-fw":"fas fa-bell fa-fw"}),title:g("deviceRows.feeding.deviceItem.clearAlerts")})),d.a.createElement(I.a,fe({},Ee,{onClick:this.handleExtraFeeding,icon:d.a.createElement("i",{className:"fas fa-utensils"}),title:g("extraFeeding")}))))))))}}we=Object(v.connect)((e,t)=>({standings:Object(O.h)(e,{CID:t.chamberId}),farm:location.farm}),e=>Object(L.b)({show:U.d},e))(we);var ye=Object(T.a)()(we);a("lrF6");class Oe extends d.a.Component{render(){const{chamber:{IndividualFeeding:e}}=this.props;if(e)return null;const{chamber:t,data:a,dispensers:n,startSendingDeviceState:i}=this.props;return d.a.createElement(h.a,{xs:12,className:"rfid-actions"},d.a.createElement(m.a,null,a.map(e=>d.a.createElement(ye,{startSendingDeviceState:i,chamberId:t.CID,key:e.id,device:n.find(t=>t.DevID===e.id),data:e}))))}}var Ce=Object(v.connect)((e,t)=>{const{chamber:{CID:a}}=t;return{data:Object(O.e)(e,{CID:a})}})(Oe),Se=a("0ajJ"),Ie=a("AsM4"),Te=a("b9ZJ"),je=a("Puqe"),xe=a.n(je),Me=a("lSCD"),ke=a.n(Me),Ne=a("lFKM"),Re=a.n(Ne),Fe=a("IBmF"),Ae=a("VfnB"),Pe=a("gTmc"),Le=a("kGDK"),Ue=a("FGff"),Ye=a("15cA"),Ve=a("9L8V");const We=({extended:e,name:t,rfid:a,t:n,animalName:i,isDead:s,isCorrectPlacement:r})=>d.a.createElement("div",{className:"standing-nr override-inactive"},e&&d.a.createElement("h5",null,i||"-"," ",(s||!r)&&d.a.createElement("small",null,d.a.createElement($.a,{tooltipContent:d.a.createElement("div",null,n(s?"deviceRows.feeding.dispenserRow.animalIsDead":"deviceRows.feeding.dispenserRow.animalIsWrongLocation")),placement:"auto",type:""},d.a.createElement("i",{className:"fas fa-exclamation-triangle warning"})))),d.a.createElement("div",{className:"opacity-75"},t),t!==a&&d.a.createElement("div",{className:"opacity-50"},a)),Be=d.a.memo(Object(T.a)()(({t:e,feedingType:t,eventStage:a,day:n,curveId:i,curveNr:s,curveMap:o,loop:{insemination:c=0,parturition:l=0,endDay:m=0}={}})=>{if(s){let t=i?o&&o.get(i)||ne.a.getSettingByID(i,{showDeleted:!0}):null;const l=y()(t,"SetData.Name",e("deviceRows.feeding.dispenserRow.curveUnknownX",{number:s})),h=!!y()(t,"DtaDelTime");let u=y()(t,"SetData.Type");u=Object.values(z.b).includes(u)?u:z.b.INDIVIDUAL;const p=u===z.b.INDIVIDUAL?z.a.NORMAL:Object(Ye.f)(t),g=Math.max(c,m),f=!!g,v=d.a.createElement(d.a.Fragment,null,"(",d.a.createElement("i",{className:"fas fa-undo fa-fw fa-xs opacity-50"}),g,")");let b="";const D=y()(t,"SetData.Stages",[]);for(let e=D.length-1;e>=0;e--)if(n>=D[e].StartDay){b=D[e].Name;break}let E;return console.log(u,p),E=t?p===z.a.NORMAL?e("newSettings.feeding.curves.curveDescriptions.".concat(z.b.INDIVIDUAL,".normal.name")):p===z.a.BOTH?e("newSettings.feeding.curves.curveDescriptions.".concat(u,a?".after.name":".before.name")):p===z.a.BEFORE?e("newSettings.feeding.curves.curveDescriptions.".concat(u,".before.name")):e("newSettings.feeding.curves.curveDescriptions.".concat(u,".after.name")):"-",d.a.createElement("div",{className:"curve-day"},d.a.createElement("b",null,r()(n)?"-":Object(Ye.d)(n,t)),!!g&&v,d.a.createElement("div",{className:"opacity-50 d-inline"}," ",e("day"),f&&d.a.createElement($.a,{tooltipContent:d.a.createElement("div",null,d.a.createElement("div",null,v," - ",e("deviceRows.feeding.dispenserRow.loop".concat(m>0?"CurveEnded":z.d.includes(u)?"Parturition":"Insemination"),{count:g}))),placement:"auto",type:""},d.a.createElement("small",null,d.a.createElement("i",{className:"fas fa-question-circle fa-fw ml-1"})))),d.a.createElement("small",{className:"opacity-75 d-block"},E),d.a.createElement("small",{className:"opacity-50 d-block"},b?"".concat(b," - "):"",l,h&&d.a.createElement($.a,{tooltipContent:d.a.createElement("div",null,e("deviceRows.feeding.dispenserRow.usingDeletedCurve")),placement:"auto",type:""},d.a.createElement("small",null,d.a.createElement("i",{className:"fas fa-exclamation-circle fa-fw ml-1"})))))}return d.a.createElement("div",{className:"curve-day"},d.a.createElement("i",{className:"fas fa-exclamation-triangle warning mr-1"}),d.a.createElement("small",{className:"opacity-50 d-block"},t===z.f.INDIVIDUAL?e("deviceRows.feeding.dispenserRow.stop"):e("deviceRows.feeding.dispenserRow.defaultCurve")))})),qe=d.a.memo(Object(T.a)()(({temperature:e={},feedingType:t,water:a={},efficiency:n=0,punishmentOptions:i={},punishment:s=0,correction:o=0,t:c,forageId:l,forageMap:m,curveNr:h})=>{const u=l?m&&m.get(l)||ne.a.getSettingByID(l,{showDeleted:!0}):null,p=!!y()(u,"DtaDelTime"),g=t===z.f.INDIVIDUAL?c("deviceRows.feeding.dispenserRow.efficiencyTime",{efficiency:Object(ue.j)(n,{showUnit:!0,unit:pe.a.SMALL,fixed:0})}):null,f=e.hasTemperature?d.a.createElement(ge.a,{highlightColor:r()(e.temperature)?"error":"success"},Object(ue.f)(e.temperature,{showUnit:!0,unit:pe.a.SMALL,fixed:1})):null,v=o?o>0?d.a.createElement(ge.a,{highlightColor:"success"},"+",o,"%"):d.a.createElement(ge.a,{highlightColor:"info"},o,"%"):null,D=s?d.a.createElement(ge.a,{highlightColor:"info"},c("punishment")," ",s):null,E=y()(u,"SetData.Color",Object(b.c)("primary")),w=Object(b.g)(E),O=!!a.hasWater&&!a.efficiency,C=!a.hasWater&&!!a.efficiency,S=!!a.hasWater||C||C,I=S?d.a.createElement(ge.a,{highlightColor:O||C?"error":"info"},d.a.createElement("i",{className:"fas fa-tint fa-fw mr-1"}),O?c("deviceRows.feeding.dispenserRow.waterError"):0===a.type?c("deviceRows.feeding.dispenserRow.efficiencyTime",{efficiency:(T=2*(a.efficiency||0),Object(ue.h)(T,{showUnit:!0,unit:pe.a.SMALL,fixed:0}))}):c("deviceRows.feeding.dispenserRow.efficiencyImpulsesLiter",{efficiency:a.efficiency})):null;var T;const j=u?d.a.createElement(ge.a,{style:{background:E,color:w},highlightColor:"info"},d.a.createElement("i",{className:"fas fa-wheat fa-fw".concat(g?" mr-1":"")}),g):d.a.createElement(ge.a,{highlightColor:"warning"},d.a.createElement("i",{className:"fas fa-wheat fa-fw".concat(g?" mr-1":"")}),g);return d.a.createElement("div",{className:"feeding-status"},d.a.createElement("small",null,I,j,v,D,f),d.a.createElement($.a,{tooltipContent:d.a.createElement("div",null,d.a.createElement("b",null,c("deviceRows.feeding.dispenserRow.doseSettings")),d.a.createElement("ul",null,!!S&&d.a.createElement("li",null,I,!C&&!O&&d.a.createElement(d.a.Fragment,null," - ",c("deviceRows.feeding.dispenserRow.waterEfficiencyDesc")),O&&d.a.createElement(d.a.Fragment,null," - ",c("deviceRows.feeding.dispenserRow.missingWaterEfficiencyConfiguration")),C&&d.a.createElement(d.a.Fragment,null," - ",c("deviceRows.feeding.dispenserRow.errorWaterEfficiency"))),d.a.createElement("li",null,j," - ",u?"".concat(p?c("deviceRows.feeding.dispenserRow.usingDeletedForage",{name:u.SetData.Name}):u.SetData.Name):c(h?"deviceRows.feeding.dispenserRow.unknownForage":"deviceRows.feeding.dispenserRow.defaultForage")),!!v&&d.a.createElement("li",null,v," - ",c("deviceRows.feeding.dispenserRow.correctionDesc",{amount:o})),!!D&&d.a.createElement("li",null,D," - ",c("deviceRows.feeding.dispenserRow.punishmentDesc",{amount1:i.Percentage,amount2:i.Trigger,amount3:i.Time})),!!f&&d.a.createElement("li",null,f," - ",c("chamber.chart.temperature"))),d.a.createElement("div",null)),placement:"auto",type:""},d.a.createElement("i",{className:"fas ".concat(p?"fa-exclamation-circle":"fa-question-circle"," fa-fw opacity-50 ml-1")})))})),Ke=d.a.memo(Object(T.a)()(({additionalDetails:e=[],additional:t=0,conv:a=(e=>e),t:n})=>e.length?d.a.createElement($.a,{tooltipContent:d.a.createElement("div",null,"(+".concat(a(t,!0),")")," - ",n("extraFeeding"),d.a.createElement("div",null,n("deviceRows.feeding.dispenserRow.extraFeedingHours"),e.map(e=>d.a.createElement("div",null,"".concat(ae()(e.time).format("DD-MM-YY HH:mm")," -> ").concat(a(e.dose,!0)),d.a.createElement("i",{className:"fas ml-1 fa-fw ".concat(e.success?"fa-check success":"fa-times error")}))))),placement:"auto",type:""},d.a.createElement("small",null,d.a.createElement("i",{className:"fas fa-question-circle fa-fw ml-1"}))):null)),He=d.a.memo(Object(T.a)()(({lastWeekHistory:e=[],content:t={}})=>{const{values:a,labels:n}=Object(se.b)({lastWeekHistory:e,content:t});return d.a.createElement("div",{className:"feeding-history"},d.a.createElement(Le.a,{showLabels:!0,showValue:!0,skew:!0,labels:n,values:a}))})),_e=d.a.memo(Object(T.a)()(({water:e={},mobile:t,t:a,children:n,unit:i=0,used:s,planned:o,additional:c,additionalDetails:l=[]})=>{const m=(e,t=!1)=>Object(ue.j)(e,{unit:i,showUnit:t,fixed:i?2:0});return d.a.createElement("div",{className:"forage-amount"},d.a.createElement("h3",{className:"align-items-center"},d.a.createElement(Ze,{water:e}),d.a.createElement("b",{className:"given"},r()(s)?"-":m(s),d.a.createElement("div",{className:"additional"}," ",t&&c?"(+".concat(m(c),")"):"")),!t&&d.a.createElement("small",null,c?"(+".concat(m(c),")"):""),d.a.createElement("small",{className:"opacity-50"},"/",r()(o)?"-":m(o,!0),d.a.createElement(Ke,{conv:m,additional:c,mobile:t,additionalDetails:l}))),n)})),ze=d.a.memo(Object(T.a)()(({isFeeding:e,seenTime:t})=>d.a.createElement("div",{className:"is-feeding"},d.a.createElement("small",{className:"opacity-50"},e?d.a.createElement(Pe.a,null):t?d.a.createElement(Ue.a,{minPeriod:30,date:t}):null)))),Ge=d.a.memo(Object(T.a)()(({skipDoses:e=[],scheduleMap:t=new Map,scheduleId:a,t:n})=>{const{doses:i,isDeleted:s}=Object(se.c)({scheduleMap:t,scheduleId:a});return d.a.createElement("div",{className:"skip-doses"},d.a.createElement("div",{className:"skip-doses"},!!i.length&&i.map((t,a)=>d.a.createElement("small",{key:a,className:"mr-1 d-inline-block"},d.a.createElement("i",{className:"".concat(e[a]?"warning":"info")},"\u25cf"),d.a.createElement("div",{className:e[a]?"color-warning font-weight-bold d-inline-block":"d-inline-block opacity-75"},t.start,"-",t.stop))),!i.length&&d.a.createElement("small",{className:"mr-1"},d.a.createElement("i",{className:"fas fa-exclamation-triangle error mr-1"}),d.a.createElement("span",{className:"opacity-50"},n("deviceRows.feeding.dispenserRow.scheduleNotFound"))),s&&d.a.createElement($.a,{tooltipContent:d.a.createElement("div",null,n("deviceRows.feeding.dispenserRow.usingDeletedSchedule")),placement:"auto",type:""},d.a.createElement("i",{className:"fas fa-exclamation-circle fa-fw opacity-50 ml-1"}))))})),Xe=d.a.memo(({buttons:e=[],mobile:t})=>e.length?d.a.createElement("div",{className:"extra-buttons"},d.a.createElement(t?d.a.Fragment:Z.a,{children:e.map((e,t)=>d.a.createElement(I.a,{key:t,type:"button",stopPropagation:!0,buttonColor:"info",icon:e.iconSvg?d.a.createElement(Ve.a,{src:e.iconSvg}):d.a.createElement("i",{className:e.icon}),disabled:e.disabled,onClick:e.action}))})):null),Ze=d.a.memo(Object(T.a)()(({water:e={},t:t})=>{const a=e.history||[],n=a.reduce((e,t)=>e+t.amount,0),i=e=>Object(ue.h)(e,{showUnit:!0,unit:pe.a.SMALL,fixed:1});return n?d.a.createElement(d.a.Fragment,null,d.a.createElement($.a,{tooltipContent:d.a.createElement("ul",null,t("deviceRows.feeding.dispenserRow.waterDisposedToday",{amount:i(n)}),a.map(e=>d.a.createElement("li",null,t("deviceRows.feeding.dispenserRow.waterDateAmount",{date:ae()(e.time).format("HH:mm"),amount:i(e.amount)}))))},d.a.createElement("small",null,d.a.createElement("i",{className:"fas fa-tint mr-1 color-info"})))):null}));a("nzcg");var Je=a("s506");class Qe extends d.a.Component{render(){const{feedingType:e,schedule:t,unit:a,feed:n,curve:i,skipDoses:s,lastWeekHistory:r,running:o,alert:c,errorsParser:l,locked:m,feeding:h,connected:u,loop:p,errors:g,name:f,forage:v,loading:b,animal:D,receiver:E,workType:w,additional:y,dateTime:O,lastSeen:C,curveMap:S,scheduleMap:I,forageMap:T,debugFixedText:j,correctLocationId:x,license:M,mobile:k,water:N,efficiency:R,punishmentOptions:F,temperature:A,t:P}=this.props;return d.a.createElement(d.a.Fragment,null,d.a.createElement("div",{className:"dispenser-item"},d.a.createElement(de,{extended:M===Je.b.EXTENDED,animal:D,day:i.day,curveMap:S,curveId:i.id,skipDoses:s,scheduleMap:I,scheduleId:t.id,dateTime:O,loading:b,receiver:E,workType:w,feedingType:e,errorsParser:l,locked:m,alert:c,feeding:h,connected:u,errors:g}),d.a.createElement(We,{extended:M===Je.b.EXTENDED,t:P,isDead:!(!D||!D.DtaDthTime),isCorrectPlacement:!x||!D||D.PlcmntID===x,name:f,rfid:D&&D.RFID,animalName:D&&D.AnmNo1}),d.a.createElement(_e,{water:N,mobile:k,forageMap:T,unit:a,additional:n.additional,additionalDetails:y,planned:n.plannedUsage,used:n.usage},d.a.createElement(qe,{feedingType:e,water:N,efficiency:R,punishmentOptions:F,additional:n.additional,mobile:k,forageMap:T,forageId:v.id,forageNr:v.number,temperature:A,curveNr:i.number,punishment:i.punishment,correction:i.correction})),d.a.createElement(Be,{mobile:k,curveMap:S,feedingType:e,eventStage:i.eventStage,curveId:i.id,curveNr:i.number,day:i.day,loop:p}),d.a.createElement(ze,{isFeeding:o,seenTime:C.time}),d.a.createElement(Ge,{mobile:k,scheduleMap:I,skipDoses:s,scheduleId:t.id}),d.a.createElement(He,{lastWeekHistory:r})),!!j&&d.a.createElement("div",{className:"fixed-debug-text"},j))}}Qe.propTypes={minLevel:f.a.number,onRowClick:f.a.func,onRowContextMenuClick:f.a.func,rowIndex:f.a.number.isRequired,loading:f.a.bool,style:f.a.object,selected:f.a.object,blurText:f.a.string,animal:f.a.object,id:f.a.string.isRequired,feedingType:f.a.number.isRequired,curve:f.a.shape({number:f.a.number,day:f.a.number,punishment:f.a.number,correction:f.a.number,eventStage:f.a.oneOf(Object.keys(Fe.h)),id:f.a.string}),schedule:f.a.shape({id:f.a.string,skip:f.a.arrayOf(f.a.number),number:f.a.number,obj:f.a.object}),loop:f.a.shape({insemination:f.a.number,parturition:f.a.number}),alert:f.a.bool,feeding:f.a.bool,locked:f.a.bool,connected:f.a.bool,feed:f.a.shape({usage:f.a.number,plannedUsage:f.a.number,additional:f.a.number}),lastSeen:f.a.shape({time:f.a.number}),lastWeekHistory:f.a.arrayOf(f.a.shape({usage:f.a.number,plannedUsage:f.a.number})),errors:f.a.arrayOf(f.a.number),running:f.a.bool,errorsParser:f.a.func,mobile:f.a.bool,buttons:f.a.oneOfType([f.a.node,null]),forage:f.a.shape({id:f.a.string})},Qe.defaultProps={onRowClick:()=>{},isLoading:!1,style:{},selected:!1,unit:pe.a.MEDIUM,connected:!1,errorsParser:Ae.i};var $e,et=Object(T.a)()(Qe),tt=a("EyHs"),at=a("/pZs"),nt=a("Tpgi"),it=a("T4Z/"),st=a("5tiW"),rt=a("hN/4"),ot=a("9jj8"),ct=a("BvFm"),lt=a("W6fe"),dt=a("lVFi");function mt(){return(mt=Object.assign||function(e){for(var t=1;t{const{chamberId:n,data:i}=this.props,s=Object(Ye.i)(n,[i]),r=ut({cookies:new Map,handleHide:()=>{},clearSelection:()=>{}},s);e(t,{},ut({},r,{},a))},this.handleExtraFeeding=()=>{this.callSubmit(lt.a,{forageDose:500},{})},this.handleLockFeeding=()=>{this.callSubmit(G.e,{status:!0})},this.handleUnlockFeeding=()=>{this.callSubmit(G.e,{status:!1})},this.handleAlarmSet=()=>{this.callSubmit(dt.a,{alert:!0})},this.handleAlarmClear=()=>{this.callSubmit(dt.a,{alert:!1})}}render(){const{mobile:e,data:{receiver:{index:t}={}}={}}=this.props,a=[{onClick:this.handleExtraFeeding,icon:"fas fa-fw fa-utensils"},{onClick:this.handleLockFeeding,icon:"fas fa-fw fa-pause"},{onClick:this.handleUnlockFeeding,icon:"fas fa-fw fa-play"},r()(t)?{onClick:this.handleAlarmSet,icon:"fas fa-fw fa-bell"}:null,{onClick:this.handleAlarmClear,icon:"fas fa-fw fa-bell-slash"}].filter(e=>e),n=e?ft:gt;return d.a.createElement("div",{className:"extra-debug"},d.a.createElement(e?d.a.Fragment:Z.a,{children:a.map((e,t)=>d.a.createElement(I.a,mt({},n,{onClick:e.onClick,icon:d.a.createElement("i",{className:e.icon})})))}))}})||$e;vt.propTypes={data:f.a.object.isRequired,chamberId:f.a.object.isRequired};var bt=Object(T.a)()(vt),Dt=a("yLV6"),Et=a.n(Dt),wt=a("0Lmq"),yt=a("40zH"),Ot=a("W/wb"),Ct=a("xi04"),St=a("NpuV"),It=a("84Ez"),Tt=a("R7+t"),jt=a("c5t2");function xt(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),a.push.apply(a,n)}return a}function Mt(e){for(var t=1;t{if(console.log(e.type,this.lastEvent,e.angle,e.deltaX),this.props.mobile){const t=-y()(this.itemRef.current.getElementsByClassName("extra-buttons"),"[0].clientWidth",0),a=y()(this.itemRef.current.getElementsByClassName("extra-debug"),"[0].clientWidth",0),n=Math.abs(e.angle),i=n>160||n<20;let s;switch(e.type){case"panstart":this.itemRef.current.classList.remove("animate-transform-x"),this.currentVal=parseInt(Object(R.g)(this.itemRef.current.style.transform)||0,10),this.lastEvent=e.type;break;case"panright":case"panleft":i&&(s=this.currentVal,this.lastEvent=e.type,s+=e.deltaX);break;case"panend":if(["panleft","panright"].includes(this.lastEvent)){s=parseInt(Object(R.g)(this.itemRef.current.style.transform)||0,10),this.itemRef.current.classList.add("animate-transform-x");const e=(-t>a?a:-t)/5;"panleft"===this.lastEvent&&(s=s<-e?t:0),"panright"===this.lastEvent&&(s=s>e?a:0)}this.lastEvent=e.type}r()(s)||(s=Math.max(s,t),s=Math.min(s,a),this.itemRef.current.style.transform="translateX(".concat(s,"px)"))}else this.itemRef.current.style.transform=""},this.initHammer=()=>{this.destroyHammer(),!this.hammer&&this.itemRef.current&&(this.hammer=new Et.a(this.itemRef.current),this.hammer.on("panstart panright panleft panend",this.handleSwipe))},this.destroyHammer=()=>{this.hammer&&(this.hammer.destroy(),this.hammer=null,this.itemRef.current.style.transform="")},this.getBlurComponent=(e=Rt)=>{const{t:t}=this.props,a={type:"button",buttonStyle:"text",stopPropagation:!0,buttonColor:"info"};switch(e){case Ft:return d.a.createElement("span",null,d.a.createElement("strong",null,t("deviceRows.feeding.dispenserRow.notAssigned")));case At:return d.a.createElement("span",null,d.a.createElement("strong",{className:"mr-1"},t("configureCurveFeeding")),d.a.createElement(I.a,Nt({},a,{onClick:()=>this.openModal(tt.a),icon:d.a.createElement("i",{className:"fas fa-cog"})})));case Pt:return d.a.createElement("span",null,d.a.createElement("strong",null,t("notConnectedDevice")));case Rt:return d.a.createElement("span",null,d.a.createElement("strong",{className:"loading-animation"},t("deviceRows.feeding.dispenserRow.loading")));default:return null}},this.openModal=e=>{const{show:t,data:a,location:{CID:n}}=this.props,i=Object(Ye.i)(n,[a]);t(e,{type:i.feedingType,selectedNodes:i.selectedNodes,receivers:i.receivers,locationID:i.chamberID,sectorType:i.sectorType})},this.clearSelection=()=>{const{dispatch:e,location:{CID:t}}=this.props;e(Object(D.h)(t))},this.handleReportParturition=()=>{this.openModal(yt.a)},this.handleReportInsemination=()=>{this.openModal(wt.a)},this.handleToggleLock=()=>{const{t:e,show:t,data:a,data:{locked:n},location:{CID:i}}=this.props,{feedingType:s,receivers:r,selectedNodes:o}=Object(Ye.i)(i,[a]);Object(G.b)({show:t,t:e,feedingType:s,status:!n,receivers:r,selectedNodes:o,onConfirmed:this.clearSelection})},this.handleManageFeeding=()=>{this.openModal(tt.a)},this.handleAlarmModal=()=>{this.openModal(he.a)},this.handleInfo=()=>{this.openModal(Ot.a)},this.handleHistory=()=>{this.openModal(St.a)},this.handleAssign=()=>{const{show:e,data:t,data:{animal:a,box:n,receiver:i},location:s}=this.props,{sectorType:r}=Object(Ye.i)(s.CID,[t]);e(Ct.a,{standing:{id:n.BID,animal:a,device:i?{DevID:i.deviceId,GatewayID:i.gatewayId,Index:i.index}:void 0,feedParam:{curveNr:y()(t,"curve.number",0),stage:y()(t,"curve.eventStage",0),startTime:y()(t,"curve.start",+new Date),isConfigured:!!y()(t,"curve.number",0)}},chamber:s,sectorType:r})},this.getButtons=()=>{const{sectorType:e,location:{IndividualFeeding:t},data:{animal:a,connected:n,locked:i}}=this.props;if(!n)return[];const s=[{action:this.handleManageFeeding,icon:"fas fa-cog"}];return t&&(s.push({action:this.handleToggleLock,icon:i?"fas fa-play":"fas fa-pause"},{action:this.handleAlarmModal,icon:"fas fa-bell"}),e===V.a.MATING&&s.push({action:this.handleReportInsemination,iconSvg:st.default}),e===V.a.DELIVERY&&s.push({action:this.handleReportParturition,iconSvg:rt.default})),t&&!a||s.push({action:this.handleInfo,icon:"fas fa-info"}),t&&s.push({action:this.handleAssign,icon:a?"fas fa-exchange":"fas fa-plus"}),s.push({action:this.handleHistory,icon:"fas fa-chart-bar"}),s},this.handleOnClick=()=>{const{dispatch:e,location:t,data:{id:a,feed:n}}=this.props;n&&e(Object(D.e)(t,a))},this.handleContextMenu=e=>{const{dispatch:t,location:a,data:{id:n,feed:i},selected:s,setEvent:r}=this.props;i&&!s&&t(Object(D.e)(a,n)),i&&ke()(r)&&r(e)},this.getValues=({license:e,curveMap:t,forageMap:a,scheduleMap:n,index:i,unit:s,location:o={},data:c={},data:{dateTime:l,loop:d={},forage:m={},errors:h=[],efficiency:u,waterEfficiency:p,waterDoseType:g,waterHistory:f,additionalFeeding:v=[],feed:b={},curve:D={},schedule:w={},lastSeen:O={}}={},mobile:C,loading:S})=>{const I=!!(c.curve&&0===c.curve.number&&c.connected&&o.IndividualFeeding),T=!c.connected,j=!c.connected&&S;let x={};D.punishment>0&&(x=Object(E.getFeedingPunishmentSettings)()[D.punishment-1]||{});const M=+new Date,k=c.device instanceof Tt.a&&c.device.hasWater(),N=c.device instanceof Tt.a&&(c.device.hasTemperatureSensor()&&c.device.isIndividualTemperature()),R=c.device instanceof Tt.a&&c.device.hasFlowMeter();return{hasWater:k,hasFlowMeter:R,temperature:{temperature:c.temperature,hasTemperature:N},water:{hasWater:k,hasFlowMeter:R,history:f||[],efficiency:p||0,type:g||0},modTime:c.modTime,efficiency:u,curveMap:t,forageMap:a,license:e,scheduleMap:n,mobile:!!C,debugFixedText:(()=>{let e="";if(o.IndividualFeeding){if(c.device)try{e=c.device.getDebugName(c.receiver?c.receiver.index:null)}catch(t){e=c.device.DevID}return e}return null})(),receiver:c.receiver,animal:c.animal,dateTime:l,rowIndex:i,connected:c.connected,punishmentOptions:x,loading:!(o.IndividualFeeding&&!c.receiver||!j),curve:{number:D.number,day:D.day,punishment:D.punishment,correction:D.correction,eventStage:D.eventStage,id:D.id},name:c.name,schedule:{id:w.id},running:!!c.running,skipDoses:c.skipDoses||[],lastWeekHistory:c.lastWeekHistory||[],lastSeen:{time:Re()(O.time)?O.time>M?M:O.time:void 0,deviceId:r()(O.deviceId)?void 0:O.deviceId},feed:{usage:b.usage,plannedUsage:b.plannedUsage,additional:v.reduce((e,t)=>e+(t.success?t.dose:0),0)},additional:v,blur:j||T||I,blurText:this.getBlurComponent(o.IndividualFeeding?j&&c.receiver?Rt:c.receiver?T?Pt:At:Ft:j?Rt:At),errors:(h||[]).map(e=>re.a.t(["notificationsCenter.errorCodes.S".concat(e),"notificationsCenter.errorCodes.".concat(e)],{name:c.name})||e),feedingType:o.IndividualFeeding?z.f.INDIVIDUAL:z.f.GROUP,forage:m,workType:c.workType,loop:{insemination:d.insemination||0,parturition:0,endDay:d.endDay||0},id:o.IndividualFeeding?"stand_".concat(c.id):"rfid_".concat(c.id),correctLocationId:o.IndividualFeeding?y()(c,"box.BID"):o.CID,feeding:c.feeding,locked:c.locked,alert:c.alert,unit:s}},this.state={isError:!1,errorCode:!1,showButtons:!this.isScrolling},this.itemRef=d.a.createRef(),this.currentVal=0,this.lastEvent=""}static getDerivedStateFromProps(e,t){return t.showButtons||e.isScrolling?null:{showButtons:!0}}componentDidMount(){this.props.mobile&&this.initHammer()}componentDidUpdate(e,t,a){if(this.props.mobile!==e.mobile&&(this.props.mobile?this.initHammer():this.destroyHammer()),Object(E.isUsingFakeData)())try{const{data:{id:t,animal:a={}}={}}=e,{data:{animal:n={}}={}}=this.props;a.AnmID!==n.AnmID&&Object(jt.c)(t)}catch(n){console.error(n)}}componentWillUnmount(){this.destroyHammer()}shouldComponentUpdate(e,t,a){return!c()(this.state,t)||(e.index!==this.props.index||(e.sectorType!==this.props.sectorType||(e.mobile!==this.props.mobile||(e.selected!==this.props.selected||(e.loading!==this.props.loading||(e.location!==this.props.location||(e.scheduleMap!==this.props.scheduleMap||(e.curveMap!==this.props.curveMap||(e.forageMap!==this.props.forageMap||(e.data.modTime!==this.props.data.modTime||(e.data.id!==this.props.data.id||JSON.stringify(e.style)!==JSON.stringify(this.props.style))))))))))))}componentDidCatch(e,t){const a=Object(nt.a)(at.a.FEEDING,e);this.setState({isError:!0,errCode:a})}render(){const{isError:e,errCode:t,showButtons:a}=this.state,{style:n}=this.props;if(e)return d.a.createElement(it.a,{style:n,errCode:t});const i=this.getValues(this.props),{selected:s,index:r,location:o,data:c={},mobile:l}=this.props,{blur:m,blurText:h}=i,u=o.IndividualFeeding?"stand_".concat(c.id):"rfid_".concat(c.id),p=["device-item",m?"inactive":"",l?"mobile":""].filter(e=>!!e).join(" ");let g=n;return!!m||Object(E.getFeedingLevels)().FeedingMinimumLevel<(i.feed.usage||0)/(i.feed.plannedUsage||1)||(g=Mt({},g,{background:"".concat(Object(b.c)("error"),"10")})),d.a.createElement(ot.a,{lp:r+1,index:r,style:g,selected:s,className:p,id:u,itemRef:this.itemRef,onClick:this.handleOnClick,onContextMenu:this.handleContextMenu},!!m&&!!h&&d.a.createElement("div",{className:"text-absolute override-inactive"},h),d.a.createElement(et,xe()(i,["blur","blurText"])),!!a&&d.a.createElement(d.a.Fragment,null,d.a.createElement(Xe,{mobile:l,buttons:this.getButtons()}),!!Object(ct.i)()&&!!c.connected&&!!o.IndividualFeeding&&d.a.createElement(bt,{chamberId:o.CID,data:c,mobile:l})))}}Lt.propTypes={data:f.a.object.isRequired,location:f.a.object.isRequired,style:f.a.object,index:f.a.number.isRequired,setEvent:f.a.func},Lt=Object(v.connect)((e,t)=>({license:Object(It.a)(e,{licenseName:Je.a.DISPENSER})}))(Lt),Lt=Object(v.connect)(null,e=>Mt({},Object(L.b)({show:U.d},e),{dispatch:e}))(Lt);var Ut=Object(T.a)()(Lt),Yt=a("ujxO"),Vt=a("c7k8");const Wt=[{max:Yt.a.LG,height:"20rem"}];class Bt extends l.Component{constructor(...e){super(...e),this.rowRenderer=({index:e,style:t,key:a,isScrolling:n})=>{const{unit:i,chamber:s,mobile:r,setEvent:o,data:c,sectorType:l,scheduleMap:m,forageMap:h,curveMap:u,isLoading:p}=this.props,g=Object(O.k)(c[e]);return d.a.createElement(Ut,{key:a,data:c[e],sectorType:l,mobile:r,forageMap:h,selected:g,scheduleMap:m,curveMap:u,loading:p,style:t,index:e,unit:i,isScrolling:n,location:s,setEvent:o})},this.noRowsRenderer=()=>{const{t:e,total:t,chamber:{IndividualFeeding:a}={}}=this.props;return d.a.createElement("div",{className:"placeholder"},e(t?a?"deviceRows.feeding.dispenserChamber.standingsNotFoundFiltered":"deviceRows.feeding.dispenserChamber.animalsNotFoundFiltered":a?"deviceRows.feeding.dispenserChamber.noBoxes":"deviceRows.feeding.dispenserChamber.noPassages"))}}componentDidUpdate(e,t,a){const{filterBy:n,sortBy:i,chamber:s}=this.props;e.filterBy===n&&i===e.sortBy||Object(R.j)("chamber_".concat(s.CID))}render(){const{sectorType:e,chamber:t,mobile:a,dispensers:n,data:i,filterBy:s,sortBy:r,startSendingDeviceState:o,isOpen:c,toggleOpen:l}=this.props;return d.a.createElement(Vt.f,null,({height:h,isScrolling:u,scrollTop:p,onChildScroll:g,registerChild:f})=>d.a.createElement(m.a,{className:"position-relative background-inherit"},d.a.createElement(H,{sectorType:e,scrollTop:p,chamber:t,isOpen:c,toggleOpen:l}),d.a.createElement(Ce,{startSendingDeviceState:o,dispensers:n,mobile:a,chamber:t}),d.a.createElement(Se.a,{itemRef:f,showNumber:!0,id:"list_".concat(t.CID),useFlexLayout:!1},d.a.createElement(Ie.a,{defaultValue:"10rem",breakPoints:Wt},({rowHeight:e})=>d.a.createElement(Te.List,{rowCount:i.length,sortBy:r,filterBy:s,data:i,rowHeight:e,width:window.innerWidth,rowRenderer:this.rowRenderer,scrollTop:p,autoHeight:!0,onScroll:g,height:h,isScrolling:u,overscanRowCount:3,className:"w-100 overflow-auto",noRowsRenderer:this.noRowsRenderer})))))}}Bt=Object(v.connect)((e,t)=>{const{chamber:{CID:a}}=t;return{data:Object(O.h)(e,{CID:a}),sortBy:Object(O.j)(e,{CID:a}),total:e.feeding.feeding[a]?Object.keys(e.feeding.feeding[a].data).length:0,filterBy:Object(O.i)(e,{CID:a})}})(Bt);var qt,Kt=Object(T.a)()(Bt),Ht=a("sEfC"),_t=a.n(Ht),zt=(a("wkDu"),a("qxeP"));let Gt=Object(v.connect)(e=>({license:Object(It.a)(e,{licenseName:Je.a.DISPENSER})}))(qt=class extends l.Component{constructor(...e){super(...e),this.parseErrors=i()((e,t)=>(t||[]).map(e=>{switch(e){case 5101:case 5103:case 5104:case 5202:case 5204:return this.props.t("notificationsCenter.errorCodes.".concat(e),{number:y()(this.props.data,"curve.number","-")});default:return this.props.t("notificationsCenter.errorCodes.".concat(e))}}),(...e)=>JSON.stringify(e)),this.iconStatus=()=>{const{license:e,scheduleMap:t,curveMap:a,data:{animal:n,dateTime:i,name:s,curve:r={},schedule:o={},skipDoses:c,connected:l,receiver:m,workType:h,feeding:u,alert:p,locked:g,errors:f}={},loading:v}=this.props,b=!!m&&!l&&!!v,D=this.parseErrors(s,f);return d.a.createElement(de,{extended:Je.b.EXTENDED===e,animal:n,curveMap:a,curveId:r.id,day:r.day,dateTime:i,scheduleId:o.id,scheduleMap:t,skipDoses:c,loading:b,receiver:m,workType:h,feedingType:z.f.INDIVIDUAL,locked:g,alert:p,feeding:u,connected:l,errors:D})},this.forageAmount=()=>{const{forageMap:e,unit:t,data:{feed:a={},additionalFeeding:n=[]}={}}=this.props,i=n.reduce((e,t)=>e+(t.success?t.dose:0),0);return d.a.createElement(_e,{forageMap:e,unit:t,additional:i,planned:a.plannedUsage,used:a.usage})},this.curveDay=()=>{const{curveMap:e,data:{curve:{id:t,number:a=0,day:n=0}={}}={}}=this.props;let i=null;if(a){let a=t?e&&e.get(t)||ne.a.getSettingByID(t):null;i=!r()(n)&&a?Object(Ye.d)(n,a):null}const s=Object(se.d)({curveMap:e,curveId:t,day:n});return d.a.createElement("div",{className:"curve-day"},d.a.createElement("i",{className:"opacity-25 fas fa-calendar-day mr-1"}),r()(i)?"-":i,!!s&&d.a.createElement("small",{className:"opacity-50 ml-1"},"(",s,")"))},this.forageModificators=()=>{const{data:{curve:{correction:e=0}={}}={}}=this.props;return d.a.createElement("div",{className:"feeding-status"},e?d.a.createElement("small",null,d.a.createElement(ge.a,{highlightColor:e>0?"success":"info"},"".concat(e>0?"+":"").concat(e,"%"))):null)},this.handleOnClick=()=>{const{dispatch:e,location:t,data:{id:a,feed:n}}=this.props;n&&e(Object(D.e)(t,a))},this.digitify=(e="")=>e.replace(/[^0-9]/g,"")}render(){const{license:e,data:{name:t,receiver:a,connected:n,animal:{AnmNo1:i}={}}={},style:s,className:r,selected:o,isLoading:c}=this.props,l=!n&&c&&!!a,m=["dispenser-simple fetura-list-item",r,o?"selected":""].filter(e=>!!e).join(" ");return d.a.createElement("div",{style:s,onClick:this.handleOnClick,className:m},d.a.createElement(zt.a,{useTransition:!0,isLoading:l}),d.a.createElement("div",{className:"name"},this.digitify(t)||"-"),e===Je.b.EXTENDED&&d.a.createElement("div",{className:"number"},i||"-"),this.iconStatus(),!!n&&d.a.createElement(d.a.Fragment,null,this.curveDay(),this.forageModificators(),this.forageAmount()))}})||qt;Gt.propTypes={data:f.a.object.isRequired};var Xt=Object(T.a)()(Gt);a("DsOL");class Zt extends l.Component{render(){const{width:e,itemRef:t,columnCount:a,headerRenderer:n,columnWidth:i,rowHeight:s}=this.props;return d.a.createElement("div",{ref:t,className:"fetura-simple-grid-header",style:{height:s,width:e}},new Array(a).fill(0).map((e,t)=>d.a.createElement("div",{className:"header",style:{width:i,height:s}},n({headerIndex:t,columnCount:a}))))}}Zt.propTypes={itemRef:f.a.func,columnWidth:f.a.number.isRequired,height:f.a.number.isRequired,rowHeight:f.a.number.isRequired,width:f.a.number.isRequired,columnCount:f.a.number.isRequired,headerRenderer:f.a.func.isRequired,className:f.a.string};var Jt,Qt=Zt,$t=a("0MVo");a("J1h9");let ea=Object(v.connect)()(Jt=class extends l.Component{constructor(...e){super(...e),this.selectAll=()=>{const{dispatch:e,chamber:t}=this.props;e(Object(D.f)(t))},this.unselectAll=()=>{const{dispatch:e,chamber:t}=this.props;e(Object(D.h)(t))}}render(){const{t:e}=this.props;return d.a.createElement(h.a,{md:12},d.a.createElement(m.a,null,d.a.createElement(h.a,{xs:6,md:6},d.a.createElement(I.a,{title:e("deviceRows.feeding.dispenserChamber.select"),type:"button",className:"w-100",onClick:this.selectAll},d.a.createElement("i",{className:"far fa-check-square d-lg-none"}),d.a.createElement("span",{className:"d-none d-lg-inline"},e("deviceRows.feeding.dispenserChamber.select")))),d.a.createElement(h.a,{xs:6,md:6},d.a.createElement(I.a,{title:e("deviceRows.feeding.dispenserChamber.unselect"),type:"button",className:"w-100",onClick:this.unselectAll},d.a.createElement("i",{className:"far fa-square d-lg-none"}),d.a.createElement("span",{className:"d-none d-lg-inline"},e("deviceRows.feeding.dispenserChamber.unselect"))))))}})||Jt;var ta=ea=Object(T.a)()(ea),aa=a("vzZS");class na extends l.Component{constructor(e){super(e),this.snapScroll=_t()(({scrollLeft:e,scrollTop:t})=>{try{const t=this.gridComponent.current.props.columnWidth,a=e%t;0!==a&&(a2*t/3)&&this.gridComponent.current.scrollToCell({columnIndex:Math.round(e/t),rowIndex:0})}catch(a){}},100),this.cellRenderer=({columnIndex:e,key:t,rowIndex:a,style:n,parent:i})=>{const{data:s,chamber:r,unit:o,isLoading:c,scheduleMap:l,curveMap:m,forageMap:h}=this.props,u=e+1===i.props.columnCount,p=[a%2===e%2?"odd":"even",a+1===i.props.rowCount?"border-bottom-0":"",u?"border-right-0":""].filter(e=>!!e).join(" ");return d.a.createElement(Xt,{location:r,scheduleMap:l,curveMap:m,forageMap:h,selected:Object(O.k)(y()(s,"[".concat(e,"][").concat(a,"]"))),key:t,isLoading:c,unit:o,className:p,data:s[e][a],style:n})},this.headerRenderer=({headerIndex:e,style:t,columnCount:a})=>{const n=!(y()(this.props,"chamber.StandsOrder",0)>>1&1);return d.a.createElement("div",{key:e,style:t},Object($t.c)(n?e:a+~e))},this.onScroll=({scrollLeft:e,scrollTop:t})=>{const{mobile:a}=this.props;try{this.headerComponent.current.scrollLeft=e}catch(n){}a&&this.snapScroll({scrollTop:t,scrollLeft:e})},this.getWidth=e=>{const{mobile:t}=this.props;return t&&e<500?e/2:Object(R.f)(10)},this.headerComponent=d.a.createRef(),this.gridComponent=d.a.createRef()}render(){const{sectorType:e,chamber:t,t:a,chamber:{StandsInRow:n=0,IndividualFeeding:i,StandsOrder:s=0}={},data:r,isLoading:o,isOpen:c,toggleOpen:l}=this.props,h=Object(R.e)();if(!i)return d.a.createElement(aa.a,{boxColor:"info"},a("deviceRows.feeding.dispenserChamber.simpleModeNotAvailableForGroupFeeding"));const u=Object(B.a)();return d.a.createElement(Vt.f,null,({height:a,scrollTop:i,registerChild:p})=>d.a.createElement(m.a,{className:"position-relative background-inherit"},d.a.createElement(Vt.a,{className:"w-100 background-inherit",disableHeight:!0,defaultWidth:window.innerWidth},({width:m})=>d.a.createElement(d.a.Fragment,null,d.a.createElement("div",{style:{top:h},className:"pt-1rem ".concat(u?"":"sticky-item")},d.a.createElement("div",{className:"justify-content-center",onClick:l},d.a.createElement("h5",{className:"chamber-menu justify-content-center",id:"chamber_".concat(t.CID)},d.a.createElement("span",null,!!c&&u&&t.CName,u&&d.a.createElement("i",{className:"ml-1 mr-1 fas fa-arrow-".concat(c?"up":"down")})))),d.a.createElement(ta,{sectorType:e,chamber:t}),d.a.createElement(Qt,{columnWidth:this.getWidth(m),columnCount:r.length,rowHeight:Object(R.f)(2),headerRenderer:this.headerRenderer,itemRef:this.headerComponent,width:m})),d.a.createElement("div",{ref:p},d.a.createElement(Vt.d,{ref:this.gridComponent,cellRenderer:this.cellRenderer,columnCount:r.length,columnWidth:this.getWidth(m),data:r,isLoading:o,scrollToAlignment:"start",autoHeight:!0,StandsOrder:s,onScroll:this.onScroll,height:a,scrollTop:i,className:"fetura-list striped",rowCount:n,rowHeight:Object(R.f)(6),width:m}))))))}}na=Object(v.connect)((e,t)=>({data:Object(O.b)(e,{chamber:t.chamber,CID:t.chamber.CID})}))(na);var ia=Object(T.a)()(na);class sa extends d.a.PureComponent{constructor(e){super(e),this.getConditionCount=i()(({animals:e,curveMap:t,chamber:a})=>{const n=e.length;let i=0;return e.forEach(e=>{const{feedParam:n}=e;if(n){if(a.IndividualFeeding&&e.PlcmntID===a.CID)return;const{startTime:s,stage:o,curveNr:c}=n;if(!r()(s)&&c){const a=[...t.values()].find(e=>e.SetData.Index+1===c);if(a){let n=ae()().startOf("day").diff(ae()(s).startOf("day"),"day")+1;n=Math.min(Math.max(n,1),a.SetData.Days.length),Object(Ye.f)(a)===z.a.BOTH&&(1!==o?n=Math.min(n,a.SetData.InseminationJumpTo):n+=a.SetData.InseminationJumpTo),console.log(a,n,e),Object(se.a)({curveMap:t,curveId:a.SetID,day:n,animal:e})&&i++}}}}),{animalCount:n,conditionCount:i}},(...e)=>JSON.stringify(e)),this.startLoading=()=>{clearTimeout(this.loadingTimer),this.loadingTimer=setTimeout(()=>{this.setState({loading:!1})},1e4),this.setState({loading:!0})},this.stopLoading=()=>{clearTimeout(this.loadingTimer),this.setState({loading:!1})},this.getData=()=>{u.a.removeFromInterval(this.sentMessages),this.sentMessages=[];const{dispatch:e,chamber:t,opened:a,dispensers:n,animals:i}=this.props;if(!a){if(n.length){let e=new Map;for(let t of n){let a=t.GatewayID;if(a){let n=e.get(a)||[];n.push(t.DevID),e.set(a,n)}}for(let[a,n]of e.entries())this.startSendingDeviceState(n,a,t,{animals:i,keepAlive:!0})}e(Object(D.d)(t,{dispensers:n,animals:i})),this.startLoading()}},this.clearData=()=>{const{chamber:e,dispatch:t,opened:a}=this.props;a&&t(Object(D.b)(e)),u.a.removeFromInterval(this.sentMessages),this.sentMessages=[]},this.toggleOpen=()=>{const{opened:e}=this.props;e?(this.clearData(),this.stopLoading(),this.updatePosition()):this.getData()},this.startSendingDeviceState=(e,t,a,{onSuccess:n,onFailure:i,keepAlive:s=!1,animals:r=[]}={})=>{console.log(e,t,r,"DSDADSSD"),u.a.removeFromInterval(this.sentMessages);const{CID:o,IndividualFeeding:c}=a;this.sentMessages.push(u.a.startSendingFeedingState(e,{onSuccess:n,onFailure:i,keepAlive:s})),c||this.sentMessages.push(u.a.startSendingFeedingStateRFID(t,o,{keepAlive:!0}))},this.updatePosition=()=>{window.dispatchEvent(new Event("resize")),window.dispatchEvent(new Event("scroll"))},this.sentMessages=[],this.state={loading:!0,sectorTypes:re.a.t("SType",{returnObjects:!0})}}shouldComponentUpdate(e,t,a){const{lang:n}=this.props;return!c()(this.props,e)||!c()(n,e.lang)}componentWillUnmount(){this.clearData()}componentDidUpdate(e,t,a){const{dispatch:n,opened:i,dispensers:s,chamber:r,animals:o}=this.props;i&&!c()(o,e.animals)&&n(Object(D.i)(r,{dispensers:s,animals:o})),i!==e.opened&&(this.updatePosition(),i&&Object(R.j)("chamber_".concat(r.CID))),e!==this.props&&this.setState({sectorTypes:re.a.t("SType",{returnObjects:!0})})}render(){const{license:e,animals:t,sectorType:a,index:n,chamber:i,dispensers:s,mobile:r,forageMap:o,curveMap:c,scheduleMap:l,viewType:u,unit:g,setEvent:f,opened:v}=this.props,{loading:D,sectorTypes:E}=this.state,{conditionCount:w=0}=e===Je.b.EXTENDED?this.getConditionCount({animals:t,curveMap:c,chamber:i}):{},y=!i.IndividualFeeding||!u,O=Object(b.b)(n);return d.a.createElement(d.a.Fragment,null,d.a.createElement(p.a,{style:{borderLeft:"4px solid ".concat(O)},className:"dispenser-chamber overflow-visible",fixedWidth:!0},d.a.createElement(m.a,{onClick:this.toggleOpen,className:"pointer"},d.a.createElement(h.a,{md:12},d.a.createElement("h5",{className:"chamber-menu justify-content-between",id:"chamber_".concat(i.CID)},d.a.createElement("span",null,(Object(B.a)()&&!v||!Object(B.a)())&&i.CName,(Object(B.a)()&&!v||!Object(B.a)())&&d.a.createElement("small",{className:"ml-1 d-none d-md-inline-block opacity-75"},E[a?a-1:999]),(Object(B.a)()&&!v||!Object(B.a)())&&d.a.createElement("i",{className:"ml-1 mr-1 fas fa-arrow-".concat(v?"up":"down")})),!!w&&d.a.createElement("span",null,w,d.a.createElement("i",{className:"ml-1 fas fa-pig info"}))))),!!v&&!y&&d.a.createElement(ia,{chamber:i,forageMap:o,unit:g,mobile:r,curveMap:c,sectorType:a,isLoading:D,isOpen:v,toggleOpen:this.toggleOpen,scheduleMap:l}),!!v&&y&&d.a.createElement(Kt,{chamber:i,forageMap:o,unit:g,sectorType:a,setEvent:f,startSendingDeviceState:this.startSendingDeviceState,curveMap:c,scheduleMap:l,isLoading:D,isOpen:v,toggleOpen:this.toggleOpen,dispensers:s,mobile:r})))}}sa.propTypes={chamber:f.a.object.isRequired,sectorType:f.a.object.isRequired,dispensers:f.a.array.isRequired,animals:f.a.array.isRequired,unit:f.a.number},sa.defaultProps={unit:Object(E.getFeedingUnit)()},sa=Object(v.connect)((e,t)=>{const{chamber:{CID:a}}=t;return{opened:!!e.feeding.feeding[a],farm:e.location.farm,license:Object(It.a)(e,{licenseName:Je.a.DISPENSER}),lang:e.language.lang.lang}})(sa);t.a=Object(T.a)()(sa)},"1iQD":function(e,t,a){},"1smR":function(e,t,a){"use strict";a.d(t,"a",(function(){return d}));var n=a("q1tI"),i=a.n(n),s=a("VyNe"),r=a("17x9"),o=a.n(r),c=a("uSQv"),l=a("LCzB");class d extends i.a.Component{constructor(...e){super(...e),this.onClick=()=>{this.props.onButtonClick()}}render(){const{title:e,children:t,disabled:a}=this.props;return i.a.createElement(s.a,{className:"device-settings-card"},i.a.createElement("h5",{className:"flex-lg-row justify-content-between align-content-center"},e,i.a.createElement(c.a,{disabled:a,buttonStyle:"round",className:"text",buttonColor:"success",icon:i.a.createElement("i",{className:"fas fa-save"}),onClick:this.onClick})),t)}}d.propTypes={title:o.a.string.isRequired,onButtonClick:o.a.func.isRequired,disabled:o.a.bool},t.b=Object(l.a)()(d)},"2JSo":function(e,t,a){},"4vr1":function(e,t,a){"use strict";var n=a("Y+p1"),i=a.n(n),s=a("q1tI"),r=a.n(s),o=a("/MKj"),c=a("SgeV"),l=a("3Z9Z"),d=a("JI6e"),m=a("uSQv"),h=a("mr+a"),u=a("W6fe"),p=a("15cA"),g=a("mxqY"),f=a("AF5L"),v=a("pxzG"),b=a("eASP"),D=a("IXwn"),E=a("EyHs"),w=a("ANjH"),y=a("f0zD"),O=a("QAqx"),C=a("msTn"),S=a("40zH"),I=a("0Lmq"),T=a("7y5B"),j=a("+V8T"),x=a("xi04"),M=a("LCzB"),k=a("XzT5"),N=a("A5yn");function R(){return(R=Object.assign||function(e){for(var t=1;tr.a.createElement(l.a,null,!!e&&r.a.createElement("label",{className:"text-center opacity-75"},e),!!t&&t.map((e,a)=>r.a.createElement(d.a,{xs:12/t.length},r.a.createElement(m.a,{type:"button",key:a,onClick:e.action,className:"w-100 pt-md-3 pb-md-3 pt-2 pb-2",icon:e.icon?r.a.createElement("i",{className:e.icon}):void 0,disabled:e.disabled,buttonColor:e.color},e.disabled?"".concat(e.text," (").concat(e.error,")"):e.text))),!!a&&r.a.createElement(d.a,{xs:12},r.a.createElement(D.a,{className:"justify-content-center"},a.map((e,t)=>r.a.createElement(m.a,{type:"button",key:t,onClick:e.action,className:(e.className||"")+" pt-md-3 pb-md-3 pt-2 pb-2",icon:e.icon?r.a.createElement("i",{className:e.icon}):void 0,buttonColor:e.color},e.text)))));class U extends s.Component{constructor(e){super(e),this.handleHide=()=>{try{this.drawer.current.handleShrink()}catch(e){}},this.clearSelection=()=>{const{dispatch:e,chamberId:t}=this.props;e(Object(N.h)({CID:t}))},this.callSubmit=(e,t={},a={})=>{const n=A({cookies:new Map,handleHide:()=>{},clearSelection:()=>{}},this.state);e(t,{},A({},n,{},a)),this.clearSelection(),this.handleHide()},this.handleExtraFeeding=(e=500)=>{this.callSubmit(u.a,{forageDose:e},{})},this.handleLock=(e=!1)=>{this.callSubmit(g.e,{status:e},{})},this.handleDose=(e=5)=>{const{receivers:t}=this.state;for(let[a,n]of t){const t=[];n.individualDTM.length&&n.individualDTM.forEach(a=>{t.push({DevID:a.DevID,dispensers:a.outputs.map(t=>({number:t.number,correctionChange:e}))})}),n.individualNRF.devices.length&&n.individualNRF.devices.forEach(a=>{t.push({DevID:a,correctionChange:e})}),t.length&&Object(f.c)(a,{devices:t})}this.handleHide()},this.handleDoseSkip=(e=!1)=>{const{receivers:t}=this.state;for(let[a,n]of t){const t=[];n.individualDTM.length&&n.individualDTM.forEach(a=>{t.push({DevID:a.DevID,dispensers:a.outputs.map(t=>({number:t.number,doses:e?6:1}))})}),n.individualNRF.devices.length&&n.individualNRF.devices.forEach(a=>{t.push({DevID:a,doses:e?6:1})}),t.length&&Object(f.x)(a,{devices:t})}this.clearSelection(),this.handleHide()},this.handleCondition=e=>{this.callSubmit(O.a,{doseCorrection:e},{})},this.openModal=e=>{const{show:t}=this.props,{feedingType:a,selectedNodes:n,receivers:i,chamberID:s,sectorType:r}=this.state;t(e,{type:a,selectedNodes:n,receivers:i,locationID:s,sectorType:r,clearSelection:()=>{this.clearSelection(),this.handleHide()}})},this.openConfirmModal=(e,t={})=>{const{show:a,t:n}=this.props,{feedingType:i,receivers:s,selectedNodes:r=[]}=this.state;e(A({show:a,feedingType:i,receivers:s,t:n,selectedNodes:r,onConfirmed:()=>{this.clearSelection(),this.handleHide()}},t))},this.handleDisable=()=>{this.openConfirmModal(g.c)},this.handleAssign=()=>{const{show:e,dispensersSelected:t,chamberId:a,chambers:n}=this.props,{sectorType:i}=this.state,s=n.find(e=>e.CID===a);e(x.a,{standing:{id:t[0].box.BID,animal:t[0].animal,device:t[0].receiver?{DevID:t[0].receiver.deviceId,GatewayID:t[0].receiver.gatewayId,Index:t[0].receiver.index}:void 0},chamber:s,sectorType:i})},this.drawer=r.a.createRef(),this.state=Object(p.i)(this.props.chamberId,this.props.dispensersSelected)}componentWillReceiveProps(e,t){const{chamberId:a,dispensersSelected:n}=this.props;if(!i()(a,e.chamberId)||!i()(n,e.dispensersSelected)){const t=Object(p.i)(e.chamberId,e.dispensersSelected);this.setState(A({},t))}}render(){const{isActive:e,dispensersSelected:t,t:a}=this.props,{sectorType:n}=this.state,i=[{buttons:[{text:a("deviceRows.feeding.dispenserSimpleButtons.assign"),action:()=>this.handleAssign(),disabled:1!==t.length,error:a("deviceRows.feeding.dispenserSimpleButtons.moreThanOne")}]},{buttons:[{text:a("alarms"),action:()=>this.openModal(j.a)}]},{buttons:[{text:a("deviceRows.feeding.dispenserSimpleButtons.emptyForage"),action:()=>this.openModal(T.a)},{text:a("deviceRows.feeding.dispenserSimpleButtons.disable"),action:()=>this.handleDisable()}]},{label:a("deviceRows.feeding.dispenserSimpleButtons.skipDoses"),buttons:[{text:a("deviceRows.feeding.dispenserSimpleButtons.closest"),action:()=>this.handleDoseSkip(!1)},{text:a("deviceRows.feeding.dispenserSimpleButtons.endOfDay"),action:()=>this.handleDoseSkip(!0)}]},{label:a("extraFeeding"),buttons:[{text:Object(v.j)(500,{unit:b.a.MEDIUM,showUnit:!0,fixed:1}),action:()=>this.handleExtraFeeding(500)},{text:Object(v.j)(1e3,{unit:b.a.MEDIUM,showUnit:!0,fixed:1}),action:()=>this.handleExtraFeeding(1e3)}]},[C.a.DELIVERY].includes(n)?{label:a("doseCorrection"),buttons:[{text:"-5%",color:"info",action:()=>this.handleDose(-5)},{text:"+5%",color:"success",action:()=>this.handleDose(5)}]}:{label:a("condition"),buttonGroup:[{text:"-25%",color:"info",action:()=>this.handleCondition(-25),className:"pl-1 pr-1 w-25"},{text:"-10%",color:"info",action:()=>this.handleCondition(-10),className:"pl-1 pr-1 w-25"},{text:"0%",action:()=>this.handleCondition(0),className:"pl-1 pr-1 w-25"},{text:"+10%",color:"success",action:()=>this.handleCondition(10),className:"pl-1 pr-1 w-25"},{text:"+25%",color:"success",action:()=>this.handleCondition(25),className:"pl-1 pr-1 w-25"}]},{buttons:[{icon:"fas fa-pause",action:()=>this.handleLock(!0)},{icon:"fas fa-play",action:()=>this.handleLock(!1)}]},{buttons:[{text:a("manageFeeding"),action:()=>this.openModal(E.a)}]}];return[C.a.DELIVERY].includes(n)?i[i.length-1].buttons.unshift({text:a("birth"),action:()=>this.openModal(S.a)}):[C.a.MATING].includes(n)&&i[i.length-1].buttons.unshift({text:a("insemination"),action:()=>this.openModal(I.a)}),r.a.createElement("div",null,r.a.createElement(c.a,{ref:this.drawer,text:k.a.t("deviceRows.feeding.dispenserSimpleButtons.selectedX",{count:t.length}),show:t.length&&e},r.a.createElement(d.a,{sm:12,md:6},i.map((e,t)=>r.a.createElement(L,R({key:"itm_".concat(t)},e))))))}}U=Object(o.connect)(null,e=>Object(w.b)({show:y.d},e))(U),U=Object(o.connect)((function(e){return{dispensersSelected:Object(h.g)(e,{CID:e.feeding.selectedChamber}),chamberId:e.feeding.selectedChamber}}))(U),t.a=Object(M.a)()(U)},"58CA":function(e,t,a){},"9CwR":function(e,t,a){},"9wQ1":function(e,t,a){"use strict";var n=a("lFKM"),i=a.n(n),s=a("q1tI"),r=a("17x9"),o=a.n(r),c=a("EP7i"),l=a("LCzB");class d extends s.Component{constructor(...e){super(...e),this.getValues=({t:e,isLoading:t,dateTime:a,isConnected:n,isAlerted:s,successClassName:r,isDisabled:o})=>{let l;if(t){if(!n)return{icon:"fas fa-fw fa-circle-notch fa-spin",color:n?r:"warning",header:e("deviceRows.iconStatus.loading")};l="fas fa-fw fa-circle-notch fa-spin"}if(n){return!!i()(a)&&Math.abs(a-+new Date)>c.a.DEVICE_OUTDATED_DATA?{icon:l||"fas fa-fw fa-sync",color:"warning",header:e("outOfSync")}:s?{icon:l||"fas fa-fw fa-exclamation",color:"error",header:e("alertedDevice")}:o?{icon:l||"fas fa-fw fa-pause",color:"disabled",header:e("deviceRows.iconStatus.disabled")}:{icon:l||"fas fa-fw fa-cog fa-spin",color:r,header:e("deviceRows.iconStatus.active")}}return{icon:"fas fa-fw fa-wifi-slash",color:"warning",header:e("notConnectedDevice")}}}componentDidMount(){this.interval=setInterval(()=>{this.forceUpdate()},c.a.DEVICE_OUTDATED_DATA_CHECK)}componentWillUnmount(){clearInterval(this.interval)}render(){const{children:e}=this.props,{icon:t,color:a,header:n}=this.getValues(this.props);return e({icon:t,color:a,header:n})}}d.propTypes={isLoading:o.a.bool.isRequired,responseTime:o.a.oneOf([o.a.number,null]),isConnected:o.a.bool.isRequired,isAlerted:o.a.bool.isRequired,children:o.a.func.isRequired,successClassName:o.a.string},d.defaultProps={successClassName:"success"},t.a=Object(l.a)()(d)},B7Ps:function(e,t,a){"use strict";var n,i=a("Y+p1"),s=a.n(i),r=a("q1tI"),o=a.n(r),c=a("wd/R"),l=a.n(c),d=a("/MKj"),m=a("17x9"),h=a.n(m),u=a("2wEF"),p=a("udB/"),g=a("pxzG"),f=a("eASP"),v=a("G7tO"),b=a("Vv3o"),D=a("VUd2"),E=a("Pi9d"),w=a.n(E),y=a("LCzB");let O=Object(d.connect)(e=>({cageData:e.aggregatedData.data}))(n=class extends r.Component{constructor(e){super(e),this.formatDate=e=>l()(e,"DD.MM.YYYY").toDate(),this.weightValueConverter=e=>Object(g.j)(e,{unit:f.a.MEDIUM,fixed:1,rawValue:!0}),this.onSliderChange=e=>{clearTimeout(this.state.timeout);let t=setTimeout(()=>{let t=this.props.cageData.get(this.props.cage.DevID);this.state.worker.postMessage({cageData:t,settlement:this.props.settlement,shadowInsertion:this.props.applyShadow?this.props.shadowInsertion:null,sliderValue:e})},100);this.setState({sliderValue:e,timeout:t})},this.state={data:[],loading:!0,sliderValue:null,timeout:null}}shouldComponentUpdate(e,t,a){return!s()(this.props.t("chamber"),e.t("chamber"))||!s()(this.state,t)}async componentDidMount(){let e=new w.a,t=this.props.cageData.get(this.props.cage.DevID);e.postMessage({cageData:t,settlement:this.props.settlement,shadowInsertion:this.props.applyShadow?this.props.shadowInsertion:null,sliderValue:this.state.sliderValue}),e.onmessage=e=>{this.setState({data:e.data.gain,sliderValue:e.data.closestIndex||this.state.sliderValue,loading:!1})},this.setState({worker:e})}UNSAFE_componentWillReceiveProps(e,t){let a=e.cageData.get(e.cage.DevID);this.state.worker.postMessage({cageData:a,settlement:e.settlement,shadowInsertion:e.applyShadow?e.shadowInsertion:null,sliderValue:this.state.sliderValue})}componentWillUnmount(){this.state.worker&&this.state.worker.terminate()}render(){const{loading:e,sliderValue:t,data:a}=this.state,{applyShadow:n}=this.props;let i=[{color:"green",dataKey:"all",name:this.props.t("all"),unit:Object(g.l)("weight",f.a.MEDIUM),valueConverter:this.weightValueConverter},{color:"blue",dataKey:"left",name:this.props.t("left"),unit:Object(g.l)("weight",f.a.MEDIUM),valueConverter:this.weightValueConverter,defaultOff:!0},{color:"orange",dataKey:"middle",name:this.props.t("middle"),unit:Object(g.l)("weight",f.a.MEDIUM),valueConverter:this.weightValueConverter,defaultOff:!0},{color:"pink",dataKey:"right",name:this.props.t("right"),unit:Object(g.l)("weight",f.a.MEDIUM),valueConverter:this.weightValueConverter,defaultOff:!0}];return n&&(i=[...i,{color:"green",dataKey:"allShadow",name:this.props.t("all"),unit:Object(g.l)("weight",f.a.MEDIUM),valueConverter:this.weightValueConverter,strokeOpacity:.4},{color:"blue",dataKey:"leftShadow",name:this.props.t("left"),unit:Object(g.l)("weight",f.a.MEDIUM),valueConverter:this.weightValueConverter,strokeOpacity:.4,defaultOff:!0},{color:"orange",dataKey:"middleShadow",name:this.props.t("middle"),unit:Object(g.l)("weight",f.a.MEDIUM),valueConverter:this.weightValueConverter,strokeOpacity:.4,defaultOff:!0},{color:"pink",dataKey:"rightShadow",name:this.props.t("right"),unit:Object(g.l)("weight",f.a.MEDIUM),valueConverter:this.weightValueConverter,strokeOpacity:.4,defaultOff:!0}]),o.a.createElement(o.a.Fragment,null,o.a.createElement(p.a,{isLoading:e}),0===a.length&&o.a.createElement(u.a,null),a.length>0&&o.a.createElement(o.a.Fragment,null,n&&o.a.createElement(b.a,{label:"Por\xf3wnanie",valueFormatter:e=>a[e].name,value:t||0,onChange:this.onSliderChange,max:a.length-1}),o.a.createElement(v.a,{dataDef:i,data:a,Yaxis:{name:this.props.t("weight")},Xaxis:{name:this.props.t("date"),dataKey:"name"},saveAsExcell:"gain",hasShadows:n,tooltipContent:n?o.a.createElement(D.a,null):null})))}})||n;O.propTypes={cage:h.a.object,settlement:h.a.shape({DtaStartTime:h.a.number.isRequired,DtaEndTime:h.a.number}),height:h.a.oneOfType([h.a.string,h.a.number]),applyShadow:h.a.bool,shadowInsertion:h.a.number},O.defaultProps={colors:{all:"#359d3c",left:"#4a9bd4",right:"#f44b4b",middle:"#ff9419",inactive:"#999"},connectNulls:!1,brushHeight:36,height:"100%",showExcelButton:!1,excelPortalContainerID:"chart-controls"},t.a=Object(y.a)()(O)},BPHX:function(e,t,a){"use strict";a.d(t,"a",(function(){return R}));var n,i=a("q1tI"),s=a.n(i),r=a("/MKj"),o=a("vYJ8"),c=a("JUMO"),l=(a("JUo3"),a("t1mp")),d=a("i8MS"),m=a("fz41"),h=a("Bffz"),u=a("17UY"),p=a("/kok"),g=a("7w6X"),f=a("4ltZ"),v=a("6uZD"),b=a("ZRKa"),D=a("xgzS"),E=a("rzZ0"),w=a("B2Cw"),y=a("lM7y"),O=a("D7Yj"),C=a("e6PY"),S=a("wd/R"),I=a.n(S),T=a("ui7M"),j=a("tMEj"),x=(a("f0Wu"),a("Akpi"));function M(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),a.push.apply(a,n)}return a}function k(e){for(var t=1;t({farm:e.location.farm,user:e.user.user,subscriptions:e.mqtt.subscriptions}))(n=class extends s.a.Component{constructor(...e){super(...e),this.state={progress:0,show:!1},this.controller=new window.AbortController,this.hideTimeout=null}componentDidMount(){this.fetchFarmData(),this.props.farm&&this.setState({show:!0,progress:0},()=>{this.startFetching()})}componentDidUpdate(e,t,a){this.props.farm!==e.farm&&(clearTimeout(this.hideTimeout),this.props.farm?(this.fetchFarmData(),this.state.show||this.setState({show:!0,progress:0},()=>{this.startFetching()})):(this.controller.abort(),this.setState({show:!1})))}runTask(e){return new Promise((t,a)=>{"requestIdleCallback"in window?window.requestIdleCallback(async()=>{try{this.state.show&&await e(),t()}catch(n){a(n)}}):setTimeout(async()=>{try{this.state.show&&await e(),t()}catch(n){a(n)}},0)})}updateProgress(e){"requestAnimationFrame"in window?window.requestAnimationFrame(()=>{this.setState({progress:e})}):this.setState({progress:e})}async getAnimals(e=null){const{farm:t}=this.props;let a={FarmID:t,DtaModTime:d.a.getModificationTime(t).DtaModTime,partial:!0};e&&(a.DtaModTime=0,a.ESKDtaModTime=e.DtaModTime,a.ESKAnmID=e.AnmID);let n=await Object(m.c)(k({},h.a.listAnimal({farmID:t}),{method:"GET",queryParams:a,signal:this.controller.signal})),i=n.items;return n.LastEvaluatedKey&&(this.updateProgress(this.state.progress+.1),i.push(...await this.getAnimals(n.LastEvaluatedKey))),i}async loadAnimals(){try{let e=await this.getAnimals();e.length>0&&await d.a.insertIntoAnimals(e)}catch(e){console.error(e)}}async getEvents(e=null){const{farm:t}=this.props;let a={FarmID:t,DtaModTime:u.a.getModificationTime(t).DtaModTime,partial:!0};e&&(a.DtaModTime=0,a.ESKDtaModTime=e.DtaModTime,a.ESKEvID=e.EvID);let n=await Object(m.c)(k({},h.a.listEvent({farmID:t}),{method:"GET",queryParams:a})),i=n.items;return n.LastEvaluatedKey&&(this.updateProgress(this.state.progress+.02),i.push(...await this.getEvents(n.LastEvaluatedKey))),i}async loadEvents(){try{let e=await this.getEvents();e.length>0&&await u.a.insertIntoEvents(e)}catch(e){console.error(e)}}async startFetching(){this.controller.abort(),this.controller=new window.AbortController;const{signal:e}=this.controller,{farm:t,user:a,subscriptions:n,dispatch:i}=this.props;await this.runTask(async()=>{await Object(l.a)(t,e),this.updateProgress(1),i(Object(f.d)(t))}),await this.runTask(async()=>{await Object(l.b)(t,a,e),this.updateProgress(2),i(Object(v.d)(t))}),await this.runTask(async()=>{await Object(l.d)(a.ClientID,t,e),this.updateProgress(3),i({type:"LIST_ALL_SETTINGS",payload:b.a.getAllSettings(t),meta:{user:a}})}),await this.runTask(async()=>{await Object(l.e)(t,e),this.updateProgress(4),i(Object(D.b)(t))}),await this.runTask(async()=>{await Object(l.g)(t,e),this.updateProgress(5),i(Object(E.a)(t))}),await this.runTask(async()=>{await this.loadAnimals(),this.updateProgress(6),i(Object(w.b)(t))}),await this.runTask(async()=>{await Object(l.c)(a.ClientID,e),this.updateProgress(7),i(Object(y.b)())}),await this.runTask(async()=>{await this.loadEvents(),this.updateProgress(8)}),await this.runTask(async()=>{await Object(l.f)(t,e),this.updateProgress(9),i(Object(C.a)(t))}),await this.runTask(async()=>{await Object(l.h)(a.ClientID,a.LocalUserID,e),this.updateProgress(10),i(Object(O.b)(t))}),await this.runTask(async()=>{n.length<2&&p.a.subscribeAllTopics(),await Object(g.a)(a),this.updateProgress(11),this.hideTimeout=setTimeout(()=>{this.setState({show:!1})},2e3)})}fetchFarmData(){if(this.props.farm){let e=Object(T.a)(this.props.farm);I.a.tz.setDefault(e),this.props.dispatch(Object(j.a)(this.props.farm))}else{let e=I.a.tz.guess(!0);I.a.tz.setDefault(e)}this.props.dispatch(Object(x.e)())}render(){return s.a.createElement(o.a,{in:this.state.show,className:"data-loader"},s.a.createElement(c.a,{now:this.state.progress,max:11,variant:11===this.state.progress?"success":""}))}})||n},BqhJ:function(e,t,a){"use strict";var n,i=a("q1tI"),s=a.n(i),r=a("wd/R"),o=a.n(r),c=a("/MKj"),l=a("17x9"),d=a.n(l),m=a("2wEF"),h=a("udB/"),u=a("pxzG"),p=a("eASP"),g=a("G7tO"),f=a("Vv3o"),v=a("VUd2"),b=a("zaLG"),D=a.n(b),E=a("LCzB");let w=Object(c.connect)(e=>({cageData:e.aggregatedData.data}))(n=class extends i.Component{constructor(e){super(e),this.formatDate=e=>o()(e,"DD.MM.YYYY").toDate(),this.weightValueConverter=e=>Object(u.j)(e,{unit:p.a.MEDIUM,fixed:1,rawValue:!0}),this.onSliderChange=e=>{clearTimeout(this.state.timeout);let t=setTimeout(()=>{let t=this.props.cageData.get(this.props.cage.DevID);this.state.worker.postMessage({cageData:t,settlement:this.props.settlement,shadowInsertion:this.props.applyShadow?this.props.shadowInsertion:null,sliderValue:e})},100);this.setState({sliderValue:e,timeout:t})},this.state={data:[],worker:void 0,loading:!0,sliderValue:null,timeout:null}}async componentDidMount(){let e=new D.a,t=this.props.cageData.get(this.props.cage.DevID);e.postMessage({cageData:t,settlement:this.props.settlement,shadowInsertion:this.props.applyShadow?this.props.shadowInsertion:null,sliderValue:this.state.sliderValue}),e.onmessage=e=>{console.log(e),this.setState({data:e.data.weight,sliderValue:e.data.closestIndex||this.state.sliderValue,loading:!1})},this.setState({worker:e})}UNSAFE_componentWillReceiveProps(e,t){let a=e.cageData.get(e.cage.DevID);this.state.worker.postMessage({cageData:a,settlement:e.settlement,shadowInsertion:e.applyShadow?e.shadowInsertion:null,sliderValue:this.state.sliderValue})}componentWillUnmount(){this.state.worker&&this.state.worker.terminate()}render(){const{loading:e,sliderValue:t,data:a}=this.state,{applyShadow:n}=this.props;let i=[{color:"green",dataKey:"all",name:this.props.t("all"),unit:Object(u.l)("weight",p.a.MEDIUM),valueConverter:this.weightValueConverter},{color:"blue",dataKey:"left",name:this.props.t("left"),unit:Object(u.l)("weight",p.a.MEDIUM),valueConverter:this.weightValueConverter,defaultOff:!0},{color:"orange",dataKey:"middle",name:this.props.t("middle"),unit:Object(u.l)("weight",p.a.MEDIUM),valueConverter:this.weightValueConverter,defaultOff:!0},{color:"pink",dataKey:"right",name:this.props.t("right"),unit:Object(u.l)("weight",p.a.MEDIUM),valueConverter:this.weightValueConverter,defaultOff:!0}];return n&&(i=[...i,{color:"green",dataKey:"allShadow",name:this.props.t("all"),unit:Object(u.l)("weight",p.a.MEDIUM),valueConverter:this.weightValueConverter,strokeOpacity:.4},{color:"blue",dataKey:"leftShadow",name:this.props.t("left"),unit:Object(u.l)("weight",p.a.MEDIUM),valueConverter:this.weightValueConverter,strokeOpacity:.4,defaultOff:!0},{color:"orange",dataKey:"middleShadow",name:this.props.t("middle"),unit:Object(u.l)("weight",p.a.MEDIUM),valueConverter:this.weightValueConverter,strokeOpacity:.4,defaultOff:!0},{color:"pink",dataKey:"rightShadow",name:this.props.t("right"),unit:Object(u.l)("weight",p.a.MEDIUM),valueConverter:this.weightValueConverter,strokeOpacity:.4,defaultOff:!0}]),s.a.createElement(s.a.Fragment,null,s.a.createElement(h.a,{isLoading:e}),0===a.length&&s.a.createElement(m.a,null),a.length>0&&s.a.createElement(s.a.Fragment,null,n&&s.a.createElement(f.a,{label:"Por\xf3wnanie",valueFormatter:e=>a[e].name,value:t||0,onChange:this.onSliderChange,max:a.length-1}),s.a.createElement(g.a,{dataDef:i,data:a,Yaxis:{name:this.props.t("weight")},Xaxis:{name:this.props.t("date"),dataKey:"name"},saveAsExcell:"weights",hasShadows:n,tooltipContent:n?s.a.createElement(v.a,null):null})))}})||n;w.propTypes={cage:d.a.object,settlement:d.a.shape({DtaStartTime:d.a.number.isRequired,DtaEndTime:d.a.number}),height:d.a.oneOfType([d.a.string,d.a.number]),applyShadow:d.a.bool,shadowInsertion:d.a.number},w.defaultProps={colors:{all:"#359d3c",left:"#4a9bd4",right:"#f44b4b",middle:"#ff9419",inactive:"#999"},connectNulls:!1,brushHeight:36,height:"100%"},t.a=Object(E.a)()(w)},DsOL:function(e,t,a){},EUHq:function(e,t,a){"use strict";var n=a("q1tI"),i=a.n(n),s=a("/MKj"),r=a("re1K"),o=a("/kok"),c=a("VfnB"),l=a("zDJl"),d=a("vSUv"),m=a.n(d),h=a("KWeU"),u=a("q17X"),p=a("mwIZ"),g=a.n(p),f=a("17x9"),v=a.n(f),b=a("wd/R"),D=a.n(b),E=a("pxzG"),w=a("eASP"),y=a("ECHa"),O=a("PGv+"),C=a("VRSS"),S=a("eKAg"),I=a("s/FU"),T=a("zv3H"),j=a("objY"),x=a("t6+f"),M=a("3SM+"),k=a("mXvJ"),N=a("YPNF"),R=a("X/ou"),F=a("qx5e"),A=a("s506"),P=a("uSQv"),L=a("udB/"),U=a("G7tO"),Y=a("LCzB"),V=a("ZW/8"),W=a("e8oE");class B extends n.Component{constructor(...e){super(...e),this.getData=()=>{const{aggregated:{data:e},date:t}=this.props,{temps:a,lastTime:n}=Object(V.j)(e,+t);return{data:[...a.values()],lastTime:n}},this.tickFormatter=e=>D()(e).format("HH:mm")}render(){const{data:e,lastTime:t}=this.getData(),{date:a,aggregated:{fetching:n},t:s}=this.props,r=Object(E.l)("temperature",w.a.SMALL),o=[{color:"green",dataKey:"temperature",name:s("chamber.chart.temperature"),unit:r,opacity:.2,valueConverter:V.m},{color:"blue",dataKey:"temperatureDesired",name:s("chamber.chart.temperatureDesired"),unit:r,opacity:.2,valueConverter:V.m},{color:"red",dataKey:"minTemp",name:s("chamber.chart.minTemp"),unit:r,valueConverter:V.m},{color:"red",dataKey:"maxTemp",name:s("chamber.chart.maxTemp"),unit:r,valueConverter:V.m}],c=[];for(let i=0;i<=t;i++)c.push(a.clone().hour(i).startOf("hour").toDate().getTime());return i.a.createElement(i.a.Fragment,null,i.a.createElement(L.a,{bgInherit:!0,isLoading:n}),i.a.createElement(i.a.Fragment,null,i.a.createElement(U.a,{dataDef:o,data:e,Yaxis:{name:s("chamber.chart.temperature")},Xaxis:{name:s("time"),dataKey:"name",ticks:c,domain:[a.clone().startOf("day").toDate().getTime(),"dataMax"],formatter:this.tickFormatter,type:"number"},saveAsExcell:"temperature",tooltipLabelFormatter:this.tickFormatter,showDomainInput:!0})))}}B.defaultProps={colors:{temperature:"#359d3c",minTemp:"#000000",maxTemp:"#f44b4b",temperatureDesired:"#4a9bd4",inactive:"#999"},connectNulls:!0,date:D()().subtract(1,"days"),showGrid:v.a.bool,onSetGridApi:v.a.func,height:"100%",showExcelButton:!1,excelPortalContainerID:"chart-controls"},B.propTypes={colors:v.a.object,connectNulls:v.a.bool,date:v.a.instanceOf(D.a).isRequired,device:v.a.object.isRequired,height:v.a.oneOfType([v.a.string,v.a.number]),showExcelButton:v.a.bool,excelPortalContainerID:v.a.string},B=Object(s.connect)((function(){const e=Object(W.a)();return function(t,a){return{aggregated:e(t,a.device)}}}))(B);var q=Object(Y.a)()(B),K=a("dxSB");class H extends n.Component{constructor(...e){super(...e),this.getData=()=>{const{date:e,aggregated:{data:t}}=this.props,{vents:a,lastTime:n}=Object(V.k)(t,+e);return{data:[...a.values()],lastTime:n}}}render(){const{aggregated:{fetching:e},date:t,t:a}=this.props,{data:n,lastTime:s}=this.getData(),r=Object(E.l)("temperature",w.a.SMALL),o=[{color:"blue",dataKey:"ventilation",name:a("chamber.chart.ventilation"),unit:"%",opacity:.2,yAxisId:"ventilation"},{color:"green",dataKey:"temperature",name:a("chamber.chart.temperature"),unit:r,opacity:.2,yAxisId:"temperature",valueConverter:V.m}],c=[];for(let i=0;i<=s;i++)c.push(t.clone().hour(i).startOf("hour").toDate().getTime());return i.a.createElement(i.a.Fragment,null,i.a.createElement(L.a,{bgInherit:!0,isLoading:e}),i.a.createElement(U.a,{dataDef:o,data:n,Yaxis:{name:a("chamber.chart.ventilation"),yAxisId:"ventilation"},Xaxis:{name:a("time"),dataKey:"name",ticks:c,domain:[t.startOf("day").toDate().getTime(),"dataMax"],formatter:V.n,type:"number"},secondYaxis:{name:a("chamber.chart.temperature"),yAxisId:"temperature"},saveAsExcell:"ventilation",tooltipLabelFormatter:V.n,showDomainInput:!0}))}}H.defaultProps={colors:{ventilation:"#4a9bd4",temperature:"#359d3c",masters:"#ff9419",inactive:"#999"},connectNulls:!0,date:D()().subtract(1,"days"),showExcelButton:!1,excelPortalContainerID:"chart-controls"},H.propTypes={colors:v.a.object,connectNulls:v.a.bool,date:v.a.instanceOf(D.a).isRequired,device:v.a.object.isRequired,showExcelButton:v.a.bool,excelPortalContainerID:v.a.string},H=Object(s.connect)((function(){const e=Object(W.a)();return function(t,a){return{aggregated:e(t,a.device)}}}))(H);var _=Object(Y.a)()(H);class z extends n.Component{constructor(...e){super(...e),this.getData=()=>{const{date:e,aggregated:{data:t}}=this.props,a=t.find(t=>t.AggTi===+e),{humidity:n,lastTime:i}=a?Object(V.d)(a):{humidity:[],lastTime:0};return{data:n,lastTime:i}}}render(){const{aggregated:{fetching:e},date:t,t:a}=this.props,{data:n,lastTime:s}=this.getData(),r=Object(E.l)("temperature",w.a.SMALL);let o=[{color:"blue",dataKey:"humidity",name:a("chamber.chart.humidity"),unit:"%",opacity:.2,yAxisId:"humidity"},{color:"green",dataKey:"temperature",name:a("chamber.chart.temperature"),unit:r,opacity:.2,yAxisId:"temperature",valueConverter:V.m}],c=[];for(let i=0;i<=s;i++)c.push(t.clone().hour(i).startOf("hour").toDate().getTime());return i.a.createElement(i.a.Fragment,null,i.a.createElement(L.a,{bgInherit:!0,isLoading:e}),i.a.createElement(U.a,{dataDef:o,data:n,Yaxis:{name:a("chamber.chart.humidity"),yAxisId:"humidity"},Xaxis:{name:a("time"),dataKey:"name",ticks:c,domain:[t.startOf("day").toDate().getTime(),"dataMax"],formatter:V.n,type:"number"},secondYaxis:{name:a("chamber.chart.temperature"),yAxisId:"temperature"},saveAsExcell:"humidity",tooltipLabelFormatter:V.n,showDomainInput:!0}))}}z.defaultProps={colors:{humidity:"#4a9bd4",temperature:"#359d3c",inactive:"#999"},connectNulls:!0,date:D()().subtract(1,"days"),showExcelButton:!1,excelPortalContainerID:"chart-controls"},z.propTypes={colors:v.a.object,connectNulls:v.a.bool,date:v.a.instanceOf(D.a).isRequired,device:v.a.object.isRequired,showExcelButton:v.a.bool,excelPortalContainerID:v.a.string},z=Object(s.connect)((function(){const e=Object(W.a)();return function(t,a){return{aggregated:e(t,a.device)}}}))(z);var G=Object(Y.a)()(z);class X extends n.Component{constructor(...e){super(...e),this.getData=()=>{const{date:e,aggregated:{data:t}}=this.props,a=t.find(t=>t.AggTi===+e),{slurry:n,lastTime:i}=a?Object(V.i)(a):{slurry:[],lastTime:0};return{data:n,lastTime:i}}}render(){const{aggregated:{fetching:e},date:t,t:a}=this.props,{data:n,lastTime:s}=this.getData(),r=Object(E.l)("length",w.a.MEDIUM),o=[{color:"black",dataKey:"slurry",name:a("chamber.chart.slurry"),unit:r,opacity:.4,valueConverter:V.l}];let c=[];for(let i=0;i<=s;i++)c.push(t.clone().hour(i).startOf("hour").toDate().getTime());return i.a.createElement(i.a.Fragment,null,i.a.createElement(L.a,{bgInherit:!0,isLoading:e}),i.a.createElement(U.a,{dataDef:o,data:n,Yaxis:{name:a("chamber.chart.slurry")},Xaxis:{name:a("time"),dataKey:"name",ticks:c,domain:[t.startOf("day").toDate().getTime(),"dataMax"],formatter:V.n,type:"number"},saveAsExcell:"slurry",tooltipLabelFormatter:V.n,showDomainInput:!0}))}}X.defaultProps={colors:{slurry:"#724527"},connectNulls:!0,date:D()().subtract(1,"days"),showExcelButton:!1,excelPortalContainerID:"chart-controls"},X.propTypes={colors:v.a.object,connectNulls:v.a.bool,date:v.a.instanceOf(D.a).isRequired,device:v.a.object.isRequired,showExcelButton:v.a.bool,excelPortalContainerID:v.a.string},X=Object(s.connect)((function(){const e=Object(W.a)();return function(t,a){return{aggregated:e(t,a.device)}}}))(X);var Z=Object(Y.a)()(X);class J extends n.Component{constructor(...e){super(...e),this.getData=()=>{const{date:e,aggregated:{data:t}}=this.props,a=t.find(t=>t.AggTi===+e),{h2s:n,lastTime:i}=a?Object(V.c)(a):{h2s:[],lastTime:0};return{data:n,lastTime:i}}}render(){const{aggregated:{fetching:e},date:t,t:a}=this.props,{data:n,lastTime:s}=this.getData(),r=[{color:"black",dataKey:"h2s",name:a("chamber.chart.h2s"),unit:"ppm",opacity:.2}],o=[];for(let i=0;i<=s;i++)o.push(t.clone().hour(i).startOf("hour").toDate().getTime());return i.a.createElement(i.a.Fragment,null,i.a.createElement(L.a,{bgInherit:!0,isLoading:e}),i.a.createElement(U.a,{dataDef:r,data:n,Yaxis:{name:a("chamber.chart.h2s")},Xaxis:{name:a("time"),dataKey:"name",ticks:o,domain:[t.startOf("day").toDate().getTime(),"dataMax"],formatter:V.n,type:"number"},saveAsExcell:"h2s",tooltipLabelFormatter:V.n,showDomainInput:!0}))}}J.defaultProps={colors:{h2s:"#ff9419"},connectNulls:!0,date:D()().subtract(1,"days"),showExcelButton:!1,excelPortalContainerID:"chart-controls"},J.propTypes={colors:v.a.object,connectNulls:v.a.bool,date:v.a.instanceOf(D.a).isRequired,climate:v.a.object.isRequired,showExcelButton:v.a.bool,excelPortalContainerID:v.a.string},J=Object(s.connect)((function(){const e=Object(W.a)();return function(t,a){return{aggregated:e(t,a.device)}}}))(J);var Q=Object(Y.a)()(J);class $ extends n.Component{constructor(...e){super(...e),this.getData=()=>{const{date:e,aggregated:{data:t}}=this.props,a=t.find(t=>t.AggTi===+e),{nh3:n,lastTime:i}=a?Object(V.e)(a):{nh3:[],lastTime:0};return{data:n,lastTime:i}}}render(){const{aggregated:{fetching:e},date:t,t:a}=this.props,{data:n,lastTime:s}=this.getData(),r=[{color:"black",dataKey:"nh3",name:a("chamber.chart.nh3"),unit:"ppm",opacity:.2}],o=[];for(let i=0;i<=s;i++)o.push(t.clone().hour(i).startOf("hour").toDate().getTime());return i.a.createElement(i.a.Fragment,null,i.a.createElement(L.a,{bgInherit:!0,isLoading:e}),i.a.createElement(U.a,{dataDef:r,data:n,Yaxis:{name:a("chamber.chart.nh3")},Xaxis:{name:a("time"),dataKey:"name",ticks:o,domain:[t.startOf("day").toDate().getTime(),"dataMax"],formatter:V.n,type:"number"},saveAsExcell:"nh3",tooltipLabelFormatter:V.n,showDomainInput:!0}))}}$.defaultProps={colors:{nh3:"#c018ff"},connectNulls:!0,date:D()().subtract(1,"days"),showExcelButton:!1,excelPortalContainerID:"chart-controls"},$.propTypes={colors:v.a.object,connectNulls:v.a.bool,date:v.a.instanceOf(D.a).isRequired,device:v.a.object.isRequired,showExcelButton:v.a.bool,excelPortalContainerID:v.a.string},$=Object(s.connect)((function(){const e=Object(W.a)();return function(t,a){return{aggregated:e(t,a.device)}}}))($);var ee=Object(Y.a)()($);class te extends n.Component{constructor(...e){super(...e),this.getData=()=>{const{date:e,aggregated:{data:t}}=this.props,a=t.find(t=>t.AggTi===+e),{co2:n,lastTime:i}=a?Object(V.b)(a):{co2:[],lastTime:0};return{data:n,lastTime:i}}}render(){const{aggregated:{fetching:e},date:t,t:a}=this.props,{data:n,lastTime:s}=this.getData(),r=[{color:"black",dataKey:"co2",name:a("chamber.chart.co2"),unit:"ppm",opacity:.2}],o=[];for(let i=0;i<=s;i++)o.push(t.clone().hour(i).startOf("hour").toDate().getTime());return i.a.createElement(i.a.Fragment,null,i.a.createElement(L.a,{bgInherit:!0,isLoading:e}),i.a.createElement(U.a,{dataDef:r,data:n,Yaxis:{name:a("chamber.chart.co2")},Xaxis:{name:a("time"),dataKey:"name",ticks:o,domain:[t.startOf("day").toDate().getTime(),"dataMax"],formatter:V.n,type:"number"},saveAsExcell:"co2",tooltipLabelFormatter:V.n,showDomainInput:!0}))}}te.defaultProps={date:D()().subtract(1,"days")},te.propTypes={date:v.a.instanceOf(D.a).isRequired,device:v.a.object.isRequired},te=Object(s.connect)((function(){const e=Object(W.a)();return function(t,a){return{aggregated:e(t,a.device)}}}))(te);var ae=Object(Y.a)()(te);class ne extends n.Component{constructor(...e){super(...e),this.getData=()=>{const{date:e,aggregated:{data:t}}=this.props,a=t.find(t=>t.AggTi===+e),{pressure:n,lastTime:i}=a?Object(V.f)(a):{pressure:[],lastTime:0};return{data:n,lastTime:i}}}render(){const{aggregated:{fetching:e},date:t,t:a}=this.props,{data:n,lastTime:s}=this.getData(),r=[{color:"blue",dataKey:"pressure",name:a("chamber.chart.pressure"),unit:"bar",opacity:.4}],o=[];for(let i=0;i<=s;i++)o.push(t.clone().hour(i).startOf("hour").toDate().getTime());return i.a.createElement(i.a.Fragment,null,i.a.createElement(L.a,{bgInherit:!0,isLoading:e}),i.a.createElement(U.a,{dataDef:r,data:n,Yaxis:{name:a("chamber.chart.pressure")},Xaxis:{name:a("time"),dataKey:"name",ticks:o,domain:[t.startOf("day").toDate().getTime(),"dataMax"],formatter:V.n,type:"number"},saveAsExcell:"pressure",tooltipLabelFormatter:V.n,showDomainInput:!0}))}}ne.defaultProps={date:D()().subtract(1,"days")},ne.propTypes={date:v.a.instanceOf(D.a).isRequired,device:v.a.object.isRequired},ne=Object(s.connect)((function(){const e=Object(W.a)();return function(t,a){return{aggregated:e(t,a.device)}}}))(ne);var ie=Object(Y.a)()(ne),se=a("2dKy"),re=a("hw2D"),oe=a("ANjH"),ce=a("n2uv");class le extends n.Component{constructor(...e){super(...e),this.getData=()=>{const{date:e,aggregated:{data:t}}=this.props,a=t.find(t=>t.AggTi===+e),{data:n,lastTime:i}=a?Object(V.a)(a):{data:[],lastTime:0};return{data:n,lastTime:i}},this.worktypeFormatter=e=>{const{t:t}=this.props;switch(e){case 0:return t("chamber.chart.climateStandard");case 1:return t("chamber.chart.climateManual");case 2:return t("chamber.chart.climateSoaking");case 3:return t("chamber.chart.climateDrying");default:return e}},this.curveActiveFormatter=e=>{const{t:t}=this.props;return t(e?"active":"chamber.chart.curveActiveFalse")},this.tooltipFormatter=(e,t,a)=>"worktype"===a.dataKey?this.worktypeFormatter(e):this.curveActiveFormatter(e)}render(){const{aggregated:{fetching:e},date:t,t:a}=this.props,{data:n,lastTime:s}=this.getData(),r=[];for(let i=0;i<=s;i++)r.push(t.clone().hour(i).startOf("hour").toDate().getTime());const o=[{color:"green",dataKey:"worktype",name:a("worktype"),opacity:.2,yAxisId:"worktype",type:"stepAfter"},{color:"blue",dataKey:"curveActive",name:a("climateCurve"),opacity:.2,yAxisId:"curveActive",type:"stepAfter"}];return i.a.createElement(i.a.Fragment,null,i.a.createElement(L.a,{isLoading:e}),i.a.createElement(U.a,{dataDef:o,data:n,Yaxis:{formatter:this.worktypeFormatter,ticks:[0,1,2,3],width:100,yAxisId:"worktype"},secondYaxis:{yAxisId:"curveActive",ticks:[0,1],formatter:this.curveActiveFormatter,width:100},Xaxis:{name:a("time"),dataKey:"name",ticks:r,type:"number",formatter:V.n,domain:[t.clone().startOf("day").toDate().getTime(),"dataMax"]},saveAsExcell:"climateSettings",tooltipFormatter:this.tooltipFormatter,tooltipLabelFormatter:V.n}))}}le.propTypes={climate:v.a.instanceOf(ce.a).isRequired,date:v.a.instanceOf(D.a).isRequired};var de=Object(oe.d)(Object(s.connect)((function(){const e=Object(W.a)();return function(t,a){return{aggregated:e(t,a.device)}}})),Object(Y.a)())(le),me=a("JI6e"),he=a("3Z9Z");class ue extends i.a.Component{constructor(e){super(e),this.onChartChange=e=>{this.setState({chart:e})},this.onDateChange=e=>{let t=D.a.utc(e);this.setDate(t)},this.onLowerDateClick=()=>{let e=this.state.date.clone().subtract(1,"day");this.setDate(e)},this.onAddDateClick=()=>{let e=this.state.date.clone().add(1,"day");this.setDate(e)},this.getOptions=()=>{const{t:e}=this.props;return[{name:e("chamber.chart.temperature"),value:"temperature"},{name:e("chamber.chart.ventilation"),value:"ventilation"},{name:e("chamber.chart.humidity"),value:"humidity"},{name:e("chamber.chart.slurry"),value:"slurry"},{name:e("chamber.chart.h2s"),value:"h2s"},{name:e("chamber.chart.nh3"),value:"nh3"},{name:e("chamber.chart.co2"),value:"co2"},{name:e("chamber.chart.pressure"),value:"pressure"},{name:e("chamber.chart.climateSettings"),value:"settings"}]},this.state={chart:"temperature",date:D.a.utc().startOf("day")}}componentDidMount(){const{device:e}=this.props,{date:t}=this.state;o.a.sendRequestForAggregatedData(e),this.checkIfHaveInAggregatedData(t.toDate().getTime()),this.props.measure()}componentWillUnmount(){}checkIfHaveInAggregatedData(e){const{aggregated:{data:t},dispatch:a,device:n}=this.props;t.find(t=>t.AggTi===e)||a(Object(K.a)(n,{AggDataTime:e}))}setDate(e){e.diff(D.a.utc().startOf("day"),"days")<=0&&(this.setState({date:e}),this.checkIfHaveInAggregatedData(e.toDate().getTime()))}render(){const{device:e}=this.props,{chart:t,date:a}=this.state,n=this.getOptions();return i.a.createElement("div",{className:"device-charts"},i.a.createElement(me.a,{xs:12,className:"mt-2"},i.a.createElement(he.a,{className:"device-chart-select"},i.a.createElement(me.a,{xs:12,xl:8,className:"chart-type mb-2"},i.a.createElement(re.a,{value:t,options:n,onChange:this.onChartChange,clearButton:!1})),i.a.createElement(me.a,{xs:12,xl:4,className:"chart-date mb-2"},i.a.createElement(P.a,{icon:i.a.createElement("i",{className:"fas fa-chevron-left"}),onClick:this.onLowerDateClick}),i.a.createElement(se.a,{type:"date",value:this.state.date.format("YYYY-MM-DD"),onChange:this.onDateChange}),i.a.createElement(P.a,{icon:i.a.createElement("i",{className:"fas fa-chevron-right"}),onClick:this.onAddDateClick})))),i.a.createElement("div",{className:"device-chart"},"temperature"===t&&i.a.createElement(i.a.Fragment,null,i.a.createElement("div",{className:"chart-main-container"},i.a.createElement(q,{device:e,date:a,showExcelButton:!0}))),"ventilation"===t&&i.a.createElement(i.a.Fragment,null,i.a.createElement("div",{className:"chart-main-container"},i.a.createElement(_,{device:e,date:a,showExcelButton:!0}))),"humidity"===t&&i.a.createElement(i.a.Fragment,null,i.a.createElement("div",{className:"chart-main-container"},i.a.createElement(G,{device:e,date:a,showExcelButton:!0}))),"slurry"===t&&i.a.createElement(i.a.Fragment,null,i.a.createElement("div",{className:"chart-main-container"},i.a.createElement(Z,{device:e,date:a,showExcelButton:!0}))),"h2s"===t&&i.a.createElement(i.a.Fragment,null,i.a.createElement("div",{className:"chart-main-container"},i.a.createElement(Q,{device:e,date:a,showExcelButton:!0}))),"nh3"===t&&i.a.createElement(i.a.Fragment,null,i.a.createElement("div",{className:"chart-main-container"},i.a.createElement(ee,{device:e,date:a,showExcelButton:!0}))),"co2"===t&&i.a.createElement(i.a.Fragment,null,i.a.createElement("div",{className:"chart-main-container"},i.a.createElement(ae,{device:e,date:a,showExcelButton:!0}))),"pressure"===t&&i.a.createElement(i.a.Fragment,null,i.a.createElement("div",{className:"chart-main-container"},i.a.createElement(ie,{device:e,date:a,showExcelButton:!0}))),"settings"===t&&i.a.createElement(i.a.Fragment,null,i.a.createElement("div",{className:"chart-main-container"},i.a.createElement(de,{device:e,date:a})))))}}ue.propTypes={device:v.a.object.isRequired,id:v.a.string,placements:v.a.array,name:v.a.string},ue=Object(F.a)(e=>({roles:[A.c._DEVICE_CLIMATE],devPlcmnts:Object(c.f)(e.device)}))(ue),ue=Object(s.connect)((function(){const e=Object(W.a)();return function(t,a){return{aggregated:e(t,a.device)}}}))(ue);var pe=Object(Y.a)()(ue),ge=a("thTS"),fe=a("99/+"),ve=a("wQVC"),be=a("F07D"),De=a("Uip1"),Ee=a("GSes"),we=a("VyNe");function ye(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),a.push.apply(a,n)}return a}function Oe(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}class Ce extends i.a.Component{constructor(...e){super(...e),this.hasAlarm=e=>!e||e.ambientConditions.alerts.reduce((e,t)=>e+t,0)>0,this.tempFormatter=e=>Object(E.f)(e,{showUnit:!0,fixed:1}),this.getValues=()=>{const{shadow:e,name:t,t:a,device:n,fetching:s}=this.props,r=Object(E.l)("temperature",w.a.SMALL),o=Object(E.l)("length",w.a.MEDIUM),l=this.getErrors(),d=e=>Object(E.f)(e,{unit:w.a.SMALL,showUnit:!0,fixed:1,acceptNil:!0,rawValue:!0});return{upperTitle:t,title:this.getTemperature(e),lowerTitle:this.isActive(e)?"".concat(a("chamber.chart.temperatureDesired"),": ").concat(this.getExpectedTemperature(e)):a("inactive"),number:n.Number||"-",icon:{errors:l,isLoading:s,isConnected:!!e,dateTime:Object(c.o)(g()(e,"metadata")),isDisabled:!this.isActive(e),isAlerted:this.hasAlarm(e)},params:[{value:g()(e,"ambientConditions.generalVentilationEfficiency"),title:a("chamber.chart.ventilation"),icon:y.a,unit:"%",valueFormatter:c.c,show:!0},{value:g()(e,"ambientConditions.requestedAirTemperature")-g()(e,"configuration.alarms.minimumTemperatureAlarmDeviation"),title:a("minTempAlarm"),icon:x.a,unit:r,valueFormatter:d,show:!0},{value:g()(e,"ambientConditions.requestedAirTemperature")+g()(e,"configuration.alarms.maximumTemperatureAlarmDeviation"),title:a("maxTempAlarm"),icon:M.a,unit:r,valueFormatter:d,show:!0},{value:g()(e,"configuration.ventilationConfiguration.minimumVentilation"),title:a("farmView.climate.minVentilation"),icon:N.a,unit:"%",valueFormatter:c.c,show:!0},{value:g()(e,"configuration.ventilationConfiguration.maximumVentilation"),title:a("farmView.climate.maxVentilation"),icon:R.a,unit:"%",valueFormatter:c.c,show:!0},{value:g()(e,"shadow.ambientConditions.expansionCardSensorsIndications[2]"),title:a("chamber.chart.humidity"),icon:O.a,unit:"%"},{value:g()(e,"service.cooling"),title:a("chamber.chart.cooling"),icon:k.a,valueFormatter:e=>i.a.createElement("i",{className:"fas fa-fw fa-".concat(e?"check":"times")})},{value:g()(e,"ambientConditions.expansionCardSensorsIndications[3]"),title:a("chamber.chart.pressure"),icon:j.a,unit:"bar"},{value:g()(e,"ambientConditions.expansionCardSensorsIndications[0]"),title:a("chamber.chart.slurry"),icon:C.a,unit:o,valueFormatter:e=>Object(E.c)(e,{unit:w.a.MEDIUM,showUnit:!0,fixed:1,acceptNil:!0,rawValue:!0})},{value:g()(e,"shadow.ambientConditions.expansionCardSensorsIndications[4]"),title:a("chamber.chart.co2"),icon:T.a,unit:"ppm"},{value:g()(e,"shadow.ambientConditions.expansionCardSensorsIndications[6]"),title:a("chamber.chart.nh3"),icon:I.a,unit:"ppm"},{value:g()(e,"shadow.ambientConditions.expansionCardSensorsIndications[5]"),title:a("chamber.chart.h2s"),icon:S.a,unit:"ppm"}]}},this.getErrors=()=>{const{t:e,shadow:t}=this.props;try{if(t&&t.ambientConditions.alerts.reduce((e,t)=>e+t,0)>0){if(t.ambientConditions.alerts[0]&&t.ambientConditions.alerts[1])return[e("farmView.climate.absoluteAlarm")];let a=[];for(let n=0;n{const s=this.getErrors();return i.a.createElement(Ee.a,{tooltipContent:i.a.createElement("div",null,i.a.createElement("div",null,t),!!n&&i.a.createElement("div",null,i.a.createElement("i",{className:"fas fa-sync mr-1"}),i.a.createElement("b",null,D()(n).format("HH:mm:ss DD.MM.YY"))),i.a.createElement("div",null,i.a.createElement("small",null,s.join("\n")))),placement:"left",type:e},i.a.createElement("div",null,i.a.createElement("i",{className:a})))},this.onContextMenu=e=>{const{openMenu:t,device:a}=this.props;return e.stopPropagation(),e.preventDefault(),e.persist(),t(e,a),!1}}getTemperature(e){if(!e)return"-";let t;try{t=e.ambientConditions.averageCurrentAirTemperature}catch(a){t=void 0}return this.tempFormatter(t)}componentDidUpdate(e,t,a){e.expanded!==this.props.expanded&&(this.props.expanded||Object(ve.i)(this.props.measure))}getExpectedTemperature(e){if(!this.isActive(e))return"-";let t;try{t=e.ambientConditions.requestedAirTemperature}catch(a){t=void 0}return this.tempFormatter(t)}isActive(e){try{return e.configuration.isActive&&!e.ambientConditions.controllerStatus[2]}catch(t){return!1}}render(){const{onExpand:e,selected:t,onSelect:a,expanded:n,measure:s,device:r}=this.props,{upperTitle:o,title:c,lowerTitle:l,params:d,icon:m,number:h}=this.getValues();return i.a.createElement(me.a,{xs:12},i.a.createElement(we.a,{type:"container",className:"pointer",selected:t},i.a.createElement(De.a,{onClick:a,icon:m,upperTitle:o,title:c,lowerTitle:l,params:d,expanded:n,selected:t,onExpand:e,number:h,showingCallback:s,onContextMenu:this.onContextMenu}),!!n&&i.a.createElement(pe,{measure:s,device:r})))}}Ce.propTypes={device:v.a.object.isRequired,id:v.a.string,placements:v.a.array,name:v.a.string},(Ce=Object(s.connect)((function(){const e=Object(ge.a)(),t=Object(be.d)(),a=Object(be.c)(),n={type:"climates"};return function(i,s){return n.id=s.id,function(e){for(var t=1;t(a.stopPropagation(),e(Object(fe.d)("climates",t.id)),!1),onExpand:()=>e(Object(fe.c)("climates",t.id))}}))(Ce)).defaultProps={type:"climates"};var Se=Object(Y.a)()(Ce),Ie=a("o/vN");function Te(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),a.push.apply(a,n)}return a}function je(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}class xe extends i.a.Component{constructor(...e){super(...e),this.getValues=()=>{const{shadow:e,name:t,t:a,device:n,fetching:s}=this.props,r=Object(E.l)("temperature",w.a.SMALL),o=this.getErrors(),l=g()(e,"ambientConditions.workType",0),d=!(e&&0===l),m=(e,t=!0)=>Object(E.f)(e,{unit:w.a.SMALL,showUnit:!0,fixed:1,acceptNil:!0,rawValue:!!t}),h=Object(E.l)("pressure");return{upperTitle:t,title:m(g()(e,"ambientConditions.averageCurrentAirTemperature"),!1),lowerTitle:d?"".concat(a("chamber.chart.temperatureDesired"),": ").concat(m(g()(e,"configuration.requestedTemperature"),!1)):a("inactive"),number:n.Number||"-",icon:{errors:o,isLoading:s,isConnected:!!e,dateTime:Object(c.o)(g()(e,"metadata")),isDisabled:!d,isAlerted:!!o.length},params:[{value:g()(e,"ambientConditions.generalVentilationEfficiency"),title:a("chamber.chart.ventilation"),icon:y.a,unit:"%",show:!0},{value:g()(e,"configuration.requestedTemperature")-g()(e,"configuration.alarms.minimumTemperatureAlarmDeviation"),title:a("minTempAlarm"),icon:x.a,unit:r,valueFormatter:m,show:!0},{value:g()(e,"configuration.requestedTemperature")+g()(e,"configuration.alarms.maximumTemperatureAlarmDeviation"),title:a("maxTempAlarm"),icon:M.a,unit:r,valueFormatter:m,show:!0},{value:g()(e,"configuration.ventilationConfiguration.minimumVentilation"),title:a("farmView.climate.minVentilation"),icon:N.a,unit:"%",show:!0},{value:g()(e,"configuration.ventilationConfiguration.maximumVentilation"),title:a("farmView.climate.maxVentilation"),icon:R.a,unit:"%",show:!0},{value:g()(e,"ambientConditions.humidity"),title:a("chamber.chart.humidity"),icon:O.a,unit:"%"},{value:g()(e,"ambientConditions.coolingOn"),title:a("chamber.chart.cooling"),icon:k.a,valueFormatter:e=>i.a.createElement("i",{className:"fas fa-fw fa-".concat(e?"check":"times")})},{value:g()(e,"ambientConditions.heatingOn"),title:a("settings.heating"),icon:Ie.a,valueFormatter:e=>i.a.createElement("i",{className:"fas fa-fw fa-".concat(e?"check":"times")})},{value:g()(e,"ambientConditions.pumpPressure"),title:a("chamber.chart.pressure"),icon:j.a,valueFormatter:e=>Object(E.e)(e,{showUnit:!1,fixed:1,acceptNil:!0,rawValue:!1}),unit:h}]}},this.getErrors=()=>{const{t:e,shadow:t}=this.props;try{if(t){const a=[],n=g()(t,"configuration.requestedTemperature"),i=g()(t,"ambientConditions.averageCurrentAirTemperature"),s=n-g()(t,"configuration.alarms.minimumTemperatureAlarmDeviation"),r=n+g()(t,"configuration.alarms.maximumTemperatureAlarmDeviation");return i>g()(t,"configuration.alarms.absoluteAlarm")?[e("farmView.climate.absoluteAlarm")]:(i>r&&a.push(e("farmView.climate.errors.1")),i{const s=this.getErrors();return i.a.createElement(Ee.a,{tooltipContent:i.a.createElement("div",null,i.a.createElement("div",null,t),!!n&&i.a.createElement("div",null,i.a.createElement("i",{className:"fas fa-sync mr-1"}),i.a.createElement("b",null,D()(n).format("HH:mm:ss DD.MM.YY"))),i.a.createElement("div",null,i.a.createElement("small",null,s.join("\n")))),placement:"left",type:e},i.a.createElement("div",null,i.a.createElement("i",{className:a})))},this.onContextMenu=e=>{const{openMenu:t,device:a}=this.props;return e.stopPropagation(),e.preventDefault(),e.persist(),t(e,a),!1}}componentDidUpdate(e,t,a){e.expanded!==this.props.expanded&&(this.props.expanded||Object(ve.i)(this.props.measure))}render(){const{selected:e,onSelect:t,expanded:a,measure:n}=this.props,{upperTitle:s,title:r,lowerTitle:o,params:c,icon:l,number:d}=this.getValues();return i.a.createElement(me.a,{xs:12},i.a.createElement(we.a,{type:"container",className:"pointer",selected:e},i.a.createElement(De.a,{onClick:t,icon:l,upperTitle:s,title:r,lowerTitle:o,params:c,expanded:a,selected:e,number:d,showingCallback:n,onContextMenu:this.onContextMenu})))}}xe.propTypes={device:v.a.object.isRequired,id:v.a.string,placements:v.a.array,name:v.a.string},(xe=Object(s.connect)((function(){const e=Object(ge.a)(),t=Object(be.d)(),a=Object(be.c)(),n={type:"climates"};return function(i,s){return n.id=s.id,function(e){for(var t=1;t(a.stopPropagation(),e(Object(fe.d)("climates",t.id)),!1),onExpand:()=>e(Object(fe.c)("climates",t.id))}}))(xe)).defaultProps={type:"climates"};var Me=Object(Y.a)()(xe),ke=a("MUrI");function Ne(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),a.push.apply(a,n)}return a}function Re(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}class Fe extends i.a.Component{constructor(...e){super(...e),this.tempFormatter=e=>Object(E.f)(e,{showUnit:!0,fixed:1}),this.onContextMenu=e=>{const{openMenu:t}=this.props;return t(e),!1},this.getValues=()=>{const{shadow:e,name:t,t:a,device:n,fetching:i}=this.props,s=Object(E.l)("temperature",w.a.SMALL),r=this.getErrors(),o=e=>Object(E.f)(e,{unit:w.a.SMALL,showUnit:!0,fixed:1,acceptNil:!0,rawValue:!0});return{upperTitle:t,title:this.getTemperature(e),lowerTitle:"",number:n.Number||"-",icon:{errors:r,isLoading:i,isConnected:!!e,dateTime:Object(c.o)(g()(e,"metadata")),isDisabled:!1,isAlerted:this.hasAlarm(e)},params:[{value:g()(n,"Settings.Temperature.MinimumAlarm"),title:a("minTempAlarm"),icon:x.a,unit:s,valueFormatter:o,show:!0},{value:g()(n,"Settings.Temperature.MaximumAlarm"),title:a("maxTempAlarm"),icon:M.a,unit:s,valueFormatter:o,show:!0}]}},this.getErrors=()=>{const{t:e,shadow:t}=this.props;try{if(t&&void 0===t.temp[0].temp)return[e("farmView.climate.temperatureSensorError")];if(t&&t.temp[0].alarmMin)return[e("farmView.climate.errors.0")];if(t&&t.temp[0].alarmMax)return[e("farmView.climate.errors.1")]}catch(a){console.error(a)}return[]},this.icon=({color:e,header:t,icon:a,dateTime:n})=>{const s=this.getErrors();return i.a.createElement(Ee.a,{tooltipContent:i.a.createElement("div",null,i.a.createElement("div",null,t),!!n&&i.a.createElement("div",null,i.a.createElement("i",{className:"fas fa-sync mr-1"}),i.a.createElement("b",null,D()(n).format("HH:mm:ss DD.MM.YY"))),i.a.createElement("div",null,i.a.createElement("small",null,s.join("\n")))),placement:"left",type:e},i.a.createElement("div",null,i.a.createElement("i",{className:a})))}}hasAlarm(e){return g()(e,"temp[0].alarmMin",!1)||g()(e,"temp[0].alarmMax",!1)||void 0===g()(e,"temp[0].temp")}getTemperature(e){if(!e)return"-";let t;try{t=e.temp[0].temp}catch(a){t=void 0}return this.tempFormatter(t)}render(){const{measure:e}=this.props,{upperTitle:t,title:a,lowerTitle:n,params:s,icon:r,number:o}=this.getValues();return i.a.createElement(me.a,{xs:12},i.a.createElement(we.a,{type:"container"},i.a.createElement(De.a,{icon:r,upperTitle:t,title:a,number:o,lowerTitle:n,params:s,showingCallback:e})))}}Fe.propTypes={device:v.a.object.isRequired,id:v.a.string,placements:v.a.array,name:v.a.string},(Fe=Object(s.connect)((function(){const e=Object(ge.a)(),t={type:"climates"};return function(a,n){return t.id=n.id,function(e){for(var t=1;t{const{loading:e,data:t,t:a}=this.props;return i.a.createElement(me.a,{xs:12},i.a.createElement(Pe.a,{isLoading:e,dataLength:t.length,noDataText:a("farmView.climate.climatesNotFound")}))},Object(u.isUsingFakeData)()){const{data:e}=this.props;m.a.restore(),m.a.stub(o.a,"startSendingDeviceState").callsFake(h.b),m.a.stub(o.a,"createAndSendMessageObject").callsFake(h.a),m.a.stub(o.a,"sendRequestForAggregatedData").callsFake(()=>{}),this.timer=setInterval(()=>{Object(h.c)(e.map(e=>e.device))},7e3)}}componentDidMount(){this.startPolling()}startPolling(){o.a.removeFromInterval(this.messageIDs);const{data:e}=this.props,t=Object(c.r)(e.map(e=>e.device));if(t)for(let a of t.values())a[l.d.DISPENSER_NRF].length&&this.messageIDs.push(o.a.startSendingDeviceState(a[l.d.DISPENSER_NRF],void 0,void 0,{keepAlive:!0})),a[l.d.CLIMATE].length&&this.messageIDs.push(o.a.startSendingDeviceState(a[l.d.CLIMATE],void 0,void 0,{keepAlive:!0})),a[l.d.CLIMATE_SK3].length&&this.messageIDs.push(o.a.startSendingDeviceState(a[l.d.CLIMATE_SK3],void 0,void 0,{keepAlive:!0}))}componentWillUnmount(){o.a.removeFromInterval(this.messageIDs)}componentDidUpdate(e,t,a){const{data:n}=this.props,{data:i}=e;n.length!==i.length&&this.startPolling()}render(){const{data:e,openMenu:t,loading:a}=this.props;return i.a.createElement(ke.a,{forceRerender:a,noRowsRenderer:this.noRowsRenderer,passProps:{openMenu:t},component:({device:e}={})=>{switch(e.DevType){case l.d.CLIMATE_SK3:return Me;case l.d.DISPENSER_NRF:return Ae;default:return Se}},data:e})}}Le=Object(s.connect)((function(e){return{data:Object(r.b)(e),loading:e.dataLoader.loading}}))(Le);t.a=Object(Y.a)()(Le)},FTWh:function(e,t,a){"use strict";var n=a("q1tI"),i=a.n(n),s=a("/MKj"),r=a("IXwn"),o=a("9D2Z"),c=a("kG49"),l=a("vzZS"),d=a("uSQv"),m=a("0u5A"),h=a("LCzB"),u=a("ANjH"),p=a("f0zD"),g=a("xUPz");const f={type:"siloses"};class v extends n.Component{constructor(...e){super(...e),this.onConfigurationClick=()=>{const{selected:e}=this.props;this.props.show(g.a,{siloses:e})}}render(){const{selected:e,event:t,openMenu:a,t:n}=this.props;return i.a.createElement(i.a.Fragment,null,i.a.createElement(r.a,{fixed:!0},i.a.createElement(o.a,{event:t},i.a.createElement(c.a,{icon:i.a.createElement("i",{className:"fas fa-cog fa-fw"}),onClick:this.onConfigurationClick},n("configuration"))),i.a.createElement(l.a,{boxColor:"info"},n("deviceRows.siloses.siloRow.selected",{count:e.length})),i.a.createElement(d.a,{buttonStyle:"round",buttonColor:"info",icon:i.a.createElement("i",{className:"fas fa-ellipsis-v"}),disabled:0===e.length,onClick:a})),i.a.createElement(g.b,null))}}v=Object(h.a)()(v),t.a=Object(s.connect)((function(e){return{selected:Object(m.b)(e,f)}}),e=>Object(u.b)({show:p.d},e))(v)},H7uW:function(e,t,a){"use strict";var n=a("Y+p1"),i=a.n(n),s=a("J2iB"),r=a.n(s),o=a("mwIZ"),c=a.n(o),l=a("q1tI"),d=a.n(l),m=a("/MKj"),h=a("17x9"),u=a.n(h),p=a("wd/R"),g=a.n(p);class f extends d.a.Component{constructor(e){super(e),this.setupClock=(e=this.props)=>{clearInterval(this.interval);const{variablePath:t,metaPath:a,deviceId:n,shadows:i}=e;let s=c()(i.get(n),t),o=a&&c()(i.get(n),a);r()(s)?this.setState({time:null}):(r()(o)||(s+=Math.max(+g()()-o,0)),this.setState({time:g()(s)},()=>{this.interval=setInterval(this.onTick,1e3)}))},this.onTick=()=>{r()(this.state.time)||this.setState(e=>r()(e.time)?{time:null}:{time:e.time.add(1,"second")})},this.state={time:null},this.setupClock(this.props)}UNSAFE_componentWillReceiveProps(e,t){const{variablePath:a,metaPath:n,deviceId:s,shadows:r}=this.props;let o=c()(e.shadows.get(e.deviceId),e.variablePath),l=e.metaPath&&c()(e.shadows.get(e.deviceId),e.metaPath),d=c()(r.get(s),a),m=n&&c()(r.get(s),n);i()(d,o)&&i()(m,l)||this.setupClock(e)}componentWillUnmount(){clearInterval(this.interval)}render(){const{renderComponent:e}=this.props,{time:t}=this.state;return d.a.createElement(d.a.Fragment,null,e(r()(t)?null:t))}}f.propTypes={deviceId:u.a.string.isRequired,variablePath:u.a.string.isRequired,metaPath:u.a.string,renderComponent:u.a.func},f.defaultProps={renderComponent:e=>d.a.createElement("time",null,e?e.format("HH:mm:ss"):"--:--:--")};t.a=Object(m.connect)(e=>({shadows:e.shadows.shadows}))(f)},HfzF:function(e,t,a){"use strict";var n=a("Y+p1"),i=a.n(n),s=a("q1tI"),r=a.n(s),o=a("17x9"),c=a.n(o),l=a("/MKj"),d=a("15cA"),m=a("IXwn"),h=a("uSQv"),u=a("T34T"),p=a("ANjH"),g=a("f0zD"),f=a("EyHs"),v=a("+V8T"),b=a("9D2Z"),D=a("kG49"),E=a("6/k7"),w=a("vzZS"),y=a("msTn"),O=a("WNbV"),C=a("mr+a"),S=a("A5yn"),I=a("mxqY"),T=a("wQVC"),j=a("ZkcS"),x=a("0Lmq"),M=a("40zH"),k=a("LCzB"),N=a("XzT5"),R=a("7y5B"),F=a("sJAb"),A=a("R7+t");function P(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),a.push.apply(a,n)}return a}function L(e){for(var t=1;t{this.openConfirmModal(I.b,{status:e})},this.handleDeletePigRFID=()=>{const{chamberID:e}=this.state;this.openConfirmModal(I.a,{chamberID:e})},this.handleDisableDispenser=()=>{this.openConfirmModal(I.c)},this.handleClickOnInfoBox=()=>{const{chamberId:e}=this.state;return e?()=>Object(T.j)(e):void 0},this.isRFID=()=>{const{feedingType:e}=this.state;return i()(e,E.f.GROUP)},this.openModal=e=>{const{show:t}=this.props,{feedingType:a,selectedNodes:n,receivers:i,chamberID:s,sectorType:r}=this.state;t(e,{type:a,selectedNodes:n,receivers:i,locationID:s,sectorType:r,clearSelection:()=>this.clearSelection()})},this.openConfirmModal=(e,t={})=>{const{show:a,t:n}=this.props,{feedingType:i,receivers:s,selectedNodes:r=[]}=this.state;e(L({show:a,t:n,feedingType:i,receivers:s,selectedNodes:r,onConfirmed:this.clearSelection},t))},this.clearSelection=()=>{const{dispatch:e}=this.props,{chamberID:t}=this.state;e(Object(S.h)({CID:t}))};const{chamberId:t,dispensersSelected:a}=this.props;this.state=Object(d.i)(t,a)}componentWillReceiveProps(e,t){const{chamberId:a,dispensersSelected:n}=this.props;if(!i()(a,e.chamberId)||!i()(n,e.dispensersSelected)){const t=Object(d.i)(e.chamberId,e.dispensersSelected);this.setState(L({},t))}}render(){const{t:e,isActive:t,event:a,onClick:n}=this.props,{selectedNodes:i,sectorType:s,feedingType:o}=this.state,c={allFeeding:!0,hasWater:!1};for(let r of i)r.device instanceof A.a&&r.device.hasWater()&&(c.hasWater=!0);const l=[{name:e("extraFeeding"),onClick:()=>this.openModal(u.a),show:[E.f.INDIVIDUAL].includes(o)},{name:e("manageFeeding"),onClick:()=>this.openModal(f.a),show:[E.f.INDIVIDUAL,E.f.GROUP].includes(o)},{name:e("deviceRows.feeding.dispenserButtons.skipDoses"),onClick:()=>this.openModal(O.a),show:[E.f.INDIVIDUAL].includes(o)},{name:e("lockFeeding"),onClick:()=>this.handleLock(!0),show:[E.f.INDIVIDUAL].includes(o)},{name:e("unlockFeeding"),onClick:()=>this.handleLock(!1),show:[E.f.INDIVIDUAL].includes(o)},{name:e("deviceRows.feeding.dispenserButtons.deletePig"),onClick:()=>this.handleDeletePigRFID(),show:[E.f.GROUP].includes(o)},{name:e("reportCondition"),onClick:()=>this.openModal(j.a),show:[E.f.INDIVIDUAL,E.f.GROUP].includes(o)},{name:e("alarms"),onClick:()=>this.openModal(v.a),show:[E.f.INDIVIDUAL].includes(o)},{name:e("deviceRows.feeding.dispenserButtons.reportInsemination"),onClick:()=>this.openModal(x.a),show:[E.f.INDIVIDUAL].includes(o)&&[y.a.MATING].includes(s)},{name:e("deviceRows.feeding.dispenserButtons.reportParturition"),onClick:()=>this.openModal(M.a),show:[E.f.INDIVIDUAL].includes(o)&&[y.a.DELIVERY].includes(s)},{name:e("disableDispenser"),onClick:()=>this.handleDisableDispenser(),show:[E.f.INDIVIDUAL].includes(o)},{name:e("emptyDispenser"),onClick:()=>this.openModal(R.a),show:[E.f.INDIVIDUAL].includes(o)},{name:e("extraWater"),onClick:()=>this.openModal(F.a),show:[E.f.INDIVIDUAL].includes(o)&&c.hasWater}];return r.a.createElement(r.a.Fragment,null,r.a.createElement(m.a,{show:!!t,fixed:!0},r.a.createElement(w.a,{onClick:this.handleClickOnInfoBox,boxColor:"info"},N.a.t("deviceRows.feeding.dispenserButtons.".concat(this.isRFID()?"selectedAnimals":"selectedStandings"),{count:i.length})),r.a.createElement(h.a,{buttonStyle:"round",icon:r.a.createElement("i",{className:"fas fa-ellipsis-v"}),type:"button",buttonColor:"info",disabled:!i.length,onClick:n})),r.a.createElement(b.a,{event:a},l.map((e,t)=>e.show?r.a.createElement(D.a,{key:t,disabled:e.disabled,onClick:()=>e.onClick()},e.name):null)))}}Y.propTypes={chambers:c.a.array.isRequired,event:c.a.object,onClick:c.a.func},Y=Object(l.connect)((e,t)=>({dispensersSelected:Object(C.g)(e,{CID:e.feeding.selectedChamber}),chamberId:e.feeding.selectedChamber,user:e.user.user}))(Y),Y=Object(l.connect)(null,e=>Object(p.b)({show:g.d},e))(Y),t.a=Object(k.a)()(Y)},JUo3:function(e,t,a){},LLWV:function(e,t,a){"use strict";var n=a("q1tI"),i=a.n(n),s=a("/MKj"),r=a("IXwn"),o=a("9D2Z"),c=a("kG49"),l=a("vzZS"),d=a("uSQv"),m=a("Uj9J"),h=a("re1K"),u=a("LCzB"),p=a("ANjH"),g=a("f0zD"),f=a("zDJl"),v=a("KbNz"),b=a("Il7A"),D=a("hpEo"),E=a("vXv+");const w={type:"climates"};class y extends n.Component{constructor(...e){super(...e),this.onConfigurationClick=()=>{const{selected:e}=this.props,t=e.map(e=>e.device);this.props.show(m.a,{climates:t})},this.onWorkTypeClick=()=>{const{selected:e}=this.props,t=e.map(e=>e.device);this.props.show(E.a,{climates:t})},this.onAlarmsClick=()=>{const{selected:e}=this.props,t=e.map(e=>e.device);this.props.show(D.a,{climates:t})},this.onBandwidthClick=()=>{const{selected:e}=this.props,t=e.map(e=>e.device);this.props.show(b.a,{climates:t})},this.onMatsClick=()=>{const{selected:e}=this.props,t=e.map(e=>e.device);this.props.show(v.a,{climates:t})},this.hasDevType=e=>{const{selected:t}=this.props;for(let a=0;aObject(p.b)({show:g.d},e))(y)},SlBD:function(e,t,a){"use strict";var n=a("mwIZ"),i=a.n(n),s=a("q1tI"),r=a.n(s),o=a("17x9"),c=a.n(o),l=a("G7tO"),d=a("LCzB"),m=a("pxzG"),h=a("eASP");class u extends r.a.Component{constructor(...e){super(...e),this.getData=()=>{const{stages:e}=this.props;if(8!==e.length)return[];const t=[],a=(t,a,n)=>i()(e,"[".concat(t,"].").concat(a),i()(e,"[".concat(t,"].").concat(n),0)),n=e=>a(e,"Floor","floor"),s=e=>a(e,"RequestedTemperature","requestedTemperature"),r=e=>a(e,"MinimumVentilation","minimumVentilation");let o=1;for(let i=0;i<8;i++)o+=i?a(i,"Days","days"):0,t[i]={days:o,expectedTemperature:s(i),ventilationMin:r(i),floor:n(i)};return t}}render(){const{t:e,className:t,curveDay:a}=this.props,n=this.getData(),i=Object(m.l)("temperature"),s=[{color:"green",dataKey:"expectedTemperature",type:"line",name:e("requestedTemperature"),valueConverter:e=>Object(m.f)(e,{unit:h.a.SMALL,fixed:1,rawValue:!0,acceptNil:!0}),unit:i},{color:"orange",dataKey:"ventilationMin",type:"line",name:e("minimumVentilation"),unit:"%"},{color:"blue",dataKey:"floor",type:"line",name:e("settings.floor"),unit:"%"}],o=a?[{x:a,name:e("curveDay"),color:"blue"}]:void 0,c=["mh-20rem h-0",t].filter(e=>!!e).join(" ");return r.a.createElement("div",{className:c},r.a.createElement(l.a,{dataDef:s,data:n,Xaxis:{dataKey:"days",name:e("day"),type:"number"},Yaxis:{name:e("value")},referenceLines:o}))}}u.propTypes={stages:c.a.array.isRequired,curveDay:c.a.number},t.a=Object(d.a)()(u)},Tt2W:function(e,t,a){"use strict";var n,i=a("Y+p1"),s=a.n(i),r=a("q1tI"),o=a.n(r),c=a("/MKj"),l=a("17x9"),d=a.n(l),m=a("wd/R"),h=a.n(m),u=a("2wEF"),p=a("udB/"),g=a("G7tO"),f=a("pxzG"),v=a("eASP"),b=a("q17X"),D=a("uFeN"),E=a.n(D),w=a("LCzB");let y=Object(c.connect)(e=>({cageData:e.aggregatedData.data}))(n=class extends r.Component{constructor(e){super(e),this.weightValueFormatter=e=>"".concat(this.props.t("weight"),": ").concat(e),this.state={data:[],averageWeight:0,averageWeightShadow:0,loading:!0}}shouldComponentUpdate(e,t,a){return!s()(this.props.container,e.container)||(!s()(this.props.t("chamber"),e.t("chamber"))||!s()(this.state,t))}valueFormatter(e){return e+this.props.t("pcs")}async componentDidMount(){let e=new E.a,t=this.props.cageData.get(this.props.cage.DevID);e.postMessage({cageData:t,date:this.props.date.toDate().getTime(),applyShadow:this.props.applyShadow,shadowDate:this.props.applyShadow?this.props.shadowDate.toDate().getTime():null,accuracy:Object(b.getPassageAccuracy)()}),e.onmessage=e=>{console.log(e.data.passage),this.setState({data:e.data.passage,averageWeight:e.data.averageWeight,averageWeightShadow:e.data.averageWeightShadow,loading:!1})},this.setState({worker:e})}componentWillUnmount(){this.state.worker&&this.state.worker.terminate()}UNSAFE_componentWillReceiveProps(e,t){if(!s()(this.props.cageData,e.cageData)||!s()(this.props.date,e.date)||!s()(this.props.shadowDate,e.shadowDate)){let t=e.cageData.get(e.cage.DevID);this.state.worker.postMessage({cageData:t,date:e.date.toDate().getTime(),applyShadow:e.applyShadow,shadowDate:e.applyShadow?e.shadowDate.toDate().getTime():null,accuracy:Object(b.getPassageAccuracy)()})}}render(){const{applyShadow:e}=this.props,{loading:t}=this.state;let a=[{color:"green",dataKey:"amount",name:this.props.t("amount"),chartType:"Bar",opacity:1}],n=[{x:Math.round(this.state.averageWeight/1e3),color:"blue",name:this.props.t("chamber.chart.averageWeight")+Object(f.j)(this.state.averageWeight,{unit:v.a.MEDIUM,showUnit:!0,fixed:1})}];return e&&(a=[...a,{color:"blue",dataKey:"amountShadow",name:this.props.t("amount"),chartType:"Area",type:"step"}],n=[...n,{x:Math.round(this.state.averageWeightShadow/1e3),color:"orange",name:this.props.t("chamber.chart.averageWeight")+Object(f.j)(this.state.averageWeightShadow,{unit:v.a.MEDIUM,showUnit:!0,fixed:1}),position:"center"}]),o.a.createElement(o.a.Fragment,null,o.a.createElement(p.a,{isLoading:t}),!this.state.data.length&&o.a.createElement(u.a,null),this.state.data.length>0&&o.a.createElement(o.a.Fragment,null,o.a.createElement(g.a,{dataDef:a,data:this.state.data,Yaxis:{name:this.props.t("amount")},Xaxis:{name:this.props.t("weight"),dataKey:"name",offset:45},type:e?"Composed":"Bar",brush:{brushKey:"amount",blockBrush:!0},referenceLines:n,saveAsExcell:"passesInWeights",showDomainInput:!0,tooltipLabelFormatter:this.weightValueFormatter})))}})||n;y.propTypes={cage:d.a.object,date:d.a.instanceOf(h.a),applyShadow:d.a.bool,shadowDate:d.a.instanceOf(h.a)},y.defaultProps={brushHeight:32,height:"100%",showExcelButton:!1,excelPortalContainerID:"chart-controls"},t.a=Object(w.a)()(y)},Uip1:function(e,t,a){"use strict";var n=a("J2iB"),i=a.n(n),s=a("lSCD"),r=a.n(s),o=a("sEfC"),c=a.n(o),l=a("q1tI"),d=a.n(l),m=a("JI6e"),h=a("3Z9Z"),u=a("XEBk"),p=(a("1iQD"),a("9wQ1")),g=a("CuyV"),f=a("wd/R"),v=a.n(f),b=a("LCzB");class D extends l.Component{constructor(...e){super(...e),this.showNumber=0,this.childrenChanged=c()(()=>{try{this.props.showingCallback()}catch(e){}},100),this.getParams=()=>{const{params:e=[]}=this.props;return e.filter(e=>!!e.show||!i()(e.value))},this.onExpand=e=>{const{onExpand:t}=this.props;e.stopPropagation(),t()},this.checkChildrenChange=e=>{this.showNumber&&this.showNumber!==e.length&&this.childrenChanged(),this.showNumber=e.length}}render(){const{t:e,onContextMenu:t,selected:a,number:n,expanded:s,onExpand:o,onClick:c,upperTitle:l,lowerTitle:f,title:b,icon:{isAlerted:D,isConnected:E,isDisabled:w,dateTime:y,isLoading:O,errors:C=[]}={}}=this.props,S=this.getParams(),I=r()(o),T=!i()(n);return this.checkChildrenChange(S),d.a.createElement(m.a,{xs:12,onClick:c,className:"device-row d-block",onContextMenu:t},d.a.createElement(h.a,null,d.a.createElement(p.a,{dateTime:y,isConnected:E,isLoading:O,isAlerted:D,isDisabled:w},({icon:e,color:t,header:n})=>d.a.createElement(d.a.Fragment,null,d.a.createElement(m.a,{sm:12,xl:2,className:"mh-5rem pt-2 pb-2 position-relative background-".concat(t).concat(a?"-dark":"")},d.a.createElement("div",{className:"device-row-icon background-".concat(t).concat(a?"-dark":"")},d.a.createElement(g.a,{tooltipContent:d.a.createElement("div",null,d.a.createElement("div",null,n),!!y&&d.a.createElement("div",null,d.a.createElement("i",{className:"fas fa-sync mr-1"}),d.a.createElement("b",null,v()(y).format("HH:mm:ss DD.MM.YY"))),d.a.createElement("div",null,d.a.createElement("small",null,C.join("\n")))),placement:"auto",type:t},d.a.createElement("div",null,d.a.createElement("i",{className:e})))),d.a.createElement(h.a,{className:"h-25"},d.a.createElement(m.a,{className:"opacity-75 no-break-word"},l,"\xa0")),d.a.createElement(h.a,{className:"h-50 align-items-center"},d.a.createElement(m.a,{className:"no-break-word"},d.a.createElement("h4",null,b))),d.a.createElement(h.a,{className:"h-25"},d.a.createElement(m.a,{className:"opacity-75 no-break-word"},f,"\xa0"))))),T&&d.a.createElement(m.a,{sm:12,xl:1,key:"number_0",className:"d-flex align-items-center justify-content-left justify-content-lg-center opacity-75"},d.a.createElement("span",{className:"d-inline d-xl-none mr-1"},e("grid.number"),":"),d.a.createElement("h3",null,n)),d.a.createElement(m.a,{sm:12,xl:10-(+T+ +I),className:"align-items-center mb-1 mt-1"},d.a.createElement(h.a,{className:"align-items-center h-100"},S.map((e,t)=>d.a.createElement(m.a,{key:t,xl:2*(e.size||1),lg:4*(e.size||1),md:4*(e.size||1),sm:6*(e.size||1),xs:6*(e.size||1)},d.a.createElement(u.a,{color:e.color,value:e.value,title:e.title,unit:e.unit,icon:e.icon,small:e.small,show:i()(e.show)?!i()(e.value):!!e.show,valueFormatter:e.valueFormatter}))))),I&&d.a.createElement(m.a,{className:"d-flex align-items-center justify-content-center mb-2 mt-2 mt-xl-0 mb-xl-0",onClick:this.onExpand,xs:12,xl:1},d.a.createElement("i",{className:"fa-fw fa-2x fas opacity-50 fa-chevron-".concat(s?"up":"down")}))))}}D.defaultProps={showingCallback:()=>{}},t.a=Object(b.a)()(D)},UvEz:function(e,t,a){"use strict";var n,i=a("Y+p1"),s=a.n(i),r=a("q1tI"),o=a.n(r),c=a("/MKj"),l=a("17x9"),d=a.n(l),m=a("2wEF"),h=a("udB/"),u=a("wd/R"),p=a.n(u),g=a("G7tO"),f=a("Vv3o"),v=a("VUd2"),b=a("08qr"),D=a.n(b),E=a("LCzB");let w=Object(c.connect)(e=>({cageData:e.aggregatedData.data}))(n=class extends r.Component{constructor(e){super(e),this.formatDate=e=>p()(e,"DD.MM.YYYY").toDate(),this.onSliderChange=e=>{clearTimeout(this.state.timeout);let t=setTimeout(()=>{let t=this.props.cageData.get(this.props.cage.DevID);this.state.worker.postMessage({cageData:t,settlement:this.props.settlement,shadowInsertion:this.props.applyShadow?this.props.shadowInsertion:null,sliderValue:e})},100);this.setState({sliderValue:e,timeout:t})},this.state={data:[],loading:!0,sliderValue:null,timeout:null}}shouldComponentUpdate(e,t,a){return!s()(this.props.t("chamber"),e.t("chamber"))||!s()(this.state,t)}async componentDidMount(){let e=new D.a,t=this.props.cageData.get(this.props.cage.DevID);e.postMessage({cageData:t,settlement:this.props.settlement,shadowInsertion:this.props.applyShadow?this.props.shadowInsertion:null,sliderValue:this.state.sliderValue}),e.onmessage=e=>{this.setState({data:e.data.passage,sliderValue:e.data.closestIndex||this.state.sliderValue,loading:!1})},this.setState({worker:e})}UNSAFE_componentWillReceiveProps(e,t){let a=e.cageData.get(e.cage.DevID);this.state.worker.postMessage({cageData:a,settlement:e.settlement,shadowInsertion:e.applyShadow?e.shadowInsertion:null,sliderValue:this.state.sliderValue})}componentWillUnmount(){this.state.worker&&this.state.worker.terminate()}render(){const{loading:e,sliderValue:t,data:a}=this.state,{applyShadow:n}=this.props;let i=[{color:"green",dataKey:"all",name:this.props.t("all")},{color:"blue",dataKey:"left",name:this.props.t("left"),defaultOff:!0},{color:"pink",dataKey:"right",name:this.props.t("right"),defaultOff:!0},{color:"orange",dataKey:"middle",name:this.props.t("middle"),defaultOff:!0}];return n&&(i=[...i,{color:"green",dataKey:"allShadow",name:this.props.t("all"),strokeOpacity:.4},{color:"blue",dataKey:"leftShadow",name:this.props.t("left"),strokeOpacity:.4,defaultOff:!0},{color:"orange",dataKey:"middleShadow",name:this.props.t("middle"),strokeOpacity:.4,defaultOff:!0},{color:"pink",dataKey:"rightShadow",name:this.props.t("right"),strokeOpacity:.4,defaultOff:!0}]),o.a.createElement(o.a.Fragment,null,o.a.createElement(h.a,{isLoading:e}),0===a.length&&o.a.createElement(m.a,null),a.length>0&&o.a.createElement(o.a.Fragment,null,n&&o.a.createElement(f.a,{label:"Por\xf3wnanie",valueFormatter:e=>a[e].name,value:t||0,onChange:this.onSliderChange,max:a.length-1}),o.a.createElement(g.a,{dataDef:i,data:a,Yaxis:{name:this.props.t("chamber.chart.passes")},Xaxis:{name:this.props.t("date"),dataKey:"name"},saveAsExcell:"passesInDays",hasShadows:n,tooltipContent:n?o.a.createElement(v.a,null):null})))}})||n;w.propTypes={cage:d.a.object,settlement:d.a.shape({DtaStartTime:d.a.number.isRequired,DtaEndTime:d.a.number}),height:d.a.oneOfType([d.a.string,d.a.number]),showExcelButton:d.a.bool,excelPortalContainerID:d.a.string},w.defaultProps={colors:{all:"#359d3c",left:"#4a9bd4",right:"#f44b4b",middle:"#ff9419",inactive:"#999"},brushHeight:36,height:"100%",showExcelButton:!1,excelPortalContainerID:"chart-controls"},t.a=Object(E.a)()(w)},VUd2:function(e,t,a){"use strict";var n=a("q1tI"),i=a.n(n),s=(a("sl4t"),a("LCzB"));class r extends i.a.Component{render(){const{label:e,payload:t,t:a}=this.props;return i.a.createElement("div",{className:"compare-insertion-tooltip"},i.a.createElement("div",null,e),i.a.createElement("ul",null,i.a.createElement("li",null,a("compareInsertionsTooltip.insertion")," 1"),t.map((e,n)=>{let s=t[n-1],r=!1;return s&&!s.dataKey.includes("Shadow")&&e.dataKey.includes("Shadow")&&(r=!0),i.a.createElement(i.a.Fragment,null,r&&i.a.createElement("li",null,a("compareInsertionsTooltip.insertion")," 2"),i.a.createElement("li",{style:{color:e.fill}},e.name,": ",e.value,e.unit))})))}}t.a=Object(s.a)()(r)},"Xn1+":function(e,t,a){"use strict";var n=a("Y+p1"),i=a.n(n),s=a("q1tI"),r=a.n(s),o=a("G7tO"),c=a("q17X"),l=a("LCzB");class d extends s.Component{constructor(e){super(e),this.state={data:this.prepareData(this.props.data)}}prepareData(e){const t=[17,16,15,14,12,10,8,7],a=Object(c.getTechnologyGroupSize)(),n=Object(c.getTechnologyGroupWeeks)(),i=Math.floor(a*(1===n?23.5:8));let s=[];for(let r=0;r<8;r++)s[r]={lactation:"".concat(r).concat(7===r?"+":""),sowsCnt:e[r].sowsCnt,sowsIdeal:Math.round(i*t[r]/100)};return s}UNSAFE_componentWillReceiveProps(e){i()(this.props.data,e.data)||this.setState({data:this.prepareData(e.data)})}render(){const{t:e}=this.props,{data:t}=this.state;return r.a.createElement(o.a,{height:"30rem",data:t,Xaxis:{dataKey:"lactation",name:e("lactation")},Yaxis:{name:e("amount")},dataDef:[{name:e("amount"),dataKey:"sowsCnt",color:"blue"},{name:e("charts.herdStructureChart.perfectAmount"),dataKey:"sowsIdeal",color:"green"}]})}}t.a=Object(l.a)()(d)},Z1LY:function(e,t,a){"use strict";var n,i=a("qPyV"),s=a.n(i),r=a("Y+p1"),o=a.n(r),c=a("mwIZ"),l=a.n(c),d=a("UfWW"),m=a.n(d),h=a("q1tI"),u=a.n(h),p=a("17x9"),g=a.n(p),f=a("qx5e"),v=a("s506"),b=a("kCVf"),D=a("sPOc"),E=a("vYJ8"),w=a("uSQv"),y=a("BqhJ"),O=a("B7Ps"),C=a("UvEz"),S=a("Tt2W"),I=a("wd/R"),T=a.n(I),j=a("dxSB"),x=a("VfnB"),M=a("/MKj"),k=a("2wEF"),N=a("udB/"),R=a("G7tO"),F=a("RQzu"),A=a.n(F),P=a("LCzB");let L=Object(M.connect)(e=>({cageData:e.aggregatedData.data}))(n=class extends h.Component{constructor(e){super(e),this.hourFormatter=e=>{const{t:t}=this.props;return"".concat(t("hour"),": ").concat(e)},this.state={data:[],loading:!0}}shouldComponentUpdate(e,t,a){return!o()(this.props.t("chamber"),e.t("chamber"))||!o()(this.state,t)}async componentDidMount(){let e=new A.a,t=this.props.cageData.get(this.props.cage.DevID);e.postMessage({cageData:t,date:this.props.date.toDate().getTime()}),e.onmessage=e=>{this.setState({data:e.data.hourly,loading:!1})},this.setState({worker:e})}UNSAFE_componentWillReceiveProps(e,t){let a=e.cageData.get(e.cage.DevID);this.state.worker.postMessage({cageData:a,date:e.date.toDate().getTime()})}componentWillUnmount(){this.state.worker&&this.state.worker.terminate()}render(){const{loading:e}=this.state,t=[{color:"green",dataKey:"all",name:this.props.t("all")},{color:"blue",dataKey:"left",name:this.props.t("left")},{color:"pink",dataKey:"right",name:this.props.t("right")},{color:"orange",dataKey:"middle",name:this.props.t("middle")}];return u.a.createElement(u.a.Fragment,null,u.a.createElement(N.a,{isLoading:e}),0===this.state.data.length&&u.a.createElement(k.a,null),this.state.data.length>0&&u.a.createElement(u.a.Fragment,null,u.a.createElement(R.a,{dataDef:t,data:this.state.data,Yaxis:{name:this.props.t("amount")},Xaxis:{name:this.props.t("hour"),dataKey:"name"},type:"Bar",saveAsExcell:"hourly",tooltipLabelFormatter:this.hourFormatter})))}})||n;L.propTypes={cage:g.a.object,date:g.a.instanceOf(T.a),height:g.a.oneOfType([g.a.string,g.a.number]),showExcelButton:g.a.bool,excelPortalContainerID:g.a.string},L.defaultProps={colors:{all:"#359d3c",left:"#4a9bd4",right:"#f44b4b",middle:"#ff9419",inactive:"#999"},brushHeight:36,height:"100%",showExcelButton:!1,excelPortalContainerID:"chart-controls"};var U=Object(P.a)()(L),Y=a("i8MS"),V=a("I8zd"),W=a("CuyV"),B=a("3Xe5"),q=(a("2JSo"),a("AAik")),K=a("S8cm"),H=a("hw2D"),_=a("2dKy"),z=a("PPjn"),G=a("ANjH"),X=a("f0zD"),Z=a("RNJp"),J=a("pxzG"),Q=a("eASP"),$=a("fbLL"),ee=a("IcrQ"),te=a("2rxW"),ae=a("dBT4"),ne=a("9odO"),ie=a("NnKB"),se=a("+3lf");class re extends u.a.Component{render(){const{name:e,weight:t,passes:a}=this.props;return u.a.createElement("div",{className:"cage-side-data"},u.a.createElement("div",{className:"side-name"},e),u.a.createElement("div",{className:"side-data"},u.a.createElement(ee.a,{icon:ne.a,name:this.props.t("chamber.separationCageInfo.averageWeightShort"),value:t}),u.a.createElement(ee.a,{icon:se.a,name:this.props.t("chamber.separationCageInfo.passes"),value:a})))}}re.propTypes={name:g.a.string.isRequired,weight:g.a.node.isRequired,passes:g.a.node.isRequired};var oe=Object(P.a)()(re),ce=a("wNKL"),le=a("yv15"),de=a("61CT"),me=a("o6/V"),he=a("Ndvx"),ue=a("mnPM"),pe=a.n(ue);class ge extends u.a.Component{constructor(e){super(e),this.weightValueConverter=e=>Object(J.j)(e,{unit:Q.a.MEDIUM,fixed:1,rawValue:!0}),this.state={data:[],loading:!0}}shouldComponentUpdate(e,t,a){return!o()(this.props.t("chamber"),e.t("chamber"))||!o()(this.state,t)}componentDidMount(){let e=new pe.a,t=this.props.cageData.get(this.props.cage.DevID);e.postMessage({cageData:t,rfid:this.props.RFID,settlement:this.props.settlement}),e.onmessage=e=>{this.setState({data:e.data.passes,loading:!1})},this.setState({worker:e})}componentWillUnmount(){this.state.worker&&this.state.worker.terminate()}UNSAFE_componentWillReceiveProps(e,t){if(!o()(this.props.cageData,e.cageData)||this.props.RFID!==e.RFID||this.props.insertion!==e.insertion){let t=e.cageData.get(e.cage.DevID);this.state.worker.postMessage({cageData:t,rfid:e.RFID,settlement:e.settlement})}}render(){const{loading:e,data:t}=this.state;let a=[{color:"green",dataKey:"weight",name:this.props.t("weight"),valueConverter:this.weightValueConverter,unit:Object(J.l)("weight",Q.a.MEDIUM)}];return u.a.createElement(u.a.Fragment,null,u.a.createElement(N.a,{isLoading:e}),0===t.length&&u.a.createElement(k.a,null),t.length>0&&u.a.createElement(u.a.Fragment,null,u.a.createElement(R.a,{dataDef:a,data:this.state.data,Yaxis:{name:this.props.t("weight")},Xaxis:{name:this.props.t("date"),dataKey:"name"},saveAsExcell:"rfid_".concat(this.props.RFID)})))}}ge.propTypes={cage:g.a.object,RFID:g.a.string.isRequired,settlement:g.a.shape({DtaStartTime:g.a.number.isRequired,DtaEndTime:g.a.number})},ge=Object(M.connect)(e=>({cageData:e.aggregatedData.data}))(ge);var fe=Object(P.a)()(ge),ve=a("q17X"),be=a("QWcO"),De=a("ujxO"),Ee=a("TAe8"),we=a("vzZS"),ye=a("XzT5");class Oe extends h.Component{getWorkTypeName(e){const{t:t}=this.props;switch(e){case 1:return t("modals.cageWorkMode.sepMode").toLowerCase();case 2:return(t("left")+" "+t("modals.cageWorkMode.exitOpen")).toLowerCase();case 3:return(t("right")+" "+t("modals.cageWorkMode.exitOpen")).toLowerCase();case 4:return t("modals.cageWorkMode.altOpen").toLowerCase();default:return""}}render(){const{object:e,t:t}=this.props;if(e.T){const{T:a,AnimalAmount:n,MinWeight:i,MaxWeight:s,ExpeditionWorktype:r}=e,o={unit:Q.a.MEDIUM,fixed:0,showUnit:!0};return u.a.createElement("h6",{className:"full-width-row-middle",style:{whiteSpace:"normal"}},ye.a.t("expeditionFullWidthRow.text",{type1:T()(a).format("HH:mm"),type2:"".concat(Object(J.j)(i,o)," - ").concat(Object(J.j)(s,o))}),", ",n>0?ye.a.t("expeditionFullWidthRow.animals",{count:n}):t("expeditionFullWidthRow.noLimitAnimals"),", ",this.getWorkTypeName(r))}const{date:a}=e;return u.a.createElement("h6",{className:"full-width-row-middle"},T.a.utc(a).format("DD.MM.YYYY"))}}var Ce=Object(P.a)()(Oe),Se=a("UZWR"),Ie=a("zck4");function Te(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),a.push.apply(a,n)}return a}function je(e){for(var t=1;t{this.state.showLoading&&(this.timer=setTimeout(()=>{this.setState({showLoading:!1})},1e4))},this.stopLoading=()=>{clearTimeout(this.timer),this.setState({showLoading:!1})},this.onClick=()=>{this.setState(e=>({collapse:!e.collapse}))},this.onButtonClick=e=>{e.stopPropagation()},this.onChartChange=e=>{let t={chart:e};if("rfid"===e){let e=this.getRFIDs(this.state.settlement);t.rfid=e.length>0?e[0].value:""}this.setState(t)},this.getShadow=()=>{try{return this.props.shadows.get(this.props.cage.DevID)}catch(e){return}},this.getWorkType=e=>void 0!==e?this.props.t("chamber.separationCageInfo.work.".concat(e)):"-",this.getGain=e=>{try{let t=this.props.cageData.get(this.props.cage.DevID);t.sort((e,t)=>t.AggTi-e.AggTi);let a=t[1];if(a){let n=e||t[0].AggDt[0].WeightExAll||0,i=n-(a.AggDt[0].WeightExAll||0),s=(n?T.a.utc().startOf("day"):T.a.utc(t[0].AggTi)).diff(a.AggTi,"days");return i>0?(i/s).toFixed(1):0}return"-"}catch(t){return console.error(t),"-"}},this.getAverageWeight=(e,t)=>{if(e)return e;try{let e=this.props.cageData.get(this.props.cage.DevID);e.sort((e,t)=>t.AggTi-e.AggTi);let a=e[0];switch(t){case 0:return a.AggDt[0].WeightExAll||0;case 1:return a.AggDt[0].WeightExLeft;case 2:return a.AggDt[0].WeightExMid;case 3:return a.AggDt[0].WeightExRight;default:return 0}}catch(a){return"-"}},this.getSettlementDay=()=>{try{const{settlement:{data:e}}=this.props;return T.a.utc().startOf("day").diff(e.DtaStartTime,"days")+1}catch(e){return"-"}},this.getAveragePasses=e=>{const{count:t}=this.state;let a=e&&e.counters&&e.counters.all;return t&&a?(a/t).toFixed(1):"-"},this.getCurrentWeight=e=>{try{return Object(J.j)(e.weight,{unit:Q.a.MEDIUM,showUnit:!0,fixed:1})}catch(t){return"- ".concat(Object(J.l)("weight",Q.a.MEDIUM))}},this.getLastClosedWeight=e=>{try{return Object(J.j)(e.averageWeights.closed,{unit:Q.a.MEDIUM,showUnit:!0,fixed:1})}catch(t){return"- ".concat(Object(J.l)("weight",Q.a.MEDIUM))}},this.getDoorStatus=(e,t)=>e&&!t?B.b.CLOSED:!e&&t?B.b.OPENED:B.b.MIDDLE,this.weightValueFormatter=e=>Object(J.j)(e,{unit:Q.a.MEDIUM,showUnit:!0,fixed:1}),this.timeValueFormatter=e=>T()(e).format("HH:mm"),this.onSelectCage=e=>{e.stopPropagation(),e.preventDefault(),this.props.onSelect(this.props.cage)},this.onSettlementChange=e=>{let t={settlement:e},a=this.getRFIDs(e);a.length>0&&(t.rfid=a[0].value),this.setState(t),this.checkIfNeedToGetAggregatedData(e.DtaStartTime,e.DtaEndTime||(new Date).getTime())},this.onCompareSettlementsClick=e=>{this.props.show(me.a,{cage:this.props.cage,chart:this.state.chart})},this.onDateChange=e=>{let t=T.a.utc(e);this.setDate(t)},this.onLowerDateClick=()=>{let e=this.state.date.clone().subtract(1,"day");this.setDate(e)},this.onAddDateClick=()=>{let e=this.state.date.clone().add(1,"day");this.setDate(e)},this.onCompareDayClick=()=>{this.props.show(he.a,{device:this.props.cage,chart:this.state.chart})},this.onCollapseExit=()=>{this.setState({chart:"main"})},this.onExpandClick=e=>{this.props.show(Z.a,{cage:this.props.cage,type:e})},this.onRFIDChange=e=>{this.setState({rfid:e})},this.onLeftRFIDClick=(e,t)=>{t>=0&&this.setState({rfid:e[t-1].value})},this.onRightClick=(e,t)=>{t>=0&&this.setState({rfid:e[t+1].value})},this.onContextMenu=e=>(this.props.onRightClick(e,this.props.cage),!1),this.onSelectedExpeditionChange=e=>{this.setState({selectedExpedition:e})};let t=e.cage.getLocation(),a=0;for(let o of t){let e=Y.a.getAllAnimalsForLocation(o,this.getLevel(o));for(let t of e)a+=t.AnmCnt}let n=t.map(e=>Object(b.k)(e)).join(", ");this.container=u.a.createRef();let i=this.getRFIDs(0),s="".concat(e.cage.Address,"/").concat(e.cage.Address.toString(16)," ").concat(Object(x.n)(e.cage.Interface));const r=this.getExpeditions(e);console.log(r),this.state={location:n,collapse:!1,chart:"main",count:a,insertion:0,date:T.a.utc().startOf("day"),rfid:i.length>0?i[0].value:"",additionalText:s,showAlias:Object(ve.getShowAliases)(),showLoading:!this.props.shadows.get(this.props.cage.DevID),expeditions:r,selectedExpedition:r[0]?r[0].value:null,settlement:e.settlement.data||null,noInsertionInDevice:!1}}getLevel(e){return e.FarmID?V.a.FARM:e.BgID?V.a.BUILDING:e.SID?V.a.SECTOR:e.CID?V.a.CHAMBER:e.BID?V.a.BOX:void 0}checkIfNeedToGetAggregatedData(e,t){if(!Object(ve.isUsingFakeData)()){let a=T.a.utc(e),n=1;if(t){n=T.a.utc(t).diff(a,"days")+1}let i=this.props.cageData.get(this.props.cage.DevID),s=!!i;if(s)for(let e=0;ee.AggTi===t).length){s=!1;break}}if(!s){let a;a=t?{AggDataTimeFrom:e,AggDataTimeTo:t}:{AggDataTime:e},this.props.dispatch(Object(j.a)(this.props.cage,a))}}}checkIfNoStartedInsertionInDevice(e){try{if(Object(ve.isUsingFakeData)())return!1;const{DtaStartTime:t}=e,{cage:a}=this.props;return console.log("checkIfNoStartedInsertionInDevice",!a.Settings.Insertions.find(e=>e.StartTime===t)),!a.Settings.Insertions.find(e=>e.StartTime===t)}catch(t){return!1}}componentDidMount(){this.startLoading();const{settlement:e}=this.state;e&&(this.checkIfNeedToGetAggregatedData(e.DtaStartTime,e.DtaEndTime||(new Date).getTime()),this.setState({noInsertionInDevice:this.checkIfNoStartedInsertionInDevice(e)}))}componentDidUpdate(e,t,a){if(!o()(this.props.settlement.data,e.settlement.data)&&!this.state.settlement){let e=this.props.settlement.data;this.setState({settlement:e,noInsertionInDevice:this.checkIfNoStartedInsertionInDevice(e)}),this.checkIfNeedToGetAggregatedData(e.DtaStartTime,e.DtaEndTime||(new Date).getTime())}o()(this.props.cage,e.cage)||this.setState({noInsertionInDevice:this.checkIfNoStartedInsertionInDevice(this.state.settlement)})}getExpeditions(e){return(Object(ve.isUsingFakeData)()?Object(Ie.c)():e.cage.getExpeditionList()).sort((e,t)=>t.startDate-e.startDate).map(e=>({name:"".concat(T()(e.startDate).format("DD.MM.YYYY HH:mm")," - ").concat(e.endDate?T()(e.endDate).format("DD.MM.YYYY HH:mm"):"..."),value:e}))}UNSAFE_componentWillReceiveProps(e,t){if(this.state.showLoading&&e.shadows.get(e.cage.DevID)&&this.stopLoading(),!o()(this.props.cage,e.cage)){const t=this.getExpeditions(e);this.setState({expeditions:t,selectedExpedition:t[0]?t[0].value:null})}}componentWillUnmount(){clearTimeout(this.timer)}getTooltipContent(e){if(!e)return"Brak po\u0142\u0105czenia";let t=[],a=0;try{for(let t in e.metadata)e.metadata[t]>a&&(a=e.metadata[t])}catch(n){console.error(n)}if(t.push(u.a.createElement(u.a.Fragment,{key:"0.0"},u.a.createElement("div",null,this.props.t("lastUpdate"),":",u.a.createElement("div",null,u.a.createElement("strong",null,T()(e.arriveTime).format("DD.MM.YYYY HH:mm")))),u.a.createElement("div",null,this.props.t("deviceLastAnswer"),":",u.a.createElement("div",null,u.a.createElement("strong",null,T()(a).format("DD.MM.YYYY HH:mm")))))),this.isError(e))for(let i=0;ie+t,0)>0}catch(t){return!0}}getMainItem(e){if(e&&5===e.configuration.workType)return u.a.createElement("div",{className:e.expeditionData.animalsNumber>=e.expeditionData.counter?"device-main-item expedition success":"device-main-item expedition"},u.a.createElement(Ee.a,{monoColor:!0,percentage:e.expeditionData.animalsNumber?100*e.expeditionData.counter/e.expeditionData.animalsNumber:0,text:e.expeditionData.animalsNumber?"".concat(e.expeditionData.counter,"/").concat(e.expeditionData.animalsNumber):e.expeditionData.counter}),u.a.createElement("small",null,Object(J.j)(e.expeditionData.minWeight,{unit:Q.a.MEDIUM,showUnit:!1,fixed:1}),"-",Object(J.j)(e.expeditionData.maxWeight,{unit:Q.a.MEDIUM,showUnit:!0,fixed:1})));let t=this.getAverageWeight(e&&e.averageWeights.all,0);return u.a.createElement("div",{className:"device-main-item"},u.a.createElement("small",null,this.props.t("avgShort")),t&&"-"!==t?Object(J.j)(t,{unit:Q.a.MEDIUM,showUnit:!1,fixed:1}):"-"," ",u.a.createElement("small",null,Object(J.l)("weight",Q.a.MEDIUM)))}createSettlementSelect(e){const{settlements:t,t:a}=this.props,{settlement:n}=this.state;return u.a.createElement("div",{className:"chart-controls"},u.a.createElement("h4",null,e),u.a.createElement("div",{className:"chart-controls-container"},t.length>1&&u.a.createElement(w.a,{buttonStyle:"bordered",onClick:this.onCompareSettlementsClick},a("chamber.separationCageInfo.compareInsertions")),u.a.createElement(H.a,{clearButton:!1,value:n,options:t.map(e=>({name:e.DtaEndTime?"".concat(T.a.utc(e.DtaStartTime).format("DD.MM.YYYY")," - ").concat(T.a.utc(e.DtaEndTime).format("DD.MM.YYYY")):"".concat(T.a.utc(e.DtaStartTime).format("DD.MM.YYYY")," - ..."),value:e})),onChange:this.onSettlementChange})))}setDate(e){e.diff(T.a.utc().startOf("day"),"days")<=0&&(this.setState({date:e}),this.checkIfNeedToGetAggregatedData(e.toDate().getTime()))}createDatePicker(e,t){return u.a.createElement("div",{className:"chart-controls"},u.a.createElement("h4",null,e),u.a.createElement("div",{className:"chart-controls-container"},t&&u.a.createElement(w.a,{buttonStyle:"bordered",onClick:this.onCompareDayClick},this.props.t("chamber.separationCageInfo.compareDays")),u.a.createElement("div",{className:"chart-controls-date"},u.a.createElement(w.a,{icon:u.a.createElement("i",{className:"fas fa-chevron-left"}),onClick:this.onLowerDateClick}),u.a.createElement(_.a,{type:"date",value:this.state.date.format("YYYY-MM-DD"),onChange:this.onDateChange,max:T()().format("yyyy-MM-dd")}),u.a.createElement(w.a,{icon:u.a.createElement("i",{className:"fas fa-chevron-right"}),onClick:this.onAddDateClick}))))}getExpeditionWorkType(e){const{t:t}=this.props;let a=e.expeditionData.workType;switch(console.log(a,e),a){case 1:return t("modals.cageWorkMode.sepMode");case 2:return t("left")+" "+t("modals.cageWorkMode.exitOpen");case 3:return t("right")+" "+t("modals.cageWorkMode.exitOpen");case 4:return t("modals.cageWorkMode.altOpen");default:return"-"}}getRFIDPasses(){try{let e=this.props.cageData.get(this.props.cage.DevID),t=T.a.utc().startOf("day").toDate().getTime(),a=e.find(e=>e.AggTi===t);if(a){let e=[];for(let t of a.AggDt[0].RFIDPass)for(let a of t.P)e.push({weight:a.W,time:a.T,RFID:t.RFID});return e.sort((e,t)=>t.time-e.time),e}return[]}catch(e){return[]}}getRFIDs(e,t=this.props){try{let a=t.cageData.get(this.props.cage.DevID);a=e.DtaEndTime?a.filter(t=>t.AggTi>=e.DtaStartTime&&t.AggTi<=e.DtaEndTime):a.filter(t=>t.AggTi>=e.DtaStartTime);let n=[];for(let e of a)for(let t of e.AggDt[0].RFIDPass)n.push({name:t.RFID,value:t.RFID});return n=s()(n,"value"),n.sort((e,t)=>+e.value-+t.value),n}catch(a){return console.error(a),[]}}getCurrentRFIDIndex(e){return m()(e,e=>e.value===this.state.rfid)}createRFIDPicker(e){const{settlements:t}=this.props,{settlement:a}=this.state;let n=this.getRFIDs(a),i=this.getCurrentRFIDIndex(n);return u.a.createElement("div",{className:"chart-controls"},u.a.createElement("h4",null,e),u.a.createElement("div",{className:"chart-controls-container"},u.a.createElement(H.a,{value:a,options:t.map(e=>({name:e.DtaEndTime?"".concat(T.a.utc(e.DtaStartTime).format("DD.MM.YYYY")," - ").concat(T.a.utc(e.DtaEndTime).format("DD.MM.YYYY")):"".concat(T.a.utc(e.DtaStartTime).format("DD.MM.YYYY")," - ..."),value:e})),onChange:this.onSettlementChange}),u.a.createElement("div",{className:"chart-controls-date"},u.a.createElement(w.a,{icon:u.a.createElement("i",{className:"fas fa-chevron-left"}),onClick:()=>this.onLeftRFIDClick(n,i),disabled:0===i}),u.a.createElement(H.a,{value:this.state.rfid,options:n,onChange:this.onRFIDChange}),u.a.createElement(w.a,{icon:u.a.createElement("i",{className:"fas fa-chevron-right"}),onClick:()=>this.onRightClick(n,i),disabled:i===n.length-1}))))}getName(){const{cage:{Alias:e}}=this.props,{location:t,additionalText:a,showAlias:n}=this.state;return n&&e?e:t||a}getMiddlePasses(){try{const{cageData:e,cage:t}=this.props,{selectedExpedition:a}=this.state;let n=e.get(t.DevID),i=T.a.utc(a.startDate),s=a.endDate?T.a.utc(a.endDate).endOf("day"):null,r=i.clone().startOf("day"),o=s?s.clone().startOf("day"):null;n=n.filter(e=>!(e.AggTio.toDate().getTime()));let c=[],l=T()(0).hour(i.hour()).minute(i.minute()),d=s?T()(0).hour(s.hour()).minute(s.minute()):null,m=(Object(ve.isUsingFakeData)()?[]:t.Settings.Expeditions).filter(e=>e.StartDate>=a.startDate&&(!a.endDate||e.EndDate<=a.endDate));for(let[h,u]of n.entries()){let e=u.AggDt[0].ExpMidPass.filter(e=>!(e.Td.toDate().getTime())),t=m.filter(e=>T()(e.StartDate).isSame(u.AggTi,"day"));for(let a of t){let t=T()(a.StartDate),n=T()(0).hour(t.hour()).minute(t.minute());e.push(je({T:n.toDate().getTime()},a,{fullWidth:!0}))}e.length>0&&c.push({fullWidth:!0,date:u.AggTi}),e.sort((e,t)=>t.T-e.T),c=[...c,...e]}return c}catch(e){return console.error(e),[]}}render(){const{collapse:e,chart:t,count:a,settlement:n,date:i,rfid:s,showLoading:r,expeditions:o,selectedExpedition:c,noInsertionInDevice:d}=this.state,{cage:m,selected:h,settlement:{state:p},t:g}=this.props,f=!!l()(m,"Settings.Marker",[]).filter(e=>e).length;let v=this.getShadow(),b=[{name:g("currentWeight"),field:"weight",valueFormatter:this.weightValueFormatter},{name:"RFID",field:"RFID",rtl:!0},{name:g("time"),field:"time",valueFormatter:this.timeValueFormatter}],I=[{name:g("currentWeight"),field:"W",valueFormatter:this.weightValueFormatter},{name:g("time"),field:"T",valueFormatter:this.timeValueFormatter}],T=[{name:g("cage"),value:"main"},{name:g("chamber.separationCageInfo.middlePasses"),value:"worktype"},{name:g("chamber.separationCageInfo.weightChart"),value:"weight"},{name:g("chamber.separationCageInfo.gainChart"),value:"gain"},{name:g("chamber.separationCageInfo.passesChart"),value:"dayPasses"},{name:g("chamber.separationCageInfo.weightPassesChart"),value:"passes"},{name:g("chamber.separationCageInfo.hourlyChart"),value:"hourly"},{name:"RFID",value:"rfid"},{name:g("chamber.separationCageInfo.calculator"),value:"calc"}];f&&T.push({name:g("marker"),value:"marker"});let j=this.getAverageWeight(v&&v.averageWeights&&v.averageWeights.all,0),x=this.getAverageWeight(v&&v.averageWeights&&v.averageWeights.left,1),M=this.getAverageWeight(v&&v.averageWeights&&v.averageWeights.middle,2),k=this.getAverageWeight(v&&v.averageWeights&&v.averageWeights.right,3),N=this.getGain(v&&v.averageWeights&&v.averageWeights.all),R=this.getName(),F=v?this.isError(v)?"error":"success":"warning",A=r?"fas fa-spin fa-circle-notch":v?this.isError(v)?"fas fa-exclamation fa-fw":"fas fa-cog fa-spin fa-fw":"fas fa-wifi-slash fa-fw",P=p===Se.a.SHOW_SETTLEMENT||p===Se.a.NO_SHOW||d;return u.a.createElement(D.a,{className:e?"device-item opened":"device-item",showWorking:!0,isError:!v,tooltipContent:this.getTooltipContent(v),onContextMenu:this.onContextMenu},u.a.createElement("div",{className:"device-info",onClick:this.onClick},u.a.createElement("div",{className:"device-main dev-ca ".concat(F)},u.a.createElement("div",{className:"device-main-location",title:R},R),this.getMainItem(v),u.a.createElement("div",{className:"device-main-item-alternate"},g("worktype"),": ",this.getWorkType(v&&v.configuration.workType)),u.a.createElement(be.a,null,({windowWidth:e})=>u.a.createElement(W.a,{tooltipContent:this.getTooltipContent(v),placement:e>=De.a.SM?"right":"left",type:F},u.a.createElement("div",{className:"device-main-working"},u.a.createElement("i",{className:A})))),u.a.createElement("div",{onClick:this.onSelectCage,className:"device-main-checkbox show-on-small-device sm"},u.a.createElement(K.a,{label:"",readOnly:!0,checked:h,id:m.DevID}))),u.a.createElement("div",{className:"device-info-main"},u.a.createElement("div",{className:"device-info-main-first".concat(P?" blur":"")},u.a.createElement(ee.a,{icon:te.a,name:g("chamber.separationCageInfo.weight"),value:this.getCurrentWeight(v)}),u.a.createElement(ee.a,{icon:ae.a,name:g("chamber.separationCageInfo.lastWeight"),value:this.getLastClosedWeight(v)}),u.a.createElement(ee.a,{icon:ne.a,name:g("chamber.separationCageInfo.averageWeightShort"),value:j&&"-"!==j?Object(J.j)(j,{unit:Q.a.MEDIUM,showUnit:!0,fixed:1}):"- ".concat(Object(J.l)("weight",Q.a.MEDIUM))}),u.a.createElement(ee.a,{icon:ie.a,name:g("gain"),value:N&&"-"!==N?Object(J.j)(N,{unit:Q.a.MEDIUM,showUnit:!0,fixed:1}):"- ".concat(Object(J.l)("weight",Q.a.MEDIUM))})),u.a.createElement("div",{className:"device-info-main-second".concat(P?" blur":"")},u.a.createElement(ee.a,{icon:ce.a,name:g("animalCount"),value:a}),u.a.createElement(ee.a,{icon:le.a,name:g("chamber.separationCageInfo.fatteningDay"),value:this.getSettlementDay()}),u.a.createElement(ee.a,{icon:de.a,name:g("chamber.separationCageInfo.averagePasses"),value:this.getAveragePasses(v)})),u.a.createElement("div",{className:"device-info-main-third".concat(P?" blur":"")},u.a.createElement(oe,{name:g("left"),weight:x&&"-"!==x?Object(J.j)(x,{unit:Q.a.MEDIUM,showUnit:!0,fixed:1}):"- ".concat(Object(J.l)("weight",Q.a.MEDIUM)),passes:v&&(v.counters.left||0===v.counters.middle)?v.counters.left:"-"}),u.a.createElement(oe,{name:g("middle"),weight:M&&"-"!==M?Object(J.j)(M,{unit:Q.a.MEDIUM,showUnit:!0,fixed:1}):"- ".concat(Object(J.l)("weight",Q.a.MEDIUM)),passes:v&&(v.counters.middle||0===v.counters.middle)?v.counters.middle:"-"}),u.a.createElement(oe,{name:g("right"),weight:k&&"-"!==k?Object(J.j)(k,{unit:Q.a.MEDIUM,showUnit:!0,fixed:1}):"- ".concat(Object(J.l)("weight",Q.a.MEDIUM)),passes:v&&(v.counters.right||0===v.counters.right)?v.counters.right:"-"})),P&&u.a.createElement("div",{className:"device-info-main-not-enough-data"},(p===Se.a.SHOW_SETTLEMENT||p===Se.a.NO_SHOW)&&g("chamber.separationCageInfo.noSettlement"),d&&g("chamber.separationCageInfo.noSettlementWeight"))),u.a.createElement("div",{onClick:this.onSelectCage,className:"device-info-checkbox hide-on-small-device sm"},u.a.createElement(K.a,{label:"",checked:h,readOnly:!0,id:m.DevID}))),u.a.createElement(E.a,{in:e,unmountOnExit:!0,onExited:this.onCollapseExit},u.a.createElement("div",{className:"chart-container"},u.a.createElement(H.a,{options:T,value:t,onChange:this.onChartChange,clearButton:!1}),u.a.createElement("div",{className:"device-chart",ref:this.container},"main"===t&&u.a.createElement("div",{className:"cage-data"},u.a.createElement("div",{className:"chart-main-container"},u.a.createElement(B.a,{entrance:this.getDoorStatus(v&&v.sensors.length>0?v.sensors[0].value:0,v&&v.sensors.length>0?v.sensors[1].value:0),middle:this.getDoorStatus(v&&v.sensors.length>0?v.sensors[2].value:0,v&&v.sensors.length>0?v.sensors[3].value:0),left:this.getDoorStatus(v&&v.sensors.length>0?v.sensors[4].value:0,v&&v.sensors.length>0?v.sensors[5].value:0),right:this.getDoorStatus(v&&v.sensors.length>0?v.sensors[6].value:0,v&&v.sensors.length>0?v.sensors[7].value:0),weight:this.getCurrentWeight(v),passes:v?v.counters.all:"-",passesLeft:v?v.counters.left:"-",passesMiddle:v?v.counters.middle:"-",passesRight:v?v.counters.right:"-",workType:v?v.configuration.workType:-1,cage:this.props.cage,valves:v?v.valves:[],weightClosed:this.getLastClosedWeight(v),errors:v?v.errors:[]})),u.a.createElement("div",{className:"cage-info"},u.a.createElement("h4",{className:"justify-content-between"},g("chamber.separationCageInfo.rfidPasses"),u.a.createElement(w.a,{buttonStyle:"round",icon:u.a.createElement("i",{className:"fas fa-expand-arrows-alt"}),onClick:()=>this.onExpandClick("RFID")})),u.a.createElement(q.a,{scrollOnPageChange:!1,data:this.getRFIDPasses().slice(0,7),headers:b,shouldIndex:!0}))),"worktype"===t&&u.a.createElement(u.a.Fragment,null,u.a.createElement("h4",{className:"justify-content-between"},g("chamber.separationCageInfo.middlePasses"),u.a.createElement(w.a,{buttonStyle:"round",icon:u.a.createElement("i",{className:"fas fa-expand-arrows-alt"}),onClick:()=>this.onExpandClick("Middle")})),o.length>0&&u.a.createElement("div",{className:"expedition-list"},u.a.createElement(H.a,{value:c,options:o,clearButton:!1,onChange:this.onSelectedExpeditionChange}),u.a.createElement(q.a,{scrollOnPageChange:!1,data:this.getMiddlePasses(),headers:I,shouldIndex:!0,showPagination:!0,paginationItems:10,isFullWidthRow:e=>e.fullWidth,fullWidthRow:u.a.createElement(Ce,null)})),0===o.length&&u.a.createElement(u.a.Fragment,null,u.a.createElement(we.a,{boxColor:"error"},g("chamber.separationCageInfo.noExpeditions")))),"weight"===t&&u.a.createElement(u.a.Fragment,null,this.createSettlementSelect(g("chamber.separationCageInfo.weightChart")),u.a.createElement("div",{className:"chart-main-container"},u.a.createElement(y.a,{cage:m,settlement:n,showExcelButton:!0}))),"gain"===t&&u.a.createElement(u.a.Fragment,null,this.createSettlementSelect(g("chamber.separationCageInfo.gainChart")),u.a.createElement("div",{className:"chart-main-container"},u.a.createElement(O.a,{cage:m,settlement:n,showExcelButton:!0}))),"dayPasses"===t&&u.a.createElement(u.a.Fragment,null,this.createSettlementSelect(g("chamber.separationCageInfo.passesChart")),u.a.createElement("div",{className:"chart-main-container"},u.a.createElement(C.a,{cage:m,settlement:n,showExcelButton:!0}))),"passes"===t&&u.a.createElement(u.a.Fragment,null,this.createDatePicker(g("chamber.separationCageInfo.weightPassesChart"),!0),u.a.createElement("div",{className:"chart-main-container"},u.a.createElement(S.a,{cage:m,date:i,container:this.container,showExcelButton:!0}))),"hourly"===t&&u.a.createElement(u.a.Fragment,null,this.createDatePicker("Wykres ilo\u015bci przej\u015b\u0107 w godzinach"),u.a.createElement("div",{className:"chart-main-container"},u.a.createElement(U,{cage:m,date:i,showExcelButton:!0}))),"calc"===t&&u.a.createElement(z.a,{cage:m,gain:N,weight:this.getAverageWeight(v&&v.averageWeights&&v.averageWeights.all,0),animalsNumber:a}),"marker"===t&&f&&u.a.createElement("div",{className:"chart-main-container"},u.a.createElement($.a,{cage:m})),"rfid"===t&&u.a.createElement(u.a.Fragment,null,this.createRFIDPicker("RFID"),u.a.createElement("div",{className:"chart-main-container"},u.a.createElement(fe,{cage:m,RFID:s,settlement:n})))))))}}Me.propTypes={cage:g.a.object.isRequired,selected:g.a.bool,onSelect:g.a.func,onRightClick:g.a.func},Me.defaultProps={selected:!1,onSelect:()=>{}},Me=Object(f.a)(e=>({roles:[v.c._DEVICE_CAGE],devPlcmnts:Object(x.f)(e.cage)}))(Me),Me=Object(M.connect)((e,t)=>{const{cage:a}=t;let n=a.getLocation(),i=Object(b.j)(n[0]);return{cageData:e.aggregatedData.data,shadows:e.shadows.shadows,lang:e.language.lang.lang,settlement:Object(Se.c)(e,{CID:i}),settlements:Object(Se.d)(e,{CID:i})}},e=>Object(G.b)({show:X.d},e))(Me);t.a=Object(P.a)()(Me)},ZiuD:function(e,t,a){"use strict";var n=a("q1tI"),i=a.n(n),s=a("17x9"),r=a.n(s),o=a("VfnB"),c=a("G7tO"),l=a("LCzB");class d extends i.a.Component{constructor(e){super(e),this.state={data:this.calculateData(e)}}calculateData(e){const{stages:t}=e;let a=[];if(8===t.length){for(let i=1;i>=0;i--){let e=t[i];if(0===i){let t=a[0];a.push({days:t.days-e.Days,expectedTemperature:e.ExpectedTemperature,ventilationMin:Object(o.c)(e.Ventilation[0]),ventilationMax:Object(o.c)(e.Ventilation[1])})}else a.push({days:-e.Days,expectedTemperature:e.ExpectedTemperature,ventilationMin:Object(o.c)(e.Ventilation[0]),ventilationMax:Object(o.c)(e.Ventilation[1])})}a.reverse();for(let i=2;i<8;i++){let e=t[i];if(2===i)a.push({days:0,expectedTemperature:e.ExpectedTemperature,ventilationMin:Object(o.c)(e.Ventilation[0]),ventilationMax:Object(o.c)(e.Ventilation[1])});else{let n=t[i-1],s=a[i-1];a.push({days:n.Days+s.days,expectedTemperature:e.ExpectedTemperature,ventilationMin:Object(o.c)(e.Ventilation[0]),ventilationMax:Object(o.c)(e.Ventilation[1])})}}let e=t[7],n=a[a.length-1];a.push({days:n.days+e.Days,expectedTemperature:e.ExpectedTemperature,ventilationMin:Object(o.c)(e.Ventilation[0]),ventilationMax:Object(o.c)(e.Ventilation[1])})}return a}UNSAFE_componentWillReceiveProps(e,t){this.setState({data:this.calculateData(e)})}render(){const{t:e}=this.props,t=[{color:"green",dataKey:"expectedTemperature",type:"stepAfter",name:e("requestedTemperature"),unit:"\xb0C"},{color:"orange",dataKey:"ventilationMin",type:"stepAfter",name:e("minimumVentilation"),unit:"%"},{color:"blue",dataKey:"ventilationMax",type:"stepAfter",name:e("maximumVentilation"),unit:"%"}];return i.a.createElement("div",{className:"climate-curve-chart"},i.a.createElement(c.a,{dataDef:t,data:this.state.data,Xaxis:{dataKey:"days",name:e("day")},Yaxis:{name:e("value")}}))}}d.propTypes={stages:r.a.array.isRequired},t.a=Object(l.a)()(d)},fxKK:function(e,t,a){"use strict";var n=a("Y+p1"),i=a.n(n),s=a("q1tI"),r=a.n(s),o=a("/MKj"),c=a("sPOc"),l=a("S8cm"),d=a("17x9"),m=a.n(d),h=a("YDFS"),u=a("wd/R"),p=a.n(u),g=a("dxSB"),f=a("vYJ8"),v=a("hw2D"),b=a("kCVf"),D=a("q17X"),E=a("UZWR"),w=a("ANjH"),y=a("LCzB"),O=a("G7tO"),C=a("udB/"),S=a("2wEF"),I=a("wPNM"),T=a.n(I),j=a("BvFm"),x=a("pxzG"),M=a("eASP");class k extends s.Component{constructor(e){super(e),this.state={loading:!0,data:[],isService:Object(j.i)()},this.worker=new T.a,this.weightValueFormatter=e=>null===e?null:Object(x.j)(e,{unit:M.a.MEDIUM,rawValue:!0}),this.tickFormatter=e=>{const{isService:t}=this.state;return t?p()(e).format("DD.MM.YYYY HH:mm"):p()(e).format("DD.MM.YYYY")},this.worker.onmessage=e=>{this.setState({data:e.data.data,loading:!1})}}componentDidMount(){this.sendDataToWorker()}componentDidUpdate(e,t,a){i()(this.props.aggregatedData,e.aggregatedData)&&i()(this.props.settlement,e.settlement)||(console.log("new data",this.props.settlement,this.props.aggregatedData),this.sendDataToWorker())}componentWillUnmount(){this.worker.terminate()}sendDataToWorker(){const{aggregatedData:e,pigletScale:t,settlement:a}=this.props,{isService:n}=this.state;let i=e.get(t.DevID)||[];this.worker.postMessage({data:i,settlement:a,isService:n}),this.setState({loading:!0})}render(){const{loading:e,data:t}=this.state,{t:a}=this.props,n=[{color:"green",dataKey:"value",name:a("weight"),opacity:.2,valueConverter:this.weightValueFormatter,unit:Object(x.l)("weight",M.a.MEDIUM)},{color:"green",dataKey:"amount",name:a("amount"),opacity:.4,chartType:"Bar",defaultOff:!0,strokeOpacity:.2,yAxisId:"right"},{color:"blue",dataKey:"valueSavgol",name:a("chamber.chart.weightSavgol"),opacity:.2,valueConverter:this.weightValueFormatter,unit:Object(x.l)("weight",M.a.MEDIUM)},{color:"blue",dataKey:"amountSavgol",name:a("chamber.chart.amountSavgol"),opacity:.4,chartType:"Bar",defaultOff:!0,strokeOpacity:.2,yAxisId:"right"}];return r.a.createElement(r.a.Fragment,null,r.a.createElement(C.a,{isLoading:e}),0===t.length&&r.a.createElement(S.a,null),t.length>0&&r.a.createElement(r.a.Fragment,null,r.a.createElement(O.a,{dataDef:n,data:t,Yaxis:{name:a("weight")},Xaxis:{name:a("time"),dataKey:"name",formatter:this.tickFormatter},saveAsExcell:"pigletScaleHistogram",tooltipLabelFormatter:this.tickFormatter,type:"Composed",secondYaxis:{name:a("amount")}})))}}k.propTypes={settlement:m.a.shape({DtaStartTime:m.a.number.isRequired,DtaEndTime:m.a.number}).isRequired,pigletScale:m.a.instanceOf(h.a).isRequired};var N=Object(w.d)(Object(o.connect)((function(e){return{aggregatedData:e.aggregatedData.data}})),Object(y.a)())(k),R=a("AUDd"),F=a.n(R);class A extends s.Component{constructor(e){super(e),this.state={loading:!0,data:[],isService:Object(j.i)()},this.worker=new F.a,this.weightValueFormatter=e=>null===e?null:Object(x.j)(e,{unit:M.a.MEDIUM,rawValue:!0}),this.tickFormatter=e=>{const{isService:t}=this.state;return t?p()(e).format("DD.MM.YYYY HH:mm"):p()(e).format("DD.MM.YYYY")},this.worker.onmessage=e=>{this.setState({data:e.data.data,loading:!1})}}componentDidMount(){this.sendDataToWorker()}componentDidUpdate(e,t,a){i()(this.props.aggregatedData,e.aggregatedData)&&i()(this.props.settlement,e.settlement)||this.sendDataToWorker()}componentWillUnmount(){this.worker.terminate()}sendDataToWorker(){const{aggregatedData:e,pigletScale:t,settlement:a}=this.props,{isService:n}=this.state;let i=e.get(t.DevID)||[];this.worker.postMessage({data:i,settlement:a,isService:n}),this.setState({loading:!0})}render(){const{loading:e,data:t}=this.state,{t:a}=this.props,n=[{color:"green",dataKey:"value",name:a("weight"),opacity:.2,valueConverter:this.weightValueFormatter,unit:Object(x.l)("weight",M.a.MEDIUM)},{color:"green",dataKey:"amount",name:a("amount"),opacity:.4,chartType:"Bar",defaultOff:!0,strokeOpacity:.2,yAxisId:"right"},{color:"blue",dataKey:"valueSavgol",name:a("chamber.chart.weightSavgol"),opacity:.2,valueConverter:this.weightValueFormatter,unit:Object(x.l)("weight",M.a.MEDIUM)},{color:"blue",dataKey:"amountSavgol",name:a("chamber.chart.amountSavgol"),opacity:.4,chartType:"Bar",defaultOff:!0,strokeOpacity:.2,yAxisId:"right"}];return r.a.createElement(r.a.Fragment,null,r.a.createElement(C.a,{isLoading:e}),0===t.length&&r.a.createElement(S.a,null),t.length>0&&r.a.createElement(r.a.Fragment,null,r.a.createElement(O.a,{dataDef:n,data:t,Yaxis:{name:a("weight")},Xaxis:{name:a("time"),dataKey:"name",formatter:this.tickFormatter},saveAsExcell:"pigletScaleHalfup",tooltipLabelFormatter:this.tickFormatter,type:"Composed",secondYaxis:{name:a("amount")}})))}}A.propTypes={settlement:m.a.shape({DtaStartTime:m.a.number.isRequired,DtaEndTime:m.a.number}).isRequired,pigletScale:m.a.instanceOf(h.a).isRequired};var P=Object(w.d)(Object(o.connect)((function(e){return{aggregatedData:e.aggregatedData.data}})),Object(y.a)())(A),L=a("FSjz"),U=a.n(L);class Y extends s.Component{constructor(e){super(e),this.state={loading:!0,data:[],isService:Object(j.i)()},this.worker=new U.a,this.weightValueFormatter=e=>null===e?null:Object(x.j)(e,{unit:M.a.MEDIUM,rawValue:!0}),this.tickFormatter=e=>{const{isService:t}=this.state;return t?p()(e).format("DD.MM.YYYY HH:mm"):p()(e).format("DD.MM.YYYY")},this.worker.onmessage=e=>{this.setState({data:e.data.data,loading:!1})}}componentDidMount(){this.sendDataToWorker()}componentDidUpdate(e,t,a){i()(this.props.aggregatedData,e.aggregatedData)&&i()(this.props.settlement,e.settlement)||this.sendDataToWorker()}componentWillUnmount(){this.worker.terminate()}sendDataToWorker(){const{aggregatedData:e,pigletScale:t,settlement:a}=this.props,{isService:n}=this.state;let i=e.get(t.DevID)||[];this.worker.postMessage({data:i,settlement:a,isService:n}),this.setState({loading:!0})}render(){const{loading:e,data:t}=this.state,{t:a}=this.props,n=[{color:"green",dataKey:"value",name:a("weight"),opacity:.2,valueConverter:this.weightValueFormatter,unit:Object(x.l)("weight",M.a.MEDIUM)},{color:"green",dataKey:"amount",name:a("amount"),opacity:.4,chartType:"Bar",defaultOff:!0,strokeOpacity:.2,yAxisId:"right"},{color:"blue",dataKey:"valueSavgol",name:a("chamber.chart.weightSavgol"),opacity:.2,valueConverter:this.weightValueFormatter,unit:Object(x.l)("weight",M.a.MEDIUM)},{color:"blue",dataKey:"amountSavgol",name:a("chamber.chart.amountSavgol"),opacity:.4,chartType:"Bar",defaultOff:!0,strokeOpacity:.2,yAxisId:"right"}];return r.a.createElement(r.a.Fragment,null,r.a.createElement(C.a,{isLoading:e}),0===t.length&&r.a.createElement(S.a,null),t.length>0&&r.a.createElement(r.a.Fragment,null,r.a.createElement(O.a,{dataDef:n,data:t,Yaxis:{name:a("weight")},Xaxis:{name:a("time"),dataKey:"name",formatter:this.tickFormatter},saveAsExcell:"pigletScaleMedian",tooltipLabelFormatter:this.tickFormatter,type:"Composed",secondYaxis:{name:a("amount")}})))}}Y.propTypes={settlement:m.a.shape({DtaStartTime:m.a.number.isRequired,DtaEndTime:m.a.number}).isRequired,pigletScale:m.a.instanceOf(h.a).isRequired};var V=Object(w.d)(Object(o.connect)((function(e){return{aggregatedData:e.aggregatedData.data}})),Object(y.a)())(Y),W=a("iwiu"),B=a.n(W);class q extends s.Component{constructor(e){super(e),this.state={loading:!0,data:[],isService:Object(j.i)()},this.worker=new B.a,this.weightValueFormatter=e=>null===e?null:Object(x.j)(e,{unit:M.a.MEDIUM,rawValue:!0}),this.tickFormatter=e=>{const{isService:t}=this.state;return t?p()(e).format("DD.MM.YYYY HH:mm"):p()(e).format("DD.MM.YYYY")},this.worker.onmessage=e=>{this.setState({data:e.data.data,loading:!1})}}componentDidMount(){this.sendDataToWorker()}componentDidUpdate(e,t,a){i()(this.props.aggregatedData,e.aggregatedData)&&i()(this.props.settlement,e.settlement)||this.sendDataToWorker()}componentWillUnmount(){this.worker.terminate()}sendDataToWorker(){const{aggregatedData:e,pigletScale:t,settlement:a}=this.props,{isService:n}=this.state;let i=e.get(t.DevID)||[];this.worker.postMessage({data:i,settlement:a,isService:n}),this.setState({loading:!0})}render(){const{loading:e,data:t}=this.state,{t:a}=this.props,n=[{color:"green",dataKey:"value",name:a("weight"),opacity:.2,valueConverter:this.weightValueFormatter,unit:Object(x.l)("weight",M.a.MEDIUM)},{color:"green",dataKey:"amount",name:a("amount"),opacity:.4,chartType:"Bar",defaultOff:!0,strokeOpacity:.2,yAxisId:"right"},{color:"blue",dataKey:"valueSavgol",name:a("chamber.chart.weightSavgol"),opacity:.2,valueConverter:this.weightValueFormatter,unit:Object(x.l)("weight",M.a.MEDIUM)},{color:"blue",dataKey:"amountSavgol",name:a("chamber.chart.amountSavgol"),opacity:.4,chartType:"Bar",defaultOff:!0,strokeOpacity:.2,yAxisId:"right"}];return r.a.createElement(r.a.Fragment,null,r.a.createElement(C.a,{isLoading:e}),0===t.length&&r.a.createElement(S.a,null),t.length>0&&r.a.createElement(r.a.Fragment,null,r.a.createElement(O.a,{dataDef:n,data:t,Yaxis:{name:a("weight")},Xaxis:{name:a("time"),dataKey:"name",formatter:this.tickFormatter},saveAsExcell:"pigletScaleNormal",tooltipLabelFormatter:this.tickFormatter,type:"Composed",secondYaxis:{name:a("amount")}})))}}q.propTypes={settlement:m.a.shape({DtaStartTime:m.a.number.isRequired,DtaEndTime:m.a.number}).isRequired,pigletScale:m.a.instanceOf(h.a).isRequired};var K=Object(w.d)(Object(o.connect)((function(e){return{aggregatedData:e.aggregatedData.data}})),Object(y.a)())(q),H=a("umKC"),_=a.n(H);class z extends s.Component{constructor(e){super(e),this.state={loading:!0,data:[],isService:Object(j.i)()},this.worker=new _.a,this.weightValueFormatter=e=>null===e?null:Object(x.j)(e,{unit:M.a.MEDIUM,rawValue:!0}),this.tickFormatter=e=>{const{isService:t}=this.state;return t?p()(e).format("DD.MM.YYYY HH:mm"):p()(e).format("DD.MM.YYYY")},this.worker.onmessage=e=>{this.setState({data:e.data.data,loading:!1})}}componentDidMount(){this.sendDataToWorker()}componentDidUpdate(e,t,a){i()(this.props.aggregatedData,e.aggregatedData)&&i()(this.props.settlement,e.settlement)||this.sendDataToWorker()}componentWillUnmount(){this.worker.terminate()}sendDataToWorker(){const{aggregatedData:e,pigletScale:t,settlement:a}=this.props,{isService:n}=this.state;let i=e.get(t.DevID)||[];this.worker.postMessage({data:i,settlement:a,isService:n}),this.setState({loading:!0})}render(){const{loading:e,data:t}=this.state,{t:a}=this.props,n=[{color:"green",dataKey:"value",name:a("weight"),opacity:.2,valueConverter:this.weightValueFormatter,unit:Object(x.l)("weight",M.a.MEDIUM),chartType:"Area"},{color:"green",dataKey:"amount",name:a("amount"),opacity:.4,chartType:"Bar",defaultOff:!0,strokeOpacity:.2,yAxisId:"right"},{color:"blue",dataKey:"valueSavgol",name:a("chamber.chart.weightSavgol"),opacity:.2,valueConverter:this.weightValueFormatter,unit:Object(x.l)("weight",M.a.MEDIUM),chartType:"Area"},{color:"blue",dataKey:"amountSavgol",name:a("chamber.chart.amountSavgol"),opacity:.4,chartType:"Bar",defaultOff:!0,strokeOpacity:.2,yAxisId:"right"}];return r.a.createElement(r.a.Fragment,null,r.a.createElement(C.a,{isLoading:e}),0===t.length&&r.a.createElement(S.a,null),t.length>0&&r.a.createElement(r.a.Fragment,null,r.a.createElement(O.a,{dataDef:n,data:t,Yaxis:{name:a("weight")},Xaxis:{name:a("time"),dataKey:"name",formatter:this.tickFormatter},saveAsExcell:"pigletScalePeaks",tooltipLabelFormatter:this.tickFormatter,type:"Composed",secondYaxis:{name:a("amount")}})))}}z.propTypes={settlement:m.a.shape({DtaStartTime:m.a.number.isRequired,DtaEndTime:m.a.number}).isRequired,pigletScale:m.a.instanceOf(h.a).isRequired};var G=Object(w.d)(Object(o.connect)((function(e){return{aggregatedData:e.aggregatedData.data}})),Object(y.a)())(z),X=a("2rxW"),Z=a("IcrQ"),J=a("QWcO"),Q=a("CuyV"),$=a("ujxO"),ee=(a("9CwR"),a("NnKB")),te=a("yv15"),ae=a("H+Jz"),ne=a("IHNp"),ie=a.n(ne);class se extends s.Component{constructor(e){super(e),this.state={loading:!0,data:[],isService:Object(j.i)()},this.worker=new ie.a,this.weightValueFormatter=e=>null===e?null:Object(x.j)(e,{unit:M.a.MEDIUM,rawValue:!0}),this.tickFormatter=e=>p()(e).format("DD.MM.YYYY"),this.worker.onmessage=e=>{this.setState({data:e.data.data,loading:!1})}}componentDidMount(){this.sendDataToWorker()}componentDidUpdate(e,t,a){i()(this.props.aggregatedData,e.aggregatedData)&&i()(this.props.settlement,e.settlement)||this.sendDataToWorker()}componentWillUnmount(){this.worker.terminate()}sendDataToWorker(){const{aggregatedData:e,pigletScale:t,settlement:a}=this.props,{isService:n}=this.state;let i=e.get(t.DevID)||[];this.worker.postMessage({data:i,settlement:a,isService:n}),this.setState({loading:!0})}render(){const{loading:e,data:t,isService:a}=this.state,{t:n}=this.props;let i=[{color:"green",dataKey:"hist",name:n("chamber.chart.hist"),opacity:.2,valueConverter:this.weightValueFormatter,unit:Object(x.l)("weight",M.a.MEDIUM),chartType:"Area"},{color:"orange",dataKey:"halfUp",name:n("chamber.chart.halfUp"),opacity:.2,valueConverter:this.weightValueFormatter,unit:Object(x.l)("weight",M.a.MEDIUM),chartType:"Area"},{color:"red",dataKey:"median",name:n("chamber.chart.median"),opacity:.2,valueConverter:this.weightValueFormatter,unit:Object(x.l)("weight",M.a.MEDIUM),chartType:"Area"},{color:"pink",dataKey:"normal",name:n("avg"),opacity:.2,valueConverter:this.weightValueFormatter,unit:Object(x.l)("weight",M.a.MEDIUM),chartType:"Area"},{color:"blue",dataKey:"peaks",name:n("chamber.chart.peaks"),opacity:.2,valueConverter:this.weightValueFormatter,unit:Object(x.l)("weight",M.a.MEDIUM),chartType:"Area"}];return a&&(i=[...i,{color:"green",dataKey:"histAmount",name:n("chamber.chart.histAmount"),opacity:.4,chartType:"Bar",defaultOff:!0,strokeOpacity:.2,yAxisId:"right"},{color:"orange",dataKey:"halfUpAmount",name:n("chamber.chart.halfUpAmount"),opacity:.4,chartType:"Bar",defaultOff:!0,strokeOpacity:.2,yAxisId:"right"},{color:"red",dataKey:"medianAmount",name:n("chamber.chart.medianAmount"),opacity:.4,chartType:"Bar",defaultOff:!0,strokeOpacity:.2,yAxisId:"right"},{color:"pink",dataKey:"normalAmount",name:n("chamber.chart.normalAmount"),opacity:.4,chartType:"Bar",defaultOff:!0,strokeOpacity:.2,yAxisId:"right"},{color:"blue",dataKey:"peaksAmount",name:n("chamber.chart.peaksAmount"),opacity:.4,chartType:"Bar",defaultOff:!0,strokeOpacity:.2,yAxisId:"right"}]),r.a.createElement(r.a.Fragment,null,r.a.createElement(C.a,{isLoading:e}),0===t.length&&r.a.createElement(S.a,null),t.length>0&&r.a.createElement(r.a.Fragment,null,r.a.createElement(O.a,{dataDef:i,data:t,Yaxis:{name:n("weight")},Xaxis:{name:n("time"),dataKey:"name",formatter:this.tickFormatter},saveAsExcell:"composedPigletScale",tooltipLabelFormatter:this.tickFormatter,type:a?"Composed":"Area",secondYaxis:a?{name:n("amount")}:null})))}}se.propTypes={settlement:m.a.shape({DtaStartTime:m.a.number.isRequired,DtaEndTime:m.a.number}).isRequired,pigletScale:m.a.instanceOf(h.a).isRequired};var re=Object(w.d)(Object(o.connect)((function(e){return{aggregatedData:e.aggregatedData.data}})),Object(y.a)())(se),oe=a("JAfD"),ce=a.n(oe);class le extends s.Component{constructor(e){super(e),this.state={loading:!0,data:[],isService:Object(j.i)()},this.worker=new ce.a,this.weightValueFormatter=e=>null===e?null:Object(x.j)(e,{unit:M.a.MEDIUM,rawValue:!0}),this.tickFormatter=e=>p()(e).format("DD.MM.YYYY"),this.worker.onmessage=e=>{this.setState({data:e.data.data,loading:!1})}}componentDidMount(){this.sendDataToWorker()}componentDidUpdate(e,t,a){i()(this.props.aggregatedData,e.aggregatedData)&&i()(this.props.settlement,e.settlement)&&this.props.field===e.field||this.sendDataToWorker()}componentWillUnmount(){this.worker.terminate()}sendDataToWorker(){const{aggregatedData:e,pigletScale:t,settlement:a,field:n}=this.props;let i=e.get(t.DevID)||[];this.worker.postMessage({data:i,settlement:a,field:n}),this.setState({loading:!0})}render(){const{loading:e,data:t}=this.state,{t:a}=this.props;let n=[{color:"green",dataKey:"gain",name:a("gain"),opacity:.2,valueConverter:this.weightValueFormatter,unit:Object(x.l)("weight",M.a.MEDIUM),chartType:"Area"}];return r.a.createElement(r.a.Fragment,null,r.a.createElement(C.a,{isLoading:e}),0===t.length&&r.a.createElement(S.a,null),t.length>0&&r.a.createElement(r.a.Fragment,null,r.a.createElement(O.a,{dataDef:n,data:t,Yaxis:{name:a("gain")},Xaxis:{name:a("time"),dataKey:"name",formatter:this.tickFormatter},saveAsExcell:"composedPigletScale",tooltipLabelFormatter:this.tickFormatter})))}}le.propTypes={settlement:m.a.shape({DtaStartTime:m.a.number.isRequired,DtaEndTime:m.a.number}).isRequired,pigletScale:m.a.instanceOf(h.a).isRequired,field:m.a.string},le.defaultProps={field:"HM"};var de=Object(w.d)(Object(o.connect)((function(e){return{aggregatedData:e.aggregatedData.data}})),Object(y.a)())(le),me=a("nNb6"),he=a("3m4P"),ue=a("5/MK"),pe=a("+0ec"),ge=a("15N+"),fe=a("TmEv"),ve=a("bmNN"),be=a("R+tp"),De=a("B+hW"),Ee=a("YRMh"),we=a("Dmtc");class ye extends s.Component{constructor(...e){super(...e),this.state={collapse:!1,chart:"composed",location:this.props.scale.getLocation().map(e=>Object(b.k)(e)).join(","),showAlias:Object(D.getShowAliases)(),settlement:this.props.settlement.data,loading:!0,noInsertionInDevice:!1,gainField:"HM"},this.onSelect=e=>{e.stopPropagation(),e.preventDefault(),this.props.onSelect(this.props.scale)},this.onCollapseExit=()=>{this.setState({chart:"histogram"})},this.onClick=()=>{this.setState(e=>({collapse:!e.collapse}))},this.onChartChange=e=>{this.setState({chart:e})},this.onSettlementChange=e=>{this.setState({settlement:e}),this.checkIfNeedAggregatedData(e.DtaStartTime,e.DtaEndTime||(new Date).getTime())},this.onGainFieldChange=e=>{this.setState({gainField:e})}}static getDerivedStateFromProps(e,t){if(t.loading){let t=e.aggregatedDataLoading.get(e.scale.DevID);return{loading:"boolean"!==typeof t||t}}return null}componentDidMount(){const{settlement:e}=this.state;Object(D.isUsingFakeData)()&&Object(we.a)(this.props.scale.DevID),e&&(this.checkIfNeedAggregatedData(e.DtaStartTime,e.DtaEndTime||(new Date).getTime()),this.setState({noInsertionInDevice:this.checkIfNoStartedInsertionInDevice(e)}))}componentDidUpdate(e,t,a){if(!i()(this.props.settlement.data,e.settlement.data)&&!this.state.settlement){let e=this.props.settlement.data;this.setState({settlement:e,noInsertionInDevice:this.checkIfNoStartedInsertionInDevice(e)}),this.checkIfNeedAggregatedData(e.DtaStartTime,e.DtaEndTime||(new Date).getTime())}i()(this.props.scale,e.scale)||this.setState({noInsertionInDevice:this.checkIfNoStartedInsertionInDevice(this.state.settlement)})}checkIfNeedAggregatedData(e,t){if(!Object(D.isUsingFakeData)()){let a=p.a.utc(e),n=1;if(t){n=p.a.utc(t).diff(a,"days")+1}let i=this.props.aggregatedData.get(this.props.scale.DevID),s=!!i;if(s)for(let e=0;ee.AggTi===t).length){s=!1;break}}if(!s){let a;a=t?{AggDataTimeFrom:e,AggDataTimeTo:t}:{AggDataTime:e},this.props.dispatch(Object(g.a)(this.props.scale,a))}}}checkIfNoStartedInsertionInDevice(e){try{const{DtaStartTime:t}=e,{scale:a}=this.props;return!Object(D.isUsingFakeData)()&&!a.Settings.Insertions.find(e=>e.StartTime===t)}catch(t){return!1}}getName(){const{scale:{Alias:e}}=this.props,{location:t,showAlias:a}=this.state;return a&&e?e:t}createSettlementSelect(e){const{settlements:t}=this.props,{settlement:a}=this.state;return r.a.createElement("div",{className:"chart-controls"},r.a.createElement("h4",null,e),r.a.createElement("div",{className:"chart-controls-container"},r.a.createElement(v.a,{value:a,options:t.map(e=>({name:e.DtaEndTime?"".concat(p.a.utc(e.DtaStartTime).format("DD.MM.YYYY")," - ").concat(p.a.utc(e.DtaEndTime).format("DD.MM.YYYY")):"".concat(p.a.utc(e.DtaStartTime).format("DD.MM.YYYY")," - ..."),value:e})),onChange:this.onSettlementChange,clearButton:!1})))}createGainTypeSelect(e){const{settlements:t,t:a}=this.props,{settlement:n,gainField:i}=this.state;return r.a.createElement("div",{className:"chart-controls"},r.a.createElement("h4",null,e),r.a.createElement("div",{className:"chart-controls-container"},r.a.createElement(v.a,{value:i,options:[{name:a("deviceRows.pigletScale.histogram"),value:"HM"},{name:a("deviceRows.pigletScale.histogram")+" - SAVGOL",value:"HMS"},{name:a("deviceRows.pigletScale.halfUp"),value:"HU"},{name:a("deviceRows.pigletScale.halfUp")+" - SAVGOL",value:"HUS"},{name:a("deviceRows.pigletScale.median"),value:"MA"},{name:a("deviceRows.pigletScale.median")+" - SAVGOL",value:"MAS"},{name:a("deviceRows.pigletScale.normal"),value:"NA"},{name:a("deviceRows.pigletScale.normal")+" - SAVGOL",value:"NAS"},{name:a("deviceRows.pigletScale.peaks"),value:"PS"},{name:a("deviceRows.pigletScale.peaks")+" - SAVGOL",value:"PSS"}],clearButton:!1,onChange:this.onGainFieldChange}),r.a.createElement(v.a,{value:n,options:t.map(e=>({name:e.DtaEndTime?"".concat(p.a.utc(e.DtaStartTime).format("DD.MM.YYYY")," - ").concat(p.a.utc(e.DtaEndTime).format("DD.MM.YYYY")):"".concat(p.a.utc(e.DtaStartTime).format("DD.MM.YYYY")," - ..."),value:e})),onChange:this.onSettlementChange,clearButton:!1})))}getWeight(e,t=!0){const{aggregatedData:a,scale:n,settlement:{data:i}}=this.props;try{let s=a.get(n.DevID)||[];s=s.filter(e=>!(i.DtaEndTime&&e.AggTi>i.DtaEndTime)&&e.AggTi>i.DtaStartTime),s.sort((e,t)=>t.AggTi-e.AggTi);let r=s[0],o=r.AggDt[r.AggDt.length-1];return t?Object(x.j)(o[e],{unit:M.a.MEDIUM,showUnit:!0})||"-":{weight:o[e],time:r.AggTi}}catch(s){return"-"}}getStatus(){const{aggregatedData:e,scale:t}=this.props;return e.get(t.DevID)?"success":"warning"}getIcon(){const{loading:e}=this.state,{aggregatedData:t,scale:a}=this.props;return e?"fas fa-spin fa-circle-notch":t.get(a.DevID)?"fas fa-cog fa-spin fa-fw":"fas fa-wifi-slash fa-fw"}getTooltipContent(){const{aggregatedData:e,scale:t,t:a}=this.props;let n=e.get(t.DevID);if(!n)return a("noConnection");n.sort((e,t)=>e.AggTi-t.AggTi);let i=n[n.length-1];if(!i)return a("noData");let s=i.AggDt[i.AggDt.length-1];return r.a.createElement("div",null,a("lastUpdate"),":",r.a.createElement("div",null,r.a.createElement("strong",null,p()(s.T).format("DD.MM.YYYY HH:mm"))))}getSubtitle(){const{settlement:e,t:t}=this.props;return e.state===E.a.SHOW_SETTLEMENT?t("deviceRows.pigletScale.noSettlement"):e.state===E.a.SHOW_SEPARATION?t("day",{count:1+p()().startOf("day").diff(p()(e.data.DtaStartTime).startOf("day"),"days")}):void 0}getSettlementWeight(e){try{const{scale:t}=this.props;let a=t.Settings.Insertions.find(t=>t.StartTime===e);return Object(x.j)(a.Weight,{unit:M.a.MEDIUM,showUnit:!0})||"-"}catch(t){return"-"}}getGain(e,t="HM"){try{const{aggregatedData:a,scale:n,settlement:{data:i}}=this.props;let s=(a.get(n.DevID)||[]).slice(0);s=s.filter(e=>!(i.DtaEndTime&&e.AggTi>i.DtaEndTime)&&e.AggTi>i.DtaStartTime),s.sort((e,t)=>t.AggTi-e.AggTi);let r=s[0],o=s[1],c=r.AggDt[r.AggDt.length-1][t],l=r.AggTi,d=o?o.AggDt[o.AggDt.length-1][t]:null,m=o?o.AggTi:null;if(console.log(c,d),console.log(l,m),null===d){d=n.Settings.Insertions.find(t=>t.StartTime===e).Weight,m=e}let h=c-d,u=p()(l).diff(m,"days");return h<0?0:h/u}catch(a){return null}}getGainConverted(e){let t={unit:M.a.MEDIUM,showUnit:!0};return Object(x.j)(e,t)}getAge(e){try{const{scale:t}=this.props;let a=t.Settings.Insertions.find(t=>t.StartTime===e);return p.a.utc().startOf("day").diff(a.BirthTime,"days")}catch(t){return"-"}}getPlannedSellDate(e,t){const{scale:a,t:n}=this.props;if(0===t)return{text:"-",tooltipText:n("deviceRows.pigletScale.plannedSell")};try{let i=a.Settings.Insertions.find(t=>t.StartTime===e).PlannedSellWeight,s=this.getWeight("HM",!1),r=Math.ceil((i-s.weight)/t);return isNaN(r)?{text:"-",tooltipText:n("deviceRows.pigletScale.plannedSell")}:r<0?{text:n("deviceRows.pigletScale.reachedWeight"),tooltipText:n("deviceRows.pigletScale.animalsReached",{weight:Object(x.j)(i,{unit:M.a.MEDIUM,showUnit:!0})})}:{text:p.a.utc(s.time).startOf("day").add(r,"days").format("DD.MM.YYYY"),tooltipText:n("deviceRows.pigletScale.animalsWillReach",{weight:Object(x.j)(i,{unit:M.a.MEDIUM,showUnit:!0}),count:r})}}catch(i){return{text:"-",tooltipText:n("deviceRows.pigletScale.plannedSell")}}}render(){const{scale:e,selected:t,t:a,onRightClick:n,settlement:{state:i,data:s}}=this.props,{collapse:o,chart:d,settlement:m,noInsertionInDevice:h,gainField:u}=this.state,g=[{name:a("deviceRows.pigletScale.composed"),value:"composed"},{name:a("gain"),value:"gain"},{name:a("deviceRows.pigletScale.histogram"),value:"histogram"},{name:a("deviceRows.pigletScale.halfUp"),value:"halfUp"},{name:a("deviceRows.pigletScale.median"),value:"median"},{name:a("deviceRows.pigletScale.normal"),value:"normal"},{name:a("deviceRows.pigletScale.peaks"),value:"peaks"}];let b=this.getName(),w=this.getStatus(),y=this.getIcon(),O=this.getSubtitle(),C=this.getGain(s?s.DtaStartTime:0),S=this.getWeight("HM"),I=this.getPlannedSellDate(s?s.DtaStartTime:0,C),T=this.getWeight("HMS"),j=this.getWeight("HUS"),x=this.getWeight("MAS"),M=this.getWeight("NAS"),k=this.getWeight("PSS"),R=Object(D.isUsingFakeData)(),F=!R&&(i===E.a.SHOW_SETTLEMENT||i===E.a.NO_SHOW||h);return r.a.createElement(c.a,{className:o?"device-item piglet-scale opened":"device-item piglet-scale",showWorking:!0,onContextMenu:t=>n(t,e)},r.a.createElement("div",{className:"device-info",onClick:this.onClick},r.a.createElement("div",{className:"device-main dev-ps ".concat(w)},r.a.createElement("div",{className:"device-main-location",title:b},b),r.a.createElement("div",{className:"device-main-item"},S),r.a.createElement("div",{className:"device-main-item-alternate",title:O},O),r.a.createElement(J.a,null,({windowWidth:e})=>r.a.createElement(Q.a,{tooltipContent:this.getTooltipContent(),placement:e>=$.a.SM?"right":"left",type:w},r.a.createElement("div",{className:"device-main-working"},r.a.createElement("i",{className:y})))),r.a.createElement("div",{onClick:this.onSelect,className:"device-main-checkbox show-on-small-device sm"},r.a.createElement(l.a,{label:"",id:e.DevID,checked:t,readOnly:!0}))),r.a.createElement("div",{className:"device-info-main"},r.a.createElement("div",{className:"device-info-main-second".concat(F?" blur":"")},r.a.createElement("div",{className:"device-info-main-second-name"},e.Number||"-"),r.a.createElement(Z.a,{icon:ae.a,name:a("settlementDate"),value:s?p.a.utc(s.DtaStartTime).format("DD.MM.YYYY"):"-",disabledTooltip:F}),r.a.createElement(Z.a,{icon:te.a,name:a("deviceRows.pigletScale.age"),value:s?this.getAge(s.DtaStartTime):"-",disabledTooltip:F}),r.a.createElement(Z.a,{icon:X.a,name:a("deviceRows.pigletScale.settlementWeight"),value:s?this.getSettlementWeight(s.DtaStartTime):"-",disabledTooltip:F}),r.a.createElement(Z.a,{icon:ee.a,name:a("gain"),value:s?this.getGainConverted(C):"-",disabledTooltip:F}),r.a.createElement(Z.a,{icon:ae.a,name:I.tooltipText,value:I.text,disabledTooltip:F})),r.a.createElement("div",{className:"device-info-main-third".concat(F?" blur":"")},r.a.createElement(Z.a,{icon:me.a,name:a("deviceRows.pigletScale.histogram"),value:S,disabledTooltip:F}),r.a.createElement(Z.a,{icon:ue.a,name:a("deviceRows.pigletScale.halfUp"),value:this.getWeight("HU"),disabledTooltip:F}),r.a.createElement(Z.a,{icon:ge.a,name:a("deviceRows.pigletScale.median"),value:this.getWeight("MA"),disabledTooltip:F}),r.a.createElement(Z.a,{icon:ve.a,name:a("deviceRows.pigletScale.normal"),value:this.getWeight("NA"),disabledTooltip:F}),r.a.createElement(Z.a,{icon:De.a,name:a("deviceRows.pigletScale.peaks"),value:this.getWeight("PS"),disabledTooltip:F})),r.a.createElement("div",{className:"device-info-main-third".concat(F?" blur":"")},!R&&r.a.createElement(Z.a,{icon:he.a,name:a("deviceRows.pigletScale.histogram")+" - SAVGOL",value:T,disabledTooltip:F}),!R&&r.a.createElement(Z.a,{icon:pe.a,name:a("deviceRows.pigletScale.halfUp")+" - SAVGOL",value:j,disabledTooltip:F}),!R&&r.a.createElement(Z.a,{icon:fe.a,name:a("deviceRows.pigletScale.median")+" - SAVGOL",value:x,disabledTooltip:F}),!R&&r.a.createElement(Z.a,{icon:be.a,name:a("deviceRows.pigletScale.normal")+" - SAVGOL",value:M,disabledTooltip:F}),!R&&r.a.createElement(Z.a,{icon:Ee.a,name:a("deviceRows.pigletScale.peaks")+" - SAVGOL",value:k,disabledTooltip:F})),F&&r.a.createElement("div",{className:"device-info-main-not-enough-data"},(i===E.a.SHOW_SETTLEMENT||i===E.a.NO_SHOW)&&a("deviceRows.pigletScale.noSettlement"),h&&a("deviceRows.pigletScale.noInsertionInDevice"))),r.a.createElement("div",{onClick:this.onSelect,className:"device-info-checkbox hide-on-small-device sm"},r.a.createElement(l.a,{label:"",id:e.DevID,checked:t,readOnly:!0}))),r.a.createElement(f.a,{in:o,unmountOnExit:!0,onExited:this.onCollapseExit,mountOnEnter:!0},r.a.createElement("div",{className:"chart-container"},r.a.createElement(v.a,{options:g,value:d,onChange:this.onChartChange,clearButton:!1}),r.a.createElement("div",{className:"device-chart"},"histogram"===d&&r.a.createElement(r.a.Fragment,null,this.createSettlementSelect(a("deviceRows.pigletScale.histogram")),r.a.createElement("div",{className:"chart-main-container"},r.a.createElement(N,{settlement:m,pigletScale:e}))),"halfUp"===d&&r.a.createElement(r.a.Fragment,null,this.createSettlementSelect(a("deviceRows.pigletScale.halfUp")),r.a.createElement("div",{className:"chart-main-container"},r.a.createElement(P,{settlement:m,pigletScale:e}))),"median"===d&&r.a.createElement(r.a.Fragment,null,this.createSettlementSelect(a("deviceRows.pigletScale.median")),r.a.createElement("div",{className:"chart-main-container"},r.a.createElement(V,{settlement:m,pigletScale:e}))),"normal"===d&&r.a.createElement(r.a.Fragment,null,this.createSettlementSelect(a("deviceRows.pigletScale.normal")),r.a.createElement("div",{className:"chart-main-container"},r.a.createElement(K,{settlement:m,pigletScale:e}))),"peaks"===d&&r.a.createElement(r.a.Fragment,null,this.createSettlementSelect(a("deviceRows.pigletScale.peaks")),r.a.createElement("div",{className:"chart-main-container"},r.a.createElement(G,{settlement:m,pigletScale:e}))),"composed"===d&&r.a.createElement(r.a.Fragment,null,this.createSettlementSelect(a("deviceRows.pigletScale.composed")),r.a.createElement("div",{className:"chart-main-container"},r.a.createElement(re,{settlement:m,pigletScale:e}))),"gain"===d&&r.a.createElement(r.a.Fragment,null,this.createGainTypeSelect(a("gain")),r.a.createElement("div",{className:"chart-main-container"},r.a.createElement(de,{pigletScale:e,settlement:m,field:u})))))))}}ye.propTypes={scale:m.a.instanceOf(h.a)};t.a=Object(w.d)(Object(o.connect)((function(e,t){let a=t.scale.getLocation(),n=Object(b.j)(a[0]);return{farm:e.location.farm,aggregatedData:e.aggregatedData.data,aggregatedDataLoading:e.aggregatedData.fetchingMap,settlements:Object(E.d)(e,{CID:n}),settlement:Object(E.c)(e,{CID:n})}})),Object(y.a)())(ye)},gE24:function(e,t,a){"use strict";var n=a("q1tI"),i=a.n(n),s=a("/MKj"),r=a("/kok"),o=a("VfnB"),c=a("zDJl"),l=a("vSUv"),d=a.n(l),m=a("PFMh"),h=a("q17X"),u=a("J2iB"),p=a.n(u),g=a("mwIZ"),f=a.n(g),v=a("17x9"),b=a.n(v),D=a("wd/R"),E=a.n(D),w=a("pxzG"),y=a("t6+f"),O=a("qx5e"),C=a("s506"),S=a("uSQv"),I=a("dxSB"),T=a("2dKy"),j=a("hw2D"),x=a("LCzB"),M=a("e8oE"),k=a("JI6e"),N=a("3Z9Z"),R=a("udB/"),F=a("G7tO"),A=a("ZW/8");class P extends n.Component{constructor(...e){super(...e),this.getData=()=>{const{aggregated:{data:e},date:t}=this.props;return{data:Object(A.g)(e,+t)}}}render(){const{data:e}=this.getData(),{t:t,aggregated:{fetching:a},date:n,index:s}=this.props;let r=Object(h.getScaleUnit)();const o=[{color:"green",dataKey:"weight",name:t("weight"),valueConverter:e=>Object(w.j)(e,{rawValue:!0,acceptNil:!0,unit:r,fixed:r?2:0}),unit:Object(w.l)("weight",r),opacity:.2}];return i.a.createElement(i.a.Fragment,null,i.a.createElement(R.a,{bgInherit:!0,isLoading:a}),i.a.createElement(F.a,{dataDef:o,data:e,Yaxis:{name:t("weight"),domain:[0,"dataMax + 1"]},Xaxis:{name:t("time"),dataKey:"name"},saveAsExcell:"Silo ".concat(s," (").concat(n.format("DD-MM-YYYY"),")"),showDomainInput:!0}))}}P.defaultProps={date:E.a.utc().startOf("day").subtract(1,"days"),height:"100%"},P.propTypes={date:b.a.instanceOf(E.a).isRequired,device:b.a.object.isRequired,index:b.a.number.isRequired},P=Object(s.connect)((function(e,t){const a=Object(M.a)(),n={DevID:t.device.DevID,index:t.index};return function(e,t){return{aggregated:a(e,n)}}}))(P);var L=Object(x.a)()(P);class U extends n.Component{constructor(...e){super(...e),this.getData=()=>{const{start:e,end:t,aggregated:{data:a}}=this.props;return{data:Object(A.h)(a,e,t)}}}render(){const{data:e}=this.getData(),{t:t,end:a,start:n,index:s,aggregated:{fetching:r}}=this.props;let o=Object(h.getScaleUnit)();const c=e=>Object(w.j)(e,{rawValue:!0,unit:o,acceptNil:!0,fixed:o?2:0}),l=[{color:"green",dataKey:"weight",name:t("weight"),valueConverter:c,unit:Object(w.l)("weight",o),opacity:.2}];return i.a.createElement(i.a.Fragment,null,i.a.createElement(R.a,{bgInherit:!0,isLoading:r}),i.a.createElement(F.a,{dataDef:l,data:e,Yaxis:{name:t("weight"),domain:[0,"dataMax + 1"],valueFormatter:c},Xaxis:{name:t("date"),dataKey:"name"},saveAsExcell:"Silo ".concat(s," (").concat(n.format("DD-MM-YYYY"),"-").concat(a.format("DD-MM-YYYY"),")"),showDomainInput:!0}))}}U.defaultProps={height:"100%",start:E.a.utc().startOf("day").subtract(7,"days"),end:E.a.utc().startOf("day")},U.propTypes={colors:b.a.object,connectNulls:b.a.bool,end:b.a.instanceOf(E.a).isRequired,start:b.a.instanceOf(E.a).isRequired,silo:b.a.object.isRequired,index:b.a.number.isRequired,height:b.a.oneOfType([b.a.string,b.a.number])},U=Object(s.connect)((function(e,t){const a=Object(M.a)(),n={DevID:t.device.DevID,index:t.index};return function(e,t){return{aggregated:a(e,n)}}}))(U);var Y=Object(x.a)()(U),V=a("BO/6");function W(){return(W=Object.assign||function(e){for(var t=1;t{this.setState({chart:e})},this.onDurationChange=e=>{console.log(e,"change"),this.setState({duration:e})},this.onDateChange=e=>{let t=E.a.utc(e);this.setDate(t)},this.onLowerDateClick=()=>{let e=this.state.date.clone().subtract(1,"day");this.setDate(e)},this.onAddDateClick=()=>{let e=this.state.date.clone().add(1,"day");this.setDate(e)},this.getOptions=()=>{const{t:e}=this.props;return[{name:e("deviceRows.siloses.siloRow.periodical"),value:"duration"},{name:e("daily"),value:"daily"}]},this.getDurationOptions=()=>{const{t:e}=this.props;return[{name:e("deviceRows.siloses.siloRow.lastXdays",{count:30}),value:this.dates[0]},{name:e("deviceRows.siloses.siloRow.lastWeek"),value:this.dates[1]},{name:e("deviceRows.siloses.siloRow.lastXdays",{count:90}),value:this.dates[2]}]},this.isRangeDate=()=>["duration"].includes(this.state.chart),this.isSingleDate=()=>["daily"].includes(this.state.chart),this.dates=[{start:E.a.utc().startOf("day").subtract(30,"days"),end:E.a.utc().startOf("day")},{start:E.a.utc().startOf("day").subtract(7,"days"),end:E.a.utc().startOf("day")},{start:E.a.utc().startOf("day").subtract(90,"days"),end:E.a.utc().startOf("day")}],this.state={chart:"duration",date:E.a.utc().startOf("day"),duration:this.getDurationOptions()[0].value}}componentDidMount(){const{device:e}=this.props;r.a.sendRequestForAggregatedData(e),this.checkIfHaveInAggregatedData(),this.props.measure()}checkIfHaveInAggregatedData(){const{aggregated:{data:e},dispatch:t,device:a,index:n}=this.props,{date:i,duration:s}=this.state,r=this.isSingleDate()?+i:+s.start,o=this.isSingleDate()?null:+s.end,c=p()(o)?[r]:new Array(Math.abs(E.a.utc(r).diff(E.a.utc(o),"day"))+1).fill(0).map((e,t)=>Math.min(o,r)+t*V.a.DAY);console.log(o,r,c,"DLKDDL");const l=c.length;let d=!0;for(let m=0;me.AggTi===c[m])){d=!1;break}d||(p()(o)?t(Object(I.a)(a,{AggDataTime:r,index:n})):t(Object(I.a)(a,{AggDataTimeFrom:r,AggDataTimeTo:o,index:n})))}setDate(e){e.diff(E.a.utc().startOf("day"),"days")<=0&&this.setState({date:e})}componentDidUpdate(e,t,a){const{chart:n,date:i,duration:s}=this.state;n===t.chart&&i===t.date&&s===t.duration||this.checkIfHaveInAggregatedData()}render(){const{device:e,index:t}=this.props,{chart:a,date:n,duration:s}=this.state,r=this.getOptions(),o=this.getDurationOptions();return i.a.createElement("div",{className:"device-charts"},i.a.createElement(k.a,{xs:12,className:"mt-2"},i.a.createElement(N.a,{className:"device-chart-select"},i.a.createElement(k.a,{xs:12,xl:8,className:"chart-type mb-2"},i.a.createElement(j.a,{value:a,options:r,onChange:this.onChartChange,clearButton:!1})),i.a.createElement(k.a,{xs:12,xl:4,className:"chart-date mb-2"},this.isSingleDate()&&i.a.createElement(i.a.Fragment,null,i.a.createElement(S.a,{icon:i.a.createElement("i",{className:"fas fa-chevron-left"}),onClick:this.onLowerDateClick}),i.a.createElement(T.a,{type:"date",value:this.state.date.format("YYYY-MM-DD"),onChange:this.onDateChange}),i.a.createElement(S.a,{icon:i.a.createElement("i",{className:"fas fa-chevron-right"}),onClick:this.onAddDateClick})),this.isRangeDate()&&i.a.createElement(i.a.Fragment,null,i.a.createElement(j.a,{clearButton:!1,options:o,value:s,onChange:this.onDurationChange}))))),i.a.createElement("div",{className:"device-chart"},"daily"===a&&i.a.createElement(i.a.Fragment,null,i.a.createElement("div",{className:"chart-main-container"},i.a.createElement(L,{device:e,index:t,date:n,showExcelButton:!0}))),"duration"===a&&i.a.createElement(i.a.Fragment,null,i.a.createElement("div",{className:"chart-main-container"},i.a.createElement(Y,W({index:t,device:e},s,{showExcelButton:!0}))))))}}B.propTypes={device:b.a.object.isRequired,id:b.a.string,placements:b.a.array,name:b.a.string},B=Object(O.a)(e=>({roles:[C.c._DEVICE_SILO],devPlcmnts:Object(o.f)(e.device)}))(B),B=Object(s.connect)((function(e,t){const a=Object(M.a)(),n={DevID:t.device.DevID,index:t.index};return function(e){return{aggregated:a(e,n)}}}))(B);var q=Object(x.a)()(B),K=a("thTS"),H=a("99/+"),_=a("wQVC"),z=a("F07D"),G=a("Uip1"),X=a("GSes"),Z=a("VyNe"),J=a("Crab"),Q=a("oF2R"),$=a("Sy8u"),ee=a("H+Jz"),te=a("m6+T"),ae=a("mr+a");function ne(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),a.push.apply(a,n)}return a}function ie(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}class se extends i.a.Component{constructor(...e){super(...e),this.getValues=()=>{const{shadow:e,name:t,t:a,device:n,fetching:i,index:s,forages:r}=this.props,c=this.getErrors(),l=Object(h.getScaleUnit)(),d=Object(w.l)("weight",l),m=(e,t=!0)=>Object(w.j)(e,{unit:l,showUnit:!0,fixed:l,acceptNil:!0,rawValue:!!t}),u=+f()(n,"Siloses[".concat(s,"].Capacity"),0),g=f()(n,"Siloses[".concat(s,"].Forage")),v=r.find(e=>e.SetID===g);return{upperTitle:t,title:m(f()(e,"weights[".concat(s,"].value")),!1),lowerTitle:e?"".concat(a("capacity"),": ").concat(m(u,!1)):"-",number:n.Siloses[s].Number||"-",icon:{errors:c,isLoading:i,isConnected:!!e,dateTime:Object(o.o)(f()(e,"metadata")),isDisabled:!1,isAlerted:!!c.length},params:[{value:u?Math.round(100*f()(e,"weights[".concat(s,"].value"),0)/u):void 0,title:a("forageAmount"),icon:J.a,unit:"%",show:!0},{value:f()(e,"addInfo[".concat(s,"].averageUsage")),title:a("deviceRows.siloses.siloRow.averageUsage"),icon:Q.a,unit:d,valueFormatter:m,show:!0},{value:f()(e,"addInfo[".concat(s,"].daysToEmptySilo")),title:a("deviceRows.siloses.siloRow.supplyLast"),icon:$.a,valueFormatter:e=>e>0?a("Xdays",{count:e}):"-",show:!0},{value:f()(e,"addInfo[".concat(s,"].fillTime")),title:a("deviceRows.siloses.siloRow.latestFillUp"),icon:ee.a,valueFormatter:e=>p()(e)?void 0:E.a.utc(e).local().format("DD.MM.YY"),show:!0,small:!0},{value:f()(e,"configuration.minWeights[".concat(s,"].value")),title:a("deviceRows.siloses.siloRow.minimumAlarm"),icon:y.a,unit:d,valueFormatter:e=>e>0?m(e):void 0},{value:f()(v,"SetData.Name"),title:a("forage"),icon:te.a,color:f()(v,"SetData.Color"),unit:"",small:!0}]}},this.getErrors=()=>{const{t:e,shadow:t,index:a}=this.props,n=Object(h.getScaleUnit)();try{if(t&&t.configuration.minWeights[a].value>t.weights[a].value)return[e("deviceRows.siloses.siloRow.weightBelowMinimum",{amount:(i=t.configuration.minWeights[a].value,Object(w.j)(i,{unit:n,showUnit:!0,fixed:n,acceptNil:!0,rawValue:!1}))})]}catch(s){}var i;return[]},this.icon=({color:e,header:t,icon:a,dateTime:n})=>{const s=this.getErrors();return i.a.createElement(X.a,{tooltipContent:i.a.createElement("div",null,i.a.createElement("div",null,t),!!n&&i.a.createElement("div",null,i.a.createElement("i",{className:"fas fa-sync mr-1"}),i.a.createElement("b",null,E()(n).format("HH:mm:ss DD.MM.YY"))),i.a.createElement("div",null,i.a.createElement("small",null,s.join("\n")))),placement:"left",type:e},i.a.createElement("div",null,i.a.createElement("i",{className:a})))},this.onContextMenu=e=>{const{openMenu:t,device:a}=this.props;return e.stopPropagation(),e.preventDefault(),e.persist(),t(e,a),!1}}componentDidUpdate(e,t,a){e.expanded!==this.props.expanded&&(this.props.expanded||Object(_.i)(this.props.measure))}render(){const{onExpand:e,selected:t,onSelect:a,expanded:n,measure:s,device:r,index:o}=this.props,{upperTitle:c,title:l,lowerTitle:d,params:m,icon:h,number:u}=this.getValues();return i.a.createElement(k.a,{xs:12},i.a.createElement(Z.a,{type:"container",className:"pointer",selected:t},i.a.createElement(G.a,{onClick:a,icon:h,upperTitle:c,title:l,lowerTitle:d,params:m,expanded:n,selected:t,onExpand:e,number:u,showingCallback:s,onContextMenu:this.onContextMenu}),!!n&&i.a.createElement(q,{measure:s,device:r,index:o})))}}se.propTypes={device:b.a.object.isRequired,id:b.a.string,placements:b.a.array,name:b.a.string},(se=Object(s.connect)((function(e,t){const a=Object(K.a)(),n=Object(z.d)(),i=Object(z.c)(),s={type:t.type};return function(e,t){return s.id=t.id,function(e){for(var t=1;t(a.stopPropagation(),e(Object(H.d)(t.type,t.id)),!1),onExpand:()=>e(Object(H.c)(t.type,t.id))}}))(se)).defaultProps={type:"siloses"};var re=Object(x.a)()(se),oe=a("MUrI"),ce=a("yuWL"),le=a("0u5A");class de extends n.Component{constructor(e){super(e),this.messageIDs=[],this.noRowsRenderer=()=>{const{loading:e,data:t,t:a}=this.props;return i.a.createElement(k.a,{xs:12},i.a.createElement(ce.a,{isLoading:e,dataLength:t.length,noDataText:a("deviceRows.siloses.siloRow.silosesNotFound")}))},Object(h.isUsingFakeData)()&&(d.a.restore(),d.a.stub(r.a,"startSendingDeviceState").callsFake(m.b),d.a.stub(r.a,"createAndSendMessageObject").callsFake(m.a),d.a.stub(r.a,"sendRequestForAggregatedData").callsFake(()=>{}))}componentDidMount(){this.startPolling()}startPolling(){r.a.removeFromInterval(this.messageIDs);const{data:e}=this.props,t=Object(o.r)(e.map(e=>e.device));if(t)for(let a of t.values())a[c.d.SCALE].length&&this.messageIDs.push(r.a.startSendingDeviceState(a[c.d.SCALE],void 0,void 0,{keepAlive:!0}))}componentWillUnmount(){r.a.removeFromInterval(this.messageIDs)}componentDidUpdate(e,t,a){const{data:n}=this.props,{data:i}=e;n.length!==i.length&&this.startPolling()}render(){const{data:e,openMenu:t,loading:a}=this.props;return i.a.createElement(oe.a,{forceRerender:a,noRowsRenderer:this.noRowsRenderer,passProps:{openMenu:t},component:()=>re,data:e})}}de=Object(s.connect)((function(e){return{data:Object(le.a)(e),loading:e.dataLoader.loading}}))(de);t.a=Object(x.a)()(de)},kAUZ:function(e,t,a){"use strict";var n,i=a("J2iB"),s=a.n(i),r=a("lSCD"),o=a.n(r),c=a("lFKM"),l=a.n(c),d=a("Y+p1"),m=a.n(d),h=a("sEfC"),u=a.n(h),p=a("q1tI"),g=a.n(p),f=a("17x9"),v=a.n(f),b=a("/MKj"),D=a("thTS"),E=a("pLLp"),w=a("sPOc"),y=a("CuyV"),O=a("S8cm"),C=a("IcrQ"),S=a("B02h"),I=a("Uz7D"),T=a("71tM"),j=a("pMvP"),x=a("rOzv"),M=a("vYJ8"),k=a("hw2D"),N=a("mwIZ"),R=a.n(N),F=a("44Ds"),A=a.n(F),P=a("wd/R"),L=a.n(P),U=a("G7tO"),Y=a("udB/"),V=a("Zayz"),W=a("pxzG"),B=a("eASP"),q=a("LCzB");let K=Object(b.connect)(e=>({aggregatedData:e.aggregatedData.data,fetchingMap:e.aggregatedData.fetchingMap}))(n=class extends p.Component{constructor(...e){super(...e),this.getTickUsage=(e=[],t,a=30,n=0)=>{const i={hasData:!1,value:0,_startIndex:0},s=t*a,r=(t+1)*a;for(let o=n;o=s&&t{const a=[],n=L()().startOf("day");let i;const r=t.find(t=>t.AggTi===+e);if(r)for(let o=0;o<48;o++){const e=this.getTickUsage(r.AggDt,o,30,i);i=e._startIndex;const t=R()(a[o-1],"meter",R()(r.AggDt[0],"MR",0)),c=e.hasData?e.value:t;console.log(o,e,t,c),a[o]={time:+n.clone().add(30*o,"minute"),name:n.clone().add(30*o,"minute").format("HH:mm"),meter:c,consumption:s()(c)||s()(t)?null:c-t}}return a}),this.formatter=e=>l()(e)?Object(W.h)(e,{showUnit:!1,unit:B.a.BIG,rawValue:!0,fixed:2}):null}render(){const{fetchingMap:e,device:t,aggregatedData:a,date:n,t:i}=this.props,s=this.getData({data:a.get(t.DevID),date:n}),r=!!e.get(t.DevID)&&!s.length,o=[{color:"blue",dataKey:"consumption",name:i("charts.waterHourlyChart.consumption"),valueConverter:this.formatter,unit:Object(W.l)("volume",B.a.BIG),opacity:.2}];return g.a.createElement(g.a.Fragment,null,g.a.createElement(Y.a,{isLoading:r}),g.a.createElement(U.a,{type:"Bar",dataDef:o,data:s,Yaxis:{name:i("charts.waterHourlyChart.consumption")},Xaxis:{name:i("time"),dataKey:"name"},saveAsExcell:"water"}))}})||n;K.defaultProps={colors:{water:"#4a9bd4"},connectNulls:!0,date:+L()().utc(),showExcelButton:!1,excelPortalContainerID:"chart-controls"},K.propTypes={colors:v.a.object,connectNulls:v.a.bool,date:v.a.number.isRequired,device:v.a.object.isRequired,showExcelButton:v.a.bool,excelPortalContainerID:v.a.string};var H,_=Object(q.a)()(K),z=a("UZWR"),G=a("VfnB"),X=a("uSQv"),Z=a("2dKy"),J=a("dxSB");let Q=Object(b.connect)(e=>({aggregatedData:e.aggregatedData.data,fetchingMap:e.aggregatedData.fetchingMap}))(H=class extends p.Component{constructor(...e){super(...e),this.getUsage=(e=[])=>e.length>1?e[e.length-1].MR-e[0].MR:null,this.getData=A()(({dateStart:e,dateEnd:t,data:a=[]})=>{const n=[],i=L.a.utc(+e).startOf("day"),s=Math.abs(L.a.utc(e).diff(L.a.utc(t),"days"))+1;for(let r=0;re.AggTi===+i.clone().add(r,"days")),"AggDt"))};return n}),this.formatter=e=>l()(e)?Object(W.h)(e,{showUnit:!1,unit:B.a.BIG,rawValue:!0,fixed:1}):null}render(){const{fetchingMap:e,device:t,aggregatedData:a,dateStart:n,dateEnd:i,t:s}=this.props,r=l()(n)&&l()(i),o=r?this.getData({data:a.get(t.DevID),dateStart:n,dateEnd:i}):[],c=!!r&&(!!e.get(t.DevID)&&!o.length),d=[{color:"blue",dataKey:"consumption",name:s("charts.waterHourlyChart.consumption"),valueConverter:this.formatter,unit:Object(W.l)("volume",B.a.BIG),opacity:.2}];return g.a.createElement(g.a.Fragment,null,g.a.createElement(Y.a,{isLoading:c}),g.a.createElement(U.a,{type:"Bar",dataDef:d,data:o,Yaxis:{name:s("charts.waterHourlyChart.consumption")},Xaxis:{name:s("day"),dataKey:"name"},saveAsExcell:"water"}))}})||H;Q.defaultProps={colors:{water:"#4a9bd4"},connectNulls:!0,showExcelButton:!1,excelPortalContainerID:"chart-controls"},Q.propTypes={colors:v.a.object,connectNulls:v.a.bool,dateEnd:v.a.number.isRequired,dateStart:v.a.number.isRequired,device:v.a.object.isRequired,showExcelButton:v.a.bool,excelPortalContainerID:v.a.string};var $=Object(q.a)()(Q),ee=a("0MVo"),te=a("9wQ1"),ae=a("K/Fu"),ne=a("n7pt"),ie=a("XzT5");function se(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),a.push.apply(a,n)}return a}function re(e){for(var t=1;t{const{aggData:a=new Map,device:n,dispatch:i}=this.props,s=t?+e:+L.a.utc(e).subtract(7,"days").startOf("day"),r=t?+t:+L.a.utc().startOf("day"),o=Math.abs(L()(s).diff(L()(r),"days"))+1;(a.has(n.DevID)?a.get(n.DevID).filter(e=>e.AggTi>=s&&e.AggTi<=r):[]).length!==o&&i(Object(J.a)(n,{AggDataTimeFrom:s,AggDataTimeTo:r}))},250),this.getOptions=()=>[{name:this.props.t("hourly"),value:"hourly"},{name:this.props.t("daily"),value:"daily"}],this.initialFetch=()=>{const{settlementList:e}=this.props,t={start:e.length?+L()(e[e.length-1].DtaStartTime).utc().startOf("day"):+L()().utc().startOf("day").subtract(7,"days"),end:+L()().utc().startOf("day")};this.fetchData(re({},t))},this.dataFetcher=(e={})=>{const{chart:t,date:a,dateStart:n,dateEnd:i}=this.state;["hourly"].includes(t)?a&&!m()(e.date,a)&&this.fetchData({start:a}):["daily"].includes(t)&&(!n||!i||m()(e.dateStart,n)&&m()(e.dateEnd,i)||this.fetchData({start:n,end:i}))},this.getErrors=({shadow:e={}})=>{const t=e.errors||[],{t:a}=this.props;return e.flowValueAlert&&t.push(6001),e.flowTimeAlert&&t.push(6002),t.map(e=>a("notificationsCenter.errorCodes.".concat(e))||e)},this.flowValueFormatter=(e,t=0)=>{const{t:a}=this.props;return l()(e)?a("deviceRows.waterFlowMeter.waterFlowMeterRow.usageXmins",{amount1:Object(W.h)(e/6,{showUnit:!0,unit:B.a.MEDIUM,fixed:t}),amount2:10}):"-"},this.consumptionValueFormatter=(e,t=0,a="{1}")=>l()(e)?Object(ee.d)(a,Object(W.h)(e,{showUnit:!0,unit:B.a.BIG,fixed:t}),1):"-",this.getValues=({aggData:e,t:t,settlementList:a,shadow:n={},fetching:i,fetched:s,device:{DevID:r,Settings:{FlowValueAlertLimit:o}}})=>{const c=this.getErrors({shadow:n}),d={start:a.length?+L()(a[a.length-1].DtaStartTime).utc().startOf("day"):+L()().utc().startOf("day").subtract(7,"days"),end:a.length&&l()(a[a.length-1].DtaEndTime)?+L()(a[a.length-1].DtaEndTime).utc().startOf("day"):void 0},m=Object(ae.a)({aggData:e.get(r),shadow:n,range:d});return console.log("options ",JSON.parse(JSON.stringify({range:d,shadow:n,aggValues:m,aggData:e.get(r),settlementList:a}))),{errors:c,currentFlow:this.flowValueFormatter(n.waterFlow),averageDailyFlow:ie.a.t("deviceRows.waterFlowMeter.waterFlowMeterRow.usageXday",{count:Object(W.h)(m.averageDailyFlow||0,{unit:B.a.BIG,showUnit:!0,fixed:1})}),dailyConsumption:this.consumptionValueFormatter(m.dailyConsumption,1),settlementConsumption:this.consumptionValueFormatter(m.settlementConsumption,1),maxAlarm:o?this.flowValueFormatter(o):t("inactive"),totalConsumption:l()(n.waterConsumption)?Object(W.h)(n.waterConsumption,{showUnit:!0,unit:B.a.BIG,fixed:1}):"-",isAlerted:!!c.length,isConnected:!!s,isLoading:!!i,dateTime:Object(G.o)(n.metadata)}},this.handleSelect=e=>{e.stopPropagation(),e.preventDefault();const{device:t,onSelect:a}=this.props;o()(a)&&a(t)},this.handleChartChange=e=>{this.setState({chart:e})},this.handleCollapseToggle=()=>{this.setState(e=>({collapse:!e.collapse}))},this.getName=()=>{const{name:e,device:{Address:t,Alias:a,Name:n,Interface:i},showAlias:r}=this.props;return r&&a?a:e||(s()(t)?n:"".concat(t,"/0x").concat(t.toString(16)," ").concat(Object(G.n)(i)))},this.getSubtitle=()=>{const{CID:e,settlement:t,t:a}=this.props;let n=ne.a.getLocationByID(e);return n&&n.BgID?"-":s()(e)?a("noChamber"):t.state===z.a.NO_SHOW?"-":t.state===z.a.SHOW_SETTLEMENT?a("waitingForSettlement"):t.state===z.a.SHOW_SEPARATION?ie.a.t("day",{count:1+L()().startOf("day").diff(L()(t.data.DtaStartTime).startOf("day"),"days")}):void 0},this.handleSettlementChange=(e={})=>{this.setState(re({},e))},this.handleDayChange=e=>{if(e){const t=L.a.utc(e,L.a.HTML5_FMT.DATETIME_LOCAL).startOf("day");t.isBefore(L.a.utc())&&this.setState({date:t})}},this.renderDaySelect=e=>{const{date:t}=this.state,a=L.a.utc(t).clone().add(1,"day").format(L.a.HTML5_FMT.DATETIME_LOCAL),n=L.a.utc(t).clone().subtract(1,"day").format(L.a.HTML5_FMT.DATETIME_LOCAL);return g.a.createElement("div",{className:"chart-controls"},g.a.createElement("h4",null,e),g.a.createElement("div",{className:"chart-controls-container"},g.a.createElement("div",{className:"chart-controls-date"},g.a.createElement(X.a,{icon:g.a.createElement("i",{className:"fas fa-chevron-left"}),onClick:()=>this.handleDayChange(n)}),g.a.createElement(Z.a,{type:"date",value:L.a.utc(t).format("YYYY-MM-DD"),onChange:this.handleDayChange}),g.a.createElement(X.a,{icon:g.a.createElement("i",{className:"fas fa-chevron-right"}),onClick:()=>this.handleDayChange(a)}))))},this.settlementOptions=(e=this.props)=>{const{settlementList:t}=e;return t.map((e,t)=>({name:e.DtaEndTime?"".concat(L.a.utc(e.DtaStartTime).format("DD.MM.YYYY")," - ").concat(L.a.utc(e.DtaEndTime).format("DD.MM.YYYY")):"".concat(L.a.utc(e.DtaStartTime).format("DD.MM.YYYY")," - ..."),value:{dateStart:+L()(e.DtaStartTime).utc().startOf("day"),dateEnd:+L()(e.DtaEndTime).utc().startOf("day")}}))},this.renderSettlementSelect=e=>{const{dateStart:t,dateEnd:a}=this.state,n=this.settlementOptions();return g.a.createElement("div",{className:"chart-controls"},g.a.createElement("h4",null,e),g.a.createElement("div",{className:"chart-controls-container"},g.a.createElement(k.a,{value:{dateStart:t,dateEnd:a},options:n,onChange:this.handleSettlementChange})))};const t=this.settlementOptions();this.state={chart:"hourly",collapse:!1,date:+L()().utc().startOf("day"),dateStart:t.length?+L.a.utc(t[t.length-1].value.dateStart).startOf("day"):void 0,dateEnd:t.length?+L.a.utc(t[t.length-1].value.dateEnd).startOf("day"):void 0}}componentDidMount(){this.initialFetch()}componentDidUpdate(e,t,a){this.dataFetcher(t);const n=this.settlementOptions(this.props),i=this.settlementOptions(e);n.length!==i.length&&(this.initialFetch(),this.setState({dateStart:n.length?+L.a.utc(n[n.length-1].value.dateStart).startOf("day"):void 0,dateEnd:n.length?+L.a.utc(n[n.length-1].value.dateEnd).startOf("day"):void 0}))}render(){const{fetched:e,t:t,device:a,device:{DevID:n,Number:i},selected:s}=this.props,{currentFlow:r,settlementConsumption:o,dateTime:c,errors:l,isConnected:d,isLoading:m,isAlerted:h,averageDailyFlow:u,dailyConsumption:p,maxAlarm:f,totalConsumption:v}=this.getValues(this.props),{chart:b,collapse:D,date:E,dateStart:N,dateEnd:R}=this.state,F=this.getOptions(),A=this.getName(),P=this.getSubtitle();return g.a.createElement(w.a,{className:D?"device-item opened":"device-item",showWorking:!0,isError:!e},g.a.createElement("div",{className:"device-info",onClick:this.handleCollapseToggle},g.a.createElement(te.a,{dateTime:c,isConnected:d,isAlerted:h,isLoading:m},({icon:e,color:t,header:a})=>g.a.createElement("div",{className:"device-main dev-cl ".concat(t)},g.a.createElement("div",{className:"device-main-location",title:A},A),g.a.createElement("div",{className:"device-main-item"},o),g.a.createElement("div",{className:"device-main-item-alternate",title:P},P),g.a.createElement(y.a,{tooltipContent:g.a.createElement("div",null,g.a.createElement("b",null,a),!!c&&g.a.createElement("div",null,g.a.createElement("i",{className:"fas fa-sync mr-1"}),g.a.createElement("b",null,L()(c).format("DD.MM.YY HH:mm"))),g.a.createElement("div",null,l.join(", "))),placement:"auto",type:t},g.a.createElement("div",{className:"device-main-working"},g.a.createElement("i",{className:e}))),g.a.createElement("div",{onClick:this.handleSelect,className:"device-main-checkbox show-on-small-device sm"},g.a.createElement(O.a,{label:"",id:n,readOnly:!0,checked:s})))),g.a.createElement("div",{className:"device-info-main"},g.a.createElement("div",{className:"device-info-main-second"},g.a.createElement("div",{className:"device-info-main-second-name"},i||"-"),g.a.createElement(C.a,{icon:x.a,name:t("deviceRows.waterFlowMeter.waterFlowMeterRow.currentFlow"),value:r}),g.a.createElement(C.a,{icon:S.a,name:t("deviceRows.waterFlowMeter.waterFlowMeterRow.averageFlowPerDay"),value:u}),g.a.createElement(C.a,{icon:I.a,name:t("deviceRows.waterFlowMeter.waterFlowMeterRow.waterConsumedToday"),value:p}),g.a.createElement(C.a,{icon:j.a,name:t("deviceRows.waterFlowMeter.waterFlowMeterRow.maxAlarmFlow"),value:f}),g.a.createElement(C.a,{icon:T.a,name:t("currentMeterState"),value:v}))),g.a.createElement("div",{onClick:this.handleSelect,className:"device-info-checkbox hide-on-small-device sm"},g.a.createElement(O.a,{label:"",id:n,readOnly:!0,checked:s}))),g.a.createElement(M.a,{in:D,unmountOnExit:!0,onEntered:this.dataFetcher},g.a.createElement("div",{className:"chart-container"},g.a.createElement(k.a,{value:b,options:F,onChange:this.handleChartChange,clearButton:!1}),g.a.createElement("div",{className:"device-chart"},"hourly"===b&&g.a.createElement(g.a.Fragment,null,this.renderDaySelect(t("hourly")),g.a.createElement("div",{className:"chart-main-container"},g.a.createElement(_,{device:a,date:E,showExcelButton:!0}))),"daily"===b&&g.a.createElement(g.a.Fragment,null,this.renderSettlementSelect(t("daily")),g.a.createElement("div",{className:"chart-main-container"},g.a.createElement($,{device:a,dateStart:N,dateEnd:R,showExcelButton:!0})))))))}}ce.propTypes={device:v.a.instanceOf(E.a).isRequired},ce=Object(b.connect)((function(){const e=Object(D.a)();return function(t,a){const{shadow:n,fetching:i,fetched:s}=e(t,a.device);return{shadow:n,fetching:i,fetched:s,aggData:t.aggregatedData.data,settlementList:Object(z.d)(t,{CID:a.CID}),settlement:Object(z.c)(t,{CID:a.CID})}}}))(ce);t.a=Object(q.a)()(ce)},lrF6:function(e,t,a){},mxqY:function(e,t,a){"use strict";a.d(t,"e",(function(){return S})),a.d(t,"d",(function(){return I})),a.d(t,"b",(function(){return T})),a.d(t,"a",(function(){return j})),a.d(t,"c",(function(){return x}));var n=a("mwIZ"),i=a.n(n),s=a("q1tI"),r=a.n(s),o=a("6/k7"),c=a("42VQ"),l=a("0MVo"),d=a("B6RA"),m=a("r3a2"),h=a("qzmO"),u=a("VfnB"),p=a("IBmF"),g=a("krkt"),f=a("A5yn"),v=a("9PNC"),b=a("n7pt"),D=a("kCmh"),E=a("zDJl");function w(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),a.push.apply(a,n)}return a}function y(e){for(var t=1;t{Object(m.c)(t.DevID,t.outputs.map(t=>({number:t.number,lock:!!e})))}),n.individualNRF.devices.length&&Object(h.u)(n.individualNRF.devices,e)}function I({workType:e=o.g.SCHEDULE},t,{receivers:a}){const n=e=>{try{const{maxOneDose:t,initDose:a,timeOrImpulse:n,optButt:i=0}=e.Settings[p.g.SET_WORK_TYPE];return{maxOneDose:t,initDose:a,timeOrImpulse:n,optButt:i}}catch(t){return{}}};for(let i of a.values())if(i.individualNRF.devices.length){let t=new Map;for(let a of i.individualNRF.devices){const i=Object(u.p)(a),s=i?i.DevID:void 0;let r=t.get(s)||{devIds:[],setting:y({},n(i),{workType:e})};r.devIds.push(a),t.set(s,r)}for(let[e,a]of t.entries())console.log("sending -> ",e,a),Object(h.C)(a.devIds,a.setting)}}const T=({status:e=!1,feedingType:t,receivers:a,selectedNodes:n,show:i,t:s,onConfirmed:r=(()=>{})})=>{[o.f.INDIVIDUAL].includes(t)&&i(c.a,{title:s(e?"deviceRows.feeding.dispenserButtons.confirmLock":"deviceRows.feeding.dispenserButtons.confirmUnlock"),text:Object(l.d)(s(e?"deviceRows.feeding.dispenserButtons.confirmLockText":"deviceRows.feeding.dispenserButtons.confirmUnlockText"),n.map(e=>e.name).join(", ")),confirmText:s("yes"),children:C(n.map(e=>e.name)),onConfirmed:t=>{S({status:e},0,{receivers:a}),t.handleHide(),r()}})},j=({feedingType:e,receivers:t,selectedNodes:a=[],chamberID:n,show:s,t:r,onConfirmed:l=(()=>{})})=>{o.f.GROUP===e&&s(c.a,{title:r("deviceRows.feeding.dispenserButtons.confirmDelete"),text:r("deviceRows.feeding.dispenserButtons.confirmDeleteText"),confirmText:r("yes"),onConfirmed:s=>{!function(e,t,{receivers:a,selectedNodes:n,feedingType:s,chamberID:r}){if(s===o.f.GROUP){const e=n.map(e=>({RFID:e.id,AnmID:e.animal?e.animal.AnmID:void 0,removed:!0,PlcmntID:r}));for(let n of a.keys())Object(h.l)(n,e,{onSuccess:()=>{const a=new Map,n=[],s=b.a.getTreeByLocationID(r),o=i()(s,"sector.SID",i()(d.default.getState(),"location.farm")),c={};e.forEach(e=>{c[e.RFID]=null,e.AnmID&&n.push({AnmID:e.AnmID,transferTo:o,DevIDsNewPlcmnt:[],EvTime:+new Date,DevIDsOldPlcmnt:D.a.getDevicesInPlcmntID(r,{showDevicesInChildren:!1}).filter(e=>[E.d.DISPENSER_NRF,E.d.DISPENSER].includes(e.DevType)).map(e=>({DevID:e.DevID,GwID:e.GatewayID}))})}),a.set(r,c),console.error(a),t(Object(f.m)(a)),n.length&&Object(v.a)(n).catch(e=>{console.error(e),Object(v.b)()})}})}}(0,d.default.dispatch,{receivers:t,selectedNodes:a,feedingType:e,chamberID:n}),s.handleHide(),l()}})},x=({feedingType:e,receivers:t,selectedNodes:a,show:n,t:i,onConfirmed:s=(()=>{})})=>{e===o.f.INDIVIDUAL&&n(c.a,{title:i("deviceRows.feeding.dispenserButtons.confirmDisable"),text:i("deviceRows.feeding.dispenserButtons.confirmDisableText"),children:C(a.map(e=>e.name)),confirmText:i("yes"),onConfirmed:e=>{!function(e,t,{receivers:a}){for(let[n,i]of a.entries()){const e=[];i.individualDTM.length&&i.individualDTM.forEach(t=>{t.outputs.forEach(t=>{e.push(y({},t,{feeding:{curveNr:0,number:t.number}}))})}),i.individualNRF.animals.length&&i.individualNRF.animals.forEach(t=>{e.push(y({},t,{feeding:{curveNr:0}}))}),e.length&&Object(h.l)(n,e)}}(0,0,{receivers:t}),e.handleHide(),s()}})}},nzcg:function(e,t,a){},rIlU:function(e,t,a){"use strict";var n=a("J2iB"),i=a.n(n),s=a("lSCD"),r=a.n(s),o=a("lFKM"),c=a.n(o),l=a("mwIZ"),d=a.n(l),m=a("q1tI"),h=a.n(m),u=a("17x9"),p=a.n(u),g=a("/MKj"),f=a("thTS"),v=a("sPOc"),b=a("CuyV"),D=a("S8cm"),E=a("IcrQ"),w=a("iINr"),y=a("9App"),O=a("YOFI"),C=a("Xyqo"),S=a("MyHe"),I=a("BvfJ"),T=a("VfnB"),j=a("wd/R"),x=a.n(j),M=a("9wQ1"),k=a("LCzB"),N=a("ZXZZ"),R=a("zDJl");class F extends h.a.Component{constructor(...e){super(...e),this.getErrors=({shadow:e={}})=>{const t=e.errors||[],{t:a}=this.props;return d()(e,"currentStatus.chainAlert")&&t.push(7001),d()(e,"currentStatus.siloAlert")&&t.push(7002),d()(e,"currentStatus.sensorChangeAlert")&&t.push(7003),t.map(e=>a("notificationsCenter.errorCodes.".concat(e))||e)},this.getWorkTypeName=e=>{const{t:t}=this.props;switch(e){case R.c.AUTOMATIC:return t("deviceRows.chainFeeding.chainFeedingRow.workTypes.automatic");case R.c.MANUAL:return t("deviceRows.chainFeeding.chainFeedingRow.workTypes.manual");case R.c.INACTIVE:return t("deviceRows.chainFeeding.chainFeedingRow.workTypes.inactive");case R.c.SCHEDULE:return t("schedule");default:return"-"}},this.getValues=({shadow:e={},device:t,fetching:a,fetched:n,t:i})=>{const s=this.getErrors({shadow:e});let r="-",o="-";if(n){d()(e,"workType.workType")===R.c.SCHEDULE&&(r=d()(e,"schedule",[]).map(e=>x()(e.start).format("HH:mm")).join("/"));let a=d()(e,"workType.sensorID");c()(a)&&(o=d()(t,"Settings.Aliases[".concat(a,"]"))?d()(t,"Settings.Aliases[".concat(a,"]")):i("deviceRows.chainFeeding.chainFeedingRow.sensor",{number:a+1}))}return{errors:s,siloStatus:n?!!d()(e,"currentStatus.sensorSilo"):null,chainStatus:n?!!d()(e,"currentStatus.sensorChain"):null,dispenserStatus:n?!!d()(e,"currentStatus.sensorFeeder"):null,lastSensor:o,delay:n?"".concat(d()(e,"workType.excessWorkTime")/6e4).concat(i("deviceRows.chainFeeding.chainFeedingRow.minute")):"-",isAlerted:!!s.length,isConnected:!!n,isLoading:!!a,schedule:r,running:n?i("deviceRows.chainFeeding.chainFeedingRow.".concat(d()(e,"isRunning")?"running":"stopped")):"-",workType:n?d()(e,"workType.workType"):null,dateTime:Object(T.o)(e.metadata)}},this.handleSelect=e=>{e.stopPropagation(),e.preventDefault();const{device:t,onSelect:a}=this.props;r()(a)&&a(t)},this.getName=()=>{const{name:e,device:{Address:t,Alias:a,Name:n,Interface:s},showAlias:r}=this.props;return r&&a?a:e||(i()(t)?n:"".concat(t,"/0x").concat(t.toString(16)," ").concat(Object(T.n)(s)))},this.getIcon=e=>i()(e)?"-":h.a.createElement("i",{className:e?"fas fa-check":"fas fa-times"}),this.onContextMenu=e=>(this.props.onMenuOpen(e,this.props.device),!1)}render(){const{fetched:e,t:t,device:{DevID:a,Number:n},selected:i}=this.props,{running:s,delay:r,workType:o,lastSensor:c,schedule:l,chainStatus:d,siloStatus:m,dispenserStatus:u,dateTime:p,errors:g,isConnected:f,isLoading:T,isAlerted:j}=this.getValues(this.props),k=this.getName();return h.a.createElement(v.a,{className:"device-item",onContextMenu:this.onContextMenu,showWorking:!0,isError:!e},h.a.createElement("div",{className:"device-info"},h.a.createElement(M.a,{dateTime:p,isConnected:f,isAlerted:j,isLoading:T},({icon:e,color:t,header:n})=>h.a.createElement("div",{className:"device-main dev-cl ".concat(t)},h.a.createElement("div",{className:"device-main-location",title:k},k),h.a.createElement("div",{className:"device-main-item"},this.getWorkTypeName(o)),h.a.createElement("div",{className:"device-main-item-alternate",title:s},s),h.a.createElement(b.a,{tooltipContent:h.a.createElement("div",null,h.a.createElement("b",null,n),!!p&&h.a.createElement("div",null,h.a.createElement("i",{className:"fas fa-sync mr-1"}),h.a.createElement("b",null,x()(p).format("DD.MM.YY HH:mm"))),h.a.createElement("div",null,g.join(", "))),placement:"auto",type:t},h.a.createElement("div",{className:"device-main-working"},h.a.createElement("i",{className:e}))),h.a.createElement("div",{onClick:this.handleSelect,className:"device-main-checkbox show-on-small-device sm"},h.a.createElement(D.a,{label:"",id:a,readOnly:!0,checked:i})))),h.a.createElement("div",{className:"device-info-main"},h.a.createElement("div",{className:"device-info-main-second"},h.a.createElement("div",{className:"device-info-main-second-name"},n||"-"),h.a.createElement(E.a,{icon:w.a,name:t("deviceRows.chainFeeding.chainFeedingRow.siloStatus"),value:this.getIcon(m)}),h.a.createElement(E.a,{icon:y.a,name:t("deviceRows.chainFeeding.chainFeedingRow.chainStatus"),value:this.getIcon(d)}),h.a.createElement(E.a,{icon:O.a,name:t("deviceRows.chainFeeding.chainFeedingRow.dispenserStatus"),value:this.getIcon(u)}),h.a.createElement(E.a,{icon:I.a,name:t("deviceRows.chainFeeding.chainFeedingRow.delay"),value:r}),h.a.createElement(E.a,{icon:C.a,name:t("deviceRows.chainFeeding.chainFeedingRow.lastSensor"),value:c}),h.a.createElement(E.a,{icon:S.a,name:t("deviceRows.chainFeeding.chainFeedingRow.schedule"),value:l}))),h.a.createElement("div",{onClick:this.handleSelect,className:"device-info-checkbox hide-on-small-device sm"},h.a.createElement(D.a,{label:"",id:a,readOnly:!0,checked:i}))))}}F.propTypes={device:p.a.instanceOf(N.a).isRequired},F=Object(g.connect)((function(){const e=Object(f.a)();return function(t,a){const{shadow:n,fetching:i,fetched:s}=e(t,a.device);return{shadow:n,fetching:i,fetched:s}}}))(F),t.a=Object(k.a)()(F)},sl4t:function(e,t,a){},wkDu:function(e,t,a){},yWPN:function(e,t,a){"use strict";var n,i=a("J2iB"),s=a.n(i),r=a("lSCD"),o=a.n(r),c=a("lFKM"),l=a.n(c),d=a("Y+p1"),m=a.n(d),h=a("sEfC"),u=a.n(h),p=a("q1tI"),g=a.n(p),f=a("17x9"),v=a.n(f),b=a("/MKj"),D=a("thTS"),E=a("pLLp"),w=a("sPOc"),y=a("CuyV"),O=a("S8cm"),C=a("IcrQ"),S=a("B02h"),I=a("Uz7D"),T=a("ZVcB"),j=a("yf5f"),x=a("BoWw"),M=a("voqg"),k=a("vYJ8"),N=a("hw2D"),R=a("UZWR"),F=a("VfnB"),A=a("wd/R"),P=a.n(A),L=a("uSQv"),U=a("2dKy"),Y=a("dxSB"),V=a("0MVo"),W=a("9wQ1"),B=a("mwIZ"),q=a.n(B),K=a("44Ds"),H=a.n(K),_=a("G7tO"),z=a("udB/"),G=a("Zayz"),X=a("pxzG"),Z=a("eASP"),J=a("LCzB");let Q=Object(b.connect)(e=>({aggregatedData:e.aggregatedData.data,fetchingMap:e.aggregatedData.fetchingMap}))(n=class extends p.Component{constructor(...e){super(...e),this.getTickUsage=(e=[],t,a=30,n=0)=>{const i={hasData:!1,value:0,_startIndex:0},s=t*a,r=(t+1)*a;for(let o=n;o=s&&t{const a=[],n=P()().startOf("day");let i;const r=t.find(t=>t.AggTi===+e);if(r)for(let o=0;o<48;o++){const e=this.getTickUsage(r.AggDt,o,30,i);i=e._startIndex;const t=q()(a[o-1],"meter",q()(r.AggDt[0],"MR",0)),c=e.hasData?e.value:t;a[o]={time:+n.clone().add(30*o,"minute"),name:n.clone().add(30*o,"minute").format("HH:mm"),meter:c,consumption:s()(c)||s()(t)?null:c-t}}return a}),this.formatter=e=>l()(e)?Object(X.b)(e,{showUnit:!1,unit:Z.a.MEDIUM,rawValue:!0,fixed:2}):null}render(){const{fetchingMap:e,device:t,aggregatedData:a,date:n,t:i}=this.props,s=this.getData({data:a.get(t.DevID),date:n}),r=!!e.get(t.DevID)&&!s.length,o=[{color:"blue",dataKey:"consumption",name:i("energyConsumption"),valueConverter:this.formatter,unit:Object(X.l)("energy",Z.a.MEDIUM),opacity:.2}];return g.a.createElement(g.a.Fragment,null,g.a.createElement(z.a,{isLoading:r}),g.a.createElement(_.a,{type:"Bar",dataDef:o,data:s,Yaxis:{name:i("energyConsumption")},Xaxis:{name:i("time"),dataKey:"name"},saveAsExcell:"water"}))}})||n;Q.defaultProps={colors:{water:"#4a9bd4"},connectNulls:!0,date:+P()().utc().startOf("day"),showExcelButton:!1,excelPortalContainerID:"chart-controls"},Q.propTypes={colors:v.a.object,connectNulls:v.a.bool,date:v.a.number.isRequired,device:v.a.object.isRequired,showExcelButton:v.a.bool,excelPortalContainerID:v.a.string};var $,ee=Object(J.a)()(Q);let te=Object(b.connect)(e=>({aggregatedData:e.aggregatedData.data,fetchingMap:e.aggregatedData.fetchingMap}))($=class extends p.Component{constructor(...e){super(...e),this.getUsage=(e=[])=>e.length>1?e[e.length-1].MR-e[0].MR:null,this.getData=H()(({dateStart:e,dateEnd:t,data:a=[]})=>{const n=[],i=P.a.utc(+e).startOf("day"),s=Math.abs(P.a.utc(e).diff(P.a.utc(t),"days"))+1;for(let r=0;re.AggTi===+i.clone().add(r,"days")),"AggDt"))};return n}),this.formatter=e=>l()(e)?Object(X.b)(e,{showUnit:!1,unit:Z.a.MEDIUM,rawValue:!0,fixed:1}):null}render(){const{fetchingMap:e,device:t,aggregatedData:a,dateStart:n,dateEnd:i,t:s}=this.props,r=l()(n)&&l()(i),o=r?this.getData({data:a.get(t.DevID),dateStart:n,dateEnd:i}):[],c=!!r&&(!!e.get(t.DevID)&&!o.length),d=[{color:"blue",dataKey:"consumption",name:s("energyConsumption"),valueConverter:this.formatter,unit:Object(X.l)("energy",Z.a.MEDIUM),opacity:.2}];return g.a.createElement(g.a.Fragment,null,g.a.createElement(z.a,{isLoading:c}),g.a.createElement(_.a,{type:"Bar",dataDef:d,data:o,Yaxis:{name:s("energyConsumption")},Xaxis:{name:s("day"),dataKey:"name"},saveAsExcell:"electricity"}))}})||$;te.defaultProps={colors:{water:"#4a9bd4"},connectNulls:!0,showExcelButton:!1,excelPortalContainerID:"chart-controls"},te.propTypes={colors:v.a.object,connectNulls:v.a.bool,dateEnd:v.a.number.isRequired,dateStart:v.a.number.isRequired,device:v.a.object.isRequired,showExcelButton:v.a.bool,excelPortalContainerID:v.a.string};var ae=Object(J.a)()(te),ne=a("nscK"),ie=a("n7pt");function se(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),a.push.apply(a,n)}return a}function re(e){for(var t=1;t{const{aggData:a=new Map,device:n,dispatch:i}=this.props,s=t?+e:+P.a.utc(e).subtract(7,"days").startOf("day"),r=t?+t:+P.a.utc().startOf("day"),o=Math.abs(P()(s).diff(P()(r),"days"))+1;(a.has(n.DevID)?a.get(n.DevID).filter(e=>e.AggTi>=s&&e.AggTi<=r):[]).length!==o&&i(Object(Y.a)(n,{AggDataTimeFrom:s,AggDataTimeTo:r}))},250),this.getOptions=()=>[{name:this.props.t("hourly"),value:"hourly"},{name:this.props.t("daily"),value:"daily"}],this.initialFetch=()=>{const{settlementList:e}=this.props,t={start:e.length?+P()(e[e.length-1].DtaStartTime).utc().startOf("day"):+P()().utc().startOf("day").subtract(7,"days"),end:+P()().utc().startOf("day")};this.fetchData(re({},t))},this.dataFetcher=(e={})=>{const{chart:t,date:a,dateStart:n,dateEnd:i}=this.state;["hourly"].includes(t)?a&&!m()(e.date,a)&&this.fetchData({start:a}):["daily"].includes(t)&&(!n||!i||m()(e.dateStart,n)&&m()(e.dateEnd,i)||this.fetchData({start:n,end:i}))},this.getErrors=({shadow:e={}})=>{const t=e.errors||[],{t:a}=this.props;return t.map(e=>a("notificationsCenter.errorCodes.".concat(e))||e)},this.getValues=({t:e,aggData:t,settlementList:a,shadow:n={},fetching:i,fetched:s,device:{DevID:r,Settings:{FlowValueAlertLimit:o}}})=>{const c=this.getErrors({shadow:n}),d={start:a.length?+P()(a[a.length-1].DtaStartTime).utc().startOf("day"):+P()().utc().startOf("day").subtract(7,"days"),end:a.length&&l()(a[a.length-1].DtaEndTime)?+P()(a[a.length-1].DtaEndTime).utc().startOf("day"):void 0},m=Object(ne.a)({aggData:t.get(r),shadow:n,range:d});return re({},m,{errors:c,settlementConsumption:this.energyFormatter(m.settlementConsumption),averageDailyConsumption:e("deviceRows.electricityFlowMeter.electricityFlowMeterRow.usageXday",{count:Object(X.b)(m.averageDailyConsumption?m.averageDailyConsumption:0,{showUnit:!0,unit:Z.a.MEDIUM,fixed:2})}),dailyConsumption:this.energyFormatter(m.dailyConsumption),totalConsumption:this.energyFormatter(n.totalActiveEnergyConsumption),l1:this.powerFormatter(n.activePowerConsumptionL1),l2:this.powerFormatter(n.activePowerConsumptionL2),l3:this.powerFormatter(n.activePowerConsumptionL3),isAlerted:!!c.length,isConnected:!!s,isLoading:!!i,dateTime:Object(F.o)(n.metadata)})},this.handleSelect=e=>{e.preventDefault(),e.stopPropagation();const{device:t,onSelect:a}=this.props;o()(a)&&a(t)},this.handleChartChange=e=>{this.setState({chart:e})},this.handleCollapseToggle=()=>{this.setState(e=>({collapse:!e.collapse}))},this.getName=()=>{const{name:e,device:{Address:t,Alias:a,Name:n,Interface:i},showAlias:r}=this.props;return r&&a?a:e||(s()(t)?n:"".concat(t,"/0x").concat(t.toString(16)," ").concat(Object(F.n)(i)))},this.getSubtitle=()=>{const{CID:e,settlement:t,t:a}=this.props;let n=ie.a.getLocationByID(e);return n&&n.BgID?"-":s()(e)?a("noChamber"):t.state===R.a.NO_SHOW?"-":t.state===R.a.SHOW_SETTLEMENT?a("waitingForSettlement"):t.state===R.a.SHOW_SEPARATION?a("deviceRows.electricityFlowMeter.electricityFlowMeterRow.dayX",{count:1+P()().startOf("day").diff(P()(t.data.DtaStartTime).startOf("day"),"days")}):void 0},this.handleSettlementChange=(e={})=>{this.setState(re({},e))},this.handleDayChange=e=>{if(e){const t=P.a.utc(e,P.a.HTML5_FMT.DATETIME_LOCAL).startOf("day");t.isBefore(P.a.utc())&&this.setState({date:t})}},this.renderDaySelect=e=>{const{date:t}=this.state,a=P.a.utc(t).clone().add(1,"day").format(P.a.HTML5_FMT.DATETIME_LOCAL),n=P.a.utc(t).clone().subtract(1,"day").format(P.a.HTML5_FMT.DATETIME_LOCAL);return g.a.createElement("div",{className:"chart-controls"},g.a.createElement("h4",null,e),g.a.createElement("div",{className:"chart-controls-container"},g.a.createElement("div",{className:"chart-controls-date"},g.a.createElement(L.a,{icon:g.a.createElement("i",{className:"fas fa-chevron-left"}),onClick:()=>this.handleDayChange(n)}),g.a.createElement(U.a,{type:"date",value:P.a.utc(t).format("YYYY-MM-DD"),onChange:this.handleDayChange}),g.a.createElement(L.a,{icon:g.a.createElement("i",{className:"fas fa-chevron-right"}),onClick:()=>this.handleDayChange(a)}))))},this.settlementOptions=(e=this.props)=>{const{settlementList:t}=e;return t.map((e,t)=>({name:e.DtaEndTime?"".concat(P.a.utc(e.DtaStartTime).format("DD.MM.YYYY")," - ").concat(P.a.utc(e.DtaEndTime).format("DD.MM.YYYY")):"".concat(P.a.utc(e.DtaStartTime).format("DD.MM.YYYY")," - ..."),value:{dateStart:+P()(e.DtaStartTime).utc().startOf("day"),dateEnd:+P()(e.DtaEndTime).utc().startOf("day")}}))},this.renderSettlementSelect=e=>{const{dateStart:t,dateEnd:a}=this.state,n=this.settlementOptions();return g.a.createElement("div",{className:"chart-controls"},g.a.createElement("h4",null,e),g.a.createElement("div",{className:"chart-controls-container"},g.a.createElement(N.a,{value:{dateStart:t,dateEnd:a},options:n,onChange:this.handleSettlementChange})))},this.energyFormatter=(e,t=0,a="{1}")=>l()(e)?Object(V.d)(a,Object(X.b)(e,{showUnit:!0,unit:Z.a.MEDIUM,fixed:t}),1):"-",this.powerFormatter=(e,t=1,a="{1}")=>l()(e)?Object(V.d)(a,Object(X.d)(e,{showUnit:!0,unit:Z.a.MEDIUM,fixed:t}),1):"-";const t=this.settlementOptions();this.state={chart:"hourly",collapse:!1,date:+P()().utc().startOf("day"),dateStart:t.length?+P.a.utc(t[t.length-1].value.dateStart).startOf("day"):void 0,dateEnd:t.length?+P.a.utc(t[t.length-1].value.dateEnd).startOf("day"):void 0}}componentDidMount(){this.initialFetch()}componentDidUpdate(e,t,a){this.dataFetcher(t);const n=this.settlementOptions(this.props),i=this.settlementOptions(e);n.length!==i.length&&(this.initialFetch(),this.setState({dateStart:n.length?+P.a.utc(n[n.length-1].value.dateStart).startOf("day"):void 0,dateEnd:n.length?+P.a.utc(n[n.length-1].value.dateEnd).startOf("day"):void 0}))}render(){const{fetched:e,t:t,device:a,device:{DevID:n,Number:i,Settings:{Phases:s=1}},selected:r}=this.props,{l1:o,l2:c,l3:l,settlementConsumption:d,dateTime:m,errors:h,isConnected:u,isLoading:p,isAlerted:f,averageDailyConsumption:v,dailyConsumption:b,totalConsumption:D}=this.getValues(this.props),{chart:E,collapse:R,date:F,dateStart:A,dateEnd:L}=this.state,U=this.getOptions(),Y=this.getName(),V=this.getSubtitle();return g.a.createElement(w.a,{className:R?"device-item opened":"device-item",showWorking:!0,isError:!e},g.a.createElement("div",{className:"device-info",onClick:this.handleCollapseToggle},g.a.createElement(W.a,{dateTime:m,isConnected:u,isAlerted:f,isLoading:p},({icon:e,color:t,header:a})=>g.a.createElement("div",{className:"device-main dev-cl ".concat(t)},g.a.createElement("div",{className:"device-main-location",title:Y},Y),g.a.createElement("div",{className:"device-main-item"},d),g.a.createElement("div",{className:"device-main-item-alternate",title:V},V),g.a.createElement(y.a,{tooltipContent:g.a.createElement("div",null,g.a.createElement("b",null,a),!!m&&g.a.createElement("div",null,g.a.createElement("i",{className:"fas fa-sync mr-1"}),g.a.createElement("b",null,P()(m).format("DD.MM.YY HH:mm"))),g.a.createElement("div",null,h.join(", "))),placement:"auto",type:t},g.a.createElement("div",{className:"device-main-working"},g.a.createElement("i",{className:e}))),g.a.createElement("div",{onClick:this.handleSelect,className:"device-main-checkbox show-on-small-device sm"},g.a.createElement(O.a,{label:"",id:n,readOnly:!0,checked:r})))),g.a.createElement("div",{className:"device-info-main"},g.a.createElement("div",{className:"device-info-main-second"},g.a.createElement("div",{className:"device-info-main-second-name"},i||"-"),g.a.createElement(C.a,{icon:S.a,name:t("deviceRows.electricityFlowMeter.electricityFlowMeterRow.averageConsumptionPerDay"),value:v}),g.a.createElement(C.a,{icon:I.a,name:t("deviceRows.electricityFlowMeter.electricityFlowMeterRow.electricityConsumedToday"),value:b}),g.a.createElement(C.a,{icon:T.a,name:t("deviceRows.electricityFlowMeter.electricityFlowMeterRow.currentMeterState"),value:D}),g.a.createElement(C.a,{icon:j.a,name:t("deviceRows.electricityFlowMeter.electricityFlowMeterRow.currentVoltageX",{type:"L1"}),value:o}),3===s&&g.a.createElement(g.a.Fragment,null,g.a.createElement(C.a,{icon:x.a,name:t("deviceRows.electricityFlowMeter.electricityFlowMeterRow.currentVoltageX",{type:"L2"}),value:c}),g.a.createElement(C.a,{icon:M.a,name:t("deviceRows.electricityFlowMeter.electricityFlowMeterRow.currentVoltageX",{type:"L3"}),value:l})),3!==s&&g.a.createElement(g.a.Fragment,null,g.a.createElement("div",{className:"fetura-icon-value"}),g.a.createElement("div",{className:"fetura-icon-value"})))),g.a.createElement("div",{onClick:this.handleSelect,className:"device-info-checkbox hide-on-small-device sm"},g.a.createElement(O.a,{label:"",id:n,readOnly:!0,checked:r}))),g.a.createElement(k.a,{in:R,unmountOnExit:!0,onEntered:this.dataFetcher},g.a.createElement("div",{className:"chart-container"},g.a.createElement(N.a,{value:E,options:U,onChange:this.handleChartChange,clearButton:!1}),g.a.createElement("div",{className:"device-chart"},"hourly"===E&&g.a.createElement(g.a.Fragment,null,this.renderDaySelect(t("hourly")),g.a.createElement("div",{className:"chart-main-container"},g.a.createElement(ee,{device:a,date:F,showExcelButton:!0}))),"daily"===E&&g.a.createElement(g.a.Fragment,null,this.renderSettlementSelect(t("daily")),g.a.createElement("div",{className:"chart-main-container"},g.a.createElement(ae,{device:a,dateStart:A,dateEnd:L,showExcelButton:!0})))))))}}ce.propTypes={device:v.a.instanceOf(E.a).isRequired},ce=Object(b.connect)((function(){const e=Object(D.a)();return function(t,a){const{shadow:n,fetching:i,fetched:s}=e(t,a.device);return{shadow:n,fetching:i,fetched:s,aggData:t.aggregatedData.data,settlementList:Object(R.d)(t,{CID:a.CID}),settlement:Object(R.c)(t,{CID:a.CID})}}}))(ce);t.a=Object(J.a)()(ce)}}]); //# sourceMappingURL=main~b88f4497.5f6d65ce.chunk.js.map