@jmruthers/pace-core 0.5.77 → 0.5.78

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.
Files changed (141) hide show
  1. package/dist/{AuthService-SBHZQtCH.d.ts → AuthService-Df3IozMG.d.ts} +5 -0
  2. package/dist/{DataTable-QCNCV6IK.js → DataTable-ETGVF4Y5.js} +6 -6
  3. package/dist/{UnifiedAuthProvider-Z2FWNW7O.js → UnifiedAuthProvider-P5SOJAQ6.js} +3 -3
  4. package/dist/{chunk-7PX43UYN.js → chunk-2OGV6IRV.js} +5 -5
  5. package/dist/{chunk-TLD5BEU6.js → chunk-5BO3MI5Y.js} +3 -3
  6. package/dist/{chunk-DVHZ5L55.js → chunk-FL4ZCQLD.js} +2 -2
  7. package/dist/{chunk-CRKP3HXI.js → chunk-FT2M4R4F.js} +2 -2
  8. package/dist/{chunk-PUKTJMRT.js → chunk-LRQ6RBJC.js} +3 -3
  9. package/dist/{chunk-JDQ7T3QB.js → chunk-MNJXXD6C.js} +19 -1
  10. package/dist/chunk-MNJXXD6C.js.map +1 -0
  11. package/dist/{chunk-LMYTEMUH.js → chunk-PTR5PMPE.js} +4 -4
  12. package/dist/{chunk-Z3T6RK3K.js → chunk-QGVSOUJ2.js} +2 -2
  13. package/dist/{chunk-NKT2DLZI.js → chunk-VSOKOFRF.js} +4 -4
  14. package/dist/{chunk-C4RQ3GQA.js → chunk-YVVGHRGI.js} +7 -7
  15. package/dist/{chunk-DDPG7FCX.js → chunk-ZMNXIJP4.js} +4 -4
  16. package/dist/components.js +8 -8
  17. package/dist/hooks.js +7 -7
  18. package/dist/index.d.ts +2 -2
  19. package/dist/index.js +11 -11
  20. package/dist/providers.d.ts +2 -2
  21. package/dist/providers.js +2 -2
  22. package/dist/rbac/index.js +7 -7
  23. package/dist/utils.js +1 -1
  24. package/docs/api/classes/ColumnFactory.md +1 -1
  25. package/docs/api/classes/ErrorBoundary.md +1 -1
  26. package/docs/api/classes/InvalidScopeError.md +1 -1
  27. package/docs/api/classes/MissingUserContextError.md +1 -1
  28. package/docs/api/classes/OrganisationContextRequiredError.md +1 -1
  29. package/docs/api/classes/PermissionDeniedError.md +1 -1
  30. package/docs/api/classes/PublicErrorBoundary.md +1 -1
  31. package/docs/api/classes/RBACAuditManager.md +1 -1
  32. package/docs/api/classes/RBACCache.md +1 -1
  33. package/docs/api/classes/RBACEngine.md +1 -1
  34. package/docs/api/classes/RBACError.md +1 -1
  35. package/docs/api/classes/RBACNotInitializedError.md +1 -1
  36. package/docs/api/classes/SecureSupabaseClient.md +1 -1
  37. package/docs/api/classes/StorageUtils.md +1 -1
  38. package/docs/api/enums/FileCategory.md +1 -1
  39. package/docs/api/interfaces/AggregateConfig.md +1 -1
  40. package/docs/api/interfaces/ButtonProps.md +1 -1
  41. package/docs/api/interfaces/CardProps.md +1 -1
  42. package/docs/api/interfaces/ColorPalette.md +1 -1
  43. package/docs/api/interfaces/ColorShade.md +1 -1
  44. package/docs/api/interfaces/DataAccessRecord.md +1 -1
  45. package/docs/api/interfaces/DataRecord.md +1 -1
  46. package/docs/api/interfaces/DataTableAction.md +1 -1
  47. package/docs/api/interfaces/DataTableColumn.md +1 -1
  48. package/docs/api/interfaces/DataTableProps.md +1 -1
  49. package/docs/api/interfaces/DataTableToolbarButton.md +1 -1
  50. package/docs/api/interfaces/EmptyStateConfig.md +1 -1
  51. package/docs/api/interfaces/EnhancedNavigationMenuProps.md +1 -1
  52. package/docs/api/interfaces/EventLogoProps.md +1 -1
  53. package/docs/api/interfaces/FileDisplayProps.md +1 -1
  54. package/docs/api/interfaces/FileMetadata.md +1 -1
  55. package/docs/api/interfaces/FileReference.md +1 -1
  56. package/docs/api/interfaces/FileSizeLimits.md +1 -1
  57. package/docs/api/interfaces/FileUploadOptions.md +1 -1
  58. package/docs/api/interfaces/FileUploadProps.md +1 -1
  59. package/docs/api/interfaces/FooterProps.md +1 -1
  60. package/docs/api/interfaces/InactivityWarningModalProps.md +1 -1
  61. package/docs/api/interfaces/InputProps.md +1 -1
  62. package/docs/api/interfaces/LabelProps.md +1 -1
  63. package/docs/api/interfaces/LoginFormProps.md +1 -1
  64. package/docs/api/interfaces/NavigationAccessRecord.md +1 -1
  65. package/docs/api/interfaces/NavigationContextType.md +1 -1
  66. package/docs/api/interfaces/NavigationGuardProps.md +1 -1
  67. package/docs/api/interfaces/NavigationItem.md +1 -1
  68. package/docs/api/interfaces/NavigationMenuProps.md +1 -1
  69. package/docs/api/interfaces/NavigationProviderProps.md +1 -1
  70. package/docs/api/interfaces/Organisation.md +1 -1
  71. package/docs/api/interfaces/OrganisationContextType.md +1 -1
  72. package/docs/api/interfaces/OrganisationMembership.md +1 -1
  73. package/docs/api/interfaces/OrganisationProviderProps.md +1 -1
  74. package/docs/api/interfaces/OrganisationSecurityError.md +1 -1
  75. package/docs/api/interfaces/PaceAppLayoutProps.md +1 -1
  76. package/docs/api/interfaces/PaceLoginPageProps.md +1 -1
  77. package/docs/api/interfaces/PageAccessRecord.md +1 -1
  78. package/docs/api/interfaces/PagePermissionContextType.md +1 -1
  79. package/docs/api/interfaces/PagePermissionGuardProps.md +1 -1
  80. package/docs/api/interfaces/PagePermissionProviderProps.md +1 -1
  81. package/docs/api/interfaces/PaletteData.md +1 -1
  82. package/docs/api/interfaces/PermissionEnforcerProps.md +1 -1
  83. package/docs/api/interfaces/PublicErrorBoundaryProps.md +1 -1
  84. package/docs/api/interfaces/PublicErrorBoundaryState.md +1 -1
  85. package/docs/api/interfaces/PublicLoadingSpinnerProps.md +1 -1
  86. package/docs/api/interfaces/PublicPageFooterProps.md +1 -1
  87. package/docs/api/interfaces/PublicPageHeaderProps.md +1 -1
  88. package/docs/api/interfaces/PublicPageLayoutProps.md +1 -1
  89. package/docs/api/interfaces/RBACConfig.md +1 -1
  90. package/docs/api/interfaces/RBACLogger.md +1 -1
  91. package/docs/api/interfaces/RoleBasedRouterContextType.md +1 -1
  92. package/docs/api/interfaces/RoleBasedRouterProps.md +1 -1
  93. package/docs/api/interfaces/RouteAccessRecord.md +1 -1
  94. package/docs/api/interfaces/RouteConfig.md +1 -1
  95. package/docs/api/interfaces/SecureDataContextType.md +1 -1
  96. package/docs/api/interfaces/SecureDataProviderProps.md +1 -1
  97. package/docs/api/interfaces/StorageConfig.md +1 -1
  98. package/docs/api/interfaces/StorageFileInfo.md +1 -1
  99. package/docs/api/interfaces/StorageFileMetadata.md +1 -1
  100. package/docs/api/interfaces/StorageListOptions.md +1 -1
  101. package/docs/api/interfaces/StorageListResult.md +1 -1
  102. package/docs/api/interfaces/StorageUploadOptions.md +1 -1
  103. package/docs/api/interfaces/StorageUploadResult.md +1 -1
  104. package/docs/api/interfaces/StorageUrlOptions.md +1 -1
  105. package/docs/api/interfaces/StyleImport.md +1 -1
  106. package/docs/api/interfaces/SwitchProps.md +1 -1
  107. package/docs/api/interfaces/ToastActionElement.md +1 -1
  108. package/docs/api/interfaces/ToastProps.md +1 -1
  109. package/docs/api/interfaces/UnifiedAuthContextType.md +1 -1
  110. package/docs/api/interfaces/UnifiedAuthProviderProps.md +1 -1
  111. package/docs/api/interfaces/UseInactivityTrackerOptions.md +1 -1
  112. package/docs/api/interfaces/UseInactivityTrackerReturn.md +1 -1
  113. package/docs/api/interfaces/UsePublicEventLogoOptions.md +1 -1
  114. package/docs/api/interfaces/UsePublicEventLogoReturn.md +1 -1
  115. package/docs/api/interfaces/UsePublicEventOptions.md +1 -1
  116. package/docs/api/interfaces/UsePublicEventReturn.md +1 -1
  117. package/docs/api/interfaces/UsePublicRouteParamsReturn.md +1 -1
  118. package/docs/api/interfaces/UseResolvedScopeOptions.md +1 -1
  119. package/docs/api/interfaces/UseResolvedScopeReturn.md +1 -1
  120. package/docs/api/interfaces/UserEventAccess.md +1 -1
  121. package/docs/api/interfaces/UserMenuProps.md +1 -1
  122. package/docs/api/interfaces/UserProfile.md +1 -1
  123. package/docs/api/modules.md +2 -2
  124. package/docs/core-concepts/rbac-system.md +2 -0
  125. package/docs/rbac/quick-start.md +64 -13
  126. package/package.json +1 -1
  127. package/src/services/EventService.ts +17 -0
  128. package/src/services/base/BaseService.ts +8 -0
  129. package/dist/chunk-JDQ7T3QB.js.map +0 -1
  130. /package/dist/{DataTable-QCNCV6IK.js.map → DataTable-ETGVF4Y5.js.map} +0 -0
  131. /package/dist/{UnifiedAuthProvider-Z2FWNW7O.js.map → UnifiedAuthProvider-P5SOJAQ6.js.map} +0 -0
  132. /package/dist/{chunk-7PX43UYN.js.map → chunk-2OGV6IRV.js.map} +0 -0
  133. /package/dist/{chunk-TLD5BEU6.js.map → chunk-5BO3MI5Y.js.map} +0 -0
  134. /package/dist/{chunk-DVHZ5L55.js.map → chunk-FL4ZCQLD.js.map} +0 -0
  135. /package/dist/{chunk-CRKP3HXI.js.map → chunk-FT2M4R4F.js.map} +0 -0
  136. /package/dist/{chunk-PUKTJMRT.js.map → chunk-LRQ6RBJC.js.map} +0 -0
  137. /package/dist/{chunk-LMYTEMUH.js.map → chunk-PTR5PMPE.js.map} +0 -0
  138. /package/dist/{chunk-Z3T6RK3K.js.map → chunk-QGVSOUJ2.js.map} +0 -0
  139. /package/dist/{chunk-NKT2DLZI.js.map → chunk-VSOKOFRF.js.map} +0 -0
  140. /package/dist/{chunk-C4RQ3GQA.js.map → chunk-YVVGHRGI.js.map} +0 -0
  141. /package/dist/{chunk-DDPG7FCX.js.map → chunk-ZMNXIJP4.js.map} +0 -0
@@ -42,6 +42,11 @@ declare abstract class BaseService {
42
42
  * Check if service is initialized
43
43
  */
44
44
  protected getInitialized(): boolean;
45
+ /**
46
+ * Reset initialization state (allows re-initialization)
47
+ * Use when dependencies change and service needs to re-initialize
48
+ */
49
+ protected resetInitialization(): void;
45
50
  /**
46
51
  * Override in subclasses to implement initialization logic
47
52
  */
@@ -53,8 +53,8 @@ import {
53
53
  sortHierarchicalDataWithSorting,
54
54
  validateHierarchicalData,
55
55
  validatePaginationConfig
56
- } from "./chunk-DDPG7FCX.js";
57
- import "./chunk-PUKTJMRT.js";
56
+ } from "./chunk-ZMNXIJP4.js";
57
+ import "./chunk-LRQ6RBJC.js";
58
58
  import "./chunk-S63MFSY6.js";
59
59
  import "./chunk-Q7APDV6H.js";
60
60
  import {
@@ -75,9 +75,9 @@ import {
75
75
  throttle,
76
76
  useDataTablePerformance
77
77
  } from "./chunk-YCKPEMJA.js";
78
- import "./chunk-CRKP3HXI.js";
79
- import "./chunk-DVHZ5L55.js";
80
- import "./chunk-JDQ7T3QB.js";
78
+ import "./chunk-FT2M4R4F.js";
79
+ import "./chunk-FL4ZCQLD.js";
80
+ import "./chunk-MNJXXD6C.js";
81
81
  import "./chunk-PYUXFQJ3.js";
82
82
  import "./chunk-JCQZ6LA7.js";
83
83
  import "./chunk-CVMVPYAL.js";
@@ -154,4 +154,4 @@ export {
154
154
  validateHierarchicalData,
155
155
  validatePaginationConfig
156
156
  };
157
- //# sourceMappingURL=DataTable-QCNCV6IK.js.map
157
+ //# sourceMappingURL=DataTable-ETGVF4Y5.js.map
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  init_UnifiedAuthProvider
3
- } from "./chunk-DVHZ5L55.js";
3
+ } from "./chunk-FL4ZCQLD.js";
4
4
  import {
5
5
  UnifiedAuthProvider,
6
6
  useUnifiedAuth
7
- } from "./chunk-JDQ7T3QB.js";
7
+ } from "./chunk-MNJXXD6C.js";
8
8
  import "./chunk-CVMVPYAL.js";
9
9
  import "./chunk-PLDDJCW6.js";
10
10
  init_UnifiedAuthProvider();
@@ -12,4 +12,4 @@ export {
12
12
  UnifiedAuthProvider,
13
13
  useUnifiedAuth
14
14
  };
15
- //# sourceMappingURL=UnifiedAuthProvider-Z2FWNW7O.js.map
15
+ //# sourceMappingURL=UnifiedAuthProvider-P5SOJAQ6.js.map
@@ -2,7 +2,7 @@ import {
2
2
  createScopeFromEvent,
3
3
  useAccessLevel,
4
4
  useCan
5
- } from "./chunk-PUKTJMRT.js";
5
+ } from "./chunk-LRQ6RBJC.js";
6
6
  import {
7
7
  OrganisationContextRequiredError,
8
8
  RBACCache,
@@ -11,13 +11,13 @@ import {
11
11
  } from "./chunk-S63MFSY6.js";
12
12
  import {
13
13
  useSecureDataAccess
14
- } from "./chunk-TLD5BEU6.js";
14
+ } from "./chunk-5BO3MI5Y.js";
15
15
  import {
16
16
  init_UnifiedAuthProvider
17
- } from "./chunk-DVHZ5L55.js";
17
+ } from "./chunk-FL4ZCQLD.js";
18
18
  import {
19
19
  useUnifiedAuth
20
- } from "./chunk-JDQ7T3QB.js";
20
+ } from "./chunk-MNJXXD6C.js";
21
21
  import {
22
22
  getCurrentAppName
23
23
  } from "./chunk-JCQZ6LA7.js";
@@ -1860,4 +1860,4 @@ export {
1860
1860
  getPermissionsForRole,
1861
1861
  ALL_PERMISSIONS
1862
1862
  };
1863
- //# sourceMappingURL=chunk-7PX43UYN.js.map
1863
+ //# sourceMappingURL=chunk-2OGV6IRV.js.map
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  init_useOrganisations,
3
3
  useOrganisations
4
- } from "./chunk-CRKP3HXI.js";
4
+ } from "./chunk-FT2M4R4F.js";
5
5
  import {
6
6
  useUnifiedAuth
7
- } from "./chunk-JDQ7T3QB.js";
7
+ } from "./chunk-MNJXXD6C.js";
8
8
  import {
9
9
  init_organisationContext,
10
10
  setOrganisationContext
@@ -380,4 +380,4 @@ function useSecureDataAccess() {
380
380
  export {
381
381
  useSecureDataAccess
382
382
  };
383
- //# sourceMappingURL=chunk-TLD5BEU6.js.map
383
+ //# sourceMappingURL=chunk-5BO3MI5Y.js.map
@@ -2,7 +2,7 @@ import {
2
2
  UnifiedAuthProvider,
3
3
  init_UnifiedAuthProvider,
4
4
  useUnifiedAuth
5
- } from "./chunk-JDQ7T3QB.js";
5
+ } from "./chunk-MNJXXD6C.js";
6
6
  import {
7
7
  __esm,
8
8
  __export
@@ -24,4 +24,4 @@ export {
24
24
  UnifiedAuthProvider_exports,
25
25
  init_UnifiedAuthProvider2 as init_UnifiedAuthProvider
26
26
  };
27
- //# sourceMappingURL=chunk-DVHZ5L55.js.map
27
+ //# sourceMappingURL=chunk-FL4ZCQLD.js.map
@@ -3,7 +3,7 @@ import {
3
3
  init_useOrganisationService,
4
4
  useEventService2 as useEventService,
5
5
  useOrganisationService2 as useOrganisationService
6
- } from "./chunk-JDQ7T3QB.js";
6
+ } from "./chunk-MNJXXD6C.js";
7
7
  import {
8
8
  __esm
9
9
  } from "./chunk-PLDDJCW6.js";
@@ -56,4 +56,4 @@ export {
56
56
  init_useOrganisations,
57
57
  useEvents
58
58
  };
59
- //# sourceMappingURL=chunk-CRKP3HXI.js.map
59
+ //# sourceMappingURL=chunk-FT2M4R4F.js.map
@@ -11,11 +11,11 @@ import {
11
11
  init_useOrganisations,
12
12
  useEvents,
13
13
  useOrganisations
14
- } from "./chunk-CRKP3HXI.js";
14
+ } from "./chunk-FT2M4R4F.js";
15
15
  import {
16
16
  init_UnifiedAuthProvider,
17
17
  useUnifiedAuth
18
- } from "./chunk-JDQ7T3QB.js";
18
+ } from "./chunk-MNJXXD6C.js";
19
19
  import {
20
20
  getCurrentAppName
21
21
  } from "./chunk-JCQZ6LA7.js";
@@ -729,4 +729,4 @@ export {
729
729
  useHasAllPermissions,
730
730
  useCachedPermissions
731
731
  };
732
- //# sourceMappingURL=chunk-PUKTJMRT.js.map
732
+ //# sourceMappingURL=chunk-LRQ6RBJC.js.map
@@ -69,6 +69,13 @@ var init_BaseService = __esm({
69
69
  getInitialized() {
70
70
  return this.isInitialized;
71
71
  }
72
+ /**
73
+ * Reset initialization state (allows re-initialization)
74
+ * Use when dependencies change and service needs to re-initialize
75
+ */
76
+ resetInitialization() {
77
+ this.isInitialized = false;
78
+ }
72
79
  };
73
80
  }
74
81
  });
@@ -973,12 +980,23 @@ var init_EventService = __esm({
973
980
  }
974
981
  // Update dependencies
975
982
  updateDependencies(supabaseClient, user, session, appName, selectedOrganisation, setSelectedEventId) {
983
+ const previousOrgId = this.selectedOrganisation?.id;
984
+ const newOrgId = selectedOrganisation?.id;
976
985
  this.supabaseClient = supabaseClient;
977
986
  this.user = user;
978
987
  this.session = session;
979
988
  this.appName = appName;
980
989
  this.selectedOrganisation = selectedOrganisation;
981
990
  this.setSelectedEventId = setSelectedEventId;
991
+ if (previousOrgId !== newOrgId) {
992
+ this.resetInitialization();
993
+ this.isInitializedRef = false;
994
+ this.isFetchingRef = false;
995
+ if (previousOrgId !== null && newOrgId !== previousOrgId) {
996
+ this.events = [];
997
+ this.selectedEvent = null;
998
+ }
999
+ }
982
1000
  this.notify();
983
1001
  }
984
1002
  // Event state getters
@@ -1978,4 +1996,4 @@ export {
1978
1996
  UnifiedAuthProvider,
1979
1997
  init_UnifiedAuthProvider
1980
1998
  };
1981
- //# sourceMappingURL=chunk-JDQ7T3QB.js.map
1999
+ //# sourceMappingURL=chunk-MNJXXD6C.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/services/base/BaseService.ts","../src/services/AuthService.ts","../src/providers/services/AuthServiceProvider.tsx","../src/services/OrganisationService.ts","../src/providers/services/OrganisationServiceProvider.tsx","../src/services/EventService.ts","../src/providers/services/EventServiceProvider.tsx","../src/services/InactivityService.ts","../src/providers/services/InactivityServiceProvider.tsx","../src/hooks/services/useAuthService.ts","../src/hooks/services/useOrganisationService.ts","../src/hooks/services/useEventService.ts","../src/hooks/services/useInactivityService.ts","../src/providers/services/UnifiedAuthProvider.tsx"],"sourcesContent":["/**\n * @file Base Service Class\n * @package @jmruthers/pace-core\n * @module Services/Base\n * @since 0.1.0\n *\n * Base service class implementing the observable pattern for React subscriptions.\n * All services extend this class to provide state change notifications.\n */\n\nexport type StateChangeCallback = () => void;\n\nexport abstract class BaseService {\n private subscribers: Array<StateChangeCallback> = [];\n private isInitialized = false;\n\n /**\n * Subscribe to state changes\n * @param callback Function to call when state changes\n * @returns Unsubscribe function\n */\n subscribe(callback: StateChangeCallback): () => void {\n this.subscribers.push(callback);\n \n // Return unsubscribe function that removes only the first occurrence\n return () => {\n const index = this.subscribers.indexOf(callback);\n if (index > -1) {\n this.subscribers.splice(index, 1);\n }\n };\n }\n\n /**\n * Notify all subscribers of state changes\n * This triggers React re-renders\n */\n protected notify(): void {\n this.subscribers.forEach(callback => {\n try {\n callback();\n } catch (error) {\n console.error('[BaseService] Error in subscriber callback:', error);\n }\n });\n }\n\n /**\n * Initialize the service\n * Override in subclasses to implement initialization logic\n */\n async initialize(): Promise<void> {\n if (this.isInitialized) {\n return;\n }\n \n await this.doInitialize();\n this.isInitialized = true;\n }\n\n /**\n * Cleanup the service\n * Override in subclasses to implement cleanup logic\n */\n cleanup(): void {\n this.subscribers = [];\n this.doCleanup();\n this.isInitialized = false;\n }\n\n /**\n * Check if service is initialized\n */\n protected getInitialized(): boolean {\n return this.isInitialized;\n }\n\n /**\n * Reset initialization state (allows re-initialization)\n * Use when dependencies change and service needs to re-initialize\n */\n protected resetInitialization(): void {\n this.isInitialized = false;\n }\n\n /**\n * Override in subclasses to implement initialization logic\n */\n protected abstract doInitialize(): Promise<void>;\n\n /**\n * Override in subclasses to implement cleanup logic\n */\n protected abstract doCleanup(): void;\n}","/**\n * @file Authentication Service\n * @package @jmruthers/pace-core\n * @module Services\n * @since 0.1.0\n *\n * Authentication service implementation.\n * Handles user authentication, session management, and auth-related operations.\n */\n\nimport { type SupabaseClient, type User, type Session, AuthError } from '@supabase/supabase-js';\nimport { BaseService } from './base/BaseService';\nimport { IAuthService, AuthResult } from './interfaces/IAuthService';\n\nexport class AuthService extends BaseService implements IAuthService {\n private user: User | null = null;\n private session: Session | null = null;\n private authLoading = false;\n private authError: AuthError | null = null;\n private supabaseClient: SupabaseClient | null = null;\n private authStateSubscription: any = null;\n\n constructor(supabaseClient: SupabaseClient) {\n super();\n this.supabaseClient = supabaseClient;\n }\n\n // Auth state getters\n getUser(): User | null {\n return this.user;\n }\n\n getSession(): Session | null {\n return this.session;\n }\n\n isAuthenticated(): boolean {\n return !!(this.user && this.session);\n }\n\n isLoading(): boolean {\n return this.authLoading;\n }\n\n getError(): AuthError | null {\n return this.authError;\n }\n\n getSupabaseClient(): SupabaseClient | null {\n return this.supabaseClient;\n }\n\n // Auth methods\n async signIn(email: string, password?: string): Promise<AuthResult> {\n if (!this.supabaseClient) {\n const error = new AuthError('Supabase client not available');\n this.authError = error;\n this.notify();\n return { user: null, session: null, error };\n }\n\n try {\n const { data, error } = await this.supabaseClient.auth.signInWithPassword({\n email,\n password: password || '',\n });\n \n if (error) {\n this.authError = error;\n this.user = null;\n this.session = null;\n } else {\n this.authError = null;\n this.user = data.user;\n this.session = data.session;\n }\n \n this.notify();\n return { user: data.user, session: data.session, error };\n } catch (error) {\n // Convert regular Error to AuthError if needed\n const authError = error instanceof AuthError \n ? error \n : new AuthError(error instanceof Error ? error.message : 'Authentication failed');\n this.authError = authError;\n this.user = null;\n this.session = null;\n this.notify();\n return { user: null, session: null, error: authError };\n }\n }\n\n async signUp(email: string, password: string): Promise<AuthResult> {\n if (!this.supabaseClient) {\n const error = new AuthError('Supabase client not available');\n this.authError = error;\n this.notify();\n return { user: null, session: null, error };\n }\n\n try {\n const { data, error } = await this.supabaseClient.auth.signUp({\n email,\n password,\n });\n \n if (error) {\n this.authError = error;\n this.user = null;\n this.session = null;\n } else {\n this.authError = null;\n this.user = data.user;\n this.session = data.session;\n }\n \n this.notify();\n return { user: data.user, session: data.session, error };\n } catch (error) {\n // Convert regular Error to AuthError if needed\n const authError = error instanceof AuthError \n ? error \n : new AuthError(error instanceof Error ? error.message : 'Authentication failed');\n this.authError = authError;\n this.user = null;\n this.session = null;\n this.notify();\n return { user: null, session: null, error: authError };\n }\n }\n\n async signOut(): Promise<AuthResult> {\n if (!this.supabaseClient) {\n const error = new AuthError('Supabase client not available');\n this.authError = error;\n this.notify();\n return { user: null, session: null, error };\n }\n\n try {\n const { error } = await this.supabaseClient.auth.signOut();\n \n if (error) {\n this.authError = error;\n } else {\n this.authError = null;\n this.user = null;\n this.session = null;\n }\n \n this.notify();\n return { user: null, session: null, error };\n } catch (error) {\n // Convert regular Error to AuthError if needed\n const authError = error instanceof AuthError \n ? error \n : new AuthError(error instanceof Error ? error.message : 'Authentication failed');\n this.authError = authError;\n this.user = null;\n this.session = null;\n this.notify();\n return { user: null, session: null, error: authError };\n }\n }\n\n async resetPassword(email: string): Promise<AuthResult> {\n if (!this.supabaseClient) {\n const error = new AuthError('Supabase client not available');\n this.authError = error;\n this.notify();\n return { user: null, session: null, error };\n }\n\n try {\n const { error } = await this.supabaseClient.auth.resetPasswordForEmail(email);\n \n if (error) {\n this.authError = error;\n } else {\n this.authError = null;\n }\n \n this.notify();\n return { user: null, session: null, error };\n } catch (error) {\n // Convert regular Error to AuthError if needed\n const authError = error instanceof AuthError \n ? error \n : new AuthError(error instanceof Error ? error.message : 'Authentication failed');\n this.authError = authError;\n this.notify();\n return { user: null, session: null, error: authError };\n }\n }\n\n async updatePassword(password: string): Promise<AuthResult> {\n if (!this.supabaseClient) {\n const error = new AuthError('Supabase client not available');\n this.authError = error;\n this.notify();\n return { user: null, session: null, error };\n }\n\n try {\n const { error } = await this.supabaseClient.auth.updateUser({\n password,\n });\n \n if (error) {\n this.authError = error;\n } else {\n this.authError = null;\n }\n \n this.notify();\n return { user: null, session: null, error };\n } catch (error) {\n const authError = error as AuthError;\n this.authError = authError;\n this.notify();\n return { user: null, session: null, error: authError };\n }\n }\n\n async refreshSession(): Promise<AuthResult> {\n if (!this.supabaseClient) {\n const error = new AuthError('Supabase client not available');\n this.authError = error;\n this.notify();\n return { user: null, session: null, error };\n }\n\n try {\n const { data, error } = await this.supabaseClient.auth.refreshSession();\n \n if (error) {\n this.authError = error;\n this.user = null;\n this.session = null;\n } else {\n this.authError = null;\n // Only update user and session if both are present (valid session)\n if (data?.user && data?.session) {\n this.user = data.user;\n this.session = data.session;\n } else {\n // If no valid session, clear everything\n this.user = null;\n this.session = null;\n }\n }\n \n this.notify();\n // Only return user if we have a valid session\n return { \n user: (data?.user && data?.session) ? data.user : null, \n session: data?.session ?? null, \n error \n };\n } catch (error) {\n // Convert regular Error to AuthError if needed\n const authError = error instanceof AuthError \n ? error \n : new AuthError(error instanceof Error ? error.message : 'Authentication failed');\n this.authError = authError;\n this.user = null;\n this.session = null;\n this.notify();\n return { user: null, session: null, error: authError };\n }\n }\n\n // Lifecycle methods\n async initialize(): Promise<void> {\n await super.initialize();\n await this.setupAuthStateListener();\n await this.restoreSession();\n }\n\n cleanup(): void {\n if (this.authStateSubscription && typeof this.authStateSubscription.unsubscribe === 'function') {\n this.authStateSubscription.unsubscribe();\n this.authStateSubscription = null;\n }\n super.cleanup();\n }\n\n protected async doInitialize(): Promise<void> {\n // Setup global error handlers\n this.setupErrorHandlers();\n }\n\n protected doCleanup(): void {\n // Remove global error handlers\n this.removeErrorHandlers();\n }\n\n private async setupAuthStateListener(): Promise<void> {\n if (!this.supabaseClient) {\n this.authLoading = false;\n this.notify();\n return;\n }\n\n try {\n this.authStateSubscription = this.supabaseClient.auth.onAuthStateChange(\n (event, session) => {\n try {\n // Handle different auth events\n if (event === 'SIGNED_OUT') {\n this.session = null;\n this.user = null;\n this.authError = null;\n } else if (event === 'SIGNED_IN' || event === 'TOKEN_REFRESHED') {\n this.session = session;\n this.user = session?.user ?? null;\n \n // Only clear auth error if we have a valid session\n if (session) {\n this.authError = null;\n }\n } else if (event === 'INITIAL_SESSION') {\n if (session) {\n this.session = session;\n this.user = session.user ?? null;\n this.authError = null;\n }\n }\n \n // Always set loading to false after any auth state change\n this.authLoading = false;\n this.notify();\n } catch (error) {\n console.warn('[AuthService] Error in auth state change handler:', error);\n this.authLoading = false;\n this.notify();\n }\n }\n );\n } catch (error) {\n console.error('[AuthService] Failed to setup auth state listener:', error);\n throw error; // Re-throw to propagate to the provider\n }\n }\n\n private async restoreSession(): Promise<void> {\n if (!this.supabaseClient) {\n this.authLoading = false;\n this.notify();\n return;\n }\n\n try {\n // First, try to get the current session\n const { data: { session: currentSession }, error: sessionError } = await this.supabaseClient.auth.getSession();\n \n if (sessionError) {\n console.warn('[AuthService] Error getting current session:', sessionError);\n // Don't treat session errors as fatal - user might not be logged in\n }\n\n if (currentSession) {\n this.session = currentSession;\n this.user = currentSession.user;\n this.authError = null;\n } else {\n // Try to get user anyway (in case session is expired but user exists)\n const { data: { user: currentUser }, error: userError } = await this.supabaseClient.auth.getUser();\n \n if (!userError && currentUser) {\n this.user = currentUser;\n // Don't set session if it's null - this prevents issues\n }\n }\n\n this.authLoading = false;\n this.notify();\n } catch (error) {\n console.error('[AuthService] Error during auth initialization:', error);\n this.authLoading = false;\n // Don't set auth error for initialization failures - user might not be logged in\n this.notify();\n }\n }\n\n private setupErrorHandlers(): void {\n if (typeof window === 'undefined') return;\n\n const handleError = (event: ErrorEvent) => {\n if (event.error?.message?.includes('AuthSessionMissingError') || \n event.error?.message?.includes('Auth session missing')) {\n console.warn('[AuthService] Suppressing AuthSessionMissingError during logout');\n event.preventDefault();\n return false;\n }\n };\n\n const handleUnhandledRejection = (event: PromiseRejectionEvent) => {\n if (event.reason?.message?.includes('AuthSessionMissingError') ||\n event.reason?.message?.includes('Auth session missing')) {\n console.warn('[AuthService] Suppressing unhandled AuthSessionMissingError');\n event.preventDefault();\n return false;\n }\n };\n\n window.addEventListener('error', handleError);\n window.addEventListener('unhandledrejection', handleUnhandledRejection);\n }\n\n private removeErrorHandlers(): void {\n if (typeof window === 'undefined') return;\n\n // Note: We can't remove specific handlers without storing references\n // In a real implementation, you'd store the handler references\n // For now, we'll rely on the service being cleaned up\n }\n}","/**\n * @file Auth Service Provider\n * @package @jmruthers/pace-core\n * @module Providers/Services\n * @since 0.1.0\n *\n * React provider for AuthService.\n * Provides authentication service instance to React components.\n */\n\nimport React, { createContext, useContext, useMemo, useEffect } from 'react';\nimport { type SupabaseClient } from '@supabase/supabase-js';\nimport { AuthService } from '../../services/AuthService';\n\n// Context type\nexport interface AuthServiceContextType {\n authService: AuthService;\n}\n\nexport const AuthServiceContext = createContext<AuthServiceContextType | null>(null);\n\nexport interface AuthServiceProviderProps {\n children: React.ReactNode;\n supabaseClient: SupabaseClient;\n}\n\nexport function AuthServiceProvider({ children, supabaseClient }: AuthServiceProviderProps) {\n // Create service instance with useMemo to prevent recreation on every render\n const authService = useMemo(\n () => new AuthService(supabaseClient),\n [supabaseClient]\n );\n\n // Initialize service on mount\n useEffect(() => {\n authService.initialize().catch(error => {\n console.error('[AuthServiceProvider] Failed to initialize auth service:', error);\n });\n\n // Cleanup on unmount\n return () => {\n authService.cleanup();\n };\n }, [authService]);\n\n const contextValue = useMemo(() => ({\n authService\n }), [authService]);\n\n return (\n <AuthServiceContext.Provider value={contextValue}>\n {children}\n </AuthServiceContext.Provider>\n );\n}\n\nexport const useAuthService = (): AuthService => {\n const context = useContext(AuthServiceContext);\n \n if (!context) {\n throw new Error('useAuthService must be used within AuthServiceProvider');\n }\n \n return context.authService;\n};","/**\n * @file Organisation Service\n * @package @jmruthers/pace-core\n * @module Services\n * @since 0.1.0\n *\n * Organisation service implementation.\n * Handles organisation management and selection with security-first approach.\n */\n\nimport { type SupabaseClient, type User, type Session } from '@supabase/supabase-js';\nimport { BaseService } from './base/BaseService';\nimport { IOrganisationService } from './interfaces/IOrganisationService';\nimport type {\n Organisation,\n OrganisationMembership,\n OrganisationSecurityError,\n OrganisationHierarchy\n} from '../types/organisation';\nimport { setOrganisationContext } from '../utils/organisationContext';\n\nexport class OrganisationService extends BaseService implements IOrganisationService {\n private _selectedOrganisation: Organisation | null = null;\n private _organisations: Organisation[] = [];\n private _userMemberships: OrganisationMembership[] = [];\n private _roleMapState: Map<string, string> = new Map();\n private _isLoading = false;\n private _error: Error | null = null;\n private _isContextReady = false;\n private retryCount = 0;\n\n // Dependencies\n private supabaseClient: SupabaseClient | null = null;\n private user: User | null = null;\n private session: Session | null = null;\n\n // Internal state management\n private isLoadingRef = false;\n private lastLoadTimeRef = 0;\n private hasFailedRef = false;\n private abortControllerRef: AbortController | null = null;\n\n constructor(supabaseClient: SupabaseClient, user: User | null, session: Session | null) {\n super();\n this.supabaseClient = supabaseClient;\n this.user = user;\n this.session = session;\n }\n\n // Interface implementation\n getSelectedOrganisation(): Organisation | null { return this._selectedOrganisation; }\n getOrganisations(): Organisation[] { return this._organisations; }\n getUserMemberships(): OrganisationMembership[] { return this._userMemberships; }\n isLoading(): boolean { \n return this._isLoading;\n }\n getError(): Error | null { return this._error; }\n hasValidOrganisationContext(): boolean { return !!(this._selectedOrganisation && !this._isLoading && !this._error && this._isContextReady); }\n isContextReady(): boolean { return this._isContextReady; }\n\n // Additional methods for testing\n setSelectedOrganisation(organisation: Organisation | null): void {\n this._selectedOrganisation = organisation;\n if (organisation) {\n localStorage.setItem('pace-core-selected-organisation', JSON.stringify(organisation));\n this.setDatabaseOrganisationContext(organisation);\n } else {\n localStorage.removeItem('pace-core-selected-organisation');\n this._isContextReady = false;\n }\n this.notify();\n }\n\n // For testing: expose dependencies\n getDependencies(): { user: User | null; session: Session | null; supabaseClient: SupabaseClient | null } {\n return {\n user: this.user,\n session: this.session,\n supabaseClient: this.supabaseClient\n };\n }\n\n // For testing: manually set state\n setTestState(\n organisations: Organisation[],\n memberships: OrganisationMembership[],\n roleMap: Map<string, string>,\n selectedOrg: Organisation | null = null\n ): void {\n this._organisations = organisations;\n this._userMemberships = memberships;\n this._roleMapState = roleMap;\n if (selectedOrg) {\n this._selectedOrganisation = selectedOrg;\n } else if (organisations.length > 0) {\n this._selectedOrganisation = organisations[0];\n }\n this._isLoading = false;\n this._error = null;\n this.notify();\n }\n\n // Update dependencies\n updateDependencies(user: User | null, session: Session | null): void {\n const wasAuthenticated = !!(this.user && this.session);\n const isAuthenticated = !!(user && session);\n \n this.user = user;\n this.session = session;\n \n // If user logs out, allow re-initialization when they log back in\n if (wasAuthenticated && !isAuthenticated) {\n // Reset BaseService initialization state to allow re-initialization\n (this as any).isInitialized = false;\n }\n \n this.notify();\n }\n\n // Organisation methods\n async switchOrganisation(orgId: string): Promise<void> {\n // Validate access\n if (!this.validateOrganisationAccess(orgId)) {\n throw new Error(`User does not have access to organisation ${orgId}`) as OrganisationSecurityError;\n }\n \n const targetOrg = this._organisations.find(org => org.id === orgId);\n if (!targetOrg) {\n throw new Error(`Organisation ${orgId} not found in user's organisations`) as OrganisationSecurityError;\n }\n \n this._selectedOrganisation = targetOrg;\n \n // Persist selection\n localStorage.setItem('pace-core-selected-organisation', JSON.stringify(targetOrg));\n \n // Set database organisation context\n await this.setDatabaseOrganisationContext(targetOrg);\n \n this.notify();\n }\n\n getUserRole(orgId?: string): string {\n const targetOrgId = orgId || this._selectedOrganisation?.id;\n if (!targetOrgId) return 'no_access';\n \n // Use roleMapState to get the role for this organisation\n return this._roleMapState.get(targetOrgId) || 'no_access';\n }\n\n validateOrganisationAccess(orgId: string): boolean {\n return this._userMemberships.some((m: any) => \n m.organisation_id === orgId && \n m.status === 'active' &&\n m.revoked_at === null\n );\n }\n\n async refreshOrganisations(): Promise<void> {\n if (!this.user || !this.session || !this.supabaseClient) return;\n \n // Force reload by triggering the effect\n this._isLoading = true;\n this.notify();\n await this.loadUserOrganisations();\n }\n\n ensureOrganisationContext(): Organisation {\n if (!this._selectedOrganisation) {\n throw new Error('Organisation context is required but not available') as OrganisationSecurityError;\n }\n return this._selectedOrganisation;\n }\n\n isOrganisationSecure(): boolean {\n return !!(this._selectedOrganisation && this.user);\n }\n\n getPrimaryOrganisation(): Organisation | null {\n // Look for org_admin role first, then leader, then member\n const rolePriority = ['org_admin', 'leader', 'member'];\n \n for (const role of rolePriority) {\n const membership = this._userMemberships.find((m: any) => m.role === role);\n if (membership) {\n return this._organisations.find((org: any) => org.id === membership.organisation_id) || null;\n }\n }\n \n return null;\n }\n\n buildOrganisationHierarchy(orgs: Organisation[]): OrganisationHierarchy[] {\n const orgMap = new Map<string, Organisation>();\n orgs.forEach(org => orgMap.set(org.id, org));\n \n const roots: OrganisationHierarchy[] = [];\n \n orgs.forEach(org => {\n if (!org.parent_id) {\n // Root organisation\n roots.push({\n organisation: org,\n children: [],\n depth: 0\n });\n }\n });\n \n // For now, return flat structure - hierarchy building can be added later\n return roots;\n }\n\n // Lifecycle methods\n async initialize(): Promise<void> {\n await super.initialize();\n \n // Don't load if already loading (prevents duplicate loads during rapid auth events)\n if (!this.isLoadingRef) {\n await this.loadUserOrganisations();\n }\n }\n\n cleanup(): void {\n // Cleanup on unmount\n this.isLoadingRef = false;\n this.hasFailedRef = false;\n this.lastLoadTimeRef = 0;\n // Don't abort pending requests - let them complete naturally\n // Aborting causes React StrictMode issues where requests are cancelled mid-flight\n // The requests will complete on their own and update state if needed\n if (this.abortControllerRef) {\n // Clear the reference but don't abort - let requests complete\n this.abortControllerRef = null;\n }\n // Reset state\n this._selectedOrganisation = null;\n this._organisations = [];\n this._userMemberships = [];\n this._roleMapState = new Map();\n this._isLoading = false;\n this._error = null;\n this._isContextReady = false;\n super.cleanup();\n }\n\n protected async doInitialize(): Promise<void> {\n // Initial setup\n }\n\n protected doCleanup(): void {\n // Cleanup any resources\n }\n\n private async setDatabaseOrganisationContext(organisation: Organisation): Promise<void> {\n if (!this.supabaseClient || !this.session) {\n console.warn('[OrganisationService] No Supabase client or session available for setting organisation context');\n this._isContextReady = false;\n this.notify();\n return;\n }\n\n try {\n console.log('[OrganisationService] Setting database organisation context for:', organisation.id);\n \n // Add timeout to prevent hanging\n const timeoutPromise = new Promise((_, reject) => {\n setTimeout(() => reject(new Error('Context setting timeout after 5 seconds')), 5000);\n });\n \n const contextPromise = setOrganisationContext(this.supabaseClient, organisation.id);\n \n await Promise.race([contextPromise, timeoutPromise]);\n \n console.log('[OrganisationService] Database organisation context set successfully');\n this._isContextReady = true;\n this.notify();\n } catch (error) {\n console.error('[OrganisationService] Failed to set database organisation context:', error);\n // Set context ready to true anyway - this is a non-critical operation\n // The app should still work without database context\n this._isContextReady = true;\n this.notify();\n // Don't throw - this is a non-critical operation\n }\n }\n\n private async loadUserOrganisations(): Promise<void> {\n // Add call tracking to detect race conditions\n const callId = Math.random().toString(36).substr(2, 9);\n console.log(`[OrganisationService] Starting loadUserOrganisations call ${callId}`);\n \n if (!this.user || !this.session || !this.supabaseClient) {\n // Clear state when no user, session, or supabase client\n this._selectedOrganisation = null;\n this._organisations = [];\n this._userMemberships = [];\n this._isLoading = false;\n this._error = null;\n this.notify();\n return;\n }\n\n // Additional check to prevent loading during auth state changes\n if (this.isLoadingRef) {\n console.log(\"OrganisationService\", \"Already loading, skipping duplicate load\");\n // Ensure loading state is correct\n this._isLoading = true;\n this.notify();\n return;\n }\n\n // Prevent rapid retries - minimum 2 seconds between attempts\n const now = Date.now();\n if (now - this.lastLoadTimeRef < 2000) {\n console.log(\"OrganisationService\", \"Too soon since last load, skipping\");\n // Ensure loading state is correct\n if (this._organisations.length > 0 || this._selectedOrganisation) {\n this._isLoading = false;\n } else {\n this._isLoading = true;\n }\n this.notify();\n return;\n }\n\n // Cancel any existing request\n if (this.abortControllerRef) {\n this.abortControllerRef.abort();\n }\n\n // Create new abort controller for this request\n this.abortControllerRef = new AbortController();\n const abortSignal = this.abortControllerRef.signal;\n\n this.lastLoadTimeRef = now;\n this.isLoadingRef = true;\n this._isLoading = true;\n this._error = null;\n this.notify();\n \n try {\n console.log(\"[OrganisationService] Supabase client ready:\", {\n isConnected: !!this.supabaseClient,\n hasAuth: !!this.supabaseClient.auth,\n hasRpc: !!this.supabaseClient.rpc\n });\n \n // Get user's organisation memberships using secure RPC function\n // Only get actual members (org_admin, leader, member) - exclude supporters\n let memberships, membershipError;\n try {\n console.log(\"[OrganisationService] Making RPC call to data_user_organisation_roles_get...\");\n \n // Add timeout and abort signal to prevent hanging RPC calls\n const timeoutPromise = new Promise((_, reject) => {\n const timeoutId = setTimeout(() => reject(new Error('RPC call timeout after 10 seconds')), 10000);\n abortSignal.addEventListener('abort', () => {\n clearTimeout(timeoutId);\n reject(new Error('Request aborted'));\n });\n });\n \n const rpcPromise = this.supabaseClient.rpc('data_user_organisation_roles_get', {\n p_user_id: this.user.id,\n p_organisation_id: null\n });\n \n // Check if request was aborted before making the call\n if (abortSignal.aborted) {\n throw new Error('Request aborted');\n }\n \n const result = await Promise.race([rpcPromise, timeoutPromise]) as any;\n \n console.log(\"[OrganisationService] RPC call completed:\", {\n hasData: !!result.data,\n hasError: !!result.error,\n dataLength: result.data?.length || 0,\n errorMessage: result.error?.message || 'No error'\n });\n \n // Filter to only actual members (org_admin, leader, member) - exclude supporters\n memberships = result.data?.filter((role: any) => \n ['org_admin', 'leader', 'member'].includes(role.role)\n ) || [];\n membershipError = result.error;\n } catch (queryError: any) {\n membershipError = queryError;\n }\n\n if (membershipError) {\n console.error(\"[OrganisationService] Error loading memberships:\", membershipError);\n \n // If RPC fails with timeout, try direct database query as fallback\n if (membershipError.message?.includes('timeout')) {\n console.log(\"[OrganisationService] RPC timed out, trying direct database query as fallback...\");\n try {\n // Check if request was aborted before making fallback query\n if (abortSignal.aborted) {\n throw new Error('Request aborted');\n }\n\n const { data: fallbackData, error: fallbackError } = await this.supabaseClient\n .from('rbac_organisation_roles')\n .select(`\n id,\n user_id,\n organisation_id,\n role,\n status,\n granted_at,\n granted_by,\n revoked_at,\n revoked_by,\n notes,\n created_at,\n updated_at,\n organisations!inner(\n id,\n name,\n display_name,\n subscription_tier,\n settings,\n is_active,\n parent_id,\n created_at,\n updated_at\n )\n `)\n .eq('user_id', this.user.id)\n .eq('status', 'active')\n .is('revoked_at', null)\n .in('role', ['org_admin', 'leader', 'member']);\n \n if (fallbackError) {\n console.error(\"[OrganisationService] Fallback query also failed:\", fallbackError);\n throw membershipError; // Throw original error\n }\n \n console.log(\"[OrganisationService] Fallback query successful, got\", fallbackData?.length || 0, \"memberships\");\n memberships = fallbackData || [];\n membershipError = null;\n } catch (fallbackErr) {\n console.error(\"[OrganisationService] Fallback query failed:\", fallbackErr);\n throw membershipError; // Throw original error\n }\n } else {\n throw membershipError;\n }\n }\n \n if (!memberships || memberships.length === 0) {\n throw new Error('User has no active organisation memberships') as OrganisationSecurityError;\n }\n\n // Get organisation details for the memberships\n const organisationIds = memberships\n .map((m: any) => m.organisation_id)\n .filter((id: string) => {\n // Better validation to prevent empty string UUID errors\n if (!id || typeof id !== 'string') {\n console.warn(\"[OrganisationService] Invalid organisation ID (not string):\", id);\n return false;\n }\n const trimmedId = id.trim();\n if (trimmedId === '') {\n console.warn(\"[OrganisationService] Empty organisation ID found\");\n return false;\n }\n // Validate UUID format\n const isValidUuid = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(trimmedId);\n if (!isValidUuid) {\n console.warn(\"[OrganisationService] Invalid UUID format:\", trimmedId);\n }\n return isValidUuid;\n });\n \n if (organisationIds.length === 0) {\n console.warn(\"[OrganisationService] No valid organisation IDs found in memberships:\", memberships);\n throw new Error('No valid organisation IDs found in memberships') as OrganisationSecurityError;\n }\n \n // Check if request was aborted before making organisations query\n if (abortSignal.aborted) {\n throw new Error('Request aborted');\n }\n \n const { data: allOrganisations, error: orgError } = await this.supabaseClient\n .from('organisations')\n .select('id, name, display_name, subscription_tier, settings, is_active, parent_id, created_at, updated_at');\n \n if (orgError) {\n console.error(\"[OrganisationService] Error loading organisations:\", orgError);\n throw orgError;\n }\n \n // Filter manually on the client side\n const organisations = allOrganisations?.filter(org => \n organisationIds.includes(org.id)\n ) || [];\n\n // Create a map of organisation_id to role from the memberships data\n const roleMap = new Map<string, string>();\n memberships?.forEach((membership: any) => {\n roleMap.set(membership.organisation_id, membership.role);\n });\n\n // Extract organisations and memberships\n const orgs = organisations as Organisation[];\n const activeOrgs = orgs.filter(org => org.is_active);\n \n if (activeOrgs.length === 0) {\n throw new Error('User has no access to active organisations') as OrganisationSecurityError;\n }\n\n this._organisations = activeOrgs;\n this._userMemberships = memberships as OrganisationMembership[];\n \n // Store role map in component state for later use\n this._roleMapState = roleMap;\n \n // Auto-select organisation: try persisted, then primary, then first\n let initialOrg: Organisation | null = null;\n \n // 1. Try to restore from localStorage\n try {\n const persistedOrgString = localStorage.getItem('pace-core-selected-organisation');\n if (persistedOrgString) {\n const persistedOrg = JSON.parse(persistedOrgString) as Organisation;\n // Validate persisted org ID before using it\n if (persistedOrg.id && typeof persistedOrg.id === 'string' && persistedOrg.id.trim() !== '') {\n const validPersistedOrg = activeOrgs.find(org => org.id === persistedOrg.id);\n if (validPersistedOrg) {\n initialOrg = validPersistedOrg;\n } else {\n console.warn(\"[OrganisationService] Persisted organisation not found in active orgs, clearing cache\");\n localStorage.removeItem('pace-core-selected-organisation');\n }\n } else {\n console.warn(\"[OrganisationService] Invalid persisted organisation ID, clearing cache\");\n localStorage.removeItem('pace-core-selected-organisation');\n }\n }\n } catch (storageError) {\n console.warn(\"[OrganisationService] Failed to restore persisted organisation:\", storageError);\n // Clear potentially corrupted cache\n localStorage.removeItem('pace-core-selected-organisation');\n }\n \n // 2. Fall back to org_admin role organisation (highest privilege)\n if (!initialOrg) {\n const adminMembership = memberships.find((m: any) => m.role === 'org_admin');\n if (adminMembership) {\n const foundOrg = organisations.find((org) => org.id === adminMembership.organisation_id);\n if (foundOrg) {\n initialOrg = foundOrg;\n }\n }\n }\n \n // 3. Fall back to first organisation\n if (!initialOrg) {\n initialOrg = activeOrgs[0];\n }\n \n if (!initialOrg) {\n throw new Error('No valid organisation found for user') as OrganisationSecurityError;\n }\n\n this._selectedOrganisation = initialOrg;\n \n // Persist selection\n localStorage.setItem('pace-core-selected-organisation', JSON.stringify(initialOrg));\n \n // Set database organisation context\n await this.setDatabaseOrganisationContext(initialOrg);\n \n // Reset retry count and failed flag on success\n this.retryCount = 0;\n this.hasFailedRef = false;\n \n } catch (err) {\n console.error(\"[OrganisationService] Failed to load organisations:\", err);\n this._error = err as Error;\n // Increment retry count on error\n this.retryCount = this.retryCount + 1;\n // Set failed flag to prevent further attempts\n this.hasFailedRef = true;\n // Clear all cached data on error to prevent corruption\n this.clearAllCachedData();\n } finally {\n // Always cleanup refs and abort controller\n this.isLoadingRef = false;\n this._isLoading = false;\n this.abortControllerRef = null;\n this.notify();\n }\n }\n\n private clearAllCachedData(): void {\n localStorage.removeItem('pace-core-selected-organisation');\n localStorage.removeItem('pace-core-organisation-context');\n this._selectedOrganisation = null;\n this._organisations = [];\n this._userMemberships = [];\n this._roleMapState = new Map();\n this.retryCount = 0;\n this._isContextReady = false;\n // Don't clear _error here - let it persist for error reporting\n }\n}","/**\n * @file Organisation Service Provider\n * @package @jmruthers/pace-core\n * @module Providers/Services\n * @since 0.1.0\n *\n * React provider for OrganisationService.\n * Provides organisation service instance to React components.\n */\n\nimport React, { createContext, useContext, useMemo, useEffect, useRef } from 'react';\nimport { type SupabaseClient, type User, type Session } from '@supabase/supabase-js';\nimport { OrganisationService } from '../../services/OrganisationService';\n\n// Context type\nexport interface OrganisationServiceContextType {\n organisationService: OrganisationService;\n}\n\nexport const OrganisationServiceContext = createContext<OrganisationServiceContextType | null>(null);\n\nexport interface OrganisationServiceProviderProps {\n children: React.ReactNode;\n supabaseClient: SupabaseClient;\n user: User | null;\n session: Session | null;\n}\n\nexport function OrganisationServiceProvider({ \n children, \n supabaseClient, \n user, \n session \n}: OrganisationServiceProviderProps) {\n // Create service instance once with useRef to avoid recreation on auth state changes\n const organisationServiceRef = useRef<OrganisationService | null>(null);\n \n if (!organisationServiceRef.current) {\n organisationServiceRef.current = new OrganisationService(supabaseClient, user, session);\n }\n \n const organisationService = organisationServiceRef.current;\n\n // Update service dependencies when they change without recreation\n useEffect(() => {\n organisationService.updateDependencies(user, session);\n \n // Re-initialize service when user/session changes\n let isMounted = true;\n \n organisationService.initialize().catch(error => {\n if (isMounted) {\n console.error('[OrganisationServiceProvider] Failed to initialize organisation service:', error);\n }\n });\n\n return () => {\n isMounted = false;\n };\n }, [organisationService, user, session]);\n\n const contextValue = useMemo(() => ({\n organisationService\n }), [organisationService]);\n\n return (\n <OrganisationServiceContext.Provider value={contextValue}>\n {children}\n </OrganisationServiceContext.Provider>\n );\n}\n\nexport const useOrganisationService = (): OrganisationService => {\n const context = useContext(OrganisationServiceContext);\n \n if (!context) {\n throw new Error('useOrganisationService must be used within OrganisationServiceProvider');\n }\n \n return context.organisationService;\n};","/**\n * @file Event Service\n * @package @jmruthers/pace-core\n * @module Services\n * @since 0.1.0\n *\n * Event service implementation.\n * Handles event management and selection with organisation context validation.\n */\n\nimport { type SupabaseClient, type User, type Session } from '@supabase/supabase-js';\nimport { BaseService } from './base/BaseService';\nimport { IEventService } from './interfaces/IEventService';\nimport { Event } from '../types/unified';\nimport { Organisation } from '../types/organisation';\nimport { DebugLogger } from '../utils/debugLogger';\n\nexport class EventService extends BaseService implements IEventService {\n private events: Event[] = [];\n private selectedEvent: Event | null = null;\n private _isLoading = false; // Start as false to avoid blocking UI\n private error: Error | null = null;\n\n // Dependencies\n private supabaseClient: SupabaseClient | null = null;\n private user: User | null = null;\n private session: Session | null = null;\n private appName: string = '';\n private selectedOrganisation: Organisation | null = null;\n private setSelectedEventId: ((eventId: string | null) => void) | null = null;\n\n // Internal state management\n private isInitializedRef = false;\n private isFetchingRef = false;\n private hasAutoSelectedRef = false;\n private userClearedEventRef = false;\n\n constructor(\n supabaseClient: SupabaseClient,\n user: User | null,\n session: Session | null,\n appName: string,\n selectedOrganisation: Organisation | null,\n setSelectedEventId: (eventId: string | null) => void\n ) {\n super();\n this.supabaseClient = supabaseClient;\n this.user = user;\n this.session = session;\n this.appName = appName;\n this.selectedOrganisation = selectedOrganisation;\n this.setSelectedEventId = setSelectedEventId;\n }\n\n // Update dependencies\n updateDependencies(\n supabaseClient: SupabaseClient,\n user: User | null,\n session: Session | null,\n appName: string,\n selectedOrganisation: Organisation | null,\n setSelectedEventId: (eventId: string | null) => void\n ): void {\n const previousOrgId = this.selectedOrganisation?.id;\n const newOrgId = selectedOrganisation?.id;\n \n this.supabaseClient = supabaseClient;\n this.user = user;\n this.session = session;\n this.appName = appName;\n this.selectedOrganisation = selectedOrganisation;\n this.setSelectedEventId = setSelectedEventId;\n \n // If organisation changed (from null to value, or different org), reset initialization\n // This ensures events are re-fetched when organisation context becomes available\n if (previousOrgId !== newOrgId) {\n this.resetInitialization(); // Reset BaseService's isInitialized flag\n this.isInitializedRef = false;\n this.isFetchingRef = false;\n // Clear events when switching organisations\n if (previousOrgId !== null && newOrgId !== previousOrgId) {\n this.events = [];\n this.selectedEvent = null;\n }\n }\n \n this.notify();\n }\n\n // Event state getters\n getEvents(): Event[] {\n return this.events;\n }\n\n getSelectedEvent(): Event | null {\n return this.selectedEvent;\n }\n\n isLoading(): boolean {\n return this._isLoading;\n }\n\n getError(): Error | null {\n return this.error;\n }\n\n // Event methods\n setSelectedEvent(event: Event | null): void {\n if (event) {\n // SECURITY: Validate event belongs to current organisation\n try {\n console.log('[EventService] Event selection validation:', {\n eventId: event.event_id,\n eventName: event.event_name,\n eventOrganisationId: event.organisation_id,\n selectedOrganisationId: this.selectedOrganisation?.id,\n selectedOrganisationName: this.selectedOrganisation?.display_name,\n match: event.organisation_id === this.selectedOrganisation?.id\n });\n \n if (this.selectedOrganisation && event.organisation_id !== this.selectedOrganisation.id) {\n console.error('[EventService] Event organisation_id does not match selected organisation', {\n eventOrganisationId: event.organisation_id,\n selectedOrganisationId: this.selectedOrganisation.id,\n eventName: event.event_name\n });\n return;\n }\n } catch (error) {\n console.error('[EventService] Error during event validation:', error);\n }\n\n this.selectedEvent = event;\n this.setSelectedEventId?.(event.event_id);\n this.persistEventSelection(event.event_id);\n // Reset the user cleared flag when selecting an event\n this.userClearedEventRef = false;\n } else {\n this.selectedEvent = null;\n this.setSelectedEventId?.(null);\n // Clear both sessionStorage and localStorage\n sessionStorage.removeItem('pace-core-selected-event');\n localStorage.removeItem('pace-core-selected-event');\n // Reset the auto-selection flag when clearing the event\n this.hasAutoSelectedRef = false;\n // Mark that user explicitly cleared the event to prevent auto-selection\n this.userClearedEventRef = true;\n }\n this.notify();\n }\n\n async refreshEvents(): Promise<void> {\n this.isInitializedRef = false;\n this.isFetchingRef = false;\n // Don't reset the user cleared flag - respect user's choice\n await this.fetchEvents();\n }\n\n async loadPersistedEvent(events: Event[]): Promise<boolean> {\n try {\n // Try sessionStorage first (tab-specific)\n let persistedEventId = sessionStorage.getItem('pace-core-selected-event');\n \n // Fallback to localStorage if no sessionStorage value (for new tabs)\n if (!persistedEventId) {\n persistedEventId = localStorage.getItem('pace-core-selected-event');\n // If we found a value in localStorage, also store it in sessionStorage for this tab\n if (persistedEventId) {\n sessionStorage.setItem('pace-core-selected-event', persistedEventId);\n }\n }\n \n if (persistedEventId && events.length > 0) {\n const persistedEvent = events.find(event => event.event_id === persistedEventId);\n if (persistedEvent) {\n this.selectedEvent = persistedEvent;\n this.setSelectedEventId?.(persistedEventId);\n return true;\n } else {\n // Clear invalid persisted event\n sessionStorage.removeItem('pace-core-selected-event');\n localStorage.removeItem('pace-core-selected-event');\n }\n }\n } catch (error) {\n console.warn('[EventService] Failed to load persisted event:', error);\n }\n return false;\n }\n\n persistEventSelection(eventId: string): void {\n try {\n // Store in sessionStorage for tab-specific persistence\n sessionStorage.setItem('pace-core-selected-event', eventId);\n // Also store in localStorage as fallback for new tabs\n localStorage.setItem('pace-core-selected-event', eventId);\n } catch (error) {\n console.warn('[EventService] Failed to persist event selection:', error);\n }\n }\n\n clearEventSelection(): void {\n try {\n // Clear from both storage locations\n sessionStorage.removeItem('pace-core-selected-event');\n localStorage.removeItem('pace-core-selected-event');\n // Clear the selected event\n this.selectedEvent = null;\n this.setSelectedEventId?.(null);\n } catch (error) {\n console.warn('[EventService] Failed to clear event selection:', error);\n }\n }\n\n autoSelectNextEvent(events: Event[]): void {\n const nextEvent = this.getNextEventByDate(events);\n if (nextEvent) {\n this.selectedEvent = nextEvent;\n this.setSelectedEventId?.(nextEvent.event_id);\n this.persistEventSelection(nextEvent.event_id);\n }\n }\n\n // Lifecycle methods\n async initialize(): Promise<void> {\n await super.initialize();\n await this.fetchEvents();\n }\n\n cleanup(): void {\n super.cleanup();\n }\n\n protected async doInitialize(): Promise<void> {\n // Initial setup - fetch events on initialization\n await this.fetchEvents();\n }\n\n protected doCleanup(): void {\n // Cleanup any resources\n }\n\n private async fetchEvents(): Promise<void> {\n if (!this.user || !this.session || !this.supabaseClient || !this.appName || !this.selectedOrganisation) {\n // Already false from initialization, just notify\n this.notify();\n return;\n }\n \n // Only set loading to true if we actually have dependencies and are going to fetch\n this._isLoading = true;\n this.notify();\n\n // Prevent multiple simultaneous fetches\n if (this.isFetchingRef) {\n return;\n }\n\n this.isFetchingRef = true;\n let isMounted = true;\n\n try {\n // Call the RPC function following the established pattern\n const { data, error: rpcError } = await this.supabaseClient.rpc('data_user_events_get', {\n p_user_id: this.user.id,\n p_organisation_id: this.selectedOrganisation.id,\n p_app_name: this.appName\n });\n\n if (rpcError) {\n throw new Error(rpcError.message || 'Failed to fetch events');\n }\n\n if (isMounted) {\n const eventsData = data || [];\n console.log('[EventService] Loaded events:', eventsData.map((event: any) => ({\n eventId: event.event_id,\n eventName: event.event_name,\n organisationId: event.organisation_id,\n selectedOrganisationId: this.selectedOrganisation?.id\n })));\n\n // Transform the data to match our Event interface\n const transformedEvents: Event[] = eventsData.map((event: any) => ({\n id: event.event_id, // Use event_id as the primary id\n event_id: event.event_id,\n event_name: event.event_name,\n event_date: event.event_date,\n event_venue: event.event_venue,\n event_participants: event.event_participants,\n event_colours: event.event_colours,\n event_logo: '', // No logo field in event table\n organisation_id: event.organisation_id,\n is_visible: event.is_visible,\n // Legacy compatibility\n name: event.event_name,\n start_date: event.event_date\n }));\n\n this.events = transformedEvents;\n this.error = null;\n\n // Reset auto-selection ref for new events\n this.hasAutoSelectedRef = false;\n\n // Try to restore persisted event first\n const persistedEventLoaded = await this.loadPersistedEvent(transformedEvents);\n \n // If no persisted event was loaded and user hasn't explicitly cleared an event, auto-select the next event\n if (!persistedEventLoaded && !this.userClearedEventRef) {\n const nextEvent = this.getNextEventByDate(transformedEvents);\n if (nextEvent) {\n this.hasAutoSelectedRef = true;\n this.selectedEvent = nextEvent;\n this.setSelectedEventId?.(nextEvent.event_id);\n this.persistEventSelection(nextEvent.event_id);\n }\n }\n }\n } catch (err) {\n console.error('[EventService] Error fetching events:', err);\n const _error = err instanceof Error ? err : new Error('Unknown error occurred');\n \n if (isMounted) {\n this.error = _error;\n this.events = [];\n }\n } finally {\n if (isMounted) {\n this._isLoading = false;\n }\n this.isFetchingRef = false;\n this.notify();\n }\n }\n\n getNextEventByDate(events?: Event[]): Event | null {\n const eventsToUse = events || this.events;\n if (!eventsToUse || eventsToUse.length === 0) {\n return null;\n }\n\n const now = new Date();\n const futureEvents = eventsToUse.filter(event => {\n if (!event.event_date) return false;\n const eventDate = new Date(event.event_date);\n return eventDate >= now;\n });\n\n if (futureEvents.length === 0) {\n return null;\n }\n\n // Sort by date (ascending) to get the next event\n const sortedFutureEvents = futureEvents.sort((a, b) => {\n const dateA = new Date(a.event_date!);\n const dateB = new Date(b.event_date!);\n return dateA.getTime() - dateB.getTime();\n });\n\n return sortedFutureEvents[0];\n }\n}","/**\n * @file Event Service Provider\n * @package @jmruthers/pace-core\n * @module Providers/Services\n * @since 0.1.0\n *\n * React provider for EventService.\n * Provides event service instance to React components.\n */\n\nimport React, { createContext, useContext, useMemo, useEffect, useRef } from 'react';\nimport { type SupabaseClient, type User, type Session } from '@supabase/supabase-js';\nimport { EventService } from '../../services/EventService';\n\n// Context type\nexport interface EventServiceContextType {\n eventService: EventService;\n}\n\n// Backward compatibility type alias\nexport type EventContextType = EventServiceContextType;\n\nexport const EventServiceContext = createContext<EventServiceContextType | null>(null);\n\nexport interface EventServiceProviderProps {\n children: React.ReactNode;\n supabaseClient: SupabaseClient;\n user: User | null;\n session: Session | null;\n appName: string;\n selectedOrganisation: any;\n setSelectedEventId: (eventId: string | null) => void;\n}\n\nexport function EventServiceProvider({ \n children, \n supabaseClient, \n user, \n session, \n appName,\n selectedOrganisation,\n setSelectedEventId\n}: EventServiceProviderProps) {\n // Create service instance once with useRef to avoid recreation on dependency changes\n const eventServiceRef = useRef<EventService | null>(null);\n \n if (!eventServiceRef.current) {\n eventServiceRef.current = new EventService(supabaseClient, user, session, appName, selectedOrganisation, setSelectedEventId);\n }\n \n const eventService = eventServiceRef.current;\n\n // Update service dependencies and initialize when dependencies change\n useEffect(() => {\n eventService.updateDependencies(supabaseClient, user, session, appName, selectedOrganisation, setSelectedEventId);\n \n // Re-initialize service when dependencies change\n let isMounted = true;\n \n eventService.initialize().catch(error => {\n if (isMounted) {\n console.error('[EventServiceProvider] Failed to initialize event service:', error);\n }\n });\n\n return () => {\n isMounted = false;\n };\n }, [eventService, supabaseClient, user, session, appName, selectedOrganisation, setSelectedEventId]);\n\n const contextValue = useMemo(() => ({\n eventService\n }), [eventService]);\n\n return (\n <EventServiceContext.Provider value={contextValue}>\n {children}\n </EventServiceContext.Provider>\n );\n}\n\nexport const useEventService = (): EventService => {\n const context = useContext(EventServiceContext);\n \n if (!context) {\n throw new Error('useEventService must be used within EventServiceProvider');\n }\n \n return context.eventService;\n};","/**\n * @file Inactivity Service\n * @package @jmruthers/pace-core\n * @module Services\n * @since 0.1.0\n *\n * Inactivity service implementation.\n * Handles inactivity tracking, auto-logout, and warning modals.\n */\n\nimport { BaseService } from './base/BaseService';\nimport { IInactivityService } from './interfaces/IInactivityService';\n\nexport class InactivityService extends BaseService implements IInactivityService {\n private _showInactivityWarning = false;\n private _inactivityTimeRemaining = 0;\n private _isIdle = false;\n private _timeRemaining = 0;\n private _showWarning = false;\n private _isTracking = false;\n\n // Dependencies\n private supabaseClient: any = null;\n private user: any = null;\n private session: any = null;\n private idleTimeoutMs = 30 * 60 * 1000; // 30 minutes\n private warnBeforeMs = 60 * 1000; // 60 seconds\n private onIdleLogout: ((reason: 'inactivity') => void) | null = null;\n\n // Internal state management\n private inactivityTracker: any = null;\n private isInactivityEnabled = true;\n\n constructor(\n supabaseClient: any,\n user: any,\n session: any,\n idleTimeoutMs: number = 30 * 60 * 1000,\n warnBeforeMs: number = 60 * 1000,\n onIdleLogout: (reason: 'inactivity') => void\n ) {\n super();\n this.supabaseClient = supabaseClient;\n this.user = user;\n this.session = session;\n this.idleTimeoutMs = idleTimeoutMs;\n this.warnBeforeMs = warnBeforeMs;\n this.onIdleLogout = onIdleLogout;\n \n // Initialize time remaining to idle timeout\n this._timeRemaining = idleTimeoutMs;\n }\n\n // Interface implementation\n isIdle(): boolean { return this._isIdle; }\n getTimeRemaining(): number { return this._timeRemaining; }\n isWarningShown(): boolean { return this._showWarning; }\n isTracking(): boolean { return this._isTracking; }\n getShowInactivityWarning(): boolean { return this._showInactivityWarning; }\n getInactivityTimeRemaining(): number { return this._inactivityTimeRemaining; }\n\n // Additional getter methods that tests expect\n getIsIdle(): boolean { return this._isIdle; }\n getIsTracking(): boolean { return this._isTracking; }\n getShowWarning(): boolean { return this._showWarning; }\n\n // Additional methods for testing\n setShowInactivityWarning(value: boolean): void {\n this._showInactivityWarning = value;\n this.notify();\n }\n\n setInactivityTimeRemaining(value: number): void {\n this._inactivityTimeRemaining = value;\n this.notify();\n }\n\n setIsIdle(value: boolean): void {\n this._isIdle = value;\n this.notify();\n }\n\n setTimeRemaining(value: number): void {\n this._timeRemaining = value;\n this.notify();\n }\n\n setShowWarning(value: boolean): void {\n this._showWarning = value;\n this.notify();\n }\n\n setIsTracking(value: boolean): void {\n this._isTracking = value;\n this.notify();\n }\n\n triggerWarning(timeRemaining: number): void {\n this._showInactivityWarning = true;\n this._inactivityTimeRemaining = Math.ceil(timeRemaining / 1000);\n this._showWarning = true;\n this.notify();\n }\n\n triggerIdle(): void {\n this._isIdle = true;\n this.handleIdleLogout();\n this.notify();\n }\n\n // Update dependencies\n updateDependencies(\n supabaseClient: any,\n user: any,\n session: any,\n idleTimeoutMs?: number,\n warnBeforeMs?: number,\n onIdleLogout?: (reason: 'inactivity') => void\n ): void {\n this.supabaseClient = supabaseClient;\n this.user = user;\n this.session = session;\n if (idleTimeoutMs !== undefined) this.idleTimeoutMs = idleTimeoutMs;\n if (warnBeforeMs !== undefined) this.warnBeforeMs = warnBeforeMs;\n if (onIdleLogout !== undefined) this.onIdleLogout = onIdleLogout;\n this.notify();\n }\n\n // Inactivity methods\n resetActivity(): void {\n if (this.inactivityTracker) {\n this.inactivityTracker.resetActivity();\n }\n this._isIdle = false;\n this._showWarning = false;\n this._showInactivityWarning = false;\n this._inactivityTimeRemaining = 0;\n this._timeRemaining = this.idleTimeoutMs;\n this.notify();\n }\n\n startTracking(): void {\n if (this.inactivityTracker) {\n this.inactivityTracker.startTracking();\n }\n this._isTracking = true;\n this.notify();\n }\n\n stopTracking(): void {\n if (this.inactivityTracker) {\n this.inactivityTracker.stopTracking();\n }\n this._isTracking = false;\n this.notify();\n }\n\n async handleIdleLogout(): Promise<void> {\n // Hide warning\n this._showInactivityWarning = false;\n this._inactivityTimeRemaining = 0;\n \n // Stop tracking\n this.stopTracking();\n \n // Sign out via Supabase\n try {\n if (this.supabaseClient) {\n await this.supabaseClient.auth.signOut();\n }\n } catch (error: any) {\n console.error('[InactivityService] Error during idle logout:', error);\n }\n \n // Call app callback for navigation/redirect\n this.onIdleLogout?.('inactivity');\n this.notify();\n }\n\n handleStaySignedIn(): void {\n this._showInactivityWarning = false;\n this._inactivityTimeRemaining = 0;\n this.resetActivity();\n this.notify();\n }\n\n async handleSignOutNow(): Promise<void> {\n this._showInactivityWarning = false;\n this._inactivityTimeRemaining = 0;\n this.stopTracking();\n \n // Sign out via Supabase\n try {\n if (this.supabaseClient) {\n await this.supabaseClient.auth.signOut();\n }\n } catch (error: any) {\n console.error('[InactivityService] Error during manual sign out:', error);\n }\n \n // Call app callback for navigation/redirect\n this.onIdleLogout?.('inactivity');\n this.notify();\n }\n\n // Lifecycle methods\n async initialize(): Promise<void> {\n await super.initialize();\n await this.setupInactivityTracker();\n }\n\n cleanup(): void {\n if (this.inactivityTracker) {\n this.inactivityTracker.cleanup?.();\n this.inactivityTracker = null;\n }\n this._isTracking = false;\n this._isIdle = false;\n this._showWarning = false;\n this._showInactivityWarning = false;\n this._timeRemaining = 0;\n this._inactivityTimeRemaining = 0;\n super.cleanup();\n }\n\n protected async doInitialize(): Promise<void> {\n // Production safety check for inactivity feature\n if (typeof window !== 'undefined') {\n const isProduction = import.meta.env.MODE === 'production';\n \n if (isProduction) {\n console.warn('[InactivityService] Inactivity feature enabled in production');\n }\n }\n }\n\n protected doCleanup(): void {\n // Cleanup any resources\n }\n\n private async setupInactivityTracker(): Promise<void> {\n if (typeof window === 'undefined') return;\n\n // Check if inactivity is enabled\n this.isInactivityEnabled = this.user && this.session;\n\n if (!this.isInactivityEnabled) {\n return;\n }\n\n try {\n // Dynamically import the inactivity tracker hook\n const { useInactivityTracker } = await import('../hooks/useInactivityTracker');\n \n // Create a mock implementation since we can't use hooks in services\n // In a real implementation, you'd need to create a non-hook version\n this.inactivityTracker = {\n isIdle: false,\n timeRemaining: 0,\n showWarning: false,\n isTracking: false,\n resetActivity: () => {\n this._isIdle = false;\n this._timeRemaining = 0;\n this._showWarning = false;\n this.notify();\n },\n startTracking: () => {\n this._isTracking = true;\n this.notify();\n },\n stopTracking: () => {\n this._isTracking = false;\n this.notify();\n },\n cleanup: () => {\n this._isTracking = false;\n this._isIdle = false;\n this._showWarning = false;\n this._timeRemaining = 0;\n }\n };\n\n // Set up event handlers\n this.setupEventHandlers();\n } catch (error) {\n console.error('[InactivityService] Failed to setup inactivity tracker:', error);\n }\n }\n\n private setupEventHandlers(): void {\n if (typeof window === 'undefined') return;\n\n let idleTimer: NodeJS.Timeout | null = null;\n let warningTimer: NodeJS.Timeout | null = null;\n let lastActivity = Date.now();\n\n const resetTimers = () => {\n lastActivity = Date.now();\n \n if (idleTimer) {\n clearTimeout(idleTimer);\n idleTimer = null;\n }\n \n if (warningTimer) {\n clearTimeout(warningTimer);\n warningTimer = null;\n }\n\n this._showInactivityWarning = false;\n this._inactivityTimeRemaining = 0;\n this._isIdle = false;\n this._showWarning = false;\n this.notify();\n };\n\n const startIdleTimer = () => {\n if (idleTimer) {\n clearTimeout(idleTimer);\n }\n\n idleTimer = setTimeout(() => {\n this._isIdle = true;\n this._showWarning = true;\n this.notify();\n \n // Start warning timer\n warningTimer = setTimeout(() => {\n this.handleIdleLogout();\n }, this.warnBeforeMs);\n }, this.idleTimeoutMs - this.warnBeforeMs);\n };\n\n const startWarningTimer = () => {\n if (warningTimer) {\n clearTimeout(warningTimer);\n }\n\n warningTimer = setTimeout(() => {\n this.handleIdleLogout();\n }, this.warnBeforeMs);\n };\n\n // Activity detection\n const activityEvents = ['mousedown', 'mousemove', 'keypress', 'scroll', 'touchstart', 'click'];\n \n const handleActivity = () => {\n resetTimers();\n startIdleTimer();\n };\n\n // Add event listeners\n activityEvents.forEach(event => {\n document.addEventListener(event, handleActivity, true);\n });\n\n // Start initial timer\n startIdleTimer();\n\n // Store cleanup function\n this.inactivityTracker.cleanup = () => {\n if (idleTimer) {\n clearTimeout(idleTimer);\n idleTimer = null;\n }\n \n if (warningTimer) {\n clearTimeout(warningTimer);\n warningTimer = null;\n }\n\n activityEvents.forEach(event => {\n document.removeEventListener(event, handleActivity, true);\n });\n\n this._isTracking = false;\n this._isIdle = false;\n this._showWarning = false;\n this._timeRemaining = 0;\n this._showInactivityWarning = false;\n this._inactivityTimeRemaining = 0;\n };\n\n this._isTracking = true;\n this.notify();\n }\n}","/**\n * @file Inactivity Service Provider\n * @package @jmruthers/pace-core\n * @module Providers/Services\n * @since 0.1.0\n *\n * React provider for InactivityService.\n * Provides inactivity service instance to React components.\n */\n\nimport React, { createContext, useContext, useMemo, useEffect, useRef } from 'react';\nimport { type SupabaseClient, type User, type Session } from '@supabase/supabase-js';\nimport { InactivityService } from '../../services/InactivityService';\n\n// Context type\nexport interface InactivityServiceContextType {\n inactivityService: InactivityService;\n}\n\nexport const InactivityServiceContext = createContext<InactivityServiceContextType | null>(null);\n\nexport interface InactivityServiceProviderProps {\n children: React.ReactNode;\n supabaseClient: SupabaseClient;\n user: User | null;\n session: Session | null;\n idleTimeoutMs?: number;\n warnBeforeMs?: number;\n onIdleLogout: (reason: 'inactivity') => void;\n}\n\nexport function InactivityServiceProvider({ \n children, \n supabaseClient, \n user, \n session, \n idleTimeoutMs = 30 * 60 * 1000,\n warnBeforeMs = 60 * 1000,\n onIdleLogout\n}: InactivityServiceProviderProps) {\n // Create service instance once with useRef to avoid recreation on dependency changes\n const inactivityServiceRef = useRef<InactivityService | null>(null);\n \n if (!inactivityServiceRef.current) {\n inactivityServiceRef.current = new InactivityService(supabaseClient, user, session, idleTimeoutMs, warnBeforeMs, onIdleLogout);\n }\n \n const inactivityService = inactivityServiceRef.current;\n\n // Update service dependencies and initialize when dependencies change\n useEffect(() => {\n inactivityService.updateDependencies(supabaseClient, user, session, idleTimeoutMs, warnBeforeMs, onIdleLogout);\n \n // Re-initialize service when dependencies change\n let isMounted = true;\n \n inactivityService.initialize().catch(error => {\n if (isMounted) {\n console.error('[InactivityServiceProvider] Failed to initialize inactivity service:', error);\n }\n });\n\n return () => {\n isMounted = false;\n };\n }, [inactivityService, supabaseClient, user, session, idleTimeoutMs, warnBeforeMs, onIdleLogout]);\n\n const contextValue = useMemo(() => ({\n inactivityService\n }), [inactivityService]);\n\n return (\n <InactivityServiceContext.Provider value={contextValue}>\n {children}\n </InactivityServiceContext.Provider>\n );\n}\n\nexport const useInactivityService = (): InactivityService => {\n const context = useContext(InactivityServiceContext);\n \n if (!context) {\n throw new Error('useInactivityService must be used within InactivityServiceProvider');\n }\n \n return context.inactivityService;\n};","/**\n * @file Auth Service Hook\n * @package @jmruthers/pace-core\n * @module Hooks/Services\n * @since 0.1.0\n *\n * React hook for AuthService.\n * Provides authentication service with reactive state updates.\n */\n\nimport { useContext, useReducer, useEffect } from 'react';\nimport { AuthServiceContext } from '../../providers/services/AuthServiceProvider';\nimport { AuthService } from '../../services/AuthService';\n\nexport function useAuthService(): AuthService {\n const context = useContext(AuthServiceContext);\n \n if (!context) {\n throw new Error('useAuthService must be used within AuthServiceProvider');\n }\n \n // Subscribe to service state changes\n const [, forceUpdate] = useReducer(x => x + 1, 0);\n \n useEffect(() => {\n return context.authService.subscribe(() => forceUpdate());\n }, [context.authService]);\n \n return context.authService;\n}","/**\n * @file Organisation Service Hook\n * @package @jmruthers/pace-core\n * @module Hooks/Services\n * @since 0.1.0\n *\n * React hook for OrganisationService.\n * Provides organisation service with reactive state updates.\n */\n\nimport { useContext, useReducer, useEffect } from 'react';\nimport { OrganisationServiceContext } from '../../providers/services/OrganisationServiceProvider';\nimport { OrganisationService } from '../../services/OrganisationService';\n\nexport function useOrganisationService(): OrganisationService {\n const context = useContext(OrganisationServiceContext);\n \n if (!context) {\n throw new Error('useOrganisationService must be used within OrganisationServiceProvider');\n }\n \n // Subscribe to service state changes\n const [, forceUpdate] = useReducer(x => x + 1, 0);\n \n useEffect(() => {\n return context.organisationService.subscribe(() => forceUpdate());\n }, [context.organisationService]);\n \n return context.organisationService;\n}","/**\n * @file Event Service Hook\n * @package @jmruthers/pace-core\n * @module Hooks/Services\n * @since 0.1.0\n *\n * React hook for EventService.\n * Provides event service with reactive state updates.\n */\n\nimport { useContext, useReducer, useEffect } from 'react';\nimport { EventServiceContext } from '../../providers/services/EventServiceProvider';\nimport { EventService } from '../../services/EventService';\n\nexport function useEventService(): EventService {\n const context = useContext(EventServiceContext);\n \n if (!context) {\n throw new Error('useEventService must be used within EventServiceProvider');\n }\n \n // Subscribe to service state changes\n const [, forceUpdate] = useReducer(x => x + 1, 0);\n \n useEffect(() => {\n return context.eventService.subscribe(() => forceUpdate());\n }, [context.eventService]);\n \n return context.eventService;\n}","/**\n * @file Inactivity Service Hook\n * @package @jmruthers/pace-core\n * @module Hooks/Services\n * @since 0.1.0\n *\n * React hook for InactivityService.\n * Provides inactivity service with reactive state updates.\n */\n\nimport { useContext, useReducer, useEffect } from 'react';\nimport { InactivityServiceContext } from '../../providers/services/InactivityServiceProvider';\nimport { InactivityService } from '../../services/InactivityService';\n\nexport function useInactivityService(): InactivityService {\n const context = useContext(InactivityServiceContext);\n \n if (!context) {\n throw new Error('useInactivityService must be used within InactivityServiceProvider');\n }\n \n // Subscribe to service state changes\n const [, forceUpdate] = useReducer(x => x + 1, 0);\n \n useEffect(() => {\n return context.inactivityService.subscribe(() => forceUpdate());\n }, [context.inactivityService]);\n \n return context.inactivityService;\n}","/**\n * @file Unified Auth Provider\n * @package @jmruthers/pace-core\n * @module Providers/Services\n * @since 0.1.0\n *\n * Unified authentication provider for authentication, organisations, events, and inactivity tracking.\n * Note: RBAC functionality is available via useRBAC() hook from '@jmruthers/pace-core/rbac'\n */\n\nimport React, { createContext, useContext, useMemo } from 'react';\nimport { type SupabaseClient, type User, type Session } from '@supabase/supabase-js';\nimport { AuthServiceProvider } from './AuthServiceProvider';\nimport { OrganisationServiceProvider } from './OrganisationServiceProvider';\nimport { EventServiceProvider } from './EventServiceProvider';\nimport { InactivityServiceProvider } from './InactivityServiceProvider';\nimport { useAuthService } from '../../hooks/services/useAuthService';\nimport { useOrganisationService } from '../../hooks/services/useOrganisationService';\nimport { useEventService } from '../../hooks/services/useEventService';\nimport { useInactivityService } from '../../hooks/services/useInactivityService';\nimport type { Organisation, OrganisationMembership } from '../../types/organisation';\nimport type { Event } from '../../types/unified';\nimport type { AuthError } from '@supabase/supabase-js';\n\n// Re-export UserEventAccess type\nexport interface UserEventAccess {\n event_id: string;\n event_name: string;\n event_description?: string | null;\n start_date: string;\n end_date: string;\n event_status: string;\n app_id: string;\n access_level: string;\n granted_at: string;\n organisation_id: string;\n}\n\n// Combined context type - focuses on auth, organisations, events, and inactivity\nexport interface UnifiedAuthContextType {\n // Auth state\n user: User | null;\n session: Session | null;\n isAuthenticated: boolean;\n authLoading: boolean;\n authError: AuthError | null;\n error: AuthError | null; // Alias for authError for backward compatibility\n supabase: SupabaseClient | null;\n \n // Auth methods\n signIn: (email: string, password?: string) => Promise<{ error: AuthError | null }>;\n signUp: (email: string, password: string) => Promise<{ error: AuthError | null }>;\n signOut: () => Promise<{ error: AuthError | null }>;\n resetPassword: (email: string) => Promise<{ error: AuthError | null }>;\n updatePassword: (password: string) => Promise<{ error: AuthError | null }>;\n refreshSession: () => Promise<{ error: AuthError | null }>;\n\n // Organisation state\n selectedOrganisation: Organisation | null;\n organisations: Organisation[];\n userMemberships: OrganisationMembership[];\n organisationLoading: boolean;\n organisationError: Error | null;\n hasValidOrganisationContext: boolean;\n isContextReady: boolean;\n \n // Organisation methods\n switchOrganisation: (orgId: string) => Promise<void>;\n getUserRole: (orgId?: string) => string;\n validateOrganisationAccess: (orgId: string) => boolean;\n refreshOrganisations: () => Promise<void>;\n ensureOrganisationContext: () => Organisation;\n isOrganisationSecure: () => boolean;\n getPrimaryOrganisation: () => Organisation | null;\n\n // Event state\n events: Event[];\n selectedEvent: Event | null;\n eventLoading: boolean;\n eventError: Error | null;\n \n // Event methods\n setSelectedEvent: (event: Event | null) => void;\n refreshEvents: () => Promise<void>;\n\n // Inactivity state\n showInactivityWarning: boolean;\n inactivityTimeRemaining: number;\n isIdle: boolean;\n timeRemaining: number;\n showWarning: boolean;\n isTracking: boolean;\n \n // Inactivity methods\n resetActivity: () => void;\n startTracking: () => void;\n stopTracking: () => void;\n handleIdleLogout: () => Promise<void>;\n handleStaySignedIn: () => void;\n handleSignOutNow: () => Promise<void>;\n\n // Additional unified properties\n appName: string;\n appConfig: { requires_event: boolean } | null;\n isLoading: boolean;\n hasErrors: boolean;\n}\n\nconst UnifiedAuthContext = createContext<UnifiedAuthContextType | undefined>(undefined);\n\nexport const useUnifiedAuth = () => {\n const context = useContext(UnifiedAuthContext);\n if (!context) {\n throw new Error('useUnifiedAuth must be used within a UnifiedAuthProvider');\n }\n return context;\n};\n\nexport interface UnifiedAuthProviderProps {\n children: React.ReactNode;\n supabaseClient: SupabaseClient;\n appName: string;\n persistState?: boolean;\n enablePersistence?: boolean;\n requireOrganisationContext?: boolean;\n \n // App configuration\n appConfig?: { requires_event: boolean } | null;\n \n // Inactivity auto-logout configuration - MANDATORY for security\n idleTimeoutMs: number; // REQUIRED: Inactivity timeout in milliseconds\n warnBeforeMs: number; // REQUIRED: Warning time before logout in milliseconds\n onIdleLogout: (reason: 'inactivity') => void; // REQUIRED: App handles redirect/navigation\n renderInactivityWarning?: (args: {\n timeRemaining: number;\n onStaySignedIn: () => void;\n onSignOutNow: () => void;\n }) => React.ReactNode; // Optional custom warning UI\n dangerouslyDisableInactivity?: boolean; // Dev-only; must not disable in production\n}\n\n// Internal component that combines all contexts\nfunction UnifiedAuthContextProvider({ \n children, \n appName,\n appConfig = { requires_event: true }, // Default to requiring events\n ...props \n}: UnifiedAuthProviderProps) {\n const authService = useAuthService();\n const organisationService = useOrganisationService();\n const inactivityService = useInactivityService();\n \n // Try to get event service, but provide fallback if not available\n let eventService;\n try {\n eventService = useEventService();\n } catch (error) {\n // EventService not available - provide fallback implementation\n eventService = {\n getEvents: () => [],\n getSelectedEvent: () => null,\n isLoading: () => false,\n getError: () => null,\n setSelectedEvent: () => {},\n refreshEvents: async () => {}\n };\n }\n\n // Get current auth state - these will trigger re-renders when services change\n const currentUser = authService.getUser();\n const currentSession = authService.getSession();\n const isAuth = !!(currentUser && currentSession);\n \n // Get loading states - these will trigger re-renders when services change\n const authLoading = authService.isLoading();\n const orgLoading = organisationService.isLoading();\n const eventLoading = eventService.isLoading();\n const totalLoading = authLoading || orgLoading || eventLoading;\n \n // Log auth state for debugging with detailed loading states\n console.log('[UnifiedAuthContext] Auth state:', {\n isAuthenticated: isAuth,\n user: currentUser?.email,\n session: currentSession ? 'exists' : 'null',\n totalLoading,\n authLoading,\n orgLoading,\n eventLoading,\n orgContextReady: organisationService.isContextReady()\n });\n \n // Memoized combined context value\n const contextValue = useMemo<UnifiedAuthContextType>(() => {\n return {\n // Auth state\n user: currentUser,\n session: currentSession,\n isAuthenticated: isAuth,\n authLoading: authLoading,\n authError: authService.getError(),\n error: authService.getError(), // Alias for backward compatibility\n supabase: authService.getSupabaseClient(),\n \n // Auth methods\n signIn: authService.signIn.bind(authService),\n signUp: authService.signUp.bind(authService),\n signOut: authService.signOut.bind(authService),\n resetPassword: authService.resetPassword.bind(authService),\n updatePassword: authService.updatePassword.bind(authService),\n refreshSession: authService.refreshSession.bind(authService),\n\n // Organisation state\n selectedOrganisation: organisationService.getSelectedOrganisation(),\n organisations: organisationService.getOrganisations(),\n userMemberships: organisationService.getUserMemberships(),\n organisationLoading: orgLoading,\n organisationError: organisationService.getError(),\n hasValidOrganisationContext: organisationService.hasValidOrganisationContext(),\n isContextReady: organisationService.isContextReady(),\n \n // Organisation methods\n switchOrganisation: organisationService.switchOrganisation.bind(organisationService),\n getUserRole: organisationService.getUserRole.bind(organisationService),\n validateOrganisationAccess: organisationService.validateOrganisationAccess.bind(organisationService),\n refreshOrganisations: organisationService.refreshOrganisations.bind(organisationService),\n ensureOrganisationContext: organisationService.ensureOrganisationContext.bind(organisationService),\n isOrganisationSecure: organisationService.isOrganisationSecure.bind(organisationService),\n getPrimaryOrganisation: organisationService.getPrimaryOrganisation.bind(organisationService),\n\n // Event state\n events: eventService.getEvents(),\n selectedEvent: eventService.getSelectedEvent(),\n eventLoading: eventLoading,\n eventError: eventService.getError(),\n \n // Event methods\n setSelectedEvent: eventService.setSelectedEvent.bind(eventService),\n refreshEvents: eventService.refreshEvents.bind(eventService),\n\n // Inactivity state\n showInactivityWarning: inactivityService.getShowInactivityWarning(),\n inactivityTimeRemaining: inactivityService.getInactivityTimeRemaining(),\n isIdle: inactivityService.isIdle(),\n timeRemaining: inactivityService.getTimeRemaining(),\n showWarning: inactivityService.isWarningShown(),\n isTracking: inactivityService.isTracking(),\n \n // Inactivity methods\n resetActivity: inactivityService.resetActivity.bind(inactivityService),\n startTracking: inactivityService.startTracking.bind(inactivityService),\n stopTracking: inactivityService.stopTracking.bind(inactivityService),\n handleIdleLogout: inactivityService.handleIdleLogout.bind(inactivityService),\n handleStaySignedIn: inactivityService.handleStaySignedIn.bind(inactivityService),\n handleSignOutNow: inactivityService.handleSignOutNow.bind(inactivityService),\n\n // Additional unified properties\n appName,\n appConfig: appConfig,\n isLoading: totalLoading,\n hasErrors: !!(authService.getError() || organisationService.getError() || eventService.getError()),\n };\n }, [authService, organisationService, eventService, inactivityService, appName, appConfig, currentUser, currentSession, isAuth, authLoading, orgLoading, eventLoading, totalLoading]);\n\n return (\n <UnifiedAuthContext.Provider value={contextValue}>\n {children}\n </UnifiedAuthContext.Provider>\n );\n}\n\n// Wrapper for EventServiceProvider that reads selectedOrganisation from OrganisationService\nfunction EventServiceProviderWrapper({ \n children, \n supabaseClient,\n user,\n session,\n appName\n}: {\n children: React.ReactNode;\n supabaseClient: SupabaseClient;\n user: User | null;\n session: Session | null;\n appName: string;\n}) {\n const organisationService = useOrganisationService();\n const selectedOrganisation = organisationService.getSelectedOrganisation();\n\n // Only render EventServiceProvider if user and session are available\n if (!user || !session) {\n return <>{children}</>;\n }\n\n return (\n <EventServiceProvider\n supabaseClient={supabaseClient}\n user={user}\n session={session}\n appName={appName}\n selectedOrganisation={selectedOrganisation}\n setSelectedEventId={() => {\n // Event selection is now handled at the application level\n }}\n >\n {children}\n </EventServiceProvider>\n );\n}\n\n// Internal component that provides user/session to child providers\nfunction ServiceAwareProviders({ \n children, \n supabaseClient,\n appName,\n appConfig,\n persistState,\n enablePersistence,\n requireOrganisationContext,\n idleTimeoutMs,\n warnBeforeMs,\n onIdleLogout,\n renderInactivityWarning,\n dangerouslyDisableInactivity\n}: UnifiedAuthProviderProps) {\n const authService = useAuthService();\n\n return (\n <OrganisationServiceProvider\n supabaseClient={supabaseClient}\n user={authService.getUser()}\n session={authService.getSession()}\n >\n <EventServiceProviderWrapper\n supabaseClient={supabaseClient}\n user={authService.getUser()}\n session={authService.getSession()}\n appName={appName}\n >\n <InactivityServiceProvider\n supabaseClient={supabaseClient}\n user={authService.getUser()}\n session={authService.getSession()}\n idleTimeoutMs={idleTimeoutMs}\n warnBeforeMs={warnBeforeMs}\n onIdleLogout={onIdleLogout}\n >\n <UnifiedAuthContextProvider\n appName={appName}\n appConfig={appConfig}\n supabaseClient={supabaseClient}\n persistState={persistState}\n enablePersistence={enablePersistence}\n requireOrganisationContext={requireOrganisationContext}\n idleTimeoutMs={idleTimeoutMs}\n warnBeforeMs={warnBeforeMs}\n onIdleLogout={onIdleLogout}\n renderInactivityWarning={renderInactivityWarning}\n dangerouslyDisableInactivity={dangerouslyDisableInactivity}\n >\n {children}\n </UnifiedAuthContextProvider>\n </InactivityServiceProvider>\n </EventServiceProviderWrapper>\n </OrganisationServiceProvider>\n );\n}\n\nexport function UnifiedAuthProvider({\n children,\n supabaseClient,\n appName,\n appConfig = { requires_event: true }, // Default to requiring events\n persistState = true,\n enablePersistence,\n requireOrganisationContext = true,\n idleTimeoutMs = 30 * 60 * 1000, // 30 minutes\n warnBeforeMs = 60 * 1000, // 60 seconds\n onIdleLogout,\n renderInactivityWarning,\n dangerouslyDisableInactivity = false\n}: UnifiedAuthProviderProps) {\n return (\n <AuthServiceProvider supabaseClient={supabaseClient}>\n <ServiceAwareProviders\n supabaseClient={supabaseClient}\n appName={appName}\n appConfig={appConfig}\n persistState={persistState}\n enablePersistence={enablePersistence}\n requireOrganisationContext={requireOrganisationContext}\n idleTimeoutMs={idleTimeoutMs}\n warnBeforeMs={warnBeforeMs}\n onIdleLogout={onIdleLogout}\n renderInactivityWarning={renderInactivityWarning}\n dangerouslyDisableInactivity={dangerouslyDisableInactivity}\n >\n {children}\n </ServiceAwareProviders>\n </AuthServiceProvider>\n );\n}\n"],"mappings":";;;;;;;;;AAAA,IAYsB;AAZtB;AAAA;AAAA;AAYO,IAAe,cAAf,MAA2B;AAAA,MAA3B;AACL,aAAQ,cAA0C,CAAC;AACnD,aAAQ,gBAAgB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAOxB,UAAU,UAA2C;AACnD,aAAK,YAAY,KAAK,QAAQ;AAG9B,eAAO,MAAM;AACX,gBAAM,QAAQ,KAAK,YAAY,QAAQ,QAAQ;AAC/C,cAAI,QAAQ,IAAI;AACd,iBAAK,YAAY,OAAO,OAAO,CAAC;AAAA,UAClC;AAAA,QACF;AAAA,MACF;AAAA;AAAA;AAAA;AAAA;AAAA,MAMU,SAAe;AACvB,aAAK,YAAY,QAAQ,cAAY;AACnC,cAAI;AACF,qBAAS;AAAA,UACX,SAAS,OAAO;AACd,oBAAQ,MAAM,+CAA+C,KAAK;AAAA,U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AAAA;AAAA,UACF;AAAA;AAAA,MACF;AAAA;AAAA,EACF;AAEJ;AAEO,SAAS,oBAAoB;AAAA,EAClC;AAAA,EACA;AAAA,EACA;AAAA,EACA,YAAY,EAAE,gBAAgB,KAAK;AAAA;AAAA,EACnC,eAAe;AAAA,EACf;AAAA,EACA,6BAA6B;AAAA,EAC7B,gBAAgB,KAAK,KAAK;AAAA;AAAA,EAC1B,eAAe,KAAK;AAAA;AAAA,EACpB;AAAA,EACA;AAAA,EACA,+BAA+B;AACjC,GAA6B;AAC3B,SACE,gBAAAA,KAAC,uBAAoB,gBACnB,0BAAAA;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MAEC;AAAA;AAAA,EACH,GACF;AAEJ;AA/YA,IA4GM,oBAEO;AA9Gb;AAAA;AAAA;AAYA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAyFA,IAAM,qBAAqBH,eAAkD,MAAS;AAE/E,IAAM,iBAAiB,MAAM;AAClC,YAAM,UAAUC,YAAW,kBAAkB;AAC7C,UAAI,CAAC,SAAS;AACZ,cAAM,IAAI,MAAM,0DAA0D;AAAA,MAC5E;AACA,aAAO;AAAA,IACT;AAAA;AAAA;","names":["createContext","useContext","useMemo","useEffect","jsx","createContext","useContext","useMemo","useEffect","useRef","jsx","createContext","useContext","useMemo","useEffect","useRef","jsx","useContext","useEffect","useAuthService","useContext","useReducer","useEffect","useOrganisationService","useContext","useReducer","useEffect","useEventService","useContext","useReducer","useEffect","useInactivityService","createContext","useContext","useMemo","jsx","useAuthService","useOrganisationService","useInactivityService","useEventService"]}
@@ -1,15 +1,15 @@
1
1
  import {
2
2
  init_OrganisationProvider,
3
3
  usePublicPageContext
4
- } from "./chunk-NKT2DLZI.js";
4
+ } from "./chunk-VSOKOFRF.js";
5
5
  import {
6
6
  init_useOrganisations,
7
7
  useEvents,
8
8
  useOrganisations
9
- } from "./chunk-CRKP3HXI.js";
9
+ } from "./chunk-FT2M4R4F.js";
10
10
  import {
11
11
  useUnifiedAuth
12
- } from "./chunk-JDQ7T3QB.js";
12
+ } from "./chunk-MNJXXD6C.js";
13
13
  import {
14
14
  applyPalette,
15
15
  clearPalette
@@ -699,4 +699,4 @@ export {
699
699
  generatePublicRoutePath,
700
700
  extractEventCodeFromPath
701
701
  };
702
- //# sourceMappingURL=chunk-LMYTEMUH.js.map
702
+ //# sourceMappingURL=chunk-PTR5PMPE.js.map
@@ -4,7 +4,7 @@ import {
4
4
  init_InactivityServiceProvider,
5
5
  init_OrganisationServiceProvider,
6
6
  init_UnifiedAuthProvider
7
- } from "./chunk-JDQ7T3QB.js";
7
+ } from "./chunk-MNJXXD6C.js";
8
8
 
9
9
  // src/providers/index.ts
10
10
  init_UnifiedAuthProvider();
@@ -12,4 +12,4 @@ init_EventServiceProvider();
12
12
  init_OrganisationServiceProvider();
13
13
  init_InactivityServiceProvider();
14
14
  init_AuthServiceProvider();
15
- //# sourceMappingURL=chunk-Z3T6RK3K.js.map
15
+ //# sourceMappingURL=chunk-QGVSOUJ2.js.map
@@ -1,17 +1,17 @@
1
1
  import {
2
2
  init_useOrganisations,
3
3
  useOrganisations
4
- } from "./chunk-CRKP3HXI.js";
4
+ } from "./chunk-FT2M4R4F.js";
5
5
  import {
6
6
  init_UnifiedAuthProvider
7
- } from "./chunk-DVHZ5L55.js";
7
+ } from "./chunk-FL4ZCQLD.js";
8
8
  import {
9
9
  OrganisationServiceContext,
10
10
  OrganisationServiceProvider,
11
11
  init_OrganisationServiceProvider,
12
12
  useOrganisationService,
13
13
  useUnifiedAuth
14
- } from "./chunk-JDQ7T3QB.js";
14
+ } from "./chunk-MNJXXD6C.js";
15
15
  import {
16
16
  __esm,
17
17
  __export
@@ -417,4 +417,4 @@ export {
417
417
  clearPublicLogoCache,
418
418
  getPublicLogoCacheStats
419
419
  };
420
- //# sourceMappingURL=chunk-NKT2DLZI.js.map
420
+ //# sourceMappingURL=chunk-VSOKOFRF.js.map