@flarehr/apollo-benefits 0.4.4900 → 0.4.4951
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{datadog-ffb29124.js → datadog-261280ed.js} +1 -1
- package/dist/assets/index-41898db5.js +32 -0
- package/dist/assets/{index-81bbc913.js → index-a816590e.js} +1 -1
- package/dist/assets/oidc-client-3a9688bc.js +1 -0
- package/dist/index.html +3 -3
- package/package.json +3 -3
- package/dist/assets/index-4c7fd9c5.js +0 -32
- package/dist/assets/oidc-client-6f6e47c2.js +0 -101
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
var Xn=Object.defineProperty;var Jn=(e,n,a)=>n in e?Xn(e,n,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[n]=a;var b=(e,n,a)=>(Jn(e,typeof n!="symbol"?n+"":n,a),a);import{Q as Ye,m as Zn,s as ea,E as ta,n as na,t as Zt,o as Ie,r as aa,u as t,S as ht,v as C,x as Te,z as Se,A as je,B as Ke,C as en,D as he,H as sa,I as ft,J as $,K as U,L as j,O as se,M as ra,l as f,p as h,w as ye,N as ia,q as ee,F as H,T as Y,P as y,R as nt,X as tn,U as la,W as ve,Y as ue,Z as ca,j as oa,$ as da,a0 as ma,a1 as ua,h as R,a2 as ha,a3 as fa,a4 as M,a5 as we,a6 as Xe,a7 as pa,a8 as ga,a9 as ba,aa as ya,ab as wa,ac as It,ad as va,ae as ka,af as xa,ag as Ae,ah as nn,ai as Tt,aj as an,ak as _e,al as Me,am as St,an as Lt,ao as Na,ap as sn,aq as Aa,ar as Ca,as as Pa,at as Ia,au as Ta,av as Sa,aw as pt,ax as gt,ay as F,k as La,az as Ea,aA as rn,aB as Et,aC as Oa,aD as Ba,aE as $a,aF as Ra,aG as _a,aH as Ma,aI as Ua,aJ as Va,aK as Da}from"./vendor-a6810c59.js";import{U as Fa,L as at}from"./oidc-client-3a9688bc.js";import{f as me,p as ja,a as Ot}from"./date-fns-74ba04b6.js";import{m as Bt}from"./framer-motion-44d211db.js";import{i as Wa}from"./datadog-261280ed.js";import"./lodash-5d893f8c.js";(function(){const n=document.createElement("link").relList;if(n&&n.supports&&n.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))s(i);new MutationObserver(i=>{for(const r of i)if(r.type==="childList")for(const l of r.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&s(l)}).observe(document,{childList:!0,subtree:!0});function a(i){const r={};return i.integrity&&(r.integrity=i.integrity),i.referrerPolicy&&(r.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?r.credentials="include":i.crossOrigin==="anonymous"?r.credentials="omit":r.credentials="same-origin",r}function s(i){if(i.ep)return;i.ep=!0;const r=a(i);fetch(i.href,r)}})();Ye.prototype.selectCached=function(e,n=a=>null){return this.selectHasCache().pipe(Zn(0),ea(a=>a?ta:na(e()).pipe(Zt(n))))};class V{static setParameters(n,a){this._apiBaseUrl=n,this._jwt=a}static get instance(){return Ie(this._apiBaseUrl).headers({Authorization:`Bearer ${this._jwt}`,"X-APP-VERSION":"0.4.4951"}).addon(aa)}}b(V,"_apiBaseUrl"),b(V,"_jwt");class Ha extends V{}class re extends V{}class Ne{static setParameters(n,a,s){this._apiBaseUrl=n,this._jwt=a,this._profileId=s}static get instance(){return Ie(this._apiBaseUrl).headers({Authorization:`Bearer ${this._jwt}`,"X-PROFILE-ID":this._profileId,"X-APP-VERSION":"0.4.4951"})}}b(Ne,"_apiBaseUrl"),b(Ne,"_jwt"),b(Ne,"_profileId");const Le=({size:e})=>t("svg",{className:`animate-spin h-${e??5} w-${e??5}`,viewBox:"0 0 24 24",fill:"none",children:[t("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor","stroke-width":"4"}),t("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),Je=()=>t("div",{className:"flex justify-center items-center h-screen text-primary",children:[t(Le,{size:5}),t("div",{className:"pl-3 text-xl font-light text-primary",children:"Loading..."})]}),ln="/benefits/app/assets/logo-a34e9b4b.png",za=()=>t("div",{className:"flex flex-col justify-center items-center h-screen text-grey-900",children:[t("img",{className:"block h-8 w-auto",src:ln,alt:"Flare Benefits"}),t("h1",{className:"mt-8",children:"You have been successfully logged out of Flare Benefits"})]});var $t,Rt;const We=["money","mind","body","work","life"];var He=(e=>(e.WellbeingHub="wellbeing",e.FlareApp="flareMobileApp",e.SalaryPackagingCars="salaryPackagingCars",e.Allowance="allowance",e.ApolloBenefitsConsent="apollo-benefits-consent",e.ApolloBenefitsCustomerRegistration="apollo-benefits-customer-registration",e))(He||{});const qa=["default","pba"];function Ga(){return{user:C,config:C,navTab:"benefits",appView:"employee",redirectPath:C,deepLink:C,referrer:C,promotionId:C,mode:"default",isWelcomeModalOpen:!1}}let Qa=($t=Te({name:"benefits-app",resettable:!0,producerFn:Se}),$t(Rt=class extends ht{constructor(){super(Ga())}})||Rt);const P=new Qa;class Ya extends Ye{constructor(a){super(a);b(this,"signedInUser$",this.select(a=>a.user));b(this,"appConfig$",this.select(a=>a.config));b(this,"navPage$",this.select(a=>a.navTab));b(this,"appView$",this.select(a=>a.appView));b(this,"signedInUserRole$",this.select(a=>je.pipe(a.user,Ke(()=>"user",s=>s.benefitsProfile.role))));this.store=a}}const K=new Ya(P);function T(e,n){return en(e,sa(()=>n))}function bt(e){return T(e,null)}function Ce(e,n="Option value is none."){if(he(e))throw new Error(n);return e.value}function _t(e,n){return en(e,Ke(()=>n===null,a=>a===n))}const Ka=()=>{const e=async()=>{const s=await Ie(`${window.location.origin}/benefits/app/config.json`).get().json();P.update({config:ft(s)})},n=()=>Ce(K.getValue().config);return{fetchConfigAsync:e,getConfig:n,getPublicBackendUrl:()=>n().apiBaseUrl.replace("backend","public")}},D=Ka();function pe(e,n){const a=new URLSearchParams(n);return $(a.get(e))}function st(e,n){const a=new URLSearchParams(n.replace(/^#+/,""));return $(a.get(e))}const dt=e=>{const n=D.getConfig().apiGatewayBaseUrl+"/benefits/app/#";if(e!=null&&e.startsWith(n)||e!=null&&e.startsWith("#"))return e.split("#")[1]};function Xa(e,n){return this.replace(e,n||e)}String.prototype.replaceIf=Xa;const Ja=(e,n)=>e==null?void 0:e.replaceIf("${profileId}",n==null?void 0:n.basicProfile.profileId).replaceIf("${accountId}",n==null?void 0:n.basicProfile.accountId).replaceIf("${partnerId}",n==null?void 0:n.basicProfile.partnerId).replaceIf("${customerId}",n==null?void 0:n.basicProfile.customerId);class Za{updateIsWelcomeModalOpen(n){P.update({isWelcomeModalOpen:n})}getIsWelcomeModalOpen(){return P.getValue().isWelcomeModalOpen}getReferrer(){const n=P.getValue().referrer;return U(n)?n.value:void 0}getPromotionId(){const n=P.getValue().promotionId;return U(n)?n.value:void 0}setReferrer(n){P.update({referrer:n})}setPromotionId(n){P.update({promotionId:n})}}const ge=new Za,es=()=>{const e="redirectPath",n="mode",a=r=>{P.update({redirectPath:r})},s=r=>{P.update({deepLink:r})},i=r=>{P.update({mode:r})};return{extractRedirectPath:()=>{const r=pe(e,window.location.search);U(r)&&(a(r),s(r))},extractMode(){const r=pe(n,window.location.search);U(r)&&qa.includes(r.value)&&i(r.value)},extractTrackingParameters:()=>{const r=pe("referrer",window.location.search),l=pe("promotionId",window.location.search);U(r)&&ge.setReferrer(r),U(l)&&ge.setPromotionId(l)},redirectToPathIfExists(){const r=K.getValue().redirectPath;U(r)&&(a(C),j(r.value))}}},Ue=es();let cn=class{constructor(n){b(this,"_value",C);this.factory=n}get value(){if(U(this._value))return this._value.value;const n=this.factory();return this._value=ft(n),n}};var Mt,Ut,q=(e=>(e[e.Unauthorized=0]="Unauthorized",e[e.SignInPending=1]="SignInPending",e[e.Authenticated=2]="Authenticated",e[e.SignOutPending=3]="SignOutPending",e[e.Error=4]="Error",e))(q||{});function ts(){return{authStatus:0,jwt:C}}let ns=(Mt=Te({name:"authentication",resettable:!0,producerFn:Se}),Mt(Ut=class extends ht{constructor(){super(ts())}})||Ut);const oe=new ns;var Ve=(e=>(e.SignIn="callback",e.SignOut="logout",e.SilentRefresh="silent-refresh",e))(Ve||{});class as{constructor(){b(this,"userManager");b(this,"tokenQueryParameter","token");b(this,"b2cJwtQueryParameter","b2cJwt");b(this,"profileIdQueryParameter","profileId");b(this,"getHostOidcUrl",()=>`${window.location.origin}/benefits/app/#/oidc`);this.userManager=new cn(()=>{const n=new Fa(this.userManagerSettings());return n.events.addAccessTokenExpired(()=>this.signOutRedirectAsync()),n.events.addUserLoaded(this.sessionUpdatedHandler),this.configureLogging(),n})}async refreshIfExpired(){const n=await this.userManager.value.getUser();n!=null&&n.expired&&this.userManager.value.signinSilent()}tokenExists(n){const a=pe(this.tokenQueryParameter,n);return se.isSome(a)}b2cJwtExists(n){const a=st(this.b2cJwtQueryParameter,n);return se.isSome(a)}isOidcRoute(n){return n.includes("callback")||n.includes("logout")||n.includes("silent-refresh")}async initFromB2cJwt(n,a){const s=Ce(st(this.b2cJwtQueryParameter,a),`"${this.b2cJwtQueryParameter}" fragment is required`),i=Ce(st(this.profileIdQueryParameter,a),`"${this.profileIdQueryParameter}" fragment is required`);Ne.setParameters(D.getConfig().workplaceBackendUrl,s,i);const r=await Ne.instance.url("token").get().json();window.location.href=n+"?token="+r.token}async initFromToken(n,a){if(this.isOidcRoute(n))return;const s=pe(this.tokenQueryParameter,a);if(se.isNone(s))throw oe.update({authStatus:q.Error}),Error(`"${this.tokenQueryParameter}" URL query parameter is required`);await this.signInRedirectAsync(s)}signOutRedirectAsync(){return oe.update({authStatus:q.SignOutPending}),this.userManager.value.signoutRedirect()}async signInRedirectCallbackAsync(){await this.userManager.value.signinRedirectCallback(window.location.href.replace("/oidc/callback?","")),oe.update({authStatus:q.Authenticated})}async signOutRedirectCallbackAsync(){await this.userManager.value.signoutRedirectCallback(),ra()}async silentRefreshCallbackAsync(){await this.userManager.value.signinSilentCallback()}async signOut(){return oe.update({authStatus:q.Unauthorized,jwt:se.none})}async signInRedirectAsync(n){oe.update({authStatus:q.SignInPending}),await this.userManager.value.signinRedirect({extraQueryParams:{irt:n.value}})}sessionUpdatedHandler(n){oe.update({jwt:se.fromNullable(n.access_token)})}userManagerSettings(){return{authority:D.getConfig().oidcAuthority,client_id:"apollo-benefits-ui",redirect_uri:`${this.getHostOidcUrl()}/callback?`,response_type:"code",scope:"openid",post_logout_redirect_uri:`${this.getHostOidcUrl()}/logout?`,silent_redirect_uri:`${this.getHostOidcUrl()}/silent-refresh?`,automaticSilentRenew:!0,accessTokenExpiringNotificationTimeInSeconds:10,filterProtocolClaims:!0,loadUserInfo:!0}}configureLogging(){at.setLogger(console),at.setLevel(at.DEBUG)}}const G=new as,ss=({mode:e})=>{const[n,a]=f(!1);return h(()=>{(async()=>{switch(e){case Ve.SignIn:await G.signInRedirectCallbackAsync(),window.location.hash="#",j("/"),Ue.redirectToPathIfExists();break;case Ve.SignOut:await G.signOutRedirectCallbackAsync(),a(!0);break;case Ve.SilentRefresh:await G.silentRefreshCallbackAsync();break}})()},[]),n?t(za,{}):t(Je,{})},rs=({fragment:e})=>(h(()=>{(async()=>await G.initFromB2cJwt(window.location.pathname,e))()},[]),t(Je,{}));class is extends Ye{constructor(a){super(a);b(this,"authState$",this.select());this.store=a}get isUnauthorized(){return this.getValue().authStatus===q.Unauthorized||this.getValue().authStatus===q.Error}get isAuthorized(){return this.getValue().authStatus===q.Authenticated}get jwt(){const a=this.getValue().jwt;return U(a)?a.value:""}}const on=new is(oe);class ls{constructor(){b(this,"_isLocked");b(this,"queue");b(this,"lock",n=>{this._isLocked=!0,setTimeout(this.unlockAndFlushQueue,n)});b(this,"unlockAndFlushQueue",async()=>{this._isLocked=!1,await Promise.all(this.queue.map(n=>V.instance.url("benefits/track-event").post(n).res())),this.queue=[]});this._isLocked=!1,this.queue=[]}async postTrackEventAsync(n){return this.isLocked?(this.queue.push(n),Promise.resolve()):V.instance.url("benefits/track-event").post(n).res()}get isLocked(){return this._isLocked}}const ze=new ls,cs="/customer-profile/backend/v1.0/workplace-link/config";class os{async getConfigAsync(){return re.instance.url(cs).get().json()}}const ds=new os,ms=e=>({isEstablished:e==null?void 0:e.isEstablished}),us="/flare-app-identity/backend/v1.0/auth/token";class hs{async getTokenAsync(){return re.instance.url(us).get().json()}}const fs=new hs;class ps{async getUserProfile(){return await V.instance.url("users/self").get().json()}async getBasicProfileByEmail(n){const a=await V.instance.url(`users?email=${n}`).get().notFound(()=>null).json();return $(a)}saveConsent(){V.instance.url("users/consent").post()}}const rt=new ps;class Vt{constructor(){b(this,"basicProfile");b(this,"benefitsProfile");b(this,"featureFlags");b(this,"account")}static toDomain(n){return{basicProfile:n.basicProfile,benefitsProfile:n.benefitsProfile,featureFlags:n.featureFlags,accountName:n.account?n.account.name+(n.account.legalEntityName?" - "+n.account.legalEntityName:""):void 0}}}const de=class de{static get profileId(){if(he(this._profileId))throw Error("ProfileId is missing.");return this._profileId.value}static set profileId(n){this._profileId=$(n)}static set accountId(n){this._accountId=$(n)}static get profileIdOrDefault(){return T(this._profileId,"")}static get accountIdOrDefault(){return T(this._accountId,"")}static get partnerIdOrDefault(){return T(this._partnerId,"")}extractProfileId(n){const a=$(ia(n).sub);if(he(a))throw Error("profileId property is missing.");de.profileId=a.value}async loadSignedInUserProfileAsync(){const n=Vt.toDomain(await rt.getUserProfile());de.accountId=n.basicProfile.accountId,P.update(a=>{a.user=$(n)})}saveUserConsent(){return rt.saveConsent(),P.update(n=>{const a=T(n.user,void 0);a&&(n.user=$({...a,benefitsProfile:{...a.benefitsProfile,hasConsent:!0}}))}),Promise.resolve()}async setWorkplaceLinkConfig(){const n=ms(await ds.getConfigAsync()),a=n.isEstablished?await this.fetchWorkplaceBackendTokenAsync():void 0;P.update(s=>{const i=T(s.user,void 0);i&&(s.user=$({...i,workplaceLinkConfig:{...n,workplaceBackendToken:a}}))})}setIsEstablished(){P.update(n=>{const a=T(n.user,void 0);a&&(n.user=$({...a,workplaceLinkConfig:{...a.workplaceLinkConfig,isEstablished:!0}}))})}setAllowanceCompleted(){P.update(n=>{const a=T(n.user,void 0);a&&(n.user=$({...a,featureFlags:{...a.featureFlags,allowance:!1}}))})}async updateCustomerIdAsync(n){const a=Vt.toDomain(await rt.getUserProfile()),s=a.basicProfile.customerId?await this.fetchWorkplaceBackendTokenAsync():void 0;P.update(i=>{const r=T(i.user,void 0);r&&(i.user=$({...r,workplaceLinkConfig:{...r.workplaceLinkConfig,workplaceBackendToken:s},basicProfile:{...r.basicProfile,customerId:a.basicProfile.customerId}})),n&&n()})}async fetchWorkplaceBackendTokenAsync(){try{return(await fs.getTokenAsync()).token}catch{return}}};b(de,"_profileId",C),b(de,"_accountId",C),b(de,"_partnerId",C);let mt=de;const z=ye.createContext(C),dn=ye.createContext(!1),ne=new mt,mn=()=>{const e=ee(z),n=H(()=>bt(e),[e]),a=Y(i=>{if(!n)return!1;const{featureFlags:r}=n;return r[i]},[n]),s=Y(()=>n?n.featureFlags:{},[n]);return{getTreatment:a,getAllTreatments:s}},Dt=e=>{switch(e){case"cars-calculator-gated":case"cars-calculator-ungated":return"cars-calculator";case"typeform":return"typeform";case"external-link":case"activity-advertisement":return"advertisement";case void 0:return"unknown";default:return e}};class un{constructor(n){b(this,"trackEventAsync");this.trackEventAsync=n}async trackAppLoadedAsync(){return this.trackEventAsync("appLoaded")}async trackBenefitsOpenedAsync(){return this.trackEventAsync("benefitsOpened")}async trackAppOfferViewedAsync(){return this.trackEventAsync("appOfferViewed")}async trackAppOfferAcceptedAsync(){return this.trackEventAsync("appOfferAccepted")}async trackWellbeingOpenedAsync(){return this.trackEventAsync("wellbeingOpened")}async trackAdminOpenedAsync(){return this.trackEventAsync("adminOpened")}async trackConsentStartedAsync(){return this.trackEventAsync("consentStarted")}async trackConsentCompletedAsync(){return this.trackEventAsync("consentCompleted")}async trackRegistrationStartedAsync(){return this.trackEventAsync("registrationStarted")}async trackRegistrationSubmittedAsync(){return this.trackEventAsync("registrationSubmitted")}async trackRegistrationResentAsync(){return this.trackEventAsync("registrationResent")}async trackRegistrationVerifiedAsync(){return this.trackEventAsync("registrationVerified")}async trackRegistrationFailedAsync(n){return this.trackEventAsync({registrationFailed:{reason:n}})}async trackRegistrationCompletedAsync(){return this.trackEventAsync("registrationCompleted")}async trackRegistrationErrorViewedAsync(n){return this.trackEventAsync({registrationErrorViewed:{reason:n}})}async trackRegistrationErrorDismissedAsync(){return this.trackEventAsync("registrationErrorDismissed")}async trackMarketplaceOfferViewedAsync(n,a,s){const i={offer:n,experiment:a,treatment:s};return this.trackEventAsync({marketplaceOfferViewed:i})}async trackMarketplaceOfferAcceptedAsync(n,a,s){const i={offer:n,experiment:a,treatment:s};return this.trackEventAsync({marketplaceOfferAccepted:i})}async trackPerksListViewedAsync(n){const a={pillar:n};return this.trackEventAsync({perksListViewed:a})}async trackEntriesListViewedAsync(n){const a={pillar:n};return this.trackEventAsync({entriesListViewed:a})}async trackFeaturePerkViewedAsync({benefitId:n,benefit:a}){const s={perkId:n,perkPillar:a.category,perkTitle:a.title,placement:"feature"};return this.trackEventAsync({perkViewed:s})}async trackExplorePerkViewedAsync({benefitId:n,benefit:a}){const s={perkId:n,perkPillar:a.category,perkTitle:a.title,placement:"explore"};return this.trackEventAsync({perkViewed:s})}async trackDocumentClickedAsync({benefitId:n,benefit:a}){const s={perkId:n,perkPillar:a.category,perkTitle:a.title,type:"document"};return this.trackEventAsync({attachmentOpened:s})}async trackPerkVisitedAsync({benefitId:n,benefit:a}){const s={perkId:n,perkPillar:a.category,perkTitle:a.title};return this.trackEventAsync({perkVisited:s})}async trackPerksListSearched(n){const a={query:n};return this.trackEventAsync({perksListSearched:a})}async trackRoleAssignedAsync(n){return this.trackEventAsync({roleAssigned:n})}async trackEntryViewed(n){return this.trackEventAsync({entryViewed:n})}async trackEntriesListSearchedAsync(n){const a={query:n};return this.trackEventAsync({entriesListSearched:a})}async trackCategoryOpenedAsync(n,a){const s={categoryId:n,categoryName:a};return this.trackEventAsync({categoryOpened:s})}async trackCategoryClosedAsync(n,a,s){const i={categoryId:n,categoryName:a,screen:s};return this.trackEventAsync({categoryClosed:i})}async trackDiscountsOpenedAsync(n,a){const s={categoryId:n,categoryName:a};return this.trackEventAsync({discountsOpened:s})}async trackActivityActionedAsync(n,a,s,i){i==="external-link"?this.trackActivityCompletedAsync(n,a,s,i):this.trackActivityStartedAsync(n,a,s,i)}async trackActivityStartedAsync(n,a,s,i){const r={categoryId:n,id:a,name:s,type:Dt(i)};return this.trackEventAsync({activityStarted:r})}async trackActivityCompletedAsync(n,a,s,i){const r={categoryId:n,id:a,name:s,type:Dt(i)};return this.trackEventAsync({activityCompleted:r})}async trackBenefitsPlanViewedAsync(n){const a={categories:n};return this.trackEventAsync({benefitsPlanViewed:a})}async trackDeepLinkOpenedAsync(n){const a={link:n};return this.trackEventAsync({deepLinkOpened:a})}async trackPromotionViewedAsync(n,a,s,i){return this.trackEventAsync({promotionViewed:{promotionId:n,location:a,categoryId:s,categoryName:i}})}async trackPromotionSelectedAsync(n,a,s,i,r){return this.trackEventAsync({promotionSelected:{promotionId:n,location:a,categoryId:s,categoryName:i,targetUrl:r}})}}const gs=async e=>{try{await ze.postTrackEventAsync({event:e,treatments:[]})}catch{return}},ut=new un(gs),O=()=>{const{getAllTreatments:e}=mn(),[n,a]=f(ut),s=Y(async i=>{try{await ze.postTrackEventAsync({event:i,treatments:Object.entries(e()).map(([r,l])=>({featureFlag:r,treatment:l.toString()}))||[],referrer:ge.getReferrer(),promotionId:ge.getPromotionId(),path:window.location.hash})}catch{return}},[]);return h(()=>{a(new un(s))},[s]),{service:n}};const bs="/benefits/app/assets/external_link-599a0aec.svg";function X(...e){return e.filter(Boolean).join(" ")}const ys=e=>`${e[0].toUpperCase()}${e.slice(1)}`,ws="/customer-storecards/workplace-backend/v1.0/shopify-url",vs=async(e,n)=>(await Ie(D.getConfig().apolloBaseUrl).url(ws).headers({Authorization:`Bearer ${e}`,"X-PROFILE-ID":n}).get().json()).redirectUrl,hn=async(e,n)=>{let a=null;try{a=window.open("","_blank");const s=await vs(e,n);a&&(a.location.href=s)}catch{a&&(a==null||a.close())}},Ft=({user:{featureFlags:e,basicProfile:n,workplaceLinkConfig:a}})=>{const[s,i]=f(C),{service:r}=O(),l=!!(a!=null&&a.workplaceBackendToken),c=H(()=>{const o=new Map([["benefits","/"]]);return e.wellbeing&&o.set("wellbeing","/wellbeing-hub"),Array.from(o)},[]);h(()=>{const o=[K.navPage$.subscribe(p=>{i($(p))})];return()=>{o.map(p=>p.unsubscribe())}},[]);const d=async()=>{r.trackDiscountsOpenedAsync("discounts","Discounts"),await hn(a.workplaceBackendToken,n.profileId)};return t("nav",{className:"-mb-px flex","aria-label":"Tabs",children:[c.map(([o,p])=>t("div",{onClick:async()=>{i($(o)),j(p)},className:X(_t(s,o)?"border-primary text-primary":"border-transparent text-gray-500","cursor-pointer hover:text-gray-700 hover:border-gray-300 px-4 md:ml-4 flex-grow md:flex-grow-0","py-4 text-center border-b-4 text-base leading-6 font-semibold cursor-pointer capitalize"),"aria-current":_t(s,o)?"page":void 0,children:t("span",{children:o})},o)),t("div",{className:`border-transparent text-gray-500 cursor-pointer hover:text-gray-700 hover:border-gray-300 px-4 md:ml-4
|
|
2
|
+
flex-grow md:flex-grow-0 py-4 text-center border-b-4 text-base
|
|
3
|
+
leading-6 font-semibold capitalize ${l?"":"hidden"}`,children:t("button",{className:"inline-flex",onClick:()=>{d()},children:[t("span",{children:"Discounts"}),t("img",{className:"ml-2",src:bs})]})})]})},ks=()=>{const[e,n]=f("employee");return h(()=>{const a=[K.appView$.subscribe(n)];return()=>{a.map(s=>s.unsubscribe())}},[]),t("span",{className:"relative z-0 inline-flex shadow-sm rounded-md",children:[t("button",{type:"button",className:X(e==="admin"?"text-primary bg-white cursor-default":"text-gray-700 bg-gray-50","relative inline-flex items-center px-4 py-1 rounded-l-md border border-gray-300 text-sm font-medium hover:bg-white focus:z-10 focus:outline-none"),onClick:()=>{e!=="admin"&&j("/admin")},children:"Admin view"}),t("button",{type:"button",className:X(e==="employee"?"text-primary bg-white cursor-default":"text-gray-700 bg-gray-50","-ml-px relative inline-flex items-center px-4 py-1 rounded-r-md border border-gray-300 text-sm font-medium hover:bg-white focus:z-10 focus:outline-none"),onClick:()=>{e!=="employee"&&j("/")},children:"Employee view"})]})},xs=[{name:"Admin view",href:"#/admin"},{name:"Employee view",href:"#/"}],fn=()=>t("span",{className:"inline-block h-8 w-8 rounded-full overflow-hidden bg-white border",children:t("svg",{className:"h-full w-full text-gray-300",fill:"currentColor",viewBox:"0 0 24 24",children:t("path",{d:"M24 20.993V24H0v-2.996A14.977 14.977 0 0112.004 15c4.904 0 9.26 2.354 11.996 5.993zM16.002 8.999a4 4 0 11-8 0 4 4 0 018 0z"})})}),Ns=({user:e})=>t(y,{children:t(ve,{as:"div","data-dd-action-name":"User menu",className:"z-30 relative inline-block text-left",children:({open:n})=>t(y,{children:[t("div",{children:t(ve.Button,{className:`max-w-xs bg-white flex items-center text-sm rounded-full hover:outline-none hover:ring-2 hover:ring-offset-2 hover:ring-primary ${n?"outline-none ring-2 ring-offset-2 ring-primary":""} `,children:t(fn,{})})}),t(ue,{enter:"transition ease-out duration-100",enterFrom:"transform opacity-0 scale-95",enterTo:"transform opacity-100 scale-100",leave:"transition ease-in duration-75",leaveFrom:"transform opacity-100 scale-100",leaveTo:"transform opacity-0 scale-95",children:t(ve.Items,{className:"absolute right-0 mt-2 w-56 divide-y divide-gray-100 rounded-md bg-white shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none",children:t("div",{className:"px-1 py-1 ",children:[t(ve.Item,{children:()=>t("div",{className:"mx-3 py-2",children:[t("div",{className:"text-base font-medium text-gray-800 dd-privacy-mask",children:e.basicProfile.firstName}),t("div",{className:"text-sm font-medium text-gray-500 dd-privacy-mask",children:e.basicProfile.email})]})}),t("div",{className:"border-t border-grey-900",children:t(ve.Item,{children:({active:a})=>t("button",{onClick:()=>G.signOutRedirectAsync(),className:`${a?"bg-secondary text-primary rounded-md":"text-gray-900 "} group flex w-full items-center mt-2 mb-1 px-3 py-2 text-sm font-medium`,children:"Logout"})})})]})})})]})})}),yt=e=>{const n=e.user;if(he(n))return t(y,{});const[a,s]=f(!1),i=n.value.benefitsProfile.role!=="user";return h(()=>{const r=[K.appView$.subscribe(l=>{s(l==="employee")})];return()=>{r.map(l=>l.unsubscribe())}},[]),t(y,{children:t(nt,{as:"nav",className:"bg-gray-50 border-0 md:border-b md:border-gray-200",children:({open:r})=>t(y,{children:[t("div",{className:`mx-auto px-4 sm:px-6 lg:px-8 border-b border-gray-200 md:border-none ${i&&!a?"":"max-w-[90rem]"}`,children:t("div",{className:"flex justify-between h-16",children:[t("div",{className:"flex",children:t("a",{href:"#",onClick:()=>j("/"),className:"flex-shrink-0 flex items-center",children:t("img",{className:"block h-8 w-auto",src:ln,alt:"Flare Benefits"})})}),t("div",{className:"ml-10 flex flex-wrap flex-grow content-end",children:t("div",{className:"hidden sm:block",children:a&&t(Ft,{user:n.value})})}),t("div",{className:"flex flex-wrap content-center",children:t("div",{className:"hidden md:block",children:i&&t(ks,{})})}),t("div",{className:"hidden md:ml-6 md:flex md:items-center",children:t(Ns,{user:n.value})}),t("div",{className:"-mr-2 flex items-center md:hidden",children:t(nt.Button,{className:"bg-white inline-flex items-center justify-center p-2 rounded-md text-gray-400 hover:text-gray-500 hover:bg-gray-100 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary",children:[t("span",{className:"sr-only",children:"Open main menu"}),r?t(tn,{className:"block h-6 w-6","aria-hidden":"true"}):t(la,{className:"block h-6 w-6","aria-hidden":"true"})]})})]})}),t(nt.Panel,{className:"md:hidden",children:t("div",{className:"pt-4 pb-3 border-b border-gray-200",children:[t("div",{className:"flex items-center px-4",children:[t("div",{className:"flex-shrink-0",children:t(fn,{})}),t("div",{className:"ml-3",children:[t("div",{className:"text-base font-medium text-gray-800 dd-privacy-mask",children:n.value.basicProfile.firstName}),t("div",{className:"text-sm font-medium text-gray-500 dd-privacy-mask",children:n.value.basicProfile.email})]})]}),t("div",{className:"mt-3 space-y-1",children:[i&&t(y,{children:xs.map(l=>t("a",{href:l.href,className:"block px-4 py-2 text-base font-medium text-gray-500 hover:text-primary hover:bg-secondary",children:l.name},l.name))}),t("a",{onClick:()=>G.signOutRedirectAsync(),className:"block cursor-pointer px-4 py-2 text-base font-medium text-gray-500 hover:text-primary hover:bg-secondary",children:"Logout"})]})]})}),a&&t("div",{className:"sm:hidden bg-white border-b border-gray-200",children:t(Ft,{user:n.value})})]})})})},De=()=>{const e=ee(z),{service:n}=O();return h(()=>{n.trackAppOfferAcceptedAsync()},[]),t(y,{children:[t(yt,{user:e}),t("div",{className:"p-4",children:t("workplace-link",{"access-token":on.jwt,"backend-url":D.getConfig().apiGatewayBaseUrl,source:"WebBenefits",channel:"web"})})]})},pn=()=>{const e=ca(),n=e.startsWith("state")||e.startsWith("code")||e.startsWith("error");return t(y,{children:n?t(De,{}):t("div",{className:"notfound",children:[t("h1",{children:"Error 404"}),t("p",{children:"That page doesn't exist."}),t("a",{href:"#/",children:t("h4",{children:"Back to Home"})})]})})};function ke(e){return ye.useContext(dn)?oa(e.component,e):t(Je,{})}const wt=e=>({listen:n=>e.listen(({location:a})=>n(a)),location:e.location,push:e.push,replace:e.replace}),As="/benefits-plan/backend/v1.0/categories",Cs=(e,n)=>`/benefits-plan/backend/v1.0/categories/${e}/products/${n}`;class Ps{constructor(){b(this,"_backendClientWithCacheEnabled")}get backendClientWithCacheEnabled(){return this._backendClientWithCacheEnabled||(this._backendClientWithCacheEnabled=re.instance.middlewares([da(),ma({throttle:1e4})])),this._backendClientWithCacheEnabled}async getCategoriesAsync(){return this.backendClientWithCacheEnabled.url(As).get().json()}async getProductActivitesAsync(n,a){const s=Cs(n,a);return re.instance.url(s).get().json()}}const vt=new Ps,Is=(e,n)=>e.map((a,s)=>({title:a,completed:s<=n})),gn=(e,n)=>Ie(D.getConfig().apolloBaseUrl).headers({Authorization:`Bearer ${e}`,"X-PROFILE-ID":n}),kt=async(e,n)=>{const[a]=await Promise.all([e,new Promise(s=>window.setTimeout(s,n))]);return a},Be=e=>new Promise(n=>setTimeout(n,e));class Ts{constructor(){b(this,"client",new cn(()=>{const n=D.getConfig();return ua({space:n.contentfulSpace,environment:n.contentfulEnvironment,accessToken:n.contentfulApiKey})}))}async loadCollectionsAsync(){return(await this.client.value.getEntries({content_type:"benefitsCollection"})).items.map(a=>{var i,r,l,c,d;const{fields:s}=a;return{id:a.sys.id,title:s.title,description:s.description,coverPhotoUrl:((l=(r=(i=s.coverPhoto)==null?void 0:i.fields)==null?void 0:r.file)==null?void 0:l.url)??"",pillar:((c=s.pillar)==null?void 0:c.toLowerCase())??"money",articles:((d=s.contentLibrary)==null?void 0:d.map(o=>({id:o.sys.id,title:o.fields.title,subtitle:o.fields.subtitle,coverPhotoUrl:o.fields.coverPhoto.fields.file.url,pillar:o.fields.pillar.toLowerCase(),primaryContentType:o.fields.primaryContentType.toLowerCase(),slug:"",externalLink:""})))??[],state:"visible"}})}async loadAvailableEntryPreviewsAsync(){return(await this.client.value.getEntries({"sys.contentType.sys.id[in]":"benefitsWellbeingArticle,benefitsExternalLink",select:"sys.id,fields"})).items.map(a=>{const{fields:s}=a;return{id:a.sys.id,title:s.title,subtitle:s.subtitle,coverPhotoUrl:s.coverPhoto.fields.file.url,pillar:s.pillar.toLowerCase(),primaryContentType:s.primaryContentType.toLowerCase(),slug:s.slug,externalLink:s.externalLink}})}async loadArticleAsync(n){const a=await this.client.value.getEntries({content_type:"benefitsWellbeingArticle",limit:1,include:10,"fields.slug":n});if(a.items.length===0)throw Error("Couldn't find this article");return a.items[0].fields}async loadBenefitsPlanCategoryAsync(){return(await this.client.value.getEntries({content_type:"benefitsWebCategoryTile"})).items.map(a=>a.fields)}async loadBenefitsLandingModalAsync(n){const a=await this.client.value.getEntries({content_type:"benefitsWebLandingModal",limit:1,"fields.slug":n});if(a.items.length!==0)return a.items[0].fields}async loadBenefitsPlanWebHomeAsync(){const n=await this.client.value.getEntries({content_type:"benefitsBenefitsPlanWeb",limit:1,"fields.slug":"home"});if(n.items.length===0)throw Error("Couldn't find benefits plan home.");return n.items[0].fields}async tryLoadActivityAdvertisementAsync(n){var a;try{return(a=(await this.client.value.getEntry(n)).fields.webBenefitsLandingModal)==null?void 0:a.fields}catch{return}}async loadFeaturedOffersAsync(){var s;const n=await this.client.value.getEntries({content_type:"benefitsProductOfferCategory"}),a=((s=n.includes)==null?void 0:s.Entry)??[];return n.items.map(({fields:{category:i,offers:r}})=>({category:i,offers:r.map(l=>{var o;if(typeof l!="object")return;const{sys:{id:c,type:d}}=l;return d==="Entry"?l.fields:d==="Link"?(o=a.find(p=>p.sys.id===c))==null?void 0:o.fields:void 0}).filter(l=>l)}))}async loadAllowanceContentAsync(n){return await this.client.value.getEntries({content_type:"benefitsMarketplaceContent","fields.contentId":n})}async loadBenefitsMarketplaceOfferAsync(){const n=await this.client.value.getEntries({content_type:"benefitsMarketplaceOffer",limit:1});if(n.items.length===0)throw Error("Couldn't find benefits marketplace offer.");return n.items[0].fields}}const te=new Ts,bn=["Start","Get Estimate","View","Ineligible"],Ss=async()=>kt(te.loadBenefitsPlanCategoryAsync(),700),Ls=async()=>kt(te.loadBenefitsPlanWebHomeAsync(),700),yn=e=>{switch(e.action){case"activity-assessment":return"activity-assessment";case"cars-calculator-ungated":return"cars-calculator-ungated";case"cars-calculator-gated":return"cars-calculator-gated";case"typeform":return e.typeformId?"typeform":"none";case"shopify":return"shopify";case"external-link":return e.link?"external-link":"none";case"activity-advertisement":return"activity-advertisement";default:return"none"}},Es=async e=>{const n=e.products.length>0?await vt.getProductActivitesAsync(e.id,e.products[0].id):{activities:[]};return(await Promise.all(n.activities.filter(s=>s.activityType==="Advertisement").map(async s=>{const i=await te.tryLoadActivityAdvertisementAsync(s.articleId);return i?{...i,id:s.id,title:s.title}:void 0}))).filter(s=>!!s)},wn=(e,n)=>{var a;return{id:e.slug,modalBody:e.body,disclaimer:e.disclaimer,heroImageDesktop:e.heroImageDesktop,heroImageMobile:e.heroImageMobile,buttonText:e.actionButtonText,component:yn(e),typeformId:e.typeformId,order:e.order||100,externalUrl:((a=e.link)==null?void 0:a.replace(/\s+/g,""))||void 0,categoryTitle:e.categoryTitle,assessmentId:e.assessmentId,selectionTile:e.tileDisplayTitle&&e.tileSubtitle&&e.tileImage?{activityId:e.id||"unknown",activityName:e.title||"unknown",displayTitle:e.tileDisplayTitle,subtitle:e.tileSubtitle,tileImage:e.tileImage,buttonText:(n==null?void 0:n.landingModal.fields.actionButtonText)||"Learn More",order:e.order||100}:void 0}},jt=(e,n,a)=>{const s=a.map(i=>wn(i,n));return{id:e.id,title:n.categoryTitle,displayTitle:n.displayTitle,subtitle:n.subtitle,iconUrl:e.iconUrl,order:n.order,landings:s.filter(i=>i.component!=="none").sort((i,r)=>i.order-r.order)}},Os=async e=>{try{const n=await te.loadBenefitsLandingModalAsync(e);if(n&&(n==null?void 0:n.action)!=="activity-advertisement")return[wn(n)]}catch{return[]}return[]},Bs=async()=>{try{const e=await vt.getCategoriesAsync(),n=await Ss();return(await Promise.all(e.categories.filter(s=>n.find(r=>r.categoryTitle.toLowerCase()===s.title.toLowerCase())&&bn.includes(s.status)).map(async s=>{try{const i=n.find(r=>r.categoryTitle.toLowerCase()===s.title.toLowerCase());switch(yn(i.landingModal.fields)){case"activity-advertisement":{const r=await Es(s);return r.length>0?jt(s,i,r):void 0}default:return jt(s,i,[i.landingModal.fields])}}catch{return}}))).filter(s=>!!s&&s.landings.length>0).sort((s,i)=>s.order-i.order)}catch{return[]}},$s=async(e,n)=>{try{const a=await vt.getCategoriesAsync(),s=await te.loadFeaturedOffersAsync(),i=a.categories.filter(r=>bn.includes(r.status));return s.flatMap(r=>{const l=i.find(c=>c.title.toLocaleLowerCase()===r.category.toLocaleLowerCase());return l?r.offers.filter(c=>c.displayLocations.includes(e)&&(!c.expiryDate||new Date(c.expiryDate).getTime()>Date.now())&&(!c.accounts||c.accounts.length===0||c.accounts.includes(n))).map(c=>({...c,categoryName:l.title,categoryId:l.id})):[]}).map(r=>{try{return{title:r.title,subtitle:r.subtitle,categoryId:r.categoryId,categoryName:r.categoryName,slug:r.slug,location:e,coverPhotoMobileUrl:r.coverPhoto.fields.file.url,coverPhotoDesktopUrl:r.webBannerImage.fields.file.url,linkButtonText:r.linkButtonLabel,linkUrl:r.linkUrl,order:r.displayPriority??0}}catch{return}}).filter(r=>r).sort((r,l)=>l.order-r.order)}catch{return[]}},vn=async()=>{var i;const e=P.getValue().benefitsPlanOffers;if(e)return e;const n=bt(P.getValue().user);if(!((i=n==null?void 0:n.workplaceLinkConfig)!=null&&i.workplaceBackendToken))return[];const s=(await gn(n.workplaceLinkConfig.workplaceBackendToken,n.basicProfile.profileId).url("/benefits-plan/workplace-backend/v1.0/offers").get().json()).offers.filter(r=>r.isEnabled&&r.isEligible);return P.update(r=>{r.benefitsPlanOffers=s}),s},Rs=()=>{const e=()=>K.getValue().mode;return{isDefault:()=>e()==="default",isPba:()=>e()==="pba"}},kn=Rs(),_s=({children:e,onSwipedLeft:n,onSwipedRight:a,onSwipedUp:s,onSwipedDown:i,...r})=>{const[c,d]=f(0),[o,p]=f(0),[g,w]=f(0),[x,k]=f(0);return t("div",{onTouchStart:u=>{p(0),d(u.targetTouches[0].clientX),k(0),w(u.targetTouches[0].clientY)},onTouchMove:u=>{p(u.targetTouches[0].clientX),k(u.targetTouches[0].clientY)},onTouchEnd:()=>{if(!c||!o||!g||!x)return;const S=c-o>50,_=g-x>50;Math.abs(c-o)>Math.abs(g-x)?S?n==null||n():a==null||a():_?s==null||s():i==null||i()},...r,children:e})},Ms=({autoplay:e,slidesContainerClassName:n,onSlideChange:a,children:s})=>{const[i,r]=f(0),l=R(),c=(e==null?void 0:e.enabled)&&s.length>1;if(!s)return t(y,{});const d=()=>{c&&(l.current=setInterval(g,e.interval))},o=()=>clearInterval(l.current),p=()=>{o(),d()},g=()=>{r(k=>k===s.length-1?0:k+1),p()},w=()=>{r(k=>k===0?s.length-1:k-1),p()},x=k=>{r(k),p()};return h(()=>(d(),o),[]),h(()=>{a==null||a(i)},[i]),t(_s,{onSwipedLeft:w,onSwipedRight:g,children:[t("div",{className:"relative",children:[s.length>1&&t(Us,{className:"hidden md:flex absolute top-0 left-4",onClick:w}),t("div",{className:`${n??""} flex flex-row overflow-hidden`,children:s.map((k,v)=>t(Ds,{index:v,activeIndex:i,children:k},v))}),s.length>1&&t(Vs,{className:"hidden md:flex absolute top-0 right-4",onClick:g})]}),s.length>1&&t(Fs,{itemsCount:s.length,activeIndex:i,onClick:x})]})},Us=({className:e,onClick:n})=>t("div",{className:`flex h-full items-center z-10 ${e??""}`,children:t(ha,{className:"w-7 h-7 p-1 rounded-full bg-white shadow cursor-pointer hover:bg-gray-200/50",onClick:n})}),Vs=({className:e,onClick:n})=>t("div",{className:`flex h-full items-center z-10 ${e??""}`,children:t(fa,{className:"w-7 h-7 p-1 rounded-full bg-white shadow cursor-pointer hover:bg-gray-200/50",onClick:n})}),Ds=({index:e,activeIndex:n,children:a})=>{let s;return e<n&&(s=`-${(e+1)*100}%`),e===n&&(s=`-${e*100}%`),e>n&&(s=`-${(e-1)*100}%`),t("div",{className:"w-full flex-none transition duration-500",style:{transform:`translate( ${s}, 0)`},children:a})},Fs=({itemsCount:e,activeIndex:n,onClick:a})=>t("div",{className:"mt-2 flex justify-center gap-2",children:Array(e).fill(null).map((s,i)=>t("span",{className:`inline-block w-2 h-2 cursor-pointer outline outline-4 rounded-full ${i===n?"bg-primary outline-primary/25":"bg-gray-300 outline-transparent"}`,onClick:()=>a(i)},i))}),be=e=>{const n=dt(e.href),[a,s]=f();h(()=>{const r=[K.signedInUser$.subscribe(l=>{U(l)?s(l.value):s(void 0)})];return()=>{r.map(l=>l.unsubscribe())}},[]);const i=r=>{r.preventDefault(),n&&j(n),e.onClick&&e.onClick()};return t(y,{children:n?t("a",{className:e.className,target:"_self",onClick:i,children:e.children}):t("a",{href:Ja(e.href,a),className:e.className,onClick:e.onClick,target:"_blank",rel:"noopener noreferrer",children:e.children})})},N=({height:e,width:n,className:a})=>t("div",{className:a,children:t("div",{className:"flex animate-pulse flex-row h-full",children:t("div",{style:{width:`${n?`${n}rem`:"100%"}`,height:`${e}rem`},className:"bg-gray-300 rounded"})})}),js=()=>t(y,{children:t("div",{className:"w-full bg-gray-50 border-grey-100 border rounded-lg flex",children:t("div",{className:"w-full grid grid-cols-1 md:grid-cols-2 place-items-center md:h-72 p-4 md:p-9",children:[t("div",{className:"w-full flex flex-col gap-4 md:gap-8",children:[t(N,{className:"w-1/5",height:1.5}),t(N,{className:"w-2/5",height:1.5}),t(N,{className:"w-4/5",height:1.5})]}),t(N,{className:"hidden md:block w-full",width:20,height:10})]})})}),Ws=({offers:e})=>{const n=R({}),{service:a}=O(),s=Y(r=>{if(!(e!=null&&e.length)||n.current[r])return;const l=e.find((c,d)=>d===r);l.isAppOffer?a.trackAppOfferViewedAsync():a.trackPromotionViewedAsync(l.slug,l.location,l.categoryId,l.categoryName),n.current[r]=!0},[e,a,n]),i=Y(r=>{a.trackPromotionSelectedAsync(r.slug,r.location,r.categoryId,r.categoryName,r.linkUrl)},[a]);return e?t(Ms,{autoplay:{enabled:!0,interval:5e3},slidesContainerClassName:"bg-white border-grey-100 border rounded",onSlideChange:s,children:e.map(r=>t(be,{className:"cursor-pointer",onClick:()=>i(r),href:r.linkUrl,children:t("div",{className:"md:h-[22.5rem] w-full flex flex-col md:flex-row text-gray-900",children:[t("div",{className:"md:hidden overflow-hidden w-full",children:t("img",{src:r.coverPhotoMobileUrl})}),t("div",{className:"flex flex-1 flex-col flex-grow justify-center py-4 px-4 md:py-0 md:pl-16 md:pr-0",children:[t("div",{className:"text-2xl leading-8 lg:text-3xl xl:text-4xl lg:leading-10 font-extrabold pt-4",children:r.title}),t("div",{className:"text-md md:text-lg leading-6 mt-2 font-medium max-w-lg",children:r.subtitle}),t("div",{className:"pt-5",children:t("span",{className:"block w-full mx-auto md:w-auto text-center md:inline-flex items-center px-4 py-2 border border-transparent shadow-sm text-sm leading-6 font-semibold rounded-md text-white bg-primary",children:t("span",{children:r.linkButtonText})})})]}),t("div",{className:"hidden md:block overflow-hidden",children:t("img",{src:r.coverPhotoDesktopUrl,className:"object-scale-down h-full"})})]})}))}):t(js,{})};const Hs=({children:e,className:n})=>t("div",{className:"gradient-tile "+n,children:e}),zs=({title:e,subtitle:n,externalUrl:a,icon:s,onClick:i})=>t("a",{className:"w-full cursor-pointer",href:a,target:a&&"_blank"||void 0,onClick:i,children:t(Hs,{className:"pl-6 pr-4 py-4 md:w-48 md:h-48 md:px-4 md:py-6 bg-white bg-opacity-50 hover:bg-opacity-100 shadow hover:shadow-lg border-2 rounded-md flex md:flex-col md:justify-items-center md:items-center",children:[t("div",{className:"flex justify-start item-center self-center",children:s}),t("div",{className:"ml-6 md:ml-0 md:text-center md:mt-auto",children:[t("div",{className:"text-blue-600 text-l md:text-xl font-bold leading-7",children:e}),t("div",{className:"text-gray-900 text-base font-medium leading-normal",children:n})]})]})}),qs={renderText:e=>e.split(`
|
|
4
|
+
`).flatMap((n,a)=>[a>0&&t("br",{}),n]),renderNode:{[M.BLOCKS.PARAGRAPH]:(e,n)=>t("p",{className:"relative text-gray-500 text-sm font-normal leading-5",children:n}),[M.INLINES.HYPERLINK]:(e,n)=>t("a",{className:"text-blue-600 underline",href:e.data.uri,target:"_blank",rel:"noopener noreferrer",children:n})}},Gs=({body:e})=>t(y,{children:we.documentToReactComponents(e,qs)}),Qs=()=>t(y,{children:[t(N,{className:"mb-1 md:mb-2",width:20,height:4}),t(N,{className:"mb-5 md:mb-10",width:40,height:2}),t("div",{className:"flex flex-col md:flex-row gap-3 md:gap-8 flex-wrap",children:[t(N,{className:"hidden md:block",width:12,height:12}),t(N,{className:"md:hidden block",height:6}),t(N,{className:"hidden md:block",width:12,height:12}),t(N,{className:"md:hidden block",height:6}),t(N,{className:"hidden md:block",width:12,height:12}),t(N,{className:"md:hidden block",height:6}),t(N,{className:"hidden md:block",width:12,height:12}),t(N,{className:"md:hidden block",height:6}),t(N,{className:"hidden md:block",width:12,height:12}),t(N,{className:"md:hidden block",height:6}),t(N,{className:"hidden md:block",width:12,height:12}),t(N,{className:"md:hidden block",height:6})]})]}),Ys=({categories:e,content:n})=>{const{service:a}=O(),[s,i]=f(!0),r=ge.getIsWelcomeModalOpen();return h(()=>{if(!s&&!r){const l=e?e.map(c=>c.title):[];a.trackBenefitsPlanViewedAsync(l)}},[s,r]),h(()=>{e&&(n!=null&&n.title)?i(!1):i(!0)},[e,n==null?void 0:n.title]),t("div",{className:"relative",children:[t("div",{className:"bg-[linear-gradient(0deg,_#2E66F7_0%,_#0005D2_100%)] absolute w-full h-full blur-[250px] opacity-10"}),e&&(n!=null&&n.title)?t(y,{children:[t("div",{className:"text-gray-700 text-2xl md:text-4xl font-bold md:font-extrabold leading-loose md:leading-10 mb-1 md:mb-2",children:n.title}),n.subtitle&&t("div",{className:"text-black text-base md:text-2xl font-normal leading-normal md:leading-loose mb-5 md:mb-10",children:n.subtitle}),t("div",{className:"flex flex-col md:flex-row gap-3 md:gap-8 flex-wrap mb-6",children:e==null?void 0:e.map(l=>t("div",{className:"category-container flex md:flex-col",children:t(zs,{title:l.displayTitle||l.title,subtitle:l.subtitle,icon:t("img",{src:l.iconUrl,className:"w-10 h-10 md:w-16 md:h-16"}),onClick:()=>j("/categories/"+l.title.toLocaleLowerCase())},l.id)}))}),n.disclaimer&&t(Gs,{body:n.disclaimer})]}):t(Qs,{})]})},Ks="/benefits/app/assets/all_tab_color-548783b9.svg",Xs="/benefits/app/assets/all_tab_gray-a5051313.svg",xn={money:"text-blue-400",mind:"text-green-400",body:"text-red-400",work:"text-orange-400",life:"text-yellow-400"},Wt=["all",...We],Js=({children:e})=>t("nav",{className:"flex p-2 space-x-8 bg-gray-50","aria-label":"Tabs",children:e}),Zs=e=>{const{children:n,onClick:a,className:s,selected:i}=e;return t("div",{onClick:a,className:X(s??"",i?"bg-white shadow-md text-gray-800":"text-gray-600 hover:bg-gray-100","w-full py-2 capitalize text-base leading-6 font-semibold rounded-lg focus:outline-none","cursor-pointer flex items-center justify-center"),"aria-current":i?"page":void 0,children:n})},er=({currentTab:e,tabNameList:n,onTabClicked:a})=>t(y,{children:[t("label",{htmlFor:"tabs",className:"sr-only",children:"Select a tab"}),t("select",{id:"tabs",name:"tabs",className:"block w-full pl-3 pr-10 py-2 text-base border-gray-300 focus:outline-none focus:ring-primary focus:border-primary sm:text-sm rounded-md",value:e,onChange:s=>{const i=s.currentTarget.value;a(i)},children:n.map(s=>t("option",{value:s,children:ys(s)}))})]}),tr={money:pa.faUsdSquare,mind:ga.faSpa,body:ba.faHeartbeat,work:ya.faBriefcase,life:wa.faUmbrellaBeach},Nn=(e,n)=>t(Xe,{size:n??"lg",icon:tr[e]}),An=({currentTab:e,onTabClicked:n})=>{const a=l=>Nn(l,"1x"),s=l=>t("div",{className:xn[l],children:a(l)}),i={all:t("img",{className:"h-3.5 w-3.5",src:Xs,alt:""}),...Object.fromEntries(We.map(l=>[l,a(l)]))},r={all:t("img",{className:"h-3.5 w-3.5",src:Ks,alt:""}),...Object.fromEntries(We.map(l=>[l,s(l)]))};return t(y,{children:[t("div",{className:"sm:hidden",children:t(er,{currentTab:e,onTabClicked:l=>n(l),tabNameList:[...Wt]})}),t("div",{className:"hidden sm:block",children:t(Js,{children:Wt.map(l=>t(Zs,{onClick:()=>{n(l)},selected:e===l,className:"uiid-explore-perks-tabs",children:[e===l?r[l]:i[l],t("span",{className:"uiid-explore-tab-name ml-3",children:l})]},l))})})]})},Cn=({onSearchEvent:e})=>{const n=R(null),a=R(null),[s,i]=f(!1);return h(()=>{const r=[n.current&&It(n.current,"input").pipe(va("target","value"),Zt(l=>{i(!!l)}),ka(500)).subscribe(async l=>{e(l)}),a.current&&It(a.current,"click").subscribe(()=>{n.current.value="",i(!1),e("")})];return()=>{r.map(l=>l==null?void 0:l.unsubscribe())}},[]),t("div",{className:"flex relative rounded-md shadow-sm",children:[t("div",{className:"absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none","aria-hidden":"true",children:t(xa,{className:"mr-3 h-4 w-4 text-gray-400","aria-hidden":"true"})}),t("input",{type:"text",name:"search",id:"search",ref:n,placeholder:"Search perks",className:"uiid-search-bar-input block w-full pl-9 rounded-none rounded-md sm:text-sm border-gray-300"}),t("div",{className:X(s?"":"hidden","absolute inset-y-0 right-0 pr-3 flex items-center z-10 cursor-pointer"),ref:a,children:t(Ae,{className:"h-5 w-5 text-gray-400 ","aria-hidden":"true"})})]})};var Ht,zt;const nr=()=>({all:[],money:[],mind:[],body:[],work:[],life:[]}),ar=()=>({perksTab:"all",searchString:""});let sr=(Ht=Te({name:"explore-perks",cache:{ttl:"3600000"},idKey:"benefitId",resettable:!0,producerFn:Se}),Ht(zt=class extends nn{constructor(){super(ar())}})||zt);const Pe=new sr,rr=()=>({setTab:e=>{Pe.update(n=>{n.perksTab=e})},searchPerks:e=>{Pe.update(n=>{n.searchString=e,n.perksTab="all"})}}),it=rr(),Pn=({children:e,className:n})=>t("div",{className:X(n??"","grid items-stretch sm:grid-cols-2 lg:grid-cols-3 gap-8"),children:e}),In=({children:e})=>t("div",{className:"uiid-preview-empty flex items-center justify-center sm:col-span-2 lg:col-span-3 justify-items-center content-center bg-gray-100 rounded-lg overflow-hidden h-72",children:t("div",{className:"text-xl font-medium text-gray-400 text-center",children:e})});class ir{async getBenefitsAsync(){return V.instance.url("benefits").get().json()}async postDocumentAsync(n){return V.instance.url("document").addon(Tt).formData(n).post().badRequest(a=>{throw new Error(a.message)}).json()}async postImageAsync(n){return V.instance.url("image").addon(Tt).formData(n).post().badRequest(a=>{throw new Error(a.message)}).json()}commandAsync(n,a){return V.instance.url("benefits/track-event").query(a||{}).post(n).badRequest(s=>{throw new Error(s.message)}).res()}}const ie=new ir,lr="/benefits/app/assets/workplace_link_banner_mobile-6ebaa24b.png",cr="/benefits/app/assets/workplace_link_banner_v2-c81ed849.png",or="/workplace-link";class ae extends an{constructor(a){super(a);b(this,"perksTab$",this.select(a=>a.perksTab));b(this,"all$",_e([this.selectAll()]).pipe(Me(([a])=>ae.filterPerks(a,"","all"))));b(this,"classifiedPerks$",_e([this.selectAll(),this.select(a=>a.searchString)]).pipe(Me(([a,s])=>{const i=s?ae.searchPerks(a,s):a;return ae.classifyPerks(i)})));b(this,"perksOnStage$",_e([this.selectAll(),this.select(a=>a.searchString),this.select(a=>a.perksTab)]).pipe(Me(([a,s,i])=>this.getHasCache()?se.fromNullable(ae.filterPerks(a,s,i)):C)));this.store=a}static filterPerks(a,s,i){const r=ae.searchPerks(a,s).filter(l=>i==="all"||l.benefit.category===i);return ae.excludeLocalPerk(r,or)}static searchPerks(a,s){return a.filter(i=>i.benefit.title.toLowerCase().includes(s.toLowerCase())||i.benefit.subtitle.toLowerCase().includes(s.toLowerCase()))}static classifyPerks(a){const s=nr();return a.forEach(i=>{const r=i.benefit.category;s[r].push(i)}),s.all=a,s}static findLocalPerk(a,s){const i=a.filter(r=>{var l;return(l=dt(r.benefit.url))==null?void 0:l.startsWith(s)});return i.length===0?void 0:i[0]}static excludeLocalPerk(a,s){return a.filter(r=>{var l;return!((l=dt(r.benefit.url))!=null&&l.startsWith(s))})}}const qe=new ae(Pe);var qt,Gt;function dr(){return{loading:!1,featuredPerks:C,featuredProductOffers:void 0,viewPerk:{isOpen:!1,perk:C},viewLanding:{isOpen:!1,landingSelection:[]},categories:void 0,benefitsPlanHome:void 0}}let mr=(qt=Te({name:"home-page",resettable:!0,producerFn:Se}),qt(Gt=class extends ht{constructor(){super(dr())}})||Gt);const J=new mr;class ur extends Ye{constructor(a){super(a);b(this,"homePageState$",this.select(a=>a.featuredPerks));b(this,"viewPerkState$",this.select(a=>a.viewPerk));b(this,"viewLandingState$",this.select(a=>a.viewLanding));b(this,"categoryState$",this.select(a=>a.categories));b(this,"benefitsPlanHomeState$",this.select(a=>a.benefitsPlanHome));b(this,"bannerItems$",this.select(a=>a.featuredProductOffers));this.store=a}}const Z=new ur(J),hr=()=>({getViewPageState:()=>{const e=n=>{J.update(a=>{a.featuredPerks=$(n)}),Pe.set(n.availableBenefits)};return qe.selectCached(()=>ie.getBenefitsAsync(),e)},getMarketplaceCategoryState:()=>{const e=n=>{J.update(a=>{a.categories=n})};return Z.selectCached(()=>Bs(),e)},getBenefitsPlanHome:()=>{const e=n=>{J.update(a=>{a.benefitsPlanHome=n})};return Z.selectCached(()=>Ls(),e)},getBannerItems:e=>{const n=s=>{J.update(i=>{i.featuredProductOffers=s})},a=()=>$s("webBanner",e.basicProfile.accountId).then(s=>e.featureFlags[He.FlareApp]?s.concat([{isAppOffer:!0,title:"Workplace benefits in your pocket!",subtitle:"Download the Flare app for easy access to your workplace benefits and much more.",categoryId:"",categoryName:"",slug:"",location:"webBanner",coverPhotoMobileUrl:lr,coverPhotoDesktopUrl:cr,linkButtonText:"Get Flare App",linkUrl:"#/workplace-link"}]):s);return Z.selectCached(()=>a(),n)},reloadViewPageState:()=>{Pe.setHasCache(!1)},openPerk:e=>{J.update(n=>{n.viewLanding={isOpen:!1,landingSelection:[],category:void 0},n.viewPerk={isOpen:!0,perk:ft(e)}})},closePerk:()=>{J.update(e=>{e.viewPerk.isOpen=!1})},openLanding:(e,n)=>{J.update(a=>{a.viewPerk.isOpen=!1,a.viewLanding={isOpen:!0,landingSelection:e,category:n}})},closeLanding:()=>{J.update(e=>{e.viewLanding={isOpen:!1,landingSelection:[],category:void 0}})}}),B=hr(),Tn="/benefits/app/assets/default_backdrop-fdd955b8.png",xt=e=>{const n=t(y,{children:[t("div",{className:"flex-shrink-0",children:t("img",{className:X(e.imageClassName??"h-48 w-full object-cover"),src:e.imageUrl,alt:""})}),t("div",{className:"flex-1 bg-white p-4 flex flex-col justify-between",children:e.children})]});return t("div",{onClick:e.onClick,className:X(e.className??"",e.onClick?"cursor-pointer":"","flex flex-col rounded-lg shadow-lg overflow-hidden"),children:e.externalLink?t("a",{href:e.externalLink,target:"_blank",rel:"noopener noreferrer",children:n}):n})},fr=e=>St.match(e.toLowerCase()).with("body",()=>"bg-pink-100 text-pink-800").with("life",()=>"bg-yellow-100 text-yellow-800").with("mind",()=>"bg-green-100 text-green-800").with("money",()=>"bg-blue-100 text-blue-800").with("work",()=>"bg-orange-100 text-orange-800").with(St.__,()=>"bg-gray-100 text-gray-800").exhaustive(),Nt=e=>{const n=fr(e.name),a=e.size==="xs"?"text-xs":"text-sm";return t("div",{className:X(e.className??"","capitalize inline-flex items-center px-2 py-0.5 rounded font-medium",n,a),children:e.name})},Sn=({perk:e,onClick:n,className:a})=>{var s;return t(xt,{className:a,imageUrl:((s=e.backdrop)==null?void 0:s.downloadUrl)??Tn,onClick:n,children:t("div",{className:"flex-1 pt-2 pb-7 px-2",children:[t(Nt,{className:"uiid-perk-tag",name:e.category}),t("div",{className:"block mt-2",children:[t("p",{className:"uiid-perk-item-title text-xl font-semibold text-gray-900",children:e.title}),t("p",{className:"uiid-perk-item-subtitle mt-1 text-sm text-gray-500",children:e.subtitle})]})]})})},Ln=()=>t("div",{className:"flex flex-col animate-pulse shadow-lg rounded-lg overflow-hidden",children:[t("div",{className:"flex-shrink-0",children:t("div",{className:"h-48 bg-gray-300"})}),t("div",{className:"flex-1 bg-white p-6 pb-9 flex flex-col justify-between",children:t("div",{className:"flex-1",children:[t("div",{className:"h-6 bg-gray-300 rounded w-12"}),t("div",{className:"block mt-2",children:[t("div",{className:"h-4 mt-4 bg-gray-300 rounded w-1/2"}),t("div",{className:"h-4 mt-2 bg-gray-300 rounded w-3/4"})]})]})})]}),En=()=>t(y,{children:[...Array(3).keys()].map((e,n)=>t(Ln,{},n))}),pr=()=>{const[e,n]=f(C),{service:a}=O();h(()=>{const r=[qe.perksOnStage$.subscribe(n)];return()=>{r.map(l=>l.unsubscribe())}},[]);const s=async r=>{B.openPerk(r),await a.trackExplorePerkViewedAsync(r)},i=T(e,[]).length>0?T(e,[]).map(r=>{const{benefit:l,benefitId:c}=r;return t(Sn,{className:"uiid-explore-perk",perk:l,onClick:()=>s(r)},c)}):t(In,{children:[t("p",{children:"Sorry, no entries were found matching your search request."}),t("p",{children:"Please try another search."})]});return t(Pn,{className:"uiid-perks-grid",children:he(e)?t(En,{}):i})},gr=()=>{const[e,n]=f(0),[a,s]=f("all"),{service:i}=O();h(()=>{(async()=>i.trackPerksListViewedAsync(a))();const l=[qe.all$.subscribe(c=>{n(c.length)}),qe.perksTab$.subscribe(s)];return()=>{l.map(c=>c.unsubscribe())}},[]),h(()=>()=>{it.searchPerks("")},[]);const r=async l=>{it.setTab(l),await i.trackPerksListViewedAsync(l)};return t("div",{className:"flex flex-col",style:{minHeight:window.innerHeight},children:[t("div",{className:"sm:flex sm:items-center sm:justify-between",children:[t("div",{className:"flex",children:[t("div",{className:"text-2xl md:text-4xl font-bold md:font-extrabold leading-loose md:leading-10 text-gray-700",children:"Explore other perks"}),t("div",{className:"text-2xl md:text-4xl font-bold md:font-extrabold leading-loose md:leading-10 text-gray-500 ml-2",children:["(",e,")"]})]}),t("div",{className:"mt-4 sm:mt-0",children:t(Cn,{onSearchEvent:async l=>{it.searchPerks(l),l&&await i.trackPerksListSearched(l)}})})]}),t("div",{className:"mt-4",children:t(An,{currentTab:a,onTabClicked:r})}),t("div",{className:"mt-6",children:t(pr,{})})]})},br=e=>{const{perks:n}=e,[a,s]=f(!0),{service:i}=O();h(()=>{s(he(n))},[n]);const r=c=>{B.openPerk(c),i.trackFeaturePerkViewedAsync(c)},l=T(n,[]).map(c=>{const{benefit:d,benefitId:o}=c;return t(Sn,{className:"uiid-featured-perk",perk:d,onClick:()=>r(c)},o)});return t("div",{className:"flex flex-col",children:[t("div",{className:"text-2xl md:text-4xl font-bold md:font-extrabold leading-loose md:leading-10 text-gray-700",children:"Featured Perks"}),t("div",{className:"grid sm:grid-cols-2 lg:grid-cols-3 gap-8 pt-6",children:a?t(En,{}):l})]})},Ze=({isOpen:e,fullWidthMobile:n,onClose:a,children:s})=>t(ue.Root,{show:e,as:y,children:t(Lt,{as:"div",static:!0,className:"modal fixed z-40 inset-0 overflow-y-auto",open:e,onClose:a,children:t("div",{className:`flex items-center justify-center min-h-screen md:max-h-screen mt-auto text-center ${n?"w-screen md:w-auto md:p-4":"p-4"}`,children:[t(ue.Child,{as:y,enter:"ease-out duration-300",enterFrom:"opacity-0",enterTo:"opacity-100",leave:"ease-in duration-200",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:t(Lt.Overlay,{className:"fixed inset-0 bg-black bg-opacity-75 transition-opacity"})}),t("span",{className:"hidden sm:inline-block sm:align-middle sm:h-screen","aria-hidden":"true",children:""}),t(ue.Child,{as:y,enter:"ease-out duration-300",enterFrom:"opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95",enterTo:"opacity-100 translate-y-0 sm:scale-100",leave:"ease-in duration-200",leaveFrom:"opacity-100 translate-y-0 sm:scale-100",leaveTo:"opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95",children:t("div",{className:`inline-block align-bottom transition-all md:align-middle bg-white text-left shadow-xl transform ${n?"mt-auto md:mb-auto md:rounded-lg overflow-visible":"rounded-lg overflow-hidden"}`,children:s})})]})})}),yr=e=>n=>!!n&&e(n),Ge=e=>yr(e.test.bind(e)),At=/^\+?(614|6104|04)([0-9]{2})([0-9]{3})([0-9]{3})$/,wr=/^(\+601){1}(1\d{8}|5\d{8}|(0|2|3|4|6|7|8|9)\d{7})$/,vr=/^[0-9]{6}$/,kr=/^[0-9]*$/,On=e=>{if(!e)return;const n=e.replace(/\s/g,""),a=n.match(At);return a==null?n:`04${a[2]} ${a[3]} ${a[4]}`},xr=e=>{const n=e.replace(/\s/g,""),a=n.match(At);return a==null?n:`+614${a[2]}${a[3]}${a[4]}`},Bn=e=>Ge(At)(e)||Ge(wr)(e),$n=Ge(vr),Nr=Ge(kr),Ar=({formId:e,profile:n,categoryId:a,categoryName:s})=>{const{service:i}=O(),r=()=>{i.trackActivityCompletedAsync(a,a,s,"typeform")};let l={};return n&&(l={email:n.email,first_name:n.firstName,last_name:n.lastName,mobile:On(n.mobilePhone),profile_id:n.profileId,account_id:n.accountId,partner_id:n.partnerId,customer_id:n.customerId,campaign_class:"Platform",campaign_source:"Flare",campaign_medium:"Web Benefits",campaign_name:"Benefits Assessment",skip_welcome:"true"}),t(Na.Widget,{id:e,className:"mx-auto w-screen h-screen md:h-[40rem] md:w-[95vw] md:max-w-[70rem]",hidden:l,inlineOnMobile:!0,onSubmit:r})},Cr=(e,n,a)=>{var d,o,p,g,w,x,k,v,L,m,u,S;const s=ee(z),i=T(s,void 0),r=i==null?void 0:i.basicProfile,l=i==null?void 0:i.accountName;let c={};switch(r&&(c={email:r.email,"first-name":r.firstName,"last-name":r.lastName,mobile:r.mobilePhone,"employer-name":l,"profile-id":r.profileId,"account-id":r.accountId,"partner-id":r.partnerId,"customer-id":r==null?void 0:r.customerId,"sf-class":"Platform","sf-source":"Flare","sf-medium":"Web Benefits","sf-name":"Benefits Assessment"}),a.component){case"activity-assessment":return t("div",{className:"p-10 overflow-x-hidden overflow-y-auto bg-white md:bg-transparent w-screen md:w-auto",children:((d=i==null?void 0:i.workplaceLinkConfig)==null?void 0:d.workplaceBackendToken)&&t("benefits-plan-assessment",{"base-url":e,"profile-id":r.profileId,"access-token":(o=i.workplaceLinkConfig)==null?void 0:o.workplaceBackendToken,"image-url":`${a.heroImageDesktop.fields.file.url}?fm=jpg&q=90&w=640&h=480`,"assessment-title":(k=(x=(w=(g=(p=a.modalBody)==null?void 0:p.content)==null?void 0:g.find(I=>I.nodeType==="heading-1"))==null?void 0:w.content)==null?void 0:x.find(I=>I.nodeType==="text"))==null?void 0:k.value,description:(S=(u=(m=(L=(v=a.modalBody)==null?void 0:v.content)==null?void 0:L.find((I,_)=>_===1))==null?void 0:m.content)==null?void 0:u.find(I=>I.nodeType==="text"))==null?void 0:S.value,"assessment-id":a.assessmentId,"track-client":"webBenefits","track-source":"WebBenefits","track-channel":"web","vertical-alignment":"items-center","skip-intro":"true"})});case"cars-calculator-ungated":return t("div",{className:"md:p-1",children:t("cars-calculator",{"datadog-disabled":!0,...c,"backend-url":e,"hide-employer-name":!0})});case"cars-calculator-gated":return t("div",{className:"md:p-1",children:t("cars-calculator",{"datadog-disabled":!0,...c,"backend-url":e,"is-gated":!0,"hide-employer-name":!0})});case"typeform":return a.typeformId?t(Ar,{formId:a.typeformId,profile:r,categoryId:n.id||"",categoryName:n.title||""}):t(y,{});default:return t(y,{})}},Pr=({category:e,landing:n,apolloBaseUrl:a})=>Cr(a,e,n),ce=({url:e,children:n,className:a,type:s,disabled:i,onClick:r})=>{const l=`block w-full mx-auto md:w-auto md:ml-0 text-center px-4 py-2 border border-transparent shadow-sm
|
|
5
|
+
text-sm leading-6 font-semibold rounded-md text-white bg-primary disabled:bg-gray-100 disabled:border-gray-300 disabled:text-gray-400 ${a}`;return e?t(be,{className:l,href:e,onClick:r,children:n}):t("button",{type:s||"button",className:l,disabled:i,onClick:r,children:n})},Ir={renderText:e=>e.split(`
|
|
6
|
+
`).flatMap((n,a)=>[a>0&&t("br",{}),n]),renderNode:{[M.BLOCKS.PARAGRAPH]:(e,n)=>t("p",{className:"text-xs leading-4 font-normal text-gray-600",children:n}),[M.INLINES.HYPERLINK]:(e,n)=>t(be,{className:"text-blue-600",href:e.data.uri,children:n}),[M.BLOCKS.LIST_ITEM]:(e,n)=>we.documentToReactComponents(e,{renderNode:{[M.BLOCKS.PARAGRAPH]:(a,s)=>t("p",{className:"text-gray-600 leading-5 text-sm ",children:s}),[M.BLOCKS.LIST_ITEM]:(a,s)=>t("li",{className:"flex gap-2",children:[t(Xe,{className:"text-primary w-3 h-5",icon:sn}),s]})}})}},Tr=({body:e})=>t(y,{children:we.documentToReactComponents(e,Ir)}),Sr={renderText:e=>e.split(`
|
|
7
|
+
`).flatMap((n,a)=>[a>0&&t("br",{}),n]),renderNode:{[M.BLOCKS.HEADING_1]:(e,n)=>t("h1",{className:"text-2xl leading-8 font-bold pb-2",children:n}),[M.BLOCKS.PARAGRAPH]:(e,n)=>t("p",{className:"text-base leading-6 font-normal text-gray-600 pb-4",children:n}),[M.BLOCKS.UL_LIST]:(e,n)=>t("ul",{className:"py-4 px-3 md:px-8 rounded-lg border-gray-200 border-2 shadow-sm flex flex-col space-y-2 mb-4",children:n}),[M.BLOCKS.LIST_ITEM]:(e,n)=>we.documentToReactComponents(e,{renderNode:{[M.BLOCKS.PARAGRAPH]:(a,s)=>t("p",{className:"text-gray-600 leading-5 text-sm ",children:s}),[M.BLOCKS.LIST_ITEM]:(a,s)=>t("li",{className:"flex gap-2",children:[t(Xe,{className:"text-primary w-3 h-5",icon:sn}),s]})}})}},Lr=({body:e})=>t(y,{children:we.documentToReactComponents(e,Sr)}),Er=()=>{const[e,n]=f();h(()=>{(async()=>{try{const i=await te.loadBenefitsMarketplaceOfferAsync();n(i)}catch{}})()},[]);const[a,s]=f(!1);return e?t(y,{children:[t("div",{className:"flex mt-6",children:[t(Xe,{className:"text-cyan-500 w-4 h-4",icon:Aa}),t("span",{className:"cursor-pointer text-xs text-primary ml-1",onClick:()=>s(!0),children:e.complianceContent.title})]}),t(Ze,{isOpen:a,fullWidthMobile:!0,onClose:()=>{},children:[t("div",{className:`${a?"block":"hidden"} absolute top-0 right-0 pt-4 pr-4 z-30`,children:t("button",{type:"button",className:"uiid-perk-details-close-button focus:outline-none bg-white rounded-md text-gray-500",onClick:()=>s(!1),children:[t("span",{className:"sr-only",children:"Close"}),t(Ae,{className:"h-6 w-6 border-0","aria-hidden":"true"})]})}),t("div",{className:"p-8",children:[t("h3",{className:"text-base font-semibold text-gray-900 mb-4",children:e.complianceContent.title}),t("div",{className:"prose-a:text-blue-500 prose-a:underline text-sm text-gray-600",dangerouslySetInnerHTML:{__html:e.complianceContent.subtitle}})]})]})]}):null},Or=({data:e,onClick:n,onClose:a,onPrevious:s,phiia:i})=>{var g,w;let r;const l=ee(z),c=T(l,void 0),d=(e==null?void 0:e.component)==="activity-assessment"&&!((g=c==null?void 0:c.workplaceLinkConfig)!=null&&g.workplaceBackendToken),o=(e==null?void 0:e.component)==="shopify"&&!((w=c==null?void 0:c.workplaceLinkConfig)!=null&&w.workplaceBackendToken);((e==null?void 0:e.component)==="external-link"||d)&&(e!=null&&e.externalUrl)&&(r=e==null?void 0:e.externalUrl);const p=async()=>{(e==null?void 0:e.component)==="shopify"&&await hn(c.workplaceLinkConfig.workplaceBackendToken,c.basicProfile.profileId),n()};return e?t("div",{className:s?"absolute md:relative bg-white rounded-lg":"rounded-lg",children:t("div",{className:"relative",children:[a&&t("div",{className:"absolute top-0 right-0 pt-2 md:pt-4 pr-4 z-30",children:t("button",{type:"button",className:"uiid-perk-details-close-button focus:outline-none bg-white rounded-md text-gray-500",onClick:a,children:[t("span",{className:"sr-only",children:"Close"}),t(Ae,{className:"h-6 w-6 border-0","aria-hidden":"true"})]})}),s&&t("div",{className:"absolute top-0 left-0 pl-4 pt-4 md:pl-4 md:pt-5 lg:pl-16 lg:pt-8 xl:pl-20 xl:pt-12 z-30",children:t("button",{type:"button",className:"uiid-perk-details-close-button focus:outline-none bg-white rounded-md text-gray-500",onClick:s,children:t("span",{className:"inline-flex text-sm leading-5 font-medium text-gray-600",children:[t(Ca,{className:"h-5 w-5 border-0 mr-2","aria-hidden":"true"}),"Back"]})})}),t("div",{className:"w-full grid grid-cols-1 md:grid-cols-2 md:gap-10 lg:gap-14 xl:gap-16 p-0 md:p-10 lg:p-16 xl:p-20 md:relative",children:[e.heroImageDesktop&&t("img",{src:`${e.heroImageDesktop.fields.file.url}?fm=jpg&q=90&w=640&h=480`,className:"mx-auto w-full order-2 self-start hidden md:block"}),e.heroImageMobile&&t("img",{src:`${e.heroImageMobile.fields.file.url}?fm=jpg&q=90&w=640&h=480`,className:"mx-auto mt-10 w-full self-start block md:hidden"}),t("div",{className:"flex flex-col self-start p-4 md:p-0 md: mt-4",children:[t(Lr,{body:e.modalBody}),t(ce,{className:"mb-6",onClick:p,url:r,disabled:o,children:e.buttonText}),e.disclaimer&&t(Tr,{body:e.disclaimer}),i?t(Er,{}):null]})]})]})}):t(y,{})},Br=({items:e,onClick:n})=>t("div",{className:"mx-auto w-screen md:h-auto md:w-[95vw] md:max-w-[70rem] lg:px-16 px-6 py-6 md:py-16",children:[t("h1",{className:"text-2xl leading-8 font-bold text-gray-600 text-center",children:"Offers available"}),t("div",{className:"w-full mx-auto flex flex-wrap items-stretch justify-center gap-8 gap-y-8 md:gap-x-24 py-10",children:e.map((a,s)=>t(xt,{imageUrl:a.imageUrl,className:"md:w-80 w-full",imageClassName:"md:h-32 w-full object-cover",children:[t("div",{children:[t("h2",{className:"text-lg font-bold text-gray-900 pb-0",children:a.title}),t("h3",{className:"text-sm text-gray-600 pb-2",children:a.subtitle}),t("div",{className:"flex pb-4",children:t("div",{className:"w-auto px-2 py-0.5 rounded text-xs font-medium bg-blue-100 text-blue-800",children:a.type})})]}),t(ce,{className:"md:w-full mx-0 mb-1",onClick:()=>n(a.id),children:a.buttonText})]},a.id))})]}),$r=()=>t("div",{className:"w-full grid grid-cols-1 md:grid-cols-2 md:gap-10 lg:gap-14 xl:gap-16 p-5 md:p-10 lg:p-16 xl:p-20 md:relative",children:[t(N,{className:"mx-auto w-full order-2 self-start hidden md:block",height:25}),t(N,{className:"ml-auto my-10 w-full self-start block md:hidden",height:12}),t("div",{className:"flex-col gap-3 md:gap-6 flex-wrap hidden md:flex",children:[t(N,{width:18,height:2}),t(N,{width:18,height:4}),t(N,{width:20,height:10}),t(N,{width:10,height:2}),t(N,{width:20,height:6})]}),t("div",{className:"flex flex-col md:flex-row gap-3 md:gap-6 flex-wrap md:hidden",children:[t(N,{height:2}),t(N,{height:4}),t(N,{height:2}),t(N,{height:6})]})]}),Rr=()=>{const[e,n]=f(!1),[a,s]=f(),[i,r]=f([]),[l,c]=f(),[d,o]=f("LOADING"),p=R(null),g=R(null),w=R(null),{service:x}=O(),k=()=>{var A;return(A=p.current)==null?void 0:A.scrollIntoView({behavior:"smooth",block:"start"})},v=()=>{var A;return(A=g.current)==null?void 0:A.scrollIntoView({behavior:"smooth",block:"start"})},L=()=>{var A;return(A=w.current)==null?void 0:A.scrollIntoView({behavior:"smooth",block:"start"})},m=()=>d==="LOADING",u=()=>d==="SELECTION",S=()=>d==="LANDING",I=()=>d==="ACTION",_=ee(z),et=T(_,void 0),Gn=()=>{var A,E,fe;I()?v():(l==null?void 0:l.component)!=="shopify"&&(l==null?void 0:l.component)!=="external-link"&&((l==null?void 0:l.component)!=="activity-assessment"||(A=et==null?void 0:et.workplaceLinkConfig)!=null&&A.workplaceBackendToken)&&o("ACTION"),l&&a&&x.trackActivityActionedAsync(a.id,((E=l.selectionTile)==null?void 0:E.activityId)||l.id,((fe=l.selectionTile)==null?void 0:fe.activityName)||a.title,l.component)},Ee=()=>{a&&x.trackCategoryClosedAsync(a.id,a.title,d),j("/")},Qn=A=>{const E=i.filter(fe=>fe.id===A)[0];A===(l==null?void 0:l.id)?o("LANDING"):c(E),E&&a&&x.trackActivityStartedAsync(a.id,E.selectionTile.activityId,E.selectionTile.activityName,E.component)},Yn=()=>{o("SELECTION")};h(()=>{I()&&v(),S()&&L(),u()&&k()},[d,l]),h(()=>{l&&d!=="LANDING"&&setTimeout(()=>o("LANDING"),100)},[l]),h(()=>{e&&a&&x.trackCategoryOpenedAsync(a.id,a.title)},[a,e]),h(()=>{const A=[Z.viewLandingState$.subscribe(({isOpen:E,category:fe,landingSelection:Oe})=>{n(E),E&&(s(fe),r(Oe),Oe.filter(Kn=>Kn.selectionTile).length>1?(o("SELECTION"),c(void 0)):Oe.length>0?(c(Oe[0]),o("LANDING")):(c(void 0),o("LOADING")))})];return()=>{A.map(E=>E.unsubscribe())}},[]);const Pt=i.filter(A=>A.selectionTile).map(A=>{var E;return{title:A.selectionTile.displayTitle,id:A.id,subtitle:A.selectionTile.subtitle,buttonText:A.selectionTile.buttonText||"Learn more",type:"Advertisement",imageUrl:`${(E=A.selectionTile.tileImage)==null?void 0:E.fields.file.url}?fm=jpg&q=90&w=640&h=480`}})||[],tt=Pt.length>1;return t(Ze,{isOpen:e,fullWidthMobile:!0,onClose:Ee,children:t("div",{className:"w-screen md:w-auto md:max-w-[70rem] md:rounded-lg",children:[t("div",{className:`${e?"block":"hidden"} absolute top-0 right-0 pt-4 pr-4 z-30`,children:t("button",{type:"button",className:"uiid-perk-details-close-button focus:outline-none bg-white rounded-md text-gray-500",onClick:Ee,children:[t("span",{className:"sr-only",children:"Close"}),t(Ae,{className:"h-6 w-6 border-0","aria-hidden":"true"})]})}),t("div",{className:m()?"md:grid":"hidden",children:t($r,{})}),tt&&t("div",{ref:p,className:u()?"md:grid":"md:hidden",children:t(Br,{items:Pt,onClick:Qn})}),t("div",{ref:w,className:S()?"md:grid":"hidden",children:t(Or,{data:l,onClick:Gn,onClose:tt&&Ee||void 0,onPrevious:tt&&Yn||void 0,phiia:!!(a!=null&&a.title.toLowerCase().includes("health"))})}),t("div",{ref:g,className:`${I()?"block":"hidden"} h-screen md:h-auto absolute md:relative md:rounded-lg bg-white`,children:t("div",{className:"m-auto relative",children:[t("div",{className:"md:hidden absolute top-0 right-0 pt-4 pr-4 z-30",children:t("button",{type:"button",className:"uiid-perk-details-close-button focus:outline-none bg-white rounded-md text-gray-500",onClick:Ee,children:[t("span",{className:"sr-only",children:"Close"}),t(Ae,{className:"h-6 w-6 border-0","aria-hidden":"true"})]})}),a&&l&&t(Pr,{apolloBaseUrl:D.getConfig().apolloBaseUrl,category:a,landing:l})]})})]})})},Rn="dd/MM/yyyy",_n="hh:mm a",lt="ccc d MMM",_r="p",Mr=(e,n,a)=>{if(e.data.dateRange){const s=Q(a,!1),i=Q(new Date(e.data.dateRange.end),e.data.dateRange.allDay);switch(n){case"Upcoming":return e.type==="customEvent"&&s<=i;case"Past":return e.type==="customEvent"&&s>i;case"Library":return e.type==="eventTemplate"}}else switch(n){case"Library":return e.type==="eventTemplate"}return!1},ll=(e,n)=>e.filter(a=>Mr(a,n,new Date)),Q=(e,n)=>n?new Date(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate(),0,0,0,0):new Date(e.getFullYear(),e.getMonth(),e.getDate(),0,0,0,0),cl=(e,n)=>{const a=new Date,s=ja(`${e} ${n||"12:00 AM"}`,`${Rn} ${_n}`,a);return n?Ot(s):(a.setUTCFullYear(s.getFullYear()),a.setUTCMonth(s.getMonth()),a.setUTCDate(s.getDate()),a.setUTCHours(0,0,0,0),Ot(a))},ol=(e,n)=>({date:me(Q(e,n),Rn),time:n?void 0:me(e,_n)}),dl=(e,n,a)=>{if(!e.data.dateRange)return 1;if(!n.data.dateRange)return-1;if(e.data.dateRange&&n.data.dateRange){const s=Q(new Date(e.data.dateRange.start),e.data.dateRange.allDay),i=Q(new Date(n.data.dateRange.start),n.data.dateRange.allDay),r=s<i?-1:1;return a.filter==="Past"?r*-1:r}else return 0},Ur=(e,n,a)=>{const s=Q(new Date(e),a),i=Q(new Date(n),a),r=s.getTime()===i.getTime()?me(s,lt):`${me(s,lt)} - ${me(i,lt)}`,l=a?"":`, ${me(new Date(e),_r)}`;return`${r}${l}`},ml=(e,n)=>n?e?e.getMonth()!==n.getMonth()?Qt(e):void 0:"More":e?Qt(e):void 0,ul=(e,n)=>e&&n?e.getFullYear()!==n.getFullYear()?e.getFullYear().toString():void 0:e==null?void 0:e.getFullYear().toString(),hl=(e,n,a)=>{const s=e[n],i=e[n-1];if(n===0){if(s.data.dateRange){const r=Q(new Date(s.data.dateRange.start),s.data.dateRange.allDay);return a(r,void 0)}}else if(i.data.dateRange){const r=Q(new Date(i.data.dateRange.start),i.data.dateRange.allDay);if(s.data.dateRange){const l=Q(new Date(s.data.dateRange.start),s.data.dateRange.allDay);return a(l,r)}else return a(void 0,r)}},Qt=e=>e.toLocaleString("default",{month:"long"})+" "+(e==null?void 0:e.getFullYear().toString()),Vr=({actionButton:e,item:n,itemId:a,onClose:s})=>{var l,c;const i=((l=n.backdrop)==null?void 0:l.downloadUrl)??Tn,r=(c=n.icon)==null?void 0:c.downloadUrl;return t("div",{className:"uiid-perk-details md:w-160 first-letter:overflow-hidden",children:[t("div",{className:"absolute top-0 right-0 pt-4 pr-4 z-30",children:t("button",{type:"button",className:"uiid-perk-details-close-button focus:outline-none bg-white rounded-md text-gray-500",onClick:s,children:[t("span",{className:"sr-only",children:"Close"}),t(tn,{className:"h-6 w-6 border-0","aria-hidden":"true"})]})}),e&&t("div",{className:"absolute top-0 left-0 pt-4 pl-4 z-30",children:e}),t("div",{className:"relative bg-cover bg-center",style:`background-image: url(${i})`,children:[t("div",{className:"absolute inset-0 bg-gradient-to-t from-black opacity-90"}),t("div",{className:"relative flex items-end py-4 px-8 h-64",children:t("div",{className:"flex items-center",children:[!n.dateRange&&t("div",{className:"h-24 w-24 flex-shrink-0",children:t("div",{className:"bg-gray-200 rounded-lg",children:r?t("img",{className:"h-24 w-24 object-contain rounded-lg",src:r,alt:""}):t("div",{className:"h-24 w-24 rounded-lg text-gray-800 grid",children:t("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-12 w-12 place-self-center",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:t("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1,d:"M12 8v13m0-13V6a2 2 0 112 2h-2zm0 0V5.5A2.5 2.5 0 109.5 8H12zm-7 4h14M5 12a2 2 0 110-4h14a2 2 0 110 4M5 12v7a2 2 0 002 2h10a2 2 0 002-2v-7"})})})})}),t("div",{className:`text-white ${n.dateRange?"":"pl-4"}`,children:[t("div",{className:"uiid-perk-details-title text-xl leading-6 md:text-3xl md:leading-9 font-extrabold",children:n.title}),t("div",{className:"relative text-sm leading-4 md:text-base md:leading-6 font-medium",children:[n.dateRange?Ur(n.dateRange.start,n.dateRange.end,n.dateRange.allDay):n.subtitle,n.dateRange&&n.location&&t(y,{children:[t("span",{className:"pipe pipe-white pipe-medium mx-3"}),t("span",{children:n.location})]})]}),t(Nt,{className:"uiid-perk-details-tag",name:n.category,size:"xs"})]})]})})]}),t("div",{className:"flex flex-col p-8",children:[t("div",{className:"flex-grow",children:[n.dateRange&&t("p",{className:"text-lg leading-8 font-semibold mb-4",children:n.subtitle}),t("p",{className:"whitespace-pre-wrap",children:n.description}),n.linkLabel&&n.url&&t(be,{href:n.url,onClick:()=>a&&ut.trackPerkVisitedAsync({benefit:n,benefitId:a}),className:"w-auto mt-6 inline-flex justify-center rounded-md border border-gray-300 shadow-sm px-4 py-2 text-sm leading-5 font-medium",children:n.linkLabel})]}),n.attachments&&n.attachments.length>0&&t("div",{className:"border border-gray-200 rounded-md mt-8",children:t("div",{className:"pl-3 pr-4 py-3 flex items-center justify-between text-sm",children:[t("div",{className:"w-0 flex-1 flex items-center",children:[t(Pa,{className:"flex-shrink-0 h-5 w-5 text-gray-400","aria-hidden":"true"}),t("span",{className:"ml-2 flex-1 w-0 truncate",children:n.attachments[0].title})]}),t("div",{className:"ml-4 flex-shrink-0",children:t("a",{href:n.attachments[0].downloadUrl,target:"_blank",className:"font-medium text-primary",onClick:()=>a&&ut.trackDocumentClickedAsync({benefit:n,benefitId:a}),children:"View"})})]})})]})]})},Dr=()=>{const[e,n]=f(!1),[a,s]=f(C);h(()=>{const r=[Z.viewPerkState$.subscribe(({isOpen:l,perk:c})=>{n(l),s(c)})];return()=>{r.map(l=>l.unsubscribe())}},[]);const i=bt(a);return i?t(Ze,{isOpen:e,onClose:B.closePerk,children:t(Vr,{item:i.benefit,itemId:i.benefitId,onClose:B.closePerk})}):t("div",{})},$e=({category:e,slug:n})=>{const a=ye.useContext(z),[s,i]=f(C),[r,l]=f(),[c,d]=f(),[o,p]=f(),[g,w]=f(),{service:x}=O();h(()=>{x.trackBenefitsOpenedAsync()},[]),h(()=>{n&&(!g||g.length>0&&g[0].id!=n)&&(async()=>w(await Os(n)))()},[n,g]),h(()=>{const m=Z.categoryState$.subscribe(u=>{var S;if((S=Ce(a).workplaceLinkConfig)!=null&&S.workplaceBackendToken)l(u);else{const I=u==null?void 0:u.filter(_=>_.title!=="Everyday");l(I)}});return()=>m.unsubscribe()},[a]),h(()=>{const m=[Z.homePageState$.subscribe(u=>{i(u)}),Z.benefitsPlanHomeState$.subscribe(u=>{d(u)}),Z.bannerItems$.subscribe(u=>{p(u)}),B.getViewPageState().subscribe(),B.getMarketplaceCategoryState().subscribe(),B.getBenefitsPlanHome().subscribe(),B.getBannerItems(Ce(a)).subscribe()];return()=>{m.map(u=>u.unsubscribe())}},[]),h(()=>{if(e&&!r&&B.openLanding([]),e&&r){const m=r==null?void 0:r.find(u=>u.title.toLocaleLowerCase()===e.toLocaleLowerCase());m?B.openLanding(m.landings,m):(B.closeLanding(),j("/"))}},[r,e]),h(()=>{!n&&!e&&(w(void 0),B.closeLanding())},[n,e]),h(()=>{if(n&&!g&&B.openLanding([]),n&&r&&g)if(g.length>0){const m=r==null?void 0:r.find(u=>{var S;return u.title.toLocaleLowerCase()===((S=g[0].categoryTitle)==null?void 0:S.toLocaleLowerCase())});B.openLanding(g,m)}else B.closeLanding(),j("/")},[n,g,r]);const k=je.pipe(s,Ia(m=>m.promotedBenefits)),v=je.pipe(k,Ke(()=>!1,m=>m.length>0)),L=kn.isPba();return t(y,{children:[!L&&t(yt,{user:a}),t("div",{className:"max-w-[90rem] min-w-5xl mx-auto py-8 px-4 sm:px-6 lg:px-8",children:[t("div",{className:"md:mb-16 mb-5",children:t(Ws,{offers:o})}),(!r||r.length>0&&c)&&t("div",{className:"md:mb-16 mb-5",children:t(Ys,{categories:r,content:c})}),v&&t("div",{className:"md:mb-16 mb-5",children:t(br,{perks:k})}),t("div",{children:t(gr,{})})]}),t(Dr,{}),t(Rr,{})]})};var Yt,Kt;const Fr=()=>({all:[],money:[],mind:[],body:[],work:[],life:[]}),jr=()=>({currentTab:"all",searchString:""});let Wr=(Yt=Te({name:"explore-wellbeing",cache:{ttl:"3600000"},resettable:!0,producerFn:Se}),Yt(Kt=class extends nn{constructor(){super(jr())}})||Kt);const Fe=new Wr;class Qe extends an{constructor(a){super(a);b(this,"currentTab$",this.select(a=>a.currentTab));b(this,"previewsOnStage$",_e([this.selectAll(),this.select(a=>a.searchString),this.select(a=>a.currentTab)]).pipe(Me(([a,s,i])=>this.getHasCache()?se.fromNullable(Qe.filterPreviews(a,s,i)):C)));this.store=a}get isPreviewsLoaded(){var a;return(((a=this.getValue().ids)==null?void 0:a.length)??0)>0}static filterPreviews(a,s,i){return Qe.searchPreviews(a,s).filter(r=>i==="all"||r.pillar===i)}static searchPreviews(a,s){return a.filter(i=>i.title.toLowerCase().includes(s.toLowerCase())||i.subtitle.toLowerCase().includes(s.toLowerCase()))}static classifyPreviews(a){const s=Fr();return a.forEach(i=>{const r=i.pillar;s[r].push(i)}),s.all=a,s}}const Ct=new Qe(Fe),Hr=()=>({setTab:e=>{Fe.update(n=>{n.currentTab=e})},searchPreviews:e=>{Fe.update(n=>{n.searchString=e,n.currentTab="all"})},loadEntryPreviews:()=>Ct.selectCached(()=>te.loadAvailableEntryPreviewsAsync(),e=>Fe.set(e))}),xe=Hr(),zr=()=>t(y,{children:[...Array(3).keys()].map((e,n)=>t(Ln,{},n))}),qr=()=>{const[e,n]=f(C),{service:a}=O();h(()=>{const r=[Ct.previewsOnStage$.subscribe(n)];return()=>{r.map(l=>l.unsubscribe())}},[]);const s=async r=>{r.externalLink||j(`/wellbeing-hub/articles/${r.slug}`),a.trackEntryViewed({contentId:r.id,contentTitle:r.slug,contentType:r.primaryContentType,contentPillar:r.pillar})},i=T(e,[]).length>0?T(e,[]).map(r=>t(xt,{className:"uiid-preview-item",imageUrl:`${r.coverPhotoUrl}?fm=jpg&q=50&w=640&h=480`,externalLink:r.externalLink,onClick:()=>s(r),children:t("div",{className:"flex-1 pb-7 pt-2 px-2",children:[t("div",{className:"flex items-center",children:[t(Nt,{className:"uiid-preview-tag",name:r.pillar}),t("div",{className:"text-sm leading-5 font-normal px-2 text-gray-300",children:"|"}),t("div",{className:"text-xs leading-4 font-semibold tracking-wider uppercase text-gray-400",children:r.primaryContentType}),t("div",{className:"flex-grow"}),r.externalLink&&t(Ta,{className:"h-5 w-5 text-gray-400 border-0"})]}),t("div",{className:"block mt-2",children:[t("p",{className:"uiid-preview-item-title text-xl font-semibold text-gray-900",children:r.title}),t("p",{className:"uiid-preview-item-subtitle mt-1 text-sm text-gray-500",children:r.subtitle})]})]})},r.id)):t(In,{children:[t("p",{children:"Sorry, no entries were found matching your search request."}),t("p",{children:"Please try another search."})]});return t(Pn,{className:"uiid-preview-grid",children:he(e)?t(zr,{}):i})},Gr=()=>{const[e,n]=f("all"),{service:a}=O();h(()=>{const r=[Ct.currentTab$.subscribe(n),xe.loadEntryPreviews().subscribe()];return()=>{r.map(l=>l.unsubscribe())}},[]),h(()=>()=>{xe.searchPreviews("")},[]);const s=async r=>{xe.setTab(r),j(`/wellbeing-hub/${r}`),a.trackEntriesListViewedAsync(r)},i=async r=>{xe.searchPreviews(r),a.trackEntriesListSearchedAsync(r)};return t("div",{className:"flex flex-col",style:{minHeight:window.innerHeight},children:[t("div",{className:"sm:flex sm:items-center sm:justify-between",children:[t("div",{className:"flex",children:t("div",{className:"text-3xl leading-9 font-semibold text-gray-700",children:"Explore the 5 pillars of wellness"})}),t("div",{className:"mt-4 sm:mt-0",children:t(Cn,{onSearchEvent:i})})]}),t("div",{className:"mt-4",children:t(An,{currentTab:e,onTabClicked:s})}),t("div",{className:"mt-6",children:t(qr,{})})]})},Qr="/benefits/app/assets/wellbeing_banner-6903d615.png",Yr=({bgImageUrl:e,className:n,children:a,excludeGradient:s})=>{const i=e?{backgroundImage:`url(${e})`}:{};return t("div",{className:X("relative w-full rounded-lg bg-cover bg-center",n??""),style:i,children:[!s&&t(y,{children:[t("div",{className:"absolute inset-0 rounded-lg bg-black bg-opacity-10"}),t("div",{className:"absolute inset-0 rounded-lg bg-gradient-to-r from-black opacity-80"})]}),t("div",{className:"relative h-full rounded-lg overflow-hidden",children:a})]})},Kr=({children:e})=>t("div",{className:"relative filter inline-flex items-center w-12 h-12 rounded-lg text-md font-medium bg-black bg-opacity-40 text-gray-800",children:[t("div",{className:"absolute inset-0 rounded-lg bg-gradient-to-b from-black bg-opacity-50"}),t("div",{className:"relative h-full w-full flex flex-wrap content-center justify-center",children:e})]}),Xr=()=>t("div",{className:"flex gap-4",children:We.map(e=>t(Kr,{children:t("div",{className:xn[e],children:Nn(e)})}))}),Jr=()=>t(Yr,{className:"h-full",bgImageUrl:Qr,children:t("div",{className:"px-4 py-10 md:px-8 md:py-24 text-white",children:[t("div",{className:"text-2xl leading-8 font-bold",children:"Wellbeing Hub"}),t("div",{className:"max-w-sm text-md md:text-lg leading-6 mt-1 font-medium hidden md:block",children:"Providing education, support and tools to help you live a healthier and happier life!"}),t("div",{className:"pt-4 hidden md:block",children:t(Xr,{})})]})}),Xt=({pillarFilter:e})=>{const n=R(null),{service:a}=O();return h(()=>{a.trackWellbeingOpenedAsync()},[]),h(()=>{var s;xe.setTab(e??"all"),a.trackEntriesListViewedAsync(e??"all"),e&&((s=n.current)==null||s.scrollIntoView({behavior:"smooth"}))},[e,n]),t("div",{className:"max-w-7xl min-w-5xl mx-auto px-4 py-8 sm:px-6 lg:px-8 mb-20",children:[t("div",{className:"flex flex-col md:flex-row",children:t("div",{className:"w-full",children:t(Jr,{})})}),t("div",{className:"mt-8 pt-4",ref:n,children:t(Gr,{})})]})},Zr=({pages:e,homePageUrl:n})=>t("nav",{className:"bg-white border-b border-gray-200 flex","aria-label":"Breadcrumb",children:t("ol",{role:"list",className:"max-w-screen-xl w-full mx-auto px-4 flex space-x-4 sm:px-6 lg:px-8",children:[t("li",{className:"flex",children:t("div",{className:"flex items-center",children:t("a",{href:n??"#",className:"text-gray-400 hover:text-gray-500",children:[t(Sa,{className:"flex-shrink-0 h-5 w-5","aria-hidden":"true"}),t("span",{className:"sr-only",children:"Home"})]})})}),e.map((a,s)=>t("li",{className:"flex",children:t("div",{className:"flex items-center",children:[t("svg",{className:"flex-shrink-0 w-6 h-full text-gray-200",viewBox:"0 0 24 44",preserveAspectRatio:"none",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:t("path",{d:"M.293 0l22 22-22 22h1.414l22-22-22-22H.293z"})}),t("a",{href:a.href,className:"ml-4 text-sm font-medium text-gray-500 hover:text-gray-700","aria-current":e.length===s+1?"page":void 0,children:a.name})]})},a.name))]})}),ei=(e,n,a)=>{h(()=>{let s=!0;return e(()=>s),()=>{s=!1,je.pipe(n,Ke(()=>{},i=>i()))}},a)},ti=(e,n)=>{h(()=>{window.scrollTo(e)},n)},ni=(e,n)=>{ti({top:0,...e},n)},ai={renderNode:{[M.BLOCKS.EMBEDDED_ASSET]:e=>{const{title:n,description:a,file:s}=e.data.target.fields;return t("figure",{children:[t("img",{src:`${s.url}?fm=jpg&q=90&w=640&h=480`,alt:n}),t("figcaption",{children:a})]})}}},si=({body:e})=>t("article",{className:"prose prose-lg prose-indigo",children:we.documentToReactComponents(e,ai)}),ri=()=>t("div",{className:"max-w-3xl mx-auto py-6 px-4 sm:py-10 sm:px-6 lg:px-8 animate-pulse",children:[t("div",{class:"h-8 bg-gray-200 rounded w-2/3"}),t("div",{className:"flex space-x-3 mt-4",children:[t("div",{className:"flex-shrink-0",children:t("div",{class:"rounded-full bg-gray-200 h-10 w-10 mr-1"})}),t("div",{className:"min-w-0 flex flex-col justify-between flex-1",children:[t("div",{class:"h-4 bg-gray-200 rounded w-1/3"}),t("div",{class:"h-4 bg-gray-200 rounded w-1/4"})]})]}),t("div",{className:"mt-8",children:t("div",{class:"flex-1 space-y-8 py-1",children:[t("div",{class:"h-8 bg-gray-200 rounded w-3/4"}),t("div",{class:"h-48 bg-gray-200 rounded w-full"}),t("div",{class:"h-24 bg-gray-200 rounded w-3/4"}),t("div",{class:"h-36 bg-gray-200 rounded w-full"}),t("div",{class:"h-12 bg-gray-200 rounded w-1/4"})]})})]}),ii=({articleSlug:e})=>{const[n,a]=f();if(ei(async i=>{const r=await kt(te.loadArticleAsync(e),700);i()&&a(r)},se.none,[e]),ni(),!n)return t(Bt.div,{initial:{opacity:0},animate:{opacity:1},children:t(ri,{})},"loading");const s=[{name:n==null?void 0:n.pillar,href:`#/wellbeing-hub/${n==null?void 0:n.pillar.toLowerCase()}`}];return t(y,{children:[t(Zr,{pages:s,homePageUrl:"#/wellbeing-hub"}),t(Bt.div,{initial:{opacity:0},animate:{opacity:1},children:t("div",{className:"max-w-3xl mx-auto py-6 px-4 sm:py-10 sm:px-6 lg:px-8",children:[t("h2",{className:"text-4xl leading-10 font-extrabold tracking-tight",children:n.title}),t("div",{className:"flex space-x-3 mt-4",children:[t("div",{className:"flex-shrink-0",children:t("img",{className:"h-10 w-10 rounded-full",src:`${n.author.fields.avatar.fields.file.url}?fm=jpg&q=90&w=640&h=480`,alt:""})}),t("div",{className:"min-w-0 flex-1",children:[t("p",{className:"text-sm font-medium text-gray-900",children:n.author.fields.name}),t("p",{className:"text-sm text-gray-500",children:me(new Date(n.originalPublicationDate),"dd MMM yyyy")})]})]}),t("div",{className:"mt-8",children:t(si,{body:n.articleBody})})]})},"article")]})},li=()=>{const e=ye.useContext(z),n=kn.isPba();return t(y,{children:[!n&&t(yt,{user:e}),t(pt,{history:wt(gt()),children:[t(F,{path:"/wellbeing-hub",component:Xt}),t(F,{path:"/wellbeing-hub/:pillarFilter",component:Xt}),t(F,{path:"/wellbeing-hub/articles/:articleSlug",component:ii})]})]})};var Mn=(e=>(e.Auth_AccountDisabled="Sorry, your account has been deactivated. Please contact Flare if there are any issues.",e.Auth_AccountLocked="Sorry, your account is currently locked due to too many attempts. Please try again later.",e.Auth_Unregistered="Sorry, we are currently experiencing some issues. Please try again later.",e.Auth_InvalidVerificationCode="Your one time passcode doesn't look right. Please try again.",e.Auth_SessionExpired="Sorry, looks like your session has expired. Please try again.",e.Validation_InvalidPhoneNumber="Please enter a valid Australian mobile number beginning with 04.",e))(Mn||{});const Un="Sorry, we are currently experiencing some issues. Please try again later.",ci=e=>e&&Mn[e]||Un,oi="/benefits-onboarding/backend/auth/signup",di="/benefits-onboarding/backend/auth/verify",mi="/benefits-onboarding/backend/auth/resend",ct={source:"WebBenefits",channel:"web"},W=e=>{const n=e.json;throw new Error(ci(n==null?void 0:n.code))};class ui{signUpAsync(n){return re.instance.url(oi).query(ct).post(n).internalError(W).badRequest(W).unauthorized(W).fetchError(W).res()}verifyAsync(n){return re.instance.url(di).query(ct).post(n).internalError(W).badRequest(W).unauthorized(W).fetchError(W).res()}resendAsync(){return re.instance.url(mi).query(ct).post().internalError(W).badRequest(W).unauthorized(W).fetchError(W).res()}}const ot=new ui,hi="/benefits/app/assets/check-57fe1dcb.svg",fi=e=>t("div",{className:"h-96 grid",children:[t("div",{className:"grid place-self-center",children:[t("div",{className:"bg-[#EAF0FE] w-16 h-16 rounded-lg flex items-center justify-center mx-auto mb-10",children:t("img",{className:"w-10",src:hi})}),t("h1",{className:"text-3xl leading-9 font-bold text-gray-900 font-sans mb-3",children:"You’re all set!"}),t("p",{className:"px-8 text-base leading-6 font-normal text-gray-500",children:"Your benefits plan and exclusive offers are waiting for you."})]}),t(ce,{className:"md:w-full md:text-base py-3 place-self-end",onClick:e.onComplete,children:"Start exploring your benefits"})]}),pi="/benefits/app/assets/warning-a7f1af23.svg",gi=e=>t("div",{className:"h-96 grid",children:[t("div",{className:"grid place-self-center",children:[t("div",{className:"bg-[#FEE2E2] w-16 h-16 rounded-lg flex items-center justify-center mx-auto mb-10",children:t("img",{className:"w-10",src:pi})}),t("h1",{className:"text-3xl leading-9 font-bold text-gray-900 font-sans mb-3",children:"Something went wrong"}),t("p",{className:"px-8 text-base leading-6 font-normal text-gray-500",children:"We’re having some technical difficulties at the moment. Click the button below to proceed to your benefits."})]}),t(ce,{className:"md:w-full md:text-base py-3 place-self-end",onClick:e.onError,children:"Dismiss"})]}),bi="/benefits/app/assets/suitcase-6471ad05.svg",yi=La(({label:e,id:n,type:a,placeholder:s,setPlaceholderOnFocus:i,value:r,className:l,onChange:c,onBlur:d,error:o},p)=>{const g=k=>{k.target instanceof HTMLInputElement&&c(k.target.value.trim())},w=k=>{k.target instanceof HTMLInputElement&&d&&d(k.target.value.trim())},x=()=>{s&&i&&!(r!=null&&r.trim())&&c(s)};return t("div",{className:l,children:[t("label",{htmlFor:n,className:"block text-sm font-medium leading-5 text-gray-900 text-left",children:e}),t("div",{className:"mt-1",children:t("input",{className:"block min-h-[2.25rem] w-full rounded-md border-0 py-1.5 pr-20 text-gray-900 ring-1 ring-inset placeholder:text-gray-400 focus:ring-2 focus:ring-inset text-base sm:text-sm sm:leading-6 ring-gray-300 focus:ring-primary-600",type:a,value:r,name:n,id:n,placeholder:s,onChange:g,onBlur:w,onFocus:x,ref:p})}),o&&t("p",{className:"my-2 text-sm text-red-600 text-left",children:o})]})}),wi=e=>{const n=a=>{a.preventDefault(),e.onSubmit()};return t(y,{children:[t("div",{className:"bg-[#EAF0FE] w-16 h-16 rounded-lg flex items-center justify-center mx-auto mb-10",children:t("img",{className:"w-10",src:bi})}),t("h1",{className:"text-3xl leading-9 font-bold text-gray-900 font-sans mb-3",children:"Confirm your employment"}),t("p",{className:"text-base leading-6 font-normal text-gray-500 mb-6",children:"Your employer has partnered with Flare to provide you access to exclusive benefits. Add your personal mobile number to verify your identity."}),t("form",{onSubmit:n,children:[t(yi,{type:"text",value:e.mobileNumber,label:"Australian Mobile Number",id:"mobile",placeholder:"04",setPlaceholderOnFocus:!0,onChange:e.onChange,error:e.errorMessage}),t(ce,{className:"md:w-full md:text-base py-3 mt-10",type:"submit",disabled:!Bn(e.mobileNumber.replace(/\s/g,"")),children:"Continue"})]})]})},vi="/benefits/app/assets/padlock-8c081120.svg",ki=e=>{const[n,a]=f(e),s=R(),i=Y(()=>{s.current&&clearInterval(s.current)},[]);h(()=>i,[i]);const r=Y(()=>{let l=e;s.current&&clearInterval(s.current),s.current=setInterval(()=>{if(l<0){s.current&&clearInterval(s.current);return}a(l--)},1e3)},[e]);return{countdown:n,restart:r}},xi=({value:e="",numInputs:n=6,onChange:a})=>{const[s,i]=f(0),r=R([]),l=()=>e?e.toString().split(""):[];h(()=>{r.current=r.current.slice(0,n)},[n]),h(()=>{var m;(m=r.current[0])==null||m.focus()},[]);const c=m=>m===""||!isNaN(Number(m)),d=m=>{const u=m.join("");a(u)},o=m=>{const u=l();u[s]=m[0]||"",d(u)},p=m=>{var S,I;const u=Math.max(Math.min(n-1,m),0);r.current[u]&&((S=r.current[u])==null||S.focus(),(I=r.current[u])==null||I.select(),i(u))},g=m=>{const{value:u}=m.target;c(u)&&(o(u),p(s+1))},w=m=>{const{value:u}=m.target;c(u)||u.length===n&&(u.split("").some(I=>!c(I))||(d(u.split("")),p(n-1)))},x=m=>u=>{i(u),m.target.select()},k=()=>{i(s-1)},v=m=>{const u=l();[m.code,m.key].includes("Backspace")?(m.preventDefault(),o(""),p(s-1)):m.code==="Delete"?(m.preventDefault(),o("")):m.code==="ArrowLeft"?(m.preventDefault(),p(s-1)):m.code==="ArrowRight"||m.key===u[s]?(m.preventDefault(),p(s+1)):(m.code==="Spacebar"||m.code==="Space"||m.code==="ArrowUp"||m.code==="ArrowDown")&&m.preventDefault()},L=m=>{m.preventDefault();const u=l();let S=s;const I=m.clipboardData.getData("text/plain").slice(0,n-s).split("");if(!I.some(_=>isNaN(Number(_)))){for(let _=0;_<n;++_)_>=s&&I.length>0&&(u[_]=I.shift()??"",S++);p(S),d(u)}};return t("div",{className:"inline-flex gap-2",children:Array.from({length:n},(m,u)=>u).map(m=>t(y,{children:t("input",{className:"border-gray-300 caret-transparent selection:bg-transparent rounded-lg col-span-1 text-center w-10 h-12 text-xl leading-7 font-normal",value:l()[m]??"",ref:u=>r.current[m]=u,onChange:g,onFocus:u=>x(u)(m),onBlur:k,onKeyDown:v,onPaste:L,autoComplete:"off",type:"text",inputMode:"numeric",onInput:w,"aria-label":"One Time Password"})},m))})},Ni=e=>{const{countdown:n,restart:a}=ki(60);h(a,[a]);const s=l=>{l.preventDefault(),e.onSubmit()},i=()=>{a(),e.onResend()},r=On(e.mobileNumber);return t(y,{children:[t("div",{className:"bg-[#EAF0FE] w-16 h-16 rounded-lg flex items-center justify-center mx-auto mb-7",children:t("img",{className:"w-10",src:vi})}),t("h1",{className:"text-3xl leading-9 font-bold text-gray-900 font-sans mb-3",children:"Verify your mobile number"}),r&&t("p",{className:"px-14 text-base leading-6 font-normal text-gray-500 mb-6",children:["An SMS verification code has been sent to the number"," ",t("span",{className:"whitespace-nowrap",children:r})]}),t("form",{onSubmit:s,children:[t(xi,{value:e.otp,numInputs:6,onChange:e.onChange}),t("p",{className:"mt-2 text-center text-xs text-gray-600 disabled:opacity-75 ",children:["Didn't get the code?",t("button",{type:"button",disabled:n!==0,className:"underline mx-2 text-primary disabled:text-gray-600 disabled:hover:bg-transparent disabled:cursor-text disabled:px-0",onClick:i,children:"Resend SMS"}),n!==0&&t(y,{children:["in ",n," secs"]})]}),t("p",{className:"my-2 text-sm text-red-600 text-center",children:e.errorMessage||""}),t(ce,{className:"md:w-full md:text-base py-3 mt-7",type:"submit",disabled:!$n(e.otp),children:"Continue"}),t(ce,{className:"inline md:w-full md:text-base py-3 mt-4 bg-white !border-gray-300 !text-gray-600",onClick:e.onBack,children:[t(Ea,{className:"inline-flex h-4 w-4 mr-2"}),"Back"]})]})]})},Ai=e=>{const[n,a]=f("Loading"),[s,i]=f(),[r,l]=f(),[c,d]=f(),{service:o}=O();h(()=>{var v;if(!e.config){a("Error"),o.trackRegistrationErrorViewedAsync("InitialConfigError");return}(v=e.config)!=null&&v.isEstablished?a("Complete"):(a("Signup"),o.trackRegistrationStartedAsync())},[]);const p=async()=>{if(i(""),r&&Bn(r.replace(/\s/g,"")))try{a("Loading"),d(void 0),await ot.signUpAsync({mobileNumber:xr(r)}),a("Verify"),o.trackRegistrationSubmittedAsync()}catch{a("Error"),o.trackRegistrationErrorViewedAsync("SignupError")}},g=async()=>{if(i(""),c&&$n(c))try{a("Loading"),await ot.verifyAsync({otp:c}),a("Complete"),o.trackRegistrationVerifiedAsync()}catch(v){a("Verify"),v instanceof Error&&v.message&&v.message!==Un?(i(v.message),o.trackRegistrationFailedAsync(v.message)):(a("Error"),o.trackRegistrationFailedAsync("InternalError"),o.trackRegistrationErrorViewedAsync("VerificationError"))}},w=async()=>{i("");try{d(void 0),o.trackRegistrationResentAsync(),await ot.resendAsync()}catch{a("Error"),o.trackRegistrationErrorViewedAsync("ResendError")}},x=()=>{e.onComplete(),o.trackRegistrationCompletedAsync()},k=()=>{e.onError(),o.trackRegistrationErrorDismissedAsync()};return t("div",{className:"min-h-[25rem]",children:[n==="Loading"&&t("div",{className:"flex items-center justify-center h-96 text-primary",children:[t("span",{className:"sr-only",children:"Loading"}),t(Le,{size:10})]}),n==="Signup"&&t(wi,{onSubmit:p,onChange:v=>{l(v),i("")},mobileNumber:r||"",errorMessage:s}),n==="Verify"&&t(Ni,{onSubmit:g,onBack:()=>a("Signup"),onResend:w,onChange:v=>{(!v||Nr(v))&&d(v),i("")},mobileNumber:r,otp:c,errorMessage:s}),n==="Complete"&&t(fi,{onComplete:x}),n==="Error"&&t(gi,{onError:k})]})},Ci=e=>t("svg",{viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",class:e.size==="lg"?"h-10 w-10":"h-5 w-5",children:[t("path",{d:"M16 8C16 12.4183 12.4183 16 8 16C3.58172 16 0 12.4183 0 8C0 3.58172 3.58172 0 8 0C12.4183 0 16 3.58172 16 8ZM1.99743 8C1.99743 11.3151 4.68487 14.0026 8 14.0026C11.3151 14.0026 14.0026 11.3151 14.0026 8C14.0026 4.68487 11.3151 1.99743 8 1.99743C4.68487 1.99743 1.99743 4.68487 1.99743 8Z",class:e.theme==="light"?"fill-white":"fill-gray-200","fill-opacity":e.theme==="light"?"0.3":"1"}),t("path",{d:"M8 1C8 0.447715 8.44943 -0.00643769 8.99741 0.0624193C9.70527 0.151368 10.3996 0.334798 11.0615 0.608964C12.0321 1.011 12.914 1.60028 13.6569 2.34315C14.3997 3.08602 14.989 3.96793 15.391 4.93853C15.6652 5.60043 15.8486 6.29473 15.9376 7.0026C16.0064 7.55057 15.5523 8 15 8C14.4477 8 14.0085 7.54925 13.9169 7.00462C13.842 6.55939 13.7169 6.12298 13.5433 5.7039C13.2417 4.97595 12.7998 4.31451 12.2426 3.75736C11.6855 3.20021 11.0241 2.75825 10.2961 2.45672C9.87702 2.28313 9.44061 2.15804 8.99538 2.08314C8.45075 1.99152 8 1.55228 8 1Z",class:e.theme==="light"?"fill-white":"fill-primary-base"})]}),Vn=e=>{const[n,a]=f(!1);return t("button",{"data-testid":e.testId,type:"button",class:`${e.class} inline-flex items-center justify-center px-10 py-2 border border-transparent text-base font-medium rounded-md shadow-sm text-white disabled:text-gray-300 bg-primary hover:bg-primary-hover disabled:bg-gray-100 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary-focus w-full md:w-auto`,disabled:e.disabled,onClick:async()=>{if(e.onClickPromise&&!n){a(!0);try{await e.onClickPromise()}catch{}a(!1)}},children:[t("div",{class:`${n?"invisible":""}`,children:e.children}),n&&t("div",{class:"absolute animate-spin",children:t(Ci,{theme:"light"})})]})},Dn=({className:e,children:n})=>t("h1",{className:`text-2xl md:text-3xl font-bold ${e??""}`,children:n}),Fn=({className:e,children:n})=>t("h3",{class:`text-base md:text-lg text-gray-600 ${e??""}`,children:n}),le=({children:e})=>{const n=ye.Children.toArray(e),a=n.find(i=>i.type===jn),s=n.find(i=>i.type===Wn);return t(ue,{appear:!0,show:!0,enter:"transition duration-700 ease-out",enterFrom:"opacity-0",enterTo:"opacity-100",children:t("div",{class:"flex flex-col text-center items-center max-w-[40rem] mx-auto",children:[t(ue,{appear:!0,show:!0,enter:"transition duration-700 ease-out md:transition-none",enterFrom:"-translate-y-6",enterTo:"translate-y-0",children:a&&t("div",{class:"flex items-center h-full",children:a})}),t(ue,{appear:!0,show:!0,enter:"transition delay-300 duration-[600ms] ease-out",enterFrom:"opacity-0 -translate-y-6",enterTo:"opacity-100 translate-y-0",children:s&&t("div",{class:"flex items-center h-full",children:s})})]})})},jn=({children:e})=>t(y,{children:e}),Wn=({children:e})=>t(y,{children:e});le.Top=jn;le.Bottom=Wn;const Pi="allowance",Ii=({navigate:e,onComplete:n})=>{const[a,s]=f(void 0),[i,r]=f(0),[l,c]=f([]);h(()=>{(async()=>{await Be(5e3);const v=(await vn()).map(L=>({name:L.content.productName,url:L.content.iconUrl}));if(v.length===0){n();return}c(v),r(1);for(let L=0;L<v.length;L++)s(L),await Be(1e3);await Be(1e3),r(2),await Be(1e3),r(3)})()},[]);const d=H(()=>{switch(i){case 0:case 1:case 2:return"Personalising your benefits plan";case 3:return"Your Benefits Plan"}},[i]),o=H(()=>{switch(i){case 0:return"Finding benefits...";case 1:case 2:return a===0?"1 benefit found that matches your profile":`${a+1} benefits found that match your profile`;case 3:return"Based on your profile, your are eligible to enrol in these benefits"}},[i,a]),p=H(()=>i===0,[i]),g=H(()=>i!==2,[i]),w=H(()=>i===2||i===3,[i]),x=H(()=>i===3,[i]),k=H(()=>i===3,[i]);return t(le,{children:[t(le.Top,{children:t("div",{className:"flex flex-col gap-4",children:[t("div",{className:`flex justify-center text-primary transition-opacity duration-700 ease-in-out ${p?"opacity-100":"opacity-0"}`,children:t(Le,{size:10})}),t(Dn,{className:`transition-opacity duration-700 ease-in-out ${g?"opacity-100":"opacity-0"}`,children:d}),t(Fn,{className:`transition-opacity duration-700 ease-in-out ${g?"opacity-100":"opacity-0"}`,children:o})]})}),t(le.Bottom,{children:t("div",{class:"flex flex-col items-center gap-4",children:[t(Ti,{scaleUp:w,showName:x,icons:l}),t(Vn,{testId:"set_up_benefits_button_next_screen",class:`mt-4 w-full md:w-[240px] transition-opacity duration-700 ease-in-out ${k?"opacity-100":"hidden opacity-0"}`,onClickPromise:async()=>{await ie.commandAsync({eventType:"Started"},{treatment:Pi}),e("/allowance/offers")},children:"Set up your benefits"})]})})]})},Ti=({scaleUp:e,showName:n,icons:a})=>t("div",{children:[t("style",{children:`
|
|
8
|
+
.bg-lighter-than-text{
|
|
9
|
+
background-color: hsl(from currentColor h s l / 0.08);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.animate-slide-from-right {
|
|
13
|
+
opacity: 0;
|
|
14
|
+
transform: translateX(400px);
|
|
15
|
+
animation: slide-from-right 1s ease-out forwards;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
@keyframes slide-from-right {
|
|
19
|
+
from {
|
|
20
|
+
transform: translateX(400px);
|
|
21
|
+
opacity: 0;
|
|
22
|
+
}
|
|
23
|
+
to {
|
|
24
|
+
transform: translateX(0);
|
|
25
|
+
opacity: 1;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
`}),t("div",{className:`flex gap-4 transition-scale transition-margin duration-700 ease-in-out ${e?"scale-150 m-4":"scale-100"}`,children:a.map((s,i)=>t("div",{className:"mt-4 flex flex-col gap-1 items-center text-primary text-[0.5rem] w-12 max-w-12 min-w-12 animate-slide-from-right",style:{animationDelay:`${1e3*i}ms`},children:[t(rn,{src:s.url,wrapper:"svg",className:"w-10 h-10 max-h-10 max-w-10 min-h-10 min-w-10 p-2.5 rounded-lg bg-lighter-than-text",beforeInjection:r=>{var l;r.removeAttribute("width"),r.removeAttribute("height"),(l=r.querySelector("path"))==null||l.removeAttribute("fill"),r.setAttribute("fill","currentColor")}}),t("p",{className:`transition-opacity duration-700 ease-in-out ${n?"opacity-100":"opacity-0"}`,children:s.name})]},s.name))})]}),Si=({visible:e,children:n})=>{const a=R(e);return e&&!a.current&&(a.current=!0),a.current?t("div",{hidden:!e,children:n}):null},Li=({iconUrl:e})=>t(rn,{src:e,wrapper:"svg",className:"w-10 h-10 max-h-10 max-w-10 min-h-10 min-w-10 p-2.5 rounded-lg bg-lighter-than-text",beforeInjection:n=>{var a;n.removeAttribute("width"),n.removeAttribute("height"),(a=n.querySelector("path"))==null||a.removeAttribute("fill"),n.setAttribute("fill","currentColor")}}),Hn=({label:e,icon:n})=>t("div",{className:"flex flex-col gap-1 items-center w-12 max-w-12 min-w-12",children:[n,t("p",{className:"max-h-10 max-w-20 break-words text-ellipsis overflow-hidden line-clamp-2",children:e})]}),zn=({children:e})=>t(y,{children:e}),Ei=({selectedIndex:e,onChange:n,children:a})=>{const s=H(()=>Et.toArray(a).filter(r=>r.type===Hn),[a]),i=H(()=>Et.toArray(a).filter(r=>r.type===zn),[a]);return h(()=>{i.length>0&&(n==null||n(0))},[]),t("div",{children:[t("div",{className:"flex items-baseline gap-8 md:mb-4",children:[t("style",{children:`
|
|
29
|
+
.bg-lighter-than-text{
|
|
30
|
+
background-color: hsl(from currentColor h s l / 0.08);
|
|
31
|
+
}
|
|
32
|
+
`}),s.map((r,l)=>t("div",{onClick:()=>n==null?void 0:n(l),className:Oa("text-sm font-medium cursor-auto h-full relative","flex items-center justify-center",l===e?"text-primary":"text-gray-400",i.length>0?"hover:before:cursor-pointer":"hover:before:cursor-default","hover:before:w-16 hover:before:h-16 hover:before:absolute"),children:r},r.key))]}),i.map((r,l)=>t(Si,{visible:l===e,children:r},r.key))]})},Oi=e=>{var i,r,l,c,d;const n=ee(z),a=T(n,void 0),s=R(null);return h(()=>{ie.commandAsync({eventType:"OfferViewed",offerName:e.marketPlaceOffer.name,data:e.marketPlaceOffer.metadata},{experiment:e.marketPlaceOffer.metadata.featureName,treatment:e.marketPlaceOffer.metadata.treatmentName}),s.current&&(s.current.terms=e.marketPlaceOffer.content.terms,s.current.details=e.marketPlaceOffer.content.details,s.current["on-accept"]=()=>{ie.commandAsync({eventType:"OfferProgressed",offerName:e.marketPlaceOffer.name,data:{...e.marketPlaceOffer.metadata,template:e.marketPlaceOffer.content.template,assessmentId:e.marketPlaceOffer.content.assessmentId,accepted:!0}},{experiment:e.marketPlaceOffer.metadata.featureName,treatment:e.marketPlaceOffer.metadata.treatmentName})},s.current["on-decline"]=()=>{ie.commandAsync({eventType:"OfferProgressed",offerName:e.marketPlaceOffer.name,data:{...e.marketPlaceOffer.metadata,template:e.marketPlaceOffer.content.template,assessmentId:e.marketPlaceOffer.content.assessmentId,accepted:!1}},{experiment:e.marketPlaceOffer.metadata.featureName,treatment:e.marketPlaceOffer.metadata.treatmentName}),e.onStepComplete(!1)},s.current["on-complete"]=()=>e.onStepComplete(!0),s.current["on-skip"]=e.marketPlaceOffer.content.skipButtonHidden?void 0:()=>e.onStepComplete(!1))},[]),(i=a==null?void 0:a.workplaceLinkConfig)!=null&&i.workplaceBackendToken?t("benefits-plan-assessment",{"base-url":D.getConfig().apolloBaseUrl,"profile-id":a==null?void 0:a.basicProfile.profileId,"skip-more-details":!0,"access-token":(r=a==null?void 0:a.workplaceLinkConfig)==null?void 0:r.workplaceBackendToken,"image-url":e.marketPlaceOffer.content.imageUrl,"assessment-id":e.marketPlaceOffer.content.assessmentId,"assessment-instructions":e.marketPlaceOffer.content.assessmentInstructions,"track-experiment":e.marketPlaceOffer.metadata.featureName,"track-treatment":e.marketPlaceOffer.metadata.treatmentName,"track-client":"webBenefits","track-source":"WebBenefits","track-channel":"web","marketplace-offer-name":e.marketPlaceOffer.name,"assessment-title":e.marketPlaceOffer.content.title,description:e.marketPlaceOffer.content.description,"accept-button":e.marketPlaceOffer.content.acceptButton,"decline-button":e.marketPlaceOffer.content.declineButton,"special-banner-title":(l=e.marketPlaceOffer.content.specialBanner)==null?void 0:l.title,"special-banner-subtitle":(c=e.marketPlaceOffer.content.specialBanner)==null?void 0:c.subtitle,"special-banner-type":(d=e.marketPlaceOffer.content.specialBanner)==null?void 0:d.type,"vertical-alignment":"items-center",ref:s}):null},Bi=({navigate:e})=>{const[n,a]=f(0),[s,i]=f(!1),[r,l]=f([]);h(()=>{vn().then(l)},[]);const c=Y(o=>{if(o&&i(!0),n===r.length-1){const g=r.some(w=>w.name==="Perks");e(`/allowance/summary/${s||o?"true":"false"}/${g?"true":"false"}`)}else a(n+1)},[n,s]),d=Y(o=>{a(o);const p=r[o];p&&ie.commandAsync({eventType:"OfferSelected",offerName:p.name,data:p.metadata},{experiment:p.metadata.featureName,treatment:p.metadata.treatmentName})},[]);return t("div",{className:"max-w-[59.5rem] mx-auto",children:t(Ei,{selectedIndex:n,onChange:d,children:[r.map(o=>t(Hn,{label:o.content.productName,icon:t(Li,{iconUrl:o.content.iconUrl})},o.name)),r.map(o=>t(zn,{children:o.content.template==="Assessment"&&t(Oi,{onStepComplete:c,marketPlaceOffer:o},o.name)},o.name))]})})},$i=e=>{var i;const n=ee(z),a=R(null),s=T(n,void 0);return h(()=>{a.current&&(a.current["on-complete"]=()=>e.navigate("/allowance/intro"))},[]),t("div",{className:"flex justify-center",children:t("benefits-plan-assessment",{"base-url":D.getConfig().apolloBaseUrl,"profile-id":s==null?void 0:s.basicProfile.profileId,"skip-intro":!0,"skip-more-details":!0,"skip-summary":!0,"access-token":(i=s==null?void 0:s.workplaceLinkConfig)==null?void 0:i.workplaceBackendToken,"assessment-id":"benefits-personalisation-assessment","track-client":"webBenefits","track-source":"WebBenefits","track-channel":"web","assessment-title":"Tell us a bit about yourself",description:"Answer a few questions to help us set up a personalised benefits plan for you:","vertical-alignment":"items-center",ref:a})})},Ri=({title:e,className:n,children:a,...s})=>{var d;const[i,r]=f(!1),l=R(null),c=Y(()=>{r(!i)},[i]);return t("div",{className:`border border-2 border-gray-300 p-2 rounded-md overflow-hidden w-full ${n??""}`,...s,children:[t("div",{className:"mx-2 flex justify-between cursor-pointer",onClick:c,children:[t("span",{className:"text-base text-left font-semibold text-primary",children:e}),t("span",{className:"text-base text-left font-semibold text-gray-500",children:i?"-":"+"})]}),t("div",{ref:l,className:"flex justify-center transition-all ease-in-out duration-1000",style:{height:i?`${((d=l==null?void 0:l.current)==null?void 0:d.scrollHeight)??0}px`:"0px",opacity:i?1:0},children:a})]})},_i="/benefits/app/assets/check-c15931a5.svg",Mi=({title:e,steps:n,...a})=>{const s=n.length,i=n.filter(r=>r.completed).length;return t("div",{...a,children:[e&&t("h1",{className:"text-lg font-semibold mb-4",children:e}),t("ol",{children:n.map((r,l)=>{const c=i===l;return t("li",{className:`relative flex-1 pb-6 ${l!==s-1?`after:content-[''] after:w-0.5 after:h-[calc(100%-theme(height.8))] ${r.completed?"after:bg-primary":"after:bg-gray-300"} after:inline-block after:absolute after:top-8 after:left-4`:""}`,children:t("div",{className:"flex font-medium w-full",children:[t("span",{className:`w-8 h-8 flex-shrink-0 ${r.completed?"bg-primary":"bg-white"} border-2 ${r.completed||c?"border-primary":"border-gray-300"} rounded-full flex justify-center items-center mr-3 text-sm ${c?"text-primary":"text-gray-500"}`,children:r.completed?t("img",{className:"w-4 h-4",src:_i}):l+1}),t("div",{children:[t("h4",{className:`text-sm text-left font-semibold ${r.completed||c?"text-primary":"text-gray-600"}`,children:r.title}),t("p",{className:"text-sm text-left font-normal",children:r.description})]})]})},l)})})]})},Jt="allowance",Ui=({hasCompletedAnyOffers:e,isAppEnabled:n,onComplete:a})=>{h(()=>{const c=Vi({isAppEnabled:n,hasCompletedAnyOffers:e});ie.commandAsync({eventType:"SummaryViewed",summaryVariant:c},{treatment:Jt})},[n,e]);const[s,i]=f();h(()=>{(async()=>{const c=await te.loadAllowanceContentAsync(e?"benefits-setup-summary-allowance":"benefits-setup-summary-allowance-no-selection");i(c.items[0].fields)})()},[]);const r=ee(z),l=T(r,void 0);return s?t(le,{children:[t(le.Top,{children:t("div",{className:"flex flex-col gap-4",children:[t(Dn,{children:s.title}),t(Fn,{children:s.description})]})}),t(le.Bottom,{children:t("div",{className:"mt-5 flex flex-col items-center gap-5 text-center",children:[s.specialContent?t(Ri,{className:"lg:w-3/4",title:s.specialContent.title,children:t(Mi,{steps:Is(s.specialContent.content,1),className:"mt-2 rounded-md px-6 py-4"})}):null,t(Vn,{testId:"allowance_set_up_benefits_button_next_screen",class:"mt-5 w-full md:w-[240px]",onClickPromise:async()=>{var o;const c=(o=l==null?void 0:l.workplaceLinkConfig)==null?void 0:o.workplaceBackendToken,d=l==null?void 0:l.basicProfile.profileId;await Promise.all([ie.commandAsync({eventType:"Completed"},{treatment:Jt}),c&&d?gn(c,d).url("/benefits-plan/workplace-backend/v1.0/allowance/complete").post():void 0]),a()},children:s.primaryAction})]})})]}):t("div",{className:"text-primary",children:t(Le,{size:6})})},Vi=({isAppEnabled:e,hasCompletedAnyOffers:n})=>{switch(!0){case(e&&n):return"allowance-accepted-app";case(e&&!n):return"allowance-declined-app";case(!e&&n):return"allowance-accepted-noapp";default:return"allowance-declined-noapp"}},Di=({onComplete:e})=>{const n=ee(z),a=T(n,void 0),[s,i]=f("/allowance"),r=l=>i(l);return t("div",{className:"flex items-center",children:(()=>{var l;if(!((l=a==null?void 0:a.workplaceLinkConfig)!=null&&l.workplaceBackendToken))return t("div",{className:"text-primary",children:t(Le,{size:10})});if(s==="/allowance/intro")return t(Ii,{navigate:r,onComplete:e});if(s==="/allowance/offers")return t(Bi,{navigate:r});if(s.startsWith("/allowance/summary/")){const c=s.replace("/allowance/summary/","").split("/");return t(Ui,{isAppEnabled:c[1]==="true",hasCompletedAnyOffers:c[0]==="true",onComplete:e})}return t($i,{navigate:r})})()})},Fi="/benefits/app/assets/welcome_image_mobile-dbde6c80.png",ji="/benefits/app/assets/welcome_image_v2-869c59e4.png",Wi=({hasNextStep:e,onClick:n})=>{const{service:a}=O();h(()=>{a.trackConsentStartedAsync()},[]);const s=()=>{a.trackConsentCompletedAsync(),n()},i=e?"Get started":"Start exploring your benefits";return t("div",{children:[t("div",{className:"min-h-[12rem] items-center hidden md:flex",children:t("img",{className:"mx-auto align-middle w-[30rem]",src:ji})}),t("div",{className:"min-h-[8rem] flex items-center md:hidden",children:t("img",{className:"mx-auto align-middle w-[30rem]",src:Fi})}),t("h1",{className:"text-3xl leading-9 font-bold text-gray-900 font-sans mb-3 mt-4",children:[t("span",{className:"w-full block",children:"Welcome to your"}),t("span",{className:"w-full block",children:"workplace benefits"})]}),t("p",{className:"text-base leading-6 font-normal text-gray-500 mb-6",children:"Get access to savings and perks from Australia’s most-loved brands, plus special offers to help you save on bigger expenses like household utilities, health insurance and more."}),t(ce,{className:"md:w-full md:text-base py-3 mb-6 focus:outline-none",onClick:s,children:i}),t("p",{className:"text-xs leading-4 font-normal text-gray-500 mb-0",children:["By clicking “",i,"” you accept the"," ",t(be,{className:"text-primary underline",href:"https://www.flarehr.com/flare-app-terms-and-conditions",children:"Terms & Conditions"})," ","and acknowledge and consent to your data being processed in accordance with Flare's"," ",t(be,{className:"text-primary underline",href:"https://www.flarehr.com/privacy-policy",children:"Privacy Policy"}),"."]})]})},Hi=({userProfile:e,isCategoryOpen:n})=>{const{getTreatment:a}=mn();h(()=>{(async()=>await ne.setWorkplaceLinkConfig())()},[]);const s=H(()=>[{stepType:"Consent",isRequired:()=>a(He.ApolloBenefitsConsent)==="on"&&(e==null?void 0:e.benefitsProfile.hasConsent)===!1},{stepType:"WorkplaceLink",isRequired:()=>{var x;return a(He.ApolloBenefitsCustomerRegistration)==="on"&&((x=e==null?void 0:e.workplaceLinkConfig)==null?void 0:x.isEstablished)===!1}},{stepType:"Allowance",isRequired:()=>{var w,x;return((w=e==null?void 0:e.workplaceLinkConfig)==null?void 0:w.isEstablished)===!0&&((x=e==null?void 0:e.featureFlags)==null?void 0:x.allowance)===!0}}].filter(w=>w.isRequired()),[e]),i=R();h(()=>{s.length>0&&(i.current=s[0])},[s]);const[r,l]=f(!1);h(()=>{l(s.length>0&&!n)},[s.length,n]),h(()=>{ge.updateIsWelcomeModalOpen(r)},[r]);const c=()=>{var w;(w=e==null?void 0:e.benefitsProfile)!=null&&w.hasConsent||ne.saveUserConsent()},d=()=>{ze.lock(5e3),ne.updateCustomerIdAsync(ze.unlockAndFlushQueue),ne.setIsEstablished()},o=()=>{ne.setIsEstablished()},p=()=>{ne.setAllowanceCompleted()},g=s[0]||i.current;return t(Ze,{isOpen:r,fullWidthMobile:!0,onClose:()=>{},children:t("div",{className:`${(g==null?void 0:g.stepType)==="Allowance"?"md:max-w-[68rem] md:min-h-[30rem] flex justify-center overflow-y-auto":"text-center md:w-[35rem]"} p-8 md:p-16 w-screen`,children:[(g==null?void 0:g.stepType)==="Consent"&&t(Wi,{onClick:c,hasNextStep:s.length>1}),(g==null?void 0:g.stepType)==="WorkplaceLink"&&t(Ai,{onComplete:d,onError:o,config:e==null?void 0:e.workplaceLinkConfig}),(g==null?void 0:g.stepType)==="Allowance"&&t(Di,{onComplete:p})]})})},Re=({category:e})=>{const[n,a]=f();return h(()=>{const s=[K.signedInUser$.subscribe(i=>{U(i)?a(i.value):a(void 0)})];return()=>{s.map(i=>i.unsubscribe())}},[]),t(y,{children:[t(pt,{history:wt(gt()),children:[t(F,{path:"/",component:$e}),t(F,{path:"/categories/:category",component:$e}),t(F,{path:"/landing/:slug",component:$e}),t(F,{path:"/wellbeing-hub/:subroute*",component:li}),t(F,{default:!0,component:$e})]}),t(Hi,{userProfile:n,isCategoryOpen:!!e})]})},qn=e=>{analytics.identify(e.basicProfile.profileId,{profile:e.basicProfile.profileId,account:e.basicProfile.accountId,partner:e.basicProfile.partnerId,benefitsRole:e.benefitsProfile.role})},zi=e=>{const n=`${e.eventName} ${e.eventAction}`,a={...e};delete a.eventName,delete a.eventAction,analytics.track(n,a)},qi=e=>()=>{},pl={identifyUser:qn,trackEvent:zi,handleTrackingOnClick:qi},Gi=Ba(()=>$a(()=>import("./index-a816590e.js"),["assets/index-a816590e.js","assets/vendor-a6810c59.js","assets/lodash-5d893f8c.js","assets/framer-motion-44d211db.js","assets/date-fns-74ba04b6.js","assets/oidc-client-3a9688bc.js","assets/datadog-261280ed.js"])),Qi=()=>{const[e,n]=f({user:C}),[a,s]=f(!1),[i,r]=f(!1),{service:l}=O();if(typeof window<"u"&&window.location.pathname.replace("/benefits/app","")!=="/")return window.location.pathname="/benefits/app/",null;h(()=>{(async()=>{if(await D.fetchConfigAsync(),Ue.extractRedirectPath(),Ue.extractMode(),Ue.extractTrackingParameters(),G.tokenExists(window.location.search)){await G.signOut(),await G.initFromToken(window.location.pathname,window.location.search);return}r(!0)})();const d=[K.signedInUser$.subscribe(o=>{n({user:o}),U(o)&&qn(o.value)}),on.authState$.subscribe(async({authStatus:o,jwt:p})=>{U(p)&&o===q.Authenticated?(await G.refreshIfExpired(),V.setParameters(D.getConfig().apiBaseUrl,p.value),re.setParameters(D.getConfig().apolloBaseUrl,p.value),Ha.setParameters(D.getConfig().apiV2BaseUrl,p.value),ne.extractProfileId(p.value),await ne.loadSignedInUserProfileAsync(),s(o===q.Authenticated)):s(!1)})];return()=>{d.map(o=>o.unsubscribe())}},[]);const c=d=>{switch(d.url.replace(/^\/+/,"").split("/")[0]){case"":P.update({appView:"employee",navTab:"benefits"});break;case"admin":P.update({appView:"admin",navTab:"benefits"});break;case"wellbeing-hub":P.update({appView:"employee",navTab:"wellbeing"});break}};return h(()=>{if(i&&a){l.trackAppLoadedAsync();const d=K.getValue().deepLink;U(d)&&(l.trackDeepLinkOpenedAsync(d.value),P.update({deepLink:C}))}},[i,a]),i?t("div",{id:"preact_root",className:"min-h-screen",children:t(dn.Provider,{value:a,children:t(z.Provider,{value:e.user,children:t(pt,{history:wt(gt()),onChange:c,children:[t(ke,{path:"/",component:Re}),t(ke,{path:"/categories/:category",component:Re}),t(ke,{path:"/landing/:slug",component:Re}),t(ke,{path:"/wellbeing-hub/:subroute*",component:Re}),t(ke,{path:"/admin/:subroute*",component:Gi}),t(F,{path:"/oidc/:mode*",component:ss}),t(F,{path:"/b2c/:fragment",component:rs}),t(F,{path:"/workplace-link",component:De}),t(F,{path:"state=:fragment*",component:De}),t(F,{path:"/code*",component:De}),t(pn,{default:!0})]})})})}):t(Je,{})};typeof window<"u"&&(Ra({storage:window.sessionStorage,key:"benefits-client-v2"}),_a(),Ma.polyfill(),Wa());Ua(t(Da,{children:t(Va,{fallback:pn,children:t(Qi,{})})}),document.body);export{wt as A,V as B,Tn as D,yt as H,Vr as I,Le as L,Ze as M,Nt as P,Vt as U,O as a,Ce as b,X as c,z as d,Ha as e,te as f,bt as g,ys as h,We as i,Q as j,Ur as k,hl as l,pl as m,ul as n,ml as o,cl as p,Mr as q,dl as r,ol as s,ll as t,rt as u,B as v,kt as w,ie as x,mn as y,ln as z};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var es=Object.defineProperty;var ts=(t,e,r)=>e in t?es(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var O=(t,e,r)=>(ts(t,typeof e!="symbol"?e+"":e,r),r);import{u as s,aL as rs,aM as ns,j as se,aB as zr,p as M,k as is,G as as,q as _i,h as X,l as A,T as R,F as Tt,y as ss,aN as Pi,S as ls,x as Wr,z as Yr,C as os,at as cs,K as xe,Q as ds,aO as Ii,an as Mt,v as j,I as ke,D as Hr,P as B,w as Kr,aP as On,aQ as us,aR as fs,ag as hs,aS as $i,aT as nt,aU as Li,ah as Vi,A as Ri,J as Te,aV as ms,B as gs,aW as _n,am as ue,aX as ps,aY as ae,aZ as Fr,a_ as ys,a$ as vs,H as ji,b0 as bs,aj as Bi,ak as it,al as Ae,s as Ui,b1 as zi,b2 as Wi,Y as wt,X as ws,U as xs,b3 as ks,b4 as Es,b5 as Ds,aw as Fs,ax as Ns,ay as xt}from"./vendor-a6810c59.js";import{B as at,u as Ss,U as Cs,M as qr,L as pt,a as Gr,g as Yi,b as yt,w as Ee,c as $,d as Hi,e as st,f as As,P as zt,h as Ki,i as qi,j as Pn,s as In,p as $n,D as Ts,k as Gi,l as Ln,m as T,n as Ms,o as Os,I as dr,q as ur,r as Vn,t as _s,v as lt,x as Ot,y as Ps,H as Is,z as $s,A as Ls}from"./index-
|
|
1
|
+
var es=Object.defineProperty;var ts=(t,e,r)=>e in t?es(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var O=(t,e,r)=>(ts(t,typeof e!="symbol"?e+"":e,r),r);import{u as s,aL as rs,aM as ns,j as se,aB as zr,p as M,k as is,G as as,q as _i,h as X,l as A,T as R,F as Tt,y as ss,aN as Pi,S as ls,x as Wr,z as Yr,C as os,at as cs,K as xe,Q as ds,aO as Ii,an as Mt,v as j,I as ke,D as Hr,P as B,w as Kr,aP as On,aQ as us,aR as fs,ag as hs,aS as $i,aT as nt,aU as Li,ah as Vi,A as Ri,J as Te,aV as ms,B as gs,aW as _n,am as ue,aX as ps,aY as ae,aZ as Fr,a_ as ys,a$ as vs,H as ji,b0 as bs,aj as Bi,ak as it,al as Ae,s as Ui,b1 as zi,b2 as Wi,Y as wt,X as ws,U as xs,b3 as ks,b4 as Es,b5 as Ds,aw as Fs,ax as Ns,ay as xt}from"./vendor-a6810c59.js";import{B as at,u as Ss,U as Cs,M as qr,L as pt,a as Gr,g as Yi,b as yt,w as Ee,c as $,d as Hi,e as st,f as As,P as zt,h as Ki,i as qi,j as Pn,s as In,p as $n,D as Ts,k as Gi,l as Ln,m as T,n as Ms,o as Os,I as dr,q as ur,r as Vn,t as _s,v as lt,x as Ot,y as Ps,H as Is,z as $s,A as Ls}from"./index-41898db5.js";import{g as Xr,d as Rn,t as Xi,e as jn,f as Vs,h as _t,m as Ji,j as Rs,k as js,s as Bn}from"./lodash-5d893f8c.js";import{m as Ve,L as Jr}from"./framer-motion-44d211db.js";import{p as kt,i as fr,b as Un}from"./date-fns-74ba04b6.js";import"./oidc-client-3a9688bc.js";import"./datadog-261280ed.js";const Wt=t=>s("div",{className:"lg:flex lg:items-center lg:justify-between",children:[s("div",{className:"flex-1 min-w-0",children:s("div",{className:"relative",children:[s("h3",{className:"text-2xl font-extrabold text-gray-900 tracking-tight sm:text-3xl",children:t.title}),s("p",{className:"mt-3 text-lg text-gray-500",children:t.subTitle})]})}),t.buttonTitle&&s("div",{className:"mt-5 flex lg:mt-0 lg:ml-4 self-end",children:s("span",{children:s("button",{type:"button",disabled:t.isLoading,className:"inline-flex items-center px-4 py-2 border border-transparent disabled:opacity-50 rounded-md shadow-sm text-sm font-medium text-white bg-gray-600 hover:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-500",onClick:t.handleButtonClick,children:[s(rs,{className:"-ml-1 mr-2 h-5 w-5","aria-hidden":"true"}),t.buttonTitle]})})})]});var Bs=function(e){return Us(e)&&!zs(e)};function Us(t){return!!t&&typeof t=="object"}function zs(t){var e=Object.prototype.toString.call(t);return e==="[object RegExp]"||e==="[object Date]"||Hs(t)}var Ws=typeof Symbol=="function"&&Symbol.for,Ys=Ws?Symbol.for("react.element"):60103;function Hs(t){return t.$$typeof===Ys}function Ks(t){return Array.isArray(t)?[]:{}}function Pt(t,e){return e.clone!==!1&&e.isMergeableObject(t)?ut(Ks(t),t,e):t}function qs(t,e,r){return t.concat(e).map(function(n){return Pt(n,r)})}function Gs(t,e,r){var n={};return r.isMergeableObject(t)&&Object.keys(t).forEach(function(i){n[i]=Pt(t[i],r)}),Object.keys(e).forEach(function(i){!r.isMergeableObject(e[i])||!t[i]?n[i]=Pt(e[i],r):n[i]=ut(t[i],e[i],r)}),n}function ut(t,e,r){r=r||{},r.arrayMerge=r.arrayMerge||qs,r.isMergeableObject=r.isMergeableObject||Bs;var n=Array.isArray(e),i=Array.isArray(t),a=n===i;return a?n?r.arrayMerge(t,e,r):Gs(t,e,r):Pt(e,r)}ut.all=function(e,r){if(!Array.isArray(e))throw new Error("first argument should be an array");return e.reduce(function(n,i){return ut(n,i,r)},{})};var Nr=ut,zn=Array.isArray,Wn=Object.keys,Xs=Object.prototype.hasOwnProperty,Js=typeof Element<"u";function Sr(t,e){if(t===e)return!0;if(t&&e&&typeof t=="object"&&typeof e=="object"){var r=zn(t),n=zn(e),i,a,l;if(r&&n){if(a=t.length,a!=e.length)return!1;for(i=a;i--!==0;)if(!Sr(t[i],e[i]))return!1;return!0}if(r!=n)return!1;var o=t instanceof Date,c=e instanceof Date;if(o!=c)return!1;if(o&&c)return t.getTime()==e.getTime();var d=t instanceof RegExp,f=e instanceof RegExp;if(d!=f)return!1;if(d&&f)return t.toString()==e.toString();var h=Wn(t);if(a=h.length,a!==Wn(e).length)return!1;for(i=a;i--!==0;)if(!Xs.call(e,h[i]))return!1;if(Js&&t instanceof Element&&e instanceof Element)return t===e;for(i=a;i--!==0;)if(l=h[i],!(l==="_owner"&&t.$$typeof)&&!Sr(t[l],e[l]))return!1;return!0}return t!==t&&e!==e}var Qs=function(e,r){try{return Sr(e,r)}catch(n){if(n.message&&n.message.match(/stack|recursion/i)||n.number===-2146828260)return console.warn("Warning: react-fast-compare does not handle circular references.",n.name,n.message),!1;throw n}};const ge=Xr(Qs);var Zs=!0;function Qr(t,e){if(!Zs){if(t)return;var r="Warning: "+e;typeof console<"u"&&console.warn(r);try{throw Error(r)}catch{}}}var Qi={exports:{}},I={};/** @license React v16.13.1
|
|
2
2
|
* react-is.production.min.js
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
class H extends Error{}H.prototype.name="InvalidTokenError";function Re(e){return decodeURIComponent(atob(e).replace(/(.)/g,(t,s)=>{let i=s.charCodeAt(0).toString(16).toUpperCase();return i.length<2&&(i="0"+i),"%"+i}))}function Ie(e){let t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw new Error("base64 string is not of the correct length")}try{return Re(t)}catch{return atob(t)}}function Pe(e,t){if(typeof e!="string")throw new H("Invalid token specified: must be a string");t||(t={});const s=t.header===!0?0:1,i=e.split(".")[s];if(typeof i!="string")throw new H(`Invalid token specified: missing part #${s+1}`);let r;try{r=Ie(i)}catch(o){throw new H(`Invalid token specified: invalid base64 for part #${s+1} (${o.message})`)}try{return JSON.parse(r)}catch(o){throw new H(`Invalid token specified: invalid json for part #${s+1} (${o.message})`)}}var Ce={debug:()=>{},info:()=>{},warn:()=>{},error:()=>{}},y,b,D=(e=>(e[e.NONE=0]="NONE",e[e.ERROR=1]="ERROR",e[e.WARN=2]="WARN",e[e.INFO=3]="INFO",e[e.DEBUG=4]="DEBUG",e))(D||{});(e=>{function t(){y=3,b=Ce}e.reset=t;function s(r){if(!(0<=r&&r<=4))throw new Error("Invalid log level");y=r}e.setLevel=s;function i(r){b=r}e.setLogger=i})(D||(D={}));var g=class v{constructor(t){this._name=t}debug(...t){y>=4&&b.debug(v._format(this._name,this._method),...t)}info(...t){y>=3&&b.info(v._format(this._name,this._method),...t)}warn(...t){y>=2&&b.warn(v._format(this._name,this._method),...t)}error(...t){y>=1&&b.error(v._format(this._name,this._method),...t)}throw(t){throw this.error(t),t}create(t){const s=Object.create(this);return s._method=t,s.debug("begin"),s}static createStatic(t,s){const i=new v(`${t}.${s}`);return i.debug("begin"),i}static _format(t,s){const i=`[${t}]`;return s?`${i} ${s}:`:i}static debug(t,...s){y>=4&&b.debug(v._format(t),...s)}static info(t,...s){y>=3&&b.info(v._format(t),...s)}static warn(t,...s){y>=2&&b.warn(v._format(t),...s)}static error(t,...s){y>=1&&b.error(v._format(t),...s)}};D.reset();var j=class{static decode(e){try{return Pe(e)}catch(t){throw g.error("JwtUtils.decode",t),t}}static async generateSignedJwt(e,t,s){const i=_.encodeBase64Url(new TextEncoder().encode(JSON.stringify(e))),r=_.encodeBase64Url(new TextEncoder().encode(JSON.stringify(t))),o=`${i}.${r}`,n=await window.crypto.subtle.sign({name:"ECDSA",hash:{name:"SHA-256"}},s,new TextEncoder().encode(o)),a=_.encodeBase64Url(new Uint8Array(n));return`${o}.${a}`}static async generateSignedJwtWithHmac(e,t,s){const i=_.encodeBase64Url(new TextEncoder().encode(JSON.stringify(e))),r=_.encodeBase64Url(new TextEncoder().encode(JSON.stringify(t))),o=`${i}.${r}`,n=await window.crypto.subtle.sign("HMAC",s,new TextEncoder().encode(o)),a=_.encodeBase64Url(new Uint8Array(n));return`${o}.${a}`}},xe="10000000-1000-4000-8000-100000000000",L=e=>btoa([...new Uint8Array(e)].map(t=>String.fromCharCode(t)).join("")),re=class m{static _randomWord(){const t=new Uint32Array(1);return crypto.getRandomValues(t),t[0]}static generateUUIDv4(){return xe.replace(/[018]/g,s=>(+s^m._randomWord()&15>>+s/4).toString(16)).replace(/-/g,"")}static generateCodeVerifier(){return m.generateUUIDv4()+m.generateUUIDv4()+m.generateUUIDv4()}static async generateCodeChallenge(t){if(!crypto.subtle)throw new Error("Crypto.subtle is available only in secure contexts (HTTPS).");try{const i=new TextEncoder().encode(t),r=await crypto.subtle.digest("SHA-256",i);return L(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}catch(s){throw g.error("CryptoUtils.generateCodeChallenge",s),s}}static generateBasicAuth(t,s){const r=new TextEncoder().encode([t,s].join(":"));return L(r)}static async hash(t,s){const i=new TextEncoder().encode(s),r=await crypto.subtle.digest(t,i);return new Uint8Array(r)}static async customCalculateJwkThumbprint(t){let s;switch(t.kty){case"RSA":s={e:t.e,kty:t.kty,n:t.n};break;case"EC":s={crv:t.crv,kty:t.kty,x:t.x,y:t.y};break;case"OKP":s={crv:t.crv,kty:t.kty,x:t.x};break;case"oct":s={crv:t.k,kty:t.kty};break;default:throw new Error("Unknown jwk type")}const i=await m.hash("SHA-256",JSON.stringify(s));return m.encodeBase64Url(i)}static async generateDPoPProof({url:t,accessToken:s,httpMethod:i,keyPair:r,nonce:o}){let n,a;const c={jti:window.crypto.randomUUID(),htm:i??"GET",htu:t,iat:Math.floor(Date.now()/1e3)};s&&(n=await m.hash("SHA-256",s),a=m.encodeBase64Url(n),c.ath=a),o&&(c.nonce=o);try{const l=await crypto.subtle.exportKey("jwk",r.publicKey),h={alg:"ES256",typ:"dpop+jwt",jwk:{crv:l.crv,kty:l.kty,x:l.x,y:l.y}};return await j.generateSignedJwt(h,c,r.privateKey)}catch(l){throw l instanceof TypeError?new Error(`Error exporting dpop public key: ${l.message}`):l}}static async generateDPoPJkt(t){try{const s=await crypto.subtle.exportKey("jwk",t.publicKey);return await m.customCalculateJwkThumbprint(s)}catch(s){throw s instanceof TypeError?new Error(`Could not retrieve dpop keys from storage: ${s.message}`):s}}static async generateDPoPKeys(){return await window.crypto.subtle.generateKey({name:"ECDSA",namedCurve:"P-256"},!1,["sign","verify"])}static async generateClientAssertionJwt(t,s,i,r="HS256"){const o=Math.floor(Date.now()/1e3),n={alg:r,typ:"JWT"},a={iss:t,sub:t,aud:i,jti:m.generateUUIDv4(),exp:o+300,iat:o},l={HS256:"SHA-256",HS384:"SHA-384",HS512:"SHA-512"}[r];if(!l)throw new Error(`Unsupported algorithm: ${r}. Supported algorithms are: HS256, HS384, HS512`);const h=new TextEncoder,d=await crypto.subtle.importKey("raw",h.encode(s),{name:"HMAC",hash:l},!1,["sign"]);return await j.generateSignedJwtWithHmac(n,a,d)}};re.encodeBase64Url=e=>L(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_");var _=re,P=class{constructor(e){this._name=e,this._callbacks=[],this._logger=new g(`Event('${this._name}')`)}addHandler(e){return this._callbacks.push(e),()=>this.removeHandler(e)}removeHandler(e){const t=this._callbacks.lastIndexOf(e);t>=0&&this._callbacks.splice(t,1)}async raise(...e){this._logger.debug("raise:",...e);for(const t of this._callbacks)await t(...e)}},ee=class{static center({...e}){var t,s,i;return e.width==null&&(e.width=(t=[800,720,600,480].find(r=>r<=window.outerWidth/1.618))!=null?t:360),(s=e.left)!=null||(e.left=Math.max(0,Math.round(window.screenX+(window.outerWidth-e.width)/2))),e.height!=null&&((i=e.top)!=null||(e.top=Math.max(0,Math.round(window.screenY+(window.outerHeight-e.height)/2)))),e}static serialize(e){return Object.entries(e).filter(([,t])=>t!=null).map(([t,s])=>`${t}=${typeof s!="boolean"?s:s?"yes":"no"}`).join(",")}},T=class $ extends P{constructor(){super(...arguments),this._logger=new g(`Timer('${this._name}')`),this._timerHandle=null,this._expiration=0,this._callback=()=>{const t=this._expiration-$.getEpochTime();this._logger.debug("timer completes in",t),this._expiration<=$.getEpochTime()&&(this.cancel(),super.raise())}}static getEpochTime(){return Math.floor(Date.now()/1e3)}init(t){const s=this._logger.create("init");t=Math.max(Math.floor(t),1);const i=$.getEpochTime()+t;if(this.expiration===i&&this._timerHandle){s.debug("skipping since already initialized for expiration at",this.expiration);return}this.cancel(),s.debug("using duration",t),this._expiration=i;const r=Math.min(t,5);this._timerHandle=setInterval(this._callback,r*1e3)}get expiration(){return this._expiration}cancel(){this._logger.create("cancel"),this._timerHandle&&(clearInterval(this._timerHandle),this._timerHandle=null)}},F=class{static readParams(e,t="query"){if(!e)throw new TypeError("Invalid URL");const i=new URL(e,"http://127.0.0.1")[t==="fragment"?"hash":"search"];return new URLSearchParams(i.slice(1))}},M=";",N=class extends Error{constructor(e,t){var s,i,r;if(super(e.error_description||e.error||""),this.form=t,this.name="ErrorResponse",!e.error)throw g.error("ErrorResponse","No error passed"),new Error("No error passed");this.error=e.error,this.error_description=(s=e.error_description)!=null?s:null,this.error_uri=(i=e.error_uri)!=null?i:null,this.state=e.userState,this.session_state=(r=e.session_state)!=null?r:null,this.url_state=e.url_state}},Q=class extends Error{constructor(e){super(e),this.name="ErrorTimeout"}},Ue=class{constructor(e){this._logger=new g("AccessTokenEvents"),this._expiringTimer=new T("Access token expiring"),this._expiredTimer=new T("Access token expired"),this._expiringNotificationTimeInSeconds=e.expiringNotificationTimeInSeconds}async load(e){const t=this._logger.create("load");if(e.access_token&&e.expires_in!==void 0){const s=e.expires_in;if(t.debug("access token present, remaining duration:",s),s>0){let r=s-this._expiringNotificationTimeInSeconds;r<=0&&(r=1),t.debug("registering expiring timer, raising in",r,"seconds"),this._expiringTimer.init(r)}else t.debug("canceling existing expiring timer because we're past expiration."),this._expiringTimer.cancel();const i=s+1;t.debug("registering expired timer, raising in",i,"seconds"),this._expiredTimer.init(i)}else this._expiringTimer.cancel(),this._expiredTimer.cancel()}async unload(){this._logger.debug("unload: canceling existing access token timers"),this._expiringTimer.cancel(),this._expiredTimer.cancel()}addAccessTokenExpiring(e){return this._expiringTimer.addHandler(e)}removeAccessTokenExpiring(e){this._expiringTimer.removeHandler(e)}addAccessTokenExpired(e){return this._expiredTimer.addHandler(e)}removeAccessTokenExpired(e){this._expiredTimer.removeHandler(e)}},Ae=class{constructor(e,t,s,i,r){this._callback=e,this._client_id=t,this._intervalInSeconds=i,this._stopOnError=r,this._logger=new g("CheckSessionIFrame"),this._timer=null,this._session_state=null,this._message=n=>{n.origin===this._frame_origin&&n.source===this._frame.contentWindow&&(n.data==="error"?(this._logger.error("error message from check session op iframe"),this._stopOnError&&this.stop()):n.data==="changed"?(this._logger.debug("changed message from check session op iframe"),this.stop(),this._callback()):this._logger.debug(n.data+" message from check session op iframe"))};const o=new URL(s);this._frame_origin=o.origin,this._frame=window.document.createElement("iframe"),this._frame.style.visibility="hidden",this._frame.style.position="fixed",this._frame.style.left="-1000px",this._frame.style.top="0",this._frame.width="0",this._frame.height="0",this._frame.src=o.href}load(){return new Promise(e=>{this._frame.onload=()=>{e()},window.document.body.appendChild(this._frame),window.addEventListener("message",this._message,!1)})}start(e){if(this._session_state===e)return;this._logger.create("start"),this.stop(),this._session_state=e;const t=()=>{!this._frame.contentWindow||!this._session_state||this._frame.contentWindow.postMessage(this._client_id+" "+this._session_state,this._frame_origin)};t(),this._timer=setInterval(t,this._intervalInSeconds*1e3)}stop(){this._logger.create("stop"),this._session_state=null,this._timer&&(clearInterval(this._timer),this._timer=null)}},ne=class{constructor(){this._logger=new g("InMemoryWebStorage"),this._data={}}clear(){this._logger.create("clear"),this._data={}}getItem(e){return this._logger.create(`getItem('${e}')`),this._data[e]}setItem(e,t){this._logger.create(`setItem('${e}')`),this._data[e]=t}removeItem(e){this._logger.create(`removeItem('${e}')`),delete this._data[e]}get length(){return Object.getOwnPropertyNames(this._data).length}key(e){return Object.getOwnPropertyNames(this._data)[e]}},z=class extends Error{constructor(e,t){super(t),this.name="ErrorDPoPNonce",this.nonce=e}},X=class{constructor(e=[],t=null,s={}){this._jwtHandler=t,this._extraHeaders=s,this._logger=new g("JsonService"),this._contentTypes=[],this._contentTypes.push(...e,"application/json"),t&&this._contentTypes.push("application/jwt")}async fetchWithTimeout(e,t={}){const{timeoutInSeconds:s,...i}=t;if(!s)return await fetch(e,i);const r=new AbortController,o=setTimeout(()=>r.abort(),s*1e3);try{return await fetch(e,{...t,signal:r.signal})}catch(n){throw n instanceof DOMException&&n.name==="AbortError"?new Q("Network timed out"):n}finally{clearTimeout(o)}}async getJson(e,{token:t,credentials:s,timeoutInSeconds:i}={}){const r=this._logger.create("getJson"),o={Accept:this._contentTypes.join(", ")};t&&(r.debug("token passed, setting Authorization header"),o.Authorization="Bearer "+t),this._appendExtraHeaders(o);let n;try{r.debug("url:",e),n=await this.fetchWithTimeout(e,{method:"GET",headers:o,timeoutInSeconds:i,credentials:s})}catch(l){throw r.error("Network Error"),l}r.debug("HTTP response received, status",n.status);const a=n.headers.get("Content-Type");if(a&&!this._contentTypes.find(l=>a.startsWith(l))&&r.throw(new Error(`Invalid response Content-Type: ${a??"undefined"}, from URL: ${e}`)),n.ok&&this._jwtHandler&&(a!=null&&a.startsWith("application/jwt")))return await this._jwtHandler(await n.text());let c;try{c=await n.json()}catch(l){throw r.error("Error parsing JSON response",l),n.ok?l:new Error(`${n.statusText} (${n.status})`)}if(!n.ok)throw r.error("Error from server:",c),c.error?new N(c):new Error(`${n.statusText} (${n.status}): ${JSON.stringify(c)}`);return c}async postForm(e,{body:t,basicAuth:s,timeoutInSeconds:i,initCredentials:r,extraHeaders:o}){const n=this._logger.create("postForm"),a={Accept:this._contentTypes.join(", "),"Content-Type":"application/x-www-form-urlencoded",...o};s!==void 0&&(a.Authorization="Basic "+s),this._appendExtraHeaders(a);let c;try{n.debug("url:",e),c=await this.fetchWithTimeout(e,{method:"POST",headers:a,body:t,timeoutInSeconds:i,credentials:r})}catch(u){throw n.error("Network error"),u}n.debug("HTTP response received, status",c.status);const l=c.headers.get("Content-Type");if(l&&!this._contentTypes.find(u=>l.startsWith(u)))throw new Error(`Invalid response Content-Type: ${l??"undefined"}, from URL: ${e}`);const h=await c.text();let d={};if(h)try{d=JSON.parse(h)}catch(u){throw n.error("Error parsing JSON response",u),c.ok?u:new Error(`${c.statusText} (${c.status})`)}if(!c.ok){if(n.error("Error from server:",d),c.headers.has("dpop-nonce")){const u=c.headers.get("dpop-nonce");throw new z(u,`${JSON.stringify(d)}`)}throw d.error?new N(d,t):new Error(`${c.statusText} (${c.status}): ${JSON.stringify(d)}`)}return d}_appendExtraHeaders(e){const t=this._logger.create("appendExtraHeaders"),s=Object.keys(this._extraHeaders),i=["accept","content-type"],r=["authorization"];s.length!==0&&s.forEach(o=>{if(i.includes(o.toLocaleLowerCase())){t.warn("Protected header could not be set",o,i);return}if(r.includes(o.toLocaleLowerCase())&&Object.keys(e).includes(o)){t.warn("Header could not be overridden",o,r);return}const n=typeof this._extraHeaders[o]=="function"?this._extraHeaders[o]():this._extraHeaders[o];n&&n!==""&&(e[o]=n)})}},Oe=class{constructor(e){this._settings=e,this._logger=new g("MetadataService"),this._signingKeys=null,this._metadata=null,this._metadataUrl=this._settings.metadataUrl,this._jsonService=new X(["application/jwk-set+json"],null,this._settings.extraHeaders),this._settings.signingKeys&&(this._logger.debug("using signingKeys from settings"),this._signingKeys=this._settings.signingKeys),this._settings.metadata&&(this._logger.debug("using metadata from settings"),this._metadata=this._settings.metadata),this._settings.fetchRequestCredentials&&(this._logger.debug("using fetchRequestCredentials from settings"),this._fetchRequestCredentials=this._settings.fetchRequestCredentials)}resetSigningKeys(){this._signingKeys=null}async getMetadata(){const e=this._logger.create("getMetadata");if(this._metadata)return e.debug("using cached values"),this._metadata;if(!this._metadataUrl)throw e.throw(new Error("No authority or metadataUrl configured on settings")),null;e.debug("getting metadata from",this._metadataUrl);const t=await this._jsonService.getJson(this._metadataUrl,{credentials:this._fetchRequestCredentials,timeoutInSeconds:this._settings.requestTimeoutInSeconds});return e.debug("merging remote JSON with seed metadata"),this._metadata=Object.assign({},t,this._settings.metadataSeed),this._metadata}getIssuer(){return this._getMetadataProperty("issuer")}getAuthorizationEndpoint(){return this._getMetadataProperty("authorization_endpoint")}getUserInfoEndpoint(){return this._getMetadataProperty("userinfo_endpoint")}getTokenEndpoint(e=!0){return this._getMetadataProperty("token_endpoint",e)}getCheckSessionIframe(){return this._getMetadataProperty("check_session_iframe",!0)}getEndSessionEndpoint(){return this._getMetadataProperty("end_session_endpoint",!0)}getRevocationEndpoint(e=!0){return this._getMetadataProperty("revocation_endpoint",e)}getKeysEndpoint(e=!0){return this._getMetadataProperty("jwks_uri",e)}async _getMetadataProperty(e,t=!1){const s=this._logger.create(`_getMetadataProperty('${e}')`),i=await this.getMetadata();if(s.debug("resolved"),i[e]===void 0){if(t===!0){s.warn("Metadata does not contain optional property");return}s.throw(new Error("Metadata does not contain property "+e))}return i[e]}async getSigningKeys(){const e=this._logger.create("getSigningKeys");if(this._signingKeys)return e.debug("returning signingKeys from cache"),this._signingKeys;const t=await this.getKeysEndpoint(!1);e.debug("got jwks_uri",t);const s=await this._jsonService.getJson(t,{timeoutInSeconds:this._settings.requestTimeoutInSeconds});if(e.debug("got key set",s),!Array.isArray(s.keys))throw e.throw(new Error("Missing keys on keyset")),null;return this._signingKeys=s.keys,this._signingKeys}},oe=class{constructor({prefix:e="oidc.",store:t=localStorage}={}){this._logger=new g("WebStorageStateStore"),this._store=t,this._prefix=e}async set(e,t){this._logger.create(`set('${e}')`),e=this._prefix+e,await this._store.setItem(e,t)}async get(e){return this._logger.create(`get('${e}')`),e=this._prefix+e,await this._store.getItem(e)}async remove(e){this._logger.create(`remove('${e}')`),e=this._prefix+e;const t=await this._store.getItem(e);return await this._store.removeItem(e),t}async getAllKeys(){this._logger.create("getAllKeys");const e=await this._store.length,t=[];for(let s=0;s<e;s++){const i=await this._store.key(s);i&&i.indexOf(this._prefix)===0&&t.push(i.substr(this._prefix.length))}return t}},qe="code",Ne="openid",Me="client_secret_post",He=60*15,B=class{constructor({authority:e,metadataUrl:t,metadata:s,signingKeys:i,metadataSeed:r,client_id:o,client_secret:n,response_type:a=qe,scope:c=Ne,redirect_uri:l,post_logout_redirect_uri:h,client_authentication:d=Me,token_endpoint_auth_signing_alg:u="HS256",prompt:w,display:C,max_age:x,ui_locales:U,acr_values:A,resource:R,response_mode:O,filterProtocolClaims:I=!0,loadUserInfo:S=!1,requestTimeoutInSeconds:p,staleStateAgeInSeconds:k=He,mergeClaimsStrategy:E={array:"replace"},disablePKCE:f=!1,stateStore:q,revokeTokenAdditionalContentTypes:me,fetchRequestCredentials:Y,refreshTokenAllowedScope:Se,extraQueryParams:ve={},extraTokenParams:ye={},extraHeaders:be={},dpop:ke,omitScopeWhenRequesting:Ee=!1}){var Z;if(this.authority=e,t?this.metadataUrl=t:(this.metadataUrl=e,e&&(this.metadataUrl.endsWith("/")||(this.metadataUrl+="/"),this.metadataUrl+=".well-known/openid-configuration")),this.metadata=s,this.metadataSeed=r,this.signingKeys=i,this.client_id=o,this.client_secret=n,this.response_type=a,this.scope=c,this.redirect_uri=l,this.post_logout_redirect_uri=h,this.client_authentication=d,this.token_endpoint_auth_signing_alg=u,this.prompt=w,this.display=C,this.max_age=x,this.ui_locales=U,this.acr_values=A,this.resource=R,this.response_mode=O,this.filterProtocolClaims=I??!0,this.loadUserInfo=!!S,this.staleStateAgeInSeconds=k,this.mergeClaimsStrategy=E,this.omitScopeWhenRequesting=Ee,this.disablePKCE=!!f,this.revokeTokenAdditionalContentTypes=me,this.fetchRequestCredentials=Y||"same-origin",this.requestTimeoutInSeconds=p,q)this.stateStore=q;else{const Te=typeof window<"u"?window.localStorage:new ne;this.stateStore=new oe({store:Te})}if(this.refreshTokenAllowedScope=Se,this.extraQueryParams=ve,this.extraTokenParams=ye,this.extraHeaders=be,this.dpop=ke,this.dpop&&!((Z=this.dpop)!=null&&Z.store))throw new Error("A DPoPStore is required when dpop is enabled")}},je=class{constructor(e,t){this._settings=e,this._metadataService=t,this._logger=new g("UserInfoService"),this._getClaimsFromJwt=async s=>{const i=this._logger.create("_getClaimsFromJwt");try{const r=j.decode(s);return i.debug("JWT decoding successful"),r}catch(r){throw i.error("Error parsing JWT response"),r}},this._jsonService=new X(void 0,this._getClaimsFromJwt,this._settings.extraHeaders)}async getClaims(e){const t=this._logger.create("getClaims");e||this._logger.throw(new Error("No token passed"));const s=await this._metadataService.getUserInfoEndpoint();t.debug("got userinfo url",s);const i=await this._jsonService.getJson(s,{token:e,credentials:this._settings.fetchRequestCredentials,timeoutInSeconds:this._settings.requestTimeoutInSeconds});return t.debug("got claims",i),i}},ae=class{constructor(e,t){this._settings=e,this._metadataService=t,this._logger=new g("TokenClient"),this._jsonService=new X(this._settings.revokeTokenAdditionalContentTypes,null,this._settings.extraHeaders)}async exchangeCode({grant_type:e="authorization_code",redirect_uri:t=this._settings.redirect_uri,client_id:s=this._settings.client_id,client_secret:i=this._settings.client_secret,extraHeaders:r,...o}){const n=this._logger.create("exchangeCode");s||n.throw(new Error("A client_id is required")),t||n.throw(new Error("A redirect_uri is required")),o.code||n.throw(new Error("A code is required"));const a=new URLSearchParams({grant_type:e,redirect_uri:t});for(const[d,u]of Object.entries(o))u!=null&&a.set(d,u);if((this._settings.client_authentication==="client_secret_basic"||this._settings.client_authentication==="client_secret_jwt")&&i==null)throw n.throw(new Error("A client_secret is required")),null;let c;const l=await this._metadataService.getTokenEndpoint(!1);switch(this._settings.client_authentication){case"client_secret_basic":c=_.generateBasicAuth(s,i);break;case"client_secret_post":a.append("client_id",s),i&&a.append("client_secret",i);break;case"client_secret_jwt":{const d=await _.generateClientAssertionJwt(s,i,l,this._settings.token_endpoint_auth_signing_alg);a.append("client_id",s),a.append("client_assertion_type","urn:ietf:params:oauth:client-assertion-type:jwt-bearer"),a.append("client_assertion",d);break}}n.debug("got token endpoint");const h=await this._jsonService.postForm(l,{body:a,basicAuth:c,timeoutInSeconds:this._settings.requestTimeoutInSeconds,initCredentials:this._settings.fetchRequestCredentials,extraHeaders:r});return n.debug("got response"),h}async exchangeCredentials({grant_type:e="password",client_id:t=this._settings.client_id,client_secret:s=this._settings.client_secret,scope:i=this._settings.scope,...r}){const o=this._logger.create("exchangeCredentials");t||o.throw(new Error("A client_id is required"));const n=new URLSearchParams({grant_type:e});this._settings.omitScopeWhenRequesting||n.set("scope",i);for(const[h,d]of Object.entries(r))d!=null&&n.set(h,d);if((this._settings.client_authentication==="client_secret_basic"||this._settings.client_authentication==="client_secret_jwt")&&s==null)throw o.throw(new Error("A client_secret is required")),null;let a;const c=await this._metadataService.getTokenEndpoint(!1);switch(this._settings.client_authentication){case"client_secret_basic":a=_.generateBasicAuth(t,s);break;case"client_secret_post":n.append("client_id",t),s&&n.append("client_secret",s);break;case"client_secret_jwt":{const h=await _.generateClientAssertionJwt(t,s,c,this._settings.token_endpoint_auth_signing_alg);n.append("client_id",t),n.append("client_assertion_type","urn:ietf:params:oauth:client-assertion-type:jwt-bearer"),n.append("client_assertion",h);break}}o.debug("got token endpoint");const l=await this._jsonService.postForm(c,{body:n,basicAuth:a,timeoutInSeconds:this._settings.requestTimeoutInSeconds,initCredentials:this._settings.fetchRequestCredentials});return o.debug("got response"),l}async exchangeRefreshToken({grant_type:e="refresh_token",client_id:t=this._settings.client_id,client_secret:s=this._settings.client_secret,timeoutInSeconds:i,extraHeaders:r,...o}){const n=this._logger.create("exchangeRefreshToken");t||n.throw(new Error("A client_id is required")),o.refresh_token||n.throw(new Error("A refresh_token is required"));const a=new URLSearchParams({grant_type:e});for(const[d,u]of Object.entries(o))Array.isArray(u)?u.forEach(w=>a.append(d,w)):u!=null&&a.set(d,u);if((this._settings.client_authentication==="client_secret_basic"||this._settings.client_authentication==="client_secret_jwt")&&s==null)throw n.throw(new Error("A client_secret is required")),null;let c;const l=await this._metadataService.getTokenEndpoint(!1);switch(this._settings.client_authentication){case"client_secret_basic":c=_.generateBasicAuth(t,s);break;case"client_secret_post":a.append("client_id",t),s&&a.append("client_secret",s);break;case"client_secret_jwt":{const d=await _.generateClientAssertionJwt(t,s,l,this._settings.token_endpoint_auth_signing_alg);a.append("client_id",t),a.append("client_assertion_type","urn:ietf:params:oauth:client-assertion-type:jwt-bearer"),a.append("client_assertion",d);break}}n.debug("got token endpoint");const h=await this._jsonService.postForm(l,{body:a,basicAuth:c,timeoutInSeconds:i,initCredentials:this._settings.fetchRequestCredentials,extraHeaders:r});return n.debug("got response"),h}async revoke(e){var t;const s=this._logger.create("revoke");e.token||s.throw(new Error("A token is required"));const i=await this._metadataService.getRevocationEndpoint(!1);s.debug(`got revocation endpoint, revoking ${(t=e.token_type_hint)!=null?t:"default token type"}`);const r=new URLSearchParams;for(const[o,n]of Object.entries(e))n!=null&&r.set(o,n);r.set("client_id",this._settings.client_id),this._settings.client_secret&&r.set("client_secret",this._settings.client_secret),await this._jsonService.postForm(i,{body:r,timeoutInSeconds:this._settings.requestTimeoutInSeconds}),s.debug("got response")}},$e=class{constructor(e,t,s){this._settings=e,this._metadataService=t,this._claimsService=s,this._logger=new g("ResponseValidator"),this._userInfoService=new je(this._settings,this._metadataService),this._tokenClient=new ae(this._settings,this._metadataService)}async validateSigninResponse(e,t,s){const i=this._logger.create("validateSigninResponse");this._processSigninState(e,t),i.debug("state processed"),await this._processCode(e,t,s),i.debug("code processed"),e.isOpenId&&this._validateIdTokenAttributes(e,"",t.nonce),i.debug("tokens validated"),await this._processClaims(e,t==null?void 0:t.skipUserInfo,e.isOpenId),i.debug("claims processed")}async validateCredentialsResponse(e,t){const s=this._logger.create("validateCredentialsResponse"),i=e.isOpenId&&!!e.id_token;i&&this._validateIdTokenAttributes(e),s.debug("tokens validated"),await this._processClaims(e,t,i),s.debug("claims processed")}async validateRefreshResponse(e,t){var s,i;const r=this._logger.create("validateRefreshResponse");e.userState=t.data,(s=e.session_state)!=null||(e.session_state=t.session_state),(i=e.scope)!=null||(e.scope=t.scope),e.isOpenId&&e.id_token&&(this._validateIdTokenAttributes(e,t.id_token),r.debug("ID Token validated")),e.id_token||(e.id_token=t.id_token,e.profile=t.profile);const o=e.isOpenId&&!!e.id_token;await this._processClaims(e,!1,o),r.debug("claims processed")}validateSignoutResponse(e,t){const s=this._logger.create("validateSignoutResponse");if(t.id!==e.state&&s.throw(new Error("State does not match")),s.debug("state validated"),e.userState=t.data,e.error)throw s.warn("Response was error",e.error),new N(e)}_processSigninState(e,t){var s;const i=this._logger.create("_processSigninState");if(t.id!==e.state&&i.throw(new Error("State does not match")),t.client_id||i.throw(new Error("No client_id on state")),t.authority||i.throw(new Error("No authority on state")),this._settings.authority!==t.authority&&i.throw(new Error("authority mismatch on settings vs. signin state")),this._settings.client_id&&this._settings.client_id!==t.client_id&&i.throw(new Error("client_id mismatch on settings vs. signin state")),i.debug("state validated"),e.userState=t.data,e.url_state=t.url_state,(s=e.scope)!=null||(e.scope=t.scope),e.error)throw i.warn("Response was error",e.error),new N(e);t.code_verifier&&!e.code&&i.throw(new Error("Expected code in response"))}async _processClaims(e,t=!1,s=!0){const i=this._logger.create("_processClaims");if(e.profile=this._claimsService.filterProtocolClaims(e.profile),t||!this._settings.loadUserInfo||!e.access_token){i.debug("not loading user info");return}i.debug("loading user info");const r=await this._userInfoService.getClaims(e.access_token);i.debug("user info claims received from user info endpoint"),s&&r.sub!==e.profile.sub&&i.throw(new Error("subject from UserInfo response does not match subject in ID Token")),e.profile=this._claimsService.mergeClaims(e.profile,this._claimsService.filterProtocolClaims(r)),i.debug("user info claims received, updated profile:",e.profile)}async _processCode(e,t,s){const i=this._logger.create("_processCode");if(e.code){i.debug("Validating code");const r=await this._tokenClient.exchangeCode({client_id:t.client_id,client_secret:t.client_secret,code:e.code,redirect_uri:t.redirect_uri,code_verifier:t.code_verifier,extraHeaders:s,...t.extraTokenParams});Object.assign(e,r)}else i.debug("No code to process")}_validateIdTokenAttributes(e,t,s){var i;const r=this._logger.create("_validateIdTokenAttributes");r.debug("decoding ID Token JWT");const o=j.decode((i=e.id_token)!=null?i:"");if(o.sub||r.throw(new Error("ID Token is missing a subject claim")),s&&o.nonce!==s&&r.throw(new Error("nonce in id_token does not match nonce in client storage")),t){const n=j.decode(t);o.sub!==n.sub&&r.throw(new Error("sub in id_token does not match current sub")),o.auth_time&&o.auth_time!==n.auth_time&&r.throw(new Error("auth_time in id_token does not match original auth_time")),o.azp&&o.azp!==n.azp&&r.throw(new Error("azp in id_token does not match original azp")),!o.azp&&n.azp&&r.throw(new Error("azp not in id_token, but present in original id_token"))}e.profile=o}},J=class V{constructor(t){this.id=t.id||_.generateUUIDv4(),this.data=t.data,t.created&&t.created>0?this.created=t.created:this.created=T.getEpochTime(),this.request_type=t.request_type,this.url_state=t.url_state}toStorageString(){return new g("State").create("toStorageString"),JSON.stringify({id:this.id,data:this.data,created:this.created,request_type:this.request_type,url_state:this.url_state})}static fromStorageString(t){return g.createStatic("State","fromStorageString"),Promise.resolve(new V(JSON.parse(t)))}static async clearStaleState(t,s){const i=g.createStatic("State","clearStaleState"),r=T.getEpochTime()-s,o=await t.getAllKeys();i.debug("got keys",o);for(let n=0;n<o.length;n++){const a=o[n],c=await t.get(a);let l=!1;if(c)try{const h=await V.fromStorageString(c);i.debug("got item from key:",a,h.created),h.created<=r&&(l=!0)}catch(h){i.error("Error parsing state for key:",a,h),l=!0}else i.debug("no item in storage for key:",a),l=!0;l&&(i.debug("removed item for key:",a),t.remove(a))}}},ce=class G extends J{constructor(t){super(t),this.code_verifier=t.code_verifier,this.code_challenge=t.code_challenge,this.authority=t.authority,this.client_id=t.client_id,this.redirect_uri=t.redirect_uri,this.scope=t.scope,this.client_secret=t.client_secret,this.extraTokenParams=t.extraTokenParams,this.response_mode=t.response_mode,this.skipUserInfo=t.skipUserInfo,this.nonce=t.nonce}static async create(t){const s=t.code_verifier===!0?_.generateCodeVerifier():t.code_verifier||void 0,i=s?await _.generateCodeChallenge(s):void 0;return new G({...t,code_verifier:s,code_challenge:i})}toStorageString(){return new g("SigninState").create("toStorageString"),JSON.stringify({id:this.id,data:this.data,created:this.created,request_type:this.request_type,url_state:this.url_state,code_verifier:this.code_verifier,authority:this.authority,client_id:this.client_id,redirect_uri:this.redirect_uri,scope:this.scope,client_secret:this.client_secret,extraTokenParams:this.extraTokenParams,response_mode:this.response_mode,skipUserInfo:this.skipUserInfo,nonce:this.nonce})}static fromStorageString(t){g.createStatic("SigninState","fromStorageString");const s=JSON.parse(t);return G.create(s)}},le=class de{constructor(t){this.url=t.url,this.state=t.state}static async create({url:t,authority:s,client_id:i,redirect_uri:r,response_type:o,scope:n,state_data:a,response_mode:c,request_type:l,client_secret:h,nonce:d,url_state:u,resource:w,skipUserInfo:C,extraQueryParams:x,extraTokenParams:U,disablePKCE:A,dpopJkt:R,omitScopeWhenRequesting:O,...I}){if(!t)throw this._logger.error("create: No url passed"),new Error("url");if(!i)throw this._logger.error("create: No client_id passed"),new Error("client_id");if(!r)throw this._logger.error("create: No redirect_uri passed"),new Error("redirect_uri");if(!o)throw this._logger.error("create: No response_type passed"),new Error("response_type");if(!n)throw this._logger.error("create: No scope passed"),new Error("scope");if(!s)throw this._logger.error("create: No authority passed"),new Error("authority");const S=await ce.create({data:a,request_type:l,url_state:u,code_verifier:!A,client_id:i,authority:s,redirect_uri:r,response_mode:c,client_secret:h,scope:n,extraTokenParams:U,skipUserInfo:C,nonce:d}),p=new URL(t);p.searchParams.append("client_id",i),p.searchParams.append("redirect_uri",r),p.searchParams.append("response_type",o),O||p.searchParams.append("scope",n),d&&p.searchParams.append("nonce",d),R&&p.searchParams.append("dpop_jkt",R);let k=S.id;u&&(k=`${k}${M}${u}`),p.searchParams.append("state",k),S.code_challenge&&(p.searchParams.append("code_challenge",S.code_challenge),p.searchParams.append("code_challenge_method","S256")),w&&(Array.isArray(w)?w:[w]).forEach(f=>p.searchParams.append("resource",f));for(const[E,f]of Object.entries({response_mode:c,...I,...x}))f!=null&&p.searchParams.append(E,f.toString());return new de({url:p.href,state:S})}};le._logger=new g("SigninRequest");var De=le,Je="openid",W=class{constructor(e){if(this.access_token="",this.token_type="",this.profile={},this.state=e.get("state"),this.session_state=e.get("session_state"),this.state){const t=decodeURIComponent(this.state).split(M);this.state=t[0],t.length>1&&(this.url_state=t.slice(1).join(M))}this.error=e.get("error"),this.error_description=e.get("error_description"),this.error_uri=e.get("error_uri"),this.code=e.get("code")}get expires_in(){if(this.expires_at!==void 0)return this.expires_at-T.getEpochTime()}set expires_in(e){typeof e=="string"&&(e=Number(e)),e!==void 0&&e>=0&&(this.expires_at=Math.floor(e)+T.getEpochTime())}get isOpenId(){var e;return((e=this.scope)==null?void 0:e.split(" ").includes(Je))||!!this.id_token}},We=class{constructor({url:e,state_data:t,id_token_hint:s,post_logout_redirect_uri:i,extraQueryParams:r,request_type:o,client_id:n,url_state:a}){if(this._logger=new g("SignoutRequest"),!e)throw this._logger.error("ctor: No url passed"),new Error("url");const c=new URL(e);if(s&&c.searchParams.append("id_token_hint",s),n&&c.searchParams.append("client_id",n),i&&(c.searchParams.append("post_logout_redirect_uri",i),t||a)){this.state=new J({data:t,request_type:o,url_state:a});let l=this.state.id;a&&(l=`${l}${M}${a}`),c.searchParams.append("state",l)}for(const[l,h]of Object.entries({...r}))h!=null&&c.searchParams.append(l,h.toString());this.url=c.href}},Ke=class{constructor(e){if(this.state=e.get("state"),this.state){const t=decodeURIComponent(this.state).split(M);this.state=t[0],t.length>1&&(this.url_state=t.slice(1).join(M))}this.error=e.get("error"),this.error_description=e.get("error_description"),this.error_uri=e.get("error_uri")}},Le=["nbf","jti","auth_time","nonce","acr","amr","azp","at_hash"],Fe=["sub","iss","aud","exp","iat"],ze=class{constructor(e){this._settings=e,this._logger=new g("ClaimsService")}filterProtocolClaims(e){const t={...e};if(this._settings.filterProtocolClaims){let s;Array.isArray(this._settings.filterProtocolClaims)?s=this._settings.filterProtocolClaims:s=Le;for(const i of s)Fe.includes(i)||delete t[i]}return t}mergeClaims(e,t){const s={...e};for(const[i,r]of Object.entries(t))if(s[i]!==r)if(Array.isArray(s[i])||Array.isArray(r))if(this._settings.mergeClaimsStrategy.array=="replace")s[i]=r;else{const o=Array.isArray(s[i])?s[i]:[s[i]];for(const n of Array.isArray(r)?r:[r])o.includes(n)||o.push(n);s[i]=o}else typeof s[i]=="object"&&typeof r=="object"?s[i]=this.mergeClaims(s[i],r):s[i]=r;return s}},he=class{constructor(e,t){this.keys=e,this.nonce=t}},Be=class{constructor(e,t){this._logger=new g("OidcClient"),this.settings=e instanceof B?e:new B(e),this.metadataService=t??new Oe(this.settings),this._claimsService=new ze(this.settings),this._validator=new $e(this.settings,this.metadataService,this._claimsService),this._tokenClient=new ae(this.settings,this.metadataService)}async createSigninRequest({state:e,request:t,request_uri:s,request_type:i,id_token_hint:r,login_hint:o,skipUserInfo:n,nonce:a,url_state:c,response_type:l=this.settings.response_type,scope:h=this.settings.scope,redirect_uri:d=this.settings.redirect_uri,prompt:u=this.settings.prompt,display:w=this.settings.display,max_age:C=this.settings.max_age,ui_locales:x=this.settings.ui_locales,acr_values:U=this.settings.acr_values,resource:A=this.settings.resource,response_mode:R=this.settings.response_mode,extraQueryParams:O=this.settings.extraQueryParams,extraTokenParams:I=this.settings.extraTokenParams,dpopJkt:S,omitScopeWhenRequesting:p=this.settings.omitScopeWhenRequesting}){const k=this._logger.create("createSigninRequest");if(l!=="code")throw new Error("Only the Authorization Code flow (with PKCE) is supported");const E=await this.metadataService.getAuthorizationEndpoint();k.debug("Received authorization endpoint",E);const f=await De.create({url:E,authority:this.settings.authority,client_id:this.settings.client_id,redirect_uri:d,response_type:l,scope:h,state_data:e,url_state:c,prompt:u,display:w,max_age:C,ui_locales:x,id_token_hint:r,login_hint:o,acr_values:U,dpopJkt:S,resource:A,request:t,request_uri:s,extraQueryParams:O,extraTokenParams:I,request_type:i,response_mode:R,client_secret:this.settings.client_secret,skipUserInfo:n,nonce:a,disablePKCE:this.settings.disablePKCE,omitScopeWhenRequesting:p});await this.clearStaleState();const q=f.state;return await this.settings.stateStore.set(q.id,q.toStorageString()),f}async readSigninResponseState(e,t=!1){const s=this._logger.create("readSigninResponseState"),i=new W(F.readParams(e,this.settings.response_mode));if(!i.state)throw s.throw(new Error("No state in response")),null;const r=await this.settings.stateStore[t?"remove":"get"](i.state);if(!r)throw s.throw(new Error("No matching state found in storage")),null;return{state:await ce.fromStorageString(r),response:i}}async processSigninResponse(e,t,s=!0){const i=this._logger.create("processSigninResponse"),{state:r,response:o}=await this.readSigninResponseState(e,s);if(i.debug("received state from storage; validating response"),this.settings.dpop&&this.settings.dpop.store){const n=await this.getDpopProof(this.settings.dpop.store);t={...t,DPoP:n}}try{await this._validator.validateSigninResponse(o,r,t)}catch(n){if(n instanceof z&&this.settings.dpop){const a=await this.getDpopProof(this.settings.dpop.store,n.nonce);t.DPoP=a,await this._validator.validateSigninResponse(o,r,t)}else throw n}return o}async getDpopProof(e,t){let s,i;return(await e.getAllKeys()).includes(this.settings.client_id)?(i=await e.get(this.settings.client_id),i.nonce!==t&&t&&(i.nonce=t,await e.set(this.settings.client_id,i))):(s=await _.generateDPoPKeys(),i=new he(s,t),await e.set(this.settings.client_id,i)),await _.generateDPoPProof({url:await this.metadataService.getTokenEndpoint(!1),httpMethod:"POST",keyPair:i.keys,nonce:i.nonce})}async processResourceOwnerPasswordCredentials({username:e,password:t,skipUserInfo:s=!1,extraTokenParams:i={}}){const r=await this._tokenClient.exchangeCredentials({username:e,password:t,...i}),o=new W(new URLSearchParams);return Object.assign(o,r),await this._validator.validateCredentialsResponse(o,s),o}async useRefreshToken({state:e,redirect_uri:t,resource:s,timeoutInSeconds:i,extraHeaders:r,extraTokenParams:o}){var n;const a=this._logger.create("useRefreshToken");let c;if(this.settings.refreshTokenAllowedScope===void 0)c=e.scope;else{const d=this.settings.refreshTokenAllowedScope.split(" ");c=(((n=e.scope)==null?void 0:n.split(" "))||[]).filter(w=>d.includes(w)).join(" ")}if(this.settings.dpop&&this.settings.dpop.store){const d=await this.getDpopProof(this.settings.dpop.store);r={...r,DPoP:d}}let l;try{l=await this._tokenClient.exchangeRefreshToken({refresh_token:e.refresh_token,scope:c,redirect_uri:t,resource:s,timeoutInSeconds:i,extraHeaders:r,...o})}catch(d){if(d instanceof z&&this.settings.dpop)r.DPoP=await this.getDpopProof(this.settings.dpop.store,d.nonce),l=await this._tokenClient.exchangeRefreshToken({refresh_token:e.refresh_token,scope:c,redirect_uri:t,resource:s,timeoutInSeconds:i,extraHeaders:r,...o});else throw d}const h=new W(new URLSearchParams);return Object.assign(h,l),a.debug("validating response",h),await this._validator.validateRefreshResponse(h,{...e,scope:c}),h}async createSignoutRequest({state:e,id_token_hint:t,client_id:s,request_type:i,url_state:r,post_logout_redirect_uri:o=this.settings.post_logout_redirect_uri,extraQueryParams:n=this.settings.extraQueryParams}={}){const a=this._logger.create("createSignoutRequest"),c=await this.metadataService.getEndSessionEndpoint();if(!c)throw a.throw(new Error("No end session endpoint")),null;a.debug("Received end session endpoint",c),!s&&o&&!t&&(s=this.settings.client_id);const l=new We({url:c,id_token_hint:t,client_id:s,post_logout_redirect_uri:o,state_data:e,extraQueryParams:n,request_type:i,url_state:r});await this.clearStaleState();const h=l.state;return h&&(a.debug("Signout request has state to persist"),await this.settings.stateStore.set(h.id,h.toStorageString())),l}async readSignoutResponseState(e,t=!1){const s=this._logger.create("readSignoutResponseState"),i=new Ke(F.readParams(e,this.settings.response_mode));if(!i.state){if(s.debug("No state in response"),i.error)throw s.warn("Response was error:",i.error),new N(i);return{state:void 0,response:i}}const r=await this.settings.stateStore[t?"remove":"get"](i.state);if(!r)throw s.throw(new Error("No matching state found in storage")),null;return{state:await J.fromStorageString(r),response:i}}async processSignoutResponse(e){const t=this._logger.create("processSignoutResponse"),{state:s,response:i}=await this.readSignoutResponseState(e,!0);return s?(t.debug("Received state from storage; validating response"),this._validator.validateSignoutResponse(i,s)):t.debug("No state from storage; skipping response validation"),i}clearStaleState(){return this._logger.create("clearStaleState"),J.clearStaleState(this.settings.stateStore,this.settings.staleStateAgeInSeconds)}async revokeToken(e,t){return this._logger.create("revokeToken"),await this._tokenClient.revoke({token:e,token_type_hint:t})}},Ve=class{constructor(e){this._userManager=e,this._logger=new g("SessionMonitor"),this._start=async t=>{const s=t.session_state;if(!s)return;const i=this._logger.create("_start");if(t.profile?(this._sub=t.profile.sub,i.debug("session_state",s,", sub",this._sub)):(this._sub=void 0,i.debug("session_state",s,", anonymous user")),this._checkSessionIFrame){this._checkSessionIFrame.start(s);return}try{const r=await this._userManager.metadataService.getCheckSessionIframe();if(r){i.debug("initializing check session iframe");const o=this._userManager.settings.client_id,n=this._userManager.settings.checkSessionIntervalInSeconds,a=this._userManager.settings.stopCheckSessionOnError,c=new Ae(this._callback,o,r,n,a);await c.load(),this._checkSessionIFrame=c,c.start(s)}else i.warn("no check session iframe found in the metadata")}catch(r){i.error("Error from getCheckSessionIframe:",r instanceof Error?r.message:r)}},this._stop=()=>{const t=this._logger.create("_stop");if(this._sub=void 0,this._checkSessionIFrame&&this._checkSessionIFrame.stop(),this._userManager.settings.monitorAnonymousSession){const s=setInterval(async()=>{clearInterval(s);try{const i=await this._userManager.querySessionStatus();if(i){const r={session_state:i.session_state,profile:i.sub?{sub:i.sub}:null};this._start(r)}}catch(i){t.error("error from querySessionStatus",i instanceof Error?i.message:i)}},1e3)}},this._callback=async()=>{const t=this._logger.create("_callback");try{const s=await this._userManager.querySessionStatus();let i=!0;s&&this._checkSessionIFrame?s.sub===this._sub?(i=!1,this._checkSessionIFrame.start(s.session_state),t.debug("same sub still logged in at OP, session state has changed, restarting check session iframe; session_state",s.session_state),await this._userManager.events._raiseUserSessionChanged()):t.debug("different subject signed into OP",s.sub):t.debug("subject no longer signed into OP"),i?this._sub?await this._userManager.events._raiseUserSignedOut():await this._userManager.events._raiseUserSignedIn():t.debug("no change in session detected, no event to raise")}catch(s){this._sub&&(t.debug("Error calling queryCurrentSigninSession; raising signed out event",s),await this._userManager.events._raiseUserSignedOut())}},e||this._logger.throw(new Error("No user manager passed")),this._userManager.events.addUserLoaded(this._start),this._userManager.events.addUserUnloaded(this._stop),this._init().catch(t=>{this._logger.error(t)})}async _init(){this._logger.create("_init");const e=await this._userManager.getUser();if(e)this._start(e);else if(this._userManager.settings.monitorAnonymousSession){const t=await this._userManager.querySessionStatus();if(t){const s={session_state:t.session_state,profile:t.sub?{sub:t.sub}:null};this._start(s)}}}},K=class ge{constructor(t){var s;this.id_token=t.id_token,this.session_state=(s=t.session_state)!=null?s:null,this.access_token=t.access_token,this.refresh_token=t.refresh_token,this.token_type=t.token_type,this.scope=t.scope,this.profile=t.profile,this.expires_at=t.expires_at,this.state=t.userState,this.url_state=t.url_state}get expires_in(){if(this.expires_at!==void 0)return this.expires_at-T.getEpochTime()}set expires_in(t){t!==void 0&&(this.expires_at=Math.floor(t)+T.getEpochTime())}get expired(){const t=this.expires_in;if(t!==void 0)return t<=0}get scopes(){var t,s;return(s=(t=this.scope)==null?void 0:t.split(" "))!=null?s:[]}toStorageString(){return new g("User").create("toStorageString"),JSON.stringify({id_token:this.id_token,session_state:this.session_state,access_token:this.access_token,refresh_token:this.refresh_token,token_type:this.token_type,scope:this.scope,profile:this.profile,expires_at:this.expires_at})}static fromStorageString(t){return g.createStatic("User","fromStorageString"),new ge(JSON.parse(t))}},te="oidc-client",ue=class{constructor(){this._abort=new P("Window navigation aborted"),this._disposeHandlers=new Set,this._window=null}async navigate(e){const t=this._logger.create("navigate");if(!this._window)throw new Error("Attempted to navigate on a disposed window");t.debug("setting URL in window"),this._window.location.replace(e.url);const{url:s,keepOpen:i}=await new Promise((r,o)=>{const n=c=>{var l;const h=c.data,d=(l=e.scriptOrigin)!=null?l:window.location.origin;if(!(c.origin!==d||(h==null?void 0:h.source)!==te)){try{const u=F.readParams(h.url,e.response_mode).get("state");if(u||t.warn("no state found in response url"),c.source!==this._window&&u!==e.state)return}catch{this._dispose(),o(new Error("Invalid response from window"))}r(h)}};window.addEventListener("message",n,!1),this._disposeHandlers.add(()=>window.removeEventListener("message",n,!1));const a=new BroadcastChannel(`oidc-client-popup-${e.state}`);a.addEventListener("message",n,!1),this._disposeHandlers.add(()=>a.close()),this._disposeHandlers.add(this._abort.addHandler(c=>{this._dispose(),o(c)}))});return t.debug("got response from window"),this._dispose(),i||this.close(),{url:s}}_dispose(){this._logger.create("_dispose");for(const e of this._disposeHandlers)e();this._disposeHandlers.clear()}static _notifyParent(e,t,s=!1,i=window.location.origin){const r={source:te,url:t,keepOpen:s},o=new g("_notifyParent");if(e)o.debug("With parent. Using parent.postMessage."),e.postMessage(r,i);else{o.debug("No parent. Using BroadcastChannel.");const n=new URL(t).searchParams.get("state");if(!n)throw new Error("No parent and no state in URL. Can't complete notification.");const a=new BroadcastChannel(`oidc-client-popup-${n}`);a.postMessage(r),a.close()}}},_e={location:!1,toolbar:!1,height:640,closePopupWindowAfterInSeconds:-1},pe="_blank",Ge=60,Qe=2,we=10,Xe=class extends B{constructor(e){const{popup_redirect_uri:t=e.redirect_uri,popup_post_logout_redirect_uri:s=e.post_logout_redirect_uri,popupWindowFeatures:i=_e,popupWindowTarget:r=pe,redirectMethod:o="assign",redirectTarget:n="self",iframeNotifyParentOrigin:a=e.iframeNotifyParentOrigin,iframeScriptOrigin:c=e.iframeScriptOrigin,requestTimeoutInSeconds:l,silent_redirect_uri:h=e.redirect_uri,silentRequestTimeoutInSeconds:d,automaticSilentRenew:u=!0,validateSubOnSilentRenew:w=!0,includeIdTokenInSilentRenew:C=!1,monitorSession:x=!1,monitorAnonymousSession:U=!1,checkSessionIntervalInSeconds:A=Qe,query_status_response_type:R="code",stopCheckSessionOnError:O=!0,revokeTokenTypes:I=["access_token","refresh_token"],revokeTokensOnSignout:S=!1,includeIdTokenInSilentSignout:p=!1,accessTokenExpiringNotificationTimeInSeconds:k=Ge,maxSilentRenewTimeoutRetries:E,userStore:f}=e;if(super(e),this.popup_redirect_uri=t,this.popup_post_logout_redirect_uri=s,this.popupWindowFeatures=i,this.popupWindowTarget=r,this.redirectMethod=o,this.redirectTarget=n,this.iframeNotifyParentOrigin=a,this.iframeScriptOrigin=c,this.silent_redirect_uri=h,this.silentRequestTimeoutInSeconds=d||l||we,this.automaticSilentRenew=u,this.validateSubOnSilentRenew=w,this.includeIdTokenInSilentRenew=C,this.monitorSession=x,this.monitorAnonymousSession=U,this.checkSessionIntervalInSeconds=A,this.stopCheckSessionOnError=O,this.query_status_response_type=R,this.revokeTokenTypes=I,this.revokeTokensOnSignout=S,this.includeIdTokenInSilentSignout=p,this.accessTokenExpiringNotificationTimeInSeconds=k,this.maxSilentRenewTimeoutRetries=E,f)this.userStore=f;else{const q=typeof window<"u"?window.sessionStorage:new ne;this.userStore=new oe({store:q})}}},se=class fe extends ue{constructor({silentRequestTimeoutInSeconds:t=we}){super(),this._logger=new g("IFrameWindow"),this._timeoutInSeconds=t,this._frame=fe.createHiddenIframe(),this._window=this._frame.contentWindow}static createHiddenIframe(){const t=window.document.createElement("iframe");return t.style.visibility="hidden",t.style.position="fixed",t.style.left="-1000px",t.style.top="0",t.width="0",t.height="0",window.document.body.appendChild(t),t}async navigate(t){this._logger.debug("navigate: Using timeout of:",this._timeoutInSeconds);const s=setTimeout(()=>void this._abort.raise(new Q("IFrame timed out without a response")),this._timeoutInSeconds*1e3);return this._disposeHandlers.add(()=>clearTimeout(s)),await super.navigate(t)}close(){var t;this._frame&&(this._frame.parentNode&&(this._frame.addEventListener("load",s=>{var i;const r=s.target;(i=r.parentNode)==null||i.removeChild(r),this._abort.raise(new Error("IFrame removed from DOM"))},!0),(t=this._frame.contentWindow)==null||t.location.replace("about:blank")),this._frame=null),this._window=null}static notifyParent(t,s){return super._notifyParent(window.parent,t,!1,s)}},Ye=class{constructor(e){this._settings=e,this._logger=new g("IFrameNavigator")}async prepare({silentRequestTimeoutInSeconds:e=this._settings.silentRequestTimeoutInSeconds}){return new se({silentRequestTimeoutInSeconds:e})}async callback(e){this._logger.create("callback"),se.notifyParent(e,this._settings.iframeNotifyParentOrigin)}},Ze=500,et=1e3,ie=class extends ue{constructor({popupWindowTarget:e=pe,popupWindowFeatures:t={},popupSignal:s,popupAbortOnClose:i}){super(),this._logger=new g("PopupWindow");const r=ee.center({..._e,...t});this._window=window.open(void 0,e,ee.serialize(r)),this.abortOnClose=!!i,s&&s.addEventListener("abort",()=>{var o;this._abort.raise(new Error((o=s.reason)!=null?o:"Popup aborted"))}),t.closePopupWindowAfterInSeconds&&t.closePopupWindowAfterInSeconds>0&&setTimeout(()=>{if(!this._window||typeof this._window.closed!="boolean"||this._window.closed){this._abort.raise(new Error("Popup blocked by user"));return}this.close()},t.closePopupWindowAfterInSeconds*et)}async navigate(e){var t;(t=this._window)==null||t.focus();const s=setInterval(()=>{(!this._window||this._window.closed)&&(this._logger.debug("Popup closed by user or isolated by redirect"),i(),this._disposeHandlers.delete(i),this.abortOnClose&&this._abort.raise(new Error("Popup closed by user")))},Ze),i=()=>clearInterval(s);return this._disposeHandlers.add(i),await super.navigate(e)}close(){this._window&&(this._window.closed||(this._window.close(),this._abort.raise(new Error("Popup closed")))),this._window=null}static notifyOpener(e,t){super._notifyParent(window.opener,e,t),!t&&!window.opener&&window.close()}},tt=class{constructor(e){this._settings=e,this._logger=new g("PopupNavigator")}async prepare({popupWindowFeatures:e=this._settings.popupWindowFeatures,popupWindowTarget:t=this._settings.popupWindowTarget,popupSignal:s,popupAbortOnClose:i}){return new ie({popupWindowFeatures:e,popupWindowTarget:t,popupSignal:s,popupAbortOnClose:i})}async callback(e,{keepOpen:t=!1}){this._logger.create("callback"),ie.notifyOpener(e,t)}},st=class{constructor(e){this._settings=e,this._logger=new g("RedirectNavigator")}async prepare({redirectMethod:e=this._settings.redirectMethod,redirectTarget:t=this._settings.redirectTarget}){var s;this._logger.create("prepare");let i=window.self;t==="top"&&(i=(s=window.top)!=null?s:window.self);const r=i.location[e].bind(i.location);let o;return{navigate:async n=>(this._logger.create("navigate"),await new Promise((c,l)=>{o=l,window.addEventListener("pageshow",()=>c(window.location.href)),r(n.url)})),close:()=>{this._logger.create("close"),o==null||o(new Error("Redirect aborted")),i.stop()}}}async callback(){}},it=class extends Ue{constructor(e){super({expiringNotificationTimeInSeconds:e.accessTokenExpiringNotificationTimeInSeconds}),this._logger=new g("UserManagerEvents"),this._userLoaded=new P("User loaded"),this._userUnloaded=new P("User unloaded"),this._silentRenewError=new P("Silent renew error"),this._userSignedIn=new P("User signed in"),this._userSignedOut=new P("User signed out"),this._userSessionChanged=new P("User session changed")}async load(e,t=!0){await super.load(e),t&&await this._userLoaded.raise(e)}async unload(){await super.unload(),await this._userUnloaded.raise()}addUserLoaded(e){return this._userLoaded.addHandler(e)}removeUserLoaded(e){return this._userLoaded.removeHandler(e)}addUserUnloaded(e){return this._userUnloaded.addHandler(e)}removeUserUnloaded(e){return this._userUnloaded.removeHandler(e)}addSilentRenewError(e){return this._silentRenewError.addHandler(e)}removeSilentRenewError(e){return this._silentRenewError.removeHandler(e)}async _raiseSilentRenewError(e){await this._silentRenewError.raise(e)}addUserSignedIn(e){return this._userSignedIn.addHandler(e)}removeUserSignedIn(e){this._userSignedIn.removeHandler(e)}async _raiseUserSignedIn(){await this._userSignedIn.raise()}addUserSignedOut(e){return this._userSignedOut.addHandler(e)}removeUserSignedOut(e){this._userSignedOut.removeHandler(e)}async _raiseUserSignedOut(){await this._userSignedOut.raise()}addUserSessionChanged(e){return this._userSessionChanged.addHandler(e)}removeUserSessionChanged(e){this._userSessionChanged.removeHandler(e)}async _raiseUserSessionChanged(){await this._userSessionChanged.raise()}},rt=class{constructor(e){this._userManager=e,this._logger=new g("SilentRenewService"),this._isStarted=!1,this._retryTimer=new T("Retry Silent Renew"),this._timeoutRetryCount=0,this._tokenExpiring=async()=>{const t=this._logger.create("_tokenExpiring");try{await this._userManager.signinSilent(),this._timeoutRetryCount=0,t.debug("silent token renewal successful")}catch(s){if(s instanceof Q){this._timeoutRetryCount++;const i=this._userManager.settings.maxSilentRenewTimeoutRetries;if(i!==void 0&&this._timeoutRetryCount>i){t.error(`Timeout retry limit reached (${this._timeoutRetryCount} > ${i}), raising silentRenewError:`,s),this._timeoutRetryCount=0,await this._userManager.events._raiseSilentRenewError(s);return}t.warn(`ErrorTimeout from signinSilent (attempt ${this._timeoutRetryCount}), retry in 5s:`,s),this._retryTimer.init(5);return}t.error("Error from signinSilent:",s),this._timeoutRetryCount=0,await this._userManager.events._raiseSilentRenewError(s)}}}async start(){const e=this._logger.create("start");if(!this._isStarted){this._isStarted=!0,this._userManager.events.addAccessTokenExpiring(this._tokenExpiring),this._retryTimer.addHandler(this._tokenExpiring);try{await this._userManager.getUser()}catch(t){e.error("getUser error",t)}}}stop(){this._isStarted&&(this._retryTimer.cancel(),this._retryTimer.removeHandler(this._tokenExpiring),this._userManager.events.removeAccessTokenExpiring(this._tokenExpiring),this._isStarted=!1)}},nt=class{constructor(e){this.refresh_token=e.refresh_token,this.id_token=e.id_token,this.session_state=e.session_state,this.scope=e.scope,this.profile=e.profile,this.data=e.state}},ot=class{constructor(e,t,s,i){this._logger=new g("UserManager"),this.settings=new Xe(e),this._client=new Be(e),this._redirectNavigator=t??new st(this.settings),this._popupNavigator=s??new tt(this.settings),this._iframeNavigator=i??new Ye(this.settings),this._events=new it(this.settings),this._silentRenewService=new rt(this),this.settings.automaticSilentRenew&&this.startSilentRenew(),this._sessionMonitor=null,this.settings.monitorSession&&(this._sessionMonitor=new Ve(this))}get events(){return this._events}get metadataService(){return this._client.metadataService}async getUser(e=!1){const t=this._logger.create("getUser"),s=await this._loadUser();return s?(t.info("user loaded"),await this._events.load(s,e),s):(t.info("user not found in storage"),null)}async removeUser(){const e=this._logger.create("removeUser");await this.storeUser(null),e.info("user removed from storage"),await this._events.unload()}async signinRedirect(e={}){var t;this._logger.create("signinRedirect");const{redirectMethod:s,...i}=e;let r;(t=this.settings.dpop)!=null&&t.bind_authorization_code&&(r=await this.generateDPoPJkt(this.settings.dpop));const o=await this._redirectNavigator.prepare({redirectMethod:s});await this._signinStart({request_type:"si:r",dpopJkt:r,...i},o)}async signinRedirectCallback(e=window.location.href){const t=this._logger.create("signinRedirectCallback"),s=await this._signinEnd(e);return s.profile&&s.profile.sub?t.info("success, signed in subject",s.profile.sub):t.info("no subject"),s}async signinResourceOwnerCredentials({username:e,password:t,skipUserInfo:s=!1}){const i=this._logger.create("signinResourceOwnerCredential"),r=await this._client.processResourceOwnerPasswordCredentials({username:e,password:t,skipUserInfo:s,extraTokenParams:this.settings.extraTokenParams});i.debug("got signin response");const o=await this._buildUser(r);return o.profile&&o.profile.sub?i.info("success, signed in subject",o.profile.sub):i.info("no subject"),o}async signinPopup(e={}){var t;const s=this._logger.create("signinPopup");let i;(t=this.settings.dpop)!=null&&t.bind_authorization_code&&(i=await this.generateDPoPJkt(this.settings.dpop));const{popupWindowFeatures:r,popupWindowTarget:o,popupSignal:n,popupAbortOnClose:a,...c}=e,l=this.settings.popup_redirect_uri;l||s.throw(new Error("No popup_redirect_uri configured"));const h=await this._popupNavigator.prepare({popupWindowFeatures:r,popupWindowTarget:o,popupSignal:n,popupAbortOnClose:a}),d=await this._signin({request_type:"si:p",redirect_uri:l,display:"popup",dpopJkt:i,...c},h);return d&&(d.profile&&d.profile.sub?s.info("success, signed in subject",d.profile.sub):s.info("no subject")),d}async signinPopupCallback(e=window.location.href,t=!1){const s=this._logger.create("signinPopupCallback");await this._popupNavigator.callback(e,{keepOpen:t}),s.info("success")}async signinSilent(e={}){var t,s;const i=this._logger.create("signinSilent"),{silentRequestTimeoutInSeconds:r,...o}=e;let n=await this._loadUser();if(!e.forceIframeAuth&&(n!=null&&n.refresh_token)){i.debug("using refresh token");const d=new nt(n);return await this._useRefreshToken({state:d,redirect_uri:o.redirect_uri,resource:o.resource,extraTokenParams:o.extraTokenParams,timeoutInSeconds:r})}let a;(t=this.settings.dpop)!=null&&t.bind_authorization_code&&(a=await this.generateDPoPJkt(this.settings.dpop));const c=this.settings.silent_redirect_uri;c||i.throw(new Error("No silent_redirect_uri configured"));let l;n&&this.settings.validateSubOnSilentRenew&&(i.debug("subject prior to silent renew:",n.profile.sub),l=n.profile.sub);const h=await this._iframeNavigator.prepare({silentRequestTimeoutInSeconds:r});return n=await this._signin({request_type:"si:s",redirect_uri:c,prompt:"none",id_token_hint:this.settings.includeIdTokenInSilentRenew?n==null?void 0:n.id_token:void 0,dpopJkt:a,...o},h,l),n&&((s=n.profile)!=null&&s.sub?i.info("success, signed in subject",n.profile.sub):i.info("no subject")),n}async _useRefreshToken(e){const t=await this._client.useRefreshToken({timeoutInSeconds:this.settings.silentRequestTimeoutInSeconds,...e}),s=new K({...e.state,...t});return await this.storeUser(s),await this._events.load(s),s}async signinSilentCallback(e=window.location.href){const t=this._logger.create("signinSilentCallback");await this._iframeNavigator.callback(e),t.info("success")}async signinCallback(e=window.location.href){const{state:t}=await this._client.readSigninResponseState(e);switch(t.request_type){case"si:r":return await this.signinRedirectCallback(e);case"si:p":await this.signinPopupCallback(e);break;case"si:s":await this.signinSilentCallback(e);break;default:throw new Error("invalid request_type in state")}}async signoutCallback(e=window.location.href,t=!1){const{state:s}=await this._client.readSignoutResponseState(e);if(s)switch(s.request_type){case"so:r":return await this.signoutRedirectCallback(e);case"so:p":await this.signoutPopupCallback(e,t);break;case"so:s":await this.signoutSilentCallback(e);break;default:throw new Error("invalid request_type in state")}}async querySessionStatus(e={}){const t=this._logger.create("querySessionStatus"),{silentRequestTimeoutInSeconds:s,...i}=e,r=this.settings.silent_redirect_uri;r||t.throw(new Error("No silent_redirect_uri configured"));const o=await this._loadUser(),n=await this._iframeNavigator.prepare({silentRequestTimeoutInSeconds:s}),a=await this._signinStart({request_type:"si:s",redirect_uri:r,prompt:"none",id_token_hint:this.settings.includeIdTokenInSilentRenew?o==null?void 0:o.id_token:void 0,response_type:this.settings.query_status_response_type,scope:"openid",skipUserInfo:!0,...i},n);try{const c={},l=await this._client.processSigninResponse(a.url,c);return t.debug("got signin response"),l.session_state&&l.profile.sub?(t.info("success for subject",l.profile.sub),{session_state:l.session_state,sub:l.profile.sub}):(t.info("success, user not authenticated"),null)}catch(c){if(this.settings.monitorAnonymousSession&&c instanceof N)switch(c.error){case"login_required":case"consent_required":case"interaction_required":case"account_selection_required":return t.info("success for anonymous user"),{session_state:c.session_state}}throw c}}async _signin(e,t,s){const i=await this._signinStart(e,t);return await this._signinEnd(i.url,s)}async _signinStart(e,t){const s=this._logger.create("_signinStart");try{const i=await this._client.createSigninRequest(e);return s.debug("got signin request"),await t.navigate({url:i.url,state:i.state.id,response_mode:i.state.response_mode,scriptOrigin:this.settings.iframeScriptOrigin})}catch(i){throw s.debug("error after preparing navigator, closing navigator window"),t.close(),i}}async _signinEnd(e,t){const s=this._logger.create("_signinEnd"),i={},r=await this._client.processSigninResponse(e,i);return s.debug("got signin response"),await this._buildUser(r,t)}async _buildUser(e,t){const s=this._logger.create("_buildUser"),i=new K(e);if(t){if(t!==i.profile.sub)throw s.debug("current user does not match user returned from signin. sub from signin:",i.profile.sub),new N({...e,error:"login_required"});s.debug("current user matches user returned from signin")}return await this.storeUser(i),s.debug("user stored"),await this._events.load(i),i}async signoutRedirect(e={}){const t=this._logger.create("signoutRedirect"),{redirectMethod:s,...i}=e,r=await this._redirectNavigator.prepare({redirectMethod:s});await this._signoutStart({request_type:"so:r",post_logout_redirect_uri:this.settings.post_logout_redirect_uri,...i},r),t.info("success")}async signoutRedirectCallback(e=window.location.href){const t=this._logger.create("signoutRedirectCallback"),s=await this._signoutEnd(e);return t.info("success"),s}async signoutPopup(e={}){const t=this._logger.create("signoutPopup"),{popupWindowFeatures:s,popupWindowTarget:i,popupSignal:r,...o}=e,n=this.settings.popup_post_logout_redirect_uri,a=await this._popupNavigator.prepare({popupWindowFeatures:s,popupWindowTarget:i,popupSignal:r});await this._signout({request_type:"so:p",post_logout_redirect_uri:n,state:n==null?void 0:{},...o},a),t.info("success")}async signoutPopupCallback(e=window.location.href,t=!1){const s=this._logger.create("signoutPopupCallback");await this._popupNavigator.callback(e,{keepOpen:t}),s.info("success")}async _signout(e,t){const s=await this._signoutStart(e,t);return await this._signoutEnd(s.url)}async _signoutStart(e={},t){var s;const i=this._logger.create("_signoutStart");try{const r=await this._loadUser();i.debug("loaded current user from storage"),this.settings.revokeTokensOnSignout&&await this._revokeInternal(r);const o=e.id_token_hint||r&&r.id_token;o&&(i.debug("setting id_token_hint in signout request"),e.id_token_hint=o),await this.removeUser(),i.debug("user removed, creating signout request");const n=await this._client.createSignoutRequest(e);return i.debug("got signout request"),await t.navigate({url:n.url,state:(s=n.state)==null?void 0:s.id,scriptOrigin:this.settings.iframeScriptOrigin})}catch(r){throw i.debug("error after preparing navigator, closing navigator window"),t.close(),r}}async _signoutEnd(e){const t=this._logger.create("_signoutEnd"),s=await this._client.processSignoutResponse(e);return t.debug("got signout response"),s}async signoutSilent(e={}){var t;const s=this._logger.create("signoutSilent"),{silentRequestTimeoutInSeconds:i,...r}=e,o=this.settings.includeIdTokenInSilentSignout?(t=await this._loadUser())==null?void 0:t.id_token:void 0,n=this.settings.popup_post_logout_redirect_uri,a=await this._iframeNavigator.prepare({silentRequestTimeoutInSeconds:i});await this._signout({request_type:"so:s",post_logout_redirect_uri:n,id_token_hint:o,...r},a),s.info("success")}async signoutSilentCallback(e=window.location.href){const t=this._logger.create("signoutSilentCallback");await this._iframeNavigator.callback(e),t.info("success")}async revokeTokens(e){const t=await this._loadUser();await this._revokeInternal(t,e)}async _revokeInternal(e,t=this.settings.revokeTokenTypes){const s=this._logger.create("_revokeInternal");if(!e)return;const i=t.filter(r=>typeof e[r]=="string");if(!i.length){s.debug("no need to revoke due to no token(s)");return}for(const r of i)await this._client.revokeToken(e[r],r),s.info(`${r} revoked successfully`),r!=="access_token"&&(e[r]=null);await this.storeUser(e),s.debug("user stored"),await this._events.load(e)}startSilentRenew(){this._logger.create("startSilentRenew"),this._silentRenewService.start()}stopSilentRenew(){this._silentRenewService.stop()}get _userStoreKey(){return`user:${this.settings.authority}:${this.settings.client_id}`}async _loadUser(){const e=this._logger.create("_loadUser"),t=await this.settings.userStore.get(this._userStoreKey);return t?(e.debug("user storageString loaded"),K.fromStorageString(t)):(e.debug("no user storageString"),null)}async storeUser(e){const t=this._logger.create("storeUser");if(e){t.debug("storing user");const s=e.toStorageString();await this.settings.userStore.set(this._userStoreKey,s)}else this._logger.debug("removing user"),await this.settings.userStore.remove(this._userStoreKey),this.settings.dpop&&await this.settings.dpop.store.remove(this.settings.client_id)}async clearStaleState(){await this._client.clearStaleState()}async dpopProof(e,t,s,i){var r,o;const n=await((o=(r=this.settings.dpop)==null?void 0:r.store)==null?void 0:o.get(this.settings.client_id));if(n)return await _.generateDPoPProof({url:e,accessToken:t==null?void 0:t.access_token,httpMethod:s,keyPair:n.keys,nonce:i})}async generateDPoPJkt(e){let t=await e.store.get(this.settings.client_id);if(!t){const s=await _.generateDPoPKeys();t=new he(s),await e.store.set(this.settings.client_id,t)}return await _.generateDPoPJkt(t.keys)}};export{D as L,ot as U};
|
package/dist/index.html
CHANGED
|
@@ -84,13 +84,13 @@
|
|
|
84
84
|
}
|
|
85
85
|
})();
|
|
86
86
|
</script>
|
|
87
|
-
<script type="module" crossorigin src="/benefits/app/assets/index-
|
|
87
|
+
<script type="module" crossorigin src="/benefits/app/assets/index-41898db5.js"></script>
|
|
88
88
|
<link rel="modulepreload" crossorigin href="/benefits/app/assets/lodash-5d893f8c.js">
|
|
89
89
|
<link rel="modulepreload" crossorigin href="/benefits/app/assets/vendor-a6810c59.js">
|
|
90
|
-
<link rel="modulepreload" crossorigin href="/benefits/app/assets/oidc-client-
|
|
90
|
+
<link rel="modulepreload" crossorigin href="/benefits/app/assets/oidc-client-3a9688bc.js">
|
|
91
91
|
<link rel="modulepreload" crossorigin href="/benefits/app/assets/date-fns-74ba04b6.js">
|
|
92
92
|
<link rel="modulepreload" crossorigin href="/benefits/app/assets/framer-motion-44d211db.js">
|
|
93
|
-
<link rel="modulepreload" crossorigin href="/benefits/app/assets/datadog-
|
|
93
|
+
<link rel="modulepreload" crossorigin href="/benefits/app/assets/datadog-261280ed.js">
|
|
94
94
|
<link rel="stylesheet" href="/benefits/app/assets/index-dff3b0d2.css">
|
|
95
95
|
</head>
|
|
96
96
|
<body>
|