!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("openstack-uicore-foundation",[],t):"object"==typeof exports?exports["openstack-uicore-foundation"]=t():e["openstack-uicore-foundation"]=t()}(this,(()=>(()=>{"use strict";var e={5097:(e,t,r)=>{r.d(t,{CLEAR_SESSION_STATE:()=>a,LOGOUT_USER:()=>n,RECEIVE_USER_INFO:()=>s,SESSION_STATE_STATUS_UNCHANGED:()=>u,SET_LOGGED_USER:()=>o,UPDATE_SESSION_STATE_STATUS:()=>i,UPDATE_USER_INFO:()=>l});r(1116),r(6842),r(9087),r(9558),r(2183);const o="SET_LOGGED_USER",n="LOGOUT_USER",s="RECEIVE_USER_INFO",a="CLEAR_SESSION_STATE",i="UPDATE_SESSION_STATE_STATUS",u="unchanged",l="UPDATE_USER_INFO"},2183:(e,t,r)=>{r.d(t,{clearAuthInfo:()=>c,getIdToken:()=>S,getOAuth2ClientId:()=>p,getOAuth2IDPBaseUrl:()=>E});var o=r(9558);r(5812),r(806);const n=require("browser-tabs-lock");var s=r.n(n);const a=require("js-cookie");var i=r.n(a);r(8041),r(9891),r(5097),r(8853);new(s());const u="authInfo",l="idToken",d=()=>{try{let e=(0,o.getFromLocalStorage)(u,!1);return e?JSON.parse(e):null}catch(e){return null}},c=()=>{"undefined"!=typeof window&&((0,o.removeFromLocalStorage)(u),i().remove(l))},S=()=>{if("undefined"!=typeof window){const e=d();return e?e.idToken:null}return null},p=()=>"undefined"!=typeof window?window.OAUTH2_CLIENT_ID:null,E=()=>"undefined"!=typeof window?window.IDP_BASE_URL:null},9087:(e,t,r)=>{r(2462),r(806),r(8041),r(9236),r(6842),r(9558),r(5097),r(2183);const o=e=>t=>({type:e,payload:t});o("RESET_LOADING"),o("START_LOADING"),o("STOP_LOADING")},8853:()=>{require("spark-md5"),require("crypto-js/sha256"),require("crypto-js/enc-base64url"),require("crypto-js/enc-hex"),"undefined"!=typeof window&&(window.crypto||window.msCrypto)},9558:(e,t,r)=>{r.d(t,{getFromLocalStorage:()=>o,removeFromLocalStorage:()=>n});r(5812),r(8041);const o=(e,t)=>{if("undefined"!=typeof window){let r=window.localStorage.getItem(e);return t&&(console.log(`getFromLocalStorage removing key ${e}`),n(e)),r}return null},n=e=>{"undefined"!=typeof window&&window.localStorage.removeItem(e)}},1116:e=>{e.exports=require("@babel/runtime/helpers/defineProperty")},2462:e=>{e.exports=require("@babel/runtime/helpers/objectWithoutProperties")},6842:e=>{e.exports=require("i18n-react/dist/i18n-react")},9891:e=>{e.exports=require("idtoken-verifier")},5812:e=>{e.exports=require("moment-timezone")},806:e=>{e.exports=require("superagent/lib/client")},9236:e=>{e.exports=require("sweetalert2")},8041:e=>{e.exports=require("urijs")}},t={};function r(o){var n=t[o];if(void 0!==n)return n.exports;var s=t[o]={exports:{}};return e[o](s,s.exports,r),s.exports}(()=>{r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t}})(),(()=>{r.d=(e,t)=>{for(var o in t)r.o(t,o)&&!r.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})}})(),(()=>{r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t)})(),(()=>{r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}})();var o={};r.r(o),r.d(o,{loggedUserReducer:()=>p});var n=r(1116),s=r.n(n),a=r(5097),i=r(9891),u=r.n(i),l=r(2183);function d(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,o)}return r}function c(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?d(Object(r),!0).forEach((function(t){s()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):d(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}const S={isLoggedUser:!1,member:null,sessionState:null,backUrl:null,sessionStateStatus:a.SESSION_STATE_STATUS_UNCHANGED},p=(e=S,t)=>{const{type:r,payload:o}=t;let n=(0,l.getOAuth2IDPBaseUrl)(),s=(0,l.getOAuth2ClientId)();switch(r){case a.SET_LOGGED_USER:{let{sessionState:r}=t.payload;return c(c({},e),{},{isLoggedUser:!0,sessionState:r,backUrl:null,sessionStateStatus:a.SESSION_STATE_STATUS_UNCHANGED})}case a.UPDATE_SESSION_STATE_STATUS:{let{sessionStateStatus:r}=t.payload;return c(c({},e),{},{sessionStateStatus:r})}case a.CLEAR_SESSION_STATE:return(0,l.clearAuthInfo)(),c(c({},e),{},{isLoggedUser:!1,sessionState:null,backUrl:null});case a.LOGOUT_USER:return(0,l.clearAuthInfo)(),c(c({},S),{},{backUrl:o.backUrl});case a.RECEIVE_USER_INFO:{let{response:r}=t.payload;if(""!==n&&""!==s){let e=new(u())({issuer:n,audience:s}).decode((0,l.getIdToken)()),t=e.payload.groups||[],o=e.payload.address||{};t=t.map((e=>({id:e.id,title:e.name,description:e.name,code:e.slug,created:e.created_at,last_edited:e.updated_at}))),r=c(c({},r),{},{groups:[...r.groups,...t],address:o})}return c(c({},e),{},{member:r})}case a.UPDATE_USER_INFO:{let r=t.payload;return c(c({},e),{},{member:r})}default:return e}};return o})()));
//# sourceMappingURL=reducers.js.map