@descope/web-component 4.5.1 → 4.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/dist/cjs/debugger-wc.js.map +1 -1
  2. package/dist/cjs/descope-wc/BaseDescopeWc.js +1 -1
  3. package/dist/cjs/descope-wc/BaseDescopeWc.js.map +1 -1
  4. package/dist/cjs/descope-wc/DescopeWc.js +1 -1
  5. package/dist/cjs/descope-wc/DescopeWc.js.map +1 -1
  6. package/dist/cjs/helpers/abTestingKey.js.map +1 -1
  7. package/dist/cjs/helpers/conditions.js.map +1 -1
  8. package/dist/cjs/helpers/flowInputs.js.map +1 -1
  9. package/dist/cjs/helpers/helpers.js.map +1 -1
  10. package/dist/cjs/helpers/lastAuth.js.map +1 -1
  11. package/dist/cjs/helpers/oidcSession.js.map +1 -1
  12. package/dist/cjs/helpers/positionHelpers.js.map +1 -1
  13. package/dist/cjs/helpers/realtime-conditions/applier.js.map +1 -1
  14. package/dist/cjs/helpers/realtime-conditions/evaluator.js.map +1 -1
  15. package/dist/cjs/helpers/state.js.map +1 -1
  16. package/dist/cjs/helpers/storage.js.map +1 -1
  17. package/dist/cjs/helpers/templates.js.map +1 -1
  18. package/dist/cjs/helpers/webauthn.js.map +1 -1
  19. package/dist/cjs/mixins/componentConditionsMixin.js.map +1 -1
  20. package/dist/cjs/mixins/duplicateFlowWarningMixin.js.map +1 -1
  21. package/dist/cjs/mixins/formMountMixin.js.map +1 -1
  22. package/dist/cjs/mixins/passwordManagerMixin.js.map +1 -1
  23. package/dist/cjs/mixins/validationTrackingMixin.js.map +1 -1
  24. package/dist/cjs/types.js.map +1 -1
  25. package/dist/esm/constants/customScreens.js.map +1 -1
  26. package/dist/esm/debugger-wc.js.map +1 -1
  27. package/dist/esm/descope-wc/BaseDescopeWc.js +1 -1
  28. package/dist/esm/descope-wc/BaseDescopeWc.js.map +1 -1
  29. package/dist/esm/descope-wc/DescopeWc.js +1 -1
  30. package/dist/esm/descope-wc/DescopeWc.js.map +1 -1
  31. package/dist/esm/helpers/abTestingKey.js.map +1 -1
  32. package/dist/esm/helpers/conditions.js.map +1 -1
  33. package/dist/esm/helpers/flowInputs.js.map +1 -1
  34. package/dist/esm/helpers/helpers.js +1 -1
  35. package/dist/esm/helpers/helpers.js.map +1 -1
  36. package/dist/esm/helpers/lastAuth.js +1 -1
  37. package/dist/esm/helpers/lastAuth.js.map +1 -1
  38. package/dist/esm/helpers/oidcSession.js +1 -1
  39. package/dist/esm/helpers/oidcSession.js.map +1 -1
  40. package/dist/esm/helpers/positionHelpers.js.map +1 -1
  41. package/dist/esm/helpers/realtime-conditions/applier.js.map +1 -1
  42. package/dist/esm/helpers/realtime-conditions/evaluator.js.map +1 -1
  43. package/dist/esm/helpers/state.js.map +1 -1
  44. package/dist/esm/helpers/storage.js.map +1 -1
  45. package/dist/esm/helpers/templates.js.map +1 -1
  46. package/dist/esm/helpers/webauthn.js.map +1 -1
  47. package/dist/esm/mixins/componentConditionsMixin.js.map +1 -1
  48. package/dist/esm/mixins/duplicateFlowWarningMixin.js.map +1 -1
  49. package/dist/esm/mixins/formMountMixin.js.map +1 -1
  50. package/dist/esm/mixins/passwordManagerMixin.js.map +1 -1
  51. package/dist/esm/mixins/validationTrackingMixin.js.map +1 -1
  52. package/dist/esm/types.js.map +1 -1
  53. package/dist/index.js +2 -2
  54. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"debugger-wc.js","sources":["../../src/lib/debugger-wc.ts"],"sourcesContent":["/* eslint-disable no-param-reassign */\nimport { compose, escapeHtml } from '@descope/sdk-helpers';\nimport { injectStyleMixin } from '@descope/sdk-mixins/inject-style-mixin';\nimport {\n addOnResize,\n dragElement,\n limitCoordinateToScreenBoundaries,\n State,\n} from './helpers';\nimport { DebuggerMessage } from './types';\n\nconst INITIAL_POS_THRESHOLD = 32;\nconst INITIAL_WIDTH = 300;\nconst INITIAL_HEIGHT = 200;\nconst MIN_SIZE = 200;\n\nconst template = document.createElement('template');\ntemplate.innerHTML = `\n<div class=\"debugger\">\n <div class=\"header\">\n <span>Debugger messages</span>\n </div>\n <div class=\"content\">\n <div class=\"empty-state\">\n No errors detected 👀\n </div>\n </div>\n</div>\n`;\n\nconst icon = `<svg width=\"18\" height=\"18\" viewBox=\"0 0 18 18\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n<path d=\"M5.99984 13.167L8.99984 10.167L11.9998 13.167L13.1665 12.0003L10.1665 9.00033L13.1665 6.00033L11.9998 4.83366L8.99984 7.83366L5.99984 4.83366L4.83317 6.00033L7.83317 9.00033L4.83317 12.0003L5.99984 13.167ZM8.99984 17.3337C7.84706 17.3337 6.76373 17.1148 5.74984 16.677C4.73595 16.2398 3.854 15.6462 3.104 14.8962C2.354 14.1462 1.76039 13.2642 1.32317 12.2503C0.885393 11.2364 0.666504 10.1531 0.666504 9.00033C0.666504 7.84755 0.885393 6.76421 1.32317 5.75033C1.76039 4.73644 2.354 3.85449 3.104 3.10449C3.854 2.35449 4.73595 1.7606 5.74984 1.32283C6.76373 0.885603 7.84706 0.666992 8.99984 0.666992C10.1526 0.666992 11.2359 0.885603 12.2498 1.32283C13.2637 1.7606 14.1457 2.35449 14.8957 3.10449C15.6457 3.85449 16.2393 4.73644 16.6765 5.75033C17.1143 6.76421 17.3332 7.84755 17.3332 9.00033C17.3332 10.1531 17.1143 11.2364 16.6765 12.2503C16.2393 13.2642 15.6457 14.1462 14.8957 14.8962C14.1457 15.6462 13.2637 16.2398 12.2498 16.677C11.2359 17.1148 10.1526 17.3337 8.99984 17.3337ZM8.99984 15.667C10.8609 15.667 12.4373 15.0212 13.729 13.7295C15.0207 12.4378 15.6665 10.8614 15.6665 9.00033C15.6665 7.13921 15.0207 5.56283 13.729 4.27116C12.4373 2.97949 10.8609 2.33366 8.99984 2.33366C7.13873 2.33366 5.56234 2.97949 4.27067 4.27116C2.979 5.56283 2.33317 7.13921 2.33317 9.00033C2.33317 10.8614 2.979 12.4378 4.27067 13.7295C5.56234 15.0212 7.13873 15.667 8.99984 15.667Z\" fill=\"#ED404A\"/>\n</svg>\n`;\n\nconst style = `\n .debugger {\n all: initial;\n width: ${INITIAL_WIDTH}px;\n height: ${INITIAL_HEIGHT}px;\n background-color: #FAFAFA;\n position: fixed;\n font-family: \"Helvetica Neue\", sans-serif;\n box-shadow: rgba(0, 0, 0, 0.1) 0px 5px 10px;\n border-radius: 8px;\n overflow: hidden;\n border: 1px solid lightgrey;\n pointer-events: initial;\n display: flex;\n flex-direction: column;\n min-width: ${MIN_SIZE}px;\n max-width: 600px;\n max-height: calc(100% - ${INITIAL_POS_THRESHOLD * 2}px);\n min-height: ${MIN_SIZE}px;\n resize: both;\n }\n\n .header {\n padding: 8px 16px;\n display: flex;\n align-items: center;\n background-color: #EEEEEE;\n cursor: move;\n border-bottom: 1px solid #e0e0e0;\n }\n\n .content {\n font-size: 14px;\n flex-grow: 1;\n overflow: auto;\n }\n\n .msg {\n border-bottom: 1px solid lightgrey;\n padding: 8px 16px;\n display: flex;\n gap: 5px;\n background-color: #FAFAFA;\n }\n\n .msg.collapsible {\n cursor: pointer;\n }\n\n .empty-state {\n padding: 8px 16px;\n background-color: #FAFAFA;\n }\n\n\n .msg.collapsible:not(.collapsed) {\n background-color: #F5F5F5;\n }\n\n .msg_title {\n padding-bottom: 5px;\n display: flex;\n gap: 8px;\n font-weight: 500;\n }\n\n .msg svg {\n padding: 1px;\n flex-shrink: 0;\n margin-top: -2px;\n }\n\n .msg_content {\n overflow: hidden;\n flex-grow: 1;\n margin-right:5px;\n }\n\n .msg_desc {\n color: #646464;\n cursor: initial;\n word-wrap: break-word;\n }\n\n .msg.collapsed .msg_desc {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n\n .msg.collapsible.collapsed .chevron {\n transform: rotate(-45deg) translateX(-2px);\n }\n\n .msg.collapsible .chevron {\n content: \"\";\n width:6px;\n height:6px;\n border-bottom: 2px solid grey;\n border-right: 2px solid grey;\n transform: rotate(45deg) translateX(-1px);\n margin: 5px;\n flex-shrink:0;\n }\n`;\n\ntype MessagesState = { messages: DebuggerMessage[] };\n\nconst BaseClass = compose(injectStyleMixin)(HTMLElement);\n\nclass Debugger extends BaseClass {\n #messagesState = new State<MessagesState>({ messages: [] });\n\n #rootEle: HTMLDivElement;\n\n #contentEle: HTMLDivElement;\n\n #headerEle: HTMLDivElement;\n\n #eventsCbRefs = {\n resize: this.#onWindowResize.bind(this),\n };\n\n constructor() {\n super();\n\n this.attachShadow({ mode: 'open' });\n this.shadowRoot.appendChild(template.content.cloneNode(true));\n\n this.#rootEle = this.shadowRoot.querySelector<HTMLDivElement>('.debugger');\n this.#contentEle = this.#rootEle.querySelector<HTMLDivElement>('.content');\n this.#headerEle = this.#rootEle.querySelector<HTMLDivElement>('.header');\n\n this.#initStyle();\n }\n\n #initStyle() {\n this.injectStyle(style);\n\n this.#rootEle.style.top = `${INITIAL_POS_THRESHOLD}px`;\n this.#rootEle.style.left = `${\n window.innerWidth - INITIAL_WIDTH - INITIAL_POS_THRESHOLD\n }px`;\n }\n\n updateData(data: DebuggerMessage | DebuggerMessage[]) {\n this.#messagesState.update((state) => ({\n messages: state.messages.concat(data),\n }));\n }\n\n #onNewMessages(data: MessagesState) {\n this.#renderMessages(data);\n this.#setCollapsibleMessages();\n }\n\n #renderMessages(data: MessagesState) {\n this.#contentEle.innerHTML = data.messages\n .map(\n (message) => `\n <div class=\"msg\">\n ${icon}\n <div class=\"msg_content\">\n <div class=\"msg_title\">\n ${escapeHtml(message.title)}\n </div>\n <div class=\"msg_desc\">\n ${escapeHtml(message.description)}\n </div>\n </div>\n <div class=\"chevron\"></div>\n </div>\n `,\n )\n .join('');\n }\n\n #setCollapsibleMessages() {\n this.#contentEle.querySelectorAll('.msg').forEach((ele: HTMLElement) => {\n const descEle = ele.querySelector('.msg_desc');\n const lineHeight = 20;\n const isScroll = descEle.scrollWidth > descEle.clientWidth;\n const isMultiLine = descEle.clientHeight > lineHeight;\n const isCollapsible = isScroll || isMultiLine;\n\n if (isCollapsible) {\n ele.classList.add('collapsible');\n ele.onclick = (e: MouseEvent) => {\n // message description should not toggle collapse\n if (!(e.target as HTMLElement).classList.contains('msg_desc')) {\n ele.classList.toggle('collapsed');\n }\n };\n } else {\n ele.classList.remove('collapsible');\n ele.onclick = null;\n }\n });\n }\n\n #onWindowResize() {\n // when window is resizing we want to make sure debugger is still visible\n const [left, top] = limitCoordinateToScreenBoundaries(\n this.#rootEle,\n Number.parseInt(this.#rootEle.style.left, 10),\n Number.parseInt(this.#rootEle.style.top, 10),\n { top: 'all', bottom: 100, left: 100, right: 100 },\n );\n this.#rootEle.style.top = `${top}px`;\n this.#rootEle.style.left = `${left}px`;\n }\n\n async init() {\n super.init?.();\n dragElement(this.#rootEle, this.#headerEle, {\n top: 'all',\n bottom: 100,\n left: 100,\n right: 100,\n });\n\n window.addEventListener('resize', this.#eventsCbRefs.resize);\n\n addOnResize(this.#rootEle);\n this.#rootEle.onresize = this.#setCollapsibleMessages.bind(this);\n\n this.#messagesState.subscribe(this.#onNewMessages.bind(this));\n }\n\n disconnectedCallback() {\n this.#messagesState.unsubscribeAll();\n window.removeEventListener('resize', this.#eventsCbRefs.resize);\n }\n}\n\nif (!customElements.get('descope-debugger')) {\n customElements.define('descope-debugger', Debugger);\n}\nexport default Debugger;\n"],"names":["template","document","createElement","innerHTML","BaseClass","compose","injectStyleMixin","HTMLElement","Debugger","constructor","super","_Debugger_messagesState","set","this","State","messages","_Debugger_rootEle","_Debugger_contentEle","_Debugger_headerEle","_Debugger_eventsCbRefs","resize","__classPrivateFieldGet","_Debugger_instances","_Debugger_onWindowResize","bind","attachShadow","mode","shadowRoot","appendChild","content","cloneNode","__classPrivateFieldSet","querySelector","_Debugger_initStyle","call","updateData","data","update","state","concat","init","_a","_super","dragElement","top","bottom","left","right","window","addEventListener","addOnResize","onresize","_Debugger_setCollapsibleMessages","subscribe","_Debugger_onNewMessages","disconnectedCallback","unsubscribeAll","removeEventListener","injectStyle","style","innerWidth","_Debugger_renderMessages","map","message","escapeHtml","title","description","join","querySelectorAll","forEach","ele","descEle","isScroll","scrollWidth","clientWidth","isMultiLine","clientHeight","classList","add","onclick","e","target","contains","toggle","remove","limitCoordinateToScreenBoundaries","Number","parseInt","customElements","get","define"],"mappings":"sYAWA,MAKMA,EAAWC,SAASC,cAAc,YACxCF,EAASG,UAAY,sNAarB,MAiHMC,EAAYC,EAAOA,QAACC,mBAARD,CAA0BE,aAE5C,MAAMC,UAAiBJ,EAarB,WAAAK,GACEC,oBAbFC,EAAiBC,IAAAC,KAAA,IAAIC,EAAqB,CAAEC,SAAU,MAEtDC,EAAyBJ,IAAAC,UAAA,GAEzBI,EAA4BL,IAAAC,UAAA,GAE5BK,EAA2BN,IAAAC,UAAA,GAE3BM,EAAgBP,IAAAC,KAAA,CACdO,OAAQC,EAAAA,uBAAAR,KAAIS,EAAA,IAAAC,GAAiBC,KAAKX,QAMlCA,KAAKY,aAAa,CAAEC,KAAM,SAC1Bb,KAAKc,WAAWC,YAAY5B,EAAS6B,QAAQC,WAAU,IAEvDC,yBAAAlB,KAAgBG,EAAAH,KAAKc,WAAWK,cAA8B,aAAY,KAC1ED,EAAAA,uBAAAlB,KAAmBI,EAAAI,EAAAA,uBAAAR,KAAIG,EAAA,KAAUgB,cAA8B,YAAW,KAC1ED,EAAAA,uBAAAlB,KAAkBK,EAAAG,EAAAA,uBAAAR,KAAIG,EAAA,KAAUgB,cAA8B,WAAU,KAExEX,EAAAA,uBAAAR,KAAIS,EAAA,IAAAW,GAAJC,KAAArB,KACD,CAWD,UAAAsB,CAAWC,GACTf,EAAAA,uBAAAR,KAAmBF,EAAA,KAAC0B,QAAQC,IAAW,CACrCvB,SAAUuB,EAAMvB,SAASwB,OAAOH,MAEnC,CA+DK,IAAAI,oHACM,QAAVC,EAAAC,EAAMF,YAAI,IAAAC,GAAAA,EAAAP,KAAArB,MACV8B,cAAYtB,EAAAA,uBAAAR,KAAIG,EAAA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GhCL,EAAIO,UAAUC,IAAI,eAClBR,EAAIS,QAAWC,IAEPA,EAAEC,OAAuBJ,UAAUK,SAAS,aAChDZ,EAAIO,UAAUM,OAAO,YACtB,IAGHb,EAAIO,UAAUO,OAAO,eACrBd,EAAIS,QAAU,KACf,GAEL,EAACxD,EAAA,WAIC,MAAOuB,EAAMF,GAAOyC,EAAAA,kCAClBhE,EAAAA,uBAAAR,KAAaG,EAAA,KACbsE,OAAOC,SAASlE,EAAAA,uBAAAR,KAAaG,EAAA,KAAC2C,MAAMb,KAAM,IAC1CwC,OAAOC,SAASlE,EAAAA,uBAAAR,KAAIG,EAAA,KAAU2C,MAAMf,IAAK,IACzC,CAAEA,IAAK,MAAOC,OAAQ,IAAKC,KAAM,IAAKC,MAAO,MAE/C1B,yBAAAR,KAAaG,EAAA,KAAC2C,MAAMf,IAAM,GAAGA,MAC7BvB,yBAAAR,KAAaG,EAAA,KAAC2C,MAAMb,KAAO,GAAGA,KAChC,EAyBG0C,eAAeC,IAAI,qBACtBD,eAAeE,OAAO,mBAAoBlF"}
1
+ {"version":3,"file":"debugger-wc.js","sources":["../../src/lib/debugger-wc.ts"],"sourcesContent":["/* eslint-disable no-param-reassign */\nimport { compose, escapeHtml } from '@descope/sdk-helpers';\nimport { injectStyleMixin } from '@descope/sdk-mixins/inject-style-mixin';\nimport {\n addOnResize,\n dragElement,\n limitCoordinateToScreenBoundaries,\n State,\n} from './helpers';\nimport { DebuggerMessage } from './types';\n\nconst INITIAL_POS_THRESHOLD = 32;\nconst INITIAL_WIDTH = 300;\nconst INITIAL_HEIGHT = 200;\nconst MIN_SIZE = 200;\n\nconst template = document.createElement('template');\ntemplate.innerHTML = `\n<div class=\"debugger\">\n <div class=\"header\">\n <span>Debugger messages</span>\n </div>\n <div class=\"content\">\n <div class=\"empty-state\">\n No errors detected 👀\n </div>\n </div>\n</div>\n`;\n\nconst icon = `<svg width=\"18\" height=\"18\" viewBox=\"0 0 18 18\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n<path d=\"M5.99984 13.167L8.99984 10.167L11.9998 13.167L13.1665 12.0003L10.1665 9.00033L13.1665 6.00033L11.9998 4.83366L8.99984 7.83366L5.99984 4.83366L4.83317 6.00033L7.83317 9.00033L4.83317 12.0003L5.99984 13.167ZM8.99984 17.3337C7.84706 17.3337 6.76373 17.1148 5.74984 16.677C4.73595 16.2398 3.854 15.6462 3.104 14.8962C2.354 14.1462 1.76039 13.2642 1.32317 12.2503C0.885393 11.2364 0.666504 10.1531 0.666504 9.00033C0.666504 7.84755 0.885393 6.76421 1.32317 5.75033C1.76039 4.73644 2.354 3.85449 3.104 3.10449C3.854 2.35449 4.73595 1.7606 5.74984 1.32283C6.76373 0.885603 7.84706 0.666992 8.99984 0.666992C10.1526 0.666992 11.2359 0.885603 12.2498 1.32283C13.2637 1.7606 14.1457 2.35449 14.8957 3.10449C15.6457 3.85449 16.2393 4.73644 16.6765 5.75033C17.1143 6.76421 17.3332 7.84755 17.3332 9.00033C17.3332 10.1531 17.1143 11.2364 16.6765 12.2503C16.2393 13.2642 15.6457 14.1462 14.8957 14.8962C14.1457 15.6462 13.2637 16.2398 12.2498 16.677C11.2359 17.1148 10.1526 17.3337 8.99984 17.3337ZM8.99984 15.667C10.8609 15.667 12.4373 15.0212 13.729 13.7295C15.0207 12.4378 15.6665 10.8614 15.6665 9.00033C15.6665 7.13921 15.0207 5.56283 13.729 4.27116C12.4373 2.97949 10.8609 2.33366 8.99984 2.33366C7.13873 2.33366 5.56234 2.97949 4.27067 4.27116C2.979 5.56283 2.33317 7.13921 2.33317 9.00033C2.33317 10.8614 2.979 12.4378 4.27067 13.7295C5.56234 15.0212 7.13873 15.667 8.99984 15.667Z\" fill=\"#ED404A\"/>\n</svg>\n`;\n\nconst style = `\n .debugger {\n all: initial;\n width: ${INITIAL_WIDTH}px;\n height: ${INITIAL_HEIGHT}px;\n background-color: #FAFAFA;\n position: fixed;\n font-family: \"Helvetica Neue\", sans-serif;\n box-shadow: rgba(0, 0, 0, 0.1) 0px 5px 10px;\n border-radius: 8px;\n overflow: hidden;\n border: 1px solid lightgrey;\n pointer-events: initial;\n display: flex;\n flex-direction: column;\n min-width: ${MIN_SIZE}px;\n max-width: 600px;\n max-height: calc(100% - ${INITIAL_POS_THRESHOLD * 2}px);\n min-height: ${MIN_SIZE}px;\n resize: both;\n }\n\n .header {\n padding: 8px 16px;\n display: flex;\n align-items: center;\n background-color: #EEEEEE;\n cursor: move;\n border-bottom: 1px solid #e0e0e0;\n }\n\n .content {\n font-size: 14px;\n flex-grow: 1;\n overflow: auto;\n }\n\n .msg {\n border-bottom: 1px solid lightgrey;\n padding: 8px 16px;\n display: flex;\n gap: 5px;\n background-color: #FAFAFA;\n }\n\n .msg.collapsible {\n cursor: pointer;\n }\n\n .empty-state {\n padding: 8px 16px;\n background-color: #FAFAFA;\n }\n\n\n .msg.collapsible:not(.collapsed) {\n background-color: #F5F5F5;\n }\n\n .msg_title {\n padding-bottom: 5px;\n display: flex;\n gap: 8px;\n font-weight: 500;\n }\n\n .msg svg {\n padding: 1px;\n flex-shrink: 0;\n margin-top: -2px;\n }\n\n .msg_content {\n overflow: hidden;\n flex-grow: 1;\n margin-right:5px;\n }\n\n .msg_desc {\n color: #646464;\n cursor: initial;\n word-wrap: break-word;\n }\n\n .msg.collapsed .msg_desc {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n\n .msg.collapsible.collapsed .chevron {\n transform: rotate(-45deg) translateX(-2px);\n }\n\n .msg.collapsible .chevron {\n content: \"\";\n width:6px;\n height:6px;\n border-bottom: 2px solid grey;\n border-right: 2px solid grey;\n transform: rotate(45deg) translateX(-1px);\n margin: 5px;\n flex-shrink:0;\n }\n`;\n\ntype MessagesState = { messages: DebuggerMessage[] };\n\nconst BaseClass = compose(injectStyleMixin)(HTMLElement);\n\nclass Debugger extends BaseClass {\n #messagesState = new State<MessagesState>({ messages: [] });\n\n #rootEle: HTMLDivElement;\n\n #contentEle: HTMLDivElement;\n\n #headerEle: HTMLDivElement;\n\n #eventsCbRefs = {\n resize: this.#onWindowResize.bind(this),\n };\n\n constructor() {\n super();\n\n this.attachShadow({ mode: 'open' });\n this.shadowRoot.appendChild(template.content.cloneNode(true));\n\n this.#rootEle = this.shadowRoot.querySelector<HTMLDivElement>('.debugger');\n this.#contentEle = this.#rootEle.querySelector<HTMLDivElement>('.content');\n this.#headerEle = this.#rootEle.querySelector<HTMLDivElement>('.header');\n\n this.#initStyle();\n }\n\n #initStyle() {\n this.injectStyle(style);\n\n this.#rootEle.style.top = `${INITIAL_POS_THRESHOLD}px`;\n this.#rootEle.style.left = `${\n window.innerWidth - INITIAL_WIDTH - INITIAL_POS_THRESHOLD\n }px`;\n }\n\n updateData(data: DebuggerMessage | DebuggerMessage[]) {\n this.#messagesState.update((state) => ({\n messages: state.messages.concat(data),\n }));\n }\n\n #onNewMessages(data: MessagesState) {\n this.#renderMessages(data);\n this.#setCollapsibleMessages();\n }\n\n #renderMessages(data: MessagesState) {\n this.#contentEle.innerHTML = data.messages\n .map(\n (message) => `\n <div class=\"msg\">\n ${icon}\n <div class=\"msg_content\">\n <div class=\"msg_title\">\n ${escapeHtml(message.title)}\n </div>\n <div class=\"msg_desc\">\n ${escapeHtml(message.description)}\n </div>\n </div>\n <div class=\"chevron\"></div>\n </div>\n `,\n )\n .join('');\n }\n\n #setCollapsibleMessages() {\n this.#contentEle.querySelectorAll('.msg').forEach((ele: HTMLElement) => {\n const descEle = ele.querySelector('.msg_desc');\n const lineHeight = 20;\n const isScroll = descEle.scrollWidth > descEle.clientWidth;\n const isMultiLine = descEle.clientHeight > lineHeight;\n const isCollapsible = isScroll || isMultiLine;\n\n if (isCollapsible) {\n ele.classList.add('collapsible');\n ele.onclick = (e: MouseEvent) => {\n // message description should not toggle collapse\n if (!(e.target as HTMLElement).classList.contains('msg_desc')) {\n ele.classList.toggle('collapsed');\n }\n };\n } else {\n ele.classList.remove('collapsible');\n ele.onclick = null;\n }\n });\n }\n\n #onWindowResize() {\n // when window is resizing we want to make sure debugger is still visible\n const [left, top] = limitCoordinateToScreenBoundaries(\n this.#rootEle,\n Number.parseInt(this.#rootEle.style.left, 10),\n Number.parseInt(this.#rootEle.style.top, 10),\n { top: 'all', bottom: 100, left: 100, right: 100 },\n );\n this.#rootEle.style.top = `${top}px`;\n this.#rootEle.style.left = `${left}px`;\n }\n\n async init() {\n super.init?.();\n dragElement(this.#rootEle, this.#headerEle, {\n top: 'all',\n bottom: 100,\n left: 100,\n right: 100,\n });\n\n window.addEventListener('resize', this.#eventsCbRefs.resize);\n\n addOnResize(this.#rootEle);\n this.#rootEle.onresize = this.#setCollapsibleMessages.bind(this);\n\n this.#messagesState.subscribe(this.#onNewMessages.bind(this));\n }\n\n disconnectedCallback() {\n this.#messagesState.unsubscribeAll();\n window.removeEventListener('resize', this.#eventsCbRefs.resize);\n }\n}\n\nif (!customElements.get('descope-debugger')) {\n customElements.define('descope-debugger', Debugger);\n}\nexport default Debugger;\n"],"names":["template","document","createElement","innerHTML","BaseClass","compose","injectStyleMixin","HTMLElement","Debugger","constructor","super","_Debugger_messagesState","set","this","State","messages","_Debugger_rootEle","_Debugger_contentEle","_Debugger_headerEle","_Debugger_eventsCbRefs","resize","__classPrivateFieldGet","_Debugger_instances","_Debugger_onWindowResize","bind","attachShadow","mode","shadowRoot","appendChild","content","cloneNode","__classPrivateFieldSet","querySelector","_Debugger_initStyle","call","updateData","data","update","state","concat","init","_a","_super","dragElement","top","bottom","left","right","window","addEventListener","addOnResize","onresize","_Debugger_setCollapsibleMessages","subscribe","_Debugger_onNewMessages","disconnectedCallback","unsubscribeAll","removeEventListener","injectStyle","style","innerWidth","_Debugger_renderMessages","map","message","escapeHtml","title","description","join","querySelectorAll","forEach","ele","descEle","isScroll","scrollWidth","clientWidth","isMultiLine","clientHeight","classList","add","onclick","e","target","contains","toggle","remove","limitCoordinateToScreenBoundaries","Number","parseInt","customElements","get","define"],"mappings":"sYAWA,MAKMA,EAAWC,SAASC,cAAc,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AA,kCAClBhE,yBAAAR,KAAIG,EAAA,KACJsE,OAAOC,SAASlE,EAAAA,uBAAAR,KAAIG,EAAA,KAAU2C,MAAMb,KAAM,IAC1CwC,OAAOC,SAASlE,EAAAA,uBAAAR,KAAIG,EAAA,KAAU2C,MAAMf,IAAK,IACzC,CAAEA,IAAK,MAAOC,OAAQ,IAAKC,KAAM,IAAKC,MAAO,MAE/C1B,yBAAAR,KAAIG,EAAA,KAAU2C,MAAMf,IAAM,GAAGA,MAC7BvB,yBAAAR,KAAIG,EAAA,KAAU2C,MAAMb,KAAO,GAAGA,KAChC,EAyBG0C,eAAeC,IAAI,qBACtBD,eAAeE,OAAO,mBAAoBlF"}
@@ -1,2 +1,2 @@
1
- "use strict";var t=require("tslib"),e=require("@descope/sdk-helpers"),i=require("@descope/sdk-mixins/static-resources-mixin"),s=require("@descope/sdk-mixins/theme-mixin"),r=require("@descope/sdk-mixins/inject-style-mixin"),n=require("@descope/sdk-mixins/telemetry-mixin"),o=require("@descope/web-js-sdk"),a=require("../constants/index.js"),l=require("../helpers/helpers.js"),d=require("../helpers/state.js");require("@descope/escape-markdown"),require("../helpers/webauthn.js");var u,c,h,g,f,p,v,_,m,b,w,k,C,P,x,F,y,A,E,S,I,j,G,M,O,q,U=require("../helpers/storage.js"),L=require("../helpers/flowInputs.js"),R=require("../mixins/formMountMixin.js"),T=require("../mixins/componentConditionsMixin.js"),W=require("../mixins/duplicateFlowWarningMixin.js"),N=require("../mixins/passwordManagerMixin.js"),D=require("../mixins/validationTrackingMixin.js"),K=require("../constants/content.js"),V=require("../constants/general.js");function z(t){return Object.freeze({__proto__:null,default:t})}const H=e.compose(s.themeMixin,i.staticResourcesMixin,R.formMountMixin,T.componentConditionsMixin,W.duplicateFlowWarningMixin,N.passwordManagerMixin,r.injectStyleMixin,n.telemetryMixin,D.validationTrackingMixin)(HTMLElement);class J extends H{static get observedAttributes(){return["project-id","flow-id","base-url","tenant","locale","debug","storage-prefix","preview","redirect-url","auto-focus","store-last-authenticated-user","refresh-cookie-name","keep-last-authenticated-user-after-logout","validate-on-blur","send-session-token","style-id"]}constructor(e){super(),u.add(this),this.sdkVersion="4.5.1",h.set(this,!1),g.set(this,void 0),this.flowStatus="initial",this.loggerWrapper={error:(e,i="")=>{this.logger.error(e,i,new Error),t.__classPrivateFieldGet(this,u,"m",q).call(this,e,i)},warn:(t,e="")=>{this.logger.warn(t,e)},info:(t,e="",i={})=>{this.logger.info(t,e,i)},debug:(t,e="")=>{this.logger.debug(t,e)}},f.set(this,new d),p.set(this,new d),v.set(this,{}),this.getComponentsContext=()=>t.__classPrivateFieldGet(this,v,"f"),this.nextRequestStatus=new d({isLoading:!1}),_.set(this,void 0),m.set(this,{popstate:t.__classPrivateFieldGet(this,u,"m",P).bind(this),componentsContext:t.__classPrivateFieldGet(this,u,"m",S).bind(this)}),b.set(this,void 0),this.getConfig=()=>t.__awaiter(this,void 0,void 0,(function*(){return(yield this.config)||{isMissingConfig:!0}})),I.set(this,void 0),j.set(this,void 0),t.__classPrivateFieldSet(this,b,e,"f"),t.__classPrivateFieldGet(this,u,"m",k).call(this)}get client(){try{return JSON.parse(this.getAttribute("client"))||{}}catch(t){return{}}}get redirectUrl(){return this.getAttribute("redirect-url")||void 0}get debug(){return"true"===this.getAttribute("debug")}get locale(){return this.getAttribute("locale")||void 0}get autoFocus(){var t;const e=null!==(t=this.getAttribute("auto-focus"))&&void 0!==t?t:"true";return"skipFirstScreen"===e?e:"true"===e}get validateOnBlur(){return"true"===this.getAttribute("validate-on-blur")}get storeLastAuthenticatedUser(){var t;return"true"===(null!==(t=this.getAttribute("store-last-authenticated-user"))&&void 0!==t?t:"true")}get refreshCookieName(){return this.getAttribute("refresh-cookie-name")||""}get keepLastAuthenticatedUserAfterLogout(){return"true"===this.getAttribute("keep-last-authenticated-user-after-logout")}get storagePrefix(){return this.getAttribute("storage-prefix")||""}get sendSessionToken(){return"true"===this.getAttribute("send-session-token")}get preview(){return!!this.getAttribute("preview")}get formConfig(){return L.transformFlowInputFormData(this.form)}get form(){return this.getAttribute("form")}get formConfigValues(){return L.extractNestedAttribute(this.formConfig,"value")}get outboundAppId(){return this.getAttribute("outbound-app-id")}get outboundAppScopes(){try{const t=JSON.parse(this.getAttribute("outbound-app-scopes"));return t||null}catch(t){return null}}get popupOrigin(){return this.getAttribute("popup-origin")}get customStorage(){return t.__classPrivateFieldGet(this,g,"f")}set customStorage(e){if(e&&"function"!=typeof e.getItem)throw new Error("Custom storage must have a getItem method");if(e&&"function"!=typeof e.setItem)throw new Error("Custom storage must have a setItem method");if(e&&"function"!=typeof e.removeItem)throw new Error("Custom storage must have a removeItem method");t.__classPrivateFieldSet(this,g,e,"f"),U.setCustomStorage(e)}get lazyStart(){return"true"===this.getAttribute("lazy-start")}start(){var e;null===(e=t.__classPrivateFieldGet(this,j,"f"))||void 0===e||e.call(this),t.__classPrivateFieldSet(this,I,Promise.resolve(),"f")}get isRestartOnError(){return"true"===this.getAttribute("restart-on-error")}getExecutionContext(){return t.__awaiter(this,void 0,void 0,(function*(){const t=yield this.getConfig();return"executionContext"in t?t.executionContext:void 0}))}getProjectConfig(){return t.__awaiter(this,void 0,void 0,(function*(){const t=yield this.getConfig();return"projectConfig"in t?t.projectConfig:void 0}))}getFlowConfig(){return t.__awaiter(this,void 0,void 0,(function*(){var t,e;const i=yield this.getProjectConfig(),s=(null===(t=null==i?void 0:i.flows)||void 0===t?void 0:t[this.flowId])||{};return null!==(e=s.version)&&void 0!==e||(s.version=0),s}))}getTargetLocales(){return t.__awaiter(this,void 0,void 0,(function*(){const t=yield this.getFlowConfig();return((null==t?void 0:t.targetLocales)||[]).map((t=>t.toLowerCase()))}))}handleKeyPress(){this.logger.debug("Enable key press handler"),this.rootElement.onkeydown=t=>{var e,i,s;const r=!!(null===(e=this.shadowRoot.activeElement)||void 0===e?void 0:e.getAttribute("href")),n=a.ELEMENTS_TO_IGNORE_ENTER_KEY_ON.includes(null!==(s=null===(i=this.shadowRoot.activeElement)||void 0===i?void 0:i.localName)&&void 0!==s?s:"");if("Enter"!==t.key||r||n)return;t.preventDefault();const o=this.rootElement.querySelectorAll("descope-button");if(1===o.length&&"false"!==o[0].getAttribute("auto-submit"))return void o[0].click();const l=Array.from(o).filter((t=>"true"===t.getAttribute("auto-submit")));if(1===l.length)return void l[0].click();const d=Array.from(o).filter((t=>"button"===t.getAttribute("data-type")));if(1===d.length)"false"!==d[0].getAttribute("auto-submit")&&d[0].click();else if(0===d.length){const t=Array.from(o).filter((t=>"sso"===t.getAttribute("data-type")));1===t.length&&"false"!==t[0].getAttribute("auto-submit")&&t[0].click()}}}disableKeyPressHandler(){this.logger.debug("Disable key press handler"),this.rootElement.onkeydown=null}getComponentsVersion(){return t.__awaiter(this,void 0,void 0,(function*(){var t;const e=yield this.getConfig(),i="projectConfig"in e?null===(t=e.projectConfig)||void 0===t?void 0:t.componentsVersion:{};return i||(this.logger.error("Did not get components version, using latest version"),"latest")}))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return t.__awaiter(this,void 0,void 0,(function*(){var i;if(this.flowStatus="loading",["ready","error","success"].forEach((t=>this.addEventListener(t,(()=>{this.flowStatus=t})))),yield null===(i=e.init)||void 0===i?void 0:i.call(this),t.__classPrivateFieldGet(this,p,"f").subscribe(t.__classPrivateFieldGet(this,u,"m",O).bind(this)),t.__classPrivateFieldGet(this,p,"f").update({isDebug:this.debug}),t.__classPrivateFieldGet(this,u,"m",C).call(this),yield t.__classPrivateFieldGet(this,u,"m",A).call(this))return void this.loggerWrapper.error("This SDK version does not support your flows version","Make sure to upgrade your flows to the latest version or use an older SDK version");const s=yield this.getConfig();if("isMissingConfig"in s&&s.isMissingConfig)return void this.loggerWrapper.error("Cannot get config file","Make sure that your projectId & flowId are correct");const{executionId:r,stepId:n,token:o,code:a,isPopup:d,exchangeError:c,redirectAuthCallbackUrl:g,redirectAuthBackupCallbackUri:v,redirectAuthCodeChallenge:_,redirectAuthInitiator:b,ssoQueryParams:w}=l.handleUrlParams(this.flowId,this.projectId,this.loggerWrapper);window.addEventListener("popstate",t.__classPrivateFieldGet(this,m,"f").popstate),window.addEventListener("components-context",t.__classPrivateFieldGet(this,m,"f").componentsContext),t.__classPrivateFieldGet(this,f,"f").subscribe(t.__classPrivateFieldGet(this,u,"m",y).bind(this)),t.__classPrivateFieldGet(this,f,"f").update(Object.assign({projectId:this.projectId,flowId:this.flowId,baseUrl:this.baseUrl,tenant:this.tenantId,redirectUrl:this.redirectUrl,locale:this.locale,stepId:n,executionId:r,token:o,code:a,isPopup:d,exchangeError:c,redirectAuthCallbackUrl:g,redirectAuthBackupCallbackUri:v,redirectAuthCodeChallenge:_,redirectAuthInitiator:b},w)),t.__classPrivateFieldSet(this,h,!0,"f")}))}disconnectedCallback(){var e;t.__classPrivateFieldGet(this,f,"f").unsubscribeAll(),t.__classPrivateFieldGet(this,p,"f").unsubscribeAll(),t.__classPrivateFieldGet(this,u,"m",M).call(this),window.removeEventListener("popstate",t.__classPrivateFieldGet(this,m,"f").popstate),window.removeEventListener("components-context",t.__classPrivateFieldGet(this,m,"f").componentsContext),null===(e=super.disconnectedCallback)||void 0===e||e.call(this)}attributeChangedCallback(e,i,s){var r;if(null===(r=super.attributeChangedCallback)||void 0===r||r.call(this,e,i,s),this.shadowRoot.isConnected&&t.__classPrivateFieldGet(this,h,"f")&&i!==s&&c.observedAttributes.includes(e)){t.__classPrivateFieldGet(this,u,"m",C).call(this);const r=null===i;t.__classPrivateFieldGet(this,f,"f").update((({stepId:t,executionId:i})=>{let n=t,o=i;return r||(o=null,n=null,l.clearRunIdsFromUrl()),{[l.camelCase(e)]:s,stepId:n,executionId:o}})),t.__classPrivateFieldGet(this,p,"f").update({isDebug:this.debug})}}}c=J,h=new WeakMap,g=new WeakMap,f=new WeakMap,p=new WeakMap,v=new WeakMap,_=new WeakMap,m=new WeakMap,b=new WeakMap,I=new WeakMap,j=new WeakMap,u=new WeakSet,w=function(){this.injectStyle("\n :host {\n\t\t\twidth: 100%;\n display: block;\n\t\t}\n\n\t\t#root {\n\t\t\theight: 100%;\n display: flex;\n flex-direction: column;\n\t\t}\n\n #content-root {\n all: initial;\n transition: opacity 200ms ease-in-out;\n }\n\n\t\t#root[data-theme] {\n\t\t\tbackground-color: transparent;\n\t\t}\n\n\t\t.fade-out {\n\t\t\topacity: 0.1!important;\n\t\t}\n\n .hidden {\n display: none;\n }\n ")},k=function(){t.__classPrivateFieldGet(this,u,"m",w).call(this),this.slotElement=document.createElement("slot"),this.slotElement.classList.add("hidden"),this.rootElement.appendChild(this.slotElement)},C=function(){const t=["base-url","tenant","locale","debug","redirect-url","auto-focus","store-last-authenticated-user","refresh-cookie-name","keep-last-authenticated-user-after-logout","preview","storage-prefix","form","client","validate-on-blur","send-session-token","style-id","outbound-app-id","outbound-app-scopes","theme-override"];c.observedAttributes.forEach((e=>{if(!t.includes(e)&&!this[l.camelCase(e)])throw Error(`${e} cannot be empty`)}))},P=function(){const{stepId:e,executionId:i}=l.getRunIdsFromUrl(this.flowId);t.__classPrivateFieldGet(this,f,"f").update({stepId:e,executionId:i})},x=function(e,i){o.createSdk&&"function"==typeof o.createSdk||this.logger.error("SDK was not loaded properly",o.createSdk,JSON.stringify(o.createSdk));const s=Object.assign(Object.assign({persistTokens:!0,preview:this.preview,storagePrefix:this.storagePrefix,storeLastAuthenticatedUser:this.storeLastAuthenticatedUser,keepLastAuthenticatedUserAfterLogout:this.keepLastAuthenticatedUserAfterLogout,refreshCookieName:this.refreshCookieName},c.sdkConfigOverrides),{projectId:e,baseUrl:i});t.__classPrivateFieldGet(this,g,"f")&&(s.customStorage=t.__classPrivateFieldGet(this,g,"f")),this.sdk=o.createSdk(s);const r={start:1,next:7};["start","next"].forEach((e=>{const i=this.sdk.flow[e],s=l.withRetry(i,1e3,3);this.sdk.flow[e]=(...i)=>t.__awaiter(this,void 0,void 0,(function*(){const n=[...i],o=r[e],a=t.__classPrivateFieldGet(this,u,"m",F).call(this,n[o]);void 0!==a&&(n[o]=a);try{return yield s(...n)}catch(t){return this.logger.error(`Error in sdk flow ${e} function`,t),{error:{errorCode:V.FETCH_EXCEPTION_ERROR_CODE,errorDescription:t.toString()}}}}))}));const n=this.sdk.flow.start;this.sdk.flow.start=(...e)=>t.__awaiter(this,void 0,void 0,(function*(){return yield t.__classPrivateFieldGet(this,u,"m",G).call(this),n.apply(this.sdk.flow,e)}))},F=function(t){if(!this.sendSessionToken)return t;const e=null===o.getSessionToken||void 0===o.getSessionToken?void 0:o.getSessionToken(this.storagePrefix);return e?Object.assign(Object.assign({},null!=t?t:{}),{sessionJwt:e}):t},y=function(e,i,s){return t.__awaiter(this,void 0,void 0,(function*(){const{projectId:i,baseUrl:r}=e;if(s("projectId")||s("baseUrl")){if(!i)return;t.__classPrivateFieldGet(this,u,"m",x).call(this,i,r)}t.__classPrivateFieldGet(this,b,"f").call(this,e)}))},A=function(){return t.__awaiter(this,void 0,void 0,(function*(){const e=yield this.getConfig();return"isMissingConfig"in e&&e.isMissingConfig&&(yield t.__classPrivateFieldGet(this,u,"m",E).call(this))}))},E=function(){return t.__awaiter(this,void 0,void 0,(function*(){const t=l.getContentUrl({projectId:this.projectId,filename:K.CONFIG_FILENAME,assetsFolder:K.PREV_VER_ASSETS_FOLDER,baseUrl:this.baseStaticUrl});try{return yield l.fetchContent(t,"json"),!0}catch(t){return!1}}))},S=function(e){t.__classPrivateFieldSet(this,v,Object.assign(Object.assign({},t.__classPrivateFieldGet(this,v,"f")),e.detail),"f")},G=function(){return this.lazyStart?(t.__classPrivateFieldGet(this,I,"f")||t.__classPrivateFieldSet(this,I,new Promise((e=>{t.__classPrivateFieldSet(this,j,e,"f")})),"f"),t.__classPrivateFieldGet(this,I,"f")):Promise.resolve()},M=function(){var e;null===(e=t.__classPrivateFieldGet(this,_,"f"))||void 0===e||e.remove(),t.__classPrivateFieldSet(this,_,null,"f")},O=function(e){return t.__awaiter(this,arguments,void 0,(function*({isDebug:e}){e?(t.__classPrivateFieldSet(this,_,document.createElement("descope-debugger"),"f"),Object.assign(t.__classPrivateFieldGet(this,_,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),yield Promise.resolve().then((function(){return z(require("../debugger-wc.js"))})),document.body.appendChild(t.__classPrivateFieldGet(this,_,"f"))):t.__classPrivateFieldGet(this,u,"m",M).call(this)}))},q=function(e,i){var s;e&&this.debug&&(null===(s=t.__classPrivateFieldGet(this,_,"f"))||void 0===s||s.updateData({title:e,description:i}))},J.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"4.5.1"}},module.exports=J;
1
+ "use strict";var t=require("tslib"),e=require("@descope/sdk-helpers"),i=require("@descope/sdk-mixins/static-resources-mixin"),s=require("@descope/sdk-mixins/theme-mixin"),r=require("@descope/sdk-mixins/inject-style-mixin"),n=require("@descope/sdk-mixins/telemetry-mixin"),o=require("@descope/web-js-sdk"),a=require("../constants/index.js"),l=require("../helpers/helpers.js"),d=require("../helpers/state.js");require("@descope/escape-markdown"),require("../helpers/webauthn.js");var u,c,h,g,f,p,v,_,m,b,w,k,C,P,x,F,y,A,E,S,I,j,G,M,O,q,U=require("../helpers/storage.js"),L=require("../helpers/flowInputs.js"),R=require("../mixins/formMountMixin.js"),T=require("../mixins/componentConditionsMixin.js"),W=require("../mixins/duplicateFlowWarningMixin.js"),N=require("../mixins/passwordManagerMixin.js"),D=require("../mixins/validationTrackingMixin.js"),K=require("../constants/content.js"),V=require("../constants/general.js");function z(t){return Object.freeze({__proto__:null,default:t})}const H=e.compose(s.themeMixin,i.staticResourcesMixin,R.formMountMixin,T.componentConditionsMixin,W.duplicateFlowWarningMixin,N.passwordManagerMixin,r.injectStyleMixin,n.telemetryMixin,D.validationTrackingMixin)(HTMLElement);class J extends H{static get observedAttributes(){return["project-id","flow-id","base-url","tenant","locale","debug","storage-prefix","preview","redirect-url","auto-focus","store-last-authenticated-user","refresh-cookie-name","keep-last-authenticated-user-after-logout","validate-on-blur","send-session-token","style-id"]}constructor(e){super(),u.add(this),this.sdkVersion="4.5.2",h.set(this,!1),g.set(this,void 0),this.flowStatus="initial",this.loggerWrapper={error:(e,i="")=>{this.logger.error(e,i,new Error),t.__classPrivateFieldGet(this,u,"m",q).call(this,e,i)},warn:(t,e="")=>{this.logger.warn(t,e)},info:(t,e="",i={})=>{this.logger.info(t,e,i)},debug:(t,e="")=>{this.logger.debug(t,e)}},f.set(this,new d),p.set(this,new d),v.set(this,{}),this.getComponentsContext=()=>t.__classPrivateFieldGet(this,v,"f"),this.nextRequestStatus=new d({isLoading:!1}),_.set(this,void 0),m.set(this,{popstate:t.__classPrivateFieldGet(this,u,"m",P).bind(this),componentsContext:t.__classPrivateFieldGet(this,u,"m",S).bind(this)}),b.set(this,void 0),this.getConfig=()=>t.__awaiter(this,void 0,void 0,(function*(){return(yield this.config)||{isMissingConfig:!0}})),I.set(this,void 0),j.set(this,void 0),t.__classPrivateFieldSet(this,b,e,"f"),t.__classPrivateFieldGet(this,u,"m",k).call(this)}get client(){try{return JSON.parse(this.getAttribute("client"))||{}}catch(t){return{}}}get redirectUrl(){return this.getAttribute("redirect-url")||void 0}get debug(){return"true"===this.getAttribute("debug")}get locale(){return this.getAttribute("locale")||void 0}get autoFocus(){var t;const e=null!==(t=this.getAttribute("auto-focus"))&&void 0!==t?t:"true";return"skipFirstScreen"===e?e:"true"===e}get validateOnBlur(){return"true"===this.getAttribute("validate-on-blur")}get storeLastAuthenticatedUser(){var t;return"true"===(null!==(t=this.getAttribute("store-last-authenticated-user"))&&void 0!==t?t:"true")}get refreshCookieName(){return this.getAttribute("refresh-cookie-name")||""}get keepLastAuthenticatedUserAfterLogout(){return"true"===this.getAttribute("keep-last-authenticated-user-after-logout")}get storagePrefix(){return this.getAttribute("storage-prefix")||""}get sendSessionToken(){return"true"===this.getAttribute("send-session-token")}get preview(){return!!this.getAttribute("preview")}get formConfig(){return L.transformFlowInputFormData(this.form)}get form(){return this.getAttribute("form")}get formConfigValues(){return L.extractNestedAttribute(this.formConfig,"value")}get outboundAppId(){return this.getAttribute("outbound-app-id")}get outboundAppScopes(){try{const t=JSON.parse(this.getAttribute("outbound-app-scopes"));return t||null}catch(t){return null}}get popupOrigin(){return this.getAttribute("popup-origin")}get customStorage(){return t.__classPrivateFieldGet(this,g,"f")}set customStorage(e){if(e&&"function"!=typeof e.getItem)throw new Error("Custom storage must have a getItem method");if(e&&"function"!=typeof e.setItem)throw new Error("Custom storage must have a setItem method");if(e&&"function"!=typeof e.removeItem)throw new Error("Custom storage must have a removeItem method");t.__classPrivateFieldSet(this,g,e,"f"),U.setCustomStorage(e)}get lazyStart(){return"true"===this.getAttribute("lazy-start")}start(){var e;null===(e=t.__classPrivateFieldGet(this,j,"f"))||void 0===e||e.call(this),t.__classPrivateFieldSet(this,I,Promise.resolve(),"f")}get isRestartOnError(){return"true"===this.getAttribute("restart-on-error")}getExecutionContext(){return t.__awaiter(this,void 0,void 0,(function*(){const t=yield this.getConfig();return"executionContext"in t?t.executionContext:void 0}))}getProjectConfig(){return t.__awaiter(this,void 0,void 0,(function*(){const t=yield this.getConfig();return"projectConfig"in t?t.projectConfig:void 0}))}getFlowConfig(){return t.__awaiter(this,void 0,void 0,(function*(){var t,e;const i=yield this.getProjectConfig(),s=(null===(t=null==i?void 0:i.flows)||void 0===t?void 0:t[this.flowId])||{};return null!==(e=s.version)&&void 0!==e||(s.version=0),s}))}getTargetLocales(){return t.__awaiter(this,void 0,void 0,(function*(){const t=yield this.getFlowConfig();return((null==t?void 0:t.targetLocales)||[]).map((t=>t.toLowerCase()))}))}handleKeyPress(){this.logger.debug("Enable key press handler"),this.rootElement.onkeydown=t=>{var e,i,s;const r=!!(null===(e=this.shadowRoot.activeElement)||void 0===e?void 0:e.getAttribute("href")),n=a.ELEMENTS_TO_IGNORE_ENTER_KEY_ON.includes(null!==(s=null===(i=this.shadowRoot.activeElement)||void 0===i?void 0:i.localName)&&void 0!==s?s:"");if("Enter"!==t.key||r||n)return;t.preventDefault();const o=this.rootElement.querySelectorAll("descope-button");if(1===o.length&&"false"!==o[0].getAttribute("auto-submit"))return void o[0].click();const l=Array.from(o).filter((t=>"true"===t.getAttribute("auto-submit")));if(1===l.length)return void l[0].click();const d=Array.from(o).filter((t=>"button"===t.getAttribute("data-type")));if(1===d.length)"false"!==d[0].getAttribute("auto-submit")&&d[0].click();else if(0===d.length){const t=Array.from(o).filter((t=>"sso"===t.getAttribute("data-type")));1===t.length&&"false"!==t[0].getAttribute("auto-submit")&&t[0].click()}}}disableKeyPressHandler(){this.logger.debug("Disable key press handler"),this.rootElement.onkeydown=null}getComponentsVersion(){return t.__awaiter(this,void 0,void 0,(function*(){var t;const e=yield this.getConfig(),i="projectConfig"in e?null===(t=e.projectConfig)||void 0===t?void 0:t.componentsVersion:{};return i||(this.logger.error("Did not get components version, using latest version"),"latest")}))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return t.__awaiter(this,void 0,void 0,(function*(){var i;if(this.flowStatus="loading",["ready","error","success"].forEach((t=>this.addEventListener(t,(()=>{this.flowStatus=t})))),yield null===(i=e.init)||void 0===i?void 0:i.call(this),t.__classPrivateFieldGet(this,p,"f").subscribe(t.__classPrivateFieldGet(this,u,"m",O).bind(this)),t.__classPrivateFieldGet(this,p,"f").update({isDebug:this.debug}),t.__classPrivateFieldGet(this,u,"m",C).call(this),yield t.__classPrivateFieldGet(this,u,"m",A).call(this))return void this.loggerWrapper.error("This SDK version does not support your flows version","Make sure to upgrade your flows to the latest version or use an older SDK version");const s=yield this.getConfig();if("isMissingConfig"in s&&s.isMissingConfig)return void this.loggerWrapper.error("Cannot get config file","Make sure that your projectId & flowId are correct");const{executionId:r,stepId:n,token:o,code:a,isPopup:d,exchangeError:c,redirectAuthCallbackUrl:g,redirectAuthBackupCallbackUri:v,redirectAuthCodeChallenge:_,redirectAuthInitiator:b,ssoQueryParams:w}=l.handleUrlParams(this.flowId,this.projectId,this.loggerWrapper);window.addEventListener("popstate",t.__classPrivateFieldGet(this,m,"f").popstate),window.addEventListener("components-context",t.__classPrivateFieldGet(this,m,"f").componentsContext),t.__classPrivateFieldGet(this,f,"f").subscribe(t.__classPrivateFieldGet(this,u,"m",y).bind(this)),t.__classPrivateFieldGet(this,f,"f").update(Object.assign({projectId:this.projectId,flowId:this.flowId,baseUrl:this.baseUrl,tenant:this.tenantId,redirectUrl:this.redirectUrl,locale:this.locale,stepId:n,executionId:r,token:o,code:a,isPopup:d,exchangeError:c,redirectAuthCallbackUrl:g,redirectAuthBackupCallbackUri:v,redirectAuthCodeChallenge:_,redirectAuthInitiator:b},w)),t.__classPrivateFieldSet(this,h,!0,"f")}))}disconnectedCallback(){var e;t.__classPrivateFieldGet(this,f,"f").unsubscribeAll(),t.__classPrivateFieldGet(this,p,"f").unsubscribeAll(),t.__classPrivateFieldGet(this,u,"m",M).call(this),window.removeEventListener("popstate",t.__classPrivateFieldGet(this,m,"f").popstate),window.removeEventListener("components-context",t.__classPrivateFieldGet(this,m,"f").componentsContext),null===(e=super.disconnectedCallback)||void 0===e||e.call(this)}attributeChangedCallback(e,i,s){var r;if(null===(r=super.attributeChangedCallback)||void 0===r||r.call(this,e,i,s),this.shadowRoot.isConnected&&t.__classPrivateFieldGet(this,h,"f")&&i!==s&&c.observedAttributes.includes(e)){t.__classPrivateFieldGet(this,u,"m",C).call(this);const r=null===i;t.__classPrivateFieldGet(this,f,"f").update((({stepId:t,executionId:i})=>{let n=t,o=i;return r||(o=null,n=null,l.clearRunIdsFromUrl()),{[l.camelCase(e)]:s,stepId:n,executionId:o}})),t.__classPrivateFieldGet(this,p,"f").update({isDebug:this.debug})}}}c=J,h=new WeakMap,g=new WeakMap,f=new WeakMap,p=new WeakMap,v=new WeakMap,_=new WeakMap,m=new WeakMap,b=new WeakMap,I=new WeakMap,j=new WeakMap,u=new WeakSet,w=function(){this.injectStyle("\n :host {\n\t\t\twidth: 100%;\n display: block;\n\t\t}\n\n\t\t#root {\n\t\t\theight: 100%;\n display: flex;\n flex-direction: column;\n\t\t}\n\n #content-root {\n all: initial;\n transition: opacity 200ms ease-in-out;\n }\n\n\t\t#root[data-theme] {\n\t\t\tbackground-color: transparent;\n\t\t}\n\n\t\t.fade-out {\n\t\t\topacity: 0.1!important;\n\t\t}\n\n .hidden {\n display: none;\n }\n ")},k=function(){t.__classPrivateFieldGet(this,u,"m",w).call(this),this.slotElement=document.createElement("slot"),this.slotElement.classList.add("hidden"),this.rootElement.appendChild(this.slotElement)},C=function(){const t=["base-url","tenant","locale","debug","redirect-url","auto-focus","store-last-authenticated-user","refresh-cookie-name","keep-last-authenticated-user-after-logout","preview","storage-prefix","form","client","validate-on-blur","send-session-token","style-id","outbound-app-id","outbound-app-scopes","theme-override"];c.observedAttributes.forEach((e=>{if(!t.includes(e)&&!this[l.camelCase(e)])throw Error(`${e} cannot be empty`)}))},P=function(){const{stepId:e,executionId:i}=l.getRunIdsFromUrl(this.flowId);t.__classPrivateFieldGet(this,f,"f").update({stepId:e,executionId:i})},x=function(e,i){o.createSdk&&"function"==typeof o.createSdk||this.logger.error("SDK was not loaded properly",o.createSdk,JSON.stringify(o.createSdk));const s=Object.assign(Object.assign({persistTokens:!0,preview:this.preview,storagePrefix:this.storagePrefix,storeLastAuthenticatedUser:this.storeLastAuthenticatedUser,keepLastAuthenticatedUserAfterLogout:this.keepLastAuthenticatedUserAfterLogout,refreshCookieName:this.refreshCookieName},c.sdkConfigOverrides),{projectId:e,baseUrl:i});t.__classPrivateFieldGet(this,g,"f")&&(s.customStorage=t.__classPrivateFieldGet(this,g,"f")),this.sdk=o.createSdk(s);const r={start:1,next:7};["start","next"].forEach((e=>{const i=this.sdk.flow[e],s=l.withRetry(i,1e3,3);this.sdk.flow[e]=(...i)=>t.__awaiter(this,void 0,void 0,(function*(){const n=[...i],o=r[e],a=t.__classPrivateFieldGet(this,u,"m",F).call(this,n[o]);void 0!==a&&(n[o]=a);try{return yield s(...n)}catch(t){return this.logger.error(`Error in sdk flow ${e} function`,t),{error:{errorCode:V.FETCH_EXCEPTION_ERROR_CODE,errorDescription:t.toString()}}}}))}));const n=this.sdk.flow.start;this.sdk.flow.start=(...e)=>t.__awaiter(this,void 0,void 0,(function*(){return yield t.__classPrivateFieldGet(this,u,"m",G).call(this),n.apply(this.sdk.flow,e)}))},F=function(t){if(!this.sendSessionToken)return t;const e=null===o.getSessionToken||void 0===o.getSessionToken?void 0:o.getSessionToken(this.storagePrefix);return e?Object.assign(Object.assign({},null!=t?t:{}),{sessionJwt:e}):t},y=function(e,i,s){return t.__awaiter(this,void 0,void 0,(function*(){const{projectId:i,baseUrl:r}=e;if(s("projectId")||s("baseUrl")){if(!i)return;t.__classPrivateFieldGet(this,u,"m",x).call(this,i,r)}t.__classPrivateFieldGet(this,b,"f").call(this,e)}))},A=function(){return t.__awaiter(this,void 0,void 0,(function*(){const e=yield this.getConfig();return"isMissingConfig"in e&&e.isMissingConfig&&(yield t.__classPrivateFieldGet(this,u,"m",E).call(this))}))},E=function(){return t.__awaiter(this,void 0,void 0,(function*(){const t=l.getContentUrl({projectId:this.projectId,filename:K.CONFIG_FILENAME,assetsFolder:K.PREV_VER_ASSETS_FOLDER,baseUrl:this.baseStaticUrl});try{return yield l.fetchContent(t,"json"),!0}catch(t){return!1}}))},S=function(e){t.__classPrivateFieldSet(this,v,Object.assign(Object.assign({},t.__classPrivateFieldGet(this,v,"f")),e.detail),"f")},G=function(){return this.lazyStart?(t.__classPrivateFieldGet(this,I,"f")||t.__classPrivateFieldSet(this,I,new Promise((e=>{t.__classPrivateFieldSet(this,j,e,"f")})),"f"),t.__classPrivateFieldGet(this,I,"f")):Promise.resolve()},M=function(){var e;null===(e=t.__classPrivateFieldGet(this,_,"f"))||void 0===e||e.remove(),t.__classPrivateFieldSet(this,_,null,"f")},O=function(e){return t.__awaiter(this,arguments,void 0,(function*({isDebug:e}){e?(t.__classPrivateFieldSet(this,_,document.createElement("descope-debugger"),"f"),Object.assign(t.__classPrivateFieldGet(this,_,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),yield Promise.resolve().then((function(){return z(require("../debugger-wc.js"))})),document.body.appendChild(t.__classPrivateFieldGet(this,_,"f"))):t.__classPrivateFieldGet(this,u,"m",M).call(this)}))},q=function(e,i){var s;e&&this.debug&&(null===(s=t.__classPrivateFieldGet(this,_,"f"))||void 0===s||s.updateData({title:e,description:i}))},J.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"4.5.2"}},module.exports=J;
2
2
  //# sourceMappingURL=BaseDescopeWc.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"BaseDescopeWc.js","sources":["../../../src/lib/descope-wc/BaseDescopeWc.ts"],"sourcesContent":["import { compose } from '@descope/sdk-helpers';\n// eslint-disable-next-line import/no-duplicates\nimport { staticResourcesMixin } from '@descope/sdk-mixins/static-resources-mixin';\n// eslint-disable-next-line import/no-duplicates\nimport { themeMixin } from '@descope/sdk-mixins/theme-mixin';\n// eslint-disable-next-line import/no-duplicates\nimport { injectStyleMixin } from '@descope/sdk-mixins/inject-style-mixin';\n// eslint-disable-next-line import/no-duplicates\nimport { telemetryMixin } from '@descope/sdk-mixins/telemetry-mixin';\nimport { createSdk, getSessionToken } from '@descope/web-js-sdk';\nimport type { FlowNextOptions, FlowStartOptions } from '@descope/web-js-sdk';\nimport {\n CONFIG_FILENAME,\n ELEMENTS_TO_IGNORE_ENTER_KEY_ON,\n FETCH_EXCEPTION_ERROR_CODE,\n PREV_VER_ASSETS_FOLDER,\n} from '../constants';\nimport {\n camelCase,\n clearRunIdsFromUrl,\n fetchContent,\n getContentUrl,\n getRunIdsFromUrl,\n handleUrlParams,\n State,\n withRetry,\n} from '../helpers';\nimport {\n extractNestedAttribute,\n transformFlowInputFormData,\n} from '../helpers/flowInputs';\nimport { setCustomStorage } from '../helpers/storage';\nimport { IsChanged } from '../helpers/state';\nimport {\n formMountMixin,\n componentConditionsMixin,\n duplicateFlowWarningMixin,\n passwordManagerMixin,\n validationTrackingMixin,\n} from '../mixins';\nimport {\n AutoFocusOptions,\n CustomStorage,\n DebuggerMessage,\n DebugState,\n DescopeUI,\n FlowConfig,\n FlowState,\n FlowStateUpdateFn,\n FlowStatus,\n ProjectConfiguration,\n SdkConfig,\n} from '../types';\n\n// this is replaced in build time\ndeclare const BUILD_VERSION: string;\n\nconst BaseClass = compose(\n themeMixin,\n staticResourcesMixin,\n formMountMixin,\n componentConditionsMixin,\n duplicateFlowWarningMixin,\n passwordManagerMixin,\n injectStyleMixin,\n telemetryMixin,\n validationTrackingMixin,\n)(HTMLElement);\n\n// this base class is responsible for WC initialization\nclass BaseDescopeWc extends BaseClass {\n static get observedAttributes() {\n return [\n 'project-id',\n 'flow-id',\n 'base-url',\n 'tenant',\n 'locale',\n 'debug',\n 'storage-prefix',\n 'preview',\n 'redirect-url',\n 'auto-focus',\n 'store-last-authenticated-user',\n 'refresh-cookie-name',\n 'keep-last-authenticated-user-after-logout',\n 'validate-on-blur',\n 'send-session-token',\n 'style-id',\n ];\n }\n\n sdkVersion = BUILD_VERSION;\n\n // this is a way for extending the sdk config from outside\n static sdkConfigOverrides: Partial<SdkConfig> = {\n baseHeaders: {\n 'x-descope-sdk-name': 'web-component',\n 'x-descope-sdk-version': BUILD_VERSION,\n },\n };\n\n #init = false;\n\n #customStorage: CustomStorage | undefined;\n\n flowStatus: FlowStatus = 'initial';\n\n loggerWrapper = {\n error: (message: string, description = '') => {\n this.logger.error(message, description, new Error());\n this.#updateDebuggerMessages(message, description);\n },\n warn: (message: string, description = '') => {\n this.logger.warn(message, description);\n },\n info: (message: string, description = '', state: any = {}) => {\n this.logger.info(message, description, state);\n },\n debug: (message: string, description = '') => {\n this.logger.debug(message, description);\n },\n };\n\n #flowState = new State<FlowState>();\n\n #debugState = new State<DebugState>();\n\n #componentsContext = {};\n\n getComponentsContext = () => this.#componentsContext;\n\n nextRequestStatus = new State<{ isLoading: boolean }>({ isLoading: false });\n\n rootElement: HTMLDivElement;\n\n contentRootElement: HTMLDivElement;\n\n slotElement: HTMLSlotElement;\n\n #debuggerEle: HTMLElement & {\n updateData: (data: DebuggerMessage | DebuggerMessage[]) => void;\n };\n\n #eventsCbRefs = {\n popstate: this.#syncStateIdFromUrl.bind(this),\n componentsContext: this.#handleComponentsContext.bind(this),\n };\n\n sdk: ReturnType<typeof createSdk>;\n\n #updateExecState: FlowStateUpdateFn;\n\n descopeUI: Promise<DescopeUI>;\n\n constructor(updateExecState: FlowStateUpdateFn) {\n super();\n this.#updateExecState = updateExecState;\n\n this.#initShadowDom();\n }\n\n #loadInitStyle() {\n this.injectStyle(`\n :host {\n\t\t\twidth: 100%;\n display: block;\n\t\t}\n\n\t\t#root {\n\t\t\theight: 100%;\n display: flex;\n flex-direction: column;\n\t\t}\n\n #content-root {\n all: initial;\n transition: opacity 200ms ease-in-out;\n }\n\n\t\t#root[data-theme] {\n\t\t\tbackground-color: transparent;\n\t\t}\n\n\t\t.fade-out {\n\t\t\topacity: 0.1!important;\n\t\t}\n\n .hidden {\n display: none;\n }\n `);\n }\n\n #initShadowDom() {\n this.#loadInitStyle();\n this.slotElement = document.createElement('slot');\n this.slotElement.classList.add('hidden');\n this.rootElement.appendChild(this.slotElement);\n }\n\n get client() {\n try {\n return (JSON.parse(this.getAttribute('client')) || {}) as Record<\n string,\n any\n >;\n } catch (e) {\n return {};\n }\n }\n\n get redirectUrl() {\n return this.getAttribute('redirect-url') || undefined;\n }\n\n get debug() {\n return this.getAttribute('debug') === 'true';\n }\n\n get locale() {\n return this.getAttribute('locale') || undefined;\n }\n\n get autoFocus(): AutoFocusOptions {\n const res = this.getAttribute('auto-focus') ?? 'true';\n if (res === 'skipFirstScreen') {\n return res;\n }\n return res === 'true';\n }\n\n get validateOnBlur() {\n return this.getAttribute('validate-on-blur') === 'true';\n }\n\n get storeLastAuthenticatedUser() {\n const res = this.getAttribute('store-last-authenticated-user') ?? 'true';\n return res === 'true';\n }\n\n get refreshCookieName() {\n return this.getAttribute('refresh-cookie-name') || '';\n }\n\n get keepLastAuthenticatedUserAfterLogout() {\n const res = this.getAttribute('keep-last-authenticated-user-after-logout');\n return res === 'true';\n }\n\n get storagePrefix() {\n return this.getAttribute('storage-prefix') || '';\n }\n\n get sendSessionToken() {\n return this.getAttribute('send-session-token') === 'true';\n }\n\n get preview() {\n return !!this.getAttribute('preview');\n }\n\n get formConfig() {\n return transformFlowInputFormData(this.form);\n }\n\n get form() {\n return this.getAttribute('form');\n }\n\n get formConfigValues() {\n return extractNestedAttribute(this.formConfig, 'value');\n }\n\n get outboundAppId() {\n return this.getAttribute('outbound-app-id');\n }\n\n get outboundAppScopes() {\n try {\n const scopes = JSON.parse(this.getAttribute('outbound-app-scopes'));\n if (!scopes) return null;\n return scopes;\n } catch (err) {\n return null;\n }\n }\n\n get popupOrigin(): string | null {\n return this.getAttribute('popup-origin');\n }\n\n // grouped getter/setter for customStorage\n get customStorage(): CustomStorage | undefined {\n return this.#customStorage;\n }\n\n set customStorage(storage: CustomStorage | undefined) {\n if (storage && typeof storage.getItem !== 'function') {\n throw new Error('Custom storage must have a getItem method');\n }\n if (storage && typeof storage.setItem !== 'function') {\n throw new Error('Custom storage must have a setItem method');\n }\n if (storage && typeof storage.removeItem !== 'function') {\n throw new Error('Custom storage must have a removeItem method');\n }\n this.#customStorage = storage;\n setCustomStorage(storage);\n }\n\n #validateAttrs() {\n const optionalAttributes = [\n 'base-url',\n 'tenant',\n 'locale',\n 'debug',\n 'redirect-url',\n 'auto-focus',\n 'store-last-authenticated-user',\n 'refresh-cookie-name',\n 'keep-last-authenticated-user-after-logout',\n 'preview',\n 'storage-prefix',\n 'form',\n 'client',\n 'validate-on-blur',\n 'send-session-token',\n 'style-id',\n 'outbound-app-id',\n 'outbound-app-scopes',\n 'theme-override',\n ];\n\n BaseDescopeWc.observedAttributes.forEach((attr: string) => {\n if (!optionalAttributes.includes(attr) && !this[camelCase(attr)])\n throw Error(`${attr} cannot be empty`);\n });\n }\n\n #syncStateIdFromUrl() {\n const { stepId, executionId } = getRunIdsFromUrl(this.flowId);\n this.#flowState.update({ stepId, executionId });\n }\n\n #createSdk(projectId: string, baseUrl: string) {\n if (!createSdk || typeof createSdk !== 'function') {\n this.logger.error(\n 'SDK was not loaded properly',\n createSdk,\n JSON.stringify(createSdk),\n );\n }\n const config: any = {\n // Use persist tokens options in order to add existing tokens in outgoing requests (if they exists)\n persistTokens: true,\n preview: this.preview,\n storagePrefix: this.storagePrefix,\n storeLastAuthenticatedUser: this.storeLastAuthenticatedUser,\n keepLastAuthenticatedUserAfterLogout:\n this.keepLastAuthenticatedUserAfterLogout,\n refreshCookieName: this.refreshCookieName,\n ...BaseDescopeWc.sdkConfigOverrides,\n projectId,\n baseUrl,\n };\n if (this.#customStorage) {\n config.customStorage = this.#customStorage;\n }\n\n this.sdk = createSdk(config);\n\n // Position of the `options` argument in core-js-sdk's flow calls:\n // flow.start(flowId, options, conditionInteractionId, interactionId, componentsVersion, flowVersions, input, isCustomScreen)\n // flow.next(executionId, stepId, interactionId, version, componentsVersion, input, isCustomScreen, options)\n // We rely on these positions staying fixed - core-js-sdk keeps them stable\n // for backwards compatibility, and new params are only appended at the end\n const flowOptionsArgIdx = { start: 1, next: 7 };\n\n // we are wrapping the next & start function so we can indicate the request status\n ['start', 'next'].forEach((key) => {\n const origFn = this.sdk.flow[key];\n const fnWithRetry = withRetry(origFn, 1000, 3);\n\n this.sdk.flow[key] = async (...args: Parameters<typeof origFn>) => {\n const callArgs = [...args] as Parameters<typeof origFn>;\n const optionsIdx = flowOptionsArgIdx[key];\n const options = this.#injectSessionJwt(callArgs[optionsIdx]);\n if (options !== undefined) {\n callArgs[optionsIdx] = options;\n }\n try {\n const resp = await fnWithRetry(...callArgs);\n return resp;\n } catch (e) {\n this.logger.error(`Error in sdk flow ${key} function`, e);\n // return a generic error object in case of an error\n return {\n error: {\n errorCode: FETCH_EXCEPTION_ERROR_CODE,\n errorDescription: e.toString(),\n },\n };\n }\n };\n });\n\n // While `lazy-start` is set, hold every flow start call until start() is\n // called. Wrapping the sdk fn holds all call sites at once, and sits outside\n // the wrapper above so the session JWT is read when the call is really sent.\n const startFn = this.sdk.flow.start;\n this.sdk.flow.start = async (\n ...args: Parameters<typeof startFn>\n ): ReturnType<typeof startFn> => {\n await this.#waitForStart();\n\n return startFn.apply(this.sdk.flow, args);\n };\n }\n\n // adds the current session JWT to a flow request options (opt-in via the\n // send-session-token attribute), so the flow can read its validated claims\n // through the sessionJwtClaims context key. Accepts only the flow start/next\n // options types and preserves the given type on return. The token is read\n // via the standalone helper - the wrapping SDKs (e.g. react-sdk) override\n // the inner sdk with persistTokens: false, so the instance getter is absent\n #injectSessionJwt<T extends FlowStartOptions | FlowNextOptions>(\n options?: T,\n ): T | undefined {\n if (!this.sendSessionToken) return options;\n const sessionToken = getSessionToken?.(this.storagePrefix);\n if (!sessionToken) return options;\n return { ...(options ?? {}), sessionJwt: sessionToken } as T;\n }\n\n async #onFlowChange(\n currentState: FlowState,\n _prevState: FlowState,\n isChanged: IsChanged<FlowState>,\n ) {\n const { projectId, baseUrl } = currentState;\n\n const shouldCreateSdkInstance =\n isChanged('projectId') || isChanged('baseUrl');\n\n if (shouldCreateSdkInstance) {\n if (!projectId) return;\n // Initialize the sdk when got a new project id\n this.#createSdk(projectId, baseUrl);\n }\n\n // update runtime state\n this.#updateExecState(currentState);\n }\n\n async #getIsFlowsVersionMismatch() {\n const config = await this.getConfig();\n\n return (\n 'isMissingConfig' in config &&\n config.isMissingConfig &&\n (await this.#isPrevVerConfig())\n );\n }\n\n // we are not using fetchStaticResource here\n // because we do not want to use the fallbacks mechanism\n async #isPrevVerConfig() {\n const prevVerConfigUrl = getContentUrl({\n projectId: this.projectId,\n filename: CONFIG_FILENAME,\n assetsFolder: PREV_VER_ASSETS_FOLDER,\n baseUrl: this.baseStaticUrl,\n });\n try {\n await fetchContent(prevVerConfigUrl, 'json');\n return true;\n } catch (e) {\n return false;\n }\n }\n\n getConfig = async () => (await this.config) || { isMissingConfig: true };\n\n #handleComponentsContext(e: CustomEvent) {\n this.#componentsContext = { ...this.#componentsContext, ...e.detail };\n }\n\n // Holds the flow's start call, so a host can preload a flow (config,\n // components, first screen) without creating a flow execution - e.g. a modal\n // that builds its flow ahead of being opened. `start()` is then the only way\n // that flow starts.\n get lazyStart() {\n return this.getAttribute('lazy-start') === 'true';\n }\n\n #startGate: Promise<void> | undefined;\n\n #releaseStartGate: (() => void) | undefined;\n\n // resolves immediately unless `lazy-start` is set, in which case it waits for\n // start()\n #waitForStart(): Promise<void> {\n if (!this.lazyStart) return Promise.resolve();\n\n if (!this.#startGate) {\n this.#startGate = new Promise((resolve) => {\n this.#releaseStartGate = resolve;\n });\n }\n\n return this.#startGate;\n }\n\n // Start a flow rendered with `lazy-start`. Safe to call before the flow\n // reached the held start call - it then goes through on arrival. The gate is\n // latched open rather than re-armed, so a flow restart (e.g. restart-on-error)\n // is not left waiting for another call.\n start() {\n this.#releaseStartGate?.();\n this.#startGate = Promise.resolve();\n }\n\n get isRestartOnError() {\n return this.getAttribute('restart-on-error') === 'true';\n }\n\n async getExecutionContext() {\n const config = await this.getConfig();\n return 'executionContext' in config ? config.executionContext : undefined;\n }\n\n #disableDebugger() {\n this.#debuggerEle?.remove();\n this.#debuggerEle = null;\n }\n\n async #handleDebugMode({ isDebug }) {\n if (isDebug) {\n this.#debuggerEle = document.createElement(\n 'descope-debugger',\n ) as HTMLElement & {\n updateData: (data: DebuggerMessage | DebuggerMessage[]) => void;\n };\n\n Object.assign(this.#debuggerEle.style, {\n position: 'fixed',\n top: '0',\n right: '0',\n height: '100vh',\n width: '100vw',\n pointerEvents: 'none',\n zIndex: 99999,\n });\n\n // we are importing the debugger dynamically so we won't load it when it's not needed\n await import('../debugger-wc');\n\n document.body.appendChild(this.#debuggerEle);\n } else {\n this.#disableDebugger();\n }\n }\n\n #updateDebuggerMessages(title: string, description: string) {\n if (title && this.debug)\n this.#debuggerEle?.updateData({ title, description });\n }\n\n async getProjectConfig(): Promise<ProjectConfiguration> {\n const config = await this.getConfig();\n return 'projectConfig' in config ? config.projectConfig : undefined;\n }\n\n async getFlowConfig(): Promise<FlowConfig> {\n const projectConfig = await this.getProjectConfig();\n\n const flowConfig =\n projectConfig?.flows?.[this.flowId] || ({} as FlowConfig);\n flowConfig.version ??= 0;\n return flowConfig;\n }\n\n async getTargetLocales() {\n const flowConfig = await this.getFlowConfig();\n return (flowConfig?.targetLocales || []).map((locale: string) =>\n locale.toLowerCase(),\n );\n }\n\n handleKeyPress() {\n this.logger.debug('Enable key press handler');\n // we want to simulate submit when the user presses Enter\n this.rootElement.onkeydown = (e) => {\n // we do not want to submit the form if the focus is on a link element\n const isLinkEleFocused =\n !!this.shadowRoot.activeElement?.getAttribute('href');\n const isIgnoredElementFocused = ELEMENTS_TO_IGNORE_ENTER_KEY_ON.includes(\n this.shadowRoot.activeElement?.localName ?? '',\n );\n\n if (e.key !== 'Enter' || isLinkEleFocused || isIgnoredElementFocused)\n return;\n\n e.preventDefault();\n const buttons: NodeListOf<HTMLButtonElement> =\n this.rootElement.querySelectorAll('descope-button');\n\n // in case there is a single button on the page, click on it\n if (\n buttons.length === 1 &&\n buttons[0].getAttribute('auto-submit') !== 'false'\n ) {\n buttons[0].click();\n return;\n }\n\n const autoSubmitButtons = Array.from(buttons).filter(\n (button) => button.getAttribute('auto-submit') === 'true',\n );\n if (autoSubmitButtons.length === 1) {\n autoSubmitButtons[0].click();\n return;\n }\n\n const genericButtons = Array.from(buttons).filter(\n (button) => button.getAttribute('data-type') === 'button',\n );\n\n // in case there is a single \"generic\" button on the page, click on it\n if (genericButtons.length === 1) {\n if (genericButtons[0].getAttribute('auto-submit') !== 'false') {\n genericButtons[0].click();\n }\n } else if (genericButtons.length === 0) {\n const ssoButtons = Array.from(buttons).filter(\n (button) => button.getAttribute('data-type') === 'sso',\n );\n\n // in case there is a single \"sso\" button on the page, click on it\n if (ssoButtons.length === 1) {\n if (ssoButtons[0].getAttribute('auto-submit') !== 'false') {\n ssoButtons[0].click();\n }\n }\n }\n };\n }\n\n disableKeyPressHandler() {\n this.logger.debug('Disable key press handler');\n this.rootElement.onkeydown = null;\n }\n\n async getComponentsVersion() {\n const config = await this.getConfig();\n const version =\n 'projectConfig' in config ? config.projectConfig?.componentsVersion : {};\n\n if (version) return version;\n\n this.logger.error('Did not get components version, using latest version');\n\n return 'latest';\n }\n\n static descopeUI: any;\n\n async init() {\n this.flowStatus = 'loading';\n ['ready', 'error', 'success'].forEach((status: FlowStatus) =>\n this.addEventListener(status, () => {\n this.flowStatus = status;\n }),\n );\n\n await super.init?.();\n this.#debugState.subscribe(this.#handleDebugMode.bind(this));\n this.#debugState.update({ isDebug: this.debug });\n\n this.#validateAttrs();\n\n if (await this.#getIsFlowsVersionMismatch()) {\n this.loggerWrapper.error(\n 'This SDK version does not support your flows version',\n 'Make sure to upgrade your flows to the latest version or use an older SDK version',\n );\n\n return;\n }\n\n const config = await this.getConfig();\n if ('isMissingConfig' in config && config.isMissingConfig) {\n this.loggerWrapper.error(\n 'Cannot get config file',\n 'Make sure that your projectId & flowId are correct',\n );\n\n return;\n }\n\n const {\n executionId,\n stepId,\n token,\n code,\n isPopup,\n exchangeError,\n redirectAuthCallbackUrl,\n redirectAuthBackupCallbackUri,\n redirectAuthCodeChallenge,\n redirectAuthInitiator,\n ssoQueryParams,\n } = handleUrlParams(this.flowId, this.projectId, this.loggerWrapper);\n\n // we want to update the state when user clicks on back in the browser\n window.addEventListener('popstate', this.#eventsCbRefs.popstate);\n\n // adding event to listen to events coming from components (e.g. recaptcha risk token) that want to add data to the context\n // this data will be sent to the server on the next request\n window.addEventListener(\n 'components-context',\n this.#eventsCbRefs.componentsContext,\n );\n\n this.#flowState.subscribe(this.#onFlowChange.bind(this));\n\n this.#flowState.update({\n projectId: this.projectId,\n flowId: this.flowId,\n baseUrl: this.baseUrl,\n tenant: this.tenantId,\n redirectUrl: this.redirectUrl,\n locale: this.locale,\n stepId,\n executionId,\n token,\n code,\n isPopup,\n exchangeError,\n redirectAuthCallbackUrl,\n redirectAuthBackupCallbackUri,\n redirectAuthCodeChallenge,\n redirectAuthInitiator,\n ...ssoQueryParams,\n });\n\n this.#init = true;\n }\n\n disconnectedCallback() {\n this.#flowState.unsubscribeAll();\n this.#debugState.unsubscribeAll();\n this.#disableDebugger();\n window.removeEventListener('popstate', this.#eventsCbRefs.popstate);\n window.removeEventListener(\n 'components-context',\n this.#eventsCbRefs.componentsContext,\n );\n // Forward to the composed mixin chain so each mixin's\n // disconnectedCallback (e.g. componentConditionsMixin) gets to clean up.\n // Without this, mixin disconnectedCallbacks are dead code.\n super.disconnectedCallback?.();\n }\n\n attributeChangedCallback(\n attrName: string,\n oldValue: string,\n newValue: string,\n ) {\n // Forward to the composed mixin chain first so other mixins always receive\n // the callback, regardless of the early return below.\n super.attributeChangedCallback?.(attrName, oldValue, newValue);\n\n if (!this.shadowRoot.isConnected || !this.#init) return;\n\n if (\n oldValue !== newValue &&\n BaseDescopeWc.observedAttributes.includes(attrName)\n ) {\n this.#validateAttrs();\n\n const isInitialRun = oldValue === null;\n\n this.#flowState.update(({ stepId, executionId }) => {\n let newStepId = stepId;\n let newExecutionId = executionId;\n\n // If not initial run and we got a new project/flow, we want to restart the step\n if (!isInitialRun) {\n newExecutionId = null;\n newStepId = null;\n clearRunIdsFromUrl();\n }\n\n return {\n [camelCase(attrName)]: newValue,\n stepId: newStepId,\n executionId: newExecutionId,\n };\n });\n\n this.#debugState.update({ isDebug: this.debug });\n }\n }\n}\n\nexport default BaseDescopeWc;\n"],"names":["BaseClass","compose","themeMixin","staticResourcesMixin","formMountMixin","componentConditionsMixin","duplicateFlowWarningMixin","passwordManagerMixin","injectStyleMixin","telemetryMixin","validationTrackingMixin","HTMLElement","BaseDescopeWc","observedAttributes","constructor","updateExecState","super","this","sdkVersion","_BaseDescopeWc_init","set","_BaseDescopeWc_customStorage","flowStatus","loggerWrapper","error","message","description","logger","Error","__classPrivateFieldGet","call","warn","info","state","debug","_BaseDescopeWc_flowState","State","_BaseDescopeWc_debugState","_BaseDescopeWc_componentsContext","getComponentsContext","nextRequestStatus","isLoading","_BaseDescopeWc_debuggerEle","_BaseDescopeWc_eventsCbRefs","popstate","_BaseDescopeWc_instances","_BaseDescopeWc_syncStateIdFromUrl","bind","componentsContext","_BaseDescopeWc_handleComponentsContext","_BaseDescopeWc_updateExecState","getConfig","config","isMissingConfig","_BaseDescopeWc_startGate","_BaseDescopeWc_releaseStartGate","__classPrivateFieldSet","_BaseDescopeWc_initShadowDom","client","JSON","parse","getAttribute","e","redirectUrl","undefined","locale","autoFocus","res","_b","validateOnBlur","storeLastAuthenticatedUser","refreshCookieName","keepLastAuthenticatedUserAfterLogout","storagePrefix","sendSessionToken","preview","formConfig","transformFlowInputFormData","form","formConfigValues","extractNestedAttribute","outboundAppId","outboundAppScopes","scopes","err","popupOrigin","customStorage","storage","getItem","setItem","removeItem","setCustomStorage","lazyStart","start","Promise","resolve","isRestartOnError","getExecutionContext","executionContext","getProjectConfig","projectConfig","getFlowConfig","flowConfig","flows","flowId","_c","version","getTargetLocales","targetLocales","map","toLowerCase","handleKeyPress","rootElement","onkeydown","isLinkEleFocused","shadowRoot","activeElement","isIgnoredElementFocused","ELEMENTS_TO_IGNORE_ENTER_KEY_ON","includes","localName","_d","key","preventDefault","buttons","querySelectorAll","length","click","autoSubmitButtons","Array","from","filter","button","genericButtons","ssoButtons","disableKeyPressHandler","getComponentsVersion","componentsVersion","init","forEach","status","addEventListener","_super","subscribe","_BaseDescopeWc_handleDebugMode","update","isDebug","_BaseDescopeWc_validateAttrs","_BaseDescopeWc_getIsFlowsVersionMismatch","executionId","stepId","token","code","isPopup","exchangeError","redirectAuthCallbackUrl","redirectAuthBackupCallbackUri","redirectAuthCodeChallenge","redirectAuthInitiator","ssoQueryParams","handleUrlParams","projectId","window","_BaseDescopeWc_onFlowChange","Object","assign","baseUrl","tenant","tenantId","disconnectedCallback","unsubscribeAll","_BaseDescopeWc_disableDebugger","removeEventListener","attributeChangedCallback","attrName","oldValue","newValue","isConnected","_a","isInitialRun","newStepId","newExecutionId","clearRunIdsFromUrl","camelCase","injectStyle","_BaseDescopeWc_loadInitStyle","slotElement","document","createElement","classList","add","appendChild","optionalAttributes","attr","getRunIdsFromUrl","_BaseDescopeWc_createSdk","createSdk","stringify","persistTokens","sdkConfigOverrides","sdk","flowOptionsArgIdx","next","origFn","flow","fnWithRetry","withRetry","args","__awaiter","callArgs","optionsIdx","options","_BaseDescopeWc_injectSessionJwt","errorCode","FETCH_EXCEPTION_ERROR_CODE","errorDescription","toString","startFn","_BaseDescopeWc_waitForStart","apply","sessionToken","getSessionToken","sessionJwt","currentState","_prevState","isChanged","_BaseDescopeWc_isPrevVerConfig","prevVerConfigUrl","getContentUrl","filename","CONFIG_FILENAME","assetsFolder","PREV_VER_ASSETS_FOLDER","baseStaticUrl","fetchContent","detail","remove","arguments","style","position","top","right","height","width","pointerEvents","zIndex","then","_interopNamespaceDefaultOnly","require","body","_BaseDescopeWc_updateDebuggerMessages","title","updateData","baseHeaders"],"mappings":"y9BAyDA,MAAMA,EAAYC,EAAAA,QAChBC,EAAAA,WACAC,EAAoBA,qBACpBC,EAAcA,eACdC,EAAwBA,yBACxBC,4BACAC,EAAAA,qBACAC,EAAAA,iBACAC,EAAAA,eACAC,EAAAA,wBATgBT,CAUhBU,aAGF,MAAMC,UAAsBZ,EAC1B,6BAAWa,GACT,MAAO,CACL,aACA,UACA,WACA,SACA,SACA,QACA,iBACA,UACA,eACA,aACA,gCACA,sBACA,4CACA,mBACA,qBACA,WAEH,CAiED,WAAAC,CAAYC,GACVC,oBAhEFC,KAAUC,WAAG,QAUbC,EAAAC,IAAAH,MAAQ,GAERI,EAA0CD,IAAAH,UAAA,GAE1CA,KAAUK,WAAe,UAEzBL,KAAAM,cAAgB,CACdC,MAAO,CAACC,EAAiBC,EAAc,MACrCT,KAAKU,OAAOH,MAAMC,EAASC,EAAa,IAAIE,OAC5CC,yBAAAZ,cAAAa,KAAAb,KAA6BQ,EAASC,EAAY,EAEpDK,KAAM,CAACN,EAAiBC,EAAc,MACpCT,KAAKU,OAAO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IAAA8H,GAAJ7I,KAAAb,QAIoB,EAAAyO,EAAA,SAAAC,EAAejO,SACjCiO,GAAS1O,KAAKiB,QACC,QAAjBkC,EAAAvC,EAAAA,uBAAAZ,KAAiByB,EAAA,YAAA,IAAA0B,GAAAA,EAAEwL,WAAW,CAAED,QAAOjO,gBAC3C,EAxdOd,EAAA2L,mBAAyC,CAC9CsD,YAAa,CACX,qBAAsB,gBACtB,wBAAyB"}
1
+ {"version":3,"file":"BaseDescopeWc.js","sources":["../../../src/lib/descope-wc/BaseDescopeWc.ts"],"sourcesContent":["import { compose } from '@descope/sdk-helpers';\n// eslint-disable-next-line import/no-duplicates\nimport { staticResourcesMixin } from '@descope/sdk-mixins/static-resources-mixin';\n// eslint-disable-next-line import/no-duplicates\nimport { themeMixin } from '@descope/sdk-mixins/theme-mixin';\n// eslint-disable-next-line import/no-duplicates\nimport { injectStyleMixin } from '@descope/sdk-mixins/inject-style-mixin';\n// eslint-disable-next-line import/no-duplicates\nimport { telemetryMixin } from '@descope/sdk-mixins/telemetry-mixin';\nimport { createSdk, getSessionToken } from '@descope/web-js-sdk';\nimport type { FlowNextOptions, FlowStartOptions } from '@descope/web-js-sdk';\nimport {\n CONFIG_FILENAME,\n ELEMENTS_TO_IGNORE_ENTER_KEY_ON,\n FETCH_EXCEPTION_ERROR_CODE,\n PREV_VER_ASSETS_FOLDER,\n} from '../constants';\nimport {\n camelCase,\n clearRunIdsFromUrl,\n fetchContent,\n getContentUrl,\n getRunIdsFromUrl,\n handleUrlParams,\n State,\n withRetry,\n} from '../helpers';\nimport {\n extractNestedAttribute,\n transformFlowInputFormData,\n} from '../helpers/flowInputs';\nimport { setCustomStorage } from '../helpers/storage';\nimport { IsChanged } from '../helpers/state';\nimport {\n formMountMixin,\n componentConditionsMixin,\n duplicateFlowWarningMixin,\n passwordManagerMixin,\n validationTrackingMixin,\n} from '../mixins';\nimport {\n AutoFocusOptions,\n CustomStorage,\n DebuggerMessage,\n DebugState,\n DescopeUI,\n FlowConfig,\n FlowState,\n FlowStateUpdateFn,\n FlowStatus,\n ProjectConfiguration,\n SdkConfig,\n} from '../types';\n\n// this is replaced in build time\ndeclare const BUILD_VERSION: string;\n\nconst BaseClass = compose(\n themeMixin,\n staticResourcesMixin,\n formMountMixin,\n componentConditionsMixin,\n duplicateFlowWarningMixin,\n passwordManagerMixin,\n injectStyleMixin,\n telemetryMixin,\n validationTrackingMixin,\n)(HTMLElement);\n\n// this base class is responsible for WC initialization\nclass BaseDescopeWc extends BaseClass {\n static get observedAttributes() {\n return [\n 'project-id',\n 'flow-id',\n 'base-url',\n 'tenant',\n 'locale',\n 'debug',\n 'storage-prefix',\n 'preview',\n 'redirect-url',\n 'auto-focus',\n 'store-last-authenticated-user',\n 'refresh-cookie-name',\n 'keep-last-authenticated-user-after-logout',\n 'validate-on-blur',\n 'send-session-token',\n 'style-id',\n ];\n }\n\n sdkVersion = BUILD_VERSION;\n\n // this is a way for extending the sdk config from outside\n static sdkConfigOverrides: Partial<SdkConfig> = {\n baseHeaders: {\n 'x-descope-sdk-name': 'web-component',\n 'x-descope-sdk-version': BUILD_VERSION,\n },\n };\n\n #init = false;\n\n #customStorage: CustomStorage | undefined;\n\n flowStatus: FlowStatus = 'initial';\n\n loggerWrapper = {\n error: (message: string, description = '') => {\n this.logger.error(message, description, new Error());\n this.#updateDebuggerMessages(message, description);\n },\n warn: (message: string, description = '') => {\n this.logger.warn(message, description);\n },\n info: (message: string, description = '', state: any = {}) => {\n this.logger.info(message, description, state);\n },\n debug: (message: string, description = '') => {\n this.logger.debug(message, description);\n },\n };\n\n #flowState = new State<FlowState>();\n\n #debugState = new State<DebugState>();\n\n #componentsContext = {};\n\n getComponentsContext = () => this.#componentsContext;\n\n nextRequestStatus = new State<{ isLoading: boolean }>({ isLoading: false });\n\n rootElement: HTMLDivElement;\n\n contentRootElement: HTMLDivElement;\n\n slotElement: HTMLSlotElement;\n\n #debuggerEle: HTMLElement & {\n updateData: (data: DebuggerMessage | DebuggerMessage[]) => void;\n };\n\n #eventsCbRefs = {\n popstate: this.#syncStateIdFromUrl.bind(this),\n componentsContext: this.#handleComponentsContext.bind(this),\n };\n\n sdk: ReturnType<typeof createSdk>;\n\n #updateExecState: FlowStateUpdateFn;\n\n descopeUI: Promise<DescopeUI>;\n\n constructor(updateExecState: FlowStateUpdateFn) {\n super();\n this.#updateExecState = updateExecState;\n\n this.#initShadowDom();\n }\n\n #loadInitStyle() {\n this.injectStyle(`\n :host {\n\t\t\twidth: 100%;\n display: block;\n\t\t}\n\n\t\t#root {\n\t\t\theight: 100%;\n display: flex;\n flex-direction: column;\n\t\t}\n\n #content-root {\n all: initial;\n transition: opacity 200ms ease-in-out;\n }\n\n\t\t#root[data-theme] {\n\t\t\tbackground-color: transparent;\n\t\t}\n\n\t\t.fade-out {\n\t\t\topacity: 0.1!important;\n\t\t}\n\n .hidden {\n display: none;\n }\n `);\n }\n\n #initShadowDom() {\n this.#loadInitStyle();\n this.slotElement = document.createElement('slot');\n this.slotElement.classList.add('hidden');\n this.rootElement.appendChild(this.slotElement);\n }\n\n get client() {\n try {\n return (JSON.parse(this.getAttribute('client')) || {}) as Record<\n string,\n any\n >;\n } catch (e) {\n return {};\n }\n }\n\n get redirectUrl() {\n return this.getAttribute('redirect-url') || undefined;\n }\n\n get debug() {\n return this.getAttribute('debug') === 'true';\n }\n\n get locale() {\n return this.getAttribute('locale') || undefined;\n }\n\n get autoFocus(): AutoFocusOptions {\n const res = this.getAttribute('auto-focus') ?? 'true';\n if (res === 'skipFirstScreen') {\n return res;\n }\n return res === 'true';\n }\n\n get validateOnBlur() {\n return this.getAttribute('validate-on-blur') === 'true';\n }\n\n get storeLastAuthenticatedUser() {\n const res = this.getAttribute('store-last-authenticated-user') ?? 'true';\n return res === 'true';\n }\n\n get refreshCookieName() {\n return this.getAttribute('refresh-cookie-name') || '';\n }\n\n get keepLastAuthenticatedUserAfterLogout() {\n const res = this.getAttribute('keep-last-authenticated-user-after-logout');\n return res === 'true';\n }\n\n get storagePrefix() {\n return this.getAttribute('storage-prefix') || '';\n }\n\n get sendSessionToken() {\n return this.getAttribute('send-session-token') === 'true';\n }\n\n get preview() {\n return !!this.getAttribute('preview');\n }\n\n get formConfig() {\n return transformFlowInputFormData(this.form);\n }\n\n get form() {\n return this.getAttribute('form');\n }\n\n get formConfigValues() {\n return extractNestedAttribute(this.formConfig, 'value');\n }\n\n get outboundAppId() {\n return this.getAttribute('outbound-app-id');\n }\n\n get outboundAppScopes() {\n try {\n const scopes = JSON.parse(this.getAttribute('outbound-app-scopes'));\n if (!scopes) return null;\n return scopes;\n } catch (err) {\n return null;\n }\n }\n\n get popupOrigin(): string | null {\n return this.getAttribute('popup-origin');\n }\n\n // grouped getter/setter for customStorage\n get customStorage(): CustomStorage | undefined {\n return this.#customStorage;\n }\n\n set customStorage(storage: CustomStorage | undefined) {\n if (storage && typeof storage.getItem !== 'function') {\n throw new Error('Custom storage must have a getItem method');\n }\n if (storage && typeof storage.setItem !== 'function') {\n throw new Error('Custom storage must have a setItem method');\n }\n if (storage && typeof storage.removeItem !== 'function') {\n throw new Error('Custom storage must have a removeItem method');\n }\n this.#customStorage = storage;\n setCustomStorage(storage);\n }\n\n #validateAttrs() {\n const optionalAttributes = [\n 'base-url',\n 'tenant',\n 'locale',\n 'debug',\n 'redirect-url',\n 'auto-focus',\n 'store-last-authenticated-user',\n 'refresh-cookie-name',\n 'keep-last-authenticated-user-after-logout',\n 'preview',\n 'storage-prefix',\n 'form',\n 'client',\n 'validate-on-blur',\n 'send-session-token',\n 'style-id',\n 'outbound-app-id',\n 'outbound-app-scopes',\n 'theme-override',\n ];\n\n BaseDescopeWc.observedAttributes.forEach((attr: string) => {\n if (!optionalAttributes.includes(attr) && !this[camelCase(attr)])\n throw Error(`${attr} cannot be empty`);\n });\n }\n\n #syncStateIdFromUrl() {\n const { stepId, executionId } = getRunIdsFromUrl(this.flowId);\n this.#flowState.update({ stepId, executionId });\n }\n\n #createSdk(projectId: string, baseUrl: string) {\n if (!createSdk || typeof createSdk !== 'function') {\n this.logger.error(\n 'SDK was not loaded properly',\n createSdk,\n JSON.stringify(createSdk),\n );\n }\n const config: any = {\n // Use persist tokens options in order to add existing tokens in outgoing requests (if they exists)\n persistTokens: true,\n preview: this.preview,\n storagePrefix: this.storagePrefix,\n storeLastAuthenticatedUser: this.storeLastAuthenticatedUser,\n keepLastAuthenticatedUserAfterLogout:\n this.keepLastAuthenticatedUserAfterLogout,\n refreshCookieName: this.refreshCookieName,\n ...BaseDescopeWc.sdkConfigOverrides,\n projectId,\n baseUrl,\n };\n if (this.#customStorage) {\n config.customStorage = this.#customStorage;\n }\n\n this.sdk = createSdk(config);\n\n // Position of the `options` argument in core-js-sdk's flow calls:\n // flow.start(flowId, options, conditionInteractionId, interactionId, componentsVersion, flowVersions, input, isCustomScreen)\n // flow.next(executionId, stepId, interactionId, version, componentsVersion, input, isCustomScreen, options)\n // We rely on these positions staying fixed - core-js-sdk keeps them stable\n // for backwards compatibility, and new params are only appended at the end\n const flowOptionsArgIdx = { start: 1, next: 7 };\n\n // we are wrapping the next & start function so we can indicate the request status\n ['start', 'next'].forEach((key) => {\n const origFn = this.sdk.flow[key];\n const fnWithRetry = withRetry(origFn, 1000, 3);\n\n this.sdk.flow[key] = async (...args: Parameters<typeof origFn>) => {\n const callArgs = [...args] as Parameters<typeof origFn>;\n const optionsIdx = flowOptionsArgIdx[key];\n const options = this.#injectSessionJwt(callArgs[optionsIdx]);\n if (options !== undefined) {\n callArgs[optionsIdx] = options;\n }\n try {\n const resp = await fnWithRetry(...callArgs);\n return resp;\n } catch (e) {\n this.logger.error(`Error in sdk flow ${key} function`, e);\n // return a generic error object in case of an error\n return {\n error: {\n errorCode: FETCH_EXCEPTION_ERROR_CODE,\n errorDescription: e.toString(),\n },\n };\n }\n };\n });\n\n // While `lazy-start` is set, hold every flow start call until start() is\n // called. Wrapping the sdk fn holds all call sites at once, and sits outside\n // the wrapper above so the session JWT is read when the call is really sent.\n const startFn = this.sdk.flow.start;\n this.sdk.flow.start = async (\n ...args: Parameters<typeof startFn>\n ): ReturnType<typeof startFn> => {\n await this.#waitForStart();\n\n return startFn.apply(this.sdk.flow, args);\n };\n }\n\n // adds the current session JWT to a flow request options (opt-in via the\n // send-session-token attribute), so the flow can read its validated claims\n // through the sessionJwtClaims context key. Accepts only the flow start/next\n // options types and preserves the given type on return. The token is read\n // via the standalone helper - the wrapping SDKs (e.g. react-sdk) override\n // the inner sdk with persistTokens: false, so the instance getter is absent\n #injectSessionJwt<T extends FlowStartOptions | FlowNextOptions>(\n options?: T,\n ): T | undefined {\n if (!this.sendSessionToken) return options;\n const sessionToken = getSessionToken?.(this.storagePrefix);\n if (!sessionToken) return options;\n return { ...(options ?? {}), sessionJwt: sessionToken } as T;\n }\n\n async #onFlowChange(\n currentState: FlowState,\n _prevState: FlowState,\n isChanged: IsChanged<FlowState>,\n ) {\n const { projectId, baseUrl } = currentState;\n\n const shouldCreateSdkInstance =\n isChanged('projectId') || isChanged('baseUrl');\n\n if (shouldCreateSdkInstance) {\n if (!projectId) return;\n // Initialize the sdk when got a new project id\n this.#createSdk(projectId, baseUrl);\n }\n\n // update runtime state\n this.#updateExecState(currentState);\n }\n\n async #getIsFlowsVersionMismatch() {\n const config = await this.getConfig();\n\n return (\n 'isMissingConfig' in config &&\n config.isMissingConfig &&\n (await this.#isPrevVerConfig())\n );\n }\n\n // we are not using fetchStaticResource here\n // because we do not want to use the fallbacks mechanism\n async #isPrevVerConfig() {\n const prevVerConfigUrl = getContentUrl({\n projectId: this.projectId,\n filename: CONFIG_FILENAME,\n assetsFolder: PREV_VER_ASSETS_FOLDER,\n baseUrl: this.baseStaticUrl,\n });\n try {\n await fetchContent(prevVerConfigUrl, 'json');\n return true;\n } catch (e) {\n return false;\n }\n }\n\n getConfig = async () => (await this.config) || { isMissingConfig: true };\n\n #handleComponentsContext(e: CustomEvent) {\n this.#componentsContext = { ...this.#componentsContext, ...e.detail };\n }\n\n // Holds the flow's start call, so a host can preload a flow (config,\n // components, first screen) without creating a flow execution - e.g. a modal\n // that builds its flow ahead of being opened. `start()` is then the only way\n // that flow starts.\n get lazyStart() {\n return this.getAttribute('lazy-start') === 'true';\n }\n\n #startGate: Promise<void> | undefined;\n\n #releaseStartGate: (() => void) | undefined;\n\n // resolves immediately unless `lazy-start` is set, in which case it waits for\n // start()\n #waitForStart(): Promise<void> {\n if (!this.lazyStart) return Promise.resolve();\n\n if (!this.#startGate) {\n this.#startGate = new Promise((resolve) => {\n this.#releaseStartGate = resolve;\n });\n }\n\n return this.#startGate;\n }\n\n // Start a flow rendered with `lazy-start`. Safe to call before the flow\n // reached the held start call - it then goes through on arrival. The gate is\n // latched open rather than re-armed, so a flow restart (e.g. restart-on-error)\n // is not left waiting for another call.\n start() {\n this.#releaseStartGate?.();\n this.#startGate = Promise.resolve();\n }\n\n get isRestartOnError() {\n return this.getAttribute('restart-on-error') === 'true';\n }\n\n async getExecutionContext() {\n const config = await this.getConfig();\n return 'executionContext' in config ? config.executionContext : undefined;\n }\n\n #disableDebugger() {\n this.#debuggerEle?.remove();\n this.#debuggerEle = null;\n }\n\n async #handleDebugMode({ isDebug }) {\n if (isDebug) {\n this.#debuggerEle = document.createElement(\n 'descope-debugger',\n ) as HTMLElement & {\n updateData: (data: DebuggerMessage | DebuggerMessage[]) => void;\n };\n\n Object.assign(this.#debuggerEle.style, {\n position: 'fixed',\n top: '0',\n right: '0',\n height: '100vh',\n width: '100vw',\n pointerEvents: 'none',\n zIndex: 99999,\n });\n\n // we are importing the debugger dynamically so we won't load it when it's not needed\n await import('../debugger-wc');\n\n document.body.appendChild(this.#debuggerEle);\n } else {\n this.#disableDebugger();\n }\n }\n\n #updateDebuggerMessages(title: string, description: string) {\n if (title && this.debug)\n this.#debuggerEle?.updateData({ title, description });\n }\n\n async getProjectConfig(): Promise<ProjectConfiguration> {\n const config = await this.getConfig();\n return 'projectConfig' in config ? config.projectConfig : undefined;\n }\n\n async getFlowConfig(): Promise<FlowConfig> {\n const projectConfig = await this.getProjectConfig();\n\n const flowConfig =\n projectConfig?.flows?.[this.flowId] || ({} as FlowConfig);\n flowConfig.version ??= 0;\n return flowConfig;\n }\n\n async getTargetLocales() {\n const flowConfig = await this.getFlowConfig();\n return (flowConfig?.targetLocales || []).map((locale: string) =>\n locale.toLowerCase(),\n );\n }\n\n handleKeyPress() {\n this.logger.debug('Enable key press handler');\n // we want to simulate submit when the user presses Enter\n this.rootElement.onkeydown = (e) => {\n // we do not want to submit the form if the focus is on a link element\n const isLinkEleFocused =\n !!this.shadowRoot.activeElement?.getAttribute('href');\n const isIgnoredElementFocused = ELEMENTS_TO_IGNORE_ENTER_KEY_ON.includes(\n this.shadowRoot.activeElement?.localName ?? '',\n );\n\n if (e.key !== 'Enter' || isLinkEleFocused || isIgnoredElementFocused)\n return;\n\n e.preventDefault();\n const buttons: NodeListOf<HTMLButtonElement> =\n this.rootElement.querySelectorAll('descope-button');\n\n // in case there is a single button on the page, click on it\n if (\n buttons.length === 1 &&\n buttons[0].getAttribute('auto-submit') !== 'false'\n ) {\n buttons[0].click();\n return;\n }\n\n const autoSubmitButtons = Array.from(buttons).filter(\n (button) => button.getAttribute('auto-submit') === 'true',\n );\n if (autoSubmitButtons.length === 1) {\n autoSubmitButtons[0].click();\n return;\n }\n\n const genericButtons = Array.from(buttons).filter(\n (button) => button.getAttribute('data-type') === 'button',\n );\n\n // in case there is a single \"generic\" button on the page, click on it\n if (genericButtons.length === 1) {\n if (genericButtons[0].getAttribute('auto-submit') !== 'false') {\n genericButtons[0].click();\n }\n } else if (genericButtons.length === 0) {\n const ssoButtons = Array.from(buttons).filter(\n (button) => button.getAttribute('data-type') === 'sso',\n );\n\n // in case there is a single \"sso\" button on the page, click on it\n if (ssoButtons.length === 1) {\n if (ssoButtons[0].getAttribute('auto-submit') !== 'false') {\n ssoButtons[0].click();\n }\n }\n }\n };\n }\n\n disableKeyPressHandler() {\n this.logger.debug('Disable key press handler');\n this.rootElement.onkeydown = null;\n }\n\n async getComponentsVersion() {\n const config = await this.getConfig();\n const version =\n 'projectConfig' in config ? config.projectConfig?.componentsVersion : {};\n\n if (version) return version;\n\n this.logger.error('Did not get components version, using latest version');\n\n return 'latest';\n }\n\n static descopeUI: any;\n\n async init() {\n this.flowStatus = 'loading';\n ['ready', 'error', 'success'].forEach((status: FlowStatus) =>\n this.addEventListener(status, () => {\n this.flowStatus = status;\n }),\n );\n\n await super.init?.();\n this.#debugState.subscribe(this.#handleDebugMode.bind(this));\n this.#debugState.update({ isDebug: this.debug });\n\n this.#validateAttrs();\n\n if (await this.#getIsFlowsVersionMismatch()) {\n this.loggerWrapper.error(\n 'This SDK version does not support your flows version',\n 'Make sure to upgrade your flows to the latest version or use an older SDK version',\n );\n\n return;\n }\n\n const config = await this.getConfig();\n if ('isMissingConfig' in config && config.isMissingConfig) {\n this.loggerWrapper.error(\n 'Cannot get config file',\n 'Make sure that your projectId & flowId are correct',\n );\n\n return;\n }\n\n const {\n executionId,\n stepId,\n token,\n code,\n isPopup,\n exchangeError,\n redirectAuthCallbackUrl,\n redirectAuthBackupCallbackUri,\n redirectAuthCodeChallenge,\n redirectAuthInitiator,\n ssoQueryParams,\n } = handleUrlParams(this.flowId, this.projectId, this.loggerWrapper);\n\n // we want to update the state when user clicks on back in the browser\n window.addEventListener('popstate', this.#eventsCbRefs.popstate);\n\n // adding event to listen to events coming from components (e.g. recaptcha risk token) that want to add data to the context\n // this data will be sent to the server on the next request\n window.addEventListener(\n 'components-context',\n this.#eventsCbRefs.componentsContext,\n );\n\n this.#flowState.subscribe(this.#onFlowChange.bind(this));\n\n this.#flowState.update({\n projectId: this.projectId,\n flowId: this.flowId,\n baseUrl: this.baseUrl,\n tenant: this.tenantId,\n redirectUrl: this.redirectUrl,\n locale: this.locale,\n stepId,\n executionId,\n token,\n code,\n isPopup,\n exchangeError,\n redirectAuthCallbackUrl,\n redirectAuthBackupCallbackUri,\n redirectAuthCodeChallenge,\n redirectAuthInitiator,\n ...ssoQueryParams,\n });\n\n this.#init = true;\n }\n\n disconnectedCallback() {\n this.#flowState.unsubscribeAll();\n this.#debugState.unsubscribeAll();\n this.#disableDebugger();\n window.removeEventListener('popstate', this.#eventsCbRefs.popstate);\n window.removeEventListener(\n 'components-context',\n this.#eventsCbRefs.componentsContext,\n );\n // Forward to the composed mixin chain so each mixin's\n // disconnectedCallback (e.g. componentConditionsMixin) gets to clean up.\n // Without this, mixin disconnectedCallbacks are dead code.\n super.disconnectedCallback?.();\n }\n\n attributeChangedCallback(\n attrName: string,\n oldValue: string,\n newValue: string,\n ) {\n // Forward to the composed mixin chain first so other mixins always receive\n // the callback, regardless of the early return below.\n super.attributeChangedCallback?.(attrName, oldValue, newValue);\n\n if (!this.shadowRoot.isConnected || !this.#init) return;\n\n if (\n oldValue !== newValue &&\n BaseDescopeWc.observedAttributes.includes(attrName)\n ) {\n this.#validateAttrs();\n\n const isInitialRun = oldValue === null;\n\n this.#flowState.update(({ stepId, executionId }) => {\n let newStepId = stepId;\n let newExecutionId = executionId;\n\n // If not initial run and we got a new project/flow, we want to restart the step\n if (!isInitialRun) {\n newExecutionId = null;\n newStepId = null;\n clearRunIdsFromUrl();\n }\n\n return {\n [camelCase(attrName)]: newValue,\n stepId: newStepId,\n executionId: newExecutionId,\n };\n });\n\n this.#debugState.update({ isDebug: this.debug });\n }\n }\n}\n\nexport default BaseDescopeWc;\n"],"names":["BaseClass","compose","themeMixin","staticResourcesMixin","formMountMixin","componentConditionsMixin","duplicateFlowWarningMixin","passwordManagerMixin","injectStyleMixin","telemetryMixin","validationTrackingMixin","HTMLElement","BaseDescopeWc","observedAttributes","constructor","updateExecState","super","this","sdkVersion","_BaseDescopeWc_init","set","_BaseDescopeWc_customStorage","flowStatus","loggerWrapper","error","message","description","logger","Error","__classPrivateFieldGet","call","warn","info","state","debug","_BaseDescopeWc_flowState","State","_BaseDescopeWc_debugState","_BaseDescopeWc_componentsContext","getComponentsContext","nextRequestStatus","isLoading","_BaseDescopeWc_debuggerEle","_BaseDescopeWc_eventsCbRefs","popstate","_BaseDescopeWc_instances","_BaseDescopeWc_syncStateIdFromUrl","bind","componentsContext","_BaseDescopeWc_handleComponentsContext","_BaseDescopeWc_updateExecState","getConfig","config","isMissingConfig","_BaseDescopeWc_startGate","_BaseDescopeWc_releaseStartGate","__classPrivateFieldSet","_BaseDescopeWc_initShadowDom","client","JSON","parse","getAttribute","e","redirectUrl","undefined","locale","autoFocus","res","_b","validateOnBlur","storeLastAuthenticatedUser","refreshCookieName","keepLastAuthenticatedUserAfterLogout","storagePrefix","sendSessionToken","preview","formConfig","transformFlowInputFormData","form","formConfigValues","extractNestedAttribute","outboundAppId","outboundAppScopes","scopes","err","popupOrigin","customStorage","storage","getItem","setItem","removeItem","setCustomStorage","lazyStart","start","Promise","resolve","isRestartOnError","getExecutionContext","executionContext","getProjectConfig","projectConfig","getFlowConfig","flowConfig","flows","flowId","_c","version","getTargetLocales","targetLocales","map","toLowerCase","handleKeyPress","rootElement","onkeydown","isLinkEleFocused","shadowRoot","activeElement","isIgnoredElementFocused","ELEMENTS_TO_IGNORE_ENTER_KEY_ON","includes","localName","_d","key","preventDefault","buttons","querySelectorAll","length","click","autoSubmitButtons","Array","from","filter","button","genericButtons","ssoButtons","disableKeyPressHandler","getComponentsVersion","componentsVersion","init","forEach","status","addEventListener","_super","subscribe","_BaseDescopeWc_handleDebugMode","update","isDebug","_BaseDescopeWc_validateAttrs","_BaseDescopeWc_getIsFlowsVersionMismatch","executionId","stepId","token","code","isPopup","exchangeError","redirectAuthCallbackUrl","redirectAuthBackupCallbackUri","redirectAuthCodeChallenge","redirectAuthInitiator","ssoQueryParams","handleUrlParams","projectId","window","_BaseDescopeWc_onFlowChange","Object","assign","baseUrl","tenant","tenantId","disconnectedCallback","unsubscribeAll","_BaseDescopeWc_disableDebugger","removeEventListener","attributeChangedCallback","attrName","oldValue","newValue","isConnected","_a","isInitialRun","newStepId","newExecutionId","clearRunIdsFromUrl","camelCase","injectStyle","_BaseDescopeWc_loadInitStyle","slotElement","document","createElement","classList","add","appendChild","optionalAttributes","attr","getRunIdsFromUrl","_BaseDescopeWc_createSdk","createSdk","stringify","persistTokens","sdkConfigOverrides","sdk","flowOptionsArgIdx","next","origFn","flow","fnWithRetry","withRetry","args","__awaiter","callArgs","optionsIdx","options","_BaseDescopeWc_injectSessionJwt","errorCode","FETCH_EXCEPTION_ERROR_CODE","errorDescription","toString","startFn","_BaseDescopeWc_waitForStart","apply","sessionToken","getSessionToken","sessionJwt","currentState","_prevState","isChanged","_BaseDescopeWc_isPrevVerConfig","prevVerConfigUrl","getContentUrl","filename","CONFIG_FILENAME","assetsFolder","PREV_VER_ASSETS_FOLDER","baseStaticUrl","fetchContent","detail","remove","arguments","style","position","top","right","height","width","pointerEvents","zIndex","then","_interopNamespaceDefaultOnly","require","body","_BaseDescopeWc_updateDebuggerMessages","title","updateData","baseHeaders"],"mappings":"y9BAyDA,MAAMA,EAAYC,EAAAA,QAChBC,EAAAA,WACAC,EAAAA,qBACAC,EAAAA,eACAC,EAAAA,yBACAC,4BACAC,EAAAA,qBACAC,EAAAA,iBACAC,EAAAA,eACAC,EAAAA,wBATgBT,CAUhBU,aAGF,MAAMC,UAAsBZ,EAC1B,6BAAWa,GACT,MAAO,CACL,aACA,UACA,WACA,SACA,SACA,QACA,iBACA,UACA,eACA,aACA,gCACA,sBACA,4CACA,mBACA,qBACA,WAEJ,CAiEA,WAAAC,CAAYC,GACVC,oBAhEFC,KAAAC,WAAa,QAUbC,EAAAC,IAAAH,MAAQ,GAERI,EAAAD,IAAAH,UAAA,GAEAA,KAAAK,WAAyB,UAEzBL,KAAAM,cAAgB,CACdC,MAAO,CAACC,EAAiBC,EAAc,MACrCT,KAAKU,OAAOH,MAAMC,EAASC,EAAa,IAAIE,OAC5CC,yBAAAZ,cAA4Ba,KAA5Bb,KAA6BQ,EAASC,EAAY,EAEpDK,KAAM,CAACN,EAAiBC,EAAc,MACpCT,KAAKU,OAAOI,KAAKN,EAASC,EAAY,EAExCM,KAAM,CAACP,EAAiBC,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B,EAAA,OAE9Bb,EAAAA,uBAAAZ,KAAI4B,EAAA,IAAA8H,GAAiB7I,KAArBb,KAEJ,GAEwB,EAAAyO,EAAA,SAAAC,EAAejO,SACjCiO,GAAS1O,KAAKiB,QACC,QAAjBkC,EAAAvC,EAAAA,uBAAAZ,KAAIyB,EAAA,YAAa,IAAA0B,GAAAA,EAAEwL,WAAW,CAAED,QAAOjO,gBAC3C,EAxdOd,EAAA2L,mBAAyC,CAC9CsD,YAAa,CACX,qBAAsB,gBACtB,wBAAyB"}
@@ -1,2 +1,2 @@
1
- "use strict";var e,t,i,s,r,o,n,a,l,d,c,u,h,p,g,v,m,_,f,b,S,w,E,I,P,R,O,C,F,y,T,A,k,W,x,N,U,L,G,j,D,M,q,V,$,B,H=require("tslib"),K=require("@descope/sdk-helpers"),X=require("@descope/web-js-sdk"),J=require("../constants/index.js"),Q=require("../helpers/helpers.js"),z=require("../helpers/state.js"),Y=require("../helpers/templates.js"),Z=require("../helpers/webauthn.js"),ee=require("../helpers/oidcSession.js"),te=require("../helpers/abTestingKey.js"),ie=require("../helpers/conditions.js"),se=require("../helpers/lastAuth.js"),re=require("../helpers/realtime-conditions/applier.js"),oe=require("./BaseDescopeWc.js"),ne=require("../constants/general.js");const ae="__descope_webauthn_timed_out__";class le extends oe{static set sdkConfigOverrides(e){oe.sdkConfigOverrides=e}static get sdkConfigOverrides(){return oe.sdkConfigOverrides}constructor(){const a=new z({deferredRedirect:!1,deferredPolling:!1});super(a.update.bind(a)),e.add(this),this.stepState=new z({}),t.set(this,void 0),i.set(this,null),s.set(this,null),r.set(this,{visibilitychange:H.__classPrivateFieldGet(this,e,"m",o).bind(this)}),this.bridgeVersion=le.bridgeVersion,n.set(this,void 0),this.nativeCallbacks={},g.set(this,!1),this.handleRedirect=e=>{window.location.assign(e)},_.set(this,(t=>{const i=()=>{this.contentRootElement.classList.toggle("hidden",t),this.slotElement.classList.toggle("hidden",!t),t&&(this.contentRootElement.innerHTML="")};t&&this.contentRootElement.hasChildNodes()?H.__classPrivateFieldGet(this,e,"m",f).call(this,i):i()})),b.set(this,((e,i,s,r,o=!1)=>{const n=[ne.FLOW_TIMED_OUT_ERROR_CODE,ne.POLLING_STATUS_NOT_FOUND_ERROR_CODE,ne.NONCE_VALIDATION_ERROR_CODE];if(this.flowState.current.action===J.RESPONSE_ACTIONS.poll){if(H.__classPrivateFieldGet(this,w,"f").call(this)&&document.hidden)return this.logger.debug("polling - Deferring polling until in foreground"),void this.flowState.update({deferredPolling:!0});this.logger.debug("polling - Scheduling polling request");const a=Date.now(),l=o?500:2e3;H.__classPrivateFieldSet(this,t,setTimeout((()=>H.__awaiter(this,void 0,void 0,(function*(){var t,d;this.logger.debug("polling - Calling next");const c=this.sdk.flow.next(e,i,J.CUSTOM_INTERACTIONS.polling,s,r,{}),u=document.hidden&&!o&&Date.now()-a>l+500;let h;u&&this.logger.debug("polling - The polling seems to be throttled");try{const e=u?1e3:6e3;h=yield Q.timeoutPromise(e,c)}catch(t){return this.logger.warn(`polling - The ${u?"throttled fetch":"fetch"} call timed out or was aborted`),void H.__classPrivateFieldGet(this,b,"f").call(this,e,i,s,r,u)}if((null===(t=null==h?void 0:h.error)||void 0===t?void 0:t.errorCode)===ne.FETCH_EXCEPTION_ERROR_CODE)return this.logger.debug("polling - Got a generic error due to exception in fetch call"),void H.__classPrivateFieldGet(this,b,"f").call(this,e,i,s,r);this.logger.debug("polling - Got a response"),(null==h?void 0:h.error)&&this.logger.debug("polling - Response has an error",JSON.stringify(h.error,null,4)),(null===(d=null==h?void 0:h.error)||void 0===d?void 0:d.errorCode)&&n.includes(h.error.errorCode)?this.logger.debug("polling - Stopping polling due to error"):H.__classPrivateFieldGet(this,b,"f").call(this,e,i,s,r),H.__classPrivateFieldGet(this,E,"f").call(this,h)}))),l),"f")}})),S.set(this,(()=>{clearTimeout(H.__classPrivateFieldGet(this,t,"f")),H.__classPrivateFieldSet(this,t,null,"f")})),w.set(this,(()=>!!window.descopeBridge||/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent))),E.set(this,(t=>{var i,r,o,n,a,l,d,c,u,h,g,v,m;if(!(null==t?void 0:t.ok)){const s=null===(i=null==t?void 0:t.response)||void 0===i?void 0:i.url,d=`${null===(r=null==t?void 0:t.response)||void 0===r?void 0:r.status} - ${null===(o=null==t?void 0:t.response)||void 0===o?void 0:o.statusText}`;H.__classPrivateFieldGet(this,e,"m",$).call(this,"error",(null==t?void 0:t.error)||{errorCode:ne.FETCH_ERROR_RESPONSE_ERROR_CODE,errorDescription:d,errorMessage:s}),this.loggerWrapper.error((null===(n=null==t?void 0:t.error)||void 0===n?void 0:n.errorDescription)||s,(null===(a=null==t?void 0:t.error)||void 0===a?void 0:a.errorMessage)||d);const c=null===(l=null==t?void 0:t.error)||void 0===l?void 0:l.errorCode;return void(c!==ne.FLOW_REQUESTED_IS_IN_OLD_VERSION_ERROR_CODE&&c!==ne.FLOW_TIMED_OUT_ERROR_CODE&&c!==ne.NONCE_VALIDATION_ERROR_CODE||!this.isRestartOnError||H.__classPrivateFieldGet(this,e,"m",p).call(this))}null===(c=null===(d=t.data)||void 0===d?void 0:d.runnerLogs)||void 0===c||c.forEach((e=>{const{level:t,title:i,log:s}=e;t&&this.loggerWrapper[t]?this.loggerWrapper[t](i,s):this.loggerWrapper.info(i,s)}));const _=null===(g=null===(h=null===(u=t.data)||void 0===u?void 0:u.screen)||void 0===h?void 0:h.state)||void 0===g?void 0:g.errorText;(null===(v=t.data)||void 0===v?void 0:v.error)?this.loggerWrapper.error(`[${t.data.error.code}]: ${t.data.error.description}`,`${_?`${_} - `:""}${t.data.error.message}`):_&&this.loggerWrapper.error(_);const{status:f,authInfo:b,lastAuth:w,action:E,openInNewTabUrl:I}=t.data;if(E!==J.RESPONSE_ACTIONS.poll&&H.__classPrivateFieldGet(this,S,"f").call(this),"completed"===f){this.storeLastAuthenticatedUser&&se.setLastAuth(Object.assign(Object.assign({},w),{lastUsedPerScreen:se.getInFlightLastUsedPerScreen()})),se.clearInFlightLastAuth(this.loggerWrapper);const i=Object.assign({},b);return t.data.output&&Object.keys(t.data.output).length>0&&(i.flowOutput=t.data.output),this.setValidationTrackingExecution(t.data.executionId),ee.clearSsoQueryParams(this.projectId,this.flowId),void H.__classPrivateFieldGet(this,e,"m",$).call(this,"success",i)}this.storeLastAuthenticatedUser&&se.setLastAuth(w,!0),I&&window.open(I,"_blank");const{executionId:P,stepId:R,stepName:O,screen:C,redirect:F,webauthn:y,error:T,samlIdpResponse:A,wsFedIdpResponse:k,nativeResponse:W}=t.data,x=Date.now();E!==J.RESPONSE_ACTIONS.poll?(this.loggerWrapper.info(`Step "${O||`#${R}`}" is ${f}`,"",{screen:C,status:f,stepId:R,stepName:O,action:E,error:T}),(null===(m=C.state)||void 0===m?void 0:m.clientScripts)&&H.__classPrivateFieldSet(this,s,this.loadSdkScripts(C.state.clientScripts),"f"),this.flowState.update({stepId:R,stepName:O,executionId:P,action:E,redirectTo:null==F?void 0:F.url,redirectIsPopup:null==F?void 0:F.isPopup,screenId:null==C?void 0:C.id,screenState:null==C?void 0:C.state,webauthnTransactionId:null==y?void 0:y.transactionId,webauthnOptions:null==y?void 0:y.options,samlIdpResponseUrl:null==A?void 0:A.url,samlIdpResponseSamlResponse:null==A?void 0:A.samlResponse,samlIdpResponseRelayState:null==A?void 0:A.relayState,wsFedIdpResponseUrl:null==k?void 0:k.url,wsFedIdpResponseWresult:null==k?void 0:k.wresult,wsFedIdpResponseWctx:null==k?void 0:k.wctx,nativeResponseType:null==W?void 0:W.type,nativePayload:null==W?void 0:W.payload,reqTimestamp:x})):this.flowState.update({action:E,reqTimestamp:x})})),I.set(this,Q.withMemCache((()=>H.__awaiter(this,void 0,void 0,(function*(){var e;try{const t=yield this.sdk.webauthn.signIn.start("",window.location.origin);return t.ok||this.loggerWrapper.warn("Webauthn start failed",null===(e=null==t?void 0:t.error)||void 0===e?void 0:e.errorMessage),t.data}catch(e){this.loggerWrapper.warn("Webauthn start failed",e.message)}}))))),C.set(this,void 0),F.set(this,void 0),x.set(this,null),G.set(this,Q.leadingDebounce(((t,i,s)=>H.__awaiter(this,void 0,void 0,(function*(){var r;if("true"!==t.getAttribute("loading")&&"true"!==t.getAttribute("disabled")){if("true"===t.getAttribute("formnovalidate")||H.__classPrivateFieldGet(this,e,"m",k).call(this)){const o=null==t?void 0:t.getAttribute("id");H.__classPrivateFieldGet(this,e,"m",M).call(this,t,o,s);const n=H.__classPrivateFieldGet(this,e,"m",N).call(this,t);try{const s=yield H.__classPrivateFieldGet(this,e,"m",W).call(this),n=Q.getElementDescopeAttributes(t);this.nextRequestStatus.update({isLoading:!0});const a=Object.assign(Object.assign(Object.assign({},n),s),{origin:H.__classPrivateFieldGet(this,e,"a",A)}),l=yield i(o,a);this.nextRequestStatus.update({isLoading:!1}),this.captureLastSubmittedLoginId(s,null===(r=null==l?void 0:l.data)||void 0===r?void 0:r.executionId),this.storeCredentials(s)}catch(e){throw n(),e}}}else this.loggerWrapper.debug("Submit already in flight, ignoring")}))))),this.flowState=a,this.setValidationTrackingSender(((e,t)=>H.__awaiter(this,[e,t],void 0,(function*({executionId:e,events:t},{keepalive:i}){const s=yield this.sdk.flow.event(e,t,i);return{ok:s.ok,retryable:s.code>=500||429===s.code}}))))}nativeResume(e,t){var i,s,r,o,n,a;const l=JSON.parse(t);if("oauthWeb"===e||"sso"===e){let e,{exchangeCode:t}=l;if(!t){const r=new URL(l.url);t=null===(i=r.searchParams)||void 0===i?void 0:i.get(J.URL_CODE_PARAM_NAME),e=(null===(s=r.searchParams)||void 0===s?void 0:s.get(J.URL_ERR_PARAM_NAME))||void 0}null===(o=(r=this.nativeCallbacks).complete)||void 0===o||o.call(r,{exchangeCode:t,exchangeError:e,idpInitiated:!0})}else if("magicLink"===e){const e=new URL(l.url),t=e.searchParams.get(J.URL_TOKEN_PARAM_NAME),i=e.searchParams.get(J.URL_RUN_IDS_PARAM_NAME).split("_").pop();H.__classPrivateFieldGet(this,S,"f").call(this),this.flowState.update({token:t,stepId:i,action:void 0})}else if("beforeScreen"===e){const{screenResolve:e}=this.nativeCallbacks;this.nativeCallbacks.screenResolve=null;const{override:t}=l;t||(this.nativeCallbacks.screenNext=null),null==e||e(t)}else if("resumeScreen"===e){const{interactionId:e,form:t}=l,{screenNext:i}=this.nativeCallbacks;this.nativeCallbacks.screenNext=null,null==i||i(e,t)}else null===(a=(n=this.nativeCallbacks).complete)||void 0===a||a.call(n,l)}loadSdkScriptsModules(){const e=this.shadowRoot.querySelectorAll("div[data-script-id]");return Array.from(e).map((e=>e.moduleRes)).filter((e=>!!e))}loadSdkScripts(e){if(!(null==e?void 0:e.length))return null;const t=(e,t)=>i=>{this.dispatchEvent(new CustomEvent("components-context",{detail:{[Q.getScriptResultPath(e.id,e.resultKey)]:i},bubbles:!0,composed:!0})),t(e.id)};this.loggerWrapper.debug(`Preparing to load scripts: ${e.map((e=>e.id)).join(", ")}`);const i=Promise.all(null==e?void 0:e.map((e=>H.__awaiter(this,void 0,void 0,(function*(){var i,s,r;const o=this.shadowRoot.querySelector(`[data-script-id="${e.id}"]`);if(o){this.loggerWrapper.debug("Script already loaded",e.id);const{moduleRes:t}=o;return null===(i=null==t?void 0:t.start)||void 0===i||i.call(t),t}(null===(s=globalThis.descope)||void 0===s?void 0:s[e.id])||(yield this.injectNpmLib("@descope/flow-scripts","1.0.20",`dist/${e.id}.js`));const n=null===(r=globalThis.descope)||void 0===r?void 0:r[e.id];return new Promise(((i,s)=>{try{const s=n(e.initArgs,{baseUrl:this.baseUrl,ref:this},t(e,i),this.loggerWrapper);if(s){const t=document.createElement("div");t.setAttribute("data-script-id",e.id),t.moduleRes=s,this.shadowRoot.appendChild(t);const r=this.nextRequestStatus.subscribe((()=>{var i;this.loggerWrapper.debug("Stopping script",e.id),(null===(i=s.stop)||void 0===i?void 0:i.call(s))&&(this.nextRequestStatus.unsubscribe(r),this.loggerWrapper.debug("Removing script",e.id),this.shadowRoot.removeChild(t))}));"function"==typeof s.present&&i(e.id)}}catch(e){s(e)}}))})))));let s;const r=new Promise((e=>{s=setTimeout((()=>{this.loggerWrapper.warn("SDK scripts loading timeout"),e(!0)}),J.SDK_SCRIPTS_LOAD_TIMEOUT)}));return Promise.race([i,r]).finally((()=>clearTimeout(s)))}get isDismissScreenErrorOnInput(){return"true"===this.getAttribute("dismiss-screen-error-on-input")}init(){var e,t;if(!window.descopeBridge)return this._init();this.lazyInit=this._init,H.__classPrivateFieldSet(this,n,null===(t=null===(e=null===window||void 0===window?void 0:window.descopeBridge)||void 0===e?void 0:e.registerFlow)||void 0===t?void 0:t.call(e,this),"f")}_init(){const t=Object.create(null,{init:{get:()=>super.init}});return H.__awaiter(this,void 0,void 0,(function*(){var i,s;this.shadowRoot.isConnected&&(null===(i=this.flowState)||void 0===i||i.subscribe(this.onFlowChange.bind(this)),H.__classPrivateFieldGet(this,e,"m",u).call(this),window.addEventListener("visibilitychange",H.__classPrivateFieldGet(this,r,"f").visibilitychange)),yield null===(s=t.init)||void 0===s?void 0:s.call(this)}))}disconnectedCallback(){var e,t,s;super.disconnectedCallback(),this.teardownValidationTracking(),H.__classPrivateFieldGet(this,n,"f")&&(null===(t=null===(e=window.descopeBridge)||void 0===e?void 0:e.unregisterFlow)||void 0===t||t.call(e,H.__classPrivateFieldGet(this,n,"f")),H.__classPrivateFieldSet(this,n,void 0,"f")),this.flowState.unsubscribeAll(),this.stepState.unsubscribeAll(),H.__classPrivateFieldGet(this,S,"f").call(this),null===(s=H.__classPrivateFieldGet(this,i,"f"))||void 0===s||s.abort(),H.__classPrivateFieldSet(this,i,null,"f"),window.removeEventListener("visibilitychange",H.__classPrivateFieldGet(this,r,"f").visibilitychange)}getHtmlFilenameWithLocale(e,t){return H.__awaiter(this,void 0,void 0,(function*(){let i;const s=K.getUserLocale(e),r=yield this.getTargetLocales();return r.includes(s.locale)?i=`${t}-${s.locale}.html`:r.includes(s.fallback)&&(i=`${t}-${s.fallback}.html`),i}))}getPageContent(e,t){return H.__awaiter(this,void 0,void 0,(function*(){if(t)try{const{body:e}=yield this.fetchStaticResource(t,"text");return e}catch(i){this.loggerWrapper.error(`Failed to fetch flow page from ${t}. Fallback to url ${e}`,i)}try{const{body:t}=yield this.fetchStaticResource(e,"text");return t}catch(e){this.loggerWrapper.error("Failed to fetch flow page",e.message)}return null}))}onFlowChange(t,r,o){return H.__awaiter(this,void 0,void 0,(function*(){var n,a;const{projectId:l,flowId:c,tenant:u,stepId:h,executionId:p,action:g,screenId:_,screenState:f,redirectTo:S,redirectIsPopup:w,redirectUrl:I,token:P,code:R,isPopup:O,exchangeError:T,webauthnTransactionId:k,webauthnOptions:W,redirectAuthCodeChallenge:x,redirectAuthCallbackUrl:N,redirectAuthBackupCallbackUri:U,redirectAuthInitiator:L,locale:G,samlIdpResponseUrl:D,samlIdpResponseSamlResponse:M,samlIdpResponseRelayState:q,wsFedIdpResponseUrl:V,wsFedIdpResponseWresult:z,wsFedIdpResponseWctx:Y,nativeResponseType:Z,nativePayload:ee,reqTimestamp:re}=t,oe=H.__rest(t,["projectId","flowId","tenant","stepId","executionId","action","screenId","screenState","redirectTo","redirectIsPopup","redirectUrl","token","code","isPopup","exchangeError","webauthnTransactionId","webauthnOptions","redirectAuthCodeChallenge","redirectAuthCallbackUrl","redirectAuthBackupCallbackUri","redirectAuthInitiator","locale","samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState","wsFedIdpResponseUrl","wsFedIdpResponseWresult","wsFedIdpResponseWctx","nativeResponseType","nativePayload","reqTimestamp"]);let ne,ae,le;const de=te.getABTestingKey(),{outboundAppId:ce,outboundAppScopes:ue}=this,he=this.sdk.getLastUserLoginId();o("flowId")&&this.setValidationTrackingEnabled(!1);const pe=yield this.getFlowConfig();H.__classPrivateFieldGet(this,e,"m",y).call(this,pe,p,o);const ge=yield this.getProjectConfig(),ve=Object.entries(ge.flows||{}).reduce(((e,[t,i])=>(e[t]=i.version,e)),{}),me=N&&x?{callbackUrl:N,codeChallenge:x,backupCallbackUri:U}:void 0,_e=this.nativeOptions?{platform:this.nativeOptions.platform,bridgeVersion:this.nativeOptions.bridgeVersion,oauthProvider:this.nativeOptions.oauthProvider,oauthRedirect:this.nativeOptions.oauthRedirect,magicLinkRedirect:this.nativeOptions.magicLinkRedirect,ssoRedirect:this.nativeOptions.ssoRedirect,externalAuthRedirect:this.nativeOptions.externalAuthRedirect}:void 0;let fe={};if(!p){se.clearInFlightLastAuth(this.loggerWrapper);const t=[...pe.clientScripts||[],...pe.sdkScripts||[]];if(pe.conditions){let e=[];({startScreenId:ne,conditionInteractionId:le,startScreenName:ae,clientScripts:e,componentsConfig:fe}=ie.calculateConditions({loginId:he,code:R,token:P,abTestingKey:de,lastAuth:se.getLastAuth(he,this.loggerWrapper)},pe.conditions)),t.push(...e||[])}else pe.condition?({startScreenId:ne,startScreenName:ae,conditionInteractionId:le}=ie.calculateCondition(pe.condition,{loginId:he,code:R,token:P,abTestingKey:de,lastAuth:se.getLastAuth(he,this.loggerWrapper)})):(ae=pe.startScreenName,ne=pe.startScreenId);if(H.__classPrivateFieldSet(this,C,ne,"f"),H.__classPrivateFieldSet(this,F,ae,"f"),H.__classPrivateFieldSet(this,s,this.loadSdkScripts(t),"f"),pe.fingerprintEnabled&&pe.fingerprintKey?yield X.ensureFingerprintIds(pe.fingerprintKey,this.baseUrl):X.clearFingerprintData(),!Q.showFirstScreenOnExecutionInit(ne,oe)){const t=yield this.sdk.flow.start(c,Object.assign(Object.assign(Object.assign(Object.assign({tenant:u,redirectAuth:me},oe),{client:this.client}),I&&{redirectUrl:I}),{lastAuth:se.getLastAuth(he,this.loggerWrapper),abTestingKey:de,locale:K.getUserLocale(G).locale,nativeOptions:_e,outboundAppId:ce,outboundAppScopes:ue}),le,"",ge.componentsVersion,ve,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({origin:H.__classPrivateFieldGet(this,e,"a",A)},this.formConfigValues),R?{exchangeCode:R,idpInitiated:!0}:{}),oe.descopeIdpInitiated&&{idpInitiated:!0}),P?{token:P}:{}),oe.oidcLoginHint?{externalId:oe.oidcLoginHint}:{}));return H.__classPrivateFieldGet(this,E,"f").call(this,t),void("completed"!==(null===(n=null==t?void 0:t.data)||void 0===n?void 0:n.status)&&this.flowState.update({code:void 0,token:void 0}))}}if(this.loggerWrapper.debug("Before popup postmessage send",JSON.stringify({isPopup:O,code:R,exchangeError:T,isCodeChanged:o("code"),isExchangeErrorChanged:o("exchangeError")})),O&&(o("code")&&R||o("exchangeError")&&T))return void H.__classPrivateFieldGet(this,e,"m",B).call(this,p,R,T);if(p&&(o("token")&&P||o("code")&&R||o("exchangeError")&&T)){const t=yield this.sdk.flow.next(p,h,J.CUSTOM_INTERACTIONS.submit,pe.version,ge.componentsVersion,{token:P,exchangeCode:R,exchangeError:T,origin:H.__classPrivateFieldGet(this,e,"a",A)});return H.__classPrivateFieldGet(this,E,"f").call(this,t),void this.flowState.update({token:void 0,code:void 0,exchangeError:void 0})}if(g===J.RESPONSE_ACTIONS.loadForm&&D&&["samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState"].some((e=>o(e)))){if(!M)return void this.loggerWrapper.error("Did not get saml idp params data to load");Q.injectSamlIdpForm(D,M,q||"",Q.submitForm)}if(g===J.RESPONSE_ACTIONS.loadForm&&V&&["wsFedIdpResponseUrl","wsFedIdpResponseWresult","wsFedIdpResponseWctx"].some((e=>o(e)))){if(!z)return void this.loggerWrapper.error("Did not get wsfed idp params data to load");Q.injectWsFedIdpForm(V,z,Y||"",Q.submitForm)}if(g===J.RESPONSE_ACTIONS.redirect&&(o("redirectTo")||o("deferredRedirect"))){if(!S)return void this.loggerWrapper.error("Did not get redirect url");if("no-op"===S)return;if("android"===L&&document.hidden)return void this.flowState.update({deferredRedirect:!0});if(this.loggerWrapper.debug(`Redirect is popup ${w}`),w){this.loggerWrapper.debug("Opening redirect in popup");const t=Q.openCenteredPopup(S,"?",598,700),i=this.shouldUsePopupPostMessage();i&&(t.name=`descope-wc|${window.location.origin}`),this.loggerWrapper.debug("Popup communication method: "+(i?"postMessage":"BroadcastChannel"));let s=!1;const r=e=>{this.loggerWrapper.debug("Received popup message",JSON.stringify(e.data));const t=i?this.popupOrigin:window.location.origin;if(e.origin!==t)return void this.loggerWrapper.debug(`Ignoring message from unexpected origin. received: "${e.origin}", expected: "${t}"`);const{action:r,data:o}=e.data||{};"code"===r&&(s=!0,this.flowState.update({code:o.code,exchangeError:o.exchangeError}))};let o;this.loggerWrapper.debug("Starting popup closed detection");const n=setInterval((()=>{t.closed&&(this.loggerWrapper.debug("Popup closed, dispatching popupclosed event"),clearInterval(n),H.__classPrivateFieldGet(this,e,"m",$).call(this,"popupclosed",{abandoned:!s}),this.loggerWrapper.debug("Cleaning up popup listeners"),null==o||o())}),1e3);if(i)window.addEventListener("message",r),o=()=>{this.loggerWrapper.debug("Cleaning up popup postMessage listener"),window.removeEventListener("message",r)};else{this.loggerWrapper.debug("Creating broadcast channel");const e=new BroadcastChannel(p);e.onmessage=r,o=()=>{this.loggerWrapper.debug("Closing channel"),e.close()}}}else this.handleRedirect(S),this.flowState.update({redirectTo:"no-op"}),H.__classPrivateFieldGet(this,e,"m",$).call(this,"popupclosed",{});return}if(g===J.RESPONSE_ACTIONS.webauthnCreate||g===J.RESPONSE_ACTIONS.webauthnGet){if(!k||!W)return void this.loggerWrapper.error("Did not get webauthn transaction id or options");null===(a=H.__classPrivateFieldGet(this,i,"f"))||void 0===a||a.abort(),H.__classPrivateFieldSet(this,i,null,"f");const t=yield H.__classPrivateFieldGet(this,e,"m",m).call(this,g,W),s=yield this.sdk.flow.next(p,h,J.CUSTOM_INTERACTIONS.submit,pe.version,ge.componentsVersion,Object.assign({transactionId:k},t));H.__classPrivateFieldGet(this,E,"f").call(this,s)}if(g===J.RESPONSE_ACTIONS.nativeBridge)return this.nativeCallbacks.complete=e=>H.__awaiter(this,void 0,void 0,(function*(){const t=yield this.sdk.flow.next(p,h,J.CUSTOM_INTERACTIONS.submit,pe.version,ge.componentsVersion,e);H.__classPrivateFieldGet(this,E,"f").call(this,t)})),H.__classPrivateFieldGet(this,e,"m",d).call(this,Z,ee),void setTimeout((()=>{this.dispatchEvent(new Event("popupclosed"))}),500);if((o("action")||o("deferredPolling"))&&H.__classPrivateFieldGet(this,b,"f").call(this,p,h,pe.version,ge.componentsVersion),!_&&!ne)return void this.loggerWrapper.warn("No screen was found to show");const be=ne||_,Se=yield this.getHtmlFilenameWithLocale(G,be),{oidcLoginHint:we,oidcPrompt:Ee,oidcErrorRedirectUri:Ie,oidcResource:Pe,samlIdpUsername:Re}=oe,Oe={direction:Q.getAnimationDirection(h,r.stepId),screenState:Object.assign(Object.assign({},f),{form:Object.assign(Object.assign({},this.formConfigValues),null==f?void 0:f.form),lastAuth:{loginId:he,name:this.sdk.getLastUserDisplayName()||he},componentsConfig:Object.assign(Object.assign(Object.assign({},pe.componentsConfig),fe),null==f?void 0:f.componentsConfig)}),htmlFilename:`${be}.html`,htmlLocaleFilename:Se,screenId:be,stepName:t.stepName||ae,samlIdpUsername:Re,oidcLoginHint:we,oidcPrompt:Ee,oidcErrorRedirectUri:Ie,oidcResource:Pe,action:g,locale:K.getUserLocale(G).locale},Ce=se.getLastAuth(he,this.loggerWrapper);Q.showFirstScreenOnExecutionInit(ne,oe)?Oe.next=(t,i)=>H.__awaiter(this,void 0,void 0,(function*(){const s=(null==pe?void 0:pe.clientScripts)||[];yield H.__classPrivateFieldGet(this,e,"m",j).call(this,s);const r=yield this.sdk.flow.start(c,Object.assign(Object.assign(Object.assign(Object.assign({tenant:u,redirectAuth:me},oe),{lastAuth:Ce,preview:this.preview,abTestingKey:de,client:this.client}),I&&{redirectUrl:I}),{locale:K.getUserLocale(G).locale,nativeOptions:_e,outboundAppId:ce,outboundAppScopes:ue}),le,t,ge.componentsVersion,ve,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),this.getComponentsContext()),Q.transformScreenInputs(i)),R&&{exchangeCode:R,idpInitiated:!0}),oe.descopeIdpInitiated&&{idpInitiated:!0}),P&&{token:P}),Oe.next.isCustomScreen);return H.__classPrivateFieldGet(this,E,"f").call(this,r),r})):(o("projectId")||o("baseUrl")||o("executionId")||o("stepId"))&&(Oe.next=(t,i)=>H.__awaiter(this,void 0,void 0,(function*(){const s=(null==f?void 0:f.clientScripts)||[];yield H.__classPrivateFieldGet(this,e,"m",j).call(this,s);const r=yield this.sdk.flow.next(p,h,t,pe.version,ge.componentsVersion,Object.assign(Object.assign({},this.getComponentsContext()),Q.transformScreenInputs(i)),Oe.next.isCustomScreen);return H.__classPrivateFieldGet(this,E,"f").call(this,r),r}))),this.loggerWrapper.debug("Got a screen with id",Oe.screenId),yield H.__classPrivateFieldGet(this,e,"m",v).call(this,Oe),this.stepState.update(Oe)}))}onStepChange(t,i){return H.__awaiter(this,void 0,void 0,(function*(){var s,r,o;const{htmlFilename:n,htmlLocaleFilename:a,direction:l,next:d,screenState:c,screenId:u}=t;this.loggerWrapper.debug("Rendering a flow screen"),this.updateScreenUser(null==c?void 0:c.user);const h=document.createElement("template");h.innerHTML=yield this.getPageContent(n,a);const p=h.content.cloneNode(!0),g=this.loadDescopeUiComponents(h);this.sdk.webauthn.helpers.isSupported()?yield H.__classPrivateFieldGet(this,e,"m",R).call(this,p,d):Y.disableWebauthnButtons(p),!t.samlIdpUsername||(null===(s=c.form)||void 0===s?void 0:s.loginId)||(null===(r=c.form)||void 0===r?void 0:r.email)||(c.form||(c.form={}),c.form.loginId=t.samlIdpUsername,c.form.email=t.samlIdpUsername),Y.updateTemplateFromScreenState(p,c,this.formConfig,this.loggerWrapper),this.applyComponentsState(p,null==c?void 0:c.componentsState);const{geo:v}=null!==(o=yield this.getExecutionContext())&&void 0!==o?o:{};Y.setComponentsAutoDetectByGeo(p,v),Y.setComponentsAutoDetectByLocale(p,t.locale);const m=()=>H.__awaiter(this,void 0,void 0,(function*(){var s,r;yield g;const o=this.contentRootElement;Y.setTOTPVariable(o,null===(s=null==c?void 0:c.totp)||void 0===s?void 0:s.image),Y.setNOTPVariable(o,null===(r=null==c?void 0:c.notp)||void 0===r?void 0:r.image),Y.setCssVars(o,p,c.cssVars,this.loggerWrapper),o.replaceChildren(p);const n=!i.htmlFilename;setTimeout((()=>{H.__classPrivateFieldGet(this,e,"m",U).call(this),this.updateUsernameAnchor(),this.validateOnBlur&&Q.handleReportValidityOnBlur(o,(t=>this.trackValidationErrors([t],H.__classPrivateFieldGet(this,e,"a",T)))),Y.updateScreenFromScreenState(o,c),this.initRealtimeConditions(o,c),H.__classPrivateFieldGet(this,e,"m",O).call(this,{isFirstScreen:n,isCustomScreen:!1,stepName:t.stepName}),Q.handleAutoFocus(o,this.autoFocus,n),H.__classPrivateFieldGet(this,e,"m",q).call(this,u)})),H.__classPrivateFieldGet(this,e,"m",V).call(this,d,u);o.querySelector(`[${J.ELEMENT_TYPE_ATTRIBUTE}="polling"]`)&&d(J.CUSTOM_INTERACTIONS.polling,{})}));l?H.__classPrivateFieldGet(this,e,"m",f).call(this,m):m()}))}getInputs(){return Array.from(this.shadowRoot.querySelectorAll(`*:not(slot)[name]:not([${J.DESCOPE_ATTRIBUTE_EXCLUDE_FIELD}])`))}shouldUsePopupPostMessage(){if(!this.popupOrigin)return!1;try{new URL(this.popupOrigin)}catch(e){return!1}return!0}}t=new WeakMap,i=new WeakMap,s=new WeakMap,r=new WeakMap,n=new WeakMap,g=new WeakMap,_=new WeakMap,b=new WeakMap,S=new WeakMap,w=new WeakMap,E=new WeakMap,I=new WeakMap,C=new WeakMap,F=new WeakMap,x=new WeakMap,G=new WeakMap,e=new WeakSet,o=function(){document.hidden||setTimeout((()=>{this.flowState.update({deferredRedirect:!1,deferredPolling:!1})}),300)},a=function(t,i,s){return H.__awaiter(this,void 0,void 0,(function*(){var r;return(null===(r=this.nativeOptions)||void 0===r?void 0:r.bridgeVersion)>=2&&new Promise((r=>{this.nativeCallbacks.screenNext=s,this.nativeCallbacks.screenResolve=r,H.__classPrivateFieldGet(this,e,"m",d).call(this,"beforeScreen",{screen:t,context:i})}))}))},l=function(t){var i;(null===(i=this.nativeOptions)||void 0===i?void 0:i.bridgeVersion)>=2&&H.__classPrivateFieldGet(this,e,"m",d).call(this,"afterScreen",{screen:t})},d=function(t,i){H.__classPrivateFieldGet(this,e,"m",$).call(this,"bridge",{type:t,payload:i})},c=function({errorText:e,errorType:t}){const i=()=>{var i;let s=e;try{s=(null===(i=this.errorTransformer)||void 0===i?void 0:i.call(this,{text:e,type:t}))||e}catch(e){this.loggerWrapper.error("Error transforming error message",e.message)}Y.replaceElementMessage(this.contentRootElement,"error-message",s)};this.addEventListener("screen-updated",i,{once:!0}),i()},u=function(){var t,i,s,r;null===(t=this.stepState)||void 0===t||t.subscribe(this.onStepChange.bind(this),(e=>{var t=e.screenState,i=void 0===t?{}:t,s=H.__rest(i,["errorText","errorType"]),r=H.__rest(e,["screenState"]);return Object.assign(Object.assign({},r),{screenState:s})})),null===(i=this.stepState)||void 0===i||i.subscribe(H.__classPrivateFieldGet(this,e,"m",c).bind(this),(e=>{var t,i;return{errorText:null===(t=null==e?void 0:e.screenState)||void 0===t?void 0:t.errorText,errorType:null===(i=null==e?void 0:e.screenState)||void 0===i?void 0:i.errorType}}),{forceUpdate:!0}),null===(s=this.stepState)||void 0===s||s.subscribe(H.__classPrivateFieldGet(this,e,"m",h).bind(this),(e=>{var t,i;return{errorText:null===(t=null==e?void 0:e.screenState)||void 0===t?void 0:t.errorText,errorType:null===(i=null==e?void 0:e.screenState)||void 0===i?void 0:i.errorType}}),{forceUpdate:!0}),null===(r=this.flowState)||void 0===r||r.subscribe((({screenId:e,executionId:t})=>{var i;try{this.updateTelemetryContext({screenId:e,executionId:t})}catch(e){null===(i=this.logger)||void 0===i||i.error("Error updating telemetry screenId:",e)}}),(e=>({screenId:e.screenId,executionId:e.executionId})))},h=function({errorText:e,errorType:t}){(t||e)&&(this.contentRootElement.querySelectorAll('descope-passcode[data-auto-submit="true"]').forEach((e=>{e.shadowRoot.querySelectorAll("descope-text-field[data-id]").forEach((e=>{e.value=""}))})),Q.handleAutoFocus(this.contentRootElement,this.autoFocus,!1))},p=function(){return H.__awaiter(this,void 0,void 0,(function*(){this.loggerWrapper.debug("Trying to restart the flow");const e=yield this.getComponentsVersion();this.reset();e===(yield this.getComponentsVersion())?(this.loggerWrapper.debug("Components version was not changed, restarting flow"),this.flowState.update({stepId:null,executionId:null})):this.loggerWrapper.error("Components version mismatch, please reload the page")}))},v=function(t){return H.__awaiter(this,void 0,void 0,(function*(){var i;const s=Object.assign(Object.assign({},this.stepState.current),t),{next:r,stepName:o}=s,n=H.__rest(s,["next","stepName"]),l=Q.transformStepStateForCustomScreen(n);let d=yield H.__classPrivateFieldGet(this,e,"m",a).call(this,o,l,r);d||(d=Boolean(yield null===(i=this.onScreenUpdate)||void 0===i?void 0:i.call(this,o,l,r,this)));const c=!this.stepState.current.htmlFilename;if(H.__classPrivateFieldGet(this,_,"f").call(this,d),r&&(r.isCustomScreen=d),H.__classPrivateFieldGet(this,g,"f")!==d){const[t,i]=["flow","custom"].sort((()=>d?-1:1));this.loggerWrapper.debug(`Switching from ${i} screen to ${t} screen`),H.__classPrivateFieldSet(this,g,d,"f"),d?this.stepState.unsubscribeAll():H.__classPrivateFieldGet(this,e,"m",u).call(this)}d?(this.loggerWrapper.debug("Showing a custom screen"),H.__classPrivateFieldGet(this,e,"m",O).call(this,{isFirstScreen:c,isCustomScreen:d,stepName:t.stepName}),this.disableKeyPressHandler()):this.handleKeyPress(),this.stepState.forceUpdate=d}))},m=function(e,t){return H.__awaiter(this,void 0,void 0,(function*(){const i=new AbortController;try{const s=e===J.RESPONSE_ACTIONS.webauthnCreate?this.sdk.webauthn.helpers.create(t,i):this.sdk.webauthn.helpers.get(t,i),r=yield Q.timeoutPromise(J.WEBAUTHN_TIMEOUT,s,ae);return r!==ae?{response:r}:(i.abort(),this.loggerWrapper.warn(`WebAuthn operation timed out after ${J.WEBAUTHN_TIMEOUT}ms`),{failure:"AbortError",failureReason:"aborted",failureMessage:"Passkey operation timed out"})}catch(e){return"InvalidStateError"===e.name?this.loggerWrapper.warn("WebAuthn operation failed",e.message):"NotAllowedError"!==e.name&&this.loggerWrapper.error(e.message),{failure:e.name,failureReason:e.reason,failureMessage:e.message}}}))},f=function(e){this.contentRootElement.addEventListener("transitionend",(()=>{this.loggerWrapper.debug("page switch transition end"),this.contentRootElement.classList.remove("fade-out"),e()}),{once:!0}),this.loggerWrapper.debug("page switch transition start"),this.contentRootElement.classList.add("fade-out")},P=function(e){const t=e.getAttribute("name");if(!["email"].includes(t)){const i=`user-${t}`;e.setAttribute("name",i),e.addEventListener("input",(()=>{e.setAttribute("name",e.value?t:i)}))}},R=function(t,s){return H.__awaiter(this,void 0,void 0,(function*(){var r;null===(r=H.__classPrivateFieldGet(this,i,"f"))||void 0===r||r.abort();const o=t.querySelector('*[autocomplete="webauthn"]');if(o&&(yield Z.isConditionalLoginSupported())){const{options:t,transactionId:r}=(yield H.__classPrivateFieldGet(this,I,"f").call(this))||{};t&&r&&(H.__classPrivateFieldGet(this,e,"m",P).call(this,o),H.__classPrivateFieldSet(this,i,new AbortController,"f"),this.sdk.webauthn.helpers.conditional(t,H.__classPrivateFieldGet(this,i,"f")).then((e=>H.__awaiter(this,void 0,void 0,(function*(){s(o.id,{transactionId:r,response:e})})))).catch((e=>{"AbortError"!==e.name&&this.loggerWrapper.error("Conditional login failed",e.message)})))}}))},O=function({isFirstScreen:t,isCustomScreen:i,stepName:s}){t&&H.__classPrivateFieldGet(this,e,"m",$).call(this,"ready",{}),i||H.__classPrivateFieldGet(this,e,"m",l).call(this,s),H.__classPrivateFieldGet(this,e,"m",$).call(this,"page-updated",{screenName:s}),H.__classPrivateFieldGet(this,e,"m",$).call(this,"screen-updated",{screenName:s})},y=function(e,t,i){this.setValidationTrackingEnabled(!!e.clientValidationTrackingEnabled),t&&i("executionId")&&this.setValidationTrackingExecution(t)},T=function(){var e,t,i,s,r,o,n;const a=null===(e=this.flowState)||void 0===e?void 0:e.current;return(null==a?void 0:a.executionId)?{executionId:a.executionId,screenId:a.screenId,screenName:(null===(n=null===(o=this.stepState)||void 0===o?void 0:o.current)||void 0===n?void 0:n.stepName)||a.stepName}:{executionId:void 0,screenId:null!==(t=H.__classPrivateFieldGet(this,C,"f"))&&void 0!==t?t:null==a?void 0:a.screenId,screenName:null!==(i=H.__classPrivateFieldGet(this,F,"f"))&&void 0!==i?i:(null===(r=null===(s=this.stepState)||void 0===s?void 0:s.current)||void 0===r?void 0:r.stepName)||(null==a?void 0:a.stepName)}},A=function(){var e;return(null===(e=this.nativeOptions)||void 0===e?void 0:e.origin)||window.location.origin},k=function(){let t=!0;const i=[];return Array.from(this.shadowRoot.querySelectorAll("*[name]")).reverse().forEach((e=>{var s,r,o;"slot"===e.localName||re.isHiddenByCondition(e,this.contentRootElement)||(null===(s=e.reportValidity)||void 0===s||s.call(e),e.validity&&!e.validity.valid&&i.push(e),t&&(t=null===(o=null===(r=e.checkValidity)||void 0===r?void 0:r.call(e))||void 0===o||o))})),i.length&&this.trackValidationErrors(i,H.__classPrivateFieldGet(this,e,"a",T)),t},W=function(){return H.__awaiter(this,void 0,void 0,(function*(){const e=this.getInputs();return(yield Promise.all(e.map((e=>H.__awaiter(this,void 0,void 0,(function*(){return{name:e.getAttribute("name"),value:e.value}})))))).reduce(((e,t)=>Object.assign(Object.assign({},e),{[t.name]:t.value})),{})}))},N=function(e){var t,i;const r=Array.from(this.contentRootElement.querySelectorAll(':not([disabled]), [disabled="false"]')).filter((t=>t!==e)),o=(null===(i=null===(t=this.flowState.current)||void 0===t?void 0:t.screenState)||void 0===i?void 0:i.clientScripts)||[];e.setAttribute("loading","true"),r.forEach((e=>e.setAttribute("disabled","true")));const n=()=>{e.removeAttribute("loading"),r.forEach((e=>{e.removeAttribute("disabled")}))},a=e=>H.__awaiter(this,void 0,void 0,(function*(){var t;this.loggerWrapper.debug("Restoring components state"),this.removeEventListener("popupclosed",a);if(!0===(null===(t=null==e?void 0:e.detail)||void 0===t?void 0:t.abandoned)&&o.length)return H.__classPrivateFieldSet(this,s,(()=>H.__awaiter(this,void 0,void 0,(function*(){try{yield this.loadSdkScripts(o)}catch(e){this.loggerWrapper.warn("Failed to refresh client scripts on popup close",null==e?void 0:e.message)}})))(),"f"),void n();n();const i=yield this.getFlowConfig(),r=[...i.clientScripts||[],...i.sdkScripts||[]];this.loadSdkScripts(r)})),l=()=>{var e;window.removeEventListener("pageshow",H.__classPrivateFieldGet(this,x,"f")),H.__classPrivateFieldSet(this,x,(e=>{e.persisted&&(this.logger.debug("Page was loaded from cache, restoring components state"),a())}),"f"),window.addEventListener("pageshow",H.__classPrivateFieldGet(this,x,"f"),{once:!0});const t=null===(e=this.stepState)||void 0===e?void 0:e.subscribe(((e,i)=>{e===i&&a(),this.removeEventListener("popupclosed",a),this.stepState.unsubscribe(t)}),(e=>e.screenId),{forceUpdate:!0})},d=this.nextRequestStatus.subscribe((({isLoading:e})=>{e?this.addEventListener("popupclosed",a,{once:!0}):(this.nextRequestStatus.unsubscribe(d),"success"===this.flowStatus?(this.removeEventListener("popupclosed",a),n()):l())}));return n},U=function(){Q.clearPreviousExternalInputs();this.contentRootElement.querySelectorAll('[external-input="true"]').forEach((t=>H.__classPrivateFieldGet(this,e,"m",L).call(this,t)))},L=function(e){if(!e)return;e.querySelectorAll("input").forEach((t=>{const i=t.getAttribute("slot"),s=`input-${e.id}-${i}`,r=document.createElement("slot");r.setAttribute("name",s),r.setAttribute("slot",i),e.appendChild(r),t.setAttribute("slot",s),this.appendChild(t)}))},j=function(e){return H.__awaiter(this,void 0,void 0,(function*(){if(H.__classPrivateFieldGet(this,s,"f")){this.loggerWrapper.debug("Waiting for sdk scripts to load");const e=Date.now();yield H.__classPrivateFieldGet(this,s,"f"),this.loggerWrapper.debug("Sdk scripts loaded for",(Date.now()-e).toString())}const t=this.loadSdkScriptsModules(),i=e.map((e=>e.id));for(const e of t)if(i.includes(e.id))try{if("function"==typeof e.present){(yield e.present())||this.loggerWrapper.debug(`Sdk script ${e.id} was cancelled`)}}catch(t){this.loggerWrapper.error(`Failed to present ${e.id} script module`,t.message)}const r=[];for(const e of t)"function"==typeof e.refresh&&r.push(e.refresh());if(r.length>0)try{yield Q.timeoutPromise(J.SDK_SCRIPTS_LOAD_TIMEOUT,Promise.all(r),null)}catch(e){this.loggerWrapper.error("Failed to refresh script module",e.message)}}))},D=function(e,t){this.contentRootElement.querySelectorAll('descope-passcode[data-auto-submit="true"]').forEach((i=>{i.addEventListener("input",(()=>{var s;(null===(s=i.checkValidity)||void 0===s?void 0:s.call(i))&&H.__classPrivateFieldGet(this,G,"f").call(this,i,e,t)}))}))},M=function(e,t,i){t&&i&&"true"===e.getAttribute(J.DESCOPE_ATTRIBUTE_OPT_IN_LAST_USED)&&se.updateLastUsedPerScreen(i,t,this.loggerWrapper)},q=function(e){var t;const i=this.sdk.getLastUserLoginId(),s=null===(t=se.getLastAuth(i,this.loggerWrapper).lastUsedPerScreen)||void 0===t?void 0:t[e];if(!s)return;const r=this.contentRootElement.querySelector(J.DESCOPE_LAST_AUTH_BADGE_COMPONENT),o=this.contentRootElement.querySelector(`#${CSS.escape(s)}`);r&&o&&(o.replaceWith(r),r.appendChild(o))},V=function(t,i){this.contentRootElement.querySelectorAll(`descope-button:not([${J.DESCOPE_ATTRIBUTE_EXCLUDE_NEXT_BUTTON}]), [data-type="button"]:not([${J.DESCOPE_ATTRIBUTE_EXCLUDE_NEXT_BUTTON}]`).forEach((e=>{e.onclick=()=>{H.__classPrivateFieldGet(this,G,"f").call(this,e,t,i)}})),H.__classPrivateFieldGet(this,e,"m",D).call(this,t,i),this.isDismissScreenErrorOnInput&&this.contentRootElement.querySelectorAll(`*[name]:not([${J.DESCOPE_ATTRIBUTE_EXCLUDE_FIELD}])`).forEach((e=>{e.addEventListener("input",(()=>{this.stepState.update((e=>Object.assign(Object.assign({},e),{screenState:Object.assign(Object.assign({},e.screenState),{errorText:"",errorType:""})})))}))}))},$=function(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t}))},B=function(e,t,i){var s;const[r,o]=(null===(s=window.name)||void 0===s?void 0:s.split("|"))||[],n={data:{code:t,exchangeError:i},action:"code"};if("descope-wc"===r&&o){this.loggerWrapper.debug("Using postMessage fallback to notify opener in origin",o);try{window.opener.postMessage(n,o)}catch(e){this.loggerWrapper.error("Failed to send postMessage fallback (likely COOP isolation)",null==e?void 0:e.message)}}else{this.loggerWrapper.debug("Creating popup channel",e);const t=new BroadcastChannel(e);t.postMessage(n),t.close()}try{window.close()}catch(e){}},le.bridgeVersion=3,module.exports=le;
1
+ "use strict";var e,t,i,s,r,o,n,a,l,d,c,u,h,p,g,v,m,_,f,b,S,w,E,I,P,R,O,C,F,y,T,A,k,W,x,N,U,L,G,j,D,M,q,V,$,B,H=require("tslib"),K=require("@descope/sdk-helpers"),X=require("@descope/web-js-sdk"),J=require("../constants/index.js"),Q=require("../helpers/helpers.js"),z=require("../helpers/state.js"),Y=require("../helpers/templates.js"),Z=require("../helpers/webauthn.js"),ee=require("../helpers/oidcSession.js"),te=require("../helpers/abTestingKey.js"),ie=require("../helpers/conditions.js"),se=require("../helpers/lastAuth.js"),re=require("../helpers/realtime-conditions/applier.js"),oe=require("./BaseDescopeWc.js"),ne=require("../constants/general.js");const ae="__descope_webauthn_timed_out__";class le extends oe{static set sdkConfigOverrides(e){oe.sdkConfigOverrides=e}static get sdkConfigOverrides(){return oe.sdkConfigOverrides}constructor(){const a=new z({deferredRedirect:!1,deferredPolling:!1});super(a.update.bind(a)),e.add(this),this.stepState=new z({}),t.set(this,void 0),i.set(this,null),s.set(this,null),r.set(this,{visibilitychange:H.__classPrivateFieldGet(this,e,"m",o).bind(this)}),this.bridgeVersion=le.bridgeVersion,n.set(this,void 0),this.nativeCallbacks={},g.set(this,!1),this.handleRedirect=e=>{window.location.assign(e)},_.set(this,(t=>{const i=()=>{this.contentRootElement.classList.toggle("hidden",t),this.slotElement.classList.toggle("hidden",!t),t&&(this.contentRootElement.innerHTML="")};t&&this.contentRootElement.hasChildNodes()?H.__classPrivateFieldGet(this,e,"m",f).call(this,i):i()})),b.set(this,((e,i,s,r,o=!1)=>{const n=[ne.FLOW_TIMED_OUT_ERROR_CODE,ne.POLLING_STATUS_NOT_FOUND_ERROR_CODE,ne.NONCE_VALIDATION_ERROR_CODE];if(this.flowState.current.action===J.RESPONSE_ACTIONS.poll){if(H.__classPrivateFieldGet(this,w,"f").call(this)&&document.hidden)return this.logger.debug("polling - Deferring polling until in foreground"),void this.flowState.update({deferredPolling:!0});this.logger.debug("polling - Scheduling polling request");const a=Date.now(),l=o?500:2e3;H.__classPrivateFieldSet(this,t,setTimeout((()=>H.__awaiter(this,void 0,void 0,(function*(){var t,d;this.logger.debug("polling - Calling next");const c=this.sdk.flow.next(e,i,J.CUSTOM_INTERACTIONS.polling,s,r,{}),u=document.hidden&&!o&&Date.now()-a>l+500;let h;u&&this.logger.debug("polling - The polling seems to be throttled");try{const e=u?1e3:6e3;h=yield Q.timeoutPromise(e,c)}catch(t){return this.logger.warn(`polling - The ${u?"throttled fetch":"fetch"} call timed out or was aborted`),void H.__classPrivateFieldGet(this,b,"f").call(this,e,i,s,r,u)}if((null===(t=null==h?void 0:h.error)||void 0===t?void 0:t.errorCode)===ne.FETCH_EXCEPTION_ERROR_CODE)return this.logger.debug("polling - Got a generic error due to exception in fetch call"),void H.__classPrivateFieldGet(this,b,"f").call(this,e,i,s,r);this.logger.debug("polling - Got a response"),(null==h?void 0:h.error)&&this.logger.debug("polling - Response has an error",JSON.stringify(h.error,null,4)),(null===(d=null==h?void 0:h.error)||void 0===d?void 0:d.errorCode)&&n.includes(h.error.errorCode)?this.logger.debug("polling - Stopping polling due to error"):H.__classPrivateFieldGet(this,b,"f").call(this,e,i,s,r),H.__classPrivateFieldGet(this,E,"f").call(this,h)}))),l),"f")}})),S.set(this,(()=>{clearTimeout(H.__classPrivateFieldGet(this,t,"f")),H.__classPrivateFieldSet(this,t,null,"f")})),w.set(this,(()=>!!window.descopeBridge||/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent))),E.set(this,(t=>{var i,r,o,n,a,l,d,c,u,h,g,v,m;if(!(null==t?void 0:t.ok)){const s=null===(i=null==t?void 0:t.response)||void 0===i?void 0:i.url,d=`${null===(r=null==t?void 0:t.response)||void 0===r?void 0:r.status} - ${null===(o=null==t?void 0:t.response)||void 0===o?void 0:o.statusText}`;H.__classPrivateFieldGet(this,e,"m",$).call(this,"error",(null==t?void 0:t.error)||{errorCode:ne.FETCH_ERROR_RESPONSE_ERROR_CODE,errorDescription:d,errorMessage:s}),this.loggerWrapper.error((null===(n=null==t?void 0:t.error)||void 0===n?void 0:n.errorDescription)||s,(null===(a=null==t?void 0:t.error)||void 0===a?void 0:a.errorMessage)||d);const c=null===(l=null==t?void 0:t.error)||void 0===l?void 0:l.errorCode;return void(c!==ne.FLOW_REQUESTED_IS_IN_OLD_VERSION_ERROR_CODE&&c!==ne.FLOW_TIMED_OUT_ERROR_CODE&&c!==ne.NONCE_VALIDATION_ERROR_CODE||!this.isRestartOnError||H.__classPrivateFieldGet(this,e,"m",p).call(this))}null===(c=null===(d=t.data)||void 0===d?void 0:d.runnerLogs)||void 0===c||c.forEach((e=>{const{level:t,title:i,log:s}=e;t&&this.loggerWrapper[t]?this.loggerWrapper[t](i,s):this.loggerWrapper.info(i,s)}));const _=null===(g=null===(h=null===(u=t.data)||void 0===u?void 0:u.screen)||void 0===h?void 0:h.state)||void 0===g?void 0:g.errorText;(null===(v=t.data)||void 0===v?void 0:v.error)?this.loggerWrapper.error(`[${t.data.error.code}]: ${t.data.error.description}`,`${_?`${_} - `:""}${t.data.error.message}`):_&&this.loggerWrapper.error(_);const{status:f,authInfo:b,lastAuth:w,action:E,openInNewTabUrl:I}=t.data;if(E!==J.RESPONSE_ACTIONS.poll&&H.__classPrivateFieldGet(this,S,"f").call(this),"completed"===f){this.storeLastAuthenticatedUser&&se.setLastAuth(Object.assign(Object.assign({},w),{lastUsedPerScreen:se.getInFlightLastUsedPerScreen()})),se.clearInFlightLastAuth(this.loggerWrapper);const i=Object.assign({},b);return t.data.output&&Object.keys(t.data.output).length>0&&(i.flowOutput=t.data.output),this.setValidationTrackingExecution(t.data.executionId),ee.clearSsoQueryParams(this.projectId,this.flowId),void H.__classPrivateFieldGet(this,e,"m",$).call(this,"success",i)}this.storeLastAuthenticatedUser&&se.setLastAuth(w,!0),I&&window.open(I,"_blank");const{executionId:P,stepId:R,stepName:O,screen:C,redirect:F,webauthn:y,error:T,samlIdpResponse:A,wsFedIdpResponse:k,nativeResponse:W}=t.data,x=Date.now();E!==J.RESPONSE_ACTIONS.poll?(this.loggerWrapper.info(`Step "${O||`#${R}`}" is ${f}`,"",{screen:C,status:f,stepId:R,stepName:O,action:E,error:T}),(null===(m=C.state)||void 0===m?void 0:m.clientScripts)&&H.__classPrivateFieldSet(this,s,this.loadSdkScripts(C.state.clientScripts),"f"),this.flowState.update({stepId:R,stepName:O,executionId:P,action:E,redirectTo:null==F?void 0:F.url,redirectIsPopup:null==F?void 0:F.isPopup,screenId:null==C?void 0:C.id,screenState:null==C?void 0:C.state,webauthnTransactionId:null==y?void 0:y.transactionId,webauthnOptions:null==y?void 0:y.options,samlIdpResponseUrl:null==A?void 0:A.url,samlIdpResponseSamlResponse:null==A?void 0:A.samlResponse,samlIdpResponseRelayState:null==A?void 0:A.relayState,wsFedIdpResponseUrl:null==k?void 0:k.url,wsFedIdpResponseWresult:null==k?void 0:k.wresult,wsFedIdpResponseWctx:null==k?void 0:k.wctx,nativeResponseType:null==W?void 0:W.type,nativePayload:null==W?void 0:W.payload,reqTimestamp:x})):this.flowState.update({action:E,reqTimestamp:x})})),I.set(this,Q.withMemCache((()=>H.__awaiter(this,void 0,void 0,(function*(){var e;try{const t=yield this.sdk.webauthn.signIn.start("",window.location.origin);return t.ok||this.loggerWrapper.warn("Webauthn start failed",null===(e=null==t?void 0:t.error)||void 0===e?void 0:e.errorMessage),t.data}catch(e){this.loggerWrapper.warn("Webauthn start failed",e.message)}}))))),C.set(this,void 0),F.set(this,void 0),x.set(this,null),G.set(this,Q.leadingDebounce(((t,i,s)=>H.__awaiter(this,void 0,void 0,(function*(){var r;if("true"!==t.getAttribute("loading")&&"true"!==t.getAttribute("disabled")){if("true"===t.getAttribute("formnovalidate")||H.__classPrivateFieldGet(this,e,"m",k).call(this)){const o=null==t?void 0:t.getAttribute("id");H.__classPrivateFieldGet(this,e,"m",M).call(this,t,o,s);const n=H.__classPrivateFieldGet(this,e,"m",N).call(this,t);try{const s=yield H.__classPrivateFieldGet(this,e,"m",W).call(this),n=Q.getElementDescopeAttributes(t);this.nextRequestStatus.update({isLoading:!0});const a=Object.assign(Object.assign(Object.assign({},n),s),{origin:H.__classPrivateFieldGet(this,e,"a",A)}),l=yield i(o,a);this.nextRequestStatus.update({isLoading:!1}),this.captureLastSubmittedLoginId(s,null===(r=null==l?void 0:l.data)||void 0===r?void 0:r.executionId),this.storeCredentials(s)}catch(e){throw n(),e}}}else this.loggerWrapper.debug("Submit already in flight, ignoring")}))))),this.flowState=a,this.setValidationTrackingSender(((e,t)=>H.__awaiter(this,[e,t],void 0,(function*({executionId:e,events:t},{keepalive:i}){const s=yield this.sdk.flow.event(e,t,i);return{ok:s.ok,retryable:s.code>=500||429===s.code}}))))}nativeResume(e,t){var i,s,r,o,n,a;const l=JSON.parse(t);if("oauthWeb"===e||"sso"===e){let e,{exchangeCode:t}=l;if(!t){const r=new URL(l.url);t=null===(i=r.searchParams)||void 0===i?void 0:i.get(J.URL_CODE_PARAM_NAME),e=(null===(s=r.searchParams)||void 0===s?void 0:s.get(J.URL_ERR_PARAM_NAME))||void 0}null===(o=(r=this.nativeCallbacks).complete)||void 0===o||o.call(r,{exchangeCode:t,exchangeError:e,idpInitiated:!0})}else if("magicLink"===e){const e=new URL(l.url),t=e.searchParams.get(J.URL_TOKEN_PARAM_NAME),i=e.searchParams.get(J.URL_RUN_IDS_PARAM_NAME).split("_").pop();H.__classPrivateFieldGet(this,S,"f").call(this),this.flowState.update({token:t,stepId:i,action:void 0})}else if("beforeScreen"===e){const{screenResolve:e}=this.nativeCallbacks;this.nativeCallbacks.screenResolve=null;const{override:t}=l;t||(this.nativeCallbacks.screenNext=null),null==e||e(t)}else if("resumeScreen"===e){const{interactionId:e,form:t}=l,{screenNext:i}=this.nativeCallbacks;this.nativeCallbacks.screenNext=null,null==i||i(e,t)}else null===(a=(n=this.nativeCallbacks).complete)||void 0===a||a.call(n,l)}loadSdkScriptsModules(){const e=this.shadowRoot.querySelectorAll("div[data-script-id]");return Array.from(e).map((e=>e.moduleRes)).filter((e=>!!e))}loadSdkScripts(e){if(!(null==e?void 0:e.length))return null;const t=(e,t)=>i=>{this.dispatchEvent(new CustomEvent("components-context",{detail:{[Q.getScriptResultPath(e.id,e.resultKey)]:i},bubbles:!0,composed:!0})),t(e.id)};this.loggerWrapper.debug(`Preparing to load scripts: ${e.map((e=>e.id)).join(", ")}`);const i=Promise.all(null==e?void 0:e.map((e=>H.__awaiter(this,void 0,void 0,(function*(){var i,s,r;const o=this.shadowRoot.querySelector(`[data-script-id="${e.id}"]`);if(o){this.loggerWrapper.debug("Script already loaded",e.id);const{moduleRes:t}=o;return null===(i=null==t?void 0:t.start)||void 0===i||i.call(t),t}(null===(s=globalThis.descope)||void 0===s?void 0:s[e.id])||(yield this.injectNpmLib("@descope/flow-scripts","1.0.20",`dist/${e.id}.js`));const n=null===(r=globalThis.descope)||void 0===r?void 0:r[e.id];return new Promise(((i,s)=>{try{const s=n(e.initArgs,{baseUrl:this.baseUrl,ref:this},t(e,i),this.loggerWrapper);if(s){const t=document.createElement("div");t.setAttribute("data-script-id",e.id),t.moduleRes=s,this.shadowRoot.appendChild(t);const r=this.nextRequestStatus.subscribe((()=>{var i;this.loggerWrapper.debug("Stopping script",e.id),(null===(i=s.stop)||void 0===i?void 0:i.call(s))&&(this.nextRequestStatus.unsubscribe(r),this.loggerWrapper.debug("Removing script",e.id),this.shadowRoot.removeChild(t))}));"function"==typeof s.present&&i(e.id)}}catch(e){s(e)}}))})))));let s;const r=new Promise((e=>{s=setTimeout((()=>{this.loggerWrapper.warn("SDK scripts loading timeout"),e(!0)}),J.SDK_SCRIPTS_LOAD_TIMEOUT)}));return Promise.race([i,r]).finally((()=>clearTimeout(s)))}get isDismissScreenErrorOnInput(){return"true"===this.getAttribute("dismiss-screen-error-on-input")}init(){var e,t;if(!window.descopeBridge)return this._init();this.lazyInit=this._init,H.__classPrivateFieldSet(this,n,null===(t=null===(e=null===window||void 0===window?void 0:window.descopeBridge)||void 0===e?void 0:e.registerFlow)||void 0===t?void 0:t.call(e,this),"f")}_init(){const t=Object.create(null,{init:{get:()=>super.init}});return H.__awaiter(this,void 0,void 0,(function*(){var i,s;this.shadowRoot.isConnected&&(null===(i=this.flowState)||void 0===i||i.subscribe(this.onFlowChange.bind(this)),H.__classPrivateFieldGet(this,e,"m",u).call(this),window.addEventListener("visibilitychange",H.__classPrivateFieldGet(this,r,"f").visibilitychange)),yield null===(s=t.init)||void 0===s?void 0:s.call(this)}))}disconnectedCallback(){var e,t,s;super.disconnectedCallback(),this.teardownValidationTracking(),H.__classPrivateFieldGet(this,n,"f")&&(null===(t=null===(e=window.descopeBridge)||void 0===e?void 0:e.unregisterFlow)||void 0===t||t.call(e,H.__classPrivateFieldGet(this,n,"f")),H.__classPrivateFieldSet(this,n,void 0,"f")),this.flowState.unsubscribeAll(),this.stepState.unsubscribeAll(),H.__classPrivateFieldGet(this,S,"f").call(this),null===(s=H.__classPrivateFieldGet(this,i,"f"))||void 0===s||s.abort(),H.__classPrivateFieldSet(this,i,null,"f"),window.removeEventListener("visibilitychange",H.__classPrivateFieldGet(this,r,"f").visibilitychange)}getHtmlFilenameWithLocale(e,t){return H.__awaiter(this,void 0,void 0,(function*(){let i;const s=K.getUserLocale(e),r=yield this.getTargetLocales();return r.includes(s.locale)?i=`${t}-${s.locale}.html`:r.includes(s.fallback)&&(i=`${t}-${s.fallback}.html`),i}))}getPageContent(e,t){return H.__awaiter(this,void 0,void 0,(function*(){if(t)try{const{body:e}=yield this.fetchStaticResource(t,"text");return e}catch(i){this.loggerWrapper.error(`Failed to fetch flow page from ${t}. Fallback to url ${e}`,i)}try{const{body:t}=yield this.fetchStaticResource(e,"text");return t}catch(e){this.loggerWrapper.error("Failed to fetch flow page",e.message)}return null}))}onFlowChange(t,r,o){return H.__awaiter(this,void 0,void 0,(function*(){var n,a;const{projectId:l,flowId:c,tenant:u,stepId:h,executionId:p,action:g,screenId:_,screenState:f,redirectTo:S,redirectIsPopup:w,redirectUrl:I,token:P,code:R,isPopup:O,exchangeError:T,webauthnTransactionId:k,webauthnOptions:W,redirectAuthCodeChallenge:x,redirectAuthCallbackUrl:N,redirectAuthBackupCallbackUri:U,redirectAuthInitiator:L,locale:G,samlIdpResponseUrl:D,samlIdpResponseSamlResponse:M,samlIdpResponseRelayState:q,wsFedIdpResponseUrl:V,wsFedIdpResponseWresult:z,wsFedIdpResponseWctx:Y,nativeResponseType:Z,nativePayload:ee,reqTimestamp:re}=t,oe=H.__rest(t,["projectId","flowId","tenant","stepId","executionId","action","screenId","screenState","redirectTo","redirectIsPopup","redirectUrl","token","code","isPopup","exchangeError","webauthnTransactionId","webauthnOptions","redirectAuthCodeChallenge","redirectAuthCallbackUrl","redirectAuthBackupCallbackUri","redirectAuthInitiator","locale","samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState","wsFedIdpResponseUrl","wsFedIdpResponseWresult","wsFedIdpResponseWctx","nativeResponseType","nativePayload","reqTimestamp"]);let ne,ae,le;const de=te.getABTestingKey(),{outboundAppId:ce,outboundAppScopes:ue}=this,he=this.sdk.getLastUserLoginId();o("flowId")&&this.setValidationTrackingEnabled(!1);const pe=yield this.getFlowConfig();H.__classPrivateFieldGet(this,e,"m",y).call(this,pe,p,o);const ge=yield this.getProjectConfig(),ve=Object.entries(ge.flows||{}).reduce(((e,[t,i])=>(e[t]=i.version,e)),{}),me=N&&x?{callbackUrl:N,codeChallenge:x,backupCallbackUri:U}:void 0,_e=this.nativeOptions?{platform:this.nativeOptions.platform,bridgeVersion:this.nativeOptions.bridgeVersion,oauthProvider:this.nativeOptions.oauthProvider,oauthRedirect:this.nativeOptions.oauthRedirect,magicLinkRedirect:this.nativeOptions.magicLinkRedirect,ssoRedirect:this.nativeOptions.ssoRedirect,externalAuthRedirect:this.nativeOptions.externalAuthRedirect}:void 0;let fe={};if(!p){se.clearInFlightLastAuth(this.loggerWrapper);const t=[...pe.clientScripts||[],...pe.sdkScripts||[]];if(pe.conditions){let e=[];({startScreenId:ne,conditionInteractionId:le,startScreenName:ae,clientScripts:e,componentsConfig:fe}=ie.calculateConditions({loginId:he,code:R,token:P,abTestingKey:de,lastAuth:se.getLastAuth(he,this.loggerWrapper)},pe.conditions)),t.push(...e||[])}else pe.condition?({startScreenId:ne,startScreenName:ae,conditionInteractionId:le}=ie.calculateCondition(pe.condition,{loginId:he,code:R,token:P,abTestingKey:de,lastAuth:se.getLastAuth(he,this.loggerWrapper)})):(ae=pe.startScreenName,ne=pe.startScreenId);if(H.__classPrivateFieldSet(this,C,ne,"f"),H.__classPrivateFieldSet(this,F,ae,"f"),H.__classPrivateFieldSet(this,s,this.loadSdkScripts(t),"f"),pe.fingerprintEnabled&&pe.fingerprintKey?yield X.ensureFingerprintIds(pe.fingerprintKey,this.baseUrl):X.clearFingerprintData(),!Q.showFirstScreenOnExecutionInit(ne,oe)){const t=yield this.sdk.flow.start(c,Object.assign(Object.assign(Object.assign(Object.assign({tenant:u,redirectAuth:me},oe),{client:this.client}),I&&{redirectUrl:I}),{lastAuth:se.getLastAuth(he,this.loggerWrapper),abTestingKey:de,locale:K.getUserLocale(G).locale,nativeOptions:_e,outboundAppId:ce,outboundAppScopes:ue}),le,"",ge.componentsVersion,ve,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({origin:H.__classPrivateFieldGet(this,e,"a",A)},this.formConfigValues),R?{exchangeCode:R,idpInitiated:!0}:{}),oe.descopeIdpInitiated&&{idpInitiated:!0}),P?{token:P}:{}),oe.oidcLoginHint?{externalId:oe.oidcLoginHint}:{}));return H.__classPrivateFieldGet(this,E,"f").call(this,t),void("completed"!==(null===(n=null==t?void 0:t.data)||void 0===n?void 0:n.status)&&this.flowState.update({code:void 0,token:void 0}))}}if(this.loggerWrapper.debug("Before popup postmessage send",JSON.stringify({isPopup:O,code:R,exchangeError:T,isCodeChanged:o("code"),isExchangeErrorChanged:o("exchangeError")})),O&&(o("code")&&R||o("exchangeError")&&T))return void H.__classPrivateFieldGet(this,e,"m",B).call(this,p,R,T);if(p&&(o("token")&&P||o("code")&&R||o("exchangeError")&&T)){const t=yield this.sdk.flow.next(p,h,J.CUSTOM_INTERACTIONS.submit,pe.version,ge.componentsVersion,{token:P,exchangeCode:R,exchangeError:T,origin:H.__classPrivateFieldGet(this,e,"a",A)});return H.__classPrivateFieldGet(this,E,"f").call(this,t),void this.flowState.update({token:void 0,code:void 0,exchangeError:void 0})}if(g===J.RESPONSE_ACTIONS.loadForm&&D&&["samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState"].some((e=>o(e)))){if(!M)return void this.loggerWrapper.error("Did not get saml idp params data to load");Q.injectSamlIdpForm(D,M,q||"",Q.submitForm)}if(g===J.RESPONSE_ACTIONS.loadForm&&V&&["wsFedIdpResponseUrl","wsFedIdpResponseWresult","wsFedIdpResponseWctx"].some((e=>o(e)))){if(!z)return void this.loggerWrapper.error("Did not get wsfed idp params data to load");Q.injectWsFedIdpForm(V,z,Y||"",Q.submitForm)}if(g===J.RESPONSE_ACTIONS.redirect&&(o("redirectTo")||o("deferredRedirect"))){if(!S)return void this.loggerWrapper.error("Did not get redirect url");if("no-op"===S)return;if("android"===L&&document.hidden)return void this.flowState.update({deferredRedirect:!0});if(this.loggerWrapper.debug(`Redirect is popup ${w}`),w){this.loggerWrapper.debug("Opening redirect in popup");const t=Q.openCenteredPopup(S,"?",598,700),i=this.shouldUsePopupPostMessage();i&&(t.name=`descope-wc|${window.location.origin}`),this.loggerWrapper.debug("Popup communication method: "+(i?"postMessage":"BroadcastChannel"));let s=!1;const r=e=>{this.loggerWrapper.debug("Received popup message",JSON.stringify(e.data));const t=i?this.popupOrigin:window.location.origin;if(e.origin!==t)return void this.loggerWrapper.debug(`Ignoring message from unexpected origin. received: "${e.origin}", expected: "${t}"`);const{action:r,data:o}=e.data||{};"code"===r&&(s=!0,this.flowState.update({code:o.code,exchangeError:o.exchangeError}))};let o;this.loggerWrapper.debug("Starting popup closed detection");const n=setInterval((()=>{t.closed&&(this.loggerWrapper.debug("Popup closed, dispatching popupclosed event"),clearInterval(n),H.__classPrivateFieldGet(this,e,"m",$).call(this,"popupclosed",{abandoned:!s}),this.loggerWrapper.debug("Cleaning up popup listeners"),null==o||o())}),1e3);if(i)window.addEventListener("message",r),o=()=>{this.loggerWrapper.debug("Cleaning up popup postMessage listener"),window.removeEventListener("message",r)};else{this.loggerWrapper.debug("Creating broadcast channel");const e=new BroadcastChannel(p);e.onmessage=r,o=()=>{this.loggerWrapper.debug("Closing channel"),e.close()}}}else this.handleRedirect(S),this.flowState.update({redirectTo:"no-op"}),H.__classPrivateFieldGet(this,e,"m",$).call(this,"popupclosed",{});return}if(g===J.RESPONSE_ACTIONS.webauthnCreate||g===J.RESPONSE_ACTIONS.webauthnGet){if(!k||!W)return void this.loggerWrapper.error("Did not get webauthn transaction id or options");null===(a=H.__classPrivateFieldGet(this,i,"f"))||void 0===a||a.abort(),H.__classPrivateFieldSet(this,i,null,"f");const t=yield H.__classPrivateFieldGet(this,e,"m",m).call(this,g,W),s=yield this.sdk.flow.next(p,h,J.CUSTOM_INTERACTIONS.submit,pe.version,ge.componentsVersion,Object.assign({transactionId:k},t));H.__classPrivateFieldGet(this,E,"f").call(this,s)}if(g===J.RESPONSE_ACTIONS.nativeBridge)return this.nativeCallbacks.complete=e=>H.__awaiter(this,void 0,void 0,(function*(){const t=yield this.sdk.flow.next(p,h,J.CUSTOM_INTERACTIONS.submit,pe.version,ge.componentsVersion,e);H.__classPrivateFieldGet(this,E,"f").call(this,t)})),H.__classPrivateFieldGet(this,e,"m",d).call(this,Z,ee),void setTimeout((()=>{this.dispatchEvent(new Event("popupclosed"))}),500);if((o("action")||o("deferredPolling"))&&H.__classPrivateFieldGet(this,b,"f").call(this,p,h,pe.version,ge.componentsVersion),!_&&!ne)return void this.loggerWrapper.warn("No screen was found to show");const be=ne||_,Se=yield this.getHtmlFilenameWithLocale(G,be),{oidcLoginHint:we,oidcPrompt:Ee,oidcErrorRedirectUri:Ie,oidcResource:Pe,samlIdpUsername:Re}=oe,Oe={direction:Q.getAnimationDirection(h,r.stepId),screenState:Object.assign(Object.assign({},f),{form:Object.assign(Object.assign({},this.formConfigValues),null==f?void 0:f.form),lastAuth:{loginId:he,name:this.sdk.getLastUserDisplayName()||he},componentsConfig:Object.assign(Object.assign(Object.assign({},pe.componentsConfig),fe),null==f?void 0:f.componentsConfig)}),htmlFilename:`${be}.html`,htmlLocaleFilename:Se,screenId:be,stepName:t.stepName||ae,samlIdpUsername:Re,oidcLoginHint:we,oidcPrompt:Ee,oidcErrorRedirectUri:Ie,oidcResource:Pe,action:g,locale:K.getUserLocale(G).locale},Ce=se.getLastAuth(he,this.loggerWrapper);Q.showFirstScreenOnExecutionInit(ne,oe)?Oe.next=(t,i)=>H.__awaiter(this,void 0,void 0,(function*(){const s=(null==pe?void 0:pe.clientScripts)||[];yield H.__classPrivateFieldGet(this,e,"m",j).call(this,s);const r=yield this.sdk.flow.start(c,Object.assign(Object.assign(Object.assign(Object.assign({tenant:u,redirectAuth:me},oe),{lastAuth:Ce,preview:this.preview,abTestingKey:de,client:this.client}),I&&{redirectUrl:I}),{locale:K.getUserLocale(G).locale,nativeOptions:_e,outboundAppId:ce,outboundAppScopes:ue}),le,t,ge.componentsVersion,ve,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),this.getComponentsContext()),Q.transformScreenInputs(i)),R&&{exchangeCode:R,idpInitiated:!0}),oe.descopeIdpInitiated&&{idpInitiated:!0}),P&&{token:P}),Oe.next.isCustomScreen);return H.__classPrivateFieldGet(this,E,"f").call(this,r),r})):(o("projectId")||o("baseUrl")||o("executionId")||o("stepId"))&&(Oe.next=(t,i)=>H.__awaiter(this,void 0,void 0,(function*(){const s=(null==f?void 0:f.clientScripts)||[];yield H.__classPrivateFieldGet(this,e,"m",j).call(this,s);const r=yield this.sdk.flow.next(p,h,t,pe.version,ge.componentsVersion,Object.assign(Object.assign({},this.getComponentsContext()),Q.transformScreenInputs(i)),Oe.next.isCustomScreen);return H.__classPrivateFieldGet(this,E,"f").call(this,r),r}))),this.loggerWrapper.debug("Got a screen with id",Oe.screenId),yield H.__classPrivateFieldGet(this,e,"m",v).call(this,Oe),this.stepState.update(Oe)}))}onStepChange(t,i){return H.__awaiter(this,void 0,void 0,(function*(){var s,r,o;const{htmlFilename:n,htmlLocaleFilename:a,direction:l,next:d,screenState:c,screenId:u}=t;this.loggerWrapper.debug("Rendering a flow screen"),this.updateScreenUser(null==c?void 0:c.user);const h=document.createElement("template");h.innerHTML=yield this.getPageContent(n,a);const p=h.content.cloneNode(!0),g=this.loadDescopeUiComponents(h);this.sdk.webauthn.helpers.isSupported()?yield H.__classPrivateFieldGet(this,e,"m",R).call(this,p,d):Y.disableWebauthnButtons(p),!t.samlIdpUsername||(null===(s=c.form)||void 0===s?void 0:s.loginId)||(null===(r=c.form)||void 0===r?void 0:r.email)||(c.form||(c.form={}),c.form.loginId=t.samlIdpUsername,c.form.email=t.samlIdpUsername),Y.updateTemplateFromScreenState(p,c,this.formConfig,this.loggerWrapper),this.applyComponentsState(p,null==c?void 0:c.componentsState);const{geo:v}=null!==(o=yield this.getExecutionContext())&&void 0!==o?o:{};Y.setComponentsAutoDetectByGeo(p,v),Y.setComponentsAutoDetectByLocale(p,t.locale);const m=()=>H.__awaiter(this,void 0,void 0,(function*(){var s,r;yield g;const o=this.contentRootElement;Y.setTOTPVariable(o,null===(s=null==c?void 0:c.totp)||void 0===s?void 0:s.image),Y.setNOTPVariable(o,null===(r=null==c?void 0:c.notp)||void 0===r?void 0:r.image),Y.setCssVars(o,p,c.cssVars,this.loggerWrapper),o.replaceChildren(p);const n=!i.htmlFilename;setTimeout((()=>{H.__classPrivateFieldGet(this,e,"m",U).call(this),this.updateUsernameAnchor(),this.validateOnBlur&&Q.handleReportValidityOnBlur(o,(t=>this.trackValidationErrors([t],H.__classPrivateFieldGet(this,e,"a",T)))),Y.updateScreenFromScreenState(o,c),this.initRealtimeConditions(o,c),H.__classPrivateFieldGet(this,e,"m",O).call(this,{isFirstScreen:n,isCustomScreen:!1,stepName:t.stepName}),Q.handleAutoFocus(o,this.autoFocus,n),H.__classPrivateFieldGet(this,e,"m",q).call(this,u)})),H.__classPrivateFieldGet(this,e,"m",V).call(this,d,u);o.querySelector(`[${J.ELEMENT_TYPE_ATTRIBUTE}="polling"]`)&&d(J.CUSTOM_INTERACTIONS.polling,{})}));l?H.__classPrivateFieldGet(this,e,"m",f).call(this,m):m()}))}getInputs(){return Array.from(this.shadowRoot.querySelectorAll(`*:not(slot)[name]:not([${J.DESCOPE_ATTRIBUTE_EXCLUDE_FIELD}])`))}shouldUsePopupPostMessage(){if(!this.popupOrigin)return!1;try{new URL(this.popupOrigin)}catch(e){return!1}return!0}}t=new WeakMap,i=new WeakMap,s=new WeakMap,r=new WeakMap,n=new WeakMap,g=new WeakMap,_=new WeakMap,b=new WeakMap,S=new WeakMap,w=new WeakMap,E=new WeakMap,I=new WeakMap,C=new WeakMap,F=new WeakMap,x=new WeakMap,G=new WeakMap,e=new WeakSet,o=function(){document.hidden||setTimeout((()=>{this.flowState.update({deferredRedirect:!1,deferredPolling:!1})}),300)},a=function(t,i,s){return H.__awaiter(this,void 0,void 0,(function*(){var r;return(null===(r=this.nativeOptions)||void 0===r?void 0:r.bridgeVersion)>=2&&new Promise((r=>{this.nativeCallbacks.screenNext=s,this.nativeCallbacks.screenResolve=r,H.__classPrivateFieldGet(this,e,"m",d).call(this,"beforeScreen",{screen:t,context:i})}))}))},l=function(t){var i;(null===(i=this.nativeOptions)||void 0===i?void 0:i.bridgeVersion)>=2&&H.__classPrivateFieldGet(this,e,"m",d).call(this,"afterScreen",{screen:t})},d=function(t,i){H.__classPrivateFieldGet(this,e,"m",$).call(this,"bridge",{type:t,payload:i})},c=function({errorText:e,errorType:t}){const i=()=>{var i;let s=e;try{s=(null===(i=this.errorTransformer)||void 0===i?void 0:i.call(this,{text:e,type:t}))||e}catch(e){this.loggerWrapper.error("Error transforming error message",e.message)}Y.replaceElementMessage(this.contentRootElement,"error-message",s)};this.addEventListener("screen-updated",i,{once:!0}),i()},u=function(){var t,i,s,r;null===(t=this.stepState)||void 0===t||t.subscribe(this.onStepChange.bind(this),(e=>{var t=e.screenState,i=void 0===t?{}:t,{errorText:s,errorType:r}=i,o=H.__rest(i,["errorText","errorType"]),n=H.__rest(e,["screenState"]);return Object.assign(Object.assign({},n),{screenState:o})})),null===(i=this.stepState)||void 0===i||i.subscribe(H.__classPrivateFieldGet(this,e,"m",c).bind(this),(e=>{var t,i;return{errorText:null===(t=null==e?void 0:e.screenState)||void 0===t?void 0:t.errorText,errorType:null===(i=null==e?void 0:e.screenState)||void 0===i?void 0:i.errorType}}),{forceUpdate:!0}),null===(s=this.stepState)||void 0===s||s.subscribe(H.__classPrivateFieldGet(this,e,"m",h).bind(this),(e=>{var t,i;return{errorText:null===(t=null==e?void 0:e.screenState)||void 0===t?void 0:t.errorText,errorType:null===(i=null==e?void 0:e.screenState)||void 0===i?void 0:i.errorType}}),{forceUpdate:!0}),null===(r=this.flowState)||void 0===r||r.subscribe((({screenId:e,executionId:t})=>{var i;try{this.updateTelemetryContext({screenId:e,executionId:t})}catch(e){null===(i=this.logger)||void 0===i||i.error("Error updating telemetry screenId:",e)}}),(e=>({screenId:e.screenId,executionId:e.executionId})))},h=function({errorText:e,errorType:t}){(t||e)&&(this.contentRootElement.querySelectorAll('descope-passcode[data-auto-submit="true"]').forEach((e=>{e.shadowRoot.querySelectorAll("descope-text-field[data-id]").forEach((e=>{e.value=""}))})),Q.handleAutoFocus(this.contentRootElement,this.autoFocus,!1))},p=function(){return H.__awaiter(this,void 0,void 0,(function*(){this.loggerWrapper.debug("Trying to restart the flow");const e=yield this.getComponentsVersion();this.reset();e===(yield this.getComponentsVersion())?(this.loggerWrapper.debug("Components version was not changed, restarting flow"),this.flowState.update({stepId:null,executionId:null})):this.loggerWrapper.error("Components version mismatch, please reload the page")}))},v=function(t){return H.__awaiter(this,void 0,void 0,(function*(){var i;const s=Object.assign(Object.assign({},this.stepState.current),t),{next:r,stepName:o}=s,n=H.__rest(s,["next","stepName"]),l=Q.transformStepStateForCustomScreen(n);let d=yield H.__classPrivateFieldGet(this,e,"m",a).call(this,o,l,r);d||(d=Boolean(yield null===(i=this.onScreenUpdate)||void 0===i?void 0:i.call(this,o,l,r,this)));const c=!this.stepState.current.htmlFilename;if(H.__classPrivateFieldGet(this,_,"f").call(this,d),r&&(r.isCustomScreen=d),H.__classPrivateFieldGet(this,g,"f")!==d){const[t,i]=["flow","custom"].sort((()=>d?-1:1));this.loggerWrapper.debug(`Switching from ${i} screen to ${t} screen`),H.__classPrivateFieldSet(this,g,d,"f"),d?this.stepState.unsubscribeAll():H.__classPrivateFieldGet(this,e,"m",u).call(this)}d?(this.loggerWrapper.debug("Showing a custom screen"),H.__classPrivateFieldGet(this,e,"m",O).call(this,{isFirstScreen:c,isCustomScreen:d,stepName:t.stepName}),this.disableKeyPressHandler()):this.handleKeyPress(),this.stepState.forceUpdate=d}))},m=function(e,t){return H.__awaiter(this,void 0,void 0,(function*(){const i=new AbortController;try{const s=e===J.RESPONSE_ACTIONS.webauthnCreate?this.sdk.webauthn.helpers.create(t,i):this.sdk.webauthn.helpers.get(t,i),r=yield Q.timeoutPromise(J.WEBAUTHN_TIMEOUT,s,ae);return r!==ae?{response:r}:(i.abort(),this.loggerWrapper.warn(`WebAuthn operation timed out after ${J.WEBAUTHN_TIMEOUT}ms`),{failure:"AbortError",failureReason:"aborted",failureMessage:"Passkey operation timed out"})}catch(e){return"InvalidStateError"===e.name?this.loggerWrapper.warn("WebAuthn operation failed",e.message):"NotAllowedError"!==e.name&&this.loggerWrapper.error(e.message),{failure:e.name,failureReason:e.reason,failureMessage:e.message}}}))},f=function(e){this.contentRootElement.addEventListener("transitionend",(()=>{this.loggerWrapper.debug("page switch transition end"),this.contentRootElement.classList.remove("fade-out"),e()}),{once:!0}),this.loggerWrapper.debug("page switch transition start"),this.contentRootElement.classList.add("fade-out")},P=function(e){const t=e.getAttribute("name");if(!["email"].includes(t)){const i=`user-${t}`;e.setAttribute("name",i),e.addEventListener("input",(()=>{e.setAttribute("name",e.value?t:i)}))}},R=function(t,s){return H.__awaiter(this,void 0,void 0,(function*(){var r;null===(r=H.__classPrivateFieldGet(this,i,"f"))||void 0===r||r.abort();const o=t.querySelector('*[autocomplete="webauthn"]');if(o&&(yield Z.isConditionalLoginSupported())){const{options:t,transactionId:r}=(yield H.__classPrivateFieldGet(this,I,"f").call(this))||{};t&&r&&(H.__classPrivateFieldGet(this,e,"m",P).call(this,o),H.__classPrivateFieldSet(this,i,new AbortController,"f"),this.sdk.webauthn.helpers.conditional(t,H.__classPrivateFieldGet(this,i,"f")).then((e=>H.__awaiter(this,void 0,void 0,(function*(){s(o.id,{transactionId:r,response:e})})))).catch((e=>{"AbortError"!==e.name&&this.loggerWrapper.error("Conditional login failed",e.message)})))}}))},O=function({isFirstScreen:t,isCustomScreen:i,stepName:s}){t&&H.__classPrivateFieldGet(this,e,"m",$).call(this,"ready",{}),i||H.__classPrivateFieldGet(this,e,"m",l).call(this,s),H.__classPrivateFieldGet(this,e,"m",$).call(this,"page-updated",{screenName:s}),H.__classPrivateFieldGet(this,e,"m",$).call(this,"screen-updated",{screenName:s})},y=function(e,t,i){this.setValidationTrackingEnabled(!!e.clientValidationTrackingEnabled),t&&i("executionId")&&this.setValidationTrackingExecution(t)},T=function(){var e,t,i,s,r,o,n;const a=null===(e=this.flowState)||void 0===e?void 0:e.current;return(null==a?void 0:a.executionId)?{executionId:a.executionId,screenId:a.screenId,screenName:(null===(n=null===(o=this.stepState)||void 0===o?void 0:o.current)||void 0===n?void 0:n.stepName)||a.stepName}:{executionId:void 0,screenId:null!==(t=H.__classPrivateFieldGet(this,C,"f"))&&void 0!==t?t:null==a?void 0:a.screenId,screenName:null!==(i=H.__classPrivateFieldGet(this,F,"f"))&&void 0!==i?i:(null===(r=null===(s=this.stepState)||void 0===s?void 0:s.current)||void 0===r?void 0:r.stepName)||(null==a?void 0:a.stepName)}},A=function(){var e;return(null===(e=this.nativeOptions)||void 0===e?void 0:e.origin)||window.location.origin},k=function(){let t=!0;const i=[];return Array.from(this.shadowRoot.querySelectorAll("*[name]")).reverse().forEach((e=>{var s,r,o;"slot"===e.localName||re.isHiddenByCondition(e,this.contentRootElement)||(null===(s=e.reportValidity)||void 0===s||s.call(e),e.validity&&!e.validity.valid&&i.push(e),t&&(t=null===(o=null===(r=e.checkValidity)||void 0===r?void 0:r.call(e))||void 0===o||o))})),i.length&&this.trackValidationErrors(i,H.__classPrivateFieldGet(this,e,"a",T)),t},W=function(){return H.__awaiter(this,void 0,void 0,(function*(){const e=this.getInputs();return(yield Promise.all(e.map((e=>H.__awaiter(this,void 0,void 0,(function*(){return{name:e.getAttribute("name"),value:e.value}})))))).reduce(((e,t)=>Object.assign(Object.assign({},e),{[t.name]:t.value})),{})}))},N=function(e){var t,i;const r=Array.from(this.contentRootElement.querySelectorAll(':not([disabled]), [disabled="false"]')).filter((t=>t!==e)),o=(null===(i=null===(t=this.flowState.current)||void 0===t?void 0:t.screenState)||void 0===i?void 0:i.clientScripts)||[];e.setAttribute("loading","true"),r.forEach((e=>e.setAttribute("disabled","true")));const n=()=>{e.removeAttribute("loading"),r.forEach((e=>{e.removeAttribute("disabled")}))},a=e=>H.__awaiter(this,void 0,void 0,(function*(){var t;this.loggerWrapper.debug("Restoring components state"),this.removeEventListener("popupclosed",a);if(!0===(null===(t=null==e?void 0:e.detail)||void 0===t?void 0:t.abandoned)&&o.length)return H.__classPrivateFieldSet(this,s,(()=>H.__awaiter(this,void 0,void 0,(function*(){try{yield this.loadSdkScripts(o)}catch(e){this.loggerWrapper.warn("Failed to refresh client scripts on popup close",null==e?void 0:e.message)}})))(),"f"),void n();n();const i=yield this.getFlowConfig(),r=[...i.clientScripts||[],...i.sdkScripts||[]];this.loadSdkScripts(r)})),l=()=>{var e;window.removeEventListener("pageshow",H.__classPrivateFieldGet(this,x,"f")),H.__classPrivateFieldSet(this,x,(e=>{e.persisted&&(this.logger.debug("Page was loaded from cache, restoring components state"),a())}),"f"),window.addEventListener("pageshow",H.__classPrivateFieldGet(this,x,"f"),{once:!0});const t=null===(e=this.stepState)||void 0===e?void 0:e.subscribe(((e,i)=>{e===i&&a(),this.removeEventListener("popupclosed",a),this.stepState.unsubscribe(t)}),(e=>e.screenId),{forceUpdate:!0})},d=this.nextRequestStatus.subscribe((({isLoading:e})=>{e?this.addEventListener("popupclosed",a,{once:!0}):(this.nextRequestStatus.unsubscribe(d),"success"===this.flowStatus?(this.removeEventListener("popupclosed",a),n()):l())}));return n},U=function(){Q.clearPreviousExternalInputs();this.contentRootElement.querySelectorAll('[external-input="true"]').forEach((t=>H.__classPrivateFieldGet(this,e,"m",L).call(this,t)))},L=function(e){if(!e)return;e.querySelectorAll("input").forEach((t=>{const i=t.getAttribute("slot"),s=`input-${e.id}-${i}`,r=document.createElement("slot");r.setAttribute("name",s),r.setAttribute("slot",i),e.appendChild(r),t.setAttribute("slot",s),this.appendChild(t)}))},j=function(e){return H.__awaiter(this,void 0,void 0,(function*(){if(H.__classPrivateFieldGet(this,s,"f")){this.loggerWrapper.debug("Waiting for sdk scripts to load");const e=Date.now();yield H.__classPrivateFieldGet(this,s,"f"),this.loggerWrapper.debug("Sdk scripts loaded for",(Date.now()-e).toString())}const t=this.loadSdkScriptsModules(),i=e.map((e=>e.id));for(const e of t)if(i.includes(e.id))try{if("function"==typeof e.present){(yield e.present())||this.loggerWrapper.debug(`Sdk script ${e.id} was cancelled`)}}catch(t){this.loggerWrapper.error(`Failed to present ${e.id} script module`,t.message)}const r=[];for(const e of t)"function"==typeof e.refresh&&r.push(e.refresh());if(r.length>0)try{yield Q.timeoutPromise(J.SDK_SCRIPTS_LOAD_TIMEOUT,Promise.all(r),null)}catch(e){this.loggerWrapper.error("Failed to refresh script module",e.message)}}))},D=function(e,t){this.contentRootElement.querySelectorAll('descope-passcode[data-auto-submit="true"]').forEach((i=>{i.addEventListener("input",(()=>{var s;(null===(s=i.checkValidity)||void 0===s?void 0:s.call(i))&&H.__classPrivateFieldGet(this,G,"f").call(this,i,e,t)}))}))},M=function(e,t,i){t&&i&&"true"===e.getAttribute(J.DESCOPE_ATTRIBUTE_OPT_IN_LAST_USED)&&se.updateLastUsedPerScreen(i,t,this.loggerWrapper)},q=function(e){var t;const i=this.sdk.getLastUserLoginId(),s=null===(t=se.getLastAuth(i,this.loggerWrapper).lastUsedPerScreen)||void 0===t?void 0:t[e];if(!s)return;const r=this.contentRootElement.querySelector(J.DESCOPE_LAST_AUTH_BADGE_COMPONENT),o=this.contentRootElement.querySelector(`#${CSS.escape(s)}`);r&&o&&(o.replaceWith(r),r.appendChild(o))},V=function(t,i){this.contentRootElement.querySelectorAll(`descope-button:not([${J.DESCOPE_ATTRIBUTE_EXCLUDE_NEXT_BUTTON}]), [data-type="button"]:not([${J.DESCOPE_ATTRIBUTE_EXCLUDE_NEXT_BUTTON}]`).forEach((e=>{e.onclick=()=>{H.__classPrivateFieldGet(this,G,"f").call(this,e,t,i)}})),H.__classPrivateFieldGet(this,e,"m",D).call(this,t,i),this.isDismissScreenErrorOnInput&&this.contentRootElement.querySelectorAll(`*[name]:not([${J.DESCOPE_ATTRIBUTE_EXCLUDE_FIELD}])`).forEach((e=>{e.addEventListener("input",(()=>{this.stepState.update((e=>Object.assign(Object.assign({},e),{screenState:Object.assign(Object.assign({},e.screenState),{errorText:"",errorType:""})})))}))}))},$=function(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t}))},B=function(e,t,i){var s;const[r,o]=(null===(s=window.name)||void 0===s?void 0:s.split("|"))||[],n={data:{code:t,exchangeError:i},action:"code"};if("descope-wc"===r&&o){this.loggerWrapper.debug("Using postMessage fallback to notify opener in origin",o);try{window.opener.postMessage(n,o)}catch(e){this.loggerWrapper.error("Failed to send postMessage fallback (likely COOP isolation)",null==e?void 0:e.message)}}else{this.loggerWrapper.debug("Creating popup channel",e);const t=new BroadcastChannel(e);t.postMessage(n),t.close()}try{window.close()}catch(e){}},le.bridgeVersion=3,module.exports=le;
2
2
  //# sourceMappingURL=DescopeWc.js.map