1import{i as b,k as P,x as h}from"./chunk-QFV2VXXO.js";import{p as v,q as S}from"./chunk-SD7HBRTT.js";import{Ic as u,R as s,W as l,h as m,l as d,m as r,ma as a,s as c,sa as g}from"./chunk-LFZB7MMP.js";var p=class o extends P{apiNamespace="reward-points";getPoints(e){return c({balance:this.get("my-balance").pipe(r(i=>i.data)),settings:e?m(e):this.getSettings()}).pipe(r(({balance:i,settings:t})=>{let n=i.available_balance,f=t.conversion_method==="percentage",H=t.conversion_points>0?t.conversion_value/t.conversion_points:0,R=f?0:Math.round(n*H*100)/100;return{balance:n,worth:R,currency:"USD",conversionMethod:t.conversion_method,conversionPoints:t.conversion_points,conversionValue:t.conversion_value}}))}getBalance(){return this.get("my-balance").pipe(r(e=>e.data))}getSettings(){return this.get("my-settings",{context:new v().set(h,!0)}).pipe(r(e=>e.data))}getPointsHistory(e=1,i=20){let t=new S().set("page",e.toString()).set("per_page",i.toString());return this.get("my-history",{params:t}).pipe(r(n=>({entries:n.data?.data??[],currentPage:n.data?.current_page??e,lastPage:n.data?.last_page??1,perPage:n.data?.per_page??i,total:n.data?.total??0})))}redeemPoints(e){return this.post("redeem",{points:e})}createPointsCoupon(e){return this.post("convert-to-coupon",{points:e})}static \u0275fac=(()=>{let e;return function(t){return(e||(e=g(o)))(t||o)}})();static \u0275prov=s({token:o,factory:o.\u0275fac,providedIn:"root"})};var y=class o{pointsApi=l(p);storeApiKeyService=l(b);settingsState=a(null);redemptionEnabledState=a(!1);loadingState=a(!1);errorState=a(null);initializePromise=null;settings=this.settingsState.asReadonly();loading=this.loadingState.asReadonly();error=this.errorState.asReadonly();redemptionEnabled=u(()=>this.redemptionEnabledState());initialize(){return this.initializePromise?this.initializePromise:(this.initializePromise=this.loadSettings(),this.initializePromise)}refresh(){return this.initializePromise=this.loadSettings(),this.initializePromise}async loadSettings(){this.loadingState.set(!0),this.errorState.set(null);try{await this.storeApiKeyService.getOrResolveStoreApiKey();let e=await d(this.pointsApi.getSettings());this.settingsState.set(e),this.redemptionEnabledState.set(e.redemption_enabled)}catch{this.settingsState.set(null),this.redemptionEnabledState.set(!1),this.errorState.set("Failed to load reward points settings")}finally{this.loadingState.set(!1)}}static \u0275fac=function(i){return new(i||o)};static \u0275prov=s({token:o,factory:o.\u0275fac,providedIn:"root"})};export{p as a,y as b};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.