(this["webpackJsonpgonzo-test-client"]=this["webpackJsonpgonzo-test-client"]||[]).push([[105],{"+PoS":function(e,t,s){"use strict";function i(e){return{type:"REDIRECT",payload:e}}s.d(t,"a",(function(){return i}))},"/kok":function(e,t,s){"use strict";var i=s("E+oP"),a=s.n(i),n=s("GoyQ"),r=s.n(n),o=s("mwIZ"),c=s.n(o),u=s("J2iB"),l=s.n(u),d=s("BkRI"),m=s.n(d),f=s("lSCD"),D=s.n(f),I=s("4qC0"),O=s.n(I),b=s("Z0cm"),g=s.n(b),p=s("bYcM"),T=s.n(p),A=s("0ygv"),y=s.n(A),S=s("B6RA"),E=s("fz41"),j=s("AO/9"),h=s("nSxQ"),C=s.n(h),v=s("ST2B"),_=s("OwcS"),w=s("IBmF");class N{onMessage(e){console.log(e);let t=e.CAnsw;S.default.dispatch({type:"SET_ALARM_DATA",payload:{DevID:e.DeviceID,data:t}})}}var P=s("j1RV"),M=s("16wW"),R=s.n(M),F=s("RRbG"),L=s("5/y7"),U=s.n(L),G=s("VfnB"),k=s("Q2bl"),B=s("dxSB"),V=s("kCmh"),z=s("zDJl"),x=s("6uZD"),W=s("n7pt"),H=s("kCVf"),Q=s("4ltZ"),q=s("Ogml"),Y=s("B2Cw"),J=s("lM7y"),K=s("5Z9N"),X=s("rzZ0"),Z=s("gLBR"),$=s("xgzS"),ee=s("Akpi"),te=s("+PoS"),se=s("q17X"),ie=s("k3WJ"),ae=s("e6PY"),ne=s("A5yn"),re=s("tMEj"),oe=s("EP7i"),ce=s("Bffz"),ue=s("D7Yj"),le=s("fAk8"),de=s("JFDi"),me=s("Gr13"),fe=s("XzT5"),De=s("Ke8t"),Ie=s("wd8a"),Oe=s("wd/R"),be=s.n(Oe),ge=s("Ze2Y");function pe(e,t){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),s.push.apply(s,i)}return s}function Te(e){for(var t=1;t{let{user:{user:{Login:t}}}=S.default.getState();localStorage.setItem("".concat(t,".token"),e.CAnsw.token),localStorage.setItem("".concat(t,".createTokenTime"),e.CAnsw.createTokenTime),localStorage.setItem("".concat(t,".localRefreshToken"),e.CAnsw.refreshToken),localStorage.setItem("".concat(t,".createRefreshTokenTime"),e.CAnsw.createRefreshTokenTime),this.sendingRefreshToken=!1},this.onRefreshTokenError=(e,t)=>{console.log(e,t),console.error("cant refresh token"),this.sendingRefreshToken=!1,Object(de.b)()},this.onRefreshTokenSend=(e,t)=>{this.sendingRefreshToken=!0,this.addMessageToQueue(t)},this.url="",this.window=null,this.msgChunks=new Map,this.client=void 0,this.offlineChecker=null,this.subscriptions=[],this.intervalMap=new Map,this.afterProcessDelay=25,this.preconditionRetryTimeout=2,this.timeout=void 0,this.timeToClearQueue=1,this.waitedSetMessage=[],this.specialMessages=[w.f.RESET_CONSUMPTION,w.n.DO_TARE,w.n.RESET_DAILY_VISITS,w.n.CLEAR_INSERTION_DATA,w.n.RESET,w.f.START_MOTORS,w.f.STOP_MOTORS,w.k.GET_FULL_DEV_STATE,w.k.GET_DEVICES,w.g.GET_LOGS,w.g.DELETE_LOGS,w.g.GET_PIG,w.g.ADD_PIG,w.g.GET_WORK_TYPE,w.g.GET_HISTORY_STANDARD,w.k.PING,w.g.GET_DAILY_USAGE,w.k.GET_AGGREGATED_DATA,w.i.STOP_ADDRESSING,w.i.START_ADDRESSING,w.i.GET_GATEWAY_TIME,w.k.UPDATE_SINGLE_DEVICE,w.k.REMOVE_DEVICES,w.k.GET_NRF_FEEDERS,w.n.GET_SENSORS_AND_VALVES,w.d.GET_CONFIGURATION,w.i.OPEN_SSH,w.i.GET_NRF_STATS,w.i.START_ADR_WST,w.i.START_ADDRESSING_NRF,w.i.STOP_ADR_WST,w.i.STOP_ADDRESSING_NRF,w.i.GET_SCHEMA,w.k.AUTH_USER,w.i.ADDR_START_SUBADDRESSING_NRF,w.a.B_INFO,w.a.B_BOOT_INFO,w.a.B_BOOT_INFO_NRF,w.a.B_NRF_STAT,w.a.B_485_TOUT_R,w.a.B_GET_SCAN_ADDR,w.i.GET_QUEUES_LAST_SUCCESS,w.i.GET_PIGS_DATA,w.i.GET_ASCII_CLIMATE_TESTING_DATA,w.k.GET_FEED_RFID_STATE,w.i.GET_ALL_ALARMS,w.i.GET_ALL_ONGOING_ALARMS,w.i.GET_USAGE_FOR_PIG,w.k.REFRESH_TOKEN,w.i.GET_FEEDING_DATA_FOR_PIG,w.i.PING,w.g.SET_ADDITIONAL_WATER,w.g.SET_ANIMAL_MODIFICATION],this.sendingRefreshToken=!1,this.reconnectsAmount=0,this.queue=new T.a((e,t)=>{this.runQueueTask(e,t)},{store:new y.a,afterProcessDelay:this.afterProcessDelay,maxTimeout:1e4,precondition:e=>{this.client&&this.client.connected?(this.timeout&&(clearTimeout(this.timeout),this.timeout=void 0),"FeturaOfflineGW"!==this.client.options.hostname&&this.subscriptions.length<2?e(null,!1):this.sendingRefreshToken?(console.log("sending refresh token"),e(null,!1)):e(null,!0)):(this.timeout||(this.timeout=setTimeout(()=>{this.clearQueue(),this.timeout=void 0},6e4*this.timeToClearQueue)),e(null,!1))},preconditionRetryTimeout:1e3*this.preconditionRetryTimeout,id:(e,t)=>{t(null,e.message.MsgId)},concurrent:3}),this.queue.on("task_finish",(e,t)=>{"object"===typeof t&&this.checkResult(t)}),this.queue.on("task_failed",(e,t)=>{console.log(e,t,this.waitedSetMessage);try{let s=this.waitedSetMessage.find(t=>t.message.MsgId===e);if(s.notification){let e=Te({id:s.notification.id},s.notification.loading);e=("Failed to fetch"===t||t.statusCode)&&s.notification.apiFailed?Te({},e,{},s.notification.apiFailed):Te({},e,{},s.notification.error),S.default.dispatch(Object(P.updateNotification)(e))}s.onError&&s.onError(t,s.message),this.waitedSetMessage=this.waitedSetMessage.filter(t=>t.message.MsgId!==e)}catch(s){console.error(s),this.waitedSetMessage=[]}}),this.onStateMessageArrived=this.onStateMessageArrived.bind(this),this.onAggregatedDataMessageArrived=this.onAggregatedDataMessageArrived.bind(this),this.onMessageArrived=this.onMessageArrived.bind(this),this.onAlarmsMessageArrived=this.onAlarmsMessageArrived.bind(this),this.onResponsesMessageArrived=this.onResponsesMessageArrived.bind(this)}clearQueue(){this.queue.use(new y.a)}runQueueTask(e,t){if(console.warn("QUEUE_TASK_EXECUTED",e),!this.client.options.host.includes("fetura")&&!this.client.options.host.includes("Fetura")||!Array.isArray(e.message.Command)||e.message.Command.includes(w.k.AUTH_USER)||e.message.Command.includes(w.k.REFRESH_TOKEN))this.sendMqttMessage({topic:e.topic,message:e.message});else{let{user:{user:{Login:t}}}=S.default.getState();if(+localStorage.getItem("".concat(t,".createTokenTime"))>(new Date).getTime())e.message.CData.token=localStorage.getItem("".concat(t,".token")),this.sendMqttMessage({topic:e.topic,message:e.message});else{if(+localStorage.getItem("".concat(t,".createRefreshTokenTime"))>(new Date).getTime()){let s=localStorage.getItem("".concat(t,".localRefreshToken"));this.sendingRefreshToken?this.addMessageToQueue(e):this.refreshToken(s,e)}else Object(de.b)()}}e.onSend&&e.onSend(e.message),this.checkCommands(e.message.Command)?(this.waitedSetMessage.push(Te({},e,{callback:t})),e.notification&&(e.notification.id=e.message.MsgId,S.default.dispatch(Object(P.addNotification)(Te({},e.notification.loading,{id:e.message.MsgId}))))):t(null,!0)}refreshToken(e,t){let s={MsgId:Object(_.a)(),PktType:w.l.REQUEST,RTime:(new Date).getTime(),Command:[w.k.REFRESH_TOKEN],CData:{refreshToken:e}};this.createAndAddMessageToQueue("devices/auth",s,null,this.onRefreshTokenSuccess,this.onRefreshTokenError,e=>this.onRefreshTokenSend(e,t))}checkIfAlreadySubscribed(e){return this.subscriptions.includes(e)}addToSubscriptions(e){this.subscriptions.push(e)}removeFromSubscriptions(e){this.subscriptions=this.subscriptions.filter(t=>t!==e)}clearSubscriptions(){console.log("clear");for(let e of this.subscriptions)this.client.unsubscribe(e);this.subscriptions=[],console.log(this.subscriptions),S.default.dispatch({type:"SUBSCRIBE_MQTT_TOPICS",payload:[]})}storeConfiguration(e,t=!0){console.log("STORING",e);let s=[],i=new ie.a(e);for(let a of Array.isArray(e.DeviceId)?e.DeviceId:[e.DeviceId]){let e=i.parseCommand(a,t);e&&(s=[...s,...e])}if(s.length>0){const{user:{user:e},location:{farm:t}}=S.default.getState();S.default.dispatch(Object(x.f)(s,t,e.ClientID,e.LocalUserID,null,null,!1))}}createMessage(e,t,s,i,a,n){return{topic:e,message:t,notification:s,onSuccess:e=>{this.storeConfiguration(e),i&&i(e)},onError:(e,t)=>{console.log(e,t),this.storeConfiguration(t,!1),a&&a(e,t)},onSend:()=>{n&&n(t)}}}addMessageToQueue(e){console.log(e),this.queue.push(e)}createAndAddMessageToQueue(e,t,s,i,a,n){this.addMessageToQueue(this.createMessage(e,t,s,i,a,n))}compressData(e){return R.a.deflate(JSON.stringify(e),{level:9,to:"string"})}decompressData(e,t){let s=!0;return t===w.p.AGGREGATED_DATA&&(s=!1),s?JSON.parse(R.a.ungzip(R.a.inflate(Array.isArray(e)?e.reduce((e,t)=>e+t,""):e),{to:"string"})):e}async createURL(e){if(await Object(E.a)()){let t=await j.a.currentCredentials();return C.a.createPresignedURL("GET",e,"/mqtt","iotdevicegateway","",{key:t.data.Credentials.AccessKeyId,secret:t.data.Credentials.SecretKey,region:v.a.cognito.REGION,protocol:"wss",sessionToken:t.sessionToken})}}subscribeAllTopics(e=""){let t=S.default.getState();const{user:{user:s},farmDevices:{devices:i}}=t;let a=[];(e||s.ClientID)&&a.push("devices/state/".concat(e||s.ClientID,"/lambda")),s.LocalUserID&&s.UserType===Ie.SERVICE&&a.push("devices/state/".concat(s.LocalUserID,"/lambda"));let n=i.filter(e=>e.DevType===z.d.GATEWAY);for(let r of n)a.push("devices/responses/".concat(e||s.ClientID,"/").concat(r.DevID)),a.push("devices/state/".concat(e||s.ClientID,"/").concat(r.DevID)),a.push("devices/aggregatedData/".concat(e||s.ClientID,"/").concat(r.DevID));for(let r of a)this.subscribeTopic(r);S.default.dispatch({type:"SUBSCRIBE_MQTT_TOPICS",payload:a})}createCheckTimeout(e){setTimeout(async()=>{console.log("timeout xD");try{let t=await fetch("https://icanhazip.com/");t&&200===t.status?(this.url=await this.createURL("a1h52tmlgb9hda-ats.iot.eu-central-1.amazonaws.com"),this.client&&(this.client.end(),this.clearSubscriptions(),this.client=null),this.createClient(this.url,{protocol:"wss",transformWsUrl:()=>this.url})):e<3e5&&this.createCheckTimeout(e)}catch(t){console.error(t),e<3e5&&this.createCheckTimeout(e)}},e)}async createLocalClient(){this.createClient("wss://".concat("FeturaOfflineGW"),{keepalive:60,port:9001,hostname:"FeturaOfflineGW",protocol:"wss",ca:["-----BEGIN CERTIFICATE-----\nMIIDtTCCAp2gAwIBAgIURiyLl4b7ktNcTdmO8RrGWlZjDSswDQYJKoZIhvcNAQEN\nBQAwajEXMBUGA1UEAwwOQW4gTVFUVCBicm9rZXIxFjAUBgNVBAoMDU93blRyYWNr\ncy5vcmcxFDASBgNVBAsMC2dlbmVyYXRlLUNBMSEwHwYJKoZIhvcNAQkBFhJub2Jv\nZHlAZXhhbXBsZS5uZXQwHhcNMTkwODIzMTgwNjE0WhcNMzIwODE5MTgwNjE0WjBq\nMRcwFQYDVQQDDA5BbiBNUVRUIGJyb2tlcjEWMBQGA1UECgwNT3duVHJhY2tzLm9y\nZzEUMBIGA1UECwwLZ2VuZXJhdGUtQ0ExITAfBgkqhkiG9w0BCQEWEm5vYm9keUBl\neGFtcGxlLm5ldDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANqtusP0\n+APMlOFVC198QMMuFJM4+myWH9I1GyhZFGTif/DbOeVEwakXMyt0G9TCktoYud5C\nQhvCoz9XZqHm163//r8rV2EU/9e6yy8g9zxz50YK9tDD9XHtK32vXCPPjEpuGKO4\nvQJMGFCaFfjG/CjtPlyioMo72auTQknZip9XvOWHJvYCjdYQVDxvfSeYFJp7Gxee\neC5sDDCz3wbSjg+eOSXCIk/3Vzg9PvQ6ITxnbbNxB0rdE0yHLkZTlmQ/dRe/JVP7\n2t4co1f8eJ/xysmzTf5nVQlKtuKZG/JpKqmvOu25ocehdIJBa8MsOoTtH35aJTRs\nb7ecflbwaxJqBh8CAwEAAaNTMFEwHQYDVR0OBBYEFDd9uCVRS+D/XeLRQ+oZOBZr\nLEAcMB8GA1UdIwQYMBaAFDd9uCVRS+D/XeLRQ+oZOBZrLEAcMA8GA1UdEwEB/wQF\nMAMBAf8wDQYJKoZIhvcNAQENBQADggEBAH5EVma7jjT1+0U7FIymQDmn/tYQ8CRn\nLWliGG6dScPR/NDM86xuB8fG96YGnE7D2PRJNIcwKx8xAJdbFTekCRBF3Aym20ZH\n6wH4jwBJgDLyfzUoCwSUYTByK7LTCQNiBqVWfGuT6dkTIjXlgl92dR//W2CP8k6y\nNyHkl8M8FY8MtL7bvwGxW1p+97QA7/haWvJB4q5UgdVdg3+DietTKL5Q4vgNzdH4\n4lOjvfJwlf6SY9jSFNTarGCCMENz+owexVyvXWX1QEi+0Muyvc0HJH2vAp9R+1Ys\nR7/OpqIKOdSTMg663uoX1A5ZB0c2X/jlE5GAbzb5A65HF0ZSX+bcPjc=\n-----END CERTIFICATE-----"],rejectUnauthorized:!1}),this.createCheckTimeout(1e4)}createClient(e,t={}){let s=1;this.client=U.a.connect(e,Te({clientId:"mqttjs_"+Math.random().toString(16).substr(2,8),keepalive:10},t)),this.client.on("connect",()=>{this.reconnectsAmount=0,!S.default.getState().mqtt.connected&&S.default.dispatch({type:"MQTT_CONNECT_FULFILLED"}),console.log("MQTT: Client connected",this.client),this.subscribeAllTopics()}),this.client.on("reconnect",async()=>{this.reconnectsAmount++,console.error("reconnect"),this.reconnectsAmount<10?S.default.dispatch({type:"MQTT_CONNECT_PENDING"}):S.default.dispatch({type:"MQTT_KEEPS_RECONNECTING"}),s--,s<0&&(this.clearSubscriptions(),this.client&&this.client.end(!0),this.client=null,await this.createLocalClient()),this.client.options.host.includes("a1h52tmlgb9hda-ats.iot.eu-central-1.amazonaws.com")&&(this.url=await this.createURL("a1h52tmlgb9hda-ats.iot.eu-central-1.amazonaws.com"),console.log("MQTT: Client reconnect"))}),this.client.on("message",(e,t)=>{this.onMessageArrived(e,t)}),this.client.stream.on("error",async e=>{console.log("error stream",e);try{e.srcElement.url.includes("a1h52tmlgb9hda-ats.iot.eu-central-1.amazonaws.com")||(this.clearQueue(),this.endConnection(e.srcElement.url),window.location.href.includes("login")&&S.default.dispatch({type:"USER_LOGIN_REJECTED",error:null}),Object(se.getOffline)()&&S.default.dispatch(Object(te.a)("/acceptCert")))}catch(e){console.error(e)}}),this.client.on("error",e=>{console.error("MQTT: Client error: ",e),this.clearSubscriptions(),Ee().notify("MQTT: Client error",{metaData:{feedback:{causedBy:e&&e.toString?e.toString():"No info available",stack:e&&e.stack?e.stack:"No info available"}}})})}async connectToAWS(){this.client&&this.client.connected?this.subscribeAllTopics():(this.url=await this.createURL("a1h52tmlgb9hda-ats.iot.eu-central-1.amazonaws.com"),this.createClient(this.url,{protocol:"wss",transformWsUrl:()=>this.url}))}async startConnection(){try{S.default.dispatch({type:"MQTT_CONNECT_PENDING"}),await this.connectToAWS()}catch(e){console.error("Blad przy polaczeniu ",e)}}endConnection(e){e?this.client.options.href===e&&(this.clearSubscriptions(),this.client.end(!1,()=>S.default.dispatch({type:"MQTT_CONNECT_FAILURE"})),this.client=void 0):(this.clearSubscriptions(),this.client.end(!1,()=>S.default.dispatch({type:"MQTT_CONNECT_FAILURE"})),this.client=void 0)}sendToChannel(e){try{this.client.publish(e.topic,JSON.stringify(e.message),{},e=>{if(e&&!Se){Ee().notify("MQTT: Send MQTT message failure (Client.publish())",{metaData:{feedback:{causedBy:e.toString?e.toString():"No info available",stack:e.stack?e.stack:"No info available"}}}),console.error("MQTT: Send MQTT message failure (Client.publish())",e)}})}catch(t){Ee().notify("MQTT: Send MQTT message failure",{metaData:{feedback:{causedBy:t&&t.toString?t.toString():"No info available",stack:t&&t.stack?t.stack:"No info available"}}}),console.error("MQTT: Send MQTT message failure: ",t)}}isMoreThan120kB(e,t=[]){return console.log(e.length),e.length>122880?(t.push(e.slice(0,122880)),e=e.slice(122880,e.length),this.isMoreThan120kB(e,t)):(console.log(t),t.push(JSON.parse(e)),t)}prepareToPublish(e,t){if(t.length>1){let s=Object(_.a)();return t=t.map((i,a)=>{let n=Object.assign({},e);return n.ChunksID=s,n.ChunksOffset=a,n.ChunksSize=t.length,n.CData=i,n})}return e.CData=t[0],[e]}async sendMqttMessage(e){let t=JSON.stringify(e.message.CData),s=this.isMoreThan120kB(t,[]);console.log(s),this.prepareToPublish(e.message,s).forEach(t=>{if(e.message=t,this.client.options.host.includes("amazonaws.com"))if(e.topic.includes("commands")){const t=S.default.getState(),{location:{farm:s}}=t;s&&Object(E.c)(Te({},ce.a.commandProxy({farmID:s}),{body:Te({},e.message,{Topic:e.topic})})).catch(t=>{let s=this.waitedSetMessage.find(t=>t.message.MsgId===e.message.MsgId);s&&s.callback(t,null)})}else this.sendToChannel(e);else this.sendToChannel(e)})}subscribeTopic(e){try{this.checkIfAlreadySubscribed(e)||(console.warn("SUBSCRIBING TO: "+e),this.client.subscribe(e),this.addToSubscriptions(e))}catch(t){console.error("sub failure:"+t)}}unsubscribeTopic(e){try{this.client.unsubscribe(e),this.removeFromSubscriptions(e)}catch(t){console.error("unsub failure: "+t)}}pingDevice(e,t,s,i,a,n){let r="devices/state/".concat(e,"/").concat(s,"/").concat(t),o={MsgId:Object(_.a)(),PktType:w.l.REQUEST,DeviceId:i,RTime:(new Date).getTime(),Command:[w.k.PING],CData:{ping:"pong"}};this.createAndAddMessageToQueue(r,o,null,a,n)}startSendingDeviceState(e,t=G.v,s=G.u,{keepAlive:i=!1}={}){const{ClientID:a,LocalUserID:n,GatewayID:r,DevID:o,isValid:c}=Object(k.a)(e);if(c){let e="devices/state/".concat(a,"/").concat(r,"/").concat(n);const c=Object(_.a)();let u={MsgId:c,PktType:w.l.REQUEST,DeviceId:r,RTime:(new Date).getTime(),Command:[w.k.GET_FULL_DEV_STATE],CData:{DeviceIDs:g()(o)?o:[o]}};S.default.dispatch(Object(F.d)({DevID:u.CData.DeviceIDs,status:!0}));const l=e=>S.default.dispatch(Object(F.d)({DevID:e.CData.DeviceIDs,status:!1})),d=e=>S.default.dispatch(Object(F.d)({DevID:e.CData.DeviceIDs,status:!0}));if(this.createAndAddMessageToQueue(e,u,null,t,s,d),i){let t=setInterval(()=>{u.MsgId=Object(_.a)(),u.RTime=(new Date).getTime(),this.createAndAddMessageToQueue(e,u,null,l,l,d)},ye);this.intervalMap.set(c,t)}return console.error("WYSYLAM"),c}s()}removeFromInterval(e){console.log("removing intervals for -> ",e),(O()(e)?[e]:g()(e)?e:[]).forEach(e=>{const t=this.intervalMap.get(e);t&&(clearInterval(t),this.intervalMap.delete(e))})}stopSendingDeviceState(e,t,s,i=[]){try{let a={MsgId:Object(_.a)(),PktType:w.l.REQUEST,DeviceId:s,RTime:(new Date).getTime(),Command:[w.k.STOP_SENDING_DEV_STATE],CData:{DeviceIDs:i}},n="devices/commands/".concat(e,"/").concat(s,"/").concat(t);this.createAndAddMessageToQueue(n,a)}catch(a){console.error("ERROR: "+a)}}startSendingFeedingState(e,{onSuccess:t,onFailure:s,keepAlive:i=!1}={}){const{ClientID:a,LocalUserID:n,GatewayID:r,DevID:o,isValid:c}=Object(k.a)(e);if(c){let e="devices/state/".concat(a,"/").concat(r,"/").concat(n);const c=Object(_.a)();let u={MsgId:c,PktType:w.l.REQUEST,DeviceId:r,RTime:(new Date).getTime(),Command:[w.k.GET_FEED_STATE],CData:{DeviceIDs:g()(o)?o:[o]}};if(this.createAndAddMessageToQueue(e,u,null,t,s),i){let t=setInterval(()=>{u.MsgId=Object(_.a)(),u.RTime=(new Date).getTime(),this.createAndAddMessageToQueue(e,u,null,null,null)},ye);this.intervalMap.set(c,t)}return c}D()(s)&&s()}startSendingFeedingStateRFID(e,t,{onSuccess:s,onFailure:i,keepAlive:a=!1}={}){const{ClientID:n,LocalUserID:r,GatewayID:o,isValid:c}=Object(k.a)(e);if(c){let e="devices/state/".concat(n,"/").concat(o,"/").concat(r);const c=Object(_.a)();let u={MsgId:c,PktType:w.l.REQUEST,DeviceId:o,RTime:(new Date).getTime(),Command:[w.k.GET_FEED_RFID_STATE],CData:{PlcmntID:t}};if(this.createAndAddMessageToQueue(e,u,null,s,i),a){let t=setInterval(()=>{u.MsgId=Object(_.a)(),u.RTime=(new Date).getTime(),this.createAndAddMessageToQueue(e,u,null,null,null)},ye);this.intervalMap.set(c,t)}return c}D()(i)&&i()}sendRequestForAggregatedData(e){const{ClientID:t,LocalUserID:s,GatewayID:i,DevID:a,isValid:n}=Object(k.a)(e);if(n){let n="devices/state/".concat(t,"/").concat(i,"/").concat(s),r={MsgId:Object(_.a)(),PktType:w.l.REQUEST,DeviceId:i,RTime:(new Date).getTime(),Command:[w.k.GET_AGGREGATED_DATA],CData:{DeviceIDs:g()(a)?a:[a]}};this.createAndAddMessageToQueue(n,r,null,null,()=>{console.log(e);let t=Array.isArray(e)?e:"string"===typeof e?[e]:[e.DevID];for(let e of t){let t="";t="string"===typeof e?e:e.DevID;let s=V.a.getDeviceByID(t);s&&S.default.dispatch(Object(B.a)(s))}})}}createAndSendMessageObject(e,t,s,i,a,n,r,o,c,u){let l=Object(_.a)(),d={MsgId:l,PktType:w.l.REQUEST,DeviceId:i,RTime:(new Date).getTime(),Command:Array.isArray(a)?a:[a],CData:{},Priority:69};n&&(d.CData=n);let m="devices/commands/".concat(e,"/").concat(t,"/").concat(s);return this.createAndAddMessageToQueue(m,d,r,o,c,u),l}createAndSendMessageObjectToStateTopic(e,t,s,i,a,n,r,o,c){let u=Object(_.a)(),l={MsgId:u,PktType:w.l.REQUEST,DeviceId:i,RTime:(new Date).getTime(),Command:Array.isArray(a)?a:[a],CData:{}};n&&(l.CData=n);let d="devices/state/".concat(e,"/").concat(t,"/").concat(s);return this.createAndAddMessageToQueue(d,l,r,o,c),u}onAddSingleDeviceSuccess(e){S.default.dispatch(Object(x.b)(e,e.FarmID))}onEditSingleDeviceSuccess(e){let t=S.default.getState();S.default.dispatch(Object(x.e)(e,e.FarmID,t.user.user.ClientID,t.user.user.LocalUserID))}sendSingleDeviceToGateway(e,t,s,i,a=!1){const n=S.default.getState(),{user:r}=n.user;let o={DevID:t.DevID,ParentID:t.ParentID,FarmID:t.FarmID,DevAdr:t.Address,DevType:t.DevType,Protocol:s,VerHard:t.VerHard,VerSoft:t.VerSoft};t.DevType===z.d.BRIDGE?o.Interfaces=t.Interfaces:o.Interface=t.Interface;let c={loading:{title:"Dodawanie urz\u0105dzenia",message:"Dodawanie urz\u0105dzenia na gateway",status:"loading",dismissible:!1,dismissAfter:0},success:{message:"Pomy\u015blnie dodano urz\u0105dzenie na gateway",dismissible:!0,dismissAfter:3e3,status:"success"},error:{message:"Nie uda\u0142o si\u0119 doda\u0107 urz\u0105dzenia na gateway",dismissible:!0,dismissAfter:3e3,status:"error"},DevID:e},u={MsgId:Object(_.a)(),PktType:w.l.REQUEST,RTime:(new Date).getTime(),Command:[w.k.UPDATE_SINGLE_DEVICE],CData:o,DeviceId:e},l="devices/commands/".concat(r.ClientID,"/").concat(e,"/").concat(r.LocalUserID);S.default.dispatch({type:"ADD_DEVICE_TO_GATEWAY_PENDING"}),this.createAndAddMessageToQueue(l,u,c,()=>{a?this.onEditSingleDeviceSuccess(t):this.onAddSingleDeviceSuccess(t),S.default.dispatch({type:"ADD_DEVICE_TO_GATEWAY_FULFILLED"}),i&&i()},()=>{S.default.dispatch({type:"ADD_DEVICE_TO_GATEWAY_REJECTED"})})}removeDevicesFromDynamoDB(e,t){console.log(e);let s=new Map,i=[];for(let r of e){r.removeDevice();let e=r.getLocation();console.log(e);let t=m()(e);for(let i of t){let e=Object(H.j)(i);console.log(e);let t=W.a.getTreeByLocationID(e);console.log(t);let a=m()(t.building);if(a.BgID===e){let e=s.get(a.BgID);e||(e=a),e.Devices=e.Devices.filter(e=>e.DevID!==r.DevID),0===e.Devices.length&&delete e.Devices,s.set(e.BgID,e)}else for(let i of a.Sectors)if(i.SID===e){i.Devices=i.Devices.filter(e=>e.DevID!==r.DevID),0===i.Devices.length&&delete i.Devices;let e=s.get(a.BgID);e||(e=a),a.Sectors[t.sectorIndex]=i,s.set(e.BgID,e)}else for(let n of i.Chambers)if(n.CID===e){n.Devices=n.Devices.filter(e=>e.DevID!==r.DevID),0===n.Devices.length&&delete n.Devices,t.sector.Chambers[t.chamberIndex]=n;let e=s.get(a.BgID);e||(e=a),a.Sectors[t.sectorIndex]=i,s.set(e.BgID,e)}else if(n.Boxes)for(let o of n.Boxes)if(o.BID===e){o.Devices=o.Devices.filter(e=>e.DevID!==r.DevID),0===o.Devices.length&&delete o.Devices,t.chamber.Boxes[t.boxIndex]=o,t.sector.Chambers[t.chamberIndex]=n;let e=s.get(a.BgID);e||(e=a),a.Sectors[t.sectorIndex]=i,s.set(e.BgID,e)}}i.push(r.prepareBeanToSave())}let a=S.default.getState();S.default.dispatch(Object(x.e)(i,a.location.farm,a.user.user.ClientID,a.user.user.LocalUserID));for(let r of s.values())console.log(r),delete r.$loki,delete r.meta,S.default.dispatch(Object(Q.e)(r));let n=t.map(e=>{let t=e.clone();return t.ParentID="UNBINDED",t.prepareBeanToSave()});n.length>0&&S.default.dispatch(Object(x.e)(n,a.location.farm,a.user.user.ClientID,a.user.user.LocalUserID)),console.log(s,i)}sendRemoveDevicesToGateway(e,t,s,i){const a=S.default.getState(),{user:n}=a.user;let r={loading:{title:"Usuwanie urz\u0105dze\u0144",message:"Usuwanie urz\u0105dze\u0144 na gateway",status:"loading",dismissible:!1,dismissAfter:0},success:{message:"Pomy\u015blnie usuni\u0119to urz\u0105dze\u0144 z gateway",dismissible:!0,dismissAfter:3e3,status:"success"},error:{message:"Nie uda\u0142o si\u0119 usun\u0105\u0107 urz\u0105dze\u0144 na gateway",dismissible:!0,dismissAfter:3e3,status:"error"},DevID:e},o={MsgId:Object(_.a)(),PktType:w.l.REQUEST,RTime:(new Date).getTime(),Command:[w.k.REMOVE_DEVICES],CData:t,DeviceId:e},c="devices/commands/".concat(n.ClientID,"/").concat(e,"/").concat(n.LocalUserID);console.log(o,c,r),this.createAndAddMessageToQueue(c,o,r,()=>{this.removeDevicesFromDynamoDB(s,i)})}saveFeedersToDynamo(e,t=!1){if(console.log(e),Array.isArray(e.CAnsw)){let s=S.default.getState(),i=[],a=[];for(let n of e.CAnsw){let e=V.a.getDeviceByID(n.DevID);if(e){if(e.DtaDltTime&&t){let t=e.clone();delete t.DtaDltTime,t.setDtaModTime(),a.push(t.prepareBeanToSave())}}else i.push(q.a.createDevice(z.d.DISPENSER_NRF,n.DevAdr,n.Interface,n.DevID,n.ParentID,n.VerHard,n.VerSoft,n.Protocol,null,{DevID:n.DevID}))}i.length>0&&S.default.dispatch(Object(x.b)(i,s.location.farm)),a.length>0&&S.default.dispatch(Object(x.e)(a,s.location.farm,s.user.user.ClientID,s.user.user.LocalUserID))}}createAndSendDeviceTreeMessage(e,t,s,i){let a=Object(_.a)(),n={MsgId:a,PktType:w.l.REQUEST,RTime:(new Date).getTime(),Command:[w.k.UPDATE_DEVICES],CData:i,DeviceId:s},r="devices/commands/".concat(e,"/").concat(s,"/").concat(t);return this.createAndAddMessageToQueue(r,n),a}createAndSendDeviceTreeGetMessage(e,t,s,i,a){let n=Object(_.a)(),r={MsgId:n,PktType:w.l.REQUEST,RTime:(new Date).getTime(),Command:[w.k.GET_DEVICES],CData:{},DeviceId:s},o="devices/commands/".concat(e,"/").concat(s,"/").concat(t);return this.createAndAddMessageToQueue(o,r,null,i,a),n}async localAuthUser(e,t,s,i,a){this.client||await this.createLocalClient();let n=Object(_.a)(),r={MsgId:n,PktType:w.l.REQUEST,RTime:(new Date).getTime(),Command:[w.k.AUTH_USER],CData:{login:e,password:t||void 0,refreshToken:s}};return this.subscribeTopic("devices/auth"),this.createAndAddMessageToQueue("devices/auth",r,null,i,a),n}getNotificationStatus(e,t){try{let s;if(l()(t.CAnsw.status)?e&&t.CAnsw[e]&&(s=t.CAnsw[e].status):s=t.CAnsw.status,s instanceof Array)switch(console.log("StATUS",t),t.Command[0]){case w.f.STOP_MOTORS:case w.f.START_MOTORS:{let e=!0;for(let i of t.CData)0===s[i.number-1]&&(e=!1);s=e?w.e.SUCCESS:w.e.COMMAND_REJECTED}break;case w.f.SET_FORCE_FEEDING:case w.f.SET_SKIP_DOSES:{let e=!0;if(g()(t.CData))for(let i of t.CData)0!==s[i.number-1]&&(e=!1);else"number"!==typeof s&&0!==s[t.CData.number-1]&&(e=!1);s=e?w.e.SUCCESS:w.e.COMMAND_REJECTED}break;default:s=w.e.COMMAND_REJECTED}return s}catch(s){return console.error(s),w.e.GET_STATUS_ERROR}}sendBugsnagReportFromDevice(e,t){const{user:{user:{ClientID:s}}}=S.default.getState();if("TestNewRole"!==s){Ee().notify(new Error("".concat(t.Command[0]," (error)")),{severity:"error",metaData:{feedback:{status:e,user:s,CAnsw:c()(t,"CAnsw","No CAnsw"),CData:c()(t,"CData","No CData"),deviceID:t.DeviceId}}})}}changeNotification(e,t){try{let s,i=Te({id:t.id},t.loading,{dismissible:!0,dismissAfter:5e3});if(g()(t.DevID)){let i=0,a=0,n=t.DevID.length;for(let s of t.DevID){let t=this.getNotificationStatus(s,e);i+=t===w.e.SUCCESS?1:0,a+=t===w.e.COMMAND_REJECTED?1:0}i===n&&(s=w.e.SUCCESS),a>0&&(s=w.e.COMMAND_REJECTED)}else s=this.getNotificationStatus(t.DevID,e);console.log(s);let a=this.waitedSetMessage.find(t=>t.message.MsgId===e.MsgId);switch(s){case w.e.SUCCESS:i=Te({},i,{},t.success),a.onSuccess&&a.onSuccess(e);break;case w.e.MESSAGE_PARSER_ERROR:i.message=fe.a.t("IOT.messageParserError"),i.status="error",this.sendBugsnagReportFromDevice(w.e.MESSAGE_PARSER_ERROR,e);break;case w.e.COMMAND_REJECTED:i.message=fe.a.t("IOT.deviceRejectedQuery"),i.status="error",this.sendBugsnagReportFromDevice(w.e.COMMAND_REJECTED,e);break;case w.e.NO_RESPONSE:i.message=fe.a.t("IOT.noResponseFromDevice"),i.status="error",this.sendBugsnagReportFromDevice(w.e.NO_RESPONSE,e);break;case w.e.NO_DATA:i.message=fe.a.t("IOT.noDownloadedDataOnTheDeviceWaitAMomentAndRepeatTheQuery"),i.status="error";break;case w.e.RETURNING_PARSER_ERROR:i.message=fe.a.t("IOT.returningParserError"),i.status="error";break;case w.e.GET_STATUS_ERROR:i.message=fe.a.t("IOT.responseProcessingError"),i.status="error";break;case w.e.NO_PRIVILEGES:i.message=fe.a.t("IOT.noPrivileges"),i.status="error";break;case w.e.DEVICE_ALREADY_FEEDING:i.message=fe.a.t("IOT.alreadyFeeding"),i.status="error";break;default:i.message=fe.a.t("IOT.noStatusRecognized"),i.status="warning"}s!==w.e.SUCCESS&&a.onError&&a.onError(null,e),S.default.dispatch(Object(P.updateNotification)(i))}catch(s){console.error(s);let t=this.waitedSetMessage.find(t=>t.message.MsgId===e.MsgId);t&&t.callback(s,null)}}checkResult(e){let t=this.waitedSetMessage.find(t=>t.message.MsgId===e.MsgId);if(t.notification)this.changeNotification(e,t.notification);else{Array.isArray(e.Command)||(e.Command=[e.Command]);for(let s of e.Command)switch(s){case w.k.GET_DEVICES:t.onSuccess&&t.onSuccess(e);break;case w.g.GET_HISTORY_STANDARD:case w.g.GET_PIG:e.CAnsw&&void 0!==e.CAnsw[e.DeviceId]&&!e.CAnsw[e.DeviceId].status?(Object.keys(e.CAnsw).map(t=>{let s=new Map;return e.CAnsw[t].RTime=e.RTime,s.set(t,e.CAnsw[t]),S.default.dispatch(Object(F.b)(s)),t}),t.onSuccess&&t.onSuccess(e)):t.onError&&t.onError(null,t.message);break;case w.g.GET_LOGS:e.CAnsw&&void 0!==e.CAnsw[e.DeviceId]?t.onSuccess&&t.onSuccess(e):t.onError&&t.onError(null,t.message);break;case w.i.GET_GATEWAY_TIME:e.CAnsw&&void 0!==e.CAnsw.time?t.onSuccess&&t.onSuccess(e):t.onError&&t.onError(null,t.message);break;case w.k.GET_FULL_DEV_STATE:e.CAnsw&&Object.keys(e.CAnsw).length>0?t.onSuccess&&t.onSuccess(e):t.onError&&t.onError(null,t.message);break;case w.k.GET_NRF_FEEDERS:e.CAnsw&&Array.isArray(e.CAnsw)?t.onSuccess&&t.onSuccess(e):t.onError&&t.onError(null,t.message);break;case w.i.PING:e.CAnsw&&2===e.CAnsw.status?t.onSuccess&&t.onSuccess(e):t.onError&&t.onError(null,t.message);break;case w.n.GET_SENSORS_AND_VALVES:e.CAnsw&&e.CAnsw.sensors&&e.CAnsw.valves?t.onSuccess&&t.onSuccess(e):t.onError&&t.onError(null,t.message);break;case w.d.GET_CONFIGURATION:let s=Array.isArray(e.DeviceId)?e.DeviceId:[e.DeviceId],i=!0;for(let t of s)e.CAnsw[t].configuration||(i=!1);i?t.onSuccess&&t.onSuccess(e):t.onError&&t.onError(null,t.message);break;case w.i.GET_NRF_STATS:e.CAnsw&&e.CAnsw.stats?t.onSuccess&&t.onSuccess(e):t.onError&&t.onError(null,t.message);break;case w.k.AUTH_USER:e.CAnsw&&!e.CAnsw.Code?t.onSuccess&&t.onSuccess(e):t.onError&&t.onError(null,t.message);break;case w.a.B_INFO:e.CAnsw&&e.CAnsw[e.DeviceId[0]]&&e.CAnsw[e.DeviceId[0]].b_info?t.onSuccess&&t.onSuccess(e):t.onError&&t.onError(null,t.message);break;case w.a.B_BOOT_INFO:e.CAnsw&&e.CAnsw[e.DeviceId[0]]&&e.CAnsw[e.DeviceId[0]].boot_info?t.onSuccess&&t.onSuccess(e):t.onError&&t.onError(null,t.message);break;case w.a.B_BOOT_INFO_NRF:e.CAnsw&&e.CAnsw[e.DeviceId[0]]&&e.CAnsw[e.DeviceId[0]].boot_info_nrf?t.onSuccess&&t.onSuccess(e):t.onError&&t.onError(null,t.message);break;case w.a.B_NRF_STAT:e.CAnsw&&e.CAnsw[e.DeviceId[0]]&&e.CAnsw[e.DeviceId[0]].nrf_stat?t.onSuccess&&t.onSuccess(e):t.onError&&t.onError(null,t.message);break;case w.a.B_485_TOUT_R:e.CAnsw&&e.CAnsw[e.DeviceId[0]]&&e.CAnsw[e.DeviceId[0]].rs485_tout?t.onSuccess&&t.onSuccess(e):t.onError&&t.onError(null,t.message);break;case w.a.B_GET_SCAN_ADDR:e.CAnsw&&e.CAnsw[e.DeviceId[0]]&&e.CAnsw[e.DeviceId[0]].scan_addr?t.onSuccess&&t.onSuccess(e):t.onError&&t.onError(null,t.message);break;case w.i.GET_QUEUES_LAST_SUCCESS:e.CAnsw&&e.CAnsw.queues?t.onSuccess&&t.onSuccess(e):t.onError&&t.onError(null,t.message);break;case w.i.GET_PIGS_DATA:e.CAnsw&&(e.CAnsw.curveCfg||e.CAnsw.pigs)?t.onSuccess&&t.onSuccess(e):t.onError&&t.onError(null,t.message);break;case w.i.GET_ASCII_CLIMATE_TESTING_DATA:e.CAnsw&&e.CAnsw.data?t.onSuccess&&t.onSuccess(e):t.onError&&t.onError(null,t.message);break;case w.k.GET_FEED_RFID_STATE:e.CAnsw&&!e.CAnsw.status?t.onSuccess&&t.onSuccess(e):t.onError&&t.onError(null,t.message);break;case w.i.GET_ALL_ALARMS:case w.i.GET_ALL_ONGOING_ALARMS:t.onSuccess&&t.onSuccess(e);break;case w.i.GET_FEEDING_DATA_FOR_PIG:case w.i.GET_USAGE_FOR_PIG:console.log(e.CAnsw.result,null!==e.CAnsw.result),e.CAnsw&&Array.isArray(e.CAnsw)?t.onSuccess&&t.onSuccess(e):t.onError&&t.onError(null,t.message);break;case w.k.REFRESH_TOKEN:e.CAnsw&&e.CAnsw.token?t.onSuccess&&t.onSuccess(e):t.onError&&t.onError(null,t.message);break;case w.f.SET_SKIP_DOSES:if(e.CAnsw)if(Array.isArray(e.CAnsw.status)){let s=!0;for(let t of e.CAnsw.status)t&&(s=!1);s?t.onSuccess&&t.onSuccess(e):t.onError&&t.onError(null,t.message)}else 2===e.CAnsw.status?t.onSuccess&&t.onSuccess(e):t.onError&&t.onError(null,t.message);else t.onError&&t.onError(null,t.message);break;default:e.CAnsw&&(void 0!==e.CAnsw[e.DeviceId]&&(2!==e.CAnsw[e.DeviceId].status?t.onError&&t.onError(null,t.message):t.onSuccess&&t.onSuccess(e)),e.CAnsw.status&&(2!==e.CAnsw.status?t.onError&&t.onError(null,t.message):t.onSuccess&&t.onSuccess(e))),console.warn("Brak notyfikacji i nie rozpoznano komendy")}}this.waitedSetMessage=this.waitedSetMessage.filter(t=>t.message.MsgId!==e.MsgId)}checkCommandByType(e,t){try{let s=Array.isArray(e)?e:[e];for(let e=0;et.message.MsgId===e.MsgId).length>0}onStateMessageArrived(e,t){console.warn("NEW STATE MESSAGE",e,t);try{if(t.PktType===w.l.BIG_RESPONSE){if(r()(t.CAnsw)&&!t.CAnsw.status){let e=new Map;if(Object.keys(t.CAnsw).map(s=>{t.CAnsw[s].status||e.set(s,t.CAnsw[s])}),!a()(e))if(this.checkCommandByType(t.Command,w.k.GET_FULL_DEV_STATE))S.default.dispatch(Object(F.b)(e));else if(this.checkCommandByType(t.Command,w.k.GET_FULL_DEV_STATE_DELTA)){S.default.dispatch(Object(F.b)(e,!0));let s=[],i=S.default.getState().shadows.shadows;for(let e in t.CAnsw)i.get(e)||s.push(e);s.length>0&&this.startSendingDeviceState(s)}else this.checkCommandByType(t.Command,w.g.GET_DAILY_USAGE)?S.default.dispatch(Object(F.a)(e)):this.checkCommandByType(t.Command,w.g.GET_DAILY_USAGE_DELTA)?S.default.dispatch(Object(F.a)(e,!0)):this.checkCommandByType(t.Command,w.i.ADDRESS_DELTA)?S.default.dispatch(Object(x.a)(t.CAnsw)):this.checkCommandByType(t.Command,w.k.GET_FEED_STATE)?S.default.dispatch(Object(ne.j)(e)):this.checkCommandByType(t.Command,w.k.GET_FEED_RFID_STATE)?S.default.dispatch(Object(ne.l)(e)):this.checkCommandByType(t.Command,w.k.GET_FEED_STATE_DELTA)?S.default.dispatch(Object(ne.k)(e)):this.checkCommandByType(t.Command,w.k.GET_FEED_RFID_STATE_DELTA)?S.default.dispatch(Object(ne.m)(e)):this.checkCommandByType(t.Command,w.i.PING)&&S.default.dispatch(Object(me.a)(t,t.DeviceId[0]))}if(this.checkIfWaitedForThisMessage(t)){this.waitedSetMessage.find(e=>e.message.MsgId===t.MsgId).callback(null,t)}}if(t.PktType===w.l.LAMBDA){function s(){const e=S.default.getState(),{location:{farm:s},user:{user:i},task:{date:a}}=e;switch(t.Table){case w.j.ANIMALS:s&&S.default.dispatch(Object(Y.c)(s));break;case w.j.BUILDINGS:s&&S.default.dispatch(Object(Q.c)(s));break;case w.j.DEVICES:s&&S.default.dispatch(Object(x.c)(s));break;case w.j.DICTIONARY:i&&S.default.dispatch(Object(J.c)(i.ClientID));break;case w.j.EVENTS:s&&S.default.dispatch(Object(K.b)(s));break;case w.j.NOTIFICATIONS:i&&s&&S.default.dispatch(Object(X.b)(s,i.LocalUserID));break;case w.j.SETTINGS:i&&s&&S.default.dispatch(Object(Z.b)(i.ClientID,s));break;case w.j.TECHNO_GROUPS:s&&S.default.dispatch(Object($.c)(s));break;case w.j.USERS:i&&S.default.dispatch(Object(ee.f)(i.ClientID));break;case w.j.GROUPS:s&&S.default.dispatch(Object(ae.b)(s));break;case w.j.ATHENA:i&&s&&S.default.dispatch(Object(ue.n)(s,i.ClientID,i.LocalUserID));break;case w.j.SETTLEMENTS:s&&S.default.dispatch(Object(re.a)(s));break;case w.j.TRANSLATIONS:i&&t.LocalUserID!==i.LocalUserID&&(i.UserType===Ie.SERVICE||i.UserType===Ie.TRANSLATOR||i.Roles.find(e=>e.Role===De.TRANSLATION))&&S.default.dispatch(Object(le.e)([t.Language],!1));break;case w.j.CHANGE_CLIENT:t.FarmID!==s&&(S.default.dispatch({type:"REFRESH_TOKEN_FULFILLED",meta:{ClientID:t.ClientID}}),S.default.dispatch(Object(te.a)("/farmChooser")));break;case w.j.ITS:if(a){let e=+be.a.utc(a);t.CData.affectedDates.includes(e)&&S.default.dispatch(Object(ge.b)(e))}break;default:console.warn("Nie rozpoznano tabeli")}}"requestIdleCallback"in window?(console.log("JEST requestIdleCallback"),requestIdleCallback(s)):setTimeout(s,0)}}catch(i){console.error(i)}}onAggregatedDataMessageArrived(e,t){console.warn("NEW AGGREGATED DATA MESSAGE",t),S.default.dispatch({type:"AGGREGATED_DATA_MQTT",payload:t})}onAlarmsMessageArrived(e,t){console.warn("NEW ALARMS MESSAGE",t),(new N).onMessage(t)}onResponsesMessageArrived(e,t){if(console.warn("NEW RESPONSES MESSAGE",t),t.PktType===w.l.BIG_RESPONSE&&(t.Command&&!g()(t.Command)&&(t.Command=[t.Command]),S.default.dispatch({type:"TERMINAL_ADD_MESSAGE",payload:{[e]:t}}),t.Command&&this.checkCommands(t.Command)&&(console.log(""),this.checkIfWaitedForThisMessage(t)))){let e=this.waitedSetMessage.find(e=>e.message.MsgId===t.MsgId);console.log("waited",e),e.callback(null,t)}}onAuthMessageArrive(e,t){if(console.warn("NEW AUTH MESSAGE",t),t.PktType===w.l.BIG_RESPONSE&&t.Command&&this.checkCommands(t.Command)&&this.checkIfWaitedForThisMessage(t)){let e=this.waitedSetMessage.find(e=>e.message.MsgId===t.MsgId);t.CAnsw.code?e.callback(t.CAnsw,null):e.callback(null,t)}}collectMessage(e,t=""){if(!e.ChunksID)return t===w.p.AGGREGATED_DATA?this.decompressData(e.AggDt,t):this.decompressData(e.CAnsw,t);{let s=this.msgChunks.get(e.ChunksID);if(!s){let t=[].fill({},0,e.ChunksSize);return t[e.ChunksOffset]=e.CAnsw,this.msgChunks.set(e.ChunksID,t),null}{s[e.ChunksOffset]=e.CAnsw,this.msgChunks.set(e.ChunksID,s);let i=0;if(s.forEach(e=>{e!=={}&&i++}),i===e.ChunksSize){let e="";return s.map(t=>{e+=t}),this.decompressData(e,t)}}}}onMessageArrived(e,t){try{console.warn("NEW MESSAGE",e,t);let s,i=e.split("/")[1],a=JSON.parse(t.toString("utf-8"));if(a.CAnsw?(s=this.collectMessage(a,i),a.CAnsw=s):s=!0,s)switch(console.log("MSG COLLECTED",a),i){case w.p.AGGREGATED_DATA:this.onAggregatedDataMessageArrived(e,a);break;case w.p.ALARMS:this.onAlarmsMessageArrived(e,a);break;case w.p.RESPONSES:this.onResponsesMessageArrived(e,a);break;case w.p.STATE:this.onStateMessageArrived(e,a);break;case w.p.AUTH:this.onAuthMessageArrive(e,a);break;default:console.error("Nie rozpoznano kana\u0142u")}}catch(s){console.error("tutaj",s)}}};t.a=je},"4Rw3":function(e,t,s){"use strict";s.d(t,"a",(function(){return d})),s.d(t,"b",(function(){return m}));var i=s("JFDi"),a=s("fz41"),n=s("Bffz"),r=s("OwcS"),o=s("B6RA"),c=s("j1RV");function u(e,t){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),s.push.apply(s,i)}return s}function l(e,t,s){return t in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}function d(e,{FarmID:t,ClientID:s,LocalUserID:r}={}){const{_FarmID:o,_LocalUserID:c,_ClientID:d}=Object(i.a)({FarmID:t,ClientID:s,LocalUserID:r});return Object(a.c)(function(e){for(var t=1;t{if(Object.assign({},s),s.value.length>0){let e=[];Object.assign(e,s.value),await l.a.insertIntoBuildings(e)}t(T(e))}).catch(s=>{t(T(e)),console.error(s)})}}function T(e){return function(t){t({type:"GET_ALL_BUILDINGS",payload:l.a.getAllBuildingsForFarm(e)})}}function A(e){const t=c()(e);delete t.$loki,delete t.meta,delete t.location;for(let s=0;sn[e])[0];const D=n[o];if(!D)throw new Error("Nie znaleziono numeru po kt\xf3rym mam zidentyfikowa\u0107 lokalizacje");return"BgID"===o&&r.BgID===D?r=n:r.hasOwnProperty("Sectors")&&r.Sectors.forEach((e,t)=>{"SID"===o&&e.SID===D?r.Sectors[t]=n:e.hasOwnProperty("Chambers")&&e.Chambers.forEach((e,s)=>{"CID"===o&&e.CID===D?r.Sectors[t].Chambers[s]=n:e.hasOwnProperty("Boxes")&&e.Boxes.forEach((e,i)=>{"BID"===o&&e.BID===D&&(r.Sectors[t].Chambers[s].Boxes[i]=n)})})}),r=A(r),r.DtaModTime=(new Date).getTime(),function(e){e({type:"UPDATE_LOCATION",payload:Object(u.c)(b({},f.a.updateBuilding({farmID:r.FarmID}),{body:r}))}).then(s=>{t&&t(s),Object(d.c)("Zaktualizowano pomy\u015blnie",i),"CypressFarm1"===r.FarmID&&e(p(r.FarmID))}).catch(e=>{s&&s(e),Object(d.b)("B\u0142\u0105d aktualizacji",i)})}}function S(e,t,s){let i=Object(d.a)("Usuwanie lokalizacji",r()(e)?e.map(e=>Object(m.k)(e)).join(","):Object(m.k)(e)),a=l.a.getBuildingByLocationID(e.BgID||e.SID||e.CID||e.BID);if(!a)throw new Error("Nie znaleziono budynku dla danej lokalizacji");let n=c()(e),o=c()(a),D=["BgID","SID","CID","BID"].filter(e=>n[e])[0];const I=n[D];if(!I)throw new Error("Nie znaleziono numeru po kt\xf3rym mam zidentyfikowa\u0107 lokalizacje");return"BgID"===D&&o.BgID===I?o.DtaDelTime=+new Date:o.hasOwnProperty("Sectors")&&o.Sectors.forEach((e,t)=>{"SID"===D&&e.SID===I?o.Sectors.splice(t,1):e.hasOwnProperty("Chambers")&&e.Chambers.forEach((e,s)=>{"CID"===D&&e.CID===I?o.Sectors[t].Chambers.splice(s,1):e.hasOwnProperty("Boxes")&&e.Boxes.forEach((e,i)=>{"BID"===D&&e.BID===I&&o.Sectors[t].Chambers[s].Boxes.splice(i,1)})})}),o=A(o),function(e){e({type:"DELETE_LOCATION",payload:Object(u.c)(b({},f.a.updateBuilding({farmID:o.FarmID}),{body:o}))}).then(s=>{t&&t(s),Object(d.c)("Usuni\u0119to pomy\u015blnie",i),"CypressFarm1"===o.FarmID&&e(p(o.FarmID))}).catch(e=>{s&&s(e),Object(d.b)("B\u0142\u0105d usuwania",i)})}}function E(e,t,s,i){let n=Object(d.a)("Dodawanie lokalizacji",r()(e)?e.map(e=>Object(m.k)(e)).join(","):Object(m.k)(e)),o=Object(D.b)(I.default.getState(),t);if(o)return function(t){t({type:"ADD_LOCATION",payload:Object(u.c)(b({},f.a.createBuilding(),{body:e}))}).then(e=>{s&&s(e),Object(d.c)("Dodano pomy\u015blnie",n),"CypressFarm1"===o.FarmID&&t(p(o.FarmID))}).catch(e=>{i&&i(e),Object(d.b)("B\u0142\u0105d dodawania",n)})};{let o=l.a.getBuildingByLocationID(t);if(!o)throw new Error("Nie znaleziono budynku dla danej lokalizacji");let m=c()(e);r()(m)||(m=[m]);let D=c()(o);if(!t)throw new Error("Nie znaleziono numeru po kt\xf3rym mam zidentyfikowa\u0107 lokalizacje");if(D.BgID===t){let e=a()(D,"Sectors",[]);e.push(...m),D.Sectors=e}else D.hasOwnProperty("Sectors")&&D.Sectors.forEach((e,s)=>{if(e.SID===t){let t=a()(e,"Chambers",[]);t.push(...m),D.Sectors[s].Chambers=t}else e.hasOwnProperty("Chambers")&&e.Chambers.forEach((e,i)=>{if(e.CID===t){if(!e.IndividualFeeding)throw new Error("Komora z grupowym karmieniem nie mo\u017ce mie\u0107 stanowisk");let t=a()(e,"Boxes",[]);t.push(...m),D.Sectors[s].Chambers[i].Boxes=t}else e.hasOwnProperty("Boxes")&&e.Boxes.forEach(e=>{if(e.BID===t)throw new Error("Box to najni\u017csza lokalizacja i nie mo\u017ce by\u0107 rodzicem")})})});return D=A(D),function(e){e({type:"ADD_LOCATION",payload:Object(u.c)(b({},f.a.updateBuilding(),{body:D}))}).then(t=>{s&&s(t),Object(d.c)("Dodano pomy\u015blnie",n),"CypressFarm1"===D.FarmID&&e(p(D.FarmID))}).catch(e=>{i&&i(e),Object(d.b)("B\u0142\u0105d dodawania",n)})}}}},"5Z9N":function(e,t,s){"use strict";s.d(t,"e",(function(){return T})),s.d(t,"a",(function(){return A})),s.d(t,"c",(function(){return y})),s.d(t,"d",(function(){return S})),s.d(t,"b",(function(){return E}));var i=s("BkRI"),a=s.n(i),n=s("lSCD"),r=s.n(n),o=s("fz41"),c=s("j1RV"),u=s("B6RA"),l=s("10H7"),d=s("17UY"),m=s("Bffz"),f=s("ehum"),D=s("XzT5");function I(e,t){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),s.push.apply(s,i)}return s}function O(e){for(var t=1;t{a.title=D.a.t("success"),a.message=D.a.t("popNotifications.changesSaved"),a.status="success",a.dismissible=!0,a.dismissAfter=3e3,u.default.dispatch(Object(c.addNotification)(a)),r()(i)&&i()}).catch(e=>{a.title=D.a.t("error"),a.message=e+"",a.status="error",a.dismissible=!0,a.dismissAfter=3e3,u.default.dispatch(Object(c.addNotification)(a))})}}function A(e,t,s=!0,i={},a=(()=>{}),n=(()=>{})){return function(s){const r=new g;e.events.forEach(e=>{if(!r.validate(f.EventSchema,e))throw console.error("AJV ERROR:",r.errors),new Error("Event is not valid.")}),s({type:"CREATE_EVENT",payload:Object(o.c)(O({},m.a.createEvent(),{body:e}))}).then(()=>{t&&t.hideModal&&t.hideModal();let n=D.a.t("animalsActions.successfullyAdded");t.type===l.b.FALL&&(n+=D.a.t("fall")),t.type===l.b.TRANSFER&&(n+=D.a.t("transfer")),t.type===l.b.SELL&&(n+=D.a.t("sale")),t.type===l.b.GRAFTING&&(n+=D.a.t("animalsActions.grafting")),t.type===l.b.INSEMINATION&&(n+=D.a.t("animalsActions.insemination")),t.type===l.b.NO_PREGNANCY&&(n+=D.a.t("noPregnancy")),t.type===l.b.PARTURITION&&(n+=D.a.t("birth")),t.type===l.b.SEPARATION_TO_MOMMY&&(n+=D.a.t("animalsActions.mommy")),t.type===l.b.USG&&(n+=D.a.t("usgResult")),t.type===l.b.SEPARATION&&(n+=D.a.t("animalsActions.separation")),t.type===l.b.JOIN&&(n+=D.a.t("animalsActions.merge")),t.type===l.b.CHANGE_CURVE&&(n+=D.a.t("animalsActions.curveChange")),t.type===l.b.MOMMY&&(n+=D.a.t("animalsActions.assignmentMommy")),t.type===l.b.CONDITION&&(n+=D.a.t("animalsActions.condition")),t.type===l.b.INCIDENT&&(n+=D.a.t("animalsActions.incident")),t.type===l.b.SELECTION&&(n+=D.a.t("animalsActions.selection")),t.type===l.b.TREATMENT&&(n+=D.a.t("animalsActions.grafting")),t.type===l.b.WEIGHTING&&(n+=D.a.t("weighting")),t.type===l.b.ACTIVE_NIPPLES&&(n+=D.a.t("activeNipplesAmount")),t.type===l.b.HEAT&&(n+=D.a.t("animalsActions.heat")),t.type===l.b.SOW_CYCLES&&(n+=D.a.t("animalsActions.sow_Cycles")),i=O({},i,{title:D.a.t("success"),message:n,status:"success",dismissible:!0,dismissAfter:3e3}),s(Object(c.addNotification)(i)),d.a.insertIntoEvents(e.events),a()}).catch(e=>{console.error(e),n()}),s({type:"CREATE_EVENT_TMP",payload:e})}}function y(e,t){return function(s){if(e){let i={FarmID:e.FarmID,AnmID:e.AnmID,partial:!0};t&&(i.DtaModTime=0,i.ESKDtaModTime=t.DtaModTime,i.ESKEvID=t.EvID),s({type:"LIST_EVENT_4_ANM",payload:Object(o.c)(O({},m.a.listEvent({farmID:e.FarmID}),{queryParams:i})),meta:{AnmID:e.AnmID,animal:e}}).then(async t=>{t.value.LastEvaluatedKey&&s(y(e,t.value.LastEvaluatedKey)),s({type:"LIST_EVENT_4_ANIMAL_FULFILLED",payload:t.value,meta:{AnmID:e.AnmID,animal:e}})}).catch(t=>{console.error(t),s({type:"LIST_EVENT_4_ANIMAL_FULFILLED",payload:{items:d.a.getAllEvents4Animal(e.AnmID)},meta:{AnmID:e.AnmID,animal:e}})}),s({type:"LIST_EVENT_4_ANIMAL_LOADING",payload:e.AnmID})}else s({type:"SET_ALL_ANIMALS_EMPTY"})}}function S(e,{FarmID:t=u.default.getState().location.farm,meta:s={}}={}){return function(i){console.log(t,e),i({type:"LIST_EVENTS_FOR_ANIMALS",payload:Object(o.c)(O({},m.a.listEventsForAnimals(),{body:{AnmIDs:e},queryParams:{FarmID:t}})),meta:O({},s,{AnmIDs:e})}),i({type:"LIST_EVENT_4_ANIMALS_LOADING",payload:e})}}function E(e,t){return function(s){let i={FarmID:e,DtaModTime:d.a.getModificationTime(e).DtaModTime,partial:!0};t&&(i.DtaModTime=0,i.ESKDtaModTime=t.DtaModTime,i.ESKEvID=t.EvID),s({type:"LIST_EVENT",payload:Object(o.c)(O({},m.a.listEvent({farmID:e}),{queryParams:i}))}).then(async t=>{if(Object.assign({},t),t.value.items&&t.value.items.length>0){let i=[];Object.assign(i,t.value.items),await d.a.insertIntoEvents(i),s(p(e))}t.value.LastEvaluatedKey&&s(E(e,t.value.LastEvaluatedKey))}).catch(t=>{console.error(t),s(p(e))})}}},"5tUy":function(e,t,s){"use strict";s.d(t,"a",(function(){return d})),s.d(t,"c",(function(){return m})),s.d(t,"b",(function(){return f}));var i=s("JFDi"),a=s("fz41"),n=s("Bffz"),r=s("OwcS"),o=s("B6RA"),c=s("j1RV");function u(e,t){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),s.push.apply(s,i)}return s}function l(e,t,s){return t in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}function d(e,{FarmID:t,ClientID:s,LocalUserID:r}={}){const{_FarmID:o,_LocalUserID:c,_ClientID:d}=Object(i.a)({FarmID:t,ClientID:s,LocalUserID:r});return Object(a.c)(function(e){for(var t=1;t{if(Object.assign({},s),s.value.length>0){let e=[];Object.assign(e,s.value),await a.a.insertIntoDevices(e)}t(g(e))}).catch(s=>{t(g(e))})}}function O(e,t,s=null){let m=Object(n.e)(e);return function(n){n({type:"CREATE_DEVICE",payload:Object(i.c)(f({},r.a.createDevices({farmID:t}),{body:m,queryParams:{table:u.DEVICES}}))}).then(()=>{const t={title:l.a.t("success"),message:l.a.t("popNotifications.added"),status:"success",dismissible:!0,dismissAfter:3e3};n(Object(d.addNotification)(t)),s&&s();let i=Array.isArray(e)?e:[e],r=new Map;for(let e of i){let t=e;e.DevType!==c.d.BROADCAST&&e.DevType!==c.d.DI_TIME&&e.DevType!==c.d.BRIDGE_CONF&&e.DevType!==c.d.BRIDGE_WORK||(t=i.find(e=>e.DevType===c.d.BRIDGE)||a.a.getDeviceByID(e.ParentID));let s=a.a.getGateway(t),n=r.get(s.DevID)||[];n.push(e),r.set(s.DevID,n)}for(let[e,s]of r.entries())Object(o.B)(e,s.map(e=>e.DevID))}).catch(e=>{console.error(e);const t={title:l.a.t("error"),message:e.message,status:"error",dismissible:!0,dismissAfter:3e3};n(Object(d.addNotification)(t))}),n({type:"CREATE_DEVICE",payload:m})}}function b(e,t,s,c,u,l,d=!0){let m=Object(n.e)(e);return function(n){n({type:"UPDATE_DEVICE",payload:Object(i.c)(f({},r.a.updateDevices({farmID:t,clientID:s,localUserID:c}),{method:"PUT",body:m,queryParams:{table:"Devices"}}))}).then(()=>{u&&u.success&&u.success(),l&&l();let t=Array.isArray(e)?e:[e],s=new Map;for(let e of t)try{let t=a.a.getGateway(e),i=s.get(t.DevID)||[];i.push(e),s.set(t.DevID,i)}catch(i){console.error(i)}for(let[e,a]of s.entries())Object(o.B)(e,a.map(e=>e.DevID),d)}).catch(()=>{u&&u.error&&u.error()}),n({type:"UPDATE_DEVICE",payload:m})}}function g(e){return function(t){t({type:"GET_DEVICES",payload:a.a.getDevices(e)})}}function p(e){return function(t){t({type:"CHANGE_ADDRESSING_STATE",payload:e})}}function T(e,t,s,n,c,u,l=!0){return function(d){d({type:"UPDATE_DEVICE_PARAMS",payload:Object(i.c)(f({},r.a.deviceParam({farmID:t,clientID:s,localUserID:n}),{body:{params:e}}))}).then(()=>{let t=new Map;for(let s of e){let e=a.a.getDeviceByID(s.DevID),i=t.get(e.GatewayID)||new Set;i.add(e.DevID),t.set(e.GatewayID,i)}for(let[e,s]of t.entries())Object(o.B)(e,[...s.values()],l);c&&c.success&&c.success(),u&&u()}).catch(()=>{c&&c.error&&c.error()})}}},"8Fj4":function(e,t,s){"use strict";function i(e){return function(t){t({type:"CHANGE_FARM",payload:e})}}function a(e){return function(t){t({type:"SHOW_HIDE_NAV_MENU_ELEMENT",payload:e})}}s.d(t,"a",(function(){return i})),s.d(t,"b",(function(){return a}))},"99/+":function(e,t,s){"use strict";s.d(t,"d",(function(){return o})),s.d(t,"b",(function(){return c})),s.d(t,"c",(function(){return u})),s.d(t,"a",(function(){return l}));var i=s("4qC0"),a=s.n(i),n=s("Z0cm"),r=s.n(n);function o(e,t){return function(s){s({type:"MAIN_TAB_TOGGLE",payload:{type:"selected",key:e,id:a()(t)?t:null}})}}function c(e,t=!1,s=[]){return function(i){i({type:"MAIN_TAB_SET_IDS",payload:{type:"selected",key:e,select:!!t,ids:r()(s)?s:a()(s)?[s]:[]}})}}function u(e,t){return function(s){s({type:"MAIN_TAB_TOGGLE",payload:{type:"expanded",key:e,id:a()(t)?t:null}})}}function l(e){return function(t){t({type:"MAIN_TAB_CLEAR",payload:e})}}},"9PNC":function(e,t,s){"use strict";s.d(t,"a",(function(){return m})),s.d(t,"c",(function(){return f})),s.d(t,"b",(function(){return D}));var i=s("fz41"),a=s("JFDi"),n=s("j1RV"),r=s("OwcS"),o=s("B6RA"),c=s("Bffz"),u=s("XzT5");function l(e,t){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),s.push.apply(s,i)}return s}function d(e,t,s){return t in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}function m(e,{FarmID:t,ClientID:s,LocalUserID:n}={}){const{_FarmID:r,_LocalUserID:o,_ClientID:u}=Object(a.a)({FarmID:t,ClientID:s,LocalUserID:n});return Object(i.c)(function(e){for(var t=1;t{let f=r.default.getState(),D=new u.a;D.postMessage({FarmID:e,array:t,plan:s,before:i,fromTime:a.toDate().getTime(),days:n,user:f.user.user,isService:Object(o.i)(),sub:f.user.attributes.sub,language:f.language,year:c,animalsMap:l}),D.onmessage=e=>{"ERROR"===e.data.type&&m(e.data.error),d(e.data.data)},r.default.dispatch(function(e,t){return function(s){s({type:"ADD_WORKER",meta:e,payload:t})}}("resultGrid",D))})}function d(e,t,s,i,a,n,r,o){return function(c){c({type:"SET_RESULTS_GRID_DATA",payload:l(e,t,s,i,a,n,r,o)})}}},A5yn:function(e,t,s){"use strict";function i(e,t={}){return function(s){s({type:"FEEDING_INITIALIZE",payload:{id:e.CID,chamber:e,options:t}})}}function a(e){return function(t){t({type:"FEEDING_DESTROY",payload:{id:e.CID}})}}function n(e,t){return function(s){s({type:"FEEDING_SELECT",payload:{chamberId:e.CID,id:t}})}}function r(e){return function(t){t({type:"FEEDING_SELECT_ALL",payload:{chamberId:e.CID}})}}function o(e){return function(t){t({type:"FEEDING_SELECT_NONE",payload:{chamberId:e.CID}})}}function c(e,t){return function(s){s({type:"FEEDING_FILTER",payload:{chamberId:e.CID,feedingFilter:t}})}}function u(e,t){return function(s){s({type:"FEEDING_SORT",payload:{chamberId:e.CID,feedingSort:t}})}}function l(e,t={}){return function(s){s({type:"FEEDING_UPDATE_ANIMALS",payload:{chamber:e,chamberId:e.CID,options:t}})}}function d(e){return function(t){t({type:"GET_FEED_STATE",payload:e})}}function m(e){return function(t){t({type:"GET_FEED_STATE_DELTA",payload:e})}}function f(e){return function(t){t({type:"GET_FEED_RFID_STATE",payload:e})}}function D(e){return function(t){t({type:"GET_FEED_RFID_STATE_DELTA",payload:e})}}function I(){return function(e){e({type:"FEEDING_CLEAR"})}}s.d(t,"d",(function(){return i})),s.d(t,"b",(function(){return a})),s.d(t,"e",(function(){return n})),s.d(t,"f",(function(){return r})),s.d(t,"h",(function(){return o})),s.d(t,"c",(function(){return c})),s.d(t,"g",(function(){return u})),s.d(t,"i",(function(){return l})),s.d(t,"j",(function(){return d})),s.d(t,"k",(function(){return m})),s.d(t,"l",(function(){return f})),s.d(t,"m",(function(){return D})),s.d(t,"a",(function(){return I}))},AF5L:function(e,t,s){"use strict";s.d(t,"s",(function(){return l})),s.d(t,"u",(function(){return d})),s.d(t,"q",(function(){return m})),s.d(t,"o",(function(){return f})),s.d(t,"b",(function(){return D})),s.d(t,"a",(function(){return I})),s.d(t,"A",(function(){return O})),s.d(t,"z",(function(){return b})),s.d(t,"y",(function(){return g})),s.d(t,"k",(function(){return p})),s.d(t,"m",(function(){return T})),s.d(t,"n",(function(){return A})),s.d(t,"B",(function(){return y})),s.d(t,"g",(function(){return S})),s.d(t,"t",(function(){return E})),s.d(t,"j",(function(){return j})),s.d(t,"i",(function(){return h})),s.d(t,"e",(function(){return C})),s.d(t,"v",(function(){return v})),s.d(t,"w",(function(){return _})),s.d(t,"d",(function(){return w})),s.d(t,"c",(function(){return N})),s.d(t,"p",(function(){return P})),s.d(t,"x",(function(){return M})),s.d(t,"h",(function(){return R})),s.d(t,"l",(function(){return F})),s.d(t,"f",(function(){return L})),s.d(t,"r",(function(){return U}));var i=s("lSCD"),a=s.n(i),n=s("/kok"),r=s("IBmF"),o=(s("B6RA"),s("Q2bl")),c=(s("RRbG"),s("kiXb")),u=s("XzT5");function l(e,t,s,i,a){const{ClientID:c,LocalUserID:l,GatewayID:d,Name:m,isValid:f}=Object(o.a)(e);if(f&&t&&t.convertToBackend)return n.a.createAndSendMessageObject(c,d,l,d,r.g.SET_NUTRITION_CURVE,t.convertToBackend(s),{loading:{title:u.a.t("feedingCurve"),message:u.a.t("IOT.setTheFeedingCurveOnAllDevicesUnder",{name:m}),status:"loading",dismissible:!1,dismissAfter:0},success:{message:u.a.t("IOT.setTheFeedingCurveOnAllDevicesUnderDone",{name:m}),dismissible:!0,dismissAfter:3e3,status:"success"},error:{message:u.a.t("IOT.setTheFeedingCurveOnAllDevicesUnderFailed",{name:m}),dismissible:!0,dismissAfter:3e3,status:"error"},DevID:d},i,a)}function d(e,t,s){const{ClientID:i,LocalUserID:a,GatewayID:c,Name:l,isValid:d}=Object(o.a)(e);if(d&&t&&t.convertToBackend)return n.a.createAndSendMessageObject(i,c,a,c,r.g.SET_SCHEDULE,t.convertToBackend(s),{loading:{title:u.a.t("schedule"),message:u.a.t("IOT.setScheduleOnAllDevicesUnder",{name:l}),status:"loading",dismissible:!1,dismissAfter:0},success:{message:u.a.t("IOT.setScheduleOnAllDevicesUnderDone",{name:l}),dismissible:!0,dismissAfter:3e3,status:"success"},error:{message:u.a.t("IOT.setScheduleOnAllDevicesUnderFailed",{name:l}),dismissible:!0,dismissAfter:3e3,status:"error"},DevID:c})}function m(e,t){const{ClientID:s,LocalUserID:i,GatewayID:a,Name:c,isValid:l}=Object(o.a)(e);if(l&&t&&t.convertToBackend)return console.log(t),n.a.createAndSendMessageObject(s,a,i,a,r.g.SET_FEED_EFC_TIME,t.convertToBackend(),{loading:{title:u.a.t("configuration"),message:u.a.t("IOT.setEfficiencyTime",{name:c}),status:"loading",dismissible:!1,dismissAfter:0},success:{message:u.a.t("IOT.setEfficiencyTimeDone",{name:c}),dismissible:!0,dismissAfter:3e3,status:"success"},error:{message:u.a.t("IOT.setEfficiencyTimeFailed",{name:c}),dismissible:!0,dismissAfter:3e3,status:"error"},DevID:a})}function f(e,t={},s,i){const{ClientID:a,LocalUserID:c,GatewayID:u,isValid:l}=Object(o.a)(e);if(l)return n.a.createAndSendMessageObject(a,u,c,u,r.g.SET_CHAMBER_DEVICES,t,null,s,i)}function D(e,t,s,i){const{ClientID:a,LocalUserID:u,GatewayID:l,Name:d,isValid:m}=Object(o.a)(e);if(m)return n.a.createAndSendMessageObject(a,l,u,l,r.i.START_ADR_WST,t,{loading:{title:c.a.t("IOT.addressing"),message:c.a.t("IOT.startAddressing",{name:d}),status:"loading",dismissible:!1,dismissAfter:0},success:{message:c.a.t("IOT.startAddressingDone",{name:d}),dismissible:!0,dismissAfter:3e3,status:"success"},error:{message:c.a.t("IOT.startAddressingFailed",{name:d}),dismissible:!0,dismissAfter:3e3,status:"error"},DevID:l},s,i)}function I(e,t,s,i){const{ClientID:a,LocalUserID:u,GatewayID:l,Name:d,isValid:m}=Object(o.a)(e);if(m)return n.a.createAndSendMessageObject(a,l,u,l,r.i.START_ADDRESSING_NRF,t,{loading:{title:c.a.t("IOT.addressing"),message:c.a.t("IOT.startAddressing",{name:d}),status:"loading",dismissible:!1,dismissAfter:0},success:{message:c.a.t("IOT.startAddressingDone",{name:d}),dismissible:!0,dismissAfter:3e3,status:"success"},error:{message:c.a.t("IOT.startAddressingFailed",{name:d}),dismissible:!0,dismissAfter:3e3,status:"error"},DevID:l},s,i)}function O(e,t,s,i){const{ClientID:a,LocalUserID:u,GatewayID:l,Name:d,isValid:m,DevID:f}=Object(o.a)(e);if(m)return n.a.createAndSendMessageObject(a,l,u,f,r.i.ADDR_START_SUBADDRESSING_NRF,{state:t?1:0},{loading:{title:c.a.t("IOT.addressing"),message:t?c.a.t("IOT.startSubAddressing",{name:d}):c.a.t("IOT.stopSubAddressing",{name:d}),status:"loading",dismissible:!1,dismissAfter:0},success:{message:t?c.a.t("IOT.startSubAddressingDone",{name:d}):c.a.t("IOT.stopSubAddressingDone",{name:d}),dismissible:!0,dismissAfter:3e3,status:"success"},error:{message:t?c.a.t("IOT.startSubAddressingFailed",{name:d}):c.a.t("IOT.stopSubAddressingFailed",{name:d}),dismissible:!0,dismissAfter:3e3,status:"error"},DevID:f},s,i)}function b(e,t,s){const{ClientID:i,LocalUserID:a,GatewayID:u,Name:l,isValid:d}=Object(o.a)(e);if(d)return n.a.createAndSendMessageObject(i,u,a,u,r.i.STOP_ADR_WST,null,{loading:{title:c.a.t("IOT.addressing"),message:c.a.t("IOT.stopAddressing",{name:l}),status:"loading",dismissible:!1,dismissAfter:0},success:{message:c.a.t("IOT.stopAddressingDone",{name:l}),dismissible:!0,dismissAfter:3e3,status:"success"},error:{message:c.a.t("IOT.stopAddressingFailed",{name:l}),dismissible:!0,dismissAfter:3e3,status:"error"},DevID:u},t,s)}function g(e,t,s){const{ClientID:i,LocalUserID:a,GatewayID:u,Name:l,isValid:d}=Object(o.a)(e);if(d)return n.a.createAndSendMessageObject(i,u,a,u,r.i.STOP_ADDRESSING_NRF,null,{loading:{title:c.a.t("IOT.addressing"),message:c.a.t("IOT.stopAddressing",{name:l}),status:"loading",dismissible:!1,dismissAfter:0},success:{message:c.a.t("IOT.stopAddressingDone",{name:l}),dismissible:!0,dismissAfter:3e3,status:"success"},error:{message:c.a.t("IOT.stopAddressingFailed",{name:l}),dismissible:!0,dismissAfter:3e3,status:"error"},DevID:u},t,s)}function p(e,t,s){const{ClientID:i,LocalUserID:a,GatewayID:c,isValid:u}=Object(o.a)(e);if(u)return n.a.createAndSendMessageObject(i,c,a,c,r.i.GET_GATEWAY_TIME,null,null,t,s)}function T(e,t){const{ClientID:s,LocalUserID:i,GatewayID:a,isValid:c,Name:l}=Object(o.a)(e);if(c)return n.a.createAndSendMessageObject(s,a,i,a,r.i.OPEN_SSH,{port:t},{loading:{title:u.a.t("IOT.openSSH"),message:u.a.t("IOT.openSSH",{name:l}),status:"loading",dismissible:!1,dismissAfter:0},success:{message:u.a.t("IOT.openSSHSuccess",{name:l}),dismissible:!0,dismissAfter:3e3,status:"success"},error:{message:u.a.t("IOT.openSSHFailure",{name:l}),dismissible:!0,dismissAfter:3e3,status:"error"},DevID:a})}function A(e,t,s,i){const{ClientID:a,LocalUserID:c,GatewayID:u,isValid:l}=Object(o.a)(e);if(l)return n.a.createAndSendMessageObject(a,u,c,u,r.i.PING,null,null,t,s,i)}function y(e,t,s){const{ClientID:i,LocalUserID:a,GatewayID:c,Name:l,isValid:d}=Object(o.a)(e);if(d)return n.a.createAndSendMessageObject(i,c,a,c,r.g.SET_SYNC_DEVICES,{devices:t},s&&{loading:{title:u.a.t("IOT.syncDevices"),message:u.a.t("IOT.syncDevicesText",{name:l}),status:"loading",dismissible:!1,dismissAfter:0},success:{message:u.a.t("IOT.syncDevicesSuccess",{name:l}),dismissible:!0,dismissAfter:3e3,status:"success"},error:{message:u.a.t("IOT.syncDevicesFailure",{name:l}),dismissible:!0,dismissAfter:3e3,status:"error"},DevID:c})}function S(e,t,s,i){const{ClientID:a,LocalUserID:c,GatewayID:u,isValid:l}=Object(o.a)(e);if(l)return n.a.createAndSendMessageObject(a,u,c,u,r.i.GET_NRF_STATS,{DevID:t},null,s,i)}function E(e,t){const{ClientID:s,LocalUserID:i,GatewayID:a,Name:c,isValid:l}=Object(o.a)(e);if(l)return n.a.createAndSendMessageObject(s,a,i,a,r.i.SET_PLCMNTS,t,{loading:{title:u.a.t("IOT.setPlcmnts"),message:u.a.t("IOT.setPlcmntText",{name:c}),status:"loading",dismissible:!1,dismissAfter:0},success:{message:u.a.t("IOT.setPlcmntSuccess",{name:c}),dismissible:!0,dismissAfter:3e3,status:"success"},error:{message:u.a.t("IOT.setPlcmntFailure",{name:c}),dismissible:!0,dismissAfter:3e3,status:"error"},DevID:a})}function j(e,t,s=(()=>{}),i=(()=>{}),a=(()=>{})){const{ClientID:c,LocalUserID:l,GatewayID:d,Name:m,isValid:f}=Object(o.a)(e);if(f)return n.a.createAndSendMessageObject(c,d,l,d,r.i.GET_SCHEMA,{type:t||"DI_NRF"},{loading:{title:u.a.t("IOT.getSchema"),message:u.a.t("IOT.getSchemaText",{name:m}),status:"loading",dismissible:!1,dismissAfter:0},success:{message:u.a.t("IOT.getSchemaSuccess",{name:m}),dismissible:!0,dismissAfter:3e3,status:"success"},error:{message:u.a.t("IOT.getSchemaFailure",{name:m}),dismissible:!0,dismissAfter:3e3,status:"error"},DevID:d},i,a,s)}function h(e,t,s){const{ClientID:i,LocalUserID:a,GatewayID:c,isValid:u}=Object(o.a)(e);if(u)return n.a.createAndSendMessageObject(i,c,a,c,r.i.GET_QUEUES_LAST_SUCCESS,null,null,t,s)}function C(e,t,s,i,a){const{ClientID:c,LocalUserID:u,GatewayID:l,isValid:d}=Object(o.a)(e);if(d)return n.a.createAndSendMessageObject(c,l,u,l,r.i.GET_ASCII_CLIMATE_TESTING_DATA,{start:t,stop:s,granularity:i},null,a)}function v(e,t,s=(()=>{}),i=(()=>{}),a=(()=>{})){const{ClientID:c,LocalUserID:l,GatewayID:d,Name:m,isValid:f}=Object(o.a)(e);if(f)return n.a.createAndSendMessageObject(c,d,l,d,r.i.SET_SCHEDULE_OUTPUT,t,{loading:{title:u.a.t("IOT.setScheduleOutput"),message:u.a.t("IOT.setScheduleOutputText",{name:m}),status:"loading",dismissible:!1,dismissAfter:0},success:{message:u.a.t("IOT.setScheduleOutputSuccess",{name:m}),dismissible:!0,dismissAfter:3e3,status:"success"},error:{message:u.a.t("IOT.setScheduleOutputError",{name:m}),dismissible:!0,dismissAfter:3e3,status:"error"},DevID:d},i,a,s)}function _(e,t,s=(()=>{}),i=(()=>{}),a=(()=>{})){const{ClientID:c,LocalUserID:l,GatewayID:d,Name:m,isValid:f}=Object(o.a)(e);if(f)return n.a.createAndSendMessageObject(c,d,l,d,r.i.SET_SCHEDULE_OUTPUT_MODE,t,{loading:{title:u.a.t("IOT.setScheduleOutputMode"),message:u.a.t("IOT.setScheduleOutputModeText",{name:m}),status:"loading",dismissible:!1,dismissAfter:0},success:{message:u.a.t("IOT.setScheduleOutputModeSuccess",{name:m}),dismissible:!0,dismissAfter:3e3,status:"success"},error:{message:u.a.t("IOT.setScheduleOutputModeError",{name:m}),dismissible:!0,dismissAfter:3e3,status:"error"},DevID:d},i,a,s)}function w(e,{DeviceIDs:t}={},{onSend:s,onSuccess:i,onFailure:a}={}){const{ClientID:c,LocalUserID:l,GatewayID:d,Name:m,isValid:f}=Object(o.a)(e);if(f)return n.a.createAndSendMessageObject(c,d,l,d,r.i.SET_CLEAR_PROBLEM,{DeviceIDs:t},{loading:{title:u.a.t("IOT.clearDispenserNRFAlarm"),message:u.a.t("IOT.clearDispenserNRFAlarmText",{name:m}),status:"loading",dismissible:!1,dismissAfter:0},success:{message:u.a.t("IOT.clearDispenserNRFAlarmSuccess",{name:m}),dismissible:!0,dismissAfter:3e3,status:"success"},error:{message:u.a.t("IOT.clearDispenserNRFAlarmError",{name:m}),dismissible:!0,dismissAfter:3e3,status:"error"},DevID:d},i,a,s)}function N(e,{devices:t}={},{onSend:s,onSuccess:i,onFailure:a}={}){const{ClientID:c,LocalUserID:l,GatewayID:d,Name:m,isValid:f}=Object(o.a)(e);if(f)return n.a.createAndSendMessageObject(c,d,l,d,r.i.SET_CHANGE_DISPENSERS_DOSE_CORRECTION,{devices:t},{loading:{title:u.a.t("IOT.setChangeDispensersDoseCorrection"),message:u.a.t("IOT.setChangeDispensersDoseCorrectionText",{name:m}),status:"loading",dismissible:!1,dismissAfter:0},success:{message:u.a.t("IOT.setChangeDispensersDoseCorrectionSuccess",{name:m}),dismissible:!0,dismissAfter:3e3,status:"success"},error:{message:u.a.t("IOT.setChangeDispensersDoseCorrectionError",{name:m}),dismissible:!0,dismissAfter:3e3,status:"error"},DevID:d},i,a,s)}function P(e,{devices:t}={},{onSend:s,onSuccess:i,onFailure:a}={}){const{ClientID:c,LocalUserID:l,GatewayID:d,Name:m,isValid:f}=Object(o.a)(e);if(f)return n.a.createAndSendMessageObject(c,d,l,d,r.i.SET_DISPENSERS_DOSE_CORRECTION,{devices:t},{loading:{title:u.a.t("condition"),message:u.a.t("IOT.setConditionText",{name:m}),status:"loading",dismissible:!1,dismissAfter:0},success:{message:u.a.t("IOT.setConditionSuccess",{name:m}),dismissible:!0,dismissAfter:3e3,status:"success"},error:{message:u.a.t("IOT.setConditionError",{name:m}),dismissible:!0,dismissAfter:3e3,status:"error"},DevID:d},i,a,s)}function M(e,{devices:t}={},{onSend:s,onSuccess:i,onFailure:a}={}){const{ClientID:c,LocalUserID:l,GatewayID:d,Name:m,isValid:f}=Object(o.a)(e);if(f)return n.a.createAndSendMessageObject(c,d,l,d,r.i.SET_SKIP_DOSES_IN_TIME,{devices:t},{loading:{title:u.a.t("IOT.skipDose"),message:u.a.t("IOT.setSkipDose",{name:m}),status:"loading",dismissible:!1,dismissAfter:0},success:{message:u.a.t("IOT.setSkipDoseDone",{name:m}),dismissible:!0,dismissAfter:3e3,status:"success"},error:{message:u.a.t("IOT.setSkipDoseFailed",{name:m}),dismissible:!0,dismissAfter:3e3,status:"error"},DevID:d},i,a,s)}function R(e,{limit:t=1e3}={},{onSend:s,onSuccess:i,onFailure:c}={}){const{ClientID:u,LocalUserID:l,GatewayID:d,isValid:m}=Object(o.a)(e);if(m)return n.a.createAndSendMessageObject(u,d,l,d,r.i.GET_ALL_ONGOING_ALARMS,{limit:t},void 0,i,c,s);a()(c)&&c()}function F(e,t,s,i){const{ClientID:a,LocalUserID:c,GatewayID:u,isValid:l}=Object(o.a)(e);if(l)return n.a.createAndSendMessageObject(a,u,c,u,r.i.GET_USAGE_FOR_PIG,t,null,s,i)}function L(e,t,s,i){const{ClientID:a,LocalUserID:c,GatewayID:u,isValid:l}=Object(o.a)(e);if(l)return n.a.createAndSendMessageObject(a,u,c,u,r.i.GET_FEEDING_DATA_FOR_PIG,t,null,s,i)}function U(e,t){const{ClientID:s,LocalUserID:i,GatewayID:a,Name:u,isValid:l}=Object(o.a)(e);if(l)return n.a.createAndSendMessageObject(s,a,i,a,r.i.SET_NEW_INSERTION,t,{loading:{title:c.a.t("IOT.setNewInsertionTitle"),message:c.a.t("IOT.setNewInsertion",{name:u}),status:"loading",dismissible:!1,dismissAfter:0},success:{message:c.a.t("IOT.setNewInsertionSuccess",{name:u}),dismissible:!0,dismissAfter:3e3,status:"success"},error:{message:c.a.t("IOT.setNewInsertionFailed",{name:u}),dismissible:!0,dismissAfter:3e3,status:"error"},DevID:a})}},Akpi:function(e,t,s){"use strict";s.d(t,"i",(function(){return y})),s.d(t,"g",(function(){return S})),s.d(t,"e",(function(){return E})),s.d(t,"j",(function(){return j})),s.d(t,"h",(function(){return h})),s.d(t,"b",(function(){return C})),s.d(t,"f",(function(){return v})),s.d(t,"k",(function(){return _})),s.d(t,"a",(function(){return w})),s.d(t,"d",(function(){return N})),s.d(t,"c",(function(){return P}));var i=s("lSCD"),a=s.n(i),n=s("fz41"),r=s("EE6H"),o=s("xgzS"),c=s("/kok"),u=s("j1RV"),l=s("AO/9"),d=s("B6RA"),m=s("+PoS"),f=s("Bffz"),D=s("BvFm"),I=s("+CSe"),O=(s("lPiR"),s("XzT5")),b=s("wd8a"),g=s("DMxJ");function p(e,t){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),s.push.apply(s,i)}return s}function T(e){for(var t=1;t{c.a.startConnection()})),t({type:"USER_IS_AUTHENTICATED"})}function S(e,t=!0,s){return function(i){i({type:"GET_USER",payload:Object(n.c)(T({},f.a.getUser(e),{queryParams:{}}))}).then(async n=>{t&&await y(n,i,e),a()(s)&&i(s())}).catch(e=>{console.error(e),i(j())})}}function E(){return function(e){e({type:"FETCH_ALL_USERS",payload:Object(g.a)()})}}function j(){return function(e){e({type:"USER_LOGOUT",payload:Object(n.e)()})}}function h(e=!0){return async function(t){t({type:"GET_CURRENT_USER",payload:Object(n.b)()}).then(async s=>{let i=await l.a.currentSession();console.log(i),console.log(s);let a=s.value,n=i.accessToken.payload.sub;const r={};a&&(e&&await t(S(n,!0)),r.login=a.username,r.name=a.attributes.name,r.email=a.attributes.email,r.phone=a.attributes.phone_number,r.address=a.attributes.address,r.locale=a.attributes.locale,r.sub=n,t({type:"USER_GET_ATTRIBUTES_FULFILLED",payload:r}))}).catch(e=>{console.error(e),Object(n.e)()})}}function C(e,t){return async function(s){await s({type:"USER_CONFIRMATION_ACCOUNT",payload:new Promise((s,i)=>{l.a.confirmSignUp(e,t).then(()=>{s()}).catch(e=>{i(e)})})}).catch(e=>{console.error(e)})}}function v(e){return function(t){t({type:"GET_USER_EMPLOYEES",payload:Object(n.c)(T({},f.a.listUser({clientID:e})))}).then(async()=>{}).catch(e=>{console.error("User employees GET error: ",e)})}}function _(e,t,s,i){return function(a){a({type:"UPDATE_AUTHORIZATIONS",payload:Object(n.c)(T({},f.a.updateUser({clientID:t,localUserID:s}),{method:"PUT",body:e}))}).then(()=>{let e={title:O.a.t("popNotifications.editUser"),message:O.a.t("popNotifications.successful"),status:"success",dismissible:!0,dismissAfter:3e3};d.default.dispatch(Object(u.addNotification)(e)),i&&i()}).catch(()=>{let e={title:O.a.t("popNotifications.editUser"),message:O.a.t("popNotifications.failure"),status:"error",dismissible:!0,dismissAfter:3e3};d.default.dispatch(Object(u.addNotification)(e))})}}function w(e,t,s,i){return function(a){a({type:"CHANGE_MQTT_PASSWORD",payload:Object(n.c)(T({},f.a.changeMQTTPassword({clientID:t,localUserID:s}),{queryParams:{LocalMqttSecret:e}}))}).then(()=>{a({type:"USER_CHANGE_MQTT_PASSWORD",payload:e});let t={title:O.a.t("popNotifications.localMqttPassword.localPasswordAuthorization"),message:O.a.t("popNotifications.localMqttPassword.successMessage"),status:"success",dismissible:!0,dismissAfter:3e3};d.default.dispatch(Object(u.addNotification)(t))}).catch(()=>{let e={title:O.a.t("popNotifications.localMqttPassword.localPasswordAuthorization"),message:O.a.t("popNotifications.localMqttPassword.failureMessage"),status:"error",dismissible:!0,dismissAfter:3e3};d.default.dispatch(Object(u.addNotification)(e))}).finally(()=>{a(Object(m.a)("".concat(i,"/settings")))})}}function N(e,t,s,i,a){return function(r){r({type:"ENABLE_DISABLE_USER",payload:Object(n.c)(T({},f.a.enableDisableUser({clientID:e}),{body:{enable:t,sub:s,login:i}}))}).then(()=>{let e={title:O.a.t("success"),message:t?O.a.t("popNotifications.enabledUser"):O.a.t("popNotifications.disabledUser"),status:"success",dismissible:!0};r(Object(u.addNotification)(e)),a&&a()}).catch(e=>{let s;if("Validation error"===e.statusText){let t="";for(let s in e)if("statusText"!==s)switch(e[s].code){case 13:t+="".concat(O.a.t("braintreeValidation.operatorsMax",{count:e[s].amount}),"
");break;case 14:t+="".concat(O.a.t("braintreeValidation.managersMax",{count:e[s].amount}),"
");break;default:t+=O.a.t("notFound.dataNotFound")}s={title:O.a.t("error"),message:t,status:"error",dismissible:!0,allowHTML:!0}}else s={title:O.a.t("error"),message:t?O.a.t("popNotifications.enabledUserErr"):O.a.t("popNotifications.disabledUserErr"),status:"error",dismissible:!0};r(Object(u.addNotification)(s))}).finally(()=>{r(Object(m.a)("/farmSettings/users"))})}}function P(e,t=(()=>{}),s=(()=>{})){return function(i){i({type:"DELETE_USER_ACCOUNT",payload:Object(n.c)(T({},f.a.deleteUser(),{body:{LocalUserID:e}}))}).then(e=>{t(e);let s={title:O.a.t("success"),message:O.a.t("popNotifications.deleteUserSuccess"),status:"success",dismissible:!0};i(Object(u.addNotification)(s))}).catch(e=>{s(e);let t={title:O.a.t("error"),message:O.a.t("popNotifications.deleteUserFailure"),status:"error",dismissible:!0};i(Object(u.addNotification)(t))})}}},B2Cw:function(e,t,s){"use strict";s.d(t,"a",(function(){return O})),s.d(t,"c",(function(){return b})),s.d(t,"b",(function(){return g}));var i=s("mwIZ"),a=s.n(i),n=s("BkRI"),r=s.n(n),o=s("fz41"),c=s("i8MS"),u=s("j1RV"),l=(s("10H7"),s("5Z9N"),s("Bffz")),d=s("CX8Q"),m=s("XzT5");function f(e,t){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),s.push.apply(s,i)}return s}function D(e){for(var t=1;t{const f=r()(a()(n,"value.items",[]));let I=r()(a()(e,"animals",[])).map(e=>e instanceof d.a?e.prepareBeanToSave():e);console.log(n,f,I,"local animals to create");let O=!1;f.length&&(await c.a.insertIntoAnimals(f),O=!0);const b=f.map(e=>e.AnmNo1);I=I.filter(e=>{if(b.includes(e.AnmID)){const t={title:m.a.t("error"),message:m.a.t("animalsActions.animalAlreadyAdded",{number:e.AnmNo1}),status:"error",dismissible:!0,dismissAfter:5e3};return s(Object(u.addNotification)(t)),!1}return!0}),I.length?s({type:"CREATE_ANIMAL",payload:Object(o.c)(D({},l.a.createAnimal({farmID:i}),{body:{animals:I}}))}).then(async e=>{const n=r()(a()(e,"value.message",[]));await c.a.insertIntoAnimals(n),s(g(i));const o={title:m.a.t("success"),message:m.a.t("animalsActions.successfullyAddedAnm",{count:n.length}),status:"success",dismissible:!0,dismissAfter:5e3};if(s(Object(u.addNotification)(o)),t)try{t({animals:n,response:e})}catch(l){console.error(l)}}).catch(async e=>{O&&s(g(i))}):O&&s(g(i))}).catch(e=>{console.error(e)})}}function b(e,t=!1,s){return function(i){let a={FarmID:e,DtaModTime:c.a.getModificationTime(e).DtaModTime,partial:!0};s&&(a.DtaModTime=0,a.ESKDtaModTime=s.DtaModTime,a.ESKAnmID=s.AnmID),i({type:"LIST_ANIMAL",payload:Object(o.c)(D({},l.a.listAnimal({farmID:e}),{queryParams:a}))}).then(async s=>{if(Object.assign({},s),s.value.items.length>0){let e=[];Object.assign(e,s.value.items),await c.a.insertIntoAnimals(e)}s.value.LastEvaluatedKey&&i(b(e,t,s.value.LastEvaluatedKey)),!t&&i(g(e))}).catch(s=>{!t&&i(g(e))})}}function g(e){return function(t){t({type:"GET_ANIMAL_MODIFICATION_TIME",payload:c.a.getModificationTime(e)})}}},CwRS:function(e,t,s){"use strict";s.d(t,"a",(function(){return c})),s.d(t,"b",(function(){return u}));var i=s("fz41"),a=s("Bffz");function n(e,t){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),s.push.apply(s,i)}return s}function r(e){for(var t=1;t{console.log("list documents -> ",e)}).catch(e=>{console.error("list documents -> ",e)})}}function u(e){return function(t){t({type:"MARK_DOCUMENT_AS_READ",payload:Object(i.c)(r({},a.a.markDocumentAsRead(),{body:{DocID:e}}))}).then(s=>{console.log("markDocumentAsRead success"),t({type:"UPDATE_DOC_READ",payload:e})}).catch(e=>{console.error(e)})}}},D7Yj:function(e,t,s){"use strict";s.d(t,"e",(function(){return V})),s.d(t,"h",(function(){return z})),s.d(t,"f",(function(){return x})),s.d(t,"j",(function(){return W})),s.d(t,"m",(function(){return H})),s.d(t,"l",(function(){return Q})),s.d(t,"g",(function(){return q})),s.d(t,"d",(function(){return Y})),s.d(t,"k",(function(){return J})),s.d(t,"c",(function(){return K})),s.d(t,"b",(function(){return X})),s.d(t,"n",(function(){return Z})),s.d(t,"a",(function(){return $})),s.d(t,"i",(function(){return te}));s("BkRI"),s("17UY"),s("Lqn+");var i=s("wd/R"),a=s.n(i),n=(s("f0Wu"),s("PTLd")),r=s.n(n),o=s("BvFm"),c=s("B6RA"),u=s("fz7+"),l=s("GUWk"),d=s("Gx0o"),m=s.n(d),f=s("q17X"),D=s("p9x/"),I=s.n(D),O=s("hKv7"),b=s.n(O),g=s("3eJ2"),p=s.n(g),T=s("R8gh"),A=s.n(T),y=s("+U6+"),S=s.n(y),E=s("w1Hw"),j=s.n(E),h=s("Vqin"),C=s.n(h),v=s("xLyO"),_=s.n(v),w=s("fz41"),N=s("Bffz"),P=s("yuUd"),M=s("8onQ"),R=s.n(M),F=s("j1RV"),L=s("XzT5");function U(e,t){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),s.push.apply(s,i)}return s}function G(e){for(var t=1;t{const{data:{status:s,data:i}}=t;"error"===s?(l.a.updateReportStatus(O.FeturaQuery.FeturaQTime,[],u.a.FAILED),e(X(m))):(l.a.updateReportStatus(O.FeturaQuery.FeturaQTime,i),e(X(m)))},i!==u.b.STRUCTURE)b.postMessage(G({},s,{start:n,stop:r,FarmID:m,isService:f,sub:D,user:I}));else{let e=+a()(d).utc().startOf("day"),t=+a()(d).utc().endOf("day");b.postMessage(G({},s,{start:e,stop:t,FarmID:m,isService:f,sub:D,user:I}))}}function V(e,t,s){return i=>{B(i,r.a,{},u.b.BIRTH,{start:t,stop:s},e);const a={title:L.a.t("reportNotifications.title"),message:L.a.t("reportNotifications.birthReport"),status:"success",dismissible:!0,dismissAfter:5e3};i(Object(F.addNotification)(a))}}function z(e,t,s){return i=>{B(i,_.a,{},u.b.MEDICINE_CONSUMPTION,{start:t,stop:s},e);const a={title:L.a.t("reportNotifications.title"),message:L.a.t("reportNotifications.medicineConsumptionReport"),status:"success",dismissible:!0,dismissAfter:5e3};i(Object(F.addNotification)(a))}}function x(e,t,s){return i=>{B(i,m.a,{},u.b.IDLE,{start:t,stop:s},e);const a={title:L.a.t("reportNotifications.title"),message:L.a.t("reportNotifications.idleDaysReport"),status:"success",dismissible:!0,dismissAfter:5e3};i(Object(F.addNotification)(a))}}function W(e,t,s){return i=>{B(i,j.a,{},u.b.SALES,{start:t,stop:s},e);const a={title:L.a.t("reportNotifications.title"),message:L.a.t("reportNotifications.idleDaysReport"),status:"success",dismissible:!0,dismissAfter:5e3};i(Object(F.addNotification)(a))}}function H(e,t,s){return function(i){B(i,C.a,{},u.b.TREATMENT,{start:t,stop:s},e);const a={title:L.a.t("reportNotifications.title"),message:L.a.t("reportNotifications.treatmentReport"),status:"success",dismissible:!0,dismissAfter:5e3};i(Object(F.addNotification)(a))}}function Q(e,t,s){return function(i){B(i,b.a,{},u.b.SEPARATION,{start:t,stop:s},e);const a={title:L.a.t("reportNotifications.title"),message:L.a.t("reportNotifications.separationReport"),status:"success",dismissible:!0,dismissAfter:5e3};i(Object(F.addNotification)(a))}}function q(e,t,s){return i=>{let a=Object(f.getDaysForRepeatedInsemination)();B(i,I.a,{daysBetweenInseminations:a},u.b.INSEMINATION,{start:t,stop:s},e);const n={title:L.a.t("reportNotifications.title"),message:L.a.t("reportNotifications.inseminationsReport"),status:"success",dismissible:!0,dismissAfter:5e3};i(Object(F.addNotification)(n))}}function Y(e,t){return s=>{B(s,p.a,{},u.b.STRUCTURE,{forDay:t},e);const i={title:L.a.t("reportNotifications.title"),message:L.a.t("reportNotifications.herdStructureReport"),status:"success",dismissible:!0,dismissAfter:5e3};s(Object(F.addNotification)(i))}}function J(e,t,s){return function(i){B(i,A.a,{},u.b.SELECTION,{start:t,stop:s},e);const a={title:L.a.t("reportNotifications.title"),message:L.a.t("reportNotifications.selectionReport"),status:"success",dismissible:!0,dismissAfter:5e3};i(Object(F.addNotification)(a))}}function K(e,t,s){return function(i){B(i,S.a,{},u.b.DEAD,{start:t,stop:s},e);const a={title:L.a.t("reportNotifications.title"),message:L.a.t("reportNotifications.deadReport"),status:"success",dismissible:!0,dismissAfter:5e3};i(Object(F.addNotification)(a))}}function X(e){return function(t){t({type:"GET_ALL_REPORTS",payload:l.a.getAllReports(e)})}}function Z(e,t,s){return function(i){i({type:"LIST_ATHENA_REPORTS",payload:Object(w.c)(G({},N.a.getReports({clientID:t,localUserID:s}),{queryParams:{DtaModTime:l.a.getModificationTime().DtaModTime}}))}).then(async t=>{t.value.items.length>0&&(await l.a.insertAthenaReports(t.value.items),i(X(e)))})}}function $(e,t,s,i,a,n,r={}){return function(o){o({type:"CREATE_REPORT_ATHENA",payload:Object(w.c)(G({},N.a.createReport({clientID:a,localUserID:n}),{body:{QueryCode:e,QueryParams:G({startDate:t,endDate:s,farmsArray:i},r),FeturaQTime:(new Date).getTime()}}))}).then(()=>{const e={title:L.a.t("reportNotifications.title"),message:L.a.t("reportNotifications.general"),status:"success",dismissible:!0,dismissAfter:5e3};o(Object(F.addNotification)(e))})}}const ee=(e,t)=>{if(!e)return null;if(t.header)return e;if(!isNaN(+e))return+e;try{return JSON.parse(e)}catch(s){}if(e.startsWith("[")){let t=(e=e.replace("[","").replace("]","")).split(",");return console.log(t),t}return e};async function te(e,t,s,i){let a=(await Object(w.c)(G({},N.a.getReportData({clientID:s,localUserID:i}),{body:{LocQTime:e,CreatorID:t}}))).ResourceUrl,n=await fetch(a),r=await n.text();return await function(e){return new Promise((t,s)=>{let i=[];try{const s=R()({columns:!0,cast:ee});s.on("readable",()=>{let e=s.read();for(;e;)i.push(e),e=s.read()}),s.on("end",()=>{t(i)}),s.write(e),console.log(i),s.end()}catch(a){s(a)}})}(r)}},DWSH:function(e,t,s){"use strict";s.d(t,"n",(function(){return I})),s.d(t,"f",(function(){return O})),s.d(t,"i",(function(){return b})),s.d(t,"h",(function(){return g})),s.d(t,"c",(function(){return p})),s.d(t,"e",(function(){return T})),s.d(t,"d",(function(){return A})),s.d(t,"j",(function(){return y})),s.d(t,"l",(function(){return S})),s.d(t,"k",(function(){return E})),s.d(t,"b",(function(){return j})),s.d(t,"a",(function(){return h})),s.d(t,"g",(function(){return C})),s.d(t,"m",(function(){return v}));var i=s("lFKM"),a=s.n(i),n=s("JFDi"),r=s("fz41"),o=s("Bffz"),c=s("OwcS"),u=s("B6RA"),l=s("j1RV"),d=s("kiXb");function m(e,t){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),s.push.apply(s,i)}return s}function f(e){for(var t=1;t{t.DevType===r.d.GATEWAY&&Object(o.n)(t.DevID,s=>e(f(s,t.DevID)),()=>{return e((s=t.DevID,function(e){e({type:"MQTT_ON_PING_FAILURE",payload:s})}));var s},()=>{return e((s=t.DevID,function(e){e({type:"MQTT_ON_PING_SEND",payload:s})}));var s})})}}function I(){return async function(e){e({type:"REGISTER_IOT",payload:Object(c.c)(d({},u.a.registerIOT()))})}}},JZab:function(e,t,s){"use strict";s.d(t,"c",(function(){return g})),s.d(t,"a",(function(){return T})),s.d(t,"e",(function(){return A})),s.d(t,"h",(function(){return y})),s.d(t,"b",(function(){return S})),s.d(t,"g",(function(){return E})),s.d(t,"d",(function(){return j})),s.d(t,"f",(function(){return h})),s.d(t,"i",(function(){return C}));var i=s("mwIZ"),a=s.n(i),n=s("fz41"),r=s("j1RV"),o=s("B6RA"),c=s("f0zD"),u=s("/U+v"),l=s("Bffz"),d=s("XzT5"),m=s("Ke8t"),f=s("BvFm");function D(e,t){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),s.push.apply(s,i)}return s}function I(e){for(var t=1;t{s({type:"BT_GENERATE_CLIENT_TOKEN",payload:Object(n.c)(I({},l.a.generateToken({customerId:e}),{queryParams:{withCustomerID:t}}))}).catch(e=>{let t={title:d.a.t("error"),message:d.a.t("popNotifications.tokenErr"),status:"error",dismissible:!0};s(Object(r.addNotification)(t)),console.error("gatewayGenerateToken: ",e)})}}function g(e,t,s){return i=>{i({type:"BT_UPDATE_PAYMENT_METHOD",payload:Object(n.c)(I({},l.a.updatePaymentMethod({customerId:s}),{queryParams:{paymentMethodToken:e},body:t}))}).then(()=>{let e={title:d.a.t("success"),message:d.a.t("popNotifications.updatePaymentOK"),status:"success",dismissible:!0,dismissAfter:3e3};i(Object(r.addNotification)(e)),i(T("","","",s))}).catch(e=>{let t={title:d.a.t("error"),message:d.a.t("popNotifications.updatePaymentError")+e,status:"error",dismissible:!0};console.error("gatewayCreatePaymentMethod: ",e),i(Object(r.addNotification)(t)),i(T("","","",s))})}}function p(e,t,s,i){return a=>{a({type:"BT_CREATE_CUSTOMER",payload:Object(n.c)(I({},l.a.customerCreate({customerId:i}),{body:{firstName:t.substr(0,t.indexOf(" ")),lastName:t.substr(t.indexOf(" ")+1),phone:s,email:e,id:i}}))}).then(()=>{a(T(e,t,s,i)),a(b(i,!0))}).catch(e=>{let t={title:d.a.t("error"),message:d.a.t("popNotifications.createUserErr"),status:"error",dismissible:!0};a(Object(r.addNotification)(t)),console.error("gatewayCustomerCreate: ",e)})}}function T(e,t,s,i,c=!1){return u=>{const{farms:{farms:D},user:{user:{ClientID:O,clientSub:g,FarmData:T}}}=o.default.getState(),A=Object(f.i)(),y=A?g:i;u({type:"BT_FIND_CUSTOMER",payload:Object(n.c)(I({},l.a.customerFind({customerId:y}),{queryParams:{forceFetch:c}})),meta:{farms:D}}).then(i=>{if(i&&i.value&&!i.value.hasOwnProperty("name")&&!A&&u(b(y,!0)),i&&i.value&&"notFoundError"===i.value.name&&!A)u(p(e,t,s,y));else{const e=A?T.filter(e=>e.ClientID===O):a()(o.default.getState(),"user.user.Roles",[]).find(e=>e.Role===m.BILLING).LocalRights;e.push({FarmID:O});const t=e.map(e=>e.FarmID);u(function(e,t=!1){return s=>{let i=o.default.getState().farms.farms;s({type:"BT_SEARCH_SUBSCRIPTION",payload:Object(n.c)(I({},l.a.searchSubscription(),{queryParams:{forceFetch:t,farmIDs:e}})),meta:{farms:i}}).catch(e=>{let t={title:d.a.t("error"),message:d.a.t("popNotifications.getFarmSubsErr"),status:"error",dismissible:!0};console.error("gatewaySubscriptionSearch: ",e),s(Object(r.addNotification)(t))})}}(t,c))}}).catch(()=>{let i={title:d.a.t("error"),message:d.a.t("popNotifications.findUserErr"),status:"error",dismissible:!0};u(Object(r.addNotification)(i)),A||u(p(e,t,s,y))})}}function A({farmID:e,clientID:t}){return s=>{s({type:"BT_RETRY_PAYMENT",payload:Object(n.c)(I({},l.a.retryPayment(),{body:{FarmID:e,ClientID:t}}))}).then(()=>{let e={title:d.a.t("success"),message:d.a.t("popNotifications.retryPaymentSuccess"),status:"success",dismissible:!0,dismissAfter:3e3};s(Object(r.addNotification)(e))}).catch(()=>{let e={title:d.a.t("error"),message:d.a.t("popNotifications.retryPaymentError"),status:"error",dismissible:!0};s(Object(r.addNotification)(e))})}}function y({farmID:e,clientID:t,localUserID:s,subs:i,pays:a}){return o=>{o({type:"BT_TERMINATE_ACCOUNT",payload:Object(n.c)(I({},l.a.terminateAccount({clientID:t,localUserID:s}),{body:{FarmID:e,ClientID:t,LocalUserID:s,subs:i,pays:a}}))}).then(()=>{let e={title:d.a.t("success"),status:"success",message:d.a.t("popNotifications.terminateAccountSuccess"),dismissible:!0,dismissAfter:3e3};o(Object(r.addNotification)(e)),o(Object(c.d)(u.a,{counter:5}))}).catch(()=>{let e={title:d.a.t("error"),message:d.a.t("popNotifications.terminateAccountError"),status:"error",dismissible:!0};o(Object(r.addNotification)(e))})}}function S(e,t=!1){const{user:{user:{clientSub:s}}}=o.default.getState(),i=Object(f.i)()?s:e;return e=>{e({type:"BT_TRANSACTION_HISTORY",payload:Object(n.c)(I({},l.a.transactionHistory({customerId:i}),{queryParams:{forceFetch:t}}))})}}function E(e){return function(t){t({type:"BT_STORE_DROPIN_INSTANCE",payload:e})}}function j(){return function(e){e({type:"BT_INITIALIZE_DROPIN"})}}function h(e){return function(t){t({type:"BT_SET_PAYMENT_METHOD_REQUESTABLE",payload:e})}}function C(e){return function(t){t({type:"BT_UPDATE_SELECTED_PLANS",payload:e})}}},LDPH:function(e,t,s){"use strict";s.d(t,"a",(function(){return m})),s.d(t,"c",(function(){return f})),s.d(t,"b",(function(){return D}));var i=s("JFDi"),a=s("fz41"),n=s("Bffz"),r=s("OwcS"),o=s("B6RA"),c=s("j1RV"),u=s("kiXb");function l(e,t){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),s.push.apply(s,i)}return s}function d(e,t,s){return t in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}function m({DevIDs:e=[],SiloIDs:t=[],PlcmntIDs:s=[],Efficiency:r=1e3},{FarmID:o,ClientID:c,LocalUserID:u}={}){const{_FarmID:m,_LocalUserID:f,_ClientID:D}=Object(i.a)({FarmID:o,ClientID:c,LocalUserID:u});return Object(a.c)(function(e){for(var t=1;t{if(t)try{return async function(e){I({type:"REGISTER_SNS_ENDPOINT_FULLFILLED",payload:e.EndpointArn});let t="-"+r,O=t+"-"+c;const b=f.find(e=>"_SERVICE"===e.Role),g=b?b.LocalRights.filter(e=>e.ClientID===r).map(e=>e.FarmID):[];let p=l.map(e=>e.FarmID);b&&(p=p.filter(e=>g.includes(e)));let T=[n.a.sns.mainTopic,n.a.sns.mainTopic+t,n.a.sns.mainTopic+O];for(let s of p){let e=t+"-"+s;T.push(n.a.sns.mainTopic+e)}I(function(e,t){return s=>{s({type:"SUBSCRIBE_SNS_TOPIC",payload:Object(i.c)(D({},d.a.subscribeSNSTopic(),{body:{Protocol:"Application",TopicArn:t,Endpoint:e}}))}).catch(e=>{let t={title:m.a.t("error"),message:m.a.t("popNotifications.subscribeTopicErr"),status:"error",dismissible:!0};s(Object(a.addNotification)(t)),console.error("subscribeSNSTopic: ",e)})}}(e.EndpointArn,T));let A={SetID:"EndpointArn",ClientID:r,FarmID:"EndpointArn",SetData:{EndpointArn:e.EndpointArn,DeviceName:s,Name:"EndpointArn"},SetType:u.a.ENDPOINT_ARN,DtaModTime:(new Date).getTime()},y=[];return y.push(A),await o.a.insertIntoSettings(y),e}(await Object(i.c)(D({},d.a.registerSNSEndpoint(),{body:{PlatformApplicationArn:e,Token:t,CustomUserData:s}})))}catch(O){return console.error(O),function(e){I({type:"REGISTER_SNS_ENDPOINT_FAILURE",payload:e});let t={title:m.a.t("error"),message:m.a.t("popNotifications.registerEndpointErr"),status:"error",dismissible:!0,dismissAfter:3e3};return I(Object(a.addNotification)(t)),e}(O)}else console.error("nie zarejestrowano endpointa bo token pusty")}}function b(e){return async t=>{try{return async function(e){t({type:"UNSUBSCRIBE_SNS_TOPIC_FULLFILLED",payload:e});let s=c.n.find({SetID:"EndpointArn"});return s.length>0&&await o.a.deleteFromSettings(s),t(Object(l.a)("/")),t(Object(r.j)()),e}(await Object(i.c)(D({},d.a.unsubscribeSNSTopic(),{body:{EndpointArn:e}})))}catch(s){return function(e){t({type:"UNSUBSCRIBE_SNS_TOPIC_FAILURE",payload:e});let s={title:m.a.t("error"),message:m.a.t("popNotifications.subscribeEndpointRemoveErr"),status:"error",dismissible:!0,dismissAfter:3e3};return t(Object(a.addNotification)(s)),e}(s)}}}},Ze2Y:function(e,t,s){"use strict";s.d(t,"c",(function(){return r})),s.d(t,"b",(function(){return o})),s.d(t,"a",(function(){return c})),s.d(t,"d",(function(){return u}));var i=s("TNb3"),a=s("wd/R"),n=s.n(a);function r(e){return function(t){t({type:"SET_FILTERS",payload:e})}}function o(e){return function(t){t({type:"GET_TASKS",payload:Object(i.a)(e)})}}function c(e){return function(t){t({type:"CHANGE_DATE",payload:e}),t(o(+n.a.utc(e)))}}function u(e){return function(t){t({type:"SET_SELECTED_TASK",payload:e})}}},a2io:function(e,t,s){"use strict";s.d(t,"a",(function(){return c}));var i=s("JFDi"),a=s("fz41"),n=s("Bffz");s("OwcS"),s("B6RA"),s("j1RV");function r(e,t){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),s.push.apply(s,i)}return s}function o(e,t,s){return t in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}function c(e,{FarmID:t,ClientID:s,LocalUserID:c}={}){const{_FarmID:u,_LocalUserID:l,_ClientID:d}=Object(i.a)({FarmID:t,ClientID:s,LocalUserID:c});return Object(a.c)(function(e){for(var t=1;t{let s=Array.isArray(e)?e:[e],i=new Map;for(let e of s)try{let t=l.a.getGateway(e),s=i.get(t.DevID)||[];s.push(e),i.set(t.DevID,s)}catch(a){console.error(a)}for(let[e,n]of i.entries())Object(d.B)(e,n.map(e=>e.DevID),o)})}function I(e,{uniqueId:t=Object(r.a)()}={}){o.default.dispatch(Object(c.addNotification)({id:t,title:u.a.t("apiNotifications.updateDevicesTitle"),message:u.a.t("apiNotifications.updateDevicesSuccess"),status:"success",dismissible:!0,dismissAfter:5e3}))}function O(e,{uniqueId:t=Object(r.a)()}={}){console.log(e),o.default.dispatch(Object(c.addNotification)({id:t,title:u.a.t("apiNotifications.updateDevicesTitle"),message:u.a.t("apiNotifications.updateDevicesFailureGeneral"),status:"error",dismissible:!0,dismissAfter:15e3}))}},dxSB:function(e,t,s){"use strict";s.d(t,"a",(function(){return m}));var i=s("lFKM"),a=s.n(i),n=s("fz41"),r=s("wd/R"),o=s.n(r),c=s("Bffz");function u(e,t){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),s.push.apply(s,i)}return s}function l(e){for(var t=1;t{}),i=(()=>{})){return function(r){let u=e.DevID;Object.keys(t).filter(e=>e.startsWith("AggDataTime")).length||(t.AggDataTime=o()().startOf("day").toDate().getTime()),a()(t.index)&&(u+="_".concat(t.index),delete t.index),r({type:"FETCH_AGGREGATED_DATA",payload:Object(n.c)(l({},c.a.getAggregatedData(e.DevID,{farmID:e.FarmID}),{queryParams:l({table:"AggData"},t,{DevIDAggData:u})})),meta:{DevID:u}}).then(e=>{s(e)}).catch(e=>{console.error(e),i(e)}),r({type:"FETCH_AGGREGATED_DATA",payload:u})}}},e6PY:function(e,t,s){"use strict";s.d(t,"b",(function(){return u})),s.d(t,"a",(function(){return l}));var i=s("fz41"),a=s("Bffz"),n=s("aIXM");function r(e,t){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),s.push.apply(s,i)}return s}function o(e){for(var t=1;t{e.value.length>0&&await n.a.insertIntoGroups(e.value)}).finally(()=>{t(l(e))})}}function l(e){return function(t){t({type:"GET_ALL_GROUPS",payload:n.a.getAllGroups(e)})}}},fAk8:function(e,t,s){"use strict";s.d(t,"b",(function(){return r})),s.d(t,"d",(function(){return o})),s.d(t,"e",(function(){return c})),s.d(t,"c",(function(){return u})),s.d(t,"a",(function(){return l}));var i=s("uqr+"),a=s.n(i),n=s("ba04");function r(e){return async function(t){t({type:"SET_LANGUAGE",payload:e})}}function o(){return{type:"GET_LANGUAGES",payload:a.a.getLanguage()}}function c(e,t=!0){return function(s){s({type:"GET_TRANSLATION",payload:Object(n.a)(e),meta:t})}}function u(){return function(e){e({type:"GET_ALL_TRANSLATION_LANGUAGES",payload:Object(n.a)([])})}}function l(e){return function(t){t({type:"ADD_LANGUAGE",payload:e})}}},gLBR:function(e,t,s){"use strict";s.d(t,"b",(function(){return T})),s.d(t,"a",(function(){return A})),s.d(t,"c",(function(){return y}));var i=s("Z0cm"),a=s.n(i),n=s("lSCD"),r=s.n(n),o=s("ZRKa"),c=s("fz41"),u=s("Bffz"),l=s("P0Qa"),d=s("Bzsw"),m=s("VfnB"),f=s("kCVf"),D=s("B6RA"),I=s("kiXb");function O(e,t){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),s.push.apply(s,i)}return s}function b(e){for(var t=1;tI.a.t(e);function T(e,t=Object(f.g)()){return function(s){let i=D.default.getState().user.user;console.log(t),s({type:"GET_SETTINGS_DATA",payload:Object(c.c)(b({},u.a.listSettings({clientID:e}),{queryParams:{DtaModTime:o.a.getModificationTime(t).DtaModTime}})).then(async e=>{if(Object.assign({},e),e.length>0){let t=[];Object.assign(t,e),await o.a.insertIntoSettings(t)}t&&s({type:"LIST_ALL_SETTINGS",payload:o.a.getAllSettings(t),meta:{user:i}})}).catch(e=>{t&&s({type:"LIST_ALL_SETTINGS",payload:o.a.getAllSettings(t),meta:{user:i}})})})}}function A(e,t,s){console.log("createSettingDynamoDB",e,t,s);let i=Object(m.e)(e,["$loki","meta"]);return function(e){let a=S(i);a&&(a=Object(d.a)("Dodawanie",a)),e({type:"CREATE_SETTING",payload:Object(c.c)(b({},u.a.createSetting(),{body:i}))}).then(e=>{if(a&&Object(d.c)("Dodano pomy\u015blnie",a),r()(t))try{t(e)}catch(s){console.error(s)}}).catch(e=>{if(console.error(e),a&&Object(d.b)("B\u0142\u0105d dodawania",a),r()(s))try{s(e)}catch(t){console.error(t)}})}}function y(e,t,s){console.log("updateSettingDynamoDB",e,t,s);let i=Object(m.e)(e,["$loki","meta"]),a=S(i);return a&&(a=Object(d.a)(E(i)?"Usuwanie":"Aktualizacja",a)),function(e){e({type:"UPDATE_SETTING",payload:Object(c.c)(b({},u.a.updateSetting(),{body:i}))}).then(e=>{if(a&&Object(d.c)(E(i)?"Usuni\u0119to pomy\u015blnie":"Zaktualizowano pomy\u015blnie",a),r()(t))try{t(e)}catch(s){console.error(s)}}).catch(e=>{if(console.error(e),a&&Object(d.b)(E(i)?"B\u0142\u0105d usuwania":"B\u0142\u0105d dodawania",a),r()(s))try{s(e)}catch(t){console.error(t)}})}}function S(e){if(a()(e)&&e.length>1)return p("settings.settings");switch(a()(e)?e[0].SetType:e.SetType){case l.a.FEEDING_CURVE:return p("feedingCurve");case l.a.FEEDING_SCHEDULE:return p("notificationsSettings.feedingSchedule");case l.a.FEEDING_FORAGE:return p("forage");case l.a.FARM_MAP:return p("map");case l.a.GENERAL:return p("notificationsSettings.mainSettings");case l.a.NOTIFICATIONS:return p("notifications.notifications");case l.a.LAYOUT:return p("notificationsSettings.dashBoard");case l.a.YEARLY_PLANS:return p("notificationsSettings.annualPlan");case l.a.ECONOMY:return p("notificationsSettings.sectorWithForage");default:return null}}function E(e){return a()(e)?!!e[0].DtaDelTime:!!e.DtaDelTime}},iaLV:function(e,t,s){"use strict";s.d(t,"a",(function(){return m})),s.d(t,"c",(function(){return f})),s.d(t,"b",(function(){return D}));var i=s("fz41"),a=s("Bffz"),n=s("JFDi"),r=s("OwcS"),o=s("B6RA"),c=s("j1RV"),u=s("kiXb");function l(e,t){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),s.push.apply(s,i)}return s}function d(e,t,s){return t in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}function m(e,{FarmID:t,ClientID:s,LocalUserID:r}={}){const{_FarmID:o,_LocalUserID:c,_ClientID:u}=Object(n.a)({FarmID:t,ClientID:s,LocalUserID:r});return Object(i.c)(function(e){for(var t=1;t{const e={title:l.a.t("success"),message:l.a.t("popNotifications.successfullyUpdated"),status:"success",dismissible:!0,dismissAfter:3e3};i(Object(u.addNotification)(e))}).catch(e=>{const t={title:l.a.t("error"),message:l.a.t("popNotifications.updateErr"),status:"error",dismissible:!0,dismissAfter:3e3};console.error(e),i(Object(u.addNotification)(t))}),i({type:"UPDATE_DICTIONARY",payload:e})}}function b(e){return function(t){t({type:"LIST_DICTIONARY",payload:Object(r.c)(m({},o.a.listDictionaries({clientID:e}),{queryParams:{DtaModTime:n.a.getModificationTime().DtaModTime}}))}).then(async e=>{if(Object.assign({},e),e.value.length>0){let t=[];Object.assign(t,e.value),await t.forEach(e=>D.push(e)),await n.a.insertIntoDictionaries(D),D.length=0}t(I())}).catch(e=>{t(I()),console.error(e)})}}function g(e,t,s){let i=a()(e),n=Object(c.e)(i);return function(e){e({type:"CREATE_DICTIONARY",payload:Object(r.c)(m({},o.a.createDictionaries({clientID:t,localUserID:s}),{body:n})).then(()=>{const t={title:l.a.t("success"),message:l.a.t("popNotifications.added"),status:"success",dismissible:!0,dismissAfter:3e3};e(Object(u.addNotification)(t))}).catch(t=>{const s={title:l.a.t("error"),message:l.a.t("popNotifications.additionErr"),status:"error",dismissible:!0,dismissAfter:3e3};console.error(t),e(Object(u.addNotification)(s))})}),e({type:"CREATE_DICTIONARY",payload:n})}}},lwfn:function(e,t,s){"use strict";s.d(t,"f",(function(){return l})),s.d(t,"e",(function(){return d})),s.d(t,"a",(function(){return m})),s.d(t,"b",(function(){return f})),s.d(t,"d",(function(){return D})),s.d(t,"c",(function(){return I}));var i=s("/kok"),a=s("Q2bl"),n=s("IBmF"),r=s("XzT5");function o(e,t){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),s.push.apply(s,i)}return s}function c(e){for(var t=1;t!!e.removed).length;return i.a.createAndSendMessageObject(u,d,l,m,a.g.SET_ANIMAL_MODIFICATION,t,c?{loading:{title:r.a.t(e?"IOT.setFeedingTitle":"IOT.setDeletePig"),message:r.a.t(e?"IOT.setFeeding":"IOT.setDeletePigText",{name:f}),status:"loading",dismissible:!1,dismissAfter:0},success:{message:r.a.t(e?"IOT.setFeedingDone":"IOT.setDeletePigSuccess",{name:f}),dismissible:!0,dismissAfter:3e3,status:"success"},error:{message:r.a.t(e?"IOT.setFeedingFailed":"IOT.setDeletePigFailure",{name:f}),dismissible:!0,dismissAfter:3e3,status:"error"},DevID:m}:null,s,o)}}function k(e,t=[],{onSuccess:s,onFailure:o,showNotification:c=!0}={}){const{ClientID:u,LocalUserID:l,GatewayID:d,DevID:m,Name:f,isValid:D}=Object(n.a)(e);if(D)return i.a.createAndSendMessageObject(u,d,l,m,a.g.SET_ANIMAL_MODIFICATION,t,c?{loading:{title:r.a.t("tagReaderDrawer.insemination"),message:r.a.t("IOT.setInseminationText",{name:f}),status:"loading",dismissible:!1,dismissAfter:0},success:{message:r.a.t("IOT.setInseminationSuccess",{name:f}),dismissible:!0,dismissAfter:3e3,status:"success"},error:{message:r.a.t("IOT.setInseminationError",{name:f}),dismissible:!0,dismissAfter:3e3,status:"error"},DevID:m}:null,s,o)}function B(e,t=[],{onSuccess:s,onFailure:o,showNotification:c=!0}={}){const{ClientID:u,LocalUserID:l,GatewayID:d,DevID:m,Name:f,isValid:D}=Object(n.a)(e);if(D)return i.a.createAndSendMessageObject(u,d,l,m,a.g.SET_ANIMAL_MODIFICATION,t,c?{loading:{title:r.a.t("menu.parturition"),message:r.a.t("IOT.setParturitionText",{name:f}),status:"loading",dismissible:!1,dismissAfter:0},success:{message:r.a.t("IOT.setParturitionSuccess",{name:f}),dismissible:!0,dismissAfter:3e3,status:"success"},error:{message:r.a.t("IOT.setParturitionError",{name:f}),dismissible:!0,dismissAfter:3e3,status:"error"},DevID:m}:null,s,o)}},r3a2:function(e,t,s){"use strict";s.d(t,"a",(function(){return u})),s.d(t,"f",(function(){return l})),s.d(t,"i",(function(){return d})),s.d(t,"c",(function(){return m})),s.d(t,"j",(function(){return f})),s.d(t,"k",(function(){return D})),s.d(t,"l",(function(){return I})),s.d(t,"d",(function(){return O})),s.d(t,"e",(function(){return b})),s.d(t,"g",(function(){return g})),s.d(t,"h",(function(){return p})),s.d(t,"b",(function(){return T}));var i=s("/kok"),a=s("IBmF"),n=(s("B6RA"),s("j1RV"),s("Q2bl")),r=s("XzT5");function o(e,t){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),s.push.apply(s,i)}return s}function c(e,t,s){return t in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}function u(e,t,s,r){const{ClientID:o,LocalUserID:c,GatewayID:u,DevID:l,isValid:d}=Object(n.a)(e);d&&i.a.createAndSendMessageObject(o,u,c,l,a.f.GET_CONFIGURATION,null,null,t,s,r)}function l(e,t){const{ClientID:s,LocalUserID:u,GatewayID:l,DevID:d,Name:m,isValid:f}=Object(n.a)(e);if(f)return i.a.createAndSendMessageObject(s,l,u,d,a.f.SET_CONFIGURATION,function(e){for(var t=1;t{console.time("getNotificationsDynamoDB then"),await a.a.insertIntoNotifications(s.value),a.a.removeOldRecords(e),t(D(e)),console.timeEnd("getNotificationsDynamoDB then")}).catch(()=>{t(D(e))})}}function m(e){return t=>{o.a.setPrivate("notificationReadTime",e),t({type:"SET_NOTIFICATIONS_READ_TIME",payload:e})}}function f(){return e=>{const{location:{farm:t}}=n.default.getState();a.a.removeOldRecords(t),e(D(t))}}function D(e){const t=o.a.getPrivate("notificationReadTime",0);return function(s){s({type:"GET_ALL_NOTIFICATIONS",payload:{data:a.a.getAllNotifications(e),notificationReadTime:t}})}}},sZ7W:function(e,t,s){"use strict";s.d(t,"b",(function(){return f})),s.d(t,"w",(function(){return D})),s.d(t,"x",(function(){return I})),s.d(t,"v",(function(){return O})),s.d(t,"c",(function(){return b})),s.d(t,"g",(function(){return g})),s.d(t,"i",(function(){return p})),s.d(t,"k",(function(){return T})),s.d(t,"l",(function(){return A})),s.d(t,"t",(function(){return y})),s.d(t,"s",(function(){return S})),s.d(t,"r",(function(){return E})),s.d(t,"p",(function(){return j})),s.d(t,"q",(function(){return h})),s.d(t,"o",(function(){return C})),s.d(t,"e",(function(){return v})),s.d(t,"h",(function(){return _})),s.d(t,"u",(function(){return w})),s.d(t,"a",(function(){return N})),s.d(t,"f",(function(){return P})),s.d(t,"n",(function(){return M})),s.d(t,"j",(function(){return R})),s.d(t,"m",(function(){return F})),s.d(t,"d",(function(){return L}));var i=s("BkRI"),a=s.n(i),n=s("Z0cm"),r=s.n(n),o=s("/kok"),c=s("IBmF"),u=s("B6RA"),l=s("RRbG"),d=s("Q2bl"),m=(s("j1RV"),s("6uZD"),s("XzT5"));function f(e,t,s,i){const{ClientID:a,LocalUserID:n,GatewayID:r,DevID:u,isValid:l}=Object(d.a)(e);l&&o.a.createAndSendMessageObject(a,r,n,u,c.n.GET_SENSORS_AND_VALVES,null,null,t,s,i)}function D(e,t,s=null){const{ClientID:i,LocalUserID:a,GatewayID:n,DevID:r,Name:u,isValid:l}=Object(d.a)(e);if(l){let e={workType:t};return o.a.createAndSendMessageObject(i,n,a,r,c.n.SET_WORK_TYPE,e,{loading:{title:m.a.t("worktype"),message:m.a.t("IOT.setOperationMode",{name:u}),status:"loading",dismissible:!1,dismissAfter:0},success:{message:m.a.t("IOT.setOperationModeDone",{name:u}),dismissible:!0,dismissAfter:3e3,status:"success"},error:{message:m.a.t("IOT.setOperationModeFailed",{name:u}),dismissible:!0,dismissAfter:3e3,status:"error"},DevID:r},s)}}function I(e,t){const{ClientID:s,LocalUserID:i,GatewayID:n,DevID:f,Name:D,isValid:I}=Object(d.a)(e);if(I)return o.a.createAndSendMessageObject(s,n,i,f,c.n.SET_WORK_TYPE_DURATION,t,{loading:{title:m.a.t("IOT.operatingModeTime"),message:m.a.t("IOT.setOperatingModeTimeOn",{name:D}),status:"loading",dismissible:!1,dismissAfter:0},success:{message:m.a.t("IOT.setOperatingModeTimeOnDone",{name:D}),dismissible:!0,dismissAfter:3e3,status:"success"},error:{message:m.a.t("IOT.setOperatingModeTimeFailed",{name:D}),dismissible:!0,dismissAfter:3e3,status:"error"},DevID:f},e=>{let t=r()(e.DevID)?e.DevID:[e.DevID];for(let s of t){let t=a()(u.default.getState().shadows.shadows.get(s));if(t&&t.configuration){t.configuration.workTypeDuration=e.CData;let i=new Map;i.set(s,t),u.default.dispatch(Object(l.b)(i))}}})}function O(e,t,s){const{ClientID:i,LocalUserID:n,GatewayID:f,DevID:D,Name:I,isValid:O}=Object(d.a)(e);if(O){let e={number:t,value:s};return o.a.createAndSendMessageObject(i,f,n,D,c.n.SET_VALVE,e,{loading:{title:m.a.t("IOT.valve"),message:m.a.t("IOT.valveStatusChange")+t+m.a.t("IOT.on",{name:I}),status:"loading",dismissible:!1,dismissAfter:0},success:{message:m.a.t("IOT.valveStatusChangeDone")+t+m.a.t("IOT.on",{name:I}),dismissible:!0,dismissAfter:3e3,status:"success"},error:{message:m.a.t("IOT.valveStatusChangeFailed")+t+m.a.t("IOT.on",{name:I}),dismissible:!0,dismissAfter:3e3,status:"error"},DevID:D},e=>{console.log(e);let t=r()(e.DevID)?e.DevID:[e.DevID];for(let s of t){let t=a()(u.default.getState().shadows.shadows.get(s));if(t&&t.valves){let i=new Map;t.valves[e.CData.number-1].valve=e.CData.status,i.set(s,t),u.default.dispatch(Object(l.b)(i))}}})}}function b(e){const{ClientID:t,LocalUserID:s,GatewayID:i,DevID:a,Name:n,isValid:r}=Object(d.a)(e);if(r)return o.a.createAndSendMessageObject(t,i,s,a,c.n.RESET,null,{loading:{title:m.a.t("IOT.resetting"),message:m.a.t("IOT.resetting",{name:n}),status:"loading",dismissible:!1,dismissAfter:0},success:{message:m.a.t("IOT.resetInProgress",{name:n}),dismissible:!0,dismissAfter:3e3,status:"success"},error:{message:m.a.t("IOT.resetFailed",{name:n}),dismissible:!0,dismissAfter:3e3,status:"error"},DevID:a})}function g(e,t){const{ClientID:s,LocalUserID:i,GatewayID:n,DevID:f,Name:D,isValid:I}=Object(d.a)(e);if(I){let e={defaultExit:t};return o.a.createAndSendMessageObject(s,n,i,f,c.n.SET_DEFAULT_EXIT,e,{loading:{title:m.a.t("defaultExit"),message:m.a.t("IOT.changeDefaultExitOn",{name:D}),status:"loading",dismissible:!1,dismissAfter:0},success:{message:m.a.t("IOT.changeDefaultExitOnDone",{name:D}),dismissible:!0,dismissAfter:3e3,status:"success"},error:{message:m.a.t("IOT.changeDefaultExitOnFailed",{name:D}),dismissible:!0,dismissAfter:3e3,status:"error"},DevID:f},e=>{let t=r()(e.DevID)?e.DevID:[e.DevID];for(let s of t){let t=a()(u.default.getState().shadows.shadows.get(s));if(t&&t.configuration){t.configuration.defaultExit=e.CData.defaultExit;let i=new Map;i.set(s,t),u.default.dispatch(Object(l.b)(i))}}})}}function p(e,t,s=null){const{ClientID:i,LocalUserID:a,GatewayID:n,DevID:r,Name:u,isValid:l}=Object(d.a)(e);if(l){let e={animalsNumber:+t};return o.a.createAndSendMessageObject(i,n,a,r,c.n.SET_EXPEDITION_ANIMALS_NUMBER,e,{loading:{title:m.a.t("IOT.animalAmountExpedition"),message:m.a.t("IOT.changeAnimalAmountExpeditionOn",{name:u}),status:"loading",dismissible:!1,dismissAfter:0},success:{message:m.a.t("IOT.changeAnimalAmountExpeditionOnDone",{name:u}),dismissible:!0,dismissAfter:3e3,status:"success"},error:{message:m.a.t("IOT.changeAnimalAmountExpeditionOnFailed",{name:u}),dismissible:!0,dismissAfter:3e3,status:"error"},DevID:r},s)}}function T(e,t,s,i=null){const{ClientID:a,LocalUserID:n,GatewayID:r,DevID:u,Name:l,isValid:f}=Object(d.a)(e);if(f){let e={minWeight:+t,maxWeight:+s};return o.a.createAndSendMessageObject(a,r,n,u,c.n.SET_EXPEDITION_WEIGHT_RANGE,e,{loading:{title:m.a.t("IOT.weightRangeExpedition"),message:m.a.t("IOT.weightRangeExpeditionChangeOn",{name:l}),status:"loading",dismissible:!1,dismissAfter:0},success:{message:m.a.t("IOT.weightRangeExpeditionChangeOnDone",{name:l}),dismissible:!0,dismissAfter:3e3,status:"success"},error:{message:m.a.t("IOT.weightRangeExpeditionChangeOnFailed",{name:l}),dismissible:!0,dismissAfter:3e3,status:"error"},DevID:u},i)}}function A(e,t,s=null){const{ClientID:i,LocalUserID:a,GatewayID:n,DevID:r,Name:u,isValid:l}=Object(d.a)(e);if(l){let e={workType:t};return o.a.createAndSendMessageObject(i,n,a,r,c.n.SET_EXPEDITION_WORK_TYPE,e,{loading:{title:m.a.t("IOT.operatingModeExpedition"),message:m.a.t("IOT.operatingModeExpeditionChangeOn",{name:u}),status:"loading",dismissible:!1,dismissAfter:0},success:{message:m.a.t("IOT.operatingModeExpeditionChangeOnDone",{name:u}),dismissible:!0,dismissAfter:3e3,status:"success"},error:{message:m.a.t("IOT.operatingModeExpeditionChangeOnFailed",{name:u}),dismissible:!0,dismissAfter:3e3,status:"error"},DevID:r},s)}}function y(e,t,s){const{ClientID:i,LocalUserID:a,GatewayID:n,DevID:r,Name:u,isValid:l}=Object(d.a)(e);if(l){let e={minWeight:+t,maxWeight:+s};return o.a.createAndSendMessageObject(i,n,a,r,c.n.SET_SEPARATION_WEIGHT_RANGE,e,{loading:{title:m.a.t("IOT.weightRangeSeparation"),message:m.a.t("IOT.weightRangeSeparationChangeOn",{name:u}),status:"loading",dismissible:!1,dismissAfter:0},success:{message:m.a.t("IOT.weightRangeSeparationChangeOnDone",{name:u}),dismissible:!0,dismissAfter:3e3,status:"success"},error:{message:m.a.t("IOT.weightRangeSeparationChangeOnFailed",{name:u}),dismissible:!0,dismissAfter:3e3,status:"error"},DevID:r})}}function S(e){const{ClientID:t,LocalUserID:s,GatewayID:i,DevID:a,Name:n,isValid:r}=Object(d.a)(e);if(r)return o.a.createAndSendMessageObject(t,i,s,a,c.n.SET_CLEAR_ERRORS,{},{loading:{title:m.a.t("IOT.clearCageErrors"),message:m.a.t("IOT.clearCageErrorsText",{name:n}),status:"loading",dismissible:!1,dismissAfter:0},success:{message:m.a.t("IOT.clearCageErrorsSuccess",{name:n}),dismissible:!0,dismissAfter:3e3,status:"success"},error:{message:m.a.t("IOT.clearCageErrorsError",{name:n}),dismissible:!0,dismissAfter:3e3,status:"error"},DevID:a})}function E(e,t){const{ClientID:s,LocalUserID:i,GatewayID:a,DevID:n,Name:r,isValid:u}=Object(d.a)(e);if(u){let e={animalsNumber:+t};return o.a.createAndSendMessageObject(s,a,i,n,c.n.SET_SEPARATION_ANIMAL_COUNT,e,{loading:{title:m.a.t("IOT.setSeparationAnimalCount"),message:m.a.t("IOT.setSeparationAnimalCountText",{name:r}),status:"loading",dismissible:!1,dismissAfter:0},success:{message:m.a.t("IOT.setSeparationAnimalCountSuccess",{name:r}),dismissible:!0,dismissAfter:3e3,status:"success"},error:{message:m.a.t("IOT.setSeparationAnimalCountError",{name:r}),dismissible:!0,dismissAfter:3e3,status:"error"},DevID:n})}}function j(e,t,s=null,i=null){const{ClientID:a,LocalUserID:n,GatewayID:r,DevID:u,Name:l,isValid:f}=Object(d.a)(e);if(f){let e={scale:t};return o.a.createAndSendMessageObject(a,r,n,u,c.n.SET_SCALE,e,{loading:{title:m.a.t("IOT.setScale"),message:m.a.t("IOT.setScaleOn",{name:l}),status:"loading",dismissible:!1,dismissAfter:0},success:{message:m.a.t("IOT.setScaleOnDone",{name:l}),dismissible:!0,dismissAfter:3e3,status:"success"},error:{message:m.a.t("IOT.setScaleOnDone",{name:l}),dismissible:!0,dismissAfter:3e3,status:"error"},DevID:u},s,i)}}function h(e,t,s){const{ClientID:i,LocalUserID:a,GatewayID:n,DevID:r,Name:u,isValid:l}=Object(d.a)(e);if(l){let e={SW:+t,SD:+s};return o.a.createAndSendMessageObject(i,n,a,r,c.n.SET_SCALE_FACTOR,e,{loading:{title:m.a.t("weightSettings"),message:m.a.t("IOT.weightSettingsChangeOn",{name:u}),status:"loading",dismissible:!1,dismissAfter:0},success:{message:m.a.t("IOT.weightSettingsChangeOnDone",{name:u}),dismissible:!0,dismissAfter:3e3,status:"success"},error:{message:m.a.t("IOT.weightSettingsChangeOnFailed",{name:u}),dismissible:!0,dismissAfter:3e3,status:"error"},DevID:r})}}function C(e,t){const{ClientID:s,LocalUserID:i,GatewayID:a,DevID:n,Name:r,isValid:u}=Object(d.a)(e);if(u){let e={returnToDefaultExit:!!t};return o.a.createAndSendMessageObject(s,a,i,n,c.n.SET_RETURN_TO_DEFAULT_EXITL,e,{loading:{title:m.a.t("IOT.returnToDefaultExit"),message:m.a.t("IOT.setReturnToDefaultExitOn",{name:r}),status:"loading",dismissible:!1,dismissAfter:0},success:{message:m.a.t("IOT.setReturnToDefaultExitOnDone",{name:r}),dismissible:!0,dismissAfter:3e3,status:"success"},error:{message:m.a.t("IOT.setReturnToDefaultExitOnFailed",{name:r}),dismissible:!0,dismissAfter:3e3,status:"error"},DevID:n})}}function v(e,t){const{ClientID:s,LocalUserID:i,GatewayID:n,DevID:f,Name:D,isValid:I}=Object(d.a)(e);if(I){let e={attemptsNumber:+t};return o.a.createAndSendMessageObject(s,n,i,f,c.n.SET_ATTEMPTS_NUMBER,e,{loading:{title:m.a.t("amountTries"),message:m.a.t("IOT.setAmountOfTriesOn",{name:D}),status:"loading",dismissible:!1,dismissAfter:0},success:{message:m.a.t("IOT.setAmountOfTriesOnDone",{name:D}),dismissible:!0,dismissAfter:3e3,status:"success"},error:{message:m.a.t("IOT.setAmountOfTriesOnFailed",{name:D}),dismissible:!0,dismissAfter:3e3,status:"error"},DevID:f},e=>{let t=r()(e.DevID)?e.DevID:[e.DevID];for(let s of t){let t=a()(u.default.getState().shadows.shadows.get(s));if(t&&t.configuration){t.configuration.attemptsNumber=e.CData.number;let i=new Map;i.set(s,t),u.default.dispatch(Object(l.b)(i))}}})}}function _(e,t){const{ClientID:s,LocalUserID:i,GatewayID:a,DevID:n,Name:r,isValid:u}=Object(d.a)(e);if(u){let e={exitTime:+t};return o.a.createAndSendMessageObject(s,a,i,n,c.n.SET_EXIT_TIME,e,{loading:{title:m.a.t("exitTime"),message:m.a.t("IOT.setExitTimeOn",{name:r}),status:"loading",dismissible:!1,dismissAfter:0},success:{message:m.a.t("IOT.setExitTimeOnDone",{name:r}),dismissible:!0,dismissAfter:3e3,status:"success"},error:{message:m.a.t("IOT.setExitTimeOnFailed",{name:r}),dismissible:!0,dismissAfter:3e3,status:"error"},DevID:n})}}function w(e,t){const{ClientID:s,LocalUserID:i,GatewayID:a,DevID:n,Name:r,isValid:u}=Object(d.a)(e);if(u){let e={tareStatus:!!t};return o.a.createAndSendMessageObject(s,a,i,n,c.n.SET_TARE_STATUS,e,{loading:{title:m.a.t("IOT.automaticTaring"),message:m.a.t("IOT.automaticTaringChangeOn",{name:r}),status:"loading",dismissible:!1,dismissAfter:0},success:{message:m.a.t("IOT.automaticTaringChangeOnDone",{name:r}),dismissible:!0,dismissAfter:3e3,status:"success"},error:{message:m.a.t("IOT.automaticTaringChangeOnFailed",{name:r}),dismissible:!0,dismissAfter:3e3,status:"error"},DevID:n})}}function N(e,t=null,s=null){const{ClientID:i,LocalUserID:a,GatewayID:n,DevID:r,Name:u,isValid:l}=Object(d.a)(e);if(l)return o.a.createAndSendMessageObject(i,n,a,r,c.n.DO_TARE,null,{loading:{title:m.a.t("IOT.weightTaring"),message:m.a.t("IOT.weightTaringOn",{name:u}),status:"loading",dismissible:!1,dismissAfter:0},success:{message:m.a.t("IOT.weightTaredOnDone",{name:u}),dismissible:!0,dismissAfter:3e3,status:"success"},error:{message:m.a.t("IOT.weightTaredOnFailed",{name:u}),dismissible:!0,dismissAfter:3e3,status:"error"},DevID:r},t,s)}function P(e,t){const{ClientID:s,LocalUserID:i,GatewayID:a,DevID:n,Name:r,isValid:u}=Object(d.a)(e);if(u)return o.a.createAndSendMessageObject(s,a,i,n,c.n.SET_AVERAGE_WEIGHT_YESTERDAY,{yesterday:t},{loading:{title:m.a.t("IOT.setAverageWeightYesterday"),message:m.a.t("IOT.setAverageWeightYesterdayText",{name:r}),status:"loading",dismissible:!1,dismissAfter:0},success:{message:m.a.t("IOT.setAverageWeightYesterdaySuccess",{name:r}),dismissible:!0,dismissAfter:3e3,status:"success"},error:{message:m.a.t("IOT.setAverageWeightYesterdayFailure",{name:r}),dismissible:!0,dismissAfter:3e3,status:"error"},DevID:n})}function M(e,t){const{ClientID:s,LocalUserID:i,GatewayID:a,DevID:n,Name:r,isValid:u}=Object(d.a)(e);if(u)return o.a.createAndSendMessageObject(s,a,i,n,c.n.SET_NUMBERS_SEND_TO_EXITS,t,{loading:{title:m.a.t("amountAnimalsToExit"),message:m.a.t("IOT.setNumbersSendToExitsText",{name:r}),status:"loading",dismissible:!1,dismissAfter:0},success:{message:m.a.t("IOT.setNumbersSendToExitsSuccess",{name:r}),dismissible:!0,dismissAfter:3e3,status:"success"},error:{message:m.a.t("IOT.setNumbersSendToExitsFailure",{name:r}),dismissible:!0,dismissAfter:3e3,status:"error"},DevID:n})}function R(e,t,s,i,a,n){const{ClientID:r,LocalUserID:u,GatewayID:l,DevID:f,Name:D,isValid:I}=Object(d.a)(e);if(I){let e={animalsNumber:+t,minWeight:+s,maxWeight:+i,keepCounter:n,workType:a};return o.a.createAndSendMessageObject(r,l,u,f,c.n.SET_EXPEDITION_DATA,e,{loading:{title:m.a.t("IOT.setExpeditionData"),message:m.a.t("IOT.setExpeditionDataText",{name:D}),status:"loading",dismissible:!1,dismissAfter:0},success:{message:m.a.t("IOT.setExpeditionDataSuccess",{name:D}),dismissible:!0,dismissAfter:3e3,status:"success"},error:{message:m.a.t("IOT.setExpeditionDataFailed",{name:D}),dismissible:!0,dismissAfter:3e3,status:"error"},DevID:f})}}function F(e,t){const{ClientID:s,LocalUserID:i,GatewayID:a,DevID:n,Name:r,isValid:u}=Object(d.a)(e);if(u)return o.a.createAndSendMessageObject(s,a,i,n,c.n.SET_MARKING_CONFIG,t,{loading:{title:m.a.t("IOT.setMarkingConfig"),message:m.a.t("IOT.setMarkingConfigText",{name:r}),status:"loading",dismissible:!1,dismissAfter:0},success:{message:m.a.t("IOT.setMarkingConfigSuccess",{name:r}),dismissible:!0,dismissAfter:3e3,status:"success"},error:{message:m.a.t("IOT.setMarkingConfigFailed",{name:r}),dismissible:!0,dismissAfter:3e3,status:"error"},DevID:n})}function L(e,{marker1:t=!1,marker2:s=!1}){const{ClientID:i,LocalUserID:a,GatewayID:n,DevID:r,Name:u,isValid:l}=Object(d.a)(e);if(l)return o.a.createAndSendMessageObject(i,n,a,r,c.n.SET_RESET_DYE_USAGE,{markers:[!!t,!!s]},{loading:{title:m.a.t("IOT.resetMarker"),message:m.a.t("IOT.resetMarkerText",{name:u}),status:"loading",dismissible:!1,dismissAfter:0},success:{message:m.a.t("IOT.resetMarkerSuccess",{name:u}),dismissible:!0,dismissAfter:3e3,status:"success"},error:{message:m.a.t("IOT.resetMarkerFailure",{name:u}),dismissible:!0,dismissAfter:3e3,status:"error"},DevID:r})}},t9AZ:function(e,t,s){"use strict";function i(e){return function(t){t({type:"SCANNED_RFID",payload:e})}}function a(e){return function(t){t({type:"PUSH_RFID_VALUES",payload:e})}}s.d(t,"b",(function(){return i})),s.d(t,"a",(function(){return a}))},tMEj:function(e,t,s){"use strict";s.d(t,"a",(function(){return a}));var i=s("DWSH");function a(e){return function(t){t({type:"LIST_CHAMBER_SETTLEMENTS",payload:Object(i.n)({FarmID:e})})}}},u5mR:function(e,t,s){"use strict";s.d(t,"a",(function(){return d})),s.d(t,"c",(function(){return m})),s.d(t,"b",(function(){return f}));var i=s("JFDi"),a=s("fz41"),n=s("Bffz"),r=s("OwcS"),o=s("B6RA"),c=s("j1RV");function u(e,t){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),s.push.apply(s,i)}return s}function l(e,t,s){return t in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}function d(e,{FarmID:t,ClientID:s,LocalUserID:r}={}){const{_FarmID:o,_LocalUserID:c,_ClientID:d}=Object(i.a)({FarmID:t,ClientID:s,LocalUserID:r});return Object(a.c)(function(e){for(var t=1;t{console.log("changeClient res",t),s({type:"REFRESH_TOKEN",payload:Object(i.d)(),meta:{ClientID:e}}).then(()=>{s(Object(r.f)(e)),o.a.subscribeAllTopics()})}).catch(e=>{console.error(e),s(Object(n.a)("/farmChooser"))})}}function D(){return e=>{e({type:"MAINTENANCE_STATUS",payload:Object(i.c)(d({},a.a.getMaintenance()))}).catch(t=>{let s={title:u.a.t("error"),message:t.message,status:"error",dismissible:!0};e(Object(c.addNotification)(s)),console.error("checkMaintenanceStatus: ",t)})}}function I(e,t,s){return function(n){n({type:"DELETE_FARM_DATA",payload:Object(i.c)(d({},a.a.deleteFarmData({farmID:e}),{body:d({},t)}))}).then(e=>{let t={title:u.a.t("success"),message:e.value.message,status:"success",dismissible:!0,dismissAfter:0};n(Object(c.addNotification)(t)),s&&s()}).catch(e=>{const t=e.data.whiteList.join(", ");let s={title:u.a.t("error"),message:"Fermy znajduj\u0105ce si\u0119 na whitelist: ".concat(t),status:"error",dismissible:!0,dismissAfter:0};n(Object(c.addNotification)(s))})}}function O(e,t=!1,s){const{startTime:n,endTime:r}=e;return function(e){e({type:"SET_MAINTENANCE_DATE",payload:Object(i.c)(d({},a.a.setMaintenanceDate(),{body:{startTime:n,endTime:r},queryParams:{sendMail:t}}))}).then(()=>{let t={title:u.a.t("success"),message:u.a.t("popNotifications.maintenanceSuccess"),status:"success",dismissible:!0};e(Object(c.addNotification)(t)),s&&s()}).catch(t=>{let s={title:u.a.t("error"),message:t.message,status:"error",dismissible:!0};e(Object(c.addNotification)(s)),console.error("setMaintenanceDate: ",t)})}}},wxLp:function(e,t,s){"use strict";s.d(t,"a",(function(){return d})),s.d(t,"c",(function(){return m})),s.d(t,"b",(function(){return f}));var i=s("JFDi"),a=s("fz41"),n=s("Bffz"),r=s("OwcS"),o=s("B6RA"),c=s("j1RV");function u(e,t){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),s.push.apply(s,i)}return s}function l(e,t,s){return t in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}function d(e,{FarmID:t,ClientID:s,LocalUserID:r}={}){const{_FarmID:o,_LocalUserID:c,_ClientID:d}=Object(i.a)({FarmID:t,ClientID:s,LocalUserID:r});return Object(a.c)(function(e){for(var t=1;t{if(Object.assign({},s),s.value.length>0){let e=[];Object.assign(e,s.value),await a.a.insertIntoTechnologyGroup(e)}t(d(e))}).catch(()=>{t(d(e))})}}function l(){return function(e){e({type:"GET_CREATE_DAY",payload:a.a.getCreateDay()})}}function d(e){return function(t){t({type:"GET_TECHNOLOGY_GROUPS",payload:a.a.getTechnologyGroups(e)})}}},ztiR:function(e,t,s){"use strict";s.d(t,"a",(function(){return m})),s.d(t,"c",(function(){return f})),s.d(t,"b",(function(){return D}));var i=s("JFDi"),a=s("fz41"),n=s("Bffz"),r=s("OwcS"),o=s("B6RA"),c=s("j1RV"),u=s("kiXb");function l(e,t){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),s.push.apply(s,i)}return s}function d(e,t,s){return t in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}function m(e,{FarmID:t,ClientID:s,LocalUserID:r}={},o=!0){const{_FarmID:c,_LocalUserID:u,_ClientID:m}=Object(i.a)({FarmID:t,ClientID:s,LocalUserID:r});return Object(a.c)(function(e){for(var t=1;t