@redacto.io/consent-sdk-react 10.4.0-beta.1 → 11.0.0-beta.2

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
@@ -3,8 +3,13 @@ var __defProp = Object.defineProperty;
3
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __esm = (fn, res) => function __init() {
7
- return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
6
+ var __esm = (fn, res, err) => function __init() {
7
+ if (err) throw err[0];
8
+ try {
9
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
10
+ } catch (e) {
11
+ throw err = [e], e;
12
+ }
8
13
  };
9
14
  var __export = (target, all) => {
10
15
  for (var name in all)
@@ -88,7 +93,7 @@ __export(src_exports, {
88
93
  module.exports = __toCommonJS(src_exports);
89
94
 
90
95
  // src/RedactoNoticeConsent/RedactoNoticeConsent.tsx
91
- var import_react8 = require("react");
96
+ var import_react9 = require("react");
92
97
 
93
98
  // src/RedactoNoticeConsent/api/index.ts
94
99
  var import_jwt_decode2 = require("jwt-decode");
@@ -5078,6 +5083,65 @@ var updateConsentState = (updates) => {
5078
5083
  }
5079
5084
  };
5080
5085
 
5086
+ // src/shared/useResolvedEndpoints.ts
5087
+ var import_react8 = require("react");
5088
+
5089
+ // src/shared/endpoints.ts
5090
+ var CONSENT_PATH = "/consent";
5091
+ var LEDGER_PATH = "/consent-ledger";
5092
+ var ABSOLUTE_HTTP_URL = /^https?:\/\/(?:\[[0-9a-f:.]+\]|[^\s/?#@:[\]]+)(?::\d+)?(?:\/[^\s?#]*)?$/i;
5093
+ var trimUrl = (value) => (value != null ? value : "").trim().replace(/\/+$/, "");
5094
+ var isConsentServerUrl = (trimmed) => ABSOLUTE_HTTP_URL.test(trimmed) && trimmed.endsWith(CONSENT_PATH);
5095
+ var isHostForm = (trimmed) => ABSOLUTE_HTTP_URL.test(trimmed) && !trimmed.endsWith(CONSENT_PATH);
5096
+ function resolveEndpoints(baseUrl, ledgerBaseUrl) {
5097
+ const trimmed = trimUrl(baseUrl);
5098
+ if (!isHostForm(trimmed)) {
5099
+ return { mode: "legacy", apiHost: void 0, baseUrl, ledgerBaseUrl };
5100
+ }
5101
+ const apiHost = trimmed.endsWith(LEDGER_PATH) ? trimmed.slice(0, -LEDGER_PATH.length) : trimmed;
5102
+ return {
5103
+ mode: "host",
5104
+ apiHost,
5105
+ baseUrl: `${apiHost}${CONSENT_PATH}`,
5106
+ ledgerBaseUrl: `${apiHost}${LEDGER_PATH}`
5107
+ };
5108
+ }
5109
+ var ENDPOINT_WARNINGS = {
5110
+ missingBaseUrl: "[Redacto] baseUrl is not set, so the SDK's built-in production default is used. Pass baseUrl: your API host.",
5111
+ consentServerBaseUrl: "[Redacto] baseUrl is the consent server URL (ending in /consent), which is deprecated. Pass the API host instead; the SDK derives the consent server and ledger URLs from it.",
5112
+ ledgerBaseUrl: "[Redacto] ledgerBaseUrl is deprecated. Pass the Redacto API host as baseUrl instead; the SDK then reaches the consent server and the ledger under it.",
5113
+ ledgerBaseUrlIgnored: "[Redacto] ledgerBaseUrl is ignored because baseUrl is the API host; the SDK reaches the ledger under that host. Remove ledgerBaseUrl.",
5114
+ slugIgnored: "[Redacto] slug is deprecated and ignored. The Privacy Center reads the organisation from the access token, or from organisationUuid and workspaceUuid. Remove slug."
5115
+ };
5116
+ var issuedWarnings = /* @__PURE__ */ new Set();
5117
+ var warnOnce = (warning) => {
5118
+ if (issuedWarnings.has(warning)) {
5119
+ return;
5120
+ }
5121
+ issuedWarnings.add(warning);
5122
+ console.warn(ENDPOINT_WARNINGS[warning]);
5123
+ };
5124
+ var warnEndpointUsage = (baseUrl, ledgerBaseUrl, { hasBuiltInDefault }) => {
5125
+ if (!baseUrl) {
5126
+ if (hasBuiltInDefault) {
5127
+ warnOnce("missingBaseUrl");
5128
+ }
5129
+ } else if (isConsentServerUrl(trimUrl(baseUrl))) {
5130
+ warnOnce("consentServerBaseUrl");
5131
+ }
5132
+ if (trimUrl(ledgerBaseUrl)) {
5133
+ warnOnce(isHostForm(trimUrl(baseUrl)) ? "ledgerBaseUrlIgnored" : "ledgerBaseUrl");
5134
+ }
5135
+ };
5136
+
5137
+ // src/shared/useResolvedEndpoints.ts
5138
+ var useResolvedEndpoints = (baseUrl, ledgerBaseUrl, { warn = true, hasBuiltInDefault = true } = {}) => (0, import_react8.useMemo)(() => {
5139
+ if (warn) {
5140
+ warnEndpointUsage(baseUrl, ledgerBaseUrl, { hasBuiltInDefault });
5141
+ }
5142
+ return resolveEndpoints(baseUrl, ledgerBaseUrl);
5143
+ }, [baseUrl, ledgerBaseUrl, warn, hasBuiltInDefault]);
5144
+
5081
5145
  // src/RedactoNoticeConsent/RedactoNoticeConsent.tsx
5082
5146
  var import_jsx_runtime7 = require("react/jsx-runtime");
5083
5147
  var DEFAULT_HEADING_COLOR = "#323B4B";
@@ -5233,7 +5297,7 @@ var PurposeItem = ({
5233
5297
  }) => {
5234
5298
  var _a, _b;
5235
5299
  const stateKey = productPurposeKey(productUuid, purpose.uuid);
5236
- const handlePurposeToggle = (0, import_react8.useCallback)(
5300
+ const handlePurposeToggle = (0, import_react9.useCallback)(
5237
5301
  () => onPurposeToggle(purpose.uuid, productUuid),
5238
5302
  [onPurposeToggle, purpose.uuid, productUuid]
5239
5303
  );
@@ -5242,13 +5306,13 @@ var PurposeItem = ({
5242
5306
  purpose.name,
5243
5307
  purpose.uuid
5244
5308
  )}`;
5245
- const headingStyle = (0, import_react8.useMemo)(
5309
+ const headingStyle = (0, import_react9.useMemo)(
5246
5310
  () => ({
5247
5311
  color: (settings == null ? void 0 : settings.headingColor) || DEFAULT_HEADING_COLOR
5248
5312
  }),
5249
5313
  [settings == null ? void 0 : settings.headingColor]
5250
5314
  );
5251
- const textStyle = (0, import_react8.useMemo)(
5315
+ const textStyle = (0, import_react9.useMemo)(
5252
5316
  () => ({
5253
5317
  color: (settings == null ? void 0 : settings.textColor) || "#344054"
5254
5318
  }),
@@ -5494,12 +5558,12 @@ var GuardianForm = ({
5494
5558
  logoUrl
5495
5559
  }) => {
5496
5560
  var _a, _b, _c, _d, _e;
5497
- const [isDropdownOpen, setIsDropdownOpen] = (0, import_react8.useState)(false);
5498
- const [focusedIndex, setFocusedIndex] = (0, import_react8.useState)(-1);
5499
- const [openUpward, setOpenUpward] = (0, import_react8.useState)(false);
5500
- const dropdownRef = (0, import_react8.useRef)(null);
5501
- const optionsRef = (0, import_react8.useRef)(null);
5502
- (0, import_react8.useEffect)(() => {
5561
+ const [isDropdownOpen, setIsDropdownOpen] = (0, import_react9.useState)(false);
5562
+ const [focusedIndex, setFocusedIndex] = (0, import_react9.useState)(-1);
5563
+ const [openUpward, setOpenUpward] = (0, import_react9.useState)(false);
5564
+ const dropdownRef = (0, import_react9.useRef)(null);
5565
+ const optionsRef = (0, import_react9.useRef)(null);
5566
+ (0, import_react9.useEffect)(() => {
5503
5567
  if (!isDropdownOpen) return;
5504
5568
  const handleClickOutside = (e) => {
5505
5569
  if (dropdownRef.current && !dropdownRef.current.contains(e.target)) {
@@ -5510,7 +5574,7 @@ var GuardianForm = ({
5510
5574
  document.addEventListener("mousedown", handleClickOutside);
5511
5575
  return () => document.removeEventListener("mousedown", handleClickOutside);
5512
5576
  }, [isDropdownOpen]);
5513
- (0, import_react8.useEffect)(() => {
5577
+ (0, import_react9.useEffect)(() => {
5514
5578
  if (!isDropdownOpen || !dropdownRef.current) return;
5515
5579
  const rect = dropdownRef.current.getBoundingClientRect();
5516
5580
  const spaceBelow = window.innerHeight - rect.bottom;
@@ -5555,7 +5619,7 @@ var GuardianForm = ({
5555
5619
  break;
5556
5620
  }
5557
5621
  };
5558
- (0, import_react8.useEffect)(() => {
5622
+ (0, import_react9.useEffect)(() => {
5559
5623
  var _a2;
5560
5624
  if (focusedIndex >= 0 && optionsRef.current) {
5561
5625
  const option = optionsRef.current.children[focusedIndex];
@@ -6364,8 +6428,8 @@ var NoticeConsentView = ({
6364
6428
  ucic,
6365
6429
  organisationUuid,
6366
6430
  workspaceUuid,
6367
- baseUrl,
6368
- ledgerBaseUrl,
6431
+ baseUrl: baseUrlProp,
6432
+ ledgerBaseUrl: ledgerBaseUrlProp,
6369
6433
  language = "en",
6370
6434
  blockUI = true,
6371
6435
  onAccept,
@@ -6387,7 +6451,11 @@ var NoticeConsentView = ({
6387
6451
  forceColorScheme
6388
6452
  }) => {
6389
6453
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L;
6390
- const sandboxParams = (0, import_react8.useMemo)(
6454
+ const endpoints = useResolvedEndpoints(baseUrlProp, ledgerBaseUrlProp, {
6455
+ warn: !previewContent
6456
+ });
6457
+ const { baseUrl, ledgerBaseUrl } = endpoints;
6458
+ const sandboxParams = (0, import_react9.useMemo)(
6391
6459
  () => ({
6392
6460
  token,
6393
6461
  sandboxUcic: ucic,
@@ -6398,7 +6466,7 @@ var NoticeConsentView = ({
6398
6466
  }),
6399
6467
  [token, ucic, email, mobile, organisationUuid, workspaceUuid]
6400
6468
  );
6401
- const propValidationError = (0, import_react8.useMemo)(() => {
6469
+ const propValidationError = (0, import_react9.useMemo)(() => {
6402
6470
  if (previewContent) {
6403
6471
  return null;
6404
6472
  }
@@ -6448,12 +6516,12 @@ var NoticeConsentView = ({
6448
6516
  }
6449
6517
  );
6450
6518
  }
6451
- const [isLoading, setIsLoading] = (0, import_react8.useState)(true);
6452
- const [isSubmitting, setIsSubmitting] = (0, import_react8.useState)(false);
6453
- const [isSubmittingAccept, setIsSubmittingAccept] = (0, import_react8.useState)(false);
6454
- const [isSubmittingDecline, setIsSubmittingDecline] = (0, import_react8.useState)(false);
6455
- const [content, setContent] = (0, import_react8.useState)(null);
6456
- const [cachedAppearance, setCachedAppearance] = (0, import_react8.useState)(void 0);
6519
+ const [isLoading, setIsLoading] = (0, import_react9.useState)(true);
6520
+ const [isSubmitting, setIsSubmitting] = (0, import_react9.useState)(false);
6521
+ const [isSubmittingAccept, setIsSubmittingAccept] = (0, import_react9.useState)(false);
6522
+ const [isSubmittingDecline, setIsSubmittingDecline] = (0, import_react9.useState)(false);
6523
+ const [content, setContent] = (0, import_react9.useState)(null);
6524
+ const [cachedAppearance, setCachedAppearance] = (0, import_react9.useState)(void 0);
6457
6525
  useIsomorphicLayoutEffect(() => {
6458
6526
  setCachedAppearance(readCachedAppearance(noticeId));
6459
6527
  }, [noticeId]);
@@ -6463,101 +6531,101 @@ var NoticeConsentView = ({
6463
6531
  settings,
6464
6532
  forceColorScheme
6465
6533
  );
6466
- (0, import_react8.useEffect)(() => {
6534
+ (0, import_react9.useEffect)(() => {
6467
6535
  if (content && !previewContent) {
6468
6536
  writeCachedAppearance(content.notice_uuid, content.appearance);
6469
6537
  }
6470
6538
  }, [content, previewContent]);
6471
- const noticeSettings = (0, import_react8.useMemo)(
6539
+ const noticeSettings = (0, import_react9.useMemo)(
6472
6540
  () => toNoticeStyleSettings(noticeAppearance),
6473
6541
  [noticeAppearance]
6474
6542
  );
6475
- const [categorizedPurposes, setCategorizedPurposes] = (0, import_react8.useState)(null);
6476
- const [selectedPurposes, setSelectedPurposes] = (0, import_react8.useState)({});
6477
- const [selectedDataElements, setSelectedDataElements] = (0, import_react8.useState)({});
6478
- const [initialDataElementSelections, setInitialDataElementSelections] = (0, import_react8.useState)({});
6479
- const [recordedPurposeSelections, setRecordedPurposeSelections] = (0, import_react8.useState)({});
6480
- const [recordedAnswers, setRecordedAnswers] = (0, import_react8.useState)({});
6481
- const [collapsedProducts, setCollapsedProducts] = (0, import_react8.useState)({});
6482
- const [pendingAction, setPendingAction] = (0, import_react8.useState)(null);
6483
- const pendingActionRef = (0, import_react8.useRef)(null);
6543
+ const [categorizedPurposes, setCategorizedPurposes] = (0, import_react9.useState)(null);
6544
+ const [selectedPurposes, setSelectedPurposes] = (0, import_react9.useState)({});
6545
+ const [selectedDataElements, setSelectedDataElements] = (0, import_react9.useState)({});
6546
+ const [initialDataElementSelections, setInitialDataElementSelections] = (0, import_react9.useState)({});
6547
+ const [recordedPurposeSelections, setRecordedPurposeSelections] = (0, import_react9.useState)({});
6548
+ const [recordedAnswers, setRecordedAnswers] = (0, import_react9.useState)({});
6549
+ const [collapsedProducts, setCollapsedProducts] = (0, import_react9.useState)({});
6550
+ const [pendingAction, setPendingAction] = (0, import_react9.useState)(null);
6551
+ const pendingActionRef = (0, import_react9.useRef)(null);
6484
6552
  pendingActionRef.current = pendingAction;
6485
- const [confirmAction, setConfirmAction] = (0, import_react8.useState)("accept-selected");
6486
- const [collapsedPurposes, setCollapsedPurposes] = (0, import_react8.useState)({});
6487
- const [hasAlreadyConsented, setHasAlreadyConsented] = (0, import_react8.useState)(false);
6488
- const [consentedProducts, setConsentedProducts] = (0, import_react8.useState)({});
6489
- const [consentedPurposes, setConsentedPurposes] = (0, import_react8.useState)({});
6490
- const [isFullyConsentedReviewMode, setIsFullyConsentedReviewMode] = (0, import_react8.useState)(false);
6491
- const [isLanguageDropdownOpen, setIsLanguageDropdownOpen] = (0, import_react8.useState)(false);
6492
- const [selectedLanguage, setSelectedLanguage] = (0, import_react8.useState)(language);
6493
- const chrome = (0, import_react8.useMemo)(
6553
+ const [confirmAction, setConfirmAction] = (0, import_react9.useState)("accept-selected");
6554
+ const [collapsedPurposes, setCollapsedPurposes] = (0, import_react9.useState)({});
6555
+ const [hasAlreadyConsented, setHasAlreadyConsented] = (0, import_react9.useState)(false);
6556
+ const [consentedProducts, setConsentedProducts] = (0, import_react9.useState)({});
6557
+ const [consentedPurposes, setConsentedPurposes] = (0, import_react9.useState)({});
6558
+ const [isFullyConsentedReviewMode, setIsFullyConsentedReviewMode] = (0, import_react9.useState)(false);
6559
+ const [isLanguageDropdownOpen, setIsLanguageDropdownOpen] = (0, import_react9.useState)(false);
6560
+ const [selectedLanguage, setSelectedLanguage] = (0, import_react9.useState)(language);
6561
+ const chrome = (0, import_react9.useMemo)(
6494
6562
  () => noticeChromeCopy(selectedLanguage),
6495
6563
  [selectedLanguage]
6496
6564
  );
6497
- const [errorMessage, setErrorMessage] = (0, import_react8.useState)(null);
6498
- const [fetchError, setFetchError] = (0, import_react8.useState)(null);
6499
- const [ttsAudioUrls, setTtsAudioUrls] = (0, import_react8.useState)(null);
6500
- const [isTTSAvailable, setIsTTSAvailable] = (0, import_react8.useState)(false);
6501
- const [isPlaying, setIsPlaying] = (0, import_react8.useState)(false);
6502
- const [isPaused, setIsPaused] = (0, import_react8.useState)(false);
6503
- const [currentAudioIndex, setCurrentAudioIndex] = (0, import_react8.useState)(0);
6504
- const [highlightedElementId, setHighlightedElementId] = (0, import_react8.useState)(null);
6505
- const [showAgeVerification, setShowAgeVerification] = (0, import_react8.useState)(false);
6506
- const [isMinorFlow, setIsMinorFlow] = (0, import_react8.useState)(false);
6507
- const [selfDeclaredAdult, setSelfDeclaredAdult] = (0, import_react8.useState)(false);
6508
- const [showGuardianForm, setShowGuardianForm] = (0, import_react8.useState)(false);
6509
- const [isSubmittingGuardian, setIsSubmittingGuardian] = (0, import_react8.useState)(false);
6510
- const [otpPendingMode, setOtpPendingMode] = (0, import_react8.useState)(null);
6511
- const preGateSelectionRef = (0, import_react8.useRef)(null);
6512
- const otpVerifiedRef = (0, import_react8.useRef)(false);
6513
- const otpTokenAtVerifyRef = (0, import_react8.useRef)(void 0);
6514
- const [otpAcceptAfterToken, setOtpAcceptAfterToken] = (0, import_react8.useState)(null);
6515
- const [otpCode, setOtpCode] = (0, import_react8.useState)("");
6516
- const [otpError, setOtpError] = (0, import_react8.useState)(null);
6517
- const [otpBusy, setOtpBusy] = (0, import_react8.useState)(false);
6565
+ const [errorMessage, setErrorMessage] = (0, import_react9.useState)(null);
6566
+ const [fetchError, setFetchError] = (0, import_react9.useState)(null);
6567
+ const [ttsAudioUrls, setTtsAudioUrls] = (0, import_react9.useState)(null);
6568
+ const [isTTSAvailable, setIsTTSAvailable] = (0, import_react9.useState)(false);
6569
+ const [isPlaying, setIsPlaying] = (0, import_react9.useState)(false);
6570
+ const [isPaused, setIsPaused] = (0, import_react9.useState)(false);
6571
+ const [currentAudioIndex, setCurrentAudioIndex] = (0, import_react9.useState)(0);
6572
+ const [highlightedElementId, setHighlightedElementId] = (0, import_react9.useState)(null);
6573
+ const [showAgeVerification, setShowAgeVerification] = (0, import_react9.useState)(false);
6574
+ const [isMinorFlow, setIsMinorFlow] = (0, import_react9.useState)(false);
6575
+ const [selfDeclaredAdult, setSelfDeclaredAdult] = (0, import_react9.useState)(false);
6576
+ const [showGuardianForm, setShowGuardianForm] = (0, import_react9.useState)(false);
6577
+ const [isSubmittingGuardian, setIsSubmittingGuardian] = (0, import_react9.useState)(false);
6578
+ const [otpPendingMode, setOtpPendingMode] = (0, import_react9.useState)(null);
6579
+ const preGateSelectionRef = (0, import_react9.useRef)(null);
6580
+ const otpVerifiedRef = (0, import_react9.useRef)(false);
6581
+ const otpTokenAtVerifyRef = (0, import_react9.useRef)(void 0);
6582
+ const [otpAcceptAfterToken, setOtpAcceptAfterToken] = (0, import_react9.useState)(null);
6583
+ const [otpCode, setOtpCode] = (0, import_react9.useState)("");
6584
+ const [otpError, setOtpError] = (0, import_react9.useState)(null);
6585
+ const [otpBusy, setOtpBusy] = (0, import_react9.useState)(false);
6518
6586
  const otpLocked = otpPendingMode !== null;
6519
6587
  const focusOtpDigit = (index) => {
6520
6588
  var _a2;
6521
6589
  if (index < 0 || index >= OTP_GATE_LENGTH) return;
6522
6590
  (_a2 = document.getElementById(`notice-otp-digit-${index}`)) == null ? void 0 : _a2.focus();
6523
6591
  };
6524
- const [guardianFormData, setGuardianFormData] = (0, import_react8.useState)({
6592
+ const [guardianFormData, setGuardianFormData] = (0, import_react9.useState)({
6525
6593
  guardianName: "",
6526
6594
  guardianContact: "",
6527
6595
  guardianRelationship: ""
6528
6596
  });
6529
- const [guardianFormErrors, setGuardianFormErrors] = (0, import_react8.useState)({});
6530
- const [showVerificationScreen, setShowVerificationScreen] = (0, import_react8.useState)(false);
6531
- const [verificationReference, setVerificationReference] = (0, import_react8.useState)(null);
6532
- const [isInitiatingVerification, setIsInitiatingVerification] = (0, import_react8.useState)(false);
6533
- const [verificationError, setVerificationError] = (0, import_react8.useState)(
6597
+ const [guardianFormErrors, setGuardianFormErrors] = (0, import_react9.useState)({});
6598
+ const [showVerificationScreen, setShowVerificationScreen] = (0, import_react9.useState)(false);
6599
+ const [verificationReference, setVerificationReference] = (0, import_react9.useState)(null);
6600
+ const [isInitiatingVerification, setIsInitiatingVerification] = (0, import_react9.useState)(false);
6601
+ const [verificationError, setVerificationError] = (0, import_react9.useState)(
6534
6602
  null
6535
6603
  );
6536
- const [verificationErrorCode, setVerificationErrorCode] = (0, import_react8.useState)(null);
6537
- const [canRetryVerification, setCanRetryVerification] = (0, import_react8.useState)(false);
6538
- const [isPollingStatus, setIsPollingStatus] = (0, import_react8.useState)(false);
6539
- const [isVerificationComplete, setIsVerificationComplete] = (0, import_react8.useState)(false);
6540
- const [isAutoTransitioning, setIsAutoTransitioning] = (0, import_react8.useState)(false);
6541
- const modalRef = (0, import_react8.useRef)(null);
6542
- const firstFocusableRef = (0, import_react8.useRef)(null);
6543
- const lastFocusableRef = (0, import_react8.useRef)(null);
6544
- const abortControllerRef = (0, import_react8.useRef)(null);
6545
- const isRequestInProgressRef = (0, import_react8.useRef)(false);
6546
- const currentAudioRef = (0, import_react8.useRef)(null);
6547
- const popupCheckIntervalRef = (0, import_react8.useRef)(null);
6548
- const statusPollIntervalRef = (0, import_react8.useRef)(null);
6549
- const verificationPopupRef = (0, import_react8.useRef)(null);
6550
- const pollingCleanupRef = (0, import_react8.useRef)(null);
6551
- const autoTransitionTimerRef = (0, import_react8.useRef)(
6604
+ const [verificationErrorCode, setVerificationErrorCode] = (0, import_react9.useState)(null);
6605
+ const [canRetryVerification, setCanRetryVerification] = (0, import_react9.useState)(false);
6606
+ const [isPollingStatus, setIsPollingStatus] = (0, import_react9.useState)(false);
6607
+ const [isVerificationComplete, setIsVerificationComplete] = (0, import_react9.useState)(false);
6608
+ const [isAutoTransitioning, setIsAutoTransitioning] = (0, import_react9.useState)(false);
6609
+ const modalRef = (0, import_react9.useRef)(null);
6610
+ const firstFocusableRef = (0, import_react9.useRef)(null);
6611
+ const lastFocusableRef = (0, import_react9.useRef)(null);
6612
+ const abortControllerRef = (0, import_react9.useRef)(null);
6613
+ const isRequestInProgressRef = (0, import_react9.useRef)(false);
6614
+ const currentAudioRef = (0, import_react9.useRef)(null);
6615
+ const popupCheckIntervalRef = (0, import_react9.useRef)(null);
6616
+ const statusPollIntervalRef = (0, import_react9.useRef)(null);
6617
+ const verificationPopupRef = (0, import_react9.useRef)(null);
6618
+ const pollingCleanupRef = (0, import_react9.useRef)(null);
6619
+ const autoTransitionTimerRef = (0, import_react9.useRef)(
6552
6620
  null
6553
6621
  );
6554
- const digilockerRedirectTimeoutRef = (0, import_react8.useRef)(null);
6555
- const isInitialMountRef = (0, import_react8.useRef)(true);
6556
- const isPollingStatusRef = (0, import_react8.useRef)(false);
6557
- const verificationSessionTokenRef = (0, import_react8.useRef)(null);
6622
+ const digilockerRedirectTimeoutRef = (0, import_react9.useRef)(null);
6623
+ const isInitialMountRef = (0, import_react9.useRef)(true);
6624
+ const isPollingStatusRef = (0, import_react9.useRef)(false);
6625
+ const verificationSessionTokenRef = (0, import_react9.useRef)(null);
6558
6626
  const isNarrowViewport = useMediaQuery("(max-width: 768px)");
6559
6627
  const isMobile = forceMobile != null ? forceMobile : isNarrowViewport;
6560
- const baseResponsiveStyles = (0, import_react8.useMemo)(
6628
+ const baseResponsiveStyles = (0, import_react9.useMemo)(
6561
6629
  () => ({
6562
6630
  modal: {
6563
6631
  width: isMobile ? "90%" : "700px"
@@ -6638,7 +6706,7 @@ var NoticeConsentView = ({
6638
6706
  );
6639
6707
  const appearance = noticeAppearance.style;
6640
6708
  const appearanceColors = noticeAppearance.colors;
6641
- const layout = (0, import_react8.useMemo)(
6709
+ const layout = (0, import_react9.useMemo)(
6642
6710
  () => resolveNoticeLayout(noticeAppearance),
6643
6711
  [noticeAppearance]
6644
6712
  );
@@ -6648,7 +6716,7 @@ var NoticeConsentView = ({
6648
6716
  const textColor = (noticeSettings == null ? void 0 : noticeSettings.textColor) || DEFAULT_TEXT_COLOR;
6649
6717
  const classicAccentColor = ((_b = (_a = noticeSettings == null ? void 0 : noticeSettings.button) == null ? void 0 : _a.accept) == null ? void 0 : _b.backgroundColor) || (content == null ? void 0 : content.primary_color) || (content ? DEFAULT_ACCENT_COLOR : headingColor);
6650
6718
  const accentColor = (_e = appearanceColors.toggle_on) != null ? _e : hasNoticeSkin(appearance) ? ((_d = (_c = noticeSettings == null ? void 0 : noticeSettings.button) == null ? void 0 : _c.acceptAll) == null ? void 0 : _d.backgroundColor) || classicAccentColor : classicAccentColor;
6651
- const variantStyles = (0, import_react8.useMemo)(
6719
+ const variantStyles = (0, import_react9.useMemo)(
6652
6720
  () => buildVariantStyles(
6653
6721
  styles,
6654
6722
  appearance,
@@ -6657,7 +6725,7 @@ var NoticeConsentView = ({
6657
6725
  ),
6658
6726
  [appearance, appearanceColors, accentColor]
6659
6727
  );
6660
- const skin = (0, import_react8.useMemo)(
6728
+ const skin = (0, import_react9.useMemo)(
6661
6729
  () => {
6662
6730
  var _a2;
6663
6731
  return buildNoticeSkin(appearance, variantStyles, {
@@ -6682,26 +6750,26 @@ var NoticeConsentView = ({
6682
6750
  ]
6683
6751
  );
6684
6752
  const textScale = NOTICE_TEXT_SCALE_FACTORS[(_f = noticeAppearance.textScale) != null ? _f : DEFAULT_TEXT_SCALE];
6685
- const styles4 = (0, import_react8.useMemo)(
6753
+ const styles4 = (0, import_react9.useMemo)(
6686
6754
  () => {
6687
6755
  var _a2;
6688
6756
  return scaleFontSizes((_a2 = skin == null ? void 0 : skin.styles) != null ? _a2 : variantStyles, textScale);
6689
6757
  },
6690
6758
  [skin, variantStyles, textScale]
6691
6759
  );
6692
- const overlayStyle2 = (0, import_react8.useMemo)(() => {
6760
+ const overlayStyle2 = (0, import_react9.useMemo)(() => {
6693
6761
  if (!layout.dimBackdrop) {
6694
6762
  return { ...styles4.overlay, backgroundColor: "transparent" };
6695
6763
  }
6696
6764
  return appearanceColors.overlay ? { ...styles4.overlay, backgroundColor: appearanceColors.overlay } : styles4.overlay;
6697
6765
  }, [styles4.overlay, appearanceColors.overlay, layout.dimBackdrop]);
6698
6766
  const styleRadii = STYLE_RADII[appearance];
6699
- const themeCssVariables = (0, import_react8.useMemo)(
6767
+ const themeCssVariables = (0, import_react9.useMemo)(
6700
6768
  () => buildThemeCssVariables(appearanceColors),
6701
6769
  [appearanceColors]
6702
6770
  );
6703
6771
  const logoSize = noticeAppearance.logoSize;
6704
- const responsiveStyles = (0, import_react8.useMemo)(() => {
6772
+ const responsiveStyles = (0, import_react9.useMemo)(() => {
6705
6773
  var _a2;
6706
6774
  const merged = {
6707
6775
  ...baseResponsiveStyles
@@ -6720,7 +6788,7 @@ var NoticeConsentView = ({
6720
6788
  return scaleFontSizes(merged, textScale);
6721
6789
  }, [baseResponsiveStyles, skin, logoSize, textScale]);
6722
6790
  const sheetParts = skin == null ? void 0 : skin.parts;
6723
- const layoutParts = (0, import_react8.useMemo)(() => {
6791
+ const layoutParts = (0, import_react9.useMemo)(() => {
6724
6792
  var _a2;
6725
6793
  const parts = (_a2 = skin == null ? void 0 : skin.parts) != null ? _a2 : buildLayoutParts(
6726
6794
  solidSurface(appearanceColors, accentColor, STYLE_RADII[appearance]),
@@ -6763,12 +6831,12 @@ var NoticeConsentView = ({
6763
6831
  }
6764
6832
  }, [appearance, drawsSwitches]);
6765
6833
  useNoticeCustomCss(noticeId, noticeAppearance.customCss);
6766
- const [openSections, setOpenSections] = (0, import_react8.useState)({
6834
+ const [openSections, setOpenSections] = (0, import_react9.useState)({
6767
6835
  about: false,
6768
6836
  dpo: false
6769
6837
  });
6770
6838
  const isTalkbackActive = isPlaying || isPaused;
6771
- const keepFocusedSectionsOpen = (0, import_react8.useCallback)(() => {
6839
+ const keepFocusedSectionsOpen = (0, import_react9.useCallback)(() => {
6772
6840
  if (typeof document === "undefined") {
6773
6841
  return;
6774
6842
  }
@@ -6792,25 +6860,25 @@ var NoticeConsentView = ({
6792
6860
  hostFont: settings == null ? void 0 : settings.font,
6793
6861
  noticeFont: content == null ? void 0 : content.font_preference
6794
6862
  });
6795
- const componentHeadingStyle = (0, import_react8.useMemo)(
6863
+ const componentHeadingStyle = (0, import_react9.useMemo)(
6796
6864
  () => ({
6797
6865
  color: (noticeSettings == null ? void 0 : noticeSettings.headingColor) || "#323B4B"
6798
6866
  }),
6799
6867
  [noticeSettings == null ? void 0 : noticeSettings.headingColor]
6800
6868
  );
6801
- const componentTextStyle = (0, import_react8.useMemo)(
6869
+ const componentTextStyle = (0, import_react9.useMemo)(
6802
6870
  () => ({
6803
6871
  color: (noticeSettings == null ? void 0 : noticeSettings.textColor) || "#344054"
6804
6872
  }),
6805
6873
  [noticeSettings == null ? void 0 : noticeSettings.textColor]
6806
6874
  );
6807
- const sectionStyle = (0, import_react8.useMemo)(
6875
+ const sectionStyle = (0, import_react9.useMemo)(
6808
6876
  () => ({
6809
6877
  color: (noticeSettings == null ? void 0 : noticeSettings.textColor) || "#344054"
6810
6878
  }),
6811
6879
  [noticeSettings == null ? void 0 : noticeSettings.textColor]
6812
6880
  );
6813
- const logoRowStyle = (0, import_react8.useMemo)(
6881
+ const logoRowStyle = (0, import_react9.useMemo)(
6814
6882
  () => ({
6815
6883
  ...styles4.logoRow,
6816
6884
  justifyContent: logoRowJustify(
@@ -6819,7 +6887,7 @@ var NoticeConsentView = ({
6819
6887
  }),
6820
6888
  [styles4, content == null ? void 0 : content.logo_position]
6821
6889
  );
6822
- const purposeRows = (0, import_react8.useMemo)(
6890
+ const purposeRows = (0, import_react9.useMemo)(
6823
6891
  () => {
6824
6892
  var _a2;
6825
6893
  return noticePurposeRows(
@@ -6830,7 +6898,7 @@ var NoticeConsentView = ({
6830
6898
  },
6831
6899
  [content]
6832
6900
  );
6833
- const renderedPurposes = (0, import_react8.useMemo)(
6901
+ const renderedPurposes = (0, import_react9.useMemo)(
6834
6902
  () => {
6835
6903
  var _a2;
6836
6904
  return purposesInRenderOrder(
@@ -6841,7 +6909,7 @@ var NoticeConsentView = ({
6841
6909
  },
6842
6910
  [content]
6843
6911
  );
6844
- const productGroups = (0, import_react8.useMemo)(
6912
+ const productGroups = (0, import_react9.useMemo)(
6845
6913
  () => {
6846
6914
  var _a2;
6847
6915
  return groupPurposesByProduct(
@@ -6852,15 +6920,15 @@ var NoticeConsentView = ({
6852
6920
  },
6853
6921
  [content]
6854
6922
  );
6855
- const productMandatoryIsAuthoritative = (0, import_react8.useMemo)(
6923
+ const productMandatoryIsAuthoritative = (0, import_react9.useMemo)(
6856
6924
  () => serverMarksMandatoryProducts(content == null ? void 0 : content.products),
6857
6925
  [content]
6858
6926
  );
6859
- const gatedProducts = (0, import_react8.useMemo)(
6927
+ const gatedProducts = (0, import_react9.useMemo)(
6860
6928
  () => gatedProductUuids(content == null ? void 0 : content.products),
6861
6929
  [content]
6862
6930
  );
6863
- const productIsRequiredFor = (0, import_react8.useCallback)(
6931
+ const productIsRequiredFor = (0, import_react9.useCallback)(
6864
6932
  (productUuid) => {
6865
6933
  var _a2;
6866
6934
  if (!productMandatoryIsAuthoritative) return void 0;
@@ -6869,7 +6937,7 @@ var NoticeConsentView = ({
6869
6937
  },
6870
6938
  [productMandatoryIsAuthoritative, gatedProducts, content]
6871
6939
  );
6872
- const confirmVerdict = (0, import_react8.useMemo)(() => {
6940
+ const confirmVerdict = (0, import_react9.useMemo)(() => {
6873
6941
  var _a2;
6874
6942
  if (!content) return { ok: false, reason: "nothing-chosen", blocking: [] };
6875
6943
  if (purposeRows.length === 0)
@@ -6951,7 +7019,7 @@ var NoticeConsentView = ({
6951
7019
  gatedProducts
6952
7020
  ]);
6953
7021
  const acceptDisabled = isSubmitting || !confirmVerdict.ok;
6954
- (0, import_react8.useEffect)(() => {
7022
+ (0, import_react9.useEffect)(() => {
6955
7023
  var _a2, _b2;
6956
7024
  clearApiCache();
6957
7025
  isRequestInProgressRef.current = false;
@@ -7018,7 +7086,7 @@ var NoticeConsentView = ({
7018
7086
  }
7019
7087
  isInitialMountRef.current = false;
7020
7088
  }, [accessToken]);
7021
- (0, import_react8.useEffect)(() => {
7089
+ (0, import_react9.useEffect)(() => {
7022
7090
  if (hasAlreadyConsented) {
7023
7091
  onAccept == null ? void 0 : onAccept();
7024
7092
  }
@@ -7350,7 +7418,7 @@ var NoticeConsentView = ({
7350
7418
  isRequestInProgressRef.current = false;
7351
7419
  }
7352
7420
  };
7353
- (0, import_react8.useEffect)(() => {
7421
+ (0, import_react9.useEffect)(() => {
7354
7422
  injectCheckboxStyles();
7355
7423
  fetchNotice();
7356
7424
  }, [
@@ -7429,7 +7497,7 @@ var NoticeConsentView = ({
7429
7497
  });
7430
7498
  setSelectedDataElements((prev) => ({ ...prev, ...elementOverrides }));
7431
7499
  };
7432
- const productBoxPurposes = (0, import_react8.useCallback)((purposes) => {
7500
+ const productBoxPurposes = (0, import_react9.useCallback)((purposes) => {
7433
7501
  const required = purposes.filter(hasRequiredDataElement);
7434
7502
  return required.length > 0 ? required : purposes;
7435
7503
  }, []);
@@ -7631,7 +7699,7 @@ var NoticeConsentView = ({
7631
7699
  setIsSubmitting(false);
7632
7700
  }
7633
7701
  };
7634
- const handleDecline = (0, import_react8.useCallback)(async () => {
7702
+ const handleDecline = (0, import_react9.useCallback)(async () => {
7635
7703
  try {
7636
7704
  setIsSubmittingDecline(true);
7637
7705
  setIsSubmitting(true);
@@ -7649,14 +7717,14 @@ var NoticeConsentView = ({
7649
7717
  setConfirmAction(kind);
7650
7718
  setPendingAction(() => action);
7651
7719
  };
7652
- const dismissConfirm = (0, import_react8.useCallback)(() => setPendingAction(null), []);
7653
- const runPendingAction = (0, import_react8.useCallback)(() => {
7720
+ const dismissConfirm = (0, import_react9.useCallback)(() => setPendingAction(null), []);
7721
+ const runPendingAction = (0, import_react9.useCallback)(() => {
7654
7722
  const action = pendingActionRef.current;
7655
7723
  if (!action) return;
7656
7724
  setPendingAction(null);
7657
7725
  action();
7658
7726
  }, []);
7659
- const handleGuardianFormChange = (0, import_react8.useCallback)(
7727
+ const handleGuardianFormChange = (0, import_react9.useCallback)(
7660
7728
  (field, value) => {
7661
7729
  setGuardianFormData((prev) => ({
7662
7730
  ...prev,
@@ -7685,7 +7753,7 @@ var NoticeConsentView = ({
7685
7753
  setGuardianFormErrors(errors);
7686
7754
  return Object.keys(errors).length === 0;
7687
7755
  };
7688
- const handleGuardianFormNext = (0, import_react8.useCallback)(async () => {
7756
+ const handleGuardianFormNext = (0, import_react9.useCallback)(async () => {
7689
7757
  if (!validateGuardianForm()) {
7690
7758
  return;
7691
7759
  }
@@ -7826,20 +7894,20 @@ var NoticeConsentView = ({
7826
7894
  noticeId,
7827
7895
  onError
7828
7896
  ]);
7829
- const handleAgeVerificationYes = (0, import_react8.useCallback)(() => {
7897
+ const handleAgeVerificationYes = (0, import_react9.useCallback)(() => {
7830
7898
  setShowAgeVerification(false);
7831
7899
  setIsMinorFlow(false);
7832
7900
  setSelfDeclaredAdult(true);
7833
7901
  }, []);
7834
- const handleAgeVerificationNo = (0, import_react8.useCallback)(() => {
7902
+ const handleAgeVerificationNo = (0, import_react9.useCallback)(() => {
7835
7903
  setShowAgeVerification(false);
7836
7904
  setShowGuardianForm(true);
7837
7905
  }, []);
7838
- const handleVerificationContinue = (0, import_react8.useCallback)(() => {
7906
+ const handleVerificationContinue = (0, import_react9.useCallback)(() => {
7839
7907
  setShowVerificationScreen(false);
7840
7908
  setIsVerificationComplete(false);
7841
7909
  }, []);
7842
- const handlePopupClosed = (0, import_react8.useCallback)(async () => {
7910
+ const handlePopupClosed = (0, import_react9.useCallback)(async () => {
7843
7911
  var _a2, _b2;
7844
7912
  if (popupCheckIntervalRef.current) {
7845
7913
  clearInterval(popupCheckIntervalRef.current);
@@ -7881,7 +7949,7 @@ var NoticeConsentView = ({
7881
7949
  isPollingStatusRef.current = false;
7882
7950
  setIsInitiatingVerification(false);
7883
7951
  }, [accessToken, sandboxParams, baseUrl]);
7884
- const startPopupMonitoring = (0, import_react8.useCallback)(
7952
+ const startPopupMonitoring = (0, import_react9.useCallback)(
7885
7953
  (popup) => {
7886
7954
  popupCheckIntervalRef.current = window.setInterval(() => {
7887
7955
  if (popup.closed) {
@@ -7891,7 +7959,7 @@ var NoticeConsentView = ({
7891
7959
  },
7892
7960
  [handlePopupClosed]
7893
7961
  );
7894
- const getVerificationErrorMessage = (0, import_react8.useCallback)(
7962
+ const getVerificationErrorMessage = (0, import_react9.useCallback)(
7895
7963
  (errorCode, fallbackError) => {
7896
7964
  switch (errorCode) {
7897
7965
  case "GUARDIAN_UNDER_18":
@@ -7910,7 +7978,7 @@ var NoticeConsentView = ({
7910
7978
  },
7911
7979
  []
7912
7980
  );
7913
- const startStatusPolling = (0, import_react8.useCallback)(
7981
+ const startStatusPolling = (0, import_react9.useCallback)(
7914
7982
  (token2) => {
7915
7983
  verificationSessionTokenRef.current = token2;
7916
7984
  setIsPollingStatus(true);
@@ -8042,7 +8110,7 @@ var NoticeConsentView = ({
8042
8110
  },
8043
8111
  [accessToken, sandboxParams, baseUrl, getVerificationErrorMessage]
8044
8112
  );
8045
- const handleBackToGuardianForm = (0, import_react8.useCallback)((clearName = false) => {
8113
+ const handleBackToGuardianForm = (0, import_react9.useCallback)((clearName = false) => {
8046
8114
  var _a2, _b2;
8047
8115
  (_a2 = verificationPopupRef.current) == null ? void 0 : _a2.close();
8048
8116
  verificationPopupRef.current = null;
@@ -8078,7 +8146,7 @@ var NoticeConsentView = ({
8078
8146
  }
8079
8147
  clearConsentState();
8080
8148
  }, []);
8081
- const availableLanguages = (0, import_react8.useMemo)(() => {
8149
+ const availableLanguages = (0, import_react9.useMemo)(() => {
8082
8150
  if (!content) return [language];
8083
8151
  const pinned = ["English"];
8084
8152
  if (content.default_language && content.default_language !== "English" && content.default_language !== "en") {
@@ -8087,7 +8155,7 @@ var NoticeConsentView = ({
8087
8155
  const rest = content.supported_languages_and_translations ? Object.keys(content.supported_languages_and_translations).filter((lang) => !pinned.includes(lang)).sort((a, b) => a.localeCompare(b, "en")) : [];
8088
8156
  return [...pinned, ...rest];
8089
8157
  }, [content, language]);
8090
- const getLanguageCode = (0, import_react8.useCallback)(
8158
+ const getLanguageCode = (0, import_react9.useCallback)(
8091
8159
  (displayLanguage) => {
8092
8160
  if (!content) return "English";
8093
8161
  if (displayLanguage === "English" || displayLanguage === "en") {
@@ -8100,7 +8168,7 @@ var NoticeConsentView = ({
8100
8168
  },
8101
8169
  [content]
8102
8170
  );
8103
- const audioSequence = (0, import_react8.useMemo)(() => {
8171
+ const audioSequence = (0, import_react9.useMemo)(() => {
8104
8172
  if (!ttsAudioUrls || !content) return [];
8105
8173
  const sequence = [];
8106
8174
  if (ttsAudioUrls.notice_banner_heading_audio_url) {
@@ -8172,7 +8240,7 @@ var NoticeConsentView = ({
8172
8240
  }
8173
8241
  return sequence;
8174
8242
  }, [ttsAudioUrls, content, categorizedPurposes]);
8175
- const elementIdSequence = (0, import_react8.useMemo)(() => {
8243
+ const elementIdSequence = (0, import_react9.useMemo)(() => {
8176
8244
  if (!ttsAudioUrls || !content) return [];
8177
8245
  const elementIds = [];
8178
8246
  if (ttsAudioUrls.notice_banner_heading_audio_url) {
@@ -8240,7 +8308,7 @@ var NoticeConsentView = ({
8240
8308
  }
8241
8309
  return elementIds;
8242
8310
  }, [ttsAudioUrls, content, categorizedPurposes]);
8243
- const stopAudio = (0, import_react8.useCallback)(() => {
8311
+ const stopAudio = (0, import_react9.useCallback)(() => {
8244
8312
  if (currentAudioRef.current) {
8245
8313
  currentAudioRef.current.pause();
8246
8314
  currentAudioRef.current.currentTime = 0;
@@ -8252,7 +8320,7 @@ var NoticeConsentView = ({
8252
8320
  setCurrentAudioIndex(0);
8253
8321
  setHighlightedElementId(null);
8254
8322
  }, [keepFocusedSectionsOpen]);
8255
- const playNextAudio = (0, import_react8.useCallback)(
8323
+ const playNextAudio = (0, import_react9.useCallback)(
8256
8324
  (index) => {
8257
8325
  if (index >= audioSequence.length) {
8258
8326
  stopAudio();
@@ -8286,7 +8354,7 @@ var NoticeConsentView = ({
8286
8354
  },
8287
8355
  [audioSequence, elementIdSequence, stopAudio, keepFocusedSectionsOpen]
8288
8356
  );
8289
- const playAudio = (0, import_react8.useCallback)(() => {
8357
+ const playAudio = (0, import_react9.useCallback)(() => {
8290
8358
  if (audioSequence.length === 0) return;
8291
8359
  if (isPaused && currentAudioRef.current) {
8292
8360
  currentAudioRef.current.play().then(() => {
@@ -8300,21 +8368,21 @@ var NoticeConsentView = ({
8300
8368
  playNextAudio(startIndex);
8301
8369
  }
8302
8370
  }, [audioSequence, isPaused, isPlaying, currentAudioIndex, playNextAudio]);
8303
- const pauseAudio = (0, import_react8.useCallback)(() => {
8371
+ const pauseAudio = (0, import_react9.useCallback)(() => {
8304
8372
  if (currentAudioRef.current && isPlaying) {
8305
8373
  currentAudioRef.current.pause();
8306
8374
  setIsPlaying(false);
8307
8375
  setIsPaused(true);
8308
8376
  }
8309
8377
  }, [isPlaying]);
8310
- const toggleAudio = (0, import_react8.useCallback)(() => {
8378
+ const toggleAudio = (0, import_react9.useCallback)(() => {
8311
8379
  if (isPlaying) {
8312
8380
  pauseAudio();
8313
8381
  } else {
8314
8382
  playAudio();
8315
8383
  }
8316
8384
  }, [isPlaying, playAudio, pauseAudio]);
8317
- (0, import_react8.useEffect)(() => {
8385
+ (0, import_react9.useEffect)(() => {
8318
8386
  var _a2;
8319
8387
  if (!isPlaying || !content || audioSequence.length === 0) return;
8320
8388
  const currentIndex = currentAudioIndex;
@@ -8359,7 +8427,7 @@ var NoticeConsentView = ({
8359
8427
  categorizedPurposes,
8360
8428
  collapsedPurposes
8361
8429
  ]);
8362
- (0, import_react8.useEffect)(() => {
8430
+ (0, import_react9.useEffect)(() => {
8363
8431
  const removeAllHighlights = () => {
8364
8432
  document.querySelectorAll(".redacto-tts-highlight").forEach((el) => {
8365
8433
  el.classList.remove("redacto-tts-highlight");
@@ -8395,7 +8463,7 @@ var NoticeConsentView = ({
8395
8463
  removeAllHighlights();
8396
8464
  };
8397
8465
  }, [highlightedElementId, isPlaying]);
8398
- (0, import_react8.useEffect)(() => {
8466
+ (0, import_react9.useEffect)(() => {
8399
8467
  setIsTTSAvailable(false);
8400
8468
  setTtsAudioUrls(null);
8401
8469
  stopAudio();
@@ -8406,7 +8474,7 @@ var NoticeConsentView = ({
8406
8474
  const ttsAbortController = new AbortController();
8407
8475
  fetchTTSAudioUrls({
8408
8476
  accessToken,
8409
- baseUrl,
8477
+ baseUrl: endpoints.mode === "host" ? ledgerBaseUrl : baseUrl,
8410
8478
  ledgerBaseUrl,
8411
8479
  noticeUuid: content.notice_uuid,
8412
8480
  language: languageCode,
@@ -8431,6 +8499,7 @@ var NoticeConsentView = ({
8431
8499
  sandboxParams,
8432
8500
  baseUrl,
8433
8501
  ledgerBaseUrl,
8502
+ endpoints.mode,
8434
8503
  getLanguageCode
8435
8504
  ]);
8436
8505
  const hostRadius = noticeSettings == null ? void 0 : noticeSettings.borderRadius;
@@ -8467,7 +8536,7 @@ var NoticeConsentView = ({
8467
8536
  color: ((_v = (_u = noticeSettings == null ? void 0 : noticeSettings.button) == null ? void 0 : _u.decline) == null ? void 0 : _v.textColor) || (skin ? textColor : "#000000"),
8468
8537
  borderColor: (_w = appearanceColors.decline_border) != null ? _w : (noticeSettings == null ? void 0 : noticeSettings.borderColor) || (skin ? skin.palette.outline : "#d0d5dd")
8469
8538
  };
8470
- const confirmHint = (0, import_react8.useMemo)(() => {
8539
+ const confirmHint = (0, import_react9.useMemo)(() => {
8471
8540
  var _a2;
8472
8541
  const { ok, reason, blocking } = confirmVerdict;
8473
8542
  if (ok || reason === "ok" || isSubmitting) return null;
@@ -8524,7 +8593,7 @@ var NoticeConsentView = ({
8524
8593
  otpTokenAtVerifyRef.current = accessToken;
8525
8594
  setOtpAcceptAfterToken(mode);
8526
8595
  };
8527
- (0, import_react8.useEffect)(() => {
8596
+ (0, import_react9.useEffect)(() => {
8528
8597
  if (!otpAcceptAfterToken) {
8529
8598
  return;
8530
8599
  }
@@ -8538,7 +8607,7 @@ var NoticeConsentView = ({
8538
8607
  const hasPrivacyCenterLine = Boolean(
8539
8608
  (content == null ? void 0 : content.privacy_center_url) || (content == null ? void 0 : content.additional_text)
8540
8609
  );
8541
- const productPolicyLinks = (0, import_react8.useMemo)(
8610
+ const productPolicyLinks = (0, import_react9.useMemo)(
8542
8611
  () => productPolicyEntries(
8543
8612
  content == null ? void 0 : content.products,
8544
8613
  content == null ? void 0 : content.product_privacy_policies
@@ -8617,7 +8686,7 @@ var NoticeConsentView = ({
8617
8686
  const handleCloseError = () => {
8618
8687
  setErrorMessage(null);
8619
8688
  };
8620
- (0, import_react8.useEffect)(() => {
8689
+ (0, import_react9.useEffect)(() => {
8621
8690
  const handleKeyDown = (event) => {
8622
8691
  if (!modalRef.current) return;
8623
8692
  if (pendingActionRef.current) return;
@@ -8662,13 +8731,13 @@ var NoticeConsentView = ({
8662
8731
  modal == null ? void 0 : modal.removeEventListener("keydown", handleKeyDown);
8663
8732
  };
8664
8733
  }, [isLoading, handleDecline, previewContent]);
8665
- (0, import_react8.useEffect)(() => {
8734
+ (0, import_react9.useEffect)(() => {
8666
8735
  stopAudio();
8667
8736
  }, [selectedLanguage, stopAudio]);
8668
- (0, import_react8.useEffect)(() => {
8737
+ (0, import_react9.useEffect)(() => {
8669
8738
  stopAudio();
8670
8739
  }, [content, stopAudio]);
8671
- (0, import_react8.useEffect)(() => {
8740
+ (0, import_react9.useEffect)(() => {
8672
8741
  return () => {
8673
8742
  var _a2, _b2;
8674
8743
  if (abortControllerRef.current) {
@@ -8694,7 +8763,7 @@ var NoticeConsentView = ({
8694
8763
  }
8695
8764
  };
8696
8765
  }, [stopAudio]);
8697
- (0, import_react8.useEffect)(() => {
8766
+ (0, import_react9.useEffect)(() => {
8698
8767
  const persistedState = getConsentState();
8699
8768
  if (!persistedState) return;
8700
8769
  if (persistedState.noticeId && persistedState.noticeId !== noticeId) {
@@ -9815,7 +9884,7 @@ var NoticeConsentView = ({
9815
9884
  var RedactoNoticeConsent = (props) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(NoticeConsentView, { ...props });
9816
9885
 
9817
9886
  // src/RedactoNoticeConsentInline/RedactoNoticeConsentInline.tsx
9818
- var import_react10 = require("react");
9887
+ var import_react11 = require("react");
9819
9888
 
9820
9889
  // src/RedactoNoticeConsentInline/api/index.ts
9821
9890
  var BASE_URL2 = DEFAULT_CONSENT_API_BASE_URL;
@@ -10275,11 +10344,11 @@ var styles2 = {
10275
10344
  };
10276
10345
 
10277
10346
  // src/RedactoNoticeConsentInline/useMediaQuery.ts
10278
- var import_react9 = require("react");
10347
+ var import_react10 = require("react");
10279
10348
  var useMediaQuery2 = (query) => {
10280
10349
  const getMatches = () => typeof window !== "undefined" ? window.matchMedia(query).matches : false;
10281
- const [matches, setMatches] = (0, import_react9.useState)(getMatches);
10282
- (0, import_react9.useEffect)(() => {
10350
+ const [matches, setMatches] = (0, import_react10.useState)(getMatches);
10351
+ (0, import_react10.useEffect)(() => {
10283
10352
  if (typeof window === "undefined") return;
10284
10353
  const media = window.matchMedia(query);
10285
10354
  const listener = (e) => {
@@ -10336,8 +10405,8 @@ var RedactoConsentInlineComponent = ({
10336
10405
  workspace_uuid,
10337
10406
  notice_uuid,
10338
10407
  accessToken,
10339
- baseUrl,
10340
- ledgerBaseUrl,
10408
+ baseUrl: baseUrlProp,
10409
+ ledgerBaseUrl: ledgerBaseUrlProp,
10341
10410
  language = "en",
10342
10411
  onAccept,
10343
10412
  onError,
@@ -10346,24 +10415,51 @@ var RedactoConsentInlineComponent = ({
10346
10415
  applicationId
10347
10416
  }) => {
10348
10417
  var _a, _b, _c;
10349
- const [content, setContent] = (0, import_react10.useState)(null);
10350
- const [isLoading, setIsLoading] = (0, import_react10.useState)(true);
10351
- const [isSubmitting, setIsSubmitting] = (0, import_react10.useState)(false);
10352
- const [selectedLanguage, setSelectedLanguage] = (0, import_react10.useState)(language);
10353
- const [collapsedPurposes, setCollapsedPurposes] = (0, import_react10.useState)({});
10354
- const [selectedPurposes, setSelectedPurposes] = (0, import_react10.useState)({});
10355
- const [selectedDataElements, setSelectedDataElements] = (0, import_react10.useState)({});
10356
- const [hasAlreadyConsented, setHasAlreadyConsented] = (0, import_react10.useState)(false);
10357
- const [isCheckingConsent, setIsCheckingConsent] = (0, import_react10.useState)(
10418
+ const endpoints = useResolvedEndpoints(baseUrlProp, ledgerBaseUrlProp);
10419
+ const { baseUrl, ledgerBaseUrl } = endpoints;
10420
+ const [content, setContent] = (0, import_react11.useState)(null);
10421
+ const [isLoading, setIsLoading] = (0, import_react11.useState)(true);
10422
+ const [isSubmitting, setIsSubmitting] = (0, import_react11.useState)(false);
10423
+ const [selectedLanguage, setSelectedLanguage] = (0, import_react11.useState)(language);
10424
+ const [collapsedPurposes, setCollapsedPurposes] = (0, import_react11.useState)({});
10425
+ const [selectedPurposes, setSelectedPurposes] = (0, import_react11.useState)({});
10426
+ const [selectedDataElements, setSelectedDataElements] = (0, import_react11.useState)({});
10427
+ const [hasAlreadyConsented, setHasAlreadyConsented] = (0, import_react11.useState)(false);
10428
+ const [isCheckingConsent, setIsCheckingConsent] = (0, import_react11.useState)(
10358
10429
  Boolean(ledgerBaseUrl) && !applicationId
10359
10430
  );
10360
- const [fetchError, setFetchError] = (0, import_react10.useState)(null);
10361
- const [errorMessage, setErrorMessage] = (0, import_react10.useState)(null);
10362
- const hasSubmittedRef = (0, import_react10.useRef)(false);
10363
- const [awaitingConfirm, setAwaitingConfirm] = (0, import_react10.useState)(false);
10364
- const refusedSelectionRef = (0, import_react10.useRef)(null);
10365
- const confirmedSelectionRef = (0, import_react10.useRef)(null);
10366
- (0, import_react10.useEffect)(() => {
10431
+ const [fetchError, setFetchError] = (0, import_react11.useState)(null);
10432
+ const [errorMessage, setErrorMessage] = (0, import_react11.useState)(null);
10433
+ const hasSubmittedRef = (0, import_react11.useRef)(false);
10434
+ const [awaitingConfirm, setAwaitingConfirm] = (0, import_react11.useState)(false);
10435
+ const refusedSelectionRef = (0, import_react11.useRef)(null);
10436
+ const confirmedSelectionRef = (0, import_react11.useRef)(null);
10437
+ const endpointsKey = JSON.stringify([endpoints.mode, baseUrl != null ? baseUrl : "", ledgerBaseUrl != null ? ledgerBaseUrl : ""]);
10438
+ const [loadedEndpointsKey, setLoadedEndpointsKey] = (0, import_react11.useState)(endpointsKey);
10439
+ if (loadedEndpointsKey !== endpointsKey) {
10440
+ setLoadedEndpointsKey(endpointsKey);
10441
+ setContent(null);
10442
+ setIsLoading(true);
10443
+ setFetchError(null);
10444
+ setErrorMessage(null);
10445
+ setHasAlreadyConsented(false);
10446
+ setIsCheckingConsent(Boolean(ledgerBaseUrl) && !applicationId);
10447
+ setIsSubmitting(false);
10448
+ setAwaitingConfirm(false);
10449
+ }
10450
+ const endpointsGenerationRef = (0, import_react11.useRef)(0);
10451
+ const committedEndpointsKeyRef = (0, import_react11.useRef)(endpointsKey);
10452
+ useIsomorphicLayoutEffect(() => {
10453
+ if (committedEndpointsKeyRef.current === endpointsKey) {
10454
+ return;
10455
+ }
10456
+ committedEndpointsKeyRef.current = endpointsKey;
10457
+ endpointsGenerationRef.current += 1;
10458
+ hasSubmittedRef.current = false;
10459
+ refusedSelectionRef.current = null;
10460
+ confirmedSelectionRef.current = null;
10461
+ }, [endpointsKey]);
10462
+ (0, import_react11.useEffect)(() => {
10367
10463
  injectSpinnerAnimation();
10368
10464
  injectCheckboxStyles();
10369
10465
  }, []);
@@ -10371,18 +10467,18 @@ var RedactoConsentInlineComponent = ({
10371
10467
  const { colors } = inlineAppearance;
10372
10468
  useNoticeCustomCss(notice_uuid, inlineAppearance.customCss);
10373
10469
  const drawsSwitches = resolveNoticeLayout(inlineAppearance).switchControl;
10374
- (0, import_react10.useEffect)(() => {
10470
+ (0, import_react11.useEffect)(() => {
10375
10471
  if (drawsSwitches) {
10376
10472
  injectSwitchStyles();
10377
10473
  }
10378
10474
  }, [drawsSwitches]);
10379
10475
  const textScale = NOTICE_TEXT_SCALE_FACTORS[(_a = inlineAppearance.textScale) != null ? _a : DEFAULT_TEXT_SCALE];
10380
- const styles4 = (0, import_react10.useMemo)(
10476
+ const styles4 = (0, import_react11.useMemo)(
10381
10477
  () => scaleFontSizes(styles2, textScale),
10382
10478
  [textScale]
10383
10479
  );
10384
10480
  const isMobile = useMediaQuery2("(max-width: 768px)");
10385
- const responsiveStyles = (0, import_react10.useMemo)(
10481
+ const responsiveStyles = (0, import_react11.useMemo)(
10386
10482
  () => scaleFontSizes(
10387
10483
  {
10388
10484
  optionTitle: {
@@ -10403,7 +10499,7 @@ var RedactoConsentInlineComponent = ({
10403
10499
  ),
10404
10500
  [isMobile, textScale]
10405
10501
  );
10406
- const purposeRows = (0, import_react10.useMemo)(
10502
+ const purposeRows = (0, import_react11.useMemo)(
10407
10503
  () => {
10408
10504
  var _a2;
10409
10505
  return noticePurposeRows(
@@ -10414,7 +10510,7 @@ var RedactoConsentInlineComponent = ({
10414
10510
  },
10415
10511
  [content]
10416
10512
  );
10417
- const areAllRequiredElementsChecked = (0, import_react10.useMemo)(() => {
10513
+ const areAllRequiredElementsChecked = (0, import_react11.useMemo)(() => {
10418
10514
  if (!content) return false;
10419
10515
  return purposeRows.every(
10420
10516
  ({ purpose, productUuid }) => purpose.data_elements.filter(isBlockingRequiredElement).every(
@@ -10422,10 +10518,10 @@ var RedactoConsentInlineComponent = ({
10422
10518
  )
10423
10519
  );
10424
10520
  }, [content, purposeRows, selectedDataElements]);
10425
- (0, import_react10.useEffect)(() => {
10521
+ (0, import_react11.useEffect)(() => {
10426
10522
  onValidationChange == null ? void 0 : onValidationChange(areAllRequiredElementsChecked);
10427
10523
  }, [areAllRequiredElementsChecked, onValidationChange]);
10428
- (0, import_react10.useEffect)(() => {
10524
+ (0, import_react11.useEffect)(() => {
10429
10525
  if (hasAlreadyConsented) {
10430
10526
  onAccept == null ? void 0 : onAccept();
10431
10527
  }
@@ -10482,12 +10578,13 @@ var RedactoConsentInlineComponent = ({
10482
10578
  setFetchError(null);
10483
10579
  setHasAlreadyConsented(false);
10484
10580
  try {
10581
+ const noticeBaseUrl = endpoints.mode === "host" && accessToken && !applicationId ? ledgerBaseUrl : baseUrl;
10485
10582
  const consentContentData = await fetchConsentContent2({
10486
10583
  org_uuid,
10487
10584
  workspace_uuid,
10488
10585
  notice_uuid,
10489
10586
  accessToken,
10490
- baseUrl,
10587
+ baseUrl: noticeBaseUrl,
10491
10588
  language,
10492
10589
  specific_uuid: applicationId,
10493
10590
  signal
@@ -10539,7 +10636,7 @@ var RedactoConsentInlineComponent = ({
10539
10636
  }
10540
10637
  }
10541
10638
  };
10542
- (0, import_react10.useEffect)(() => {
10639
+ (0, import_react11.useEffect)(() => {
10543
10640
  const controller = new AbortController();
10544
10641
  void fetchNotice(controller.signal);
10545
10642
  return () => {
@@ -10551,9 +10648,10 @@ var RedactoConsentInlineComponent = ({
10551
10648
  notice_uuid,
10552
10649
  language,
10553
10650
  applicationId,
10554
- accessToken
10651
+ accessToken,
10652
+ endpointsKey
10555
10653
  ]);
10556
- (0, import_react10.useEffect)(() => {
10654
+ (0, import_react11.useEffect)(() => {
10557
10655
  if (!ledgerBaseUrl || applicationId) {
10558
10656
  return;
10559
10657
  }
@@ -10650,12 +10748,14 @@ var RedactoConsentInlineComponent = ({
10650
10748
  return newState;
10651
10749
  });
10652
10750
  };
10653
- const handleAcceptWithToken = (0, import_react10.useCallback)(
10751
+ const handleAcceptWithToken = (0, import_react11.useCallback)(
10654
10752
  async (tokenToUse) => {
10655
10753
  if (!tokenToUse || !content) {
10656
10754
  setErrorMessage("Unable to submit consent. Please try again.");
10657
10755
  throw new Error("Access token or content not available");
10658
10756
  }
10757
+ const generation = endpointsGenerationRef.current;
10758
+ const isCurrent = () => endpointsGenerationRef.current === generation;
10659
10759
  try {
10660
10760
  setIsSubmitting(true);
10661
10761
  setErrorMessage(null);
@@ -10691,16 +10791,24 @@ var RedactoConsentInlineComponent = ({
10691
10791
  declined: false,
10692
10792
  meta_data: applicationId ? { specific_uuid: applicationId } : void 0
10693
10793
  });
10794
+ if (!isCurrent()) {
10795
+ return;
10796
+ }
10694
10797
  onAccept == null ? void 0 : onAccept();
10695
10798
  hasSubmittedRef.current = false;
10696
10799
  } catch (error) {
10800
+ if (!isCurrent()) {
10801
+ return;
10802
+ }
10697
10803
  const err = error;
10698
10804
  const message = err.message || "Failed to submit consent. Please try again.";
10699
10805
  setErrorMessage(message);
10700
10806
  hasSubmittedRef.current = false;
10701
10807
  throw error;
10702
10808
  } finally {
10703
- setIsSubmitting(false);
10809
+ if (isCurrent()) {
10810
+ setIsSubmitting(false);
10811
+ }
10704
10812
  }
10705
10813
  },
10706
10814
  [
@@ -10717,11 +10825,11 @@ var RedactoConsentInlineComponent = ({
10717
10825
  ]
10718
10826
  );
10719
10827
  const confirmBeforeSubmit = inlineAppearance.confirmBeforeSubmit === true;
10720
- const selectionSignature = (0, import_react10.useMemo)(
10828
+ const selectionSignature = (0, import_react11.useMemo)(
10721
10829
  () => JSON.stringify([selectedPurposes, selectedDataElements]),
10722
10830
  [selectedPurposes, selectedDataElements]
10723
10831
  );
10724
- const confirmSubmission = (0, import_react10.useCallback)(() => {
10832
+ const confirmSubmission = (0, import_react11.useCallback)(() => {
10725
10833
  setAwaitingConfirm(false);
10726
10834
  confirmedSelectionRef.current = selectionSignature;
10727
10835
  hasSubmittedRef.current = true;
@@ -10731,11 +10839,11 @@ var RedactoConsentInlineComponent = ({
10731
10839
  onError == null ? void 0 : onError(err);
10732
10840
  });
10733
10841
  }, [accessToken, handleAcceptWithToken, onError, selectionSignature]);
10734
- const refuseSubmission = (0, import_react10.useCallback)(() => {
10842
+ const refuseSubmission = (0, import_react11.useCallback)(() => {
10735
10843
  setAwaitingConfirm(false);
10736
10844
  refusedSelectionRef.current = selectionSignature;
10737
10845
  }, [selectionSignature]);
10738
- (0, import_react10.useEffect)(() => {
10846
+ (0, import_react11.useEffect)(() => {
10739
10847
  if (accessToken && content && areAllRequiredElementsChecked && !isSubmitting && !isCheckingConsent && !hasAlreadyConsented && !hasSubmittedRef.current) {
10740
10848
  if (confirmBeforeSubmit) {
10741
10849
  if (refusedSelectionRef.current === selectionSignature || confirmedSelectionRef.current === selectionSignature) {
@@ -10766,7 +10874,7 @@ var RedactoConsentInlineComponent = ({
10766
10874
  confirmBeforeSubmit,
10767
10875
  selectionSignature
10768
10876
  ]);
10769
- (0, import_react10.useEffect)(() => {
10877
+ (0, import_react11.useEffect)(() => {
10770
10878
  refusedSelectionRef.current = null;
10771
10879
  confirmedSelectionRef.current = null;
10772
10880
  if (!accessToken) {
@@ -11055,10 +11163,10 @@ var RedactoConsentInlineComponent = ({
11055
11163
  );
11056
11164
  };
11057
11165
  RedactoConsentInlineComponent.displayName = "RedactoConsentInline";
11058
- var RedactoConsentInline = (0, import_react10.memo)(RedactoConsentInlineComponent);
11166
+ var RedactoConsentInline = (0, import_react11.memo)(RedactoConsentInlineComponent);
11059
11167
 
11060
11168
  // src/RedactoNoticeAssisted/RedactoNoticeAssisted.tsx
11061
- var import_react12 = require("react");
11169
+ var import_react13 = require("react");
11062
11170
 
11063
11171
  // src/RedactoNoticeAssisted/styles.ts
11064
11172
  var styles3 = {
@@ -12018,11 +12126,11 @@ var injectAssistedStyles = () => {
12018
12126
  };
12019
12127
 
12020
12128
  // src/RedactoNoticeAssisted/useMediaQuery.ts
12021
- var import_react11 = require("react");
12129
+ var import_react12 = require("react");
12022
12130
  var useMediaQuery3 = (query) => {
12023
12131
  const getMatches = () => typeof window !== "undefined" ? window.matchMedia(query).matches : false;
12024
- const [matches, setMatches] = (0, import_react11.useState)(getMatches);
12025
- (0, import_react11.useEffect)(() => {
12132
+ const [matches, setMatches] = (0, import_react12.useState)(getMatches);
12133
+ (0, import_react12.useEffect)(() => {
12026
12134
  if (typeof window === "undefined") return;
12027
12135
  const media = window.matchMedia(query);
12028
12136
  const listener = (e) => {
@@ -13643,56 +13751,60 @@ var RedactoNoticeAssisted = ({
13643
13751
  organisationUuid,
13644
13752
  workspaceUuid,
13645
13753
  noticeUuid,
13646
- baseUrl,
13647
- ledgerBaseUrl,
13754
+ baseUrl: baseUrlProp,
13755
+ ledgerBaseUrl: ledgerBaseUrlProp,
13648
13756
  onDecline,
13649
13757
  onComplete,
13650
13758
  settings
13651
13759
  }) => {
13652
13760
  var _a, _b, _c, _d;
13761
+ const { baseUrl, ledgerBaseUrl } = useResolvedEndpoints(
13762
+ baseUrlProp,
13763
+ ledgerBaseUrlProp
13764
+ );
13653
13765
  const isMobile = useMediaQuery3("(max-width: 768px)");
13654
- const [content, setContent] = (0, import_react12.useState)(null);
13655
- const [isLoading, setIsLoading] = (0, import_react12.useState)(true);
13656
- const [fetchError, setFetchError] = (0, import_react12.useState)(null);
13657
- const [step, setStep] = (0, import_react12.useState)("notice");
13658
- const [acceptMode, setAcceptMode] = (0, import_react12.useState)("selected");
13659
- const [selectedPurposes, setSelectedPurposes] = (0, import_react12.useState)({});
13660
- const [selectedDataElements, setSelectedDataElements] = (0, import_react12.useState)({});
13661
- const [collapsedPurposes, setCollapsedPurposes] = (0, import_react12.useState)({});
13662
- const [isLanguageDropdownOpen, setIsLanguageDropdownOpen] = (0, import_react12.useState)(false);
13663
- const [selectedLanguage, setSelectedLanguage] = (0, import_react12.useState)("English");
13664
- const languageContainerRef = (0, import_react12.useRef)(null);
13665
- const [ttsAudioUrls, setTtsAudioUrls] = (0, import_react12.useState)(null);
13666
- const [isTTSAvailable, setIsTTSAvailable] = (0, import_react12.useState)(false);
13667
- const [isPlaying, setIsPlaying] = (0, import_react12.useState)(false);
13668
- const [isPaused, setIsPaused] = (0, import_react12.useState)(false);
13669
- const [currentAudioIndex, setCurrentAudioIndex] = (0, import_react12.useState)(0);
13670
- const [highlightedElementId, setHighlightedElementId] = (0, import_react12.useState)(null);
13671
- const currentAudioRef = (0, import_react12.useRef)(null);
13672
- const [verifyMethod, setVerifyMethod] = (0, import_react12.useState)(
13766
+ const [content, setContent] = (0, import_react13.useState)(null);
13767
+ const [isLoading, setIsLoading] = (0, import_react13.useState)(true);
13768
+ const [fetchError, setFetchError] = (0, import_react13.useState)(null);
13769
+ const [step, setStep] = (0, import_react13.useState)("notice");
13770
+ const [acceptMode, setAcceptMode] = (0, import_react13.useState)("selected");
13771
+ const [selectedPurposes, setSelectedPurposes] = (0, import_react13.useState)({});
13772
+ const [selectedDataElements, setSelectedDataElements] = (0, import_react13.useState)({});
13773
+ const [collapsedPurposes, setCollapsedPurposes] = (0, import_react13.useState)({});
13774
+ const [isLanguageDropdownOpen, setIsLanguageDropdownOpen] = (0, import_react13.useState)(false);
13775
+ const [selectedLanguage, setSelectedLanguage] = (0, import_react13.useState)("English");
13776
+ const languageContainerRef = (0, import_react13.useRef)(null);
13777
+ const [ttsAudioUrls, setTtsAudioUrls] = (0, import_react13.useState)(null);
13778
+ const [isTTSAvailable, setIsTTSAvailable] = (0, import_react13.useState)(false);
13779
+ const [isPlaying, setIsPlaying] = (0, import_react13.useState)(false);
13780
+ const [isPaused, setIsPaused] = (0, import_react13.useState)(false);
13781
+ const [currentAudioIndex, setCurrentAudioIndex] = (0, import_react13.useState)(0);
13782
+ const [highlightedElementId, setHighlightedElementId] = (0, import_react13.useState)(null);
13783
+ const currentAudioRef = (0, import_react13.useRef)(null);
13784
+ const [verifyMethod, setVerifyMethod] = (0, import_react13.useState)(
13673
13785
  "mobile"
13674
13786
  );
13675
- const [mobile, setMobile] = (0, import_react12.useState)("");
13676
- const mobileInputRef = (0, import_react12.useRef)(null);
13677
- const [email, setEmail] = (0, import_react12.useState)("");
13678
- const emailInputRef = (0, import_react12.useRef)(null);
13679
- const [otpSent, setOtpSent] = (0, import_react12.useState)(false);
13680
- const verifyBlockRef = (0, import_react12.useRef)(null);
13681
- const otpSectionRef = (0, import_react12.useRef)(null);
13682
- const [otpDigits, setOtpDigits] = (0, import_react12.useState)(
13787
+ const [mobile, setMobile] = (0, import_react13.useState)("");
13788
+ const mobileInputRef = (0, import_react13.useRef)(null);
13789
+ const [email, setEmail] = (0, import_react13.useState)("");
13790
+ const emailInputRef = (0, import_react13.useRef)(null);
13791
+ const [otpSent, setOtpSent] = (0, import_react13.useState)(false);
13792
+ const verifyBlockRef = (0, import_react13.useRef)(null);
13793
+ const otpSectionRef = (0, import_react13.useRef)(null);
13794
+ const [otpDigits, setOtpDigits] = (0, import_react13.useState)(
13683
13795
  () => Array.from({ length: ASSISTED_CONFIG.otpLength }, () => "")
13684
13796
  );
13685
- const otpInputRefs = (0, import_react12.useRef)([]);
13686
- const [resendCountdown, setResendCountdown] = (0, import_react12.useState)(0);
13687
- const [otpUuid, setOtpUuid] = (0, import_react12.useState)("");
13688
- const [isSendingOtp, setIsSendingOtp] = (0, import_react12.useState)(false);
13689
- const [isVerifying, setIsVerifying] = (0, import_react12.useState)(false);
13690
- const [createError, setCreateError] = (0, import_react12.useState)(null);
13691
- const [otpError, setOtpError] = (0, import_react12.useState)(null);
13692
- (0, import_react12.useEffect)(() => {
13797
+ const otpInputRefs = (0, import_react13.useRef)([]);
13798
+ const [resendCountdown, setResendCountdown] = (0, import_react13.useState)(0);
13799
+ const [otpUuid, setOtpUuid] = (0, import_react13.useState)("");
13800
+ const [isSendingOtp, setIsSendingOtp] = (0, import_react13.useState)(false);
13801
+ const [isVerifying, setIsVerifying] = (0, import_react13.useState)(false);
13802
+ const [createError, setCreateError] = (0, import_react13.useState)(null);
13803
+ const [otpError, setOtpError] = (0, import_react13.useState)(null);
13804
+ (0, import_react13.useEffect)(() => {
13693
13805
  injectAssistedStyles();
13694
13806
  }, []);
13695
- (0, import_react12.useEffect)(() => {
13807
+ (0, import_react13.useEffect)(() => {
13696
13808
  const controller = new AbortController();
13697
13809
  setIsLoading(true);
13698
13810
  setFetchError(null);
@@ -13728,14 +13840,14 @@ var RedactoNoticeAssisted = ({
13728
13840
  });
13729
13841
  return () => controller.abort();
13730
13842
  }, [organisationUuid, workspaceUuid, noticeUuid, baseUrl]);
13731
- (0, import_react12.useEffect)(() => {
13843
+ (0, import_react13.useEffect)(() => {
13732
13844
  if (resendCountdown <= 0) return;
13733
13845
  const intervalId = window.setInterval(() => {
13734
13846
  setResendCountdown((prev) => prev <= 1 ? 0 : prev - 1);
13735
13847
  }, 1e3);
13736
13848
  return () => window.clearInterval(intervalId);
13737
13849
  }, [resendCountdown]);
13738
- (0, import_react12.useEffect)(() => {
13850
+ (0, import_react13.useEffect)(() => {
13739
13851
  if (step !== "verify") return;
13740
13852
  const id = window.setTimeout(
13741
13853
  () => scrollIntoViewSoft(verifyBlockRef.current),
@@ -13743,7 +13855,7 @@ var RedactoNoticeAssisted = ({
13743
13855
  );
13744
13856
  return () => window.clearTimeout(id);
13745
13857
  }, [step]);
13746
- (0, import_react12.useEffect)(() => {
13858
+ (0, import_react13.useEffect)(() => {
13747
13859
  if (!otpSent) return;
13748
13860
  const id = window.setTimeout(
13749
13861
  () => scrollIntoViewSoft(otpSectionRef.current),
@@ -13751,7 +13863,7 @@ var RedactoNoticeAssisted = ({
13751
13863
  );
13752
13864
  return () => window.clearTimeout(id);
13753
13865
  }, [otpSent]);
13754
- (0, import_react12.useEffect)(() => {
13866
+ (0, import_react13.useEffect)(() => {
13755
13867
  if (!isLanguageDropdownOpen) return;
13756
13868
  const handleClickOutside = (e) => {
13757
13869
  if (languageContainerRef.current && !languageContainerRef.current.contains(e.target)) {
@@ -13766,7 +13878,7 @@ var RedactoNoticeAssisted = ({
13766
13878
  const isMobileValid = mobile.replace(/\D/g, "").length >= 10;
13767
13879
  const isEmailValid = EMAIL_REGEX.test(email.trim());
13768
13880
  const isContactValid = verifyMethod === "email" ? isEmailValid : isMobileValid;
13769
- const displayedPurposes = (0, import_react12.useMemo)(
13881
+ const displayedPurposes = (0, import_react13.useMemo)(
13770
13882
  () => {
13771
13883
  var _a2;
13772
13884
  return purposesInRenderOrder(
@@ -13777,7 +13889,7 @@ var RedactoNoticeAssisted = ({
13777
13889
  },
13778
13890
  [content]
13779
13891
  );
13780
- const areAllRequiredElementsChecked = (0, import_react12.useMemo)(() => {
13892
+ const areAllRequiredElementsChecked = (0, import_react13.useMemo)(() => {
13781
13893
  if (!content) return false;
13782
13894
  return displayedPurposes.every((purpose) => {
13783
13895
  const requiredElements = purpose.data_elements.filter(
@@ -13788,20 +13900,20 @@ var RedactoNoticeAssisted = ({
13788
13900
  );
13789
13901
  });
13790
13902
  }, [content, displayedPurposes, selectedDataElements]);
13791
- const normalizedDefaultLang = (0, import_react12.useMemo)(() => {
13903
+ const normalizedDefaultLang = (0, import_react13.useMemo)(() => {
13792
13904
  const dl = content == null ? void 0 : content.default_language;
13793
13905
  if (!dl) return "English";
13794
13906
  return dl === "en" || dl === "EN" ? "English" : dl;
13795
13907
  }, [content]);
13796
- const isDefaultLanguage = (0, import_react12.useCallback)(
13908
+ const isDefaultLanguage = (0, import_react13.useCallback)(
13797
13909
  (lang) => lang === "English" || lang === "en" || lang === "EN",
13798
13910
  []
13799
13911
  );
13800
- const ts = (0, import_react12.useMemo)(
13912
+ const ts = (0, import_react13.useMemo)(
13801
13913
  () => makeStaticT(toBcp47Code(selectedLanguage)),
13802
13914
  [selectedLanguage]
13803
13915
  );
13804
- const getTranslatedText = (0, import_react12.useCallback)(
13916
+ const getTranslatedText = (0, import_react13.useCallback)(
13805
13917
  (key, fallback, itemId) => {
13806
13918
  var _a2, _b2, _c2;
13807
13919
  if (!content) return fallback;
@@ -13831,7 +13943,7 @@ var RedactoNoticeAssisted = ({
13831
13943
  },
13832
13944
  [content, selectedLanguage, isDefaultLanguage]
13833
13945
  );
13834
- const getTranslatedDpoText = (0, import_react12.useCallback)(
13946
+ const getTranslatedDpoText = (0, import_react13.useCallback)(
13835
13947
  (key, fallback) => {
13836
13948
  var _a2, _b2;
13837
13949
  if (!(content == null ? void 0 : content.dpo_info)) return fallback;
@@ -13843,7 +13955,7 @@ var RedactoNoticeAssisted = ({
13843
13955
  },
13844
13956
  [content, selectedLanguage, isDefaultLanguage]
13845
13957
  );
13846
- const availableLanguages = (0, import_react12.useMemo)(() => {
13958
+ const availableLanguages = (0, import_react13.useMemo)(() => {
13847
13959
  if (!content) return [selectedLanguage];
13848
13960
  const pinned = ["English"];
13849
13961
  if (normalizedDefaultLang && normalizedDefaultLang !== "English") {
@@ -13873,7 +13985,7 @@ var RedactoNoticeAssisted = ({
13873
13985
  const assistedStyle = assistedAppearance.style;
13874
13986
  const radii = STYLE_RADII[assistedStyle];
13875
13987
  const textScale = NOTICE_TEXT_SCALE_FACTORS[(_a = assistedAppearance.textScale) != null ? _a : DEFAULT_TEXT_SCALE];
13876
- const styles4 = (0, import_react12.useMemo)(
13988
+ const styles4 = (0, import_react13.useMemo)(
13877
13989
  () => scaleFontSizes(
13878
13990
  buildVariantStyles(
13879
13991
  mergeNoticeStyles(styles3, {
@@ -13911,7 +14023,7 @@ var RedactoNoticeAssisted = ({
13911
14023
  const hasPrivacyCenterLine = Boolean(
13912
14024
  (content == null ? void 0 : content.privacy_center_url) || (content == null ? void 0 : content.additional_text)
13913
14025
  );
13914
- const responsive = (0, import_react12.useMemo)(
14026
+ const responsive = (0, import_react13.useMemo)(
13915
14027
  () => scaleFontSizes(
13916
14028
  {
13917
14029
  modal: { width: isMobile ? "90%" : "700px" },
@@ -13952,7 +14064,7 @@ var RedactoNoticeAssisted = ({
13952
14064
  ),
13953
14065
  [isMobile, textScale]
13954
14066
  );
13955
- const togglePurpose = (0, import_react12.useCallback)(
14067
+ const togglePurpose = (0, import_react13.useCallback)(
13956
14068
  (uuid) => {
13957
14069
  setSelectedPurposes((prev) => {
13958
14070
  const next = !prev[uuid];
@@ -13969,10 +14081,10 @@ var RedactoNoticeAssisted = ({
13969
14081
  },
13970
14082
  [content]
13971
14083
  );
13972
- const togglePurposeCollapse = (0, import_react12.useCallback)((uuid) => {
14084
+ const togglePurposeCollapse = (0, import_react13.useCallback)((uuid) => {
13973
14085
  setCollapsedPurposes((prev) => ({ ...prev, [uuid]: !prev[uuid] }));
13974
14086
  }, []);
13975
- const handleDataElementToggle = (0, import_react12.useCallback)(
14087
+ const handleDataElementToggle = (0, import_react13.useCallback)(
13976
14088
  (purposeUuid, elementUuid) => {
13977
14089
  if (!content) return;
13978
14090
  const combinedId = `${purposeUuid}-${elementUuid}`;
@@ -13998,14 +14110,14 @@ var RedactoNoticeAssisted = ({
13998
14110
  },
13999
14111
  [content]
14000
14112
  );
14001
- const toggleLanguageDropdown = (0, import_react12.useCallback)(() => {
14113
+ const toggleLanguageDropdown = (0, import_react13.useCallback)(() => {
14002
14114
  setIsLanguageDropdownOpen((prev) => !prev);
14003
14115
  }, []);
14004
- const handleLanguageSelect = (0, import_react12.useCallback)((lang) => {
14116
+ const handleLanguageSelect = (0, import_react13.useCallback)((lang) => {
14005
14117
  setSelectedLanguage(lang);
14006
14118
  setIsLanguageDropdownOpen(false);
14007
14119
  }, []);
14008
- const audioSequence = (0, import_react12.useMemo)(() => {
14120
+ const audioSequence = (0, import_react13.useMemo)(() => {
14009
14121
  if (!ttsAudioUrls || !content) return [];
14010
14122
  const sequence = [];
14011
14123
  if (ttsAudioUrls.notice_banner_heading_audio_url) {
@@ -14066,7 +14178,7 @@ var RedactoNoticeAssisted = ({
14066
14178
  }
14067
14179
  return sequence;
14068
14180
  }, [ttsAudioUrls, content, displayedPurposes]);
14069
- const elementIdSequence = (0, import_react12.useMemo)(() => {
14181
+ const elementIdSequence = (0, import_react13.useMemo)(() => {
14070
14182
  if (!ttsAudioUrls || !content) return [];
14071
14183
  const elementIds = [];
14072
14184
  if (ttsAudioUrls.notice_banner_heading_audio_url) {
@@ -14123,7 +14235,7 @@ var RedactoNoticeAssisted = ({
14123
14235
  }
14124
14236
  return elementIds;
14125
14237
  }, [ttsAudioUrls, content, displayedPurposes]);
14126
- const stopAudio = (0, import_react12.useCallback)(() => {
14238
+ const stopAudio = (0, import_react13.useCallback)(() => {
14127
14239
  if (currentAudioRef.current) {
14128
14240
  currentAudioRef.current.pause();
14129
14241
  currentAudioRef.current.currentTime = 0;
@@ -14134,7 +14246,7 @@ var RedactoNoticeAssisted = ({
14134
14246
  setCurrentAudioIndex(0);
14135
14247
  setHighlightedElementId(null);
14136
14248
  }, []);
14137
- const playNextAudio = (0, import_react12.useCallback)(
14249
+ const playNextAudio = (0, import_react13.useCallback)(
14138
14250
  (index) => {
14139
14251
  if (index >= audioSequence.length) {
14140
14252
  stopAudio();
@@ -14167,7 +14279,7 @@ var RedactoNoticeAssisted = ({
14167
14279
  },
14168
14280
  [audioSequence, elementIdSequence, stopAudio]
14169
14281
  );
14170
- const playAudio = (0, import_react12.useCallback)(() => {
14282
+ const playAudio = (0, import_react13.useCallback)(() => {
14171
14283
  if (audioSequence.length === 0) return;
14172
14284
  if (isPaused && currentAudioRef.current) {
14173
14285
  currentAudioRef.current.play().then(() => {
@@ -14181,21 +14293,21 @@ var RedactoNoticeAssisted = ({
14181
14293
  playNextAudio(startIndex);
14182
14294
  }
14183
14295
  }, [audioSequence, isPaused, isPlaying, currentAudioIndex, playNextAudio]);
14184
- const pauseAudio = (0, import_react12.useCallback)(() => {
14296
+ const pauseAudio = (0, import_react13.useCallback)(() => {
14185
14297
  if (currentAudioRef.current && isPlaying) {
14186
14298
  currentAudioRef.current.pause();
14187
14299
  setIsPlaying(false);
14188
14300
  setIsPaused(true);
14189
14301
  }
14190
14302
  }, [isPlaying]);
14191
- const toggleAudio = (0, import_react12.useCallback)(() => {
14303
+ const toggleAudio = (0, import_react13.useCallback)(() => {
14192
14304
  if (isPlaying) {
14193
14305
  pauseAudio();
14194
14306
  } else {
14195
14307
  playAudio();
14196
14308
  }
14197
14309
  }, [isPlaying, playAudio, pauseAudio]);
14198
- (0, import_react12.useEffect)(() => {
14310
+ (0, import_react13.useEffect)(() => {
14199
14311
  setIsTTSAvailable(false);
14200
14312
  setTtsAudioUrls(null);
14201
14313
  stopAudio();
@@ -14226,7 +14338,7 @@ var RedactoNoticeAssisted = ({
14226
14338
  baseUrl,
14227
14339
  stopAudio
14228
14340
  ]);
14229
- (0, import_react12.useEffect)(() => {
14341
+ (0, import_react13.useEffect)(() => {
14230
14342
  const elementId = elementIdSequence[currentAudioIndex];
14231
14343
  if (!isPlaying || !elementId) {
14232
14344
  return;
@@ -14244,7 +14356,7 @@ var RedactoNoticeAssisted = ({
14244
14356
  displayedPurposes,
14245
14357
  collapsedPurposes
14246
14358
  ]);
14247
- (0, import_react12.useEffect)(() => {
14359
+ (0, import_react13.useEffect)(() => {
14248
14360
  const removeAllHighlights = () => {
14249
14361
  document.querySelectorAll(".redacto-tts-highlight").forEach((el) => {
14250
14362
  el.classList.remove("redacto-tts-highlight");
@@ -14275,7 +14387,7 @@ var RedactoNoticeAssisted = ({
14275
14387
  removeAllHighlights();
14276
14388
  };
14277
14389
  }, [highlightedElementId, isPlaying]);
14278
- const handleConfirmStep = (0, import_react12.useCallback)(
14390
+ const handleConfirmStep = (0, import_react13.useCallback)(
14279
14391
  (mode = "selected") => {
14280
14392
  if (mode !== "selected" && content) {
14281
14393
  const selection = buildSelectionForMode(
@@ -14300,15 +14412,15 @@ var RedactoNoticeAssisted = ({
14300
14412
  },
14301
14413
  [content, selectedPurposes, selectedDataElements, verifyMethod, stopAudio]
14302
14414
  );
14303
- const handleAcceptAll = (0, import_react12.useCallback)(
14415
+ const handleAcceptAll = (0, import_react13.useCallback)(
14304
14416
  () => handleConfirmStep("all"),
14305
14417
  [handleConfirmStep]
14306
14418
  );
14307
- const handleAcceptSelected = (0, import_react12.useCallback)(
14419
+ const handleAcceptSelected = (0, import_react13.useCallback)(
14308
14420
  () => handleConfirmStep("selected"),
14309
14421
  [handleConfirmStep]
14310
14422
  );
14311
- const handleEditSelections = (0, import_react12.useCallback)(() => {
14423
+ const handleEditSelections = (0, import_react13.useCallback)(() => {
14312
14424
  setAcceptMode("selected");
14313
14425
  setStep("notice");
14314
14426
  setOtpSent(false);
@@ -14322,7 +14434,7 @@ var RedactoNoticeAssisted = ({
14322
14434
  }, []);
14323
14435
  const otpRecipient = verifyMethod === "email" ? email.trim() : `${ASSISTED_CONFIG.dialCode}${mobile}`;
14324
14436
  const otpChannel = verifyMethod === "email" ? ASSISTED_CONFIG.emailChannel : ASSISTED_CONFIG.channel;
14325
- const sendOtp = (0, import_react12.useCallback)(async () => {
14437
+ const sendOtp = (0, import_react13.useCallback)(async () => {
14326
14438
  setCreateError(null);
14327
14439
  setIsSendingOtp(true);
14328
14440
  try {
@@ -14348,11 +14460,11 @@ var RedactoNoticeAssisted = ({
14348
14460
  setIsSendingOtp(false);
14349
14461
  }
14350
14462
  }, [organisationUuid, workspaceUuid, otpRecipient, otpChannel, baseUrl, ts]);
14351
- const handleGetOtp = (0, import_react12.useCallback)(() => {
14463
+ const handleGetOtp = (0, import_react13.useCallback)(() => {
14352
14464
  if (!isContactValid || isSendingOtp) return;
14353
14465
  void sendOtp();
14354
14466
  }, [isContactValid, isSendingOtp, sendOtp]);
14355
- const handleSelectMethod = (0, import_react12.useCallback)(
14467
+ const handleSelectMethod = (0, import_react13.useCallback)(
14356
14468
  (method) => {
14357
14469
  if (otpSent || isSendingOtp) return;
14358
14470
  setVerifyMethod(method);
@@ -14364,11 +14476,11 @@ var RedactoNoticeAssisted = ({
14364
14476
  },
14365
14477
  [otpSent, isSendingOtp]
14366
14478
  );
14367
- const handleResend = (0, import_react12.useCallback)(() => {
14479
+ const handleResend = (0, import_react13.useCallback)(() => {
14368
14480
  if (isSendingOtp) return;
14369
14481
  void sendOtp();
14370
14482
  }, [isSendingOtp, sendOtp]);
14371
- const handleChangeContact = (0, import_react12.useCallback)(() => {
14483
+ const handleChangeContact = (0, import_react13.useCallback)(() => {
14372
14484
  setOtpSent(false);
14373
14485
  setOtpUuid("");
14374
14486
  setOtpDigits(Array.from({ length: ASSISTED_CONFIG.otpLength }, () => ""));
@@ -14380,7 +14492,7 @@ var RedactoNoticeAssisted = ({
14380
14492
  (_a2 = (verifyMethod === "email" ? emailInputRef : mobileInputRef).current) == null ? void 0 : _a2.focus();
14381
14493
  }, 0);
14382
14494
  }, [verifyMethod]);
14383
- const handleOtpChange = (0, import_react12.useCallback)((index, raw) => {
14495
+ const handleOtpChange = (0, import_react13.useCallback)((index, raw) => {
14384
14496
  var _a2;
14385
14497
  const digit = raw.replace(/\D/g, "").slice(-1);
14386
14498
  setOtpDigits((prev) => {
@@ -14392,7 +14504,7 @@ var RedactoNoticeAssisted = ({
14392
14504
  (_a2 = otpInputRefs.current[index + 1]) == null ? void 0 : _a2.focus();
14393
14505
  }
14394
14506
  }, []);
14395
- const handleOtpKeyDown = (0, import_react12.useCallback)(
14507
+ const handleOtpKeyDown = (0, import_react13.useCallback)(
14396
14508
  (index, e) => {
14397
14509
  var _a2;
14398
14510
  if (e.key === "Backspace" && !otpDigits[index] && index > 0) {
@@ -14401,7 +14513,7 @@ var RedactoNoticeAssisted = ({
14401
14513
  },
14402
14514
  [otpDigits]
14403
14515
  );
14404
- const handleOtpPaste = (0, import_react12.useCallback)((e) => {
14516
+ const handleOtpPaste = (0, import_react13.useCallback)((e) => {
14405
14517
  var _a2;
14406
14518
  const pasted = e.clipboardData.getData("text").replace(/\D/g, "").slice(0, ASSISTED_CONFIG.otpLength);
14407
14519
  if (!pasted) return;
@@ -14418,7 +14530,7 @@ var RedactoNoticeAssisted = ({
14418
14530
  const focusIndex = Math.min(pasted.length, ASSISTED_CONFIG.otpLength - 1);
14419
14531
  (_a2 = otpInputRefs.current[focusIndex]) == null ? void 0 : _a2.focus();
14420
14532
  }, []);
14421
- const resetFlow = (0, import_react12.useCallback)(() => {
14533
+ const resetFlow = (0, import_react13.useCallback)(() => {
14422
14534
  var _a2;
14423
14535
  setStep("notice");
14424
14536
  const preselection = buildPreselection(
@@ -14437,7 +14549,7 @@ var RedactoNoticeAssisted = ({
14437
14549
  setCreateError(null);
14438
14550
  setOtpError(null);
14439
14551
  }, [content]);
14440
- const handleSuccess = (0, import_react12.useCallback)(() => {
14552
+ const handleSuccess = (0, import_react13.useCallback)(() => {
14441
14553
  if (onComplete) {
14442
14554
  onComplete();
14443
14555
  return;
@@ -14445,7 +14557,7 @@ var RedactoNoticeAssisted = ({
14445
14557
  console.log("[RedactoNoticeAssisted] consent recorded");
14446
14558
  resetFlow();
14447
14559
  }, [onComplete, resetFlow]);
14448
- const handleConfirm = (0, import_react12.useCallback)(async () => {
14560
+ const handleConfirm = (0, import_react13.useCallback)(async () => {
14449
14561
  if (!isOtpComplete || isVerifying || !content) return;
14450
14562
  setOtpError(null);
14451
14563
  setIsVerifying(true);
@@ -14538,7 +14650,7 @@ var RedactoNoticeAssisted = ({
14538
14650
  handleSuccess,
14539
14651
  ts
14540
14652
  ]);
14541
- const handleDecline = (0, import_react12.useCallback)(() => {
14653
+ const handleDecline = (0, import_react13.useCallback)(() => {
14542
14654
  if (onDecline) {
14543
14655
  onDecline();
14544
14656
  return;
@@ -15434,20 +15546,29 @@ var RedactoNoticePreview = ({
15434
15546
  ) });
15435
15547
 
15436
15548
  // src/RedactoNoticeConsent/components/DigiLockerCallback.tsx
15437
- var import_react13 = require("react");
15549
+ var import_react14 = require("react");
15438
15550
  var import_jsx_runtime11 = require("react/jsx-runtime");
15551
+ var sameOriginUrlOrRoot = (candidate) => {
15552
+ if (!candidate) return "/";
15553
+ try {
15554
+ const url = new URL(candidate, window.location.origin);
15555
+ return url.origin === window.location.origin ? url.href : "/";
15556
+ } catch {
15557
+ return "/";
15558
+ }
15559
+ };
15439
15560
  var DigiLockerCallback = ({
15440
15561
  accessToken: propAccessToken,
15441
15562
  baseUrl,
15442
15563
  onSuccess,
15443
15564
  onError
15444
15565
  }) => {
15445
- const [status, setStatus] = (0, import_react13.useState)("processing");
15446
- const [message, setMessage] = (0, import_react13.useState)("Verifying your guardian...");
15447
- const [errorDetail, setErrorDetail] = (0, import_react13.useState)(null);
15448
- const retryTimeoutRef = (0, import_react13.useRef)(null);
15449
- const redirectTimeoutRef = (0, import_react13.useRef)(null);
15450
- const isMountedRef = (0, import_react13.useRef)(true);
15566
+ const [status, setStatus] = (0, import_react14.useState)("processing");
15567
+ const [message, setMessage] = (0, import_react14.useState)("Verifying your guardian...");
15568
+ const [errorDetail, setErrorDetail] = (0, import_react14.useState)(null);
15569
+ const retryTimeoutRef = (0, import_react14.useRef)(null);
15570
+ const redirectTimeoutRef = (0, import_react14.useRef)(null);
15571
+ const isMountedRef = (0, import_react14.useRef)(true);
15451
15572
  const getErrorMessage = (errorCode) => {
15452
15573
  switch (errorCode) {
15453
15574
  case "GUARDIAN_UNDER_18":
@@ -15464,7 +15585,7 @@ var DigiLockerCallback = ({
15464
15585
  return "Verification failed. Please try again.";
15465
15586
  }
15466
15587
  };
15467
- const redirectToOriginalPage = (0, import_react13.useCallback)(
15588
+ const redirectToOriginalPage = (0, import_react14.useCallback)(
15468
15589
  (originalUrl, verificationResult, verificationReference) => {
15469
15590
  updateConsentState({
15470
15591
  verificationResult,
@@ -15472,12 +15593,12 @@ var DigiLockerCallback = ({
15472
15593
  flowState: verificationResult === "verified" ? "consent-form" : "error"
15473
15594
  });
15474
15595
  redirectTimeoutRef.current = setTimeout(() => {
15475
- window.location.href = originalUrl;
15596
+ window.location.href = sameOriginUrlOrRoot(originalUrl);
15476
15597
  }, 1500);
15477
15598
  },
15478
15599
  []
15479
15600
  );
15480
- const handleCallback = (0, import_react13.useCallback)(async () => {
15601
+ const handleCallback = (0, import_react14.useCallback)(async () => {
15481
15602
  var _a, _b;
15482
15603
  try {
15483
15604
  const params = new URLSearchParams(window.location.search);
@@ -15544,7 +15665,7 @@ var DigiLockerCallback = ({
15544
15665
  return;
15545
15666
  }
15546
15667
  setMessage("Processing verification...");
15547
- const apiBaseUrl = baseUrl || storedBaseUrl;
15668
+ const apiBaseUrl = resolveEndpoints(baseUrl || storedBaseUrl).baseUrl;
15548
15669
  const response = await verifyGuardianStatus({
15549
15670
  accessToken,
15550
15671
  baseUrl: apiBaseUrl,
@@ -15692,7 +15813,7 @@ var DigiLockerCallback = ({
15692
15813
  }
15693
15814
  }
15694
15815
  }, [propAccessToken, baseUrl, onSuccess, onError, redirectToOriginalPage]);
15695
- (0, import_react13.useEffect)(() => {
15816
+ (0, import_react14.useEffect)(() => {
15696
15817
  injectCheckboxStyles();
15697
15818
  handleCallback();
15698
15819
  return () => {
@@ -15701,11 +15822,11 @@ var DigiLockerCallback = ({
15701
15822
  if (redirectTimeoutRef.current) clearTimeout(redirectTimeoutRef.current);
15702
15823
  };
15703
15824
  }, [handleCallback]);
15704
- const handleRetry = (0, import_react13.useCallback)(() => {
15825
+ const handleRetry = (0, import_react14.useCallback)(() => {
15705
15826
  const persistedState = getConsentState();
15706
15827
  if (persistedState == null ? void 0 : persistedState.originalUrl) {
15707
15828
  clearConsentState();
15708
- window.location.href = persistedState.originalUrl;
15829
+ window.location.href = sameOriginUrlOrRoot(persistedState.originalUrl);
15709
15830
  } else {
15710
15831
  window.location.href = "/";
15711
15832
  }