@forgerock/login-widget 1.0.0-beta.5 → 1.0.0-beta.6

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.
@@ -181,11 +181,6 @@ function set_data(text, data) {
181
181
  function set_input_value(input, value) {
182
182
  input.value = value == null ? '' : value;
183
183
  }
184
- function custom_event(type, detail, { bubbles = false, cancelable = false } = {}) {
185
- const e = document.createEvent('CustomEvent');
186
- e.initCustomEvent(type, bubbles, cancelable, detail);
187
- return e;
188
- }
189
184
  class HtmlTag {
190
185
  constructor(is_svg = false) {
191
186
  this.is_svg = false;
@@ -257,34 +252,6 @@ function onMount(fn) {
257
252
  function afterUpdate(fn) {
258
253
  get_current_component().$$.after_update.push(fn);
259
254
  }
260
- /**
261
- * Creates an event dispatcher that can be used to dispatch [component events](/docs#template-syntax-component-directives-on-eventname).
262
- * Event dispatchers are functions that can take two arguments: `name` and `detail`.
263
- *
264
- * Component events created with `createEventDispatcher` create a
265
- * [CustomEvent](https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent).
266
- * These events do not [bubble](https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Building_blocks/Events#Event_bubbling_and_capture).
267
- * The `detail` argument corresponds to the [CustomEvent.detail](https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/detail)
268
- * property and can contain any type of data.
269
- *
270
- * https://svelte.dev/docs#run-time-svelte-createeventdispatcher
271
- */
272
- function createEventDispatcher() {
273
- const component = get_current_component();
274
- return (type, detail, { cancelable = false } = {}) => {
275
- const callbacks = component.$$.callbacks[type];
276
- if (callbacks) {
277
- // TODO are there situations where events could be dispatched
278
- // in a server (non-DOM) environment?
279
- const event = custom_event(type, detail, { cancelable });
280
- callbacks.slice().forEach(fn => {
281
- fn.call(component, event);
282
- });
283
- return !event.defaultPrevented;
284
- }
285
- return true;
286
- };
287
- }
288
255
 
289
256
  const dirty_components = [];
290
257
  const binding_callbacks = [];
@@ -604,6 +571,172 @@ class SvelteComponent {
604
571
  }
605
572
  }
606
573
 
574
+ const subscriber_queue = [];
575
+ /**
576
+ * Creates a `Readable` store that allows reading by subscription.
577
+ * @param value initial value
578
+ * @param {StartStopNotifier}start start and stop notifications for subscriptions
579
+ */
580
+ function readable(value, start) {
581
+ return {
582
+ subscribe: writable(value, start).subscribe
583
+ };
584
+ }
585
+ /**
586
+ * Create a `Writable` store that allows both updating and reading by subscription.
587
+ * @param {*=}value initial value
588
+ * @param {StartStopNotifier=}start start and stop notifications for subscriptions
589
+ */
590
+ function writable(value, start = noop) {
591
+ let stop;
592
+ const subscribers = new Set();
593
+ function set(new_value) {
594
+ if (safe_not_equal(value, new_value)) {
595
+ value = new_value;
596
+ if (stop) { // store is ready
597
+ const run_queue = !subscriber_queue.length;
598
+ for (const subscriber of subscribers) {
599
+ subscriber[1]();
600
+ subscriber_queue.push(subscriber, value);
601
+ }
602
+ if (run_queue) {
603
+ for (let i = 0; i < subscriber_queue.length; i += 2) {
604
+ subscriber_queue[i][0](subscriber_queue[i + 1]);
605
+ }
606
+ subscriber_queue.length = 0;
607
+ }
608
+ }
609
+ }
610
+ }
611
+ function update(fn) {
612
+ set(fn(value));
613
+ }
614
+ function subscribe(run, invalidate = noop) {
615
+ const subscriber = [run, invalidate];
616
+ subscribers.add(subscriber);
617
+ if (subscribers.size === 1) {
618
+ stop = start(set) || noop;
619
+ }
620
+ run(value);
621
+ return () => {
622
+ subscribers.delete(subscriber);
623
+ if (subscribers.size === 0) {
624
+ stop();
625
+ stop = null;
626
+ }
627
+ };
628
+ }
629
+ return { set, update, subscribe };
630
+ }
631
+ function derived(stores, fn, initial_value) {
632
+ const single = !Array.isArray(stores);
633
+ const stores_array = single
634
+ ? [stores]
635
+ : stores;
636
+ const auto = fn.length < 2;
637
+ return readable(initial_value, (set) => {
638
+ let inited = false;
639
+ const values = [];
640
+ let pending = 0;
641
+ let cleanup = noop;
642
+ const sync = () => {
643
+ if (pending) {
644
+ return;
645
+ }
646
+ cleanup();
647
+ const result = fn(single ? values[0] : values, set);
648
+ if (auto) {
649
+ set(result);
650
+ }
651
+ else {
652
+ cleanup = is_function(result) ? result : noop;
653
+ }
654
+ };
655
+ const unsubscribers = stores_array.map((store, i) => subscribe(store, (value) => {
656
+ values[i] = value;
657
+ pending &= ~(1 << i);
658
+ if (inited) {
659
+ sync();
660
+ }
661
+ }, () => {
662
+ pending |= (1 << i);
663
+ }));
664
+ inited = true;
665
+ sync();
666
+ return function stop() {
667
+ run_all(unsubscribers);
668
+ cleanup();
669
+ };
670
+ });
671
+ }
672
+
673
+ const componentStore = writable({
674
+ modal: null,
675
+ form: null,
676
+ error: null,
677
+ mounted: false,
678
+ open: null,
679
+ reason: null,
680
+ type: null,
681
+ });
682
+ const componentApi = () => {
683
+ const { update, subscribe } = componentStore;
684
+ return {
685
+ close: (args) => {
686
+ update((state) => {
687
+ if (state.type === 'inline') {
688
+ console.warn('Component type of "inline" has no `close` method');
689
+ // There's nothing to do, so just return existing state
690
+ return state;
691
+ }
692
+ if (!state.modal) {
693
+ console.warn('Modal component is not mounted. Please instantiate the Widget before use.');
694
+ // There's nothing to do, so just return existing state
695
+ return state;
696
+ }
697
+ state.modal?.component.closeDialog();
698
+ return {
699
+ ...state,
700
+ open: false,
701
+ reason: args?.reason || null,
702
+ };
703
+ });
704
+ },
705
+ mount: (component, element) => {
706
+ update((state) => {
707
+ return {
708
+ ...state,
709
+ modal: {
710
+ ...(component && { component, element }),
711
+ },
712
+ mounted: true,
713
+ type: component ? 'modal' : 'inline',
714
+ };
715
+ });
716
+ },
717
+ open: () => {
718
+ update((state) => {
719
+ if (state.type === 'inline') {
720
+ console.warn('Component type of "inline" has no `open` method');
721
+ // There's nothing to do, so just return existing state
722
+ return state;
723
+ }
724
+ if (!state.modal) {
725
+ console.warn('Modal component is not mounted. Please instantiate the Widget before use.');
726
+ // There's nothing to do, so just return existing state
727
+ return state;
728
+ }
729
+ state.modal.element.showModal();
730
+ return {
731
+ ...state,
732
+ open: true,
733
+ };
734
+ });
735
+ },
736
+ subscribe,
737
+ };
738
+ };
739
+
607
740
  /*
608
741
  * @forgerock/javascript-sdk
609
742
  *
@@ -6599,7 +6732,7 @@ enums$2.PolicyKey = PolicyKey;
6599
6732
 
6600
6733
  var messageCreator = {};
6601
6734
 
6602
- var strings$1 = {};
6735
+ var strings = {};
6603
6736
 
6604
6737
  /*
6605
6738
  * @forgerock/javascript-sdk
@@ -6610,8 +6743,8 @@ var strings$1 = {};
6610
6743
  * This software may be modified and distributed under the terms
6611
6744
  * of the MIT license. See the LICENSE file for details.
6612
6745
  */
6613
- Object.defineProperty(strings$1, "__esModule", { value: true });
6614
- strings$1.plural = void 0;
6746
+ Object.defineProperty(strings, "__esModule", { value: true });
6747
+ strings.plural = void 0;
6615
6748
  /**
6616
6749
  * @module
6617
6750
  * @ignore
@@ -6623,7 +6756,7 @@ function plural(n, singularText, pluralText) {
6623
6756
  }
6624
6757
  return pluralText !== undefined ? pluralText : singularText + 's';
6625
6758
  }
6626
- strings$1.plural = plural;
6759
+ strings.plural = plural;
6627
6760
 
6628
6761
  var helpers$2 = {};
6629
6762
 
@@ -6657,7 +6790,7 @@ helpers$2.getProp = getProp;
6657
6790
  */
6658
6791
  var _a;
6659
6792
  Object.defineProperty(messageCreator, "__esModule", { value: true });
6660
- var strings_1 = strings$1;
6793
+ var strings_1 = strings;
6661
6794
  var enums_1$7 = enums$2;
6662
6795
  var helpers_1$2 = helpers$2;
6663
6796
  var defaultMessageCreator = (_a = {},
@@ -10715,64 +10848,6 @@ var HttpClient = /** @class */ (function (_super) {
10715
10848
  }(event_1.default));
10716
10849
  var _default$2 = httpClient.default = HttpClient;
10717
10850
 
10718
- const subscriber_queue = [];
10719
- /**
10720
- * Creates a `Readable` store that allows reading by subscription.
10721
- * @param value initial value
10722
- * @param {StartStopNotifier}start start and stop notifications for subscriptions
10723
- */
10724
- function readable(value, start) {
10725
- return {
10726
- subscribe: writable(value, start).subscribe
10727
- };
10728
- }
10729
- /**
10730
- * Create a `Writable` store that allows both updating and reading by subscription.
10731
- * @param {*=}value initial value
10732
- * @param {StartStopNotifier=}start start and stop notifications for subscriptions
10733
- */
10734
- function writable(value, start = noop) {
10735
- let stop;
10736
- const subscribers = new Set();
10737
- function set(new_value) {
10738
- if (safe_not_equal(value, new_value)) {
10739
- value = new_value;
10740
- if (stop) { // store is ready
10741
- const run_queue = !subscriber_queue.length;
10742
- for (const subscriber of subscribers) {
10743
- subscriber[1]();
10744
- subscriber_queue.push(subscriber, value);
10745
- }
10746
- if (run_queue) {
10747
- for (let i = 0; i < subscriber_queue.length; i += 2) {
10748
- subscriber_queue[i][0](subscriber_queue[i + 1]);
10749
- }
10750
- subscriber_queue.length = 0;
10751
- }
10752
- }
10753
- }
10754
- }
10755
- function update(fn) {
10756
- set(fn(value));
10757
- }
10758
- function subscribe(run, invalidate = noop) {
10759
- const subscriber = [run, invalidate];
10760
- subscribers.add(subscriber);
10761
- if (subscribers.size === 1) {
10762
- stop = start(set) || noop;
10763
- }
10764
- run(value);
10765
- return () => {
10766
- subscribers.delete(subscriber);
10767
- if (subscribers.size === 0) {
10768
- stop();
10769
- stop = null;
10770
- }
10771
- };
10772
- }
10773
- return { set, update, subscribe };
10774
- }
10775
-
10776
10851
  var util$2;
10777
10852
  (function (util) {
10778
10853
  util.assertEqual = (val) => val;
@@ -13950,240 +14025,80 @@ function configure (config) {
13950
14025
  Config.set(config);
13951
14026
  }
13952
14027
 
13953
- function widgetApiFactory(modal) {
13954
- let journeyStore;
13955
- let oauthStore;
13956
- let userStore;
13957
- let returnError;
13958
- let returnResponse;
13959
- const configuration = {
13960
- set(options) {
13961
- // Set base config to SDK
13962
- // TODO: Move to a shared utility
13963
- configure({
13964
- // Set some basics by default
13965
- ...{
13966
- // TODO: Could this be a default OAuth client provided by Platform UI OOTB?
13967
- clientId: 'WebLoginWidgetClient',
13968
- // TODO: If a realmPath is not provided, should we call the realm endpoint and detect a likely default?
13969
- // https://backstage.forgerock.com/docs/am/7/setup-guide/sec-rest-realm-rest.html#rest-api-list-realm
13970
- realmPath: 'alpha',
13971
- // TODO: Once we move to SSR, this default should be more intelligent
13972
- redirectUri: typeof window === 'object' ? window.location.href : 'https://localhost:3000/callback',
13973
- scope: 'openid email',
13974
- },
13975
- // Let user provided config override defaults
13976
- ...options,
13977
- // Force 'legacy' to remove confusion
13978
- ...{ support: 'legacy' },
13979
- });
13980
- },
13981
- };
13982
- const journey = {
13983
- start(options) {
13984
- const requestsOauth = options?.oauth || true;
13985
- const requestsUser = options?.user || true;
13986
- let journey;
13987
- let oauth;
13988
- const journeyStoreUnsub = journeyStore.subscribe((response) => {
13989
- if (!requestsOauth && response.successful) {
13990
- returnResponse &&
13991
- returnResponse({
13992
- journey: response,
13993
- });
13994
- if (modal) {
13995
- modal.close({ reason: 'auto' });
13996
- }
13997
- }
13998
- else if (requestsOauth && response.successful) {
13999
- journey = response;
14000
- oauthStore?.get({ forceRenew: true });
14001
- }
14002
- else if (response.error) {
14003
- journey = response;
14004
- returnError &&
14005
- returnError({
14006
- journey: response,
14007
- });
14008
- }
14009
- /**
14010
- * Clean up unneeded subscription, but only when it's successful
14011
- * Leaving the subscription allows for the journey to be
14012
- * restarted internally.
14013
- */
14014
- if (response.successful) {
14015
- journeyStoreUnsub();
14016
- }
14017
- });
14018
- const oauthStoreUnsub = oauthStore.subscribe((response) => {
14019
- if (!requestsUser && response.successful) {
14020
- returnResponse &&
14021
- returnResponse({
14022
- journey,
14023
- oauth: response,
14024
- });
14025
- if (modal) {
14026
- modal.close({ reason: 'auto' });
14027
- }
14028
- }
14029
- else if (requestsUser && response.successful) {
14030
- oauth = response;
14031
- userStore?.get();
14032
- }
14033
- else if (response.error) {
14034
- oauth = response;
14035
- returnError &&
14036
- returnError({
14037
- journey,
14038
- oauth: response,
14039
- });
14040
- }
14041
- /**
14042
- * Clean up unneeded subscription, but only when it's successful
14043
- * Leaving the subscription allows for the journey to be
14044
- * restarted internally.
14045
- */
14046
- if (response.successful) {
14047
- oauthStoreUnsub();
14048
- }
14049
- });
14050
- const userStoreUnsub = userStore.subscribe((response) => {
14051
- if (response.successful) {
14052
- returnResponse &&
14053
- returnResponse({
14054
- journey,
14055
- oauth,
14056
- user: response,
14057
- });
14058
- if (modal) {
14059
- modal.close({ reason: 'auto' });
14060
- }
14061
- }
14062
- else if (response.error) {
14063
- returnError &&
14064
- returnError({
14065
- journey,
14066
- oauth,
14067
- user: response,
14068
- });
14069
- }
14070
- /**
14071
- * Clean up unneeded subscription, but only when it's successful
14072
- * Leaving the subscription allows for the journey to be
14073
- * restarted internally.
14074
- */
14075
- if (response.successful) {
14076
- userStoreUnsub();
14077
- }
14078
- });
14079
- if (options?.resumeUrl) {
14080
- journeyStore.resume(options.resumeUrl);
14081
- }
14082
- else {
14083
- journeyStore.start({
14084
- ...options?.config,
14085
- tree: options?.journey,
14086
- });
14087
- }
14088
- },
14089
- onFailure(fn) {
14090
- returnError = (response) => fn(response);
14091
- },
14092
- onSuccess(fn) {
14093
- returnResponse = (response) => fn(response);
14094
- },
14095
- };
14096
- const user = {
14097
- // TODO: add "scopes" to parameters for "true" authorization
14098
- async authorized(remote = false) {
14099
- if (remote) {
14100
- try {
14101
- return await UserManager.getCurrentUser();
14102
- }
14103
- catch (err) {
14104
- console.warn(err);
14105
- return;
14106
- }
14107
- }
14108
- try {
14109
- return !!(await TokenManager$1.getTokens());
14110
- }
14111
- catch (err) {
14112
- return;
14113
- }
14114
- },
14115
- async info(remote = false) {
14116
- userStore = userStore;
14117
- if (remote) {
14118
- try {
14119
- return await UserManager.getCurrentUser();
14120
- }
14121
- catch (err) {
14122
- console.warn(err);
14123
- return;
14124
- }
14125
- }
14126
- return get_store_value(userStore).response;
14127
- },
14128
- logout: async () => {
14129
- const { clientId } = Config.get();
14130
- userStore = userStore;
14131
- /**
14132
- * If configuration has a clientId, then use FRUser to logout to ensure
14133
- * token revoking and removal; else, just end the session.
14134
- */
14135
- if (clientId) {
14136
- // Call SDK logout
14137
- await FRUser.logout();
14138
- }
14139
- else {
14140
- await SessionManager.logout();
14141
- }
14142
- // Reset stores
14143
- journeyStore && journeyStore.reset();
14144
- oauthStore && oauthStore.reset();
14145
- userStore && userStore.reset();
14146
- // Fetch fresh journey step
14147
- journey && journey.start();
14148
- },
14149
- async tokens(options) {
14150
- // `getTokens` throws if no tokens, so catch and just return with `undefined`
14151
- try {
14152
- return await TokenManager$1.getTokens(options);
14153
- }
14154
- catch (err) {
14155
- console.warn(err);
14156
- return;
14157
- }
14158
- },
14159
- };
14160
- return {
14161
- configuration,
14162
- journey,
14163
- async request(options) {
14164
- return await _default$2.request(options);
14165
- },
14166
- getJourneyStore() {
14167
- return journeyStore;
14168
- },
14169
- getOAuthStore() {
14170
- return oauthStore;
14171
- },
14172
- getUserStore() {
14173
- return userStore;
14174
- },
14175
- ...(modal && { modal }),
14176
- setJourneyStore(store) {
14177
- journeyStore = store;
14178
- },
14179
- setOAuthStore(store) {
14180
- oauthStore = store;
14181
- },
14182
- setUserStore(store) {
14183
- userStore = store;
14184
- },
14185
- user,
14186
- };
14028
+ const journeyConfigItemSchema = mod.object({
14029
+ journey: mod.string().optional(),
14030
+ match: mod
14031
+ .string()
14032
+ .regex(/^(#\/service|\?journey)/, {
14033
+ message: 'HREF string must start with `?journey` or `#/service`',
14034
+ })
14035
+ .array(),
14036
+ });
14037
+ const journeyConfigSchema = mod.object({
14038
+ forgotPassword: journeyConfigItemSchema,
14039
+ forgotUsername: journeyConfigItemSchema,
14040
+ login: journeyConfigItemSchema,
14041
+ register: journeyConfigItemSchema,
14042
+ });
14043
+ const defaultJourneys = {
14044
+ forgotPassword: {
14045
+ journey: 'ResetPassword',
14046
+ match: ['#/service/ResetPassword', '?journey=ResetPassword'],
14047
+ },
14048
+ forgotUsername: {
14049
+ journey: 'ForgottenUsername',
14050
+ match: ['#/service/ForgottenUsername', '?journey=ForgottenUsername'],
14051
+ },
14052
+ login: {
14053
+ journey: undefined,
14054
+ match: ['#/service/Login', '?journey'],
14055
+ },
14056
+ register: {
14057
+ journey: 'Registration',
14058
+ match: ['#/service/Registration', '?journey=Registration'],
14059
+ },
14060
+ };
14061
+ // Ensure default follows schema
14062
+ journeyConfigSchema.parse(defaultJourneys);
14063
+ const configuredJourneysStore = writable(Object.keys(defaultJourneys).map((key) => ({
14064
+ ...defaultJourneys[key],
14065
+ key,
14066
+ })));
14067
+ function initialize$6(customJourneys) {
14068
+ if (customJourneys) {
14069
+ // Provide developer feedback if customized
14070
+ journeyConfigSchema.parse(customJourneys);
14071
+ const arr = Object.keys(customJourneys);
14072
+ configuredJourneysStore.set(arr.map((key) => ({
14073
+ ...customJourneys[key],
14074
+ key,
14075
+ })));
14076
+ }
14077
+ return configuredJourneysStore;
14078
+ }
14079
+
14080
+ /*
14081
+ * forgerock-sample-web-react
14082
+ *
14083
+ * decode.js
14084
+ *
14085
+ * Copyright (c) 2021 ForgeRock. All rights reserved.
14086
+ * This software may be modified and distributed under the terms
14087
+ * of the MIT license. See the LICENSE file for details.
14088
+ */
14089
+ /**
14090
+ * @function htmlDecode - Decodes HTML encoded strings
14091
+ * @param {string} input - string that needs to be HTML decoded
14092
+ * @returns {string} - decoded string
14093
+ */
14094
+ function htmlDecode(input) {
14095
+ // Check if running in server before using the document object
14096
+ if (typeof document !== 'object') {
14097
+ return null;
14098
+ }
14099
+ const e = document.createElement('div');
14100
+ e.innerHTML = input;
14101
+ return e.childNodes.length === 0 ? '' : e.childNodes[0].nodeValue;
14187
14102
  }
14188
14103
 
14189
14104
  var libExports$1 = {};
@@ -16108,17 +16023,18 @@ const stringsSchema = mod
16108
16023
  stringsSchema.partial();
16109
16024
  // Ensure fallback follows schema
16110
16025
  stringsSchema.parse(fallback);
16111
- let strings;
16112
- function initialize$6(userLocale) {
16026
+ const stringsStore = writable(null);
16027
+ function initialize$5(userLocale) {
16113
16028
  if (userLocale) {
16114
16029
  /**
16115
16030
  * Allow widgets to overwrite select portions of the content
16116
16031
  */
16117
- strings = readable({ ...fallback, ...userLocale });
16032
+ stringsStore.set({ ...fallback, ...userLocale });
16118
16033
  }
16119
16034
  else {
16120
- strings = readable(fallback);
16035
+ stringsStore.set(fallback);
16121
16036
  }
16037
+ return stringsSchema;
16122
16038
  }
16123
16039
 
16124
16040
  /**
@@ -16133,7 +16049,7 @@ function interpolate(key, values, externalText) {
16133
16049
  if (!key)
16134
16050
  throw new Error('No key provided to t()');
16135
16051
  // Grab the text from the translations store.
16136
- const contentObj = get_store_value(strings);
16052
+ const contentObj = get_store_value(stringsStore);
16137
16053
  const string = (contentObj && contentObj[key]) || '';
16138
16054
  let messageDirty = '';
16139
16055
  if (values) {
@@ -16238,9 +16154,1024 @@ function textToKey(text) {
16238
16154
  return transformedString.charAt(0).toLowerCase() + transformedString.slice(1);
16239
16155
  }
16240
16156
 
16157
+ const authIdTimeoutErrorCode = '110';
16158
+ const constrainedViolationMessage = 'constraint violation';
16159
+ /**
16160
+ * @function convertStringToKey -
16161
+ * @param {string} string
16162
+ * @returns {string}
16163
+ */
16164
+ function convertStringToKey(string) {
16165
+ if (!string) {
16166
+ return '';
16167
+ }
16168
+ if (string.toLocaleLowerCase().includes('constraint violation')) {
16169
+ console.error('Delta Sierra error has occurred. Please communicate this to your system administrator.');
16170
+ if (string.toLocaleLowerCase().includes('password')) {
16171
+ return 'constraintViolationForPassword';
16172
+ }
16173
+ return 'constraintViolationForValue';
16174
+ }
16175
+ const replaceFunction = (_, char) => `${char.toLowerCase()}`;
16176
+ const normalizedString = string
16177
+ .replace(/^([A-Z])/g, replaceFunction)
16178
+ .replace(/\s([a-z])/g, (_, char) => `${char.toUpperCase()}`);
16179
+ const key = normalizedString.replace(/\W/g, '');
16180
+ return key;
16181
+ }
16182
+ /**
16183
+ * @function initCheckValidation -
16184
+ * @returns {boolean}
16185
+ */
16186
+ function initCheckValidation() {
16187
+ let hasPrevError = false;
16188
+ return function checkValidation(callback) {
16189
+ const failedPolices = callback.getOutputByName('failedPolicies', []);
16190
+ if (failedPolices.length && !hasPrevError) {
16191
+ hasPrevError = true;
16192
+ return true;
16193
+ }
16194
+ return false;
16195
+ };
16196
+ }
16197
+ /**
16198
+ * @function shouldRedirectFromStep -
16199
+ * @returns {boolean}
16200
+ */
16201
+ function shouldRedirectFromStep(step) {
16202
+ return step.getCallbacksOfType(CallbackType$1.RedirectCallback).length > 0;
16203
+ }
16204
+ /**
16205
+ * @function shouldPopulateWithPreviousCallbacks -
16206
+ * @param {object} nextStep
16207
+ * @param {array} previousCallbacks
16208
+ * @param {object} restartedStep
16209
+ * @param {number} stepNumber
16210
+ * @returns {boolean}
16211
+ */
16212
+ function shouldPopulateWithPreviousCallbacks(nextStep, previousCallbacks, restartedStep, stepNumber) {
16213
+ if (!Array.isArray(previousCallbacks)) {
16214
+ return false;
16215
+ }
16216
+ if (restartedStep.type !== StepType$1.Step) {
16217
+ return false;
16218
+ }
16219
+ if (stepNumber !== 1) {
16220
+ return false;
16221
+ }
16222
+ const details = nextStep.payload.detail;
16223
+ const message = nextStep.payload.message?.toLowerCase();
16224
+ /**
16225
+ * Now that we know we have previous callbacks, this is of type "Step",
16226
+ * it has payload detail or payload message, and it's just the first step,
16227
+ * we can populate the new step with old callbacks.
16228
+ */
16229
+ if (details?.errorCode === authIdTimeoutErrorCode ||
16230
+ message?.includes(constrainedViolationMessage)) {
16231
+ return true;
16232
+ }
16233
+ // Fallback to false
16234
+ return false;
16235
+ }
16236
+
16237
+ const selfSubmittingCallbacks = [
16238
+ CallbackType$1.ConfirmationCallback,
16239
+ CallbackType$1.DeviceProfileCallback,
16240
+ CallbackType$1.PollingWaitCallback,
16241
+ CallbackType$1.SelectIdPCallback,
16242
+ ];
16243
+ const userInputCallbacks = [
16244
+ CallbackType$1.BooleanAttributeInputCallback,
16245
+ CallbackType$1.ChoiceCallback,
16246
+ CallbackType$1.ConfirmationCallback,
16247
+ CallbackType$1.KbaCreateCallback,
16248
+ CallbackType$1.NameCallback,
16249
+ CallbackType$1.NumberAttributeInputCallback,
16250
+ CallbackType$1.PasswordCallback,
16251
+ CallbackType$1.ReCaptchaCallback,
16252
+ CallbackType$1.SelectIdPCallback,
16253
+ CallbackType$1.StringAttributeInputCallback,
16254
+ CallbackType$1.TermsAndConditionsCallback,
16255
+ CallbackType$1.ValidatedCreatePasswordCallback,
16256
+ CallbackType$1.ValidatedCreateUsernameCallback,
16257
+ ];
16258
+ // This eventually will be overridable by user of framework
16259
+ const forceUserInputOptionalityCallbacks = {
16260
+ SelectIdPCallback: (callback) => {
16261
+ const selectIdpCb = callback;
16262
+ return !!selectIdpCb
16263
+ .getProviders()
16264
+ .find((provider) => provider.provider === 'localAuthentication');
16265
+ },
16266
+ };
16267
+ function isCbReadyByDefault(callback) {
16268
+ if (callback.getType() === CallbackType$1.ConfirmationCallback) {
16269
+ const cb = callback;
16270
+ if (cb.getOptions().length === 1) {
16271
+ return true;
16272
+ }
16273
+ }
16274
+ return false;
16275
+ }
16276
+ function canForceUserInputOptionality(callback) {
16277
+ // See if a callback function exists within this collection
16278
+ const fn = forceUserInputOptionalityCallbacks[callback.getType()];
16279
+ // If there is a function, run it and it will return a boolean
16280
+ return fn ? fn(callback) : false;
16281
+ }
16282
+ /**
16283
+ * @function isSelfSubmitting -
16284
+ * @param {object} callback - generic FRCallback from JavaScript SDK
16285
+ * @returns
16286
+ */
16287
+ function isSelfSubmitting(callback) {
16288
+ return selfSubmittingCallbacks.includes(callback.getType());
16289
+ }
16290
+ /**
16291
+ * @function isStepSelfSubmittable -
16292
+ * @param {array} callbacks - CallbackMetadata
16293
+ * @returns
16294
+ */
16295
+ function isStepSelfSubmittable(callbacks, userInputOptional) {
16296
+ if (userInputOptional) {
16297
+ return true;
16298
+ }
16299
+ const unsubmittableCallbacks = callbacks.filter((callback) => callback.derived.isUserInputRequired && !callback.derived.isSelfSubmitting);
16300
+ return !unsubmittableCallbacks.length;
16301
+ }
16302
+ /**
16303
+ *
16304
+ * @param {object} callback - Generic callback provided by JavaScript SDK
16305
+ * @returns
16306
+ */
16307
+ function requiresUserInput(callback) {
16308
+ if (callback.getType() === CallbackType$1.SelectIdPCallback) {
16309
+ return false;
16310
+ }
16311
+ if (callback.getType() === CallbackType$1.ConfirmationCallback) {
16312
+ const cb = callback;
16313
+ if (cb.getOptions().length === 1) {
16314
+ return false;
16315
+ }
16316
+ }
16317
+ return userInputCallbacks.includes(callback.getType());
16318
+ }
16319
+ // Notice this function can take a user provided argument function to
16320
+ // override behavior (this doesn't have to be well defined)
16321
+ function isUserInputOptional(callbackMetadataArray, numOfUserInputCbs, fn) {
16322
+ // default reducer function to check if both overriding callback exists
16323
+ // along with user input required callbacks
16324
+ const fallbackFn = (prev, curr) => {
16325
+ if (curr.derived.canForceUserInputOptionality && numOfUserInputCbs > 0) {
16326
+ prev = true;
16327
+ }
16328
+ return prev;
16329
+ };
16330
+ // Call reduce function with either fallback or user provided function
16331
+ return callbackMetadataArray.reduce(fn || fallbackFn, false);
16332
+ }
16333
+
16334
+ /**
16335
+ * @function buildCallbackMetadata - Constructs an array of callback metadata that matches to original callback array
16336
+ * @param {object} step - The modified Widget step object
16337
+ * @param checkValidation - function that checks if current callback is the first invalid callback
16338
+ * @returns {array}
16339
+ */
16340
+ function buildCallbackMetadata(step, checkValidation, stageJson) {
16341
+ const callbackCount = {};
16342
+ return step?.callbacks.map((callback, idx) => {
16343
+ const cb = callback;
16344
+ const callbackType = cb.getType();
16345
+ let stageCbMetadata;
16346
+ if (callbackCount[callbackType]) {
16347
+ callbackCount[callbackType] = callbackCount[callbackType] + 1;
16348
+ }
16349
+ else {
16350
+ callbackCount[callbackType] = 1;
16351
+ }
16352
+ if (stageJson && stageJson[callbackType]) {
16353
+ const stageCbArray = stageJson[callbackType];
16354
+ stageCbMetadata = stageCbArray[callbackCount[callbackType] - 1];
16355
+ }
16356
+ return {
16357
+ derived: {
16358
+ canForceUserInputOptionality: canForceUserInputOptionality(callback),
16359
+ isFirstInvalidInput: checkValidation(callback),
16360
+ isReadyForSubmission: isCbReadyByDefault(callback),
16361
+ isSelfSubmitting: isSelfSubmitting(callback),
16362
+ isUserInputRequired: requiresUserInput(callback),
16363
+ },
16364
+ idx,
16365
+ // Only use the `platform` prop if there's metadata to add
16366
+ ...(stageCbMetadata && {
16367
+ platform: {
16368
+ ...stageCbMetadata,
16369
+ },
16370
+ }),
16371
+ };
16372
+ });
16373
+ }
16374
+ /**
16375
+ * @function buildStepMetadata - Constructs a metadata object that summarizes the step from AM
16376
+ * @param {array} callbackMetadataArray - The array returned from buildCallbackMetadata
16377
+ * @returns {object}
16378
+ */
16379
+ function buildStepMetadata(callbackMetadataArray, stageJson, stageName) {
16380
+ const numOfUserInputCbs = callbackMetadataArray.filter((cb) => !!cb.derived.isUserInputRequired).length;
16381
+ const userInputOptional = isUserInputOptional(callbackMetadataArray, numOfUserInputCbs);
16382
+ let stageMetadata;
16383
+ if (stageJson) {
16384
+ stageMetadata = Object.keys(stageJson).reduce((prev, curr) => {
16385
+ // Filter out objects or arrays as those are for the callbacks
16386
+ if (typeof stageJson[curr] !== 'object') {
16387
+ prev[curr] = stageJson[curr];
16388
+ }
16389
+ return prev;
16390
+ }, {});
16391
+ }
16392
+ return {
16393
+ derived: {
16394
+ isStepSelfSubmittable: isStepSelfSubmittable(callbackMetadataArray, userInputOptional),
16395
+ isUserInputOptional: userInputOptional,
16396
+ numOfCallbacks: callbackMetadataArray.length,
16397
+ numOfSelfSubmittableCbs: callbackMetadataArray.filter((cb) => !!cb.derived.isSelfSubmitting)
16398
+ .length,
16399
+ numOfUserInputCbs: numOfUserInputCbs,
16400
+ },
16401
+ // Only use the `platform` prop if there's metadata to add
16402
+ ...(stageMetadata && {
16403
+ platform: {
16404
+ ...stageMetadata,
16405
+ },
16406
+ }),
16407
+ // stageName and stateMetadata are mutually exclusive
16408
+ ...(stageName && {
16409
+ platform: {
16410
+ stageName,
16411
+ }
16412
+ }),
16413
+ };
16414
+ }
16415
+
16416
+ function initializeStack(initOptions) {
16417
+ const initialValue = initOptions ? [initOptions] : [];
16418
+ const { update, set, subscribe } = writable(initialValue);
16419
+ // Assign to exported variable (see bottom of file)
16420
+ stack = {
16421
+ pop: async () => {
16422
+ return new Promise((resolve) => {
16423
+ update((current) => {
16424
+ let state;
16425
+ if (current.length) {
16426
+ state = current.slice(0, -1);
16427
+ }
16428
+ else {
16429
+ state = current;
16430
+ }
16431
+ resolve([...state]);
16432
+ return state;
16433
+ });
16434
+ });
16435
+ },
16436
+ push: async (options) => {
16437
+ return new Promise((resolve) => {
16438
+ update((current) => {
16439
+ let state;
16440
+ if (!current.length) {
16441
+ state = [{ ...options }];
16442
+ }
16443
+ else if (options && options?.tree !== current[current.length - 1]?.tree) {
16444
+ state = [...current, options];
16445
+ }
16446
+ else {
16447
+ state = current;
16448
+ }
16449
+ resolve([...state]);
16450
+ return state;
16451
+ });
16452
+ });
16453
+ },
16454
+ reset: () => {
16455
+ set([]);
16456
+ },
16457
+ subscribe,
16458
+ };
16459
+ return stack;
16460
+ }
16461
+ const journeyStore = writable({
16462
+ completed: false,
16463
+ error: null,
16464
+ loading: false,
16465
+ metadata: null,
16466
+ step: null,
16467
+ successful: false,
16468
+ response: null,
16469
+ });
16470
+ function initialize$4(initOptions) {
16471
+ const stack = initializeStack();
16472
+ let restartOptions;
16473
+ let stepNumber = 0;
16474
+ async function next(prevStep = null, nextOptions, resumeUrl) {
16475
+ /**
16476
+ * Create an options object with nextOptions overriding anything from initOptions
16477
+ * TODO: Does this object merge need to be more granular?
16478
+ */
16479
+ const options = {
16480
+ ...initOptions,
16481
+ ...nextOptions,
16482
+ };
16483
+ // These options are reserved only for restarting a journey after failure
16484
+ if (initOptions || nextOptions) {
16485
+ restartOptions = {
16486
+ // Prioritize next options over initialize options
16487
+ ...initOptions,
16488
+ ...nextOptions,
16489
+ };
16490
+ }
16491
+ /**
16492
+ * Save previous step information just in case we have a total
16493
+ * form failure due to 400 response from ForgeRock.
16494
+ */
16495
+ let previousCallbacks;
16496
+ if (prevStep && prevStep.type === StepType$1.Step) {
16497
+ previousCallbacks = prevStep?.callbacks;
16498
+ }
16499
+ const previousPayload = prevStep?.payload;
16500
+ let nextStep;
16501
+ journeyStore.set({
16502
+ completed: false,
16503
+ error: null,
16504
+ loading: true,
16505
+ metadata: get_store_value(journeyStore).metadata,
16506
+ step: prevStep,
16507
+ successful: false,
16508
+ response: null,
16509
+ });
16510
+ try {
16511
+ if (resumeUrl) {
16512
+ // If resuming an unknown journey remove the tree from the options
16513
+ options.tree = undefined;
16514
+ /**
16515
+ * Attempt to resume journey
16516
+ */
16517
+ nextStep = await FRAuth$1.resume(resumeUrl, options);
16518
+ }
16519
+ else if (prevStep) {
16520
+ // If continuing on a tree remove it from the options
16521
+ options.tree = undefined;
16522
+ /**
16523
+ * Initial attempt to retrieve next step
16524
+ */
16525
+ nextStep = await FRAuth$1.next(prevStep, options);
16526
+ }
16527
+ else {
16528
+ nextStep = await FRAuth$1.next(undefined, options);
16529
+ }
16530
+ }
16531
+ catch (err) {
16532
+ console.error(`Next step request | ${err}`);
16533
+ /**
16534
+ * Setup an object to display failure message
16535
+ */
16536
+ nextStep = new FRLoginFailure$1({
16537
+ message: interpolate('unknownNetworkError'),
16538
+ });
16539
+ }
16540
+ if (nextStep.type === StepType$1.Step) {
16541
+ const stageAttribute = nextStep.getStage();
16542
+ let stageJson = null;
16543
+ let stageName = null;
16544
+ // Check if stage attribute is serialized JSON
16545
+ if (stageAttribute && stageAttribute.includes('{')) {
16546
+ try {
16547
+ stageJson = JSON.parse(stageAttribute);
16548
+ }
16549
+ catch (err) {
16550
+ console.warn('Stage attribute value was not parsable');
16551
+ }
16552
+ }
16553
+ else if (stageAttribute) {
16554
+ stageName = stageAttribute;
16555
+ }
16556
+ const callbackMetadata = buildCallbackMetadata(nextStep, initCheckValidation(), stageJson);
16557
+ const stepMetadata = buildStepMetadata(callbackMetadata, stageJson, stageName);
16558
+ // Iterate on a successful progression
16559
+ stepNumber = stepNumber + 1;
16560
+ journeyStore.set({
16561
+ completed: false,
16562
+ error: null,
16563
+ loading: false,
16564
+ metadata: {
16565
+ callbacks: callbackMetadata,
16566
+ step: stepMetadata,
16567
+ },
16568
+ step: nextStep,
16569
+ successful: false,
16570
+ response: null,
16571
+ });
16572
+ }
16573
+ else if (nextStep.type === StepType$1.LoginSuccess) {
16574
+ /**
16575
+ * SUCCESSFUL COMPLETION BLOCK
16576
+ */
16577
+ // Set final state
16578
+ journeyStore.set({
16579
+ completed: true,
16580
+ error: null,
16581
+ loading: false,
16582
+ metadata: null,
16583
+ step: null,
16584
+ successful: true,
16585
+ response: nextStep.payload,
16586
+ });
16587
+ }
16588
+ else if (nextStep.type === StepType$1.LoginFailure) {
16589
+ /**
16590
+ * FAILURE COMPLETION BLOCK
16591
+ *
16592
+ * Grab failure message, which may contain encoded HTML
16593
+ */
16594
+ const failureMessageStr = htmlDecode(nextStep.payload.message || '');
16595
+ let restartedStep = null;
16596
+ try {
16597
+ /**
16598
+ * Restart tree to get fresh step
16599
+ */
16600
+ restartedStep = await FRAuth$1.next(undefined, restartOptions);
16601
+ }
16602
+ catch (err) {
16603
+ console.error(`Restart failed step request | ${err}`);
16604
+ /**
16605
+ * Setup an object to display failure message
16606
+ */
16607
+ restartedStep = new FRLoginFailure$1({
16608
+ message: interpolate('unknownNetworkError'),
16609
+ });
16610
+ }
16611
+ /**
16612
+ * Now that we have a new authId (the identification of the
16613
+ * fresh step) let's populate this new step with old callback data if
16614
+ * this is step one and meets a few criteria.
16615
+ *
16616
+ * If error code is 110 or error message includes "Constrained Violation",
16617
+ * then the issue needs special handling.
16618
+ *
16619
+ * If this is the first step in the journey, replace the callbacks with
16620
+ * existing callbacks to resubmit with a fresh authId.
16621
+ ******************************************************************* */
16622
+ if (shouldPopulateWithPreviousCallbacks(nextStep, previousCallbacks, restartedStep, stepNumber)) {
16623
+ /**
16624
+ * TypeScript notes:
16625
+ *
16626
+ * Assert that restartedStep is FRStep as that is required for the above condition to be true.
16627
+ * Also, assert that previousCallbacks is FRCallback[] as that too is required for above to be true.
16628
+ *
16629
+ * Attempt a refactor using Ryan's suggestion found here: https://www.typescriptlang.org/play?#code/PTAEHUFMBsGMHsC2lQBd5oBYoCoE8AHSAZVgCcBLA1UABWgEM8BzM+AVwDsATAGiwoBnUENANQAd0gAjQRVSQAUCEmYKsTKGYUAbpGF4OY0BoadYKdJMoL+gzAzIoz3UNEiPOofEVKVqAHSKymAAmkYI7NCuqGqcANag8ABmIjQUXrFOKBJMggBcISGgoAC0oACCbvCwDKgU8JkY7p7ehCTkVDQS2E6gnPCxGcwmZqDSTgzxxWWVoASMFmgYkAAeRJTInN3ymj4d-jSCeNsMq-wuoPaOltigAKoASgAywhK7SbGQZIIz5VWCFzSeCrZagNYbChbHaxUDcCjJZLfSDbExIAgUdxkUBIursJzCFJtXydajBZJcWD1RqgJyofGcABqDGg7EgAB4cAA+AAUq3y3nBqwUPGEglQlE4IwA-FcJcNQALOOxENJvgBKUAAb0UJT1CNAPNQ7SJoIAvBbQAAiZWq75WzV0hmgUG6vXg6CCFBOsheVZukoB0CKAC+incNCGUtAZtpkHpvuZrI54slzF5VoAjA6ANzkynUrxCYjyqV8gWphUAH36KrVZHVAuB8BaXh17oNRpNqXNloA5JWpX3Ne33XqfZkyGy8+6w0GJziWV683PO8XS8wjXFmOqR0Go8wAhlYKzuPoeVbsNBoPBc6HgiocM0PL7QIh4H0GMD2JG7owpewDDMJA-AnuoiRfvAegiF4VoAKKrAwiALPoVpJNiVrgA4qADqAABykASFaQQqAA8l8ZDvF6-DAUcqCOAorjSHgcbvjoCpfF6aKINCwiXF8kgftEIgGBw2ILEwrAcDwQQlEAA
16630
+ */
16631
+ restartedStep = restartedStep;
16632
+ // Rebuild callbacks onto restartedStep
16633
+ restartedStep.callbacks = previousCallbacks;
16634
+ // Rebuild payload onto restartedStep ensuring the use of the NEW authId
16635
+ restartedStep.payload = {
16636
+ ...previousPayload,
16637
+ authId: restartedStep.payload.authId,
16638
+ };
16639
+ const details = nextStep.payload.detail;
16640
+ /**
16641
+ * Only if the authId expires do we resubmit with same callback values
16642
+ */
16643
+ if (details?.errorCode === authIdTimeoutErrorCode) {
16644
+ restartedStep = await FRAuth$1.next(restartedStep, options);
16645
+ }
16646
+ }
16647
+ /**
16648
+ * SET RESULT OF SUBSEQUENT REQUEST
16649
+ *
16650
+ * After the above attempts to salvage the form submission, let's return
16651
+ * the final result to the user.
16652
+ */
16653
+ if (restartedStep.type === StepType$1.Step) {
16654
+ const stageAttribute = restartedStep.getStage();
16655
+ let stageJson = null;
16656
+ let stageName = null;
16657
+ // Check if stage attribute is serialized JSON
16658
+ if (stageAttribute && stageAttribute.includes('{')) {
16659
+ try {
16660
+ stageJson = JSON.parse(stageAttribute);
16661
+ }
16662
+ catch (err) {
16663
+ console.warn('Stage attribute value was not parsable');
16664
+ }
16665
+ }
16666
+ else if (stageAttribute) {
16667
+ stageName = stageAttribute;
16668
+ }
16669
+ const callbackMetadata = buildCallbackMetadata(restartedStep, initCheckValidation(), stageJson);
16670
+ const stepMetadata = buildStepMetadata(callbackMetadata, stageJson, stageName);
16671
+ journeyStore.set({
16672
+ completed: false,
16673
+ error: {
16674
+ code: nextStep.getCode(),
16675
+ message: failureMessageStr,
16676
+ // TODO: Should we remove the callbacks for PII info?
16677
+ step: prevStep?.payload,
16678
+ },
16679
+ loading: false,
16680
+ metadata: {
16681
+ callbacks: callbackMetadata,
16682
+ step: stepMetadata,
16683
+ },
16684
+ step: restartedStep,
16685
+ successful: false,
16686
+ response: null,
16687
+ });
16688
+ }
16689
+ else if (restartedStep.type === StepType$1.LoginSuccess) {
16690
+ journeyStore.set({
16691
+ completed: true,
16692
+ error: null,
16693
+ loading: false,
16694
+ metadata: null,
16695
+ step: null,
16696
+ successful: true,
16697
+ response: restartedStep.payload,
16698
+ });
16699
+ }
16700
+ else {
16701
+ journeyStore.set({
16702
+ completed: true,
16703
+ error: {
16704
+ code: nextStep.getCode(),
16705
+ message: failureMessageStr,
16706
+ // TODO: Should we remove the callbacks for PII info?
16707
+ step: prevStep?.payload,
16708
+ },
16709
+ loading: false,
16710
+ metadata: null,
16711
+ step: null,
16712
+ successful: false,
16713
+ response: restartedStep.payload,
16714
+ });
16715
+ }
16716
+ }
16717
+ }
16718
+ async function pop() {
16719
+ reset();
16720
+ const updatedStack = await stack.pop();
16721
+ const currentJourney = updatedStack[updatedStack.length - 1];
16722
+ await start(currentJourney);
16723
+ }
16724
+ async function push(newOptions) {
16725
+ reset();
16726
+ await stack.push(newOptions);
16727
+ await start(newOptions);
16728
+ }
16729
+ async function resume(url, resumeOptions) {
16730
+ await next(undefined, resumeOptions, url);
16731
+ }
16732
+ async function start(startOptions) {
16733
+ await stack.push(startOptions);
16734
+ await next(undefined, startOptions);
16735
+ }
16736
+ function reset() {
16737
+ journeyStore.set({
16738
+ completed: false,
16739
+ error: null,
16740
+ loading: false,
16741
+ metadata: null,
16742
+ step: null,
16743
+ successful: false,
16744
+ response: null,
16745
+ });
16746
+ }
16747
+ return {
16748
+ next,
16749
+ pop,
16750
+ push,
16751
+ reset,
16752
+ resume,
16753
+ start,
16754
+ subscribe: journeyStore.subscribe,
16755
+ };
16756
+ }
16757
+ let stack;
16758
+
16759
+ const linksSchema = mod
16760
+ .object({
16761
+ termsAndConditions: mod.string(),
16762
+ })
16763
+ .strict();
16764
+ linksSchema.partial();
16765
+ const linksStore = writable();
16766
+ function initialize$3(customLinks) {
16767
+ // If customLinks is provided, provide feedback for object
16768
+ if (customLinks) {
16769
+ // Provide developer feedback for custom links
16770
+ linksSchema.parse(customLinks);
16771
+ linksStore.set(customLinks);
16772
+ }
16773
+ return linksStore;
16774
+ }
16775
+
16776
+ const oauthStore = writable({
16777
+ completed: false,
16778
+ error: null,
16779
+ loading: false,
16780
+ successful: false,
16781
+ response: null,
16782
+ });
16783
+ function initialize$2(initOptions) {
16784
+ async function get(getOptions) {
16785
+ /**
16786
+ * Create an options object with getOptions overriding anything from initOptions
16787
+ * TODO: Does this object merge need to be more granular?
16788
+ */
16789
+ const options = {
16790
+ ...{ query: { prompt: 'none' } },
16791
+ ...initOptions,
16792
+ ...getOptions,
16793
+ };
16794
+ let tokens;
16795
+ oauthStore.set({
16796
+ completed: false,
16797
+ error: null,
16798
+ loading: true,
16799
+ successful: false,
16800
+ response: null,
16801
+ });
16802
+ try {
16803
+ tokens = await TokenManager$1.getTokens(options);
16804
+ }
16805
+ catch (err) {
16806
+ if (err instanceof Error) {
16807
+ oauthStore.set({
16808
+ completed: true,
16809
+ error: {
16810
+ message: err.message,
16811
+ },
16812
+ loading: false,
16813
+ successful: false,
16814
+ response: null,
16815
+ });
16816
+ }
16817
+ return;
16818
+ }
16819
+ oauthStore.set({
16820
+ completed: true,
16821
+ error: null,
16822
+ loading: false,
16823
+ successful: true,
16824
+ response: tokens,
16825
+ });
16826
+ }
16827
+ function reset() {
16828
+ oauthStore.set({
16829
+ completed: false,
16830
+ error: null,
16831
+ loading: false,
16832
+ successful: false,
16833
+ response: null,
16834
+ });
16835
+ }
16836
+ return {
16837
+ get,
16838
+ reset,
16839
+ subscribe: oauthStore.subscribe,
16840
+ };
16841
+ }
16842
+
16843
+ const userStore = writable({
16844
+ completed: false,
16845
+ error: null,
16846
+ loading: false,
16847
+ successful: false,
16848
+ response: null,
16849
+ });
16850
+ function initialize$1(initOptions) {
16851
+ async function get(getOptions) {
16852
+ /**
16853
+ * Create an options object with getOptions overriding anything from initOptions
16854
+ * TODO: Does this object merge need to be more granular?
16855
+ */
16856
+ const options = {
16857
+ ...initOptions,
16858
+ ...getOptions,
16859
+ };
16860
+ userStore.set({
16861
+ completed: false,
16862
+ error: null,
16863
+ loading: true,
16864
+ successful: false,
16865
+ response: null,
16866
+ });
16867
+ try {
16868
+ const user = await UserManager.getCurrentUser(options);
16869
+ userStore.set({
16870
+ completed: true,
16871
+ error: null,
16872
+ loading: false,
16873
+ successful: true,
16874
+ response: user,
16875
+ });
16876
+ }
16877
+ catch (err) {
16878
+ if (err instanceof Error) {
16879
+ userStore.set({
16880
+ completed: true,
16881
+ error: {
16882
+ message: err.message,
16883
+ },
16884
+ loading: false,
16885
+ successful: false,
16886
+ response: null,
16887
+ });
16888
+ }
16889
+ }
16890
+ }
16891
+ function reset() {
16892
+ userStore.set({
16893
+ completed: false,
16894
+ error: null,
16895
+ loading: false,
16896
+ successful: false,
16897
+ response: null,
16898
+ });
16899
+ }
16900
+ return {
16901
+ get,
16902
+ reset,
16903
+ subscribe: userStore.subscribe,
16904
+ };
16905
+ }
16906
+
16907
+ const logoSchema = mod
16908
+ .object({
16909
+ dark: mod.string().optional(),
16910
+ height: mod.number().optional(),
16911
+ light: mod.string().optional(),
16912
+ width: mod.number().optional(),
16913
+ })
16914
+ .strict();
16915
+ const styleSchema = mod
16916
+ .object({
16917
+ checksAndRadios: mod.union([mod.literal('animated'), mod.literal('standard')]).optional(),
16918
+ labels: mod.union([mod.literal('floating').optional(), mod.literal('stacked')]).optional(),
16919
+ logo: logoSchema.optional(),
16920
+ sections: mod
16921
+ .object({
16922
+ header: mod.boolean().optional(),
16923
+ })
16924
+ .optional(),
16925
+ stage: mod
16926
+ .object({
16927
+ icon: mod.boolean().optional(),
16928
+ })
16929
+ .optional(),
16930
+ })
16931
+ .strict();
16932
+ styleSchema.partial();
16933
+ const styleStore = writable({
16934
+ checksAndRadios: 'animated',
16935
+ labels: 'floating',
16936
+ logo: {},
16937
+ sections: {},
16938
+ stage: {},
16939
+ });
16940
+ function initialize(customStyle) {
16941
+ if (customStyle) {
16942
+ styleSchema.parse(customStyle);
16943
+ styleStore.set(customStyle);
16944
+ }
16945
+ return styleStore;
16946
+ }
16947
+
16948
+ function widgetApiFactory(componentApi) {
16949
+ let journeyStore;
16950
+ let oauthStore;
16951
+ let userStore;
16952
+ function getStores() {
16953
+ return {
16954
+ journeyStore,
16955
+ oauthStore,
16956
+ userStore,
16957
+ };
16958
+ }
16959
+ function resetAndRestartStores() {
16960
+ // Reset stores
16961
+ journeyStore.reset();
16962
+ oauthStore.reset();
16963
+ userStore.reset();
16964
+ // Fetch fresh journey step
16965
+ journey().start();
16966
+ }
16967
+ const configuration = (options) => {
16968
+ if (options?.config) {
16969
+ configure({
16970
+ // Set some basics by default
16971
+ ...{
16972
+ // TODO: Could this be a default OAuth client provided by Platform UI OOTB?
16973
+ clientId: 'WebLoginWidgetClient',
16974
+ // TODO: If a realmPath is not provided, should we call the realm endpoint and detect a likely default?
16975
+ // https://backstage.forgerock.com/docs/am/7/setup-guide/sec-rest-realm-rest.html#rest-api-list-realm
16976
+ realmPath: 'alpha',
16977
+ // TODO: Once we move to SSR, this default should be more intelligent
16978
+ redirectUri: typeof window === 'object' ? window.location.href : 'https://localhost:3000/callback',
16979
+ scope: 'openid email',
16980
+ },
16981
+ // Let user provided config override defaults
16982
+ ...options?.config,
16983
+ // Force 'legacy' to remove confusion
16984
+ ...{ support: 'legacy' },
16985
+ });
16986
+ }
16987
+ /**
16988
+ * Initialize the stores and ensure both variables point to the same reference.
16989
+ * Variables with _ are the reactive version of the original variable from above.
16990
+ */
16991
+ journeyStore = initialize$4(options?.config);
16992
+ oauthStore = initialize$2(options?.config);
16993
+ userStore = initialize$1(options?.config);
16994
+ initialize$5(options?.content);
16995
+ initialize$6(options?.journeys);
16996
+ initialize$3(options?.links);
16997
+ initialize(options?.style);
16998
+ return {
16999
+ set(setOptions) {
17000
+ if (setOptions?.config) {
17001
+ configure({
17002
+ // Set some basics by default
17003
+ ...{
17004
+ // TODO: Could this be a default OAuth client provided by Platform UI OOTB?
17005
+ clientId: 'WebLoginWidgetClient',
17006
+ // TODO: If a realmPath is not provided, should we call the realm endpoint and detect a likely default?
17007
+ // https://backstage.forgerock.com/docs/am/7/setup-guide/sec-rest-realm-rest.html#rest-api-list-realm
17008
+ realmPath: 'alpha',
17009
+ // TODO: Once we move to SSR, this default should be more intelligent
17010
+ redirectUri: typeof window === 'object'
17011
+ ? window.location.href
17012
+ : 'https://localhost:3000/callback',
17013
+ scope: 'openid email',
17014
+ },
17015
+ // Let user provided config override defaults
17016
+ ...setOptions?.config,
17017
+ // Force 'legacy' to remove confusion
17018
+ ...{ support: 'legacy' },
17019
+ });
17020
+ }
17021
+ /**
17022
+ * Initialize the stores and ensure both variables point to the same reference.
17023
+ * Variables with _ are the reactive version of the original variable from above.
17024
+ */
17025
+ journeyStore = initialize$4(setOptions?.config);
17026
+ oauthStore = initialize$2(setOptions?.config);
17027
+ userStore = initialize$1(setOptions?.config);
17028
+ initialize$5(setOptions?.content);
17029
+ initialize$6(setOptions?.journeys);
17030
+ initialize$3(setOptions?.links);
17031
+ initialize(setOptions?.style);
17032
+ },
17033
+ };
17034
+ };
17035
+ const journey = (options) => {
17036
+ const requestsOauth = options?.oauth || true;
17037
+ const requestsUser = options?.user || true;
17038
+ const { subscribe, } = derived([journeyStore, oauthStore, userStore], ([$journeyStore, $oauthStore, $userStore], set) => {
17039
+ set({
17040
+ journey: $journeyStore,
17041
+ oauth: $oauthStore,
17042
+ user: $userStore,
17043
+ });
17044
+ if ($journeyStore) {
17045
+ if ($journeyStore.successful && $oauthStore.successful && $userStore.completed) {
17046
+ formFactor === 'modal' && componentApi.close({ reason: 'auto' });
17047
+ }
17048
+ else if ($journeyStore.successful && $oauthStore.successful) {
17049
+ if (requestsUser && $userStore.loading === false && $userStore.completed === false) {
17050
+ userStore.get();
17051
+ }
17052
+ else if (!requestsUser) {
17053
+ formFactor === 'modal' && componentApi.close({ reason: 'auto' });
17054
+ }
17055
+ }
17056
+ else if ($journeyStore.successful) {
17057
+ if (requestsOauth &&
17058
+ $oauthStore.loading === false &&
17059
+ $oauthStore.completed === false) {
17060
+ oauthStore.get();
17061
+ }
17062
+ else if (!requestsOauth) {
17063
+ formFactor === 'modal' && componentApi.close({ reason: 'auto' });
17064
+ }
17065
+ }
17066
+ }
17067
+ });
17068
+ // Create a simple reference to prevent repeated subscribing and unsubscribing
17069
+ let formFactor = null;
17070
+ function start(startOptions) {
17071
+ // Grab the form factor and cache it
17072
+ formFactor = get_store_value(componentStore).type;
17073
+ if (startOptions?.resumeUrl) {
17074
+ journeyStore.resume(startOptions.resumeUrl);
17075
+ }
17076
+ else {
17077
+ journeyStore.start({
17078
+ ...startOptions?.config,
17079
+ tree: startOptions?.journey,
17080
+ });
17081
+ }
17082
+ return new Promise((resolve) => {
17083
+ const unsubscribe = subscribe((event) => {
17084
+ if (event.journey.successful && event.oauth.successful && event.user.completed) {
17085
+ resolve(event);
17086
+ unsubscribe();
17087
+ }
17088
+ else if (event.journey.successful && event.oauth.successful) {
17089
+ if (!requestsUser) {
17090
+ resolve(event);
17091
+ unsubscribe();
17092
+ }
17093
+ }
17094
+ else if (event.journey.successful) {
17095
+ if (!requestsOauth) {
17096
+ resolve(event);
17097
+ unsubscribe();
17098
+ }
17099
+ }
17100
+ });
17101
+ });
17102
+ }
17103
+ return { start, subscribe };
17104
+ };
17105
+ const user = {
17106
+ info() {
17107
+ const { get, subscribe } = userStore;
17108
+ function wrappedGet(options) {
17109
+ get(options);
17110
+ return new Promise((resolve) => {
17111
+ const unsubscribe = userStore.subscribe((event) => {
17112
+ if (event.completed) {
17113
+ resolve(event);
17114
+ unsubscribe();
17115
+ }
17116
+ });
17117
+ });
17118
+ }
17119
+ return { get: wrappedGet, subscribe };
17120
+ },
17121
+ async logout() {
17122
+ const { clientId } = Config.get();
17123
+ let obj;
17124
+ /**
17125
+ * If configuration has a clientId, then use FRUser to logout to ensure
17126
+ * token revoking and removal; else, just end the session.
17127
+ */
17128
+ if (clientId) {
17129
+ obj = FRUser;
17130
+ }
17131
+ else {
17132
+ obj = SessionManager;
17133
+ }
17134
+ try {
17135
+ await obj.logout();
17136
+ resetAndRestartStores();
17137
+ }
17138
+ catch (err) {
17139
+ // Regardless of errors, reset all stores and restart journey
17140
+ resetAndRestartStores();
17141
+ throw err;
17142
+ }
17143
+ // Return undefined as there's no response information to share
17144
+ return;
17145
+ },
17146
+ tokens() {
17147
+ const { get, subscribe } = oauthStore;
17148
+ function wrappedGet(options) {
17149
+ get(options);
17150
+ return new Promise((resolve) => {
17151
+ const unsubscribe = oauthStore.subscribe((event) => {
17152
+ if (event.completed) {
17153
+ resolve(event);
17154
+ unsubscribe();
17155
+ }
17156
+ });
17157
+ });
17158
+ }
17159
+ return { get: wrappedGet, subscribe };
17160
+ },
17161
+ };
17162
+ return {
17163
+ component: componentApi,
17164
+ configuration,
17165
+ getStores,
17166
+ journey,
17167
+ request: _default$2.request,
17168
+ user,
17169
+ };
17170
+ }
17171
+
16241
17172
  /* src/lib/components/_utilities/locale-strings.svelte generated by Svelte v3.55.1 */
16242
17173
 
16243
- function create_else_block$9(ctx) {
17174
+ function create_else_block$a(ctx) {
16244
17175
  let current;
16245
17176
  const default_slot_template = /*#slots*/ ctx[5].default;
16246
17177
  const default_slot = create_slot(default_slot_template, ctx, /*$$scope*/ ctx[4], null);
@@ -16293,7 +17224,7 @@ function create_else_block$9(ctx) {
16293
17224
  }
16294
17225
 
16295
17226
  // (11:0) {#if html}
16296
- function create_if_block$m(ctx) {
17227
+ function create_if_block$n(ctx) {
16297
17228
  let current;
16298
17229
  const default_slot_template = /*#slots*/ ctx[5].default;
16299
17230
  const default_slot = create_slot(default_slot_template, ctx, /*$$scope*/ ctx[4], null);
@@ -16395,7 +17326,7 @@ function create_fragment$W(ctx) {
16395
17326
  let if_block;
16396
17327
  let if_block_anchor;
16397
17328
  let current;
16398
- const if_block_creators = [create_if_block$m, create_else_block$9];
17329
+ const if_block_creators = [create_if_block$n, create_else_block$a];
16399
17330
  const if_blocks = [];
16400
17331
 
16401
17332
  function select_block_type(ctx, dirty) {
@@ -16590,53 +17521,9 @@ class X_icon extends SvelteComponent {
16590
17521
  }
16591
17522
  }
16592
17523
 
16593
- const logoSchema = mod
16594
- .object({
16595
- dark: mod.string().optional(),
16596
- height: mod.number().optional(),
16597
- light: mod.string().optional(),
16598
- width: mod.number().optional(),
16599
- })
16600
- .strict();
16601
- const styleSchema = mod
16602
- .object({
16603
- checksAndRadios: mod.union([mod.literal('animated'), mod.literal('standard')]).optional(),
16604
- labels: mod.union([mod.literal('floating').optional(), mod.literal('stacked')]).optional(),
16605
- logo: logoSchema.optional(),
16606
- sections: mod
16607
- .object({
16608
- header: mod.boolean().optional(),
16609
- })
16610
- .optional(),
16611
- stage: mod
16612
- .object({
16613
- icon: mod.boolean().optional(),
16614
- })
16615
- .optional(),
16616
- })
16617
- .strict();
16618
- styleSchema.partial();
16619
- let style;
16620
- const fallbackStyle = {
16621
- checksAndRadios: 'animated',
16622
- labels: 'floating',
16623
- logo: {},
16624
- sections: {},
16625
- stage: {},
16626
- };
16627
- function initialize$5(customStyle) {
16628
- if (customStyle) {
16629
- styleSchema.parse(customStyle);
16630
- style = readable(customStyle);
16631
- }
16632
- else {
16633
- style = readable(fallbackStyle);
16634
- }
16635
- }
16636
-
16637
17524
  /* src/lib/components/compositions/dialog/dialog.svelte generated by Svelte v3.55.1 */
16638
17525
 
16639
- function create_else_block$8(ctx) {
17526
+ function create_else_block$9(ctx) {
16640
17527
  let div;
16641
17528
  let button;
16642
17529
  let xicon;
@@ -16654,7 +17541,7 @@ function create_else_block$8(ctx) {
16654
17541
  }
16655
17542
  });
16656
17543
 
16657
- let if_block = /*$style*/ ctx[5]?.logo && create_if_block_1$c(ctx);
17544
+ let if_block = /*$styleStore*/ ctx[5]?.logo && create_if_block_1$c(ctx);
16658
17545
 
16659
17546
  return {
16660
17547
  c() {
@@ -16666,7 +17553,7 @@ function create_else_block$8(ctx) {
16666
17553
  attr(button, "class", "tw_dialog-x md:tw_dialog-x_medium tw_focusable-element dark:tw_focusable-element_dark");
16667
17554
  attr(button, "aria-controls", /*dialogId*/ ctx[1]);
16668
17555
 
16669
- attr(div, "class", div_class_value = `tw_pt-10 md:tw_pt-10 tw_text-right ${(/*$style*/ ctx[5]?.logo)
17556
+ attr(div, "class", div_class_value = `tw_pt-10 md:tw_pt-10 tw_text-right ${(/*$styleStore*/ ctx[5]?.logo)
16670
17557
  ? 'tw_h-32 md:tw_h-36 tw_pb-6'
16671
17558
  : ''}`);
16672
17559
  },
@@ -16679,14 +17566,14 @@ function create_else_block$8(ctx) {
16679
17566
  current = true;
16680
17567
 
16681
17568
  if (!mounted) {
16682
- dispose = listen(button, "click", /*click_handler_1*/ ctx[9]);
17569
+ dispose = listen(button, "click", /*click_handler_1*/ ctx[8]);
16683
17570
  mounted = true;
16684
17571
  }
16685
17572
  },
16686
17573
  p(ctx, dirty) {
16687
17574
  const xicon_changes = {};
16688
17575
 
16689
- if (dirty & /*$$scope*/ 2048) {
17576
+ if (dirty & /*$$scope*/ 1024) {
16690
17577
  xicon_changes.$$scope = { dirty, ctx };
16691
17578
  }
16692
17579
 
@@ -16696,7 +17583,7 @@ function create_else_block$8(ctx) {
16696
17583
  attr(button, "aria-controls", /*dialogId*/ ctx[1]);
16697
17584
  }
16698
17585
 
16699
- if (/*$style*/ ctx[5]?.logo) {
17586
+ if (/*$styleStore*/ ctx[5]?.logo) {
16700
17587
  if (if_block) {
16701
17588
  if_block.p(ctx, dirty);
16702
17589
  } else {
@@ -16709,7 +17596,7 @@ function create_else_block$8(ctx) {
16709
17596
  if_block = null;
16710
17597
  }
16711
17598
 
16712
- if (!current || dirty & /*$style*/ 32 && div_class_value !== (div_class_value = `tw_pt-10 md:tw_pt-10 tw_text-right ${(/*$style*/ ctx[5]?.logo)
17599
+ if (!current || dirty & /*$styleStore*/ 32 && div_class_value !== (div_class_value = `tw_pt-10 md:tw_pt-10 tw_text-right ${(/*$styleStore*/ ctx[5]?.logo)
16713
17600
  ? 'tw_h-32 md:tw_h-36 tw_pb-6'
16714
17601
  : ''}`)) {
16715
17602
  attr(div, "class", div_class_value);
@@ -16734,8 +17621,8 @@ function create_else_block$8(ctx) {
16734
17621
  };
16735
17622
  }
16736
17623
 
16737
- // (39:2) {#if withHeader}
16738
- function create_if_block$l(ctx) {
17624
+ // (45:2) {#if withHeader}
17625
+ function create_if_block$m(ctx) {
16739
17626
  let div1;
16740
17627
  let div0;
16741
17628
  let div0_style_value;
@@ -16763,10 +17650,10 @@ function create_if_block$l(ctx) {
16763
17650
  create_component(xicon.$$.fragment);
16764
17651
  attr(div0, "class", "tw_dialog-logo dark:tw_dialog-logo_dark");
16765
17652
 
16766
- attr(div0, "style", div0_style_value = `--logo-dark: url("${/*$style*/ ctx[5]?.logo?.dark}"); --logo-light: url("${/*$style*/ ctx[5]?.logo?.light}"); ${(/*$style*/ ctx[5]?.logo?.height)
16767
- ? `height: ${/*$style*/ ctx[5]?.logo.height}px;`
16768
- : ''} ${(/*$style*/ ctx[5]?.logo?.width)
16769
- ? `width: ${/*$style*/ ctx[5]?.logo.width}px;`
17653
+ attr(div0, "style", div0_style_value = `--logo-dark: url("${/*$styleStore*/ ctx[5]?.logo?.dark}"); --logo-light: url("${/*$styleStore*/ ctx[5]?.logo?.light}"); ${(/*$styleStore*/ ctx[5]?.logo?.height)
17654
+ ? `height: ${/*$styleStore*/ ctx[5]?.logo.height}px;`
17655
+ : ''} ${(/*$styleStore*/ ctx[5]?.logo?.width)
17656
+ ? `width: ${/*$styleStore*/ ctx[5]?.logo.width}px;`
16770
17657
  : ''}`);
16771
17658
 
16772
17659
  attr(button, "class", "tw_dialog-x md:tw_dialog-x_medium tw_focusable-element dark:tw_focusable-element_dark");
@@ -16782,22 +17669,22 @@ function create_if_block$l(ctx) {
16782
17669
  current = true;
16783
17670
 
16784
17671
  if (!mounted) {
16785
- dispose = listen(button, "click", /*click_handler*/ ctx[8]);
17672
+ dispose = listen(button, "click", /*click_handler*/ ctx[7]);
16786
17673
  mounted = true;
16787
17674
  }
16788
17675
  },
16789
17676
  p(ctx, dirty) {
16790
- if (!current || dirty & /*$style*/ 32 && div0_style_value !== (div0_style_value = `--logo-dark: url("${/*$style*/ ctx[5]?.logo?.dark}"); --logo-light: url("${/*$style*/ ctx[5]?.logo?.light}"); ${(/*$style*/ ctx[5]?.logo?.height)
16791
- ? `height: ${/*$style*/ ctx[5]?.logo.height}px;`
16792
- : ''} ${(/*$style*/ ctx[5]?.logo?.width)
16793
- ? `width: ${/*$style*/ ctx[5]?.logo.width}px;`
17677
+ if (!current || dirty & /*$styleStore*/ 32 && div0_style_value !== (div0_style_value = `--logo-dark: url("${/*$styleStore*/ ctx[5]?.logo?.dark}"); --logo-light: url("${/*$styleStore*/ ctx[5]?.logo?.light}"); ${(/*$styleStore*/ ctx[5]?.logo?.height)
17678
+ ? `height: ${/*$styleStore*/ ctx[5]?.logo.height}px;`
17679
+ : ''} ${(/*$styleStore*/ ctx[5]?.logo?.width)
17680
+ ? `width: ${/*$styleStore*/ ctx[5]?.logo.width}px;`
16794
17681
  : ''}`)) {
16795
17682
  attr(div0, "style", div0_style_value);
16796
17683
  }
16797
17684
 
16798
17685
  const xicon_changes = {};
16799
17686
 
16800
- if (dirty & /*$$scope*/ 2048) {
17687
+ if (dirty & /*$$scope*/ 1024) {
16801
17688
  xicon_changes.$$scope = { dirty, ctx };
16802
17689
  }
16803
17690
 
@@ -16825,7 +17712,7 @@ function create_if_block$l(ctx) {
16825
17712
  };
16826
17713
  }
16827
17714
 
16828
- // (71:8) <XIcon classes="tw_inline-block tw_fill-current tw_text-secondary-dark dark:tw_text-secondary-light" >
17715
+ // (77:8) <XIcon classes="tw_inline-block tw_fill-current tw_text-secondary-dark dark:tw_text-secondary-light" >
16829
17716
  function create_default_slot_1$c(ctx) {
16830
17717
  let t;
16831
17718
  let current;
@@ -16855,7 +17742,7 @@ function create_default_slot_1$c(ctx) {
16855
17742
  };
16856
17743
  }
16857
17744
 
16858
- // (76:6) {#if $style?.logo}
17745
+ // (82:6) {#if $styleStore?.logo}
16859
17746
  function create_if_block_1$c(ctx) {
16860
17747
  let div;
16861
17748
  let div_style_value;
@@ -16864,13 +17751,13 @@ function create_if_block_1$c(ctx) {
16864
17751
  c() {
16865
17752
  div = element("div");
16866
17753
  attr(div, "class", "tw_dialog-logo dark:tw_dialog-logo_dark");
16867
- attr(div, "style", div_style_value = `--logo-dark: url("${/*$style*/ ctx[5]?.logo?.dark}"); --logo-light: url("${/*$style*/ ctx[5]?.logo?.light}")`);
17754
+ attr(div, "style", div_style_value = `--logo-dark: url("${/*$styleStore*/ ctx[5]?.logo?.dark}"); --logo-light: url("${/*$styleStore*/ ctx[5]?.logo?.light}")`);
16868
17755
  },
16869
17756
  m(target, anchor) {
16870
17757
  insert(target, div, anchor);
16871
17758
  },
16872
17759
  p(ctx, dirty) {
16873
- if (dirty & /*$style*/ 32 && div_style_value !== (div_style_value = `--logo-dark: url("${/*$style*/ ctx[5]?.logo?.dark}"); --logo-light: url("${/*$style*/ ctx[5]?.logo?.light}")`)) {
17760
+ if (dirty & /*$styleStore*/ 32 && div_style_value !== (div_style_value = `--logo-dark: url("${/*$styleStore*/ ctx[5]?.logo?.dark}"); --logo-light: url("${/*$styleStore*/ ctx[5]?.logo?.light}")`)) {
16874
17761
  attr(div, "style", div_style_value);
16875
17762
  }
16876
17763
  },
@@ -16880,7 +17767,7 @@ function create_if_block_1$c(ctx) {
16880
17767
  };
16881
17768
  }
16882
17769
 
16883
- // (54:8) <XIcon classes="tw_inline-block tw_fill-current tw_text-secondary-dark dark:tw_text-secondary-light" >
17770
+ // (60:8) <XIcon classes="tw_inline-block tw_fill-current tw_text-secondary-dark dark:tw_text-secondary-light" >
16884
17771
  function create_default_slot$o(ctx) {
16885
17772
  let t;
16886
17773
  let current;
@@ -16918,7 +17805,7 @@ function create_fragment$U(ctx) {
16918
17805
  let div;
16919
17806
  let dialog_class_value;
16920
17807
  let current;
16921
- const if_block_creators = [create_if_block$l, create_else_block$8];
17808
+ const if_block_creators = [create_if_block$m, create_else_block$9];
16922
17809
  const if_blocks = [];
16923
17810
 
16924
17811
  function select_block_type(ctx, dirty) {
@@ -16928,8 +17815,8 @@ function create_fragment$U(ctx) {
16928
17815
 
16929
17816
  current_block_type_index = select_block_type(ctx);
16930
17817
  if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx);
16931
- const default_slot_template = /*#slots*/ ctx[7].default;
16932
- const default_slot = create_slot(default_slot_template, ctx, /*$$scope*/ ctx[11], null);
17818
+ const default_slot_template = /*#slots*/ ctx[6].default;
17819
+ const default_slot = create_slot(default_slot_template, ctx, /*$$scope*/ ctx[10], null);
16933
17820
 
16934
17821
  return {
16935
17822
  c() {
@@ -16953,7 +17840,7 @@ function create_fragment$U(ctx) {
16953
17840
  default_slot.m(div, null);
16954
17841
  }
16955
17842
 
16956
- /*dialog_binding*/ ctx[10](dialog);
17843
+ /*dialog_binding*/ ctx[9](dialog);
16957
17844
  current = true;
16958
17845
  },
16959
17846
  p(ctx, [dirty]) {
@@ -16984,15 +17871,15 @@ function create_fragment$U(ctx) {
16984
17871
  }
16985
17872
 
16986
17873
  if (default_slot) {
16987
- if (default_slot.p && (!current || dirty & /*$$scope*/ 2048)) {
17874
+ if (default_slot.p && (!current || dirty & /*$$scope*/ 1024)) {
16988
17875
  update_slot_base(
16989
17876
  default_slot,
16990
17877
  default_slot_template,
16991
17878
  ctx,
16992
- /*$$scope*/ ctx[11],
17879
+ /*$$scope*/ ctx[10],
16993
17880
  !current
16994
- ? get_all_dirty_from_scope(/*$$scope*/ ctx[11])
16995
- : get_slot_changes(default_slot_template, /*$$scope*/ ctx[11], dirty, null),
17881
+ ? get_all_dirty_from_scope(/*$$scope*/ ctx[10])
17882
+ : get_slot_changes(default_slot_template, /*$$scope*/ ctx[10], dirty, null),
16996
17883
  null
16997
17884
  );
16998
17885
  }
@@ -17025,30 +17912,34 @@ function create_fragment$U(ctx) {
17025
17912
  if (detaching) detach(dialog);
17026
17913
  if_blocks[current_block_type_index].d();
17027
17914
  if (default_slot) default_slot.d(detaching);
17028
- /*dialog_binding*/ ctx[10](null);
17915
+ /*dialog_binding*/ ctx[9](null);
17029
17916
  }
17030
17917
  };
17031
17918
  }
17032
17919
 
17033
17920
  function instance$V($$self, $$props, $$invalidate) {
17034
- let $style;
17035
- component_subscribe($$self, style, $$value => $$invalidate(5, $style = $$value));
17921
+ let $styleStore;
17922
+ component_subscribe($$self, styleStore, $$value => $$invalidate(5, $styleStore = $$value));
17036
17923
  let { $$slots: slots = {}, $$scope } = $$props;
17037
- let { closeCallback } = $$props;
17038
17924
  let { dialogEl = null } = $$props;
17039
17925
  let { dialogId } = $$props;
17040
17926
  let { forceOpen = false } = $$props;
17041
17927
  let { withHeader = false } = $$props;
17042
17928
 
17043
- function closeDialog(args) {
17044
- const { reason } = args || { reason: 'external' };
17045
-
17929
+ function closeDialog(reason) {
17046
17930
  function completeClose() {
17047
17931
  dialogEl?.close();
17048
17932
  dialogEl?.classList.remove('tw_dialog-closing');
17049
17933
 
17050
- // Call dev provided callback function for event hook
17051
- closeCallback && closeCallback({ reason });
17934
+ // Ensure we have a store and it has an update method on it
17935
+ componentStore?.update(state => {
17936
+ if (state.open === false) {
17937
+ // If state is already correct, just return the same reference
17938
+ return state;
17939
+ }
17940
+
17941
+ return { ...state, open: false, reason };
17942
+ });
17052
17943
  }
17053
17944
 
17054
17945
  // Create timer in case the CSS is not loaded
@@ -17070,8 +17961,8 @@ function instance$V($$self, $$props, $$invalidate) {
17070
17961
  dialogEl?.classList.add('tw_dialog-closing');
17071
17962
  }
17072
17963
 
17073
- const click_handler = () => closeDialog({ reason: 'user' });
17074
- const click_handler_1 = () => closeDialog({ reason: 'user' });
17964
+ const click_handler = () => closeDialog('user');
17965
+ const click_handler_1 = () => closeDialog('user');
17075
17966
 
17076
17967
  function dialog_binding($$value) {
17077
17968
  binding_callbacks[$$value ? 'unshift' : 'push'](() => {
@@ -17081,12 +17972,11 @@ function instance$V($$self, $$props, $$invalidate) {
17081
17972
  }
17082
17973
 
17083
17974
  $$self.$$set = $$props => {
17084
- if ('closeCallback' in $$props) $$invalidate(6, closeCallback = $$props.closeCallback);
17085
17975
  if ('dialogEl' in $$props) $$invalidate(0, dialogEl = $$props.dialogEl);
17086
17976
  if ('dialogId' in $$props) $$invalidate(1, dialogId = $$props.dialogId);
17087
17977
  if ('forceOpen' in $$props) $$invalidate(2, forceOpen = $$props.forceOpen);
17088
17978
  if ('withHeader' in $$props) $$invalidate(3, withHeader = $$props.withHeader);
17089
- if ('$$scope' in $$props) $$invalidate(11, $$scope = $$props.$$scope);
17979
+ if ('$$scope' in $$props) $$invalidate(10, $$scope = $$props.$$scope);
17090
17980
  };
17091
17981
 
17092
17982
  return [
@@ -17095,8 +17985,7 @@ function instance$V($$self, $$props, $$invalidate) {
17095
17985
  forceOpen,
17096
17986
  withHeader,
17097
17987
  closeDialog,
17098
- $style,
17099
- closeCallback,
17988
+ $styleStore,
17100
17989
  slots,
17101
17990
  click_handler,
17102
17991
  click_handler_1,
@@ -17110,7 +17999,6 @@ class Dialog extends SvelteComponent {
17110
17999
  super();
17111
18000
 
17112
18001
  init(this, options, instance$V, create_fragment$U, safe_not_equal, {
17113
- closeCallback: 6,
17114
18002
  dialogEl: 0,
17115
18003
  dialogId: 1,
17116
18004
  forceOpen: 2,
@@ -17423,7 +18311,7 @@ class Warning_icon extends SvelteComponent {
17423
18311
 
17424
18312
  /* src/lib/components/primitives/alert/alert.svelte generated by Svelte v3.55.1 */
17425
18313
 
17426
- function create_else_block$7(ctx) {
18314
+ function create_else_block$8(ctx) {
17427
18315
  let infoicon;
17428
18316
  let current;
17429
18317
  infoicon = new Info_icon({});
@@ -17481,7 +18369,7 @@ function create_if_block_1$b(ctx) {
17481
18369
  }
17482
18370
 
17483
18371
  // (41:4) {#if type === 'error'}
17484
- function create_if_block$k(ctx) {
18372
+ function create_if_block$l(ctx) {
17485
18373
  let alerticon;
17486
18374
  let current;
17487
18375
  alerticon = new Alert_icon({});
@@ -17518,7 +18406,7 @@ function create_fragment$Q(ctx) {
17518
18406
  let span;
17519
18407
  let div_class_value;
17520
18408
  let current;
17521
- const if_block_creators = [create_if_block$k, create_if_block_1$b, create_else_block$7];
18409
+ const if_block_creators = [create_if_block$l, create_if_block_1$b, create_else_block$8];
17522
18410
  const if_blocks = [];
17523
18411
 
17524
18412
  function select_block_type(ctx, dirty) {
@@ -17753,7 +18641,7 @@ class Spinner extends SvelteComponent {
17753
18641
 
17754
18642
  /* src/lib/components/primitives/button/button.svelte generated by Svelte v3.55.1 */
17755
18643
 
17756
- function create_if_block$j(ctx) {
18644
+ function create_if_block$k(ctx) {
17757
18645
  let spinner;
17758
18646
  let current;
17759
18647
 
@@ -17811,7 +18699,7 @@ function create_fragment$O(ctx) {
17811
18699
  let current;
17812
18700
  let mounted;
17813
18701
  let dispose;
17814
- let if_block = /*busy*/ ctx[0] && create_if_block$j();
18702
+ let if_block = /*busy*/ ctx[0] && create_if_block$k();
17815
18703
  const default_slot_template = /*#slots*/ ctx[7].default;
17816
18704
  const default_slot = create_slot(default_slot_template, ctx, /*$$scope*/ ctx[6], null);
17817
18705
  const default_slot_or_fallback = default_slot || fallback_block$1();
@@ -17853,7 +18741,7 @@ function create_fragment$O(ctx) {
17853
18741
  transition_in(if_block, 1);
17854
18742
  }
17855
18743
  } else {
17856
- if_block = create_if_block$j();
18744
+ if_block = create_if_block$k();
17857
18745
  if_block.c();
17858
18746
  transition_in(if_block, 1);
17859
18747
  if_block.m(button, t);
@@ -17923,684 +18811,57 @@ function generateClassString$2(...args) {
17923
18811
  case 'outline':
17924
18812
  return `${prev} tw_button-outline dark:tw_button-outline_dark`;
17925
18813
  case 'auto':
17926
- return `${prev} tw_w-auto`;
17927
- case 'full':
17928
- return `${prev} tw_w-full`;
17929
- default:
17930
- return prev;
17931
- }
17932
- },
17933
- ''
17934
- );
17935
- }
17936
-
17937
- function instance$P($$self, $$props, $$invalidate) {
17938
- let { $$slots: slots = {}, $$scope } = $$props;
17939
- let { busy = false } = $$props;
17940
- let { classes = '' } = $$props;
17941
-
17942
- let { onClick = e => {
17943
-
17944
- } } = $$props;
17945
-
17946
- let { style = 'outline' } = $$props;
17947
- let { type = null } = $$props;
17948
- let { width = 'auto' } = $$props;
17949
-
17950
- $$self.$$set = $$props => {
17951
- if ('busy' in $$props) $$invalidate(0, busy = $$props.busy);
17952
- if ('classes' in $$props) $$invalidate(1, classes = $$props.classes);
17953
- if ('onClick' in $$props) $$invalidate(2, onClick = $$props.onClick);
17954
- if ('style' in $$props) $$invalidate(3, style = $$props.style);
17955
- if ('type' in $$props) $$invalidate(4, type = $$props.type);
17956
- if ('width' in $$props) $$invalidate(5, width = $$props.width);
17957
- if ('$$scope' in $$props) $$invalidate(6, $$scope = $$props.$$scope);
17958
- };
17959
-
17960
- return [busy, classes, onClick, style, type, width, $$scope, slots];
17961
- }
17962
-
17963
- class Button extends SvelteComponent {
17964
- constructor(options) {
17965
- super();
17966
-
17967
- init(this, options, instance$P, create_fragment$O, safe_not_equal, {
17968
- busy: 0,
17969
- classes: 1,
17970
- onClick: 2,
17971
- style: 3,
17972
- type: 4,
17973
- width: 5
17974
- });
17975
- }
17976
- }
17977
-
17978
- /*
17979
- * forgerock-sample-web-react
17980
- *
17981
- * decode.js
17982
- *
17983
- * Copyright (c) 2021 ForgeRock. All rights reserved.
17984
- * This software may be modified and distributed under the terms
17985
- * of the MIT license. See the LICENSE file for details.
17986
- */
17987
- /**
17988
- * @function htmlDecode - Decodes HTML encoded strings
17989
- * @param {string} input - string that needs to be HTML decoded
17990
- * @returns {string} - decoded string
17991
- */
17992
- function htmlDecode(input) {
17993
- // Check if running in server before using the document object
17994
- if (typeof document !== 'object') {
17995
- return null;
17996
- }
17997
- const e = document.createElement('div');
17998
- e.innerHTML = input;
17999
- return e.childNodes.length === 0 ? '' : e.childNodes[0].nodeValue;
18000
- }
18001
-
18002
- const authIdTimeoutErrorCode = '110';
18003
- const constrainedViolationMessage = 'constraint violation';
18004
- /**
18005
- * @function convertStringToKey -
18006
- * @param {string} string
18007
- * @returns {string}
18008
- */
18009
- function convertStringToKey(string) {
18010
- if (!string) {
18011
- return '';
18012
- }
18013
- if (string.toLocaleLowerCase().includes('constraint violation')) {
18014
- console.error('Delta Sierra error has occurred. Please communicate this to your system administrator.');
18015
- if (string.toLocaleLowerCase().includes('password')) {
18016
- return 'constraintViolationForPassword';
18017
- }
18018
- return 'constraintViolationForValue';
18019
- }
18020
- const replaceFunction = (_, char) => `${char.toLowerCase()}`;
18021
- const normalizedString = string
18022
- .replace(/^([A-Z])/g, replaceFunction)
18023
- .replace(/\s([a-z])/g, (_, char) => `${char.toUpperCase()}`);
18024
- const key = normalizedString.replace(/\W/g, '');
18025
- return key;
18026
- }
18027
- /**
18028
- * @function initCheckValidation -
18029
- * @returns {boolean}
18030
- */
18031
- function initCheckValidation() {
18032
- let hasPrevError = false;
18033
- return function checkValidation(callback) {
18034
- const failedPolices = callback.getOutputByName('failedPolicies', []);
18035
- if (failedPolices.length && !hasPrevError) {
18036
- hasPrevError = true;
18037
- return true;
18038
- }
18039
- return false;
18040
- };
18041
- }
18042
- /**
18043
- * @function shouldRedirectFromStep -
18044
- * @returns {boolean}
18045
- */
18046
- function shouldRedirectFromStep(step) {
18047
- return step.getCallbacksOfType(CallbackType$1.RedirectCallback).length > 0;
18048
- }
18049
- /**
18050
- * @function shouldPopulateWithPreviousCallbacks -
18051
- * @param {object} nextStep
18052
- * @param {array} previousCallbacks
18053
- * @param {object} restartedStep
18054
- * @param {number} stepNumber
18055
- * @returns {boolean}
18056
- */
18057
- function shouldPopulateWithPreviousCallbacks(nextStep, previousCallbacks, restartedStep, stepNumber) {
18058
- if (!Array.isArray(previousCallbacks)) {
18059
- return false;
18060
- }
18061
- if (restartedStep.type !== StepType$1.Step) {
18062
- return false;
18063
- }
18064
- if (stepNumber !== 1) {
18065
- return false;
18066
- }
18067
- const details = nextStep.payload.detail;
18068
- const message = nextStep.payload.message?.toLowerCase();
18069
- /**
18070
- * Now that we know we have previous callbacks, this is of type "Step",
18071
- * it has payload detail or payload message, and it's just the first step,
18072
- * we can populate the new step with old callbacks.
18073
- */
18074
- if (details?.errorCode === authIdTimeoutErrorCode ||
18075
- message?.includes(constrainedViolationMessage)) {
18076
- return true;
18077
- }
18078
- // Fallback to false
18079
- return false;
18080
- }
18081
-
18082
- const selfSubmittingCallbacks = [
18083
- CallbackType$1.ConfirmationCallback,
18084
- CallbackType$1.DeviceProfileCallback,
18085
- CallbackType$1.PollingWaitCallback,
18086
- CallbackType$1.SelectIdPCallback,
18087
- ];
18088
- const userInputCallbacks = [
18089
- CallbackType$1.BooleanAttributeInputCallback,
18090
- CallbackType$1.ChoiceCallback,
18091
- CallbackType$1.ConfirmationCallback,
18092
- CallbackType$1.KbaCreateCallback,
18093
- CallbackType$1.NameCallback,
18094
- CallbackType$1.NumberAttributeInputCallback,
18095
- CallbackType$1.PasswordCallback,
18096
- CallbackType$1.ReCaptchaCallback,
18097
- CallbackType$1.SelectIdPCallback,
18098
- CallbackType$1.StringAttributeInputCallback,
18099
- CallbackType$1.TermsAndConditionsCallback,
18100
- CallbackType$1.ValidatedCreatePasswordCallback,
18101
- CallbackType$1.ValidatedCreateUsernameCallback,
18102
- ];
18103
- // This eventually will be overridable by user of framework
18104
- const forceUserInputOptionalityCallbacks = {
18105
- SelectIdPCallback: (callback) => {
18106
- const selectIdpCb = callback;
18107
- return !!selectIdpCb
18108
- .getProviders()
18109
- .find((provider) => provider.provider === 'localAuthentication');
18110
- },
18111
- };
18112
- function isCbReadyByDefault(callback) {
18113
- if (callback.getType() === CallbackType$1.ConfirmationCallback) {
18114
- const cb = callback;
18115
- if (cb.getOptions().length === 1) {
18116
- return true;
18117
- }
18118
- }
18119
- return false;
18120
- }
18121
- function canForceUserInputOptionality(callback) {
18122
- // See if a callback function exists within this collection
18123
- const fn = forceUserInputOptionalityCallbacks[callback.getType()];
18124
- // If there is a function, run it and it will return a boolean
18125
- return fn ? fn(callback) : false;
18126
- }
18127
- /**
18128
- * @function isSelfSubmitting -
18129
- * @param {object} callback - generic FRCallback from JavaScript SDK
18130
- * @returns
18131
- */
18132
- function isSelfSubmitting(callback) {
18133
- return selfSubmittingCallbacks.includes(callback.getType());
18134
- }
18135
- /**
18136
- * @function isStepSelfSubmittable -
18137
- * @param {array} callbacks - CallbackMetadata
18138
- * @returns
18139
- */
18140
- function isStepSelfSubmittable(callbacks, userInputOptional) {
18141
- if (userInputOptional) {
18142
- return true;
18143
- }
18144
- const unsubmittableCallbacks = callbacks.filter((callback) => callback.derived.isUserInputRequired && !callback.derived.isSelfSubmitting);
18145
- return !unsubmittableCallbacks.length;
18146
- }
18147
- /**
18148
- *
18149
- * @param {object} callback - Generic callback provided by JavaScript SDK
18150
- * @returns
18151
- */
18152
- function requiresUserInput(callback) {
18153
- if (callback.getType() === CallbackType$1.SelectIdPCallback) {
18154
- return false;
18155
- }
18156
- if (callback.getType() === CallbackType$1.ConfirmationCallback) {
18157
- const cb = callback;
18158
- if (cb.getOptions().length === 1) {
18159
- return false;
18160
- }
18161
- }
18162
- return userInputCallbacks.includes(callback.getType());
18163
- }
18164
- // Notice this function can take a user provided argument function to
18165
- // override behavior (this doesn't have to be well defined)
18166
- function isUserInputOptional(callbackMetadataArray, numOfUserInputCbs, fn) {
18167
- // default reducer function to check if both overriding callback exists
18168
- // along with user input required callbacks
18169
- const fallbackFn = (prev, curr) => {
18170
- if (curr.derived.canForceUserInputOptionality && numOfUserInputCbs > 0) {
18171
- prev = true;
18172
- }
18173
- return prev;
18174
- };
18175
- // Call reduce function with either fallback or user provided function
18176
- return callbackMetadataArray.reduce(fn || fallbackFn, false);
18177
- }
18178
-
18179
- /**
18180
- * @function buildCallbackMetadata - Constructs an array of callback metadata that matches to original callback array
18181
- * @param {object} step - The modified Widget step object
18182
- * @param checkValidation - function that checks if current callback is the first invalid callback
18183
- * @returns {array}
18184
- */
18185
- function buildCallbackMetadata(step, checkValidation, stageJson) {
18186
- const callbackCount = {};
18187
- return step?.callbacks.map((callback, idx) => {
18188
- const cb = callback;
18189
- const callbackType = cb.getType();
18190
- let stageCbMetadata;
18191
- if (callbackCount[callbackType]) {
18192
- callbackCount[callbackType] = callbackCount[callbackType] + 1;
18193
- }
18194
- else {
18195
- callbackCount[callbackType] = 1;
18196
- }
18197
- if (stageJson && stageJson[callbackType]) {
18198
- const stageCbArray = stageJson[callbackType];
18199
- stageCbMetadata = stageCbArray[callbackCount[callbackType] - 1];
18200
- }
18201
- return {
18202
- derived: {
18203
- canForceUserInputOptionality: canForceUserInputOptionality(callback),
18204
- isFirstInvalidInput: checkValidation(callback),
18205
- isReadyForSubmission: isCbReadyByDefault(callback),
18206
- isSelfSubmitting: isSelfSubmitting(callback),
18207
- isUserInputRequired: requiresUserInput(callback),
18208
- },
18209
- idx,
18210
- // Only use the `platform` prop if there's metadata to add
18211
- ...(stageCbMetadata && {
18212
- platform: {
18213
- ...stageCbMetadata,
18214
- },
18215
- }),
18216
- };
18217
- });
18218
- }
18219
- /**
18220
- * @function buildStepMetadata - Constructs a metadata object that summarizes the step from AM
18221
- * @param {array} callbackMetadataArray - The array returned from buildCallbackMetadata
18222
- * @returns {object}
18223
- */
18224
- function buildStepMetadata(callbackMetadataArray, stageJson, stageName) {
18225
- const numOfUserInputCbs = callbackMetadataArray.filter((cb) => !!cb.derived.isUserInputRequired).length;
18226
- const userInputOptional = isUserInputOptional(callbackMetadataArray, numOfUserInputCbs);
18227
- let stageMetadata;
18228
- if (stageJson) {
18229
- stageMetadata = Object.keys(stageJson).reduce((prev, curr) => {
18230
- // Filter out objects or arrays as those are for the callbacks
18231
- if (typeof stageJson[curr] !== 'object') {
18232
- prev[curr] = stageJson[curr];
18233
- }
18234
- return prev;
18235
- }, {});
18236
- }
18237
- return {
18238
- derived: {
18239
- isStepSelfSubmittable: isStepSelfSubmittable(callbackMetadataArray, userInputOptional),
18240
- isUserInputOptional: userInputOptional,
18241
- numOfCallbacks: callbackMetadataArray.length,
18242
- numOfSelfSubmittableCbs: callbackMetadataArray.filter((cb) => !!cb.derived.isSelfSubmitting)
18243
- .length,
18244
- numOfUserInputCbs: numOfUserInputCbs,
18245
- },
18246
- // Only use the `platform` prop if there's metadata to add
18247
- ...(stageMetadata && {
18248
- platform: {
18249
- ...stageMetadata,
18250
- },
18251
- }),
18252
- // stageName and stateMetadata are mutually exclusive
18253
- ...(stageName && {
18254
- platform: {
18255
- stageName,
18256
- }
18257
- }),
18258
- };
18814
+ return `${prev} tw_w-auto`;
18815
+ case 'full':
18816
+ return `${prev} tw_w-full`;
18817
+ default:
18818
+ return prev;
18819
+ }
18820
+ },
18821
+ ''
18822
+ );
18259
18823
  }
18260
18824
 
18261
- function initializeStack(initOptions) {
18262
- const initialValue = initOptions ? [initOptions] : [];
18263
- const { update, set, subscribe } = writable(initialValue);
18264
- // Assign to exported variable (see bottom of file)
18265
- stack = {
18266
- pop: async () => {
18267
- return new Promise((resolve) => {
18268
- update((current) => {
18269
- let state;
18270
- if (current.length) {
18271
- state = current.slice(0, -1);
18272
- }
18273
- else {
18274
- state = current;
18275
- }
18276
- resolve([...state]);
18277
- return state;
18278
- });
18279
- });
18280
- },
18281
- push: async (options) => {
18282
- return new Promise((resolve) => {
18283
- update((current) => {
18284
- let state;
18285
- if (!current.length) {
18286
- state = [{ ...options }];
18287
- }
18288
- else if (options && options?.tree !== current[current.length - 1]?.tree) {
18289
- state = [...current, options];
18290
- }
18291
- else {
18292
- state = current;
18293
- }
18294
- resolve([...state]);
18295
- return state;
18296
- });
18297
- });
18298
- },
18299
- reset: () => {
18300
- set([]);
18301
- },
18302
- subscribe,
18303
- };
18304
- return stack;
18825
+ function instance$P($$self, $$props, $$invalidate) {
18826
+ let { $$slots: slots = {}, $$scope } = $$props;
18827
+ let { busy = false } = $$props;
18828
+ let { classes = '' } = $$props;
18829
+
18830
+ let { onClick = e => {
18831
+
18832
+ } } = $$props;
18833
+
18834
+ let { style = 'outline' } = $$props;
18835
+ let { type = null } = $$props;
18836
+ let { width = 'auto' } = $$props;
18837
+
18838
+ $$self.$$set = $$props => {
18839
+ if ('busy' in $$props) $$invalidate(0, busy = $$props.busy);
18840
+ if ('classes' in $$props) $$invalidate(1, classes = $$props.classes);
18841
+ if ('onClick' in $$props) $$invalidate(2, onClick = $$props.onClick);
18842
+ if ('style' in $$props) $$invalidate(3, style = $$props.style);
18843
+ if ('type' in $$props) $$invalidate(4, type = $$props.type);
18844
+ if ('width' in $$props) $$invalidate(5, width = $$props.width);
18845
+ if ('$$scope' in $$props) $$invalidate(6, $$scope = $$props.$$scope);
18846
+ };
18847
+
18848
+ return [busy, classes, onClick, style, type, width, $$scope, slots];
18305
18849
  }
18306
- function initialize$4(initOptions) {
18307
- const journeyStore = writable({
18308
- completed: false,
18309
- error: null,
18310
- loading: false,
18311
- metadata: null,
18312
- step: null,
18313
- successful: false,
18314
- response: null,
18315
- });
18316
- const { set, subscribe } = journeyStore;
18317
- const stack = initializeStack();
18318
- let restartOptions;
18319
- let stepNumber = 0;
18320
- async function next(prevStep = null, nextOptions, resumeUrl) {
18321
- /**
18322
- * Create an options object with nextOptions overriding anything from initOptions
18323
- * TODO: Does this object merge need to be more granular?
18324
- */
18325
- const options = {
18326
- ...initOptions,
18327
- ...nextOptions,
18328
- };
18329
- // These options are reserved only for restarting a journey after failure
18330
- if (initOptions || nextOptions) {
18331
- restartOptions = {
18332
- // Prioritize next options over initialize options
18333
- ...initOptions,
18334
- ...nextOptions,
18335
- };
18336
- }
18337
- /**
18338
- * Save previous step information just in case we have a total
18339
- * form failure due to 400 response from ForgeRock.
18340
- */
18341
- let previousCallbacks;
18342
- if (prevStep && prevStep.type === StepType$1.Step) {
18343
- previousCallbacks = prevStep?.callbacks;
18344
- }
18345
- const previousPayload = prevStep?.payload;
18346
- let nextStep;
18347
- set({
18348
- completed: false,
18349
- error: null,
18350
- loading: true,
18351
- metadata: get_store_value(journeyStore).metadata,
18352
- step: prevStep,
18353
- successful: false,
18354
- response: null,
18355
- });
18356
- try {
18357
- if (resumeUrl) {
18358
- // If resuming an unknown journey remove the tree from the options
18359
- options.tree = undefined;
18360
- /**
18361
- * Attempt to resume journey
18362
- */
18363
- nextStep = await FRAuth$1.resume(resumeUrl, options);
18364
- }
18365
- else if (prevStep) {
18366
- // If continuing on a tree remove it from the options
18367
- options.tree = undefined;
18368
- /**
18369
- * Initial attempt to retrieve next step
18370
- */
18371
- nextStep = await FRAuth$1.next(prevStep, options);
18372
- }
18373
- else {
18374
- nextStep = await FRAuth$1.next(undefined, options);
18375
- }
18376
- }
18377
- catch (err) {
18378
- console.error(`Next step request | ${err}`);
18379
- /**
18380
- * Setup an object to display failure message
18381
- */
18382
- nextStep = new FRLoginFailure$1({
18383
- message: interpolate('unknownNetworkError'),
18384
- });
18385
- }
18386
- if (nextStep.type === StepType$1.Step) {
18387
- const stageAttribute = nextStep.getStage();
18388
- let stageJson = null;
18389
- let stageName = null;
18390
- // Check if stage attribute is serialized JSON
18391
- if (stageAttribute && stageAttribute.includes('{')) {
18392
- try {
18393
- stageJson = JSON.parse(stageAttribute);
18394
- }
18395
- catch (err) {
18396
- console.warn('Stage attribute value was not parsable');
18397
- }
18398
- }
18399
- else if (stageAttribute) {
18400
- stageName = stageAttribute;
18401
- }
18402
- const callbackMetadata = buildCallbackMetadata(nextStep, initCheckValidation(), stageJson);
18403
- const stepMetadata = buildStepMetadata(callbackMetadata, stageJson, stageName);
18404
- // Iterate on a successful progression
18405
- stepNumber = stepNumber + 1;
18406
- set({
18407
- completed: false,
18408
- error: null,
18409
- loading: false,
18410
- metadata: {
18411
- callbacks: callbackMetadata,
18412
- step: stepMetadata,
18413
- },
18414
- step: nextStep,
18415
- successful: false,
18416
- response: null,
18417
- });
18418
- }
18419
- else if (nextStep.type === StepType$1.LoginSuccess) {
18420
- /**
18421
- * SUCCESSFUL COMPLETION BLOCK
18422
- */
18423
- // Set final state
18424
- set({
18425
- completed: true,
18426
- error: null,
18427
- loading: false,
18428
- metadata: null,
18429
- step: null,
18430
- successful: true,
18431
- response: nextStep.payload,
18432
- });
18433
- }
18434
- else if (nextStep.type === StepType$1.LoginFailure) {
18435
- /**
18436
- * FAILURE COMPLETION BLOCK
18437
- *
18438
- * Grab failure message, which may contain encoded HTML
18439
- */
18440
- const failureMessageStr = htmlDecode(nextStep.payload.message || '');
18441
- let restartedStep = null;
18442
- try {
18443
- /**
18444
- * Restart tree to get fresh step
18445
- */
18446
- restartedStep = await FRAuth$1.next(undefined, restartOptions);
18447
- }
18448
- catch (err) {
18449
- console.error(`Restart failed step request | ${err}`);
18450
- /**
18451
- * Setup an object to display failure message
18452
- */
18453
- restartedStep = new FRLoginFailure$1({
18454
- message: interpolate('unknownNetworkError'),
18455
- });
18456
- }
18457
- /**
18458
- * Now that we have a new authId (the identification of the
18459
- * fresh step) let's populate this new step with old callback data if
18460
- * this is step one and meets a few criteria.
18461
- *
18462
- * If error code is 110 or error message includes "Constrained Violation",
18463
- * then the issue needs special handling.
18464
- *
18465
- * If this is the first step in the journey, replace the callbacks with
18466
- * existing callbacks to resubmit with a fresh authId.
18467
- ******************************************************************* */
18468
- if (shouldPopulateWithPreviousCallbacks(nextStep, previousCallbacks, restartedStep, stepNumber)) {
18469
- /**
18470
- * TypeScript notes:
18471
- *
18472
- * Assert that restartedStep is FRStep as that is required for the above condition to be true.
18473
- * Also, assert that previousCallbacks is FRCallback[] as that too is required for above to be true.
18474
- *
18475
- * Attempt a refactor using Ryan's suggestion found here: https://www.typescriptlang.org/play?#code/PTAEHUFMBsGMHsC2lQBd5oBYoCoE8AHSAZVgCcBLA1UABWgEM8BzM+AVwDsATAGiwoBnUENANQAd0gAjQRVSQAUCEmYKsTKGYUAbpGF4OY0BoadYKdJMoL+gzAzIoz3UNEiPOofEVKVqAHSKymAAmkYI7NCuqGqcANag8ABmIjQUXrFOKBJMggBcISGgoAC0oACCbvCwDKgU8JkY7p7ehCTkVDQS2E6gnPCxGcwmZqDSTgzxxWWVoASMFmgYkAAeRJTInN3ymj4d-jSCeNsMq-wuoPaOltigAKoASgAywhK7SbGQZIIz5VWCFzSeCrZagNYbChbHaxUDcCjJZLfSDbExIAgUdxkUBIursJzCFJtXydajBZJcWD1RqgJyofGcABqDGg7EgAB4cAA+AAUq3y3nBqwUPGEglQlE4IwA-FcJcNQALOOxENJvgBKUAAb0UJT1CNAPNQ7SJoIAvBbQAAiZWq75WzV0hmgUG6vXg6CCFBOsheVZukoB0CKAC+incNCGUtAZtpkHpvuZrI54slzF5VoAjA6ANzkynUrxCYjyqV8gWphUAH36KrVZHVAuB8BaXh17oNRpNqXNloA5JWpX3Ne33XqfZkyGy8+6w0GJziWV683PO8XS8wjXFmOqR0Go8wAhlYKzuPoeVbsNBoPBc6HgiocM0PL7QIh4H0GMD2JG7owpewDDMJA-AnuoiRfvAegiF4VoAKKrAwiALPoVpJNiVrgA4qADqAABykASFaQQqAA8l8ZDvF6-DAUcqCOAorjSHgcbvjoCpfF6aKINCwiXF8kgftEIgGBw2ILEwrAcDwQQlEAA
18476
- */
18477
- restartedStep = restartedStep;
18478
- // Rebuild callbacks onto restartedStep
18479
- restartedStep.callbacks = previousCallbacks;
18480
- // Rebuild payload onto restartedStep ensuring the use of the NEW authId
18481
- restartedStep.payload = {
18482
- ...previousPayload,
18483
- authId: restartedStep.payload.authId,
18484
- };
18485
- const details = nextStep.payload.detail;
18486
- /**
18487
- * Only if the authId expires do we resubmit with same callback values
18488
- */
18489
- if (details?.errorCode === authIdTimeoutErrorCode) {
18490
- restartedStep = await FRAuth$1.next(restartedStep, options);
18491
- }
18492
- }
18493
- /**
18494
- * SET RESULT OF SUBSEQUENT REQUEST
18495
- *
18496
- * After the above attempts to salvage the form submission, let's return
18497
- * the final result to the user.
18498
- */
18499
- if (restartedStep.type === StepType$1.Step) {
18500
- const stageAttribute = restartedStep.getStage();
18501
- let stageJson = null;
18502
- let stageName = null;
18503
- // Check if stage attribute is serialized JSON
18504
- if (stageAttribute && stageAttribute.includes('{')) {
18505
- try {
18506
- stageJson = JSON.parse(stageAttribute);
18507
- }
18508
- catch (err) {
18509
- console.warn('Stage attribute value was not parsable');
18510
- }
18511
- }
18512
- else if (stageAttribute) {
18513
- stageName = stageAttribute;
18514
- }
18515
- const callbackMetadata = buildCallbackMetadata(restartedStep, initCheckValidation(), stageJson);
18516
- const stepMetadata = buildStepMetadata(callbackMetadata, stageJson, stageName);
18517
- set({
18518
- completed: false,
18519
- error: {
18520
- code: nextStep.getCode(),
18521
- message: failureMessageStr,
18522
- // TODO: Should we remove the callbacks for PII info?
18523
- step: prevStep?.payload,
18524
- },
18525
- loading: false,
18526
- metadata: {
18527
- callbacks: callbackMetadata,
18528
- step: stepMetadata,
18529
- },
18530
- step: restartedStep,
18531
- successful: false,
18532
- response: null,
18533
- });
18534
- }
18535
- else if (restartedStep.type === StepType$1.LoginSuccess) {
18536
- set({
18537
- completed: true,
18538
- error: null,
18539
- loading: false,
18540
- metadata: null,
18541
- step: null,
18542
- successful: true,
18543
- response: restartedStep.payload,
18544
- });
18545
- }
18546
- else {
18547
- set({
18548
- completed: true,
18549
- error: {
18550
- code: nextStep.getCode(),
18551
- message: failureMessageStr,
18552
- // TODO: Should we remove the callbacks for PII info?
18553
- step: prevStep?.payload,
18554
- },
18555
- loading: false,
18556
- metadata: null,
18557
- step: null,
18558
- successful: false,
18559
- response: restartedStep.payload,
18560
- });
18561
- }
18562
- }
18563
- }
18564
- async function pop() {
18565
- reset();
18566
- const updatedStack = await stack.pop();
18567
- const currentJourney = updatedStack[updatedStack.length - 1];
18568
- await start(currentJourney);
18569
- }
18570
- async function push(newOptions) {
18571
- reset();
18572
- await stack.push(newOptions);
18573
- await start(newOptions);
18574
- }
18575
- async function resume(url, resumeOptions) {
18576
- await next(undefined, resumeOptions, url);
18577
- }
18578
- async function start(startOptions) {
18579
- await stack.push(startOptions);
18580
- await next(undefined, startOptions);
18581
- }
18582
- function reset() {
18583
- set({
18584
- completed: false,
18585
- error: null,
18586
- loading: false,
18587
- metadata: null,
18588
- step: null,
18589
- successful: false,
18590
- response: null,
18591
- });
18592
- }
18593
- return {
18594
- next,
18595
- pop,
18596
- push,
18597
- reset,
18598
- resume,
18599
- start,
18600
- subscribe,
18601
- };
18850
+
18851
+ class Button extends SvelteComponent {
18852
+ constructor(options) {
18853
+ super();
18854
+
18855
+ init(this, options, instance$P, create_fragment$O, safe_not_equal, {
18856
+ busy: 0,
18857
+ classes: 1,
18858
+ onClick: 2,
18859
+ style: 3,
18860
+ type: 4,
18861
+ width: 5
18862
+ });
18863
+ }
18602
18864
  }
18603
- let stack;
18604
18865
 
18605
18866
  /* src/lib/components/primitives/form/form.svelte generated by Svelte v3.55.1 */
18606
18867
 
@@ -18831,7 +19092,7 @@ class Form extends SvelteComponent {
18831
19092
 
18832
19093
  /* src/lib/components/_utilities/server-strings.svelte generated by Svelte v3.55.1 */
18833
19094
 
18834
- function create_else_block$6(ctx) {
19095
+ function create_else_block$7(ctx) {
18835
19096
  let current;
18836
19097
  const default_slot_template = /*#slots*/ ctx[4].default;
18837
19098
  const default_slot = create_slot(default_slot_template, ctx, /*$$scope*/ ctx[3], null);
@@ -18884,7 +19145,7 @@ function create_else_block$6(ctx) {
18884
19145
  }
18885
19146
 
18886
19147
  // (10:0) {#if html}
18887
- function create_if_block$i(ctx) {
19148
+ function create_if_block$j(ctx) {
18888
19149
  let current;
18889
19150
  const default_slot_template = /*#slots*/ ctx[4].default;
18890
19151
  const default_slot = create_slot(default_slot_template, ctx, /*$$scope*/ ctx[3], null);
@@ -18986,7 +19247,7 @@ function create_fragment$M(ctx) {
18986
19247
  let if_block;
18987
19248
  let if_block_anchor;
18988
19249
  let current;
18989
- const if_block_creators = [create_if_block$i, create_else_block$6];
19250
+ const if_block_creators = [create_if_block$j, create_else_block$7];
18990
19251
  const if_blocks = [];
18991
19252
 
18992
19253
  function select_block_type(ctx, dirty) {
@@ -19179,64 +19440,9 @@ class Shield_icon extends SvelteComponent {
19179
19440
  }
19180
19441
  }
19181
19442
 
19182
- const journeyConfigItemSchema = mod.object({
19183
- journey: mod.string().optional(),
19184
- match: mod
19185
- .string()
19186
- .regex(/^(#\/service|\?journey)/, {
19187
- message: 'HREF string must start with `?journey` or `#/service`',
19188
- })
19189
- .array(),
19190
- });
19191
- const journeyConfigSchema = mod.object({
19192
- forgotPassword: journeyConfigItemSchema,
19193
- forgotUsername: journeyConfigItemSchema,
19194
- login: journeyConfigItemSchema,
19195
- register: journeyConfigItemSchema,
19196
- });
19197
- const defaultJourneys = {
19198
- forgotPassword: {
19199
- journey: 'ResetPassword',
19200
- match: ['#/service/ResetPassword', '?journey=ResetPassword'],
19201
- },
19202
- forgotUsername: {
19203
- journey: 'ForgottenUsername',
19204
- match: ['#/service/ForgottenUsername', '?journey=ForgottenUsername'],
19205
- },
19206
- login: {
19207
- journey: undefined,
19208
- match: ['#/service/Login', '?journey'],
19209
- },
19210
- register: {
19211
- journey: 'Registration',
19212
- match: ['#/service/Registration', '?journey=Registration'],
19213
- },
19214
- };
19215
- // Ensure default follows schema
19216
- journeyConfigSchema.parse(defaultJourneys);
19217
- let configuredJourneys;
19218
- function initialize$3(customJourneys) {
19219
- if (customJourneys) {
19220
- // Provide developer feedback if customized
19221
- journeyConfigSchema.parse(customJourneys);
19222
- const arr = Object.keys(customJourneys);
19223
- configuredJourneys = readable(arr.map((key) => ({
19224
- ...customJourneys[key],
19225
- key,
19226
- })));
19227
- }
19228
- else {
19229
- const arr = Object.keys(defaultJourneys);
19230
- configuredJourneys = readable(arr.map((key) => ({
19231
- ...defaultJourneys[key],
19232
- key,
19233
- })));
19234
- }
19235
- }
19236
-
19237
19443
  /* src/lib/journey/stages/_utilities/back-to.svelte generated by Svelte v3.55.1 */
19238
19444
 
19239
- function create_if_block$h(ctx) {
19445
+ function create_if_block$i(ctx) {
19240
19446
  let p;
19241
19447
  let button;
19242
19448
  let t_value = interpolate(/*string*/ ctx[1]) + "";
@@ -19274,7 +19480,7 @@ function create_if_block$h(ctx) {
19274
19480
 
19275
19481
  function create_fragment$K(ctx) {
19276
19482
  let if_block_anchor;
19277
- let if_block = /*$stack*/ ctx[2].length > 1 && create_if_block$h(ctx);
19483
+ let if_block = /*$stack*/ ctx[2].length > 1 && create_if_block$i(ctx);
19278
19484
 
19279
19485
  return {
19280
19486
  c() {
@@ -19290,7 +19496,7 @@ function create_fragment$K(ctx) {
19290
19496
  if (if_block) {
19291
19497
  if_block.p(ctx, dirty);
19292
19498
  } else {
19293
- if_block = create_if_block$h(ctx);
19499
+ if_block = create_if_block$i(ctx);
19294
19500
  if_block.c();
19295
19501
  if_block.m(if_block_anchor.parentNode, if_block_anchor);
19296
19502
  }
@@ -19310,15 +19516,15 @@ function create_fragment$K(ctx) {
19310
19516
 
19311
19517
  function instance$L($$self, $$props, $$invalidate) {
19312
19518
  let $stack;
19313
- let $configuredJourneys;
19314
- component_subscribe($$self, configuredJourneys, $$value => $$invalidate(5, $configuredJourneys = $$value));
19519
+ let $configuredJourneysStore;
19520
+ component_subscribe($$self, configuredJourneysStore, $$value => $$invalidate(5, $configuredJourneysStore = $$value));
19315
19521
  let { journey } = $$props;
19316
19522
  let stack = journey.stack;
19317
19523
  component_subscribe($$self, stack, value => $$invalidate(2, $stack = value));
19318
19524
  let string = '';
19319
19525
 
19320
19526
  function constructString() {
19321
- const currentJourney = $configuredJourneys.find(journey => {
19527
+ const currentJourney = $configuredJourneysStore.find(journey => {
19322
19528
  return journey.journey === $stack[$stack.length - 2]?.tree;
19323
19529
  });
19324
19530
 
@@ -19359,7 +19565,7 @@ class Back_to extends SvelteComponent {
19359
19565
  * @param {object} currentJourney - The current stage's journey object
19360
19566
  */
19361
19567
  function captureLinks(linkWrapper, currentJourney) {
19362
- const journeys = get_store_value(configuredJourneys);
19568
+ const journeys = get_store_value(configuredJourneysStore);
19363
19569
  const stack = get_store_value(currentJourney.stack);
19364
19570
  linkWrapper.addEventListener('click', (event) => {
19365
19571
  const target = event.target;
@@ -19666,7 +19872,7 @@ function getAttributeValidationFailureText(callback) {
19666
19872
 
19667
19873
  /* src/lib/components/primitives/message/input-message.svelte generated by Svelte v3.55.1 */
19668
19874
 
19669
- function create_if_block$g(ctx) {
19875
+ function create_if_block$h(ctx) {
19670
19876
  let p;
19671
19877
  let p_class_value;
19672
19878
  let p_id_value;
@@ -19699,7 +19905,7 @@ function create_if_block$g(ctx) {
19699
19905
 
19700
19906
  function create_fragment$J(ctx) {
19701
19907
  let if_block_anchor;
19702
- let if_block = /*dirtyMessage*/ ctx[1] && create_if_block$g(ctx);
19908
+ let if_block = /*dirtyMessage*/ ctx[1] && create_if_block$h(ctx);
19703
19909
 
19704
19910
  return {
19705
19911
  c() {
@@ -19715,7 +19921,7 @@ function create_fragment$J(ctx) {
19715
19921
  if (if_block) {
19716
19922
  if_block.p(ctx, dirty);
19717
19923
  } else {
19718
- if_block = create_if_block$g(ctx);
19924
+ if_block = create_if_block$h(ctx);
19719
19925
  if_block.c();
19720
19926
  if_block.m(if_block_anchor.parentNode, if_block_anchor);
19721
19927
  }
@@ -21194,7 +21400,7 @@ function create_each_block$7(ctx) {
21194
21400
  }
21195
21401
 
21196
21402
  // (62:0) {#if labelOrder === 'last'}
21197
- function create_if_block$f(ctx) {
21403
+ function create_if_block$g(ctx) {
21198
21404
  let label_1;
21199
21405
  let current;
21200
21406
 
@@ -21284,7 +21490,7 @@ function create_fragment$C(ctx) {
21284
21490
  each_blocks[i] = create_each_block$7(get_each_context$7(ctx, each_value, i));
21285
21491
  }
21286
21492
 
21287
- let if_block1 = /*labelOrder*/ ctx[7] === 'last' && create_if_block$f(ctx);
21493
+ let if_block1 = /*labelOrder*/ ctx[7] === 'last' && create_if_block$g(ctx);
21288
21494
 
21289
21495
  return {
21290
21496
  c() {
@@ -21406,7 +21612,7 @@ function create_fragment$C(ctx) {
21406
21612
  transition_in(if_block1, 1);
21407
21613
  }
21408
21614
  } else {
21409
- if_block1 = create_if_block$f(ctx);
21615
+ if_block1 = create_if_block$g(ctx);
21410
21616
  if_block1.c();
21411
21617
  transition_in(if_block1, 1);
21412
21618
  if_block1.m(if_block1_anchor.parentNode, if_block1_anchor);
@@ -21710,7 +21916,7 @@ let Floating_label$1 = class Floating_label extends SvelteComponent {
21710
21916
 
21711
21917
  /* src/lib/journey/callbacks/choice/choice.svelte generated by Svelte v3.55.1 */
21712
21918
 
21713
- function create_else_block$5(ctx) {
21919
+ function create_else_block$6(ctx) {
21714
21920
  let select;
21715
21921
  let current;
21716
21922
 
@@ -21759,7 +21965,7 @@ function create_else_block$5(ctx) {
21759
21965
  }
21760
21966
 
21761
21967
  // (62:0) {#if callbackMetadata?.platform?.displayType === 'radio'}
21762
- function create_if_block$e(ctx) {
21968
+ function create_if_block$f(ctx) {
21763
21969
  let radio;
21764
21970
  let current;
21765
21971
 
@@ -21814,7 +22020,7 @@ function create_fragment$A(ctx) {
21814
22020
  let if_block;
21815
22021
  let if_block_anchor;
21816
22022
  let current;
21817
- const if_block_creators = [create_if_block$e, create_else_block$5];
22023
+ const if_block_creators = [create_if_block$f, create_else_block$6];
21818
22024
  const if_blocks = [];
21819
22025
 
21820
22026
  function select_block_type(ctx, dirty) {
@@ -22096,7 +22302,7 @@ function get_each_context$6(ctx, list, i) {
22096
22302
  }
22097
22303
 
22098
22304
  // (96:0) {#if stepMetadata?.platform?.stageName !== 'OneTimePassword'}
22099
- function create_if_block$d(ctx) {
22305
+ function create_if_block$e(ctx) {
22100
22306
  let current_block_type_index;
22101
22307
  let if_block;
22102
22308
  let if_block_anchor;
@@ -22217,7 +22423,7 @@ function create_if_block_1$9(ctx) {
22217
22423
  let if_block;
22218
22424
  let if_block_anchor;
22219
22425
  let current;
22220
- const if_block_creators = [create_if_block_2$8, create_else_block$4];
22426
+ const if_block_creators = [create_if_block_2$8, create_else_block$5];
22221
22427
  const if_blocks = [];
22222
22428
 
22223
22429
  function select_block_type_1(ctx, dirty) {
@@ -22452,7 +22658,7 @@ function create_default_slot_1$a(ctx) {
22452
22658
  }
22453
22659
 
22454
22660
  // (107:4) {:else}
22455
- function create_else_block$4(ctx) {
22661
+ function create_else_block$5(ctx) {
22456
22662
  let checkbox;
22457
22663
  let current;
22458
22664
 
@@ -22573,7 +22779,7 @@ function create_default_slot$h(ctx) {
22573
22779
  function create_fragment$y(ctx) {
22574
22780
  let if_block_anchor;
22575
22781
  let current;
22576
- let if_block = /*stepMetadata*/ ctx[1]?.platform?.stageName !== 'OneTimePassword' && create_if_block$d(ctx);
22782
+ let if_block = /*stepMetadata*/ ctx[1]?.platform?.stageName !== 'OneTimePassword' && create_if_block$e(ctx);
22577
22783
 
22578
22784
  return {
22579
22785
  c() {
@@ -22594,7 +22800,7 @@ function create_fragment$y(ctx) {
22594
22800
  transition_in(if_block, 1);
22595
22801
  }
22596
22802
  } else {
22597
- if_block = create_if_block$d(ctx);
22803
+ if_block = create_if_block$e(ctx);
22598
22804
  if_block.c();
22599
22805
  transition_in(if_block, 1);
22600
22806
  if_block.m(if_block_anchor.parentNode, if_block_anchor);
@@ -23368,7 +23574,7 @@ function create_if_block_1$8(ctx) {
23368
23574
  }
23369
23575
 
23370
23576
  // (129:0) {#if labelOrder === 'last'}
23371
- function create_if_block$c(ctx) {
23577
+ function create_if_block$d(ctx) {
23372
23578
  let label_1;
23373
23579
  let current;
23374
23580
 
@@ -23452,7 +23658,7 @@ function create_fragment$x(ctx) {
23452
23658
  let if_block4 = /*type*/ ctx[11] === 'password' && create_if_block_3$3(ctx);
23453
23659
  let if_block5 = /*type*/ ctx[11] === 'phone' && create_if_block_2$7(ctx);
23454
23660
  let if_block6 = /*type*/ ctx[11] === 'text' && create_if_block_1$8(ctx);
23455
- let if_block7 = /*labelOrder*/ ctx[6] === 'last' && create_if_block$c(ctx);
23661
+ let if_block7 = /*labelOrder*/ ctx[6] === 'last' && create_if_block$d(ctx);
23456
23662
 
23457
23663
  return {
23458
23664
  c() {
@@ -23602,7 +23808,7 @@ function create_fragment$x(ctx) {
23602
23808
  transition_in(if_block7, 1);
23603
23809
  }
23604
23810
  } else {
23605
- if_block7 = create_if_block$c(ctx);
23811
+ if_block7 = create_if_block$d(ctx);
23606
23812
  if_block7.c();
23607
23813
  transition_in(if_block7, 1);
23608
23814
  if_block7.m(if_block7_anchor.parentNode, if_block7_anchor);
@@ -24461,7 +24667,7 @@ class Lock_icon extends SvelteComponent {
24461
24667
 
24462
24668
  /* src/lib/journey/callbacks/kba/kba-create.svelte generated by Svelte v3.55.1 */
24463
24669
 
24464
- function create_if_block$b(ctx) {
24670
+ function create_if_block$c(ctx) {
24465
24671
  let input;
24466
24672
  let current;
24467
24673
 
@@ -24540,7 +24746,7 @@ function create_fragment$t(ctx) {
24540
24746
  }
24541
24747
  });
24542
24748
 
24543
- let if_block = /*displayCustomQuestionInput*/ ctx[3] && create_if_block$b(ctx);
24749
+ let if_block = /*displayCustomQuestionInput*/ ctx[3] && create_if_block$c(ctx);
24544
24750
 
24545
24751
  function input_value_binding(value) {
24546
24752
  /*input_value_binding*/ ctx[20](value);
@@ -24618,7 +24824,7 @@ function create_fragment$t(ctx) {
24618
24824
  transition_in(if_block, 1);
24619
24825
  }
24620
24826
  } else {
24621
- if_block = create_if_block$b(ctx);
24827
+ if_block = create_if_block$c(ctx);
24622
24828
  if_block.c();
24623
24829
  transition_in(if_block, 1);
24624
24830
  if_block.m(fieldset, t6);
@@ -25000,7 +25206,7 @@ class Name extends SvelteComponent {
25000
25206
 
25001
25207
  /* src/lib/components/icons/eye-icon.svelte generated by Svelte v3.55.1 */
25002
25208
 
25003
- function create_else_block$3(ctx) {
25209
+ function create_else_block$4(ctx) {
25004
25210
  let svg;
25005
25211
  let path0;
25006
25212
  let path1;
@@ -25082,7 +25288,7 @@ function create_else_block$3(ctx) {
25082
25288
  }
25083
25289
 
25084
25290
  // (6:0) {#if !visible}
25085
- function create_if_block$a(ctx) {
25291
+ function create_if_block$b(ctx) {
25086
25292
  let svg;
25087
25293
  let path0;
25088
25294
  let path1;
@@ -25168,7 +25374,7 @@ function create_fragment$r(ctx) {
25168
25374
  let if_block;
25169
25375
  let if_block_anchor;
25170
25376
  let current;
25171
- const if_block_creators = [create_if_block$a, create_else_block$3];
25377
+ const if_block_creators = [create_if_block$b, create_else_block$4];
25172
25378
  const if_blocks = [];
25173
25379
 
25174
25380
  function select_block_type(ctx, dirty) {
@@ -25681,7 +25887,7 @@ function create_input_button_slot(ctx) {
25681
25887
  }
25682
25888
 
25683
25889
  // (89:0) {#if callbackMetadata?.platform?.confirmPassword}
25684
- function create_if_block$9(ctx) {
25890
+ function create_if_block$a(ctx) {
25685
25891
  let confirminput;
25686
25892
  let current;
25687
25893
 
@@ -25759,7 +25965,7 @@ function create_fragment$p(ctx) {
25759
25965
  }
25760
25966
  });
25761
25967
 
25762
- let if_block = /*callbackMetadata*/ ctx[1]?.platform?.confirmPassword && create_if_block$9(ctx);
25968
+ let if_block = /*callbackMetadata*/ ctx[1]?.platform?.confirmPassword && create_if_block$a(ctx);
25763
25969
 
25764
25970
  return {
25765
25971
  c() {
@@ -25808,7 +26014,7 @@ function create_fragment$p(ctx) {
25808
26014
  transition_in(if_block, 1);
25809
26015
  }
25810
26016
  } else {
25811
- if_block = create_if_block$9(ctx);
26017
+ if_block = create_if_block$a(ctx);
25812
26018
  if_block.c();
25813
26019
  transition_in(if_block, 1);
25814
26020
  if_block.m(if_block_anchor.parentNode, if_block_anchor);
@@ -27132,7 +27338,7 @@ function create_each_block$5(ctx) {
27132
27338
  }
27133
27339
 
27134
27340
  // (81:0) {#if stepMetadata && stepMetadata.derived.numOfCallbacks > 1}
27135
- function create_if_block$8(ctx) {
27341
+ function create_if_block$9(ctx) {
27136
27342
  let grid;
27137
27343
  let current;
27138
27344
 
@@ -27201,7 +27407,7 @@ function create_fragment$h(ctx) {
27201
27407
  each_blocks[i] = null;
27202
27408
  });
27203
27409
 
27204
- let if_block = /*stepMetadata*/ ctx[0] && /*stepMetadata*/ ctx[0].derived.numOfCallbacks > 1 && create_if_block$8(ctx);
27410
+ let if_block = /*stepMetadata*/ ctx[0] && /*stepMetadata*/ ctx[0].derived.numOfCallbacks > 1 && create_if_block$9(ctx);
27205
27411
 
27206
27412
  return {
27207
27413
  c() {
@@ -27257,7 +27463,7 @@ function create_fragment$h(ctx) {
27257
27463
  transition_in(if_block, 1);
27258
27464
  }
27259
27465
  } else {
27260
- if_block = create_if_block$8(ctx);
27466
+ if_block = create_if_block$9(ctx);
27261
27467
  if_block.c();
27262
27468
  transition_in(if_block, 1);
27263
27469
  if_block.m(if_block_anchor.parentNode, if_block_anchor);
@@ -27496,7 +27702,7 @@ function create_if_block_1$6(ctx) {
27496
27702
  }
27497
27703
 
27498
27704
  // (23:0) {#if simplifiedFailures.length}
27499
- function create_if_block$7(ctx) {
27705
+ function create_if_block$8(ctx) {
27500
27706
  let div;
27501
27707
  let p;
27502
27708
  let t0;
@@ -27646,7 +27852,7 @@ function create_fragment$g(ctx) {
27646
27852
  let if_block;
27647
27853
  let if_block_anchor;
27648
27854
  let current;
27649
- const if_block_creators = [create_if_block$7, create_if_block_1$6];
27855
+ const if_block_creators = [create_if_block$8, create_if_block_1$6];
27650
27856
  const if_blocks = [];
27651
27857
 
27652
27858
  function select_block_type(ctx, dirty) {
@@ -28099,28 +28305,9 @@ class Link extends SvelteComponent {
28099
28305
  }
28100
28306
  }
28101
28307
 
28102
- const linksSchema = mod
28103
- .object({
28104
- termsAndConditions: mod.string(),
28105
- })
28106
- .strict();
28107
- linksSchema.partial();
28108
- let links;
28109
- function initialize$2(customLinks) {
28110
- // If customLinks is provided, provide feedback for object
28111
- if (customLinks) {
28112
- // Provide developer feedback for custom links
28113
- linksSchema.parse(customLinks);
28114
- links = readable(customLinks);
28115
- }
28116
- else {
28117
- links = readable();
28118
- }
28119
- }
28120
-
28121
28308
  /* src/lib/journey/callbacks/terms-and-conditions/terms-conditions.svelte generated by Svelte v3.55.1 */
28122
28309
 
28123
- function create_else_block$2(ctx) {
28310
+ function create_else_block$3(ctx) {
28124
28311
  let p;
28125
28312
 
28126
28313
  return {
@@ -28141,8 +28328,8 @@ function create_else_block$2(ctx) {
28141
28328
  };
28142
28329
  }
28143
28330
 
28144
- // (43:0) {#if $links?.termsAndConditions}
28145
- function create_if_block$6(ctx) {
28331
+ // (43:0) {#if $linksStore?.termsAndConditions}
28332
+ function create_if_block$7(ctx) {
28146
28333
  let link;
28147
28334
  let t;
28148
28335
  let checkbox;
@@ -28151,7 +28338,7 @@ function create_if_block$6(ctx) {
28151
28338
  link = new Link({
28152
28339
  props: {
28153
28340
  classes: "tw_block tw_mb-4",
28154
- href: /*$links*/ ctx[2]?.termsAndConditions,
28341
+ href: /*$linksStore*/ ctx[2]?.termsAndConditions,
28155
28342
  target: "_blank",
28156
28343
  $$slots: { default: [create_default_slot_1$5] },
28157
28344
  $$scope: { ctx }
@@ -28183,7 +28370,7 @@ function create_if_block$6(ctx) {
28183
28370
  },
28184
28371
  p(ctx, dirty) {
28185
28372
  const link_changes = {};
28186
- if (dirty & /*$links*/ 4) link_changes.href = /*$links*/ ctx[2]?.termsAndConditions;
28373
+ if (dirty & /*$linksStore*/ 4) link_changes.href = /*$linksStore*/ ctx[2]?.termsAndConditions;
28187
28374
 
28188
28375
  if (dirty & /*$$scope*/ 1024) {
28189
28376
  link_changes.$$scope = { dirty, ctx };
@@ -28219,7 +28406,7 @@ function create_if_block$6(ctx) {
28219
28406
  };
28220
28407
  }
28221
28408
 
28222
- // (44:2) <Link classes="tw_block tw_mb-4" href={$links?.termsAndConditions} target="_blank">
28409
+ // (44:2) <Link classes="tw_block tw_mb-4" href={$linksStore?.termsAndConditions} target="_blank">
28223
28410
  function create_default_slot_1$5(ctx) {
28224
28411
  let t_value = interpolate('termsAndConditionsLinkText') + "";
28225
28412
  let t;
@@ -28273,11 +28460,11 @@ function create_fragment$d(ctx) {
28273
28460
  let if_block;
28274
28461
  let if_block_anchor;
28275
28462
  let current;
28276
- const if_block_creators = [create_if_block$6, create_else_block$2];
28463
+ const if_block_creators = [create_if_block$7, create_else_block$3];
28277
28464
  const if_blocks = [];
28278
28465
 
28279
28466
  function select_block_type(ctx, dirty) {
28280
- if (/*$links*/ ctx[2]?.termsAndConditions) return 0;
28467
+ if (/*$linksStore*/ ctx[2]?.termsAndConditions) return 0;
28281
28468
  return 1;
28282
28469
  }
28283
28470
 
@@ -28338,8 +28525,8 @@ function create_fragment$d(ctx) {
28338
28525
  }
28339
28526
 
28340
28527
  function instance$d($$self, $$props, $$invalidate) {
28341
- let $links;
28342
- component_subscribe($$self, links, $$value => $$invalidate(2, $links = $$value));
28528
+ let $linksStore;
28529
+ component_subscribe($$self, linksStore, $$value => $$invalidate(2, $linksStore = $$value));
28343
28530
  const selfSubmitFunction = null;
28344
28531
  const stepMetadata = null;
28345
28532
  const style = {};
@@ -28390,7 +28577,7 @@ function instance$d($$self, $$props, $$invalidate) {
28390
28577
  return [
28391
28578
  callbackMetadata,
28392
28579
  inputName,
28393
- $links,
28580
+ $linksStore,
28394
28581
  Checkbox,
28395
28582
  setValue,
28396
28583
  selfSubmitFunction,
@@ -29210,7 +29397,7 @@ function get_if_ctx(ctx) {
29210
29397
  }
29211
29398
 
29212
29399
  // (198:0) {:else}
29213
- function create_else_block$1(ctx) {
29400
+ function create_else_block$2(ctx) {
29214
29401
  let unknown;
29215
29402
  let current;
29216
29403
  const unknown_spread_levels = [/*newProps*/ ctx[19]];
@@ -29898,7 +30085,7 @@ function create_if_block_1$5(ctx) {
29898
30085
  }
29899
30086
 
29900
30087
  // (102:0) {#if cbType === CallbackType.BooleanAttributeInputCallback}
29901
- function create_if_block$5(ctx) {
30088
+ function create_if_block$6(ctx) {
29902
30089
  let boolean;
29903
30090
  let current;
29904
30091
  const boolean_spread_levels = [/*newProps*/ ctx[19]];
@@ -29947,7 +30134,7 @@ function create_fragment$8(ctx) {
29947
30134
  let current;
29948
30135
 
29949
30136
  const if_block_creators = [
29950
- create_if_block$5,
30137
+ create_if_block$6,
29951
30138
  create_if_block_1$5,
29952
30139
  create_if_block_2$5,
29953
30140
  create_if_block_3$1,
@@ -29963,7 +30150,7 @@ function create_fragment$8(ctx) {
29963
30150
  create_if_block_13,
29964
30151
  create_if_block_14,
29965
30152
  create_if_block_15,
29966
- create_else_block$1
30153
+ create_else_block$2
29967
30154
  ];
29968
30155
 
29969
30156
  const if_blocks = [];
@@ -30310,7 +30497,7 @@ function create_each_block$3(ctx) {
30310
30497
  callbackMetadata: /*metadata*/ ctx[3]?.callbacks[/*idx*/ ctx[17]],
30311
30498
  selfSubmitFunction: /*determineSubmission*/ ctx[11],
30312
30499
  stepMetadata: /*metadata*/ ctx[3]?.step && { .../*metadata*/ ctx[3].step },
30313
- style: /*$style*/ ctx[10]
30500
+ style: /*$styleStore*/ ctx[10]
30314
30501
  }
30315
30502
  }
30316
30503
  });
@@ -30326,12 +30513,12 @@ function create_each_block$3(ctx) {
30326
30513
  p(ctx, dirty) {
30327
30514
  const callbackmapper_changes = {};
30328
30515
 
30329
- if (dirty & /*step, metadata, $style*/ 1048) callbackmapper_changes.props = {
30516
+ if (dirty & /*step, metadata, $styleStore*/ 1048) callbackmapper_changes.props = {
30330
30517
  callback: /*callback*/ ctx[15],
30331
30518
  callbackMetadata: /*metadata*/ ctx[3]?.callbacks[/*idx*/ ctx[17]],
30332
30519
  selfSubmitFunction: /*determineSubmission*/ ctx[11],
30333
30520
  stepMetadata: /*metadata*/ ctx[3]?.step && { .../*metadata*/ ctx[3].step },
30334
- style: /*$style*/ ctx[10]
30521
+ style: /*$styleStore*/ ctx[10]
30335
30522
  };
30336
30523
 
30337
30524
  callbackmapper.$set(callbackmapper_changes);
@@ -30352,7 +30539,7 @@ function create_each_block$3(ctx) {
30352
30539
  }
30353
30540
 
30354
30541
  // (105:2) {#if metadata?.step?.derived.isUserInputOptional || !metadata?.step?.derived.isStepSelfSubmittable}
30355
- function create_if_block$4(ctx) {
30542
+ function create_if_block$5(ctx) {
30356
30543
  let button;
30357
30544
  let current;
30358
30545
 
@@ -30473,7 +30660,7 @@ function create_default_slot$5(ctx) {
30473
30660
  each_blocks[i] = null;
30474
30661
  });
30475
30662
 
30476
- let if_block2 = (/*metadata*/ ctx[3]?.step?.derived.isUserInputOptional || !/*metadata*/ ctx[3]?.step?.derived.isStepSelfSubmittable) && create_if_block$4(ctx);
30663
+ let if_block2 = (/*metadata*/ ctx[3]?.step?.derived.isUserInputOptional || !/*metadata*/ ctx[3]?.step?.derived.isStepSelfSubmittable) && create_if_block$5(ctx);
30477
30664
  backto = new Back_to({ props: { journey: /*journey*/ ctx[2] } });
30478
30665
 
30479
30666
  return {
@@ -30578,7 +30765,7 @@ function create_default_slot$5(ctx) {
30578
30765
  check_outros();
30579
30766
  }
30580
30767
 
30581
- if (dirty & /*step, metadata, determineSubmission, $style*/ 3096) {
30768
+ if (dirty & /*step, metadata, determineSubmission, $styleStore*/ 3096) {
30582
30769
  each_value = /*step*/ ctx[4]?.callbacks;
30583
30770
  let i;
30584
30771
 
@@ -30613,7 +30800,7 @@ function create_default_slot$5(ctx) {
30613
30800
  transition_in(if_block2, 1);
30614
30801
  }
30615
30802
  } else {
30616
- if_block2 = create_if_block$4(ctx);
30803
+ if_block2 = create_if_block$5(ctx);
30617
30804
  if_block2.c();
30618
30805
  transition_in(if_block2, 1);
30619
30806
  if_block2.m(t5.parentNode, t5);
@@ -30719,7 +30906,7 @@ function create_fragment$7(ctx) {
30719
30906
  if (dirty & /*formAriaDescriptor*/ 128) form_1_changes.ariaDescribedBy = /*formAriaDescriptor*/ ctx[7];
30720
30907
  if (dirty & /*formNeedsFocus*/ 256) form_1_changes.needsFocus = /*formNeedsFocus*/ ctx[8];
30721
30908
 
30722
- if (dirty & /*$$scope, journey, metadata, step, $style, alertNeedsFocus, formMessageKey, form, linkWrapper*/ 263806) {
30909
+ if (dirty & /*$$scope, journey, metadata, step, $styleStore, alertNeedsFocus, formMessageKey, form, linkWrapper*/ 263806) {
30723
30910
  form_1_changes.$$scope = { dirty, ctx };
30724
30911
  }
30725
30912
 
@@ -30751,8 +30938,8 @@ const formHeaderId = 'genericStepHeader';
30751
30938
  const formElementId = 'genericStepForm';
30752
30939
 
30753
30940
  function instance$7($$self, $$props, $$invalidate) {
30754
- let $style;
30755
- component_subscribe($$self, style, $$value => $$invalidate(10, $style = $$value));
30941
+ let $styleStore;
30942
+ component_subscribe($$self, styleStore, $$value => $$invalidate(10, $styleStore = $$value));
30756
30943
  let { form } = $$props;
30757
30944
  let { formEl = null } = $$props;
30758
30945
  let { journey } = $$props;
@@ -30833,7 +31020,7 @@ function instance$7($$self, $$props, $$invalidate) {
30833
31020
  formAriaDescriptor,
30834
31021
  formNeedsFocus,
30835
31022
  linkWrapper,
30836
- $style,
31023
+ $styleStore,
30837
31024
  determineSubmission,
30838
31025
  submitFormWrapper,
30839
31026
  header_binding,
@@ -31131,7 +31318,7 @@ function create_each_block$2(ctx) {
31131
31318
  }
31132
31319
 
31133
31320
  // (71:2) {#if metadata?.step?.derived.isUserInputOptional || !metadata?.step?.derived.isStepSelfSubmittable}
31134
- function create_if_block$3(ctx) {
31321
+ function create_if_block$4(ctx) {
31135
31322
  let button;
31136
31323
  let current;
31137
31324
 
@@ -31244,7 +31431,7 @@ function create_default_slot$4(ctx) {
31244
31431
  each_blocks[i] = null;
31245
31432
  });
31246
31433
 
31247
- let if_block2 = (/*metadata*/ ctx[3]?.step?.derived.isUserInputOptional || !/*metadata*/ ctx[3]?.step?.derived.isStepSelfSubmittable) && create_if_block$3(ctx);
31434
+ let if_block2 = (/*metadata*/ ctx[3]?.step?.derived.isUserInputOptional || !/*metadata*/ ctx[3]?.step?.derived.isStepSelfSubmittable) && create_if_block$4(ctx);
31248
31435
 
31249
31436
  return {
31250
31437
  c() {
@@ -31370,7 +31557,7 @@ function create_default_slot$4(ctx) {
31370
31557
  transition_in(if_block2, 1);
31371
31558
  }
31372
31559
  } else {
31373
- if_block2 = create_if_block$3(ctx);
31560
+ if_block2 = create_if_block$4(ctx);
31374
31561
  if_block2.c();
31375
31562
  transition_in(if_block2, 1);
31376
31563
  if_block2.m(if_block2_anchor.parentNode, if_block2_anchor);
@@ -31496,7 +31683,7 @@ function create_fragment$5(ctx) {
31496
31683
 
31497
31684
  function instance$5($$self, $$props, $$invalidate) {
31498
31685
  let $style;
31499
- component_subscribe($$self, style, $$value => $$invalidate(7, $style = $$value));
31686
+ component_subscribe($$self, styleStore, $$value => $$invalidate(7, $style = $$value));
31500
31687
  let { form } = $$props;
31501
31688
  let { formEl = null } = $$props;
31502
31689
  let { journey } = $$props;
@@ -31801,7 +31988,7 @@ function create_each_block$1(ctx) {
31801
31988
  callbackMetadata: /*metadata*/ ctx[3]?.callbacks[/*idx*/ ctx[14]],
31802
31989
  selfSubmitFunction: /*determineSubmission*/ ctx[9],
31803
31990
  stepMetadata: /*metadata*/ ctx[3]?.step && { .../*metadata*/ ctx[3].step },
31804
- style: /*$style*/ ctx[8]
31991
+ style: /*$styleStore*/ ctx[8]
31805
31992
  }
31806
31993
  }
31807
31994
  });
@@ -31817,12 +32004,12 @@ function create_each_block$1(ctx) {
31817
32004
  p(ctx, dirty) {
31818
32005
  const callbackmapper_changes = {};
31819
32006
 
31820
- if (dirty & /*step, metadata, $style*/ 280) callbackmapper_changes.props = {
32007
+ if (dirty & /*step, metadata, $styleStore*/ 280) callbackmapper_changes.props = {
31821
32008
  callback: /*callback*/ ctx[12],
31822
32009
  callbackMetadata: /*metadata*/ ctx[3]?.callbacks[/*idx*/ ctx[14]],
31823
32010
  selfSubmitFunction: /*determineSubmission*/ ctx[9],
31824
32011
  stepMetadata: /*metadata*/ ctx[3]?.step && { .../*metadata*/ ctx[3].step },
31825
- style: /*$style*/ ctx[8]
32012
+ style: /*$styleStore*/ ctx[8]
31826
32013
  };
31827
32014
 
31828
32015
  callbackmapper.$set(callbackmapper_changes);
@@ -31843,7 +32030,7 @@ function create_each_block$1(ctx) {
31843
32030
  }
31844
32031
 
31845
32032
  // (77:2) {#if metadata?.step?.derived.isUserInputOptional || !metadata?.step?.derived.isStepSelfSubmittable}
31846
- function create_if_block$2(ctx) {
32033
+ function create_if_block$3(ctx) {
31847
32034
  let button;
31848
32035
  let current;
31849
32036
 
@@ -31953,7 +32140,7 @@ function create_default_slot$3(ctx) {
31953
32140
  each_blocks[i] = null;
31954
32141
  });
31955
32142
 
31956
- let if_block2 = (/*metadata*/ ctx[3]?.step?.derived.isUserInputOptional || !/*metadata*/ ctx[3]?.step?.derived.isStepSelfSubmittable) && create_if_block$2(ctx);
32143
+ let if_block2 = (/*metadata*/ ctx[3]?.step?.derived.isUserInputOptional || !/*metadata*/ ctx[3]?.step?.derived.isStepSelfSubmittable) && create_if_block$3(ctx);
31957
32144
 
31958
32145
  return {
31959
32146
  c() {
@@ -32045,7 +32232,7 @@ function create_default_slot$3(ctx) {
32045
32232
  check_outros();
32046
32233
  }
32047
32234
 
32048
- if (dirty & /*step, metadata, determineSubmission, $style*/ 792) {
32235
+ if (dirty & /*step, metadata, determineSubmission, $styleStore*/ 792) {
32049
32236
  each_value = /*step*/ ctx[4]?.callbacks;
32050
32237
  let i;
32051
32238
 
@@ -32080,7 +32267,7 @@ function create_default_slot$3(ctx) {
32080
32267
  transition_in(if_block2, 1);
32081
32268
  }
32082
32269
  } else {
32083
- if_block2 = create_if_block$2(ctx);
32270
+ if_block2 = create_if_block$3(ctx);
32084
32271
  if_block2.c();
32085
32272
  transition_in(if_block2, 1);
32086
32273
  if_block2.m(if_block2_anchor.parentNode, if_block2_anchor);
@@ -32178,7 +32365,7 @@ function create_fragment$3(ctx) {
32178
32365
  const form_1_changes = {};
32179
32366
  if (dirty & /*form*/ 2) form_1_changes.onSubmitWhenValid = /*form*/ ctx[1]?.submit;
32180
32367
 
32181
- if (dirty & /*$$scope, journey, metadata, step, $style, alertNeedsFocus, formMessageKey, form, linkWrapper*/ 33278) {
32368
+ if (dirty & /*$$scope, journey, metadata, step, $styleStore, alertNeedsFocus, formMessageKey, form, linkWrapper*/ 33278) {
32182
32369
  form_1_changes.$$scope = { dirty, ctx };
32183
32370
  }
32184
32371
 
@@ -32206,8 +32393,8 @@ function create_fragment$3(ctx) {
32206
32393
  }
32207
32394
 
32208
32395
  function instance$3($$self, $$props, $$invalidate) {
32209
- let $style;
32210
- component_subscribe($$self, style, $$value => $$invalidate(8, $style = $$value));
32396
+ let $styleStore;
32397
+ component_subscribe($$self, styleStore, $$value => $$invalidate(8, $styleStore = $$value));
32211
32398
  let { form } = $$props;
32212
32399
  let { formEl = null } = $$props;
32213
32400
  let { journey } = $$props;
@@ -32269,7 +32456,7 @@ function instance$3($$self, $$props, $$invalidate) {
32269
32456
  alertNeedsFocus,
32270
32457
  formMessageKey,
32271
32458
  linkWrapper,
32272
- $style,
32459
+ $styleStore,
32273
32460
  determineSubmission,
32274
32461
  p_binding,
32275
32462
  form_1_formEl_binding
@@ -32420,7 +32607,7 @@ function create_each_block(ctx) {
32420
32607
  callbackMetadata: /*metadata*/ ctx[3]?.callbacks[/*idx*/ ctx[16]],
32421
32608
  selfSubmitFunction: /*determineSubmission*/ ctx[9],
32422
32609
  stepMetadata: /*metadata*/ ctx[3]?.step && { .../*metadata*/ ctx[3].step },
32423
- style: /*$style*/ ctx[8]
32610
+ style: /*$styleStore*/ ctx[8]
32424
32611
  }
32425
32612
  }
32426
32613
  });
@@ -32436,12 +32623,12 @@ function create_each_block(ctx) {
32436
32623
  p(ctx, dirty) {
32437
32624
  const callbackmapper_changes = {};
32438
32625
 
32439
- if (dirty & /*step, metadata, $style*/ 280) callbackmapper_changes.props = {
32626
+ if (dirty & /*step, metadata, $styleStore*/ 280) callbackmapper_changes.props = {
32440
32627
  callback: /*callback*/ ctx[14],
32441
32628
  callbackMetadata: /*metadata*/ ctx[3]?.callbacks[/*idx*/ ctx[16]],
32442
32629
  selfSubmitFunction: /*determineSubmission*/ ctx[9],
32443
32630
  stepMetadata: /*metadata*/ ctx[3]?.step && { .../*metadata*/ ctx[3].step },
32444
- style: /*$style*/ ctx[8]
32631
+ style: /*$styleStore*/ ctx[8]
32445
32632
  };
32446
32633
 
32447
32634
  callbackmapper.$set(callbackmapper_changes);
@@ -32462,7 +32649,7 @@ function create_each_block(ctx) {
32462
32649
  }
32463
32650
 
32464
32651
  // (71:2) {#if metadata?.step?.derived.isUserInputOptional || !metadata?.step?.derived.isStepSelfSubmittable}
32465
- function create_if_block$1(ctx) {
32652
+ function create_if_block$2(ctx) {
32466
32653
  let button;
32467
32654
  let current;
32468
32655
 
@@ -32575,7 +32762,7 @@ function create_default_slot$2(ctx) {
32575
32762
  each_blocks[i] = null;
32576
32763
  });
32577
32764
 
32578
- let if_block2 = (/*metadata*/ ctx[3]?.step?.derived.isUserInputOptional || !/*metadata*/ ctx[3]?.step?.derived.isStepSelfSubmittable) && create_if_block$1(ctx);
32765
+ let if_block2 = (/*metadata*/ ctx[3]?.step?.derived.isUserInputOptional || !/*metadata*/ ctx[3]?.step?.derived.isStepSelfSubmittable) && create_if_block$2(ctx);
32579
32766
 
32580
32767
  t11 = new Locale_strings({
32581
32768
  props: { key: "dontHaveAnAccount", html: true }
@@ -32696,7 +32883,7 @@ function create_default_slot$2(ctx) {
32696
32883
  check_outros();
32697
32884
  }
32698
32885
 
32699
- if (dirty & /*step, metadata, determineSubmission, $style*/ 792) {
32886
+ if (dirty & /*step, metadata, determineSubmission, $styleStore*/ 792) {
32700
32887
  each_value = /*step*/ ctx[4]?.callbacks;
32701
32888
  let i;
32702
32889
 
@@ -32731,7 +32918,7 @@ function create_default_slot$2(ctx) {
32731
32918
  transition_in(if_block2, 1);
32732
32919
  }
32733
32920
  } else {
32734
- if_block2 = create_if_block$1(ctx);
32921
+ if_block2 = create_if_block$2(ctx);
32735
32922
  if_block2.c();
32736
32923
  transition_in(if_block2, 1);
32737
32924
  if_block2.m(t5.parentNode, t5);
@@ -32834,7 +33021,7 @@ function create_fragment$2(ctx) {
32834
33021
  const form_1_changes = {};
32835
33022
  if (dirty & /*form*/ 2) form_1_changes.onSubmitWhenValid = /*form*/ ctx[1]?.submit;
32836
33023
 
32837
- if (dirty & /*$$scope, linkWrapper, journey, metadata, step, $style, alertNeedsFocus, formMessageKey, form*/ 131582) {
33024
+ if (dirty & /*$$scope, linkWrapper, journey, metadata, step, $styleStore, alertNeedsFocus, formMessageKey, form*/ 131582) {
32838
33025
  form_1_changes.$$scope = { dirty, ctx };
32839
33026
  }
32840
33027
 
@@ -32862,8 +33049,8 @@ function create_fragment$2(ctx) {
32862
33049
  }
32863
33050
 
32864
33051
  function instance$2($$self, $$props, $$invalidate) {
32865
- let $style;
32866
- component_subscribe($$self, style, $$value => $$invalidate(8, $style = $$value));
33052
+ let $styleStore;
33053
+ component_subscribe($$self, styleStore, $$value => $$invalidate(8, $styleStore = $$value));
32867
33054
  let { form } = $$props;
32868
33055
  let { formEl = null } = $$props;
32869
33056
  let { journey } = $$props;
@@ -32933,7 +33120,7 @@ function instance$2($$self, $$props, $$invalidate) {
32933
33120
  alertNeedsFocus,
32934
33121
  formMessageKey,
32935
33122
  linkWrapper,
32936
- $style,
33123
+ $styleStore,
32937
33124
  determineSubmission,
32938
33125
  click_handler,
32939
33126
  click_handler_1,
@@ -32981,7 +33168,7 @@ function mapStepToStage(currentStep) {
32981
33168
 
32982
33169
  /* src/lib/journey/journey.svelte generated by Svelte v3.55.1 */
32983
33170
 
32984
- function create_else_block(ctx) {
33171
+ function create_else_block$1(ctx) {
32985
33172
  let alert;
32986
33173
  let t;
32987
33174
  let button;
@@ -33096,7 +33283,7 @@ function create_if_block_3(ctx) {
33096
33283
  }
33097
33284
 
33098
33285
  // (26:0) {#if !$journeyStore?.completed}
33099
- function create_if_block(ctx) {
33286
+ function create_if_block$1(ctx) {
33100
33287
  let current_block_type_index;
33101
33288
  let if_block;
33102
33289
  let if_block_anchor;
@@ -33411,7 +33598,7 @@ function create_fragment$1(ctx) {
33411
33598
  let if_block;
33412
33599
  let if_block_anchor;
33413
33600
  let current;
33414
- const if_block_creators = [create_if_block, create_if_block_3, create_else_block];
33601
+ const if_block_creators = [create_if_block$1, create_if_block_3, create_else_block$1];
33415
33602
  const if_blocks = [];
33416
33603
 
33417
33604
  function select_block_type(ctx, dirty) {
@@ -33537,139 +33724,21 @@ class Journey extends SvelteComponent {
33537
33724
  }
33538
33725
  }
33539
33726
 
33540
- function initialize$1(initOptions) {
33541
- const { set, subscribe } = writable({
33542
- completed: false,
33543
- error: null,
33544
- loading: false,
33545
- successful: false,
33546
- response: null,
33547
- });
33548
- async function get(getOptions) {
33549
- /**
33550
- * Create an options object with getOptions overriding anything from initOptions
33551
- * TODO: Does this object merge need to be more granular?
33552
- */
33553
- const options = {
33554
- ...{ query: { prompt: 'none' } },
33555
- ...initOptions,
33556
- ...getOptions,
33557
- };
33558
- let tokens;
33559
- try {
33560
- tokens = await TokenManager$1.getTokens(options);
33561
- }
33562
- catch (err) {
33563
- console.error(`Get tokens | ${err}`);
33564
- if (err instanceof Error) {
33565
- set({
33566
- completed: true,
33567
- error: {
33568
- message: err.message,
33569
- },
33570
- loading: false,
33571
- successful: false,
33572
- response: null,
33573
- });
33574
- }
33575
- return;
33576
- }
33577
- set({
33578
- completed: true,
33579
- error: null,
33580
- loading: false,
33581
- successful: true,
33582
- response: tokens,
33583
- });
33584
- }
33585
- function reset() {
33586
- set({
33587
- completed: false,
33588
- error: null,
33589
- loading: false,
33590
- successful: false,
33591
- response: null,
33592
- });
33593
- }
33594
- return {
33595
- get,
33596
- reset,
33597
- subscribe,
33598
- };
33599
- }
33600
-
33601
- function initialize(initOptions) {
33602
- const { set, subscribe } = writable({
33603
- completed: false,
33604
- error: null,
33605
- loading: false,
33606
- successful: false,
33607
- response: null,
33608
- });
33609
- async function get(getOptions) {
33610
- /**
33611
- * Create an options object with getOptions overriding anything from initOptions
33612
- * TODO: Does this object merge need to be more granular?
33613
- */
33614
- const options = {
33615
- ...initOptions,
33616
- ...getOptions,
33617
- };
33618
- try {
33619
- const user = await UserManager.getCurrentUser(options);
33620
- set({
33621
- completed: true,
33622
- error: null,
33623
- loading: false,
33624
- successful: true,
33625
- response: user,
33626
- });
33627
- }
33628
- catch (err) {
33629
- console.error(`Get current user | ${err}`);
33630
- if (err instanceof Error) {
33631
- set({
33632
- completed: true,
33633
- error: {
33634
- message: err.message,
33635
- },
33636
- loading: false,
33637
- successful: false,
33638
- response: null,
33639
- });
33640
- }
33641
- }
33642
- }
33643
- function reset() {
33644
- set({
33645
- completed: false,
33646
- error: null,
33647
- loading: false,
33648
- successful: false,
33649
- response: null,
33650
- });
33651
- }
33652
- return {
33653
- get,
33654
- reset,
33655
- subscribe,
33656
- };
33657
- }
33727
+ /* src/lib/widget/index.svelte generated by Svelte v3.55.1 */
33658
33728
 
33659
- /* src/lib/widget/modal.svelte generated by Svelte v3.55.1 */
33660
-
33661
- function create_default_slot(ctx) {
33729
+ function create_else_block(ctx) {
33730
+ let div;
33662
33731
  let journey_1;
33663
33732
  let updating_formEl;
33664
33733
  let current;
33665
33734
 
33666
- function journey_1_formEl_binding(value) {
33667
- /*journey_1_formEl_binding*/ ctx[9](value);
33735
+ function journey_1_formEl_binding_1(value) {
33736
+ /*journey_1_formEl_binding_1*/ ctx[9](value);
33668
33737
  }
33669
33738
 
33670
33739
  let journey_1_props = {
33671
- displayIcon: /*style*/ ctx[0]?.stage?.icon || !/*style*/ ctx[0]?.logo,
33672
- journeyStore: api.getJourneyStore()
33740
+ displayIcon: /*$styleStore*/ ctx[4]?.stage?.icon ?? true,
33741
+ journeyStore: /*journeyStore*/ ctx[5]
33673
33742
  };
33674
33743
 
33675
33744
  if (/*formEl*/ ctx[3] !== void 0) {
@@ -33677,19 +33746,22 @@ function create_default_slot(ctx) {
33677
33746
  }
33678
33747
 
33679
33748
  journey_1 = new Journey({ props: journey_1_props });
33680
- binding_callbacks.push(() => bind(journey_1, 'formEl', journey_1_formEl_binding));
33749
+ binding_callbacks.push(() => bind(journey_1, 'formEl', journey_1_formEl_binding_1));
33681
33750
 
33682
33751
  return {
33683
33752
  c() {
33753
+ div = element("div");
33684
33754
  create_component(journey_1.$$.fragment);
33755
+ attr(div, "class", "fr_widget-root");
33685
33756
  },
33686
33757
  m(target, anchor) {
33687
- mount_component(journey_1, target, anchor);
33758
+ insert(target, div, anchor);
33759
+ mount_component(journey_1, div, null);
33688
33760
  current = true;
33689
33761
  },
33690
33762
  p(ctx, dirty) {
33691
33763
  const journey_1_changes = {};
33692
- if (dirty & /*style*/ 1) journey_1_changes.displayIcon = /*style*/ ctx[0]?.stage?.icon || !/*style*/ ctx[0]?.logo;
33764
+ if (dirty & /*$styleStore*/ 16) journey_1_changes.displayIcon = /*$styleStore*/ ctx[4]?.stage?.icon ?? true;
33693
33765
 
33694
33766
  if (!updating_formEl && dirty & /*formEl*/ 8) {
33695
33767
  updating_formEl = true;
@@ -33709,36 +33781,37 @@ function create_default_slot(ctx) {
33709
33781
  current = false;
33710
33782
  },
33711
33783
  d(detaching) {
33712
- destroy_component(journey_1, detaching);
33784
+ if (detaching) detach(div);
33785
+ destroy_component(journey_1);
33713
33786
  }
33714
33787
  };
33715
33788
  }
33716
33789
 
33717
- function create_fragment(ctx) {
33790
+ // (28:0) {#if type === 'modal'}
33791
+ function create_if_block(ctx) {
33718
33792
  let div;
33719
33793
  let dialog;
33720
33794
  let updating_dialogEl;
33721
33795
  let current;
33722
33796
 
33723
33797
  function dialog_dialogEl_binding(value) {
33724
- /*dialog_dialogEl_binding*/ ctx[10](value);
33798
+ /*dialog_dialogEl_binding*/ ctx[7](value);
33725
33799
  }
33726
33800
 
33727
33801
  let dialog_props = {
33728
- closeCallback: /*_closeCallback*/ ctx[4],
33729
33802
  dialogId: "sampleDialog",
33730
- withHeader: /*style*/ ctx[0]?.sections?.header,
33803
+ withHeader: /*$styleStore*/ ctx[4]?.sections?.header,
33731
33804
  $$slots: { default: [create_default_slot] },
33732
33805
  $$scope: { ctx }
33733
33806
  };
33734
33807
 
33735
- if (/*_dialogEl*/ ctx[2] !== void 0) {
33736
- dialog_props.dialogEl = /*_dialogEl*/ ctx[2];
33808
+ if (/*dialogEl*/ ctx[2] !== void 0) {
33809
+ dialog_props.dialogEl = /*dialogEl*/ ctx[2];
33737
33810
  }
33738
33811
 
33739
33812
  dialog = new Dialog({ props: dialog_props });
33740
33813
  binding_callbacks.push(() => bind(dialog, 'dialogEl', dialog_dialogEl_binding));
33741
- /*dialog_binding*/ ctx[11](dialog);
33814
+ /*dialog_binding*/ ctx[8](dialog);
33742
33815
 
33743
33816
  return {
33744
33817
  c() {
@@ -33751,17 +33824,17 @@ function create_fragment(ctx) {
33751
33824
  mount_component(dialog, div, null);
33752
33825
  current = true;
33753
33826
  },
33754
- p(ctx, [dirty]) {
33827
+ p(ctx, dirty) {
33755
33828
  const dialog_changes = {};
33756
- if (dirty & /*style*/ 1) dialog_changes.withHeader = /*style*/ ctx[0]?.sections?.header;
33829
+ if (dirty & /*$styleStore*/ 16) dialog_changes.withHeader = /*$styleStore*/ ctx[4]?.sections?.header;
33757
33830
 
33758
- if (dirty & /*$$scope, style, formEl*/ 8201) {
33831
+ if (dirty & /*$$scope, $styleStore, formEl*/ 2072) {
33759
33832
  dialog_changes.$$scope = { dirty, ctx };
33760
33833
  }
33761
33834
 
33762
- if (!updating_dialogEl && dirty & /*_dialogEl*/ 4) {
33835
+ if (!updating_dialogEl && dirty & /*dialogEl*/ 4) {
33763
33836
  updating_dialogEl = true;
33764
- dialog_changes.dialogEl = /*_dialogEl*/ ctx[2];
33837
+ dialog_changes.dialogEl = /*dialogEl*/ ctx[2];
33765
33838
  add_flush_callback(() => updating_dialogEl = false);
33766
33839
  }
33767
33840
 
@@ -33778,121 +33851,160 @@ function create_fragment(ctx) {
33778
33851
  },
33779
33852
  d(detaching) {
33780
33853
  if (detaching) detach(div);
33781
- /*dialog_binding*/ ctx[11](null);
33854
+ /*dialog_binding*/ ctx[8](null);
33782
33855
  destroy_component(dialog);
33783
33856
  }
33784
33857
  };
33785
33858
  }
33786
33859
 
33787
- let dialogComp;
33788
- let dialogEl;
33789
- let callMounted;
33790
- let closeCallback;
33791
-
33792
- const api = widgetApiFactory({
33793
- close(args) {
33794
- dialogComp.closeDialog(args);
33795
- },
33796
- onClose(fn) {
33797
- closeCallback = args => fn(args);
33798
- },
33799
- onMount(fn) {
33800
- callMounted = (dialog, form) => fn(dialog, form);
33801
- },
33802
- open(options, forceRestart) {
33803
- // If journey does not have a step, start the journey
33804
- if (!get_store_value(api.getJourneyStore()).step || forceRestart) {
33805
- journey.start(options);
33806
- }
33860
+ // (30:4) <Dialog bind:dialogEl bind:this={dialogComp} dialogId="sampleDialog" withHeader={$styleStore?.sections?.header} >
33861
+ function create_default_slot(ctx) {
33862
+ let journey_1;
33863
+ let updating_formEl;
33864
+ let current;
33807
33865
 
33808
- dialogEl.showModal();
33866
+ function journey_1_formEl_binding(value) {
33867
+ /*journey_1_formEl_binding*/ ctx[6](value);
33809
33868
  }
33810
- });
33811
33869
 
33812
- const configuration = api.configuration;
33813
- const journey = api.journey;
33814
- const modal = api.modal;
33815
- const request = api.request;
33816
- const user = api.user;
33870
+ let journey_1_props = {
33871
+ displayIcon: /*$styleStore*/ ctx[4]?.stage?.icon ?? !/*$styleStore*/ ctx[4]?.logo,
33872
+ journeyStore: /*journeyStore*/ ctx[5]
33873
+ };
33817
33874
 
33818
- function instance($$self, $$props, $$invalidate) {
33819
- let { config = undefined } = $$props;
33820
- let { content = undefined } = $$props;
33821
- let { journeys = undefined } = $$props;
33822
- let { links = undefined } = $$props;
33823
- let { style = undefined } = $$props;
33824
- const dispatch = createEventDispatcher();
33875
+ if (/*formEl*/ ctx[3] !== void 0) {
33876
+ journey_1_props.formEl = /*formEl*/ ctx[3];
33877
+ }
33825
33878
 
33826
- // Reference to the closeCallback from the above module context
33827
- let _closeCallback = closeCallback;
33879
+ journey_1 = new Journey({ props: journey_1_props });
33880
+ binding_callbacks.push(() => bind(journey_1, 'formEl', journey_1_formEl_binding));
33828
33881
 
33829
- // Variables that reference the Svelte component and the DOM element
33830
- // Variables with `_` reference points to the same variables from the `context="module"`
33831
- let _dialogComp;
33882
+ return {
33883
+ c() {
33884
+ create_component(journey_1.$$.fragment);
33885
+ },
33886
+ m(target, anchor) {
33887
+ mount_component(journey_1, target, anchor);
33888
+ current = true;
33889
+ },
33890
+ p(ctx, dirty) {
33891
+ const journey_1_changes = {};
33892
+ if (dirty & /*$styleStore*/ 16) journey_1_changes.displayIcon = /*$styleStore*/ ctx[4]?.stage?.icon ?? !/*$styleStore*/ ctx[4]?.logo;
33832
33893
 
33833
- let _dialogEl;
33894
+ if (!updating_formEl && dirty & /*formEl*/ 8) {
33895
+ updating_formEl = true;
33896
+ journey_1_changes.formEl = /*formEl*/ ctx[3];
33897
+ add_flush_callback(() => updating_formEl = false);
33898
+ }
33834
33899
 
33835
- // The single reference to the `form` DOM element
33836
- let formEl;
33900
+ journey_1.$set(journey_1_changes);
33901
+ },
33902
+ i(local) {
33903
+ if (current) return;
33904
+ transition_in(journey_1.$$.fragment, local);
33905
+ current = true;
33906
+ },
33907
+ o(local) {
33908
+ transition_out(journey_1.$$.fragment, local);
33909
+ current = false;
33910
+ },
33911
+ d(detaching) {
33912
+ destroy_component(journey_1, detaching);
33913
+ }
33914
+ };
33915
+ }
33837
33916
 
33838
- if (config) {
33839
- // Set base config to SDK
33840
- // TODO: Move to a shared utility
33841
- configure({
33842
- // Set some basics by default
33843
- ...{
33844
- // TODO: Could this be a default OAuth client provided by Platform UI OOTB?
33845
- clientId: 'WebLoginWidgetClient',
33846
- // TODO: If a realmPath is not provided, should we call the realm endpoint and detect a likely default?
33847
- // https://backstage.forgerock.com/docs/am/7/setup-guide/sec-rest-realm-rest.html#rest-api-list-realm
33848
- realmPath: 'alpha',
33849
- // TODO: Once we move to SSR, this default should be more intelligent
33850
- redirectUri: typeof window === 'object'
33851
- ? window.location.href
33852
- : 'https://localhost:3000/callback',
33853
- scope: 'openid email'
33854
- },
33855
- // Let user provided config override defaults
33856
- ...config,
33857
- // Force 'legacy' to remove confusion
33858
- ...{ support: 'legacy' }
33859
- });
33917
+ function create_fragment(ctx) {
33918
+ let current_block_type_index;
33919
+ let if_block;
33920
+ let if_block_anchor;
33921
+ let current;
33922
+ const if_block_creators = [create_if_block, create_else_block];
33923
+ const if_blocks = [];
33924
+
33925
+ function select_block_type(ctx, dirty) {
33926
+ if (/*type*/ ctx[0] === 'modal') return 0;
33927
+ return 1;
33860
33928
  }
33861
33929
 
33862
- /**
33863
- * Initialize the stores and ensure both variables point to the same reference.
33864
- * Variables with _ are the reactive version of the original variable from above.
33865
- */
33866
- api.setJourneyStore(initialize$4(config));
33930
+ current_block_type_index = select_block_type(ctx);
33931
+ if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx);
33867
33932
 
33868
- api.setOAuthStore(initialize$1(config));
33869
- api.setUserStore(initialize(config));
33870
- initialize$6(content);
33871
- initialize$3(journeys);
33872
- initialize$2(links);
33873
- initialize$5(style);
33933
+ return {
33934
+ c() {
33935
+ if_block.c();
33936
+ if_block_anchor = empty();
33937
+ },
33938
+ m(target, anchor) {
33939
+ if_blocks[current_block_type_index].m(target, anchor);
33940
+ insert(target, if_block_anchor, anchor);
33941
+ current = true;
33942
+ },
33943
+ p(ctx, [dirty]) {
33944
+ let previous_block_index = current_block_type_index;
33945
+ current_block_type_index = select_block_type(ctx);
33874
33946
 
33875
- onMount(() => {
33876
- dialogComp = _dialogComp;
33877
- dialogEl = _dialogEl;
33947
+ if (current_block_type_index === previous_block_index) {
33948
+ if_blocks[current_block_type_index].p(ctx, dirty);
33949
+ } else {
33950
+ group_outros();
33878
33951
 
33879
- /**
33880
- * Call mounted event for Singleton users
33881
- */
33882
- callMounted && callMounted(_dialogEl, formEl);
33952
+ transition_out(if_blocks[previous_block_index], 1, 1, () => {
33953
+ if_blocks[previous_block_index] = null;
33954
+ });
33883
33955
 
33884
- /**
33885
- * Call mounted event for Instance users
33886
- * NOTE: needs to be wrapped in setTimeout. Asked in Svelte Discord
33887
- * if this is an issue or expected. Answer: Object instantiation seems
33888
- * to be synchronous, so this doesn't get called without `setTimeout`.
33889
- */
33890
- setTimeout(
33891
- () => {
33892
- dispatch('modal-mount', 'Modal mounted');
33893
- },
33894
- 0
33895
- );
33956
+ check_outros();
33957
+ if_block = if_blocks[current_block_type_index];
33958
+
33959
+ if (!if_block) {
33960
+ if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx);
33961
+ if_block.c();
33962
+ } else {
33963
+ if_block.p(ctx, dirty);
33964
+ }
33965
+
33966
+ transition_in(if_block, 1);
33967
+ if_block.m(if_block_anchor.parentNode, if_block_anchor);
33968
+ }
33969
+ },
33970
+ i(local) {
33971
+ if (current) return;
33972
+ transition_in(if_block);
33973
+ current = true;
33974
+ },
33975
+ o(local) {
33976
+ transition_out(if_block);
33977
+ current = false;
33978
+ },
33979
+ d(detaching) {
33980
+ if_blocks[current_block_type_index].d(detaching);
33981
+ if (detaching) detach(if_block_anchor);
33982
+ }
33983
+ };
33984
+ }
33985
+
33986
+ const api = widgetApiFactory(componentApi());
33987
+ const configuration = api.configuration;
33988
+ const journey = api.journey;
33989
+ const component = componentApi;
33990
+ const request = api.request;
33991
+ const user = api.user;
33992
+
33993
+ function instance($$self, $$props, $$invalidate) {
33994
+ let $styleStore;
33995
+ component_subscribe($$self, styleStore, $$value => $$invalidate(4, $styleStore = $$value));
33996
+ let { type = 'modal' } = $$props;
33997
+ const componentEvents = componentApi();
33998
+ const { journeyStore } = api.getStores();
33999
+
34000
+ // Variables that reference the Svelte component and the DOM elements
34001
+ let dialogComp;
34002
+
34003
+ let dialogEl;
34004
+ let formEl;
34005
+
34006
+ onMount(() => {
34007
+ componentEvents.mount(dialogComp, dialogEl);
33896
34008
  });
33897
34009
 
33898
34010
  function journey_1_formEl_binding(value) {
@@ -33901,59 +34013,51 @@ function instance($$self, $$props, $$invalidate) {
33901
34013
  }
33902
34014
 
33903
34015
  function dialog_dialogEl_binding(value) {
33904
- _dialogEl = value;
33905
- $$invalidate(2, _dialogEl);
34016
+ dialogEl = value;
34017
+ $$invalidate(2, dialogEl);
33906
34018
  }
33907
34019
 
33908
34020
  function dialog_binding($$value) {
33909
34021
  binding_callbacks[$$value ? 'unshift' : 'push'](() => {
33910
- _dialogComp = $$value;
33911
- $$invalidate(1, _dialogComp);
34022
+ dialogComp = $$value;
34023
+ $$invalidate(1, dialogComp);
33912
34024
  });
33913
34025
  }
33914
34026
 
34027
+ function journey_1_formEl_binding_1(value) {
34028
+ formEl = value;
34029
+ $$invalidate(3, formEl);
34030
+ }
34031
+
33915
34032
  $$self.$$set = $$props => {
33916
- if ('config' in $$props) $$invalidate(5, config = $$props.config);
33917
- if ('content' in $$props) $$invalidate(6, content = $$props.content);
33918
- if ('journeys' in $$props) $$invalidate(7, journeys = $$props.journeys);
33919
- if ('links' in $$props) $$invalidate(8, links = $$props.links);
33920
- if ('style' in $$props) $$invalidate(0, style = $$props.style);
34033
+ if ('type' in $$props) $$invalidate(0, type = $$props.type);
33921
34034
  };
33922
34035
 
33923
34036
  return [
33924
- style,
33925
- _dialogComp,
33926
- _dialogEl,
34037
+ type,
34038
+ dialogComp,
34039
+ dialogEl,
33927
34040
  formEl,
33928
- _closeCallback,
33929
- config,
33930
- content,
33931
- journeys,
33932
- links,
34041
+ $styleStore,
34042
+ journeyStore,
33933
34043
  journey_1_formEl_binding,
33934
34044
  dialog_dialogEl_binding,
33935
- dialog_binding
34045
+ dialog_binding,
34046
+ journey_1_formEl_binding_1
33936
34047
  ];
33937
34048
  }
33938
34049
 
33939
- class Modal extends SvelteComponent {
34050
+ class Widget extends SvelteComponent {
33940
34051
  constructor(options) {
33941
34052
  super();
33942
-
33943
- init(this, options, instance, create_fragment, safe_not_equal, {
33944
- config: 5,
33945
- content: 6,
33946
- journeys: 7,
33947
- links: 8,
33948
- style: 0
33949
- });
34053
+ init(this, options, instance, create_fragment, safe_not_equal, { type: 0 });
33950
34054
  }
33951
34055
  }
33952
34056
 
34057
+ exports.component = component;
33953
34058
  exports.configuration = configuration;
33954
- exports.default = Modal;
34059
+ exports.default = Widget;
33955
34060
  exports.journey = journey;
33956
- exports.modal = modal;
33957
34061
  exports.request = request;
33958
34062
  exports.user = user;
33959
- //# sourceMappingURL=modal.cjs.map
34063
+ //# sourceMappingURL=index.cjs.map