@glideidentity/web-client-sdk 4.4.8-beta.2 → 4.4.8-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/web-client-sdk.min.js +1 -1
- package/dist/core/phone-auth/client.js +8 -2
- package/dist/core/phone-auth/strategies/link.js +97 -5
- package/dist/core/version.js +1 -1
- package/dist/esm/core/phone-auth/client.js +8 -2
- package/dist/esm/core/phone-auth/strategies/link.js +97 -5
- package/dist/esm/core/version.js +1 -1
- package/package.json +1 -1
|
@@ -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.8-beta.2"},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,r;if(e&&"object"==typeof e&&(e.code||e.error)){const t=e.code||e.error,r={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)&&(r.retryAfter=e.details.retryAfter),r}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===(r=e.headers)||void 0===r?void 0:r["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:r.SDK_VERSION,errorCapturedAt:(new Date).toISOString()}},t.createErrorBreadcrumb=function(e){var t,n,r;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===(r=e.browserError)||void 0===r?void 0:r.name}}};const r=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 o={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 o[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,r){return new(n||(n=Promise))(function(o,i){function s(e){try{l(r.next(e))}catch(e){i(e)}}function a(e){try{l(r.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}l((r=r.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())}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="${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="${e}" alt="QR Code" class="glide-auth-qr-code" />\n <p class="glide-auth-status">${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="${e.iosQRCode}" \n alt="QR Code" \n class="glide-auth-qr-code" \n data-ios="${e.iosQRCode}"\n data-android="${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 r,o,i;const s=t||(null===(r=this.options)||void 0===r?void 0:r.buttonText)||"Open Verification App";this.createModal(`\n <div class="glide-auth-link-container">\n <p class="glide-auth-description">\n ${(null===(o=this.options)||void 0===o?void 0:o.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 r,o;null===(o=null===(r=this.callbacks)||void 0===r?void 0:r.onAuthStart)||void 0===o||o.call(r),window.open(e,"_blank"),n()}):console.error("[Modal] Link button not found in modal")})}showTS43Button(e){return new Promise((t,r)=>{var o,i,s;const a=(null===(o=this.options)||void 0===o?void 0:o.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",o=>n(this,void 0,void 0,function*(){var n,o,i,s,c,u;null===(o=null===(n=this.callbacks)||void 0===n?void 0:n.onAuthStart)||void 0===o||o.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,r(e)}})):console.error("[Modal] TS43 button not found in modal")})}updateStatus(e,t=!1){var n;const r=null===(n=this.container)||void 0===n?void 0:n.querySelector(".glide-auth-status");r&&(r.textContent=e,r.className=t?"glide-auth-status glide-auth-error":"glide-auth-status")}createModal(e){var t,n,r;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===(r=this.options)||void 0===r?void 0:r.title)||"Phone Verification"}</h2>\n </div>\n <div class="glide-auth-content">\n ${e}\n </div>\n `,this.injectStyles();const o=this.container.querySelector(".glide-auth-close");o&&o.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 r=null===(e=this.container)||void 0===e?void 0:e.querySelectorAll(".glide-platform-btn"),o=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");r&&o&&r.forEach(e=>{e.addEventListener("click",e=>{const t=e.currentTarget,n=t.getAttribute("data-platform");r.forEach(e=>e.classList.remove("active")),t.classList.add("active"),"ios"===n?(o.src=o.getAttribute("data-ios")||"",i&&(i.textContent="Scan with your iPhone to authenticate")):"android"===n&&(o.src=o.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 r(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=r,t.hasTrigger=function(e){return!!n(e)&&"trigger"in e&&"function"==typeof e.trigger},t.isHeadlessResult=n,t.requiresPolling=r,t.requiresUserAction=e=>!1},425:(e,t,n)=>{function r(e,t){return function(){return e.apply(t,arguments)}}const{toString:o}=Object.prototype,{getPrototypeOf:i}=Object,{iterator:s,toStringTag:a}=Symbol,l=(c=Object.create(null),e=>{const t=o.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 E(e){return null!==e&&!p(e)&&null!==e.constructor&&!p(e.constructor)&&m(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const f=u("ArrayBuffer"),g=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"),y=u("File"),A=u("Blob"),O=u("FileList"),S=u("URLSearchParams"),[I,C,T,N]=["ReadableStream","Request","Response","Headers"].map(u);function w(e,t,{allOwnKeys:n=!1}={}){if(null==e)return;let r,o;if("object"!=typeof e&&(e=[e]),h(e))for(r=0,o=e.length;r<o;r++)t.call(null,e[r],r,e);else{if(E(e))return;const o=n?Object.getOwnPropertyNames(e):Object.keys(e),i=o.length;let s;for(r=0;r<i;r++)s=o[r],t.call(null,e[s],s,e)}}function P(e,t){if(E(e))return null;t=t.toLowerCase();const n=Object.keys(e);let r,o=n.length;for(;o-- >0;)if(r=n[o],t===r.toLowerCase())return r;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),r={};w(n,(n,o)=>{let i;!1!==(i=t(n,o,e))&&(r[o]=i||n)}),Object.defineProperties(e,r)},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:f,isBuffer:E,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&&f(e.buffer),t},isString:g,isNumber:R,isBoolean:e=>!0===e||!1===e,isObject:b,isPlainObject:_,isEmptyObject:e=>{if(!b(e)||E(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:y,isBlob:A,isRegExp:j,isFunction:m,isStream:e=>b(e)&&m(e.pipe),isURLSearchParams:S,isTypedArray:L,isFileList:O,forEach:w,merge:function e(){const{caseless:t,skipUndefined:n}=U(this)&&this||{},r={},o=(o,i)=>{const s=t&&P(r,i)||i;_(r[s])&&_(o)?r[s]=e(r[s],o):_(o)?r[s]=e({},o):h(o)?r[s]=o.slice():n&&p(o)||(r[s]=o)};for(let e=0,t=arguments.length;e<t;e++)arguments[e]&&w(arguments[e],o);return r},extend:(e,t,n,{allOwnKeys:o}={})=>(w(t,(t,o)=>{n&&m(t)?e[o]=r(t,n):e[o]=t},{allOwnKeys:o}),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,r)=>{e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},toFlatObject:(e,t,n,r)=>{let o,s,a;const l={};if(t=t||{},null==e)return t;do{for(o=Object.getOwnPropertyNames(e),s=o.length;s-- >0;)a=o[s],r&&!r(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 r=e.indexOf(t,n);return-1!==r&&r===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 r;for(;(r=n.next())&&!r.done;){const n=r.value;t.call(e,n[0],n[1])}},matchAll:(e,t)=>{let n;const r=[];for(;null!==(n=e.exec(t));)r.push(n);return r},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 r=e[n];m(r)&&(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={},r=e=>{e.forEach(e=>{n[e]=!0})};return h(e)?r(e):r(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:P,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,r)=>{if(b(e)){if(t.indexOf(e)>=0)return;if(E(e))return e;if(!("toJSON"in e)){t[r]=e;const o=h(e)?[]:{};return w(e,(e,t)=>{const i=n(e,r+1);!p(i)&&(o[t]=i)}),t[r]=void 0,o}}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,r,o){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),r&&(this.request=r),o&&(this.response=o,this.status=o.status?o.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,r,o,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,r,o),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 r=(n=W.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(e,t){return!W.isUndefined(t[e])})).metaTokens,o=n.visitor||c,i=n.dots,s=n.indexes,a=(n.Blob||"undefined"!=typeof Blob&&Blob)&&W.isSpecCompliantForm(t);if(!W.isFunction(o))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,o){let a=e;if(e&&!o&&"object"==typeof e)if(W.endsWith(n,"{}"))n=r?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,r){!W.isUndefined(e)&&null!==e&&t.append(!0===s?Z([n],r,i):null===s?n:n+"[]",l(e))}),!1;return!!X(e)||(t.append(Z(o,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,r){if(!W.isUndefined(n)){if(-1!==u.indexOf(n))throw Error("Circular reference detected in "+r.join("."));u.push(n),W.forEach(n,function(n,i){!0===(!(W.isUndefined(n)||null===n)&&o.call(t,n,W.isString(i)?i.trim():i,r,d))&&e(n,r?r.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 re(e,t){this._pairs=[],e&&te(e,this,t)}const oe=re.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 r=n&&n.encode||ie;W.isFunction(n)&&(n={serialize:n});const o=n&&n.serialize;let i;if(i=o?o(t,n):W.isURLSearchParams(t)?t.toString():new re(t,n).toString(r),i){const t=e.indexOf("#");-1!==t&&(e=e.slice(0,t)),e+=(-1===e.indexOf("?")?"?":"&")+i}return e}oe.append=function(e,t){this._pairs.push([e,t])},oe.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:re,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,Ee=ue&&window.location.href||"http://localhost";var fe={...Object.freeze({__proto__:null,hasBrowserEnv:ue,hasStandardBrowserWebWorkerEnv:pe,hasStandardBrowserEnv:he,navigator:de,origin:Ee}),...ce};function ge(e){function t(e,n,r,o){let i=e[o++];if("__proto__"===i)return!0;const s=Number.isFinite(+i),a=o>=e.length;return i=!i&&W.isArray(r)?r.length:i,a?(W.hasOwnProp(r,i)?r[i]=[r[i],n]:r[i]=n,!s):(r[i]&&W.isObject(r[i])||(r[i]=[]),t(e,n,r[i],o)&&W.isArray(r[i])&&(r[i]=function(e){const t={},n=Object.keys(e);let r;const o=n.length;let i;for(r=0;r<o;r++)i=n[r],t[i]=e[i];return t}(r[i])),!s)}if(W.isFormData(e)&&W.isFunction(e.entries)){const n={};return W.forEachEntry(e,(e,r)=>{t(function(e){return W.matchAll(/\w+|\[(\w*)]/g,e).map(e=>"[]"===e[0]?"":e[1]||e[0])}(e),r,n,0)}),n}return null}const me={transitional:le,adapter:["xhr","http","fetch"],transformRequest:[function(e,t){const n=t.getContentType()||"",r=n.indexOf("application/json")>-1,o=W.isObject(e);if(o&&W.isHTMLForm(e)&&(e=new FormData(e)),W.isFormData(e))return r?JSON.stringify(ge(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(o){if(n.indexOf("application/x-www-form-urlencoded")>-1)return function(e,t){return te(e,new fe.classes.URLSearchParams,{visitor:function(e,t,n,r){return fe.isNode&&W.isBuffer(e)?(this.append(t,e.toString("base64")),!1):r.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 o||r?(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,r="json"===this.responseType;if(W.isResponse(e)||W.isReadableStream(e))return e;if(e&&W.isString(e)&&(n&&!this.responseType||r)){const n=!(t&&t.silentJSONParsing)&&r;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:fe.classes.FormData,Blob:fe.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 ye(e){return!1===e||null==e?e:W.isArray(e)?e.map(ye):String(e)}function Ae(e,t,n,r,o){return W.isFunction(r)?r.call(this,t,n):(o&&(t=n),W.isString(t)?W.isString(r)?-1!==t.indexOf(r):W.isRegExp(r)?r.test(t):void 0:void 0)}class Oe{constructor(e){e&&this.set(e)}set(e,t,n){const r=this;function o(e,t,n){const o=ve(t);if(!o)throw new Error("header name must be a non-empty string");const i=W.findKey(r,o);(!i||void 0===r[i]||!0===n||void 0===n&&!1!==r[i])&&(r[i||t]=ye(e))}const i=(e,t)=>W.forEach(e,(e,n)=>o(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,r,o;return e&&e.split("\n").forEach(function(e){o=e.indexOf(":"),n=e.substring(0,o).trim().toLowerCase(),r=e.substring(o+1).trim(),!n||t[n]&&be[n]||("set-cookie"===n?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t})(e),t);else if(W.isObject(e)&&W.isIterable(e)){let n,r,o={};for(const t of e){if(!W.isArray(t))throw TypeError("Object iterator must return a key-value pair");o[r=t[0]]=(n=o[r])?W.isArray(n)?[...n,t[1]]:[n,t[1]]:t[1]}i(o,t)}else null!=e&&o(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 r;for(;r=n.exec(e);)t[r[1]]=r[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&&!Ae(0,this[n],n,t))}return!1}delete(e,t){const n=this;let r=!1;function o(e){if(e=ve(e)){const o=W.findKey(n,e);!o||t&&!Ae(0,n[o],o,t)||(delete n[o],r=!0)}}return W.isArray(e)?e.forEach(o):o(e),r}clear(e){const t=Object.keys(this);let n=t.length,r=!1;for(;n--;){const o=t[n];e&&!Ae(0,this[o],o,e,!0)||(delete this[o],r=!0)}return r}normalize(e){const t=this,n={};return W.forEach(this,(r,o)=>{const i=W.findKey(n,o);if(i)return t[i]=ye(r),void delete t[o];const s=e?function(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,t,n)=>t.toUpperCase()+n)}(o):String(o).trim();s!==o&&delete t[o],t[s]=ye(r),n[s]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const t=Object.create(null);return W.forEach(this,(n,r)=>{null!=n&&!1!==n&&(t[r]=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 r(e){const r=ve(e);t[r]||(function(e,t){const n=W.toCamelCase(" "+t);["get","set","has"].forEach(r=>{Object.defineProperty(e,r+n,{value:function(e,n,o){return this[r].call(this,t,e,n,o)},configurable:!0})})}(n,e),t[r]=!0)}return W.isArray(e)?e.forEach(r):r(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,r=t||n,o=Se.from(r.headers);let i=r.data;return W.forEach(e,function(e){i=e.call(n,i,o.normalize(),t?t.status:void 0)}),o.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 r=n.config.validateStatus;n.status&&r&&!r(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 we=(e,t,n=3)=>{let r=0;const o=function(e,t){e=e||10;const n=new Array(e),r=new Array(e);let o,i=0,s=0;return t=void 0!==t?t:1e3,function(a){const l=Date.now(),c=r[s];o||(o=l),n[i]=a,r[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-o<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-r,l=o(a);r=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)},Pe=(e,t)=>{const n=null!=e;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},De=e=>(...t)=>W.asap(()=>e(...t));var Ue=fe.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,fe.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(fe.origin),fe.navigator&&/(msie|trident)/i.test(fe.navigator.userAgent)):()=>!0,Le=fe.hasStandardBrowserEnv?{write(e,t,n,r,o,i){const s=[e+"="+encodeURIComponent(t)];W.isNumber(n)&&s.push("expires="+new Date(n).toGMTString()),W.isString(r)&&s.push("path="+r),W.isString(o)&&s.push("domain="+o),!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 r=!/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t);return e&&(r||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 r(e,t,n,r){return W.isPlainObject(e)&&W.isPlainObject(t)?W.merge.call({caseless:r},e,t):W.isPlainObject(t)?W.merge({},t):W.isArray(t)?t.slice():t}function o(e,t,n,o){return W.isUndefined(t)?W.isUndefined(e)?void 0:r(void 0,e,0,o):r(e,t,0,o)}function i(e,t){if(!W.isUndefined(t))return r(void 0,t)}function s(e,t){return W.isUndefined(t)?W.isUndefined(e)?void 0:r(void 0,e):r(void 0,t)}function a(n,o,i){return i in t?r(n,o):i in e?r(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)=>o(ke(e),ke(t),0,!0)};return W.forEach(Object.keys({...e,...t}),function(r){const i=l[r]||o,s=i(e[r],t[r],r);W.isUndefined(s)&&i!==a||(n[r]=s)}),n}var je=e=>{const t=Me({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:o,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(fe.hasStandardBrowserEnv||fe.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(fe.hasStandardBrowserEnv&&(r&&W.isFunction(r)&&(r=r(t)),r||!1!==r&&Ue(t.url))){const e=o&&i&&Le.read(i);e&&s.set(o,e)}return t},Be="undefined"!=typeof XMLHttpRequest&&function(e){return new Promise(function(t,n){const r=je(e);let o=r.data;const i=Se.from(r.headers).normalize();let s,a,l,c,u,{responseType:d,onUploadProgress:h,onDownloadProgress:p}=r;function E(){c&&c(),u&&u(),r.cancelToken&&r.cancelToken.unsubscribe(s),r.signal&&r.signal.removeEventListener("abort",s)}let f=new XMLHttpRequest;function g(){if(!f)return;const r=Se.from("getAllResponseHeaders"in f&&f.getAllResponseHeaders());Ne(function(e){t(e),E()},function(e){n(e),E()},{data:d&&"text"!==d&&"json"!==d?f.response:f.responseText,status:f.status,statusText:f.statusText,headers:r,config:e,request:f}),f=null}f.open(r.method.toUpperCase(),r.url,!0),f.timeout=r.timeout,"onloadend"in f?f.onloadend=g:f.onreadystatechange=function(){f&&4===f.readyState&&(0!==f.status||f.responseURL&&0===f.responseURL.indexOf("file:"))&&setTimeout(g)},f.onabort=function(){f&&(n(new z("Request aborted",z.ECONNABORTED,e,f)),f=null)},f.onerror=function(t){const r=new z(t&&t.message?t.message:"Network Error",z.ERR_NETWORK,e,f);r.event=t||null,n(r),f=null},f.ontimeout=function(){let t=r.timeout?"timeout of "+r.timeout+"ms exceeded":"timeout exceeded";const o=r.transitional||le;r.timeoutErrorMessage&&(t=r.timeoutErrorMessage),n(new z(t,o.clarifyTimeoutError?z.ETIMEDOUT:z.ECONNABORTED,e,f)),f=null},void 0===o&&i.setContentType(null),"setRequestHeader"in f&&W.forEach(i.toJSON(),function(e,t){f.setRequestHeader(t,e)}),W.isUndefined(r.withCredentials)||(f.withCredentials=!!r.withCredentials),d&&"json"!==d&&(f.responseType=r.responseType),p&&([l,u]=we(p,!0),f.addEventListener("progress",l)),h&&f.upload&&([a,c]=we(h),f.upload.addEventListener("progress",a),f.upload.addEventListener("loadend",c)),(r.cancelToken||r.signal)&&(s=t=>{f&&(n(!t||t.type?new Te(null,e,f):t),f.abort(),f=null)},r.cancelToken&&r.cancelToken.subscribe(s),r.signal&&(r.signal.aborted?s():r.signal.addEventListener("abort",s)));const m=function(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}(r.url);m&&-1===fe.protocols.indexOf(m)?n(new z("Unsupported protocol "+m+":",z.ERR_BAD_REQUEST,e)):f.send(o||null)})},Fe=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let n,r=new AbortController;const o=function(e){if(!n){n=!0,s();const t=e instanceof Error?e:this.reason;r.abort(t instanceof z?t:new Te(t instanceof Error?t.message:t))}};let i=t&&setTimeout(()=>{i=null,o(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(o):e.removeEventListener("abort",o)}),e=null)};e.forEach(e=>e.addEventListener("abort",o));const{signal:a}=r;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 r,o=0;for(;o<n;)r=o+t,yield e.slice(o,r),o=r},qe=(e,t,n,r)=>{const o=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,r&&r(e))};return new ReadableStream({async pull(e){try{const{done:t,value:r}=await o.next();if(t)return a(),void e.close();let i=r.byteLength;if(n){let e=s+=i;n(e)}e.enqueue(new Uint8Array(r))}catch(e){throw a(e),e}},cancel:e=>(a(e),o.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:r}=e,o=t?He(t):"function"==typeof fetch,i=He(n),s=He(r);if(!o)return!1;const a=o&&He($e),l=o&&("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(fe.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 r("").body)),h={stream:d&&(e=>e.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(e=>{!h[e]&&(h[e]=(t,n)=>{let r=t&&t[e];if(r)return r.call(t);throw new z(`Response type '${e}' is not supported`,z.ERR_NOT_SUPPORT,n)})});return async e=>{let{url:o,method:s,data:a,signal:c,cancelToken:p,timeout:E,onDownloadProgress:f,onUploadProgress:g,responseType:m,headers:R,withCredentials:b="same-origin",fetchOptions:_}=je(e),v=t||fetch;m=m?(m+"").toLowerCase():"text";let y=Fe([c,p&&p.toAbortSignal()],E),A=null;const O=y&&y.unsubscribe&&(()=>{y.unsubscribe()});let S;try{if(g&&u&&"get"!==s&&"head"!==s&&0!==(S=await(async(e,t)=>{const r=W.toFiniteNumber(e.getContentLength());return null==r?(async e=>{if(null==e)return 0;if(W.isBlob(e))return e.size;if(W.isSpecCompliantForm(e)){const t=new n(fe.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):r})(R,a))){let e,t=new n(o,{method:"POST",body:a,duplex:"half"});if(W.isFormData(a)&&(e=t.headers.get("content-type"))&&R.setContentType(e),t.body){const[e,n]=Pe(S,we(De(g)));a=qe(t.body,65536,e,n)}}W.isString(b)||(b=b?"include":"omit");const t=i&&"credentials"in n.prototype,c={..._,signal:y,method:s.toUpperCase(),headers:R.normalize().toJSON(),body:a,duplex:"half",credentials:t?b:void 0};A=i&&new n(o,c);let p=await(i?v(A,_):v(o,c));const E=d&&("stream"===m||"response"===m);if(d&&(f||E&&O)){const e={};["status","statusText","headers"].forEach(t=>{e[t]=p[t]});const t=W.toFiniteNumber(p.headers.get("content-length")),[n,o]=f&&Pe(t,we(De(f),!0))||[];p=new r(qe(p.body,65536,n,()=>{o&&o(),O&&O()}),e)}m=m||"text";let I=await h[W.findKey(h,m)||"text"](p,e);return!E&&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:A})})}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,A),{cause:t.cause||t});throw z.from(t,t&&t.code,e,A)}}},Ke=new Map,Ye=e=>{let t=e?e.env:{};const{fetch:n,Request:r,Response:o}=t,i=[r,o,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 r,o;const i={};for(let s=0;s<n;s++){let n;if(r=e[s],o=r,!Ze(r)&&(o=Xe[(n=String(r)).toLowerCase()],void 0===o))throw new z(`Unknown adapter '${n}'`);if(o&&(W.isFunction(o)||(o=o.get(t))))break;i[n||"#"+s]=o}if(!o){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 o};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 rt="1.12.2",ot={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{ot[e]=function(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}});const it={};ot.transitional=function(e,t,n){function r(e,t){return"[Axios v"+rt+"] Transitional option '"+e+"'"+t+(n?". "+n:"")}return(n,o,i)=>{if(!1===e)throw new z(r(o," has been removed"+(t?" in "+t:"")),z.ERR_DEPRECATED);return t&&!it[o]&&(it[o]=!0,console.warn(r(o," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(n,o,i)}},ot.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 r=Object.keys(e);let o=r.length;for(;o-- >0;){const i=r[o],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:ot};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:r,headers:o}=t;void 0!==n&&st.assertOptions(n,{silentJSONParsing:at.transitional(at.boolean),forcedJSONParsing:at.transitional(at.boolean),clarifyTimeoutError:at.transitional(at.boolean)},!1),null!=r&&(W.isFunction(r)?t.paramsSerializer={serialize:r}:st.assertOptions(r,{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=o&&W.merge(o.common,o[t.method]);o&&W.forEach(["delete","get","head","post","put","patch","common"],e=>{delete o[e]}),t.headers=Se.concat(i,o);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,r,o){return this.request(Me(o||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:n,data:r}))}}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 r=new Promise(e=>{n.subscribe(e),t=e}).then(e);return r.cancel=function(){n.unsubscribe(t)},r},e(function(e,r,o){n.reason||(n.reason=new Te(e,r,o),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 Et=function e(t){const n=new ct(t),o=r(ct.prototype.request,n);return W.extend(o,ct.prototype,n,{allOwnKeys:!0}),W.extend(o,n,null,{allOwnKeys:!0}),o.create=function(n){return e(Me(t,n))},o}(Re);Et.Axios=ct,Et.CanceledError=Te,Et.CancelToken=dt,Et.isCancel=Ce,Et.VERSION=rt,Et.toFormData=te,Et.AxiosError=z,Et.Cancel=Et.CanceledError,Et.all=function(e){return Promise.all(e)},Et.spread=function(e){return function(t){return e.apply(null,t)}},Et.isAxiosError=function(e){return W.isObject(e)&&!0===e.isAxiosError},Et.mergeConfig=Me,Et.AxiosHeaders=Se,Et.formToJSON=e=>ge(W.isHTMLForm(e)?new FormData(e):e),Et.getAdapter=et,Et.HttpStatusCode=pt,Et.default=Et,e.exports=Et},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!==r.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:r}=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 r&&0!==r.trim().length?{valid:!0}:{valid:!1,error:"Policy text is required when consent data is provided"}},t.createValidationError=function(e,t,n){const r=new Error(t);return r.code=e,n&&(r.field=n),r},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 r=n(566)},499:function(e,t,n){var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{l(r.next(e))}catch(e){i(e)}}function a(e){try{l(r.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}l((r=r.apply(e,t||[])).next())})},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.SDKClient=void 0;const i=o(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=>r(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 r(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 r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(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}}),o(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,r){return new(n||(n=Promise))(function(o,i){function s(e){try{l(r.next(e))}catch(e){i(e)}}function a(e){try{l(r.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}l((r=r.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.LinkHandler=void 0,t.LinkHandler=class{constructor(){this.isPolling=!1,this.isCancelled=!1}invoke(e,t){return n(this,void 0,void 0,function*(){const n=e.data;if(!n||!n.url)throw new Error("Invalid link data: missing URL");const r=e.session.session_key;return this.openAuthenticationLink(n.url),(null==t?void 0:t.onLinkOpened)&&t.onLinkOpened(),this.startPolling(r,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,r){return n(this,void 0,void 0,function*(){const o=(null==r?void 0:r.pollingInterval)||2e3,i=(null==r?void 0:r.maxPollingAttempts)||150;let s=0;return new Promise((a,l)=>{this.isPolling=!0;const c=()=>n(this,void 0,void 0,function*(){if(this.isPolling)try{if(s++,s>=i)return this.stopPolling(),(null==r?void 0:r.onTimeout)&&r.onTimeout(),(null==r?void 0:r.onStatusUpdate)&&r.onStatusUpdate({status:"expired",message:"Authentication timeout"}),void l(new Error("Authentication timeout after 5 minutes"));let n;t.status_url?(n=t.status_url,console.log("[Link Auth] Using status URL from link data:",n)):n=`https://api.glideidentity.app/public/public/status/${e}`;const o=yield fetch(n,{method:"GET",headers:{Accept:"application/json"}});if(200===o.status){const t=yield o.json();"completed"===t.status?(this.stopPolling(),(null==r?void 0:r.onStatusUpdate)&&r.onStatusUpdate({status:"authenticated",message:"Authentication successful",data:t}),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&&(null==r?void 0:r.onStatusUpdate)&&r.onStatusUpdate({status:"pending",message:"Waiting for app authentication..."})}else if(410===o.status){this.stopPolling();const e=yield o.json().catch(()=>({message:"Session expired"}));(null==r?void 0:r.onTimeout)&&r.onTimeout(),(null==r?void 0:r.onStatusUpdate)&&r.onStatusUpdate({status:"expired",message:e.message||"Session expired"}),l(new Error(e.message||"Session expired"))}else if(422===o.status){this.stopPolling();const e=yield o.json().catch(()=>({message:"Authentication failed"})),t="USER_CANCELLED"===e.code?"User cancelled authentication":e.message||"Verification failed";(null==r?void 0:r.onStatusUpdate)&&r.onStatusUpdate({status:"error",message:t}),l(new Error(t))}else if(404===o.status)this.stopPolling(),(null==r?void 0:r.onStatusUpdate)&&r.onStatusUpdate({status:"error",message:"Session not found"}),l(new Error("Session not found"));else if(400===o.status){this.stopPolling();const e=yield o.json().catch(()=>({message:"Invalid session key"}));l(new Error(e.message||"Invalid session key"))}}catch(e){(null==r?void 0:r.onStatusUpdate)&&r.onStatusUpdate({status:"pending",message:`Connection issue, retrying... (${s}/${i})`})}});c(),this.pollingInterval=setInterval(c,o)})})}stopPolling(){this.isPolling=!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}cancel(){var e;this.isCancelled=!0,this.stopPolling(),null===(e=this.onCancel)||void 0===e||e.call(this)}}},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],r=t.map(e=>{if("object"==typeof e)try{return JSON.stringify(e,null,2)}catch(e){return"[Object]"}return String(e)}).join(" "),o={log:"#fff",error:"#ff6b6b",warn:"#ffd93d",info:"#6bcf7f",debug:"#95a5a6"},i=`\n <div style="margin: 4px 0; font-family: monospace; font-size: 11px; color: ${o[e]||"#fff"};">\n <span style="color: #666;">[${n}]</span>\n <span style="color: ${o[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(r)}</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 r=document.createElement("div");r.id="debug-buttons";const o=document.createElement("button");o.textContent="Clear",o.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(),r.appendChild(o),r.appendChild(i),r.appendChild(s),t.appendChild(n),t.appendChild(r),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 r(e){return!!/^\d{3}$/.test(e.mcc)&&!!/^\d{2,3}$/.test(e.mnc)}function o(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,r){return{code:e,message:t.ERROR_MESSAGES[e],request_id:r,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=r,t.validateSession=o,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:r,validateSession:o,validateUseCase:i,isTS43Data:l,isLinkData:c,isErrorResponse:u,createErrorResponse:s,getErrorStatusCode:a}},724:function(e,t,n){var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{l(r.next(e))}catch(e){i(e)}}function a(e){try{l(r.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}l((r=r.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.PhoneAuthManager=void 0;const o=n(514);t.PhoneAuthManager=class{constructor(e={}){this.listeners=[],this.client=new o.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 r(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 r=n,o="GetPhoneNumber"===e.use_case?yield this.client.getPhoneNumber(r,t.session):yield this.client.verifyPhoneNumber(r,t.session);return this.updateState({result:o,currentStep:"complete",isLoading:!1}),o}catch(t){const n=t,r=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:r,currentStep:"idle",isLoading:!1}),r}})}getPhoneNumber(e){return r(this,void 0,void 0,function*(){return this.verify(Object.assign({use_case:"GetPhoneNumber"},e))})}verifyPhoneNumber(e,t){return r(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,r){return new(n||(n=Promise))(function(o,i){function s(e){try{l(r.next(e))}catch(e){i(e)}}function a(e){try{l(r.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}l((r=r.apply(e,t||[])).next())})};function r(e,t){const n=(null==t?void 0:t.container)||document.createElement("div");n.className="phone-auth-qr-container";const r=document.createElement("img");if(r.src=e,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=r,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 o=document.createElement("div");o.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()},o.appendChild(i);const s=r(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"});o.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 ",o.appendChild(a),n.appendChild(o),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}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 r,o,i,s,a;if(n&&n.data&&"object"==typeof n.data){const e=n.data;r=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.qr_code_image||e.qr_code,o=e.session_id,i=e.status_url,s=e.polling_interval,a=e.expires_in}if(!r&&n&&(r=n.qr_code_image||n.qr_code,o=o||n.session_id,i=i||n.status_url||n.polling_endpoint,s=s||n.polling_interval,a=a||n.expires_in),!r)throw new Error("Invalid desktop authentication data: missing QR code");if(!o)throw new Error("Invalid desktop authentication data: missing session ID");(null==t?void 0:t.onQRCodeReady)&&t.onQRCodeReady(r),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)||150;return console.log(`[Desktop QR] Starting polling - endpoint source: ${c}, interval: ${u}ms, max attempts: ${d}`),this.startPolling(l||"",o,u,d,a||300,t,c)})}startPolling(e,t,r,o,i,s){return n(this,arguments,void 0,function*(e,t,r,o,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*(){try{if(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>=o)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 r=new URL(e);n=`${r.protocol}//${r.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}/${o})`),console.log(`[Desktop QR] Using ${a} endpoint: ${n}`);const r=yield fetch(n,{method:"GET",headers:{Accept:"application/json"}});if(console.log(`[Desktop QR] Status response: ${r.status} ${r.statusText}`),200===r.status){const e=yield r.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}/${o})`}))}else if(410===r.status){this.stopPolling();const e=yield r.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===r.status){this.stopPolling();const e=yield r.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===r.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===r.status){this.stopPolling();const e=yield r.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}/${o})`})}});u(),this.pollingIntervalId=setInterval(u,r)})})}stopPolling(){this.pollingIntervalId&&(console.log("[Desktop QR] Stopping polling"),clearInterval(this.pollingIntervalId),this.pollingIntervalId=void 0),this.pollingAttempts=0}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 r,o=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=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||(r=function(e){return r=Object.getOwnPropertyNames||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[t.length]=n);return t},r(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n=r(e),s=0;s<n.length;s++)"default"!==n[s]&&o(t,e,n[s]);return i(t,e),t}),a=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{l(r.next(e))}catch(e){i(e)}}function a(e){try{l(r.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}l((r=r.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),E=n(544),f=n(244);t.PhoneAuthClient=class{constructor(e={}){var t,r,o,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===(r=e.endpoints)||void 0===r?void 0:r.process)||"/api/magic-auth/process",polling:null===(o=e.endpoints)||void 0===o?void 0:o.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),r=(0,u.serializeError)(e);!this.debug&&(0,u.isUserError)(e)||console.error("[PhoneAuth] Error:",Object.assign(Object.assign({},r),{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,r;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 r=n,o=e.use_case===l.USE_CASE.GET_PHONE_NUMBER?yield this.getPhoneNumber(r,t.session):yield this.verifyPhoneNumber(r,t.session);return this.cacheSession(e,o),o}catch(o){const i=(0,u.isPhoneAuthError)(o)?o:(0,u.parseBackendError)(o);if(this.shouldRetry(i)&&this.retryCount<t){this.retryCount++,null===(r=(n=this.callbacks).onRetryAttempt)||void 0===r||r.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 o=this.getCachedSession(e);return o?(this.debug&&console.log("[PhoneAuth] Using cached session result"),o):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)(o)){if(o.context)throw o;throw{code:i.code,message:o.message,details:o.details,status:o.status,requestId:o.requestId,timestamp:o.timestamp,retryAfter:o.retryAfter,browserError:o.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",o)}})}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;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.phone_number&&!e.plmn&&!(null===(t=e.options)||void 0===t?void 0:t.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"}):e.use_case?this.createError(u.PhoneAuthErrorCode.MISSING_PARAMETERS,"Either phone number or PLMN (MCC/MNC) must be provided",{field:"phoneNumber,plmn"}):this.createError(u.PhoneAuthErrorCode.MISSING_PARAMETERS,"use_case is required",{field:"use_case"});!(null===(n=e.options)||void 0===n?void 0:n.parent_session_id)||e.phone_number||e.plmn||e.use_case||this.debug&&console.log("[PhoneAuth] Using parent_session_id only - all fields will be inherited from parent session");const r=`web-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,o=btoa(String.fromCharCode(...crypto.getRandomValues(new Uint8Array(32)))).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"");if(!(0,d.validateNonce)(o).valid)throw this.createError(u.PhoneAuthErrorCode.INTERNAL_SERVER_ERROR,"Failed to generate valid nonce",{field:"nonce"});const i={use_case:e.use_case,phone_number:e.phone_number,plmn:e.plmn?{mcc:e.plmn.mcc,mnc:e.plmn.mnc}:void 0,nonce:o,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",i);try{const t=yield this.fetchWithTimeout(this.config.endpoints.prepare,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});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 r=(0,u.parseBackendError)(n);throw r.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},r.details=Object.assign(Object.assign({},r.details),{endpoint:"prepare",status:t.status}),r}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,r,o,i,s,d,h,g,m,R,b,_,v;let y;try{y="undefined"!=typeof structuredClone?structuredClone(e):JSON.parse(JSON.stringify(e))}catch(t){this.debug&&console.log("[PhoneAuth] structuredClone failed, using JSON fallback:",t),y=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(y,null,2));const A=t&&("preventDefaultUI"in t||"executionMode"in t||"theme"in t||"modalOptions"in t||"callbacks"in t)?t:void 0,O=(y.authentication_strategy,null!==(n=null==A?void 0:A.preventDefaultUI)&&void 0!==n&&n),S=null!==(r=null==A?void 0:A.executionMode)&&void 0!==r?r:"standard",I=t&&!A?t:void 0;if(y.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=y.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 r=n.data;return this.log("Secure credential response received",r),r.vp_token}catch(t){const r=t,o={name:r.name||"UnknownError",message:r.message||"Unknown error occurred",stack:r.stack,code:r.code},i={step:"prompt",timestamp:(new Date).toISOString(),userAgent:navigator.userAgent,url:window.location.href,authentication_strategy:y.authentication_strategy,hasSession:!!y.session};if(r.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:o,context:i});if(r.name===c.BrowserError.NETWORK&&r.code===c.BrowserErrorCode.USER_CANCELLED_DC_API)throw this.createError(u.PhoneAuthErrorCode.USER_DENIED,"Authentication cancelled by user",{originalError:t,browserError:o,context:i});if(r.name===c.BrowserError.NETWORK)throw this.createError(u.PhoneAuthErrorCode.NETWORK_ERROR,"Network error occurred while retrieving credentials",{originalError:t,browserError:o,context:i});if(r.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:o,context:i});if(r.name===c.BrowserError.SECURITY)throw this.createError(u.PhoneAuthErrorCode.FORBIDDEN,"Security error: This feature requires a secure context (HTTPS)",{originalError:t,browserError:o,context:i});if(r.name===c.BrowserError.ABORT||(null===(e=o.message)||void 0===e?void 0:e.includes("The operation was aborted"))||(null===(n=o.message)||void 0===n?void 0:n.includes("User cancelled")))throw this.createError(u.PhoneAuthErrorCode.USER_DENIED,"Authentication cancelled",{originalError:t,browserError:o,context:i});throw this.createError(u.PhoneAuthErrorCode.INTERNAL_SERVER_ERROR,`Digital Credentials API error: ${r.message||"Unknown error"}`,{originalError:t,browserError:o,context:i})}}),r=()=>a(this,void 0,void 0,function*(){var e,t;try{const t=yield n();return null===(e=null==A?void 0:A.onTriggerAttempt)||void 0===e||e.call(A,{strategy:l.AUTHENTICATION_STRATEGY.TS43,success:!0}),t}catch(e){throw null===(t=null==A?void 0:A.onTriggerAttempt)||void 0===t||t.call(A,{strategy:l.AUTHENTICATION_STRATEGY.TS43,success:!1,error:e}),e}});let o;try{const e=yield r();o=Promise.resolve({credential:"string"==typeof e?e:Object.values(e)[0],session:y.session,authenticated:!0})}catch(e){o=Promise.reject(e)}if("extended"===S)return{strategy:"ts43",session:y.session,credential:o,trigger:()=>a(this,void 0,void 0,function*(){const e=yield r();o=Promise.resolve({credential:"string"==typeof e?e:Object.values(e)[0],session:y.session,authenticated:!0})}),cancel:()=>{o=Promise.reject(this.createError(u.PhoneAuthErrorCode.USER_DENIED,"Authentication cancelled"))}};{const e=yield o;return{[y.session.session_key]:e.credential}}}if(y.authentication_strategy!==l.AUTHENTICATION_STRATEGY.DESKTOP){if(y.authentication_strategy===l.AUTHENTICATION_STRATEGY.LINK){const e=y.data,t=new E.LinkHandler,n=()=>{var t,n;try{window.open(e.url,"_blank"),null===(t=null==A?void 0:A.onTriggerAttempt)||void 0===t||t.call(A,{strategy:l.AUTHENTICATION_STRATEGY.LINK,url:e.url,success:!0})}catch(t){null===(n=null==A?void 0:A.onTriggerAttempt)||void 0===n||n.call(A,{strategy:l.AUTHENTICATION_STRATEGY.LINK,url:e.url,success:!1,error:t})}};!1!==(null==A?void 0:A.autoTrigger)&&n();const r={pollingEndpoint:(null==A?void 0:A.pollingEndpoint)||(null===(v=this.config.endpoints)||void 0===v?void 0:v.polling),pollingInterval:(null==A?void 0:A.pollingInterval)||this.config.pollingInterval||2e3,maxPollingAttempts:(null==A?void 0:A.maxPollingAttempts)||this.config.maxPollingAttempts||150,onLinkOpened:void 0,onStatusUpdate:void 0},o=t.invoke(y,r).then(e=>{if(e.authenticated&&e.credential)return{credential:e.credential,session:y.session,authenticated:!0};throw this.createError(u.PhoneAuthErrorCode.USER_DENIED,e.error||"Link authentication failed")});if("extended"===S)return{strategy:"link",session:y.session,credential:o,data:{app_url:e.url},trigger:n,start_polling:()=>t.invoke(y,r).then(e=>({credential:e.credential||"",session:y.session,authenticated:e.authenticated})),stop_polling:()=>t.cleanup(),cancel:()=>{t.cancel(),t.cleanup()},is_polling:!0};{const e=yield o,t=this.config.aggregatorId||"default";return{[t]:e.credential}}}throw this.createError(u.PhoneAuthErrorCode.UNSUPPORTED_STRATEGY,`Unknown authentication strategy: ${y.authentication_strategy}`)}{const e=y.data,t=new p.DesktopHandler,n={iosQRCode:(null===(o=e.data)||void 0===o?void 0:o.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},r={ios_qr_image:(null===(g=e.data)||void 0===g?void 0:g.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},a=(null==A?void 0:A.pollingEndpoint)||(null==I?void 0:I.pollingEndpoint)||(null===(_=this.config.endpoints)||void 0===_?void 0:_.polling),l=Object.assign(Object.assign({},I),{pollingEndpoint:a,pollingInterval:(null==A?void 0:A.pollingInterval)||(null==I?void 0:I.pollingInterval)||this.config.pollingInterval||2e3,maxPollingAttempts:(null==A?void 0:A.maxPollingAttempts)||(null==I?void 0:I.maxPollingAttempts)||this.config.maxPollingAttempts||150,onQRCodeReady:void 0,onStatusUpdate:void 0}),c=!O;let E,v;console.log("[Desktop] Modal decision:",{preventDefaultUI:O,showModal:c,executionMode:S,hasInvokeOptions:!!A,hasDesktopOptions:!!I}),c?(console.log("[Desktop] Creating modal with QR data:",n),E=new f.AuthModal(null==A?void 0:A.modalOptions,null==A?void 0:A.callbacks),E.setCloseCallback(()=>{this.log("Desktop QR modal closed by user, cancelling polling"),t.cancel()}),l.onQRCodeReady=e=>{console.log("[Desktop] onQRCodeReady callback triggered:",e),E.showQRCode(e,"Scan with your mobile device")},l.onStatusUpdate=e=>{"pending"===e.status?E.updateStatus("Waiting for authentication..."):"authenticated"===e.status?(E.updateStatus("Authentication successful!"),setTimeout(()=>E.close(),1500)):"expired"===e.status?E.updateStatus("QR code expired",!0):"error"===e.status&&E.updateStatus("Authentication failed",!0)},v=E):console.log("[Desktop] Modal not shown - preventDefaultUI is true");const C=()=>t.invoke(y,l).then(e=>{if(e.authenticated&&e.credential)return{credential:e.credential,session:y.session,authenticated:!0};throw this.createError(u.PhoneAuthErrorCode.USER_DENIED,e.error||"Desktop authentication failed")});if("extended"===S){const e=c?C():Promise.resolve({credential:"",session:y.session,authenticated:!1});return{strategy:"desktop",session:y.session,credential:e,qr_code_data:r,modal_ref:v,start_polling:C,stop_polling:()=>{t.cleanup(),E&&E.close()},cancel:()=>{t.cancel(),t.cleanup(),E&&E.close()},is_polling:c}}try{const t=yield C();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(),E&&E.close()}}})}getPhoneNumber(e,t){return a(this,void 0,void 0,function*(){const n=this.extractCredentialString(e),r={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(r)});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),r={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(r)});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,r=setTimeout(()=>n.abort(),this.config.timeout);try{return yield fetch(e,Object.assign(Object.assign({},t),{signal:n.signal}))}finally{clearTimeout(r)}})}createError(e,t,n){const r={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)&&(r.browserError=n.browserError),(null==n?void 0:n.context)&&(r.context=n.context),(null==n?void 0:n.status)&&(r.status=n.status),(null==n?void 0:n.requestId)&&(r.requestId=n.requestId),(null==n?void 0:n.timestamp)&&(r.timestamp=n.timestamp),(null==n?void 0:n.retryAfter)&&(r.retryAfter=n.retryAfter),r}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,r;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 o=(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)||o||"NetworkError"===(null===(n=e.browserError)||void 0===n?void 0:n.name)&&19!==(null===(r=e.browserError)||void 0===r?void 0:r.code)}analyzeCrossDeviceError(e,t){var n;const r=e,o="AbortError"===r.name&&this.crossDeviceActive||(null===(n=r.message)||void 0===n?void 0:n.includes("timeout"))&&this.crossDeviceActive,i="NetworkError"===r.name&&19!==r.code&&this.crossDeviceActive;return o?{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:r.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:r.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,r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{l(r.next(e))}catch(e){i(e)}}function a(e){try{l(r.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}l((r=r.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 o{constructor(e=n.SILENT,t="[Glide]",r=!1){this.level=e,this.prefix=t,this.enableGrouping=r}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 r=(new Date).toISOString(),o=n?this.sanitizeFields(n):{},i=`${this.prefix} ${r} [${e.toUpperCase()}] ${t}`;this.enableGrouping&&Object.keys(o).length>0?(console.groupCollapsed(i),Object.entries(o).forEach(([e,t])=>{console.log(`${e}:`,t)}),console.groupEnd()):Object.keys(o).length>0?console[e](i,o):console[e](i)}sanitizeFields(e){const t={};for(const[n,r]of Object.entries(e))t[n]=this.sanitizeValue(n,r);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"],r=e.toLowerCase();for(const e of n)if(r.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=o,t.NoopLogger=class{debug(e,t){}info(e,t){}warn(e,t){}error(e,t){}};class i{constructor(e,t,r){this.buffer=[],this.flushInterval=5e3,this.maxBufferSize=100,this.endpoint=e,this.apiKey=t,this.localLogger=r||new o(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 r={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(r),this.localLogger[e](t,n),this.buffer.length>=this.maxBufferSize&&this.flush()}flush(){return r(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,r){const o=this.marks.get(e),i=this.marks.get(t);if(o&&i){const s=i-o;this.logger.debug(n,Object.assign(Object.assign({},r),{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 r=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 o(r,null==e?void 0:e.prefix);return new i(e.remote.endpoint,e.remote.apiKey,t)}return new o(r,null==e?void 0:e.prefix)}}t.LoggerFactory=l,l.defaultLevel=n.SILENT,l.defaultLogger=null},931:function(e,t,n){var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),t.AuthStatus=t.BrowserName=t.BrowserErrorCode=t.BrowserError=void 0,o(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 r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{l(r.next(e))}catch(e){i(e)}}function a(e){try{l(r.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}l((r=r.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.VanillaClient=void 0;const o=n(499);t.VanillaClient=class{constructor(e){this.client=new o.SDKClient(e)}authenticate(e,t){return r(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 r(this,void 0,void 0,function*(){return this.client.get(e,t)})}}}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var i=t[r]={exports:{}};return e[r].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 r={};return(()=>{var e=r;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 o=n(514);Object.defineProperty(e,"PhoneAuthErrorCode",{enumerable:!0,get:function(){return o.PhoneAuthErrorCode}}),Object.defineProperty(e,"isPhoneAuthError",{enumerable:!0,get:function(){return o.isPhoneAuthError}}),Object.defineProperty(e,"isUserError",{enumerable:!0,get:function(){return o.isUserError}}),Object.defineProperty(e,"getUserMessage",{enumerable:!0,get:function(){return o.getUserMessage}}),Object.defineProperty(e,"isErrorCode",{enumerable:!0,get:function(){return o.isErrorCode}}),Object.defineProperty(e,"getRetryDelay",{enumerable:!0,get:function(){return o.getRetryDelay}}),Object.defineProperty(e,"isRetryableError",{enumerable:!0,get:function(){return o.isRetryableError}}),Object.defineProperty(e,"serializeError",{enumerable:!0,get:function(){return o.serializeError}}),Object.defineProperty(e,"createErrorBreadcrumb",{enumerable:!0,get:function(){return o.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}})})(),r})());
|
|
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.8-beta.3"},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())}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="${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="${e}" alt="QR Code" class="glide-auth-qr-code" />\n <p class="glide-auth-status">${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="${e.iosQRCode}" \n alt="QR Code" \n class="glide-auth-qr-code" \n data-ios="${e.iosQRCode}"\n data-android="${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 E(e){return null!==e&&!p(e)&&null!==e.constructor&&!p(e.constructor)&&m(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const g=u("ArrayBuffer"),f=d("string"),m=d("function"),R=d("number"),b=e=>null!==e&&"object"==typeof e,v=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)},_=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 w(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(E(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 P(e,t){if(E(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={};w(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:g,isBuffer:E,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&&g(e.buffer),t},isString:f,isNumber:R,isBoolean:e=>!0===e||!1===e,isObject:b,isPlainObject:v,isEmptyObject:e=>{if(!b(e)||E(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:_,isFile:A,isBlob:y,isRegExp:j,isFunction:m,isStream:e=>b(e)&&m(e.pipe),isURLSearchParams:S,isTypedArray:L,isFileList:O,forEach:w,merge:function e(){const{caseless:t,skipUndefined:n}=U(this)&&this||{},o={},r=(r,i)=>{const s=t&&P(o,i)||i;v(o[s])&&v(r)?o[s]=e(o[s],r):v(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]&&w(arguments[e],r);return o},extend:(e,t,n,{allOwnKeys:r}={})=>(w(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:P,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(E(e))return e;if(!("toJSON"in e)){t[o]=e;const r=h(e)?[]:{};return w(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,Ee=ue&&window.location.href||"http://localhost";var ge={...Object.freeze({__proto__:null,hasBrowserEnv:ue,hasStandardBrowserWebWorkerEnv:pe,hasStandardBrowserEnv:he,navigator:de,origin:Ee}),...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 ge.classes.URLSearchParams,{visitor:function(e,t,n,o){return ge.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:ge.classes.FormData,Blob:ge.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"]),ve=Symbol("internals");function _e(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=_e(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=_e(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=_e(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=_e(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[ve]=this[ve]={accessors:{}}).accessors,n=this.prototype;function o(e){const o=_e(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 we=(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)},Pe=(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=ge.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,ge.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(ge.origin),ge.navigator&&/(msie|trident)/i.test(ge.navigator.userAgent)):()=>!0,Le=ge.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(ge.hasStandardBrowserEnv||ge.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(ge.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 E(){c&&c(),u&&u(),o.cancelToken&&o.cancelToken.unsubscribe(s),o.signal&&o.signal.removeEventListener("abort",s)}let g=new XMLHttpRequest;function f(){if(!g)return;const o=Se.from("getAllResponseHeaders"in g&&g.getAllResponseHeaders());Ne(function(e){t(e),E()},function(e){n(e),E()},{data:d&&"text"!==d&&"json"!==d?g.response:g.responseText,status:g.status,statusText:g.statusText,headers:o,config:e,request:g}),g=null}g.open(o.method.toUpperCase(),o.url,!0),g.timeout=o.timeout,"onloadend"in g?g.onloadend=f:g.onreadystatechange=function(){g&&4===g.readyState&&(0!==g.status||g.responseURL&&0===g.responseURL.indexOf("file:"))&&setTimeout(f)},g.onabort=function(){g&&(n(new z("Request aborted",z.ECONNABORTED,e,g)),g=null)},g.onerror=function(t){const o=new z(t&&t.message?t.message:"Network Error",z.ERR_NETWORK,e,g);o.event=t||null,n(o),g=null},g.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,g)),g=null},void 0===r&&i.setContentType(null),"setRequestHeader"in g&&W.forEach(i.toJSON(),function(e,t){g.setRequestHeader(t,e)}),W.isUndefined(o.withCredentials)||(g.withCredentials=!!o.withCredentials),d&&"json"!==d&&(g.responseType=o.responseType),p&&([l,u]=we(p,!0),g.addEventListener("progress",l)),h&&g.upload&&([a,c]=we(h),g.upload.addEventListener("progress",a),g.upload.addEventListener("loadend",c)),(o.cancelToken||o.signal)&&(s=t=>{g&&(n(!t||t.type?new Te(null,e,g):t),g.abort(),g=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===ge.protocols.indexOf(m)?n(new z("Unsupported protocol "+m+":",z.ERR_BAD_REQUEST,e)):g.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(ge.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:E,onDownloadProgress:g,onUploadProgress:f,responseType:m,headers:R,withCredentials:b="same-origin",fetchOptions:v}=je(e),_=t||fetch;m=m?(m+"").toLowerCase():"text";let A=Fe([c,p&&p.toAbortSignal()],E),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(ge.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]=Pe(S,we(De(f)));a=qe(t.body,65536,e,n)}}W.isString(b)||(b=b?"include":"omit");const t=i&&"credentials"in n.prototype,c={...v,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?_(y,v):_(r,c));const E=d&&("stream"===m||"response"===m);if(d&&(g||E&&O)){const e={};["status","statusText","headers"].forEach(t=>{e[t]=p[t]});const t=W.toFiniteNumber(p.headers.get("content-length")),[n,r]=g&&Pe(t,we(De(g),!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!E&&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 Et=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);Et.Axios=ct,Et.CanceledError=Te,Et.CancelToken=dt,Et.isCancel=Ce,Et.VERSION=ot,Et.toFormData=te,Et.AxiosError=z,Et.Cancel=Et.CanceledError,Et.all=function(e){return Promise.all(e)},Et.spread=function(e){return function(t){return e.apply(null,t)}},Et.isAxiosError=function(e){return W.isObject(e)&&!0===e.isAxiosError},Et.mergeConfig=Me,Et.AxiosHeaders=Se,Et.formToJSON=e=>fe(W.isHTMLForm(e)?new FormData(e):e),Et.getAdapter=et,Et.HttpStatusCode=pt,Et.default=Et,e.exports=Et},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.isPolling=!1,this.isCancelled=!1}invoke(e,t){return n(this,void 0,void 0,function*(){console.log("[Link Auth] 🔗 SDK Version: 4.4.8-beta.2 (with enhanced error logging)"),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)||150;let s=0;return console.log("[Link Auth] 🚀 Starting polling:",{sessionKey:e,interval:`${r}ms`,maxAttempts:i,linkDataAvailable:!!t}),new Promise((a,l)=>{this.isPolling=!0;const c=()=>n(this,void 0,void 0,function*(){if(!this.isPolling)return;let n="";try{if(s++,s>=i)return this.stopPolling(),(null==o?void 0:o.onTimeout)&&o.onTimeout(),(null==o?void 0:o.onStatusUpdate)&&o.onStatusUpdate({status:"expired",message:"Authentication timeout"}),void l(new Error("Authentication timeout after 5 minutes"));let r=null==o?void 0:o.pollingEndpoint,c="options";if(!r&&t.status_url&&(r=t.status_url,c="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:",r,"from source:",c),r&&(r.startsWith("http://")||r.startsWith("https://")))if(r.includes("{{session_id}}"))n=r.replace("{{session_id}}",e);else if(r.includes(e))n=r;else{const t=new URL(r);n=`${t.protocol}//${t.host}/public/public/status/${e}`}else if(r&&""!==r){const t="undefined"!=typeof window?window.location.origin:"";n=r.includes("{{session_id}}")?t+r.replace("{{session_id}}",e):t+r+"/"+e}else n=`https://api.glideidentity.app/public/public/status/${e}`,c="fallback";console.log(`[Link Auth] Using ${c} endpoint: ${n}`),console.log(`[Link Auth] Polling status (attempt ${s}/${i}): ${n}`);const u=yield fetch(n,{method:"GET",headers:{Accept:"application/json"}});if(console.log(`[Link Auth] Poll response - Status: ${u.status}, OK: ${u.ok}`),200===u.status){const t=yield u.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}),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..."),(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))}else if(410===u.status){console.log("[Link Auth] ❌ Session expired (410)"),this.stopPolling();const e=yield u.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===u.status){console.log("[Link Auth] ❌ Authentication failed (422)"),this.stopPolling();const e=yield u.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===u.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===u.status){console.log("[Link Auth] ❌ Invalid session key (400)"),this.stopPolling();const e=yield u.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:",u.status,"continuing to poll...");try{const e=yield u.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),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})`})}});c(),this.pollingInterval=setInterval(c,r)})})}stopPolling(){console.log("[Link Auth] 🏁 Stopping polling"),this.isPolling=!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}cancel(){var e;this.isCancelled=!0,this.stopPolling(),null===(e=this.onCancel)||void 0===e||e.call(this)}}},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");n.className="phone-auth-qr-container";const o=document.createElement("img");if(o.src=e,o.alt="QR Code for authentication",o.style.width=`${(null==t?void 0:t.size)||256}px`,o.style.height=`${(null==t?void 0:t.size)||256}px`,o.style.display="block",o.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(o),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}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.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)||150;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*(){try{if(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})`})}});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}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),E=n(544),g=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,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;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.phone_number&&!e.plmn&&!(null===(t=e.options)||void 0===t?void 0:t.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"}):e.use_case?this.createError(u.PhoneAuthErrorCode.MISSING_PARAMETERS,"Either phone number or PLMN (MCC/MNC) must be provided",{field:"phoneNumber,plmn"}):this.createError(u.PhoneAuthErrorCode.MISSING_PARAMETERS,"use_case is required",{field:"use_case"});!(null===(n=e.options)||void 0===n?void 0:n.parent_session_id)||e.phone_number||e.plmn||e.use_case||this.debug&&console.log("[PhoneAuth] Using parent_session_id only - all fields will be inherited from parent session");const o=`web-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,r=btoa(String.fromCharCode(...crypto.getRandomValues(new Uint8Array(32)))).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"");if(!(0,d.validateNonce)(r).valid)throw this.createError(u.PhoneAuthErrorCode.INTERNAL_SERVER_ERROR,"Failed to generate valid nonce",{field:"nonce"});const i={use_case:e.use_case,phone_number:e.phone_number,plmn:e.plmn?{mcc:e.plmn.mcc,mnc:e.plmn.mnc}:void 0,nonce:r,id:o,consent_data:e.consent_data,client_info:{user_agent:navigator.userAgent,platform:navigator.platform},options:e.options};this.log("Preparing phone verification request",i);try{const t=yield this.fetchWithTimeout(this.config.endpoints.prepare,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});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}});let r;try{const e=yield o();r=Promise.resolve({credential:"string"==typeof e?e:Object.values(e)[0],session:O.session,authenticated:!0})}catch(e){r=Promise.reject(e)}if("extended"===C)return{strategy:"ts43",session:O.session,credential:r,trigger:()=>a(this,void 0,void 0,function*(){const e=yield o();r=Promise.resolve({credential:"string"==typeof e?e:Object.values(e)[0],session:O.session,authenticated:!0})}),cancel:()=>{r=Promise.reject(this.createError(u.PhoneAuthErrorCode.USER_DENIED,"Authentication cancelled"))}};{const e=yield r;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 E.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===(_=this.config.endpoints)||void 0===_?void 0:_.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||150,onLinkOpened:void 0,onStatusUpdate:void 0};console.log("[PhoneAuth Client] Final Link polling options:",o);const r=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")});if("extended"===C)return{strategy:"link",session:O.session,credential:r,data:{app_url:e.url},trigger:n,start_polling:()=>t.invoke(O,o).then(e=>({credential:e.credential||"",session:O.session,authenticated:e.authenticated})),stop_polling:()=>t.cleanup(),cancel:()=>{t.cancel(),t.cleanup()},is_polling:!0};{const e=yield r,t=this.config.aggregatorId||"default";return{[t]:e.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},a=(null==S?void 0:S.pollingEndpoint)||(null==T?void 0:T.pollingEndpoint)||(null===(v=this.config.endpoints)||void 0===v?void 0:v.polling),l=Object.assign(Object.assign({},T),{pollingEndpoint:a,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||150,onQRCodeReady:void 0,onStatusUpdate:void 0}),c=!I;let E,_;console.log("[Desktop] Modal decision:",{preventDefaultUI:I,showModal:c,executionMode:C,hasInvokeOptions:!!S,hasDesktopOptions:!!T}),c?(console.log("[Desktop] Creating modal with QR data:",n),E=new g.AuthModal(null==S?void 0:S.modalOptions,null==S?void 0:S.callbacks),E.setCloseCallback(()=>{this.log("Desktop QR modal closed by user, cancelling polling"),t.cancel()}),l.onQRCodeReady=e=>{console.log("[Desktop] onQRCodeReady callback triggered:",e),E.showQRCode(e,"Scan with your mobile device")},l.onStatusUpdate=e=>{"pending"===e.status?E.updateStatus("Waiting for authentication..."):"authenticated"===e.status?(E.updateStatus("Authentication successful!"),setTimeout(()=>E.close(),1500)):"expired"===e.status?E.updateStatus("QR code expired",!0):"error"===e.status&&E.updateStatus("Authentication failed",!0)},_=E):console.log("[Desktop] Modal not shown - preventDefaultUI is true");const A=()=>t.invoke(O,l).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=c?A():Promise.resolve({credential:"",session:O.session,authenticated:!1});return{strategy:"desktop",session:O.session,credential:e,qr_code_data:o,modal_ref:_,start_polling:A,stop_polling:()=>{t.cleanup(),E&&E.close()},cancel:()=>{t.cancel(),t.cleanup(),E&&E.close()},is_polling:c}}try{const t=yield A();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(),E&&E.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})());
|
|
@@ -514,7 +514,7 @@ class PhoneAuthClient {
|
|
|
514
514
|
// This ensures we work with plain objects for browser APIs
|
|
515
515
|
// Vue's reactivity system wraps objects in Proxies which can interfere
|
|
516
516
|
// with browser APIs like Digital Credentials API that expect plain objects
|
|
517
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
517
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
518
518
|
// Try structuredClone first (modern browsers), but catch errors and fallback to JSON method
|
|
519
519
|
let plainResponse;
|
|
520
520
|
try {
|
|
@@ -900,13 +900,19 @@ class PhoneAuthClient {
|
|
|
900
900
|
triggerLink();
|
|
901
901
|
}
|
|
902
902
|
// Start polling in the background
|
|
903
|
+
console.log('[PhoneAuth Client] Link polling config:', {
|
|
904
|
+
fromInvokeOptions: invokeOptions === null || invokeOptions === void 0 ? void 0 : invokeOptions.pollingEndpoint,
|
|
905
|
+
fromClientConfig: (_o = this.config.endpoints) === null || _o === void 0 ? void 0 : _o.polling,
|
|
906
|
+
finalPollingEndpoint: (invokeOptions === null || invokeOptions === void 0 ? void 0 : invokeOptions.pollingEndpoint) || ((_p = this.config.endpoints) === null || _p === void 0 ? void 0 : _p.polling)
|
|
907
|
+
});
|
|
903
908
|
const pollingOptions = {
|
|
904
|
-
pollingEndpoint: (invokeOptions === null || invokeOptions === void 0 ? void 0 : invokeOptions.pollingEndpoint) || ((
|
|
909
|
+
pollingEndpoint: (invokeOptions === null || invokeOptions === void 0 ? void 0 : invokeOptions.pollingEndpoint) || ((_q = this.config.endpoints) === null || _q === void 0 ? void 0 : _q.polling),
|
|
905
910
|
pollingInterval: (invokeOptions === null || invokeOptions === void 0 ? void 0 : invokeOptions.pollingInterval) || this.config.pollingInterval || 2000,
|
|
906
911
|
maxPollingAttempts: (invokeOptions === null || invokeOptions === void 0 ? void 0 : invokeOptions.maxPollingAttempts) || this.config.maxPollingAttempts || 150,
|
|
907
912
|
onLinkOpened: undefined,
|
|
908
913
|
onStatusUpdate: undefined
|
|
909
914
|
};
|
|
915
|
+
console.log('[PhoneAuth Client] Final Link polling options:', pollingOptions);
|
|
910
916
|
// Create credential promise
|
|
911
917
|
const credentialPromise = handler.invoke(plainResponse, pollingOptions).then(result => {
|
|
912
918
|
if (result.authenticated && result.credential) {
|
|
@@ -26,12 +26,21 @@ class LinkHandler {
|
|
|
26
26
|
*/
|
|
27
27
|
invoke(data, options) {
|
|
28
28
|
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
+
console.log('[Link Auth] 🔗 SDK Version: 4.4.8-beta.2 (with enhanced error logging)');
|
|
30
|
+
console.log('[Link Auth] 🔗 invoke() called with data:', JSON.stringify(data, null, 2));
|
|
31
|
+
console.log('[Link Auth] Options:', options ? JSON.stringify({
|
|
32
|
+
pollingInterval: options.pollingInterval,
|
|
33
|
+
maxPollingAttempts: options.maxPollingAttempts,
|
|
34
|
+
pollingEndpoint: options.pollingEndpoint
|
|
35
|
+
}) : 'none');
|
|
29
36
|
// Extract link data from prepare response
|
|
30
37
|
const linkData = data.data;
|
|
31
38
|
if (!linkData || !linkData.url) {
|
|
32
39
|
throw new Error('Invalid link data: missing URL');
|
|
33
40
|
}
|
|
34
41
|
const sessionKey = data.session.session_key;
|
|
42
|
+
console.log('[Link Auth] Session key:', sessionKey);
|
|
43
|
+
console.log('[Link Auth] Link URL:', linkData.url);
|
|
35
44
|
// Open authentication app without navigating away from current page
|
|
36
45
|
this.openAuthenticationLink(linkData.url);
|
|
37
46
|
// Notify that link was opened
|
|
@@ -63,12 +72,19 @@ class LinkHandler {
|
|
|
63
72
|
const interval = (options === null || options === void 0 ? void 0 : options.pollingInterval) || 2000; // Fixed 2 second interval
|
|
64
73
|
const maxAttempts = (options === null || options === void 0 ? void 0 : options.maxPollingAttempts) || 150; // 5 minutes with 2s interval
|
|
65
74
|
let attempts = 0;
|
|
75
|
+
console.log('[Link Auth] 🚀 Starting polling:', {
|
|
76
|
+
sessionKey,
|
|
77
|
+
interval: `${interval}ms`,
|
|
78
|
+
maxAttempts,
|
|
79
|
+
linkDataAvailable: !!linkData
|
|
80
|
+
});
|
|
66
81
|
return new Promise((resolve, reject) => {
|
|
67
82
|
this.isPolling = true;
|
|
68
83
|
const poll = () => __awaiter(this, void 0, void 0, function* () {
|
|
69
84
|
if (!this.isPolling) {
|
|
70
85
|
return; // Polling was stopped
|
|
71
86
|
}
|
|
87
|
+
let statusUrl = ''; // Declare at function scope for catch block access
|
|
72
88
|
try {
|
|
73
89
|
attempts++;
|
|
74
90
|
// Check max attempts
|
|
@@ -87,16 +103,54 @@ class LinkHandler {
|
|
|
87
103
|
return;
|
|
88
104
|
}
|
|
89
105
|
// Build public status endpoint URL
|
|
90
|
-
|
|
91
|
-
//
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
106
|
+
// Use the same priority logic as Desktop strategy:
|
|
107
|
+
// 1. options?.pollingEndpoint (already contains invoke options OR client config from client.ts)
|
|
108
|
+
// 2. Backend-provided status_url from linkData
|
|
109
|
+
// 3. Hardcoded fallback to API server
|
|
110
|
+
let endpoint = options === null || options === void 0 ? void 0 : options.pollingEndpoint;
|
|
111
|
+
let endpointSource = 'options';
|
|
112
|
+
if (!endpoint && linkData.status_url) {
|
|
113
|
+
endpoint = linkData.status_url;
|
|
114
|
+
endpointSource = 'backend';
|
|
115
|
+
}
|
|
116
|
+
console.log('[Link Auth] Polling endpoint selection:');
|
|
117
|
+
console.log(' - options?.pollingEndpoint:', options === null || options === void 0 ? void 0 : options.pollingEndpoint);
|
|
118
|
+
console.log(' - linkData.status_url:', linkData.status_url);
|
|
119
|
+
console.log(' - selected endpoint:', endpoint, 'from source:', endpointSource);
|
|
120
|
+
// Build the status URL based on endpoint format (same as Desktop)
|
|
121
|
+
if (endpoint && (endpoint.startsWith('http://') || endpoint.startsWith('https://'))) {
|
|
122
|
+
// Full URL provided
|
|
123
|
+
if (endpoint.includes('{{session_id}}')) {
|
|
124
|
+
statusUrl = endpoint.replace('{{session_id}}', sessionKey);
|
|
125
|
+
}
|
|
126
|
+
else if (!endpoint.includes(sessionKey)) {
|
|
127
|
+
// If it doesn't already contain the session ID, check if it's a base URL
|
|
128
|
+
const url = new URL(endpoint);
|
|
129
|
+
statusUrl = `${url.protocol}//${url.host}/public/public/status/${sessionKey}`;
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
statusUrl = endpoint;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
else if (endpoint && endpoint !== '') {
|
|
136
|
+
// Relative path provided (e.g. '/api/phone-auth/status')
|
|
137
|
+
const origin = typeof window !== 'undefined' ? window.location.origin : '';
|
|
138
|
+
if (endpoint.includes('{{session_id}}')) {
|
|
139
|
+
statusUrl = origin + endpoint.replace('{{session_id}}', sessionKey);
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
// Append session ID to the provided endpoint
|
|
143
|
+
statusUrl = origin + endpoint + '/' + sessionKey;
|
|
144
|
+
}
|
|
95
145
|
}
|
|
96
146
|
else {
|
|
147
|
+
// No endpoint provided - use hardcoded fallback
|
|
97
148
|
statusUrl = `https://api.glideidentity.app/public/public/status/${sessionKey}`;
|
|
149
|
+
endpointSource = 'fallback';
|
|
98
150
|
}
|
|
151
|
+
console.log(`[Link Auth] Using ${endpointSource} endpoint: ${statusUrl}`);
|
|
99
152
|
// Poll public status endpoint - no authentication required
|
|
153
|
+
console.log(`[Link Auth] Polling status (attempt ${attempts}/${maxAttempts}): ${statusUrl}`);
|
|
100
154
|
const response = yield fetch(statusUrl, {
|
|
101
155
|
method: 'GET',
|
|
102
156
|
headers: {
|
|
@@ -104,12 +158,16 @@ class LinkHandler {
|
|
|
104
158
|
// No Authorization header needed for public endpoint
|
|
105
159
|
}
|
|
106
160
|
});
|
|
161
|
+
console.log(`[Link Auth] Poll response - Status: ${response.status}, OK: ${response.ok}`);
|
|
107
162
|
// Handle based on HTTP status code
|
|
108
163
|
if (response.status === 200) {
|
|
109
164
|
// Session is active (pending or completed)
|
|
110
165
|
const result = yield response.json();
|
|
166
|
+
console.log('[Link Auth] Poll response data:', JSON.stringify(result, null, 2));
|
|
111
167
|
if (result.status === 'completed') {
|
|
112
168
|
// Authentication completed successfully
|
|
169
|
+
console.log('[Link Auth] ✅ Authentication COMPLETED! Session:', sessionKey);
|
|
170
|
+
console.log('[Link Auth] Full completion result:', JSON.stringify(result, null, 2));
|
|
113
171
|
this.stopPolling();
|
|
114
172
|
// Authentication completed successfully
|
|
115
173
|
if (options === null || options === void 0 ? void 0 : options.onStatusUpdate) {
|
|
@@ -134,6 +192,7 @@ class LinkHandler {
|
|
|
134
192
|
}
|
|
135
193
|
else if (result.status === 'pending') {
|
|
136
194
|
// Continue polling
|
|
195
|
+
console.log('[Link Auth] Status still pending, continuing to poll...');
|
|
137
196
|
if (options === null || options === void 0 ? void 0 : options.onStatusUpdate) {
|
|
138
197
|
options.onStatusUpdate({
|
|
139
198
|
status: 'pending',
|
|
@@ -141,9 +200,14 @@ class LinkHandler {
|
|
|
141
200
|
});
|
|
142
201
|
}
|
|
143
202
|
}
|
|
203
|
+
else {
|
|
204
|
+
// Unexpected status value
|
|
205
|
+
console.log('[Link Auth] ⚠️ Unexpected status value:', result.status, 'Full result:', JSON.stringify(result, null, 2));
|
|
206
|
+
}
|
|
144
207
|
}
|
|
145
208
|
else if (response.status === 410) {
|
|
146
209
|
// Session expired
|
|
210
|
+
console.log('[Link Auth] ❌ Session expired (410)');
|
|
147
211
|
this.stopPolling();
|
|
148
212
|
const errorData = yield response.json().catch(() => ({ message: 'Session expired' }));
|
|
149
213
|
if (options === null || options === void 0 ? void 0 : options.onTimeout) {
|
|
@@ -159,8 +223,10 @@ class LinkHandler {
|
|
|
159
223
|
}
|
|
160
224
|
else if (response.status === 422) {
|
|
161
225
|
// Authentication failed
|
|
226
|
+
console.log('[Link Auth] ❌ Authentication failed (422)');
|
|
162
227
|
this.stopPolling();
|
|
163
228
|
const errorData = yield response.json().catch(() => ({ message: 'Authentication failed' }));
|
|
229
|
+
console.log('[Link Auth] Error data:', JSON.stringify(errorData, null, 2));
|
|
164
230
|
const isUserCancelled = errorData.code === 'USER_CANCELLED';
|
|
165
231
|
const errorMsg = isUserCancelled
|
|
166
232
|
? 'User cancelled authentication'
|
|
@@ -176,6 +242,7 @@ class LinkHandler {
|
|
|
176
242
|
}
|
|
177
243
|
else if (response.status === 404) {
|
|
178
244
|
// Session not found
|
|
245
|
+
console.log('[Link Auth] ❌ Session not found (404)');
|
|
179
246
|
this.stopPolling();
|
|
180
247
|
if (options === null || options === void 0 ? void 0 : options.onStatusUpdate) {
|
|
181
248
|
options.onStatusUpdate({
|
|
@@ -187,16 +254,40 @@ class LinkHandler {
|
|
|
187
254
|
}
|
|
188
255
|
else if (response.status === 400) {
|
|
189
256
|
// Invalid session key
|
|
257
|
+
console.log('[Link Auth] ❌ Invalid session key (400)');
|
|
190
258
|
this.stopPolling();
|
|
191
259
|
const errorData = yield response.json().catch(() => ({ message: 'Invalid session key' }));
|
|
260
|
+
console.log('[Link Auth] Error data:', JSON.stringify(errorData, null, 2));
|
|
192
261
|
reject(new Error(errorData.message || 'Invalid session key'));
|
|
193
262
|
}
|
|
194
263
|
else {
|
|
195
264
|
// Unexpected status - continue polling
|
|
265
|
+
console.log('[Link Auth] ⚠️ Unexpected HTTP status:', response.status, 'continuing to poll...');
|
|
266
|
+
try {
|
|
267
|
+
const body = yield response.text();
|
|
268
|
+
console.log('[Link Auth] Response body:', body);
|
|
269
|
+
}
|
|
270
|
+
catch (e) {
|
|
271
|
+
console.log('[Link Auth] Could not read response body');
|
|
272
|
+
}
|
|
196
273
|
}
|
|
197
274
|
}
|
|
198
275
|
catch (error) {
|
|
199
276
|
// Network or other error - continue polling
|
|
277
|
+
console.error('[Link Auth] 🔴 Polling error:', error.message || error);
|
|
278
|
+
console.error('[Link Auth] Error details:', {
|
|
279
|
+
name: error.name,
|
|
280
|
+
message: error.message,
|
|
281
|
+
stack: error.stack,
|
|
282
|
+
statusUrl: statusUrl,
|
|
283
|
+
attempt: attempts,
|
|
284
|
+
error: error
|
|
285
|
+
});
|
|
286
|
+
// Check if it's a CORS error (common on mobile)
|
|
287
|
+
if (error.message && error.message.toLowerCase().includes('failed')) {
|
|
288
|
+
console.error('[Link Auth] ⚠️ Possible CORS issue. Status URL:', statusUrl);
|
|
289
|
+
console.error('[Link Auth] Make sure the API endpoint allows CORS from your ngrok domain');
|
|
290
|
+
}
|
|
200
291
|
if (options === null || options === void 0 ? void 0 : options.onStatusUpdate) {
|
|
201
292
|
options.onStatusUpdate({
|
|
202
293
|
status: 'pending',
|
|
@@ -216,6 +307,7 @@ class LinkHandler {
|
|
|
216
307
|
* Stop polling
|
|
217
308
|
*/
|
|
218
309
|
stopPolling() {
|
|
310
|
+
console.log('[Link Auth] 🏁 Stopping polling');
|
|
219
311
|
this.isPolling = false;
|
|
220
312
|
if (this.pollingInterval) {
|
|
221
313
|
clearInterval(this.pollingInterval);
|
package/dist/core/version.js
CHANGED
|
@@ -478,7 +478,7 @@ export class PhoneAuthClient {
|
|
|
478
478
|
// This ensures we work with plain objects for browser APIs
|
|
479
479
|
// Vue's reactivity system wraps objects in Proxies which can interfere
|
|
480
480
|
// with browser APIs like Digital Credentials API that expect plain objects
|
|
481
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
481
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
482
482
|
// Try structuredClone first (modern browsers), but catch errors and fallback to JSON method
|
|
483
483
|
let plainResponse;
|
|
484
484
|
try {
|
|
@@ -864,13 +864,19 @@ export class PhoneAuthClient {
|
|
|
864
864
|
triggerLink();
|
|
865
865
|
}
|
|
866
866
|
// Start polling in the background
|
|
867
|
+
console.log('[PhoneAuth Client] Link polling config:', {
|
|
868
|
+
fromInvokeOptions: invokeOptions === null || invokeOptions === void 0 ? void 0 : invokeOptions.pollingEndpoint,
|
|
869
|
+
fromClientConfig: (_o = this.config.endpoints) === null || _o === void 0 ? void 0 : _o.polling,
|
|
870
|
+
finalPollingEndpoint: (invokeOptions === null || invokeOptions === void 0 ? void 0 : invokeOptions.pollingEndpoint) || ((_p = this.config.endpoints) === null || _p === void 0 ? void 0 : _p.polling)
|
|
871
|
+
});
|
|
867
872
|
const pollingOptions = {
|
|
868
|
-
pollingEndpoint: (invokeOptions === null || invokeOptions === void 0 ? void 0 : invokeOptions.pollingEndpoint) || ((
|
|
873
|
+
pollingEndpoint: (invokeOptions === null || invokeOptions === void 0 ? void 0 : invokeOptions.pollingEndpoint) || ((_q = this.config.endpoints) === null || _q === void 0 ? void 0 : _q.polling),
|
|
869
874
|
pollingInterval: (invokeOptions === null || invokeOptions === void 0 ? void 0 : invokeOptions.pollingInterval) || this.config.pollingInterval || 2000,
|
|
870
875
|
maxPollingAttempts: (invokeOptions === null || invokeOptions === void 0 ? void 0 : invokeOptions.maxPollingAttempts) || this.config.maxPollingAttempts || 150,
|
|
871
876
|
onLinkOpened: undefined,
|
|
872
877
|
onStatusUpdate: undefined
|
|
873
878
|
};
|
|
879
|
+
console.log('[PhoneAuth Client] Final Link polling options:', pollingOptions);
|
|
874
880
|
// Create credential promise
|
|
875
881
|
const credentialPromise = handler.invoke(plainResponse, pollingOptions).then(result => {
|
|
876
882
|
if (result.authenticated && result.credential) {
|
|
@@ -23,12 +23,21 @@ export class LinkHandler {
|
|
|
23
23
|
*/
|
|
24
24
|
invoke(data, options) {
|
|
25
25
|
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
+
console.log('[Link Auth] 🔗 SDK Version: 4.4.8-beta.2 (with enhanced error logging)');
|
|
27
|
+
console.log('[Link Auth] 🔗 invoke() called with data:', JSON.stringify(data, null, 2));
|
|
28
|
+
console.log('[Link Auth] Options:', options ? JSON.stringify({
|
|
29
|
+
pollingInterval: options.pollingInterval,
|
|
30
|
+
maxPollingAttempts: options.maxPollingAttempts,
|
|
31
|
+
pollingEndpoint: options.pollingEndpoint
|
|
32
|
+
}) : 'none');
|
|
26
33
|
// Extract link data from prepare response
|
|
27
34
|
const linkData = data.data;
|
|
28
35
|
if (!linkData || !linkData.url) {
|
|
29
36
|
throw new Error('Invalid link data: missing URL');
|
|
30
37
|
}
|
|
31
38
|
const sessionKey = data.session.session_key;
|
|
39
|
+
console.log('[Link Auth] Session key:', sessionKey);
|
|
40
|
+
console.log('[Link Auth] Link URL:', linkData.url);
|
|
32
41
|
// Open authentication app without navigating away from current page
|
|
33
42
|
this.openAuthenticationLink(linkData.url);
|
|
34
43
|
// Notify that link was opened
|
|
@@ -60,12 +69,19 @@ export class LinkHandler {
|
|
|
60
69
|
const interval = (options === null || options === void 0 ? void 0 : options.pollingInterval) || 2000; // Fixed 2 second interval
|
|
61
70
|
const maxAttempts = (options === null || options === void 0 ? void 0 : options.maxPollingAttempts) || 150; // 5 minutes with 2s interval
|
|
62
71
|
let attempts = 0;
|
|
72
|
+
console.log('[Link Auth] 🚀 Starting polling:', {
|
|
73
|
+
sessionKey,
|
|
74
|
+
interval: `${interval}ms`,
|
|
75
|
+
maxAttempts,
|
|
76
|
+
linkDataAvailable: !!linkData
|
|
77
|
+
});
|
|
63
78
|
return new Promise((resolve, reject) => {
|
|
64
79
|
this.isPolling = true;
|
|
65
80
|
const poll = () => __awaiter(this, void 0, void 0, function* () {
|
|
66
81
|
if (!this.isPolling) {
|
|
67
82
|
return; // Polling was stopped
|
|
68
83
|
}
|
|
84
|
+
let statusUrl = ''; // Declare at function scope for catch block access
|
|
69
85
|
try {
|
|
70
86
|
attempts++;
|
|
71
87
|
// Check max attempts
|
|
@@ -84,16 +100,54 @@ export class LinkHandler {
|
|
|
84
100
|
return;
|
|
85
101
|
}
|
|
86
102
|
// Build public status endpoint URL
|
|
87
|
-
|
|
88
|
-
//
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
103
|
+
// Use the same priority logic as Desktop strategy:
|
|
104
|
+
// 1. options?.pollingEndpoint (already contains invoke options OR client config from client.ts)
|
|
105
|
+
// 2. Backend-provided status_url from linkData
|
|
106
|
+
// 3. Hardcoded fallback to API server
|
|
107
|
+
let endpoint = options === null || options === void 0 ? void 0 : options.pollingEndpoint;
|
|
108
|
+
let endpointSource = 'options';
|
|
109
|
+
if (!endpoint && linkData.status_url) {
|
|
110
|
+
endpoint = linkData.status_url;
|
|
111
|
+
endpointSource = 'backend';
|
|
112
|
+
}
|
|
113
|
+
console.log('[Link Auth] Polling endpoint selection:');
|
|
114
|
+
console.log(' - options?.pollingEndpoint:', options === null || options === void 0 ? void 0 : options.pollingEndpoint);
|
|
115
|
+
console.log(' - linkData.status_url:', linkData.status_url);
|
|
116
|
+
console.log(' - selected endpoint:', endpoint, 'from source:', endpointSource);
|
|
117
|
+
// Build the status URL based on endpoint format (same as Desktop)
|
|
118
|
+
if (endpoint && (endpoint.startsWith('http://') || endpoint.startsWith('https://'))) {
|
|
119
|
+
// Full URL provided
|
|
120
|
+
if (endpoint.includes('{{session_id}}')) {
|
|
121
|
+
statusUrl = endpoint.replace('{{session_id}}', sessionKey);
|
|
122
|
+
}
|
|
123
|
+
else if (!endpoint.includes(sessionKey)) {
|
|
124
|
+
// If it doesn't already contain the session ID, check if it's a base URL
|
|
125
|
+
const url = new URL(endpoint);
|
|
126
|
+
statusUrl = `${url.protocol}//${url.host}/public/public/status/${sessionKey}`;
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
statusUrl = endpoint;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
else if (endpoint && endpoint !== '') {
|
|
133
|
+
// Relative path provided (e.g. '/api/phone-auth/status')
|
|
134
|
+
const origin = typeof window !== 'undefined' ? window.location.origin : '';
|
|
135
|
+
if (endpoint.includes('{{session_id}}')) {
|
|
136
|
+
statusUrl = origin + endpoint.replace('{{session_id}}', sessionKey);
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
// Append session ID to the provided endpoint
|
|
140
|
+
statusUrl = origin + endpoint + '/' + sessionKey;
|
|
141
|
+
}
|
|
92
142
|
}
|
|
93
143
|
else {
|
|
144
|
+
// No endpoint provided - use hardcoded fallback
|
|
94
145
|
statusUrl = `https://api.glideidentity.app/public/public/status/${sessionKey}`;
|
|
146
|
+
endpointSource = 'fallback';
|
|
95
147
|
}
|
|
148
|
+
console.log(`[Link Auth] Using ${endpointSource} endpoint: ${statusUrl}`);
|
|
96
149
|
// Poll public status endpoint - no authentication required
|
|
150
|
+
console.log(`[Link Auth] Polling status (attempt ${attempts}/${maxAttempts}): ${statusUrl}`);
|
|
97
151
|
const response = yield fetch(statusUrl, {
|
|
98
152
|
method: 'GET',
|
|
99
153
|
headers: {
|
|
@@ -101,12 +155,16 @@ export class LinkHandler {
|
|
|
101
155
|
// No Authorization header needed for public endpoint
|
|
102
156
|
}
|
|
103
157
|
});
|
|
158
|
+
console.log(`[Link Auth] Poll response - Status: ${response.status}, OK: ${response.ok}`);
|
|
104
159
|
// Handle based on HTTP status code
|
|
105
160
|
if (response.status === 200) {
|
|
106
161
|
// Session is active (pending or completed)
|
|
107
162
|
const result = yield response.json();
|
|
163
|
+
console.log('[Link Auth] Poll response data:', JSON.stringify(result, null, 2));
|
|
108
164
|
if (result.status === 'completed') {
|
|
109
165
|
// Authentication completed successfully
|
|
166
|
+
console.log('[Link Auth] ✅ Authentication COMPLETED! Session:', sessionKey);
|
|
167
|
+
console.log('[Link Auth] Full completion result:', JSON.stringify(result, null, 2));
|
|
110
168
|
this.stopPolling();
|
|
111
169
|
// Authentication completed successfully
|
|
112
170
|
if (options === null || options === void 0 ? void 0 : options.onStatusUpdate) {
|
|
@@ -131,6 +189,7 @@ export class LinkHandler {
|
|
|
131
189
|
}
|
|
132
190
|
else if (result.status === 'pending') {
|
|
133
191
|
// Continue polling
|
|
192
|
+
console.log('[Link Auth] Status still pending, continuing to poll...');
|
|
134
193
|
if (options === null || options === void 0 ? void 0 : options.onStatusUpdate) {
|
|
135
194
|
options.onStatusUpdate({
|
|
136
195
|
status: 'pending',
|
|
@@ -138,9 +197,14 @@ export class LinkHandler {
|
|
|
138
197
|
});
|
|
139
198
|
}
|
|
140
199
|
}
|
|
200
|
+
else {
|
|
201
|
+
// Unexpected status value
|
|
202
|
+
console.log('[Link Auth] ⚠️ Unexpected status value:', result.status, 'Full result:', JSON.stringify(result, null, 2));
|
|
203
|
+
}
|
|
141
204
|
}
|
|
142
205
|
else if (response.status === 410) {
|
|
143
206
|
// Session expired
|
|
207
|
+
console.log('[Link Auth] ❌ Session expired (410)');
|
|
144
208
|
this.stopPolling();
|
|
145
209
|
const errorData = yield response.json().catch(() => ({ message: 'Session expired' }));
|
|
146
210
|
if (options === null || options === void 0 ? void 0 : options.onTimeout) {
|
|
@@ -156,8 +220,10 @@ export class LinkHandler {
|
|
|
156
220
|
}
|
|
157
221
|
else if (response.status === 422) {
|
|
158
222
|
// Authentication failed
|
|
223
|
+
console.log('[Link Auth] ❌ Authentication failed (422)');
|
|
159
224
|
this.stopPolling();
|
|
160
225
|
const errorData = yield response.json().catch(() => ({ message: 'Authentication failed' }));
|
|
226
|
+
console.log('[Link Auth] Error data:', JSON.stringify(errorData, null, 2));
|
|
161
227
|
const isUserCancelled = errorData.code === 'USER_CANCELLED';
|
|
162
228
|
const errorMsg = isUserCancelled
|
|
163
229
|
? 'User cancelled authentication'
|
|
@@ -173,6 +239,7 @@ export class LinkHandler {
|
|
|
173
239
|
}
|
|
174
240
|
else if (response.status === 404) {
|
|
175
241
|
// Session not found
|
|
242
|
+
console.log('[Link Auth] ❌ Session not found (404)');
|
|
176
243
|
this.stopPolling();
|
|
177
244
|
if (options === null || options === void 0 ? void 0 : options.onStatusUpdate) {
|
|
178
245
|
options.onStatusUpdate({
|
|
@@ -184,16 +251,40 @@ export class LinkHandler {
|
|
|
184
251
|
}
|
|
185
252
|
else if (response.status === 400) {
|
|
186
253
|
// Invalid session key
|
|
254
|
+
console.log('[Link Auth] ❌ Invalid session key (400)');
|
|
187
255
|
this.stopPolling();
|
|
188
256
|
const errorData = yield response.json().catch(() => ({ message: 'Invalid session key' }));
|
|
257
|
+
console.log('[Link Auth] Error data:', JSON.stringify(errorData, null, 2));
|
|
189
258
|
reject(new Error(errorData.message || 'Invalid session key'));
|
|
190
259
|
}
|
|
191
260
|
else {
|
|
192
261
|
// Unexpected status - continue polling
|
|
262
|
+
console.log('[Link Auth] ⚠️ Unexpected HTTP status:', response.status, 'continuing to poll...');
|
|
263
|
+
try {
|
|
264
|
+
const body = yield response.text();
|
|
265
|
+
console.log('[Link Auth] Response body:', body);
|
|
266
|
+
}
|
|
267
|
+
catch (e) {
|
|
268
|
+
console.log('[Link Auth] Could not read response body');
|
|
269
|
+
}
|
|
193
270
|
}
|
|
194
271
|
}
|
|
195
272
|
catch (error) {
|
|
196
273
|
// Network or other error - continue polling
|
|
274
|
+
console.error('[Link Auth] 🔴 Polling error:', error.message || error);
|
|
275
|
+
console.error('[Link Auth] Error details:', {
|
|
276
|
+
name: error.name,
|
|
277
|
+
message: error.message,
|
|
278
|
+
stack: error.stack,
|
|
279
|
+
statusUrl: statusUrl,
|
|
280
|
+
attempt: attempts,
|
|
281
|
+
error: error
|
|
282
|
+
});
|
|
283
|
+
// Check if it's a CORS error (common on mobile)
|
|
284
|
+
if (error.message && error.message.toLowerCase().includes('failed')) {
|
|
285
|
+
console.error('[Link Auth] ⚠️ Possible CORS issue. Status URL:', statusUrl);
|
|
286
|
+
console.error('[Link Auth] Make sure the API endpoint allows CORS from your ngrok domain');
|
|
287
|
+
}
|
|
197
288
|
if (options === null || options === void 0 ? void 0 : options.onStatusUpdate) {
|
|
198
289
|
options.onStatusUpdate({
|
|
199
290
|
status: 'pending',
|
|
@@ -213,6 +304,7 @@ export class LinkHandler {
|
|
|
213
304
|
* Stop polling
|
|
214
305
|
*/
|
|
215
306
|
stopPolling() {
|
|
307
|
+
console.log('[Link Auth] 🏁 Stopping polling');
|
|
216
308
|
this.isPolling = false;
|
|
217
309
|
if (this.pollingInterval) {
|
|
218
310
|
clearInterval(this.pollingInterval);
|
package/dist/esm/core/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// SDK version - injected at build time
|
|
2
|
-
export const SDK_VERSION = '4.4.8-beta.
|
|
2
|
+
export const SDK_VERSION = '4.4.8-beta.3';
|