{ "version": 3, "sources": ["libs/mediio-plattform/auth/core/active-organization/data-access/src/lib/services/active-organization.service.ts"], "sourcesContent": ["import { Injectable, Signal, WritableSignal, signal } from '@angular/core';\r\n\r\nconst activeOrganizationStorageKey = 'activeOrganizationId';\r\n\r\n@Injectable({ providedIn: 'root' })\r\nexport class ActiveOrganizationService {\r\n private readonly _activeOrganizationId: WritableSignal = signal(\r\n localStorage.getItem(activeOrganizationStorageKey) ?? sessionStorage.getItem(activeOrganizationStorageKey),\r\n );\r\n\r\n /**\r\n * Returns the id of the active organization.\r\n */\r\n readonly activeOrganizationId: Signal = this._activeOrganizationId.asReadonly();\r\n\r\n /**\r\n * Returns whether the active organization is remembered between logins.\r\n */\r\n get isActiveOrganizationRemembered(): boolean {\r\n return localStorage.getItem(activeOrganizationStorageKey) != null;\r\n }\r\n\r\n /**\r\n * Sets the active organization id.\r\n * @param activeOrganizationId The new active organization id.\r\n * @param remember If `true` the active organization id is preserved during logins.\r\n * @param referrer The URL to navigate to.\r\n */\r\n setActiveOrganizationId(activeOrganizationId: string, remember?: boolean, referrer?: string): void {\r\n remember ??= this.isActiveOrganizationRemembered;\r\n\r\n const [writeStorage, removeStorage] = remember ? [localStorage, sessionStorage] : [sessionStorage, localStorage];\r\n\r\n this._activeOrganizationId.set(activeOrganizationId);\r\n\r\n writeStorage.setItem(activeOrganizationStorageKey, activeOrganizationId);\r\n removeStorage.removeItem(activeOrganizationStorageKey);\r\n\r\n if (referrer) {\r\n self.location.assign(referrer);\r\n }\r\n }\r\n\r\n /**\r\n * Resets the active organization id on logout if it is not remembered.\r\n */\r\n resetActiveOrganizationIdOnLogout(): void {\r\n sessionStorage.removeItem(activeOrganizationStorageKey);\r\n }\r\n}\r\n"], "mappings": "iDAEA,IAAMA,EAA+B,uBAGxBC,GAAyB,IAAA,CAAhC,MAAOA,CAAyB,CADtCC,aAAA,CAEmB,KAAAC,sBAAuDC,EACtEC,aAAaC,QAAQN,CAA4B,GAAKO,eAAeD,QAAQN,CAA4B,CAAC,EAMnG,KAAAQ,qBAA8C,KAAKL,sBAAsBM,WAAU,EAK5F,IAAIC,gCAA8B,CAChC,OAAOL,aAAaC,QAAQN,CAA4B,GAAK,IAC/D,CAQAW,wBAAwBH,EAA8BI,EAAoBC,EAAiB,CACzFD,IAAa,KAAKF,+BAElB,GAAM,CAACI,EAAcC,CAAa,EAAIH,EAAW,CAACP,aAAcE,cAAc,EAAI,CAACA,eAAgBF,YAAY,EAE/G,KAAKF,sBAAsBa,IAAIR,CAAoB,EAEnDM,EAAaG,QAAQjB,EAA8BQ,CAAoB,EACvEO,EAAcG,WAAWlB,CAA4B,EAEjDa,GACFM,KAAKC,SAASC,OAAOR,CAAQ,CAEjC,CAKAS,mCAAiC,CAC/Bf,eAAeW,WAAWlB,CAA4B,CACxD,iDA3CWC,EAAyB,CAAA,iCAAzBA,EAAyBsB,QAAzBtB,EAAyBuB,UAAAC,WADZ,MAAM,CAAA,CAAA,SACnBxB,CAAyB,GAAA", "names": ["activeOrganizationStorageKey", "ActiveOrganizationService", "constructor", "_activeOrganizationId", "signal", "localStorage", "getItem", "sessionStorage", "activeOrganizationId", "asReadonly", "isActiveOrganizationRemembered", "setActiveOrganizationId", "remember", "referrer", "writeStorage", "removeStorage", "set", "setItem", "removeItem", "self", "location", "assign", "resetActiveOrganizationIdOnLogout", "factory", "\u0275fac", "providedIn"] }