import {H,E as Et,R as Rt,a as V}from'./chunk-6zPu8Pcy.js';import {J,a6 as pi,ex as L$1,gt as gr,as as t,lV as wy,c as tS,aM as AD,aG as br,aA as o$1,lW as gu,bK as G,bJ as F,aa as ye,aN as r4,ad as ce}from'./main-WUGO6e7n.js';var m,o,W,L,b=J(()=>{pi();m=L$1(gr());t();wy();H();tS();AD();o="dvls.dev.trialStateOverride",W=["notStarted","ongoing","ongoingEndingSoon","expired","expiredWindowElapsed","extendedOngoing","extendedEnded","canRequestAgain"],L=(()=>{class l{constructor(e){this.serverInformationService=e,this.options=[{label:"Off (real state)",value:null},{label:"Not started",value:"notStarted"},{label:"Ongoing",value:"ongoing"},{label:"Ongoing (extension window open)",value:"ongoingEndingSoon"},{label:"Expired (can extend)",value:"expired"},{label:"Expired (window elapsed)",value:"expiredWindowElapsed"},{label:"Extended ongoing",value:"extendedOngoing"},{label:"Extended ended",value:"extendedEnded"},{label:"Spent, can request again",value:"canRequestAgain"}],this.overrideSubject=new br(this.readOverride()),this.realTrialInfo=null,this.simulatedTrialInfo=null,this.serverInformationService.privateServerInformationChange.subscribe(n=>{this.overrideSubject.getValue()&&n&&n.trialInfo!==this.simulatedTrialInfo&&(this.realTrialInfo=n.trialInfo,this.apply());});}get isAllowed(){return !o$1.production||this.serverInformationService.isFeatureFlagEnabled("TrialSimulation")}get override(){return this.overrideSubject.getValue()}setOverride(e){try{e?localStorage.setItem(o,e):localStorage.removeItem(o);}catch(n){}this.overrideSubject.next(e),this.apply();}apply(){let e=this.serverInformationService.privateServerInformation;if(!e)return;let n=this.overrideSubject.getValue();if(!n){this.simulatedTrialInfo&&(e.trialInfo=this.realTrialInfo,this.simulatedTrialInfo=null,this.serverInformationService.privateServerInformation=e);return}this.simulatedTrialInfo||(this.realTrialInfo=e.trialInfo),this.simulatedTrialInfo=this.buildTrialInfo(n),e.trialInfo=this.simulatedTrialInfo,this.serverInformationService.privateServerInformation=e;}buildTrialInfo(e){let n=this.realTrialInfo,r={trialDurationDays:n?.trialDurationDays??V,extensionDurationDays:n?.extensionDurationDays??Rt,extensionWindowDays:n?.extensionWindowDays??Et},s=I=>(0,m.default)().add(I,"days").toISOString();switch(e){case "notStarted":return new gu(G(F({},r),{isTrialActive:!1,isTrialAlreadyRequested:!1,isEnded:!1,isExtended:!1,isExpiringSoon:!1,canExtend:!1,canReRequest:!1,showWarningWhenEnds:!1,endDate:null,daysRemaining:null}));case "ongoing":return new gu(G(F({},r),{isTrialActive:!0,isTrialAlreadyRequested:!0,isEnded:!1,isExtended:!1,isExpiringSoon:!1,canExtend:!1,canReRequest:!1,showWarningWhenEnds:!0,endDate:s(12),daysRemaining:12}));case "ongoingEndingSoon":return new gu(G(F({},r),{isTrialActive:!0,isTrialAlreadyRequested:!0,isEnded:!1,isExtended:!1,isExpiringSoon:!0,canExtend:!0,canReRequest:!1,showWarningWhenEnds:!0,endDate:s(2),daysRemaining:2}));case "expired":return new gu(G(F({},r),{isTrialActive:!1,isTrialAlreadyRequested:!0,isEnded:!0,isExtended:!1,isExpiringSoon:!1,canExtend:!0,canReRequest:!1,showWarningWhenEnds:!0,endDate:s(-3),daysRemaining:0}));case "expiredWindowElapsed":return new gu(G(F({},r),{isTrialActive:!1,isTrialAlreadyRequested:!0,isEnded:!0,isExtended:!1,isExpiringSoon:!1,canExtend:!1,canReRequest:!1,showWarningWhenEnds:!0,endDate:s(-100),daysRemaining:0}));case "extendedOngoing":return new gu(G(F({},r),{isTrialActive:!0,isTrialAlreadyRequested:!0,isEnded:!1,isExtended:!0,isExpiringSoon:!1,canExtend:!1,canReRequest:!1,showWarningWhenEnds:!0,endDate:s(10),daysRemaining:10}));case "extendedEnded":return new gu(G(F({},r),{isTrialActive:!1,isTrialAlreadyRequested:!0,isEnded:!0,isExtended:!0,isExpiringSoon:!1,canExtend:!1,canReRequest:!1,showWarningWhenEnds:!0,endDate:s(-3),daysRemaining:0}));case "canRequestAgain":return new gu(G(F({},r),{isTrialActive:!1,isTrialAlreadyRequested:!0,isEnded:!0,isExtended:!1,isExpiringSoon:!1,canExtend:!1,canReRequest:!0,showWarningWhenEnds:!1,endDate:s(-400),daysRemaining:0}))}}readOverride(){try{let e=localStorage.getItem(o);return W.includes(e)?e:null}catch(e){return null}}static{this.\u0275fac=function(n){return new(n||l)(ye(r4))};}static{this.\u0275prov=ce({token:l,factory:l.\u0275fac,providedIn:"root"});}}return l})();});export{L,b};