@glideidentity/web-client-sdk 4.4.9 → 4.4.10

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.
@@ -1,2 +1,2 @@
1
1
  /*! For license information please see web-client-sdk.min.js.LICENSE.txt */
2
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.GlideWebClientSDK=t():e.GlideWebClientSDK=t()}(this,()=>(()=>{"use strict";var e={50:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SDK_VERSION=void 0,t.SDK_VERSION="4.4.9"},192:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.PhoneAuthErrorCode=void 0,t.isPhoneAuthError=function(e){return e&&"string"==typeof e.code&&"string"==typeof e.message},t.isUserError=s,t.getUserMessage=a,t.isErrorCode=function(e,t){return e.code===t},t.getRetryDelay=function(e){return e.code===t.PhoneAuthErrorCode.RATE_LIMIT_EXCEEDED&&e.retryAfter?1e3*e.retryAfter:null},t.isRetryableError=function(e){return[t.PhoneAuthErrorCode.NETWORK_ERROR,t.PhoneAuthErrorCode.SERVICE_UNAVAILABLE,t.PhoneAuthErrorCode.DOWNSTREAM_SERVICE_ERROR,t.PhoneAuthErrorCode.RATE_LIMIT_EXCEEDED].includes(e.code)},t.parseBackendError=function(e){var n,o;if(e&&"object"==typeof e&&(e.code||e.error)){const t=e.code||e.error,o={code:t,message:e.message||a({code:t}),status:e.status,requestId:e.requestId||e.request_id,timestamp:e.timestamp,details:e.details,traceId:e.trace_id||e.traceId,spanId:e.span_id||e.spanId,service:e.service};return(null===(n=e.details)||void 0===n?void 0:n.retryAfter)&&(o.retryAfter=e.details.retryAfter),o}if(e&&e.status){const n=function(e){switch(e){case 400:return t.PhoneAuthErrorCode.BAD_REQUEST;case 401:return t.PhoneAuthErrorCode.UNAUTHORIZED;case 403:return t.PhoneAuthErrorCode.FORBIDDEN;case 404:return t.PhoneAuthErrorCode.NOT_FOUND;case 409:return t.PhoneAuthErrorCode.CONFLICT;case 422:return t.PhoneAuthErrorCode.UNPROCESSABLE_ENTITY;case 429:return t.PhoneAuthErrorCode.RATE_LIMIT_EXCEEDED;case 500:default:return t.PhoneAuthErrorCode.INTERNAL_SERVER_ERROR;case 502:return t.PhoneAuthErrorCode.BAD_GATEWAY;case 503:return t.PhoneAuthErrorCode.SERVICE_UNAVAILABLE;case 504:return t.PhoneAuthErrorCode.GATEWAY_TIMEOUT}}(e.status);return{code:n,message:e.message||a({code:n}),status:e.status,requestId:null===(o=e.headers)||void 0===o?void 0:o["x-request-id"]}}return{code:t.PhoneAuthErrorCode.INTERNAL_SERVER_ERROR,message:"An unexpected error occurred",status:500}},t.serializeError=function(e){return{code:e.code,message:e.message,status:e.status,requestId:e.requestId,timestamp:e.timestamp,traceId:e.traceId,spanId:e.spanId,service:e.service,retryAfter:e.retryAfter,browserError:e.browserError,context:e.context,details:l(e.details),sdkVersion:o.SDK_VERSION,errorCapturedAt:(new Date).toISOString()}},t.createErrorBreadcrumb=function(e){var t,n,o;return{category:"phone-auth",message:`Phone Auth Error: ${e.code}`,level:s(e)?"warning":"error",data:{code:e.code,step:null===(t=e.context)||void 0===t?void 0:t.step,useCase:null===(n=e.context)||void 0===n?void 0:n.useCase,requestId:e.requestId,browserErrorType:null===(o=e.browserError)||void 0===o?void 0:o.name}}};const o=n(50);t.PhoneAuthErrorCode={BAD_REQUEST:"BAD_REQUEST",VALIDATION_ERROR:"VALIDATION_ERROR",INVALID_PARAMETERS:"INVALID_PARAMETERS",MISSING_PARAMETERS:"MISSING_PARAMETERS",INVALID_PHONE_NUMBER:"INVALID_PHONE_NUMBER",INVALID_MCC_MNC:"INVALID_MCC_MNC",UNAUTHORIZED:"UNAUTHORIZED",INVALID_CREDENTIALS:"INVALID_CREDENTIALS",EXPIRED_TOKEN:"EXPIRED_TOKEN",TOKEN_ACQUISITION_FAILED:"TOKEN_ACQUISITION_FAILED",INVALID_API_KEY:"INVALID_API_KEY",MISSING_AUTH_HEADER:"MISSING_AUTH_HEADER",FORBIDDEN:"FORBIDDEN",INSUFFICIENT_PERMISSIONS:"INSUFFICIENT_PERMISSIONS",ACCESS_DENIED:"ACCESS_DENIED",NOT_FOUND:"NOT_FOUND",RESOURCE_NOT_FOUND:"RESOURCE_NOT_FOUND",SESSION_NOT_FOUND:"SESSION_NOT_FOUND",CARRIER_NOT_FOUND:"CARRIER_NOT_FOUND",ENDPOINT_NOT_FOUND:"ENDPOINT_NOT_FOUND",CONFLICT:"CONFLICT",RESOURCE_ALREADY_EXISTS:"RESOURCE_ALREADY_EXISTS",DUPLICATE_SESSION:"DUPLICATE_SESSION",CONCURRENT_MODIFICATION:"CONCURRENT_MODIFICATION",UNPROCESSABLE_ENTITY:"UNPROCESSABLE_ENTITY",UNSUPPORTED_VERIFICATION:"UNSUPPORTED_VERIFICATION",INVALID_VERIFICATION:"INVALID_VERIFICATION",VERIFICATION_FAILED:"VERIFICATION_FAILED",OTP_EXPIRED:"OTP_EXPIRED",OTP_INVALID:"OTP_INVALID",RCS_UNAVAILABLE:"RCS_UNAVAILABLE",CARRIER_IDENTIFICATION_FAILED:"CARRIER_IDENTIFICATION_FAILED",CARRIER_NOT_ELIGIBLE:"CARRIER_NOT_ELIGIBLE",UNSUPPORTED_CARRIER:"UNSUPPORTED_CARRIER",UNSUPPORTED_PLATFORM:"UNSUPPORTED_PLATFORM",UNSUPPORTED_STRATEGY:"UNSUPPORTED_STRATEGY",INVALID_SESSION_STATE:"INVALID_SESSION_STATE",PHONE_NUMBER_MISMATCH:"PHONE_NUMBER_MISMATCH",INVALID_CREDENTIAL_FORMAT:"INVALID_CREDENTIAL_FORMAT",RATE_LIMIT_EXCEEDED:"RATE_LIMIT_EXCEEDED",TOO_MANY_REQUESTS:"TOO_MANY_REQUESTS",QUOTA_EXCEEDED:"QUOTA_EXCEEDED",INTERNAL_SERVER_ERROR:"INTERNAL_SERVER_ERROR",CIRCUIT_BREAKER_CONFIGURATION_ERROR:"CIRCUIT_BREAKER_CONFIGURATION_ERROR",DATABASE_ERROR:"DATABASE_ERROR",CACHE_ERROR:"CACHE_ERROR",SERIALIZATION_ERROR:"SERIALIZATION_ERROR",CRYPTO_ERROR:"CRYPTO_ERROR",BAD_GATEWAY:"BAD_GATEWAY",UPSTREAM_ERROR:"UPSTREAM_ERROR",INVALID_RESPONSE:"INVALID_RESPONSE",SERVICE_UNAVAILABLE:"SERVICE_UNAVAILABLE",DOWNSTREAM_SERVICE_ERROR:"DOWNSTREAM_SERVICE_ERROR",PROVIDER_ERROR:"PROVIDER_ERROR",CIRCUIT_BREAKER_OPEN:"CIRCUIT_BREAKER_OPEN",MAINTENANCE_MODE:"MAINTENANCE_MODE",GATEWAY_TIMEOUT:"GATEWAY_TIMEOUT",REQUEST_TIMEOUT:"REQUEST_TIMEOUT",UPSTREAM_TIMEOUT:"UPSTREAM_TIMEOUT",DEADLINE_EXCEEDED:"DEADLINE_EXCEEDED",BROWSER_NOT_SUPPORTED:"BROWSER_NOT_SUPPORTED",USER_DENIED:"USER_DENIED",NETWORK_ERROR:"NETWORK_ERROR"};const r={CARRIER_NOT_ELIGIBLE:"Your carrier is not eligible for this verification method.",CARRIER_IDENTIFICATION_FAILED:"Unable to identify carrier for the provided phone number.",CARRIER_NOT_FOUND:"Carrier information not available.",UNSUPPORTED_CARRIER:"This carrier is not supported.",RATE_LIMIT_EXCEEDED:"Too many attempts. Please wait a moment and try again.",TOO_MANY_REQUESTS:"Too many requests. Please slow down and try again.",QUOTA_EXCEEDED:"Usage limit reached. Please try again later.",SESSION_NOT_FOUND:"Your session has expired. Please start over.",INVALID_SESSION_STATE:"Invalid session state. Please start over.",DUPLICATE_SESSION:"A session already exists. Please complete or cancel it first.",BROWSER_NOT_SUPPORTED:"Digital Credentials API is not available. Please enable the #web-identity-digital-credentials flag in chrome://flags",UNSUPPORTED_PLATFORM:"This platform is not supported for authentication.",UNSUPPORTED_STRATEGY:"This authentication method is not available.",USER_DENIED:"Authentication was cancelled. Please try again when you're ready.",SERVICE_UNAVAILABLE:"The service is temporarily unavailable. Please try again later.",CIRCUIT_BREAKER_OPEN:"Service is experiencing issues. Please try again later.",MAINTENANCE_MODE:"Service is under maintenance. Please try again later.",DOWNSTREAM_SERVICE_ERROR:"A required service is unavailable. Please try again later.",TOKEN_ACQUISITION_FAILED:"Failed to acquire authentication token. Please try again.",EXPIRED_TOKEN:"Your authentication has expired. Please start over.",INVALID_CREDENTIALS:"Invalid credentials provided.",INVALID_PHONE_NUMBER:"Please enter a valid phone number.",PHONE_NUMBER_MISMATCH:"Phone number mismatch. Please verify your number.",INVALID_PARAMETERS:"Invalid parameters provided.",MISSING_PARAMETERS:"Required information is missing.",VALIDATION_ERROR:"Validation failed. Please check your input.",NETWORK_ERROR:"Network connection failed. Please check your connection and try again.",GATEWAY_TIMEOUT:"Request timed out. Please try again.",REQUEST_TIMEOUT:"Request timed out. Please try again.",DEADLINE_EXCEEDED:"Operation took too long. Please try again.",VERIFICATION_FAILED:"Verification failed. Please try again.",INVALID_VERIFICATION:"Invalid verification response.",INVALID_CREDENTIAL_FORMAT:"Invalid credential format.",BAD_REQUEST:"Invalid request. Please try again.",UNAUTHORIZED:"Authentication required.",FORBIDDEN:"Access denied.",NOT_FOUND:"Resource not found.",INTERNAL_SERVER_ERROR:"An error occurred. Please try again later."},i=new Set(["CARRIER_NOT_ELIGIBLE","CARRIER_IDENTIFICATION_FAILED","CARRIER_NOT_FOUND","UNSUPPORTED_CARRIER","RATE_LIMIT_EXCEEDED","TOO_MANY_REQUESTS","QUOTA_EXCEEDED","BROWSER_NOT_SUPPORTED","UNSUPPORTED_PLATFORM","UNSUPPORTED_STRATEGY","USER_DENIED","SESSION_NOT_FOUND","INVALID_SESSION_STATE","EXPIRED_TOKEN","SERVICE_UNAVAILABLE","CIRCUIT_BREAKER_OPEN","MAINTENANCE_MODE","NETWORK_ERROR","GATEWAY_TIMEOUT","REQUEST_TIMEOUT","INVALID_PHONE_NUMBER","PHONE_NUMBER_MISMATCH","MISSING_PARAMETERS","VALIDATION_ERROR"]);function s(e){return i.has(e.code)}function a(e){return r[e.code]||"An unexpected error occurred. Please try again."}function l(e){if(!e||"object"!=typeof e)return e;const t=JSON.parse(JSON.stringify(e)),n=["carrier","phone_number","mnc","mcc","carrier_name"];for(const e of n)delete t[e];return t}},244:function(e,t){var n=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))(function(r,i){function s(e){try{l(o.next(e))}catch(e){i(e)}}function a(e){try{l(o.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}l((o=o.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.AuthModal=void 0,t.AuthModal=class{constructor(e,t){this.container=null,this.backdrop=null,this.isOpen=!1,this.options=e||{},this.callbacks=t||{},this.handleEscapeKey=this.handleEscapeKey.bind(this)}handleEscapeKey(e){var t,n;"Escape"===e.key&&this.isOpen&&!1!==(null===(t=this.options)||void 0===t?void 0:t.closeOnEscape)&&(null===(n=this.closeCallback)||void 0===n||n.call(this),this.close())}escapeHtml(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}showQRCode(e,t="Scan QR code with your phone"){if(console.log("[Modal] showQRCode called with:",e),this.isOpen)console.log("[Modal] Modal already open, skipping recreation");else{if("object"==typeof e&&e.iosQRCode){const n=e.androidQRCode&&e.androidQRCode.length>0&&e.androidQRCode!==e.iosQRCode;if(console.log("[Modal] Has valid Android QR?",n),n)return console.log("[Modal] Using dual-platform modal"),void this.createDualPlatformQRModal(e,t);console.log("[Modal] Android QR missing/empty, using single iOS QR"),this.createModal(`\n <div class="glide-auth-qr-container">\n <img src="${this.escapeHtml(e.iosQRCode)}" alt="QR Code" class="glide-auth-qr-code" />\n <p class="glide-auth-status">Scan with your iPhone to authenticate</p>\n </div>\n `)}else console.log("[Modal] Using legacy single QR code modal"),this.createModal(`\n <div class="glide-auth-qr-container">\n <img src="${this.escapeHtml(e)}" alt="QR Code" class="glide-auth-qr-code" />\n <p class="glide-auth-status">${this.escapeHtml(t)}</p>\n </div>\n `);this.show()}}createDualPlatformQRModal(e,t){this.createModal(`\n <div class="glide-auth-qr-container">\n \x3c!-- Platform Switcher --\x3e\n <div class="glide-platform-switcher">\n <button class="glide-platform-btn glide-platform-ios active" data-platform="ios">\n <svg width="18" height="18" viewBox="0 0 24 24" fill="currentColor">\n <path d="M17.05 20.28c-.98.95-2.05.88-3.08.4-1.09-.5-2.08-.48-3.24 0-1.44.62-2.2.44-3.06-.4C2.79 15.25 3.51 7.59 9.05 7.31c1.35.07 2.29.74 3.08.8 1.18-.24 2.31-.93 3.57-.84 1.51.12 2.65.72 3.4 1.8-3.12 1.87-2.38 5.98.48 7.13-.57 1.5-1.31 2.99-2.54 4.09l.01-.01zM12.03 7.25c-.15-2.23 1.66-4.07 3.74-4.25.29 2.58-2.34 4.5-3.74 4.25z"/>\n </svg>\n <span>iOS</span>\n </button>\n <button class="glide-platform-btn glide-platform-android" data-platform="android">\n <svg width="18" height="18" viewBox="0 0 24 24" fill="currentColor">\n <path d="M17.6 9.48l1.84-3.18c.16-.31.04-.69-.26-.85-.29-.15-.65-.06-.83.22l-1.88 3.24c-2.86-1.21-6.08-1.21-8.94 0L5.65 5.67c-.19-.28-.54-.38-.83-.22-.3.16-.42.54-.26.85l1.84 3.18C4.08 11.08 2.4 13.97 2.4 17.2h19.2c0-3.23-1.68-6.12-4.0-7.72zM7.0 14.8c-.66 0-1.2-.54-1.2-1.2s.54-1.2 1.2-1.2 1.2.54 1.2 1.2-.54 1.2-1.2 1.2zm10 0c-.66 0-1.2-.54-1.2-1.2s.54-1.2 1.2-1.2 1.2.54 1.2 1.2-.54 1.2-1.2 1.2z"/>\n </svg>\n <span>Android</span>\n </button>\n </div>\n\n \x3c!-- QR Code Image --\x3e\n <img \n id="glide-qr-code-img" \n src="${this.escapeHtml(e.iosQRCode)}" \n alt="QR Code" \n class="glide-auth-qr-code" \n data-ios="${this.escapeHtml(e.iosQRCode)}"\n data-android="${this.escapeHtml(e.androidQRCode||"")}"\n />\n \n \x3c!-- Status Message --\x3e\n <p class="glide-auth-status" id="glide-platform-message">Scan with your iPhone to authenticate</p>\n </div>\n `),this.show()}setCloseCallback(e){this.closeCallback=e}showLinkButton(e,t){return new Promise(n=>{var o,r,i;const s=t||(null===(o=this.options)||void 0===o?void 0:o.buttonText)||"Open Verification App";this.createModal(`\n <div class="glide-auth-link-container">\n <p class="glide-auth-description">\n ${(null===(r=this.options)||void 0===r?void 0:r.description)||"Click below to verify your phone number"}\n </p>\n <button class="glide-auth-button" id="glide-auth-link-button">\n ${s}\n </button>\n <p class="glide-auth-helper-text">\n You'll be redirected to complete verification\n </p>\n </div>\n `),this.show();const a=null===(i=this.container)||void 0===i?void 0:i.querySelector("#glide-auth-link-button");a?a.addEventListener("click",t=>{var o,r;null===(r=null===(o=this.callbacks)||void 0===o?void 0:o.onAuthStart)||void 0===r||r.call(o),window.open(e,"_blank"),n()}):console.error("[Modal] Link button not found in modal")})}showTS43Button(e){return new Promise((t,o)=>{var r,i,s;const a=(null===(r=this.options)||void 0===r?void 0:r.buttonText)||"Verify with Carrier";this.createModal(`\n <div class="glide-auth-ts43-container">\n <p class="glide-auth-description">\n ${(null===(i=this.options)||void 0===i?void 0:i.description)||"Verify using your carrier credentials"}\n </p>\n <button class="glide-auth-button" id="glide-auth-ts43-button">\n ${a}\n </button>\n <p class="glide-auth-helper-text">\n Secure verification through your mobile carrier\n </p>\n </div>\n `),this.show();const l=null===(s=this.container)||void 0===s?void 0:s.querySelector("#glide-auth-ts43-button");l?l.addEventListener("click",r=>n(this,void 0,void 0,function*(){var n,r,i,s,c,u;null===(r=null===(n=this.callbacks)||void 0===n?void 0:n.onAuthStart)||void 0===r||r.call(n),l.setAttribute("disabled","true"),l.textContent="Verifying...";try{const n=yield e();null===(s=null===(i=this.callbacks)||void 0===i?void 0:i.onAuthComplete)||void 0===s||s.call(i,n),t(n),this.close()}catch(e){null===(u=null===(c=this.callbacks)||void 0===c?void 0:c.onError)||void 0===u||u.call(c,e),l.removeAttribute("disabled"),l.textContent=a,o(e)}})):console.error("[Modal] TS43 button not found in modal")})}updateStatus(e,t=!1){var n;const o=null===(n=this.container)||void 0===n?void 0:n.querySelector(".glide-auth-status");o&&(o.textContent=e,o.className=t?"glide-auth-status glide-auth-error":"glide-auth-status")}createModal(e){var t,n,o;this.cleanup(),this.backdrop=document.createElement("div"),this.backdrop.className="glide-auth-backdrop",this.backdrop.style.cssText="\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n background: rgba(0, 0, 0, 0.5);\n z-index: 9998;\n opacity: 0;\n transition: opacity 0.3s ease;\n ",this.container=document.createElement("div"),this.container.className=`glide-auth-modal ${(null===(t=this.options)||void 0===t?void 0:t.className)||""}`,this.container.style.cssText="\n position: fixed;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%) scale(0.9);\n background: white;\n border-radius: 12px;\n padding: 24px;\n max-width: 400px;\n width: 90%;\n box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);\n z-index: 9999;\n opacity: 0;\n transition: opacity 0.3s ease, transform 0.3s ease;\n ",this.container.innerHTML=`\n <div class="glide-auth-header">\n ${!1!==(null===(n=this.options)||void 0===n?void 0:n.showCloseButton)?'\n <button class="glide-auth-close" aria-label="Close">\n <svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">\n <line x1="18" y1="6" x2="6" y2="18"></line>\n <line x1="6" y1="6" x2="18" y2="18"></line>\n </svg>\n </button>\n ':""}\n <h2 class="glide-auth-title">${(null===(o=this.options)||void 0===o?void 0:o.title)||"Phone Verification"}</h2>\n </div>\n <div class="glide-auth-content">\n ${e}\n </div>\n `,this.injectStyles();const r=this.container.querySelector(".glide-auth-close");r&&r.addEventListener("click",()=>{var e;null===(e=this.closeCallback)||void 0===e||e.call(this),this.close()}),this.backdrop.addEventListener("click",e=>{var t,n;e.target===this.backdrop&&!1!==(null===(t=this.options)||void 0===t?void 0:t.closeOnBackdrop)&&(null===(n=this.closeCallback)||void 0===n||n.call(this),this.close())})}injectStyles(){if(document.getElementById("glide-auth-styles"))return;const e=document.createElement("style");e.id="glide-auth-styles",e.textContent="\n .glide-auth-backdrop {\n backdrop-filter: blur(4px);\n }\n\n .glide-auth-modal {\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;\n }\n\n .glide-auth-header {\n position: relative;\n margin-bottom: 20px;\n }\n\n .glide-auth-close {\n position: absolute;\n top: 0;\n right: 0;\n background: none;\n border: none;\n cursor: pointer;\n padding: 0;\n color: #666;\n transition: color 0.2s;\n }\n\n .glide-auth-close:hover {\n color: #000;\n }\n\n .glide-auth-title {\n margin: 0;\n font-size: 24px;\n font-weight: 600;\n color: #333;\n text-align: center;\n }\n\n .glide-auth-content {\n text-align: center;\n }\n\n .glide-auth-description {\n color: #666;\n margin: 0 0 20px 0;\n font-size: 16px;\n line-height: 1.5;\n }\n\n .glide-auth-button {\n background: #007AFF;\n color: white;\n border: none;\n border-radius: 8px;\n padding: 12px 24px;\n font-size: 16px;\n font-weight: 500;\n cursor: pointer;\n transition: background 0.2s, transform 0.1s;\n min-width: 200px;\n }\n\n .glide-auth-button:hover:not(:disabled) {\n background: #0051D5;\n transform: translateY(-1px);\n }\n\n .glide-auth-button:active {\n transform: translateY(0);\n }\n\n .glide-auth-button:disabled {\n opacity: 0.6;\n cursor: not-allowed;\n }\n\n .glide-auth-helper-text {\n color: #999;\n font-size: 14px;\n margin: 16px 0 0 0;\n }\n\n .glide-auth-qr-code {\n max-width: 256px;\n width: 100%;\n height: auto;\n margin: 20px auto;\n display: block;\n }\n\n .glide-auth-status {\n color: #666;\n font-size: 16px;\n margin: 16px 0;\n }\n\n .glide-auth-error {\n color: #FF3B30;\n }\n\n .glide-auth-qr-container,\n .glide-auth-link-container,\n .glide-auth-ts43-container {\n padding: 20px 0;\n }\n\n /* Platform Switcher Styles */\n .glide-platform-switcher {\n display: flex;\n justify-content: center;\n gap: 10px;\n margin-bottom: 20px;\n }\n\n .glide-platform-btn {\n display: flex;\n align-items: center;\n gap: 6px;\n padding: 10px 20px;\n border: 2px solid;\n background: transparent;\n border-radius: 8px;\n cursor: pointer;\n font-size: 14px;\n font-weight: 600;\n transition: all 0.2s ease;\n }\n\n .glide-platform-btn svg {\n flex-shrink: 0;\n }\n\n .glide-platform-ios {\n border-color: #007AFF;\n color: #007AFF;\n }\n\n .glide-platform-ios.active {\n background: #007AFF;\n color: white;\n }\n\n .glide-platform-ios:hover:not(.active) {\n background: rgba(0, 122, 255, 0.1);\n }\n\n .glide-platform-android {\n border-color: #3DDC84;\n color: #3DDC84;\n }\n\n .glide-platform-android.active {\n background: #3DDC84;\n color: white;\n }\n\n .glide-platform-android:hover:not(.active) {\n background: rgba(61, 220, 132, 0.1);\n }\n ",document.head.appendChild(e)}show(){var e,t;this.container&&this.backdrop&&!this.isOpen&&(document.body.appendChild(this.backdrop),document.body.appendChild(this.container),document.addEventListener("keydown",this.handleEscapeKey),this.setupPlatformToggles(),requestAnimationFrame(()=>{this.backdrop&&this.container&&(this.backdrop.style.opacity="1",this.container.style.opacity="1",this.container.style.transform="translate(-50%, -50%) scale(1)")}),this.isOpen=!0,null===(t=null===(e=this.callbacks)||void 0===e?void 0:e.onOpen)||void 0===t||t.call(e))}setupPlatformToggles(){var e,t,n;const o=null===(e=this.container)||void 0===e?void 0:e.querySelectorAll(".glide-platform-btn"),r=null===(t=this.container)||void 0===t?void 0:t.querySelector("#glide-qr-code-img"),i=null===(n=this.container)||void 0===n?void 0:n.querySelector("#glide-platform-message");o&&r&&o.forEach(e=>{e.addEventListener("click",e=>{const t=e.currentTarget,n=t.getAttribute("data-platform");o.forEach(e=>e.classList.remove("active")),t.classList.add("active"),"ios"===n?(r.src=r.getAttribute("data-ios")||"",i&&(i.textContent="Scan with your iPhone to authenticate")):"android"===n&&(r.src=r.getAttribute("data-android")||"",i&&(i.textContent="Scan with your Android device to authenticate"))})})}close(){this.container&&this.backdrop&&this.isOpen&&(document.removeEventListener("keydown",this.handleEscapeKey),this.backdrop.style.opacity="0",this.container.style.opacity="0",this.container.style.transform="translate(-50%, -50%) scale(0.9)",this.closeCallback=void 0,setTimeout(()=>{var e,t;this.cleanup(),this.isOpen=!1,null===(t=null===(e=this.callbacks)||void 0===e?void 0:e.onClose)||void 0===t||t.call(e)},300))}cleanup(){var e,t;null===(e=this.container)||void 0===e||e.remove(),null===(t=this.backdrop)||void 0===t||t.remove(),this.container=null,this.backdrop=null}isModalOpen(){return this.isOpen}}},363:(e,t)=>{function n(e){return e&&"object"==typeof e&&"strategy"in e&&"credential"in e&&"cancel"in e&&"function"==typeof e.cancel}function o(e){return!!n(e)&&("link"===e.strategy&&"start_polling"in e||"desktop"===e.strategy&&"start_polling"in e)}Object.defineProperty(t,"__esModule",{value:!0}),t.requiresUserAction=t.requiresPolling=t.isHeadlessResult=void 0,t.isExtendedResponse=n,t.isCredential=function(e){return!!e&&("string"==typeof e||"object"==typeof e&&(!("strategy"in e)&&!("credential"in e)&&!("cancel"in e)))},t.isAuthCredential=function(e){return e&&"object"==typeof e&&"credential"in e&&"authenticated"in e&&"session"in e},t.isLinkStrategy=function(e){return"link"===e.strategy},t.isTS43Strategy=function(e){return"ts43"===e.strategy},t.isDesktopStrategy=function(e){return"desktop"===e.strategy},t.getStrategy=function(e){if(n(e))return e.strategy},t.hasPollingControls=o,t.hasTrigger=function(e){return!!n(e)&&"trigger"in e&&"function"==typeof e.trigger},t.isHeadlessResult=n,t.requiresPolling=o,t.requiresUserAction=e=>!1},425:(e,t,n)=>{function o(e,t){return function(){return e.apply(t,arguments)}}const{toString:r}=Object.prototype,{getPrototypeOf:i}=Object,{iterator:s,toStringTag:a}=Symbol,l=(c=Object.create(null),e=>{const t=r.call(e);return c[t]||(c[t]=t.slice(8,-1).toLowerCase())});var c;const u=e=>(e=e.toLowerCase(),t=>l(t)===e),d=e=>t=>typeof t===e,{isArray:h}=Array,p=d("undefined");function g(e){return null!==e&&!p(e)&&null!==e.constructor&&!p(e.constructor)&&m(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const E=u("ArrayBuffer"),f=d("string"),m=d("function"),R=d("number"),b=e=>null!==e&&"object"==typeof e,_=e=>{if("object"!==l(e))return!1;const t=i(e);return!(null!==t&&t!==Object.prototype&&null!==Object.getPrototypeOf(t)||a in e||s in e)},v=u("Date"),A=u("File"),y=u("Blob"),O=u("FileList"),S=u("URLSearchParams"),[I,C,T,N]=["ReadableStream","Request","Response","Headers"].map(u);function P(e,t,{allOwnKeys:n=!1}={}){if(null==e)return;let o,r;if("object"!=typeof e&&(e=[e]),h(e))for(o=0,r=e.length;o<r;o++)t.call(null,e[o],o,e);else{if(g(e))return;const r=n?Object.getOwnPropertyNames(e):Object.keys(e),i=r.length;let s;for(o=0;o<i;o++)s=r[o],t.call(null,e[s],s,e)}}function w(e,t){if(g(e))return null;t=t.toLowerCase();const n=Object.keys(e);let o,r=n.length;for(;r-- >0;)if(o=n[r],t===o.toLowerCase())return o;return null}const D="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:n.g,U=e=>!p(e)&&e!==D,L=(x="undefined"!=typeof Uint8Array&&i(Uint8Array),e=>x&&e instanceof x);var x;const k=u("HTMLFormElement"),M=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),j=u("RegExp"),B=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),o={};P(n,(n,r)=>{let i;!1!==(i=t(n,r,e))&&(o[r]=i||n)}),Object.defineProperties(e,o)},F=u("AsyncFunction"),V=(q="function"==typeof setImmediate,H=m(D.postMessage),q?setImmediate:H?(G=`axios@${Math.random()}`,$=[],D.addEventListener("message",({source:e,data:t})=>{e===D&&t===G&&$.length&&$.shift()()},!1),e=>{$.push(e),D.postMessage(G,"*")}):e=>setTimeout(e));var q,H,G,$;const Q="undefined"!=typeof queueMicrotask?queueMicrotask.bind(D):"undefined"!=typeof process&&process.nextTick||V;var W={isArray:h,isArrayBuffer:E,isBuffer:g,isFormData:e=>{let t;return e&&("function"==typeof FormData&&e instanceof FormData||m(e.append)&&("formdata"===(t=l(e))||"object"===t&&m(e.toString)&&"[object FormData]"===e.toString()))},isArrayBufferView:function(e){let t;return t="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&E(e.buffer),t},isString:f,isNumber:R,isBoolean:e=>!0===e||!1===e,isObject:b,isPlainObject:_,isEmptyObject:e=>{if(!b(e)||g(e))return!1;try{return 0===Object.keys(e).length&&Object.getPrototypeOf(e)===Object.prototype}catch(e){return!1}},isReadableStream:I,isRequest:C,isResponse:T,isHeaders:N,isUndefined:p,isDate:v,isFile:A,isBlob:y,isRegExp:j,isFunction:m,isStream:e=>b(e)&&m(e.pipe),isURLSearchParams:S,isTypedArray:L,isFileList:O,forEach:P,merge:function e(){const{caseless:t,skipUndefined:n}=U(this)&&this||{},o={},r=(r,i)=>{const s=t&&w(o,i)||i;_(o[s])&&_(r)?o[s]=e(o[s],r):_(r)?o[s]=e({},r):h(r)?o[s]=r.slice():n&&p(r)||(o[s]=r)};for(let e=0,t=arguments.length;e<t;e++)arguments[e]&&P(arguments[e],r);return o},extend:(e,t,n,{allOwnKeys:r}={})=>(P(t,(t,r)=>{n&&m(t)?e[r]=o(t,n):e[r]=t},{allOwnKeys:r}),e),trim:e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,""),stripBOM:e=>(65279===e.charCodeAt(0)&&(e=e.slice(1)),e),inherits:(e,t,n,o)=>{e.prototype=Object.create(t.prototype,o),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},toFlatObject:(e,t,n,o)=>{let r,s,a;const l={};if(t=t||{},null==e)return t;do{for(r=Object.getOwnPropertyNames(e),s=r.length;s-- >0;)a=r[s],o&&!o(a,e,t)||l[a]||(t[a]=e[a],l[a]=!0);e=!1!==n&&i(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},kindOf:l,kindOfTest:u,endsWith:(e,t,n)=>{e=String(e),(void 0===n||n>e.length)&&(n=e.length),n-=t.length;const o=e.indexOf(t,n);return-1!==o&&o===n},toArray:e=>{if(!e)return null;if(h(e))return e;let t=e.length;if(!R(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},forEachEntry:(e,t)=>{const n=(e&&e[s]).call(e);let o;for(;(o=n.next())&&!o.done;){const n=o.value;t.call(e,n[0],n[1])}},matchAll:(e,t)=>{let n;const o=[];for(;null!==(n=e.exec(t));)o.push(n);return o},isHTMLForm:k,hasOwnProperty:M,hasOwnProp:M,reduceDescriptors:B,freezeMethods:e=>{B(e,(t,n)=>{if(m(e)&&-1!==["arguments","caller","callee"].indexOf(n))return!1;const o=e[n];m(o)&&(t.enumerable=!1,"writable"in t?t.writable=!1:t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")}))})},toObjectSet:(e,t)=>{const n={},o=e=>{e.forEach(e=>{n[e]=!0})};return h(e)?o(e):o(String(e).split(t)),n},toCamelCase:e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(e,t,n){return t.toUpperCase()+n}),noop:()=>{},toFiniteNumber:(e,t)=>null!=e&&Number.isFinite(e=+e)?e:t,findKey:w,global:D,isContextDefined:U,isSpecCompliantForm:function(e){return!!(e&&m(e.append)&&"FormData"===e[a]&&e[s])},toJSONObject:e=>{const t=new Array(10),n=(e,o)=>{if(b(e)){if(t.indexOf(e)>=0)return;if(g(e))return e;if(!("toJSON"in e)){t[o]=e;const r=h(e)?[]:{};return P(e,(e,t)=>{const i=n(e,o+1);!p(i)&&(r[t]=i)}),t[o]=void 0,r}}return e};return n(e,0)},isAsyncFn:F,isThenable:e=>e&&(b(e)||m(e))&&m(e.then)&&m(e.catch),setImmediate:V,asap:Q,isIterable:e=>null!=e&&m(e[s])};function z(e,t,n,o,r){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=(new Error).stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),o&&(this.request=o),r&&(this.response=r,this.status=r.status?r.status:null)}W.inherits(z,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:W.toJSONObject(this.config),code:this.code,status:this.status}}});const K=z.prototype,Y={};function X(e){return W.isPlainObject(e)||W.isArray(e)}function J(e){return W.endsWith(e,"[]")?e.slice(0,-2):e}function Z(e,t,n){return e?e.concat(t).map(function(e,t){return e=J(e),!n&&t?"["+e+"]":e}).join(n?".":""):t}["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{Y[e]={value:e}}),Object.defineProperties(z,Y),Object.defineProperty(K,"isAxiosError",{value:!0}),z.from=(e,t,n,o,r,i)=>{const s=Object.create(K);W.toFlatObject(e,s,function(e){return e!==Error.prototype},e=>"isAxiosError"!==e);const a=e&&e.message?e.message:"Error",l=null==t&&e?e.code:t;return z.call(s,a,l,n,o,r),e&&null==s.cause&&Object.defineProperty(s,"cause",{value:e,configurable:!0}),s.name=e&&e.name||"Error",i&&Object.assign(s,i),s};const ee=W.toFlatObject(W,{},null,function(e){return/^is[A-Z]/.test(e)});function te(e,t,n){if(!W.isObject(e))throw new TypeError("target must be an object");t=t||new FormData;const o=(n=W.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(e,t){return!W.isUndefined(t[e])})).metaTokens,r=n.visitor||c,i=n.dots,s=n.indexes,a=(n.Blob||"undefined"!=typeof Blob&&Blob)&&W.isSpecCompliantForm(t);if(!W.isFunction(r))throw new TypeError("visitor must be a function");function l(e){if(null===e)return"";if(W.isDate(e))return e.toISOString();if(W.isBoolean(e))return e.toString();if(!a&&W.isBlob(e))throw new z("Blob is not supported. Use a Buffer instead.");return W.isArrayBuffer(e)||W.isTypedArray(e)?a&&"function"==typeof Blob?new Blob([e]):Buffer.from(e):e}function c(e,n,r){let a=e;if(e&&!r&&"object"==typeof e)if(W.endsWith(n,"{}"))n=o?n:n.slice(0,-2),e=JSON.stringify(e);else if(W.isArray(e)&&function(e){return W.isArray(e)&&!e.some(X)}(e)||(W.isFileList(e)||W.endsWith(n,"[]"))&&(a=W.toArray(e)))return n=J(n),a.forEach(function(e,o){!W.isUndefined(e)&&null!==e&&t.append(!0===s?Z([n],o,i):null===s?n:n+"[]",l(e))}),!1;return!!X(e)||(t.append(Z(r,n,i),l(e)),!1)}const u=[],d=Object.assign(ee,{defaultVisitor:c,convertValue:l,isVisitable:X});if(!W.isObject(e))throw new TypeError("data must be an object");return function e(n,o){if(!W.isUndefined(n)){if(-1!==u.indexOf(n))throw Error("Circular reference detected in "+o.join("."));u.push(n),W.forEach(n,function(n,i){!0===(!(W.isUndefined(n)||null===n)&&r.call(t,n,W.isString(i)?i.trim():i,o,d))&&e(n,o?o.concat(i):[i])}),u.pop()}}(e),t}function ne(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(e){return t[e]})}function oe(e,t){this._pairs=[],e&&te(e,this,t)}const re=oe.prototype;function ie(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function se(e,t,n){if(!t)return e;const o=n&&n.encode||ie;W.isFunction(n)&&(n={serialize:n});const r=n&&n.serialize;let i;if(i=r?r(t,n):W.isURLSearchParams(t)?t.toString():new oe(t,n).toString(o),i){const t=e.indexOf("#");-1!==t&&(e=e.slice(0,t)),e+=(-1===e.indexOf("?")?"?":"&")+i}return e}re.append=function(e,t){this._pairs.push([e,t])},re.toString=function(e){const t=e?function(t){return e.call(this,t,ne)}:ne;return this._pairs.map(function(e){return t(e[0])+"="+t(e[1])},"").join("&")};var ae=class{constructor(){this.handlers=[]}use(e,t,n){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!n&&n.synchronous,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){W.forEach(this.handlers,function(t){null!==t&&e(t)})}},le={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},ce={isBrowser:!0,classes:{URLSearchParams:"undefined"!=typeof URLSearchParams?URLSearchParams:oe,FormData:"undefined"!=typeof FormData?FormData:null,Blob:"undefined"!=typeof Blob?Blob:null},protocols:["http","https","file","blob","url","data"]};const ue="undefined"!=typeof window&&"undefined"!=typeof document,de="object"==typeof navigator&&navigator||void 0,he=ue&&(!de||["ReactNative","NativeScript","NS"].indexOf(de.product)<0),pe="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&"function"==typeof self.importScripts,ge=ue&&window.location.href||"http://localhost";var Ee={...Object.freeze({__proto__:null,hasBrowserEnv:ue,hasStandardBrowserWebWorkerEnv:pe,hasStandardBrowserEnv:he,navigator:de,origin:ge}),...ce};function fe(e){function t(e,n,o,r){let i=e[r++];if("__proto__"===i)return!0;const s=Number.isFinite(+i),a=r>=e.length;return i=!i&&W.isArray(o)?o.length:i,a?(W.hasOwnProp(o,i)?o[i]=[o[i],n]:o[i]=n,!s):(o[i]&&W.isObject(o[i])||(o[i]=[]),t(e,n,o[i],r)&&W.isArray(o[i])&&(o[i]=function(e){const t={},n=Object.keys(e);let o;const r=n.length;let i;for(o=0;o<r;o++)i=n[o],t[i]=e[i];return t}(o[i])),!s)}if(W.isFormData(e)&&W.isFunction(e.entries)){const n={};return W.forEachEntry(e,(e,o)=>{t(function(e){return W.matchAll(/\w+|\[(\w*)]/g,e).map(e=>"[]"===e[0]?"":e[1]||e[0])}(e),o,n,0)}),n}return null}const me={transitional:le,adapter:["xhr","http","fetch"],transformRequest:[function(e,t){const n=t.getContentType()||"",o=n.indexOf("application/json")>-1,r=W.isObject(e);if(r&&W.isHTMLForm(e)&&(e=new FormData(e)),W.isFormData(e))return o?JSON.stringify(fe(e)):e;if(W.isArrayBuffer(e)||W.isBuffer(e)||W.isStream(e)||W.isFile(e)||W.isBlob(e)||W.isReadableStream(e))return e;if(W.isArrayBufferView(e))return e.buffer;if(W.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let i;if(r){if(n.indexOf("application/x-www-form-urlencoded")>-1)return function(e,t){return te(e,new Ee.classes.URLSearchParams,{visitor:function(e,t,n,o){return Ee.isNode&&W.isBuffer(e)?(this.append(t,e.toString("base64")),!1):o.defaultVisitor.apply(this,arguments)},...t})}(e,this.formSerializer).toString();if((i=W.isFileList(e))||n.indexOf("multipart/form-data")>-1){const t=this.env&&this.env.FormData;return te(i?{"files[]":e}:e,t&&new t,this.formSerializer)}}return r||o?(t.setContentType("application/json",!1),function(e){if(W.isString(e))try{return(0,JSON.parse)(e),W.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(0,JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){const t=this.transitional||me.transitional,n=t&&t.forcedJSONParsing,o="json"===this.responseType;if(W.isResponse(e)||W.isReadableStream(e))return e;if(e&&W.isString(e)&&(n&&!this.responseType||o)){const n=!(t&&t.silentJSONParsing)&&o;try{return JSON.parse(e,this.parseReviver)}catch(e){if(n){if("SyntaxError"===e.name)throw z.from(e,z.ERR_BAD_RESPONSE,this,null,this.response);throw e}}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:Ee.classes.FormData,Blob:Ee.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};W.forEach(["delete","get","head","post","put","patch"],e=>{me.headers[e]={}});var Re=me;const be=W.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),_e=Symbol("internals");function ve(e){return e&&String(e).trim().toLowerCase()}function Ae(e){return!1===e||null==e?e:W.isArray(e)?e.map(Ae):String(e)}function ye(e,t,n,o,r){return W.isFunction(o)?o.call(this,t,n):(r&&(t=n),W.isString(t)?W.isString(o)?-1!==t.indexOf(o):W.isRegExp(o)?o.test(t):void 0:void 0)}class Oe{constructor(e){e&&this.set(e)}set(e,t,n){const o=this;function r(e,t,n){const r=ve(t);if(!r)throw new Error("header name must be a non-empty string");const i=W.findKey(o,r);(!i||void 0===o[i]||!0===n||void 0===n&&!1!==o[i])&&(o[i||t]=Ae(e))}const i=(e,t)=>W.forEach(e,(e,n)=>r(e,n,t));if(W.isPlainObject(e)||e instanceof this.constructor)i(e,t);else if(W.isString(e)&&(e=e.trim())&&!/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim()))i((e=>{const t={};let n,o,r;return e&&e.split("\n").forEach(function(e){r=e.indexOf(":"),n=e.substring(0,r).trim().toLowerCase(),o=e.substring(r+1).trim(),!n||t[n]&&be[n]||("set-cookie"===n?t[n]?t[n].push(o):t[n]=[o]:t[n]=t[n]?t[n]+", "+o:o)}),t})(e),t);else if(W.isObject(e)&&W.isIterable(e)){let n,o,r={};for(const t of e){if(!W.isArray(t))throw TypeError("Object iterator must return a key-value pair");r[o=t[0]]=(n=r[o])?W.isArray(n)?[...n,t[1]]:[n,t[1]]:t[1]}i(r,t)}else null!=e&&r(t,e,n);return this}get(e,t){if(e=ve(e)){const n=W.findKey(this,e);if(n){const e=this[n];if(!t)return e;if(!0===t)return function(e){const t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let o;for(;o=n.exec(e);)t[o[1]]=o[2];return t}(e);if(W.isFunction(t))return t.call(this,e,n);if(W.isRegExp(t))return t.exec(e);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=ve(e)){const n=W.findKey(this,e);return!(!n||void 0===this[n]||t&&!ye(0,this[n],n,t))}return!1}delete(e,t){const n=this;let o=!1;function r(e){if(e=ve(e)){const r=W.findKey(n,e);!r||t&&!ye(0,n[r],r,t)||(delete n[r],o=!0)}}return W.isArray(e)?e.forEach(r):r(e),o}clear(e){const t=Object.keys(this);let n=t.length,o=!1;for(;n--;){const r=t[n];e&&!ye(0,this[r],r,e,!0)||(delete this[r],o=!0)}return o}normalize(e){const t=this,n={};return W.forEach(this,(o,r)=>{const i=W.findKey(n,r);if(i)return t[i]=Ae(o),void delete t[r];const s=e?function(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,t,n)=>t.toUpperCase()+n)}(r):String(r).trim();s!==r&&delete t[r],t[s]=Ae(o),n[s]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const t=Object.create(null);return W.forEach(this,(n,o)=>{null!=n&&!1!==n&&(t[o]=e&&W.isArray(n)?n.join(", "):n)}),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,t])=>e+": "+t).join("\n")}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){const n=new this(e);return t.forEach(e=>n.set(e)),n}static accessor(e){const t=(this[_e]=this[_e]={accessors:{}}).accessors,n=this.prototype;function o(e){const o=ve(e);t[o]||(function(e,t){const n=W.toCamelCase(" "+t);["get","set","has"].forEach(o=>{Object.defineProperty(e,o+n,{value:function(e,n,r){return this[o].call(this,t,e,n,r)},configurable:!0})})}(n,e),t[o]=!0)}return W.isArray(e)?e.forEach(o):o(e),this}}Oe.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),W.reduceDescriptors(Oe.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(e){this[n]=e}}}),W.freezeMethods(Oe);var Se=Oe;function Ie(e,t){const n=this||Re,o=t||n,r=Se.from(o.headers);let i=o.data;return W.forEach(e,function(e){i=e.call(n,i,r.normalize(),t?t.status:void 0)}),r.normalize(),i}function Ce(e){return!(!e||!e.__CANCEL__)}function Te(e,t,n){z.call(this,null==e?"canceled":e,z.ERR_CANCELED,t,n),this.name="CanceledError"}function Ne(e,t,n){const o=n.config.validateStatus;n.status&&o&&!o(n.status)?t(new z("Request failed with status code "+n.status,[z.ERR_BAD_REQUEST,z.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n)):e(n)}W.inherits(Te,z,{__CANCEL__:!0});const Pe=(e,t,n=3)=>{let o=0;const r=function(e,t){e=e||10;const n=new Array(e),o=new Array(e);let r,i=0,s=0;return t=void 0!==t?t:1e3,function(a){const l=Date.now(),c=o[s];r||(r=l),n[i]=a,o[i]=l;let u=s,d=0;for(;u!==i;)d+=n[u++],u%=e;if(i=(i+1)%e,i===s&&(s=(s+1)%e),l-r<t)return;const h=c&&l-c;return h?Math.round(1e3*d/h):void 0}}(50,250);return function(n,i){let s,a,l=0,c=1e3/i;const u=(n,i=Date.now())=>{l=i,s=null,a&&(clearTimeout(a),a=null),(n=>{const i=n.loaded,s=n.lengthComputable?n.total:void 0,a=i-o,l=r(a);o=i,e({loaded:i,total:s,progress:s?i/s:void 0,bytes:a,rate:l||void 0,estimated:l&&s&&i<=s?(s-i)/l:void 0,event:n,lengthComputable:null!=s,[t?"download":"upload"]:!0})})(...n)};return[(...e)=>{const t=Date.now(),n=t-l;n>=c?u(e,t):(s=e,a||(a=setTimeout(()=>{a=null,u(s)},c-n)))},()=>s&&u(s)]}(0,n)},we=(e,t)=>{const n=null!=e;return[o=>t[0]({lengthComputable:n,total:e,loaded:o}),t[1]]},De=e=>(...t)=>W.asap(()=>e(...t));var Ue=Ee.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,Ee.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(Ee.origin),Ee.navigator&&/(msie|trident)/i.test(Ee.navigator.userAgent)):()=>!0,Le=Ee.hasStandardBrowserEnv?{write(e,t,n,o,r,i){const s=[e+"="+encodeURIComponent(t)];W.isNumber(n)&&s.push("expires="+new Date(n).toGMTString()),W.isString(o)&&s.push("path="+o),W.isString(r)&&s.push("domain="+r),!0===i&&s.push("secure"),document.cookie=s.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read:()=>null,remove(){}};function xe(e,t,n){let o=!/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t);return e&&(o||0==n)?function(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}(e,t):t}const ke=e=>e instanceof Se?{...e}:e;function Me(e,t){t=t||{};const n={};function o(e,t,n,o){return W.isPlainObject(e)&&W.isPlainObject(t)?W.merge.call({caseless:o},e,t):W.isPlainObject(t)?W.merge({},t):W.isArray(t)?t.slice():t}function r(e,t,n,r){return W.isUndefined(t)?W.isUndefined(e)?void 0:o(void 0,e,0,r):o(e,t,0,r)}function i(e,t){if(!W.isUndefined(t))return o(void 0,t)}function s(e,t){return W.isUndefined(t)?W.isUndefined(e)?void 0:o(void 0,e):o(void 0,t)}function a(n,r,i){return i in t?o(n,r):i in e?o(void 0,n):void 0}const l={url:i,method:i,data:i,baseURL:s,transformRequest:s,transformResponse:s,paramsSerializer:s,timeout:s,timeoutMessage:s,withCredentials:s,withXSRFToken:s,adapter:s,responseType:s,xsrfCookieName:s,xsrfHeaderName:s,onUploadProgress:s,onDownloadProgress:s,decompress:s,maxContentLength:s,maxBodyLength:s,beforeRedirect:s,transport:s,httpAgent:s,httpsAgent:s,cancelToken:s,socketPath:s,responseEncoding:s,validateStatus:a,headers:(e,t,n)=>r(ke(e),ke(t),0,!0)};return W.forEach(Object.keys({...e,...t}),function(o){const i=l[o]||r,s=i(e[o],t[o],o);W.isUndefined(s)&&i!==a||(n[o]=s)}),n}var je=e=>{const t=Me({},e);let{data:n,withXSRFToken:o,xsrfHeaderName:r,xsrfCookieName:i,headers:s,auth:a}=t;if(t.headers=s=Se.from(s),t.url=se(xe(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),a&&s.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),W.isFormData(n))if(Ee.hasStandardBrowserEnv||Ee.hasStandardBrowserWebWorkerEnv)s.setContentType(void 0);else if(W.isFunction(n.getHeaders)){const e=n.getHeaders(),t=["content-type","content-length"];Object.entries(e).forEach(([e,n])=>{t.includes(e.toLowerCase())&&s.set(e,n)})}if(Ee.hasStandardBrowserEnv&&(o&&W.isFunction(o)&&(o=o(t)),o||!1!==o&&Ue(t.url))){const e=r&&i&&Le.read(i);e&&s.set(r,e)}return t},Be="undefined"!=typeof XMLHttpRequest&&function(e){return new Promise(function(t,n){const o=je(e);let r=o.data;const i=Se.from(o.headers).normalize();let s,a,l,c,u,{responseType:d,onUploadProgress:h,onDownloadProgress:p}=o;function g(){c&&c(),u&&u(),o.cancelToken&&o.cancelToken.unsubscribe(s),o.signal&&o.signal.removeEventListener("abort",s)}let E=new XMLHttpRequest;function f(){if(!E)return;const o=Se.from("getAllResponseHeaders"in E&&E.getAllResponseHeaders());Ne(function(e){t(e),g()},function(e){n(e),g()},{data:d&&"text"!==d&&"json"!==d?E.response:E.responseText,status:E.status,statusText:E.statusText,headers:o,config:e,request:E}),E=null}E.open(o.method.toUpperCase(),o.url,!0),E.timeout=o.timeout,"onloadend"in E?E.onloadend=f:E.onreadystatechange=function(){E&&4===E.readyState&&(0!==E.status||E.responseURL&&0===E.responseURL.indexOf("file:"))&&setTimeout(f)},E.onabort=function(){E&&(n(new z("Request aborted",z.ECONNABORTED,e,E)),E=null)},E.onerror=function(t){const o=new z(t&&t.message?t.message:"Network Error",z.ERR_NETWORK,e,E);o.event=t||null,n(o),E=null},E.ontimeout=function(){let t=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const r=o.transitional||le;o.timeoutErrorMessage&&(t=o.timeoutErrorMessage),n(new z(t,r.clarifyTimeoutError?z.ETIMEDOUT:z.ECONNABORTED,e,E)),E=null},void 0===r&&i.setContentType(null),"setRequestHeader"in E&&W.forEach(i.toJSON(),function(e,t){E.setRequestHeader(t,e)}),W.isUndefined(o.withCredentials)||(E.withCredentials=!!o.withCredentials),d&&"json"!==d&&(E.responseType=o.responseType),p&&([l,u]=Pe(p,!0),E.addEventListener("progress",l)),h&&E.upload&&([a,c]=Pe(h),E.upload.addEventListener("progress",a),E.upload.addEventListener("loadend",c)),(o.cancelToken||o.signal)&&(s=t=>{E&&(n(!t||t.type?new Te(null,e,E):t),E.abort(),E=null)},o.cancelToken&&o.cancelToken.subscribe(s),o.signal&&(o.signal.aborted?s():o.signal.addEventListener("abort",s)));const m=function(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}(o.url);m&&-1===Ee.protocols.indexOf(m)?n(new z("Unsupported protocol "+m+":",z.ERR_BAD_REQUEST,e)):E.send(r||null)})},Fe=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let n,o=new AbortController;const r=function(e){if(!n){n=!0,s();const t=e instanceof Error?e:this.reason;o.abort(t instanceof z?t:new Te(t instanceof Error?t.message:t))}};let i=t&&setTimeout(()=>{i=null,r(new z(`timeout ${t} of ms exceeded`,z.ETIMEDOUT))},t);const s=()=>{e&&(i&&clearTimeout(i),i=null,e.forEach(e=>{e.unsubscribe?e.unsubscribe(r):e.removeEventListener("abort",r)}),e=null)};e.forEach(e=>e.addEventListener("abort",r));const{signal:a}=o;return a.unsubscribe=()=>W.asap(s),a}};const Ve=function*(e,t){let n=e.byteLength;if(!t||n<t)return void(yield e);let o,r=0;for(;r<n;)o=r+t,yield e.slice(r,o),r=o},qe=(e,t,n,o)=>{const r=async function*(e,t){for await(const n of async function*(e){if(e[Symbol.asyncIterator])return void(yield*e);const t=e.getReader();try{for(;;){const{done:e,value:n}=await t.read();if(e)break;yield n}}finally{await t.cancel()}}(e))yield*Ve(n,t)}(e,t);let i,s=0,a=e=>{i||(i=!0,o&&o(e))};return new ReadableStream({async pull(e){try{const{done:t,value:o}=await r.next();if(t)return a(),void e.close();let i=o.byteLength;if(n){let e=s+=i;n(e)}e.enqueue(new Uint8Array(o))}catch(e){throw a(e),e}},cancel:e=>(a(e),r.return())},{highWaterMark:2})},{isFunction:He}=W,Ge=(({Request:e,Response:t})=>({Request:e,Response:t}))(W.global),{ReadableStream:$e,TextEncoder:Qe}=W.global,We=(e,...t)=>{try{return!!e(...t)}catch(e){return!1}},ze=e=>{e=W.merge.call({skipUndefined:!0},Ge,e);const{fetch:t,Request:n,Response:o}=e,r=t?He(t):"function"==typeof fetch,i=He(n),s=He(o);if(!r)return!1;const a=r&&He($e),l=r&&("function"==typeof Qe?(c=new Qe,e=>c.encode(e)):async e=>new Uint8Array(await new n(e).arrayBuffer()));var c;const u=i&&a&&We(()=>{let e=!1;const t=new n(Ee.origin,{body:new $e,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t}),d=s&&a&&We(()=>W.isReadableStream(new o("").body)),h={stream:d&&(e=>e.body)};r&&["text","arrayBuffer","blob","formData","stream"].forEach(e=>{!h[e]&&(h[e]=(t,n)=>{let o=t&&t[e];if(o)return o.call(t);throw new z(`Response type '${e}' is not supported`,z.ERR_NOT_SUPPORT,n)})});return async e=>{let{url:r,method:s,data:a,signal:c,cancelToken:p,timeout:g,onDownloadProgress:E,onUploadProgress:f,responseType:m,headers:R,withCredentials:b="same-origin",fetchOptions:_}=je(e),v=t||fetch;m=m?(m+"").toLowerCase():"text";let A=Fe([c,p&&p.toAbortSignal()],g),y=null;const O=A&&A.unsubscribe&&(()=>{A.unsubscribe()});let S;try{if(f&&u&&"get"!==s&&"head"!==s&&0!==(S=await(async(e,t)=>{const o=W.toFiniteNumber(e.getContentLength());return null==o?(async e=>{if(null==e)return 0;if(W.isBlob(e))return e.size;if(W.isSpecCompliantForm(e)){const t=new n(Ee.origin,{method:"POST",body:e});return(await t.arrayBuffer()).byteLength}return W.isArrayBufferView(e)||W.isArrayBuffer(e)?e.byteLength:(W.isURLSearchParams(e)&&(e+=""),W.isString(e)?(await l(e)).byteLength:void 0)})(t):o})(R,a))){let e,t=new n(r,{method:"POST",body:a,duplex:"half"});if(W.isFormData(a)&&(e=t.headers.get("content-type"))&&R.setContentType(e),t.body){const[e,n]=we(S,Pe(De(f)));a=qe(t.body,65536,e,n)}}W.isString(b)||(b=b?"include":"omit");const t=i&&"credentials"in n.prototype,c={..._,signal:A,method:s.toUpperCase(),headers:R.normalize().toJSON(),body:a,duplex:"half",credentials:t?b:void 0};y=i&&new n(r,c);let p=await(i?v(y,_):v(r,c));const g=d&&("stream"===m||"response"===m);if(d&&(E||g&&O)){const e={};["status","statusText","headers"].forEach(t=>{e[t]=p[t]});const t=W.toFiniteNumber(p.headers.get("content-length")),[n,r]=E&&we(t,Pe(De(E),!0))||[];p=new o(qe(p.body,65536,n,()=>{r&&r(),O&&O()}),e)}m=m||"text";let I=await h[W.findKey(h,m)||"text"](p,e);return!g&&O&&O(),await new Promise((t,n)=>{Ne(t,n,{data:I,headers:Se.from(p.headers),status:p.status,statusText:p.statusText,config:e,request:y})})}catch(t){if(O&&O(),t&&"TypeError"===t.name&&/Load failed|fetch/i.test(t.message))throw Object.assign(new z("Network Error",z.ERR_NETWORK,e,y),{cause:t.cause||t});throw z.from(t,t&&t.code,e,y)}}},Ke=new Map,Ye=e=>{let t=e?e.env:{};const{fetch:n,Request:o,Response:r}=t,i=[o,r,n];let s,a,l=i.length,c=Ke;for(;l--;)s=i[l],a=c.get(s),void 0===a&&c.set(s,a=l?new Map:ze(t)),c=a;return a};Ye();const Xe={http:null,xhr:Be,fetch:{get:Ye}};W.forEach(Xe,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch(e){}Object.defineProperty(e,"adapterName",{value:t})}});const Je=e=>`- ${e}`,Ze=e=>W.isFunction(e)||null===e||!1===e;var et=(e,t)=>{e=W.isArray(e)?e:[e];const{length:n}=e;let o,r;const i={};for(let s=0;s<n;s++){let n;if(o=e[s],r=o,!Ze(o)&&(r=Xe[(n=String(o)).toLowerCase()],void 0===r))throw new z(`Unknown adapter '${n}'`);if(r&&(W.isFunction(r)||(r=r.get(t))))break;i[n||"#"+s]=r}if(!r){const e=Object.entries(i).map(([e,t])=>`adapter ${e} `+(!1===t?"is not supported by the environment":"is not available in the build"));throw new z("There is no suitable adapter to dispatch the request "+(n?e.length>1?"since :\n"+e.map(Je).join("\n"):" "+Je(e[0]):"as no adapter specified"),"ERR_NOT_SUPPORT")}return r};function tt(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new Te(null,e)}function nt(e){return tt(e),e.headers=Se.from(e.headers),e.data=Ie.call(e,e.transformRequest),-1!==["post","put","patch"].indexOf(e.method)&&e.headers.setContentType("application/x-www-form-urlencoded",!1),et(e.adapter||Re.adapter,e)(e).then(function(t){return tt(e),t.data=Ie.call(e,e.transformResponse,t),t.headers=Se.from(t.headers),t},function(t){return Ce(t)||(tt(e),t&&t.response&&(t.response.data=Ie.call(e,e.transformResponse,t.response),t.response.headers=Se.from(t.response.headers))),Promise.reject(t)})}const ot="1.12.2",rt={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{rt[e]=function(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}});const it={};rt.transitional=function(e,t,n){function o(e,t){return"[Axios v"+ot+"] Transitional option '"+e+"'"+t+(n?". "+n:"")}return(n,r,i)=>{if(!1===e)throw new z(o(r," has been removed"+(t?" in "+t:"")),z.ERR_DEPRECATED);return t&&!it[r]&&(it[r]=!0,console.warn(o(r," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(n,r,i)}},rt.spelling=function(e){return(t,n)=>(console.warn(`${n} is likely a misspelling of ${e}`),!0)};var st={assertOptions:function(e,t,n){if("object"!=typeof e)throw new z("options must be an object",z.ERR_BAD_OPTION_VALUE);const o=Object.keys(e);let r=o.length;for(;r-- >0;){const i=o[r],s=t[i];if(s){const t=e[i],n=void 0===t||s(t,i,e);if(!0!==n)throw new z("option "+i+" must be "+n,z.ERR_BAD_OPTION_VALUE);continue}if(!0!==n)throw new z("Unknown option "+i,z.ERR_BAD_OPTION)}},validators:rt};const at=st.validators;class lt{constructor(e){this.defaults=e||{},this.interceptors={request:new ae,response:new ae}}async request(e,t){try{return await this._request(e,t)}catch(e){if(e instanceof Error){let t={};Error.captureStackTrace?Error.captureStackTrace(t):t=new Error;const n=t.stack?t.stack.replace(/^.+\n/,""):"";try{e.stack?n&&!String(e.stack).endsWith(n.replace(/^.+\n.+\n/,""))&&(e.stack+="\n"+n):e.stack=n}catch(e){}}throw e}}_request(e,t){"string"==typeof e?(t=t||{}).url=e:t=e||{},t=Me(this.defaults,t);const{transitional:n,paramsSerializer:o,headers:r}=t;void 0!==n&&st.assertOptions(n,{silentJSONParsing:at.transitional(at.boolean),forcedJSONParsing:at.transitional(at.boolean),clarifyTimeoutError:at.transitional(at.boolean)},!1),null!=o&&(W.isFunction(o)?t.paramsSerializer={serialize:o}:st.assertOptions(o,{encode:at.function,serialize:at.function},!0)),void 0!==t.allowAbsoluteUrls||(void 0!==this.defaults.allowAbsoluteUrls?t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:t.allowAbsoluteUrls=!0),st.assertOptions(t,{baseUrl:at.spelling("baseURL"),withXsrfToken:at.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let i=r&&W.merge(r.common,r[t.method]);r&&W.forEach(["delete","get","head","post","put","patch","common"],e=>{delete r[e]}),t.headers=Se.concat(i,r);const s=[];let a=!0;this.interceptors.request.forEach(function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(a=a&&e.synchronous,s.unshift(e.fulfilled,e.rejected))});const l=[];let c;this.interceptors.response.forEach(function(e){l.push(e.fulfilled,e.rejected)});let u,d=0;if(!a){const e=[nt.bind(this),void 0];for(e.unshift(...s),e.push(...l),u=e.length,c=Promise.resolve(t);d<u;)c=c.then(e[d++],e[d++]);return c}u=s.length;let h=t;for(;d<u;){const e=s[d++],t=s[d++];try{h=e(h)}catch(e){t.call(this,e);break}}try{c=nt.call(this,h)}catch(e){return Promise.reject(e)}for(d=0,u=l.length;d<u;)c=c.then(l[d++],l[d++]);return c}getUri(e){return se(xe((e=Me(this.defaults,e)).baseURL,e.url,e.allowAbsoluteUrls),e.params,e.paramsSerializer)}}W.forEach(["delete","get","head","options"],function(e){lt.prototype[e]=function(t,n){return this.request(Me(n||{},{method:e,url:t,data:(n||{}).data}))}}),W.forEach(["post","put","patch"],function(e){function t(t){return function(n,o,r){return this.request(Me(r||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:n,data:o}))}}lt.prototype[e]=t(),lt.prototype[e+"Form"]=t(!0)});var ct=lt;class ut{constructor(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");let t;this.promise=new Promise(function(e){t=e});const n=this;this.promise.then(e=>{if(!n._listeners)return;let t=n._listeners.length;for(;t-- >0;)n._listeners[t](e);n._listeners=null}),this.promise.then=e=>{let t;const o=new Promise(e=>{n.subscribe(e),t=e}).then(e);return o.cancel=function(){n.unsubscribe(t)},o},e(function(e,o,r){n.reason||(n.reason=new Te(e,o,r),t(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const t=this._listeners.indexOf(e);-1!==t&&this._listeners.splice(t,1)}toAbortSignal(){const e=new AbortController,t=t=>{e.abort(t)};return this.subscribe(t),e.signal.unsubscribe=()=>this.unsubscribe(t),e.signal}static source(){let e;return{token:new ut(function(t){e=t}),cancel:e}}}var dt=ut;const ht={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(ht).forEach(([e,t])=>{ht[t]=e});var pt=ht;const gt=function e(t){const n=new ct(t),r=o(ct.prototype.request,n);return W.extend(r,ct.prototype,n,{allOwnKeys:!0}),W.extend(r,n,null,{allOwnKeys:!0}),r.create=function(n){return e(Me(t,n))},r}(Re);gt.Axios=ct,gt.CanceledError=Te,gt.CancelToken=dt,gt.isCancel=Ce,gt.VERSION=ot,gt.toFormData=te,gt.AxiosError=z,gt.Cancel=gt.CanceledError,gt.all=function(e){return Promise.all(e)},gt.spread=function(e){return function(t){return e.apply(null,t)}},gt.isAxiosError=function(e){return W.isObject(e)&&!0===e.isAxiosError},gt.mergeConfig=Me,gt.AxiosHeaders=Se,gt.formToJSON=e=>fe(W.isHTMLForm(e)?new FormData(e):e),gt.getAdapter=et,gt.HttpStatusCode=pt,gt.default=gt,e.exports=gt},495:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.validatePhoneNumber=function(e){return e?e.startsWith("+")?e.length<8?{valid:!1,error:"Phone number too short for E.164 format (minimum 8 characters including +)"}:e.length>16?{valid:!1,error:"Phone number too long for E.164 format (maximum 15 digits after +)"}:/^\+\d+$/.test(e)?/^\+[1-9]\d{1,14}$/.test(e)?{valid:!0}:{valid:!1,error:"Invalid E.164 phone number format"}:{valid:!1,error:"Phone number contains invalid characters. E.164 format only allows + followed by digits"}:{valid:!1,error:"Phone number must be in E.164 format (start with +)"}:{valid:!0}},t.validatePlmn=function(e){if(!e)return{valid:!0};const{mcc:t,mnc:n}=e;return t&&/^\d{3}$/.test(t)?n&&/^\d{2,3}$/.test(n)?{valid:!0}:{valid:!1,error:"MNC must be 2 or 3 digits"}:{valid:!1,error:"MCC must be exactly 3 digits"}},t.validateUseCaseRequirements=function(e,t,n){return e!==o.USE_CASE.VERIFY_PHONE_NUMBER||t||n?{valid:!0}:{valid:!1,error:"Phone number is required for VerifyPhoneNumber use case"}},t.validateConsentData=function(e){if(!e)return{valid:!0};const{consent_text:t,policy_link:n,policy_text:o}=e;if(!t||0===t.trim().length)return{valid:!1,error:"Consent text is required when consent data is provided"};if(!n||0===n.trim().length)return{valid:!1,error:"Policy link is required when consent data is provided"};try{new URL(n)}catch(e){return{valid:!1,error:"Policy link must be a valid URL"}}return o&&0!==o.trim().length?{valid:!0}:{valid:!1,error:"Policy text is required when consent data is provided"}},t.createValidationError=function(e,t,n){const o=new Error(t);return o.code=e,n&&(o.field=n),o},t.validateNonce=function(e){return e&&0!==e.length?/^[A-Za-z0-9_-]+$/.test(e)?e.length<32||e.length>128?{valid:!1,error:"Nonce must be between 32 and 128 characters"}:{valid:!0}:{valid:!1,error:"Nonce must be base64url encoded"}:{valid:!1,error:"Nonce is required"}};const o=n(566)},499:function(e,t,n){var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))(function(r,i){function s(e){try{l(o.next(e))}catch(e){i(e)}}function a(e){try{l(o.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}l((o=o.apply(e,t||[])).next())})},r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.SDKClient=void 0;const i=r(n(425)),s=n(514);t.SDKClient=class{constructor(e){this.config=e,this.client=i.default.create({baseURL:e.baseURL||"",timeout:e.timeout||1e4,headers:{"Content-Type":"application/json"}}),this.phoneAuth=new s.PhoneAuthClient({endpoints:e.phoneAuthEndpoints?{prepare:e.phoneAuthEndpoints.prepareRequest,process:e.phoneAuthEndpoints.processResponse}:void 0,debug:e.debug}),this.client.interceptors.request.use(e=>o(this,void 0,void 0,function*(){return this.token&&(e.headers.Authorization=`Bearer ${this.token}`),e}))}setToken(e){this.token=e}clearToken(){this.token=void 0}get(e,t){return o(this,void 0,void 0,function*(){if(!this.config.baseURL)throw new Error("baseURL is required for making API requests. Please provide it in the ClientConfig.");const n=yield this.client.get(e,{headers:null==t?void 0:t.headers,params:null==t?void 0:t.params});return{data:n.data,status:n.status,headers:Object.fromEntries(Object.entries(n.headers).map(([e,t])=>[e,String(t)]))}})}}},514:function(e,t,n){var o=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,r)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),r=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||o(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),t.requiresUserAction=t.requiresPolling=t.isHeadlessResult=t.hasTrigger=t.hasPollingControls=t.getStrategy=t.isDesktopStrategy=t.isTS43Strategy=t.isLinkStrategy=t.isAuthCredential=t.isCredential=t.isExtendedResponse=t.MobileDebugConsole=t.validateNonce=t.validateConsentData=t.validateUseCaseRequirements=t.validatePlmn=t.validatePhoneNumber=t.createErrorBreadcrumb=t.serializeError=t.isRetryableError=t.getRetryDelay=t.isErrorCode=t.getUserMessage=t.isUserError=t.isPhoneAuthError=t.PhoneAuthErrorCode=t.PhoneAuthClient=void 0;var i=n(895);Object.defineProperty(t,"PhoneAuthClient",{enumerable:!0,get:function(){return i.PhoneAuthClient}}),r(n(931),t);var s=n(192);Object.defineProperty(t,"PhoneAuthErrorCode",{enumerable:!0,get:function(){return s.PhoneAuthErrorCode}}),Object.defineProperty(t,"isPhoneAuthError",{enumerable:!0,get:function(){return s.isPhoneAuthError}}),Object.defineProperty(t,"isUserError",{enumerable:!0,get:function(){return s.isUserError}}),Object.defineProperty(t,"getUserMessage",{enumerable:!0,get:function(){return s.getUserMessage}}),Object.defineProperty(t,"isErrorCode",{enumerable:!0,get:function(){return s.isErrorCode}}),Object.defineProperty(t,"getRetryDelay",{enumerable:!0,get:function(){return s.getRetryDelay}}),Object.defineProperty(t,"isRetryableError",{enumerable:!0,get:function(){return s.isRetryableError}}),Object.defineProperty(t,"serializeError",{enumerable:!0,get:function(){return s.serializeError}}),Object.defineProperty(t,"createErrorBreadcrumb",{enumerable:!0,get:function(){return s.createErrorBreadcrumb}});var a=n(495);Object.defineProperty(t,"validatePhoneNumber",{enumerable:!0,get:function(){return a.validatePhoneNumber}}),Object.defineProperty(t,"validatePlmn",{enumerable:!0,get:function(){return a.validatePlmn}}),Object.defineProperty(t,"validateUseCaseRequirements",{enumerable:!0,get:function(){return a.validateUseCaseRequirements}}),Object.defineProperty(t,"validateConsentData",{enumerable:!0,get:function(){return a.validateConsentData}}),Object.defineProperty(t,"validateNonce",{enumerable:!0,get:function(){return a.validateNonce}});var l=n(545);Object.defineProperty(t,"MobileDebugConsole",{enumerable:!0,get:function(){return l.MobileDebugConsole}});var c=n(363);Object.defineProperty(t,"isExtendedResponse",{enumerable:!0,get:function(){return c.isExtendedResponse}}),Object.defineProperty(t,"isCredential",{enumerable:!0,get:function(){return c.isCredential}}),Object.defineProperty(t,"isAuthCredential",{enumerable:!0,get:function(){return c.isAuthCredential}}),Object.defineProperty(t,"isLinkStrategy",{enumerable:!0,get:function(){return c.isLinkStrategy}}),Object.defineProperty(t,"isTS43Strategy",{enumerable:!0,get:function(){return c.isTS43Strategy}}),Object.defineProperty(t,"isDesktopStrategy",{enumerable:!0,get:function(){return c.isDesktopStrategy}}),Object.defineProperty(t,"getStrategy",{enumerable:!0,get:function(){return c.getStrategy}}),Object.defineProperty(t,"hasPollingControls",{enumerable:!0,get:function(){return c.hasPollingControls}}),Object.defineProperty(t,"hasTrigger",{enumerable:!0,get:function(){return c.hasTrigger}}),Object.defineProperty(t,"isHeadlessResult",{enumerable:!0,get:function(){return c.isHeadlessResult}}),Object.defineProperty(t,"requiresPolling",{enumerable:!0,get:function(){return c.requiresPolling}}),Object.defineProperty(t,"requiresUserAction",{enumerable:!0,get:function(){return c.requiresUserAction}})},544:function(e,t){var n=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))(function(r,i){function s(e){try{l(o.next(e))}catch(e){i(e)}}function a(e){try{l(o.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}l((o=o.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.LinkHandler=void 0,t.LinkHandler=class{constructor(){this.isPollingActive=!1,this.isCancelled=!1,this.isPollingInProgress=!1}invoke(e,t){return n(this,void 0,void 0,function*(){console.log("[Link Auth] 🔗 invoke() called with data:",JSON.stringify(e,null,2)),console.log("[Link Auth] Options:",t?JSON.stringify({pollingInterval:t.pollingInterval,maxPollingAttempts:t.maxPollingAttempts,pollingEndpoint:t.pollingEndpoint}):"none");const n=e.data;if(!n||!n.url)throw new Error("Invalid link data: missing URL");const o=e.session.session_key;return console.log("[Link Auth] Session key:",o),console.log("[Link Auth] Link URL:",n.url),this.openAuthenticationLink(n.url),(null==t?void 0:t.onLinkOpened)&&t.onLinkOpened(),this.startPolling(o,n,t)})}openAuthenticationLink(e){const t=window.open(e,"_blank");t&&!t.closed&&void 0!==t.closed||console.warn("[LinkHandler] Failed to open app link - popup may have been blocked")}startPolling(e,t,o){return n(this,void 0,void 0,function*(){const r=(null==o?void 0:o.pollingInterval)||2e3,i=(null==o?void 0:o.maxPollingAttempts)||30;let s=0;return console.log("[Link Auth] 🚀 Starting polling:",{sessionKey:e,interval:`${r}ms`,maxAttempts:i,linkDataAvailable:!!t}),new Promise((a,l)=>{this.isPollingActive=!0,this.pollingReject=l;const c=()=>n(this,void 0,void 0,function*(){if(!this.isPollingActive)return;if(this.isPollingInProgress)return;let n="";try{if(this.isPollingInProgress=!0,s>=i){this.stopPolling(),(null==o?void 0:o.onTimeout)&&o.onTimeout();const e=Math.round(i*r/1e3),t=e>=60?`${Math.floor(e/60)} minute${Math.floor(e/60)>1?"s":""}`:`${e} seconds`;return(null==o?void 0:o.onStatusUpdate)&&o.onStatusUpdate({status:"expired",message:`Authentication timeout after ${t}`}),void l(new Error(`Authentication timeout after ${t}`))}let c=null==o?void 0:o.pollingEndpoint,u="options";if(!c&&t.status_url&&(c=t.status_url,u="backend"),console.log("[Link Auth] Polling endpoint selection:"),console.log(" - options?.pollingEndpoint:",null==o?void 0:o.pollingEndpoint),console.log(" - linkData.status_url:",t.status_url),console.log(" - selected endpoint:",c,"from source:",u),c&&(c.startsWith("http://")||c.startsWith("https://")))if(c.includes("{{session_id}}"))n=c.replace("{{session_id}}",e);else if(c.includes(e))n=c;else{const t=new URL(c);n=`${t.protocol}//${t.host}/public/public/status/${e}`}else if(c&&""!==c){const t="undefined"!=typeof window?window.location.origin:"";n=c.includes("{{session_id}}")?t+c.replace("{{session_id}}",e):t+c+"/"+e}else n=`https://api.glideidentity.app/public/public/status/${e}`,u="fallback";console.log(`[Link Auth] Using ${u} endpoint: ${n}`),console.log(`[Link Auth] Polling status (attempt ${s}/${i}): ${n}`);const d=yield fetch(n,{method:"GET",headers:{Accept:"application/json"}});if(console.log(`[Link Auth] Poll response - Status: ${d.status}, OK: ${d.ok}`),200===d.status){const t=yield d.json();console.log("[Link Auth] Poll response data:",JSON.stringify(t,null,2)),"completed"===t.status?(console.log("[Link Auth] ✅ Authentication COMPLETED! Session:",e),console.log("[Link Auth] Full completion result:",JSON.stringify(t,null,2)),this.stopPolling(),(null==o?void 0:o.onStatusUpdate)&&o.onStatusUpdate({status:"authenticated",message:"Authentication successful",data:t}),this.pollingReject=void 0,a({authenticated:!0,credential:t.credential||e,session:t.session||{session_key:e,status:t.status,protocol:t.protocol||"link",created_at:t.created_at,last_updated:t.last_updated}})):"pending"===t.status?(console.log("[Link Auth] Status still pending, continuing to poll..."),s++,(null==o?void 0:o.onStatusUpdate)&&o.onStatusUpdate({status:"pending",message:"Waiting for app authentication..."})):(console.log("[Link Auth] ⚠️ Unexpected status value:",t.status,"Full result:",JSON.stringify(t,null,2)),s++)}else if(410===d.status){console.log("[Link Auth] ❌ Session expired (410)"),this.stopPolling();const e=yield d.json().catch(()=>({message:"Session expired"}));(null==o?void 0:o.onTimeout)&&o.onTimeout(),(null==o?void 0:o.onStatusUpdate)&&o.onStatusUpdate({status:"expired",message:e.message||"Session expired"}),l(new Error(e.message||"Session expired"))}else if(422===d.status){console.log("[Link Auth] ❌ Authentication failed (422)"),this.stopPolling();const e=yield d.json().catch(()=>({message:"Authentication failed"}));console.log("[Link Auth] Error data:",JSON.stringify(e,null,2));const t="USER_CANCELLED"===e.code?"User cancelled authentication":e.message||"Verification failed";(null==o?void 0:o.onStatusUpdate)&&o.onStatusUpdate({status:"error",message:t}),l(new Error(t))}else if(404===d.status)console.log("[Link Auth] ❌ Session not found (404)"),this.stopPolling(),(null==o?void 0:o.onStatusUpdate)&&o.onStatusUpdate({status:"error",message:"Session not found"}),l(new Error("Session not found"));else if(400===d.status){console.log("[Link Auth] ❌ Invalid session key (400)"),this.stopPolling();const e=yield d.json().catch(()=>({message:"Invalid session key"}));console.log("[Link Auth] Error data:",JSON.stringify(e,null,2)),l(new Error(e.message||"Invalid session key"))}else{console.log("[Link Auth] ⚠️ Unexpected HTTP status:",d.status,"continuing to poll..."),s++;try{const e=yield d.text();console.log("[Link Auth] Response body:",e)}catch(e){console.log("[Link Auth] Could not read response body")}}}catch(e){console.error("[Link Auth] 🔴 Polling error:",e.message||e),s++,console.error("[Link Auth] Error details:",{name:e.name,message:e.message,stack:e.stack,statusUrl:n,attempt:s,error:e}),e.message&&e.message.toLowerCase().includes("failed")&&(console.error("[Link Auth] ⚠️ Possible CORS issue. Status URL:",n),console.error("[Link Auth] Make sure the API endpoint allows CORS from your ngrok domain")),(null==o?void 0:o.onStatusUpdate)&&o.onStatusUpdate({status:"pending",message:`Connection issue, retrying... (${s}/${i})`})}finally{this.isPollingInProgress=!1}});c(),this.pollingInterval=setInterval(c,r)})})}stopPolling(){console.log("[Link Auth] 🏁 Stopping polling"),this.isPollingActive=!1,this.isPollingInProgress=!1,this.pollingInterval&&(clearInterval(this.pollingInterval),this.pollingInterval=void 0)}formatResponse(e){if(!e.authenticated||!e.credential)throw new Error("Authentication not completed");return{credential:e.credential,session:e.session,type:"link"}}isSupported(){return/iPhone|iPad|iPod|Android/i.test(navigator.userAgent)}cleanup(){this.stopPolling(),this.isCancelled=!1,this.onCancel=void 0,this.pollingReject=void 0}isPolling(){return void 0!==this.pollingInterval}cancel(){var e;console.log("[Link Auth] Cancelling authentication"),this.isCancelled=!0,this.stopPolling(),null===(e=this.onCancel)||void 0===e||e.call(this),this.pollingReject&&(this.pollingReject({code:"USER_DENIED",message:"Authentication cancelled by user"}),this.pollingReject=void 0)}}},545:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.MobileDebugConsole=void 0;class n{constructor(){this.logs=[],this.container=null,this.logsContainer=null,this.floatingToggle=null,this.isAtBottom=!0,this.isVisible=!0,this.originalConsole={log:console.log,error:console.error,warn:console.warn,debug:console.debug,info:console.info},this.interceptConsole(),this.createUI()}static init(){return n.instance||(n.instance=new n),n.instance}static destroy(){n.instance&&(n.instance.cleanup(),n.instance=null)}interceptConsole(){["log","error","warn","debug","info"].forEach(e=>{const t=this.originalConsole[e];console[e]=(...n)=>{t.apply(console,n),this.addLog(e,n)}})}addLog(e,t){const n=(new Date).toTimeString().split(" ")[0],o=t.map(e=>{if("object"==typeof e)try{return JSON.stringify(e,null,2)}catch(e){return"[Object]"}return String(e)}).join(" "),r={log:"#fff",error:"#ff6b6b",warn:"#ffd93d",info:"#6bcf7f",debug:"#95a5a6"},i=`\n <div style="margin: 4px 0; font-family: monospace; font-size: 11px; color: ${r[e]||"#fff"};">\n <span style="color: #666;">[${n}]</span>\n <span style="color: ${r[e]}; font-weight: bold; text-transform: uppercase; font-size: 9px;">[${e}]</span>\n <span style="white-space: pre-wrap; word-break: break-all;">${this.escapeHtml(o)}</span>\n </div>\n `;this.logs.push(i),this.logs.length>500&&this.logs.shift(),this.updateDisplay()}updateDisplay(){this.logsContainer&&this.isVisible&&(this.isAtBottom=this.logsContainer.scrollHeight-this.logsContainer.scrollTop<=this.logsContainer.clientHeight+50,this.logsContainer.innerHTML=this.logs.join(""),this.isAtBottom&&(this.logsContainer.scrollTop=this.logsContainer.scrollHeight))}createUI(){const e=document.createElement("style");e.textContent="\n #mobile-debug-console {\n position: fixed;\n bottom: 0;\n left: 0;\n right: 0;\n height: 45vh;\n background: rgba(0, 0, 0, 0.95);\n z-index: 999999;\n display: flex;\n flex-direction: column;\n font-family: monospace;\n transition: transform 0.3s ease;\n }\n \n #mobile-debug-console.hidden {\n transform: translateY(100%);\n }\n \n #debug-header {\n display: flex;\n justify-content: space-between;\n align-items: center;\n padding: 10px;\n background: #1a1a1a;\n border-top: 2px solid #333;\n }\n \n #debug-title {\n color: #0f0;\n font-size: 12px;\n font-weight: bold;\n }\n \n #debug-buttons {\n display: flex;\n gap: 10px;\n }\n \n #debug-buttons button {\n padding: 5px 10px;\n background: #333;\n color: #fff;\n border: 1px solid #555;\n border-radius: 3px;\n font-size: 11px;\n cursor: pointer;\n }\n \n #debug-buttons button:active {\n background: #555;\n }\n \n #debug-logs {\n flex: 1;\n overflow-y: auto;\n padding: 10px;\n -webkit-overflow-scrolling: touch;\n }\n \n #debug-floating-toggle {\n position: fixed;\n bottom: 20px;\n right: 20px;\n width: 50px;\n height: 50px;\n border-radius: 50%;\n background: rgba(0, 0, 0, 0.8);\n border: 2px solid #0f0;\n color: #0f0;\n cursor: pointer;\n z-index: 999998;\n display: none;\n align-items: center;\n justify-content: center;\n font-size: 24px;\n box-shadow: 0 2px 10px rgba(0, 255, 0, 0.3);\n transition: all 0.3s ease;\n }\n \n #debug-floating-toggle:hover {\n background: rgba(0, 0, 0, 0.9);\n transform: scale(1.1);\n box-shadow: 0 4px 15px rgba(0, 255, 0, 0.5);\n }\n \n #debug-floating-toggle.visible {\n display: flex;\n }\n ",document.head.appendChild(e),this.container=document.createElement("div"),this.container.id="mobile-debug-console",this.isVisible||(this.container.className="hidden");const t=document.createElement("div");t.id="debug-header";const n=document.createElement("div");n.id="debug-title",n.textContent="📱 Mobile Debug Console";const o=document.createElement("div");o.id="debug-buttons";const r=document.createElement("button");r.textContent="Clear",r.onclick=()=>this.clear();const i=document.createElement("button");i.textContent="Hide",i.onclick=()=>this.toggle();const s=document.createElement("button");s.textContent="✕",s.style.color="#ff6b6b",s.onclick=()=>this.cleanup(),o.appendChild(r),o.appendChild(i),o.appendChild(s),t.appendChild(n),t.appendChild(o),this.logsContainer=document.createElement("div"),this.logsContainer.id="debug-logs",this.logsContainer.addEventListener("scroll",()=>{this.isAtBottom=this.logsContainer.scrollHeight-this.logsContainer.scrollTop<=this.logsContainer.clientHeight+50}),this.container.appendChild(t),this.container.appendChild(this.logsContainer),document.body.appendChild(this.container),this.floatingToggle=document.createElement("button"),this.floatingToggle.id="debug-floating-toggle",this.floatingToggle.innerHTML="🖥️",this.floatingToggle.title="Show Debug Console",this.floatingToggle.onclick=()=>this.toggle(),document.body.appendChild(this.floatingToggle),window.__debugToggleBtn=i}escapeHtml(e){const t=document.createElement("div");return t.textContent=e,t.innerHTML}toggle(){this.isVisible=!this.isVisible,this.container&&this.floatingToggle&&(this.isVisible?(this.container.classList.remove("hidden"),this.floatingToggle.classList.remove("visible"),window.__debugToggleBtn.textContent="Hide",this.updateDisplay()):(this.container.classList.add("hidden"),this.floatingToggle.classList.add("visible"),window.__debugToggleBtn.textContent="Show"))}clear(){this.logs=[],this.logsContainer&&(this.logsContainer.innerHTML="")}cleanup(){Object.keys(this.originalConsole).forEach(e=>{console[e]=this.originalConsole[e]}),this.container&&this.container.remove(),this.floatingToggle&&this.floatingToggle.remove(),delete window.__debugToggleBtn}}t.MobileDebugConsole=n,n.instance=null},566:(e,t)=>{function n(e){return t.E164_REGEX.test(e)}function o(e){return!!/^\d{3}$/.test(e.mcc)&&!!/^\d{2,3}$/.test(e.mnc)}function r(e){return!(!e.session_key||e.session_key.length<16)}function i(e){return e===t.USE_CASE.GET_PHONE_NUMBER||e===t.USE_CASE.VERIFY_PHONE_NUMBER}function s(e,n,o){return{code:e,message:t.ERROR_MESSAGES[e],request_id:o,timestamp:(new Date).toISOString(),details:n}}function a(e){return t.ERROR_STATUS_CODES[e]||500}function l(e){return e&&"string"==typeof e.protocol&&e.data&&e.data.dcql_query}function c(e){return e&&e.url&&"string"==typeof e.url}function u(e){return e&&"string"==typeof e.code&&"string"==typeof e.message}Object.defineProperty(t,"__esModule",{value:!0}),t.E164_REGEX=t.ERROR_STATUS_CODES=t.ERROR_MESSAGES=t.ERROR_CODE=t.AUTHENTICATION_STRATEGY=t.USE_CASE=void 0,t.validatePhoneNumber=n,t.validatePLMN=o,t.validateSession=r,t.validateUseCase=i,t.createErrorResponse=s,t.getErrorStatusCode=a,t.isTS43Data=l,t.isLinkData=c,t.isErrorResponse=u,t.USE_CASE={GET_PHONE_NUMBER:"GetPhoneNumber",VERIFY_PHONE_NUMBER:"VerifyPhoneNumber"},t.AUTHENTICATION_STRATEGY={TS43:"ts43",LINK:"link",DESKTOP:"desktop"},t.ERROR_CODE={INVALID_PHONE_NUMBER:"INVALID_PHONE_NUMBER",MISSING_REQUIRED_FIELD:"MISSING_REQUIRED_FIELD",INVALID_USE_CASE:"INVALID_USE_CASE",INVALID_SESSION:"INVALID_SESSION",SESSION_EXPIRED:"SESSION_EXPIRED",CARRIER_NOT_ELIGIBLE:"CARRIER_NOT_ELIGIBLE",UNSUPPORTED_PLATFORM:"UNSUPPORTED_PLATFORM",PHONE_NUMBER_MISMATCH:"PHONE_NUMBER_MISMATCH",INVALID_CREDENTIAL:"INVALID_CREDENTIAL",VERIFICATION_FAILED:"VERIFICATION_FAILED",USE_CASE_MISMATCH:"USE_CASE_MISMATCH",RATE_LIMIT_EXCEEDED:"RATE_LIMIT_EXCEEDED",INTERNAL_SERVER_ERROR:"INTERNAL_SERVER_ERROR",SERVICE_UNAVAILABLE:"SERVICE_UNAVAILABLE"},t.ERROR_MESSAGES={[t.ERROR_CODE.INVALID_PHONE_NUMBER]:"Phone number must be in E.164 format",[t.ERROR_CODE.MISSING_REQUIRED_FIELD]:"Required field is missing",[t.ERROR_CODE.INVALID_USE_CASE]:"Use case must be 'GetPhoneNumber' or 'VerifyPhoneNumber'",[t.ERROR_CODE.INVALID_SESSION]:"Session not found or expired",[t.ERROR_CODE.SESSION_EXPIRED]:"Session has expired",[t.ERROR_CODE.CARRIER_NOT_ELIGIBLE]:"Your carrier does not support this verification method",[t.ERROR_CODE.UNSUPPORTED_PLATFORM]:"Your platform is not supported",[t.ERROR_CODE.PHONE_NUMBER_MISMATCH]:"Phone number does not match the device",[t.ERROR_CODE.INVALID_CREDENTIAL]:"Invalid or expired credential",[t.ERROR_CODE.VERIFICATION_FAILED]:"Phone number verification failed",[t.ERROR_CODE.USE_CASE_MISMATCH]:"Session was prepared for a different use case",[t.ERROR_CODE.RATE_LIMIT_EXCEEDED]:"Too many requests. Please try again later",[t.ERROR_CODE.INTERNAL_SERVER_ERROR]:"An unexpected error occurred",[t.ERROR_CODE.SERVICE_UNAVAILABLE]:"Service temporarily unavailable"},t.ERROR_STATUS_CODES={[t.ERROR_CODE.INVALID_PHONE_NUMBER]:400,[t.ERROR_CODE.MISSING_REQUIRED_FIELD]:400,[t.ERROR_CODE.INVALID_USE_CASE]:400,[t.ERROR_CODE.INVALID_SESSION]:404,[t.ERROR_CODE.SESSION_EXPIRED]:404,[t.ERROR_CODE.CARRIER_NOT_ELIGIBLE]:422,[t.ERROR_CODE.UNSUPPORTED_PLATFORM]:422,[t.ERROR_CODE.PHONE_NUMBER_MISMATCH]:422,[t.ERROR_CODE.INVALID_CREDENTIAL]:422,[t.ERROR_CODE.VERIFICATION_FAILED]:422,[t.ERROR_CODE.USE_CASE_MISMATCH]:422,[t.ERROR_CODE.RATE_LIMIT_EXCEEDED]:429,[t.ERROR_CODE.INTERNAL_SERVER_ERROR]:500,[t.ERROR_CODE.SERVICE_UNAVAILABLE]:503},t.E164_REGEX=/^\+[1-9]\d{1,14}$/,t.default={USE_CASE:t.USE_CASE,AUTHENTICATION_STRATEGY:t.AUTHENTICATION_STRATEGY,ERROR_CODE:t.ERROR_CODE,ERROR_MESSAGES:t.ERROR_MESSAGES,ERROR_STATUS_CODES:t.ERROR_STATUS_CODES,E164_REGEX:t.E164_REGEX,validatePhoneNumber:n,validatePLMN:o,validateSession:r,validateUseCase:i,isTS43Data:l,isLinkData:c,isErrorResponse:u,createErrorResponse:s,getErrorStatusCode:a}},724:function(e,t,n){var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))(function(r,i){function s(e){try{l(o.next(e))}catch(e){i(e)}}function a(e){try{l(o.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}l((o=o.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.PhoneAuthManager=void 0;const r=n(514);t.PhoneAuthManager=class{constructor(e={}){this.listeners=[],this.client=new r.PhoneAuthClient(e),this.state={isLoading:!1,error:null,result:null,currentStep:"idle",isSupported:this.client.isSupported()}}getState(){return Object.assign({},this.state)}subscribe(e){return this.listeners.push(e),()=>{const t=this.listeners.indexOf(e);-1!==t&&this.listeners.splice(t,1)}}updateState(e){this.state=Object.assign(Object.assign({},this.state),e),this.listeners.forEach(e=>e(this.getState()))}verify(e){return o(this,void 0,void 0,function*(){this.updateState({isLoading:!0,error:null,result:null,currentStep:"requesting"});try{const t=yield this.client.preparePhoneRequest(e);this.updateState({currentStep:"authenticating"});const n=yield this.client.invokeSecurePrompt(t);this.updateState({currentStep:"processing"});const o=n,r="GetPhoneNumber"===e.use_case?yield this.client.getPhoneNumber(o,t.session):yield this.client.verifyPhoneNumber(o,t.session);return this.updateState({result:r,currentStep:"complete",isLoading:!1}),r}catch(t){const n=t,o=Object.assign(Object.assign({},n),{context:n.context||{useCase:e.use_case,timestamp:(new Date).toISOString(),userAgent:"undefined"!=typeof navigator?navigator.userAgent:void 0,url:"undefined"!=typeof window?window.location.href:void 0}});throw this.updateState({error:o,currentStep:"idle",isLoading:!1}),o}})}getPhoneNumber(e){return o(this,void 0,void 0,function*(){return this.verify(Object.assign({use_case:"GetPhoneNumber"},e))})}verifyPhoneNumber(e,t){return o(this,void 0,void 0,function*(){return this.verify(Object.assign({use_case:"VerifyPhoneNumber",phone_number:e},t))})}reset(){this.updateState({isLoading:!1,error:null,result:null,currentStep:"idle"})}isSupported(){return this.state.isSupported}}},802:function(e,t){var n=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))(function(r,i){function s(e){try{l(o.next(e))}catch(e){i(e)}}function a(e){try{l(o.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}l((o=o.apply(e,t||[])).next())})};function o(e,t){const n=(null==t?void 0:t.container)||document.createElement("div");let o;if(n.className="phone-auth-qr-container","string"==typeof e)o=e;else{if(!e||"object"!=typeof e)throw new Error("Invalid qrCodeData: must be string or QRCodeData object");if(e.iosQRCode)o=e.iosQRCode;else{if(!e.androidQRCode)throw new Error("Invalid QRCodeData: missing QR code images");o=e.androidQRCode}}const r=document.createElement("img");if(r.src=o,r.alt="QR Code for authentication",r.style.width=`${(null==t?void 0:t.size)||256}px`,r.style.height=`${(null==t?void 0:t.size)||256}px`,r.style.display="block",r.style.margin="0 auto",null==t?void 0:t.title){const e=document.createElement("h3");e.textContent=t.title,e.style.textAlign="center",e.style.marginBottom="1rem",n.appendChild(e)}if(n.appendChild(r),null==t?void 0:t.description){const e=document.createElement("p");e.textContent=t.description,e.style.textAlign="center",e.style.marginTop="1rem",e.style.color="#666",n.appendChild(e)}return n}Object.defineProperty(t,"__esModule",{value:!0}),t.DesktopHandler=void 0,t.createQRCodeDisplay=o,t.showQRCodeModal=function(e,t){const n=document.createElement("div");n.style.cssText="\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n background-color: rgba(0, 0, 0, 0.5);\n display: flex;\n align-items: center;\n justify-content: center;\n z-index: 9999;\n ";const r=document.createElement("div");r.style.cssText="\n background: white;\n padding: 2rem;\n border-radius: 8px;\n max-width: 400px;\n position: relative;\n ";const i=document.createElement("button");i.textContent="×",i.style.cssText="\n position: absolute;\n top: 10px;\n right: 10px;\n background: none;\n border: none;\n font-size: 24px;\n cursor: pointer;\n color: #999;\n ",i.onclick=()=>{document.body.removeChild(n),(null==t?void 0:t.onClose)&&t.onClose()},r.appendChild(i);const s=o(e,{title:(null==t?void 0:t.title)||"Scan QR Code to Authenticate",description:(null==t?void 0:t.description)||"Use your mobile device to scan this QR code"});r.appendChild(s);const a=document.createElement("div");a.id="desktop-auth-status",a.style.cssText="\n text-align: center;\n margin-top: 1rem;\n color: #666;\n font-size: 14px;\n ",r.appendChild(a),n.appendChild(r),document.body.appendChild(n),n.onclick=e=>{e.target===n&&(document.body.removeChild(n),(null==t?void 0:t.onClose)&&t.onClose())}},t.DesktopHandler=class{constructor(){this.pollingAttempts=0,this.isCancelled=!1,this.isPollingInProgress=!1}mapBackendStatus(e,t){switch(e){case 200:return"completed"===t?"authenticated":"pending";case 410:return"expired";default:return"error"}}invoke(e,t){return n(this,void 0,void 0,function*(){const n=e.data;let o,r,i,s,a;if(n&&n.data&&"object"==typeof n.data){const e=n.data;o=e.ios_qr_image&&e.android_qr_image?{iosQRCode:e.ios_qr_image,androidQRCode:e.android_qr_image,iosUrl:e.ios_url,androidUrl:e.android_url}:e.ios_qr_image||e.android_qr_image?e.ios_qr_image||e.android_qr_image:e.qr_code_image||e.qr_code,r=e.session_id,i=e.status_url,s=e.polling_interval,a=e.expires_in}if(!o&&n&&(o=n.qr_code_image||n.qr_code,r=r||n.session_id,i=i||n.status_url||n.polling_endpoint,s=s||n.polling_interval,a=a||n.expires_in),!o)throw new Error("Invalid desktop authentication data: missing QR code");if(!r)throw new Error("Invalid desktop authentication data: missing session ID");(null==t?void 0:t.onQRCodeReady)&&t.onQRCodeReady(o),console.log("[Desktop QR] Polling endpoint selection:"),console.log(" - options?.pollingEndpoint:",null==t?void 0:t.pollingEndpoint),console.log(" - backend pollingEndpoint:",i);let l=null==t?void 0:t.pollingEndpoint,c="options";l||(l=i,c="backend"),l||(console.log("[Desktop QR] No polling endpoint provided, will use hardcoded fallback"),c="fallback"),console.log("[Desktop QR] Selected endpoint:",l,"from source:",c);const u=(null==t?void 0:t.pollingInterval)||s||2e3,d=(null==t?void 0:t.maxPollingAttempts)||30;return console.log(`[Desktop QR] Starting polling - endpoint source: ${c}, interval: ${u}ms, max attempts: ${d}`),this.startPolling(l||"",r,u,d,a||300,t,c)})}startPolling(e,t,o,r,i,s){return n(this,arguments,void 0,function*(e,t,o,r,i,s,a="unknown"){const l=Date.now()+1e3*i;return new Promise((i,c)=>{this.pollingReject=c;const u=()=>n(this,void 0,void 0,function*(){if(!this.isPollingInProgress)try{if(this.isPollingInProgress=!0,this.isCancelled)return this.stopPolling(),(null==s?void 0:s.onCancel)&&s.onCancel(),(null==s?void 0:s.onStatusUpdate)&&s.onStatusUpdate({status:"cancelled",message:"Authentication cancelled"}),void c({code:"USER_DENIED",message:"Authentication cancelled by user"});if(Date.now()>l)return this.stopPolling(),(null==s?void 0:s.onExpired)&&s.onExpired(),(null==s?void 0:s.onStatusUpdate)&&s.onStatusUpdate({status:"expired",message:"QR code has expired"}),void i({authenticated:!1,error:"Authentication expired"});if(this.pollingAttempts>=r)return this.stopPolling(),(null==s?void 0:s.onTimeout)&&s.onTimeout(),(null==s?void 0:s.onStatusUpdate)&&s.onStatusUpdate({status:"error",message:"Polling timeout reached"}),void i({authenticated:!1,error:"Polling timeout"});let n;if(e&&(e.startsWith("http://")||e.startsWith("https://"))){const o=new URL(e);n=`${o.protocol}//${o.host}/public/public/status/${t}`}else n=e&&""!==e?`${e}/${t}`:`/api/phone-auth/status/${t}`;console.log(`[Desktop QR] Polling status (attempt ${this.pollingAttempts}/${r})`),console.log(`[Desktop QR] Using ${a} endpoint: ${n}`);const o=yield fetch(n,{method:"GET",headers:{Accept:"application/json"}});if(console.log(`[Desktop QR] Status response: ${o.status} ${o.statusText}`),200===o.status){const e=yield o.json();if("completed"===e.status){this.stopPolling();const n=document.querySelector('[style*="position: fixed"]');n&&n.querySelector("#desktop-auth-status")&&setTimeout(()=>{n.remove()},500),(null==s?void 0:s.onStatusUpdate)&&s.onStatusUpdate({status:"authenticated",message:"Authentication successful",data:e}),this.pollingReject=void 0,i({authenticated:!0,credential:e.credential||e.session_key||t,session:e.session||{session_key:e.session_key||t,status:e.status,protocol:e.protocol,created_at:e.created_at,last_updated:e.last_updated}})}else"pending"===e.status&&(this.pollingAttempts++,(null==s?void 0:s.onStatusUpdate)&&s.onStatusUpdate({status:"pending",message:`Waiting for authentication (attempt ${this.pollingAttempts}/${r})`}))}else if(410===o.status){this.stopPolling();const e=yield o.json().catch(()=>({message:"Session expired"})),t=document.querySelector('[style*="position: fixed"]');t&&t.querySelector("#desktop-auth-status")&&setTimeout(()=>{t.remove()},500),(null==s?void 0:s.onExpired)&&s.onExpired(),(null==s?void 0:s.onStatusUpdate)&&s.onStatusUpdate({status:"expired",message:e.message||"Session has expired"}),i({authenticated:!1,error:e.message||"Session expired"})}else if(422===o.status){this.stopPolling();const e=yield o.json().catch(()=>({message:"Authentication failed"})),t=document.querySelector('[style*="position: fixed"]');t&&t.querySelector("#desktop-auth-status")&&setTimeout(()=>{t.remove()},500);const n="USER_CANCELLED"===e.code;(null==s?void 0:s.onStatusUpdate)&&s.onStatusUpdate({status:"error",message:e.message||"Authentication failed"}),i({authenticated:!1,error:n?"User cancelled authentication":e.message||"Authentication failed"})}else if(404===o.status)this.stopPolling(),(null==s?void 0:s.onStatusUpdate)&&s.onStatusUpdate({status:"error",message:"Session not found"}),i({authenticated:!1,error:"Session not found"});else if(400===o.status){this.stopPolling();const e=yield o.json().catch(()=>({message:"Invalid session key"}));i({authenticated:!1,error:e.message||"Invalid session key"})}else this.pollingAttempts++}catch(e){this.pollingAttempts++,(null==s?void 0:s.onStatusUpdate)&&s.onStatusUpdate({status:"pending",message:`Network error, retrying... (attempt ${this.pollingAttempts}/${r})`})}finally{this.isPollingInProgress=!1}});u(),this.pollingIntervalId=setInterval(u,o)})})}stopPolling(){this.pollingIntervalId&&(console.log("[Desktop QR] Stopping polling"),clearInterval(this.pollingIntervalId),this.pollingIntervalId=void 0),this.pollingAttempts=0,this.isPollingInProgress=!1}isPolling(){return void 0!==this.pollingIntervalId}formatResponse(e){if(!e.authenticated||!e.credential)throw new Error("Authentication not completed");return{credential:e.credential,session:e.session}}isSupported(){return"undefined"!=typeof window&&"undefined"!=typeof fetch&&"undefined"!=typeof Promise}cleanup(){this.stopPolling(),this.isCancelled=!1,this.onCancel=void 0,this.pollingReject=void 0}cancel(){var e;console.log("[Desktop QR] Cancelling authentication"),this.isCancelled=!0,this.stopPolling(),null===(e=this.onCancel)||void 0===e||e.call(this),this.pollingReject&&(this.pollingReject({code:"USER_DENIED",message:"Authentication cancelled by user"}),this.pollingReject=void 0)}}},895:function(e,t,n){var o,r=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,r)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||(o=function(e){return o=Object.getOwnPropertyNames||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[t.length]=n);return t},o(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n=o(e),s=0;s<n.length;s++)"default"!==n[s]&&r(t,e,n[s]);return i(t,e),t}),a=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))(function(r,i){function s(e){try{l(o.next(e))}catch(e){i(e)}}function a(e){try{l(o.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}l((o=o.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.PhoneAuthClient=void 0;const l=s(n(566)),c=n(931),u=n(192),d=n(495),h=n(928),p=n(802),g=n(544),E=n(244);t.PhoneAuthClient=class{constructor(e={}){var t,o,r,i;this.crossDeviceActive=!1,this.retryCount=0,this.sessionCache=new Map,this.baseTimeout=e.timeout||3e4,this.config={endpoints:{prepare:(null===(t=e.endpoints)||void 0===t?void 0:t.prepare)||"/api/magic-auth/prepare",process:(null===(o=e.endpoints)||void 0===o?void 0:o.process)||"/api/magic-auth/process",polling:null===(r=e.endpoints)||void 0===r?void 0:r.polling},timeout:e.timeout||3e4,pollingInterval:e.pollingInterval||2e3,maxPollingAttempts:e.maxPollingAttempts||30,debug:e.debug||!1,aggregatorId:e.aggregatorId||"default",devtools:e.devtools},this.debug=this.config.debug,this.callbacks={onCrossDeviceDetected:e.onCrossDeviceDetected,onRetryAttempt:e.onRetryAttempt},this.logger=h.LoggerFactory.create({level:e.logLevel,prefix:"[PhoneAuth]",remote:e.remoteLogging,custom:e.logger}),(null===(i=e.devtools)||void 0===i?void 0:i.showMobileConsole)&&"undefined"!=typeof window&&Promise.resolve().then(()=>s(n(545))).then(({MobileDebugConsole:e})=>{e.init(),console.log("[PhoneAuth] Mobile debug console enabled")}).catch(e=>{console.error("[PhoneAuth] Failed to load mobile debug console:",e)}),this.setupCacheCleanup()}getUserFriendlyMessage(e){return"string"==typeof e?(0,u.getUserMessage)({code:e}):(0,u.getUserMessage)(e)}logError(e,t){const n=(0,u.createErrorBreadcrumb)(e),o=(0,u.serializeError)(e);!this.debug&&(0,u.isUserError)(e)||console.error("[PhoneAuth] Error:",Object.assign(Object.assign({},o),{breadcrumb:n,context:t})),e.traceId&&console.debug("[PhoneAuth] Trace Context:",{traceId:e.traceId,spanId:e.spanId,requestId:e.requestId})}isSupported(){return"undefined"!=typeof window&&"DigitalCredential"in window}getBrowserSupportInfo(){if("undefined"==typeof window)return{supported:!1,browser:"unknown",message:"Not running in a browser environment"};const e=navigator.userAgent,t=/Chrome/.test(e)&&/Google Inc/.test(navigator.vendor),n=/Edg\//.test(e);return this.isSupported()?{supported:!0,browser:t?c.BrowserName.CHROME:n?c.BrowserName.EDGE:c.BrowserName.OTHER}:t||n?{supported:!1,browser:t?c.BrowserName.CHROME:c.BrowserName.EDGE,message:"Digital Credentials API is not enabled. Please enable the #web-identity-digital-credentials flag.",helpUrl:t?"chrome://flags/#web-identity-digital-credentials":"edge://flags/#web-identity-digital-credentials"}:{supported:!1,browser:"other",message:"Your browser doesn't support the Digital Credentials API. Please use Chrome or Edge with the #web-identity-digital-credentials flag enabled."}}verify(e){return a(this,void 0,void 0,function*(){return this.retryCount=0,this.lastRequest=e,this.verifyWithRetry(e,2)})}verifyWithRetry(e,t){return a(this,void 0,void 0,function*(){var n,o;try{const t=yield this.preparePhoneRequest(e),n=yield this.invokeSecurePrompt(t);if(n&&"object"==typeof n&&"strategy"in n)throw this.createError(u.PhoneAuthErrorCode.INVALID_RESPONSE,"Headless mode is not supported in authenticatePhoneNumber. Use preparePhoneRequest and invokeSecurePrompt directly for headless mode.");const o=n;if(!e.use_case)throw this.createError(u.PhoneAuthErrorCode.MISSING_PARAMETERS,"use_case is required",{field:"use_case"});const r=e.use_case===l.USE_CASE.GET_PHONE_NUMBER?yield this.getPhoneNumber(o,t.session):yield this.verifyPhoneNumber(o,t.session);return this.cacheSession(e,r),r}catch(r){const i=(0,u.isPhoneAuthError)(r)?r:(0,u.parseBackendError)(r);if(this.shouldRetry(i)&&this.retryCount<t){this.retryCount++,null===(o=(n=this.callbacks).onRetryAttempt)||void 0===o||o.call(n,this.retryCount,t),this.debug&&console.log(`[PhoneAuth] Retrying verification (attempt ${this.retryCount+1}/${t+1})`),yield this.delay(Math.min(1e3*Math.pow(2,this.retryCount-1),5e3));const r=this.getCachedSession(e);return r?(this.debug&&console.log("[PhoneAuth] Using cached session result"),r):this.verifyWithRetry(e,t)}if(i.context={step:"complete",useCase:e.use_case,timestamp:(new Date).toISOString(),userAgent:navigator.userAgent,attemptNumber:this.retryCount+1,maxAttempts:t+1},this.logError(i,{options:e}),(0,u.isPhoneAuthError)(r)){if(r.context)throw r;throw{code:i.code,message:r.message,details:r.details,status:r.status,requestId:r.requestId,timestamp:r.timestamp,retryAfter:r.retryAfter,browserError:r.browserError,context:{useCase:e.use_case,timestamp:(new Date).toISOString(),userAgent:"undefined"!=typeof navigator?navigator.userAgent:void 0,url:"undefined"!=typeof window?window.location.href:void 0,attemptNumber:this.retryCount+1,maxAttempts:t+1}}}throw this.createError(u.PhoneAuthErrorCode.VERIFICATION_FAILED,"Verification failed",r)}})}getPhoneNumberComplete(e){return a(this,void 0,void 0,function*(){return this.verify(Object.assign({use_case:l.USE_CASE.GET_PHONE_NUMBER},e))})}verifyPhoneNumberComplete(e,t){return a(this,void 0,void 0,function*(){return this.verify(Object.assign({use_case:l.USE_CASE.VERIFY_PHONE_NUMBER,phone_number:e},t))})}preparePhoneRequest(e){return a(this,void 0,void 0,function*(){var t,n,o;if(e.phone_number){const t=(0,d.validatePhoneNumber)(e.phone_number);if(!t.valid)throw this.createError(u.PhoneAuthErrorCode.INVALID_PHONE_NUMBER,t.error,{field:"phone_number"})}if(e.plmn){const t=(0,d.validatePlmn)(e.plmn);if(!t.valid)throw this.createError(u.PhoneAuthErrorCode.BAD_REQUEST,t.error,{field:"plmn"})}if(e.consent_data){const t=(0,d.validateConsentData)(e.consent_data);if(!t.valid)throw this.createError(u.PhoneAuthErrorCode.BAD_REQUEST,t.error,{field:"consent_data"})}if(!e.use_case&&(!(null===(t=e.options)||void 0===t?void 0:t.parent_session_id)||e.phone_number||e.plmn))throw this.createError(u.PhoneAuthErrorCode.MISSING_PARAMETERS,"use_case is required",{field:"use_case"});if(!e.phone_number&&!e.plmn&&!(null===(n=e.options)||void 0===n?void 0:n.parent_session_id))throw e.use_case===l.USE_CASE.GET_PHONE_NUMBER?this.createError(u.PhoneAuthErrorCode.MISSING_PARAMETERS,"PLMN (MCC/MNC) is required for GetPhoneNumber. Please provide carrier network information.",{field:"plmn",useCase:"GetPhoneNumber"}):e.use_case===l.USE_CASE.VERIFY_PHONE_NUMBER?this.createError(u.PhoneAuthErrorCode.MISSING_PARAMETERS,"Phone number is required for VerifyPhoneNumber",{field:"phoneNumber",useCase:"VerifyPhoneNumber"}):this.createError(u.PhoneAuthErrorCode.MISSING_PARAMETERS,"Either phone number or PLMN (MCC/MNC) must be provided",{field:"phoneNumber,plmn"});!(null===(o=e.options)||void 0===o?void 0:o.parent_session_id)||e.phone_number||e.plmn||this.debug&&console.log("[PhoneAuth] Using parent_session_id: %s, use_case: %s",e.options.parent_session_id,e.use_case||"not provided");const r=`web-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,i=btoa(String.fromCharCode(...crypto.getRandomValues(new Uint8Array(32)))).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"");if(!(0,d.validateNonce)(i).valid)throw this.createError(u.PhoneAuthErrorCode.INTERNAL_SERVER_ERROR,"Failed to generate valid nonce",{field:"nonce"});const s={use_case:e.use_case,phone_number:e.phone_number,plmn:e.plmn?{mcc:e.plmn.mcc,mnc:e.plmn.mnc}:void 0,nonce:i,id:r,consent_data:e.consent_data,client_info:{user_agent:navigator.userAgent,platform:navigator.platform},options:e.options};this.log("Preparing phone verification request",s);try{const t=yield this.fetchWithTimeout(this.config.endpoints.prepare,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!t.ok){let n=null;try{n=yield t.json(),n=Object.assign(Object.assign({},n),{status:t.status})}catch(e){n={status:t.status,statusText:t.statusText}}const o=(0,u.parseBackendError)(n);throw o.context={step:"prepare",useCase:e.use_case,timestamp:(new Date).toISOString(),userAgent:"undefined"!=typeof navigator?navigator.userAgent:void 0,url:"undefined"!=typeof window?window.location.href:void 0},o.details=Object.assign(Object.assign({},o.details),{endpoint:"prepare",status:t.status}),o}const n=yield t.json();if(this.log("Phone verification request prepared",n),!n.authentication_strategy||!n.data||!n.session)throw this.createError(u.PhoneAuthErrorCode.INVALID_RESPONSE,"Invalid response format from backend");return n}catch(t){if(this.isAuthError(t))throw t;throw this.createError(u.PhoneAuthErrorCode.NETWORK_ERROR,"Failed to prepare verification request",{originalError:t,context:{step:"prepare",useCase:e.use_case,timestamp:(new Date).toISOString(),userAgent:"undefined"!=typeof navigator?navigator.userAgent:void 0,url:"undefined"!=typeof window?window.location.href:void 0}})}})}invokeSecurePrompt(e,t){return a(this,void 0,void 0,function*(){var n,o,r,i,s,d,h,f,m,R,b,_,v,A,y;let O;try{O="undefined"!=typeof structuredClone?structuredClone(e):JSON.parse(JSON.stringify(e))}catch(t){this.debug&&console.log("[PhoneAuth] structuredClone failed, using JSON fallback:",t),O=JSON.parse(JSON.stringify(e))}console.log("[PhoneAuth] === invokeSecurePrompt called ==="),console.log("[PhoneAuth] Session cache size:",this.sessionCache.size),console.log("[PhoneAuth] Retry count:",this.retryCount),console.log("[PhoneAuth] PrepareResponse received:",JSON.stringify(O,null,2));const S=t&&("preventDefaultUI"in t||"executionMode"in t||"theme"in t||"modalOptions"in t||"callbacks"in t)?t:void 0,I=(O.authentication_strategy,null!==(n=null==S?void 0:S.preventDefaultUI)&&void 0!==n&&n),C=null!==(o=null==S?void 0:S.executionMode)&&void 0!==o?o:"standard",T=t&&!S?t:void 0;if(O.authentication_strategy===l.AUTHENTICATION_STRATEGY.TS43){if(!this.isSupported())throw this.createError(u.PhoneAuthErrorCode.BROWSER_NOT_SUPPORTED,"Your browser does not support the Digital Credentials API required for TS43 authentication");const e=O.data,t={digital:{requests:[{protocol:e.protocol,data:e.data}]}};this.log("Invoking TS43 secure authentication prompt",t);const n=()=>a(this,void 0,void 0,function*(){var e,n;try{const e=t,n=yield navigator.credentials.get(e);if(!n||!("data"in n)||!n.data){const e=this.getBrowserSupportInfo();if(e.browser===c.BrowserName.CHROME||e.browser===c.BrowserName.EDGE)throw new Error(`Digital Credentials API returned no response. This usually means the browser feature flag is not enabled. Please ensure the ${e.helpUrl||"#web-identity-digital-credentials flag"} is set to "Enabled" (not "Default" or "Disabled") and restart your browser.`);throw new Error("Digital Credentials API returned no response. Your browser may not fully support this feature.")}const o=n.data;return this.log("Secure credential response received",o),o.vp_token}catch(t){const o=t,r={name:o.name||"UnknownError",message:o.message||"Unknown error occurred",stack:o.stack,code:o.code},i={step:"prompt",timestamp:(new Date).toISOString(),userAgent:navigator.userAgent,url:window.location.href,authentication_strategy:O.authentication_strategy,hasSession:!!O.session};if(o.name===c.BrowserError.NOT_ALLOWED)throw this.createError(u.PhoneAuthErrorCode.USER_DENIED,"User denied the credential request or the request timed out",{originalError:t,browserError:r,context:i});if(o.name===c.BrowserError.NETWORK&&o.code===c.BrowserErrorCode.USER_CANCELLED_DC_API)throw this.createError(u.PhoneAuthErrorCode.USER_DENIED,"Authentication cancelled by user",{originalError:t,browserError:r,context:i});if(o.name===c.BrowserError.NETWORK)throw this.createError(u.PhoneAuthErrorCode.NETWORK_ERROR,"Network error occurred while retrieving credentials",{originalError:t,browserError:r,context:i});if(o.name===c.BrowserError.NOT_SUPPORTED)throw this.createError(u.PhoneAuthErrorCode.BROWSER_NOT_SUPPORTED,"Your browser does not support the Digital Credentials API",{originalError:t,browserError:r,context:i});if(o.name===c.BrowserError.SECURITY)throw this.createError(u.PhoneAuthErrorCode.FORBIDDEN,"Security error: This feature requires a secure context (HTTPS)",{originalError:t,browserError:r,context:i});if(o.name===c.BrowserError.ABORT||(null===(e=r.message)||void 0===e?void 0:e.includes("The operation was aborted"))||(null===(n=r.message)||void 0===n?void 0:n.includes("User cancelled")))throw this.createError(u.PhoneAuthErrorCode.USER_DENIED,"Authentication cancelled",{originalError:t,browserError:r,context:i});throw this.createError(u.PhoneAuthErrorCode.INTERNAL_SERVER_ERROR,`Digital Credentials API error: ${o.message||"Unknown error"}`,{originalError:t,browserError:r,context:i})}}),o=()=>a(this,void 0,void 0,function*(){var e,t;try{const t=yield n();return null===(e=null==S?void 0:S.onTriggerAttempt)||void 0===e||e.call(S,{strategy:l.AUTHENTICATION_STRATEGY.TS43,success:!0}),t}catch(e){throw null===(t=null==S?void 0:S.onTriggerAttempt)||void 0===t||t.call(S,{strategy:l.AUTHENTICATION_STRATEGY.TS43,success:!1,error:e}),e}}),r={promise:null};try{const e=yield o();r.promise=Promise.resolve({credential:"string"==typeof e?e:Object.values(e)[0],session:O.session,authenticated:!0})}catch(e){r.promise=Promise.reject(e)}if("extended"===C){const e={strategy:"ts43",session:O.session,credential:r.promise,trigger:()=>a(this,void 0,void 0,function*(){const e=yield o();r.promise=Promise.resolve({credential:"string"==typeof e?e:Object.values(e)[0],session:O.session,authenticated:!0})}),cancel:()=>{r.promise=Promise.reject(this.createError(u.PhoneAuthErrorCode.USER_DENIED,"Authentication cancelled"))}};return Object.defineProperty(e,"credential",{get:()=>r.promise,enumerable:!0,configurable:!0}),e}{const e=yield r.promise;return{[O.session.session_key]:e.credential}}}if(O.authentication_strategy!==l.AUTHENTICATION_STRATEGY.DESKTOP){if(O.authentication_strategy===l.AUTHENTICATION_STRATEGY.LINK){const e=O.data,t=new g.LinkHandler,n=()=>{var t,n;try{window.open(e.url,"_blank"),null===(t=null==S?void 0:S.onTriggerAttempt)||void 0===t||t.call(S,{strategy:l.AUTHENTICATION_STRATEGY.LINK,url:e.url,success:!0})}catch(t){null===(n=null==S?void 0:S.onTriggerAttempt)||void 0===n||n.call(S,{strategy:l.AUTHENTICATION_STRATEGY.LINK,url:e.url,success:!1,error:t})}};!1!==(null==S?void 0:S.autoTrigger)&&n(),console.log("[PhoneAuth Client] Link polling config:",{fromInvokeOptions:null==S?void 0:S.pollingEndpoint,fromClientConfig:null===(v=this.config.endpoints)||void 0===v?void 0:v.polling,finalPollingEndpoint:(null==S?void 0:S.pollingEndpoint)||(null===(A=this.config.endpoints)||void 0===A?void 0:A.polling)});const o={pollingEndpoint:(null==S?void 0:S.pollingEndpoint)||(null===(y=this.config.endpoints)||void 0===y?void 0:y.polling),pollingInterval:(null==S?void 0:S.pollingInterval)||this.config.pollingInterval||2e3,maxPollingAttempts:(null==S?void 0:S.maxPollingAttempts)||this.config.maxPollingAttempts||30,onLinkOpened:void 0,onStatusUpdate:void 0};if(console.log("[PhoneAuth Client] Final Link polling options:",o),"extended"===C){let r=!1,i=null;i=t.invoke(O,o),r=!0;const s=i.then(e=>{if(e.authenticated&&e.credential)return{credential:e.credential,session:O.session,authenticated:!0};throw this.createError(u.PhoneAuthErrorCode.USER_DENIED,e.error||"Link authentication failed")}),l=()=>a(this,void 0,void 0,function*(){if(!r){r=!0,i||(i=t.invoke(O,o));const e=yield i;if(e.authenticated&&e.credential)return{credential:e.credential,session:O.session,authenticated:!0};throw this.createError(u.PhoneAuthErrorCode.USER_DENIED,e.error||"Link authentication failed")}const e=yield i;if(e.authenticated&&e.credential)return{credential:e.credential,session:O.session,authenticated:!0};throw this.createError(u.PhoneAuthErrorCode.USER_DENIED,e.error||"Link authentication failed")}),c={strategy:"link",session:O.session,credential:s,data:{app_url:e.url},trigger:n,start_polling:l,stop_polling:()=>t.cleanup(),cancel:()=>{t.cancel(),t.cleanup()},is_polling:!1};return Object.defineProperty(c,"is_polling",{get:()=>t.isPolling(),enumerable:!0,configurable:!0}),c}{const e=t.invoke(O,o).then(e=>{if(e.authenticated&&e.credential)return{credential:e.credential,session:O.session,authenticated:!0};throw this.createError(u.PhoneAuthErrorCode.USER_DENIED,e.error||"Link authentication failed")}),n=yield e,r=this.config.aggregatorId||"default";return{[r]:n.credential}}}throw this.createError(u.PhoneAuthErrorCode.UNSUPPORTED_STRATEGY,`Unknown authentication strategy: ${O.authentication_strategy}`)}{const e=O.data,t=new p.DesktopHandler,n={iosQRCode:(null===(r=e.data)||void 0===r?void 0:r.ios_qr_image)||e.ios_qr_image||(null===(i=e.data)||void 0===i?void 0:i.qr_code_image)||e.qr_code_image||e.qr_code||"",androidQRCode:(null===(s=e.data)||void 0===s?void 0:s.android_qr_image)||e.android_qr_image,iosUrl:(null===(d=e.data)||void 0===d?void 0:d.ios_url)||e.ios_url,androidUrl:(null===(h=e.data)||void 0===h?void 0:h.android_url)||e.android_url},o={ios_qr_image:(null===(f=e.data)||void 0===f?void 0:f.ios_qr_image)||e.ios_qr_image,android_qr_image:(null===(m=e.data)||void 0===m?void 0:m.android_qr_image)||e.android_qr_image,qr_code:(null===(R=e.data)||void 0===R?void 0:R.qr_code_image)||e.qr_code_image||e.qr_code,challenge:null===(b=e.data)||void 0===b?void 0:b.challenge},l=(null==S?void 0:S.pollingEndpoint)||(null==T?void 0:T.pollingEndpoint)||(null===(_=this.config.endpoints)||void 0===_?void 0:_.polling),c=Object.assign(Object.assign({},T),{pollingEndpoint:l,pollingInterval:(null==S?void 0:S.pollingInterval)||(null==T?void 0:T.pollingInterval)||this.config.pollingInterval||2e3,maxPollingAttempts:(null==S?void 0:S.maxPollingAttempts)||(null==T?void 0:T.maxPollingAttempts)||this.config.maxPollingAttempts||30,onQRCodeReady:void 0,onStatusUpdate:void 0}),g=!I;let v,A;console.log("[Desktop] Modal decision:",{preventDefaultUI:I,showModal:g,executionMode:C,hasInvokeOptions:!!S,hasDesktopOptions:!!T}),g?(console.log("[Desktop] Creating modal with QR data:",n),v=new E.AuthModal(null==S?void 0:S.modalOptions,null==S?void 0:S.callbacks),v.setCloseCallback(()=>{this.log("Desktop QR modal closed by user, cancelling polling"),t.cancel()}),c.onQRCodeReady=e=>{console.log("[Desktop] onQRCodeReady callback triggered:",e),v.showQRCode(e,"Scan with your mobile device")},c.onStatusUpdate=e=>{"pending"===e.status?v.updateStatus("Waiting for authentication..."):"authenticated"===e.status?(v.updateStatus("Authentication successful!"),setTimeout(()=>v.close(),1500)):"expired"===e.status?v.updateStatus("QR code expired",!0):"error"===e.status&&v.updateStatus("Authentication failed",!0)},A=v):console.log("[Desktop] Modal not shown - preventDefaultUI is true");const y=()=>t.invoke(O,c).then(e=>{if(e.authenticated&&e.credential)return{credential:e.credential,session:O.session,authenticated:!0};throw this.createError(u.PhoneAuthErrorCode.USER_DENIED,e.error||"Desktop authentication failed")});if("extended"===C){let e=null,n=null,r=!1;const i=new Promise((t,o)=>{e=t,n=o,g&&(r=!0,y().then(t).catch(o))}),s=()=>a(this,void 0,void 0,function*(){if(r)throw this.createError(u.PhoneAuthErrorCode.INVALID_SESSION_STATE,"Polling has already been started");r=!0;try{const t=yield y();return e&&e(t),t}catch(e){throw n&&n(e),e}}),l=()=>{t.cleanup(),v&&v.close()},c=()=>{t.cancel(),t.cleanup(),v&&v.close(),!r&&n&&n(this.createError(u.PhoneAuthErrorCode.USER_DENIED,"Desktop authentication cancelled by user"))},d={strategy:"desktop",session:O.session,credential:i,qr_code_data:o,modal_ref:A,start_polling:s,stop_polling:l,cancel:c,is_polling:!1};return Object.defineProperty(d,"is_polling",{get:()=>t.isPolling(),enumerable:!0,configurable:!0}),d}try{const t=yield y();let n="default";return e&&"object"==typeof e&&(e.data&&"object"==typeof e.data&&(n=e.data.session_id||n),n&&"default"!==n||(n=e.session_id||n)),{[n]:t.credential}}finally{t.cleanup(),v&&v.close()}}})}getPhoneNumber(e,t){return a(this,void 0,void 0,function*(){const n=this.extractCredentialString(e),o={session:t,credential:n,use_case:l.USE_CASE.GET_PHONE_NUMBER};this.config.debug?this.log("Getting phone number from credential",{session:t,credential:n?n.substring(0,50)+"...":"undefined",endpoint:this.config.endpoints.process||"/api/phone-auth/process"}):this.log("Getting phone number from credential");try{const e=yield this.fetchWithTimeout(this.config.endpoints.process||"/api/phone-auth/process",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)});if(!e.ok){const t=yield this.extractErrorDetails(e),n=(0,u.parseBackendError)(t);throw n.context={step:"process",timestamp:(new Date).toISOString(),userAgent:"undefined"!=typeof navigator?navigator.userAgent:void 0,url:"undefined"!=typeof window?window.location.href:void 0},n}const t=yield e.json();if(this.log("Phone number retrieved",{phone_number:t.phone_number}),!t.phone_number)throw this.createError(u.PhoneAuthErrorCode.VERIFICATION_FAILED,"No phone number returned from server");return t}catch(e){if(this.isAuthError(e))throw e;throw this.createError(u.PhoneAuthErrorCode.NETWORK_ERROR,"Failed to get phone number",{originalError:e,context:{step:"process",timestamp:(new Date).toISOString()}})}})}verifyPhoneNumber(e,t){return a(this,void 0,void 0,function*(){const n=this.extractCredentialString(e),o={session:t,credential:n,use_case:l.USE_CASE.VERIFY_PHONE_NUMBER};this.config.debug?this.log("Verifying phone number with credential",{session:t,credential:n?n.substring(0,50)+"...":"undefined",endpoint:this.config.endpoints.process||"/api/phone-auth/process"}):this.log("Verifying phone number");try{const e=yield this.fetchWithTimeout(this.config.endpoints.process||"/api/phone-auth/process",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)});if(!e.ok){const t=yield this.extractErrorDetails(e),n=(0,u.parseBackendError)(t);throw n.context={step:"process",timestamp:(new Date).toISOString(),userAgent:"undefined"!=typeof navigator?navigator.userAgent:void 0,url:"undefined"!=typeof window?window.location.href:void 0},n}const t=yield e.json();if(this.log("Phone number verification result",{phone_number:t.phone_number,verified:t.verified}),!t.phone_number)throw this.createError(u.PhoneAuthErrorCode.VERIFICATION_FAILED,"No phone number returned from server");return t}catch(e){if(this.isAuthError(e))throw e;throw this.createError(u.PhoneAuthErrorCode.NETWORK_ERROR,"Failed to verify phone number",{originalError:e,context:{step:"process",timestamp:(new Date).toISOString()}})}})}extractCredentialString(e){if("string"==typeof e)return e;let t=e[this.config.aggregatorId||"glide"];if(!t&&e.glide&&(t=e.glide),!t&&e.default&&(t=e.default),!t){const n=Object.keys(e);n.length>0&&(t=e[n[0]])}return Array.isArray(t)?t[0]:t}extractErrorDetails(e){return a(this,void 0,void 0,function*(){try{const t=yield e.json();return Object.assign(Object.assign({},t),{status:e.status})}catch(t){return{status:e.status,statusText:e.statusText}}})}fetchWithTimeout(e,t){return a(this,void 0,void 0,function*(){const n=new AbortController,o=setTimeout(()=>n.abort(),this.config.timeout);try{return yield fetch(e,Object.assign(Object.assign({},t),{signal:n.signal}))}finally{clearTimeout(o)}})}createError(e,t,n){const o={code:e,message:t,details:(null==n?void 0:n.originalError)?Object.assign(Object.assign({},n),{originalError:void 0}):n};return(null==n?void 0:n.browserError)&&(o.browserError=n.browserError),(null==n?void 0:n.context)&&(o.context=n.context),(null==n?void 0:n.status)&&(o.status=n.status),(null==n?void 0:n.requestId)&&(o.requestId=n.requestId),(null==n?void 0:n.timestamp)&&(o.timestamp=n.timestamp),(null==n?void 0:n.retryAfter)&&(o.retryAfter=n.retryAfter),o}isAuthError(e){return e&&"string"==typeof e.code&&"string"==typeof e.message}log(...e){this.debug&&console.log("[PhoneAuth]",...e)}shouldRetry(e){var t,n,o;if(e.status&&e.status>=400&&e.status<500)return!1;if(["USER_DENIED","BROWSER_NOT_SUPPORTED","INVALID_PHONE_NUMBER","INVALID_PARAMETERS","MISSING_PARAMETERS","UNPROCESSABLE_ENTITY","USE_CASE_MISMATCH","PHONE_NUMBER_MISMATCH","VERIFICATION_FAILED","INVALID_CREDENTIAL","CARRIER_NOT_ELIGIBLE","SESSION_EXPIRED","INVALID_SESSION"].includes(e.code))return!1;const r=(null===(t=e.details)||void 0===t?void 0:t.errorType)&&["CROSS_DEVICE_TIMEOUT","CROSS_DEVICE_CONNECTION_LOST","CROSS_DEVICE_INCOMPLETE"].includes(e.details.errorType);return["NETWORK_ERROR","REQUEST_TIMEOUT","GATEWAY_TIMEOUT","SERVICE_UNAVAILABLE","BAD_GATEWAY","INTERNAL_SERVER_ERROR"].includes(e.code)||r||"NetworkError"===(null===(n=e.browserError)||void 0===n?void 0:n.name)&&19!==(null===(o=e.browserError)||void 0===o?void 0:o.code)}analyzeCrossDeviceError(e,t){var n;const o=e,r="AbortError"===o.name&&this.crossDeviceActive||(null===(n=o.message)||void 0===n?void 0:n.includes("timeout"))&&this.crossDeviceActive,i="NetworkError"===o.name&&19!==o.code&&this.crossDeviceActive;return r?{code:"REQUEST_TIMEOUT",message:"Cross-device authentication timed out. The QR code may have expired or the phone connection was lost.",details:{suggestion:"Try again and complete the phone authentication within 2 minutes",originalError:o.message,crossDevice:!0,errorType:"CROSS_DEVICE_TIMEOUT"},browserError:e.browserError}:i?{code:"NETWORK_ERROR",message:"Connection lost during cross-device authentication. Please ensure both devices have stable internet.",details:{suggestion:"Check your network connection on both devices and try again",originalError:o.message,crossDevice:!0,errorType:"CROSS_DEVICE_CONNECTION_LOST"},browserError:e.browserError}:e}cacheSession(e,t){const n=this.getCacheKey(e);this.sessionCache.set(n,{timestamp:Date.now(),data:t})}getCachedSession(e){const t=this.getCacheKey(e),n=this.sessionCache.get(t);return n?Date.now()-n.timestamp>3e5?(this.sessionCache.delete(t),null):n.data:null}getCacheKey(e){var t,n;return`${e.use_case}-${e.phone_number||"no-phone"}-${(null===(t=e.plmn)||void 0===t?void 0:t.mcc)||""}-${(null===(n=e.plmn)||void 0===n?void 0:n.mnc)||""}`}setupCacheCleanup(){"undefined"!=typeof window&&setInterval(()=>{const e=Date.now();for(const[t,n]of this.sessionCache.entries())e-n.timestamp>3e5&&this.sessionCache.delete(t)},6e4)}delay(e){return new Promise(t=>setTimeout(t,e))}}},928:function(e,t){var n,o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))(function(r,i){function s(e){try{l(o.next(e))}catch(e){i(e)}}function a(e){try{l(o.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}l((o=o.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.LoggerFactory=t.PerformanceTimer=t.RemoteLogger=t.NoopLogger=t.ConsoleLogger=t.LogLevel=void 0,t.parseLogLevel=s,t.getLogLevelFromEnv=a,t.generateRequestId=function(){return`req_${Date.now()}_${Math.random().toString(36).substring(2,9)}`},function(e){e[e.SILENT=0]="SILENT",e[e.ERROR=1]="ERROR",e[e.WARN=2]="WARN",e[e.INFO=3]="INFO",e[e.DEBUG=4]="DEBUG"}(n||(t.LogLevel=n={}));class r{constructor(e=n.SILENT,t="[Glide]",o=!1){this.level=e,this.prefix=t,this.enableGrouping=o}debug(e,t){this.level>=n.DEBUG&&this.log("debug",e,t)}info(e,t){this.level>=n.INFO&&this.log("info",e,t)}warn(e,t){this.level>=n.WARN&&this.log("warn",e,t)}error(e,t){this.level>=n.ERROR&&this.log("error",e,t)}log(e,t,n){const o=(new Date).toISOString(),r=n?this.sanitizeFields(n):{},i=`${this.prefix} ${o} [${e.toUpperCase()}] ${t}`;this.enableGrouping&&Object.keys(r).length>0?(console.groupCollapsed(i),Object.entries(r).forEach(([e,t])=>{console.log(`${e}:`,t)}),console.groupEnd()):Object.keys(r).length>0?console[e](i,r):console[e](i)}sanitizeFields(e){const t={};for(const[n,o]of Object.entries(e))t[n]=this.sanitizeValue(n,o);return t}sanitizeValue(e,t){const n=["apikey","api_key","apiKey","token","accesstoken","access_token","accessToken","password","passwd","pwd","secret","credential","authorization","auth","cookie","session"],o=e.toLowerCase();for(const e of n)if(o.includes(e.toLowerCase()))return"string"==typeof t&&t.length>4?t.substring(0,4)+"****[REDACTED]":"****[REDACTED]";if("string"==typeof t){if(/^\+?[1-9]\d{6,14}$/.test(t))return t.substring(0,6)+"****";if(/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)){const[,e]=t.split("@");return"****@"+e}if(t.includes("://")&&t.includes("@"))return t.replace(/\/\/([^:]+):([^@]+)@/,"//****:****@");if(t.startsWith("eyJ")&&3===t.split(".").length)return t.substring(0,10)+"****[JWT]";if(/\b\d{13,19}\b/.test(t))return t.substring(0,4)+"****"+t.substring(t.length-4)}return t&&"object"==typeof t&&!Array.isArray(t)?this.sanitizeFields(t):Array.isArray(t)?t.map((t,n)=>this.sanitizeValue(`${e}[${n}]`,t)):t}}t.ConsoleLogger=r,t.NoopLogger=class{debug(e,t){}info(e,t){}warn(e,t){}error(e,t){}};class i{constructor(e,t,o){this.buffer=[],this.flushInterval=5e3,this.maxBufferSize=100,this.endpoint=e,this.apiKey=t,this.localLogger=o||new r(n.ERROR),"undefined"!=typeof window&&(setInterval(()=>this.flush(),this.flushInterval),window.addEventListener("beforeunload",()=>this.flush()))}debug(e,t){this.log("debug",e,t)}info(e,t){this.log("info",e,t)}warn(e,t){this.log("warn",e,t)}error(e,t){this.log("error",e,t)}log(e,t,n){const o={timestamp:(new Date).toISOString(),level:e,message:t,fields:n,userAgent:"undefined"!=typeof navigator?navigator.userAgent:void 0,url:"undefined"!=typeof window?window.location.href:void 0};this.buffer.push(o),this.localLogger[e](t,n),this.buffer.length>=this.maxBufferSize&&this.flush()}flush(){return o(this,void 0,void 0,function*(){if(0===this.buffer.length)return;const e=[...this.buffer];this.buffer=[];try{yield fetch(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.apiKey}`},body:JSON.stringify({logs:e})})}catch(e){this.localLogger.error("Failed to send logs to remote server",{error:e})}})}}function s(e){switch(e.toLowerCase()){case"debug":return n.DEBUG;case"info":return n.INFO;case"warn":case"warning":return n.WARN;case"error":return n.ERROR;default:return n.SILENT}}function a(){if("undefined"!=typeof localStorage){const e=localStorage.getItem("GLIDE_LOG_LEVEL");if(e)return s(e);const t=localStorage.getItem("GLIDE_DEBUG");if("true"===t||"1"===t)return n.DEBUG}if("undefined"!=typeof window&&window.location){const e=new URLSearchParams(window.location.search),t=e.get("glide_log_level");if(t)return s(t);if(e.has("glide_debug"))return n.DEBUG}return n.SILENT}t.RemoteLogger=i,t.PerformanceTimer=class{constructor(e){this.marks=new Map,this.startTime=performance.now(),this.logger=e}mark(e){this.marks.set(e,performance.now())}logElapsed(e,t){const n=performance.now()-this.startTime;this.logger.debug(e,Object.assign(Object.assign({},t),{elapsedMs:n,elapsed:`${n.toFixed(2)}ms`}))}logMarkDuration(e,t,n,o){const r=this.marks.get(e),i=this.marks.get(t);if(r&&i){const s=i-r;this.logger.debug(n,Object.assign(Object.assign({},o),{durationMs:s,duration:`${s.toFixed(2)}ms`,fromMark:e,toMark:t}))}}};class l{static setDefaultLevel(e){this.defaultLevel=e}static setDefaultLogger(e){this.defaultLogger=e}static create(e){var t,n;if(null==e?void 0:e.custom)return e.custom;if(this.defaultLogger)return this.defaultLogger;const o=null!==(n=null!==(t=null==e?void 0:e.level)&&void 0!==t?t:a())&&void 0!==n?n:this.defaultLevel;if(null==e?void 0:e.remote){const t=new r(o,null==e?void 0:e.prefix);return new i(e.remote.endpoint,e.remote.apiKey,t)}return new r(o,null==e?void 0:e.prefix)}}t.LoggerFactory=l,l.defaultLevel=n.SILENT,l.defaultLogger=null},931:function(e,t,n){var o=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,r)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),r=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||o(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),t.AuthStatus=t.BrowserName=t.BrowserErrorCode=t.BrowserError=void 0,r(n(566),t),t.BrowserError={NOT_ALLOWED:"NotAllowedError",NETWORK:"NetworkError",NOT_SUPPORTED:"NotSupportedError",SECURITY:"SecurityError",ABORT:"AbortError",TIMEOUT:"TimeoutError",INVALID_STATE:"InvalidStateError",DATA_CLONE:"DataCloneError",ENCODING:"EncodingError",NOT_READABLE:"NotReadableError",UNKNOWN:"UnknownError",TYPE:"TypeError",RANGE:"RangeError",SYNTAX:"SyntaxError"},t.BrowserErrorCode={USER_CANCELLED_DC_API:19,PERMISSION_DENIED:1,POSITION_UNAVAILABLE:2,TIMEOUT:3,NOT_FOUND:8,ABORT:20,NETWORK:19,SECURITY:18},t.BrowserName={CHROME:"Chrome",EDGE:"Edge",SAFARI:"Safari",FIREFOX:"Firefox",OPERA:"Opera",BRAVE:"Brave",OTHER:"other"},t.AuthStatus={PENDING:"pending",COMPLETED:"completed",CANCELLED:"cancelled",FAILED:"failed",EXPIRED:"expired",NOT_FOUND:"not_found"}},982:function(e,t,n){var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))(function(r,i){function s(e){try{l(o.next(e))}catch(e){i(e)}}function a(e){try{l(o.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}l((o=o.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.VanillaClient=void 0;const r=n(499);t.VanillaClient=class{constructor(e){this.client=new r.SDKClient(e)}authenticate(e,t){return o(this,void 0,void 0,function*(){throw new Error("authenticate method is deprecated. Use client.setToken() directly.")})}setToken(e){this.client.setToken(e)}get(e,t){return o(this,void 0,void 0,function*(){return this.client.get(e,t)})}}}},t={};function n(o){var r=t[o];if(void 0!==r)return r.exports;var i=t[o]={exports:{}};return e[o].call(i.exports,i,i.exports,n),i.exports}n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}();var o={};return(()=>{var e=o;Object.defineProperty(e,"__esModule",{value:!0}),e.PhoneAuthManager=e.ClientManager=e.BrowserName=e.BrowserErrorCode=e.BrowserError=e.AuthenticationStrategy=e.UseCase=e.createErrorBreadcrumb=e.serializeError=e.isRetryableError=e.getRetryDelay=e.isErrorCode=e.getUserMessage=e.isUserError=e.isPhoneAuthError=e.PhoneAuthErrorCode=e.PhoneAuthClient=void 0;var t=n(514);Object.defineProperty(e,"PhoneAuthClient",{enumerable:!0,get:function(){return t.PhoneAuthClient}});var r=n(514);Object.defineProperty(e,"PhoneAuthErrorCode",{enumerable:!0,get:function(){return r.PhoneAuthErrorCode}}),Object.defineProperty(e,"isPhoneAuthError",{enumerable:!0,get:function(){return r.isPhoneAuthError}}),Object.defineProperty(e,"isUserError",{enumerable:!0,get:function(){return r.isUserError}}),Object.defineProperty(e,"getUserMessage",{enumerable:!0,get:function(){return r.getUserMessage}}),Object.defineProperty(e,"isErrorCode",{enumerable:!0,get:function(){return r.isErrorCode}}),Object.defineProperty(e,"getRetryDelay",{enumerable:!0,get:function(){return r.getRetryDelay}}),Object.defineProperty(e,"isRetryableError",{enumerable:!0,get:function(){return r.isRetryableError}}),Object.defineProperty(e,"serializeError",{enumerable:!0,get:function(){return r.serializeError}}),Object.defineProperty(e,"createErrorBreadcrumb",{enumerable:!0,get:function(){return r.createErrorBreadcrumb}});var i=n(931);Object.defineProperty(e,"UseCase",{enumerable:!0,get:function(){return i.USE_CASE}}),Object.defineProperty(e,"AuthenticationStrategy",{enumerable:!0,get:function(){return i.AUTHENTICATION_STRATEGY}}),Object.defineProperty(e,"BrowserError",{enumerable:!0,get:function(){return i.BrowserError}}),Object.defineProperty(e,"BrowserErrorCode",{enumerable:!0,get:function(){return i.BrowserErrorCode}}),Object.defineProperty(e,"BrowserName",{enumerable:!0,get:function(){return i.BrowserName}});var s=n(982);Object.defineProperty(e,"ClientManager",{enumerable:!0,get:function(){return s.VanillaClient}});var a=n(724);Object.defineProperty(e,"PhoneAuthManager",{enumerable:!0,get:function(){return a.PhoneAuthManager}})})(),o})());
2
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.GlideWebClientSDK=t():e.GlideWebClientSDK=t()}(this,()=>(()=>{"use strict";var e={50:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SDK_VERSION=void 0,t.SDK_VERSION="4.4.10"},192:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.PhoneAuthErrorCode=void 0,t.isPhoneAuthError=function(e){return e&&"string"==typeof e.code&&"string"==typeof e.message},t.isUserError=s,t.getUserMessage=a,t.isErrorCode=function(e,t){return e.code===t},t.getRetryDelay=function(e){return e.code===t.PhoneAuthErrorCode.RATE_LIMIT_EXCEEDED&&e.retryAfter?1e3*e.retryAfter:null},t.isRetryableError=function(e){return[t.PhoneAuthErrorCode.NETWORK_ERROR,t.PhoneAuthErrorCode.SERVICE_UNAVAILABLE,t.PhoneAuthErrorCode.DOWNSTREAM_SERVICE_ERROR,t.PhoneAuthErrorCode.RATE_LIMIT_EXCEEDED].includes(e.code)},t.parseBackendError=function(e){var n,o;if(e&&"object"==typeof e&&(e.code||e.error)){const t=e.code||e.error,o={code:t,message:e.message||a({code:t}),status:e.status,requestId:e.requestId||e.request_id,timestamp:e.timestamp,details:e.details,traceId:e.trace_id||e.traceId,spanId:e.span_id||e.spanId,service:e.service};return(null===(n=e.details)||void 0===n?void 0:n.retryAfter)&&(o.retryAfter=e.details.retryAfter),o}if(e&&e.status){const n=function(e){switch(e){case 400:return t.PhoneAuthErrorCode.BAD_REQUEST;case 401:return t.PhoneAuthErrorCode.UNAUTHORIZED;case 403:return t.PhoneAuthErrorCode.FORBIDDEN;case 404:return t.PhoneAuthErrorCode.NOT_FOUND;case 409:return t.PhoneAuthErrorCode.CONFLICT;case 422:return t.PhoneAuthErrorCode.UNPROCESSABLE_ENTITY;case 429:return t.PhoneAuthErrorCode.RATE_LIMIT_EXCEEDED;case 500:default:return t.PhoneAuthErrorCode.INTERNAL_SERVER_ERROR;case 502:return t.PhoneAuthErrorCode.BAD_GATEWAY;case 503:return t.PhoneAuthErrorCode.SERVICE_UNAVAILABLE;case 504:return t.PhoneAuthErrorCode.GATEWAY_TIMEOUT}}(e.status);return{code:n,message:e.message||a({code:n}),status:e.status,requestId:null===(o=e.headers)||void 0===o?void 0:o["x-request-id"]}}return{code:t.PhoneAuthErrorCode.INTERNAL_SERVER_ERROR,message:"An unexpected error occurred",status:500}},t.serializeError=function(e){return{code:e.code,message:e.message,status:e.status,requestId:e.requestId,timestamp:e.timestamp,traceId:e.traceId,spanId:e.spanId,service:e.service,retryAfter:e.retryAfter,browserError:e.browserError,context:e.context,details:l(e.details),sdkVersion:o.SDK_VERSION,errorCapturedAt:(new Date).toISOString()}},t.createErrorBreadcrumb=function(e){var t,n,o;return{category:"phone-auth",message:`Phone Auth Error: ${e.code}`,level:s(e)?"warning":"error",data:{code:e.code,step:null===(t=e.context)||void 0===t?void 0:t.step,useCase:null===(n=e.context)||void 0===n?void 0:n.useCase,requestId:e.requestId,browserErrorType:null===(o=e.browserError)||void 0===o?void 0:o.name}}};const o=n(50);t.PhoneAuthErrorCode={BAD_REQUEST:"BAD_REQUEST",VALIDATION_ERROR:"VALIDATION_ERROR",INVALID_PARAMETERS:"INVALID_PARAMETERS",MISSING_PARAMETERS:"MISSING_PARAMETERS",INVALID_PHONE_NUMBER:"INVALID_PHONE_NUMBER",INVALID_MCC_MNC:"INVALID_MCC_MNC",UNAUTHORIZED:"UNAUTHORIZED",INVALID_CREDENTIALS:"INVALID_CREDENTIALS",EXPIRED_TOKEN:"EXPIRED_TOKEN",TOKEN_ACQUISITION_FAILED:"TOKEN_ACQUISITION_FAILED",INVALID_API_KEY:"INVALID_API_KEY",MISSING_AUTH_HEADER:"MISSING_AUTH_HEADER",FORBIDDEN:"FORBIDDEN",INSUFFICIENT_PERMISSIONS:"INSUFFICIENT_PERMISSIONS",ACCESS_DENIED:"ACCESS_DENIED",NOT_FOUND:"NOT_FOUND",RESOURCE_NOT_FOUND:"RESOURCE_NOT_FOUND",SESSION_NOT_FOUND:"SESSION_NOT_FOUND",CARRIER_NOT_FOUND:"CARRIER_NOT_FOUND",ENDPOINT_NOT_FOUND:"ENDPOINT_NOT_FOUND",CONFLICT:"CONFLICT",RESOURCE_ALREADY_EXISTS:"RESOURCE_ALREADY_EXISTS",DUPLICATE_SESSION:"DUPLICATE_SESSION",CONCURRENT_MODIFICATION:"CONCURRENT_MODIFICATION",UNPROCESSABLE_ENTITY:"UNPROCESSABLE_ENTITY",UNSUPPORTED_VERIFICATION:"UNSUPPORTED_VERIFICATION",INVALID_VERIFICATION:"INVALID_VERIFICATION",VERIFICATION_FAILED:"VERIFICATION_FAILED",OTP_EXPIRED:"OTP_EXPIRED",OTP_INVALID:"OTP_INVALID",RCS_UNAVAILABLE:"RCS_UNAVAILABLE",CARRIER_IDENTIFICATION_FAILED:"CARRIER_IDENTIFICATION_FAILED",CARRIER_NOT_ELIGIBLE:"CARRIER_NOT_ELIGIBLE",UNSUPPORTED_CARRIER:"UNSUPPORTED_CARRIER",UNSUPPORTED_PLATFORM:"UNSUPPORTED_PLATFORM",UNSUPPORTED_STRATEGY:"UNSUPPORTED_STRATEGY",INVALID_SESSION_STATE:"INVALID_SESSION_STATE",PHONE_NUMBER_MISMATCH:"PHONE_NUMBER_MISMATCH",INVALID_CREDENTIAL_FORMAT:"INVALID_CREDENTIAL_FORMAT",RATE_LIMIT_EXCEEDED:"RATE_LIMIT_EXCEEDED",TOO_MANY_REQUESTS:"TOO_MANY_REQUESTS",QUOTA_EXCEEDED:"QUOTA_EXCEEDED",INTERNAL_SERVER_ERROR:"INTERNAL_SERVER_ERROR",CIRCUIT_BREAKER_CONFIGURATION_ERROR:"CIRCUIT_BREAKER_CONFIGURATION_ERROR",DATABASE_ERROR:"DATABASE_ERROR",CACHE_ERROR:"CACHE_ERROR",SERIALIZATION_ERROR:"SERIALIZATION_ERROR",CRYPTO_ERROR:"CRYPTO_ERROR",BAD_GATEWAY:"BAD_GATEWAY",UPSTREAM_ERROR:"UPSTREAM_ERROR",INVALID_RESPONSE:"INVALID_RESPONSE",SERVICE_UNAVAILABLE:"SERVICE_UNAVAILABLE",DOWNSTREAM_SERVICE_ERROR:"DOWNSTREAM_SERVICE_ERROR",PROVIDER_ERROR:"PROVIDER_ERROR",CIRCUIT_BREAKER_OPEN:"CIRCUIT_BREAKER_OPEN",MAINTENANCE_MODE:"MAINTENANCE_MODE",GATEWAY_TIMEOUT:"GATEWAY_TIMEOUT",REQUEST_TIMEOUT:"REQUEST_TIMEOUT",UPSTREAM_TIMEOUT:"UPSTREAM_TIMEOUT",DEADLINE_EXCEEDED:"DEADLINE_EXCEEDED",BROWSER_NOT_SUPPORTED:"BROWSER_NOT_SUPPORTED",USER_DENIED:"USER_DENIED",NETWORK_ERROR:"NETWORK_ERROR"};const r={CARRIER_NOT_ELIGIBLE:"Your carrier is not eligible for this verification method.",CARRIER_IDENTIFICATION_FAILED:"Unable to identify carrier for the provided phone number.",CARRIER_NOT_FOUND:"Carrier information not available.",UNSUPPORTED_CARRIER:"This carrier is not supported.",RATE_LIMIT_EXCEEDED:"Too many attempts. Please wait a moment and try again.",TOO_MANY_REQUESTS:"Too many requests. Please slow down and try again.",QUOTA_EXCEEDED:"Usage limit reached. Please try again later.",SESSION_NOT_FOUND:"Your session has expired. Please start over.",INVALID_SESSION_STATE:"Invalid session state. Please start over.",DUPLICATE_SESSION:"A session already exists. Please complete or cancel it first.",BROWSER_NOT_SUPPORTED:"Digital Credentials API is not available. Please enable the #web-identity-digital-credentials flag in chrome://flags",UNSUPPORTED_PLATFORM:"This platform is not supported for authentication.",UNSUPPORTED_STRATEGY:"This authentication method is not available.",USER_DENIED:"Authentication was cancelled. Please try again when you're ready.",SERVICE_UNAVAILABLE:"The service is temporarily unavailable. Please try again later.",CIRCUIT_BREAKER_OPEN:"Service is experiencing issues. Please try again later.",MAINTENANCE_MODE:"Service is under maintenance. Please try again later.",DOWNSTREAM_SERVICE_ERROR:"A required service is unavailable. Please try again later.",TOKEN_ACQUISITION_FAILED:"Failed to acquire authentication token. Please try again.",EXPIRED_TOKEN:"Your authentication has expired. Please start over.",INVALID_CREDENTIALS:"Invalid credentials provided.",INVALID_PHONE_NUMBER:"Please enter a valid phone number.",PHONE_NUMBER_MISMATCH:"Phone number mismatch. Please verify your number.",INVALID_PARAMETERS:"Invalid parameters provided.",MISSING_PARAMETERS:"Required information is missing.",VALIDATION_ERROR:"Validation failed. Please check your input.",NETWORK_ERROR:"Network connection failed. Please check your connection and try again.",GATEWAY_TIMEOUT:"Request timed out. Please try again.",REQUEST_TIMEOUT:"Request timed out. Please try again.",DEADLINE_EXCEEDED:"Operation took too long. Please try again.",VERIFICATION_FAILED:"Verification failed. Please try again.",INVALID_VERIFICATION:"Invalid verification response.",INVALID_CREDENTIAL_FORMAT:"Invalid credential format.",BAD_REQUEST:"Invalid request. Please try again.",UNAUTHORIZED:"Authentication required.",FORBIDDEN:"Access denied.",NOT_FOUND:"Resource not found.",INTERNAL_SERVER_ERROR:"An error occurred. Please try again later."},i=new Set(["CARRIER_NOT_ELIGIBLE","CARRIER_IDENTIFICATION_FAILED","CARRIER_NOT_FOUND","UNSUPPORTED_CARRIER","RATE_LIMIT_EXCEEDED","TOO_MANY_REQUESTS","QUOTA_EXCEEDED","BROWSER_NOT_SUPPORTED","UNSUPPORTED_PLATFORM","UNSUPPORTED_STRATEGY","USER_DENIED","SESSION_NOT_FOUND","INVALID_SESSION_STATE","EXPIRED_TOKEN","SERVICE_UNAVAILABLE","CIRCUIT_BREAKER_OPEN","MAINTENANCE_MODE","NETWORK_ERROR","GATEWAY_TIMEOUT","REQUEST_TIMEOUT","INVALID_PHONE_NUMBER","PHONE_NUMBER_MISMATCH","MISSING_PARAMETERS","VALIDATION_ERROR"]);function s(e){return i.has(e.code)}function a(e){return r[e.code]||"An unexpected error occurred. Please try again."}function l(e){if(!e||"object"!=typeof e)return e;const t=JSON.parse(JSON.stringify(e)),n=["carrier","phone_number","mnc","mcc","carrier_name"];for(const e of n)delete t[e];return t}},244:function(e,t){var n=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))(function(r,i){function s(e){try{l(o.next(e))}catch(e){i(e)}}function a(e){try{l(o.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}l((o=o.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.AuthModal=void 0,t.AuthModal=class{constructor(e,t){this.container=null,this.backdrop=null,this.isOpen=!1,this.options=e||{},this.callbacks=t||{},this.handleEscapeKey=this.handleEscapeKey.bind(this)}handleEscapeKey(e){var t,n;"Escape"===e.key&&this.isOpen&&!1!==(null===(t=this.options)||void 0===t?void 0:t.closeOnEscape)&&(null===(n=this.closeCallback)||void 0===n||n.call(this),this.close())}escapeHtml(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}showQRCode(e,t="Scan QR code with your phone"){if(console.log("[Modal] showQRCode called with:",e),this.isOpen)console.log("[Modal] Modal already open, skipping recreation");else{if("object"==typeof e&&e.iosQRCode){const n=e.androidQRCode&&e.androidQRCode.length>0&&e.androidQRCode!==e.iosQRCode;if(console.log("[Modal] Has valid Android QR?",n),n)return console.log("[Modal] Using dual-platform modal"),void this.createDualPlatformQRModal(e,t);console.log("[Modal] Android QR missing/empty, using single iOS QR"),this.createModal(`\n <div class="glide-auth-qr-container">\n <img src="${this.escapeHtml(e.iosQRCode)}" alt="QR Code" class="glide-auth-qr-code" />\n <p class="glide-auth-status">Scan with your iPhone to authenticate</p>\n </div>\n `)}else console.log("[Modal] Using legacy single QR code modal"),this.createModal(`\n <div class="glide-auth-qr-container">\n <img src="${this.escapeHtml(e)}" alt="QR Code" class="glide-auth-qr-code" />\n <p class="glide-auth-status">${this.escapeHtml(t)}</p>\n </div>\n `);this.show()}}createDualPlatformQRModal(e,t){this.createModal(`\n <div class="glide-auth-qr-container">\n \x3c!-- Platform Switcher --\x3e\n <div class="glide-platform-switcher">\n <button class="glide-platform-btn glide-platform-ios active" data-platform="ios">\n <svg width="18" height="18" viewBox="0 0 24 24" fill="currentColor">\n <path d="M17.05 20.28c-.98.95-2.05.88-3.08.4-1.09-.5-2.08-.48-3.24 0-1.44.62-2.2.44-3.06-.4C2.79 15.25 3.51 7.59 9.05 7.31c1.35.07 2.29.74 3.08.8 1.18-.24 2.31-.93 3.57-.84 1.51.12 2.65.72 3.4 1.8-3.12 1.87-2.38 5.98.48 7.13-.57 1.5-1.31 2.99-2.54 4.09l.01-.01zM12.03 7.25c-.15-2.23 1.66-4.07 3.74-4.25.29 2.58-2.34 4.5-3.74 4.25z"/>\n </svg>\n <span>iOS</span>\n </button>\n <button class="glide-platform-btn glide-platform-android" data-platform="android">\n <svg width="18" height="18" viewBox="0 0 24 24" fill="currentColor">\n <path d="M17.6 9.48l1.84-3.18c.16-.31.04-.69-.26-.85-.29-.15-.65-.06-.83.22l-1.88 3.24c-2.86-1.21-6.08-1.21-8.94 0L5.65 5.67c-.19-.28-.54-.38-.83-.22-.3.16-.42.54-.26.85l1.84 3.18C4.08 11.08 2.4 13.97 2.4 17.2h19.2c0-3.23-1.68-6.12-4.0-7.72zM7.0 14.8c-.66 0-1.2-.54-1.2-1.2s.54-1.2 1.2-1.2 1.2.54 1.2 1.2-.54 1.2-1.2 1.2zm10 0c-.66 0-1.2-.54-1.2-1.2s.54-1.2 1.2-1.2 1.2.54 1.2 1.2-.54 1.2-1.2 1.2z"/>\n </svg>\n <span>Android</span>\n </button>\n </div>\n\n \x3c!-- QR Code Image --\x3e\n <img \n id="glide-qr-code-img" \n src="${this.escapeHtml(e.iosQRCode)}" \n alt="QR Code" \n class="glide-auth-qr-code" \n data-ios="${this.escapeHtml(e.iosQRCode)}"\n data-android="${this.escapeHtml(e.androidQRCode||"")}"\n />\n \n \x3c!-- Status Message --\x3e\n <p class="glide-auth-status" id="glide-platform-message">Scan with your iPhone to authenticate</p>\n </div>\n `),this.show()}setCloseCallback(e){this.closeCallback=e}showLinkButton(e,t){return new Promise(n=>{var o,r,i;const s=t||(null===(o=this.options)||void 0===o?void 0:o.buttonText)||"Open Verification App";this.createModal(`\n <div class="glide-auth-link-container">\n <p class="glide-auth-description">\n ${(null===(r=this.options)||void 0===r?void 0:r.description)||"Click below to verify your phone number"}\n </p>\n <button class="glide-auth-button" id="glide-auth-link-button">\n ${s}\n </button>\n <p class="glide-auth-helper-text">\n You'll be redirected to complete verification\n </p>\n </div>\n `),this.show();const a=null===(i=this.container)||void 0===i?void 0:i.querySelector("#glide-auth-link-button");a?a.addEventListener("click",t=>{var o,r;null===(r=null===(o=this.callbacks)||void 0===o?void 0:o.onAuthStart)||void 0===r||r.call(o),window.open(e,"_blank"),n()}):console.error("[Modal] Link button not found in modal")})}showTS43Button(e){return new Promise((t,o)=>{var r,i,s;const a=(null===(r=this.options)||void 0===r?void 0:r.buttonText)||"Verify with Carrier";this.createModal(`\n <div class="glide-auth-ts43-container">\n <p class="glide-auth-description">\n ${(null===(i=this.options)||void 0===i?void 0:i.description)||"Verify using your carrier credentials"}\n </p>\n <button class="glide-auth-button" id="glide-auth-ts43-button">\n ${a}\n </button>\n <p class="glide-auth-helper-text">\n Secure verification through your mobile carrier\n </p>\n </div>\n `),this.show();const l=null===(s=this.container)||void 0===s?void 0:s.querySelector("#glide-auth-ts43-button");l?l.addEventListener("click",r=>n(this,void 0,void 0,function*(){var n,r,i,s,c,u;null===(r=null===(n=this.callbacks)||void 0===n?void 0:n.onAuthStart)||void 0===r||r.call(n),l.setAttribute("disabled","true"),l.textContent="Verifying...";try{const n=yield e();null===(s=null===(i=this.callbacks)||void 0===i?void 0:i.onAuthComplete)||void 0===s||s.call(i,n),t(n),this.close()}catch(e){null===(u=null===(c=this.callbacks)||void 0===c?void 0:c.onError)||void 0===u||u.call(c,e),l.removeAttribute("disabled"),l.textContent=a,o(e)}})):console.error("[Modal] TS43 button not found in modal")})}updateStatus(e,t=!1){var n;const o=null===(n=this.container)||void 0===n?void 0:n.querySelector(".glide-auth-status");o&&(o.textContent=e,o.className=t?"glide-auth-status glide-auth-error":"glide-auth-status")}createModal(e){var t,n,o;this.cleanup(),this.backdrop=document.createElement("div"),this.backdrop.className="glide-auth-backdrop",this.backdrop.style.cssText="\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n background: rgba(0, 0, 0, 0.5);\n z-index: 9998;\n opacity: 0;\n transition: opacity 0.3s ease;\n ",this.container=document.createElement("div"),this.container.className=`glide-auth-modal ${(null===(t=this.options)||void 0===t?void 0:t.className)||""}`,this.container.style.cssText="\n position: fixed;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%) scale(0.9);\n background: white;\n border-radius: 12px;\n padding: 24px;\n max-width: 400px;\n width: 90%;\n box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);\n z-index: 9999;\n opacity: 0;\n transition: opacity 0.3s ease, transform 0.3s ease;\n ",this.container.innerHTML=`\n <div class="glide-auth-header">\n ${!1!==(null===(n=this.options)||void 0===n?void 0:n.showCloseButton)?'\n <button class="glide-auth-close" aria-label="Close">\n <svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">\n <line x1="18" y1="6" x2="6" y2="18"></line>\n <line x1="6" y1="6" x2="18" y2="18"></line>\n </svg>\n </button>\n ':""}\n <h2 class="glide-auth-title">${(null===(o=this.options)||void 0===o?void 0:o.title)||"Phone Verification"}</h2>\n </div>\n <div class="glide-auth-content">\n ${e}\n </div>\n `,this.injectStyles();const r=this.container.querySelector(".glide-auth-close");r&&r.addEventListener("click",()=>{var e;null===(e=this.closeCallback)||void 0===e||e.call(this),this.close()}),this.backdrop.addEventListener("click",e=>{var t,n;e.target===this.backdrop&&!1!==(null===(t=this.options)||void 0===t?void 0:t.closeOnBackdrop)&&(null===(n=this.closeCallback)||void 0===n||n.call(this),this.close())})}injectStyles(){if(document.getElementById("glide-auth-styles"))return;const e=document.createElement("style");e.id="glide-auth-styles",e.textContent="\n .glide-auth-backdrop {\n backdrop-filter: blur(4px);\n }\n\n .glide-auth-modal {\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;\n }\n\n .glide-auth-header {\n position: relative;\n margin-bottom: 20px;\n }\n\n .glide-auth-close {\n position: absolute;\n top: 0;\n right: 0;\n background: none;\n border: none;\n cursor: pointer;\n padding: 0;\n color: #666;\n transition: color 0.2s;\n }\n\n .glide-auth-close:hover {\n color: #000;\n }\n\n .glide-auth-title {\n margin: 0;\n font-size: 24px;\n font-weight: 600;\n color: #333;\n text-align: center;\n }\n\n .glide-auth-content {\n text-align: center;\n }\n\n .glide-auth-description {\n color: #666;\n margin: 0 0 20px 0;\n font-size: 16px;\n line-height: 1.5;\n }\n\n .glide-auth-button {\n background: #007AFF;\n color: white;\n border: none;\n border-radius: 8px;\n padding: 12px 24px;\n font-size: 16px;\n font-weight: 500;\n cursor: pointer;\n transition: background 0.2s, transform 0.1s;\n min-width: 200px;\n }\n\n .glide-auth-button:hover:not(:disabled) {\n background: #0051D5;\n transform: translateY(-1px);\n }\n\n .glide-auth-button:active {\n transform: translateY(0);\n }\n\n .glide-auth-button:disabled {\n opacity: 0.6;\n cursor: not-allowed;\n }\n\n .glide-auth-helper-text {\n color: #999;\n font-size: 14px;\n margin: 16px 0 0 0;\n }\n\n .glide-auth-qr-code {\n max-width: 256px;\n width: 100%;\n height: auto;\n margin: 20px auto;\n display: block;\n }\n\n .glide-auth-status {\n color: #666;\n font-size: 16px;\n margin: 16px 0;\n }\n\n .glide-auth-error {\n color: #FF3B30;\n }\n\n .glide-auth-qr-container,\n .glide-auth-link-container,\n .glide-auth-ts43-container {\n padding: 20px 0;\n }\n\n /* Platform Switcher Styles */\n .glide-platform-switcher {\n display: flex;\n justify-content: center;\n gap: 10px;\n margin-bottom: 20px;\n }\n\n .glide-platform-btn {\n display: flex;\n align-items: center;\n gap: 6px;\n padding: 10px 20px;\n border: 2px solid;\n background: transparent;\n border-radius: 8px;\n cursor: pointer;\n font-size: 14px;\n font-weight: 600;\n transition: all 0.2s ease;\n }\n\n .glide-platform-btn svg {\n flex-shrink: 0;\n }\n\n .glide-platform-ios {\n border-color: #007AFF;\n color: #007AFF;\n }\n\n .glide-platform-ios.active {\n background: #007AFF;\n color: white;\n }\n\n .glide-platform-ios:hover:not(.active) {\n background: rgba(0, 122, 255, 0.1);\n }\n\n .glide-platform-android {\n border-color: #3DDC84;\n color: #3DDC84;\n }\n\n .glide-platform-android.active {\n background: #3DDC84;\n color: white;\n }\n\n .glide-platform-android:hover:not(.active) {\n background: rgba(61, 220, 132, 0.1);\n }\n ",document.head.appendChild(e)}show(){var e,t;this.container&&this.backdrop&&!this.isOpen&&(document.body.appendChild(this.backdrop),document.body.appendChild(this.container),document.addEventListener("keydown",this.handleEscapeKey),this.setupPlatformToggles(),requestAnimationFrame(()=>{this.backdrop&&this.container&&(this.backdrop.style.opacity="1",this.container.style.opacity="1",this.container.style.transform="translate(-50%, -50%) scale(1)")}),this.isOpen=!0,null===(t=null===(e=this.callbacks)||void 0===e?void 0:e.onOpen)||void 0===t||t.call(e))}setupPlatformToggles(){var e,t,n;const o=null===(e=this.container)||void 0===e?void 0:e.querySelectorAll(".glide-platform-btn"),r=null===(t=this.container)||void 0===t?void 0:t.querySelector("#glide-qr-code-img"),i=null===(n=this.container)||void 0===n?void 0:n.querySelector("#glide-platform-message");o&&r&&o.forEach(e=>{e.addEventListener("click",e=>{const t=e.currentTarget,n=t.getAttribute("data-platform");o.forEach(e=>e.classList.remove("active")),t.classList.add("active"),"ios"===n?(r.src=r.getAttribute("data-ios")||"",i&&(i.textContent="Scan with your iPhone to authenticate")):"android"===n&&(r.src=r.getAttribute("data-android")||"",i&&(i.textContent="Scan with your Android device to authenticate"))})})}close(){this.container&&this.backdrop&&this.isOpen&&(document.removeEventListener("keydown",this.handleEscapeKey),this.backdrop.style.opacity="0",this.container.style.opacity="0",this.container.style.transform="translate(-50%, -50%) scale(0.9)",this.closeCallback=void 0,setTimeout(()=>{var e,t;this.cleanup(),this.isOpen=!1,null===(t=null===(e=this.callbacks)||void 0===e?void 0:e.onClose)||void 0===t||t.call(e)},300))}cleanup(){var e,t;null===(e=this.container)||void 0===e||e.remove(),null===(t=this.backdrop)||void 0===t||t.remove(),this.container=null,this.backdrop=null}isModalOpen(){return this.isOpen}}},363:(e,t)=>{function n(e){return e&&"object"==typeof e&&"strategy"in e&&"credential"in e&&"cancel"in e&&"function"==typeof e.cancel}function o(e){return!!n(e)&&("link"===e.strategy&&"start_polling"in e||"desktop"===e.strategy&&"start_polling"in e)}Object.defineProperty(t,"__esModule",{value:!0}),t.requiresUserAction=t.requiresPolling=t.isHeadlessResult=void 0,t.isExtendedResponse=n,t.isCredential=function(e){return!!e&&("string"==typeof e||"object"==typeof e&&(!("strategy"in e)&&!("credential"in e)&&!("cancel"in e)))},t.isAuthCredential=function(e){return e&&"object"==typeof e&&"credential"in e&&"authenticated"in e&&"session"in e},t.isLinkStrategy=function(e){return"link"===e.strategy},t.isTS43Strategy=function(e){return"ts43"===e.strategy},t.isDesktopStrategy=function(e){return"desktop"===e.strategy},t.getStrategy=function(e){if(n(e))return e.strategy},t.hasPollingControls=o,t.hasTrigger=function(e){return!!n(e)&&"trigger"in e&&"function"==typeof e.trigger},t.isHeadlessResult=n,t.requiresPolling=o,t.requiresUserAction=e=>!1},425:(e,t,n)=>{function o(e,t){return function(){return e.apply(t,arguments)}}const{toString:r}=Object.prototype,{getPrototypeOf:i}=Object,{iterator:s,toStringTag:a}=Symbol,l=(c=Object.create(null),e=>{const t=r.call(e);return c[t]||(c[t]=t.slice(8,-1).toLowerCase())});var c;const u=e=>(e=e.toLowerCase(),t=>l(t)===e),d=e=>t=>typeof t===e,{isArray:h}=Array,p=d("undefined");function g(e){return null!==e&&!p(e)&&null!==e.constructor&&!p(e.constructor)&&m(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const E=u("ArrayBuffer"),f=d("string"),m=d("function"),R=d("number"),b=e=>null!==e&&"object"==typeof e,_=e=>{if("object"!==l(e))return!1;const t=i(e);return!(null!==t&&t!==Object.prototype&&null!==Object.getPrototypeOf(t)||a in e||s in e)},v=u("Date"),A=u("File"),y=u("Blob"),O=u("FileList"),S=u("URLSearchParams"),[I,C,T,N]=["ReadableStream","Request","Response","Headers"].map(u);function P(e,t,{allOwnKeys:n=!1}={}){if(null==e)return;let o,r;if("object"!=typeof e&&(e=[e]),h(e))for(o=0,r=e.length;o<r;o++)t.call(null,e[o],o,e);else{if(g(e))return;const r=n?Object.getOwnPropertyNames(e):Object.keys(e),i=r.length;let s;for(o=0;o<i;o++)s=r[o],t.call(null,e[s],s,e)}}function w(e,t){if(g(e))return null;t=t.toLowerCase();const n=Object.keys(e);let o,r=n.length;for(;r-- >0;)if(o=n[r],t===o.toLowerCase())return o;return null}const D="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:n.g,U=e=>!p(e)&&e!==D,L=(x="undefined"!=typeof Uint8Array&&i(Uint8Array),e=>x&&e instanceof x);var x;const k=u("HTMLFormElement"),M=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),j=u("RegExp"),B=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),o={};P(n,(n,r)=>{let i;!1!==(i=t(n,r,e))&&(o[r]=i||n)}),Object.defineProperties(e,o)},F=u("AsyncFunction"),V=(q="function"==typeof setImmediate,H=m(D.postMessage),q?setImmediate:H?(G=`axios@${Math.random()}`,$=[],D.addEventListener("message",({source:e,data:t})=>{e===D&&t===G&&$.length&&$.shift()()},!1),e=>{$.push(e),D.postMessage(G,"*")}):e=>setTimeout(e));var q,H,G,$;const Q="undefined"!=typeof queueMicrotask?queueMicrotask.bind(D):"undefined"!=typeof process&&process.nextTick||V;var W={isArray:h,isArrayBuffer:E,isBuffer:g,isFormData:e=>{let t;return e&&("function"==typeof FormData&&e instanceof FormData||m(e.append)&&("formdata"===(t=l(e))||"object"===t&&m(e.toString)&&"[object FormData]"===e.toString()))},isArrayBufferView:function(e){let t;return t="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&E(e.buffer),t},isString:f,isNumber:R,isBoolean:e=>!0===e||!1===e,isObject:b,isPlainObject:_,isEmptyObject:e=>{if(!b(e)||g(e))return!1;try{return 0===Object.keys(e).length&&Object.getPrototypeOf(e)===Object.prototype}catch(e){return!1}},isReadableStream:I,isRequest:C,isResponse:T,isHeaders:N,isUndefined:p,isDate:v,isFile:A,isBlob:y,isRegExp:j,isFunction:m,isStream:e=>b(e)&&m(e.pipe),isURLSearchParams:S,isTypedArray:L,isFileList:O,forEach:P,merge:function e(){const{caseless:t,skipUndefined:n}=U(this)&&this||{},o={},r=(r,i)=>{const s=t&&w(o,i)||i;_(o[s])&&_(r)?o[s]=e(o[s],r):_(r)?o[s]=e({},r):h(r)?o[s]=r.slice():n&&p(r)||(o[s]=r)};for(let e=0,t=arguments.length;e<t;e++)arguments[e]&&P(arguments[e],r);return o},extend:(e,t,n,{allOwnKeys:r}={})=>(P(t,(t,r)=>{n&&m(t)?e[r]=o(t,n):e[r]=t},{allOwnKeys:r}),e),trim:e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,""),stripBOM:e=>(65279===e.charCodeAt(0)&&(e=e.slice(1)),e),inherits:(e,t,n,o)=>{e.prototype=Object.create(t.prototype,o),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},toFlatObject:(e,t,n,o)=>{let r,s,a;const l={};if(t=t||{},null==e)return t;do{for(r=Object.getOwnPropertyNames(e),s=r.length;s-- >0;)a=r[s],o&&!o(a,e,t)||l[a]||(t[a]=e[a],l[a]=!0);e=!1!==n&&i(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},kindOf:l,kindOfTest:u,endsWith:(e,t,n)=>{e=String(e),(void 0===n||n>e.length)&&(n=e.length),n-=t.length;const o=e.indexOf(t,n);return-1!==o&&o===n},toArray:e=>{if(!e)return null;if(h(e))return e;let t=e.length;if(!R(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},forEachEntry:(e,t)=>{const n=(e&&e[s]).call(e);let o;for(;(o=n.next())&&!o.done;){const n=o.value;t.call(e,n[0],n[1])}},matchAll:(e,t)=>{let n;const o=[];for(;null!==(n=e.exec(t));)o.push(n);return o},isHTMLForm:k,hasOwnProperty:M,hasOwnProp:M,reduceDescriptors:B,freezeMethods:e=>{B(e,(t,n)=>{if(m(e)&&-1!==["arguments","caller","callee"].indexOf(n))return!1;const o=e[n];m(o)&&(t.enumerable=!1,"writable"in t?t.writable=!1:t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")}))})},toObjectSet:(e,t)=>{const n={},o=e=>{e.forEach(e=>{n[e]=!0})};return h(e)?o(e):o(String(e).split(t)),n},toCamelCase:e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(e,t,n){return t.toUpperCase()+n}),noop:()=>{},toFiniteNumber:(e,t)=>null!=e&&Number.isFinite(e=+e)?e:t,findKey:w,global:D,isContextDefined:U,isSpecCompliantForm:function(e){return!!(e&&m(e.append)&&"FormData"===e[a]&&e[s])},toJSONObject:e=>{const t=new Array(10),n=(e,o)=>{if(b(e)){if(t.indexOf(e)>=0)return;if(g(e))return e;if(!("toJSON"in e)){t[o]=e;const r=h(e)?[]:{};return P(e,(e,t)=>{const i=n(e,o+1);!p(i)&&(r[t]=i)}),t[o]=void 0,r}}return e};return n(e,0)},isAsyncFn:F,isThenable:e=>e&&(b(e)||m(e))&&m(e.then)&&m(e.catch),setImmediate:V,asap:Q,isIterable:e=>null!=e&&m(e[s])};function z(e,t,n,o,r){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=(new Error).stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),o&&(this.request=o),r&&(this.response=r,this.status=r.status?r.status:null)}W.inherits(z,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:W.toJSONObject(this.config),code:this.code,status:this.status}}});const K=z.prototype,Y={};function X(e){return W.isPlainObject(e)||W.isArray(e)}function J(e){return W.endsWith(e,"[]")?e.slice(0,-2):e}function Z(e,t,n){return e?e.concat(t).map(function(e,t){return e=J(e),!n&&t?"["+e+"]":e}).join(n?".":""):t}["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{Y[e]={value:e}}),Object.defineProperties(z,Y),Object.defineProperty(K,"isAxiosError",{value:!0}),z.from=(e,t,n,o,r,i)=>{const s=Object.create(K);W.toFlatObject(e,s,function(e){return e!==Error.prototype},e=>"isAxiosError"!==e);const a=e&&e.message?e.message:"Error",l=null==t&&e?e.code:t;return z.call(s,a,l,n,o,r),e&&null==s.cause&&Object.defineProperty(s,"cause",{value:e,configurable:!0}),s.name=e&&e.name||"Error",i&&Object.assign(s,i),s};const ee=W.toFlatObject(W,{},null,function(e){return/^is[A-Z]/.test(e)});function te(e,t,n){if(!W.isObject(e))throw new TypeError("target must be an object");t=t||new FormData;const o=(n=W.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(e,t){return!W.isUndefined(t[e])})).metaTokens,r=n.visitor||c,i=n.dots,s=n.indexes,a=(n.Blob||"undefined"!=typeof Blob&&Blob)&&W.isSpecCompliantForm(t);if(!W.isFunction(r))throw new TypeError("visitor must be a function");function l(e){if(null===e)return"";if(W.isDate(e))return e.toISOString();if(W.isBoolean(e))return e.toString();if(!a&&W.isBlob(e))throw new z("Blob is not supported. Use a Buffer instead.");return W.isArrayBuffer(e)||W.isTypedArray(e)?a&&"function"==typeof Blob?new Blob([e]):Buffer.from(e):e}function c(e,n,r){let a=e;if(e&&!r&&"object"==typeof e)if(W.endsWith(n,"{}"))n=o?n:n.slice(0,-2),e=JSON.stringify(e);else if(W.isArray(e)&&function(e){return W.isArray(e)&&!e.some(X)}(e)||(W.isFileList(e)||W.endsWith(n,"[]"))&&(a=W.toArray(e)))return n=J(n),a.forEach(function(e,o){!W.isUndefined(e)&&null!==e&&t.append(!0===s?Z([n],o,i):null===s?n:n+"[]",l(e))}),!1;return!!X(e)||(t.append(Z(r,n,i),l(e)),!1)}const u=[],d=Object.assign(ee,{defaultVisitor:c,convertValue:l,isVisitable:X});if(!W.isObject(e))throw new TypeError("data must be an object");return function e(n,o){if(!W.isUndefined(n)){if(-1!==u.indexOf(n))throw Error("Circular reference detected in "+o.join("."));u.push(n),W.forEach(n,function(n,i){!0===(!(W.isUndefined(n)||null===n)&&r.call(t,n,W.isString(i)?i.trim():i,o,d))&&e(n,o?o.concat(i):[i])}),u.pop()}}(e),t}function ne(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(e){return t[e]})}function oe(e,t){this._pairs=[],e&&te(e,this,t)}const re=oe.prototype;function ie(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function se(e,t,n){if(!t)return e;const o=n&&n.encode||ie;W.isFunction(n)&&(n={serialize:n});const r=n&&n.serialize;let i;if(i=r?r(t,n):W.isURLSearchParams(t)?t.toString():new oe(t,n).toString(o),i){const t=e.indexOf("#");-1!==t&&(e=e.slice(0,t)),e+=(-1===e.indexOf("?")?"?":"&")+i}return e}re.append=function(e,t){this._pairs.push([e,t])},re.toString=function(e){const t=e?function(t){return e.call(this,t,ne)}:ne;return this._pairs.map(function(e){return t(e[0])+"="+t(e[1])},"").join("&")};var ae=class{constructor(){this.handlers=[]}use(e,t,n){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!n&&n.synchronous,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){W.forEach(this.handlers,function(t){null!==t&&e(t)})}},le={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},ce={isBrowser:!0,classes:{URLSearchParams:"undefined"!=typeof URLSearchParams?URLSearchParams:oe,FormData:"undefined"!=typeof FormData?FormData:null,Blob:"undefined"!=typeof Blob?Blob:null},protocols:["http","https","file","blob","url","data"]};const ue="undefined"!=typeof window&&"undefined"!=typeof document,de="object"==typeof navigator&&navigator||void 0,he=ue&&(!de||["ReactNative","NativeScript","NS"].indexOf(de.product)<0),pe="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&"function"==typeof self.importScripts,ge=ue&&window.location.href||"http://localhost";var Ee={...Object.freeze({__proto__:null,hasBrowserEnv:ue,hasStandardBrowserWebWorkerEnv:pe,hasStandardBrowserEnv:he,navigator:de,origin:ge}),...ce};function fe(e){function t(e,n,o,r){let i=e[r++];if("__proto__"===i)return!0;const s=Number.isFinite(+i),a=r>=e.length;return i=!i&&W.isArray(o)?o.length:i,a?(W.hasOwnProp(o,i)?o[i]=[o[i],n]:o[i]=n,!s):(o[i]&&W.isObject(o[i])||(o[i]=[]),t(e,n,o[i],r)&&W.isArray(o[i])&&(o[i]=function(e){const t={},n=Object.keys(e);let o;const r=n.length;let i;for(o=0;o<r;o++)i=n[o],t[i]=e[i];return t}(o[i])),!s)}if(W.isFormData(e)&&W.isFunction(e.entries)){const n={};return W.forEachEntry(e,(e,o)=>{t(function(e){return W.matchAll(/\w+|\[(\w*)]/g,e).map(e=>"[]"===e[0]?"":e[1]||e[0])}(e),o,n,0)}),n}return null}const me={transitional:le,adapter:["xhr","http","fetch"],transformRequest:[function(e,t){const n=t.getContentType()||"",o=n.indexOf("application/json")>-1,r=W.isObject(e);if(r&&W.isHTMLForm(e)&&(e=new FormData(e)),W.isFormData(e))return o?JSON.stringify(fe(e)):e;if(W.isArrayBuffer(e)||W.isBuffer(e)||W.isStream(e)||W.isFile(e)||W.isBlob(e)||W.isReadableStream(e))return e;if(W.isArrayBufferView(e))return e.buffer;if(W.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let i;if(r){if(n.indexOf("application/x-www-form-urlencoded")>-1)return function(e,t){return te(e,new Ee.classes.URLSearchParams,{visitor:function(e,t,n,o){return Ee.isNode&&W.isBuffer(e)?(this.append(t,e.toString("base64")),!1):o.defaultVisitor.apply(this,arguments)},...t})}(e,this.formSerializer).toString();if((i=W.isFileList(e))||n.indexOf("multipart/form-data")>-1){const t=this.env&&this.env.FormData;return te(i?{"files[]":e}:e,t&&new t,this.formSerializer)}}return r||o?(t.setContentType("application/json",!1),function(e){if(W.isString(e))try{return(0,JSON.parse)(e),W.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(0,JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){const t=this.transitional||me.transitional,n=t&&t.forcedJSONParsing,o="json"===this.responseType;if(W.isResponse(e)||W.isReadableStream(e))return e;if(e&&W.isString(e)&&(n&&!this.responseType||o)){const n=!(t&&t.silentJSONParsing)&&o;try{return JSON.parse(e,this.parseReviver)}catch(e){if(n){if("SyntaxError"===e.name)throw z.from(e,z.ERR_BAD_RESPONSE,this,null,this.response);throw e}}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:Ee.classes.FormData,Blob:Ee.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};W.forEach(["delete","get","head","post","put","patch"],e=>{me.headers[e]={}});var Re=me;const be=W.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),_e=Symbol("internals");function ve(e){return e&&String(e).trim().toLowerCase()}function Ae(e){return!1===e||null==e?e:W.isArray(e)?e.map(Ae):String(e)}function ye(e,t,n,o,r){return W.isFunction(o)?o.call(this,t,n):(r&&(t=n),W.isString(t)?W.isString(o)?-1!==t.indexOf(o):W.isRegExp(o)?o.test(t):void 0:void 0)}class Oe{constructor(e){e&&this.set(e)}set(e,t,n){const o=this;function r(e,t,n){const r=ve(t);if(!r)throw new Error("header name must be a non-empty string");const i=W.findKey(o,r);(!i||void 0===o[i]||!0===n||void 0===n&&!1!==o[i])&&(o[i||t]=Ae(e))}const i=(e,t)=>W.forEach(e,(e,n)=>r(e,n,t));if(W.isPlainObject(e)||e instanceof this.constructor)i(e,t);else if(W.isString(e)&&(e=e.trim())&&!/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim()))i((e=>{const t={};let n,o,r;return e&&e.split("\n").forEach(function(e){r=e.indexOf(":"),n=e.substring(0,r).trim().toLowerCase(),o=e.substring(r+1).trim(),!n||t[n]&&be[n]||("set-cookie"===n?t[n]?t[n].push(o):t[n]=[o]:t[n]=t[n]?t[n]+", "+o:o)}),t})(e),t);else if(W.isObject(e)&&W.isIterable(e)){let n,o,r={};for(const t of e){if(!W.isArray(t))throw TypeError("Object iterator must return a key-value pair");r[o=t[0]]=(n=r[o])?W.isArray(n)?[...n,t[1]]:[n,t[1]]:t[1]}i(r,t)}else null!=e&&r(t,e,n);return this}get(e,t){if(e=ve(e)){const n=W.findKey(this,e);if(n){const e=this[n];if(!t)return e;if(!0===t)return function(e){const t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let o;for(;o=n.exec(e);)t[o[1]]=o[2];return t}(e);if(W.isFunction(t))return t.call(this,e,n);if(W.isRegExp(t))return t.exec(e);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=ve(e)){const n=W.findKey(this,e);return!(!n||void 0===this[n]||t&&!ye(0,this[n],n,t))}return!1}delete(e,t){const n=this;let o=!1;function r(e){if(e=ve(e)){const r=W.findKey(n,e);!r||t&&!ye(0,n[r],r,t)||(delete n[r],o=!0)}}return W.isArray(e)?e.forEach(r):r(e),o}clear(e){const t=Object.keys(this);let n=t.length,o=!1;for(;n--;){const r=t[n];e&&!ye(0,this[r],r,e,!0)||(delete this[r],o=!0)}return o}normalize(e){const t=this,n={};return W.forEach(this,(o,r)=>{const i=W.findKey(n,r);if(i)return t[i]=Ae(o),void delete t[r];const s=e?function(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,t,n)=>t.toUpperCase()+n)}(r):String(r).trim();s!==r&&delete t[r],t[s]=Ae(o),n[s]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const t=Object.create(null);return W.forEach(this,(n,o)=>{null!=n&&!1!==n&&(t[o]=e&&W.isArray(n)?n.join(", "):n)}),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,t])=>e+": "+t).join("\n")}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){const n=new this(e);return t.forEach(e=>n.set(e)),n}static accessor(e){const t=(this[_e]=this[_e]={accessors:{}}).accessors,n=this.prototype;function o(e){const o=ve(e);t[o]||(function(e,t){const n=W.toCamelCase(" "+t);["get","set","has"].forEach(o=>{Object.defineProperty(e,o+n,{value:function(e,n,r){return this[o].call(this,t,e,n,r)},configurable:!0})})}(n,e),t[o]=!0)}return W.isArray(e)?e.forEach(o):o(e),this}}Oe.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),W.reduceDescriptors(Oe.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(e){this[n]=e}}}),W.freezeMethods(Oe);var Se=Oe;function Ie(e,t){const n=this||Re,o=t||n,r=Se.from(o.headers);let i=o.data;return W.forEach(e,function(e){i=e.call(n,i,r.normalize(),t?t.status:void 0)}),r.normalize(),i}function Ce(e){return!(!e||!e.__CANCEL__)}function Te(e,t,n){z.call(this,null==e?"canceled":e,z.ERR_CANCELED,t,n),this.name="CanceledError"}function Ne(e,t,n){const o=n.config.validateStatus;n.status&&o&&!o(n.status)?t(new z("Request failed with status code "+n.status,[z.ERR_BAD_REQUEST,z.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n)):e(n)}W.inherits(Te,z,{__CANCEL__:!0});const Pe=(e,t,n=3)=>{let o=0;const r=function(e,t){e=e||10;const n=new Array(e),o=new Array(e);let r,i=0,s=0;return t=void 0!==t?t:1e3,function(a){const l=Date.now(),c=o[s];r||(r=l),n[i]=a,o[i]=l;let u=s,d=0;for(;u!==i;)d+=n[u++],u%=e;if(i=(i+1)%e,i===s&&(s=(s+1)%e),l-r<t)return;const h=c&&l-c;return h?Math.round(1e3*d/h):void 0}}(50,250);return function(n,i){let s,a,l=0,c=1e3/i;const u=(n,i=Date.now())=>{l=i,s=null,a&&(clearTimeout(a),a=null),(n=>{const i=n.loaded,s=n.lengthComputable?n.total:void 0,a=i-o,l=r(a);o=i,e({loaded:i,total:s,progress:s?i/s:void 0,bytes:a,rate:l||void 0,estimated:l&&s&&i<=s?(s-i)/l:void 0,event:n,lengthComputable:null!=s,[t?"download":"upload"]:!0})})(...n)};return[(...e)=>{const t=Date.now(),n=t-l;n>=c?u(e,t):(s=e,a||(a=setTimeout(()=>{a=null,u(s)},c-n)))},()=>s&&u(s)]}(0,n)},we=(e,t)=>{const n=null!=e;return[o=>t[0]({lengthComputable:n,total:e,loaded:o}),t[1]]},De=e=>(...t)=>W.asap(()=>e(...t));var Ue=Ee.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,Ee.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(Ee.origin),Ee.navigator&&/(msie|trident)/i.test(Ee.navigator.userAgent)):()=>!0,Le=Ee.hasStandardBrowserEnv?{write(e,t,n,o,r,i){const s=[e+"="+encodeURIComponent(t)];W.isNumber(n)&&s.push("expires="+new Date(n).toGMTString()),W.isString(o)&&s.push("path="+o),W.isString(r)&&s.push("domain="+r),!0===i&&s.push("secure"),document.cookie=s.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read:()=>null,remove(){}};function xe(e,t,n){let o=!/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t);return e&&(o||0==n)?function(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}(e,t):t}const ke=e=>e instanceof Se?{...e}:e;function Me(e,t){t=t||{};const n={};function o(e,t,n,o){return W.isPlainObject(e)&&W.isPlainObject(t)?W.merge.call({caseless:o},e,t):W.isPlainObject(t)?W.merge({},t):W.isArray(t)?t.slice():t}function r(e,t,n,r){return W.isUndefined(t)?W.isUndefined(e)?void 0:o(void 0,e,0,r):o(e,t,0,r)}function i(e,t){if(!W.isUndefined(t))return o(void 0,t)}function s(e,t){return W.isUndefined(t)?W.isUndefined(e)?void 0:o(void 0,e):o(void 0,t)}function a(n,r,i){return i in t?o(n,r):i in e?o(void 0,n):void 0}const l={url:i,method:i,data:i,baseURL:s,transformRequest:s,transformResponse:s,paramsSerializer:s,timeout:s,timeoutMessage:s,withCredentials:s,withXSRFToken:s,adapter:s,responseType:s,xsrfCookieName:s,xsrfHeaderName:s,onUploadProgress:s,onDownloadProgress:s,decompress:s,maxContentLength:s,maxBodyLength:s,beforeRedirect:s,transport:s,httpAgent:s,httpsAgent:s,cancelToken:s,socketPath:s,responseEncoding:s,validateStatus:a,headers:(e,t,n)=>r(ke(e),ke(t),0,!0)};return W.forEach(Object.keys({...e,...t}),function(o){const i=l[o]||r,s=i(e[o],t[o],o);W.isUndefined(s)&&i!==a||(n[o]=s)}),n}var je=e=>{const t=Me({},e);let{data:n,withXSRFToken:o,xsrfHeaderName:r,xsrfCookieName:i,headers:s,auth:a}=t;if(t.headers=s=Se.from(s),t.url=se(xe(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),a&&s.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),W.isFormData(n))if(Ee.hasStandardBrowserEnv||Ee.hasStandardBrowserWebWorkerEnv)s.setContentType(void 0);else if(W.isFunction(n.getHeaders)){const e=n.getHeaders(),t=["content-type","content-length"];Object.entries(e).forEach(([e,n])=>{t.includes(e.toLowerCase())&&s.set(e,n)})}if(Ee.hasStandardBrowserEnv&&(o&&W.isFunction(o)&&(o=o(t)),o||!1!==o&&Ue(t.url))){const e=r&&i&&Le.read(i);e&&s.set(r,e)}return t},Be="undefined"!=typeof XMLHttpRequest&&function(e){return new Promise(function(t,n){const o=je(e);let r=o.data;const i=Se.from(o.headers).normalize();let s,a,l,c,u,{responseType:d,onUploadProgress:h,onDownloadProgress:p}=o;function g(){c&&c(),u&&u(),o.cancelToken&&o.cancelToken.unsubscribe(s),o.signal&&o.signal.removeEventListener("abort",s)}let E=new XMLHttpRequest;function f(){if(!E)return;const o=Se.from("getAllResponseHeaders"in E&&E.getAllResponseHeaders());Ne(function(e){t(e),g()},function(e){n(e),g()},{data:d&&"text"!==d&&"json"!==d?E.response:E.responseText,status:E.status,statusText:E.statusText,headers:o,config:e,request:E}),E=null}E.open(o.method.toUpperCase(),o.url,!0),E.timeout=o.timeout,"onloadend"in E?E.onloadend=f:E.onreadystatechange=function(){E&&4===E.readyState&&(0!==E.status||E.responseURL&&0===E.responseURL.indexOf("file:"))&&setTimeout(f)},E.onabort=function(){E&&(n(new z("Request aborted",z.ECONNABORTED,e,E)),E=null)},E.onerror=function(t){const o=new z(t&&t.message?t.message:"Network Error",z.ERR_NETWORK,e,E);o.event=t||null,n(o),E=null},E.ontimeout=function(){let t=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const r=o.transitional||le;o.timeoutErrorMessage&&(t=o.timeoutErrorMessage),n(new z(t,r.clarifyTimeoutError?z.ETIMEDOUT:z.ECONNABORTED,e,E)),E=null},void 0===r&&i.setContentType(null),"setRequestHeader"in E&&W.forEach(i.toJSON(),function(e,t){E.setRequestHeader(t,e)}),W.isUndefined(o.withCredentials)||(E.withCredentials=!!o.withCredentials),d&&"json"!==d&&(E.responseType=o.responseType),p&&([l,u]=Pe(p,!0),E.addEventListener("progress",l)),h&&E.upload&&([a,c]=Pe(h),E.upload.addEventListener("progress",a),E.upload.addEventListener("loadend",c)),(o.cancelToken||o.signal)&&(s=t=>{E&&(n(!t||t.type?new Te(null,e,E):t),E.abort(),E=null)},o.cancelToken&&o.cancelToken.subscribe(s),o.signal&&(o.signal.aborted?s():o.signal.addEventListener("abort",s)));const m=function(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}(o.url);m&&-1===Ee.protocols.indexOf(m)?n(new z("Unsupported protocol "+m+":",z.ERR_BAD_REQUEST,e)):E.send(r||null)})},Fe=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let n,o=new AbortController;const r=function(e){if(!n){n=!0,s();const t=e instanceof Error?e:this.reason;o.abort(t instanceof z?t:new Te(t instanceof Error?t.message:t))}};let i=t&&setTimeout(()=>{i=null,r(new z(`timeout ${t} of ms exceeded`,z.ETIMEDOUT))},t);const s=()=>{e&&(i&&clearTimeout(i),i=null,e.forEach(e=>{e.unsubscribe?e.unsubscribe(r):e.removeEventListener("abort",r)}),e=null)};e.forEach(e=>e.addEventListener("abort",r));const{signal:a}=o;return a.unsubscribe=()=>W.asap(s),a}};const Ve=function*(e,t){let n=e.byteLength;if(!t||n<t)return void(yield e);let o,r=0;for(;r<n;)o=r+t,yield e.slice(r,o),r=o},qe=(e,t,n,o)=>{const r=async function*(e,t){for await(const n of async function*(e){if(e[Symbol.asyncIterator])return void(yield*e);const t=e.getReader();try{for(;;){const{done:e,value:n}=await t.read();if(e)break;yield n}}finally{await t.cancel()}}(e))yield*Ve(n,t)}(e,t);let i,s=0,a=e=>{i||(i=!0,o&&o(e))};return new ReadableStream({async pull(e){try{const{done:t,value:o}=await r.next();if(t)return a(),void e.close();let i=o.byteLength;if(n){let e=s+=i;n(e)}e.enqueue(new Uint8Array(o))}catch(e){throw a(e),e}},cancel:e=>(a(e),r.return())},{highWaterMark:2})},{isFunction:He}=W,Ge=(({Request:e,Response:t})=>({Request:e,Response:t}))(W.global),{ReadableStream:$e,TextEncoder:Qe}=W.global,We=(e,...t)=>{try{return!!e(...t)}catch(e){return!1}},ze=e=>{e=W.merge.call({skipUndefined:!0},Ge,e);const{fetch:t,Request:n,Response:o}=e,r=t?He(t):"function"==typeof fetch,i=He(n),s=He(o);if(!r)return!1;const a=r&&He($e),l=r&&("function"==typeof Qe?(c=new Qe,e=>c.encode(e)):async e=>new Uint8Array(await new n(e).arrayBuffer()));var c;const u=i&&a&&We(()=>{let e=!1;const t=new n(Ee.origin,{body:new $e,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t}),d=s&&a&&We(()=>W.isReadableStream(new o("").body)),h={stream:d&&(e=>e.body)};r&&["text","arrayBuffer","blob","formData","stream"].forEach(e=>{!h[e]&&(h[e]=(t,n)=>{let o=t&&t[e];if(o)return o.call(t);throw new z(`Response type '${e}' is not supported`,z.ERR_NOT_SUPPORT,n)})});return async e=>{let{url:r,method:s,data:a,signal:c,cancelToken:p,timeout:g,onDownloadProgress:E,onUploadProgress:f,responseType:m,headers:R,withCredentials:b="same-origin",fetchOptions:_}=je(e),v=t||fetch;m=m?(m+"").toLowerCase():"text";let A=Fe([c,p&&p.toAbortSignal()],g),y=null;const O=A&&A.unsubscribe&&(()=>{A.unsubscribe()});let S;try{if(f&&u&&"get"!==s&&"head"!==s&&0!==(S=await(async(e,t)=>{const o=W.toFiniteNumber(e.getContentLength());return null==o?(async e=>{if(null==e)return 0;if(W.isBlob(e))return e.size;if(W.isSpecCompliantForm(e)){const t=new n(Ee.origin,{method:"POST",body:e});return(await t.arrayBuffer()).byteLength}return W.isArrayBufferView(e)||W.isArrayBuffer(e)?e.byteLength:(W.isURLSearchParams(e)&&(e+=""),W.isString(e)?(await l(e)).byteLength:void 0)})(t):o})(R,a))){let e,t=new n(r,{method:"POST",body:a,duplex:"half"});if(W.isFormData(a)&&(e=t.headers.get("content-type"))&&R.setContentType(e),t.body){const[e,n]=we(S,Pe(De(f)));a=qe(t.body,65536,e,n)}}W.isString(b)||(b=b?"include":"omit");const t=i&&"credentials"in n.prototype,c={..._,signal:A,method:s.toUpperCase(),headers:R.normalize().toJSON(),body:a,duplex:"half",credentials:t?b:void 0};y=i&&new n(r,c);let p=await(i?v(y,_):v(r,c));const g=d&&("stream"===m||"response"===m);if(d&&(E||g&&O)){const e={};["status","statusText","headers"].forEach(t=>{e[t]=p[t]});const t=W.toFiniteNumber(p.headers.get("content-length")),[n,r]=E&&we(t,Pe(De(E),!0))||[];p=new o(qe(p.body,65536,n,()=>{r&&r(),O&&O()}),e)}m=m||"text";let I=await h[W.findKey(h,m)||"text"](p,e);return!g&&O&&O(),await new Promise((t,n)=>{Ne(t,n,{data:I,headers:Se.from(p.headers),status:p.status,statusText:p.statusText,config:e,request:y})})}catch(t){if(O&&O(),t&&"TypeError"===t.name&&/Load failed|fetch/i.test(t.message))throw Object.assign(new z("Network Error",z.ERR_NETWORK,e,y),{cause:t.cause||t});throw z.from(t,t&&t.code,e,y)}}},Ke=new Map,Ye=e=>{let t=e?e.env:{};const{fetch:n,Request:o,Response:r}=t,i=[o,r,n];let s,a,l=i.length,c=Ke;for(;l--;)s=i[l],a=c.get(s),void 0===a&&c.set(s,a=l?new Map:ze(t)),c=a;return a};Ye();const Xe={http:null,xhr:Be,fetch:{get:Ye}};W.forEach(Xe,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch(e){}Object.defineProperty(e,"adapterName",{value:t})}});const Je=e=>`- ${e}`,Ze=e=>W.isFunction(e)||null===e||!1===e;var et=(e,t)=>{e=W.isArray(e)?e:[e];const{length:n}=e;let o,r;const i={};for(let s=0;s<n;s++){let n;if(o=e[s],r=o,!Ze(o)&&(r=Xe[(n=String(o)).toLowerCase()],void 0===r))throw new z(`Unknown adapter '${n}'`);if(r&&(W.isFunction(r)||(r=r.get(t))))break;i[n||"#"+s]=r}if(!r){const e=Object.entries(i).map(([e,t])=>`adapter ${e} `+(!1===t?"is not supported by the environment":"is not available in the build"));throw new z("There is no suitable adapter to dispatch the request "+(n?e.length>1?"since :\n"+e.map(Je).join("\n"):" "+Je(e[0]):"as no adapter specified"),"ERR_NOT_SUPPORT")}return r};function tt(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new Te(null,e)}function nt(e){return tt(e),e.headers=Se.from(e.headers),e.data=Ie.call(e,e.transformRequest),-1!==["post","put","patch"].indexOf(e.method)&&e.headers.setContentType("application/x-www-form-urlencoded",!1),et(e.adapter||Re.adapter,e)(e).then(function(t){return tt(e),t.data=Ie.call(e,e.transformResponse,t),t.headers=Se.from(t.headers),t},function(t){return Ce(t)||(tt(e),t&&t.response&&(t.response.data=Ie.call(e,e.transformResponse,t.response),t.response.headers=Se.from(t.response.headers))),Promise.reject(t)})}const ot="1.12.2",rt={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{rt[e]=function(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}});const it={};rt.transitional=function(e,t,n){function o(e,t){return"[Axios v"+ot+"] Transitional option '"+e+"'"+t+(n?". "+n:"")}return(n,r,i)=>{if(!1===e)throw new z(o(r," has been removed"+(t?" in "+t:"")),z.ERR_DEPRECATED);return t&&!it[r]&&(it[r]=!0,console.warn(o(r," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(n,r,i)}},rt.spelling=function(e){return(t,n)=>(console.warn(`${n} is likely a misspelling of ${e}`),!0)};var st={assertOptions:function(e,t,n){if("object"!=typeof e)throw new z("options must be an object",z.ERR_BAD_OPTION_VALUE);const o=Object.keys(e);let r=o.length;for(;r-- >0;){const i=o[r],s=t[i];if(s){const t=e[i],n=void 0===t||s(t,i,e);if(!0!==n)throw new z("option "+i+" must be "+n,z.ERR_BAD_OPTION_VALUE);continue}if(!0!==n)throw new z("Unknown option "+i,z.ERR_BAD_OPTION)}},validators:rt};const at=st.validators;class lt{constructor(e){this.defaults=e||{},this.interceptors={request:new ae,response:new ae}}async request(e,t){try{return await this._request(e,t)}catch(e){if(e instanceof Error){let t={};Error.captureStackTrace?Error.captureStackTrace(t):t=new Error;const n=t.stack?t.stack.replace(/^.+\n/,""):"";try{e.stack?n&&!String(e.stack).endsWith(n.replace(/^.+\n.+\n/,""))&&(e.stack+="\n"+n):e.stack=n}catch(e){}}throw e}}_request(e,t){"string"==typeof e?(t=t||{}).url=e:t=e||{},t=Me(this.defaults,t);const{transitional:n,paramsSerializer:o,headers:r}=t;void 0!==n&&st.assertOptions(n,{silentJSONParsing:at.transitional(at.boolean),forcedJSONParsing:at.transitional(at.boolean),clarifyTimeoutError:at.transitional(at.boolean)},!1),null!=o&&(W.isFunction(o)?t.paramsSerializer={serialize:o}:st.assertOptions(o,{encode:at.function,serialize:at.function},!0)),void 0!==t.allowAbsoluteUrls||(void 0!==this.defaults.allowAbsoluteUrls?t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:t.allowAbsoluteUrls=!0),st.assertOptions(t,{baseUrl:at.spelling("baseURL"),withXsrfToken:at.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let i=r&&W.merge(r.common,r[t.method]);r&&W.forEach(["delete","get","head","post","put","patch","common"],e=>{delete r[e]}),t.headers=Se.concat(i,r);const s=[];let a=!0;this.interceptors.request.forEach(function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(a=a&&e.synchronous,s.unshift(e.fulfilled,e.rejected))});const l=[];let c;this.interceptors.response.forEach(function(e){l.push(e.fulfilled,e.rejected)});let u,d=0;if(!a){const e=[nt.bind(this),void 0];for(e.unshift(...s),e.push(...l),u=e.length,c=Promise.resolve(t);d<u;)c=c.then(e[d++],e[d++]);return c}u=s.length;let h=t;for(;d<u;){const e=s[d++],t=s[d++];try{h=e(h)}catch(e){t.call(this,e);break}}try{c=nt.call(this,h)}catch(e){return Promise.reject(e)}for(d=0,u=l.length;d<u;)c=c.then(l[d++],l[d++]);return c}getUri(e){return se(xe((e=Me(this.defaults,e)).baseURL,e.url,e.allowAbsoluteUrls),e.params,e.paramsSerializer)}}W.forEach(["delete","get","head","options"],function(e){lt.prototype[e]=function(t,n){return this.request(Me(n||{},{method:e,url:t,data:(n||{}).data}))}}),W.forEach(["post","put","patch"],function(e){function t(t){return function(n,o,r){return this.request(Me(r||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:n,data:o}))}}lt.prototype[e]=t(),lt.prototype[e+"Form"]=t(!0)});var ct=lt;class ut{constructor(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");let t;this.promise=new Promise(function(e){t=e});const n=this;this.promise.then(e=>{if(!n._listeners)return;let t=n._listeners.length;for(;t-- >0;)n._listeners[t](e);n._listeners=null}),this.promise.then=e=>{let t;const o=new Promise(e=>{n.subscribe(e),t=e}).then(e);return o.cancel=function(){n.unsubscribe(t)},o},e(function(e,o,r){n.reason||(n.reason=new Te(e,o,r),t(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const t=this._listeners.indexOf(e);-1!==t&&this._listeners.splice(t,1)}toAbortSignal(){const e=new AbortController,t=t=>{e.abort(t)};return this.subscribe(t),e.signal.unsubscribe=()=>this.unsubscribe(t),e.signal}static source(){let e;return{token:new ut(function(t){e=t}),cancel:e}}}var dt=ut;const ht={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(ht).forEach(([e,t])=>{ht[t]=e});var pt=ht;const gt=function e(t){const n=new ct(t),r=o(ct.prototype.request,n);return W.extend(r,ct.prototype,n,{allOwnKeys:!0}),W.extend(r,n,null,{allOwnKeys:!0}),r.create=function(n){return e(Me(t,n))},r}(Re);gt.Axios=ct,gt.CanceledError=Te,gt.CancelToken=dt,gt.isCancel=Ce,gt.VERSION=ot,gt.toFormData=te,gt.AxiosError=z,gt.Cancel=gt.CanceledError,gt.all=function(e){return Promise.all(e)},gt.spread=function(e){return function(t){return e.apply(null,t)}},gt.isAxiosError=function(e){return W.isObject(e)&&!0===e.isAxiosError},gt.mergeConfig=Me,gt.AxiosHeaders=Se,gt.formToJSON=e=>fe(W.isHTMLForm(e)?new FormData(e):e),gt.getAdapter=et,gt.HttpStatusCode=pt,gt.default=gt,e.exports=gt},495:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.validatePhoneNumber=function(e){return e?e.startsWith("+")?e.length<8?{valid:!1,error:"Phone number too short for E.164 format (minimum 8 characters including +)"}:e.length>16?{valid:!1,error:"Phone number too long for E.164 format (maximum 15 digits after +)"}:/^\+\d+$/.test(e)?/^\+[1-9]\d{1,14}$/.test(e)?{valid:!0}:{valid:!1,error:"Invalid E.164 phone number format"}:{valid:!1,error:"Phone number contains invalid characters. E.164 format only allows + followed by digits"}:{valid:!1,error:"Phone number must be in E.164 format (start with +)"}:{valid:!0}},t.validatePlmn=function(e){if(!e)return{valid:!0};const{mcc:t,mnc:n}=e;return t&&/^\d{3}$/.test(t)?n&&/^\d{2,3}$/.test(n)?{valid:!0}:{valid:!1,error:"MNC must be 2 or 3 digits"}:{valid:!1,error:"MCC must be exactly 3 digits"}},t.validateUseCaseRequirements=function(e,t,n){return e!==o.USE_CASE.VERIFY_PHONE_NUMBER||t||n?{valid:!0}:{valid:!1,error:"Phone number is required for VerifyPhoneNumber use case"}},t.validateConsentData=function(e){if(!e)return{valid:!0};const{consent_text:t,policy_link:n,policy_text:o}=e;if(!t||0===t.trim().length)return{valid:!1,error:"Consent text is required when consent data is provided"};if(!n||0===n.trim().length)return{valid:!1,error:"Policy link is required when consent data is provided"};try{new URL(n)}catch(e){return{valid:!1,error:"Policy link must be a valid URL"}}return o&&0!==o.trim().length?{valid:!0}:{valid:!1,error:"Policy text is required when consent data is provided"}},t.createValidationError=function(e,t,n){const o=new Error(t);return o.code=e,n&&(o.field=n),o},t.validateNonce=function(e){return e&&0!==e.length?/^[A-Za-z0-9_-]+$/.test(e)?e.length<32||e.length>128?{valid:!1,error:"Nonce must be between 32 and 128 characters"}:{valid:!0}:{valid:!1,error:"Nonce must be base64url encoded"}:{valid:!1,error:"Nonce is required"}};const o=n(566)},499:function(e,t,n){var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))(function(r,i){function s(e){try{l(o.next(e))}catch(e){i(e)}}function a(e){try{l(o.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}l((o=o.apply(e,t||[])).next())})},r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.SDKClient=void 0;const i=r(n(425)),s=n(514);t.SDKClient=class{constructor(e){this.config=e,this.client=i.default.create({baseURL:e.baseURL||"",timeout:e.timeout||1e4,headers:{"Content-Type":"application/json"}}),this.phoneAuth=new s.PhoneAuthClient({endpoints:e.phoneAuthEndpoints?{prepare:e.phoneAuthEndpoints.prepareRequest,process:e.phoneAuthEndpoints.processResponse}:void 0,debug:e.debug}),this.client.interceptors.request.use(e=>o(this,void 0,void 0,function*(){return this.token&&(e.headers.Authorization=`Bearer ${this.token}`),e}))}setToken(e){this.token=e}clearToken(){this.token=void 0}get(e,t){return o(this,void 0,void 0,function*(){if(!this.config.baseURL)throw new Error("baseURL is required for making API requests. Please provide it in the ClientConfig.");const n=yield this.client.get(e,{headers:null==t?void 0:t.headers,params:null==t?void 0:t.params});return{data:n.data,status:n.status,headers:Object.fromEntries(Object.entries(n.headers).map(([e,t])=>[e,String(t)]))}})}}},514:function(e,t,n){var o=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,r)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),r=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||o(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),t.requiresUserAction=t.requiresPolling=t.isHeadlessResult=t.hasTrigger=t.hasPollingControls=t.getStrategy=t.isDesktopStrategy=t.isTS43Strategy=t.isLinkStrategy=t.isAuthCredential=t.isCredential=t.isExtendedResponse=t.MobileDebugConsole=t.validateNonce=t.validateConsentData=t.validateUseCaseRequirements=t.validatePlmn=t.validatePhoneNumber=t.createErrorBreadcrumb=t.serializeError=t.isRetryableError=t.getRetryDelay=t.isErrorCode=t.getUserMessage=t.isUserError=t.isPhoneAuthError=t.PhoneAuthErrorCode=t.PhoneAuthClient=void 0;var i=n(895);Object.defineProperty(t,"PhoneAuthClient",{enumerable:!0,get:function(){return i.PhoneAuthClient}}),r(n(931),t);var s=n(192);Object.defineProperty(t,"PhoneAuthErrorCode",{enumerable:!0,get:function(){return s.PhoneAuthErrorCode}}),Object.defineProperty(t,"isPhoneAuthError",{enumerable:!0,get:function(){return s.isPhoneAuthError}}),Object.defineProperty(t,"isUserError",{enumerable:!0,get:function(){return s.isUserError}}),Object.defineProperty(t,"getUserMessage",{enumerable:!0,get:function(){return s.getUserMessage}}),Object.defineProperty(t,"isErrorCode",{enumerable:!0,get:function(){return s.isErrorCode}}),Object.defineProperty(t,"getRetryDelay",{enumerable:!0,get:function(){return s.getRetryDelay}}),Object.defineProperty(t,"isRetryableError",{enumerable:!0,get:function(){return s.isRetryableError}}),Object.defineProperty(t,"serializeError",{enumerable:!0,get:function(){return s.serializeError}}),Object.defineProperty(t,"createErrorBreadcrumb",{enumerable:!0,get:function(){return s.createErrorBreadcrumb}});var a=n(495);Object.defineProperty(t,"validatePhoneNumber",{enumerable:!0,get:function(){return a.validatePhoneNumber}}),Object.defineProperty(t,"validatePlmn",{enumerable:!0,get:function(){return a.validatePlmn}}),Object.defineProperty(t,"validateUseCaseRequirements",{enumerable:!0,get:function(){return a.validateUseCaseRequirements}}),Object.defineProperty(t,"validateConsentData",{enumerable:!0,get:function(){return a.validateConsentData}}),Object.defineProperty(t,"validateNonce",{enumerable:!0,get:function(){return a.validateNonce}});var l=n(545);Object.defineProperty(t,"MobileDebugConsole",{enumerable:!0,get:function(){return l.MobileDebugConsole}});var c=n(363);Object.defineProperty(t,"isExtendedResponse",{enumerable:!0,get:function(){return c.isExtendedResponse}}),Object.defineProperty(t,"isCredential",{enumerable:!0,get:function(){return c.isCredential}}),Object.defineProperty(t,"isAuthCredential",{enumerable:!0,get:function(){return c.isAuthCredential}}),Object.defineProperty(t,"isLinkStrategy",{enumerable:!0,get:function(){return c.isLinkStrategy}}),Object.defineProperty(t,"isTS43Strategy",{enumerable:!0,get:function(){return c.isTS43Strategy}}),Object.defineProperty(t,"isDesktopStrategy",{enumerable:!0,get:function(){return c.isDesktopStrategy}}),Object.defineProperty(t,"getStrategy",{enumerable:!0,get:function(){return c.getStrategy}}),Object.defineProperty(t,"hasPollingControls",{enumerable:!0,get:function(){return c.hasPollingControls}}),Object.defineProperty(t,"hasTrigger",{enumerable:!0,get:function(){return c.hasTrigger}}),Object.defineProperty(t,"isHeadlessResult",{enumerable:!0,get:function(){return c.isHeadlessResult}}),Object.defineProperty(t,"requiresPolling",{enumerable:!0,get:function(){return c.requiresPolling}}),Object.defineProperty(t,"requiresUserAction",{enumerable:!0,get:function(){return c.requiresUserAction}})},544:function(e,t){var n=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))(function(r,i){function s(e){try{l(o.next(e))}catch(e){i(e)}}function a(e){try{l(o.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}l((o=o.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.LinkHandler=void 0,t.LinkHandler=class{constructor(){this.isPollingActive=!1,this.isCancelled=!1,this.isPollingInProgress=!1}invoke(e,t){return n(this,void 0,void 0,function*(){console.log("[Link Auth] 🔗 invoke() called with data:",JSON.stringify(e,null,2)),console.log("[Link Auth] Options:",t?JSON.stringify({pollingInterval:t.pollingInterval,maxPollingAttempts:t.maxPollingAttempts,pollingEndpoint:t.pollingEndpoint}):"none");const n=e.data;if(!n||!n.url)throw new Error("Invalid link data: missing URL");const o=e.session.session_key;return console.log("[Link Auth] Session key:",o),console.log("[Link Auth] Link URL:",n.url),this.openAuthenticationLink(n.url),(null==t?void 0:t.onLinkOpened)&&t.onLinkOpened(),this.startPolling(o,n,t)})}openAuthenticationLink(e){const t=window.open(e,"_blank");t&&!t.closed&&void 0!==t.closed||console.warn("[LinkHandler] Failed to open app link - popup may have been blocked")}startPolling(e,t,o){return n(this,void 0,void 0,function*(){const r=(null==o?void 0:o.pollingInterval)||2e3,i=(null==o?void 0:o.maxPollingAttempts)||30;let s=0;return console.log("[Link Auth] 🚀 Starting polling:",{sessionKey:e,interval:`${r}ms`,maxAttempts:i,linkDataAvailable:!!t}),new Promise((a,l)=>{this.isPollingActive=!0,this.pollingReject=l;const c=()=>n(this,void 0,void 0,function*(){if(!this.isPollingActive)return;if(this.isPollingInProgress)return;let n="";try{if(this.isPollingInProgress=!0,s>=i){this.stopPolling(),(null==o?void 0:o.onTimeout)&&o.onTimeout();const e=Math.round(i*r/1e3),t=e>=60?`${Math.floor(e/60)} minute${Math.floor(e/60)>1?"s":""}`:`${e} seconds`;return(null==o?void 0:o.onStatusUpdate)&&o.onStatusUpdate({status:"expired",message:`Authentication timeout after ${t}`}),void l(new Error(`Authentication timeout after ${t}`))}let c=null==o?void 0:o.pollingEndpoint,u="options";if(!c&&t.status_url&&(c=t.status_url,u="backend"),console.log("[Link Auth] Polling endpoint selection:"),console.log(" - options?.pollingEndpoint:",null==o?void 0:o.pollingEndpoint),console.log(" - linkData.status_url:",t.status_url),console.log(" - selected endpoint:",c,"from source:",u),c&&(c.startsWith("http://")||c.startsWith("https://")))if(c.includes("{{session_id}}"))n=c.replace("{{session_id}}",e);else if(c.includes(e))n=c;else{const t=new URL(c);n=`${t.protocol}//${t.host}/public/public/status/${e}`}else if(c&&""!==c){const t="undefined"!=typeof window?window.location.origin:"";n=c.includes("{{session_id}}")?t+c.replace("{{session_id}}",e):t+c+"/"+e}else n=`https://api.glideidentity.app/public/public/status/${e}`,u="fallback";console.log(`[Link Auth] Using ${u} endpoint: ${n}`),console.log(`[Link Auth] Polling status (attempt ${s}/${i}): ${n}`);const d=yield fetch(n,{method:"GET",headers:{Accept:"application/json"}});if(console.log(`[Link Auth] Poll response - Status: ${d.status}, OK: ${d.ok}`),200===d.status){const t=yield d.json();console.log("[Link Auth] Poll response data:",JSON.stringify(t,null,2)),"completed"===t.status?(console.log("[Link Auth] ✅ Authentication COMPLETED! Session:",e),console.log("[Link Auth] Full completion result:",JSON.stringify(t,null,2)),this.stopPolling(),(null==o?void 0:o.onStatusUpdate)&&o.onStatusUpdate({status:"authenticated",message:"Authentication successful",data:t}),this.pollingReject=void 0,a({authenticated:!0,credential:t.credential||e,session:t.session||{session_key:e,status:t.status,protocol:t.protocol||"link",created_at:t.created_at,last_updated:t.last_updated}})):"pending"===t.status?(console.log("[Link Auth] Status still pending, continuing to poll..."),s++,(null==o?void 0:o.onStatusUpdate)&&o.onStatusUpdate({status:"pending",message:"Waiting for app authentication..."})):(console.log("[Link Auth] ⚠️ Unexpected status value:",t.status,"Full result:",JSON.stringify(t,null,2)),s++)}else if(410===d.status){console.log("[Link Auth] ❌ Session expired (410)"),this.stopPolling();const e=yield d.json().catch(()=>({message:"Session expired"}));(null==o?void 0:o.onTimeout)&&o.onTimeout(),(null==o?void 0:o.onStatusUpdate)&&o.onStatusUpdate({status:"expired",message:e.message||"Session expired"}),l(new Error(e.message||"Session expired"))}else if(422===d.status){console.log("[Link Auth] ❌ Authentication failed (422)"),this.stopPolling();const e=yield d.json().catch(()=>({message:"Authentication failed"}));console.log("[Link Auth] Error data:",JSON.stringify(e,null,2));const t="USER_CANCELLED"===e.code?"User cancelled authentication":e.message||"Verification failed";(null==o?void 0:o.onStatusUpdate)&&o.onStatusUpdate({status:"error",message:t}),l(new Error(t))}else if(404===d.status)console.log("[Link Auth] ❌ Session not found (404)"),this.stopPolling(),(null==o?void 0:o.onStatusUpdate)&&o.onStatusUpdate({status:"error",message:"Session not found"}),l(new Error("Session not found"));else if(400===d.status){console.log("[Link Auth] ❌ Invalid session key (400)"),this.stopPolling();const e=yield d.json().catch(()=>({message:"Invalid session key"}));console.log("[Link Auth] Error data:",JSON.stringify(e,null,2)),l(new Error(e.message||"Invalid session key"))}else{console.log("[Link Auth] ⚠️ Unexpected HTTP status:",d.status,"continuing to poll..."),s++;try{const e=yield d.text();console.log("[Link Auth] Response body:",e)}catch(e){console.log("[Link Auth] Could not read response body")}}}catch(e){console.error("[Link Auth] 🔴 Polling error:",e.message||e),s++,console.error("[Link Auth] Error details:",{name:e.name,message:e.message,stack:e.stack,statusUrl:n,attempt:s,error:e}),e.message&&e.message.toLowerCase().includes("failed")&&(console.error("[Link Auth] ⚠️ Possible CORS issue. Status URL:",n),console.error("[Link Auth] Make sure the API endpoint allows CORS from your ngrok domain")),(null==o?void 0:o.onStatusUpdate)&&o.onStatusUpdate({status:"pending",message:`Connection issue, retrying... (${s}/${i})`})}finally{this.isPollingInProgress=!1}});c(),this.pollingInterval=setInterval(c,r)})})}stopPolling(){console.log("[Link Auth] 🏁 Stopping polling"),this.isPollingActive=!1,this.isPollingInProgress=!1,this.pollingInterval&&(clearInterval(this.pollingInterval),this.pollingInterval=void 0)}formatResponse(e){if(!e.authenticated||!e.credential)throw new Error("Authentication not completed");return{credential:e.credential,session:e.session,type:"link"}}isSupported(){return/iPhone|iPad|iPod|Android/i.test(navigator.userAgent)}cleanup(){this.stopPolling(),this.isCancelled=!1,this.onCancel=void 0,this.pollingReject=void 0}isPolling(){return void 0!==this.pollingInterval}cancel(){var e;console.log("[Link Auth] Cancelling authentication"),this.isCancelled=!0,this.stopPolling(),null===(e=this.onCancel)||void 0===e||e.call(this),this.pollingReject&&(this.pollingReject({code:"USER_DENIED",message:"Authentication cancelled by user"}),this.pollingReject=void 0)}}},545:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.MobileDebugConsole=void 0;class n{constructor(){this.logs=[],this.container=null,this.logsContainer=null,this.floatingToggle=null,this.isAtBottom=!0,this.isVisible=!0,this.originalConsole={log:console.log,error:console.error,warn:console.warn,debug:console.debug,info:console.info},this.interceptConsole(),this.createUI()}static init(){return n.instance||(n.instance=new n),n.instance}static destroy(){n.instance&&(n.instance.cleanup(),n.instance=null)}interceptConsole(){["log","error","warn","debug","info"].forEach(e=>{const t=this.originalConsole[e];console[e]=(...n)=>{t.apply(console,n),this.addLog(e,n)}})}addLog(e,t){const n=(new Date).toTimeString().split(" ")[0],o=t.map(e=>{if("object"==typeof e)try{return JSON.stringify(e,null,2)}catch(e){return"[Object]"}return String(e)}).join(" "),r={log:"#fff",error:"#ff6b6b",warn:"#ffd93d",info:"#6bcf7f",debug:"#95a5a6"},i=`\n <div style="margin: 4px 0; font-family: monospace; font-size: 11px; color: ${r[e]||"#fff"};">\n <span style="color: #666;">[${n}]</span>\n <span style="color: ${r[e]}; font-weight: bold; text-transform: uppercase; font-size: 9px;">[${e}]</span>\n <span style="white-space: pre-wrap; word-break: break-all;">${this.escapeHtml(o)}</span>\n </div>\n `;this.logs.push(i),this.logs.length>500&&this.logs.shift(),this.updateDisplay()}updateDisplay(){this.logsContainer&&this.isVisible&&(this.isAtBottom=this.logsContainer.scrollHeight-this.logsContainer.scrollTop<=this.logsContainer.clientHeight+50,this.logsContainer.innerHTML=this.logs.join(""),this.isAtBottom&&(this.logsContainer.scrollTop=this.logsContainer.scrollHeight))}createUI(){const e=document.createElement("style");e.textContent="\n #mobile-debug-console {\n position: fixed;\n bottom: 0;\n left: 0;\n right: 0;\n height: 45vh;\n background: rgba(0, 0, 0, 0.95);\n z-index: 999999;\n display: flex;\n flex-direction: column;\n font-family: monospace;\n transition: transform 0.3s ease;\n }\n \n #mobile-debug-console.hidden {\n transform: translateY(100%);\n }\n \n #debug-header {\n display: flex;\n justify-content: space-between;\n align-items: center;\n padding: 10px;\n background: #1a1a1a;\n border-top: 2px solid #333;\n }\n \n #debug-title {\n color: #0f0;\n font-size: 12px;\n font-weight: bold;\n }\n \n #debug-buttons {\n display: flex;\n gap: 10px;\n }\n \n #debug-buttons button {\n padding: 5px 10px;\n background: #333;\n color: #fff;\n border: 1px solid #555;\n border-radius: 3px;\n font-size: 11px;\n cursor: pointer;\n }\n \n #debug-buttons button:active {\n background: #555;\n }\n \n #debug-logs {\n flex: 1;\n overflow-y: auto;\n padding: 10px;\n -webkit-overflow-scrolling: touch;\n }\n \n #debug-floating-toggle {\n position: fixed;\n bottom: 20px;\n right: 20px;\n width: 50px;\n height: 50px;\n border-radius: 50%;\n background: rgba(0, 0, 0, 0.8);\n border: 2px solid #0f0;\n color: #0f0;\n cursor: pointer;\n z-index: 999998;\n display: none;\n align-items: center;\n justify-content: center;\n font-size: 24px;\n box-shadow: 0 2px 10px rgba(0, 255, 0, 0.3);\n transition: all 0.3s ease;\n }\n \n #debug-floating-toggle:hover {\n background: rgba(0, 0, 0, 0.9);\n transform: scale(1.1);\n box-shadow: 0 4px 15px rgba(0, 255, 0, 0.5);\n }\n \n #debug-floating-toggle.visible {\n display: flex;\n }\n ",document.head.appendChild(e),this.container=document.createElement("div"),this.container.id="mobile-debug-console",this.isVisible||(this.container.className="hidden");const t=document.createElement("div");t.id="debug-header";const n=document.createElement("div");n.id="debug-title",n.textContent="📱 Mobile Debug Console";const o=document.createElement("div");o.id="debug-buttons";const r=document.createElement("button");r.textContent="Clear",r.onclick=()=>this.clear();const i=document.createElement("button");i.textContent="Hide",i.onclick=()=>this.toggle();const s=document.createElement("button");s.textContent="✕",s.style.color="#ff6b6b",s.onclick=()=>this.cleanup(),o.appendChild(r),o.appendChild(i),o.appendChild(s),t.appendChild(n),t.appendChild(o),this.logsContainer=document.createElement("div"),this.logsContainer.id="debug-logs",this.logsContainer.addEventListener("scroll",()=>{this.isAtBottom=this.logsContainer.scrollHeight-this.logsContainer.scrollTop<=this.logsContainer.clientHeight+50}),this.container.appendChild(t),this.container.appendChild(this.logsContainer),document.body.appendChild(this.container),this.floatingToggle=document.createElement("button"),this.floatingToggle.id="debug-floating-toggle",this.floatingToggle.innerHTML="🖥️",this.floatingToggle.title="Show Debug Console",this.floatingToggle.onclick=()=>this.toggle(),document.body.appendChild(this.floatingToggle),window.__debugToggleBtn=i}escapeHtml(e){const t=document.createElement("div");return t.textContent=e,t.innerHTML}toggle(){this.isVisible=!this.isVisible,this.container&&this.floatingToggle&&(this.isVisible?(this.container.classList.remove("hidden"),this.floatingToggle.classList.remove("visible"),window.__debugToggleBtn.textContent="Hide",this.updateDisplay()):(this.container.classList.add("hidden"),this.floatingToggle.classList.add("visible"),window.__debugToggleBtn.textContent="Show"))}clear(){this.logs=[],this.logsContainer&&(this.logsContainer.innerHTML="")}cleanup(){Object.keys(this.originalConsole).forEach(e=>{console[e]=this.originalConsole[e]}),this.container&&this.container.remove(),this.floatingToggle&&this.floatingToggle.remove(),delete window.__debugToggleBtn}}t.MobileDebugConsole=n,n.instance=null},566:(e,t)=>{function n(e){return t.E164_REGEX.test(e)}function o(e){return!!/^\d{3}$/.test(e.mcc)&&!!/^\d{2,3}$/.test(e.mnc)}function r(e){return!(!e.session_key||e.session_key.length<16)}function i(e){return e===t.USE_CASE.GET_PHONE_NUMBER||e===t.USE_CASE.VERIFY_PHONE_NUMBER}function s(e,n,o){return{code:e,message:t.ERROR_MESSAGES[e],request_id:o,timestamp:(new Date).toISOString(),details:n}}function a(e){return t.ERROR_STATUS_CODES[e]||500}function l(e){return e&&"string"==typeof e.protocol&&e.data&&e.data.dcql_query}function c(e){return e&&e.url&&"string"==typeof e.url}function u(e){return e&&"string"==typeof e.code&&"string"==typeof e.message}Object.defineProperty(t,"__esModule",{value:!0}),t.E164_REGEX=t.ERROR_STATUS_CODES=t.ERROR_MESSAGES=t.ERROR_CODE=t.AUTHENTICATION_STRATEGY=t.USE_CASE=void 0,t.validatePhoneNumber=n,t.validatePLMN=o,t.validateSession=r,t.validateUseCase=i,t.createErrorResponse=s,t.getErrorStatusCode=a,t.isTS43Data=l,t.isLinkData=c,t.isErrorResponse=u,t.USE_CASE={GET_PHONE_NUMBER:"GetPhoneNumber",VERIFY_PHONE_NUMBER:"VerifyPhoneNumber"},t.AUTHENTICATION_STRATEGY={TS43:"ts43",LINK:"link",DESKTOP:"desktop"},t.ERROR_CODE={INVALID_PHONE_NUMBER:"INVALID_PHONE_NUMBER",MISSING_REQUIRED_FIELD:"MISSING_REQUIRED_FIELD",INVALID_USE_CASE:"INVALID_USE_CASE",INVALID_SESSION:"INVALID_SESSION",SESSION_EXPIRED:"SESSION_EXPIRED",CARRIER_NOT_ELIGIBLE:"CARRIER_NOT_ELIGIBLE",UNSUPPORTED_PLATFORM:"UNSUPPORTED_PLATFORM",PHONE_NUMBER_MISMATCH:"PHONE_NUMBER_MISMATCH",INVALID_CREDENTIAL:"INVALID_CREDENTIAL",VERIFICATION_FAILED:"VERIFICATION_FAILED",USE_CASE_MISMATCH:"USE_CASE_MISMATCH",RATE_LIMIT_EXCEEDED:"RATE_LIMIT_EXCEEDED",INTERNAL_SERVER_ERROR:"INTERNAL_SERVER_ERROR",SERVICE_UNAVAILABLE:"SERVICE_UNAVAILABLE"},t.ERROR_MESSAGES={[t.ERROR_CODE.INVALID_PHONE_NUMBER]:"Phone number must be in E.164 format",[t.ERROR_CODE.MISSING_REQUIRED_FIELD]:"Required field is missing",[t.ERROR_CODE.INVALID_USE_CASE]:"Use case must be 'GetPhoneNumber' or 'VerifyPhoneNumber'",[t.ERROR_CODE.INVALID_SESSION]:"Session not found or expired",[t.ERROR_CODE.SESSION_EXPIRED]:"Session has expired",[t.ERROR_CODE.CARRIER_NOT_ELIGIBLE]:"Your carrier does not support this verification method",[t.ERROR_CODE.UNSUPPORTED_PLATFORM]:"Your platform is not supported",[t.ERROR_CODE.PHONE_NUMBER_MISMATCH]:"Phone number does not match the device",[t.ERROR_CODE.INVALID_CREDENTIAL]:"Invalid or expired credential",[t.ERROR_CODE.VERIFICATION_FAILED]:"Phone number verification failed",[t.ERROR_CODE.USE_CASE_MISMATCH]:"Session was prepared for a different use case",[t.ERROR_CODE.RATE_LIMIT_EXCEEDED]:"Too many requests. Please try again later",[t.ERROR_CODE.INTERNAL_SERVER_ERROR]:"An unexpected error occurred",[t.ERROR_CODE.SERVICE_UNAVAILABLE]:"Service temporarily unavailable"},t.ERROR_STATUS_CODES={[t.ERROR_CODE.INVALID_PHONE_NUMBER]:400,[t.ERROR_CODE.MISSING_REQUIRED_FIELD]:400,[t.ERROR_CODE.INVALID_USE_CASE]:400,[t.ERROR_CODE.INVALID_SESSION]:404,[t.ERROR_CODE.SESSION_EXPIRED]:404,[t.ERROR_CODE.CARRIER_NOT_ELIGIBLE]:422,[t.ERROR_CODE.UNSUPPORTED_PLATFORM]:422,[t.ERROR_CODE.PHONE_NUMBER_MISMATCH]:422,[t.ERROR_CODE.INVALID_CREDENTIAL]:422,[t.ERROR_CODE.VERIFICATION_FAILED]:422,[t.ERROR_CODE.USE_CASE_MISMATCH]:422,[t.ERROR_CODE.RATE_LIMIT_EXCEEDED]:429,[t.ERROR_CODE.INTERNAL_SERVER_ERROR]:500,[t.ERROR_CODE.SERVICE_UNAVAILABLE]:503},t.E164_REGEX=/^\+[1-9]\d{1,14}$/,t.default={USE_CASE:t.USE_CASE,AUTHENTICATION_STRATEGY:t.AUTHENTICATION_STRATEGY,ERROR_CODE:t.ERROR_CODE,ERROR_MESSAGES:t.ERROR_MESSAGES,ERROR_STATUS_CODES:t.ERROR_STATUS_CODES,E164_REGEX:t.E164_REGEX,validatePhoneNumber:n,validatePLMN:o,validateSession:r,validateUseCase:i,isTS43Data:l,isLinkData:c,isErrorResponse:u,createErrorResponse:s,getErrorStatusCode:a}},724:function(e,t,n){var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))(function(r,i){function s(e){try{l(o.next(e))}catch(e){i(e)}}function a(e){try{l(o.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}l((o=o.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.PhoneAuthManager=void 0;const r=n(514);t.PhoneAuthManager=class{constructor(e={}){this.listeners=[],this.client=new r.PhoneAuthClient(e),this.state={isLoading:!1,error:null,result:null,currentStep:"idle",isSupported:this.client.isSupported()}}getState(){return Object.assign({},this.state)}subscribe(e){return this.listeners.push(e),()=>{const t=this.listeners.indexOf(e);-1!==t&&this.listeners.splice(t,1)}}updateState(e){this.state=Object.assign(Object.assign({},this.state),e),this.listeners.forEach(e=>e(this.getState()))}verify(e){return o(this,void 0,void 0,function*(){this.updateState({isLoading:!0,error:null,result:null,currentStep:"requesting"});try{const t=yield this.client.preparePhoneRequest(e);this.updateState({currentStep:"authenticating"});const n=yield this.client.invokeSecurePrompt(t);this.updateState({currentStep:"processing"});const o=n,r="GetPhoneNumber"===e.use_case?yield this.client.getPhoneNumber(o,t.session):yield this.client.verifyPhoneNumber(o,t.session);return this.updateState({result:r,currentStep:"complete",isLoading:!1}),r}catch(t){const n=t,o=Object.assign(Object.assign({},n),{context:n.context||{useCase:e.use_case,timestamp:(new Date).toISOString(),userAgent:"undefined"!=typeof navigator?navigator.userAgent:void 0,url:"undefined"!=typeof window?window.location.href:void 0}});throw this.updateState({error:o,currentStep:"idle",isLoading:!1}),o}})}getPhoneNumber(e){return o(this,void 0,void 0,function*(){return this.verify(Object.assign({use_case:"GetPhoneNumber"},e))})}verifyPhoneNumber(e,t){return o(this,void 0,void 0,function*(){return this.verify(Object.assign({use_case:"VerifyPhoneNumber",phone_number:e},t))})}reset(){this.updateState({isLoading:!1,error:null,result:null,currentStep:"idle"})}isSupported(){return this.state.isSupported}}},802:function(e,t){var n=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))(function(r,i){function s(e){try{l(o.next(e))}catch(e){i(e)}}function a(e){try{l(o.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}l((o=o.apply(e,t||[])).next())})};function o(e,t){const n=(null==t?void 0:t.container)||document.createElement("div");let o;if(n.className="phone-auth-qr-container","string"==typeof e)o=e;else{if(!e||"object"!=typeof e)throw new Error("Invalid qrCodeData: must be string or QRCodeData object");if(e.iosQRCode)o=e.iosQRCode;else{if(!e.androidQRCode)throw new Error("Invalid QRCodeData: missing QR code images");o=e.androidQRCode}}const r=document.createElement("img");if(r.src=o,r.alt="QR Code for authentication",r.style.width=`${(null==t?void 0:t.size)||256}px`,r.style.height=`${(null==t?void 0:t.size)||256}px`,r.style.display="block",r.style.margin="0 auto",null==t?void 0:t.title){const e=document.createElement("h3");e.textContent=t.title,e.style.textAlign="center",e.style.marginBottom="1rem",n.appendChild(e)}if(n.appendChild(r),null==t?void 0:t.description){const e=document.createElement("p");e.textContent=t.description,e.style.textAlign="center",e.style.marginTop="1rem",e.style.color="#666",n.appendChild(e)}return n}Object.defineProperty(t,"__esModule",{value:!0}),t.DesktopHandler=void 0,t.createQRCodeDisplay=o,t.showQRCodeModal=function(e,t){const n=document.createElement("div");n.style.cssText="\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n background-color: rgba(0, 0, 0, 0.5);\n display: flex;\n align-items: center;\n justify-content: center;\n z-index: 9999;\n ";const r=document.createElement("div");r.style.cssText="\n background: white;\n padding: 2rem;\n border-radius: 8px;\n max-width: 400px;\n position: relative;\n ";const i=document.createElement("button");i.textContent="×",i.style.cssText="\n position: absolute;\n top: 10px;\n right: 10px;\n background: none;\n border: none;\n font-size: 24px;\n cursor: pointer;\n color: #999;\n ",i.onclick=()=>{document.body.removeChild(n),(null==t?void 0:t.onClose)&&t.onClose()},r.appendChild(i);const s=o(e,{title:(null==t?void 0:t.title)||"Scan QR Code to Authenticate",description:(null==t?void 0:t.description)||"Use your mobile device to scan this QR code"});r.appendChild(s);const a=document.createElement("div");a.id="desktop-auth-status",a.style.cssText="\n text-align: center;\n margin-top: 1rem;\n color: #666;\n font-size: 14px;\n ",r.appendChild(a),n.appendChild(r),document.body.appendChild(n),n.onclick=e=>{e.target===n&&(document.body.removeChild(n),(null==t?void 0:t.onClose)&&t.onClose())}},t.DesktopHandler=class{constructor(){this.pollingAttempts=0,this.isCancelled=!1,this.isPollingInProgress=!1}mapBackendStatus(e,t){switch(e){case 200:return"completed"===t?"authenticated":"pending";case 410:return"expired";default:return"error"}}invoke(e,t){return n(this,void 0,void 0,function*(){const n=e.data;let o,r,i,s,a;if(n&&n.data&&"object"==typeof n.data){const e=n.data;o=e.ios_qr_image&&e.android_qr_image?{iosQRCode:e.ios_qr_image,androidQRCode:e.android_qr_image,iosUrl:e.ios_url,androidUrl:e.android_url}:e.ios_qr_image||e.android_qr_image?e.ios_qr_image||e.android_qr_image:e.qr_code_image||e.qr_code,r=e.session_id,i=e.status_url,s=e.polling_interval,a=e.expires_in}if(!o&&n&&(o=n.qr_code_image||n.qr_code,r=r||n.session_id,i=i||n.status_url||n.polling_endpoint,s=s||n.polling_interval,a=a||n.expires_in),!o)throw new Error("Invalid desktop authentication data: missing QR code");if(!r)throw new Error("Invalid desktop authentication data: missing session ID");(null==t?void 0:t.onQRCodeReady)&&t.onQRCodeReady(o),console.log("[Desktop QR] Polling endpoint selection:"),console.log(" - options?.pollingEndpoint:",null==t?void 0:t.pollingEndpoint),console.log(" - backend pollingEndpoint:",i);let l=null==t?void 0:t.pollingEndpoint,c="options";l||(l=i,c="backend"),l||(console.log("[Desktop QR] No polling endpoint provided, will use hardcoded fallback"),c="fallback"),console.log("[Desktop QR] Selected endpoint:",l,"from source:",c);const u=(null==t?void 0:t.pollingInterval)||s||2e3,d=(null==t?void 0:t.maxPollingAttempts)||30;return console.log(`[Desktop QR] Starting polling - endpoint source: ${c}, interval: ${u}ms, max attempts: ${d}`),this.startPolling(l||"",r,u,d,a||300,t,c)})}startPolling(e,t,o,r,i,s){return n(this,arguments,void 0,function*(e,t,o,r,i,s,a="unknown"){const l=Date.now()+1e3*i;return new Promise((i,c)=>{this.pollingReject=c;const u=()=>n(this,void 0,void 0,function*(){if(!this.isPollingInProgress)try{if(this.isPollingInProgress=!0,this.isCancelled)return this.stopPolling(),(null==s?void 0:s.onCancel)&&s.onCancel(),(null==s?void 0:s.onStatusUpdate)&&s.onStatusUpdate({status:"cancelled",message:"Authentication cancelled"}),void c({code:"USER_DENIED",message:"Authentication cancelled by user"});if(Date.now()>l)return this.stopPolling(),(null==s?void 0:s.onExpired)&&s.onExpired(),(null==s?void 0:s.onStatusUpdate)&&s.onStatusUpdate({status:"expired",message:"QR code has expired"}),void i({authenticated:!1,error:"Authentication expired"});if(this.pollingAttempts>=r)return this.stopPolling(),(null==s?void 0:s.onTimeout)&&s.onTimeout(),(null==s?void 0:s.onStatusUpdate)&&s.onStatusUpdate({status:"error",message:"Polling timeout reached"}),void i({authenticated:!1,error:"Polling timeout"});let n;if(e&&(e.startsWith("http://")||e.startsWith("https://"))){const o=new URL(e);n=`${o.protocol}//${o.host}/public/public/status/${t}`}else n=e&&""!==e?`${e}/${t}`:`/api/phone-auth/status/${t}`;console.log(`[Desktop QR] Polling status (attempt ${this.pollingAttempts}/${r})`),console.log(`[Desktop QR] Using ${a} endpoint: ${n}`);const o=yield fetch(n,{method:"GET",headers:{Accept:"application/json"}});if(console.log(`[Desktop QR] Status response: ${o.status} ${o.statusText}`),200===o.status){const e=yield o.json();if("completed"===e.status){this.stopPolling();const n=document.querySelector('[style*="position: fixed"]');n&&n.querySelector("#desktop-auth-status")&&setTimeout(()=>{n.remove()},500),(null==s?void 0:s.onStatusUpdate)&&s.onStatusUpdate({status:"authenticated",message:"Authentication successful",data:e}),this.pollingReject=void 0,i({authenticated:!0,credential:e.credential||e.session_key||t,session:e.session||{session_key:e.session_key||t,status:e.status,protocol:e.protocol,created_at:e.created_at,last_updated:e.last_updated}})}else"pending"===e.status&&(this.pollingAttempts++,(null==s?void 0:s.onStatusUpdate)&&s.onStatusUpdate({status:"pending",message:`Waiting for authentication (attempt ${this.pollingAttempts}/${r})`}))}else if(410===o.status){this.stopPolling();const e=yield o.json().catch(()=>({message:"Session expired"})),t=document.querySelector('[style*="position: fixed"]');t&&t.querySelector("#desktop-auth-status")&&setTimeout(()=>{t.remove()},500),(null==s?void 0:s.onExpired)&&s.onExpired(),(null==s?void 0:s.onStatusUpdate)&&s.onStatusUpdate({status:"expired",message:e.message||"Session has expired"}),i({authenticated:!1,error:e.message||"Session expired"})}else if(422===o.status){this.stopPolling();const e=yield o.json().catch(()=>({message:"Authentication failed"})),t=document.querySelector('[style*="position: fixed"]');t&&t.querySelector("#desktop-auth-status")&&setTimeout(()=>{t.remove()},500);const n="USER_CANCELLED"===e.code;(null==s?void 0:s.onStatusUpdate)&&s.onStatusUpdate({status:"error",message:e.message||"Authentication failed"}),i({authenticated:!1,error:n?"User cancelled authentication":e.message||"Authentication failed"})}else if(404===o.status)this.stopPolling(),(null==s?void 0:s.onStatusUpdate)&&s.onStatusUpdate({status:"error",message:"Session not found"}),i({authenticated:!1,error:"Session not found"});else if(400===o.status){this.stopPolling();const e=yield o.json().catch(()=>({message:"Invalid session key"}));i({authenticated:!1,error:e.message||"Invalid session key"})}else this.pollingAttempts++}catch(e){this.pollingAttempts++,(null==s?void 0:s.onStatusUpdate)&&s.onStatusUpdate({status:"pending",message:`Network error, retrying... (attempt ${this.pollingAttempts}/${r})`})}finally{this.isPollingInProgress=!1}});u(),this.pollingIntervalId=setInterval(u,o)})})}stopPolling(){this.pollingIntervalId&&(console.log("[Desktop QR] Stopping polling"),clearInterval(this.pollingIntervalId),this.pollingIntervalId=void 0),this.pollingAttempts=0,this.isPollingInProgress=!1}isPolling(){return void 0!==this.pollingIntervalId}formatResponse(e){if(!e.authenticated||!e.credential)throw new Error("Authentication not completed");return{credential:e.credential,session:e.session}}isSupported(){return"undefined"!=typeof window&&"undefined"!=typeof fetch&&"undefined"!=typeof Promise}cleanup(){this.stopPolling(),this.isCancelled=!1,this.onCancel=void 0,this.pollingReject=void 0}cancel(){var e;console.log("[Desktop QR] Cancelling authentication"),this.isCancelled=!0,this.stopPolling(),null===(e=this.onCancel)||void 0===e||e.call(this),this.pollingReject&&(this.pollingReject({code:"USER_DENIED",message:"Authentication cancelled by user"}),this.pollingReject=void 0)}}},895:function(e,t,n){var o,r=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,r)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||(o=function(e){return o=Object.getOwnPropertyNames||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[t.length]=n);return t},o(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n=o(e),s=0;s<n.length;s++)"default"!==n[s]&&r(t,e,n[s]);return i(t,e),t}),a=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))(function(r,i){function s(e){try{l(o.next(e))}catch(e){i(e)}}function a(e){try{l(o.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}l((o=o.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.PhoneAuthClient=void 0;const l=s(n(566)),c=n(931),u=n(192),d=n(495),h=n(928),p=n(802),g=n(544),E=n(244);t.PhoneAuthClient=class{constructor(e={}){var t,o,r,i;this.crossDeviceActive=!1,this.retryCount=0,this.sessionCache=new Map,this.baseTimeout=e.timeout||3e4,this.config={endpoints:{prepare:(null===(t=e.endpoints)||void 0===t?void 0:t.prepare)||"/api/magic-auth/prepare",process:(null===(o=e.endpoints)||void 0===o?void 0:o.process)||"/api/magic-auth/process",polling:null===(r=e.endpoints)||void 0===r?void 0:r.polling},timeout:e.timeout||3e4,pollingInterval:e.pollingInterval||2e3,maxPollingAttempts:e.maxPollingAttempts||30,debug:e.debug||!1,aggregatorId:e.aggregatorId||"default",devtools:e.devtools},this.debug=this.config.debug,this.callbacks={onCrossDeviceDetected:e.onCrossDeviceDetected,onRetryAttempt:e.onRetryAttempt},this.logger=h.LoggerFactory.create({level:e.logLevel,prefix:"[PhoneAuth]",remote:e.remoteLogging,custom:e.logger}),(null===(i=e.devtools)||void 0===i?void 0:i.showMobileConsole)&&"undefined"!=typeof window&&Promise.resolve().then(()=>s(n(545))).then(({MobileDebugConsole:e})=>{e.init(),console.log("[PhoneAuth] Mobile debug console enabled")}).catch(e=>{console.error("[PhoneAuth] Failed to load mobile debug console:",e)}),this.setupCacheCleanup()}getUserFriendlyMessage(e){return"string"==typeof e?(0,u.getUserMessage)({code:e}):(0,u.getUserMessage)(e)}logError(e,t){const n=(0,u.createErrorBreadcrumb)(e),o=(0,u.serializeError)(e);!this.debug&&(0,u.isUserError)(e)||console.error("[PhoneAuth] Error:",Object.assign(Object.assign({},o),{breadcrumb:n,context:t})),e.traceId&&console.debug("[PhoneAuth] Trace Context:",{traceId:e.traceId,spanId:e.spanId,requestId:e.requestId})}isSupported(){return"undefined"!=typeof window&&"DigitalCredential"in window}getBrowserSupportInfo(){if("undefined"==typeof window)return{supported:!1,browser:"unknown",message:"Not running in a browser environment"};const e=navigator.userAgent,t=/Chrome/.test(e)&&/Google Inc/.test(navigator.vendor),n=/Edg\//.test(e);return this.isSupported()?{supported:!0,browser:t?c.BrowserName.CHROME:n?c.BrowserName.EDGE:c.BrowserName.OTHER}:t||n?{supported:!1,browser:t?c.BrowserName.CHROME:c.BrowserName.EDGE,message:"Digital Credentials API is not enabled. Please enable the #web-identity-digital-credentials flag.",helpUrl:t?"chrome://flags/#web-identity-digital-credentials":"edge://flags/#web-identity-digital-credentials"}:{supported:!1,browser:"other",message:"Your browser doesn't support the Digital Credentials API. Please use Chrome or Edge with the #web-identity-digital-credentials flag enabled."}}verify(e){return a(this,void 0,void 0,function*(){return this.retryCount=0,this.lastRequest=e,this.verifyWithRetry(e,2)})}verifyWithRetry(e,t){return a(this,void 0,void 0,function*(){var n,o;try{const t=yield this.preparePhoneRequest(e),n=yield this.invokeSecurePrompt(t);if(n&&"object"==typeof n&&"strategy"in n)throw this.createError(u.PhoneAuthErrorCode.INVALID_RESPONSE,"Headless mode is not supported in authenticatePhoneNumber. Use preparePhoneRequest and invokeSecurePrompt directly for headless mode.");const o=n;if(!e.use_case)throw this.createError(u.PhoneAuthErrorCode.MISSING_PARAMETERS,"use_case is required",{field:"use_case"});const r=e.use_case===l.USE_CASE.GET_PHONE_NUMBER?yield this.getPhoneNumber(o,t.session):yield this.verifyPhoneNumber(o,t.session);return this.cacheSession(e,r),r}catch(r){const i=(0,u.isPhoneAuthError)(r)?r:(0,u.parseBackendError)(r);if(this.shouldRetry(i)&&this.retryCount<t){this.retryCount++,null===(o=(n=this.callbacks).onRetryAttempt)||void 0===o||o.call(n,this.retryCount,t),this.debug&&console.log(`[PhoneAuth] Retrying verification (attempt ${this.retryCount+1}/${t+1})`),yield this.delay(Math.min(1e3*Math.pow(2,this.retryCount-1),5e3));const r=this.getCachedSession(e);return r?(this.debug&&console.log("[PhoneAuth] Using cached session result"),r):this.verifyWithRetry(e,t)}if(i.context={step:"complete",useCase:e.use_case,timestamp:(new Date).toISOString(),userAgent:navigator.userAgent,attemptNumber:this.retryCount+1,maxAttempts:t+1},this.logError(i,{options:e}),(0,u.isPhoneAuthError)(r)){if(r.context)throw r;throw{code:i.code,message:r.message,details:r.details,status:r.status,requestId:r.requestId,timestamp:r.timestamp,retryAfter:r.retryAfter,browserError:r.browserError,context:{useCase:e.use_case,timestamp:(new Date).toISOString(),userAgent:"undefined"!=typeof navigator?navigator.userAgent:void 0,url:"undefined"!=typeof window?window.location.href:void 0,attemptNumber:this.retryCount+1,maxAttempts:t+1}}}throw this.createError(u.PhoneAuthErrorCode.VERIFICATION_FAILED,"Verification failed",r)}})}getPhoneNumberComplete(e){return a(this,void 0,void 0,function*(){return this.verify(Object.assign({use_case:l.USE_CASE.GET_PHONE_NUMBER},e))})}verifyPhoneNumberComplete(e,t){return a(this,void 0,void 0,function*(){return this.verify(Object.assign({use_case:l.USE_CASE.VERIFY_PHONE_NUMBER,phone_number:e},t))})}preparePhoneRequest(e){return a(this,void 0,void 0,function*(){var t,n,o;if(e.phone_number){const t=(0,d.validatePhoneNumber)(e.phone_number);if(!t.valid)throw this.createError(u.PhoneAuthErrorCode.INVALID_PHONE_NUMBER,t.error,{field:"phone_number"})}if(e.plmn){const t=(0,d.validatePlmn)(e.plmn);if(!t.valid)throw this.createError(u.PhoneAuthErrorCode.BAD_REQUEST,t.error,{field:"plmn"})}if(e.consent_data){const t=(0,d.validateConsentData)(e.consent_data);if(!t.valid)throw this.createError(u.PhoneAuthErrorCode.BAD_REQUEST,t.error,{field:"consent_data"})}if(!e.use_case&&(!(null===(t=e.options)||void 0===t?void 0:t.parent_session_id)||e.phone_number||e.plmn))throw this.createError(u.PhoneAuthErrorCode.MISSING_PARAMETERS,"use_case is required",{field:"use_case"});if(!e.phone_number&&!e.plmn&&!(null===(n=e.options)||void 0===n?void 0:n.parent_session_id))throw e.use_case===l.USE_CASE.GET_PHONE_NUMBER?this.createError(u.PhoneAuthErrorCode.MISSING_PARAMETERS,"PLMN (MCC/MNC) is required for GetPhoneNumber. Please provide carrier network information.",{field:"plmn",useCase:"GetPhoneNumber"}):e.use_case===l.USE_CASE.VERIFY_PHONE_NUMBER?this.createError(u.PhoneAuthErrorCode.MISSING_PARAMETERS,"Phone number is required for VerifyPhoneNumber",{field:"phoneNumber",useCase:"VerifyPhoneNumber"}):this.createError(u.PhoneAuthErrorCode.MISSING_PARAMETERS,"Either phone number or PLMN (MCC/MNC) must be provided",{field:"phoneNumber,plmn"});!(null===(o=e.options)||void 0===o?void 0:o.parent_session_id)||e.phone_number||e.plmn||this.debug&&console.log("[PhoneAuth] Using parent_session_id: %s, use_case: %s",e.options.parent_session_id,e.use_case||"not provided");const r=`web-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,i=btoa(String.fromCharCode(...crypto.getRandomValues(new Uint8Array(32)))).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"");if(!(0,d.validateNonce)(i).valid)throw this.createError(u.PhoneAuthErrorCode.INTERNAL_SERVER_ERROR,"Failed to generate valid nonce",{field:"nonce"});const s={use_case:e.use_case,phone_number:e.phone_number,plmn:e.plmn?{mcc:e.plmn.mcc,mnc:e.plmn.mnc}:void 0,nonce:i,id:r,consent_data:e.consent_data,client_info:{user_agent:navigator.userAgent,platform:navigator.platform},options:e.options};this.log("Preparing phone verification request",s);try{const t=yield this.fetchWithTimeout(this.config.endpoints.prepare,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!t.ok){let n=null;try{n=yield t.json(),n=Object.assign(Object.assign({},n),{status:t.status})}catch(e){n={status:t.status,statusText:t.statusText}}const o=(0,u.parseBackendError)(n);throw o.context={step:"prepare",useCase:e.use_case,timestamp:(new Date).toISOString(),userAgent:"undefined"!=typeof navigator?navigator.userAgent:void 0,url:"undefined"!=typeof window?window.location.href:void 0},o.details=Object.assign(Object.assign({},o.details),{endpoint:"prepare",status:t.status}),o}const n=yield t.json();if(this.log("Phone verification request prepared",n),!n.authentication_strategy||!n.data||!n.session)throw this.createError(u.PhoneAuthErrorCode.INVALID_RESPONSE,"Invalid response format from backend");return n}catch(t){if(this.isAuthError(t))throw t;throw this.createError(u.PhoneAuthErrorCode.NETWORK_ERROR,"Failed to prepare verification request",{originalError:t,context:{step:"prepare",useCase:e.use_case,timestamp:(new Date).toISOString(),userAgent:"undefined"!=typeof navigator?navigator.userAgent:void 0,url:"undefined"!=typeof window?window.location.href:void 0}})}})}invokeSecurePrompt(e,t){return a(this,void 0,void 0,function*(){var n,o,r,i,s,d,h,f,m,R,b,_,v,A,y;let O;try{O="undefined"!=typeof structuredClone?structuredClone(e):JSON.parse(JSON.stringify(e))}catch(t){this.debug&&console.log("[PhoneAuth] structuredClone failed, using JSON fallback:",t),O=JSON.parse(JSON.stringify(e))}console.log("[PhoneAuth] === invokeSecurePrompt called ==="),console.log("[PhoneAuth] Session cache size:",this.sessionCache.size),console.log("[PhoneAuth] Retry count:",this.retryCount),console.log("[PhoneAuth] PrepareResponse received:",JSON.stringify(O,null,2));const S=t,I=(O.authentication_strategy,null!==(n=null==S?void 0:S.preventDefaultUI)&&void 0!==n&&n),C=null!==(o=null==S?void 0:S.executionMode)&&void 0!==o?o:"standard";if(O.authentication_strategy===l.AUTHENTICATION_STRATEGY.TS43){if(!this.isSupported())throw this.createError(u.PhoneAuthErrorCode.BROWSER_NOT_SUPPORTED,"Your browser does not support the Digital Credentials API required for TS43 authentication");const e=O.data,t={digital:{requests:[{protocol:e.protocol,data:e.data}]}};this.log("Invoking TS43 secure authentication prompt",t);const n=()=>a(this,void 0,void 0,function*(){var e,n;try{const e=t,n=yield navigator.credentials.get(e);if(!n||!("data"in n)||!n.data){const e=this.getBrowserSupportInfo();if(e.browser===c.BrowserName.CHROME||e.browser===c.BrowserName.EDGE)throw new Error(`Digital Credentials API returned no response. This usually means the browser feature flag is not enabled. Please ensure the ${e.helpUrl||"#web-identity-digital-credentials flag"} is set to "Enabled" (not "Default" or "Disabled") and restart your browser.`);throw new Error("Digital Credentials API returned no response. Your browser may not fully support this feature.")}const o=n.data;return this.log("Secure credential response received",o),o.vp_token}catch(t){const o=t,r={name:o.name||"UnknownError",message:o.message||"Unknown error occurred",stack:o.stack,code:o.code},i={step:"prompt",timestamp:(new Date).toISOString(),userAgent:navigator.userAgent,url:window.location.href,authentication_strategy:O.authentication_strategy,hasSession:!!O.session};if(o.name===c.BrowserError.NOT_ALLOWED)throw this.createError(u.PhoneAuthErrorCode.USER_DENIED,"User denied the credential request or the request timed out",{originalError:t,browserError:r,context:i});if(o.name===c.BrowserError.NETWORK&&o.code===c.BrowserErrorCode.USER_CANCELLED_DC_API)throw this.createError(u.PhoneAuthErrorCode.USER_DENIED,"Authentication cancelled by user",{originalError:t,browserError:r,context:i});if(o.name===c.BrowserError.NETWORK)throw this.createError(u.PhoneAuthErrorCode.NETWORK_ERROR,"Network error occurred while retrieving credentials",{originalError:t,browserError:r,context:i});if(o.name===c.BrowserError.NOT_SUPPORTED)throw this.createError(u.PhoneAuthErrorCode.BROWSER_NOT_SUPPORTED,"Your browser does not support the Digital Credentials API",{originalError:t,browserError:r,context:i});if(o.name===c.BrowserError.SECURITY)throw this.createError(u.PhoneAuthErrorCode.FORBIDDEN,"Security error: This feature requires a secure context (HTTPS)",{originalError:t,browserError:r,context:i});if(o.name===c.BrowserError.ABORT||(null===(e=r.message)||void 0===e?void 0:e.includes("The operation was aborted"))||(null===(n=r.message)||void 0===n?void 0:n.includes("User cancelled")))throw this.createError(u.PhoneAuthErrorCode.USER_DENIED,"Authentication cancelled",{originalError:t,browserError:r,context:i});throw this.createError(u.PhoneAuthErrorCode.INTERNAL_SERVER_ERROR,`Digital Credentials API error: ${o.message||"Unknown error"}`,{originalError:t,browserError:r,context:i})}}),o=()=>a(this,void 0,void 0,function*(){var e,t;try{const t=yield n();return null===(e=null==S?void 0:S.onTriggerAttempt)||void 0===e||e.call(S,{strategy:l.AUTHENTICATION_STRATEGY.TS43,success:!0}),t}catch(e){throw null===(t=null==S?void 0:S.onTriggerAttempt)||void 0===t||t.call(S,{strategy:l.AUTHENTICATION_STRATEGY.TS43,success:!1,error:e}),e}}),r={promise:null};try{const e=yield o();r.promise=Promise.resolve({credential:"string"==typeof e?e:Object.values(e)[0],session:O.session,authenticated:!0})}catch(e){r.promise=Promise.reject(e)}if("extended"===C){const e={strategy:"ts43",session:O.session,credential:r.promise,trigger:()=>a(this,void 0,void 0,function*(){const e=yield o();r.promise=Promise.resolve({credential:"string"==typeof e?e:Object.values(e)[0],session:O.session,authenticated:!0})}),cancel:()=>{r.promise=Promise.reject(this.createError(u.PhoneAuthErrorCode.USER_DENIED,"Authentication cancelled"))}};return Object.defineProperty(e,"credential",{get:()=>r.promise,enumerable:!0,configurable:!0}),e}{const e=yield r.promise;return{[O.session.session_key]:e.credential}}}if(O.authentication_strategy!==l.AUTHENTICATION_STRATEGY.DESKTOP){if(O.authentication_strategy===l.AUTHENTICATION_STRATEGY.LINK){const e=O.data,t=new g.LinkHandler,n=()=>{var t,n;try{window.open(e.url,"_blank"),null===(t=null==S?void 0:S.onTriggerAttempt)||void 0===t||t.call(S,{strategy:l.AUTHENTICATION_STRATEGY.LINK,url:e.url,success:!0})}catch(t){null===(n=null==S?void 0:S.onTriggerAttempt)||void 0===n||n.call(S,{strategy:l.AUTHENTICATION_STRATEGY.LINK,url:e.url,success:!1,error:t})}};!1!==(null==S?void 0:S.autoTrigger)&&n(),console.log("[PhoneAuth Client] Link polling config:",{fromOptions:null==S?void 0:S.pollingEndpoint,fromClientConfig:null===(v=this.config.endpoints)||void 0===v?void 0:v.polling,finalPollingEndpoint:(null==S?void 0:S.pollingEndpoint)||(null===(A=this.config.endpoints)||void 0===A?void 0:A.polling)});const o={pollingEndpoint:(null==S?void 0:S.pollingEndpoint)||(null===(y=this.config.endpoints)||void 0===y?void 0:y.polling),pollingInterval:(null==S?void 0:S.pollingInterval)||this.config.pollingInterval||2e3,maxPollingAttempts:(null==S?void 0:S.maxPollingAttempts)||this.config.maxPollingAttempts||30,onLinkOpened:void 0,onStatusUpdate:void 0};if(console.log("[PhoneAuth Client] Final Link polling options:",o),"extended"===C){let r=!1,i=null;i=t.invoke(O,o),r=!0;const s=i.then(e=>{if(e.authenticated&&e.credential)return{credential:e.credential,session:O.session,authenticated:!0};throw this.createError(u.PhoneAuthErrorCode.USER_DENIED,e.error||"Link authentication failed")}),l=()=>a(this,void 0,void 0,function*(){if(!r){r=!0,i||(i=t.invoke(O,o));const e=yield i;if(e.authenticated&&e.credential)return{credential:e.credential,session:O.session,authenticated:!0};throw this.createError(u.PhoneAuthErrorCode.USER_DENIED,e.error||"Link authentication failed")}const e=yield i;if(e.authenticated&&e.credential)return{credential:e.credential,session:O.session,authenticated:!0};throw this.createError(u.PhoneAuthErrorCode.USER_DENIED,e.error||"Link authentication failed")}),c={strategy:"link",session:O.session,credential:s,data:{app_url:e.url},trigger:n,start_polling:l,stop_polling:()=>t.cleanup(),cancel:()=>{t.cancel(),t.cleanup()},is_polling:!1};return Object.defineProperty(c,"is_polling",{get:()=>t.isPolling(),enumerable:!0,configurable:!0}),c}{const e=t.invoke(O,o).then(e=>{if(e.authenticated&&e.credential)return{credential:e.credential,session:O.session,authenticated:!0};throw this.createError(u.PhoneAuthErrorCode.USER_DENIED,e.error||"Link authentication failed")}),n=yield e,r=this.config.aggregatorId||"default";return{[r]:n.credential}}}throw this.createError(u.PhoneAuthErrorCode.UNSUPPORTED_STRATEGY,`Unknown authentication strategy: ${O.authentication_strategy}`)}{const e=O.data,t=new p.DesktopHandler,n={iosQRCode:(null===(r=e.data)||void 0===r?void 0:r.ios_qr_image)||e.ios_qr_image||(null===(i=e.data)||void 0===i?void 0:i.qr_code_image)||e.qr_code_image||e.qr_code||"",androidQRCode:(null===(s=e.data)||void 0===s?void 0:s.android_qr_image)||e.android_qr_image,iosUrl:(null===(d=e.data)||void 0===d?void 0:d.ios_url)||e.ios_url,androidUrl:(null===(h=e.data)||void 0===h?void 0:h.android_url)||e.android_url},o={ios_qr_image:(null===(f=e.data)||void 0===f?void 0:f.ios_qr_image)||e.ios_qr_image,android_qr_image:(null===(m=e.data)||void 0===m?void 0:m.android_qr_image)||e.android_qr_image,qr_code:(null===(R=e.data)||void 0===R?void 0:R.qr_code_image)||e.qr_code_image||e.qr_code,challenge:null===(b=e.data)||void 0===b?void 0:b.challenge},l=(null==S?void 0:S.pollingEndpoint)||(null===(_=this.config.endpoints)||void 0===_?void 0:_.polling),c=Object.assign(Object.assign({},S),{pollingEndpoint:l,pollingInterval:(null==S?void 0:S.pollingInterval)||this.config.pollingInterval||2e3,maxPollingAttempts:(null==S?void 0:S.maxPollingAttempts)||this.config.maxPollingAttempts||30,onQRCodeReady:void 0,onStatusUpdate:void 0}),g=!I;let v,A;console.log("[Desktop] Modal decision:",{preventDefaultUI:I,showModal:g,executionMode:C,hasOptions:!!S}),g?(console.log("[Desktop] Creating modal with QR data:",n),v=new E.AuthModal(null==S?void 0:S.modalOptions,null==S?void 0:S.callbacks),v.setCloseCallback(()=>{this.log("Desktop QR modal closed by user, cancelling polling"),t.cancel()}),c.onQRCodeReady=e=>{console.log("[Desktop] onQRCodeReady callback triggered:",e),v.showQRCode(e,"Scan with your mobile device")},c.onStatusUpdate=e=>{"pending"===e.status?v.updateStatus("Waiting for authentication..."):"authenticated"===e.status?(v.updateStatus("Authentication successful!"),setTimeout(()=>v.close(),1500)):"expired"===e.status?v.updateStatus("QR code expired",!0):"error"===e.status&&v.updateStatus("Authentication failed",!0)},A=v):console.log("[Desktop] Modal not shown - preventDefaultUI is true");const y=()=>t.invoke(O,c).then(e=>{if(e.authenticated&&e.credential)return{credential:e.credential,session:O.session,authenticated:!0};throw this.createError(u.PhoneAuthErrorCode.USER_DENIED,e.error||"Desktop authentication failed")});if("extended"===C){const e=new Promise((e,t)=>{y().then(e).catch(t)}),n=()=>a(this,void 0,void 0,function*(){return e}),r=()=>{t.cleanup(),v&&v.close()},i=()=>{t.cancel(),t.cleanup(),v&&v.close()},s={strategy:"desktop",session:O.session,credential:e,qr_code_data:o,modal_ref:A,start_polling:n,stop_polling:r,cancel:i,is_polling:!1};return Object.defineProperty(s,"is_polling",{get:()=>t.isPolling(),enumerable:!0,configurable:!0}),s}try{const t=yield y();let n="default";return e&&"object"==typeof e&&(e.data&&"object"==typeof e.data&&(n=e.data.session_id||n),n&&"default"!==n||(n=e.session_id||n)),{[n]:t.credential}}finally{t.cleanup(),v&&v.close()}}})}getPhoneNumber(e,t){return a(this,void 0,void 0,function*(){const n=this.extractCredentialString(e),o={session:t,credential:n,use_case:l.USE_CASE.GET_PHONE_NUMBER};this.config.debug?this.log("Getting phone number from credential",{session:t,credential:n?n.substring(0,50)+"...":"undefined",endpoint:this.config.endpoints.process||"/api/phone-auth/process"}):this.log("Getting phone number from credential");try{const e=yield this.fetchWithTimeout(this.config.endpoints.process||"/api/phone-auth/process",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)});if(!e.ok){const t=yield this.extractErrorDetails(e),n=(0,u.parseBackendError)(t);throw n.context={step:"process",timestamp:(new Date).toISOString(),userAgent:"undefined"!=typeof navigator?navigator.userAgent:void 0,url:"undefined"!=typeof window?window.location.href:void 0},n}const t=yield e.json();if(this.log("Phone number retrieved",{phone_number:t.phone_number}),!t.phone_number)throw this.createError(u.PhoneAuthErrorCode.VERIFICATION_FAILED,"No phone number returned from server");return t}catch(e){if(this.isAuthError(e))throw e;throw this.createError(u.PhoneAuthErrorCode.NETWORK_ERROR,"Failed to get phone number",{originalError:e,context:{step:"process",timestamp:(new Date).toISOString()}})}})}verifyPhoneNumber(e,t){return a(this,void 0,void 0,function*(){const n=this.extractCredentialString(e),o={session:t,credential:n,use_case:l.USE_CASE.VERIFY_PHONE_NUMBER};this.config.debug?this.log("Verifying phone number with credential",{session:t,credential:n?n.substring(0,50)+"...":"undefined",endpoint:this.config.endpoints.process||"/api/phone-auth/process"}):this.log("Verifying phone number");try{const e=yield this.fetchWithTimeout(this.config.endpoints.process||"/api/phone-auth/process",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)});if(!e.ok){const t=yield this.extractErrorDetails(e),n=(0,u.parseBackendError)(t);throw n.context={step:"process",timestamp:(new Date).toISOString(),userAgent:"undefined"!=typeof navigator?navigator.userAgent:void 0,url:"undefined"!=typeof window?window.location.href:void 0},n}const t=yield e.json();if(this.log("Phone number verification result",{phone_number:t.phone_number,verified:t.verified}),!t.phone_number)throw this.createError(u.PhoneAuthErrorCode.VERIFICATION_FAILED,"No phone number returned from server");return t}catch(e){if(this.isAuthError(e))throw e;throw this.createError(u.PhoneAuthErrorCode.NETWORK_ERROR,"Failed to verify phone number",{originalError:e,context:{step:"process",timestamp:(new Date).toISOString()}})}})}extractCredentialString(e){if("string"==typeof e)return e;let t=e[this.config.aggregatorId||"glide"];if(!t&&e.glide&&(t=e.glide),!t&&e.default&&(t=e.default),!t){const n=Object.keys(e);n.length>0&&(t=e[n[0]])}return Array.isArray(t)?t[0]:t}extractErrorDetails(e){return a(this,void 0,void 0,function*(){try{const t=yield e.json();return Object.assign(Object.assign({},t),{status:e.status})}catch(t){return{status:e.status,statusText:e.statusText}}})}fetchWithTimeout(e,t){return a(this,void 0,void 0,function*(){const n=new AbortController,o=setTimeout(()=>n.abort(),this.config.timeout);try{return yield fetch(e,Object.assign(Object.assign({},t),{signal:n.signal}))}finally{clearTimeout(o)}})}createError(e,t,n){const o={code:e,message:t,details:(null==n?void 0:n.originalError)?Object.assign(Object.assign({},n),{originalError:void 0}):n};return(null==n?void 0:n.browserError)&&(o.browserError=n.browserError),(null==n?void 0:n.context)&&(o.context=n.context),(null==n?void 0:n.status)&&(o.status=n.status),(null==n?void 0:n.requestId)&&(o.requestId=n.requestId),(null==n?void 0:n.timestamp)&&(o.timestamp=n.timestamp),(null==n?void 0:n.retryAfter)&&(o.retryAfter=n.retryAfter),o}isAuthError(e){return e&&"string"==typeof e.code&&"string"==typeof e.message}log(...e){this.debug&&console.log("[PhoneAuth]",...e)}shouldRetry(e){var t,n,o;if(e.status&&e.status>=400&&e.status<500)return!1;if(["USER_DENIED","BROWSER_NOT_SUPPORTED","INVALID_PHONE_NUMBER","INVALID_PARAMETERS","MISSING_PARAMETERS","UNPROCESSABLE_ENTITY","USE_CASE_MISMATCH","PHONE_NUMBER_MISMATCH","VERIFICATION_FAILED","INVALID_CREDENTIAL","CARRIER_NOT_ELIGIBLE","SESSION_EXPIRED","INVALID_SESSION"].includes(e.code))return!1;const r=(null===(t=e.details)||void 0===t?void 0:t.errorType)&&["CROSS_DEVICE_TIMEOUT","CROSS_DEVICE_CONNECTION_LOST","CROSS_DEVICE_INCOMPLETE"].includes(e.details.errorType);return["NETWORK_ERROR","REQUEST_TIMEOUT","GATEWAY_TIMEOUT","SERVICE_UNAVAILABLE","BAD_GATEWAY","INTERNAL_SERVER_ERROR"].includes(e.code)||r||"NetworkError"===(null===(n=e.browserError)||void 0===n?void 0:n.name)&&19!==(null===(o=e.browserError)||void 0===o?void 0:o.code)}analyzeCrossDeviceError(e,t){var n;const o=e,r="AbortError"===o.name&&this.crossDeviceActive||(null===(n=o.message)||void 0===n?void 0:n.includes("timeout"))&&this.crossDeviceActive,i="NetworkError"===o.name&&19!==o.code&&this.crossDeviceActive;return r?{code:"REQUEST_TIMEOUT",message:"Cross-device authentication timed out. The QR code may have expired or the phone connection was lost.",details:{suggestion:"Try again and complete the phone authentication within 2 minutes",originalError:o.message,crossDevice:!0,errorType:"CROSS_DEVICE_TIMEOUT"},browserError:e.browserError}:i?{code:"NETWORK_ERROR",message:"Connection lost during cross-device authentication. Please ensure both devices have stable internet.",details:{suggestion:"Check your network connection on both devices and try again",originalError:o.message,crossDevice:!0,errorType:"CROSS_DEVICE_CONNECTION_LOST"},browserError:e.browserError}:e}cacheSession(e,t){const n=this.getCacheKey(e);this.sessionCache.set(n,{timestamp:Date.now(),data:t})}getCachedSession(e){const t=this.getCacheKey(e),n=this.sessionCache.get(t);return n?Date.now()-n.timestamp>3e5?(this.sessionCache.delete(t),null):n.data:null}getCacheKey(e){var t,n;return`${e.use_case}-${e.phone_number||"no-phone"}-${(null===(t=e.plmn)||void 0===t?void 0:t.mcc)||""}-${(null===(n=e.plmn)||void 0===n?void 0:n.mnc)||""}`}setupCacheCleanup(){"undefined"!=typeof window&&setInterval(()=>{const e=Date.now();for(const[t,n]of this.sessionCache.entries())e-n.timestamp>3e5&&this.sessionCache.delete(t)},6e4)}delay(e){return new Promise(t=>setTimeout(t,e))}}},928:function(e,t){var n,o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))(function(r,i){function s(e){try{l(o.next(e))}catch(e){i(e)}}function a(e){try{l(o.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}l((o=o.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.LoggerFactory=t.PerformanceTimer=t.RemoteLogger=t.NoopLogger=t.ConsoleLogger=t.LogLevel=void 0,t.parseLogLevel=s,t.getLogLevelFromEnv=a,t.generateRequestId=function(){return`req_${Date.now()}_${Math.random().toString(36).substring(2,9)}`},function(e){e[e.SILENT=0]="SILENT",e[e.ERROR=1]="ERROR",e[e.WARN=2]="WARN",e[e.INFO=3]="INFO",e[e.DEBUG=4]="DEBUG"}(n||(t.LogLevel=n={}));class r{constructor(e=n.SILENT,t="[Glide]",o=!1){this.level=e,this.prefix=t,this.enableGrouping=o}debug(e,t){this.level>=n.DEBUG&&this.log("debug",e,t)}info(e,t){this.level>=n.INFO&&this.log("info",e,t)}warn(e,t){this.level>=n.WARN&&this.log("warn",e,t)}error(e,t){this.level>=n.ERROR&&this.log("error",e,t)}log(e,t,n){const o=(new Date).toISOString(),r=n?this.sanitizeFields(n):{},i=`${this.prefix} ${o} [${e.toUpperCase()}] ${t}`;this.enableGrouping&&Object.keys(r).length>0?(console.groupCollapsed(i),Object.entries(r).forEach(([e,t])=>{console.log(`${e}:`,t)}),console.groupEnd()):Object.keys(r).length>0?console[e](i,r):console[e](i)}sanitizeFields(e){const t={};for(const[n,o]of Object.entries(e))t[n]=this.sanitizeValue(n,o);return t}sanitizeValue(e,t){const n=["apikey","api_key","apiKey","token","accesstoken","access_token","accessToken","password","passwd","pwd","secret","credential","authorization","auth","cookie","session"],o=e.toLowerCase();for(const e of n)if(o.includes(e.toLowerCase()))return"string"==typeof t&&t.length>4?t.substring(0,4)+"****[REDACTED]":"****[REDACTED]";if("string"==typeof t){if(/^\+?[1-9]\d{6,14}$/.test(t))return t.substring(0,6)+"****";if(/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)){const[,e]=t.split("@");return"****@"+e}if(t.includes("://")&&t.includes("@"))return t.replace(/\/\/([^:]+):([^@]+)@/,"//****:****@");if(t.startsWith("eyJ")&&3===t.split(".").length)return t.substring(0,10)+"****[JWT]";if(/\b\d{13,19}\b/.test(t))return t.substring(0,4)+"****"+t.substring(t.length-4)}return t&&"object"==typeof t&&!Array.isArray(t)?this.sanitizeFields(t):Array.isArray(t)?t.map((t,n)=>this.sanitizeValue(`${e}[${n}]`,t)):t}}t.ConsoleLogger=r,t.NoopLogger=class{debug(e,t){}info(e,t){}warn(e,t){}error(e,t){}};class i{constructor(e,t,o){this.buffer=[],this.flushInterval=5e3,this.maxBufferSize=100,this.endpoint=e,this.apiKey=t,this.localLogger=o||new r(n.ERROR),"undefined"!=typeof window&&(setInterval(()=>this.flush(),this.flushInterval),window.addEventListener("beforeunload",()=>this.flush()))}debug(e,t){this.log("debug",e,t)}info(e,t){this.log("info",e,t)}warn(e,t){this.log("warn",e,t)}error(e,t){this.log("error",e,t)}log(e,t,n){const o={timestamp:(new Date).toISOString(),level:e,message:t,fields:n,userAgent:"undefined"!=typeof navigator?navigator.userAgent:void 0,url:"undefined"!=typeof window?window.location.href:void 0};this.buffer.push(o),this.localLogger[e](t,n),this.buffer.length>=this.maxBufferSize&&this.flush()}flush(){return o(this,void 0,void 0,function*(){if(0===this.buffer.length)return;const e=[...this.buffer];this.buffer=[];try{yield fetch(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.apiKey}`},body:JSON.stringify({logs:e})})}catch(e){this.localLogger.error("Failed to send logs to remote server",{error:e})}})}}function s(e){switch(e.toLowerCase()){case"debug":return n.DEBUG;case"info":return n.INFO;case"warn":case"warning":return n.WARN;case"error":return n.ERROR;default:return n.SILENT}}function a(){if("undefined"!=typeof localStorage){const e=localStorage.getItem("GLIDE_LOG_LEVEL");if(e)return s(e);const t=localStorage.getItem("GLIDE_DEBUG");if("true"===t||"1"===t)return n.DEBUG}if("undefined"!=typeof window&&window.location){const e=new URLSearchParams(window.location.search),t=e.get("glide_log_level");if(t)return s(t);if(e.has("glide_debug"))return n.DEBUG}return n.SILENT}t.RemoteLogger=i,t.PerformanceTimer=class{constructor(e){this.marks=new Map,this.startTime=performance.now(),this.logger=e}mark(e){this.marks.set(e,performance.now())}logElapsed(e,t){const n=performance.now()-this.startTime;this.logger.debug(e,Object.assign(Object.assign({},t),{elapsedMs:n,elapsed:`${n.toFixed(2)}ms`}))}logMarkDuration(e,t,n,o){const r=this.marks.get(e),i=this.marks.get(t);if(r&&i){const s=i-r;this.logger.debug(n,Object.assign(Object.assign({},o),{durationMs:s,duration:`${s.toFixed(2)}ms`,fromMark:e,toMark:t}))}}};class l{static setDefaultLevel(e){this.defaultLevel=e}static setDefaultLogger(e){this.defaultLogger=e}static create(e){var t,n;if(null==e?void 0:e.custom)return e.custom;if(this.defaultLogger)return this.defaultLogger;const o=null!==(n=null!==(t=null==e?void 0:e.level)&&void 0!==t?t:a())&&void 0!==n?n:this.defaultLevel;if(null==e?void 0:e.remote){const t=new r(o,null==e?void 0:e.prefix);return new i(e.remote.endpoint,e.remote.apiKey,t)}return new r(o,null==e?void 0:e.prefix)}}t.LoggerFactory=l,l.defaultLevel=n.SILENT,l.defaultLogger=null},931:function(e,t,n){var o=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,r)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),r=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||o(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),t.AuthStatus=t.BrowserName=t.BrowserErrorCode=t.BrowserError=void 0,r(n(566),t),t.BrowserError={NOT_ALLOWED:"NotAllowedError",NETWORK:"NetworkError",NOT_SUPPORTED:"NotSupportedError",SECURITY:"SecurityError",ABORT:"AbortError",TIMEOUT:"TimeoutError",INVALID_STATE:"InvalidStateError",DATA_CLONE:"DataCloneError",ENCODING:"EncodingError",NOT_READABLE:"NotReadableError",UNKNOWN:"UnknownError",TYPE:"TypeError",RANGE:"RangeError",SYNTAX:"SyntaxError"},t.BrowserErrorCode={USER_CANCELLED_DC_API:19,PERMISSION_DENIED:1,POSITION_UNAVAILABLE:2,TIMEOUT:3,NOT_FOUND:8,ABORT:20,NETWORK:19,SECURITY:18},t.BrowserName={CHROME:"Chrome",EDGE:"Edge",SAFARI:"Safari",FIREFOX:"Firefox",OPERA:"Opera",BRAVE:"Brave",OTHER:"other"},t.AuthStatus={PENDING:"pending",COMPLETED:"completed",CANCELLED:"cancelled",FAILED:"failed",EXPIRED:"expired",NOT_FOUND:"not_found"}},982:function(e,t,n){var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))(function(r,i){function s(e){try{l(o.next(e))}catch(e){i(e)}}function a(e){try{l(o.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}l((o=o.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.VanillaClient=void 0;const r=n(499);t.VanillaClient=class{constructor(e){this.client=new r.SDKClient(e)}authenticate(e,t){return o(this,void 0,void 0,function*(){throw new Error("authenticate method is deprecated. Use client.setToken() directly.")})}setToken(e){this.client.setToken(e)}get(e,t){return o(this,void 0,void 0,function*(){return this.client.get(e,t)})}}}},t={};function n(o){var r=t[o];if(void 0!==r)return r.exports;var i=t[o]={exports:{}};return e[o].call(i.exports,i,i.exports,n),i.exports}n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}();var o={};return(()=>{var e=o;Object.defineProperty(e,"__esModule",{value:!0}),e.PhoneAuthManager=e.ClientManager=e.BrowserName=e.BrowserErrorCode=e.BrowserError=e.AuthenticationStrategy=e.UseCase=e.createErrorBreadcrumb=e.serializeError=e.isRetryableError=e.getRetryDelay=e.isErrorCode=e.getUserMessage=e.isUserError=e.isPhoneAuthError=e.PhoneAuthErrorCode=e.PhoneAuthClient=void 0;var t=n(514);Object.defineProperty(e,"PhoneAuthClient",{enumerable:!0,get:function(){return t.PhoneAuthClient}});var r=n(514);Object.defineProperty(e,"PhoneAuthErrorCode",{enumerable:!0,get:function(){return r.PhoneAuthErrorCode}}),Object.defineProperty(e,"isPhoneAuthError",{enumerable:!0,get:function(){return r.isPhoneAuthError}}),Object.defineProperty(e,"isUserError",{enumerable:!0,get:function(){return r.isUserError}}),Object.defineProperty(e,"getUserMessage",{enumerable:!0,get:function(){return r.getUserMessage}}),Object.defineProperty(e,"isErrorCode",{enumerable:!0,get:function(){return r.isErrorCode}}),Object.defineProperty(e,"getRetryDelay",{enumerable:!0,get:function(){return r.getRetryDelay}}),Object.defineProperty(e,"isRetryableError",{enumerable:!0,get:function(){return r.isRetryableError}}),Object.defineProperty(e,"serializeError",{enumerable:!0,get:function(){return r.serializeError}}),Object.defineProperty(e,"createErrorBreadcrumb",{enumerable:!0,get:function(){return r.createErrorBreadcrumb}});var i=n(931);Object.defineProperty(e,"UseCase",{enumerable:!0,get:function(){return i.USE_CASE}}),Object.defineProperty(e,"AuthenticationStrategy",{enumerable:!0,get:function(){return i.AUTHENTICATION_STRATEGY}}),Object.defineProperty(e,"BrowserError",{enumerable:!0,get:function(){return i.BrowserError}}),Object.defineProperty(e,"BrowserErrorCode",{enumerable:!0,get:function(){return i.BrowserErrorCode}}),Object.defineProperty(e,"BrowserName",{enumerable:!0,get:function(){return i.BrowserName}});var s=n(982);Object.defineProperty(e,"ClientManager",{enumerable:!0,get:function(){return s.VanillaClient}});var a=n(724);Object.defineProperty(e,"PhoneAuthManager",{enumerable:!0,get:function(){return a.PhoneAuthManager}})})(),o})());
@@ -513,7 +513,8 @@ export interface ExtendedResponse {
513
513
  cancel: () => void;
514
514
  }
515
515
  /**
516
- * Extended response for Desktop strategy
516
+ * Extended response for Desktop strategy.
517
+ * Note: Polling starts immediately even with preventDefaultUI: true (consistent with Link strategy)
517
518
  */
518
519
  export interface DesktopExtendedResponse extends ExtendedResponse {
519
520
  strategy: 'desktop';
@@ -528,7 +529,7 @@ export interface DesktopExtendedResponse extends ExtendedResponse {
528
529
  /** Challenge pattern */
529
530
  challenge?: any;
530
531
  };
531
- /** Start or restart polling */
532
+ /** Returns the existing polling promise (polling starts immediately) */
532
533
  start_polling: () => Promise<AuthCredential>;
533
534
  /** Stop polling */
534
535
  stop_polling: () => void;
@@ -531,19 +531,13 @@ class PhoneAuthClient {
531
531
  console.log('[PhoneAuth] Session cache size:', this.sessionCache.size);
532
532
  console.log('[PhoneAuth] Retry count:', this.retryCount);
533
533
  console.log('[PhoneAuth] PrepareResponse received:', JSON.stringify(plainResponse, null, 2));
534
- // Check if we're using new InvokeOptions format
535
- // Properly detect InvokeOptions by checking for any of its properties
536
- const invokeOptions = options && ('preventDefaultUI' in options ||
537
- 'executionMode' in options ||
538
- 'theme' in options ||
539
- 'modalOptions' in options ||
540
- 'callbacks' in options) ? options : undefined;
541
- // Get configuration from options
534
+ // Treat options as InvokeOptions (the modern format)
535
+ // Legacy DesktopAuthOptions properties will still work through property access
536
+ const opts = options;
537
+ // Get configuration from options - access properties directly
542
538
  const strategy = plainResponse.authentication_strategy;
543
- const preventDefaultUI = (_a = invokeOptions === null || invokeOptions === void 0 ? void 0 : invokeOptions.preventDefaultUI) !== null && _a !== void 0 ? _a : false;
544
- const executionMode = (_b = invokeOptions === null || invokeOptions === void 0 ? void 0 : invokeOptions.executionMode) !== null && _b !== void 0 ? _b : 'standard';
545
- // DesktopAuthOptions is only used if not InvokeOptions
546
- const desktopOptions = options && !invokeOptions ? options : undefined;
539
+ const preventDefaultUI = (_a = opts === null || opts === void 0 ? void 0 : opts.preventDefaultUI) !== null && _a !== void 0 ? _a : false;
540
+ const executionMode = (_b = opts === null || opts === void 0 ? void 0 : opts.executionMode) !== null && _b !== void 0 ? _b : 'standard';
547
541
  // Handle based on authentication strategy
548
542
  if (plainResponse.authentication_strategy === API.AUTHENTICATION_STRATEGY.TS43) {
549
543
  // Check browser support for TS43 strategy which requires Digital Credentials API
@@ -665,14 +659,14 @@ class PhoneAuthClient {
665
659
  var _a, _b;
666
660
  try {
667
661
  const result = yield triggerTS43();
668
- (_a = invokeOptions === null || invokeOptions === void 0 ? void 0 : invokeOptions.onTriggerAttempt) === null || _a === void 0 ? void 0 : _a.call(invokeOptions, {
662
+ (_a = opts === null || opts === void 0 ? void 0 : opts.onTriggerAttempt) === null || _a === void 0 ? void 0 : _a.call(opts, {
669
663
  strategy: API.AUTHENTICATION_STRATEGY.TS43,
670
664
  success: true
671
665
  });
672
666
  return result;
673
667
  }
674
668
  catch (error) {
675
- (_b = invokeOptions === null || invokeOptions === void 0 ? void 0 : invokeOptions.onTriggerAttempt) === null || _b === void 0 ? void 0 : _b.call(invokeOptions, {
669
+ (_b = opts === null || opts === void 0 ? void 0 : opts.onTriggerAttempt) === null || _b === void 0 ? void 0 : _b.call(opts, {
676
670
  strategy: API.AUTHENTICATION_STRATEGY.TS43,
677
671
  success: false,
678
672
  error
@@ -763,11 +757,10 @@ class PhoneAuthClient {
763
757
  qr_code: ((_k = desktopData.data) === null || _k === void 0 ? void 0 : _k.qr_code_image) || desktopData.qr_code_image || desktopData.qr_code,
764
758
  challenge: (_l = desktopData.data) === null || _l === void 0 ? void 0 : _l.challenge
765
759
  };
766
- // Polling options
767
- const pollingEndpointToUse = (invokeOptions === null || invokeOptions === void 0 ? void 0 : invokeOptions.pollingEndpoint) ||
768
- (desktopOptions === null || desktopOptions === void 0 ? void 0 : desktopOptions.pollingEndpoint) ||
760
+ // Polling options - gather from any options format
761
+ const pollingEndpointToUse = (opts === null || opts === void 0 ? void 0 : opts.pollingEndpoint) ||
769
762
  ((_m = this.config.endpoints) === null || _m === void 0 ? void 0 : _m.polling);
770
- const pollingOptions = Object.assign(Object.assign({}, desktopOptions), { pollingEndpoint: pollingEndpointToUse, pollingInterval: (invokeOptions === null || invokeOptions === void 0 ? void 0 : invokeOptions.pollingInterval) || (desktopOptions === null || desktopOptions === void 0 ? void 0 : desktopOptions.pollingInterval) || this.config.pollingInterval || 2000, maxPollingAttempts: (invokeOptions === null || invokeOptions === void 0 ? void 0 : invokeOptions.maxPollingAttempts) || (desktopOptions === null || desktopOptions === void 0 ? void 0 : desktopOptions.maxPollingAttempts) || this.config.maxPollingAttempts || 30, onQRCodeReady: undefined, onStatusUpdate: undefined });
763
+ const pollingOptions = Object.assign(Object.assign({}, opts), { pollingEndpoint: pollingEndpointToUse, pollingInterval: (opts === null || opts === void 0 ? void 0 : opts.pollingInterval) || this.config.pollingInterval || 2000, maxPollingAttempts: (opts === null || opts === void 0 ? void 0 : opts.maxPollingAttempts) || this.config.maxPollingAttempts || 30, onQRCodeReady: undefined, onStatusUpdate: undefined });
771
764
  // Decide whether to show modal based on preventDefaultUI
772
765
  const showModal = !preventDefaultUI;
773
766
  let modal;
@@ -776,13 +769,12 @@ class PhoneAuthClient {
776
769
  preventDefaultUI,
777
770
  showModal,
778
771
  executionMode,
779
- hasInvokeOptions: !!invokeOptions,
780
- hasDesktopOptions: !!desktopOptions
772
+ hasOptions: !!opts
781
773
  });
782
774
  if (showModal) {
783
775
  console.log('[Desktop] Creating modal with QR data:', qrCodeData);
784
776
  // Create and setup modal
785
- modal = new modal_1.AuthModal(invokeOptions === null || invokeOptions === void 0 ? void 0 : invokeOptions.modalOptions, invokeOptions === null || invokeOptions === void 0 ? void 0 : invokeOptions.callbacks);
777
+ modal = new modal_1.AuthModal(opts === null || opts === void 0 ? void 0 : opts.modalOptions, opts === null || opts === void 0 ? void 0 : opts.callbacks);
786
778
  modal.setCloseCallback(() => {
787
779
  this.log('Desktop QR modal closed by user, cancelling polling');
788
780
  handler.cancel();
@@ -830,41 +822,20 @@ class PhoneAuthClient {
830
822
  // Handle based on execution mode
831
823
  if (executionMode === 'extended') {
832
824
  // Extended mode - return control methods
833
- let credentialResolve = null;
834
- let credentialReject = null;
835
- let pollingStarted = false;
836
- // Create a promise that will remain pending until polling starts
825
+ // Create a promise and always start polling immediately
837
826
  const credentialPromise = new Promise((resolve, reject) => {
838
- credentialResolve = resolve;
839
- credentialReject = reject;
840
- // If modal is shown, start polling immediately
841
- if (showModal) {
842
- pollingStarted = true;
843
- startPolling()
844
- .then(resolve)
845
- .catch(reject);
846
- }
847
- // Otherwise, promise remains pending until start_polling() is called
827
+ // Always start polling immediately in extended mode (consistent with Link)
828
+ // This prevents the "unresolved promise trap" where developers might await
829
+ // the credential before calling start_polling()
830
+ startPolling()
831
+ .then(resolve)
832
+ .catch(reject);
848
833
  });
849
834
  // Create wrapped functions
850
835
  const wrappedStartPolling = () => __awaiter(this, void 0, void 0, function* () {
851
- if (pollingStarted) {
852
- throw this.createError(error_utils_1.PhoneAuthErrorCode.INVALID_SESSION_STATE, 'Polling has already been started');
853
- }
854
- pollingStarted = true;
855
- try {
856
- const result = yield startPolling();
857
- if (credentialResolve) {
858
- credentialResolve(result);
859
- }
860
- return result;
861
- }
862
- catch (err) {
863
- if (credentialReject) {
864
- credentialReject(err);
865
- }
866
- throw err;
867
- }
836
+ // Polling has already started automatically in extended mode
837
+ // This method just returns the existing credential promise for consistency
838
+ return credentialPromise;
868
839
  });
869
840
  const wrappedStopPolling = () => {
870
841
  handler.cleanup();
@@ -876,10 +847,7 @@ class PhoneAuthClient {
876
847
  handler.cleanup();
877
848
  if (modal)
878
849
  modal.close();
879
- // Reject the credential promise if it's still pending
880
- if (!pollingStarted && credentialReject) {
881
- credentialReject(this.createError(error_utils_1.PhoneAuthErrorCode.USER_DENIED, 'Desktop authentication cancelled by user'));
882
- }
850
+ // The credential promise will be rejected by the handler.cancel() call
883
851
  };
884
852
  // Create the response object with a getter for is_polling
885
853
  const response = {
@@ -937,14 +905,14 @@ class PhoneAuthClient {
937
905
  var _a, _b;
938
906
  try {
939
907
  window.open(linkData.url, '_blank');
940
- (_a = invokeOptions === null || invokeOptions === void 0 ? void 0 : invokeOptions.onTriggerAttempt) === null || _a === void 0 ? void 0 : _a.call(invokeOptions, {
908
+ (_a = opts === null || opts === void 0 ? void 0 : opts.onTriggerAttempt) === null || _a === void 0 ? void 0 : _a.call(opts, {
941
909
  strategy: API.AUTHENTICATION_STRATEGY.LINK,
942
910
  url: linkData.url,
943
911
  success: true
944
912
  });
945
913
  }
946
914
  catch (error) {
947
- (_b = invokeOptions === null || invokeOptions === void 0 ? void 0 : invokeOptions.onTriggerAttempt) === null || _b === void 0 ? void 0 : _b.call(invokeOptions, {
915
+ (_b = opts === null || opts === void 0 ? void 0 : opts.onTriggerAttempt) === null || _b === void 0 ? void 0 : _b.call(opts, {
948
916
  strategy: API.AUTHENTICATION_STRATEGY.LINK,
949
917
  url: linkData.url,
950
918
  success: false,
@@ -954,19 +922,19 @@ class PhoneAuthClient {
954
922
  };
955
923
  // Link always auto-opens the app (no SDK UI by default)
956
924
  // Open immediately to preserve user gesture context
957
- if ((invokeOptions === null || invokeOptions === void 0 ? void 0 : invokeOptions.autoTrigger) !== false) {
925
+ if ((opts === null || opts === void 0 ? void 0 : opts.autoTrigger) !== false) {
958
926
  triggerLink();
959
927
  }
960
928
  // Start polling in the background
961
929
  console.log('[PhoneAuth Client] Link polling config:', {
962
- fromInvokeOptions: invokeOptions === null || invokeOptions === void 0 ? void 0 : invokeOptions.pollingEndpoint,
930
+ fromOptions: opts === null || opts === void 0 ? void 0 : opts.pollingEndpoint,
963
931
  fromClientConfig: (_o = this.config.endpoints) === null || _o === void 0 ? void 0 : _o.polling,
964
- finalPollingEndpoint: (invokeOptions === null || invokeOptions === void 0 ? void 0 : invokeOptions.pollingEndpoint) || ((_p = this.config.endpoints) === null || _p === void 0 ? void 0 : _p.polling)
932
+ finalPollingEndpoint: (opts === null || opts === void 0 ? void 0 : opts.pollingEndpoint) || ((_p = this.config.endpoints) === null || _p === void 0 ? void 0 : _p.polling)
965
933
  });
966
934
  const pollingOptions = {
967
- pollingEndpoint: (invokeOptions === null || invokeOptions === void 0 ? void 0 : invokeOptions.pollingEndpoint) || ((_q = this.config.endpoints) === null || _q === void 0 ? void 0 : _q.polling),
968
- pollingInterval: (invokeOptions === null || invokeOptions === void 0 ? void 0 : invokeOptions.pollingInterval) || this.config.pollingInterval || 2000,
969
- maxPollingAttempts: (invokeOptions === null || invokeOptions === void 0 ? void 0 : invokeOptions.maxPollingAttempts) || this.config.maxPollingAttempts || 30,
935
+ pollingEndpoint: (opts === null || opts === void 0 ? void 0 : opts.pollingEndpoint) || ((_q = this.config.endpoints) === null || _q === void 0 ? void 0 : _q.polling),
936
+ pollingInterval: (opts === null || opts === void 0 ? void 0 : opts.pollingInterval) || this.config.pollingInterval || 2000,
937
+ maxPollingAttempts: (opts === null || opts === void 0 ? void 0 : opts.maxPollingAttempts) || this.config.maxPollingAttempts || 30,
970
938
  onLinkOpened: undefined,
971
939
  onStatusUpdate: undefined
972
940
  };
@@ -2,4 +2,4 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SDK_VERSION = void 0;
4
4
  // SDK version - injected at build time
5
- exports.SDK_VERSION = '4.4.9';
5
+ exports.SDK_VERSION = '4.4.10';
@@ -513,7 +513,8 @@ export interface ExtendedResponse {
513
513
  cancel: () => void;
514
514
  }
515
515
  /**
516
- * Extended response for Desktop strategy
516
+ * Extended response for Desktop strategy.
517
+ * Note: Polling starts immediately even with preventDefaultUI: true (consistent with Link strategy)
517
518
  */
518
519
  export interface DesktopExtendedResponse extends ExtendedResponse {
519
520
  strategy: 'desktop';
@@ -528,7 +529,7 @@ export interface DesktopExtendedResponse extends ExtendedResponse {
528
529
  /** Challenge pattern */
529
530
  challenge?: any;
530
531
  };
531
- /** Start or restart polling */
532
+ /** Returns the existing polling promise (polling starts immediately) */
532
533
  start_polling: () => Promise<AuthCredential>;
533
534
  /** Stop polling */
534
535
  stop_polling: () => void;
@@ -495,19 +495,13 @@ export class PhoneAuthClient {
495
495
  console.log('[PhoneAuth] Session cache size:', this.sessionCache.size);
496
496
  console.log('[PhoneAuth] Retry count:', this.retryCount);
497
497
  console.log('[PhoneAuth] PrepareResponse received:', JSON.stringify(plainResponse, null, 2));
498
- // Check if we're using new InvokeOptions format
499
- // Properly detect InvokeOptions by checking for any of its properties
500
- const invokeOptions = options && ('preventDefaultUI' in options ||
501
- 'executionMode' in options ||
502
- 'theme' in options ||
503
- 'modalOptions' in options ||
504
- 'callbacks' in options) ? options : undefined;
505
- // Get configuration from options
498
+ // Treat options as InvokeOptions (the modern format)
499
+ // Legacy DesktopAuthOptions properties will still work through property access
500
+ const opts = options;
501
+ // Get configuration from options - access properties directly
506
502
  const strategy = plainResponse.authentication_strategy;
507
- const preventDefaultUI = (_a = invokeOptions === null || invokeOptions === void 0 ? void 0 : invokeOptions.preventDefaultUI) !== null && _a !== void 0 ? _a : false;
508
- const executionMode = (_b = invokeOptions === null || invokeOptions === void 0 ? void 0 : invokeOptions.executionMode) !== null && _b !== void 0 ? _b : 'standard';
509
- // DesktopAuthOptions is only used if not InvokeOptions
510
- const desktopOptions = options && !invokeOptions ? options : undefined;
503
+ const preventDefaultUI = (_a = opts === null || opts === void 0 ? void 0 : opts.preventDefaultUI) !== null && _a !== void 0 ? _a : false;
504
+ const executionMode = (_b = opts === null || opts === void 0 ? void 0 : opts.executionMode) !== null && _b !== void 0 ? _b : 'standard';
511
505
  // Handle based on authentication strategy
512
506
  if (plainResponse.authentication_strategy === API.AUTHENTICATION_STRATEGY.TS43) {
513
507
  // Check browser support for TS43 strategy which requires Digital Credentials API
@@ -629,14 +623,14 @@ export class PhoneAuthClient {
629
623
  var _a, _b;
630
624
  try {
631
625
  const result = yield triggerTS43();
632
- (_a = invokeOptions === null || invokeOptions === void 0 ? void 0 : invokeOptions.onTriggerAttempt) === null || _a === void 0 ? void 0 : _a.call(invokeOptions, {
626
+ (_a = opts === null || opts === void 0 ? void 0 : opts.onTriggerAttempt) === null || _a === void 0 ? void 0 : _a.call(opts, {
633
627
  strategy: API.AUTHENTICATION_STRATEGY.TS43,
634
628
  success: true
635
629
  });
636
630
  return result;
637
631
  }
638
632
  catch (error) {
639
- (_b = invokeOptions === null || invokeOptions === void 0 ? void 0 : invokeOptions.onTriggerAttempt) === null || _b === void 0 ? void 0 : _b.call(invokeOptions, {
633
+ (_b = opts === null || opts === void 0 ? void 0 : opts.onTriggerAttempt) === null || _b === void 0 ? void 0 : _b.call(opts, {
640
634
  strategy: API.AUTHENTICATION_STRATEGY.TS43,
641
635
  success: false,
642
636
  error
@@ -727,11 +721,10 @@ export class PhoneAuthClient {
727
721
  qr_code: ((_k = desktopData.data) === null || _k === void 0 ? void 0 : _k.qr_code_image) || desktopData.qr_code_image || desktopData.qr_code,
728
722
  challenge: (_l = desktopData.data) === null || _l === void 0 ? void 0 : _l.challenge
729
723
  };
730
- // Polling options
731
- const pollingEndpointToUse = (invokeOptions === null || invokeOptions === void 0 ? void 0 : invokeOptions.pollingEndpoint) ||
732
- (desktopOptions === null || desktopOptions === void 0 ? void 0 : desktopOptions.pollingEndpoint) ||
724
+ // Polling options - gather from any options format
725
+ const pollingEndpointToUse = (opts === null || opts === void 0 ? void 0 : opts.pollingEndpoint) ||
733
726
  ((_m = this.config.endpoints) === null || _m === void 0 ? void 0 : _m.polling);
734
- const pollingOptions = Object.assign(Object.assign({}, desktopOptions), { pollingEndpoint: pollingEndpointToUse, pollingInterval: (invokeOptions === null || invokeOptions === void 0 ? void 0 : invokeOptions.pollingInterval) || (desktopOptions === null || desktopOptions === void 0 ? void 0 : desktopOptions.pollingInterval) || this.config.pollingInterval || 2000, maxPollingAttempts: (invokeOptions === null || invokeOptions === void 0 ? void 0 : invokeOptions.maxPollingAttempts) || (desktopOptions === null || desktopOptions === void 0 ? void 0 : desktopOptions.maxPollingAttempts) || this.config.maxPollingAttempts || 30, onQRCodeReady: undefined, onStatusUpdate: undefined });
727
+ const pollingOptions = Object.assign(Object.assign({}, opts), { pollingEndpoint: pollingEndpointToUse, pollingInterval: (opts === null || opts === void 0 ? void 0 : opts.pollingInterval) || this.config.pollingInterval || 2000, maxPollingAttempts: (opts === null || opts === void 0 ? void 0 : opts.maxPollingAttempts) || this.config.maxPollingAttempts || 30, onQRCodeReady: undefined, onStatusUpdate: undefined });
735
728
  // Decide whether to show modal based on preventDefaultUI
736
729
  const showModal = !preventDefaultUI;
737
730
  let modal;
@@ -740,13 +733,12 @@ export class PhoneAuthClient {
740
733
  preventDefaultUI,
741
734
  showModal,
742
735
  executionMode,
743
- hasInvokeOptions: !!invokeOptions,
744
- hasDesktopOptions: !!desktopOptions
736
+ hasOptions: !!opts
745
737
  });
746
738
  if (showModal) {
747
739
  console.log('[Desktop] Creating modal with QR data:', qrCodeData);
748
740
  // Create and setup modal
749
- modal = new AuthModal(invokeOptions === null || invokeOptions === void 0 ? void 0 : invokeOptions.modalOptions, invokeOptions === null || invokeOptions === void 0 ? void 0 : invokeOptions.callbacks);
741
+ modal = new AuthModal(opts === null || opts === void 0 ? void 0 : opts.modalOptions, opts === null || opts === void 0 ? void 0 : opts.callbacks);
750
742
  modal.setCloseCallback(() => {
751
743
  this.log('Desktop QR modal closed by user, cancelling polling');
752
744
  handler.cancel();
@@ -794,41 +786,20 @@ export class PhoneAuthClient {
794
786
  // Handle based on execution mode
795
787
  if (executionMode === 'extended') {
796
788
  // Extended mode - return control methods
797
- let credentialResolve = null;
798
- let credentialReject = null;
799
- let pollingStarted = false;
800
- // Create a promise that will remain pending until polling starts
789
+ // Create a promise and always start polling immediately
801
790
  const credentialPromise = new Promise((resolve, reject) => {
802
- credentialResolve = resolve;
803
- credentialReject = reject;
804
- // If modal is shown, start polling immediately
805
- if (showModal) {
806
- pollingStarted = true;
807
- startPolling()
808
- .then(resolve)
809
- .catch(reject);
810
- }
811
- // Otherwise, promise remains pending until start_polling() is called
791
+ // Always start polling immediately in extended mode (consistent with Link)
792
+ // This prevents the "unresolved promise trap" where developers might await
793
+ // the credential before calling start_polling()
794
+ startPolling()
795
+ .then(resolve)
796
+ .catch(reject);
812
797
  });
813
798
  // Create wrapped functions
814
799
  const wrappedStartPolling = () => __awaiter(this, void 0, void 0, function* () {
815
- if (pollingStarted) {
816
- throw this.createError(PhoneAuthErrorCode.INVALID_SESSION_STATE, 'Polling has already been started');
817
- }
818
- pollingStarted = true;
819
- try {
820
- const result = yield startPolling();
821
- if (credentialResolve) {
822
- credentialResolve(result);
823
- }
824
- return result;
825
- }
826
- catch (err) {
827
- if (credentialReject) {
828
- credentialReject(err);
829
- }
830
- throw err;
831
- }
800
+ // Polling has already started automatically in extended mode
801
+ // This method just returns the existing credential promise for consistency
802
+ return credentialPromise;
832
803
  });
833
804
  const wrappedStopPolling = () => {
834
805
  handler.cleanup();
@@ -840,10 +811,7 @@ export class PhoneAuthClient {
840
811
  handler.cleanup();
841
812
  if (modal)
842
813
  modal.close();
843
- // Reject the credential promise if it's still pending
844
- if (!pollingStarted && credentialReject) {
845
- credentialReject(this.createError(PhoneAuthErrorCode.USER_DENIED, 'Desktop authentication cancelled by user'));
846
- }
814
+ // The credential promise will be rejected by the handler.cancel() call
847
815
  };
848
816
  // Create the response object with a getter for is_polling
849
817
  const response = {
@@ -901,14 +869,14 @@ export class PhoneAuthClient {
901
869
  var _a, _b;
902
870
  try {
903
871
  window.open(linkData.url, '_blank');
904
- (_a = invokeOptions === null || invokeOptions === void 0 ? void 0 : invokeOptions.onTriggerAttempt) === null || _a === void 0 ? void 0 : _a.call(invokeOptions, {
872
+ (_a = opts === null || opts === void 0 ? void 0 : opts.onTriggerAttempt) === null || _a === void 0 ? void 0 : _a.call(opts, {
905
873
  strategy: API.AUTHENTICATION_STRATEGY.LINK,
906
874
  url: linkData.url,
907
875
  success: true
908
876
  });
909
877
  }
910
878
  catch (error) {
911
- (_b = invokeOptions === null || invokeOptions === void 0 ? void 0 : invokeOptions.onTriggerAttempt) === null || _b === void 0 ? void 0 : _b.call(invokeOptions, {
879
+ (_b = opts === null || opts === void 0 ? void 0 : opts.onTriggerAttempt) === null || _b === void 0 ? void 0 : _b.call(opts, {
912
880
  strategy: API.AUTHENTICATION_STRATEGY.LINK,
913
881
  url: linkData.url,
914
882
  success: false,
@@ -918,19 +886,19 @@ export class PhoneAuthClient {
918
886
  };
919
887
  // Link always auto-opens the app (no SDK UI by default)
920
888
  // Open immediately to preserve user gesture context
921
- if ((invokeOptions === null || invokeOptions === void 0 ? void 0 : invokeOptions.autoTrigger) !== false) {
889
+ if ((opts === null || opts === void 0 ? void 0 : opts.autoTrigger) !== false) {
922
890
  triggerLink();
923
891
  }
924
892
  // Start polling in the background
925
893
  console.log('[PhoneAuth Client] Link polling config:', {
926
- fromInvokeOptions: invokeOptions === null || invokeOptions === void 0 ? void 0 : invokeOptions.pollingEndpoint,
894
+ fromOptions: opts === null || opts === void 0 ? void 0 : opts.pollingEndpoint,
927
895
  fromClientConfig: (_o = this.config.endpoints) === null || _o === void 0 ? void 0 : _o.polling,
928
- finalPollingEndpoint: (invokeOptions === null || invokeOptions === void 0 ? void 0 : invokeOptions.pollingEndpoint) || ((_p = this.config.endpoints) === null || _p === void 0 ? void 0 : _p.polling)
896
+ finalPollingEndpoint: (opts === null || opts === void 0 ? void 0 : opts.pollingEndpoint) || ((_p = this.config.endpoints) === null || _p === void 0 ? void 0 : _p.polling)
929
897
  });
930
898
  const pollingOptions = {
931
- pollingEndpoint: (invokeOptions === null || invokeOptions === void 0 ? void 0 : invokeOptions.pollingEndpoint) || ((_q = this.config.endpoints) === null || _q === void 0 ? void 0 : _q.polling),
932
- pollingInterval: (invokeOptions === null || invokeOptions === void 0 ? void 0 : invokeOptions.pollingInterval) || this.config.pollingInterval || 2000,
933
- maxPollingAttempts: (invokeOptions === null || invokeOptions === void 0 ? void 0 : invokeOptions.maxPollingAttempts) || this.config.maxPollingAttempts || 30,
899
+ pollingEndpoint: (opts === null || opts === void 0 ? void 0 : opts.pollingEndpoint) || ((_q = this.config.endpoints) === null || _q === void 0 ? void 0 : _q.polling),
900
+ pollingInterval: (opts === null || opts === void 0 ? void 0 : opts.pollingInterval) || this.config.pollingInterval || 2000,
901
+ maxPollingAttempts: (opts === null || opts === void 0 ? void 0 : opts.maxPollingAttempts) || this.config.maxPollingAttempts || 30,
934
902
  onLinkOpened: undefined,
935
903
  onStatusUpdate: undefined
936
904
  };
@@ -1,2 +1,2 @@
1
1
  // SDK version - injected at build time
2
- export const SDK_VERSION = '4.4.9';
2
+ export const SDK_VERSION = '4.4.10';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glideidentity/web-client-sdk",
3
- "version": "4.4.9",
3
+ "version": "4.4.10",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/esm/index.js",
6
6
  "types": "./dist/index.d.ts",