(this["webpackJsonpgonzo-test-client"]=this["webpackJsonpgonzo-test-client"]||[]).push([[107],{qx5e:function(e,s,t){"use strict";var i=t("E+oP"),c=t.n(i),a=t("mwIZ"),r=t.n(a),n=t("q1tI"),l=t.n(n),o=t("s506"),f=t("RTKB"),h=t("/MKj"),u=t("kCVf"),I=t("vzZS"),d=t("kiXb");s.a=e=>s=>{class t extends l.a.Component{constructor(...e){super(...e),this.state={show:!1},this.p=this.getProps()}componentDidMount(){this.setState({show:this.checkIfCanBeDisplayed()})}getProps(){return"function"===typeof e?e(this.props):e}checkIfLicPackageIsValid(e,s,t){return!(e!==o.b.BASIC||!s)||!(e!==o.b.EXTENDED||!s||!t)}checkIfCanBeDisplayed(){const{roles:e=[],clientPackage:s,devPlcmnts:t}=this.p,{farm:i,user:a}=this.props;if(a.Roles.find(e=>e.Role===o.c._SUBSCRIPTION))return e.includes(o.c._SUBSCRIPTION);let n=a.Roles.find(e=>e.Role===o.c._SERVICE);if(n){if(!i)return!0;if(!!n.LocalRights.find(e=>e.FarmID===i))return!0}const l=r()(a,"Packages[".concat(i,"]"),{});if(s){if(c()(l))return!1;if(s.administration&&!this.checkIfLicPackageIsValid(s.administration,l.admBasic,l.admExt))return!1;if(s.alarms&&!this.checkIfLicPackageIsValid(s.alarms,l.alBasic,l.alExt))return!1;if(s.cages&&!this.checkIfLicPackageIsValid(s.cages,l.cgBasic,l.cgExt))return!1;if(s.chains&&!this.checkIfLicPackageIsValid(s.chains,l.chBasic,l.chExt))return!1;if(s.climates&&!this.checkIfLicPackageIsValid(s.climates,l.clBasic,l.clExt))return!1;if(s.counters&&!this.checkIfLicPackageIsValid(s.counters,l.cntBasic,l.cntExt))return!1;if(s.dispensers5G&&!this.checkIfLicPackageIsValid(s.dispensers5G,l.di5GBasic,l.di5GExt))return!1;if(s.dispensers&&!this.checkIfLicPackageIsValid(s.dispensers,l.diBasic,l.diExt))return!1;if(s.porkers&&!this.checkIfLicPackageIsValid(s.porkers,l.porkerBasic,l.porkerExt))return!1;if(s.smallCages&&!this.checkIfLicPackageIsValid(s.smallCages,l.scBasic,l.scExt))return!1;if(s.siloses&&!this.checkIfLicPackageIsValid(s.siloses,l.slBasic,l.slExt))return!1;if(s.managment&&!this.checkIfLicPackageIsValid(s.managment,l.mngBasic,l.mngExt))return!1}let f=a.Roles.find(e=>e.Role===o.c.OWNER);if(f){if(!i)return!0;if(!!f.LocalRights.find(e=>e.FarmID===i))return!0}for(let h of e){let e=r()(a,"Roles",[]).find(e=>e.Role===h);if(!e)return!1;if(i){let s=e.LocalRights.find(e=>e.FarmID===i);if(console.log("hasRightsToFarm",s),!s)return!1;if(Array.isArray(t)&&s){if(c()(t))return!1;if(h!==o.c._DEVICE_CONFIG&&h.startsWith("_DEVICE")){const e=r()(s,"Plcmnts",[]);if("*"===e[0])return!0;{let i=r()(s,"Plcmnts",[]).filter(e=>t.includes(e));if(c()(i)){for(let s=0;st.includes(e.PlcmntID));if(!c()(i))return!0}return!1}return!0}}}}}return!0}render(){const{show:e}=this.state;return e?l.a.createElement(s,this.props):this.p.showComponent?l.a.createElement(f.a,null):this.p.showInfo?l.a.createElement(I.a,{boxColor:"warning"},d.a.t("withRoles.noAccessWarningMessage")):null}}return t.displayName="WithRoles(".concat(s.displayName||s.name||"Component",")"),Object(h.connect)(e=>({farm:e.location.farm,user:e.user.user}))(t)}}}]); //# sourceMappingURL=main~ed5688e5.e3203350.chunk.js.map