import t,{Fragment as n,createElement as i,Children as s,PureComponent as e}from"react";const r=()=>{};const o=n?t=>{if(!t)return null;return t.length>1?i(n,null,...t):s.only(t)}:s.only;class u extends e{constructor(...t){super(...t);this.t=false;this.i=null;this.o=r}componentWillUnmount(){this.o()}u(t){if(t===this.i)return;this.o();this.i=null;if(t){this.i=t;this.o=t.on("updated",(()=>this.forceUpdate()))}}get allowed(){return this.t}l(){const t=this.props;const n=t.of||t.a||t.an||t.this||t.on;const i=t.not?"cannot":"can";return t.ability[i](t.I||t.do,n,t.field)}render(){this.u(this.props.ability);this.t=this.l();return this.props.passThrough||this.t?this.h():null}h(){const{children:t,ability:n}=this.props;const i="function"===typeof t?t(this.t,n):t;return o(i)}}function c(t){var n,i;return i=n=class extends u{},n.defaultProps={ability:t},i}function l(t){return n=>i(t,null,(t=>i(u,Object.assign({ability:t},n))))}function useAbility(n){if("production"!==process.env.NODE_ENV&&"function"!==typeof t.useContext)throw new Error("You must use React >= 16.8 in order to use useAbility()");const i=t.useContext(n);const[s,e]=t.useState();t.useEffect((()=>i.on("updated",(t=>{if(t.rules!==s)e(t.rules)}))),[]);return i}export{u as Can,c as createCanBoundTo,l as createContextualCan,useAbility}; //# sourceMappingURL=index.mjs.map