class t{constructor(t=[]){this._state={},t.forEach((({type:t,intervals:e,service:i,progressive:s=!1,secability:a=1,quantity:n=0})=>{this._state[t]={intervals:e,service:i,progressive:s,secability:a,quantity:n}}))}getQuantity(t){return this._state[t].quantity}setQuantity(t,e){isNaN(e)||(this._state[t].quantity=e)}getMaxInterval(t){const{intervals:e,quantity:i}=this._state[t];return e?.find((({minRange:t,maxRange:e})=>i>=t&&i<(e??1/0)))??null}getIntervalPrice(t,i){const s=this._state[t].intervals?.[i]??null;if(null==s)return 0;const a=this._state[t].progressive,n=this._state[t].secability,{price:r}=s,c=this._state[t].quantity,u=Math.ceil(c/n)*n;if(a){const{minRange:t,maxRange:i}=s;return r*e(t,u,i??1/0)}return s===this.getMaxInterval(t)?r*u:0}getSectionPrice(t){return(this._state[t].intervals??[]).map(((e,i)=>this.getIntervalPrice(t,i))).reduce(((t,e)=>t+e),0)}getTotalPrice(){return Object.keys(this._state).map((t=>this.getSectionPrice(t))).reduce(((t,e)=>t+e),0)}}function e(t,e,i){const s=0===t?0:t-1,a=0===t?i-1:i-t;return Math.max(0,Math.min(e-s,a))}export{t as PricingConsumptionSimulator,e as getIntervalQuantity};
//# sourceMappingURL=pricing.js.map
