@axcode/axcloud-sdk 0.2.0-dev.03fb26c → 0.2.0-dev.85285e0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,344 +1,13 @@
1
1
  'use strict';
2
2
 
3
+ var chunkDI4M6A7K_js = require('./chunk-DI4M6A7K.js');
4
+ var chunkEX66R5IA_js = require('./chunk-EX66R5IA.js');
5
+ var chunkDSWRJZWR_js = require('./chunk-DSWRJZWR.js');
3
6
  var react = require('react');
4
7
  var auth0React = require('@auth0/auth0-react');
5
8
  var reactQuery = require('@tanstack/react-query');
6
9
  var jsxRuntime = require('react/jsx-runtime');
7
10
 
8
- // src/core/errors.ts
9
- var AxCloudError = class _AxCloudError extends Error {
10
- constructor(message, code, status, details) {
11
- super(message);
12
- this.name = "AxCloudError";
13
- this.code = code;
14
- this.status = status;
15
- this.details = details;
16
- const ErrorWithCapture = Error;
17
- if (ErrorWithCapture.captureStackTrace) {
18
- ErrorWithCapture.captureStackTrace(this, _AxCloudError);
19
- }
20
- }
21
- static fromResponse(status, body) {
22
- const details = typeof body === "object" ? body : void 0;
23
- const message = (typeof details?.message === "string" ? details.message : void 0) || (typeof details?.error === "string" ? details.error : void 0);
24
- switch (status) {
25
- case 401:
26
- return new _AxCloudError(
27
- message || "Authentication required",
28
- "UNAUTHORIZED",
29
- status,
30
- details
31
- );
32
- case 403:
33
- return new _AxCloudError(message || "Access denied", "FORBIDDEN", status, details);
34
- case 404:
35
- return new _AxCloudError(message || "Resource not found", "NOT_FOUND", status, details);
36
- case 422:
37
- return new _AxCloudError(
38
- message || "Validation failed",
39
- "VALIDATION_ERROR",
40
- status,
41
- details
42
- );
43
- default:
44
- if (status >= 500) {
45
- return new _AxCloudError(message || "Server error", "SERVER_ERROR", status, details);
46
- }
47
- return new _AxCloudError(message || "An error occurred", "UNKNOWN_ERROR", status, details);
48
- }
49
- }
50
- static networkError(originalError) {
51
- const isDev = typeof process !== "undefined" && process.env?.NODE_ENV === "development";
52
- const message = isDev && originalError?.message ? originalError.message : "Network request failed";
53
- return new _AxCloudError(
54
- message,
55
- "NETWORK_ERROR",
56
- 0,
57
- isDev ? { originalError: originalError?.message } : void 0
58
- );
59
- }
60
- static timeoutError(timeoutMs) {
61
- return new _AxCloudError(`Request timed out after ${timeoutMs}ms`, "TIMEOUT_ERROR", 0, {
62
- timeout: timeoutMs
63
- });
64
- }
65
- };
66
- function isAxCloudError(error) {
67
- return error instanceof AxCloudError;
68
- }
69
-
70
- // src/core/client.ts
71
- var AxCloudClient = class {
72
- constructor(config) {
73
- this.baseUrl = config.baseUrl.replace(/\/$/, "");
74
- this.getAccessToken = config.getAccessToken;
75
- this.apiKey = config.apiKey;
76
- this.defaultTimeout = config.timeout ?? 3e4;
77
- }
78
- /**
79
- * Update the access token getter (used when auth state changes)
80
- */
81
- setAccessTokenGetter(getter) {
82
- this.getAccessToken = getter;
83
- }
84
- /**
85
- * Build URL with query parameters
86
- */
87
- buildUrl(path, params) {
88
- const url = new URL(`${this.baseUrl}${path}`);
89
- if (params) {
90
- Object.entries(params).forEach(([key, value]) => {
91
- if (value !== void 0) {
92
- url.searchParams.append(key, String(value));
93
- }
94
- });
95
- }
96
- return url.toString();
97
- }
98
- /**
99
- * API key should only be sent to public endpoints.
100
- * This avoids leaking public keys to authenticated/internal routes.
101
- */
102
- shouldAttachApiKey(path) {
103
- const normalized = path.startsWith("/") ? path : `/${path}`;
104
- return normalized.startsWith("/public/") || normalized.startsWith("/api/public/") || normalized.startsWith("/content/public/") || normalized.startsWith("/media/public/") || normalized.startsWith("/documents/public/") || normalized.startsWith("/barnsport/public/") || normalized.startsWith("/api/barnsport/public/");
105
- }
106
- /**
107
- * Make an authenticated request
108
- */
109
- async request(path, options = {}) {
110
- const { body, params, headers: customHeaders, timeout, ...restOptions } = options;
111
- const headers = {
112
- "Content-Type": "application/json"
113
- };
114
- if (customHeaders) {
115
- const customHeadersRecord = customHeaders;
116
- Object.assign(headers, customHeadersRecord);
117
- }
118
- if (this.apiKey && this.shouldAttachApiKey(path)) {
119
- headers["x-api-key"] = this.apiKey;
120
- }
121
- if (this.getAccessToken) {
122
- try {
123
- const token = await this.getAccessToken();
124
- if (token) {
125
- headers["Authorization"] = `Bearer ${token}`;
126
- }
127
- } catch (error) {
128
- if (typeof process !== "undefined" && process.env?.NODE_ENV === "development") {
129
- console.warn(
130
- "[AxCloud SDK] Failed to fetch access token:",
131
- error instanceof Error ? error.message : error
132
- );
133
- }
134
- }
135
- }
136
- const url = this.buildUrl(path, params);
137
- const controller = new AbortController();
138
- const requestTimeout = timeout ?? this.defaultTimeout;
139
- const timeoutId = setTimeout(() => controller.abort(), requestTimeout);
140
- try {
141
- const response = await fetch(url, {
142
- ...restOptions,
143
- headers,
144
- body: body ? JSON.stringify(body) : void 0,
145
- signal: controller.signal
146
- });
147
- const contentType = response.headers.get("content-type");
148
- const isJson = contentType?.includes("application/json");
149
- if (!response.ok) {
150
- const errorBody = isJson ? await response.json().catch(() => null) : null;
151
- throw AxCloudError.fromResponse(response.status, errorBody);
152
- }
153
- if (response.status === 204) {
154
- return {};
155
- }
156
- return isJson ? await response.json() : {};
157
- } catch (error) {
158
- if (error instanceof AxCloudError) {
159
- throw error;
160
- }
161
- if (error instanceof Error && error.name === "AbortError") {
162
- throw AxCloudError.timeoutError(requestTimeout);
163
- }
164
- throw AxCloudError.networkError(error instanceof Error ? error : void 0);
165
- } finally {
166
- clearTimeout(timeoutId);
167
- }
168
- }
169
- /**
170
- * GET request
171
- */
172
- get(path, params) {
173
- return this.request(path, { method: "GET", params });
174
- }
175
- /**
176
- * POST request
177
- */
178
- post(path, body) {
179
- return this.request(path, { method: "POST", body });
180
- }
181
- /**
182
- * PUT request
183
- */
184
- put(path, body) {
185
- return this.request(path, { method: "PUT", body });
186
- }
187
- /**
188
- * PATCH request
189
- */
190
- patch(path, body) {
191
- return this.request(path, { method: "PATCH", body });
192
- }
193
- /**
194
- * DELETE request
195
- */
196
- delete(path) {
197
- return this.request(path, { method: "DELETE" });
198
- }
199
- };
200
- var clientRegistry = /* @__PURE__ */ new WeakMap();
201
- function createClient(config, key) {
202
- const client = new AxCloudClient(config);
203
- if (key) {
204
- clientRegistry.set(key, client);
205
- }
206
- return client;
207
- }
208
- function getClient(key) {
209
- if (key) {
210
- const client = clientRegistry.get(key);
211
- if (client) {
212
- return client;
213
- }
214
- }
215
- throw new Error("AxCloud client not found. Make sure AxCloudProvider is mounted and use useAxCloudContext() to get the client.");
216
- }
217
-
218
- // src/core/analytics.ts
219
- var EVENT_NAME_PATTERN = /^[a-z][a-z0-9_]{1,63}$/;
220
- var PROPERTY_KEY_PATTERN = /^[a-z][a-z0-9_]{0,47}$/;
221
- var SENSITIVE_PROPERTY_PATTERN = /(^|_)(auth0|email|name|password|query|search|secret|token|trace|user|userid)($|_)/;
222
- var EMAIL_VALUE_PATTERN = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
223
- var OPAQUE_SEGMENT_PATTERNS = [
224
- /^[0-9a-f]{8}-[0-9a-f-]{27,}$/i,
225
- /^(org|user|section|document|content|poll|invitation|invite|trace|chan)[_-][a-z0-9_-]+$/i,
226
- /^[a-f0-9]{20,}$/i,
227
- /^[a-z0-9_-]{32,}$/i
228
- ];
229
- var scriptLoads = /* @__PURE__ */ new Map();
230
- function isLocalAnalyticsHostname(hostname) {
231
- return hostname === "localhost" || hostname === "127.0.0.1" || hostname === "::1";
232
- }
233
- function sanitizeAnalyticsPath(pathname, customNormalizer) {
234
- const rawPath = pathname.split(/[?#]/, 1)[0] || "/";
235
- const normalizedInput = rawPath.startsWith("/") ? rawPath : `/${rawPath}`;
236
- const custom = customNormalizer?.(normalizedInput);
237
- if (custom === null) return null;
238
- const path = custom ?? normalizedInput;
239
- const cleanPath = path.split(/[?#]/, 1)[0] || "/";
240
- const segments = cleanPath.split("/").map((segment) => {
241
- if (!segment) return segment;
242
- let decoded = segment;
243
- try {
244
- decoded = decodeURIComponent(segment);
245
- } catch {
246
- }
247
- return OPAQUE_SEGMENT_PATTERNS.some((pattern) => pattern.test(decoded)) ? ":id" : segment;
248
- });
249
- return segments.join("/") || "/";
250
- }
251
- function sanitizeAnalyticsEventData(data) {
252
- if (!data) return void 0;
253
- const sanitized = {};
254
- for (const [rawKey, rawValue] of Object.entries(data).slice(0, 20)) {
255
- const key = rawKey.trim().toLowerCase();
256
- if (!PROPERTY_KEY_PATTERN.test(key) || SENSITIVE_PROPERTY_PATTERN.test(key)) continue;
257
- if (typeof rawValue === "string") {
258
- const value = rawValue.trim();
259
- if (!value || value.length > 100 || EMAIL_VALUE_PATTERN.test(value)) continue;
260
- sanitized[key] = value;
261
- continue;
262
- }
263
- if (typeof rawValue === "number" && Number.isFinite(rawValue)) {
264
- sanitized[key] = rawValue;
265
- continue;
266
- }
267
- if (typeof rawValue === "boolean") sanitized[key] = rawValue;
268
- }
269
- return Object.keys(sanitized).length > 0 ? sanitized : void 0;
270
- }
271
- function isAllowedAnalyticsEvent(eventName, allowedEvents) {
272
- return EVENT_NAME_PATTERN.test(eventName) && Boolean(allowedEvents?.includes(eventName));
273
- }
274
- async function fetchAnalyticsPublicConfig(input) {
275
- const baseUrl = input.apiUrl.replace(/\/$/, "");
276
- const url = new URL(`${baseUrl}/analytics/public/config`);
277
- url.searchParams.set("orgId", input.orgId);
278
- url.searchParams.set("siteKey", input.siteKey);
279
- url.searchParams.set("stage", input.stage);
280
- url.searchParams.set("hostname", input.hostname);
281
- const response = await fetch(url, {
282
- method: "GET",
283
- headers: { Accept: "application/json" },
284
- signal: input.signal
285
- });
286
- if (!response.ok) throw new Error(`Analytics configuration returned ${response.status}`);
287
- return response.json();
288
- }
289
- function loadAnalyticsScript(config, doc = document) {
290
- if (!config.enabled || !config.websiteId || !config.scriptUrl) {
291
- return Promise.reject(new Error("Analytics tracker configuration is incomplete"));
292
- }
293
- const key = `${config.scriptUrl}|${config.websiteId}`;
294
- const existingPromise = scriptLoads.get(key);
295
- if (existingPromise) return existingPromise;
296
- const existing = doc.querySelector(
297
- `script[data-axcloud-analytics-site="${config.websiteId}"]`
298
- );
299
- if (existing && doc.defaultView?.umami) {
300
- return Promise.resolve();
301
- }
302
- const promise = new Promise((resolve, reject) => {
303
- const script = existing || doc.createElement("script");
304
- const onLoad = () => resolve();
305
- const onError = () => reject(new Error("Analytics tracker failed to load"));
306
- script.addEventListener("load", onLoad, { once: true });
307
- script.addEventListener("error", onError, { once: true });
308
- if (!existing) {
309
- script.src = config.scriptUrl;
310
- script.defer = true;
311
- script.dataset.websiteId = config.websiteId;
312
- script.dataset.axcloudAnalyticsSite = config.websiteId;
313
- script.dataset.autoTrack = String(config.autoTrack === true);
314
- if (config.hostUrl) script.dataset.hostUrl = config.hostUrl;
315
- if (config.domains?.length) script.dataset.domains = config.domains.join(",");
316
- if (config.respectDoNotTrack !== false) script.dataset.doNotTrack = "true";
317
- if (config.excludeSearch !== false) script.dataset.excludeSearch = "true";
318
- if (config.excludeHash !== false) script.dataset.excludeHash = "true";
319
- doc.head.appendChild(script);
320
- }
321
- }).catch((error) => {
322
- scriptLoads.delete(key);
323
- throw error;
324
- });
325
- scriptLoads.set(key, promise);
326
- return promise;
327
- }
328
- function sendAnalyticsPageView(pathname, options, targetWindow = window) {
329
- const path = sanitizeAnalyticsPath(pathname, options.normalizePath);
330
- const umami = targetWindow.umami;
331
- if (!path || !umami) return false;
332
- umami.track({ url: path, title: targetWindow.document.title });
333
- return true;
334
- }
335
- function sendAnalyticsEvent(eventName, data, allowedEvents, targetWindow = window) {
336
- const umami = targetWindow.umami;
337
- if (!umami || !isAllowedAnalyticsEvent(eventName, allowedEvents)) return false;
338
- umami.track(eventName, sanitizeAnalyticsEventData(data));
339
- return true;
340
- }
341
-
342
11
  // src/core/contentSlots.ts
343
12
  var SLOT_ATTRIBUTE_KEYS = ["slot", "field", "key", "name"];
344
13
  function getContentSlotMap(content) {
@@ -628,135 +297,6 @@ async function castVote(votingApiUrl, params) {
628
297
  await ensureOk(response);
629
298
  return readJson(response);
630
299
  }
631
- var AxCloudContext = react.createContext(null);
632
- function useAxCloudContext() {
633
- const context = react.useContext(AxCloudContext);
634
- if (!context) {
635
- throw new Error("useAxCloudContext must be used within a AxCloudProvider");
636
- }
637
- return context;
638
- }
639
- var NAVIGATION_EVENT = "axcloud-sdk:navigation";
640
- var historySubscriberCount = 0;
641
- var originalPushState = null;
642
- var originalReplaceState = null;
643
- function subscribeToNavigation(callback) {
644
- if (typeof window === "undefined") return () => void 0;
645
- if (historySubscriberCount === 0) {
646
- originalPushState = window.history.pushState.bind(window.history);
647
- originalReplaceState = window.history.replaceState.bind(window.history);
648
- window.history.pushState = ((...args) => {
649
- originalPushState?.(...args);
650
- window.dispatchEvent(new Event(NAVIGATION_EVENT));
651
- });
652
- window.history.replaceState = ((...args) => {
653
- originalReplaceState?.(...args);
654
- window.dispatchEvent(new Event(NAVIGATION_EVENT));
655
- });
656
- }
657
- historySubscriberCount += 1;
658
- window.addEventListener("popstate", callback);
659
- window.addEventListener(NAVIGATION_EVENT, callback);
660
- return () => {
661
- window.removeEventListener("popstate", callback);
662
- window.removeEventListener(NAVIGATION_EVENT, callback);
663
- historySubscriberCount = Math.max(0, historySubscriberCount - 1);
664
- if (historySubscriberCount === 0) {
665
- if (originalPushState) window.history.pushState = originalPushState;
666
- if (originalReplaceState) window.history.replaceState = originalReplaceState;
667
- originalPushState = null;
668
- originalReplaceState = null;
669
- }
670
- };
671
- }
672
- function doNotTrackEnabled(config) {
673
- if (config.respectDoNotTrack === false || typeof navigator === "undefined") return false;
674
- return navigator.doNotTrack === "1";
675
- }
676
- function useAnalyticsRuntime(config) {
677
- const [enabled, setEnabled] = react.useState(false);
678
- const [ready, setReady] = react.useState(false);
679
- const publicConfigRef = react.useRef(null);
680
- const optionsRef = react.useRef(config.analytics);
681
- optionsRef.current = config.analytics;
682
- const trackPageView = react.useCallback(
683
- (pathname) => {
684
- if (!ready || !optionsRef.current || typeof window === "undefined") return false;
685
- return sendAnalyticsPageView(pathname || window.location.pathname, optionsRef.current);
686
- },
687
- [ready]
688
- );
689
- const track = react.useCallback(
690
- (eventName, data) => {
691
- if (!ready || typeof window === "undefined") return false;
692
- return sendAnalyticsEvent(eventName, data, publicConfigRef.current?.allowedEvents);
693
- },
694
- [ready]
695
- );
696
- react.useEffect(() => {
697
- const options = config.analytics;
698
- setEnabled(false);
699
- setReady(false);
700
- publicConfigRef.current = null;
701
- if (!options?.enabled || !options.siteKey || typeof window === "undefined") return void 0;
702
- if (isLocalAnalyticsHostname(window.location.hostname) && !options.trackLocalhost)
703
- return void 0;
704
- const controller = new AbortController();
705
- let cancelled = false;
706
- let unsubscribe = () => void 0;
707
- const initialize = async () => {
708
- try {
709
- const publicConfig = await fetchAnalyticsPublicConfig({
710
- apiUrl: config.apiUrl,
711
- orgId: config.orgId,
712
- siteKey: options.siteKey,
713
- stage: config.stage,
714
- hostname: window.location.hostname,
715
- signal: controller.signal
716
- });
717
- if (cancelled || !publicConfig.enabled || doNotTrackEnabled(publicConfig)) return;
718
- publicConfigRef.current = publicConfig;
719
- setEnabled(true);
720
- await loadAnalyticsScript(publicConfig);
721
- if (cancelled) return;
722
- setReady(true);
723
- if (!publicConfig.autoTrack) {
724
- const trackCurrentPage = () => {
725
- sendAnalyticsPageView(window.location.pathname, options);
726
- };
727
- trackCurrentPage();
728
- unsubscribe = subscribeToNavigation(trackCurrentPage);
729
- }
730
- } catch (error) {
731
- if (!cancelled && !(error instanceof Error && error.name === "AbortError")) {
732
- setEnabled(false);
733
- setReady(false);
734
- }
735
- }
736
- };
737
- void initialize();
738
- return () => {
739
- cancelled = true;
740
- controller.abort();
741
- unsubscribe();
742
- };
743
- }, [
744
- config.analytics?.enabled,
745
- config.analytics?.siteKey,
746
- config.analytics?.trackLocalhost,
747
- config.analytics?.normalizePath,
748
- config.apiUrl,
749
- config.orgId,
750
- config.stage
751
- ]);
752
- return react.useMemo(
753
- () => ({ enabled, ready, track, trackPageView }),
754
- [enabled, ready, track, trackPageView]
755
- );
756
- }
757
- function useAnalytics() {
758
- return useAxCloudContext().analytics;
759
- }
760
300
 
761
301
  // src/react/auth/auth0Invitation.ts
762
302
  var AUTH0_INVITATION_PATTERN = /^[A-Za-z0-9_-]{1,2048}$/;
@@ -777,7 +317,7 @@ function createDefaultQueryClient() {
777
317
  staleTime: 1e3 * 60,
778
318
  gcTime: 1e3 * 60 * 30,
779
319
  retry: (failureCount, error) => {
780
- if (isAxCloudError(error) && error.status >= 400 && error.status < 500) {
320
+ if (chunkDI4M6A7K_js.isAxCloudError(error) && error.status >= 400 && error.status < 500) {
781
321
  return false;
782
322
  }
783
323
  return failureCount < 2;
@@ -810,7 +350,7 @@ function AxCloudInnerProvider({
810
350
  timeout
811
351
  }) {
812
352
  const { getAccessTokenSilently, isAuthenticated, isLoading, user } = auth0React.useAuth0();
813
- const analytics = useAnalyticsRuntime(config);
353
+ const analytics = chunkDI4M6A7K_js.useAnalyticsRuntime(config);
814
354
  const [, setOwnerGeneration] = react.useState(0);
815
355
  const currentSubject = isLoading ? void 0 : isAuthenticated ? user?.sub : null;
816
356
  const currentOwnerSignature = currentSubject === void 0 ? void 0 : createQueryClientOwnerSignature(config, currentSubject);
@@ -834,7 +374,7 @@ function AxCloudInnerProvider({
834
374
  }
835
375
  } : async () => void 0;
836
376
  const client = react.useMemo(() => {
837
- return new AxCloudClient({
377
+ return new chunkDI4M6A7K_js.AxCloudClient({
838
378
  baseUrl: config.apiUrl,
839
379
  apiKey: config.apiKey,
840
380
  timeout,
@@ -864,7 +404,7 @@ function AxCloudInnerProvider({
864
404
  [config, client, isAuthenticated, isLoading, user?.sub, clearContentCache, analytics]
865
405
  );
866
406
  const identityReady = currentOwnerSignature !== void 0 && !ownerNeedsActivation;
867
- return /* @__PURE__ */ jsxRuntime.jsx(AxCloudContext.Provider, { value: contextValue, children: identityReady ? children : null });
407
+ return /* @__PURE__ */ jsxRuntime.jsx(chunkDSWRJZWR_js.AxCloudContext.Provider, { value: contextValue, children: identityReady ? children : null });
868
408
  }
869
409
  function AxCloudProvider({
870
410
  children,
@@ -907,7 +447,7 @@ function AxCloudProvider({
907
447
  ) });
908
448
  }
909
449
  function useAuth() {
910
- const { config, client, clearContentCache } = useAxCloudContext();
450
+ const { config, client, clearContentCache } = chunkDSWRJZWR_js.useAxCloudContext();
911
451
  const {
912
452
  isAuthenticated,
913
453
  isLoading,
@@ -988,7 +528,7 @@ function useAuth() {
988
528
  ...data.retry_after_seconds !== void 0 ? { retryAfterSeconds: data.retry_after_seconds } : {}
989
529
  };
990
530
  } catch (requestError) {
991
- if (isAxCloudError(requestError) && requestError.status === 429) {
531
+ if (chunkDI4M6A7K_js.isAxCloudError(requestError) && requestError.status === 429) {
992
532
  const responseDetails = requestError.details?.details;
993
533
  const retryAfterSeconds = Number(
994
534
  responseDetails && typeof responseDetails === "object" ? responseDetails.retry_after_seconds : void 0
@@ -1236,7 +776,7 @@ function normalizeCurrentUserResponse(raw, configuredOrgId) {
1236
776
  }
1237
777
  function useUser() {
1238
778
  const { isAuthenticated, isLoading: isAuthLoading, user: auth0User } = auth0React.useAuth0();
1239
- const { client, stage, orgId } = useAxCloudContext();
779
+ const { client, stage, orgId } = chunkDSWRJZWR_js.useAxCloudContext();
1240
780
  const queryKey = currentUserQueryKey(stage, orgId, auth0User?.sub);
1241
781
  const query = reactQuery.useQuery({
1242
782
  queryKey,
@@ -1284,7 +824,7 @@ function useUser() {
1284
824
  };
1285
825
  }
1286
826
  function useUpdateMyProfile() {
1287
- const { client, stage } = useAxCloudContext();
827
+ const { client, stage } = chunkDSWRJZWR_js.useAxCloudContext();
1288
828
  const queryClient = reactQuery.useQueryClient();
1289
829
  return reactQuery.useMutation({
1290
830
  mutationFn: (updates) => client.patch("/api/users/me/profile", updates),
@@ -1297,7 +837,7 @@ function useUpdateMyProfile() {
1297
837
  });
1298
838
  }
1299
839
  function useOrg() {
1300
- const { client, orgId, stage, isPublicMode } = useAxCloudContext();
840
+ const { client, orgId, stage, isPublicMode } = chunkDSWRJZWR_js.useAxCloudContext();
1301
841
  const usePublicEndpoint = isPublicMode;
1302
842
  const query = reactQuery.useQuery({
1303
843
  queryKey: ["axcloud", "organization", orgId, stage, usePublicEndpoint],
@@ -1346,7 +886,7 @@ function useOrg() {
1346
886
  // src/react/contentQueryPolicy.ts
1347
887
  var CONTENT_STALE_TIME_MS = 6e4;
1348
888
  function shouldRetryContentRequest(failureCount, error) {
1349
- if (isAxCloudError(error) && error.status >= 400 && error.status < 500) {
889
+ if (chunkDI4M6A7K_js.isAxCloudError(error) && error.status >= 400 && error.status < 500) {
1350
890
  return false;
1351
891
  }
1352
892
  return failureCount < 2;
@@ -1401,7 +941,7 @@ function getContentAccessState(context, publicOnly) {
1401
941
 
1402
942
  // src/react/hooks/useContent.ts
1403
943
  function useContent(contentType, options = {}) {
1404
- const context = useAxCloudContext();
944
+ const context = chunkDSWRJZWR_js.useAxCloudContext();
1405
945
  const { client, config, orgId, stage } = context;
1406
946
  const collectionType = normalizeContentCollectionType(contentType);
1407
947
  const {
@@ -1464,7 +1004,7 @@ function useContent(contentType, options = {}) {
1464
1004
  };
1465
1005
  }
1466
1006
  function useContentItem(contentType, idOrSlug, options = {}) {
1467
- const context = useAxCloudContext();
1007
+ const context = chunkDSWRJZWR_js.useAxCloudContext();
1468
1008
  const { client, config, orgId, stage } = context;
1469
1009
  const detailType = normalizeContentDetailType(contentType);
1470
1010
  const { publicOnly = false, lang } = options;
@@ -1520,7 +1060,7 @@ function useNews(options = {}) {
1520
1060
  function useMySection(options = {}) {
1521
1061
  const { includeMembers = true } = options;
1522
1062
  const { isAuthenticated } = auth0React.useAuth0();
1523
- const { client, orgId, stage } = useAxCloudContext();
1063
+ const { client, orgId, stage } = chunkDSWRJZWR_js.useAxCloudContext();
1524
1064
  const { user, sectionId, isLoading: isUserLoading } = useUser();
1525
1065
  const query = reactQuery.useQuery({
1526
1066
  queryKey: ["axcloud", "mySection", orgId, sectionId, includeMembers, stage],
@@ -1554,7 +1094,7 @@ function useMySection(options = {}) {
1554
1094
  };
1555
1095
  }
1556
1096
  function useSections() {
1557
- const { client, orgId, stage } = useAxCloudContext();
1097
+ const { client, orgId, stage } = chunkDSWRJZWR_js.useAxCloudContext();
1558
1098
  const query = reactQuery.useQuery({
1559
1099
  queryKey: ["axcloud", "sections", orgId, stage],
1560
1100
  queryFn: async () => {
@@ -1573,7 +1113,7 @@ function useSections() {
1573
1113
  };
1574
1114
  }
1575
1115
  function useForms(options = {}) {
1576
- const { client, stage } = useAxCloudContext();
1116
+ const { client, stage } = chunkDSWRJZWR_js.useAxCloudContext();
1577
1117
  const { formType, status, limit = 50, cursor } = options;
1578
1118
  const query = reactQuery.useQuery({
1579
1119
  queryKey: ["axcloud", "forms", "submissions", stage, formType, status, limit, cursor],
@@ -1599,7 +1139,7 @@ function useForms(options = {}) {
1599
1139
  };
1600
1140
  }
1601
1141
  function useFormStats(options = {}) {
1602
- const { client, stage } = useAxCloudContext();
1142
+ const { client, stage } = chunkDSWRJZWR_js.useAxCloudContext();
1603
1143
  const { days = 30 } = options;
1604
1144
  const query = reactQuery.useQuery({
1605
1145
  queryKey: ["axcloud", "forms", "stats", stage, days],
@@ -1620,7 +1160,7 @@ function useFormStats(options = {}) {
1620
1160
  };
1621
1161
  }
1622
1162
  function useUpdateFormSubmission() {
1623
- const { client, stage } = useAxCloudContext();
1163
+ const { client, stage } = chunkDSWRJZWR_js.useAxCloudContext();
1624
1164
  const queryClient = reactQuery.useQueryClient();
1625
1165
  return reactQuery.useMutation({
1626
1166
  mutationFn: async ({
@@ -1636,7 +1176,7 @@ function useUpdateFormSubmission() {
1636
1176
  });
1637
1177
  }
1638
1178
  function useCodeBallot({ pollId, votingApiUrl }) {
1639
- const { orgId, config } = useAxCloudContext();
1179
+ const { orgId, config } = chunkDSWRJZWR_js.useAxCloudContext();
1640
1180
  const baseUrl = votingApiUrl || `${config.apiUrl.replace(/\/$/, "")}/voting`;
1641
1181
  const [stage, setStage] = react.useState("enter_code");
1642
1182
  const [code, setCode] = react.useState("");
@@ -1707,7 +1247,7 @@ function useCodeBallot({ pollId, votingApiUrl }) {
1707
1247
  }
1708
1248
  var LINKED_ACCOUNTS_QUERY_KEY = ["axcloud", "linked-accounts"];
1709
1249
  function useLinkedAccounts() {
1710
- const { client, stage } = useAxCloudContext();
1250
+ const { client, stage } = chunkDSWRJZWR_js.useAxCloudContext();
1711
1251
  const { isAuthenticated } = useAuth();
1712
1252
  const queryClient = reactQuery.useQueryClient();
1713
1253
  const query = reactQuery.useQuery({
@@ -1758,7 +1298,7 @@ function useLinkedAccounts() {
1758
1298
  };
1759
1299
  }
1760
1300
  function useBranding() {
1761
- const { client, orgId } = useAxCloudContext();
1301
+ const { client, orgId } = chunkDSWRJZWR_js.useAxCloudContext();
1762
1302
  const query = reactQuery.useQuery({
1763
1303
  queryKey: ["axcloud", "media", "branding", orgId],
1764
1304
  queryFn: async () => {
@@ -1780,7 +1320,7 @@ function useBranding() {
1780
1320
  };
1781
1321
  }
1782
1322
  function useLogo() {
1783
- const { client, orgId } = useAxCloudContext();
1323
+ const { client, orgId } = chunkDSWRJZWR_js.useAxCloudContext();
1784
1324
  const query = reactQuery.useQuery({
1785
1325
  queryKey: ["axcloud", "media", "logo", orgId],
1786
1326
  queryFn: async () => {
@@ -1801,7 +1341,7 @@ function useLogo() {
1801
1341
  };
1802
1342
  }
1803
1343
  function useAvatar(userId) {
1804
- const { client, orgId } = useAxCloudContext();
1344
+ const { client, orgId } = chunkDSWRJZWR_js.useAxCloudContext();
1805
1345
  const query = reactQuery.useQuery({
1806
1346
  queryKey: ["axcloud", "media", "avatar", orgId, userId],
1807
1347
  queryFn: async () => {
@@ -1822,7 +1362,7 @@ function useAvatar(userId) {
1822
1362
  };
1823
1363
  }
1824
1364
  function useMediaList(type = "media", limit = 50) {
1825
- const { client, orgId } = useAxCloudContext();
1365
+ const { client, orgId } = chunkDSWRJZWR_js.useAxCloudContext();
1826
1366
  const query = reactQuery.useQuery({
1827
1367
  queryKey: ["axcloud", "media", "list", orgId, type, limit],
1828
1368
  queryFn: async () => {
@@ -1844,7 +1384,7 @@ function useMediaList(type = "media", limit = 50) {
1844
1384
  };
1845
1385
  }
1846
1386
  function useMedia(mediaId) {
1847
- const { client, orgId } = useAxCloudContext();
1387
+ const { client, orgId } = chunkDSWRJZWR_js.useAxCloudContext();
1848
1388
  const query = reactQuery.useQuery({
1849
1389
  queryKey: ["axcloud", "media", "file", orgId, mediaId],
1850
1390
  queryFn: async () => {
@@ -1871,7 +1411,7 @@ function buildDocumentParams(options) {
1871
1411
  };
1872
1412
  }
1873
1413
  function useDocuments(options) {
1874
- const { client, orgId } = useAxCloudContext();
1414
+ const { client, orgId } = chunkDSWRJZWR_js.useAxCloudContext();
1875
1415
  const params = buildDocumentParams(options);
1876
1416
  const query = reactQuery.useQuery({
1877
1417
  queryKey: ["axcloud", "documents", "list", orgId, options],
@@ -1891,7 +1431,7 @@ function useDocuments(options) {
1891
1431
  };
1892
1432
  }
1893
1433
  function useDocumentDownload(documentId) {
1894
- const { client, orgId } = useAxCloudContext();
1434
+ const { client, orgId } = chunkDSWRJZWR_js.useAxCloudContext();
1895
1435
  const query = reactQuery.useQuery({
1896
1436
  queryKey: ["axcloud", "documents", "download", orgId, documentId],
1897
1437
  queryFn: async () => {
@@ -1916,7 +1456,7 @@ function useDocumentDownload(documentId) {
1916
1456
  };
1917
1457
  }
1918
1458
  function useMemberDocuments(options) {
1919
- const { client, orgId } = useAxCloudContext();
1459
+ const { client, orgId } = chunkDSWRJZWR_js.useAxCloudContext();
1920
1460
  const params = buildDocumentParams(options);
1921
1461
  const folderId = options?.folderId;
1922
1462
  const query = reactQuery.useQuery({
@@ -1939,7 +1479,7 @@ function useMemberDocuments(options) {
1939
1479
  };
1940
1480
  }
1941
1481
  function useMemberDocumentFolders() {
1942
- const { client, orgId } = useAxCloudContext();
1482
+ const { client, orgId } = chunkDSWRJZWR_js.useAxCloudContext();
1943
1483
  const query = reactQuery.useQuery({
1944
1484
  queryKey: ["axcloud", "documents", "member", "folders", orgId],
1945
1485
  queryFn: async () => {
@@ -1958,7 +1498,7 @@ function useMemberDocumentFolders() {
1958
1498
  };
1959
1499
  }
1960
1500
  function useMemberDocumentDownload(documentId) {
1961
- const { client, orgId } = useAxCloudContext();
1501
+ const { client, orgId } = chunkDSWRJZWR_js.useAxCloudContext();
1962
1502
  const query = reactQuery.useQuery({
1963
1503
  queryKey: ["axcloud", "documents", "member", "download", orgId, documentId],
1964
1504
  queryFn: async () => {
@@ -1982,126 +1522,6 @@ function useMemberDocumentDownload(documentId) {
1982
1522
  refetch: query.refetch
1983
1523
  };
1984
1524
  }
1985
- function useBarnsportMunicipalities() {
1986
- const { client, orgId } = useAxCloudContext();
1987
- const query = reactQuery.useQuery({
1988
- queryKey: ["axcloud", "barnsport", "municipalities", orgId],
1989
- queryFn: () => client.get(
1990
- `/barnsport/public/${orgId}/municipalities`
1991
- ),
1992
- staleTime: 1e3 * 60 * 30
1993
- });
1994
- return {
1995
- municipalities: query.data?.items ?? [],
1996
- count: query.data?.count ?? 0,
1997
- isLoading: query.isLoading,
1998
- isError: query.isError,
1999
- error: query.error,
2000
- refetch: query.refetch
2001
- };
2002
- }
2003
- function useBarnsportSports() {
2004
- const { client, orgId } = useAxCloudContext();
2005
- const query = reactQuery.useQuery({
2006
- queryKey: ["axcloud", "barnsport", "sports", orgId],
2007
- queryFn: () => client.get(
2008
- `/barnsport/public/${orgId}/sports`
2009
- ),
2010
- staleTime: 1e3 * 60 * 30
2011
- });
2012
- return {
2013
- sports: query.data?.items ?? [],
2014
- count: query.data?.count ?? 0,
2015
- isLoading: query.isLoading,
2016
- isError: query.isError,
2017
- error: query.error,
2018
- refetch: query.refetch
2019
- };
2020
- }
2021
- function useBarnsportSport(slug) {
2022
- const { client, orgId } = useAxCloudContext();
2023
- const query = reactQuery.useQuery({
2024
- queryKey: ["axcloud", "barnsport", "sport", orgId, slug],
2025
- queryFn: () => client.get(
2026
- `/barnsport/public/${orgId}/sports/${slug || ""}`
2027
- ),
2028
- enabled: Boolean(slug),
2029
- staleTime: 1e3 * 60 * 15
2030
- });
2031
- return {
2032
- sport: query.data?.sport ?? null,
2033
- isLoading: query.isLoading,
2034
- isError: query.isError,
2035
- error: query.error,
2036
- refetch: query.refetch
2037
- };
2038
- }
2039
- function useBarnsportActivities(filters = {}) {
2040
- const { client, orgId } = useAxCloudContext();
2041
- const params = { ...filters };
2042
- const query = reactQuery.useQuery({
2043
- queryKey: ["axcloud", "barnsport", "activities", orgId, filters],
2044
- queryFn: () => client.get(
2045
- `/barnsport/public/${orgId}/activities`,
2046
- params
2047
- ),
2048
- staleTime: 1e3 * 60 * 5
2049
- });
2050
- return {
2051
- activities: query.data?.items ?? [],
2052
- count: query.data?.count ?? 0,
2053
- nextCursor: query.data?.nextCursor ?? null,
2054
- isLoading: query.isLoading,
2055
- isError: query.isError,
2056
- error: query.error,
2057
- refetch: query.refetch
2058
- };
2059
- }
2060
- function useBarnsportActivity(slug) {
2061
- const { client, orgId } = useAxCloudContext();
2062
- const query = reactQuery.useQuery({
2063
- queryKey: ["axcloud", "barnsport", "activity", orgId, slug],
2064
- queryFn: () => client.get(
2065
- `/barnsport/public/${orgId}/activities/${slug || ""}`
2066
- ),
2067
- enabled: Boolean(slug),
2068
- staleTime: 1e3 * 60 * 5
2069
- });
2070
- return {
2071
- activity: query.data?.activity ?? null,
2072
- isLoading: query.isLoading,
2073
- isError: query.isError,
2074
- error: query.error,
2075
- refetch: query.refetch
2076
- };
2077
- }
2078
- function useBarnsportSitemap(baseUrl) {
2079
- const { client, orgId } = useAxCloudContext();
2080
- const query = reactQuery.useQuery({
2081
- queryKey: ["axcloud", "barnsport", "sitemap", orgId, baseUrl],
2082
- queryFn: () => client.get(`/barnsport/public/${orgId}/sitemap`, {
2083
- baseUrl
2084
- }),
2085
- staleTime: 1e3 * 60 * 15
2086
- });
2087
- return {
2088
- sitemap: query.data ?? null,
2089
- urls: query.data?.urls ?? [],
2090
- isLoading: query.isLoading,
2091
- isError: query.isError,
2092
- error: query.error,
2093
- refetch: query.refetch
2094
- };
2095
- }
2096
- function useSubmitBarnsportInterest() {
2097
- const { client, orgId } = useAxCloudContext();
2098
- return reactQuery.useMutation({
2099
- mutationFn: (submission) => client.post(
2100
- `/barnsport/public/${orgId}/interest`,
2101
- submission
2102
- )
2103
- });
2104
- }
2105
1525
  function LoginButton({
2106
1526
  children = "Log in",
2107
1527
  returnTo,
@@ -2345,8 +1765,86 @@ function LinkedAccountsList({
2345
1765
  ] });
2346
1766
  }
2347
1767
 
2348
- exports.AxCloudClient = AxCloudClient;
2349
- exports.AxCloudError = AxCloudError;
1768
+ Object.defineProperty(exports, "AxCloudClient", {
1769
+ enumerable: true,
1770
+ get: function () { return chunkDI4M6A7K_js.AxCloudClient; }
1771
+ });
1772
+ Object.defineProperty(exports, "AxCloudError", {
1773
+ enumerable: true,
1774
+ get: function () { return chunkDI4M6A7K_js.AxCloudError; }
1775
+ });
1776
+ Object.defineProperty(exports, "createClient", {
1777
+ enumerable: true,
1778
+ get: function () { return chunkDI4M6A7K_js.createClient; }
1779
+ });
1780
+ Object.defineProperty(exports, "fetchAnalyticsPublicConfig", {
1781
+ enumerable: true,
1782
+ get: function () { return chunkDI4M6A7K_js.fetchAnalyticsPublicConfig; }
1783
+ });
1784
+ Object.defineProperty(exports, "getClient", {
1785
+ enumerable: true,
1786
+ get: function () { return chunkDI4M6A7K_js.getClient; }
1787
+ });
1788
+ Object.defineProperty(exports, "isAllowedAnalyticsEvent", {
1789
+ enumerable: true,
1790
+ get: function () { return chunkDI4M6A7K_js.isAllowedAnalyticsEvent; }
1791
+ });
1792
+ Object.defineProperty(exports, "isAxCloudError", {
1793
+ enumerable: true,
1794
+ get: function () { return chunkDI4M6A7K_js.isAxCloudError; }
1795
+ });
1796
+ Object.defineProperty(exports, "isLocalAnalyticsHostname", {
1797
+ enumerable: true,
1798
+ get: function () { return chunkDI4M6A7K_js.isLocalAnalyticsHostname; }
1799
+ });
1800
+ Object.defineProperty(exports, "sanitizeAnalyticsEventData", {
1801
+ enumerable: true,
1802
+ get: function () { return chunkDI4M6A7K_js.sanitizeAnalyticsEventData; }
1803
+ });
1804
+ Object.defineProperty(exports, "sanitizeAnalyticsPath", {
1805
+ enumerable: true,
1806
+ get: function () { return chunkDI4M6A7K_js.sanitizeAnalyticsPath; }
1807
+ });
1808
+ Object.defineProperty(exports, "useAnalytics", {
1809
+ enumerable: true,
1810
+ get: function () { return chunkDI4M6A7K_js.useAnalytics; }
1811
+ });
1812
+ Object.defineProperty(exports, "useAnalyticsRuntime", {
1813
+ enumerable: true,
1814
+ get: function () { return chunkDI4M6A7K_js.useAnalyticsRuntime; }
1815
+ });
1816
+ Object.defineProperty(exports, "useBarnsportActivities", {
1817
+ enumerable: true,
1818
+ get: function () { return chunkEX66R5IA_js.useBarnsportActivities; }
1819
+ });
1820
+ Object.defineProperty(exports, "useBarnsportActivity", {
1821
+ enumerable: true,
1822
+ get: function () { return chunkEX66R5IA_js.useBarnsportActivity; }
1823
+ });
1824
+ Object.defineProperty(exports, "useBarnsportMunicipalities", {
1825
+ enumerable: true,
1826
+ get: function () { return chunkEX66R5IA_js.useBarnsportMunicipalities; }
1827
+ });
1828
+ Object.defineProperty(exports, "useBarnsportSitemap", {
1829
+ enumerable: true,
1830
+ get: function () { return chunkEX66R5IA_js.useBarnsportSitemap; }
1831
+ });
1832
+ Object.defineProperty(exports, "useBarnsportSport", {
1833
+ enumerable: true,
1834
+ get: function () { return chunkEX66R5IA_js.useBarnsportSport; }
1835
+ });
1836
+ Object.defineProperty(exports, "useBarnsportSports", {
1837
+ enumerable: true,
1838
+ get: function () { return chunkEX66R5IA_js.useBarnsportSports; }
1839
+ });
1840
+ Object.defineProperty(exports, "useSubmitBarnsportInterest", {
1841
+ enumerable: true,
1842
+ get: function () { return chunkEX66R5IA_js.useSubmitBarnsportInterest; }
1843
+ });
1844
+ Object.defineProperty(exports, "useAxCloudContext", {
1845
+ enumerable: true,
1846
+ get: function () { return chunkDSWRJZWR_js.useAxCloudContext; }
1847
+ });
2350
1848
  exports.AxCloudProvider = AxCloudProvider;
2351
1849
  exports.LinkedAccountsList = LinkedAccountsList;
2352
1850
  exports.LoginButton = LoginButton;
@@ -2357,31 +1855,14 @@ exports.castVote = castVote;
2357
1855
  exports.castVoteWithCode = castVoteWithCode;
2358
1856
  exports.checkEligibility = checkEligibility;
2359
1857
  exports.checkVotingCode = checkVotingCode;
2360
- exports.createClient = createClient;
2361
1858
  exports.createContentSlotReader = createContentSlotReader;
2362
1859
  exports.createFormHelper = createFormHelper;
2363
- exports.fetchAnalyticsPublicConfig = fetchAnalyticsPublicConfig;
2364
1860
  exports.getBallot = getBallot;
2365
- exports.getClient = getClient;
2366
1861
  exports.getContentSlotMap = getContentSlotMap;
2367
1862
  exports.getVotingReceipt = getVotingReceipt;
2368
- exports.isAllowedAnalyticsEvent = isAllowedAnalyticsEvent;
2369
- exports.isAxCloudError = isAxCloudError;
2370
- exports.isLocalAnalyticsHostname = isLocalAnalyticsHostname;
2371
- exports.sanitizeAnalyticsEventData = sanitizeAnalyticsEventData;
2372
- exports.sanitizeAnalyticsPath = sanitizeAnalyticsPath;
2373
1863
  exports.submitForm = submitForm;
2374
- exports.useAnalytics = useAnalytics;
2375
- exports.useAnalyticsRuntime = useAnalyticsRuntime;
2376
1864
  exports.useAuth = useAuth;
2377
1865
  exports.useAvatar = useAvatar;
2378
- exports.useAxCloudContext = useAxCloudContext;
2379
- exports.useBarnsportActivities = useBarnsportActivities;
2380
- exports.useBarnsportActivity = useBarnsportActivity;
2381
- exports.useBarnsportMunicipalities = useBarnsportMunicipalities;
2382
- exports.useBarnsportSitemap = useBarnsportSitemap;
2383
- exports.useBarnsportSport = useBarnsportSport;
2384
- exports.useBarnsportSports = useBarnsportSports;
2385
1866
  exports.useBranding = useBranding;
2386
1867
  exports.useCodeBallot = useCodeBallot;
2387
1868
  exports.useContent = useContent;
@@ -2403,7 +1884,6 @@ exports.useNews = useNews;
2403
1884
  exports.useOrg = useOrg;
2404
1885
  exports.usePageContent = usePageContent;
2405
1886
  exports.useSections = useSections;
2406
- exports.useSubmitBarnsportInterest = useSubmitBarnsportInterest;
2407
1887
  exports.useUpdateFormSubmission = useUpdateFormSubmission;
2408
1888
  exports.useUpdateMyProfile = useUpdateMyProfile;
2409
1889
  exports.useUser = useUser;